Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1033071ybv; Fri, 7 Feb 2020 13:06:09 -0800 (PST) X-Google-Smtp-Source: APXvYqypzVmLeqScBhHI/bAgitbqR9Enug7TFT2BNUQGKbKMtXMLB/cSY8e4g7DOYRBiz143VVvf X-Received: by 2002:aca:c415:: with SMTP id u21mr3440683oif.49.1581109569154; Fri, 07 Feb 2020 13:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581109569; cv=none; d=google.com; s=arc-20160816; b=g0tQr+0beNlpEm+lp8zMMkL5LTVSH4gDDVpHDkix5BPt82qG3iOJFgl54yJcUGuNXp LsswgPa9ztdENpMMviqTFsq8F8b3zMyhTb2i/1Z1YpCzbFW90xXfvL4VqysBRGeEOTP7 wJ7X1Db5HfnE2IKV9IzJhb7czmYSY/ZGrwnZ9OoCD+s4N0a+Aixra5NbZ2Dn5T6PA7/j v66y0SflZLghZ6QIgbjXvd4jOplzj3S+ZUlxxNHsCx9PBW0p9Gugy3zuDki3+FjUYqaF fNhwtGyjV3AGm8vFcibzCAibDRzLsOPQG+ggZC5+JmW7i8tlAp5VZ4OO4xcP9E6YCvQj BiUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5lJt5Yzx59hF8rQdZW8GYTqEWLKS9KK0PnhyH5TCCjU=; b=fFE1Toj4go9THAI5QU7ix4ZXay+ioUuO5jEvcyPhmVaZJWSjd1lK9OO7+sQtd37o/4 AESAaMiWavsUkuJ0lhrYgy6TMvgEhnl2rBQyzGCfMwwDTzcBikvg8XjKqSN7TwKbVhW+ DD+1j85Mp8/I01ZJxTmw2ESCCYrStJh/7o7LaJQHd/MX09XRkGrfSTy14n/2G8vzLx1u 4qQvmijMkOBeBdTjYLGtOMRkeYaX1Bqs6n7KGWKh2qrOrR+iCg9a/iJYVuZfgsazGlJb CV1LD8E4+OQnEjNbeeuua6VIVTxw5hsQN/58RhQ0J8ZZ2ifP2MrQ6Bc2/g/xeSVcjIfK oU2A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k66si3872374oih.200.2020.02.07.13.05.56; Fri, 07 Feb 2020 13:06:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727076AbgBGVE4 (ORCPT + 99 others); Fri, 7 Feb 2020 16:04:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:63086 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbgBGVEz (ORCPT ); Fri, 7 Feb 2020 16:04:55 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 017L4o33091446; Fri, 7 Feb 2020 16:04:50 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y0mppsst8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Feb 2020 16:04:50 -0500 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 017L4nEF091382; Fri, 7 Feb 2020 16:04:49 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y0mppssm4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Feb 2020 16:04:49 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 017Kt7Qu025292; Fri, 7 Feb 2020 20:59:33 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 2xykca68su-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Feb 2020 20:59:33 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 017KxWoO41353704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Feb 2020 20:59:32 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C1B528059; Fri, 7 Feb 2020 20:59:32 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B712128058; Fri, 7 Feb 2020 20:59:31 +0000 (GMT) Received: from [9.41.103.158] (unknown [9.41.103.158]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 7 Feb 2020 20:59:31 +0000 (GMT) Subject: Re: [PATCH] spi: Add FSI-attached SPI controller driver To: Andy Shevchenko Cc: Eddie James , linux-spi , Linux Kernel Mailing List , Mark Brown , Joel Stanley , Andrew Jeffery 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> From: Eddie James Message-ID: Date: Fri, 7 Feb 2020 14:59:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-07_05:2020-02-07,2020-02-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=991 clxscore=1015 suspectscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002070150 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/7/20 2:34 PM, Andy Shevchenko wrote: > 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? Yes, it will typically be 8 + 8 +... remainder. Basically, on any RX, the driver polls for the rx register full. Once full, it will read however much data is left to be transferred. Since we use min(len, 8) then we read 8 usually, until we get to the end. > >>>>>>>>>> + return num_bytes; >>>>>>>>>> +}