public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Vidya Sagar <vidyas@nvidia.com>
To: Jingoo Han <jingoohan1@gmail.com>,
	"gustavo.pimentel@synopsys.com" <gustavo.pimentel@synopsys.com>,
	"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"Jisheng.Zhang@synaptics.com" <Jisheng.Zhang@synaptics.com>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"kishon@ti.com" <kishon@ti.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kthota@nvidia.com" <kthota@nvidia.com>,
	"mmaddireddy@nvidia.com" <mmaddireddy@nvidia.com>,
	"sagar.tv@gmail.com" <sagar.tv@gmail.com>
Subject: Re: [PATCH V7 2/3] PCI: dwc: Cleanup DBI,ATU read and write APIs
Date: Sun, 23 Jun 2019 20:13:14 +0530	[thread overview]
Message-ID: <beef4f7f-e6e5-4735-7847-c04e608d54d5@nvidia.com> (raw)
In-Reply-To: <PSXP216MB0662E297AC662E53D515141CAAE10@PSXP216MB0662.KORP216.PROD.OUTLOOK.COM>

On 6/23/2019 1:17 PM, Jingoo Han wrote:
> On 6/23/19, 1:52 AM, Vidya Sagar wrote:
>>
>> Cleanup DBI read and write APIs by removing "__" (underscore) from their
>> names as there are no no-underscore versions and the underscore versions
>> are already doing what no-underscore versions typically do. It also removes
>> passing dbi/dbi2 base address as one of the arguments as the same can be
>> derived with in read and write APIs. Since dw_pcie_{readl/writel}_dbi()
>> APIs can't be used for ATU read/write as ATU base address could be
>> different from DBI base address, this patch attempts to implement
>> ATU read/write APIs using ATU base address without using
>> dw_pcie_{readl/writel}_dbi() APIs.
>>
>> Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
>> ---
>> Changes from v6:
>> * Modified ATU read/write APIs to use implementation specific DBI read/write
>>    APIs if present.
>>
>> Changes from v5:
>> * Removed passing base address as one of the arguments as the same can be derived within
>>    the API itself.
>> * Modified ATU read/write APIs to call dw_pcie_{write/read}() API
>>
>> Changes from v4:
>> * This is a new patch in this series
>>
>>   drivers/pci/controller/dwc/pcie-designware.c | 28 +++++------
>>   drivers/pci/controller/dwc/pcie-designware.h | 51 +++++++++++++-------
>>   2 files changed, 45 insertions(+), 34 deletions(-)
> 
> .....
> 
>>   static inline void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
>>   {
>> -	__dw_pcie_write_dbi(pci, pci->atu_base, reg, 0x4, val);
>> +	int ret;
>> +
>> +	if (pci->ops->write_dbi) {
>> +		pci->ops->write_dbi(pci, pci->atu_base, reg, 0x4, val);
>> +		return;
>> +	}
>> +
>> +	ret = dw_pcie_write(pci->atu_base + reg, 0x4, val);
>> +	if (ret)
>> +		dev_err(pci->dev, "Write ATU address failed\n");
>>   }
>>   
>>   static inline u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)
>>   {
>> -	return __dw_pcie_read_dbi(pci, pci->atu_base, reg, 0x4);
>> +	int ret;
>> +	u32 val;
>> +
>> +	if (pci->ops->read_dbi)
>> +		return pci->ops->read_dbi(pci, pci->atu_base, reg, 0x4);
>> +
>> +	ret = dw_pcie_read(pci->atu_base + reg, 0x4, &val);
>> +	if (ret)
>> +		dev_err(pci->dev, "Read ATU address failed\n");
>> +
>> +	return val;
>>   }
> 
> Hmm. In cases of dbi and  dbi2, readb/readw/readl and writeb/writew/writel are
> located in pcie-designware.h. These functions just call read/write which are located
> in pcie-designware.c. For readability, would you write the code as below?
> 
> 1. For drivers/pci/controller/dwc/pcie-designware.h,
>      Just call dw_pcie_{write/read}_atu(), instead of implementing functions as below.
> 
> 	static inline void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
> 	{
> 		return  dw_pcie_write_atu(pci, reg, 0x4, val);
> 	}
> 
> 	static inline u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)	
> 	{
> 		return  dw_pcie_read_atu(pci, reg, 0x4);
> 	}
> 
> 2. For drivers/pci/controller/dwc/pcie-designware.c,
>      Please add new dw_pcie_{write/read}_atu() as below.
> 
> 	void dw_pcie_write_atu(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
> 	{
> 		int ret;
> 
> 		if (pci->ops->write_dbi) {
> 			pci->ops->write_dbi(pci, pci->atu_base, reg, size, val);
> 			return;
> 		}
> 
> 		ret = dw_pcie_write(pci->atu_base + reg, size, val);
> 		if (ret)
> 			dev_err(pci->dev, "Write ATU address failed\n");
> 	}
> 
> 	u32 dw_pcie_read_atu(struct dw_pcie *pci, u32 reg, size_t size)
> 	{
> 		int ret;
> 		u32 val;
> 
> 		if (pci->ops->read_dbi)
> 			return pci->ops->read_dbi(pci, pci->atu_base, reg, size);
> 
> 		ret = dw_pcie_read(pci->atu_base + reg, size, &val);
> 		if (ret)
> 			dev_err(pci->dev, "Read ATU address failed\n");
> 
> 		return val;
> 	}
> 
> Thank you.
> 
> Best regards,
> Jingoo Han
Ok. I'll take care of it in next patch.

> 
>>   
>>   static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
>> -- 
>> 2.17.1
> 


  reply	other threads:[~2019-06-23 14:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-22 16:51 [PATCH V7 1/3] PCI: dwc: Add API support to de-initialize host Vidya Sagar
2019-06-22 16:51 ` [PATCH V7 2/3] PCI: dwc: Cleanup DBI,ATU read and write APIs Vidya Sagar
2019-06-23  7:47   ` Jingoo Han
2019-06-23 14:43     ` Vidya Sagar [this message]
2019-06-22 16:51 ` [PATCH V7 3/3] PCI: dwc: Export APIs to support .remove() implementation Vidya Sagar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=beef4f7f-e6e5-4735-7847-c04e608d54d5@nvidia.com \
    --to=vidyas@nvidia.com \
    --cc=Jisheng.Zhang@synaptics.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=kishon@ti.com \
    --cc=kthota@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mmaddireddy@nvidia.com \
    --cc=sagar.tv@gmail.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox