habanalabs: trace LBW reads/writes
authorOhad Sharabi <osharabi@habana.ai>
Wed, 30 Nov 2022 12:41:49 +0000 (14:41 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Thu, 26 Jan 2023 09:52:11 +0000 (11:52 +0200)
Add traces to LBW reads/writes.
This may be handy when debugging configuration failure or events when
tracking configuration flow.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/accel/habanalabs/common/device.c
drivers/accel/habanalabs/common/pci/pci.c

index 6a05ab3fda236f618d7eb01dc863a98e91b364d4..722a5beb097478f35d0fa9e882a5f4391da82adf 100644 (file)
@@ -2401,7 +2401,12 @@ void hl_device_fini(struct hl_device *hdev)
  */
 inline u32 hl_rreg(struct hl_device *hdev, u32 reg)
 {
-       return readl(hdev->rmmio + reg);
+       u32 val = readl(hdev->rmmio + reg);
+
+       if (unlikely(trace_habanalabs_rreg32_enabled()))
+               trace_habanalabs_rreg32(hdev->dev, reg, val);
+
+       return val;
 }
 
 /*
@@ -2416,6 +2421,9 @@ inline u32 hl_rreg(struct hl_device *hdev, u32 reg)
  */
 inline void hl_wreg(struct hl_device *hdev, u32 reg, u32 val)
 {
+       if (unlikely(trace_habanalabs_wreg32_enabled()))
+               trace_habanalabs_wreg32(hdev->dev, reg, val);
+
        writel(val, hdev->rmmio + reg);
 }
 
index 5fe3da5fba306acfd9b9a8679ae749690a67d07c..d1f4c695baf22d63a18f97cda3efb1e751025105 100644 (file)
@@ -10,6 +10,8 @@
 
 #include <linux/pci.h>
 
+#include <trace/events/habanalabs.h>
+
 #define HL_PLDM_PCI_ELBI_TIMEOUT_MSEC  (HL_PCI_ELBI_TIMEOUT_MSEC * 100)
 
 #define IATU_REGION_CTRL_REGION_EN_MASK                BIT(31)
@@ -120,6 +122,9 @@ int hl_pci_elbi_read(struct hl_device *hdev, u64 addr, u32 *data)
        if ((val & PCI_CONFIG_ELBI_STS_MASK) == PCI_CONFIG_ELBI_STS_DONE) {
                pci_read_config_dword(pdev, mmPCI_CONFIG_ELBI_DATA, data);
 
+               if (unlikely(trace_habanalabs_elbi_read_enabled()))
+                       trace_habanalabs_elbi_read(hdev->dev, (u32) addr, val);
+
                return 0;
        }
 
@@ -179,8 +184,11 @@ static int hl_pci_elbi_write(struct hl_device *hdev, u64 addr, u32 data)
                usleep_range(300, 500);
        }
 
-       if ((val & PCI_CONFIG_ELBI_STS_MASK) == PCI_CONFIG_ELBI_STS_DONE)
+       if ((val & PCI_CONFIG_ELBI_STS_MASK) == PCI_CONFIG_ELBI_STS_DONE) {
+               if (unlikely(trace_habanalabs_elbi_write_enabled()))
+                       trace_habanalabs_elbi_write(hdev->dev, (u32) addr, val);
                return 0;
+       }
 
        if (val & PCI_CONFIG_ELBI_STS_ERR)
                return -EIO;