Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Sep 2010 12:30:35 +0530
From:      "Jayachandran C." <c.jayachandran@gmail.com>
To:        Neel Natu <neelnatu@gmail.com>
Cc:        gonzo@freebsd.org, freebsd-mips@freebsd.org
Subject:   Re: busdma_machdep.c with more than 512M memory
Message-ID:  <AANLkTimcUdL5gg6e-f3M7QLoMEP93V8TE_9HTzBYPGC8@mail.gmail.com>
In-Reply-To: <AANLkTikOKU8KOaw6aFd1dMqpcZW%2BcMkU72mrDBcUncVq@mail.gmail.com>
References:  <AANLkTimjmpOBOAncY9K9AhCodvp27t=XTQ9qZp4q8%2Bvv@mail.gmail.com> <AANLkTim2gqj=cbgM35rD5oyMD43rWFY1cjyY4A4CoR99@mail.gmail.com> <AANLkTim7zDxy9bYYvPT31t-mRB37NPpONsBHhouBPpG_@mail.gmail.com> <AANLkTikOKU8KOaw6aFd1dMqpcZW%2BcMkU72mrDBcUncVq@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 10, 2010 at 11:22 AM, Neel Natu <neelnatu@gmail.com> wrote:
> Hi JC,
>
> On Mon, Sep 6, 2010 at 12:38 AM, Jayachandran C.
> <c.jayachandran@gmail.com> wrote:
>> On Mon, Sep 6, 2010 at 1:04 PM, Jayachandran C.
>> <c.jayachandran@gmail.com> wrote:
>>> On Wed, Sep 1, 2010 at 12:37 PM, Jayachandran C.
>>> <c.jayachandran@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.
>>>>
>>>>
>>>> ---
>>>> =A0632 =A0 =A0 =A0 =A0 if (newmap->flags & DMAMAP_UNCACHEABLE) {
>>>> =A0633 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 void *tmpaddr =3D (void *)*vadd=
r;
>>>> =A0634
>>>> =A0635 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (tmpaddr) {
>>>> =A0636 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tmpaddr =3D (vo=
id
>>>> *)MIPS_PHYS_TO_KSEG1(vtophys(tmpaddr));
>>>> =A0637 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 newmap->origbuf=
fer =3D *vaddr;
>>>> =A0638 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 newmap->allocbu=
ffer =3D tmpaddr;
>>>> =A0639 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mips_dcache_wbi=
nv_range((vm_offset_t)*vaddr,
>>>> =A0640 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dmat->m=
axsize);
>>>> =A0641 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *vaddr =3D tmpa=
ddr;
>>>> =A0642 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>>>> ---
>>>> 1361 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bpage->busaddr =3D pmap_kextract(=
bpage->vaddr);
>>>> 1362 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bpage->vaddr_nocache =3D
>>>> 1363 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (vm_offset_t)MIPS_PHYS_TO=
_KSEG1(bpage->busaddr);
>>>> 1364 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimcUdL5gg6e-f3M7QLoMEP93V8TE_9HTzBYPGC8>