The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread()
@ 2024-09-25  8:27 Andy Shevchenko
  2024-09-25  8:55 ` Matti Vaittinen
  2024-10-01 11:13 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-09-25  8:27 UTC (permalink / raw)
  To: Matti Vaittinen, linux-kernel
  Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki,
	Andy Shevchenko

The commit 4d60cac951fd ("regmap-irq: Add no_status support") adds
an additional branch into IRQ thread handler in regmap. It wisely
chose to use memset32() as it might be optimised on some architectures
and hence give a performance benefit. At the same time the old code
continue using simple memset(). Update the old code to use memset32().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap-irq.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index a750e48a26b8..33ec28e3a802 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -364,14 +364,11 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		memset32(data->status_buf, GENMASK(31, 0), chip->num_regs);
 	} else if (chip->num_main_regs) {
 		unsigned int max_main_bits;
-		unsigned long size;
-
-		size = chip->num_regs * sizeof(unsigned int);
 
 		max_main_bits = (chip->num_main_status_bits) ?
 				 chip->num_main_status_bits : chip->num_regs;
 		/* Clear the status buf as we don't read all status regs */
-		memset(data->status_buf, 0, size);
+		memset32(data->status_buf, 0, chip->num_regs);
 
 		/* We could support bulk read for main status registers
 		 * but I don't expect to see devices with really many main
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread()
  2024-09-25  8:27 [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread() Andy Shevchenko
@ 2024-09-25  8:55 ` Matti Vaittinen
  2024-09-25  9:02   ` Andy Shevchenko
  2024-10-01 11:13 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Matti Vaittinen @ 2024-09-25  8:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki

On 9/25/24 11:27, Andy Shevchenko wrote:
> The commit 4d60cac951fd ("regmap-irq: Add no_status support") adds
> an additional branch into IRQ thread handler in regmap. It wisely
> chose to use memset32() as it might be optimised on some architectures
> and hence give a performance benefit. At the same time the old code
> continue using simple memset(). Update the old code to use memset32().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/base/regmap/regmap-irq.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
> index a750e48a26b8..33ec28e3a802 100644
> --- a/drivers/base/regmap/regmap-irq.c
> +++ b/drivers/base/regmap/regmap-irq.c
> @@ -364,14 +364,11 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
>   		memset32(data->status_buf, GENMASK(31, 0), chip->num_regs);
>   	} else if (chip->num_main_regs) {
>   		unsigned int max_main_bits;
> -		unsigned long size;
> -
> -		size = chip->num_regs * sizeof(unsigned int);
>   
>   		max_main_bits = (chip->num_main_status_bits) ?
>   				 chip->num_main_status_bits : chip->num_regs;
>   		/* Clear the status buf as we don't read all status regs */
> -		memset(data->status_buf, 0, size);
> +		memset32(data->status_buf, 0, chip->num_regs);
>   
>   		/* We could support bulk read for main status registers
>   		 * but I don't expect to see devices with really many main

Thanks Andy.

Can we guarantee the sizeof(unsigned int) == sizeof(uint32_t) on all 
supported architectures? (The status_buf is unsigned int, right?). If 
yes, then this looks nice to me.

Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread()
  2024-09-25  8:55 ` Matti Vaittinen
@ 2024-09-25  9:02   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-09-25  9:02 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: linux-kernel, Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki

On Wed, Sep 25, 2024 at 11:55:51AM +0300, Matti Vaittinen wrote:
> On 9/25/24 11:27, Andy Shevchenko wrote:

...

> >   		memset32(data->status_buf, GENMASK(31, 0), chip->num_regs);

> > -		memset(data->status_buf, 0, size);
> > +		memset32(data->status_buf, 0, chip->num_regs);

> Can we guarantee the sizeof(unsigned int) == sizeof(uint32_t) on all
> supported architectures? (The status_buf is unsigned int, right?). If yes,
> then this looks nice to me.

Yes as long as we (Linux kernel) support only 32-bit and higher architectures.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread()
  2024-09-25  8:27 [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread() Andy Shevchenko
  2024-09-25  8:55 ` Matti Vaittinen
@ 2024-10-01 11:13 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-10-01 11:13 UTC (permalink / raw)
  To: Matti Vaittinen, linux-kernel, Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki

On Wed, 25 Sep 2024 11:27:26 +0300, Andy Shevchenko wrote:
> The commit 4d60cac951fd ("regmap-irq: Add no_status support") adds
> an additional branch into IRQ thread handler in regmap. It wisely
> chose to use memset32() as it might be optimised on some architectures
> and hence give a performance benefit. At the same time the old code
> continue using simple memset(). Update the old code to use memset32().
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread()
      commit: 21e9a1dd01b17095192ea86decc0c2081451612e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-01 11:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25  8:27 [PATCH v1 1/1] regmap-irq: Consistently use memset32() in regmap_irq_thread() Andy Shevchenko
2024-09-25  8:55 ` Matti Vaittinen
2024-09-25  9:02   ` Andy Shevchenko
2024-10-01 11:13 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox