From patchwork Fri Feb 24 12:54:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 9590183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 06A6D601AE for ; Fri, 24 Feb 2017 13:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C09142857C for ; Fri, 24 Feb 2017 13:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B573428791; Fri, 24 Feb 2017 13:08:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E4EA2857C for ; Fri, 24 Feb 2017 13:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4Uxq9ZpZKUMmtlXzHG8goJWH7wE2eAJa1oWJv9ZqM04=; b=TMfi8cpY9NArgfhMVzFdwLRpsA 6kybeeiJBf2R9WA6gVQudDPHn50D5TQUpnW/8m50BtgSHRLv0DGQHot0TQ3GOAG4nBwRCaOq8K7pd gGqOrqKya2ZsHVMgOEpvzh/cmwskC8DU5Hz5vZqse3eXYY6pMaDaPGKDFq5hwV4T2CPqX8c4V424K AiBS8GHeS+lkQHwhptg/KwlBcD6FjV8/3yaCL4tA/XJ6sX0Zt3npqQfY4djcGe2HvjCNZSfr2ib+G eSdiYuRIrhA5Th9fbg/XipO1/9yZ/U6mB6XyDqKBpsdXBgvafXcGMtFWUTOZF4aBhTBA8korwqafM jW/D6bhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1chFbS-0007If-D9; Fri, 24 Feb 2017 13:08:06 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chFPi-0006YD-FT; Fri, 24 Feb 2017 12:55:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mtozVjWpOwDCdm8wUKcluQSnM9QkaSU0iQnSzn/jh7g=; b=cnh5FhG9+v7wN+NpNxLUrtQvu xGfxwQ+qnX/mvcXjlTV5Jb70gZH0W5QikXnY1Y1W7Q/p7Qz6NnO/sOCW0MYNrVWXCzRzffY9YkqI7 RB8JUByqjzceOyauNgVLWpMFlT+CRKR94ra3GatzHcPgJ8AZfwOEB5CRv8DCHxkQvyuRRVlOPzpFf zgAfeHZYAhLEdgPm6/RsJCgJbArt/oaiL9Bi0fdoc+OTpwl4foeSBCT2c6qRCHc9f7bHFIjUu4cm1 QpJA8jlo7HQ8XUgn78Tp1MP9EZvI+Bi8q2oUOaK4I/l96XB2/svEpChmLHrhPwa8SkYMZqj9sLpKd FnO5WDVBQ==; Received: from dougal.metanate.com ([90.155.101.14] helo=metanate.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chFPd-00039O-JU; Fri, 24 Feb 2017 12:55:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=IqnE7VJWzIqm9pWYcUmX894Ls+qCZH3JQsr899sB4no=; b=aQGhUk2+qZuh4A47wX00UOuDksUgVT54zVu6FfypIuu6cROmtWFVcQEUhddZV6w5uTJstv+NQdke2dLXgn8GKaellmQu1qGRMimL0LSb+Le49tx5Ims4arrdmqY/5jwkdl2zOlsahMSf19vjnZiXUihUUfGi/zvyMZ1Gg4D9BurdWsA+RzXYsNhW23uCtelPmkTWaGduvnYg/jmYJgzWi/Z2EAJEx+bumDzZi5QJP4S79sVAWCHq3riKIoIX0I+gxNDeka4GQVWo8fWM7UkHGgjASKGknPuFFjlmM3m+F3ely36j2x5bqW0X9U65+gqCimcBMHHgltCI4J38LsW6aQ==; Received: from brian ([192.168.88.1] helo=leela.metanate.com) by shrek.metanate.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.83_RC2) (envelope-from ) id 1chFP0-0006ml-QU; Fri, 24 Feb 2017 12:55:14 +0000 From: John Keeping To: Mark Yao Subject: [PATCH v4 10/23] drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned Date: Fri, 24 Feb 2017 12:54:53 +0000 Message-Id: <20170224125506.21533-11-john@metanate.com> X-Mailer: git-send-email 2.12.0.rc0.230.gf625d4cdb9.dirty In-Reply-To: <20170224125506.21533-1-john@metanate.com> References: <20170224125506.21533-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170224_075553_864229_5F51251C X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Sean Paul , Chris Zhong , John Keeping , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP By dereferencing the MIPI command buffer as a u32* we rely on it being correctly aligned on ARM, but this may not be the case. Copy it into a stack variable that will be correctly aligned. Signed-off-by: John Keeping Reviewed-by: Chris Zhong --- v3: - Add Chris' Reviewed-by Unchanged in v2 --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 1b6fce2600f3..0c66e6eaf44a 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -609,10 +609,10 @@ static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, const struct mipi_dsi_msg *msg) { - const u32 *tx_buf = msg->tx_buf; - int len = msg->tx_len, pld_data_bytes = sizeof(*tx_buf), ret; + const u8 *tx_buf = msg->tx_buf; + int len = msg->tx_len, pld_data_bytes = sizeof(u32), ret; u32 hdr_val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type); - u32 remainder = 0; + u32 remainder; u32 val; if (msg->tx_len < 3) { @@ -623,12 +623,14 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, while (DIV_ROUND_UP(len, pld_data_bytes)) { if (len < pld_data_bytes) { + remainder = 0; memcpy(&remainder, tx_buf, len); dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); len = 0; } else { - dsi_write(dsi, DSI_GEN_PLD_DATA, *tx_buf); - tx_buf++; + memcpy(&remainder, tx_buf, pld_data_bytes); + dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); + tx_buf += pld_data_bytes; len -= pld_data_bytes; }