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: 10153259 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 DCB8160596 for ; Tue, 9 Jan 2018 20:33:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9CBA201A4 for ; Tue, 9 Jan 2018 20:33:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE6A8204BA; Tue, 9 Jan 2018 20:33:22 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 1215320415 for ; Tue, 9 Jan 2018 20:33:21 +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=IddHeAVDvlsxGdB0NRhlUbPKwFlwMDA/DT6/+w2SQZw=; b=HvmnPfD9OsRntKqsLyRVoQiidA ezpXezrHy/CxpqFwdYf3uhKut8gkHY+LYhba2i+Gfpj8e8VXA/AusxqWCDr4TSOQqxeYIqO2gPX91 LNRf6wznkDEfM1pvmQXSNtOuLJwA3ZsHNeuq5r0twG1F3juQlSUnIQ2m38uvVeZcQqs3KPTQRfEAE MKEB1d22lbflGY753kBXc4e5F0IxcDVjx6GE6FUXtC1dpAbj9PpSul/7dCVabL27A7vXbtKEUn950 loAdg/8ZeSmiFYMkXEJCJLSr/u79nVdueJtywvSdeOacAsBOWEeXiuPBqBg2pCLd/62/LlJc4bD1+ kjR11Q4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZ0aF-0000Uk-UR; Tue, 09 Jan 2018 20:33:19 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZ0aC-0000DG-C3 for linux-rockchip@lists.infradead.org; Tue, 09 Jan 2018 20:33:17 +0000 Received: by mail-pg0-x241.google.com with SMTP id f14so6201500pga.10 for ; Tue, 09 Jan 2018 12:33:06 -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=Sup8H25AzV5gUW0A1UOefoE/SLfnKkb1j+tjHvLVRJnUrS044dGcunWZZ5CVnPs7D5 0f9M8f9qabC7CMtc7CqK/R1S4OqU2vK2tGyYdZyHparj4XzxiYouMa5Tw3D0oWqq2U19 j9zcfk/twPBLEiZJJheJ74K6UiDDP8jd9ovqtON7lN4EhoFAfDBxqu2Psw/c1FyidK7H PALR9yCogRgMZuZ/jy49spuNl8hyQFx1Au1nncG8we3AxsFWb0egn0rQdCVW3qHzRimr 3EbUq9NM7fcoKRMddAFy56BwrjlUPmVoMrUbmjWlGCqKioutfopQmdGM+Co21igPsgwn X40g== X-Gm-Message-State: AKGB3mLlzCTyrFd4TWk7uX8TGvVC+eb7JaNcCoPIIxSd7gCZfIFiusAi W7uLY/dn/2wf3tx46c2+Q++P5g== 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_123316_410671_D10F7039 X-CRM114-Status: GOOD ( 11.09 ) 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: 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, Sean Paul , zyw@rock-chips.com, xbl@rock-chips.com, Vincent Abriou 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 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,