Skip to contentSkip to conversation

parisc: remove obsolete manual allocation aligning

PATCH Applied Rolf Eike Beer 2 participants 2 messages Sep 14, 2022 – Sep 15, 2022 PA-RISC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parisc: remove obsolete manual allocation aligning

kmalloc() returns memory with __assume_kmalloc_alignment, which is __alignof__(unsigned long long) for parisc.

---
 drivers/parisc/iosapic.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

I must confirm it's entirely untested.

drivers/parisc/iosapic.c +1 -10
index 3a8c98615634..bdef7a8d6ab8 100644
@@ -221,16 +221,7 @@ static size_t irt_num_entry;
 
 static struct irt_entry *iosapic_alloc_irt(int num_entries)
 {
-	unsigned long a;
-
-	/* The IRT needs to be 8-byte aligned for the PDC call. 
-	 * Normally kmalloc would guarantee larger alignment, but
-	 * if CONFIG_DEBUG_SLAB is enabled, then we can get only
-	 * 4-byte alignment on 32-bit kernels
-	 */
-	a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL);
-	a = (a + 7UL) & ~7UL;
-	return (struct irt_entry *)a;
+	return kcalloc(num_entries, sizeof(struct irt_entry), GFP_KERNEL);
 }
 
 /**
Signature · 1 line
2.35.3
maintainer Applied
#1 lore raw
Quoted 4 lines · Rolf Eike Beer

kmalloc() returns memory with __assume_kmalloc_alignment, which is __alignof__(unsigned long long) for parisc.

applied.

Thanks!
Helge

Quoted 28 lines
---
  drivers/parisc/iosapic.c | 11 +----------
  1 file changed, 1 insertion(+), 10 deletions(-)

I must confirm it's entirely untested.

drivers/parisc/iosapic.c +1 -10
index 3a8c98615634..bdef7a8d6ab8 100644
@@ -221,16 +221,7 @@ static size_t irt_num_entry;
 
  static struct irt_entry *iosapic_alloc_irt(int num_entries)
  {
-	unsigned long a;
-
-	/* The IRT needs to be 8-byte aligned for the PDC call.
-	 * Normally kmalloc would guarantee larger alignment, but
-	 * if CONFIG_DEBUG_SLAB is enabled, then we can get only
-	 * 4-byte alignment on 32-bit kernels
-	 */
-	a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL);
-	a = (a + 7UL) & ~7UL;
-	return (struct irt_entry *)a;
+	return kcalloc(num_entries, sizeof(struct irt_entry), GFP_KERNEL);
  }
 
  /**