Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux drm: Destroy dma map in sg_table...
details: https://anonhg.NetBSD.org/src/rev/97671d2687fa
branches: trunk
changeset: 1028838:97671d2687fa
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 12:10:42 2021 +0000
description:
drm: Destroy dma map in sg_table_free.
Helps to reduce a little diff.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c | 15 ++++++---------
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c | 12 ++++++------
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c | 11 +++--------
sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c | 15 +++++++++------
sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c | 10 ++--------
sys/external/bsd/drm2/include/linux/scatterlist.h | 3 ++-
sys/external/bsd/drm2/linux/linux_sgt.c | 10 +++++++---
7 files changed, 35 insertions(+), 41 deletions(-)
diffs (276 lines):
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_phys.c,v 1.6 2021/12/19 12:10:20 riastradh Exp $ */
+/* $NetBSD: i915_gem_phys.c,v 1.7 2021/12/19 12:10:42 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.6 2021/12/19 12:10:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.7 2021/12/19 12:10:42 riastradh Exp $");
#include <linux/highmem.h>
#include <linux/shmem_fs.h>
@@ -91,8 +91,11 @@
ret = -bus_dmamap_create(dmat, roundup_pow_of_two(obj->base.size), 1,
roundup_pow_of_two(obj->base.size), 0, BUS_DMA_WAITOK,
&sg->sg_dmamap);
- if (ret)
+ if (ret) {
+ sg->sg_dmamap = NULL;
goto err_st1;
+ }
+ sg->sg_dmat = dmat;
/* XXX errno NetBSD->Linux */
ret = -bus_dmamap_load_raw(dmat, sg->sg_dmamap, &obj->mm.u.phys.seg, 1,
roundup_pow_of_two(obj->base.size), BUS_DMA_WAITOK);
@@ -140,10 +143,6 @@
err_st1:
if (loaded)
bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
- if (st->sgl->sg_dmamap) {
- bus_dmamap_destroy(dmat, st->sgl->sg_dmamap);
- st->sgl->sg_dmamap = NULL;
- }
sg_free_table(st);
#endif
err_st:
@@ -219,8 +218,6 @@
#ifdef __NetBSD__
bus_dmamap_unload(dmat, pages->sgl->sg_dmamap);
- bus_dmamap_destroy(dmat, pages->sgl->sg_dmamap);
- pages->sgl->sg_dmamap = NULL;
#endif
sg_free_table(pages);
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_region.c,v 1.3 2021/12/19 11:33:49 riastradh Exp $ */
+/* $NetBSD: i915_gem_region.c,v 1.4 2021/12/19 12:10:42 riastradh Exp $ */
// SPDX-License-Identifier: MIT
/*
@@ -6,7 +6,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.3 2021/12/19 11:33:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.4 2021/12/19 12:10:42 riastradh Exp $");
#include "intel_memory_region.h"
#include "i915_gem_region.h"
@@ -22,7 +22,6 @@
obj->mm.dirty = false;
#ifdef __NetBSD__
bus_dmamap_unload(obj->base.dev->dmat, pages->sgl->sg_dmamap);
- bus_dmamap_destroy(obj->base.dev->dmat, pages->sgl->sg_dmamap);
#endif
sg_free_table(pages);
kfree(pages);
@@ -91,8 +90,11 @@
/* XXX errno NetBSD->Linux */
ret = -bus_dmamap_create(dmat, size, nsegs, size, 0, BUS_DMA_WAITOK,
&sg->sg_dmamap);
- if (ret)
+ if (ret) {
+ sg->sg_dmamap = NULL;
goto err;
+ }
+ sg->sg_dmat = dmat;
/* XXX errno NetBSD->Linux */
ret = -bus_dmamap_load_raw(dmat, sg->sg_dmamap, segs, nsegs, size,
@@ -153,8 +155,6 @@
err:
if (loaded)
bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
- if (st->sgl->sg_dmamap)
- bus_dmamap_destroy(dmat, st->sgl->sg_dmamap);
if (segs)
kmem_free(segs, nsegs * sizeof(segs[0]));
__intel_memory_region_put_pages_buddy(mem, blocks);
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_stolen.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $ */
+/* $NetBSD: i915_gem_stolen.c,v 1.5 2021/12/19 12:10:42 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.5 2021/12/19 12:10:42 riastradh Exp $");
#include <linux/errno.h>
#include <linux/mutex.h>
@@ -557,6 +557,7 @@
st->sgl->sg_dmamap = NULL;
goto out;
}
+ st->sgl->sg_dmat = dmat;
/* XXX errno NetBSD->Liux */
ret = -bus_dmamap_load_raw(dmat, st->sgl->sg_dmamap, seg, nseg, size,
@@ -571,10 +572,6 @@
out: if (ret) {
if (loaded)
bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
- if (st->sgl->sg_dmamap) {
- bus_dmamap_destroy(dmat, st->sgl->sg_dmamap);
- st->sgl->sg_dmamap = NULL;
- }
sg_free_table(st);
kfree(st);
return ERR_PTR(ret);
@@ -611,8 +608,6 @@
/* Should only be called from i915_gem_object_release_stolen() */
#ifdef __NetBSD__
bus_dmamap_unload(obj->base.dev->dmat, pages->sgl->sg_dmamap);
- bus_dmamap_destroy(obj->base.dev->dmat, pages->sgl->sg_dmamap);
- pages->sgl->sg_dmamap = NULL;
#endif
sg_free_table(pages);
kfree(pages);
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_ggtt.c,v 1.10 2021/12/19 12:10:07 riastradh Exp $ */
+/* $NetBSD: intel_ggtt.c,v 1.11 2021/12/19 12:10:42 riastradh Exp $ */
// SPDX-License-Identifier: MIT
/*
@@ -6,7 +6,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_ggtt.c,v 1.10 2021/12/19 12:10:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_ggtt.c,v 1.11 2021/12/19 12:10:42 riastradh Exp $");
#include <linux/stop_machine.h>
@@ -1631,8 +1631,11 @@
(bus_size_t)view->partial.size << PAGE_SHIFT,
view->partial.size, PAGE_SIZE, 0, BUS_DMA_NOWAIT,
&st->sgl->sg_dmamap);
- if (ret)
+ if (ret) {
+ st->sgl->sg_dmamap = NULL;
goto fail;
+ }
+ st->sgl->sg_dmat = obj->base.dev->dmat;
}
/*
@@ -1669,10 +1672,10 @@
/* Success! */
return st;
-fail: if (st->sgl->sg_dmamap)
- bus_dmamap_destroy(obj->base.dev->dmat, st->sgl->sg_dmamap);
- if (st)
+fail: if (st) {
+ sg_free_table(st);
kfree(st);
+ }
return ERR_PTR(ret);
#else
struct sg_table *st;
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_gtt.c,v 1.8 2021/12/19 12:10:07 riastradh Exp $ */
+/* $NetBSD: intel_gtt.c,v 1.9 2021/12/19 12:10:42 riastradh Exp $ */
// SPDX-License-Identifier: MIT
/*
@@ -6,7 +6,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.8 2021/12/19 12:10:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.9 2021/12/19 12:10:42 riastradh Exp $");
#include <linux/slab.h> /* fault-inject.h is not standalone! */
@@ -268,12 +268,6 @@
GEM_BUG_ON(!vma->pages);
if (vma->pages != vma->obj->mm.pages) {
-#ifdef __NetBSD__
- if (vma->pages->sgl->sg_dmamap) {
- bus_dma_tag_t dmat = vma->obj->base.dev->dmat;
- bus_dmamap_destroy(dmat, vma->pages->sgl->sg_dmamap);
- }
-#endif
sg_free_table(vma->pages);
kfree(vma->pages);
}
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/include/linux/scatterlist.h
--- a/sys/external/bsd/drm2/include/linux/scatterlist.h Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/scatterlist.h Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scatterlist.h,v 1.6 2021/12/19 11:38:04 riastradh Exp $ */
+/* $NetBSD: scatterlist.h,v 1.7 2021/12/19 12:10:42 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@
struct scatterlist {
struct page **sg_pgs;
unsigned sg_npgs;
+ bus_dma_tag_t sg_dmat;
bus_dmamap_t sg_dmamap;
} sgl[1];
unsigned nents;
diff -r 403327921a65 -r 97671d2687fa sys/external/bsd/drm2/linux/linux_sgt.c
--- a/sys/external/bsd/drm2/linux/linux_sgt.c Sun Dec 19 12:10:34 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_sgt.c Sun Dec 19 12:10:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sgt.c,v 1.2 2021/12/19 12:10:14 riastradh Exp $ */
+/* $NetBSD: linux_sgt.c,v 1.3 2021/12/19 12:10:42 riastradh Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sgt.c,v 1.2 2021/12/19 12:10:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sgt.c,v 1.3 2021/12/19 12:10:42 riastradh Exp $");
#include <sys/bus.h>
#include <sys/errno.h>
@@ -128,7 +128,10 @@
sg_free_table(struct sg_table *sgt)
{
- KASSERT(sgt->sgl->sg_dmamap == NULL);
+ if (sgt->sgl->sg_dmamap) {
+ KASSERT(sgt->sgl->sg_dmat);
+ bus_dmamap_destroy(sgt->sgl->sg_dmat, sgt->sgl->sg_dmamap);
+ }
kfree(sgt->sgl->sg_pgs);
sgt->sgl->sg_pgs = NULL;
sgt->sgl->sg_npgs = 0;
@@ -182,6 +185,7 @@
/* Success! */
KASSERT(sg->sg_dmamap->dm_nsegs > 0);
KASSERT(sg->sg_dmamap->dm_nsegs <= nents);
+ sg->sg_dmat = dmat;
ret = sg->sg_dmamap->dm_nsegs;
error = 0;
Home |
Main Index |
Thread Index |
Old Index