Skip to contentSkip to conversation

hwrng: manage resource allocation in amd driver

PATCH In review Dmitry Eremin-Solenikov 3 participants 4 messages Apr 27, 2011 – May 4, 2011 Hardware random number generator core

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hwrng: manage resource allocation in amd driver

As amd driver doesn't bind to PCI device, we'd better manage reource allocation on our own to disallow (possible) conflicts.

---
 drivers/char/hw_random/amd-rng.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/char/hw_random/amd-rng.c +9 -0
index 0d8c578..c6af038 100644
@@ -133,6 +133,12 @@ found:
 	pmbase &= 0x0000FF00;
 	if (pmbase == 0)
 		goto out;
+	if (!request_region(pmbase + 0xF0, 8, "AMD HWRNG")) {
+		dev_err(&pdev->dev, "AMD HWRNG region 0x%x already in use!\n",
+			pmbase + 0xF0);
+		err = -EBUSY;
+		goto out;
+	}
 	amd_rng.priv = (unsigned long)pmbase;
 	amd_pdev = pdev;
 
@@ -141,6 +147,7 @@ found:
 	if (err) {
 		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
 		       err);
+		release_region(pmbase + 0xF0, 8);
 		goto out;
 	}
 out:
@@ -149,6 +156,8 @@ out:
 
 static void __exit mod_exit(void)
 {
+	u32 pmbase = (unsigned long)amd_rng.priv;
+	release_region(pmbase + 0xF0, 8);
 	hwrng_unregister(&amd_rng);
 }
 
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/2 hwrnd: enable AMD hw rnd driver for Maple PPC boards

PPC 970FX Evaluation kit (Maple) boards bear AMD8111 southbridge. Allow this driver to be compiled in if PPC_MAPLE is selected.

---
 drivers/char/hw_random/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/hw_random/Kconfig +1 -1
index beecd1c..a60043b 100644
@@ -49,7 +49,7 @@ config HW_RANDOM_INTEL
 
 config HW_RANDOM_AMD
 	tristate "AMD HW Random Number Generator support"
-	depends on HW_RANDOM && X86 && PCI
+	depends on HW_RANDOM && (X86 || PPC_MAPLE) && PCI
 	default HW_RANDOM
 	---help---
 	  This driver provides kernel-side support for the Random Number
Signature · 1 line
1.7.4.4
Acked-by on v1 1/2
#2 lore raw
In reply to Dmitry Eremin-Solenikov
Quoted 2 lines · Dmitry Eremin-Solenikov

As amd driver doesn't bind to PCI device, we'd better manage reource allocation on our own to disallow (possible) conflicts.

These two look good to me.

Quoted 39 lines
---
 drivers/char/hw_random/amd-rng.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/char/hw_random/amd-rng.c +9 -0
index 0d8c578..c6af038 100644
@@ -133,6 +133,12 @@ found:
 	pmbase &= 0x0000FF00;
 	if (pmbase == 0)
 		goto out;
+	if (!request_region(pmbase + 0xF0, 8, "AMD HWRNG")) {
+		dev_err(&pdev->dev, "AMD HWRNG region 0x%x already in use!\n",
+			pmbase + 0xF0);
+		err = -EBUSY;
+		goto out;
+	}
 	amd_rng.priv = (unsigned long)pmbase;
 	amd_pdev = pdev;
 
@@ -141,6 +147,7 @@ found:
 	if (err) {
 		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
 		       err);
+		release_region(pmbase + 0xF0, 8);
 		goto out;
 	}
 out:
@@ -149,6 +156,8 @@ out:
 
 static void __exit mod_exit(void)
 {
+	u32 pmbase = (unsigned long)amd_rng.priv;
+	release_region(pmbase + 0xF0, 8);
 	hwrng_unregister(&amd_rng);
 }
 
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#3 lore raw
Quoted 7 lines · Matt Mackall
Quoted 2 lines · Dmitry Eremin-Solenikov

As amd driver doesn't bind to PCI device, we'd better manage reource allocation on our own to disallow (possible) conflicts.

These two look good to me.

All applied. Thanks a lot.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt