mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 14:21:47 +00:00
scsi: balance out autopm get/put calls in scsi_sysfs_add_sdev()
SCSI Well-known logical units generally don't have any scsi driver associated with it which means no one will call scsi_autopm_put_device() on these wlun scsi devices and this would result in keeping the corresponding scsi device always active (hence LLD can't be suspended as well). Same exact problem can be seen for other scsi device representing normal logical unit whose driver is yet to be loaded. This patch fixes the above problem with this approach: - make the scsi_autopm_put_device call at the end of scsi_sysfs_add_sdev to make it balance out the get earlier in the function. - let drivers do paired get/put calls in their probe methods. Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Dolev Raviv <draviv@codeaurora.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
50c4e96411
commit
6fe8c1dbef
@ -1044,10 +1044,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
|
|||||||
pm_runtime_enable(&sdev->sdev_gendev);
|
pm_runtime_enable(&sdev->sdev_gendev);
|
||||||
scsi_autopm_put_target(starget);
|
scsi_autopm_put_target(starget);
|
||||||
|
|
||||||
/* The following call will keep sdev active indefinitely, until
|
|
||||||
* its driver does a corresponding scsi_autopm_pm_device(). Only
|
|
||||||
* drivers supporting autosuspend will do this.
|
|
||||||
*/
|
|
||||||
scsi_autopm_get_device(sdev);
|
scsi_autopm_get_device(sdev);
|
||||||
|
|
||||||
error = device_add(&sdev->sdev_gendev);
|
error = device_add(&sdev->sdev_gendev);
|
||||||
@ -1085,6 +1081,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scsi_autopm_put_device(sdev);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2965,6 +2965,7 @@ static int sd_probe(struct device *dev)
|
|||||||
int index;
|
int index;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
scsi_autopm_get_device(sdp);
|
||||||
error = -ENODEV;
|
error = -ENODEV;
|
||||||
if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)
|
if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)
|
||||||
goto out;
|
goto out;
|
||||||
@ -3041,6 +3042,7 @@ static int sd_probe(struct device *dev)
|
|||||||
out_free:
|
out_free:
|
||||||
kfree(sdkp);
|
kfree(sdkp);
|
||||||
out:
|
out:
|
||||||
|
scsi_autopm_put_device(sdp);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,6 +657,7 @@ static int sr_probe(struct device *dev)
|
|||||||
struct scsi_cd *cd;
|
struct scsi_cd *cd;
|
||||||
int minor, error;
|
int minor, error;
|
||||||
|
|
||||||
|
scsi_autopm_get_device(sdev);
|
||||||
error = -ENODEV;
|
error = -ENODEV;
|
||||||
if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
|
if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -744,6 +745,7 @@ fail_put:
|
|||||||
fail_free:
|
fail_free:
|
||||||
kfree(cd);
|
kfree(cd);
|
||||||
fail:
|
fail:
|
||||||
|
scsi_autopm_put_device(sdev);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4105,6 +4105,7 @@ static int st_probe(struct device *dev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scsi_autopm_get_device(SDp);
|
||||||
i = queue_max_segments(SDp->request_queue);
|
i = queue_max_segments(SDp->request_queue);
|
||||||
if (st_max_sg_segs < i)
|
if (st_max_sg_segs < i)
|
||||||
i = st_max_sg_segs;
|
i = st_max_sg_segs;
|
||||||
@ -4244,6 +4245,7 @@ out_put_disk:
|
|||||||
out_buffer_free:
|
out_buffer_free:
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
out:
|
out:
|
||||||
|
scsi_autopm_put_device(SDp);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user