Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1011097ybv; Fri, 7 Feb 2020 12:36:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzMX/QEl97kQOHgUre1WJTM1yRq9B1JkjHDCCT40ZyRpQoysukeLL4MEeMXkYinHAmuGKcM X-Received: by 2002:a05:6830:1353:: with SMTP id r19mr969207otq.288.1581107808923; Fri, 07 Feb 2020 12:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581107808; cv=none; d=google.com; s=arc-20160816; b=wn6BxvSmRTndf9jhDyNjD6THPNyPnj8xCNytd7jnpwv1lnUdegPb2yCPPsxNigeOhd 8funYuNEt2G4G8PJrDTeITo+lGQtNNH/tHVmmTUqeTcpZ3mTIzH1Xh0TEtampOYg74Ig MgL5bWOLeetxHpuruCfd929NqoPKG6YE87FqS5V/CaVnafgb7SNyaTVifjBRtIj5EQkP Su7ywSNuorIjsgJ6Jh54boozpwk2OmFLkPF+d9DxooCDKIzvzdxpUTyXXEc0+EpdTwh9 FheDHi/U/haiQN5GnrAQe9zSBNanJxdns589TLflYgS0z3pGCympAv6jdTCLvYSe/WAq OknQ== 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:dkim-signature; bh=CPHWMcpySeg2md9hRvh4nN53ZKbWdcZQ7Q42r2DM3hQ=; b=oYkSPZOI86UK+AoGD9iYooYYKMIyUrTaNsEvecltpgk0hD0HuBLMfzB0Dgj6gFjeFW TGjMyXjc8V6KuwkoBPVjqm5Fm9CcYkutAPmRb2vzk6i528DPPxUD8bAds0zOjMD2pLfD bMDwwLKZYDd9/SnZOxwmoDmyEceuroHXJVQTPdD31Sbda9QGt1fGwkcmWucWskT+w66O KY/xpL+4D9DAiRIouROW21oBUFFEycBjDzj0a5Ioy8HOsztbZab5Ze/XiVSOqAspStgG lhbVH+WQskMOu25gqFMAEZZk6K3cY/+5UKkZpxGdLGqt9Z9fmfSkxpVk4blJvaxP7f39 hhPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qGoYo7eD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si235463oti.47.2020.02.07.12.36.36; Fri, 07 Feb 2020 12:36:48 -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=@gmail.com header.s=20161025 header.b=qGoYo7eD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgBGUe0 (ORCPT + 99 others); Fri, 7 Feb 2020 15:34:26 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32920 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbgBGUeZ (ORCPT ); Fri, 7 Feb 2020 15:34:25 -0500 Received: by mail-pg1-f195.google.com with SMTP id 6so385200pgk.0; Fri, 07 Feb 2020 12:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CPHWMcpySeg2md9hRvh4nN53ZKbWdcZQ7Q42r2DM3hQ=; b=qGoYo7eDVXz+tTgVmwGzojl5oRZkZGp/aJnTH9QzgAejALP7c/LUCtfsi2h/7qVAl5 86HkC8YMssBrgzMiYEbCe2OjX/RKo5M/hoAJlFazVVK1u1CuE4mC5baY+JnhrPswTtwt +Fsll3ls4D+1ld2XksqQEj2aDXPnWrcYCQS9y8iRIEoMr+xI87UGwI9qtMhlsAO4u0sM LhZDNqt9gWAgIvShf4q09rsQ4d+Jpo66gm/jtCWUvx5IerrvBlQ2NaqIEXpYLzqtuKTu NTWFldhN9qX7+SWfGqUSBnNyHkDOQAzvi2ibHwmZ2KW/c8/jShH4T1fv7fyoQsvYOAd/ 0rag== 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=CPHWMcpySeg2md9hRvh4nN53ZKbWdcZQ7Q42r2DM3hQ=; b=lKE0v31QXgK14GOdSucNRV7A2WvH2fggCoLYO1ecsJrDQtXWJZJeCh01tJoivRu/nA Aj2fZ8+YJQPWH5b4862o5Z61WF8zmeVRkxcgmnLfOEyoQXbOrqp5ONx7fpXAI22IeBbS cOk0V+HynXWWEukCsWnmVu/irP0maOSoFpWn1EtO5hUzDy3P98GyQujhynvBln6OQUv0 p70wUliUWvfu8C1HtGhWBIfd7KAWOx0J9qZwlHpnFeSfJy6z6VQGZHaBP45dBD5jWWPL tbBqe0ODlI1lI24bWKdH8+sp6ugzY1jbjXSj1qieG8cIqZcAQU4TyFrFobzUmHqIBDjx Xfag== X-Gm-Message-State: APjAAAWIsrT5F7KyQUBgVoJJqI9oZAxDV8Qn24bp3BbJ0QeGULXCvL2T gSjvAaCYAHnpk7rXCY/lxOb6d84HDgVjWP4BQtc= X-Received: by 2002:a65:5242:: with SMTP id q2mr1016240pgp.74.1581107665130; Fri, 07 Feb 2020 12:34:25 -0800 (PST) MIME-Version: 1.0 References: <1580328504-436-1-git-send-email-eajames@linux.ibm.com> <29f6cc86-69ca-bc88-b6ae-2b1a24c0dae3@linux.vnet.ibm.com> <744f0019-8656-eec1-cb9a-7e70cd042587@linux.ibm.com> <90973143-bd0a-33cf-9eb8-a83be1a9b415@linux.vnet.ibm.com> In-Reply-To: From: Andy Shevchenko Date: Fri, 7 Feb 2020 22:34:17 +0200 Message-ID: Subject: Re: [PATCH] spi: Add FSI-attached SPI controller driver To: Eddie James Cc: Eddie James , linux-spi , Linux Kernel Mailing List , Mark Brown , Joel Stanley , Andrew Jeffery 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 Fri, Feb 7, 2020 at 10:04 PM Eddie James wrote: > On 2/7/20 1:39 PM, Andy Shevchenko wrote: > > On Fri, Feb 7, 2020 at 9:28 PM Eddie James wrote: > >> On 2/5/20 9:51 AM, Andy Shevchenko wrote: > >>> On Tue, Feb 4, 2020 at 6:06 PM Eddie James wrote: > >>>> On 2/4/20 5:02 AM, Andy Shevchenko wrote: > >>>>> On Mon, Feb 3, 2020 at 10:33 PM Eddie James wrote: > >>>>>> On 1/30/20 10:37 AM, Andy Shevchenko wrote: > >>>>>>>> + for (i = 0; i < num_bytes; ++i) > >>>>>>>> + rx[i] = (u8)((in >> (8 * ((num_bytes - 1) - i))) & 0xffULL); > >>>>>>> Redundant & 0xffULL part. > >>> For me it looks like > >>> > >>> u8 tmp[8]; > >>> > >>> put_unaligned_be64(in, tmp); > >>> memcpy(rx, tmp, num_bytes); > >>> > >>> put_unaligned*() is just a method to unroll the value to the u8 buffer. > >>> See, for example, linux/unaligned/be_byteshift.h implementation. > >> > >> Unforunately it is not the same. put_unaligned_be64 will take the > >> highest 8 bits (0xff00000000000000) and move it into tmp[0]. Then > >> 0x00ff000000000000 into tmp[1], etc. This is only correct for this > >> driver IF my transfer is 8 bytes. If, for example, I transfer 5 bytes, > >> then I need 0x000000ff00000000 into tmp[0], 0x00000000ff000000 into > >> tmp[1], etc. So I think my current implementation is correct. > > Yes, I missed correction of the start address in memcpy(). Otherwise > > it's still the same what I was talking about. > > > I see now, yes, thanks. > > Do you think this is worth a v3? Perhaps put_unaligned is slightly more > optimized than the loop but there is more memory copy with that way too. I already forgot the entire context when this has been called. Can you summarize what the sequence(s) of num_bytes are expected usually. IIUC if packets small, less than 8 bytes, than num_bytes will be that value. Otherwise it will be something like 8 + 8 + 8 ... + tail. Is it correct assumption? > >>>>>>>> + return num_bytes; > >>>>>>>> +} -- With Best Regards, Andy Shevchenko