Skip to content

riscv64: sg2042: hack: support AMD graphics cards #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion drivers/gpu/drm/drm_gem_vram_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,11 @@ static struct ttm_tt *bo_driver_ttm_tt_create(struct ttm_buffer_object *bo,
tt = kzalloc(sizeof(*tt), GFP_KERNEL);
if (!tt)
return NULL;

#if !defined(CONFIG_PCIE_SG2042_HACK)
ret = ttm_tt_init(tt, bo, page_flags, ttm_cached, 0);
#else
ret = ttm_tt_init(tt, bo, page_flags, ttm_write_combined, 0);
#endif
if (ret < 0)
goto err_ttm_tt_init;

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/radeon/radeon_irq_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
* of address for "64-bit" MSIs which breaks on some platforms, notably
* IBM POWER servers, so we limit them
*/
#if !defined(CONFIG_PCIE_SG2042_HACK)
if (rdev->family < CHIP_BONAIRE) {
dev_info(rdev->dev, "radeon: MSI limited to 32-bit\n");
rdev->pdev->no_64bit_msi = 1;
}
#endif

/* force MSI on */
if (radeon_msi == 1)
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/ttm/ttm_bo_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
if (ret)
return ret;

#if !defined(CONFIG_PCIE_SG2042_HACK)
if (num_pages == 1 && ttm->caching == ttm_cached &&
!(man->use_tt && (ttm->page_flags & TTM_TT_FLAG_DECRYPTED))) {
/*
Expand All @@ -365,6 +366,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
map->page = ttm->pages[start_page];
map->virtual = kmap(map->page);
} else {
#endif
{
/*
* We need to use vmap to get the desired page protection
* or to make the buffer object look contiguous.
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/ttm/ttm_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
#endif /* CONFIG_UML */
#endif /* __i386__ || __x86_64__ */
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \
defined(__powerpc__) || defined(__mips__) || defined(__loongarch__)
defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \
defined(__riscv)
if (caching == ttm_write_combined)
tmp = pgprot_writecombine(tmp);
else
Expand Down
10 changes: 10 additions & 0 deletions drivers/gpu/drm/ttm/ttm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
res->bus.addr = NULL;
res->bus.offset = 0;
res->bus.is_iomem = false;
#if !defined(CONFIG_PCIE_SG2042_HACK)
res->bus.caching = ttm_cached;
#else
res->bus.caching = ttm_write_combined;
#endif
res->bo = bo;

man = ttm_manager_type(bo->bdev, place->mem_type);
Expand Down Expand Up @@ -840,16 +844,22 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io,
} else {
iter_io->needs_unmap = true;
memset(&iter_io->dmap, 0, sizeof(iter_io->dmap));
#if !defined(CONFIG_PCIE_SG2042_HACK)
if (mem->bus.caching == ttm_write_combined)
#else
if (mem->bus.caching == ttm_write_combined || mem->bus.caching == ttm_cached)
#endif
iosys_map_set_vaddr_iomem(&iter_io->dmap,
ioremap_wc(mem->bus.offset,
mem->size));
#if !defined(CONFIG_PCIE_SG2042_HACK)
else if (mem->bus.caching == ttm_cached)
iosys_map_set_vaddr(&iter_io->dmap,
memremap(mem->bus.offset, mem->size,
MEMREMAP_WB |
MEMREMAP_WT |
MEMREMAP_WC));
#endif

/* If uncached requested or if mapping cached or wc failed */
if (iosys_map_is_null(&iter_io->dmap))
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/ttm/ttm_tt.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ static void ttm_tt_init_fields(struct ttm_tt *ttm,
ttm->dma_address = NULL;
ttm->swap_storage = NULL;
ttm->sg = bo->sg;
#if !defined(CONFIG_PCIE_SG2042_HACK)
ttm->caching = caching;
#else
ttm->caching = ttm_write_combined;
#endif
ttm->restore = NULL;
ttm->backup = NULL;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8378,10 +8378,12 @@ static bool ixgbe_check_fw_error(struct ixgbe_adapter *adapter)
/* read fwsm.ext_err_ind register and log errors */
fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw));

#if !defined(CONFIG_PCIE_SG2042_HACK)
if (fwsm & IXGBE_FWSM_EXT_ERR_IND_MASK ||
!(fwsm & IXGBE_FWSM_FW_VAL_BIT))
e_dev_warn("Warning firmware error detected FWSM: 0x%08X\n",
fwsm);
#endif

if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) {
e_dev_err("Firmware recovery mode detected. Limiting functionality. Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
Expand Down
10 changes: 10 additions & 0 deletions drivers/pci/controller/cadence/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ config PCIE_SG2042
controller in host mode. Sophgo SG2042 PCIe controller uses Cadence
PCIe core.

config PCIE_SG2042_HACK
bool "Sophgo SG2042 PCIe controller (host mode) with hack"
depends on ARCH_SOPHGO || COMPILE_TEST
depends on OF
depends on PCIE_SG2042
default n
help
To enable support for graphics cards and some peripherals on the
Sophgo SG2042, some "hacks" are required. Say "Y" to enable it.

config PCI_J721E
bool

Expand Down
11 changes: 11 additions & 0 deletions sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,14 @@ enum {
AZX_DCAPS_SNOOP_TYPE(ATI))

/* quirks for ATI/AMD HDMI */
#if defined(CONFIG_PCIE_SG2042_HACK)
#define AZX_DCAPS_PRESET_ATI_HDMI \
(AZX_DCAPS_NO_TCSEL | AZX_DCAPS_POSFIX_LPIB)
#else
#define AZX_DCAPS_PRESET_ATI_HDMI \
(AZX_DCAPS_NO_TCSEL | AZX_DCAPS_POSFIX_LPIB|\
AZX_DCAPS_NO_MSI64)
#endif

/* quirks for ATI HDMI with snoop off */
#define AZX_DCAPS_PRESET_ATI_HDMI_NS \
Expand All @@ -316,9 +321,15 @@ enum {
AZX_DCAPS_RETRY_PROBE)

/* quirks for Nvidia */
#if defined(CONFIG_PCIE_SG2042_HACK)
#define AZX_DCAPS_PRESET_NVIDIA \
(AZX_DCAPS_CORBRP_SELF_CLEAR |\
AZX_DCAPS_SNOOP_TYPE(NVIDIA))
#else
#define AZX_DCAPS_PRESET_NVIDIA \
(AZX_DCAPS_NO_MSI | AZX_DCAPS_CORBRP_SELF_CLEAR |\
AZX_DCAPS_SNOOP_TYPE(NVIDIA))
#endif

#define AZX_DCAPS_PRESET_CTHDA \
(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB |\
Expand Down