All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] softirq: Reserve a bit in tasklet.state for the user
@ 2017-01-23 15:33 Chris Wilson
  2017-01-23 15:44 ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2017-01-23 15:33 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Wilson, Thomas Gleixner, Jens Axboe, Hannes Reinecke,
	Bjorn Helgaas, Chen Fan, Alexander Potapenko

Allow the user to communicate with the tasklet through the atomic state
field by assigning a bit for their use. This can be used, for example,
to differentiate between a tasklet called following an irq or from
process context, where some hardware state may only be valid after the
irq.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: Alexander Potapenko <glider@google.com>
---
 include/linux/interrupt.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 53144e78a369..ab321552089b 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -542,7 +542,8 @@ struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
 enum
 {
 	TASKLET_STATE_SCHED,	/* Tasklet is scheduled for execution */
-	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
+	TASKLET_STATE_RUN,	/* Tasklet is running (SMP only) */
+	TASKLET_STATE_USER	/* Reserved for use by the owner */
 };
 
 #ifdef CONFIG_SMP
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] softirq: Reserve a bit in tasklet.state for the user
  2017-01-23 15:33 [PATCH] softirq: Reserve a bit in tasklet.state for the user Chris Wilson
@ 2017-01-23 15:44 ` Jens Axboe
  2017-01-23 15:57   ` [PATCH] drm/i915: Only run execlist context-switch handler after an interrupt Chris Wilson
  2017-01-23 15:59   ` [PATCH] softirq: Reserve a bit in tasklet.state for the user Thomas Gleixner
  0 siblings, 2 replies; 5+ messages in thread
From: Jens Axboe @ 2017-01-23 15:44 UTC (permalink / raw)
  To: Chris Wilson, linux-kernel
  Cc: Thomas Gleixner, Hannes Reinecke, Bjorn Helgaas, Chen Fan,
	Alexander Potapenko

On 01/23/2017 08:33 AM, Chris Wilson wrote:
> Allow the user to communicate with the tasklet through the atomic state
> field by assigning a bit for their use. This can be used, for example,
> to differentiate between a tasklet called following an irq or from
> process context, where some hardware state may only be valid after the
> irq.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> Cc: Alexander Potapenko <glider@google.com>
> ---
>  include/linux/interrupt.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
> index 53144e78a369..ab321552089b 100644
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -542,7 +542,8 @@ struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
>  enum
>  {
>  	TASKLET_STATE_SCHED,	/* Tasklet is scheduled for execution */
> -	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
> +	TASKLET_STATE_RUN,	/* Tasklet is running (SMP only) */
> +	TASKLET_STATE_USER	/* Reserved for use by the owner */
>  };

I have no problem making that distinction, but it's impossible to ack
this patch without having seen how you plan to utilize it, as the patch
is meaningless on its own.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] drm/i915: Only run execlist context-switch handler after an interrupt
  2017-01-23 15:44 ` Jens Axboe
@ 2017-01-23 15:57   ` Chris Wilson
  2017-01-23 15:59   ` [PATCH] softirq: Reserve a bit in tasklet.state for the user Thomas Gleixner
  1 sibling, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2017-01-23 15:57 UTC (permalink / raw)
  To: linux-kernel, axboe; +Cc: tglx, hare, bhelgaas, glider, Chris Wilson

