diff mbox

[v3,1/7] PCI: Ignore enforced alignment when kernel uses existing firmware setup

Message ID 1467283993-3185-2-git-send-email-xyjxie@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Yongji Xie June 30, 2016, 10:53 a.m. UTC
PCI resources allocator will use firmware setup and not try to
reassign resource when PCI_PROBE_ONLY or IORESOURCE_PCI_FIXED
is set.

The enforced alignment in pci_reassigndev_resource_alignment()
should be ignored in this case. Otherwise, some PCI devices'
resources would be released here and not re-allocated.

Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
 drivers/pci/pci.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Gavin Shan July 1, 2016, 12:28 a.m. UTC | #1
On Thu, Jun 30, 2016 at 06:53:07PM +0800, Yongji Xie wrote:
>PCI resources allocator will use firmware setup and not try to
>reassign resource when PCI_PROBE_ONLY or IORESOURCE_PCI_FIXED
>is set.
>
>The enforced alignment in pci_reassigndev_resource_alignment()
>should be ignored in this case. Otherwise, some PCI devices'
>resources would be released here and not re-allocated.
>
>Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
>---
> drivers/pci/pci.c |   12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
>diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>index c8b4dbd..be8f72c 100644
>--- a/drivers/pci/pci.c
>+++ b/drivers/pci/pci.c
>@@ -4760,6 +4760,13 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
>
> 	spin_lock(&resource_alignment_lock);
> 	p = resource_alignment_param;
>+	if (pci_has_flag(PCI_PROBE_ONLY)) {
>+		if (*p)
>+			printk_once(KERN_INFO "PCI: Ignore resource_alignment parameter: %s with PCI_PROBE_ONLY set\n",
>+						p);

We don't have to print @resource_alignment as it's ignored completely.
The content included in it doesn't mean anything:

			pr_info_once("PCI: resource_alignment ignored with PCI_PROBE_ONLY\n");

>+		spin_unlock(&resource_alignment_lock);
>+		return 0;
>+	}

A empty line is needed here.

> 	while (*p) {
> 		count = 0;
> 		if (sscanf(p, "%d%n", &align_order, &count) == 1 &&
>@@ -4837,6 +4844,11 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
> 		r = &dev->resource[i];
> 		if (!(r->flags & IORESOURCE_MEM))
> 			continue;
>+		if (r->flags & IORESOURCE_PCI_FIXED) {
>+			dev_info(&dev->dev, "No alignment for fixed BAR%d: %pR\n",
>+				i, r);

The message would be like below to match PCI code style. I'm thinking it probably
uses dev_dbg() instead dev_info(), but not sure for 100%.

			dev_info(&dev->dev, "BAR %d: fixed %pR, no alignment\n", i, r);

>+			continue;
>+		}

A empty line is needed here.

> 		size = resource_size(r);
> 		if (size < align) {
> 			size = align;

Thanks,
Gavin

--
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
Yongji Xie July 1, 2016, 4:49 a.m. UTC | #2
Hi Gavin,

On 2016/7/1 8:28, Gavin Shan wrote:

> On Thu, Jun 30, 2016 at 06:53:07PM +0800, Yongji Xie wrote:
>> PCI resources allocator will use firmware setup and not try to
>> reassign resource when PCI_PROBE_ONLY or IORESOURCE_PCI_FIXED
>> is set.
>>
>> The enforced alignment in pci_reassigndev_resource_alignment()
>> should be ignored in this case. Otherwise, some PCI devices'
>> resources would be released here and not re-allocated.
>>
>> Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
>> ---
>> drivers/pci/pci.c |   12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index c8b4dbd..be8f72c 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4760,6 +4760,13 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
>>
>> 	spin_lock(&resource_alignment_lock);
>> 	p = resource_alignment_param;
>> +	if (pci_has_flag(PCI_PROBE_ONLY)) {
>> +		if (*p)
>> +			printk_once(KERN_INFO "PCI: Ignore resource_alignment parameter: %s with PCI_PROBE_ONLY set\n",
>> +						p);
> We don't have to print @resource_alignment as it's ignored completely.
> The content included in it doesn't mean anything:
>
> 			pr_info_once("PCI: resource_alignment ignored with PCI_PROBE_ONLY\n");

OK. It looks simpler now.

>> +		spin_unlock(&resource_alignment_lock);
>> +		return 0;
>> +	}
> A empty line is needed here.
>
>> 	while (*p) {
>> 		count = 0;
>> 		if (sscanf(p, "%d%n", &align_order, &count) == 1 &&
>> @@ -4837,6 +4844,11 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>> 		r = &dev->resource[i];
>> 		if (!(r->flags & IORESOURCE_MEM))
>> 			continue;
>> +		if (r->flags & IORESOURCE_PCI_FIXED) {
>> +			dev_info(&dev->dev, "No alignment for fixed BAR%d: %pR\n",
>> +				i, r);
> The message would be like below to match PCI code style. I'm thinking it probably
> uses dev_dbg() instead dev_info(), but not sure for 100%.
>
> 			dev_info(&dev->dev, "BAR %d: fixed %pR, no alignment\n", i, r);

Maybe dev_info() is OK.:-)

>> +			continue;
>> +		}
> A empty line is needed here.
>
>> 		size = resource_size(r);
>> 		if (size < align) {
>> 			size = align;
> Thanks,
> Gavin
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

--
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/pci.c b/drivers/pci/pci.c
index c8b4dbd..be8f72c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4760,6 +4760,13 @@  static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
 
 	spin_lock(&resource_alignment_lock);
 	p = resource_alignment_param;
+	if (pci_has_flag(PCI_PROBE_ONLY)) {
+		if (*p)
+			printk_once(KERN_INFO "PCI: Ignore resource_alignment parameter: %s with PCI_PROBE_ONLY set\n",
+						p);
+		spin_unlock(&resource_alignment_lock);
+		return 0;
+	}
 	while (*p) {
 		count = 0;
 		if (sscanf(p, "%d%n", &align_order, &count) == 1 &&
@@ -4837,6 +4844,11 @@  void pci_reassigndev_resource_alignment(struct pci_dev *dev)
 		r = &dev->resource[i];
 		if (!(r->flags & IORESOURCE_MEM))
 			continue;
+		if (r->flags & IORESOURCE_PCI_FIXED) {
+			dev_info(&dev->dev, "No alignment for fixed BAR%d: %pR\n",
+				i, r);
+			continue;
+		}
 		size = resource_size(r);
 		if (size < align) {
 			size = align;