From nobody Sun Dec 14 11:18:45 2025 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4554B2DC329; Thu, 30 Oct 2025 01:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761789502; cv=none; b=SrxCwLDz0zAh5UTAG7l8k0ephiU4hRm/pIjy07Y+ynux4AH/6czPlS+BJiLB9Ed/LWeq8Je6uvUKefKBV7hppJdrwSr0/wvNyw35jR8iiZXo8iawfApt/w50tOq0Z+NVLVD7IpbtT0CJeWZCq5RuGqByVhoBxXPCWoPYhj4E9II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761789502; c=relaxed/simple; bh=ubFdRZvKZLM2UVfXaM21Z32PIhIQl+TGSP+2aHyVY9c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u43Nh4xwdIRLmO/KGXKh9KXfAaSyvh/mUaqzVXejZV9EcjVoE+rq5D1sGh7pH+5c+5JievW5e3bn197rpEwqxeBzIy7W8N+zQdv1TIGc+iz5T7gf/yewbtFI5QugiRglf2D3Tg7T0S9UkgXfy+Jis6Rpstggu1BgOok96sneAHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=EW6Gp/IG; arc=none smtp.client-ip=113.46.200.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="EW6Gp/IG" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8Rdli7IOcBA5bBhZab0kfFb9r3Yb40uezhOwMZIb5+s=; b=EW6Gp/IGWfFEenSev60tjXBjWJe1Q4v2pefPKMXQdtu9gjO+SxU5kzVmKeW0Aq9AQLJj1yOZX YW1pwdDYDmDRCx39FVGkZpsxtAb97iBMeeXlnpkRA0ChDzJYS22p+S5LavEkNRkqGsfPb9539qV o/WBtDAFgv9oqe/mg10ipa8= Received: from mail.maildlp.com (unknown [172.19.163.252]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4cxnLg1bkXzRhXP; Thu, 30 Oct 2025 09:57:47 +0800 (CST) Received: from dggpemf500015.china.huawei.com (unknown [7.185.36.143]) by mail.maildlp.com (Postfix) with ESMTPS id C52CA180B62; Thu, 30 Oct 2025 09:58:16 +0800 (CST) Received: from huawei.com (10.90.31.46) by dggpemf500015.china.huawei.com (7.185.36.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 30 Oct 2025 09:58:16 +0800 From: Longfang Liu To: , , , , CC: , , , Subject: [PATCH v12 1/2] crypto: hisilicon - qm updates BAR configuration Date: Thu, 30 Oct 2025 09:57:43 +0800 Message-ID: <20251030015744.131771-2-liulongfang@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251030015744.131771-1-liulongfang@huawei.com> References: <20251030015744.131771-1-liulongfang@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemf500015.china.huawei.com (7.185.36.143) Content-Type: text/plain; charset="utf-8" On new platforms greater than QM_HW_V3, the configuration region for the live migration function of the accelerator device is no longer placed in the VF, but is instead placed in the PF. Therefore, the configuration region of the live migration function needs to be opened when the QM driver is loaded. When the QM driver is uninstalled, the driver needs to clear this configuration. Signed-off-by: Longfang Liu Reviewed-by: Shameer Kolothum Acked-by: Herbert Xu --- drivers/crypto/hisilicon/qm.c | 27 +++++++++++++++++++++++++++ include/linux/hisi_acc_qm.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index a5b96adf2d1e..e88085c2cbb3 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -3019,11 +3019,36 @@ static void qm_put_pci_res(struct hisi_qm *qm) pci_release_mem_regions(pdev); } =20 +static void hisi_mig_region_clear(struct hisi_qm *qm) +{ + u32 val; + + /* Clear migration region set of PF */ + if (qm->fun_type =3D=3D QM_HW_PF && qm->ver > QM_HW_V3) { + val =3D readl(qm->io_base + QM_MIG_REGION_SEL); + val &=3D ~QM_MIG_REGION_EN; + writel(val, qm->io_base + QM_MIG_REGION_SEL); + } +} + +static void hisi_mig_region_enable(struct hisi_qm *qm) +{ + u32 val; + + /* Select migration region of PF */ + if (qm->fun_type =3D=3D QM_HW_PF && qm->ver > QM_HW_V3) { + val =3D readl(qm->io_base + QM_MIG_REGION_SEL); + val |=3D QM_MIG_REGION_EN; + writel(val, qm->io_base + QM_MIG_REGION_SEL); + } +} + static void hisi_qm_pci_uninit(struct hisi_qm *qm) { struct pci_dev *pdev =3D qm->pdev; =20 pci_free_irq_vectors(pdev); + hisi_mig_region_clear(qm); qm_put_pci_res(qm); pci_disable_device(pdev); } @@ -5725,6 +5750,7 @@ int hisi_qm_init(struct hisi_qm *qm) goto err_free_qm_memory; =20 qm_cmd_init(qm); + hisi_mig_region_enable(qm); =20 return 0; =20 @@ -5863,6 +5889,7 @@ static int qm_rebuild_for_resume(struct hisi_qm *qm) } =20 qm_cmd_init(qm); + hisi_mig_region_enable(qm); hisi_qm_dev_err_init(qm); /* Set the doorbell timeout to QM_DB_TIMEOUT_CFG ns. */ writel(QM_DB_TIMEOUT_SET, qm->io_base + QM_DB_TIMEOUT_CFG); diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h index c4690e365ade..ca1ec437a3ca 100644 --- a/include/linux/hisi_acc_qm.h +++ b/include/linux/hisi_acc_qm.h @@ -99,6 +99,9 @@ =20 #define QM_DEV_ALG_MAX_LEN 256 =20 +#define QM_MIG_REGION_SEL 0x100198 +#define QM_MIG_REGION_EN BIT(0) + /* uacce mode of the driver */ #define UACCE_MODE_NOUACCE 0 /* don't use uacce */ #define UACCE_MODE_SVA 1 /* use uacce sva mode */ --=20 2.33.0