Skip to contentSkip to conversation

PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

PATCH In review Shunsuke Mie 3 participants 10 messages Sep 22, 2022 – Oct 28, 2022

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

PATCH v2 1/1 PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this before IS_ALIGNED().

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
index 9a00448c7e61..f74155ee8d72 100644
@@ -1021,7 +1021,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb,
 	peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
 	/* Check if epc_features is populated incorrectly */
-	if ((!IS_ALIGNED(size, align)))
+	if (align && (!IS_ALIGNED(size, align)))
 		return -EINVAL;
 
 	spad_count = ntb->spad_count;
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
index 0ea85e1d292e..5e346c0a0f05 100644
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb)
 	size = epc_features->bar_fixed_size[barno];
 	align = epc_features->align;
 
-	if ((!IS_ALIGNED(size, align)))
+	if (align && !IS_ALIGNED(size, align))
 		return -EINVAL;
 
 	spad_count = ntb->spad_count;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this before IS_ALIGNED().

Thanks,
Mani

Quoted 38 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
index 9a00448c7e61..f74155ee8d72 100644
@@ -1021,7 +1021,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb,
 	peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
 	/* Check if epc_features is populated incorrectly */
-	if ((!IS_ALIGNED(size, align)))
+	if (align && (!IS_ALIGNED(size, align)))
 		return -EINVAL;
 
 	spad_count = ntb->spad_count;
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
index 0ea85e1d292e..5e346c0a0f05 100644
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb)
 	size = epc_features->bar_fixed_size[barno];
 	align = epc_features->align;
 
-	if ((!IS_ALIGNED(size, align)))
+	if (align && !IS_ALIGNED(size, align))
 		return -EINVAL;
 
 	spad_count = ntb->spad_count;
Signature · 1 line
2.17.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Quoted 5 lines

Caution: EXT Email

Quoted 2 lines · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

Quoted 56 lines
Quoted 4 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this before IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Review

Quoted 10 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb,

Review

Quoted 9 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb)

Quoted 11 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -2
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
--

2.17.1

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

#3 lore raw

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 15 lines
Quoted 15 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Quoted 8 lines
Quoted 5 lines

Caution: EXT Email

Quoted 2 lines · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

Quoted 49 lines
Quoted 49 lines
Quoted 4 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this before IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Review

Quoted 10 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb,

Review

Quoted 9 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb)

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -1
      spad_count = ntb->spad_count;
--

2.17.1

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

Best,
Shunsuke

#4 lore raw
Quoted 43 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 12 lines
Quoted 12 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for

no

Quoted 8 lines
Quoted 7 lines

epc alignment constraint

Caution: EXT Email

Quoted 2 lines · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in

Quoted 7 lines
Quoted 2 lines

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

I think it should be based on what original term defined. It should be fixed at where make mistake.

Are there other place use align == 0 means no alignment in kernel?

Quoted 62 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 23 lines
Quoted 23 lines

epf_ntb *ntb,

Review

Quoted 9 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb)

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -1
      spad_count = ntb->spad_count;
--

2.17.1

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

Best,
Shunsuke

#5 lore raw
Quoted 45 lines · Frank Li
Quoted 45 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 12 lines
Quoted 12 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for

no

Quoted 10 lines
Quoted 7 lines

epc alignment constraint

Caution: EXT Email

Quoted 2 lines · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

Quoted 9 lines
Quoted 5 lines

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

I think it should be based on what original term defined. It should be fixed at where make mistake.

1byte is the default alignment that drivers can assume, why do you want drivers to set them explicitly when they do not want any special alignment?

I think this patch is fine.

Thanks,
Mani

Quoted 64 lines

Are there other place use align == 0 means no alignment in kernel?

Quoted 62 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 23 lines
Quoted 23 lines

epf_ntb *ntb,

Review

Quoted 9 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int epf_ntb_config_spad_bar_alloc(struct

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct

epf_ntb *ntb)

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -1
      spad_count = ntb->spad_count;
--

2.17.1

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

Best,
Shunsuke

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#6 lore raw
Quoted 74 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 10:12 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

Quoted 12 lines · Frank Li
Quoted 12 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 10 lines
Quoted 10 lines

no epc alignment constraint

Caution: EXT Email

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 3 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang

