From patchwork Sat Dec 26 06:43:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11990257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED702C433DB for ; Sat, 26 Dec 2020 06:45:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A55A7207B5 for ; Sat, 26 Dec 2020 06:45:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A55A7207B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2MR+5H6MmGP5vsJ4dEB1hO6W/ep7B5GbWQHmRRwbHMw=; b=EmqmAj8z5ojR6Bxr576zH3UZr AHcactQv4YD/g+ZkcAggZPPaQ0cPjZVarHW9aWHq4gVA00tXxx6T+7iwZHFpSIRS9qv/9mjQqBrpB 1xtkrHApg+3TpJ8mSQLImDXJyJnOyrhez/tY3SO4Ifl8lNQec1qcdO/yfjRODpvQdcAMZEp8oofN3 GUlqLzwNyiC9B1OghXj3nzap3XIXa5r6FYyUntwUMfIS9ty/9gJVjbUFh9BfbApMZ3Kn1LgauhiN2 1CNQlPcKdzdYJT1R+hDFF05JhcddN9QRjvYdQgrlKXs0YXuwEurcCQutzmxG9m5HZPT6Prs91uYSX FTLmuqZyA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kt3JO-0007Bm-RA; Sat, 26 Dec 2020 06:44:22 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kt3JM-0007AZ-98 for linux-arm-kernel@lists.infradead.org; Sat, 26 Dec 2020 06:44:21 +0000 Received: by mail-pl1-x634.google.com with SMTP id be12so3200697plb.4 for ; Fri, 25 Dec 2020 22:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iXNqUNlDxA192iSDhXK8T34CWCe+lAvUgPxne7auzLU=; b=X3VqkGTtPHgY1bRWcNfIIEzEkd4CnRBVwL6y4V5NGTcXyshWxpSPWcwaHQU8OKHq6B yBpnK5X5s/GS0m91eQwyqhsBGtP3KFY5xpHkasoNxDOsGuajYXohFFWto5HX2wHOfyz6 W8YvxplDXEFPL3eb5vXxsoD7GZ8hUqYo7ClG/2qpwlTFEzayzUR9sNvZlyckR2Z2S59r 7FQO44kuK+Y/v/K0F6Rqei6vBf+rVPeMM3rCOUzxlS5eHYGQ/lVOcrm4y32oxnzB9D3H UmtXExLbDEPjcAVKVEGRSYCfj3yJwOkw/ODwlHCoEcawrRfmC3TUQIl2D6kI8gU4kCba sLIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iXNqUNlDxA192iSDhXK8T34CWCe+lAvUgPxne7auzLU=; b=e8Xvd1G/A8/PRDqcsLOD4YVi6oL0CpXAL1p4NhtB8pNi2ztZtz0TifWrnyHf5l+Pdx GyYVugitnFnj5r55ISScNx+bDMsQgOF1iUWwQcdqZoPN88gXXlMm3EkrYYrzrJwrgmhR vOy9WJ3Ty0kBk/+ByJiU9R20ugvwlglZjaEgVwI4mO1H0ZGLxULL45m8/XdMDy+CjsqI pXTP1aUbAEXJ6w0vOrCjefw96GTQDIeoiPD7F39M5RTPr2iGXpwY8qP7JMqn2DEuOUoO G1SPy+kHRH1rAqSXCeTGxi/PMJSmMrIAHHrRyhhZL90ABqTlHZLu+aN07i8/hM8MltIa qYRQ== X-Gm-Message-State: AOAM532oWqRJe29BKR00nbOhBMQng5FOG+GzU21IMHvUnUPh+cPOZQoN ul9/QgOxWvaaHJBLg6XdrfE= X-Google-Smtp-Source: ABdhPJziO6I42bYuv8uPNtCMThaNM13m0w03d0WDcSIMvWOVwMMh5b8LH0b40IFyd3zK8pLldMrW0w== X-Received: by 2002:a17:90b:128a:: with SMTP id fw10mr11311388pjb.113.1608965056485; Fri, 25 Dec 2020 22:44:16 -0800 (PST) Received: from syed.domain.name ([103.201.127.53]) by smtp.gmail.com with ESMTPSA id r185sm30254706pfc.53.2020.12.25.22.44.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Dec 2020 22:44:16 -0800 (PST) Date: Sat, 26 Dec 2020 12:13:58 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org Subject: [PATCH 3/5] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201226_014420_343612_C8E4CF79 X-CRM114-Status: GOOD ( 14.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com, arnd@arndb.de, yamada.masahiro@socionext.com, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, daniel.lezcano@linaro.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, rrichter@marvell.com, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, rui.zhang@intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch reimplements the thunderx_gpio_set_multiple function in drivers/gpio/gpio-thunderx.c to use the new for_each_set_clump macro. Instead of looping for each bank in thunderx_gpio_set_multiple function, now we can skip bank which is not set and save cycles. Cc: William Breathitt Gray Cc: Robert Richter Cc: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris --- drivers/gpio/gpio-thunderx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 9f66deab46ea..716b75ba7df6 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -16,6 +16,7 @@ #include #include #include +#include <../drivers/gpio/clump_bits.h> #define GPIO_RX_DAT 0x0 @@ -275,12 +276,15 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip, unsigned long *bits) { int bank; - u64 set_bits, clear_bits; + unsigned long set_bits, clear_bits, gpio_mask; + unsigned long offset; + struct thunderx_gpio *txgpio = gpiochip_get_data(chip); - for (bank = 0; bank <= chip->ngpio / 64; bank++) { - set_bits = bits[bank] & mask[bank]; - clear_bits = ~bits[bank] & mask[bank]; + for_each_set_clump(offset, gpio_mask, mask, chip->ngpio, 64) { + bank = offset / 64; + set_bits = bits[bank] & gpio_mask; + clear_bits = ~bits[bank] & gpio_mask; writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); }