Received: by 10.223.164.202 with SMTP id h10csp2833858wrb; Sun, 12 Nov 2017 20:03:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMbcOX8rRBvmalSRpZA8XObHMWQK7lsfFQfO/Zj8lHagHBLi1jJ6hwax5NjZ7KH93825G7kb X-Received: by 10.99.163.25 with SMTP id s25mr7524739pge.310.1510545821864; Sun, 12 Nov 2017 20:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510545821; cv=none; d=google.com; s=arc-20160816; b=F4wuAmz4ywmEpvoZdZBdLW8zOcUANGYgu61pgz+fzK0RnGdIOhjDKFn6yCAYdik/PN 9Ogs06L75yLYG/cVbNWg80t64W9d6a05hOTEKSrpRpsUVIXTZaKS95/X4+4wUZqWVrs9 quAd/ZODiesga07jc6cOecN7EBPncv3JegtiaxvMS5T9SLQDf8SdsHYO3NyCRWYlbVLc EBmRfpM0dYEAaB98/KoKHjWcOhTQW9cOZx6236Z36cVgy8pGp9A0W029MCvVR0IG0Nge S2l/acqb53fo7IvwYRnx201D9IVugvSjJilkTMYO3o41qfyru6lleXPj4eRozKBVJglS ExGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:dkim-signature :arc-authentication-results; bh=Nh9qiBPn2FUOeHJ3kAd5LkmZ30hsRrmRXREEB7LQDzE=; b=f3tc3DxIct4PqNFY0Hp/ysq5oDMLWU4bOq4HeJpyz2FIXu/gxIde7WmjbG3yUhb6hj RQMZGVi5eS9ZY14tlFIEHp6IPEcRywUqTnHoojcnX4aXSnmt/yAX29FSTnaLncAgmg6N 0Koc6s+uu93i2NTYmO/JYk3F2Sw/uPCC1ptM7BGj5+umIHlivp5jPV7AJEH5pLhX+lh2 zx39Ts9UKNPyHbJf4bLOuu1A2DtiK6/TQkjLNQGx+D06tJYybWsC1/yCX8mI7rPkIjZP phYgG7rhXy/Q5wX9uMBg9hIiivtV7nbajblNMYjQSJmIdHL02QEl/jM0DieIIXKPhp8C MVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=CNZ4rt97; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si13130185pgq.361.2017.11.12.20.03.28; Sun, 12 Nov 2017 20:03:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=CNZ4rt97; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793AbdKMECs (ORCPT + 87 others); Sun, 12 Nov 2017 23:02:48 -0500 Received: from mail-ve1eur01on0040.outbound.protection.outlook.com ([104.47.1.40]:24954 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751637AbdKMECp (ORCPT ); Sun, 12 Nov 2017 23:02:45 -0500 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; bh=Nh9qiBPn2FUOeHJ3kAd5LkmZ30hsRrmRXREEB7LQDzE=; b=CNZ4rt97ZQtQyRhgZFDAOT9STBrnP4IKbCFjdLhoa8mO1xAhQN4lBTz8CWeaxiMDwdjcElan3Q+cpl+dd+sFn7l+IcEvcPEN79iljpdYGHDAZcGqnIGgIsnWgfLI/Nc3OlG2JHLVO0Dtx5IrFIJze7X+x53MXI1UVIrjAbs8pNI= Received: from HE1PR04MB3114.eurprd04.prod.outlook.com (10.171.196.32) by HE1PR04MB1452.eurprd04.prod.outlook.com (10.163.176.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Mon, 13 Nov 2017 04:02:40 +0000 Received: from HE1PR04MB3114.eurprd04.prod.outlook.com ([fe80::7c45:dc7:82b6:2636]) by HE1PR04MB3114.eurprd04.prod.outlook.com ([fe80::7c45:dc7:82b6:2636%13]) with mapi id 15.20.0218.011; Mon, 13 Nov 2017 04:02:40 +0000 From: Xiaowei Bao To: Kishon Vijay Abraham I , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "bhelgaas@google.com" , "shawnguo@kernel.org" , Madalin-cristian Bucur , Sumit Garg , "Y.b. Lu" , "hongtao.jia@nxp.com" , Andy Tang , Leo Li , "jingoohan1@gmail.com" , "pbrobinson@gmail.com" , "songxiaowei@hisilicon.com" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "Z.q. Hou" , "Mingkai Hu" , "M.h. Lian" Subject: RE: [PATCHv4 2/3] ARMv8: layerscape: add the pcie ep function support Thread-Topic: [PATCHv4 2/3] ARMv8: layerscape: add the pcie ep function support Thread-Index: AQHTWdl1ZmsGSCDQcUeOShbnnZd0TaMNJ4QAgAR73vA= Date: Mon, 13 Nov 2017 04:02:40 +0000 Message-ID: References: <20171110034847.17891-1-xiaowei.bao@nxp.com> <20171110034847.17891-3-xiaowei.bao@nxp.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=xiaowei.bao@nxp.com; x-originating-ip: [199.59.231.64] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1PR04MB1452;6:XTscfAOSK43hNHTnlH56mGdYM5crMacby6nyk7KxDJXHoY0GUQE95K2kgo7LsyrsIB4CQZXVnFOUS/7U2RkbXQpxaZqkNhkoodEzaAZepQ01pPIB2dDWLJtZpOlu/6rs73gFvpgjrr51L3a5zzuevEj53XCEpB6JDD8LL2Rn/SsEbpb5YGO8zUCAZBfsUf281A6Tx6eRMiufv9UZfIcXVgAGh39l2A4DJcxPMJBs34jPvpn9FQniArPdCeFQ1CiQYBCJqcpEHeq/ZhM8mgvRif3M9q2H/Pn4GWIDDujAUKnz/YZF9IdWBgyJy9SioFB9EkkI86s/B2LKo5TPRSO+0Hm1uYCXQm+5/YogLpG8jmg=;5:F5U7hVduSVQmK+nWLa8EiYRc+zgOFffrmdH7kgYu30o23g6ehaYIWcuOCZULT862R0wB+Myyg7Rqj9TXHB3CywxRHyO7azh1DOfBQ4mNMDM8cOuSK0I90n8jWW6r0f0lekUWpbCtoQogFGe/JeJNbWPvKB1B0pnAEbHMpxXarNw=;24:6oOJfqC3B8FLN4E+zdBimblWKC/w+odg0eESlGT72SWv8O1UHrDVUMoni9lY26t4SpRe6FHQXmooPBG8eUoAu5ks4AD6GcJ79lw3FYRNqV8=;7:oIekFS92x/pifj7lcrhcGdsrHZQ6ywc6eryChXgsXO7DATDfYQzrIjzRFG4aoZfnaKSO9MlO9cMDwU/17iU1Z04cMTlOA8/ibdSh4YqgZK80BSrm4dq3uvh+tUtT2wWmOzl88uZgXuBW4sTicK79Xa2qUxSSMgZSNBrUvdc0CUW54I7TEMPp3S3rxbwD5+Z0KBgICqByCA0HRPN1XH3ZKlOfGrJ5aMIEDv2ra2DKq6o6/bnn6m3odn+r6ygTtI05 x-ms-office365-filtering-correlation-id: 53d7fb7d-98b1-47ee-c162-08d52a4b625e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:HE1PR04MB1452; x-ms-traffictypediagnostic: HE1PR04MB1452: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(31051911155226)(9452136761055)(189930954265078)(65623756079841)(185117386973197)(258649278758335)(211936372134217)(45079756050767); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231022)(920507027)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR04MB1452;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR04MB1452; x-forefront-prvs: 0490BBA1F0 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(376002)(346002)(39860400002)(199003)(24454002)(189002)(13464003)(3280700002)(39060400002)(229853002)(50986999)(68736007)(97736004)(76176999)(54356999)(6436002)(6506006)(25786009)(7696004)(86362001)(575784001)(316002)(6246003)(99286004)(2950100002)(5660300001)(5250100002)(2900100001)(110136005)(2501003)(7416002)(101416001)(3660700001)(66066001)(189998001)(33656002)(966005)(14454004)(105586002)(6636002)(106356001)(6306002)(478600001)(81156014)(81166006)(8676002)(9686003)(45080400002)(2201001)(7736002)(3846002)(55016002)(102836003)(6116002)(53546010)(2906002)(53936002)(305945005)(74316002)(8936002)(34040400001)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB1452;H:HE1PR04MB3114.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53d7fb7d-98b1-47ee-c162-08d52a4b625e X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Nov 2017 04:02:40.2365 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1452 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Kishon Vijay Abraham I [mailto:kishon@ti.com] > Sent: Friday, November 10, 2017 2:32 PM > To: Xiaowei Bao ; robh+dt@kernel.org; > mark.rutland@arm.com; catalin.marinas@arm.com; will.deacon@arm.com; > bhelgaas@google.com; shawnguo@kernel.org; Madalin-cristian Bucur > ; Sumit Garg ; Y.b. Lu > ; hongtao.jia@nxp.com; Andy Tang > ; Leo Li ; jingoohan1@gmail.com; > pbrobinson@gmail.com; songxiaowei@hisilicon.com; > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux- > kernel@vger.kernel.org; linux-pci@vger.kernel.org; linuxppc- > dev@lists.ozlabs.org; Z.q. Hou ; Mingkai Hu > ; M.h. Lian > Subject: Re: [PATCHv4 2/3] ARMv8: layerscape: add the pcie ep function su= pport >=20 > Hi, >=20 > On Friday 10 November 2017 09:18 AM, Bao Xiaowei wrote: > > Add the pcie controller ep function support of layerscape base on pcie > > ep framework. > > > > Signed-off-by: Bao Xiaowei > > --- > > v2: > > - fix the ioremap function used but no ioumap issue > > - optimize the code structure > > - add code comments > > v3: > > - fix the msi outband window request failed issue > > v4: > > - optimize the code, adjust the format > > > > drivers/pci/dwc/pci-layerscape.c | 120 > > ++++++++++++++++++++++++++++++++++++--- > > 1 file changed, 113 insertions(+), 7 deletions(-) >=20 > $subject should begin with > PCI: layerscape: > > > > diff --git a/drivers/pci/dwc/pci-layerscape.c > > b/drivers/pci/dwc/pci-layerscape.c > > index 87fa486bee2c..6f3e434599e0 100644 > > --- a/drivers/pci/dwc/pci-layerscape.c > > +++ b/drivers/pci/dwc/pci-layerscape.c > > @@ -34,7 +34,12 @@ > > /* PEX Internal Configuration Registers */ > > #define PCIE_STRFMR1 0x71c /* Symbol Timer & Filter Mask > Register1 */ > > > > +#define PCIE_DBI2_BASE 0x1000 /* DBI2 base address*/ >=20 > The base address should come from dt. We get the dbi base address form dt, and this is the offset base on the dbi= base address, if the follow patch is merged, this define is not needed. > > +#define PCIE_MSI_MSG_DATA_OFF 0x5c /* MSI Data register address*/ > > +#define PCIE_MSI_OB_SIZE 4096 > > +#define PCIE_MSI_ADDR_OFFSET (1024 * 1024) > > #define PCIE_IATU_NUM 6 > > +#define PCIE_EP_ADDR_SPACE_SIZE 0x100000000 > > > > struct ls_pcie_drvdata { > > u32 lut_offset; > > @@ -44,12 +49,20 @@ struct ls_pcie_drvdata { > > const struct dw_pcie_ops *dw_pcie_ops; }; > > > > +struct ls_pcie_ep { > > + dma_addr_t msi_phys_addr; > > + void __iomem *msi_virt_addr; > > + u64 msi_msg_addr; > > + u16 msi_msg_data; > > +}; > > + > > struct ls_pcie { > > struct dw_pcie *pci; > > void __iomem *lut; > > struct regmap *scfg; > > const struct ls_pcie_drvdata *drvdata; > > int index; > > + struct ls_pcie_ep *pcie_ep; > > }; > > > > #define to_ls_pcie(x) dev_get_drvdata((x)->dev) > > @@ -263,6 +276,99 @@ static const struct of_device_id ls_pcie_of_match[= ] =3D > { > > { }, > > }; > > > > +static void ls_pcie_raise_msi_irq(struct ls_pcie_ep *pcie_ep) { > > + iowrite32(pcie_ep->msi_msg_data, pcie_ep->msi_virt_addr); } > > + > > +static int ls_pcie_raise_irq(struct dw_pcie_ep *ep, > > + enum pci_epc_irq_type type, u8 interrupt_num) { > > + struct dw_pcie *pci =3D to_dw_pcie_from_ep(ep); > > + struct ls_pcie *pcie =3D to_ls_pcie(pci); > > + struct ls_pcie_ep *pcie_ep =3D pcie->pcie_ep; > > + u32 free_win; > > + > > + /* get the msi message address and msi message data */ > > + pcie_ep->msi_msg_addr =3D ioread32(pci->dbi_base + > MSI_MESSAGE_ADDR_L32) | > > + (((u64)ioread32(pci->dbi_base + MSI_MESSAGE_ADDR_U32)) << > 32); > > + pcie_ep->msi_msg_data =3D ioread16(pci->dbi_base + > > +PCIE_MSI_MSG_DATA_OFF); > > + > > + /* request and config the outband window for msi */ > > + free_win =3D find_first_zero_bit(&ep->ob_window_map, > > + sizeof(ep->ob_window_map)); > > + if (free_win >=3D ep->num_ob_windows) { > > + dev_err(pci->dev, "no free outbound window\n"); > > + return -ENOMEM; > > + } > > + > > + dw_pcie_prog_outbound_atu(pci, free_win, PCIE_ATU_TYPE_MEM, > > + pcie_ep->msi_phys_addr, > > + pcie_ep->msi_msg_addr, > > + PCIE_MSI_OB_SIZE); > > + > > + set_bit(free_win, &ep->ob_window_map); >=20 > This custom logic is not required. You can use [1] instead >=20 > [1] -> > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flkml= .or > g%2Flkml%2F2017%2F11%2F3%2F318&data=3D02%7C01%7Cxiaowei.bao%40nxp. > com%7Cdefeb10941b145bc81ac08d528051939%7C686ea1d3bc2b4c6fa92cd99c > 5c301635%7C0%7C0%7C636458924733901810&sdata=3D3TMGeoj3L9SlNsXeAYN > %2BSe0K1Orv3xb7Ah9G%2BD9k4Rg%3D&reserved=3D0 These patchs have not merged on the latest kernel, yes? I will test it when= these patchs merged, analyzed the patch, it is viable for ls1046a platform= . > > + > > + /* generate the msi interrupt */ > > + ls_pcie_raise_msi_irq(pcie_ep); > > + > > + /* release the outband window of msi */ > > + dw_pcie_disable_atu(pci, free_win, DW_PCIE_REGION_OUTBOUND); > > + clear_bit(free_win, &ep->ob_window_map); > > + > > + return 0; > > +} > > + > > +static struct dw_pcie_ep_ops pcie_ep_ops =3D { > > + .raise_irq =3D ls_pcie_raise_irq, > > +}; > > + > > +static int __init ls_add_pcie_ep(struct ls_pcie *pcie, > > + struct platform_device *pdev) > > +{ > > + struct dw_pcie *pci =3D pcie->pci; > > + struct device *dev =3D pci->dev; > > + struct dw_pcie_ep *ep; > > + struct ls_pcie_ep *pcie_ep; > > + struct resource *cfg_res; > > + int ret; > > + > > + ep =3D &pci->ep; > > + ep->ops =3D &pcie_ep_ops; > > + > > + pcie_ep =3D devm_kzalloc(dev, sizeof(*pcie_ep), GFP_KERNEL); > > + if (!pcie_ep) > > + return -ENOMEM; > > + > > + pcie->pcie_ep =3D pcie_ep; > > + > > + cfg_res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, > "config"); > > + if (cfg_res) { > > + ep->phys_base =3D cfg_res->start; > > + ep->addr_size =3D PCIE_EP_ADDR_SPACE_SIZE; > > + } else { > > + dev_err(dev, "missing *config* space\n"); > > + return -ENODEV; > > + } > > + > > + pcie_ep->msi_phys_addr =3D ep->phys_base + PCIE_MSI_ADDR_OFFSET; > > + > > + pcie_ep->msi_virt_addr =3D ioremap(pcie_ep->msi_phys_addr, > > + PCIE_MSI_OB_SIZE); > > + if (!pcie_ep->msi_virt_addr) { > > + dev_err(dev, "failed to map MSI outbound region\n"); > > + return -ENOMEM; > > + } > > + > > + ret =3D dw_pcie_ep_init(ep); > > + if (ret) { > > + dev_err(dev, "failed to initialize endpoint\n"); > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > static int __init ls_add_pcie_port(struct ls_pcie *pcie) { > > struct dw_pcie *pci =3D pcie->pci; > > @@ -309,18 +415,18 @@ static int __init ls_pcie_probe(struct > platform_device *pdev) > > if (IS_ERR(pci->dbi_base)) > > return PTR_ERR(pci->dbi_base); > > > > - pcie->lut =3D pci->dbi_base + pcie->drvdata->lut_offset; > > + pci->dbi_base2 =3D pci->dbi_base + PCIE_DBI2_BASE; > > > > - if (!ls_pcie_is_bridge(pcie)) > > - return -ENODEV; > > + pcie->lut =3D pci->dbi_base + pcie->drvdata->lut_offset; > > > > platform_set_drvdata(pdev, pcie); > > > > - ret =3D ls_add_pcie_port(pcie); > > - if (ret < 0) > > - return ret; > > + if (!ls_pcie_is_bridge(pcie)) > > + ret =3D ls_add_pcie_ep(pcie, pdev); >=20 > HOST or EP mode should be obtained directly from dt. The RC or EP mode can configured by the rcw, we can't obtain the RC or EP m= ode from the dt, we can obtain the RC or EP mode by reading the specific r= egister in code. >=20 > Thanks > Kishon From 1583659921389728327@xxx Fri Nov 10 06:36:32 +0000 2017 X-GM-THRID: 1583650627816591526 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread