From patchwork Mon Feb 8 10:58:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luojiaxing X-Patchwork-Id: 12075005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A92A3C433E0 for ; Mon, 8 Feb 2021 11:06:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 633DE64E27 for ; Mon, 8 Feb 2021 11:06:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232861AbhBHLGZ (ORCPT ); Mon, 8 Feb 2021 06:06:25 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:12870 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232825AbhBHLAK (ORCPT ); Mon, 8 Feb 2021 06:00:10 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DZ3012Flwz7hqv; Mon, 8 Feb 2021 18:57:53 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 18:59:11 +0800 From: Luo Jiaxing To: CC: , , Subject: [PATCH v1 1/2] irqchip/gic-v3-its: don't set bitmap for LPI which user didn't allocate Date: Mon, 8 Feb 2021 18:58:45 +0800 Message-ID: <1612781926-56206-2-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612781926-56206-1-git-send-email-luojiaxing@huawei.com> References: <1612781926-56206-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The driver sets the LPI bitmap of device based on get_count_order(nvecs). This means that when the number of LPI interrupts does not meet the power of two, redundant bits are set in the LPI bitmap. However, when free interrupt, these redundant bits is not cleared. As a result, device will fails to allocate the same numbers of interrupts next time. Therefore, clear the redundant bits set in LPI bitmap. Fixes: 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt that has no mapping") Signed-off-by: Luo Jiaxing --- drivers/irqchip/irq-gic-v3-its.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index ed46e60..027f7ef 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3435,6 +3435,10 @@ static int its_alloc_device_irq(struct its_device *dev, int nvecs, irq_hw_number *hwirq = dev->event_map.lpi_base + idx; + bitmap_clear(dev->event_map.lpi_map, + idx + nvecs, + roundup_pow_of_two(nvecs) - nvecs); + return 0; } From patchwork Mon Feb 8 10:58:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luojiaxing X-Patchwork-Id: 12075003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2200C433E6 for ; Mon, 8 Feb 2021 11:04:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7102564E7B for ; Mon, 8 Feb 2021 11:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232954AbhBHLCV (ORCPT ); Mon, 8 Feb 2021 06:02:21 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:12869 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbhBHLAK (ORCPT ); Mon, 8 Feb 2021 06:00:10 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DZ3011pt1z7hkj; Mon, 8 Feb 2021 18:57:53 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 18:59:11 +0800 From: Luo Jiaxing To: CC: , , Subject: [PATCH v1 2/2] genirq/msi: add an error print when __irq_domain_alloc_irqs() failed Date: Mon, 8 Feb 2021 18:58:46 +0800 Message-ID: <1612781926-56206-3-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612781926-56206-1-git-send-email-luojiaxing@huawei.com> References: <1612781926-56206-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org During debug, we found that the return value of __irq_domain_alloc_irqs() will be overwritten by the return value of subsequent function. As a result, the locating clue will be lost. To improve debug efficiency, an error message is added to print the return value of __irq_domain_alloc_irqs(). Signed-off-by: Luo Jiaxing --- kernel/irq/msi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index b338d62..f8729b0 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -418,6 +418,7 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, desc->affinity); if (virq < 0) { ret = -ENOSPC; + dev_err(dev, "failed to allocate irq, virq=%d\n", virq); if (ops->handle_error) ret = ops->handle_error(domain, desc, ret); if (ops->msi_finish)