* [PATCH] PCI: epf-mhi: Really use "align" from EPF core
@ 2023-08-26 15:06 Manivannan Sadhasivam
2023-08-26 15:34 ` Krzysztof Wilczyński
0 siblings, 1 reply; 2+ messages in thread
From: Manivannan Sadhasivam @ 2023-08-26 15:06 UTC (permalink / raw)
To: lpieralisi, kw
Cc: kishon, bhelgaas, linux-pci, linux-kernel, linux-arm-msm,
Manivannan Sadhasivam
Commit <15fe2e279c19> was supposed to make use of "align" parameter from
the EPF core, but it incorrectly used the outbound window "page_size".
Fix it!
Fixes: 15fe2e279c19 ("PCI: epf-mhi: Make use of the alignment restriction from EPF core")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/pci/endpoint/functions/pci-epf-mhi.c | 22 ++++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
index bb7de6884824..bb4669eafcca 100644
--- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
+++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
@@ -92,6 +92,7 @@ static const struct pci_epf_mhi_ep_info sdx55_info = {
};
struct pci_epf_mhi {
+ const struct pci_epc_features *epc_features;
const struct pci_epf_mhi_ep_info *info;
struct mhi_ep_cntrl mhi_cntrl;
struct pci_epf *epf;
@@ -102,9 +103,9 @@ struct pci_epf_mhi {
int irq;
};
-static size_t get_align_offset(struct pci_epc *epc, u64 addr)
+static size_t get_align_offset(struct pci_epf_mhi *epf_mhi, u64 addr)
{
- return addr % epc->mem->window.page_size;
+ return addr % epf_mhi->epc_features->align;
}
static int __pci_epf_mhi_alloc_map(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
@@ -138,8 +139,7 @@ static int pci_epf_mhi_alloc_map(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
size_t size)
{
struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
- struct pci_epc *epc = epf_mhi->epf->epc;
- size_t offset = get_align_offset(epc, pci_addr);
+ size_t offset = get_align_offset(epf_mhi, pci_addr);
return __pci_epf_mhi_alloc_map(mhi_cntrl, pci_addr, paddr, vaddr,
offset, size);
@@ -164,9 +164,7 @@ static void pci_epf_mhi_unmap_free(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
size_t size)
{
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 = get_align_offset(epc, pci_addr);
+ size_t offset = get_align_offset(epf_mhi, pci_addr);
__pci_epf_mhi_unmap_free(mhi_cntrl, pci_addr, paddr, vaddr, offset,
size);
@@ -190,8 +188,7 @@ 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);
- struct pci_epc *epc = epf_mhi->epf->epc;
- size_t offset = get_align_offset(epc, from);
+ size_t offset = get_align_offset(epf_mhi, from);
void __iomem *tre_buf;
phys_addr_t tre_phys;
int ret;
@@ -219,8 +216,7 @@ 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);
- struct pci_epc *epc = epf_mhi->epf->epc;
- size_t offset = get_align_offset(epc, to);
+ size_t offset = get_align_offset(epf_mhi, to);
void __iomem *tre_buf;
phys_addr_t tre_phys;
int ret;
@@ -277,6 +273,10 @@ static int pci_epf_mhi_core_init(struct pci_epf *epf)
return ret;
}
+ epf_mhi->epc_features = pci_epc_get_features(epc, epf->func_no, epf->vfunc_no);
+ if (!epf_mhi->epc_features)
+ return -ENODATA;
+
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: epf-mhi: Really use "align" from EPF core
2023-08-26 15:06 [PATCH] PCI: epf-mhi: Really use "align" from EPF core Manivannan Sadhasivam
@ 2023-08-26 15:34 ` Krzysztof Wilczyński
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Wilczyński @ 2023-08-26 15:34 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: lpieralisi, kishon, bhelgaas, linux-pci, linux-kernel,
linux-arm-msm
Hello,
> Commit <15fe2e279c19> was supposed to make use of "align" parameter from
> the EPF core, but it incorrectly used the outbound window "page_size".
> Fix it!
Thank you! Much appreciated.
I will apply and squash this against the patches I recently applied.
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-26 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-26 15:06 [PATCH] PCI: epf-mhi: Really use "align" from EPF core Manivannan Sadhasivam
2023-08-26 15:34 ` Krzysztof Wilczyński
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).