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 EC823C3DA61 for ; Sun, 21 Jul 2024 08:24:24 +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=CZWtiPJtZ43++/gnJNwx4X2rQpR8wl/UQidt0ugSAnI=; b=1QHC0dkn8/b033PABMtZM12Z+r 6rlZPQ/1OVE7NGKuILmyCLY9IAH4E7oAfkrj3UAj2Bb9TsZHvS9tElzhQsgUHeA3ds01cert1q/Pq OnMkatVoSo5mibc4guqa3+6zrvLdYPt8ZCPCEOFKqm/UgaxezcHAJuVO42ZtnN+ksd9HbTv0Y1od8 IuWKZmuoGKDkJGuCSh+oAAh25vJsPgNvyHyM4ZoyoRlDVNiL6VD2OE2PO+6ZT9LNJ+xOlOE3ajYWA CWCs+6X3oh1HOdC11aBECSZuRY2l0cQCU0erWOOsPsxwQEhc4ooZ4mQC7Te1PUPF2dK67Ydlsl/j+ jUZ7Y5LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVRrX-00000006Sus-1BJc; Sun, 21 Jul 2024 08:24:11 +0000 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVRr9-00000006Soa-24sx for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 08:23:49 +0000 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-7037a208ff5so1926306a34.0 for ; Sun, 21 Jul 2024 01:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721550225; x=1722155025; 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=CZWtiPJtZ43++/gnJNwx4X2rQpR8wl/UQidt0ugSAnI=; b=caP1LjepfRka2ItYuYYHqsByDWxueJtkYstCtTQ5W9pgfQft4H4xVcoc1CLAPRQrsA 2UopmRqoS3jv3+FJQVNIjp1hlGulsIJEYhlRuZQY+dPkF3c+nXo4I1X4Z3EM4+qH3Wpo sFhKSufhKDueXjCjTG0bv4FbR8RB0tXdKsrgbf3zr+sTD0SCQYCJwiqoIuLzfU8XO+BL 4k6ktyVPTFAKQngRgqHlU0c8psSaotW1bmdgvSmx0MIIM7tl0Hcz6pjAJYaaCUBye5Zq c4GrSg6GM22ZC/CCN+m4gQ9AGaWir80QoTlAoGc7o8MQEWJXStJLBYezGClF+1xxaj99 2B6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721550225; x=1722155025; 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=CZWtiPJtZ43++/gnJNwx4X2rQpR8wl/UQidt0ugSAnI=; b=t5uY2ozDCgrWWRWOm8WbQqzivmoGTc7craLX4ShCGtBIUhfeGVLle4v/U7cD2qsQwQ SX/kSksSDF5p4M7Rc9xljF9pfT/8r/Z3z+tQp33U4Wnwybqvpm6vld6grWDxSToM7Vor 3zi613Nm7o/3c/q+8kpKBxCzX7KJb6GQYsxBG7mRZ6BMTfCNOrJTV+TuRxzxAr5MFUO/ G4nlmxee34UigUGrSNBiEJAKhImws2oQZfqKdj+pHDrLPHB9OCtvOntlOR9ehzmGv7wz kMadD02cxbf1itqDF4PL1ZQNlwfHhIavH9Ko3yjywZTmVTItInoAOKKlkqzn26SCDIMZ DnRQ== X-Forwarded-Encrypted: i=1; AJvYcCWCJJ8ZpppFesBx+l0GCfAyEwrorrDzpXciIIj1YgcUaGtbS0E6v2ThEe+tvw5zse1taCeQ85t0oGLkTvZEFQjUehxQcFiMcbJtQ5J7zw2e/gF74v8= X-Gm-Message-State: AOJu0YwOhbc8CfJ31K7fs8SUgaPSv9mT3Y2FB4El1YpzFBAYtyK+R3R+ xkviJ4WDGrWHCULWZdlzmW509rlieIC9JG2kpPodd8o3DFP04bbMOElfJOCAgg== X-Google-Smtp-Source: AGHT+IFfjJ8Cc595RCoBIrmV7WXBKOr6HnF25bvKEhlw/SDpWj45/smT1TJlSOniO5oPcyQREg2Jnw== X-Received: by 2002:a05:6830:3986:b0:704:4808:1d7a with SMTP id 46e09a7af769-708fdb22d04mr6996262a34.13.1721550225266; Sun, 21 Jul 2024 01:23:45 -0700 (PDT) Received: from thinkpad ([120.56.206.118]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70cff59e188sm3520618b3a.157.2024.07.21.01.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 01:23:44 -0700 (PDT) Date: Sun, 21 Jul 2024 13:53:36 +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 v7 10/10] PCI: imx6: Add i.MX8Q PCIe root complex (RC) support Message-ID: <20240721082336.GG1908@thinkpad> References: <20240708-pci2_upstream-v7-0-ac00b8174f89@nxp.com> <20240708-pci2_upstream-v7-10-ac00b8174f89@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240708-pci2_upstream-v7-10-ac00b8174f89@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240721_012347_719788_501F29FB X-CRM114-Status: GOOD ( 24.31 ) 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, Jul 08, 2024 at 01:08:14PM -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. > > 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 "ranges" property. > > Signed-off-by: Richard Zhu > Signed-off-by: Frank Li Reviewed-by: Manivannan Sadhasivam One comment below. > --- > 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 c72c7a0b0e02d..4e029d1c284e8 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) > > @@ -1015,6 +1017,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, > @@ -1023,6 +1041,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) > @@ -1452,6 +1471,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, -ENODEV, "DTS Miss PCI memory range"); > + } Is this check really necessary? Can the driver work if there is no MEM region defined in DT (irrespective of the flag)? I can understand your intentions, but this check seems pointless to me. - Mani -- மணிவண்ணன் சதாசிவம்