From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941162AbcKNXGl (ORCPT ); Mon, 14 Nov 2016 18:06:41 -0500 Received: from mail-bl2nam02on0115.outbound.protection.outlook.com ([104.47.38.115]:40245 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S937878AbcKNXGk (ORCPT ); Mon, 14 Nov 2016 18:06:40 -0500 From: KY Srinivasan To: Dexuan Cui , Bjorn Helgaas , "linux-pci@vger.kernel.org" , "devel@linuxdriverproject.org" CC: "gregkh@linuxfoundation.org" , Haiyang Zhang , Stephen Hemminger , "Jake Oshins" , Hadden Hoppert , "Vitaly Kuznetsov" , "jasowang@redhat.com" , "apw@canonical.com" , "olaf@aepfle.de" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 2/3] PCI: hv: fix hv_pci_remove() for hot-remove Thread-Topic: [PATCH 2/3] PCI: hv: fix hv_pci_remove() for hot-remove Thread-Index: AdI7IqyRrDR3tD1kS56J2c38IbZyTADqQpyg Date: Mon, 14 Nov 2016 23:06:36 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; x-originating-ip: [2001:4898:80e8:6::3e6] x-microsoft-exchange-diagnostics: 1;DM5PR03MB2665;7:QwYFBPoTkBi9hwCBRXI3e0a75yIKmyCF/DOMQsdnoyt2d6Jo00Jj3RvqvynZUSxFA3b3Z3NNtAptmGg3Vk/hwcgH9oOLYfQr/4UiAqEypiawRKBRb4b6RqPwc5nTm3prhSUU0d5ANDxM/I2Vnr/mQ18RKiCc7+sqngTco7ppMmjSBYoeXjQul8WaR7EoQpr15qt46AyL8rUgFEahUbk4oY0BHdxk/EMK1HYMLiud65dWq6mb9S1WPJmGUL6PoQySDpzQvCB5Q/omCQQWXTBA3w1j6G8GNY1RJnutHfPkeM4WAlLi2qmatV9PhjXUlFWcn18dv2EN45/vqdssg3gKzW7qC7exSzfHefrTQNMtHiw47RW8xwspVJ0lC9RczG4M x-ms-office365-filtering-correlation-id: b1ea2fb8-4da7-4ba6-0ee5-08d40ce2e256 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2665; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(211936372134217)(198206253151910); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6045074)(6060326)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(61426038)(61427038)(6046074)(6061324);SRVR:DM5PR03MB2665;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2665; x-forefront-prvs: 0126A32F74 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(377454003)(189002)(13464003)(199003)(2950100002)(76576001)(7696004)(229853002)(10290500002)(7846002)(2900100001)(68736007)(87936001)(33656002)(4326007)(105586002)(77096005)(7736002)(86362001)(189998001)(74316002)(575784001)(305945005)(2201001)(2501003)(106356001)(99286002)(86612001)(122556002)(8990500004)(6116002)(9686002)(102836003)(92566002)(10090500001)(3900700001)(8676002)(2561002)(5660300001)(8936002)(5005710100001)(101416001)(81166006)(2421001)(81156014)(97736004)(2906002)(3280700002)(1511001)(5001770100001)(3660700001)(76176999)(50986999)(54356999);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR03MB2665;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Nov 2016 23:06:36.3123 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2665 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uAEN6laY023616 > -----Original Message----- > From: Dexuan Cui > Sent: Wednesday, November 9, 2016 11:19 PM > To: Bjorn Helgaas ; linux-pci@vger.kernel.org; > devel@linuxdriverproject.org > Cc: gregkh@linuxfoundation.org; KY Srinivasan ; > Haiyang Zhang ; Stephen Hemminger > ; Jake Oshins ; Hadden > Hoppert ; Vitaly Kuznetsov > ; jasowang@redhat.com; apw@canonical.com; > olaf@aepfle.de; linux-kernel@vger.kernel.org > Subject: [PATCH 2/3] PCI: hv: fix hv_pci_remove() for hot-remove > > 1. We don't really need such a big on-stack buffer when sending > the teardown_packet: vmbus_sendpacket() here only uses > sizeof(struct pci_message). > > 2. In the hot-remove case (PCI_EJECT), after we send > PCI_EJECTION_COMPLETE > to the host, the host will send a RESCIND_CHANNEL message to us and the > host won't access the per-channel ringbuffer any longer, so we needn't > send PCI_RESOURCES_RELEASED/PCI_BUS_D0EXIT to the host, and we > shouldn't > expect the host's completion message of PCI_BUS_D0EXIT, which will never > come. > > 3. We should send PCI_BUS_D0EXIT after hv_send_resources_released(). > > Signed-off-by: Dexuan Cui > CC: Jake Oshins > Cc: KY Srinivasan > CC: Haiyang Zhang > CC: Vitaly Kuznetsov Thanks Dexuan. Acked-by: K. Y. Srinivasan > > --- > > I made the patch based on discussions with Jake Oshins and others. > > drivers/pci/host/pci-hyperv.c | 53 +++++++++++++++++++++++++++-------- > -------- > 1 file changed, 33 insertions(+), 20 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index 93ed64a..7590ad0 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -2266,24 +2266,32 @@ static int hv_pci_probe(struct hv_device *hdev, > return ret; > } > > -/** > - * hv_pci_remove() - Remove routine for this VMBus channel > - * @hdev: VMBus's tracking struct for this root PCI bus > - * > - * Return: 0 on success, -errno on failure > - */ > -static int hv_pci_remove(struct hv_device *hdev) > +static void hv_pci_bus_exit(struct hv_device *hdev) > { > - int ret; > - struct hv_pcibus_device *hbus; > - union { > + struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); > + struct { > struct pci_packet teardown_packet; > - u8 buffer[0x100]; > + u8 buffer[sizeof(struct pci_message)]; > } pkt; > struct pci_bus_relations relations; > struct hv_pci_compl comp_pkt; > + int ret; > > - hbus = hv_get_drvdata(hdev); > + /* > + * After the host sends the RESCIND_CHANNEL message, it doesn't > + * access the per-channel ringbuffer any longer. > + */ > + if (hdev->channel->rescind) > + return; > + > + /* Delete any children which might still exist. */ > + memset(&relations, 0, sizeof(relations)); > + hv_pci_devices_present(hbus, &relations); > + > + ret = hv_send_resources_released(hdev); > + if (ret) > + dev_err(&hdev->device, > + "Couldn't send resources released packet(s)\n"); > > memset(&pkt.teardown_packet, 0, sizeof(pkt.teardown_packet)); > init_completion(&comp_pkt.host_event); > @@ -2298,7 +2306,19 @@ static int hv_pci_remove(struct hv_device *hdev) > > VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); > if (!ret) > wait_for_completion_timeout(&comp_pkt.host_event, 10 * > HZ); > +} > + > +/** > + * hv_pci_remove() - Remove routine for this VMBus channel > + * @hdev: VMBus's tracking struct for this root PCI bus > + * > + * Return: 0 on success, -errno on failure > + */ > +static int hv_pci_remove(struct hv_device *hdev) > +{ > + struct hv_pcibus_device *hbus; > > + hbus = hv_get_drvdata(hdev); > if (hbus->state == hv_pcibus_installed) { > /* Remove the bus from PCI's point of view. */ > pci_lock_rescan_remove(); > @@ -2307,17 +2327,10 @@ static int hv_pci_remove(struct hv_device > *hdev) > pci_unlock_rescan_remove(); > } > > - ret = hv_send_resources_released(hdev); > - if (ret) > - dev_err(&hdev->device, > - "Couldn't send resources released packet(s)\n"); > + hv_pci_bus_exit(hdev); > > vmbus_close(hdev->channel); > > - /* Delete any children which might still exist. */ > - memset(&relations, 0, sizeof(relations)); > - hv_pci_devices_present(hbus, &relations); > - > iounmap(hbus->cfg_addr); > hv_free_config_window(hbus); > pci_free_resource_list(&hbus->resources_for_children); > -- > 2.7.4