From: Sasha Levin Date: Mon, 7 Aug 2023 12:15:35 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.14.321~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d1a8ab515b2b5da885ea3cc7554bad48f49f862;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch b/queue-5.4/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch new file mode 100644 index 00000000000..d0cbba42707 --- /dev/null +++ b/queue-5.4/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch @@ -0,0 +1,120 @@ +From 391017d71e2a1654a36293696b0cec509cfef41c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 25 Jun 2023 00:10:21 +0530 +Subject: mtd: rawnand: omap_elm: Fix incorrect type in assignment + +From: Roger Quadros + +[ Upstream commit d8403b9eeee66d5dd81ecb9445800b108c267ce3 ] + +Once the ECC word endianness is converted to BE32, we force cast it +to u32 so we can use elm_write_reg() which in turn uses writel(). + +Fixes below sparse warnings: + + drivers/mtd/nand/raw/omap_elm.c:180:37: sparse: expected unsigned int [usertype] val + drivers/mtd/nand/raw/omap_elm.c:180:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:185:37: sparse: expected unsigned int [usertype] val + drivers/mtd/nand/raw/omap_elm.c:185:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:190:37: sparse: expected unsigned int [usertype] val + drivers/mtd/nand/raw/omap_elm.c:190:37: sparse: got restricted __be32 [usertype] +>> drivers/mtd/nand/raw/omap_elm.c:200:40: sparse: sparse: restricted __be32 degrades to integer + drivers/mtd/nand/raw/omap_elm.c:206:39: sparse: sparse: restricted __be32 degrades to integer + drivers/mtd/nand/raw/omap_elm.c:210:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:210:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:213:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:213:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:216:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:216:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:219:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:219:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:222:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:222:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:225:37: sparse: expected unsigned int [assigned] [usertype] val + drivers/mtd/nand/raw/omap_elm.c:225:37: sparse: got restricted __be32 [usertype] + drivers/mtd/nand/raw/omap_elm.c:228:39: sparse: sparse: restricted __be32 degrades to integer + +Fixes: bf22433575ef ("mtd: devices: elm: Add support for ELM error correction") +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202306212211.WDXokuWh-lkp@intel.com/ +Signed-off-by: Roger Quadros +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20230624184021.7740-1-rogerq@kernel.org +Signed-off-by: Sasha Levin +--- + drivers/mtd/nand/raw/omap_elm.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/drivers/mtd/nand/raw/omap_elm.c b/drivers/mtd/nand/raw/omap_elm.c +index 6e0e31eab7cce..c4064f8fd6118 100644 +--- a/drivers/mtd/nand/raw/omap_elm.c ++++ b/drivers/mtd/nand/raw/omap_elm.c +@@ -174,17 +174,17 @@ static void elm_load_syndrome(struct elm_info *info, + switch (info->bch_type) { + case BCH8_ECC: + /* syndrome fragment 0 = ecc[9-12B] */ +- val = cpu_to_be32(*(u32 *) &ecc[9]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[9]); + elm_write_reg(info, offset, val); + + /* syndrome fragment 1 = ecc[5-8B] */ + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[5]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[5]); + elm_write_reg(info, offset, val); + + /* syndrome fragment 2 = ecc[1-4B] */ + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[1]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[1]); + elm_write_reg(info, offset, val); + + /* syndrome fragment 3 = ecc[0B] */ +@@ -194,35 +194,35 @@ static void elm_load_syndrome(struct elm_info *info, + break; + case BCH4_ECC: + /* syndrome fragment 0 = ecc[20-52b] bits */ +- val = (cpu_to_be32(*(u32 *) &ecc[3]) >> 4) | ++ val = ((__force u32)cpu_to_be32(*(u32 *)&ecc[3]) >> 4) | + ((ecc[2] & 0xf) << 28); + elm_write_reg(info, offset, val); + + /* syndrome fragment 1 = ecc[0-20b] bits */ + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[0]) >> 12; ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[0]) >> 12; + elm_write_reg(info, offset, val); + break; + case BCH16_ECC: +- val = cpu_to_be32(*(u32 *) &ecc[22]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[22]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[18]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[18]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[14]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[14]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[10]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[10]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[6]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[6]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[2]); ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[2]); + elm_write_reg(info, offset, val); + offset += 4; +- val = cpu_to_be32(*(u32 *) &ecc[0]) >> 16; ++ val = (__force u32)cpu_to_be32(*(u32 *)&ecc[0]) >> 16; + elm_write_reg(info, offset, val); + break; + default: +-- +2.40.1 + diff --git a/queue-5.4/powerpc-mm-altmap-fix-altmap-boundary-check.patch b/queue-5.4/powerpc-mm-altmap-fix-altmap-boundary-check.patch new file mode 100644 index 00000000000..76e1af42480 --- /dev/null +++ b/queue-5.4/powerpc-mm-altmap-fix-altmap-boundary-check.patch @@ -0,0 +1,41 @@ +From 009fde0c0f5d20b3dbdbf15cd7f658b4aa0d8cef Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Jul 2023 23:43:20 +0530 +Subject: powerpc/mm/altmap: Fix altmap boundary check + +From: Aneesh Kumar K.V + +[ Upstream commit 6722b25712054c0f903b839b8f5088438dd04df3 ] + +altmap->free includes the entire free space from which altmap blocks +can be allocated. So when checking whether the kernel is doing altmap +block free, compute the boundary correctly, otherwise memory hotunplug +can fail. + +Fixes: 9ef34630a461 ("powerpc/mm: Fallback to RAM if the altmap is unusable") +Signed-off-by: "Aneesh Kumar K.V" +Reviewed-by: David Hildenbrand +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230724181320.471386-1-aneesh.kumar@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/mm/init_64.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c +index e4fb5ab41e2d3..cfb97fabd5320 100644 +--- a/arch/powerpc/mm/init_64.c ++++ b/arch/powerpc/mm/init_64.c +@@ -279,8 +279,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end, + start = _ALIGN_DOWN(start, page_size); + if (altmap) { + alt_start = altmap->base_pfn; +- alt_end = altmap->base_pfn + altmap->reserve + +- altmap->free + altmap->alloc + altmap->align; ++ alt_end = altmap->base_pfn + altmap->reserve + altmap->free; + } + + pr_debug("vmemmap_free %lx...%lx\n", start, end); +-- +2.40.1 + diff --git a/queue-5.4/series b/queue-5.4/series index f2b024bf726..c32f1f09c46 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -133,3 +133,5 @@ fs-protect-reconfiguration-of-sb-read-write-from-racing-writes.patch ext2-drop-fragment-support.patch test_firmware-prevent-race-conditions-by-a-correct-implementation-of-locking.patch test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch +mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch +powerpc-mm-altmap-fix-altmap-boundary-check.patch