habanalabs: Avoid using a non-initialized MMU cache mutex
Subsystems (2)
PATCH 1/1 habanalabs: Avoid using a non-initialized MMU cache mutex
From: Tomer Tayar <[email protected]>
The MMU cache mutex is used in the ASIC hw_init() functions, but it is initialized only later in hl_mmu_init().
This patch prevents it by moving the initialization to the device_early_init() function.
--- drivers/misc/habanalabs/device.c | 2 ++ drivers/misc/habanalabs/mmu.c | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/misc/habanalabs/device.c +2 -0
@@ -231,6 +231,7 @@ static int device_early_init(struct hl_device *hdev)mutex_init (&hdev->fd_open_cnt_lock);mutex_init (&hdev->send_cpu_message_lock); +mutex_init (&hdev->mmu_cache_lock);INIT_LIST_HEAD (&hdev->hw_queues_mirror_list);spin_lock_init (&hdev->hw_queues_mirror_lock);atomic_set (&hdev->in_reset,0 );
@@ -260,6 +261,7 @@ static int device_early_init(struct hl_device *hdev)*/ static void device_early_fini (struct hl_device *hdev) { +mutex_destroy (&hdev->mmu_cache_lock);mutex_destroy (&hdev->send_cpu_message_lock);hl_cb_mgr_fini (hdev, &hdev->kernel_cb_mgr);
drivers/misc/habanalabs/mmu.c +1 -7
@@ -404,15 +404,12 @@ int hl_mmu_init(struct hl_device *hdev)/* MMU H/W init was already done in device hw_init() */ -mutex_init (&hdev->mmu_cache_lock); - hdev->mmu_pgt_pool =gen_pool_create (__ffs (prop->mmu_hop_table_size),-1 );if (!hdev->mmu_pgt_pool) {dev_err (hdev->dev,"Failed to create page gen pool\n" ); - rc = -ENOMEM ; - goto err_pool_create; +return -ENOMEM ; } rc = gen_pool_add(hdev->mmu_pgt_pool, prop->mmu_pgt_addr +
@@ -436,8 +433,6 @@ int hl_mmu_init(struct hl_device *hdev) err_pool_add:gen_pool_destroy (hdev->mmu_pgt_pool); -err_pool_create: -mutex_destroy (&hdev->mmu_cache_lock);return rc; }
@@ -459,7 +454,6 @@ void hl_mmu_fini(struct hl_device *hdev)kvfree (hdev->mmu_shadow_hop0);gen_pool_destroy (hdev->mmu_pgt_pool); -mutex_destroy (&hdev->mmu_cache_lock);/* MMU H/W fini will be done in device hw_fini() */ }
Signature · 1 line
2.17.1
Sasha Levin
maintainerQuoted 104 lines · Oded Gabbay
Quoted 103 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.0.15, v4.19.42, v4.14.118, v4.9.175, v4.4.179, v3.18.139.
v5.0.15: Failed to apply! Possible dependencies:
0861e41de530("habanalabs: add context and ASID modules")839c48030d27("habanalabs: add basic Goya h/w initialization")9494a8dd8d22("habanalabs: add h/w queues module")99b9d7b4970c("habanalabs: add basic Goya support")be5d926b5c10("habanalabs: add command buffer module")c4d66343a46a("habanalabs: add skeleton driver")d91389bc839d("habanalabs: add sysfs and hwmon support")eff6f4a0e70b("habanalabs: add command submission module")v4.19.42: Failed to apply! Possible dependencies:
0861e41de530 ("habanalabs: add context and ASID modules") 839c48030d27 ("habanalabs: add basic Goya h/w initialization") 9494a8dd8d22 ("habanalabs: add h/w queues module") 99b9d7b4970c ("habanalabs: add basic Goya support") be5d926b5c10 ("habanalabs: add command buffer module") c4d66343a46a ("habanalabs: add skeleton driver") fcb418cd567f ("pvpanic: move pvpanic to misc as common driver")v4.14.118: Failed to apply! Possible dependencies:
01451ad47e27 ("powerpc/powermac: Use setup_timer() helper") 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") 83ad1e6a1dc0 ("powerpc/oprofile: Use setup_timer() helper") 8d6b1bf20f61 ("powerpc/6xx: Use setup_timer() helper") 9494a8dd8d22 ("habanalabs: add h/w queues module") b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets") b9eaf1872222 ("treewide: init_timer() -> setup_timer()") be5d926b5c10 ("habanalabs: add command buffer module") c4d66343a46a ("habanalabs: add skeleton driver") cd414f3d9316 ("drm/msm: Move memptrs to msm_gpu") e455b69ddf9b ("misc: rtsx: Move Realtek Card Reader Driver to misc") e629cfa36ea0 ("MIPS: Lasat: Use setup_timer() helper") e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()") f97decac5f4c ("drm/msm: Support multiple ringbuffers")v4.9.175: Failed to apply! Possible dependencies:
01451ad47e27 ("powerpc/powermac: Use setup_timer() helper") 118f6523793d ("mfd: rtsx: Convert forgotten dev_info() statement to pcr_dbg()") 53460c53b761 ("[media] au0828: Add timer to restart TS stream if no data arrives on bulk endpoint") 7c96f59e0caf ("[media] s5p-mfc: Fix initialization of internal structures") 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") 83ad1e6a1dc0 ("powerpc/oprofile: Use setup_timer() helper") 87d284443d07 ("mfd: rtsx: Do retry when DMA transfer error") 8d6b1bf20f61 ("powerpc/6xx: Use setup_timer() helper") 9494a8dd8d22 ("habanalabs: add h/w queues module") b9eaf1872222 ("treewide: init_timer() -> setup_timer()") be5d926b5c10 ("habanalabs: add command buffer module") c4d66343a46a ("habanalabs: add skeleton driver") cf43e6be865a ("block: add scalable completion tracking of requests") e26ae3660b9c ("mfd: rtsx: Make arrays depth and cd_mask static const") e455b69ddf9b ("misc: rtsx: Move Realtek Card Reader Driver to misc") e629cfa36ea0 ("MIPS: Lasat: Use setup_timer() helper") e806402130c9 ("block: split out request-only flags into a new namespace") e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")v4.4.179: Failed to apply! Possible dependencies:
118f6523793d ("mfd: rtsx: Convert forgotten dev_info() statement to pcr_dbg()") 53460c53b761 ("[media] au0828: Add timer to restart TS stream if no data arrives on bulk endpoint") 7c96f59e0caf ("[media] s5p-mfc: Fix initialization of internal structures") 80c1bce9aa31 ("[media] au0828: Refactoring for start_urb_transfer()") 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") 87d284443d07 ("mfd: rtsx: Do retry when DMA transfer error") 9494a8dd8d22 ("habanalabs: add h/w queues module") 9815c7cf22da ("NFC: pn533: Separate physical layer from the core implementation") b9eaf1872222 ("treewide: init_timer() -> setup_timer()") be5d926b5c10 ("habanalabs: add command buffer module") c4d66343a46a ("habanalabs: add skeleton driver") e26ae3660b9c ("mfd: rtsx: Make arrays depth and cd_mask static const") e455b69ddf9b ("misc: rtsx: Move Realtek Card Reader Driver to misc") e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")v3.18.139: Failed to apply! Possible dependencies:
0523b8f41473 ("mfd: rtsx: Using pcr_dbg replace dev_dbg") 0b271258544b ("mfd: rt5033: Add Richtek RT5033 driver core.") 19f3bd548f27 ("mfd: rtsx: Remove LCTLR defination") 338a12814297 ("mfd: Add support for Diolan DLN-2 devices") 5cb5d9616a47 ("mfd: rtsx: Fix PM suspend for 5227 & 5249") 663c425f2c8d ("mfd: rtsx: Add support for rts524A") 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") 9494a8dd8d22 ("habanalabs: add h/w queues module") 9e33ce79f828 ("mfd: rtsx: Update PETXCFG address") a3b63979f8a3 ("mfd: rtsx: Add func to split u32 into register") b038538104d5 ("mfd: rtsx: Update phy register") b158b69a3765 ("mfd: rtsx: Simplify function return logic") be5d926b5c10 ("habanalabs: add command buffer module") c4d66343a46a ("habanalabs: add skeleton driver") ce6a5acc9387 ("mfd: rtsx: Add support for rts522A") e455b69ddf9b ("misc: rtsx: Move Realtek Card Reader Driver to misc") e89f231826a7 ("mfd: rtsx: Update driving settings")How should we proceed with this patch?
Quoted 7 lines
Quoted 3 lines
--
Thanks,
Sashaok, I see my mistake.
How do I specify a specific kernel version ?
Because this applies only to future 5.1.X, that aren't available yet.
Take a look at
https://www.kernel.org/doc/Documentation/process/stable-kernel-rules.rst
A "Fixes" tag also helps a lot.
--
Thanks,
Sasha