Date: Sun, 3 Jun 2012 23:48:04 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r236532 - in projects/altix2/sys: conf kern sys Message-ID: <201206032348.q53Nm4Ci092630@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Sun Jun 3 23:48:04 2012 New Revision: 236532 URL: http://svn.freebsd.org/changeset/base/236532 Log: Hook-up and respin the busdma/mi IOMMU interface. In particular, rename busdma_mmu_t to busdma_mtag_t, because its use is for deriving the proper memory allocation restrictions based on the device DMA restrictions and the I/O MMUs involved when doing DMA. Modified: projects/altix2/sys/conf/files projects/altix2/sys/kern/busdma_if.m projects/altix2/sys/kern/subr_busdma.c projects/altix2/sys/sys/busdma.h Modified: projects/altix2/sys/conf/files ============================================================================== --- projects/altix2/sys/conf/files Sun Jun 3 22:40:32 2012 (r236531) +++ projects/altix2/sys/conf/files Sun Jun 3 23:48:04 2012 (r236532) @@ -2505,6 +2505,7 @@ fs/cd9660/cd9660_vfsops.c optional cd966 fs/cd9660/cd9660_vnops.c optional cd9660 fs/cd9660/cd9660_iconv.c optional cd9660_iconv kern/bus_if.m standard +kern/busdma_if.m standard kern/clock_if.m standard kern/cpufreq_if.m standard kern/device_if.m standard Modified: projects/altix2/sys/kern/busdma_if.m ============================================================================== --- projects/altix2/sys/kern/busdma_if.m Sun Jun 3 22:40:32 2012 (r236531) +++ projects/altix2/sys/kern/busdma_if.m Sun Jun 3 23:48:04 2012 (r236532) @@ -31,25 +31,14 @@ INTERFACE busdma; -busdma_mmu_t { - void * cookie; - vm_paddr_t minaddr; - vm_paddr_t maxaddr; - vm_size_t maxsz; - vm_paddr_t align; - vm_paddr_t bndry; -} - -METHOD int iommu_alloc { +METHOD int iommu_xlate { device_t dev; - busdma_md_t md; - busdma_mmu_t *mmu; + busdma_mtag_t mtag; }; METHOD int iommu_map { device_t dev; busdma_md_t md; - busdma_mmu_t *mmu; }; METHOD int iommu_unmap { Modified: projects/altix2/sys/kern/subr_busdma.c ============================================================================== --- projects/altix2/sys/kern/subr_busdma.c Sun Jun 3 22:40:32 2012 (r236531) +++ projects/altix2/sys/kern/subr_busdma.c Sun Jun 3 23:48:04 2012 (r236532) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_kern.h> #include <vm/pmap.h> +#include "busdma_if.h" + struct busdma_tag { struct busdma_tag *dt_chain; struct busdma_tag *dt_child; @@ -357,21 +359,35 @@ busdma_mem_alloc(struct busdma_tag *tag, { struct busdma_md *md; struct busdma_md_seg *seg; + struct busdma_mtag mtag; + device_t bus; vm_size_t maxsz; u_int idx; + int error; md = _busdma_md_create(tag, BUSDMA_MD_FLAG_ALLOCATED); if (md == NULL) return (ENOMEM); + mtag.dmt_minaddr = tag->dt_minaddr; + mtag.dmt_maxaddr = tag->dt_maxaddr; + mtag.dmt_maxsz = tag->dt_maxsegsz; + mtag.dmt_align = tag->dt_align; + mtag.dmt_bndry = tag->dt_bndry; + + bus = device_get_parent(tag->dt_device); + error = BUSDMA_IOMMU_XLATE(bus, &mtag); + if (error) + printf("BUSDMA_IOMMU_XLATE: error=%d\n", error); + idx = 0; maxsz = tag->dt_maxsz; while (maxsz > 0 && idx < tag->dt_nsegs) { seg = &md->md_seg[idx]; - seg->mds_size = MIN(maxsz, tag->dt_maxsegsz); + seg->mds_size = MIN(maxsz, mtag.dmt_maxsz); seg->mds_vaddr = kmem_alloc_contig(kernel_map, seg->mds_size, - 0, tag->dt_minaddr, tag->dt_maxaddr, tag->dt_align, - tag->dt_bndry, VM_MEMATTR_DEFAULT); + 0, mtag.dmt_minaddr, mtag.dmt_maxaddr, mtag.dmt_align, + mtag.dmt_bndry, VM_MEMATTR_DEFAULT); if (seg->mds_vaddr == 0) { /* TODO: try a smaller segment size */ goto fail; @@ -383,6 +399,9 @@ busdma_mem_alloc(struct busdma_tag *tag, } if (maxsz == 0) { md->md_nsegs = idx; + error = BUSDMA_IOMMU_MAP(bus, md); + if (error) + printf("BUSDMA_IOMMU_MAP: error=%d\n", error); _busdma_md_dump(__func__, md); *md_p = md; return (0); @@ -401,11 +420,18 @@ busdma_mem_alloc(struct busdma_tag *tag, int busdma_mem_free(struct busdma_md *md) { + device_t bus; u_int idx; + int error; if ((md->md_flags & BUSDMA_MD_FLAG_ALLOCATED) == 0) return (EINVAL); + bus = device_get_parent(md->md_tag->dt_device); + error = BUSDMA_IOMMU_UNMAP(bus, md); + if (error) + printf("BUSDMA_IOMMU_UNMAP: error=%d\n", error); + for (idx = 0; idx < md->md_nsegs; idx++) kmem_free(kernel_map, md->md_seg[idx].mds_vaddr, md->md_seg[idx].mds_size); Modified: projects/altix2/sys/sys/busdma.h ============================================================================== --- projects/altix2/sys/sys/busdma.h Sun Jun 3 22:40:32 2012 (r236531) +++ projects/altix2/sys/sys/busdma.h Sun Jun 3 23:48:04 2012 (r236532) @@ -37,6 +37,15 @@ typedef struct busdma_tag *busdma_tag_t; struct busdma_md; typedef struct busdma_md *busdma_md_t; +struct busdma_mtag { + vm_paddr_t dmt_minaddr; + vm_paddr_t dmt_maxaddr; + vm_size_t dmt_maxsz; + vm_paddr_t dmt_align; + vm_paddr_t dmt_bndry; +}; +typedef struct busdma_mtag *busdma_mtag_t; + /* * busdma_tag_create * returns: errno value
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206032348.q53Nm4Ci092630>