Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4965293imm; Tue, 7 Aug 2018 10:13:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpco4KhimWMkyJfOPk9MG4ls6odcSfYiN79ER29UcHwbpNsiMZuGrupfMaYw/RCblw02yOeZ X-Received: by 2002:a63:4d06:: with SMTP id a6-v6mr19375046pgb.408.1533662007879; Tue, 07 Aug 2018 10:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533662007; cv=none; d=google.com; s=arc-20160816; b=dfJhUwySewSjI6jMVsQdlcqUsjwvVH93N/hhf4aGkdJ8q/XApgcYFeY0pH5lQphare 305QC46HBNSmF8F24q98POD0uMKOdTuDH6Y/P6r2nGHDp5ZhQ7lmR+ag91U84RgtxFlu bfHmSIoahntrNQB8JkKJcjsFUIJK3Sr7dWNPUlzKkZMuv62Q45c1aP+GeB4ttlNJ1FQN YGYf9q+F3ZEtq9mRy6HYXfLcX+mHRHpXnbS0B6la+zvzI5IOpz72tGmt8FbMkne/nfrz 0jOdjK2EsjhIKi8dNvM19Ze6jSkf4ikQGaFyLPFcUA1ZF6zJsad47t9FdbqrlduM5Pt8 0lfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=iALAG52SDbrvEqywDaeJu1WeLAt0pVh1FjVsg/6JQiY=; b=cREcwCZiFI3O285VYidWwg9NxwMvUEwVsNo5PgOADYShTqCuL+/66jOyxc9mUO9ug9 CsnS2mk7r626f/WeYbwY/d0v8Zo6ZrNGmaivCZXtKJ2bMf9RpqlmLL4y2rmkGVHaSAX+ rHSPUGjr3blRBZ608M0ZZ9638PZ7JytpXuP0dcYCDlAFzOZ6agMSsj81rjrJEwqUGZqm Sh/2U2ElT7w5FgXPy3J9Yy1uhTv/F+ZEGJzrdMouHK+HuXPn2p2C27Tev4UW+4/ruyFq aODbsPZKYgq95yfNk5ezZxEwOY6CJLt2J7rDLaYk90QCc0eqNH4W/SNY/8qIUb05yfW+ G5aA== 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 h90-v6si1362566plb.484.2018.08.07.10.13.12; Tue, 07 Aug 2018 10:13:27 -0700 (PDT) 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 S2390123AbeHGT0Z (ORCPT + 99 others); Tue, 7 Aug 2018 15:26:25 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36790 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388706AbeHGT0Z (ORCPT ); Tue, 7 Aug 2018 15:26:25 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id CD33320789; Tue, 7 Aug 2018 19:11:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 1C5A02093C; Tue, 7 Aug 2018 19:10:42 +0200 (CEST) Date: Tue, 7 Aug 2018 19:10:42 +0200 From: Boris Brezillon To: Janusz Krzysztofik Cc: Linus Walleij , Jonathan Corbet , =?UTF-8?B?TWlxdcOobA==?= Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Mark Vasut , ext Tony Lindgren , Aaro Koskinen , Linux ARM , Linux-OMAP , linux-mtd@lists.infradead.org, linux-doc@vger.kernel.org, "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH v2 09/12] gpiolib: Identify GPIO descriptor arrays with direct mapping Message-ID: <20180807191042.0204909a@bbrezillon> In-Reply-To: <1793769.2WP40jSPqy@z50> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-10-jmkrzyszt@gmail.com> <1793769.2WP40jSPqy@z50> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 07 Aug 2018 18:50:22 +0200 Janusz Krzysztofik wrote: > Hi Linus, > > On Tuesday, August 7, 2018 1:29:43 AM CEST Linus Walleij wrote: > > Hi Janusz! > > > > On Tue, Aug 7, 2018 at 12:29 AM Janusz Krzysztofik > wrote: > > > > > Certain GPIO array lookup results may map directly to GPIO pins of a > > > single GPIO chip in hardware order. If that condition is recognized > > > and handled efficiently, significant performance gain of get/set array > > > functions may be possible. > > > > > > While processing a request for an array of GPIO descriptors, verify if > > > the descriptors just collected represent consecutive pins of a single > > > GPIO chip. Pass that information with the array to the caller so it > > > can benefit from enhanced performance as soon as bitmap based get/set > > > array functions which can make efficient use of that are available. > > > > > > Signed-off-by: Janusz Krzysztofik > > (...) > > > This function returns a struct gpio_descs which contains an array of > > > -descriptors:: > > > +descriptors. It may also contain a valid descriptor of a single GPIO > chip in > > > +case the array strictly matches pin hardware layout of the chip:: > > > > > > struct gpio_descs { > > > unsigned int ndescs; > > > struct gpio_desc *desc[]; > > > + struct gpio_chip *chip; > > > > This must be motivated: if the only purpose is to indicate to the consumer > that > > all GPIOs are on the same chip, why not just have a > > > > bool all_on_same_chip; > > > > That you set to true if these are all on the same chip? > > My approach would probably save one or two instructions per get/set call, but > I'm not stuck to it and will be happy to find a better solution. > > How about folding the chip descriptor inside an additional structure, private > to drivers, with internals not revealed to consumers? Or just get the chip from gpio_descs->desc[0]->gdev->chip when ->all_on_same_chip is true... That adds 2 dereferencing though.