All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: "Timothée Cercueil" <litchi.pi@protonmail.com>, u-boot@lists.denx.de
Cc: "Peng Fan" <peng.fan@nxp.com>,
	"Timothée Cercueil" <timothee.cercueil@st.com>
Subject: Re: [PATCH] drivers/mmc/rpmb.c: Fix driver routing memory alignment with tmp buffer
Date: Tue, 15 Jun 2021 17:47:13 +0900	[thread overview]
Message-ID: <54f59495-7684-6558-ca33-c40e486e06e0@samsung.com> (raw)
In-Reply-To: <20210615072850.16812-1-litchi.pi@protonmail.com>

Hi Timorthee,

On 6/15/21 4:29 PM, Timothée Cercueil wrote:
> From: litchipi <litchi.pi@protonmail.com>
> 

Could you change to subject as "mmc: rpmb: fix ...."?

> Fix mmc_rpmb_route_frames() implementation to comply with most MMC
> drivers that expect some alignment of MMC data frames in memory.
> 
> When called from drivers/tee/optee/rpmb.c, the address passed is not
> aligned properly. OP-TEE OS inserts a 6-byte header before a raw RPMB
> frame which makes RPMB data buffer not 32bit aligned. To prevent breaking
> ABI with OPTEE-OS RPC memrefs, allocate a temporary buffer to copy the
> data into an aligned memory.
> 
> Many RPMB drivers implicitly expect 32bit alignment of the eMMC frame
> including arm_pl180_mmci.c, sandbox_mmc.c and stm32_sdmmc2.c
> 
> Signed-off-by: Timothée Cercueil <timothee.cercueil@st.com>
> Signed-off-by: litchipi <litchi.pi@protonmail.com>
> Change-Id: Iec7554cf6be1219e2d80eb7b45d8d60531c9a7d6

Remove Change-Id.

Best Regards,
Jaehoon Chung

> Signed-off-by: Timothée Cercueil <litchi.pi@protonmail.com>
> ---
>  drivers/mmc/rpmb.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
> index ea7e506666..b68d98573c 100644
> --- a/drivers/mmc/rpmb.c
> +++ b/drivers/mmc/rpmb.c
> @@ -480,10 +480,24 @@ int mmc_rpmb_route_frames(struct mmc *mmc, void *req, unsigned long reqlen,
>  	 * and possibly just delay an eventual error which will be harder
>  	 * to track down.
>  	 */
> +	void *rpmb_data = NULL;
> +	int ret;
> 
>  	if (reqlen % sizeof(struct s_rpmb) || rsplen % sizeof(struct s_rpmb))
>  		return -EINVAL;
> 
> -	return rpmb_route_frames(mmc, req, reqlen / sizeof(struct s_rpmb),
> -				 rsp, rsplen / sizeof(struct s_rpmb));
> +	if (!IS_ALIGNED((uintptr_t)req, ARCH_DMA_MINALIGN)) {
> +		/* Memory alignment is required by MMC driver */
> +		rpmb_data = malloc(reqlen);
> +		if (!rpmb_data)
> +			return -ENOMEM;
> +
> +		memcpy(rpmb_data, req, reqlen);
> +		req = rpmb_data;
> +	}
> +
> +	ret = rpmb_route_frames(mmc, req, reqlen / sizeof(struct s_rpmb),
> +				rsp, rsplen / sizeof(struct s_rpmb));
> +	free(rpmb_data);
> +	return ret;
>  }
> --
> 2.17.1
> 
> 
> 


      reply	other threads:[~2021-06-15  8:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210615072930epcas1p413620362cc2fa456c2a183b41d493eef@epcas1p4.samsung.com>
2021-06-15  7:29 ` [PATCH] drivers/mmc/rpmb.c: Fix driver routing memory alignment with tmp buffer Timothée Cercueil
2021-06-15  8:47   ` Jaehoon Chung [this message]

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=54f59495-7684-6558-ca33-c40e486e06e0@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=litchi.pi@protonmail.com \
    --cc=peng.fan@nxp.com \
    --cc=timothee.cercueil@st.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.