public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
To: liulongfang <liulongfang@huawei.com>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"Jonathan Cameron" <jonathan.cameron@huawei.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linuxarm@openeuler.org" <linuxarm@openeuler.org>
Subject: RE: [PATCH v7 1/4] hisi_acc_vfio_pci: extract public functions for container_of
Date: Mon, 5 Aug 2024 09:11:01 +0000	[thread overview]
Message-ID: <342ae840f5064d92b569b521b30ddae8@huawei.com> (raw)
In-Reply-To: <20240730121438.58455-2-liulongfang@huawei.com>



> -----Original Message-----
> From: liulongfang <liulongfang@huawei.com>
> Sent: Tuesday, July 30, 2024 1:15 PM
> To: alex.williamson@redhat.com; jgg@nvidia.com; Shameerali Kolothum
> Thodi <shameerali.kolothum.thodi@huawei.com>; Jonathan Cameron
> <jonathan.cameron@huawei.com>
> Cc: kvm@vger.kernel.org; linux-kernel@vger.kernel.org;
> linuxarm@openeuler.org; liulongfang <liulongfang@huawei.com>
> Subject: [PATCH v7 1/4] hisi_acc_vfio_pci: extract public functions for
> container_of
> 
> In the current driver, vdev is obtained from struct
> hisi_acc_vf_core_device through the container_of function.
> This method is used in many places in the driver. In order to
> reduce this repetitive operation, It was extracted into
> a public function.
> 
> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
> ---

LGTM,

Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>

Thanks,
Shameer

>  .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c    | 21 ++++++++++---------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
> b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
> index 9a3e97108ace..45351be8e270 100644
> --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
> +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
> @@ -630,6 +630,12 @@ static void hisi_acc_vf_disable_fds(struct
> hisi_acc_vf_core_device *hisi_acc_vde
>  	}
>  }
> 
> +static struct hisi_acc_vf_core_device *hisi_acc_get_vf_dev(struct
> vfio_device *vdev)
> +{
> +	return container_of(vdev, struct hisi_acc_vf_core_device,
> +			    core_device.vdev);
> +}
> +
>  static void hisi_acc_vf_reset(struct hisi_acc_vf_core_device *hisi_acc_vdev)
>  {
>  	hisi_acc_vdev->vf_qm_state = QM_NOT_READY;
> @@ -1033,8 +1039,7 @@ static struct file *
>  hisi_acc_vfio_pci_set_device_state(struct vfio_device *vdev,
>  				   enum vfio_device_mig_state new_state)
>  {
> -	struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(vdev,
> -			struct hisi_acc_vf_core_device, core_device.vdev);
> +	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> hisi_acc_get_vf_dev(vdev);
>  	enum vfio_device_mig_state next_state;
>  	struct file *res = NULL;
>  	int ret;
> @@ -1075,8 +1080,7 @@ static int
>  hisi_acc_vfio_pci_get_device_state(struct vfio_device *vdev,
>  				   enum vfio_device_mig_state *curr_state)
>  {
> -	struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(vdev,
> -			struct hisi_acc_vf_core_device, core_device.vdev);
> +	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> hisi_acc_get_vf_dev(vdev);
> 
>  	mutex_lock(&hisi_acc_vdev->state_mutex);
>  	*curr_state = hisi_acc_vdev->mig_state;
> @@ -1280,8 +1284,7 @@ static long hisi_acc_vfio_pci_ioctl(struct vfio_device
> *core_vdev, unsigned int
> 
>  static int hisi_acc_vfio_pci_open_device(struct vfio_device *core_vdev)
>  {
> -	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> container_of(core_vdev,
> -			struct hisi_acc_vf_core_device, core_device.vdev);
> +	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> hisi_acc_get_vf_dev(core_vdev);
>  	struct vfio_pci_core_device *vdev = &hisi_acc_vdev->core_device;
>  	int ret;
> 
> @@ -1304,8 +1307,7 @@ static int hisi_acc_vfio_pci_open_device(struct
> vfio_device *core_vdev)
> 
>  static void hisi_acc_vfio_pci_close_device(struct vfio_device *core_vdev)
>  {
> -	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> container_of(core_vdev,
> -			struct hisi_acc_vf_core_device, core_device.vdev);
> +	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> hisi_acc_get_vf_dev(core_vdev);
>  	struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;
> 
>  	iounmap(vf_qm->io_base);
> @@ -1320,8 +1322,7 @@ static const struct vfio_migration_ops
> hisi_acc_vfio_pci_migrn_state_ops = {
> 
>  static int hisi_acc_vfio_pci_migrn_init_dev(struct vfio_device *core_vdev)
>  {
> -	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> container_of(core_vdev,
> -			struct hisi_acc_vf_core_device, core_device.vdev);
> +	struct hisi_acc_vf_core_device *hisi_acc_vdev =
> hisi_acc_get_vf_dev(core_vdev);
>  	struct pci_dev *pdev = to_pci_dev(core_vdev->dev);
>  	struct hisi_qm *pf_qm = hisi_acc_get_pf_qm(pdev);
> 
> --
> 2.24.0


  reply	other threads:[~2024-08-05  9:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 12:14 [PATCH v7 0/4] debugfs to hisilicon migration driver Longfang Liu
2024-07-30 12:14 ` [PATCH v7 1/4] hisi_acc_vfio_pci: extract public functions for container_of Longfang Liu
2024-08-05  9:11   ` Shameerali Kolothum Thodi [this message]
2024-07-30 12:14 ` [PATCH v7 2/4] hisi_acc_vfio_pci: create subfunction for data reading Longfang Liu
2024-08-05  9:12   ` Shameerali Kolothum Thodi
2024-07-30 12:14 ` [PATCH v7 3/4] hisi_acc_vfio_pci: register debugfs for hisilicon migration driver Longfang Liu
2024-08-05  8:51   ` Shameerali Kolothum Thodi
2024-08-06  8:30     ` liulongfang
2024-07-30 12:14 ` [PATCH v7 4/4] Documentation: add debugfs description for hisi migration Longfang Liu
2024-08-05  9:09   ` Shameerali Kolothum Thodi
2024-08-06  8:37     ` 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=342ae840f5064d92b569b521b30ddae8@huawei.com \
    --to=shameerali.kolothum.thodi@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@openeuler.org \
    --cc=liulongfang@huawei.com \
    /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