On Tue, 19 Jan 2016, Paul Menzel wrote: > Could you please attach the debugging patch. Hopefully Alexandre, Erich, > or I will have some spare time to build an image from it. Actually, this patch is an attempt at a fix. After looking more carefully at your log pictures, I realized what the problem must be. It's too bad nobody was able to capture a log where the error occurred in sr_runtime_suspend, though -- all the logs in the bug report show sd_runtime_resume. > Alan, thank you a lot for being so responsive and helpful! You're welcome. Alan Stern
drivers/scsi/sd.c | 7 +++++-- drivers/scsi/sr.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) Index: usb-4.4/drivers/scsi/sd.c =================================================================== --- usb-4.4.orig/drivers/scsi/sd.c +++ usb-4.4/drivers/scsi/sd.c @@ -3275,8 +3275,8 @@ static int sd_suspend_common(struct devi struct scsi_disk *sdkp = dev_get_drvdata(dev); int ret = 0; - if (!sdkp) - return 0; /* this can happen */ + if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ + return 0; if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); @@ -3315,6 +3315,9 @@ static int sd_resume(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); + if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ + return 0; + if (!sdkp->device->manage_start_stop) return 0; Index: usb-4.4/drivers/scsi/sr.c =================================================================== --- usb-4.4.orig/drivers/scsi/sr.c +++ usb-4.4/drivers/scsi/sr.c @@ -144,6 +144,9 @@ static int sr_runtime_suspend(struct dev { struct scsi_cd *cd = dev_get_drvdata(dev); + if (!cd) /* E.g.: runtime suspend following sr_remove() */ + return 0; + if (cd->media_present) return -EBUSY; else @@ -985,6 +988,7 @@ static int sr_remove(struct device *dev) scsi_autopm_get_device(cd->device); del_gendisk(cd->disk); + dev_set_drvdata(dev, NULL); mutex_lock(&sr_ref_mutex); kref_put(&cd->kref, sr_kref_release);