From: laurentiu.tudor@nxp.com (Laurentiu Tudor)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits
Date: Mon, 17 Jul 2017 14:53:54 +0000 [thread overview]
Message-ID: <596CCF7E.9030005@nxp.com> (raw)
In-Reply-To: <59364128-679b-2ea8-9838-62e9bd5f5a7e@arm.com>
Hi Robin,
On 07/17/2017 04:43 PM, Robin Murphy wrote:
> On 17/07/17 14:26, laurentiu.tudor at 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);
>> }
>>
>> /**
>>
>
WARNING: multiple messages have this Message-ID (diff)
From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
To: Robin Murphy <robin.murphy@arm.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"stuyoder@gmail.com" <stuyoder@gmail.com>
Cc: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"Ruxandra Ioana Radulescu" <ruxandra.radulescu@nxp.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"marc.zyngier@arm.com" <marc.zyngier@arm.com>,
Roy Pledge <roy.pledge@nxp.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"agraf@suse.de" <agraf@suse.de>,
"Catalin Horghidan" <catalin.horghidan@nxp.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Leo Li <leoyang.li@nxp.com>,
Bharat Bhushan <bharat.bhushan@nxp.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits
Date: Mon, 17 Jul 2017 14:53:54 +0000 [thread overview]
Message-ID: <596CCF7E.9030005@nxp.com> (raw)
In-Reply-To: <59364128-679b-2ea8-9838-62e9bd5f5a7e@arm.com>
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);
>> }
>>
>> /**
>>
>
next prev parent reply other threads:[~2017-07-17 14:53 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 13:26 [PATCH 0/7] staging: fsl-mc: make the driver compile on other architectures laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:26 ` [PATCH 1/7] staging: fsl-mc: add missing fsl_mc comment in struct msi_desc laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:26 ` [PATCH 2/7] staging: fsl-mc: use generic memory barriers laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:38 ` Robin Murphy
2017-07-17 13:38 ` Robin Murphy
2017-07-17 13:46 ` Laurentiu Tudor
2017-07-17 13:46 ` Laurentiu Tudor
2017-07-17 13:26 ` [PATCH 3/7] staging: fsl-mc: drop useless gic v3 related #include laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:26 ` [PATCH 4/7] staging: fsl-mc: fix compilation with non-generic msi domain ops laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:26 ` [PATCH 5/7] staging: fsl-mc: fix formating of phys_addr_t on 32 bits laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:26 ` [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-17 13:43 ` Robin Murphy
2017-07-17 13:43 ` Robin Murphy
2017-07-17 14:53 ` Laurentiu Tudor [this message]
2017-07-17 14:53 ` Laurentiu Tudor
2017-07-17 13:45 ` Arnd Bergmann
2017-07-17 13:45 ` Arnd Bergmann
2017-07-17 14:27 ` Laurentiu Tudor
2017-07-17 14:27 ` Laurentiu Tudor
2017-07-17 15:00 ` Arnd Bergmann
2017-07-17 15:00 ` Arnd Bergmann
2017-07-18 11:08 ` Laurentiu Tudor
2017-07-18 11:08 ` Laurentiu Tudor
2017-07-18 11:39 ` Arnd Bergmann
2017-07-18 11:39 ` Arnd Bergmann
2017-07-17 13:26 ` [PATCH 7/7] staging: fsl-mc: allow the driver compile multi-arch laurentiu.tudor at nxp.com
2017-07-17 13:26 ` laurentiu.tudor
2017-07-19 16:09 ` kbuild test robot
2017-07-19 16:09 ` kbuild test robot
2017-07-19 17:31 ` kbuild test robot
2017-07-19 17:31 ` kbuild test robot
2017-07-20 13:47 ` Laurentiu Tudor
2017-07-20 13:47 ` Laurentiu Tudor
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=596CCF7E.9030005@nxp.com \
--to=laurentiu.tudor@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.