Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751429AbdGQNny (ORCPT ); Mon, 17 Jul 2017 09:43:54 -0400 Received: from foss.arm.com ([217.140.101.70]:39694 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbdGQNnx (ORCPT ); Mon, 17 Jul 2017 09:43:53 -0400 Subject: Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits To: laurentiu.tudor@nxp.com, gregkh@linuxfoundation.org, stuyoder@gmail.com Cc: devel@driverdev.osuosl.org, ruxandra.radulescu@nxp.com, arnd@arndb.de, marc.zyngier@arm.com, roy.pledge@nxp.com, linux-kernel@vger.kernel.org, agraf@suse.de, catalin.horghidan@nxp.com, ioana.ciornei@nxp.com, leoyang.li@nxp.com, bharat.bhushan@nxp.com, linux-arm-kernel@lists.infradead.org References: <20170717132646.3020-1-laurentiu.tudor@nxp.com> <20170717132646.3020-7-laurentiu.tudor@nxp.com> From: Robin Murphy Message-ID: <59364128-679b-2ea8-9838-62e9bd5f5a7e@arm.com> Date: Mon, 17 Jul 2017 14:43:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170717132646.3020-7-laurentiu.tudor@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2549 Lines: 73 On 17/07/17 14:26, laurentiu.tudor@nxp.com wrote: > From: Laurentiu Tudor > > 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 Then you can just use writeq()/writeq_relaxed()/readq_relaxed() on 32-bit platforms as well. Robin. > Signed-off-by: Laurentiu Tudor > --- > 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); > } > > /** >