From nobody Fri Apr 3 09:52:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3317C6FA82 for ; Thu, 15 Sep 2022 01:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbiIOBhT (ORCPT ); Wed, 14 Sep 2022 21:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbiIOBhP (ORCPT ); Wed, 14 Sep 2022 21:37:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 895A98C460 for ; Wed, 14 Sep 2022 18:37:14 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSfpD4RmtzNmGP; Thu, 15 Sep 2022 09:32:36 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 15 Sep 2022 09:37:12 +0800 Received: from huawei.com (10.69.192.56) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 15 Sep 2022 09:37:12 +0800 From: Longfang Liu To: , , CC: , , , Subject: [PATCH 5/5] hisi_acc_vfio_pci: Fix some clean code issues Date: Thu, 15 Sep 2022 09:31:57 +0800 Message-ID: <20220915013157.60771-6-liulongfang@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220915013157.60771-1-liulongfang@huawei.com> References: <20220915013157.60771-1-liulongfang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 1.Fix some code comments 2.Fix some code style issues 3.Delete an unused macro definition Signed-off-by: Longfang Liu --- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 40 +++++++++---------- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 1 - 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index fce49c7f5db8..c4857e171da9 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -426,10 +426,10 @@ static int vf_qm_get_match_data(struct hisi_acc_vf_co= re_device *hisi_acc_vdev, int ret; =20 vf_data->acc_magic =3D ACC_DEV_MAGIC; - /* save device id */ + /* Save device id */ vf_data->dev_id =3D hisi_acc_vdev->vf_dev->device; =20 - /* vf qp num save from PF */ + /* VF qp num save from PF */ ret =3D pf_qm_get_qp_num(pf_qm, vf_id, &vf_data->qp_base); if (ret <=3D 0) { dev_err(dev, "failed to get vft qp nums!\n"); @@ -473,19 +473,19 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_de= vice *hisi_acc_vdev, =20 ret =3D qm_set_regs(qm, vf_data); if (ret) { - dev_err(dev, "Set VF regs failed\n"); + dev_err(dev, "set VF regs failed\n"); return ret; } =20 ret =3D hisi_qm_mb(qm, QM_MB_CMD_SQC_BT, qm->sqc_dma, 0, 0); if (ret) { - dev_err(dev, "Set sqc failed\n"); + dev_err(dev, "set sqc failed\n"); return ret; } =20 ret =3D hisi_qm_mb(qm, QM_MB_CMD_CQC_BT, qm->cqc_dma, 0, 0); if (ret) { - dev_err(dev, "Set cqc failed\n"); + dev_err(dev, "set cqc failed\n"); return ret; } =20 @@ -640,15 +640,16 @@ static void hisi_acc_vf_disable_fds(struct hisi_acc_v= f_core_device *hisi_acc_vde static void hisi_acc_vf_state_mutex_unlock(struct hisi_acc_vf_core_device *hisi_acc_vd= ev) { -again: - spin_lock(&hisi_acc_vdev->reset_lock); - if (hisi_acc_vdev->deferred_reset) { + while (true) { + spin_lock(&hisi_acc_vdev->reset_lock); + if (!hisi_acc_vdev->deferred_reset) + break; + hisi_acc_vdev->deferred_reset =3D false; spin_unlock(&hisi_acc_vdev->reset_lock); hisi_acc_vdev->vf_qm_state =3D QM_NOT_READY; hisi_acc_vdev->mig_state =3D VFIO_DEVICE_STATE_RUNNING; hisi_acc_vf_disable_fds(hisi_acc_vdev); - goto again; } mutex_unlock(&hisi_acc_vdev->state_mutex); spin_unlock(&hisi_acc_vdev->reset_lock); @@ -709,10 +710,9 @@ static ssize_t hisi_acc_vf_resume_write(struct file *f= ilp, const char __user *bu =20 if (pos) return -ESPIPE; - pos =3D &filp->f_pos; =20 - if (*pos < 0 || - check_add_overflow((loff_t)len, *pos, &requested_length)) + if (filp->f_pos < 0 || + check_add_overflow((loff_t)len, filp->f_pos, &requested_length)) return -EINVAL; =20 if (requested_length > sizeof(struct acc_vf_data)) @@ -729,7 +729,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *fi= lp, const char __user *bu done =3D -EFAULT; goto out_unlock; } - *pos +=3D len; + filp->f_pos +=3D len; done =3D len; migf->total_length +=3D len; out_unlock: @@ -772,14 +772,14 @@ static ssize_t hisi_acc_vf_save_read(struct file *fil= p, char __user *buf, size_t { struct hisi_acc_vf_migration_file *migf =3D filp->private_data; ssize_t done =3D 0; + size_t min_len; int ret; =20 if (pos) return -ESPIPE; - pos =3D &filp->f_pos; =20 mutex_lock(&migf->lock); - if (*pos > migf->total_length) { + if (filp->f_pos > migf->total_length) { done =3D -EINVAL; goto out_unlock; } @@ -789,15 +789,15 @@ static ssize_t hisi_acc_vf_save_read(struct file *fil= p, char __user *buf, size_t goto out_unlock; } =20 - len =3D min_t(size_t, migf->total_length - *pos, len); - if (len) { - ret =3D copy_to_user(buf, &migf->vf_data, len); + min_len =3D min_t(size_t, migf->total_length - filp->f_pos, len); + if (min_len) { + ret =3D copy_to_user(buf, &migf->vf_data, min_len); if (ret) { done =3D -EFAULT; goto out_unlock; } - *pos +=3D len; - done =3D len; + filp->f_pos +=3D min_len; + done =3D min_len; } out_unlock: mutex_unlock(&migf->lock); diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.h index 5494f4983bbe..8e4bf21deae1 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h @@ -16,7 +16,6 @@ #define SEC_CORE_INT_STATUS 0x301008 #define HPRE_HAC_INT_STATUS 0x301800 #define HZIP_CORE_INT_STATUS 0x3010AC -#define QM_QUE_ISO_CFG 0x301154 =20 #define QM_VFT_CFG_RDY 0x10006c #define QM_VFT_CFG_OP_WR 0x100058 --=20 2.33.0