<[email protected]>;

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 7 lines
Quoted 7 lines

no

Quoted 6 lines
Quoted 6 lines

epc alignment constraint

Caution: EXT Email

Quoted 1 line · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and

the

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

Quoted 7 lines
Quoted 3 lines

I think it should be based on what original term defined. It should be fixed at where make mistake.

1byte is the default alignment that drivers can assume, why do you want drivers
to set them explicitly when they do not want any special alignment?

What's definition of not alignment by align variable? Using both 0 and 1 as no alignment is not good enough.

I grep whole kernel driver directory, not one use

	If (align && IS_ALIGNED(x, align))  statement.    

There are a common convention, align is 2^n

Quoted 74 lines

I think this patch is fine.

Thanks,
Mani

Quoted 39 lines

Are there other place use align == 0 means no alignment in kernel?

Quoted 37 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 8 lines
Quoted 8 lines

epf_ntb *ntb,

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 2 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

epf_ntb *ntb)

Quoted 11 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -2
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
--

2.17.1

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

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

Best,
Shunsuke

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

#7 lore raw

[Added Kishon's new email address and removed the old one]

Quoted 82 lines · Frank Li
Quoted 74 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 10:12 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

Quoted 12 lines · Frank Li
Quoted 12 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 10 lines
Quoted 10 lines

no epc alignment constraint

Caution: EXT Email

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 3 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang

<[email protected]>;

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 7 lines
Quoted 7 lines

no

Quoted 6 lines
Quoted 6 lines

epc alignment constraint

Caution: EXT Email

Quoted 1 line · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints, and

the

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

Quoted 7 lines
Quoted 3 lines

I think it should be based on what original term defined. It should be fixed at where make mistake.

1byte is the default alignment that drivers can assume, why do you want drivers
to set them explicitly when they do not want any special alignment?

Quoted 5 lines

What's definition of not alignment by align variable? Using both 0 and 1 as no alignment is not good enough.

I grep whole kernel driver directory, not one use

	If (align && IS_ALIGNED(x, align))  statement.    

I can see multiple hits:

lib/ubsan.c
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_vma.c
drivers/nvdimm/pfn_devs.c
drivers/misc/pci_endpoint_test.c

But in most of the places, the alignment is guaranteed to be set by the client drivers because they might be read from the hardware register or fixed for an IP. But in this case, I don't think we should _force_ the drivers to set alignment to 1 (default) if they don't really care about it.

Thanks,
Mani

Quoted 78 lines

There are a common convention, align is 2^n

Quoted 74 lines

I think this patch is fine.

Thanks,
Mani

Quoted 39 lines

Are there other place use align == 0 means no alignment in kernel?

Quoted 37 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 8 lines
Quoted 8 lines

epf_ntb *ntb,

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 2 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

epf_ntb *ntb)

Quoted 11 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -2
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
--

2.17.1

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

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

Best,
Shunsuke

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

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#8 lore raw
Quoted 128 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 11:10 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; [email protected]; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

