From patchwork Thu Nov 25 13:00:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12693666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1D15C433F5 for ; Thu, 25 Nov 2021 13:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=m90f3eEcsDkZjRx91AS0YbVApQlGx9wW1Sx0SP+Z0og=; b=IBBXyVI03Ai+YO 062ELauXNMqDPOw4GV2NRe1MEk/xDivYIetlZLqzM9/D30w7/HPNKGBJ7iIwSN95WBJhkOHS1l1RF AxfA8PURdTsUp5JqcW8s/yCPPy3CbQhHRFAX9UpXj57AdDZCKw4o5DTTL2VMMFmiXFVG9Hv3qeTD5 C/Ei7hKrpZd+1w/YEIWao3yNJVkB1Fa/dbxOqp4q5bTAy7G3Lgdj08TSqhb38HRzJXEnVXnyhGsA/ OpJsAx6bpb47kExibFHuPVoPXmbWd9z5jsDVZwkhmFSXLCjdEB7oxFh2oCk8RRA3yw/tdMChwWEUc yFwa1lGxu2TXhHY3C30g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqENf-007Zjf-3j; Thu, 25 Nov 2021 13:01:39 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqENO-007Zhy-T0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 13:01:24 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E2E4060C49; Thu, 25 Nov 2021 13:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637845282; bh=6Rgn/uumnB+zIy7XvreND7vpK4sRvHa5kqbq/KxeWk8=; h=From:To:Cc:Subject:Date:From; b=PmB4haGaSRSgZYbi1N8+zk+GFRmD5aQ7wVyQiDZTm342n8LL6jSx+YNtOdBiBJNaO mQeX/z+CmpJ54UOp6bj2eEWQyS753AxGc1JAx6qzm2zyHhEvrncaRrHqPGrSVEss+V weTkns1UX5lv3a/VLcksBVXM+gYDw6+rFrBFk56oWzB5IPSEvQcPOeL4uGJgZLkUqa wo9pLHxOpqrfo5CgSQNkbfU7CeVpmuRw6maQpr3Jl+OyBV3aYXW20OXfokKKe07ZS9 ElPekFN1l7EfTYPjg6b3kgrSK85TJgPTqadNrAYUfi2oDu10RKkuq7WYNOhADcbW6V XpzhTjPVYuhfg== Received: by pali.im (Postfix) id 5D5BC67E; Thu, 25 Nov 2021 14:01:17 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] irqchip/armada-370-xp: Fix return value of armada_370_xp_msi_alloc() Date: Thu, 25 Nov 2021 14:00:56 +0100 Message-Id: <20211125130057.26705-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_050122_985579_354E81B2 X-CRM114-Status: GOOD ( 12.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org IRQ domain alloc function should return zero on success. Non-zero value indicates failure. Signed-off-by: Pali Rohár Fixes: fcc392d501bd ("irqchip/armada-370-xp: Use the generic MSI infrastructure") Cc: stable@vger.kernel.org --- drivers/irqchip/irq-armada-370-xp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index 80906bfec845..41ad745cf343 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -250,7 +250,7 @@ static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq, NULL, NULL); } - return hwirq; + return 0; } static void armada_370_xp_msi_free(struct irq_domain *domain, From patchwork Thu Nov 25 13:00:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12693667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1DA7C433EF for ; Thu, 25 Nov 2021 13:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ixswMNKl72cjS2kTciJvUpyE2TIlpJkk8Mg0sEm73WM=; b=A4J2vGGzw7TRza tb6WLuZmMPlekPoq+zTHcArjsy+KXA/uTtHM66UYkZHHGJlT3p01yLu2rLojtKr7ayKlouTIWwKRF gaT58euiT/Q7ouIXDMhZItRVTALpXuTin0yqM/YIaaOHmp+EAFNB7AN5WKbTVen+XjH1/oaAPeUBe pT1acvVD2x8l+ijO6ca+oitYHQsmfcea/m1xIJKnUTUSsEciOxROpXrfQ52FnZllwZ3pL8ifJ1QBl 6nhmBfnlummc05yVgHeXKm8kEpyyl477hu2PunRAkbwxL6ZjVI8G9x1VtUr0kkoWwpgiAA42NtbY7 lJ+It/pda6+Q/Lq3yMvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqEOE-007a1n-Qe; Thu, 25 Nov 2021 13:02:15 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqENQ-007Zj8-Mk for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 13:01:26 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 429F6601FA; Thu, 25 Nov 2021 13:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637845284; bh=rHQc8cLZj3iHYiqYAudA4oR15/U/EZooZ80bhH8XqpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=By8v/GtPwcABogTHrsibYKuiSF7UWVfpNIbM3ZxjNOfarPVYmESOf50RzeKg2vqIK YIyEpTWtbAGG+eLhYqYp6/I5lX5s0OyGsYwRn31HrK1i5K0aUMCSZ3gzUSZjPN1I5j wjsrzpFVpx6XqHnGnYIPzvji9FK6CWdG1uaZ/vV9YfIFfBCDq0PkWJ0IJFYr8e+/jE RlRzcaDtDqj8Hp97EH3wuDfffhPVfVS6kkpLa122Xg1Bd7+QM4j/HbcLTcTiJrQd1f vpvHP0fazwqLZ0GgWybe9QvaPMDa/Ep8d8VWgPxIkruP/ql0wA+MveSDEr9yingjf1 hKnr2kRiaT3Lg== Received: by pali.im (Postfix) id A89C8EDE; Thu, 25 Nov 2021 14:01:18 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] irqchip/armada-370-xp: Fix support for Multi-MSI interrupts Date: Thu, 25 Nov 2021 14:00:57 +0100 Message-Id: <20211125130057.26705-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211125130057.26705-1-pali@kernel.org> References: <20211125130057.26705-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_050124_801018_80CCEAEF X-CRM114-Status: GOOD ( 13.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org irq-armada-370-xp driver already sets MSI_FLAG_MULTI_PCI_MSI flag into msi_domain_info structure. But allocated interrupt numbers for Multi-MSI needs to be properly aligned otherwise devices send MSI interrupt with wrong number. Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area() to allocate aligned interrupt numbers. Signed-off-by: Pali Rohár Fixes: a71b9412c90c ("irqchip/armada-370-xp: Allow allocation of multiple MSIs") Cc: stable@vger.kernel.org Acked-by: Marc Zyngier --- drivers/irqchip/irq-armada-370-xp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index 41ad745cf343..5b8d571c041d 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -232,16 +232,12 @@ static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq, int hwirq, i; mutex_lock(&msi_used_lock); + hwirq = bitmap_find_free_region(msi_used, PCI_MSI_DOORBELL_NR, + order_base_2(nr_irqs)); + mutex_unlock(&msi_used_lock); - hwirq = bitmap_find_next_zero_area(msi_used, PCI_MSI_DOORBELL_NR, - 0, nr_irqs, 0); - if (hwirq >= PCI_MSI_DOORBELL_NR) { - mutex_unlock(&msi_used_lock); + if (hwirq < 0) return -ENOSPC; - } - - bitmap_set(msi_used, hwirq, nr_irqs); - mutex_unlock(&msi_used_lock); for (i = 0; i < nr_irqs; i++) { irq_domain_set_info(domain, virq + i, hwirq + i, @@ -259,7 +255,7 @@ static void armada_370_xp_msi_free(struct irq_domain *domain, struct irq_data *d = irq_domain_get_irq_data(domain, virq); mutex_lock(&msi_used_lock); - bitmap_clear(msi_used, d->hwirq, nr_irqs); + bitmap_release_region(msi_used, d->hwirq, order_base_2(nr_irqs)); mutex_unlock(&msi_used_lock); }