From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D9E72C0F8E; Mon, 16 Feb 2026 13:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771248387; cv=none; b=dP2SlWMpGGGsCPWEMGh0eirKJ3e2jAZxIB7xq8HdnspQc7ILzPiMAMsSj3UpMluADewN+POeyctQ6j6rJp1KXDaBDlt8ginkS4O05odGhAwhFaOdK9yDwC+E+FtscduJAaRmn01catVZ2jx2JDrp8P0B3/tSp6P6yDc4z+WKmTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771248387; c=relaxed/simple; bh=USoDS4LrGsrRdtGLZUzoqeua48Mf9qhS9vUwm+V3yzc=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=Er7fI6Jenee50sbUt78aUwGsk0ExULNd43xwQ7MAcAY+ZNEvGMyIAIzByXhBM3ul7dCQrT981V2wgLT6oQt9EVH5rQ/LLjyQbdZuUhu0VY+kMeKkKQnNNGZnSEr0Ji2Kzp1yKakS5HHtPHjSeMnbETuvFtGJ8dHQ76A1WpEVFCA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F4Y7yDA/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F4Y7yDA/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DBA8C116C6; Mon, 16 Feb 2026 13:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771248387; bh=USoDS4LrGsrRdtGLZUzoqeua48Mf9qhS9vUwm+V3yzc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F4Y7yDA/I2ujF53hJmCDchRz/5Pnhmpg95JLzqW7whhhN+m4NHW5T0dNeK6XVNNzM zRSpI4PxMCHl5uaB1yfY3BK9Np9wrBecnFn6dZUx6Bni5fNGOjtKuqwJtw0heFHUII U8rnvo0ECArD8ZUbNfR2P4VgNWMEcwyrntmMlc1UR/jA2ehpkfwxylhnKofmfccn1T 3G9yUinP76NQQRw/FQT0vW3dpwC5imdwPH1AlwKQWpOdLBtPlzDypaai2Cco6zAKS3 S7rR8tAL2F3vVHNzWBD4PVuBY/x2BZIyScWw3HD20J0LdCgT38ylsivmlUYMy6iwq/ MUIUh4c9FpOHA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vrycL-0000000BOdb-02OJ; Mon, 16 Feb 2026 13:26:25 +0000 Date: Mon, 16 Feb 2026 13:26:24 +0000 Message-ID: <86bjhobz0f.wl-maz@kernel.org> From: Marc Zyngier To: Aksh Garg Cc: , , , , , , , , , Subject: Re: [PATCH] PCI: Add PCI_RID_MASK macro In-Reply-To: <20260216120600.479738-1-a-garg7@ti.com> References: <20260216120600.479738-1-a-garg7@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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: a-garg7@ti.com, linux-pci@vger.kernel.org, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org, bhelgaas@google.com, cassel@kernel.org, linux-kernel@vger.kernel.org, s-vadapalli@ti.com, danishanwar@ti.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 16 Feb 2026 12:06:00 +0000, Aksh Garg wrote: > > Routing ID (RID) is a 16-bit value composed of bus number and devfn. No. RID here means "Requester ID". Please lookup the PCI spec. > Add a PCI_RID_MASK macro to eliminate the use of magic number 0xffff > when masking for RIDs. I'm not convinced this is universally true. Some RIDs (or RID-like identifiers, such as Stream IDs and Device IDs) are larger than 16 bit, depending on the integration. The fact that this particular integration uses a 16bit RID without any extra qualifier in the upper bits doesn't make it universal. > This provides a standard way for drivers to extract RIDs without > resorting to magic numbers. > > Signed-off-by: Aksh Garg > --- > drivers/pci/controller/pcie-apple.c | 2 +- > include/linux/pci.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c > index 2d92fc79f6dd..6bf9fe102e2f 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -802,7 +802,7 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci > u32 val; > > val = readl_relaxed(port_rid2sid_addr(port, idx)); > - if ((val & 0xffff) == rid) { > + if ((val & PCI_RID_MASK) == rid) { > apple_pcie_rid2sid_write(port, idx, 0); > bitmap_release_region(port->sid_map, idx, 0); > dev_dbg(&pdev->dev, "Released %x (%d)\n", val, idx); > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 864775651c6f..e3d9730121c8 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -71,6 +71,7 @@ > #define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn)) > /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */ > #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff) > +#define PCI_RID_MASK 0xffff Even the naming of this macro clashes with the current nomenclature, where we use PCI_DEVID()/pci_dev_id() to manipulate this information. Thanks, M. -- Without deviation from the norm, progress is not possible.