All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ben Wolsieffer <ben.wolsieffer@hefring.com>
Cc: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Ben Whitten <ben.whitten@gmail.com>
Subject: Re: [PATCH] regmap: prevent noinc writes from clobbering cache
Date: Wed, 1 Nov 2023 19:06:34 +0100	[thread overview]
Message-ID: <2023110124-semisoft-negligee-aea1@gregkh> (raw)
In-Reply-To: <20231101142926.2722603-2-ben.wolsieffer@hefring.com>

On Wed, Nov 01, 2023 at 10:29:27AM -0400, Ben Wolsieffer wrote:
> Currently, noinc writes are cached as if they were standard incrementing
> writes, overwriting unrelated register values in the cache. Instead, we
> want to cache the last value written to the register, as is done in the
> accelerated noinc handler (regmap_noinc_readwrite).
> 
> Fixes: cdf6b11daa77 ("regmap: Add regmap_noinc_write API")
> Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
> ---
>  drivers/base/regmap/regmap.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 234a84ecde8b..ea6157747199 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -1620,17 +1620,19 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
>  	}
>  
>  	if (!map->cache_bypass && map->format.parse_val) {
> -		unsigned int ival;
> +		unsigned int ival, offset;
>  		int val_bytes = map->format.val_bytes;
> -		for (i = 0; i < val_len / val_bytes; i++) {
> -			ival = map->format.parse_val(val + (i * val_bytes));
> -			ret = regcache_write(map,
> -					     reg + regmap_get_offset(map, i),
> -					     ival);
> +
> +		/* Cache the last written value for noinc writes */
> +		i = noinc ? val_len - val_bytes : 0;
> +		for (; i < val_len; i += val_bytes) {
> +			ival = map->format.parse_val(val + i);
> +			offset = noinc ? 0 : regmap_get_offset(map, i / val_bytes);
> +			ret = regcache_write(map, reg + offset, ival);
>  			if (ret) {
>  				dev_err(map->dev,
>  					"Error in caching of register: %x ret: %d\n",
> -					reg + regmap_get_offset(map, i), ret);
> +					reg + offset, ret);
>  				return ret;
>  			}
>  		}
> -- 
> 2.42.0
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

  parent reply	other threads:[~2023-11-01 18:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 14:29 [PATCH] regmap: prevent noinc writes from clobbering cache Ben Wolsieffer
2023-11-01 17:05 ` Mark Brown
2023-11-01 20:20   ` Ben Wolsieffer
2023-11-01 20:24     ` Mark Brown
2023-11-01 18:06 ` Greg Kroah-Hartman [this message]
2023-11-02 11:52 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023110124-semisoft-negligee-aea1@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=ben.whitten@gmail.com \
    --cc=ben.wolsieffer@hefring.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.