forked from freebsd/freebsd-src
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of xen_bus_dma_tag_create()
This is a rough implementation of the function. Needs more finishing.
- Loading branch information
Pratyush Yadav
committed
May 25, 2018
1 parent
43c4401
commit 3c94ef4
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,6 +585,61 @@ gnttab_expand(unsigned int req_entries) | |
return (error); | ||
} | ||
|
||
int | ||
xen_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, | ||
bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, | ||
bus_dma_filter_t *filtfunc, void *filtfuncarg, bus_size_t maxsize, | ||
int nsegments, bus_size_t maxsegsz, int flags, | ||
bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat, | ||
grant_ref_t **refs) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
domid_t domid; | ||
int i, j, error; | ||
|
||
if (maxsegsz < PAGE_SIZE) { | ||
return (EINVAL); | ||
} | ||
|
||
domid = flags >> 16; | ||
flags &= 0xffff; | ||
|
||
/* Allocate a new dma tag. */ | ||
error = bus_dma_tag_create(parent, alignment, boundary, lowaddr, highaddr, | ||
filtfunc, filterarg, maxsize, nsegments, maxsegsz, flags, lockfunc, | ||
lockfuncarg, dmat); | ||
if (error) { | ||
return error; | ||
} | ||
|
||
/* Allocate the grant references for each segment. */ | ||
*refs = malloc(nsegments*sizeof(grant_ref_t), M_DEVBUF, M_NOWAIT); | ||
if((*refs) == NULL) { | ||
bus_dma_tag_destroy(dmat); | ||
return (ENOMEM); | ||
} | ||
|
||
/* | ||
* Create entries in the grant table for each segment. The frame number is set | ||
* to 0 for now. It will be updated when the dma map is loaded. | ||
*/ | ||
for (i = 0; i < nsegments; i++) { | ||
error = gnttab_grant_foreign_access(domid, 0, 0, (*refs[i])); | ||
This comment has been minimized.
Sorry, something went wrong.
royger
|
||
if (error) { | ||
for (j = 0; j <= i; j++) { | ||
gnttab_end_foreign_access_ref((*refs[j])); | ||
free(*refs); | ||
*refs = NULL; | ||
This comment has been minimized.
Sorry, something went wrong.
royger
|
||
bus_dma_tag_destroy(dmat); | ||
return error; | ||
} | ||
} | ||
} | ||
|
||
/* XXX Leaving cleaning up the refs array to the caller. Is it ok? */ | ||
|
||
return 0; | ||
} | ||
|
||
static void | ||
xen_bus_dmamap_load_callback(void *callback_arg, bus_dma_segment_t | ||
*segs, int nseg, int error) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This extra 'refs' parameter is not part of the current busdma interface:
bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
bus_dma_filter_t *filtfunc, void *filtfuncarg, bus_size_t maxsize,
int nsegments, bus_size_t maxsegsz, int flags,
bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat);
Are you planning to modify the busdma interface in order to add a new parameter?
IMO the Xen specific data should be hidden in bus_dma_tag_t.