1. 30 11月, 2012 7 次提交
    • A
      [SCSI] sd: update sd to use the new pm callbacks · 691e3d31
      Aaron Lu 提交于
      Update sd driver to use the callbacks defined in dev_pm_ops.
      
      sd_freeze is NULL, the bus level callback has taken care of quiescing
      the device so there should be nothing needs to be done here.
      Consequently, sd_thaw is not needed here either.
      
      suspend, poweroff and runtime suspend share the same routine sd_suspend,
      which will sync flush and then stop the drive, this is the same as before.
      
      resume, restore and runtime resume share the same routine sd_resume,
      which will start the drive by putting it into active power state, this
      is also the same as before.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      691e3d31
    • A
      [SCSI] scsi_pm: use callbacks from dev_pm_ops for scsi devices · 80d2fd48
      Aaron Lu 提交于
      Use of pm_message_t is deprecated and device driver is not supposed
      to use that. This patch migrates the SCSI bus level pm callbacks
      to call device's pm callbacks defined in its driver's dev_pm_ops.
      
      This is achieved by finding out which device pm callback should be used
      in bus callback function, and then pass that callback function pointer
      as a param to the scsi_bus_{suspend,resume}_common routine, which will
      further pass that callback to scsi_dev_type_{suspend,resume} after
      proper handling.
      
      The special case for freeze in scsi_bus_suspend_common is not necessary
      since there is no high level SCSI driver has implemented freeze, so no
      need to runtime resume the device if it is in runtime suspended state
      for system freeze, just return like the system suspend/hibernate case.
      
      Since only sd has implemented drv->suspend/drv->resume, and I'll update
      sd driver to use the new callbacks in the following patch, there is no
      need to fallback to call drv->suspend/drv->resume if dev_pm_ops is NULL.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      80d2fd48
    • A
      [SCSI] Revert "[SCSI] runtime resume parent for child's system-resume" · 9c31d8e1
      Aaron Lu 提交于
      This reverts commit 28fd00d4.
      
      With commit 88d26136 (PM: Prevent
      runtime suspend during system resume), this patch is no longer needed.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      9c31d8e1
    • A
      [SCSI] Revert "[SCSI] scsi_pm: set device runtime state before parent suspended" · 63347905
      Aaron Lu 提交于
      This reverts commit 33a2285d.
      
      With commit 88d26136 (PM: Prevent
      runtime suspend during system resume), this patch is no longer needed.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      63347905
    • A
      [SCSI] sd: put to stopped power state when runtime suspend · a0147563
      Aaron Lu 提交于
      When device is runtime suspended, put it to stopped power state to save
      some power.
      
      This will also make the behaviour consistent with what the scsi_pm.c
      thinks about sd as the comment says:
      sd treats runtime suspend, system suspend and system hibernate identical.
      With this patch, it is now identical.
      And sd_shutdown will also do nothing when it finds the device has been
      runtime suspended, if we do not spin down the disk in runtime suspend
      by putting it into stopped power state, the disk will be shut down
      incorrectly.
      And the the same problem can be solved for runtime power off after
      runtime suspended case by this change.
      
      With the current runtime scheme for disk, it will only be runtime
      suspended when no process opens the disk, so this shouldn't happen a
      lot, which makes it acceptable to spin down the disk when runtime
      suspended. If some day a more aggressive runtime scheme is used, like
      the 'request based runtime pm for disk' that Alan Stern and Lin Ming
      has been working, we can introduce some policy to control this. But for
      now, make it simple and correct by spinning down the disk.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      a0147563
    • X
      [SCSI] mvsas: fix undefined bit shift · beecadea
      Xi Wang 提交于
      The macro bit(n) is defined as ((u32)1 << n), and thus it doesn't work
      with n >= 32, such as in mvs_94xx_assign_reg_set():
      
      	if (i >= 32) {
      		mvi->sata_reg_set |= bit(i);
      		...
      	}
      
      The shift ((u32)1 << n) with n >= 32 also leads to undefined behavior.
      The result varies depending on the architecture.
      
      This patch changes bit(n) to do a 64-bit shift.  It also simplifies
      mv_ffc64() using __ffs64(), since invoking ffz() with ~0 is undefined.
      Signed-off-by: NXi Wang <xi.wang@gmail.com>
      Acked-by: NXiangliang Yu <yuxiangl@marvell.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      beecadea
    • S
      [SCSI] prevent stack buffer overflow in host_reset · 072f19b4
      Sasha Levin 提交于
      store_host_reset() has tried to re-invent the wheel to compare sysfs strings.
      Unfortunately it did so poorly and never bothered to check the input from
      userspace before overwriting stack with it, so something simple as:
      
      echo "WoopsieWoopsie" >
      /sys/devices/pseudo_0/adapter0/host0/scsi_host/host0/host_reset
      
      would result in:
      
      [  316.310101] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffff81f5bac7
      [  316.310101]
      [  316.320051] Pid: 6655, comm: sh Tainted: G        W    3.7.0-rc5-next-20121114-sasha-00016-g5c9d68d-dirty #129
      [  316.320051] Call Trace:
      [  316.340058] pps pps0: PPS event at 1352918752.620355751
      [  316.340062] pps pps0: capture assert seq #303
      [  316.320051]  [<ffffffff83b3856b>] panic+0xcd/0x1f4
      [  316.320051]  [<ffffffff81f5bac7>] ? store_host_reset+0xd7/0x100
      [  316.320051]  [<ffffffff8110b996>] __stack_chk_fail+0x16/0x20
      [  316.320051]  [<ffffffff81f5bac7>] store_host_reset+0xd7/0x100
      [  316.320051]  [<ffffffff81e55bb3>] dev_attr_store+0x13/0x30
      [  316.320051]  [<ffffffff812f7db1>] sysfs_write_file+0x101/0x170
      [  316.320051]  [<ffffffff8127acc8>] vfs_write+0xb8/0x180
      [  316.320051]  [<ffffffff8127ae80>] sys_write+0x50/0xa0
      [  316.320051]  [<ffffffff83c03418>] tracesys+0xe1/0xe6
      
      Fix this by uninventing whatever was going on there and just use sysfs_streq.
      
      Bug introduced by 29443691 ("[SCSI] scsi: Added support for adapter and
      firmware reset").
      
      [jejb: added necessary const to prevent compile warnings]
      Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
      Cc: <stable@vger.kernel.org> #3.2+
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      072f19b4
  2. 27 11月, 2012 33 次提交