mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Qais Yousef <qais.yousef@imgtec.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	Jason Cooper <jason@lakedaemon.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	Mark Rutland <Mark.Rutland@arm.com>,
	Jiang Liu <jiang.liu@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH 01/10] irqchip: irq-mips-gic: export gic_send_ipi
Date: Wed, 26 Aug 2015 23:40:35 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.11.1508262101450.15006@nanos> (raw)
In-Reply-To: <55DDDE3C.8030609@imgtec.com>

On Wed, 26 Aug 2015, Qais Yousef wrote:
> On 08/26/2015 04:08 PM, Thomas Gleixner wrote:
> > IPI = Inter Processor Interrupt
> > 
> > As the name says that's an interrupt which goes from one cpu to
> > another. So an IPI has a very clear target.
> 
> OK understood. My interpretation of the processor here was the difference. I
> was viewing the whole linux cpus as one unit with regard to its coprocessors.

You can only view it this way if you talk about peripheral interrupts
which are not used as per cpu interrupts and can be routed to a single
cpu or a set of cpus via set_affinity.

> > Whether the platform implements IPIs via general interrupts which are
> > made affine to a particular cpu or some other specialized mechanism is
> > completely irrelevant. An IPI is not subject to affinity settings,
> > period.
> > 
> > So if you want to use an IPI then you need a target cpu for that IPI.
> > 
> > If you want something which can be affined to any cpu, then you need a
> > general interrupt and not an IPI.
> 
> We are using IPIs to exchange interrupts. Affinity is not important to me.

That's a bold statement. If you chose CPU x as the target for the
interrupts received from the coprocessor, then you have pinned the
processing for this stuff on to CPU x. So you limit the freedom of
moving stuff around on the linux cpus.

And if your root irq controller supports sending normal device
interrupts in the same or a similar way as it sends IPIs you can spare
quite some extra handling on the linux side for receiving the
coprocessor interrupt, i.e. you can use just the bog standard
request_irq() mechanism and have the ability to set the affinity of
that interrupt from user space so you can move it to the core on which
your processing happens. Definitely simpler and more flexible, so I
would go there if the hardware allows.

But back to the IPIs. We need infrastructure and DT support to:

1) reserve an IPI

2) send an IPI

3) request/free an IPI

#1 We have no infrastructure for that, but we definitely need one.

   We can look at the IPI as a single linux irq number which is
   replicated on all cpu cores. The replication can happen in hardware
   or by software, but that depends on the underlying root irq
   controller. How that is implemented does not matter for the
   reservation.

   The most flexible and platform independent solution would be to
   describe the IPI space as a seperate irq domain. In most cases this
   would be a hierarchical domain stacked on the root irq domain:

   [IPI-domain] --> [GIC-MIPS-domain]

   on x86 this would be:

   [IPI-domain] --> [vector-domain]

   That needs some change how the IPIs which are used by the kernel
   (rescheduling, function call ..) are set up, but we get a proper
   management and collision avoidance that way. Depending on the
   platform we could actually remove the whole IPI compile time
   reservation and hand out IPIs at boot time on demand and
   dynamically.

   So the reservation function would be something like:

   unsigned int irq_reserve_ipi(const struct cpumask *dest, void *devid);

   @dest contains the possible targets for the IPI. So for generic
   linux IPIs this would be cpu_possible_mask. For your coprocessor
   the target would be a cpumask with just the bit of the coprocessor
   core set. If you need to use an IPI for sending an interrupt from
   the coprocessor to a specific linux core then @dest will contain
   just that target cpu.

   @devid is stored in the IPI domain for sanity checks during
   operation.

   The function returns a linux irq number or 0 if allocation fails.

   We need a complementary interface as well, so you can hand back the
   IPI to the core when the coprocessor is disabled:

   void irq_destroy_ipi(unsigned int irq, void *devid);


   To configure your coprocessor proper, we need a translation
   mechanism from the linux interrupt number to the magic value which
   needs to be written into the trigger register when the coprocessor
   wants to send an interrupt or an IPI.

   int irq_get_irq_hwcfg(unsigned int irq, struct irq_hwcfg *cfg);

   struct irq_hwcfg needs to be defined, but it might look like this:

     {
	/* Generic fields */
	x;
	...
	union {
	      mips_gic;
	      ...
	};
     };

   The actual hw specific value(s) need to be filled in from the irq
   domain specific code.


#2 We have no generic mechanism for that either.

   Something like this is needed:

   void irq_send_ipi(unsigned int irq, const struct cpumask *dest,
   		     void *devid);	      

   @dest is for generic linux IPIs and can be NULL so the IPI is sent to
    	 the core(s) which have been handed in at reservation time

   @devid is used to sanity check the driver call.

   So that finally will call down via a irq chip callback into the
   code which sends the IPI.


