Linux-HyperV Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] scsi: storvsc: Add the support of hibernation
@ 2019-09-25 20:11 Dexuan Cui
  2019-09-25 21:55 ` kbuild test robot
  2019-10-01 18:51 ` Sasha Levin
  0 siblings, 2 replies; 4+ messages in thread
From: Dexuan Cui @ 2019-09-25 20:11 UTC (permalink / raw)
  To: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, sashal, jejb,
	martin.petersen, linux-hyperv, linux-scsi, linux-kernel,
	Michael Kelley
  Cc: Dexuan Cui

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 <decui@microsoft.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>

---

This patch is basically a pure Hyper-V specific change and it has a
build dependency on the commit 271b2224d42f ("Drivers: hv: vmbus: Implement
suspend/resume for VSC drivers for hibernation"), which is on Sasha Levin's
Hyper-V tree's hyperv-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/log/?h=hyperv-next

I request this patch should go through Sasha's tree rather than the
SCSI tree.

In v2:
	Added Acked-by from Martin.

	@Sasha: I think the patch can go through the hyper-v tree, since
                we have the Ack from Martin. :-)

	No other change.


 drivers/scsi/storvsc_drv.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index ed8b9ac..9fbf604 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1727,6 +1727,13 @@ enum {
 
 MODULE_DEVICE_TABLE(vmbus, id_table);
 
+static const struct { guid_t guid; } fc_guid = { HV_SYNTHFC_GUID };
+
+static bool hv_dev_is_fc(struct hv_device *hv_dev)
+{
+	return guid_equal(&fc_guid.guid, &hv_dev->dev_type);
+}
+
 static int storvsc_probe(struct hv_device *device,
 			const struct hv_vmbus_device_id *dev_id)
 {
@@ -1935,11 +1942,45 @@ static int storvsc_remove(struct hv_device *dev)
 	return 0;
 }
 
+static int storvsc_suspend(struct hv_device *hv_dev)
+{
+	struct storvsc_device *stor_device = hv_get_drvdata(hv_dev);
+	struct Scsi_Host *host = stor_device->host;
+	struct hv_host_device *host_dev = shost_priv(host);
+
+	storvsc_wait_to_drain(stor_device);
+
+	drain_workqueue(host_dev->handle_error_wq);
+
+	vmbus_close(hv_dev->channel);
+
+	memset(stor_device->stor_chns, 0,
+	       num_possible_cpus() * sizeof(void *));
+
+	kfree(stor_device->stor_chns);
+	stor_device->stor_chns = NULL;
+
+	cpumask_clear(&stor_device->alloced_cpus);
+
+	return 0;
+}
+
+static int storvsc_resume(struct hv_device *hv_dev)
+{
+	int ret;
+
+	ret = storvsc_connect_to_vsp(hv_dev, storvsc_ringbuffer_size,
+				     hv_dev_is_fc(hv_dev));
+	return ret;
+}
+
 static struct hv_driver storvsc_drv = {
 	.name = KBUILD_MODNAME,
 	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
+	.suspend = storvsc_suspend,
+	.resume = storvsc_resume,
 	.driver = {
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add the support of hibernation
  2019-09-25 20:11 [PATCH v2] scsi: storvsc: Add the support of hibernation Dexuan Cui
@ 2019-09-25 21:55 ` kbuild test robot
  2019-09-25 22:15   ` Dexuan Cui
  2019-10-01 18:51 ` Sasha Levin
  1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2019-09-25 21:55 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: kbuild-all, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	sashal, jejb, martin.petersen, linux-hyperv, linux-scsi,
	linux-kernel, Michael Kelley, Dexuan Cui

[-- Attachment #1: Type: text/plain, Size: 2342 bytes --]

Hi Dexuan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[cannot apply to v5.3 next-20190924]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dexuan-Cui/scsi-storvsc-Add-the-support-of-hibernation/20190926-041702
base:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-rhel (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers//scsi/storvsc_drv.c:1981:3: error: 'struct hv_driver' has no member named 'suspend'
     .suspend = storvsc_suspend,
      ^~~~~~~
>> drivers//scsi/storvsc_drv.c:1981:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .suspend = storvsc_suspend,
                ^~~~~~~~~~~~~~~
   drivers//scsi/storvsc_drv.c:1981:13: note: (near initialization for 'storvsc_drv.shutdown')
>> drivers//scsi/storvsc_drv.c:1982:3: error: 'struct hv_driver' has no member named 'resume'; did you mean 'remove'?
     .resume = storvsc_resume,
      ^~~~~~
      remove
   drivers//scsi/storvsc_drv.c:1982:12: warning: excess elements in struct initializer
     .resume = storvsc_resume,
               ^~~~~~~~~~~~~~
   drivers//scsi/storvsc_drv.c:1982:12: note: (near initialization for 'storvsc_drv')
   cc1: some warnings being treated as errors

vim +1981 drivers//scsi/storvsc_drv.c

  1975	
  1976	static struct hv_driver storvsc_drv = {
  1977		.name = KBUILD_MODNAME,
  1978		.id_table = id_table,
  1979		.probe = storvsc_probe,
  1980		.remove = storvsc_remove,
> 1981		.suspend = storvsc_suspend,
> 1982		.resume = storvsc_resume,
  1983		.driver = {
  1984			.probe_type = PROBE_PREFER_ASYNCHRONOUS,
  1985		},
  1986	};
  1987	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 43550 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] scsi: storvsc: Add the support of hibernation
  2019-09-25 21:55 ` kbuild test robot
@ 2019-09-25 22:15   ` Dexuan Cui
  0 siblings, 0 replies; 4+ messages in thread
From: Dexuan Cui @ 2019-09-25 22:15 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	sashal, jejb, martin.petersen, linux-hyperv, linux-scsi,
	linux-kernel, Michael Kelley

> From: kbuild test robot <lkp@intel.com>
> Sent: Wednesday, September 25, 2019 2:55 PM
> To: Dexuan Cui <decui@microsoft.com>
> Cc: kbuild-all@01.org; KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; sashal@kernel.org; jejb@linux.ibm.com;
> martin.petersen@oracle.com; linux-hyperv@vger.kernel.org;
> linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Michael Kelley
> <mikelley@microsoft.com>; Dexuan Cui <decui@microsoft.com>
> Subject: Re: [PATCH v2] scsi: storvsc: Add the support of hibernation
> 
> Hi Dexuan,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on mkp-scsi/for-next]
> [cannot apply to v5.3 next-20190924]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see
> [...snipped...]
> config: x86_64-rhel (attached as .config)
> compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers//scsi/storvsc_drv.c:1981:3: error: 'struct hv_driver' has no member
> named 'suspend'
>      .suspend = storvsc_suspend,
>       ^~~~~~~

This patch depends on the below patch in Linus's tree (today):
271b2224d42f ("Drivers: hv: vmbus: Implement suspend/resume for VSC drivers for hibernation")
So, we don't really have an issue here.

The mkp-scsi/for-next branch needs to do a merge with Linus's master branch.

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add the support of hibernation
  2019-09-25 20:11 [PATCH v2] scsi: storvsc: Add the support of hibernation Dexuan Cui
  2019-09-25 21:55 ` kbuild test robot
@ 2019-10-01 18:51 ` Sasha Levin
  1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-10-01 18:51 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, jejb,
	martin.petersen, linux-hyperv, linux-scsi, linux-kernel,
	Michael Kelley

On Wed, Sep 25, 2019 at 08:11:08PM +0000, Dexuan Cui wrote:
>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 <decui@microsoft.com>
>Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
>
>---
>
>This patch is basically a pure Hyper-V specific change and it has a
>build dependency on the commit 271b2224d42f ("Drivers: hv: vmbus: Implement
>suspend/resume for VSC drivers for hibernation"), which is on Sasha Levin's
>Hyper-V tree's hyperv-next branch:
>https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/log/?h=hyperv-next
>
>I request this patch should go through Sasha's tree rather than the
>SCSI tree.
>
>In v2:
>	Added Acked-by from Martin.
>
>	@Sasha: I think the patch can go through the hyper-v tree, since
>                we have the Ack from Martin. :-)

Queued up for hyperv-next, thanks!

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 20:11 [PATCH v2] scsi: storvsc: Add the support of hibernation Dexuan Cui
2019-09-25 21:55 ` kbuild test robot
2019-09-25 22:15   ` Dexuan Cui
2019-10-01 18:51 ` Sasha Levin

Linux-HyperV Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hyperv/0 linux-hyperv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hyperv linux-hyperv/ https://lore.kernel.org/linux-hyperv \
		linux-hyperv@vger.kernel.org linux-hyperv@archiver.kernel.org
	public-inbox-index linux-hyperv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hyperv


AGPL code for this site: git clone https://public-inbox.org/ public-inbox