Skip to content

Instantly share code, notes, and snippets.

@ntrippar
Created May 23, 2017 00:21
Show Gist options
  • Select an option

  • Save ntrippar/bdd5662e1116d8cd39bd582878ec60df to your computer and use it in GitHub Desktop.

Select an option

Save ntrippar/bdd5662e1116d8cd39bd582878ec60df to your computer and use it in GitHub Desktop.
NDAY-2017-0106
static int nvhost_init_error_notifier(struct nvhost_channel *ch,
struct nvhost_set_error_notifier *args) {
void *va;
struct dma_buf *dmabuf;
if (!args->mem) {
dev_err(&ch->dev->dev, "invalid memory handle\n");
return -EINVAL;
}
dmabuf = dma_buf_get(args->mem);
if (ch->error_notifier_ref)
nvhost_free_error_notifiers(ch);
if (IS_ERR(dmabuf)) {
dev_err(&ch->dev->dev, "Invalid handle: %d\n", args->mem);
return -EINVAL;
}
/* map handle */
va = dma_buf_vmap(dmabuf);
if (!va) {
dma_buf_put(dmabuf);
dev_err(&ch->dev->dev, "Cannot map notifier handle\n");
return -ENOMEM;
}
/* set channel notifiers pointer */
ch->error_notifier_ref = dmabuf;
ch->error_notifier = va + args->offset;
ch->error_notifier_va = va;
memset(ch->error_notifier, 0, sizeof(struct nvhost_notification));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment