From: Darren Salt <devspam@moreofthesa.me.uk>
To: christian.koenig@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/7] amdgpu: resize BAR0 to the maximum available size, even if it doesn't cover VRAM (v2)
Date: Fri, 11 Dec 2020 17:31:50 +0000 [thread overview]
Message-ID: <58E2B73AC8%devspam@moreofthesa.me.uk> (raw)
In-Reply-To: <67019c3e-13cb-0196-73f1-2e71b0a5b6f9@gmail.com>
I demand that Christian König may or may not have written...
> Am 11.12.20 um 01:55 schrieb Darren Salt:
[snip]
>> + rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size);
>> + current_size = pci_rebar_get_current_size(adev->pdev, 0);
>> +
>> + /* Skip if the BIOS has already enabled large BAR, covering the VRAM */
>> + if (current_size >= rbar_size)
> You should probably keep the comparison as it is and check the resource
> length against the VRAM size instead.
Perhaps. I wonder, though, if I should do
if (adev->gmc.real_vram_size == 0)
return;
instead of the first part of the original condition.
[snip]
>> + dev_dbg(adev->dev, "BIOS-allocated BAR0 was %lluMB; trying to get %lluMB",
>> + current_size < 0 ? 0 : (pci_rebar_size_to_bytes(current_size) >> 20),
>> + pci_rebar_size_to_bytes(rbar_size) >> 20);
> Please no extra debugging output, we spam syslog that enough with the
> existing resize.
Okay, I'll dispose of that.
[snip]
>> - r = pci_resize_resource(adev->pdev, 0, rbar_size);
>> - if (r == -ENOSPC)
>> - DRM_INFO("Not enough PCI address space for a large BAR.");
>> - else if (r && r != -ENOTSUPP)
>> - DRM_ERROR("Problem resizing BAR0 (%d).", r);
>> + r = 0;
>> + for (; rbar_size >= 0 && rbar_size > current_size; --rbar_size) {
>> + /* Skip this size if it isn't advertised.
>> + * This avoids pci_resize_resources returning -EINVAL for that reason.
>> + */
>> + if (!(available_sizes & BIT(rbar_size)))
>> + continue;
> Well exactly that try and error is a rather big NAK.
> What you need to do instead is to look at the return value from
> pci_rebar_get_possible_sizes() and determine the size closed to the desired
> one. […]
Well… there's that rapid reject immediately following; and the override patch
alters that condition.
> E.g. when need a size of 13 is needed you first check if any bit >= 13
> are set. You can use the ffs() for this.
So… find the lowest bit set, after masking out bits 0 to (rbar_size-1),
and try to re-allocate accordingly.
I could have it check for larger sizes if that fails, but I don't think that
it's worth it. If the BAR size is >= 2× the VRAM size, it's a waste of
address space; and the advertisement of such a size is arguably a VBIOS bug
anyway.
> If that isn't the case use fls() to get the highest set bit < 13.
That suggests that it'll be easiest to clear each bit after the corresponding
size is checked, I think. Also, this looks like it's adding complexity to
try to make rarely-executed code slightly faster in some cases (I can't see
it helping where available_sizes == 0x3F00, for example).
Incidentally, is it worth trying to reduce the BAR size at all? Thinking
mainly of two situations – limiting the maximum size, and the BIOS having
allocated one much too large.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-12-11 18:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 0:54 [PATCH 0/7] amdgpu, pci: improved BAR resizing support Darren Salt
2020-12-11 0:55 ` [PATCH 1/7] pci: export PCI BAR size-reading functions Darren Salt
2020-12-11 9:07 ` Christian König
2020-12-11 0:55 ` [PATCH 2/7] pci: add BAR bytes->size helper & expose size->bytes helper Darren Salt
2020-12-11 0:55 ` [PATCH 3/7] amdgpu: resize BAR0 to the maximum available size, even if it doesn't cover VRAM (v2) Darren Salt
2020-12-11 16:42 ` Christian König
2020-12-11 17:31 ` Darren Salt [this message]
2020-12-11 19:06 ` Alex Deucher
2020-12-14 8:12 ` Christian König
2020-12-14 15:46 ` Darren Salt
2020-12-14 20:44 ` Christian König
2020-12-11 0:55 ` [PATCH 4/7] amdgpu: module option controlling whether BAR0 resizing is done Darren Salt
2020-12-11 9:09 ` Christian König
2020-12-11 0:55 ` [PATCH 5/7] amdgpu: limit maximum FB BAR size when attempting to enlarge Darren Salt
2020-12-11 0:55 ` [PATCH 6/7] pci: allow for overriding the list of advertised BAR sizes Darren Salt
2020-12-11 0:55 ` [PATCH 7/7] amdgpu: allow overriding of the GPU's list of supported " Darren Salt
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=58E2B73AC8%devspam@moreofthesa.me.uk \
--to=devspam@moreofthesa.me.uk \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
/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