From nobody Tue Feb 10 11:38:43 2026 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=1563874453; cv=none; d=zoho.com; s=zohoarc; b=V5VhlboQ6lfeEvnp58MhETVdepAkrxMMeMA+LsERz7FJPzOv0TDyY/7i9fVObgqTEW6GkWEAHvl0wngXQA/MOevp3gFAkUPCzFLIUBLhrM9tSrR2b8QlITAU5layvavqx1qLvFMWb8XwSR9zf2MDiW8aFO4cYi94Rids5sJ/5UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563874453; 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=QEpneJkyNoXnrHpgEkp4dXgfV+qkZ/SymtspTXVuGNQ=; b=Y8XmObLkyr8Negi6MVDsVnFEunOZS8L0X5zqQH36JwRBz8vIcZiYyeFzpQCKKTgHWmbBroctEbW8qWEO9meOJHdH4PVJiHdbbP5QZ698lsLzj0LyNTkVkLv1m6B9+A3UJH4cL5VyyAcvUKYiFU7HuxeWwQLYMUbl6qA0GyrJzYA= 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 1563874453247474.3453913946388; Tue, 23 Jul 2019 02:34:13 -0700 (PDT) Received: from localhost ([::1]:40590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hprBU-0007Um-4V for importer@patchew.org; Tue, 23 Jul 2019 05:34:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47886) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hprBH-00072D-Ps for qemu-devel@nongnu.org; Tue, 23 Jul 2019 05:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hprBG-0008CN-8x for qemu-devel@nongnu.org; Tue, 23 Jul 2019 05:33:59 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2482 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hprBF-0008BE-SX for qemu-devel@nongnu.org; Tue, 23 Jul 2019 05:33:58 -0400 Received: from dggeml406-hub.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 2700CFF488D0A16F80FB; Tue, 23 Jul 2019 17:33:54 +0800 (CST) Received: from DGGEML423-HUB.china.huawei.com (10.1.199.40) by dggeml406-hub.china.huawei.com (10.3.17.50) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jul 2019 17:33:53 +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 17:33:44 +0800 From: "Zhangbo (Oscar)" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v2] pcie: fix device unplug timeout Thread-Index: AdVBOa+k2REPW1pPTHWvtO0bYVI0tA== Date: Tue, 23 Jul 2019 09:33:43 +0000 Message-ID: <0259E1C966E8C54AA93AA2B1240828E672DF3D45@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.188 Subject: [Qemu-devel] [PATCH v2] 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\)" , "philmd@redhat.com" , "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: Li Mingwang Signed-off-by: Fang Ying Signed-off-by: Zhang Bo --- 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