From 01ac16ec858e508d724c3c793140c532c4c21a4a Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 7 Aug 2023 08:15:36 -0400 Subject: [PATCH] Fixes for 4.19 Signed-off-by: Sasha Levin --- ..._elm-fix-incorrect-type-in-assignmen.patch | 120 ++++++++++++++++++ ...-mm-altmap-fix-altmap-boundary-check.patch | 41 ++++++ queue-4.19/series | 2 + 3 files changed, 163 insertions(+) create mode 100644 queue-4.19/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch create mode 100644 queue-4.19/powerpc-mm-altmap-fix-altmap-boundary-check.patch diff --git a/queue-4.19/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch b/queue-4.19/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch new file mode 100644 index 00000000000..627261c467d --- /dev/null +++ b/queue-4.19/mtd-rawnand-omap_elm-fix-incorrect-type-in-assignmen.patch @@ -0,0 +1,120 @@ +From 4700b283bdfa9c3d91e133f9742131bbe2b44e00 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 6736777a41567..02d1740383120 100644 +--- a/drivers/mtd/nand/raw/omap_elm.c ++++ b/drivers/mtd/nand/raw/omap_elm.c +@@ -184,17 +184,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] */ +@@ -204,35 +204,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-4.19/powerpc-mm-altmap-fix-altmap-boundary-check.patch b/queue-4.19/powerpc-mm-altmap-fix-altmap-boundary-check.patch new file mode 100644 index 00000000000..b2c850c62bd --- /dev/null +++ b/queue-4.19/powerpc-mm-altmap-fix-altmap-boundary-check.patch @@ -0,0 +1,41 @@ +From 40065a8beeebc804804b00514a5e765123016bc7 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 a5091c0347475..aff86679af961 100644 +--- a/arch/powerpc/mm/init_64.c ++++ b/arch/powerpc/mm/init_64.c +@@ -266,8 +266,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-4.19/series b/queue-4.19/series index f39657449c9..2a93c798451 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -311,3 +311,5 @@ net-usbnet-fix-warning-in-usbnet_start_xmit-usb_submit_urb.patch ext2-drop-fragment-support.patch test_firmware-fix-a-memory-leak-with-reqs-buffer.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 -- 2.47.3