#3 Now you get lucky, because we actually have an interface for this

   request_percpu_irq()
   free_percpu_irq()
   disable_percpu_irq()
   enable_percpu_irq()

   Though there is a caveat. enable/disable_percpu_irq() must be
   called from the target cpu, but that should be a solvable problem.

   And at the IPI-domain side we need sanity checks whether the cpu
   from which enable/disable is called is actually configured in the
   reservation mask.
   
   There are a few other nasty details, but that's not important for
   the big picture.

   As I said above, I really would recommend to avoid that if possible
   because a bog standard device interrupt is way simpler to deal
   with. 

That's certainly not the quick and dirty solution you are looking for,
but exposing IPIs to drivers by anything else than a well thought out
infrastructure is not going to happen.

Thanks,

	tglx

  reply	other threads:[~2015-08-26 21:41 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 12:39 [PATCH 00/10] Add support for img AXD audio hardware decoder Qais Yousef
2015-08-24 12:39 ` [PATCH 01/10] irqchip: irq-mips-gic: export gic_send_ipi Qais Yousef
2015-08-24 12:49   ` Thomas Gleixner
2015-08-24 13:02     ` Qais Yousef
2015-08-24 13:32       ` Marc Zyngier
2015-08-24 14:27         ` Qais Yousef
2015-08-24 15:07           ` Thomas Gleixner
2015-08-24 16:39             ` Qais Yousef
2015-08-24 17:17               ` Marc Zyngier
2015-08-26 11:23                 ` Qais Yousef
2015-08-26 13:19                   ` Thomas Gleixner
2015-08-26 14:57                     ` Qais Yousef
2015-08-26 15:08                       ` Thomas Gleixner
2015-08-26 15:41                         ` Qais Yousef
2015-08-26 21:40                           ` Thomas Gleixner [this message]
2015-08-27  2:22                             ` Jiang Liu
2015-08-28 10:38                             ` Qais Yousef
2015-08-28 14:22                               ` Thomas Gleixner
2015-08-28 15:12                                 ` Qais Yousef
2015-09-02  9:33                                 ` Qais Yousef
2015-09-02  9:55                                   ` Marc Zyngier
2015-09-02 10:48                                     ` Qais Yousef
2015-09-02 11:53                                       ` Marc Zyngier
2015-09-02 13:25                                         ` Qais Yousef
2015-09-02 14:14                                           ` Marc Zyngier
2015-09-02 12:12                                     ` Jason Cooper
2015-08-24 14:55       ` Thomas Gleixner
2015-08-24 15:11         ` Qais Yousef
2015-08-24 12:39 ` [PATCH 02/10] dt: add img,axd.txt device tree binding document Qais Yousef
2015-08-24 13:26   ` Mark Rutland
2015-08-24 13:49     ` Qais Yousef
2015-08-24 12:39 ` [PATCH 03/10] ALSA: add AXD Audio Processing IP alsa driver Qais Yousef
2015-08-26 18:37   ` Mark Brown
2015-08-27 12:15     ` Qais Yousef
2015-08-27 15:32       ` Mark Brown
2015-08-28  9:22         ` Qais Yousef
2015-09-03 12:46           ` Mark Brown
2015-08-24 12:39 ` [PATCH 04/10] ALSA: axd: add fw binary header manipulation files Qais Yousef
2015-08-24 12:39 ` [PATCH 05/10] ALSA: axd: add buffers " Qais Yousef
2015-08-26 18:43   ` Mark Brown
2015-08-27 14:21     ` Qais Yousef
2015-08-29  9:47       ` Mark Brown
2015-09-01 10:00         ` Qais Yousef
2015-09-03 12:32           ` Mark Brown
2015-09-14  9:11             ` Qais Yousef
2015-09-14 18:50               ` Mark Brown
2015-08-24 12:39 ` [PATCH 06/10] ALSA: axd: add basic files for sending/receiving axd cmds Qais Yousef
2015-08-26 19:16   ` Mark Brown
2015-08-27 15:40     ` Qais Yousef
2015-08-29 10:18       ` Mark Brown
2015-09-01 10:46         ` Qais Yousef
2015-09-03 12:40           ` Mark Brown
2015-08-24 12:39 ` [PATCH 07/10] ALSA: axd: add cmd interface helper functions Qais Yousef
2015-08-24 12:39 ` [PATCH 08/10] ALSA: axd: add low level AXD platform setup files Qais Yousef
2015-08-24 12:39 ` [PATCH 09/10] ALSA: axd: add alsa compress offload operations Qais Yousef
2015-08-24 12:39 ` [PATCH 10/10] ALSA: axd: add Makefile Qais Yousef
2015-08-26 18:04 ` [PATCH 00/10] Add support for img AXD audio hardware decoder Mark Brown
2015-08-27  9:07   ` Qais Yousef

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=alpine.DEB.2.11.1508262101450.15006@nanos \
    --to=tglx@linutronix.de \
    --cc=Mark.Rutland@arm.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jason@lakedaemon.net \
    --cc=jiang.liu@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marc.zyngier@arm.com \
    --cc=qais.yousef@imgtec.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

all inboxes | Powered by JetHome®