aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhash Jadavani <subhashj@codeaurora.org>2014-09-10 07:54:09 -0400
committerChristoph Hellwig <hch@lst.de>2014-09-15 19:02:05 -0400
commit6fe8c1dbefd63ef3988edb745d9eb81fc6d0513c (patch)
tree004e03b101ba8afc0886b9356d62f04bf45cacc9
parent50c4e96411a6cd728f04cf70d8d6def57828b320 (diff)
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>
-rw-r--r--drivers/scsi/scsi_sysfs.c5
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/st.c2
4 files changed, 7 insertions, 4 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 85e36f3a5585..f4cb7b3e9e23 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1044,10 +1044,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
1044 pm_runtime_enable(&sdev->sdev_gendev); 1044 pm_runtime_enable(&sdev->sdev_gendev);
1045 scsi_autopm_put_target(starget); 1045 scsi_autopm_put_target(starget);
1046 1046
1047 /* The following call will keep sdev active indefinitely, until
1048 * its driver does a corresponding scsi_autopm_pm_device(). Only
1049 * drivers supporting autosuspend will do this.
1050 */
1051 scsi_autopm_get_device(sdev); 1047 scsi_autopm_get_device(sdev);
1052 1048
1053 error = device_add(&sdev->sdev_gendev); 1049 error = device_add(&sdev->sdev_gendev);
@@ -1085,6 +1081,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
1085 } 1081 }
1086 } 1082 }
1087 1083
1084 scsi_autopm_put_device(sdev);
1088 return error; 1085 return error;
1089} 1086}
1090 1087
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index aa43496b7b93..0cb5c9f0c743 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2965,6 +2965,7 @@ static int sd_probe(struct device *dev)
2965 int index; 2965 int index;
2966 int error; 2966 int error;
2967 2967
2968 scsi_autopm_get_device(sdp);
2968 error = -ENODEV; 2969 error = -ENODEV;
2969 if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC) 2970 if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)
2970 goto out; 2971 goto out;
@@ -3041,6 +3042,7 @@ static int sd_probe(struct device *dev)
3041 out_free: 3042 out_free:
3042 kfree(sdkp); 3043 kfree(sdkp);
3043 out: 3044 out:
3045 scsi_autopm_put_device(sdp);
3044 return error; 3046 return error;
3045} 3047}
3046 3048
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 7eeb93627beb..2de44cc58b1a 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -657,6 +657,7 @@ static int sr_probe(struct device *dev)
657 struct scsi_cd *cd; 657 struct scsi_cd *cd;
658 int minor, error; 658 int minor, error;
659 659
660 scsi_autopm_get_device(sdev);
660 error = -ENODEV; 661 error = -ENODEV;
661 if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM) 662 if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
662 goto fail; 663 goto fail;
@@ -744,6 +745,7 @@ fail_put:
744fail_free: 745fail_free:
745 kfree(cd); 746 kfree(cd);
746fail: 747fail:
748 scsi_autopm_put_device(sdev);
747 return error; 749 return error;
748} 750}
749 751
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index aff9689de0f7..d3fd6e8fb378 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4105,6 +4105,7 @@ static int st_probe(struct device *dev)
4105 return -ENODEV; 4105 return -ENODEV;
4106 } 4106 }
4107 4107
4108 scsi_autopm_get_device(SDp);
4108 i = queue_max_segments(SDp->request_queue); 4109 i = queue_max_segments(SDp->request_queue);
4109 if (st_max_sg_segs < i) 4110 if (st_max_sg_segs < i)
4110 i = st_max_sg_segs; 4111 i = st_max_sg_segs;
@@ -4244,6 +4245,7 @@ out_put_disk:
4244out_buffer_free: 4245out_buffer_free:
4245 kfree(buffer); 4246 kfree(buffer);
4246out: 4247out:
4248 scsi_autopm_put_device(SDp);
4247 return -ENODEV; 4249 return -ENODEV;
4248}; 4250};
4249 4251