Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion arch/arm64/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size)
if (pfn_is_map_memory(__phys_to_pfn(phys_addr)))
return (void __iomem *)__phys_to_virt(phys_addr);

return __ioremap_caller(phys_addr, size, __pgprot(PROT_NORMAL),
return __ioremap_caller(phys_addr, size, __pgprot(PROT_DEVICE_nGnRE),
__builtin_return_address(0));
}
EXPORT_SYMBOL(ioremap_cache);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/radeon/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,8 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
cjiffies = jiffies;
if (time_after(cjiffies, ctx->last_jump_jiffies)) {
cjiffies -= ctx->last_jump_jiffies;
if ((jiffies_to_msecs(cjiffies) > 5000)) {
DRM_ERROR("atombios stuck in loop for more than 5secs aborting\n");
if ((jiffies_to_msecs(cjiffies) > 30000)) {
DRM_ERROR("atombios stuck in loop for more than 30secs aborting\n");
ctx->abort = true;
}
} else {
Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/radeon/evergreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -5029,6 +5029,7 @@ static int evergreen_startup(struct radeon_device *rdev)
if (r)
return r;
}

evergreen_gpu_init(rdev);

/* allocate rlc buffers */
Expand All @@ -5044,11 +5045,17 @@ static int evergreen_startup(struct radeon_device *rdev)
}
}

/* TODO: Dying after here currently. */
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); msleep(200);

/* allocate wb buffer */
r = radeon_wb_init(rdev);
if (r)
return r;

/* TODO: Dying before here currently. */
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); msleep(200);

r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX);
if (r) {
dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r);
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/radeon/evergreen_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ struct radeon_fence *evergreen_copy_dma(struct radeon_device *rdev,
radeon_ring_unlock_commit(rdev, ring, false);
radeon_sync_free(rdev, &sync, fence);

r600_dma_ring_test(rdev, ring);

return fence;
}

Expand Down
9 changes: 6 additions & 3 deletions drivers/gpu/drm/radeon/r600.c
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,7 @@ u32 r600_gfx_get_rptr(struct radeon_device *rdev,
else
rptr = RREG32(R600_CP_RB_RPTR);

mb(); //CHANGED
return rptr;
}

Expand Down Expand Up @@ -3483,7 +3484,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev)
if (rdev->ih.ring_obj == NULL) {
r = radeon_bo_create(rdev, rdev->ih.ring_size,
PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, 0,
RADEON_GEM_DOMAIN_VRAM, 0,
NULL, NULL, &rdev->ih.ring_obj);
if (r) {
DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r);
Expand All @@ -3493,7 +3494,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev)
if (unlikely(r != 0))
return r;
r = radeon_bo_pin(rdev->ih.ring_obj,
RADEON_GEM_DOMAIN_GTT,
RADEON_GEM_DOMAIN_VRAM,
&rdev->ih.gpu_addr);
if (r) {
radeon_bo_unreserve(rdev->ih.ring_obj);
Expand Down Expand Up @@ -4038,8 +4039,10 @@ static u32 r600_get_ih_wptr(struct radeon_device *rdev)
{
u32 wptr, tmp;

if (rdev->wb.enabled)
if (rdev->wb.enabled) {
wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]);
mb();
}
else
wptr = RREG32(IH_RB_WPTR);

Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/radeon/r600_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ uint32_t r600_dma_get_rptr(struct radeon_device *rdev,
else
rptr = RREG32(DMA_RB_RPTR);

mb(); //CHANGED
return (rptr & 0x3fffc) >> 2;
}

