diff mbox

[15/19] mfd: Don't convert just one IRQ using irqdomain if a range is provided

Message ID 1347016499-29354-16-git-send-email-lee.jones@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Lee Jones Sept. 7, 2012, 11:14 a.m. UTC
MFD core code attempts to convert specified hardware (local) IRQ
numbers to virtual-IRQs, which something Linux can understand. This
works great when only one IRQ is specified. However, converting
entire ranges is currently unsupported. If this occurs we issue a
kernel warning to inform the user of this, but we continue to
convert the first specified IRQ anyway and replace the range. This
is not the correct behaviour. This patch ensures that if a range
is specified, it is left untouched.

CC: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/mfd-core.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Arnd Bergmann Sept. 7, 2012, 12:35 p.m. UTC | #1
On Friday 07 September 2012, Lee Jones wrote:
> MFD core code attempts to convert specified hardware (local) IRQ
> numbers to virtual-IRQs, which something Linux can understand. This
> works great when only one IRQ is specified. However, converting
> entire ranges is currently unsupported. If this occurs we issue a
> kernel warning to inform the user of this, but we continue to
> convert the first specified IRQ anyway and replace the range. This
> is not the correct behaviour. This patch ensures that if a range
> is specified, it is left untouched.
> 
> CC: Samuel Ortiz <sameo@linux.intel.com>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>

I don't see the advantage of the change. The warning already tells
us that the input to mfd_add_device was incorrect, so nothing the
function does can reliably fix it. Leaving the resource empty
is just as wrong as listing only the first interrupt.

	Arnd
Lee Jones Sept. 7, 2012, 12:46 p.m. UTC | #2
On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> On Friday 07 September 2012, Lee Jones wrote:
> > MFD core code attempts to convert specified hardware (local) IRQ
> > numbers to virtual-IRQs, which something Linux can understand. This
> > works great when only one IRQ is specified. However, converting
> > entire ranges is currently unsupported. If this occurs we issue a
> > kernel warning to inform the user of this, but we continue to
> > convert the first specified IRQ anyway and replace the range. This
> > is not the correct behaviour. This patch ensures that if a range
> > is specified, it is left untouched.
> > 
> > CC: Samuel Ortiz <sameo@linux.intel.com>
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> 
> I don't see the advantage of the change. The warning already tells
> us that the input to mfd_add_device was incorrect, so nothing the
> function does can reliably fix it. Leaving the resource empty
> is just as wrong as listing only the first interrupt.

My thinking was to leave them in a range, then have the target driver
convert each entry in the range manually. But what you're saying is
that no registration should be attempted using ranges at all? What if
the range was vast? Surely a resource array a few hundred lines long
isn't correct either? My immediate example would be "GPIO_INT6", which
has 31 lines. Do you want them all splitting out individually?
Arnd Bergmann Sept. 7, 2012, 1:37 p.m. UTC | #3
On Friday 07 September 2012, Lee Jones wrote:
> On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> > On Friday 07 September 2012, Lee Jones wrote:
> > > MFD core code attempts to convert specified hardware (local) IRQ
> > > numbers to virtual-IRQs, which something Linux can understand. This
> > > works great when only one IRQ is specified. However, converting
> > > entire ranges is currently unsupported. If this occurs we issue a
> > > kernel warning to inform the user of this, but we continue to
> > > convert the first specified IRQ anyway and replace the range. This
> > > is not the correct behaviour. This patch ensures that if a range
> > > is specified, it is left untouched.
> > > 
> > > CC: Samuel Ortiz <sameo@linux.intel.com>
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > 
> > I don't see the advantage of the change. The warning already tells
> > us that the input to mfd_add_device was incorrect, so nothing the
> > function does can reliably fix it. Leaving the resource empty
> > is just as wrong as listing only the first interrupt.
> 
> My thinking was to leave them in a range, then have the target driver
> convert each entry in the range manually. But what you're saying is
> that no registration should be attempted using ranges at all? What if
> the range was vast? Surely a resource array a few hundred lines long
> isn't correct either? My immediate example would be "GPIO_INT6", which
> has 31 lines. Do you want them all splitting out individually?

The examples I had seen before were all just ranges of two interrupts,
and in those cases it was clear that splitting them would be best.

In the exampled of the ab8500-gpio driver, it looks like the resource is
not actually being used, and the gpio driver implements its own irq_chip,
so maybe we can get away with not solving this problem for now.

	Arnd
