busdma_machdep.c with more than 512M memory

Jayachandran C. c.jayachandran at gmail.com
Fri Sep 10 07:00:37 UTC 2010


On Fri, Sep 10, 2010 at 11:22 AM, Neel Natu <neelnatu at gmail.com> wrote:
> Hi JC,
>
> On Mon, Sep 6, 2010 at 12:38 AM, Jayachandran C.
> <c.jayachandran at gmail.com> wrote:
>> On Mon, Sep 6, 2010 at 1:04 PM, Jayachandran C.
>> <c.jayachandran at gmail.com> wrote:
>>> On Wed, Sep 1, 2010 at 12:37 PM, Jayachandran C.
>>> <c.jayachandran at gmail.com> wrote:
>>>> I was looking at a few crashes I see with PCI drivers, and I think it
>>>> is caused by an issue in busdma_machdep.c where physical address is
>>>> directly converted using MIPS_PHYS_TO_KSEG1. I have not looked at it
>>>> in detail, but it looks obviously wrong.
>>>>
>>>> Any suggestions on how to fix thiis is welcome, it probably needs an
>>>> uncached TLB entry. On 64bit we could use XKPHYS uncached.
>>>>
>>>>
>>>> ---
>>>>  632         if (newmap->flags & DMAMAP_UNCACHEABLE) {
>>>>  633                 void *tmpaddr = (void *)*vaddr;
>>>>  634
>>>>  635                 if (tmpaddr) {
>>>>  636                         tmpaddr = (void
>>>> *)MIPS_PHYS_TO_KSEG1(vtophys(tmpaddr));
>>>>  637                         newmap->origbuffer = *vaddr;
>>>>  638                         newmap->allocbuffer = tmpaddr;
>>>>  639                         mips_dcache_wbinv_range((vm_offset_t)*vaddr,
>>>>  640                             dmat->maxsize);
>>>>  641                         *vaddr = tmpaddr;
>>>>  642                 }
>>>> ---
>>>> 1361                 bpage->busaddr = pmap_kextract(bpage->vaddr);
>>>> 1362                 bpage->vaddr_nocache =
>>>> 1363                     (vm_offset_t)MIPS_PHYS_TO_KSEG1(bpage->busaddr);
>>>> 1364                 mtx_lock(&bounce_lock);
>>>
>>> Based on Juli's suggestion, I have a patch (attached) to switch the
>>> calls to pmap_mapdev/pmap_unmapdev.
>>>
>>> Seems to work for me now, please review.
>>
>> That was an older version of the patch, here is the correct version.
>>
>
> This assumes that pmap_mapdev() always returns an uncached mapping
> which is true for n64 kernels but not for o32 kernels with memory
> beyond 512MB.

I think my original patch was incorrect, pmap_mapdev() should not be
used to map physical memory uncached. It may be just for mapping
device address space uncached, and that may be why it checks if the
physical address is cacheable.

> Any objections if I commit the following patch that makes
> pmap_mapdev() always return an uncached mapping.

I think we should remove the usage of pmap_mapdev() in busdma and just
use your new pmap_kenter_attr() there, which I think would make it
clear.

Thanks,
JC.


More information about the freebsd-mips mailing list