From patchwork Mon Aug 6 22:29:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4842C13AC for ; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 323D729A7B for ; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 250FD29A91; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5A0829A7B for ; Mon, 6 Aug 2018 22:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LvpIMVNbrb0npfQDu2oNJ4/DO41jdsjN3PoQgystWoc=; b=akpSGAj6LZK1Hx7zltbIZgPN10 JGT7il7QhuRk/sIvh3lvaEdMGnUwgCNkpqLhOFG/FVgax6tdRw/SSqq4eZgiDyG1RQCrvPjX92Wlx UphgFCAGhyHNvtOke7br0PKxVs6NHTCPvVRRQQcIPjyfD8oNIqP4p7mIjaQVzErwYd5JHCYeKFRqG lS+O5iOm9GOHSJZIv7hqpfzWp6mwJ9NdLssKGtST0uc1fh8SpaA1G51CM/w31PO6N3SG1y/eBqLZZ y8X2QkA+zjWLrOE3eEPQ9gFfUfpDAhfYghxXGAcQsasMiJ+9iVRfDP0fMfdx/XIN5PC4J8ECrseXb j1JpKsJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmoAz-0001Lq-EM; Mon, 06 Aug 2018 22:40:33 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005UC-Qu; Mon, 06 Aug 2018 22:29:55 +0000 Received: by mail-lf1-x142.google.com with SMTP id y200-v6so10196921lfd.7; Mon, 06 Aug 2018 15:29:46 -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=LSzeC+613z5xhRugtzI0fegvYRIPDJinO54GASqfKaJS7ZbsIzLNFq8aGxHuOqEXjt oOYSKgPUnCODYK8WKXCP7uTF+nyXU9tkgpNCjPm2HmpBit1t720G6+stYrH+QzeqS6SO P9qYM62RANX8sULuWi44pSXSBKErx6QIiHn8oG5LhWqqxdfqfFQMo4mbgkeErwy+743P XOqYSTFAGdvtugyw8u6XUb/DLB1bE/qYP5K2oh43+ZoYkxd56YtZdyo4U2p4juP8uYVB 6/sUEpl1kaVqXeibFWgPOTl0Ib/wmziK7EIWkjvwpKKApjPlc0JeR/OpNCDUwd8U8Cum Z4HQ== X-Gm-Message-State: AOUpUlElXPIKn3ZG4UAbONQ8V8zsQLIUjeEoqB07jYTWBr+beZEkd+cd f1XSPdvZkuy0pNVBKBMpiuA= X-Google-Smtp-Source: AAOMgpdOVignCZnEeCBAFO3oZT9ssWE7eymuQTN++pgaa4W5/B4vcnak1+wEbM2FXkRJkCqWvtg9Vw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152947_311908_253BDB98 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);