Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'postmerge' into for-linus

Signed-off-by: James Bottomley <JBottomley@Parallels.com>

+93 -38
+4 -5
drivers/scsi/scsi_lib.c
··· 276 276 } 277 277 EXPORT_SYMBOL(scsi_execute); 278 278 279 - 280 - int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, 279 + int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd, 281 280 int data_direction, void *buffer, unsigned bufflen, 282 281 struct scsi_sense_hdr *sshdr, int timeout, int retries, 283 - int *resid) 282 + int *resid, int flags) 284 283 { 285 284 char *sense = NULL; 286 285 int result; ··· 290 291 return DRIVER_ERROR << 24; 291 292 } 292 293 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, 293 - sense, timeout, retries, 0, resid); 294 + sense, timeout, retries, flags, resid); 294 295 if (sshdr) 295 296 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr); 296 297 297 298 kfree(sense); 298 299 return result; 299 300 } 300 - EXPORT_SYMBOL(scsi_execute_req); 301 + EXPORT_SYMBOL(scsi_execute_req_flags); 301 302 302 303 /* 303 304 * Function: scsi_init_cmd_errh()
+71 -13
drivers/scsi/scsi_pm.c
··· 144 144 145 145 #ifdef CONFIG_PM_RUNTIME 146 146 147 + static int sdev_blk_runtime_suspend(struct scsi_device *sdev, 148 + int (*cb)(struct device *)) 149 + { 150 + int err; 151 + 152 + err = blk_pre_runtime_suspend(sdev->request_queue); 153 + if (err) 154 + return err; 155 + if (cb) 156 + err = cb(&sdev->sdev_gendev); 157 + blk_post_runtime_suspend(sdev->request_queue, err); 158 + 159 + return err; 160 + } 161 + 162 + static int sdev_runtime_suspend(struct device *dev) 163 + { 164 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 165 + int (*cb)(struct device *) = pm ? pm->runtime_suspend : NULL; 166 + struct scsi_device *sdev = to_scsi_device(dev); 167 + int err; 168 + 169 + if (sdev->request_queue->dev) 170 + return sdev_blk_runtime_suspend(sdev, cb); 171 + 172 + err = scsi_dev_type_suspend(dev, cb); 173 + if (err == -EAGAIN) 174 + pm_schedule_suspend(dev, jiffies_to_msecs( 175 + round_jiffies_up_relative(HZ/10))); 176 + return err; 177 + } 178 + 147 179 static int scsi_runtime_suspend(struct device *dev) 148 180 { 149 181 int err = 0; 150 - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 151 182 152 183 dev_dbg(dev, "scsi_runtime_suspend\n"); 153 - if (scsi_is_sdev_device(dev)) { 154 - err = scsi_dev_type_suspend(dev, 155 - pm ? pm->runtime_suspend : NULL); 156 - if (err == -EAGAIN) 157 - pm_schedule_suspend(dev, jiffies_to_msecs( 158 - round_jiffies_up_relative(HZ/10))); 159 - } 184 + if (scsi_is_sdev_device(dev)) 185 + err = sdev_runtime_suspend(dev); 160 186 161 187 /* Insert hooks here for targets, hosts, and transport classes */ 162 188 163 189 return err; 164 190 } 165 191 192 + static int sdev_blk_runtime_resume(struct scsi_device *sdev, 193 + int (*cb)(struct device *)) 194 + { 195 + int err = 0; 196 + 197 + blk_pre_runtime_resume(sdev->request_queue); 198 + if (cb) 199 + err = cb(&sdev->sdev_gendev); 200 + blk_post_runtime_resume(sdev->request_queue, err); 201 + 202 + return err; 203 + } 204 + 205 + static int sdev_runtime_resume(struct device *dev) 206 + { 207 + struct scsi_device *sdev = to_scsi_device(dev); 208 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 209 + int (*cb)(struct device *) = pm ? pm->runtime_resume : NULL; 210 + 211 + if (sdev->request_queue->dev) 212 + return sdev_blk_runtime_resume(sdev, cb); 213 + else 214 + return scsi_dev_type_resume(dev, cb); 215 + } 216 + 166 217 static int scsi_runtime_resume(struct device *dev) 167 218 { 168 219 int err = 0; 169 - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 170 220 171 221 dev_dbg(dev, "scsi_runtime_resume\n"); 172 222 if (scsi_is_sdev_device(dev)) 173 - err = scsi_dev_type_resume(dev, pm ? pm->runtime_resume : NULL); 223 + err = sdev_runtime_resume(dev); 174 224 175 225 /* Insert hooks here for targets, hosts, and transport classes */ 176 226 ··· 235 185 236 186 /* Insert hooks here for targets, hosts, and transport classes */ 237 187 238 - if (scsi_is_sdev_device(dev)) 239 - err = pm_schedule_suspend(dev, 100); 240 - else 188 + if (scsi_is_sdev_device(dev)) { 189 + struct scsi_device *sdev = to_scsi_device(dev); 190 + 191 + if (sdev->request_queue->dev) { 192 + pm_runtime_mark_last_busy(dev); 193 + err = pm_runtime_autosuspend(dev); 194 + } else { 195 + err = pm_runtime_suspend(dev); 196 + } 197 + } else { 241 198 err = pm_runtime_suspend(dev); 199 + } 242 200 return err; 243 201 } 244 202
+6 -16
drivers/scsi/sd.c
··· 1136 1136 1137 1137 sdev = sdkp->device; 1138 1138 1139 - retval = scsi_autopm_get_device(sdev); 1140 - if (retval) 1141 - goto error_autopm; 1142 - 1143 1139 /* 1144 1140 * If the device is in error recovery, wait until it is done. 1145 1141 * If the device is offline, then disallow any access to it. ··· 1180 1184 return 0; 1181 1185 1182 1186 error_out: 1183 - scsi_autopm_put_device(sdev); 1184 - error_autopm: 1185 1187 scsi_disk_put(sdkp); 1186 1188 return retval; 1187 1189 } ··· 1214 1220 * XXX is followed by a "rmmod sd_mod"? 1215 1221 */ 1216 1222 1217 - scsi_autopm_put_device(sdev); 1218 1223 scsi_disk_put(sdkp); 1219 1224 } 1220 1225 ··· 1374 1381 retval = -ENODEV; 1375 1382 1376 1383 if (scsi_block_when_processing_errors(sdp)) { 1377 - retval = scsi_autopm_get_device(sdp); 1378 - if (retval) 1379 - goto out; 1380 - 1381 1384 sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL); 1382 1385 retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES, 1383 1386 sshdr); 1384 - scsi_autopm_put_device(sdp); 1385 1387 } 1386 1388 1387 1389 /* failed to execute TUR, assume media not present */ ··· 1426 1438 * Leave the rest of the command zero to indicate 1427 1439 * flush everything. 1428 1440 */ 1429 - res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 1430 - SD_FLUSH_TIMEOUT, SD_MAX_RETRIES, NULL); 1441 + res = scsi_execute_req_flags(sdp, cmd, DMA_NONE, NULL, 0, 1442 + &sshdr, SD_FLUSH_TIMEOUT, 1443 + SD_MAX_RETRIES, NULL, REQ_PM); 1431 1444 if (res == 0) 1432 1445 break; 1433 1446 } ··· 2846 2857 2847 2858 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", 2848 2859 sdp->removable ? "removable " : ""); 2860 + blk_pm_runtime_init(sdp->request_queue, dev); 2849 2861 scsi_autopm_put_device(sdp); 2850 2862 put_device(&sdkp->dev); 2851 2863 } ··· 3030 3040 if (!scsi_device_online(sdp)) 3031 3041 return -ENODEV; 3032 3042 3033 - res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 3034 - SD_TIMEOUT, SD_MAX_RETRIES, NULL); 3043 + res = scsi_execute_req_flags(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 3044 + SD_TIMEOUT, SD_MAX_RETRIES, NULL, REQ_PM); 3035 3045 if (res) { 3036 3046 sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n"); 3037 3047 sd_print_result(sdkp, res);
+12 -4
include/scsi/scsi_device.h
··· 394 394 int data_direction, void *buffer, unsigned bufflen, 395 395 unsigned char *sense, int timeout, int retries, 396 396 int flag, int *resid); 397 - extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, 398 - int data_direction, void *buffer, unsigned bufflen, 399 - struct scsi_sense_hdr *, int timeout, int retries, 400 - int *resid); 397 + extern int scsi_execute_req_flags(struct scsi_device *sdev, 398 + const unsigned char *cmd, int data_direction, void *buffer, 399 + unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout, 400 + int retries, int *resid, int flags); 401 + static inline int scsi_execute_req(struct scsi_device *sdev, 402 + const unsigned char *cmd, int data_direction, void *buffer, 403 + unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout, 404 + int retries, int *resid) 405 + { 406 + return scsi_execute_req_flags(sdev, cmd, data_direction, buffer, 407 + bufflen, sshdr, timeout, retries, resid, 0); 408 + } 401 409 extern void sdev_disable_disk_events(struct scsi_device *sdev); 402 410 extern void sdev_enable_disk_events(struct scsi_device *sdev); 403 411