habanalabs: remove all kdma locks
authorOded Gabbay <ogabbay@kernel.org>
Tue, 19 Jul 2022 09:16:01 +0000 (12:16 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Sun, 18 Sep 2022 10:29:50 +0000 (13:29 +0300)
We don't use KDMA concurrently in the driver. The only use is through
debugfs and we don't protect concurrent access through it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/gaudi/gaudi.c
drivers/misc/habanalabs/gaudi2/gaudi2.c
drivers/misc/habanalabs/gaudi2/gaudi2P.h
drivers/misc/habanalabs/goya/goya.c

index d3efec6..8d9e96c 100644 (file)
@@ -1452,8 +1452,6 @@ struct engines_data {
  * @compute_reset_late_init: perform certain actions needed after a compute reset
  * @hw_queues_lock: acquire H/W queues lock.
  * @hw_queues_unlock: release H/W queues lock.
- * @kdma_lock: acquire H/W queues lock. Relevant from GRECO ASIC
- * @kdma_unlock: release H/W queues lock. Relevant from GRECO ASIC
  * @get_pci_id: retrieve PCI ID.
  * @get_eeprom_data: retrieve EEPROM data from F/W.
  * @get_monitor_dump: retrieve monitor registers dump from F/W.
@@ -1590,8 +1588,6 @@ struct hl_asic_funcs {
        int (*compute_reset_late_init)(struct hl_device *hdev);
        void (*hw_queues_lock)(struct hl_device *hdev);
        void (*hw_queues_unlock)(struct hl_device *hdev);
-       void (*kdma_lock)(struct hl_device *hdev, int dcore_id);
-       void (*kdma_unlock)(struct hl_device *hdev, int dcore_id);
        u32 (*get_pci_id)(struct hl_device *hdev);
        int (*get_eeprom_data)(struct hl_device *hdev, void *data, size_t max_size);
        int (*get_monitor_dump)(struct hl_device *hdev, void *data);
index 20f6273..4d11efe 100644 (file)
@@ -9196,8 +9196,6 @@ static const struct hl_asic_funcs gaudi_funcs = {
        .compute_reset_late_init = gaudi_compute_reset_late_init,
        .hw_queues_lock = gaudi_hw_queues_lock,
        .hw_queues_unlock = gaudi_hw_queues_unlock,
-       .kdma_lock = NULL,
-       .kdma_unlock = NULL,
        .get_pci_id = gaudi_get_pci_id,
        .get_eeprom_data = gaudi_get_eeprom_data,
        .get_monitor_dump = gaudi_get_monitor_dump,
index 3531a33..2c43ed4 100644 (file)
@@ -3010,7 +3010,6 @@ static int gaudi2_sw_init(struct hl_device *hdev)
        }
 
        spin_lock_init(&gaudi2->hw_queues_lock);
-       spin_lock_init(&gaudi2->kdma_lock);
 
        gaudi2->scratchpad_kernel_address = hl_asic_dma_alloc_coherent(hdev, PAGE_SIZE,
                                                        &gaudi2->scratchpad_bus_address,
@@ -6464,22 +6463,6 @@ static void gaudi2_hw_queues_unlock(struct hl_device *hdev)
        spin_unlock(&gaudi2->hw_queues_lock);
 }
 
-static void gaudi2_kdma_lock(struct hl_device *hdev, int dcore_id)
-       __acquires(&gaudi2->kdma_lock)
-{
-       struct gaudi2_device *gaudi2 = hdev->asic_specific;
-
-       spin_lock(&gaudi2->kdma_lock);
-}
-
-static void gaudi2_kdma_unlock(struct hl_device *hdev, int dcore_id)
-       __releases(&gaudi2->kdma_lock)
-{
-       struct gaudi2_device *gaudi2 = hdev->asic_specific;
-
-       spin_unlock(&gaudi2->kdma_lock);
-}
-
 static u32 gaudi2_get_pci_id(struct hl_device *hdev)
 {
        return hdev->pdev->device;
@@ -9122,8 +9105,6 @@ static int gaudi2_debugfs_read_dma(struct hl_device *hdev, u64 addr, u32 size, v
                goto unreserve_va;
        }
 
-       hdev->asic_funcs->kdma_lock(hdev, 0);
-
        /* Enable MMU on KDMA */
        gaudi2_kdma_set_mmbp_asid(hdev, false, ctx->asid);
 
@@ -9151,8 +9132,6 @@ static int gaudi2_debugfs_read_dma(struct hl_device *hdev, u64 addr, u32 size, v
 
        gaudi2_kdma_set_mmbp_asid(hdev, true, HL_KERNEL_ASID_ID);
 
-       hdev->asic_funcs->kdma_unlock(hdev, 0);
-
        mutex_lock(&ctx->mmu_lock);
        hl_mmu_unmap_contiguous(ctx, reserved_va_base, SZ_2M);
        hl_mmu_invalidate_cache_range(hdev, false, MMU_OP_USERPTR,
@@ -9951,8 +9930,6 @@ static const struct hl_asic_funcs gaudi2_funcs = {
        .compute_reset_late_init = gaudi2_compute_reset_late_init,
        .hw_queues_lock = gaudi2_hw_queues_lock,
        .hw_queues_unlock = gaudi2_hw_queues_unlock,
-       .kdma_lock = gaudi2_kdma_lock,
-       .kdma_unlock = gaudi2_kdma_unlock,
        .get_pci_id = gaudi2_get_pci_id,
        .get_eeprom_data = gaudi2_get_eeprom_data,
        .get_monitor_dump = gaudi2_get_monitor_dump,
index 5110574..347ea1d 100644 (file)
@@ -457,7 +457,6 @@ struct dup_block_ctx {
  *                 the user can map.
  * @lfsr_rand_seeds: array of MME ACC random seeds to set.
  * @hw_queues_lock: protects the H/W queues from concurrent access.
- * @kdma_lock: protects the KDMA engine from concurrent access.
  * @scratchpad_kernel_address: general purpose PAGE_SIZE contiguous memory,
  *                             this memory region should be write-only.
  *                             currently used for HBW QMAN writes which is
@@ -509,7 +508,6 @@ struct dup_block_ctx {
  * @flush_db_fifo: flag to force flush DB FIFO after a write.
  * @hbm_cfg: HBM subsystem settings
  * @hw_queues_lock_mutex: used by simulator instead of hw_queues_lock.
- * @kdma_lock_mutex: used by simulator instead of kdma_lock.
  */
 struct gaudi2_device {
        int (*cpucp_info_get)(struct hl_device *hdev);
@@ -518,7 +516,6 @@ struct gaudi2_device {
        int                             lfsr_rand_seeds[MME_NUM_OF_LFSR_SEEDS];
 
        spinlock_t                      hw_queues_lock;
-       spinlock_t                      kdma_lock;
 
        void                            *scratchpad_kernel_address;
        dma_addr_t                      scratchpad_bus_address;
index d4459c2..91429d6 100644 (file)
@@ -5481,8 +5481,6 @@ static const struct hl_asic_funcs goya_funcs = {
        .compute_reset_late_init = goya_compute_reset_late_init,
        .hw_queues_lock = goya_hw_queues_lock,
        .hw_queues_unlock = goya_hw_queues_unlock,
-       .kdma_lock = NULL,
-       .kdma_unlock = NULL,
        .get_pci_id = goya_get_pci_id,
        .get_eeprom_data = goya_get_eeprom_data,
        .get_monitor_dump = goya_get_monitor_dump,