RE: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint
From: Frank Li
Date: Thu Oct 27 2022 - 10:36:05 EST
> -----Original Message-----
> From: Shunsuke Mie <mie@xxxxxxxxxx>
> Sent: Wednesday, October 26, 2022 8:43 PM
> To: Frank Li <frank.li@xxxxxxx>
> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>; Jon
> Mason <jdmason@xxxxxxxx>; Dave Jiang <dave.jiang@xxxxxxxxx>; Allen
> Hubbe <allenbh@xxxxxxxxx>; Kishon Vijay Abraham I <kishon@xxxxxx>;
> Lorenzo Pieralisi <lpieralisi@xxxxxxxxxx>; Krzysztof Wilczyński
> <kw@xxxxxxxxx>; Bjorn Helgaas <bhelgaas@xxxxxxxxxx>;
> ntb@xxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> 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 <frank.li@xxxxxxx>:
> >
> >
> >
> > > -----Original Message-----
> > > From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> > > Sent: Tuesday, October 25, 2022 9:22 AM
> > > To: Shunsuke Mie <mie@xxxxxxxxxx>
> > > Cc: Jon Mason <jdmason@xxxxxxxx>; Dave Jiang <dave.jiang@xxxxxxxxx>;
> > > Allen Hubbe <allenbh@xxxxxxxxx>; Kishon Vijay Abraham I
> > > <kishon@xxxxxx>; Lorenzo Pieralisi <lpieralisi@xxxxxxxxxx>; Krzysztof
> > > Wilczyński <kw@xxxxxxxxx>; Bjorn Helgaas <bhelgaas@xxxxxxxxxx>;
> > > ntb@xxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx
> > > Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for
> no
> > > epc alignment constraint
> > >
> > > Caution: EXT Email
> > >
> > > On Thu, Sep 22, 2022 at 06:23:57PM +0900, Shunsuke Mie wrote:
> > > > 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.
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?
>
> > > > epf_ntb_config_spad_bar_alloc() doesn't work well. Check for this
> before
> > > > IS_ALIGNED().
> > > >
> > > > Signed-off-by: Shunsuke Mie <mie@xxxxxxxxxx>
> > >
> > > Reviewed-by: Manivannan Sadhasivam
> > > <manivannan.sadhasivam@xxxxxxxxxx>
> > >
> > > Thanks,
> > > Mani
> > >
> > > > ---
> > > > 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(-)
> > > >
> > > > 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