Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7084037rwr; Wed, 10 May 2023 03:47:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73Ljn12kmmIMKMcguuH/8Rng3PBNBVe7lKfcy8+2qO7ckEbMZ0HabvS9/PlexoyaDe0W3P X-Received: by 2002:a17:902:eccc:b0:1ac:b449:3528 with SMTP id a12-20020a170902eccc00b001acb4493528mr1932647plh.46.1683715621089; Wed, 10 May 2023 03:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683715621; cv=none; d=google.com; s=arc-20160816; b=JyeAklrL1PnsrQzlMQjxVSNxXgWp3KX5/A7scze2P87T/HEoxwGhdBaSI8C11gJ2yL O8ktAb8m93EFOstypmyCHPJlj/cnNXXuswjgwHtymDOMq+LfIZHR3VJv3Vaaj53nh5M2 tzu8divuiHT+S2TcUQaOcXXvASuaig0635uBKaUO0tWXWAUJHwKXnNp3ARPlGTxIwnzl NtF7S2eLE3tNh0uil9/9Oadly5ekzJulqZ4uTaTAXAEZGtnEocAx+b1fGsfqPlALu+Tf CllEnJczfw9wUoa0Bs0yxdAYkfeqZ8szPEV4TNWWICBn+Xxqcc0MPlA7sebcoIhGRylc dlzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=ic5OlChHh5HSjj+lhNLVRYkjQWdeZjZqEBTx+sSAjoc=; b=Ak08/09Kwb3+bnd02LeKG00Zxi3WD+dT38uTyxhjjpnrNe5zCs1euPo67E8q9b03vr JSqdSQWrVF1o3QIJzIPua5nslOAWtajIMnl36Bk/DC/uWPZHCCsEdgDsF7M9jQR6k5Vv UFzuOf83OS5SkVuL5fNpECAZDIHJnjf3r8mEYQg5cnc5hTJv3Ykmbcp5GyhnUZBmHotc rKfoTiC03inEmAgc6ZbEIFizp3Hb0YZtRQfXBePxkMlq3MbZCiGHCkeMyHp3VIhAMuIc eyTp/Ny32GYBrc2pQTFitHEKJqDiDyY4KhYVAEDLEKi8oiYWk9jBYZxnEGIb5NqTvDpu r18A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a170902eb4200b001ac95bf7229si3768153pli.190.2023.05.10.03.46.45; Wed, 10 May 2023 03:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236451AbjEJKNT convert rfc822-to-8bit (ORCPT + 99 others); Wed, 10 May 2023 06:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjEJKNS (ORCPT ); Wed, 10 May 2023 06:13:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 978292118; Wed, 10 May 2023 03:13:12 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4BE051063; Wed, 10 May 2023 03:13:56 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 217DA3F5A1; Wed, 10 May 2023 03:13:09 -0700 (PDT) Date: Wed, 10 May 2023 11:13:06 +0100 From: Andre Przywara To: David Laight Cc: 'Maxim Kiselev' , Icenowy Zheng , Samuel Holland , Mark Brown , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , "Paul Walmsley" , Palmer Dabbelt , Albert Ou , Cristian Ciocaltea , Heiko Stuebner , Maxime Ripard , "linux-spi@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-sunxi@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-riscv@lists.infradead.org" Subject: Re: [PATCH v3 2/5] spi: sun6i: change OF match data to a struct Message-ID: <20230510111306.52e30f26@donnerap.cambridge.arm.com> In-Reply-To: <1592f46b0f794b24a87a964d7208da68@AcuMS.aculab.com> References: <20230506232616.1792109-1-bigunclemax@gmail.com> <20230506232616.1792109-3-bigunclemax@gmail.com> <702d085b3b814759a344886364c518f8@AcuMS.aculab.com> <1592f46b0f794b24a87a964d7208da68@AcuMS.aculab.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 May 2023 08:55:27 +0000 David Laight wrote: Hi David, > From: Maxim Kiselev > > Sent: 10 May 2023 09:34 > > > > Hi, David > > > > > Is it worth doing a structure copy at this point? > > > The 'cfg' data is short and constant and it would make Sorry, I don't really get the reason for this. Since the data is constant, wouldn't it make much more sense to keep it there in the const section, which we need anyway? What would a second copy bring us? > > > the code that uses it smaller and faster. Smaller: Do you mean the generated code? Not sure that really matters, but your sketch below hints that the C code would get larger, more error prone (you mention yourself that you skipped over the error checking) and most importantly harder to read. Faster: Do you have numbers that back that up, or does that solve a particular problem of yours? This is programming a SPI controller transfer, which runs in the vicinity of a few Mbits/s. I doubt that saving a few memory accesses (once per transfer, not per word) matters even the slightest? The actual MMIO access to program the controller registers already takes a few dozen to a few hundred cycles, so I doubt that doing a struct copy saves us anything here, in practice. Besides: Copying the pointer is the most common pattern in the kernel, I believe. I just sampled 21 SPI drivers in the tree, 17 out of them do this. The other either copy the members of the struct into the driver data (which would be an option for us, too), or immediately consume the data in the probe() routine. If you have some good reason to optimise this, please send a patch (on top). Cheers, Andre. > > > > I'm sorry but I don't fully understand what you are suggesting. > > In patch 3\5 we extend the sun6i_spi_cfg structure with the has_clk_ctl field. > > You are still only adding a second integer. > > I'm suggesting that instead of sspi->cfg being a pointer to the > config data it is a copy of the config data. > So the assignment below becomes (ignoring error checks) > memcpy(&sspi->cfg, of_device_get_match_data(&pdev->dev), sizeof sspi->cfg); > and the code that needs the values is: > sspi->cfg.fifo_depth > (etc) > > David > > > > > пн, 8 мая 2023 г. в 12:47, David Laight : > > > > > > From: Maksim Kiselev > > > > Sent: 07 May 2023 00:26 > > > > > > > > As we're adding more properties to the OF match data, convert it to a > > > > struct now. > > > > > > > ... > > > > - sspi->fifo_depth = (unsigned long)of_device_get_match_data(&pdev->dev); > > > > + sspi->cfg = of_device_get_match_data(&pdev->dev); > > > > > > Is it worth doing a structure copy at this point? > > > The 'cfg' data is short and constant and it would make > > > the code that uses it smaller and faster. > > > > > > David > > > > > > - > > > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > > > Registration No: 1397386 (Wales) > > > > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)