Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3261801pxj; Tue, 1 Jun 2021 00:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC4iJk7dmdxfxQ7go33SkS18+kRxj/J6EaovTRjvJMUx/ZnOx7nJtYbh6S8gBOTVfPiiQ5 X-Received: by 2002:a17:906:3912:: with SMTP id f18mr8430475eje.161.1622534230167; Tue, 01 Jun 2021 00:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622534230; cv=none; d=google.com; s=arc-20160816; b=X4a0r5fHEMWErbiXfYoCck9MG/bUvZXr2bBUo3VBmXUCYpkNxHz8Wb03Pgn7mDmyrB 79Nts4f8WQamymtIQ4gVtBzsB215lTCf3A56PmSbti2jIhLHzeX/NoxlN5W6gz9apCbD TssP8a7v50/q76yAvvOpZSnEUD9svPOKR5hEoIb6GrT7Nw4UYAh3BUfrzHbfJ3kwoB8P 0z43oQcoAB4cWLPqy2CAoRmfuSvyRLoj3hJ/x4Kr8lXf3nqyuUErKewBg1nEK9dKQidm XhfZmQUfOVWt4EwZMXU/eKfRdmPWdPDHRuCJoO53lzTfkXzmCbge0Kv0tW0zJrVv1Dac V5EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=tpREtYSsCWaMUaZ24K6cZUGEj7Xg1oppdXhs0jUvHGk=; b=z7ywTD+ZDBe9XKY42e81r0fXb9EsIQhepvgCDweEgmr09l5wmg6iOElzgCP0YkiDrB +3MHQzM8Ki1GiW5fVfmyK27aiQf8hUlKodozNgx9wDM3BJrxjzFmDVfFRIrl+l7RFviv ezssNrWj/fKozDhZ6XGVVkulEocYfLZP1WBuRomvTczmdNnwam7I+3XZxQMVVKoqMYTY zoXO1u2t/tEf9sU74dirmEHESM5/UJnYIOrw6N6k5loAl8u2kDt/FAy4L86F1/Fm8Ab9 eDWLY181mbyPL2xR/i+13uubzmbQk24UE19wB3M+PRMDTLePj7WfjHcqzIpeULFZFTdc jSsw== 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 w19si14725294edc.370.2021.06.01.00.56.47; Tue, 01 Jun 2021 00:57:10 -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 S233098AbhFAHz3 (ORCPT + 99 others); Tue, 1 Jun 2021 03:55:29 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3366 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233069AbhFAHz2 (ORCPT ); Tue, 1 Jun 2021 03:55:28 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4FvPT662K0z630D; Tue, 1 Jun 2021 15:50:02 +0800 (CST) Received: from dggpemm500004.china.huawei.com (7.185.36.219) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 1 Jun 2021 15:53:46 +0800 Received: from [10.174.177.91] (10.174.177.91) 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, 1 Jun 2021 15:53:45 +0800 Subject: Re: [PATCH] genirq/msi: Fix unpaired calls in msi To: , CC: , , , , References: <20210518033117.78104-1-cuibixuan@huawei.com> From: Bixuan Cui Message-ID: <70ac79fb-aa73-33fe-3ed5-f1d2b59ed7cb@huawei.com> Date: Tue, 1 Jun 2021 15:53:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20210518033117.78104-1-cuibixuan@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.91] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 A gentle ping :) Thanks Bixuan Cui On 2021/5/18 11:31, Bixuan Cui wrote: > 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) { > /* >