Re: [RFC] Make use of non-dynamic dmabuf in RDMA

2021-08-24 Thread Jason Gunthorpe
On Tue, Aug 24, 2021 at 10:27:23AM -0700, John Hubbard wrote: > On 8/24/21 2:32 AM, Christian König wrote: > > Am 24.08.21 um 11:06 schrieb Gal Pressman: > > > On 23/08/2021 13:43, Christian König wrote: > > > > Am 21.08.21 um 11:16 schrieb Gal Pressman: > &

Re: linux-next: build failure after merge of the hmm tree

2021-08-23 Thread Jason Gunthorpe
On Mon, Aug 23, 2021 at 05:50:27PM +1000, Stephen Rothwell wrote: > From: Stephen Rothwell > Date: Mon, 23 Aug 2021 17:46:27 +1000 > Subject: [PATCH] drm/i915/ttm: fix up for "lib/scatterlist: Provide a > dedicated function to support tableappend" > > Signed-off-by: Stephen Rothwell >

Re: [PATCH rdma-next v3 2/3] lib/scatterlist: Fix wrong update of orig_nents

2021-08-23 Thread Jason Gunthorpe
On Mon, Aug 23, 2021 at 04:45:45PM +0300, Maor Gottlieb wrote: > > On 8/23/2021 3:45 PM, Jason Gunthorpe wrote: > > On Mon, Aug 23, 2021 at 02:09:37PM +0300, Maor Gottlieb wrote: > > > On 8/20/2021 6:54 PM, Jason Gunthorpe wrote: > > > > On Thu, Jul 29, 2021 at

Re: [PATCH rdma-next v3 2/3] lib/scatterlist: Fix wrong update of orig_nents

