Loading drivers/gpu/msm/kgsl.c +12 −0 Original line number Diff line number Diff line Loading @@ -3027,6 +3027,18 @@ static int kgsl_setup_dma_buf(struct kgsl_mem_entry *entry, entry->memdesc.sglen = 0; for (s = entry->memdesc.sg; s != NULL; s = sg_next(s)) { int priv = (entry->memdesc.priv & KGSL_MEMDESC_SECURE) ? 1 : 0; /* * Check that each chunk of of the sg table matches the secure * flag. */ if (PagePrivate(sg_page(s)) != priv) { ret = -EPERM; goto out; } entry->memdesc.size += s->length; entry->memdesc.sglen++; } Loading drivers/gpu/msm/kgsl_sharedmem.c +7 −3 Original line number Diff line number Diff line Loading @@ -924,7 +924,7 @@ int kgsl_cma_alloc_coherent(struct kgsl_device *device, goto err; } result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); result = memdesc_sg_dma(memdesc, memdesc->physaddr, size); if (result) goto err; Loading Loading @@ -1020,7 +1020,7 @@ int kgsl_cma_alloc_secure(struct kgsl_device *device, goto err; } result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); result = memdesc_sg_dma(memdesc, memdesc->physaddr, size); if (result) goto err; Loading @@ -1029,6 +1029,9 @@ int kgsl_cma_alloc_secure(struct kgsl_device *device, if (result != 0) goto err; /* Set the private bit to indicate that we've secured this */ SetPagePrivate(sg_page(memdesc->sg)); memdesc->priv |= KGSL_MEMDESC_TZ_LOCKED; /* Record statistics */ Loading @@ -1051,5 +1054,6 @@ static void kgsl_cma_unlock_secure(struct kgsl_memdesc *memdesc) if (memdesc->size == 0 || !(memdesc->priv & KGSL_MEMDESC_TZ_LOCKED)) return; scm_lock_chunk(memdesc, 0); if (!scm_lock_chunk(memdesc, 0)) ClearPagePrivate(sg_page(memdesc->sg)); } drivers/gpu/msm/kgsl_sharedmem.h +30 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,36 @@ memdesc_sg_phys(struct kgsl_memdesc *memdesc, return 0; } /** * memdesg_sg_dma() - Turn a dma_addr (from CMA) into a sg table * @memdesc: Pointer to the memdesc structure * @addr: Physical address from the dma_alloc function * @size: Size of the chunk * * Create a sg table for the contigious chunk specified by addr and size. */ static inline int memdesc_sg_dma(struct kgsl_memdesc *memdesc, phys_addr_t addr, size_t size) { struct page *page = phys_to_page(addr); memdesc->sg = kgsl_malloc(sizeof(struct scatterlist)); if (memdesc->sg == NULL) return -ENOMEM; sg_set_page(memdesc->sg, page, size, 0); /* * Continuing a grand tradition of doing it wrong this should be the * dma_addr_t and not the phys_addr_t. But everything downstream of us * assume this is a phys_addr_t so we do this. */ sg_dma_address(memdesc->sg) = addr; return 0; } /* * kgsl_memdesc_is_global - is this a globally mapped buffer? * @memdesc: the memdesc Loading Loading
drivers/gpu/msm/kgsl.c +12 −0 Original line number Diff line number Diff line Loading @@ -3027,6 +3027,18 @@ static int kgsl_setup_dma_buf(struct kgsl_mem_entry *entry, entry->memdesc.sglen = 0; for (s = entry->memdesc.sg; s != NULL; s = sg_next(s)) { int priv = (entry->memdesc.priv & KGSL_MEMDESC_SECURE) ? 1 : 0; /* * Check that each chunk of of the sg table matches the secure * flag. */ if (PagePrivate(sg_page(s)) != priv) { ret = -EPERM; goto out; } entry->memdesc.size += s->length; entry->memdesc.sglen++; } Loading
drivers/gpu/msm/kgsl_sharedmem.c +7 −3 Original line number Diff line number Diff line Loading @@ -924,7 +924,7 @@ int kgsl_cma_alloc_coherent(struct kgsl_device *device, goto err; } result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); result = memdesc_sg_dma(memdesc, memdesc->physaddr, size); if (result) goto err; Loading Loading @@ -1020,7 +1020,7 @@ int kgsl_cma_alloc_secure(struct kgsl_device *device, goto err; } result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); result = memdesc_sg_dma(memdesc, memdesc->physaddr, size); if (result) goto err; Loading @@ -1029,6 +1029,9 @@ int kgsl_cma_alloc_secure(struct kgsl_device *device, if (result != 0) goto err; /* Set the private bit to indicate that we've secured this */ SetPagePrivate(sg_page(memdesc->sg)); memdesc->priv |= KGSL_MEMDESC_TZ_LOCKED; /* Record statistics */ Loading @@ -1051,5 +1054,6 @@ static void kgsl_cma_unlock_secure(struct kgsl_memdesc *memdesc) if (memdesc->size == 0 || !(memdesc->priv & KGSL_MEMDESC_TZ_LOCKED)) return; scm_lock_chunk(memdesc, 0); if (!scm_lock_chunk(memdesc, 0)) ClearPagePrivate(sg_page(memdesc->sg)); }
drivers/gpu/msm/kgsl_sharedmem.h +30 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,36 @@ memdesc_sg_phys(struct kgsl_memdesc *memdesc, return 0; } /** * memdesg_sg_dma() - Turn a dma_addr (from CMA) into a sg table * @memdesc: Pointer to the memdesc structure * @addr: Physical address from the dma_alloc function * @size: Size of the chunk * * Create a sg table for the contigious chunk specified by addr and size. */ static inline int memdesc_sg_dma(struct kgsl_memdesc *memdesc, phys_addr_t addr, size_t size) { struct page *page = phys_to_page(addr); memdesc->sg = kgsl_malloc(sizeof(struct scatterlist)); if (memdesc->sg == NULL) return -ENOMEM; sg_set_page(memdesc->sg, page, size, 0); /* * Continuing a grand tradition of doing it wrong this should be the * dma_addr_t and not the phys_addr_t. But everything downstream of us * assume this is a phys_addr_t so we do this. */ sg_dma_address(memdesc->sg) = addr; return 0; } /* * kgsl_memdesc_is_global - is this a globally mapped buffer? * @memdesc: the memdesc Loading