From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Moti Haimovski <mhaimovski@habana.ai>
Subject: [PATCH 7/7] habanalabs: support debugfs Byte access to device DRAM
Date: Mon, 11 Apr 2022 12:08:05 +0300 [thread overview]
Message-ID: <20220411090805.1617112-7-ogabbay@kernel.org> (raw)
In-Reply-To: <20220411090805.1617112-1-ogabbay@kernel.org>
From: Moti Haimovski <mhaimovski@habana.ai>
The habanalabs HW requires memory resources to be used by its
internal hardware structures. These structures are allocated and
initialized by the driver. We would like to use the device HBM for
that purpose. This memory is io-remapped and accessed using the
writel()/writeb()/writew() commands.
Since some of the HW structures are one byte in size we need to
add support for the writeb() and readb() functions in the driver.
Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
drivers/misc/habanalabs/common/debugfs.c | 3 +++
drivers/misc/habanalabs/common/device.c | 12 ++++++++++++
drivers/misc/habanalabs/common/habanalabs.h | 2 ++
3 files changed, 17 insertions(+)
diff --git a/drivers/misc/habanalabs/common/debugfs.c b/drivers/misc/habanalabs/common/debugfs.c
index ffa613af6b0d..7c4a4d504e4c 100644
--- a/drivers/misc/habanalabs/common/debugfs.c
+++ b/drivers/misc/habanalabs/common/debugfs.c
@@ -688,6 +688,9 @@ static void hl_access_host_mem(struct hl_device *hdev, u64 addr, u64 *val,
case DEBUGFS_WRITE64:
*(u64 *) phys_to_virt(addr - offset) = *val;
break;
+ default:
+ dev_err(hdev->dev, "hostmem access-type %d id not supported\n", acc_type);
+ break;
}
}
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c
index 0f4f7e538b61..9d2978e43e51 100644
--- a/drivers/misc/habanalabs/common/device.c
+++ b/drivers/misc/habanalabs/common/device.c
@@ -53,6 +53,14 @@ static int hl_access_sram_dram_region(struct hl_device *hdev, u64 addr, u64 *val
}
switch (acc_type) {
+ case DEBUGFS_READ8:
+ *val = readb(hdev->pcie_bar[region->bar_id] +
+ addr - region->region_base + region->offset_in_bar);
+ break;
+ case DEBUGFS_WRITE8:
+ writeb(*val, hdev->pcie_bar[region->bar_id] +
+ addr - region->region_base + region->offset_in_bar);
+ break;
case DEBUGFS_READ32:
*val = readl(hdev->pcie_bar[region->bar_id] +
addr - region->region_base + region->offset_in_bar);
@@ -148,7 +156,11 @@ int hl_access_cfg_region(struct hl_device *hdev, u64 addr, u64 *val,
WREG32(addr - cfg_region->region_base, lower_32_bits(*val));
WREG32(addr + sizeof(u32) - cfg_region->region_base, upper_32_bits(*val));
break;
+ default:
+ dev_err(hdev->dev, "access type %d is not supported\n", acc_type);
+ return -EOPNOTSUPP;
}
+
return 0;
}
diff --git a/drivers/misc/habanalabs/common/habanalabs.h b/drivers/misc/habanalabs/common/habanalabs.h
index 5f7e584d0f33..a8e6118c0fc7 100644
--- a/drivers/misc/habanalabs/common/habanalabs.h
+++ b/drivers/misc/habanalabs/common/habanalabs.h
@@ -1100,6 +1100,8 @@ enum div_select_defs {
};
enum debugfs_access_type {
+ DEBUGFS_READ8,
+ DEBUGFS_WRITE8,
DEBUGFS_READ32,
DEBUGFS_WRITE32,
DEBUGFS_READ64,
--
2.25.1
prev parent reply other threads:[~2022-04-11 9:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 9:07 [PATCH 1/7] habanalabs: don't print normal reset operations Oded Gabbay
2022-04-11 9:08 ` [PATCH 2/7] habanalabs: remove user interrupt debug print Oded Gabbay
2022-04-11 9:08 ` [PATCH 3/7] habanalabs: fix comments according to kernel-doc Oded Gabbay
2022-04-11 9:08 ` [PATCH 4/7] habanalabs: refactor HOP functions in MMU V1 Oded Gabbay
2022-04-11 9:08 ` [PATCH 5/7] habanalabs/gaudi: use lower_32_bits() for casting Oded Gabbay
2022-04-11 9:08 ` [PATCH 6/7] habanalabs: use for_each_sgtable_dma_sg for dma sgt Oded Gabbay
2022-04-11 9:08 ` Oded Gabbay [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220411090805.1617112-7-ogabbay@kernel.org \
--to=ogabbay@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhaimovski@habana.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox