From: Randy Dunlap <rdunlap@xenotime.net>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
Rob Herring <rob.herring@calxeda.com>,
Thomas Gleixner <tglx@linutronix.de>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFCv2 01/14] irq_domain: add documentation and MAINTAINERS entry.
Date: Tue, 24 Jan 2012 11:13:41 -0800 [thread overview]
Message-ID: <4F1F02E5.3000605@xenotime.net> (raw)
In-Reply-To: <1327352870-14687-2-git-send-email-grant.likely@secretlab.ca>
On 01/23/2012 01:07 PM, Grant Likely wrote:
> Documentation for irq_domain library which will be created in subsequent
> patches.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
> Documentation/IRQ-domain.txt | 113 ++++++++++++++++++++++++++++++++++++++++++
> MAINTAINERS | 9 +++
> 2 files changed, 122 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/IRQ-domain.txt
>
> diff --git a/Documentation/IRQ-domain.txt b/Documentation/IRQ-domain.txt
> new file mode 100644
> index 0000000..247f32a
> --- /dev/null
> +++ b/Documentation/IRQ-domain.txt
> @@ -0,0 +1,113 @@
> +irq_domain interrupt number mapping library
> +
> +The current design of the Linux kernel uses a single large number
> +space where each separate IRQ source is assigned a different number.
> +This is simple when there is only one interrupt controller, but in
> +systems with controllers the kernel must ensure that each one does not
with multiple interrupt controllers,
> +get assigned overlapping allocations of Linux irq numbers.
IRQ
> +
> +The irq_alloc_desc*() and irq_free_desc*() API provides allocation of
I would say: APIs provide
> +irq numbers, but it doesn't provide any support for reverse mapping of
IRQ numbers, but they don't provide
> +the controller-local irq (hwirq) number into the Linux irq number
IRQ IRQ
> +space.
> +
> +The irq_domain library adds mapping between hwirq and irq numbers on
IRQ
> +top of the irq_alloc_desc*() API. An irq_domain to manage mapping is
> +preferred over interrupt controller drivers open coding their own
> +reverse mapping scheme.
> +
> +irq_domain also implements translation from Device Tree interrupt
> +specifiers to hwirq numbers, and can be easily extended to support
> +other irq topology data sources.
IRQ
> +
> +=== irq_domain usage ===
> +An interrupt controller driver creates and registers an irq_domain by
> +calling one of the irq_domain_add_*() functions (each mapping method
> +has a different allocator function, more on that later). The function
> +will return a pointer to the irq_domain on success. It must provide
"It" ? The caller ?
> +the allocator function with an irq_domain_ops structure with the .map
> +callback populated as a minimum.
> +
> +In most cases, the irq_domain will begin empty without any mappings
> +between hwirq and irq numbers. Mappings are added to the irq_domain
IRQ
> +by calling irq_create_mapping() which accepts the irq_domain and a
> +hwirq number as arguments. If a mapping for the hwirq doesn't already
> +exist then it will allocate a new linux irq_desc, associate it with
Linux
> +the hwirq, and call the .map() callback so the driver can perform any
> +required hardware setup.
> +
> +When an interrupt is received, irq_find_mapping() function should
> +be used to find the Linux irq number from the hwirq number.
IRQ
> +
> +If the driver has the Linux irq number or the irq_data pointer, and
IRQ
> +needs to know the associated hwirq number (such as in the irq_chip
> +callbacks) then it can be directly obtained from irq_data->hwirq.
> +
> +=== Types of irq_domain mappings ===
> +There are several mechanisms available for reverse mapping from hwirq
> +to Linux irq, and each mechanism uses a different allocation function
IRQ,
.
> +Which reverse map type should be used depends on the use case. Each
> +of the reverse map types are described below:
> +
> +==== Linear ====
> +irq_domain_add_linear()
> +
> +The linear reverse map maintains a fixed size table indexed by the
> +hwirq number. When a hwirq is mapped, an irq_desc is allocated for
> +the hwirq, and the irq number is stored in the table.
IRQ
> +
> +The Linear map is a good choice when the maximum number of hwirqs is
> +fixed and a relatively small number (~ < 256). The advantages of this
> +map are fixed time lookup for irq numbers, and irq_descs are only
IRQ
> +allocated for in-use irqs. The disadvantage is that the table must be
> +as large as the largest possible hwirq number.
> +
> +The majority of drivers should use the linear map.
> +
> +==== Tree ====
> +irq_domain_add_tree()
> +
> +The irq_domain maintains a radix tree map from hwirq numbers to linux
Linux
> +irqs. When an hwirq is mapped, and irq_desc is allocated and the
IRQs. When a hwirq an
> +hwirq is used as the lookup key for the radix tree.
> +
> +The tree map is a good choice if the hwirq number can be very large
> +since it doesn't need to allocate a table as large as the largest
> +hwirq number. The disadvantage is that hwirq to irq number lookup is
IRQ
> +dependent on how many entries are in the table.
> +
> +Very few drivers should need this mapping. At the moment, powerpc
> +iseries is the only user.
> +
> +==== No Map ===-
> +irq_domain_add_nomap()
> +
> +The No Map mapping is to be used when the hwirq number is
> +programmable in the hardware. In this case it is best to program the
> +Linux irq number into the hardware itself so that no mapping is
IRQ
> +required. Calling irq_create_direct_mapping() will allocate a linux
Linux
> +irq number and call the .map() callback so that driver can program the
IRQ
> +Linux irq number into the hardware.
IRQ
> +
> +Most drivers cannot use this mapping.
> +
> +==== Legacy ====
> +irq_domain_add_legacy()
> +irq_domain_add_legacy_isa()
> +
> +The Legacy mapping is a special case for drivers that already have a
> +range of irq_descs allocated for the hwirqs. It is used when the
> +driver cannot be immediately converted to use the linear mapping, such
> +as when the driver is used in a system with fixed irq number
IRQ
> +assignments, as is typical in many embedded system board files.
> +
> +The legacy map assumes a contiguous range of irq numbers has already
IRQ
> +been allocated for the controller and that the irq number can be
IRQ
> +calculated by adding a fixed offset to the hwirq number, and
> +visa-versa. The disadvantage is that it requires the interrupt
> +controller to manage irq allocations and it requires an irq_desc to be
IRQ
> +allocated for every hwirq, even if it is unused.
> +
> +Drivers should only use the legacy map if they have fixed irq mappings
IRQ
> +(#define IRQ_* in embedded board files). For example, ISA controllers
> +mapped to Linux irqs 0-15 would use the legacy map.
IRQs
--
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
WARNING: multiple messages have this Message-ID (diff)
From: Randy Dunlap <rdunlap@xenotime.net>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
devicetree-discuss@lists.ozlabs.org,
Milton Miller <miltonm@bga.com>,
benh@kernel.crashing.org, Rob Herring <rob.herring@calxeda.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [RFCv2 01/14] irq_domain: add documentation and MAINTAINERS entry.
Date: Tue, 24 Jan 2012 11:13:41 -0800 [thread overview]
Message-ID: <4F1F02E5.3000605@xenotime.net> (raw)
In-Reply-To: <1327352870-14687-2-git-send-email-grant.likely@secretlab.ca>
On 01/23/2012 01:07 PM, Grant Likely wrote:
> Documentation for irq_domain library which will be created in subsequent
> patches.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
> Documentation/IRQ-domain.txt | 113 ++++++++++++++++++++++++++++++++++++++++++
> MAINTAINERS | 9 +++
> 2 files changed, 122 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/IRQ-domain.txt
>
> diff --git a/Documentation/IRQ-domain.txt b/Documentation/IRQ-domain.txt
> new file mode 100644
> index 0000000..247f32a
> --- /dev/null
> +++ b/Documentation/IRQ-domain.txt
> @@ -0,0 +1,113 @@
> +irq_domain interrupt number mapping library
> +
> +The current design of the Linux kernel uses a single large number
> +space where each separate IRQ source is assigned a different number.
> +This is simple when there is only one interrupt controller, but in
> +systems with controllers the kernel must ensure that each one does not
with multiple interrupt controllers,
> +get assigned overlapping allocations of Linux irq numbers.
IRQ
> +
> +The irq_alloc_desc*() and irq_free_desc*() API provides allocation of
I would say: APIs provide
> +irq numbers, but it doesn't provide any support for reverse mapping of
IRQ numbers, but they don't provide
> +the controller-local irq (hwirq) number into the Linux irq number
IRQ IRQ
> +space.
> +
> +The irq_domain library adds mapping between hwirq and irq numbers on
IRQ
> +top of the irq_alloc_desc*() API. An irq_domain to manage mapping is
> +preferred over interrupt controller drivers open coding their own
> +reverse mapping scheme.
> +
> +irq_domain also implements translation from Device Tree interrupt
> +specifiers to hwirq numbers, and can be easily extended to support
> +other irq topology data sources.
IRQ
> +
> +=== irq_domain usage ===
> +An interrupt controller driver creates and registers an irq_domain by
> +calling one of the irq_domain_add_*() functions (each mapping method
> +has a different allocator function, more on that later). The function
> +will return a pointer to the irq_domain on success. It must provide
"It" ? The caller ?
> +the allocator function with an irq_domain_ops structure with the .map
> +callback populated as a minimum.
> +
> +In most cases, the irq_domain will begin empty without any mappings
> +between hwirq and irq numbers. Mappings are added to the irq_domain
IRQ
> +by calling irq_create_mapping() which accepts the irq_domain and a
> +hwirq number as arguments. If a mapping for the hwirq doesn't already
> +exist then it will allocate a new linux irq_desc, associate it with
Linux
> +the hwirq, and call the .map() callback so the driver can perform any
> +required hardware setup.
> +
> +When an interrupt is received, irq_find_mapping() function should
> +be used to find the Linux irq number from the hwirq number.
IRQ
> +
> +If the driver has the Linux irq number or the irq_data pointer, and
IRQ
> +needs to know the associated hwirq number (such as in the irq_chip
> +callbacks) then it can be directly obtained from irq_data->hwirq.
> +
> +=== Types of irq_domain mappings ===
> +There are several mechanisms available for reverse mapping from hwirq
> +to Linux irq, and each mechanism uses a different allocation function
IRQ,
.
> +Which reverse map type should be used depends on the use case. Each
> +of the reverse map types are described below:
> +
> +==== Linear ====
> +irq_domain_add_linear()
> +
> +The linear reverse map maintains a fixed size table indexed by the
> +hwirq number. When a hwirq is mapped, an irq_desc is allocated for
> +the hwirq, and the irq number is stored in the table.
IRQ
> +
> +The Linear map is a good choice when the maximum number of hwirqs is
> +fixed and a relatively small number (~ < 256). The advantages of this
> +map are fixed time lookup for irq numbers, and irq_descs are only
IRQ
> +allocated for in-use irqs. The disadvantage is that the table must be
> +as large as the largest possible hwirq number.
> +
> +The majority of drivers should use the linear map.
> +
> +==== Tree ====
> +irq_domain_add_tree()
> +
> +The irq_domain maintains a radix tree map from hwirq numbers to linux
Linux
> +irqs. When an hwirq is mapped, and irq_desc is allocated and the
IRQs. When a hwirq an
> +hwirq is used as the lookup key for the radix tree.
> +
> +The tree map is a good choice if the hwirq number can be very large
> +since it doesn't need to allocate a table as large as the largest
> +hwirq number. The disadvantage is that hwirq to irq number lookup is
IRQ
> +dependent on how many entries are in the table.
> +
> +Very few drivers should need this mapping. At the moment, powerpc
> +iseries is the only user.
> +
> +==== No Map ===-
> +irq_domain_add_nomap()
> +
> +The No Map mapping is to be used when the hwirq number is
> +programmable in the hardware. In this case it is best to program the
> +Linux irq number into the hardware itself so that no mapping is
IRQ
> +required. Calling irq_create_direct_mapping() will allocate a linux
Linux
> +irq number and call the .map() callback so that driver can program the
IRQ
> +Linux irq number into the hardware.
IRQ
> +
> +Most drivers cannot use this mapping.
> +
> +==== Legacy ====
> +irq_domain_add_legacy()
> +irq_domain_add_legacy_isa()
> +
> +The Legacy mapping is a special case for drivers that already have a
> +range of irq_descs allocated for the hwirqs. It is used when the
> +driver cannot be immediately converted to use the linear mapping, such
> +as when the driver is used in a system with fixed irq number
IRQ
> +assignments, as is typical in many embedded system board files.
> +
> +The legacy map assumes a contiguous range of irq numbers has already
IRQ
> +been allocated for the controller and that the irq number can be
IRQ
> +calculated by adding a fixed offset to the hwirq number, and
> +visa-versa. The disadvantage is that it requires the interrupt
> +controller to manage irq allocations and it requires an irq_desc to be
IRQ
> +allocated for every hwirq, even if it is unused.
> +
> +Drivers should only use the legacy map if they have fixed irq mappings
IRQ
> +(#define IRQ_* in embedded board files). For example, ISA controllers
> +mapped to Linux irqs 0-15 would use the legacy map.
IRQs
--
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
next prev parent reply other threads:[~2012-01-24 18:22 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-23 21:07 [RFCv2 00/14] Grant Likely
2012-01-23 21:07 ` [RFCv2 01/14] irq_domain: add documentation and MAINTAINERS entry Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-24 19:13 ` Randy Dunlap [this message]
2012-01-24 19:13 ` Randy Dunlap
2012-01-28 17:05 ` Grant Likely
2012-01-28 17:05 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 02/14] dt: Make irqdomain less verbose Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 03/14] irq_domain: Make irq_domain structure match powerpc's irq_host Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-24 21:38 ` Rob Herring
2012-01-24 21:38 ` Rob Herring
2012-01-24 21:38 ` Rob Herring
2012-01-24 22:08 ` Grant Likely
2012-01-24 22:08 ` Grant Likely
2012-01-24 22:08 ` Grant Likely
2012-01-24 22:11 ` Rob Herring
2012-01-24 22:11 ` Rob Herring
2012-01-24 22:11 ` Rob Herring
2012-01-23 21:07 ` [RFCv2 04/14] irq_domain: convert microblaze from irq_host to irq_domain Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 05/14] irq_domain/powerpc: Use common irq_domain structure instead of irq_host Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 06/14] irq_domain/powerpc: eliminate irq_map; use irq_alloc_desc() instead Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 07/14] irq_domain/powerpc: Eliminate virq_is_host() Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 08/14] irq_domain: Move irq_domain code from powerpc to kernel/irq Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 09/14] irqdomain: remove NO_IRQ from irq domain code Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 10/14] irq_domain: Remove references to old irq_host names Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 11/14] irq_domain: Replace irq_alloc_host() with revmap-specific initializers Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 12/14] irq_domain: Add support for base irq and hwirq in legacy mappings Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 13/14] irq_domain: Remove 'new' irq_domain in favour of the ppc one Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-24 22:10 ` Rob Herring
2012-01-24 22:10 ` Rob Herring
2012-01-24 22:10 ` Rob Herring
2012-01-25 0:26 ` Grant Likely
2012-01-25 0:26 ` Grant Likely
2012-01-25 0:26 ` Grant Likely
2012-01-25 0:26 ` Grant Likely
2012-01-23 21:07 ` [RFCv2 14/14] irq_domain: Remove irq_domain_add_simple() Grant Likely
2012-01-23 21:07 ` Grant Likely
2012-01-23 21:53 ` [RFCv2 00/14] Rob Herring
2012-01-23 21:53 ` Rob Herring
2012-01-23 21:53 ` Rob Herring
2012-01-25 14:13 ` Cousson, Benoit
2012-01-25 14:13 ` Cousson, Benoit
2012-01-25 14:13 ` Cousson, Benoit
2012-01-25 18:51 ` Rob Herring
2012-01-25 18:51 ` Rob Herring
2012-01-25 18:51 ` Rob Herring
2012-01-26 21:33 ` Grant Likely
2012-01-26 21:33 ` Grant Likely
2012-01-27 22:08 ` Benjamin Herrenschmidt
2012-01-27 22:08 ` Benjamin Herrenschmidt
2012-01-27 22:08 ` Benjamin Herrenschmidt
2012-01-27 22:13 ` Grant Likely
2012-01-27 22:13 ` Grant Likely
2012-01-27 22:13 ` Grant Likely
2012-01-25 22:53 ` Mark Salter
2012-01-25 22:53 ` Mark Salter
2012-01-25 22:53 ` Mark Salter
2012-01-26 13:38 ` Grant Likely
2012-01-26 13:38 ` Grant Likely
[not found] ` <1327352870-14687-1-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2012-01-26 14:26 ` [PATCH] irq_domain/c6x: Convert c6x to use generic irq_domain support Mark Salter
2012-01-26 14:26 ` Mark Salter
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=4F1F02E5.3000605@xenotime.net \
--to=rdunlap@xenotime.net \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=miltonm@bga.com \
--cc=rob.herring@calxeda.com \
--cc=tglx@linutronix.de \
/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 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.