From: David Laight <David.Laight@ACULAB.COM>
To: 'Florian Fainelli' <f.fainelli@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Brian Norris <computersforpeace@gmail.com>,
Gregory Fong <gregory.0xf0@gmail.com>,
"maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE"
<bcm-kernel-feedback-list@broadcom.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
"moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"linux-next@vger.kernel.org" <linux-next@vger.kernel.org>,
"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>,
"paul.gortmaker@windriver.com" <paul.gortmaker@windriver.com>
Subject: RE: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
Date: Wed, 23 Jan 2019 14:23:24 +0000 [thread overview]
Message-ID: <43155ea7637e45d6aad04f5747cbb6bb@AcuMS.aculab.com> (raw)
In-Reply-To: <20190123003345.13750-3-f.fainelli@gmail.com>
From: Florian Fainelli
> Sent: 23 January 2019 00:34
>
> On 32-bit architectures defining resource_size_t as 64-bit (because of
> PAE), we can run into a linker failure because of the modulo and the
> division against resource_size(), replace the two problematic operations
> with an alignment check on the register resource (instead of modulo),
> and the division with DIV_ROUND_CLOSEST_ULL().
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> drivers/reset/reset-brcmstb.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/reset/reset-brcmstb.c b/drivers/reset/reset-brcmstb.c
> index 01ab1f71518b..c4cab8b5052d 100644
> --- a/drivers/reset/reset-brcmstb.c
> +++ b/drivers/reset/reset-brcmstb.c
> @@ -91,7 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (resource_size(res) % SW_INIT_BANK_SIZE) {
> + if (!IS_ALIGNED(res->start, SW_INIT_BANK_SIZE) ||
> + !IS_AGLINED(resource_size(res), SW_INIT_BANK_SIZE)) {
> dev_err(kdev, "incorrect register range\n");
> return -EINVAL;
> }
> @@ -103,7 +104,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)
> dev_set_drvdata(kdev, priv);
>
> priv->rcdev.owner = THIS_MODULE;
> - priv->rcdev.nr_resets = (resource_size(res) / SW_INIT_BANK_SIZE) * 32;
> + priv->rcdev.nr_resets = DIV_ROUND_CLOSEST_ULL(resource_size(res),
> + SW_INIT_BANK_SIZE) * 32;
> priv->rcdev.ops = &brcmstb_reset_ops;
> priv->rcdev.of_node = kdev->of_node;
> /* Use defaults: 1 cell and simple xlate function */
Isn't it enough to assign resource_size(res) to an 'unsigned int' ?
The value is never actually going to be over 4G.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2019-01-23 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 0:33 [PATCH reset-next 0/2] reset: brcmstb: Misc fixes Florian Fainelli
2019-01-23 0:33 ` [PATCH reset-next 1/2] reset: brcmstb: Make it tristate Florian Fainelli
2019-01-23 0:33 ` [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t Florian Fainelli
2019-01-23 0:53 ` Randy Dunlap
2019-01-23 9:39 ` Philipp Zabel
2019-01-23 14:23 ` David Laight [this message]
2019-01-23 9:41 ` [PATCH reset-next 0/2] reset: brcmstb: Misc fixes Philipp Zabel
2019-01-23 22:56 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43155ea7637e45d6aad04f5747cbb6bb@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=computersforpeace@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=gregory.0xf0@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=p.zabel@pengutronix.de \
--cc=paul.gortmaker@windriver.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).