From mboxrd@z Thu Jan 1 00:00:00 1970 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 85395C27C4F for ; Sun, 30 Jun 2024 16:51:39 +0000 (UTC) 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:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZmmRRw0rUqlBzxiX2pzqJcIUiD2NcUThL2qZCGcblbE=; b=3m4DVebZlOk/TE/Ty9DKfMEfd8 naCIEvZzSR65wsBBPQU0w8iT44a7WM8GMozeoMsYxS+CT4/gRZDF03FEyRQhGna2lfLe7lKQ8TE5y reEHZbtpw4rgD2vR+1xgNNNUMGPOVmbJnWIyi9jmOhdzxYfSktbhY/jsUTL22sMobGLQGr+oVuKg9 3p2Itke2fD6hasD/MVOWprvo4OIW3IHPfWx3YIS1N++NdZHuE/kq0GuWlLjRsuKjZpaNoFXGKOqMk Hk0uGOeKowwUudQgX4WWHnlsYOQv+Yum/dXoWq4SZFBL8P09YB/49r5VoIIJhYC5QeCUemuUPSBS1 OYgQPB5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNxlt-00000000jPo-3qUU; Sun, 30 Jun 2024 16:51:25 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNxli-00000000jOW-3Y9r for linux-arm-kernel@lists.infradead.org; Sun, 30 Jun 2024 16:51:16 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fa2ea1c443so17106315ad.0 for ; Sun, 30 Jun 2024 09:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719766273; x=1720371073; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ZmmRRw0rUqlBzxiX2pzqJcIUiD2NcUThL2qZCGcblbE=; b=J/quYlgFtTV/bacLN73BytwaoVKB1FqLeMI1GgqHfP3likcxQvP1Xr64eIn4QBaa9L vd6PaDkdgST3OeZD683eo1GbuPLn6HBu/EaZthqWQDeAKSGI8TsgNoim1GCp5ULX9Lly omQdC73kK2EEAMcEqyBiuL910p215A1KKC0CjBvHpCmpa2ie8M1bDlxVRlk6286FHufA 3zKvo9khtGg0VgFH3twrw4if/uDEerjwyglJGw5HoDRRBPhA5AS4XZF4wuiAlMFuFQiW iSGMuDpcNxR61Hl8TImJ7pkvI/+AU6rNsOFUfjxMcoc7RpRTqvZUpxiDJZitFU+18xXH kGBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719766273; x=1720371073; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZmmRRw0rUqlBzxiX2pzqJcIUiD2NcUThL2qZCGcblbE=; b=lW8VcPzl78E4bE1XjnitTJZ/yF4+okSC9d/PV/dvcPqm+HZmaxsf/d7yJlbi3ejo3s eNkmsaihsKNqqaEwMct9M3cvImgESY4lrI0Xldf5tMowN6koSQBsGmLsVU5gvQrwR/Yd dxMBA02F0F1kxabz60iydk9KdHM93n/Ti4UqtXisruXBubU0tgEidPUqbahy9M6VICGN 0HkBcD/d1zeXg4kGdr5Sfuuk8hJzCejnAO2uufI/2iuRAZ/3GRUSVb4ogjP1MF80NvNn xv2IJKAbQAGt3e0mGxYCGEVMgDY89dfLtHXx4jnoswEPfog+90f500frvhTJ6a+OuLe8 QzJw== X-Forwarded-Encrypted: i=1; AJvYcCVspRXEo7Brv9rjSVFnXn0ekczYvdOSmAJnpIJ4xd7zTHDsa/w9SyjC0cfjntJvPLX7892P4sOuJ8WcJZ5s75zVCixbR03ZeRwkVpivIXt7sQ7G9Ww= X-Gm-Message-State: AOJu0YxQNYM3Z7xw7kn9bZKUbHPQc8sLJo4AAfnHfH8lL5RQNEicszqf tXrbuio8f6SDHFm4/+C2beyKW5cUXm6BtohFsdjarqgSQc/U44zNRAoLbTYeTA== X-Google-Smtp-Source: AGHT+IFb9xngZdlMkF4/QJVf4vOFYOhYP0MvzKGLF16d5uCq0aKbtbmw7vV/puD8i55ELqdRaIJQGA== X-Received: by 2002:a17:903:22d1:b0:1f9:d111:8a19 with SMTP id d9443c01a7336-1fadbd01fbcmr30336695ad.64.1719766273266; Sun, 30 Jun 2024 09:51:13 -0700 (PDT) Received: from thinkpad ([220.158.156.215]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10d1a82sm48223075ad.59.2024.06.30.09.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 09:51:12 -0700 (PDT) Date: Sun, 30 Jun 2024 22:21:03 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Conor Dooley , linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v6 10/10] PCI: imx6: Add i.MX8Q PCIe root complex (RC) support Message-ID: <20240630165103.GE5264@thinkpad> References: <20240617-pci2_upstream-v6-0-e0821238f997@nxp.com> <20240617-pci2_upstream-v6-10-e0821238f997@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240617-pci2_upstream-v6-10-e0821238f997@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240630_095115_072563_CB8DE988 X-CRM114-Status: GOOD ( 24.02 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 17, 2024 at 04:16:46PM -0400, Frank Li wrote: > From: Richard Zhu > > Implement i.MX8Q (i.MX8QM, i.MX8QXP, and i.MX8DXL) PCIe RC support. While > the controller resembles that of iMX8MP, the PHY differs significantly. > Notably, there's a distinction between PCI bus addresses and CPU addresses. Do we know the reason? > > Introduce IMX_PCIE_FLAG_CPU_ADDR_FIXUP in drvdata::flags to indicate driver > need the cpu_addr_fixup() callback to facilitate CPU address to PCI bus > address conversion according to "range" property. 'ranges' > > Signed-off-by: Richard Zhu > Signed-off-by: Frank Li > --- > drivers/pci/controller/dwc/pci-imx6.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 18c133f5a56fc..d2533d889d120 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -66,6 +66,7 @@ enum imx_pcie_variants { > IMX8MQ, > IMX8MM, > IMX8MP, > + IMX8Q, > IMX95, > IMX8MQ_EP, > IMX8MM_EP, > @@ -81,6 +82,7 @@ enum imx_pcie_variants { > #define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5) > #define IMX_PCIE_FLAG_HAS_SERDES BIT(6) > #define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) > +#define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(8) > > #define imx_check_flag(pci, val) (pci->drvdata->flags & val) > > @@ -1012,6 +1014,22 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp) > regulator_disable(imx_pcie->vpcie); > } > > +static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) > +{ > + struct imx_pcie *imx_pcie = to_imx_pcie(pcie); > + struct dw_pcie_rp *pp = &pcie->pp; > + struct resource_entry *entry; > + unsigned int offset; > + > + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) > + return cpu_addr; > + > + entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); > + offset = entry->offset; > + > + return (cpu_addr - offset); > +} > + > static const struct dw_pcie_host_ops imx_pcie_host_ops = { > .init = imx_pcie_host_init, > .deinit = imx_pcie_host_exit, > @@ -1020,6 +1038,7 @@ static const struct dw_pcie_host_ops imx_pcie_host_ops = { > static const struct dw_pcie_ops dw_pcie_ops = { > .start_link = imx_pcie_start_link, > .stop_link = imx_pcie_stop_link, > + .cpu_addr_fixup = imx_pcie_cpu_addr_fixup, > }; > > static void imx_pcie_ep_init(struct dw_pcie_ep *ep) > @@ -1449,6 +1468,13 @@ static int imx_pcie_probe(struct platform_device *pdev) > if (ret < 0) > return ret; > > + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) { > + if (!resource_list_first_type(&pci->pp.bridge->windows, IORESOURCE_MEM)) { > + dw_pcie_host_deinit(&pci->pp); > + return dev_err_probe(dev, -EINVAL, "DTS Miss PCI memory range"); -ENODEV - Mani -- மணிவண்ணன் சதாசிவம்