public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Kevin Tian <kevin.tian@intel.com>, Yi Liu <yi.l.liu@intel.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>,
	Zhi Wang <zhi.a.wang@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Halil Pasic <pasic@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Tony Krowiak <akrowiak@linux.ibm.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Harald Freudenberger <freude@linux.ibm.com>,
	Diana Craciun <diana.craciun@oss.nxp.com>,
	Eric Auger <eric.auger@redhat.com>,
	Kirti Wankhede <kwankhede@nvidia.com>,
	Abhishek Sahu <abhsahu@nvidia.com>,
	Yishai Hadas <yishaih@nvidia.com>,
	intel-gvt-dev@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	kvm@vger.kernel.org
Subject: Re: [PATCH v1 3/7] vfio/ccw: move private initialization to callback
Date: Fri, 28 Oct 2022 15:18:28 -0400	[thread overview]
Message-ID: <bb376b2e40cbde282c886557af3f9c44d85df907.camel@linux.ibm.com> (raw)
In-Reply-To: <8f295a4b-416a-dc17-487c-d4c4e309c738@linux.ibm.com>

On Fri, 2022-10-28 at 14:52 -0400, Matthew Rosato wrote:
> On 10/19/22 12:21 PM, Eric Farman wrote:
> > There's already a device initialization callback that is
> > used to initialize the release completion workaround.
> 
> As discussed off-list, maybe clarify what callback you're talking
> about here and/or reference the commit that added it.