Expand Down Expand Up @@ -245,6 +246,7 @@ int r600_dma_ring_test(struct radeon_device *rdev,
tmp = 0xCAFEDEAD;
rdev->wb.wb[index/4] = cpu_to_le32(tmp);

mb(); //CHANGED
r = radeon_ring_lock(rdev, ring, 4);
if (r) {
DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r);
Expand All @@ -258,6 +260,7 @@ int r600_dma_ring_test(struct radeon_device *rdev,

for (i = 0; i < rdev->usec_timeout; i++) {
tmp = le32_to_cpu(rdev->wb.wb[index/4]);
mb(); //CHANGED
if (tmp == 0xDEADBEEF)
break;
udelay(1);
Expand Down Expand Up @@ -379,6 +382,7 @@ int r600_dma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
r = 0;
for (i = 0; i < rdev->usec_timeout; i++) {
tmp = le32_to_cpu(rdev->wb.wb[index/4]);
mb(); //CHANGED
if (tmp == 0xDEADBEEF)
break;
udelay(1);
Expand Down
34 changes: 34 additions & 0 deletions drivers/gpu/drm/radeon/radeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ struct radeon_fence_driver {
atomic64_t last_seq;
bool initialized, delayed_irq;
struct delayed_work lockup_work;
dma_addr_t dma_addr;
};

struct radeon_fence {
Expand Down Expand Up @@ -668,6 +669,8 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
dma_addr_t *dma_addr, uint32_t flags);


void radeon_gart_sync_all_for_device(struct radeon_device *rdev);

/*
* GPU MC structures, functions & helpers
*/
Expand Down Expand Up @@ -2237,6 +2240,13 @@ void radeon_agp_disable(struct radeon_device *rdev);
int radeon_asic_init(struct radeon_device *rdev);


/*
* memcpy_io and memset_io functions that work on a raspberry pi 4
*/
void memcpy_fromio_pcie(void *to, const volatile void __iomem *from, size_t count);
void memcpy_toio_pcie(volatile void __iomem *to, const void *from, size_t count);
void memset_io_pcie(volatile void __iomem *dst, int c, size_t count);

/*
* IOCTL.
*/
Expand Down Expand Up @@ -2337,6 +2347,11 @@ struct radeon_atcs {
typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);

struct moved_bos_entry{
struct radeon_bo* bo;
struct list_head list;
};

struct radeon_device {
struct device *dev;
struct drm_device *ddev;
Expand Down Expand Up @@ -2482,6 +2497,25 @@ struct radeon_device {
/* tracking pinned memory */
u64 vram_pin_size;
u64 gart_pin_size;
struct radeon_bo *rick;
uint64_t rick_gpu;
void *rick_cpu;
uint64_t fb_gpu;

// reading back shader code for debugging
struct radeon_bo* shader_read_bo;
uint64_t shader_read_gpu;
void* shader_read_cpu;

// needed because of weird stuff
int numFSuses;

// tracking moved BOs to move them back after CS execution
struct radeon_bo** moved_bos; // array of pointers to the BOs that were moved
int nMovedBos; // number of BOs moved (determines size of array)
struct mutex move_bos_mutex;
struct list_head move_bo_head;
bool trackMoves; // enables or disables tracking of the BO moves to avoid tracking while moving the BOs back after CS execution
};

bool radeon_is_px(struct drm_device *dev);
Expand Down
11 changes: 8 additions & 3 deletions drivers/gpu/drm/radeon/radeon_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
iounmap(bios);
return false;
}
memcpy_fromio(rdev->bios, bios, size);
memcpy_fromio_pcie(rdev->bios, bios, size);
iounmap(bios);
return true;
}
Expand All @@ -81,6 +81,7 @@ static bool radeon_read_bios(struct radeon_device *rdev)
{
uint8_t __iomem *bios, val1, val2;
size_t size;
int pos;

rdev->bios = NULL;
/* XXX: some cards may return 0 for rom size? ddx has a workaround */
Expand All @@ -101,7 +102,11 @@ static bool radeon_read_bios(struct radeon_device *rdev)
pci_unmap_rom(rdev->pdev, bios);
return false;
}
memcpy_fromio(rdev->bios, bios, size);
//memcpy_fromio(rdev->bios, bios, size);
for(pos = 0;pos < size; pos++){
//memcpy_fromio(rdev->bios+pos,bios+pos,1);
rdev->bios[pos] = __raw_readb(bios+pos);
}
pci_unmap_rom(rdev->pdev, bios);
return true;
}
Expand All @@ -125,7 +130,7 @@ static bool radeon_read_platform_bios(struct radeon_device *rdev)
if (!bios)
goto free_bios;

memcpy_fromio(rdev->bios, bios, romlen);
memcpy_fromio_pcie(rdev->bios, bios, romlen);
iounmap(bios);

if (rdev->bios[0] != 0x55 || rdev->bios[1] != 0xaa)
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/radeon/radeon_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
struct radeon_device *rdev = dev->dev_private;
struct radeon_cs_parser parser;
int r;
INIT_LIST_HEAD(&rdev->move_bo_head);

down_read(&rdev->exclusive_lock);
if (!rdev->accel_working) {
Expand All @@ -676,6 +677,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
r = -EAGAIN;
return r;
}
rdev->trackMoves = true;
/* initialize parser */
memset(&parser, 0, sizeof(struct radeon_cs_parser));
parser.filp = filp;
Expand Down
Loading