From patchwork Sun Jan 1 18:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 37979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3868597wrt; Sun, 1 Jan 2023 10:34:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvjUP75c0MlXzkf4qzd/msaZM1jD8WOud/0PCvQqyRpMa0V7+PF3bl4i/gS664vjNEND633 X-Received: by 2002:a05:6402:538c:b0:483:21d8:87af with SMTP id ew12-20020a056402538c00b0048321d887afmr25015684edb.24.1672598088452; Sun, 01 Jan 2023 10:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672598088; cv=none; d=google.com; s=arc-20160816; b=cknTnMtYY/num6mYgFfqt7RBcG080nEAnCO2UakFXvAAUahn+v9M4GSeuggKQD8fd6 tqsGbZnMEMv5y29Oz8Thl0IwkjorHu/3ca1yhroLDFbve/bsOIsILZy9+f+s6P6RYsfm 2+vhai5wWLZ7B0wgDF07jpY6HGzSTDzLxOy/9mn0G2kAOh+GAU8VIN2d4UivKqfMtM1c zfNEgoUUrq+9D4ogXaP+5a1vS+eYF9GQ1m31W7k6bgoFg+adhwZ0y2fEjg325S6sEDD0 cPOSKoXKl6VhIqfiB//yR0FI8NDSJDT8YjLAhHjBF7RTpFHJDjXnvxrsMbjABRsoRy2k toVg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=BcrNw+w4SNGHCE4lx9Q7z+Zcv9oKolCWuuHkfZmCA7w=; b=tLKWAHsh4ADbSFL6LhBD9YqRq+q0VaTtfE7c8EPiY+dfs0/gvOzlCa+wd5sSuB4dO9 V1r92kQ51sB0Rwmea5O/1OMZ6qFbhOTvyiERAnQ7aZkNB/75Vn93va0TW3OECAuHEBZz gIThBNdas/yQQSZ6JHPgBNaIH+mHM+3vcroNDEK58ViEiNh7QFcALBNW/2YpYrCcBPcY htnvL3WY5U/BlLPyNcoXyY8xB0mCHR85KdyS9IoTmVWPsi+dxsnGLAxLmqGtQYlnGVXC /PJ5Vz94Tn7KRazXeXslsa+ydU00fk5xDciscOHtcr74FB5KWSeP0dWcCac6UoB43jz3 W4nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=vIIeS466; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JTk2uFeo; 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=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y24-20020aa7c258000000b004875d4836dfsi11925879edo.163.2023.01.01.10.34.22; Sun, 01 Jan 2023 10:34:48 -0800 (PST) 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=@sholland.org header.s=fm3 header.b=vIIeS466; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JTk2uFeo; 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=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjAASdZ (ORCPT + 99 others); Sun, 1 Jan 2023 13:33:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjAASdX (ORCPT ); Sun, 1 Jan 2023 13:33:23 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD5E726E4; Sun, 1 Jan 2023 10:33:21 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id AD1FB320039A; Sun, 1 Jan 2023 13:33:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 01 Jan 2023 13:33:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672598000; x=1672684400; bh=Bc rNw+w4SNGHCE4lx9Q7z+Zcv9oKolCWuuHkfZmCA7w=; b=vIIeS466ptQuOHMydg 7+zt+zhwPQTGDtQHXGc9usTB8nIXqFaguDCPX543aOJlLFFcEBO2CM9wx6o07mVF FuIrsiVecs9RegpKtHGCz6zEaCVQGDr7PbI6OuMVpq78iJ+5VoByKApOnVIANXbV arNpT1xxF1+WOOMwGKTAXWiCmBJSiImbLUPa3egcH+fW5TedFxWsw7n8qQ2Wrzto lLtnu88TlQDPIfts5Kn2tWc+HTt9DBC2oX6FTMZdMx/n4Df5m9C0XqQaD/dQtBXv obGCzIppON567mN20UZkaNnQDcS0bQuxB9yFcsYVwObdP4ISN49Ezinpa7mbM+4R Z/2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672598000; x=1672684400; bh=BcrNw+w4SNGHC E4lx9Q7z+Zcv9oKolCWuuHkfZmCA7w=; b=JTk2uFeou2tfXoKp6XM7d+lV8OikV 4wirUf5qLap69gsp49CJuYnJ8VLcWcCMV+f2k6AtibiKr9nI/Xw8S9N1KII/xqOZ nn/txguuYokG4nKsRofw1cepDfNMna16DEJ6ToNQFqg8BppvoPs4JxahPJXAF16O vIa/TNbAtXMjxg7XkFJeYpvksJfplDLJzvJvLA3hyo6DIcdAUHpXWmGKOy0RgnPH 1dDjn6b8AMe0iXSHvBdfZz2E0LIuDWgE+8k51A5rLXriFSW3bEo10MDV5bXBGZ/9 NKllMIB0rRrxzsSBJM8yrfEEveOHZMXuI0Lxn8fzyN6sp33Y8rbG12kaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrjedtgdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 1 Jan 2023 13:33:19 -0500 (EST) From: Samuel Holland To: Srinivas Kandagatla , Chen-Yu Tsai , Jernej Skrabec Cc: Samuel Holland , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, stable@vger.kernel.org, Heiko Stuebner Subject: [PATCH v2 1/2] nvmem: sunxi_sid: Always use 32-bit MMIO reads Date: Sun, 1 Jan 2023 12:33:15 -0600 Message-Id: <20230101183316.43642-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20230101183316.43642-1-samuel@sholland.org> References: <20230101183316.43642-1-samuel@sholland.org> MIME-Version: 1.0 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, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753846213154947014?= X-GMAIL-MSGID: =?utf-8?q?1753846213154947014?= The SID SRAM on at least some SoCs (A64 and D1) returns different values when read with bus cycles narrower than 32 bits. This is not immediately obvious, because memcpy_fromio() uses word-size accesses as long as enough data is being copied. The vendor driver always uses 32-bit MMIO reads, so do the same here. This is faster than the register-based method, which is currently used as a workaround on A64. And it fixes the values returned on D1, where the SRAM method was being used. The special case for the last word is needed to maintain .word_size == 1 for sysfs ABI compatibility, as noted previously in commit de2a3eaea552 ("nvmem: sunxi_sid: Optimize register read-out method"). Cc: stable@vger.kernel.org Fixes: 07ae4fde9efa ("nvmem: sunxi_sid: Add support for D1 variant") Tested-by: Heiko Stuebner Signed-off-by: Samuel Holland Reviewed-by: Jernej Skrabec --- (no changes since v1) drivers/nvmem/sunxi_sid.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 5750e1f4bcdb..92dfe4cb10e3 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -41,8 +41,21 @@ static int sunxi_sid_read(void *context, unsigned int offset, void *val, size_t bytes) { struct sunxi_sid *sid = context; + u32 word; + + /* .stride = 4 so offset is guaranteed to be aligned */ + __ioread32_copy(val, sid->base + sid->value_offset + offset, bytes / 4); - memcpy_fromio(val, sid->base + sid->value_offset + offset, bytes); + val += round_down(bytes, 4); + offset += round_down(bytes, 4); + bytes = bytes % 4; + + if (!bytes) + return 0; + + /* Handle any trailing bytes */ + word = readl_relaxed(sid->base + sid->value_offset + offset); + memcpy(val, &word, bytes); return 0; }