From patchwork Tue Jan 9 20:32:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10153253 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 23C22601A1 for ; Tue, 9 Jan 2018 20:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21C09201A4 for ; Tue, 9 Jan 2018 20:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1579C20499; Tue, 9 Jan 2018 20:33:10 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BFBF6201A4 for ; Tue, 9 Jan 2018 20:33:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF0C06E156; Tue, 9 Jan 2018 20:33:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18C5C6E151 for ; Tue, 9 Jan 2018 20:33:05 +0000 (UTC) Received: by mail-pg0-x242.google.com with SMTP id i5so8770785pgq.11 for ; Tue, 09 Jan 2018 12:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v1wRHgd2P8e8a6A29vKVtRz1IDDvbSXSUBOjSXEPjPs=; b=dtifNL/ReJCNPn+XtjfXn9G28f1PZ0+8RaKsiaXX6ooXua8DljW+jhmT491FYqdSek sE+xAdHF/O8wkLuatVsY5FGc4Fy0dtUWro9NfrsUV92Ignbevr334E64UjszTut82ZCY E6N6wTwK+TqYkyCpdnHqnnvalHkq7RPWlTExI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v1wRHgd2P8e8a6A29vKVtRz1IDDvbSXSUBOjSXEPjPs=; b=UyLDYg6HlVcgTAW9oJyCqfg8c1DaiyrTOk5mz51OF0iP/rFJZhqvlub69dxAkI3X1H K9b7SWsvlsjKIwHKMj8CmtAEUAxi5NLvqc6Q6Z1ZuULKFruh+5HJI4EiJIu/ElGpfIig Tjm2SbkgxVDQCv+Mqlzwu3z5uEs6hi7IgLUyZlrCFdtiykvcKObuK6BfIyfgRoml/eDz lJGO5areho4AqmMmniZb+uYzrJdLLrq7l/UIID6nSZPwy2LBb/x4N+DTa+5m4Ixm4k7z Miau2qjdlTmpcmaVMgeMjHNcEbJ+x1hA3v04AmKFRzrfmRiKLVFE2QAEUqgolgJrPTmM meaA== X-Gm-Message-State: AKGB3mJF3ELv2x+bPIZv/5GpoVIu5s0Zz6zGu4QocdtCO/+eayCVPRvs ZYcwwCP9t3MD44TyzH7L/NHTkw== X-Google-Smtp-Source: ACJfBov7PReCe6PMWStDwtfrxtotgTeIb5upyOx9VhGVBF55Fv+01HTk5SInVHtEWmpcJzolB/6tPQ== X-Received: by 10.84.128.74 with SMTP id 68mr6918698pla.228.1515529985643; Tue, 09 Jan 2018 12:33:05 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id v25sm16248084pfg.132.2018.01.09.12.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 12:33:05 -0800 (PST) From: Brian Norris To: Archit Taneja , Andrzej Hajda , Laurent Pinchart Subject: [PATCH v2 2/2] drm/bridge/synopsys: dsi: handle endianness correctly in dw_mipi_dsi_write() Date: Tue, 9 Jan 2018 12:32:48 -0800 Message-Id: <20180109203248.139249-2-briannorris@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180109203248.139249-1-briannorris@chromium.org> References: <20180109203248.139249-1-briannorris@chromium.org> Cc: hl@rock-chips.com, David Airlie , Brian Norris , hoegsberg@gmail.com, Philippe Cornu , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Yannick Fertre , linux-rockchip@lists.infradead.org, Nickey Yang , mka@chromium.org, zyw@rock-chips.com, xbl@rock-chips.com, Vincent Abriou X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We're filling the "remainder" word with little-endian data, then writing it out to IO registers with endian-correcting writel(). That probably won't work on big-endian systems. Let's mark the "remainder" variable as LE32 (since we fill it with memcpy()) and do the swapping explicitly. Some of this function could be done more easily without memcpy(), but the unaligned "remainder" case is a little hard to do without potentially overrunning 'tx_buf', so I just applied the same solution in all cases (memcpy() + le32_to_cpu()). Tested only on a little-endian system. Signed-off-by: Brian Norris Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index ed91e32ee43a..90f13df6f106 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -360,18 +360,18 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, { const u8 *tx_buf = packet->payload; int len = packet->payload_length, pld_data_bytes = sizeof(u32), ret; - u32 remainder; + __le32 word; u32 val; while (len) { if (len < pld_data_bytes) { - remainder = 0; - memcpy(&remainder, tx_buf, len); - dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); + word = 0; + memcpy(&word, tx_buf, len); + dsi_write(dsi, DSI_GEN_PLD_DATA, le32_to_cpu(word)); len = 0; } else { - memcpy(&remainder, tx_buf, pld_data_bytes); - dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); + memcpy(&word, tx_buf, pld_data_bytes); + dsi_write(dsi, DSI_GEN_PLD_DATA, le32_to_cpu(word)); tx_buf += pld_data_bytes; len -= pld_data_bytes; } @@ -386,9 +386,9 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, } } - remainder = 0; - memcpy(&remainder, packet->header, sizeof(packet->header)); - return dw_mipi_dsi_gen_pkt_hdr_write(dsi, remainder); + word = 0; + memcpy(&word, packet->header, sizeof(packet->header)); + return dw_mipi_dsi_gen_pkt_hdr_write(dsi, le32_to_cpu(word)); } static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,