Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1752544rwr; Fri, 28 Apr 2023 01:02:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qYfttxcyg6iErEzbmvZ6R8/PN7AvbDu+fJD7W0iOmPF3esieaGvzyU4/C+FvIRMH+uKi4 X-Received: by 2002:a17:90b:1a86:b0:234:28ac:ec4a with SMTP id ng6-20020a17090b1a8600b0023428acec4amr4438582pjb.2.1682668931628; Fri, 28 Apr 2023 01:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682668931; cv=none; d=google.com; s=arc-20160816; b=Thyl87RFkY1jjFqqX6sH2zm1DKf9iAaYg0+3ihpHsc1Wnv24DAbdRLyJRTkud66PNX W1vRk27oQCi2J2MYKeeKNg5J09T8EIOWha9evW9KKqs/fhBAwDdANBbd2w0sNrojT8kf VljV0neiHTn8BG3LzkxxxCtdGgtD9OP39Mzsq5FLlIZDkezc5zof8TaPIfYH6qvrGiYQ 553b6csKzzCe4IjXEcSKiFjUv8LJLgCBur8WpfpjO+41T+VDS9c14DvT69YmjUDylMYB 8j7jZDtx9B25gGgpR+9buwfdPmE/YXtMQaU7NX58ktokd6keiBjKQWcROGD8qcKwJp/k EaXg== 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=YiAtgghwMLCLp7mSE08hfQRojWgcQ8TdcNOl5eIy3As=; b=leiVbGs2gEs/zppu36zpHEOFqnCeEzHcGAfaoxrWB5PgeW57Qq1ePNaAURQ96EamKA p2PHrkdwM2TpqjMSiP/RnmoQKfWoQ/94Vnn6b+SnyYmoUodcI5fKa1xOK2OCTh1MS6Jf X3Yj3NEFz//uKqcsMoJs7OAiAh9/uKWKg7+GpfD3ivRSw8F0rY6okAAkGe6OsxOWkMln clTZ9V8cDkxWHyXE/TNUnYzuXOrUI/EkXwRUd1OG7Wm/zZtBPtMyLX1c6lGn/HrcRGe8 itItmY0hyx1KnP0P0d0N5mtJrjUmR2kEjqAiQhEJIHjs7g2tPnd8rTXOOLMPrHtJ+Slt RR/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=l9Nvacfy; 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 co11-20020a17090afe8b00b002498218b776si22532341pjb.188.2023.04.28.01.01.55; Fri, 28 Apr 2023 01:02:11 -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=l9Nvacfy; 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 S1345112AbjD1Huq (ORCPT + 99 others); Fri, 28 Apr 2023 03:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345985AbjD1Htv (ORCPT ); Fri, 28 Apr 2023 03:49:51 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBC544A2 for ; Fri, 28 Apr 2023 00:48:37 -0700 (PDT) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 80FA31BF20E; Fri, 28 Apr 2023 07:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1682668067; 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=YiAtgghwMLCLp7mSE08hfQRojWgcQ8TdcNOl5eIy3As=; b=l9NvacfyJNU9T6JFaT/nSElfFHuwxhZbmeFgh5ZWjXXvOpkhUUcRQDWMcjJWnyI99eoVLb pdec/7zvrAnNjIgSTB1/0Vey0Z9v1Ji3wzmHd4FEpO9cIF/MQ8S//M0cTvfxA9rfwZ8MsM +8JGpTefmntqsm85/xO3krJHO3ey2+bYfl22NNQhdL1mzehqruPgzq8rjxRc1DOIxjsPZ9 SP0m3vLGvw1AQ/U+tzqX/Nze1cXvbVDK3qrB49I0tvve+OGpHlZG+b893Ld1k0LzaG5GpJ AGM6fl98ba543RV32xMnAJ4wlMdJfiYsEySYtH2++NGwW2PDDwgVZpX1V8h+HQ== Date: Fri, 28 Apr 2023 09:47:45 +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: <20230428094745.63677228@pc-7.home> In-Reply-To: <20230428093010.07e61080@pc-7.home> References: <20230420150617.381922-1-maxime.chevallier@bootlin.com> <20230428093010.07e61080@pc-7.home> 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 On Fri, 28 Apr 2023 09:30:10 +0200 Maxime Chevallier wrote: > 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 ? Oops I'm missing the actual link, sorry about that :( [1] : https://lore.kernel.org/all/20230324093644.464704-3-maxime.chevallier@bootlin.com/ > 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 >