···23272327 FDI_FE_ERRC_ENABLE);23282328}2329232923302330-static bool pipe_has_enabled_pch(struct intel_crtc *intel_crtc)23302330+static bool pipe_has_enabled_pch(struct intel_crtc *crtc)23312331{23322332- return intel_crtc->base.enabled && intel_crtc->config.has_pch_encoder;23322332+ return crtc->base.enabled && crtc->active &&23332333+ crtc->config.has_pch_encoder;23332334}2334233523352336static void ivb_modeset_global_resources(struct drm_device *dev)···29802979 I915_READ(VSYNCSHIFT(cpu_transcoder)));29812980}2982298129822982+static void cpt_enable_fdi_bc_bifurcation(struct drm_device *dev)29832983+{29842984+ struct drm_i915_private *dev_priv = dev->dev_private;29852985+ uint32_t temp;29862986+29872987+ temp = I915_READ(SOUTH_CHICKEN1);29882988+ if (temp & FDI_BC_BIFURCATION_SELECT)29892989+ return;29902990+29912991+ WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);29922992+ WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);29932993+29942994+ temp |= FDI_BC_BIFURCATION_SELECT;29952995+ DRM_DEBUG_KMS("enabling fdi C rx\n");29962996+ I915_WRITE(SOUTH_CHICKEN1, temp);29972997+ POSTING_READ(SOUTH_CHICKEN1);29982998+}29992999+30003000+static void ivybridge_update_fdi_bc_bifurcation(struct intel_crtc *intel_crtc)30013001+{30023002+ struct drm_device *dev = intel_crtc->base.dev;30033003+ struct drm_i915_private *dev_priv = dev->dev_private;30043004+30053005+ switch (intel_crtc->pipe) {30063006+ case PIPE_A:30073007+ break;30083008+ case PIPE_B:30093009+ if (intel_crtc->config.fdi_lanes > 2)30103010+ WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);30113011+ else30123012+ cpt_enable_fdi_bc_bifurcation(dev);30133013+30143014+ break;30153015+ case PIPE_C:30163016+ cpt_enable_fdi_bc_bifurcation(dev);30173017+30183018+ break;30193019+ default:30203020+ BUG();30213021+ }30223022+}30233023+29833024/*29843025 * Enable PCH resources required for PCH ports:29853026 * - PCH PLLs···30392996 u32 reg, temp;3040299730412998 assert_pch_transcoder_disabled(dev_priv, pipe);29992999+30003000+ if (IS_IVYBRIDGE(dev))30013001+ ivybridge_update_fdi_bc_bifurcation(intel_crtc);3042300230433003 /* Write the TU size bits before fdi link training, so that error30443004 * detection works. */···50294983 if (!(tmp & PIPECONF_ENABLE))50304984 return false;5031498549864986+ if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) {49874987+ switch (tmp & PIPECONF_BPC_MASK) {49884988+ case PIPECONF_6BPC:49894989+ pipe_config->pipe_bpp = 18;49904990+ break;49914991+ case PIPECONF_8BPC:49924992+ pipe_config->pipe_bpp = 24;49934993+ break;49944994+ case PIPECONF_10BPC:49954995+ pipe_config->pipe_bpp = 30;49964996+ break;49974997+ default:49984998+ break;49994999+ }50005000+ }50015001+50325002 intel_get_pipe_timings(crtc, pipe_config);5033500350345004 i9xx_get_pfit_config(crtc, pipe_config);···56385576 return true;56395577}5640557856415641-static void cpt_enable_fdi_bc_bifurcation(struct drm_device *dev)56425642-{56435643- struct drm_i915_private *dev_priv = dev->dev_private;56445644- uint32_t temp;56455645-56465646- temp = I915_READ(SOUTH_CHICKEN1);56475647- if (temp & FDI_BC_BIFURCATION_SELECT)56485648- return;56495649-56505650- WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);56515651- WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);56525652-56535653- temp |= FDI_BC_BIFURCATION_SELECT;56545654- DRM_DEBUG_KMS("enabling fdi C rx\n");56555655- I915_WRITE(SOUTH_CHICKEN1, temp);56565656- POSTING_READ(SOUTH_CHICKEN1);56575657-}56585658-56595659-static void ivybridge_update_fdi_bc_bifurcation(struct intel_crtc *intel_crtc)56605660-{56615661- struct drm_device *dev = intel_crtc->base.dev;56625662- struct drm_i915_private *dev_priv = dev->dev_private;56635663-56645664- switch (intel_crtc->pipe) {56655665- case PIPE_A:56665666- break;56675667- case PIPE_B:56685668- if (intel_crtc->config.fdi_lanes > 2)56695669- WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);56705670- else56715671- cpt_enable_fdi_bc_bifurcation(dev);56725672-56735673- break;56745674- case PIPE_C:56755675- cpt_enable_fdi_bc_bifurcation(dev);56765676-56775677- break;56785678- default:56795679- BUG();56805680- }56815681-}56825682-56835579int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp)56845580{56855581 /*···58315811 &intel_crtc->config.fdi_m_n);58325812 }5833581358345834- if (IS_IVYBRIDGE(dev))58355835- ivybridge_update_fdi_bc_bifurcation(intel_crtc);58365836-58375814 ironlake_set_pipeconf(crtc);5838581558395816 /* Set up the display plane register */···58975880 tmp = I915_READ(PIPECONF(crtc->pipe));58985881 if (!(tmp & PIPECONF_ENABLE))58995882 return false;58835883+58845884+ switch (tmp & PIPECONF_BPC_MASK) {58855885+ case PIPECONF_6BPC:58865886+ pipe_config->pipe_bpp = 18;58875887+ break;58885888+ case PIPECONF_8BPC:58895889+ pipe_config->pipe_bpp = 24;58905890+ break;58915891+ case PIPECONF_10BPC:58925892+ pipe_config->pipe_bpp = 30;58935893+ break;58945894+ case PIPECONF_12BPC:58955895+ pipe_config->pipe_bpp = 36;58965896+ break;58975897+ default:58985898+ break;58995899+ }5900590059015901 if (I915_READ(PCH_TRANSCONF(crtc->pipe)) & TRANS_ENABLE) {59025902 struct intel_shared_dpll *pll;···86458611 PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md);86468612 PIPE_CONF_CHECK_X(dpll_hw_state.fp0);86478613 PIPE_CONF_CHECK_X(dpll_hw_state.fp1);86148614+86158615+ if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5)86168616+ PIPE_CONF_CHECK_I(pipe_bpp);8648861786498618#undef PIPE_CONF_CHECK_X86508619#undef PIPE_CONF_CHECK_I
+20
drivers/gpu/drm/i915/intel_dp.c
···14011401 else14021402 pipe_config->port_clock = 270000;14031403 }14041404+14051405+ if (is_edp(intel_dp) && dev_priv->vbt.edp_bpp &&14061406+ pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) {14071407+ /*14081408+ * This is a big fat ugly hack.14091409+ *14101410+ * Some machines in UEFI boot mode provide us a VBT that has 1814111411+ * bpp and 1.62 GHz link bandwidth for eDP, which for reasons14121412+ * unknown we fail to light up. Yet the same BIOS boots up with14131413+ * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as14141414+ * max, not what it tells us to use.14151415+ *14161416+ * Note: This will still be broken if the eDP panel is not lit14171417+ * up by the BIOS, and thus we can't get the mode at module14181418+ * load.14191419+ */14201420+ DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n",14211421+ pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp);14221422+ dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;14231423+ }14041424}1405142514061426static bool is_edp_psr(struct intel_dp *intel_dp)
···17341734 */17351735struct input_dev *input_allocate_device(void)17361736{17371737+ static atomic_t input_no = ATOMIC_INIT(0);17371738 struct input_dev *dev;1738173917391740 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);···17441743 device_initialize(&dev->dev);17451744 mutex_init(&dev->mutex);17461745 spin_lock_init(&dev->event_lock);17461746+ init_timer(&dev->timer);17471747 INIT_LIST_HEAD(&dev->h_list);17481748 INIT_LIST_HEAD(&dev->node);17491749+17501750+ dev_set_name(&dev->dev, "input%ld",17511751+ (unsigned long) atomic_inc_return(&input_no) - 1);1749175217501753 __module_get(THIS_MODULE);17511754 }···20242019 */20252020int input_register_device(struct input_dev *dev)20262021{20272027- static atomic_t input_no = ATOMIC_INIT(0);20282022 struct input_devres *devres = NULL;20292023 struct input_handler *handler;20302024 unsigned int packet_size;···20632059 * If delay and period are pre-set by the driver, then autorepeating20642060 * is handled by the driver itself and we don't do it in input.c.20652061 */20662066- init_timer(&dev->timer);20672062 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {20682063 dev->timer.data = (long) dev;20692064 dev->timer.function = input_repeat_key;···2075207220762073 if (!dev->setkeycode)20772074 dev->setkeycode = input_default_setkeycode;20782078-20792079- dev_set_name(&dev->dev, "input%ld",20802080- (unsigned long) atomic_inc_return(&input_no) - 1);2081207520822076 error = device_add(&dev->dev);20832077 if (error)
+9-2
drivers/input/keyboard/pxa27x_keypad.c
···786786 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);787787 input_set_capability(input_dev, EV_MSC, MSC_SCAN);788788789789- if (pdata)789789+ if (pdata) {790790 error = pxa27x_keypad_build_keycode(keypad);791791- else791791+ } else {792792 error = pxa27x_keypad_build_keycode_from_dt(keypad);793793+ /*794794+ * Data that we get from DT resides in dynamically795795+ * allocated memory so we need to update our pdata796796+ * pointer.797797+ */798798+ pdata = keypad->pdata;799799+ }793800 if (error) {794801 dev_err(&pdev->dev, "failed to build keycode\n");795802 goto failed_put_clk;
+10-4
drivers/input/misc/cm109.c
···351351 if (status) {352352 if (status == -ESHUTDOWN)353353 return;354354- dev_err(&dev->intf->dev, "%s: urb status %d\n", __func__, status);354354+ dev_err_ratelimited(&dev->intf->dev, "%s: urb status %d\n",355355+ __func__, status);356356+ goto out;355357 }356358357359 /* Special keys */···420418 dev->ctl_data->byte[2],421419 dev->ctl_data->byte[3]);422420423423- if (status)424424- dev_err(&dev->intf->dev, "%s: urb status %d\n", __func__, status);421421+ if (status) {422422+ if (status == -ESHUTDOWN)423423+ return;424424+ dev_err_ratelimited(&dev->intf->dev, "%s: urb status %d\n",425425+ __func__, status);426426+ }425427426428 spin_lock(&dev->ctl_submit_lock);427429···433427434428 if (likely(!dev->shutdown)) {435429436436- if (dev->buzzer_pending) {430430+ if (dev->buzzer_pending || status) {437431 dev->buzzer_pending = 0;438432 dev->ctl_urb_pending = 1;439433 cm109_submit_buzz_toggle(dev);
···552552 struct acpiphp_func *func;553553 int max, pass;554554 LIST_HEAD(add_list);555555- int nr_found;556555557557- nr_found = acpiphp_rescan_slot(slot);556556+ acpiphp_rescan_slot(slot);558557 max = acpiphp_max_busnr(bus);559558 for (pass = 0; pass < 2; pass++) {560559 list_for_each_entry(dev, &bus->devices, bus_list) {···573574 }574575 }575576 __pci_bus_assign_resources(bus, &add_list, NULL);576576- /* Nothing more to do here if there are no new devices on this bus. */577577- if (!nr_found && (slot->flags & SLOT_ENABLED))578578- return;579577580578 acpiphp_sanitize_bus(bus);581579 acpiphp_set_hpp_values(bus);
+2
drivers/scsi/aacraid/linit.c
···771771static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)772772{773773 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;774774+ if (!capable(CAP_SYS_RAWIO))775775+ return -EPERM;774776 return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg);775777}776778
+95-81
drivers/scsi/sg.c
···105105static int sg_add(struct device *, struct class_interface *);106106static void sg_remove(struct device *, struct class_interface *);107107108108+static DEFINE_SPINLOCK(sg_open_exclusive_lock);109109+108110static DEFINE_IDR(sg_index_idr);109109-static DEFINE_RWLOCK(sg_index_lock);111111+static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock112112+ file descriptor list for device */110113111114static struct class_interface sg_interface = {112115 .add_dev = sg_add,···146143} Sg_request;147144148145typedef struct sg_fd { /* holds the state of a file descriptor */149149- struct list_head sfd_siblings; /* protected by sfd_lock of device */146146+ /* sfd_siblings is protected by sg_index_lock */147147+ struct list_head sfd_siblings;150148 struct sg_device *parentdp; /* owning device */151149 wait_queue_head_t read_wait; /* queue read until command done */152150 rwlock_t rq_list_lock; /* protect access to list in req_arr */···170166171167typedef struct sg_device { /* holds the state of each scsi generic device */172168 struct scsi_device *device;169169+ wait_queue_head_t o_excl_wait; /* queue open() when O_EXCL in use */173170 int sg_tablesize; /* adapter's max scatter-gather table size */174171 u32 index; /* device index number */175175- spinlock_t sfd_lock; /* protect file descriptor list for device */172172+ /* sfds is protected by sg_index_lock */176173 struct list_head sfds;177177- struct rw_semaphore o_sem; /* exclude open should hold this rwsem */178174 volatile char detached; /* 0->attached, 1->detached pending removal */175175+ /* exclude protected by sg_open_exclusive_lock */179176 char exclude; /* opened for exclusive access */180177 char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */181178 struct gendisk *disk;···225220 return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);226221}227222223223+static int get_exclude(Sg_device *sdp)224224+{225225+ unsigned long flags;226226+ int ret;227227+228228+ spin_lock_irqsave(&sg_open_exclusive_lock, flags);229229+ ret = sdp->exclude;230230+ spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);231231+ return ret;232232+}233233+234234+static int set_exclude(Sg_device *sdp, char val)235235+{236236+ unsigned long flags;237237+238238+ spin_lock_irqsave(&sg_open_exclusive_lock, flags);239239+ sdp->exclude = val;240240+ spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);241241+ return val;242242+}243243+228244static int sfds_list_empty(Sg_device *sdp)229245{230246 unsigned long flags;231247 int ret;232248233233- spin_lock_irqsave(&sdp->sfd_lock, flags);249249+ read_lock_irqsave(&sg_index_lock, flags);234250 ret = list_empty(&sdp->sfds);235235- spin_unlock_irqrestore(&sdp->sfd_lock, flags);251251+ read_unlock_irqrestore(&sg_index_lock, flags);236252 return ret;237253}238254···265239 struct request_queue *q;266240 Sg_device *sdp;267241 Sg_fd *sfp;242242+ int res;268243 int retval;269244270245 nonseekable_open(inode, filp);···294267 goto error_out;295268 }296269297297- if ((flags & O_EXCL) && (O_RDONLY == (flags & O_ACCMODE))) {298298- retval = -EPERM; /* Can't lock it with read only access */270270+ if (flags & O_EXCL) {271271+ if (O_RDONLY == (flags & O_ACCMODE)) {272272+ retval = -EPERM; /* Can't lock it with read only access */273273+ goto error_out;274274+ }275275+ if (!sfds_list_empty(sdp) && (flags & O_NONBLOCK)) {276276+ retval = -EBUSY;277277+ goto error_out;278278+ }279279+ res = wait_event_interruptible(sdp->o_excl_wait,280280+ ((!sfds_list_empty(sdp) || get_exclude(sdp)) ? 0 : set_exclude(sdp, 1)));281281+ if (res) {282282+ retval = res; /* -ERESTARTSYS because signal hit process */283283+ goto error_out;284284+ }285285+ } else if (get_exclude(sdp)) { /* some other fd has an exclusive lock on dev */286286+ if (flags & O_NONBLOCK) {287287+ retval = -EBUSY;288288+ goto error_out;289289+ }290290+ res = wait_event_interruptible(sdp->o_excl_wait, !get_exclude(sdp));291291+ if (res) {292292+ retval = res; /* -ERESTARTSYS because signal hit process */293293+ goto error_out;294294+ }295295+ }296296+ if (sdp->detached) {297297+ retval = -ENODEV;299298 goto error_out;300299 }301301- if (flags & O_NONBLOCK) {302302- if (flags & O_EXCL) {303303- if (!down_write_trylock(&sdp->o_sem)) {304304- retval = -EBUSY;305305- goto error_out;306306- }307307- } else {308308- if (!down_read_trylock(&sdp->o_sem)) {309309- retval = -EBUSY;310310- goto error_out;311311- }312312- }313313- } else {314314- if (flags & O_EXCL)315315- down_write(&sdp->o_sem);316316- else317317- down_read(&sdp->o_sem);318318- }319319- /* Since write lock is held, no need to check sfd_list */320320- if (flags & O_EXCL)321321- sdp->exclude = 1; /* used by release lock */322322-323300 if (sfds_list_empty(sdp)) { /* no existing opens on this device */324301 sdp->sgdebug = 0;325302 q = sdp->device->request_queue;326303 sdp->sg_tablesize = queue_max_segments(q);327304 }328328- sfp = sg_add_sfp(sdp, dev);329329- if (!IS_ERR(sfp))305305+ if ((sfp = sg_add_sfp(sdp, dev)))330306 filp->private_data = sfp;331331- /* retval is already provably zero at this point because of the332332- * check after retval = scsi_autopm_get_device(sdp->device))333333- */334307 else {335335- retval = PTR_ERR(sfp);336336-337308 if (flags & O_EXCL) {338338- sdp->exclude = 0; /* undo if error */339339- up_write(&sdp->o_sem);340340- } else341341- up_read(&sdp->o_sem);309309+ set_exclude(sdp, 0); /* undo if error */310310+ wake_up_interruptible(&sdp->o_excl_wait);311311+ }312312+ retval = -ENOMEM;313313+ goto error_out;314314+ }315315+ retval = 0;342316error_out:317317+ if (retval) {343318 scsi_autopm_put_device(sdp->device);344319sdp_put:345320 scsi_device_put(sdp->device);···358329{359330 Sg_device *sdp;360331 Sg_fd *sfp;361361- int excl;362332363333 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))364334 return -ENXIO;365335 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name));366336367367- excl = sdp->exclude;368368- sdp->exclude = 0;369369- if (excl)370370- up_write(&sdp->o_sem);371371- else372372- up_read(&sdp->o_sem);337337+ set_exclude(sdp, 0);338338+ wake_up_interruptible(&sdp->o_excl_wait);373339374340 scsi_autopm_put_device(sdp->device);375341 kref_put(&sfp->f_ref, sg_remove_sfp);···14151391 disk->first_minor = k;14161392 sdp->disk = disk;14171393 sdp->device = scsidp;14181418- spin_lock_init(&sdp->sfd_lock);14191394 INIT_LIST_HEAD(&sdp->sfds);14201420- init_rwsem(&sdp->o_sem);13951395+ init_waitqueue_head(&sdp->o_excl_wait);14211396 sdp->sg_tablesize = queue_max_segments(q);14221397 sdp->index = k;14231398 kref_init(&sdp->d_ref);···1549152615501527 /* Need a write lock to set sdp->detached. */15511528 write_lock_irqsave(&sg_index_lock, iflags);15521552- spin_lock(&sdp->sfd_lock);15531529 sdp->detached = 1;15541530 list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) {15551531 wake_up_interruptible(&sfp->read_wait);15561532 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_HUP);15571533 }15581558- spin_unlock(&sdp->sfd_lock);15591534 write_unlock_irqrestore(&sg_index_lock, iflags);1560153515611536 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic");···2064204320652044 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);20662045 if (!sfp)20672067- return ERR_PTR(-ENOMEM);20462046+ return NULL;2068204720692048 init_waitqueue_head(&sfp->read_wait);20702049 rwlock_init(&sfp->rq_list_lock);···20782057 sfp->cmd_q = SG_DEF_COMMAND_Q;20792058 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN;20802059 sfp->parentdp = sdp;20812081- spin_lock_irqsave(&sdp->sfd_lock, iflags);20822082- if (sdp->detached) {20832083- spin_unlock_irqrestore(&sdp->sfd_lock, iflags);20842084- return ERR_PTR(-ENODEV);20852085- }20602060+ write_lock_irqsave(&sg_index_lock, iflags);20862061 list_add_tail(&sfp->sfd_siblings, &sdp->sfds);20872087- spin_unlock_irqrestore(&sdp->sfd_lock, iflags);20622062+ write_unlock_irqrestore(&sg_index_lock, iflags);20882063 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp));20892064 if (unlikely(sg_big_buff != def_reserved_size))20902065 sg_big_buff = def_reserved_size;···21302113 struct sg_device *sdp = sfp->parentdp;21312114 unsigned long iflags;2132211521332133- spin_lock_irqsave(&sdp->sfd_lock, iflags);21162116+ write_lock_irqsave(&sg_index_lock, iflags);21342117 list_del(&sfp->sfd_siblings);21352135- spin_unlock_irqrestore(&sdp->sfd_lock, iflags);21182118+ write_unlock_irqrestore(&sg_index_lock, iflags);21192119+ wake_up_interruptible(&sdp->o_excl_wait);2136212021372121 INIT_WORK(&sfp->ew.work, sg_remove_sfp_usercontext);21382122 schedule_work(&sfp->ew.work);···25202502 return 0;25212503}2522250425232523-/* must be called while holding sg_index_lock and sfd_lock */25052505+/* must be called while holding sg_index_lock */25242506static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)25252507{25262508 int k, m, new_interface, blen, usg;···2605258726062588 read_lock_irqsave(&sg_index_lock, iflags);26072589 sdp = it ? sg_lookup_dev(it->index) : NULL;26082608- if (sdp) {26092609- spin_lock(&sdp->sfd_lock);26102610- if (!list_empty(&sdp->sfds)) {26112611- struct scsi_device *scsidp = sdp->device;25902590+ if (sdp && !list_empty(&sdp->sfds)) {25912591+ struct scsi_device *scsidp = sdp->device;2612259226132613- seq_printf(s, " >>> device=%s ", sdp->disk->disk_name);26142614- if (sdp->detached)26152615- seq_printf(s, "detached pending close ");26162616- else26172617- seq_printf26182618- (s, "scsi%d chan=%d id=%d lun=%d em=%d",26192619- scsidp->host->host_no,26202620- scsidp->channel, scsidp->id,26212621- scsidp->lun,26222622- scsidp->host->hostt->emulated);26232623- seq_printf(s, " sg_tablesize=%d excl=%d\n",26242624- sdp->sg_tablesize, sdp->exclude);26252625- sg_proc_debug_helper(s, sdp);26262626- }26272627- spin_unlock(&sdp->sfd_lock);25932593+ seq_printf(s, " >>> device=%s ", sdp->disk->disk_name);25942594+ if (sdp->detached)25952595+ seq_printf(s, "detached pending close ");25962596+ else25972597+ seq_printf25982598+ (s, "scsi%d chan=%d id=%d lun=%d em=%d",25992599+ scsidp->host->host_no,26002600+ scsidp->channel, scsidp->id,26012601+ scsidp->lun,26022602+ scsidp->host->hostt->emulated);26032603+ seq_printf(s, " sg_tablesize=%d excl=%d\n",26042604+ sdp->sg_tablesize, get_exclude(sdp));26052605+ sg_proc_debug_helper(s, sdp);26282606 }26292607 read_unlock_irqrestore(&sg_index_lock, iflags);26302608 return 0;
···570570 ltv_t *pLtv;571571 bool_t ltvAllocated = FALSE;572572 ENCSTRCT sEncryption;573573+ size_t len;573574574575#ifdef USE_WDS575576 hcf_16 hcfPort = HCF_PORT_0;···687686 break;688687 case CFG_CNF_OWN_NAME:689688 memset(lp->StationName, 0, sizeof(lp->StationName));690690- memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);689689+ len = min_t(size_t, pLtv->u.u16[0], sizeof(lp->StationName));690690+ strlcpy(lp->StationName, &pLtv->u.u8[2], len);691691 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);692692 break;693693 case CFG_CNF_LOAD_BALANCING:···17851783{17861784 struct wl_private *lp = wl_priv(dev);17871785 unsigned long flags;17861786+ size_t len;17881787 int ret = 0;17891788 /*------------------------------------------------------------------------*/17901789···17961793 wl_lock(lp, &flags);1797179417981795 memset(lp->StationName, 0, sizeof(lp->StationName));17991799-18001800- memcpy(lp->StationName, extra, wrqu->data.length);17961796+ len = min_t(size_t, wrqu->data.length, sizeof(lp->StationName));17971797+ strlcpy(lp->StationName, extra, len);1801179818021799 /* Commit the adapter parameters */18031800 wl_apply(lp);
+2-7
drivers/tty/serial/atmel_serial.c
···14991499/*15001500 * Get ip name usart or uart15011501 */15021502-static int atmel_get_ip_name(struct uart_port *port)15021502+static void atmel_get_ip_name(struct uart_port *port)15031503{15041504 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);15051505 int name = UART_GET_IP_NAME(port);···15181518 atmel_port->is_usart = false;15191519 } else {15201520 dev_err(port->dev, "Not supported ip name, set to uart\n");15211521- return -EINVAL;15221521 }15231523-15241524- return 0;15251522}1526152315271524/*···24022405 /*24032406 * Get port name of usart or uart24042407 */24052405- ret = atmel_get_ip_name(&port->uart);24062406- if (ret < 0)24072407- goto err_add_port;24082408+ atmel_get_ip_name(&port->uart);2408240924092410 return 0;24102411
+15-2
drivers/uio/uio.c
···642642{643643 struct uio_device *idev = vma->vm_private_data;644644 int mi = uio_find_mem_index(vma);645645+ struct uio_mem *mem;645646 if (mi < 0)647647+ return -EINVAL;648648+ mem = idev->info->mem + mi;649649+650650+ if (vma->vm_end - vma->vm_start > mem->size)646651 return -EINVAL;647652648653 vma->vm_ops = &uio_physical_vm_ops;649649-650654 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);651655656656+ /*657657+ * We cannot use the vm_iomap_memory() helper here,658658+ * because vma->vm_pgoff is the map index we looked659659+ * up above in uio_find_mem_index(), rather than an660660+ * actual page offset into the mmap.661661+ *662662+ * So we just do the physical mmap without a page663663+ * offset.664664+ */652665 return remap_pfn_range(vma,653666 vma->vm_start,654654- idev->info->mem[mi].addr >> PAGE_SHIFT,667667+ mem->addr >> PAGE_SHIFT,655668 vma->vm_end - vma->vm_start,656669 vma->vm_page_prot);657670}
···44 * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com)55 * Copyright (C) 2003 IBM Corp.66 *77- * Copyright (C) 2009, 2013 Frank Schäfer <fschaefer.oss@googlemail.com>88- * - fixes, improvements and documentation for the baud rate encoding methods99- * Copyright (C) 2013 Reinhard Max <max@suse.de>1010- * - fixes and improvements for the divisor based baud rate encoding method1111- *127 * Original driver for 2.2.x by anonymous138 *149 * This program is free software; you can redistribute it and/or···129134130135131136enum pl2303_type {132132- type_0, /* H version ? */133133- type_1, /* H version ? */134134- HX_TA, /* HX(A) / X(A) / TA version */ /* TODO: improve */135135- HXD_EA_RA_SA, /* HXD / EA / RA / SA version */ /* TODO: improve */136136- TB, /* TB version */137137- HX_CLONE, /* Cheap and less functional clone of the HX chip */137137+ type_0, /* don't know the difference between type 0 and */138138+ type_1, /* type 1, until someone from prolific tells us... */139139+ HX, /* HX version of the pl2303 chip */138140};139139-/*140140- * NOTE: don't know the difference between type 0 and type 1,141141- * until someone from Prolific tells us...142142- * TODO: distinguish between X/HX, TA and HXD, EA, RA, SA variants143143- */144141145142struct pl2303_serial_private {146143 enum pl2303_type type;···172185{173186 struct pl2303_serial_private *spriv;174187 enum pl2303_type type = type_0;175175- char *type_str = "unknown (treating as type_0)";176188 unsigned char *buf;177189178190 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);···184198 return -ENOMEM;185199 }186200187187- if (serial->dev->descriptor.bDeviceClass == 0x02) {201201+ if (serial->dev->descriptor.bDeviceClass == 0x02)188202 type = type_0;189189- type_str = "type_0";190190- } else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) {191191- /*192192- * NOTE: The bcdDevice version is the only difference between193193- * the device descriptors of the X/HX, HXD, EA, RA, SA, TA, TB194194- */195195- if (le16_to_cpu(serial->dev->descriptor.bcdDevice) == 0x300) {196196- /* Check if the device is a clone */197197- pl2303_vendor_read(0x9494, 0, serial, buf);198198- /*199199- * NOTE: Not sure if this read is really needed.200200- * The HX returns 0x00, the clone 0x02, but the Windows201201- * driver seems to ignore the value and continues.202202- */203203- pl2303_vendor_write(0x0606, 0xaa, serial);204204- pl2303_vendor_read(0x8686, 0, serial, buf);205205- if (buf[0] != 0xaa) {206206- type = HX_CLONE;207207- type_str = "X/HX clone (limited functionality)";208208- } else {209209- type = HX_TA;210210- type_str = "X/HX/TA";211211- }212212- pl2303_vendor_write(0x0606, 0x00, serial);213213- } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice)214214- == 0x400) {215215- type = HXD_EA_RA_SA;216216- type_str = "HXD/EA/RA/SA";217217- } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice)218218- == 0x500) {219219- type = TB;220220- type_str = "TB";221221- } else {222222- dev_info(&serial->interface->dev,223223- "unknown/unsupported device type\n");224224- kfree(spriv);225225- kfree(buf);226226- return -ENODEV;227227- }228228- } else if (serial->dev->descriptor.bDeviceClass == 0x00229229- || serial->dev->descriptor.bDeviceClass == 0xFF) {203203+ else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)204204+ type = HX;205205+ else if (serial->dev->descriptor.bDeviceClass == 0x00)230206 type = type_1;231231- type_str = "type_1";232232- }233233- dev_dbg(&serial->interface->dev, "device type: %s\n", type_str);207207+ else if (serial->dev->descriptor.bDeviceClass == 0xFF)208208+ type = type_1;209209+ dev_dbg(&serial->interface->dev, "device type: %d\n", type);234210235211 spriv->type = type;236212 usb_set_serial_data(serial, spriv);···207259 pl2303_vendor_read(0x8383, 0, serial, buf);208260 pl2303_vendor_write(0, 1, serial);209261 pl2303_vendor_write(1, 0, serial);210210- if (type == type_0 || type == type_1)211211- pl2303_vendor_write(2, 0x24, serial);212212- else262262+ if (type == HX)213263 pl2303_vendor_write(2, 0x44, serial);264264+ else265265+ pl2303_vendor_write(2, 0x24, serial);214266215267 kfree(buf);216268 return 0;···264316 return retval;265317}266318267267-static int pl2303_baudrate_encode_direct(int baud, enum pl2303_type type,268268- u8 buf[4])319319+static void pl2303_encode_baudrate(struct tty_struct *tty,320320+ struct usb_serial_port *port,321321+ u8 buf[4])269322{270270- /*271271- * NOTE: Only the values defined in baud_sup are supported !272272- * => if unsupported values are set, the PL2303 uses 9600 baud instead273273- * => HX clones just don't work at unsupported baud rates < 115200 baud,274274- * for baud rates > 115200 they run at 115200 baud275275- */276323 const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600,277277- 4800, 7200, 9600, 14400, 19200, 28800, 38400,278278- 57600, 115200, 230400, 460800, 614400, 921600,279279- 1228800, 2457600, 3000000, 6000000, 12000000 };280280- /*281281- * NOTE: With the exception of type_0/1 devices, the following282282- * additional baud rates are supported (tested with HX rev. 3A only):283283- * 110*, 56000*, 128000, 134400, 161280, 201600, 256000*, 268800,284284- * 403200, 806400. (*: not HX and HX clones)285285- *286286- * Maximum values: HXD, TB: 12000000; HX, TA: 6000000;287287- * type_0+1: 1228800; RA: 921600; HX clones, SA: 115200288288- *289289- * As long as we are not using this encoding method for anything else290290- * than the type_0+1, HX and HX clone chips, there is no point in291291- * complicating the code to support them.292292- */324324+ 4800, 7200, 9600, 14400, 19200, 28800, 38400,325325+ 57600, 115200, 230400, 460800, 500000, 614400,326326+ 921600, 1228800, 2457600, 3000000, 6000000 };327327+328328+ struct usb_serial *serial = port->serial;329329+ struct pl2303_serial_private *spriv = usb_get_serial_data(serial);330330+ int baud;293331 int i;332332+333333+ /*334334+ * NOTE: Only the values defined in baud_sup are supported!335335+ * => if unsupported values are set, the PL2303 seems to use336336+ * 9600 baud (at least my PL2303X always does)337337+ */338338+ baud = tty_get_baud_rate(tty);339339+ dev_dbg(&port->dev, "baud requested = %d\n", baud);340340+ if (!baud)341341+ return;294342295343 /* Set baudrate to nearest supported value */296344 for (i = 0; i < ARRAY_SIZE(baud_sup); ++i) {297345 if (baud_sup[i] > baud)298346 break;299347 }348348+300349 if (i == ARRAY_SIZE(baud_sup))301350 baud = baud_sup[i - 1];302351 else if (i > 0 && (baud_sup[i] - baud) > (baud - baud_sup[i - 1]))303352 baud = baud_sup[i - 1];304353 else305354 baud = baud_sup[i];306306- /* Respect the chip type specific baud rate limits */307307- /*308308- * FIXME: as long as we don't know how to distinguish between the309309- * HXD, EA, RA, and SA chip variants, allow the max. value of 12M.310310- */311311- if (type == HX_TA)312312- baud = min_t(int, baud, 6000000);313313- else if (type == type_0 || type == type_1)355355+356356+ /* type_0, type_1 only support up to 1228800 baud */357357+ if (spriv->type != HX)314358 baud = min_t(int, baud, 1228800);315315- else if (type == HX_CLONE)316316- baud = min_t(int, baud, 115200);317317- /* Direct (standard) baud rate encoding method */318318- put_unaligned_le32(baud, buf);319359320320- return baud;321321-}322322-323323-static int pl2303_baudrate_encode_divisor(int baud, enum pl2303_type type,324324- u8 buf[4])325325-{326326- /*327327- * Divisor based baud rate encoding method328328- *329329- * NOTE: HX clones do NOT support this method.330330- * It's not clear if the type_0/1 chips support it.331331- *332332- * divisor = 12MHz * 32 / baudrate = 2^A * B333333- *334334- * with335335- *336336- * A = buf[1] & 0x0e337337- * B = buf[0] + (buf[1] & 0x01) << 8338338- *339339- * Special cases:340340- * => 8 < B < 16: device seems to work not properly341341- * => B <= 8: device uses the max. value B = 512 instead342342- */343343- unsigned int A, B;344344-345345- /*346346- * NOTE: The Windows driver allows maximum baud rates of 110% of the347347- * specified maximium value.348348- * Quick tests with early (2004) HX (rev. A) chips suggest, that even349349- * higher baud rates (up to the maximum of 24M baud !) are working fine,350350- * but that should really be tested carefully in "real life" scenarios351351- * before removing the upper limit completely.352352- * Baud rates smaller than the specified 75 baud are definitely working353353- * fine.354354- */355355- if (type == type_0 || type == type_1)356356- baud = min_t(int, baud, 1228800 * 1.1);357357- else if (type == HX_TA)358358- baud = min_t(int, baud, 6000000 * 1.1);359359- else if (type == HXD_EA_RA_SA)360360- /* HXD, EA: 12Mbps; RA: 1Mbps; SA: 115200 bps */361361- /*362362- * FIXME: as long as we don't know how to distinguish between363363- * these chip variants, allow the max. of these values364364- */365365- baud = min_t(int, baud, 12000000 * 1.1);366366- else if (type == TB)367367- baud = min_t(int, baud, 12000000 * 1.1);368368- /* Determine factors A and B */369369- A = 0;370370- B = 12000000 * 32 / baud; /* 12MHz */371371- B <<= 1; /* Add one bit for rounding */372372- while (B > (512 << 1) && A <= 14) {373373- A += 2;374374- B >>= 2;375375- }376376- if (A > 14) { /* max. divisor = min. baudrate reached */377377- A = 14;378378- B = 512;379379- /* => ~45.78 baud */360360+ if (baud <= 115200) {361361+ put_unaligned_le32(baud, buf);380362 } else {381381- B = (B + 1) >> 1; /* Round the last bit */382382- }383383- /* Handle special cases */384384- if (B == 512)385385- B = 0; /* also: 1 to 8 */386386- else if (B < 16)387363 /*388388- * NOTE: With the current algorithm this happens389389- * only for A=0 and means that the min. divisor390390- * (respectively: the max. baudrate) is reached.364364+ * Apparently the formula for higher speeds is:365365+ * baudrate = 12M * 32 / (2^buf[1]) / buf[0]391366 */392392- B = 16; /* => 24 MBaud */393393- /* Encode the baud rate */394394- buf[3] = 0x80; /* Select divisor encoding method */395395- buf[2] = 0;396396- buf[1] = (A & 0x0e); /* A */397397- buf[1] |= ((B & 0x100) >> 8); /* MSB of B */398398- buf[0] = B & 0xff; /* 8 LSBs of B */399399- /* Calculate the actual/resulting baud rate */400400- if (B <= 8)401401- B = 512;402402- baud = 12000000 * 32 / ((1 << A) * B);367367+ unsigned tmp = 12000000 * 32 / baud;368368+ buf[3] = 0x80;369369+ buf[2] = 0;370370+ buf[1] = (tmp >= 256);371371+ while (tmp >= 256) {372372+ tmp >>= 2;373373+ buf[1] <<= 1;374374+ }375375+ buf[0] = tmp;376376+ }403377404404- return baud;405405-}406406-407407-static void pl2303_encode_baudrate(struct tty_struct *tty,408408- struct usb_serial_port *port,409409- enum pl2303_type type,410410- u8 buf[4])411411-{412412- int baud;413413-414414- baud = tty_get_baud_rate(tty);415415- dev_dbg(&port->dev, "baud requested = %d\n", baud);416416- if (!baud)417417- return;418418- /*419419- * There are two methods for setting/encoding the baud rate420420- * 1) Direct method: encodes the baud rate value directly421421- * => supported by all chip types422422- * 2) Divisor based method: encodes a divisor to a base value (12MHz*32)423423- * => not supported by HX clones (and likely type_0/1 chips)424424- *425425- * NOTE: Although the divisor based baud rate encoding method is much426426- * more flexible, some of the standard baud rate values can not be427427- * realized exactly. But the difference is very small (max. 0.2%) and428428- * the device likely uses the same baud rate generator for both methods429429- * so that there is likley no difference.430430- */431431- if (type == type_0 || type == type_1 || type == HX_CLONE)432432- baud = pl2303_baudrate_encode_direct(baud, type, buf);433433- else434434- baud = pl2303_baudrate_encode_divisor(baud, type, buf);435378 /* Save resulting baud rate */436379 tty_encode_baud_rate(tty, baud, baud);437380 dev_dbg(&port->dev, "baud set = %d\n", baud);···379540 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);380541 }381542382382- /* For reference: buf[0]:buf[3] baud rate value */383383- pl2303_encode_baudrate(tty, port, spriv->type, buf);543543+ /* For reference buf[0]:buf[3] baud rate value */544544+ pl2303_encode_baudrate(tty, port, &buf[0]);384545385546 /* For reference buf[4]=0 is 1 stop bits */386547 /* For reference buf[4]=1 is 1.5 stop bits */···457618 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf);458619459620 if (C_CRTSCTS(tty)) {460460- if (spriv->type == type_0 || spriv->type == type_1)461461- pl2303_vendor_write(0x0, 0x41, serial);462462- else621621+ if (spriv->type == HX)463622 pl2303_vendor_write(0x0, 0x61, serial);623623+ else624624+ pl2303_vendor_write(0x0, 0x41, serial);464625 } else {465626 pl2303_vendor_write(0x0, 0x0, serial);466627 }···497658 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);498659 int result;499660500500- if (spriv->type == type_0 || spriv->type == type_1) {661661+ if (spriv->type != HX) {501662 usb_clear_halt(serial->dev, port->write_urb->pipe);502663 usb_clear_halt(serial->dev, port->read_urb->pipe);503664 } else {···672833 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),673834 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,674835 0, NULL, 0, 100);675675- /* NOTE: HX clones don't support sending breaks, -EPIPE is returned */676836 if (result)677837 dev_err(&port->dev, "error sending break = %d\n", result);678838}
+1-25
drivers/video/au1100fb.c
···361361int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)362362{363363 struct au1100fb_device *fbdev;364364- unsigned int len;365365- unsigned long start=0, off;366364367365 fbdev = to_au1100fb_device(fbi);368368-369369- if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {370370- return -EINVAL;371371- }372372-373373- start = fbdev->fb_phys & PAGE_MASK;374374- len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);375375-376376- off = vma->vm_pgoff << PAGE_SHIFT;377377-378378- if ((vma->vm_end - vma->vm_start + off) > len) {379379- return -EINVAL;380380- }381381-382382- off += start;383383- vma->vm_pgoff = off >> PAGE_SHIFT;384366385367 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);386368 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6387369388388- if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,389389- vma->vm_end - vma->vm_start,390390- vma->vm_page_prot)) {391391- return -EAGAIN;392392- }393393-394394- return 0;370370+ return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);395371}396372397373static struct fb_ops au1100fb_ops =
+1-22
drivers/video/au1200fb.c
···12331233 * method mainly to allow the use of the TLB streaming flag (CCA=6)12341234 */12351235static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)12361236-12371236{12381238- unsigned int len;12391239- unsigned long start=0, off;12401237 struct au1200fb_device *fbdev = info->par;12411241-12421242- if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {12431243- return -EINVAL;12441244- }12451245-12461246- start = fbdev->fb_phys & PAGE_MASK;12471247- len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);12481248-12491249- off = vma->vm_pgoff << PAGE_SHIFT;12501250-12511251- if ((vma->vm_end - vma->vm_start + off) > len) {12521252- return -EINVAL;12531253- }12541254-12551255- off += start;12561256- vma->vm_pgoff = off >> PAGE_SHIFT;1257123812581239 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);12591240 pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */1260124112611261- return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,12621262- vma->vm_end - vma->vm_start,12631263- vma->vm_page_prot);12421242+ return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);12641243}1265124412661245static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata)
+3-2
fs/dcache.c
···542542 * If ref is non-zero, then decrement the refcount too.543543 * Returns dentry requiring refcount drop, or NULL if we're done.544544 */545545-static inline struct dentry *545545+static struct dentry *546546dentry_kill(struct dentry *dentry, int unlock_on_failure)547547 __releases(dentry->d_lock)548548{···630630 goto kill_it;631631 }632632633633- dentry->d_flags |= DCACHE_REFERENCED;633633+ if (!(dentry->d_flags & DCACHE_REFERENCED))634634+ dentry->d_flags |= DCACHE_REFERENCED;634635 dentry_lru_add(dentry);635636636637 dentry->d_lockref.count--;
···3434 int sem_ctls[4];3535 int used_sems;36363737- int msg_ctlmax;3838- int msg_ctlmnb;3939- int msg_ctlmni;3737+ unsigned int msg_ctlmax;3838+ unsigned int msg_ctlmnb;3939+ unsigned int msg_ctlmni;4040 atomic_t msg_bytes;4141 atomic_t msg_hdrs;4242 int auto_msgmni;
···479479 /*480480 * Control data for the mmap() data buffer.481481 *482482- * User-space reading the @data_head value should issue an rmb(), on483483- * SMP capable platforms, after reading this value -- see484484- * perf_event_wakeup().482482+ * User-space reading the @data_head value should issue an smp_rmb(),483483+ * after reading this value.485484 *486485 * When the mapping is PROT_WRITE the @data_tail value should be487487- * written by userspace to reflect the last read data. In this case488488- * the kernel will not over-write unread data.486486+ * written by userspace to reflect the last read data, after issueing487487+ * an smp_mb() to separate the data read from the ->data_tail store.488488+ * In this case the kernel will not over-write unread data.489489+ *490490+ * See perf_output_put_handle() for the data ordering.489491 */490492 __u64 data_head; /* head in the data section */491493 __u64 data_tail; /* user-space written tail */
···8787 goto out;88888989 /*9090- * Publish the known good head. Rely on the full barrier implied9191- * by atomic_dec_and_test() order the rb->head read and this9292- * write.9090+ * Since the mmap() consumer (userspace) can run on a different CPU:9191+ *9292+ * kernel user9393+ *9494+ * READ ->data_tail READ ->data_head9595+ * smp_mb() (A) smp_rmb() (C)9696+ * WRITE $data READ $data9797+ * smp_wmb() (B) smp_mb() (D)9898+ * STORE ->data_head WRITE ->data_tail9999+ *100100+ * Where A pairs with D, and B pairs with C.101101+ *102102+ * I don't think A needs to be a full barrier because we won't in fact103103+ * write data until we see the store from userspace. So we simply don't104104+ * issue the data WRITE until we observe it. Be conservative for now.105105+ *106106+ * OTOH, D needs to be a full barrier since it separates the data READ107107+ * from the tail WRITE.108108+ *109109+ * For B a WMB is sufficient since it separates two WRITEs, and for C110110+ * an RMB is sufficient since it separates two READs.111111+ *112112+ * See perf_output_begin().93113 */114114+ smp_wmb();94115 rb->user_page->data_head = head;9511696117 /*···175154 * Userspace could choose to issue a mb() before updating the176155 * tail pointer. So that all reads will be completed before the177156 * write is issued.157157+ *158158+ * See perf_output_put_handle().178159 */179160 tail = ACCESS_ONCE(rb->user_page->data_tail);180180- smp_rmb();161161+ smp_mb();181162 offset = head = local_read(&rb->head);182163 head += size;183164 if (unlikely(!perf_output_space(rb, tail, offset, head)))
+1-1
lib/Kconfig.debug
···983983984984config DEBUG_KOBJECT_RELEASE985985 bool "kobject release debugging"986986- depends on DEBUG_KERNEL986986+ depends on DEBUG_OBJECTS_TIMERS987987 help988988 kobjects are reference counted objects. This means that their989989 last reference count put is not predictable, and the kobject can
+2-1
lib/scatterlist.c
···577577 miter->__offset += miter->consumed;578578 miter->__remaining -= miter->consumed;579579580580- if (miter->__flags & SG_MITER_TO_SG)580580+ if ((miter->__flags & SG_MITER_TO_SG) &&581581+ !PageSlab(miter->page))581582 flush_kernel_dcache_page(miter->page);582583583584 if (miter->__flags & SG_MITER_ATOMIC) {
+48-22
mm/huge_memory.c
···12781278int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,12791279 unsigned long addr, pmd_t pmd, pmd_t *pmdp)12801280{12811281+ struct anon_vma *anon_vma = NULL;12811282 struct page *page;12821283 unsigned long haddr = addr & HPAGE_PMD_MASK;12841284+ int page_nid = -1, this_nid = numa_node_id();12831285 int target_nid;12841284- int current_nid = -1;12851285- bool migrated;12861286+ bool page_locked;12871287+ bool migrated = false;1286128812871289 spin_lock(&mm->page_table_lock);12881290 if (unlikely(!pmd_same(pmd, *pmdp)))12891291 goto out_unlock;1290129212911293 page = pmd_page(pmd);12921292- get_page(page);12931293- current_nid = page_to_nid(page);12941294+ page_nid = page_to_nid(page);12941295 count_vm_numa_event(NUMA_HINT_FAULTS);12951295- if (current_nid == numa_node_id())12961296+ if (page_nid == this_nid)12961297 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);1297129812991299+ /*13001300+ * Acquire the page lock to serialise THP migrations but avoid dropping13011301+ * page_table_lock if at all possible13021302+ */13031303+ page_locked = trylock_page(page);12981304 target_nid = mpol_misplaced(page, vma, haddr);12991305 if (target_nid == -1) {13001300- put_page(page);13011301- goto clear_pmdnuma;13061306+ /* If the page was locked, there are no parallel migrations */13071307+ if (page_locked)13081308+ goto clear_pmdnuma;13091309+13101310+ /*13111311+ * Otherwise wait for potential migrations and retry. We do13121312+ * relock and check_same as the page may no longer be mapped.13131313+ * As the fault is being retried, do not account for it.13141314+ */13151315+ spin_unlock(&mm->page_table_lock);13161316+ wait_on_page_locked(page);13171317+ page_nid = -1;13181318+ goto out;13021319 }1303132013041304- /* Acquire the page lock to serialise THP migrations */13211321+ /* Page is misplaced, serialise migrations and parallel THP splits */13221322+ get_page(page);13051323 spin_unlock(&mm->page_table_lock);13061306- lock_page(page);13241324+ if (!page_locked)13251325+ lock_page(page);13261326+ anon_vma = page_lock_anon_vma_read(page);1307132713081328 /* Confirm the PTE did not while locked */13091329 spin_lock(&mm->page_table_lock);13101330 if (unlikely(!pmd_same(pmd, *pmdp))) {13111331 unlock_page(page);13121332 put_page(page);13331333+ page_nid = -1;13131334 goto out_unlock;13141335 }13151315- spin_unlock(&mm->page_table_lock);1316133613171317- /* Migrate the THP to the requested node */13371337+ /*13381338+ * Migrate the THP to the requested node, returns with page unlocked13391339+ * and pmd_numa cleared.13401340+ */13411341+ spin_unlock(&mm->page_table_lock);13181342 migrated = migrate_misplaced_transhuge_page(mm, vma,13191343 pmdp, pmd, addr, page, target_nid);13201320- if (!migrated)13211321- goto check_same;13441344+ if (migrated)13451345+ page_nid = target_nid;1322134613231323- task_numa_fault(target_nid, HPAGE_PMD_NR, true);13241324- return 0;13251325-13261326-check_same:13271327- spin_lock(&mm->page_table_lock);13281328- if (unlikely(!pmd_same(pmd, *pmdp)))13291329- goto out_unlock;13471347+ goto out;13301348clear_pmdnuma:13491349+ BUG_ON(!PageLocked(page));13311350 pmd = pmd_mknonnuma(pmd);13321351 set_pmd_at(mm, haddr, pmdp, pmd);13331352 VM_BUG_ON(pmd_numa(*pmdp));13341353 update_mmu_cache_pmd(vma, addr, pmdp);13541354+ unlock_page(page);13351355out_unlock:13361356 spin_unlock(&mm->page_table_lock);13371337- if (current_nid != -1)13381338- task_numa_fault(current_nid, HPAGE_PMD_NR, false);13571357+13581358+out:13591359+ if (anon_vma)13601360+ page_unlock_anon_vma_read(anon_vma);13611361+13621362+ if (page_nid != -1)13631363+ task_numa_fault(page_nid, HPAGE_PMD_NR, migrated);13641364+13391365 return 0;13401366}13411367
+2-1
mm/list_lru.c
···8181 * decrement nr_to_walk first so that we don't livelock if we8282 * get stuck on large numbesr of LRU_RETRY items8383 */8484- if (--(*nr_to_walk) == 0)8484+ if (!*nr_to_walk)8585 break;8686+ --*nr_to_walk;86878788 ret = isolate(item, &nlru->lock, cb_arg);8889 switch (ret) {
+26-31
mm/memcontrol.c
···5454#include <linux/page_cgroup.h>5555#include <linux/cpu.h>5656#include <linux/oom.h>5757+#include <linux/lockdep.h>5758#include "internal.h"5859#include <net/sock.h>5960#include <net/ip.h>···20472046 return total;20482047}2049204820492049+#ifdef CONFIG_LOCKDEP20502050+static struct lockdep_map memcg_oom_lock_dep_map = {20512051+ .name = "memcg_oom_lock",20522052+};20532053+#endif20542054+20502055static DEFINE_SPINLOCK(memcg_oom_lock);2051205620522057/*···20902083 }20912084 iter->oom_lock = false;20922085 }20932093- }20862086+ } else20872087+ mutex_acquire(&memcg_oom_lock_dep_map, 0, 1, _RET_IP_);2094208820952089 spin_unlock(&memcg_oom_lock);20962090···21032095 struct mem_cgroup *iter;2104209621052097 spin_lock(&memcg_oom_lock);20982098+ mutex_release(&memcg_oom_lock_dep_map, 1, _RET_IP_);21062099 for_each_mem_cgroup_tree(iter, memcg)21072100 iter->oom_lock = false;21082101 spin_unlock(&memcg_oom_lock);···27742765 *ptr = memcg;27752766 return 0;27762767nomem:27772777- *ptr = NULL;27782778- if (gfp_mask & __GFP_NOFAIL)27792779- return 0;27802780- return -ENOMEM;27682768+ if (!(gfp_mask & __GFP_NOFAIL)) {27692769+ *ptr = NULL;27702770+ return -ENOMEM;27712771+ }27812772bypass:27822773 *ptr = root_mem_cgroup;27832774 return -EINTR;···37823773{37833774 /* Update stat data for mem_cgroup */37843775 preempt_disable();37853785- WARN_ON_ONCE(from->stat->count[idx] < nr_pages);37863786- __this_cpu_add(from->stat->count[idx], -nr_pages);37763776+ __this_cpu_sub(from->stat->count[idx], nr_pages);37873777 __this_cpu_add(to->stat->count[idx], nr_pages);37883778 preempt_enable();37893779}···49584950 } while (usage > 0);49594951}4960495249614961-/*49624962- * This mainly exists for tests during the setting of set of use_hierarchy.49634963- * Since this is the very setting we are changing, the current hierarchy value49644964- * is meaningless49654965- */49664966-static inline bool __memcg_has_children(struct mem_cgroup *memcg)49674967-{49684968- struct cgroup_subsys_state *pos;49694969-49704970- /* bounce at first found */49714971- css_for_each_child(pos, &memcg->css)49724972- return true;49734973- return false;49744974-}49754975-49764976-/*49774977- * Must be called with memcg_create_mutex held, unless the cgroup is guaranteed49784978- * to be already dead (as in mem_cgroup_force_empty, for instance). This is49794979- * from mem_cgroup_count_children(), in the sense that we don't really care how49804980- * many children we have; we only need to know if we have any. It also counts49814981- * any memcg without hierarchy as infertile.49824982- */49834953static inline bool memcg_has_children(struct mem_cgroup *memcg)49844954{49854985- return memcg->use_hierarchy && __memcg_has_children(memcg);49554955+ lockdep_assert_held(&memcg_create_mutex);49564956+ /*49574957+ * The lock does not prevent addition or deletion to the list49584958+ * of children, but it prevents a new child from being49594959+ * initialized based on this parent in css_online(), so it's49604960+ * enough to decide whether hierarchically inherited49614961+ * attributes can still be changed or not.49624962+ */49634963+ return memcg->use_hierarchy &&49644964+ !list_empty(&memcg->css.cgroup->children);49864965}4987496649884967/*···50495054 */50505055 if ((!parent_memcg || !parent_memcg->use_hierarchy) &&50515056 (val == 1 || val == 0)) {50525052- if (!__memcg_has_children(memcg))50575057+ if (list_empty(&memcg->css.cgroup->children))50535058 memcg->use_hierarchy = val;50545059 else50555060 retval = -EBUSY;
+21-32
mm/memory.c
···35213521}3522352235233523int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,35243524- unsigned long addr, int current_nid)35243524+ unsigned long addr, int page_nid)35253525{35263526 get_page(page);3527352735283528 count_vm_numa_event(NUMA_HINT_FAULTS);35293529- if (current_nid == numa_node_id())35293529+ if (page_nid == numa_node_id())35303530 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);3531353135323532 return mpol_misplaced(page, vma, addr);···35373537{35383538 struct page *page = NULL;35393539 spinlock_t *ptl;35403540- int current_nid = -1;35403540+ int page_nid = -1;35413541 int target_nid;35423542 bool migrated = false;35433543···35673567 return 0;35683568 }3569356935703570- current_nid = page_to_nid(page);35713571- target_nid = numa_migrate_prep(page, vma, addr, current_nid);35703570+ page_nid = page_to_nid(page);35713571+ target_nid = numa_migrate_prep(page, vma, addr, page_nid);35723572 pte_unmap_unlock(ptep, ptl);35733573 if (target_nid == -1) {35743574- /*35753575- * Account for the fault against the current node if it not35763576- * being replaced regardless of where the page is located.35773577- */35783578- current_nid = numa_node_id();35793574 put_page(page);35803575 goto out;35813576 }···35783583 /* Migrate to the requested node */35793584 migrated = migrate_misplaced_page(page, target_nid);35803585 if (migrated)35813581- current_nid = target_nid;35863586+ page_nid = target_nid;3582358735833588out:35843584- if (current_nid != -1)35853585- task_numa_fault(current_nid, 1, migrated);35893589+ if (page_nid != -1)35903590+ task_numa_fault(page_nid, 1, migrated);35863591 return 0;35873592}35883593···35973602 unsigned long offset;35983603 spinlock_t *ptl;35993604 bool numa = false;36003600- int local_nid = numa_node_id();3601360536023606 spin_lock(&mm->page_table_lock);36033607 pmd = *pmdp;···36193625 for (addr = _addr + offset; addr < _addr + PMD_SIZE; pte++, addr += PAGE_SIZE) {36203626 pte_t pteval = *pte;36213627 struct page *page;36223622- int curr_nid = local_nid;36283628+ int page_nid = -1;36233629 int target_nid;36243624- bool migrated;36303630+ bool migrated = false;36313631+36253632 if (!pte_present(pteval))36263633 continue;36273634 if (!pte_numa(pteval))···36443649 if (unlikely(page_mapcount(page) != 1))36453650 continue;3646365136473647- /*36483648- * Note that the NUMA fault is later accounted to either36493649- * the node that is currently running or where the page is36503650- * migrated to.36513651- */36523652- curr_nid = local_nid;36533653- target_nid = numa_migrate_prep(page, vma, addr,36543654- page_to_nid(page));36553655- if (target_nid == -1) {36523652+ page_nid = page_to_nid(page);36533653+ target_nid = numa_migrate_prep(page, vma, addr, page_nid);36543654+ pte_unmap_unlock(pte, ptl);36553655+ if (target_nid != -1) {36563656+ migrated = migrate_misplaced_page(page, target_nid);36573657+ if (migrated)36583658+ page_nid = target_nid;36593659+ } else {36563660 put_page(page);36573657- continue;36583661 }3659366236603660- /* Migrate to the requested node */36613661- pte_unmap_unlock(pte, ptl);36623662- migrated = migrate_misplaced_page(page, target_nid);36633663- if (migrated)36643664- curr_nid = target_nid;36653665- task_numa_fault(curr_nid, 1, migrated);36633663+ if (page_nid != -1)36643664+ task_numa_fault(page_nid, 1, migrated);3666366536673666 pte = pte_offset_map_lock(mm, pmdp, addr, &ptl);36683667 }