linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: lpieralisi@kernel.org, kw@linux.com, kishon@kernel.org,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2 2/7] PCI: epf-mhi: Make use of the alignment restriction from EPF core
Date: Sat, 26 Aug 2023 20:16:15 +0530	[thread overview]
Message-ID: <20230826144615.GA8858@thinkpad> (raw)
In-Reply-To: <20230825225006.GA642059@bhelgaas>

On Fri, Aug 25, 2023 at 05:50:06PM -0500, Bjorn Helgaas wrote:
> On Mon, Jul 17, 2023 at 12:24:54PM +0530, Manivannan Sadhasivam wrote:
> > Instead of hardcoding the alignment restriction in the EPF_MHI driver, make
> > use of the info available from the EPF core that reflects the alignment
> > restriction of the endpoint controller.
> > 
> > For this purpose, let's introduce the get_align_offset() static function.
> 
> I thought this might be related to the [1/7] patch since they both
> mention an alignment restriction in the EPF core, but [1/7] sets
> pci_epc_features.align and this patch doesn't reference .align, so
> this must be a different alignment restriction?
> 
> I'm sure there's nothing wrong here, and this is already applied, so
> no need to do anything unless .align *should* appear here.
> 

You are absolutely right! The patch was intented to make use of "align" but
"page_size" was used as per old revision. Even though this patch works (because
both "page_size" and "align" were 4K in my setup), it should be fixed.

I will send a fix up patch now. Thanks for spotting.

- Mani

> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  drivers/pci/endpoint/functions/pci-epf-mhi.c | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> > index 9c1f5a154fbd..bb7de6884824 100644
> > --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
> > +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> > @@ -102,6 +102,11 @@ struct pci_epf_mhi {
> >  	int irq;
> >  };
> >  
> > +static size_t get_align_offset(struct pci_epc *epc, u64 addr)
> > +{
> > +	return addr % epc->mem->window.page_size;
> > +}
> > +
> >  static int __pci_epf_mhi_alloc_map(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
> >  				 phys_addr_t *paddr, void __iomem **vaddr,
> >  				 size_t offset, size_t size)
> > @@ -134,7 +139,7 @@ static int pci_epf_mhi_alloc_map(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
> >  {
> >  	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> >  	struct pci_epc *epc = epf_mhi->epf->epc;
> > -	size_t offset = pci_addr & (epc->mem->window.page_size - 1);
> > +	size_t offset = get_align_offset(epc, pci_addr);
> >  
> >  	return __pci_epf_mhi_alloc_map(mhi_cntrl, pci_addr, paddr, vaddr,
> >  				      offset, size);
> > @@ -161,7 +166,7 @@ static void pci_epf_mhi_unmap_free(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
> >  	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> >  	struct pci_epf *epf = epf_mhi->epf;
> >  	struct pci_epc *epc = epf->epc;
> > -	size_t offset = pci_addr & (epc->mem->window.page_size - 1);
> > +	size_t offset = get_align_offset(epc, pci_addr);
> >  
> >  	__pci_epf_mhi_unmap_free(mhi_cntrl, pci_addr, paddr, vaddr, offset,
> >  				 size);
> > @@ -185,7 +190,8 @@ static int pci_epf_mhi_read_from_host(struct mhi_ep_cntrl *mhi_cntrl, u64 from,
> >  				      void *to, size_t size)
> >  {
> >  	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> > -	size_t offset = from % SZ_4K;
> > +	struct pci_epc *epc = epf_mhi->epf->epc;
> > +	size_t offset = get_align_offset(epc, from);
> >  	void __iomem *tre_buf;
> >  	phys_addr_t tre_phys;
> >  	int ret;
> > @@ -213,7 +219,8 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
> >  				     void *from, u64 to, size_t size)
> >  {
> >  	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> > -	size_t offset = to % SZ_4K;
> > +	struct pci_epc *epc = epf_mhi->epf->epc;
> > +	size_t offset = get_align_offset(epc, to);
> >  	void __iomem *tre_buf;
> >  	phys_addr_t tre_phys;
> >  	int ret;
> > -- 
> > 2.25.1
> > 

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2023-08-26 14:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17  6:54 [PATCH v2 0/7] Improvements to Qcom PCIe EP and EPF MHI drivers Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 1/7] PCI: qcom-ep: Pass alignment restriction to the EPF core Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 2/7] PCI: epf-mhi: Make use of the alignment restriction from " Manivannan Sadhasivam
2023-08-25 22:50   ` Bjorn Helgaas
2023-08-26 14:46     ` Manivannan Sadhasivam [this message]
2023-07-17  6:54 ` [PATCH v2 3/7] PCI: qcom-ep: Add eDMA support Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 4/7] PCI: epf-mhi: " Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 5/7] PCI: epf-mhi: Add support for SM8450 Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 6/7] PCI: epf-mhi: Use iATU for small transfers Manivannan Sadhasivam
2023-07-17  6:54 ` [PATCH v2 7/7] PCI: endpoint: Add kernel-doc for pci_epc_mem_init() API Manivannan Sadhasivam
2023-07-17  7:04   ` Randy Dunlap
2023-08-25 18:28 ` [PATCH v2 0/7] Improvements to Qcom PCIe EP and EPF MHI drivers Krzysztof Wilczyński

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=20230826144615.GA8858@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).