kconfig: merge_config: use an empty file as initfile
Subsystems (82)
Sasha Levin
maintainerPATCH 617/642 drm/xe: Add locks in gtidle code
In reply to Sasha LevinFrom: Vinay Belgaumkar <[email protected]>
[ Upstream commit d160dc6f53914d729be7fcb7afbd0e9e6a3725b2 ]
The update of the residency values needs to be protected by a lock to avoid multiple entrypoints, for example when multiple userspace clients read the sysfs file. Other in-kernel clients are going to be added to sample these values, making the problem worse. Protect those updates with a raw_spinlock so it can be called by future integration with perf pmu.
--- drivers/gpu/drm/xe/xe_gt_idle.c | 23 ++++++++++++++++++++--- drivers/gpu/drm/xe/xe_gt_idle.h | 1 + drivers/gpu/drm/xe/xe_gt_idle_types.h | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_gt_idle.c +20 -3
@@ -69,6 +69,8 @@ static u64 get_residency_ms(struct xe_gt_idle *gtidle, u64 cur_residency) {u64 delta, overflow_residency, prev_residency; +lockdep_assert_held (>idle->lock); + overflow_residency =BIT_ULL (32 );/*
@@ -275,8 +277,21 @@ static ssize_t idle_status_show(struct device *dev,return sysfs_emit (buff,"%s\n" ,gt_idle_state_to_string (state)); } -static DEVICE_ATTR_RO (idle_status); +u64 xe_gt_idle_residency_msec (struct xe_gt_idle *gtidle) +{ +struct xe_guc_pc *pc =gtidle_to_pc (gtidle); +u64 residency; +unsigned long flags; + +raw_spin_lock_irqsave (>idle->lock, flags); + residency =get_residency_ms (gtidle, gtidle->idle_residency (pc)); +raw_spin_unlock_irqrestore (>idle->lock, flags); + +return residency; +} + +static DEVICE_ATTR_RO (idle_status);static ssize_t idle_residency_ms_show (struct device *dev,struct device_attribute *attr,char *buff) {
@@ -285,10 +300,10 @@ static ssize_t idle_residency_ms_show(struct device *dev,u64 residency;xe_pm_runtime_get (pc_to_xe (pc)); - residency = gtidle->idle_residency (pc); + residency =xe_gt_idle_residency_msec (gtidle);xe_pm_runtime_put (pc_to_xe (pc)); -return sysfs_emit (buff,"%llu\n" ,get_residency_ms (gtidle, residency)); +return sysfs_emit (buff,"%llu\n" , residency); }static DEVICE_ATTR_RO (idle_residency_ms);
@@ -331,6 +346,8 @@ int xe_gt_idle_init(struct xe_gt_idle *gtidle)if (!kobj)return -ENOMEM ; +raw_spin_lock_init (>idle->lock); +if (xe_gt_is_media_type (gt)) {snprintf (gtidle->name,sizeof (gtidle->name),"gt%d-mc" , gt->info.id); gtidle->idle_residency = xe_guc_pc_mc6_residency;
drivers/gpu/drm/xe/xe_gt_idle.h +1 -0
@@ -17,5 +17,6 @@ void xe_gt_idle_disable_c6(struct xe_gt *gt);void xe_gt_idle_enable_pg (struct xe_gt *gt);void xe_gt_idle_disable_pg (struct xe_gt *gt);int xe_gt_idle_pg_print (struct xe_gt *gt,struct drm_printer *p); +u64 xe_gt_idle_residency_msec (struct xe_gt_idle *gtidle);#endif /* _XE_GT_IDLE_H_ */
drivers/gpu/drm/xe/xe_gt_idle_types.h +3 -0
@@ -6,6 +6,7 @@#ifndef _XE_GT_IDLE_SYSFS_TYPES_H_#define _XE_GT_IDLE_SYSFS_TYPES_H_ +#include <linux/spinlock.h> #include <linux/types.h> struct xe_guc_pc ;
@@ -31,6 +32,8 @@ struct xe_gt_idle {u64 cur_residency;/** @prev_residency: previous residency counter */ u64 prev_residency; +/** @lock: Lock protecting idle residency counters */ +raw_spinlock_t lock;/** @idle_status: get the current idle state */ enum xe_gt_idle_state (*idle_status)(struct xe_guc_pc *pc);/** @idle_residency: get idle residency counter */
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 618/642 drm/panel-edp: Add Starry 116KHD024006
In reply to Sasha LevinFrom: Douglas Anderson <[email protected]>
[ Upstream commit 749b5b279e5636cdcef51e15d67b77162cca6caa ]
We have a few reports of sc7180-trogdor-pompom devices that have a panel in them that IDs as STA 0x0004 and has the following raw EDID:
00 ff ff ff ff ff ff 00 4e 81 04 00 00 00 00 00 10 20 01 04 a5 1a 0e 78 0a dc dd 96 5b 5b 91 28 1f 52 54 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 8e 1c 56 a0 50 00 1e 30 28 20 55 00 00 90 10 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fe 00 31 31 36 4b 48 44 30 32 34 30 30 36 0a 00 e6
We've been unable to locate a datasheet for this panel and our partner has not been responsive, but all Starry eDP datasheets that we can find agree on the same timing (delay_100_500_e200) so it should be safe to use that here instead of the super conservative timings. We'll still go a little extra conservative and allow hpd_absent of 200 instead of 100 because that won't add any real-world delay in most cases.
We'll associate the string from the EDID ("116KHD024006") with this panel. Given that the ID is the suspicious value of 0x0004 it seems likely that Starry doesn't always update their IDs but the string will still work to differentiate if we ever need to in the future.
--- drivers/gpu/drm/panel/panel-edp.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-edp.c +1 -0
@@ -1993,6 +1993,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('S' ,'H' ,'P' ,0x154c , &delay_200_500_p2e100,"LQ116M1JW10" ),EDP_PANEL_ENTRY ('S' ,'H' ,'P' ,0x1593 , &delay_200_500_p2e100,"LQ134N1" ), +EDP_PANEL_ENTRY ('S' ,'T' ,'A' ,0x0004 , &delay_200_500_e200,"116KHD024006" ), EDP_PANEL_ENTRY('S', 'T', 'A', 0x0100, &delay_100_500_e200, "2081116HHD028001-51D"), { /* sentinal */ }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 619/642 accel/ivpu: Dump only first MMU fault from single context
In reply to Sasha LevinFrom: Karol Wachowski <[email protected]>
[ Upstream commit 0240fa18d247c99a1967f2fed025296a89a1c5f5 ]
Stop dumping consecutive faults from an already faulty context immediately, instead of waiting for the context abort thread handler (IRQ handler bottom half) to abort currently executing jobs.
Remove 'R' (record events) bit from context descriptor of a faulty context to prevent future faults generation.
This change speeds up the IRQ handler by eliminating the need to print the fault content repeatedly. Additionally, it prevents flooding dmesg with errors, which was occurring due to the delay in the bottom half of the handler stopping fault-generating jobs.
--- drivers/accel/ivpu/ivpu_mmu.c | 51 ++++++++++++++++++++++++--- drivers/accel/ivpu/ivpu_mmu_context.c | 13 ------- drivers/accel/ivpu/ivpu_mmu_context.h | 2 -- 3 files changed, 46 insertions(+), 20 deletions(-)
drivers/accel/ivpu/ivpu_mmu.c +46 -5
@@ -870,23 +870,64 @@ static u32 *ivpu_mmu_get_event(struct ivpu_device *vdev)return evt; } +static int ivpu_mmu_disable_events (struct ivpu_device *vdev,u32 ssid) +{ +struct ivpu_mmu_info *mmu = vdev->mmu; +struct ivpu_mmu_cdtab *cdtab = &mmu->cdtab; +u64 *entry; +u64 val; + +if (ssid >IVPU_MMU_CDTAB_ENT_COUNT ) +return -EINVAL ; + + entry = cdtab->base + (ssid *IVPU_MMU_CDTAB_ENT_SIZE ); + + val =READ_ONCE (entry[0 ]); + val &= ~IVPU_MMU_CD_0_R ; +WRITE_ONCE (entry[0 ], val); + +if (!ivpu_is_force_snoop_enabled (vdev)) +clflush_cache_range (entry,IVPU_MMU_CDTAB_ENT_SIZE ); + +ivpu_mmu_cmdq_write_cfgi_all (vdev); + +return 0 ; +} +void ivpu_mmu_irq_evtq_handler (struct ivpu_device *vdev) { +struct ivpu_file_priv *file_priv; +u32 last_ssid =-1 ;u32 *event;u32 ssid;ivpu_dbg (vdev,IRQ ,"MMU event queue\n" ); -while ((event =ivpu_mmu_get_event (vdev)) !=NULL ) { -ivpu_mmu_dump_event (vdev, event); - +while ((event =ivpu_mmu_get_event (vdev))) { ssid =FIELD_GET (IVPU_MMU_EVT_SSID_MASK , event[0 ]); + +if (ssid == last_ssid) +continue ; + +xa_lock (&vdev->context_xa); + file_priv =xa_load (&vdev->context_xa, ssid); +if (file_priv) { +if (file_priv->has_mmu_faults) { + event =NULL ; + }else { +ivpu_mmu_disable_events (vdev, ssid); + file_priv->has_mmu_faults = true; + } + } +xa_unlock (&vdev->context_xa); + +if (event) +ivpu_mmu_dump_event (vdev, event); +if (ssid ==IVPU_GLOBAL_CONTEXT_MMU_SSID ) {ivpu_pm_trigger_recovery (vdev,"MMU event" );return ; } - -ivpu_mmu_user_context_mark_invalid (vdev, ssid);REGV_WR32 (IVPU_MMU_REG_EVTQ_CONS_SEC , vdev->mmu->evtq.cons); }
drivers/accel/ivpu/ivpu_mmu_context.c +0 -13
@@ -635,16 +635,3 @@ void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev)ivpu_mmu_cd_clear (vdev, vdev->rctx.id);ivpu_mmu_context_fini (vdev, &vdev->rctx); } - -void ivpu_mmu_user_context_mark_invalid (struct ivpu_device *vdev,u32 ssid) -{ -struct ivpu_file_priv *file_priv; - -xa_lock (&vdev->context_xa); - - file_priv =xa_load (&vdev->context_xa, ssid); -if (file_priv) - file_priv->has_mmu_faults = true; - -xa_unlock (&vdev->context_xa); -}
drivers/accel/ivpu/ivpu_mmu_context.h +0 -2
@@ -37,8 +37,6 @@ void ivpu_mmu_global_context_fini(struct ivpu_device *vdev);int ivpu_mmu_reserved_context_init (struct ivpu_device *vdev);void ivpu_mmu_reserved_context_fini (struct ivpu_device *vdev); -void ivpu_mmu_user_context_mark_invalid (struct ivpu_device *vdev,u32 ssid); -int ivpu_mmu_context_insert_node (struct ivpu_mmu_context *ctx,const struct ivpu_addr_range *range,u64 size,struct drm_mm_node *node);void ivpu_mmu_context_remove_node (struct ivpu_mmu_context *ctx,struct drm_mm_node *node);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 620/642 accel/ivpu: Separate DB ID and CMDQ ID allocations from CMDQ allocation
In reply to Sasha LevinFrom: Karol Wachowski <[email protected]>
[ Upstream commit 950942b4813f8c44dbec683fdb140cf4a238516b ]
Move doorbell ID and command queue ID XArray allocations from command queue memory allocation function. This will allow ID allocations to be done without the need for actual memory allocation.
--- drivers/accel/ivpu/ivpu_job.c | 88 +++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 24 deletions(-)
drivers/accel/ivpu/ivpu_job.c +64 -24
@@ -83,23 +83,9 @@ static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv)if (!cmdq)return NULL ; - ret =xa_alloc_cyclic (&vdev->db_xa, &cmdq->db_id,NULL , vdev->db_limit, &vdev->db_next, -GFP_KERNEL ); -if (ret <0 ) { -ivpu_err (vdev,"Failed to allocate doorbell id: %d\n" , ret); - goto err_free_cmdq; - } - - ret =xa_alloc_cyclic (&file_priv->cmdq_xa, &cmdq->id, cmdq, file_priv->cmdq_limit, - &file_priv->cmdq_id_next,GFP_KERNEL ); -if (ret <0 ) { -ivpu_err (vdev,"Failed to allocate command queue id: %d\n" , ret); - goto err_erase_db_xa; - } - cmdq->mem =ivpu_bo_create_global (vdev,SZ_4K ,DRM_IVPU_BO_WC |DRM_IVPU_BO_MAPPABLE );if (!cmdq->mem) - goto err_erase_cmdq_xa; + goto err_free_cmdq; ret =ivpu_preemption_buffers_create (vdev, file_priv, cmdq);if (ret)
@@ -107,10 +93,6 @@ static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv)return cmdq; -err_erase_cmdq_xa: -xa_erase (&file_priv->cmdq_xa, cmdq->id); -err_erase_db_xa: -xa_erase (&vdev->db_xa, cmdq->db_id); err_free_cmdq:kfree (cmdq);return NULL ;
@@ -233,30 +215,88 @@ static int ivpu_cmdq_fini(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmreturn 0 ; } +static int ivpu_db_id_alloc (struct ivpu_device *vdev,u32 *db_id) +{ +int ret; +u32 id; + + ret =xa_alloc_cyclic (&vdev->db_xa, &id,NULL , vdev->db_limit, &vdev->db_next,GFP_KERNEL ); +if (ret <0 ) +return ret; + + *db_id = id; +return 0 ; +} + +static int ivpu_cmdq_id_alloc (struct ivpu_file_priv *file_priv,u32 *cmdq_id) +{ +int ret; +u32 id; + + ret =xa_alloc_cyclic (&file_priv->cmdq_xa, &id,NULL , file_priv->cmdq_limit, + &file_priv->cmdq_id_next,GFP_KERNEL ); +if (ret <0 ) +return ret; + + *cmdq_id = id; +return 0 ; +} +static struct ivpu_cmdq *ivpu_cmdq_acquire (struct ivpu_file_priv *file_priv,u8 priority) { +struct ivpu_device *vdev = file_priv->vdev;struct ivpu_cmdq *cmdq; -unsigned long cmdq_id; +unsigned long id;int ret;lockdep_assert_held (&file_priv->lock); -xa_for_each (&file_priv->cmdq_xa, cmdq_id, cmdq) +xa_for_each (&file_priv->cmdq_xa, id, cmdq)if (cmdq->priority == priority)break ;if (!cmdq) { cmdq =ivpu_cmdq_alloc (file_priv); -if (!cmdq) +if (!cmdq) { +ivpu_err (vdev,"Failed to allocate command queue\n" );return NULL ; + } + + ret =ivpu_db_id_alloc (vdev, &cmdq->db_id); +if (ret) { +ivpu_err (file_priv->vdev,"Failed to allocate doorbell ID: %d\n" , ret); + goto err_free_cmdq; + } + + ret =ivpu_cmdq_id_alloc (file_priv, &cmdq->id); +if (ret) { +ivpu_err (vdev,"Failed to allocate command queue ID: %d\n" , ret); + goto err_erase_db_id; + } + cmdq->priority = priority; + ret =xa_err (xa_store (&file_priv->cmdq_xa, cmdq->id, cmdq,GFP_KERNEL )); +if (ret) { +ivpu_err (vdev,"Failed to store command queue in cmdq_xa: %d\n" , ret); + goto err_erase_cmdq_id; + } } ret =ivpu_cmdq_init (file_priv, cmdq, priority); -if (ret) -return NULL ; +if (ret) { +ivpu_err (vdev,"Failed to initialize command queue: %d\n" , ret); + goto err_free_cmdq; + }return cmdq; + +err_erase_cmdq_id: +xa_erase (&file_priv->cmdq_xa, cmdq->id); +err_erase_db_id: +xa_erase (&vdev->db_xa, cmdq->db_id); +err_free_cmdq: +ivpu_cmdq_free (file_priv, cmdq); +return NULL ; }void ivpu_cmdq_release_all_locked (struct ivpu_file_priv *file_priv)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 621/642 drm: Add valid clones check
In reply to Sasha LevinFrom: Jessica Zhang <[email protected]>
[ Upstream commit 41b4b11da02157c7474caf41d56baae0e941d01a ]
Check that all encoders attached to a given CRTC are valid possible_clones of each other.
--- drivers/gpu/drm/drm_atomic_helper.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +28 -0
@@ -574,6 +574,30 @@ mode_valid(struct drm_atomic_state *state)return 0 ; } +static int drm_atomic_check_valid_clones (struct drm_atomic_state *state, +struct drm_crtc *crtc) +{ +struct drm_encoder *drm_enc; +struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, + crtc); + +drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) { +if (!drm_enc->possible_clones) { +DRM_DEBUG ("enc%d possible_clones is 0\n" , drm_enc->base.id); +continue ; + } + +if ((crtc_state->encoder_mask & drm_enc->possible_clones) != + crtc_state->encoder_mask) { +DRM_DEBUG ("crtc%d failed valid clone check for mask 0x%x\n" , + crtc->base.id, crtc_state->encoder_mask); +return -EINVAL ; + } + } + +return 0 ; +} +/** * drm_atomic_helper_check_modeset - validate state object for modeset changes * @dev: DRM device
@@ -745,6 +769,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, ret =drm_atomic_add_affected_planes (state, crtc);if (ret !=0 )return ret; + + ret =drm_atomic_check_valid_clones (state, crtc); +if (ret !=0 ) +return ret; }/*
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 622/642 i3c: master: svc: Fix implicit fallthrough in svc_i3c_master_ibi_work()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e8d2d287e26d9bd9114cf258a123a6b70812442e ]
Clang warns (or errors with CONFIG_WERROR=y):
drivers/i3c/master/svc-i3c-master.c:596:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
596 | default:
| ^
drivers/i3c/master/svc-i3c-master.c:596:2: note: insert 'break;' to avoid fall-through
596 | default:
| ^
| break;1 error generated.
Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -552,6 +552,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)break ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :svc_i3c_master_emit_stop (master); +break ;default :break ; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 623/642 ASoC: sma1307: Fix error handling in sma1307_setting_loaded()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 012a6efcc805308b1d90a1056ba963eb08858645 ]
There are a couple bugs in this code:
1) The cleanup code calls kfree(sma1307->set.header) and kfree(sma1307->set.def) but those functions were allocated using devm_kzalloc(). It results in a double free. Delete all these kfree() calls.
2) A missing call to kfree(data) if the checksum was wrong on this error path:
if ((sma1307->set.checksum >> 8) != SMA1307_SETTING_CHECKSUM) { Since the "data" pointer is supposed to be freed on every return, I changed that to use the __free(kfree) cleanup attribute.
--- sound/soc/codecs/sma1307.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
sound/soc/codecs/sma1307.c +2 -9
@@ -1710,7 +1710,7 @@ static void sma1307_check_fault_worker(struct work_struct *work)static void sma1307_setting_loaded (struct sma1307_priv *sma1307,const char *file) {const struct firmware *fw; -int *data, size, offset, num_mode; +int size, offset, num_mode;int ret; ret =request_firmware (&fw, file, sma1307->dev);
@@ -1727,7 +1727,7 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *filreturn ; } - data =kzalloc (fw->size,GFP_KERNEL ); + int *data __free(kfree) = kzalloc(fw->size, GFP_KERNEL);if (!data) {release_firmware (fw); sma1307->set.status = false;
@@ -1747,7 +1747,6 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil sma1307->set.header_size, GFP_KERNEL);if (!sma1307->set.header) { -kfree (data); sma1307->set.status = false;return ; }
@@ -1768,8 +1767,6 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil = devm_kzalloc(sma1307->dev, sma1307->set.def_size *sizeof (int ),GFP_KERNEL );if (!sma1307->set.def) { -kfree (data); -kfree (sma1307->set.header); sma1307->set.status = false;return ; }
@@ -1787,9 +1784,6 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil sma1307->set.mode_size *2 *sizeof (int ), GFP_KERNEL);if (!sma1307->set.mode_set[i]) { -kfree (data); -kfree (sma1307->set.header); -kfree (sma1307->set.def);for (int j =0 ; j < i; j++)kfree (sma1307->set.mode_set[j]); sma1307->set.status = false;
@@ -1804,7 +1798,6 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil } } -kfree (data); sma1307->set.status = true; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 624/642 can: fix missing decrement of j1939_proto.inuse_idx
In reply to Sasha LevinFrom: Davide Caratti <[email protected]>
[ Upstream commit 8b1879491472c145c58c3cbbaf0e05ea93ee5ddf ]
Like other protocols on top of AF_CAN family, also j1939_proto.inuse_idx needs to be decremented on socket dismantle.
--- net/can/j1939/socket.c | 1 + 1 file changed, 1 insertion(+)
net/can/j1939/socket.c +1 -0
@@ -655,6 +655,7 @@ static int j1939_sk_release(struct socket *sock) sock->sk =NULL ;release_sock (sk); +sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 );sock_put (sk);return 0 ;
Signature · 1 line
2.39.5
Re: [PATCH AUTOSEL 6.14 624/642] can: fix missing decrement of j1939_proto.inuse_idx
Hi Sasha,
this fix is needed for this commit
6bffe88452db ("can: add protocol counter for AF_CAN sockets")
which has been introduced in 6.15
It must not be applied to 6.14-stable.
Best regards,
Oliver
Quoted 31 lines · Sasha Levin
From: Davide Caratti <[email protected]>
[ Upstream commit
8b1879491472c145c58c3cbbaf0e05ea93ee5ddf]Like other protocols on top of
AF_CANfamily, also j1939_proto.inuse_idx needs to be decremented on socket dismantle.Fixes 6bffe88452db ("can: add protocol counter for AF_CAN sockets")Reported-by Oliver Hartkopp <[email protected]>Signed-off-by Davide Caratti <[email protected]>Acked-by Oleksij Rempel <[email protected]>Link https://patch.msgid.link/09ce71f281b9e27d1e3d1104430bf3fceb8c7321.1742292636.git.dcaratti@redhat.com open hereSigned-off-by Marc Kleine-Budde <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- net/can/j1939/socket.c | 1 + 1 file changed, 1 insertion(+)net/can/j1939/socket.c +1
-0@@ -655,6 +655,7 @@ static int j1939_sk_release(struct socket *sock) sock->sk =NULL ;release_sock (sk); +sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 );sock_put (sk);return 0 ;
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.14 624/642] can: fix missing decrement of j1939_proto.inuse_idx
Quoted 11 lines · Oliver Hartkopp
Hi Sasha,
this fix is needed for this commit
6bffe88452db("can: add protocol counter forAF_CANsockets")which has been introduced in 6.15
It must not be applied to 6.14-stable.
I'll drop it, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 625/642 pinctrl: tegra: Fix off by one in tegra_pinctrl_get_group()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 5a062c3c3b82004766bc3ece82b594d337076152 ]
This should be >= pmx->soc->ngroups instead of > to avoid an out of bounds access. The pmx->soc->groups[] array is allocated in tegra_pinctrl_probe().
--- drivers/pinctrl/tegra/pinctrl-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +1 -1
@@ -305,7 +305,7 @@ static const struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev * {struct tegra_pmx *pmx =pinctrl_dev_get_drvdata (pctldev); -if (group_index <0 || group_index > pmx->soc->ngroups) +if (group_index <0 || group_index >= pmx->soc->ngroups)return NULL ;return &pmx->soc->groups[group_index];
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 626/642 watchdog: aspeed: fix 64-bit division
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 48a136639ec233614a61653e19f559977d5da2b5 ]
On 32-bit architectures, the new calculation causes a build failure:
ld.lld-21: error: undefined symbol: __aeabi_uldivmod
Since neither value is ever larger than a register, cast both sides into a uintptr_t.
--- drivers/watchdog/aspeed_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/aspeed_wdt.c +1 -1
@@ -254,7 +254,7 @@ static void aspeed_wdt_update_bootstatus(struct platform_device *pdev,if (!of_device_is_compatible (pdev->dev.of_node,"aspeed,ast2400-wdt" )) { res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - idx = ((intptr_t )wdt->base &0x00000fff ) /resource_size (res); + idx = ((intptr_t )wdt->base &0x00000fff ) / (uintptr_t )resource_size (res); } scu_base =syscon_regmap_lookup_by_compatible (scu.compatible);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 627/642 drm/amdkfd: Correct F8_MODE for gfx950
In reply to Sasha LevinFrom: Amber Lin <[email protected]>
[ Upstream commit 0c7e053448945e5a4379dc4396c762d7422b11ca ]
Correct F8_MODE setting for gfx950 that was removed
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c +1 -2
@@ -69,8 +69,7 @@ static bool set_cache_memory_policy_v9(struct device_queue_manager *dqm, qpd->sh_mem_config |=1 <<SH_MEM_CONFIG__RETRY_DISABLE__SHIFT ;if (KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,3 ) || -KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,4 ) || -KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,5 ,0 )) +KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,4 )) qpd->sh_mem_config |= (1 <<SH_MEM_CONFIG__F8_MODE__SHIFT ); qpd->sh_mem_ape1_limit =0 ;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 628/642 drm/gem: Internally test import_attach for imported objects
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 8260731ccad0451207b45844bb66eb161a209218 ]
Test struct drm_gem_object.import_attach to detect imported objects.
During object clenanup, the dma_buf field might be NULL. Testing it in an object's free callback then incorrectly does a cleanup as for native objects. Happens for calls to drm_mode_destroy_dumb_ioctl() that clears the dma_buf field in drm_gem_object_exported_dma_buf_free().
v3:
- only test for import_attach (Boris)
v2:
- use import_attach.dmabuf instead of dma_buf (Christian)
--- include/drm/drm_gem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/drm/drm_gem.h +1 -2
@@ -585,8 +585,7 @@ static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_obje*/ static inline bool drm_gem_is_imported (const struct drm_gem_object *obj) { -/* The dma-buf's priv field points to the original GEM object. */ -return obj->dma_buf && (obj->dma_buf->priv != obj); +return !!obj->import_attach; }#ifdef CONFIG_LOCKDEP
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 629/642 virtgpu: don't reset on shutdown
In reply to Sasha LevinFrom: "Michael S. Tsirkin" <[email protected]>
[ Upstream commit 183a08715af1491d381b4e22efd61578fbe05fa5 ]
It looks like GPUs are used after shutdown is invoked.
Thus, breaking virtio gpu in the shutdown callback is not a good idea - guest hangs attempting to finish console drawing, with these warnings:
[ 20.504464] WARNING: CPU: 0 PID: 568 at drivers/gpu/drm/virtio/virtgpu_vq.c:358 virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu] [ 20.505685] Modules linked in: nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 rfkill ip_set nf_tables nfnetlink vfat fat intel_rapl_msr intel_rapl_common intel_uncore_frequency_common nfit libnvdimm kvm_intel kvm rapl iTCO_wdt iTCO_vendor_support virtio_gpu virtio_dma_buf pcspkr drm_shmem_helper i2c_i801 drm_kms_helper lpc_ich i2c_smbus virtio_balloon joydev drm fuse xfs libcrc32c ahci libahci crct10dif_pclmul crc32_pclmul crc32c_intel libata virtio_net ghash_clmulni_intel net_failover virtio_blk failover serio_raw dm_mirror dm_region_hash dm_log dm_mod [ 20.511847] CPU: 0 PID: 568 Comm: kworker/0:3 Kdump: loaded Tainted: G W ------- --- 5.14.0-578.6675_1757216455.el9.x86_64 #1 [ 20.513157] Hardware name: Red Hat KVM/RHEL, BIOS edk2-20241117-3.el9 11/17/2024 [ 20.513918] Workqueue: events drm_fb_helper_damage_work [drm_kms_helper] [ 20.514626] RIP: 0010:virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu] [ 20.515332] Code: 00 00 48 85 c0 74 0c 48 8b 78 08 48 89 ee e8 51 50 00 00 65 ff 0d 42 e3 74 3f 0f 85 69 ff ff ff 0f 1f 44 00 00 e9 5f ff ff ff <0f> 0b e9 3f ff ff ff 48 83 3c 24 00 74 0e 49 8b 7f 40 48 85 ff 74 [ 20.517272] RSP: 0018:ff34f0a8c0787ad8 EFLAGS: 00010282 [ 20.517820] RAX: 00000000fffffffb RBX: 0000000000000000 RCX: 0000000000000820 [ 20.518565] RDX: 0000000000000000 RSI: ff34f0a8c0787be0 RDI: ff218bef03a26300 [ 20.519308] RBP: ff218bef03a26300 R08: 0000000000000001 R09: ff218bef07224360 [ 20.520059] R10: 0000000000008dc0 R11: 0000000000000002 R12: ff218bef02630028 [ 20.520806] R13: ff218bef0263fb48 R14: ff218bef00cb8000 R15: ff218bef07224360 [ 20.521555] FS: 0000000000000000(0000) GS:ff218bef7ba00000(0000) knlGS:0000000000000000 [ 20.522397] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 20.522996] CR2: 000055ac4f7871c0 CR3: 000000010b9f2002 CR4: 0000000000771ef0 [ 20.523740] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 20.524477] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400 [ 20.525223] PKRU: 55555554 [ 20.525515] Call Trace: [ 20.525777] <TASK> [ 20.526003] ? show_trace_log_lvl+0x1c4/0x2df [ 20.526464] ? show_trace_log_lvl+0x1c4/0x2df [ 20.526925] ? virtio_gpu_queue_fenced_ctrl_buffer+0x82/0x2c0 [virtio_gpu] [ 20.527643] ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu] [ 20.528282] ? __warn+0x7e/0xd0 [ 20.528621] ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu] [ 20.529256] ? report_bug+0x100/0x140 [ 20.529643] ? handle_bug+0x3c/0x70 [ 20.530010] ? exc_invalid_op+0x14/0x70 [ 20.530421] ? asm_exc_invalid_op+0x16/0x20 [ 20.530862] ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu] [ 20.531506] ? virtio_gpu_queue_ctrl_sgs+0x174/0x290 [virtio_gpu] [ 20.532148] virtio_gpu_queue_fenced_ctrl_buffer+0x82/0x2c0 [virtio_gpu] [ 20.532843] virtio_gpu_primary_plane_update+0x3e2/0x460 [virtio_gpu] [ 20.533520] drm_atomic_helper_commit_planes+0x108/0x320 [drm_kms_helper] [ 20.534233] drm_atomic_helper_commit_tail+0x45/0x80 [drm_kms_helper] [ 20.534914] commit_tail+0xd2/0x130 [drm_kms_helper] [ 20.535446] drm_atomic_helper_commit+0x11b/0x140 [drm_kms_helper] [ 20.536097] drm_atomic_commit+0xa4/0xe0 [drm] [ 20.536588] ? __pfx___drm_printfn_info+0x10/0x10 [drm] [ 20.537162] drm_atomic_helper_dirtyfb+0x192/0x270 [drm_kms_helper] [ 20.537823] drm_fbdev_shmem_helper_fb_dirty+0x43/0xa0 [drm_shmem_helper] [ 20.538536] drm_fb_helper_damage_work+0x87/0x160 [drm_kms_helper] [ 20.539188] process_one_work+0x194/0x380 [ 20.539612] worker_thread+0x2fe/0x410 [ 20.540007] ? __pfx_worker_thread+0x10/0x10 [ 20.540456] kthread+0xdd/0x100 [ 20.540791] ? __pfx_kthread+0x10/0x10 [ 20.541190] ret_from_fork+0x29/0x50 [ 20.541566] </TASK> [ 20.541802] ---[ end trace 0000000000000000 ]---
It looks like the shutdown is called in the middle of console drawing, so we should either wait for it to finish, or let drm handle the shutdown.
This patch implements this second option:
Add an option for drivers to bypass the common break+reset handling. As DRM is careful to flush/synchronize outstanding buffers, it looks like GPU can just have a NOP there.
Message-Id: <8490dbeb6f79ed039e6c11d121002618972538a3.1744293540.git.mst@redhat.com>
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 9 +++++++++ drivers/virtio/virtio.c | 6 ++++++ include/linux/virtio.h | 3 +++ 3 files changed, 18 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.c +9 -0
@@ -125,6 +125,14 @@ static void virtio_gpu_remove(struct virtio_device *vdev)drm_dev_put (dev); } +static void virtio_gpu_shutdown (struct virtio_device *vdev) +{ +/* +* drm does its own synchronization on shutdown. +* Do nothing here, opt out of device reset. +*/ +} +static void virtio_gpu_config_changed (struct virtio_device *vdev) {struct drm_device *dev = vdev->priv;
@@ -159,6 +167,7 @@ static struct virtio_driver virtio_gpu_driver = { .id_table = id_table, .probe = virtio_gpu_probe, .remove = virtio_gpu_remove, + .shutdown = virtio_gpu_shutdown, .config_changed = virtio_gpu_config_changed };
drivers/virtio/virtio.c +6 -0
@@ -407,6 +407,12 @@ static void virtio_dev_shutdown(struct device *_d)if (!drv)return ; +/* If the driver has its own shutdown method, use that. */ +if (drv->shutdown) { + drv->shutdown (dev); +return ; + } +/* * Some devices get wedged if you kick them after they are * reset. Mark all vqs as broken to make sure we don't.
include/linux/virtio.h +3 -0
@@ -220,6 +220,8 @@ size_t virtio_max_dma_size(const struct virtio_device *vdev);* occurs. * @reset_done: optional function to call after transport specific reset * operation has finished. +* @shutdown: synchronize with the device on shutdown. If provided, replaces +* the virtio core implementation. */ struct virtio_driver {struct device_driver driver;
@@ -237,6 +239,7 @@ struct virtio_driver {int (*restore)(struct virtio_device *dev);int (*reset_prepare)(struct virtio_device *dev);int (*reset_done)(struct virtio_device *dev); +void (*shutdown)(struct virtio_device *dev); };#define drv_to_virtio (__drv) container_of_const(__drv, struct virtio_driver, driver)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 630/642 x86/mm/init: Handle the special case of device private pages in add_pages(), to not increase max_pfn and trigger dma_addressing_limited() bounce buffers
In reply to Sasha LevinFrom: Balbir Singh <[email protected]>
[ Upstream commit 7170130e4c72ce0caa0cb42a1627c635cc262821 ]
As Bert Karwatzki reported, the following recent commit causes a performance regression on AMD iGPU and dGPU systems:
7ffb791423c7 ("x86/kaslr: Reduce KASLR entropy on most x86 systems")
It exposed a bug with nokaslr and zone device interaction.
The root cause of the bug is that, the GPU driver registers a zone device private memory region. When KASLR is disabled or the above commit is applied, the direct_map_physmem_end is set to much higher than 10 TiB typically to the 64TiB address. When zone device private memory is added to the system via add_pages(), it bumps up the max_pfn to the same value. This causes dma_addressing_limited() to return true, since the device cannot address memory all the way up to max_pfn.
This caused a regression for games played on the iGPU, as it resulted in the DMA32 zone being used for GPU allocations.
Fix this by not bumping up max_pfn on x86 systems, when pgmap is passed into add_pages(). The presence of pgmap is used to determine if device private memory is being added via add_pages().
More details:
devm_request_mem_region() and request_free_mem_region() request for device private memory. iomem_resource is passed as the base resource with start and end parameters. iomem_resource's end depends on several factors, including the platform and virtualization. On x86 for example on bare metal, this value is set to boot_cpu_data.x86_phys_bits. boot_cpu_data.x86_phys_bits can change depending on support for MKTME. By default it is set to the same as log2(direct_map_physmem_end) which is 46 to 52 bits depending on the number of levels in the page table. The allocation routines used iomem_resource's end and direct_map_physmem_end to figure out where to allocate the region.
[ arch/powerpc is also impacted by this problem, but this patch does not fix
the issue for PowerPC. ]
Testing:
1. Tested on a virtual machine with test_hmm for zone device inseration
2. A previous version of this patch was tested by Bert, please see:
https://lore.kernel.org/lkml/[email protected]/
[ mingo: Clarified the comments and the changelog. ]
--- arch/x86/mm/init_64.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/mm/init_64.c +12 -3
@@ -967,9 +967,18 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, ret =__add_pages (nid, start_pfn, nr_pages, params);WARN_ON_ONCE (ret); -/* update max_pfn, max_low_pfn and high_memory */ -update_end_of_memory_vars (start_pfn <<PAGE_SHIFT , - nr_pages <<PAGE_SHIFT ); +/* +* Special case: add_pages() is called by memremap_pages() for adding device +* private pages. Do not bump up max_pfn in the device private path, +* because max_pfn changes affect dma_addressing_limited(). +* +* dma_addressing_limited() returning true when max_pfn is the device's +* addressable memory can force device drivers to use bounce buffers +* and impact their performance negatively: +*/ +if (!params->pgmap) +/* update max_pfn, max_low_pfn and high_memory */ +update_end_of_memory_vars (start_pfn <<PAGE_SHIFT , nr_pages <<PAGE_SHIFT );return ret; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 631/642 bpf: abort verification if env->cur_state->loop_entry != NULL
In reply to Sasha LevinFrom: Eduard Zingerman <[email protected]>
[ Upstream commit f3c2d243a36ef23be07bc2bce7c6a5cb6e07d9e3 ]
In addition to warning abort verification with -EFAULT. If env->cur_state->loop_entry != NULL something is irrecoverably buggy.
--- kernel/bpf/verifier.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +4 -2
@@ -19265,8 +19265,10 @@ static int do_check(struct bpf_verifier_env *env)return err;break ; }else { -if (WARN_ON_ONCE (env->cur_state->loop_entry)) - env->cur_state->loop_entry =NULL ; +if (WARN_ON_ONCE (env->cur_state->loop_entry)) { +verbose (env,"verifier bug: env->cur_state->loop_entry != NULL\n" ); +return -EFAULT ; + } do_print_state = true;continue ; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 632/642 ipv6: remove leftover ip6 cookie initializer
In reply to Sasha LevinFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 54580ccdd8a9c6821fd6f72171d435480867e4c3 ]
As of the blamed commit ipc6.dontfrag is always initialized at the start of udpv6_sendmsg, by ipcm6_init_sk, to either 0 or 1.
Later checks against -1 are no longer needed and the branches are now dead code.
The blamed commit had removed those branches. But I had overlooked this one case.
UDP has both a lockless fast path and a slower path for corked requests. This branch remained in the fast path.
--- net/ipv6/ip6_output.c | 2 -- 1 file changed, 2 deletions(-)
net/ipv6/ip6_output.c +0 -2
@@ -2055,8 +2055,6 @@ struct sk_buff *ip6_make_skb(struct sock *sk,ip6_cork_release (cork, &v6_cork);return ERR_PTR (err); } -if (ipc6->dontfrag <0 ) - ipc6->dontfrag =inet6_test_bit (DONTFRAG , sk); err = __ip6_append_data(sk, &queue, cork, &v6_cork, ¤t->task_frag, getfrag, from,
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 633/642 kernfs: Use RCU to access kernfs_node::parent.
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 633488947ef66b194377411322dc9e12aab79b65 ]
kernfs_rename_lock is used to obtain stable kernfs_node::{name|parent} pointer. This is a preparation to access kernfs_node::parent under RCU and ensure that the pointer remains stable under the RCU lifetime guarantees.
For a complete path, as it is done in kernfs_path_from_node(), the kernfs_rename_lock is still required in order to obtain a stable parent relationship while computing the relevant node depth. This must not change while the nodes are inspected in order to build the path. If the kernfs user never moves the nodes (changes the parent) then the kernfs_rename_lock is not required and the RCU guarantees are sufficient. This "restriction" can be set with KERNFS_ROOT_INVARIANT_PARENT. Otherwise the lock is required.
Rename kernfs_node::parent to kernfs_node::__parent to denote the RCU access and use RCU accessor while accessing the node.
Make cgroup use KERNFS_ROOT_INVARIANT_PARENT since the parent here can not change.
Stable-dep-of: 6ef5b6fae304 ("kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().")
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 65 +++++++++---- fs/kernfs/dir.c | 96 ++++++++++++------- fs/kernfs/kernfs-internal.h | 32 ++++++- fs/kernfs/mount.c | 10 +- fs/kernfs/symlink.c | 23 ++--- fs/sysfs/file.c | 24 +++-- include/linux/kernfs.h | 10 +- kernel/cgroup/cgroup-v1.c | 2 +- kernel/cgroup/cgroup.c | 24 ++++- .../selftests/bpf/progs/profiler.inc.h | 2 +- 10 files changed, 195 insertions(+), 93 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +44 -21
@@ -957,10 +957,20 @@ static int rdt_last_cmd_status_show(struct kernfs_open_file *of,return 0 ; } +static void *rdt_kn_parent_priv (struct kernfs_node *kn) +{ +/* +* The parent pointer is only valid within RCU section since it can be +* replaced. +*/ +guard (rcu)(); +return rcu_dereference (kn->__parent)->priv; +} +static int rdt_num_closids_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);seq_printf (seq,"%u\n" , s->num_closid);return 0 ;
@@ -969,7 +979,7 @@ static int rdt_num_closids_show(struct kernfs_open_file *of,static int rdt_default_ctrl_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%x\n" , r->default_ctrl);
@@ -979,7 +989,7 @@ static int rdt_default_ctrl_show(struct kernfs_open_file *of,static int rdt_min_cbm_bits_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%u\n" , r->cache.min_cbm_bits);
@@ -989,7 +999,7 @@ static int rdt_min_cbm_bits_show(struct kernfs_open_file *of,static int rdt_shareable_bits_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%x\n" , r->cache.shareable_bits);
@@ -1013,7 +1023,7 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,static int rdt_bit_usage_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);/* * Use unsigned long even though only 32 bits are used to ensure * test_bit() is used safely.
@@ -1095,7 +1105,7 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of,static int rdt_min_bw_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%u\n" , r->membw.min_bw);
@@ -1105,7 +1115,7 @@ static int rdt_min_bw_show(struct kernfs_open_file *of,static int rdt_num_rmids_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct rdt_resource *r = of->kn->parent->priv; +struct rdt_resource *r =rdt_kn_parent_priv (of->kn);seq_printf (seq,"%d\n" , r->num_rmid);
@@ -1115,7 +1125,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file *of,static int rdt_mon_features_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct rdt_resource *r = of->kn->parent->priv; +struct rdt_resource *r =rdt_kn_parent_priv (of->kn);struct mon_evt *mevt;list_for_each_entry (mevt, &r->evt_list, list) {
@@ -1130,7 +1140,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of,static int rdt_bw_gran_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%u\n" , r->membw.bw_gran);
@@ -1140,7 +1150,7 @@ static int rdt_bw_gran_show(struct kernfs_open_file *of,static int rdt_delay_linear_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%u\n" , r->membw.delay_linear);
@@ -1158,7 +1168,7 @@ static int max_threshold_occ_show(struct kernfs_open_file *of,static int rdt_thread_throttle_mode_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;if (r->membw.throttle_mode ==THREAD_THROTTLE_PER_THREAD )
@@ -1223,7 +1233,7 @@ static enum resctrl_conf_type resctrl_peer_type(enum resctrl_conf_type my_type)static int rdt_has_sparse_bitmasks_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct resctrl_schema *s = of->kn->parent->priv; +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;seq_printf (seq,"%u\n" , r->cache.arch_has_sparse_bitmasks);
@@ -1635,7 +1645,7 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtidstatic int mbm_total_bytes_config_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct rdt_resource *r = of->kn->parent->priv; +struct rdt_resource *r =rdt_kn_parent_priv (of->kn);mbm_config_show (seq, r,QOS_L3_MBM_TOTAL_EVENT_ID );
@@ -1645,7 +1655,7 @@ static int mbm_total_bytes_config_show(struct kernfs_open_file *of,static int mbm_local_bytes_config_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) { -struct rdt_resource *r = of->kn->parent->priv; +struct rdt_resource *r =rdt_kn_parent_priv (of->kn);mbm_config_show (seq, r,QOS_L3_MBM_LOCAL_EVENT_ID );
@@ -1751,7 +1761,7 @@ static ssize_t mbm_total_bytes_config_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { - struct rdt_resource *r = of->kn->parent->priv; + struct rdt_resource *r = rdt_kn_parent_priv(of->kn);int ret;/* Valid input requires a trailing newline */
@@ -1777,7 +1787,7 @@ static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { - struct rdt_resource *r = of->kn->parent->priv; + struct rdt_resource *r = rdt_kn_parent_priv(of->kn);int ret;/* Valid input requires a trailing newline */
@@ -2441,12 +2451,13 @@ static struct rdtgroup *kernfs_to_rdtgroup(struct kernfs_node *kn)* resource. "info" and its subdirectories don't * have rdtgroup structures, so return NULL here. */ -if (kn == kn_info || kn->parent == kn_info) +if (kn == kn_info || +rcu_access_pointer (kn->__parent) == kn_info)return NULL ;else return kn->priv; }else { -return kn->parent->priv; +return rdt_kn_parent_priv (kn); } }
@@ -3772,9 +3783,18 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)return 0 ; } +static struct kernfs_node *rdt_kn_parent (struct kernfs_node *kn) +{ +/* +* Valid within the RCU section it was obtained or while rdtgroup_mutex +* is held. +*/ +return rcu_dereference_check (kn->__parent,lockdep_is_held (&rdtgroup_mutex)); +} +static int rdtgroup_rmdir (struct kernfs_node *kn) { -struct kernfs_node *parent_kn = kn->parent; +struct kernfs_node *parent_kn;struct rdtgroup *rdtgrp;cpumask_var_t tmpmask;int ret =0 ;
@@ -3787,6 +3807,7 @@ static int rdtgroup_rmdir(struct kernfs_node *kn) ret = -EPERM ; goto out; } + parent_kn =rdt_kn_parent (kn);/* * If the rdtgroup is a ctrl_mon group and parent directory
@@ -3855,6 +3876,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp,static int rdtgroup_rename (struct kernfs_node *kn,struct kernfs_node *new_parent,const char *new_name) { +struct kernfs_node *kn_parent;struct rdtgroup *new_prdtgrp;struct rdtgroup *rdtgrp;cpumask_var_t tmpmask;
@@ -3889,8 +3911,9 @@ static int rdtgroup_rename(struct kernfs_node *kn, goto out; } -if (rdtgrp->type !=RDTMON_GROUP || !kn->parent || - !is_mon_groups (kn->parent, kn->name)) { + kn_parent =rdt_kn_parent (kn); +if (rdtgrp->type !=RDTMON_GROUP || !kn_parent || + !is_mon_groups (kn_parent, kn->name)) {rdt_last_cmd_puts ("Source must be a MON group\n" ); ret = -EPERM ; goto out;
fs/kernfs/dir.c +60 -36
286 lines not on this page · raw message
fs/kernfs/kernfs-internal.h +29 -3
@@ -19,6 +19,8 @@#include <linux/kernfs.h> #include <linux/fs_context.h> +extern rwlock_t kernfs_rename_lock; +struct kernfs_iattrs {kuid_t ia_uid;kgid_t ia_gid;
@@ -64,11 +66,14 @@ struct kernfs_root {* * Return: the kernfs_root @kn belongs to. */ -static inline struct kernfs_root *kernfs_root (struct kernfs_node *kn) +static inline struct kernfs_root *kernfs_root (const struct kernfs_node *kn) { +const struct kernfs_node *knp;/* if parent exists, it's always a dir; otherwise, @sd is a dir */ -if (kn->parent) - kn = kn->parent; +guard (rcu)(); + knp =rcu_dereference (kn->__parent); +if (knp) + kn = knp;return kn->dir.root; }
@@ -97,6 +102,27 @@ struct kernfs_super_info { };#define kernfs_info (SB ) ((struct kernfs_super_info *)(SB->s_fs_info)) +static inline bool kernfs_root_is_locked (const struct kernfs_node *kn) +{ +return lockdep_is_held (&kernfs_root (kn)->kernfs_rwsem); +} + +static inline struct kernfs_node *kernfs_parent (const struct kernfs_node *kn) +{ +/* +* The kernfs_node::__parent remains valid within a RCU section. The kn +* can be reparented (and renamed) which changes the entry. This can be +* avoided by locking kernfs_root::kernfs_rwsem or kernfs_rename_lock. +* Both locks can be used to obtain a reference on __parent. Once the +* reference count reaches 0 then the node is about to be freed +* and can not be renamed (or become a different parent) anymore. +*/ +return rcu_dereference_check (kn->__parent, +kernfs_root_is_locked (kn) || +lockdep_is_held (&kernfs_rename_lock) || + !atomic_read (&kn->count)); +} +static inline struct kernfs_node *kernfs_dentry_node (struct dentry *dentry) {if (d_really_is_negative (dentry))
fs/kernfs/mount.c +5 -5
@@ -148,7 +148,7 @@ static struct dentry *kernfs_get_parent_dentry(struct dentry *child)struct kernfs_root *root =kernfs_root (kn);guard (rwsem_read)(&root->kernfs_rwsem); -return d_obtain_alias (kernfs_get_inode (child->d_sb, kn->parent)); +return d_obtain_alias (kernfs_get_inode (child->d_sb,kernfs_parent (kn))); }static const struct export_operations kernfs_export_ops = {
@@ -188,10 +188,10 @@ static struct kernfs_node *find_next_ancestor(struct kernfs_node *child,return NULL ; } -while (child->parent != parent) { -if (!child->parent) +while (kernfs_parent (child) != parent) { + child =kernfs_parent (child); +if (!child)return NULL ; - child = child->parent; }return child;
@@ -216,7 +216,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn, dentry =dget (sb->s_root);/* Check if this is the root kernfs_node */ -if (!kn->parent) +if (!rcu_access_pointer (kn->__parent))return dentry; root =kernfs_root (kn);
fs/kernfs/symlink.c +12 -11
@@ -62,10 +62,10 @@ static int kernfs_get_target_path(struct kernfs_node *parent,/* go up to the root, stop at the base */ base = parent; -while (base->parent) { - kn = target->parent; -while (kn->parent && base != kn) - kn = kn->parent; +while (kernfs_parent (base)) { + kn =kernfs_parent (target); +while (kernfs_parent (kn) && base != kn) + kn =kernfs_parent (kn);if (base == kn)break ;
@@ -75,14 +75,14 @@ static int kernfs_get_target_path(struct kernfs_node *parent,strcpy (s,"../" ); s +=3 ; - base = base->parent; + base =kernfs_parent (base); }/* determine end of target string for reverse fillup */ kn = target; -while (kn->parent && kn != base) { +while (kernfs_parent (kn) && kn != base) { len +=strlen (kn->name) +1 ; - kn = kn->parent; + kn =kernfs_parent (kn); }/* check limits */
@@ -94,7 +94,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent,/* reverse fillup of target string from target to base */ kn = target; -while (kn->parent && kn != base) { +while (kernfs_parent (kn) && kn != base) {int slen =strlen (kn->name); len -= slen;
@@ -102,7 +102,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent,if (len) s[--len] ='/' ; - kn = kn->parent; + kn =kernfs_parent (kn); }return 0 ;
@@ -111,12 +111,13 @@ static int kernfs_get_target_path(struct kernfs_node *parent,static int kernfs_getlink (struct inode *inode,char *path) {struct kernfs_node *kn = inode->i_private; -struct kernfs_node *parent = kn->parent; +struct kernfs_node *parent;struct kernfs_node *target = kn->symlink.target_kn; -struct kernfs_root *root =kernfs_root (parent); +struct kernfs_root *root =kernfs_root (kn);int error;down_read (&root->kernfs_rwsem); + parent =kernfs_parent (kn); error =kernfs_get_target_path (parent, target, path);up_read (&root->kernfs_rwsem);
fs/sysfs/file.c +15 -9
@@ -19,13 +19,19 @@#include "sysfs.h" +static struct kobject *sysfs_file_kobj (struct kernfs_node *kn) +{ +guard (rcu)(); +return rcu_dereference (kn->__parent)->priv; +} +/* * Determine ktype->sysfs_ops for the given kernfs_node. This function * must be called while holding an active reference. */ static const struct sysfs_ops *sysfs_file_ops (struct kernfs_node *kn) { -struct kobject *kobj = kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (kn);if (kn->flags &KERNFS_LOCKDEP )lockdep_assert_held (kn);
@@ -40,7 +46,7 @@ static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)static int sysfs_kf_seq_show (struct seq_file *sf,void *v) {struct kernfs_open_file *of = sf->private; -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);const struct sysfs_ops *ops =sysfs_file_ops (of->kn);ssize_t count;char *buf;
@@ -78,7 +84,7 @@ static ssize_t sysfs_kf_bin_read(struct kernfs_open_file *of, char *buf, size_t count, loff_t pos) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);loff_t size =file_inode (of->file)->i_size;if (!count)
@@ -105,7 +111,7 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, size_t count, loff_t pos) {const struct sysfs_ops *ops =sysfs_file_ops (of->kn); -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);ssize_t len;/*
@@ -131,7 +137,7 @@ static ssize_t sysfs_kf_write(struct kernfs_open_file *of, char *buf, size_t count, loff_t pos) {const struct sysfs_ops *ops =sysfs_file_ops (of->kn); -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);if (!count)return 0 ;
@@ -144,7 +150,7 @@ static ssize_t sysfs_kf_bin_write(struct kernfs_open_file *of, char *buf, size_t count, loff_t pos) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);loff_t size =file_inode (of->file)->i_size;if (size) {
@@ -168,7 +174,7 @@ static int sysfs_kf_bin_mmap(struct kernfs_open_file *of, struct vm_area_struct *vma) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);return battr->mmap (of->file, kobj, battr, vma); }
@@ -177,7 +183,7 @@ static loff_t sysfs_kf_bin_llseek(struct kernfs_open_file *of, loff_t offset, int whence) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (of->kn);if (battr->llseek)return battr->llseek (of->file, kobj, battr, offset, whence);
@@ -494,7 +500,7 @@ EXPORT_SYMBOL_GPL(sysfs_break_active_protection);*/ void sysfs_unbreak_active_protection (struct kernfs_node *kn) { -struct kobject *kobj = kn->parent->priv; +struct kobject *kobj =sysfs_file_kobj (kn);kernfs_unbreak_active_protection (kn);kernfs_put (kn);
include/linux/kernfs.h +9 -1
@@ -147,6 +147,11 @@ enum kernfs_root_flag {* Support user xattrs to be written to nodes rooted at this root. */ KERNFS_ROOT_SUPPORT_USER_XATTR =0x0008 , + +/* +* Renames must not change the parent node. +*/ + KERNFS_ROOT_INVARIANT_PARENT = 0x0010, };/* type-specific structures for kernfs_node union members */
@@ -199,8 +204,8 @@ struct kernfs_node {* never moved to a different parent, it is safe to access the * parent directly. */ -struct kernfs_node *parent;const char *name; +struct kernfs_node __rcu *__parent;struct rb_node rb;
@@ -416,6 +421,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,struct kernfs_root *kernfs_create_root (struct kernfs_syscall_ops *scops,unsigned int flags,void *priv);void kernfs_destroy_root (struct kernfs_root *root); +unsigned int kernfs_root_flags (struct kernfs_node *kn); struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent, const char *name, umode_t mode,
@@ -514,6 +520,8 @@ kernfs_create_root(struct kernfs_syscall_ops *scops, unsigned int flags, {return ERR_PTR (-ENOSYS ); }static inline void kernfs_destroy_root (struct kernfs_root *root) { } +static inline unsigned int kernfs_root_flags (struct kernfs_node *kn) +{return 0 ; }static inline struct kernfs_node * kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
kernel/cgroup/cgroup-v1.c +1 -1
@@ -844,7 +844,7 @@ static int cgroup1_rename(struct kernfs_node *kn, struct kernfs_node *new_parentif (kernfs_type (kn) !=KERNFS_DIR )return -ENOTDIR ; -if (kn->parent != new_parent) +if (rcu_access_pointer (kn->__parent) != new_parent)return -EIO ;/*
kernel/cgroup/cgroup.c +19 -5
@@ -633,9 +633,22 @@ int cgroup_task_count(const struct cgroup *cgrp)return count; } +static struct cgroup *kn_priv (struct kernfs_node *kn) +{ +struct kernfs_node *parent; +/* +* The parent can not be replaced due to KERNFS_ROOT_INVARIANT_PARENT. +* Therefore it is always safe to dereference this pointer outside of a +* RCU section. +*/ + parent =rcu_dereference_check (kn->__parent, +kernfs_root_flags (kn) &KERNFS_ROOT_INVARIANT_PARENT ); +return parent->priv; +} +struct cgroup_subsys_state *of_css (struct kernfs_open_file *of) { -struct cgroup *cgrp = of->kn->parent->priv; +struct cgroup *cgrp =kn_priv (of->kn);struct cftype *cft =of_cft (of);/*
@@ -1612,7 +1625,7 @@ void cgroup_kn_unlock(struct kernfs_node *kn)if (kernfs_type (kn) ==KERNFS_DIR ) cgrp = kn->priv;else - cgrp = kn->parent->priv; + cgrp =kn_priv (kn);cgroup_unlock ();
@@ -1644,7 +1657,7 @@ struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline)if (kernfs_type (kn) ==KERNFS_DIR ) cgrp = kn->priv;else - cgrp = kn->parent->priv; + cgrp =kn_priv (kn);/* * We're gonna grab cgroup_mutex which nests outside kernfs
@@ -2118,7 +2131,8 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask) root->kf_root =kernfs_create_root (kf_sops,KERNFS_ROOT_CREATE_DEACTIVATED |KERNFS_ROOT_SUPPORT_EXPORTOP | -KERNFS_ROOT_SUPPORT_USER_XATTR , +KERNFS_ROOT_SUPPORT_USER_XATTR | +KERNFS_ROOT_INVARIANT_PARENT , root_cgrp);if (IS_ERR (root->kf_root)) { ret =PTR_ERR (root->kf_root);
@@ -4144,7 +4158,7 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) {struct cgroup_file_ctx *ctx = of->priv; -struct cgroup *cgrp = of->kn->parent->priv; +struct cgroup *cgrp =kn_priv (of->kn);struct cftype *cft =of_cft (of);struct cgroup_subsys_state *css;int ret;
tools/testing/selftests/bpf/progs/profiler.inc.h +1 -1
@@ -223,7 +223,7 @@ static INLINE void* read_full_cgroup_path(struct kernfs_node* cgroup_node, if (bpf_cmp_likely(filepart_length, <=, MAX_PATH)) { payload += filepart_length; } - cgroup_node =BPF_CORE_READ (cgroup_node, parent); + cgroup_node =BPF_CORE_READ (cgroup_node, __parent); }return payload; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 634/642 kernfs: Use RCU to access kernfs_node::name.
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 741c10b096bc4dd79cd9f215b6ef173bb953e75c ]
Using RCU lifetime rules to access kernfs_node::name can avoid the trouble with kernfs_rename_lock in kernfs_name() and kernfs_path_from_node() if the fs was created with KERNFS_ROOT_INVARIANT_PARENT. This is usefull as it allows to implement kernfs_path_from_node() only with RCU protection and avoiding kernfs_rename_lock. The lock is only required if the __parent node can be changed and the function requires an unchanged hierarchy while it iterates from the node to its parent.
The change is needed to allow the lookup of the node's path (kernfs_path_from_node()) from context which runs always with disabled preemption and or interrutps even on PREEMPT_RT. The problem is that kernfs_rename_lock becomes a sleeping lock on PREEMPT_RT.
I went through all ::name users and added the required access for the lookup with a few extensions:
- rdtgroup_pseudo_lock_create() drops all locks and then uses the name later on. resctrl supports rename with different parents. Here I made a temporal copy of the name while it is used outside of the lock.
- kernfs_rename_ns() accepts NULL as new_parent. This simplifies sysfs_move_dir_ns() where it can set NULL in order to reuse the current name.
- kernfs_rename_ns() is only using kernfs_rename_lock if the parents are different. All users use either kernfs_rwsem (for stable path view) or just RCU for the lookup. The ::name uses always RCU free.
Use RCU lifetime guarantees to access kernfs_node::name.
Stable-dep-of: 6ef5b6fae304 ("kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().")
--- arch/x86/kernel/cpu/resctrl/internal.h | 5 + arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 14 ++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 +- fs/kernfs/dir.c | 113 ++++++++++++---------- fs/kernfs/file.c | 4 +- fs/kernfs/kernfs-internal.h | 5 + fs/kernfs/mount.c | 5 +- fs/kernfs/symlink.c | 7 +- fs/sysfs/dir.c | 2 +- include/linux/kernfs.h | 4 +- security/selinux/hooks.c | 7 +- 11 files changed, 105 insertions(+), 71 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +5 -0
@@ -507,6 +507,11 @@ int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,extern struct mutex rdtgroup_mutex; +static inline const char *rdt_kn_name (const struct kernfs_node *kn) +{ +return rcu_dereference_check (kn->name,lockdep_is_held (&rdtgroup_mutex)); +} +extern struct rdt_hw_resource rdt_resources_all[];extern struct rdtgroup rdtgroup_default;extern struct dentry *debugfs_resctrl;
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +10 -4
@@ -52,7 +52,8 @@ static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode) rdtgrp =dev_get_drvdata (dev);if (mode) *mode =0600 ; -return kasprintf (GFP_KERNEL ,"pseudo_lock/%s" , rdtgrp->kn->name); +guard (mutex)(&rdtgroup_mutex); +return kasprintf (GFP_KERNEL ,"pseudo_lock/%s" ,rdt_kn_name (rdtgrp->kn)); }static const struct class pseudo_lock_class = {
@@ -1293,6 +1294,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)struct task_struct *thread;unsigned int new_minor;struct device *dev; + char *kn_name __free(kfree) = NULL;int ret; ret =pseudo_lock_region_alloc (plr);
@@ -1304,6 +1306,11 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) ret = -EINVAL ; goto out_region; } + kn_name =kstrdup (rdt_kn_name (rdtgrp->kn),GFP_KERNEL ); +if (!kn_name) { + ret = -ENOMEM ; + goto out_cstates; + } plr->thread_done =0 ;
@@ -1348,8 +1355,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)mutex_unlock (&rdtgroup_mutex);if (!IS_ERR_OR_NULL (debugfs_resctrl)) { - plr->debugfs_dir =debugfs_create_dir (rdtgrp->kn->name, - debugfs_resctrl); + plr->debugfs_dir =debugfs_create_dir (kn_name, debugfs_resctrl);if (!IS_ERR_OR_NULL (plr->debugfs_dir)) debugfs_create_file("pseudo_lock_measure", 0200, plr->debugfs_dir, rdtgrp,
@@ -1358,7 +1364,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) dev =device_create (&pseudo_lock_class,NULL ,MKDEV (pseudo_lock_major, new_minor), - rdtgrp,"%s" , rdtgrp->kn->name); + rdtgrp,"%s" , kn_name);mutex_lock (&rdtgroup_mutex);
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -5
@@ -917,14 +917,14 @@ int proc_resctrl_show(struct seq_file *s, struct pid_namespace *ns,continue ;seq_printf (s,"res:%s%s\n" , (rdtg == &rdtgroup_default) ?"/" :"" , - rdtg->kn->name); +rdt_kn_name (rdtg->kn));seq_puts (s,"mon:" );list_for_each_entry (crg, &rdtg->mon.crdtgrp_list, mon.crdtgrp_list) {if (!resctrl_arch_match_rmid (tsk, crg->mon.parent->closid, crg->mon.rmid))continue ; -seq_printf (s,"%s" , crg->kn->name); +seq_printf (s,"%s" ,rdt_kn_name (crg->kn));break ; }seq_putc (s,'\n' );
@@ -3676,7 +3676,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,*/ static bool is_mon_groups (struct kernfs_node *kn,const char *name) { -return (!strcmp (kn->name,"mon_groups" ) && +return (!strcmp (rdt_kn_name (kn),"mon_groups" ) &&strcmp (name,"mon_groups" )); }
@@ -3825,7 +3825,7 @@ static int rdtgroup_rmdir(struct kernfs_node *kn) ret =rdtgroup_rmdir_ctrl (rdtgrp, tmpmask); } }else if (rdtgrp->type ==RDTMON_GROUP && -is_mon_groups (parent_kn, kn->name)) { +is_mon_groups (parent_kn,rdt_kn_name (kn))) { ret =rdtgroup_rmdir_mon (rdtgrp, tmpmask); }else { ret = -EPERM ;
@@ -3913,7 +3913,7 @@ static int rdtgroup_rename(struct kernfs_node *kn, kn_parent =rdt_kn_parent (kn);if (rdtgrp->type !=RDTMON_GROUP || !kn_parent || - !is_mon_groups (kn_parent, kn->name)) { + !is_mon_groups (kn_parent,rdt_kn_name (kn))) {rdt_last_cmd_puts ("Source must be a MON group\n" ); ret = -EPERM ; goto out;
fs/kernfs/dir.c +62 -51
247 lines not on this page · raw message
fs/kernfs/file.c +3 -1
@@ -915,6 +915,7 @@ static void kernfs_notify_workfn(struct work_struct *work)list_for_each_entry (info, &kernfs_root (kn)->supers, node) {struct kernfs_node *parent;struct inode *p_inode =NULL ; +const char *kn_name;struct inode *inode;struct qstr name;
@@ -928,7 +929,8 @@ static void kernfs_notify_workfn(struct work_struct *work)if (!inode)continue ; - name =QSTR (kn->name); + kn_name =kernfs_rcu_name (kn); + name =QSTR (kn_name); parent =kernfs_get_parent (kn);if (parent) { p_inode =ilookup (info->sb,kernfs_ino (parent));
fs/kernfs/kernfs-internal.h +5 -0
@@ -107,6 +107,11 @@ static inline bool kernfs_root_is_locked(const struct kernfs_node *kn)return lockdep_is_held (&kernfs_root (kn)->kernfs_rwsem); } +static inline const char *kernfs_rcu_name (const struct kernfs_node *kn) +{ +return rcu_dereference_check (kn->name,kernfs_root_is_locked (kn)); +} +static inline struct kernfs_node *kernfs_parent (const struct kernfs_node *kn) {/*
fs/kernfs/mount.c +3 -2
@@ -231,6 +231,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn, do { struct dentry *dtmp; struct kernfs_node *kntmp; + const char *name; if (kn == knparent) return dentry;
@@ -239,8 +240,8 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,dput (dentry);return ERR_PTR (-EINVAL ); } - dtmp =lookup_positive_unlocked (kntmp->name, dentry, -strlen (kntmp->name)); + name =rcu_dereference (kntmp->name); + dtmp =lookup_positive_unlocked (name, dentry,strlen (name));dput (dentry);if (IS_ERR (dtmp))return dtmp;
fs/kernfs/symlink.c +4 -3
@@ -81,7 +81,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent,/* determine end of target string for reverse fillup */ kn = target;while (kernfs_parent (kn) && kn != base) { - len +=strlen (kn->name) +1 ; + len +=strlen (kernfs_rcu_name (kn)) +1 ; kn =kernfs_parent (kn); }
@@ -95,10 +95,11 @@ static int kernfs_get_target_path(struct kernfs_node *parent,/* reverse fillup of target string from target to base */ kn = target;while (kernfs_parent (kn) && kn != base) { -int slen =strlen (kn->name); +const char *name =kernfs_rcu_name (kn); +int slen =strlen (name); len -= slen; -memcpy (s + len, kn->name, slen); +memcpy (s + len, name, slen);if (len) s[--len] ='/' ;
fs/sysfs/dir.c +1 -1
@@ -123,7 +123,7 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, new_parent = new_parent_kobj && new_parent_kobj->sd ? new_parent_kobj->sd : sysfs_root_kn; -return kernfs_rename_ns (kn, new_parent, kn->name, new_ns); +return kernfs_rename_ns (kn, new_parent,NULL , new_ns); }/**
include/linux/kernfs.h +2 -2
@@ -204,8 +204,8 @@ struct kernfs_node {* never moved to a different parent, it is safe to access the * parent directly. */ -const char *name;struct kernfs_node __rcu *__parent; +const char __rcu *name;struct rb_node rb;
@@ -400,7 +400,7 @@ static inline bool kernfs_ns_enabled(struct kernfs_node *kn) }int kernfs_name (struct kernfs_node *kn,char *buf,size_t buflen); -int kernfs_path_from_node (struct kernfs_node *root_kn,struct kernfs_node *kn, +int kernfs_path_from_node (struct kernfs_node *kn_to,struct kernfs_node *kn_from,char *buf,size_t buflen);void pr_cont_kernfs_name (struct kernfs_node *kn);void pr_cont_kernfs_path (struct kernfs_node *kn);
security/selinux/hooks.c +5 -2
@@ -3584,10 +3584,13 @@ static int selinux_kernfs_init_security(struct kernfs_node *kn_dir, newsid = tsec->create_sid; }else {u16 secclass =inode_mode_to_security_class (kn->mode); +const char *kn_name;struct qstr q; - q.name = kn->name; - q.hash_len =hashlen_string (kn_dir, kn->name); +/* kn is fresh, can't be renamed, name goes not away */ + kn_name =rcu_dereference_check (kn->name, true); + q.name = kn_name; + q.hash_len =hashlen_string (kn_dir, kn_name); rc = security_transition_sid(tsec->sid, parent_sid, secclass, &q,
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 635/642 kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 6ef5b6fae304091593956be59065c0c8633ad9e8 ]
syzbot reported two warnings:
- kernfs_node::name was accessed outside of a RCU section so it created warning. The kernfs_rwsem was held so it was okay but it wasn't seen.
- While kernfs_rwsem was held invoked lookup_positive_unlocked()-> kernfs_dop_revalidate() which acquired kernfs_rwsem.
kernfs_rwsem was both acquired as a read lock so it can be acquired twice. However if a writer acquires the lock after the first reader then neither the writer nor the second reader can obtain the lock so it deadlocks.
The reason for the lock is to ensure that kernfs_node::name remain stable during lookup_positive_unlocked()'s invocation. The function can not be invoked within a RCU section because it may sleep.
Make a temporary copy of the kernfs_node::name under the lock so GFP_KERNEL can be used and use this instead.
--- fs/kernfs/mount.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
fs/kernfs/mount.c +24 -9
@@ -220,12 +220,19 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,return dentry; root =kernfs_root (kn); -guard (rwsem_read)(&root->kernfs_rwsem); - - knparent =find_next_ancestor (kn,NULL ); -if (WARN_ON (!knparent)) { -dput (dentry); +/* +* As long as kn is valid, its parent can not vanish. This is cgroup's +* kn so it not have its parent replaced. Therefore it is safe to use +* the ancestor node outside of the RCU or locked section. +*/ +if (WARN_ON_ONCE (!(root->flags &KERNFS_ROOT_INVARIANT_PARENT )))return ERR_PTR (-EINVAL ); +scoped_guard (rcu) { + knparent =find_next_ancestor (kn,NULL ); +if (WARN_ON (!knparent)) { +dput (dentry); +return ERR_PTR (-EINVAL ); + } } do {
@@ -235,14 +242,22 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,if (kn == knparent)return dentry; - kntmp =find_next_ancestor (kn, knparent); -if (WARN_ON (!kntmp)) { + + scoped_guard(rwsem_read, &root->kernfs_rwsem) { + kntmp =find_next_ancestor (kn, knparent); +if (WARN_ON (!kntmp)) { +dput (dentry); +return ERR_PTR (-EINVAL ); + } + name =kstrdup (kernfs_rcu_name (kntmp),GFP_KERNEL ); + } +if (!name) {dput (dentry); -return ERR_PTR (-EINVAL ); +return ERR_PTR (-ENOMEM ); } - name =rcu_dereference (kntmp->name); dtmp =lookup_positive_unlocked (name, dentry,strlen (name));dput (dentry); +kfree (name);if (IS_ERR (dtmp))return dtmp; knparent = kntmp;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 636/642 serial: sh-sci: Save and restore more registers
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 81100b9a7b0515132996d62a7a676a77676cb6e3 ]
On (H)SCIF with a Baud Rate Generator for External Clock (BRG), there are multiple ways to configure the requested serial speed. If firmware uses a different method than Linux, and if any debug info is printed after the Bit Rate Register (SCBRR) is restored, but before termios is reconfigured (which configures the alternative method), the system may lock-up during resume.
Fix this by saving and restoring the contents of the BRG Frequency Division (SCDL) and Clock Select (SCCKS) registers as well.
Also save and restore the HSCIF's Sampling Rate Register (HSSRR), which configures the sampling point, and the SCIFA/SCIFB's Serial Port Control and Data Registers (SCPCR/SCPDR), which configure the optional control flow signals.
After this, all registers that are not saved/restored are either:
- read-only,
- write-only,
- status registers containing flags with clear-after-set semantics,
- FIFO Data Count Trigger registers, which do not matter much for the serial console.
--- drivers/tty/serial/sh-sci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/tty/serial/sh-sci.c +25 -0
@@ -105,10 +105,15 @@ struct plat_sci_reg { };struct sci_suspend_regs { +u16 scdl; +u16 sccks;u16 scsmr;u16 scscr;u16 scfcr;u16 scsptr; +u16 hssrr; +u16 scpcr; +u16 scpdr;u8 scbrr;u8 semr; };
@@ -3564,6 +3569,10 @@ static void sci_console_save(struct sci_port *s)struct sci_suspend_regs *regs = &s->suspend_regs;struct uart_port *port = &s->port; +if (sci_getreg (port,SCDL )->size) + regs->scdl =sci_serial_in (port,SCDL ); +if (sci_getreg (port,SCCKS )->size) + regs->sccks =sci_serial_in (port,SCCKS );if (sci_getreg (port,SCSMR )->size) regs->scsmr =sci_serial_in (port,SCSMR );if (sci_getreg (port,SCSCR )->size)
@@ -3574,6 +3583,12 @@ static void sci_console_save(struct sci_port *s) regs->scsptr =sci_serial_in (port,SCSPTR );if (sci_getreg (port,SCBRR )->size) regs->scbrr =sci_serial_in (port,SCBRR ); +if (sci_getreg (port,HSSRR )->size) + regs->hssrr =sci_serial_in (port,HSSRR ); +if (sci_getreg (port,SCPCR )->size) + regs->scpcr =sci_serial_in (port,SCPCR ); +if (sci_getreg (port,SCPDR )->size) + regs->scpdr =sci_serial_in (port,SCPDR );if (sci_getreg (port,SEMR )->size) regs->semr =sci_serial_in (port,SEMR ); }
@@ -3583,6 +3598,10 @@ static void sci_console_restore(struct sci_port *s)struct sci_suspend_regs *regs = &s->suspend_regs;struct uart_port *port = &s->port; +if (sci_getreg (port,SCDL )->size) +sci_serial_out (port,SCDL , regs->scdl); +if (sci_getreg (port,SCCKS )->size) +sci_serial_out (port,SCCKS , regs->sccks);if (sci_getreg (port,SCSMR )->size)sci_serial_out (port,SCSMR , regs->scsmr);if (sci_getreg (port,SCSCR )->size)
@@ -3593,6 +3612,12 @@ static void sci_console_restore(struct sci_port *s)sci_serial_out (port,SCSPTR , regs->scsptr);if (sci_getreg (port,SCBRR )->size)sci_serial_out (port,SCBRR , regs->scbrr); +if (sci_getreg (port,HSSRR )->size) +sci_serial_out (port,HSSRR , regs->hssrr); +if (sci_getreg (port,SCPCR )->size) +sci_serial_out (port,SCPCR , regs->scpcr); +if (sci_getreg (port,SCPDR )->size) +sci_serial_out (port,SCPDR , regs->scpdr);if (sci_getreg (port,SEMR )->size)sci_serial_out (port,SEMR , regs->semr); }
Signature · 1 line
2.39.5
Re: [PATCH AUTOSEL 6.14 636/642] serial: sh-sci: Save and restore more registers
Hi Sasha,
Quoted 19 lines · Sasha Levin
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit
81100b9a7b0515132996d62a7a676a77676cb6e3]On (H)SCIF with a Baud Rate Generator for External Clock (BRG), there are multiple ways to configure the requested serial speed. If firmware uses a different method than Linux, and if any debug info is printed after the Bit Rate Register (SCBRR) is restored, but before termios is reconfigured (which configures the alternative method), the system may lock-up during resume.
Fix this by saving and restoring the contents of the BRG Frequency Division (SCDL) and Clock Select (SCCKS) registers as well.
Also save and restore the HSCIF's Sampling Rate Register (HSSRR), which configures the sampling point, and the SCIFA/SCIFB's Serial Port Control and Data Registers (SCPCR/SCPDR), which configure the optional control flow signals.
Quoted 6 lines
After this, all registers that are not saved/restored are either:
- read-only,
- write-only,
- status registers containing flags with clear-after-set semantics,
- FIFO Data Count Trigger registers, which do not matter much for the serial console.
Please make sure to backport this to v6.1, v6.6, and v6.12, too, as the commit this fixes:
Quoted 1 line
Fixes 22a6984c5b5df8ea ("serial: sh-sci: Update the suspend/resume support")
is already queued for v6.1, v6.6, and v6.12.
Quoted 6 lines
Signed-off-by Geert Uytterhoeven <[email protected]>Tested-by Claudiu Beznea <[email protected]>Reviewed-by Claudiu Beznea <[email protected]>Link https://lore.kernel.org/r/11c2eab45d48211e75d8b8202cce60400880fe55.1741114989.git.geert+renesas@glider.be open hereSigned-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Thanks!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Sasha Levin
maintainerPATCH 637/642 drm/amd/display: Exit idle optimizations before accessing PHY
In reply to Sasha LevinFrom: Ovidiu Bunea <[email protected]>
[ Upstream commit c488967488d7eff7b9c527d5469c424c15377502 ]
[why & how]
By default, DCN HW is in idle optimized state which does not allow access to PHY registers. If BIOS powers up the DCN, it is fine because they will power up everything. Only exit idle optimized state when not taking control from VBIOS.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +5 -0
@@ -1889,6 +1889,7 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)bool can_apply_edp_fast_boot = false;bool can_apply_seamless_boot = false;bool keep_edp_vdd_on = false; +struct dc_bios *dcb = dc->ctx->dc_bios;DC_LOGGER_INIT ();
@@ -1965,6 +1966,8 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context) hws->funcs.edp_backlight_control (edp_link_with_sink, false); }/*resume from S3, no vbios posting, no need to power down again*/ +if (dcb && dcb->funcs && !dcb->funcs->is_accelerated_mode (dcb)) +clk_mgr_exit_optimized_pwr_state (dc, dc->clk_mgr);power_down_all_hw_blocks (dc);
@@ -1977,6 +1980,8 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)disable_vga_and_power_gate_all_controllers (dc);if (edp_link_with_sink && !keep_edp_vdd_on) dc->hwss.edp_power_control (edp_link_with_sink, false); +if (dcb && dcb->funcs && !dcb->funcs->is_accelerated_mode (dcb)) +clk_mgr_optimize_pwr_state (dc, dc->clk_mgr); }bios_set_scratch_acc_mode_change (dc->ctx->dc_bios,1 ); }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 638/642 drm/amdkfd: Fix error handling for missing PASID in 'kfd_process_device_init_vm'
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 2b04d04de956b44cc140d45cf8ebccfb378ce3bf ]
In the kfd_process_device_init_vm function, a valid error code is now returned when the associated Process Address Space ID (PASID) is not present.
If the address space virtual memory (avm) does not have an associated PASID, the function sets the ret variable to -EINVAL before proceeding to the error handling section. This ensures that the calling function, such as kfd_ioctl_acquire_vm, can appropriately handle the error, thereby preventing any issues during virtual memory initialization.
Fixes the below:drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:1694 kfd_process_device_init_vm()
warn: missing error code 'ret'
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c
1647 int kfd_process_device_init_vm(struct kfd_process_device *pdd,
1648 struct file *drm_file)
1649 {
...
1690
1691 if (unlikely(!avm->pasid)) {
1692 dev_warn(pdd->dev->adev->dev, "WARN: vm %p has no pasid associated",
1693 avm);--> 1694 goto err_get_pasid;
ret = -EINVAL?
1695 }
Reported by: Dan Carpenter <[email protected]>
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -0
@@ -1711,6 +1711,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,if (unlikely (!avm->pasid)) {dev_warn (pdd->dev->adev->dev,"WARN: vm %p has no pasid associated" , avm); + ret = -EINVAL ; goto err_get_pasid; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 639/642 drm/amdkfd: Fix pasid value leak
In reply to Sasha LevinFrom: Xiaogang Chen <[email protected]>
[ Upstream commit 10e08943caedfb4b0b95933d248503a6f6b9fef6 ]
Curret kfd does not allocate pasid values, instead uses pasid value for each vm from graphic driver. So should not prevent graphic driver from releasing pasid values since the values are allocated by graphic driver, not kfd driver anymore. This patch does not stop graphic driver release pasid values.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 -- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 21 ------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 5 +---- 5 files changed, 1 insertion(+), 42 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +0 -2
@@ -303,8 +303,6 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,struct amdgpu_vm *avm, void **process_info, struct dma_fence **ef); -void amdgpu_amdkfd_gpuvm_release_process_vm (struct amdgpu_device *adev, -void *drm_priv);uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir (void *drm_priv);size_t amdgpu_amdkfd_get_available_memory (struct amdgpu_device *adev,uint8_t xcp_id);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -21
@@ -1578,27 +1578,6 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, } } -void amdgpu_amdkfd_gpuvm_release_process_vm (struct amdgpu_device *adev, -void *drm_priv) -{ -struct amdgpu_vm *avm; - -if (WARN_ON (!adev || !drm_priv)) -return ; - - avm =drm_priv_to_vm (drm_priv); - -pr_debug ("Releasing process vm %p\n" , avm); - -/* The original pasid of amdgpu vm has already been -* released during making a amdgpu vm to a compute vm -* The current pasid is managed by kfd and will be -* released on kfd process destroy. Set amdgpu pasid -* to 0 to avoid duplicate release. -*/ -amdgpu_vm_release_compute (adev, avm); -} -uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir (void *drm_priv) {struct amdgpu_vm *avm =drm_priv_to_vm (drm_priv);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -14
@@ -2687,20 +2687,6 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)return r; } -/** -* amdgpu_vm_release_compute - release a compute vm -* @adev: amdgpu_device pointer -* @vm: a vm turned into compute vm by calling amdgpu_vm_make_compute -* -* This is a correspondant of amdgpu_vm_make_compute. It decouples compute -* pasid from vm. Compute should stop use of vm after this call. -*/ -void amdgpu_vm_release_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm) -{ -amdgpu_vm_set_pasid (adev, vm,0 ); - vm->is_compute_context = false; -} -static int amdgpu_vm_stats_is_zero (struct amdgpu_vm *vm) {for (int i =0 ; i < __AMDGPU_PL_NUM; ++i) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -1
@@ -489,7 +489,6 @@ int amdgpu_vm_set_pasid(struct amdgpu_device *adev, struct amdgpu_vm *vm,long amdgpu_vm_wait_idle (struct amdgpu_vm *vm,long timeout);int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id);int amdgpu_vm_make_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm); -void amdgpu_vm_release_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_fini (struct amdgpu_device *adev,struct amdgpu_vm *vm);int amdgpu_vm_lock_pd (struct amdgpu_vm *vm,struct drm_exec *exec,unsigned int num_fences);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -4
@@ -1059,11 +1059,8 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)kfd_process_device_destroy_cwsr_dgpu (pdd);kfd_process_device_destroy_ib_mem (pdd); -if (pdd->drm_file) { -amdgpu_amdkfd_gpuvm_release_process_vm ( - pdd->dev->adev, pdd->drm_priv); +if (pdd->drm_file)fput (pdd->drm_file); - }if (pdd->qpd.cwsr_kaddr && !pdd->qpd.cwsr_base) free_pages((unsigned long)pdd->qpd.cwsr_kaddr,
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 640/642 wifi: mac80211: Add counter for all monitor interfaces
In reply to Sasha LevinFrom: Alexander Wetzel <[email protected]>
[ Upstream commit 129860044c611008be37f49d04cf41874e3659e6 ]
Count open monitor interfaces regardless of the monitor interface type. The new counter virt_monitors takes over counting interfaces depending on the virtual monitor interface while monitors is used for all active monitor interfaces.
This fixes monitor packet mirroring when using MONITOR_FLAG_ACTIVE or NO_VIRTUAL_MONITOR interfaces.
--- net/mac80211/cfg.c | 5 ++--- net/mac80211/ethtool.c | 2 +- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/iface.c | 22 +++++++++++++--------- net/mac80211/util.c | 3 ++- 5 files changed, 19 insertions(+), 15 deletions(-)
net/mac80211/cfg.c +2 -3
@@ -4370,9 +4370,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,if (chanctx_conf) { *chandef = link->conf->chanreq.oper; ret =0 ; - }else if (!ieee80211_hw_check (&local->hw,NO_VIRTUAL_MONITOR ) && - local->open_count >0 && - local->open_count == local->monitors && + }else if (local->open_count >0 && + local->open_count == local->virt_monitors && sdata->vif.type ==NL80211_IFTYPE_MONITOR ) { *chandef = local->monitor_chanreq.oper; ret =0 ;
net/mac80211/ethtool.c +1 -1
@@ -158,7 +158,7 @@ static void ieee80211_get_stats(struct net_device *dev,if (chanctx_conf) channel = chanctx_conf->def.chan;else if (local->open_count >0 && - local->open_count == local->monitors && + local->open_count == local->virt_monitors && sdata->vif.type ==NL80211_IFTYPE_MONITOR ) channel = local->monitor_chanreq.oper.chan;else
net/mac80211/ieee80211_i.h +1 -1
@@ -1378,7 +1378,7 @@ struct ieee80211_local {spinlock_t queue_stop_reason_lock;int open_count; -int monitors, tx_mntrs; +int monitors, virt_monitors, tx_mntrs;/* number of interfaces with corresponding FIF_ flags */ int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll, fif_probe_req;
net/mac80211/iface.c +13 -9
@@ -582,11 +582,13 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do/* no need to tell driver */ break ;case NL80211_IFTYPE_MONITOR : + local->monitors--; +if (!(sdata->u.mntr.flags &MONITOR_FLAG_ACTIVE ) && !ieee80211_hw_check (&local->hw,NO_VIRTUAL_MONITOR )) { - local->monitors--; -if (local->monitors ==0 ) { + local->virt_monitors--; +if (local->virt_monitors ==0 ) { local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR ; hw_reconf_flags |=IEEE80211_CONF_CHANGE_MONITOR ; }
@@ -686,7 +688,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_docase NL80211_IFTYPE_AP_VLAN :break ;case NL80211_IFTYPE_MONITOR : -if (local->monitors ==0 ) +if (local->virt_monitors ==0 )ieee80211_del_virtual_monitor (local);ieee80211_recalc_idle (local);
@@ -723,7 +725,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_doieee80211_configure_filter (local);ieee80211_hw_config (local, hw_reconf_flags); -if (local->monitors == local->open_count) +if (local->virt_monitors == local->open_count)ieee80211_add_virtual_monitor (local); }
@@ -982,7 +984,7 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat local->hw.wiphy->frag_threshold != (u32)-1) flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED ; -if (local->monitors) +if (local->virt_monitors) flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED ; }else { flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED ;
@@ -992,7 +994,7 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) { flags |= IEEE80211_OFFLOAD_DECAP_ENABLED; - if (local->monitors && + if (local->virt_monitors && !ieee80211_hw_check(&local->hw, SUPPORTS_CONC_MON_RX_DECAP)) flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; } else {
@@ -1336,20 +1338,22 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)if (res) goto err_stop; }else { -if (local->monitors ==0 && local->open_count ==0 ) { +if (local->virt_monitors ==0 && local->open_count ==0 ) { res =ieee80211_add_virtual_monitor (local);if (res) goto err_stop; } - local->monitors++; + local->virt_monitors++;/* must be before the call to ieee80211_configure_filter */ -if (local->monitors ==1 ) { +if (local->virt_monitors ==1 ) { local->hw.conf.flags |=IEEE80211_CONF_MONITOR ; hw_reconf_flags |=IEEE80211_CONF_CHANGE_MONITOR ; } } + local->monitors++; +ieee80211_adjust_monitor_flags (sdata,1 );ieee80211_configure_filter (local);ieee80211_recalc_offload (local);
net/mac80211/util.c +2 -1
@@ -2156,7 +2156,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) wake_up: -if (local->monitors == local->open_count && local->monitors >0 ) +if (local->virt_monitors >0 && + local->virt_monitors == local->open_count)ieee80211_add_virtual_monitor (local);/*
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 641/642 HID: Kconfig: Add LEDS_CLASS_MULTICOLOR dependency to HID_LOGITECH
In reply to Sasha LevinFrom: Kate Hsuan <[email protected]>
[ Upstream commit 4465f4fa21e0e54c10896db3ed49dbd5a9aad3fd ]
The test bot found an issue with building hid-lg-g15.
All errors (new ones prefixed by >>):
powerpc-linux-ld: drivers/hid/hid-lg-g15.o: in function `lg_g510_kbd_led_write':
Quoted 1 line
Quoted 1 line
drivers/hid/hid-lg-g15.c:241:(.text+0x768): undefined reference to `led_mc_calc_color_components'
powerpc-linux-ld: drivers/hid/hid-lg-g15.o: in function `lg_g15_register_led':
Quoted 1 line
Quoted 1 line
drivers/hid/hid-lg-g15.c:686:(.text+0xa9c): undefined reference to `devm_led_classdev_multicolor_register_ext'
Since multicolor LED APIs manage the keyboard backlight settings of hid-lg-g15, the LEDS_CLASS_MULTICOLOR dependency was added to HID_LOGITECH.
--- drivers/hid/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/hid/Kconfig +1 -0
@@ -603,6 +603,7 @@ config HID_LOGITECH tristate "Logitech devices" depends on USB_HID depends on LEDS_CLASS + depends on LEDS_CLASS_MULTICOLOR default !EXPERT help Support for Logitech devices that are not fully compliant with HID standard.
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 642/642 net-sysfs: restore behavior for not running devices
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 75bc3dab4e49b4daccb27ad6ce8ce2fcd253fc1b ]
modprobe dummy dumdummies=1
Old behavior :
$ cat /sys/class/net/dummy0/carrier cat: /sys/class/net/dummy0/carrier: Invalid argument
After blamed commit, an empty string is reported.
$ cat /sys/class/net/dummy0/carrier $
In this commit, I restore the old behavior for carrier, speed and duplex attributes.
--- net/core/net-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/net-sysfs.c +4 -1
@@ -313,12 +313,13 @@ static ssize_t carrier_show(struct device *dev, struct device_attribute *attr, char *buf) { struct net_device *netdev = to_net_dev(dev); -int ret = -EINVAL ; +int ret; ret =sysfs_rtnl_lock (&dev->kobj, &attr->attr, netdev);if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {/* Synchronize carrier state with link watch, * see also rtnl_getlink().
@@ -349,6 +350,7 @@ static ssize_t speed_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;
@@ -376,6 +378,7 @@ static ssize_t duplex_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;
Signature · 1 line
2.39.5