diff --git a/drivers/gpu/host1x-emu/ioctl.c b/drivers/gpu/host1x-emu/ioctl.c index c018dfa3..599d1693 100644 --- a/drivers/gpu/host1x-emu/ioctl.c +++ b/drivers/gpu/host1x-emu/ioctl.c @@ -218,19 +218,27 @@ static int host1x_ioctl_syncpoint_wait( struct host1x_emu_ctrl_syncpt_wait_args *args) { - signed long timeout_jiffies; - struct host1x_syncpt *sp; - struct host1x *host = ctx->host; + signed long timeout_jiffies; + struct host1x_syncpt *sp; + struct host1x *host = ctx->host; + ktime_t ts; + int err; - sp = HOST1X_EMU_EXPORT_CALL(host1x_syncpt_get_by_id_noref(host, args->id)); - if (!sp) - return -EINVAL; - timeout_jiffies = timeout_abs_to_jiffies(args->timeout_ns); + sp = HOST1X_EMU_EXPORT_CALL(host1x_syncpt_get_by_id_noref(host, args->id)); + if (!sp) + return -EINVAL; - return HOST1X_EMU_EXPORT_CALL(host1x_syncpt_wait(sp, - args->threshold, - timeout_jiffies, - &args->value)); + timeout_jiffies = timeout_abs_to_jiffies(args->timeout_ns); + err = HOST1X_EMU_EXPORT_CALL(host1x_syncpt_wait_ts(sp, + args->threshold, + timeout_jiffies, + &args->value, + &ts)); + if (err) + return err; + + args->timestamp = ktime_to_ns(ts); + return 0; } static long host1x_ctrlctl(struct file *filp, unsigned int cmd, unsigned long arg) diff --git a/drivers/gpu/host1x-emu/nvhost.c b/drivers/gpu/host1x-emu/nvhost.c index cbfaf57a..ee1a5a0a 100644 --- a/drivers/gpu/host1x-emu/nvhost.c +++ b/drivers/gpu/host1x-emu/nvhost.c @@ -392,16 +392,25 @@ HOST1X_EMU_EXPORT_SYMBOL(nvhost_syncpt_incr_max_ext); HOST1X_EMU_EXPORT_DECL(u32, nvhost_syncpt_unit_interface_get_byte_offset_ext(struct platform_device *pdev, u32 syncpt_id)) { - struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct platform_device *host1x_pdev; + struct host1x *host1x; - if (WARN_ON(!pdata)) - return 0; - if (syncpt_id >= pdata->host1x->syncpt_count) { - pr_info("Invalid syncpoint ID!\n"); - return 0; - } + host1x_pdev = HOST1X_EMU_EXPORT_CALL(nvhost_get_default_device()); + if (WARN_ON(!host1x_pdev)) + return 0; - return syncpt_id * pdata->host1x->syncpt_page_size; + host1x = platform_get_drvdata(host1x_pdev); + if (!host1x) { + pr_info("No platform data for host1x!\n"); + return 0; + } + + if (syncpt_id >= host1x->syncpt_count) { + pr_info("Invalid syncpoint ID!\n"); + return 0; + } + + return syncpt_id * host1x->syncpt_page_size; } HOST1X_EMU_EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_byte_offset_ext); @@ -431,11 +440,22 @@ HOST1X_EMU_EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_byte_offset); HOST1X_EMU_EXPORT_DECL(int, nvhost_syncpt_unit_interface_get_aperture(struct platform_device *pdev, u64 *base, size_t *size)) { - struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct platform_device *host1x_pdev; + struct host1x *host1x; - *base = pdata->host1x->syncpt_phy_apt; - *size = pdata->host1x->syncpt_page_size * pdata->host1x->syncpt_count; - return 0; + host1x_pdev = HOST1X_EMU_EXPORT_CALL(nvhost_get_default_device()); + if (WARN_ON(!host1x_pdev)) + return 0; + + host1x = platform_get_drvdata(host1x_pdev); + if (!host1x) { + pr_info("No platform data for host1x!\n"); + return 0; + } + + *base = host1x->syncpt_phy_apt; + *size = host1x->syncpt_page_size * host1x->syncpt_count; + return 0; } HOST1X_EMU_EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_aperture); diff --git a/drivers/gpu/host1x-emu/syncpt.c b/drivers/gpu/host1x-emu/syncpt.c index 39b27d72..82d369cc 100644 --- a/drivers/gpu/host1x-emu/syncpt.c +++ b/drivers/gpu/host1x-emu/syncpt.c @@ -313,20 +313,21 @@ HOST1X_EMU_EXPORT_DECL(struct host1x_syncpt*, host1x_syncpt_alloc(struct host1x * TODO: Optimize syncpoint allocation, serial allocation * dosen't effectively utilize per pool polling thread. */ - for (i = host->syncpt_base; i < host->syncpt_end; i++, sp++) { + /* FIXME: WAR to allocate syncpoint from index 1, As at client level synpt-id 0 is invalid*/ + for (i = host->syncpt_base + 1; i < host->syncpt_end; i++, sp++) { - /* Do pool verification if pool selected */ - if ((pool != NULL) && (sp->pool != pool)) - continue; + /* Do pool verification if pool selected */ + if ((pool != NULL) && (sp->pool != pool)) + continue; - /* Skip if pool is read only pool */ - if (sp->pool == &host->pools[host->ro_pool_id]) - continue; + /* Skip if pool is read only pool */ + if (sp->pool == &host->pools[host->ro_pool_id]) + continue; - if (kref_read(&sp->ref) == 0) { - break; - } - } + if (kref_read(&sp->ref) == 0) { + break; + } + } if (i >= host->syncpt_end) { goto unlock;