Re: [PATCH v8 11/22] KVM: s390: pci: add basic kvm_zdev structure

From: Alex Williamson
Date: Tue May 24 2022 - 18:51:05 EST


On Tue, 24 May 2022 14:58:56 -0400
Matthew Rosato <mjrosato@xxxxxxxxxxxxx> wrote:
> diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
> new file mode 100644
> index 000000000000..21c2be5c2713
> --- /dev/null
> +++ b/arch/s390/kvm/pci.c
> @@ -0,0 +1,36 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * s390 kvm PCI passthrough support
> + *
> + * Copyright IBM Corp. 2022
> + *
> + * Author(s): Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
> + */
> +
> +#include <linux/kvm_host.h>
> +#include <linux/pci.h>
> +#include "pci.h"
> +
> +static int kvm_s390_pci_dev_open(struct zpci_dev *zdev)
> +{
> + struct kvm_zdev *kzdev;
> +
> + kzdev = kzalloc(sizeof(struct kvm_zdev), GFP_KERNEL);
> + if (!kzdev)
> + return -ENOMEM;
> +
> + kzdev->zdev = zdev;
> + zdev->kzdev = kzdev;
> +
> + return 0;
> +}
> +
> +static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)
> +{
> + struct kvm_zdev *kzdev;
> +
> + kzdev = zdev->kzdev;
> + WARN_ON(kzdev->zdev != zdev);
> + zdev->kzdev = 0;

I imagine this should be s/0/NULL/, right? I feel like there was a
recent similar discussion, but I can't think of any unique search terms
to sort it out of my inbox. Thanks,

Alex