From: Longfang Liu <liulongfang@huawei.com>
To: <alex.williamson@redhat.com>, <jgg@nvidia.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<liulongfang@huawei.com>
Subject: [PATCH] hisi_acc_vfio_pci: simplify the command for reading device information.
Date: Thu, 14 May 2026 17:20:26 +0800 [thread overview]
Message-ID: <20260514092026.2018844-1-liulongfang@huawei.com> (raw)
From: Weili Qian <qianweili@huawei.com>
The mailbox operation for the Hisi accelerator device now
provides a new read function that supports direct information retrieval
by specifying commands, thereby simplifying the related mailbox command
handling in the driver.
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 39 ++-----------------
1 file changed, 3 insertions(+), 36 deletions(-)
diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
index bb121f635b9f..86362ec424a5 100644
--- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
+++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
@@ -81,13 +81,10 @@ static int qm_get_vft(struct hisi_qm *qm, u32 *base)
u32 qp_num;
int ret;
- ret = hisi_qm_mb(qm, QM_MB_CMD_SQC_VFT_V2, 0, 0, 1);
+ ret = hisi_qm_mb_read(qm, &sqc_vft, QM_MB_CMD_SQC_VFT_V2, 0);
if (ret)
return ret;
- sqc_vft = readl(qm->io_base + QM_MB_CMD_DATA_ADDR_L) |
- ((u64)readl(qm->io_base + QM_MB_CMD_DATA_ADDR_H) <<
- QM_XQC_ADDR_OFFSET);
*base = QM_SQC_VFT_BASE_MASK_V2 & (sqc_vft >> QM_SQC_VFT_BASE_SHIFT_V2);
qp_num = (QM_SQC_VFT_NUM_MASK_V2 &
(sqc_vft >> QM_SQC_VFT_NUM_SHIFT_V2)) + 1;
@@ -95,36 +92,6 @@ static int qm_get_vft(struct hisi_qm *qm, u32 *base)
return qp_num;
}
-static int qm_get_sqc(struct hisi_qm *qm, u64 *addr)
-{
- int ret;
-
- ret = hisi_qm_mb(qm, QM_MB_CMD_SQC_BT, 0, 0, 1);
- if (ret)
- return ret;
-
- *addr = readl(qm->io_base + QM_MB_CMD_DATA_ADDR_L) |
- ((u64)readl(qm->io_base + QM_MB_CMD_DATA_ADDR_H) <<
- QM_XQC_ADDR_OFFSET);
-
- return 0;
-}
-
-static int qm_get_cqc(struct hisi_qm *qm, u64 *addr)
-{
- int ret;
-
- ret = hisi_qm_mb(qm, QM_MB_CMD_CQC_BT, 0, 0, 1);
- if (ret)
- return ret;
-
- *addr = readl(qm->io_base + QM_MB_CMD_DATA_ADDR_L) |
- ((u64)readl(qm->io_base + QM_MB_CMD_DATA_ADDR_H) <<
- QM_XQC_ADDR_OFFSET);
-
- return 0;
-}
-
static void qm_xqc_reg_offsets(struct hisi_qm *qm,
u32 *eqc_addr, u32 *aeqc_addr)
{
@@ -575,13 +542,13 @@ static int vf_qm_read_data(struct hisi_qm *vf_qm, struct acc_vf_data *vf_data)
vf_data->aeqe_dma |= vf_data->qm_aeqc_dw[QM_XQC_ADDR_LOW];
/* Through SQC_BT/CQC_BT to get sqc and cqc address */
- ret = qm_get_sqc(vf_qm, &vf_data->sqc_dma);
+ ret = hisi_qm_mb_read(vf_qm, &vf_data->sqc_dma, QM_MB_CMD_SQC_BT, 0);
if (ret) {
dev_err(dev, "failed to read SQC addr!\n");
return ret;
}
- ret = qm_get_cqc(vf_qm, &vf_data->cqc_dma);
+ ret = hisi_qm_mb_read(vf_qm, &vf_data->cqc_dma, QM_MB_CMD_CQC_BT, 0);
if (ret) {
dev_err(dev, "failed to read CQC addr!\n");
return ret;
--
2.43.0
next reply other threads:[~2026-05-14 9:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 9:20 Longfang Liu [this message]
2026-05-20 21:11 ` Alex Williamson
2026-05-21 1:31 ` liulongfang
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=20260514092026.2018844-1-liulongfang@huawei.com \
--to=liulongfang@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=jgg@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®