x86 busdma: fix mis-use of bus_addr_t where vm_paddr_t is assumed.
Right now bus_addr_t and vm_paddr_t are always aliased to the same underlying integer type on x86, which makes the interchange hard to detect. Shortly, i386 kernel would use uint64_t for vm_paddr_t to enable automatic use of PAE paging structures if hardware allows it, while bus_addr_t would be extended to 64bit only when PAE option is specified. Fix all places that were identified as using bus_addr_t while page address was assumed. This was performed by testing the complete PAE merging patch on machine with > 4G of RAM enabled. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D18854
This commit is contained in:
parent
f2a496d667
commit
957b9bbf3c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=343146
@ -87,7 +87,7 @@ struct bus_dma_impl {
|
||||
};
|
||||
|
||||
void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
|
||||
int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
|
||||
int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr);
|
||||
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
bus_size_t alignment,
|
||||
bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
|
||||
|
@ -139,7 +139,7 @@ static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages);
|
||||
static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
int commit);
|
||||
static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
vm_offset_t vaddr, bus_addr_t addr1, bus_addr_t addr2, bus_size_t size);
|
||||
vm_offset_t vaddr, vm_paddr_t addr1, vm_paddr_t addr2, bus_size_t size);
|
||||
static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
|
||||
static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
pmap_t pmap, void *buf, bus_size_t buflen, int flags);
|
||||
@ -507,7 +507,7 @@ static void
|
||||
_bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
|
||||
bus_size_t buflen, int flags)
|
||||
{
|
||||
bus_addr_t curaddr;
|
||||
vm_paddr_t curaddr;
|
||||
bus_size_t sgsize;
|
||||
|
||||
if (map != &nobounce_dmamap && map->pagesneeded == 0) {
|
||||
@ -536,7 +536,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
|
||||
{
|
||||
vm_offset_t vaddr;
|
||||
vm_offset_t vendaddr;
|
||||
bus_addr_t paddr;
|
||||
vm_paddr_t paddr;
|
||||
bus_size_t sg_len;
|
||||
|
||||
if (map != &nobounce_dmamap && map->pagesneeded == 0) {
|
||||
@ -643,12 +643,19 @@ _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int flags)
|
||||
* Add a single contiguous physical range to the segment list.
|
||||
*/
|
||||
static int
|
||||
_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
|
||||
_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t curaddr,
|
||||
bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
|
||||
{
|
||||
bus_addr_t baddr, bmask;
|
||||
int seg;
|
||||
|
||||
KASSERT(curaddr <= BUS_SPACE_MAXADDR,
|
||||
("ds_addr %#jx > BUS_SPACE_MAXADDR %#jx; dmat %p fl %#x low %#jx "
|
||||
"hi %#jx",
|
||||
(uintmax_t)curaddr, (uintmax_t)BUS_SPACE_MAXADDR,
|
||||
dmat, dmat->bounce_flags, (uintmax_t)dmat->common.lowaddr,
|
||||
(uintmax_t)dmat->common.highaddr));
|
||||
|
||||
/*
|
||||
* Make sure we don't cross any boundaries.
|
||||
*/
|
||||
@ -695,7 +702,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
int *segp)
|
||||
{
|
||||
bus_size_t sgsize;
|
||||
bus_addr_t curaddr;
|
||||
vm_paddr_t curaddr;
|
||||
int error;
|
||||
|
||||
if (map == NULL)
|
||||
@ -747,7 +754,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
|
||||
int *segp)
|
||||
{
|
||||
bus_size_t sgsize, max_sgsize;
|
||||
bus_addr_t curaddr;
|
||||
vm_paddr_t curaddr;
|
||||
vm_offset_t kvaddr, vaddr;
|
||||
int error;
|
||||
|
||||
@ -1194,7 +1201,7 @@ reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int commit)
|
||||
|
||||
static bus_addr_t
|
||||
add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
||||
bus_addr_t addr1, bus_addr_t addr2, bus_size_t size)
|
||||
vm_paddr_t addr1, vm_paddr_t addr2, bus_size_t size)
|
||||
{
|
||||
struct bounce_zone *bz;
|
||||
struct bounce_page *bpage;
|
||||
|
@ -99,14 +99,15 @@ bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
* to check for a match, if there is no filter callback then assume a match.
|
||||
*/
|
||||
int
|
||||
bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr)
|
||||
bus_dma_run_filter(struct bus_dma_tag_common *tc, vm_paddr_t paddr)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = 0;
|
||||
do {
|
||||
if (((paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
((paddr & (tc->alignment - 1)) != 0)) &&
|
||||
if ((paddr >= BUS_SPACE_MAXADDR ||
|
||||
(paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
(paddr & (tc->alignment - 1)) != 0) &&
|
||||
(tc->filter == NULL ||
|
||||
(*tc->filter)(tc->filterarg, paddr) != 0))
|
||||
retval = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user