diff mbox

PCI/shpchp: fix a bus speed issue on hotplug

Message ID 1398954948-24219-1-git-send-email-marcel.a@redhat.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Marcel Apfelbaum May 1, 2014, 2:35 p.m. UTC
When a board is added, the shpchp driver checks if there
is a mismatch between the bridge's adapter and the bus speed.
If there is, it sets the subordinate speed (if there is no device on it).

However, it takes the reference of the board speed from the primary bus
and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
its speed is not updated and remains 0xff. As a result hotplug fails
with error: "Speed of bus ff and adapter 0 mismatch".

Fixed that by checking the speed against the subordinate bus.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael S. Tsirkin May 1, 2014, 3:43 p.m. UTC | #1
On Thu, May 01, 2014 at 05:35:48PM +0300, Marcel Apfelbaum wrote:
> When a board is added, the shpchp driver checks if there
> is a mismatch between the bridge's adapter and the bus speed.
> If there is, it sets the subordinate speed (if there is no device on it).
> 
> However, it takes the reference of the board speed from the primary bus
> and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> its speed is not updated and remains 0xff. As a result hotplug fails
> with error: "Speed of bus ff and adapter 0 mismatch".
> 
> Fixed that by checking the speed against the subordinate bus.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Looking at git history, I suspect this is a regression
introduced by
	commit 3749c51ac6c1560aa1cb1520066bed84c6f8152a
	Author: Matthew Wilcox <matthew@wil.cx>
	Date:   Sun Dec 13 08:11:32 2009 -0500
	    PCI: Make current and maximum bus speeds part of the PCI core
At least I remember this configuration worked for me early in 2009...

> ---
>  drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> index 5849927..6efc2ec 100644
> --- a/drivers/pci/hotplug/shpchp_ctrl.c
> +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
>  		return WRONG_BUS_FREQUENCY;
>  	}
>  
> -	bsp = ctrl->pci_dev->bus->cur_bus_speed;
> -	msp = ctrl->pci_dev->bus->max_bus_speed;
> +	bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> +	msp = ctrl->pci_dev->subordinate->max_bus_speed;
>  
>  	/* Check if there are other slots or devices on the same bus */
>  	if (!list_empty(&ctrl->pci_dev->subordinate->devices))
> -- 
> 1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas May 1, 2014, 6:02 p.m. UTC | #2
On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
> When a board is added, the shpchp driver checks if there
> is a mismatch between the bridge's adapter and the bus speed.
> If there is, it sets the subordinate speed (if there is no device on it).
>
> However, it takes the reference of the board speed from the primary bus
> and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> its speed is not updated and remains 0xff. As a result hotplug fails
> with error: "Speed of bus ff and adapter 0 mismatch".

It'd be cool to have a bugzilla for this with lspci and dmesg output.
I'll also have to check the other hotplug drivers for similar issues,
unless you've already done that.

> Fixed that by checking the speed against the subordinate bus.
>
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> index 5849927..6efc2ec 100644
> --- a/drivers/pci/hotplug/shpchp_ctrl.c
> +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
>                 return WRONG_BUS_FREQUENCY;
>         }
>
> -       bsp = ctrl->pci_dev->bus->cur_bus_speed;
> -       msp = ctrl->pci_dev->bus->max_bus_speed;
> +       bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> +       msp = ctrl->pci_dev->subordinate->max_bus_speed;
>
>         /* Check if there are other slots or devices on the same bus */
>         if (!list_empty(&ctrl->pci_dev->subordinate->devices))
> --
> 1.8.3.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Apfelbaum May 1, 2014, 6:13 p.m. UTC | #3
On Thu, 2014-05-01 at 12:02 -0600, Bjorn Helgaas wrote:
> On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
> > When a board is added, the shpchp driver checks if there
> > is a mismatch between the bridge's adapter and the bus speed.
> > If there is, it sets the subordinate speed (if there is no device on it).
> >
> > However, it takes the reference of the board speed from the primary bus
> > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> > its speed is not updated and remains 0xff. As a result hotplug fails
> > with error: "Speed of bus ff and adapter 0 mismatch".
> 
> It'd be cool to have a bugzilla for this with lspci and dmesg output.
> I'll also have to check the other hotplug drivers for similar issues,
> unless you've already done that.
I'll open a BZ with the details, sure.

