diff options
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 36 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/cik.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/fiji_smc.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/iceland_smc.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/si.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/tonga_smc.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vi.c | 27 |
10 files changed, 81 insertions, 55 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index ee45d9f7f3dc..fb8d6030a64d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1827,6 +1827,7 @@ struct amdgpu_asic_funcs { | |||
1827 | bool (*read_disabled_bios)(struct amdgpu_device *adev); | 1827 | bool (*read_disabled_bios)(struct amdgpu_device *adev); |
1828 | bool (*read_bios_from_rom)(struct amdgpu_device *adev, | 1828 | bool (*read_bios_from_rom)(struct amdgpu_device *adev, |
1829 | u8 *bios, u32 length_bytes); | 1829 | u8 *bios, u32 length_bytes); |
1830 | void (*detect_hw_virtualization) (struct amdgpu_device *adev); | ||
1830 | int (*read_register)(struct amdgpu_device *adev, u32 se_num, | 1831 | int (*read_register)(struct amdgpu_device *adev, u32 se_num, |
1831 | u32 sh_num, u32 reg_offset, u32 *value); | 1832 | u32 sh_num, u32 reg_offset, u32 *value); |
1832 | void (*set_vga_state)(struct amdgpu_device *adev, bool state); | 1833 | void (*set_vga_state)(struct amdgpu_device *adev, bool state); |
@@ -1836,8 +1837,6 @@ struct amdgpu_asic_funcs { | |||
1836 | /* MM block clocks */ | 1837 | /* MM block clocks */ |
1837 | int (*set_uvd_clocks)(struct amdgpu_device *adev, u32 vclk, u32 dclk); | 1838 | int (*set_uvd_clocks)(struct amdgpu_device *adev, u32 vclk, u32 dclk); |
1838 | int (*set_vce_clocks)(struct amdgpu_device *adev, u32 evclk, u32 ecclk); | 1839 | int (*set_vce_clocks)(struct amdgpu_device *adev, u32 evclk, u32 ecclk); |
1839 | /* query virtual capabilities */ | ||
1840 | u32 (*get_virtual_caps)(struct amdgpu_device *adev); | ||
1841 | /* static power management */ | 1840 | /* static power management */ |
1842 | int (*get_pcie_lanes)(struct amdgpu_device *adev); | 1841 | int (*get_pcie_lanes)(struct amdgpu_device *adev); |
1843 | void (*set_pcie_lanes)(struct amdgpu_device *adev, int lanes); | 1842 | void (*set_pcie_lanes)(struct amdgpu_device *adev, int lanes); |
@@ -1934,15 +1933,36 @@ struct cgs_device *amdgpu_cgs_create_device(struct amdgpu_device *adev); | |||
1934 | void amdgpu_cgs_destroy_device(struct cgs_device *cgs_device); | 1933 | void amdgpu_cgs_destroy_device(struct cgs_device *cgs_device); |
1935 | 1934 | ||
1936 | 1935 | ||
1936 | #define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0) /* vBIOS is sr-iov ready */ | ||
1937 | #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1) /* sr-iov is enabled on this GPU */ | ||
1938 | #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2) /* this GPU is a virtual function */ | ||
1939 | #define AMDGPU_PASSTHROUGH_MODE (1 << 3) /* thw whole GPU is pass through for VM */ | ||
1937 | /* GPU virtualization */ | 1940 | /* GPU virtualization */ |
1938 | #define AMDGPU_VIRT_CAPS_SRIOV_EN (1 << 0) | ||
1939 | #define AMDGPU_VIRT_CAPS_IS_VF (1 << 1) | ||
1940 | struct amdgpu_virtualization { | 1941 | struct amdgpu_virtualization { |
1941 | bool supports_sr_iov; | 1942 | uint32_t virtual_caps; |
1942 | bool is_virtual; | ||
1943 | u32 caps; | ||
1944 | }; | 1943 | }; |
1945 | 1944 | ||
1945 | #define amdgpu_sriov_enabled(adev) \ | ||
1946 | ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV) | ||
1947 | |||
1948 | #define amdgpu_sriov_vf(adev) \ | ||
1949 | ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_IS_VF) | ||
1950 | |||
1951 | #define amdgpu_sriov_bios(adev) \ | ||
1952 | ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS) | ||
1953 | |||
1954 | #define amdgpu_passthrough(adev) \ | ||
1955 | ((adev)->virtualization.virtual_caps & AMDGPU_PASSTHROUGH_MODE) | ||
1956 | |||
1957 | static inline bool is_virtual_machine(void) | ||
1958 | { | ||
1959 | #ifdef CONFIG_X86 | ||
1960 | return boot_cpu_has(X86_FEATURE_HYPERVISOR); | ||
1961 | #else | ||
1962 | return false; | ||
1963 | #endif | ||
1964 | } | ||
1965 | |||
1946 | /* | 1966 | /* |
1947 | * Core structure, functions and helpers. | 1967 | * Core structure, functions and helpers. |
1948 | */ | 1968 | */ |
@@ -2260,12 +2280,12 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
2260 | #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev)) | 2280 | #define amdgpu_asic_get_xclk(adev) (adev)->asic_funcs->get_xclk((adev)) |
2261 | #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) | 2281 | #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) |
2262 | #define amdgpu_asic_set_vce_clocks(adev, ev, ec) (adev)->asic_funcs->set_vce_clocks((adev), (ev), (ec)) | 2282 | #define amdgpu_asic_set_vce_clocks(adev, ev, ec) (adev)->asic_funcs->set_vce_clocks((adev), (ev), (ec)) |
2263 | #define amdgpu_asic_get_virtual_caps(adev) ((adev)->asic_funcs->get_virtual_caps((adev))) | ||
2264 | #define amdgpu_get_pcie_lanes(adev) (adev)->asic_funcs->get_pcie_lanes((adev)) | 2283 | #define amdgpu_get_pcie_lanes(adev) (adev)->asic_funcs->get_pcie_lanes((adev)) |
2265 | #define amdgpu_set_pcie_lanes(adev, l) (adev)->asic_funcs->set_pcie_lanes((adev), (l)) | 2284 | #define amdgpu_set_pcie_lanes(adev, l) (adev)->asic_funcs->set_pcie_lanes((adev), (l)) |
2266 | #define amdgpu_asic_get_gpu_clock_counter(adev) (adev)->asic_funcs->get_gpu_clock_counter((adev)) | 2285 | #define amdgpu_asic_get_gpu_clock_counter(adev) (adev)->asic_funcs->get_gpu_clock_counter((adev)) |
2267 | #define amdgpu_asic_read_disabled_bios(adev) (adev)->asic_funcs->read_disabled_bios((adev)) | 2286 | #define amdgpu_asic_read_disabled_bios(adev) (adev)->asic_funcs->read_disabled_bios((adev)) |
2268 | #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) | 2287 | #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) |
2288 | #define amdgpu_asic_detect_hw_virtualization(adev) (adev)->asic_funcs->detect_hw_virtualization((adev)) | ||
2269 | #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) | 2289 | #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) |
2270 | #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid)) | 2290 | #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid)) |
2271 | #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) | 2291 | #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index d97efc1a3109..4acc92b9eec6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -110,7 +110,7 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, | |||
110 | bool always_indirect) | 110 | bool always_indirect) |
111 | { | 111 | { |
112 | trace_amdgpu_mm_wreg(adev->pdev->device, reg, v); | 112 | trace_amdgpu_mm_wreg(adev->pdev->device, reg, v); |
113 | 113 | ||
114 | if ((reg * 4) < adev->rmmio_size && !always_indirect) | 114 | if ((reg * 4) < adev->rmmio_size && !always_indirect) |
115 | writel(v, ((void __iomem *)adev->rmmio) + (reg * 4)); | 115 | writel(v, ((void __iomem *)adev->rmmio) + (reg * 4)); |
116 | else { | 116 | else { |
@@ -1485,13 +1485,10 @@ static int amdgpu_resume(struct amdgpu_device *adev) | |||
1485 | return 0; | 1485 | return 0; |
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | static bool amdgpu_device_is_virtual(void) | 1488 | static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev) |
1489 | { | 1489 | { |
1490 | #ifdef CONFIG_X86 | 1490 | if (amdgpu_atombios_has_gpu_virtualization_table(adev)) |
1491 | return boot_cpu_has(X86_FEATURE_HYPERVISOR); | 1491 | adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; |
1492 | #else | ||
1493 | return false; | ||
1494 | #endif | ||
1495 | } | 1492 | } |
1496 | 1493 | ||
1497 | /** | 1494 | /** |
@@ -1648,25 +1645,25 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1648 | goto failed; | 1645 | goto failed; |
1649 | } | 1646 | } |
1650 | 1647 | ||
1651 | /* See if the asic supports SR-IOV */ | 1648 | /* detect if we are with an SRIOV vbios */ |
1652 | adev->virtualization.supports_sr_iov = | 1649 | amdgpu_device_detect_sriov_bios(adev); |
1653 | amdgpu_atombios_has_gpu_virtualization_table(adev); | ||
1654 | |||
1655 | /* Check if we are executing in a virtualized environment */ | ||
1656 | adev->virtualization.is_virtual = amdgpu_device_is_virtual(); | ||
1657 | adev->virtualization.caps = amdgpu_asic_get_virtual_caps(adev); | ||
1658 | 1650 | ||
1659 | /* Post card if necessary */ | 1651 | /* Post card if necessary */ |
1660 | if (!amdgpu_card_posted(adev) || | 1652 | if (!amdgpu_sriov_vf(adev) && |
1661 | (adev->virtualization.is_virtual && | 1653 | (!amdgpu_card_posted(adev) || amdgpu_passthrough(adev))) { |
1662 | !(adev->virtualization.caps & AMDGPU_VIRT_CAPS_SRIOV_EN))) { | ||
1663 | if (!adev->bios) { | 1654 | if (!adev->bios) { |
1664 | dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n"); | 1655 | dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n"); |
1665 | r = -EINVAL; | 1656 | r = -EINVAL; |
1666 | goto failed; | 1657 | goto failed; |
1667 | } | 1658 | } |
1668 | DRM_INFO("GPU not posted. posting now...\n"); | 1659 | DRM_INFO("GPU not posted. posting now...\n"); |
1669 | amdgpu_atom_asic_init(adev->mode_info.atom_context); | 1660 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
1661 | if (r) { | ||
1662 | dev_err(adev->dev, "gpu post error!\n"); | ||
1663 | goto failed; | ||
1664 | } | ||
1665 | } else { | ||
1666 | DRM_INFO("GPU post is not needed\n"); | ||
1670 | } | 1667 | } |
1671 | 1668 | ||
1672 | /* Initialize clocks */ | 1669 | /* Initialize clocks */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index c96ae105b764..0c5f36d1ea3e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -485,7 +485,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) | |||
485 | /* if we are running in a VM, make sure the device | 485 | /* if we are running in a VM, make sure the device |
486 | * torn down properly on reboot/shutdown | 486 | * torn down properly on reboot/shutdown |
487 | */ | 487 | */ |
488 | if (adev->virtualization.is_virtual) | 488 | if (amdgpu_passthrough(adev)) |
489 | amdgpu_pci_remove(pdev); | 489 | amdgpu_pci_remove(pdev); |
490 | } | 490 | } |
491 | 491 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index 825de800b798..a845b6a93b79 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -963,12 +963,6 @@ static bool cik_read_bios_from_rom(struct amdgpu_device *adev, | |||
963 | return true; | 963 | return true; |
964 | } | 964 | } |
965 | 965 | ||
966 | static u32 cik_get_virtual_caps(struct amdgpu_device *adev) | ||
967 | { | ||
968 | /* CIK does not support SR-IOV */ | ||
969 | return 0; | ||
970 | } | ||
971 | |||
972 | static const struct amdgpu_allowed_register_entry cik_allowed_read_registers[] = { | 966 | static const struct amdgpu_allowed_register_entry cik_allowed_read_registers[] = { |
973 | {mmGRBM_STATUS, false}, | 967 | {mmGRBM_STATUS, false}, |
974 | {mmGB_ADDR_CONFIG, false}, | 968 | {mmGB_ADDR_CONFIG, false}, |
@@ -1641,6 +1635,12 @@ static uint32_t cik_get_rev_id(struct amdgpu_device *adev) | |||
1641 | >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; | 1635 | >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; |
1642 | } | 1636 | } |
1643 | 1637 | ||
1638 | static void cik_detect_hw_virtualization(struct amdgpu_device *adev) | ||
1639 | { | ||
1640 | if (is_virtual_machine()) /* passthrough mode */ | ||
1641 | adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | ||
1642 | } | ||
1643 | |||
1644 | static const struct amdgpu_ip_block_version bonaire_ip_blocks[] = | 1644 | static const struct amdgpu_ip_block_version bonaire_ip_blocks[] = |
1645 | { | 1645 | { |
1646 | /* ORDER MATTERS! */ | 1646 | /* ORDER MATTERS! */ |
@@ -2384,13 +2384,13 @@ static const struct amdgpu_asic_funcs cik_asic_funcs = | |||
2384 | { | 2384 | { |
2385 | .read_disabled_bios = &cik_read_disabled_bios, | 2385 | .read_disabled_bios = &cik_read_disabled_bios, |
2386 | .read_bios_from_rom = &cik_read_bios_from_rom, | 2386 | .read_bios_from_rom = &cik_read_bios_from_rom, |
2387 | .detect_hw_virtualization = cik_detect_hw_virtualization, | ||
2387 | .read_register = &cik_read_register, | 2388 | .read_register = &cik_read_register, |
2388 | .reset = &cik_asic_reset, | 2389 | .reset = &cik_asic_reset, |
2389 | .set_vga_state = &cik_vga_set_state, | 2390 | .set_vga_state = &cik_vga_set_state, |
2390 | .get_xclk = &cik_get_xclk, | 2391 | .get_xclk = &cik_get_xclk, |
2391 | .set_uvd_clocks = &cik_set_uvd_clocks, | 2392 | .set_uvd_clocks = &cik_set_uvd_clocks, |
2392 | .set_vce_clocks = &cik_set_vce_clocks, | 2393 | .set_vce_clocks = &cik_set_vce_clocks, |
2393 | .get_virtual_caps = &cik_get_virtual_caps, | ||
2394 | }; | 2394 | }; |
2395 | 2395 | ||
2396 | static int cik_common_early_init(void *handle) | 2396 | static int cik_common_early_init(void *handle) |
diff --git a/drivers/gpu/drm/amd/amdgpu/fiji_smc.c b/drivers/gpu/drm/amd/amdgpu/fiji_smc.c index b3e19ba4c57f..8cfb0a3cf725 100644 --- a/drivers/gpu/drm/amd/amdgpu/fiji_smc.c +++ b/drivers/gpu/drm/amd/amdgpu/fiji_smc.c | |||
@@ -275,7 +275,7 @@ static int fiji_smu_upload_firmware_image(struct amdgpu_device *adev) | |||
275 | /* Skip SMC ucode loading on SR-IOV capable boards. | 275 | /* Skip SMC ucode loading on SR-IOV capable boards. |
276 | * vbios does this for us in asic_init in that case. | 276 | * vbios does this for us in asic_init in that case. |
277 | */ | 277 | */ |
278 | if (adev->virtualization.supports_sr_iov) | 278 | if (amdgpu_sriov_bios(adev)) |
279 | return 0; | 279 | return 0; |
280 | 280 | ||
281 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; | 281 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 8e7127f09ff6..6ec8e01109aa 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
@@ -261,8 +261,10 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device *adev) | |||
261 | 261 | ||
262 | /* Skip MC ucode loading on SR-IOV capable boards. | 262 | /* Skip MC ucode loading on SR-IOV capable boards. |
263 | * vbios does this for us in asic_init in that case. | 263 | * vbios does this for us in asic_init in that case. |
264 | * Skip MC ucode loading on VF, because hypervisor will do that | ||
265 | * for this adaptor. | ||
264 | */ | 266 | */ |
265 | if (adev->virtualization.supports_sr_iov) | 267 | if (amdgpu_sriov_bios(adev)) |
266 | return 0; | 268 | return 0; |
267 | 269 | ||
268 | hdr = (const struct mc_firmware_header_v1_0 *)adev->mc.fw->data; | 270 | hdr = (const struct mc_firmware_header_v1_0 *)adev->mc.fw->data; |
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_smc.c b/drivers/gpu/drm/amd/amdgpu/iceland_smc.c index ef7c27d7356a..c6e004a3f557 100644 --- a/drivers/gpu/drm/amd/amdgpu/iceland_smc.c +++ b/drivers/gpu/drm/amd/amdgpu/iceland_smc.c | |||
@@ -282,7 +282,7 @@ static int iceland_smu_upload_firmware_image(struct amdgpu_device *adev) | |||
282 | /* Skip SMC ucode loading on SR-IOV capable boards. | 282 | /* Skip SMC ucode loading on SR-IOV capable boards. |
283 | * vbios does this for us in asic_init in that case. | 283 | * vbios does this for us in asic_init in that case. |
284 | */ | 284 | */ |
285 | if (adev->virtualization.supports_sr_iov) | 285 | if (amdgpu_sriov_bios(adev)) |
286 | return 0; | 286 | return 0; |
287 | 287 | ||
288 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; | 288 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; |
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index fee76b8a536f..dc9511c5ecb8 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -952,12 +952,6 @@ static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | |||
952 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | 952 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
953 | } | 953 | } |
954 | 954 | ||
955 | static u32 si_get_virtual_caps(struct amdgpu_device *adev) | ||
956 | { | ||
957 | /* SI does not support SR-IOV */ | ||
958 | return 0; | ||
959 | } | ||
960 | |||
961 | static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { | 955 | static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { |
962 | {GRBM_STATUS, false}, | 956 | {GRBM_STATUS, false}, |
963 | {GB_ADDR_CONFIG, false}, | 957 | {GB_ADDR_CONFIG, false}, |
@@ -1124,16 +1118,22 @@ static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) | |||
1124 | return 0; | 1118 | return 0; |
1125 | } | 1119 | } |
1126 | 1120 | ||
1121 | static void si_detect_hw_virtualization(struct amdgpu_device *adev) | ||
1122 | { | ||
1123 | if (is_virtual_machine()) /* passthrough mode */ | ||
1124 | adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | ||
1125 | } | ||
1126 | |||
1127 | static const struct amdgpu_asic_funcs si_asic_funcs = | 1127 | static const struct amdgpu_asic_funcs si_asic_funcs = |
1128 | { | 1128 | { |
1129 | .read_disabled_bios = &si_read_disabled_bios, | 1129 | .read_disabled_bios = &si_read_disabled_bios, |
1130 | .detect_hw_virtualization = si_detect_hw_virtualization, | ||
1130 | .read_register = &si_read_register, | 1131 | .read_register = &si_read_register, |
1131 | .reset = &si_asic_reset, | 1132 | .reset = &si_asic_reset, |
1132 | .set_vga_state = &si_vga_set_state, | 1133 | .set_vga_state = &si_vga_set_state, |
1133 | .get_xclk = &si_get_xclk, | 1134 | .get_xclk = &si_get_xclk, |
1134 | .set_uvd_clocks = &si_set_uvd_clocks, | 1135 | .set_uvd_clocks = &si_set_uvd_clocks, |
1135 | .set_vce_clocks = NULL, | 1136 | .set_vce_clocks = NULL, |
1136 | .get_virtual_caps = &si_get_virtual_caps, | ||
1137 | }; | 1137 | }; |
1138 | 1138 | ||
1139 | static uint32_t si_get_rev_id(struct amdgpu_device *adev) | 1139 | static uint32_t si_get_rev_id(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_smc.c b/drivers/gpu/drm/amd/amdgpu/tonga_smc.c index 940de1836f8f..1e71e819468b 100644 --- a/drivers/gpu/drm/amd/amdgpu/tonga_smc.c +++ b/drivers/gpu/drm/amd/amdgpu/tonga_smc.c | |||
@@ -275,7 +275,7 @@ static int tonga_smu_upload_firmware_image(struct amdgpu_device *adev) | |||
275 | /* Skip SMC ucode loading on SR-IOV capable boards. | 275 | /* Skip SMC ucode loading on SR-IOV capable boards. |
276 | * vbios does this for us in asic_init in that case. | 276 | * vbios does this for us in asic_init in that case. |
277 | */ | 277 | */ |
278 | if (adev->virtualization.supports_sr_iov) | 278 | if (amdgpu_sriov_bios(adev)) |
279 | return 0; | 279 | return 0; |
280 | 280 | ||
281 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; | 281 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; |
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index b688e2f77419..a8154d0ac288 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c | |||
@@ -445,18 +445,21 @@ static bool vi_read_bios_from_rom(struct amdgpu_device *adev, | |||
445 | return true; | 445 | return true; |
446 | } | 446 | } |
447 | 447 | ||
448 | static u32 vi_get_virtual_caps(struct amdgpu_device *adev) | 448 | static void vi_detect_hw_virtualization(struct amdgpu_device *adev) |
449 | { | 449 | { |
450 | u32 caps = 0; | 450 | uint32_t reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER); |
451 | u32 reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER); | 451 | /* bit0: 0 means pf and 1 means vf */ |
452 | /* bit31: 0 means disable IOV and 1 means enable */ | ||
453 | if (reg & 1) | ||
454 | adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_IS_VF; | ||
452 | 455 | ||
453 | if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, IOV_ENABLE)) | 456 | if (reg & 0x80000000) |
454 | caps |= AMDGPU_VIRT_CAPS_SRIOV_EN; | 457 | adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; |
455 | 458 | ||
456 | if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, FUNC_IDENTIFIER)) | 459 | if (reg == 0) { |
457 | caps |= AMDGPU_VIRT_CAPS_IS_VF; | 460 | if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */ |
458 | 461 | adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | |
459 | return caps; | 462 | } |
460 | } | 463 | } |
461 | 464 | ||
462 | static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = { | 465 | static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = { |
@@ -1521,13 +1524,13 @@ static const struct amdgpu_asic_funcs vi_asic_funcs = | |||
1521 | { | 1524 | { |
1522 | .read_disabled_bios = &vi_read_disabled_bios, | 1525 | .read_disabled_bios = &vi_read_disabled_bios, |
1523 | .read_bios_from_rom = &vi_read_bios_from_rom, | 1526 | .read_bios_from_rom = &vi_read_bios_from_rom, |
1527 | .detect_hw_virtualization = vi_detect_hw_virtualization, | ||
1524 | .read_register = &vi_read_register, | 1528 | .read_register = &vi_read_register, |
1525 | .reset = &vi_asic_reset, | 1529 | .reset = &vi_asic_reset, |
1526 | .set_vga_state = &vi_vga_set_state, | 1530 | .set_vga_state = &vi_vga_set_state, |
1527 | .get_xclk = &vi_get_xclk, | 1531 | .get_xclk = &vi_get_xclk, |
1528 | .set_uvd_clocks = &vi_set_uvd_clocks, | 1532 | .set_uvd_clocks = &vi_set_uvd_clocks, |
1529 | .set_vce_clocks = &vi_set_vce_clocks, | 1533 | .set_vce_clocks = &vi_set_vce_clocks, |
1530 | .get_virtual_caps = &vi_get_virtual_caps, | ||
1531 | }; | 1534 | }; |
1532 | 1535 | ||
1533 | static int vi_common_early_init(void *handle) | 1536 | static int vi_common_early_init(void *handle) |
@@ -1657,6 +1660,10 @@ static int vi_common_early_init(void *handle) | |||
1657 | return -EINVAL; | 1660 | return -EINVAL; |
1658 | } | 1661 | } |
1659 | 1662 | ||
1663 | /* in early init stage, vbios code won't work */ | ||
1664 | if (adev->asic_funcs->detect_hw_virtualization) | ||
1665 | amdgpu_asic_detect_hw_virtualization(adev); | ||
1666 | |||
1660 | if (amdgpu_smc_load_fw && smc_enabled) | 1667 | if (amdgpu_smc_load_fw && smc_enabled) |
1661 | adev->firmware.smu_load = true; | 1668 | adev->firmware.smu_load = true; |
1662 | 1669 | ||