diff mbox series

[RESEND] ntb_hw_switchtec: Fix ntb_mw_clear_trans returning error if size == 0

Message ID 20190710084427.7iqrhapxa7jo5v6y@yadro.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series [RESEND] ntb_hw_switchtec: Fix ntb_mw_clear_trans returning error if size == 0 | expand

Commit Message

Alexander Fomichev July 10, 2019, 8:44 a.m. UTC
ntb_mw_set_trans should work as ntb_mw_clear_trans when size == 0 and/or
addr == 0. But error in xlate_pos checking condition prevents this.
Fix the condition to make ntb_mw_clear_trans working.

Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
---
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Fomichev Jan. 22, 2020, 1:15 p.m. UTC | #1
Somehow this patch was lost. The problem is still actual.
Please, add to upstream.

On Wed, Jul 10, 2019 at 11:44:27AM +0300, Alexander Fomichev wrote:
> ntb_mw_set_trans should work as ntb_mw_clear_trans when size == 0 and/or
> addr == 0. But error in xlate_pos checking condition prevents this.
> Fix the condition to make ntb_mw_clear_trans working.
> 
> Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
>  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> index 1e2f627d3bac..19d46af19650 100644
> --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> @@ -299,7 +299,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
>  	if (widx >= switchtec_ntb_mw_count(ntb, pidx))
>  		return -EINVAL;
>  
> -	if (xlate_pos < 12)
> +	if (size != 0 && xlate_pos < 12)
>  		return -EINVAL;
>  
>  	if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {
> -- 
> 2.17.1
Alexander Fomichev March 3, 2020, 12:32 p.m. UTC | #2
Ping?

CC: Jon Mason <jdmason@kudzu.us>
CC: Dave Jiang <dave.jiang@intel.com>
CC: Allen Hubbe <allenbh@gmail.com>
CC: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
CC: Logan Gunthorpe <logang@deltatee.com>

On Wed, Jan 22, 2020 at 04:15:13PM +0300, Alexander Fomichev wrote:
> Somehow this patch was lost. The problem is still actual.
> Please, add to upstream.
> 
> On Wed, Jul 10, 2019 at 11:44:27AM +0300, Alexander Fomichev wrote:
> > ntb_mw_set_trans should work as ntb_mw_clear_trans when size == 0 and/or
> > addr == 0. But error in xlate_pos checking condition prevents this.
> > Fix the condition to make ntb_mw_clear_trans working.
> > 
> > Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
> > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> > ---
> >  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > index 1e2f627d3bac..19d46af19650 100644
> > --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > @@ -299,7 +299,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
> >  	if (widx >= switchtec_ntb_mw_count(ntb, pidx))
> >  		return -EINVAL;
> >  
> > -	if (xlate_pos < 12)
> > +	if (size != 0 && xlate_pos < 12)
> >  		return -EINVAL;
> >  
> >  	if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {
> > -- 
> > 2.17.1
> 
> -- 
> Regards,
>   Alexander
Jon Mason March 12, 2020, 11:39 p.m. UTC | #3
On Tue, Mar 3, 2020 at 7:32 AM Alexander Fomichev <fomichev.ru@gmail.com> wrote:
>
> Ping?

Sorry, I missed this somehow  :(

I just pulled it in and it should be in my github tree in the next hour or so.

Thanks,
Jon

>
> CC: Jon Mason <jdmason@kudzu.us>
> CC: Dave Jiang <dave.jiang@intel.com>
> CC: Allen Hubbe <allenbh@gmail.com>
> CC: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
> CC: Logan Gunthorpe <logang@deltatee.com>
>
> On Wed, Jan 22, 2020 at 04:15:13PM +0300, Alexander Fomichev wrote:
> > Somehow this patch was lost. The problem is still actual.
> > Please, add to upstream.
> >
> > On Wed, Jul 10, 2019 at 11:44:27AM +0300, Alexander Fomichev wrote:
> > > ntb_mw_set_trans should work as ntb_mw_clear_trans when size == 0 and/or
> > > addr == 0. But error in xlate_pos checking condition prevents this.
> > > Fix the condition to make ntb_mw_clear_trans working.
> > >
> > > Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
> > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> > > ---
> > >  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > index 1e2f627d3bac..19d46af19650 100644
> > > --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > @@ -299,7 +299,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
> > >     if (widx >= switchtec_ntb_mw_count(ntb, pidx))
> > >             return -EINVAL;
> > >
> > > -   if (xlate_pos < 12)
> > > +   if (size != 0 && xlate_pos < 12)
> > >             return -EINVAL;
> > >
> > >     if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {
> > > --
> > > 2.17.1
> >
> > --
> > Regards,
> >   Alexander
Alexander Fomichev March 13, 2020, 8:17 a.m. UTC | #4
Thank you very much.

Regards,
Alexander.

On Thu, Mar 12, 2020 at 07:39:02PM -0400, Jon Mason wrote:
> On Tue, Mar 3, 2020 at 7:32 AM Alexander Fomichev <fomichev.ru@gmail.com> wrote:
> >
> > Ping?
> 
> Sorry, I missed this somehow  :(
> 
> I just pulled it in and it should be in my github tree in the next hour or so.
> 
> Thanks,
> Jon
> 
> >
> > CC: Jon Mason <jdmason@kudzu.us>
> > CC: Dave Jiang <dave.jiang@intel.com>
> > CC: Allen Hubbe <allenbh@gmail.com>
> > CC: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
> > CC: Logan Gunthorpe <logang@deltatee.com>
> >
> > On Wed, Jan 22, 2020 at 04:15:13PM +0300, Alexander Fomichev wrote:
> > > Somehow this patch was lost. The problem is still actual.
> > > Please, add to upstream.
> > >
> > > On Wed, Jul 10, 2019 at 11:44:27AM +0300, Alexander Fomichev wrote:
> > > > ntb_mw_set_trans should work as ntb_mw_clear_trans when size == 0 and/or
> > > > addr == 0. But error in xlate_pos checking condition prevents this.
> > > > Fix the condition to make ntb_mw_clear_trans working.
> > > >
> > > > Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
> > > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> > > > ---
> > > >  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > > index 1e2f627d3bac..19d46af19650 100644
> > > > --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > > +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> > > > @@ -299,7 +299,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
> > > >     if (widx >= switchtec_ntb_mw_count(ntb, pidx))
> > > >             return -EINVAL;
> > > >
> > > > -   if (xlate_pos < 12)
> > > > +   if (size != 0 && xlate_pos < 12)
> > > >             return -EINVAL;
> > > >
> > > >     if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {
> > > > --
> > > > 2.17.1
> > >
> > > --
> > > Regards,
> > >   Alexander
diff mbox series

Patch

diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
index 1e2f627d3bac..19d46af19650 100644
--- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
+++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
@@ -299,7 +299,7 @@  static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
 	if (widx >= switchtec_ntb_mw_count(ntb, pidx))
 		return -EINVAL;
 
-	if (xlate_pos < 12)
+	if (size != 0 && xlate_pos < 12)
 		return -EINVAL;
 
 	if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {