diff mbox series

[net-next,v2,2/4] net: ipa: use upper_32_bits()

Message ID 20210318135141.583977-3-elder@linaro.org
State New
Headers show
Series net: ipa: support 32-bit targets | expand

Commit Message

Alex Elder March 18, 2021, 1:51 p.m. UTC
Use upper_32_bits() to extract the high-order 32 bits of a DMA
address.  This avoids doing a 32-position shift on a DMA address
if it happens not to be 64 bits wide.

Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Alex Elder <elder@linaro.org>

---
v2: - Switched to use the existing function, as suggested by Florian.

 drivers/net/ipa/gsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.27.0

Comments

Florian Fainelli March 18, 2021, 4:03 p.m. UTC | #1
On 3/18/2021 6:51 AM, Alex Elder wrote:
> Use upper_32_bits() to extract the high-order 32 bits of a DMA

> address.  This avoids doing a 32-position shift on a DMA address

> if it happens not to be 64 bits wide.

> 

> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>

> Signed-off-by: Alex Elder <elder@linaro.org>

> ---

> v2: - Switched to use the existing function, as suggested by Florian.

> 

>  drivers/net/ipa/gsi.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c

> index 2119367b93ea9..82c5a0d431ee5 100644

> --- a/drivers/net/ipa/gsi.c

> +++ b/drivers/net/ipa/gsi.c

> @@ -711,7 +711,7 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id)

>  	val = evt_ring->ring.addr & GENMASK(31, 0);


Did you want to introduce another patch to use lower_32_bits() for the
assignment above?

>  	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_2_OFFSET(evt_ring_id));

>  

> -	val = evt_ring->ring.addr >> 32;

> +	val = upper_32_bits(evt_ring->ring.addr);

>  	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_3_OFFSET(evt_ring_id));

>  

>  	/* Enable interrupt moderation by setting the moderation delay */

> @@ -819,7 +819,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)

>  	val = channel->tre_ring.addr & GENMASK(31, 0);


And likewise?

>  	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));

>  

> -	val = channel->tre_ring.addr >> 32;

> +	val = upper_32_bits(channel->tre_ring.addr);

>  	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));

>  

>  	/* Command channel gets low weighted round-robin priority */

> 


-- 
Florian
Alex Elder March 18, 2021, 4:24 p.m. UTC | #2
On 3/18/21 11:03 AM, Florian Fainelli wrote:
> 

> 

> On 3/18/2021 6:51 AM, Alex Elder wrote:

>> Use upper_32_bits() to extract the high-order 32 bits of a DMA

>> address.  This avoids doing a 32-position shift on a DMA address

>> if it happens not to be 64 bits wide.

>>

>> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>

>> Signed-off-by: Alex Elder <elder@linaro.org>

>> ---

>> v2: - Switched to use the existing function, as suggested by Florian.

>>

>>   drivers/net/ipa/gsi.c | 4 ++--

>>   1 file changed, 2 insertions(+), 2 deletions(-)

>>

>> diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c

>> index 2119367b93ea9..82c5a0d431ee5 100644

>> --- a/drivers/net/ipa/gsi.c

>> +++ b/drivers/net/ipa/gsi.c

>> @@ -711,7 +711,7 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id)

>>   	val = evt_ring->ring.addr & GENMASK(31, 0);

> 

> Did you want to introduce another patch to use lower_32_bits() for the

> assignment above?


Bah... Yes, I should have done that.  I was really just
focused on the new function I created and didn't need
to.   I'll do as you suggest.

I'll also see if I do that anywhere else in the driver
and will use these functions as well if appropriate.

I'll do so in the same patch 2 of version 3.

Thanks Florian.

					-Alex

> 

>>   	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_2_OFFSET(evt_ring_id));

>>   

>> -	val = evt_ring->ring.addr >> 32;

>> +	val = upper_32_bits(evt_ring->ring.addr);

>>   	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_3_OFFSET(evt_ring_id));

>>   

>>   	/* Enable interrupt moderation by setting the moderation delay */

>> @@ -819,7 +819,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)

>>   	val = channel->tre_ring.addr & GENMASK(31, 0);

> 

> And likewise?

> 

>>   	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));

>>   

>> -	val = channel->tre_ring.addr >> 32;

>> +	val = upper_32_bits(channel->tre_ring.addr);

>>   	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));

>>   

>>   	/* Command channel gets low weighted round-robin priority */

>>

>
diff mbox series

Patch

diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
index 2119367b93ea9..82c5a0d431ee5 100644
--- a/drivers/net/ipa/gsi.c
+++ b/drivers/net/ipa/gsi.c
@@ -711,7 +711,7 @@  static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id)
 	val = evt_ring->ring.addr & GENMASK(31, 0);
 	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_2_OFFSET(evt_ring_id));
 
-	val = evt_ring->ring.addr >> 32;
+	val = upper_32_bits(evt_ring->ring.addr);
 	iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_3_OFFSET(evt_ring_id));
 
 	/* Enable interrupt moderation by setting the moderation delay */
@@ -819,7 +819,7 @@  static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
 	val = channel->tre_ring.addr & GENMASK(31, 0);
 	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));
 
-	val = channel->tre_ring.addr >> 32;
+	val = upper_32_bits(channel->tre_ring.addr);
 	iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
 
 	/* Command channel gets low weighted round-robin priority */