Lee Jones Sept. 7, 2012, 1:43 p.m. UTC | #4
On Fri, Sep 07, 2012 at 01:37:26PM +0000, Arnd Bergmann wrote:
> On Friday 07 September 2012, Lee Jones wrote:
> > On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> > > On Friday 07 September 2012, Lee Jones wrote:
> > > > MFD core code attempts to convert specified hardware (local) IRQ
> > > > numbers to virtual-IRQs, which something Linux can understand. This
> > > > works great when only one IRQ is specified. However, converting
> > > > entire ranges is currently unsupported. If this occurs we issue a
> > > > kernel warning to inform the user of this, but we continue to
> > > > convert the first specified IRQ anyway and replace the range. This
> > > > is not the correct behaviour. This patch ensures that if a range
> > > > is specified, it is left untouched.
> > > > 
> > > > CC: Samuel Ortiz <sameo@linux.intel.com>
> > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > 
> > > I don't see the advantage of the change. The warning already tells
> > > us that the input to mfd_add_device was incorrect, so nothing the
> > > function does can reliably fix it. Leaving the resource empty
> > > is just as wrong as listing only the first interrupt.
> > 
> > My thinking was to leave them in a range, then have the target driver
> > convert each entry in the range manually. But what you're saying is
> > that no registration should be attempted using ranges at all? What if
> > the range was vast? Surely a resource array a few hundred lines long
> > isn't correct either? My immediate example would be "GPIO_INT6", which
> > has 31 lines. Do you want them all splitting out individually?
> 
> The examples I had seen before were all just ranges of two interrupts,
> and in those cases it was clear that splitting them would be best.
> 
> In the exampled of the ab8500-gpio driver, it looks like the resource is
> not actually being used, and the gpio driver implements its own irq_chip,
> so maybe we can get away with not solving this problem for now.

Understood. I'd still feel more comfortable if we didn't trash the
range. I think it would be best to show the warning, and leave the
range for its target driver to take care - hence the patch.

... but it's your call.
Arnd Bergmann Sept. 7, 2012, 1:57 p.m. UTC | #5
On Friday 07 September 2012, Lee Jones wrote:
> On Fri, Sep 07, 2012 at 01:37:26PM +0000, Arnd Bergmann wrote:
> > On Friday 07 September 2012, Lee Jones wrote:
> > > On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> >
> > The examples I had seen before were all just ranges of two interrupts,
> > and in those cases it was clear that splitting them would be best.
> > 
> > In the exampled of the ab8500-gpio driver, it looks like the resource is
> > not actually being used, and the gpio driver implements its own irq_chip,
> > so maybe we can get away with not solving this problem for now.
> 
> Understood. I'd still feel more comfortable if we didn't trash the
> range. I think it would be best to show the warning, and leave the
> range for its target driver to take care - hence the patch.
> 
> ... but it's your call.

I'm fine with whatever Samuel sees fit here.  My personal opinion is
that leaving the range alone for the child driver to do the conversion
would be too inconsistent and only lead to confusion with driver authors.

	Arnd
Samuel Ortiz Sept. 17, 2012, 1:45 p.m. UTC | #6
Hi Lee, Arnd,

On Fri, Sep 07, 2012 at 01:57:27PM +0000, Arnd Bergmann wrote:
> On Friday 07 September 2012, Lee Jones wrote:
> > On Fri, Sep 07, 2012 at 01:37:26PM +0000, Arnd Bergmann wrote:
> > > On Friday 07 September 2012, Lee Jones wrote:
> > > > On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> > >
> > > The examples I had seen before were all just ranges of two interrupts,
> > > and in those cases it was clear that splitting them would be best.
> > > 
> > > In the exampled of the ab8500-gpio driver, it looks like the resource is
> > > not actually being used, and the gpio driver implements its own irq_chip,
> > > so maybe we can get away with not solving this problem for now.
> > 
> > Understood. I'd still feel more comfortable if we didn't trash the
> > range. I think it would be best to show the warning, and leave the
> > range for its target driver to take care - hence the patch.
> > 
> > ... but it's your call.
> 
> I'm fine with whatever Samuel sees fit here.  My personal opinion is
> that leaving the range alone for the child driver to do the conversion
> would be too inconsistent and only lead to confusion with driver authors.
Although I agree modifying the range is not very nice from the MFD core, I
also think that the actual mapping should always be handled by MFD and not
depend on wether the range is a singleton or not. Moreover the semantics of
leaving the range untouched meaning that we haven't done the mappings is
obscure.
So I'm not taking this patch, sorry Lee.

