Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2549674imu; Thu, 29 Nov 2018 06:45:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xjs5qqvCdu5elX/OnKz5KHWcgOjiTkzphTuc5r8toJgUWDnO6sJG/yGmmlMs3nOXGC6jlI X-Received: by 2002:a62:b24a:: with SMTP id x71mr1697279pfe.148.1543502713845; Thu, 29 Nov 2018 06:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502713; cv=none; d=google.com; s=arc-20160816; b=hpvPMQsZqNtLtfYiIBYJlPjugjlBCQ9hPPvHDkPdhgVVadRmUODp33xeiFPKSbMpj9 ECb7PKvV+wvFKPpbJodRD9F9DfdPTUxPB1UzTpCUK3dw1b5/n0ZPe62RTL4Pf6rAFEFX 1BAPx6LYDdgv4hIQvZ71HnSxANW73CYx75F9LgpzyhNlkrqbK+E81aeE7L5V0Ks2XBBA RoHY8IboZsWTpt7KxOBAOnYaYyP6UtuCfrVzHVkSWlZbd59RSMXg/mbHsDh6xMBiajvm yUce6j4YiaLp0J/T22Ze/CgtVYJvI7G6xGn3OQ1LWnOmyoYb3l+IJIvV4bppQ8w6wtoM Bvxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=/5c5Cm9/wXyP8BywKcCwzxv0hrsD1exeR+gZBxPNzVA=; b=ZWc06LZ3kHp4hax2cAPY4q6x6wQPSdYsWiwTmVmHrtVlZFh3+r0gyPA5i/LAIzhEly OANSbymH4nGIhyW+yGXCNIiKS/8ryfg+POGjW1VpYfnaSbPgvojlCBQ8Udvps04ymMHo jRfafswKHNyS/O2XVAyNSj0yYh9ozT9thpL2pdVFr/CVosAumEuFSuoIR25hJVEeUAL1 Ld51ByuFLMR4sL+2z/EfjStJ0BktB4cF+T2gm/l2AWM3mRMVJVbo9LjIE6BSxAgyM1f2 DPCqfLSh/T1RttD+lsUvOFvbWmnLLzTa5AF0w/9rG8e7TB9fAqYIpe3XRlWNIGG8G6mr ezXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=e9EAnnPE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22si2144207pgr.383.2018.11.29.06.44.58; Thu, 29 Nov 2018 06:45:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=e9EAnnPE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388068AbeK3BsK (ORCPT + 99 others); Thu, 29 Nov 2018 20:48:10 -0500 Received: from smtprelay.synopsys.com ([198.182.60.111]:47276 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeK3BsJ (ORCPT ); Thu, 29 Nov 2018 20:48:09 -0500 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 99F3E10C08CC; Thu, 29 Nov 2018 06:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1543502554; bh=yaa6er+gvN33SEO//p4seoTIdtqTBwRlv+If4fIiUPI=; h=Subject:To:References:CC:From:Date:In-Reply-To:From; b=e9EAnnPEo2TLfuPDuwwiOE94f0qkxyw0poOCc37a5cfyHRkzCY4M8s8TnshmJ9W08 JQTgcVa8wOeWTgncnRrPHMKH7Ff9aR/X0eAGltXUuBLdmrPi59x0R6D+ysNRAWikX2 /aHZ8BD6yTIo3Y4PHGj4S6HqhpGLOAi+yjI99RV+DaR0rmR6qKft/+MHolPvS/CKXr wd9PdH5RHZ1qaJMYrQoPmEJFjGs6gMlOslZpyMj0v9a0jZYCK3MeTxsUKzuBZ6Nf8o BTOwqM6UtRu0Jn2tdOEDQK/715sTZUmxAJLYV3j0HFDiSQpKhRlTuo/sZZpk+njJNu ZoPrZUS8qFuig== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) by mailhost.synopsys.com (Postfix) with ESMTP id 8C6903B2A; Thu, 29 Nov 2018 06:42:34 -0800 (PST) Received: from DE02WEHTCA.internal.synopsys.com (10.225.19.92) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 29 Nov 2018 06:42:34 -0800 Received: from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by DE02WEHTCA.internal.synopsys.com (10.225.19.92) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 29 Nov 2018 15:42:32 +0100 Received: from [10.0.2.15] (10.107.19.26) by DE02WEHTCB.internal.synopsys.com (10.225.19.80) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 29 Nov 2018 15:42:31 +0100 Subject: Re: [PATCH v2] ARC: io.h: Implement reads{x}()/writes{x}() To: David Laight , "linux-snps-arc@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <19fb2e394afcb073bbc109e432417fbbc03323f6.1543499759.git.joabreu@synopsys.com> CC: Vineet Gupta , Alexey Brodkin , Joao Pinto , "Vitor Soares" From: Jose Abreu Message-ID: <89122bd8-bca2-2ae1-0dd0-160abbebcace@synopsys.com> Date: Thu, 29 Nov 2018 14:42:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.107.19.26] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29-11-2018 14:38, David Laight wrote: > From: Jose Abreu >> Sent: 29 November 2018 14:29 >> >> Some ARC CPU's do not support unaligned loads/stores. Currently, generic >> implementation of reads{b/w/l}()/writes{b/w/l}() is being used with ARC. >> This can lead to misfunction of some drivers as generic functions do a >> plain dereference of a pointer that can be unaligned. >> >> Let's use {get/put}_unaligned() helper instead of plain dereference of >> pointer in order to fix this. > ... >> +#define __raw_readsx(t,f) \ >> +static inline void __raw_reads##f(const volatile void __iomem *addr, \ >> + void *buffer, unsigned int count) \ >> +{ \ >> + if (count) { \ >> + const unsigned long bptr = (unsigned long)buffer; \ >> + u##t *buf = buffer; \ >> +\ >> + do { \ >> + u##t x = __raw_read##f(addr); \ >> +\ >> + /* Some ARC CPU's don't support unaligned accesses */ \ >> + if (bptr % ((t) / 8)) { \ >> + put_unaligned(x, buf++); \ >> + } else { \ >> + *buf++ = x; \ >> + } \ >> + } while (--count); \ >> + } \ >> +} > Does the compiler move the alignment test outside the loop? > You really want two copies of the loop body. Hmm, I would expect so because the if condition takes two const args ... I will try check that. Thanks and Best Regards, Jose Miguel Abreu > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) >