Skip to contentSkip to conversation

No need to call irq_domain_legacy_revmap() for twice

PATCH In review Mike Qiu 2 participants 8 messages Sep 24, 2012 – Jun 5, 2013

Subsystems (2)
lore
Share & tools
lore

Mike Qiu

author
#0 lore raw

PATCH 1/1 No need to call irq_domain_legacy_revmap() for twice

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +5 -2
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;
 
 	/* Allocate a virtual interrupt number */
 	hint = hwirq % nr_irqs;
Signature · 1 line
1.7.7.6
author
#1 lore raw

Any comments?
Thanks

Quoted 33 lines · 在 2012-09-24一的 17:37 +0800,Mike Qiu写道:

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +5 -2
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;
 
 	/* Allocate a virtual interrupt number */
 	hint = hwirq % nr_irqs;
#2 lore raw
In reply to Mike Qiu
Quoted 20 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 10 lines
kernel/irq/irqdomain.c +5 -2
 	}
 
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

g.

author
#3 lore raw
Quoted 23 lines · 在 2012-11-26一的 20:17 +0000,Grant Likely写道:
Quoted 22 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
Quoted 12 lines

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 8 lines
kernel/irq/irqdomain.c +5 -2
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

Yes, thanks

this judgment has been done in
/*Check if mapping already exists*/
virq = irq_find_mapping(domain, hwirq);

if the virq equals none zero, the func irq_create_mapping will return the virq value directly(already exists).

otherwise, that means virq equals zero, this has two meanings, one is haven't find the already exist mapping, the other one is in irq_find_mapping()

	case IRQ_DOMAIN_MAP_LEGACY:
		return irq_domain_legacy_revmap(domain, hwirq); 

this may return zero.

So, when we check if it is a IRQ_DOMAIN_MAP_LEGACY, we just return zero is OK. because if it is none zero, it will be return after check if mapping already exists, and never come here. also we never try to assign the virq for the legacy map.

I don't know if you have understand my explanation.

Thanks
Mike

Quoted 2 lines

g.

#4 lore raw
Quoted 50 lines · Mike
Quoted 23 lines · 在 2012-11-26一的 20:17 +0000,Grant Likely写道:
Quoted 22 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
Quoted 12 lines

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 8 lines
kernel/irq/irqdomain.c +5 -2
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

Yes, thanks

this judgment has been done in
/*Check if mapping already exists*/
virq = irq_find_mapping(domain, hwirq);

if the virq equals none zero, the func irq_create_mapping will return the virq value directly(already exists).

otherwise, that means virq equals zero, this has two meanings, one is haven't find the already exist mapping, the other one is in irq_find_mapping()

	case IRQ_DOMAIN_MAP_LEGACY:
		return irq_domain_legacy_revmap(domain, hwirq); 
Quoted 8 lines

this may return zero.

So, when we check if it is a IRQ_DOMAIN_MAP_LEGACY, we just return zero is OK. because if it is none zero, it will be return after check if mapping already exists, and never come here. also we never try to assign the virq for the legacy map.

I don't know if you have understand my explanation.

Yes, your explanation makes sense and you are correct. I'm not going to apply this for v3.8 (I've left it too late before the merge window), but I'll look again after the merge window closes.

g.

author
#5 lore raw
Quoted 58 lines · 在 2012-12-11二的 08:30 +0000,Grant Likely写道:
Quoted 57 lines · Mike
Quoted 23 lines · 在 2012-11-26一的 20:17 +0000,Grant Likely写道:
Quoted 22 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
Quoted 12 lines

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 8 lines
kernel/irq/irqdomain.c +5 -2
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

Yes, thanks

this judgment has been done in
/*Check if mapping already exists*/
virq = irq_find_mapping(domain, hwirq);

if the virq equals none zero, the func irq_create_mapping will return the virq value directly(already exists).

otherwise, that means virq equals zero, this has two meanings, one is haven't find the already exist mapping, the other one is in irq_find_mapping()

	case IRQ_DOMAIN_MAP_LEGACY:
		return irq_domain_legacy_revmap(domain, hwirq); 

this may return zero.

So, when we check if it is a IRQ_DOMAIN_MAP_LEGACY, we just return zero is OK. because if it is none zero, it will be return after check if mapping already exists, and never come here. also we never try to assign the virq for the legacy map.

Quoted 8 lines
Quoted 1 line

I don't know if you have understand my explanation.