Mark when we run the execlist tasklet following the interrupt, so we
don't probe a potentially uninitialised register when submitting the
contexts multiple times before the hardware responds.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_irq.c         | 7 +++++--
 drivers/gpu/drm/i915/intel_lrc.c        | 3 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.h | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6fefc34ef602..42be116dd33d 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1349,8 +1349,11 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift)
 {
 	if (iir & (GT_RENDER_USER_INTERRUPT << test_shift))
 		notify_ring(engine);
-	if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << test_shift))
-		tasklet_schedule(&engine->irq_tasklet);
+
+	if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << test_shift)) {
+		set_bit(IRQ_CTX_SWITCH, &engine->irq_tasklet.state);
+		tasklet_hi_schedule(&engine->irq_tasklet);
+	}
 }
 
 static irqreturn_t gen8_gt_irq_ack(struct drm_i915_private *dev_priv,
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 65bb877a726d..b55e38a590c1 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -578,7 +578,7 @@ static void intel_lrc_irq_handler(unsigned long data)
 
 	intel_uncore_forcewake_get(dev_priv, engine->fw_domains);
 
-	if (!execlists_elsp_idle(engine)) {
+	while (test_and_clear_bit(IRQ_CTX_SWITCH, &engine->irq_tasklet.state)) {
 		u32 __iomem *csb_mmio =
 			dev_priv->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_PTR(engine));
 		u32 __iomem *buf =
@@ -1347,6 +1347,7 @@ static int gen8_init_common_ring(struct intel_engine_cs *engine)
 	DRM_DEBUG_DRIVER("Execlists enabled for %s\n", engine->name);
 
 	/* After a GPU reset, we may have requests to replay */
+	clear_bit(IRQ_CTX_SWITCH, &engine->irq_tasklet.state);
 	if (!execlists_elsp_idle(engine)) {
 		engine->execlist_port[0].count = 0;
 		engine->execlist_port[1].count = 0;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 34cdbb6350a8..c63f39d47fdd 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -373,6 +373,7 @@ struct intel_engine_cs {
 
 	/* Execlists */
 	struct tasklet_struct irq_tasklet;
+#define IRQ_CTX_SWITCH (BITS_PER_LONG - 1) /* TASKLET_STATE_USER */
 	struct execlist_port {
 		struct drm_i915_gem_request *request;
 		unsigned int count;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] softirq: Reserve a bit in tasklet.state for the user
  2017-01-23 15:44 ` Jens Axboe
  2017-01-23 15:57   ` [PATCH] drm/i915: Only run execlist context-switch handler after an interrupt Chris Wilson
@ 2017-01-23 15:59   ` Thomas Gleixner
  2017-01-23 16:10     ` Peter Zijlstra
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2017-01-23 15:59 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Chris Wilson, LKML, Hannes Reinecke, Bjorn Helgaas, Chen Fan,
	Alexander Potapenko, Ingo Molnar, Peter Zijlstra

On Mon, 23 Jan 2017, Jens Axboe wrote:

> On 01/23/2017 08:33 AM, Chris Wilson wrote:
> > Allow the user to communicate with the tasklet through the atomic state
> > field by assigning a bit for their use. This can be used, for example,
> > to differentiate between a tasklet called following an irq or from
> > process context, where some hardware state may only be valid after the
> > irq.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: Hannes Reinecke <hare@suse.com>
> > Cc: Bjorn Helgaas <bhelgaas@google.com>
> > Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> > Cc: Alexander Potapenko <glider@google.com>
> > ---
> >  include/linux/interrupt.h | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
> > index 53144e78a369..ab321552089b 100644
> > --- a/include/linux/interrupt.h
> > +++ b/include/linux/interrupt.h
> > @@ -542,7 +542,8 @@ struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
> >  enum
> >  {
> >  	TASKLET_STATE_SCHED,	/* Tasklet is scheduled for execution */
> > -	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
> > +	TASKLET_STATE_RUN,	/* Tasklet is running (SMP only) */
> > +	TASKLET_STATE_USER	/* Reserved for use by the owner */
> >  };
> 
> I have no problem making that distinction, but it's impossible to ack
> this patch without having seen how you plan to utilize it, as the patch
> is meaningless on its own.

Right and w/o well defined semantics of this bit it's not at all
acceptable. tasklets have vagely semantics already, we really don't need to
increase that horror.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] softirq: Reserve a bit in tasklet.state for the user
  2017-01-23 15:59   ` [PATCH] softirq: Reserve a bit in tasklet.state for the user Thomas Gleixner
@ 2017-01-23 16:10     ` Peter Zijlstra
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2017-01-23 16:10 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Jens Axboe, Chris Wilson, LKML, Hannes Reinecke, Bjorn Helgaas,
	Chen Fan, Alexander Potapenko, Ingo Molnar

On Mon, Jan 23, 2017 at 04:59:32PM +0100, Thomas Gleixner wrote:
> On Mon, 23 Jan 2017, Jens Axboe wrote:
> 
> > On 01/23/2017 08:33 AM, Chris Wilson wrote:
> > > Allow the user to communicate with the tasklet through the atomic state
> > > field by assigning a bit for their use. This can be used, for example,
> > > to differentiate between a tasklet called following an irq or from
> > > process context, where some hardware state may only be valid after the
> > > irq.

Egads, this sounds like a horrible hack. What does 'after and irq' even
mean?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-23 16:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 15:33 [PATCH] softirq: Reserve a bit in tasklet.state for the user Chris Wilson
2017-01-23 15:44 ` Jens Axboe
2017-01-23 15:57   ` [PATCH] drm/i915: Only run execlist context-switch handler after an interrupt Chris Wilson
2017-01-23 15:59   ` [PATCH] softirq: Reserve a bit in tasklet.state for the user Thomas Gleixner
2017-01-23 16:10     ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.