Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2813887pxb; Mon, 18 Apr 2022 08:46:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfFCsx2CT7NmPOCI+AJ54t3Nm96ZqsU5dn2iBJYRjd/f0vPsPSmTPK3elRIXVbGf8ZzEDC X-Received: by 2002:a17:906:7947:b0:6da:892f:2503 with SMTP id l7-20020a170906794700b006da892f2503mr9570422ejo.710.1650296778102; Mon, 18 Apr 2022 08:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650296776; cv=none; d=google.com; s=arc-20160816; b=VFellhJ9yrqLOaA/lj/ivpCR9Jy3D1+IN6EcBHRTGQ21UmMemhD4UtIXWqqeryddYL eZRoiiD9uJsMCb2/dTlS5Th5hkN4fu8GeYvA1nd7uBi6K2yYW75FKs0MOqsH2EXw0Ef1 vblfwJc/y5d/SpJt00pG0gr9GKAsm7y06iLEzoD85wN4yBZpH4bdRZQahXnlpStv4aeI bmRXPpYL2ORYByeZ1khuOS3EGIblMGQo4TlF5jJ36N3AMrkKwQxgM8U9FLInMm6Mx1w3 hWCGnG+51AgDe+DouZfvlkwIvFVY+TQx1SECikiOYsOTj+sqcFjwvDw4MR6ZIV+Qvox7 K/mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NMN+sGK0Ikquy8eiUriqwYyEDF3nF97PMTMTVhRAv2Y=; b=QNw6rOIYaLMDcz0DME0HyGkirgykbwFNc+qsNC+q0Dbit+3Hf4SVXPpGDSJ8jSqhR9 VPWVWkDZmyzDjq4EtjLLNuLf+5QYYUdkpr+PYcjebGVUaEEO2dBMCi59Cc5H+14cS/np 21nv1BxpDsQala5TeXeb2RWa9W3mTnK/GzPQLcLDOa6Qped4/tEKHrbSJYq33p/ngONk 5x63tYX1DqNZZZIJlm/4MqVT5uEH3Qp8JtbC6U5pas1/v7ujp+EBfanNtrmUD0jc1QlU HL6aJ0Bwy63P5qv/lCksHA7QOpa5BRtCYTrIdbZXeIpFuYnhdJ0wYpt7nFtaQmw67dtb a0OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O1rJoViT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020aa7dc0d000000b00418c2b5bd58si5968706edu.58.2022.04.18.08.45.52; Mon, 18 Apr 2022 08:46:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O1rJoViT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243280AbiDROCN (ORCPT + 99 others); Mon, 18 Apr 2022 10:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243842AbiDRNmU (ORCPT ); Mon, 18 Apr 2022 09:42:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 492833121C; Mon, 18 Apr 2022 05:59:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1F1D609FA; Mon, 18 Apr 2022 12:59:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4F76C385A7; Mon, 18 Apr 2022 12:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286775; bh=tAgNDFITJraa6hr2dQBON6qTAxbYC//JPNb21T8z+98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1rJoViTNS+0kB2Ukx9wpqkldXqWW9yVZ63PGGJoIrd9X20htJTp90bAQZdTr3D36 E5f8C0Exi13B7LpWA5Jm22+TPBKiUkWoX1U71QiBK9NHTkxcj5T+q0s7BdDTLWH+rI ZFBdn06BA6+BxMJgkHG1LNjLGoKygsVJOyNntkK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 4.14 214/284] PCI: aardvark: Fix support for MSI interrupts Date: Mon, 18 Apr 2022 14:13:15 +0200 Message-Id: <20220418121217.801505300@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár [ Upstream commit b0b0b8b897f8e12b2368e868bd7cdc5742d5c5a9 ] Aardvark hardware supports Multi-MSI and MSI_FLAG_MULTI_PCI_MSI is already set for the MSI chip. But when allocating MSI interrupt numbers for Multi-MSI, the numbers need to be properly aligned, otherwise endpoint devices send MSI interrupt with incorrect numbers. Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area(). To ensure that aligned MSI interrupt numbers are used by endpoint devices, we cannot use Linux virtual irq numbers (as they are random and not properly aligned). Instead we need to use the aligned hwirq numbers. This change fixes receiving MSI interrupts on Armada 3720 boards and allows using NVMe disks which use Multi-MSI feature with 3 interrupts. Without this NVMe disks freeze booting as linux nvme-core.c is waiting 60s for an interrupt. Link: https://lore.kernel.org/r/20220110015018.26359-4-kabel@kernel.org Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin --- drivers/pci/host/pci-aardvark.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c index 9ae544e113dc..124fd7cb5da5 100644 --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c @@ -834,7 +834,7 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data, msg->address_lo = lower_32_bits(msi_msg); msg->address_hi = upper_32_bits(msi_msg); - msg->data = data->irq; + msg->data = data->hwirq; } static int advk_msi_set_affinity(struct irq_data *irq_data, @@ -851,15 +851,11 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain, int hwirq, i; mutex_lock(&pcie->msi_used_lock); - hwirq = bitmap_find_next_zero_area(pcie->msi_used, MSI_IRQ_NUM, - 0, nr_irqs, 0); - if (hwirq >= MSI_IRQ_NUM) { - mutex_unlock(&pcie->msi_used_lock); - return -ENOSPC; - } - - bitmap_set(pcie->msi_used, hwirq, nr_irqs); + hwirq = bitmap_find_free_region(pcie->msi_used, MSI_IRQ_NUM, + order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); + if (hwirq < 0) + return -ENOSPC; for (i = 0; i < nr_irqs; i++) irq_domain_set_info(domain, virq + i, hwirq + i, @@ -877,7 +873,7 @@ static void advk_msi_irq_domain_free(struct irq_domain *domain, struct advk_pcie *pcie = domain->host_data; mutex_lock(&pcie->msi_used_lock); - bitmap_clear(pcie->msi_used, d->hwirq, nr_irqs); + bitmap_release_region(pcie->msi_used, d->hwirq, order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); } -- 2.35.1