Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1355510pxj; Wed, 19 May 2021 04:19:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYxR7xyFieo/pNk5OkQFI5+QHdyQE5FVqYSEoOJetkPHXei5Cxz2cA4zpq4M+kUMAZPgBa X-Received: by 2002:a92:cda7:: with SMTP id g7mr9141739ild.50.1621423140000; Wed, 19 May 2021 04:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621423139; cv=none; d=google.com; s=arc-20160816; b=qbyMp1LZLPjcxjwqNjCX+ee+LDOmqJkJPVL+mrxvV2puNfLeaJOM+dUDf8H6J5O4y2 2RoFuVp/K8IQHhPKit86gj6FeZFDJwlaW5RMVzVYEkhSbPAlbdp9/Dz+VHOuwd+ruNzS RGgN3TIdRw+J/4sFt6yqQXxnyoxJ8fCGiBHHVtsuI63j0FceEj0to2yrvB2KjxnySgQH OjOH8RarNkZGugA7oO5EIhcJRxEemnbD1gLMnPygKb0JxQobOSUsThXNUZVYT01cI4mD HGOXzMbALVSWk18ZIRBYH9w5vn2rua1fIeZprwCTD7OiUW2OHhj3WlWiW8UeenHQaQ5F VfAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=yuPxvtgplc8Cv+Lod+sL0p0HgLwqcX0WVV40YXGOU9M=; b=0FypnwOr9JyubH1+Tfrd4sjSvST5IAhNeG9uCfJ521gNEsFSYlszR6aWxGc+Wpm9Wa zJgzsMsnlMdTBdMT2fxV0kV/9OTNnjesFPXFBzCf8+JYgzUrAj5eKpCtZ/Z6/vb1RrG7 Ed0BAhz9hSeqn+T2fK3aDfT6IjFGuIhIaIY3DkFtpl+7Xgs1g9js/KEMiJ4RzCpqHDiW 04qoqfTBKzPNiiyTrRC32XmwVUHOnbok1xu3CjKqp4Y6Q0GUZ88KKWvQZXlANVyc8/2R 67m/LZ0EiMQX0bJHFjCM5+ppndu9mw9Yl1493wpZHyljTeIb2mdOS7oBarq4ukC8kihb y8KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si24845493iog.66.2021.05.19.04.18.47; Wed, 19 May 2021 04:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346205AbhERCJX (ORCPT + 99 others); Mon, 17 May 2021 22:09:23 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4724 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbhERCJW (ORCPT ); Mon, 17 May 2021 22:09:22 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FkfSz5nxVzmhqb; Tue, 18 May 2021 10:04:35 +0800 (CST) Received: from dggpemm500004.china.huawei.com (7.185.36.219) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 18 May 2021 10:08:04 +0800 Received: from huawei.com (10.174.28.241) by dggpemm500004.china.huawei.com (7.185.36.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 18 May 2021 10:08:03 +0800 From: Bixuan Cui To: , CC: , , , , , Subject: [PATCH] genirq/msi: Fix unpaired calls in msi Date: Tue, 18 May 2021 11:31:17 +0800 Message-ID: <20210518033117.78104-1-cuibixuan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.28.241] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500004.china.huawei.com (7.185.36.219) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are unpaired calls in the msi: msi_domain_alloc_irqs() { ... __irq_domain_alloc_irqs() ... irq_domain_activate_irq() } msi_domain_free_irqs() { ... irq_domain_free_irqs() } When msi_domain_alloc_irqs() and msi_domain_free_irqs() are called in pairs, the irq_domain_deactivate_irq() is missing calls. This problem occurs during PCI initialization.After pci_msi_setup_msi_irqs is executed (invoke irq_domain_activate_irq to initialize the MSI irq), error_cleanup_irqs() of pcie_port_device_register() is executed. As follows: pcie_port_device_register() { ... error_cleanup_irqs: pci_free_irq_vectors(dev); } Invoking Procedure: pcie_port_device_register -> goto error_cleanup_irqs -> pci_free_irq_vectors(dev); pci_disable_msi free_msi_irqs pci_msi_teardown_msi_irqs msi_domain_free_irqs // no deactivate before free irq_domain_free_irqs Signed-off-by: Bixuan Cui --- kernel/irq/msi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index c41965e348b5..8828d4863c5d 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -476,11 +476,6 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, return 0; cleanup: - for_each_msi_vector(desc, i, dev) { - irq_data = irq_domain_get_irq_data(domain, i); - if (irqd_is_activated(irq_data)) - irq_domain_deactivate_irq(irq_data); - } msi_domain_free_irqs(domain, dev); return ret; } @@ -506,6 +501,14 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) { struct msi_desc *desc; + struct irq_data *irq_data; + int i; + + for_each_msi_vector(desc, i, dev) { + irq_data = irq_domain_get_irq_data(domain, i); + if (irqd_is_activated(irq_data)) + irq_domain_deactivate_irq(irq_data); + } for_each_msi_entry(desc, dev) { /* -- 2.17.1