From: Sasha Levin Date: Sun, 4 Dec 2022 21:10:30 +0000 (-0500) Subject: Fixes for 6.0 X-Git-Tag: v4.9.335~37^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9fb495330ec9bb4d8c4c412b901575684a0e055e;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.0 Signed-off-by: Sasha Levin --- diff --git a/queue-6.0/acpi-hmat-fix-initiator-registration-for-single-init.patch b/queue-6.0/acpi-hmat-fix-initiator-registration-for-single-init.patch new file mode 100644 index 00000000000..d411523a5a9 --- /dev/null +++ b/queue-6.0/acpi-hmat-fix-initiator-registration-for-single-init.patch @@ -0,0 +1,111 @@ +From b35304e373e1b6d6edd8ee8c41175971e9936914 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 fca69a726360..b42653707fdc 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-6.0/acpi-hmat-remove-unnecessary-variable-initialization.patch b/queue-6.0/acpi-hmat-remove-unnecessary-variable-initialization.patch new file mode 100644 index 00000000000..c4a53235f8b --- /dev/null +++ b/queue-6.0/acpi-hmat-remove-unnecessary-variable-initialization.patch @@ -0,0 +1,42 @@ +From 05f0bef5e777f3f62e4b6a2735fe0e53c399819f 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 c3d783aca196..fca69a726360 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-6.0/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch b/queue-6.0/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch new file mode 100644 index 00000000000..c971eba8834 --- /dev/null +++ b/queue-6.0/i2c-imx-only-dma-messages-with-i2c_m_dma_safe-flag-s.patch @@ -0,0 +1,54 @@ +From 8fc4f96558e8f83b9c6fb07e2bd1fc6dd9080847 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 3082183bd66a..fc70920c4dda 100644 +--- a/drivers/i2c/busses/i2c-imx.c ++++ b/drivers/i2c/busses/i2c-imx.c +@@ -1132,7 +1132,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", +@@ -1298,7 +1299,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-6.0/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch b/queue-6.0/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch new file mode 100644 index 00000000000..c620dcd26ee --- /dev/null +++ b/queue-6.0/i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch @@ -0,0 +1,64 @@ +From 346a455f1f4b84bfb342787cb97d0badabbe59b3 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 0c365b57d957..83457359ec45 100644 +--- a/drivers/i2c/busses/i2c-npcm7xx.c ++++ b/drivers/i2c/busses/i2c-npcm7xx.c +@@ -2393,8 +2393,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-6.0/i2c-qcom-geni-fix-error-return-code-in-geni_i2c_gpi_.patch b/queue-6.0/i2c-qcom-geni-fix-error-return-code-in-geni_i2c_gpi_.patch new file mode 100644 index 00000000000..e8a20aeed4b --- /dev/null +++ b/queue-6.0/i2c-qcom-geni-fix-error-return-code-in-geni_i2c_gpi_.patch @@ -0,0 +1,36 @@ +From eefd3a9c5280eba838a77bfcfe4bc2617d7ad86d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 21 Nov 2022 18:17:52 +0800 +Subject: i2c: qcom-geni: fix error return code in geni_i2c_gpi_xfer + +From: Wang Yufen + +[ Upstream commit 7d8ccf4f117d082156e842d959f634efcf203cef ] + +Fix to return a negative error code from the gi2c->err instead of +0. + +Fixes: d8703554f4de ("i2c: qcom-geni: Add support for GPI DMA") +Signed-off-by: Wang Yufen +Reviewed-by: Tommaso Merciai +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-qcom-geni.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c +index 84a77512614d..8fce98bb77ff 100644 +--- a/drivers/i2c/busses/i2c-qcom-geni.c ++++ b/drivers/i2c/busses/i2c-qcom-geni.c +@@ -626,7 +626,6 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], i + dev_err(gi2c->se.dev, "I2C timeout gpi flags:%d addr:0x%x\n", + gi2c->cur->flags, gi2c->cur->addr); + gi2c->err = -ETIMEDOUT; +- goto err; + } + + if (gi2c->err) { +-- +2.35.1 + diff --git a/queue-6.0/series b/queue-6.0/series index 2bbe3e5c535..dfbb22ae354 100644 --- a/queue-6.0/series +++ b/queue-6.0/series @@ -112,3 +112,8 @@ ipv4-handle-attempt-to-delete-multipath-route-when-f.patch ipv4-fix-route-deletion-when-nexthop-info-is-not-spe.patch mm-damon-introduce-struct-damos_access_pattern.patch mm-damon-sysfs-fix-wrong-empty-schemes-assumption-un.patch +i2c-npcm7xx-fix-error-handling-in-npcm_i2c_init.patch +i2c-qcom-geni-fix-error-return-code-in-geni_i2c_gpi_.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