Subject: Re: [PATCH 2/3] aqc111: fix writing to the phy on BE

From: Oliver Neukum <[email-masked]>
Date: Tue, 14 May 2019 15:14:04 +0200

On Di, 2019-05-14 at 12:11 +0000, Igor Russkikh wrote:
> On 09.05.2019 12:08, Oliver Neukum wrote:
> > When writing to the phy on BE architectures an internal data structure
> > was directly given, leading to it being byte swapped in the wrong
> > way for the CPU in 50% of all cases. A temporary buffer must be used.
> > 
> > Signed-off-by: Oliver Neukum <[email-masked]>
> > ---
> >  drivers/net/usb/aqc111.c | 23 +++++++++++++++++------
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
> > index 408df2d335e3..599d560a8450 100644
> > --- a/drivers/net/usb/aqc111.c
> > +++ b/drivers/net/usb/aqc111.c
> > @@ -320,6 +320,7 @@ static int aqc111_get_link_ksettings(struct net_device *net,
> >  static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
> >  {
> >  	struct aqc111_data *aqc111_data = dev->driver_priv;
> > +	u32 phy_on_the_wire;
> >  
> >  	aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
> >  	aqc111_data->phy_cfg |= AQ_PAUSE;
> > @@ -361,7 +362,8 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
> >  		}
> >  	}
> >  
> > -	aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg);
> > +	phy_on_the_wire = aqc111_data->phy_cfg;
> > +	aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &phy_on_the_wire);
> 
> Hi Oliver,
> 
> I see all write32_cmd and write16_cmd are using a temporary variable to do an
> internal cpu_to_le32. Why this extra temporary storage is needed?
> 
> The question is actually for both 2nd and third patch.
> In all the cases BE machine will store temporary bswap conversion in tmp
> variable and will not actually touch actual field.

Hi,

I am most terribly sorry. I overlooked the copy. Shall I revert or will
you.

	Sorry
		Oliver