I didn't check the other hotplug drivers, but I do plan
to look into PCIe driver as part of QEMU's PCIe hotplug feature.

Thanks,
Marcel

> 
> > Fixed that by checking the speed against the subordinate bus.
> >
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> > index 5849927..6efc2ec 100644
> > --- a/drivers/pci/hotplug/shpchp_ctrl.c
> > +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> > @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
> >                 return WRONG_BUS_FREQUENCY;
> >         }
> >
> > -       bsp = ctrl->pci_dev->bus->cur_bus_speed;
> > -       msp = ctrl->pci_dev->bus->max_bus_speed;
> > +       bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> > +       msp = ctrl->pci_dev->subordinate->max_bus_speed;
> >
> >         /* Check if there are other slots or devices on the same bus */
> >         if (!list_empty(&ctrl->pci_dev->subordinate->devices))
> > --
> > 1.8.3.1
> >



--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Apfelbaum May 1, 2014, 6:57 p.m. UTC | #4
On Thu, 2014-05-01 at 21:13 +0300, Marcel Apfelbaum wrote:
> On Thu, 2014-05-01 at 12:02 -0600, Bjorn Helgaas wrote:
> > On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
> > > When a board is added, the shpchp driver checks if there
> > > is a mismatch between the bridge's adapter and the bus speed.
> > > If there is, it sets the subordinate speed (if there is no device on it).
> > >
> > > However, it takes the reference of the board speed from the primary bus
> > > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> > > its speed is not updated and remains 0xff. As a result hotplug fails
> > > with error: "Speed of bus ff and adapter 0 mismatch".
> > 
> > It'd be cool to have a bugzilla for this with lspci and dmesg output.
> > I'll also have to check the other hotplug drivers for similar issues,
> > unless you've already done that.
> I'll open a BZ with the details, sure.
Done: https://bugzilla.kernel.org/show_bug.cgi?id=75251
If you need further details, please let me know.

Thanks,
Marcel


> 
> I didn't check the other hotplug drivers, but I do plan
> to look into PCIe driver as part of QEMU's PCIe hotplug feature.
> 
> Thanks,
> Marcel
> 
> > 
> > > Fixed that by checking the speed against the subordinate bus.
> > >
> > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > > Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > > ---
> > >  drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> > > index 5849927..6efc2ec 100644
> > > --- a/drivers/pci/hotplug/shpchp_ctrl.c
> > > +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> > > @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
> > >                 return WRONG_BUS_FREQUENCY;
> > >         }
> > >
> > > -       bsp = ctrl->pci_dev->bus->cur_bus_speed;
> > > -       msp = ctrl->pci_dev->bus->max_bus_speed;
> > > +       bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> > > +       msp = ctrl->pci_dev->subordinate->max_bus_speed;
> > >
> > >         /* Check if there are other slots or devices on the same bus */
> > >         if (!list_empty(&ctrl->pci_dev->subordinate->devices))
> > > --
> > > 1.8.3.1
> > >
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas May 1, 2014, 8 p.m. UTC | #5
On Thu, May 1, 2014 at 12:57 PM, Marcel Apfelbaum
<marcel.apfelbaum@gmail.com> wrote:
> On Thu, 2014-05-01 at 21:13 +0300, Marcel Apfelbaum wrote:
>> On Thu, 2014-05-01 at 12:02 -0600, Bjorn Helgaas wrote:
>> > On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
>> > > When a board is added, the shpchp driver checks if there
>> > > is a mismatch between the bridge's adapter and the bus speed.
>> > > If there is, it sets the subordinate speed (if there is no device on it).
>> > >
>> > > However, it takes the reference of the board speed from the primary bus
>> > > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
>> > > its speed is not updated and remains 0xff. As a result hotplug fails
>> > > with error: "Speed of bus ff and adapter 0 mismatch".
>> >
>> > It'd be cool to have a bugzilla for this with lspci and dmesg output.
>> > I'll also have to check the other hotplug drivers for similar issues,
>> > unless you've already done that.
>> I'll open a BZ with the details, sure.
> Done: https://bugzilla.kernel.org/show_bug.cgi?id=75251
> If you need further details, please let me know.