Yes, your explanation makes sense and you are correct. I'm not going to apply this for v3.8 (I've left it too late before the merge window), but I'll look again after the merge window closes.

g.

OK, fair enough.
Thanks

author
#6 lore raw
In reply to Grant Likely
Quoted 58 lines · 在 2012-12-11二的 08:30 +0000,Grant Likely写道:
Quoted 57 lines · Mike
Quoted 23 lines · 在 2012-11-26一的 20:17 +0000,Grant Likely写道:
Quoted 22 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
Quoted 12 lines

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 8 lines
kernel/irq/irqdomain.c +5 -2
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

Yes, thanks

this judgment has been done in
/*Check if mapping already exists*/
virq = irq_find_mapping(domain, hwirq);

if the virq equals none zero, the func irq_create_mapping will return the virq value directly(already exists).

otherwise, that means virq equals zero, this has two meanings, one is haven't find the already exist mapping, the other one is in irq_find_mapping()

	case IRQ_DOMAIN_MAP_LEGACY:
		return irq_domain_legacy_revmap(domain, hwirq); 

this may return zero.

So, when we check if it is a IRQ_DOMAIN_MAP_LEGACY, we just return zero is OK. because if it is none zero, it will be return after check if mapping already exists, and never come here. also we never try to assign the virq for the legacy map.

Quoted 6 lines
Quoted 1 line

I don't know if you have understand my explanation.

Yes, your explanation makes sense and you are correct. I'm not going to apply this for v3.8 (I've left it too late before the merge window), but I'll look again after the merge window closes.

Hi Grant

I don't know if you forget this patch ...

I haven't see this patch in 3.9-rc7

just for a reminder

Thanks
Mike

Quoted 2 lines

g.

#7 lore raw
Quoted 65 lines · Mike
Quoted 58 lines · 在 2012-12-11二的 08:30 +0000,Grant Likely写道:
Quoted 57 lines · Mike
Quoted 23 lines · 在 2012-11-26一的 20:17 +0000,Grant Likely写道:
Quoted 22 lines · Mike Qiu

Function irq_create_mapping() calls irq_find_mapping(). The later function has checked if the indicated IRQ domain has hw IRQ mapped to virtual IRQ through legacy mode or not and return the value of the legacy irq number by call irq_domain_legacy_revmap(). We needn't to call irq_domain_legacy_revmap() to do same check in irq_create_mapping() again.

The patch removes the duplicate call.

---
 kernel/irq/irqdomain.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 49a7772..286d672 100644
@@ -547,9 +547,12 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
 		return virq;
 	}
 
Quoted 12 lines

kernel/irq/irqdomain.c unsigned int irq_create_mapping(struct irq_domain *domain, · line 555

Quoted 8 lines
kernel/irq/irqdomain.c +5 -2
-	/* Get a virtual interrupt number */
+	/*
+	 * For IRQ domain with type of IRQ_DOMAIN_MAP_LEGACY, we needn't
+	 * create the IRQ mapping for non-existing one, so just return 0.
+	 */
 	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return irq_domain_legacy_revmap(domain, hwirq);
+		return 0;

But it does need to return the virq assigned to the hwirq. That is why it has to call the revmap function.

Yes, thanks

this judgment has been done in
/*Check if mapping already exists*/
virq = irq_find_mapping(domain, hwirq);

if the virq equals none zero, the func irq_create_mapping will return the virq value directly(already exists).

otherwise, that means virq equals zero, this has two meanings, one is haven't find the already exist mapping, the other one is in irq_find_mapping()

	case IRQ_DOMAIN_MAP_LEGACY:
		return irq_domain_legacy_revmap(domain, hwirq); 

this may return zero.

So, when we check if it is a IRQ_DOMAIN_MAP_LEGACY, we just return zero is OK. because if it is none zero, it will be return after check if mapping already exists, and never come here. also we never try to assign the virq for the legacy map.

Quoted 6 lines
Quoted 1 line

I don't know if you have understand my explanation.

Yes, your explanation makes sense and you are correct. I'm not going to apply this for v3.8 (I've left it too late before the merge window), but I'll look again after the merge window closes.

Quoted 7 lines

Hi Grant

I don't know if you forget this patch ...

I haven't see this patch in 3.9-rc7

just for a reminder

After taking another look at it, I'm not going to apply this patch. It isn't actively dangerous for the revmap to get called twice, and I've got a patch pending that removes the legacy map entirely and replaces it with a pre-populated linear map.

g.