提交 cf8167ec 编写于 作者: L Longfang Liu 提交者: Zheng Zengkai

vfio/hisilicon: modify QM for live migration driver

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I473Q4?from=project-issue

----------------------------------------------------------------------

Add device status recording function for accelerator live migration driver.
Signed-off-by: NLongfang Liu <liulongfang@huawei.com>
Reviewed-by: NHao Fang <fanghao11@huawei.com>
Reviewed-by: NMingqiang Ling <lingmingqiang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 58754e77
......@@ -3266,6 +3266,13 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id)
return 0;
}
static void hisi_qm_set_state(struct hisi_qm *qm, enum vf_state state)
{
/* set vf driver state */
if (qm->ver > QM_HW_V2)
writel(state, qm->io_base + QM_VF_STATE);
}
static void hisi_qm_pre_init(struct hisi_qm *qm)
{
struct pci_dev *pdev = qm->pdev;
......@@ -3365,6 +3372,8 @@ void hisi_qm_uninit(struct hisi_qm *qm)
qm->qdma.va, qm->qdma.dma);
}
hisi_qm_set_state(qm, VF_NOT_READY);
qm_irq_unregister(qm);
hisi_qm_pci_uninit(qm);
uacce_remove(qm->uacce);
......@@ -3578,6 +3587,8 @@ int hisi_qm_start(struct hisi_qm *qm)
if (!ret)
atomic_set(&qm->status.flags, QM_START);
hisi_qm_set_state(qm, VF_READY);
err_unlock:
up_write(&qm->qps_lock);
return ret;
......@@ -3672,6 +3683,8 @@ int hisi_qm_stop(struct hisi_qm *qm, enum qm_stop_reason r)
struct device *dev = &qm->pdev->dev;
int ret = 0;
hisi_qm_set_state(qm, VF_PREPARE);
down_write(&qm->qps_lock);
qm->status.stop_reason = r;
......@@ -5640,6 +5653,8 @@ static int hisi_qm_pci_init(struct hisi_qm *qm)
goto err_get_pci_res;
pci_set_master(pdev);
hisi_qm_set_state(qm, VF_PREPARE);
if (!qm->ops->get_irq_num) {
ret = -EOPNOTSUPP;
goto err_get_pci_res;
......
......@@ -80,6 +80,7 @@
#define QM_SHAPER_CFG 0x100164
#define QM_SHAPER_ENABLE BIT(30)
#define QM_SHAPER_TYPE1_OFFSET 10
#define QM_VF_STATE 0x0060
/* page number for queue file region */
#define QM_DOORBELL_PAGE_NR 1
......@@ -109,6 +110,12 @@ enum qp_state {
QP_CLOSE,
};
enum vf_state {
VF_READY = 0x0,
VF_NOT_READY,
VF_PREPARE,
};
enum qm_hw_ver {
QM_HW_UNKNOWN = -1,
QM_HW_V1 = 0x20,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册