linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Huacai Chen <chenhuacai@gmail.com>, Bjorn Helgaas <helgaas@kernel.org>
Cc: Huacai Chen <chenhuacai@loongson.cn>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci <linux-pci@vger.kernel.org>,
	huangshuai@loongson.cn
Subject: Re: [PATCH 3/5] PCI: Improve the mrrs quirk for LS7A
Date: Sat, 15 May 2021 14:22:52 +0800	[thread overview]
Message-ID: <41a47822-8aed-917a-ec6a-e37be5ff2f35@flygoat.com> (raw)
In-Reply-To: <CAAhV-H4cH40d++SQ+sNXtjh_arC1ASPfRCdLsGtBoTnTWwB6aQ@mail.gmail.com>



在 2021/5/15 11:49, Huacai Chen 写道:
> Hi, Krzysztof and Bjorn
>
> I will improve my spelling, and others see below.
>
> On Fri, May 14, 2021 at 11:40 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>> On Fri, May 14, 2021 at 04:00:23PM +0800, Huacai Chen wrote:
>>> In new revision of LS7A, some pcie ports support larger value than 256,
>>> but their mrrs values are not dectectable. And moreover, the current
>>> loongson_mrrs_quirk() cannot avoid devices increasing its mrrs after
>>> pci_enable_device(). So the only possible way is configure mrrs of all
>>> devices in BIOS, and add a pci dev flag (PCI_DEV_FLAGS_NO_INCREASE_MRRS)
>>> to stop the increasing mrrs operations.
>> s/mrrs/MRRS/
>> s/dectectable/detectable/
>>
>> This doesn't make sense to me.  MRRS "sets the maximum Read Request
>> size for the Function as a Requester" (PCIe r5.0, sec 7.5.3.4).
>>
>> The MRRS in the Device Control register is a 3-bit RW field (or a RO
>> field with value 000b).  If it's RW, software is allowed to write any
>> 3-bit value to it.  There is no "maximum allowed value" for software
>> to detect.
>>
>> The value software writes is only a *limit* on the Read Request size.
>> The hardware is never obligated to generate Read Requests of that max
>> size.  If software writes 101b (4096 byte max size), and the hardware
>> only supports generating 128-byte Read Requests, there's no issue.
>> It's perfectly fine for the hardware to generate 128-byte requests.
>>
>> Apparently something bad happens if software writes something "too
>> large" to MRRS?  What actually happens?
>>
>> If the problem is that the device generates a large Read Request and
>> in response, it receives a data TLP that is larger than it can handle,
>> that sounds like an MPS issue, not an MRRS issue.
>>
>> Based on the existing loongson_mrrs_quirk(), it looks like this is a
>> long-standing issue.  I'm sorry I missed this when reviewing the
>> driver in the first place.  This all needs a much better explanation
>> of what the real problem is.  The "h/w limitation of 256 bytes maximum
>> read request size" comment just doesn't make sense from the spec point
>> of view.
>>
>> I do know that Linux uses MRRS and MPS in ... highly unusual ways, and
>> maybe we're tripping over that somehow.  If so, we need to figure out
>> exactly how so we can make Linux's use of MPS and MRRS better overall.
> I have discussed with Shuai Huang (the main designer of LS7A), he said
> that some devices (such as Realtek 8169) usually write a large value
> to MRRS in its driver. And that usually larger than LS7A bridge can
> handle, the quirk in this patch is avoid device driver to increase
> MRRS (and BIOS initialize a reasonable value at power on stage).

Based on my experiments on LS2K which have a similar issue, I guess the
problem is Loongson's AXI bus failed to accept reading burst larger then
certain size.

The larger MRRS is legal for PCIe controller but not for upstream bus.
So when you write the value to MRRS register the controller will still
generate oversized TLP and then send illegal response to AXI bus. Thus
we need to limit MRRS in software to avoid such situation.

I'm not a loongson employee so it might be wrong.

Thanks.

- Jiaxun

>
> Huacai
>

  reply	other threads:[~2021-05-15  6:23 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  8:00 [PATCH 0/5] PCI: Loongson-related pci quirks Huacai Chen
2021-05-14  8:00 ` [PATCH 1/5] PCI/portdrv: Don't disable pci device during shutdown Huacai Chen
2021-05-14 14:20   ` Krzysztof Wilczyński
2021-05-14 16:09   ` Bjorn Helgaas
2021-05-15  3:38     ` Huacai Chen
2021-05-14  8:00 ` [PATCH 2/5] PCI: Move loongson pci quirks to quirks.c Huacai Chen
2021-05-14  8:00 ` [PATCH 3/5] PCI: Improve the mrrs quirk for LS7A Huacai Chen
2021-05-14 14:03   ` Krzysztof Wilczyński
2021-05-14 15:39   ` Bjorn Helgaas
2021-05-15  3:49     ` Huacai Chen
2021-05-15  6:22       ` Jiaxun Yang [this message]
2021-05-14  8:00 ` [PATCH 4/5] PCI: Add quirk for multifunction devices of LS7A Huacai Chen
2021-05-14 13:22   ` Krzysztof Wilczyński
2021-05-14 14:52   ` Jiaxun Yang
2021-05-15  3:52     ` Huacai Chen
2021-05-18 13:59       ` Bjorn Helgaas
2021-05-19  2:26         ` Huacai Chen
2021-05-19  3:05           ` Jiaxun Yang
2021-05-14 15:51   ` Bjorn Helgaas
2021-05-15  3:56     ` Huacai Chen
2021-05-14  8:00 ` [PATCH 5/5] PCI: Support ASpeed VGA cards behind a misbehaving bridge Huacai Chen
2021-05-14 13:56   ` Krzysztof Wilczyński
2021-05-14 15:10   ` Bjorn Helgaas
2021-05-15  9:09     ` Huacai Chen
2021-05-17 12:53       ` Huacai Chen
2021-05-17 18:28         ` Bjorn Helgaas
2021-05-18  2:31           ` 隋景峰
2021-05-18  3:09             ` Bjorn Helgaas
2021-05-18  9:30               ` suijingfeng
2021-05-18 19:31                 ` Bjorn Helgaas
2021-05-18  7:13           ` Huacai Chen
2021-05-18 19:35             ` Bjorn Helgaas
2021-05-19  2:17               ` Huacai Chen
2021-05-19 19:33                 ` Bjorn Helgaas
2021-05-25 11:03                   ` Huacai Chen
2021-05-25 13:55                     ` Bjorn Helgaas
2021-05-26  2:33                       ` Huacai Chen
2021-05-26  3:00                         ` Dave Airlie
2021-05-26 18:29                           ` Bjorn Helgaas

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=41a47822-8aed-917a-ec6a-e37be5ff2f35@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=bhelgaas@google.com \
    --cc=chenhuacai@gmail.com \
    --cc=chenhuacai@loongson.cn \
    --cc=helgaas@kernel.org \
    --cc=huangshuai@loongson.cn \
    --cc=linux-pci@vger.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 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).