Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6921319rwr; Tue, 25 Apr 2023 05:59:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bug++/+WbwVmXIV4iYLAdj0JlocECjy0OnJq+iBtzif7OKkpgNKHFULSXvhsxLWT8nQeeh X-Received: by 2002:a05:6a20:3d28:b0:cb:8d74:112e with SMTP id y40-20020a056a203d2800b000cb8d74112emr19255352pzi.45.1682427598817; Tue, 25 Apr 2023 05:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682427598; cv=none; d=google.com; s=arc-20160816; b=aDCfUYh0NWAGM5GnR5wxN1byghPj3bDjW6M5iQMlh7Lk+lyTqboqZ/2wPIGQMkFK6N 8WeLrgdqX5jMh8Bs17P5Uc4VxubyNBEG0Vw6DMwSqJs7wOEZ2bXw35ICaV6dwdYvchHI vcDR+DJS5Vmr+gsFjshTEqRciuDucVQGj3z3lSho37E9hyDEq1ZSi+P2Eiq+Uy9KFifP bOx40u7EcvIB4a31q/o7RlFkxnSoaePLmKRUmZiVZBeQ6UE3Jx8Q4RLrkZYtOCETBvYJ 4Fr26/pm8z48Nnhv77f0y75SjTLYUx5qQBLbpD5J48s6iWa0E+pbZ0p0An6lU9W/aZNB f7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pIykU0ZHrypg6vk16EkPn3Zb2Mie0dPrsvF87f5aH7E=; b=TJk1CM6QGaxMH1iKV8zkml6Zppw4ov2jOaxMvNpEltb4DNuBqfcHr6/CtztcdZm8zs 300i6NYdlaarTyorKB8/er4hCL7ALDqUPofaMDfVgDMbIAg2+9/NhSs41EPKc7XuGwpb cYiq/xt6Jup5uIIlONPthYYF3harZfKxrQvD/wsyUMXFoggu49jEOyLxs2uqjL07R2EQ jefjHfmwy5BYtbDgR/lzmRyPKcU62I3ow5QdcY1GGqHa8tu3yOB341I3M1b1Gk3J0O77 BNv6hTBzw9xf9x60RGXuzjmcw38dLah+oePOi2wtPMV6/mBfLzYlpyobTwRVzsUjAiVP NquQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bz9CkJDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a63c14d000000b005138de75d17si13666565pgi.116.2023.04.25.05.59.44; Tue, 25 Apr 2023 05:59:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bz9CkJDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233991AbjDYM4b (ORCPT + 99 others); Tue, 25 Apr 2023 08:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233800AbjDYM4a (ORCPT ); Tue, 25 Apr 2023 08:56:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 389A9D30E for ; Tue, 25 Apr 2023 05:56:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C7EA5616A0 for ; Tue, 25 Apr 2023 12:56:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64233C433D2; Tue, 25 Apr 2023 12:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682427388; bh=WFqdsbjQA1vnRQupRN+CqeKWDQbtJsSTLh4Q8kWeiBY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bz9CkJDJSSNnCzcLYr28xns7faj4QIsO0/JpqjpFPybCvR88QDD5j6cVHVCMduRWE qf6hs8GOuZuERt3CYLMkuFUdYdNSqK1MhsOfD4jekuQ4XpOFnzeGfes4t0WdWDTxOP FcboqPS4mh0pUHGUjxUqTN6MOi+mY9ikW4Fb31W17hqis8fP6sqYmNvyOfsEdCrFq7 x26VQQ/oOZP8PcfahKaQfu1VKmWwA7p+DDE2Yr+c6ZjGA4OxfFTXINMQQ3F3ue8rR5 udrnVlW4bPrT9l0HssFu7ho6WRq+TjawmRs0ZTRHqANAsWxPDNXloIlxkjHmeeB8Ss B2tCqTyQgERsQ== Date: Tue, 25 Apr 2023 13:56:23 +0100 From: Mark Brown To: Colin Foster Cc: Maxime Chevallier , Greg Kroah-Hartman , "Rafael J . Wysocki" , Lee Jones , linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, alexis.lothore@bootlin.com Subject: Re: [PATCH] regmap: don't check for alignment when using reg_shift Message-ID: References: <20230420150617.381922-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="DiFt6ZB+CLaQPege" Content-Disposition: inline In-Reply-To: X-Cookie: The meek don't want it. X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --DiFt6ZB+CLaQPege Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 21, 2023 at 08:50:30AM -0700, Colin Foster wrote: > On Thu, Apr 20, 2023 at 05:06:17PM +0200, Maxime Chevallier wrote: > > On regmap consumers that require address translation through > > up/downshifting, the alignment check in the regmap core doesn't take the > > translation into account. This doesn't matter when downshifting the > > register address, as any address that fits a given alignment requirement > > will still meet it when downshifted (a 4-byte aligned address will > > always also be 2-bytes aligned for example). > > However, when upshifting, this check causes spurious errors, as it > > occurs before the upshifting. > I don't follow why upshifting should make a difference to alignment. > Assuming it does though, would it make sense to test > map->format.reg_shift > 0 > instead of just !map->format.reg_shift? Yeah, I think the question is more when we should run the alignment check than if we should have one. I think running the check after any shifting makes sense, we'd be better off reorganising the checks if needed than removing them. >=20 > > - if (!IS_ALIGNED(reg, map->reg_stride)) > > + if (!map->format.reg_shift && !IS_ALIGNED(reg, map->reg_stride)) > > return -EINVAL; >=20 > In the case of ocelot_spi, we'd want to flag an invalid access to a > register like 0x71070003... Before this patch it would return -EINVAL, > after this patch it would access 0x71070000. >=20 > Colin Foster --DiFt6ZB+CLaQPege Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmRHzfYACgkQJNaLcl1U h9Cpggf/c7E3rKx9CqXXzBlq45k7DnQbPm0a1LBhR2l4e4Tt8fLdhpImflz2foAJ rwiYt18SG3Lr8eXqXrPjItqjiHb79lpjJdB1rlze6rkVJohxVlpxTWZPYnCmhcXu 7NYMzlQpCiPZZzVqmIDF9/IuA/3pinFBVegyzJxdbjbhBGUZDvIL2hez0D2JfAlD 97OlNQPwEJ46d/AoWZjhHecb+7gWHZZRzvREkiqTYDAqrg5ZSXm3DJ+v6j0EfCV2 sWYYyjXdN0x5mLy7yZDiBnDP8FdQh5Fk+A/kQ1gR3Rqh69CJFEuv+O6+mkOgnVmf VKTVmhsWvZwsYRp1jTkxeUbuv4CKmQ== =+cEC -----END PGP SIGNATURE----- --DiFt6ZB+CLaQPege--