From 1d4cacb47e3ee079883d2771a9a35408be60b866 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sun, 4 Dec 2022 16:10:31 -0500 Subject: [PATCH] Fixes for 5.10 Signed-off-by: Sasha Levin --- ...itiator-registration-for-single-init.patch | 111 ++++++++++++++++++ ...-unnecessary-variable-initialization.patch | 42 +++++++ ...-messages-with-i2c_m_dma_safe-flag-s.patch | 54 +++++++++ ...-fix-error-handling-in-npcm_i2c_init.patch | 64 ++++++++++ queue-5.10/series | 4 + 5 files changed, 275 insertions(+) create mode 100644 queue-5.10/acpi-hmat-fix-initiator-registration-for-single-init.patch create mode 100644 queue-5.10/acpi-hmat-remove-unnecessary-variable-initialization.patch create mode 100644 queue-5.10/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch create mode 100644 queue-5.10/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch diff --git a/queue-5.10/acpi-hmat-fix-initiator-registration-for-single-init.patch b/queue-5.10/acpi-hmat-fix-initiator-registration-for-single-init.patch new file mode 100644 index 00000000000..3dff716eb8d --- /dev/null +++ b/queue-5.10/acpi-hmat-fix-initiator-registration-for-single-init.patch @@ -0,0 +1,111 @@ +From 5cf9fa360b3c0281885cbf96e7c5d2e1abd3dadd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Nov 2022 16:37:37 -0700 +Subject: ACPI: HMAT: Fix initiator registration for single-initiator systems + +From: Vishal Verma + +[ Upstream commit 48d4180939e12c4bd2846f984436d895bb9699ed ] + +In a system with a single initiator node, and one or more memory-only +'target' nodes, the memory-only node(s) would fail to register their +initiator node correctly. i.e. in sysfs: + + # ls /sys/devices/system/node/node0/access0/targets/ + node0 + +Where as the correct behavior should be: + + # ls /sys/devices/system/node/node0/access0/targets/ + node0 node1 + +This happened because hmat_register_target_initiators() uses list_sort() +to sort the initiator list, but the sort comparision function +(initiator_cmp()) is overloaded to also set the node mask's bits. + +In a system with a single initiator, the list is singular, and list_sort +elides the comparision helper call. Thus the node mask never gets set, +and the subsequent search for the best initiator comes up empty. + +Add a new helper to consume the sorted initiator list, and generate the +nodemask, decoupling it from the overloaded initiator_cmp() comparision +callback. This prevents the singular list corner case naturally, and +makes the code easier to follow as well. + +Cc: +Cc: Rafael J. Wysocki +Cc: Liu Shixin +Cc: Dan Williams +Cc: Kirill A. Shutemov +Reported-by: Chris Piper +Signed-off-by: Vishal Verma +Acked-by: Rafael J. Wysocki +Acked-by: Kirill A. Shutemov +Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-2-3712569be691@intel.com +Signed-off-by: Dan Williams +Signed-off-by: Sasha Levin +--- + drivers/acpi/numa/hmat.c | 26 ++++++++++++++++++++------ + 1 file changed, 20 insertions(+), 6 deletions(-) + +diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c +index fd202689dcda..26453a945da4 100644 +--- a/drivers/acpi/numa/hmat.c ++++ b/drivers/acpi/numa/hmat.c +@@ -563,17 +563,26 @@ static int initiator_cmp(void *priv, const struct list_head *a, + { + struct memory_initiator *ia; + struct memory_initiator *ib; +- unsigned long *p_nodes = priv; + + ia = list_entry(a, struct memory_initiator, node); + ib = list_entry(b, struct memory_initiator, node); + +- set_bit(ia->processor_pxm, p_nodes); +- set_bit(ib->processor_pxm, p_nodes); +- + return ia->processor_pxm - ib->processor_pxm; + } + ++static int initiators_to_nodemask(unsigned long *p_nodes) ++{ ++ struct memory_initiator *initiator; ++ ++ if (list_empty(&initiators)) ++ return -ENXIO; ++ ++ list_for_each_entry(initiator, &initiators, node) ++ set_bit(initiator->processor_pxm, p_nodes); ++ ++ return 0; ++} ++ + static void hmat_register_target_initiators(struct memory_target *target) + { + static DECLARE_BITMAP(p_nodes, MAX_NUMNODES); +@@ -610,7 +619,10 @@ static void hmat_register_target_initiators(struct memory_target *target) + * initiators. + */ + bitmap_zero(p_nodes, MAX_NUMNODES); +- list_sort(p_nodes, &initiators, initiator_cmp); ++ list_sort(NULL, &initiators, initiator_cmp); ++ if (initiators_to_nodemask(p_nodes) < 0) ++ return; ++ + if (!access0done) { + for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) { + loc = localities_types[i]; +@@ -644,7 +656,9 @@ static void hmat_register_target_initiators(struct memory_target *target) + + /* Access 1 ignores Generic Initiators */ + bitmap_zero(p_nodes, MAX_NUMNODES); +- list_sort(p_nodes, &initiators, initiator_cmp); ++ if (initiators_to_nodemask(p_nodes) < 0) ++ return; ++ + for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) { + loc = localities_types[i]; + if (!loc) +-- +2.35.1 + diff --git a/queue-5.10/acpi-hmat-remove-unnecessary-variable-initialization.patch b/queue-5.10/acpi-hmat-remove-unnecessary-variable-initialization.patch new file mode 100644 index 00000000000..60fc99ba148 --- /dev/null +++ b/queue-5.10/acpi-hmat-remove-unnecessary-variable-initialization.patch @@ -0,0 +1,42 @@ +From e280de7024000b6f689c6d76d1b29851ebd5ef69 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Nov 2022 16:37:36 -0700 +Subject: ACPI: HMAT: remove unnecessary variable initialization + +From: Vishal Verma + +[ Upstream commit 14f16d47561ba9249efc6c2db9d47ed56841f070 ] + +In hmat_register_target_initiators(), the variable 'best' gets +initialized in the outer per-locality-type for loop. The initialization +just before setting up 'Access 1' targets was unnecessary. Remove it. + +Cc: Rafael J. Wysocki +Cc: Liu Shixin +Cc: Dan Williams +Acked-by: Kirill A. Shutemov +Acked-by: Rafael J. Wysocki +Signed-off-by: Vishal Verma +Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-1-3712569be691@intel.com +Signed-off-by: Dan Williams +Stable-dep-of: 48d4180939e1 ("ACPI: HMAT: Fix initiator registration for single-initiator systems") +Signed-off-by: Sasha Levin +--- + drivers/acpi/numa/hmat.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c +index 137a5dd880c2..fd202689dcda 100644 +--- a/drivers/acpi/numa/hmat.c ++++ b/drivers/acpi/numa/hmat.c +@@ -645,7 +645,6 @@ static void hmat_register_target_initiators(struct memory_target *target) + /* Access 1 ignores Generic Initiators */ + bitmap_zero(p_nodes, MAX_NUMNODES); + list_sort(p_nodes, &initiators, initiator_cmp); +- best = 0; + for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) { + loc = localities_types[i]; + if (!loc) +-- +2.35.1 + diff --git a/queue-5.10/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch b/queue-5.10/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch new file mode 100644 index 00000000000..b6c3a396663 --- /dev/null +++ b/queue-5.10/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch @@ -0,0 +1,54 @@ +From 5c6d08cfa1854ed7bc68e47ad89633a850f24bbe Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 10 Nov 2022 00:59:02 +0100 +Subject: i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set + +From: Andrew Lunn + +[ Upstream commit d36678f7905cbd1dc55a8a96e066dafd749d4600 ] + +Recent changes to the DMA code has resulting in the IMX driver failing +I2C transfers when the buffer has been vmalloc. Only perform DMA +transfers if the message has the I2C_M_DMA_SAFE flag set, indicating +the client is providing a buffer which is DMA safe. + +This is a minimal fix for stable. The I2C core provides helpers to +allocate a bounce buffer. For a fuller fix the master should make use +of these helpers. + +Fixes: 4544b9f25e70 ("dma-mapping: Add vmap checks to dma_map_single()") +Signed-off-by: Andrew Lunn +Acked-by: Oleksij Rempel +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-imx.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c +index be4ad516293b..b4fb4336b4e8 100644 +--- a/drivers/i2c/busses/i2c-imx.c ++++ b/drivers/i2c/busses/i2c-imx.c +@@ -843,7 +843,8 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, + int i, result; + unsigned int temp; + int block_data = msgs->flags & I2C_M_RECV_LEN; +- int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data; ++ int use_dma = i2c_imx->dma && msgs->flags & I2C_M_DMA_SAFE && ++ msgs->len >= DMA_THRESHOLD && !block_data; + + dev_dbg(&i2c_imx->adapter.dev, + "<%s> write slave address: addr=0x%x\n", +@@ -1011,7 +1012,8 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter, + result = i2c_imx_read(i2c_imx, &msgs[i], is_lastmsg, atomic); + } else { + if (!atomic && +- i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD) ++ i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD && ++ msgs[i].flags & I2C_M_DMA_SAFE) + result = i2c_imx_dma_write(i2c_imx, &msgs[i]); + else + result = i2c_imx_write(i2c_imx, &msgs[i], atomic); +-- +2.35.1 + diff --git a/queue-5.10/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch b/queue-5.10/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch new file mode 100644 index 00000000000..c9c0139d60d --- /dev/null +++ b/queue-5.10/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch @@ -0,0 +1,64 @@ +From fd10d5f5bd503169c9481a237b5a7d5634691c7a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 9 Nov 2022 11:22:50 +0000 +Subject: i2c: npcm7xx: Fix error handling in npcm_i2c_init() + +From: Yuan Can + +[ Upstream commit 145900cf91c4b32ac05dbc8675a0c7f4a278749d ] + +A problem about i2c-npcm7xx create debugfs failed is triggered with the +following log given: + + [ 173.827310] debugfs: Directory 'npcm_i2c' with parent '/' already present! + +The reason is that npcm_i2c_init() returns platform_driver_register() +directly without checking its return value, if platform_driver_register() +failed, it returns without destroy the newly created debugfs, resulting +the debugfs of npcm_i2c can never be created later. + + npcm_i2c_init() + debugfs_create_dir() # create debugfs directory + platform_driver_register() + driver_register() + bus_add_driver() + priv = kzalloc(...) # OOM happened + # return without destroy debugfs directory + +Fix by removing debugfs when platform_driver_register() returns error. + +Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver") +Signed-off-by: Yuan Can +Reviewed-by: Tali Perry +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-npcm7xx.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c +index 31e3d2c9d6bc..c1b679737240 100644 +--- a/drivers/i2c/busses/i2c-npcm7xx.c ++++ b/drivers/i2c/busses/i2c-npcm7xx.c +@@ -2362,8 +2362,17 @@ static struct platform_driver npcm_i2c_bus_driver = { + + static int __init npcm_i2c_init(void) + { ++ int ret; ++ + npcm_i2c_debugfs_dir = debugfs_create_dir("npcm_i2c", NULL); +- return platform_driver_register(&npcm_i2c_bus_driver); ++ ++ ret = platform_driver_register(&npcm_i2c_bus_driver); ++ if (ret) { ++ debugfs_remove_recursive(npcm_i2c_debugfs_dir); ++ return ret; ++ } ++ ++ return 0; + } + module_init(npcm_i2c_init); + +-- +2.35.1 + diff --git a/queue-5.10/series b/queue-5.10/series index 1618d79850b..07ac09e2962 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -82,3 +82,7 @@ ipv4-fix-route-deletion-when-nexthop-info-is-not-spe.patch revert-tty-n_gsm-avoid-call-of-sleeping-functions-from-atomic-context.patch x86-tsx-add-a-feature-bit-for-tsx-control-msr-support.patch x86-pm-add-enumeration-check-before-spec-msrs-save-restore-setup.patch +i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch +i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch +acpi-hmat-remove-unnecessary-variable-initialization.patch +acpi-hmat-fix-initiator-registration-for-single-init.patch -- 2.47.3