Microsemi / switchtec-kernel

A kernel module for the Microsemi PCIe switch
GNU General Public License v2.0
45 stars 31 forks source link

Update README.rst to include BAR prefetchable requirement #63

Closed wesleywesley closed 5 years ago

wesleywesley commented 5 years ago

For improving MRPC efficiency by leveraging write combining, it requires the BAR prefetchable bit set for Management/NT Endpoint.

Story about this patch: In case of BAR prefetchable bit cleared, there will be only resource0 under /sys/devices/ of sysfs for the Management/NT EP, different to the bit set case, both resource0 and resource0_wc. It lead to user space tool could not work when it need to memory map resource0_wc.

While on the other hand, write combining feature only enabled when BAR prefetchable bit is set actually.

Signed-off-by: Wesley Sheng wesley.sheng@microchip.com

lsgunth commented 5 years ago

Woludn't a better solution be to have switchtec-user fall back on resource0 when resource0_wc doesn't exist?

wesleywesley commented 5 years ago

@lsgunth Yes, Switchtec-user should compatible for both non- & prefetchable case.

wesleywesley commented 5 years ago

Fix the issue in Switchtec-user: Fall back to resource0 in case resource0_wc doesn't exist #87 https://github.com/Microsemi/switchtec-user/pull/87

Close this PR.

wesleywesley commented 5 years ago

Some update about prefetchable and non-prefetchable of BAR:

Per spec: Set to one. If there are no side effects on reads, the device returns all bytes on reads regardless of the byte enables, and host bridges can merge processor writes into this range without causing errors. Bit must be set to zero otherwise.

So perfetchable space has two very well defined attributes: read do not have side effects write merging is allowed

But when capture pcie treace for both linux and windows driver with this bit set or not, we got the results: that's just a suggestion bit, no mandatory. WC feature is only depend on if driver enable it or not, but has nothing to do with this bit is 0 or 1. If switchtec-kernel/switchtec-kmdf enable the wc mapping, each write could up to 16 dwords, while no-wc mapping, one byte enabled for each dword write on linux, and 4 dowrds for windows.

We can determine on linux whether or not prefetchable by check if resource0_wc device file is exists or not from sysfs. And on windows, just check ep's bar types property, what we got is 0000-0100 for non-pre and 0001-0000 for pre. Because there is no document about this for Windows how to distinguish, this is just my observation.

Regard, Wesley