habanalabs: remove power9 workaround for dma support
[linux-2.6-microblaze.git] / drivers / misc / habanalabs / common / habanalabs.h
index cb710fd..6c7a602 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0
  *
- * Copyright 2016-2021 HabanaLabs, Ltd.
+ * Copyright 2016-2022 HabanaLabs, Ltd.
  * All Rights Reserved.
  *
  */
@@ -402,8 +402,11 @@ enum hl_device_hw_state {
  * @hop4_mask: mask to get the PTE address in hop 4.
  * @hop5_mask: mask to get the PTE address in hop 5.
  * @last_mask: mask to get the bit indicating this is the last hop.
+ * @pgt_size: size for page tables.
  * @page_size: default page size used to allocate memory.
  * @num_hops: The amount of hops supported by the translation table.
+ * @hop_table_size: HOP table size.
+ * @hop0_tables_total_size: total size for all HOP0 tables.
  * @host_resident: Should the MMU page table reside in host memory or in the
  *                 device DRAM.
  */
@@ -423,8 +426,11 @@ struct hl_mmu_properties {
        u64     hop4_mask;
        u64     hop5_mask;
        u64     last_mask;
+       u64     pgt_size;
        u32     page_size;
        u32     num_hops;
+       u32     hop_table_size;
+       u32     hop0_tables_total_size;
        u8      host_resident;
 };
 
@@ -1155,7 +1161,6 @@ struct fw_load_mgr {
  *                    internal memory via DMA engine.
  * @add_device_attr: add ASIC specific device attributes.
  * @handle_eqe: handle event queue entry (IRQ) from CPU-CP.
- * @set_pll_profile: change PLL profile (manual/automatic).
  * @get_events_stat: retrieve event queue entries histogram.
  * @read_pte: read MMU page table entry from DRAM.
  * @write_pte: write MMU page table entry to DRAM.
@@ -1164,9 +1169,6 @@ struct fw_load_mgr {
  * @mmu_invalidate_cache_range: flush specific MMU STLB cache lines with
  *                              ASID-VA-size mask.
  * @send_heartbeat: send is-alive packet to CPU-CP and verify response.
- * @set_clock_gating: enable/disable clock gating per engine according to
- *                    clock gating mask in hdev
- * @disable_clock_gating: disable clock gating completely
  * @debug_coresight: perform certain actions on Coresight for debugging.
  * @is_device_idle: return true if device is idle, false otherwise.
  * @non_hard_reset_late_init: perform certain actions needed after a reset which is not hard-reset
@@ -1187,7 +1189,6 @@ struct fw_load_mgr {
  * @halt_coresight: stop the ETF and ETR traces.
  * @ctx_init: context dependent initialization.
  * @ctx_fini: context dependent cleanup.
- * @get_clk_rate: Retrieve the ASIC current and maximum clock rate in MHz
  * @get_queue_id_for_cq: Get the H/W queue id related to the given CQ index.
  * @load_firmware_to_device: load the firmware to the device's memory
  * @load_boot_fit_to_device: load boot fit to device's memory
@@ -1285,12 +1286,10 @@ struct hl_asic_funcs {
                                bool user_address, u64 val);
        int (*debugfs_read_dma)(struct hl_device *hdev, u64 addr, u32 size,
                                void *blob_addr);
-       void (*add_device_attr)(struct hl_device *hdev,
-                               struct attribute_group *dev_attr_grp);
+       void (*add_device_attr)(struct hl_device *hdev, struct attribute_group *dev_clk_attr_grp,
+                               struct attribute_group *dev_vrm_attr_grp);
        void (*handle_eqe)(struct hl_device *hdev,
                                struct hl_eq_entry *eq_entry);
-       void (*set_pll_profile)(struct hl_device *hdev,
-                       enum hl_pll_frequency freq);
        void* (*get_events_stat)(struct hl_device *hdev, bool aggregate,
                                u32 *size);
        u64 (*read_pte)(struct hl_device *hdev, u64 addr);
@@ -1300,8 +1299,6 @@ struct hl_asic_funcs {
        int (*mmu_invalidate_cache_range)(struct hl_device *hdev, bool is_hard,
                                u32 flags, u32 asid, u64 va, u64 size);
        int (*send_heartbeat)(struct hl_device *hdev);
-       void (*set_clock_gating)(struct hl_device *hdev);
-       void (*disable_clock_gating)(struct hl_device *hdev);
        int (*debug_coresight)(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
        bool (*is_device_idle)(struct hl_device *hdev, u64 *mask_arr,
                                        u8 mask_len, struct seq_file *s);
@@ -1320,7 +1317,6 @@ struct hl_asic_funcs {
        void (*halt_coresight)(struct hl_device *hdev, struct hl_ctx *ctx);
        int (*ctx_init)(struct hl_ctx *ctx);
        void (*ctx_fini)(struct hl_ctx *ctx);
-       int (*get_clk_rate)(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk);
        u32 (*get_queue_id_for_cq)(struct hl_device *hdev, u32 cq_idx);
        int (*load_firmware_to_device)(struct hl_device *hdev);
        int (*load_boot_fit_to_device)(struct hl_device *hdev);
@@ -2569,9 +2565,6 @@ struct hl_reset_info {
  * @max_power: the max power of the device, as configured by the sysadmin. This
  *             value is saved so in case of hard-reset, the driver will restore
  *             this value and update the F/W after the re-initialization
- * @clock_gating_mask: is clock gating enabled. bitmask that represents the
- *                     different engines. See debugfs-driver-habanalabs for
- *                     details.
  * @boot_error_status_mask: contains a mask of the device boot error status.
  *                          Each bit represents a different error, according to
  *                          the defines in hl_boot_if.h. If the bit is cleared,
@@ -2611,8 +2604,6 @@ struct hl_reset_info {
  * @in_debug: whether the device is in a state where the profiling/tracing infrastructure
  *            can be used. This indication is needed because in some ASICs we need to do
  *            specific operations to enable that infrastructure.
- * @power9_64bit_dma_enable: true to enable 64-bit DMA mask support. Relevant
- *                           only to POWER9 machines.
  * @cdev_sysfs_created: were char devices and sysfs nodes created.
  * @stop_on_err: true if engines should stop on error.
  * @supports_sync_stream: is sync stream supported.
@@ -2710,7 +2701,6 @@ struct hl_device {
        atomic64_t                      dram_used_mem;
        u64                             timeout_jiffies;
        u64                             max_power;
-       u64                             clock_gating_mask;
        u64                             boot_error_status_mask;
        u64                             dram_pci_bar_start;
        u64                             last_successful_open_jif;
@@ -2736,7 +2726,6 @@ struct hl_device {
        u8                              device_cpu_disabled;
        u8                              dma_mask;
        u8                              in_debug;
-       u8                              power9_64bit_dma_enable;
        u8                              cdev_sysfs_created;
        u8                              stop_on_err;
        u8                              supports_sync_stream;
@@ -3024,6 +3013,9 @@ int hl_mmu_unmap_contiguous(struct hl_ctx *ctx, u64 virt_addr, u32 size);
 int hl_mmu_invalidate_cache(struct hl_device *hdev, bool is_hard, u32 flags);
 int hl_mmu_invalidate_cache_range(struct hl_device *hdev, bool is_hard,
                                        u32 flags, u32 asid, u64 va, u64 size);
+u64 hl_mmu_get_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte);
+u64 hl_mmu_get_hop_pte_phys_addr(struct hl_ctx *ctx, struct hl_mmu_properties *mmu_prop,
+                                       u8 hop_idx, u64 hop_addr, u64 virt_addr);
 void hl_mmu_swap_out(struct hl_ctx *ctx);
 void hl_mmu_swap_in(struct hl_ctx *ctx);
 int hl_mmu_if_set_funcs(struct hl_device *hdev);
@@ -3094,39 +3086,26 @@ enum pci_region hl_get_pci_memory_region(struct hl_device *hdev, u64 addr);
 int hl_pci_init(struct hl_device *hdev);
 void hl_pci_fini(struct hl_device *hdev);
 
-long hl_get_frequency(struct hl_device *hdev, u32 pll_index,
-                                                               bool curr);
-void hl_set_frequency(struct hl_device *hdev, u32 pll_index,
-                                                               u64 freq);
-int hl_get_temperature(struct hl_device *hdev,
-                      int sensor_index, u32 attr, long *value);
-int hl_set_temperature(struct hl_device *hdev,
-                      int sensor_index, u32 attr, long value);
-int hl_get_voltage(struct hl_device *hdev,
-                  int sensor_index, u32 attr, long *value);
-int hl_get_current(struct hl_device *hdev,
-                  int sensor_index, u32 attr, long *value);
-int hl_get_fan_speed(struct hl_device *hdev,
-                    int sensor_index, u32 attr, long *value);
-int hl_get_pwm_info(struct hl_device *hdev,
-                   int sensor_index, u32 attr, long *value);
-void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
-                       long value);
-u64 hl_get_max_power(struct hl_device *hdev);
-void hl_set_max_power(struct hl_device *hdev);
-int hl_set_voltage(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_set_current(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_set_power(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_get_power(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long *value);
-int hl_get_clk_rate(struct hl_device *hdev,
-                       u32 *cur_clk, u32 *max_clk);
-void hl_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq);
-void hl_add_device_attr(struct hl_device *hdev,
-                       struct attribute_group *dev_attr_grp);
+long hl_fw_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr);
+void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq);
+int hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_set_temperature(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+u64 hl_fw_get_max_power(struct hl_device *hdev);
+void hl_fw_set_max_power(struct hl_device *hdev);
+int hl_set_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_set_current(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_set_power(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_get_power(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_fw_get_clk_rate(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk);
+void hl_fw_set_pll_profile(struct hl_device *hdev);
+void hl_sysfs_add_dev_clk_attr(struct hl_device *hdev, struct attribute_group *dev_clk_attr_grp);
+void hl_sysfs_add_dev_vrm_attr(struct hl_device *hdev, struct attribute_group *dev_vrm_attr_grp);
+
 void hw_sob_get(struct hl_hw_sob *hw_sob);
 void hw_sob_put(struct hl_hw_sob *hw_sob);
 void hl_encaps_handle_do_release(struct kref *ref);