All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Jiang <liuj97@gmail.com>
To: Kevin Hao <haokexin@gmail.com>, Yinghai Lu <yinghai@kernel.org>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH 2/2] PCI: unset the resource if we can't get the correct CPU address
Date: Mon, 20 May 2013 23:27:52 +0800	[thread overview]
Message-ID: <519A40F8.5010306@gmail.com> (raw)
In-Reply-To: <20130519022445.GA25698@pek-khao-d1.corp.ad.wrs.com>

On Sun 19 May 2013 10:24:45 AM CST, Kevin Hao wrote:
> On Fri, May 17, 2013 at 10:51:20PM +0800, Liu Jiang wrote:
>> On Fri 17 May 2013 10:11:29 AM CST, Kevin Hao wrote:
>>> On Fri, May 17, 2013 at 12:18:07AM +0800, Liu Jiang wrote:
>>>> On Tue 14 May 2013 09:07:56 PM CST, Kevin Hao wrote:
>>>>> In the current kernel, we just set the CPU address to the bus address
>>>>> if we can't find the match region for one specific bus address. If BAR
>>>>> of one pci device is set to address which happens to be a legitimate
>>>>> CPU address by firmware, the kernel will think this resource is legal
>>>>> and will not try to reassign later. In cases the CPU address and bus
>>>>> address isn't equal, the device will not work. So we should check
>>>>> if we can translate the bus address to CPU address correctly. If not,
>>>>> we should unset this resource and wish the kernel will reassign it
>>>>> later.
>>>>>
>>>>> Since we will invoke pcibios_bus_to_resource unconditionally if we
>>>>> don't goto fail, move it out of if/else wrap.
>>>>>
>>>>> Signed-off-by: Kevin Hao <haokexin@gmail.com>
>>>>> ---
>>>>>   drivers/pci/probe.c | 9 ++++++---
>>>>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>>>> index 70f10fa..c96772f 100644
>>>>> --- a/drivers/pci/probe.c
>>>>> +++ b/drivers/pci/probe.c
>>>>> @@ -250,12 +250,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
>>>>>   			pci_write_config_dword(dev, pos + 4, 0);
>>>>>   			region.start = 0;
>>>>>   			region.end = sz64;
>>>>> -			pcibios_bus_to_resource(dev, res, &region);
>>>>>   			bar_disabled = true;
>>>>>   		} else {
>>>>>   			region.start = l64;
>>>>>   			region.end = l64 + sz64;
>>>>> -			pcibios_bus_to_resource(dev, res, &region);
>>>>>   		}
>>>>>   	} else {
>>>>>   		sz = pci_size(l, sz, mask);
>>>>> @@ -265,7 +263,12 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
>>>>>
>>>>>   		region.start = l;
>>>>>   		region.end = l + sz;
>>>>> -		pcibios_bus_to_resource(dev, res, &region);
>>>>> +	}
>>>>> +
>>>>> +	if (!pcibios_bus_to_resource(dev, res, &region)) {
>>>>> +		res->flags |= IORESOURCE_UNSET;
>>>>> +		res->end -= res->start;
>>>>> +		res->start = 0;
>>>>>   	}
>>>>>
>>>>>   	goto out;
>>>>
>>>> Hi Kevin,
>>>>       Will this break subtractive decode PCI bridges and devices?
>>>
>>> No. A subtractive decode occurs only when no other pci bridge or device
>>> claim the transactions. As you can see that when we are trying to translate
>>> a bus address to cpu address we search the address regions of pci host
>>> bridge instead of a pci bridge. The pci host bridge address regions should
>>> cover all the bus address we can use for the pci device or bridge under this
>>> pci controller. This definitely also include the bus address regions used by
>>> the expansion bus for subtractive decode. So if a pci device use a bus address
>>> that is unknown to this pci host bridge, there is definitely something wrong
>>> here. This is the case we are trying to fix.
>>>
>> Hi Kevin,
>>        I'm not sure about this assumption "the pci host bridge
>> address regions should cover
>> all the bus address we can use for the pci device or bridge under
>> this pci controller".
>> I have a fear that it may cause regressions to some legacy x86
>> platforms, such as an AMD
>> platform with PCI based IOAPICs, though I have no evidences for it.
>
> Does any x86 expert can confirm whether the assumption that "the pci host
> bridge address regions should cover all the bus address we can use for the
> pci device or bridge under this pci host bridge" is true or not on x86?
> It seems definitely wrong in logical. But things always happen out of
> expectation in reality. :-)
>
> Thanks,
> Kevin
>
>> Regards!
>> Gerry
>>> Thanks,
>>> Kevin
>>>
>>>> Regards!
>>>> Gerry
>>
>>

Hi Yinghai,
      Any comments here?

  reply	other threads:[~2013-05-20 15:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 13:07 [PATCH 0/2] fix the pci device malfunction if a wrong bus address is assigned by firmware Kevin Hao
2013-05-14 13:07 ` [PATCH 1/2] PCI: make pcibios_bus_to_resource return either success or failure Kevin Hao
2013-05-14 13:07 ` [PATCH 2/2] PCI: unset the resource if we can't get the correct CPU address Kevin Hao
2013-05-16 16:18   ` Liu Jiang
2013-05-17  2:11     ` Kevin Hao
2013-05-17 14:51       ` Liu Jiang
2013-05-19  2:24         ` Kevin Hao
2013-05-20 15:27           ` Liu Jiang [this message]
2013-05-23 20:22           ` Bjorn Helgaas
2013-05-24  2:54             ` Kevin Hao
2013-05-24 17:13               ` Bjorn Helgaas
2013-05-25 11:17                 ` Kevin Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519A40F8.5010306@gmail.com \
    --to=liuj97@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=haokexin@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.