提交 c3f52220 编写于 作者: M Mikko Perttunen 提交者: Thierry Reding

gpu: host1x: Enable Tegra186 syncpoint protection

Since Tegra186 the Host1x hardware allows syncpoints to be assigned to
specific channels, preventing any other channels from incrementing
them.

Enable this feature where available and assign syncpoints to channels
when submitting a job. Syncpoints are currently never unassigned from
channels since that would require extra work and is unnecessary with
the current channel allocation model.
Signed-off-by: NMikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: NDmitry Osipenko <digetx@gmail.com>
Signed-off-by: NThierry Reding <treding@nvidia.com>
上级 2fb0dceb
...@@ -79,6 +79,9 @@ struct host1x_syncpt_ops { ...@@ -79,6 +79,9 @@ struct host1x_syncpt_ops {
u32 (*load)(struct host1x_syncpt *syncpt); u32 (*load)(struct host1x_syncpt *syncpt);
int (*cpu_incr)(struct host1x_syncpt *syncpt); int (*cpu_incr)(struct host1x_syncpt *syncpt);
int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr); int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
void (*assign_to_channel)(struct host1x_syncpt *syncpt,
struct host1x_channel *channel);
void (*enable_protection)(struct host1x *host);
}; };
struct host1x_intr_ops { struct host1x_intr_ops {
...@@ -186,6 +189,18 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x *host, ...@@ -186,6 +189,18 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x *host,
return host->syncpt_op->patch_wait(sp, patch_addr); return host->syncpt_op->patch_wait(sp, patch_addr);
} }
static inline void host1x_hw_syncpt_assign_to_channel(
struct host1x *host, struct host1x_syncpt *sp,
struct host1x_channel *ch)
{
return host->syncpt_op->assign_to_channel(sp, ch);
}
static inline void host1x_hw_syncpt_enable_protection(struct host1x *host)
{
return host->syncpt_op->enable_protection(host);
}
static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm, static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
void (*syncpt_thresh_work)(struct work_struct *)) void (*syncpt_thresh_work)(struct work_struct *))
{ {
......
...@@ -147,6 +147,8 @@ static int channel_submit(struct host1x_job *job) ...@@ -147,6 +147,8 @@ static int channel_submit(struct host1x_job *job)
syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs); syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs);
host1x_hw_syncpt_assign_to_channel(host, sp, ch);
job->syncpt_end = syncval; job->syncpt_end = syncval;
/* add a setclass for modules that require it */ /* add a setclass for modules that require it */
......
...@@ -106,6 +106,50 @@ static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr) ...@@ -106,6 +106,50 @@ static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr)
return 0; return 0;
} }
/**
* syncpt_assign_to_channel() - Assign syncpoint to channel
* @sp: syncpoint
* @ch: channel
*
* On chips with the syncpoint protection feature (Tegra186+), assign @sp to
* @ch, preventing other channels from incrementing the syncpoints. If @ch is
* NULL, unassigns the syncpoint.
*
* On older chips, do nothing.
*/
static void syncpt_assign_to_channel(struct host1x_syncpt *sp,
struct host1x_channel *ch)
{
#if HOST1X_HW >= 6
struct host1x *host = sp->host;
if (!host->hv_regs)
return;
host1x_sync_writel(host,
HOST1X_SYNC_SYNCPT_CH_APP_CH(ch ? ch->id : 0xff),
HOST1X_SYNC_SYNCPT_CH_APP(sp->id));
#endif
}
/**
* syncpt_enable_protection() - Enable syncpoint protection
* @host: host1x instance
*
* On chips with the syncpoint protection feature (Tegra186+), enable this
* feature. On older chips, do nothing.
*/
static void syncpt_enable_protection(struct host1x *host)
{
#if HOST1X_HW >= 6
if (!host->hv_regs)
return;
host1x_hypervisor_writel(host, HOST1X_HV_SYNCPT_PROT_EN_CH_EN,
HOST1X_HV_SYNCPT_PROT_EN);
#endif
}
static const struct host1x_syncpt_ops host1x_syncpt_ops = { static const struct host1x_syncpt_ops host1x_syncpt_ops = {
.restore = syncpt_restore, .restore = syncpt_restore,
.restore_wait_base = syncpt_restore_wait_base, .restore_wait_base = syncpt_restore_wait_base,
...@@ -113,4 +157,6 @@ static const struct host1x_syncpt_ops host1x_syncpt_ops = { ...@@ -113,4 +157,6 @@ static const struct host1x_syncpt_ops host1x_syncpt_ops = {
.load = syncpt_load, .load = syncpt_load,
.cpu_incr = syncpt_cpu_incr, .cpu_incr = syncpt_cpu_incr,
.patch_wait = syncpt_patch_wait, .patch_wait = syncpt_patch_wait,
.assign_to_channel = syncpt_assign_to_channel,
.enable_protection = syncpt_enable_protection,
}; };
...@@ -398,6 +398,13 @@ int host1x_syncpt_init(struct host1x *host) ...@@ -398,6 +398,13 @@ int host1x_syncpt_init(struct host1x *host)
for (i = 0; i < host->info->nb_pts; i++) { for (i = 0; i < host->info->nb_pts; i++) {
syncpt[i].id = i; syncpt[i].id = i;
syncpt[i].host = host; syncpt[i].host = host;
/*
* Unassign syncpt from channels for purposes of Tegra186
* syncpoint protection. This prevents any channel from
* accessing it until it is reassigned.
*/
host1x_hw_syncpt_assign_to_channel(host, &syncpt[i], NULL);
} }
for (i = 0; i < host->info->nb_bases; i++) for (i = 0; i < host->info->nb_bases; i++)
...@@ -408,6 +415,7 @@ int host1x_syncpt_init(struct host1x *host) ...@@ -408,6 +415,7 @@ int host1x_syncpt_init(struct host1x *host)
host->bases = bases; host->bases = bases;
host1x_syncpt_restore(host); host1x_syncpt_restore(host);
host1x_hw_syncpt_enable_protection(host);
/* Allocate sync point to use for clearing waits for expired fences */ /* Allocate sync point to use for clearing waits for expired fences */
host->nop_sp = host1x_syncpt_alloc(host, NULL, 0); host->nop_sp = host1x_syncpt_alloc(host, NULL, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册