Skip to content

Commit 1e459b2

Browse files
Longfang LiuAlex Williamson
authored andcommitted
crypto: hisilicon/qm: Set the VF QM state register
We use VF QM state register to record the status of the QM configuration state. This will be used in the ACC migration driver to determine whether we can safely save and restore the QM data. Signed-off-by: Longfang Liu <liulongfang@huawei.com> Acked-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Link: https://lore.kernel.org/r/20220308184902.2242-8-shameerali.kolothum.thodi@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 442fbc0 commit 1e459b2

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/crypto/hisilicon/qm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,6 +3492,12 @@ static void hisi_qm_pci_uninit(struct hisi_qm *qm)
34923492
pci_disable_device(pdev);
34933493
}
34943494

3495+
static void hisi_qm_set_state(struct hisi_qm *qm, u8 state)
3496+
{
3497+
if (qm->ver > QM_HW_V2 && qm->fun_type == QM_HW_VF)
3498+
writel(state, qm->io_base + QM_VF_STATE);
3499+
}
3500+
34953501
/**
34963502
* hisi_qm_uninit() - Uninitialize qm.
34973503
* @qm: The qm needed uninit.
@@ -3520,6 +3526,7 @@ void hisi_qm_uninit(struct hisi_qm *qm)
35203526
dma_free_coherent(dev, qm->qdma.size,
35213527
qm->qdma.va, qm->qdma.dma);
35223528
}
3529+
hisi_qm_set_state(qm, QM_NOT_READY);
35233530
up_write(&qm->qps_lock);
35243531

35253532
qm_irq_unregister(qm);
@@ -3745,6 +3752,7 @@ int hisi_qm_start(struct hisi_qm *qm)
37453752
if (!ret)
37463753
atomic_set(&qm->status.flags, QM_START);
37473754

3755+
hisi_qm_set_state(qm, QM_READY);
37483756
err_unlock:
37493757
up_write(&qm->qps_lock);
37503758
return ret;

include/linux/hisi_acc_qm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define QM_DB_RAND_SHIFT_V2 16
6868
#define QM_DB_INDEX_SHIFT_V2 32
6969
#define QM_DB_PRIORITY_SHIFT_V2 48
70+
#define QM_VF_STATE 0x60
7071

7172
/* qm cache */
7273
#define QM_CACHE_CTL 0x100050
@@ -162,6 +163,11 @@ enum qm_debug_file {
162163
DEBUG_FILE_NUM,
163164
};
164165

166+
enum qm_vf_state {
167+
QM_READY = 0,
168+
QM_NOT_READY,
169+
};
170+
165171
struct qm_dfx {
166172
atomic64_t err_irq_cnt;
167173
atomic64_t aeq_irq_cnt;

0 commit comments

Comments
 (0)