qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
To: Auger Eric <eric.auger@redhat.com>
Cc: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	qemu-devel@nongnu.org, borntraeger@de.ibm.com,
	alex.williamson@redhat.com,
	Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>,
	cornelia.huck@de.ibm.com, agraf@suse.com
Subject: Re: [Qemu-devel] [PATCH v6 07/13] vfio/ccw: vfio based subchannel passthrough driver
Date: Tue, 2 May 2017 13:07:53 +0800	[thread overview]
Message-ID: <20170502050753.GC27968@bjsdjshi@linux.vnet.ibm.com> (raw)
In-Reply-To: <3958d3c4-2381-dc97-47cf-9a72593cd83c@redhat.com>

* Auger Eric <eric.auger@redhat.com> [2017-05-01 13:08:05 +0200]:

Hi Eric,

[...]

> > diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> > new file mode 100644
> > index 0000000..cd4dfe8
> > --- /dev/null
> > +++ b/hw/vfio/ccw.c
[...]

> > +static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp)
> > +{
> > +    char *tmp, group_path[PATH_MAX];
> > +    ssize_t len;
> > +    int groupid;
> > +
> > +    tmp = g_strdup_printf("/sys/bus/css/devices/%x.%x.%04x/%s/iommu_group",
> > +                          cdev->hostid.cssid, cdev->hostid.ssid,
> > +                          cdev->hostid.devid, cdev->mdevid);
> May be worth replacing this static function by a common
> vfio_get_device_group(VFIODevice *vbasedev, Error **errp) in common.c
> that would be used by vfio/pci devices? It would use the sysfsdev
> populated before.
Are you propsing that we introduce a common interface for all of the
devices which use the quite alike logic of populating the sysfsdev?

I put this on my todo list, and prefer to defer it to a time after this
set upstreamed.

> > +    len = readlink(tmp, group_path, sizeof(group_path));
> > +    g_free(tmp);
> > +
> > +    if (len <= 0 || len >= sizeof(group_path)) {
> > +        error_setg(errp, "vfio: no iommu_group found");
> may be good to align the error message with pci/platform. I noticed the
> case where len==0 is handled as ENAMETOOLONG on pci/platform which looks
> bad. Maybe this is why you changed it.
I copy this from pci.c. :>

And I agree with you that, the error message is better to be aligned if
it's possible to do that.

> > +        return NULL;
> > +    }
> > +
> > +    group_path[len] = 0;
> > +
> > +    if (sscanf(basename(group_path), "%d", &groupid) != 1) {
> > +        error_setg(errp, "vfio: failed to read %s", group_path);
> > +        return NULL;
> > +    }
> > +
> > +    return vfio_get_group(groupid, &address_space_memory, errp);
> > +}
> > +
> > +static void vfio_ccw_put_group(VFIOGroup *group)
> Is it really needed?
Ok. Removed.

> > +{
> > +    vfio_put_group(group);
> > +}
> > +
> > +static void vfio_ccw_realize(DeviceState *dev, Error **errp)
> > +{
> > +    VFIODevice *vbasedev;
> > +    VFIOGroup *group;
> > +    CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev);
> > +    S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev);
> > +    VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev);
> > +    S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
> > +
> > +    /* Call the class init function for subchannel. */
> > +    if (cdc->realize) {
> > +        cdc->realize(cdev, vcdev->vdev.sysfsdev, errp);
> > +        if (*errp) {
> use local err?
Ok.

> 
> Thanks
> 
> Eric
> > +            return;
> > +        }
> > +    }
> > +
> > +    group = vfio_ccw_get_group(cdev, errp);
> > +    if (!group) {
> > +        goto out_group_err;
> > +    }
> > +
> > +    vcdev->vdev.ops = &vfio_ccw_ops;
> > +    vcdev->vdev.type = VFIO_DEVICE_TYPE_CCW;
> > +    vcdev->vdev.name = g_strdup_printf("%x.%x.%04x", cdev->hostid.cssid,
> > +                                       cdev->hostid.ssid, cdev->hostid.devid);
> > +    QLIST_FOREACH(vbasedev, &group->device_list, next) {
> > +        if (strcmp(vbasedev->name, vcdev->vdev.name) == 0) {
> > +            error_setg(errp, "vfio: subchannel %s has already been attached",
> > +                       vcdev->vdev.name);
> > +            goto out_device_err;
> > +        }
> > +    }
> > +
> > +    if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, errp)) {
> > +        goto out_device_err;
> > +    }
> > +
> > +    return;
> > +
> > +out_device_err:
> > +    vfio_ccw_put_group(group);
> > +out_group_err:
> > +    if (cdc->unrealize) {
> > +        cdc->unrealize(cdev, errp);
> > +    }
> > +}
> > +
[...]

-- 
Dong Jia Shi

  reply	other threads:[~2017-05-02  5:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 13:09 [Qemu-devel] [PATCH v6 00/13] basic channel IO passthrough infrastructure based on vfio Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 01/13] update-linux-headers: update for vfio-ccw Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 02/13] vfio: linux-headers " Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 03/13] s390x/css: add s390-squash-mcss machine option Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 04/13] s390x/css: realize css_sch_build_schib Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 05/13] s390x/css: realize css_create_sch Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 06/13] s390x/css: device support for s390-ccw passthrough Dong Jia Shi
2017-05-01 11:08   ` Auger Eric
2017-05-02  2:37     ` Dong Jia Shi
2017-05-01 11:20   ` Auger Eric
2017-05-01 11:24     ` Auger Eric
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 07/13] vfio/ccw: vfio based subchannel passthrough driver Dong Jia Shi
2017-05-01 11:08   ` Auger Eric
2017-05-02  5:07     ` Dong Jia Shi [this message]
2017-05-02  6:48       ` Auger Eric
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 08/13] vfio/ccw: get io region info Dong Jia Shi
2017-05-01 11:08   ` Auger Eric
2017-05-02  5:16     ` Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 09/13] vfio/ccw: get irqs info and set the eventfd fd Dong Jia Shi
2017-05-01 11:08   ` Auger Eric
2017-05-02  5:37     ` Dong Jia Shi
2017-05-02  6:49       ` Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 10/13] s390x/css: introduce and realize ccw-request callback Dong Jia Shi
2017-05-01 17:28   ` Auger Eric
2017-05-02  2:15     ` Dong Jia Shi
2017-05-02 16:04       ` Cornelia Huck
2017-05-03  2:18         ` Dong Jia Shi
2017-05-03 11:14           ` Cornelia Huck
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 11/13] s390x/css: ccw translation infrastructure Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 12/13] vfio/ccw: update sense data if a unit check is pending Dong Jia Shi
2017-04-28 13:09 ` [Qemu-devel] [PATCH v6 13/13] MAINTAINERS: Add vfio-ccw maintainer Dong Jia Shi

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=20170502050753.GC27968@bjsdjshi@linux.vnet.ibm.com \
    --to=bjsdjshi@linux.vnet.ibm.com \
    --cc=agraf@suse.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=renxiaof@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).