Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4036840imm; Mon, 6 Aug 2018 15:33:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfsgyRFKD8QMj4fWS7qUqsLgrLLAi9ZcOgngdP2Y0JPT78cSo0wJSMFDDrh4+dDa+MS39tV X-Received: by 2002:a63:375b:: with SMTP id g27-v6mr16250835pgn.59.1533594801823; Mon, 06 Aug 2018 15:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533594801; cv=none; d=google.com; s=arc-20160816; b=kqPZWaN04iMJypAS5V2V8HXedsqC7//w28tL+FjV1BAY+kdlzEM1HEZokLnOfiVmo7 Eg8bnOnF6RCd5of8XChdO8SxYVSpdn6vtg0cFJ2r3038CzWwXFO1baQpd5yKbGbW/ZwB SFFsLNrkGJw8tgz6ZF2kKQ+z6/5l5n2J51DtcQaSgHoRSnkJ4hMJdEMAIYWufXhXplRH dELovCCqqCrqUqX60cIIEtZxzcn1e7ofzYsGmRwPEeT4NKY/erzQDSFLdjDv4+1Jyrt4 0m8YGLpl0L9CeNLWioy3dyVYLpy+hJp1lY+Wqycmw6hRBtu56JZATYihVdYL4Vf/6ovy bdRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=UZjTLX7QnQr/t1695VcV1KTsYiUTLZK2WnrZPxW0nQ0=; b=P0DCM+8pMY+YCVk8Owhr1b2dIFSKCshmO7n4ZR+npo2Bbs3xnqS0q3DKIuh/C9LOcd 0fhtNBCtfwmxV4cxk6nVbPldlfYcSZ3xcYmC6Kx2XrLd8vYIcgH6Fsubz0YfLc/6InJL cNks73M7tUBroXZo+2fPnvU6X3ZKuP5TuIfJRk28JsMSMKhWAxj0I8z4DBRl+zafv1Jv oxdXfgk+chN9i+IJMHH9Eiod8jkOkpDNPQOXUOkU5hJ0IJbo7YDVXcePjT7Y/R8CMayd tZByg84Wj2EOBBiPlLovQ1gfHuHTtKHzplg5Vb/OtTTjXQvGXp2y/ZiRQL2R7AG6nAKe kCfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f4TupVyG; 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 q4-v6si10643612pll.156.2018.08.06.15.33.06; Mon, 06 Aug 2018 15:33:21 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f4TupVyG; 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 S2388324AbeHGAk6 (ORCPT + 99 others); Mon, 6 Aug 2018 20:40:58 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45369 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387889AbeHGAk5 (ORCPT ); Mon, 6 Aug 2018 20:40:57 -0400 Received: by mail-lf1-f68.google.com with SMTP id j143-v6so10188048lfj.12; Mon, 06 Aug 2018 15:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UZjTLX7QnQr/t1695VcV1KTsYiUTLZK2WnrZPxW0nQ0=; b=f4TupVyGulWb3GeTA5wNIXDgA28jrcBpoND1Ko4n43chjDMerygFxt+GgpBmhCWCEh K/A8/d6es6eXkmxlKoHfZjx30fvveGPjnB182ekcFQetalYPOaF4T9hu0nUk85K7igRD pFaf34gyE0Zk2i1ShroXnPSN5wopTGpVpI1c/n9zik+LN0rqjfs7uR3Gro5ITP9UccJk gxvw9AxP+3OeRFlgDcpoSvLkaHLUAWI/ABqKHR/WspP52lLK5uBZn4q3a4MufOHAaCYx pZWK2+kUNIZ1qoXXJfb7/ohkBoX7If/OVQRjuGQrfmXfv5c61AbP5/BLb6/0Yc4wYlwU kEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UZjTLX7QnQr/t1695VcV1KTsYiUTLZK2WnrZPxW0nQ0=; b=Jqvi0lJmOaw9wwXyL5s6YI8thPaE609XO1MbjkhBSqG3Z3bI50y4vXx0bBgZUiLVmt T2LDfqv54dop88CTQtQuNtAjGEi59CA4Iyr7hbtgl0Gr0TXz55b56+dozqHvgSaeKjqK DG+1GNJeecByF0mlSRvC3YiMEBdJJDLCAyemMp86oJqDAWv+tCDavpPRoXyNyyKsCQeE qQn1bLHmqMM6v6pwBagIlXsuO3omc9SdM+7v9izBYtLTGIuTRZSgJ8KN4kXAYQUZhkuo +eLVRjI2FAsLiyv3f9dkZkrwQomW1h4lR4PbT/403TWxDW1BpMeuR42VPtQzQ+Spe/aF 7Cyw== X-Gm-Message-State: AOUpUlH8ulOhm8PMKoyMAmlFCnh8XYZHTz5aauMgUGZgSuVZ0GosOYj6 438obxVcwm5+iqAFeNt7bgQ= X-Received: by 2002:a19:5a56:: with SMTP id o83-v6mr11909803lfb.50.1533594584634; Mon, 06 Aug 2018 15:29:44 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:44 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Cc: Jonathan Corbet , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tony Lindgren , Aaro Koskinen , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, linux-doc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [RFC PATCH v2 12/12] gpiolib: Add fast processing path to bitmap API functions Date: Tue, 7 Aug 2018 00:29:18 +0200 Message-Id: <20180806222918.12644-13-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Certain GPIO descriptor arrays returned by gpio_get_array() may contain information on a single GPIO chip driving array member pins in hardware order. In such cases, bitmaps of values can be passed directly to the chip callback functions without wasting time on iterations. Add respective code to gpiod_get/set_array_bitmap_complex() functions. Signed-off-by: Janusz Krzysztofik --- Documentation/driver-api/gpio/consumer.rst | 6 ++++++ drivers/gpio/gpiolib.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index bec4eab3b87c..b82f134dc352 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst @@ -409,6 +409,12 @@ descriptor arrays, only those of type struct gpio_descs returned by gpiod_get_array() and its variants. Supported array size is limited to the size of the bitmap, i.e., sizeof(unsigned long). +If the .chip member of the array structure, filled in by gpiod_get_array() in +certain circumstances, contains a valid GPIO chip descriptor, the raw variants +of the functions can take fast processing paths, passing bitmap arguments +directly to the chip callback functions. That allows for utilization of GPIO +banks as data I/O ports without much loss of performance. + GPIOs mapped to IRQs -------------------- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5b541364dee0..bf95f2964bc5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2846,6 +2846,12 @@ int gpiod_get_array_bitmap_complex(bool raw, bool can_sleep, if (array->ndescs > sizeof(*bits)) return -EINVAL; + if (raw && !IS_ERR_OR_NULL(array->chip)) { + unsigned long mask = (1ULL << array->ndescs) - 1; + + return gpio_chip_get_multiple(array->chip, &mask, bits); + } + i = gpiod_get_array_value_complex(raw, can_sleep, array->ndescs, array->desc, value_array); if (i) @@ -3156,6 +3162,14 @@ int gpiod_set_array_bitmap_complex(bool raw, bool can_sleep, if (array->ndescs > sizeof(*bits)) return -EINVAL; + if (raw && !IS_ERR_OR_NULL(array->chip)) { + unsigned long mask = (1ULL << array->ndescs) - 1; + + gpio_chip_set_multiple(array->chip, &mask, bits); + + return 0; + } + for (i = 0; i < array->ndescs; i++) value_array[i] = test_bit(i, bits); -- 2.16.4