Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19542ybl; Tue, 28 Jan 2020 17:31:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzUV2GXjPzf0xbHfFsrwiYv5ySiot3egnzpBAEVKtnzio2qzOqeAfnZgAd8OZ1Bb/G3R39s X-Received: by 2002:a05:6830:1691:: with SMTP id k17mr19413562otr.282.1580261518648; Tue, 28 Jan 2020 17:31:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580261518; cv=none; d=google.com; s=arc-20160816; b=LX27BIvxlHsglBJUjclnQ8b2z4pWAC6zRxueuAA/fExhSHWeVXJn2vA7BDl4VoNeFo 5qT6rAq9vH/DzhscMz1VuQq6/itpIdHBZsjAkhwkt5XcBSM3Xbat2Dztri0cxq8Vpdlj qXOGSWtIY5OmfsE6t8zysyG3F5OjrJWTTxhN6sioLIxsflKAxreiU7+MJ1Ch9USUwnC9 8plKCpANQ4ZUWTvBl7YIvxPOnj6TXNEWU8hsPaKpxf0NxdzAD98EnnarJjBhqi1ptEFt qRzUuKRdv2u26NtitKq4ZalmCQgLR97J5PojRejg+Ch8UTcGIxxcI1QgfpZKonR0BDQw FGUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6B1VhRQwgQQGh2ESABiP5pnpxVqXMTnf0pfde8jgU5c=; b=HXhCBpOqtmNRaBEW67i5vJ6CkKUREZIP/LmH7L2o9pPeZHgKOY5CNY5d24X0cC46ic QnbvNbtCUWCVy/Mb/ieE1fSTKQIW8ruxKlRuivHY+lMd0ycz0jA9PpBABSRxljvDaHtn NjH6S1v0YY4EeJ2jyYUBsFH3ZymUbtFY6rOqTiIdzdeOt4/AxUwEOYSVBRk5CEM+h0vo 96Z8OAhkS/KyMvirQU5aLLBU2J4PjA3WG3QJ+iEFfKDcblfUSTKMX7oiLpAo7stm7bBy sX/VTwIuKkgM/kXwY3/vnQ/MG5DPVjcfacRCZ8OgOwKlzV4S4nR175aWbRsIWuTE3GWg 47Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kMbL6DRc; 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 m4si278070otn.281.2020.01.28.17.31.46; Tue, 28 Jan 2020 17:31:58 -0800 (PST) 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=kMbL6DRc; 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 S1726556AbgA2B2C (ORCPT + 99 others); Tue, 28 Jan 2020 20:28:02 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36335 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbgA2B2C (ORCPT ); Tue, 28 Jan 2020 20:28:02 -0500 Received: by mail-pf1-f193.google.com with SMTP id 185so3812794pfv.3; Tue, 28 Jan 2020 17:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6B1VhRQwgQQGh2ESABiP5pnpxVqXMTnf0pfde8jgU5c=; b=kMbL6DRcPopPriLil1q2cF2S0RTqtzattA8RUgMO00342T7nMhfwjfAxqur9SZ18BJ OaoOfVUck8Q5588qfLfhbP6qPlDy2FDGEUcf/ti2ph0e1M+IiF7JezuvlngZkDu2+QQl qD0s4yptkrqbqS+rj5RMPx+/8sll0v6fts+KN/R2epMJ7PhBe88FFmB3KgnWOUi206uj QZVSRrdIkfIKMKTW+hiblnFsxZDv7IOfFiSB1Be9Ej/x2Dgi0Z/rlZtKS0zizrjw/1pC v2FHPKGxwHva5KtYnGFKIMOWSYAUBWTrfQ9Rpg0jdOit7foTnNE61SLwkdqtm4CpizYy 4/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6B1VhRQwgQQGh2ESABiP5pnpxVqXMTnf0pfde8jgU5c=; b=WgvS9Fm2ZV1WEUPCPLvFLs03gbzrHvbMSLj/nBsDPX8hFd2EM/IiNmQTprDVejRKCP oFxOk0qamGALfFzLnHsXHAUafJEjT0melEY/3v5iQAONpv7D7rM8I0j/fAXdhMKWfPa9 DTzGQPPGrJNbqRIWn7ITBB9rzkgJDInj6ktsGwvzZ9ZU080lv0Q/lCbsg0GIwECwsJF8 Uv8Q+lTRzinF+jjaW2N9eizDs/xK5dcwFYrF7j8X+YUi5DVFVTrlUHdsnBB+5vUl4Smn 0HFVa6/2HkrriZEnoIum+UC3G4wBVrEgWtiat59/XV4mFszPcLJ88Prl5PPe2iqlO8oP JVrA== X-Gm-Message-State: APjAAAXURoJKhN8pRu1XFwbPTS8vzrX90FMEl0OGiDpUs9qY6RMPWH4Q X8tS2L1xkHGrrOzNyK62SAiDl7NpEU3rHt+f7OQ= X-Received: by 2002:a63:c748:: with SMTP id v8mr19346399pgg.143.1580261280721; Tue, 28 Jan 2020 17:28:00 -0800 (PST) MIME-Version: 1.0 References: <1580189061-14091-1-git-send-email-yash.shah@sifive.com> In-Reply-To: From: JaeJoon Jung Date: Wed, 29 Jan 2020 10:27:49 +0900 Message-ID: Subject: Re: [PATCH] gpio/sifive: fix static checker warning To: Marc Zyngier Cc: Yash Shah , atish.patra@wdc.com, wesley@sifive.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, bgolaszewski@baylibre.com, Palmer Dabbelt , sachin.ghadi@sifive.com, linux-gpio@vger.kernel.org, Paul Walmsley , linux-riscv Content-Type: multipart/mixed; boundary="0000000000004a46f3059d3d40cb" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000004a46f3059d3d40cb Content-Type: text/plain; charset="UTF-8" Because SiFive FU540 GPIO Registers are aligned 32-bit, I think that irq_state is good "unsigned int" than "unsigned long". I refer to SiFive FU540-C000 Manual v1p0 (GPIO Register Table 103) as "Only naturally aligned 32-bit memory accesses are supported" when you use assign_bit(offset, &chip->irq_state, 1), offset is 32-bit. I prefer to use bit operation instead of assign_bit(). u32 bit = BIT(offset); chip->irq_state |= bit; If you use this code, you do not use the assign_bit() and need not change irq_state data type. There are many improvements in my works for drivers/gpio/gpio-sifive.c. I hope to check my attached source file. On Tue, 28 Jan 2020 at 22:21, Marc Zyngier wrote: > > On 2020-01-28 05:24, Yash Shah wrote: > > Typcasting "irq_state" leads to the below static checker warning: > > The fix is to declare "irq_state" as unsigned long instead of u32. > > > > drivers/gpio/gpio-sifive.c:97 sifive_gpio_irq_enable() > > warn: passing casted pointer '&chip->irq_state' to > > 'assign_bit()' 32 vs 64. > > > > Fixes: 96868dce644d ("gpio/sifive: Add GPIO driver for SiFive SoCs") > > Reported-by: Dan Carpenter > > Signed-off-by: Yash Shah > > --- > > drivers/gpio/gpio-sifive.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c > > index 147a1bd..c54dd08 100644 > > --- a/drivers/gpio/gpio-sifive.c > > +++ b/drivers/gpio/gpio-sifive.c > > @@ -35,7 +35,7 @@ struct sifive_gpio { > > void __iomem *base; > > struct gpio_chip gc; > > struct regmap *regs; > > - u32 irq_state; > > + unsigned long irq_state; > > unsigned int trigger[SIFIVE_GPIO_MAX]; > > unsigned int irq_parent[SIFIVE_GPIO_MAX]; > > }; > > @@ -94,7 +94,7 @@ static void sifive_gpio_irq_enable(struct irq_data > > *d) > > spin_unlock_irqrestore(&gc->bgpio_lock, flags); > > > > /* Enable interrupts */ > > - assign_bit(offset, (unsigned long *)&chip->irq_state, 1); > > + assign_bit(offset, &chip->irq_state, 1); > > sifive_gpio_set_ie(chip, offset); > > } > > > > @@ -104,7 +104,7 @@ static void sifive_gpio_irq_disable(struct irq_data > > *d) > > struct sifive_gpio *chip = gpiochip_get_data(gc); > > int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX; > > > > - assign_bit(offset, (unsigned long *)&chip->irq_state, 0); > > + assign_bit(offset, &chip->irq_state, 0); > > sifive_gpio_set_ie(chip, offset); > > irq_chip_disable_parent(d); > > } > > Yup, nice one. Should have spotted it. > > Reviewed-by: Marc Zyngier > > Linus, do you want me to queue this via the irqchip tree (given that > it is where the original bug came from)? Or would you rather take it? > > M. > -- > Jazz is not dead. It just smells funny... > --0000000000004a46f3059d3d40cb Content-Type: text/x-csrc; charset="US-ASCII"; name="gpio-sifive.c" Content-Disposition: attachment; filename="gpio-sifive.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k5ymr1ly0 LyoKICogU2lGaXZlIEdQSU8gZHJpdmVyCiAqCiAqIENvcHlyaWdodCAoQykgMjAxOCBTaUZpdmUs IEluYy4KICoKICogVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0 cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKICogaXQgdW5kZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUg R2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2ZXJzaW9uIDIgYXMKICogcHVibGlz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b19zaWZpdmVfZGVidWcoImly cSBoYW5kbGVyOiBvZmZzZXQ9JWRcbiIsIG9mZnNldCk7Cn0KCiNpZmRlZiBHUElPX1NJRklWRV9E RUJVRwpzdGF0aWMgdm9pZCBncGlvX3NpZml2ZV9zZXRfaXJxX2VuYWJsZShzdHJ1Y3Qgc2lmaXZl X2dwaW8gKmNoaXAsIHVuc2lnbmVkIG9mZnNldCkgICAgICAgICAgICAgICAgICAgICAgICAgIAp7 CiAgICAgICAgdTMyIGJpdCA9IEJJVChvZmZzZXQpOwoKICAgICAgICAvKiBTd2l0Y2ggdG8gaW5w dXQgKi8KICAgICAgICBncGlvX3NpZml2ZV9kaXJlY3Rpb25faW5wdXQoJmNoaXAtPmdjLCBvZmZz ZXQpOwoKICAgICAgICAvKiBDbGVhciBhbnkgc3RpY2t5IHBlbmRpbmcgaW50ZXJydXB0cyAqLwog ICAgICAgIHdyaXRlbChiaXQsIGNoaXAtPmJhc2UgKyBHUElPX1JJU0VfSVApOwogICAgICAgIHdy aXRlbChiaXQsIGNoaXAtPmJhc2UgKyBHUElPX0ZBTExfSVApOwogICAgICAgIHdyaXRlbChiaXQs IGNoaXAtPmJhc2UgKyBHUElPX0hJR0hfSVApOwogICAgICAgIHdyaXRlbChiaXQsIGNoaXAtPmJh c2UgKyBHUElPX0xPV19JUCk7CgogICAgICAgIC8qIEVuYWJsZSBpbnRlcnJ1cHRzICovCiAgICAg ICAgY2hpcC0+aXJxX2VuYWJsZSB8PSBiaXQ7CiAgICAgICAgZ3Bpb19zaWZpdmVfc2V0X2llKGNo aXAsIG9mZnNldCk7Cn0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgCnN0YXRpYyB2b2lkIGdwaW9fc2lmaXZlX3Nld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