gpu: nvgpu: support kernel-3.10 version

Make necessary changes to support nvgpu on kernel-3.10

This includes below changes
- PROBE_PREFER_ASYNCHRONOUS is defined only for K3.10
- Fence handling and struct sync_fence is different between
  K3.10 and K3.18
- variable status in struct sync_fence is atomic on K3.18
  whereas it is int on K3.10
- if SOC == T132, set soc_name = "tegra13x"
- ioremap_cache() is not defined on K3.10 ARM versions,
  hence use ioremap_cached()

Bug 200188753

Change-Id: I18d77eb1404e15054e8510d67c9a61c0f1883e2b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1121092
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Deepak Nibade
2016-04-06 16:03:44 +05:30
committed by Terje Bergstrom
parent d369dca4ac
commit b6dc4315a4
6 changed files with 54 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
*/
#include <linux/gk20a.h>
#include <linux/version.h>
#include "channel_sync_gk20a.h"
#include "gk20a.h"
@@ -93,10 +94,12 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
int i;
int num_wait_cmds;
struct sync_fence *sync_fence;
struct sync_pt *pt;
struct priv_cmd_entry *wait_cmd = NULL;
struct gk20a_channel_syncpt *sp =
container_of(s, struct gk20a_channel_syncpt, ops);
struct channel_gk20a *c = sp->c;
u32 wait_id;
int err = 0;
sync_fence = nvhost_sync_fdget(fd);
@@ -104,9 +107,13 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
return -EINVAL;
/* validate syncpt ids */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
list_for_each_entry(pt, &sync_fence->pt_list_head, pt_list) {
#else
for (i = 0; i < sync_fence->num_fences; i++) {
struct sync_pt *pt = sync_pt_from_fence(sync_fence->cbs[i].sync_pt);
u32 wait_id = nvhost_sync_pt_id(pt);
pt = sync_pt_from_fence(sync_fence->cbs[i].sync_pt);
#endif
wait_id = nvhost_sync_pt_id(pt);
if (!wait_id || !nvhost_syncpt_is_valid_pt_ext(sp->host1x_pdev,
wait_id)) {
sync_fence_put(sync_fence);
@@ -129,9 +136,13 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
}
i = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
list_for_each_entry(pt, &sync_fence->pt_list_head, pt_list) {
#else
for (i = 0; i < sync_fence->num_fences; i++) {
struct fence *f = sync_fence->cbs[i].sync_pt;
struct sync_pt *pt = sync_pt_from_fence(f);
#endif
u32 wait_id = nvhost_sync_pt_id(pt);
u32 wait_value = nvhost_sync_pt_thresh(pt);
@@ -144,6 +155,9 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd,
} else
add_wait_cmd(&wait_cmd->ptr[i * 4], wait_id,
wait_value);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
i++;
#endif
}
WARN_ON(i != num_wait_cmds);
sync_fence_put(sync_fence);

View File

@@ -15,6 +15,7 @@
#include <linux/gk20a.h>
#include <linux/file.h>
#include <linux/version.h>
#include "gk20a.h"
#include "semaphore_gk20a.h"
@@ -153,10 +154,17 @@ struct gk20a_fence *gk20a_fence_from_semaphore(
struct sync_fence *sync_fence = NULL;
#ifdef CONFIG_SYNC
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
sync_fence = gk20a_sync_fence_create(timeline, semaphore,
dependency, "f-gk20a-0x%04llx",
((uintptr_t)(void *)semaphore->value) &
0xffff);
#else
sync_fence = gk20a_sync_fence_create(timeline, semaphore,
dependency, "f-gk20a-0x%04llx",
((u64)(void *)semaphore->value) &
0xffff);
#endif
if (!sync_fence)
return NULL;
#endif

View File

@@ -43,6 +43,7 @@
#include <linux/reset.h>
#include <linux/sched.h>
#include <linux/version.h>
#include "gk20a.h"
#include "debug_gk20a.h"
@@ -1667,7 +1668,9 @@ static struct platform_driver gk20a_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "gk20a",
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
#endif
#ifdef CONFIG_OF
.of_match_table = tegra_gk20a_of_match,
#endif

View File

@@ -770,6 +770,9 @@ static int gk20a_tegra_probe(struct device *dev)
}
}
if (tegra_get_chipid() == TEGRA_CHIPID_TEGRA13)
platform->soc_name = "tegra13x";
gk20a_tegra_get_clocks(dev);
return 0;

View File

@@ -15,6 +15,7 @@
#include "sync_gk20a.h"
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/file.h>
#include <linux/fs.h>
@@ -149,7 +150,11 @@ static struct gk20a_sync_pt *gk20a_sync_pt_create_shared(
/* Store the dependency fence for this pt. */
if (dependency) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
if (dependency->status == 0) {
#else
if (!atomic_read(&dependency->status)) {
#endif
shared->dep = dependency;
} else {
shared->dep_timestamp = ktime_get();
@@ -214,6 +219,9 @@ static int gk20a_sync_pt_has_signaled(struct sync_pt *sync_pt)
{
struct gk20a_sync_pt *pt = to_gk20a_sync_pt(sync_pt);
struct gk20a_sync_timeline *obj = pt->obj;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
struct sync_pt *pos;
#endif
bool signaled = true;
spin_lock(&pt->lock);
@@ -233,6 +241,12 @@ static int gk20a_sync_pt_has_signaled(struct sync_pt *sync_pt)
* first.*/
if (pt->dep) {
s64 ns = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
struct list_head *dep_pts = &pt->dep->pt_list_head;
list_for_each_entry(pos, dep_pts, pt_list) {
ns = max(ns, ktime_to_ns(pos->timestamp));
}
#else
struct fence *fence;
int i;
@@ -240,6 +254,7 @@ static int gk20a_sync_pt_has_signaled(struct sync_pt *sync_pt)
fence = pt->dep->cbs[i].sync_pt;
ns = max(ns, ktime_to_ns(fence->timestamp));
}
#endif
pt->dep_timestamp = ns_to_ktime(ns);
sync_fence_put(pt->dep);
pt->dep = NULL;
@@ -260,7 +275,11 @@ static inline ktime_t gk20a_sync_pt_duration(struct sync_pt *sync_pt)
struct gk20a_sync_pt *pt = to_gk20a_sync_pt(sync_pt);
if (!gk20a_sync_pt_has_signaled(sync_pt) || !pt->dep_timestamp.tv64)
return ns_to_ktime(0);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
return ktime_sub(sync_pt->timestamp, pt->dep_timestamp);
#else
return ktime_sub(sync_pt->base.timestamp, pt->dep_timestamp);
#endif
}
static int gk20a_sync_pt_compare(struct sync_pt *a, struct sync_pt *b)

View File

@@ -14,6 +14,7 @@
#include <linux/string.h>
#include <linux/tegra-ivc.h>
#include <linux/tegra_vgpu.h>
#include <linux/version.h>
#include "gk20a/gk20a.h"
#include "gk20a/ctxsw_trace_gk20a.h"
@@ -61,7 +62,11 @@ static int vgpu_fecs_trace_init(struct gk20a *g)
goto fail;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
vcst->buf = ioremap_cached(vcst->cookie->ipa, vcst->cookie->size);
#else
vcst->buf = ioremap_cache(vcst->cookie->ipa, vcst->cookie->size);
#endif
if (!vcst->buf) {
dev_info(dev_from_gk20a(g), "ioremap_cache failed\n");
err = -EINVAL;