Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1824873pxb; Mon, 20 Sep 2021 06:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSMjJkWZGTVNWrXu72VegQMllrHY+5lIF7Jd5BnIft5RH9P6apGeottYjIU9j/1b8m2H9F X-Received: by 2002:a17:907:2098:: with SMTP id pv24mr29563508ejb.426.1632143731919; Mon, 20 Sep 2021 06:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632143731; cv=none; d=google.com; s=arc-20160816; b=X1Ik8aczcdkqzlXl62KLjCd3WcpXdvb3UCZA5nyTU6CLBT3U0NnX30ENaKfPa9TXms sTdbCDIUCc4uYPjexCZsXcxEs4DxCTnNfHYD4eSEeiruqvO563w6PaeXRq9epBGpI0+0 QD0YbZ1Mi0K405zCOAghsTqit/URDbAvYF7be4tMLwQrINlFEn7lNHAhO6G/dM3KIF4l xIFe56TMetZ9SMZwQeXQCM122tlsIEH4WAJBU7LLNh7YpXRt0/V5/uCIFjNzhSBkApKn 2yhEFzJh+wm4h43typt3863fCbF3aydazmbnNlP+b9E+GnqNqiyWrne3b53pwrk2ME1n DusA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=rQP4yCack4NH5zLnvnr88Oqw4KdO+k1PpsG1OyC4eDE=; b=a9VzAiSCFfooFlSngbBKphCGzFxl0QUTxAcjH4liFAGUo63EYi3YFZgaCIyWJRaat/ nvyOhk3HgX6wRB2+wXG5XHVr85dj6BR/DztrOmEKLlcSVx7aw6EET0A3tlWBuCPGzi7f 4O2xCSPlSnqijtoHc3xiE5jPDBnb8lVXvFUxDH+9n+9m6BKRbQFHxwl/coEKSzOieBea 3KGMO+GLWd83c1D0pGFq1DsKp2/vAu6K5LaSirT12WCJMotAe5yDU0BqdYPkpQPwzUDF fgw/VHaF759Jdv0MWFoERWlHIeKfAvMkSpzVg5wGV/6AQ6RK2rVt3TQz/Jl9XDai1Nze v0zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si8486647edw.425.2021.09.20.06.15.00; Mon, 20 Sep 2021 06:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbhITIho (ORCPT + 99 others); Mon, 20 Sep 2021 04:37:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhITIhn (ORCPT ); Mon, 20 Sep 2021 04:37:43 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F33B600AA; Mon, 20 Sep 2021 08:36:17 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mSEmd-00BijS-7E; Mon, 20 Sep 2021 09:36:15 +0100 Date: Mon, 20 Sep 2021 09:36:14 +0100 Message-ID: <875yuvwsn5.wl-maz@kernel.org> From: Marc Zyngier To: Kishon Vijay Abraham I Cc: Thomas Gleixner , Bjorn Helgaas , , , Lorenzo Pieralisi , , Robin Murphy Subject: Re: [PATCH 3/3] irqchip/gic-v3-its: Include "msi-map-mask" for calculating nvecs In-Reply-To: <20210920064133.14115-4-kishon@ti.com> References: <20210920064133.14115-1-kishon@ti.com> <20210920064133.14115-4-kishon@ti.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kishon@ti.com, tglx@linutronix.de, bhelgaas@google.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lokeshvutla@ti.com, Robin.Murphy@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Robin, who has dealt with a lot of the stuff here. On Mon, 20 Sep 2021 07:41:33 +0100, Kishon Vijay Abraham I wrote: > > Using "msi-map-mask" in device tree lets multiple PCIe requestor ID to > use the same GIC ITS device ID. So while creating the Interrupt > Translation Table (ITT) for a specific GIC ITS device ID, the total number > of interrupts required by all the PCIe requestor ID that maps to the > same GIC ITS device ID should be calculated > > Add support for gic-v3-its to include "msi-map-mask" property in device > tree for calculating the total number of MSI interrupts in > its_pci_msi_prepare(). > > Signed-off-by: Kishon Vijay Abraham I > --- > drivers/irqchip/irq-gic-v3-its-pci-msi.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c > index ad2810c017ed..c79bca1a5787 100644 > --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c > +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c > @@ -54,9 +54,13 @@ static int its_get_pci_alias(struct pci_dev *pdev, u16 alias, void *data) > static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, > int nvec, msi_alloc_info_t *info) > { > + int alias_count = 0, map_count = 0, minnvec = 1, ret; > struct pci_dev *pdev, *alias_dev; > struct msi_domain_info *msi_info; > - int alias_count = 0, minnvec = 1; > + struct device *parent_dev; > + struct pci_bus *root_bus; > + struct device_node *np; > + u32 map_mask, rid; > > if (!dev_is_pci(dev)) > return -EINVAL; > @@ -78,6 +82,21 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, > info->flags |= MSI_ALLOC_FLAGS_PROXY_DEVICE; > } > > + for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent) { Move the declaration of np, ret and map_count here. > + np = parent_dev->of_node; > + if (!np) > + continue; > + > + ret = of_property_read_u32(np, "msi-map-mask", &map_mask); > + if (!ret && map_mask != 0xffff) { > + rid = pci_dev_id(pdev) & map_mask; > + root_bus = find_pci_root_bus(pdev->bus); > + __pci_walk_bus(root_bus, its_pci_msi_vec_count, &map_count, rid, map_mask); > + break; > + } > + } > + alias_count = max(map_count, alias_count); Move this after the call to __pci_walk_bus(). > + > /* ITS specific DeviceID, as the core ITS ignores dev. */ > info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev); If you don't set the PROXY_DEVICE flag, bad thing will happen when the canonical device is removed. Ultimately, this should be moved into a separate helper, along the line of pci_for_each_dma_alias(). It probably also needs to have an ACPI counterpart. Thanks, M. -- Without deviation from the norm, progress is not possible.