Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp310702imu; Wed, 21 Nov 2018 20:36:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/UGPS1/m+DWscKMQyYtW0WtAht3X6NfI95FR0pL4jf317b0ehV7cpoOUDbAN4m0BiNcUTGP X-Received: by 2002:a17:902:8306:: with SMTP id bd6mr9729942plb.217.1542861411809; Wed, 21 Nov 2018 20:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542861411; cv=none; d=google.com; s=arc-20160816; b=HjobrQdB8SvfmGA5Ki8RNMfk3vK5cHi5SX845tnR/dLj8ViBfkK1xwjMB9qrj1ur0f BwCQO2RKDZxTX1CDkVbYX/iOeyx7aMM4mhH0KZUuDpkUwNnopFIH3LiHK/XBjW3o6dAB vpNIF+fPebgP2Q3Z7714I36L8NaWA8DDiTorWGKufgS6QA1Abzs1LcugMSg+bhVU/DWd Cx+1AVl8iOIlwnObW5MwGeQk4hpT4kavttJwWx0lrYlgfuhhOxv+aQdtc3mURVvfYgnu R3y9rFHyDoyccGJ+dEd45zBTFGe/m0Tl3VKcRQZ4p+xzV4XpN0Qkdd8CVjGKfuDbHYBZ jGqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=2o53HgLaMIQ1zL3ADeDSW1+2nwbK3pzdJ6EvUWfAAzQ=; b=Z01hScKsnEoI5U17+zR3Tav/6VBJyrNeylqjo9PhQGP1k0JGZOtyNIi4d6WSvOOy2G SsBmSmpxbrMaZ3maAWlGQp9XQ1vOgwojr06HXAkzHIuTYc0Xi0Ib+iIoqI/laZpidDHB 4wOmz0boeREBHd2i+YWd+Lo0IePJXCunoWrs8k3Pg/n0kYCFxXMoBZaxoxKuX1FrjHWN j90M1kl67qqJsNlAYGUBHmyrQKvWgoi7nsGeA2qOVnH/jOMb/wrpEn4KzTrRvZUnLyoI /JmGkY6ithU93lFsohxpGGsSv9gZnt5PpoEry2DT/SOp/A2RUbpn/eXn1AjYqT5ut0TY yrAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=eWvfmyeG; 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 e34si21775773pgb.80.2018.11.21.20.36.37; Wed, 21 Nov 2018 20:36:51 -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=eWvfmyeG; 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 S1732551AbeKVGvm (ORCPT + 99 others); Thu, 22 Nov 2018 01:51:42 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:34954 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbeKVGvm (ORCPT ); Thu, 22 Nov 2018 01:51:42 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 60A4324E039E; Wed, 21 Nov 2018 12:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1542831355; bh=53N6lv59bHizH+C1e6qoRPcUG/qknSSogLi9WBLdaJ4=; h=From:To:CC:Subject:Date:References:From; b=eWvfmyeGzMa37KTWvvBXKM+tAoJESEm+9FFHhjyvetX9f8RAJXVw1yZKzq0Hu7yKZ VUMpFNK+fhXVtpeRoKwHdJoDVHhClZKrdoaR07PV8Bi8RtP3fnJJMv/ef05JXTrByH mu9+1vHSbIbnZvnAw+loKZT8FDYA/WcQ1V80ehtl0b/VSGOn3JF78wc4/CSTwdO0FI zYbHuBDhnipZHi/pgK8odSuXVeQ1PScA8ymMbIP+sWGaqYVd45UUD2xB927yl9QgsZ 2vwNTr/IaMf6OICWUdy7x/CLW9dKjwyVhX3CWA6okc3QBZmchpSfHo5LzvjNFe1Sel WoHoJWRljc6uA== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 4FFD458FE; Wed, 21 Nov 2018 12:15:55 -0800 (PST) Received: from US01WEMBX2.internal.synopsys.com ([fe80::e4b6:5520:9c0d:250b]) by us01wehtc1.internal.synopsys.com ([::1]) with mapi id 14.03.0415.000; Wed, 21 Nov 2018 12:15:55 -0800 From: Vineet Gupta To: Arnd Bergmann CC: Vitor Soares , "alexey.brodkin@synopsys.com" , Joao Pinto , "jose.abreu@synopsys.com" , "open list:SYNOPSYS ARC ARCHITECTURE" , Linux Kernel Mailing List Subject: Re: Misaligned Access Thread-Topic: Misaligned Access Thread-Index: AQHUa8BEl692JJiolkiUiQERHFjjDw== Date: Wed, 21 Nov 2018 20:15:54 +0000 Message-ID: References: <13D59CF9CEBAF94592A12E8AE55501350113CD10@DE02WEMBXB.internal.synopsys.com> <9ffd1270-ad92-88b7-eb53-85c65fe971dd@synopsys.com> <4881796E12491D4BB15146FE0209CE6468198AC6@DE02WEMBXB.internal.synopsys.com> <661a4323-5768-4977-5434-ab644c5418aa@synopsys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.144.199.106] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/21/18 12:12 PM, Arnd Bergmann wrote:=0A= > On Wed, Nov 21, 2018 at 8:42 PM Vineet Gupta = wrote:=0A= >> +CC lkml, Arnd : subject matter expert=0A= >>=0A= >> On 11/21/18 10:06 AM, Vitor Soares wrote:=0A= >>> I use the follow function to get data from a RX Fifo.=0A= >>>=0A= >>>=0A= >>> static void dw_i3c_master_read_rx_fifo(struct dw_i3c_master *master,=0A= >>> u8 *bytes, int nbytes)=0A= >>> {=0A= >>> readsl(master->regs + RX_TX_DATA_PORT, bytes, nbytes / 4);=0A= >> So the semantics are reading the same fifo register N times, to get the = N words,=0A= >> hence read*s*l is appropriate. That however expects the buffer to be 4 b= ytes=0A= >> aligned, hence your issue. You can't possibly use the reads*b* as we wan= t the=0A= >>=0A= >> The obvious but crude hack is to use a temp array for readsl and then co= py over=0A= >> using memcpy, but I'm sure there are better ways, @Arnd ? To summarize i= s issue is=0A= >> a driver triggering unaligned access due to the misinteraction of API (d= river get=0A= >> an unaligned u8 *) which goes against expectations of io accessor readl = (needed=0A= >> since the register contents are 4 bytes)=0A= > Is this again on ARC or some other architecture that cannot do unaligned= =0A= > access to normal RAM? On ARMv7 or x86, you should never see a problem=0A= > because the CPU handles misaligned writes. On ARMv4/v5, the readsl()=0A= > implementation internally aligns the access to the output buffer so it=0A= > will work correctly.=0A= =0A= This is indeed on ARC: on ARC700 unaligned access to RAM was never supporte= d and=0A= on HS38x cores, it is configurable, so the API probably needs to support bo= th cases.=0A= =0A= Thx,=0A= -Vineet=0A=