Skip to content

Commit 56fb105

Browse files
dcuiSasha Levin
authored andcommitted
scsi: storvsc: Add the support of hibernation
When we're in storvsc_suspend(), we're sure the SCSI layer has quiesced the scsi device by scsi_bus_suspend() -> ... -> scsi_device_quiesce(), so the low level SCSI adapter driver only needs to suspend/resume its own state. Signed-off-by: Dexuan Cui <[email protected]> Acked-by: Martin K. Petersen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 931cccc commit 56fb105

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

drivers/scsi/storvsc_drv.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,13 @@ static const struct hv_vmbus_device_id id_table[] = {
17271727

17281728
MODULE_DEVICE_TABLE(vmbus, id_table);
17291729

1730+
static const struct { guid_t guid; } fc_guid = { HV_SYNTHFC_GUID };
1731+
1732+
static bool hv_dev_is_fc(struct hv_device *hv_dev)
1733+
{
1734+
return guid_equal(&fc_guid.guid, &hv_dev->dev_type);
1735+
}
1736+
17301737
static int storvsc_probe(struct hv_device *device,
17311738
const struct hv_vmbus_device_id *dev_id)
17321739
{
@@ -1934,11 +1941,45 @@ static int storvsc_remove(struct hv_device *dev)
19341941
return 0;
19351942
}
19361943

1944+
static int storvsc_suspend(struct hv_device *hv_dev)
1945+
{
1946+
struct storvsc_device *stor_device = hv_get_drvdata(hv_dev);
1947+
struct Scsi_Host *host = stor_device->host;
1948+
struct hv_host_device *host_dev = shost_priv(host);
1949+
1950+
storvsc_wait_to_drain(stor_device);
1951+
1952+
drain_workqueue(host_dev->handle_error_wq);
1953+
1954+
vmbus_close(hv_dev->channel);
1955+
1956+
memset(stor_device->stor_chns, 0,
1957+
num_possible_cpus() * sizeof(void *));
1958+
1959+
kfree(stor_device->stor_chns);
1960+
stor_device->stor_chns = NULL;
1961+
1962+
cpumask_clear(&stor_device->alloced_cpus);
1963+
1964+
return 0;
1965+
}
1966+
1967+
static int storvsc_resume(struct hv_device *hv_dev)
1968+
{
1969+
int ret;
1970+
1971+
ret = storvsc_connect_to_vsp(hv_dev, storvsc_ringbuffer_size,
1972+
hv_dev_is_fc(hv_dev));
1973+
return ret;
1974+
}
1975+
19371976
static struct hv_driver storvsc_drv = {
19381977
.name = KBUILD_MODNAME,
19391978
.id_table = id_table,
19401979
.probe = storvsc_probe,
19411980
.remove = storvsc_remove,
1981+
.suspend = storvsc_suspend,
1982+
.resume = storvsc_resume,
19421983
.driver = {
19431984
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
19441985
},

0 commit comments

Comments
 (0)