2021-08-23 Thread Jason Gunthorpe
On Mon, Aug 23, 2021 at 02:09:37PM +0300, Maor Gottlieb wrote: > > On 8/20/2021 6:54 PM, Jason Gunthorpe wrote: > > On Thu, Jul 29, 2021 at 12:39:12PM +0300, Leon Romanovsky wrote: > > > > > +/** > > > + * __sg_free_table - Free a previously mapped sg table

Re: [PATCH rdma-next v3 0/3] SG fix together with update to RDMA umem

2021-08-20 Thread Jason Gunthorpe
On Thu, Jul 29, 2021 at 12:39:10PM +0300, Leon Romanovsky wrote: > From: Leon Romanovsky > > Changelog: > v3: > * Rewrote to new API suggestion > * Split for more patches > v2: https://lore.kernel.org/lkml/cover.1626605893.git.leo...@nvidia.com > * Changed implementation of first patch, based

Re: [PATCH rdma-next v3 2/3] lib/scatterlist: Fix wrong update of orig_nents

2021-08-20 Thread Jason Gunthorpe
On Fri, Aug 20, 2021 at 12:54:25PM -0300, Jason Gunthorpe wrote: > On Thu, Jul 29, 2021 at 12:39:12PM +0300, Leon Romanovsky wrote: > > > +/** > > + * __sg_free_table - Free a previously mapped sg table > > + * @table: The sg table header to use > > + * @max

Re: [PATCH rdma-next v3 2/3] lib/scatterlist: Fix wrong update of orig_nents

2021-08-20 Thread Jason Gunthorpe
On Thu, Jul 29, 2021 at 12:39:12PM +0300, Leon Romanovsky wrote: > +/** > + * __sg_free_table - Free a previously mapped sg table > + * @table: The sg table header to use > + * @max_ents:The maximum number of entries per single scatterlist > + * @total_ents: The total number of

Re: [RFC] Make use of non-dynamic dmabuf in RDMA

2021-08-20 Thread Jason Gunthorpe
On Fri, Aug 20, 2021 at 03:58:33PM +0300, Gal Pressman wrote: > Though it would've been nicer if we could agree on a solution that could work > for more than 1-2 RDMA devices, using the existing tools the RDMA subsystem > has. I don't think it can really be done, revoke is necessary, and isn't

Re: [PATCH v2 56/63] RDMA/mlx5: Use struct_group() to zero struct mlx5_ib_mr

2021-08-20 Thread Jason Gunthorpe
On Thu, Aug 19, 2021 at 11:14:37AM -0700, Kees Cook wrote: > Which do you mean? When doing the conversions I tended to opt for > struct_group() since it provides more robust "intentionality". Strictly > speaking, the new memset helpers are doing field-spanning writes, but the > "clear to the end"

Re: [RFC] Make use of non-dynamic dmabuf in RDMA

2021-08-20 Thread Jason Gunthorpe
On Fri, Aug 20, 2021 at 09:25:30AM +0200, Daniel Vetter wrote: > On Fri, Aug 20, 2021 at 1:06 AM Jason Gunthorpe wrote: > > On Wed, Aug 18, 2021 at 11:34:51AM +0200, Daniel Vetter wrote: > > > On Wed, Aug 18, 2021 at 9:45 AM Gal Pressman wrote: > > > > > > &g

Re: [RFC] Make use of non-dynamic dmabuf in RDMA

2021-08-19 Thread Jason Gunthorpe
On Wed, Aug 18, 2021 at 11:34:51AM +0200, Daniel Vetter wrote: > On Wed, Aug 18, 2021 at 9:45 AM Gal Pressman wrote: > > > > Hey all, > > > > Currently, the RDMA subsystem can only work with dynamic dmabuf > > attachments, which requires the RDMA device to support on-demand-paging > > (ODP) which

Re: [PATCH v2 56/63] RDMA/mlx5: Use struct_group() to zero struct mlx5_ib_mr

2021-08-19 Thread Jason Gunthorpe
On Thu, Aug 19, 2021 at 09:19:08AM -0700, Kees Cook wrote: > On Thu, Aug 19, 2021 at 09:27:16AM -0300, Jason Gunthorpe wrote: > > On Tue, Aug 17, 2021 at 11:05:26PM -0700, Kees Cook wrote: > > > In preparation for FORTIFY_SOURCE performing compile-time and run-time > >

Re: [PATCH v2 56/63] RDMA/mlx5: Use struct_group() to zero struct mlx5_ib_mr

2021-08-19 Thread Jason Gunthorpe
_mr that should be > initialized to zero. > > Cc: Leon Romanovsky > Cc: Doug Ledford > Cc: Jason Gunthorpe > Cc: linux-r...@vger.kernel.org > Signed-off-by: Kees Cook > --- > drivers/infiniband/hw/mlx5/mlx5_ib.h | 4 +++- > 1 file changed, 3 insertions(+), 1 del

[PATCH v4 12/14] vfio/ap, ccw: Fix open/close when multiple device FDs are open

2021-08-05 Thread Jason Gunthorpe
. Since these really want the new open/close_device() semantics just change the functions over. Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- drivers/s390/cio/vfio_ccw_ops.c | 8 drivers/s390/crypto/vfio_ap_ops.c | 8 2 files changed, 8 insertions(+), 8

[PATCH v4 13/14] vfio/gvt: Fix open/close when multiple device FDs are open

2021-08-05 Thread Jason Gunthorpe
these really want the new open/close_device() semantics just change the function over. Reviewed-by: Zhenyu Wang Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/kvmgt.c | 8 1 file changed, 4 insertions(+), 4 deletions

[PATCH v4 01/14] vfio/samples: Remove module get/put

2021-08-05 Thread Jason Gunthorpe
ot;) Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()") Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 samples/vfio-mdev/mdpy.c | 4 2 files changed, 8 deletions(-) diff --git

[PATCH v4 07/14] vfio/platform: Use open_device() instead of open coding a refcnt scheme

2021-08-05 Thread Jason Gunthorpe
Hellwig Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas --- drivers/vfio/platform/vfio_platform_common.c | 95 --- drivers/vfio/platform/vfio_platform_private.h | 1 - 2 files changed, 40 insertions(+), 56 deletions(-) diff --git a/drivers/vfio/platform

[PATCH v4 05/14] vfio/samples: Delete useless open/close

2021-08-05 Thread Jason Gunthorpe
The core code no longer requires these ops to be defined, so delete these empty functions and leave the op as NULL. mtty's functions only log a pointless message, delete that entirely. Signed-off-by: Yishai Hadas Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason

[PATCH v4 06/14] vfio/fsl: Move to the device set infrastructure

2021-08-05 Thread Jason Gunthorpe
-by: Jason Gunthorpe --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 156 -- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c| 6 +- drivers/vfio/fsl-mc/vfio_fsl_mc_private.h | 7 - 3 files changed, 29 insertions(+), 140 deletions(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b

[PATCH v4 14/14] vfio: Remove struct vfio_device_ops open/release

2021-08-05 Thread Jason Gunthorpe
Nothing uses this anymore, delete it. Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_mdev.c | 22 -- drivers/vfio/vfio.c | 14 +- include/linux/mdev.h | 7 --- include

[PATCH v4 03/14] vfio: Introduce a vfio_uninit_group_dev() API call

2021-08-05 Thread Jason Gunthorpe
-by: Max Gurtovoy Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- Documentation/driver-api/vfio.rst| 4 ++- drivers/vfio/fsl-mc/vfio_fsl_mc.c| 7 ++--- drivers/vfio/mdev/vfio_mdev.c| 13 +++--- drivers/vfio

[PATCH v4 10/14] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-08-05 Thread Jason Gunthorpe
Reviewed-off-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 213 +++- 1 file changed, 89 insertions(+), 124 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 0147f04c91b2fb..a4f44ea52fa

[PATCH v4 08/14] vfio/pci: Move to the device set infrastructure

2021-08-05 Thread Jason Gunthorpe
ed by what devices pci_reset_bus() touches, which is either the entire bus or only the slot. Rely on the core code to do everything reflck was doing and delete reflck entirely. Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/

[PATCH v4 04/14] vfio: Provide better generic support for open/release vfio_device_ops

2021-08-05 Thread Jason Gunthorpe
into sets. This implementation uses xarray instead of searching through the driver core structures, which simplifies the somewhat tricky locking in this area. Following patches convert all the drivers. Signed-off-by: Yishai Hadas Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off

[PATCH v4 02/14] vfio/mbochs: Fix missing error unwind of mbochs_used_mbytes

2021-08-05 Thread Jason Gunthorpe
ot;) Reported-by: Cornelia Huck Co-developed-by: Alex Williamson Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-

[PATCH v4 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-08-05 Thread Jason Gunthorpe
ide vfio_pci_dev_set_try_reset(). This restructuring corrects a call to pci_dev_driver() without holding the device_lock() and removes a hard wiring to _pci_driver. Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 182 +--- 1 file changed, 86 insertions(+),

[PATCH v4 11/14] vfio/mbochs: Fix close when multiple device FDs are open

2021-08-05 Thread Jason Gunthorpe
Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index 7b2e12fe70827c..c313ab4d1f4e4e 100644 --- a/samples/vfio-mdev/mbochs.c

[PATCH v4 00/14] Provide core infrastructure for managing open/release

2021-08-05 Thread Jason Gunthorpe
Return 0 from mdev open_device if there is no op - Fix style for else {} - Spelling fix for singleton - Acquire cur_mem under lock - Always use error unwind flow for vfio_pci_check_all_devices_bound() v1: https://lore.kernel.org/r/0-v1-eaf3ccbba33c+1add0-vfio_reflck_...@nvidia.com Jason Gunthorpe (12): v

Re: [PATCH v3 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-08-05 Thread Jason Gunthorpe
On Thu, Aug 05, 2021 at 11:33:11AM -0600, Alex Williamson wrote: > > +static int vfio_pci_is_device_in_set(struct pci_dev *pdev, void *data) > > +{ > > + struct vfio_device_set *dev_set = data; > > + struct vfio_device *cur; > > + > > + lockdep_assert_held(_set->lock); > > + > > +

Re: [PATCH v3 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-08-05 Thread Jason Gunthorpe
On Tue, Aug 03, 2021 at 10:52:25AM -0600, Alex Williamson wrote: > On Tue, 3 Aug 2021 13:41:52 -0300 > Jason Gunthorpe wrote: > > On Tue, Aug 03, 2021 at 10:34:06AM -0600, Alex Williamson wrote: > > > I think the vfio_pci_find_reset_target() function needs to be re-worked

Re: [PATCH v3 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-08-03 Thread Jason Gunthorpe
On Tue, Aug 03, 2021 at 10:34:06AM -0600, Alex Williamson wrote: > On Wed, 28 Jul 2021 21:49:18 -0300 > Jason Gunthorpe wrote: > > > Keep track of all the vfio_devices that have been added to the device set > > and use this list in vfio_pci_try_bus_reset() instead of trying

Re: refactor the i915 GVT support

2021-08-03 Thread Jason Gunthorpe
On Tue, Aug 03, 2021 at 05:43:15PM +0800, Zhenyu Wang wrote: > Acked-by: Zhenyu Wang > > Thanks a lot for this effort! Great, do we have a submission plan for this? how much does it clash with my open_device/etc patch? ie does the whole thing have to go through the vfio tree? Thanks, Jason

Re: [PATCH v3 02/14] vfio/mbochs: Fix missing error unwind of mbochs_used_mbytes

2021-07-29 Thread Jason Gunthorpe
On Thu, Jul 29, 2021 at 12:38:12PM +0300, Dan Carpenter wrote: > This should just be: > atomic_add(type->mbytes, _avail_mbytes); Arg, yes, thanks Dan - I thought I got all of these. Jason

[PATCH v3 12/14] vfio/ap, ccw: Fix open/close when multiple device FDs are open

2021-07-28 Thread Jason Gunthorpe
. Since these really want the new open/close_device() semantics just change the functions over. Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- drivers/s390/cio/vfio_ccw_ops.c | 8 drivers/s390/crypto/vfio_ap_ops.c | 8 2 files changed, 8 insertions(+), 8

[PATCH v3 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-07-28 Thread Jason Gunthorpe
ing corrects a call to pci_dev_driver() without holding the device_lock() and removes a hard wiring to _pci_driver. Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 148 +++- 1 file changed, 62 insertions(+), 86 deletions(-) diff --git a/drivers/vfio/

[PATCH v3 14/14] vfio: Remove struct vfio_device_ops open/release

2021-07-28 Thread Jason Gunthorpe
Nothing uses this anymore, delete it. Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_mdev.c | 22 -- drivers/vfio/vfio.c | 14 +- include/linux/mdev.h | 7 --- include

[PATCH v3 01/14] vfio/samples: Remove module get/put

2021-07-28 Thread Jason Gunthorpe
ot;) Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()") Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 samples/vfio-mdev/mdpy.c | 4 2 files changed, 8 deletions(-) diff --git

[PATCH v3 03/14] vfio: Introduce a vfio_uninit_group_dev() API call

2021-07-28 Thread Jason Gunthorpe
-by: Max Gurtovoy Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- Documentation/driver-api/vfio.rst| 4 ++- drivers/vfio/fsl-mc/vfio_fsl_mc.c| 7 ++--- drivers/vfio/mdev/vfio_mdev.c| 13 +++--- drivers/vfio

[PATCH v3 13/14] vfio/gvt: Fix open/close when multiple device FDs are open

2021-07-28 Thread Jason Gunthorpe
these really want the new open/close_device() semantics just change the function over. Reviewed-by: Zhenyu Wang Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/kvmgt.c | 8 1 file changed, 4 insertions(+), 4 deletions

[PATCH v3 06/14] vfio/fsl: Move to the device set infrastructure

2021-07-28 Thread Jason Gunthorpe
-by: Jason Gunthorpe --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 154 -- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c| 6 +- drivers/vfio/fsl-mc/vfio_fsl_mc_private.h | 7 - 3 files changed, 28 insertions(+), 139 deletions(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b

[PATCH v3 10/14] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-07-28 Thread Jason Gunthorpe
viewed-off-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 215 +++- 1 file changed, 91 insertions(+), 124 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index a1ae9a83a38621..721dcc99aaa

[PATCH v3 05/14] vfio/samples: Delete useless open/close

2021-07-28 Thread Jason Gunthorpe
The core code no longer requires these ops to be defined, so delete these empty functions and leave the op as NULL. mtty's functions only log a pointless message, delete that entirely. Signed-off-by: Yishai Hadas Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason

[PATCH v3 11/14] vfio/mbochs: Fix close when multiple device FDs are open

2021-07-28 Thread Jason Gunthorpe
Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index 5ac65894fcd38c..6974626ec1c5d0 100644 --- a/samples/vfio-mdev/mbochs.c

[PATCH v3 04/14] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-28 Thread Jason Gunthorpe
into sets. This implementation uses xarray instead of searching through the driver core structures, which simplifies the somewhat tricky locking in this area. Following patches convert all the drivers. Signed-off-by: Yishai Hadas Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- dr

[PATCH v3 02/14] vfio/mbochs: Fix missing error unwind of mbochs_used_mbytes

2021-07-28 Thread Jason Gunthorpe
ot;) Reported-by: Cornelia Huck Co-developed-by: Alex Williamson Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index e

[PATCH v3 08/14] vfio/pci: Move to the device set infrastructure

2021-07-28 Thread Jason Gunthorpe
ed by what devices pci_reset_bus() touches, which is either the entire bus or only the slot. Rely on the core code to do everything reflck was doing and delete reflck entirely. Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/

[PATCH v3 07/14] vfio/platform: Use open_device() instead of open coding a refcnt scheme

2021-07-28 Thread Jason Gunthorpe
Platform simply wants to run some code when the device is first opened/last closed. Use the core framework and locking for this. Aside from removing a bit of code this narrows the locking scope from a global lock. Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Reviewed-by: Cornelia

[PATCH v3 00/14] Provide core infrastructure for managing open/release

2021-07-28 Thread Jason Gunthorpe
g fix for singleton - Acquire cur_mem under lock - Always use error unwind flow for vfio_pci_check_all_devices_bound() v1: https://lore.kernel.org/r/0-v1-eaf3ccbba33c+1add0-vfio_reflck_...@nvidia.com Jason Gunthorpe (12): vfio/samples: Remove module get/put vfio/mbochs: Fix missing error unwin

Re: refactor the i915 GVT support

2021-07-28 Thread Jason Gunthorpe
On Wed, Jul 28, 2021 at 01:38:58PM +, Wang, Zhi A wrote: > I guess those APIs you were talking about are KVM-only. For other > hypervisors, e.g. Xen, ARCN cannot use the APIs you mentioned. Not > sure if you have already noticed that VFIO is KVM-only right now. There is very little hard

Re: refactor the i915 GVT support

2021-07-27 Thread Jason Gunthorpe
On Thu, Jul 22, 2021 at 01:26:36PM +0200, Gerd Hoffmann wrote: > Hi, > > > https://github.com/intel/gvt-linux/blob/topic/gvt-xengt/drivers/gpu/drm/i915/gvt/xengt.c > > > But it's hard for some customers to contribute their own "hypervisor" > > module to the upstream Linux kernel. I am thinking

Re: [PATCH v2 04/14] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 09:39:14AM +0200, Christoph Hellwig wrote: > This looks unessecarily complicated. We can just try to load first > and then store it under the same lock, e.g.: Yes indeed, I went with this: int vfio_assign_device_set(struct vfio_device *device, void *set_id) {

Re: [PATCH v2 10/14] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 10:12:08AM +0200, Christoph Hellwig wrote: > On Tue, Jul 20, 2021 at 02:42:56PM -0300, Jason Gunthorpe wrote: > > Like vfio_pci_try_bus_reset() this code wants to reset all of the devices > > in the "reset group" which is the same mem

Re: [PATCH v2 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 10:05:43AM +0200, Christoph Hellwig wrote: > On Tue, Jul 20, 2021 at 02:42:55PM -0300, Jason Gunthorpe wrote: > > Keep track of all the vfio_devices that have been added to the device set > > and use this list in vfio_pci_try_bus_reset() instead of

Re: [PATCH v2 06/14] vfio/fsl: Move to the device set infrastructure

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 02:29:03PM +0200, Christoph Hellwig wrote: > On Fri, Jul 23, 2021 at 09:22:27AM -0300, Jason Gunthorpe wrote: > > > But do we even need the else part? Assingning _dev->dev is > > > equivalent to the default per-device set anyway, isn't it? > &g

Re: [PATCH v2 08/14] vfio/pci: Move to the device set infrastructure

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 09:47:49AM +0200, Christoph Hellwig wrote: > > @@ -2020,12 +2004,17 @@ static int vfio_pci_probe(struct pci_dev *pdev, > > const struct pci_device_id *id) > > INIT_LIST_HEAD(>vma_list); > > init_rwsem(>memory_lock); > > > > - ret = vfio_pci_reflck_attach(vdev);

Re: [PATCH v2 07/14] vfio/platform: Use open_device() instead of open coding a refcnt scheme

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 09:45:21AM +0200, Christoph Hellwig wrote: > Looks good, > > Reviewed-by: Christoph Hellwig > > On Tue, Jul 20, 2021 at 02:42:53PM -0300, Jason Gunthorpe wrote: > > Platform simply wants to run some code when the device is first > > opene

Re: [PATCH v2 06/14] vfio/fsl: Move to the device set infrastructure

2021-07-23 Thread Jason Gunthorpe
On Fri, Jul 23, 2021 at 09:44:35AM +0200, Christoph Hellwig wrote: > On Tue, Jul 20, 2021 at 02:42:52PM -0300, Jason Gunthorpe wrote: > > .write = vfio_fsl_mc_write, > > @@ -625,13 +526,15 @@ static int vfio_fsl_mc_probe(struct fsl_mc_device > > *mc_dev) > >

Re: [PATCH v4 10/13] lib: test_hmm add module param for zone device type

2021-07-22 Thread Jason Gunthorpe
On Thu, Jul 22, 2021 at 11:59:17AM -0500, Sierra Guiza, Alejandro (Alex) wrote: > > On 7/22/2021 7:23 AM, Jason Gunthorpe wrote: > > On Sat, Jul 17, 2021 at 02:21:32PM -0500, Alex Sierra wrote: > > > In order to configure device generic in test_hmm, two > > > modu

Re: [PATCH rdma-next v2 1/2] lib/scatterlist: Fix wrong update of orig_nents

2021-07-22 Thread Jason Gunthorpe
On Thu, Jul 22, 2021 at 02:07:51PM +0100, Christoph Hellwig wrote: > On Thu, Jul 22, 2021 at 10:00:40AM -0300, Jason Gunthorpe wrote: > > this is better: > > > >struct sg_append_table state; > > > >sg_append_init(, sgt, gfp_mask); > > > >

Re: [PATCH rdma-next v2 1/2] lib/scatterlist: Fix wrong update of orig_nents

2021-07-22 Thread Jason Gunthorpe
On Sun, Jul 18, 2021 at 02:09:12PM +0300, Leon Romanovsky wrote: > @@ -386,12 +414,14 @@ static struct scatterlist *get_next_sg(struct sg_table > *table, > return ERR_PTR(-ENOMEM); > sg_init_table(new_sg, alloc_size); > if (cur) { > + if (total_nents) > +

Re: [PATCH v4 10/13] lib: test_hmm add module param for zone device type

2021-07-22 Thread Jason Gunthorpe
On Sat, Jul 17, 2021 at 02:21:32PM -0500, Alex Sierra wrote: > In order to configure device generic in test_hmm, two > module parameters should be passed, which correspon to the > SP start address of each device (2) spm_addr_dev0 & > spm_addr_dev1. If no parameters are passed, private device >

Re: [PATCH v2 02/14] vfio/mbochs: Fix missing error unwind in mbochs_probe()

2021-07-20 Thread Jason Gunthorpe
On Tue, Jul 20, 2021 at 04:01:27PM -0600, Alex Williamson wrote: > On Tue, 20 Jul 2021 14:42:48 -0300 > Jason Gunthorpe wrote: > > > Compared to mbochs_remove() two cases are missing from the > > vfio_register_group_dev() unwind. Add them in. > > > > Fixes: 68

[PATCH v2 12/14] vfio/ap, ccw: Fix open/close when multiple device FDs are open

2021-07-20 Thread Jason Gunthorpe
. Since these really want the new open/close_device() semantics just change the functions over. Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- drivers/s390/cio/vfio_ccw_ops.c | 8 drivers/s390/crypto/vfio_ap_ops.c | 8 2 files changed, 8 insertions(+), 8

[PATCH v2 10/14] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-07-20 Thread Jason Gunthorpe
Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 201 +++- 1 file changed, 84 insertions(+), 117 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index fbc20f6d2dd412..d751d38f2175b6 100644 --- a/drivers/vfio/pci/vfio_p

[PATCH v2 11/14] vfio/mbochs: Fix close when multiple device FDs are open

2021-07-20 Thread Jason Gunthorpe
Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index fb81d11029e8a5..39002b07e692ac 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev

[PATCH v2 13/14] vfio/gvt: Fix open/close when multiple device FDs are open

2021-07-20 Thread Jason Gunthorpe
these really want the new open/close_device() semantics just change the function over. Reviewed-by: Zhenyu Wang Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/kvmgt.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm

[PATCH v2 09/14] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-07-20 Thread Jason Gunthorpe
ing corrects a call to pci_dev_driver() without holding the device_lock() and removes a hard wiring to _pci_driver. Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 110 ++-- drivers/vfio/vfio.c | 10 include/linux/vfio.h| 2 +

[PATCH v2 05/14] vfio/samples: Delete useless open/close

2021-07-20 Thread Jason Gunthorpe
The core code no longer requires these ops to be defined, so delete these empty functions and leave the op as NULL. mtty's functions only log a pointless message, delete that entirely. Signed-off-by: Yishai Hadas Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev

[PATCH v2 07/14] vfio/platform: Use open_device() instead of open coding a refcnt scheme

2021-07-20 Thread Jason Gunthorpe
Platform simply wants to run some code when the device is first opened/last closed. Use the core framework and locking for this. Aside from removing a bit of code this narrows the locking scope from a global lock. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio

[PATCH v2 08/14] vfio/pci: Move to the device set infrastructure

2021-07-20 Thread Jason Gunthorpe
ed by what devices pci_reset_bus() touches, which is either the entire bus or only the slot. Rely on the core code to do everything reflck was doing and delete reflck entirely. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c

[PATCH v2 00/14] Provide core infrastructure for managing open/release

2021-07-20 Thread Jason Gunthorpe
if there is no op - Fix style for else {} - Spelling fix for singleton - Acquire cur_mem under lock - Always use error unwind flow for vfio_pci_check_all_devices_bound() v1: https://lore.kernel.org/r/0-v1-eaf3ccbba33c+1add0-vfio_reflck_...@nvidia.com Jason Gunthorpe (12): vfio/samples: Remov

[PATCH v2 03/14] vfio: Introduce a vfio_uninit_group_dev() API call

2021-07-20 Thread Jason Gunthorpe
-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe --- Documentation/driver-api/vfio.rst| 4 ++- drivers/vfio/fsl-mc/vfio_fsl_mc.c| 7 ++--- drivers/vfio/mdev/vfio_mdev.c| 13 +++--- drivers/vfio/pci/vfio_pci.c | 6 +++-- drivers/vfio

[PATCH v2 06/14] vfio/fsl: Move to the device set infrastructure

2021-07-20 Thread Jason Gunthorpe
-by: Jason Gunthorpe --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 153 -- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c| 6 +- drivers/vfio/fsl-mc/vfio_fsl_mc_private.h | 7 - 3 files changed, 27 insertions(+), 139 deletions(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b

[PATCH v2 14/14] vfio: Remove struct vfio_device_ops open/release

2021-07-20 Thread Jason Gunthorpe
Nothing uses this anymore, delete it. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_mdev.c | 22 -- drivers/vfio/vfio.c | 14 +- include/linux/mdev.h | 7 --- include/linux/vfio.h | 4

[PATCH v2 04/14] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-20 Thread Jason Gunthorpe
into sets. This implementation uses xarray instead of searching through the driver core structures, which simplifies the somewhat tricky locking in this area. Following patches convert all the drivers. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_md

[PATCH v2 02/14] vfio/mbochs: Fix missing error unwind in mbochs_probe()

2021-07-20 Thread Jason Gunthorpe
Compared to mbochs_remove() two cases are missing from the vfio_register_group_dev() unwind. Add them in. Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()") Reported-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 7 +

[PATCH v2 01/14] vfio/samples: Remove module get/put

2021-07-20 Thread Jason Gunthorpe
ot;) Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()") Reviewed-by: Cornelia Huck Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 samples/vfio-mdev/mdpy.c | 4 2 files changed, 8 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c

Re: [PATCH 05/13] vfio/fsl: Move to the device set infrastructure

2021-07-20 Thread Jason Gunthorpe
On Tue, Jul 20, 2021 at 07:23:35PM +0300, Diana Craciun OSS wrote: > I have tested the changes and everything works as expected. Great, thanks, I added a Tested-by for you Jason

Re: [PATCH 05/13] vfio/fsl: Move to the device set infrastructure

2021-07-20 Thread Jason Gunthorpe
On Tue, Jul 20, 2021 at 07:12:26PM +0300, Diana Craciun OSS wrote: > On 7/15/2021 3:20 AM, Jason Gunthorpe wrote: > > FSL uses the internal reflck to implement the open_device() functionality, > > conversion to the core code is straightforward. > > > > The decis

Re: [PATCH 03/13] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-19 Thread Jason Gunthorpe
On Mon, Jul 19, 2021 at 10:01:31AM -0300, Jason Gunthorpe wrote: > On Mon, Jul 19, 2021 at 02:58:58PM +0200, Cornelia Huck wrote: > > > - ret = device->ops->open(device); > > > - if (ret) { > > > - module_put(device->dev->driver->o

Re: [PATCH 03/13] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-19 Thread Jason Gunthorpe
On Mon, Jul 19, 2021 at 02:58:58PM +0200, Cornelia Huck wrote: > > - ret = device->ops->open(device); > > - if (ret) { > > - module_put(device->dev->driver->owner); > > - vfio_device_put(device); > > - return ret; > > + mutex_lock(>dev_set->lock); > > +

Re: [PATCH 02/13] vfio: Introduce a vfio_uninit_group_dev() API call

2021-07-19 Thread Jason Gunthorpe
On Mon, Jul 19, 2021 at 02:11:38PM +0200, Cornelia Huck wrote: > On Wed, Jul 14 2021, Jason Gunthorpe wrote: > > > From: Max Gurtovoy > > > > This pairs with vfio_init_group_dev() and allows undoing any state that is > > stored in the vfio_device unrelated to r

Re: [PATCH 09/13] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-07-15 Thread Jason Gunthorpe
On Thu, Jul 15, 2021 at 03:00:55PM -0600, Alex Williamson wrote: > On Wed, 14 Jul 2021 21:20:38 -0300 > Jason Gunthorpe wrote: > > +/* > > + * We need to get memory_lock for each device, but devices can share > > mmap_lock, > > + * therefore we need to zap and hol

Re: [PATCH 00/13] Provide core infrastructure for managing open/release

2021-07-15 Thread Jason Gunthorpe
On Thu, Jul 15, 2021 at 06:58:31PM +0530, Kirti Wankhede wrote: > > Review of all the drivers show that they are either already open coding > > the first/last semantic or are buggy and missing it. All drivers are > > migrated/fixed to the new open/close_device ops and the unused per-FD > >

Re: [PATCH 02/13] vfio: Introduce a vfio_uninit_group_dev() API call

2021-07-15 Thread Jason Gunthorpe
On Thu, Jul 15, 2021 at 06:49:05AM +0300, Leon Romanovsky wrote: > On Wed, Jul 14, 2021 at 09:20:31PM -0300, Jason Gunthorpe wrote: > > From: Max Gurtovoy > > > > This pairs with vfio_init_group_dev() and allows undoing any state that is > > stored in the vfio_devic

[PATCH 11/13] vfio/ap, ccw: Fix open/close when multiple device FDs are open

2021-07-14 Thread Jason Gunthorpe
. Since these really want the new open/close_device() semantics just change the functions over. Signed-off-by: Jason Gunthorpe --- drivers/s390/cio/vfio_ccw_ops.c | 8 drivers/s390/crypto/vfio_ap_ops.c | 8 2 files changed, 8 insertions(+), 8 deletions(-) diff --git

[PATCH 09/13] vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device set

2021-07-14 Thread Jason Gunthorpe
Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 205 1 file changed, 88 insertions(+), 117 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index fbc20f6d2dd412..ff23168b8dc551 100644 --- a/drivers/vfio/pci/vfio_p

[PATCH 08/13] vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_set

2021-07-14 Thread Jason Gunthorpe
ing corrects a call to pci_dev_driver() without holding the device_lock() and removes a hard wiring to _pci_driver. Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c | 110 ++-- drivers/vfio/vfio.c | 10 include/linux/vfio.h| 2 +

[PATCH 07/13] vfio/pci: Move to the device set infrastructure

2021-07-14 Thread Jason Gunthorpe
ed by what devices pci_reset_bus() touches, which is either the entire bus or only the slot. Rely on the core code to do everything reflck was doing and delete reflck entirely. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci.c

[PATCH 05/13] vfio/fsl: Move to the device set infrastructure

2021-07-14 Thread Jason Gunthorpe
the device set lock is actually protecting, but I think it is related to the interrupt setup. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 152 -- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c| 6 +- drivers/vfio/fsl

[PATCH 13/13] vfio: Remove struct vfio_device_ops open/release

2021-07-14 Thread Jason Gunthorpe
Nothing uses this anymore, delete it. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_mdev.c | 22 -- drivers/vfio/vfio.c | 14 +- include/linux/mdev.h | 7 --- include/linux/vfio.h | 4

[PATCH 10/13] vfio/mbochs: Fix close when multiple device FDs are open

2021-07-14 Thread Jason Gunthorpe
mbochs_close() iterates over global device state and frees it. Currently this is done every time a device FD is closed, but if multiple device FDs are open this could corrupt other still active FDs. Change this to use close_device() so it only runs on the last close. Signed-off-by: Jason

[PATCH 12/13] vfio/gvt: Fix open/close when multiple device FDs are open

2021-07-14 Thread Jason Gunthorpe
these really want the new open/close_device() semantics just change the function over. Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/kvmgt.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c

[PATCH 03/13] vfio: Provide better generic support for open/release vfio_device_ops

2021-07-14 Thread Jason Gunthorpe
into sets. This implementation uses xarray instead of searching through the driver core structures, which simplifies the somewhat tricky locking in this area. Following patches convert all the drivers. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio/mdev/vfio_md

[PATCH 01/13] vfio/samples: Remove module get/put

2021-07-14 Thread Jason Gunthorpe
ot;) Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()") Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 4 samples/vfio-mdev/mdpy.c | 4 2 files changed, 8 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c

[PATCH 06/13] vfio/platform: Use open_device() instead of open coding a refcnt scheme

2021-07-14 Thread Jason Gunthorpe
Platform simply wants to run some code when the device is first opened/last closed. Use the core framework and locking for this. Aside from removing a bit of code this narrows the locking scope from a global lock. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- drivers/vfio

[PATCH 04/13] vfio/samples: Delete useless open/close

2021-07-14 Thread Jason Gunthorpe
The core code no longer requires these ops to be defined, so delete these empty functions and leave the op as NULL. mtty's functions only log a pointless message, delete that entirely. Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe --- samples/vfio-mdev/mbochs.c | 6

[PATCH 00/13] Provide core infrastructure for managing open/release

2021-07-14 Thread Jason Gunthorpe
om the struct pci_device. Overall a few minor bugs are squashed and quite a bit of code is removed through consolidation. Jason Gunthorpe (11): vfio/samples: Remove module get/put vfio: Provide better generic support for open/release vfio_device_ops vfio/samples: Delete useless open/

[PATCH 02/13] vfio: Introduce a vfio_uninit_group_dev() API call

2021-07-14 Thread Jason Gunthorpe
-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe --- Documentation/driver-api/vfio.rst| 4 ++- drivers/vfio/fsl-mc/vfio_fsl_mc.c| 6 +++-- drivers/vfio/mdev/vfio_mdev.c| 13 +++--- drivers/vfio/pci/vfio_pci.c | 6 +++-- drivers/vfio

Re: [PATCH v4 0/2] Add p2p via dmabuf to habanalabs

2021-07-06 Thread Jason Gunthorpe
On Tue, Jul 06, 2021 at 07:35:55PM +0200, Daniel Vetter wrote: > Yup. We dont care about any of the fancy pieces you build on top, nor > does the compiler need to be the optimizing one. Just something that's > good enough to drive the hw in some demons to see how it works and all > that.

<    2   3   4   5   6   7   8   9   10   11   >