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 758E3C3DA61 for ; Wed, 24 Jul 2024 09:54:55 +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=bDgEYlw9bJMyIkYG+I3RR+zw7mE/Wd3hBgx5OXzcfpk=; b=ZFdA3OSrMneVKovCWLSpJngua0 EAesQRDFq7Z7esWjcOKLF+9aL6I6yyYLNckA6azjIhiqv6riwmF9CR8E2sjv936AGIc+Og5OTqrx4 vA3RySksAoiZ7CvgPRlfB/tGTAPd392M3Y7872rOMaKGqpvqsN0BXCMy/X613VT2knQvuZ11u5EkW 26ZgCn4XJl+J+jwvLrWr1JVCFRD41CYLxnhu/cgAymIunVS96WxPvS5xcbhgEZD7i5L7zixp4NXXc cOA42kGqUGIoyiDFgKMiTFHBGL1WLui3V1lwOgVzwl5HGXk9r81vv9byTt77GxXmXrlecne5qaAHB oRbR8J1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWYho-0000000F0Eb-03J2; Wed, 24 Jul 2024 09:54:44 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWYhP-0000000F0Bn-2rTB for linux-arm-kernel@lists.infradead.org; Wed, 24 Jul 2024 09:54:21 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-70d399da0b5so1778008b3a.3 for ; Wed, 24 Jul 2024 02:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721814858; x=1722419658; 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=bDgEYlw9bJMyIkYG+I3RR+zw7mE/Wd3hBgx5OXzcfpk=; b=O5mZ5j744TD2ADAzP/5jQmXLiZ2bKKpyKpPL10id3lQFKUu/uP4i7CpFE0IOEDfd48 ousXMlIbvrxoDjNO8Tazq1mwA93R9Lcr5JCtbJ+9zi/btjliXjIaXDAB3LanR6Wmgpq7 +fqz/PLjeakzwLCBAm1CevQx30IFCr2MVNBwgl5ac2v/4Fux/uKdiJ/lBqBh6+LZWW1t bNa5wAAZYN67nnmHL5LfFKFFELYFd/QKG9KcP+NQwV5Sh/XObZb1Rjj6aWlM+Ip1P5l6 oxvvLgPxdcJARQpetGn9sgbr5QRLGpB4KuyZLnOFs6K853rm0vIQL++YY9/ed23IAMcI cPtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721814858; x=1722419658; 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=bDgEYlw9bJMyIkYG+I3RR+zw7mE/Wd3hBgx5OXzcfpk=; b=cJ0tCVJy0k2JMdlOfCzMqeymWHiZPTEMBTmY/PSxXtaPZ97tVIslY+hcwOrR7iT698 p3yEGDNJuyADw7XO21so0qRrg8KnVDVNpW2g/wu8+fZopmV0A9N21nM+dpxDIYk0gj3a yuUPRT5l+yHgirQ7ShSHTXfrnpzjjj8rFOben9QF3Vxmi/ChHflQXrffWNjWnuHWi5nT wTbdNGzn9iGKM6i4PUSuOhj6ttQOYIl2ZnhgSpbvbSGyUYDwOP+qOn985+aCMrLuWojj 6wF+0R4GN0t4XHV/t1NY319RNjnMu+wroaaHAH4docLS8sBcdGrfotodJZ5NJs/mCbnj f3YA== X-Forwarded-Encrypted: i=1; AJvYcCXYvUVjGpzclLF0nuQUbdcI+Waglc1NQ2fBO3Sgk10ivYFQewpLU8x3Jl4vs5OqFdjsZOBst1f/EakYdVtG/tEE2zD2ufUY4CZd8PqEjBJOFvdF6KY= X-Gm-Message-State: AOJu0YxShMuv+SNAyuz/N2PKUFCpN2itMwtCHlpknyjOv+rxskZbuAu4 T2ZF76XsTPIquxE1dQLTNp6hjUBEAHjTCqH+rromAQGX/I68aG4tQFuc69RPwg== X-Google-Smtp-Source: AGHT+IFc+bmwgUZf2NfrEi7RhkKsd/8QICOyMXuwNBmgqrPle6nKABbl1IG3MSOd56s4eQUb8WgHpA== X-Received: by 2002:a05:6a00:2e19:b0:70d:2796:bce8 with SMTP id d2e1a72fcca58-70e996ffa7amr2918567b3a.20.1721814858089; Wed, 24 Jul 2024 02:54:18 -0700 (PDT) Received: from thinkpad ([2409:40f4:1015:1102:2847:8cd3:4e58:1c8]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-79f0b909876sm6583051a12.40.2024.07.24.02.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 02:54:17 -0700 (PDT) Date: Wed, 24 Jul 2024 15:24:07 +0530 From: Manivannan Sadhasivam To: Mayank Rana Cc: Rob Herring , Will Deacon , lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com, jingoohan1@gmail.com, cassel@kernel.org, yoshihiro.shimoda.uh@renesas.com, s-vadapalli@ti.com, u.kleine-koenig@pengutronix.de, dlemoal@kernel.org, amishin@t-argos.ru, thierry.reding@gmail.com, jonathanh@nvidia.com, Frank.Li@nxp.com, ilpo.jarvinen@linux.intel.com, vidyas@nvidia.com, marek.vasut+renesas@gmail.com, krzk+dt@kernel.org, conor+dt@kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, quic_ramkri@quicinc.com, quic_nkela@quicinc.com, quic_shazhuss@quicinc.com, quic_msarkar@quicinc.com, quic_nitegupt@quicinc.com, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH V2 7/7] PCI: host-generic: Add dwc PCIe controller based MSI controller usage Message-ID: <20240724095407.GA2347@thinkpad> References: <1721067215-5832-1-git-send-email-quic_mrana@quicinc.com> <1721067215-5832-8-git-send-email-quic_mrana@quicinc.com> <20240716085811.GA19348@willie-the-truck> <20240716134210.GA3534018-robh@kernel.org> <9b6eac04-f377-4afa-8712-ab916f831bba@quicinc.com> <6038632d-92ec-4034-bc68-add9d47f2bad@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6038632d-92ec-4034-bc68-add9d47f2bad@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240724_025419_786920_46805F2F X-CRM114-Status: GOOD ( 44.23 ) 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 Tue, Jul 23, 2024 at 03:56:35PM -0700, Mayank Rana wrote: > Hi Rob > > On 7/16/2024 3:32 PM, Mayank Rana wrote: > > Hi Will and Rob > > > > Thank you for your quick review comments. > > > > On 7/16/2024 6:42 AM, Rob Herring wrote: > > > On Tue, Jul 16, 2024 at 09:58:12AM +0100, Will Deacon wrote: > > > > On Mon, Jul 15, 2024 at 11:13:35AM -0700, Mayank Rana wrote: > > > > > Add usage of Synopsys Designware PCIe controller based MSI > > > > > controller to > > > > > support MSI functionality with ECAM compliant Synopsys Designware PCIe > > > > > controller. To use this functionality add device compatible string as > > > > > "snps,dw-pcie-ecam-msi". > > > > > > > > > > Signed-off-by: Mayank Rana > > > > > --- > > > > >   drivers/pci/controller/pci-host-generic.c | 92 > > > > > ++++++++++++++++++++++++++++++- > > > > >   1 file changed, 91 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/pci/controller/pci-host-generic.c > > > > > b/drivers/pci/controller/pci-host-generic.c > > > > > index c2c027f..457ae44 100644 > > > > > --- a/drivers/pci/controller/pci-host-generic.c > > > > > +++ b/drivers/pci/controller/pci-host-generic.c > > > > > @@ -8,13 +8,73 @@ > > > > >    * Author: Will Deacon > > > > >    */ > > > > > -#include > > > > >   #include > > > > > +#include > > > > >   #include > > > > > +#include > > > > >   #include > > > > >   #include > > > > >   #include > > > > > +#include "dwc/pcie-designware-msi.h" > > > > > + > > > > > +struct dw_ecam_pcie { > > > > > +    void __iomem *cfg; > > > > > +    struct dw_msi *msi; > > > > > +    struct pci_host_bridge *bridge; > > > > > +}; > > > > > + > > > > > +static u32 dw_ecam_pcie_readl(void *p_data, u32 reg) > > > > > +{ > > > > > +    struct dw_ecam_pcie *ecam_pcie = (struct dw_ecam_pcie *)p_data; > > > > > + > > > > > +    return readl(ecam_pcie->cfg + reg); > > > > > +} > > > > > + > > > > > +static void dw_ecam_pcie_writel(void *p_data, u32 reg, u32 val) > > > > > +{ > > > > > +    struct dw_ecam_pcie *ecam_pcie = (struct dw_ecam_pcie *)p_data; > > > > > + > > > > > +    writel(val, ecam_pcie->cfg + reg); > > > > > +} > > > > > + > > > > > +static struct dw_ecam_pcie *dw_pcie_ecam_msi(struct > > > > > platform_device *pdev) > > > > > +{ > > > > > +    struct device *dev = &pdev->dev; > > > > > +    struct dw_ecam_pcie *ecam_pcie; > > > > > +    struct dw_msi_ops *msi_ops; > > > > > +    u64 addr; > > > > > + > > > > > +    ecam_pcie = devm_kzalloc(dev, sizeof(*ecam_pcie), GFP_KERNEL); > > > > > +    if (!ecam_pcie) > > > > > +        return ERR_PTR(-ENOMEM); > > > > > + > > > > > +    if (of_property_read_reg(dev->of_node, 0, &addr, NULL) < 0) { > > > > > > Using this function on MMIO addresses is wrong. It is an untranslated > > > address. > > ok. do you prefer me to use of_address_to_resource() instead here ? > > > > > > > +        dev_err(dev, "Failed to get reg address\n"); > > > > > +        return ERR_PTR(-ENODEV); > > > > > +    } > > > > > + > > > > > +    ecam_pcie->cfg = devm_ioremap(dev, addr, PAGE_SIZE); > > > > > +    if (ecam_pcie->cfg == NULL) > > > > > +        return ERR_PTR(-ENOMEM); > > > > > + > > > > > +    msi_ops = devm_kzalloc(dev, sizeof(*msi_ops), GFP_KERNEL); > > > > > +    if (!msi_ops) > > > > > +        return ERR_PTR(-ENOMEM); > > > > > + > > > > > +    msi_ops->readl_msi = dw_ecam_pcie_readl; > > > > > +    msi_ops->writel_msi = dw_ecam_pcie_writel; > > > > > +    msi_ops->pp = ecam_pcie; > > > > > +    ecam_pcie->msi = dw_pcie_msi_host_init(pdev, msi_ops, 0); > > > > > +    if (IS_ERR(ecam_pcie->msi)) { > > > > > +        dev_err(dev, "dw_pcie_msi_host_init() failed\n"); > > > > > +        return ERR_PTR(-EINVAL); > > > > > +    } > > > > > + > > > > > +    dw_pcie_msi_init(ecam_pcie->msi); > > > > > +    return ecam_pcie; > > > > > +} > > > > > > > > Hmm. This looks like quite a lot of not-very-generic code to be adding > > > > to pci-host-generic.c. The file is now, what, 50% designware logic? > > > > > > Agreed. > > > > > > I would suggest you add ECAM support to the DW/QCom driver reusing some > > > of the common ECAM support code. > > I can try although there is very limited reusage of code with > > pcie-qcom.c and pcie-designware-host.c except reusing MSI functionality. > > That would make more new OPs within pcie-designware-host.c and > > pcie-qcom.c just to perform few operation. As now MSI functionality is > > available outside pcie core designware driver (although those changes > > are under review), will you be ok to allow separate Qualcomm PCIe ECAM > > driver as previously submitted RFC as https://lore.kernel.org/all/d10199df-5fb3-407b-b404-a0a4d067341f@quicinc.com/T/ > > > > I can modify above ECAM driver to call into PCIe designware module based > > MSI ops as doing here and that would allow reusing of MSI functionality > > at same time allowing separate driver for handling firmware VM based > > implementation. > Can you consider above request to have separate driver here ? > Please suggest on this. > Generic ECAM driver is already supporting some DWC based ECAM implementations like the ones added in commit 58fb207fb100 ("PCI: generic: Add support for Synopsys DesignWare RC in ECAM mode"). >From that perspective, I think it makes sense to add Qcom ECAM driver as a part of this. But at the same time, you can also add the ECAM mode to the existing DWC Qcom driver and reuse existing codes like MSI. Considering the amount of Qcom specific features you are going to add (like safety interrupts etc...), it won't look like a generic ECAM driver anyway. So I guess there is no *ideal* location for this driver. IMO as long as you avoid code duplication, I'm fine with whatever location. >From a quick look, I think it you go with Rob's suggestion, you can reuse existing MSI and future RASDES functionalities, isn't it? - Mani -- மணிவண்ணன் சதாசிவம்