Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3829149ybb; Mon, 6 Apr 2020 17:01:53 -0700 (PDT) X-Google-Smtp-Source: APiQypLUrod3Od+YVml6LRdTJsV3KZ3hubDgF6ncMaqm0wmxqrmGfDoJ/T7JYQkegfT9vmI+3lAY X-Received: by 2002:a9d:7488:: with SMTP id t8mr19163563otk.219.1586217713565; Mon, 06 Apr 2020 17:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586217713; cv=none; d=google.com; s=arc-20160816; b=sT4gs+emJE+RzpNV3Y8KRrb0XHTdgtBgkGINPn4ZY8wDB4J5dbk5c+lpegA0mPSJsB oFkcTQzRaLf9yZvMLqG594f3GqVdf5dNNdd6a7o/lMCkME1uzDx2Ka8r40A5YEKR0oAg E+C1R/udY014AayxunIfJDvlQAFXm/GZhuhpLkLtb5ve+Hun011CTuHCQiFAA5Rv7FHv GxE8o2RygRTiEsa/xRZWS4kkiSl2r9idlyWjlFgQHu1WcErLu/RtQnMVff60CxOzayt6 EQGCtcjlHAlUcep9nBSLkQwSleVxPiajyMedJLTC/ZBYAHw1Z5q/C7xL0J2QzOEbinfQ Aa4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yABShm/LeI3qvPj7GklbqY25K387McX1oq0xyOsTdY4=; b=z6RTte9C7o6GeMfAO5bxcdc/F5j6zFovS+HByfAXBKYlRc9vbqKy05eo4GdLs4dOVK 232YL0cz0CaQ+WXC+3U3gGGXYSLZsfTdu1JpOAQOLGIEnd7feCjXpFSPaNPQ14W3Hfs8 7l6nZVGfuQR52yu58DQAH4FqKtmjBKKSyhn5x5cJmAVsr+NysVzmln5A0jD4NddAbSpe PTmoV686WNCYV1h4wOHKWDgKyR1M2uyv+Mzeg5opqLxuiDLn+guOa7kwPUn8HQPytWwB NdOEzd8BSrSKKK63XoMTv7NrMA008VsviK+W6QJPqZtRV5pWLYhMxF8dveQO5AvQ1Ida bFvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jtUpYaF2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id n3si8150328oib.163.2020.04.06.17.01.37; Mon, 06 Apr 2020 17:01:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jtUpYaF2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726417AbgDGABC (ORCPT + 99 others); Mon, 6 Apr 2020 20:01:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:33266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbgDGABC (ORCPT ); Mon, 6 Apr 2020 20:01:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BAE352078A; Tue, 7 Apr 2020 00:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586217661; bh=hFO4jLIKH+x5/7ssSNwRO2Wq0ZVgFPUvQpXBS26CSuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtUpYaF2QgX4lzseS+tVO6yBotFBdNhOx05YhaExi1sNw2qmSULCE3vOPSHfuA5gP p1Uu75P4/Qd5mt0pi7XnGAXd1SYATMiwfsyKsj32ale3LwkFL6hekKcQ4FG3LWC3P8 rclduIbjvRlqy+vFwi/Te7j+Lf0PePIBRxo1fvW0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Jirman , Chen-Yu Tsai , Maxime Ripard , Sasha Levin , linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.5 02/35] bus: sunxi-rsb: Return correct data when mixing 16-bit and 8-bit reads Date: Mon, 6 Apr 2020 20:00:24 -0400 Message-Id: <20200407000058.16423-2-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407000058.16423-1-sashal@kernel.org> References: <20200407000058.16423-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ondrej Jirman [ Upstream commit a43ab30dcd4a1abcdd0d2461bf1cf7c0817f6cd3 ] When doing a 16-bit read that returns data in the MSB byte, the RSB_DATA register will keep the MSB byte unchanged when doing the following 8-bit read. sunxi_rsb_read() will then return a result that contains high byte from 16-bit read mixed with the 8-bit result. The consequence is that after this happens the PMIC's regmap will look like this: (0x33 is the high byte from the 16-bit read) % cat /sys/kernel/debug/regmap/sunxi-rsb-3a3/registers 00: 33 01: 33 02: 33 03: 33 04: 33 05: 33 06: 33 07: 33 08: 33 09: 33 0a: 33 0b: 33 0c: 33 0d: 33 0e: 33 [snip] Fix this by masking the result of the read with the correct mask based on the size of the read. There are no 16-bit users in the mainline kernel, so this doesn't need to get into the stable tree. Signed-off-by: Ondrej Jirman Acked-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/bus/sunxi-rsb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index be79d6c6a4e45..1bb00a959c67f 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -345,7 +345,7 @@ static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr, if (ret) goto unlock; - *buf = readl(rsb->regs + RSB_DATA); + *buf = readl(rsb->regs + RSB_DATA) & GENMASK(len * 8 - 1, 0); unlock: mutex_unlock(&rsb->lock); -- 2.20.1