regmap: Add bulk read/write callbacks into regmap_config
Subsystems (6)
RFC PATCH 1/2 regmap: Add bulk read/write callbacks into regmap_config
Currently the regmap_config structure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks. The regmap_bus already implements bulk counterparts of both, and is being misused as a workaround for the missing bulk read/write callbacks in regmap_config by a couple of drivers. To stop this misuse, add the bulk read/write callbacks to regmap_config and call them from the regmap core code.
--- drivers/base/regmap/internal.h | 4 ++ drivers/base/regmap/regmap.c | 76 ++++++++++++++++++---------------- include/linux/regmap.h | 12 ++++++ 3 files changed, 56 insertions(+), 36 deletions(-)
drivers/base/regmap/internal.h +4 -0
@@ -110,6 +110,10 @@ struct regmap {int (*reg_write)(void *context,unsigned int reg,unsigned int val);int (*reg_update_bits)(void *context,unsigned int reg,unsigned int mask,unsigned int val); +/* Bulk read/write */ +int (*read)(void *context,const void *reg_buf,size_t reg_size, +void *val_buf,size_t val_size); +int (*write)(void *context,const void *data,size_t count);bool defer_caching;
drivers/base/regmap/regmap.c +40 -36
194 lines not on this page · raw message
include/linux/regmap.h +12 -0
@@ -299,6 +299,12 @@ typedef void (*regmap_unlock)(void *);* if the function require special handling with lock and reg * handling and the operation cannot be represented as a simple * update_bits operation on a bus such as SPI, I2C, etc. +* @read: Optional callback that if filled will be used to perform all the +* bulk reads from the registers. Data is returned in the buffer used +* to transmit data. +* @write: Same as above for writing. +* @max_raw_read: Max raw read size that can be used on the device. +* @max_raw_write: Max raw write size that can be used on the device. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex * to perform locking. This field is ignored if custom lock/unlock * functions are used (see fields lock/unlock of struct regmap_config).
@@ -385,6 +391,12 @@ struct regmap_config {int (*reg_write)(void *context,unsigned int reg,unsigned int val);int (*reg_update_bits)(void *context,unsigned int reg,unsigned int mask,unsigned int val); +/* Bulk read/write */ +int (*read)(void *context,const void *reg_buf,size_t reg_size, +void *val_buf,size_t val_size); +int (*write)(void *context,const void *data,size_t count); +size_t max_raw_read; +size_t max_raw_write;bool fast_io;
Signature · 1 line
2.35.1
RFC PATCH 2/2 drm: bridge: icn6211: Convert to regmap_config bulk read/write
Instead of working around the missing bulk register read/write in regmap_config using regmap_bus callbacks, switch to new regmap_config read/write callbacks.
--- drivers/gpu/drm/bridge/chipone-icn6211.c | 38 ++++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/chipone-icn6211.c +22 -16
@@ -181,15 +181,6 @@ static const struct regmap_access_table chipone_dsi_writeable_table = { .n_yes_ranges = ARRAY_SIZE(chipone_dsi_writeable_ranges), }; -static const struct regmap_config chipone_regmap_config = { - .reg_bits =8 , - .val_bits =8 , - .rd_table = &chipone_dsi_readable_table, - .wr_table = &chipone_dsi_writeable_table, - .cache_type =REGCACHE_RBTREE , - .max_register =MIPI_ATE_STATUS (1 ), -}; -static int chipone_dsi_read (void *context,const void *reg,size_t reg_size,void *val,size_t val_size)
@@ -210,11 +201,26 @@ static int chipone_dsi_write(void *context, const void *data, size_t count)return mipi_dsi_generic_write (dsi, data,2 ); } -static const struct regmap_bus chipone_dsi_regmap_bus = { - .read = chipone_dsi_read, - .write = chipone_dsi_write, - .reg_format_endian_default =REGMAP_ENDIAN_NATIVE , - .val_format_endian_default =REGMAP_ENDIAN_NATIVE , +static const struct regmap_config chipone_regmap_config = { + .name ="chipone-i2c" , + .reg_bits =8 , + .val_bits =8 , + .rd_table = &chipone_dsi_readable_table, + .wr_table = &chipone_dsi_writeable_table, + .cache_type =REGCACHE_RBTREE , + .max_register =MIPI_ATE_STATUS (1 ), +}; + +static const struct regmap_config chipone_dsi_regmap_config = { + .name ="chipone-dsi" , + .reg_bits =8 , + .val_bits =8 , + .rd_table = &chipone_dsi_readable_table, + .wr_table = &chipone_dsi_writeable_table, + .cache_type =REGCACHE_RBTREE , + .max_register =MIPI_ATE_STATUS (1 ), + .read = chipone_dsi_read, + .write = chipone_dsi_write, };static inline struct chipone *bridge_to_chipone (struct drm_bridge *bridge)
@@ -691,8 +697,8 @@ static int chipone_dsi_probe(struct mipi_dsi_device *dsi)if (ret)return ret; - icn->regmap =devm_regmap_init (dev, &chipone_dsi_regmap_bus, - dsi, &chipone_regmap_config); + icn->regmap =devm_regmap_init (dev,NULL , + dsi, &chipone_dsi_regmap_config);if (IS_ERR (icn->regmap))return PTR_ERR (icn->regmap);
Signature · 1 line
2.35.1
Mark Brown
maintainerRe: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
In reply to Marek VasutQuoted 9 lines · Marek Vasut
Currently the
regmap_configstructure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks. Theregmap_busalready implements bulk counterparts of both, and is being misused as a workaround for the missing bulk read/write callbacks inregmap_configby a couple of drivers. To stop this misuse, add the bulk read/write callbacks toregmap_configand call them from the regmap core code.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/2] regmap: Add bulk read/write callbacks into regmap_config
commit: d77e745613680c54708470402e2b623dcd769681
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
Re: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 11 lines · Mark Brown
Quoted 9 lines · Marek Vasut
Currently the
regmap_configstructure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks. Theregmap_busalready implements bulk counterparts of both, and is being misused as a workaround for the missing bulk read/write callbacks inregmap_configby a couple of drivers. To stop this misuse, add the bulk read/write callbacks toregmap_configand call them from the regmap core code.[...]
Quoted 8 lines
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/2] regmap: Add bulk read/write callbacks into
regmap_configcommit: d77e745613680c54708470402e2b623dcd769681
I was really hoping this would get a lot more review / comments before this is applied.
Mark Brown
maintainerRe: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 11 lines · Marek Vasut
Quoted 7 lines · Mark Brown
Quoted 2 lines · Marek Vasut
Currently the
regmap_configstructure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks.[1/2] regmap: Add bulk read/write callbacks into
regmap_configcommit: d77e745613680c54708470402e2b623dcd769681I was really hoping this would get a lot more review / comments before this is applied.
I can easily punt for this release, though TBH I'm not anticipating huge numbers of comments on a regmap patch unless it breaks things for people, they tend to be very quiet. I did go through it and didn't spot any issues so it seemed like the testing coverage would be useful here. Are there specific things you're worried about that you'd like feedback on?
Re: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 10 lines · Mark Brown
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Mark Brown
Quoted 2 lines · Marek Vasut
Currently the
regmap_configstructure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks.[1/2] regmap: Add bulk read/write callbacks into
regmap_configcommit: d77e745613680c54708470402e2b623dcd769681
Quoted 6 lines
Quoted 2 lines
I was really hoping this would get a lot more review / comments before this is applied.
I can easily punt for this release, though TBH I'm not anticipating huge numbers of comments on a regmap patch unless it breaks things for people, they tend to be very quiet.
In that case, let's wait and see ...
Quoted 4 lines
I did go through it and didn't spot
any issues so it seemed like the testing coverage would be useful here. Are there specific things you're worried about that you'd like feedback on?
Plumbing on core code is worrying.
Mark Brown
maintainerRe: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 8 lines · Marek Vasut
Quoted 4 lines · Mark Brown
I did go through it and didn't spot
any issues so it seemed like the testing coverage would be useful here. Are there specific things you're worried about that you'd like feedback on?Plumbing on core code is worrying.
Yeah, that's a big part of why I want things in testing. With something like this a lot of it is being aware of all the random corner cases out there.
Re: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
In reply to Mark BrownQuoted 10 lines · Mark Brown
Quoted 9 lines · Marek Vasut
Currently the
regmap_configstructure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks. Theregmap_busalready implements bulk counterparts of both, and is being misused as a workaround for the missing bulk read/write callbacks inregmap_configby a couple of drivers. To stop this misuse, add the bulk read/write callbacks toregmap_configand call them from the regmap core code.[...]
Hey Mark, sorry for hijacking the thread a bit. regmap.h seems to have comprehensive API documentation, but there's very little in terms of higher level documentation that I could find. Is there any?
I've been toying with the idea of adding a regmap based interface for accessing Display Port DPCD registers, with caching, and regmap seems like it's got the kitchen sink but I find it a bit difficult to navigate...
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Mark Brown
maintainerRe: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 3 lines · Jani Nikula
Hey Mark, sorry for hijacking the thread a bit.
regmap.hseems to have comprehensive API documentation, but there's very little in terms of higher level documentation that I could find. Is there any?
Not outside of the source. I did a presentation at ELC-E ages ago which you can probably find but I'm not sure how much it would add.
Quoted 4 lines
I've been toying with the idea of adding a regmap based interface for accessing Display Port DPCD registers, with caching, and regmap seems like it's got the kitchen sink but I find it a bit difficult to navigate...
The bus code is generally very thin so you shouldn't need to worry about what the core is up to much if you just want to support some bus. If this is a bus that has registers at hardware level then looking at something like regmap-sdw.c should be helpful, for something that's just a bit stream at the bus level then something like regmap-i3c.c is a simple example.
Re: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 9 lines · Mark Brown
Quoted 3 lines · Jani Nikula
Hey Mark, sorry for hijacking the thread a bit.
regmap.hseems to have comprehensive API documentation, but there's very little in terms of higher level documentation that I could find. Is there any?Not outside of the source. I did a presentation at ELC-E ages ago which you can probably find but I'm not sure how much it would add.
I watched that one!
Anyway no recording, but I think I've found the pdf. Was in 2012 apparently.
https://elinux.org/images/a/a3/Regmap-_The_Power_of_Subsystems_and_Abstractions.pdf
Cheers, Daniel
Quoted 12 lines
Quoted 5 lines
I've been toying with the idea of adding a regmap based interface for accessing Display Port DPCD registers, with caching, and regmap seems like it's got the kitchen sink but I find it a bit difficult to navigate...
The bus code is generally very thin so you shouldn't need to worry about what the core is up to much if you just want to support some bus. If this is a bus that has registers at hardware level then looking at something like
regmap-sdw.cshould be helpful, for something that's just a bit stream at the bus level then something likeregmap-i3c.cis a simple example.
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Mark Brown
maintainerRe: (subset) [PATCH 1/2] [RFC] regmap: Add bulk read/write callbacks into regmap_config
Quoted 7 lines · Daniel Vetter
Quoted 3 lines · Mark Brown
Not outside of the source. I did a presentation at ELC-E ages ago which you can probably find but I'm not sure how much it would add.
I watched that one!
I'm so sorry.
Quoted 4 lines
Anyway no recording, but I think I've found the pdf. Was in 2012 apparently.
https://elinux.org/images/a/a3/Regmap-_The_Power_of_Subsystems_and_Abstractions.pdf
That's the one I was thinking of, yes!