* [PATCH] PCI: mvebu - The bridge secondary status register should be 0
@ 2013-10-15 20:16 Jason Gunthorpe
2013-10-17 13:12 ` Jason Cooper
2013-10-31 8:54 ` Thomas Petazzoni
0 siblings, 2 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2013-10-15 20:16 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: Jason Cooper, Ezequiel Garcia, linux-arm-kernel, linux-pci
There are no writable bits in the secondary status register, only
write 1 to clear bits. The driver never sets any of the write 1 to
clear bits so the status register should always be 0, just remove
the set from the write path.
Someday the write 1 to clear bits should be copied/cleared directly
from registers in the HW.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
drivers/pci/host/pci-mvebu.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 09fc586..3e5cdbd 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -495,7 +495,6 @@ static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
*/
bridge->iobase = (value & 0xff) | PCI_IO_RANGE_TYPE_32;
bridge->iolimit = ((value >> 8) & 0xff) | PCI_IO_RANGE_TYPE_32;
- bridge->secondary_status = value >> 16;
mvebu_pcie_handle_iobase_change(port);
break;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] PCI: mvebu - The bridge secondary status register should be 0
2013-10-15 20:16 Jason Gunthorpe
@ 2013-10-17 13:12 ` Jason Cooper
2013-10-31 8:54 ` Thomas Petazzoni
1 sibling, 0 replies; 9+ messages in thread
From: Jason Cooper @ 2013-10-17 13:12 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Thomas Petazzoni, linux-arm-kernel, linux-pci, Ezequiel Garcia
On Tue, Oct 15, 2013 at 02:16:30PM -0600, Jason Gunthorpe wrote:
> There are no writable bits in the secondary status register, only
> write 1 to clear bits. The driver never sets any of the write 1 to
> clear bits so the status register should always be 0, just remove
> the set from the write path.
>
> Someday the write 1 to clear bits should be copied/cleared directly
> from registers in the HW.
>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
> drivers/pci/host/pci-mvebu.c | 1 -
> 1 file changed, 1 deletion(-)
Applied to mvebu/drivers
thx,
Jason.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] PCI: mvebu - The bridge secondary status register should be 0
2013-10-15 20:16 Jason Gunthorpe
2013-10-17 13:12 ` Jason Cooper
@ 2013-10-31 8:54 ` Thomas Petazzoni
1 sibling, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2013-10-31 8:54 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Jason Cooper, Ezequiel Garcia, linux-arm-kernel, linux-pci
Dear Jason Gunthorpe,
On Tue, 15 Oct 2013 14:16:30 -0600, Jason Gunthorpe wrote:
> There are no writable bits in the secondary status register, only
> write 1 to clear bits. The driver never sets any of the write 1 to
> clear bits so the status register should always be 0, just remove
> the set from the write path.
>
> Someday the write 1 to clear bits should be copied/cleared directly
> from registers in the HW.
>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] PCI: mvebu - The bridge secondary status register should be 0
@ 2013-11-26 18:02 Jason Gunthorpe
2013-11-26 18:02 ` [PATCH] PCI: mvebu - Return a value for the INTERRUPT_LINE/PIN register Jason Gunthorpe
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2013-11-26 18:02 UTC (permalink / raw)
To: Bjorn Helgaas, Jason Cooper, Thomas Petazzoni
Cc: Ezequiel Garcia, linux-arm-kernel, linux-pci
There are no writable bits in the secondary status register, only
write 1 to clear bits. The driver never sets any of the write 1 to
clear bits so the status register should always be 0, just remove
the set from the write path.
Someday the write 1 to clear bits should be copied/cleared directly
from registers in the HW.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
drivers/pci/host/pci-mvebu.c | 1 -
1 file changed, 1 deletion(-)
Thomas: This was the last patch in my set that you haven't reviewed. Thanks
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index c269e43..6f5a20f 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -500,7 +500,6 @@ static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
*/
bridge->iobase = (value & 0xff) | PCI_IO_RANGE_TYPE_32;
bridge->iolimit = ((value >> 8) & 0xff) | PCI_IO_RANGE_TYPE_32;
- bridge->secondary_status = value >> 16;
mvebu_pcie_handle_iobase_change(port);
break;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] PCI: mvebu - Return a value for the INTERRUPT_LINE/PIN register
2013-11-26 18:02 [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Gunthorpe
@ 2013-11-26 18:02 ` Jason Gunthorpe
2013-11-26 18:02 ` [PATCH RESEND v3 1/2] PCI: mvebu - The bridge should obey the MEM and IO command bits Jason Gunthorpe
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2013-11-26 18:02 UTC (permalink / raw)
To: Bjorn Helgaas, Jason Cooper, Thomas Petazzoni
Cc: Ezequiel Garcia, linux-arm-kernel, linux-pci
The emulated bridge does not support interrupts so it should return the
value 0 for interrupt line, 0 for pin. This indicates that interrupts
are not supported.
Since max lat and min gnt are also in the same 32 bit word we return
0 for them, which means 'do not care'.
This corrects an error message from the kernel:
pci 0000:00:01.0: of_irq_parse_pci() failed with rc=135
Which is due to the default return of 0xFFFFFFFF indicating that
interrupts are supported.
The error message regression was caused by 16b84e5a505
'of/irq: Create of_irq_parse_and_map_pci() to consolidate arch code.'
So this patch should head toward 3.13
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
drivers/pci/host/pci-mvebu.c | 5 +++++
1 file changed, 5 insertions(+)
Thomas: This is needed for 3.13, can you Ack it so Bjorn can pick it up?
Thanks
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 6f5a20f..327ee2f 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -447,6 +447,11 @@ static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
*value = 0;
break;
+ case PCI_INTERRUPT_LINE:
+ /* LINE PIN MIN_GNT MAX_LAT */
+ *value = 0;
+ break;
+
default:
*value = 0xffffffff;
return PCIBIOS_BAD_REGISTER_NUMBER;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RESEND v3 1/2] PCI: mvebu - The bridge should obey the MEM and IO command bits
2013-11-26 18:02 [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Gunthorpe
2013-11-26 18:02 ` [PATCH] PCI: mvebu - Return a value for the INTERRUPT_LINE/PIN register Jason Gunthorpe
@ 2013-11-26 18:02 ` Jason Gunthorpe
2013-11-26 18:02 ` [PATCH RESEND v3 2/2] PCI: mvebu - Support a bridge with no IO port window Jason Gunthorpe
2013-11-26 18:23 ` [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Cooper
3 siblings, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2013-11-26 18:02 UTC (permalink / raw)
To: Bjorn Helgaas, Jason Cooper, Thomas Petazzoni
Cc: Ezequiel Garcia, linux-arm-kernel, linux-pci
When PCI_COMMAND_MEMORY/PCI_COMMAND_IO are cleared the bridge should not
allocate windows or even look at the window limit/base registers.
Otherwise it can attempt to setup bogus windows that the PCI core code
creates during discovery. The core will leave PCI_COMMAND_IO cleared if
it doesn't need an IO window.
Have mvebu_pcie_handle_*_change respect the bits, and call the change
function whenever the bits changes.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/pci/host/pci-mvebu.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
Bjorn, this is now ready to go for the next merge window.
Can you take it through your tree? Thanks
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 327ee2f..6fde82b 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -300,7 +300,8 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
/* Are the new iobase/iolimit values invalid? */
if (port->bridge.iolimit < port->bridge.iobase ||
- port->bridge.iolimitupper < port->bridge.iobaseupper) {
+ port->bridge.iolimitupper < port->bridge.iobaseupper ||
+ !(port->bridge.command & PCI_COMMAND_IO)) {
/* If a window was configured, remove it */
if (port->iowin_base) {
@@ -337,7 +338,8 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
{
/* Are the new membase/memlimit values invalid? */
- if (port->bridge.memlimit < port->bridge.membase) {
+ if (port->bridge.memlimit < port->bridge.membase ||
+ !(port->bridge.command & PCI_COMMAND_MEMORY)) {
/* If a window was configured, remove it */
if (port->memwin_base) {
@@ -490,8 +492,16 @@ static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
switch (where & ~3) {
case PCI_COMMAND:
+ {
+ u32 old = bridge->command;
+
bridge->command = value & 0xffff;
+ if ((old ^ bridge->command) & PCI_COMMAND_IO)
+ mvebu_pcie_handle_iobase_change(port);
+ if ((old ^ bridge->command) & PCI_COMMAND_MEMORY)
+ mvebu_pcie_handle_membase_change(port);
break;
+ }
case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_1:
bridge->bar[((where & ~3) - PCI_BASE_ADDRESS_0) / 4] = value;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RESEND v3 2/2] PCI: mvebu - Support a bridge with no IO port window
2013-11-26 18:02 [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Gunthorpe
2013-11-26 18:02 ` [PATCH] PCI: mvebu - Return a value for the INTERRUPT_LINE/PIN register Jason Gunthorpe
2013-11-26 18:02 ` [PATCH RESEND v3 1/2] PCI: mvebu - The bridge should obey the MEM and IO command bits Jason Gunthorpe
@ 2013-11-26 18:02 ` Jason Gunthorpe
2013-11-26 18:23 ` [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Cooper
3 siblings, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2013-11-26 18:02 UTC (permalink / raw)
To: Bjorn Helgaas, Jason Cooper, Thomas Petazzoni
Cc: Ezequiel Garcia, linux-arm-kernel, linux-pci
Make pcie-io-aperture and the IO port MBUS ID in ranges optional.
If not provided the bridge reports to Linux that IO space mapping is
not supported and refuses to configure an IO mbus window.
This allows both complete disable (do not specify pcie-io-aperture) and
per-port disable (do not specify a IO target ranges entry for the port)
Most PCIE devices these days do not require IO support to function,
so having an option to disable it in the driver is useful.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/pci/host/pci-mvebu.c | 63 ++++++++++++++++++++++++++++++--------------
1 file changed, 43 insertions(+), 20 deletions(-)
Bjorn, this is now ready to go for the next merge window.
Can you take it through your tree? Thanks
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 6fde82b..ef8691a 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -150,6 +150,11 @@ static inline u32 mvebu_readl(struct mvebu_pcie_port *port, u32 reg)
return readl(port->base + reg);
}
+static inline bool mvebu_has_ioport(struct mvebu_pcie_port *port)
+{
+ return port->io_target != -1 && port->io_attr != -1;
+}
+
static bool mvebu_pcie_link_up(struct mvebu_pcie_port *port)
{
return !(mvebu_readl(port, PCIE_STAT_OFF) & PCIE_STAT_LINK_DOWN);
@@ -314,6 +319,12 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
return;
}
+ if (!mvebu_has_ioport(port)) {
+ dev_WARN(&port->pcie->pdev->dev,
+ "Attempt to set IO when IO is disabled\n");
+ return;
+ }
+
/*
* We read the PCI-to-PCI bridge emulated registers, and
* calculate the base address and size of the address decoding
@@ -428,9 +439,12 @@ static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
break;
case PCI_IO_BASE:
- *value = (bridge->secondary_status << 16 |
- bridge->iolimit << 8 |
- bridge->iobase);
+ if (!mvebu_has_ioport(port))
+ *value = bridge->secondary_status << 16;
+ else
+ *value = (bridge->secondary_status << 16 |
+ bridge->iolimit << 8 |
+ bridge->iobase);
break;
case PCI_MEMORY_BASE:
@@ -495,6 +509,9 @@ static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
{
u32 old = bridge->command;
+ if (!mvebu_has_ioport(port))
+ value &= ~PCI_COMMAND_IO;
+
bridge->command = value & 0xffff;
if ((old ^ bridge->command) & PCI_COMMAND_IO)
mvebu_pcie_handle_iobase_change(port);
@@ -665,7 +682,9 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
struct mvebu_pcie *pcie = sys_to_pcie(sys);
int i;
- pci_add_resource_offset(&sys->resources, &pcie->realio, sys->io_offset);
+ if (resource_size(&pcie->realio) != 0)
+ pci_add_resource_offset(&sys->resources, &pcie->realio,
+ sys->io_offset);
pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset);
pci_add_resource(&sys->resources, &pcie->busn);
@@ -766,12 +785,17 @@ static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev,
#define DT_CPUADDR_TO_ATTR(cpuaddr) (((cpuaddr) >> 48) & 0xFF)
static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
- unsigned long type, int *tgt, int *attr)
+ unsigned long type,
+ unsigned int *tgt,
+ unsigned int *attr)
{
const int na = 3, ns = 2;
const __be32 *range;
int rlen, nranges, rangesz, pna, i;
+ *tgt = -1;
+ *attr = -1;
+
range = of_get_property(np, "ranges", &rlen);
if (!range)
return -EINVAL;
@@ -841,16 +865,15 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
}
mvebu_mbus_get_pcie_io_aperture(&pcie->io);
- if (resource_size(&pcie->io) == 0) {
- dev_err(&pdev->dev, "invalid I/O aperture size\n");
- return -EINVAL;
- }
- pcie->realio.flags = pcie->io.flags;
- pcie->realio.start = PCIBIOS_MIN_IO;
- pcie->realio.end = min_t(resource_size_t,
- IO_SPACE_LIMIT,
- resource_size(&pcie->io));
+ if (resource_size(&pcie->io) != 0) {
+ pcie->realio.flags = pcie->io.flags;
+ pcie->realio.start = PCIBIOS_MIN_IO;
+ pcie->realio.end = min_t(resource_size_t,
+ IO_SPACE_LIMIT,
+ resource_size(&pcie->io));
+ } else
+ pcie->realio = pcie->io;
/* Get the bus range */
ret = of_pci_parse_bus_range(np, &pcie->busn);
@@ -909,12 +932,12 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
continue;
}
- ret = mvebu_get_tgt_attr(np, port->devfn, IORESOURCE_IO,
- &port->io_target, &port->io_attr);
- if (ret < 0) {
- dev_err(&pdev->dev, "PCIe%d.%d: cannot get tgt/attr for io window\n",
- port->port, port->lane);
- continue;
+ if (resource_size(&pcie->io) != 0)
+ mvebu_get_tgt_attr(np, port->devfn, IORESOURCE_IO,
+ &port->io_target, &port->io_attr);
+ else {
+ port->io_target = -1;
+ port->io_attr = -1;
}
port->reset_gpio = of_get_named_gpio_flags(child,
--
1.8.1.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] PCI: mvebu - The bridge secondary status register should be 0
2013-11-26 18:02 [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Gunthorpe
` (2 preceding siblings ...)
2013-11-26 18:02 ` [PATCH RESEND v3 2/2] PCI: mvebu - Support a bridge with no IO port window Jason Gunthorpe
@ 2013-11-26 18:23 ` Jason Cooper
2013-11-26 18:38 ` Bjorn Helgaas
3 siblings, 1 reply; 9+ messages in thread
From: Jason Cooper @ 2013-11-26 18:23 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Bjorn Helgaas, Thomas Petazzoni, Ezequiel Garcia,
linux-arm-kernel, linux-pci
On Tue, Nov 26, 2013 at 11:02:52AM -0700, Jason Gunthorpe wrote:
> There are no writable bits in the secondary status register, only
> write 1 to clear bits. The driver never sets any of the write 1 to
> clear bits so the status register should always be 0, just remove
> the set from the write path.
>
> Someday the write 1 to clear bits should be copied/cleared directly
> from registers in the HW.
>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
> drivers/pci/host/pci-mvebu.c | 1 -
> 1 file changed, 1 deletion(-)
Whole series
Acked-by: Jason Cooper <jason@lakedaemon.net>
thx,
Jason.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] PCI: mvebu - The bridge secondary status register should be 0
2013-11-26 18:23 ` [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Cooper
@ 2013-11-26 18:38 ` Bjorn Helgaas
0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2013-11-26 18:38 UTC (permalink / raw)
To: Jason Cooper
Cc: Jason Gunthorpe, Thomas Petazzoni, Ezequiel Garcia,
linux-arm-kernel, linux-pci
On Tue, Nov 26, 2013 at 01:23:28PM -0500, Jason Cooper wrote:
> On Tue, Nov 26, 2013 at 11:02:52AM -0700, Jason Gunthorpe wrote:
> > There are no writable bits in the secondary status register, only
> > write 1 to clear bits. The driver never sets any of the write 1 to
> > clear bits so the status register should always be 0, just remove
> > the set from the write path.
> >
> > Someday the write 1 to clear bits should be copied/cleared directly
> > from registers in the HW.
> >
> > Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> > ---
> > drivers/pci/host/pci-mvebu.c | 1 -
> > 1 file changed, 1 deletion(-)
>
> Whole series
>
> Acked-by: Jason Cooper <jason@lakedaemon.net>
Thanks, I applied the Interrupt Line/Pin change to for-linus for v3.13, and
the others to pci/host-mvebu for v3.14.
Bjorn
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-11-26 18:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 18:02 [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Gunthorpe
2013-11-26 18:02 ` [PATCH] PCI: mvebu - Return a value for the INTERRUPT_LINE/PIN register Jason Gunthorpe
2013-11-26 18:02 ` [PATCH RESEND v3 1/2] PCI: mvebu - The bridge should obey the MEM and IO command bits Jason Gunthorpe
2013-11-26 18:02 ` [PATCH RESEND v3 2/2] PCI: mvebu - Support a bridge with no IO port window Jason Gunthorpe
2013-11-26 18:23 ` [PATCH] PCI: mvebu - The bridge secondary status register should be 0 Jason Cooper
2013-11-26 18:38 ` Bjorn Helgaas
-- strict thread matches above, loose matches on Subject: below --
2013-10-15 20:16 Jason Gunthorpe
2013-10-17 13:12 ` Jason Cooper
2013-10-31 8:54 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).