6.1.53-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 279/600 md/raid10: use dereference_rdev_and_rrdev() to get devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 673643490b9a0eb3b25633abe604f62b8f63dba1 ]
Commit 2ae6aaf76912 ("md/raid10: fix io loss while replacement replace rdev") reads replacement first to prevent io loss. However, there are same issue in wait_blocked_dev() and raid10_handle_discard(), too. Fix it by using dereference_rdev_and_rrdev() to get devices.
--- drivers/md/raid10.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/md/raid10.c +5 -8
@@ -1346,11 +1346,9 @@ static void wait_blocked_dev(struct mddev *mddev, struct r10bio *r10_bio) blocked_rdev =NULL ;rcu_read_lock ();for (i =0 ; i < conf->copies; i++) { -struct md_rdev *rdev =rcu_dereference (conf->mirrors[i].rdev); -struct md_rdev *rrdev =rcu_dereference ( - conf->mirrors[i].replacement); -if (rdev == rrdev) - rrdev =NULL ; +struct md_rdev *rdev, *rrdev; + + rdev =dereference_rdev_and_rrdev (&conf->mirrors[i], &rrdev);if (rdev &&unlikely (test_bit (Blocked, &rdev->flags))) {atomic_inc (&rdev->nr_pending); blocked_rdev = rdev;
@@ -1786,10 +1784,9 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)*/ rcu_read_lock ();for (disk =0 ; disk < geo->raid_disks; disk++) { -struct md_rdev *rdev =rcu_dereference (conf->mirrors[disk].rdev); -struct md_rdev *rrdev =rcu_dereference ( - conf->mirrors[disk].replacement); +struct md_rdev *rdev, *rrdev; + rdev =dereference_rdev_and_rrdev (&conf->mirrors[disk], &rrdev); r10_bio->devs[disk].bio =NULL ; r10_bio->devs[disk].repl_bio =NULL ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 280/600 md/md-bitmap: remove unnecessary local variable in backlog_store()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit b4d129640f194ffc4cc64c3e97f98ae944c072e8 ]
Local variable is definied first in the beginning of backlog_store(), there is no need to define it again.
--- drivers/md/md-bitmap.c | 2 -- 1 file changed, 2 deletions(-)
drivers/md/md-bitmap.c +0 -2
@@ -2504,8 +2504,6 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len)mddev_destroy_serial_pool (mddev,NULL , false); }else if (backlog && !mddev->serial_info_pool) {/* serial_info_pool is needed since backlog is not zero */ -struct md_rdev *rdev; -rdev_for_each (rdev, mddev)mddev_create_serial_pool (mddev, rdev, false); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 281/600 md/md-bitmap: hold reconfig_mutex in backlog_store()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 44abfa6a95df425c0660d56043020b67e6d93ab8 ]
Several reasons why 'reconfig_mutex' should be held:
1) rdev_for_each() is not safe to be called without the lock, because rdev can be removed concurrently.
2) mddev_destroy_serial_pool() and mddev_create_serial_pool() should not be called concurrently.
3) mddev_suspend() from mddev_destroy/create_serial_pool() should be protected by the lock.
--- drivers/md/md-bitmap.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/md/md-bitmap.c +7 -0
@@ -2481,6 +2481,10 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len)if (backlog >COUNTER_MAX )return -EINVAL ; + rv =mddev_lock (mddev); +if (rv) +return rv; +/* * Without write mostly device, it doesn't make sense to set * backlog for max_write_behind.
@@ -2494,6 +2498,7 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len)if (!has_write_mostly) {pr_warn_ratelimited ("%s: can't set backlog, no write mostly device available\n" ,mdname (mddev)); +mddev_unlock (mddev);return -EINVAL ; }
@@ -2509,6 +2514,8 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len) }if (old_mwb != backlog)md_bitmap_update_sb (mddev->bitmap); + +mddev_unlock (mddev);return len; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 282/600 drm/msm: Update dev core dump to not print backwards
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan McCann <[email protected]>
[ Upstream commit 903705111d863ed8ccf73465da77d232fc422ec1 ]
Device core dump add block method adds hardware blocks to dumping queue with stack behavior which causes the hardware blocks to be printed in reverse order. Change the addition to dumping queue data structure from "list_add" to "list_add_tail" for FIFO queue behavior.
Patchwork: https://patchwork.freedesktop.org/patch/546200/
--- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +1 -1
@@ -192,5 +192,5 @@ void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len, new_blk->base_addr = base_addr;msm_disp_state_dump_regs (&new_blk->state, new_blk->size, base_addr); -list_add (&new_blk->node, &disp_state->blocks); +list_add_tail (&new_blk->node, &disp_state->blocks); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 283/600 drm/tegra: dpaux: Fix incorrect return value of platform_get_irq
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yangtao Li <[email protected]>
[ Upstream commit 2a1ca44b654346cadfc538c4fb32eecd8daf3140 ]
When platform_get_irq fails, we should return dpaux->irq instead of -ENXIO.
--- drivers/gpu/drm/tegra/dpaux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/dpaux.c +1 -1
@@ -468,7 +468,7 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->irq =platform_get_irq (pdev,0 );if (dpaux->irq <0 ) -return -ENXIO ; +return dpaux->irq;if (!pdev->dev.pm_domain) { dpaux->rst =devm_reset_control_get (&pdev->dev,"dpaux" );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 284/600 of: unittest: fix null pointer dereferencing in of_unittest_find_node_by_name()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruan Jinjie <[email protected]>
[ Upstream commit d6ce4f0ea19c32f10867ed93d8386924326ab474 ]
when kmalloc() fail to allocate memory in kasprintf(), name or full_name will be NULL, strcmp() will cause null pointer dereference.
--- drivers/of/unittest.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/of/unittest.c +6 -4
@@ -70,7 +70,7 @@ static void __init of_unittest_find_node_by_name(void) np =of_find_node_by_path ("/testcase-data" ); name =kasprintf (GFP_KERNEL ,"%pOF" , np); -unittest (np && !strcmp ("/testcase-data" , name), +unittest (np && name && !strcmp ("/testcase-data" , name),"find /testcase-data failed\n" );of_node_put (np);kfree (name);
@@ -81,14 +81,14 @@ static void __init of_unittest_find_node_by_name(void) np =of_find_node_by_path ("/testcase-data/phandle-tests/consumer-a" ); name =kasprintf (GFP_KERNEL ,"%pOF" , np); -unittest (np && !strcmp ("/testcase-data/phandle-tests/consumer-a" , name), +unittest (np && name && !strcmp ("/testcase-data/phandle-tests/consumer-a" , name),"find /testcase-data/phandle-tests/consumer-a failed\n" );of_node_put (np);kfree (name); np =of_find_node_by_path ("testcase-alias" ); name =kasprintf (GFP_KERNEL ,"%pOF" , np); -unittest (np && !strcmp ("/testcase-data" , name), +unittest (np && name && !strcmp ("/testcase-data" , name),"find testcase-alias failed\n" );of_node_put (np);kfree (name);
@@ -99,7 +99,7 @@ static void __init of_unittest_find_node_by_name(void) np =of_find_node_by_path ("testcase-alias/phandle-tests/consumer-a" ); name =kasprintf (GFP_KERNEL ,"%pOF" , np); -unittest (np && !strcmp ("/testcase-data/phandle-tests/consumer-a" , name), +unittest (np && name && !strcmp ("/testcase-data/phandle-tests/consumer-a" , name),"find testcase-alias/phandle-tests/consumer-a failed\n" );of_node_put (np);kfree (name);
@@ -1379,6 +1379,8 @@ static void attach_node_and_children(struct device_node *np)const char *full_name; full_name =kasprintf (GFP_KERNEL ,"%pOF" , np); +if (!full_name) +return ;if (!strcmp (full_name,"/__local_fixups__" ) || !strcmp (full_name,"/__fixups__" )) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 285/600 arm64: dts: qcom: sm8150: Fix the I2C7 interrupt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zeyan Li <[email protected]>
[ Upstream commit f9568d22ce06192a7e14bda3a29dc216659554ff ]
I2C6 and I2C7 use the same interrupts, which is incorrect. In the downstream kernel, I2C7 has interrupts of 608 instead of 607.
--- arch/arm64/boot/dts/qcom/sm8150.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sm8150.dtsi +1 -1
@@ -1196,7 +1196,7 @@ i2c7: i2c@89c000 { dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&qup_i2c7_default>; - interrupts = <GIC_SPI 607 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 608 IRQ_TYPE_LEVEL_HIGH>; #address-cells = <1>; #size-cells = <0>; status = "disabled";
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 286/600 ARM: dts: BCM53573: Fix Tenda AC9 switch CPU port
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
[ Upstream commit 7141209db9c335ab261a17933809a3e660ebdc12 ]
Primary Ethernet interface is connected to the port 8 (not 5).
--- arch/arm/boot/dts/bcm47189-tenda-ac9.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/bcm47189-tenda-ac9.dts +2 -2
@@ -135,8 +135,8 @@ port@4 { label = "lan4"; }; - port@5 { - reg = <5>; + port@8 { + reg = <8>; label = "cpu"; ethernet = <&gmac0>; };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 287/600 drm/armada: Fix off-by-one error in armada_overlay_get_property()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 5f0d984053f74983a287100a9519b2fabb785fb5 ]
As ffs() returns one more than the index of the first bit set (zero means no bits set), the color key mode value is shifted one position too much.
Fix this by using FIELD_GET() instead.
--- drivers/gpu/drm/armada/armada_overlay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/armada/armada_overlay.c +4 -2
@@ -4,6 +4,8 @@* Rewritten from the dovefb driver, and Armada510 manuals. */ +#include <linux/bitfield.h> +#include <drm/armada_drm.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h>
@@ -445,8 +447,8 @@ static int armada_overlay_get_property(struct drm_plane *plane,drm_to_overlay_state (state)->colorkey_ug, drm_to_overlay_state(state)->colorkey_vb, 0); }else if (property == priv->colorkey_mode_prop) { - *val = (drm_to_overlay_state (state)->colorkey_mode & -CFG_CKMODE_MASK ) >>ffs (CFG_CKMODE_MASK ); + *val =FIELD_GET (CFG_CKMODE_MASK , +drm_to_overlay_state (state)->colorkey_mode); }else if (property == priv->brightness_prop) { *val =drm_to_overlay_state (state)->brightness +256 ; }else if (property == priv->contrast_prop) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 288/600 drm/repaper: Reduce temporary buffer size in repaper_fb_dirty()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit fedf429e071f6dbbe7a69dfc342492e037692018 ]
As the temporary buffer is no longer used to store 8-bit grayscale data, its size can be reduced to the size needed to store the monochrome bitmap data.
--- drivers/gpu/drm/tiny/repaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tiny/repaper.c +1 -1
@@ -533,7 +533,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)DRM_DEBUG ("Flushing [FB:%d] st=%ums\n" , fb->base.id, epd->factored_stage_time); - buf =kmalloc_array (fb->width, fb->height,GFP_KERNEL ); + buf =kmalloc (fb->width * fb->height /8 ,GFP_KERNEL );if (!buf) { ret = -ENOMEM ; goto out_exit;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 289/600 drm/panel: simple: Add missing connector type and pixel format for AUO T215HVN01
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 7a675a8fa598edb29a664a91adb80f0340649f6f ]
The connector type and pixel format are missing for this panel, add them to prevent various drivers from failing to determine either of those parameters.
--- drivers/gpu/drm/panel/panel-simple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-simple.c +3 -1
@@ -1159,7 +1159,9 @@ static const struct panel_desc auo_t215hvn01 = { .delay = { .disable = 5, .unprepare = 1000, - } + }, + .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, + .connector_type = DRM_MODE_CONNECTOR_LVDS, };static const struct drm_display_mode avic_tm070ddh03_mode = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 290/600 ima: Remove deprecated IMA_TRUSTED_KEYRING Kconfig
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nayna Jain <[email protected]>
[ Upstream commit 5087fd9e80e539d2163accd045b73da64de7de95 ]
Time to remove "IMA_TRUSTED_KEYRING".
--- security/integrity/ima/Kconfig | 12 ------------ 1 file changed, 12 deletions(-)
security/integrity/ima/Kconfig +0 -12
@@ -248,18 +248,6 @@ config IMA_APPRAISE_MODSIG The modsig keyword can be used in the IMA policy to allow a hook to accept such signatures. -config IMA_TRUSTED_KEYRING - bool "Require all keys on the .ima keyring be signed (deprecated)" - depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING - depends on INTEGRITY_ASYMMETRIC_KEYS - select INTEGRITY_TRUSTED_KEYRING - default y - help - This option requires that all keys added to the .ima - keyring be signed by a key on the system trusted keyring. - - This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING - config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY bool "Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)" depends on SYSTEM_TRUSTED_KEYRING
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 291/600 drm: xlnx: zynqmp_dpsub: Add missing check for dma_set_mask
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 1832fba7f9780aff67c96ad30f397c2d76141833 ]
Add check for dma_set_mask() and return the error if it fails.
--- drivers/gpu/drm/xlnx/zynqmp_dpsub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/xlnx/zynqmp_dpsub.c +3 -1
@@ -201,7 +201,9 @@ static int zynqmp_dpsub_probe(struct platform_device *pdev) dpsub->dev = &pdev->dev;platform_set_drvdata (pdev, dpsub); -dma_set_mask (dpsub->dev,DMA_BIT_MASK (ZYNQMP_DISP_MAX_DMA_BIT )); + ret =dma_set_mask (dpsub->dev,DMA_BIT_MASK (ZYNQMP_DISP_MAX_DMA_BIT )); +if (ret) +return ret;/* Try the reserved memory. Proceed if there's none. */ of_reserved_mem_device_init (&pdev->dev);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 292/600 soc: qcom: smem: Fix incompatible types in comparison
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Jiahao <[email protected]>
[ Upstream commit 5f908786cf44fcb397cfe0f322ef2f41b0909e2a ]
This patch fixes the following sparse error:
drivers/soc/qcom/smem.c:738:30: error: incompatible types in comparison expression (different add ress spaces):drivers/soc/qcom/smem.c:738:30: void *drivers/soc/qcom/smem.c:738:30: void [noderef] __iomem *
In addr_in_range(), "base" is of type void __iomem *, converting void *addr to the same type to fix above sparse error.
--- drivers/soc/qcom/smem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/smem.c +1 -1
@@ -723,7 +723,7 @@ EXPORT_SYMBOL(qcom_smem_get_free_space);static bool addr_in_range (void __iomem *base,size_t size,void *addr) { -return base && (addr >= base && addr < base + size); +return base && ((void __iomem *)addr >= base && (void __iomem *)addr < base + size); }/**
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 293/600 drm/msm/mdp5: Dont leak some plane state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <[email protected]>
[ Upstream commit fd0ad3b2365c1c58aa5a761c18efc4817193beb6 ]
Apparently no one noticed that mdp5 plane states leak like a sieve ever since we introduced plane_state->commit refcount a few years ago in 21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early by tracking commits, v3.")
Fix it by using the right helpers.
Patchwork: https://patchwork.freedesktop.org/patch/551236/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +1 -2
@@ -130,8 +130,7 @@ static void mdp5_plane_destroy_state(struct drm_plane *plane, {struct mdp5_plane_state *pstate =to_mdp5_plane_state (state); -if (state->fb) -drm_framebuffer_put (state->fb); +__drm_atomic_helper_plane_destroy_state (state);kfree (pstate); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 294/600 firmware: meson_sm: fix to avoid potential NULL pointer dereference
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit f2ed165619c16577c02b703a114a1f6b52026df4 ]
of_match_device() may fail and returns a NULL pointer.
Fix this by checking the return value of of_match_device.
--- drivers/firmware/meson/meson_sm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/meson/meson_sm.c +2 -0
@@ -292,6 +292,8 @@ static int __init meson_sm_probe(struct platform_device *pdev)return -ENOMEM ; chip =of_match_device (meson_sm_ids, dev)->data; +if (!chip) +return -EINVAL ;if (chip->cmd_shmem_in_base) { fw->sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 295/600 drm/msm/dpu: fix the irq index in dpu_encoder_phys_wb_wait_for_commit_done
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit d93cf453f51da168f4410ba73656f1e862096973 ]
Since commit 1e7ac595fa46 ("drm/msm/dpu: pass irq to dpu_encoder_helper_wait_for_irq()") the dpu_encoder_phys_wb_wait_for_commit_done expects the IRQ index rather than the IRQ index in phys_enc->intr table, however writeback got the older invocation in place. This was unnoticed for several releases, but now it's time to fix it.
Patchwork: https://patchwork.freedesktop.org/patch/550924/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +2 -1
@@ -460,7 +460,8 @@ static int dpu_encoder_phys_wb_wait_for_commit_done( wait_info.atomic_cnt = &phys_enc->pending_kickoff_cnt; wait_info.timeout_ms =KICKOFF_TIMEOUT_MS ; - ret =dpu_encoder_helper_wait_for_irq (phys_enc,INTR_IDX_WB_DONE , + ret =dpu_encoder_helper_wait_for_irq (phys_enc, + phys_enc->irq[INTR_IDX_WB_DONE ], dpu_encoder_phys_wb_done_irq, &wait_info);if (ret == -ETIMEDOUT )_dpu_encoder_phys_wb_handle_wbdone_timeout (phys_enc);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 296/600 smackfs: Prevent underflow in smk_set_cipso()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 3ad49d37cf5759c3b8b68d02e3563f633d9c1aee ]
There is a upper bound to "catlen" but no lower bound to prevent negatives. I don't see that this necessarily causes a problem but we may as well be safe.
--- security/smack/smackfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smackfs.c +1 -1
@@ -896,7 +896,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, } ret =sscanf (rule,"%d" , &catlen); -if (ret !=1 || catlen >SMACK_CIPSO_MAXCATNUM ) +if (ret !=1 || catlen <0 || catlen >SMACK_CIPSO_MAXCATNUM ) goto out; if (format == SMK_FIXED24_FMT &&
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 297/600 drm/amd/pm: fix variable dereferenced issue in amdgpu_device_attr_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Wang <[email protected]>
[ Upstream commit 25e6373a5b8efc623443f2699d2b929bf3067d76 ]
- fix variable ('attr') dereferenced issue.
- using condition check instead of BUG_ON().
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7 -3
@@ -2072,15 +2072,19 @@ static int amdgpu_device_attr_create(struct amdgpu_device *adev, uint32_t mask, struct list_head *attr_list) { int ret = 0; -struct device_attribute *dev_attr = &attr->dev_attr; -const char *name = dev_attr->attr.name;enum amdgpu_device_attr_states attr_states =ATTR_STATE_SUPPORTED ;struct amdgpu_device_attr_entry *attr_entry; +struct device_attribute *dev_attr; +const char *name;int (*attr_update)(struct amdgpu_device *adev,struct amdgpu_device_attr *attr,uint32_t mask,enum amdgpu_device_attr_states *states) = default_attr_update; -BUG_ON (!attr); +if (!attr) +return -EINVAL ; + + dev_attr = &attr->dev_attr; + name = dev_attr->attr.name; attr_update = attr->attr_update ? attr->attr_update : default_attr_update;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 298/600 drm/msm/a2xx: Call adreno_gpu_init() earlier
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit db07ce5da8b26bfeaf437a676ae49bd3bb1eace6 ]
The adreno_is_a20x() and adreno_is_a225() functions rely on the GPU revision, but such information is retrieved inside adreno_gpu_init(), which is called afterwards.
Fix this problem by caling adreno_gpu_init() earlier, so that the GPU information revision is available when adreno_is_a20x() and adreno_is_a225() run.
Tested on a imx53-qsb board.
Patchwork: https://patchwork.freedesktop.org/patch/543456/
--- drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a2xx_gpu.c +4 -4
@@ -521,6 +521,10 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev) gpu->perfcntrs = perfcntrs; gpu->num_perfcntrs =ARRAY_SIZE (perfcntrs); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 ); +if (ret) + goto fail; +if (adreno_is_a20x (adreno_gpu)) adreno_gpu->registers = a200_registers;else if (adreno_is_a225 (adreno_gpu))
@@ -528,10 +532,6 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev)else adreno_gpu->registers = a220_registers; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 ); -if (ret) - goto fail; -if (!gpu->aspace) {dev_err (dev->dev,"No memory protection without MMU\n" );if (!allow_vram_carveout) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 299/600 audit: fix possible soft lockup in __audit_inode_child()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaosheng Cui <[email protected]>
[ Upstream commit b59bc6e37237e37eadf50cd5de369e913f524463 ]
Tracefs or debugfs maybe cause hundreds to thousands of PATH records, too many PATH records maybe cause soft lockup.
For example:
1. CONFIG_KASAN=y && CONFIG_PREEMPTION=n
2. auditctl -a exit,always -S open -k key
3. sysctl -w kernel.watchdog_thresh=5
4. mkdir /sys/kernel/debug/tracing/instances/test
There may be a soft lockup as follows:
watchdog: BUG: soft lockup - CPU#45 stuck for 7s! [mkdir:15498] Kernel panic - not syncing: softlockup: hung tasks Call trace: dump_backtrace+0x0/0x30c show_stack+0x20/0x30 dump_stack+0x11c/0x174 panic+0x27c/0x494 watchdog_timer_fn+0x2bc/0x390 __run_hrtimer+0x148/0x4fc __hrtimer_run_queues+0x154/0x210 hrtimer_interrupt+0x2c4/0x760 arch_timer_handler_phys+0x48/0x60 handle_percpu_devid_irq+0xe0/0x340 __handle_domain_irq+0xbc/0x130 gic_handle_irq+0x78/0x460 el1_irq+0xb8/0x140 __audit_inode_child+0x240/0x7bc tracefs_create_file+0x1b8/0x2a0 trace_create_file+0x18/0x50 event_create_dir+0x204/0x30c __trace_add_new_event+0xac/0x100 event_trace_add_tracer+0xa0/0x130 trace_array_create_dir+0x60/0x140 trace_array_create+0x1e0/0x370 instance_mkdir+0x90/0xd0 tracefs_syscall_mkdir+0x68/0xa0 vfs_mkdir+0x21c/0x34c do_mkdirat+0x1b4/0x1d4 __arm64_sys_mkdirat+0x4c/0x60 el0_svc_common.constprop.0+0xa8/0x240 do_el0_svc+0x8c/0xc0 el0_svc+0x20/0x30 el0_sync_handler+0xb0/0xb4 el0_sync+0x160/0x180
Therefore, we add cond_resched() to __audit_inode_child() to fix it.
--- kernel/auditsc.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/auditsc.c +2 -0
@@ -2456,6 +2456,8 @@ void __audit_inode_child(struct inode *parent, } } +cond_resched (); +/* is there a matching child entry? */ list_for_each_entry (n, &context->names_list, list) {/* can only match entries that have a name */
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 300/600 block/mq-deadline: use correct way to throttling write requests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit d47f9717e5cfd0dd8c0ba2ecfa47c38d140f1bb6 ]
The original formula was inaccurate:dd->async_depth = max(1UL, 3 * q->nr_requests / 4);
For write requests, when we assign a tags from sched_tags, data->shallow_depth will be passed to sbitmap_find_bit, see the following code:
nr = sbitmap_find_bit_in_word(&sb->map[index],
min_t (unsigned int, __map_depth(sb, index), depth), alloc_hint, wrap);
The smaller of data->shallow_depth and __map_depth(sb, index) will be used as the maximum range when allocating bits.
For a mmc device (one hw queue, deadline I/O scheduler):q->nr_requests = sched_tags = 128, so according to the previous calculation method, dd->async_depth = data->shallow_depth = 96, and the platform is 64bits with 8 cpus, sched_tags.bitmap_tags.sb.shift=5, sb.maps[]=32/32/32/32, 32 is smaller than 96, whether it is a read or a write I/O, tags can be allocated to the maximum range each time, which has not throttling effect.
In addition, refer to the methods of bfg/kyber I/O scheduler, limit ratiois are calculated base on sched_tags.bitmap_tags.sb.shift.
This patch can throttle write requests really.
--- block/mq-deadline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/mq-deadline.c +2 -1
@@ -622,8 +622,9 @@ static void dd_depth_updated(struct blk_mq_hw_ctx *hctx)struct request_queue *q = hctx->queue;struct deadline_data *dd = q->elevator->elevator_data;struct blk_mq_tags *tags = hctx->sched_tags; +unsigned int shift = tags->bitmap_tags.sb.shift; - dd->async_depth =max (1UL ,3 * q->nr_requests /4 ); + dd->async_depth =max (1U ,3 * (1U << shift) /4 );sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, dd->async_depth); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 301/600 io_uring: fix drain stalls by invalid SQE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit cfdbaa3a291d6fd2cb4a1a70d74e63b4abc2f5ec ]
cq_extra is protected by ->completion_lock, which io_get_sqe() misses. The bug is harmless as it doesn't happen in real life, requires invalid SQ index array and racing with submission, and only messes up the userspace, i.e. stall requests execution but will be cleaned up on ring destruction.
--- io_uring/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/io_uring.c +2 -0
@@ -2240,7 +2240,9 @@ static const struct io_uring_sqe *io_get_sqe(struct io_ring_ctx *ctx) }/* drop invalid entries */ +spin_lock (&ctx->completion_lock); ctx->cq_extra--; +spin_unlock (&ctx->completion_lock);WRITE_ONCE (ctx->rings->sq_dropped,READ_ONCE (ctx->rings->sq_dropped) +1 );return NULL ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 302/600 drm/mediatek: dp: Add missing error checks in mtk_dp_parse_capabilities
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit cfc146137a9f12e883ba64bc496b6da4d23f26d5 ]
If reading the RX capabilities fails the training pattern will be set
wrongly: add error checking for drm_dp_read_dpcd_caps() and return if anything went wrong with it.
While at it, also add a less critical error check when writing to clear the ESI0 IRQ vector.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +10 -5
@@ -1588,7 +1588,9 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)u8 val;ssize_t ret; -drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); + ret =drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); +if (ret <0 ) +return ret;if (drm_dp_tps4_supported (mtk_dp->rx_cap)) mtk_dp->train_info.channel_eq_pattern =DP_TRAINING_PATTERN_4 ;
@@ -1615,10 +1617,13 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)return ret ==0 ? -EIO : ret; } -if (val) -drm_dp_dpcd_writeb (&mtk_dp->aux, -DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 , - val); +if (val) { + ret =drm_dp_dpcd_writeb (&mtk_dp->aux, +DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 , + val); +if (ret <0 ) +return ret; + } }return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 303/600 bus: ti-sysc: Fix build warning for 64-bit build
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
[ Upstream commit e1e1e9bb9d943ec690670a609a5f660ca10eaf85 ]
Fix "warning: cast from pointer to integer of different size" on 64-bit builds.
Note that this is a cosmetic fix at this point as the driver is not yet used for 64-bit systems.
--- drivers/bus/ti-sysc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/ti-sysc.c +1 -1
@@ -3125,7 +3125,7 @@ static int sysc_init_static_data(struct sysc *ddata) match =soc_device_match (sysc_soc_match);if (match && match->data) - sysc_soc->soc = (int )match->data; + sysc_soc->soc = (enum sysc_soc )match->data;/* * Check and warn about possible old incomplete dtb. We now want to see
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 304/600 drm/mediatek: Remove freeing not dynamic allocated memory
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason-JH.Lin <[email protected]>
[ Upstream commit 27b9e2ea3f2757da26bb8280e46f7fdbb1acb219 ]
Fixing the coverity issue of:mtk_drm_cmdq_pkt_destroy frees address of mtk_crtc->cmdq_handle
So remove the free function.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +2 -5
@@ -115,10 +115,9 @@ static int mtk_drm_cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *dma_addr_t dma_addr; pkt->va_base =kzalloc (size,GFP_KERNEL ); -if (!pkt->va_base) { -kfree (pkt); +if (!pkt->va_base)return -ENOMEM ; - } + pkt->buf_size = size; pkt->cl = (void *)client;
@@ -128,7 +127,6 @@ static int mtk_drm_cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *if (dma_mapping_error (dev, dma_addr)) {dev_err (dev,"dma map failed, size=%u\n" , (u32 )(u64 )size);kfree (pkt->va_base); -kfree (pkt);return -ENOMEM ; }
@@ -144,7 +142,6 @@ static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt)dma_unmap_single (client->chan->mbox->dev, pkt->pa_base, pkt->buf_size,DMA_TO_DEVICE ); kfree(pkt->va_base); - kfree(pkt); }#endif
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 305/600 ARM: dts: qcom: ipq4019: correct SDHCI XO clock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Marko <[email protected]>
[ Upstream commit b5ed7a5c1fdb3981713f7b637b72aa390c3db036 ]
Using GCC_DCD_XO_CLK as the XO clock for SDHCI controller is not correct, it seems that I somehow made a mistake of passing it instead of the fixed XO clock.
--- arch/arm/boot/dts/qcom-ipq4019.dtsi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm/boot/dts/qcom-ipq4019.dtsi +6 -3
@@ -228,9 +228,12 @@ sdhci: mmc@7824900 { interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "hc_irq", "pwr_irq"; bus-width = <8>; - clocks = <&gcc GCC_SDCC1_AHB_CLK>, <&gcc GCC_SDCC1_APPS_CLK>, - <&gcc GCC_DCD_XO_CLK>; - clock-names = "iface", "core", "xo"; + clocks = <&gcc GCC_SDCC1_AHB_CLK>, + <&gcc GCC_SDCC1_APPS_CLK>, + <&xo>; + clock-names = "iface", + "core", + "xo"; status = "disabled"; };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 306/600 drm/mediatek: Fix potential memory leak if vmap() fail
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sui Jingfeng <[email protected]>
[ Upstream commit 379091e0f6d179d1a084c65de90fa44583b14a70 ]
Also return -ENOMEM if such a failure happens, the implement should take responsibility for the error handling.
--- drivers/gpu/drm/mediatek/mtk_drm_gem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +5 -1
@@ -242,7 +242,11 @@ int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map) mtk_gem->kvaddr =vmap (mtk_gem->pages, npages,VM_MAP ,pgprot_writecombine (PAGE_KERNEL )); - +if (!mtk_gem->kvaddr) { +kfree (sgt); +kfree (mtk_gem->pages); +return -ENOMEM ; + } out:kfree (sgt);iosys_map_set_vaddr (map, mtk_gem->kvaddr);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 307/600 arm64: dts: qcom: apq8016-sbc: Fix ov5640 regulator supply names
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
[ Upstream commit 43a684580819e7f35b6cb38236be63c4cba26ef4 ]
The ov5640 driver expects DOVDD, AVDD and DVDD as regulator supply names.
The ov5640 has depended on these names since the driver was committed upstream in 2017. Similarly apq8016-sbc.dtsi has had completely different regulator names since its own initial commit in 2020.
Perhaps the regulators were left on in previous 410c bootloaders. In any case today on 6.5 we won't switch on the ov5640 without correctly naming the regulators.
--- arch/arm64/boot/dts/qcom/apq8016-sbc.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/qcom/apq8016-sbc.dts +3 -3
@@ -289,9 +289,9 @@ camera_rear@3b { clock-names = "xclk"; clock-frequency = <23880000>; - vdddo-supply = <&camera_vdddo_1v8>; - vdda-supply = <&camera_vdda_2v8>; - vddd-supply = <&camera_vddd_1v5>; + DOVDD-supply = <&camera_vdddo_1v8>; + AVDD-supply = <&camera_vdda_2v8>; + DVDD-supply = <&camera_vddd_1v5>; /* No camera mezzanine by default */ status = "disabled";
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 308/600 arm64: dts: qcom: msm8998: Drop bus clock reference from MMSS SMMU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit a3ce236364b82688ca4c7605f63c4efd68e9589c ]
The MMSS SMMU has been abusingly consuming the exposed RPM interconnect clock. Drop it.
--- arch/arm64/boot/dts/qcom/msm8998.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/qcom/msm8998.dtsi +3 -3
@@ -2418,10 +2418,10 @@ mmss_smmu: iommu@cd00000 { clocks = <&mmcc MNOC_AHB_CLK>, <&mmcc BIMC_SMMU_AHB_CLK>, - <&rpmcc RPM_SMD_MMAXI_CLK>, <&mmcc BIMC_SMMU_AXI_CLK>; - clock-names = "iface-mm", "iface-smmu", - "bus-mm", "bus-smmu"; + clock-names = "iface-mm", + "iface-smmu", + "bus-smmu"; #global-interrupts = <0>; interrupts =
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 309/600 arm64: dts: qcom: msm8998: Add missing power domain to MMSS SMMU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 7f828f3207142351750e9545527341425187de7b ]
The MMSS SMMU has its own power domain. Attach it so that we can drop the "keep it always-on" hack.
--- arch/arm64/boot/dts/qcom/msm8998.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/msm8998.dtsi +2 -0
@@ -2445,6 +2445,8 @@ mmss_smmu: iommu@cd00000 { <GIC_SPI 261 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>; + + power-domains = <&mmcc BIMC_SMMU_GDSC>; }; remoteproc_adsp: remoteproc@17300000 {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 310/600 arm64: dts: qcom: msm8996: Fix dsi1 interrupts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Wronek <[email protected]>
[ Upstream commit bd3b4ac11845b428996cfd2c7b8302ba6a07340d ]
Fix IRQ flags mismatch which was keeping dsi1 from probing by changing interrupts = <4> to interrupts = <5>.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +1 -1
@@ -1063,7 +1063,7 @@ dsi1: dsi@996000 { reg-names = "dsi_ctrl"; interrupt-parent = <&mdss>; - interrupts = <4>; + interrupts = <5>; clocks = <&mmcc MDSS_MDP_CLK>, <&mmcc MDSS_BYTE1_CLK>,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 311/600 arm64: dts: qcom: sc8280xp-x13s: Unreserve NC pins
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 7868ed0144b33903e16a50485775f669c109e41a ]
Pins 83-86 and 158-160 are NC, so there's no point in keeping them reserved. Take care of that.
--- arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +1 -1
@@ -347,7 +347,7 @@ edp_bl_pwm: edp-bl-pwm-state { }; &tlmm { - gpio-reserved-ranges = <70 2>, <74 6>, <83 4>, <125 2>, <128 2>, <154 7>; + gpio-reserved-ranges = <70 2>, <74 6>, <125 2>, <128 2>, <154 4>; kybd_default: kybd-default-state { disable {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 312/600 bus: ti-sysc: Fix cast to enum warning
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
[ Upstream commit de44bf2f7683347f75690ef6cf61a1d5ba8f0891 ]
Fix warning for "cast to smaller integer type 'enum sysc_soc' from 'const void *'".
--- drivers/bus/ti-sysc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/ti-sysc.c +1 -1
@@ -3125,7 +3125,7 @@ static int sysc_init_static_data(struct sysc *ddata) match =soc_device_match (sysc_soc_match);if (match && match->data) - sysc_soc->soc = (enum sysc_soc )match->data; + sysc_soc->soc = (enum sysc_soc )(uintptr_t )match->data;/* * Check and warn about possible old incomplete dtb. We now want to see
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 313/600 md/raid5-cache: fix a deadlock in r5l_exit_log()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit a705b11b358dee677aad80630e7608b2d5f56691 ]
Commit b13015af94cf ("md/raid5-cache: Clear conf->log after finishing work") introduce a new problem:
// caller hold reconfig_mutexr5l_exit_log
flush_work(&log->disable_writeback_work)
r5c_disable_writeback_async wait_event /* * conf->log is not NULL, and mddev_trylock() * will fail, wait_event() can never pass. */
conf->log = NULL
Fix this problem by setting 'config->log' to NULL before wake_up() as it used to be, so that wait_event() from r5c_disable_writeback_async() can exist. In the meantime, move forward md_unregister_thread() so that null-ptr-deref this commit fixed can still be fixed.
--- drivers/md/raid5-cache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/raid5-cache.c +6 -3
@@ -3166,12 +3166,15 @@ void r5l_exit_log(struct r5conf *conf) {struct r5l_log *log = conf->log; -/* Ensure disable_writeback_work wakes up and exits */ -wake_up (&conf->mddev->sb_wait); -flush_work (&log->disable_writeback_work);md_unregister_thread (&log->reclaim_thread); +/* +* 'reconfig_mutex' is held by caller, set 'confg->log' to NULL to +* ensure disable_writeback_work wakes up and exits. +*/ conf->log =NULL ; +wake_up (&conf->mddev->sb_wait); +flush_work (&log->disable_writeback_work);mempool_exit (&log->meta_pool);bioset_exit (&log->bs);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 314/600 md/raid5-cache: fix null-ptr-deref for r5l_flush_stripe_to_raid()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 0d0bd28c500173bfca78aa840f8f36d261ef1765 ]
r5l_flush_stripe_to_raid() will check if the list 'flushing_ios' is empty, and then submit 'flush_bio', however, r5l_log_flush_endio() is clearing the list first and then clear the bio, which will cause null-ptr-deref:
T1: submit flush io
raid5d
handle_active_stripes
r5l_flush_stripe_to_raid
// list is empty
// add 'io_end_ios' to the list
bio_init
submit_bio
// io1
T2: io1 is doner5l_log_flush_endio
list_splice_tail_init
// clear the list
T3: submit new flush io ... r5l_flush_stripe_to_raid // list is empty // add 'io_end_ios' to the list bio_init bio_uninit // clear bio->bi_blkg submit_bio // null-ptr-deref
Fix this problem by clearing bio before clearing the list in r5l_log_flush_endio().
--- drivers/md/raid5-cache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/raid5-cache.c +1 -2
@@ -1260,14 +1260,13 @@ static void r5l_log_flush_endio(struct bio *bio)if (bio->bi_status)md_error (log->rdev->mddev, log->rdev); +bio_uninit (bio);spin_lock_irqsave (&log->io_list_lock, flags);list_for_each_entry (io, &log->flushing_ios, log_sibling)r5l_io_run_stripes (io);list_splice_tail_init (&log->flushing_ios, &log->finished_ios);spin_unlock_irqrestore (&log->io_list_lock, flags); - -bio_uninit (bio); }/*
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 315/600 firmware: cs_dsp: Fix new control name check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Karpovich <[email protected]>
[ Upstream commit 7ac1102b227b36550452b663fd39ab1c09378a95 ]
Before adding a new FW control, its name is checked against existing controls list. But the string length in strncmp used to compare controls names is taken from the list, so if beginnings of the controls are matching, then the new control is not created. For example, if CAL_R control already exists, CAL_R_SELECTED is not created.
The fix is to compare string lengths as well.
--- drivers/firmware/cirrus/cs_dsp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/firmware/cirrus/cs_dsp.c +2 -1
@@ -939,7 +939,8 @@ static int cs_dsp_create_control(struct cs_dsp *dsp, ctl->alg_region.alg == alg_region->alg && ctl->alg_region.type == alg_region->type) {if ((!subname && !ctl->subname) || - (subname && !strncmp (ctl->subname, subname, ctl->subname_len))) { + (subname && (ctl->subname_len == subname_len) && + !strncmp (ctl->subname, subname, ctl->subname_len))) {if (!ctl->enabled) ctl->enabled =1 ;return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 316/600 md/raid1: free the r1bio before waiting for blocked rdev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueshi Hu <[email protected]>
[ Upstream commit 992db13a4aee766c8bfbf046ad15c2db5fa7cab8 ]
Raid1 reshape will change mempool and r1conf::raid_disks which are needed to free r1bio. allow_barrier() make a concurrent raid1_reshape() possible. So, free the in-flight r1bio before waiting blocked rdev.
--- drivers/md/raid1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/raid1.c +2 -2
@@ -1370,6 +1370,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,return ; } + retry_write: r1_bio =alloc_r1bio (mddev, bio); r1_bio->sectors = max_write_sectors;
@@ -1385,7 +1386,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,*/ disks = conf->raid_disks *2 ; - retry_write: blocked_rdev =NULL ;rcu_read_lock (); max_sectors = r1_bio->sectors;
@@ -1465,7 +1465,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,for (j =0 ; j < i; j++)if (r1_bio->bios[j])rdev_dec_pending (conf->mirrors[j].rdev, mddev); - r1_bio->state =0 ; +free_r1bio (r1_bio);allow_barrier (conf, bio->bi_iter.bi_sector);if (bio->bi_opf &REQ_NOWAIT ) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 317/600 md/raid1: hold the barrier until handle_read_error() finishes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueshi Hu <[email protected]>
[ Upstream commit c069da449a13669ffa754fd971747e7e17e7d691 ]
handle_read_error() will call allow_barrier() to match the former barrier raising. However, it should put the allow_barrier() at the end to avoid a concurrent raid reshape.
--- drivers/md/raid1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid1.c +3 -1
@@ -2495,6 +2495,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)struct mddev *mddev = conf->mddev;struct bio *bio;struct md_rdev *rdev; +sector_t sector;clear_bit (R1BIO_ReadError, &r1_bio->state);/* we got a read error. Maybe the drive is bad. Maybe just
@@ -2524,12 +2525,13 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) }rdev_dec_pending (rdev, conf->mddev); -allow_barrier (conf, r1_bio->sector); + sector = r1_bio->sector; bio = r1_bio->master_bio;/* Reuse the old r1_bio so that the IO_BLOCKED settings are preserved */ r1_bio->state =0 ;raid1_read_request (mddev, bio, r1_bio->sectors, r1_bio); +allow_barrier (conf, sector); }static void raid1d (struct md_thread *thread)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 318/600 md: add error_handlers for raid0 and linear
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mariusz Tkaczyk <[email protected]>
[ Upstream commit c31fea2f8e2a72c817f318016bbc327095175a9f ]
After the commit 9631abdbf406c("md: Set MD_BROKEN for RAID1 and RAID10") MD_BROKEN must be set if array is failed because state_store() checks it. If it is set then -EBUSY is returned to userspace.
For raid0 and linear MD_BROKEN is not set by error_handler(). As a result mdadm is unable to trigger clean-up actions. It is a regression.
This patch adds appropriate error_handler for raid0 and linear. The error handler sets MD_BROKEN for this device.
Stable-dep-of: 319ff40a5427 ("md/raid0: Fix performance regression for large sequential writes")
--- drivers/md/md-linear.c | 14 +++++++++++++- drivers/md/md.c | 3 +++ drivers/md/md.h | 10 ++-------- drivers/md/raid0.c | 14 +++++++++++++- 4 files changed, 31 insertions(+), 10 deletions(-)
drivers/md/md-linear.c +13 -1
@@ -223,7 +223,8 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio) bio_sector < start_sector)) goto out_of_bounds; -if (unlikely (is_mddev_broken (tmp_dev->rdev,"linear" ))) { +if (unlikely (is_rdev_broken (tmp_dev->rdev))) { +md_error (mddev, tmp_dev->rdev);bio_io_error (bio);return true; }
@@ -270,6 +271,16 @@ static void linear_status (struct seq_file *seq, struct mddev *mddev)seq_printf (seq," %dk rounding" , mddev->chunk_sectors /2 ); } +static void linear_error (struct mddev *mddev,struct md_rdev *rdev) +{ +if (!test_and_set_bit (MD_BROKEN , &mddev->flags)) { +char *md_name =mdname (mddev); + +pr_crit ("md/linear%s: Disk failure on %pg detected, failing array.\n" , + md_name, rdev->bdev); + } +} +static void linear_quiesce (struct mddev *mddev,int state) { }
@@ -286,6 +297,7 @@ static struct md_personality linear_personality = .hot_add_disk = linear_add, .size = linear_size, .quiesce = linear_quiesce, + .error_handler = linear_error, };static int __init linear_init (void )
drivers/md/md.c +3 -0
@@ -7992,6 +7992,9 @@ void md_error(struct mddev *mddev, struct md_rdev *rdev)return ; mddev->pers->error_handler (mddev, rdev); +if (mddev->pers->level ==0 || mddev->pers->level ==LEVEL_LINEAR ) +return ; +if (mddev->degraded && !test_bit (MD_BROKEN , &mddev->flags))set_bit (MD_RECOVERY_RECOVER , &mddev->recovery);sysfs_notify_dirent_safe (rdev->sysfs_state);
drivers/md/md.h +2 -8
@@ -790,15 +790,9 @@ extern void mddev_destroy_serial_pool(struct mddev *mddev, struct md_rdev *rdev,struct md_rdev *md_find_rdev_nr_rcu (struct mddev *mddev,int nr);struct md_rdev *md_find_rdev_rcu (struct mddev *mddev,dev_t dev); -static inline bool is_mddev_broken (struct md_rdev *rdev,const char *md_type) +static inline bool is_rdev_broken (struct md_rdev *rdev) { -if (!disk_live (rdev->bdev->bd_disk)) { -if (!test_and_set_bit (MD_BROKEN , &rdev->mddev->flags)) -pr_warn ("md: %s: %s array has a missing/failed member\n" , -mdname (rdev->mddev), md_type); -return true; - } -return false; +return !disk_live (rdev->bdev->bd_disk); }static inline void rdev_dec_pending (struct md_rdev *rdev,struct mddev *mddev)
drivers/md/raid0.c +13 -1
@@ -615,8 +615,9 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)return true; } -if (unlikely (is_mddev_broken (tmp_dev,"raid0" ))) { +if (unlikely (is_rdev_broken (tmp_dev))) {bio_io_error (bio); +md_error (mddev, tmp_dev);return true; }
@@ -638,6 +639,16 @@ static void raid0_status(struct seq_file *seq, struct mddev *mddev)return ; } +static void raid0_error (struct mddev *mddev,struct md_rdev *rdev) +{ +if (!test_and_set_bit (MD_BROKEN , &mddev->flags)) { +char *md_name =mdname (mddev); + +pr_crit ("md/raid0%s: Disk failure on %pg detected, failing array.\n" , + md_name, rdev->bdev); + } +} +static void *raid0_takeover_raid45 (struct mddev *mddev) {struct md_rdev *rdev;
@@ -813,6 +824,7 @@ static struct md_personality raid0_personality= .size = raid0_size, .takeover = raid0_takeover, .quiesce = raid0_quiesce, + .error_handler = raid0_error, };static int __init raid0_init (void )
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 319/600 md/raid0: Factor out helper for mapping and submitting a bio
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit af50e20afb401cc203bd2a9ff62ece0ae4976103 ]
Factor out helper function for mapping and submitting a bio out of raid0_make_request(). We will use it later for submitting both parts of a split bio.
Stable-dep-of: 319ff40a5427 ("md/raid0: Fix performance regression for large sequential writes")
--- drivers/md/raid0.c | 79 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 39 deletions(-)
drivers/md/raid0.c +40 -39
@@ -557,54 +557,21 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)bio_endio (bio); } -static bool raid0_make_request (struct mddev *mddev,struct bio *bio) +static void raid0_map_submit_bio (struct mddev *mddev,struct bio *bio) {struct r0conf *conf = mddev->private;struct strip_zone *zone;struct md_rdev *tmp_dev; -sector_t bio_sector; -sector_t sector; -sector_t orig_sector; -unsigned chunk_sects; -unsigned sectors; - -if (unlikely (bio->bi_opf &REQ_PREFLUSH ) - &&md_flush_request (mddev, bio)) -return true; - -if (unlikely ((bio_op (bio) ==REQ_OP_DISCARD ))) { -raid0_handle_discard (mddev, bio); -return true; - } - - bio_sector = bio->bi_iter.bi_sector; - sector = bio_sector; - chunk_sects = mddev->chunk_sectors; - - sectors = chunk_sects - - (likely (is_power_of_2 (chunk_sects)) - ? (sector & (chunk_sects-1 )) - :sector_div (sector, chunk_sects)); - -/* Restore due to sector_div */ - sector = bio_sector; - -if (sectors <bio_sectors (bio)) { -struct bio *split =bio_split (bio, sectors,GFP_NOIO , - &mddev->bio_set); -bio_chain (split, bio); -submit_bio_noacct (bio); - bio = split; - } +sector_t bio_sector = bio->bi_iter.bi_sector; +sector_t sector = bio_sector;if (bio->bi_pool != &mddev->bio_set)md_account_bio (mddev, &bio); - orig_sector = sector; zone =find_zone (mddev->private, §or);switch (conf->layout) {case RAID0_ORIG_LAYOUT : - tmp_dev =map_sector (mddev, zone, orig_sector, §or); + tmp_dev =map_sector (mddev, zone, bio_sector, §or);break ;case RAID0_ALT_MULTIZONE_LAYOUT : tmp_dev =map_sector (mddev, zone, sector, §or);
@@ -612,13 +579,13 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)default :WARN (1 ,"md/raid0:%s: Invalid layout\n" ,mdname (mddev));bio_io_error (bio); -return true; +return ; }if (unlikely (is_rdev_broken (tmp_dev))) {bio_io_error (bio);md_error (mddev, tmp_dev); -return true; +return ; }bio_set_dev (bio, tmp_dev->bdev);
@@ -630,6 +597,40 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio) bio_sector);mddev_check_write_zeroes (mddev, bio);submit_bio_noacct (bio); +} + +static bool raid0_make_request (struct mddev *mddev,struct bio *bio) +{ +sector_t sector; +unsigned chunk_sects; +unsigned sectors; + +if (unlikely (bio->bi_opf &REQ_PREFLUSH ) + &&md_flush_request (mddev, bio)) +return true; + +if (unlikely ((bio_op (bio) ==REQ_OP_DISCARD ))) { +raid0_handle_discard (mddev, bio); +return true; + } + + sector = bio->bi_iter.bi_sector; + chunk_sects = mddev->chunk_sectors; + + sectors = chunk_sects - + (likely (is_power_of_2 (chunk_sects)) + ? (sector & (chunk_sects-1 )) + :sector_div (sector, chunk_sects)); + +if (sectors <bio_sectors (bio)) { +struct bio *split =bio_split (bio, sectors,GFP_NOIO , + &mddev->bio_set); +bio_chain (split, bio); +submit_bio_noacct (bio); + bio = split; + } + +raid0_map_submit_bio (mddev, bio);return true; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 320/600 md/raid0: Fix performance regression for large sequential writes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 319ff40a542736d67e5bce18635de35d0e7a0bff ]
Commit f00d7c85be9e ("md/raid0: fix up bio splitting.") among other things changed how bio that needs to be split is submitted. Before this commit, we have split the bio, mapped and submitted each part. After this commit, we map only the first part of the split bio and submit the second part unmapped. Due to bio sorting in __submit_bio_noacct() this results in the following request ordering:
9,0 18 1181 0.525037895 15995 Q WS 1479315464 + 63392
Split off chunk-sized (1024 sectors) request:
9,0 18 1182 0.629019647 15995 X WS 1479315464 / 1479316488
Request is unaligned to the chunk so it's split in raid0_make_request(). This is the first part mapped and punted to bio_list:
8,0 18 7053 0.629020455 15995 A WS 739921928 + 1016 <- (9,0) 1479315464
Now raid0_make_request() returns, second part is postponed on bio_list. __submit_bio_noacct() resorts the bio_list, mapped request is submitted to the underlying device:
8,0 18 7054 0.629022782 15995 G WS 739921928 + 1016
Now we take another request from the bio_list which is the remainder of the original huge request. Split off another chunk-sized bit from it and the situation repeats:
9,0 18 1183 0.629024499 15995 X WS 1479316488 / 1479317512 8,16 18 6998 0.629025110 15995 A WS 739921928 + 1016 <- (9,0) 1479316488 8,16 18 6999 0.629026728 15995 G WS 739921928 + 1016 ... 9,0 18 1184 0.629032940 15995 X WS 1479317512 / 1479318536 [libnetacq-write] 8,0 18 7059 0.629033294 15995 A WS 739922952 + 1016 <- (9,0) 1479317512 8,0 18 7060 0.629033902 15995 G WS 739922952 + 1016
...
This repeats until we consume the whole original huge request. Now we finally get to processing the second parts of the split off requests (in reverse order):
8,16 18 7181 0.629161384 15995 A WS 739952640 + 8 <- (9,0) 1479377920 8,0 18 7239 0.629162140 15995 A WS 739952640 + 8 <- (9,0) 1479376896 8,16 18 7186 0.629163881 15995 A WS 739951616 + 8 <- (9,0) 1479375872 8,0 18 7242 0.629164421 15995 A WS 739951616 + 8 <- (9,0) 1479374848
...
I guess it is obvious that this IO pattern is extremely inefficient way to perform sequential IO. It also makes bio_list to grow to rather long lengths.
Change raid0_make_request() to map both parts of the split bio. Since we know we are provided with at most chunk-sized bios, we will always need to split the incoming bio at most once.
--- drivers/md/raid0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid0.c +1 -1
@@ -626,7 +626,7 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)struct bio *split =bio_split (bio, sectors,GFP_NOIO , &mddev->bio_set);bio_chain (split, bio); -submit_bio_noacct (bio); +raid0_map_submit_bio (mddev, bio); bio = split; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 321/600 md: raid0: account for split bio in iostat accounting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jeffery <[email protected]>
[ Upstream commit cc22b5407e9ca76adb7efeed843146510b1b72a5 ]
When a bio is split by md raid0, the newly created bio will not be tracked by md for I/O accounting. Only the portion of I/O still assigned to the original bio which was reduced by the split will be accounted for. This results in md iostat data sometimes showing I/O values far below the actual amount of data being sent through md.
md_account_bio() needs to be called for all bio generated by the bio split.
A simple example of the issue was generated using a raid0 device on partitions to the same device. Since all raid0 I/O then goes to one device, it makes it easy to see a gap between the md device and its sd storage. Reading an lvm device on top of the md device, the iostat output (some 0 columns and extra devices removed to make the data more compact) was:
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read
md2 0.00 0.00 0.00 0.00 0 sde 0.00 0.00 0.00 0.00 0 md2 1364.00 411496.00 0.00 0.00 411496 sde 1734.00 646144.00 0.00 0.00 646144 md2 1699.00 510680.00 0.00 0.00 510680 sde 2155.00 802784.00 0.00 0.00 802784 md2 803.00 241480.00 0.00 0.00 241480 sde 1016.00 377888.00 0.00 0.00 377888 md2 0.00 0.00 0.00 0.00 0 sde 0.00 0.00 0.00 0.00 0
I/O was generated doing large direct I/O reads (12M) with dd to a linear lvm volume on top of the 4 leg raid0 device.
The md2 reads were showing as roughly 2/3 of the reads to the sde device containing all of md2's raid partitions. The sum of reads to sde was 1826816 kB, which was the expected amount as it was the amount read by dd. With the patch, the total reads from md will match the reads from sde and be consistent with the amount of I/O generated.
--- drivers/md/raid0.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/raid0.c +1 -2
@@ -565,8 +565,7 @@ static void raid0_map_submit_bio(struct mddev *mddev, struct bio *bio)sector_t bio_sector = bio->bi_iter.bi_sector;sector_t sector = bio_sector; -if (bio->bi_pool != &mddev->bio_set) -md_account_bio (mddev, &bio); +md_account_bio (mddev, &bio); zone =find_zone (mddev->private, §or);switch (conf->layout) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 322/600 ASoC: SOF: amd: clear dsp to host interrupt status
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit 38592ae6dc9f84b7a994c43de2136b8115ca30f6 ]
DSP_SW_INTR_STAT_OFFSET is a common interrupt register which will be accessed by both ACP firmware and driver. This register contains register bits corresponds to host to dsp interrupts and vice versa.
when dsp to host interrupt is reported, only clear dsp to host interrupt bit in DSP_SW_INTR_STAT_OFFSET.
--- sound/soc/sof/amd/acp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/acp.c +3 -3
@@ -349,9 +349,9 @@ static irqreturn_t acp_irq_handler(int irq, void *dev_id)unsigned int val; val =snd_sof_dsp_read (sdev,ACP_DSP_BAR , base +DSP_SW_INTR_STAT_OFFSET ); -if (val) { - val |=ACP_DSP_TO_HOST_IRQ ; -snd_sof_dsp_write (sdev,ACP_DSP_BAR , base +DSP_SW_INTR_STAT_OFFSET , val); +if (val &ACP_DSP_TO_HOST_IRQ ) { +snd_sof_dsp_write (sdev,ACP_DSP_BAR , base +DSP_SW_INTR_STAT_OFFSET , +ACP_DSP_TO_HOST_IRQ );return IRQ_WAKE_THREAD ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 323/600 of: overlay: Call of_changeset_init() early
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit a9515ff4fb142b690a0d2b58782b15903b990dba ]
When of_overlay_fdt_apply() fails, the changeset may be partially applied, and the caller is still expected to call of_overlay_remove() to clean up this partial state.
However, of_overlay_apply() calls of_resolve_phandles() before init_overlay_changeset(). Hence if the overlay fails to apply due to an unresolved symbol, the overlay_changeset.cset.entries list is still uninitialized, and cleanup will crash with a NULL-pointer dereference in overlay_removal_is_ok().
Fix this by moving the call to of_changeset_init() from init_overlay_changeset() to of_overlay_fdt_apply(), where all other early initialization is done.
--- drivers/of/overlay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/of/overlay.c +1 -2
@@ -752,8 +752,6 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs)if (!of_node_is_root (ovcs->overlay_root))pr_debug ("%s() ovcs->overlay_root is not root\n" , __func__); -of_changeset_init (&ovcs->cset); - cnt =0 ;/* fragment nodes */
@@ -1013,6 +1011,7 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,INIT_LIST_HEAD (&ovcs->ovcs_list);list_add_tail (&ovcs->ovcs_list, &ovcs_list); +of_changeset_init (&ovcs->cset);/* * Must create permanent copy of FDT because of_fdt_unflatten_tree()
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 324/600 of: unittest: Fix overlay type in apply/revert check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 6becf8f845ae1f0b1cfed395bbeccbd23654162d ]
The removal check in of_unittest_apply_revert_overlay_check() always uses the platform device overlay type, while it should use the actual overlay type, as passed as a parameter to the function.
This has no impact on any current test, as all tests calling of_unittest_apply_revert_overlay_check() use the platform device overlay type.
--- drivers/of/unittest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/unittest.c +1 -1
@@ -2062,7 +2062,7 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr,of_unittest_untrack_overlay (save_ovcs_id);/* unittest device must be again in before state */ -if (of_unittest_device_exists (unittest_nr,PDEV_OVERLAY ) != before) { +if (of_unittest_device_exists (unittest_nr, ovtype) != before) { unittest(0, "%s with device @\"%s\" %s\n", overlay_name_from_nr(overlay_nr), unittest_path(unittest_nr, ovtype),
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 325/600 ALSA: ac97: Fix possible error value of *rac97
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit 67de40c9df94037769967ba28c7d951afb45b7fb ]
Before committing 79597c8bf64c, *rac97 always be NULL if there is an error. When error happens, make sure *rac97 is NULL is safer.
For examble, in snd_vortex_mixer():
err = snd_ac97_mixer(pbus, &ac97, &vortex->codec); vortex->isquad = ((vortex->codec == NULL) ? 0 : (vortex->codec->ext_id&0x80));
If error happened but vortex->codec isn't NULL, this may cause some problems.
Move the judgement order to be clearer and better.
--- sound/pci/ac97/ac97_codec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/ac97/ac97_codec.c +2 -3
@@ -2070,10 +2070,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, .dev_disconnect = snd_ac97_dev_disconnect, }; -if (!rac97) -return -EINVAL ; -if (snd_BUG_ON (!bus || !template)) +if (snd_BUG_ON (!bus || !template || !rac97))return -EINVAL ; + *rac97 =NULL ;if (snd_BUG_ON (template->num >=4 ))return -EINVAL ;if (bus->codec[template->num])
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 326/600 ipmi:ssif: Add check for kstrdup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit c5586d0f711e9744d0cade39b0c4a2d116a333ca ]
Add check for the return value of kstrdup() and return the error if it fails in order to avoid NULL pointer dereference.
Message-Id: <[email protected]>
--- drivers/char/ipmi/ipmi_ssif.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/char/ipmi/ipmi_ssif.c +5 -0
@@ -1603,6 +1603,11 @@ static int ssif_add_infos(struct i2c_client *client) info->addr_src =SI_ACPI ; info->client = client; info->adapter_name =kstrdup (client->adapter->name,GFP_KERNEL ); +if (!info->adapter_name) { +kfree (info); +return -ENOMEM ; + } + info->binfo.addr = client->addr;list_add_tail (&info->link, &ssif_infos);return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 327/600 ipmi:ssif: Fix a memory leak when scanning for an adapter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
[ Upstream commit b8d72e32e1453d37ee5c8a219f24e7eeadc471ef ]
The adapter scan ssif_info_find() sets info->adapter_name if the adapter info came from SMBIOS, as it's not set in that case. However, this function can be called more than once, and it will leak the adapter name if it had already been set. So check for NULL before setting it.
--- drivers/char/ipmi/ipmi_ssif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ipmi/ipmi_ssif.c +1 -1
@@ -1403,7 +1403,7 @@ static struct ssif_addr_info *ssif_info_find(unsigned short addr, restart:list_for_each_entry (info, &ssif_infos, link) {if (info->binfo.addr == addr) { -if (info->addr_src ==SI_SMBIOS ) +if (info->addr_src ==SI_SMBIOS && !info->adapter_name) info->adapter_name =kstrdup (adapter_name,GFP_KERNEL );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 328/600 clk: qcom: gpucc-sm6350: Introduce index-based clk lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit f6f89d194e4ddcfe197ac8a05ed4161f642a5c68 ]
Add the nowadays-prefered and marginally faster way of looking up parent clocks in the device tree. It also allows for clock-names-independent operation, so long as the order (which is enforced by schema) is kept.
Stable-dep-of: 743913b343a3 ("clk: qcom: gpucc-sm6350: Fix clock source names")
--- drivers/clk/qcom/gpucc-sm6350.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/clk/qcom/gpucc-sm6350.c +13 -5
@@ -24,6 +24,12 @@#define CX_GMU_CBCR_WAKE_MASK 0xF#define CX_GMU_CBCR_WAKE_SHIFT 8 +enum { +DT_BI_TCXO , +DT_GPLL0_OUT_MAIN , +DT_GPLL0_OUT_MAIN_DIV , +}; +enum {P_BI_TCXO ,P_GPLL0_OUT_MAIN ,
@@ -61,6 +67,7 @@ static struct clk_alpha_pll gpu_cc_pll0 = { .hw.init = &(struct clk_init_data){ .name ="gpu_cc_pll0" , .parent_data = &(const struct clk_parent_data ){ + .index =DT_BI_TCXO , .fw_name ="bi_tcxo" , }, .num_parents =1 ,
@@ -104,6 +111,7 @@ static struct clk_alpha_pll gpu_cc_pll1 = { .hw.init = &(struct clk_init_data){ .name ="gpu_cc_pll1" , .parent_data = &(const struct clk_parent_data ){ + .index =DT_BI_TCXO , .fw_name ="bi_tcxo" , }, .num_parents =1 ,
@@ -121,11 +129,11 @@ static const struct parent_map gpu_cc_parent_map_0[] = { };static const struct clk_parent_data gpu_cc_parent_data_0[] = { - { .fw_name ="bi_tcxo" }, + { .index =DT_BI_TCXO , .fw_name ="bi_tcxo" }, { .hw = &gpu_cc_pll0.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, - { .fw_name ="gcc_gpu_gpll0_clk" }, - { .fw_name ="gcc_gpu_gpll0_div_clk" }, + { .index =DT_GPLL0_OUT_MAIN , .fw_name ="gcc_gpu_gpll0_clk" }, + { .index =DT_GPLL0_OUT_MAIN_DIV , .fw_name ="gcc_gpu_gpll0_div_clk" }, };static const struct parent_map gpu_cc_parent_map_1[] = {
@@ -138,12 +146,12 @@ static const struct parent_map gpu_cc_parent_map_1[] = { };static const struct clk_parent_data gpu_cc_parent_data_1[] = { - { .fw_name ="bi_tcxo" }, + { .index =DT_BI_TCXO , .fw_name ="bi_tcxo" }, { .hw = &crc_div.hw }, { .hw = &gpu_cc_pll0.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, - { .fw_name ="gcc_gpu_gpll0_clk" }, + { .index =DT_GPLL0_OUT_MAIN , .fw_name ="gcc_gpu_gpll0_clk" }, };static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 329/600 clk: qcom: gpucc-sm6350: Fix clock source names
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 743913b343a3ec2510fe3c0dfaff03d049659922 ]
fw_name for GCC inputs didn't match the bindings. Fix it.
--- drivers/clk/qcom/gpucc-sm6350.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gpucc-sm6350.c +3 -3
@@ -132,8 +132,8 @@ static const struct clk_parent_data gpu_cc_parent_data_0[] = { { .index = DT_BI_TCXO, .fw_name = "bi_tcxo" }, { .hw = &gpu_cc_pll0.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, - { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk" }, - { .index = DT_GPLL0_OUT_MAIN_DIV, .fw_name = "gcc_gpu_gpll0_div_clk" }, + { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk_src" }, + { .index = DT_GPLL0_OUT_MAIN_DIV, .fw_name = "gcc_gpu_gpll0_div_clk_src" }, }; static const struct parent_map gpu_cc_parent_map_1[] = {
@@ -151,7 +151,7 @@ static const struct clk_parent_data gpu_cc_parent_data_1[] = { { .hw = &gpu_cc_pll0.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, { .hw = &gpu_cc_pll1.clkr.hw }, - { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk" }, + { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk_src" }, }; static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 330/600 clk: qcom: gcc-sc8280xp: Add EMAC GDSCs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Halaney <[email protected]>
[ Upstream commit 32c2f2a46db1322caaf78d5ea747ed5c56d2e353 ]
Add the EMAC GDSCs to allow the EMAC hardware to be enabled.
Stable-dep-of: 2fd02de27054 ("clk: qcom: gcc-sc8280xp: Add missing GDSC flags")
--- drivers/clk/qcom/gcc-sc8280xp.c | 18 ++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sc8280xp.h | 2 ++ 2 files changed, 20 insertions(+)
drivers/clk/qcom/gcc-sc8280xp.c +18 -0
@@ -6873,6 +6873,22 @@ static struct gdsc usb30_sec_gdsc = { .pwrsts = PWRSTS_RET_ON, }; +static struct gdsc emac_0_gdsc = { + .gdscr =0xaa004 , + .pd = { + .name ="emac_0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , +}; + +static struct gdsc emac_1_gdsc = { + .gdscr =0xba004 , + .pd = { + .name ="emac_1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , +}; +static struct clk_regmap *gcc_sc8280xp_clocks[] = { [GCC_AGGRE_NOC_PCIE0_TUNNEL_AXI_CLK ] = &gcc_aggre_noc_pcie0_tunnel_axi_clk.clkr, [GCC_AGGRE_NOC_PCIE1_TUNNEL_AXI_CLK ] = &gcc_aggre_noc_pcie1_tunnel_axi_clk.clkr,
@@ -7351,6 +7367,8 @@ static struct gdsc *gcc_sc8280xp_gdscs[] = { [USB30_MP_GDSC] = &usb30_mp_gdsc, [USB30_PRIM_GDSC] = &usb30_prim_gdsc, [USB30_SEC_GDSC] = &usb30_sec_gdsc, + [EMAC_0_GDSC] = &emac_0_gdsc, + [EMAC_1_GDSC] = &emac_1_gdsc, };static const struct clk_rcg_dfs_data gcc_dfs_clocks[] = {
include/dt-bindings/clock/qcom,gcc-sc8280xp.h +2 -0
@@ -492,5 +492,7 @@#define USB30_MP_GDSC 9#define USB30_PRIM_GDSC 10#define USB30_SEC_GDSC 11 +#define EMAC_0_GDSC 12 +#define EMAC_1_GDSC 13#endif
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 331/600 clk: qcom: gcc-sc8280xp: Add missing GDSC flags
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 2fd02de27054576a4a8c89302e2f77122c55e957 ]
All of the 8280's GCC GDSCs can and should use the retain registers so as not to lose their state when entering lower power modes.
--- drivers/clk/qcom/gcc-sc8280xp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/clk/qcom/gcc-sc8280xp.c +14 -7
@@ -6760,7 +6760,7 @@ static struct gdsc pcie_0_tunnel_gdsc = { .name = "pcie_0_tunnel_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE, + .flags = VOTABLE | RETAIN_FF_ENABLE, }; static struct gdsc pcie_1_tunnel_gdsc = {
@@ -6771,7 +6771,7 @@ static struct gdsc pcie_1_tunnel_gdsc = { .name = "pcie_1_tunnel_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE, + .flags = VOTABLE | RETAIN_FF_ENABLE, };/*
@@ -6786,7 +6786,7 @@ static struct gdsc pcie_2a_gdsc = { .name = "pcie_2a_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE | ALWAYS_ON, + .flags = VOTABLE | RETAIN_FF_ENABLE | ALWAYS_ON, }; static struct gdsc pcie_2b_gdsc = {
@@ -6797,7 +6797,7 @@ static struct gdsc pcie_2b_gdsc = { .name = "pcie_2b_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE | ALWAYS_ON, + .flags = VOTABLE | RETAIN_FF_ENABLE | ALWAYS_ON, }; static struct gdsc pcie_3a_gdsc = {
@@ -6808,7 +6808,7 @@ static struct gdsc pcie_3a_gdsc = { .name = "pcie_3a_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE | ALWAYS_ON, + .flags = VOTABLE | RETAIN_FF_ENABLE | ALWAYS_ON, }; static struct gdsc pcie_3b_gdsc = {
@@ -6819,7 +6819,7 @@ static struct gdsc pcie_3b_gdsc = { .name = "pcie_3b_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE | ALWAYS_ON, + .flags = VOTABLE | RETAIN_FF_ENABLE | ALWAYS_ON, }; static struct gdsc pcie_4_gdsc = {
@@ -6830,7 +6830,7 @@ static struct gdsc pcie_4_gdsc = { .name = "pcie_4_gdsc", }, .pwrsts = PWRSTS_OFF_ON, - .flags = VOTABLE | ALWAYS_ON, + .flags = VOTABLE | RETAIN_FF_ENABLE | ALWAYS_ON, }; static struct gdsc ufs_card_gdsc = {
@@ -6839,6 +6839,7 @@ static struct gdsc ufs_card_gdsc = { .name = "ufs_card_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc ufs_phy_gdsc = {
@@ -6847,6 +6848,7 @@ static struct gdsc ufs_phy_gdsc = { .name = "ufs_phy_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc usb30_mp_gdsc = {
@@ -6855,6 +6857,7 @@ static struct gdsc usb30_mp_gdsc = { .name = "usb30_mp_gdsc", }, .pwrsts = PWRSTS_RET_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc usb30_prim_gdsc = {
@@ -6863,6 +6866,7 @@ static struct gdsc usb30_prim_gdsc = { .name = "usb30_prim_gdsc", }, .pwrsts = PWRSTS_RET_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc usb30_sec_gdsc = {
@@ -6871,6 +6875,7 @@ static struct gdsc usb30_sec_gdsc = { .name = "usb30_sec_gdsc", }, .pwrsts = PWRSTS_RET_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc emac_0_gdsc = {
@@ -6879,6 +6884,7 @@ static struct gdsc emac_0_gdsc = { .name = "emac_0_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .flags = RETAIN_FF_ENABLE, }; static struct gdsc emac_1_gdsc = {
@@ -6887,6 +6893,7 @@ static struct gdsc emac_1_gdsc = { .name = "emac_1_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .flags = RETAIN_FF_ENABLE, }; static struct clk_regmap *gcc_sc8280xp_clocks[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 332/600 dt-bindings: clock: qcom,gcc-sc8280xp: Add missing GDSCs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 9eba4db02a88e7a810aabd70f7a6960f184f391f ]
There are 10 more GDSCs that we've not been caring about, and by extension (and perhaps even more importantly), not putting to sleep. Add them.
--- include/dt-bindings/clock/qcom,gcc-sc8280xp.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/dt-bindings/clock/qcom,gcc-sc8280xp.h +10 -0
@@ -494,5 +494,15 @@#define USB30_SEC_GDSC 11#define EMAC_0_GDSC 12#define EMAC_1_GDSC 13 +#define USB4_1_GDSC 14 +#define USB4_GDSC 15 +#define HLOS1_VOTE_MMNOC_MMU_TBU_HF0_GDSC 16 +#define HLOS1_VOTE_MMNOC_MMU_TBU_HF1_GDSC 17 +#define HLOS1_VOTE_MMNOC_MMU_TBU_SF0_GDSC 18 +#define HLOS1_VOTE_MMNOC_MMU_TBU_SF1_GDSC 19 +#define HLOS1_VOTE_TURING_MMU_TBU0_GDSC 20 +#define HLOS1_VOTE_TURING_MMU_TBU1_GDSC 21 +#define HLOS1_VOTE_TURING_MMU_TBU2_GDSC 22 +#define HLOS1_VOTE_TURING_MMU_TBU3_GDSC 23#endif
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 333/600 clk: qcom: gcc-sc8280xp: Add missing GDSCs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 4712eb7ff85bd3dd09c6668b8de4080e02b3eea9 ]
There are 10 more GDSCs that we've not been caring about, and by extension (and perhaps even more importantly), not putting to sleep. Add them.
--- drivers/clk/qcom/gcc-sc8280xp.c | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
drivers/clk/qcom/gcc-sc8280xp.c +100 -0
@@ -6896,6 +6896,96 @@ static struct gdsc emac_1_gdsc = { .flags = RETAIN_FF_ENABLE, }; +static struct gdsc usb4_1_gdsc = { + .gdscr =0xb8004 , + .pd = { + .name ="usb4_1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =RETAIN_FF_ENABLE , +}; + +static struct gdsc usb4_gdsc = { + .gdscr =0x2a004 , + .pd = { + .name ="usb4_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =RETAIN_FF_ENABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc = { + .gdscr =0x7d050 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc = { + .gdscr =0x7d058 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf0_gdsc = { + .gdscr =0x7d054 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_sf0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf1_gdsc = { + .gdscr =0x7d06c , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_sf1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu0_gdsc = { + .gdscr =0x7d05c , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu1_gdsc = { + .gdscr =0x7d060 , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu2_gdsc = { + .gdscr =0x7d0a0 , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu2_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu3_gdsc = { + .gdscr =0x7d0a4 , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu3_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; +static struct clk_regmap *gcc_sc8280xp_clocks[] = { [GCC_AGGRE_NOC_PCIE0_TUNNEL_AXI_CLK ] = &gcc_aggre_noc_pcie0_tunnel_axi_clk.clkr, [GCC_AGGRE_NOC_PCIE1_TUNNEL_AXI_CLK ] = &gcc_aggre_noc_pcie1_tunnel_axi_clk.clkr,
@@ -7376,6 +7466,16 @@ static struct gdsc *gcc_sc8280xp_gdscs[] = { [USB30_SEC_GDSC] = &usb30_sec_gdsc, [EMAC_0_GDSC] = &emac_0_gdsc, [EMAC_1_GDSC] = &emac_1_gdsc, + [USB4_1_GDSC] = &usb4_1_gdsc, + [USB4_GDSC] = &usb4_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF0_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF1_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_SF0_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_sf0_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_SF1_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_sf1_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU0_GDSC] = &hlos1_vote_turing_mmu_tbu0_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU1_GDSC] = &hlos1_vote_turing_mmu_tbu1_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU2_GDSC] = &hlos1_vote_turing_mmu_tbu2_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU3_GDSC] = &hlos1_vote_turing_mmu_tbu3_gdsc, };static const struct clk_rcg_dfs_data gcc_dfs_clocks[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 334/600 clk: rockchip: rk3568: Fix PLL rate setting for 78.75MHz
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alibek Omarov <[email protected]>
[ Upstream commit dafebd0f9a4f56b10d7fbda0bff1f540d16a2ea4 ]
PLL rate on RK356x is calculated through the simple formula:
((24000000 / _refdiv) * _fbdiv) / (_postdiv1 * _postdiv2)
The PLL rate setting for 78.75MHz seems to be copied from 96MHz so this patch fixes it and configures it properly.
--- drivers/clk/rockchip/clk-rk3568.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-rk3568.c +1 -1
@@ -81,7 +81,7 @@ static struct rockchip_pll_rate_table rk3568_pll_rates[] = {RK3036_PLL_RATE (108000000 ,2 ,45 ,5 ,1 ,1 ,0 ),RK3036_PLL_RATE (100000000 ,1 ,150 ,6 ,6 ,1 ,0 ),RK3036_PLL_RATE (96000000 ,1 ,96 ,6 ,4 ,1 ,0 ), -RK3036_PLL_RATE (78750000 ,1 ,96 ,6 ,4 ,1 ,0 ), +RK3036_PLL_RATE (78750000 ,4 ,315 ,6 ,4 ,1 ,0 ), RK3036_PLL_RATE(74250000, 2, 99, 4, 4, 1, 0), { /* sentinel */ }, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 335/600 PCI: apple: Initialize pcie->nvecs before use
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit d8650c0c2aa2e413594e4cb0faafa9958c1d7782 ]
The apple_pcie_setup_port() function computes ilog2(pcie->nvecs) to set up the number of MSIs available for each port. However, it's called before apple_msi_init(), which initializes pcie->nvecs.
Luckily, pcie->nvecs is part of kzalloc()-ed structure and, as such, initialized as zero. ilog2(0) happens to be 0xffffffff which then simply configures more MSIs in hardware than we have. This doesn't break anything because we never hand out those vectors.
Thus, swap the order of the two calls so that the correctly initialized value is then used.
--- drivers/pci/controller/pcie-apple.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-apple.c +5 -1
@@ -783,6 +783,10 @@ static int apple_pcie_init(struct pci_config_window *cfg) cfg->priv = pcie;INIT_LIST_HEAD (&pcie->ports); + ret =apple_msi_init (pcie); +if (ret) +return ret; +for_each_child_of_node (dev->of_node, of_port) { ret =apple_pcie_setup_port (pcie, of_port);if (ret) {
@@ -792,7 +796,7 @@ static int apple_pcie_init(struct pci_config_window *cfg) } } -return apple_msi_init (pcie); +return 0 ; }static int apple_pcie_probe (struct platform_device *pdev)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 336/600 PCI: qcom-ep: Switch MHI bus master clock off during L1SS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit b9cbc06049cb6b7a322d708c2098195fb9fdcc4c ]
Currently, as part of the qcom_pcie_perst_deassert() function, instead of writing the updated value to clear PARF_MSTR_AXI_CLK_EN, the variable "val" is re-read.
This must be fixed to ensure that the master clock supplied to the MHI bus is correctly gated during L1.1/L1.2 to save power.
Thus, replace the line that re-reads "val" with a line that writes the updated value to the register to clear PARF_MSTR_AXI_CLK_EN.
--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom-ep.c +1 -1
@@ -410,7 +410,7 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)/* Gate Master AXI clock to MHI bus during L1SS */ val =readl_relaxed (pcie_ep->parf +PARF_MHI_CLOCK_RESET_CTRL ); val &= ~PARF_MSTR_AXI_CLK_EN ; - val =readl_relaxed (pcie_ep->parf +PARF_MHI_CLOCK_RESET_CTRL ); +writel_relaxed (val, pcie_ep->parf +PARF_MHI_CLOCK_RESET_CTRL );dw_pcie_ep_init_notify (&pcie_ep->pci.ep);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 337/600 drivers: clk: keystone: Fix parameter judgment in _of_pll_clk_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minjie Du <[email protected]>
[ Upstream commit a995c50db887ef97f3160775aef7d772635a6f6e ]
The function clk_register_pll() may return NULL or an ERR_PTR. Don't treat an ERR_PTR as valid.
--- drivers/clk/keystone/pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/keystone/pll.c +1 -1
@@ -209,7 +209,7 @@ static void __init _of_pll_clk_init(struct device_node *node, bool pllctrl) } clk =clk_register_pll (NULL , node->name, parent_name, pll_data); -if (clk) { +if (!IS_ERR_OR_NULL (clk)) {of_clk_add_provider (node, of_clk_src_simple_get, clk);return ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 338/600 PCI/DOE: Fix destroy_work_on_stack() race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ira Weiny <[email protected]>
[ Upstream commit e3a3a097eaebaf234a482b4d2f9f18fe989208c1 ]
The following debug object splat was observed in testing:
ODEBUG: free active (active state 0) object: 0000000097d23782 object type: work_struct hint: doe_statemachine_work+0x0/0x510
WARNING: CPU: 1 PID: 71 at lib/debugobjects.c:514 debug_print_object+0x7d/0xb0 ... Workqueue: pci 0000:36:00.0 DOE [1 doe_statemachine_work RIP: 0010:debug_print_object+0x7d/0xb0 ... Call Trace: ? debug_print_object+0x7d/0xb0 ? __pfx_doe_statemachine_work+0x10/0x10 debug_object_free.part.0+0x11b/0x150 doe_statemachine_work+0x45e/0x510 process_one_work+0x1d4/0x3c0
This occurs because destroy_work_on_stack() was called after signaling the completion in the calling thread. This creates a race between destroy_work_on_stack() and the task->work struct going out of scope in pci_doe().
Signal the work complete after destroying the work struct. This is safe because signal_task_complete() is the final thing the work item does and the workqueue code is careful not to access the work struct after.
--- drivers/pci/doe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/doe.c +1 -1
@@ -223,8 +223,8 @@ static int pci_doe_recv_resp(struct pci_doe_mb *doe_mb, struct pci_doe_task *tasstatic void signal_task_complete (struct pci_doe_task *task,int rv) { task->rv = rv; - task->complete (task);destroy_work_on_stack (&task->work); + task->complete (task); }static void signal_task_abort (struct pci_doe_task *task,int rv)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 339/600 clk: sunxi-ng: Modify mismatched function name
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Jianhua <[email protected]>
[ Upstream commit 075d9ca5b4e17f84fd1c744a405e69ec743be7f0 ]
No functional modification involved.
drivers/clk/sunxi-ng/ccu_mmc_timing.c:54: warning: expecting prototype for sunxi_ccu_set_mmc_timing_mode(). Prototype was for sunxi_ccu_get_mmc_timing_mode() instead
--- drivers/clk/sunxi-ng/ccu_mmc_timing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi-ng/ccu_mmc_timing.c +1 -1
@@ -43,7 +43,7 @@ int sunxi_ccu_set_mmc_timing_mode(struct clk *clk, bool new_mode)EXPORT_SYMBOL_GPL (sunxi_ccu_set_mmc_timing_mode);/** -* sunxi_ccu_set_mmc_timing_mode: Get the current MMC clock timing mode +* sunxi_ccu_get_mmc_timing_mode: Get the current MMC clock timing mode * @clk: clock to query * * Returns 0 if the clock is in old timing mode, > 0 if it is in
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 340/600 clk: qcom: gcc-sc7180: Fix up gcc_sdcc2_apps_clk_src
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Wronek <[email protected]>
[ Upstream commit fd0b5ba87ad5709f0fd3d2bc4b7870494a75f96a ]
Set .flags = CLK_OPS_PARENT_ENABLE to fix "gcc_sdcc2_apps_clk_src: rcg didn't update its configuration" error.
--- drivers/clk/qcom/gcc-sc7180.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-sc7180.c +1 -0
@@ -667,6 +667,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .name = "gcc_sdcc2_apps_clk_src", .parent_data = gcc_parent_data_5, .num_parents = ARRAY_SIZE(gcc_parent_data_5), + .flags = CLK_OPS_PARENT_ENABLE, .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 341/600 EDAC/igen6: Fix the issue of no error events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit ce53ad81ed36c24aff075f94474adecfabfcf239 ]
Current igen6_edac checks for pending errors before the registration of the error handler. However, there is a possibility that the error occurs during the registration process, leading to unhandled pending errors and no future error events. This issue can be reproduced by repeatedly injecting errors during the loading of the igen6_edac.
Fix this issue by moving the pending error handler after the registration of the error handler, ensuring that no pending errors are left unhandled.
--- drivers/edac/igen6_edac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/edac/igen6_edac.c +4 -4
@@ -27,7 +27,7 @@#include "edac_mc.h" #include "edac_module.h" -#define IGEN6_REVISION "v2.5" +#define IGEN6_REVISION "v2.5.1"#define EDAC_MOD_STR "igen6_edac"#define IGEN6_NMI_NAME "igen6_ibecc"
@@ -1216,9 +1216,6 @@ static int igen6_probe(struct pci_dev *pdev, const struct pci_device_id *ent)INIT_WORK (&ecclog_work, ecclog_work_cb);init_irq_work (&ecclog_irq_work, ecclog_irq_work_cb); -/* Check if any pending errors before registering the NMI handler */ -ecclog_handler (); - rc =register_err_handler ();if (rc) goto fail3;
@@ -1230,6 +1227,9 @@ static int igen6_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto fail4; } +/* Check if any pending errors before/during the registration of the error handler */ +ecclog_handler (); +igen6_debug_setup ();return 0 ; fail4:
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 342/600 ext4: correct grp validation in ext4_mb_good_group
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit a9ce5993a0f5c0887c8a1b4ffa3b8046fbcfdc93 ]
Group corruption check will access memory of grp and will trigger kernel crash if grp is NULL. So do NULL check before corruption check.
--- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.c +1 -1
@@ -2401,7 +2401,7 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac,BUG_ON (cr <0 || cr >=4 ); -if (unlikely (EXT4_MB_GRP_BBITMAP_CORRUPT (grp) || !grp)) +if (unlikely (!grp ||EXT4_MB_GRP_BBITMAP_CORRUPT (grp)))return false; free = grp->bb_free;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 343/600 ext4: avoid potential data overflow in next_linear_group
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 60c672b7f2d1e5dd1774f2399b355c9314e709f8 ]
ngroups is ext4_group_t (unsigned int) while next_linear_group treat it in int. If ngroups is bigger than max number described by int, it will be treat as a negative number. Then "return group + 1 >= ngroups ? 0 :
group + 1;" may keep returning 0.
Switch int to ext4_group_t in next_linear_group to fix the overflow.
--- fs/ext4/mballoc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +3 -2
@@ -966,8 +966,9 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)* Return next linear group for allocation. If linear traversal should not be * performed, this function just returns the same group */ -static int -next_linear_group (struct ext4_allocation_context *ac,int group,int ngroups) +static ext4_group_t +next_linear_group (struct ext4_allocation_context *ac,ext4_group_t group, +ext4_group_t ngroups) {if (!should_optimize_scan (ac)) goto inc_and_return;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 344/600 clk: qcom: gcc-sm8250: Fix gcc_sdcc2_apps_clk_src
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Whewell <[email protected]>
[ Upstream commit 783cb693828ce487cf0bc6ad16cbcf2caae6f8d9 ]
GPLL9 is not on by default, which causes a "gcc_sdcc2_apps_clk_src: rcg didn't update its configuration" error when booting. Set .flags = CLK_OPS_PARENT_ENABLE to fix the error.
--- drivers/clk/qcom/gcc-sm8250.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-sm8250.c +1 -0
@@ -721,6 +721,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .name = "gcc_sdcc2_apps_clk_src", .parent_data = gcc_parent_data_4, .num_parents = ARRAY_SIZE(gcc_parent_data_4), + .flags = CLK_OPS_PARENT_ENABLE, .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 345/600 kvm/vfio: Prepare for accepting vfio device fd
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Liu <[email protected]>
[ Upstream commit 2f99073a722beef5f74f3b0f32bda227ba3df1e0 ]
This renames kvm_vfio_group related helpers to prepare for accepting vfio device fd. No functional change is intended.
Stable-dep-of: 9e0f4f2918c2 ("kvm/vfio: ensure kvg instance stays around in kvm_vfio_group_add()")
--- virt/kvm/vfio.c | 115 ++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 57 deletions(-)
virt/kvm/vfio.c +58 -57
@@ -21,7 +21,7 @@#include <asm/kvm_ppc.h> #endif -struct kvm_vfio_group { +struct kvm_vfio_file {struct list_head node;struct file *file;#ifdef CONFIG_SPAPR_TCE_IOMMU
@@ -30,7 +30,7 @@ struct kvm_vfio_group { };struct kvm_vfio { -struct list_head group_list; +struct list_head file_list;struct mutex lock;bool noncoherent; };
@@ -98,34 +98,35 @@ static struct iommu_group *kvm_vfio_file_iommu_group(struct file *file) }static void kvm_spapr_tce_release_vfio_group (struct kvm *kvm, -struct kvm_vfio_group *kvg) +struct kvm_vfio_file *kvf) { -if (WARN_ON_ONCE (!kvg->iommu_group)) +if (WARN_ON_ONCE (!kvf->iommu_group))return ; -kvm_spapr_tce_release_iommu_group (kvm, kvg->iommu_group); -iommu_group_put (kvg->iommu_group); - kvg->iommu_group =NULL ; +kvm_spapr_tce_release_iommu_group (kvm, kvf->iommu_group); +iommu_group_put (kvf->iommu_group); + kvf->iommu_group =NULL ; }#endif /* -* Groups can use the same or different IOMMU domains. If the same then -* adding a new group may change the coherency of groups we've previously -* been told about. We don't want to care about any of that so we retest -* each group and bail as soon as we find one that's noncoherent. This -* means we only ever [un]register_noncoherent_dma once for the whole device. +* Groups/devices can use the same or different IOMMU domains. If the same +* then adding a new group/device may change the coherency of groups/devices +* we've previously been told about. We don't want to care about any of +* that so we retest each group/device and bail as soon as we find one that's +* noncoherent. This means we only ever [un]register_noncoherent_dma once +* for the whole device. */ static void kvm_vfio_update_coherency (struct kvm_device *dev) {struct kvm_vfio *kv = dev->private;bool noncoherent = false; -struct kvm_vfio_group *kvg; +struct kvm_vfio_file *kvf;mutex_lock (&kv->lock); -list_for_each_entry (kvg, &kv->group_list, node) { -if (!kvm_vfio_file_enforced_coherent (kvg->file)) { +list_for_each_entry (kvf, &kv->file_list, node) { +if (!kvm_vfio_file_enforced_coherent (kvf->file)) { noncoherent = true;break ; }
@@ -143,10 +144,10 @@ static void kvm_vfio_update_coherency(struct kvm_device *dev)mutex_unlock (&kv->lock); } -static int kvm_vfio_group_add (struct kvm_device *dev,unsigned int fd) +static int kvm_vfio_file_add (struct kvm_device *dev,unsigned int fd) {struct kvm_vfio *kv = dev->private; -struct kvm_vfio_group *kvg; +struct kvm_vfio_file *kvf;struct file *filp;int ret;
@@ -162,27 +163,27 @@ static int kvm_vfio_group_add(struct kvm_device *dev, unsigned int fd)mutex_lock (&kv->lock); -list_for_each_entry (kvg, &kv->group_list, node) { -if (kvg->file == filp) { +list_for_each_entry (kvf, &kv->file_list, node) { +if (kvf->file == filp) { ret = -EEXIST ; goto err_unlock; } } - kvg =kzalloc (sizeof (*kvg),GFP_KERNEL_ACCOUNT ); -if (!kvg) { + kvf =kzalloc (sizeof (*kvf),GFP_KERNEL_ACCOUNT ); +if (!kvf) { ret = -ENOMEM ; goto err_unlock; } - kvg->file = filp; -list_add_tail (&kvg->node, &kv->group_list); + kvf->file = filp; +list_add_tail (&kvf->node, &kv->file_list);kvm_arch_start_assignment (dev->kvm);mutex_unlock (&kv->lock); -kvm_vfio_file_set_kvm (kvg->file, dev->kvm); +kvm_vfio_file_set_kvm (kvf->file, dev->kvm);kvm_vfio_update_coherency (dev);return 0 ;
@@ -193,10 +194,10 @@ static int kvm_vfio_group_add(struct kvm_device *dev, unsigned int fd)return ret; } -static int kvm_vfio_group_del (struct kvm_device *dev,unsigned int fd) +static int kvm_vfio_file_del (struct kvm_device *dev,unsigned int fd) {struct kvm_vfio *kv = dev->private; -struct kvm_vfio_group *kvg; +struct kvm_vfio_file *kvf;struct fd f;int ret;
@@ -208,18 +209,18 @@ static int kvm_vfio_group_del(struct kvm_device *dev, unsigned int fd)mutex_lock (&kv->lock); -list_for_each_entry (kvg, &kv->group_list, node) { -if (kvg->file != f.file) +list_for_each_entry (kvf, &kv->file_list, node) { +if (kvf->file != f.file)continue ; -list_del (&kvg->node); +list_del (&kvf->node);kvm_arch_end_assignment (dev->kvm);#ifdef CONFIG_SPAPR_TCE_IOMMU -kvm_spapr_tce_release_vfio_group (dev->kvm, kvg); +kvm_spapr_tce_release_vfio_group (dev->kvm, kvf);#endif -kvm_vfio_file_set_kvm (kvg->file,NULL ); -fput (kvg->file); -kfree (kvg); +kvm_vfio_file_set_kvm (kvf->file,NULL ); +fput (kvf->file); +kfree (kvf); ret =0 ;break ; }
@@ -234,12 +235,12 @@ static int kvm_vfio_group_del(struct kvm_device *dev, unsigned int fd) }#ifdef CONFIG_SPAPR_TCE_IOMMU -static int kvm_vfio_group_set_spapr_tce (struct kvm_device *dev, -void __user *arg) +static int kvm_vfio_file_set_spapr_tce (struct kvm_device *dev, +void __user *arg) {struct kvm_vfio_spapr_tce param;struct kvm_vfio *kv = dev->private; -struct kvm_vfio_group *kvg; +struct kvm_vfio_file *kvf;struct fd f;int ret;
@@ -254,20 +255,20 @@ static int kvm_vfio_group_set_spapr_tce(struct kvm_device *dev,mutex_lock (&kv->lock); -list_for_each_entry (kvg, &kv->group_list, node) { -if (kvg->file != f.file) +list_for_each_entry (kvf, &kv->file_list, node) { +if (kvf->file != f.file)continue ; -if (!kvg->iommu_group) { - kvg->iommu_group =kvm_vfio_file_iommu_group (kvg->file); -if (WARN_ON_ONCE (!kvg->iommu_group)) { +if (!kvf->iommu_group) { + kvf->iommu_group =kvm_vfio_file_iommu_group (kvf->file); +if (WARN_ON_ONCE (!kvf->iommu_group)) { ret = -EIO ; goto err_fdput; } } ret =kvm_spapr_tce_attach_iommu_group (dev->kvm, param.tablefd, - kvg->iommu_group); + kvf->iommu_group);break ; }
@@ -278,8 +279,8 @@ static int kvm_vfio_group_set_spapr_tce(struct kvm_device *dev, }#endif -static int kvm_vfio_set_group (struct kvm_device *dev,long attr, -void __user *arg) +static int kvm_vfio_set_file (struct kvm_device *dev,long attr, +void __user *arg) {int32_t __user *argp = arg;int32_t fd;
@@ -288,16 +289,16 @@ static int kvm_vfio_set_group(struct kvm_device *dev, long attr,case KVM_DEV_VFIO_GROUP_ADD :if (get_user (fd, argp))return -EFAULT ; -return kvm_vfio_group_add (dev, fd); +return kvm_vfio_file_add (dev, fd);case KVM_DEV_VFIO_GROUP_DEL :if (get_user (fd, argp))return -EFAULT ; -return kvm_vfio_group_del (dev, fd); +return kvm_vfio_file_del (dev, fd);#ifdef CONFIG_SPAPR_TCE_IOMMU case KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE : -return kvm_vfio_group_set_spapr_tce (dev, arg); +return kvm_vfio_file_set_spapr_tce (dev, arg);#endif }
@@ -309,8 +310,8 @@ static int kvm_vfio_set_attr(struct kvm_device *dev, {switch (attr->group) {case KVM_DEV_VFIO_GROUP : -return kvm_vfio_set_group (dev, attr->attr, -u64_to_user_ptr (attr->addr)); +return kvm_vfio_set_file (dev, attr->attr, +u64_to_user_ptr (attr->addr)); }return -ENXIO ;
@@ -339,16 +340,16 @@ static int kvm_vfio_has_attr(struct kvm_device *dev,static void kvm_vfio_release (struct kvm_device *dev) {struct kvm_vfio *kv = dev->private; -struct kvm_vfio_group *kvg, *tmp; +struct kvm_vfio_file *kvf, *tmp; -list_for_each_entry_safe (kvg, tmp, &kv->group_list, node) { +list_for_each_entry_safe (kvf, tmp, &kv->file_list, node) {#ifdef CONFIG_SPAPR_TCE_IOMMU -kvm_spapr_tce_release_vfio_group (dev->kvm, kvg); +kvm_spapr_tce_release_vfio_group (dev->kvm, kvf);#endif -kvm_vfio_file_set_kvm (kvg->file,NULL ); -fput (kvg->file); -list_del (&kvg->node); -kfree (kvg); +kvm_vfio_file_set_kvm (kvf->file,NULL ); +fput (kvf->file); +list_del (&kvf->node); +kfree (kvf);kvm_arch_end_assignment (dev->kvm); }
@@ -382,7 +383,7 @@ static int kvm_vfio_create(struct kvm_device *dev, u32 type)if (!kv)return -ENOMEM ; -INIT_LIST_HEAD (&kv->group_list); +INIT_LIST_HEAD (&kv->file_list);mutex_init (&kv->lock); dev->private = kv;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 346/600 kvm/vfio: ensure kvg instance stays around in kvm_vfio_group_add()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 9e0f4f2918c2ff145d3dedee862d9919a6ed5812 ]
kvm_vfio_group_add() creates kvg instance, links it to kv->group_list, and calls kvm_vfio_file_set_kvm() with kvg->file as an argument after dropping kv->lock. If we race group addition and deletion calls, kvg instance may get freed by the time we get around to calling kvm_vfio_file_set_kvm().
Previous iterations of the code did not reference kvg->file outside of the critical section, but used a temporary variable. Still, they had similar problem of the file reference being owned by kvg structure and potential for kvm_vfio_group_del() dropping it before kvm_vfio_group_add() had a chance to complete.
Fix this by moving call to kvm_vfio_file_set_kvm() under the protection of kv->lock. We already call it while holding the same lock when vfio group is being deleted, so it should be safe here as well.
--- virt/kvm/vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/vfio.c +1 -1
@@ -180,10 +180,10 @@ static int kvm_vfio_file_add(struct kvm_device *dev, unsigned int fd)list_add_tail (&kvf->node, &kv->file_list);kvm_arch_start_assignment (dev->kvm); +kvm_vfio_file_set_kvm (kvf->file, dev->kvm);mutex_unlock (&kv->lock); -kvm_vfio_file_set_kvm (kvf->file, dev->kvm);kvm_vfio_update_coherency (dev);return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 347/600 clk: qcom: reset: Use the correct type of sleep/delay based on length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 181b66ee7cdd824797fc99b53bec29cf5630a04f ]
Use the fsleep() helper that (based on the length of the delay, see: [1]) chooses the correct sleep/delay functions.
[1] https://www.kernel.org/doc/Documentation/timers/timers-howto.txt
--- drivers/clk/qcom/reset.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/reset.c +2 -1
@@ -16,7 +16,8 @@ static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id)struct qcom_reset_controller *rst =to_qcom_reset_controller (rcdev); rcdev->ops->assert (rcdev, id); -udelay (rst->reset_map[id].udelay ?:1 );/* use 1 us as default */ +fsleep (rst->reset_map[id].udelay ?:1 );/* use 1 us as default */ + rcdev->ops->deassert (rcdev, id);return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 348/600 clk: qcom: gcc-sm6350: Fix gcc_sdcc2_apps_clk_src
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit df04d166d1f346dbf740bbea64a3bed3e7f14c8d ]
GPLL7 is not on by default, which causes a "gcc_sdcc2_apps_clk_src: rcg didn't update its configuration" error when booting. Set .flags = CLK_OPS_PARENT_ENABLE to fix the error.
--- drivers/clk/qcom/gcc-sm6350.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-sm6350.c +1 -0
@@ -641,6 +641,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .name = "gcc_sdcc2_apps_clk_src", .parent_data = gcc_parent_data_8, .num_parents = ARRAY_SIZE(gcc_parent_data_8), + .flags = CLK_OPS_PARENT_ENABLE, .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 349/600 PCI: microchip: Correct the DED and SEC interrupt bit offsets
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daire McNamara <[email protected]>
[ Upstream commit 6d473a5a26136edf55c435a1c433e52910e03926 ]
The SEC and DED interrupt bits are laid out the wrong way round so the SEC interrupt handler attempts to mask, unmask, and clear the DED interrupt and vice versa. Correct the bit offsets so that each interrupt handler operates properly.
--- drivers/pci/controller/pcie-microchip-host.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-microchip-host.c +4 -4
@@ -167,12 +167,12 @@#define EVENT_PCIE_DLUP_EXIT 2#define EVENT_SEC_TX_RAM_SEC_ERR 3#define EVENT_SEC_RX_RAM_SEC_ERR 4 -#define EVENT_SEC_AXI2PCIE_RAM_SEC_ERR 5 -#define EVENT_SEC_PCIE2AXI_RAM_SEC_ERR 6 +#define EVENT_SEC_PCIE2AXI_RAM_SEC_ERR 5 +#define EVENT_SEC_AXI2PCIE_RAM_SEC_ERR 6#define EVENT_DED_TX_RAM_DED_ERR 7#define EVENT_DED_RX_RAM_DED_ERR 8 -#define EVENT_DED_AXI2PCIE_RAM_DED_ERR 9 -#define EVENT_DED_PCIE2AXI_RAM_DED_ERR 10 +#define EVENT_DED_PCIE2AXI_RAM_DED_ERR 9 +#define EVENT_DED_AXI2PCIE_RAM_DED_ERR 10#define EVENT_LOCAL_DMA_END_ENGINE_0 11#define EVENT_LOCAL_DMA_END_ENGINE_1 12#define EVENT_LOCAL_DMA_ERROR_ENGINE_0 13
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 350/600 PCI: Mark NVIDIA T4 GPUs to avoid bus reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wu Zongyong <[email protected]>
[ Upstream commit d5af729dc2071273f14cbb94abbc60608142fd83 ]
NVIDIA T4 GPUs do not work with SBR. This problem is found when the T4 card is direct attached to a Root Port only. Avoid bus reset by marking T4 GPUs PCI_DEV_FLAGS_NO_BUS_RESET.
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -3631,7 +3631,7 @@ static void quirk_no_bus_reset(struct pci_dev *dev)*/ static void quirk_nvidia_no_bus_reset (struct pci_dev *dev) { -if ((dev->device &0xffc0 ) ==0x2340 ) +if ((dev->device &0xffc0 ) ==0x2340 || dev->device ==0x1eb8 )quirk_no_bus_reset (dev); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 351/600 pinctrl: mcp23s08: check return value of devm_kasprintf()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit f941714a7c7698eadb59bc27d34d6d6f38982705 ]
devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pinctrl/pinctrl-mcp23s08_spi.c +10 -0
@@ -91,18 +91,28 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev, mcp->reg_shift =0 ; mcp->chip.ngpio =8 ; mcp->chip.label =devm_kasprintf (dev,GFP_KERNEL ,"mcp23s08.%d" , addr); +if (!mcp->chip.label) +return -ENOMEM ; config = &mcp23x08_regmap; name =devm_kasprintf (dev,GFP_KERNEL ,"%d" , addr); +if (!name) +return -ENOMEM ; +break ;case MCP_TYPE_S17 : mcp->reg_shift =1 ; mcp->chip.ngpio =16 ; mcp->chip.label =devm_kasprintf (dev,GFP_KERNEL ,"mcp23s17.%d" , addr); +if (!mcp->chip.label) +return -ENOMEM ; config = &mcp23x17_regmap; name =devm_kasprintf (dev,GFP_KERNEL ,"%d" , addr); +if (!name) +return -ENOMEM ; +break ;case MCP_TYPE_S18 :
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 352/600 PCI: Allow drivers to request exclusive config regions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ira Weiny <[email protected]>
[ Upstream commit 278294798ac9118412c9624a801d3f20f2279363 ]
PCI config space access from user space has traditionally been unrestricted with writes being an understood risk for device operation.
Unfortunately, device breakage or odd behavior from config writes lacks indicators that can leave driver writers confused when evaluating failures. This is especially true with the new PCIe Data Object Exchange (DOE) mailbox protocol where backdoor shenanigans from user space through things such as vendor defined protocols may affect device operation without complete breakage.
A prior proposal restricted read and writes completely.[1] Greg and Bjorn pointed out that proposal is flawed for a couple of reasons. First, lspci should always be allowed and should not interfere with any device operation. Second, setpci is a valuable tool that is sometimes necessary and it should not be completely restricted.[2] Finally methods exist for full lock of device access if required.
Even though access should not be restricted it would be nice for driver writers to be able to flag critical parts of the config space such that interference from user space can be detected.
Introduce pci_request_config_region_exclusive() to mark exclusive config regions. Such regions trigger a warning and kernel taint if accessed via user space.
Create pci_warn_once() to restrict the user from spamming the log.
[1] https://lore.kernel.org/all/161663543465.1867664.5674061943008380442.stgit@dwillia2-desk3.amr.corp.intel.com/
[2] https://lore.kernel.org/all/[email protected]/
Stable-dep-of: 5e70d0acf082 ("PCI: Add locking to RMW PCI Express Capability Register accessors")
--- drivers/pci/pci-sysfs.c | 7 +++++++ drivers/pci/probe.c | 6 ++++++ include/linux/ioport.h | 2 ++ include/linux/pci.h | 17 +++++++++++++++++ kernel/resource.c | 13 ++++++++----- 5 files changed, 40 insertions(+), 5 deletions(-)
drivers/pci/pci-sysfs.c +7 -0
@@ -756,6 +756,13 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,if (ret)return ret; +if (resource_is_exclusive (&dev->driver_exclusive_resource, off, + count)) { +pci_warn_once (dev,"%s: Unexpected write to kernel-exclusive config offset %llx" , + current->comm, off); +add_taint (TAINT_USER ,LOCKDEP_STILL_OK ); + } +if (off > dev->cfg_size)return 0 ;if (off + count > dev->cfg_size) {
drivers/pci/probe.c +6 -0
@@ -2306,6 +2306,12 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)INIT_LIST_HEAD (&dev->bus_list); dev->dev.type = &pci_dev_type; dev->bus =pci_bus_get (bus); + dev->driver_exclusive_resource = (struct resource ) { + .name ="PCI Exclusive" , + .start =0 , + .end =-1 , + }; +#ifdef CONFIG_PCI_MSI raw_spin_lock_init (&dev->msi_lock);#endif
include/linux/ioport.h +2 -0
@@ -318,6 +318,8 @@ extern void __devm_release_region(struct device *dev, struct resource *parent, resource_size_t start, resource_size_t n);extern int iomem_map_sanity_check (resource_size_t addr,unsigned long size);extern bool iomem_is_exclusive (u64 addr); +extern bool resource_is_exclusive (struct resource *resource,u64 addr, +resource_size_t size); extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
include/linux/pci.h +17 -0
@@ -409,6 +409,7 @@ struct pci_dev {*/ unsigned int irq;struct resource resource[DEVICE_COUNT_RESOURCE ];/* I/O and memory regions + expansion ROMs */ +struct resource driver_exclusive_resource;/* driver exclusive resource ranges */ bool match_driver;/* Skip attaching driver */
@@ -1408,6 +1409,21 @@ int pci_request_selected_regions(struct pci_dev *, int, const char *);int pci_request_selected_regions_exclusive (struct pci_dev *,int ,const char *);void pci_release_selected_regions (struct pci_dev *,int ); +static inline __must_check struct resource * +pci_request_config_region_exclusive (struct pci_dev *pdev,unsigned int offset, +unsigned int len,const char *name) +{ +return __request_region (&pdev->driver_exclusive_resource, offset, len, + name,IORESOURCE_EXCLUSIVE ); +} + +static inline void pci_release_config_region (struct pci_dev *pdev, +unsigned int offset, +unsigned int len) +{ +__release_region (&pdev->driver_exclusive_resource, offset, len); +} +/* drivers/pci/bus.c */ void pci_add_resource (struct list_head *resources,struct resource *res); void pci_add_resource_offset(struct list_head *resources, struct resource *res,
@@ -2487,6 +2503,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); #define pci_crit(pdev, fmt, arg...) dev_crit(&(pdev)->dev, fmt, ##arg) #define pci_err(pdev, fmt, arg...) dev_err(&(pdev)->dev, fmt, ##arg) #define pci_warn(pdev, fmt, arg...) dev_warn(&(pdev)->dev, fmt, ##arg) +#define pci_warn_once(pdev, fmt, arg...) dev_warn_once(&(pdev)->dev, fmt, ##arg) #define pci_notice(pdev, fmt, arg...) dev_notice(&(pdev)->dev, fmt, ##arg) #define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg) #define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg)
kernel/resource.c +8 -5
@@ -1693,18 +1693,15 @@ static int strict_iomem_checks;* * Returns true if exclusive to the kernel, otherwise returns false. */ -bool iomem_is_exclusive (u64 addr) +bool resource_is_exclusive (struct resource *root,u64 addr,resource_size_t size) {const unsigned int exclusive_system_ram =IORESOURCE_SYSTEM_RAM |IORESOURCE_EXCLUSIVE ;bool skip_children = false, err = false; -int size =PAGE_SIZE ;struct resource *p; - addr = addr &PAGE_MASK ; -read_lock (&resource_lock); -for_each_resource (&iomem_resource, p, skip_children) { +for_each_resource (root, p, skip_children) {if (p->start >= addr + size)break ;if (p->end < addr) {
@@ -1743,6 +1740,12 @@ bool iomem_is_exclusive(u64 addr)return err; } +bool iomem_is_exclusive (u64 addr) +{ +return resource_is_exclusive (&iomem_resource, addr &PAGE_MASK , +PAGE_SIZE ); +} +struct resource_entry *resource_list_create_entry (struct resource *res,size_t extra_size) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 353/600 PCI: Add locking to RMW PCI Express Capability Register accessors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 5e70d0acf0825f439079736080350371f8d6699a ]
Many places in the kernel write the Link Control and Root Control PCI Express Capability Registers without proper concurrency control and this could result in losing the changes one of the writers intended to make.
Add pcie_cap_lock spinlock into the struct pci_dev and use it to protect bit changes made in the RMW capability accessors. Protect only a selected set of registers by differentiating the RMW accessor internally to locked/unlocked variants using a wrapper which has the same signature as pcie_capability_clear_and_set_word(). As the Capability Register (pos) given to the wrapper is always a constant, the compiler should be able to simplify all the dead-code away.
So far only the Link Control Register (ASPM, hotplug, link retraining, various drivers) and the Root Control Register (AER & PME) seem to require RMW locking.
--- drivers/pci/access.c | 20 +++++++++++++++++--- drivers/pci/probe.c | 1 + include/linux/pci.h | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 5 deletions(-)
drivers/pci/access.c +17 -3
@@ -491,8 +491,8 @@ int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) }EXPORT_SYMBOL (pcie_capability_write_dword); -int pcie_capability_clear_and_set_word (struct pci_dev *dev,int pos, -u16 clear,u16 set) +int pcie_capability_clear_and_set_word_unlocked (struct pci_dev *dev,int pos, +u16 clear,u16 set) {int ret;u16 val;
@@ -506,7 +506,21 @@ int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,return ret; } -EXPORT_SYMBOL (pcie_capability_clear_and_set_word); +EXPORT_SYMBOL (pcie_capability_clear_and_set_word_unlocked); + +int pcie_capability_clear_and_set_word_locked (struct pci_dev *dev,int pos, +u16 clear,u16 set) +{ +unsigned long flags; +int ret; + +spin_lock_irqsave (&dev->pcie_cap_lock, flags); + ret =pcie_capability_clear_and_set_word_unlocked (dev, pos, clear, set); +spin_unlock_irqrestore (&dev->pcie_cap_lock, flags); + +return ret; +} +EXPORT_SYMBOL (pcie_capability_clear_and_set_word_locked);int pcie_capability_clear_and_set_dword (struct pci_dev *dev,int pos,u32 clear,u32 set)
drivers/pci/probe.c +1 -0
@@ -2312,6 +2312,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus) .end = -1, }; +spin_lock_init (&dev->pcie_cap_lock);#ifdef CONFIG_PCI_MSI raw_spin_lock_init (&dev->msi_lock);#endif
include/linux/pci.h +32 -2
@@ -466,6 +466,7 @@ struct pci_dev {pci_dev_flags_t dev_flags;atomic_t enable_cnt;/* pci_enable_device has been called */ +spinlock_t pcie_cap_lock;/* Protects RMW ops in capability accessors */ u32 saved_config_space[16 ];/* Config space saved at suspend time */ struct hlist_head saved_cap_space;int rom_attr_enabled;/* Display of ROM attribute enabled? */
@@ -1209,11 +1210,40 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);int pcie_capability_read_dword (struct pci_dev *dev,int pos,u32 *val);int pcie_capability_write_word (struct pci_dev *dev,int pos,u16 val);int pcie_capability_write_dword (struct pci_dev *dev,int pos,u32 val); -int pcie_capability_clear_and_set_word (struct pci_dev *dev,int pos, -u16 clear,u16 set); +int pcie_capability_clear_and_set_word_unlocked (struct pci_dev *dev,int pos, +u16 clear,u16 set); +int pcie_capability_clear_and_set_word_locked (struct pci_dev *dev,int pos, +u16 clear,u16 set);int pcie_capability_clear_and_set_dword (struct pci_dev *dev,int pos,u32 clear,u32 set); +/** +* pcie_capability_clear_and_set_word - RMW accessor for PCI Express Capability Registers +* @dev: PCI device structure of the PCI Express device +* @pos: PCI Express Capability Register +* @clear: Clear bitmask +* @set: Set bitmask +* +* Perform a Read-Modify-Write (RMW) operation using @clear and @set +* bitmasks on PCI Express Capability Register at @pos. Certain PCI Express +* Capability Registers are accessed concurrently in RMW fashion, hence +* require locking which is handled transparently to the caller. +*/ +static inline int pcie_capability_clear_and_set_word (struct pci_dev *dev, +int pos, +u16 clear,u16 set) +{ +switch (pos) { +case PCI_EXP_LNKCTL : +case PCI_EXP_RTCTL : +return pcie_capability_clear_and_set_word_locked (dev, pos, + clear, set); +default : +return pcie_capability_clear_and_set_word_unlocked (dev, pos, + clear, set); + } +} +static inline int pcie_capability_set_word (struct pci_dev *dev,int pos,u16 set) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 354/600 PCI: pciehp: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 5f75f96c61039151c193775d776fde42477eace1 ]
As hotplug is not the only driver touching LNKCTL, use the RMW capability accessor which handles concurrent changes correctly.
--- drivers/pci/hotplug/pciehp_hpc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +3 -9
@@ -332,17 +332,11 @@ int pciehp_check_link_status(struct controller *ctrl)static int __pciehp_link_set (struct controller *ctrl,bool enable) {struct pci_dev *pdev =ctrl_dev (ctrl); -u16 lnk_ctrl; -pcie_capability_read_word (pdev,PCI_EXP_LNKCTL , &lnk_ctrl); +pcie_capability_clear_and_set_word (pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_LD , + enable ?0 :PCI_EXP_LNKCTL_LD ); -if (enable) - lnk_ctrl &= ~PCI_EXP_LNKCTL_LD ; -else - lnk_ctrl |=PCI_EXP_LNKCTL_LD ; - -pcie_capability_write_word (pdev,PCI_EXP_LNKCTL , lnk_ctrl); -ctrl_dbg (ctrl,"%s: lnk_ctrl = %x\n" , __func__, lnk_ctrl);return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 355/600 PCI/ASPM: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit e09060b3b6b4661278ff8e1b7b81a37d5ea86eae ]
Don't assume that the device is fully under the control of ASPM and use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register values.
If configuration fails in pcie_aspm_configure_common_clock(), the function attempts to restore the old PCI_EXP_LNKCTL_CCC settings. Store only the old PCI_EXP_LNKCTL_CCC bit for the relevant devices rather than the content of the whole LNKCTL registers. It aligns better with how pcie_lnkctl_clear_and_set() expects its parameter and makes the code more obvious to understand.
--- drivers/pci/pcie/aspm.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/pci/pcie/aspm.c +13 -17
@@ -250,7 +250,7 @@ static int pcie_retrain_link(struct pcie_link_state *link)static void pcie_aspm_configure_common_clock (struct pcie_link_state *link) {int same_clock =1 ; -u16 reg16, parent_reg, child_reg[8 ]; +u16 reg16, ccc, parent_old_ccc, child_old_ccc[8 ];struct pci_dev *child, *parent = link->pdev;struct pci_bus *linkbus = parent->subordinate;/*
@@ -272,6 +272,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)/* Port might be already in common clock mode */ pcie_capability_read_word (parent,PCI_EXP_LNKCTL , ®16); + parent_old_ccc = reg16 &PCI_EXP_LNKCTL_CCC ;if (same_clock && (reg16 &PCI_EXP_LNKCTL_CCC )) {bool consistent = true;
@@ -288,34 +289,29 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)pci_info (parent,"ASPM: current common clock configuration is inconsistent, reconfiguring\n" ); } + ccc = same_clock ?PCI_EXP_LNKCTL_CCC :0 ;/* Configure downstream component, all functions */ list_for_each_entry (child, &linkbus->devices, bus_list) {pcie_capability_read_word (child,PCI_EXP_LNKCTL , ®16); - child_reg[PCI_FUNC (child->devfn)] = reg16; -if (same_clock) - reg16 |=PCI_EXP_LNKCTL_CCC ; -else - reg16 &= ~PCI_EXP_LNKCTL_CCC ; -pcie_capability_write_word (child,PCI_EXP_LNKCTL , reg16); + child_old_ccc[PCI_FUNC (child->devfn)] = reg16 &PCI_EXP_LNKCTL_CCC ; +pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_CCC , ccc); }/* Configure upstream component */ -pcie_capability_read_word (parent,PCI_EXP_LNKCTL , ®16); - parent_reg = reg16; -if (same_clock) - reg16 |=PCI_EXP_LNKCTL_CCC ; -else - reg16 &= ~PCI_EXP_LNKCTL_CCC ; -pcie_capability_write_word (parent,PCI_EXP_LNKCTL , reg16); +pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_CCC , ccc);if (pcie_retrain_link (link)) {/* Training failed. Restore common clock configurations */ pci_err (parent,"ASPM: Could not configure common clock\n" );list_for_each_entry (child, &linkbus->devices, bus_list) -pcie_capability_write_word (child,PCI_EXP_LNKCTL , - child_reg[PCI_FUNC (child->devfn)]); -pcie_capability_write_word (parent,PCI_EXP_LNKCTL , parent_reg); +pcie_capability_clear_and_set_word (child,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_CCC , + child_old_ccc[PCI_FUNC (child->devfn)]); +pcie_capability_clear_and_set_word (parent,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_CCC , parent_old_ccc); } }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 356/600 clk: qcom: gcc-sm8450: Use floor ops for SDCC RCGs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit a27ac3806b0a0e6954fb5967223b8635242e5b8f ]
Use the floor ops to prevent warnings like this at suspend exit and boot:
mmc0: Card appears overclocked; req 800000 Hz, actual 25000000 Hz
--- drivers/clk/qcom/gcc-sm8450.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8450.c +2 -2
@@ -904,7 +904,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_7, .num_parents = ARRAY_SIZE(gcc_parent_data_7), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_floor_ops, }, };
@@ -926,7 +926,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 357/600 clk: imx: pllv4: Fix SPLL2 MULT range
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Li <[email protected]>
[ Upstream commit 3f0cdb945471f1abd1cf4d172190e9c489c5052a ]
The SPLL2 on iMX8ULP is different with other frac PLLs, it can support VCO from 650Mhz to 1Ghz. According to RM, the MULT is using a range from 27 to 54, not some fixed values. If using current PLL implementation, some clock rate can't be supported.
Fix the issue by adding new type for the SPLL2 and use MULT range to replace MULT table
--- drivers/clk/imx/clk-pllv4.c | 46 +++++++++++++++++++++++++++++-------- drivers/clk/imx/clk.h | 1 + 2 files changed, 37 insertions(+), 10 deletions(-)
drivers/clk/imx/clk-pllv4.c +36 -10
@@ -44,11 +44,15 @@ struct clk_pllv4 {u32 cfg_offset;u32 num_offset;u32 denom_offset; +bool use_mult_range; };/* Valid PLL MULT Table */ static const int pllv4_mult_table[] = {33 ,27 ,22 ,20 ,17 ,16 }; +/* Valid PLL MULT range, (max, min) */ +static const int pllv4_mult_range[] = {54 ,27 }; +#define to_clk_pllv4 (__hw) container_of(__hw, struct clk_pllv4, hw)#define LOCK_TIMEOUT_US USEC_PER_MSEC
@@ -94,17 +98,30 @@ static unsigned long clk_pllv4_recalc_rate(struct clk_hw *hw,static long clk_pllv4_round_rate (struct clk_hw *hw,unsigned long rate,unsigned long *prate) { +struct clk_pllv4 *pll =to_clk_pllv4 (hw);unsigned long parent_rate = *prate;unsigned long round_rate, i;u32 mfn, mfd =DEFAULT_MFD ;bool found = false;u64 temp64; - -for (i =0 ; i <ARRAY_SIZE (pllv4_mult_table); i++) { - round_rate = parent_rate * pllv4_mult_table[i]; -if (rate >= round_rate) { +u32 mult; + +if (pll->use_mult_range) { + temp64 = (u64 )rate; +do_div (temp64, parent_rate); + mult = temp64; +if (mult >= pllv4_mult_range[1 ] && + mult <= pllv4_mult_range[0 ]) { + round_rate = parent_rate * mult; found = true; -break ; + } + }else { +for (i =0 ; i <ARRAY_SIZE (pllv4_mult_table); i++) { + round_rate = parent_rate * pllv4_mult_table[i]; +if (rate >= round_rate) { + found = true; +break ; + } } }
@@ -138,14 +155,20 @@ static long clk_pllv4_round_rate(struct clk_hw *hw, unsigned long rate,return round_rate + (u32 )temp64; } -static bool clk_pllv4_is_valid_mult (unsigned int mult) +static bool clk_pllv4_is_valid_mult (struct clk_pllv4 *pll,unsigned int mult) {int i;/* check if mult is in valid MULT table */ -for (i =0 ; i <ARRAY_SIZE (pllv4_mult_table); i++) { -if (pllv4_mult_table[i] == mult) +if (pll->use_mult_range) { +if (mult >= pllv4_mult_range[1 ] && + mult <= pllv4_mult_range[0 ])return true; + }else { +for (i =0 ; i <ARRAY_SIZE (pllv4_mult_table); i++) { +if (pllv4_mult_table[i] == mult) +return true; + } }return false;
@@ -160,7 +183,7 @@ static int clk_pllv4_set_rate(struct clk_hw *hw, unsigned long rate, mult = rate / parent_rate; -if (!clk_pllv4_is_valid_mult (mult)) +if (!clk_pllv4_is_valid_mult (pll, mult))return -EINVAL ;if (parent_rate <=MAX_MFD )
@@ -227,10 +250,13 @@ struct clk_hw *imx_clk_hw_pllv4(enum imx_pllv4_type type, const char *name, pll->base = base; -if (type ==IMX_PLLV4_IMX8ULP ) { +if (type ==IMX_PLLV4_IMX8ULP || + type ==IMX_PLLV4_IMX8ULP_1GHZ ) { pll->cfg_offset =IMX8ULP_PLL_CFG_OFFSET ; pll->num_offset =IMX8ULP_PLL_NUM_OFFSET ; pll->denom_offset =IMX8ULP_PLL_DENOM_OFFSET ; +if (type ==IMX_PLLV4_IMX8ULP_1GHZ ) + pll->use_mult_range = true; }else { pll->cfg_offset =PLL_CFG_OFFSET ; pll->num_offset =PLL_NUM_OFFSET ;
drivers/clk/imx/clk.h +1 -0
@@ -46,6 +46,7 @@ enum imx_pll14xx_type {enum imx_pllv4_type {IMX_PLLV4_IMX7ULP ,IMX_PLLV4_IMX8ULP , +IMX_PLLV4_IMX8ULP_1GHZ , };enum imx_pfdv2_type {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 358/600 clk: imx: imx8ulp: update SPLL2 type
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 7653a59be8af043adc4c09473975a860e6055ff9 ]
The SPLL2 on iMX8ULP is different with other frac PLLs, it can support VCO from 650Mhz to 1Ghz. Following the changes to pllv4, use the new type IMX_PLLV4_IMX8ULP_1GHZ.
--- drivers/clk/imx/clk-imx8ulp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-imx8ulp.c +1 -1
@@ -167,7 +167,7 @@ static int imx8ulp_clk_cgc1_init(struct platform_device *pdev) clks[IMX8ULP_CLK_SPLL2_PRE_SEL ] =imx_clk_hw_mux_flags ("spll2_pre_sel" , base +0x510 ,0 ,1 , pll_pre_sels,ARRAY_SIZE (pll_pre_sels),CLK_SET_PARENT_GATE ); clks[IMX8ULP_CLK_SPLL3_PRE_SEL ] =imx_clk_hw_mux_flags ("spll3_pre_sel" , base +0x610 ,0 ,1 , pll_pre_sels,ARRAY_SIZE (pll_pre_sels),CLK_SET_PARENT_GATE ); - clks[IMX8ULP_CLK_SPLL2 ] =imx_clk_hw_pllv4 (IMX_PLLV4_IMX8ULP ,"spll2" ,"spll2_pre_sel" , base +0x500 ); + clks[IMX8ULP_CLK_SPLL2 ] =imx_clk_hw_pllv4 (IMX_PLLV4_IMX8ULP_1GHZ ,"spll2" ,"spll2_pre_sel" , base +0x500 ); clks[IMX8ULP_CLK_SPLL3 ] =imx_clk_hw_pllv4 (IMX_PLLV4_IMX8ULP ,"spll3" ,"spll3_pre_sel" , base +0x600 ); clks[IMX8ULP_CLK_SPLL3_VCODIV ] =imx_clk_hw_divider ("spll3_vcodiv" ,"spll3" , base +0x604 ,0 ,6 );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 359/600 clk: imx8mp: fix sai4 clock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Felsch <[email protected]>
[ Upstream commit c30f600f1f41dcf5ef0fb02e9a201f9b2e8f31bd ]
The reference manual don't mention a SAI4 hardware block. This would be clock slice 78 which is skipped (TRM, page 237). Remove any reference to this clock to align the driver with the reality.
--- drivers/clk/imx/clk-imx8mp.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/clk/imx/clk-imx8mp.c +0 -5
@@ -177,10 +177,6 @@ static const char * const imx8mp_sai3_sels[] = {"osc_24m", "audio_pll1_out", "au"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , "clk_ext3", "clk_ext4", }; -static const char *const imx8mp_sai4_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , -"clk_ext1" ,"clk_ext2" , }; -static const char *const imx8mp_sai5_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" ,"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" ,"clk_ext2" ,"clk_ext3" , };
@@ -566,7 +562,6 @@ static int imx8mp_clocks_probe(struct platform_device *pdev) hws[IMX8MP_CLK_SAI1 ] =imx8m_clk_hw_composite ("sai1" , imx8mp_sai1_sels, ccm_base +0xa580 ); hws[IMX8MP_CLK_SAI2 ] =imx8m_clk_hw_composite ("sai2" , imx8mp_sai2_sels, ccm_base +0xa600 ); hws[IMX8MP_CLK_SAI3 ] =imx8m_clk_hw_composite ("sai3" , imx8mp_sai3_sels, ccm_base +0xa680 ); - hws[IMX8MP_CLK_SAI4 ] =imx8m_clk_hw_composite ("sai4" , imx8mp_sai4_sels, ccm_base +0xa700 ); hws[IMX8MP_CLK_SAI5 ] =imx8m_clk_hw_composite ("sai5" , imx8mp_sai5_sels, ccm_base +0xa780 ); hws[IMX8MP_CLK_SAI6 ] =imx8m_clk_hw_composite ("sai6" , imx8mp_sai6_sels, ccm_base +0xa800 ); hws[IMX8MP_CLK_ENET_QOS ] =imx8m_clk_hw_composite ("enet_qos" , imx8mp_enet_qos_sels, ccm_base +0xa880 );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 360/600 clk: imx: composite-8m: fix clock pauses when set_rate would be a no-op
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit 4dd432d985ef258e3bc436e568fba4b987b59171 ]
Reconfiguring the clock divider to the exact same value is observed on an i.MX8MN to often cause a longer than usual clock pause, probably because the divider restarts counting whenever the register is rewritten.
This issue doesn't show up normally, because the clock framework will take care to not call set_rate when the clock rate is the same. However, when we reconfigure an upstream clock, the common code will call set_rate with the newly calculated rate on all children, e.g.:
- sai5 is running normally and divides Audio PLL out by 16.
- Audio PLL rate is increased by 32Hz (glitch-free kdiv change)
- rates for children are recalculated and rates are set recursively
- imx8m_clk_composite_divider_set_rate(sai5) is called with
32/16 = 2Hz more
- imx8m_clk_composite_divider_set_rate computes same divider as before
- divider register is written, so it restarts counting from zero and MCLK is briefly paused, so instead of e.g. 40ns, MCLK is low for 120ns.
Some external clock consumers can be upset by such unexpected clock pauses, so let's make sure we only rewrite the divider value when the value to be written is actually different.
--- drivers/clk/imx/clk-composite-8m.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-composite-8m.c +7 -5
@@ -97,7 +97,7 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw,int prediv_value;int div_value;int ret; -u32 val; +u32 orig, val; ret =imx8m_clk_composite_compute_dividers (rate, parent_rate, &prediv_value, &div_value);
@@ -106,13 +106,15 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw,spin_lock_irqsave (divider->lock, flags); - val =readl (divider->reg); - val &= ~((clk_div_mask (divider->width) << divider->shift) | - (clk_div_mask (PCG_DIV_WIDTH ) <<PCG_DIV_SHIFT )); + orig =readl (divider->reg); + val = orig & ~((clk_div_mask (divider->width) << divider->shift) | + (clk_div_mask (PCG_DIV_WIDTH ) <<PCG_DIV_SHIFT )); val |= (u32)(prediv_value -1 ) << divider->shift; val |= (u32)(div_value -1 ) <<PCG_DIV_SHIFT ; -writel (val, divider->reg); + +if (val != orig) +writel (val, divider->reg);spin_unlock_irqrestore (divider->lock, flags);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 361/600 powerpc/radix: Move some functions into #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 4a9dd8f292efd614f0a18452e6474fe19ae17b47 ]
With skiboot_defconfig, Clang reports:
CC arch/powerpc/mm/book3s64/radix_tlb.oarch/powerpc/mm/book3s64/radix_tlb.c:419:20: error: unused function '_tlbie_pid_lpid' [-Werror,-Wunused-function] static inline void _tlbie_pid_lpid(unsigned long pid, unsigned long lpid,
^
arch/powerpc/mm/book3s64/radix_tlb.c:663:20: error: unused function '_tlbie_va_range_lpid' [-Werror,-Wunused-function]
static inline void _tlbie_va_range_lpid(unsigned long start, unsigned long end,
^This is because those functions are only called from functions enclosed in a #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
Move below functions inside that #ifdef
* __tlbie_pid_lpid(unsigned long pid,
* __tlbie_va_lpid(unsigned long va, unsigned long pid,
* fixup_tlbie_pid_lpid(unsigned long pid, unsigned long lpid)
* _tlbie_pid_lpid(unsigned long pid, unsigned long lpid,
* fixup_tlbie_va_range_lpid(unsigned long va,
* __tlbie_va_range_lpid(unsigned long start, unsigned long end,
* _tlbie_va_range_lpid(unsigned long start, unsigned long end,
--- arch/powerpc/mm/book3s64/radix_tlb.c | 240 ++++++++++++++------------- 1 file changed, 121 insertions(+), 119 deletions(-)
arch/powerpc/mm/book3s64/radix_tlb.c +121 -119
@@ -127,21 +127,6 @@ static __always_inline void __tlbie_pid(unsigned long pid, unsigned long ric)trace_tlbie (0 ,0 , rb, rs, ric, prs, r); } -static __always_inline void __tlbie_pid_lpid(unsigned long pid, -unsigned long lpid, -unsigned long ric) -{ -unsigned long rb, rs, prs, r; - - rb =PPC_BIT (53 );/* IS = 1 */ - rs = (pid <<PPC_BITLSHIFT (31 )) | (lpid & ~(PPC_BITMASK (0 ,31 ))); - prs =1 ;/* process scoped */ - r =1 ;/* radix format */ - - asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) - : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); - trace_tlbie(0 ,0 , rb, rs, ric, prs, r); -} static __always_inline void __tlbie_lpid(unsigned long lpid, unsigned long ric) {unsigned long rb,rs,prs,r;
@@ -202,23 +187,6 @@ static __always_inline void __tlbie_va(unsigned long va, unsigned long pid,trace_tlbie (0 ,0 , rb, rs, ric, prs, r); } -static __always_inline void __tlbie_va_lpid(unsigned long va, unsigned long pid, -unsigned long lpid, -unsigned long ap,unsigned long ric) -{ -unsigned long rb, rs, prs, r; - - rb = va & ~(PPC_BITMASK (52 ,63 )); - rb |= ap <<PPC_BITLSHIFT (58 ); - rs = (pid <<PPC_BITLSHIFT (31 )) | (lpid & ~(PPC_BITMASK (0 ,31 ))); - prs =1 ;/* process scoped */ - r =1 ;/* radix format */ - - asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) - : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); - trace_tlbie(0 ,0 , rb, rs, ric, prs, r); -} - static __always_inline void __tlbie_lpid_va(unsigned long va, unsigned long lpid,unsigned long ap,unsigned long ric) {
@@ -264,22 +232,6 @@ static inline void fixup_tlbie_va_range(unsigned long va, unsigned long pid, } } -static inline void fixup_tlbie_va_range_lpid (unsigned long va, -unsigned long pid, -unsigned long lpid, -unsigned long ap) -{ -if (cpu_has_feature (CPU_FTR_P9_TLBIE_ERAT_BUG )) { - asmvolatile ("ptesync" : : :"memory" ); -__tlbie_pid_lpid (0 , lpid,RIC_FLUSH_TLB ); - } - -if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) { - asmvolatile ("ptesync" : : :"memory" ); -__tlbie_va_lpid (va, pid, lpid, ap,RIC_FLUSH_TLB ); - } -} -static inline void fixup_tlbie_pid (unsigned long pid) {/*
@@ -299,26 +251,6 @@ static inline void fixup_tlbie_pid(unsigned long pid) } } -static inline void fixup_tlbie_pid_lpid (unsigned long pid,unsigned long lpid) -{ -/* -* We can use any address for the invalidation, pick one which is -* probably unused as an optimisation. -*/ -unsigned long va = ((1UL <<52 ) -1 ); - -if (cpu_has_feature (CPU_FTR_P9_TLBIE_ERAT_BUG )) { - asmvolatile ("ptesync" : : :"memory" ); -__tlbie_pid_lpid (0 , lpid,RIC_FLUSH_TLB ); - } - -if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) { - asmvolatile ("ptesync" : : :"memory" ); -__tlbie_va_lpid (va, pid, lpid,mmu_get_ap (MMU_PAGE_64K ), -RIC_FLUSH_TLB ); - } -} -static inline void fixup_tlbie_lpid_va (unsigned long va,unsigned long lpid,unsigned long ap) {
@@ -416,31 +348,6 @@ static inline void _tlbie_pid(unsigned long pid, unsigned long ric) asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); } -static inline void _tlbie_pid_lpid (unsigned long pid,unsigned long lpid, -unsigned long ric) -{ - asmvolatile ("ptesync" : : :"memory" ); - -/* -* Workaround the fact that the "ric" argument to __tlbie_pid -* must be a compile-time contraint to match the "i" constraint -* in the asm statement. -*/ -switch (ric) { -case RIC_FLUSH_TLB : -__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_TLB ); -fixup_tlbie_pid_lpid (pid, lpid); -break ; -case RIC_FLUSH_PWC : -__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_PWC ); -break ; -case RIC_FLUSH_ALL : -default : -__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_ALL ); -fixup_tlbie_pid_lpid (pid, lpid); - } - asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); -}struct tlbiel_pid {unsigned long pid;unsigned long ric;
@@ -566,20 +473,6 @@ static inline void __tlbie_va_range(unsigned long start, unsigned long end,fixup_tlbie_va_range (addr - page_size, pid, ap); } -static inline void __tlbie_va_range_lpid (unsigned long start,unsigned long end, -unsigned long pid,unsigned long lpid, -unsigned long page_size, -unsigned long psize) -{ -unsigned long addr; -unsigned long ap =mmu_get_ap (psize); - -for (addr = start; addr < end; addr += page_size) -__tlbie_va_lpid (addr, pid, lpid, ap,RIC_FLUSH_TLB ); - -fixup_tlbie_va_range_lpid (addr - page_size, pid, lpid, ap); -} - static __always_inline void _tlbie_va(unsigned long va, unsigned long pid,unsigned long psize,unsigned long ric) {
@@ -660,18 +553,6 @@ static inline void _tlbie_va_range(unsigned long start, unsigned long end, asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); } -static inline void _tlbie_va_range_lpid (unsigned long start,unsigned long end, -unsigned long pid,unsigned long lpid, -unsigned long page_size, -unsigned long psize,bool also_pwc) -{ - asmvolatile ("ptesync" : : :"memory" ); -if (also_pwc) -__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_PWC ); -__tlbie_va_range_lpid (start, end, pid, lpid, page_size, psize); - asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); -} - static inline void _tlbiel_va_range_multicast(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long pid, unsigned long page_size,
@@ -1476,6 +1357,127 @@ void radix__flush_tlb_all(void) }#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE +static __always_inline void __tlbie_pid_lpid(unsigned long pid, +unsigned long lpid, +unsigned long ric) +{ +unsigned long rb, rs, prs, r; + + rb =PPC_BIT (53 );/* IS = 1 */ + rs = (pid <<PPC_BITLSHIFT (31 )) | (lpid & ~(PPC_BITMASK (0 ,31 ))); + prs =1 ;/* process scoped */ + r =1 ;/* radix format */ + + asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) + : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); + trace_tlbie(0 ,0 , rb, rs, ric, prs, r); +} + +static __always_inline void __tlbie_va_lpid(unsigned long va, unsigned long pid, +unsigned long lpid, +unsigned long ap,unsigned long ric) +{ +unsigned long rb, rs, prs, r; + + rb = va & ~(PPC_BITMASK (52 ,63 )); + rb |= ap <<PPC_BITLSHIFT (58 ); + rs = (pid <<PPC_BITLSHIFT (31 )) | (lpid & ~(PPC_BITMASK (0 ,31 ))); + prs =1 ;/* process scoped */ + r =1 ;/* radix format */ + + asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) + : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); + trace_tlbie(0 ,0 , rb, rs, ric, prs, r); +} + +static inline void fixup_tlbie_pid_lpid (unsigned long pid,unsigned long lpid) +{ +/* +* We can use any address for the invalidation, pick one which is +* probably unused as an optimisation. +*/ +unsigned long va = ((1UL <<52 ) -1 ); + +if (cpu_has_feature (CPU_FTR_P9_TLBIE_ERAT_BUG )) { + asmvolatile ("ptesync" : : :"memory" ); +__tlbie_pid_lpid (0 , lpid,RIC_FLUSH_TLB ); + } + +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) { + asmvolatile ("ptesync" : : :"memory" ); +__tlbie_va_lpid (va, pid, lpid,mmu_get_ap (MMU_PAGE_64K ), +RIC_FLUSH_TLB ); + } +} + +static inline void _tlbie_pid_lpid (unsigned long pid,unsigned long lpid, +unsigned long ric) +{ + asmvolatile ("ptesync" : : :"memory" ); + +/* +* Workaround the fact that the "ric" argument to __tlbie_pid +* must be a compile-time contraint to match the "i" constraint +* in the asm statement. +*/ +switch (ric) { +case RIC_FLUSH_TLB : +__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_TLB ); +fixup_tlbie_pid_lpid (pid, lpid); +break ; +case RIC_FLUSH_PWC : +__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_PWC ); +break ; +case RIC_FLUSH_ALL : +default : +__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_ALL ); +fixup_tlbie_pid_lpid (pid, lpid); + } + asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); +} + +static inline void fixup_tlbie_va_range_lpid (unsigned long va, +unsigned long pid, +unsigned long lpid, +unsigned long ap) +{ +if (cpu_has_feature (CPU_FTR_P9_TLBIE_ERAT_BUG )) { + asmvolatile ("ptesync" : : :"memory" ); +__tlbie_pid_lpid (0 , lpid,RIC_FLUSH_TLB ); + } + +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) { + asmvolatile ("ptesync" : : :"memory" ); +__tlbie_va_lpid (va, pid, lpid, ap,RIC_FLUSH_TLB ); + } +} + +static inline void __tlbie_va_range_lpid (unsigned long start,unsigned long end, +unsigned long pid,unsigned long lpid, +unsigned long page_size, +unsigned long psize) +{ +unsigned long addr; +unsigned long ap =mmu_get_ap (psize); + +for (addr = start; addr < end; addr += page_size) +__tlbie_va_lpid (addr, pid, lpid, ap,RIC_FLUSH_TLB ); + +fixup_tlbie_va_range_lpid (addr - page_size, pid, lpid, ap); +} + +static inline void _tlbie_va_range_lpid (unsigned long start,unsigned long end, +unsigned long pid,unsigned long lpid, +unsigned long page_size, +unsigned long psize,bool also_pwc) +{ + asmvolatile ("ptesync" : : :"memory" ); +if (also_pwc) +__tlbie_pid_lpid (pid, lpid,RIC_FLUSH_PWC ); +__tlbie_va_range_lpid (start, end, pid, lpid, page_size, psize); + asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); +} +/* * Performs process-scoped invalidations for a given LPID * as part of H_RPT_INVALIDATE hcall.
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 362/600 vfio/type1: fix cap_migration information leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Hajnoczi <[email protected]>
[ Upstream commit cd24e2a60af633f157d7e59c0a6dba64f131c0b1 ]
Fix an information leak where an uninitialized hole in struct vfio_iommu_type1_info_cap_migration on the stack is exposed to userspace.
The definition of struct vfio_iommu_type1_info_cap_migration contains a hole as shown in this pahole(1) output:
struct vfio_iommu_type1_info_cap_migration {
struct vfio_info_cap_header header; /* 0 8 */
__u32 flags; /* 8 4 */ /* XXX 4 bytes hole, try to pack */
__u64 pgsize_bitmap; /* 16 8 */
__u64 max_dirty_bitmap_size; /* 24 8 */
/* size: 32, cachelines: 1, members: 4 */
/* sum members: 28, holes: 1, sum holes: 4 */
/* last cacheline: 32 bytes */};
The cap_mig variable is filled in without initializing the hole:
static int vfio_iommu_migration_build_caps(struct vfio_iommu *iommu,
struct vfio_info_cap *caps)
{
struct vfio_iommu_type1_info_cap_migration cap_mig;
cap_mig.header.id = VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION;
cap_mig.header.version = 1;
cap_mig.flags = 0;
/* support minimum pgsize */
cap_mig.pgsize_bitmap = (size_t)1 << __ffs(iommu->pgsize_bitmap);
cap_mig.max_dirty_bitmap_size = DIRTY_BITMAP_SIZE_MAX;
return vfio_info_add_capability(caps, &cap_mig.header, sizeof(cap_mig));}
The structure is then copied to a temporary location on the heap. At this point it's already too late and ioctl(VFIO_IOMMU_GET_INFO) copies it to userspace later:
int vfio_info_add_capability(struct vfio_info_cap *caps,
struct vfio_info_cap_header *cap, size_t size)
{
struct vfio_info_cap_header *header;
header = vfio_info_cap_add(caps, size, cap->id, cap->version);
if (IS_ERR(header))
return PTR_ERR(header);
memcpy(header + 1, cap + 1, size - sizeof(*header));
return 0;}
This issue was found by code inspection.
--- drivers/vfio/vfio_iommu_type1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/vfio_iommu_type1.c +1 -1
@@ -2822,7 +2822,7 @@ static int vfio_iommu_iova_build_caps(struct vfio_iommu *iommu,static int vfio_iommu_migration_build_caps (struct vfio_iommu *iommu,struct vfio_info_cap *caps) { -struct vfio_iommu_type1_info_cap_migration cap_mig; +struct vfio_iommu_type1_info_cap_migration cap_mig = {}; cap_mig.header.id =VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION ; cap_mig.header.version =1 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 363/600 nvdimm: Fix memleak of pmu attr_groups in unregister_nvdimm_pmu()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Meskhidze <[email protected]>
[ Upstream commit 85ae42c72142346645e63c33835da947dfa008b3 ]
Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function 'unregister_nvdimm_pmu'.
--- drivers/nvdimm/nd_perf.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvdimm/nd_perf.c +1 -0
@@ -324,6 +324,7 @@ void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) {perf_pmu_unregister (&nd_pmu->pmu);nvdimm_pmu_free_hotplug_memory (nd_pmu); +kfree (nd_pmu->pmu.attr_groups);kfree (nd_pmu); }EXPORT_SYMBOL_GPL (unregister_nvdimm_pmu);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 364/600 nvdimm: Fix dereference after free in register_nvdimm_pmu()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Meskhidze <[email protected]>
[ Upstream commit 08ca6906a4b7e48f8e93b7c1f49a742a415be6d5 ]
'nd_pmu->pmu.attr_groups' is dereferenced in function 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in function 'nvdimm_pmu_free_hotplug_memory' memory pointed by the fields of 'nd_pmu->pmu.attr_groups' is deallocated it is necessary to call 'kfree' after 'nvdimm_pmu_free_hotplug_memory'.
--- drivers/nvdimm/nd_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/nd_perf.c +1 -1
@@ -308,8 +308,8 @@ int register_nvdimm_pmu(struct nvdimm_pmu *nd_pmu, struct platform_device *pdev) rc =perf_pmu_register (&nd_pmu->pmu, nd_pmu->pmu.name,-1 );if (rc) { -kfree (nd_pmu->pmu.attr_groups);nvdimm_pmu_free_hotplug_memory (nd_pmu); +kfree (nd_pmu->pmu.attr_groups);return rc; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 365/600 powerpc/fadump: reset dump area size if fadump memory reserve fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sourabh Jain <[email protected]>
[ Upstream commit d1eb75e0dfed80d2d85b664e28a39f65b290ab55 ]
In case fadump_reserve_mem() fails to reserve memory, the reserve_dump_area_size variable will retain the reserve area size. This will lead to /sys/kernel/fadump/mem_reserved node displaying an incorrect memory reserved by fadump.
To fix this problem, reserve dump area size variable is set to 0 if fadump failed to reserve memory.
--- arch/powerpc/kernel/fadump.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/fadump.c +1 -0
@@ -654,6 +654,7 @@ int __init fadump_reserve_mem(void)return ret; error_out: fw_dump.fadump_enabled =0 ; + fw_dump.reserve_dump_area_size =0 ;return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 366/600 powerpc/perf: Convert fsl_emb notifier to state machine callbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 34daf445f82bd3a4df852bb5f1dffd792ac830a0 ]
CC arch/powerpc/perf/core-fsl-emb.oarch/powerpc/perf/core-fsl-emb.c:675:6: error: no previous prototype for 'hw_perf_event_setup' [-Werror=missing-prototypes]
675 | void hw_perf_event_setup(int cpu)
| ^~~~~~~~~~~~~~~~~~~
Looks like fsl_emb was completely missed by commit 3f6da3905398 ("perf:
Rework and fix the arch CPU-hotplug hooks")
So, apply same changes as commit 3f6da3905398 ("perf: Rework and fix the arch CPU-hotplug hooks") then commit 57ecde42cc74 ("powerpc/perf:
Convert book3s notifier to state machine callbacks")
While at it, also fix following error:
arch/powerpc/perf/core-fsl-emb.c: In function 'perf_event_interrupt':arch/powerpc/perf/core-fsl-emb.c:648:13: error: variable 'found' set but not used [-Werror=unused-but-set-variable]
648 | int found = 0;
| ^~~~~--- arch/powerpc/perf/core-fsl-emb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/perf/core-fsl-emb.c +5 -3
@@ -645,7 +645,6 @@ static void perf_event_interrupt(struct pt_regs *regs)struct cpu_hw_events *cpuhw =this_cpu_ptr (&cpu_hw_events);struct perf_event *event;unsigned long val; -int found =0 ;for (i =0 ; i < ppmu->n_counter; ++i) { event = cpuhw->event[i];
@@ -654,7 +653,6 @@ static void perf_event_interrupt(struct pt_regs *regs)if ((int )val <0 ) {if (event) {/* event has overflowed */ - found =1 ;record_and_restart (event, val, regs); }else {/*
@@ -672,11 +670,13 @@ static void perf_event_interrupt(struct pt_regs *regs)isync (); } -void hw_perf_event_setup (int cpu) +static int fsl_emb_pmu_prepare_cpu (unsigned int cpu) {struct cpu_hw_events *cpuhw = &per_cpu (cpu_hw_events, cpu);memset (cpuhw,0 ,sizeof (*cpuhw)); + +return 0 ; }int register_fsl_emb_pmu (struct fsl_emb_pmu *pmu)
@@ -689,6 +689,8 @@ int register_fsl_emb_pmu(struct fsl_emb_pmu *pmu) pmu->name);perf_pmu_register (&fsl_emb_pmu,"cpu" ,PERF_TYPE_RAW ); +cpuhp_setup_state (CPUHP_PERF_POWER ,"perf/powerpc:prepare" , + fsl_emb_pmu_prepare_cpu,NULL );return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 367/600 drm/amdgpu: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit ce7d88110b9ed5f33fe79ea6d4ed049fb0e57bce ]
Don't assume that only the driver would be accessing LNKCTL. ASPM policy changes can trigger write to LNKCTL outside of driver's control. And in the case of upstream bridge, the driver does not even own the device it's changing the registers for.
Use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register value.
--- drivers/gpu/drm/amd/amdgpu/cik.c | 36 +++++++++----------------------- drivers/gpu/drm/amd/amdgpu/si.c | 36 +++++++++----------------------- 2 files changed, 20 insertions(+), 52 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik.c +10 -26
@@ -1574,17 +1574,8 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &bridge_cfg); -pcie_capability_read_word (adev->pdev,PCI_EXP_LNKCTL , - &gpu_cfg); - - tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); - - tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (adev->pdev,PCI_EXP_LNKCTL , - tmp16); +pcie_capability_set_word (root,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); +pcie_capability_set_word (adev->pdev,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); tmp =RREG32_PCIE (ixPCIE_LC_STATUS1); max_lw = (tmp & PCIE_LC_STATUS1__LC_DETECTED_LINK_WIDTH_MASK) >>
@@ -1637,21 +1628,14 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)msleep (100 );/* linkctl */ -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (root,PCI_EXP_LNKCTL , - tmp16); - -pcie_capability_read_word (adev->pdev, -PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (adev->pdev, -PCI_EXP_LNKCTL , - tmp16); +pcie_capability_clear_and_set_word (root,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + bridge_cfg & +PCI_EXP_LNKCTL_HAWD ); +pcie_capability_clear_and_set_word (adev->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + gpu_cfg & +PCI_EXP_LNKCTL_HAWD );/* linkctl2 */ pcie_capability_read_word(root, PCI_EXP_LNKCTL2,
drivers/gpu/drm/amd/amdgpu/si.c +10 -26
@@ -2276,17 +2276,8 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &bridge_cfg); -pcie_capability_read_word (adev->pdev,PCI_EXP_LNKCTL , - &gpu_cfg); - - tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); - - tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (adev->pdev,PCI_EXP_LNKCTL , - tmp16); +pcie_capability_set_word (root,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); +pcie_capability_set_word (adev->pdev,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); tmp =RREG32_PCIE (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;
@@ -2331,21 +2322,14 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)mdelay (100 ); -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (root,PCI_EXP_LNKCTL , - tmp16); - -pcie_capability_read_word (adev->pdev, -PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (adev->pdev, -PCI_EXP_LNKCTL , - tmp16); +pcie_capability_clear_and_set_word (root,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + bridge_cfg & +PCI_EXP_LNKCTL_HAWD ); +pcie_capability_clear_and_set_word (adev->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + gpu_cfg & +PCI_EXP_LNKCTL_HAWD );pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , &tmp16);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 368/600 drm/radeon: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 7189576e8a829130192b33c5b64e8a475369c776 ]
Don't assume that only the driver would be accessing LNKCTL. ASPM policy changes can trigger write to LNKCTL outside of driver's control. And in the case of upstream bridge, the driver does not even own the device it's changing the registers for.
Use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register value.
--- drivers/gpu/drm/radeon/cik.c | 36 ++++++++++------------------------- drivers/gpu/drm/radeon/si.c | 37 ++++++++++-------------------------- 2 files changed, 20 insertions(+), 53 deletions(-)
drivers/gpu/drm/radeon/cik.c +10 -26
@@ -9534,17 +9534,8 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &bridge_cfg); -pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL , - &gpu_cfg); - - tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); - - tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL , - tmp16); +pcie_capability_set_word (root,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); +pcie_capability_set_word (rdev->pdev,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); tmp =RREG32_PCIE_PORT (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;
@@ -9591,21 +9582,14 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)msleep (100 );/* linkctl */ -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (root,PCI_EXP_LNKCTL , - tmp16); - -pcie_capability_read_word (rdev->pdev, -PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (rdev->pdev, -PCI_EXP_LNKCTL , - tmp16); +pcie_capability_clear_and_set_word (root,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + bridge_cfg & +PCI_EXP_LNKCTL_HAWD ); +pcie_capability_clear_and_set_word (rdev->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + gpu_cfg & +PCI_EXP_LNKCTL_HAWD );/* linkctl2 */ pcie_capability_read_word(root, PCI_EXP_LNKCTL2,
drivers/gpu/drm/radeon/si.c +10 -27
@@ -7131,17 +7131,8 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &bridge_cfg); -pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL , - &gpu_cfg); - - tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); - - tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL , - tmp16); +pcie_capability_set_word (root,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); +pcie_capability_set_word (rdev->pdev,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_HAWD ); tmp =RREG32_PCIE (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;
@@ -7188,22 +7179,14 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)msleep (100 );/* linkctl */ -pcie_capability_read_word (root,PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (root, -PCI_EXP_LNKCTL , - tmp16); - -pcie_capability_read_word (rdev->pdev, -PCI_EXP_LNKCTL , - &tmp16); - tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; - tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pcie_capability_write_word (rdev->pdev, -PCI_EXP_LNKCTL , - tmp16); +pcie_capability_clear_and_set_word (root,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + bridge_cfg & +PCI_EXP_LNKCTL_HAWD ); +pcie_capability_clear_and_set_word (rdev->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_HAWD , + gpu_cfg & +PCI_EXP_LNKCTL_HAWD );/* linkctl2 */ pcie_capability_read_word(root, PCI_EXP_LNKCTL2,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 369/600 net/mlx5: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 30de872537bda526664d7a20b646adfb3e7ce6e6 ]
Don't assume that only the driver would be accessing LNKCTL of the upstream bridge. ASPM policy changes can trigger write to LNKCTL outside of driver's control.
Use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register value.
--- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +2 -7
@@ -319,16 +319,11 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev)pci_cfg_access_lock (sdev); }/* PCI link toggle */ - err =pci_read_config_word (bridge, cap +PCI_EXP_LNKCTL , ®16); -if (err) -return err; - reg16 |=PCI_EXP_LNKCTL_LD ; - err =pci_write_config_word (bridge, cap +PCI_EXP_LNKCTL , reg16); + err =pcie_capability_set_word (bridge,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_LD );if (err)return err;msleep (500 ); - reg16 &= ~PCI_EXP_LNKCTL_LD ; - err =pci_write_config_word (bridge, cap +PCI_EXP_LNKCTL , reg16); + err =pcie_capability_clear_word (bridge,PCI_EXP_LNKCTL ,PCI_EXP_LNKCTL_LD );if (err)return err;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 370/600 wifi: ath11k: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 6c1b6bdb34aaf8f94f65a9cae1d63490320c11bc ]
Don't assume that only the driver would be accessing LNKCTL. ASPM policy changes can trigger write to LNKCTL outside of driver's control.
Use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register value. On restore, clear the ASPMC field properly.
--- drivers/net/wireless/ath/ath11k/pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath11k/pci.c +6 -4
@@ -582,8 +582,8 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1));/* disable L0s and L1 */ -pcie_capability_write_word (ab_pci->pdev,PCI_EXP_LNKCTL , - ab_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC ); +pcie_capability_clear_word (ab_pci->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC );set_bit (ATH11K_PCI_ASPM_RESTORE , &ab_pci->flags); }
@@ -591,8 +591,10 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci)static void ath11k_pci_aspm_restore (struct ath11k_pci *ab_pci) {if (test_and_clear_bit (ATH11K_PCI_ASPM_RESTORE , &ab_pci->flags)) -pcie_capability_write_word (ab_pci->pdev,PCI_EXP_LNKCTL , - ab_pci->link_ctl); +pcie_capability_clear_and_set_word (ab_pci->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC , + ab_pci->link_ctl & +PCI_EXP_LNKCTL_ASPMC ); }static int ath11k_pci_power_up (struct ath11k_base *ab)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 371/600 wifi: ath10k: Use RMW accessors for changing LNKCTL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit f139492a09f15254fa261245cdbd65555cdf39e3 ]
Don't assume that only the driver would be accessing LNKCTL. ASPM policy changes can trigger write to LNKCTL outside of driver's control.
Use RMW capability accessors which does proper locking to avoid losing concurrent updates to the register value. On restore, clear the ASPMC field properly.
--- drivers/net/wireless/ath/ath10k/pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +5 -4
@@ -1963,8 +1963,9 @@ static int ath10k_pci_hif_start(struct ath10k *ar)ath10k_pci_irq_enable (ar);ath10k_pci_rx_post (ar); -pcie_capability_write_word (ar_pci->pdev,PCI_EXP_LNKCTL , - ar_pci->link_ctl); +pcie_capability_clear_and_set_word (ar_pci->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC , + ar_pci->link_ctl &PCI_EXP_LNKCTL_ASPMC );return 0 ; }
@@ -2821,8 +2822,8 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar,pcie_capability_read_word (ar_pci->pdev,PCI_EXP_LNKCTL , &ar_pci->link_ctl); -pcie_capability_write_word (ar_pci->pdev,PCI_EXP_LNKCTL , - ar_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC ); +pcie_capability_clear_word (ar_pci->pdev,PCI_EXP_LNKCTL , +PCI_EXP_LNKCTL_ASPMC );/* * Bring the target up cleanly.
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 372/600 NFSv4.2: Rework scratch handling for READ_PLUS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit fbd2a05f29a95d5b42b294bf47e55a711424965b ]
Instead of using a tiny, static scratch buffer, we should use a kmalloc()-ed buffer that is allocated when checking for read plus usage. This lets us use the buffer before decoding any part of the READ_PLUS operation instead of setting it right before segment decoding, meaning it should be a little more robust.
Stable-dep-of: bb05a617f06b ("NFSv4.2: Fix READ_PLUS smatch warnings")
--- fs/nfs/nfs42xdr.c | 4 ++-- fs/nfs/nfs4proc.c | 17 ++++++++++++----- include/linux/nfs_xdr.h | 1 + 3 files changed, 15 insertions(+), 7 deletions(-)
fs/nfs/nfs42xdr.c +2 -2
@@ -1121,7 +1121,6 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)uint32_t segments;struct read_plus_segment *segs;int status, i; -char scratch_buf[16 ];__be32 *p; status =decode_op_hdr (xdr,OP_READ_PLUS );
@@ -1142,7 +1141,6 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)if (!segs)return -ENOMEM ; -xdr_set_scratch_buffer (xdr, &scratch_buf,sizeof (scratch_buf)); status = -EIO ;for (i =0 ; i < segments; i++) { status =decode_read_plus_segment (xdr, &segs[i]);
@@ -1347,6 +1345,8 @@ static int nfs4_xdr_dec_read_plus(struct rpc_rqst *rqstp,struct compound_hdr hdr;int status; +xdr_set_scratch_buffer (xdr, res->scratch,sizeof (res->scratch)); + status =decode_compound_hdr (xdr, &hdr);if (status) goto out;
fs/nfs/nfs4proc.c +12 -5
@@ -5446,6 +5446,8 @@ static bool nfs4_read_plus_not_supported(struct rpc_task *task,static int nfs4_read_done (struct rpc_task *task,struct nfs_pgio_header *hdr) { +if (hdr->res.scratch) +kfree (hdr->res.scratch);if (!nfs4_sequence_done (task, &hdr->res.seq_res))return -EAGAIN ;if (nfs4_read_stateid_changed (task, &hdr->args))
@@ -5459,17 +5461,22 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) }#if definedCONFIG_NFS_V4_2 && definedCONFIG_NFS_V4_2_READ_PLUS -static void nfs42_read_plus_support (struct nfs_pgio_header *hdr, +static bool nfs42_read_plus_support (struct nfs_pgio_header *hdr,struct rpc_message *msg) {/* Note: We don't use READ_PLUS with pNFS yet */ -if (nfs_server_capable (hdr->inode,NFS_CAP_READ_PLUS ) && !hdr->ds_clp) +if (nfs_server_capable (hdr->inode,NFS_CAP_READ_PLUS ) && !hdr->ds_clp) { msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS ]; + hdr->res.scratch =kmalloc (32 ,GFP_KERNEL ); +return hdr->res.scratch !=NULL ; + } +return false; }#else -static void nfs42_read_plus_support (struct nfs_pgio_header *hdr, +static bool nfs42_read_plus_support (struct nfs_pgio_header *hdr,struct rpc_message *msg) { +return false; }#endif /* CONFIG_NFS_V4_2 */
@@ -5479,8 +5486,8 @@ static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr, hdr->timestamp = jiffies;if (!hdr->pgio_done_cb) hdr->pgio_done_cb = nfs4_read_done_cb; - msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ ]; -nfs42_read_plus_support (hdr, msg); +if (!nfs42_read_plus_support (hdr, msg)) + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ ];nfs4_init_sequence (&hdr->args.seq_args, &hdr->res.seq_res,0 ,0 ); }
include/linux/nfs_xdr.h +1 -0
@@ -670,6 +670,7 @@ struct nfs_pgio_res {struct {unsigned int replen;/* used by read */ int eof;/* used by read */ +void * scratch;/* used by read */ };struct {struct nfs_writeverf * verf;/* used by write */
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 373/600 NFSv4.2: Fix READ_PLUS smatch warnings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit bb05a617f06b7a882e19c4f475b8e37f14d9ceac ]
Smatch reports:
fs/nfs/nfs42xdr.c:1131 decode_read_plus() warn: missing error code? 'status'
Which Dan suggests to fix by doing a hardcoded "return 0" from the "if (segments == 0)" check.
Additionally, smatch reports that the "status = -EIO" assignment is not used. This patch addresses both these issues.
--- fs/nfs/nfs42xdr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/nfs42xdr.c +1 -2
@@ -1135,13 +1135,12 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) res->eof =be32_to_cpup (p++); segments =be32_to_cpup (p++);if (segments ==0 ) -return status; +return 0 ; segs =kmalloc_array (segments,sizeof (*segs),GFP_KERNEL );if (!segs)return -ENOMEM ; - status = -EIO ;for (i =0 ; i < segments; i++) { status =decode_read_plus_segment (xdr, &segs[i]);if (status <0 )
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 374/600 NFSv4.2: Fix up READ_PLUS alignment
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit f8527028a7e52da884055c401abc04e0b0c84285 ]
Assume that the first segment will be a DATA segment, and place the data directly into the xdr pages so it doesn't need to be shifted.
Stable-dep-of: 8d18f6c5bb86 ("NFSv4.2: Fix READ_PLUS size calculations")
--- fs/nfs/nfs42xdr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/nfs/nfs42xdr.c +4 -3
@@ -47,13 +47,14 @@#define decode_deallocate_maxsz (op_decode_hdr_maxsz)#define encode_read_plus_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + 3) -#define NFS42_READ_PLUS_SEGMENT_SIZE (1 /* data_content4 */ + \ +#define NFS42_READ_PLUS_DATA_SEGMENT_SIZE \ + (1 /* data_content4 */ + \ 2 /* data_info4.di_offset */ + \ - 2 /* data_info4.di_length */) + 1 /* data_info4.di_length */) #define decode_read_plus_maxsz (op_decode_hdr_maxsz + \ 1 /* rpr_eof */ + \ 1 /* rpr_contents count */ + \ - 2 * NFS42_READ_PLUS_SEGMENT_SIZE) + NFS42_READ_PLUS_DATA_SEGMENT_SIZE) #define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 375/600 NFSv4.2: Fix READ_PLUS size calculations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit 8d18f6c5bb864d97a730f471c56cdecf313efe64 ]
I bump the decode_read_plus_maxsz to account for hole segments, but I need to subtract out this increase when calling rpc_prepare_reply_pages() so the common case of single data segment replies can be directly placed into the xdr pages without needing to be shifted around.
--- fs/nfs/nfs42xdr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/nfs/nfs42xdr.c +9 -3
@@ -51,10 +51,16 @@ (1 /* data_content4 */ + \ 2 /* data_info4.di_offset */ + \ 1 /* data_info4.di_length */) +#define NFS42_READ_PLUS_HOLE_SEGMENT_SIZE \ + (1 /* data_content4 */ + \ + 2 /* data_info4.di_offset */ + \ + 2 /* data_info4.di_length */) +#define READ_PLUS_SEGMENT_SIZE_DIFF (NFS42_READ_PLUS_HOLE_SEGMENT_SIZE - \ + NFS42_READ_PLUS_DATA_SEGMENT_SIZE)#define decode_read_plus_maxsz (op_decode_hdr_maxsz + \ 1 /* rpr_eof */ + \ 1 /* rpr_contents count */ + \ - NFS42_READ_PLUS_DATA_SEGMENT_SIZE) + NFS42_READ_PLUS_HOLE_SEGMENT_SIZE) #define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \
@@ -781,8 +787,8 @@ static void nfs4_xdr_enc_read_plus(struct rpc_rqst *req,encode_putfh (xdr, args->fh, &hdr);encode_read_plus (xdr, args, &hdr); -rpc_prepare_reply_pages (req, args->pages, args->pgbase, - args->count, hdr.replen); +rpc_prepare_reply_pages (req, args->pages, args->pgbase, args->count, + hdr.replen -READ_PLUS_SEGMENT_SIZE_DIFF );encode_nops (&hdr); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 376/600 powerpc: Dont include lppaca.h in paca.h
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit 1aa000667669fa855853decbb1c69e974d8ff716 ]
By adding a forward declaration for struct lppaca we can untangle paca.h and lppaca.h. Also move get_lppaca() into lppaca.h for consistency.
Add includes of lppaca.h to some files that need it.
Stable-dep-of: eac030b22ea1 ("powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT")
--- arch/powerpc/include/asm/lppaca.h | 4 ++++ arch/powerpc/include/asm/paca.h | 6 +----- arch/powerpc/include/asm/paravirt.h | 1 + arch/powerpc/include/asm/plpar_wrappers.h | 1 + arch/powerpc/kvm/book3s_hv_ras.c | 1 + arch/powerpc/mm/book3s64/slb.c | 1 + arch/powerpc/xmon/xmon.c | 1 + 7 files changed, 10 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/lppaca.h +4 -0
@@ -134,6 +134,10 @@ static inline bool lppaca_shared_proc(struct lppaca *l)return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); } +#ifdef CONFIG_PPC_PSERIES +#define get_lppaca () (get_paca()->lppaca_ptr) +#endif +/* * SLB shadow buffer structure as defined in the PAPR. The save_area * contains adjacent ESID and VSID pairs for each shadowed SLB. The
arch/powerpc/include/asm/paca.h +1 -5
@@ -15,7 +15,6 @@#include <linux/cache.h> #include <linux/string.h> #include <asm/types.h> -#include <asm/lppaca.h> #include <asm/mmu.h> #include <asm/page.h> #ifdef CONFIG_PPC_BOOK3E_64
@@ -47,14 +46,11 @@ extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */#define get_paca () local_paca#endif -#ifdef CONFIG_PPC_PSERIES -#define get_lppaca () (get_paca()->lppaca_ptr) -#endif -#define get_slb_shadow () (get_paca()->slb_shadow_ptr)struct task_struct ;struct rtas_args ; +struct lppaca ;/* * Defines the layout of the paca.
arch/powerpc/include/asm/paravirt.h +1 -0
@@ -6,6 +6,7 @@#include <asm/smp.h> #ifdef CONFIG_PPC64 #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/hvcall.h> #endif
arch/powerpc/include/asm/plpar_wrappers.h +1 -0
@@ -9,6 +9,7 @@#include <asm/hvcall.h> #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/page.h> static inline long poll_pending (void )
arch/powerpc/kvm/book3s_hv_ras.c +1 -0
@@ -9,6 +9,7 @@#include <linux/kvm.h> #include <linux/kvm_host.h> #include <linux/kernel.h> +#include <asm/lppaca.h> #include <asm/opal.h> #include <asm/mce.h> #include <asm/machdep.h>
arch/powerpc/mm/book3s64/slb.c +1 -0
@@ -13,6 +13,7 @@#include <asm/mmu.h> #include <asm/mmu_context.h> #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/ppc-opcode.h> #include <asm/cputable.h> #include <asm/cacheflush.h>
arch/powerpc/xmon/xmon.c +1 -0
@@ -58,6 +58,7 @@#ifdef CONFIG_PPC64 #include <asm/hvcall.h> #include <asm/paca.h> +#include <asm/lppaca.h> #endif #include "nonstdio.h"
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 377/600 powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell Currey <[email protected]>
[ Upstream commit eac030b22ea12cdfcbb2e941c21c03964403c63f ]
lppaca_shared_proc() takes a pointer to the lppaca which is typically accessed through get_lppaca(). With DEBUG_PREEMPT enabled, this leads to checking if preemption is enabled, for example:
BUG: using smp_processor_id() in preemptible [00000000] code: grep/10693
caller is lparcfg_data+0x408/0x19a0
CPU: 4 PID: 10693 Comm: grep Not tainted 6.5.0-rc3 #2
Call Trace:
dump_stack_lvl+0x154/0x200 (unreliable)
check_preemption_disabled+0x214/0x220
lparcfg_data+0x408/0x19a0
...This isn't actually a problem however, as it does not matter which lppaca is accessed, the shared proc state will be the same. vcpudispatch_stats_procfs_init() already works around this by disabling preemption, but the lparcfg code does not, erroring any time /proc/powerpc/lparcfg is accessed with DEBUG_PREEMPT enabled.
Instead of disabling preemption on the caller side, rework lppaca_shared_proc() to not take a pointer and instead directly access the lppaca, bypassing any potential preemption checks.
--- arch/powerpc/include/asm/lppaca.h | 11 +++++++++-- arch/powerpc/platforms/pseries/lpar.c | 10 +--------- arch/powerpc/platforms/pseries/lparcfg.c | 4 ++-- arch/powerpc/platforms/pseries/setup.c | 2 +- drivers/cpuidle/cpuidle-pseries.c | 8 +------- 5 files changed, 14 insertions(+), 21 deletions(-)
arch/powerpc/include/asm/lppaca.h +9 -2
@@ -45,6 +45,7 @@#include <asm/types.h> #include <asm/mmu.h> #include <asm/firmware.h> +#include <asm/paca.h> /* * The lppaca is the "virtual processor area" registered with the hypervisor,
@@ -127,14 +128,20 @@ struct lppaca {*/ #define LPPACA_OLD_SHARED_PROC 2 -static inline bool lppaca_shared_proc (struct lppaca *l) +#ifdef CONFIG_PPC_PSERIES +/* +* All CPUs should have the same shared proc value, so directly access the PACA +* to avoid false positives from DEBUG_PREEMPT. +*/ +static inline bool lppaca_shared_proc (void ) { +struct lppaca *l = local_paca->lppaca_ptr; +if (!firmware_has_feature (FW_FEATURE_SPLPAR ))return false;return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); } -#ifdef CONFIG_PPC_PSERIES #define get_lppaca () (get_paca()->lppaca_ptr)#endif
arch/powerpc/platforms/pseries/lpar.c +1 -9
@@ -638,16 +638,8 @@ static const struct proc_ops vcpudispatch_stats_freq_proc_ops = {static int __init vcpudispatch_stats_procfs_init (void ) { -/* -* Avoid smp_processor_id while preemptible. All CPUs should have -* the same value for lppaca_shared_proc. -*/ -preempt_disable (); -if (!lppaca_shared_proc (get_lppaca ())) { -preempt_enable (); +if (!lppaca_shared_proc ())return 0 ; - } -preempt_enable ();if (!proc_create ("powerpc/vcpudispatch_stats" ,0600 ,NULL , &vcpudispatch_stats_proc_ops))
arch/powerpc/platforms/pseries/lparcfg.c +2 -2
@@ -205,7 +205,7 @@ static void parse_ppp_data(struct seq_file *m) ppp_data.active_system_procs);/* pool related entries are appropriate for shared configs */ -if (lppaca_shared_proc (get_lppaca ())) { +if (lppaca_shared_proc ()) {unsigned long pool_idle_time, pool_procs;seq_printf (m,"pool=%d\n" , ppp_data.pool_num);
@@ -616,7 +616,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) partition_potential_processors);seq_printf (m,"shared_processor_mode=%d\n" , -lppaca_shared_proc (get_lppaca ())); +lppaca_shared_proc ());#ifdef CONFIG_PPC_64S_HASH_MMU if (!radix_enabled ())
arch/powerpc/platforms/pseries/setup.c +1 -1
@@ -846,7 +846,7 @@ static void __init pSeries_setup_arch(void)if (firmware_has_feature (FW_FEATURE_LPAR )) {vpa_init (boot_cpuid); -if (lppaca_shared_proc (get_lppaca ())) { +if (lppaca_shared_proc ()) {static_branch_enable (&shared_processor);pv_spinlocks_init ();#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
drivers/cpuidle/cpuidle-pseries.c +1 -7
@@ -410,13 +410,7 @@ static int __init pseries_idle_probe(void)return -ENODEV ;if (firmware_has_feature (FW_FEATURE_SPLPAR )) { -/* -* Use local_paca instead of get_lppaca() since -* preemption is not disabled, and it is not required in -* fact, since lppaca_ptr does not need to be the value -* associated to the current CPU, it can be from any CPU. -*/ -if (lppaca_shared_proc (local_paca->lppaca_ptr)) { +if (lppaca_shared_proc ()) { cpuidle_state_table = shared_states; max_idle_state =ARRAY_SIZE (shared_states); }else {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 378/600 nfs/blocklayout: Use the passed in gfp flags
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 08b45fcb2d4675f6182fe0edc0d8b1fe604051fa ]
This allocation should use the passed in GFP_ flags instead of GFP_KERNEL. One places where this matters is in filelayout_pg_init_write() which uses GFP_NOFS as the allocation flags.
--- fs/nfs/blocklayout/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/dev.c +2 -2
@@ -402,7 +402,7 @@ bl_parse_concat(struct nfs_server *server, struct pnfs_block_dev *d,int ret, i; d->children =kcalloc (v->concat.volumes_count, -sizeof (struct pnfs_block_dev ),GFP_KERNEL ); +sizeof (struct pnfs_block_dev ), gfp_mask);if (!d->children)return -ENOMEM ;
@@ -431,7 +431,7 @@ bl_parse_stripe(struct nfs_server *server, struct pnfs_block_dev *d,int ret, i; d->children =kcalloc (v->stripe.volumes_count, -sizeof (struct pnfs_block_dev ),GFP_KERNEL ); +sizeof (struct pnfs_block_dev ), gfp_mask);if (!d->children)return -ENOMEM ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 379/600 powerpc/pseries: Fix hcall tracepoints with JUMP_LABEL=n
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
[ Upstream commit 750bd41aeaeb1f0e0128aa4f8fcd6dd759713641 ]
With JUMP_LABEL=n, hcall_tracepoint_refcount's address is being tested instead of its value. This results in the tracing slowpath always being taken unnecessarily.
--- arch/powerpc/platforms/pseries/hvCall.S | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/pseries/hvCall.S +1 -0
@@ -89,6 +89,7 @@ BEGIN_FTR_SECTION; \ b 1f; \ END_FTR_SECTION(0, 1); \ LOAD_REG_ADDR(r12, hcall_tracepoint_refcount) ; \ + ld r12,0(r12); \ std r12,32(r1); \ cmpdi r12,0; \ bne- LABEL; \
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 380/600 powerpc/mpc5xxx: Add missing fwnode_handle_put()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang He <[email protected]>
[ Upstream commit b9bbbf4979073d5536b7650decd37fcb901e6556 ]
In mpc5xxx_fwnode_get_bus_frequency(), we should add fwnode_handle_put() when break out of the iteration fwnode_for_each_parent_node() as it will automatically increase and decrease the refcounter.
--- arch/powerpc/sysdev/mpc5xxx_clocks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/mpc5xxx_clocks.c +3 -1
@@ -25,8 +25,10 @@ unsigned long mpc5xxx_fwnode_get_bus_frequency(struct fwnode_handle *fwnode)fwnode_for_each_parent_node (fwnode, parent) { ret =fwnode_property_read_u32 (parent,"bus-frequency" , &bus_freq); -if (!ret) +if (!ret) { +fwnode_handle_put (parent);return bus_freq; + } }return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 381/600 powerpc/iommu: Fix notifiers being shared by PCI and VIO buses
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell Currey <[email protected]>
[ Upstream commit c37b6908f7b2bd24dcaaf14a180e28c9132b9c58 ]
fail_iommu_setup() registers the fail_iommu_bus_notifier struct to both PCI and VIO buses. struct notifier_block is a linked list node, so this causes any notifiers later registered to either bus type to also be registered to the other since they share the same node.
This causes issues in (at least) the vgaarb code, which registers a notifier for PCI buses. pci_notify() ends up being called on a vio device, converted with to_pci_dev() even though it's not a PCI device, and finally makes a bad access in vga_arbiter_add_pci_device() as discovered with KASAN:
BUG: KASAN: slab-out-of-bounds in vga_arbiter_add_pci_device+0x60/0xe00 Read of size 4 at addr c000000264c26fdc by task swapper/0/1 Call Trace: dump_stack_lvl+0x1bc/0x2b8 (unreliable) print_report+0x3f4/0xc60 kasan_report+0x244/0x698 __asan_load4+0xe8/0x250 vga_arbiter_add_pci_device+0x60/0xe00 pci_notify+0x88/0x444 notifier_call_chain+0x104/0x320 blocking_notifier_call_chain+0xa0/0x140 device_add+0xac8/0x1d30 device_register+0x58/0x80 vio_register_device_node+0x9ac/0xce0 vio_bus_scan_register_devices+0xc4/0x13c __machine_initcall_pseries_vio_device_init+0x94/0xf0 do_one_initcall+0x12c/0xaa8 kernel_init_freeable+0xa48/0xba8 kernel_init+0x64/0x400 ret_from_kernel_thread+0x5c/0x64
Fix this by creating separate notifier_block structs for each bus type.
--- arch/powerpc/kernel/iommu.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/powerpc/kernel/iommu.c +14 -3
@@ -171,17 +171,28 @@ static int fail_iommu_bus_notify(struct notifier_block *nb,return 0 ; } -static struct notifier_block fail_iommu_bus_notifier = { +/* +* PCI and VIO buses need separate notifier_block structs, since they're linked +* list nodes. Sharing a notifier_block would mean that any notifiers later +* registered for PCI buses would also get called by VIO buses and vice versa. +*/ +static struct notifier_block fail_iommu_pci_bus_notifier = { .notifier_call = fail_iommu_bus_notify }; +#ifdef CONFIG_IBMVIO +static struct notifier_block fail_iommu_vio_bus_notifier = { + .notifier_call = fail_iommu_bus_notify +}; +#endif +static int __init fail_iommu_setup (void ) {#ifdef CONFIG_PCI -bus_register_notifier (&pci_bus_type, &fail_iommu_bus_notifier); +bus_register_notifier (&pci_bus_type, &fail_iommu_pci_bus_notifier);#endif #ifdef CONFIG_IBMVIO -bus_register_notifier (&vio_bus_type, &fail_iommu_bus_notifier); +bus_register_notifier (&vio_bus_type, &fail_iommu_vio_bus_notifier);#endif return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 382/600 ext4: fix unttached inode after power cut with orphan file feature enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 1524773425ae8113b0b782886366e68656b34e53 ]
Running generic/475(filesystem consistent tests after power cut) could easily trigger unattached inode error while doing fsck:
Unattached zero-length inode 39405. Clear? no
Unattached inode 39405
Connect to /lost+found? no
Above inconsistence is caused by following process:
P1 P2ext4_create
inode = ext4_new_inode_start_handle // itable records nlink=1 ext4_add_nondir
err = ext4_add_entry // ENOSPC
ext4_append
ext4_bread
ext4_getblk
ext4_map_blocks // returns ENOSPC
drop_nlink(inode) // won't be updated into disk inode ext4_orphan_add(handle, inode)
ext4_orphan_file_add
ext4_journal_stop(handle)
jbd2_journal_commit_transaction // commit success
>> power cut <<ext4_fill_super
ext4_load_and_init_journal // itable records nlink=1
ext4_orphan_cleanup
ext4_process_orphan
if (inode->i_nlink) // true, inode won't be deleted
Then, allocated inode will be reserved on disk and corresponds to no dentries, so e2fsck reports 'unattached inode' problem.
The problem won't happen if orphan file feature is disabled, because ext4_orphan_add() will update disk inode in orphan list mode. There are several places not updating disk inode while putting inode into orphan area, such as ext4_add_nondir(), ext4_symlink() and whiteout in ext4_rename(). Fix it by updating inode into disk in all error branches of these places.
--- fs/ext4/namei.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ext4/namei.c +3 -0
@@ -2799,6 +2799,7 @@ static int ext4_add_nondir(handle_t *handle,return err; }drop_nlink (inode); +ext4_mark_inode_dirty (handle, inode);ext4_orphan_add (handle, inode);unlock_new_inode (inode);return err;
@@ -3436,6 +3437,7 @@ static int ext4_symlink(struct user_namespace *mnt_userns, struct inode *dir, err_drop_inode:clear_nlink (inode); +ext4_mark_inode_dirty (handle, inode);ext4_orphan_add (handle, inode);unlock_new_inode (inode);if (handle)
@@ -4021,6 +4023,7 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,ext4_resetent (handle, &old, old.inode->i_ino, old_file_type);drop_nlink (whiteout); +ext4_mark_inode_dirty (handle, whiteout);ext4_orphan_add (handle, whiteout); }unlock_new_inode (whiteout);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 383/600 jfs: validate max amount of blocks before allocation.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Filippov <[email protected]>
[ Upstream commit 0225e10972fa809728b8d4c1bd2772b3ec3fdb57 ]
The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.
--- fs/jfs/jfs_extent.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)* blocks in the map. in that case, we'll start off with the * maximum free. */ + +/* give up if no space left */ +if (bmp->db_maxfreebud ==-1 ) +return -ENOSPC ; + max = (s64 )1 << bmp->db_maxfreebud;if (*nblocks >= max && *nblocks > nbperpage) nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 384/600 fs: lockd: avoid possible wrong NULL parameter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit de8d38cf44bac43e83bad28357ba84784c412752 ]
clang's static analysis warning: fs/lockd/mon.c: line 293, column 2:
Null pointer passed as 2nd argument to memory copy function.
Assuming 'hostname' is NULL and calling 'nsm_create_handle()', this will pass NULL as 2nd argument to memory copy function 'memcpy()'. So return NULL if 'hostname' is invalid.
--- fs/lockd/mon.c | 3 +++ 1 file changed, 3 insertions(+)
fs/lockd/mon.c +3 -0
@@ -276,6 +276,9 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap, {struct nsm_handle *new; +if (!hostname) +return NULL ; + new =kzalloc (sizeof (*new) + hostname_len +1 ,GFP_KERNEL );if (unlikely (new ==NULL ))return NULL ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 385/600 NFSD: da_addr_body field missing in some GETDEVICEINFO replies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6372e2ee629894433fe6107d7048536a3280a284 ]
The XDR specification in RFC 8881 looks like this:
struct device_addr4 {
layouttype4 da_layout_type;
opaque da_addr_body<>;
};struct GETDEVICEINFO4resok {
device_addr4 gdir_device_addr;
bitmap4 gdir_notification;
};union GETDEVICEINFO4res switch (nfsstat4 gdir_status) { case NFS4_OK:
GETDEVICEINFO4resok gdir_resok4; case NFS4ERR_TOOSMALL: count4 gdir_mincount; default: void; };
Looking at nfsd4_encode_getdeviceinfo() ....
When the client provides a zero gd_maxcount, then the Linux NFS server implementation encodes the da_layout_type field and then skips the da_addr_body field completely, proceeding directly to encode gdir_notification field.
There does not appear to be an option in the specification to skip encoding da_addr_body. Moreover, Section 18.40.3 says:
Quoted 4 lines
If the client wants to just update or turn off notifications, it MAY send a GETDEVICEINFO operation with
gdia_maxcountset to zero. In that event, if the device ID is valid, the reply'sda_addr_bodyfield of thegdir_device_addrfield will be of zero length.
Since the layout drivers are responsible for encoding the da_addr_body field, put this fix inside the ->encode_getdeviceinfo methods.
--- fs/nfsd/blocklayoutxdr.c | 9 +++++++++ fs/nfsd/flexfilelayoutxdr.c | 9 +++++++++ fs/nfsd/nfs4xdr.c | 25 +++++++++++-------------- 3 files changed, 29 insertions(+), 14 deletions(-)
fs/nfsd/blocklayoutxdr.c +9 -0
@@ -82,6 +82,15 @@ nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr,int len =sizeof (__be32), ret, i;__be32 *p; +/* +* See paragraph 5 of RFC 8881 S18.40.3. +*/ +if (!gdp->gd_maxcount) { +if (xdr_stream_encode_u32 (xdr,0 ) !=XDR_UNIT ) +return nfserr_resource; +return nfs_ok; + } + p =xdr_reserve_space (xdr, len +sizeof (__be32));if (!p)return nfserr_resource;
fs/nfsd/flexfilelayoutxdr.c +9 -0
@@ -85,6 +85,15 @@ nfsd4_ff_encode_getdeviceinfo(struct xdr_stream *xdr,int addr_len;__be32 *p; +/* +* See paragraph 5 of RFC 8881 S18.40.3. +*/ +if (!gdp->gd_maxcount) { +if (xdr_stream_encode_u32 (xdr,0 ) !=XDR_UNIT ) +return nfserr_resource; +return nfs_ok; + } +/* len + padding for two strings */ addr_len =16 + da->netaddr.netid_len + da->netaddr.addr_len; ver_len =20 ;
fs/nfsd/nfs4xdr.c +11 -14
@@ -4571,20 +4571,17 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, *p++ =cpu_to_be32 (gdev->gd_layout_type); -/* If maxcount is 0 then just update notifications */ -if (gdev->gd_maxcount !=0 ) { - ops = nfsd4_layout_ops[gdev->gd_layout_type]; - nfserr = ops->encode_getdeviceinfo (xdr, gdev); -if (nfserr) { -/* -* We don't bother to burden the layout drivers with -* enforcing gd_maxcount, just tell the client to -* come back with a bigger buffer if it's not enough. -*/ -if (xdr->buf->len +4 > gdev->gd_maxcount) - goto toosmall; -return nfserr; - } + ops = nfsd4_layout_ops[gdev->gd_layout_type]; + nfserr = ops->encode_getdeviceinfo (xdr, gdev); +if (nfserr) { +/* +* We don't bother to burden the layout drivers with +* enforcing gd_maxcount, just tell the client to +* come back with a bigger buffer if it's not enough. +*/ +if (xdr->buf->len +4 > gdev->gd_maxcount) + goto toosmall; +return nfserr; }if (gdev->gd_notify_types) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 386/600 NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit f67b55b6588bcf9316a1e6e8d529100a5aa3ebe6 ]
Commit 64cfca85bacd asserts the only valid return values for nfs2/3_decode_dirent should not include -ENAMETOOLONG, but for a server that sends a filename3 which exceeds MAXNAMELEN in a READDIR response the client's behavior will be to endlessly retry the operation.
We could map -ENAMETOOLONG into -EBADCOOKIE, but that would produce truncated listings without any error. The client should return an error for this case to clearly assert that the server implementation must be corrected.
--- fs/nfs/nfs2xdr.c | 2 +- fs/nfs/nfs3xdr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs2xdr.c +1 -1
@@ -949,7 +949,7 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, error =decode_filename_inline (xdr, &entry->name, &entry->len);if (unlikely (error)) -return -EAGAIN ; +return error == -ENAMETOOLONG ? -ENAMETOOLONG : -EAGAIN ;/* * The type (size and byte order) of nfscookie isn't defined in
fs/nfs/nfs3xdr.c +1 -1
@@ -1991,7 +1991,7 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, error =decode_inline_filename3 (xdr, &entry->name, &entry->len);if (unlikely (error)) -return -EAGAIN ; +return error == -ENAMETOOLONG ? -ENAMETOOLONG : -EAGAIN ; error =decode_cookie3 (xdr, &new_cookie);if (unlikely (error))
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 387/600 NFSv4.2: fix handling of COPY ERR_OFFLOAD_NO_REQ
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <[email protected]>
[ Upstream commit 5690eed941ab7e33c3c3d6b850100cabf740f075 ]
If the client sent a synchronous copy and the server replied with ERR_OFFLOAD_NO_REQ indicating that it wants an asynchronous copy instead, the client should retry with asynchronous copy.
--- fs/nfs/nfs42proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/nfs42proc.c +3 -2
@@ -470,8 +470,9 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,continue ; }break ; - }else if (err == -NFS4ERR_OFFLOAD_NO_REQS && !args.sync) { - args.sync = true; + }else if (err == -NFS4ERR_OFFLOAD_NO_REQS && + args.sync != res.synchronous) { + args.sync = res.synchronous; dst_exception.retry =1 ;continue ; } else if ((err == -ESTALE ||
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 388/600 pNFS: Fix assignment of xprtdata.cred
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit c4a123d2e8c4dc91d581ee7d05c0cd51a0273fab ]
The comma at the end of the line was leftover from an earlier refactor of the _nfs4_pnfs_v3_ds_connect() function. This is technically valid C, so the compilers didn't catch it, but if I'm understanding how it works correctly it assigns the return value of rpc_clnt_add_xprtr() to xprtdata.cred.
--- fs/nfs/pnfs_nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/pnfs_nfs.c +1 -1
@@ -943,7 +943,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,* Test this address for session trunking and * add as an alias */ - xprtdata.cred =nfs4_get_clid_cred (clp), + xprtdata.cred =nfs4_get_clid_cred (clp);rpc_clnt_add_xprt (clp->cl_rpcclient, &xprt_args, rpc_clnt_setup_test_and_add_xprt, &rpcdata);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 389/600 cgroup/cpuset: Inherit parents load balance state in v2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit c8c926200c55454101f072a4b16c9ff5b8c9e56f ]
Since commit f28e22441f35 ("cgroup/cpuset: Add a new isolated cpus.partition type"), the CS_SCHED_LOAD_BALANCE bit of a v2 cpuset can be on or off. The child cpusets of a partition root must have the same setting as its parent or it may screw up the rebuilding of sched domains. Fix this problem by making sure the a child v2 cpuset will follows its parent cpuset load balance state unless the child cpuset is a new partition root itself.
--- kernel/cgroup/cpuset.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
kernel/cgroup/cpuset.c +30 -3
@@ -1606,11 +1606,16 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, }/* -* Skip the whole subtree if the cpumask remains the same -* and has no partition root state and force flag not set. +* Skip the whole subtree if +* 1) the cpumask remains the same, +* 2) has no partition root state, +* 3) force flag not set, and +* 4) for v2 load balance state same as its parent. */ if (!cp->partition_root_state && !force && -cpumask_equal (tmp->new_cpus, cp->effective_cpus)) { +cpumask_equal (tmp->new_cpus, cp->effective_cpus) && + (!cgroup_subsys_on_dfl (cpuset_cgrp_subsys) || + (is_sched_load_balance (parent) ==is_sched_load_balance (cp)))) { pos_css =css_rightmost_descendant (pos_css);continue ; }
@@ -1693,6 +1698,20 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,update_tasks_cpumask (cp, tmp->new_cpus); +/* +* On default hierarchy, inherit the CS_SCHED_LOAD_BALANCE +* from parent if current cpuset isn't a valid partition root +* and their load balance states differ. +*/ +if (cgroup_subsys_on_dfl (cpuset_cgrp_subsys) && + !is_partition_valid (cp) && + (is_sched_load_balance (parent) !=is_sched_load_balance (cp))) { +if (is_sched_load_balance (parent)) +set_bit (CS_SCHED_LOAD_BALANCE , &cp->flags); +else +clear_bit (CS_SCHED_LOAD_BALANCE , &cp->flags); + } +/* * On legacy hierarchy, if the effective cpumask of any non- * empty cpuset is changed, we need to rebuild sched domains.
@@ -3213,6 +3232,14 @@ static int cpuset_css_online(struct cgroup_subsys_state *css) cs->use_parent_ecpus = true; parent->child_ecpus_count++; } + +/* +* For v2, clear CS_SCHED_LOAD_BALANCE if parent is isolated +*/ +if (cgroup_subsys_on_dfl (cpuset_cgrp_subsys) && + !is_sched_load_balance (parent)) +clear_bit (CS_SCHED_LOAD_BALANCE , &cs->flags); +spin_unlock_irq (&callback_lock);if (!test_bit (CGRP_CPUSET_CLONE_CHILDREN , &css->cgroup->flags))
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 390/600 RDMA/qedr: Remove a duplicate assignment in irdma_query_ah()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minjie Du <[email protected]>
[ Upstream commit 65e02e840847158c7ee48ca8e6e91062b0f78662 ]
Delete a duplicate statement from this function implementation.
--- drivers/infiniband/hw/irdma/verbs.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +0 -1
@@ -4354,7 +4354,6 @@ static int irdma_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr) ah_attr->grh.traffic_class = ah->sc_ah.ah_info.tc_tos; ah_attr->grh.hop_limit = ah->sc_ah.ah_info.hop_ttl; ah_attr->grh.sgid_index = ah->sgid_index; - ah_attr->grh.sgid_index = ah->sgid_index;memcpy (&ah_attr->grh.dgid, &ah->dgid,sizeof (ah_attr->grh.dgid)); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 391/600 media: ov5640: fix low resolution image abnormal issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoniu.zhou <[email protected]>
[ Upstream commit a828002f38c5ee49d3f0c0e64c0f0caa1aec8dc2 ]
OV5640 will output abnormal image data when work at low resolution (320x240, 176x144 and 160x120) after switching from high resolution, such as 1080P, the time interval between high and low switching must be less than 1000ms in order to OV5640 don't enter suspend state during the time.
The reason is by 0x3824 value don't restore to initialize value when do resolution switching. In high resolution setting array, 0x3824 is set to 0x04, but low resolution setting array remove 0x3824 in commit db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So when do resolution switching from high to low, such as 1080P to 320x240, and the time interval is less than auto suspend delay time which means global initialize setting array will not be loaded, the output image data are abnormal. Hence move 0x3824 from ov5640_init_setting[] table to ov5640_setting_low_res[] table and also move 0x4407 0x460b, 0x460c to avoid same issue.
--- drivers/media/i2c/ov5640.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5640.c +3 -4
@@ -557,9 +557,7 @@ static const struct reg_value ov5640_init_setting[] = { {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x4837, 0x0a, 0, 0}, {0x3824, 0x02, 0, 0}, + {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0},
@@ -623,7 +621,8 @@ static const struct reg_value ov5640_setting_low_res[] = { {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x5001, 0xa3, 0, 0}, + {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, + {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, }; static const struct reg_value ov5640_setting_720P_1280_720[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 392/600 media: ad5820: Drop unsupported ad5823 from i2c_ and of_device_id tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit f126ff7e4024f6704e6ec0d4137037568708a3c7 ]
The supported ad5820 and ad5821 VCMs both use a single 16 bit register which is written by sending 2 bytes with the data directly after sending the i2c-client address.
The ad5823 OTOH has a more typical i2c / smbus device setup with multiple 8 bit registers where the first byte send after the i2c-client address is the register address and the actual data only starts from the second byte after the i2c-client address.
The ad5823 i2c_ and of_device_id-s was added at the same time as the ad5821 ids with as rationale:
"""
Some camera modules also refer that AD5823 is a replacement of AD5820:
https://download.kamami.com/p564094-OV8865_DS.pdf
"""
The AD5823 may be an electrical and functional replacement of the AD5820, but from a software pov it is not compatible at all and it is going to need its own driver, drop its id from the ad5820 driver.
--- drivers/media/i2c/ad5820.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/i2c/ad5820.c +0 -2
@@ -356,7 +356,6 @@ static void ad5820_remove(struct i2c_client *client)static const struct i2c_device_id ad5820_id_table[] = { {"ad5820" ,0 }, {"ad5821" ,0 }, - {"ad5823" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, ad5820_id_table);
@@ -364,7 +363,6 @@ MODULE_DEVICE_TABLE(i2c, ad5820_id_table);static const struct of_device_id ad5820_of_table[] = { { .compatible ="adi,ad5820" }, { .compatible ="adi,ad5821" }, - { .compatible ="adi,ad5823" }, { } };MODULE_DEVICE_TABLE (of, ad5820_of_table);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 393/600 media: i2c: tvp5150: check return value of devm_kasprintf()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 26ce7054d804be73935b9268d6e0ecf2fbbc8aef ]
devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/media/i2c/tvp5150.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/tvp5150.c +4 -0
@@ -2068,6 +2068,10 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np) tvpc->ent.name =devm_kasprintf (dev,GFP_KERNEL ,"%s %s" , v4l2c->name, v4l2c->label ? v4l2c->label :"" ); +if (!tvpc->ent.name) { + ret = -ENOMEM ; + goto err_free; + } } ep_np =of_graph_get_endpoint_by_regs (np,TVP5150_PAD_VID_OUT ,0 );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 394/600 media: v4l2-core: Fix a potential resource leak in v4l2_fwnode_parse_link()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit d7b13edd4cb4bfa335b6008ab867ac28582d3e5c ]
If fwnode_graph_get_remote_endpoint() fails, 'fwnode' is known to be NULL, so fwnode_handle_put() is a no-op.
Release the reference taken from a previous fwnode_graph_get_port_parent() call instead.
Also handle fwnode_graph_get_port_parent() failures.
In order to fix these issues, add an error handling path to the function and the needed gotos.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +14 -4
@@ -551,19 +551,29 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, link->local_id = fwep.id; link->local_port = fwep.port; link->local_node =fwnode_graph_get_port_parent (fwnode); +if (!link->local_node) +return -ENOLINK ; fwnode =fwnode_graph_get_remote_endpoint (fwnode); -if (!fwnode) { -fwnode_handle_put (fwnode); -return -ENOLINK ; - } +if (!fwnode) + goto err_put_local_node;fwnode_graph_parse_endpoint (fwnode, &fwep); link->remote_id = fwep.id; link->remote_port = fwep.port; link->remote_node =fwnode_graph_get_port_parent (fwnode); +if (!link->remote_node) + goto err_put_remote_endpoint;return 0 ; + +err_put_remote_endpoint: +fwnode_handle_put (fwnode); + +err_put_local_node: +fwnode_handle_put (link->local_node); + +return -ENOLINK ; }EXPORT_SYMBOL_GPL (v4l2_fwnode_parse_link);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 395/600 iommu/amd/iommu_v2: Fix pasid_state refcount dec hit 0 warning on pasid unbind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Marcovitch <[email protected]>
[ Upstream commit 534103bcd52ca9c1fecbc70e717b4a538dc4ded8 ]
When unbinding pasid - a race condition exists vs outstanding page faults.
To prevent this, the pasid_state object contains a refcount.
* set to 1 on pasid bind
* incremented on each ppr notification start
* decremented on each ppr notification done
* decremented on pasid unbind
Since refcount_dec assumes that refcount will never reach 0:
the current implementation causes the following to be invoked on pasid unbind:
REFCOUNT_WARN("decrement hit 0; leaking memory")
Fix this issue by changing refcount_dec to refcount_dec_and_test to explicitly handle refcount=1.
--- drivers/iommu/amd/iommu_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/amd/iommu_v2.c +2 -2
@@ -262,8 +262,8 @@ static void put_pasid_state(struct pasid_state *pasid_state)static void put_pasid_state_wait (struct pasid_state *pasid_state) { -refcount_dec (&pasid_state->count); -wait_event (pasid_state->wq, !refcount_read (&pasid_state->count)); +if (!refcount_dec_and_test (&pasid_state->count)) +wait_event (pasid_state->wq, !refcount_read (&pasid_state->count));free_pasid_state (pasid_state); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 396/600 iommu: rockchip: Fix directory table address encoding
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit 6df63b7ebdaf5fcd75dceedf6967d0761e56eca1 ]
The physical address to the directory table is currently encoded using the following bit layout for IOMMU v2.
31:12 - Address bit 31:0
11: 4 - Address bit 39:32
This is also the bit layout used by the vendor kernel.
However, testing has shown that addresses to the directory/page tables and memory pages are all encoded using the same bit layout.
IOMMU v1:
31:12 - Address bit 31:0
IOMMU v2:
31:12 - Address bit 31:0
11: 8 - Address bit 35:32
7: 4 - Address bit 39:36
Change to use the mk_dtentries ops to encode the directory table address correctly. The value written to DTE_ADDR may include the valid bit set, a bit that is ignored and DTE_ADDR reg read it back as 0.
This also update the bit layout comment for the page address and the number of nybbles that are read back for DTE_ADDR comment.
These changes render the dte_addr_phys and dma_addr_dte ops unused and is removed.
--- drivers/iommu/rockchip-iommu.c | 43 ++++------------------------------ 1 file changed, 5 insertions(+), 38 deletions(-)
drivers/iommu/rockchip-iommu.c +5 -38
@@ -98,8 +98,6 @@ struct rk_iommu_ops {phys_addr_t (*pt_address)(u32 dte);u32 (*mk_dtentries)(dma_addr_t pt_dma);u32 (*mk_ptentries)(phys_addr_t page,int prot); -phys_addr_t (*dte_addr_phys)(u32 addr); -u32 (*dma_addr_dte)(dma_addr_t dt_dma);u64 dma_bit_mask; };
@@ -277,8 +275,8 @@ static u32 rk_mk_pte(phys_addr_t page, int prot)/* * In v2: * 31:12 - Page address bit 31:0 -* 11:9 - Page address bit 34:32 -* 8:4 - Page address bit 39:35 +* 11: 8 - Page address bit 35:32 +* 7: 4 - Page address bit 39:36 * 3 - Security * 2 - Writable * 1 - Readable
@@ -505,7 +503,7 @@ static int rk_iommu_force_reset(struct rk_iommu *iommu)/* * Check if register DTE_ADDR is working by writing DTE_ADDR_DUMMY -* and verifying that upper 5 nybbles are read back. +* and verifying that upper 5 (v1) or 7 (v2) nybbles are read back. */ for (i =0 ; i < iommu->num_mmu; i++) { dte_addr = rk_ops->pt_address (DTE_ADDR_DUMMY );
@@ -530,33 +528,6 @@ static int rk_iommu_force_reset(struct rk_iommu *iommu)return 0 ; } -static inline phys_addr_t rk_dte_addr_phys (u32 addr) -{ -return (phys_addr_t )addr; -} - -static inline u32 rk_dma_addr_dte (dma_addr_t dt_dma) -{ -return dt_dma; -} - -#define DT_HI_MASK GENMASK_ULL(39, 32) -#define DTE_BASE_HI_MASK GENMASK(11, 4) -#define DT_SHIFT 28 - -static inline phys_addr_t rk_dte_addr_phys_v2 (u32 addr) -{ -u64 addr64 = addr; -return (phys_addr_t)(addr64 &RK_DTE_PT_ADDRESS_MASK ) | - ((addr64 &DTE_BASE_HI_MASK ) <<DT_SHIFT ); -} - -static inline u32 rk_dma_addr_dte_v2 (dma_addr_t dt_dma) -{ -return (dt_dma &RK_DTE_PT_ADDRESS_MASK ) | - ((dt_dma &DT_HI_MASK ) >>DT_SHIFT ); -} -static void log_iova (struct rk_iommu *iommu,int index,dma_addr_t iova) {void __iomem *base = iommu->bases[index];
@@ -576,7 +547,7 @@ static void log_iova(struct rk_iommu *iommu, int index, dma_addr_t iova) page_offset =rk_iova_page_offset (iova); mmu_dte_addr =rk_iommu_read (base,RK_MMU_DTE_ADDR ); - mmu_dte_addr_phys = rk_ops->dte_addr_phys (mmu_dte_addr); + mmu_dte_addr_phys = rk_ops->pt_address (mmu_dte_addr); dte_addr_phys = mmu_dte_addr_phys + (4 * dte_index); dte_addr =phys_to_virt (dte_addr_phys);
@@ -966,7 +937,7 @@ static int rk_iommu_enable(struct rk_iommu *iommu)for (i =0 ; i < iommu->num_mmu; i++) {rk_iommu_write (iommu->bases[i],RK_MMU_DTE_ADDR , - rk_ops->dma_addr_dte (rk_domain->dt_dma)); + rk_ops->mk_dtentries (rk_domain->dt_dma));rk_iommu_base_command (iommu->bases[i],RK_MMU_CMD_ZAP_CACHE );rk_iommu_write (iommu->bases[i],RK_MMU_INT_MASK ,RK_MMU_IRQ_MASK ); }
@@ -1373,8 +1344,6 @@ static struct rk_iommu_ops iommu_data_ops_v1 = { .pt_address = &rk_dte_pt_address, .mk_dtentries = &rk_mk_dte, .mk_ptentries = &rk_mk_pte, - .dte_addr_phys = &rk_dte_addr_phys, - .dma_addr_dte = &rk_dma_addr_dte, .dma_bit_mask = DMA_BIT_MASK(32), };
@@ -1382,8 +1351,6 @@ static struct rk_iommu_ops iommu_data_ops_v2 = { .pt_address = &rk_dte_pt_address_v2, .mk_dtentries = &rk_mk_dte_v2, .mk_ptentries = &rk_mk_pte_v2, - .dte_addr_phys = &rk_dte_addr_phys_v2, - .dma_addr_dte = &rk_dma_addr_dte_v2, .dma_bit_mask = DMA_BIT_MASK(40), };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 397/600 drivers: usb: smsusb: fix error handling code in smsusb_init_device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dongliang Mu <[email protected]>
[ Upstream commit b9c7141f384097fa4fa67d2f72e5731d628aef7c ]
The previous commit 4b208f8b561f ("[media] siano: register media controller earlier")moves siano_media_device_register before smscore_register_device, and adds corresponding error handling code if smscore_register_device fails. However, it misses the following error handling code of smsusb_init_device.
Fix this by moving error handling code at the end of smsusb_init_device and adding a goto statement in the following error handling parts.
--- drivers/media/usb/siano/smsusb.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/media/usb/siano/smsusb.c +11 -10
@@ -455,12 +455,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) rc =smscore_register_device (¶ms, &dev->coredev,0 , mdev);if (rc <0 ) {pr_err ("smscore_register_device(...) failed, rc %d\n" , rc); -smsusb_term_device (intf); -#ifdef CONFIG_MEDIA_CONTROLLER_DVB -media_device_unregister (mdev); -#endif -kfree (mdev); -return rc; + goto err_unregister_device; }smscore_set_board_id (dev->coredev, board_id);
@@ -477,8 +472,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) rc =smsusb_start_streaming (dev);if (rc <0 ) {pr_err ("smsusb_start_streaming(...) failed\n" ); -smsusb_term_device (intf); -return rc; + goto err_unregister_device; } dev->state =SMSUSB_ACTIVE ;
@@ -486,13 +480,20 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) rc =smscore_start_device (dev->coredev);if (rc <0 ) {pr_err ("smscore_start_device(...) failed\n" ); -smsusb_term_device (intf); -return rc; + goto err_unregister_device; }pr_debug ("device 0x%p created\n" , dev);return rc; + +err_unregister_device: +smsusb_term_device (intf); +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +media_device_unregister (mdev); +#endif +kfree (mdev); +return rc; } static int smsusb_probe(struct usb_interface *intf,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 398/600 media: dib7000p: Fix potential division by zero
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniil Dulov <[email protected]>
[ Upstream commit a1db7b2c5533fc67e2681eb5efc921a67bc7d5b8 ]
Variable loopdiv can be assigned 0, then it is used as a denominator, without checking it for 0.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/dvb-frontends/dib7000p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/dib7000p.c +1 -1
@@ -497,7 +497,7 @@ static int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth prediv = reg_1856 &0x3f ; loopdiv = (reg_1856 >>6 ) &0x3f ; -if ((bw !=NULL ) && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) { +if (loopdiv && bw && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) {dprintk ("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)\n" , prediv, bw->pll_prediv, loopdiv, bw->pll_ratio); reg_1856 &=0xf000 ; reg_1857 =dib7000p_read_word (state,1857 );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 399/600 media: dvb-usb: m920x: Fix a potential memory leak in m920x_i2c_xfer()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit ea9ef6c2e001c5dc94bee35ebd1c8a98621cf7b8 ]
'read' is freed when it is known to be NULL, but not when a read error occurs.
Revert the logic to avoid a small leak, should a m920x_read() call fail.
--- drivers/media/usb/dvb-usb/m920x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/m920x.c +3 -2
@@ -277,7 +277,6 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuchar *read =kmalloc (1 ,GFP_KERNEL );if (!read) { ret = -ENOMEM ; -kfree (read); goto unlock; }
@@ -288,8 +287,10 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuif ((ret =m920x_read (d->udev,M9206_I2C ,0x0 ,0x20 | stop, - read,1 )) !=0 ) + read,1 )) !=0 ) { +kfree (read); goto unlock; + } msg[i].buf[j] = read[0 ]; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 400/600 media: cx24120: Add retval check for cx24120_message_send()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniil Dulov <[email protected]>
[ Upstream commit 96002c0ac824e1773d3f706b1f92e2a9f2988047 ]
If cx24120_message_send() returns error, we should keep local struct unchanged.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/dvb-frontends/cx24120.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/cx24120.c +3 -1
@@ -973,7 +973,9 @@ static void cx24120_set_clock_ratios(struct dvb_frontend *fe) cmd.arg[8 ] = (clock_ratios_table[idx].rate >>8 ) &0xff ; cmd.arg[9 ] = (clock_ratios_table[idx].rate >>0 ) &0xff ; -cx24120_message_send (state, &cmd); + ret =cx24120_message_send (state, &cmd); +if (ret !=0 ) +return ;/* Calculate ber window rates for stat work */ cx24120_calculate_ber_window (state, clock_ratios_table[idx].rate);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 401/600 RDMA/siw: Fabricate a GID on tun and loopback devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit bad5b6e34ffbaacc77ad28a0f482e33b3929e635 ]
LOOPBACK and NONE (tunnel) devices have all-zero MAC addresses. Currently, siw_device_create() falls back to copying the IB device's name in those cases, because an all-zero MAC address breaks the RDMA core address resolution mechanism.
However, at the point when siw_device_create() constructs a GID, the ib_device::name field is uninitialized, leaving the MAC address to remain in an all-zero state.
Fabricate a random artificial GID for such devices, and ensure this artificial GID is returned for all device query operations.
--- drivers/infiniband/sw/siw/siw.h | 1 + drivers/infiniband/sw/siw/siw_main.c | 22 ++++++++-------------- drivers/infiniband/sw/siw/siw_verbs.c | 4 ++-- 3 files changed, 11 insertions(+), 16 deletions(-)
drivers/infiniband/sw/siw/siw.h +1 -0
@@ -74,6 +74,7 @@ struct siw_device {u32 vendor_part_id;int numa_node; +char raw_gid[ETH_ALEN ];/* physical port state (only one port per device) */ enum ib_port_state state;
drivers/infiniband/sw/siw/siw_main.c +8 -14
@@ -75,8 +75,7 @@ static int siw_device_register(struct siw_device *sdev, const char *name)return rv; } -siw_dbg (base_dev,"HWaddr=%pM\n" , sdev->netdev->dev_addr); - +siw_dbg (base_dev,"HWaddr=%pM\n" , sdev->raw_gid);return 0 ; }
@@ -313,24 +312,19 @@ static struct siw_device *siw_device_create(struct net_device *netdev)return NULL ; base_dev = &sdev->base_dev; - sdev->netdev = netdev; -if (netdev->type !=ARPHRD_LOOPBACK && netdev->type !=ARPHRD_NONE ) { -addrconf_addr_eui48 ((unsigned char *)&base_dev->node_guid, - netdev->dev_addr); +if (netdev->addr_len) { +memcpy (sdev->raw_gid, netdev->dev_addr, + min_t(unsigned int, netdev->addr_len, ETH_ALEN)); }else {/* -* This device does not have a HW address, -* but connection mangagement lib expects gid != 0 +* This device does not have a HW address, but +* connection mangagement requires a unique gid. */ -size_t len =min_t (size_t,strlen (base_dev->name),6 ); -char addr[6 ] = { }; - -memcpy (addr, base_dev->name, len); -addrconf_addr_eui48 ((unsigned char *)&base_dev->node_guid, - addr); +eth_random_addr (sdev->raw_gid); } +addrconf_addr_eui48 ((u8 *)&base_dev->node_guid, sdev->raw_gid); base_dev->uverbs_cmd_mask |=BIT_ULL (IB_USER_VERBS_CMD_POST_SEND );
drivers/infiniband/sw/siw/siw_verbs.c +2 -2
@@ -157,7 +157,7 @@ int siw_query_device(struct ib_device *base_dev, struct ib_device_attr *attr, attr->vendor_part_id = sdev->vendor_part_id;addrconf_addr_eui48 ((u8 *)&attr->sys_image_guid, - sdev->netdev->dev_addr); + sdev->raw_gid);return 0 ; }
@@ -218,7 +218,7 @@ int siw_query_gid(struct ib_device *base_dev, u32 port, int idx,/* subnet_prefix == interface_id == 0; */ memset (gid,0 ,sizeof (*gid)); -memcpy (&gid->raw[0 ], sdev->netdev->dev_addr,6 ); +memcpy (gid->raw, sdev->raw_gid,ETH_ALEN );return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 402/600 scsi: hisi_sas: Fix warnings detected by sparse
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit c0328cc595124579328462fc45d7a29a084cf357 ]
This patch fixes the following warning:
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:2168:43: sparse: sparse: restricted __le32 degrades to integer
Stable-dep-of: f5393a5602ca ("scsi: hisi_sas: Fix normally completed I/O analysed as failed")
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +4 -3
@@ -2163,6 +2163,7 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,u32 trans_tx_fail_type =le32_to_cpu (record->trans_tx_fail_type);u16 sipc_rx_err_type =le16_to_cpu (record->sipc_rx_err_type);u32 dw3 =le32_to_cpu (complete_hdr->dw3); +u32 dw0 =le32_to_cpu (complete_hdr->dw0);switch (task->task_proto) {case SAS_PROTOCOL_SSP :
@@ -2172,8 +2173,8 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,* but I/O information has been written to the host memory, we examine * response IU. */ -if (!(complete_hdr->dw0 &CMPLT_HDR_RSPNS_GOOD_MSK ) && - (complete_hdr->dw0 &CMPLT_HDR_RSPNS_XFRD_MSK )) +if (!(dw0 &CMPLT_HDR_RSPNS_GOOD_MSK ) && + (dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ))return false; ts->residual = trans_tx_fail_type;
@@ -2189,7 +2190,7 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,case SAS_PROTOCOL_SATA :case SAS_PROTOCOL_STP :case SAS_PROTOCOL_SATA |SAS_PROTOCOL_STP : -if ((complete_hdr->dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) && +if ((dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) && (sipc_rx_err_type &RX_FIS_STATUS_ERR_MSK )) { ts->stat =SAS_PROTO_RESPONSE ; }else if (dma_rx_err_type &RX_DATA_LEN_UNDERFLOW_MSK ) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 403/600 scsi: hisi_sas: Fix normally completed I/O analysed as failed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit f5393a5602cacfda2014e0ff8220e5a7564e7cd1 ]
The PIO read command has no response frame and the struct iu[1024] won't be filled. I/Os which are normally completed will be treated as failed in sas_ata_task_done() when iu contains abnormal dirty data.
Consequently ending_fis should not be filled by iu when the response frame hasn't been written to memory.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 11 +++++++++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +9 -2
@@ -2026,6 +2026,11 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba,u16 dma_tx_err_type =le16_to_cpu (err_record->dma_tx_err_type);u16 sipc_rx_err_type =le16_to_cpu (err_record->sipc_rx_err_type);u32 dma_rx_err_type =le32_to_cpu (err_record->dma_rx_err_type); +struct hisi_sas_complete_v2_hdr *complete_queue = + hisi_hba->complete_hdr[slot->cmplt_queue]; +struct hisi_sas_complete_v2_hdr *complete_hdr = + &complete_queue[slot->cmplt_queue_slot]; +u32 dw0 =le32_to_cpu (complete_hdr->dw0);int error =-1 ;if (err_phase ==1 ) {
@@ -2310,7 +2315,8 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba,break ; } } -hisi_sas_sata_done (task, slot); +if (dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) +hisi_sas_sata_done (task, slot); }break ;default :
@@ -2443,7 +2449,8 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba,case SAS_PROTOCOL_SATA |SAS_PROTOCOL_STP : { ts->stat =SAS_SAM_STAT_GOOD ; -hisi_sas_sata_done (task, slot); +if (dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) +hisi_sas_sata_done (task, slot);break ; }default :
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +4 -2
@@ -2203,7 +2203,8 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task, ts->stat =SAS_OPEN_REJECT ; ts->open_rej_reason =SAS_OREJ_RSVD_RETRY ; } -hisi_sas_sata_done (task, slot); +if (dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) +hisi_sas_sata_done (task, slot);break ;case SAS_PROTOCOL_SMP : ts->stat =SAS_SAM_STAT_CHECK_CONDITION ;
@@ -2330,7 +2331,8 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,case SAS_PROTOCOL_STP :case SAS_PROTOCOL_SATA |SAS_PROTOCOL_STP : ts->stat =SAS_SAM_STAT_GOOD ; -hisi_sas_sata_done (task, slot); +if (dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) +hisi_sas_sata_done (task, slot);break ;default : ts->stat =SAS_SAM_STAT_CHECK_CONDITION ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 404/600 dt-bindings: extcon: maxim,max77843: restrict connector properties
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit fb2c3f72e819254d8c76de95917e5f9ff232586c ]
Do not allow any other properties in connector child, except what usb-connector.yaml evaluates.
--- Documentation/devicetree/bindings/extcon/maxim,max77843.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/extcon/maxim,max77843.yaml +1 -0
@@ -23,6 +23,7 @@ properties: connector: $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false ports: $ref: /schemas/graph.yaml#/properties/ports
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 405/600 media: amphion: reinit vpu if reqbufs output 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit 73e3f09292a0492a3fe0f87a8170a74f12624c5e ]
according to v4l2 stateful decoder document 4.5.1.3. State Machine, the state should change from seek to initialization
if call VIDIOC_REQBUFS(OUTPUT, 0).
so reinit the vpu decoder if reqbufs output 0
--- drivers/media/platform/amphion/vdec.c | 2 -- drivers/media/platform/amphion/vpu_v4l2.c | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/media/platform/amphion/vdec.c +0 -2
@@ -1407,9 +1407,7 @@ static void vdec_release(struct vpu_inst *inst) {if (inst->id !=VPU_INST_NULL_ID )vpu_trace (inst->dev,"[%d]\n" , inst->id); -vpu_inst_lock (inst);vdec_stop (inst, true); -vpu_inst_unlock (inst); }static void vdec_cleanup (struct vpu_inst *inst)
drivers/media/platform/amphion/vpu_v4l2.c +6 -1
@@ -404,6 +404,11 @@ static int vpu_vb2_queue_setup(struct vb2_queue *vq,for (i =0 ; i < cur_fmt->num_planes; i++) psize[i] = cur_fmt->sizeimage[i]; +if (V4L2_TYPE_IS_OUTPUT (vq->type) && inst->state ==VPU_CODEC_STATE_SEEK ) { +vpu_trace (inst->dev,"reinit when VIDIOC_REQBUFS(OUTPUT, 0)\n" ); +call_void_vop (inst, release); + } +return 0 ; }
@@ -688,9 +693,9 @@ int vpu_v4l2_close(struct file *file)v4l2_m2m_ctx_release (inst->fh.m2m_ctx); inst->fh.m2m_ctx =NULL ; } +call_void_vop (inst, release);vpu_inst_unlock (inst); -call_void_vop (inst, release);vpu_inst_unregister (inst);vpu_inst_put (inst);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 406/600 media: amphion: add helper function to get id name
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit 12cd8b8ac02525977b2e860a877add10e8ce7468 ]
convert numbers into meaningful names,
then it can improve the log readability
--- drivers/media/platform/amphion/vdec.c | 9 +-- drivers/media/platform/amphion/vpu.h | 3 + drivers/media/platform/amphion/vpu_cmds.c | 11 ++-- drivers/media/platform/amphion/vpu_dbg.c | 6 +- drivers/media/platform/amphion/vpu_helpers.c | 61 ++++++++++++++++++++ drivers/media/platform/amphion/vpu_msgs.c | 2 +- 6 files changed, 79 insertions(+), 13 deletions(-)
drivers/media/platform/amphion/vdec.c +5 -4
@@ -249,7 +249,8 @@ static int vdec_update_state(struct vpu_inst *inst, enum vpu_codec_state state, vdec->state =VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ;if (inst->state != pre_state) -vpu_trace (inst->dev,"[%d] %d -> %d\n" , inst->id, pre_state, inst->state); +vpu_trace (inst->dev,"[%d] %s -> %s\n" , inst->id, +vpu_codec_state_name (pre_state),vpu_codec_state_name (inst->state));if (inst->state ==VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE )vdec_handle_resolution_change (inst);
@@ -994,8 +995,8 @@ static int vdec_response_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vbreturn -EINVAL ; } -dev_dbg (inst->dev,"[%d] state = %d, alloc fs %d, tag = 0x%x\n" , - inst->id, inst->state, vbuf->vb2_buf.index, vdec->seq_tag); +dev_dbg (inst->dev,"[%d] state = %s, alloc fs %d, tag = 0x%x\n" , + inst->id,vpu_codec_state_name (inst->state), vbuf->vb2_buf.index, vdec->seq_tag); vpu_buf =to_vpu_vb2_buffer (vbuf);memset (&info,0 ,sizeof (info));
@@ -1354,7 +1355,7 @@ static void vdec_abort(struct vpu_inst *inst)struct vpu_rpc_buffer_desc desc;int ret; -vpu_trace (inst->dev,"[%d] state = %d\n" , inst->id, inst->state); +vpu_trace (inst->dev,"[%d] state = %s\n" , inst->id,vpu_codec_state_name (inst->state)); vdec->aborting = true;vpu_iface_add_scode (inst,SCODE_PADDING_ABORT );
drivers/media/platform/amphion/vpu.h +3 -0
@@ -353,6 +353,9 @@ void vpu_inst_record_flow(struct vpu_inst *inst, u32 flow);int vpu_core_driver_init (void );void vpu_core_driver_exit (void ); +const char *vpu_id_name (u32 id); +const char *vpu_codec_state_name (enum vpu_codec_state state); +extern bool debug; #define vpu_trace(dev, fmt, arg...) \ do { \
drivers/media/platform/amphion/vpu_cmds.c +6 -5
@@ -98,7 +98,7 @@ static struct vpu_cmd_t *vpu_alloc_cmd(struct vpu_inst *inst, u32 id, void *data cmd->id = id; ret =vpu_iface_pack_cmd (inst->core, cmd->pkt, inst->id, id, data);if (ret) { -dev_err (inst->dev,"iface pack cmd(%d) fail\n" , id); +dev_err (inst->dev,"iface pack cmd %s fail\n" ,vpu_id_name (id));vfree (cmd->pkt);vfree (cmd);return NULL ;
@@ -125,14 +125,14 @@ static int vpu_session_process_cmd(struct vpu_inst *inst, struct vpu_cmd_t *cmd) {int ret; -dev_dbg (inst->dev,"[%d]send cmd(0x%x)\n" , inst->id, cmd->id); +dev_dbg (inst->dev,"[%d]send cmd %s\n" , inst->id,vpu_id_name (cmd->id));vpu_iface_pre_send_cmd (inst); ret =vpu_cmd_send (inst->core, cmd->pkt);if (!ret) {vpu_iface_post_send_cmd (inst);vpu_inst_record_flow (inst, cmd->id); }else { -dev_err (inst->dev,"[%d] iface send cmd(0x%x) fail\n" , inst->id, cmd->id); +dev_err (inst->dev,"[%d] iface send cmd %s fail\n" , inst->id,vpu_id_name (cmd->id)); }return ret;
@@ -149,7 +149,8 @@ static void vpu_process_cmd_request(struct vpu_inst *inst)list_for_each_entry_safe (cmd, tmp, &inst->cmd_q, list) {list_del_init (&cmd->list);if (vpu_session_process_cmd (inst, cmd)) -dev_err (inst->dev,"[%d] process cmd(%d) fail\n" , inst->id, cmd->id); +dev_err (inst->dev,"[%d] process cmd %s fail\n" , + inst->id,vpu_id_name (cmd->id));if (cmd->request) { inst->pending = (void *)cmd;break ;
@@ -339,7 +340,7 @@ static int vpu_session_send_cmd(struct vpu_inst *inst, u32 id, void *data) exit:if (ret) -dev_err (inst->dev,"[%d] send cmd(0x%x) fail\n" , inst->id, id); +dev_err (inst->dev,"[%d] send cmd %s fail\n" , inst->id,vpu_id_name (id));return ret; }
drivers/media/platform/amphion/vpu_dbg.c +3 -3
@@ -67,7 +67,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num =scnprintf (str,sizeof (str),"tgig = %d,pid = %d\n" , inst->tgid, inst->pid);if (seq_write (s, str, num))return 0 ; - num =scnprintf (str,sizeof (str),"state = %d\n" , inst->state); + num =scnprintf (str,sizeof (str),"state = %s\n" ,vpu_codec_state_name (inst->state));if (seq_write (s, str, num))return 0 ; num = scnprintf(str, sizeof(str),
@@ -188,9 +188,9 @@ static int vpu_dbg_instance(struct seq_file *s, void *data)if (!inst->flows[idx])continue ; - num =scnprintf (str,sizeof (str),"\t[%s]0x%x\n" , + num =scnprintf (str,sizeof (str),"\t[%s] %s\n" , inst->flows[idx] >=VPU_MSG_ID_NOOP ?"M" :"C" , - inst->flows[idx]); +vpu_id_name (inst->flows[idx]));if (seq_write (s, str, num)) {mutex_unlock (&inst->core->cmd_lock);return 0 ;
drivers/media/platform/amphion/vpu_helpers.c +61 -0
70 lines not on this page · raw message
drivers/media/platform/amphion/vpu_msgs.c +1 -1
@@ -210,7 +210,7 @@ static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *mreturn -EINVAL ; msg_id = ret; -dev_dbg (inst->dev,"[%d] receive event(0x%x)\n" , inst->id, msg_id); +dev_dbg (inst->dev,"[%d] receive event(%s)\n" , inst->id,vpu_id_name (msg_id));for (i =0 ; i <ARRAY_SIZE (handlers); i++) {if (handlers[i].id == msg_id) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 407/600 media: mtk-jpeg: Fix use after free bug due to uncanceled work
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Wang <[email protected]>
[ Upstream commit c677d7ae83141d390d1253abebafa49c962afb52 ]
In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with mtk_jpeg_job_timeout_work. Then mtk_jpeg_dec_device_run and mtk_jpeg_enc_device_run may be called to start the work.
If we remove the module which will call mtk_jpeg_remove to make cleanup, there may be a unfinished work. The possible sequence is as follows, which will cause a typical UAF bug.
Fix it by canceling the work before cleanup in the mtk_jpeg_remove
CPU0 CPU1
|mtk_jpeg_job_timeout_work
mtk_jpeg_remove |
v4l2_m2m_release |
kfree(m2m_dev); |
|
| v4l2_m2m_get_curr_priv
| m2m_dev->curr_ctx //use--- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1 -0
@@ -1412,6 +1412,7 @@ static int mtk_jpeg_remove(struct platform_device *pdev) {struct mtk_jpeg_dev *jpeg =platform_get_drvdata (pdev); +cancel_delayed_work_sync (&jpeg->job_timeout_work);pm_runtime_disable (&pdev->dev);video_unregister_device (jpeg->vdev);v4l2_m2m_release (jpeg->m2m_dev);
Signature · 1 line
2.40.1
Re:[PATCH 6.1 407/600] media: mtk-jpeg: Fix use after free bug due to uncanceled work
Hi,
Sorry to bother you for I didn't know how to submit patch to a specific branch. Could you please push this patch to 5.10 branch? The chrome-os is affcted by this issue.
Best regards,
Zheng Wang
Quoted 55 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Wang <[email protected]>
[ Upstream commit
c677d7ae83141d390d1253abebafa49c962afb52]In
mtk_jpeg_probe,&jpeg->job_timeout_workis bound withmtk_jpeg_job_timeout_work. Thenmtk_jpeg_dec_device_runandmtk_jpeg_enc_device_runmay be called to start the work.
If we remove the module which will callmtk_jpeg_removeto make cleanup, there may be a unfinished work. The possible sequence is as follows, which will cause a typical UAF bug.Fix it by canceling the work before cleanup in the
mtk_jpeg_removeCPU0 CPU1
|mtk_jpeg_job_timeout_work
mtk_jpeg_remove|v4l2_m2m_release | kfree(m2m_dev); | | | v4l2_m2m_get_curr_priv | m2m_dev->curr_ctx //useFixes b2f0d2724ba4 ("[media] vcodec: mediatek: Add Mediatek JPEG Decoder Driver")Signed-off-by Zheng Wang <[email protected]>Reviewed-by Alexandre Mergnat <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Hans Verkuil <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c| 1 +1 file changed, 1 insertion(+)drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1
-0@@ -1412,6 +1412,7 @@ static int mtk_jpeg_remove(struct platform_device *pdev) {struct mtk_jpeg_dev *jpeg =platform_get_drvdata (pdev); +cancel_delayed_work_sync (&jpeg->job_timeout_work);pm_runtime_disable (&pdev->dev);video_unregister_device (jpeg->vdev);v4l2_m2m_release (jpeg->m2m_dev);Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 407/600] media: mtk-jpeg: Fix use after free bug due to uncanceled work
Quoted 5 lines · 王征
Hi,
Sorry to bother you for I didn't know how to submit patch to a specific branch. Could you please push this patch to 5.10 branch? The chrome-os is affcted by this issue.
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
Re:Re: [PATCH 6.1 407/600] media: mtk-jpeg: Fix use after free bug due to uncanceled work
Quoted 9 lines · Greg Kroah-Hartman
Quoted 5 lines · 王征
Hi,
Sorry to bother you for I didn't know how to submit patch to a specific branch. Could you please push this patch to 5.10 branch? The chrome-os is affcted by this issue.
Quoted 6 lines
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
Get it! Thanks very mush:)
Best wishes,
Zheng Wang
Greg Kroah-Hartman
maintainerPATCH 408/600 media: rkvdec: increase max supported height for H.264
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Gaignard <[email protected]>
[ Upstream commit f000e6ca2d60fefd02a180a57df2c4162fa0c1b7 ]
After testing it is possible for the hardware to decode H264 bistream with a height up to 2560.
--- drivers/staging/media/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/rkvdec/rkvdec.c +1 -1
@@ -120,7 +120,7 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { .max_width = 4096, .step_width = 16, .min_height = 48, - .max_height = 2304, + .max_height = 2560, .step_height = 16, }, .ctrls = &rkvdec_h264_ctrls,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 409/600 media: amphion: fix CHECKED_RETURN issues reported by coverity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit b237b058adbc7825da9c8f358f1ff3f0467d623a ]
calling "vpu_cmd_send/vpu_get_buffer_state/vpu_session_alloc_fs" without checking return value
--- drivers/media/platform/amphion/vdec.c | 5 ++++- drivers/media/platform/amphion/vpu_cmds.c | 3 ++- drivers/media/platform/amphion/vpu_dbg.c | 11 +++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-)
drivers/media/platform/amphion/vdec.c +4 -1
@@ -957,6 +957,7 @@ static int vdec_response_frame_abnormal(struct vpu_inst *inst) {struct vdec_t *vdec = inst->priv;struct vpu_fs_info info; +int ret;if (!vdec->req_frame_count)return 0 ;
@@ -964,7 +965,9 @@ static int vdec_response_frame_abnormal(struct vpu_inst *inst)memset (&info,0 ,sizeof (info)); info.type =MEM_RES_FRAME ; info.tag = vdec->seq_tag +0xf0 ; -vpu_session_alloc_fs (inst, &info); + ret =vpu_session_alloc_fs (inst, &info); +if (ret) +return ret; vdec->req_frame_count--;return 0 ;
drivers/media/platform/amphion/vpu_cmds.c +2 -1
@@ -306,7 +306,8 @@ static void vpu_core_keep_active(struct vpu_core *core)dev_dbg (core->dev,"try to wake up\n" );mutex_lock (&core->cmd_lock); -vpu_cmd_send (core, &pkt); +if (vpu_cmd_send (core, &pkt)) +dev_err (core->dev,"fail to keep active\n" );mutex_unlock (&core->cmd_lock); }
drivers/media/platform/amphion/vpu_dbg.c +9 -2
@@ -50,6 +50,13 @@ static char *vpu_stat_name[] = { [VPU_BUF_STATE_ERROR] = "error", }; +static inline const char *to_vpu_stat_name (int state) +{ +if (state <=VPU_BUF_STATE_ERROR ) +return vpu_stat_name[state]; +return "unknown" ; +} +static int vpu_dbg_instance (struct seq_file *s,void *data) {struct vpu_inst *inst = s->private;
@@ -141,7 +148,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num =scnprintf (str,sizeof (str),"output [%2d] state = %10s, %8s\n" , i, vb2_stat_name[vb->state], - vpu_stat_name[vpu_get_buffer_state (vbuf)]); +to_vpu_stat_name (vpu_get_buffer_state (vbuf)));if (seq_write (s, str, num))return 0 ; }
@@ -156,7 +163,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num =scnprintf (str,sizeof (str),"capture[%2d] state = %10s, %8s\n" , i, vb2_stat_name[vb->state], - vpu_stat_name[vpu_get_buffer_state (vbuf)]); +to_vpu_stat_name (vpu_get_buffer_state (vbuf)));if (seq_write (s, str, num))return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 410/600 media: amphion: fix REVERSE_INULL issues reported by coverity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit 79d3bafaecc13bccab1ebbd28a15e669c5a4cdaf ]
null-checking of a pointor is suggested before dereferencing it
--- drivers/media/platform/amphion/venc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/amphion/venc.c +4 -2
@@ -278,7 +278,7 @@ static int venc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *parm {struct vpu_inst *inst =to_inst (file);struct venc_t *venc = inst->priv; -struct v4l2_fract *timeperframe = &parm->parm.capture.timeperframe; +struct v4l2_fract *timeperframe;if (!parm)return -EINVAL ;
@@ -289,6 +289,7 @@ static int venc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *parmif (!vpu_helper_check_type (inst, parm->type))return -EINVAL ; + timeperframe = &parm->parm.capture.timeperframe; parm->parm.capture.capability =V4L2_CAP_TIMEPERFRAME ; parm->parm.capture.readbuffers =0 ; timeperframe->numerator = venc->params.frame_rate.numerator;
@@ -301,7 +302,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *parm {struct vpu_inst *inst =to_inst (file);struct venc_t *venc = inst->priv; -struct v4l2_fract *timeperframe = &parm->parm.capture.timeperframe; +struct v4l2_fract *timeperframe;unsigned long n, d;if (!parm)
@@ -313,6 +314,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *parmif (!vpu_helper_check_type (inst, parm->type))return -EINVAL ; + timeperframe = &parm->parm.capture.timeperframe;if (!timeperframe->numerator) timeperframe->numerator = venc->params.frame_rate.numerator;if (!timeperframe->denominator)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 411/600 media: amphion: fix UNINIT issues reported by coverity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit c224d0497a31ea2d173e1ea16af308945bff9037 ]
using uninitialized value may introduce risk
--- drivers/media/platform/amphion/vpu_msgs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/amphion/vpu_msgs.c +6 -6
@@ -32,7 +32,7 @@ static void vpu_session_handle_start_done(struct vpu_inst *inst, struct vpu_rpc_static void vpu_session_handle_mem_request (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -struct vpu_pkt_mem_req_data req_data; +struct vpu_pkt_mem_req_data req_data = {0 };vpu_iface_unpack_msg_data (inst->core, pkt, (void *)&req_data); vpu_trace(inst->dev, "[%d] %d:%d %d:%d %d:%d\n",
@@ -80,7 +80,7 @@ static void vpu_session_handle_resolution_change(struct vpu_inst *inst, struct vstatic void vpu_session_handle_enc_frame_done (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -struct vpu_enc_pic_info info; +struct vpu_enc_pic_info info = {0 };vpu_iface_unpack_msg_data (inst->core, pkt, (void *)&info); dev_dbg(inst->dev, "[%d] frame id = %d, wptr = 0x%x, size = %d\n",
@@ -90,7 +90,7 @@ static void vpu_session_handle_enc_frame_done(struct vpu_inst *inst, struct vpu_static void vpu_session_handle_frame_request (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -struct vpu_fs_info fs; +struct vpu_fs_info fs = {0 };vpu_iface_unpack_msg_data (inst->core, pkt, &fs);call_void_vop (inst, event_notify,VPU_MSG_ID_FRAME_REQ , &fs);
@@ -107,7 +107,7 @@ static void vpu_session_handle_frame_release(struct vpu_inst *inst, struct vpu_r info.type = inst->out_format.type;call_void_vop (inst, buf_done, &info); }else if (inst->core->type ==VPU_CORE_TYPE_DEC ) { -struct vpu_fs_info fs; +struct vpu_fs_info fs = {0 };vpu_iface_unpack_msg_data (inst->core, pkt, &fs);call_void_vop (inst, event_notify,VPU_MSG_ID_FRAME_RELEASE , &fs);
@@ -122,7 +122,7 @@ static void vpu_session_handle_input_done(struct vpu_inst *inst, struct vpu_rpc_static void vpu_session_handle_pic_decoded (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -struct vpu_dec_pic_info info; +struct vpu_dec_pic_info info = {0 };vpu_iface_unpack_msg_data (inst->core, pkt, (void *)&info);call_void_vop (inst, get_one_frame, &info);
@@ -130,7 +130,7 @@ static void vpu_session_handle_pic_decoded(struct vpu_inst *inst, struct vpu_rpcstatic void vpu_session_handle_pic_done (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -struct vpu_dec_pic_info info; +struct vpu_dec_pic_info info = {0 };struct vpu_frame_info frame;memset (&frame,0 ,sizeof (frame));
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 412/600 media: amphion: fix UNUSED_VALUE issue reported by coverity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit cf6a06354989c41b536be8e094561ee16223cf1f ]
assign value '-EINVAL' to ret, but the stored value is overwritten before it can be used
--- drivers/media/platform/amphion/vpu_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/amphion/vpu_cmds.c +1 -1
@@ -315,7 +315,7 @@ static int vpu_session_send_cmd(struct vpu_inst *inst, u32 id, void *data) {unsigned long key;int sync = false; -int ret = -EINVAL ; +int ret;if (inst->id <0 )return -EINVAL ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 413/600 media: amphion: ensure the bitops dont cross boundaries
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit 5bd28eae48589694ff4e5badb03bf75dae695b3f ]
the supported_instance_count determine the instance index range, it shouldn't exceed the bits number of instance_mask, otherwise the bitops of instance_mask may cross boundaries
--- drivers/media/platform/amphion/vpu_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/amphion/vpu_core.c +2 -0
@@ -88,6 +88,8 @@ static int vpu_core_boot_done(struct vpu_core *core) core->supported_instance_count =min (core->supported_instance_count, count); } +if (core->supported_instance_count >=BITS_PER_TYPE (core->instance_mask)) + core->supported_instance_count =BITS_PER_TYPE (core->instance_mask); core->fw_version = fw_version;vpu_core_set_state (core,VPU_CORE_ACTIVE );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 414/600 media: mediatek: vcodec: Return NULL if no vdec_fb is found
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Irui Wang <[email protected]>
[ Upstream commit dfa2d6e07432270330ae191f50a0e70636a4cd2b ]
"fb_use_list" is used to store used or referenced frame buffers for vp9 stateful decoder. "NULL" should be returned when getting target frame buffer failed from "fb_use_list", not a random unexpected one.
--- drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c +3 -2
@@ -226,10 +226,11 @@ static struct vdec_fb *vp9_rm_from_fb_use_list(struct vdec_vp9_instif (fb->base_y.va == addr) {list_move_tail (&node->list, &inst->available_fb_node_list); -break ; +return fb; } } -return fb; + +return NULL ; } static void vp9_add_to_fb_free_list(struct vdec_vp9_inst *inst,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 415/600 media: mediatek: vcodec: fix potential double free
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit be40f524b6edac4fb9a98ef79620fd9b9497a998 ]
The "lat_buf->private_data" needs to be set to NULL to prevent a double free. How this would happen is if vdec_msg_queue_init() failed twice in a row and on the second time it failed earlier than on the first time.
The vdec_msg_queue_init() function has a loop which does:
for (i = 0; i < NUM_BUFFER_COUNT; i++) {Each iteration initializes one element in the msg_queue->lat_buf[] array and then the clean up function vdec_msg_queue_deinit() frees each element of the msg_queue->lat_buf[] array. This clean up code relies on the assumption that every element is either initialized or zeroed. Leaving a freed pointer which is non-zero breaks the assumption.
--- drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +1 -0
@@ -246,6 +246,7 @@ void vdec_msg_queue_deinit(struct vdec_msg_queue *msg_queue,mtk_vcodec_mem_free (ctx, mem);kfree (lat_buf->private_data); + lat_buf->private_data =NULL ; } }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 416/600 media: mediatek: vcodec: fix resource leaks in vdec_msg_queue_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit cf10b0bb503c974ba049d6f888b21178be20a962 ]
If we encounter any error in the vdec_msg_queue_init() then we need to set "msg_queue->wdma_addr.size = 0;". Normally, this is done inside the vdec_msg_queue_deinit() function. However, if the first call to allocate &msg_queue->wdma_addr fails, then the vdec_msg_queue_deinit() function is a no-op. For that situation, just set the size to zero explicitly and return.
There were two other error paths which did not clean up before returning. Change those error paths to goto mem_alloc_err.
--- drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +1 -0
@@ -313,6 +313,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, err =mtk_vcodec_mem_alloc (ctx, &msg_queue->wdma_addr);if (err) {mtk_v4l2_err ("failed to allocate wdma_addr buf" ); + msg_queue->wdma_addr.size =0 ;return -ENOMEM ; } msg_queue->wdma_rptr_addr = msg_queue->wdma_addr.dma_addr;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 417/600 usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit 5eda42aebb7668b4dcff025cd3ccb0d3d7c53da6 ]
The function mxs_phy_is_otg_host() will return true if OTG_ID_VALUE is 0 at USBPHY_CTRL register. However, OTG_ID_VALUE will not reflect the real state if the ID pin is float, such as Host-only or Type-C cases. The value of OTG_ID_VALUE is always 1 which means device mode.
This patch will fix the issue by judging the current mode based on last_event. The controller will update last_event in time.
--- drivers/usb/phy/phy-mxs-usb.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +2 -8
@@ -388,14 +388,8 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)static bool mxs_phy_is_otg_host (struct mxs_phy *mxs_phy) { -void __iomem *base = mxs_phy->phy.io_priv; -u32 phyctrl =readl (base +HW_USBPHY_CTRL ); - -if (IS_ENABLED (CONFIG_USB_OTG ) && - !(phyctrl &BM_USBPHY_CTRL_OTG_ID_VALUE )) -return true; - -return false; +return IS_ENABLED (CONFIG_USB_OTG ) && + mxs_phy->phy.last_event ==USB_EVENT_ID ; }static void mxs_phy_disconnect_line (struct mxs_phy *mxs_phy,bool on)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 418/600 scsi: RDMA/srp: Fix residual handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 89e637c19b2441aabc8dbf22a8745b932fd6996e ]
Although the code for residual handling in the SRP initiator follows the SCSI documentation, that documentation has never been correct. Because scsi_finish_command() starts from the data buffer length and subtracts the residual, scsi_set_resid() must not be called if a residual overflow occurs. Hence remove the scsi_set_resid() calls from the SRP initiator if a residual overflow occurrs.
--- drivers/infiniband/ulp/srp/ib_srp.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +0 -4
@@ -1984,12 +1984,8 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp)if (unlikely (rsp->flags &SRP_RSP_FLAG_DIUNDER ))scsi_set_resid (scmnd,be32_to_cpu (rsp->data_in_res_cnt)); -else if (unlikely (rsp->flags &SRP_RSP_FLAG_DIOVER )) -scsi_set_resid (scmnd, -be32_to_cpu (rsp->data_in_res_cnt));else if (unlikely (rsp->flags &SRP_RSP_FLAG_DOUNDER ))scsi_set_resid (scmnd,be32_to_cpu (rsp->data_out_res_cnt)); -else if (unlikely (rsp->flags &SRP_RSP_FLAG_DOOVER )) -scsi_set_resid (scmnd, -be32_to_cpu (rsp->data_out_res_cnt));srp_free_req (ch, req, scmnd,be32_to_cpu (rsp->req_lim_delta));
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 419/600 scsi: iscsi: Rename iscsi_set_param() to iscsi_if_set_param()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenchao Hao <[email protected]>
[ Upstream commit 0c26a2d7c98039e913e63f9250fde738a3f88a60 ]
There are two iscsi_set_param() functions defined in libiscsi.c and scsi_transport_iscsi.c respectively which is confusing.
Rename the one in scsi_transport_iscsi.c to iscsi_if_set_param().
Stable-dep-of: 971dfcb74a80 ("scsi: iscsi: Add length check for nlattr payload")
--- drivers/scsi/scsi_transport_iscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +2 -2
@@ -3013,7 +3013,7 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev }static int -iscsi_set_param (struct iscsi_transport *transport,struct iscsi_uevent *ev) +iscsi_if_set_param (struct iscsi_transport *transport,struct iscsi_uevent *ev) {char *data = (char *)ev +sizeof (*ev);struct iscsi_cls_conn *conn;
@@ -3966,7 +3966,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) err = -EINVAL ;break ;case ISCSI_UEVENT_SET_PARAM : - err =iscsi_set_param (transport, ev); + err =iscsi_if_set_param (transport, ev);break ;case ISCSI_UEVENT_CREATE_CONN :case ISCSI_UEVENT_DESTROY_CONN :
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 420/600 scsi: iscsi: Add length check for nlattr payload
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Ma <[email protected]>
[ Upstream commit 971dfcb74a800047952f5288512b9c7ddedb050a ]
The current NETLINK_ISCSI netlink parsing loop checks every nlmsg to make sure the length is bigger than sizeof(struct iscsi_uevent) and then calls iscsi_if_recv_msg().
nlh = nlmsg_hdr(skb);
if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) ||
skb->len < nlh->nlmsg_len) {
break;
}
...
err = iscsi_if_recv_msg(skb, nlh, &group);Hence, in iscsi_if_recv_msg() the nlmsg_data can be safely converted to iscsi_uevent as the length is already checked.
However, in other cases the length of nlattr payload is not checked before the payload is converted to other data structures. One example is iscsi_set_path() which converts the payload to type iscsi_path without any checks:
params = (struct iscsi_path *)((char *)ev + sizeof(*ev));
Whereas iscsi_if_transport_conn() correctly checks the pdu_len:
pdu_len = nlh->nlmsg_len - sizeof(*nlh) - sizeof(*ev);
if ((ev->u.send_pdu.hdr_size > pdu_len) ..
err = -EINVAL;To sum up, some code paths called in iscsi_if_recv_msg() do not check the length of the data (see below picture) and directly convert the data to another data structure. This could result in an out-of-bound reads and heap dirty data leakage.
_________ nlmsg_len(nlh) _______________
/ \
+----------+--------------+---------------------------+
| nlmsghdr | iscsi_uevent | data |
+----------+--------------+---------------------------+
\ /
iscsi_uevent->u.set_param.lenFix the issue by adding the length check before accessing it. To clean up the code, an additional parameter named rlen is added. The rlen is calculated at the beginning of iscsi_if_recv_msg() which avoids duplicated calculation.
--- drivers/scsi/scsi_transport_iscsi.c | 72 +++++++++++++++++------------ 1 file changed, 43 insertions(+), 29 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +43 -29
@@ -3013,14 +3013,15 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev }static int -iscsi_if_set_param (struct iscsi_transport *transport,struct iscsi_uevent *ev) +iscsi_if_set_param (struct iscsi_transport *transport,struct iscsi_uevent *ev,u32 rlen) {char *data = (char *)ev +sizeof (*ev);struct iscsi_cls_conn *conn;struct iscsi_cls_session *session;int err =0 , value =0 , state; -if (ev->u.set_param.len >PAGE_SIZE ) +if (ev->u.set_param.len > rlen || + ev->u.set_param.len >PAGE_SIZE )return -EINVAL ; session =iscsi_session_lookup (ev->u.set_param.sid);
@@ -3117,7 +3118,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,static int iscsi_if_transport_ep (struct iscsi_transport *transport, -struct iscsi_uevent *ev,int msg_type) +struct iscsi_uevent *ev,int msg_type,u32 rlen) {struct iscsi_endpoint *ep;int rc =0 ;
@@ -3125,7 +3126,10 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,switch (msg_type) {case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST :case ISCSI_UEVENT_TRANSPORT_EP_CONNECT : - rc =iscsi_if_ep_connect (transport, ev, msg_type); +if (rlen <sizeof (struct sockaddr )) + rc = -EINVAL ; +else + rc =iscsi_if_ep_connect (transport, ev, msg_type);break ;case ISCSI_UEVENT_TRANSPORT_EP_POLL :if (!transport->ep_poll)
@@ -3149,12 +3153,15 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,static int iscsi_tgt_dscvr (struct iscsi_transport *transport, -struct iscsi_uevent *ev) +struct iscsi_uevent *ev,u32 rlen) {struct Scsi_Host *shost;struct sockaddr *dst_addr;int err; +if (rlen <sizeof (*dst_addr)) +return -EINVAL ; +if (!transport->tgt_dscvr)return -EINVAL ;
@@ -3175,7 +3182,7 @@ iscsi_tgt_dscvr(struct iscsi_transport *transport,static int iscsi_set_host_param (struct iscsi_transport *transport, -struct iscsi_uevent *ev) +struct iscsi_uevent *ev,u32 rlen) {char *data = (char *)ev +sizeof (*ev);struct Scsi_Host *shost;
@@ -3184,7 +3191,8 @@ iscsi_set_host_param(struct iscsi_transport *transport,if (!transport->set_host_param)return -ENOSYS ; -if (ev->u.set_host_param.len >PAGE_SIZE ) +if (ev->u.set_host_param.len > rlen || + ev->u.set_host_param.len >PAGE_SIZE )return -EINVAL ; shost =scsi_host_lookup (ev->u.set_host_param.host_no);
@@ -3201,12 +3209,15 @@ iscsi_set_host_param(struct iscsi_transport *transport, }static int -iscsi_set_path (struct iscsi_transport *transport,struct iscsi_uevent *ev) +iscsi_set_path (struct iscsi_transport *transport,struct iscsi_uevent *ev,u32 rlen) {struct Scsi_Host *shost;struct iscsi_path *params;int err; +if (rlen <sizeof (*params)) +return -EINVAL ; +if (!transport->set_path)return -ENOSYS ;
@@ -3266,12 +3277,15 @@ iscsi_set_iface_params(struct iscsi_transport *transport, }static int -iscsi_send_ping (struct iscsi_transport *transport,struct iscsi_uevent *ev) +iscsi_send_ping (struct iscsi_transport *transport,struct iscsi_uevent *ev,u32 rlen) {struct Scsi_Host *shost;struct sockaddr *dst_addr;int err; +if (rlen <sizeof (*dst_addr)) +return -EINVAL ; +if (!transport->send_ping)return -ENOSYS ;
@@ -3769,13 +3783,12 @@ iscsi_get_host_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh) }static int iscsi_if_transport_conn (struct iscsi_transport *transport, -struct nlmsghdr *nlh) +struct nlmsghdr *nlh,u32 pdu_len) {struct iscsi_uevent *ev =nlmsg_data (nlh);struct iscsi_cls_session *session;struct iscsi_cls_conn *conn =NULL ;struct iscsi_endpoint *ep; -uint32_t pdu_len;int err =0 ;switch (nlh->nlmsg_type) {
@@ -3860,8 +3873,6 @@ static int iscsi_if_transport_conn(struct iscsi_transport *transport,break ;case ISCSI_UEVENT_SEND_PDU : - pdu_len = nlh->nlmsg_len -sizeof (*nlh) -sizeof (*ev); -if ((ev->u.send_pdu.hdr_size > pdu_len) || (ev->u.send_pdu.data_size > (pdu_len - ev->u.send_pdu.hdr_size))) { err = -EINVAL ;
@@ -3891,6 +3902,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)struct iscsi_internal *priv;struct iscsi_cls_session *session;struct iscsi_endpoint *ep =NULL ; +u32 rlen;if (!netlink_capable (skb,CAP_SYS_ADMIN ))return -EPERM ;
@@ -3910,6 +3922,13 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) portid =NETLINK_CB (skb).portid; +/* +* Even though the remaining payload may not be regarded as nlattr, +* (like address or something else), calculate the remaining length +* here to ease following length checks. +*/ + rlen =nlmsg_attrlen (nlh,sizeof (*ev)); +switch (nlh->nlmsg_type) {case ISCSI_UEVENT_CREATE_SESSION : err = iscsi_if_create_session(priv, ep, ev,
@@ -3966,7 +3985,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) err = -EINVAL ;break ;case ISCSI_UEVENT_SET_PARAM : - err =iscsi_if_set_param (transport, ev); + err =iscsi_if_set_param (transport, ev, rlen);break ;case ISCSI_UEVENT_CREATE_CONN :case ISCSI_UEVENT_DESTROY_CONN :
@@ -3974,7 +3993,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)case ISCSI_UEVENT_START_CONN :case ISCSI_UEVENT_BIND_CONN :case ISCSI_UEVENT_SEND_PDU : - err =iscsi_if_transport_conn (transport, nlh); + err =iscsi_if_transport_conn (transport, nlh, rlen);break ;case ISCSI_UEVENT_GET_STATS : err =iscsi_if_get_stats (transport, nlh);
@@ -3983,23 +4002,22 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)case ISCSI_UEVENT_TRANSPORT_EP_POLL :case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT :case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST : - err =iscsi_if_transport_ep (transport, ev, nlh->nlmsg_type); + err =iscsi_if_transport_ep (transport, ev, nlh->nlmsg_type, rlen);break ;case ISCSI_UEVENT_TGT_DSCVR : - err =iscsi_tgt_dscvr (transport, ev); + err =iscsi_tgt_dscvr (transport, ev, rlen);break ;case ISCSI_UEVENT_SET_HOST_PARAM : - err =iscsi_set_host_param (transport, ev); + err =iscsi_set_host_param (transport, ev, rlen);break ;case ISCSI_UEVENT_PATH_UPDATE : - err =iscsi_set_path (transport, ev); + err =iscsi_set_path (transport, ev, rlen);break ;case ISCSI_UEVENT_SET_IFACE_PARAMS : - err =iscsi_set_iface_params (transport, ev, -nlmsg_attrlen (nlh,sizeof (*ev))); + err =iscsi_set_iface_params (transport, ev, rlen);break ;case ISCSI_UEVENT_PING : - err =iscsi_send_ping (transport, ev); + err =iscsi_send_ping (transport, ev, rlen);break ;case ISCSI_UEVENT_GET_CHAP : err =iscsi_get_chap (transport, nlh);
@@ -4008,13 +4026,10 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) err =iscsi_delete_chap (transport, ev);break ;case ISCSI_UEVENT_SET_FLASHNODE_PARAMS : - err =iscsi_set_flashnode_param (transport, ev, -nlmsg_attrlen (nlh, -sizeof (*ev))); + err =iscsi_set_flashnode_param (transport, ev, rlen);break ;case ISCSI_UEVENT_NEW_FLASHNODE : - err =iscsi_new_flashnode (transport, ev, -nlmsg_attrlen (nlh,sizeof (*ev))); + err =iscsi_new_flashnode (transport, ev, rlen);break ;case ISCSI_UEVENT_DEL_FLASHNODE : err =iscsi_del_flashnode (transport, ev);
@@ -4029,8 +4044,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) err =iscsi_logout_flashnode_sid (transport, ev);break ;case ISCSI_UEVENT_SET_CHAP : - err =iscsi_set_chap (transport, ev, -nlmsg_attrlen (nlh,sizeof (*ev))); + err =iscsi_set_chap (transport, ev, rlen);break ;case ISCSI_UEVENT_GET_HOST_STATS : err =iscsi_get_host_stats (transport, nlh);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 421/600 scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Ma <[email protected]>
[ Upstream commit ce51c817008450ef4188471db31639d42d37a5e1 ]
The functions iscsi_if_set_param() and iscsi_if_set_host_param() convert an nlattr payload to type char* and then call C string handling functions like sscanf and kstrdup:
char *data = (char*)ev + sizeof(*ev); ... sscanf(data, "%d", &value);
However, since the nlattr is provided by the user-space program and the nlmsg skb is allocated with GFP_KERNEL instead of GFP_ZERO flag (see netlink_alloc_large_skb() in netlink_sendmsg()), dirty data on the heap can lead to an OOB access for those string handling functions.
By investigating how the bug is introduced, we find it is really interesting as the old version parsing code starting from commit fd7255f51a13 ("[SCSI] iscsi: add sysfs attrs for uspace sync up") treated the nlattr as integer bytes instead of string and had length check in iscsi_copy_param():
if (ev->u.set_param.len != sizeof(uint32_t))
BUG();But, since the commit a54a52caad4b ("[SCSI] iscsi: fixup set/get param functions"), the code treated the nlattr as C string while forgetting to add any strlen checks(), opening the possibility of an OOB access.
Fix the potential OOB by adding the strlen() check before accessing the buf. If the data passes this check, all low-level set_param handlers can safely treat this buf as legal C string.
--- drivers/scsi/scsi_transport_iscsi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/scsi_transport_iscsi.c +8 -0
@@ -3029,6 +3029,10 @@ iscsi_if_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev, uif (!conn || !session)return -EINVAL ; +/* data will be regarded as NULL-ended string, do length check */ +if (strlen (data) > ev->u.set_param.len) +return -EINVAL ; +switch (ev->u.set_param.param) {case ISCSI_PARAM_SESS_RECOVERY_TMO :sscanf (data,"%d" , &value);
@@ -3202,6 +3206,10 @@ iscsi_set_host_param(struct iscsi_transport *transport,return -ENODEV ; } +/* see similar check in iscsi_if_set_param() */ +if (strlen (data) > ev->u.set_host_param.len) +return -EINVAL ; + err = transport->set_host_param (shost, ev->u.set_host_param.param, data, ev->u.set_host_param.len);scsi_host_put (shost);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 422/600 scsi: be2iscsi: Add length check when parsing nlattrs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Ma <[email protected]>
[ Upstream commit ee0268f230f66cb472df3424f380ea668da2749a ]
beiscsi_iface_set_param() parses nlattr with nla_for_each_attr and assumes every attributes can be viewed as struct iscsi_iface_param_info.
This is not true because there is no any nla_policy to validate the attributes passed from the upper function iscsi_set_iface_params().
Add the nla_len check before accessing the nlattr data and return EINVAL if the length check fails.
--- drivers/scsi/be2iscsi/be_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/be2iscsi/be_iscsi.c +4 -0
@@ -450,6 +450,10 @@ int beiscsi_iface_set_param(struct Scsi_Host *shost, }nla_for_each_attr (attrib, data, dt_len, rm_len) { +/* ignore nla_type as it is never used */ +if (nla_len (attrib) <sizeof (*iface_param)) +return -EINVAL ; + iface_param =nla_data (attrib);if (iface_param->param_type !=ISCSI_NET_PARAM )
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 423/600 scsi: qla4xxx: Add length check when parsing nlattrs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Ma <[email protected]>
[ Upstream commit 47cd3770e31df942e2bb925a9a855c79ed0662eb ]
There are three places that qla4xxx parses nlattrs:
- qla4xxx_set_chap_entry()
- qla4xxx_iface_set_param()
- qla4xxx_sysfs_ddb_set_param()
and each of them directly converts the nlattr to specific pointer of structure without length checking. This could be dangerous as those attributes are not validated and a malformed nlattr (e.g., length 0) could result in an OOB read that leaks heap dirty data.
Add the nla_len check before accessing the nlattr data and return EINVAL if the length check fails.
--- drivers/scsi/qla4xxx/ql4_os.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/scsi/qla4xxx/ql4_os.c +15 -0
@@ -968,6 +968,11 @@ static int qla4xxx_set_chap_entry(struct Scsi_Host *shost, void *data, int len)memset (&chap_rec,0 ,sizeof (chap_rec));nla_for_each_attr (attr, data, len, rem) { +if (nla_len (attr) <sizeof (*param_info)) { + rc = -EINVAL ; + goto exit_set_chap; + } + param_info =nla_data (attr);switch (param_info->param) {
@@ -2750,6 +2755,11 @@ qla4xxx_iface_set_param(struct Scsi_Host *shost, void *data, uint32_t len) }nla_for_each_attr (attr, data, len, rem) { +if (nla_len (attr) <sizeof (*iface_param)) { + rval = -EINVAL ; + goto exit_init_fw_cb; + } + iface_param =nla_data (attr);if (iface_param->param_type ==ISCSI_NET_PARAM ) {
@@ -8104,6 +8114,11 @@ qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,memset ((void *)&chap_tbl,0 ,sizeof (chap_tbl));nla_for_each_attr (attr, data, len, rem) { +if (nla_len (attr) <sizeof (*fnode_param)) { + rc = -EINVAL ; + goto exit_set_param; + } + fnode_param =nla_data (attr);switch (fnode_param->param) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 424/600 iio: accel: adxl313: Fix adxl313_i2c_id[] table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit f636554c4cd1c644109cc525900a056495b86cc9 ]
The .driver_data in adxl313_i2c_id[] for adxl312 and adxl314 is wrong. Fix this issue by adding corresponding adxl31x_chip_info data.
--- drivers/iio/accel/adxl313_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/accel/adxl313_i2c.c +2 -2
@@ -40,8 +40,8 @@ static const struct regmap_config adxl31x_i2c_regmap_config[] = {static const struct i2c_device_id adxl313_i2c_id[] = { { .name ="adxl312" , .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312 ] }, - { .name ="adxl313" , .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312 ] }, - { .name ="adxl314" , .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312 ] }, + { .name ="adxl313" , .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL313 ] }, + { .name ="adxl314" , .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL314 ] }, { } };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 425/600 serial: sprd: Assign sprd_port after initialized to avoid wrong access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunyan Zhang <[email protected]>
[ Upstream commit f9608f1887568b728839d006024585ab02ef29e5 ]
The global pointer 'sprd_port' may not zero when sprd_probe returns failure, that is a risk for sprd_port to be accessed afterward, and may lead to unexpected errors.
For example:
There are two UART ports, UART1 is used for console and configured in kernel command line, i.e. "console=";
The UART1 probe failed and the memory allocated to sprd_port[1] was released, but sprd_port[1] was not set to NULL;
In UART2 probe, the same virtual address was allocated to sprd_port[2], and UART2 probe process finally will go into sprd_console_setup() to register UART1 as console since it is configured as preferred console (filled to console_cmdline[]), but the console parameters (sprd_port[1]) belong to UART2.
So move the sprd_port[] assignment to where the port already initialized can avoid the above issue.
--- drivers/tty/serial/sprd_serial.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/tty/serial/sprd_serial.c +17 -8
@@ -1132,7 +1132,7 @@ static bool sprd_uart_is_console(struct uart_port *uport)static int sprd_clk_init (struct uart_port *uport) {struct clk *clk_uart, *clk_parent; -struct sprd_uart_port *u = sprd_port[uport->line]; + struct sprd_uart_port *u = container_of(uport, struct sprd_uart_port, port); clk_uart =devm_clk_get (uport->dev,"uart" );if (IS_ERR (clk_uart)) {
@@ -1175,22 +1175,22 @@ static int sprd_probe(struct platform_device *pdev) {struct resource *res;struct uart_port *up; +struct sprd_uart_port *sport;int irq;int index;int ret; index =of_alias_get_id (pdev->dev.of_node,"serial" ); -if (index <0 || index >=ARRAY_SIZE (sprd_port)) { +if (index <0 || index >=UART_NR_MAX ) {dev_err (&pdev->dev,"got a wrong serial alias id %d\n" , index);return -EINVAL ; } - sprd_port[index] =devm_kzalloc (&pdev->dev,sizeof (*sprd_port[index]), -GFP_KERNEL ); -if (!sprd_port[index]) + sport =devm_kzalloc (&pdev->dev,sizeof (*sport),GFP_KERNEL ); +if (!sport)return -ENOMEM ; - up = &sprd_port[index]->port; + up = &sport->port; up->dev = &pdev->dev; up->line = index; up->type =PORT_SPRD ;
@@ -1221,7 +1221,7 @@ static int sprd_probe(struct platform_device *pdev)* Allocate one dma buffer to prepare for receive transfer, in case * memory allocation failure at runtime. */ - ret =sprd_rx_alloc_buf (sprd_port[index]); + ret =sprd_rx_alloc_buf (sport);if (ret)return ret;
@@ -1232,14 +1232,23 @@ static int sprd_probe(struct platform_device *pdev)return ret; } } + sprd_ports_num++; + sprd_port[index] = sport; ret =uart_add_one_port (&sprd_uart_driver, up);if (ret) -sprd_remove (pdev); + goto clean_port;platform_set_drvdata (pdev, up); +return 0 ; + +clean_port: + sprd_port[index] =NULL ; +if (--sprd_ports_num ==0 ) +uart_unregister_driver (&sprd_uart_driver); +sprd_rx_free_buf (sport);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 426/600 serial: sprd: Fix DMA buffer leak issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunyan Zhang <[email protected]>
[ Upstream commit cd119fdc3ee1450fbf7f78862b5de44c42b6e47f ]
Release DMA buffer when _probe() returns failure to avoid memory leak.
--- drivers/tty/serial/sprd_serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/sprd_serial.c +3 -2
@@ -367,7 +367,7 @@ static void sprd_rx_free_buf(struct sprd_uart_port *sp)if (sp->rx_dma.virt)dma_free_coherent (sp->port.dev,SPRD_UART_RX_SIZE , sp->rx_dma.virt, sp->rx_dma.phys_addr); - + sp->rx_dma.virt =NULL ; }static int sprd_rx_dma_config (struct uart_port *port,u32 burst)
@@ -1229,7 +1229,7 @@ static int sprd_probe(struct platform_device *pdev) ret =uart_register_driver (&sprd_uart_driver);if (ret <0 ) {pr_err ("Failed to register SPRD-UART driver\n" ); -return ret; + goto free_rx_buf; } }
@@ -1248,6 +1248,7 @@ static int sprd_probe(struct platform_device *pdev) sprd_port[index] =NULL ;if (--sprd_ports_num ==0 )uart_unregister_driver (&sprd_uart_driver); +free_rx_buf:sprd_rx_free_buf (sport);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 427/600 x86/APM: drop the duplicate APM_MINOR_DEV macro
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 4ba2909638a29630a346d6c4907a3105409bee7d ]
This source file already includes <linux/miscdevice.h>, which contains the same macro. It doesn't need to be defined here again.
--- arch/x86/kernel/apm_32.c | 6 ------ 1 file changed, 6 deletions(-)
arch/x86/kernel/apm_32.c +0 -6
@@ -238,12 +238,6 @@extern int (*console_blank_hook)(int );#endif -/* -* The apm_bios device is one of the misc char devices. -* This is its minor number. -*/ -#define APM_MINOR_DEV 134 -/* * Various options can be changed at boot time as follows: * (We allow underscores for compatibility with the modules code)
Signature · 1 line
2.40.1