Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751478AbdGQOyB (ORCPT ); Mon, 17 Jul 2017 10:54:01 -0400 Received: from mail-eopbgr20064.outbound.protection.outlook.com ([40.107.2.64]:3692 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751280AbdGQOx7 (ORCPT ); Mon, 17 Jul 2017 10:53:59 -0400 From: Laurentiu Tudor To: Robin Murphy , "gregkh@linuxfoundation.org" , "stuyoder@gmail.com" CC: "devel@driverdev.osuosl.org" , "Ruxandra Ioana Radulescu" , "arnd@arndb.de" , "marc.zyngier@arm.com" , Roy Pledge , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "Catalin Horghidan" , Ioana Ciornei , Leo Li , Bharat Bhushan , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits Thread-Topic: [PATCH 6/7] staging: fsl-mc: rewrite mc command send/receive to work on 32-bits Thread-Index: AQHS/wBzPleRJFQYukKH8pTIIt4qC6JYB2+AgAATkAA= Date: Mon, 17 Jul 2017 14:53:54 +0000 Message-ID: <596CCF7E.9030005@nxp.com> References: <20170717132646.3020-1-laurentiu.tudor@nxp.com> <20170717132646.3020-7-laurentiu.tudor@nxp.com> <59364128-679b-2ea8-9838-62e9bd5f5a7e@arm.com> In-Reply-To: <59364128-679b-2ea8-9838-62e9bd5f5a7e@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2557;7:ohk4yRphUB+p4G6852VBEpl/Dsvb4uH7MjUv9BWm5pZuylpg01bNcIGLI598IlCoUu/y9zbPxOH5ICNZlcK593THqGHO/uohLwf5QTSECnTLYoM4NFvcCdJJXL1veW3eY0iDWcxo5pmOt7nrCYBKD5ct14wAKXVi0xe0OkHHm1BRnTPU8w64+uPv1lWJmW1723WypzqSU3blq0QrRLJ7POS6Yl5KCRuq+bUAfclyZm3n5S0t7DoFLOxbaTAz73uXTzBmU6L59O2oHaz+3dIP/qOz3ftOVP5BQD19DRtv2r0pLULBRrt++eoeIaXuQ7pg9nhs7sBnegWHX7jLRc9kW3WzG9qB7kCNc5rCzmSb2yzjH77wblFtOsybuERJcpayJnjnycYTbbqOCGHEniQAOVBR3d0tNoEIEwKu9tspiGLuCL61ooRpNiAGpyaOXcn3T9p9VFYfXejlYbmmxKmxQYMHP2MqYD354nMQRbe5TUG0CntTx/uy769WxhWvXdvjfDeNMtHGsvcJkEvZZIrO7DIv13CIgzEu3fZy3XbPyJ23tTRI7VhHpxT9gd9Utr93H/4vSYXt6kZp89HJix/mycidaintpPjdHHm0qx7onUbBwXscWO22rDMD5fZ+QeEjH7EE//lwo92Ioqz2d7BhYxOHe3CwhMs5weI/8pDbcUG2/pory5JAJUvHeusJl0IdNaMBLJeIlNGTWgE6/QhWo3MQNe/V22vFSXD0+nDP4ZcUfv3CjQKsSHi/G0SnlZ2XSKRgIgNghstvCfe4MlgBdMHKIUBab2/Zvfwa7Fh8vK0= x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39400400002)(39410400002)(39450400003)(39860400002)(39840400002)(39850400002)(43544003)(24454002)(377454003)(4326008)(80316001)(305945005)(99286003)(54906002)(3660700001)(66066001)(53546010)(3846002)(5250100002)(53936002)(6512007)(33656002)(7736002)(25786009)(36756003)(3280700002)(2501003)(6246003)(38730400002)(102836003)(478600001)(6116002)(14454004)(5660300001)(189998001)(2906002)(54356999)(59896002)(50986999)(65816999)(8936002)(76176999)(2950100002)(6506006)(6436002)(2900100001)(8676002)(87266999)(81166006)(229853002)(86362001)(2201001)(6486002)(39060400002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2557;H:VI1PR0401MB1856.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; x-ms-office365-filtering-correlation-id: 199188eb-451d-48c9-1f6d-08d4cd23a583 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:VI1PR0401MB2557; x-ms-traffictypediagnostic: VI1PR0401MB2557: x-exchange-antispam-report-test: UriScan:(236129657087228)(185117386973197)(275809806118684)(247924648384137); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910075)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123562025)(20161123558100)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0401MB2557;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0401MB2557; x-forefront-prvs: 0371762FE7 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <830EB4D1FEEC37409C4C53F76561C13B@eurprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2017 14:53:54.9059 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2557 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v6HEs6v0017292 Content-Length: 2886 Lines: 83 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 >> >> 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. > 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 >> --- >> 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); >> } >> >> /** >> >