* [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint
@ 2022-09-16 7:56 Shunsuke Mie
2022-09-19 18:55 ` Bjorn Helgaas
0 siblings, 1 reply; 3+ messages in thread
From: Shunsuke Mie @ 2022-09-16 7:56 UTC (permalink / raw)
To: Jon Mason
Cc: Dave Jiang, Allen Hubbe, Kishon Vijay Abraham I,
Lorenzo Pieralisi, Krzysztof Wilczyński, Bjorn Helgaas, ntb,
linux-pci, linux-kernel, Shunsuke Mie
Some pci endpoint controllers has not alignment constraint, and the
epc_features->align becomes 0. In this case, IS_ALIGNED() in
epf_ntb_config_spad_bar_alloc() doesn't work well. So this patch adds the 0
checking before the IS_ALIGNED().
Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
---
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(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
index 9a00448c7e61..f74155ee8d72 100644
--- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
@@ -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;
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 0ea85e1d292e..5e346c0a0f05 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint
2022-09-16 7:56 [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint Shunsuke Mie
@ 2022-09-19 18:55 ` Bjorn Helgaas
2022-09-20 10:12 ` Shunsuke Mie
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2022-09-19 18:55 UTC (permalink / raw)
To: Shunsuke Mie
Cc: Jon Mason, Dave Jiang, Allen Hubbe, Kishon Vijay Abraham I,
Lorenzo Pieralisi, Krzysztof Wilczyński, Bjorn Helgaas, ntb,
linux-pci, linux-kernel
On Fri, Sep 16, 2022 at 04:56:51PM +0900, Shunsuke Mie wrote:
> Some pci endpoint controllers has not alignment constraint, and the
s/pci/PCI/
s/has not/have no/
s/constraint/constraints/
> epc_features->align becomes 0. In this case, IS_ALIGNED() in
> epf_ntb_config_spad_bar_alloc() doesn't work well. So this patch adds the 0
> checking before the IS_ALIGNED().
s/So this patch adds .../Check for this before IS_ALIGNED()/
> Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
> ---
> 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(-)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> index 9a00448c7e61..f74155ee8d72 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> @@ -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;
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index 0ea85e1d292e..5e346c0a0f05 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> @@ -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;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint
2022-09-19 18:55 ` Bjorn Helgaas
@ 2022-09-20 10:12 ` Shunsuke Mie
0 siblings, 0 replies; 3+ messages in thread
From: Shunsuke Mie @ 2022-09-20 10:12 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Jon Mason, Dave Jiang, Allen Hubbe, Kishon Vijay Abraham I,
Lorenzo Pieralisi, Krzysztof Wilczyński, Bjorn Helgaas, ntb,
linux-pci, Linux Kernel Mailing List
2022年9月20日(火) 3:55 Bjorn Helgaas <helgaas@kernel.org>:
>
> On Fri, Sep 16, 2022 at 04:56:51PM +0900, Shunsuke Mie wrote:
> > Some pci endpoint controllers has not alignment constraint, and the
>
> s/pci/PCI/
> s/has not/have no/
> s/constraint/constraints/
>
> > epc_features->align becomes 0. In this case, IS_ALIGNED() in
> > epf_ntb_config_spad_bar_alloc() doesn't work well. So this patch adds the 0
> > checking before the IS_ALIGNED().
>
> s/So this patch adds .../Check for this before IS_ALIGNED()/
Thank you. I'll fix these.
>
> > Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
> > ---
> > 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(-)
> >
> > diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> > index 9a00448c7e61..f74155ee8d72 100644
> > --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
> > +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> > @@ -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;
> > diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > index 0ea85e1d292e..5e346c0a0f05 100644
> > --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > @@ -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;
> > --
> > 2.17.1
> >
Best,
Shunsuke
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-20 10:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 7:56 [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint Shunsuke Mie
2022-09-19 18:55 ` Bjorn Helgaas
2022-09-20 10:12 ` Shunsuke Mie
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).