Thanks.  Would you mind attaching the "lspci -vv" output?  That should
show more details, including the information used to compute the bus
speed.

Also, you checked the "regression" box.  Can you confirm that and
identify a known-working kernel?  If we know which kernels are broken,
we can potentially mark the fix to be backported to them.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Apfelbaum May 1, 2014, 8:36 p.m. UTC | #6
On Thu, 2014-05-01 at 14:00 -0600, Bjorn Helgaas wrote:
> On Thu, May 1, 2014 at 12:57 PM, Marcel Apfelbaum
> <marcel.apfelbaum@gmail.com> wrote:
> > On Thu, 2014-05-01 at 21:13 +0300, Marcel Apfelbaum wrote:
> >> On Thu, 2014-05-01 at 12:02 -0600, Bjorn Helgaas wrote:
> >> > On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
> >> > > When a board is added, the shpchp driver checks if there
> >> > > is a mismatch between the bridge's adapter and the bus speed.
> >> > > If there is, it sets the subordinate speed (if there is no device on it).
> >> > >
> >> > > However, it takes the reference of the board speed from the primary bus
> >> > > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> >> > > its speed is not updated and remains 0xff. As a result hotplug fails
> >> > > with error: "Speed of bus ff and adapter 0 mismatch".
> >> >
> >> > It'd be cool to have a bugzilla for this with lspci and dmesg output.
> >> > I'll also have to check the other hotplug drivers for similar issues,
> >> > unless you've already done that.
> >> I'll open a BZ with the details, sure.
> > Done: https://bugzilla.kernel.org/show_bug.cgi?id=75251
> > If you need further details, please let me know.
> 
> Thanks.  Would you mind attaching the "lspci -vv" output?  That should
> show more details, including the information used to compute the bus
> speed.
Sure, done.

> 
> Also, you checked the "regression" box.  Can you confirm that and
> identify a known-working kernel?  If we know which kernels are broken,
> we can potentially mark the fix to be backported to them.
I checked the regression box based on Michael's comment that in early 2009 it did work.
He pointed out a commit he thinks that caused this regression.

I think it can be backported to all the relevant stable versions since
the commit that introduced the code mentioned in the patch.

Thanks,
Marcel

> 
> Bjorn



--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Apfelbaum May 4, 2014, 10:40 a.m. UTC | #7
On Thu, 2014-05-01 at 14:00 -0600, Bjorn Helgaas wrote:
> On Thu, May 1, 2014 at 12:57 PM, Marcel Apfelbaum
> <marcel.apfelbaum@gmail.com> wrote:
> > On Thu, 2014-05-01 at 21:13 +0300, Marcel Apfelbaum wrote:
> >> On Thu, 2014-05-01 at 12:02 -0600, Bjorn Helgaas wrote:
> >> > On Thu, May 1, 2014 at 8:35 AM, Marcel Apfelbaum <marcel.a@redhat.com> wrote:
> >> > > When a board is added, the shpchp driver checks if there
> >> > > is a mismatch between the bridge's adapter and the bus speed.
> >> > > If there is, it sets the subordinate speed (if there is no device on it).
> >> > >
> >> > > However, it takes the reference of the board speed from the primary bus
> >> > > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> >> > > its speed is not updated and remains 0xff. As a result hotplug fails
> >> > > with error: "Speed of bus ff and adapter 0 mismatch".
> >> >
> >> > It'd be cool to have a bugzilla for this with lspci and dmesg output.
> >> > I'll also have to check the other hotplug drivers for similar issues,
> >> > unless you've already done that.
> >> I'll open a BZ with the details, sure.
> > Done: https://bugzilla.kernel.org/show_bug.cgi?id=75251
> > If you need further details, please let me know.
> 
> Thanks.  Would you mind attaching the "lspci -vv" output?  That should
> show more details, including the information used to compute the bus
> speed.
> 
> Also, you checked the "regression" box.  Can you confirm that and
> identify a known-working kernel?  If we know which kernels are broken,
> we can potentially mark the fix to be backported to them.
I checked 2.6.24-26-generic that comes with Ubuntu 8.04 and it works OK.
So we have a working version.

