Re: [PATCH RFC v4 15/21] PCI: Allow the failed resources to be reassigned later

2019-03-26 Thread Bjorn Helgaas
On Mon, Mar 11, 2019 at 04:31:16PM +0300, Sergey Miroshnichenko wrote:
> Don't lose the size of the requested EP's BAR if it can't be fit
> in a current trial, so this can be retried.

s/EP/device/, since this applies equally to conventional PCI.

> But a failed bridge window must be dropped and recalculated in the
> next trial.
> 
> Signed-off-by: Sergey Miroshnichenko 
> ---
>  drivers/pci/setup-bus.c |  3 ++-
>  drivers/pci/setup-res.c | 12 
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index f9d605cd1725..c1559a4a8564 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -309,7 +309,8 @@ static void assign_requested_resources_sorted(struct 
> list_head *head,
>   0 /* don't care */,
>   0 /* don't care */);
>   }
> - reset_resource(res);
> + if (!pci_movable_bars_enabled())
> + reset_resource(res);
>   }
>   }
>  }
> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> index d8ca40a97693..732d18f60f1b 100644
> --- a/drivers/pci/setup-res.c
> +++ b/drivers/pci/setup-res.c
> @@ -298,6 +298,18 @@ static int _pci_assign_resource(struct pci_dev *dev, int 
> resno,
>  
>   bus = dev->bus;
>   while ((ret = __pci_assign_resource(bus, dev, resno, size, min_align))) 
> {
> + if (pci_movable_bars_enabled()) {
> + if (resno >= PCI_BRIDGE_RESOURCES &&
> + resno <= PCI_BRIDGE_RESOURCE_END) {
> + struct resource *res = dev->resource + resno;
> +
> + res->start = 0;
> + res->end = 0;
> + res->flags = 0;
> + }
> + break;
> + }
> +
>   if (!bus->parent || !bus->self->transparent)
>   break;
>   bus = bus->parent;
> -- 
> 2.20.1
> 


[PATCH RFC v4 15/21] PCI: Allow the failed resources to be reassigned later

2019-03-11 Thread Sergey Miroshnichenko
Don't lose the size of the requested EP's BAR if it can't be fit
in a current trial, so this can be retried.

But a failed bridge window must be dropped and recalculated in the
next trial.

Signed-off-by: Sergey Miroshnichenko 
---
 drivers/pci/setup-bus.c |  3 ++-
 drivers/pci/setup-res.c | 12 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index f9d605cd1725..c1559a4a8564 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -309,7 +309,8 @@ static void assign_requested_resources_sorted(struct 
list_head *head,
0 /* don't care */,
0 /* don't care */);
}
-   reset_resource(res);
+   if (!pci_movable_bars_enabled())
+   reset_resource(res);
}
}
 }
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index d8ca40a97693..732d18f60f1b 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -298,6 +298,18 @@ static int _pci_assign_resource(struct pci_dev *dev, int 
resno,
 
bus = dev->bus;
while ((ret = __pci_assign_resource(bus, dev, resno, size, min_align))) 
{
+   if (pci_movable_bars_enabled()) {
+   if (resno >= PCI_BRIDGE_RESOURCES &&
+   resno <= PCI_BRIDGE_RESOURCE_END) {
+   struct resource *res = dev->resource + resno;
+
+   res->start = 0;
+   res->end = 0;
+   res->flags = 0;
+   }
+   break;
+   }
+
if (!bus->parent || !bus->self->transparent)
break;
bus = bus->parent;
-- 
2.20.1