From patchwork Thu Sep 19 22:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13808010 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011041.outbound.protection.outlook.com [52.101.65.41]) (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 7E20C1B3B30 for ; Thu, 19 Sep 2024 22:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726783450; cv=fail; b=UCAyb73aVRhsLsPjUJYoLDUSOUHAktGcdHQ4mHhNwArGCNh7MjJBayTs4qdCtm2HJjW+Pq+R79vApdZNRBk3Xe0QrkBMHFAgFrB+V3bdSjcsZFjdu5dJmJ528yd96mmnp9NG1R9BFvoi+evr1QBAXwwmTNousmuVRde4RcVvoLs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726783450; c=relaxed/simple; bh=xzYn63emtYc+0sKbyvuTFJ9WeodUAKX0K4Fs50oRMQo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=UdEJC0+hYFYzTYbTqwF9nNCIZC5+y67rHtRUWjmAdqFkdkBO4igIfCKMEFAEMCI1PND+J1wkhoL2SZ4k5dxdqbzZxsDwRBUAbmZW1UnvZgutzDYxW+mssbPtRc68lF5FiM3+D0jisba3GnQZ4hF4CCj7QCEpwbI0YgTvrGmlU0M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JygXVzgm; arc=fail smtp.client-ip=52.101.65.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JygXVzgm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cW7bgGOrvjsNPXb4f76//Lw/ySCoHXnltL8v2PundtKtsdAqSjKGpzO9oIxQAveCjH9/05qxRXhoqRs12Y0iwT6eFe8UmCI5AmMrr/ihZlMX1eGCpqOsnyU9H6gNfTbyhtses0d1Q8qfeUseGrxOWdUR6J01YVqd8aWVmR5g5rGZgWO3rZeOydxyMdnDZlv1Rq/ycDMl/FtFneNZ+ea7Ehv82s4HpDxgW4Rf4C/RLrYHdcZTCdRR8xn/g9wjwiDYtnaU7CvQOLOA3DnXpWu5u/CJSQTyU1z9Y9mUVzMS8FSLO1bYb6Dlkz+gqZmOxPc92KFZ0JXVVwr6OQ3ayPWuRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N5eUkhJHRxOeEl28v7oWBblbZUiVSwRNPOWGzZMSZ0o=; b=HhgghtOVM7kVKEGpyoVHZmTbP41AY4KpMvA6g8mxQoray0kM8qsw7L3Es5ME2G1iuuI8S4QQ/G+GBdqeu5B+EsT1GQg51mjcF6CEVLMirQqrSJxce68yJZmZxuecm6HfiqWpZHBkbYI9PFrx3jg2XcK4xnpfoZ8eVDqWtYFyakBAA3p5kFUtAM2MPxZYTdUgF1lGPqKHJNn+236vm2RWopYNX9vIC+6Kg1DkbyBs+myEiv41mtIDHfCeTt+uOvqoBxlqNoqUjqDgTQArZZRC2kfXvMlI3UMHd8X1XYEYT0bBeFMfssrkDlWe4Oy5MrToTkBNkKtfL618k+28Ff+1iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N5eUkhJHRxOeEl28v7oWBblbZUiVSwRNPOWGzZMSZ0o=; b=JygXVzgmIqxxdExmaLA9Vu8bCTu3sTv8a3ztsLmPgSyK1WlXc5s3ZiwqffmaGqI7AsamRipmLNAfEGyqfFoQxRd+iZF6gZqlAOcdISI47SKDtjjrjZg08OEuu5XFZu0uSBPZ2FbQdDszeCu5BgamQWPGYO2oHmvGpiwuaq2nByNpma73qrmcmcN0BF28b1hPsK+HxEL6n2G8+HMN1q4Kxq7lBWQBOSETxBqffip3X4BGwPCuLHwu73hE+jPy5ZrQL3W8iB4kFjcKqCxwdPeLFO2iKDAK1BgOt6O4yv0XlXkzABckoL/oaZ3wtCase0PN57Y8ySA+aGsWQQXM9Nf5CQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by GVXPR04MB9849.eurprd04.prod.outlook.com (2603:10a6:150:112::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Thu, 19 Sep 2024 22:04:05 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7982.018; Thu, 19 Sep 2024 22:04:05 +0000 From: Frank Li Date: Thu, 19 Sep 2024 18:03:05 -0400 Subject: [PATCH 5/9] PCI: dwc: ep: Replace phys_base and addr_size with range Message-Id: <20240919-pcie_ep_range-v1-5-b3e9d62780b7@nxp.com> References: <20240919-pcie_ep_range-v1-0-b3e9d62780b7@nxp.com> In-Reply-To: <20240919-pcie_ep_range-v1-0-b3e9d62780b7@nxp.com> To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Abraham I , Saravana Kannan , Jingoo Han , Gustavo Pimentel , Jesper Nilsson , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, =?utf-8?q?Krzys?= =?utf-8?q?ztof_Wilczy=C5=84ski?= , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1726783409; l=3076; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=xzYn63emtYc+0sKbyvuTFJ9WeodUAKX0K4Fs50oRMQo=; b=F4FFq004pYIQGI3NL8uKoINIVRJvhIbVz198gtigJ7zMRQT9xuttIBNi6AqXVgvdxZnUE30hX GRMs1qYsxpLBgLyjTM++wDtdiJXxcoNlmvpr1yq9M00s4qH+memyi2z X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0057.namprd05.prod.outlook.com (2603:10b6:a03:33f::32) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GVXPR04MB9849:EE_ X-MS-Office365-Filtering-Correlation-Id: 237f8e7b-dc94-4ce0-2695-08dcd8f6fa72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Be+Md8kc/BV9jAveNYok4HM0ATthzt/?= =?utf-8?q?nPSAVLOBozwFax1bZ1oUUEGA5YZYwwYX5ZYiyVWGxolfmMNs6kG48C2/am34w4ipL?= =?utf-8?q?pezigZBET95C9iVuLfnf17fHvZqVUuRbo2qadlKHp6XwRON61dkHjvLYnWFZKIrov?= =?utf-8?q?418SqcGRV6DoQeapRblDFB8XXDS0uDXf4qAyJ8+6exFFQScBMhdkwkoUkd7jXFgr+?= =?utf-8?q?VHqPqdGikfCkV4H3UYoeao3Asx09MCDyC1d9WZjGDV5uARAp98GUjiWbWg4T/kboG?= =?utf-8?q?iIYGKlGGzimtTMKVRVFmrOrvFY02xCnl7QeECgE5e3spZyYWRQZQccavn0oJ4YE/c?= =?utf-8?q?yhTs3xps6Y7G7iTaXs73uebFXAK+BZLKp/wL87mwZj9CdyJ2UIvEE2RVDaiaqGelV?= =?utf-8?q?8LXUD/sFXgwl9KS196q9FRGn1YlAsj5fbOGArIEkdJfgFZYXsyZrb9cF3+9CyKfHL?= =?utf-8?q?USK6Dzv+oAUN+nOhf3qKgrbn64ot37xN2FmHWFHCF3cBU0ERacnDTfguESm4ggE3A?= =?utf-8?q?brU/DCYyp7whBDiRfLyEI5VPi+WICI8lbde3Ccws7Wgd2D7bfkuNCIigaffZOitTv?= =?utf-8?q?Q3sOcWAk5vf8KT47n5ms/0XeWkrhxQvwUhc4fIvxCLIIhP84FN7jaZ12Bj3O05iuX?= =?utf-8?q?F9fJ6yd7ZSqH/kWTL4e/z48fOzQDaFyioP6Q2Ow7EHMzJE7I1sQoYTEc6zVID4VgN?= =?utf-8?q?7FNU5C/ORyVTPF+x6pBTz8H4wHUvDWTgzJofy91gGNIdSFIvfu9/ptangVgv+CXrH?= =?utf-8?q?pZaArB7s5mDuavetMWrqwKnn1wldqR6MhBPHyvlBOwGFUK8koZ1bX8xq7PEPFG5wM?= =?utf-8?q?uCjojnb5xMpP1Y2l/+BKVHYhiTxViEF84x5ImQAZoUX1LAluhrL957HjJtrAsJcnK?= =?utf-8?q?xDDOonAv2utUE33dRf/AsJ/lVAhSc0e+yNJvrsWeGuJxOsElbDXcP2aY6251up5AJ?= =?utf-8?q?T7aghEvi1/W0sz4T0JcZSHzQG9ptS6+KB5vX4IJAvkywLsDrcOmh3utJmr3Xc5I88?= =?utf-8?q?N9dMwOxw1xp7iGgaFLt9Wlj+WqqpxOLK93ebkR+Z0fbmsTwSv6rahs3Y9t5smbCPD?= =?utf-8?q?iKXkpHdve4kO/vAv34RqiO8D2NG3cR5E168FjN7ZgXqmJ1jnGRdTaceJAKpAjYrvB?= =?utf-8?q?iybj7aDCeaDiUG88UxidarbGMxShVjTU+D6DwAqxa+5h7MV9SxdWq3edWvhObfARZ?= =?utf-8?q?KvUCKmfeqJl6d2Igi7cnv8x9k/8RWDB9Ap5YTWPfdgsSJQ3nrLywhu7X+wK73Ytx/?= =?utf-8?q?eunFrgcT2cwkHQqIBFdza14yz+GV3erofs13taTw1cojguLygN6G4ZPXYxjYRoBQe?= =?utf-8?q?Y108pVm/IaCg8GBjeTNUVjCYzqpLhe1CQrcI8JWoOSxgIYxyhOL6qcI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?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gKg0LHTFqSAmPnxloKC6qa5g9?= =?utf-8?q?jnxvL5+wB5rCfe7WK0sk722z87H4PGF0RRvJoRfWrrSx48BhVEGmBkL1ajwM3TAQh?= =?utf-8?q?psn56ns72C/ZhmKDZxmMz8/AKMDd1EFY9CfK8AeX32leBwZZRsRzCCh0tOZeGW/Ho?= =?utf-8?q?oEriO68m/1G4aDIf2yhzlX/kRyoHqy4OQKG6MjEsmUUkCdS2dskDSKMDVi3/oWnTF?= =?utf-8?q?oZ4Q+e3DbFCkpKSDlUfM1JZduvWOqJ66iJVIOhvGH7QZbi49zFGpxGFELy4Aujbsq?= =?utf-8?q?0QRCNEJ2Knzt9JDa59/jmrA+AxOvq2dJ8pCeubIG0wgEiGN84CBBiF5tTD953w9a7?= =?utf-8?q?ZdoEtWaxdPk8UwttHjRdOjD9GrL2QAGAlQoY9mSIZpcr4gajb0mNfww7osilpZOCE?= =?utf-8?q?veG4BtG+/3qSLfpZHf8AvcZP6apm4LuXQLh9H8MLCF+w3LiCn8jI9w3FZYNCaqhGd?= =?utf-8?q?20bdg1ICM2FSesIn5wklaKgbepjfmSSIE2lkL5jCvNJ1u/mcADP7yK0odM4WRg2Ls?= =?utf-8?q?6zukq/NoPl1BNV/D+6yDT2ph4ojFFTUOqwvGjA6faUBSl2cqS0zpKkSeEWNqQc8oB?= =?utf-8?q?xuvas+rLcKKuDPtj4deRZfzR66Y4L0L8fLNylslqM6x6W+w24kvcot2mkKaZLWj+J?= =?utf-8?q?lTPEB0otuq1/?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 237f8e7b-dc94-4ce0-2695-08dcd8f6fa72 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 22:04:05.6174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: htu9MGrbSmcSGZ3l3L8hDTyu9CFBqlZo3+2CTRvRoXA4QiiD2I708/cb+Cb1IDdBMjfzB/gSqv0D0uf/kk+XnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9849 The CPU address and PCI address are the same in most system. But in some systems such as i.MX8QXP, they are different. Previously, we used the cpu_addr_fixup() hook function to handle address translation. However, the device tree can use the common 'ranges' property to indicate how CPU and PCI addresses are translated. Replace the fields 'phys_base' and 'addr_size' in struct dw_pcie_ep with struct of_pci_range 'range'. The of_pci_range already includes cpu_addr and size information. Prepare to add 'ranges' support. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/dwc/pcie-designware-ep.c | 6 +++--- drivers/pci/controller/dwc/pcie-designware.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c b/drivers/pci/controller/dwc/pcie-artpec6.c index f8e7283dacd47..f93d3c7a980c8 100644 --- a/drivers/pci/controller/dwc/pcie-artpec6.c +++ b/drivers/pci/controller/dwc/pcie-artpec6.c @@ -104,7 +104,7 @@ static u64 artpec6_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 cpu_addr) case DW_PCIE_RC_TYPE: return cpu_addr - pp->cfg0_base; case DW_PCIE_EP_TYPE: - return cpu_addr - ep->phys_base; + return cpu_addr - ep->range.cpu_addr; default: dev_err(pci->dev, "UNKNOWN device type\n"); } diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 43ba5c6738df1..feac1a435f764 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -872,8 +872,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (!res) return -EINVAL; - ep->phys_base = res->start; - ep->addr_size = resource_size(res); + ep->range.cpu_addr = ep->range.pci_addr = res->start; + ep->range.size = resource_size(res); if (ep->ops->pre_init) ep->ops->pre_init(ep); @@ -891,7 +891,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (ret < 0) epc->max_functions = 1; - ret = pci_epc_mem_init(epc, ep->phys_base, ep->addr_size, + ret = pci_epc_mem_init(epc, ep->range.cpu_addr, ep->range.size, ep->page_size); if (ret < 0) { dev_err(dev, "Failed to initialize address space\n"); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 347ab74ac35aa..59109a32b2afc 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -409,8 +410,7 @@ struct dw_pcie_ep { struct pci_epc *epc; struct list_head func_list; const struct dw_pcie_ep_ops *ops; - phys_addr_t phys_base; - size_t addr_size; + struct of_pci_range range; size_t page_size; u8 bar_to_atu[PCI_STD_NUM_BARS]; phys_addr_t *outbound_addr;