I hope it helps,
Marcel

> 
> Bjorn



--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ronen Hod May 4, 2014, 1:48 p.m. UTC | #8
On 05/01/2014 05:35 PM, Marcel Apfelbaum wrote:
> When a board is added, the shpchp driver checks if there
> is a mismatch between the bridge's adapter and the bus speed.
> If there is, it sets the subordinate speed (if there is no device on it).

Since the speed is irrelevant when running in a VM, I suggest that
you either ignore it altogether, or "normalize" the speed of all the
devices/bridges/buses in QEMU in order to avoid any conflicts
in the first place.

Thanks, Ronen.

>
> However, it takes the reference of the board speed from the primary bus
> and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> its speed is not updated and remains 0xff. As a result hotplug fails
> with error: "Speed of bus ff and adapter 0 mismatch".
>
> Fixed that by checking the speed against the subordinate bus.
>
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> index 5849927..6efc2ec 100644
> --- a/drivers/pci/hotplug/shpchp_ctrl.c
> +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
>   		return WRONG_BUS_FREQUENCY;
>   	}
>   
> -	bsp = ctrl->pci_dev->bus->cur_bus_speed;
> -	msp = ctrl->pci_dev->bus->max_bus_speed;
> +	bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> +	msp = ctrl->pci_dev->subordinate->max_bus_speed;
>   
>   	/* Check if there are other slots or devices on the same bus */
>   	if (!list_empty(&ctrl->pci_dev->subordinate->devices))

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Apfelbaum May 4, 2014, 2:07 p.m. UTC | #9
On Sun, 2014-05-04 at 16:48 +0300, Ronen Hod wrote:
> On 05/01/2014 05:35 PM, Marcel Apfelbaum wrote:
> > When a board is added, the shpchp driver checks if there
> > is a mismatch between the bridge's adapter and the bus speed.
> > If there is, it sets the subordinate speed (if there is no device on it).
> 
> Since the speed is irrelevant when running in a VM, I suggest that
> you either ignore it altogether, or "normalize" the speed of all the
> devices/bridges/buses in QEMU in order to avoid any conflicts
> in the first place.
Before this patch, this would not help since the primary bus speed
is not even set by the kernel.

After this patch, normalizing the QEMU device/bus/... speed may help
avoiding future conflicts, but we should discuss it in qemu mailing list :).

Ignoring emulated/para-virt device's speed when running in a VM it is\
a good question, but I don't know if such a distinction would be feasible.

Any thoughts would be appreciated,
Thanks,
Marcel

> 
> Thanks, Ronen.
> 
> >
> > However, it takes the reference of the board speed from the primary bus
> > and not from the subordinate. If the primary bus is PCI and not PCIX/PCIe,
> > its speed is not updated and remains 0xff. As a result hotplug fails
> > with error: "Speed of bus ff and adapter 0 mismatch".
> >
> > Fixed that by checking the speed against the subordinate bus.
> >
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >   drivers/pci/hotplug/shpchp_ctrl.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> > index 5849927..6efc2ec 100644
> > --- a/drivers/pci/hotplug/shpchp_ctrl.c
> > +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> > @@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
> >   		return WRONG_BUS_FREQUENCY;
> >   	}
> >   
> > -	bsp = ctrl->pci_dev->bus->cur_bus_speed;
> > -	msp = ctrl->pci_dev->bus->max_bus_speed;
> > +	bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
> > +	msp = ctrl->pci_dev->subordinate->max_bus_speed;
> >   
> >   	/* Check if there are other slots or devices on the same bus */
> >   	if (!list_empty(&ctrl->pci_dev->subordinate->devices))
> 



--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 5849927..6efc2ec 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -282,8 +282,8 @@  static int board_added(struct slot *p_slot)
 		return WRONG_BUS_FREQUENCY;
 	}
 
-	bsp = ctrl->pci_dev->bus->cur_bus_speed;
-	msp = ctrl->pci_dev->bus->max_bus_speed;
+	bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
+	msp = ctrl->pci_dev->subordinate->max_bus_speed;
 
 	/* Check if there are other slots or devices on the same bus */
 	if (!list_empty(&ctrl->pci_dev->subordinate->devices))