From nobody Sat May 18 07:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1563868119; cv=none; d=zoho.com; s=zohoarc; b=lzCL1GIPsM1WcWUe+3b4TOoxFbxO+Sa+lwr9cQSvYGFpKj9hRH2uDaejEafHJldccBKY3kgYTbSataoMlM/vUOitA+4X2vx7xG1Wb0bJ7uYhayCSau+soEE664I6jCJwae/2ZRtY65wS0UsRSY0ChsY7LsozNfJaabuvzq5neNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563868119; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=YatDOvu3tyL5kM8MJtAjtZIVJvcM5q4OBAku7cowIiQ=; b=QkjAQ4HJz/5ZjiYrmoO/QA4jPGt+Aa98jkSDYn6EKkU0k5Hmp9U1gz9dGnjDxF3KMrHQLbq4Ug9Q7GmF1n0RmehPMtO2ijJjqumeix7J+puJtDTOSu+wOWQ2ltDoUiqm7IAZsn+dwt3WN173oq8jgHRKFLKbL/PnZuyzt+qZe8k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563868119250874.3982721538537; Tue, 23 Jul 2019 00:48:39 -0700 (PDT) Received: from localhost ([::1]:39904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hppXI-00046I-2C for importer@patchew.org; Tue, 23 Jul 2019 03:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46723) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hppWx-0003Dj-Bb for qemu-devel@nongnu.org; Tue, 23 Jul 2019 03:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hppWw-0004wL-5a for qemu-devel@nongnu.org; Tue, 23 Jul 2019 03:48:15 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:2049 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hppWv-0004u1-Pe for qemu-devel@nongnu.org; Tue, 23 Jul 2019 03:48:14 -0400 Received: from DGGEML402-HUB.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 37A392BD08075E719FBD; Tue, 23 Jul 2019 15:48:10 +0800 (CST) Received: from DGGEML423-HUB.china.huawei.com (10.1.199.40) by DGGEML402-HUB.china.huawei.com (10.3.17.38) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jul 2019 15:48:09 +0800 Received: from DGGEML509-MBX.china.huawei.com ([169.254.1.213]) by dggeml423-hub.china.huawei.com ([10.1.199.40]) with mapi id 14.03.0439.000; Tue, 23 Jul 2019 15:48:00 +0800 From: "Zhangbo (Oscar)" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH] pcie: fix device unplug timeout Thread-Index: AdVBKcKkGyAqa5gqR9GDySD3jrl0FA== Date: Tue, 23 Jul 2019 07:48:00 +0000 Message-ID: <0259E1C966E8C54AA93AA2B1240828E672DF1C9F@dggeml509-mbx.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.17.158] Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.189 Subject: [Qemu-devel] [PATCH] pcie: fix device unplug timeout X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fangying , "dengkai \(A\)" , "limingwang \(A\)" , "mst@redhat.com" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" If the linux kernel only receives an ABP event during pcie unplug, it will = sleep 5s=20 to expect a PDC event, which will cause device unplug timeout. In the meanwhile, if the kernel only receives a PDC event during the unplug= , it will wait for at least 1 second before checking card present as data link l= ayer state changed (link down) event reported prior to presence detect changed (card is not present). Therefore we can send both ABP and PDC events to the kernel in unplug proce= ss to avoid unplug timeout. Signed-off-by: limingwang@huawei.com Signed-off-by: fangying1@huawei.com Signed-off-by: oscar.zhangbo@huawei.com --- hw/pci/pcie.c | 8 ++------ include/hw/pci/pcie.h | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 174f392..a800f23 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -485,7 +485,8 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *ho= tplug_dev, PCI_EXP_LNKSTA_DLLLA); } =20 - pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev)); + pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), + PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP); } =20 /* pci express slot for pci express root/downstream port @@ -701,11 +702,6 @@ int pcie_cap_slot_post_load(void *opaque, int version_= id) return 0; } =20 -void pcie_cap_slot_push_attention_button(PCIDevice *dev) -{ - pcie_cap_slot_event(dev, PCI_EXP_HP_EV_ABP); -} - /* root control/capabilities/status. PME isn't emulated for now */ void pcie_cap_root_init(PCIDevice *dev) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 8cf3361..0975a54 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -112,7 +112,6 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t old_slt_ctl, uint16_t old_slt_sta, uint32_t addr, uint32_t val, int len); int pcie_cap_slot_post_load(void *opaque, int version_id); -void pcie_cap_slot_push_attention_button(PCIDevice *dev); =20 void pcie_cap_root_init(PCIDevice *dev); void pcie_cap_root_reset(PCIDevice *dev); --=20 1.8.3.1