Message ID | 20220928061918.6340-3-niranjana.vishwanathapura@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/vm_bind: Add VM_BIND functionality | expand |
On 28/09/2022 07:19, Niranjana Vishwanathapura wrote: > Add function __i915_sw_fence_await_reservation() for > asynchronous wait on a dma-resv object with specified > dma_resv_usage. This is required for async vma unbind > with vm_bind. > > Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> > --- > drivers/gpu/drm/i915/i915_sw_fence.c | 28 +++++++++++++++++++++------- > drivers/gpu/drm/i915/i915_sw_fence.h | 23 +++++++++++++++++------ > 2 files changed, 38 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c > index cc2a8821d22a..b7a10c374a08 100644 > --- a/drivers/gpu/drm/i915/i915_sw_fence.c > +++ b/drivers/gpu/drm/i915/i915_sw_fence.c > @@ -7,7 +7,6 @@ > #include <linux/slab.h> > #include <linux/dma-fence.h> > #include <linux/irq_work.h> > -#include <linux/dma-resv.h> > > #include "i915_sw_fence.h" > #include "i915_selftest.h" > @@ -569,11 +568,26 @@ int __i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, > return ret; > } > > -int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > - struct dma_resv *resv, > - bool write, > - unsigned long timeout, > - gfp_t gfp) > +/** > + * __i915_sw_fence_await_reservation() - Setup a fence to wait on a dma-resv > + * object with specified usage. > + * @fence: the fence that needs to wait > + * @resv: dma-resv object > + * @usage: dma_resv_usage (See enum dma_resv_usage) > + * @timeout: how long to wait in jiffies > + * @gfp: allocation mode > + * > + * Setup the @fence to asynchronously wait on dma-resv object @resv for usage > + * @usage to complete before signaling. s/usage @usage/@usage/ ? > + * > + * Returns 0 if there is nothing to wait on, -ve upon error and >0 upon What does "-ve" mean btw? Acked-by: Matthew Auld <matthew.auld@intel.com> > + * successfully setting up the wait. > + */ > +int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > + struct dma_resv *resv, > + enum dma_resv_usage usage, > + unsigned long timeout, > + gfp_t gfp) > { > struct dma_resv_iter cursor; > struct dma_fence *f; > @@ -582,7 +596,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > debug_fence_assert(fence); > might_sleep_if(gfpflags_allow_blocking(gfp)); > > - dma_resv_iter_begin(&cursor, resv, dma_resv_usage_rw(write)); > + dma_resv_iter_begin(&cursor, resv, usage); > dma_resv_for_each_fence_unlocked(&cursor, f) { > pending = i915_sw_fence_await_dma_fence(fence, f, timeout, > gfp); > diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h > index f752bfc7c6e1..9c4859dc4c0d 100644 > --- a/drivers/gpu/drm/i915/i915_sw_fence.h > +++ b/drivers/gpu/drm/i915/i915_sw_fence.h > @@ -10,13 +10,13 @@ > #define _I915_SW_FENCE_H_ > > #include <linux/dma-fence.h> > +#include <linux/dma-resv.h> > #include <linux/gfp.h> > #include <linux/kref.h> > #include <linux/notifier.h> /* for NOTIFY_DONE */ > #include <linux/wait.h> > > struct completion; > -struct dma_resv; > struct i915_sw_fence; > > enum i915_sw_fence_notify { > @@ -89,11 +89,22 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, > unsigned long timeout, > gfp_t gfp); > > -int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > - struct dma_resv *resv, > - bool write, > - unsigned long timeout, > - gfp_t gfp); > +int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > + struct dma_resv *resv, > + enum dma_resv_usage usage, > + unsigned long timeout, > + gfp_t gfp); > + > +static inline int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, > + struct dma_resv *resv, > + bool write, > + unsigned long timeout, > + gfp_t gfp) > +{ > + return __i915_sw_fence_await_reservation(fence, resv, > + dma_resv_usage_rw(write), > + timeout, gfp); > +} > > bool i915_sw_fence_await(struct i915_sw_fence *fence); > void i915_sw_fence_complete(struct i915_sw_fence *fence);
On Wed, Sep 28, 2022 at 06:39:05PM +0100, Matthew Auld wrote: >On 28/09/2022 07:19, Niranjana Vishwanathapura wrote: >>Add function __i915_sw_fence_await_reservation() for >>asynchronous wait on a dma-resv object with specified >>dma_resv_usage. This is required for async vma unbind >>with vm_bind. >> >>Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> >>--- >> drivers/gpu/drm/i915/i915_sw_fence.c | 28 +++++++++++++++++++++------- >> drivers/gpu/drm/i915/i915_sw_fence.h | 23 +++++++++++++++++------ >> 2 files changed, 38 insertions(+), 13 deletions(-) >> >>diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c >>index cc2a8821d22a..b7a10c374a08 100644 >>--- a/drivers/gpu/drm/i915/i915_sw_fence.c >>+++ b/drivers/gpu/drm/i915/i915_sw_fence.c >>@@ -7,7 +7,6 @@ >> #include <linux/slab.h> >> #include <linux/dma-fence.h> >> #include <linux/irq_work.h> >>-#include <linux/dma-resv.h> >> #include "i915_sw_fence.h" >> #include "i915_selftest.h" >>@@ -569,11 +568,26 @@ int __i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, >> return ret; >> } >>-int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >>- struct dma_resv *resv, >>- bool write, >>- unsigned long timeout, >>- gfp_t gfp) >>+/** >>+ * __i915_sw_fence_await_reservation() - Setup a fence to wait on a dma-resv >>+ * object with specified usage. >>+ * @fence: the fence that needs to wait >>+ * @resv: dma-resv object >>+ * @usage: dma_resv_usage (See enum dma_resv_usage) >>+ * @timeout: how long to wait in jiffies >>+ * @gfp: allocation mode >>+ * >>+ * Setup the @fence to asynchronously wait on dma-resv object @resv for usage >>+ * @usage to complete before signaling. > >s/usage @usage/@usage/ ? Thanks for the review Matt. Sure, will fix. > >>+ * >>+ * Returns 0 if there is nothing to wait on, -ve upon error and >0 upon > >What does "-ve" mean btw? > -ve error code. Will update Regards, Niranjana >Acked-by: Matthew Auld <matthew.auld@intel.com> > >>+ * successfully setting up the wait. >>+ */ >>+int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >>+ struct dma_resv *resv, >>+ enum dma_resv_usage usage, >>+ unsigned long timeout, >>+ gfp_t gfp) >> { >> struct dma_resv_iter cursor; >> struct dma_fence *f; >>@@ -582,7 +596,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >> debug_fence_assert(fence); >> might_sleep_if(gfpflags_allow_blocking(gfp)); >>- dma_resv_iter_begin(&cursor, resv, dma_resv_usage_rw(write)); >>+ dma_resv_iter_begin(&cursor, resv, usage); >> dma_resv_for_each_fence_unlocked(&cursor, f) { >> pending = i915_sw_fence_await_dma_fence(fence, f, timeout, >> gfp); >>diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h >>index f752bfc7c6e1..9c4859dc4c0d 100644 >>--- a/drivers/gpu/drm/i915/i915_sw_fence.h >>+++ b/drivers/gpu/drm/i915/i915_sw_fence.h >>@@ -10,13 +10,13 @@ >> #define _I915_SW_FENCE_H_ >> #include <linux/dma-fence.h> >>+#include <linux/dma-resv.h> >> #include <linux/gfp.h> >> #include <linux/kref.h> >> #include <linux/notifier.h> /* for NOTIFY_DONE */ >> #include <linux/wait.h> >> struct completion; >>-struct dma_resv; >> struct i915_sw_fence; >> enum i915_sw_fence_notify { >>@@ -89,11 +89,22 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, >> unsigned long timeout, >> gfp_t gfp); >>-int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >>- struct dma_resv *resv, >>- bool write, >>- unsigned long timeout, >>- gfp_t gfp); >>+int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >>+ struct dma_resv *resv, >>+ enum dma_resv_usage usage, >>+ unsigned long timeout, >>+ gfp_t gfp); >>+ >>+static inline int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, >>+ struct dma_resv *resv, >>+ bool write, >>+ unsigned long timeout, >>+ gfp_t gfp) >>+{ >>+ return __i915_sw_fence_await_reservation(fence, resv, >>+ dma_resv_usage_rw(write), >>+ timeout, gfp); >>+} >> bool i915_sw_fence_await(struct i915_sw_fence *fence); >> void i915_sw_fence_complete(struct i915_sw_fence *fence);
diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c index cc2a8821d22a..b7a10c374a08 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/i915_sw_fence.c @@ -7,7 +7,6 @@ #include <linux/slab.h> #include <linux/dma-fence.h> #include <linux/irq_work.h> -#include <linux/dma-resv.h> #include "i915_sw_fence.h" #include "i915_selftest.h" @@ -569,11 +568,26 @@ int __i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, return ret; } -int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, - struct dma_resv *resv, - bool write, - unsigned long timeout, - gfp_t gfp) +/** + * __i915_sw_fence_await_reservation() - Setup a fence to wait on a dma-resv + * object with specified usage. + * @fence: the fence that needs to wait + * @resv: dma-resv object + * @usage: dma_resv_usage (See enum dma_resv_usage) + * @timeout: how long to wait in jiffies + * @gfp: allocation mode + * + * Setup the @fence to asynchronously wait on dma-resv object @resv for usage + * @usage to complete before signaling. + * + * Returns 0 if there is nothing to wait on, -ve upon error and >0 upon + * successfully setting up the wait. + */ +int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, + struct dma_resv *resv, + enum dma_resv_usage usage, + unsigned long timeout, + gfp_t gfp) { struct dma_resv_iter cursor; struct dma_fence *f; @@ -582,7 +596,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, debug_fence_assert(fence); might_sleep_if(gfpflags_allow_blocking(gfp)); - dma_resv_iter_begin(&cursor, resv, dma_resv_usage_rw(write)); + dma_resv_iter_begin(&cursor, resv, usage); dma_resv_for_each_fence_unlocked(&cursor, f) { pending = i915_sw_fence_await_dma_fence(fence, f, timeout, gfp); diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h index f752bfc7c6e1..9c4859dc4c0d 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.h +++ b/drivers/gpu/drm/i915/i915_sw_fence.h @@ -10,13 +10,13 @@ #define _I915_SW_FENCE_H_ #include <linux/dma-fence.h> +#include <linux/dma-resv.h> #include <linux/gfp.h> #include <linux/kref.h> #include <linux/notifier.h> /* for NOTIFY_DONE */ #include <linux/wait.h> struct completion; -struct dma_resv; struct i915_sw_fence; enum i915_sw_fence_notify { @@ -89,11 +89,22 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence, unsigned long timeout, gfp_t gfp); -int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, - struct dma_resv *resv, - bool write, - unsigned long timeout, - gfp_t gfp); +int __i915_sw_fence_await_reservation(struct i915_sw_fence *fence, + struct dma_resv *resv, + enum dma_resv_usage usage, + unsigned long timeout, + gfp_t gfp); + +static inline int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, + struct dma_resv *resv, + bool write, + unsigned long timeout, + gfp_t gfp) +{ + return __i915_sw_fence_await_reservation(fence, resv, + dma_resv_usage_rw(write), + timeout, gfp); +} bool i915_sw_fence_await(struct i915_sw_fence *fence); void i915_sw_fence_complete(struct i915_sw_fence *fence);
Add function __i915_sw_fence_await_reservation() for asynchronous wait on a dma-resv object with specified dma_resv_usage. This is required for async vma unbind with vm_bind. Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> --- drivers/gpu/drm/i915/i915_sw_fence.c | 28 +++++++++++++++++++++------- drivers/gpu/drm/i915/i915_sw_fence.h | 23 +++++++++++++++++------ 2 files changed, 38 insertions(+), 13 deletions(-)