From patchwork Tue Jun 2 02:07:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1302011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bb782gRMz9sSf; Tue, 2 Jun 2020 12:08:34 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jfwLu-0005Cn-GQ; Tue, 02 Jun 2020 02:08:30 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwLr-0005CD-B4 for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:08:27 +0000 Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwLr-0001y5-11 for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:08:27 +0000 Received: by mail-qk1-f197.google.com with SMTP id v6so10020741qkh.7 for ; Mon, 01 Jun 2020 19:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AJ87Pr5G2rIqi3bey6f73wywyydo7i2ACChsoLahVRY=; b=GeJ4ONJ7xTxdkawSZZTPdo2ZWvhfDpMbb8pD3bC3Xq9BYgAE5up2Nw5gp3TXnNa1OW iwKi4GW3YvtpoMK+BuudX0v5QZMfXw5+tYAUe3LG3+B1CUjuQfj8ygtYregcyUPVo2eS Hfm6BLK6Rw6d6gxXVguQZtT4zR+Lln7PLjPtob42Nii8AQa1kUL1zeqtB3oGMtrJZvIF 7Tu7ZvCS8GR6t4NDXFKxs2LWxUtdnTrC14U8hh1WmokM9Pe196nwSNCQ4gFFlv5OGTva /mUwMhW/MyvyK4sE2CVVBnkb6lb4MSyj+5dtiJ3HL6jjnuOMirtk9NX4bo8oq0RFADoE APhA== X-Gm-Message-State: AOAM5328emRinh8DRPGpb76Hft43LwT97FSGj/+Qm5S/lCKfieBINuIG RL9/St/eG4E+xgSvesytriJhPYy/XvRjWEyItxgw0eRc9E3NVZqRqZqJcfbzpTkfsbqvQltnEis h4YTv9Y14WRpvZTM20cjdwGjWYcSmlKlbnFEvlgaM X-Received: by 2002:a0c:c2c2:: with SMTP id c2mr22521581qvi.150.1591063705627; Mon, 01 Jun 2020 19:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3rkCyo1PapIoSPzm4z5JBPFNqK5pceHOKcqk4vCFFcLUHIR2buIq1d3t8LYKwqLtopW7G4A== X-Received: by 2002:a0c:c2c2:: with SMTP id c2mr22521571qvi.150.1591063705308; Mon, 01 Jun 2020 19:08:25 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id t13sm1138342qtc.77.2020.06.01.19.08.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 19:08:24 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [focal:linux-azure][PATCH 02/21] scsi: storvsc: Add the support of hibernation Date: Mon, 1 Jun 2020 23:07:58 -0300 Message-Id: <20200602020817.236422-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602020817.236422-1-marcelo.cerri@canonical.com> References: <20200602020817.236422-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1880032 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 Acked-by: Martin K. Petersen Signed-off-by: Sasha Levin (cherry picked from commit 56fb105859345d65aed08ebbb0f6160c4f0777eb) Signed-off-by: Marcelo Henrique Cerri --- 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 7402bc63cdc2..423972dfefae 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1727,6 +1727,13 @@ static const struct hv_vmbus_device_id id_table[] = { 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) { @@ -1942,11 +1949,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, },