Agreed. Will point out that it's private->release_comp, introduced with
commit ebb72b765fb49 ("vfio/ccw: Use the new device life cycle
helpers")

> 
> > 
> > Move the other elements of the vfio_ccw_private struct that
> > require distinct initialization over to that routine.
> > 
> > Signed-off-by: Eric Farman <farman@linux.ibm.com>
> > ---
> >  drivers/s390/cio/vfio_ccw_drv.c     | 57 +++----------------------
> > ----
> >  drivers/s390/cio/vfio_ccw_ops.c     | 43 ++++++++++++++++++++++
> >  drivers/s390/cio/vfio_ccw_private.h |  7 +++-
> >  3 files changed, 55 insertions(+), 52 deletions(-)
> > 
> > diff --git a/drivers/s390/cio/vfio_ccw_drv.c
> > b/drivers/s390/cio/vfio_ccw_drv.c
> > index 4ee953c8ae39..cc9ed2fd970f 100644
> > --- a/drivers/s390/cio/vfio_ccw_drv.c
> > +++ b/drivers/s390/cio/vfio_ccw_drv.c
> > @@ -24,10 +24,10 @@
> >  #include "vfio_ccw_private.h"
> >  
> >  struct workqueue_struct *vfio_ccw_work_q;
> > -static struct kmem_cache *vfio_ccw_io_region;
> > -static struct kmem_cache *vfio_ccw_cmd_region;
> > -static struct kmem_cache *vfio_ccw_schib_region;
> > -static struct kmem_cache *vfio_ccw_crw_region;
> > +struct kmem_cache *vfio_ccw_io_region;
> > +struct kmem_cache *vfio_ccw_cmd_region;
> > +struct kmem_cache *vfio_ccw_schib_region;
> > +struct kmem_cache *vfio_ccw_crw_region;
> >  
> >  debug_info_t *vfio_ccw_debug_msg_id;
> >  debug_info_t *vfio_ccw_debug_trace_id;
> > @@ -74,7 +74,7 @@ int vfio_ccw_sch_quiesce(struct subchannel *sch)
> >         return ret;
> >  }
> >  
> > -static void vfio_ccw_sch_io_todo(struct work_struct *work)
> > +void vfio_ccw_sch_io_todo(struct work_struct *work)
> >  {
> >         struct vfio_ccw_private *private;
> >         struct irb *irb;
> > @@ -110,7 +110,7 @@ static void vfio_ccw_sch_io_todo(struct
> > work_struct *work)
> >                 eventfd_signal(private->io_trigger, 1);
> >  }
> >  
> > -static void vfio_ccw_crw_todo(struct work_struct *work)
> > +void vfio_ccw_crw_todo(struct work_struct *work)
> >  {
> >         struct vfio_ccw_private *private;
> >  
> > @@ -154,52 +154,7 @@ static struct vfio_ccw_private
> > *vfio_ccw_alloc_private(struct subchannel *sch)
> >         if (!private)
> >                 return ERR_PTR(-ENOMEM);
> 
> Not sure we really still need vfio_ccw_alloc_private() now or whether
> you can just kzalloc() inline right in vfio_ccw_sch_probe()

Fair. It ends up ends up getting scrapped in patch 6 anyway, but that
might clean things up just a smidge more. Will give it a whirl.

> Either way:
> 
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

Thanks!

> 
> 
> >  
> > -       mutex_init(&private->io_mutex);
> > -       private->state = VFIO_CCW_STATE_STANDBY;
> > -       INIT_LIST_HEAD(&private->crw);
> > -       INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo);
> > -       INIT_WORK(&private->crw_work, vfio_ccw_crw_todo);
> > -
> > -       private->cp.guest_cp = kcalloc(CCWCHAIN_LEN_MAX,
> > sizeof(struct ccw1),
> > -                                      GFP_KERNEL);
> > -       if (!private->cp.guest_cp)
> > -               goto out_free_private;
> > -
> > -       private->io_region = kmem_cache_zalloc(vfio_ccw_io_region,
> > -                                              GFP_KERNEL |
> > GFP_DMA);
> > -       if (!private->io_region)
> > -               goto out_free_cp;
> > -
> > -       private->cmd_region =
> > kmem_cache_zalloc(vfio_ccw_cmd_region,
> > -                                               GFP_KERNEL |
> > GFP_DMA);
> > -       if (!private->cmd_region)
> > -               goto out_free_io;
> > -
> > -       private->schib_region =
> > kmem_cache_zalloc(vfio_ccw_schib_region,
> > -                                                 GFP_KERNEL |
> > GFP_DMA);
> > -
> > -       if (!private->schib_region)
> > -               goto out_free_cmd;
> > -
> > -       private->crw_region =
> > kmem_cache_zalloc(vfio_ccw_crw_region,
> > -                                               GFP_KERNEL |
> > GFP_DMA);
> > -
> > -       if (!private->crw_region)
> > -               goto out_free_schib;
> >         return private;
> > -
> > -out_free_schib:
> > -       kmem_cache_free(vfio_ccw_schib_region, private-
> > >schib_region);
> > -out_free_cmd:
> > -       kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region);
> > -out_free_io:
> > -       kmem_cache_free(vfio_ccw_io_region, private->io_region);
> > -out_free_cp:
> > -       kfree(private->cp.guest_cp);
> > -out_free_private:
> > -       mutex_destroy(&private->io_mutex);
> > -       kfree(private);
> > -       return ERR_PTR(-ENOMEM);
> >  }
> >  
> >  static void vfio_ccw_free_private(struct vfio_ccw_private
> > *private)
> > diff --git a/drivers/s390/cio/vfio_ccw_ops.c
> > b/drivers/s390/cio/vfio_ccw_ops.c
> > index cf383c729d53..626b8eb3507b 100644
> > --- a/drivers/s390/cio/vfio_ccw_ops.c
> > +++ b/drivers/s390/cio/vfio_ccw_ops.c
> > @@ -50,8 +50,51 @@ static int vfio_ccw_mdev_init_dev(struct
> > vfio_device *vdev)
> >         struct vfio_ccw_private *private =
> >                 container_of(vdev, struct vfio_ccw_private, vdev);
> >  
> > +       mutex_init(&private->io_mutex);
> > +       private->state = VFIO_CCW_STATE_STANDBY;
> > +       INIT_LIST_HEAD(&private->crw);
> > +       INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo);
> > +       INIT_WORK(&private->crw_work, vfio_ccw_crw_todo);
> >         init_completion(&private->release_comp);
> > +
> > +       private->cp.guest_cp = kcalloc(CCWCHAIN_LEN_MAX,
> > sizeof(struct ccw1),
> > +                                      GFP_KERNEL);
> > +       if (!private->cp.guest_cp)
> > +               goto out_free_private;
> > +
> > +       private->io_region = kmem_cache_zalloc(vfio_ccw_io_region,
> > +                                              GFP_KERNEL |
> > GFP_DMA);
> > +       if (!private->io_region)
> > +               goto out_free_cp;
> > +
> > +       private->cmd_region =
> > kmem_cache_zalloc(vfio_ccw_cmd_region,
> > +                                               GFP_KERNEL |
> > GFP_DMA);
> > +       if (!private->cmd_region)
> > +               goto out_free_io;
> > +
> > +       private->schib_region =
> > kmem_cache_zalloc(vfio_ccw_schib_region,
> > +                                                 GFP_KERNEL |
> > GFP_DMA);
> > +       if (!private->schib_region)
> > +               goto out_free_cmd;
> > +
> > +       private->crw_region =
> > kmem_cache_zalloc(vfio_ccw_crw_region,
> > +                                               GFP_KERNEL |
> > GFP_DMA);
> > +       if (!private->crw_region)
> > +               goto out_free_schib;
> > +
> >         return 0;
> > +
> > +out_free_schib:
> > +       kmem_cache_free(vfio_ccw_schib_region, private-
> > >schib_region);
> > +out_free_cmd:
> > +       kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region);
> > +out_free_io:
> > +       kmem_cache_free(vfio_ccw_io_region, private->io_region);
> > +out_free_cp:
> > +       kfree(private->cp.guest_cp);
> > +out_free_private:
> > +       mutex_destroy(&private->io_mutex);
> > +       return -ENOMEM;
> >  }
> >  
> >  static int vfio_ccw_mdev_probe(struct mdev_device *mdev)
> > diff --git a/drivers/s390/cio/vfio_ccw_private.h
> > b/drivers/s390/cio/vfio_ccw_private.h
> > index 0fdff1435230..b35940057073 100644
> > --- a/drivers/s390/cio/vfio_ccw_private.h
> > +++ b/drivers/s390/cio/vfio_ccw_private.h
> > @@ -116,6 +116,8 @@ struct vfio_ccw_private {
> >  } __aligned(8);
> >  
> >  int vfio_ccw_sch_quiesce(struct subchannel *sch);
> > +void vfio_ccw_sch_io_todo(struct work_struct *work);
> > +void vfio_ccw_crw_todo(struct work_struct *work);
> >  
> >  extern struct mdev_driver vfio_ccw_mdev_driver;
> >  
> > @@ -163,7 +165,10 @@ static inline void vfio_ccw_fsm_event(struct
> > vfio_ccw_private *private,
> >  }
> >  
> >  extern struct workqueue_struct *vfio_ccw_work_q;
> > -
> > +extern struct kmem_cache *vfio_ccw_io_region;
> > +extern struct kmem_cache *vfio_ccw_cmd_region;
> > +extern struct kmem_cache *vfio_ccw_schib_region;
> > +extern struct kmem_cache *vfio_ccw_crw_region;
> >  
> >  /* s390 debug feature, similar to base cio */
> >  extern debug_info_t *vfio_ccw_debug_msg_id;
> 


  reply	other threads:[~2022-10-28 19:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 16:21 [PATCH v1 0/7] vfio-ccw parent rework Eric Farman
2022-10-19 16:21 ` [PATCH v1 1/7] vfio/ccw: create a parent struct Eric Farman
2022-10-27 20:32   ` Eric Farman
2022-10-28 16:51   ` Matthew Rosato
2022-10-28 17:21     ` Eric Farman
2022-10-19 16:21 ` [PATCH v1 2/7] vfio/ccw: remove private->sch Eric Farman
2022-10-28 18:43   ` Matthew Rosato
2022-10-19 16:21 ` [PATCH v1 3/7] vfio/ccw: move private initialization to callback Eric Farman
2022-10-28 18:52   ` Matthew Rosato
2022-10-28 19:18     ` Eric Farman [this message]
2022-10-19 16:21 ` [PATCH v1 4/7] vfio/ccw: move private to mdev lifecycle Eric Farman
2022-11-01  9:08   ` Tian, Kevin
2022-11-01 14:05     ` Eric Farman
2022-10-19 16:21 ` [PATCH v1 5/7] vfio/ccw: remove release completion Eric Farman
2022-11-01  9:09   ` Tian, Kevin
2022-10-19 16:21 ` [PATCH v1 6/7] vfio/ccw: replace vfio_init_device with _alloc_ Eric Farman
2022-10-19 17:15   ` Jason Gunthorpe
2022-10-19 17:57     ` Eric Farman
2022-10-20 12:26       ` Jason Gunthorpe
2022-11-01  9:10   ` Tian, Kevin
2022-10-19 16:21 ` [PATCH v1 7/7] vfio: Remove vfio_free_device Eric Farman
2022-10-19 17:16   ` Jason Gunthorpe
2022-11-01  9:11   ` Tian, Kevin
2022-10-19 17:18 ` [PATCH v1 0/7] vfio-ccw parent rework Jason Gunthorpe

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=bb376b2e40cbde282c886557af3f9c44d85df907.camel@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=abhsahu@nvidia.com \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@gmail.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=diana.craciun@oss.nxp.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric.auger@redhat.com \
    --cc=freude@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jgg@nvidia.com \
    --cc=jjherne@linux.ibm.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=svens@linux.ibm.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=vneethv@linux.ibm.com \
    --cc=yi.l.liu@intel.com \
    --cc=yishaih@nvidia.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhi.a.wang@intel.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