regmap: only call custom reg_update_bits() if reg is marked volatile
Subsystems (4)
PATCH 1/2 regmap: only call custom reg_update_bits() if reg is marked volatile
From: Jon Ringle <[email protected]>
The only time that it makes sense to call a custom provided reg_update_bits function, is the register being updated is one that has volatile bits. Otherwise, the normal read/modify/write cycle (where the read is likely to be free from the cache) will do just fine. This should keep the reg cache intact, since volatile registers won't get cached anyway.
---
This patch is being submitted because
"[PATCH net-next v2 1/2] regmap: Allow installing custom reg_update_bits function" was applied to net-next prematurely (there was a v3 patch out for review).
This is a diff between the v2 and v3.
Thanks,
Jon
drivers/base/regmap/internal.h | 3 +-- drivers/base/regmap/regmap.c | 48 +++++++++++++----------------------------- include/linux/regmap.h | 3 +-- 3 files changed, 17 insertions(+), 37 deletions(-)
drivers/base/regmap/internal.h +1 -2
@@ -99,8 +99,7 @@ struct regmap {int (*reg_read)(void *context,unsigned int reg,unsigned int *val);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, -bool *change,bool force_write); +unsigned int mask,unsigned int val);bool defer_caching;
drivers/base/regmap/regmap.c +15 -33
59 lines not on this page · raw message
include/linux/regmap.h +1 -2
@@ -297,8 +297,7 @@ typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,typedef int (*regmap_hw_reg_write )(void *context,unsigned int reg,unsigned int val);typedef int (*regmap_hw_reg_update_bits )(void *context,unsigned int reg, -unsigned int mask,unsigned int val, -bool *change,bool force_write); +unsigned int mask,unsigned int val);typedef struct regmap_async *(*regmap_hw_async_alloc )(void );typedef void (*regmap_hw_free_context )(void *context);
Signature · 1 line
2.4.1
PATCH 2/2 net: encx24j600: Simplified regmap_encx24j600_reg_update_bits()
From: Jon Ringle <[email protected]>
The changes to _regmap_update_bits() to call a custom reg_update_bits() function simplify the function signature and also don't need to deal with registers that can't individual bit updates via the hardware. The normal flow of _regmap_update_bits() will take care of doing read/modify/write cycle for any register not marked as volatile.
---
This patch is being submitted because
"[PATCH net-next v3 2/2] net: Microchip encx24j600 driver"
was applied to net-next prematurely (there was a v3 patch out for review).
This is a diff between the v2 and v3.
Thanks,
Jon
drivers/net/ethernet/microchip/encx24j600-regmap.c | 56 ++++------------------ 1 file changed, 9 insertions(+), 47 deletions(-)
drivers/net/ethernet/microchip/encx24j600-regmap.c +9 -47
@@ -191,8 +191,7 @@ static int regmap_encx24j600_sfr_clr_bits(struct encx24j600_context *ctx,static int regmap_encx24j600_reg_update_bits (void *context,unsigned int reg,unsigned int mask, -unsigned int val,bool *change, -bool force_write) +unsigned int val) {struct encx24j600_context *ctx = context;
@@ -200,61 +199,24 @@ static int regmap_encx24j600_reg_update_bits(void *context, unsigned int reg,unsigned int set_mask = mask & val;unsigned int clr_mask = mask & ~val; -if (change) - *change = false; - -if ((reg >=0x40 && reg <0x6c ) || reg >=0x80 ) { -/* Must do read/modify/write cycles for -* MAC/MII regs or Unbanked SFR regs -*/ -u16 tmp, orig; - - ret =regmap_encx24j600_sfr_read (context, reg, (u8 *)&orig, -sizeof (orig)); -if (ret !=0 ) -return ret; - - tmp = orig & ~mask; - tmp |= val & mask; - -if (force_write || (tmp != orig)) { - ret =regmap_encx24j600_sfr_write (context, reg, - (u8 *)&tmp, -sizeof (tmp)); -if (change) - *change = true; - }else if (change) { - *change = false; - } - -return ret; - } +if ((reg >=0x40 && reg <0x6c ) || reg >=0x80 ) +return -EINVAL ; -if (set_mask &0xff ) { +if (set_mask &0xff ) ret =regmap_encx24j600_sfr_set_bits (ctx, reg, set_mask); -if (ret ==0 && change) - *change = true; - } + set_mask = (set_mask &0xff00 ) >>8 ; -if ((set_mask &0xff ) && (ret ==0 )) { +if ((set_mask &0xff ) && (ret ==0 )) ret =regmap_encx24j600_sfr_set_bits (ctx, reg +1 , set_mask); -if (ret ==0 && change) - *change = true; - } -if ((clr_mask &0xff ) && (ret ==0 )) { +if ((clr_mask &0xff ) && (ret ==0 )) ret =regmap_encx24j600_sfr_clr_bits (ctx, reg, clr_mask); -if (ret ==0 && change) - *change = true; - } + clr_mask = (clr_mask &0xff00 ) >>8 ; -if ((clr_mask &0xff ) && (ret ==0 )) { +if ((clr_mask &0xff ) && (ret ==0 )) ret =regmap_encx24j600_sfr_clr_bits (ctx, reg +1 , clr_mask); -if (ret ==0 && change) - *change = true; - }return ret; }
Signature · 1 line
2.4.1
Mark Brown
maintainerQuoted 7 lines · On Mon, Oct 05, 2015 at 09:29:31AM -0400, [email protected] wrote:
From: Jon Ringle <[email protected]>
The only time that it makes sense to call a custom provided
reg_update_bitsfunction, is the register being updated is one that has volatile bits. Otherwise, the normal read/modify/write cycle (where the read is likely to be free from the cache) will do just fine. This should keep the reg cache intact, since volatile registers won't get cached anyway.
Dave, to be clear please do *not* apply this patch at least for the time being - I've not reviewed it or the one from Thursday that you applied this morning.
David Miller
maintainerFrom: Mark Brown <[email protected]>
Date: Mon, 5 Oct 2015 15:57:22 +0100
Quoted 9 lines · On Mon, Oct 05, 2015 at 09:29:31AM -0400, [email protected] wrote:
Quoted 7 lines
From: Jon Ringle <[email protected]>
The only time that it makes sense to call a custom provided
reg_update_bitsfunction, is the register being updated is one that has volatile bits. Otherwise, the normal read/modify/write cycle (where the read is likely to be free from the cache) will do just fine. This should keep the reg cache intact, since volatile registers won't get cached anyway.
Quoted 3 lines
Dave, to be clear please do *not* apply this patch at least for the time being - I've not reviewed it or the one from Thursday that you applied this morning.
It's applied, it's pushed out to my tree, and therefore this will need to be fixed up with a relative patch of some sort.
What you don't seem to understand is that my GIT tree is never rebased or mangled because many people depend upon it. So once a patch is applied, that commit lives on forever.
Mark Brown
maintainerQuoted 8 lines · David Miller
From: Mark Brown <[email protected]>
Quoted 3 lines
Dave, to be clear please do *not* apply this patch at least for the time being - I've not reviewed it or the one from Thursday that you applied this morning.
It's applied, it's pushed out to my tree, and therefore this will need to be fixed up with a relative patch of some sort.
This appears to be an incremental change, not the initial commit which you already applied. I'm asking you to stop applying changes to regmap which have not been reviewed.
Quoted 3 lines
What you don't seem to understand is that my GIT tree is never rebased or mangled because many people depend upon it. So once a patch is applied, that commit lives on forever.
I'm not *so* concerned if the patch lives in history, I'm concerned with having something I can sensibly review and ideally getting the code into my tree.
Quoted 17 lines · Mark Brown
Quoted 10 lines · David Miller
From: Mark Brown <[email protected]>
Quoted 3 lines
Dave, to be clear please do *not* apply this patch at least for the time being - I've not reviewed it or the one from Thursday that you applied this morning.
It's applied, it's pushed out to my tree, and therefore this will need to be fixed up with a relative patch of some sort.
This appears to be an incremental change, not the initial commit which you already applied. I'm asking you to stop applying changes to regmap which have not been reviewed.
Quoted 7 lines
Quoted 3 lines
What you don't seem to understand is that my GIT tree is never rebased or mangled because many people depend upon it. So once a patch is applied, that commit lives on forever.
I'm not *so* concerned if the patch lives in history, I'm concerned with having something I can sensibly review and ideally getting the code into my tree.
I would suggest the following course of action:
1) David, revert the following from net-next:
$ git revert 9886ce2b9d4e5a8bb3d78d0f7eff3c0f1ed58d67 $ git revert 04fbfce7a222327b97ca165294ef19f0faa45960 $ git revert 7741c373cf3ea1f5383fa97fb7a640a429d3dd7c
2) Mark, please use the patch titled "[PATCH net-next v3 1/2] regmap:
Allow installing custom". It will apply cleanly to the regmap for-next branch
3) Once Mark has accepted this patch into the regmap tree, I will make any adjustments needed to the net-next patch.
4) David should then merge the regmap for-next branch into net-next
5) I will submit a new patch to net-next for the encx24j600 driver that should build against the regmap changes
Sound like a good plan?
-Jon
David Miller
maintainerFrom: Jon Ringle <[email protected]>
Date: Tue, 6 Oct 2015 08:50:43 -0400
Quoted 1 line
4) David should then merge the regmap for-next branch into net-next
Nope, this doesn't work at all.
It is my tree which people depend upon, not the other way around.
From: Jon Ringle <[email protected]>
Date: Tue, 6 Oct 2015 08:50:43 -0400
Quoted 4 lines
1) David, revert the following from net-next:
$ git revert 9886ce2b9d4e5a8bb3d78d0f7eff3c0f1ed58d67 $ git revert 04fbfce7a222327b97ca165294ef19f0faa45960 $ git revert 7741c373cf3ea1f5383fa97fb7a640a429d3dd7c
Applied, thanks.
Mark Brown
maintainerQuoted 1 line · Jon Ringle
4) David should then merge the regmap for-next branch into net-next
What I generally do (and what's best practice in general for cross tree work) is apply patches on topic branches and then create a signed tag for anything that's being merged into another tree. That both means we've got a signed tag for the chain of trust in the code and means that only the specific dependency gets pulled into other trees rather than everything that's queued. Minimising what's pulled in makes pull requests look cleaner and avoids noise from in development code appearing in other trees (eg, any bugs in other code that's not quite ready won't get merged).
In my specific trees nobody should ever merge my for-FOO branches, they're rebuilt frequently - the topic branches are fast forward only and intended for that (though like I say a signed tag is best). Linus complains about keeping the for-FOO branches fast forward only.
Quoted 4 lines
5) I will submit a new patch to net-next for the encx24j600 driver that should build against the regmap changes
Sound like a good plan?
Makes sense to me modulo the signed tag thing above.
Mark Brown
maintainerQuoted 5 lines · David Miller
Quoted 1 line
4) David should then merge the regmap for-next branch into net-next
Nope, this doesn't work at all.
It is my tree which people depend upon, not the other way around.
Yes, it does work - this is the way we normally handle cross tree issues. There is nothing about pulling code from other trees into your tree which will stop other people depending on your tree, obviously anything you merge in needs to stay fast forward only and ideally not make any resulting pull requests look terrible but that's really the only restriction.