Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1369714pxj; Fri, 18 Jun 2021 05:50:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhdyzUuCfOReLWD46b0LwJcpBLKydFoEUB12uVn08vh4qyy9uFt3NdqZCWPREtjOW3+5S4 X-Received: by 2002:a05:6402:759:: with SMTP id p25mr4824993edy.146.1624020633643; Fri, 18 Jun 2021 05:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624020633; cv=none; d=google.com; s=arc-20160816; b=pOrX9xyRQU3RGnuvDXfL7njUhZtcam3eyHDR7HBike5ijiDl3iCIor6KH8/GAh3ZKU z0+bhhBHjYGlBuh4KdBDlNAhkbxgkOAYt4igD3w12uANTebmJU0Jh04V1xkkd4mtnCsF 9oRNM1id7UTbiipUrCUqKgRauvmlrnnFHFT/z3vgCK3YDJ5oSxrROh2h8UpljaJwB+F7 NIBWstCQ7/FiyLn+puKlJv9FFrqMLkJJZAWtps5z27aAuuPF8l3wbY6JsXFQYSWH5O5e OjUjo9GDJ8hRaF3szgBCTGiTSJMyOrm4IHDuBt0eRODgtVJJxLGBUppGRccM7LdBYu9i 5CmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qTW2DXwsHBpnCTon2YIPrmiC1kFXKo29pPoIwWYyKTs=; b=LjXE0mEHt7K+B0ZbaIQUZQ7AtjCpO+bT6AVSpvQMgS/38Hp/peZBKA/psfK7PzHKw9 3XIZ5CIN20dv9aTm7OkDhUakYmSmj5KEfq0xKdWFtOY3uOiYT2XzHOkTICSPfQu0Q9qT aXSzQdI1n5XJcLW1fR4y9wf3vGWRyQxhoWX47QXcimLWUuuUCTHs2Rb0lxhD2UNlOuXE 1/IR31MqegSkXjkryRcLxDLhjDjEYIHYV5uZwT4MsPWgxJrtliKJJGxrc7zvHPcp2i3f XVIr9nla3wC+hb0+iqveNmT8h8RKOyaycvZbbPpY7ozgXJnvGzQgr+IRnsOjowDwDkFq L/2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LYd6PeqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si8574325edv.206.2021.06.18.05.50.10; Fri, 18 Jun 2021 05:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LYd6PeqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233858AbhFRLxg (ORCPT + 99 others); Fri, 18 Jun 2021 07:53:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:42940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231849AbhFRLxf (ORCPT ); Fri, 18 Jun 2021 07:53:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D35E613D1; Fri, 18 Jun 2021 11:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624017086; bh=vYZK8vTsfVOdXVXB0QFo0w3TjJiqmtRYwcEGIkSvqjM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LYd6PeqWTWFHGNaeIbOEvY+gnFFIT9DPDjC4o+J4vRXnDy+s/ZSPE92rD11Ow1Zdh BYZlEClp6Ofp3V9nwgXCwbUKVVeY8Hm5Bu8UcLftKAfkVuOLr/lYbdIcIO/AW38S2g zY8BdirSkRHScj7xbUE0w8CxGfreapkfSgYRFEi0f84DVKlRc2fnPVjLA7cdaieqUN HS9yuH3hdz8eNVbjnIR9XepVyDH9eZjxEZr6o1OdoOlJcIZRJcqJWMpSAoUVZ3XReL XqfKbhro9e/aqacezdsgAGIl7KoodLwXRtG7MHO4ZwmaczpC5HhJXlArKHapKdsd+v t1F4SOfWaBlEg== Date: Fri, 18 Jun 2021 12:51:04 +0100 From: Mark Brown To: Srinivas Kandagatla Cc: srivasam@codeaurora.org, rafael@kernel.org, dp@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Marek Szyprowski Subject: Re: [PATCH] regmap: move readable check before accessing regcache. Message-ID: <20210618115104.GB4920@sirena.org.uk> References: <20210618113558.10046-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="z6Eq5LdranGa6ru8" Content-Disposition: inline In-Reply-To: <20210618113558.10046-1-srinivas.kandagatla@linaro.org> X-Cookie: Are you a turtle? User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --z6Eq5LdranGa6ru8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 18, 2021 at 12:35:58PM +0100, Srinivas Kandagatla wrote: > The issue that I encountered is when doing regmap_update_bits on > a write only register. In regcache path this will not do the right > thing as the register is not readable and driver which is using > regmap_update_bits will never notice that it can not do a update > bits on write only register leading to inconsistent writes and > random hardware behavior. Why will use of regmap_update_bits() mean that a driver will never notice a write failure? Shouldn't remgap_update_bits() be fixed to report any errors it isn't reporting, or the driver fixed to check=20 error codes? I really don't understand the issue you're trying to report - what is "the right thing" and what makes you believe that a driver can't do an _update_bits() on a write only but cached register? Can you specify in concrete terms what the problem is. > There seems to be missing checks in regcache_read() which is > now added by moving the orignal check in _regmap_read() before > accessing regcache. > Cc: stable@vger.kernel.org > Fixes: 5d1729e7f02f ("regmap: Incorporate the regcache core into regmap") Are you *sure* you've identified the actual issue here - nobody has seen any problems with this in the past decade? Please don't just pick a random commit for the sake of adding a Fixes tag. > @@ -2677,6 +2677,9 @@ static int _regmap_read(struct regmap *map, unsigne= d int reg, > int ret; > void *context =3D _regmap_map_get_context(map); > =20 > + if (!regmap_readable(map, reg)) > + return -EIO; > + > if (!map->cache_bypass) { > ret =3D regcache_read(map, reg, val); > if (ret =3D=3D 0) > @@ -2686,9 +2689,6 @@ static int _regmap_read(struct regmap *map, unsigne= d int reg, > if (map->cache_only) > return -EBUSY; > =20 > - if (!regmap_readable(map, reg)) > - return -EIO; > - This puts the readability check before the cache check which will break all drivers using the cache on write only registers. --z6Eq5LdranGa6ru8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmDMiKcACgkQJNaLcl1U h9DsIAf5Afd+Q+6o68mPeTQ66gkNA3M28sW18xKpTCwg4Pvb1SjI9zqnz9MoVH/0 d4iKxGR5q7xQwdteTLxsCUAFECKxPb03EGOEtMd3t/hjRau5LVs/CUKMpbig5M2w YWUbsAekvXv773+Y5E9DaXljqYaIxk9sAPog5MupiBShBlOSSaM23XQqhlrE2/Kq kpjdZzyR3q3yVcXqxjwlWtsiR5Iuzz/djnYJEprfQHDhoHCZ3hrKvGcuLvcIHScY bMJhLnRbb1C17sy3z18aPC+u0wqQqSCvLfstlc+burujEHDZWSSictoutSp4URWa yGi2EibjoNft/jCQU/0IxMssaFN9/Q== =5sp4 -----END PGP SIGNATURE----- --z6Eq5LdranGa6ru8--