From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4C53606A32C for ; Fri, 4 Dec 2026 20:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oN/nkuPP; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=CBvvA48C DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=nrz7wWBbcmrOoutoKqseubTDGDalmVn1Hz0VvhVXGEc=; b=oN/nkuPPVjqbGG IDUGmCIZ9ZrQaMDjBLWWXFMgvgVDvSq5QJQzrUqVa+kogx9VA0xqtWnyMgAevYS0jknfppe056yie E4wFNVqY5Sb+89stY63uC8zda96Py2nTdd5BPlnXvczaNf1If/k5qFMx2L0VwUr29SFTPhmYWiTI+ 4P/tZdminRWq95QUqGN4IeeN1JcyNGdrRyb7Qa9WC5+e92nxnJTBIqB7F08L6LH84Pw+rAdy4kdRr IJ7HZMzS+v7s6T9Bh10VUK8d0OnX9DeH8BKNV35cjS4ZyMT8wzXZ11KMxZiFmyzYa7pvD9KxNt3g2 Kycwl854P9f7RcbPX/Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZjB-00000001Po5-0uul; Fri, 04 Dec 2026 20:18:00 +0000 Received: from mail.tipi-net.de ([2a03:4000:43:185::1]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZho-00000001PlG-35uh; Fri, 04 Dec 2026 20:17:28 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3806BA012B; Fri, 04 Dec 2026 21:16:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1796415378; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=nrz7wWBbcmrOoutoKqseubTDGDalmVn1Hz0VvhVXGEc=; b=CBvvA48CKKSzX4Tk0rOmQL+dGmvrpgUcltGRTJiEXkw9aYDxpJD2ozO9G0fye19du/Wrvh Y2uz0XqN1d+uVyA+2YKJv2Eth+qq4ywgwbYUqFIxwyEJAsMt2/JWfwmoV4fL4j6pjDnhcG 2DVhN82Fw9qtBCY6vBEwSfdjlrXq3P8xcueGiqtKYGYMSjl0zxrCvV1GJwDt/Y8JJoGXNk Owr8rIr2xNn4EKINJwKkfeX6SuVXAHTDAwwisQMNkpccE2CLSw1zuokF8X8JY1yLdwUfrE YUmfMI5jP31jY8twd+2oCk5BMqqUF/t9Lmo0qqCo2NMdCez4jyiqDoI8TJHkDA== X-Archived-By: MIME-Version: 1.0 Date: Fri, 04 Dec 2026 21:16:17 +0100 From: Nicolai Buchwitz To: Thomas Gleixner Cc: Radu Rendec , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Stanimir Varbanov , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jonathan Bell , Stefan Wahren Subject: Re: [PATCH 2/3] irqchip/bcm2712-mip: Support multiple MSI ranges In-Reply-To: <87cxrgn83r.ffs@fw13> References: <20261202-nb-bcm2712-mip-msi-ranges-v1-0-eb3db393f2e2@tipi-net.de> <20261202-nb-bcm2712-mip-msi-ranges-v1-2-eb3db393f2e2@tipi-net.de> <87cxrgn83r.ffs@fw13> Message-ID: <237a3034c656b213b93c0b66f519d2a1@tipi-net.de> X-Sender: nb@tipi-net.de Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_121727_266825_5AB159F5 X-CRM114-Status: GOOD ( 20.97 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 4.12.2026 20:44, Thomas Gleixner wrote: > On Wed, Dec 02 2026 at 11:12, Nicolai Buchwitz wrote: >> /** >> * struct mip_priv - MSI-X interrupt controller data >> * @lock: Used to protect bitmap alloc/free >> * @base: Base address of MMIO area >> * @msg_addr: PCIe MSI-X address >> - * @msi_base: MSI base >> + * @parent_irqs: GIC SPI numbers indexed by MIP message data > > Please realign these entries so they are all tabular. > >> * @num_msis: Count of MSIs >> * @msi_offset: MSI offset >> * @bitmap: A bitmap for hwirqs > >> @@ -96,7 +97,7 @@ static int mip_middle_domain_alloc(struct irq_domain >> *domain, unsigned int virq, >> { >> struct mip_priv *mip = domain->host_data; >> struct irq_fwspec fwspec = {0}; >> - unsigned int hwirq, i; >> + unsigned int hwirq, i, allocated = 0; > > Reverse fir tree order. See > > https://docs.kernel.org/process/maintainer-tip.html > >> struct irq_data *irqd; >> int irq, ret; >> >> @@ -104,21 +105,24 @@ static int mip_middle_domain_alloc(struct >> irq_domain *domain, unsigned int virq, >> if (irq < 0) >> return irq; >> >> - hwirq = irq + mip->msi_offset; >> + hwirq = irq; >> >> fwspec.fwnode = domain->parent->fwnode; >> fwspec.param_count = 3; >> fwspec.param[0] = 0; >> - fwspec.param[1] = hwirq + mip->msi_base; >> fwspec.param[2] = IRQ_TYPE_EDGE_RISING; >> >> - ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &fwspec); >> - if (ret) >> - goto err_free_hwirq; >> - >> for (i = 0; i < nr_irqs; i++) { >> + fwspec.param[1] = mip->parent_irqs[hwirq + i]; >> + ret = irq_domain_alloc_irqs_parent(domain, virq + i, 1, &fwspec); >> + if (ret) >> + goto err_free; >> + allocated++; >> + >> irqd = irq_domain_get_irq_data(domain->parent, virq + i); >> - irqd->chip->irq_set_type(irqd, IRQ_TYPE_EDGE_RISING); >> + ret = irqd->chip->irq_set_type(irqd, IRQ_TYPE_EDGE_RISING); >> + if (ret) >> + goto err_free; >> >> ret = irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i, >> &mip_middle_irq_chip, mip); >> @@ -133,8 +137,8 @@ static int mip_middle_domain_alloc(struct >> irq_domain *domain, unsigned int virq, >> return 0; >> >> err_free: >> - irq_domain_free_irqs_parent(domain, virq, nr_irqs); >> -err_free_hwirq: >> + if (allocated) >> + irq_domain_free_irqs_parent(domain, virq, allocated); >> mip_free_hwirq(mip, irq, nr_irqs); >> return ret; >> } >> @@ -152,7 +156,7 @@ static void mip_middle_domain_free(struct >> irq_domain *domain, unsigned int virq, >> mip = irq_data_get_irq_chip_data(irqd); >> hwirq = irqd_to_hwirq(irqd); >> irq_domain_free_irqs_parent(domain, virq, nr_irqs); >> - mip_free_hwirq(mip, hwirq - mip->msi_offset, nr_irqs); >> + mip_free_hwirq(mip, hwirq, nr_irqs); >> } >> >> static const struct irq_domain_ops mip_middle_domain_ops = { >> @@ -185,7 +189,7 @@ static int mip_init_domains(struct mip_priv *mip, >> struct device_node *np) >> .fwnode = of_fwnode_handle(np), >> .ops = &mip_middle_domain_ops, >> .host_data = mip, >> - .size = mip->num_msis, >> + .size = MIP_NUM_IRQS, >> .parent = mip->parent, >> .dev = mip->dev, >> }; >> @@ -209,32 +213,59 @@ static int mip_init_domains(struct mip_priv >> *mip, struct device_node *np) >> static int mip_parse_dt(struct mip_priv *mip, struct device_node *np) >> { >> struct of_phandle_args args; >> + struct irq_domain *parent; >> + u32 first, span, i, cells; >> u64 size; >> - int ret; >> + int ret, count, range; > > Please declare the variables which are only used in the for() loop in > that scope and not here. > >> ret = of_property_read_u32(np, "brcm,msi-offset", &mip->msi_offset); >> if (ret) >> mip->msi_offset = 0; >> - >> - ret = of_parse_phandle_with_args(np, "msi-ranges", >> "#interrupt-cells", >> - 0, &args); >> - if (ret) >> - return ret; >> - >> - ret = of_property_read_u32_index(np, "msi-ranges", args.args_count + >> 1, >> - &mip->num_msis); >> - if (ret) >> - goto err_put; >> + if (mip->msi_offset >= MIP_NUM_IRQS) >> + return -EINVAL; >> >> ret = of_property_read_reg(np, 1, &mip->msg_addr, &size); >> if (ret) >> - goto err_put; >> + return ret; >> >> - mip->msi_base = args.args[1]; >> + /* <&gic type spi flags span> per range */ >> + count = of_property_count_u32_elems(np, "msi-ranges"); >> + if (count <= 0 || count % 5) >> + return -EINVAL; >> + if (count > 5 && of_property_present(np, "brcm,msi-offset")) >> + return -EINVAL; >> + >> + first = mip->msi_offset; >> + for (range = 0; range < count / 5; range++) { > > for (int range = 0; .... > >> + ret = of_parse_phandle_with_fixed_args(np, "msi-ranges", 4, >> + range, &args); >> + if (ret) >> + return ret; >> >> - mip->parent = irq_find_host(args.np); >> - if (!mip->parent) >> + ret = of_property_read_u32(args.np, "#interrupt-cells", &cells); >> + if (ret) >> + goto err_put; >> ret = -EINVAL; >> + span = args.args[3]; >> + if (cells != 3 || args.args[0] != 0 || >> + args.args[2] != IRQ_TYPE_EDGE_RISING || >> + !span || span > MIP_NUM_IRQS - first) >> + goto err_put; >> + > > You have 100 characters. Please make it use of them > > >> + parent = irq_find_host(args.np); >> + if (!parent || (mip->parent && parent != mip->parent)) >> + goto err_put; >> + mip->parent = parent; >> + >> + /* The legacy offset shifts the SPI as well as the message data */ >> + for (i = 0; i < span; i++) >> + mip->parent_irqs[first + i] = args.args[1] + >> + mip->msi_offset + i; > > See bracket rules in documentation. > >> + first += span; >> + of_node_put(args.np); >> + } >> + mip->num_msis = first - mip->msi_offset; >> + return 0; >> >> err_put: >> of_node_put(args.np); >> @@ -264,18 +295,20 @@ static int mip_msi_probe(struct platform_device >> *pdev, struct device_node *paren >> goto err_priv; >> } >> >> - mip->bitmap = bitmap_zalloc(mip->num_msis, GFP_KERNEL); >> + mip->bitmap = bitmap_alloc(MIP_NUM_IRQS, GFP_KERNEL); >> if (!mip->bitmap) { >> ret = -ENOMEM; >> goto err_base; >> } >> + bitmap_fill(mip->bitmap, MIP_NUM_IRQS); >> + bitmap_clear(mip->bitmap, mip->msi_offset, mip->num_msis); > > That want's a comment. Thanks, I will send a v2 with the style fixups + comment. Regards Nicolai