mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: Andrzej Hajda <a.hajda@samsung.com>,
	Brian Norris <briannorris@chromium.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	David Airlie <airlied@linux.ie>,
	Yannick Fertre <yannick.fertre@st.com>,
	Philippe Cornu <philippe.cornu@st.com>,
	Vincent Abriou <vincent.abriou@st.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Sean Paul <seanpaul@chromium.org>,
	Nickey Yang <nickey.yang@rock-chips.com>,
	hl@rock-chips.com, linux-rockchip@lists.infradead.org,
	mka@chromium.org, hoegsberg@gmail.com, zyw@rock-chips.com,
	xbl@rock-chips.com
Subject: Re: [PATCH v2 2/2] drm/bridge/synopsys: dsi: handle endianness correctly in dw_mipi_dsi_write()
Date: Tue, 16 Jan 2018 12:22:52 +0530	[thread overview]
Message-ID: <e4d9d6d6-76c4-4914-d800-c007a6e8938b@codeaurora.org> (raw)
In-Reply-To: <199f9097-736e-afe8-2093-bb28fba8b308@samsung.com>



On 01/10/2018 08:03 PM, Andrzej Hajda wrote:
> On 09.01.2018 21:32, Brian Norris wrote:
>> 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 <briannorris@chromium.org>
>> ---
>>   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));
> 
> You could create and use appropriate helper, lets say:
> 
> u32 le_to_cpup(const u8 *p, int count)
> {
>      __le32 r = 0;
> 
>      memcpy(&r, p, count);
>      return le32_to_cpu(r);
> }
> 
> With or without this change:
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

Queued to drm-misc-next as is.

Thanks,
Archit

> 
>   --
> Regards
> Andrzej
> 
> 
>>   }
>>   
>>   static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
> 
> 

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2018-01-16  6:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 20:32 [PATCH v2 1/2] drm/bridge/synopsys: dsi: use common mipi_dsi_create_packet() Brian Norris
2018-01-09 20:32 ` [PATCH v2 2/2] drm/bridge/synopsys: dsi: handle endianness correctly in dw_mipi_dsi_write() Brian Norris
2018-01-10 14:33   ` Andrzej Hajda
2018-01-16  6:52     ` Archit Taneja [this message]
2018-01-16 18:57       ` Brian Norris
2018-01-11 13:51 ` [PATCH v2 1/2] drm/bridge/synopsys: dsi: use common mipi_dsi_create_packet() Philippe CORNU
2018-01-12  7:10   ` Andrzej Hajda
2018-01-16  6:56 ` Archit Taneja
2018-01-16 19:04 ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4d9d6d6-76c4-4914-d800-c007a6e8938b@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=briannorris@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hl@rock-chips.com \
    --cc=hoegsberg@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mka@chromium.org \
    --cc=nickey.yang@rock-chips.com \
    --cc=philippe.cornu@st.com \
    --cc=seanpaul@chromium.org \
    --cc=vincent.abriou@st.com \
    --cc=xbl@rock-chips.com \
    --cc=yannick.fertre@st.com \
    --cc=zyw@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome