Skip to contentSkip to conversation

PCI: endpoint: Improve pci_epc_ops::align_addr() interface

PATCH In review Damien Le Moal 4 participants 7 messages Oct 15, 2024 – Nov 2, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: endpoint: Improve pci_epc_ops::align_addr() interface

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

---
Changes from v1:
- Also updated the type of the pci_addr and map_pci_addr fields of struct pci_epc_map.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 6 +++---
 include/linux/pci-epc.h                         | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +3 -3
index 0ada60487c25..df1460ed63d9 100644
@@ -268,12 +268,12 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
 	return -EINVAL;
 }
 
-static phys_addr_t dw_pcie_ep_align_addr(struct pci_epc *epc,
-			phys_addr_t pci_addr, size_t *pci_size, size_t *offset)
+static u64 dw_pcie_ep_align_addr(struct pci_epc *epc, u64 pci_addr,
+				 size_t *pci_size, size_t *offset)
 {
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-	phys_addr_t mask = pci->region_align - 1;
+	u64 mask = pci->region_align - 1;
 	size_t ofst = pci_addr & mask;
 
 	*pci_size = ALIGN(ofst + *pci_size, ep->page_size);
include/linux/pci-epc.h +4 -4
index f4b8dc37e447..de8cc3658220 100644
@@ -49,10 +49,10 @@ pci_epc_interface_string(enum pci_epc_interface_type type)
  * @virt_addr: virtual address at which @pci_addr is mapped
  */
 struct pci_epc_map {
-	phys_addr_t	pci_addr;
+	u64		pci_addr;
 	size_t		pci_size;
 
-	phys_addr_t	map_pci_addr;
+	u64		map_pci_addr;
 	size_t		map_size;
 
 	phys_addr_t	phys_base;
@@ -93,8 +93,8 @@ struct pci_epc_ops {
 			   struct pci_epf_bar *epf_bar);
 	void	(*clear_bar)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			     struct pci_epf_bar *epf_bar);
-	phys_addr_t (*align_addr)(struct pci_epc *epc, phys_addr_t pci_addr,
-				  size_t *size, size_t *offset);
+	u64	(*align_addr)(struct pci_epc *epc, u64 pci_addr, size_t *size,
+			      size_t *offset);
 	int	(*map_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			    phys_addr_t addr, u64 pci_addr, size_t size);
 	void	(*unmap_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
Signature · 1 line
2.47.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 72 lines · Damien Le Moal

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

---
Changes from v1:
- Also updated the type of the pci_addr and map_pci_addr fields of struct pci_epc_map.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 6 +++---
 include/linux/pci-epc.h                         | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +3 -3
index 0ada60487c25..df1460ed63d9 100644
@@ -268,12 +268,12 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
 	return -EINVAL;
 }
 
-static phys_addr_t dw_pcie_ep_align_addr(struct pci_epc *epc,
-			phys_addr_t pci_addr, size_t *pci_size, size_t *offset)
+static u64 dw_pcie_ep_align_addr(struct pci_epc *epc, u64 pci_addr,
+				 size_t *pci_size, size_t *offset)
 {
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-	phys_addr_t mask = pci->region_align - 1;
+	u64 mask = pci->region_align - 1;
 	size_t ofst = pci_addr & mask;
 
 	*pci_size = ALIGN(ofst + *pci_size, ep->page_size);
include/linux/pci-epc.h +4 -4
index f4b8dc37e447..de8cc3658220 100644
@@ -49,10 +49,10 @@ pci_epc_interface_string(enum pci_epc_interface_type type)
  * @virt_addr: virtual address at which @pci_addr is mapped
  */
 struct pci_epc_map {
-	phys_addr_t	pci_addr;
+	u64		pci_addr;
 	size_t		pci_size;
 
-	phys_addr_t	map_pci_addr;
+	u64		map_pci_addr;
 	size_t		map_size;
 
 	phys_addr_t	phys_base;
@@ -93,8 +93,8 @@ struct pci_epc_ops {
 			   struct pci_epf_bar *epf_bar);
 	void	(*clear_bar)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			     struct pci_epf_bar *epf_bar);
-	phys_addr_t (*align_addr)(struct pci_epc *epc, phys_addr_t pci_addr,
-				  size_t *size, size_t *offset);
+	u64	(*align_addr)(struct pci_epc *epc, u64 pci_addr, size_t *size,
+			      size_t *offset);
 	int	(*map_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			    phys_addr_t addr, u64 pci_addr, size_t size);
 	void	(*unmap_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
Signature · 1 line
2.47.0
Reviewed-by on v2 1/1
#2 lore raw
In reply to Damien Le Moal
Quoted 9 lines · Damien Le Moal

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Quoted 3 lines
Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

- Mani

Quoted 60 lines

---
Changes from v1:
- Also updated the type of the pci_addr and map_pci_addr fields of struct pci_epc_map.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 6 +++---
 include/linux/pci-epc.h                         | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +3 -3
index 0ada60487c25..df1460ed63d9 100644
@@ -268,12 +268,12 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
 	return -EINVAL;
 }
 
-static phys_addr_t dw_pcie_ep_align_addr(struct pci_epc *epc,
-			phys_addr_t pci_addr, size_t *pci_size, size_t *offset)
+static u64 dw_pcie_ep_align_addr(struct pci_epc *epc, u64 pci_addr,
+				 size_t *pci_size, size_t *offset)
 {
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-	phys_addr_t mask = pci->region_align - 1;
+	u64 mask = pci->region_align - 1;
 	size_t ofst = pci_addr & mask;
 
 	*pci_size = ALIGN(ofst + *pci_size, ep->page_size);
include/linux/pci-epc.h +4 -4
index f4b8dc37e447..de8cc3658220 100644
@@ -49,10 +49,10 @@ pci_epc_interface_string(enum pci_epc_interface_type type)
  * @virt_addr: virtual address at which @pci_addr is mapped
  */
 struct pci_epc_map {
-	phys_addr_t	pci_addr;
+	u64		pci_addr;
 	size_t		pci_size;
 
-	phys_addr_t	map_pci_addr;
+	u64		map_pci_addr;
 	size_t		map_size;
 
 	phys_addr_t	phys_base;
@@ -93,8 +93,8 @@ struct pci_epc_ops {
 			   struct pci_epf_bar *epf_bar);
 	void	(*clear_bar)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			     struct pci_epf_bar *epf_bar);
-	phys_addr_t (*align_addr)(struct pci_epc *epc, phys_addr_t pci_addr,
-				  size_t *size, size_t *offset);
+	u64	(*align_addr)(struct pci_epc *epc, u64 pci_addr, size_t *size,
+			      size_t *offset);
 	int	(*map_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			    phys_addr_t addr, u64 pci_addr, size_t size);
 	void	(*unmap_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
Signature · 1 line
2.47.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
In reply to Damien Le Moal
Quoted 9 lines · Damien Le Moal

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Quoted 3 lines
Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

I thought of applying it, but then decided to squash it with the offending patches.

- Mani

Quoted 60 lines

---
Changes from v1:
- Also updated the type of the pci_addr and map_pci_addr fields of struct pci_epc_map.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 6 +++---
 include/linux/pci-epc.h                         | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +3 -3
index 0ada60487c25..df1460ed63d9 100644
@@ -268,12 +268,12 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
 	return -EINVAL;
 }
 
-static phys_addr_t dw_pcie_ep_align_addr(struct pci_epc *epc,
-			phys_addr_t pci_addr, size_t *pci_size, size_t *offset)
+static u64 dw_pcie_ep_align_addr(struct pci_epc *epc, u64 pci_addr,
+				 size_t *pci_size, size_t *offset)
 {
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-	phys_addr_t mask = pci->region_align - 1;
+	u64 mask = pci->region_align - 1;
 	size_t ofst = pci_addr & mask;
 
 	*pci_size = ALIGN(ofst + *pci_size, ep->page_size);
include/linux/pci-epc.h +4 -4
index f4b8dc37e447..de8cc3658220 100644
@@ -49,10 +49,10 @@ pci_epc_interface_string(enum pci_epc_interface_type type)
  * @virt_addr: virtual address at which @pci_addr is mapped
  */
 struct pci_epc_map {
-	phys_addr_t	pci_addr;
+	u64		pci_addr;
 	size_t		pci_size;
 
-	phys_addr_t	map_pci_addr;
+	u64		map_pci_addr;
 	size_t		map_size;
 
 	phys_addr_t	phys_base;
@@ -93,8 +93,8 @@ struct pci_epc_ops {
 			   struct pci_epf_bar *epf_bar);
 	void	(*clear_bar)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			     struct pci_epf_bar *epf_bar);
-	phys_addr_t (*align_addr)(struct pci_epc *epc, phys_addr_t pci_addr,
-				  size_t *size, size_t *offset);
+	u64	(*align_addr)(struct pci_epc *epc, u64 pci_addr, size_t *size,
+			      size_t *offset);
 	int	(*map_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 			    phys_addr_t addr, u64 pci_addr, size_t size);
 	void	(*unmap_addr)(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
Signature · 1 line
2.47.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#4 lore raw
Quoted 10 lines · Manivannan Sadhasivam
Quoted 9 lines · Damien Le Moal

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Quoted 6 lines
Quoted 3 lines
Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

I thought of applying it, but then decided to squash it with the offending patches.

Fine with me. Thanks !

Signature · 2 lines
Damien Le Moal
Western Digital Research
#5 lore raw
Quoted 11 lines · Damien Le Moal
Quoted 10 lines · Manivannan Sadhasivam
Quoted 9 lines · Damien Le Moal

The PCI endpoint controller operation interface for the align_addr() operation uses the phys_addr_t type for the PCI address argument and return a value using this type. This is not ideal as PCI addresses are bus addresses, not regular memory physical addresses. Replace the use of phys_addr_t for this operation with the generic u64 type. To be consistent with this change the Designware driver implementation of this operation (function dw_pcie_ep_align_addr()) as well as the type of PCI address fields of struct pci_epc_map are also changed.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Fixes e98c99e2ccad ("PCI: endpoint: Introduce pci_epc_mem_map()/unmap()")
Fixes cb6b7158fdf5 ("PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation")

I thought of applying it, but then decided to squash it with the offending patches.

Fine with me. Thanks !

Just checked the pci/endpoint branch but I do not see this patch squashed there. Did you push the change ?

Signature · 2 lines
Damien Le Moal
Western Digital Research
#6 lore raw

Hello,

[...]

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I thought of applying it, but then decided to squash it with the offending patches.

Fine with me. Thanks !

Just checked the pci/endpoint branch but I do not see this patch squashed there.

If you so happen to check using the Git web interface kernel.org, then there is some sort of a caching going on that can return old results for a while before the cache expires.

Quoted 1 line

Did you push the change ?

Looks like changes are there.

Krzysztof