diff mbox series

[v3,1/4] Allow system to allocate IRQ 0 to ATA devices

Message ID 20181106024239.7935-1-chaohong.guo@intel.com
State Not Applicable
Delegated to: David Miller
Headers show
Series [v3,1/4] Allow system to allocate IRQ 0 to ATA devices | expand

Commit Message

Guo, Chaohong Nov. 6, 2018, 2:42 a.m. UTC
Interrupt vector 0 can be used on some platform. In libata, the routine
ata_host_activate() considers irq=0 as invalid. As a result, when running
linux in non-root cell of Jailhouse,  if we allocate just one PCI ATA
device to the guest, the device will get an IRQ of value 0. Although IRQ0
is perfectly legal, ATA device will fail to start up.

    Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
---
 drivers/ata/libata-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergei Shtylyov Nov. 6, 2018, 3:33 p.m. UTC | #1
On 11/06/2018 05:42 AM, Chaohong guo wrote:

> Interrupt vector 0 can be used on some platform.

   It exists even on x86. However, it's never passed to request_irq() there IIRC,
just to setup_irq()...

> In libata, the routine
> ata_host_activate() considers irq=0 as invalid.

   As a matter of fact, Linus told everybody to consider IRQ0 invalid, hence this
code perhaps...

> As a result, when running
> linux in non-root cell of Jailhouse,  if we allocate just one PCI ATA
> device to the guest, the device will get an IRQ of value 0. Although IRQ0
> is perfectly legal, ATA device will fail to start up.

   I've just rechecked the PCI specs and they say that on x86 IRQ0 is valid,
so your software is OK.

>     Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
> ---
>  drivers/ata/libata-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

   Like Bart said, this patch alone would break some drivers...

[...]

MBR, Sergei
Guo, Chaohong Nov. 14, 2018, 4:50 a.m. UTC | #2
> -----Original Message-----
> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
> Sent: Tuesday, November 6, 2018 11:34 PM
> To: Guo, Chaohong <chaohong.guo@intel.com>; linux-ide@vger.kernel.org
> Cc: b.zolnierkie@samsung.com; axboe@kernel.dk; vireshk@kernel.org
> Subject: Re: [PATCH v3 1/4] Allow system to allocate IRQ 0 to ATA devices
> 
> On 11/06/2018 05:42 AM, Chaohong guo wrote:
> 
> > Interrupt vector 0 can be used on some platform.
> 
>    It exists even on x86. However, it's never passed to request_irq() there IIRC,
> just to setup_irq()...

[Guo, Chaohong] 
Yes.  normally on x86 platform,  the vector 0 won't be allocated to device. It is a system vector for handling the exception of dividing zero.
After my changing,  the AHCI driver can work with vector 0 in non-root jailhouse cell just because jailhouse will remap it via VT-D interrupt remapping.

How do you think about it ?  Do we fix it in somewhere else to prevent kernel in non-root cell from allocating vector less than 0x20 ?

-minskey

> 
> > In libata, the routine
> > ata_host_activate() considers irq=0 as invalid.
> 
>    As a matter of fact, Linus told everybody to consider IRQ0 invalid, hence
> this code perhaps...
> 
> > As a result, when running
> > linux in non-root cell of Jailhouse,  if we allocate just one PCI ATA
> > device to the guest, the device will get an IRQ of value 0. Although
> > IRQ0 is perfectly legal, ATA device will fail to start up.
> 
>    I've just rechecked the PCI specs and they say that on x86 IRQ0 is valid, so
> your software is OK.
> 
> >     Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
> > ---
> >  drivers/ata/libata-core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>    Like Bart said, this patch alone would break some drivers...
> 
> [...]
> 
> MBR, Sergei
Sergei Shtylyov Nov. 14, 2018, 8:06 a.m. UTC | #3
On 14.11.2018 7:50, Guo, Chaohong wrote:

>> -----Original Message-----
>> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
>> Sent: Tuesday, November 6, 2018 11:34 PM
>> To: Guo, Chaohong <chaohong.guo@intel.com>; linux-ide@vger.kernel.org
>> Cc: b.zolnierkie@samsung.com; axboe@kernel.dk; vireshk@kernel.org
>> Subject: Re: [PATCH v3 1/4] Allow system to allocate IRQ 0 to ATA devices
>>
>> On 11/06/2018 05:42 AM, Chaohong guo wrote:
>>
>>> Interrupt vector 0 can be used on some platform.
>>
>>     It exists even on x86. However, it's never passed to request_irq() there IIRC,
>> just to setup_irq()...
> 
> [Guo, Chaohong]
> Yes.  normally on x86 platform,  the vector 0 won't be allocated to device. It is a system vector for handling the exception of dividing zero.

    You are clearly mixing the interrupt vectors with IRQs. IRQ0 on x86 is used
by the i8254 (timer).

> After my changing,  the AHCI driver can work with vector 0 in non-root jailhouse cell just because jailhouse will remap it via VT-D interrupt remapping.
> 
> How do you think about it ?  Do we fix it in somewhere else to prevent kernel in non-root cell from allocating vector less than 0x20 ?
> 
> -minskey

MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a9dd4ea7467d..d83ba91c5051 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6628,7 +6628,7 @@  int ata_host_activate(struct ata_host *host, int irq,
 		return rc;
 
 	/* Special case for polling mode */
-	if (!irq) {
+	if (irq < 0) {
 		WARN_ON(irq_handler);
 		return ata_host_register(host, sht);
 	}