Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1689051 > unrolled thread

Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits

Started byRobin Murphy <robin.murphy@arm.com>
First post2017-07-17 15:50 +0200
Last post2017-07-17 17:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to  work on 32-bits Robin Murphy <robin.murphy@arm.com> - 2017-07-17 15:50 +0200
    Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to  work on 32-bits Laurentiu Tudor <laurentiu.tudor@nxp.com> - 2017-07-17 17:00 +0200

#1689051 — Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits

FromRobin Murphy <robin.murphy@arm.com>
Date2017-07-17 15:50 +0200
SubjectRe: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits
Message-ID<u4ezn-5Kj-3@gated-at.bofh.it>
On 17/07/17 14:26, laurentiu.tudor@nxp.com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> 
> Split the 64-bit accesses in 32-bit accesses because there's no real
> constrain in MC to do only atomic 64-bit. There's only one place
> where ordering is important: when writing the MC command header the
> first 32-bit part of the header must be written last.
> We do this switch in order to allow compiling the driver on 32-bit.

#include <linux/io-64-nonatomic-hi-lo.h>

Then you can just use writeq()/writeq_relaxed()/readq_relaxed() on
32-bit platforms as well.

Robin.

> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> ---
>  drivers/staging/fsl-mc/bus/mc-sys.c | 31 ++++++++++++-------------------
>  1 file changed, 12 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/mc-sys.c b/drivers/staging/fsl-mc/bus/mc-sys.c
> index 195d9f3..dd2828e 100644
> --- a/drivers/staging/fsl-mc/bus/mc-sys.c
> +++ b/drivers/staging/fsl-mc/bus/mc-sys.c
> @@ -124,14 +124,15 @@ static inline void mc_write_command(struct mc_command __iomem *portal,
>  {
>  	int i;
>  
> -	/* copy command parameters into the portal */
> -	for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
> -		__raw_writeq(cmd->params[i], &portal->params[i]);
> -	/* ensure command params are committed before submitting it */
> -	wmb();
> -
> -	/* submit the command by writing the header */
> -	__raw_writeq(cmd->header, &portal->header);
> +	/*
> +	 * copy command parameters into the portal. Final write
> +	 * triggers the submission of the command.
> +	 */
> +	for (i = sizeof(struct mc_command) / sizeof(u32) - 1; i >= 0; i--) {
> +		__raw_writel(((u32 *)cmd)[i], &((u32 *)portal)[i]);
> +		/* ensure command params are committed before submitting it */
> +		wmb();
> +	}
>  }
>  
>  /**
> @@ -148,19 +149,11 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem *
>  						  struct mc_command *resp)
>  {
>  	int i;
> -	enum mc_cmd_status status;
> -
> -	/* Copy command response header from MC portal: */
> -	resp->header = __raw_readq(&portal->header);
> -	status = mc_cmd_hdr_read_status(resp);
> -	if (status != MC_CMD_STATUS_OK)
> -		return status;
>  
> -	/* Copy command response data from MC portal: */
> -	for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
> -		resp->params[i] = __raw_readq(&portal->params[i]);
> +	for (i = 0; i < sizeof(struct mc_command) / sizeof(u32); i++)
> +		((u32 *)resp)[i] = __raw_readl(&((u32 *)portal)[i]);
>  
> -	return status;
> +	return mc_cmd_hdr_read_status(resp);
>  }
>  
>  /**
> 

[toc] | [next] | [standalone]


#1689150

FromLaurentiu Tudor <laurentiu.tudor@nxp.com>
Date2017-07-17 17:00 +0200
Message-ID<u4fF8-6ob-19@gated-at.bofh.it>
In reply to#1689051
Hi Robin,

On 07/17/2017 04:43 PM, Robin Murphy wrote:
> On 17/07/17 14:26, laurentiu.tudor@nxp.com wrote:
>> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>>
>> Split the 64-bit accesses in 32-bit accesses because there's no real
>> constrain in MC to do only atomic 64-bit. There's only one place
>> where ordering is important: when writing the MC command header the
>> first 32-bit part of the header must be written last.
>> We do this switch in order to allow compiling the driver on 32-bit.
>
> #include <linux/io-64-nonatomic-hi-lo.h>
>
> Then you can just use writeq()/writeq_relaxed()/readq_relaxed() on
> 32-bit platforms as well.
>

Thanks, didn't knew of the header. This should take care of the 
compilation errors i was seeing. There's one problem though: these 
handle byte-ordering and i need raw accessors. :-(

---
Best Regards, Laurentiu

>> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>> ---
>>   drivers/staging/fsl-mc/bus/mc-sys.c | 31 ++++++++++++-------------------
>>   1 file changed, 12 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/staging/fsl-mc/bus/mc-sys.c b/drivers/staging/fsl-mc/bus/mc-sys.c
>> index 195d9f3..dd2828e 100644
>> --- a/drivers/staging/fsl-mc/bus/mc-sys.c
>> +++ b/drivers/staging/fsl-mc/bus/mc-sys.c
>> @@ -124,14 +124,15 @@ static inline void mc_write_command(struct mc_command __iomem *portal,
>>   {
>>   	int i;
>>
>> -	/* copy command parameters into the portal */
>> -	for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
>> -		__raw_writeq(cmd->params[i], &portal->params[i]);
>> -	/* ensure command params are committed before submitting it */
>> -	wmb();
>> -
>> -	/* submit the command by writing the header */
>> -	__raw_writeq(cmd->header, &portal->header);
>> +	/*
>> +	 * copy command parameters into the portal. Final write
>> +	 * triggers the submission of the command.
>> +	 */
>> +	for (i = sizeof(struct mc_command) / sizeof(u32) - 1; i >= 0; i--) {
>> +		__raw_writel(((u32 *)cmd)[i], &((u32 *)portal)[i]);
>> +		/* ensure command params are committed before submitting it */
>> +		wmb();
>> +	}
>>   }
>>
>>   /**
>> @@ -148,19 +149,11 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem *
>>   						  struct mc_command *resp)
>>   {
>>   	int i;
>> -	enum mc_cmd_status status;
>> -
>> -	/* Copy command response header from MC portal: */
>> -	resp->header = __raw_readq(&portal->header);
>> -	status = mc_cmd_hdr_read_status(resp);
>> -	if (status != MC_CMD_STATUS_OK)
>> -		return status;
>>
>> -	/* Copy command response data from MC portal: */
>> -	for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
>> -		resp->params[i] = __raw_readq(&portal->params[i]);
>> +	for (i = 0; i < sizeof(struct mc_command) / sizeof(u32); i++)
>> +		((u32 *)resp)[i] = __raw_readl(&((u32 *)portal)[i]);
>>
>> -	return status;
>> +	return mc_cmd_hdr_read_status(resp);
>>   }
>>
>>   /**
>>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web