From patchwork Thu Oct 6 22:03:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13000771 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 0E87EC433FE for ; Thu, 6 Oct 2022 22:05:00 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=BCtXjta/aT6WVH7Q5Nwb/buQjRUvNJwbi+wtHBp59u0=; b=hqZLTz3jqFdkGq ID7QudQwlx4rQhIyDDUUloTHJRnxHxh25PqwAjsTg0l/yVxBQnLVnxT/rGgBHoJViZ9n6FlX/XKKT ful1dLaRf02ccjsiVXoiNlLLQi1wB6UayYFpM3qnejh+8feZcL+X4S1e2snG1THA8PVPdnMYIgt1W addx7R/JfNfnVSspdSAVxwTlmFTB1mPg7FpvzRW5OAbE9WjvucmZYomQjuj/zkYMsl/02E5VQ7HwR HSWpL4I9Tit5d32d+xjFTkp6IP28kBA7f0HOfT818gLyVZ9UFYIS5+BHblgS15miv9SiPsyfLpp1s vhNDold6jlmg2x4711ZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogYy0-005WVa-Vq; Thu, 06 Oct 2022 22:03:45 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogYxq-005WKG-PH; Thu, 06 Oct 2022 22:03:36 +0000 Received: by mail-ed1-x52d.google.com with SMTP id u21so4685105edi.9; Thu, 06 Oct 2022 15:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=LvjVJjiaNiXSnHQ1r2rSRUSpphAvqfDohp9kovF79Fw=; b=a6ENQW/fBFHrcuTkmewx1Ezqz7WdsS8lHYb3wM4ybF+4tVltkXPGBh9RMEa1f+9ZPE Cufh1iIddOcvRVvVoDjB8B8tJmcOTi/yZcYKcHaqPJksUXjbk2cSadcpBollm7L7ZUrL fOZWjV/N1lzLku1HwKyPOxlWfXbQnwoEnF5LoAOqCCg5PW7J895CKOglppVEpRT8NmRD 587qGPl+18YVo1ZnaLoMc6O3138Pu8+h8geFWNPN7bOB41cOXgIM4MJK0fVi/ffMF0k6 TQq9TFlzGZHE2iVhQmshUn02czDFIG/TcxYRey4Hl+pCTOlOtSs/4vAfpVQ7KYemoqF1 lsyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LvjVJjiaNiXSnHQ1r2rSRUSpphAvqfDohp9kovF79Fw=; b=rJP3yIhukJIHVtwdMrSIV/1sCMZys3jWFwKLgLhsgXVCAhpUCkLzdqOL2wZkwPi4dq itBVjlc0gfQ4mtfTWLV/fJtCQnrFOm+KGyW9zbWJvqs/SK7w0nfaSRhriBjU2DAgFyK3 8OmxCOxCuLRd381CDoSiUAPOlomB8SASQcUBCbjdlUkjZ5j0bfkspVnQ0soUTh0VqIpM fN9Hb/A55RmMQ7rUNVPU7h2iy/j4v/osTEDeQTQxjuuX+6moTPX6T6+IJDorQhyiIIga ErKtYFDnuighzpprK+2j0QTTqKifadhUE2LyXoeHpdLZ31ZPRYXCabpRvuohL/6AacVc PoLw== X-Gm-Message-State: ACrzQf1e7m5RSb1aJuVkm1jjA02c/oqIN9yAu+z3YTecbxa0ioQE6H+Y YBjut05fKdowt7DNV1JA7KY= X-Google-Smtp-Source: AMsMyM5lpw9c0Xsha7zB9F1tvzVa0a06GrkmekFIVkKbSmB4K3Yw55PgrVrY9J3MOB30bkMwUrJBtg== X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr1785028edz.301.1665093811706; Thu, 06 Oct 2022 15:03:31 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id f14-20020a17090631ce00b0078246b1360fsm241484ejf.131.2022.10.06.15.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 15:03:30 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 1/5] PCI: brcmstb: Enable Multi-MSI Date: Thu, 6 Oct 2022 18:03:17 -0400 Message-Id: <20221006220322.33000-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221006220322.33000-1-jim2101024@gmail.com> References: <20221006220322.33000-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_150334_836332_62B02793 X-CRM114-Status: GOOD ( 15.77 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We always wanted to enable Multi-MSI but didn't have a test device until recently. In addition, there are some devices out there that will ask for multiple MSI but refuse to work if they are only granted one. Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli Acked-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 521acd632f1a..a45ce7d61847 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -445,7 +445,8 @@ static struct irq_chip brcm_msi_irq_chip = { static struct msi_domain_info brcm_msi_domain_info = { /* Multi MSI is supported by the controller, but not by this driver */ - .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS), + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_MULTI_PCI_MSI), .chip = &brcm_msi_irq_chip, }; @@ -505,21 +506,23 @@ static struct irq_chip brcm_msi_bottom_irq_chip = { .irq_ack = brcm_msi_ack_irq, }; -static int brcm_msi_alloc(struct brcm_msi *msi) +static int brcm_msi_alloc(struct brcm_msi *msi, unsigned int nr_irqs) { int hwirq; mutex_lock(&msi->lock); - hwirq = bitmap_find_free_region(msi->used, msi->nr, 0); + hwirq = bitmap_find_free_region(msi->used, msi->nr, + order_base_2(nr_irqs)); mutex_unlock(&msi->lock); return hwirq; } -static void brcm_msi_free(struct brcm_msi *msi, unsigned long hwirq) +static void brcm_msi_free(struct brcm_msi *msi, unsigned long hwirq, + unsigned int nr_irqs) { mutex_lock(&msi->lock); - bitmap_release_region(msi->used, hwirq, 0); + bitmap_release_region(msi->used, hwirq, order_base_2(nr_irqs)); mutex_unlock(&msi->lock); } @@ -527,16 +530,17 @@ static int brcm_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *args) { struct brcm_msi *msi = domain->host_data; - int hwirq; + int hwirq, i; - hwirq = brcm_msi_alloc(msi); + hwirq = brcm_msi_alloc(msi, nr_irqs); if (hwirq < 0) return hwirq; - irq_domain_set_info(domain, virq, (irq_hw_number_t)hwirq, - &brcm_msi_bottom_irq_chip, domain->host_data, - handle_edge_irq, NULL, NULL); + for (i = 0; i < nr_irqs; i++) + irq_domain_set_info(domain, virq + i, hwirq + i, + &brcm_msi_bottom_irq_chip, domain->host_data, + handle_edge_irq, NULL, NULL); return 0; } @@ -546,7 +550,7 @@ static void brcm_irq_domain_free(struct irq_domain *domain, struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct brcm_msi *msi = irq_data_get_irq_chip_data(d); - brcm_msi_free(msi, d->hwirq); + brcm_msi_free(msi, d->hwirq, nr_irqs); } static const struct irq_domain_ops msi_domain_ops = {