Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1731876rwr; Fri, 28 Apr 2023 00:37:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WxgsGqsdE7DurQiUgw0B8t4x30UclQJecibhy89hagOf/yAcyiu0U8Cvlpc98JHffl7Ve X-Received: by 2002:a17:902:eccc:b0:1a9:813f:7d6f with SMTP id a12-20020a170902eccc00b001a9813f7d6fmr5723996plh.42.1682667467323; Fri, 28 Apr 2023 00:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682667467; cv=none; d=google.com; s=arc-20160816; b=HDEY8zU2pqSxOjEIdPEl6dTz5XVyymLkZ1/9YGKLIvV3VICEJEVxRmhHhPKOprOlPY Hj7y8VKPndV+PU2LYdK0NvCRgTzZBa+/cFg4doe7niG0YdVkoqjJucMT8qENCirnG+Wj tYJ5Q/mxgnLEwWfEXI82Zs0+nJwXG/VSY+XA71WqoglLEwNKLSxfkddGjJxCAcn6Dv/Y EGSua40E/W0KgqPDiSQm7Oagiz94rdlvDaC0Vb7NySPdGQpyPNus/azJemLI0M5mk36k KYX5QEzySyK4azttt8+yEP6dmLsAZLsjWSCIjNNeY6vLf583rdJ5n7rpgj4QuBhN81DM rkNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=iWBTxT4oyu6/mZM/P/Ah3o6QGBXo1mkLcX+rJvFiAcA=; b=BM/5zds1ndICBErfe50G5/bsTLRqo1LnXiUmMPbLbonGxrHtEAYjDEVUPpCoVP5kRp I5t1pXT5txttmc+DtdW9AuhGsCIsX1cLx7mZEsOWtqUTHva4Boq1uEF3UgCuW/S6Ktle l0zt8Zt4XOTYQbhpGaDlc0cd0AXYyyvcoqLjXU0W23cyCrj2iSWA3f6Rjrj2Sg7Am0O4 +JK0ZpAuO9rpfwg6T5tXb1k15QFVmZfcxS3RIjpmbik/5Nbs7BMrG4ZHIk/G5lU204CZ DRw3+FIZcZo6iOTFSha8wpp5uJCaSffaJKH0i5wRpqJ504jS7C2YcXLhXd1sqHjCM1hl gr/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=IzLGQ+hx; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li12-20020a170903294c00b001a8102f5d7fsi17297803plb.504.2023.04.28.00.37.32; Fri, 28 Apr 2023 00:37:47 -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=@bootlin.com header.s=gm1 header.b=IzLGQ+hx; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345508AbjD1HaV (ORCPT + 99 others); Fri, 28 Apr 2023 03:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345510AbjD1HaR (ORCPT ); Fri, 28 Apr 2023 03:30:17 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB86C268E for ; Fri, 28 Apr 2023 00:30:14 -0700 (PDT) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 1B89B40007; Fri, 28 Apr 2023 07:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1682667013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iWBTxT4oyu6/mZM/P/Ah3o6QGBXo1mkLcX+rJvFiAcA=; b=IzLGQ+hx3RDpUx5pk5wdyfx3i1Zr4VlVadxAm0pnO83yakXm19TVdjd7Bj2KPBhYH6Y2VJ ftjNcXPoZq+hrE5td7RrDjGXB+OkHJmjcsTVlb41I5IFM4eiM4ZjMj42eKGAQdcsommaLp Zc2C3X1QZs545xQJe/M3U5QmkQ2i1OehEVD7hG1DZGbtA+qACAcSgObdygtEaO9hXTV2c8 oJpVExjUo/1REDMA+D1jEnNQLPjKsfaKwB5swEE38mGvXKJmCcZMFySdCOQKrTXsMP2LIE mEnCRpby/PKf1y5LWtpklOtfd2CqtLEH9ZZTzPMRKLFwDsom52sKl0CoqBbsEQ== Date: Fri, 28 Apr 2023 09:30:10 +0200 From: Maxime Chevallier To: Mark Brown Cc: Colin Foster , 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: <20230428093010.07e61080@pc-7.home> In-Reply-To: References: <20230420150617.381922-1-maxime.chevallier@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hello Mark, Colin, On Tue, 25 Apr 2023 13:56:23 +0100 Mark Brown wrote: > 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. In the initial RFC I suggested this [1] approach, which checked for alignment after shifting, that way we are sure that the alignment check is done according to the underlying regmap provider's constraints. Maybe this could be sufficient ? Thanks, Maxime > > > > > - if (!IS_ALIGNED(reg, map->reg_stride)) > > > + if (!map->format.reg_shift && !IS_ALIGNED(reg, > > > map->reg_stride)) return -EINVAL; > > > > 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. > > > > Colin Foster