From 995cf0e014b0144edf1125668a97c252c5ab775e Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Fri, 24 Jan 2025 14:37:58 +0100 Subject: regmap: Reorder 'struct regmap' On a x86_64, with configured with allmodconfig, pahole states that the regmap structure is: /* size: 1048, cachelines: 17, members: 78 */ /* sum members: 1006, holes: 9, sum holes: 35 */ /* padding: 7 */ /* member types with holes: 2, total: 2 */ /* last cacheline: 24 bytes */ So, when such a struct is allocated, 2048 bytes are allocated, with most of this space being wasted. Move a few bools so that the size is reduced to 1024. After this change, pahole gives: /* size: 1024, cachelines: 16, members: 78 */ /* sum members: 1006, holes: 6, sum holes: 18 */ /* member types with holes: 2, total: 2 */ Signed-off-by: Christophe JAILLET Link: https://patch.msgid.link/f01f900d15633d5cda5f27763723acb307c0d22f.1737725820.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown --- drivers/base/regmap/internal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index bdb450436cbc..6f31240ee4a9 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -73,12 +73,12 @@ struct regmap { void *bus_context; const char *name; - bool async; spinlock_t async_lock; wait_queue_head_t async_waitq; struct list_head async_list; struct list_head async_free; int async_ret; + bool async; #ifdef CONFIG_DEBUG_FS bool debugfs_disable; @@ -117,8 +117,6 @@ struct regmap { void *val_buf, size_t val_size); int (*write)(void *context, const void *data, size_t count); - bool defer_caching; - unsigned long read_flag_mask; unsigned long write_flag_mask; @@ -127,6 +125,8 @@ struct regmap { int reg_stride; int reg_stride_order; + bool defer_caching; + /* If set, will always write field to HW. */ bool force_write_field; @@ -161,6 +161,9 @@ struct regmap { struct reg_sequence *patch; int patch_regs; + /* if set, the regmap core can sleep */ + bool can_sleep; + /* if set, converts bulk read to single read */ bool use_single_read; /* if set, converts bulk write to single write */ @@ -176,9 +179,6 @@ struct regmap { void *selector_work_buf; /* Scratch buffer used for selector */ struct hwspinlock *hwlock; - - /* if set, the regmap core can sleep */ - bool can_sleep; }; struct regcache_ops { -- cgit v1.2.3-59-g8ed1b From 153dbf4adad0082d030c30d20541df2b1af52db6 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 6 Feb 2025 21:16:30 +0200 Subject: regmap: irq: Use one way of setting all bits in the register Currently there are two ways of how we represent all bits set, i.e. UINT_MAX and GENMASK(31, 0). Use the former as the single way of doing that, which is crystal clear on how we fill the unsigned int value. Signed-off-by: Andy Shevchenko Link: https://patch.msgid.link/20250206191644.1132869-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 0bcd81389a29..e5631188d692 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -823,7 +823,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, /* Ack masked but set interrupts */ if (d->chip->no_status) { /* no status register so default to all active */ - d->status_buf[i] = GENMASK(31, 0); + d->status_buf[i] = UINT_MAX; } else { reg = d->get_irq_reg(d, d->chip->status_base, i); ret = regmap_read(map, reg, &d->status_buf[i]); -- cgit v1.2.3-59-g8ed1b