# Re: \[RFC 12/14\] irq\_domain: Add support for base irq and hwirq in legacy mappings

- From: Grant Likely \<hidden\>
- Date: 2012-01-13 00:54:20 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2012/01/3808875
- Thread: https://ratatoskr.run/linuxppc-dev/2012/01/3808431/t.md

```text
On Thu, Jan 12, 2012 at 5:37 PM, Rob Herring [ref] wrote:
> On 01/11/2012 02:22 PM, Grant Likely wrote:
>> Add support for a legacy mapping where irq =3D (hwirq - first_hwirq + fi=
rst_irq)
>> so that a controller driver can allocate a fixed range of irq_descs and =
use
>> a simple calculation to translate back and forth between linux and hw ir=
q
>> numbers. =A0This is needed to use an irq_domain with many of the ARM int=
errupt
>> controller drivers that manage their own irq_desc allocations. =A0Ultima=
tely
>> the goal is to migrate those drivers to use the linear revmap, but doing=
 it
>> this way allows each driver to be converted separately which makes the
>> migration path easier.
>>
>> This patch generalizes the IRQ_DOMAIN_MAP_LEGACY method to use
>> (first_irq-first_hwirq) as the offset between hwirq and linux irq number=
,
>> and adds checks to make sure that the hwirq number does not exceed range
>> assigned to the controller.
>>
>> Signed-off-by: Grant Likely <redacted>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> ---
>> =A0arch/powerpc/include/asm/irq.h =A0 | =A0 =A03 -
>> =A0arch/powerpc/sysdev/i8259.c =A0 =A0 =A0| =A0 =A02 +-
>> =A0arch/powerpc/sysdev/tsi108_pci.c | =A0 =A02 +-
>> =A0include/linux/irqdomain.h =A0 =A0 =A0 =A0| =A0 20 +++++++++-
>> =A0kernel/irq/irqdomain.c =A0 =A0 =A0 =A0 =A0 | =A0 78 +++++++++++++++++=
++++++++-------------
>> =A05 files changed, 73 insertions(+), 32 deletions(-)
>>
>
> snip...
>
>> @@ -454,8 +477,11 @@ unsigned int irq_find_mapping(struct irq_domain *do=
main,
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0;
>>
>> =A0 =A0 =A0 /* legacy -> bail early */
>> - =A0 =A0 if (domain->revmap_type =3D=3D IRQ_DOMAIN_MAP_LEGACY)
>> - =A0 =A0 =A0 =A0 =A0 =A0 return hwirq;
>> + =A0 =A0 if (domain->revmap_type =3D=3D IRQ_DOMAIN_MAP_LEGACY) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (hwirq > domain->revmap_data.legacy.size)
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0;
>> + =A0 =A0 =A0 =A0 =A0 =A0 return domain->revmap_data.legacy.first_irq + =
hwirq;
>
> This needs a "- domain->revmap_data.legacy.first_hwirq"

Good catch, thanks.
g.
```
