mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/9] mci: add RPMB support
Date: Wed, 19 Mar 2025 16:41:10 +0100	[thread overview]
Message-ID: <d8abf87b-2cda-4b21-ad76-f51ac888e300@pengutronix.de> (raw)
In-Reply-To: <29edc564-8919-40d3-b4ac-d0e622a92bcd@pengutronix.de>



On 3/19/25 16:34, Ahmad Fatoum wrote:
> 
> 
> On 3/19/25 16:29, Sascha Hauer wrote:
>> On Tue, Mar 18, 2025 at 12:33:05PM +0100, Sascha Hauer wrote:
>>> On Mon, Mar 17, 2025 at 04:18:32PM +0100, Ahmad Fatoum wrote:
>>>> Hello Sascha,
>>>>
>>>> On 3/12/25 13:16, Sascha Hauer wrote:
>>>>> +
>>>>> +int mci_rpmb_route_frames(struct mci *mci, void *req, unsigned long reqlen,
>>>>> +			  void *rsp, unsigned long rsplen)
>>>>> +{
>>>>> +	/*
>>>>> +	 * Whoever crafted the data supplied to this function knows how to
>>>>> +	 * format the PRMB frames and which response is expected. If
>>>>> +	 * there's some unexpected mismatch it's more helpful to report an
>>>>> +	 * error immediately than trying to guess what was the intention
>>>>> +	 * and possibly just delay an eventual error which will be harder
>>>>> +	 * to track down.
>>>>> +	 */
>>>>> +	void *rpmb_data = NULL;
>>>>> +	int ret;
>>>>> +
>>>>> +	mci_blk_part_switch(mci->rpmb_part);
>>>>> +
>>>>> +	if (!IS_ALIGNED((uintptr_t)req, ARCH_DMA_MINALIGN)) {
>>>>
>>>> Even if alignment happens to be correct, there is no guarantee that
>>>> there is no other data sharing a cache line.
>>>
>>> reqlen is expected to be a single block of 512 bytes, so indeed when req
>>> is aligned then the end is cacheline aligned as well. We could check
>>> reqlen as well, but I actually never ran into this case, so we can just
>>> return an error for now as you suggested.
>>
>> I was wrong here. the request is placed directly behind a 6 byte struct,
>> so it's guaranteed to be unaligned. We always have to copy it.
>>
>> The response might be unaligned as well, but must be aligned to pass it
>> to the mmc layer. In my tests the response was always aligned, but
>> better safe than sorry, so I'll add an alignment check here as well,
>> this time including a check for the length.

Sorry about the empty mail. Can we have a generic helper for this?

Maybe dma_map_buf_is_aligned or something like that, preferably with a
device argument from the outset.

Cheers,
Ahmad

> 
> 
> 
>>
>> Sascha
>>
> 




  reply	other threads:[~2025-03-19 15:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 12:16 [PATCH 0/9] Add " Sascha Hauer
2025-03-12 12:16 ` [PATCH 1/9] mci: implement mci_set_blockcount() Sascha Hauer
2025-03-12 12:16 ` [PATCH 2/9] mci: export some functions for RPMB support Sascha Hauer
2025-03-12 12:16 ` [PATCH 3/9] mci: detect RPMB partitions Sascha Hauer
2025-03-12 12:16 ` [PATCH 4/9] mci: add RPMB support Sascha Hauer
2025-03-17 15:18   ` Ahmad Fatoum
2025-03-18 11:33     ` Sascha Hauer
2025-03-19 15:29       ` Sascha Hauer
2025-03-19 15:34         ` Ahmad Fatoum
2025-03-19 15:41           ` Ahmad Fatoum [this message]
2025-03-12 12:16 ` [PATCH 5/9] tee: optee: probe successfully even when no devices are found Sascha Hauer
2025-03-12 12:16 ` [PATCH 6/9] tee: optee: implement shared mem alloc/free RPC commands Sascha Hauer
2025-03-18 11:42   ` Ahmad Fatoum
2025-03-12 12:16 ` [PATCH 7/9] tee: optee: implement RPMB support Sascha Hauer
2025-03-12 12:16 ` [PATCH 8/9] tee: optee: implement AVB named persistent values support Sascha Hauer
2025-03-12 12:16 ` [PATCH 9/9] commands: add avb_pvalue command Sascha Hauer

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=d8abf87b-2cda-4b21-ad76-f51ac888e300@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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