Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1752605rdb; Wed, 31 Jan 2024 08:05:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IExkDW7Zfsm0pZg2gwjdIjVF1XulbiDiD/zhe1t81dp5RVeK0V/MGW7bqFKF9/P8syMlHfM X-Received: by 2002:a05:6a00:2e98:b0:6de:1d4a:c22c with SMTP id fd24-20020a056a002e9800b006de1d4ac22cmr2525287pfb.0.1706717109976; Wed, 31 Jan 2024 08:05:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706717109; cv=pass; d=google.com; s=arc-20160816; b=u6pCpuj8U5Q7fL1gvEhEiQTyiMD0NBGjmvYMDrrb/nkHqxqlJb7wOlNWFMlIsQO6ww Cj6m98yinmWRH1uAPIv668LFlna82ZBe9MM9ShPseWBnTCqbJNrk3lZE54pStj1/DFQi 48+XCwvckVVf4jm+H7b5hymGbMResnjJxvlBElgc0PIORJvy+RnWXN9RcXLygZ8fycLn PxH4Y3uXFW6JgKTmp5xGG8fB2BohehdwVwj4Na0OJYMGoI8SKv5AhpHiVkj3H3WKdNla 9U27OaAtqSKpZl2DX/vYfq3EbiJhTzB8b2GdNxot5NhJCsoe2MHmQsbr0sBCOtoRhYZy UjWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9zRUek2aBogSyzaUq35rUcFSlWZ+bDNLWJplCN5AqvU=; fh=T3z7bmxLspyKTUEuBLBvNTcFah51XmNNT2f0se8EFqM=; b=RpVNy62iC+2omluYOwRjO9IMQZYmKQP55/6OaZhCVkOJoRalg+3eW6e3w3wASvWQlC T0qnFDTmcmqQ779QcAhOmGEHhwQGEwnb2CObd4NqgaUNk2D0TPW7OAG37S1mMCwDMOUN QIuAAb95Wim5wmU4n4rHNXDM75QKe7Ji+QpMkBaZE3PzJy6fvMleN95i7YElJzzdGNGl QM7XVr/DriJrcTlE8so6OwE1K9ZcEXhfw32zk7YklalyQN2qc2qdrQ+acC7uGUQHjMAK VTA01ANUPUUNmriJQmFlepE90ycGEO+YbixIN1/OeNFMRN5CQi58rOOXjaosv007FZcZ F0tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=kf3hVBn4; arc=pass (i=1 spf=pass spfdomain=opensource.cirrus.com dkim=pass dkdomain=cirrus.com dmarc=pass fromdomain=opensource.cirrus.com); spf=pass (google.com: domain of linux-kernel+bounces-46731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com X-Forwarded-Encrypted: i=1; AJvYcCVANSV8YxxBl2111Zh7XJf1XhNfz/hyCZ/EY04NQk9iydpzYZZTrAYTpxbvqKwqxu1LjhCJlMHn7L216dForlAIwo3BAzZFLGtC52VXgA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lm18-20020a056a003c9200b006dde67a0246si9768449pfb.271.2024.01.31.08.05.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 08:05:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=kf3hVBn4; arc=pass (i=1 spf=pass spfdomain=opensource.cirrus.com dkim=pass dkdomain=cirrus.com dmarc=pass fromdomain=opensource.cirrus.com); spf=pass (google.com: domain of linux-kernel+bounces-46731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2D24CB23B06 for ; Wed, 31 Jan 2024 15:42:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9932B12A148; Wed, 31 Jan 2024 15:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="kf3hVBn4" Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E176978B7E; Wed, 31 Jan 2024 15:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706715739; cv=none; b=MNSeLpfIVfrCTGIwCzUD5M+xuTjlY0IxxjcxRge7EH9MnmMgFgH7j07ISFZZitmxZfOre33dW87LNg/uYZkbJOgOSYvUWP7LxarZHb9qMen7E504wXVXBOowln74tKHJa2Xu5OapC7iCdUFnoLUN/5+rNEU5ERWuXel8guz/qDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706715739; c=relaxed/simple; bh=ejQDb/K2pqX/zGSPCSBHEbX1yV2ewgTMosiZWj4uTBw=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R+W3SC4thgaSZj8LDP/SUwIp8oPRcDz4fwQfpAsTXDEHlWbsvSnPT9Fb+MewcyrdhjpR0hfYA7OzsFje0VLbDRb4VMosm2oxQWMB5fIkrhSGqL+ekIAtxacjyjKmlP4juSbqK02X8H+6/4cidHN5SwnJYGVIqw1iU8O7xF9Ot7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=kf3hVBn4; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V6hZO0021183; Wed, 31 Jan 2024 09:41:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=PODMain02222019; bh=9zRUek2aBogSyza Uq35rUcFSlWZ+bDNLWJplCN5AqvU=; b=kf3hVBn4657bGK2vMU8xTyDRMQHDBgR H3anUKrF9Dz5CGVcpuhAYctmIxGyI31uJYCOcX/tAbRIHCz7QsCPMQba0rdXAUyr j/aV6QrzHvDAuYLZVFS0XaujRBqrsQz85icFVof9M+MsLt9oQ7GM6MuffT/GST2W mH2v3++KgWjLaMzvJGT2nm8h6vRWCA9gVbmiLdQOSvrOubQuZaxaCSk6uh4uLZ41 qvL8Tp8YHVihJf1qppFIbvcS41KlhyIRvFF6DT03bobA9qzc9Nl1eWJ0eFs44WCV 10NdwDpC0R17N1i8IuKam9Kx6k2ULa3mjMouoWLebcTPgcZYHbfjGNw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vw043vw4t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 09:41:54 -0600 (CST) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 31 Jan 2024 15:41:51 +0000 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.40 via Frontend Transport; Wed, 31 Jan 2024 15:41:51 +0000 Received: from ediswmail9.ad.cirrus.com (ediswmail9.ad.cirrus.com [198.61.86.93]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTPS id A2CE8820242; Wed, 31 Jan 2024 15:41:51 +0000 (UTC) Date: Wed, 31 Jan 2024 15:41:50 +0000 From: Charles Keepax To: CC: , , , , , , , , , , , , , , , , Subject: Re: [PATCH v7 5/6] spi: cs42l43: Add SPI controller support Message-ID: References: <20230804104602.395892-1-ckeepax@opensource.cirrus.com> <20230804104602.395892-6-ckeepax@opensource.cirrus.com> <20240119114917.GB16899@ediswmail.ad.cirrus.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240119114917.GB16899@ediswmail.ad.cirrus.com> X-Proofpoint-ORIG-GUID: tm09R4IRvormBltDxfOzMXF9SxmrUytb X-Proofpoint-GUID: tm09R4IRvormBltDxfOzMXF9SxmrUytb X-Proofpoint-Spam-Reason: safe On Fri, Jan 19, 2024 at 11:49:17AM +0000, Charles Keepax wrote: > On Thu, Jan 18, 2024 at 07:06:13PM +0200, andy.shevchenko@gmail.com wrote: > > Fri, Aug 04, 2023 at 11:46:01AM +0100, Charles Keepax kirjoitti: > > > + while (buf < block) { > > > + const u8 *word = min(buf + sizeof(u32), block); > > > + int pad = (buf + sizeof(u32)) - word; > > > + > > > + while (buf < word) { > > > + val >>= BITS_PER_BYTE; > > > + val |= FIELD_PREP(GENMASK(31, 24), *buf); > > > + > > > + buf++; > > > + } > > > > Is this a reinvented way of get_unaligned_*() APIs? > > > > > + val >>= pad * BITS_PER_BYTE; > > > + > > > + regmap_write(regmap, CS42L43_TX_DATA, val); > > > + } > > > > ... > > > > > + while (buf < word) { > > > + *buf = FIELD_GET(GENMASK(7, 0), val); > > > + > > > + val >>= BITS_PER_BYTE; > > > + buf++; > > > + } > > > > put_unaligned_*() ? > > > > Alas as it has been a while I have forgetten the exact context > here and this one will take a little more time. I will try to > find some spare time to work out if that would actual do the same > thing, I have a vague feeling there was something here. > Ok found some time to refresh my memory on this. The main issue here was as this is processing raw data for the SPI we shouldn't assume the data is a multiple of 4-bytes. You could write the code such that you used put_unaligned_le32 for most of the data and then special case the remainder, which would probably be slightly faster. But for the remainder you either end with the code here anyway or a special case for each of the cases 8,16,24 bits. So the code ends up looking much messier. Personally I am inclined to leave this unless performance on the SPI becomes a major issue. There is perhaps an argument for a comment in the code to explain this given it took me time to remember what was going on. Thanks, Charles