All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/8] irqdomain: Support identity mapped VIRQ allocation.
Date: Sat, 19 May 2012 20:21:40 +0000	[thread overview]
Message-ID: <20120519202140.7B0973E03B8@localhost> (raw)
In-Reply-To: <1337407908-7421-7-git-send-email-lethal@linux-sh.org>

On Sat, 19 May 2012 15:11:46 +0900, Paul Mundt <lethal@linux-sh.org> wrote:
> This adds a new irq_create_identity_mapping() routine to permit platforms
> to utilize 1:1 identity mapping between hardware and linux IRQs for
> domain population. The same semantics as irq_create_mapping() apply,
> though in this case we only support irqdesc allocation at a static
> location, rather than falling back on dynamic lookup.
> 
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
> ---
>  include/linux/irqdomain.h |    2 ++
>  kernel/irq/irqdomain.c    |   41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
> index 5abb533..e32d2e7 100644
> --- a/include/linux/irqdomain.h
> +++ b/include/linux/irqdomain.h
> @@ -149,6 +149,8 @@ extern unsigned int irq_create_mapping(struct irq_domain *host,
>  extern void irq_dispose_mapping(unsigned int virq);
>  extern unsigned int irq_find_mapping(struct irq_domain *host,
>  				     irq_hw_number_t hwirq);
> +extern unsigned int irq_create_identity_mapping(struct irq_domain *host,
> +						irq_hw_number_t hwirq);
>  extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
>  extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq,
>  				    irq_hw_number_t hwirq);
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 5f0ca52..ac44781 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -459,6 +459,47 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
>  }
>  EXPORT_SYMBOL_GPL(irq_create_mapping);
>  
> +/**
> + * irq_create_identity_mapping() - Allocate an identity mapped irq
> + * @domain: domain owning this hardware interrupt or NULL for default domain
> + * @hwirq: hardware irq number in that domain space
> + *
> + * This routine is used to allocate IRQs with a 1:1 identity mapping
> + * between the hardware and linux irq.
> + */
> +unsigned int irq_create_identity_mapping(struct irq_domain *domain,
> +					 irq_hw_number_t hwirq)

How about the following for an API (omitting error checking, and the
actual names are up for debate):

int irq_domain_associate_many(struct irq_domain *domain,
				unsigned int irq_base,
				irq_hw_number_t hwirq_base,
				int count)
{
	int i;
	for (i = 0; i < count; i++)
		irq_setup_virq(domain, irq_base + i, hwirq_base + i);
}
int irq_create_strict_mappings(struct irq_domain *domain,
				unsigned int irq_base,
				irq_hw_number_t hwirq_base,
				int count)
{
	/* Allows for non-identity, but still static mappings of a
	 * range of irq numbers */
	irq_alloc_descs(irq_base, irq_base, irq_domain_nid(domain->of_node));
	irq_domain_associate_many(domain, irq_base, hwirq, count);
	...
}

/* in header */
static int irq_create_identity_mapping(struct irq_domain *domain,
					irq_hw_number_t hwirq_base)
{
	irq_create_strict_mappings(domain, hwirq_base, hwirq_base, 1);
}

That would give the ability to either associated for pre-allocated
irq_descs, or strict map for allocating a specific range of irqs.


