summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-06-12 12:30:10 +0000
committerkettenis <kettenis@openbsd.org>2020-06-12 12:30:10 +0000
commit50f19d1942a4cc2d3ad10c62a47e60223b4cf0f0 (patch)
treea9abf029d6fd00816b77a8bae067ee0856784765
parentMake amdgpu_irq_add_domain silent; this functionality is only needed to (diff)
downloadwireguard-openbsd-50f19d1942a4cc2d3ad10c62a47e60223b4cf0f0.tar.xz
wireguard-openbsd-50f19d1942a4cc2d3ad10c62a47e60223b4cf0f0.zip
Silence amdgpu_device_resize_fb_bar; supporting resizing of PCI BARs is
tricky and using the pre-programmed BAR size should always work. Using bigger BARs might improve performance but it we probably need other changes (such as making the driver mpsafe) to benefit from that.
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
index 71ef4d4537e..3509e8b3815 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
@@ -886,6 +886,7 @@ void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb)
*/
int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
{
+#ifdef __linux__
u64 space_needed = roundup_pow_of_two(adev->gmc.real_vram_size);
u32 rbar_size = order_base_2(((space_needed >> 20) | 1)) - 1;
struct pci_bus *root;
@@ -893,16 +894,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
unsigned i;
u16 cmd;
int r;
- pcireg_t type;
-
- /* XXX not right yet */
- STUB();
- return 0;
/* Bypass for VF */
if (amdgpu_sriov_vf(adev))
return 0;
-#ifdef notyet
/* Check if the root BUS has 64bit memory resources */
root = adev->pdev->bus;
@@ -918,7 +913,6 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
/* Trying to resize is pointless without a root hub window above 4GB */
if (!res)
return 0;
-#endif
/* Disable memory decoding while we change the BAR addresses and size */
pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);
@@ -927,12 +921,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
/* Free the VRAM and doorbell BAR, we most likely need to move both. */
amdgpu_device_doorbell_fini(adev);
-#ifdef __linux__
if (adev->asic_type >= CHIP_BONAIRE)
pci_release_resource(adev->pdev, 2);
pci_release_resource(adev->pdev, 0);
-#endif
r = pci_resize_resource(adev->pdev, 0, rbar_size);
if (r == -ENOSPC)
@@ -940,31 +932,17 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
else if (r && r != -ENOTSUPP)
DRM_ERROR("Problem resizing BAR0 (%d).", r);
-#ifdef __linux__
pci_assign_unassigned_bus_resources(adev->pdev->bus);
-#else
-#define AMDGPU_PCI_MEM 0x10
- type = pci_mapreg_type(adev->pc, adev->pa_tag, AMDGPU_PCI_MEM);
- if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM ||
- pci_mapreg_info(adev->pc, adev->pa_tag, AMDGPU_PCI_MEM,
- type, NULL, &adev->fb_aper_size, NULL)) {
- printf(": can't get frambuffer info\n");
- return -ENODEV;
- }
-#endif
/* When the doorbell or fb BAR isn't available we have no chance of
* using the device.
*/
r = amdgpu_device_doorbell_init(adev);
-#ifdef notyet
if (r || (pci_resource_flags(adev->pdev, 0) & IORESOURCE_UNSET))
-#else
- if (r)
-#endif
return -ENODEV;
pci_write_config_word(adev->pdev, PCI_COMMAND, cmd);
+#endif /* __linux__ */
return 0;
}