Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp253453imu; Wed, 21 Nov 2018 19:16:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoMj0p4EYrWgyYjlB6biuNm7SBkjEACASgcGe3YIA1Q6WRWpOYqQdMzZrt8HmRXp0RjboK X-Received: by 2002:a63:484c:: with SMTP id x12mr8322090pgk.375.1542856579040; Wed, 21 Nov 2018 19:16:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542856579; cv=none; d=google.com; s=arc-20160816; b=t1JE+ft+kh5QSkBaYry9yTXrsoCrFrO/mK2g1fgpMpLmx3wPjS1v9D/e5BVMcLATEL v1gfubk0rXiGPiCv22cXjnoWV4nTM0V7AVCaqfMM6DnYbzlERGhqvnkaVdF5pBiqhiQL K8px1J9Px4dOCndc1BrsErDKrIM66Fri0Kg/t4+MBBpHZJ83wpvpvv8K5ndfVd4kjFYL lQyWKb0F736DDfUYrNCvYAmw9X6dwkNSN3r3p7218zQAaKX27WTnOBGgXzQvJiolqejm Tu0ApVjfshM258oZtFgMyYEzhXYg8mqBfvhxlC+VGPYmg71tjpqh1gmIQu0UM8l1nxq0 iKtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=x3RMZ9Tqg5MU+iTt+DglkqSPPJ9lbOgnYuS4GLTL234=; b=ocmJPM09A5RSVAAFYlrPlD2HctOVWSCbAzTFW4d+M0XU9bDy3YT8UJuRwRpufYvejg fsIhMK6cawTsY9BLUpcxjQx5kB4KF0wyuiEUMBByqA0yrfvp2OLeJZK5PW7znRpjB+g5 mT//AvyQa70hBPVdtL284D79qJ8z/ksx5/k74Ef9xBRQEuli0ZghehKMCKuJ1DRVUei/ b1HNW++HfhDhra4tZVfbLpEgMx2g9D/+lQVXPJ4aJLKTfptSve6i9oAzREo1NPZgDJEy sJzy8RQtfOrbQbm3qN3zqsKc+GVNOPR5AIAUkrMl4F/Lkfc7tjS9+BJZkC391zERTKy2 wtZw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si15543970pli.284.2018.11.21.19.16.03; Wed, 21 Nov 2018 19:16:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389066AbeKVGr4 (ORCPT + 99 others); Thu, 22 Nov 2018 01:47:56 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38070 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389024AbeKVGrz (ORCPT ); Thu, 22 Nov 2018 01:47:55 -0500 Received: by mail-qt1-f193.google.com with SMTP id p17so5237426qtl.5 for ; Wed, 21 Nov 2018 12:12:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x3RMZ9Tqg5MU+iTt+DglkqSPPJ9lbOgnYuS4GLTL234=; b=PqDNJk7zZcwD+bJ6BG2+XL4fWLaFtafc7pqyeCJ0uI43SkV8D4dlPk5LdWJBY+DQvd ELqxhRs3dobXcgegUqI4WjrARH/q4ewnbIau9fCnUK5jlDiE/qXVs/bW1mq2OT5/9fao TlCOPqH3NcjvJHYoVfXL9v+x/mOkxmLxQQqFrX8aBdrlF1/Sfff3toZYdVwrx2K7Rkaf fqXqq5WR+o+Z9TP4//kmS1mDhlZrSl9E/d2vJhuCEPrxnvuRbH8c4O33nkZzwNbRGBSW Ja7JzU6h6ahun4z0WNuxdUwPB9WB8/eJi5k0prW91hZNf1h5Q9RogWar2c518Liq0Tgp JcDA== X-Gm-Message-State: AA+aEWbG7YUlRwrQEBBW6OAzqr44xl70amw4qMZCdLi7HzaO4wBDm9xB gcH8EohGnMMWnhKIp3HVJ/Tox9BD2LlLCP1ay2M= X-Received: by 2002:ac8:7451:: with SMTP id h17mr4187549qtr.319.1542831128830; Wed, 21 Nov 2018 12:12:08 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: From: Arnd Bergmann Date: Wed, 21 Nov 2018 21:11:52 +0100 Message-ID: Subject: Re: Misaligned Access To: Vineet Gupta Cc: Vitor Soares , alexey.brodkin@synopsys.com, Joao Pinto , jose.abreu@synopsys.com, "open list:SYNOPSYS ARC ARCHITECTURE" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 8:42 PM Vineet Gupta wrote: > > +CC lkml, Arnd : subject matter expert > > On 11/21/18 10:06 AM, Vitor Soares wrote: > > I use the follow function to get data from a RX Fifo. > > > > > > static void dw_i3c_master_read_rx_fifo(struct dw_i3c_master *master, > > u8 *bytes, int nbytes) > > { > > readsl(master->regs + RX_TX_DATA_PORT, bytes, nbytes / 4); > > So the semantics are reading the same fifo register N times, to get the N words, > hence read*s*l is appropriate. That however expects the buffer to be 4 bytes > aligned, hence your issue. You can't possibly use the reads*b* as we want the > > The obvious but crude hack is to use a temp array for readsl and then copy over > using memcpy, but I'm sure there are better ways, @Arnd ? To summarize is issue is > a driver triggering unaligned access due to the misinteraction of API (driver get > an unaligned u8 *) which goes against expectations of io accessor readl (needed > since the register contents are 4 bytes) Is this again on ARC or some other architecture that cannot do unaligned access to normal RAM? On ARMv7 or x86, you should never see a problem because the CPU handles misaligned writes. On ARMv4/v5, the readsl() implementation internally aligns the access to the output buffer so it will work correctly. Arnd