6.12.119-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 720/1756 ARM: mvebu: fix Cortex-A9 errata selection for Armada 38x
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 76e67df8bc1cb72157368c3669119e64cdb0a6a6 ]
Armada 38x uses Cortex-A9 r4p1, but MACH_ARMADA_38X selects the workaround for erratum 720789, which was fixed in r2p0, and omits workarounds for errata that still affect r4p1.
Drop ARM_ERRATA_720789 and select ARM_ERRATA_754322 for faulty MMU translations following an ASID switch and ARM_ERRATA_764319 for unexpected undefined instruction exceptions when reading debug registers. Also select ARM_ERRATA_764369 when SMP is enabled to work around cache maintenance by MVA failing to reach other agents.
The Cortex-A9 r4 Software Developers Errata Notice (ARM UAN 0009D) lists these errata in sections 2.3.3, 2.5.10 and 2.3.4, respectively.
--- arch/arm/mach-mvebu/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/Kconfig +3 -1
@@ -55,7 +55,9 @@ config MACH_ARMADA_375 config MACH_ARMADA_38X bool "Marvell Armada 380/385 boards" depends on ARCH_MULTI_V7 - select ARM_ERRATA_720789 + select ARM_ERRATA_754322 + select ARM_ERRATA_764319 + select ARM_ERRATA_764369 if SMP select PL310_ERRATA_753970 select ARM_GIC select ARM_GLOBAL_TIMER
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 721/1756 ice: skip stats handling for channel VSIs on rebuild
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemek Kitszel <[email protected]>
[ Upstream commit 3fca849c965333f387aa02dca02326ce3abd1305 ]
ice_vsi_alloc_stat_arrays() returns early for ICE_VSI_CHNL, so a channel VSI never gets an entry in pf->vsi_stats[]. ice_vsi_realloc_stat_arrays() dereferences that entry unconditionally, and ice_vsi_rebuild() calls it before anything else, so the NULL is not filtered out anywhere.
The path is live. ice_prepare_for_reset() removes the queue channels only for resets other than a PFR, so a PFR leaves the channel VSIs in place, and ice_rebuild() then calls ice_rebuild_channels(), which rebuilds every ICE_VSI_CHNL VSI it finds. A PF reset with ADQ (mqprio hardware offload) configured thus dereferences NULL.
That combination is reset recovery on top of an active mqprio offload, which is why it went unnoticed. It was found while refactoring this code, not reported by a user.
I'm leaning towards removing our limited (compared to OOT ADQ) support, but it's outside of this series. Bug could be triggered by:
tc qdisc del dev "$IF" root 2>/dev/null || true
tc qdisc add dev "$IF" root mqprio num_tc 2 \
map 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \
queues 2@0 2@2 hw 1 mode channel
sleep 3
ethtool --reset "$IF" irq dma filter offload
Workqueue: ice ice_service_task [ice] RIP: 0010:ice_vsi_rebuild+0x289/0x380 [ice] ice_rebuild_channels+0xd6/0x320 [ice] ice_rebuild+0x4f6/0x540 [ice] ice_do_reset+0x9f/0x1a0 [ice] ice_service_task+0x4a/0x460 [ice]
--- drivers/net/ethernet/intel/ice/ice_lib.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
@@ -2961,6 +2961,10 @@ ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi)u16 prev_rxq = vsi->alloc_rxq;int i; +/* channel VSIs have no entry in pf->vsi_stats[] */ +if (vsi->type ==ICE_VSI_CHNL ) +return 0 ; + vsi_stat = pf->vsi_stats[vsi->idx];if (req_txq < prev_txq) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 722/1756 drm/msm: Properly handle msm_ioremap() without name
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 14fe0ea79e0e25efc603f6f4bc81cb5b813f0e69 ]
msm_ioremap() accepts being called without name of the region to map and in such case maps by index 0. However error paths still use the name in error message.
Patchwork: https://patchwork.freedesktop.org/patch/752660/
--- drivers/gpu/drm/msm/msm_io_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_io_utils.c +4 -2
@@ -77,7 +77,8 @@ static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *nameif (!res) {if (!quiet) -DRM_DEV_ERROR (&pdev->dev,"failed to get memory resource: %s\n" , name); +DRM_DEV_ERROR (&pdev->dev,"failed to get memory resource: %s\n" , + (name ?:"#0" ));return ERR_PTR (-EINVAL ); }
@@ -86,7 +87,8 @@ static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name ptr =devm_ioremap (&pdev->dev, res->start, size);if (!ptr) {if (!quiet) -DRM_DEV_ERROR (&pdev->dev,"failed to ioremap: %s\n" , name); +DRM_DEV_ERROR (&pdev->dev,"failed to ioremap: %s\n" , + (name ?:"#0" ));return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 723/1756 dt-bindings: display/msm: hdmi: Correct name of disallowed supplies
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 3309f5c888602c647f50c1921c9b60759fa86c21 ]
There are no properties in DTS or Linux drivers called "core-vcc-supplies" or "hdmi-mux-supplies", so the binding probably wanted "-supply" properties instead (which are defined in the top-level properties of the binding).
Patchwork: https://patchwork.freedesktop.org/patch/752661/
--- Documentation/devicetree/bindings/display/msm/hdmi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/msm/hdmi.yaml +2 -2
@@ -128,7 +128,7 @@ allOf: - const: core - const: master_iface - const: slave_iface - core-vcc-supplies: false + core-vcc-supply: false - if: properties:
@@ -151,7 +151,7 @@ allOf: - const: core - const: alt_iface - const: extp - hdmi-mux-supplies: false + hdmi-mux-supply: false - if: properties:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 724/1756 drm/msm/mdp5: drop cursor pipe for msm8x76
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit c33cee4c07f1533ad48ed8e3eef75df57edf44c1 ]
The MSM8976/56 family of platforms doe't have a separate cursor plane. Instead the cursor is a part of the LM block. Drop the erroneously added pipe configuration, letting LM to provide a legacy cursor instead.
Patchwork: https://patchwork.freedesktop.org/patch/753150/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c +0 -9
@@ -787,15 +787,6 @@ static const struct mdp5_cfg_hw msm8x76_config = {MDP_PIPE_CAP_SW_PIX_EXT | 0, }, - .pipe_cursor = { - .count = 1, - .base = { 0x440DC }, - .caps =MDP_PIPE_CAP_HFLIP | -MDP_PIPE_CAP_VFLIP | -MDP_PIPE_CAP_SW_PIX_EXT | -MDP_PIPE_CAP_CURSOR | - 0, - }, .lm = { .count = 2, .base = { 0x44000, 0x45000 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 725/1756 drm/msm/dp: Initialize the debugfs connector pointer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xilin Wu <[email protected]>
[ Upstream commit c2f772ec52898a3f6967d17035da7b739465f81c ]
The debugfs cleanup removed the connector assignment from the debug context, but the video-pattern test files still dereference that pointer to check connector status. Reading those files can therefore dereference NULL.
Store the supplied connector before creating the debugfs files.
Patchwork: https://patchwork.freedesktop.org/patch/757261/
--- drivers/gpu/drm/msm/dp/dp_debug.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/dp/dp_debug.c +1 -0
@@ -215,6 +215,7 @@ int dp_debug_init(struct device *dev, struct dp_panel *panel, debug->link = link; debug->panel = panel; + debug->connector = connector;debugfs_create_file ("dp_debug" ,0444 , root, debug, &dp_debug_fops);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 726/1756 staging: sm750fb: free cmap on framebuffer release
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Costa <[email protected]>
[ Upstream commit b7c885194b81a0376d1fdb457eac40d21d6fb65f ]
The cmap is allocated by lynxfb_set_fbinfo() but never freed, so it is leaked when the framebuffer is torn down. This happens on every unbind, and on the register_framebuffer() error path in sm750fb_framebuffer_alloc().
Add a lynxfb_unset_fbinfo() cleanup counterpart to lynxfb_set_fbinfo() which deallocates the cmap, and call it on teardown. In the alloc error path it is only called once lynxfb_set_fbinfo() has succeeded, so the cmap is only freed when it was actually allocated.
--- drivers/staging/sm750fb/sm750.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +9 -1
@@ -906,6 +906,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)return ret; } +static void lynxfb_unset_fbinfo (struct fb_info *info) +{ +fb_dealloc_cmap (&info->cmap); +} +/* chip specific g_option configuration routine */ static void sm750fb_setup (struct sm750_dev *sm750_dev,char *src) {
@@ -992,6 +997,7 @@ static void sm750fb_framebuffer_release(struct sm750_dev *sm750_dev)while (sm750_dev->fb_count) { fb_info = sm750_dev->fbinfo[sm750_dev->fb_count -1 ];unregister_framebuffer (fb_info); +lynxfb_unset_fbinfo (fb_info);framebuffer_release (fb_info); sm750_dev->fb_count--; }
@@ -1018,12 +1024,14 @@ static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) err =register_framebuffer (fb_info);if (err <0 ) - goto release_fb; + goto unset_fb; sm750_dev->fb_count++;return 0 ; +unset_fb: +lynxfb_unset_fbinfo (fb_info); release_fb:framebuffer_release (fb_info);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 727/1756 OPP: Fix the return value in dev_pm_opp_get_of_node() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 706081c6b9327dd611dd72b20130a77f0f059b6e ]
dev_pm_opp_get_of_node() returns NULL when the OPP is invalid, but its kernel-doc says "else 0 on success", which was never true. Say NULL.
--- drivers/opp/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +1 -1
@@ -1482,7 +1482,7 @@ bool dev_pm_opp_of_has_required_opp(struct device *dev)* dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp * @opp: opp for which DT node has to be returned for * -* Return: DT node corresponding to the opp, else 0 on success. +* Return: DT node corresponding to the opp, else NULL. * * The caller needs to put the node with of_node_put() after using it. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 728/1756 drm/imx/lcdc: avoid duplicate clk_per enable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ze Huang <[email protected]>
[ Upstream commit b08f4d9b21a7846b91bb6c4064f58c3a7ab997c7 ]
The simple-KMS helper calls the pipe update after enabling the CRTC. On an enable commit, imx_lcdc_pipe_enable() already programs the mode and enables clk_per. The following pipe update sees the plane move from no CRTC to the active CRTC, treats it as a mode update, and calls imx_lcdc_update_hw_registers() again.
That second call has no old CRTC state to disable clk_per first, but it enables clk_per again at the end. The disable path only drops one reference, leaving clk_per enabled after each on/off cycle.
Skip the register update from the pipe update path when the CRTC already needs a modeset. The enable path has already programmed the hardware for that commit; keep the event handling in pipe update unchanged.
--- drivers/gpu/drm/imx/lcdc/imx-lcdc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/lcdc/imx-lcdc.c +2 -1
@@ -309,7 +309,8 @@ static void imx_lcdc_pipe_update(struct drm_simple_display_pipe *pipe,else if (old_crtc != crtc) mode_changed = true; -imx_lcdc_update_hw_registers (pipe, old_state, mode_changed); +if (!drm_atomic_crtc_needs_modeset (crtc->state)) +imx_lcdc_update_hw_registers (pipe, old_state, mode_changed);if (event) { crtc->state->event =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 729/1756 rtc: ftrtc010: drop needless struct ftrtc010_rtc::rtc_dev member
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
[ Upstream commit a55d44807b63f171f8079d770c9d82fa87046cdd ]
The memory pointed to by the ::rtc_dev member is managed via devres, and no code in this driver uses it past _probe().
We can drop it from the structure and just use a local temporary variable, reducing runtime memory consumption by a few bytes.
Stable-dep-of: c60478875a44 ("rtc: ftrtc010: fix clock resource leak on probe failure")
--- drivers/rtc/rtc-ftrtc010.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/rtc/rtc-ftrtc010.c +8 -9
@@ -28,7 +28,6 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("platform:" DRV_NAME );struct ftrtc010_rtc { -struct rtc_device *rtc_dev;void __iomem *rtc_base;int rtc_irq;struct clk *pclk;
@@ -113,6 +112,7 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)struct ftrtc010_rtc *rtc;struct device *dev = &pdev->dev;struct resource *res; +struct rtc_device *rtc_dev;int ret; rtc =devm_kzalloc (&pdev->dev,sizeof (*rtc),GFP_KERNEL );
@@ -160,29 +160,28 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) goto err_disable_extclk; } - rtc->rtc_dev =devm_rtc_allocate_device (dev); -if (IS_ERR (rtc->rtc_dev)) { - ret =PTR_ERR (rtc->rtc_dev); + rtc_dev =devm_rtc_allocate_device (dev); +if (IS_ERR (rtc_dev)) { + ret =PTR_ERR (rtc_dev); goto err_disable_extclk; } - rtc->rtc_dev->ops = &ftrtc010_rtc_ops; + rtc_dev->ops = &ftrtc010_rtc_ops; sec =readl (rtc->rtc_base +FTRTC010_RTC_SECOND ); min =readl (rtc->rtc_base +FTRTC010_RTC_MINUTE ); hour =readl (rtc->rtc_base +FTRTC010_RTC_HOUR ); days =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); - rtc->rtc_dev->range_min = (u64 )days *86400 + hour *3600 + - min *60 + sec; - rtc->rtc_dev->range_max =U32_MAX + rtc->rtc_dev->range_min; + rtc_dev->range_min = (u64 )days *86400 + hour *3600 + min *60 + sec; + rtc_dev->range_max =U32_MAX + rtc_dev->range_min; ret =devm_request_irq (dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,IRQF_SHARED , pdev->name, dev);if (unlikely (ret)) goto err_disable_extclk; -return devm_rtc_register_device (rtc->rtc_dev); +return devm_rtc_register_device (rtc_dev); err_disable_extclk:clk_disable_unprepare (rtc->extclk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 730/1756 rtc: ftrtc010: fix clock resource leak on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit c60478875a445dee1206aad6285c18cd8c91f7f2 ]
When devm_rtc_register_device() fails, ftrtc010_rtc_probe() returns the error directly without releasing clocks obtained via clk_prepare_enable(). This leaks both extclk and pclk resources, which may prevent subsequent probe attempts or module removal.
Capture the return value and jump to the error handling path to properly release clocks via clk_disable_unprepare().
Fixes smatch warnings:
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->extclk' from clk_prepare_enable() not released on lines: 183.
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->pclk' from clk_prepare_enable() not released on lines: 183.
--- drivers/rtc/rtc-ftrtc010.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ftrtc010.c +5 -1
@@ -181,7 +181,11 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)if (unlikely (ret)) goto err_disable_extclk; -return devm_rtc_register_device (rtc_dev); + ret =devm_rtc_register_device (rtc_dev); +if (ret) + goto err_disable_extclk; + +return 0 ; err_disable_extclk:clk_disable_unprepare (rtc->extclk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 731/1756 rtc: ftrtc010: use devm clock APIs to fix use-after-disable in remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit d41ee317c9907d714014d0d5e4726fbd6acf338e ]
The driver mixes devm_rtc_register_device() with manual clock disabling in ftrtc010_rtc_remove(). Because the RTC device was registered via devm, it remains registered until devres cleanup runs after .remove() returns. An unprivileged process holding an open /dev/rtc0 file descriptor could issue ioctl(RTC_RD_TIME) during this window, triggering MMIO reads on clock-gated hardware and causing a synchronous external abort.
Replace devm_clk_get() + clk_prepare_enable() with devm_clk_get_enabled() to tie clock lifecycle to devres. Remove the manual .remove() callback and the corresponding error handling labels in ftrtc010_rtc_probe().
--- drivers/rtc/rtc-ftrtc010.c | 67 +++++++++----------------------------- 1 file changed, 16 insertions(+), 51 deletions(-)
drivers/rtc/rtc-ftrtc010.c +16 -51
@@ -120,51 +120,33 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)return -ENOMEM ;platform_set_drvdata (pdev, rtc); - rtc->pclk =devm_clk_get (dev,"PCLK" ); -if (IS_ERR (rtc->pclk)) { + rtc->pclk =devm_clk_get_enabled (dev,"PCLK" ); +if (IS_ERR_OR_NULL (rtc->pclk)) {dev_err (dev,"could not get PCLK\n" ); - }else { - ret =clk_prepare_enable (rtc->pclk); -if (ret) { -dev_err (dev,"failed to enable PCLK\n" ); -return ret; - } +return PTR_ERR_OR_ZERO (rtc->pclk); } - rtc->extclk =devm_clk_get (dev,"EXTCLK" ); -if (IS_ERR (rtc->extclk)) { + rtc->extclk =devm_clk_get_enabled (dev,"EXTCLK" ); +if (IS_ERR_OR_NULL (rtc->extclk)) {dev_err (dev,"could not get EXTCLK\n" ); - }else { - ret =clk_prepare_enable (rtc->extclk); -if (ret) { -dev_err (dev,"failed to enable EXTCLK\n" ); - goto err_disable_pclk; - } +return PTR_ERR_OR_ZERO (rtc->extclk); } rtc->rtc_irq =platform_get_irq (pdev,0 ); -if (rtc->rtc_irq <0 ) { - ret = rtc->rtc_irq; - goto err_disable_extclk; - } +if (rtc->rtc_irq <0 ) +return rtc->rtc_irq; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { - ret = -ENODEV ; - goto err_disable_extclk; - } +if (!res) +return -ENODEV ; rtc->rtc_base =devm_ioremap (dev, res->start,resource_size (res)); -if (!rtc->rtc_base) { - ret = -ENOMEM ; - goto err_disable_extclk; - } +if (!rtc->rtc_base) +return -ENOMEM ; rtc_dev =devm_rtc_allocate_device (dev); -if (IS_ERR (rtc_dev)) { - ret =PTR_ERR (rtc_dev); - goto err_disable_extclk; - } +if (IS_ERR (rtc_dev)) +return PTR_ERR (rtc_dev); rtc_dev->ops = &ftrtc010_rtc_ops;
@@ -179,29 +161,13 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) ret =devm_request_irq (dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,IRQF_SHARED , pdev->name, dev);if (unlikely (ret)) - goto err_disable_extclk; +return ret; ret =devm_rtc_register_device (rtc_dev);if (ret) - goto err_disable_extclk; +return ret;return 0 ; - -err_disable_extclk: -clk_disable_unprepare (rtc->extclk); -err_disable_pclk: -clk_disable_unprepare (rtc->pclk); -return ret; -} - -static void ftrtc010_rtc_remove (struct platform_device *pdev) -{ -struct ftrtc010_rtc *rtc =platform_get_drvdata (pdev); - -if (!IS_ERR (rtc->extclk)) -clk_disable_unprepare (rtc->extclk); -if (!IS_ERR (rtc->pclk)) -clk_disable_unprepare (rtc->pclk); }static const struct of_device_id ftrtc010_rtc_dt_match[] = {
@@ -217,7 +183,6 @@ static struct platform_driver ftrtc010_rtc_driver = { .of_match_table = ftrtc010_rtc_dt_match, }, .probe = ftrtc010_rtc_probe, - .remove = ftrtc010_rtc_remove, };module_platform_driver_probe (ftrtc010_rtc_driver, ftrtc010_rtc_probe);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 732/1756 ARM: vexpress: fix device_node refcount leak in vexpress_flags_set()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit 62b9ae8ae4a7f0b93efa1efa230782b37057b1e7 ]
vexpress_flags_set() obtains a reference to the "arm,vexpress-sysreg" device node via of_find_compatible_node() and passes it to of_iomap(), but never calls of_node_put() on it. of_iomap() only reads the node's reg property to create the mapping and does not take ownership, so the node reference is leaked. The function runs from the __init SMP prepare path and caches the mapping in a static, so this is a one-shot leak of a single refcount during boot, with no functional impact.
The lookup was added to drivers/mfd/vexpress-sysreg.c by the commit below and later moved here by commit 9b06fc39084e ("ARM: vexpress: Move vexpress_flags_set() into arch code").
Annotate node with the __free(device_node) cleanup attribute so the reference is released when it goes out of scope.
Found by static analysis tool CodeQL.
--- arch/arm/mach-versatile/v2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-versatile/v2m.c +2 -2
@@ -13,8 +13,8 @@ void vexpress_flags_set(u32 data)static void __iomem *base;if (!base) { -struct device_node *node =of_find_compatible_node (NULL ,NULL , -"arm,vexpress-sysreg" ); + struct device_node *node __free(device_node) = +of_find_compatible_node (NULL ,NULL ,"arm,vexpress-sysreg" ); base =of_iomap (node,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 733/1756 ARM: vexpress: fix device_node refcount leak in vexpress_smp_dt_prepare_cpus()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit 27b98d331f1dcebe088ab51a7061a387a7440cb2 ]
vexpress_smp_dt_prepare_cpus() obtains a reference to the SCU device node via of_find_matching_node() and passes it to of_iomap(), but never calls of_node_put() on it. of_iomap() does not take ownership of the node, so the reference is leaked. The function is the .smp_prepare_cpus hook invoked once from the __init SMP bring-up path, so this is a one-shot leak of a single refcount during boot, with no functional impact.
Annotate scu with the __free(device_node) cleanup attribute so the reference is released when the function returns.
Found while reviewing a CodeQL report for vexpress_flags_set() on the same SMP bring-up path.
--- arch/arm/mach-versatile/platsmp-vexpress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-versatile/platsmp-vexpress.c +2 -2
@@ -61,8 +61,8 @@ static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {static void __init vexpress_smp_dt_prepare_cpus (unsigned int max_cpus) { -struct device_node *scu =of_find_matching_node (NULL , - vexpress_smp_dt_scu_match); + struct device_node *scu __free(device_node) = +of_find_matching_node (NULL , vexpress_smp_dt_scu_match);if (scu)scu_enable (of_iomap (scu,0 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 734/1756 arm64: dts: st: fix sai3b unit address on stm32mp231
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Nowicki <[email protected]>
[ Upstream commit 4b14dbc4c636e760f5db5a2e4e1b4589d484a7d2 ]
The unit address of the sai3b node, 502b0024, is the address of the SAI_BCR1 register in the secure alias of SAI3. The reg property of the node translates to the non-secure address 0x402b0024, which all other SAI nodes use. Fix the unit address to match.
--- arch/arm64/boot/dts/st/stm32mp231.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -1
@@ -557,7 +557,7 @@ sai3a: audio-controller@402b0004 { status = "disabled"; }; - sai3b: audio-controller@502b0024 { + sai3b: audio-controller@402b0024 { compatible = "st,stm32-sai-sub-b"; reg = <0x24 0x20>; #sound-dai-cells = <0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 735/1756 seg6: fix HMAC validation when an extension header precedes the SRH
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuya Kusakabe <[email protected]>
[ Upstream commit f9cb4d296d81adb0923546ca5d54fae57a81af52 ]
seg6_hmac_validate_skb() derived the SRH from skb_transport_header(). That only holds while the two coincide, which is not true on the seg6_local input path.
ip6_rcv_core() leaves the transport header just past the IPv6 header. A Hop-by-Hop options header is consumed before the route lookup and advances it, but a Destination Options header is not: the seg6_local lwtunnel is entered through an input redirect from the route lookup, which bypasses the extension header handlers. The transport header then still points at the Destination Options header while seg6_get_srh() has located the real SRH further down the chain.
The HMAC is therefore computed over the Destination Options header, and a packet carrying a valid HMAC TLV is dropped when seg6_require_hmac is set. Such a packet is legitimate: RFC 8200 allows Destination Options before a routing header, and get_srh() has walked the header chain since commit 5829d70b0b6c ("ipv6: sr: fix get_srh() to comply with IPv6 standard "RFC 8200"").
With a Fragment or an Authentication header in front of the SRH, the same mistake also reads past the data pulled by seg6_get_srh(). This happens before seg6_require_hmac is read, so the default configuration is affected.
Reproduce by giving a node a seg6local End SID with net.ipv6.conf.<dev>.seg6_require_hmac=1 and a key installed with "ip sr hmac set <keyid> sha1", then sending
IPv6 -> Destination Options -> SRH (carrying a valid HMAC TLV) -> payload
to that SID: it is dropped, while the same packet without the Destination Options header passes.
--- include/net/seg6_hmac.h | 3 ++- net/ipv6/exthdrs.c | 2 +- net/ipv6/seg6_hmac.c | 5 +---- net/ipv6/seg6_local.c | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-)
include/net/seg6_hmac.h +2 -1
@@ -48,7 +48,8 @@ extern int seg6_hmac_info_add(struct net *net, u32 key,extern int seg6_hmac_info_del (struct net *net,u32 key);extern int seg6_push_hmac (struct net *net,struct in6_addr *saddr,struct ipv6_sr_hdr *srh); -extern bool seg6_hmac_validate_skb (struct sk_buff *skb); +extern bool seg6_hmac_validate_skb (struct sk_buff *skb, +struct ipv6_sr_hdr *srh);#ifdef CONFIG_IPV6_SEG6_HMAC extern int seg6_hmac_init (void );extern void seg6_hmac_exit (void );
net/ipv6/exthdrs.c +1 -1
@@ -390,7 +390,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev) }#ifdef CONFIG_IPV6_SEG6_HMAC -if (!seg6_hmac_validate_skb (skb)) { +if (!seg6_hmac_validate_skb (skb, hdr)) {kfree_skb (skb);return -1 ; }
net/ipv6/seg6_hmac.c +1 -4
@@ -234,13 +234,12 @@ EXPORT_SYMBOL(seg6_hmac_compute);* * called with rcu_read_lock() */ -bool seg6_hmac_validate_skb (struct sk_buff *skb) +bool seg6_hmac_validate_skb (struct sk_buff *skb,struct ipv6_sr_hdr *srh) {u8 hmac_output[SEG6_HMAC_FIELD_LEN ];struct net *net =dev_net (skb->dev);struct seg6_hmac_info *hinfo;struct sr6_tlv_hmac *tlv; -struct ipv6_sr_hdr *srh;struct inet6_dev *idev;int require_hmac;
@@ -248,8 +247,6 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)if (!idev)return false; - srh = (struct ipv6_sr_hdr *)skb_transport_header (skb); - tlv =seg6_get_tlv_hmac (srh); require_hmac =READ_ONCE (idev->cnf.seg6_require_hmac);
net/ipv6/seg6_local.c +3 -3
@@ -222,7 +222,7 @@ static struct ipv6_sr_hdr *get_and_validate_srh(struct sk_buff *skb)return NULL ;#ifdef CONFIG_IPV6_SEG6_HMAC -if (!seg6_hmac_validate_skb (skb)) +if (!seg6_hmac_validate_skb (skb, srh))return NULL ;#endif
@@ -239,7 +239,7 @@ static bool decap_and_validate(struct sk_buff *skb, int proto)return false;#ifdef CONFIG_IPV6_SEG6_HMAC -if (srh && !seg6_hmac_validate_skb (skb)) +if (srh && !seg6_hmac_validate_skb (skb, srh))return false;#endif
@@ -768,7 +768,7 @@ static int end_flv8986_core(struct sk_buff *skb, struct seg6_local_lwt *slwt) srhoff = srh ? ((unsigned char *)srh - skb->data) :0 ; pinfo =seg6_get_srh_pktinfo (srh);#ifdef CONFIG_IPV6_SEG6_HMAC -if (srh && !seg6_hmac_validate_skb (skb)) +if (srh && !seg6_hmac_validate_skb (skb, srh)) goto drop;#endif flvmask = finfo->flv_ops;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 736/1756 amt: pull the AMT header behind the transport header in amt_parse_type()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Omar Ramadan <[email protected]>
[ Upstream commit eb0c18404c8943356f4aa164e5db9067b79ea93c ]
A gateway's encap socket passes ICMP errors to amt_err_lookup(), which calls amt_parse_type() on the quoted datagram to see which AMT message failed. On that path skb->data points at the quoted IP header and the transport header at the quoted UDP header, and icmp_socket_deliver() only guarantees the quoted IP header plus 8 bytes, that is, up to the end of the UDP header.
amt_parse_type() pulls sizeof(struct udphdr) + sizeof(struct amt_header) bytes from skb->data, which on this path stays inside the quoted IP header, and then reads the AMT header behind udp_hdr(skb). An ICMP error that quotes only the IP and UDP headers of a Request, the minimum RFC 792 asks for, therefore makes it read past the pulled data, and past the end of the packet when nothing follows.
Pull up to the transport header plus the UDP and AMT headers, as vxlan_err_lookup() does. amt_rcv() is called with the transport header at skb->data, so the pull on the receive path does not change.
--- drivers/net/amt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/amt.c +6 -2
@@ -1284,8 +1284,12 @@ static int amt_parse_type(struct sk_buff *skb) {struct amt_header *amth; -if (!pskb_may_pull (skb,sizeof (struct udphdr ) + -sizeof (struct amt_header ))) +/* skb->data is the UDP header on receive, but the quoted IP header +* when amt_err_lookup() parses an ICMP error, so pull up to the +* transport header rather than from skb->data. +*/ +if (!pskb_may_pull (skb,skb_transport_offset (skb) + +sizeof (struct udphdr ) +sizeof (struct amt_header )))return -1 ; amth = (struct amt_header *)(udp_hdr (skb) +1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 737/1756 misc: enclosure: fix UAF on device_register() failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 0f3b12bab74e13a2b8686a49c5b83099da61e032 ]
After device_register() fails, the embedded struct device has already been initialized and must be released with put_device() so that enclosure_release() can drop the parent reference and free edev.
The error path currently does put_device(parent) + kfree(edev), which skips the device lifetime rules and can free the object while the device core still owns a reference (use-after-free).
--- drivers/misc/enclosure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/enclosure.c +1 -2
@@ -147,8 +147,7 @@ enclosure_register(struct device *dev, const char *name, int components,return edev; err: -put_device (edev->edev.parent); -kfree (edev); +put_device (&edev->edev);return ERR_PTR (err); }EXPORT_SYMBOL_GPL (enclosure_register);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 738/1756 misc: nsm: mark device ready before registering the hwrng and misc device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jasper Wise <[email protected]>
[ Upstream commit e15596e84c818a2b727d2a7cf742a29331e44c43 ]
nsm_device_probe() registers an hwrng provider and /dev/nsm. hwrng_register() can make this the current RNG, and the hwrng fill kthread finds it through the RCU-protected get_current_rng() rather than under the rng_mutex that hwrng_register() holds, so it can be in nsm_rng_read() offering buffers and kicking the queue before probe has returned.
The driver never calls virtio_device_ready(), so DRIVER_OK is set on its behalf by virtio_dev_probe(), only once probe has returned. The virtio spec is explicit about that ordering in 3.1 Device Initialization:
| The driver MUST NOT send any buffer available notifications to the | device before setting DRIVER_OK.
A device that waits for DRIVER_OK before servicing the queue therefore leaves that read unanswered.
Set DRIVER_OK once the virtqueue exists and before either interface is registered, so that the queue is usable by the time anything that can reach it is published; commit f5866db64f34 ("virtio_console: enable VQs early") and commit 1d774589f924 ("i2c: virtio: mark device ready before registering the adapter") do the same for the same reason. The err_hwrng and err_misc paths then unwind a device that is live, so reset it before deleting the virtqueue - the core only adds VIRTIO_CONFIG_S_FAILED to the status when probe fails, it does not reset.
--- drivers/misc/nsm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/nsm.c +3 -0
@@ -440,6 +440,8 @@ static int nsm_device_probe(struct virtio_device *vdev)mutex_init (&nsm->lock); +virtio_device_ready (vdev); +/* Register as hwrng provider */ nsm->hwrng = (struct hwrng ) { .read = nsm_rng_read,
@@ -472,6 +474,7 @@ static int nsm_device_probe(struct virtio_device *vdev) err_misc:hwrng_unregister (&nsm->hwrng); err_hwrng: +virtio_reset_device (vdev); vdev->config->del_vqs (vdev); err_init_vq:return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 739/1756 misc: nsm: fix CBOR short-length decoding
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 6edddc1d101bfd5cafc94ca2dffaf13e4394662d ]
CBOR encodes byte-string lengths from 0 through 23 directly in the additional-information field. cbor_object_get_array() only handles 23, so shorter byte strings leave array_len uninitialized. Reserved values 28 through 30 and the unsupported indefinite-length encoding also fall through without assigning it.
parse_resp_get_random() then uses the indeterminate value for bounds checking and as the byte count returned to the hwrng core. This can reject a valid short response or report an incorrect amount of entropy.
Decode the complete inline-length range and reject unsupported values. Extended definite-length encodings retain their existing behavior, and the existing size and INT_MAX checks continue to bound the returned slice.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/misc/nsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/nsm.c +3 -1
@@ -117,7 +117,7 @@ static int cbor_object_get_array(u8 *cbor_object, size_t cbor_object_size, u8 ** array_len_p = &cbor_object[1 ];switch (cbor_short_size) { -case CBOR_SHORT_SIZE_MAX_VALUE :/* short encoding */ + case 0 ... CBOR_SHORT_SIZE_MAX_VALUE: /* short encoding */ array_len = cbor_short_size;break ;case CBOR_LONG_SIZE_U8 :
@@ -132,6 +132,8 @@ static int cbor_object_get_array(u8 *cbor_object, size_t cbor_object_size, u8 **case CBOR_LONG_SIZE_U64 : array_len =be64_to_cpup ((__be64 *)array_len_p);break ; +default : +return -EFAULT ; }if (cbor_object_size < array_offset)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 740/1756 debugfs: make debugfs_create_str() read-only
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 5ec78be9552035e1e71de218f968c03c44181bf0 ]
debugfs_create_str() supports replacing the backing string from userspace. Concurrent writers can race and free the same old string twice.
All writable in-tree users have been converted to local file operations. Remove the generic write support from debugfs_create_str(), and refuse to create a file when the caller passes write permission bits.
This makes unsupported writable use visible instead of silently creating a file with different permissions.
--- fs/debugfs/file.c | 81 ++++++----------------------------------------- 1 file changed, 10 insertions(+), 71 deletions(-)
fs/debugfs/file.c +10 -71
@@ -992,98 +992,37 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,return ret; } -static ssize_t debugfs_write_file_str (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct dentry *dentry =F_DENTRY (file); -char *old, *new =NULL ; -int pos = *ppos; -int r; - - r =debugfs_file_get (dentry); -if (unlikely (r)) -return r; - - old = *(char **)file->private_data; - -/* only allow strict concatenation */ - r = -EINVAL ; -if (pos && pos !=strlen (old)) - goto error; - - r = -E2BIG ; -if (pos + count +1 >PAGE_SIZE ) - goto error; - - r = -ENOMEM ; - new =kmalloc (pos + count +1 ,GFP_KERNEL ); -if (!new) - goto error; - -if (pos) -memcpy (new, old, pos); - - r = -EFAULT ; -if (copy_from_user (new + pos, user_buf, count)) - goto error; - - new[pos + count] ='\0' ; -strim (new); - -rcu_assign_pointer (*(char __rcu **)file->private_data, new); -synchronize_rcu (); -kfree (old); - -debugfs_file_put (dentry); -return count; - -error: -kfree (new); -debugfs_file_put (dentry); -return r; -} -static const struct file_operations fops_str = { .read = debugfs_read_file_str, - .write = debugfs_write_file_str, - .open = simple_open, - .llseek = default_llseek, -}; - -static const struct file_operations fops_str_ro = { - .read = debugfs_read_file_str, - .open = simple_open, - .llseek = default_llseek, -}; - -static const struct file_operations fops_str_wo = { - .write = debugfs_write_file_str, .open = simple_open, .llseek = default_llseek, };/** -* debugfs_create_str - create a debugfs file that is used to read and write a string value +* debugfs_create_str - create a debugfs file that is used to read a string value * @name: a pointer to a string containing the name of the file to create. * @mode: the permission that the file should have * @parent: a pointer to the parent dentry for this file. This should be a * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. -* @value: a pointer to the variable that the file should read to and write -* from. This pointer and the string it points to must not be %NULL. +* @value: a pointer to the variable that the file should read from. This +* pointer and the string it points to must not be %NULL. * * This function creates a file in debugfs with the given name that -* contains the value of the variable @value. If the @mode variable is so -* set, it can be read from, and written to. +* contains the value of the variable @value. The file can be read from. +* Writable files are not supported; if @mode contains write permission bits, +* no file is created. */ void debugfs_create_str (const char *name,umode_t mode,struct dentry *parent,char **value) {if (WARN_ON (!value || !*value))return ; +if (WARN (mode &0222 , +"%s() does not support writable files\n" , __func__)) +return ; -debugfs_create_mode_unsafe (name, mode, parent, value, &fops_str, - &fops_str_ro, &fops_str_wo); +debugfs_create_file_unsafe (name, mode, parent, value, &fops_str); }EXPORT_SYMBOL_GPL (debugfs_create_str);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 741/1756 ASoC: rt712: avoid duplicate reset in io_init
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuming Fan <[email protected]>
[ Upstream commit 923ff8155ef6e83b73b852300d50f2053b969552 ]
The codec should be reset only once during io_init, regardless of whether the system performs a warm or cold reboot.
--- sound/soc/codecs/rt712-sdca.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/codecs/rt712-sdca.c +3 -2
@@ -1834,7 +1834,8 @@ int rt712_sdca_io_init(struct device *dev, struct sdw_slave *slave)pm_runtime_get_noresume (&slave->dev); -rt712_sdca_reset (rt712); +if (!rt712->first_hw_init) +rt712_sdca_reset (rt712);rt712_sdca_index_read (rt712,RT712_VENDOR_REG ,RT712_JD_PRODUCT_NUM , &val); rt712->hw_id = (val &0xf000 ) >>12 ;
@@ -1858,7 +1859,7 @@ int rt712_sdca_io_init(struct device *dev, struct sdw_slave *slave)* if set_jack callback occurred early than io_init, * we set up the jack detection function now */ -if (rt712->hs_jack) +if (rt712->hs_jack && (!rt712->first_hw_init))rt712_sdca_jack_init (rt712);rt712_sdca_index_write (rt712,RT712_VENDOR_REG ,RT712_SW_CONFIG1 ,0x0001 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 742/1756 perf trace: Copy sockaddr arguments by their length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 1c443dfc3202048b2cb1d3c2534b39b28701e929 ]
The BTF augmenter copies sizeof(struct sockaddr), 16 bytes, for the sockaddr arguments of connect, bind and sendto, and runs before the sys_enter_connect and sys_enter_sendto programs that copy their length. An IPv6 address needs 24 or 28 bytes, so the rest was read from past the payload, and now that the printers are bounded only its family is shown.
Copy them as buffers sized by the length argument after them, up to the 32 bytes augmented buffers are limited to. That holds an IPv6 address and doubles the AF_LOCAL path shown.
Committer testing:
Is using BPF:
root@x2:~# strace -e bpf perf trace -e connect,bind |& head -5
bpf(BPF_TOKEN_CREATE, {token_create={flags=0, bpffs_fd=12}}, 8) = -1 EOPNOTSUPP (Operation not supported)
bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3054260, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0}, 148) = 12
bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3054390, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0, fd_array_cnt=0, signature=NULL, signature_size=0, keyring_id=0}, 168) = 12
bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3053f80, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="libbpf_nametest", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0}, 148) = 12
bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=4, max_entries=1, map_flags=BPF_F_MMAPABLE, inner_map_fd=0, map_name="libbpf_mmap", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0, value_type_btf_obj_fd=0, map_token_fd=0, excl_prog_hash=NULL, excl_prog_hash_size=0}, 92) = 12
root@x2:~#And btf:
root@x2:~# strace -e openat perf trace -e connect,bind |& grep "/sys/kernel/btf/vmlinux" openat(AT_FDCWD, "/sys/kernel/btf/vmlinux", O_RDONLY) = 12 ^C root@x2:~#
And copying the sockaddr parameters according to its addrlen or the cap in the augmented bpf, that probably needs to be a bit bigger for local sockets:
⬢ [acme@toolbx perf-tools-next]$ echo -n /var/run/.heim_org.h5l.kcm-soc | wc -c 30
⬢ [acme@toolbx perf-tools-next]$ ls -la /var/run/.heim_org.h5l.kcm-socket srw-rw-rw-. 1 nobody nobody 0 Sep 14 23:13 /var/run/.heim_org.h5l.kcm-socket ⬢ [acme@toolbx perf-tools-next]$
root@x2:~# perf trace -e connect,bind --max-events 10
0.000 ( 0.717 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
3.733 ( 0.059 ms): pool-0/29901 connect(fd: 10, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
8.859 ( 0.054 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
10.880 ( 0.053 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
1225.303 ( 0.081 ms): systemd-resolv/103685 connect(fd: 30, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0
1226.000 ( 0.046 ms): systemd-resolv/103685 connect(fd: 31, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0
1371.972 ( 0.055 ms): systemd-resolv/103685 connect(fd: 27, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0
1382.266 ( 0.260 ms): Socket Thread/2663038 connect(fd: 178, uservaddr: { .family: INET, port: 443, addr: 186.192.83.34 }, addrlen: 16) = -1 (unknown) (Operation now in progress)
5003.508 ( 0.063 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
5007.007 ( 0.054 ms): pool-0/29901 connect(fd: 10, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0
root@x2:~#--- tools/perf/builtin-trace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +6 -1
@@ -3770,7 +3770,12 @@ static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, unsignecontinue ; bt = sc->arg_fmt[i].type; - beauty_array[i] = bt->size; +/* Copy a sockaddr as a buffer sized by the next argument, e.g. addrlen. */ +if (strcmp (name,"sockaddr" ) ==0 && field->next && +strstr (field->next->name,"len" )) + beauty_array[i] = -((i +1 ) +1 ); +else + beauty_array[i] = bt->size; can_augment = true; } else if (field->flags & TEP_FIELD_IS_POINTER && /* string */ strcmp(field->type, "const char *") == 0 &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 743/1756 perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 5a022bf88fb0f4edde14b1f6f9029d96bffbf3e6 ]
We need it to fix some other libbpf version dependent issues when building with LIBBPF_DYNAMIC=1.
Stable-dep-of: 1fdf657871b9 ("perf thread_map: Add thread_map__tgid()")
--- tools/perf/util/bpf-filter.c | 1 + tools/perf/util/bpf-utils.h | 5 +++++ 2 files changed, 6 insertions(+)
tools/perf/util/bpf-filter.c +1 -0
@@ -55,6 +55,7 @@#include "util/debug.h" #include "util/evsel.h" #include "util/target.h" +#include "util/bpf-utils.h" #include "util/bpf-filter.h" #include <util/bpf-filter-flex.h>
tools/perf/util/bpf-utils.h +5 -0
@@ -8,6 +8,11 @@#ifdef HAVE_LIBBPF_SUPPORT #include <bpf/libbpf.h> +#include <bpf/libbpf_version.h> + +#define LIBBPF_CURRENT_VERSION_GEQ (major, minor) \ + (LIBBPF_MAJOR_VERSION > (major) || \ + (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))/* * Get bpf_prog_info in continuous memory
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 744/1756 perf thread_map: Add thread_map__tgid()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 1fdf657871b9240edcaaf1d15caaac5b78a84317 ]
bpf-filter reads the tgid of each thread in a thread map from /proc, to key its BPF map by process, and perf trace is about to do the same. Move convert_to_tgid() to thread_map.c as thread_map__tgid(), taking the thread map and index both users have.
While moving it, fix two bugs. Match Tgid: at the start of a line, as a task can set its comm, shown on the Name: line before it, to contain "Tgid: <n>". And check the character after the number before freeing the buffer it points into, rather than after.
--- tools/perf/util/bpf-filter.c | 29 ++--------------------------- tools/perf/util/thread_map.c | 26 ++++++++++++++++++++++++++ tools/perf/util/thread_map.h | 1 + 3 files changed, 29 insertions(+), 27 deletions(-)
tools/perf/util/bpf-filter.c +2 -27
@@ -55,6 +55,7 @@#include "util/debug.h" #include "util/evsel.h" #include "util/target.h" +#include "util/thread_map.h" #include "util/bpf-utils.h" #include "util/bpf-filter.h"
@@ -201,31 +202,6 @@ static int get_filter_entries(struct evsel *evsel, struct perf_bpf_filter_entryreturn 0 ; } -static int convert_to_tgid (int tid) -{ -char path[128 ]; -char *buf, *p, *q; -int tgid; -size_t len; - -scnprintf (path,sizeof (path),"%d/status" , tid); -if (procfs__read_str (path, &buf, &len) <0 ) -return -1 ; - - p =strstr (buf,"Tgid:" ); -if (p ==NULL ) { -free (buf); -return -1 ; - } - - tgid =strtol (p +6 , &q,0 ); -free (buf); -if (*q !='\n' ) -return -1 ; - -return tgid; -} -/* * The event might be closed already so we cannot get the list of ids using FD * like in create_event_hash() below, let's iterate the event_hash map and
@@ -406,14 +382,13 @@ static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en last =-1 ; nr =perf_thread_map__nr (threads);for (int i =0 ; i < nr; i++) { -int pid =perf_thread_map__pid (threads, i);int tgid;struct idx_hash_key key = { .evt_id = event_id, };/* it actually needs tgid, let's get tgid from /proc. */ - tgid =convert_to_tgid (pid); + tgid =thread_map__tgid (threads, i);if (tgid <0 ) {/* the thread may be dead, ignore. */ continue ;
tools/perf/util/thread_map.c +26 -0
@@ -427,3 +427,29 @@ int thread_map__remove(struct perf_thread_map *threads, int idx) threads->nr--;return 0 ; } + +/* The tgid of the thread at idx, read from /proc, or -1 if it has exited. */ +pid_t thread_map__tgid (struct perf_thread_map *threads,int idx) +{ +char path[128 ]; +char *buf, *p, *q; +pid_t tgid; +size_t len; + +snprintf (path,sizeof (path),"%d/status" ,perf_thread_map__pid (threads, idx)); +if (procfs__read_str (path, &buf, &len) <0 ) +return -1 ; + +/* From a line start, as the Name: line before it can contain "Tgid:". */ + p =strstr (buf,"\nTgid:" ); +if (p ==NULL ) { +free (buf); +return -1 ; + } + + tgid =strtol (p +6 , &q,0 ); +if (*q !='\n' ) + tgid =-1 ; +free (buf); +return tgid; +}
tools/perf/util/thread_map.h +1 -0
@@ -26,4 +26,5 @@ size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp);void thread_map__read_comms (struct perf_thread_map *threads);bool thread_map__has (struct perf_thread_map *threads,pid_t pid);int thread_map__remove (struct perf_thread_map *threads,int idx); +pid_t thread_map__tgid (struct perf_thread_map *threads,int idx);#endif /* __PERF_THREAD_MAP_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 745/1756 cpufreq: amd-pstate: Restore previous mode when changing driver mode fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit f6d3cbc63935fa8911da87e91ed768824d495470 ]
amd_pstate_change_driver_mode() unregisters the currently active driver before registering the requested mode. If amd_pstate_register_driver() fails for the new mode, the function returns the error without restoring anything, leaving the system with no cpufreq scaling driver at all until a valid mode is manually re-selected.
Remember the mode that was active before the transition and, if registering the requested mode fails, register the previous mode again so the system keeps a working scaling driver. The original error is still returned to the caller so the sysfs write reports the failure.
--- drivers/cpufreq/amd-pstate.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/amd-pstate.c +10 -3
@@ -1235,6 +1235,7 @@ static int amd_pstate_change_mode_without_dvr_change(int mode)static int amd_pstate_change_driver_mode (int mode) { +int old_mode = cppc_state;int ret; ret =amd_pstate_unregister_driver (0 );
@@ -1242,10 +1243,16 @@ static int amd_pstate_change_driver_mode(int mode)return ret; ret =amd_pstate_register_driver (mode); -if (ret) -return ret; +if (ret) { +pr_err ("Failed to register %s mode, restoring %s mode\n" , +amd_pstate_get_mode_string (mode), +amd_pstate_get_mode_string (old_mode)); +if (amd_pstate_register_driver (old_mode)) +pr_err ("Failed to restore %s mode\n" , +amd_pstate_get_mode_string (old_mode)); + } -return 0 ; +return ret; }static cppc_mode_transition_fn mode_state_machine[AMD_PSTATE_MAX ][AMD_PSTATE_MAX ] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 746/1756 cpufreq: amd-pstate: Propagate cppc_set_auto_sel() errors on mode change
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 8de705037124dd1cd49bd8cae6536d63ec4e1807 ]
amd_pstate_change_mode_without_dvr_change() iterates over the online CPUs and calls cppc_set_auto_sel() to enable or disable hardware autonomous selection, but discards its return value and unconditionally returns 0.
If the firmware rejects the request, the failure is hidden: the cpufreq core records the mode transition as successful while the hardware stays in its previous autonomous-selection state. The software mode and the actual hardware behaviour then disagree, breaking the expected frequency scaling.
Check the return value of cppc_set_auto_sel() and propagate the first error to the caller so the sysfs write reports the failure.
--- drivers/cpufreq/amd-pstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/cpufreq/amd-pstate.c +4 -1
@@ -1220,6 +1220,7 @@ static int amd_pstate_unregister_driver(int dummy)static int amd_pstate_change_mode_without_dvr_change (int mode) {int cpu =0 ; +int ret; cppc_state = mode;
@@ -1227,7 +1228,9 @@ static int amd_pstate_change_mode_without_dvr_change(int mode)return 0 ;for_each_online_cpu (cpu) { -cppc_set_auto_sel (cpu, (cppc_state ==AMD_PSTATE_PASSIVE ) ?0 :1 ); + ret =cppc_set_auto_sel (cpu, (cppc_state ==AMD_PSTATE_PASSIVE ) ?0 :1 ); +if (ret) +return ret; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 747/1756 pinctrl: mediatek: mt7629: fix the 2.4 GHz Wi-Fi pin mode array
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuanhong Guo <[email protected]>
[ Upstream commit 0b056aef31602cd10d2b35adc4746781b4fb8609 ]
The wf0_2g group contains nine pins but only eight mux values. mtk_pinmux_set_mux() indexes the mode array once for each pin, reading past its end when configuring pin 78 (WF0_2G_HB6). This can select an unrelated mux value or fail with -EINVAL, preventing the Wi-Fi device from probing.
Add the missing mode 1 entry for WF0_2G_HB6.
--- drivers/pinctrl/mediatek/pinctrl-mt7629.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mt7629.c +1 -1
@@ -294,7 +294,7 @@ static int mt7629_pwm_1_funcs[] = { 2, };/* WF 2G */ static int mt7629_wf0_2g_pins[] = {70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 , }; -static int mt7629_wf0_2g_funcs[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , }; +static int mt7629_wf0_2g_funcs[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , };/* WF 5G */ static int mt7629_wf0_5g_pins[] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 748/1756 mm/memory_hotplug: fix missing rollback in __add_pages()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lance Yang <[email protected]>
[ Upstream commit c31bb839fb829958101250ee5acfa4f94fdb7ecd ]
__add_pages() returns on a sparse_add_section() failure without removing the sections already added in the same request.
For memremap_pages(), the failed range is not counted in pgmap->nr_range, so memunmap_pages() skips it. The sections already added in that range retain their vmemmap mappings and subsection bits. Retrying a section-aligned range can then fail with -EEXIST.
Save the initial PFN and remove [start_pfn, pfn) on failure. For a vmemmap population failure, section_activate() already cleans up the current section, so the rollback excludes it. If the first section fails, __remove_pages() receives an empty range and does nothing.
--- mm/memory_hotplug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +5 -1
@@ -388,6 +388,7 @@ EXPORT_SYMBOL_GPL(pfn_to_online_page);int __add_pages (int nid,unsigned long pfn,unsigned long nr_pages,struct mhp_params *params) { +const unsigned long start_pfn = pfn;const unsigned long end_pfn = pfn + nr_pages;unsigned long cur_nr_pages;int err;
@@ -421,8 +422,11 @@ int __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, SECTION_ALIGN_UP(pfn + 1) - pfn); err =sparse_add_section (nid, pfn, cur_nr_pages, altmap, params->pgmap); -if (err) +if (err) { +__remove_pages (start_pfn, pfn - start_pfn, altmap, + params->pgmap);break ; + }cond_resched (); }vmemmap_populate_print_last ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 749/1756 drm/tegra: Fix syncobj_in wait return value check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 27836c46a3db5a7869a9f7e181136f0c4d8bc0d1 ]
dma_fence_wait_timeout() returns the remaining timeout in jiffies on success, zero on timeout, and a negative error code if interrupted. The return value was assigned to 'err' and checked as if it were an errno, the opposite of the correct logic.
Fix the code to use a properly typed variable and check each condition correctly.
--- drivers/gpu/drm/tegra/submit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/submit.c +8 -2
@@ -530,6 +530,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,if (args->syncobj_in) {struct dma_fence *fence; +long wait_err; err =drm_syncobj_find_fence (file, args->syncobj_in,0 ,0 , &fence);if (err) {
@@ -537,10 +538,15 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, goto unlock; } - err =dma_fence_wait_timeout (fence, true,msecs_to_jiffies (10000 )); + wait_err =dma_fence_wait_timeout (fence, true,msecs_to_jiffies (10000 ));dma_fence_put (fence); -if (err) { +if (wait_err ==0 ) {SUBMIT_ERR (context,"wait for syncobj_in timed out" ); + err = -ETIMEDOUT ; + goto unlock; + }else if (wait_err <0 ) { +/* In practice, -ERESTARTSYS */ + err = wait_err; goto unlock; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 750/1756 drm/tegra: Dont pass an ERR_PTR to drm_syncobj_replace_fence()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 7fce3d34eddfff6361cb4de2c5b8789b88a552b6 ]
When host1x_fence_create() fails, avoid trying to attach the error pointer to the out syncobj.
--- drivers/gpu/drm/tegra/submit.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tegra/submit.c +1 -0
@@ -655,6 +655,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,if (IS_ERR (fence)) { err =PTR_ERR (fence);SUBMIT_ERR (context,"failed to create postfence: %d" , err); + goto put_job; }drm_syncobj_replace_fence (syncobj, fence);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 751/1756 drm/tegra: Drop reference on postfence
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 5ba3dfe724448f308ad7b28ef8d4f41bca4896ae ]
drm_syncobj_replace_fence() calls dma_fence_get() on the parameter fence, so we need to drop ours. Add a call to dma_fence_put() to do that.
--- drivers/gpu/drm/tegra/submit.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tegra/submit.c +1 -0
@@ -659,6 +659,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, }drm_syncobj_replace_fence (syncobj, fence); +dma_fence_put (fence); } goto put_job;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 752/1756 nvdimm/pmem: Release gendisk on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hemanth Selam <[email protected]>
[ Upstream commit 855a46681e0ba601952c346e5b62d867e51ecb23 ]
pmem_attach_disk() allocates the gendisk with blk_alloc_disk() and hands it to devres only once device_add_disk() has succeeded. Until that point the probe path owns the disk itself, which is why every failure after the allocation jumps to the out: label and puts it there.
The devm_init_badblocks() failure returns directly instead, so the disk allocated a few lines earlier is never released. Nothing releases it afterwards either: the devres action that would have done so has not been registered yet, so unbinding the namespace or destroying it does not reach the disk, and it stays allocated along with its queue and its bdev inode until the machine is rebooted.
devm_init_badblocks() only fails when a single page allocation fails, so reaching this at all needs memory exhaustion during namespace probe, and because device_add_disk() has not run there is nothing user visible left
behind: no device node, no sysfs entry, only the leaked memory.
Release the gendisk through the existing cleanup path on this failure.
--- drivers/nvdimm/pmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvdimm/pmem.c +4 -2
@@ -561,8 +561,10 @@ static int pmem_attach_disk(struct device *dev,nvdimm_namespace_disk_name (ndns, disk->disk_name);set_capacity (disk, (pmem->size - pmem->pfn_pad - pmem->data_offset) /512 ); -if (devm_init_badblocks (dev, &pmem->bb)) -return -ENOMEM ; +if (devm_init_badblocks (dev, &pmem->bb)) { + rc = -ENOMEM ; + goto out; + }nvdimm_badblocks_populate (nd_region, &pmem->bb, &bb_range); disk->bb = &pmem->bb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 753/1756 platform/chrome: cros_ec_typec: Validate SVID and mode counts in discovery data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Szpila <[email protected]>
[ Upstream commit 317e7abcaf60b79765dcf35c014edac8b9d37a6e ]
cros_typec_register_altmodes() iterates over sop_disc->svid_count and sop_disc->svids[i].mode_count from the EC_CMD_TYPEC_DISCOVERY response without validating their bounds.
port->disc_data is allocated as a buffer of EC_PROTO2_MAX_RESPONSE_SIZE bytes, and each SVID entry contains a fixed mode_vdo[6] array. If the EC returns an out-of-bounds svid_count or mode_count, the loops read past the end of the mode_vdo array or the disc_data buffer.
Validate that the discovery response with svid_count entries fits within EC_PROTO2_MAX_RESPONSE_SIZE using struct_size(), and ensure each SVID's mode_count does not exceed ARRAY_SIZE(sop_disc->svids[i].mode_vdo) before registering altmodes.
--- drivers/platform/chrome/cros_ec_typec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +10 -0
@@ -7,8 +7,10 @@*/ #include <linux/acpi.h> +#include <linux/array_size.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/overflow.h> #include <linux/platform_data/cros_ec_commands.h> #include <linux/platform_data/cros_usbpd_notify.h> #include <linux/platform_device.h>
@@ -764,7 +766,15 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_int ret =0 ;int i, j; +if (struct_size (sop_disc, svids, sop_disc->svid_count) >EC_PROTO2_MAX_RESPONSE_SIZE ) +return -EINVAL ; +for (i =0 ; i < sop_disc->svid_count; i++) { +if (sop_disc->svids[i].mode_count >ARRAY_SIZE (sop_disc->svids[i].mode_vdo)) { + ret = -EINVAL ; + goto err_cleanup; + } +for (j =0 ; j < sop_disc->svids[i].mode_count; j++) {memset (&desc,0 ,sizeof (desc)); desc.svid = sop_disc->svids[i].svid;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 754/1756 crypto: atmel - handle authenc requests without plaintext
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ccbd95b3efbc0580b6abde2a905823417ca56022 ]
Authenc permits a nonempty associated-data string with no plaintext. The Atmel driver accepts such a request, has SHA process the associated data, and then unconditionally asks AES DMA to transfer zero bytes. The Atmel DMA engines reject the zero-length descriptor, so the valid request fails, normally with -ENOMEM.
Skip the AES transfer when textlen is zero and proceed directly to SHA finalization.
Once an HMAC transform has cached its inner and outer states, SHA can complete this path synchronously. The forced ahash completion callback then invokes the AES finalizer through a void function and discards its return value. This loses -EBADMSG for a mismatched tag and reports successful decryption.
For synchronous SHA completion, release the SHA device without invoking the ahash callback and call the AES finalizer directly. Its result then propagates through the synchronous call chain. Keep the existing callback path for asynchronous completion.
On a SAM9X75, the unpatched driver failed valid AAD-only requests and returned success for a bad tag after the transform had been used once. With this change, bad tags return -EBADMSG for both fresh and reused transforms.
--- drivers/crypto/atmel-aes.c | 2 ++ drivers/crypto/atmel-sha.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
drivers/crypto/atmel-aes.c +2 -0
@@ -1830,6 +1830,8 @@ static int atmel_aes_authenc_transfer(struct atmel_aes_dev *dd, int err, dd->is_async = true;if (err)return atmel_aes_complete (dd, err); +if (!rctx->textlen) +return atmel_aes_authenc_digest (dd);/* Prepare src and dst scatter-lists to transfer cipher/plain texts. */ src =scatterwalk_ffwd (rctx->src, req->src, req->assoclen);
drivers/crypto/atmel-sha.c +14 -0
@@ -2393,11 +2393,25 @@ static int atmel_sha_authenc_final_done(struct atmel_sha_dev *dd) {struct ahash_request *req = dd->req;struct atmel_sha_authenc_reqctx *authctx =ahash_request_ctx (req); +atmel_aes_authenc_fn_t cb; +struct atmel_aes_dev *aes_dev;size_t i, num_words = authctx->digestlen /sizeof (u32);for (i =0 ; i < num_words; ++i) authctx->digest[i] =atmel_sha_read (dd,SHA_REG_DIGEST (i)); +if (!dd->is_async) { +/* +* Return the AES finalizer's status directly for synchronous requests. +* The ahash callback cannot propagate it. +*/ + cb = authctx->cb; + aes_dev = authctx->aes_dev; + dd->force_complete = false; + (void )atmel_sha_complete (dd,0 ); +return cb (aes_dev,0 , false); + } +return atmel_sha_complete (dd,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 755/1756 crypto: tcrypt - Avoid reading req->base after submission
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 3a31a4baad6726bf974bcc58a6398f6a36d10aa0 ]
Once a request has been submitted to the Crypto API, the value of req->base.data must not be read by the caller as it may change while the request is processed.
Avoid reading it in tcrypt by combining the crypto_wait struct with the request object into a tcrypt request object and pass that around instead of the request object.
--- crypto/tcrypt.c | 182 +++++++++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 81 deletions(-)
crypto/tcrypt.c +101 -81
@@ -56,6 +56,21 @@*/ #define get_driver_name (tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm)) +struct tcrypt_aead_request { +struct aead_request *req; +struct crypto_wait wait; +}; + +struct tcrypt_ahash_request { +struct ahash_request *req; +struct crypto_wait wait; +}; + +struct tcrypt_skcipher_request { +struct skcipher_request *req; +struct crypto_wait wait; +}; +/* * Used by test_cipher_speed() */
@@ -129,18 +144,15 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],sg_set_buf (&sg[k +1 ], xbuf[k], rem); } -static inline int do_one_aead_op (struct aead_request *req,int ret) +static inline int do_one_aead_op (struct tcrypt_aead_request *req,int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &req->wait); }struct test_mb_aead_data {struct scatterlist sg[XBUFSIZE ];struct scatterlist sgout[XBUFSIZE ]; -struct aead_request *req; -struct crypto_wait wait; +struct tcrypt_aead_request req;char *xbuf[XBUFSIZE ];char *xoutbuf[XBUFSIZE ];char *axbuf[XBUFSIZE ];
@@ -154,14 +166,14 @@ static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,/* Fire up a bunch of concurrent requests */ for (i =0 ; i < num_mb; i++) {if (enc ==ENCRYPT ) - rc[i] =crypto_aead_encrypt (data[i].req); + rc[i] =crypto_aead_encrypt (data[i].req.req);else - rc[i] =crypto_aead_decrypt (data[i].req); + rc[i] =crypto_aead_decrypt (data[i].req.req); }/* Wait for all requests to finish */ for (i =0 ; i < num_mb; i++) { - rc[i] =crypto_wait_req (rc[i], &data[i].wait); + rc[i] =crypto_wait_req (rc[i], &data[i].req.wait);if (rc[i]) {pr_info ("concurrent request %d error %d\n" , i, rc[i]);
@@ -310,21 +322,21 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, }for (i =0 ; i < num_mb; ++i) { - data[i].req =aead_request_alloc (tfm,GFP_KERNEL ); -if (!data[i].req) { + data[i].req.req =aead_request_alloc (tfm,GFP_KERNEL ); +if (!data[i].req.req) {pr_err ("alg: aead: Failed to allocate request for %s\n" , algo);while (i--) -aead_request_free (data[i].req); +aead_request_free (data[i].req.req); goto out_free_xoutbuf; } }for (i =0 ; i < num_mb; ++i) { -crypto_init_wait (&data[i].wait); -aead_request_set_callback (data[i].req, +crypto_init_wait (&data[i].req.wait); +aead_request_set_callback (data[i].req.req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &data[i].wait); + crypto_req_done, &data[i].req.wait); } pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
@@ -386,16 +398,16 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, bs + (enc ? authsize :0 ), assoc, aad_size); -aead_request_set_ad (cur->req, aad_size); +aead_request_set_ad (cur->req.req, aad_size);if (!enc) { -aead_request_set_crypt (cur->req, +aead_request_set_crypt (cur->req.req, cur->sgout, cur->sg, bs, iv); - ret =crypto_aead_encrypt (cur->req); - ret =do_one_aead_op (cur->req, ret); + ret =crypto_aead_encrypt (cur->req.req); + ret =do_one_aead_op (&cur->req, ret);if (ret) { pr_err("calculating auth failed (%d)\n",
@@ -404,7 +416,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, } } -aead_request_set_crypt (cur->req, cur->sg, +aead_request_set_crypt (cur->req.req, cur->sg, cur->sgout, bs + (enc ?0 : authsize), iv);
@@ -432,7 +444,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, out:for (i =0 ; i < num_mb; ++i) -aead_request_free (data[i].req); +aead_request_free (data[i].req.req); out_free_xoutbuf:for (i =0 ; i < num_mb; ++i)testmgr_free_buf (data[i].xoutbuf);
@@ -450,9 +462,10 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,kfree (iv); } -static int test_aead_jiffies (struct aead_request *req,int enc, +static int test_aead_jiffies (struct tcrypt_aead_request *treq,int enc,int blen,int secs) { +struct aead_request *req = treq->req;unsigned long start, end;int bcount;int ret;
@@ -460,9 +473,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) {if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req));if (ret)return ret;
@@ -473,8 +486,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,return 0 ; } -static int test_aead_cycles (struct aead_request *req,int enc,int blen) +static int test_aead_cycles (struct tcrypt_aead_request *treq,int enc,int blen) { +struct aead_request *req = treq->req;unsigned long cycles =0 ;int ret =0 ;int i;
@@ -482,9 +496,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)/* Warm-up run. */ for (i =0 ; i <4 ; i++) {if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req));if (ret) goto out;
@@ -496,9 +510,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen) start =get_cycles ();if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req)); end =get_cycles ();if (ret)
@@ -520,6 +534,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, unsigned int tcount, u8 authsize, unsigned int aad_size, u8 *keysize) { + struct tcrypt_aead_request treq;unsigned int i, j;struct crypto_aead *tfm;int ret = -ENOMEM ;
@@ -535,7 +550,6 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,char *axbuf[XBUFSIZE ];const int *b_size;unsigned int iv_len; -struct crypto_wait wait; iv =kzalloc (MAX_IVLEN ,GFP_KERNEL );if (!iv)
@@ -577,7 +591,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, goto out_noreq; } -crypto_init_wait (&wait); +crypto_init_wait (&treq.wait);pr_info ("testing speed of %s (%s) %s\n" , algo,get_driver_name (crypto_aead, tfm), e);
@@ -587,9 +601,10 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, algo); goto out_noreq; } + treq.req = req;aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); i =0 ; do {
@@ -650,7 +665,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,*/ aead_request_set_crypt (req, sgout, sg, bs, iv); - ret =do_one_aead_op (req, + ret =do_one_aead_op (&treq,crypto_aead_encrypt (req));if (ret) {
@@ -665,11 +680,11 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, iv);if (secs) { - ret =test_aead_jiffies (req, enc, bs, + ret =test_aead_jiffies (&treq, enc, bs, secs);cond_resched (); }else { - ret =test_aead_cycles (req, enc, bs); + ret =test_aead_cycles (&treq, enc, bs); }if (ret) {
@@ -709,23 +724,22 @@ static void test_hash_sg_init(struct scatterlist *sg) } } -static inline int do_one_ahash_op (struct ahash_request *req,int ret) +static inline int do_one_ahash_op (struct tcrypt_ahash_request *treq,int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &treq->wait); } -static int test_ahash_jiffies_digest (struct ahash_request *req,int blen, -char *out,int secs) +static int test_ahash_jiffies_digest (struct tcrypt_ahash_request *treq, +int blen,char *out,int secs) { +struct ahash_request *req = treq->req;unsigned long start, end;int bcount;int ret;for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) { - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret)return ret; }
@@ -736,28 +750,29 @@ static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_jiffies (struct ahash_request *req,int blen, +static int test_ahash_jiffies (struct tcrypt_ahash_request *treq,int blen,int plen,char *out,int secs) { +struct ahash_request *req = treq->req;unsigned long start, end;int bcount, pcount;int ret;if (plen == blen) -return test_ahash_jiffies_digest (req, blen, out, secs); +return test_ahash_jiffies_digest (treq, blen, out, secs);for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) { - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret)return ret;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret)return ret; }/* we assume there is enough space in 'out' for the result */ - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret)return ret; }
@@ -768,15 +783,16 @@ static int test_ahash_jiffies(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_cycles_digest (struct ahash_request *req,int blen, -char *out) +static int test_ahash_cycles_digest (struct tcrypt_ahash_request *treq, +int blen,char *out) { +struct ahash_request *req = treq->req;unsigned long cycles =0 ;int ret, i;/* Warm-up run. */ for (i =0 ; i <4 ; i++) { - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret) goto out; }
@@ -787,7 +803,7 @@ static int test_ahash_cycles_digest(struct ahash_request *req, int blen, start =get_cycles (); - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret) goto out;
@@ -806,26 +822,27 @@ static int test_ahash_cycles_digest(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_cycles (struct ahash_request *req,int blen, +static int test_ahash_cycles (struct tcrypt_ahash_request *treq,int blen,int plen,char *out) { +struct ahash_request *req = treq->req;unsigned long cycles =0 ;int i, pcount, ret;if (plen == blen) -return test_ahash_cycles_digest (req, blen, out); +return test_ahash_cycles_digest (treq, blen, out);/* Warm-up run. */ for (i =0 ; i <4 ; i++) { - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret) goto out;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret) goto out; } - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret) goto out; }
@@ -836,15 +853,15 @@ static int test_ahash_cycles(struct ahash_request *req, int blen, start =get_cycles (); - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret) goto out;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret) goto out; } - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret) goto out;
@@ -867,7 +884,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, struct hash_speed *speed, unsigned mask) {struct scatterlist sg[TVMEMSIZE ]; -struct crypto_wait wait; +struct tcrypt_ahash_request treq;struct ahash_request *req;struct crypto_ahash *tfm;char *output;
@@ -896,9 +913,10 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, goto out; } -crypto_init_wait (&wait); + treq.req = req; +crypto_init_wait (&treq.wait);ahash_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); output =kmalloc (MAX_DIGEST_SIZE ,GFP_KERNEL );if (!output)
@@ -921,11 +939,11 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,ahash_request_set_crypt (req, sg, output, speed[i].plen);if (secs) { - ret =test_ahash_jiffies (req, speed[i].blen, + ret =test_ahash_jiffies (&treq, speed[i].blen, speed[i].plen, output, secs);cond_resched (); }else { - ret =test_ahash_cycles (req, speed[i].blen, + ret =test_ahash_cycles (&treq, speed[i].blen, speed[i].plen, output); }
@@ -1211,16 +1229,16 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,kfree (data); } -static inline int do_one_acipher_op (struct skcipher_request *req,int ret) +static inline int do_one_acipher_op (struct tcrypt_skcipher_request *req, +int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &req->wait); } -static int test_acipher_jiffies (struct skcipher_request *req,int enc, +static int test_acipher_jiffies (struct tcrypt_skcipher_request *treq,int enc,int blen,int secs) { +struct skcipher_request *req = treq->req;unsigned long start, end;int bcount;int ret;
@@ -1228,10 +1246,10 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) {if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req));if (ret)
@@ -1243,9 +1261,10 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,return 0 ; } -static int test_acipher_cycles (struct skcipher_request *req,int enc, +static int test_acipher_cycles (struct tcrypt_skcipher_request *treq,int enc,int blen) { +struct skcipher_request *req = treq->req;unsigned long cycles =0 ;int ret =0 ;int i;
@@ -1253,10 +1272,10 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,/* Warm-up run. */ for (i =0 ; i <4 ; i++) {if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req));if (ret)
@@ -1269,10 +1288,10 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc, start =get_cycles ();if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req)); end =get_cycles ();
@@ -1294,8 +1313,8 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,struct cipher_speed_template *template, unsigned int tcount, u8 *keysize, bool async) { + struct tcrypt_skcipher_request treq;unsigned int ret, i, j, k, iv_len; -struct crypto_wait wait;const char *key;char iv[128 ];struct skcipher_request *req;
@@ -1308,7 +1327,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,else e ="decryption" ; -crypto_init_wait (&wait); +crypto_init_wait (&treq.wait); tfm =crypto_alloc_skcipher (algo,0 , async ?0 :CRYPTO_ALG_ASYNC );
@@ -1327,8 +1346,9 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, goto out; } + treq.req = req;skcipher_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); i =0 ; do {
@@ -1395,11 +1415,11 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,skcipher_request_set_crypt (req, sg, sg, bs, iv);if (secs) { - ret =test_acipher_jiffies (req, enc, + ret =test_acipher_jiffies (&treq, enc, bs, secs);cond_resched (); }else { - ret =test_acipher_cycles (req, enc, + ret =test_acipher_cycles (&treq, enc, bs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 756/1756 hwrng: intel - return -ENOMEM when kmalloc_obj() fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit a0590c556cdbf88373d38494a23f1503d39b0ab2 ]
intel_rng_mod_init() incorrectly returns -ENODEV when kmalloc_obj() fails. Return -ENOMEM instead.
--- drivers/char/hw_random/intel-rng.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/intel-rng.c +1 -0
@@ -349,6 +349,7 @@ static int __init intel_rng_mod_init(void) intel_rng_hw =kmalloc (sizeof (*intel_rng_hw),GFP_KERNEL );if (!intel_rng_hw) {pci_dev_put (dev); + err = -ENOMEM ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 757/1756 rtc: ftrtc010: fix integer overflow in time calculation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit 32f04694fa87b8ac9fa58f9ceb2dc6cbc476e2a1 ]
In ftrtc010_rtc_read_time() and ftrtc010_rtc_set_time(), all variables (offset, days, hour, min, sec) are u32. The expression "days * 86400 + hour * 3600 + min * 60 + sec" is evaluated in 32-bit arithmetic, which silently wraps around for dates beyond approximately year 2106 (U32_MAX / 86400 ≈ 49710 days).
In ftrtc010_rtc_read_time(), perform the addition in 32-bit arithmetic first to preserve two's complement wrapping for negative offsets, then cast the result to timeu64_t. In ftrtc010_rtc_set_time(), cast individual u32 operands to timeu64_t before multiplication to prevent overflow in the right-hand side of the offset calculation.
--- drivers/rtc/rtc-ftrtc010.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ftrtc010.c +3 -2
@@ -73,7 +73,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) days =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); offset =readl (rtc->rtc_base +FTRTC010_RTC_RECORD ); - time = offset + days *86400 + hour *3600 + min *60 + sec; + time = (timeu64_t)(offset + days *86400 + hour *3600 + min *60 + sec);rtc_time64_to_tm (time, tm);
@@ -93,7 +93,8 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) hour =readl (rtc->rtc_base +FTRTC010_RTC_HOUR ); day =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); - offset = time - (day *86400 + hour *3600 + min *60 + sec); + offset = time - ((timeu64_t )day *86400 + (timeu64_t )hour *3600 + + (timeu64_t )min *60 + (timeu64_t )sec);writel (offset, rtc->rtc_base +FTRTC010_RTC_RECORD );writel (0x01 , rtc->rtc_base +FTRTC010_RTC_CR );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 758/1756 ALSA: ump: Avoid dereference with max_src_size=0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b61a2369085fd995c8ad44245d3fbd45b1216f71 ]
safe_copy_string() refers the source pointer for a NUL terminator before verifying the source size. When max_src_size=0, it may dereference wrongly. Fix the verification order.
Only hypothetical hardening, and we see no actual issue in the current code, as they are all valid sources.
--- sound/core/ump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/ump.c +1 -1
@@ -66,7 +66,7 @@ static void safe_copy_string(void *dst, size_t max_dst_size,if (!max_dst_size--)return ; -for (s = src; max_dst_size && *s && max_src_size--; s++) { +for (s = src; max_dst_size && max_src_size-- && *s; s++) {if (!isascii (*s) || !isprint (*s))continue ; *d++ = *s;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 759/1756 hwrng: intel - return -ENOMEM when ioremap() fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4c3ca7c8c152278332590bfd3df1b0f086364759 ]
intel_init_hw_struct() incorrectly returns -EBUSY when ioremap() fails. Return -ENOMEM instead.
--- drivers/char/hw_random/intel-rng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/intel-rng.c +2 -2
@@ -318,8 +318,8 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n"; } intel_rng_hw->mem =ioremap (INTEL_FWH_ADDR ,INTEL_FWH_ADDR_LEN ); -if (intel_rng_hw->mem ==NULL ) -return -EBUSY ; +if (!intel_rng_hw->mem) +return -ENOMEM ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 760/1756 clocksource/drivers/dbx500-prcmu: Check timer register mapping
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 8f30b035a6676e292ee8e54334711d9905dd0495 ]
Return -ENOMEM if of_iomap() fails, before reading or configuring the timer register block.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/clocksource/clksrc-dbx500-prcmu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/clksrc-dbx500-prcmu.c +2 -0
@@ -52,6 +52,8 @@ static struct clocksource clocksource_dbx500_prcmu = {static int __init clksrc_dbx500_prcmu_init (struct device_node *node) { clksrc_dbx500_timer_base =of_iomap (node,0 ); +if (!clksrc_dbx500_timer_base) +return -ENOMEM ;/* * The A9 sub system expects the timer to be configured as
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 761/1756 isofs: return long Joliet names whole
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Goergens <[email protected]>
[ Upstream commit b8253bcf92d6365b20eea6465f5a93c9fc4aa029 ]
get_joliet_filename() writes into a buffer allocated by its caller but is not told how big that buffer is. It hardcodes PAGE_SIZE as the output limit for utf16s_to_utf8s() and gives uni16_to_x8() no limit at all. PAGE_SIZE was never the right bound. Before commit b2eb2e288604 ("isofs: Drop support of directory entries straddling blocks") both callers allocated a page, but only its first 1024 bytes were for the name, the rest holding a copy of a directory record that straddled a block. It could not overflow only because a directory record holds at most 222 bytes of name (255 bytes, 33 of them fixed), which no converter expands beyond 1024 bytes.
It also keeps the converted length in an unsigned char. 222 bytes of name are 111 UTF-16 units, and the UTF-8 converter, used for iocharset=utf8 and when CONFIG_NLS_DEFAULT is "utf8", needs three bytes for each CJK, Thai or Devanagari character, so such a name can take up to 333 bytes. Past 255 the length wraps. readdir then reports a short name that usually ends in the middle of a UTF-8 sequence, and lookup finds the file only under that name, never under its real one; a name that wraps to exactly 0 bytes is not listed at all.
Such names are out of spec, since Joliet allows 64 units, but common tools write them: PowerISO 9.5 and UltraISO 9.76 both keep up to 110 units by default. Windows, for which Joliet was made, returns them whole, including 111-unit names in records that leave out the padding byte.
Return them whole here too. Pass the buffer size down and have both converters respect it. utf16s_to_utf8s() stops before a character that does not fit, and uni16_to_x8() now hands uni2char() the space that actually remains and stops on -ENAMETOOLONG, as fs/hfsplus/unicode.c does. Both callers pass JOLIET_NAME_MAX + 1, room for 111 units at three bytes each plus the terminator; no character set needs more than three bytes for a UTF-16 unit, and isofs_dir_record_valid() already rejects a record whose name_len claims more than the record holds, so no name is cut. Make the length an int, which is what both converters return.
These names are longer than NAME_MAX. POSIX lets the limit vary by filesystem, reported by pathconf(_PC_NAME_MAX), and the VFS limits a name only by PATH_MAX (verify_dirent_name() in fs/readdir.c).
vfat, exfat, hfsplus and ntfs3 already return names of up to 255 UTF-16 units, 765 bytes of UTF-8, and such names break the same things there:
copying the file to a filesystem with a 255-byte limit, such as ext4 or tmpfs, fails with ENAMETOOLONG, and cp, tar, rsync and Python's shutil report that file and carry on with the rest, so the copy is incomplete but says so. glibc's readdir() returns the names, but the deprecated readdir_r() skips them and fails with ENAMETOOLONG, and an inotify reader with the buffer size inotify(7) suggests gets EINVAL. In the kernel, fanotify reports events on such a file without its name and warns once in fanotify_info_copy_name(), and a directory with such a name cannot be reconnected from a file handle, because the generic get_name() in fs/exportfs, which isofs uses, skips names longer than NAME_MAX. Cutting at NAME_MAX would avoid these, but would list names that Windows does not show and that can coincide within a directory.
Every name of at most 255 bytes is returned exactly as before.
--- fs/isofs/dir.c | 4 +++- fs/isofs/isofs.h | 11 ++++++++++- fs/isofs/joliet.c | 27 ++++++++++++++++++++------- fs/isofs/namei.c | 3 ++- 4 files changed, 35 insertions(+), 10 deletions(-)
fs/isofs/dir.c +3 -1
@@ -215,7 +215,9 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,if (map) {#ifdef CONFIG_JOLIET if (sbi->s_joliet_level) { - len =get_joliet_filename (de, tmpname, inode); + len =get_joliet_filename (de, tmpname, +JOLIET_NAME_MAX +1 , + inode); p = tmpname; } else#endif
fs/isofs/isofs.h +10 -1
@@ -118,7 +118,16 @@ extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *,extern int get_rock_ridge_filename (struct iso_directory_record *,char *,struct inode *);extern int isofs_name_translate (struct iso_directory_record *,char *,struct inode *); -int get_joliet_filename (struct iso_directory_record *,unsigned char *,struct inode *); +/* +* The longest name the Joliet converter returns, in bytes. A directory +* record is at most 255 bytes long, which leaves room for 111 UTF-16 units +* of name, and no character set needs more than three bytes for one unit. +*/ +#define JOLIET_NAME_MAX \ + ((255 - sizeof(struct iso_directory_record)) / 2 * 3) + +int get_joliet_filename (struct iso_directory_record *de,unsigned char *outname, +int outsize,struct inode *inode);int get_acorn_filename (struct iso_directory_record *,char *,struct inode *);extern struct dentry *isofs_lookup (struct inode *,struct dentry *,unsigned int flags);
fs/isofs/joliet.c +20 -7
@@ -15,19 +15,26 @@* Convert Unicode 16 to UTF-8 or ASCII. */ static int -uni16_to_x8 (unsigned char *ascii,__be16 *uni,int len,struct nls_table *nls) +uni16_to_x8 (unsigned char *ascii,__be16 *uni,int len,struct nls_table *nls, +int outsize) {__be16 *ip, ch; -unsigned char *op; +unsigned char *op, *end; ip = uni; op = ascii; + end = ascii + outsize -1 ;/* leave room for the terminator */ while ((ch =get_unaligned (ip)) && len) {int llen; - llen = nls->uni2char (be16_to_cpu (ch), op,NLS_MAX_CHARSET_SIZE ); + +if (op >= end) +break ; + llen = nls->uni2char (be16_to_cpu (ch), op, end - op);if (llen >0 ) op += llen; +else if (llen == -ENAMETOOLONG ) +break ;else *op++ ='?' ; ip++;
@@ -38,21 +45,27 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)return (op - ascii); } +/* +* Convert the Joliet name of @de into @outname, a buffer of @outsize bytes. +* The result is at most @outsize - 1 bytes long; a longer name is cut at a +* character boundary. +*/ int -get_joliet_filename (struct iso_directory_record * de,unsigned char *outname,struct inode * inode) +get_joliet_filename (struct iso_directory_record *de,unsigned char *outname, +int outsize,struct inode *inode) {struct nls_table *nls; -unsigned char len =0 ; +int len =0 ; nls =ISOFS_SB (inode->i_sb)->s_nls_iocharset;if (!nls) { len =utf16s_to_utf8s ((const wchar_t *) de->name, de->name_len[0 ] >>1 ,UTF16_BIG_ENDIAN , - outname,PAGE_SIZE ); + outname, outsize -1 ); }else { len =uni16_to_x8 (outname, (__be16 *) de->name, - de->name_len[0 ] >>1 , nls); + de->name_len[0 ] >>1 , nls, outsize); }if ((len >2 ) && (outname[len-2 ] ==';' ) && (outname[len-1 ] =='1' )) len -=2 ;
fs/isofs/namei.c +2 -1
@@ -112,7 +112,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, dpnt = tmpname; #ifdef CONFIG_JOLIET }else if (sbi->s_joliet_level) { - dlen =get_joliet_filename (de, tmpname, dir); + dlen =get_joliet_filename (de, tmpname, +JOLIET_NAME_MAX +1 , dir); dpnt = tmpname;#endif }else if (sbi->s_mapping =='a' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 762/1756 ASoC: dwc: Use OF match data again for StarFive JH7110
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuri Zaporozhets <[email protected]>
[ Upstream commit d532e2f5c288556075dc429941861391118787a0 ]
Commit d6d6c513f5d2 ("ASoC: dwc: Use ops to get platform data") made dw_i2s_probe() fetch its platform data with of_device_get_match_data(), and commit 52ea7c0543f8 ("ASoC: dwc: i2s: Add StarFive JH7110 SoC support") put the JH7110 configuration into the OF match table. Commit 9c97790a07dc ("ASoC: dwc: Fix non-DT instantiation") then went back to pdev->dev.platform_data so that non-DT users such as AMD work again.
Since then the JH7110 match data is never read. The probe runs neither the JH7110 clock and reset setup (i2s_pd_init) nor uses its capability flags; it configures the DAI from COMP_PARAM_1 instead. On the VisionFive 2, i2stx0 drives the bit and frame clocks for HDMI audio, but COMP_PARAM_1 reports it as slave-only, so the sound card fails to probe:
designware-i2s 120b0000.i2s: ASoC error (-22): at snd_soc_dai_set_fmt() on 120b0000.i2s asoc-simple-card sound-hdmi: probe with driver asoc-simple-card failed with error -22
Take the OF match data first and fall back to the platform data when there is none, so that both DT and non-DT users get their configuration.
Tested on a VisionFive 2 v1.3B (v7.0.3 with local HDMI audio patches):
the HDMI sound card now probes and plays through i2stx0. The non-DT path is build-tested only.
--- sound/soc/dwc/dwc-i2s.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/dwc/dwc-i2s.c +5 -1
@@ -21,6 +21,7 @@#include <linux/reset.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <sound/designware_i2s.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -916,13 +917,16 @@ static int jh7110_i2stx0_clk_cfg(struct i2s_clk_config_data *config)static int dw_i2s_probe (struct platform_device *pdev) { -const struct i2s_platform_data *pdata = pdev->dev.platform_data; +const struct i2s_platform_data *pdata =device_get_match_data (&pdev->dev);struct dw_i2s_dev *dev;struct resource *res;int ret, irq;struct snd_soc_dai_driver *dw_i2s_dai;const char *clk_id; +if (!pdata) + pdata =dev_get_platdata (&pdev->dev); + dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 763/1756 iommu/arm-smmu-v3: Ensure L2 tables are visible before L1 ptrs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mostafa Saleh <[email protected]>
[ Upstream commit 84366fb547ed987c4857311da0e5127d95bf97e6 ]
Commit 6fabce53f6b9 ("iommu/arm-smmu-v3: Add a missing dma_wmb() for hitless STE update") adds a dma_wmb() to arm_smmu_write_entry() to make sure stream tables
and context descriptors are observed first.
However, STE L1 table descriptors are configured directly via WRITE_ONCE(), where before that they were zeroed with memset() inside dma_direct_alloc() then written to abort in via memset() also in arm_smmu_init_initial_stes() without a barrier in both cases which means that the SMMUv3 can observe the allocated table before the written descriptors causing it to fetch random data.
Similarly in arm_smmu_write_cd_l1_desc() where the L1 CD is written after dma_alloc_coherent() with no barriers.
Add dma_wmb() in both cases.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +6 -0
@@ -1240,6 +1240,9 @@ static void arm_smmu_write_cd_l1_desc(struct arm_smmu_cdtab_l1 *dst, {u64 val = (l2ptr_dma &CTXDESC_L1_DESC_L2PTR_MASK ) |CTXDESC_L1_DESC_V ; +/* Ensure the zero-cleared L2 table is fully visible. */ +dma_wmb (); +/* The HW has 64 bit atomicity with stores to the L2 CD table */ WRITE_ONCE (dst->l2ptr,cpu_to_le64 (val)); }
@@ -1511,6 +1514,9 @@ static void arm_smmu_write_strtab_l1_desc(struct arm_smmu_strtab_l1 *dst, val |=FIELD_PREP (STRTAB_L1_DESC_SPAN ,STRTAB_SPLIT +1 ); val |= l2ptr_dma &STRTAB_L1_DESC_L2PTR_MASK ; +/* Ensure the new L2 table is fully visible. */ +dma_wmb (); +/* The HW has 64 bit atomicity with stores to the L2 STE table */ WRITE_ONCE (dst->l2ptr,cpu_to_le64 (val)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 764/1756 iommu/arm-smmu-v3-test: Fix arm_smmu_v3_test_debug_print_used_bits()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mostafa Saleh <[email protected]>
[ Upstream commit ce58940ccc3d1a377d238d93666c140405f8ce05 ]
arm_smmu_v3_test_debug_print_used_bits() hardcodes arm_smmu_get_ste_used() instead of using the provided writer->ops->get_used() callback. This caused Context Descriptors to be incorrectly parsed as STEs.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c +2 -2
@@ -97,8 +97,8 @@ arm_smmu_v3_test_debug_print_used_bits(struct arm_smmu_entry_writer *writer, {__le64 used_bits[NUM_ENTRY_QWORDS ] = {}; -arm_smmu_get_ste_used (ste, used_bits); -pr_debug ("STE used bits: " ); + writer->ops->get_used (ste, used_bits); +pr_debug ("Entry used bits: " );print_hex_dump_debug (" " ,DUMP_PREFIX_NONE ,16 ,8 , used_bits,sizeof (used_bits), false); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 765/1756 arm64: dts: amlogic: meson-sm1-odroid-hc4: mux the SPI NOR HOLD# and WP# pins
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit 0b825126590879812321cdab53786fcd906f7761 ]
The SPI NOR flash uses six lines, but nor_pins covers only four: data, clock and chip select. Nothing claims HOLD# (BOOT_3) and WP# (BOOT_7), so they keep the boot ROM setting. After a boot from SPI they are in the nor function and the flash works. After a boot from SD with the button under the board, they stay eMMC data lines pulled low, and spi-nor reports "unrecognized JEDEC id bytes: 00 00 00 00 00 00".
Add them as a separate group in meson-g12-common.dtsi rather than tonor_pins: whether HOLD# and WP# reach the SoC depends on the board. The HC4 has eMMC disabled and takes both groups.
Tested on ODROID-HC4: with BOOT_3 and BOOT_7 set back to eMMC with pull-down and spifc rebound, the flash fails as above without this patch and probes as a 16 MiB mtd0 with it.
--- arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 9 +++++++++ arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +9 -0
@@ -615,6 +615,15 @@ mux { }; }; + nor_hold_wp_pins: nor-hold-wp { + mux { + groups = "nor_hold", + "nor_wp"; + function = "nor"; + bias-disable; + }; + }; + pdm_din0_a_pins: pdm-din0-a { mux { groups = "pdm_din0_a";
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +1 -1
@@ -124,7 +124,7 @@ &sd_emmc_c { &spifc { status = "okay"; - pinctrl-0 = <&nor_pins>; + pinctrl-0 = <&nor_pins>, <&nor_hold_wp_pins>; pinctrl-names = "default"; flash@0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 766/1756 arm64: dts: amlogic: meson-sm1-odroid-hc4: run the SPI NOR at 40 MHz
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit b44e2be772f866985cafdf90355285069ea68495 ]
At 104 MHz, reads return corrupted data: bit 0 of the first byte of a transfer flips from 0 to 1 part of the time. The same byte read as the second byte of a transfer was correct in all 100 reads. One 4 KiB block read 200 times came back wrong 157 times. Writes are unaffected.
flashcp verifies while it writes, so a bootloader update erases blocks it should skip and can abort halfway, with the flash half written.
The Hardkernel vendor device tree for this board uses 40 MHz. At 40 MHz the same tests pass: 200 block reads with no mismatch, and 14 flashcp runs with no block erased.
Tested on ODROID-HC4 with an XT25F128B.
--- arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +1 -1
@@ -132,7 +132,7 @@ flash@0 { #size-cells = <1>; compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <104000000>; + spi-max-frequency = <40000000>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 767/1756 soc/tegra: flowctrl: Release OF node reference on error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 4eaed7ea6ab36e1160d660b05551702c36dfed6c ]
tegra_flowctrl_init() obtains a reference from of_find_matching_node() and currently releases it only after of_address_to_resource() succeeds.
Release the reference before checking the resource conversion result so the error path is balanced as well.
--- drivers/soc/tegra/flowctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/soc/tegra/flowctrl.c +5 -2
@@ -195,11 +195,14 @@ static int __init tegra_flowctrl_init(void) np =of_find_matching_node (NULL , tegra_flowctrl_match);if (np) { -if (of_address_to_resource (np,0 , &res) <0 ) { +int err =of_address_to_resource (np,0 , &res); + +of_node_put (np); + +if (err <0 ) {pr_err ("failed to get flowctrl register\n" );return -ENXIO ; } -of_node_put (np); }else if (IS_ENABLED (CONFIG_ARM )) {/* * Hardcoded fallback for 32-bit Tegra
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 768/1756 drm/msm/dp: dont report link training success after a reinit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Keri <[email protected]>
[ Upstream commit a47987366e7fc2c05aeffc97f8e1f776e583f792 ]
When every training attempt fails, the retry loop in msm_dp_ctrl_on_link() ends on a successful msm_dp_ctrl_reinitialize_mainlink(), leaving rc at 0. The caller then enables the stream on an untrained link and the display stays dark.
The retry counter only reaches zero in that case, so treat it as a training failure.
Patchwork: https://patchwork.freedesktop.org/patch/756528/
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/dp/dp_ctrl.c +3 -0
@@ -1915,6 +1915,9 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)if (ctrl->link->sink_request &DP_TEST_LINK_PHY_TEST_PATTERN )return rc; +if (!link_train_max_retries) + rc = -ETIMEDOUT ; +if (rc ==0 ) {/* link train successfully */ /* * do not stop train pattern here
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 769/1756 drm/msm/dpu: disable the slave encoder before the master
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonhoe Kim <[email protected]>
[ Upstream commit 32d04280ddebb6eb964990931b0f1001f63b35e7 ]
dpu_encoder_virt_atomic_disable() disables the physical encoders in phys_encs[] order, i.e. the master first. With a split display (two interfaces on one CTL, e.g. bonded DSI) the master's dpu_encoder_helper_phys_cleanup() then resets the shared CTL while the slave's timing engine is still running, and the source pipe is left stalled half-way through the slave's next frame.
A power collapse of the MDSS core GDSC clears the stall, so it normally goes unnoticed. When MDSS stays powered across the disable (a full modeset, or an active DP controller), the next enable scans out
nothing: black screen with the backlight on.
Disable the slave before the master, as atomic_enable() enables them in that order. The slave's cleanup still resets the CTL while the master is running, but the last reset, from the master's cleanup, now happens with both timing engines stopped.
Tested on a Lenovo Legion Tab Y700 gen 5 (SM8850, bonded DSI video-mode panel) with MDSS kept active:
echo on > /sys/bus/platform/devices/9800000.display-subsystem/power/control
DPMS off/on: black 10/10 before, picture 10/10 after. Full modesets were not retested with this version. Only tested on this device.
Patchwork: https://patchwork.freedesktop.org/patch/757684/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +4 -6
@@ -1320,7 +1320,6 @@ static void dpu_encoder_virt_atomic_disable(struct drm_encoder *drm_enc,struct dpu_encoder_virt *dpu_enc =NULL ;struct drm_crtc *crtc;struct drm_crtc_state *old_state =NULL ; -int i =0 ; dpu_enc =to_dpu_encoder_virt (drm_enc);DPU_DEBUG_ENC (dpu_enc,"\n" );
@@ -1346,12 +1345,11 @@ static void dpu_encoder_virt_atomic_disable(struct drm_encoder *drm_enc,dpu_encoder_resource_control (drm_enc,DPU_ENC_RC_EVENT_PRE_STOP ); -for (i =0 ; i < dpu_enc->num_phys_encs; i++) { -struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; +if (dpu_enc->cur_slave && dpu_enc->cur_slave->ops.disable) + dpu_enc->cur_slave->ops.disable (dpu_enc->cur_slave); -if (phys->ops.disable) - phys->ops.disable (phys); - } +if (dpu_enc->cur_master && dpu_enc->cur_master->ops.disable) + dpu_enc->cur_master->ops.disable (dpu_enc->cur_master);/* after phys waits for frame-done, should be no more frames pending */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 770/1756 drm/msm/dpu: extract bandwidth aggregation function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit b9aedd32a81792f5b4b7716815aba375ebaff526 ]
In preparation to refactoring the dpu_core_perf debugfs interface, extract the bandwidth aggregation function from _dpu_core_perf_crtc_update_bus().
Patchwork: https://patchwork.freedesktop.org/patch/636058/
Stable-dep-of: 480ba24aa340 ("drm/msm/dpu: compute the CRTC bandwidth from the state being checked")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +25 -20
@@ -204,36 +204,41 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,return 0 ; } -static int _dpu_core_perf_crtc_update_bus (struct dpu_kms *kms, -struct drm_crtc *crtc) +static void dpu_core_perf_aggregate (struct drm_device *ddev, +enum dpu_crtc_client_type curr_client_type, +struct dpu_core_perf_params *perf) { -struct dpu_core_perf_params perf = {0 }; -enum dpu_crtc_client_type curr_client_type - =dpu_crtc_get_client_type (crtc); -struct drm_crtc *tmp_crtc;struct dpu_crtc_state *dpu_cstate; -int i, ret =0 ; -u64 avg_bw; - -if (!kms->num_paths) -return 0 ; +struct drm_crtc *tmp_crtc; -drm_for_each_crtc (tmp_crtc, crtc->dev) { +drm_for_each_crtc (tmp_crtc, ddev) {if (tmp_crtc->enabled && - curr_client_type == -dpu_crtc_get_client_type (tmp_crtc)) { + curr_client_type ==dpu_crtc_get_client_type (tmp_crtc)) { dpu_cstate =to_dpu_crtc_state (tmp_crtc->state); - perf.max_per_pipe_ib =max (perf.max_per_pipe_ib, - dpu_cstate->new_perf.max_per_pipe_ib); + perf->max_per_pipe_ib =max (perf->max_per_pipe_ib, + dpu_cstate->new_perf.max_per_pipe_ib); - perf.bw_ctl += dpu_cstate->new_perf.bw_ctl; + perf->bw_ctl += dpu_cstate->new_perf.bw_ctl; -DRM_DEBUG_ATOMIC ("crtc=%d bw=%llu paths:%d\n" , - tmp_crtc->base.id, - dpu_cstate->new_perf.bw_ctl, kms->num_paths); +DRM_DEBUG_ATOMIC ("crtc=%d bw=%llu\n" , + tmp_crtc->base.id, + dpu_cstate->new_perf.bw_ctl); } } +} + +static int _dpu_core_perf_crtc_update_bus (struct dpu_kms *kms, +struct drm_crtc *crtc) +{ +struct dpu_core_perf_params perf = {0 }; +int i, ret =0 ; +u64 avg_bw; + +if (!kms->num_paths) +return 0 ; + +dpu_core_perf_aggregate (crtc->dev,dpu_crtc_get_client_type (crtc), &perf); avg_bw = perf.bw_ctl;do_div (avg_bw, (kms->num_paths *1000 ));/*Bps_to_icc*/
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 771/1756 drm/msm/dpu: change ib values to u32
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit c54b61102f468cef440423a57341a95763a287a3 ]
The IB values in core_perf calculations (max_per_pipe_ib, fix_core_ib_vote) are expressed in KBps and are passed to icc_set_bw without additional division. Change type of those values to u32.
Patchwork: https://patchwork.freedesktop.org/patch/636061/
Stable-dep-of: 480ba24aa340 ("drm/msm/dpu: compute the CRTC bandwidth from the state being checked")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h | 6 +++--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +2 -2
@@ -135,7 +135,7 @@ static void _dpu_core_perf_calc_crtc(const struct dpu_core_perf *core_perf, }DRM_DEBUG_ATOMIC ( -"crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n" , +"crtc=%d clk_rate=%llu core_ib=%u core_ab=%llu\n" , crtc->base.id, perf->core_clk_rate, perf->max_per_pipe_ib, perf->bw_ctl); }
@@ -482,7 +482,7 @@ int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent) (u32 *)perf, &dpu_core_perf_mode_fops);debugfs_create_u64 ("fix_core_clk_rate" ,0600 , entry, &perf->fix_core_clk_rate); -debugfs_create_u64 ("fix_core_ib_vote" ,0600 , entry, +debugfs_create_u32 ("fix_core_ib_vote" ,0600 , entry, &perf->fix_core_ib_vote);debugfs_create_u64 ("fix_core_ab_vote" ,0600 , entry, &perf->fix_core_ab_vote);
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h +3 -3
@@ -19,7 +19,7 @@* @core_clk_rate: core clock rate request */ struct dpu_core_perf_params { -u64 max_per_pipe_ib; +u32 max_per_pipe_ib;u64 bw_ctl;u64 core_clk_rate; };
@@ -40,7 +40,7 @@ struct dpu_core_perf_tune {* @perf_tune: debug control for performance tuning * @enable_bw_release: debug control for bandwidth release * @fix_core_clk_rate: fixed core clock request in Hz used in mode 2 -* @fix_core_ib_vote: fixed core ib vote in bps used in mode 2 +* @fix_core_ib_vote: fixed core ib vote in KBps used in mode 2 * @fix_core_ab_vote: fixed core ab vote in bps used in mode 2 */ struct dpu_core_perf {
@@ -50,7 +50,7 @@ struct dpu_core_perf {struct dpu_core_perf_tune perf_tune;u32 enable_bw_release;u64 fix_core_clk_rate; -u64 fix_core_ib_vote; +u32 fix_core_ib_vote;u64 fix_core_ab_vote; };
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +1 -1
@@ -1386,7 +1386,7 @@ static int dpu_crtc_debugfs_state_show(struct seq_file *s, void *v)seq_printf (s,"core_clk_rate: %llu\n" , dpu_crtc->cur_perf.core_clk_rate);seq_printf (s,"bw_ctl: %llu\n" , dpu_crtc->cur_perf.bw_ctl); -seq_printf (s,"max_per_pipe_ib: %llu\n" , +seq_printf (s,"max_per_pipe_ib: %u\n" , dpu_crtc->cur_perf.max_per_pipe_ib);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 772/1756 drm/msm/dpu: make fix_core_ab_vote consistent with fix_core_ib_vote
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 879a7f8c8c2d727bc4c8ae3238f0dbf52eada6db ]
The fix_core_ab_vote is an average bandwidth value, used for bandwidth overrides in several cases. However there is an internal inconsistency:fix_core_ib_vote is defined in KBps, while fix_core_ab_vote is defined in Bps.
Fix that by changing the type of the variable to u32 and using * 1000ULL multiplier when setting up the dpu_core_perf_params::bw_ctl value.
Patchwork: https://patchwork.freedesktop.org/patch/636064/
Stable-dep-of: 480ba24aa340 ("drm/msm/dpu: compute the CRTC bandwidth from the state being checked")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +2 -2
@@ -125,7 +125,7 @@ static void _dpu_core_perf_calc_crtc(const struct dpu_core_perf *core_perf, perf->max_per_pipe_ib =0 ; perf->core_clk_rate =0 ; }else if (core_perf->perf_tune.mode ==DPU_PERF_MODE_FIXED ) { - perf->bw_ctl = core_perf->fix_core_ab_vote; + perf->bw_ctl = core_perf->fix_core_ab_vote *1000ULL ; perf->max_per_pipe_ib = core_perf->fix_core_ib_vote; perf->core_clk_rate = core_perf->fix_core_clk_rate; }else {
@@ -484,7 +484,7 @@ int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent) &perf->fix_core_clk_rate);debugfs_create_u32 ("fix_core_ib_vote" ,0600 , entry, &perf->fix_core_ib_vote); -debugfs_create_u64 ("fix_core_ab_vote" ,0600 , entry, +debugfs_create_u32 ("fix_core_ab_vote" ,0600 , entry, &perf->fix_core_ab_vote);return 0 ;
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h +2 -2
@@ -41,7 +41,7 @@ struct dpu_core_perf_tune {* @enable_bw_release: debug control for bandwidth release * @fix_core_clk_rate: fixed core clock request in Hz used in mode 2 * @fix_core_ib_vote: fixed core ib vote in KBps used in mode 2 -* @fix_core_ab_vote: fixed core ab vote in bps used in mode 2 +* @fix_core_ab_vote: fixed core ab vote in KBps used in mode 2 */ struct dpu_core_perf {const struct dpu_perf_cfg *perf_cfg;
@@ -51,7 +51,7 @@ struct dpu_core_perf {u32 enable_bw_release;u64 fix_core_clk_rate;u32 fix_core_ib_vote; -u64 fix_core_ab_vote; +u32 fix_core_ab_vote; };/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 773/1756 drm/msm/dpu: drop core_clk_rate overrides from _dpu_core_perf_calc_crtc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e7e2495595e01839b117e9c08500ff80cd218f6a ]
core_clk_rate override is handled in _dpu_core_perf_get_core_clk_rate(). Drop imperfect duplicating code from _dpu_core_perf_calc_crtc().
Patchwork: https://patchwork.freedesktop.org/patch/636070/
Stable-dep-of: 480ba24aa340 ("drm/msm/dpu: compute the CRTC bandwidth from the state being checked")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +1 -3
@@ -123,16 +123,14 @@ static void _dpu_core_perf_calc_crtc(const struct dpu_core_perf *core_perf,if (core_perf->perf_tune.mode ==DPU_PERF_MODE_MINIMUM ) { perf->bw_ctl =0 ; perf->max_per_pipe_ib =0 ; - perf->core_clk_rate =0 ; }else if (core_perf->perf_tune.mode ==DPU_PERF_MODE_FIXED ) { perf->bw_ctl = core_perf->fix_core_ab_vote *1000ULL ; perf->max_per_pipe_ib = core_perf->fix_core_ib_vote; - perf->core_clk_rate = core_perf->fix_core_clk_rate; }else { perf->bw_ctl =_dpu_core_perf_calc_bw (perf_cfg, crtc); perf->max_per_pipe_ib = perf_cfg->min_dram_ib; - perf->core_clk_rate =_dpu_core_perf_calc_clk (perf_cfg, crtc, state); } + perf->core_clk_rate =_dpu_core_perf_calc_clk (perf_cfg, crtc, state); DRM_DEBUG_ATOMIC( "crtc=%d clk_rate=%llu core_ib=%u core_ab=%llu\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 774/1756 drm/msm/dpu: handle perf mode in _dpu_core_perf_crtc_update_bus()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 6d3175a72cc07e90f81fb35841048a8a9b5134cb ]
Move perf mode handling for the bandwidth to _dpu_core_perf_crtc_update_bus() rather than overriding per-CRTC data and then aggregating known values.
Note, this changes the fix_core_ab_vote. Previously it would be multiplied per the CRTC number, now it will be used directly for interconnect voting. This better reflects user requirements in the case of different resolutions being set on different CRTCs: instead of using the same bandwidth for each CRTC (which is incorrect) user can now calculate overall bandwidth required by all outputs and use that value.
Note #2: this also disables threshold checks for user-entered bandwidth values. First of all, it doesn't make sense to fail atomic commits because of the debugfs input. Compositors have no way to correlate failing commits with debugfs settings. Second, it makes sense to allow users to go beyond these values and check whether this makes any difference or fixes the issue.
Patchwork: https://patchwork.freedesktop.org/patch/636072/
Stable-dep-of: 480ba24aa340 ("drm/msm/dpu: compute the CRTC bandwidth from the state being checked")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +18 -18
@@ -118,20 +118,9 @@ static void _dpu_core_perf_calc_crtc(const struct dpu_core_perf *core_perf,return ; } -memset (perf,0 ,sizeof (struct dpu_core_perf_params )); - -if (core_perf->perf_tune.mode ==DPU_PERF_MODE_MINIMUM ) { - perf->bw_ctl =0 ; - perf->max_per_pipe_ib =0 ; - }else if (core_perf->perf_tune.mode ==DPU_PERF_MODE_FIXED ) { - perf->bw_ctl = core_perf->fix_core_ab_vote *1000ULL ; - perf->max_per_pipe_ib = core_perf->fix_core_ib_vote; - }else { - perf->bw_ctl =_dpu_core_perf_calc_bw (perf_cfg, crtc); - perf->max_per_pipe_ib = perf_cfg->min_dram_ib; - } + perf->bw_ctl =_dpu_core_perf_calc_bw (perf_cfg, crtc); + perf->max_per_pipe_ib = perf_cfg->min_dram_ib; perf->core_clk_rate =_dpu_core_perf_calc_clk (perf_cfg, crtc, state); - DRM_DEBUG_ATOMIC( "crtc=%d clk_rate=%llu core_ib=%u core_ab=%llu\n", crtc->base.id, perf->core_clk_rate,
@@ -231,18 +220,29 @@ static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms, {struct dpu_core_perf_params perf = {0 };int i, ret =0 ; -u64 avg_bw; +u32 avg_bw; +u32 peak_bw;if (!kms->num_paths)return 0 ; -dpu_core_perf_aggregate (crtc->dev,dpu_crtc_get_client_type (crtc), &perf); +if (kms->perf.perf_tune.mode ==DPU_PERF_MODE_MINIMUM ) { + avg_bw =0 ; + peak_bw =0 ; + }else if (kms->perf.perf_tune.mode ==DPU_PERF_MODE_FIXED ) { + avg_bw = kms->perf.fix_core_ab_vote; + peak_bw = kms->perf.fix_core_ib_vote; + }else { +dpu_core_perf_aggregate (crtc->dev,dpu_crtc_get_client_type (crtc), &perf); + + avg_bw =div_u64 (perf.bw_ctl,1000 );/*Bps_to_icc*/ + peak_bw = perf.max_per_pipe_ib; + } - avg_bw = perf.bw_ctl; -do_div (avg_bw, (kms->num_paths *1000 ));/*Bps_to_icc*/ + avg_bw /= kms->num_paths;for (i =0 ; i < kms->num_paths; i++) -icc_set_bw (kms->path[i], avg_bw, perf.max_per_pipe_ib); +icc_set_bw (kms->path[i], avg_bw, peak_bw);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 775/1756 drm/msm/dpu: compute the CRTC bandwidth from the state being checked
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonhoe Kim <[email protected]>
[ Upstream commit 480ba24aa34031c898d0a711405664cd947bbee4 ]
_dpu_core_perf_calc_bw() is called with the new CRTC state but sums plane_fetch_bw over drm_atomic_crtc_for_each_plane(), i.e. the planes of the committed state. When the CRTC is re-enabled (DPMS on, system resume) the committed state has no planes attached, so the check computes bw_ctl = 0 and the display runs without an average bandwidth vote on the MDP path until some later commit changes a plane -- which may not happen for a long time on a static screen such as a lock screen.
Seen on a Lenovo TB323FU (SM8850) through the interconnect and DPU
tracepoints: after DPMS off/on or s2idle, dpu_perf_crtc_update reported bw_ctl=0 and qnm_mdp was left at avg_bw=0 (peak 800000) instead of the 3728793 kBps voted before, until the next mode change.
Iterate the plane states of the CRTC state being checked instead. drm_atomic_crtc_state_for_each_plane_state() falls back to the current plane state for planes that are not part of the commit, so the result is unchanged for commits that do touch the planes.
With this, bw_ctl is 3728793600 right after DPMS on and after resume. Only tested on this device.
Patchwork: https://patchwork.freedesktop.org/patch/757683/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +6 -11
@@ -34,24 +34,19 @@ enum dpu_perf_mode {/** * _dpu_core_perf_calc_bw() - to calculate BW per crtc * @perf_cfg: performance configuration -* @crtc: pointer to a crtc +* @state: the CRTC state * Return: returns aggregated BW for all planes in crtc. */ static u64 _dpu_core_perf_calc_bw (const struct dpu_perf_cfg *perf_cfg, -struct drm_crtc *crtc) +struct drm_crtc_state *state) {struct drm_plane *plane; -struct dpu_plane_state *pstate; +const struct drm_plane_state *plane_state;u64 crtc_plane_bw =0 ;u32 bw_factor; -drm_atomic_crtc_for_each_plane (plane, crtc) { - pstate =to_dpu_plane_state (plane->state); -if (!pstate) -continue ; - - crtc_plane_bw += pstate->plane_fetch_bw; - } +drm_atomic_crtc_state_for_each_plane_state (plane, plane_state, state) + crtc_plane_bw +=to_dpu_plane_state (plane_state)->plane_fetch_bw; bw_factor = perf_cfg->bw_inefficiency_factor;if (bw_factor) {
@@ -118,7 +113,7 @@ static void _dpu_core_perf_calc_crtc(const struct dpu_core_perf *core_perf,return ; } - perf->bw_ctl =_dpu_core_perf_calc_bw (perf_cfg, crtc); + perf->bw_ctl =_dpu_core_perf_calc_bw (perf_cfg, state); perf->max_per_pipe_ib = perf_cfg->min_dram_ib; perf->core_clk_rate =_dpu_core_perf_calc_clk (perf_cfg, crtc, state); DRM_DEBUG_ATOMIC(
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 776/1756 phy: HiSilicon: Fix error handling in hi3670_pcie_allclk_ctrl()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akash Sukhavasi <[email protected]>
[ Upstream commit 7540fc0a4f667b6773d10753a602a42a3113087b ]
When hi3670_pcie_pll_ctrl() fails, hi3670_pcie_allclk_ctrl() returns -EINVAL directly, skipping the close_clocks cleanup path. This leaves the PLL with its power-down bit cleared.
Use goto close_clocks instead, which disables the PLL and propagates the original error code from hi3670_pcie_pll_ctrl().
Found while investigating a Smatch warning.
--- drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/hisilicon/phy-hi3670-pcie.c +1 -1
@@ -476,7 +476,7 @@ static int hi3670_pcie_allclk_ctrl(struct hi3670_pcie_phy *phy, bool clk_on) ret =hi3670_pcie_pll_ctrl (phy, true);if (ret) {dev_err (dev,"Failed to enable pll\n" ); -return -EINVAL ; + goto close_clocks; }hi3670_pcie_hp_debounce_gt (phy, true);hi3670_pcie_phyref_gt (phy, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 777/1756 phy: rockchip: usbdp: Update mode_change after error handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 3f2181226d7708349c69cd4a4b21372a8049576b ]
If rk_udphy_init() or rk_udphy_setup() fails, the reinit will not be tried again. Fix this by only updating the variable after all potential errors have been handled.
Note, that no errors have been seen on real hardware and failures would most likely be fatal and require at least a full reboot as the function already asserts the PHY reset lines. So this is more of a theoretical issue.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +2 -2
@@ -1000,15 +1000,14 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode) }if (udphy->status ==UDPHY_MODE_NONE ) { - udphy->mode_change = false; ret =rk_udphy_setup (udphy);if (ret)return ret;if (udphy->mode &UDPHY_MODE_USB )rk_udphy_u3_port_disable (udphy, false); - }else if (udphy->mode_change) { udphy->mode_change = false; + }else if (udphy->mode_change) { udphy->status =UDPHY_MODE_NONE ;if (udphy->mode ==UDPHY_MODE_DP )rk_udphy_u3_port_disable (udphy, true);
@@ -1017,6 +1016,7 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode) ret =rk_udphy_setup (udphy);if (ret)return ret; + udphy->mode_change = false; } udphy->status |= mode;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 778/1756 phy: rockchip: usbdp: Do not lose USB3 PHY status
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit b322403c294b67fd6bcf6719b4fc9f8a9e313129 ]
By default (i.e. without manually enabling runtime PM) DWC3 requests the USB3 PHY once and keeps it enabled all the time. When DisplayPort is being requested later on, a mode change is needed. This re-initializes the PHY. During re-initialization the status variable has incorrectly been cleared, which means the tracking information for USB3 is lost.
This is not an immediate problem, since the DP side keeps the PHY enabled. But once DP is toggled off, the whole PHY will be disabled. This is a problem, because the USB side still needs it powered.
Fix things by not clearing the status flags.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 1 - 1 file changed, 1 deletion(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +0 -1
@@ -1008,7 +1008,6 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)rk_udphy_u3_port_disable (udphy, false); udphy->mode_change = false; }else if (udphy->mode_change) { - udphy->status =UDPHY_MODE_NONE ;if (udphy->mode ==UDPHY_MODE_DP )rk_udphy_u3_port_disable (udphy, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 779/1756 phy: rockchip: usbdp: Fix devm_clk_bulk_get_all check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit a2ddfc60a7d3ba0f571f037371b261642f8ed208 ]
If devm_clk_bulk_get_all() returns -EPROBE_DEFER, it is replaced with -ENODEV, permanently failing the driver probe instead of allowing it to defer. Avoid masking the error code to fix the issue.
This effectively drops returning -ENODEV in case no clocks are being described in DT. This special case will now be handled by the follow-up check searching for "refclk" and exit with -EINVAL.
None of this will be hit in practice, since the driver is only used by RK3588 and RK3576 - on these platforms the DT is validated to contain the clocks and the clock driver is force probed early. Thus there is no need to backport this.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +2 -2
@@ -427,8 +427,8 @@ static int rk_udphy_clk_init(struct rk_udphy *udphy, struct device *dev)int i; udphy->num_clks =devm_clk_bulk_get_all (dev, &udphy->clks); -if (udphy->num_clks <1 ) -return -ENODEV ; +if (udphy->num_clks <0 ) +return udphy->num_clks;/* used for configure phy reference clock frequency */ for (i =0 ; i < udphy->num_clks; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 780/1756 phy: rockchip: usbdp: Handle missing clock-names DT property gracefully
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 17cd5e026a6e806b811f915b8e02a8b9d14f6f41 ]
The rk_udphy_clk_init() function would currently try to do a strncmp for a NULL pointer, if DT specifies 'clocks' property, but no 'clock-names' property. Fix this by making sure the clock has an id string set.
Note that DT binding requires setting clock-names, so this is only a problem when booting a non-compliant device tree.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/rockchip/phy-rockchip-usbdp.c +3 -0
@@ -432,6 +432,9 @@ static int rk_udphy_clk_init(struct rk_udphy *udphy, struct device *dev)/* used for configure phy reference clock frequency */ for (i =0 ; i < udphy->num_clks; i++) { +if (!udphy->clks[i].id) +continue ; +if (!strncmp (udphy->clks[i].id,"refclk" ,6 )) { udphy->refclk = udphy->clks[i].clk;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 781/1756 phy: rockchip: usbdp: Drop seamless DP takeover
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 1ab628ce8f3ab694c28dcfcd5b1eec0cf9f499b8 ]
Right now the DRM drivers do not support seamless DP takeover and I'm I'm not aware of any bootloader implementing this feature either.
In any case this feature would be limited to boards using the USBDP PHY for a DP or eDP connection instead of the more commonly USB-C connector. With USB-C's DP AltMode a seamless DP takeover requires handing over the state of the TCPM state machine from the bootloader to the kernel. This in turn requires a huge amount of work to keep the state machine implementations synchronized. It's very unlikely we will see somebody implementing that in the foreseeable future.
As the current code is obviously buggy and untested, let's simply drop support for seamless DP takeover. It can be re-implemented cleanly once somebody adds all missing bits.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 31 ----------------------- 1 file changed, 31 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +0 -31
@@ -452,11 +452,6 @@ static int rk_udphy_reset_assert_all(struct rk_udphy *udphy)return reset_control_bulk_assert (udphy->num_rsts, udphy->rsts); } -static int rk_udphy_reset_deassert_all (struct rk_udphy *udphy) -{ -return reset_control_bulk_deassert (udphy->num_rsts, udphy->rsts); -} -static int rk_udphy_reset_deassert (struct rk_udphy *udphy,char *name) {struct reset_control_bulk_data *list = udphy->rsts;
@@ -924,28 +919,6 @@ static int rk_udphy_parse_lane_mux_data(struct rk_udphy *udphy)return 0 ; } -static int rk_udphy_get_initial_status (struct rk_udphy *udphy) -{ -int ret; -u32 value; - - ret =clk_bulk_prepare_enable (udphy->num_clks, udphy->clks); -if (ret) { -dev_err (udphy->dev,"failed to enable clk\n" ); -return ret; - } - -rk_udphy_reset_deassert_all (udphy); - -regmap_read (udphy->pma_regmap,CMN_LANE_MUX_AND_EN_OFFSET , &value); -if (FIELD_GET (CMN_DP_LANE_MUX_ALL , value) &&FIELD_GET (CMN_DP_LANE_EN_ALL , value)) - udphy->status =UDPHY_MODE_DP ; -else -rk_udphy_disable (udphy); - -return 0 ; -} -static int rk_udphy_parse_dt (struct rk_udphy *udphy) {struct device *dev = udphy->dev;
@@ -1496,10 +1469,6 @@ static int rk_udphy_probe(struct platform_device *pdev)if (ret)return ret; - ret =rk_udphy_get_initial_status (udphy); -if (ret) -return ret; -mutex_init (&udphy->mutex);platform_set_drvdata (pdev, udphy);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 782/1756 phy: rockchip: usbdp: Limit DP lane count to muxed lanes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 443997ca8d797375ff35e8f3ad3828799e88f71b ]
In theory the DP controller could request 4 lanes when the PHY is restricted to 2 lanes as the other half is used by USB3.
With the current user (DW-DP) this cannot happen, but as the check is cheap and users might change in the future protect things accordingly. Not doing so would corrupt USB3 usage by the following code configuring the voltages.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/rockchip/phy-rockchip-usbdp.c +3 -0
@@ -1102,6 +1102,9 @@ static int rk_udphy_dp_phy_verify_link_rate(struct rk_udphy *udphy,static int rk_udphy_dp_phy_verify_lanes (struct rk_udphy *udphy,struct phy_configure_opts_dp *dp) { +if (dp->lanes > udphy->dp_lanes) +return -EINVAL ; +switch (dp->lanes) {case 1 :case 2 :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 783/1756 phy: rockchip: usbdp: add rk3576 device match data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Wang <[email protected]>
[ Upstream commit a76de028c619dd18f89786805bcc7bb4d379ea9f ]
This adds RK3576 device match data support.
Stable-dep-of: b1ca8de219ae ("phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB")
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/phy/rockchip/phy-rockchip-usbdp.c +41 -0
@@ -1530,6 +1530,43 @@ static const char * const rk_udphy_rst_list[] = {"init" ,"cmn" ,"lane" ,"pcs_apb" ,"pma_apb" }; +static const struct rk_udphy_cfg rk3576_udphy_cfgs = { + .num_phys =1 , + .phy_ids = {0x2b010000 }, + .num_rsts =ARRAY_SIZE (rk_udphy_rst_list), + .rst_list = rk_udphy_rst_list, + .grfcfg = { +/* u2phy-grf */ + .bvalid_phy_con =RK_UDPHY_GEN_GRF_REG (0x0010 ,1 ,0 ,0x2 ,0x3 ), + .bvalid_grf_con =RK_UDPHY_GEN_GRF_REG (0x0000 ,15 ,14 ,0x1 ,0x3 ), + +/* usb-grf */ + .usb3otg0_cfg =RK_UDPHY_GEN_GRF_REG (0x0030 ,15 ,0 ,0x1100 ,0x0188 ), + +/* usbdpphy-grf */ + .low_pwrn =RK_UDPHY_GEN_GRF_REG (0x0004 ,13 ,13 ,0 ,1 ), + .rx_lfps =RK_UDPHY_GEN_GRF_REG (0x0004 ,14 ,14 ,0 ,1 ), + }, + .vogrfcfg = { + { + .hpd_trigger =RK_UDPHY_GEN_GRF_REG (0x0000 ,11 ,10 ,1 ,3 ), + .dp_lane_reg =0x0000 , + }, + }, + .dp_tx_ctrl_cfg = { + rk3588_dp_tx_drv_ctrl_rbr_hbr_typec, + rk3588_dp_tx_drv_ctrl_rbr_hbr_typec, + rk3588_dp_tx_drv_ctrl_hbr2, + rk3588_dp_tx_drv_ctrl_hbr3, + }, + .dp_tx_ctrl_cfg_typec = { + rk3588_dp_tx_drv_ctrl_rbr_hbr_typec, + rk3588_dp_tx_drv_ctrl_rbr_hbr_typec, + rk3588_dp_tx_drv_ctrl_hbr2, + rk3588_dp_tx_drv_ctrl_hbr3, + }, +}; +static const struct rk_udphy_cfg rk3588_udphy_cfgs = { .num_phys =2 , .phy_ids = {
@@ -1576,6 +1613,10 @@ static const struct rk_udphy_cfg rk3588_udphy_cfgs = { };static const struct of_device_id rk_udphy_dt_match[] = { + { + .compatible ="rockchip,rk3576-usbdp-phy" , + .data = &rk3576_udphy_cfgs + }, { .compatible ="rockchip,rk3588-usbdp-phy" , .data = &rk3588_udphy_cfgs
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 784/1756 phy: rockchip: usbdp: Add missing mode_change update
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 5def5d61ea5ac6f391364f6fdcff13a27a52026e ]
rk_udphy_set_typec_default_mapping() updates the available modes, but does not set the mode_change as required. This results in missing re-initialization and thus non-working DisplayPort.
Fix this issue by introducing a new helper to update the available modes.
Stable-dep-of: b1ca8de219ae ("phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB")
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +11 -5
@@ -616,6 +616,15 @@ static void rk_udphy_dp_hpd_event_trigger(struct rk_udphy *udphy, bool hpd)rk_udphy_grfreg_write (udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, hpd); } +static void rk_udphy_mode_set (struct rk_udphy *udphy,u8 mode) +{ +if (udphy->mode == mode) +return ; + + udphy->mode_change = true; + udphy->mode = mode; +} +static void rk_udphy_set_typec_default_mapping (struct rk_udphy *udphy) {if (udphy->flip) {
@@ -646,7 +655,7 @@ static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)gpiod_set_value_cansleep (udphy->sbu2_dc_gpio,1 ); } - udphy->mode =UDPHY_MODE_DP_USB ; +rk_udphy_mode_set (udphy,UDPHY_MODE_DP_USB ); } static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
@@ -1364,10 +1373,7 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,usleep_range (750 ,800 );rk_udphy_dp_hpd_event_trigger (udphy, true); }else if (data->status &DP_STATUS_HPD_STATE ) { -if (udphy->mode != mode) { - udphy->mode = mode; - udphy->mode_change = true; - } +rk_udphy_mode_set (udphy, mode);rk_udphy_dp_hpd_event_trigger (udphy, true); }else {rk_udphy_dp_hpd_event_trigger (udphy, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 785/1756 phy: rockchip: usbdp: Support single-lane DP
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yubing <[email protected]>
[ Upstream commit ae9b60ef1d626d1a4fdf8854f66d58f6ac56e37d ]
Implement support for using just a single DisplayPort line.
Stable-dep-of: b1ca8de219ae ("phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB")
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 64 ++++++++++------------- 1 file changed, 27 insertions(+), 37 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +27 -37
@@ -193,6 +193,7 @@ struct rk_udphy {int id;bool dp_in_use; +int dp_lanes;/* PHY const config */ const struct rk_udphy_cfg *cfgs;
@@ -534,6 +535,13 @@ static void rk_udphy_usb_bvalid_enable(struct rk_udphy *udphy, u8 enable)* <0 1> dpln0 dpln1 usbrx usbtx * <2 3> usbrx usbtx dpln0 dpln1 * --------------------------------------------------------------------------- +* if 1 lane for dp function, 2 lane for usb function, define rockchip,dp-lane-mux = <x>; +* sample as follow: +* --------------------------------------------------------------------------- +* B11-B10 A2-A3 A11-A10 B2-B3 +* rockchip,dp-lane-mux ln0(tx/rx) ln1(tx) ln2(tx/rx) ln3(tx) +* <0> dpln0 \ usbrx usbtx +* --------------------------------------------------------------------------- */ static void rk_udphy_dplane_select (struct rk_udphy *udphy)
@@ -541,18 +549,18 @@ static void rk_udphy_dplane_select(struct rk_udphy *udphy)const struct rk_udphy_cfg *cfg = udphy->cfgs;u32 value =0 ; -switch (udphy->mode) { -case UDPHY_MODE_DP : - value |=2 << udphy->dp_lane_sel[2 ] *2 ; +switch (udphy->dp_lanes) { +case 4 : value |=3 << udphy->dp_lane_sel[3 ] *2 ; + value |=2 << udphy->dp_lane_sel[2 ] *2 ; fallthrough; -case UDPHY_MODE_DP_USB : - value |=0 << udphy->dp_lane_sel[0 ] *2 ; +case 2 : value |=1 << udphy->dp_lane_sel[1 ] *2 ; -break ; + fallthrough; -case UDPHY_MODE_USB : +case 1 : + value |=0 << udphy->dp_lane_sel[0 ] *2 ;break ;default :
@@ -565,28 +573,6 @@ static void rk_udphy_dplane_select(struct rk_udphy *udphy) FIELD_PREP(DP_AUX_DOUT_SEL, udphy->dp_aux_dout_sel) | value); } -static int rk_udphy_dplane_get (struct rk_udphy *udphy) -{ -int dp_lanes; - -switch (udphy->mode) { -case UDPHY_MODE_DP : - dp_lanes =4 ; -break ; - -case UDPHY_MODE_DP_USB : - dp_lanes =2 ; -break ; - -case UDPHY_MODE_USB : -default : - dp_lanes =0 ; -break ; - } - -return dp_lanes; -} -static void rk_udphy_dplane_enable (struct rk_udphy *udphy,int dp_lanes) {u32 val =0 ;
@@ -656,6 +642,7 @@ static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy) }rk_udphy_mode_set (udphy,UDPHY_MODE_DP_USB ); + udphy->dp_lanes =2 ; } static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
@@ -894,7 +881,7 @@ static int rk_udphy_parse_lane_mux_data(struct rk_udphy *udphy)return 0 ; } -if (num_lanes !=2 && num_lanes !=4 ) +if (num_lanes !=1 && num_lanes !=2 && num_lanes !=4 )return dev_err_probe (udphy->dev, -EINVAL ,"invalid number of lane mux\n" );
@@ -920,9 +907,11 @@ static int rk_udphy_parse_lane_mux_data(struct rk_udphy *udphy) } udphy->mode =UDPHY_MODE_DP ; -if (num_lanes ==2 ) { + udphy->dp_lanes = num_lanes; +if (num_lanes ==1 || num_lanes ==2 ) { udphy->mode |=UDPHY_MODE_USB ; - udphy->flip = (udphy->lane_mux_sel[0 ] ==PHY_LANE_MUX_DP ); + udphy->flip = (udphy->lane_mux_sel[0 ] ==PHY_LANE_MUX_DP ) || + (udphy->lane_mux_sel[1 ] ==PHY_LANE_MUX_DP ); }return 0 ;
@@ -1050,18 +1039,17 @@ static int rk_udphy_dp_phy_exit(struct phy *phy)static int rk_udphy_dp_phy_power_on (struct phy *phy) {struct rk_udphy *udphy =phy_get_drvdata (phy); -int ret, dp_lanes; +int ret;mutex_lock (&udphy->mutex); - dp_lanes =rk_udphy_dplane_get (udphy); -phy_set_bus_width (phy, dp_lanes); +phy_set_bus_width (phy, udphy->dp_lanes); ret =rk_udphy_power_on (udphy,UDPHY_MODE_DP );if (ret) goto unlock; -rk_udphy_dplane_enable (udphy, dp_lanes); +rk_udphy_dplane_enable (udphy, udphy->dp_lanes);rk_udphy_dplane_select (udphy);
@@ -1344,6 +1332,7 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux, udphy->lane_mux_sel[2 ] =PHY_LANE_MUX_DP ; udphy->lane_mux_sel[3 ] =PHY_LANE_MUX_DP ; mode =UDPHY_MODE_DP ; + udphy->dp_lanes =4 ;break ;case TYPEC_DP_STATE_D :
@@ -1360,6 +1349,7 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux, udphy->lane_mux_sel[3 ] =PHY_LANE_MUX_DP ; } mode =UDPHY_MODE_DP_USB ; + udphy->dp_lanes =2 ;break ; }
@@ -1505,7 +1495,7 @@ static int rk_udphy_probe(struct platform_device *pdev) ret =PTR_ERR (udphy->phy_dp);return dev_err_probe (dev, ret,"failed to create DP phy\n" ); } -phy_set_bus_width (udphy->phy_dp,rk_udphy_dplane_get (udphy)); +phy_set_bus_width (udphy->phy_dp, udphy->dp_lanes); udphy->phy_dp->attrs.max_link_rate =8100 ;phy_set_drvdata (udphy->phy_dp, udphy);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 786/1756 phy: rockchip: usbdp: Drop DP HPD handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 4fd2c13cbb11f5483a43cc789cb8de1c3bd23238 ]
Drop the HPD handling logic from the USBDP PHY. The registers involved require the display controller power domain being enabled and thus the HPD signal should be handled by the displayport controller itself. Apart from that the HPD handling as it is done here is incorrect and misses hotplug events happening after the USB-C connector (e.g. when a USB-C to HDMI adapter is involved and the HDMI cable is replugged).
Proper USB-C DP HPD support requires some restructuring of the DP controller driver, which will happen independent of this patch. The mainline kernel does not yet support USB-C DP AltMode on RK3588 and RK3576, so it is fine to drop this code without adding the counterpart in the DRM in an atomic change.
Stable-dep-of: b1ca8de219ae ("phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB")
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 85 +++-------------------- 1 file changed, 9 insertions(+), 76 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +9 -76
@@ -127,7 +127,6 @@ struct rk_udphy_grf_cfg {struct rk_udphy_vogrf_cfg {/* vo-grf */ -struct rk_udphy_grf_reg hpd_trigger;u32 dp_lane_reg; };
@@ -185,14 +184,11 @@ struct rk_udphy {u32 dp_lane_sel[4 ];u32 dp_aux_dout_sel;u32 dp_aux_din_sel; -bool dp_sink_hpd_sel; -bool dp_sink_hpd_cfg;unsigned int link_rate;unsigned int lanes;u8 bw;int id; -bool dp_in_use;int dp_lanes;/* PHY const config */
@@ -589,19 +585,6 @@ static void rk_udphy_dplane_enable(struct rk_udphy *udphy, int dp_lanes) CMN_DP_CMN_RSTN, FIELD_PREP(CMN_DP_CMN_RSTN, 0x0)); } -static void rk_udphy_dp_hpd_event_trigger (struct rk_udphy *udphy,bool hpd) -{ -const struct rk_udphy_cfg *cfg = udphy->cfgs; - - udphy->dp_sink_hpd_sel = true; - udphy->dp_sink_hpd_cfg = hpd; - -if (!udphy->dp_in_use) -return ; - -rk_udphy_grfreg_write (udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, hpd); -} -static void rk_udphy_mode_set (struct rk_udphy *udphy,u8 mode) {if (udphy->mode == mode)
@@ -1013,29 +996,6 @@ static void rk_udphy_power_off(struct rk_udphy *udphy, u8 mode)rk_udphy_disable (udphy); } -static int rk_udphy_dp_phy_init (struct phy *phy) -{ -struct rk_udphy *udphy =phy_get_drvdata (phy); - -mutex_lock (&udphy->mutex); - - udphy->dp_in_use = true; - -mutex_unlock (&udphy->mutex); - -return 0 ; -} - -static int rk_udphy_dp_phy_exit (struct phy *phy) -{ -struct rk_udphy *udphy =phy_get_drvdata (phy); - -mutex_lock (&udphy->mutex); - udphy->dp_in_use = false; -mutex_unlock (&udphy->mutex); -return 0 ; -} -static int rk_udphy_dp_phy_power_on (struct phy *phy) {struct rk_udphy *udphy =phy_get_drvdata (phy);
@@ -1267,8 +1227,6 @@ static int rk_udphy_dp_phy_configure(struct phy *phy, }static const struct phy_ops rk_udphy_dp_phy_ops = { - .init = rk_udphy_dp_phy_init, - .exit = rk_udphy_dp_phy_exit, .power_on = rk_udphy_dp_phy_power_on, .power_off = rk_udphy_dp_phy_power_off, .configure = rk_udphy_dp_phy_configure,
@@ -1322,6 +1280,14 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,struct rk_udphy *udphy =typec_mux_get_drvdata (mux);u8 mode; +/* +* Ignore mux events not involving DP AltMode, because +* the mode field is being reused, e.g. state->mode == 4 +* could be either TYPEC_MODE_USB4 or TYPEC_DP_STATE_C. +*/ +if (!state->alt || state->alt->svid !=USB_TYPEC_DP_SID ) +return 0 ; +mutex_lock (&udphy->mutex);switch (state->mode) {
@@ -1353,22 +1319,7 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,break ; } -if (state->alt && state->alt->svid ==USB_TYPEC_DP_SID ) { -struct typec_displayport_data *data = state->data; - -if (!data) { -rk_udphy_dp_hpd_event_trigger (udphy, false); - }else if (data->status &DP_STATUS_IRQ_HPD ) { -rk_udphy_dp_hpd_event_trigger (udphy, false); -usleep_range (750 ,800 ); -rk_udphy_dp_hpd_event_trigger (udphy, true); - }else if (data->status &DP_STATUS_HPD_STATE ) { -rk_udphy_mode_set (udphy, mode); -rk_udphy_dp_hpd_event_trigger (udphy, true); - }else { -rk_udphy_dp_hpd_event_trigger (udphy, false); - } - } +rk_udphy_mode_set (udphy, mode);mutex_unlock (&udphy->mutex);return 0 ;
@@ -1508,20 +1459,6 @@ static int rk_udphy_probe(struct platform_device *pdev)return 0 ; } -static int __maybe_unused rk_udphy_resume (struct device *dev) -{ -struct rk_udphy *udphy =dev_get_drvdata (dev); - -if (udphy->dp_sink_hpd_sel) -rk_udphy_dp_hpd_event_trigger (udphy, udphy->dp_sink_hpd_cfg); - -return 0 ; -} - -static const struct dev_pm_ops rk_udphy_pm_ops = { -SET_LATE_SYSTEM_SLEEP_PM_OPS (NULL , rk_udphy_resume) -}; -static const char *const rk_udphy_rst_list[] = {"init" ,"cmn" ,"lane" ,"pcs_apb" ,"pma_apb" };
@@ -1545,7 +1482,6 @@ static const struct rk_udphy_cfg rk3576_udphy_cfgs = { }, .vogrfcfg = { { - .hpd_trigger = RK_UDPHY_GEN_GRF_REG(0x0000, 11, 10, 1, 3), .dp_lane_reg = 0x0000, }, },
@@ -1586,11 +1522,9 @@ static const struct rk_udphy_cfg rk3588_udphy_cfgs = { }, .vogrfcfg = { { - .hpd_trigger = RK_UDPHY_GEN_GRF_REG(0x0000, 11, 10, 1, 3), .dp_lane_reg = 0x0000, }, { - .hpd_trigger = RK_UDPHY_GEN_GRF_REG(0x0008, 11, 10, 1, 3), .dp_lane_reg = 0x0008, }, },
@@ -1626,7 +1560,6 @@ static struct platform_driver rk_udphy_driver = { .driver = { .name = "rockchip-usbdp-phy", .of_match_table = rk_udphy_dt_match, - .pm = &rk_udphy_pm_ops, }, };module_platform_driver (rk_udphy_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 787/1756 phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit b1ca8de219ae6e4d9eec22acfbe4357d8addd94c ]
Handle TYPEC_STATE_SAFE and TYPEC_STATE_USB Type-C state events, so that the muxing is properly updated when exiting DP AltMode.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +15 -6
@@ -1274,18 +1274,27 @@ static const struct phy_ops rk_udphy_usb3_phy_ops = { .owner = THIS_MODULE, }; +static bool rk_udphy_is_supported_mode (struct typec_mux_state *state) +{ +/* Handle Safe State and USB State */ +if (state->mode <TYPEC_STATE_MODAL ) +return true; + +/* Handle DP AltMode */ +if (state->alt && state->alt->svid ==USB_TYPEC_DP_SID ) +return true; + +return false; +} +static int rk_udphy_typec_mux_set (struct typec_mux_dev *mux,struct typec_mux_state *state) {struct rk_udphy *udphy =typec_mux_get_drvdata (mux);u8 mode; -/* -* Ignore mux events not involving DP AltMode, because -* the mode field is being reused, e.g. state->mode == 4 -* could be either TYPEC_MODE_USB4 or TYPEC_DP_STATE_C. -*/ -if (!state->alt || state->alt->svid !=USB_TYPEC_DP_SID ) +/* Ignore mux events not involving USB or DP */ +if (!rk_udphy_is_supported_mode (state))return 0 ;mutex_lock (&udphy->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 788/1756 phy: rockchip: usbdp: Hold mutex in DP PHY configure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 619233ce6b2329529c9f0ff9682d6e22d160ebd6 ]
rk_udphy_dp_phy_configure() accesses some variables from the struct rk_udphy, which are updated independently from the USB-C framework.
The USB-C mux/orientation switch functions already hold a mutex to ensure mutual exclusive access to the struct rk_udphy states, so simply hold the same one in the DP PHY configuration function.
Reproducing problems due to this on real hardware would be really hard, but could be possible when quickly re-connecting the USB-C connector.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/rockchip/phy-rockchip-usbdp.c +2 -0
@@ -1136,6 +1136,8 @@ static int rk_udphy_dp_phy_configure(struct phy *phy,u32 i, val, lane;int ret; +guard (mutex)(&udphy->mutex); +if (dp->set_rate) { ret =rk_udphy_dp_phy_verify_link_rate (udphy, dp);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 789/1756 phy: rockchip: usbdp: Rename mode_change to phy_needs_reinit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit fbce9cc28cadb24026a6c061819d42e50d3bfea0 ]
Right now the mode_change property is set whenever the mode changes between USB-only, DP-only and USB-DP. It is needed, because on any mode change the PHY needs to be re-initialized. Apparently at least DP also requires a re-init when the cable orientation is changed, which is currently not being done (except when the orientation switch also involves a mode change). Prepare for this by renaming mode_change to phy_needs_reinit.
Stable-dep-of: cf3aa34e6f07 ("phy: rockchip: usbdp: Avoid xHCI SErrors")
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +5 -5
@@ -170,7 +170,7 @@ struct rk_udphy {/* PHY status management */ bool flip; -bool mode_change; +bool phy_needs_reinit;u8 mode;u8 status;
@@ -590,7 +590,7 @@ static void rk_udphy_mode_set(struct rk_udphy *udphy, u8 mode)if (udphy->mode == mode)return ; - udphy->mode_change = true; + udphy->phy_needs_reinit = true; udphy->mode = mode; }
@@ -963,8 +963,8 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)if (udphy->mode &UDPHY_MODE_USB )rk_udphy_u3_port_disable (udphy, false); - udphy->mode_change = false; - }else if (udphy->mode_change) { + udphy->phy_needs_reinit = false; + }else if (udphy->phy_needs_reinit) {if (udphy->mode ==UDPHY_MODE_DP )rk_udphy_u3_port_disable (udphy, true);
@@ -972,7 +972,7 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode) ret =rk_udphy_setup (udphy);if (ret)return ret; - udphy->mode_change = false; + udphy->phy_needs_reinit = false; } udphy->status |= mode;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 790/1756 phy: rockchip: usbdp: Avoid xHCI SErrors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit cf3aa34e6f0798544c26ad93a6c3c2231ab09738 ]
The USBDP PHY provides the PIPE clock to the USB3 controller, which means the PHY must be fully running when anything tries to access the xHCI registers.
When switching between USB3-only, USB3 + DP and DP-only mode, the PHY must be re-initialized resulting in a short period of the PHY being disabled. If the DWC3 driver decides to access the xHCI at this point the system will fail with an SError.
This patch avoids the problems by disabling the USB3 port before re-initializing it. This does a couple of things:
- forces phystatus to 0 from GRF (not from PHY)
- switches PIPE clock source from PHY to UTMI (safe fallback clock)
- num_u3_port=0
The last part will be ignored, as DWC3 already probed, but the clock re-routing will avoid the SError. There is a small delay afterwards to make sure the mux happened. The datasheet gives no hints how long it takes, so delay time is a guess.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +5 -2
@@ -965,13 +965,16 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)rk_udphy_u3_port_disable (udphy, false); udphy->phy_needs_reinit = false; }else if (udphy->phy_needs_reinit) { -if (udphy->mode ==UDPHY_MODE_DP ) -rk_udphy_u3_port_disable (udphy, true); +rk_udphy_u3_port_disable (udphy, true); +udelay (10 );rk_udphy_disable (udphy); ret =rk_udphy_setup (udphy);if (ret)return ret; + +if (!udphy->hs && udphy->mode &UDPHY_MODE_USB ) +rk_udphy_u3_port_disable (udphy, false); udphy->phy_needs_reinit = false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 791/1756 phy: rockchip: usbdp: Handle rk_udphy_reset_deassert errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 35101e2f49c04bf1cfc69b8a0d3f85c742369ccc ]
Handle rk_udphy_reset_deassert returning errors to avoid theoretical (Rockchip reset controller driver does not return errors) SError.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +19 -6
@@ -771,8 +771,12 @@ static int rk_udphy_init(struct rk_udphy *udphy)/* Step 1: power on pma and deassert apb rstn */ rk_udphy_grfreg_write (udphy->udphygrf, &cfg->grfcfg.low_pwrn, true); -rk_udphy_reset_deassert (udphy,"pma_apb" ); -rk_udphy_reset_deassert (udphy,"pcs_apb" ); + ret =rk_udphy_reset_deassert (udphy,"pma_apb" ); +if (ret) + goto assert_resets; + ret =rk_udphy_reset_deassert (udphy,"pcs_apb" ); +if (ret) + goto assert_resets;/* Step 2: set init sequence and phy refclk */ ret = regmap_multi_reg_write(udphy->pma_regmap, rk_udphy_init_sequence,
@@ -798,8 +802,11 @@ static int rk_udphy_init(struct rk_udphy *udphy) FIELD_PREP(CMN_DP_LANE_EN_ALL, 0));/* Step 4: deassert init rstn and wait for 200ns from datasheet */ -if (udphy->mode &UDPHY_MODE_USB ) -rk_udphy_reset_deassert (udphy,"init" ); +if (udphy->mode &UDPHY_MODE_USB ) { + ret =rk_udphy_reset_deassert (udphy,"init" ); +if (ret) + goto assert_resets; + }if (udphy->mode &UDPHY_MODE_DP ) { regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET,
@@ -811,8 +818,14 @@ static int rk_udphy_init(struct rk_udphy *udphy)/* Step 5: deassert cmn/lane rstn */ if (udphy->mode &UDPHY_MODE_USB ) { -rk_udphy_reset_deassert (udphy,"cmn" ); -rk_udphy_reset_deassert (udphy,"lane" ); + ret =rk_udphy_reset_deassert (udphy,"cmn" ); +if (ret) + goto assert_resets; + + ret =rk_udphy_reset_deassert (udphy,"lane" ); +if (ret) + goto assert_resets; + }/* Step 6: wait for lock done of pll */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 792/1756 phy: rockchip: usbdp: Only enable USB3 when not in high-speed mode
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit fbbf6c85b08008bf68ef49931175edeaa36ba82f ]
Ensure that USB3 mode is not accidently enabled during PHY re-init for systems that are configured as high-speed only via DT.
--- drivers/phy/rockchip/phy-rockchip-usbdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/rockchip/phy-rockchip-usbdp.c +1 -1
@@ -974,7 +974,7 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)if (ret)return ret; -if (udphy->mode &UDPHY_MODE_USB ) +if (!udphy->hs && udphy->mode &UDPHY_MODE_USB )rk_udphy_u3_port_disable (udphy, false); udphy->phy_needs_reinit = false; }else if (udphy->phy_needs_reinit) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 793/1756 scsi: scsi_debug: Refuse a negative physblk_exp
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit a349876633f7a583429367daf16f9a4282118255 ]
sdebug_init() refuses a physblk_exp above 15, but the parameter is a signed int, so a negative value is accepted. The driver then shifts by it when it builds the Block Limits VPD page, which is undefined behaviour, and READ CAPACITY (16) reports an exponent of 15 for -1.
Refuse a negative value as well, and print it as a signed value.
--- drivers/scsi/scsi_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +2 -2
@@ -7809,8 +7809,8 @@ static int __init scsi_debug_init(void)return -EINVAL ; } -if (sdebug_physblk_exp >15 ) { -pr_err ("invalid physblk_exp %u\n" , sdebug_physblk_exp); +if (sdebug_physblk_exp <0 || sdebug_physblk_exp >15 ) { +pr_err ("invalid physblk_exp %d\n" , sdebug_physblk_exp);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 794/1756 scsi: scsi_debug: Take the zone metadata lock before the data lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit c9aedbcbff0fe31fabdea09600609eb30e05441d ]
resp_comp_write() takes the data lock and then the zone metadata lock, while every other command that takes both takes the metadata lock first and reaches the data lock through do_device_access(). A COMPARE AND WRITE and any other write to the same store can therefore deadlock each other.
Take the locks in the same order as everywhere else.
Correct the comment above map_region() while here: the provisioning map is covered by the metadata lock rather than the data lock, which is why resp_unmap() takes only the metadata lock.
--- drivers/scsi/scsi_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/scsi_debug.c +3 -3
@@ -4756,20 +4756,20 @@ static int resp_comp_write(struct scsi_cmnd *scp,"indicated=%u, IO sent=%d bytes\n" , my_name, dnum * lb_size, ret); -sdeb_data_write_lock (sip);sdeb_meta_write_lock (sip); +sdeb_data_write_lock (sip);if (!comp_write_worker (sip, lba, num, arr, false)) {mk_sense_buffer (scp,MISCOMPARE ,MISCOMPARE_VERIFY_ASC ,0 ); retval = check_condition_result; goto cleanup_unlock; } -/* Cover sip->map_storep (which map_region()) sets with data lock */ +/* Cover sip->map_storep (which map_region() sets) with the meta lock */ if (scsi_debug_lbp ())map_region (sip, lba, num); cleanup_unlock: -sdeb_meta_write_unlock (sip);sdeb_data_write_unlock (sip); +sdeb_meta_write_unlock (sip); cleanup_free:kfree (arr);return retval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 795/1756 scsi: scsi_debug: Refuse a short WRITE ATOMIC (16) before writing it
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit b81608b17c5d04c797e6fc1cfb95182c842a4db9 ]
A write whose data-out buffer is shorter than its transfer length is short. An ordinary write transfers what the buffer holds and reports the rest as a residual, but an atomic write cannot be short: SBC-6 r02 (T10/BSR INCITS 587), 4.28.1, requires each atomic write operation to write either all of its data or none of it, and 4.28.2 requires one that cannot complete to leave the LBAs that it specifies unaltered.
resp_atomic_write() does fail a short WRITE ATOMIC (16) with DID_ERROR, but only after do_device_access() has returned, and do_device_access() copies one logical block at a time, so by then the blocks that the buffer did hold have been written. An eight block WRITE ATOMIC (16) with a buffer of four fails having overwritten the first four.
Check the length of the buffer before writing anything, and fail the command with the same DID_ERROR as before.
--- drivers/scsi/scsi_debug.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/scsi_debug.c +8 -0
@@ -5379,6 +5379,14 @@ static int resp_atomic_write(struct scsi_cmnd *scp, } } +/* +* Short atomic writes are not allowed: SBC-6 4.28.2 requires an +* atomic write that cannot complete to leave its LBAs unaltered, and +* do_device_access() would already have written part of it. +*/ +if (scsi_bufflen (scp) < len * sdebug_sector_size) +return DID_ERROR <<16 ; + ret =do_device_access (sip, scp,0 , lba, len,0 , true, true);if (unlikely (ret ==-1 ))return DID_ERROR <<16 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 796/1756 scsi: scsi_debug: Map the region written by WRITE ATOMIC (16)
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 491bd55c35cbb1ce059f22e7f3c6284551970fef ]
When logical block provisioning is enabled, every command that writes user data calls map_region() so that GET LBA STATUS reports the region as mapped. resp_atomic_write() does not, so GET LBA STATUS keeps reporting a region as deallocated after a WRITE ATOMIC (16) has written it.
Call map_region() the way resp_write_dt0() does, holding the zone metadata write lock across the access. That lock is what serialises the map against resp_unmap(), which does nothing unless logical block provisioning is enabled.
--- drivers/scsi/scsi_debug.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/scsi/scsi_debug.c +14 -0
@@ -4173,6 +4173,11 @@ static unsigned int map_state(struct sdeb_store_info *sip, sector_t lba,return mapped; } +/* +* Callers may map the whole range of a write without checking how much of +* it was written. SBC-6 4.7.4.6.2 allows a deallocated LBA to become mapped +* at any time, and only requires an LBA that was written to be mapped. +*/ static void map_region (struct sdeb_store_info *sip,sector_t lba,unsigned int len) {
@@ -5335,6 +5340,7 @@ static int resp_atomic_write(struct scsi_cmnd *scp,u8 *cmd = scp->cmnd;u16 boundary, len;u64 lba, lba_tmp; +bool lbp =scsi_debug_lbp ();int ret;if (!scsi_debug_atomic_write ()) {
@@ -5387,7 +5393,15 @@ static int resp_atomic_write(struct scsi_cmnd *scp,if (scsi_bufflen (scp) < len * sdebug_sector_size)return DID_ERROR <<16 ; +if (lbp) +sdeb_meta_write_lock (sip); + ret =do_device_access (sip, scp,0 , lba, len,0 , true, true); +if (lbp) { +map_region (sip, lba, len); +sdeb_meta_write_unlock (sip); + } +if (unlikely (ret ==-1 ))return DID_ERROR <<16 ;if (unlikely (ret != len * sdebug_sector_size))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 797/1756 scsi: scsi_debug: Validate the access parameters of WRITE ATOMIC (16)
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit a6c339feb830daa097ccc4c50c339c1733c12d42 ]
resp_atomic_write() validates the fields that are specific to an atomic write, but never the range that the command addresses. Every other command that writes user data calls check_device_access_params() first, which rejects a transfer that ends beyond the capacity of the device, one whose length exceeds the size of the store, and any write to a write protected device.
Call check_device_access_params(). The zone checks that it ends with are unreachable, as atomic writes and ZBC emulation are mutually exclusive.
--- drivers/scsi/scsi_debug.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/scsi_debug.c +4 -0
@@ -5385,6 +5385,10 @@ static int resp_atomic_write(struct scsi_cmnd *scp, } } + ret =check_device_access_params (scp, lba, len, true); +if (ret) +return ret; +/* * Short atomic writes are not allowed: SBC-6 4.28.2 requires an * atomic write that cannot complete to leave its LBAs unaltered, and
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 798/1756 scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 8d1cc285194dbcba88c136e1ff7c25cb10e38a5b ]
A device reset returns the drive's density and block size to their defaults. Commit 7081dc75df79 ("scsi: st: Restore some drive settings after reset") re-applies values changed by the user when the position is recovered with MTREW, MTSEEK or MTEOM. MTLOAD and MTRETEN are also allowed to clear the reset condition and also leave the same medium at BOT, but they restore nothing.
Because check_tape() reads the drive's block size with MODE SENSE on every open, the driver silently switches to the drive default after the reset. An application that set fixed-block mode with MTSETBLK and recovers with MTLOAD or MTRETEN keeps writing, but variable-length blocks, without any error.
Restore the changed density and block size for MTLOAD and MTRETEN as well. Both operations may make the drive report a new medium, and the new session started by check_tape() clears the "changed" flags and applies the mode defaults. So save the values before the operation, let check_tape() run first (do_load_unload() already calls it for MTLOAD; call it after MTRETEN), and then re-apply them. Retry the restore once in case a unit attention is still pending. Only restore when the drive is ready after the
operation: with an immediate-mode load and O_NONBLOCK, check_tape() does not wait and the drive may still be loading. In immediate mode (MT_ST_NOWAIT) MTRETEN may return before the retension has finished; do not wait for it there.
MTOFFL is not changed: the medium is unloaded and a different one may be loaded next, for which the mode defaults apply.
Reproduced with scsi_debug (which reports a new medium after MTRETEN and MTLOAD) and with IBM LTO drives on FC (which do not).
--- drivers/scsi/st.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/scsi/st.c +51 -0
@@ -3513,6 +3513,23 @@ static int partition_tape(struct scsi_tape *STp, int size) +/* +* Re-apply a density and block size that were changed by the user before a +* device reset (a negative value means "not changed"). A unit attention +* still pending after the operation (e.g. new medium after a load) fails the +* first MODE SELECT, so retry each once. As in the other post-reset restore +* path, errors are ignored and one setting failing does not prevent +* restoring the other. +*/ +static void st_restore_changed_settings (struct scsi_tape *STp,int density, +int blksize) +{ +if (density >=0 &&st_int_ioctl (STp,MTSETDENSITY , density)) +st_int_ioctl (STp,MTSETDENSITY , density); +if (blksize >=0 &&st_int_ioctl (STp,MTSETBLK , blksize)) +st_int_ioctl (STp,MTSETBLK , blksize); +} +/* The ioctl command */ static long st_ioctl (struct file *file,unsigned int cmd_in,unsigned long arg) {
@@ -3521,6 +3538,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)int retval =0 ;unsigned int blk;bool cmd_mtiocget; +int restore_density =-1 , restore_blksize =-1 ;struct scsi_tape *STp = file->private_data;struct st_modedef *STm;struct st_partstat *STps;
@@ -3660,6 +3678,17 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)st_int_ioctl (STp,MTSETDENSITY , STp->changed_density);if (STp->blksize_changed)st_int_ioctl (STp,MTSETBLK , STp->changed_blksize); + }else if (mtc.mt_op ==MTLOAD || mtc.mt_op ==MTRETEN ) { +/* +* The same medium ends up at BOT, so the settings +* apply as with MTREW. The operation may start a +* new session, which clears the "changed" flags: +* save the values and restore them afterwards. +*/ +if (STp->density_changed) + restore_density = STp->changed_density; +if (STp->blksize_changed) + restore_blksize = STp->changed_blksize; } }
@@ -3739,6 +3768,14 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)if (mtc.mt_op ==MTLOAD ) { retval =do_load_unload (STp, file,max (1 , mtc.mt_count)); +/* +* Restore only if the drive is ready: after an +* immediate-mode load with O_NONBLOCK, check_tape() +* does not wait and the drive may still be loading. +*/ +if (!retval && STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); goto out; }
@@ -3757,6 +3794,20 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) retval =st_compression (STp, (mtc.mt_count &1 )); else retval =st_int_ioctl (STp, mtc.mt_op, mtc.mt_count); +if (!retval && mtc.mt_op ==MTRETEN && !STp->immediate && + (restore_density >=0 || restore_blksize >=0 )) { +/* +* Retension reloads the medium and the drive may +* report a new medium. Let check_tape() start the new +* session (applying the mode defaults) now, as for +* MTLOAD; otherwise it happens at the next open and +* overrides the restored settings. +*/ +if (check_tape (STp, file) >=0 && + STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); + } goto out; }if (!STm->defined) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 799/1756 scsi: st: Record the tape position after a successful MTLOAD
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 54ee0ee9bdeb7e9d3b70cc5c2bdf7e58c4423e8d ]
Commit 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset") allows MTLOAD to clear the reset condition because the tape location is known after MTLOAD. But the driver does not record it:reset_state() sets the file and block numbers to -1, and do_load_unload() leaves them there. check_tape() sets them to 0 only for a new session, which requires a new-medium unit attention. Drives that do not report one when the medium was already loaded (seen with IBM LTO drives) keep reporting file/block -1 in MTIOCGET and no BOT, although the tape is at the beginning.
After a successful load, reset the partition and the state of all partitions, as the new-session path in check_tape() does: partition 0, position at BOT, EOF state cleared and no pending write. Otherwise the driver may still record the previous partition, so that a later MTSETPART to that partition is not performed; a read after loading at EOD fails with EIO; and a partition left in the ST_WRITING state by a partition switch in read() or write() makes st_flush() write a filemark at the beginning of partition 0 when the device is closed.
--- drivers/scsi/st.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/scsi/st.c +24 -0
@@ -2663,6 +2663,30 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_codelse { STp->rew_at_close = STp->autorew_dev; retval =check_tape (STp, filp); +/* +* LOAD leaves the medium at the beginning of partition +* 0. check_tape() records that only for a new session; +* without a new-medium unit attention (the medium was +* already loaded) the partition and the partition state +* would be left as before the load. Reset them as a +* new session does, for all partitions: a stale +* ST_WRITING state would make st_flush() write a +* filemark at the beginning of partition 0. +*/ +if (retval ==CHKRES_READY ) { +int i; + + STp->partition = STp->new_partition =0 ; +for (i =0 ; i <ST_NBR_PARTITIONS ; i++) { + STps = &(STp->ps[i]); + STps->rw =ST_IDLE ; + STps->eof =ST_NOEOF ; + STps->at_sm =0 ; + STps->last_block_valid =0 ; + STps->drv_block =0 ; + STps->drv_file =0 ; + } + }if (retval >0 ) retval =0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 800/1756 phy: freescale: fsl-samsung-hdmi: Replace register defines with macro
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit 4a5a9e2577d61a4ee3e9788e0c2b0c1cbc5ba7b3 ]
There are 47 registers defined as PHY_REG_xx were xx goes from 00 to
47. Simplify this by replacing them all with a macro which is passed the register number to return the proper register offset.
Stable-dep-of: c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 133 ++++++------------- 1 file changed, 43 insertions(+), 90 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +43 -90
@@ -14,76 +14,29 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> -#define PHY_REG_00 0x00 -#define PHY_REG_01 0x04 -#define PHY_REG_02 0x08 -#define PHY_REG_08 0x20 -#define PHY_REG_09 0x24 -#define PHY_REG_10 0x28 -#define PHY_REG_11 0x2c - -#define PHY_REG_12 0x30 -#define REG12_CK_DIV_MASK GENMASK(5, 4) - -#define PHY_REG_13 0x34 -#define REG13_TG_CODE_LOW_MASK GENMASK(7, 0) - -#define PHY_REG_14 0x38 -#define REG14_TOL_MASK GENMASK(7, 4) -#define REG14_RP_CODE_MASK GENMASK(3, 1) -#define REG14_TG_CODE_HIGH_MASK GENMASK(0, 0) - -#define PHY_REG_15 0x3c -#define PHY_REG_16 0x40 -#define PHY_REG_17 0x44 -#define PHY_REG_18 0x48 -#define PHY_REG_19 0x4c -#define PHY_REG_20 0x50 - -#define PHY_REG_21 0x54 -#define REG21_SEL_TX_CK_INV BIT(7) -#define REG21_PMS_S_MASK GENMASK(3, 0) - -#define PHY_REG_22 0x58 -#define PHY_REG_23 0x5c -#define PHY_REG_24 0x60 -#define PHY_REG_25 0x64 -#define PHY_REG_26 0x68 -#define PHY_REG_27 0x6c -#define PHY_REG_28 0x70 -#define PHY_REG_29 0x74 -#define PHY_REG_30 0x78 -#define PHY_REG_31 0x7c -#define PHY_REG_32 0x80 +#define PHY_REG (reg) (reg * 4) +#define REG12_CK_DIV_MASK GENMASK(5, 4) + +#define REG13_TG_CODE_LOW_MASK GENMASK(7, 0) + +#define REG14_TOL_MASK GENMASK(7, 4) +#define REG14_RP_CODE_MASK GENMASK(3, 1) +#define REG14_TG_CODE_HIGH_MASK GENMASK(0, 0) + +#define REG21_SEL_TX_CK_INV BIT(7) +#define REG21_PMS_S_MASK GENMASK(3, 0)/* * REG33 does not match the ref manual. According to Sandor Yu from NXP, * "There is a doc issue on the i.MX8MP latest RM" * REG33 is being used per guidance from Sandor */ +#define REG33_MODE_SET_DONE BIT(7) +#define REG33_FIX_DA BIT(1) -#define PHY_REG_33 0x84 -#define REG33_MODE_SET_DONE BIT(7) -#define REG33_FIX_DA BIT(1) - -#define PHY_REG_34 0x88 -#define REG34_PHY_READY BIT(7) -#define REG34_PLL_LOCK BIT(6) -#define REG34_PHY_CLK_READY BIT(5) - -#define PHY_REG_35 0x8c -#define PHY_REG_36 0x90 -#define PHY_REG_37 0x94 -#define PHY_REG_38 0x98 -#define PHY_REG_39 0x9c -#define PHY_REG_40 0xa0 -#define PHY_REG_41 0xa4 -#define PHY_REG_42 0xa8 -#define PHY_REG_43 0xac -#define PHY_REG_44 0xb0 -#define PHY_REG_45 0xb4 -#define PHY_REG_46 0xb8 -#define PHY_REG_47 0xbc +#define REG34_PHY_READY BIT(7) +#define REG34_PLL_LOCK BIT(6) +#define REG34_PHY_CLK_READY BIT(5)#define PHY_PLL_DIV_REGS_NUM 6
@@ -369,29 +322,29 @@ struct reg_settings { };static const struct reg_settings common_phy_cfg[] = { - {PHY_REG_00 ,0x00 }, {PHY_REG_01 ,0xd1 }, - {PHY_REG_08 ,0x4f }, {PHY_REG_09 ,0x30 }, - {PHY_REG_10 ,0x33 }, {PHY_REG_11 ,0x65 }, + {PHY_REG (0 ),0x00 }, {PHY_REG (1 ),0xd1 }, + {PHY_REG (8 ),0x4f }, {PHY_REG (9 ),0x30 }, + {PHY_REG (10 ),0x33 }, {PHY_REG (11 ),0x65 },/* REG12 pixclk specific */ /* REG13 pixclk specific */ /* REG14 pixclk specific */ - {PHY_REG_15 ,0x80 }, {PHY_REG_16 ,0x6c }, - {PHY_REG_17 ,0xf2 }, {PHY_REG_18 ,0x67 }, - {PHY_REG_19 ,0x00 }, {PHY_REG_20 ,0x10 }, + {PHY_REG (15 ),0x80 }, {PHY_REG (16 ),0x6c }, + {PHY_REG (17 ),0xf2 }, {PHY_REG (18 ),0x67 }, + {PHY_REG (19 ),0x00 }, {PHY_REG (20 ),0x10 },/* REG21 pixclk specific */ - {PHY_REG_22 ,0x30 }, {PHY_REG_23 ,0x32 }, - {PHY_REG_24 ,0x60 }, {PHY_REG_25 ,0x8f }, - {PHY_REG_26 ,0x00 }, {PHY_REG_27 ,0x00 }, - {PHY_REG_28 ,0x08 }, {PHY_REG_29 ,0x00 }, - {PHY_REG_30 ,0x00 }, {PHY_REG_31 ,0x00 }, - {PHY_REG_32 ,0x00 }, {PHY_REG_33 ,0x80 }, - {PHY_REG_34 ,0x00 }, {PHY_REG_35 ,0x00 }, - {PHY_REG_36 ,0x00 }, {PHY_REG_37 ,0x00 }, - {PHY_REG_38 ,0x00 }, {PHY_REG_39 ,0x00 }, - {PHY_REG_40 ,0x00 }, {PHY_REG_41 ,0xe0 }, - {PHY_REG_42 ,0x83 }, {PHY_REG_43 ,0x0f }, - {PHY_REG_44 ,0x3E }, {PHY_REG_45 ,0xf8 }, - {PHY_REG_46 ,0x00 }, {PHY_REG_47 ,0x00 } + {PHY_REG (22 ),0x30 }, {PHY_REG (23 ),0x32 }, + {PHY_REG (24 ),0x60 }, {PHY_REG (25 ),0x8f }, + {PHY_REG (26 ),0x00 }, {PHY_REG (27 ),0x00 }, + {PHY_REG (28 ),0x08 }, {PHY_REG (29 ),0x00 }, + {PHY_REG (30 ),0x00 }, {PHY_REG (31 ),0x00 }, + {PHY_REG (32 ),0x00 }, {PHY_REG (33 ),0x80 }, + {PHY_REG (34 ),0x00 }, {PHY_REG (35 ),0x00 }, + {PHY_REG (36 ),0x00 }, {PHY_REG (37 ),0x00 }, + {PHY_REG (38 ),0x00 }, {PHY_REG (39 ),0x00 }, + {PHY_REG (40 ),0x00 }, {PHY_REG (41 ),0xe0 }, + {PHY_REG (42 ),0x83 }, {PHY_REG (43 ),0x0f }, + {PHY_REG (44 ),0x3E }, {PHY_REG (45 ),0xf8 }, + {PHY_REG (46 ),0x00 }, {PHY_REG (47 ),0x00 } };struct fsl_samsung_hdmi_phy {
@@ -442,7 +395,7 @@ fsl_samsung_hdmi_phy_configure_pixclk(struct fsl_samsung_hdmi_phy *phy, }writeb (REG21_SEL_TX_CK_INV |FIELD_PREP (REG21_PMS_S_MASK , div), - phy->regs +PHY_REG_21 ); + phy->regs +PHY_REG (21 )); } static void
@@ -469,7 +422,7 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,break ; } -writeb (FIELD_PREP (REG12_CK_DIV_MASK ,ilog2 (div)), phy->regs +PHY_REG_12 ); +writeb (FIELD_PREP (REG12_CK_DIV_MASK ,ilog2 (div)), phy->regs +PHY_REG (12 ));/* * Calculation for the frequency lock detector target code (fld_tg_code)
@@ -489,11 +442,11 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,/* FLD_TOL and FLD_RP_CODE taken from downstream driver */ writeb (FIELD_PREP (REG13_TG_CODE_LOW_MASK , fld_tg_code), - phy->regs +PHY_REG_13 ); + phy->regs +PHY_REG (13 ));writeb (FIELD_PREP (REG14_TOL_MASK ,2 ) |FIELD_PREP (REG14_RP_CODE_MASK ,2 ) |FIELD_PREP (REG14_TG_CODE_HIGH_MASK , fld_tg_code >>8 ), - phy->regs +PHY_REG_14 ); + phy->regs +PHY_REG (14 )); } static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,
@@ -503,7 +456,7 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,u8 val;/* HDMI PHY init */ -writeb (REG33_FIX_DA , phy->regs +PHY_REG_33 ); +writeb (REG33_FIX_DA , phy->regs +PHY_REG (33 ));/* common PHY registers */ for (i =0 ; i <ARRAY_SIZE (common_phy_cfg); i++)
@@ -511,14 +464,14 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,/* set individual PLL registers PHY_REG2 ... PHY_REG7 */ for (i =0 ; i <PHY_PLL_DIV_REGS_NUM ; i++) -writeb (cfg->pll_div_regs[i], phy->regs +PHY_REG_02 + i *4 ); +writeb (cfg->pll_div_regs[i], phy->regs +PHY_REG (2 ) + i *4 );fsl_samsung_hdmi_phy_configure_pixclk (phy, cfg);fsl_samsung_hdmi_phy_configure_pll_lock_det (phy, cfg); -writeb (REG33_FIX_DA |REG33_MODE_SET_DONE , phy->regs +PHY_REG_33 ); +writeb (REG33_FIX_DA |REG33_MODE_SET_DONE , phy->regs +PHY_REG (33 )); - ret =readb_poll_timeout (phy->regs +PHY_REG_34 , val, + ret =readb_poll_timeout (phy->regs +PHY_REG (34 ), val, val ®34_PLL_LOCK ,50 ,20000 );if (ret)dev_err (phy->dev,"PLL failed to lock\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 801/1756 phy: freescale: fsl-samsung-hdmi: Simplify REG21_PMS_S_MASK lookup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit 375ee44adb3640099508c5c0c01d86f0bdb16e97 ]
The value of 'S' is writen to two places, PHY_REG3[7:4] and PHY_REG21[3:0]. There is a lookup table which contains the value of PHY_REG3. Rather than using a switch statement based on the pixel clock to search for the value of 'S' again, just shift the contents of PHY_REG3[7:4] >> 4 and place the value in PHY_REG21[3:0]. Doing this can eliminate an entire function.
Stable-dep-of: c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 39 ++------------------ 1 file changed, 4 insertions(+), 35 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +4 -35
@@ -364,40 +364,6 @@ to_fsl_samsung_hdmi_phy(struct clk_hw *hw) return container_of(hw, struct fsl_samsung_hdmi_phy, hw); } -static void -fsl_samsung_hdmi_phy_configure_pixclk (struct fsl_samsung_hdmi_phy *phy, -const struct phy_config *cfg) -{ -u8 div =0x1 ; - -switch (cfg->pixclk) { - case 22250000 ... 33750000: - div =0xf ; -break ; - case 35000000 ... 40000000: - div =0xb ; -break ; - case 43200000 ... 47500000: - div =0x9 ; -break ; - case 50349650 ... 63500000: - div =0x7 ; -break ; - case 67500000 ... 90000000: - div =0x5 ; -break ; - case 94000000 ... 148500000: - div =0x3 ; -break ; - case 154000000 ... 297000000: - div =0x1 ; -break ; - } - -writeb (REG21_SEL_TX_CK_INV |FIELD_PREP (REG21_PMS_S_MASK , div), - phy->regs +PHY_REG (21 )); -} -static void fsl_samsung_hdmi_phy_configure_pll_lock_det (struct fsl_samsung_hdmi_phy *phy,const struct phy_config *cfg)
@@ -466,7 +432,10 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,for (i =0 ; i <PHY_PLL_DIV_REGS_NUM ; i++)writeb (cfg->pll_div_regs[i], phy->regs +PHY_REG (2 ) + i *4 ); -fsl_samsung_hdmi_phy_configure_pixclk (phy, cfg); +/* High nibble of pll_div_regs[1] contains S which also gets written to REG21 */ +writeb (REG21_SEL_TX_CK_INV |FIELD_PREP (REG21_PMS_S_MASK , + cfg->pll_div_regs[1 ] >>4 ), phy->regs +PHY_REG (21 )); +fsl_samsung_hdmi_phy_configure_pll_lock_det (phy, cfg);writeb (REG33_FIX_DA |REG33_MODE_SET_DONE , phy->regs +PHY_REG (33 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 802/1756 phy: freescale: fsl-samsung-hdmi: Support dynamic integer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit 1951dbb41d1dff7c135eed4fa1a6330df6971549 ]
There is currently a look-up table for a variety of resolutions. Since the phy has the ability to dynamically calculate the values necessary to use the intger divider which should allow more resolutions without having to update the look-up-table.
If the lookup table cannot find an exact match, fall back to the dynamic calculator of the integer divider.
Previously, the value of P was hard-coded to 1, this required an update to the phy_pll_cfg table to add in the extra value into the table, so if the value of P is calculated to be something else by the PMS calculator, the calculated_phy_pll_cfg structure can be used instead without having to keep track of which method was used.
Stable-dep-of: c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 377 +++++++++++++------ 1 file changed, 270 insertions(+), 107 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +270 -107
@@ -16,6 +16,8 @@#define PHY_REG (reg) (reg * 4) +#define REG01_PMS_P_MASK GENMASK(3, 0) +#define REG03_PMS_S_MASK GENMASK(7, 4)#define REG12_CK_DIV_MASK GENMASK(5, 4)#define REG13_TG_CODE_LOW_MASK GENMASK(7, 0)
@@ -38,281 +40,296 @@#define REG34_PLL_LOCK BIT(6)#define REG34_PHY_CLK_READY BIT(5) -#define PHY_PLL_DIV_REGS_NUM 6 +#ifndef MHZ +#define MHZ (1000UL * 1000UL) +#endif + +#define PHY_PLL_DIV_REGS_NUM 7struct phy_config {u32 pixclk;u8 pll_div_regs[PHY_PLL_DIV_REGS_NUM ]; }; +/* +* The calculated_phy_pll_cfg only handles integer divider for PMS, +* meaning the last four entries will be fixed, but the first three will +* be calculated by the PMS calculator. +*/ +static struct phy_config calculated_phy_pll_cfg = { + .pixclk =0 , + .pll_div_regs = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x80 ,0x00 }, +}; + +/* The lookup table contains values for which the fractional divder is used */ static const struct phy_config phy_pll_cfg[] = { { .pixclk =22250000 , - .pll_div_regs = {0x4b ,0xf1 ,0x89 ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x4b ,0xf1 ,0x89 ,0x88 ,0x80 ,0x40 }, }, { .pixclk =23750000 , - .pll_div_regs = {0x50 ,0xf1 ,0x86 ,0x85 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x50 ,0xf1 ,0x86 ,0x85 ,0x80 ,0x40 }, }, { .pixclk =24000000 , - .pll_div_regs = {0x50 ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x50 ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =24024000 , - .pll_div_regs = {0x50 ,0xf1 ,0x99 ,0x02 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x50 ,0xf1 ,0x99 ,0x02 ,0x80 ,0x40 }, }, { .pixclk =25175000 , - .pll_div_regs = {0x54 ,0xfc ,0xcc ,0x91 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x54 ,0xfc ,0xcc ,0x91 ,0x80 ,0x40 }, }, { .pixclk =25200000 , - .pll_div_regs = {0x54 ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x54 ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =26750000 , - .pll_div_regs = {0x5a ,0xf2 ,0x89 ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0xf2 ,0x89 ,0x88 ,0x80 ,0x40 }, }, { .pixclk =27000000 , - .pll_div_regs = {0x5a ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0xf0 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =27027000 , - .pll_div_regs = {0x5a ,0xf2 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0xf2 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =29500000 , - .pll_div_regs = {0x62 ,0xf4 ,0x95 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x62 ,0xf4 ,0x95 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =30750000 , - .pll_div_regs = {0x66 ,0xf4 ,0x82 ,0x01 ,0x88 ,0x45 }, + .pll_div_regs = {0xd1 ,0x66 ,0xf4 ,0x82 ,0x01 ,0x88 ,0x45 }, }, { .pixclk =30888000 , - .pll_div_regs = {0x66 ,0xf4 ,0x99 ,0x18 ,0x88 ,0x45 }, + .pll_div_regs = {0xd1 ,0x66 ,0xf4 ,0x99 ,0x18 ,0x88 ,0x45 }, }, { .pixclk =33750000 , - .pll_div_regs = {0x70 ,0xf4 ,0x82 ,0x01 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x70 ,0xf4 ,0x82 ,0x01 ,0x80 ,0x40 }, }, { .pixclk =35000000 , - .pll_div_regs = {0x58 ,0xb8 ,0x8b ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x58 ,0xb8 ,0x8b ,0x88 ,0x80 ,0x40 }, }, { .pixclk =36000000 , - .pll_div_regs = {0x5a ,0xb0 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0xb0 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =36036000 , - .pll_div_regs = {0x5a ,0xb2 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0xb2 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =40000000 , - .pll_div_regs = {0x64 ,0xb0 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x64 ,0xb0 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =43200000 , - .pll_div_regs = {0x5a ,0x90 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0x90 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =43243200 , - .pll_div_regs = {0x5a ,0x92 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x92 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =44500000 , - .pll_div_regs = {0x5c ,0x92 ,0x98 ,0x11 ,0x84 ,0x41 }, + .pll_div_regs = {0xd1 ,0x5c ,0x92 ,0x98 ,0x11 ,0x84 ,0x41 }, }, { .pixclk =47000000 , - .pll_div_regs = {0x62 ,0x94 ,0x95 ,0x82 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x62 ,0x94 ,0x95 ,0x82 ,0x80 ,0x40 }, }, { .pixclk =47500000 , - .pll_div_regs = {0x63 ,0x96 ,0xa1 ,0x82 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x63 ,0x96 ,0xa1 ,0x82 ,0x80 ,0x40 }, }, { .pixclk =50349650 , - .pll_div_regs = {0x54 ,0x7c ,0xc3 ,0x8f ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x54 ,0x7c ,0xc3 ,0x8f ,0x80 ,0x40 }, }, { .pixclk =50400000 , - .pll_div_regs = {0x54 ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x54 ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =53250000 , - .pll_div_regs = {0x58 ,0x72 ,0x84 ,0x03 ,0x82 ,0x41 }, + .pll_div_regs = {0xd1 ,0x58 ,0x72 ,0x84 ,0x03 ,0x82 ,0x41 }, }, { .pixclk =53500000 , - .pll_div_regs = {0x5a ,0x72 ,0x89 ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x72 ,0x89 ,0x88 ,0x80 ,0x40 }, }, { .pixclk =54000000 , - .pll_div_regs = {0x5a ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =54054000 , - .pll_div_regs = {0x5a ,0x72 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x72 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =59000000 , - .pll_div_regs = {0x62 ,0x74 ,0x95 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x62 ,0x74 ,0x95 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =59340659 , - .pll_div_regs = {0x62 ,0x74 ,0xdb ,0x52 ,0x88 ,0x47 }, + .pll_div_regs = {0xd1 ,0x62 ,0x74 ,0xdb ,0x52 ,0x88 ,0x47 }, }, { .pixclk =59400000 , - .pll_div_regs = {0x63 ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x63 ,0x70 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =61500000 , - .pll_div_regs = {0x66 ,0x74 ,0x82 ,0x01 ,0x88 ,0x45 }, + .pll_div_regs = {0xd1 ,0x66 ,0x74 ,0x82 ,0x01 ,0x88 ,0x45 }, }, { .pixclk =63500000 , - .pll_div_regs = {0x69 ,0x74 ,0x89 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x69 ,0x74 ,0x89 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =67500000 , - .pll_div_regs = {0x54 ,0x52 ,0x87 ,0x03 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x54 ,0x52 ,0x87 ,0x03 ,0x80 ,0x40 }, }, { .pixclk =70000000 , - .pll_div_regs = {0x58 ,0x58 ,0x8b ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x58 ,0x58 ,0x8b ,0x88 ,0x80 ,0x40 }, }, { .pixclk =72000000 , - .pll_div_regs = {0x5a ,0x50 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0x50 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =72072000 , - .pll_div_regs = {0x5a ,0x52 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x52 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =74176000 , - .pll_div_regs = {0x5d ,0x58 ,0xdb ,0xA2 ,0x88 ,0x41 }, + .pll_div_regs = {0xd1 ,0x5d ,0x58 ,0xdb ,0xA2 ,0x88 ,0x41 }, }, { .pixclk =74250000 , - .pll_div_regs = {0x5c ,0x52 ,0x90 ,0x0d ,0x84 ,0x41 }, + .pll_div_regs = {0xd1 ,0x5c ,0x52 ,0x90 ,0x0d ,0x84 ,0x41 }, }, { .pixclk =78500000 , - .pll_div_regs = {0x62 ,0x54 ,0x87 ,0x01 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x62 ,0x54 ,0x87 ,0x01 ,0x80 ,0x40 }, }, { .pixclk =80000000 , - .pll_div_regs = {0x64 ,0x50 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x64 ,0x50 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =82000000 , - .pll_div_regs = {0x66 ,0x54 ,0x82 ,0x01 ,0x88 ,0x45 }, + .pll_div_regs = {0xd1 ,0x66 ,0x54 ,0x82 ,0x01 ,0x88 ,0x45 }, }, { .pixclk =82500000 , - .pll_div_regs = {0x67 ,0x54 ,0x88 ,0x01 ,0x90 ,0x49 }, + .pll_div_regs = {0xd1 ,0x67 ,0x54 ,0x88 ,0x01 ,0x90 ,0x49 }, }, { .pixclk =89000000 , - .pll_div_regs = {0x70 ,0x54 ,0x84 ,0x83 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x70 ,0x54 ,0x84 ,0x83 ,0x80 ,0x40 }, }, { .pixclk =90000000 , - .pll_div_regs = {0x70 ,0x54 ,0x82 ,0x01 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x70 ,0x54 ,0x82 ,0x01 ,0x80 ,0x40 }, }, { .pixclk =94000000 , - .pll_div_regs = {0x4e ,0x32 ,0xa7 ,0x10 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x4e ,0x32 ,0xa7 ,0x10 ,0x80 ,0x40 }, }, { .pixclk =95000000 , - .pll_div_regs = {0x50 ,0x31 ,0x86 ,0x85 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x50 ,0x31 ,0x86 ,0x85 ,0x80 ,0x40 }, }, { .pixclk =98901099 , - .pll_div_regs = {0x52 ,0x3a ,0xdb ,0x4c ,0x88 ,0x47 }, + .pll_div_regs = {0xd1 ,0x52 ,0x3a ,0xdb ,0x4c ,0x88 ,0x47 }, }, { .pixclk =99000000 , - .pll_div_regs = {0x52 ,0x32 ,0x82 ,0x01 ,0x88 ,0x47 }, + .pll_div_regs = {0xd1 ,0x52 ,0x32 ,0x82 ,0x01 ,0x88 ,0x47 }, }, { .pixclk =100699300 , - .pll_div_regs = {0x54 ,0x3c ,0xc3 ,0x8f ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x54 ,0x3c ,0xc3 ,0x8f ,0x80 ,0x40 }, }, { .pixclk =100800000 , - .pll_div_regs = {0x54 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x54 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =102500000 , - .pll_div_regs = {0x55 ,0x32 ,0x8c ,0x05 ,0x90 ,0x4b }, + .pll_div_regs = {0xd1 ,0x55 ,0x32 ,0x8c ,0x05 ,0x90 ,0x4b }, }, { .pixclk =104750000 , - .pll_div_regs = {0x57 ,0x32 ,0x98 ,0x07 ,0x90 ,0x49 }, + .pll_div_regs = {0xd1 ,0x57 ,0x32 ,0x98 ,0x07 ,0x90 ,0x49 }, }, { .pixclk =106500000 , - .pll_div_regs = {0x58 ,0x32 ,0x84 ,0x03 ,0x82 ,0x41 }, + .pll_div_regs = {0xd1 ,0x58 ,0x32 ,0x84 ,0x03 ,0x82 ,0x41 }, }, { .pixclk =107000000 , - .pll_div_regs = {0x5a ,0x32 ,0x89 ,0x88 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x32 ,0x89 ,0x88 ,0x80 ,0x40 }, }, { .pixclk =108000000 , - .pll_div_regs = {0x5a ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =108108000 , - .pll_div_regs = {0x5a ,0x32 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x32 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =118000000 , - .pll_div_regs = {0x62 ,0x34 ,0x95 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x62 ,0x34 ,0x95 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =118800000 , - .pll_div_regs = {0x63 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x63 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =123000000 , - .pll_div_regs = {0x66 ,0x34 ,0x82 ,0x01 ,0x88 ,0x45 }, + .pll_div_regs = {0xd1 ,0x66 ,0x34 ,0x82 ,0x01 ,0x88 ,0x45 }, }, { .pixclk =127000000 , - .pll_div_regs = {0x69 ,0x34 ,0x89 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x69 ,0x34 ,0x89 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =135000000 , - .pll_div_regs = {0x70 ,0x34 ,0x82 ,0x01 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x70 ,0x34 ,0x82 ,0x01 ,0x80 ,0x40 }, }, { .pixclk =135580000 , - .pll_div_regs = {0x71 ,0x39 ,0xe9 ,0x82 ,0x9c ,0x5b }, + .pll_div_regs = {0xd1 ,0x71 ,0x39 ,0xe9 ,0x82 ,0x9c ,0x5b }, }, { .pixclk =137520000 , - .pll_div_regs = {0x72 ,0x38 ,0x99 ,0x10 ,0x85 ,0x41 }, + .pll_div_regs = {0xd1 ,0x72 ,0x38 ,0x99 ,0x10 ,0x85 ,0x41 }, }, { .pixclk =138750000 , - .pll_div_regs = {0x73 ,0x35 ,0x88 ,0x05 ,0x90 ,0x4d }, + .pll_div_regs = {0xd1 ,0x73 ,0x35 ,0x88 ,0x05 ,0x90 ,0x4d }, }, { .pixclk =140000000 , - .pll_div_regs = {0x75 ,0x36 ,0xa7 ,0x90 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x75 ,0x36 ,0xa7 ,0x90 ,0x80 ,0x40 }, }, { .pixclk =144000000 , - .pll_div_regs = {0x78 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x78 ,0x30 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =148352000 , - .pll_div_regs = {0x7b ,0x35 ,0xdb ,0x39 ,0x90 ,0x45 }, + .pll_div_regs = {0xd1 ,0x7b ,0x35 ,0xdb ,0x39 ,0x90 ,0x45 }, }, { .pixclk =148500000 , - .pll_div_regs = {0x7b ,0x35 ,0x84 ,0x03 ,0x90 ,0x45 }, + .pll_div_regs = {0xd1 ,0x7b ,0x35 ,0x84 ,0x03 ,0x90 ,0x45 }, }, { .pixclk =154000000 , - .pll_div_regs = {0x40 ,0x18 ,0x83 ,0x01 ,0x00 ,0x40 }, + .pll_div_regs = {0xd1 ,0x40 ,0x18 ,0x83 ,0x01 ,0x00 ,0x40 }, }, { .pixclk =157000000 , - .pll_div_regs = {0x41 ,0x11 ,0xa7 ,0x14 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x41 ,0x11 ,0xa7 ,0x14 ,0x80 ,0x40 }, }, { .pixclk =160000000 , - .pll_div_regs = {0x42 ,0x12 ,0xa1 ,0x20 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x42 ,0x12 ,0xa1 ,0x20 ,0x80 ,0x40 }, }, { .pixclk =162000000 , - .pll_div_regs = {0x43 ,0x18 ,0x8b ,0x08 ,0x96 ,0x55 }, + .pll_div_regs = {0xd1 ,0x43 ,0x18 ,0x8b ,0x08 ,0x96 ,0x55 }, }, { .pixclk =164000000 , - .pll_div_regs = {0x45 ,0x11 ,0x83 ,0x82 ,0x90 ,0x4b }, + .pll_div_regs = {0xd1 ,0x45 ,0x11 ,0x83 ,0x82 ,0x90 ,0x4b }, }, { .pixclk =165000000 , - .pll_div_regs = {0x45 ,0x11 ,0x84 ,0x81 ,0x90 ,0x4b }, + .pll_div_regs = {0xd1 ,0x45 ,0x11 ,0x84 ,0x81 ,0x90 ,0x4b }, }, { .pixclk =180000000 , - .pll_div_regs = {0x4b ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x4b ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =185625000 , - .pll_div_regs = {0x4e ,0x12 ,0x9a ,0x95 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x4e ,0x12 ,0x9a ,0x95 ,0x80 ,0x40 }, }, { .pixclk =188000000 , - .pll_div_regs = {0x4e ,0x12 ,0xa7 ,0x10 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x4e ,0x12 ,0xa7 ,0x10 ,0x80 ,0x40 }, }, { .pixclk =198000000 , - .pll_div_regs = {0x52 ,0x12 ,0x82 ,0x01 ,0x88 ,0x47 }, + .pll_div_regs = {0xd1 ,0x52 ,0x12 ,0x82 ,0x01 ,0x88 ,0x47 }, }, { .pixclk =205000000 , - .pll_div_regs = {0x55 ,0x12 ,0x8c ,0x05 ,0x90 ,0x4b }, + .pll_div_regs = {0xd1 ,0x55 ,0x12 ,0x8c ,0x05 ,0x90 ,0x4b }, }, { .pixclk =209500000 , - .pll_div_regs = {0x57 ,0x12 ,0x98 ,0x07 ,0x90 ,0x49 }, + .pll_div_regs = {0xd1 ,0x57 ,0x12 ,0x98 ,0x07 ,0x90 ,0x49 }, }, { .pixclk =213000000 , - .pll_div_regs = {0x58 ,0x12 ,0x84 ,0x03 ,0x82 ,0x41 }, + .pll_div_regs = {0xd1 ,0x58 ,0x12 ,0x84 ,0x03 ,0x82 ,0x41 }, }, { .pixclk =216000000 , - .pll_div_regs = {0x5a ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x5a ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =216216000 , - .pll_div_regs = {0x5a ,0x12 ,0xfd ,0x0c ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x5a ,0x12 ,0xfd ,0x0c ,0x80 ,0x40 }, }, { .pixclk =237600000 , - .pll_div_regs = {0x63 ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x63 ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =254000000 , - .pll_div_regs = {0x69 ,0x14 ,0x89 ,0x08 ,0x80 ,0x40 }, + .pll_div_regs = {0xd1 ,0x69 ,0x14 ,0x89 ,0x08 ,0x80 ,0x40 }, }, { .pixclk =277500000 , - .pll_div_regs = {0x73 ,0x15 ,0x88 ,0x05 ,0x90 ,0x4d }, + .pll_div_regs = {0xd1 ,0x73 ,0x15 ,0x88 ,0x05 ,0x90 ,0x4d }, }, { .pixclk =288000000 , - .pll_div_regs = {0x78 ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, + .pll_div_regs = {0xd1 ,0x78 ,0x10 ,0x00 ,0x00 ,0x80 ,0x00 }, }, { .pixclk =297000000 , - .pll_div_regs = {0x7b ,0x15 ,0x84 ,0x03 ,0x90 ,0x45 }, + .pll_div_regs = {0xd1 ,0x7b ,0x15 ,0x84 ,0x03 ,0x90 ,0x45 }, }, };
@@ -322,7 +339,8 @@ struct reg_settings { };static const struct reg_settings common_phy_cfg[] = { - {PHY_REG (0 ),0x00 }, {PHY_REG (1 ),0xd1 }, + {PHY_REG (0 ),0x00 }, +/* PHY_REG(1-7) pix clk specific */ {PHY_REG (8 ),0x4f }, {PHY_REG (9 ),0x30 }, {PHY_REG (10 ),0x33 }, {PHY_REG (11 ),0x65 },/* REG12 pixclk specific */
@@ -415,6 +433,83 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy, phy->regs + PHY_REG(14)); } +static unsigned long fsl_samsung_hdmi_phy_find_pms (unsigned long fout,u8 *p,u16 *m,u8 *s) +{ +unsigned long best_freq =0 ; +u32 min_delta =0xffffffff ; +u8 _p, best_p; +u16 _m, best_m; +u8 _s, best_s; + +/* +* Figure 13-78 of the reference manual states the PLL should be TMDS x 5 +* while the TMDS_CLKO should be the PLL / 5. So to calculate the PLL, +* take the pix clock x 5, then return the value of the PLL / 5. +*/ + fout *=5 ; + +/* The ref manual states the values of 'P' range from 1 to 11 */ +for (_p =1 ; _p <=11 ; ++_p) { +for (_s =1 ; _s <=16 ; ++_s) { +u64 tmp; +u32 delta; + +/* s must be one or even */ +if (_s >1 && (_s &0x01 ) ==1 ) + _s++; + +/* _s cannot be 14 per the TRM */ +if (_s ==14 ) +continue ; + +/* +* TODO: Ref Manual doesn't state the range of _m +* so this should be further refined if possible. +* This range was set based on the original values +* in the lookup table +*/ + tmp = (u64 )fout * (_p * _s); +do_div (tmp,24 *MHZ ); + _m = tmp; +if (_m <0x30 || _m >0x7b ) +continue ; + +/* +* Rev 2 of the Ref Manual states the +* VCO can range between 750MHz and +* 3GHz. The VCO is assumed to be +* Fvco = (M * f_ref) / P, +* where f_ref is 24MHz. +*/ + tmp = (u64 )_m *24 *MHZ ; +do_div (tmp, _p); +if (tmp <750 *MHZ || + tmp >3000 *MHZ ) +continue ; + +/* Final frequency after post-divider */ +do_div (tmp, _s); + + delta =abs (fout - tmp); +if (delta < min_delta) { + best_p = _p; + best_s = _s; + best_m = _m; + min_delta = delta; + best_freq = tmp; + } + } + } + +if (best_freq) { + *p = best_p; + *m = best_m; + *s = best_s; + } + +return best_freq /5 ; +} +static int fsl_samsung_hdmi_phy_configure (struct fsl_samsung_hdmi_phy *phy,const struct phy_config *cfg) {
@@ -428,13 +523,13 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,for (i =0 ; i <ARRAY_SIZE (common_phy_cfg); i++)writeb (common_phy_cfg[i].val, phy->regs + common_phy_cfg[i].reg); -/* set individual PLL registers PHY_REG2 ... PHY_REG7 */ +/* set individual PLL registers PHY_REG1 ... PHY_REG7 */ for (i =0 ; i <PHY_PLL_DIV_REGS_NUM ; i++) -writeb (cfg->pll_div_regs[i], phy->regs +PHY_REG (2 ) + i *4 ); +writeb (cfg->pll_div_regs[i], phy->regs +PHY_REG (1 ) + i *4 ); -/* High nibble of pll_div_regs[1] contains S which also gets written to REG21 */ +/* High nibble of PHY_REG3 and low nibble of PHY_REG21 both contain 'S' */ writeb (REG21_SEL_TX_CK_INV |FIELD_PREP (REG21_PMS_S_MASK , - cfg->pll_div_regs[1 ] >>4 ), phy->regs +PHY_REG (21 )); + cfg->pll_div_regs[2 ] >>4 ), phy->regs +PHY_REG (21 ));fsl_samsung_hdmi_phy_configure_pll_lock_det (phy, cfg);
@@ -459,34 +554,102 @@ static unsigned long phy_clk_recalc_rate(struct clk_hw *hw,return phy->cur_cfg->pixclk; } -static long phy_clk_round_rate (struct clk_hw *hw, -unsigned long rate,unsigned long *parent_rate) +/* Helper function to lookup the available fractional-divider rate */ +static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate (unsigned long rate) {int i; +/* Search the lookup table */ for (i =ARRAY_SIZE (phy_pll_cfg) -1 ; i >=0 ; i--)if (phy_pll_cfg[i].pixclk <= rate) -return phy_pll_cfg[i].pixclk; +break ; + +return &phy_pll_cfg[i]; +} + +static void fsl_samsung_hdmi_calculate_phy (struct phy_config *cal_phy,unsigned long rate, +u8 p,u16 m,u8 s) +{ + cal_phy->pixclk = rate; + cal_phy->pll_div_regs[0 ] =FIELD_PREP (REG01_PMS_P_MASK , p); + cal_phy->pll_div_regs[1 ] = m; + cal_phy->pll_div_regs[2 ] =FIELD_PREP (REG03_PMS_S_MASK , s-1 ); +/* pll_div_regs 3-6 are fixed and pre-defined already */ +} + +static long phy_clk_round_rate (struct clk_hw *hw, +unsigned long rate,unsigned long *parent_rate) +{ +const struct phy_config *fract_div_phy; +u32 int_div_clk; +u16 m; +u8 p, s; + +/* If the clock is out of range return error instead of searching */ +if (rate >297000000 || rate <22250000 ) +return -EINVAL ; + +/* Search the fractional divider lookup table */ + fract_div_phy =fsl_samsung_hdmi_phy_lookup_rate (rate); -return -EINVAL ; +/* If the rate is an exact match, return that value */ +if (rate == fract_div_phy->pixclk) +return fract_div_phy->pixclk; + +/* If the exact match isn't found, calculate the integer divider */ + int_div_clk =fsl_samsung_hdmi_phy_find_pms (rate, &p, &m, &s); + +/* If the int_div_clk rate is an exact match, return that value */ +if (int_div_clk == rate) +return int_div_clk; + +/* If neither rate is an exact match, use the value from the LUT */ +return fract_div_phy->pixclk; +} + +static int phy_use_fract_div (struct fsl_samsung_hdmi_phy *phy,const struct phy_config *fract_div_phy) +{ + phy->cur_cfg = fract_div_phy; +dev_dbg (phy->dev,"fsl_samsung_hdmi_phy: using fractional divider rate = %u\n" , + phy->cur_cfg->pixclk); +return fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); }static int phy_clk_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) {struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); -int i; +const struct phy_config *fract_div_phy; +u32 int_div_clk; +u16 m; +u8 p, s; -for (i =ARRAY_SIZE (phy_pll_cfg) -1 ; i >=0 ; i--) -if (phy_pll_cfg[i].pixclk <= rate) -break ; +/* Search the fractional divider lookup table */ + fract_div_phy =fsl_samsung_hdmi_phy_lookup_rate (rate); -if (i <0 ) -return -EINVAL ; +/* If the rate is an exact match, use that value */ +if (fract_div_phy->pixclk == rate) +return phy_use_fract_div (phy, fract_div_phy); - phy->cur_cfg = &phy_pll_cfg[i]; +/* +* If the rate from the fractional divider is not exact, check the integer divider, +* and use it if that value is an exact match. +*/ + int_div_clk =fsl_samsung_hdmi_phy_find_pms (rate, &p, &m, &s); +if (int_div_clk == rate) { +dev_dbg (phy->dev,"fsl_samsung_hdmi_phy: integer divider rate = %u\n" , + int_div_clk); + +fsl_samsung_hdmi_calculate_phy (&calculated_phy_pll_cfg, int_div_clk, p, m, s); + phy->cur_cfg = &calculated_phy_pll_cfg; +return fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); + } -return fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); +/* +* If neither the fractional divider nor the integer divider can find an exact value +* fall back to using the fractional divider +*/ +return phy_use_fract_div (phy, fract_div_phy); }static const struct clk_ops phy_clk_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 803/1756 phy: freescale: fsl-samsung-hdmi: Use helper function devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 279950205dde78bc0e3ca73a8dfee6842f0e1edc ]
Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly.
Stable-dep-of: c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +1 -9
@@ -706,7 +706,7 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)if (IS_ERR (phy->regs))return PTR_ERR (phy->regs); - phy->apbclk =devm_clk_get (phy->dev,"apb" ); + phy->apbclk =devm_clk_get_enabled (phy->dev,"apb" );if (IS_ERR (phy->apbclk))return dev_err_probe (phy->dev,PTR_ERR (phy->apbclk),"failed to get apb clk\n" );
@@ -716,12 +716,6 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); - ret =clk_prepare_enable (phy->apbclk); -if (ret) { -dev_err (phy->dev,"failed to enable apbclk\n" ); -return ret; - } -pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);
@@ -737,8 +731,6 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return 0 ; register_clk_failed: -clk_disable_unprepare (phy->apbclk); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 804/1756 phy: freescale: fsl-samsung-hdmi: initialize default rate
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristo Chen <[email protected]>
[ Upstream commit c01ccf91b257741e9edc374a465126bae9ae4711 ]
The HDMI PHY clock reports 74.25 MHz when cur_cfg is unset, but does not establish that rate in hardware. The common clock framework caches the reported rate when registering the clock and skips a first clk_set_rate(74250000) request because the rate appears unchanged.
Consequently, a display whose initial mode uses a 74.25 MHz pixel clock can leave the PHY with its bootloader register state and receive no TMDS signal. Requesting another rate first avoids the issue because the set_rate callback configures the PHY.
Program the 74.25 MHz table entry with the reference clock enabled before registering the clock provider. recalc_rate can then report the configured rate, and a skipped first rate change is safe. Also enable the reference clock when restoring that configuration on resume.
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 59 +++++++++++++++----- 1 file changed, 44 insertions(+), 15 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +44 -15
@@ -44,6 +44,8 @@#define MHZ (1000UL * 1000UL)#endif +#define PHY_DEFAULT_RATE 74250000 +#define PHY_PLL_DIV_REGS_NUM 7struct phy_config {
@@ -543,17 +545,6 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,return ret; } -static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) -{ -struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); - -if (!phy->cur_cfg) -return 74250000 ; - -return phy->cur_cfg->pixclk; -} -/* Helper function to lookup the available fractional-divider rate */ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate (unsigned long rate) {
@@ -567,6 +558,14 @@ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long rreturn &phy_pll_cfg[i]; } +static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); + +return phy->cur_cfg->pixclk; +} +static void fsl_samsung_hdmi_calculate_phy (struct phy_config *cal_phy,unsigned long rate,u8 p,u16 m,u8 s) {
@@ -692,6 +691,7 @@ static int phy_clk_register(struct fsl_samsung_hdmi_phy *phy)static int fsl_samsung_hdmi_phy_probe (struct platform_device *pdev) { +const struct phy_config *default_cfg;struct fsl_samsung_hdmi_phy *phy;int ret;
@@ -716,6 +716,23 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); +/* +* Establish the rate reported by recalc_rate() before registering the +* clock. Otherwise CCF may skip the first set_rate() when it requests +* the assumed default rate, leaving the PHY unconfigured. +*/ + ret =clk_prepare_enable (phy->refclk); +if (ret) +return dev_err_probe (phy->dev, ret, +"failed to enable ref clk\n" ); + + default_cfg =fsl_samsung_hdmi_phy_lookup_rate (PHY_DEFAULT_RATE ); + ret =fsl_samsung_hdmi_phy_configure (phy, default_cfg); +clk_disable_unprepare (phy->refclk); +if (ret) +return dev_err_probe (phy->dev, ret, +"failed to configure default rate\n" ); +pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);
@@ -751,7 +768,7 @@ static int __maybe_unused fsl_samsung_hdmi_phy_suspend(struct device *dev)static int __maybe_unused fsl_samsung_hdmi_phy_resume (struct device *dev) {struct fsl_samsung_hdmi_phy *phy =dev_get_drvdata (dev); -int ret =0 ; +int ret; ret =clk_prepare_enable (phy->apbclk);if (ret) {
@@ -759,11 +776,23 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)return ret; } -if (phy->cur_cfg) - ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); +if (!phy->cur_cfg) +return 0 ; -return ret; + ret =clk_prepare_enable (phy->refclk); +if (ret) { +dev_err (phy->dev,"failed to enable ref clk\n" ); + goto disable_apbclk; + } + + ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); +clk_disable_unprepare (phy->refclk); +if (!ret) +return 0 ; +disable_apbclk: +clk_disable_unprepare (phy->apbclk); +return ret; } static DEFINE_RUNTIME_DEV_PM_OPS(fsl_samsung_hdmi_phy_pm_ops,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 805/1756 md: take reconfig_mutex when enabling PPL on an inactive array
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit 900bf42e0ff8009f66ffd4a679c56264957019dd ]
consistency_policy_store() sets MD_HAS_PPL for an external-metadata array that is not running yet, without holding reconfig_mutex. But ->pers is only assigned after pers->run() returns, so "not running" also covers an md_run() that is in progress under the lock.
If the write lands inside raid5_run() after log_init() has decided not to set up PPL, or after a failed ppl_init_log() has cleared the flag, the flag ends up set with conf->log_private still NULL. The next idle pass of raid5d() then does:
raid5d() -> handle_active_stripes() -> log_flush_stripe_to_raid()
-> ppl_write_stripe_run()
and dereferences the NULL ppl_conf:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002 KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:ppl_write_stripe_run+0x60/0x1320 drivers/md/raid5-ppl.c:538
Take reconfig_mutex around the update and refuse it with -EBUSY once the array is running, in which case ->change_consistency_policy() is the right interface.
--- drivers/md/md.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/md/md.c +9 -1
@@ -5641,7 +5641,15 @@ consistency_policy_store(struct mddev *mddev, const char *buf, size_t len)else err = -EBUSY ; }else if (mddev->external &&strncmp (buf,"ppl" ,3 ) ==0 ) { -set_bit (MD_HAS_PPL , &mddev->flags); +/* md_run() holds the lock until ->pers is set */ + err =mddev_lock (mddev); +if (err) +return err; +if (mddev->pers) + err = -EBUSY ; +else +set_bit (MD_HAS_PPL , &mddev->flags); +mddev_unlock (mddev); }else { err = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 806/1756 md/raid5: drain released_stripes before destroying the cache
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit af560e357a81964544be40c549e241b032ef7565 ]
grow_one_stripe() calls raid5_release_stripe() for each new stripe. When mddev->thread is already set, that queues the stripe on conf->released_stripes and wakes the thread. Only raid5d moves that list onto inactive_list.
Takeover calls setup_conf() while mddev->thread still belongs to the previous personality, so those stripes stay on released_stripes. If setup_conf() then fails, shrink_stripes() only frees inactive_list and kmem_cache_destroy() warns that objects remain.
Move stripes still queued on released_stripes onto inactive_list before shrink_stripes() frees them.
--- drivers/md/raid5.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/md/raid5.c +31 -0
@@ -2706,6 +2706,37 @@ static int drop_one_stripe(struct r5conf *conf)static void shrink_stripes (struct r5conf *conf) { +struct list_head temp[NR_STRIPE_HASH_LOCKS ]; +int i; + +/* +* grow_one_stripe() parks new stripes on released_stripes when +* mddev->thread is already set. Takeover leaves the previous +* personality's thread there, so raid5d never moves them to +* inactive_list. Drain them before the cache is destroyed. +* slab_cache is assigned only after device_lock and the hash +* lists exist; earlier abort paths have nothing to drain. +*/ +if (conf->slab_cache) { +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) +INIT_LIST_HEAD (&temp[i]); + +spin_lock_irq (&conf->device_lock); +release_stripe_list (conf, temp); +spin_unlock_irq (&conf->device_lock); + +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) { +if (list_empty (&temp[i])) +continue ; +spin_lock_irq (conf->hash_locks + i); +if (list_empty (conf->inactive_list + i)) +atomic_dec (&conf->empty_inactive_list_nr); +list_splice_tail_init (&temp[i], + conf->inactive_list + i); +spin_unlock_irq (conf->hash_locks + i); + } + } +while (conf->max_nr_stripes &&drop_one_stripe (conf)) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 807/1756 clk: imx: composite-93: return timeout from gate enable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 246d9fa6b83d2d3c524aad28de1ab5db5cecf048 ]
imx93_clk_composite_wait_ready() already reports a busy timeout, but imx93_clk_composite_gate_enable() ignores that and always returns 0. The clk framework then marks the clock enabled and lets consumers run while the CCM slice is still busy.
Propagate the timeout so enable fails instead of looking successful.
--- drivers/clk/imx/clk-composite-93.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-composite-93.c +6 -5
@@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)return ret; } -static void imx93_clk_composite_gate_endisable (struct clk_hw *hw,int enable) +static int imx93_clk_composite_gate_endisable (struct clk_hw *hw,int enable) {struct clk_gate *gate =to_clk_gate (hw);unsigned long flags;u32 reg; +int ret;if (gate->lock)spin_lock_irqsave (gate->lock, flags);
@@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)writel (reg, gate->reg); -imx93_clk_composite_wait_ready (hw, gate->reg); + ret =imx93_clk_composite_wait_ready (hw, gate->reg);if (gate->lock)spin_unlock_irqrestore (gate->lock, flags); + +return ret; }static int imx93_clk_composite_gate_enable (struct clk_hw *hw) { -imx93_clk_composite_gate_endisable (hw,1 ); - -return 0 ; +return imx93_clk_composite_gate_endisable (hw,1 ); }static void imx93_clk_composite_gate_disable (struct clk_hw *hw)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 808/1756 md/raid5: protect big_stripe_tree lookup with RCU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 73b0df929494522acf9ccc8dafea4f721166965b ]
big_stripe_tree is updated under tree_lock, and deleted radix-tree nodes are freed after an RCU grace period. r5c_big_stripe_cached() used to run under an RCU read-side critical section, but that protection was removed together with unrelated rdev lookup protection.
The lookup can now be preempted while walking the tree, allowing a concurrent deletion and grace period to complete before the walk resumes. Protect the lookup locally with rcu_read_lock(). Only the presence of the entry is used after unlocking.
--- drivers/md/raid5-cache.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/raid5-cache.c +2 -0
@@ -2971,7 +2971,9 @@ bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect)return false; tree_index =r5c_tree_index (conf, sect); +rcu_read_lock (); slot =radix_tree_lookup (&log->big_stripe_tree, tree_index); +rcu_read_unlock ();return slot !=NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 809/1756 dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit ca9a67831805dc788407a05f276abb6b86b1174d ]
On the H6 SoC, the Video Engine has two memory ports, thus two IOMMU connections. The secondary one that is missing is likely used for reading reference frames. The newer H616 is the same. On the other hand, the D1 only has one memory port.
Add the missing IOMMU connection for the Video Engine.
--- .../allwinner,sun4i-a10-video-engine.yaml | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +20 -1
@@ -55,7 +55,10 @@ properties: description: Phandle to the device SRAM iommus: - maxItems: 1 + minItems: 1 + items: + - description: VE port on IOMMU + - description: VE_R port on IOMMU memory-region: maxItems: 1
@@ -82,6 +85,22 @@ required: - resets - allwinner,sram +allOf: + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h6-video-engine + then: + properties: + iommus: + minItems: 2 + else: + properties: + iommus: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 810/1756 power: supply: bq24190: Remove redundant pm_runtime_mark_last_busy() calls
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit 2453753f395e68af947d9ac6ce37bf0eb40f7123 ]
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(), pm_runtime_autosuspend() and pm_request_autosuspend() now include a call to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to pm_runtime_mark_last_busy().
Stable-dep-of: e0844bd22a9f ("power: supply: bq24190_charger: don't reset registers across system suspend")
--- drivers/power/supply/bq24190_charger.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/power/supply/bq24190_charger.c +0 -14
@@ -502,7 +502,6 @@ static ssize_t bq24190_sysfs_show(struct device *dev,else count =sysfs_emit (buf,"%hhx\n" , v); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return count;
@@ -533,7 +532,6 @@ static ssize_t bq24190_sysfs_store(struct device *dev,if (ret) count = ret; -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return count;
@@ -560,7 +558,6 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)else ret =bq24190_charger_set_charge_type (bdi, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -603,7 +600,6 @@ static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable) } out: -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -636,7 +632,6 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)BQ24190_REG_POC_CHG_CONFIG_MASK , BQ24190_REG_POC_CHG_CONFIG_SHIFT, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);if (ret)
@@ -673,7 +668,6 @@ static int bq24296_vbus_is_enabled(struct regulator_dev *dev)BQ24296_REG_POC_OTG_CONFIG_MASK , BQ24296_REG_POC_OTG_CONFIG_SHIFT, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);if (ret)
@@ -1373,7 +1367,6 @@ static int bq24190_charger_get_property(struct power_supply *psy, ret = -ENODATA ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -1415,7 +1408,6 @@ static int bq24190_charger_set_property(struct power_supply *psy, ret = -EINVAL ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -1673,7 +1665,6 @@ static int bq24190_battery_get_property(struct power_supply *psy, ret = -ENODATA ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -1704,7 +1695,6 @@ static int bq24190_battery_set_property(struct power_supply *psy, ret = -EINVAL ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;
@@ -1852,7 +1842,6 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)return IRQ_NONE ; }bq24190_check_status (bdi); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); bdi->irq_event = false;
@@ -2160,7 +2149,6 @@ static int bq24190_probe(struct i2c_client *client)if (ret <0 ) goto out_charger; -pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev);return 0 ;
@@ -2247,7 +2235,6 @@ static __maybe_unused int bq24190_pm_suspend(struct device *dev)bq24190_register_reset (bdi);if (error >=0 ) { -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); }
@@ -2272,7 +2259,6 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)bq24190_read (bdi,BQ24190_REG_SS , &bdi->ss_reg);if (error >=0 ) { -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); }
Signature · 1 line
2.53.0
Re: [PATCH 6.12 0810/1756] power: supply: bq24190: Remove redundant pm_runtime_mark_last_busy() calls
Hi Greg/Sasha,
Quoted 13 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit
2453753f395e68af947d9ac6ce37bf0eb40f7123]
pm_runtime_put_autosuspend(),pm_runtime_put_sync_autosuspend(),pm_runtime_autosuspend()andpm_request_autosuspend()now include a call topm_runtime_mark_last_busy(). Remove the now-reduntant explicit call topm_runtime_mark_last_busy().
Quoted 9 lines
Signed-off-by Sakari Ailus <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>Stable-dep-of:
e0844bd22a9f("power: supply:bq24190_charger: don't reset registers across system suspend")Signed-off-by Sasha Levin <[email protected]>--- drivers/power/supply/bq24190_charger.c | 14 -------------- 1 file changed, 14 deletions(-)
Ai assisted backport review has found an issue for this backport. The finding looks correct to me.
Verdict: lets drop it until we have the prerequisite I think.
The removed pm_runtime_mark_last_busy() calls are still needed with the 6.12.y runtime-PM helper.
Before this change, the driver did:
pm_runtime_mark_last_busy(bdi->dev);
pm_runtime_put_autosuspend(bdi->dev);Upstream can remove the first call because its helper includes it:
static inline int pm_runtime_put_autosuspend(struct device *dev)
{
pm_runtime_mark_last_busy(dev);
return __pm_runtime_put_autosuspend(dev);
}But the 6.12.y helper does not update last_busy:
static inline int pm_runtime_put_autosuspend(struct device *dev)
{
return __pm_runtime_suspend(dev,
RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
}An access to an already-active charger therefore no longer refreshes its autosuspend deadline. It can suspend sooner after that access, potentially immediately if the old deadline expired.
Upstream's helper change is b3db492e8335 ("PM: runtime: Mark last busy stamp in pm_runtime_put_autosuspend()").
Could we retain the explicit last-busy updates in 6.12.y rather than take this cleanup without the helper change?
thanks.
Harshit
Quoted 116 lines
drivers/power/supply/bq24190_charger.c +0
-14@@ -502,7 +502,6 @@ static ssize_t bq24190_sysfs_show(struct device *dev,else count =sysfs_emit (buf,"%hhx\n" , v); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return count;@@ -533,7 +532,6 @@ static ssize_t bq24190_sysfs_store(struct device *dev,if (ret) count = ret; -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return count;@@ -560,7 +558,6 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)else ret =bq24190_charger_set_charge_type (bdi, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -603,7 +600,6 @@ static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable) } out: -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -636,7 +632,6 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)BQ24190_REG_POC_CHG_CONFIG_MASK , BQ24190_REG_POC_CHG_CONFIG_SHIFT, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);if (ret)@@ -673,7 +668,6 @@ static int bq24296_vbus_is_enabled(struct regulator_dev *dev)BQ24296_REG_POC_OTG_CONFIG_MASK , BQ24296_REG_POC_OTG_CONFIG_SHIFT, &val); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);if (ret)@@ -1373,7 +1367,6 @@ static int bq24190_charger_get_property(struct power_supply *psy, ret = -ENODATA ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -1415,7 +1408,6 @@ static int bq24190_charger_set_property(struct power_supply *psy, ret = -EINVAL ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -1673,7 +1665,6 @@ static int bq24190_battery_get_property(struct power_supply *psy, ret = -ENODATA ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -1704,7 +1695,6 @@ static int bq24190_battery_set_property(struct power_supply *psy, ret = -EINVAL ; } -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev);return ret;@@ -1852,7 +1842,6 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)return IRQ_NONE ; }bq24190_check_status (bdi); -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); bdi->irq_event = false;@@ -2160,7 +2149,6 @@ static int bq24190_probe(struct i2c_client *client)if (ret <0 ) goto out_charger; -pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev);return 0 ;@@ -2247,7 +2235,6 @@ static __maybe_unused int bq24190_pm_suspend(struct device *dev)bq24190_register_reset (bdi);if (error >=0 ) { -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); }@@ -2272,7 +2259,6 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)bq24190_read (bdi,BQ24190_REG_SS , &bdi->ss_reg);if (error >=0 ) { -pm_runtime_mark_last_busy (bdi->dev);pm_runtime_put_autosuspend (bdi->dev); }
Re: [PATCH 6.12 0810/1756] power: supply: bq24190: Remove redundant pm_runtime_mark_last_busy() calls
Hi all,
Quoted 28 lines · Harshit Mogalapalli
Hi Greg/Sasha,
Quoted 13 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit
2453753f395e68af947d9ac6ce37bf0eb40f7123]
pm_runtime_put_autosuspend(),pm_runtime_put_sync_autosuspend(),pm_runtime_autosuspend()andpm_request_autosuspend()now include a call topm_runtime_mark_last_busy(). Remove the now-reduntant explicit call topm_runtime_mark_last_busy().Quoted 9 lines
Signed-off-by Sakari Ailus <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>Stable-dep-of:
e0844bd22a9f("power: supply:bq24190_charger: don't reset registers across system suspend")Signed-off-by Sasha Levin <[email protected]>--- drivers/power/supply/bq24190_charger.c | 14 -------------- 1 file changed, 14 deletions(-)
Quoted 4 lines
Ai assisted backport review has found an issue for this backport. The finding looks correct to me.
Verdict: lets drop it until we have the prerequisite I think.
I agree. The pm_runtime_mark_last_busy() changes were merged for v6.17 so these patches musn't be backported before that (and I wouldn't backport the pre-requisites).
Signature · 3 lines
Regards, Sakari Ailus
Sasha Levin
maintainerRe: [PATCH 6.12 0810/1756] power: supply: bq24190: Remove redundant pm_runtime_mark_last_busy() calls
In reply to Harshit MogalapalliQuoted 2 lines
Could we retain the explicit last-busy updates in 6.12.y rather than take this cleanup without the helper change?
Dropped both bq24190 patches from 6.12, thanks.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 811/1756 power: supply: bq24190_charger: dont reset registers across system suspend
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Brue <[email protected]>
[ Upstream commit e0844bd22a9f97885882bde3c4a441710e895240 ]
bq24190_pm_suspend() calls bq24190_register_reset(), which returns every register to its power-on default, and bq24190_pm_resume() does it again before re-applying the probe-time configuration. On any board that wires the charger's interrupt this makes system suspend unusable.
The reset re-arms the chip's 40 s i2c watchdog. bq24190_set_config() turns that watchdog off at probe, deliberately: as the comment there explains, the same write also takes the part out of default mode into host mode. Nothing pets it while the system is asleep, so it expires, resets the registers again and pulses INT. The charger interrupt is a system wake source -- armed unconditionally in probe since commit f385e6e2a153 ("power:bq24190_charger: Use PM runtime autosuspend"), and still enabled by default after the conversion to the wake irq API [1] -- so the pulse wakes the machine.
Measured on an MT8173 board (Amazon Fire HD 10 2017, BQ24297) by swapping only this driver between builds with and without this change, asking for a 150 s suspend each time:
on charger, with the reset: 41-43 s, 7 runs of 7 on charger, without the reset: 150 s, 3 runs of 3 on battery, with the reset: 40-41 s, 3 runs of 3 on battery, without the reset: 150 s, 3 runs of 3
It is not a charging-only problem. The watchdog runs from VBUS or from the battery, so an unplugged tablet loses suspend in the same way.
ftrace names the wake source. Across the resume, the first device interrupt after the machine comes back is the charger:
1270.760799: suspend_resume: machine_suspend[3] end 1270.775683: irq_handler_entry: irq=25 name=bq24190-charger 1270.776156: irq_handler_entry: irq=250 name=11010000.i2c
Everything between is IPI and arch_timer from bringing the secondary CPUs back up, and no RTC interrupt appears anywhere in the trace -- the 150 s wake alarm never fired. The cause leaves nothing behind for userspace to find, because WATCHDOG_FAULT is in the latch-on-read fault register and the driver's own interrupt handler has already consumed it.
The reset also discards host configuration that nothing restores. Resume calls bq24190_set_config(), which writes only the watchdog, SYS_MIN, IPRECHG, ITERM, ICHG and VREG, so:
- IINLIM returns to its power-on default. Boards without a charger-type detector set the input limit from userspace; measured here, one ordinary suspend/resume silently took input_current_limit from 1500 mA to 500 mA, and to 100 mA when running from the battery, where the default differs.
- EN_HIZ is cleared, so a charger the host put into high-impedance mode starts drawing from VBUS again the moment the system sleeps.
There is no way to have both. Default mode is what the reset is for, and on this part default mode and a disarmed watchdog are mutually exclusive: a write to any register moves the chip into host mode, and it only returns to default mode when the watchdog times out. Parking it in default mode for the sleep therefore always leaves a timer armed that will fire, and on any board that wires INT that firing is a wake. A per-board opt-out would not be choosing between two workable configurations, only between a working suspend and a broken one.
Resetting in suspend buys nothing worth this. The part is in host mode with its watchdog off; it charges on its own, switching from constant current to constant voltage and terminating when the battery is full, and nothing in it can expire or change while the host sleeps. Resetting on resume is weaker
still: the host is awake and about to reconfigure the chip, so the reset only guarantees the loss.
The one thing the reset does guard against is a host that never comes back:
a chip in host mode keeps whatever it was last told, where default mode would revert to the power-on values. But that is the state the driver leaves it in for all of normal runtime operation already, so sleep is not special, and the part still makes its own constant-current to constant-voltage transition and terminates when the battery is full.
So drop it in both directions. The suspend callback has nothing left to do and goes away. Resume re-applies the probe-time configuration, which is idempotent and also recovers a part that did somehow fall back to default mode, since bq24190_set_config() starts by turning the watchdog off.
This has been proposed before. Hans de Goede sent the same change in 2017
[2] and Sebastian Reichel agreed with the reasoning [3], but v6 kept the reset on by default and added the "disable-reset" device property instead [4]. That property cannot answer this: it is set only from x86 platform code -- i2c-cht-wc and x86-android-tablets -- and is not in bq24190.yaml, so no DT board can reach it. Every in-tree DT user of this driver (tegra124-xiaomi-mocha, qcom-msm8974-lge-nexus5-hammerhead, qcom-msm8974pro-oneplus-bacon, rk3188-bqedison2qc) wires the charger interrupt and so has the same wake armed, with no way to opt out. If some board does want the reset, it would be better expressed the other way round.
The vendor kernel for this board does not reset across suspend either: its driver, drivers/power/mt81xx/bq24297.c, only masks the charger interrupt on suspend and unmasks it on resume.
Reproduced on a BQ24297. The reasoning applies to the family, but the other parts were not available to test.
[1] https://lore.kernel.org/all/20260908-rbrue-suez-upstreaming-bq24190_charger-use-wake-irq-api-v1-1-c3f10ae2a34a@gmail.com/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/20170323112052.ukyazi4pnji7n6st@earth/
[4] https://lore.kernel.org/all/[email protected]/
--- drivers/power/supply/bq24190_charger.c | 30 ++++++++------------------ 1 file changed, 9 insertions(+), 21 deletions(-)
drivers/power/supply/bq24190_charger.c +9 -21
@@ -2222,25 +2222,6 @@ static __maybe_unused int bq24190_runtime_resume(struct device *dev)return 0 ; } -static __maybe_unused int bq24190_pm_suspend (struct device *dev) -{ -struct i2c_client *client =to_i2c_client (dev); -struct bq24190_dev_info *bdi =i2c_get_clientdata (client); -int error; - - error =pm_runtime_resume_and_get (bdi->dev); -if (error <0 ) -dev_warn (bdi->dev,"pm_runtime_get failed: %i\n" , error); - -bq24190_register_reset (bdi); - -if (error >=0 ) { -pm_runtime_put_autosuspend (bdi->dev); - } - -return 0 ; -} -static __maybe_unused int bq24190_pm_resume (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -2254,7 +2235,14 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)if (error <0 )dev_warn (bdi->dev,"pm_runtime_get failed: %i\n" , error); -bq24190_register_reset (bdi); +/* +* The chip kept its configuration through the sleep: it is in host +* mode with the i2c watchdog off, so nothing expired and nothing was +* reset. Do not reset it here either -- a userspace setting such as +* EN_HIZ or IINLIM would otherwise be silently lost on every resume. +* Re-applying the probe-time configuration is idempotent and cheap, +* and covers a part that did somehow fall back to default mode. +*/ bq24190_set_config (bdi);bq24190_read (bdi,BQ24190_REG_SS , &bdi->ss_reg);
@@ -2273,7 +2261,7 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)static const struct dev_pm_ops bq24190_pm_ops = { SET_RUNTIME_PM_OPS(bq24190_runtime_suspend, bq24190_runtime_resume, NULL) -SET_SYSTEM_SLEEP_PM_OPS (bq24190_pm_suspend, bq24190_pm_resume) +SET_SYSTEM_SLEEP_PM_OPS (NULL , bq24190_pm_resume) };static const struct i2c_device_id bq24190_i2c_ids[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 812/1756 md: Fix the null-ptr-deref of mddev->private while submitting IO
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 4c90b76e0198deb89376988daa8d96b48bea7fcf ]
Concurrent processes md_stop and IO submission can trigger a NULL pointer dereference of mddev->private:
BUG: kernel NULL pointer dereference, address: 0000000000000070 RIP: 0010:_wait_barrier+0x2f/0x250 Call Trace: raid1_make_request+0x150/0xf50 md_handle_request+0x104/0x530 md_submit_bio+0x76/0x130 submit_bio+0xdd/0x250 submit_bio_wait+0x1f/0x40 __blkdev_direct_IO_simple+0x1f6/0x370 blkdev_write_iter+0x3b2/0x520 ksys_write+0x7d/0x190
One process can submit I/O through an open file while a forked process uses the same file to issue STOP_ARRAY. The opener check permits this because md_open() was called only once. do_md_stop() can then clear mddev->private while the I/O is entering the personality make_request callback.
This affects raid0, raid1, raid10, and raid5. Suspend STOP_ARRAY while holding the reconfiguration lock so teardown waits for active_io references to drain. Fail I/O in md_handle_request() if mddev->pers is NULL after the array resumes.
The sysfs stopping paths are protected by mddev_set_closing_and_sync_blockdev(). Apply that protection to both clear and inactive transitions even when the array is read-only. dm-raid teardown is already invoked with the device suspended.
Fetch a reproducer in
https://bugzilla.kernel.org/show_bug.cgi?id=222020
--- drivers/md/md.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/md/md.c +17 -1
@@ -398,6 +398,20 @@ bool md_handle_request(struct mddev *mddev, struct bio *bio)if (!percpu_ref_tryget_live (&mddev->active_io)) goto check_suspended; } +if (!mddev->pers) { +/* +* The __md_stop() sets 'mddev->private' to NULL during +* the IO submitting, check 'mddev->pers' before the IO +* being processed by specific driver to avoid the +* null-ptr-deref of 'mddev-><member>'. The check is +* safe because the IO has got the 'mddev->active_io' +* reference, and all __md_stop() callers will wait for +* the reference to be zero. +*/ +bio_io_error (bio); +percpu_ref_put (&mddev->active_io); +return true; + }if (!mddev->pers->make_request (mddev, bio)) {percpu_ref_put (&mddev->active_io);if (!mddev->gendisk && mddev->pers->prepare_suspend)
@@ -4468,7 +4482,8 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)case readonly:case inactive:case read_auto: -if (!mddev->pers || !md_is_rdwr (mddev)) +if (!mddev->pers || + (st != clear && st != inactive && !md_is_rdwr (mddev)))break ;/* write sysfs will not open mddev and opener should be 0 */ err =mddev_set_closing_and_sync_blockdev (mddev,0 );
@@ -7736,6 +7751,7 @@ static bool md_ioctl_need_suspend(unsigned int cmd)case HOT_REMOVE_DISK :case SET_BITMAP_FILE :case SET_ARRAY_INFO : +case STOP_ARRAY :return true;default :return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 813/1756 dt-bindings: power: supply: ab8500: Add AB8505 charger
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 80d28539c1f9baab72210501729d67e3d9daa4b8 ]
AB8500 and AB8505 expose different charger interrupt sets. Add a unique AB8505 charger compatible with the AB8500 compatible as its fallback. Use the variant-specific string to require the fourteen main and USB charger interrupts on AB8500 and the nine USB charger interrupts on AB8505.
Also clarify that autopower_cfg describes the AB8500 facility, since the corresponding AB8505 register bit is reserved.
--- .../supply/stericsson,ab8500-charger.yaml | 76 ++++++++++++++----- 1 file changed, 56 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-charger.yaml +56 -20
@@ -10,12 +10,13 @@ title: AB8500 Charger maintainers: - Sebastian Reichel <[email protected]> -allOf: - - $ref: power-supply.yaml# - properties: compatible: - const: stericsson,ab8500-charger + oneOf: + - const: stericsson,ab8500-charger + - items: + - const: stericsson,ab8505-charger + - const: stericsson,ab8500-charger monitored-battery: $ref: /schemas/types.yaml#/definitions/phandle
@@ -30,27 +31,15 @@ properties: autopower_cfg: type: boolean - description: automatic poweron after powerloss + description: AB8500 automatic poweron after powerloss interrupts: + minItems: 9 maxItems: 14 interrupt-names: - items: - - const: MAIN_CH_UNPLUG_DET - - const: MAIN_CHARGE_PLUG_DET - - const: MAIN_EXT_CH_NOT_OK - - const: MAIN_CH_TH_PROT_R - - const: MAIN_CH_TH_PROT_F - - const: VBUS_DET_F - - const: VBUS_DET_R - - const: USB_LINK_STATUS - - const: USB_CH_TH_PROT_R - - const: USB_CH_TH_PROT_F - - const: USB_CHARGER_NOT_OKR - - const: VBUS_OVV - - const: CH_WD_EXP - - const: VBUS_CH_DROP_END + minItems: 9 + maxItems: 14 io-channels: minItems: 2
@@ -77,6 +66,53 @@ required: - io-channels - io-channel-names +allOf: + - $ref: power-supply.yaml# + - if: + properties: + compatible: + contains: + const: stericsson,ab8505-charger + then: + properties: + interrupts: + minItems: 9 + maxItems: 9 + + interrupt-names: + items: + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + else: + properties: + interrupts: + minItems: 14 + maxItems: 14 + + interrupt-names: + items: + - const: MAIN_CH_UNPLUG_DET + - const: MAIN_CHARGE_PLUG_DET + - const: MAIN_EXT_CH_NOT_OK + - const: MAIN_CH_TH_PROT_R + - const: MAIN_CH_TH_PROT_F + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 814/1756 .gitignore: drop Module.markers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit a7d32fa14bc74d1786a2f0513b6f0815bd4be311 ]
commit fc5377668c3d ("tracing: Remove markers") deleted the marker code and the modpost output. Follow-up commit 8723eaeff59a ("Kbuild: clean up marker") removed it from clean and mrproper targets. Both are from 2009, so the file is hopefully no longer in anyone's tree, drop it from .gitignore as well.
--- .gitignore | 1 - 1 file changed, 1 deletion(-)
.gitignore +0 -1
@@ -67,7 +67,6 @@ modules.order /vmlinux-gdb.py /vmlinuz /System.map -/Module.markers /modules.builtin /modules.builtin.modinfo /modules.builtin.ranges
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 815/1756 perf/cxl: Program the requested event group on configurable counters
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit b22dcc11429866e07dc54299255e8ca13c26d38a ]
cxl_pmu_get_event_idx() sets *counter_idx for a configurable counter but never *event_idx. hwc->event_base stays 0, so cxl_pmu_event_start() programs event group 0 no matter which group the user asked for.
Return the matched capability's event_idx.
--- drivers/perf/cxl_pmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/perf/cxl_pmu.c +6 -2
@@ -510,7 +510,10 @@ static const struct attribute_group *cxl_pmu_attr_groups[] = { NULL }; -/* If counter_idx == NULL, don't try to allocate a counter. */ +/* +* If counter_idx == NULL, don't try to allocate a counter. Callers that +* allocate pass both counter_idx and event_idx. +*/ static int cxl_pmu_get_event_idx (struct perf_event *event,int *counter_idx,int *event_idx) {
@@ -538,7 +541,7 @@ static int cxl_pmu_get_event_idx(struct perf_event *event, int *counter_idx, pmu_ev =cxl_pmu_find_config_counter_ev_cap (info, vid, gid, mask);if (!IS_ERR (pmu_ev)) { -if (!counter_idx) +if (!counter_idx || !event_idx)return 0 ; bitmap_andnot(configurable_and_free, info->conf_counter_bm,
@@ -549,6 +552,7 @@ static int cxl_pmu_get_event_idx(struct perf_event *event, int *counter_idx,return -EINVAL ; *counter_idx = i; + *event_idx = pmu_ev->event_idx;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 816/1756 perf/cxl: Clear stale event fields before reprogramming a counter
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 7406d6cf76b1dad53084f3988dc65ab967209344 ]
cxl_pmu_event_start() ORs the event group id, event mask, edge and invert selections into a configurable counter's config register without clearing them first, and cxl_pmu_event_stop() leaves them set. Reuse the counter for another event and the new selection lands on top of the old one, so the counter counts the wrong events with stale edge and invert behaviour.
Use FIELD_MODIFY() so each field is replaced rather than accumulated.
--- drivers/perf/cxl_pmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/perf/cxl_pmu.c +8 -8
@@ -643,17 +643,17 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags) cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_INT_ON_OVRFLW ,1 ); cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_FREEZE_ON_OVRFLW ,1 ); cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_ENABLE ,1 ); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EDGE , -cxl_pmu_config1_get_edge (event) ?1 :0 ); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_INVERT , -cxl_pmu_config1_get_invert (event) ?1 :0 ); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EDGE , &cfg, +cxl_pmu_config1_get_edge (event) ?1 :0 ); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_INVERT , &cfg, +cxl_pmu_config1_get_invert (event) ?1 :0 );/* Fixed purpose counters have next two fields RO */ if (test_bit (hwc->idx, info->conf_counter_bm)) { - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EVENT_GRP_ID_IDX_MSK , - hwc->event_base); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EVENTS_MSK , -cxl_pmu_config_get_mask (event)); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EVENT_GRP_ID_IDX_MSK , &cfg, + hwc->event_base); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EVENTS_MSK , &cfg, +cxl_pmu_config_get_mask (event)); } cfg &= ~CXL_PMU_COUNTER_CFG_THRESHOLD_MSK ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 817/1756 perf/cxl: Fix the counter overflow delta fixup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 0326269ed73529cdf821664b6176814cde9ca374 ]
The counter is masked to counter_width, so the subtraction in __cxl_pmu_read() throws away the bit that records the wrap. A delta of one whole period reads back as 0, the same as no events at all, and only the overflow status tells the two apart - which is why __cxl_pmu_read() takes an overflow argument.
The fixup keys off the delta rather than the operands:
delta = (new_cnt - prev_cnt) & GENMASK_ULL(counter_width - 1, 0); if (overflow && delta < GENMASK_ULL(counter_width - 1, 0)) delta += (1UL << counter_width);
so it cannot tell which of these it is looking at:
event_start polled read wrap ctr = 0 .......... ctr = P/2 ......... mask -> 0 (+r) prev = 0 prev = P/2 IRQ reads new = r
prev = 0 (no read yet): new >= prev, fell short -> add period prev = P/2 (polled): new < prev, spans wrap -> add nothing
Both rows are the same interrupt and the old guard adds a period in both, so a mid-period read makes the event over-count. 'perf stat -I' hits that.
Condition the fixup on new_cnt >= prev_cnt, the one case the subtraction cannot express. Dropping it outright would break the first row. It stays exact whatever the residual r is, which matters because some events increment by more than 1 per cycle (CXL r4.0 8.2.7.2.1, Threshold) and can step past 0 as they wrap.
Use mask + 1 for the period rather than a shift. It is 0 for a 64-bit counter, and avoids the old 1UL << counter_width - undefined for width 64, and for >= 32 on 32-bit kernels.
--- drivers/perf/cxl_pmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/perf/cxl_pmu.c +10 -6
@@ -686,7 +686,7 @@ static void __cxl_pmu_read(struct perf_event *event, bool overflow) {struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (event->pmu);struct hw_perf_event *hwc = &event->hw; -u64 new_cnt, prev_cnt, delta; +u64 new_cnt, prev_cnt, delta, mask; do { prev_cnt = local64_read(&hwc->prev_count);
@@ -694,12 +694,16 @@ static void __cxl_pmu_read(struct perf_event *event, bool overflow) }while (local64_cmpxchg (&hwc->prev_count, prev_cnt, new_cnt) != prev_cnt);/* -* If we know an overflow occur then take that into account. -* Note counter is not reset as that would lose events +* The mask discards the bit that says the counter wrapped, so a delta of +* one whole period reads back as 0 - the same as no events at all. Only +* the overflow status separates them, and new_cnt >= prev_cnt is that +* case, so add the period back. mask + 1 is 2^counter_width, which comes +* out as 0 for a 64-bit counter and avoids an undefined 1 << 64. */ - delta = (new_cnt - prev_cnt) &GENMASK_ULL (info->counter_width -1 ,0 ); -if (overflow && delta <GENMASK_ULL (info->counter_width -1 ,0 )) - delta += (1UL << info->counter_width); + mask =GENMASK_ULL (info->counter_width -1 ,0 ); + delta = (new_cnt - prev_cnt) & mask; +if (overflow && new_cnt >= prev_cnt) + delta += mask +1 ;local64_add (delta, &event->count); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 818/1756 perf/cxl: Accept an overflow interrupt on MSI message number 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit af06fba45746058ba8f983a0ac2f457a3404edba ]
cxl_pmu_probe() rejects the PMU when info->irq <= 0, but at that point the field still holds the MSI/MSI-X message number the device signals overflow on, not a Linux virq. That number is 0-based, and -1 means no interrupt support. Message number 0 is valid and pci_irq_vector() takes a 0-based index, so a compliant device signalling on the first vector fails to probe.
Reject only the no-interrupt case, matching how the CXL mailbox and event interrupts handle it.
--- drivers/perf/cxl_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +1 -1
@@ -870,7 +870,7 @@ static int cxl_pmu_probe(struct device *dev) .capabilities = PERF_PMU_CAP_NO_EXCLUDE, }; -if (info->irq <=0 ) +if (info->irq <0 )return -EINVAL ; rc =pci_irq_vector (pdev, info->irq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 819/1756 perf/cxl: Dont share the overflow interrupt, and keep it pinned
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit b899fd3487b0d4066d60ebcf5b73e77c9617de54 ]
The PMU pins its overflow interrupt to info->on_cpu in the hotplug callbacks, but requests it with only IRQF_SHARED | IRQF_NO_THREAD. Without IRQF_NOBALANCING, irqbalance or a userspace smp_affinity write can move it elsewhere, and cxl_pmu_irq() then runs local64_cmpxchg() and local64_add() on hwc->prev_count and event->count at the same time as the managing CPU. local64_t is only atomic against same-CPU access, so the counts corrupt.
The flag alone does not fix that while the line is shared. __setup_irq() only acts on it for the first action on a line, and a co-owner has no reason to want our affinity - it would keep taking the interrupt wherever its own points, running our handler on the wrong CPU.
Drop IRQF_SHARED and add IRQF_NOBALANCING. The spec only recommends a distinct Interrupt Message Number per CPMU instance (CXL r4.0 8.2.7.1.1), so a device may put several on one vector, or share with the mailbox or event log. Such a device now loses a PMU rather than silently miscounting - and only the PMU, since the preceding patch adds the CPMUs after the event configuration.
--- drivers/perf/cxl_pmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/perf/cxl_pmu.c +9 -2
@@ -779,7 +779,7 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data) overflowed =readq (base +CXL_PMU_OVERFLOW_REG ); -/* Interrupt may be shared, so maybe it isn't ours */ +/* Nothing overflowed, so the device did not raise this */ if (!overflowed)return IRQ_NONE ;
@@ -882,7 +882,14 @@ static int cxl_pmu_probe(struct device *dev)if (!irq_name)return -ENOMEM ; - rc =devm_request_irq (dev, irq, cxl_pmu_irq,IRQF_SHARED |IRQF_NO_THREAD , +/* +* The handler must run on info->on_cpu, so the interrupt cannot be +* shared - IRQF_NOBALANCING is only honoured for the first action on a +* line, and a co-owner would keep taking the interrupt wherever its own +* affinity points. +*/ + rc =devm_request_irq (dev, irq, cxl_pmu_irq, +IRQF_NO_THREAD |IRQF_NOBALANCING , irq_name, info);if (rc)return rc;
Signature · 1 line
2.53.0
Re: [PATCH 6.12 0819/1756] perf/cxl: Dont share the overflow interrupt, and keep it pinned
Hi Greg/Sasha,
Quoted 58 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit
b899fd3487b0d4066d60ebcf5b73e77c9617de54]The PMU pins its overflow interrupt to
info->on_cpuin the hotplug callbacks, but requests it with onlyIRQF_SHARED|IRQF_NO_THREAD. WithoutIRQF_NOBALANCING, irqbalance or a userspacesmp_affinitywrite can move it elsewhere, andcxl_pmu_irq()then runslocal64_cmpxchg()andlocal64_add()onhwc->prev_countandevent->countat the same time as the managing CPU.local64_tis only atomic against same-CPU access, so the counts corrupt.The flag alone does not fix that while the line is shared.
__setup_irq()only acts on it for the first action on a line, and a co-owner has no reason to want our affinity - it would keep taking the interrupt wherever its own points, running our handler on the wrong CPU.Drop
IRQF_SHAREDand addIRQF_NOBALANCING. The spec only recommends a distinct Interrupt Message Number per CPMU instance (CXL r4.0 8.2.7.1.1), so a device may put several on one vector, or share with the mailbox or event log. Such a device now loses a PMU rather than silently miscounting - and only the PMU, since the preceding patch adds the CPMUs after the event configuration.Fixes 5d7107c72796 ("perf: CXL Performance Monitoring Unit driver")Reported-by [email protected]Assisted-by Claude:claude-opus-4-8Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Davidlohr Bueso <[email protected]>Signed-off-by Dave Jiang <[email protected]>Signed-off-by Will Deacon <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/perf/cxl_pmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/perf/cxl_pmu.c +1
-1@@ -779,7 +779,7 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data) overflowed =readq (base +CXL_PMU_OVERFLOW_REG ); -/* Interrupt may be shared, so maybe it isn't ours */ +/* Nothing overflowed, so the device did not raise this */ if (!overflowed)return IRQ_NONE ;@@ -882,7 +882,14 @@ static int cxl_pmu_probe(struct device *dev)if (!irq_name)return -ENOMEM ;
drivers/perf/cxl_pmu.c static int cxl_pmu_probe(struct device *dev) · line 893
Quoted 10 lines
drivers/perf/cxl_pmu.c +8
-1- rc =devm_request_irq (dev, irq, cxl_pmu_irq,IRQF_SHARED |IRQF_NO_THREAD , +/* +* The handler must run on info->on_cpu, so the interrupt cannot be +* shared - IRQF_NOBALANCING is only honoured for the first action on a +* line, and a co-owner would keep taking the interrupt wherever its own +* affinity points. +*/ + rc =devm_request_irq (dev, irq, cxl_pmu_irq, +IRQF_NO_THREAD |IRQF_NOBALANCING , irq_name, info);
I ran an AI-assisted backport review of 6.12.y and the finding looks correct to me.
Verdict: lets drop this until we have a prerequisite commit.
In drivers/perf/cxl_pmu.c, cxl_pmu_probe(), this patch removes IRQF_SHARED:
- rc = devm_request_irq(dev, irq, cxl_pmu_irq,
- IRQF_SHARED | IRQF_NO_THREAD,
+ rc = devm_request_irq(dev, irq, cxl_pmu_irq,
+ IRQF_NO_THREAD | IRQF_NOBALANCING,
irq_name, info);
But drivers/cxl/pci.c, cxl_pci_probe(), still adds PMUs before configuring event interrupts:
for (i = 0; i < pmu_count; i++) {
...
rc = devm_cxl_pmu_add(...);
...
}
rc = cxl_event_config(host_bridge, mds, irq_avail);
if (rc)
return rc;If a PMU claims a vector also used for events, the event request in cxl_request_irq() cannot share that exclusive interrupt:
return devm_request_threaded_irq(dev, irq, NULL, thread_fn,
IRQF_SHARED | IRQF_ONESHOT, NULL, dev_id);
The resulting -EBUSY propagates through cxl_event_config() and aborts cxl_pci_probe(), losing the memory device as well as PMU support.
I think this needs 28b2b667f48f ("cxl/pci: Add the PMUs after configuring events").
Upstream places cxl_event_config() before the PMU loop, so the event IRQ is reserved first and a conflict only fails PMU probe.
Could we take the prerequisite first ?
thanks,
Harshit
Quoted 2 lines
drivers/perf/cxl_pmu.c +0
-0if (rc)return rc;
Re: [PATCH 6.12 0819/1756] perf/cxl: Dont share the overflow interrupt, and keep it pinned
Quoted 2 lines
I think this needs
28b2b667f48f("cxl/pci: Add the PMUs after configuring events").
[...]
Quoted 1 line
Could we take the prerequisite first ?
Queued the missing prerequisite for 7.3, 6.18, 6.12 and 6.6, thanks.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 820/1756 perf/cxl: Unfreeze counters after handling an overflow interrupt
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 2e4fe234c72d65a09bbfd421240a0cfd7c8046a2 ]
The counters run with Freeze on Overflow set, so one overflow freezes every counter in the block (CXL r4.0 8.2.7.2.1), and a frozen counter "remains frozen until explicitly unfrozen by software" (8.2.7.1.3, Table 8-183). cxl_pmu_irq() reads the overflowed counters and clears the overflow status but never unfreezes, so everything stays frozen until the next pmu_enable() and events in that window are lost.
Unfreeze after clearing the status, unless the PMU has been disabled in the meantime - cxl_pmu_disable() freezes the block deliberately. Track the enabled state and leave it frozen in that case.
--- drivers/perf/cxl_pmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/perf/cxl_pmu.c +19 -0
@@ -107,6 +107,8 @@ struct cxl_pmu_info {struct hlist_node node;bool filter_hdm;int irq; +/* Set between pmu_enable() and pmu_disable(), read by the IRQ handler */ +bool enabled; };#define pmu_to_cxl_pmu_info (_pmu) container_of(_pmu, struct cxl_pmu_info, pmu)
@@ -592,6 +594,7 @@ static void cxl_pmu_enable(struct pmu *pmu)void __iomem *base = info->base;/* Can assume frozen at this stage */ +WRITE_ONCE (info->enabled, true);writeq (0 , base +CXL_PMU_FREEZE_REG ); }
@@ -600,6 +603,7 @@ static void cxl_pmu_disable(struct pmu *pmu)struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (pmu);void __iomem *base = info->base; +WRITE_ONCE (info->enabled, false);/* * Whilst bits above number of counters are RsvdZ * they are unlikely to be repurposed given
@@ -798,6 +802,21 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data)writeq (overflowed, base +CXL_PMU_OVERFLOW_REG ); +/* +* An overflow freezes every counter in the CPMU, so unfreeze once the +* overflowed ones have been read and their status cleared. Otherwise +* they stay frozen until the next pmu_enable() and events are lost. +* +* Not while the PMU is disabled, so as not to undo an intentional freeze. +* The check is advisory, not exclusive: pmu_disable() normally runs on +* info->on_cpu with interrupts off, where the pinned handler cannot +* preempt it. In the one window where it does not - the migration in +* cxl_pmu_offline_cpu() - the counters are legitimately running again, +* so unfreezing is correct there anyway. +*/ +if (READ_ONCE (info->enabled)) +writeq (0 , base +CXL_PMU_FREEZE_REG ); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 821/1756 perf/cxl: Validate the hardware-reported counter width
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 1c5499e67303a9393388197fb14b39ed06a3dc55 ]
cxl_pmu_parse_caps() takes the Counter Width straight from the CPMU Capability register without a bounds check. The Counter Data register is 64 bits wide, so a device reporting 0 or more than 64 is reporting nonsense, and GENMASK_ULL(width - 1, 0) in the read path then shifts out of range. That is undefined behaviour, and a UBSAN splat where it is enabled.
Reject a counter width outside 1..64 at probe.
--- drivers/perf/cxl_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/perf/cxl_pmu.c +9 -0
@@ -141,6 +141,15 @@ static int cxl_pmu_parse_caps(struct device *dev, struct cxl_pmu_info *info) info->num_counters =FIELD_GET (CXL_PMU_CAP_NUM_COUNTERS_MSK , val) +1 ; info->counter_width =FIELD_GET (CXL_PMU_CAP_COUNTER_WIDTH_MSK , val); +/* +* The Counter Data register is 64 bits wide, so a Counter Width of 0 or +* >64 is invalid. Reject it rather than let GENMASK_ULL(width - 1, 0) in +* the read path shift out of range. +*/ +if (info->counter_width ==0 || info->counter_width >64 ) { +dev_err (dev,"Invalid counter width %d\n" , info->counter_width); +return -ENODEV ; + } info->num_event_capabilities =FIELD_GET (CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK , val) +1 ; info->filter_hdm =FIELD_GET (CXL_PMU_CAP_FILTERS_SUP_MSK , val) &CXL_PMU_FILTER_HDM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 822/1756 perf/cxl: Dont log through pmu.dev in the overflow interrupt handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 984920c893f0e6832351bc03deeb5ef9a42fbdbb ]
perf_pmu_unregister() frees pmu->dev without clearing the pointer, and cxl_pmu_probe() orders its devm actions so that teardown runs it before free_irq(). Nothing in between masks the interrupt, and cxl_pmu_event_stop() leaves the overflow status bit set, so an overflow taken just before teardown is still delivered and still reaches the dev_dbg() in the !event branch - by which point info->pmu.dev is freed.
Log through info->pmu.parent instead, which is devm-managed and outlives every teardown action.
--- drivers/perf/cxl_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +1 -1
@@ -801,7 +801,7 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data)struct perf_event *event = info->hw_events[i];if (!event) { -dev_dbg (info->pmu.dev, +dev_dbg (info->pmu.parent,"overflow but on non enabled counter %d\n" , i);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 823/1756 perf/cxl: Clear stale overflow status before using a counter
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 05d82cf377f706d0b566b572bc66e3a2057bd68e ]
cxl_pmu_event_stop() leaves the counter's bit set in the overflow status register and only cxl_pmu_irq() ever clears it, so a counter handed from one event to the next starts with the previous owner's overflow pending. The perf core stops and starts back to back with interrupts off, so an interrupt latched over the handover lands on the new event. prev_count is 0 by then, so the read path adds a full period: 2^counter_width phantom counts.
Clear the bit in cxl_pmu_event_start(), before the config write arms Interrupt on Overflow. Clear the whole register at probe too, for counters no event ever owns - the driver never touched it, so firmware or a previous kernel can leave a bit set there.
--- drivers/perf/cxl_pmu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/perf/cxl_pmu.c +17 -0
@@ -679,6 +679,15 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags)*/ cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_THRESHOLD_MSK ,cxl_pmu_config1_get_threshold (event)); + +/* +* Drop any overflow the previous owner of this counter left pending; +* cxl_pmu_event_stop() does not. Otherwise an interrupt latched over +* the handover gets charged to this event. Do it before arming Interrupt +* on Overflow below, and note RW1C leaves the other counters alone. +*/ +writeq (BIT_ULL (hwc->idx), base +CXL_PMU_OVERFLOW_REG ); +writeq (cfg, base +CXL_PMU_COUNTER_CFG_REG (hwc->idx));local64_set (&hwc->prev_count,0 );
@@ -910,6 +919,14 @@ static int cxl_pmu_probe(struct device *dev)if (!irq_name)return -ENOMEM ; +/* +* Same for counters no event owns yet: clear whatever firmware or a +* previous kernel left set before the handler goes live. Bits above the +* implemented counters are reserved, so only write those. +*/ +writeq (GENMASK_ULL (info->num_counters -1 ,0 ), + info->base +CXL_PMU_OVERFLOW_REG ); +/* * The handler must run on info->on_cpu, so the interrupt cannot be * shared - IRQF_NOBALANCING is only honoured for the first action on a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 824/1756 perf/dwc_pcie: Fix PCI device reference leak in probe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 3a4067658363e34bf4e1d7039e5b52951fcb4012 ]
pci_get_domain_bus_and_slot() returns a referenced PCI device. When the subsequent RAS DES capability lookup fails, dwc_pcie_pmu_probe() returns -ENODEV without releasing that reference. Repeated failed probes can therefore keep the PCI device allocated after removal.
Declare the looked-up device with __free(pci_dev_put), so the temporary reference is released on every return path. Keeping the reference scoped to the whole probe also covers all later uses of the device during initialization.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/perf/dwc_pcie_pmu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/perf/dwc_pcie_pmu.c +5 -6
@@ -613,16 +613,16 @@ static struct notifier_block dwc_pcie_pmu_nb = {static int dwc_pcie_pmu_probe (struct platform_device *plat_dev) { -struct pci_dev *pdev; +u32 sbdf = plat_dev->id; + struct pci_dev *pdev __free(pci_dev_put) = +pci_get_domain_bus_and_slot (sbdf >>16 , +PCI_BUS_NUM (sbdf &0xffff ), + sbdf &0xff );struct dwc_pcie_pmu *pcie_pmu;char *name; -u32 sbdf;u16 vsec;int ret; - sbdf = plat_dev->id; - pdev =pci_get_domain_bus_and_slot (sbdf >>16 ,PCI_BUS_NUM (sbdf &0xffff ), - sbdf &0xff );if (!pdev) {pr_err ("No pdev found for the sbdf 0x%x\n" , sbdf);return -ENODEV ;
@@ -632,7 +632,6 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)if (!vsec)return -ENODEV ; -pci_dev_put (pdev); name =devm_kasprintf (&plat_dev->dev,GFP_KERNEL ,"dwc_rootport_%x" , sbdf);if (!name)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 825/1756 spi: fsl: switch to managed controller allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 6afe041c2ce9068b2b6c64eddb5537911752050c ]
Switch to device managed controller allocation to simplify error handling and to avoid having to take another reference during deregistration.
Stable-dep-of: af1d882d421d ("spi: fsl: unmap immr_spi_cs on remove")
--- drivers/spi/spi-fsl-spi.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/spi/spi-fsl-spi.c +2 -12
@@ -535,7 +535,7 @@ static struct spi_controller *fsl_spi_probe(struct device *dev,u32 regval;int ret =0 ; - host =spi_alloc_host (dev,sizeof (struct mpc8xxx_spi )); + host =devm_spi_alloc_host (dev,sizeof (struct mpc8xxx_spi ));if (host ==NULL ) { ret = -ENOMEM ; goto err;
@@ -559,7 +559,7 @@ static struct spi_controller *fsl_spi_probe(struct device *dev, ret =fsl_spi_cpm_init (mpc8xxx_spi);if (ret) - goto err_cpm_init; + goto err; mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) {
@@ -625,8 +625,6 @@ static struct spi_controller *fsl_spi_probe(struct device *dev, err_probe:fsl_spi_cpm_free (mpc8xxx_spi); -err_cpm_init: -spi_controller_put (host); err:return ERR_PTR (ret); }
@@ -705,13 +703,9 @@ static void of_fsl_spi_remove(struct platform_device *ofdev)struct spi_controller *host =platform_get_drvdata (ofdev);struct mpc8xxx_spi *mpc8xxx_spi =spi_controller_get_devdata (host); -spi_controller_get (host); -spi_unregister_controller (host);fsl_spi_cpm_free (mpc8xxx_spi); - -spi_controller_put (host); }static struct platform_driver of_fsl_spi_driver = {
@@ -757,13 +751,9 @@ static void plat_mpc8xxx_spi_remove(struct platform_device *pdev)struct spi_controller *host =platform_get_drvdata (pdev);struct mpc8xxx_spi *mpc8xxx_spi =spi_controller_get_devdata (host); -spi_controller_get (host); -spi_unregister_controller (host);fsl_spi_cpm_free (mpc8xxx_spi); - -spi_controller_put (host); }MODULE_ALIAS ("platform:mpc8xxx_spi" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 826/1756 spi: fsl: unmap immr_spi_cs on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit af1d882d421de504a1e5fac92eb06947b6cbdd8f ]
of_fsl_spi_remove() does not unmap pinfo->immr_spi_cs after a successful probe when CONFIG_FSL_SOC is enabled and fsl,spisel_boot causes of_fsl_spi_probe() to map it with ioremap(). The probe error path already performs the matching iounmap().
Retrieve pinfo from the platform data and call iounmap() when pinfo->immr_spi_cs is present, pairing normal removal with the mapping established by of_fsl_spi_probe().
--- drivers/spi/spi-fsl-spi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/spi/spi-fsl-spi.c +8 -0
@@ -702,10 +702,18 @@ static void of_fsl_spi_remove(struct platform_device *ofdev) {struct spi_controller *host =platform_get_drvdata (ofdev);struct mpc8xxx_spi *mpc8xxx_spi =spi_controller_get_devdata (host); +#if IS_ENABLED (CONFIG_FSL_SOC ) +struct fsl_spi_platform_data *pdata =dev_get_platdata (&ofdev->dev); +struct mpc8xxx_spi_probe_info *pinfo =to_of_pinfo (pdata); +#endif spi_unregister_controller (host);fsl_spi_cpm_free (mpc8xxx_spi); +#if IS_ENABLED (CONFIG_FSL_SOC ) +if (pinfo->immr_spi_cs) +iounmap (pinfo->immr_spi_cs); +#endif }static struct platform_driver of_fsl_spi_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 827/1756 spi: bcm63xx-hsspi: Disable runtime PM on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 38232bd3cea74845c2064eb9f7eac77fa5a21d85 ]
bcm63xx_hsspi_probe() enables runtime PM before creating the sysfs
group, but bcm63xx_hsspi_remove() does not perform the matchingpm_runtime_disable() after a successful probe.
The probe error paths already disable runtime PM when sysfs group creation or controller registration fails.
Add pm_runtime_disable() to the remove path after removing the sysfs group to balance pm_runtime_enable() from bcm63xx_hsspi_probe().
--- drivers/spi/spi-bcm63xx-hsspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-bcm63xx-hsspi.c +1 -0
@@ -888,6 +888,7 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev)clk_disable_unprepare (bs->pll_clk);clk_disable_unprepare (bs->clk);sysfs_remove_group (&pdev->dev.kobj, &bcm63xx_hsspi_group); +pm_runtime_disable (&pdev->dev); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 828/1756 selftests/alsa: Do not take another controls event as our own
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c9b0768669976a1beb0a1537b4257bd6b76dfbac ]
The wait_for_event() skips an event for a different control with a continue inside its do-while loop. But continue goes straight to the loop condition, and that tests the mask of the event just skipped. So a value event for another control ends the wait as if it were ours.
A driver that notifies a second control from its put() queues that event first. The core only sends ours once put() returns. So the wait returns early and leaves ours in the queue. The next test then reports it as spurious. And event_missing passes for a control whose put() said nothing changed, as long as it notified a neighbour.
To fix this, clear the mask before skipping the event.
--- tools/testing/selftests/alsa/mixer-test.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/alsa/mixer-test.c +2 -0
@@ -261,6 +261,8 @@ static int wait_for_event(struct ctl_data *ctl, int timeout)if (ev_id !=snd_ctl_elem_info_get_numid (ctl->info)) {ksft_print_msg ("Event for unexpected ctl %s\n" ,snd_ctl_event_elem_get_name (event)); +/* The loop condition must not see the other control's mask */ + mask =0 ;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 829/1756 power: supply: ab8500_btemp: Fix event temperature reporting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 95990cda8e42dda4bd3f1475d578323981bd8579 ]
The event-aware path initializes its local temperature to zero and compares that zero against the thermal thresholds. Consequently some events report the measured temperature after it crosses the event threshold, while others always report the threshold.
Start with the measured temperature, clamp it according to the active event, and convert to tenths of a degree only once. This path is used by AB8505 and later variants.
--- drivers/power/supply/ab8500_btemp.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/power/supply/ab8500_btemp.c +9 -19
@@ -468,39 +468,29 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,*/ static int ab8500_btemp_get_temp (struct ab8500_btemp *di) { -int temp =0 ; +int temp = di->bat_temp;/* * The BTEMP events are not reliabe on AB8500 cut3.3 * and prior versions */ -if (is_ab8500_3p3_or_earlier (di->parent)) { - temp = di->bat_temp *10 ; - }else { +if (!is_ab8500_3p3_or_earlier (di->parent)) {if (di->events.btemp_low) {if (temp > di->btemp_ranges.btemp_low_limit) - temp = di->btemp_ranges.btemp_low_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_low_limit; }else if (di->events.btemp_high) {if (temp < di->btemp_ranges.btemp_high_limit) - temp = di->btemp_ranges.btemp_high_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_high_limit; }else if (di->events.btemp_lowmed) {if (temp > di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; }else if (di->events.btemp_medhigh) {if (temp < di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; - }else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; + } } -return temp; + +return temp *10 ; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 830/1756 power: supply: ab8500: Preserve battery termination current
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3b33eda4067494658d51db0792377fef98787e3f ]
The battery-info parser uses a negative value for an unspecified termination current. Testing the value as a boolean instead replaces every valid positive current from the battery description with 200 mA.
Apply the default only when the property is unspecified so batteries retain their described charging termination current.
--- drivers/power/supply/ab8500_bmdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ab8500_bmdata.c +1 -1
@@ -174,7 +174,7 @@ int ab8500_bm_of_probe(struct power_supply *psy,if (bi->constant_charge_voltage_max_uv <0 ) bi->constant_charge_voltage_max_uv =4100000 ; -if (bi->charge_term_current_ua) +if (bi->charge_term_current_ua <0 )/* Charging stops when we drop below this current */ bi->charge_term_current_ua =200000 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 831/1756 power: supply: ab8500_charger: Fix AC charger re-enable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3e1d2517347f6bb72f74e63ec77d1634385fbf21 ]
The AC check-enable callback passes the embedded USB charger object to ab8500_charger_ac_en(). That helper derives the parent with the AC charger offset, so the wrong object yields an invalid ab8500_charger pointer.
Pass the AC charger object when re-enabling AC charging.
--- drivers/power/supply/ab8500_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/ab8500_charger.c +2 -2
@@ -1778,7 +1778,7 @@ static int ab8500_charger_usb_check_enable(struct ux500_charger *charger, }/** -* ab8500_charger_ac_check_enable() - enable usb charging +* ab8500_charger_ac_check_enable() - enable AC charging * @charger: pointer to the ux500_charger structure * @vset_uv: charging voltage in microvolt * @iset_ua: charger output current in micrompere
@@ -1817,7 +1817,7 @@ static int ab8500_charger_ac_check_enable(struct ux500_charger *charger,return ret; } - ret =ab8500_charger_ac_en (&di->usb_chg, true, vset_uv, iset_ua); + ret =ab8500_charger_ac_en (&di->ac_chg, true, vset_uv, iset_ua);if (ret <0 ) {dev_err (di->dev,"failed to enable AC charger %d\n" , __LINE__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 832/1756 power: supply: ab8500_charger: Decode AB8505 USB status
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 2b697df2b6394613a3bb168adfa8a845ad7c83d9 ]
AB8505 keeps USB link status in the same bit position as AB8500 but defines a different five-bit value table. Reusing the AB8500 enum treats several reserved AB8505 values as chargers and misidentifies the AB8505 charger-fault and DM-high states.
Add an AB8505 decoder, reject reserved and non-charging states, and retain conservative current limits for supported charger types. Restrict the invalid-link workaround to AB8500 and stop processing when the status register cannot be read.
--- drivers/power/supply/ab8500_charger.c | 170 +++++++++++++++++++++----- 1 file changed, 142 insertions(+), 28 deletions(-)
drivers/power/supply/ab8500_charger.c +142 -28
@@ -136,6 +136,33 @@ enum ab8500_charger_link_status { USB_STAT_ACA_DOCK_CHARGER, }; +/* UsbLink1Status register values used by AB8505 */ +enum ab8505_charger_link_status { +AB8505_USB_STAT_OFF , +AB8505_USB_STAT_SDP_NOT_CHARGING , +AB8505_USB_STAT_SDP_CHARGING , +AB8505_USB_STAT_SDP_SUSPENDED , +AB8505_USB_STAT_CDP , +AB8505_USB_STAT_RESERVED_5 , +AB8505_USB_STAT_RESERVED_6 , +AB8505_USB_STAT_DCP , +AB8505_USB_STAT_ACA_RID_A , +AB8505_USB_STAT_ACA_RID_B , +AB8505_USB_STAT_ACA_RID_C , +AB8505_USB_STAT_RESERVED_11 , +AB8505_USB_STAT_RESERVED_12 , +AB8505_USB_STAT_UPSTREAM_IDGND , +AB8505_USB_STAT_CHARGER_NOT_OK , +AB8505_USB_STAT_CHARGER_DM_HIGH , +AB8505_USB_STAT_PHY_ENABLED , +AB8505_USB_STAT_UPSTREAM_NO_IDGND , +AB8505_USB_STAT_UPSTREAM_IDGND_VBUS , +AB8505_USB_STAT_CHARGER_SE1 , +AB8505_USB_STAT_CARKIT_1 , +AB8505_USB_STAT_CARKIT_2 , +AB8505_USB_STAT_ACA_DOCK_CHARGER , +}; +enum ab8500_usb_state {AB8500_BM_USB_STATE_RESET_HS ,/* HighSpeed Reset */ AB8500_BM_USB_STATE_RESET_FS ,/* FullSpeed/LowSpeed Reset */
@@ -699,20 +726,102 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe) }/** -* ab8500_charger_max_usb_curr() - get the max curr for the USB type +* ab8505_charger_max_usb_curr() - get the max current for the USB type * @di: pointer to the ab8500_charger structure * @link_status: the identified USB type * -* Get the maximum current that is allowed to be drawn from the host -* based on the USB type. +* Decode AB8505-specific UsbLink1Status values and get the maximum current +* that is allowed to be drawn based on the USB type. * Returns error code in case of failure else 0 on success */ +static int ab8505_charger_max_usb_curr (struct ab8500_charger *di, +u8 link_status) +{ +int ret =0 ; + + di->is_aca_rid =0 ; + +switch (link_status) { +case AB8505_USB_STAT_SDP_NOT_CHARGING : +case AB8505_USB_STAT_SDP_CHARGING : +case AB8505_USB_STAT_SDP_SUSPENDED : +case AB8505_USB_STAT_CDP : +case AB8505_USB_STAT_CHARGER_DM_HIGH : +case AB8505_USB_STAT_UPSTREAM_NO_IDGND : +case AB8505_USB_STAT_UPSTREAM_IDGND_VBUS : +case AB8505_USB_STAT_CHARGER_SE1 : +case AB8505_USB_STAT_CARKIT_1 : +case AB8505_USB_STAT_CARKIT_2 : +case AB8505_USB_STAT_ACA_DOCK_CHARGER : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P5 ; +break ; +case AB8505_USB_STAT_DCP : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P5 ; +break ; +case AB8505_USB_STAT_ACA_RID_A : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P5 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_ACA_RID_B : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P3 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_ACA_RID_C : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P5 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_OFF : +if (di->vbus_detected) { + di->usb_device_is_unrecognised = true; + di->max_usb_in_curr.usb_type_max_ua = +USB_CH_IP_CUR_LVL_1P5 ; +break ; + } + fallthrough; +case AB8505_USB_STAT_UPSTREAM_IDGND : +case AB8505_USB_STAT_PHY_ENABLED : +dev_err (di->dev,"USB Type - Charging not allowed\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; +case AB8505_USB_STAT_CHARGER_NOT_OK : + di->flags.vbus_collapse = true; +dev_err (di->dev,"USB Type - VBUS has collapsed\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; +case AB8505_USB_STAT_RESERVED_5 : +case AB8505_USB_STAT_RESERVED_6 : +case AB8505_USB_STAT_RESERVED_11 : +case AB8505_USB_STAT_RESERVED_12 : +default : +dev_err (di->dev,"USB Type - Unknown\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; + } + +return ret; +} + +/** +* ab8500_charger_max_usb_curr() - get the max current for the USB type +* @di: pointer to the ab8500_charger structure +* @link_status: the identified USB type +* +* Get the maximum current that is allowed to be drawn based on the USB type. +* Returns error code in case of failure else 0 on success. +*/ static int ab8500_charger_max_usb_curr (struct ab8500_charger *di, -enum ab8500_charger_link_status link_status) +u8 link_status) {int ret =0 ; di->usb_device_is_unrecognised = false; +if (is_ab8505 (di->parent)) { + ret =ab8505_charger_max_usb_curr (di, link_status); + goto out; + }/* * Platform only supports USB 2.0.
@@ -721,7 +830,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,* should set USB_CH_IP_CUR_LVL_0P5. */ -switch (link_status) { +switch ((enum ab8500_charger_link_status )link_status) {case USB_STAT_STD_HOST_NC :case USB_STAT_STD_HOST_C_NS :case USB_STAT_STD_HOST_C_S :
@@ -825,6 +934,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,break ; } +out: di->max_usb_in_curr.set_max_ua = di->max_usb_in_curr.usb_type_max_ua;dev_dbg (di->dev,"USB Type - 0x%02x MaxCurr: %d" , link_status, di->max_usb_in_curr.set_max_ua);
@@ -866,8 +976,7 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di) val = (val &AB8500_USB_LINK_STATUS ) >>USB_LINK_STATUS_SHIFT ; else val = (val &AB8505_USB_LINK_STATUS ) >>USB_LINK_STATUS_SHIFT ; - ret =ab8500_charger_max_usb_curr (di, - (enum ab8500_charger_link_status ) val); + ret =ab8500_charger_max_usb_curr (di, val);return ret; }
@@ -929,8 +1038,7 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)if (val)break ; } - ret =ab8500_charger_max_usb_curr (di, - (enum ab8500_charger_link_status ) val); + ret =ab8500_charger_max_usb_curr (di, val);return ret; }
@@ -2278,6 +2386,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)int ret;u8 val;u8 link_status; +u8 link_status_mask;struct ab8500_charger *di =container_of (work, struct ab8500_charger, usb_link_status_work);
@@ -2304,20 +2413,22 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work) ret =abx500_get_register_interruptible (di->dev,AB8500_USB ,AB8500_USB_LINK1_STAT_REG , &val); -if (ret >=0 ) -dev_dbg (di->dev,"UsbLineStatus register = 0x%02x\n" , val); -else -dev_dbg (di->dev,"Error reading USB link status\n" ); +if (ret <0 ) { +dev_err (di->dev,"Error reading USB link status\n" ); +return ; + } +dev_dbg (di->dev,"UsbLineStatus register = 0x%02x\n" , val);if (is_ab8500 (di->parent)) - link_status =AB8500_USB_LINK_STATUS ; + link_status_mask =AB8500_USB_LINK_STATUS ;else - link_status =AB8505_USB_LINK_STATUS ; + link_status_mask =AB8505_USB_LINK_STATUS ; + link_status = (val & link_status_mask) >>USB_LINK_STATUS_SHIFT ;if (detected_chargers &USB_PW_CONN ) { -if (((val & link_status) >>USB_LINK_STATUS_SHIFT ) == -USB_STAT_NOT_VALID_LINK && - di->invalid_charger_detect_state ==0 ) { +if (is_ab8500 (di->parent) && + link_status ==USB_STAT_NOT_VALID_LINK && + di->invalid_charger_detect_state ==0 ) {dev_dbg (di->dev,"Invalid charger detected, state= 0\n" );/*Enable charger*/
@@ -2340,18 +2451,21 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)abx500_mask_and_set_register_interruptible (di->dev,AB8500_USB ,AB8500_USB_LINE_CTRL2_REG ,USB_CH_DET ,0x00 ); -/*Check link status*/ -if (is_ab8500 (di->parent)) - ret =abx500_get_register_interruptible (di->dev, -AB8500_USB ,AB8500_USB_LINE_STAT_REG , - &val); -else - ret =abx500_get_register_interruptible (di->dev, -AB8500_USB ,AB8500_USB_LINK1_STAT_REG , - &val); +/* Check link status */ + ret =abx500_get_register_interruptible (di->dev, +AB8500_USB , +AB8500_USB_LINE_STAT_REG , + &val); +if (ret <0 ) { +dev_err (di->dev, +"Error reading USB link status\n" ); +return ; + } + link_status = (val & link_status_mask) >> +USB_LINK_STATUS_SHIFT ;dev_dbg (di->dev,"USB link status= 0x%02x\n" , - (val & link_status) >>USB_LINK_STATUS_SHIFT ); + link_status); di->invalid_charger_detect_state =2 ; } }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 833/1756 power: supply: ab8500_charger: Respect AB8505 register layout
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dcecf527632297011153f088573689a1ad1de790 ]
Several AB8505 charger fields differ from AB8500. Its long VBUS falling debounce is 300 ms rather than 100 ms, and its VBUS overvoltage selector has a different encoding programmed through OTP. Writing the AB8500 6.3 V value selects 9 V on AB8505.
AB8505 revision 3 also defines SwControlFallback as reserved, correcting older documentation which led the driver to support autopower there. Preserve the AB8505 overvoltage setting, wait for its documented debounce, and reject the unsupported autopower setting.
--- drivers/power/supply/ab8500_charger.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/power/supply/ab8500_charger.c +19 -8
@@ -52,7 +52,7 @@#define MAIN_CH_DET 0x01#define MAIN_CH_CV_ON 0x04#define USB_CH_CV_ON 0x08 -#define VBUS_DET_DBNC100 0x02 +#define VBUS_DET_DBNC_LONG 0x02#define VBUS_DET_DBNC1 0x01#define OTP_ENABLE_WD 0x01#define DROP_COUNT_RESET 0x01
@@ -383,6 +383,10 @@ static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,u8 bit;int ret; +/* SwControlFallback is reserved and must remain clear on AB8505. */ +if (is_ab8505 (di->parent)) +return ; +dev_dbg (di->dev,"SW Fallback: %d\n" , fallback);if (is_ab8500 (di->parent)) {
@@ -703,12 +707,16 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)if (!probe) {/* -* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC100 +* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC_LONG * when disconnecting ACA even though no * charger was connected. Try waiting a little -* longer than the 100 ms of VBUS_DET_DBNC100... +* longer than its 100 ms debounce. AB8505 uses +* a 300 ms falling debounce for the same bit. */ -msleep (110 ); +if (is_ab8505 (di->parent)) +msleep (310 ); +else +msleep (110 ); } ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER ,AB8500_CH_USBCH_STAT1_REG , &val);
@@ -719,7 +727,7 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)dev_dbg (di->dev,"%s AB8500_CH_USBCH_STAT1_REG %x\n" , __func__, val); -if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC100 )) +if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC_LONG )) result |=USB_PW_CONN ;return result;
@@ -3186,7 +3194,7 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) } } -if (is_ab8505_2p0 (di->parent)) +if (is_ab8505 (di->parent)) ret = abx500_mask_and_set_register_interruptible(di->dev, AB8500_CHARGER, AB8500_USBCH_CTRL2_REG,
@@ -3535,11 +3543,14 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); -/* get parent data */ di->dev = dev; di->parent =dev_get_drvdata (pdev->dev.parent); + di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); +if (di->autopower_cfg &&is_ab8505 (di->parent)) { +dev_warn (dev,"autopower is not supported on AB8505\n" ); + di->autopower_cfg = false; + }/* Get ADC channels */ if (!is_ab8505 (di->parent)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 834/1756 power: supply: ab8500_charger: Handle detection errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1098c619ce7595a77a8c2e366a703e9fc5f29bf7 ]
ab8500_charger_detect_chargers() returns either a charger bitmask or a negative register-access error. The probe and component-bind paths use a negative return value as a bitmask, making failed reads appear as both AC and USB connections.
Propagate detection errors and release the bind-time workqueue on failure.
--- drivers/power/supply/ab8500_charger.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/power/supply/ab8500_charger.c +8 -0
@@ -3463,6 +3463,10 @@ static int ab8500_charger_bind(struct device *dev) } ch_stat =ab8500_charger_detect_chargers (di, false); +if (ch_stat <0 ) { +destroy_workqueue (di->charger_wq); +return ch_stat; + }if (ch_stat &AC_PW_CONN ) {if (is_ab8500 (di->parent))
@@ -3751,6 +3755,10 @@ static int ab8500_charger_probe(struct platform_device *pdev)/* Identify the connected charger types during startup */ charger_status =ab8500_charger_detect_chargers (di, true); +if (charger_status <0 ) { + ret = charger_status; + goto remove_ab8500_bm; + }if (charger_status &AC_PW_CONN ) { di->ac.charger_connected =1 ; di->ac_conn = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 835/1756 power: supply: ab8500_charger: Skip absent AB8505 main charger
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 52c8cdcc1146d86fae524a589d4512c8d59ea8b4 ]
AB8505 contains only the USB charger. It has no integrated main charger, main-charger status register, or main-charger interrupts.
Avoid reading the missing status register, requesting the five missing interrupts, or disabling an AC charger which was never enabled. This lets the driver bind using only the AB8505 USB charger resources.
--- drivers/power/supply/ab8500_charger.c | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/power/supply/ab8500_charger.c +21 -11
@@ -692,16 +692,19 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)int ret;u8 val; -/* Check for AC charger */ - ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , -AB8500_CH_STATUS1_REG , &val); -if (ret <0 ) { -dev_err (di->dev,"%s ab8500 read failed\n" , __func__); -return ret; - } +/* AB8505 has no integrated main charger. */ +if (!is_ab8505 (di->parent)) { + ret =abx500_get_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_CH_STATUS1_REG , &val); +if (ret <0 ) { +dev_err (di->dev,"%s ab8500 read failed\n" , __func__); +return ret; + } -if (val &MAIN_CH_DET ) - result =AC_PW_CONN ; +if (val &MAIN_CH_DET ) + result =AC_PW_CONN ; + }/* Check for USB charger */
@@ -3501,7 +3504,8 @@ static void ab8500_charger_unbind(struct device *dev)int ret;/* Disable AC charging */ -ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 ); +if (di->ac_chg.enabled) +ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 );/* Disable USB charging */ ab8500_charger_usb_en (&di->usb_chg, false,0 ,0 );
@@ -3725,7 +3729,13 @@ static int ab8500_charger_probe(struct platform_device *pdev) }/* Request interrupts */ -for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { +/* The first five interrupts belong to the AB8500 main charger. */ +if (is_ab8505 (di->parent)) + i =5 ; +else + i =0 ; + +for (; i <ARRAY_SIZE (ab8500_charger_irq); i++) { irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name);if (irq <0 )return irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 836/1756 power: supply: ab8500_charger: Retry AB8505 USB detection
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 95fba2e3055df99ed19e7d6399101bac42b3e7d5 ]
AB8505 reports UsbLink1Status state 14 when the USB charger port is not OK. The manual says that software can return the port detector to the detection state by setting the self-clearing ChargerCtrl.DropCountReset bit.
The Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle, and Samsung-SGH-T599-Codina-TMO product trees are reference points for a workaround that cycles the USB charger and retries detection three times before rejecting VBUS. Only the Kyle tree writes 1 to DropCountReset; the other two write 0 and therefore do not request the documented reset.
Add the same bounded recovery for AB8505, preserving the configured USB charger control bits across each cycle. Keep the charger connected while recovering, then report the fault and disconnect it if all three attempts fail. Leave AB8500 behavior unchanged.
--- drivers/power/supply/ab8500_charger.c | 114 ++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 5 deletions(-)
drivers/power/supply/ab8500_charger.c +109 -5
@@ -99,6 +99,8 @@#define CHARGER_STATUS_POLL 10/* in ms */ +#define AB8505_USB_CHARGER_NOT_OK_RETRIES 3 +#define CHG_WD_INTERVAL (60 * HZ)#define AB8500_SW_CONTROL_FALLBACK 0x03
@@ -261,6 +263,8 @@ struct ab8500_charger_max_usb_in_curr {* @is_aca_rid: Incicate if accessory is ACA type * @current_stepping_sessions: * Counter for current stepping sessions +* @usb_charger_not_ok_retries: +* Number of AB8505 USB charger recovery attempts * @parent: Pointer to the struct ab8500 * @adc_main_charger_v ADC channel for main charger voltage * @adc_main_charger_c ADC channel for main charger current
@@ -314,6 +318,7 @@ struct ab8500_charger {int invalid_charger_detect_state;int is_aca_rid;atomic_t current_stepping_sessions; +unsigned int usb_charger_not_ok_retries;struct ab8500 *parent;struct iio_channel *adc_main_charger_v;struct iio_channel *adc_main_charger_c;
@@ -473,6 +478,9 @@ static void ab8500_power_supply_changed(struct ab8500_charger *di,static void ab8500_charger_set_usb_connected (struct ab8500_charger *di,bool connected) { +if (!connected && !di->vbus_detected) + di->usb_charger_not_ok_retries =0 ; +if (connected != di->usb.charger_connected) {dev_dbg (di->dev,"USB connected:%i\n" , connected); di->usb.charger_connected = connected;
@@ -796,10 +804,19 @@ static int ab8505_charger_max_usb_curr(struct ab8500_charger *di, ret = -ENXIO ;break ;case AB8505_USB_STAT_CHARGER_NOT_OK : - di->flags.vbus_collapse = true; -dev_err (di->dev,"USB Type - VBUS has collapsed\n" ); di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; - ret = -ENXIO ; +if (di->usb_charger_not_ok_retries < +AB8505_USB_CHARGER_NOT_OK_RETRIES ) { +dev_warn (di->dev, +"USB Type - VBUS has collapsed, retrying\n" ); +queue_delayed_work (di->charger_wq, + &di->check_usbchgnotok_work,0 ); + ret = -EAGAIN ; + }else { +dev_err (di->dev, +"USB Type - VBUS recovery failed\n" ); + ret = -ENXIO ; + }break ;case AB8505_USB_STAT_RESERVED_5 :case AB8505_USB_STAT_RESERVED_6 :
@@ -2588,6 +2605,48 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work) } } +static int ab8505_charger_retry_usb_detection (struct ab8500_charger *di) +{ +u8 usbch_ctrl1; +bool usb_enabled; +int restore_ret; +int ret; + + ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , + &usbch_ctrl1); +if (ret <0 ) +return ret; + + usb_enabled = usbch_ctrl1 &USB_CH_ENA ; +if (usb_enabled) { + ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , +USB_CH_ENA ,0 ); +if (ret <0 ) +return ret; + } + + ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_CHARGER_CTRL , +DROP_COUNT_RESET , +DROP_COUNT_RESET ); + +if (usb_enabled) { + restore_ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , +USB_CH_ENA , +USB_CH_ENA ); +if (restore_ret <0 ) +return restore_ret; + } + +return ret; +} +/** * ab8500_charger_check_usbchargernotok_work() - check USB chg not ok status * @work: pointer to the work_struct structure
@@ -2597,7 +2656,10 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work)static void ab8500_charger_check_usbchargernotok_work (struct work_struct *work) {int ret; +u8 link_status =0 ;u8 reg_value; +bool charger_not_ok; +bool prev_collapse;bool prev_status; struct ab8500_charger *di = container_of(work,
@@ -2610,19 +2672,61 @@ static void ab8500_charger_check_usbchargernotok_work(struct work_struct *work)dev_err (di->dev,"%s ab8500 read failed\n" , __func__);return ; } + charger_not_ok = reg_value &VBUS_CH_NOK ; +if (is_ab8505 (di->parent)) { + ret =abx500_get_register_interruptible (di->dev,AB8500_USB , +AB8500_USB_LINK1_STAT_REG , + &link_status); +if (ret <0 ) { +dev_err (di->dev,"%s USB link status read failed\n" , + __func__); +return ; + } + + link_status = (link_status &AB8505_USB_LINK_STATUS ) >> +USB_LINK_STATUS_SHIFT ; + charger_not_ok |= + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK ; + } + prev_status = di->flags.usbchargernotok; + prev_collapse = di->flags.vbus_collapse; + +if (is_ab8505 (di->parent) && + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK && + di->usb_charger_not_ok_retries < +AB8505_USB_CHARGER_NOT_OK_RETRIES ) { + di->usb_charger_not_ok_retries++; + di->flags.usbchargernotok = false; + di->flags.vbus_collapse = true; +dev_warn (di->dev,"Retrying USB charger detection (%u/%u)\n" , + di->usb_charger_not_ok_retries, +AB8505_USB_CHARGER_NOT_OK_RETRIES ); -if (reg_value &VBUS_CH_NOK ) { + ret =ab8505_charger_retry_usb_detection (di); +if (ret <0 ) +dev_err (di->dev,"USB charger retry failed: %d\n" , ret); + +queue_delayed_work (di->charger_wq, + &di->check_usbchgnotok_work,HZ ); + }else if (charger_not_ok) { di->flags.usbchargernotok = true; +if (is_ab8505 (di->parent) && + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK ) { + di->flags.vbus_collapse = false; +ab8500_charger_set_usb_connected (di, false); + }/* Check again in 1sec */ queue_delayed_work (di->charger_wq, &di->check_usbchgnotok_work,HZ ); }else { di->flags.usbchargernotok = false; di->flags.vbus_collapse = false; + di->usb_charger_not_ok_retries =0 ; } -if (prev_status != di->flags.usbchargernotok) +if (prev_status != di->flags.usbchargernotok || + prev_collapse != di->flags.vbus_collapse)ab8500_power_supply_changed (di, di->usb_chg.psy); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 837/1756 power: supply: ab8500_charger: Recover inactive AB8505 charger
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 76bdf9d78245bb068207c23e9bf43d4b9bb201c3 ]
UsbChCtrl1.UsbChEna can remain set while UsbChStatus1.UsbChOn is clear. The existing recovery only checks the control bit, so it considers the charger enabled and leaves charging stopped.
The Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle, and Samsung-SGH-T599-Codina-TMO product trees are reference points for checking both bits and cycling the charger when they disagree.
Extend the USB charger check to detect this AB8505 state and enable the check in the charging algorithm for AB8505. Only cycle the charger when VBUS is debounced and no charger-not-OK, thermal, overvoltage, or watchdog fault accounts for the inactive hardware.
--- drivers/power/supply/ab8500_chargalg.c | 9 ++--- drivers/power/supply/ab8500_charger.c | 51 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-)
drivers/power/supply/ab8500_chargalg.c +3 -6
@@ -1239,12 +1239,9 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di) charger_status =ab8500_chargalg_check_charger_connection (di); -if (is_ab8500 (di->parent)) { - ret =ab8500_chargalg_check_charger_enable (di); -if (ret <0 ) -dev_err (di->dev,"Checking charger is enabled error" -": Returned Value %d\n" , ret); - } + ret =ab8500_chargalg_check_charger_enable (di); +if (ret <0 ) +dev_err (di->dev,"Checking charger enable failed: %d\n" , ret);/* * First check if we have a charger connected.
drivers/power/supply/ab8500_charger.c +50 -1
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 838/1756 power: supply: ab8500_fg: Finalize current measurements
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9a0461fb5e7cc64ed303bee3661452879ee139a1 ]
ab8500_fg_inst_curr_start() returns with cc_lock held and the CCEOC IRQ enabled. The bounded sampling loop in the load-compensated voltage path returns without calling ab8500_fg_inst_curr_finalize() when it expires, leaving both resources active. The next fuel-gauge work item then blocks on cc_lock and all cached power-supply values stop updating.
The Samsung-GT-I8530-Gavini, Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle and Samsung-SGH-T599-Codina-TMO product trees use a bounded sampling loop in drivers/battery/abb_fuelgauge.c but still call the finalizer. Follow that pattern so the normal completion timeout also performs the required cleanup.
Check the start result as well and return an uncompensated voltage if the instantaneous current transaction cannot be started or completed.
--- drivers/power/supply/ab8500_fg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/power/supply/ab8500_fg.c +9 -4
@@ -934,9 +934,15 @@ static int ab8500_load_comp_fg_bat_voltage(struct ab8500_fg *di, bool always)int i =0 ;int vbat_uv =0 ;int rcomp; +int ret;/* Average the instant current to get a stable current measurement */ -ab8500_fg_inst_curr_start (di); + ret =ab8500_fg_inst_curr_start (di); +if (ret) { +dev_err (di->dev,"failed to start instantaneous current measurement\n" ); + di->vbat_uv =ab8500_fg_bat_voltage (di); +return di->vbat_uv; + } do { vbat_uv += ab8500_fg_bat_voltage(di);
@@ -945,15 +951,14 @@ static int ab8500_load_comp_fg_bat_voltage(struct ab8500_fg *di, bool always) }while (!ab8500_fg_inst_curr_done (di) && i <=WAIT_FOR_INST_CURRENT_MAX ); -if (i >WAIT_FOR_INST_CURRENT_MAX ) { + ret =ab8500_fg_inst_curr_finalize (di, &di->inst_curr_ua); +if (ret) {dev_err (di->dev,"TIMEOUT: return uncompensated measurement of VBAT\n" ); di->vbat_uv = vbat_uv / i;return di->vbat_uv; } -ab8500_fg_inst_curr_finalize (di, &di->inst_curr_ua); -/* * If there is too high current dissipation, the compensation cannot be * trusted so return an error unless we must return something here, as
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 839/1756 power: supply: ab8500_fg: Avoid reserved AB8505 CCConf bit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit edafb2e4642b72b0f86ce5990d5c29c116bb642b ]
AB8500 defines CCConf bit 1 as CCDeepSleepEna, but AB8505 reserves bits 7:1 and only defines bit 0, CCPwrUpEna. The fuel-gauge driver currently writes both bits whenever it starts the coulomb counter.
The Samsung-GT-S7710-Skomer and related Samsung product trees use the same unconditional value in their fuel-gauge drivers, so they provide no AB8505 workaround to carry over. Select the value from the detected PMIC variant instead, retaining the deep-sleep enable bit on all existing non-AB8505 paths and avoiding the reserved bit on AB8505.
--- drivers/power/supply/ab8500_fg.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/power/supply/ab8500_fg.c +12 -2
@@ -451,6 +451,16 @@ static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) avg->avg = sample; } +static u8 ab8500_fg_cc_config (struct ab8500_fg *di) +{ +u8 config =CC_PWR_UP_ENA ; + +if (!is_ab8505 (di->parent)) + config |=CC_DEEP_SLEEP_ENA ; + +return config; +} +/** * ab8500_fg_coulomb_counter() - enable coulomb counter * @di: pointer to the ab8500_fg structure
@@ -481,7 +491,7 @@ static int ab8500_fg_coulomb_counter(struct ab8500_fg *di, bool enable)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto cc_err;
@@ -555,7 +565,7 @@ int ab8500_fg_inst_curr_start(struct ab8500_fg *di)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto fail; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 840/1756 ASoC: rt5682-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9a98f7e955d35e0831fb179e88e98cf9bc0e001e ]
rt5682_sdw_remove() cancels jack_detect_work only when hw_init is true. rt5682_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack_detect_work may already have been queued by rt5682_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work object is initialized during probe, so cancel it unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt5682-sdw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/rt5682-sdw.c +1 -2
@@ -695,8 +695,7 @@ static int rt5682_sdw_remove(struct sdw_slave *slave) {struct rt5682_priv *rt5682 =dev_get_drvdata (&slave->dev); -if (rt5682->hw_init) -cancel_delayed_work_sync (&rt5682->jack_detect_work); +cancel_delayed_work_sync (&rt5682->jack_detect_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 841/1756 ASoC: rt711-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 4bf78e3d9e324f9f2e39feecedd4f70b05baeb16 ]
rt711_sdw_remove() cancels the jack and calibration work only when hw_init is true. rt711_update_status() clears hw_init when the SoundWire slave becomes unattached, but work may already have been queued by rt711_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdw.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/codecs/rt711-sdw.c +3 -5
@@ -462,11 +462,9 @@ static int rt711_sdw_remove(struct sdw_slave *slave) {struct rt711_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); -cancel_work_sync (&rt711->calibration_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work); +cancel_work_sync (&rt711->calibration_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 842/1756 ASoC: rt711-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit ecc2fca6decefe27d8cf40a4c9815798eec24d30 ]
rt711_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt711_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt711_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt711-sdca-sdw.c +2 -4
@@ -361,10 +361,8 @@ static int rt711_sdca_sdw_remove(struct sdw_slave *slave) {struct rt711_sdca_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 843/1756 ASoC: rt712-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit c7d07df95ee7ce7859e6c873a76d19ea9c64b6fd ]
rt712_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt712_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt712_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt712-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt712-sdca-sdw.c +2 -4
@@ -378,10 +378,8 @@ static int rt712_sdca_sdw_remove(struct sdw_slave *slave) {struct rt712_sdca_priv *rt712 =dev_get_drvdata (&slave->dev); -if (rt712->hw_init) { -cancel_delayed_work_sync (&rt712->jack_detect_work); -cancel_delayed_work_sync (&rt712->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt712->jack_detect_work); +cancel_delayed_work_sync (&rt712->jack_btn_check_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 844/1756 ASoC: rt722-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9d29132d81a7f269177be676c3b81cc575899975 ]
rt722_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt722_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt722_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt722-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt722-sdca-sdw.c +2 -4
@@ -438,10 +438,8 @@ static int rt722_sdca_sdw_remove(struct sdw_slave *slave) {struct rt722_sdca_priv *rt722 =dev_get_drvdata (&slave->dev); -if (rt722->hw_init) { -cancel_delayed_work_sync (&rt722->jack_detect_work); -cancel_delayed_work_sync (&rt722->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt722->jack_detect_work); +cancel_delayed_work_sync (&rt722->jack_btn_check_work);if (rt722->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 845/1756 arm64: dts: rockchip: Rename rk3328 HDMI audio card
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit daa0db717771d43c25d98c2798fa6a7b0252deb7 ]
Rename the card from "HDMI" to "RK3328 HDMI" so it identifies the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3328.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +1 -1
@@ -207,7 +207,7 @@ hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <128>; - simple-audio-card,name = "HDMI"; + simple-audio-card,name = "RK3328 HDMI"; status = "disabled"; simple-audio-card,cpu {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 846/1756 ARM: dts: ux500: Use AB8505 charger compatible
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ff1501cbb825de117267124ecb8898112b4051c5 ]
Identify the AB8505 charger using its variant-specific compatible and retain the AB8500 compatible as a fallback for the existing driver. This selects the AB8505 interrupt constraints from the binding.
The AB8505 interrupt table explicitly omits the five interrupt sources belonging to the AB8500 main charger. Remove these nonexistent interrupts from the AB8505 charger node, leaving its nine USB charger interrupts.
--- arch/arm/boot/dts/st/ste-ab8505.dtsi | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
arch/arm/boot/dts/st/ste-ab8505.dtsi +4 -13
@@ -137,13 +137,9 @@ ab8500_btemp { }; ab8500_charger { - compatible = "stericsson,ab8500-charger"; - interrupts = <10 IRQ_TYPE_LEVEL_HIGH>, - <11 IRQ_TYPE_LEVEL_HIGH>, - <0 IRQ_TYPE_LEVEL_HIGH>, - <107 IRQ_TYPE_LEVEL_HIGH>, - <106 IRQ_TYPE_LEVEL_HIGH>, - <14 IRQ_TYPE_LEVEL_HIGH>, + compatible = "stericsson,ab8505-charger", + "stericsson,ab8500-charger"; + interrupts = <14 IRQ_TYPE_LEVEL_HIGH>, <15 IRQ_TYPE_LEVEL_HIGH>, <79 IRQ_TYPE_LEVEL_HIGH>, <105 IRQ_TYPE_LEVEL_HIGH>,
@@ -152,12 +148,7 @@ ab8500_charger { <22 IRQ_TYPE_LEVEL_HIGH>, <21 IRQ_TYPE_LEVEL_HIGH>, <16 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "MAIN_CH_UNPLUG_DET", - "MAIN_CHARGE_PLUG_DET", - "MAIN_EXT_CH_NOT_OK", - "MAIN_CH_TH_PROT_R", - "MAIN_CH_TH_PROT_F", - "VBUS_DET_F", + interrupt-names = "VBUS_DET_F", "VBUS_DET_R", "USB_LINK_STATUS", "USB_CH_TH_PROT_R",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 847/1756 arm64: dts: rockchip: Update CPU OPP voltages in RK356x SoC dtsi
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragan Simic <[email protected]>
[ Upstream commit 0e183fcc92b0eaa13b33b39846d86c3d65b8330a ]
Update the lower/upper voltage limits and the exact voltages for the Rockchip RK356x CPU OPPs, using the most conservative values (i.e. the highest per-OPP voltages) found in the vendor kernel source. [1]
Using the most conservative per-OPP voltages ensures reliable CPU operation regardless of the actual CPU binning, with the downside of possibly using a bit more power for the CPU cores than absolutely needed.
Additionally, fill in the missing "clock-latency-ns" CPU OPP properties, using the values found in the vendor kernel source. [1]
Related-to: eb665b1c06bc ("arm64: dts: rockchip: Update GPU OPP voltages in RK356x SoC dtsi")
Stable-dep-of: 8043ed0f40fe ("arm64: dts: rockchip: Rename rk3566 and rk3568 HDMI audio cards")
--- arch/arm64/boot/dts/rockchip/rk3568.dtsi | 1 + arch/arm64/boot/dts/rockchip/rk356x.dtsi | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3568.dtsi +1 -0
@@ -274,6 +274,7 @@ &cpu0_opp_table { opp-1992000000 { opp-hz = /bits/ 64 <1992000000>; opp-microvolt = <1150000 1150000 1150000>; + clock-latency-ns = <40000>; }; };
arch/arm64/boot/dts/rockchip/rk356x.dtsi +12 -6
@@ -134,39 +134,45 @@ cpu0_opp_table: opp-table-0 { opp-408000000 { opp-hz = /bits/ 64 <408000000>; - opp-microvolt = <900000 900000 1150000>; + opp-microvolt = <850000 850000 1150000>; clock-latency-ns = <40000>; }; opp-600000000 { opp-hz = /bits/ 64 <600000000>; - opp-microvolt = <900000 900000 1150000>; + opp-microvolt = <850000 850000 1150000>; + clock-latency-ns = <40000>; }; opp-816000000 { opp-hz = /bits/ 64 <816000000>; - opp-microvolt = <900000 900000 1150000>; + opp-microvolt = <850000 850000 1150000>; + clock-latency-ns = <40000>; opp-suspend; }; opp-1104000000 { opp-hz = /bits/ 64 <1104000000>; opp-microvolt = <900000 900000 1150000>; + clock-latency-ns = <40000>; }; opp-1416000000 { opp-hz = /bits/ 64 <1416000000>; - opp-microvolt = <900000 900000 1150000>; + opp-microvolt = <1025000 1025000 1150000>; + clock-latency-ns = <40000>; }; opp-1608000000 { opp-hz = /bits/ 64 <1608000000>; - opp-microvolt = <975000 975000 1150000>; + opp-microvolt = <1100000 1100000 1150000>; + clock-latency-ns = <40000>; }; opp-1800000000 { opp-hz = /bits/ 64 <1800000000>; - opp-microvolt = <1050000 1050000 1150000>; + opp-microvolt = <1150000 1150000 1150000>; + clock-latency-ns = <40000>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 848/1756 arm64: dts: rockchip: Prepare RK356x SoC dtsi files for per-variant OPPs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragan Simic <[email protected]>
[ Upstream commit 853f9632a17624e9264c68be5c9587f13d04be54 ]
Rename the Rockchip RK356x SoC dtsi files and, consequently, adjust their contents appropriately, to prepare them for the ability to specify different CPU and GPU OPPs for each of the supported RK356x SoC variants.
The first new RK356x SoC variant to be introduced is the RK3566T, which the Pine64 Quartz64 Zero SBC is officially based on. [1] Some other SBCs are also based on the RK3566T variant, including Radxa ROCK 3C and ZERO 3E/3W, but the slight trouble is that Radxa doesn't state that officially. Though, it's rather easy to spot the RK3566T on such boards, because their official specifications state that the maximum frequency for the Cortex-A55 cores is lower than the "full-fat" RK3566's 1.8 GHz. [2][3][4]
These changes follow the approach used for the Rockchip RK3588 SoC variants, which was introduced and described further in commit def88eb4d836 ("arm64:
dts: rockchip: Prepare RK3588 SoC dtsi files for per-variant OPPs"). Please see that commit for a more detailed explanation.
No functional changes are introduced, which was validated by decompiling and comparing all affected board dtb files before and after these changes. In more detail, the affected dtb files have some of their blocks shuffled around a bit and some of their phandles have different values, as a result of the changes to the order in which the building blocks from the parent dtsi files are included, but they effectively remain the same as the originals.
As a side note, due to the nature of introduced changes, this commit is a bit more readable when viewed using the --break-rewrites option for git-log(1).
[1] https://wiki.pine64.org/wiki/Quartz64
[2] https://dl.radxa.com/rock3/docs/hw/3c/radxa_rock3c_product_brief.pdf
[3] https://dl.radxa.com/zero3/docs/hw/3e/radxa_zero_3e_product_brief.pdf
[4] https://dl.radxa.com/zero3/docs/hw/3w/radxa_zero_3w_product_brief.pdf
Related-to: def88eb4d836 ("arm64: dts: rockchip: Prepare RK3588 SoC dtsi files for per-variant OPPs")
Stable-dep-of: 8043ed0f40fe ("arm64: dts: rockchip: Rename rk3566 and rk3568 HDMI audio cards")
---
arch/arm64/boot/dts/rockchip/rk3566-base.dtsi | 35 ++++++
arch/arm64/boot/dts/rockchip/rk3566.dtsi | 116 ++++++++++++++----
arch/arm64/boot/dts/rockchip/rk3568.dtsi | 114 +++++++++++++++--
.../{rk356x.dtsi => rk356x-base.dtsi} | 87 -------------
4 files changed, 236 insertions(+), 116 deletions(-)
create mode 100644 arch/arm64/boot/dts/rockchip/rk3566-base.dtsi
rename arch/arm64/boot/dts/rockchip/{rk356x.dtsi => rk356x-base.dtsi} (96%)arch/arm64/boot/dts/rockchip/rk3566-base.dtsi new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk356x-base.dtsi" + +/ { + compatible = "rockchip,rk3566"; +}; + +&pipegrf { + compatible = "rockchip,rk3566-pipe-grf", "syscon"; +}; + +&power { + power-domain@RK3568_PD_PIPE { + reg = <RK3568_PD_PIPE>; + clocks = <&cru PCLK_PIPE>; + pm_qos = <&qos_pcie2x1>, + <&qos_sata1>, + <&qos_sata2>, + <&qos_usb3_0>, + <&qos_usb3_1>; + #power-domain-cells = <0>; + }; +}; + +&usb_host0_xhci { + phys = <&usb2phy0_otg>; + phy-names = "usb2-phy"; + extcon = <&usb2phy0>; + maximum-speed = "high-speed"; +}; + +&vop { + compatible = "rockchip,rk3566-vop"; +};
arch/arm64/boot/dts/rockchip/rk3566.dtsi +94 -22
129 lines not on this page · raw message
arch/arm64/boot/dts/rockchip/rk3568.dtsi +107 -7
130 lines not on this page · raw message
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi renamed from arch/arm64/boot/dts/rockchip/rk356x.dtsi +0 -87
129 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 849/1756 arm64: dts: rockchip: Rename rk3566 and rk3568 HDMI audio cards
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit 8043ed0f40fe2b49df1c2c25409ab6bd3f88e806 ]
Move the HDMI audio card name for RK3566 and RK3568 to their corresponding dtsi files so the name can be set to match the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3566-base.dtsi | 4 ++++ arch/arm64/boot/dts/rockchip/rk3568.dtsi | 4 ++++ arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 1 - 3 files changed, 8 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3566-base.dtsi +4 -0
@@ -6,6 +6,10 @@ / { compatible = "rockchip,rk3566"; }; +&hdmi_sound { + simple-audio-card,name = "RK3566 HDMI"; +}; + &pipegrf { compatible = "rockchip,rk3566-pipe-grf", "syscon"; };
arch/arm64/boot/dts/rockchip/rk3568.dtsi +4 -0
@@ -378,6 +378,10 @@ &gpu { operating-points-v2 = <&gpu_opp_table>; }; +&hdmi_sound { + simple-audio-card,name = "RK3568 HDMI"; +}; + &pipegrf { compatible = "rockchip,rk3568-pipe-grf", "syscon"; };
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi +0 -1
@@ -146,7 +146,6 @@ scmi_clk: protocol@14 { hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; - simple-audio-card,name = "HDMI"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <256>; status = "disabled";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 850/1756 arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 23eab1a5e36099fd1269f8a18dc389e04dc19011 ]
The analog headphone jack on this board has never produced any sound with a mainline kernel.
GPIO4_C5 has to be high for audio to reach the jack. The board file muxes the pin to GPIO through the rt5640_hpcon pinctrl group and references that group from the codec node, but nothing ever requests or drives the line.
Describe it the way rk3399-roc-pc-plus.dts already does something similar, as a simple-audio-amplifier auxiliary component, so that DAPM asserts the GPIO while the headphone path is active.
Measured on a Firefly-RK3399 by toggling only this line while a 1 kHz tone kept playing, with the playback PCM in state: RUNNING throughout:
high -> audible, low -> silent, high -> audible
With this change the line is claimed and follows the audio path:
pin 149 (gpio4-21): headphones-amp gpio4:149
idle: gpio-21 (|enable) out lo
playing: gpio-21 (|enable) out hi
--- .../arm64/boot/dts/rockchip/rk3399-firefly.dts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +14 -4
@@ -96,6 +96,15 @@ key-power { }; }; + /* GPIO that enables the headphone output path */ + headphones_amp: headphones-amp { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio4 RK_PC5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&rt5640_hpcon>; + sound-name-prefix = "Headphone Amp"; + }; + ir-receiver { compatible = "gpio-ir-receiver"; gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
@@ -132,8 +141,11 @@ rt5640-sound { simple-audio-card,routing = "Mic Jack", "MICBIAS1", "IN1P", "Mic Jack", - "Headphone Jack", "HPOL", - "Headphone Jack", "HPOR"; + "Headphone Amp INL", "HPOL", + "Headphone Amp INR", "HPOR", + "Headphone Jack", "Headphone Amp OUTL", + "Headphone Jack", "Headphone Amp OUTR"; + simple-audio-card,aux-devs = <&headphones_amp>; simple-audio-card,cpu { sound-dai = <&i2s1>;
@@ -547,8 +559,6 @@ rt5640: rt5640@1c { clock-names = "mclk"; realtek,in1-differential; #sound-dai-cells = <0>; - pinctrl-names = "default"; - pinctrl-0 = <&rt5640_hpcon>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 851/1756 arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 9416a641cfe5b75dd9178c15960ee741c1091b45 ]
The board file enables i2s0, but no sound card references it: the on-board RT5640 is wired to i2s1 and the S/PDIF transmitter has its own controller. Keeping it enabled starves the other controllers, due to the pl330 instance that serves the audio block only having six channels.
The i2s0 pin groups also lists GPIO4_A0, which carries SCLK_I2S_8CH_OUT, providing the MCLK the codec runs on.
So add the pinmux for the MCLK signal to the i2s1 node.
The RT5640 and S/PDIF cards then register with no DMA errors, and a 1 kHz tone measured through the codec's internal HPOL/HPOR loopback is unchanged (L 2135 -> 2138, R 2202 -> 2203), confirming that MCLK still reaches the codec.
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +8 -6
@@ -628,13 +628,9 @@ accelerometer@68 { }; }; -&i2s0 { - rockchip,playback-channels = <8>; - rockchip,capture-channels = <8>; - status = "okay"; -}; - &i2s1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2s_8ch_mclk_pin>, <&i2s1_2ch_bus>; rockchip,playback-channels = <2>; rockchip,capture-channels = <2>; status = "okay";
@@ -689,6 +685,12 @@ ir_int: ir-int { }; }; + i2s1 { + i2s_8ch_mclk_pin: i2s-8ch-mclk-pin { + rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>; + }; + }; + lcd-panel { lcd_panel_reset: lcd-panel-reset { rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 852/1756 ASoC: mt6359-accdet: manage private workqueues with devres
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 9a773d9d21fa909e8babbe11e93c811cf1a6d22d ]
The threaded jack-detect interrupts queue work on two private workqueues. Neither queue is destroyed on device removal, so queued callbacks can retain pointers to devm-allocated state after it is released. Probe error paths also leak the queues.
Create and initialize both workqueues before requesting interrupts, then add a managed cleanup action. Since the managed IRQs are acquired afterwards, devres releases and synchronizes them before draining and destroying the workqueues on both removal and probe failure.
--- sound/soc/codecs/mt6359-accdet.c | 50 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-)
sound/soc/codecs/mt6359-accdet.c +28 -22
@@ -919,6 +919,14 @@ int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (mt6359_accdet_enable_jack_detect); +static void mt6359_accdet_destroy_workqueues (void *data) +{ +struct mt6359_accdet *priv = data; + +destroy_workqueue (priv->jd_workqueue); +destroy_workqueue (priv->accdet_workqueue); +} +static int mt6359_accdet_probe (struct platform_device *pdev) {struct mt6359_accdet *priv;
@@ -960,6 +968,26 @@ static int mt6359_accdet_probe(struct platform_device *pdev) }mutex_init (&priv->res_lock); + priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); +INIT_WORK (&priv->accdet_work, mt6359_accdet_work); +if (!priv->accdet_workqueue) { +dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); +return -ENOMEM ; + } + + priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); +INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); +if (!priv->jd_workqueue) { +dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); +destroy_workqueue (priv->accdet_workqueue); +return -ENOMEM ; + } + + ret =devm_add_action_or_reset (&pdev->dev, + mt6359_accdet_destroy_workqueues, priv); +if (ret) +return ret; + priv->accdet_irq =platform_get_irq (pdev,0 );if (priv->accdet_irq >=0 ) { ret = devm_request_threaded_irq(&pdev->dev, priv->accdet_irq,
@@ -1005,22 +1033,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev) } } - priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); -INIT_WORK (&priv->accdet_work, mt6359_accdet_work); -if (!priv->accdet_workqueue) { -dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); - ret =-1 ; - goto err_accdet_wq; - } - - priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); -INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); -if (!priv->jd_workqueue) { -dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); - ret =-1 ; - goto err_eint_wq; - } -platform_set_drvdata (pdev, priv); ret = devm_snd_soc_register_component(&pdev->dev, &mt6359_accdet_soc_driver,
@@ -1039,12 +1051,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev)mt6359_accdet_jack_report (priv);return 0 ; - -err_eint_wq: -destroy_workqueue (priv->accdet_workqueue); -err_accdet_wq: -dev_err (&pdev->dev,"%s error. now exit.!\n" , __func__); -return ret; }static struct platform_driver mt6359_accdet_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 853/1756 perf/marvell: cn10k_tad: Publish the OF module alias
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit 848468c86f716e4552bd478d2f3c3f5d81bec7ac ]
The TAD PMU platform driver has ACPI and OF match tables, but only the ACPI table is published. A Device Tree platform device emits an OF modalias, so the ACPI alias does not select this module for it.
Publish the OF table inside CONFIG_OF and retain ACPI support.
--- drivers/perf/marvell_cn10k_tad_pmu.c | 1 + 1 file changed, 1 insertion(+)
drivers/perf/marvell_cn10k_tad_pmu.c +1 -0
@@ -365,6 +365,7 @@ static const struct of_device_id tad_pmu_of_match[] = { { .compatible = "marvell,cn10k-tad-pmu", }, {}, }; +MODULE_DEVICE_TABLE (of, tad_pmu_of_match);#endif #ifdef CONFIG_ACPI
Signature · 1 line
2.53.0