Cheers,
Samuel.
Lee Jones Sept. 17, 2012, 2:11 p.m. UTC | #7
On Mon, Sep 17, 2012 at 03:45:50PM +0200, Samuel Ortiz wrote:
> Hi Lee, Arnd,
> 
> On Fri, Sep 07, 2012 at 01:57:27PM +0000, Arnd Bergmann wrote:
> > On Friday 07 September 2012, Lee Jones wrote:
> > > On Fri, Sep 07, 2012 at 01:37:26PM +0000, Arnd Bergmann wrote:
> > > > On Friday 07 September 2012, Lee Jones wrote:
> > > > > On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> > > >
> > > > The examples I had seen before were all just ranges of two interrupts,
> > > > and in those cases it was clear that splitting them would be best.
> > > > 
> > > > In the exampled of the ab8500-gpio driver, it looks like the resource is
> > > > not actually being used, and the gpio driver implements its own irq_chip,
> > > > so maybe we can get away with not solving this problem for now.
> > > 
> > > Understood. I'd still feel more comfortable if we didn't trash the
> > > range. I think it would be best to show the warning, and leave the
> > > range for its target driver to take care - hence the patch.
> > > 
> > > ... but it's your call.
> > 
> > I'm fine with whatever Samuel sees fit here.  My personal opinion is
> > that leaving the range alone for the child driver to do the conversion
> > would be too inconsistent and only lead to confusion with driver authors.
> Although I agree modifying the range is not very nice from the MFD core, I
> also think that the actual mapping should always be handled by MFD and not
> depend on wether the range is a singleton or not. Moreover the semantics of
> leaving the range untouched meaning that we haven't done the mappings is
> obscure.
> So I'm not taking this patch, sorry Lee.

No problem.

Would it be better if we _did_ support ranges, and map all of the
IRQs in the range instead?
Samuel Ortiz Sept. 21, 2012, 10:20 p.m. UTC | #8
Hi Lee,

On Mon, Sep 17, 2012 at 03:11:07PM +0100, Lee Jones wrote:
> On Mon, Sep 17, 2012 at 03:45:50PM +0200, Samuel Ortiz wrote:
> > Hi Lee, Arnd,
> > 
> > On Fri, Sep 07, 2012 at 01:57:27PM +0000, Arnd Bergmann wrote:
> > > On Friday 07 September 2012, Lee Jones wrote:
> > > > On Fri, Sep 07, 2012 at 01:37:26PM +0000, Arnd Bergmann wrote:
> > > > > On Friday 07 September 2012, Lee Jones wrote:
> > > > > > On Fri, Sep 07, 2012 at 12:35:41PM +0000, Arnd Bergmann wrote:
> > > > >
> > > > > The examples I had seen before were all just ranges of two interrupts,
> > > > > and in those cases it was clear that splitting them would be best.
> > > > > 
> > > > > In the exampled of the ab8500-gpio driver, it looks like the resource is
> > > > > not actually being used, and the gpio driver implements its own irq_chip,
> > > > > so maybe we can get away with not solving this problem for now.
> > > > 
> > > > Understood. I'd still feel more comfortable if we didn't trash the
> > > > range. I think it would be best to show the warning, and leave the
> > > > range for its target driver to take care - hence the patch.
> > > > 
> > > > ... but it's your call.
> > > 
> > > I'm fine with whatever Samuel sees fit here.  My personal opinion is
> > > that leaving the range alone for the child driver to do the conversion
> > > would be too inconsistent and only lead to confusion with driver authors.
> > Although I agree modifying the range is not very nice from the MFD core, I
> > also think that the actual mapping should always be handled by MFD and not
> > depend on wether the range is a singleton or not. Moreover the semantics of
> > leaving the range untouched meaning that we haven't done the mappings is
> > obscure.
> > So I'm not taking this patch, sorry Lee.
> 
> No problem.
> 
> Would it be better if we _did_ support ranges, and map all of the
> IRQs in the range instead?
I think that would be a reasonable solution, unless Arnd or Mark see a serious
problem with that.

Cheers,
Samuel.
diff mbox

Patch

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index f8b7771..f07cf69 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -126,10 +126,12 @@  static int mfd_add_device(struct device *parent, int id,
 		} else if (cell->resources[r].flags & IORESOURCE_IRQ) {
 			if (domain) {
 				/* Unable to create mappings for IRQ ranges. */
-				WARN_ON(cell->resources[r].start !=
-					cell->resources[r].end);
-				res[r].start = res[r].end = irq_create_mapping(
-					domain, cell->resources[r].start);
+				if (!WARN_ON(cell->resources[r].start !=
+						cell->resources[r].end))
+					res[r].start = res[r].end =
+						irq_create_mapping(
+							domain,
+							cell->resources[r].start);
 			} else {
 				res[r].start = irq_base +
 					cell->resources[r].start;