> +{
> +	int virq;
> +
> +	pr_debug("irq: irq_create_identity_mapping(0x%p, 0x%lx)\n",
> +		 domain, hwirq);
> +
> +	if (domain = NULL)
> +		domain = irq_default_domain;

This is a new API, and I'm not a fan of the irq_default_domain usage
so I'd like just drop the above too lines.  My opinion is that if your
calling into get a mapping, then the code really should know what
domain it is requesting from.  If a default domain really is needed,
then there it should be explicit for the caller to find the default
domain and then pass that in to this function.

> +	if (domain = NULL) {
> +		WARN_ON(1);
> +		return 0;
> +	}
> +
> +	virq = irq_alloc_desc_at(hwirq, irq_domain_nid(domain->of_node));
> +	if (virq < 0) {
> +		pr_debug("irq: -> virq allocation failed\n");
> +		return 0;
> +	}
> +
> +	if (irq_setup_virq(domain, virq, hwirq)) {
> +		if (domain->revmap_type != IRQ_DOMAIN_MAP_LEGACY)
> +			irq_free_desc(virq);
> +		return 0;
> +	}
> +
> +	pr_debug("irq: irq %lu identity mapped\n", hwirq);
> +
> +	return virq;
> +}
> +EXPORT_SYMBOL_GPL(irq_create_identity_mapping);
> +
>  unsigned int irq_create_of_mapping(struct device_node *controller,
>  				   const u32 *intspec, unsigned int intsize)
>  {
> -- 
> 1.7.9.rc0.28.g0e1cf
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH 6/8] irqdomain: Support identity mapped VIRQ allocation.
Date: Sat, 19 May 2012 14:21:40 -0600	[thread overview]
Message-ID: <20120519202140.7B0973E03B8@localhost> (raw)
In-Reply-To: <1337407908-7421-7-git-send-email-lethal@linux-sh.org>

On Sat, 19 May 2012 15:11:46 +0900, Paul Mundt <lethal@linux-sh.org> wrote:
> This adds a new irq_create_identity_mapping() routine to permit platforms
> to utilize 1:1 identity mapping between hardware and linux IRQs for
> domain population. The same semantics as irq_create_mapping() apply,
> though in this case we only support irqdesc allocation at a static
> location, rather than falling back on dynamic lookup.
> 
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
> ---
>  include/linux/irqdomain.h |    2 ++
>  kernel/irq/irqdomain.c    |   41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
> index 5abb533..e32d2e7 100644
> --- a/include/linux/irqdomain.h
> +++ b/include/linux/irqdomain.h
> @@ -149,6 +149,8 @@ extern unsigned int irq_create_mapping(struct irq_domain *host,
>  extern void irq_dispose_mapping(unsigned int virq);
>  extern unsigned int irq_find_mapping(struct irq_domain *host,
>  				     irq_hw_number_t hwirq);
> +extern unsigned int irq_create_identity_mapping(struct irq_domain *host,
> +						irq_hw_number_t hwirq);
>  extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
>  extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq,
>  				    irq_hw_number_t hwirq);
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 5f0ca52..ac44781 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -459,6 +459,47 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
>  }
>  EXPORT_SYMBOL_GPL(irq_create_mapping);
>  
> +/**
> + * irq_create_identity_mapping() - Allocate an identity mapped irq
> + * @domain: domain owning this hardware interrupt or NULL for default domain
> + * @hwirq: hardware irq number in that domain space
> + *
> + * This routine is used to allocate IRQs with a 1:1 identity mapping
> + * between the hardware and linux irq.
> + */
> +unsigned int irq_create_identity_mapping(struct irq_domain *domain,
> +					 irq_hw_number_t hwirq)

How about the following for an API (omitting error checking, and the
actual names are up for debate):

int irq_domain_associate_many(struct irq_domain *domain,
				unsigned int irq_base,
				irq_hw_number_t hwirq_base,
				int count)
{
	int i;
	for (i = 0; i < count; i++)
		irq_setup_virq(domain, irq_base + i, hwirq_base + i);
}
int irq_create_strict_mappings(struct irq_domain *domain,
				unsigned int irq_base,
				irq_hw_number_t hwirq_base,
				int count)
{
	/* Allows for non-identity, but still static mappings of a
	 * range of irq numbers */
	irq_alloc_descs(irq_base, irq_base, irq_domain_nid(domain->of_node));
	irq_domain_associate_many(domain, irq_base, hwirq, count);
	...
}

/* in header */
static int irq_create_identity_mapping(struct irq_domain *domain,
					irq_hw_number_t hwirq_base)
{
	irq_create_strict_mappings(domain, hwirq_base, hwirq_base, 1);
}

