Skip to contentSkip to conversation

reset: brcmstb: Misc fixes

PATCH In review Florian Fainelli 4 participants 8 messages Jan 23, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover reset: brcmstb: Misc fixes

Hi Philipp,

These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver") since this is only in reset/next and linux-next so far.

Thank you!

Florian Fainelli (2):
reset: brcmstb: Make it tristate
reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t

 drivers/reset/Kconfig         | 3 ++-
 drivers/reset/reset-brcmstb.c | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 reset: brcmstb: Make it tristate

The driver can be built as a module just fine, so let's make it selectable as such.

---
 drivers/reset/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/reset/Kconfig +2 -1
index 1ca03c57e049..d9a02b7f90cf 100644
@@ -41,7 +41,8 @@ config RESET_BERLIN
 	  This enables the reset controller driver for Marvell Berlin SoCs.
 
 config RESET_BRCMSTB
-	bool "Broadcom STB reset controller" if COMPILE_TEST
+	tristate "Broadcom STB reset controller"
+	depends on ARCH_BRCMSTB || COMPILE_TEST
 	default ARCH_BRCMSTB
 	help
 	  This enables the reset controller driver for Broadcom STB SoCs using
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t

In reply to Florian Fainelli

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().

Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")
---
 drivers/reset/reset-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +4 -2
index 01ab1f71518b..c4cab8b5052d 100644
@@ -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 */
Signature · 1 line
2.17.1
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t

Quoted 29 lines · Florian Fainelli

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().

Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")
---
 drivers/reset/reset-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +2 -1
index 01ab1f71518b..c4cab8b5052d 100644
@@ -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;
 	}

drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 111

Quoted 9 lines
drivers/reset/reset-brcmstb.c +2 -1
@@ -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 */

Hi Florian,

This gives me:

CC drivers/reset/reset-brcmstb.o
../drivers/reset/reset-brcmstb.c: In function ‘brcmstb_reset_probe’:
../drivers/reset/reset-brcmstb.c:95:6: error: implicit declaration of function ‘IS_AGLINED’ [-Werror=implicit-function-declaration]

      !IS_AGLINED(resource_size(res), SW_INIT_BANK_SIZE)) {
      ^

but if the typo is fixed, it is fine :) then you can added:

Thanks.

Signature · 1 line
~Randy
maintainer
#4 lore raw

Re: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t

In reply to Florian Fainelli

Hi Florian,

Quoted 18 lines · Florian Fainelli

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().

Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")
---
 drivers/reset/reset-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +0 -0
index 01ab1f71518b..c4cab8b5052d 100644

drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 95

Quoted 6 lines
drivers/reset/reset-brcmstb.c +2 -1
@@ -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)) {

Typo.

drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 108

Quoted 10 lines
drivers/reset/reset-brcmstb.c +2 -1
 		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;

This should be DIV_ROUND_DOWN_ULL.

regards
Philipp

#5 lore raw

RE: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t

In reply to Florian Fainelli

From: Florian Fainelli

Quoted 30 lines

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().

Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")
---
 drivers/reset/reset-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +2 -1
index 01ab1f71518b..c4cab8b5052d 100644
@@ -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;
 	}

drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 111

Quoted 9 lines
drivers/reset/reset-brcmstb.c +2 -1
@@ -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)

maintainer
#6 lore raw
In reply to Florian Fainelli
Quoted 6 lines · Florian Fainelli

Hi Philipp,

These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver") since this is only in reset/next and linux-next so far.

If you want this squashed, feel free to submit an updated version of the original patches and I'll replace them. That way I don't have to decide how to stitch (or drop) the commit messages.

thanks
Philipp

#7 lore raw
Quoted 11 lines · Philipp Zabel
Quoted 6 lines · Florian Fainelli

Hi Philipp,

These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver") since this is only in reset/next and linux-next so far.

If you want this squashed, feel free to submit an updated version of the original patches and I'll replace them. That way I don't have to decide how to stitch (or drop) the commit messages.

Thanks, I sent you a replacement version for the second patch only, hope that is alright.

Signature · 1 line
Florian