[Added Kishon's new email address and removed the old one]

Quoted 7 lines · Frank Li
Quoted 7 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 10:12 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>;

Dave

Quoted 1 line
Quoted 1 line

Jiang <[email protected]>; Allen Hubbe <[email protected]>;

Kishon

Quoted 1 line
Quoted 1 line

Vijay Abraham I <[email protected]>; Lorenzo Pieralisi

<[email protected]>;

Quoted 4 lines
Quoted 4 lines

Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 4 lines
Quoted 4 lines

no epc alignment constraint

Caution: EXT Email

Quoted 8 lines
Quoted 8 lines · Frank Li
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>;

Jon

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Mason <[email protected]>; Dave Jiang <[email protected]>;

Allen

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Hubbe <[email protected]>; Kishon Vijay Abraham I

<[email protected]>;

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a

check

Quoted 5 lines
Quoted 5 lines

for

Quoted 4 lines
Quoted 4 lines

no epc alignment constraint

Caution: EXT Email

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Manivannan Sadhasivam

<[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang

<[email protected]>;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>;

Krzysztof

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Wilczyński <[email protected]>; Bjorn Helgaas

<[email protected]>;

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a

check

Quoted 8 lines
Quoted 8 lines

for

Quoted 7 lines
Quoted 7 lines

no

Quoted 6 lines
Quoted 6 lines

epc alignment constraint

Caution: EXT Email

Quoted 1 line · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints,

and

Quoted 19 lines
Quoted 11 lines

the

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

Quoted 7 lines
Quoted 3 lines

I think it should be based on what original term defined. It should be fixed at where make mistake.

1byte is the default alignment that drivers can assume, why do you want drivers
to set them explicitly when they do not want any special alignment?

Quoted 5 lines

What's definition of not alignment by align variable? Using both 0 and 1 as no alignment is not good enough.

I grep whole kernel driver directory, not one use

      If (align && IS_ALIGNED(x, align))  statement.

I can see multiple hits:

lib/ubsan.c
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_vma.c
drivers/nvdimm/pfn_devs.c
drivers/misc/pci_endpoint_test.c

Quoted 5 lines

But in most of the places, the alignment is guaranteed to be set by the client drivers because they might be read from the hardware register or fixed for an
IP. But in this case, I don't think we should _force_ the drivers to set alignment to 1 (default) if they don't really care about it.

I keep my opinion. I think EP controller have not reported correct data. Hardware register also can be set 0 as no alignment means.
It broken "align" conversion.

If most people prefer this way, I suggest change api document at Include/linux/pci-epc.h to explicitly said 0 is validate option.

Quoted 86 lines

Thanks,
Mani

Quoted 14 lines

There are a common convention, align is 2^n

Quoted 10 lines

I think this patch is fine.

Thanks,
Mani

Quoted 4 lines

Are there other place use align == 0 means no alignment in kernel?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for

this

Quoted 56 lines
Quoted 56 lines
Quoted 35 lines
Quoted 35 lines

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 8 lines
Quoted 8 lines

epf_ntb *ntb,

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 2 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

epf_ntb *ntb)

Quoted 11 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -2
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
--

2.17.1

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

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

Best,
Shunsuke

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

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

#9 lore raw

2022年10月28日(金) 1:25 Frank Li <[email protected]>:

Quoted 135 lines
Quoted 129 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 11:10 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>; Dave Jiang <[email protected]>; Allen Hubbe <[email protected]>; [email protected]; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint

Caution: EXT Email

[Added Kishon's new email address and removed the old one]

Quoted 7 lines · Frank Li
Quoted 7 lines

-----Original Message-----
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, October 27, 2022 10:12 AM
To: Frank Li <[email protected]>
Cc: Shunsuke Mie <[email protected]>; Jon Mason <[email protected]>;

Dave

Quoted 1 line
Quoted 1 line

Jiang <[email protected]>; Allen Hubbe <[email protected]>;

Kishon

Quoted 1 line
Quoted 1 line

Vijay Abraham I <[email protected]>; Lorenzo Pieralisi

<[email protected]>;

Quoted 4 lines
Quoted 4 lines

Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check

for

Quoted 4 lines
Quoted 4 lines

no epc alignment constraint

Caution: EXT Email

Quoted 8 lines
Quoted 8 lines · Frank Li
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Wednesday, October 26, 2022 8:43 PM
To: Frank Li <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>;

Jon

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Mason <[email protected]>; Dave Jiang <[email protected]>;

Allen

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Hubbe <[email protected]>; Kishon Vijay Abraham I

<[email protected]>;

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a

check

Quoted 5 lines
Quoted 5 lines

for

Quoted 4 lines
Quoted 4 lines

no epc alignment constraint

Caution: EXT Email

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hi Frank,

2022年10月26日(水) 1:07 Frank Li <[email protected]>:

Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Manivannan Sadhasivam

<[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Tuesday, October 25, 2022 9:22 AM
To: Shunsuke Mie <[email protected]>
Cc: Jon Mason <[email protected]>; Dave Jiang

<[email protected]>;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Allen Hubbe <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Lorenzo Pieralisi <[email protected]>;

Krzysztof

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Wilczyński <[email protected]>; Bjorn Helgaas

<[email protected]>;

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; linux-

[email protected]

Quoted 1 line
Quoted 1 line

Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a

check

Quoted 8 lines
Quoted 8 lines

for

Quoted 7 lines
Quoted 7 lines

no

Quoted 6 lines
Quoted 6 lines

epc alignment constraint

Caution: EXT Email

Quoted 1 line · Shunsuke Mie

Some PCI endpoint controllers have no alignment constraints,

and

Quoted 19 lines
Quoted 11 lines

the

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

epc_features->align becomes 0. In this case, IS_ALIGNED() in

[Frank Li] why not set epc_features->align 1 no alignment constraints should mean align to byte.

It is one of the solutions too I think. But in that case, we need to write epc_features->align = 1 to all epc drivers, dwc, qcom, rcar, tegra, and etc.

I think that my change is better.

Quoted 7 lines
Quoted 3 lines

I think it should be based on what original term defined. It should be fixed at where make mistake.

1byte is the default alignment that drivers can assume, why do you want drivers
to set them explicitly when they do not want any special alignment?

Quoted 5 lines

What's definition of not alignment by align variable? Using both 0 and 1 as no alignment is not good enough.

I grep whole kernel driver directory, not one use

      If (align && IS_ALIGNED(x, align))  statement.

I can see multiple hits:

lib/ubsan.c
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_vma.c
drivers/nvdimm/pfn_devs.c
drivers/misc/pci_endpoint_test.c

Quoted 5 lines

But in most of the places, the alignment is guaranteed to be set by the client drivers because they might be read from the hardware register or fixed for an
IP. But in this case, I don't think we should _force_ the drivers to set alignment to 1 (default) if they don't really care about it.

Quoted 3 lines

I keep my opinion. I think EP controller have not reported correct data. Hardware register also can be set 0 as no alignment means.
It broken "align" conversion.

It is certainly true. In addition, I don't think it is a good design for the framework to
require the same check for all ep function drivers. like this patch.

But I can't be determined, so I'm going to look into other drivers/subsystems to find a
common and better way.

Quoted 2 lines

If most people prefer this way, I suggest change api document at Include/linux/pci-epc.h to explicitly said 0 is validate option.

Yes. If we take the way, I'll add the explanation.

Quoted 78 lines
Quoted 78 lines

Thanks,
Mani

Quoted 14 lines

There are a common convention, align is 2^n

Quoted 10 lines

I think this patch is fine.

Thanks,
Mani

Quoted 4 lines

Are there other place use align == 0 means no alignment in kernel?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

epf_ntb_config_spad_bar_alloc() doesn't work well. Check for

this

Quoted 59 lines
Quoted 59 lines
Quoted 35 lines
Quoted 35 lines

before

Quoted 19 lines
Quoted 19 lines
Quoted 3 lines

IS_ALIGNED().

Reviewed-by: Manivannan Sadhasivam
<[email protected]>

Thanks,
Mani

Quoted 9 lines

---
Changes in v2:
* Fix the commit message in phrasings and words.
---

---
 drivers/pci/endpoint/functions/pci-epf-ntb.c  | 2 +-
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-ntb.c

drivers/pci/endpoint/functions/pci-epf-ntb.c static int

Quoted 4 lines

index 9a00448c7e61..f74155ee8d72 100644

drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
@@ -1021,7 +1021,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 8 lines
Quoted 8 lines

epf_ntb *ntb,

Quoted 7 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
      peer_size = peer_epc_features->bar_fixed_size[peer_barno];
 
      /* Check if epc_features is populated incorrectly */
-     if ((!IS_ALIGNED(size, align)))
+     if (align && (!IS_ALIGNED(size, align)))
              return -EINVAL;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 2 lines
drivers/pci/endpoint/functions/pci-epf-ntb.c +0 -0
      spad_count = ntb->spad_count;
(quoted diff) +0 -0

b/drivers/pci/endpoint/functions/pci-epf-vntb.c

drivers/pci/endpoint/functions/pci-epf-vntb.c static int

Quoted 4 lines

index 0ea85e1d292e..5e346c0a0f05 100644

drivers/pci/endpoint/functions/pci-epf-vntb.c +0 -0
@@ -418,7 +418,7 @@ static int

epf_ntb_config_spad_bar_alloc(struct

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines

epf_ntb *ntb)

Quoted 11 lines
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -2
      size = epc_features->bar_fixed_size[barno];
      align = epc_features->align;
 
-     if ((!IS_ALIGNED(size, align)))
+     if (align && !IS_ALIGNED(size, align))
              return -EINVAL;
 
      spad_count = ntb->spad_count;
--

2.17.1

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

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Best,
Shunsuke

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

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

Best,
Shunsuke