That would give the ability to either associated for pre-allocated
irq_descs, or strict map for allocating a specific range of irqs.


> +{
> +	int virq;
> +
> +	pr_debug("irq: irq_create_identity_mapping(0x%p, 0x%lx)\n",
> +		 domain, hwirq);
> +
> +	if (domain == NULL)
> +		domain = irq_default_domain;

This is a new API, and I'm not a fan of the irq_default_domain usage
so I'd like just drop the above too lines.  My opinion is that if your
calling into get a mapping, then the code really should know what
domain it is requesting from.  If a default domain really is needed,
then there it should be explicit for the caller to find the default
domain and then pass that in to this function.

> +	if (domain == NULL) {
> +		WARN_ON(1);
> +		return 0;
> +	}
> +
> +	virq = irq_alloc_desc_at(hwirq, irq_domain_nid(domain->of_node));
> +	if (virq < 0) {
> +		pr_debug("irq: -> virq allocation failed\n");
> +		return 0;
> +	}
> +
> +	if (irq_setup_virq(domain, virq, hwirq)) {
> +		if (domain->revmap_type != IRQ_DOMAIN_MAP_LEGACY)
> +			irq_free_desc(virq);
> +		return 0;
> +	}
> +
> +	pr_debug("irq: irq %lu identity mapped\n", hwirq);
> +
> +	return virq;
> +}
> +EXPORT_SYMBOL_GPL(irq_create_identity_mapping);
> +
>  unsigned int irq_create_of_mapping(struct device_node *controller,
>  				   const u32 *intspec, unsigned int intsize)
>  {
> -- 
> 1.7.9.rc0.28.g0e1cf
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

  reply	other threads:[~2012-05-19 20:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-19  6:11 [PATCH 0/8] irqdomain cleanups + identity mapping support Paul Mundt
2012-05-19  6:11 ` Paul Mundt
2012-05-19  6:11 ` [PATCH 1/8] irqdomain: Support removal of IRQ domains Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:34   ` Grant Likely
2012-05-19 18:34     ` Grant Likely
2012-05-19  6:11 ` [PATCH 2/8] irqdomain: Export remaining public API symbols Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:34   ` Grant Likely
2012-05-19 18:34     ` Grant Likely
2012-05-19  6:11 ` [PATCH 3/8] irqdomain: Make irq_domain_simple_map() static Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:35   ` Grant Likely
2012-05-19 18:35     ` Grant Likely
2012-05-19  6:11 ` [PATCH 4/8] irqdomain: Simple NUMA awareness Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:41   ` Grant Likely
2012-05-19 18:41     ` Grant Likely
2012-05-21  4:46     ` Paul Mundt
2012-05-21  4:46       ` Paul Mundt
2012-05-19  6:11 ` [PATCH 5/8] irqdomain: Kill off duplicate definitions Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:42   ` Grant Likely
2012-05-19 18:42     ` Grant Likely
2012-05-19  6:11 ` [PATCH 6/8] irqdomain: Support identity mapped VIRQ allocation Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 20:21   ` Grant Likely [this message]
2012-05-19 20:21     ` Grant Likely
2012-05-21  4:55     ` Paul Mundt
2012-05-21  4:55       ` Paul Mundt
2012-05-19  6:11 ` [PATCH 7/8] irqdomain: trivial pr_fmt conversion Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19  6:34   ` Joe Perches
2012-05-19  6:34     ` Joe Perches
2012-05-19  6:57     ` Paul Mundt
2012-05-19  6:57       ` Paul Mundt
2012-05-19 18:49   ` Grant Likely
2012-05-19 18:49     ` Grant Likely
2012-05-19  6:11 ` [PATCH 8/8] irqdomain: Support insertion of existing IRQ allocations Paul Mundt
2012-05-19  6:11   ` Paul Mundt
2012-05-19 18:32 ` [PATCH 0/8] irqdomain cleanups + identity mapping support Grant Likely
2012-05-19 18:32   ` Grant Likely

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=20120519202140.7B0973E03B8@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    /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.