Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp727669ybz; Fri, 24 Apr 2020 08:17:48 -0700 (PDT) X-Google-Smtp-Source: APiQypIk0CbMdrtPpnr7nRrC/WGbKHsqY+lFqS0mB7WEGe9y5B2QHgSqIblOaSRFsFx7hqFJyK34 X-Received: by 2002:a05:6402:17e3:: with SMTP id t3mr7811702edy.203.1587741468594; Fri, 24 Apr 2020 08:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587741468; cv=none; d=google.com; s=arc-20160816; b=qGdD0sjQV9TDxXsdV4kM2ZVnLDqYvVp+CVd/ekB/9DCeHa0zcv/FzZ+ty4a/ilB0Ho ozzdYqcN3Ap5MRPTtOI6VZzu0y6m3rRYayToSnKl53U7ArMCcXQRmZbYL7YTnL3c7Iq2 KPZE2uASg0Jr+S6QhyAB8hD4XDoPy6RCKMymKWWhYpM75TVlA0QL7urUCE65kRyHqObh Tx+sVMxb54VuSWd9GnvHPSOAa6VEgGvv3OchjfXxM8gRW6dgQXwE8LA42nmHSJyw7gNk jPBUq7WBazRKY2FLzI9J93dNjJsLJV+G/P8CgPh1qlH9PVEGj/6XEsORb5jQEbSjTLeW vecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QSwg6gghB4J4fxCnCtJXebe2/h8we5Uo4r3Dshm/gm4=; b=NlENTrA49jNfJPqVuKymVqndfzqSlRAS+E7AcS+NIdobEMjXxwl9VI9oh0ItRTj9ii undSDWFCE0fRlCyuNrAfGNIhxlERHfI+al1NYSTiNO+7Qxd0CsgzkEgie8A3QtsKhNlt GEtcX7VDalaJLgbopCAg9mxppot2M58OVJNPfA0pLpZhnPAYzhmISnPblMdQm7YP72hp KR+sJbwkflhs9YS+RSUn9JJ9rNNRJc3ebRqHml0He0Iuptdjk7Yrgu/g/6UzEr6IQbi/ 5Pkmobe/qz1a9vVINQdSpjWBECfbjLviJo7w1Ct8MQSIaAoVFeYLJymFQxLYlGe47oDR RcMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RE5RXCnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g7si3307527edn.251.2020.04.24.08.17.25; Fri, 24 Apr 2020 08:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RE5RXCnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727929AbgDXPO6 (ORCPT + 99 others); Fri, 24 Apr 2020 11:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726959AbgDXPO6 (ORCPT ); Fri, 24 Apr 2020 11:14:58 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37FABC09B045; Fri, 24 Apr 2020 08:14:58 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id y19so4803379qvv.4; Fri, 24 Apr 2020 08:14:58 -0700 (PDT) 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; bh=QSwg6gghB4J4fxCnCtJXebe2/h8we5Uo4r3Dshm/gm4=; b=RE5RXCnG+VdWldHaDGPi6/nEecCcxvkxHbnfNVgzb8DKgjrwjLAI7Ze5lCs/z+RBFG CTgV2hmcegRhgTJOUk3RdA7otfcOx/Vijtj4L1PMpdAc8chmHhe0asg/Um6loo9AZkg8 Nf1Be1hpnlfQgM7Sxant7wbJ08eQAF9hIFGrK7VdwNPrmFs76N3kR4HjHejlAlgSoXVy h2y2bHax3dUAlj1ueE8EVNlSOpRDWtKCT6xogZpn7YFxhj9/c5McHRdeCn20x8rbe5zv bKjN/WCMOEx3W+QkOMhfVtb0u8Nk95Zz4JRqIWO5tw0TYUq+VSID/HozDkZ2YHNVmqB/ mY+A== 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; bh=QSwg6gghB4J4fxCnCtJXebe2/h8we5Uo4r3Dshm/gm4=; b=dkrSswHcY6xjzwVwiWZWCuRPPY79vfS/fcasQPW/6tnF6FJQrJ5vlJ+UDqyw+sod6f Vo1y2e3/8/oUc8P2EYh8iKgNat3SA1Qw7lbgh7CQY4Gn1GwKfQZHZZI+P3JdDGFx18vx lnQ5nSf6awB62jzRSDthL+ojdC8Qqs4nu8hbzT0RKK7C4JBckDFaBSKqim9NOHY62/uM FXK7fof7rIIXJRcsZFONigD0yf5lUFIrTGXYXWDcki2m0IdI/wc5lvpL6/9r4oSW5hNy Jf6E+iGGwROH89drmH71dRR80mmQitlsiUqR1fOxK/2KqQD9dt5BYRQY05ZXfSBHjAxh pusw== X-Gm-Message-State: AGi0PubhDq4X+XGm1Lv7YfAwxJ9kBKPTUkdWRjriJJpOgSSqIdRRLXK4 lSUfmvUeHhspdCQ15e+InUg= X-Received: by 2002:a05:6214:1262:: with SMTP id r2mr9952180qvv.126.1587741297402; Fri, 24 Apr 2020 08:14:57 -0700 (PDT) Received: from icarus (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id 65sm3863089qkf.79.2020.04.24.08.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 08:14:56 -0700 (PDT) Date: Fri, 24 Apr 2020 11:14:54 -0400 From: William Breathitt Gray To: rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com Cc: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, Syed Nayyar Waris , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/6] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <20200424151454.GB5034@icarus> References: <20200424123050.GA5653@syed> <20200424135547.GB3255@icarus> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BQPnanjtCNWHyqYD" Content-Disposition: inline In-Reply-To: <20200424135547.GB3255@icarus> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --BQPnanjtCNWHyqYD Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 24, 2020 at 09:55:47AM -0400, William Breathitt Gray wrote: > On Fri, Apr 24, 2020 at 06:00:50PM +0530, Syed Nayyar Waris wrote: > > 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. > >=20 > > Cc: Robert Richter > > Cc: Linus Walleij > > Cc: Bartosz Golaszewski > > Signed-off-by: Syed Nayyar Waris > > Signed-off-by: William Breathitt Gray > > --- > > drivers/gpio/gpio-thunderx.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > >=20 > > diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c > > index 9f66dea..74aea25 100644 > > --- a/drivers/gpio/gpio-thunderx.c > > +++ b/drivers/gpio/gpio-thunderx.c > > @@ -275,12 +275,16 @@ static void thunderx_gpio_set_multiple(struct gpi= o_chip *chip, > > unsigned long *bits) > > { > > int bank; > > - u64 set_bits, clear_bits; > > + u64 set_bits, clear_bits, gpio_mask; > > + const unsigned long bank_size =3D 64; > > + unsigned long offset; > > + > > struct thunderx_gpio *txgpio =3D gpiochip_get_data(chip); > > =20 > > - for (bank =3D 0; bank <=3D chip->ngpio / 64; bank++) { > > - set_bits =3D bits[bank] & mask[bank]; > > - clear_bits =3D ~bits[bank] & mask[bank]; > > + for_each_set_clump(offset, gpio_mask, mask, chip->ngpio, bank_size) { > > + bank =3D offset / bank_size; > > + set_bits =3D bits[bank] & gpio_mask; > > + clear_bits =3D ~bits[bank] & gpio_mask; > > writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GP= IO_TX_SET); > > writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + = GPIO_TX_CLR); > > } > > --=20 > > 2.7.4 >=20 > We noticed in the original code that this set_multiple callback does not > appear to work correctly on systems where BITS_PER_LONG =3D=3D 32. On tho= se > systems, the bits and mask values are 32-bit, but the for loop jumps 64 > bits at a time -- that means the loop is skipping the upper 32 gpio > lines of every iteration. >=20 > Is the gpio-thunderx driver only intended for 64-bit systems? Or this > behavior a bug? >=20 > William Breathitt Gray Nevermind, I spoke too soon; I see there's a depends on 64BIT line in the Kconfig for GPIO_THUNDERX. William Breathitt Gray --BQPnanjtCNWHyqYD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAl6jAm4ACgkQhvpINdm7 VJK2DRAAjsPKyCL9M0yAhH8ymPu3Lg1Mgg3hUc3R0ZDUgEk570duKvcY4vGEWtBl EyFpN+ZUE+XFnftAEStFDGka9cvQyYMNdyfo9AGj2Ht1Ypo6UfTvHmIMnmjUB5zj 4jThLWmEXRxXZOaNz9lQAdtdqaxTM3RzSiM4NZcc5+yNaB/n3y+XHlfKd+O6S2ZV ruaFrVvBSYfRmXgGm5JIpJlxAWFH3hpvpHutt6MxacR0wox0Ik+mM+7t/3Yp3+l3 0fuh3UWHDEi7+yEpJlYYEwNna7rPRrzYZtOXILsKjEmJ0g98PgfhknnGLxJ5/rSR 4BURS+R61qjTGOtCk3VVb6u+FuRB8pVWvLh07NS6JPnm5aNjKTiMfYwLnxpF7cey Kqh11+3b3gklWXgEnsBXVkZAT2kYnS/4KFC5LfFc7Mkt5K5SvQR15Y3zGu2CII2G 10Zr5XfYIS5dArs4ZbSvFiWvRKlpa3dpHJMZEQxTA1DC0l5DFLC76MC1B5MA+miA 7/J8rREmV5nyo3tAi1T05cDr5zpe2o66HB0N+qXck5TaiS0mjkMmPGVtl/BaTwDF pqiMZWIQ8TG/2QIm9I9AZ7w+O06rQ9TkNgheE5rBxn0TM3yrLDQ9oH990kwCEFjH Z1HQA9A7YqDjMfUQD/WNDL66B3/wUF7pCiNVgnfbHrc/vhT0w/Y= =7Xlp -----END PGP SIGNATURE----- --BQPnanjtCNWHyqYD--