Date: Mon, 6 Sep 2010 13:08:15 +0530 From: "Jayachandran C." <c.jayachandran@gmail.com> To: freebsd-mips@freebsd.org Cc: gonzo@freebsd.org Subject: Re: busdma_machdep.c with more than 512M memory Message-ID: <AANLkTim7zDxy9bYYvPT31t-mRB37NPpONsBHhouBPpG_@mail.gmail.com> In-Reply-To: <AANLkTim2gqj=cbgM35rD5oyMD43rWFY1cjyY4A4CoR99@mail.gmail.com> References: <AANLkTimjmpOBOAncY9K9AhCodvp27t=XTQ9qZp4q8%2Bvv@mail.gmail.com> <AANLkTim2gqj=cbgM35rD5oyMD43rWFY1cjyY4A4CoR99@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--0016364d26cb054440048f925db7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 *)*vaddr; >> =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 (void >> *)MIPS_PHYS_TO_KSEG1(vtophys(tmpaddr)); >> =A0637 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 newmap->origbuffe= r =3D *vaddr; >> =A0638 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 newmap->allocbuff= er =3D tmpaddr; >> =A0639 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mips_dcache_wbinv= _range((vm_offset_t)*vaddr, >> =A0640 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dmat->max= size); >> =A0641 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *vaddr =3D tmpadd= r; >> =A0642 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> --- >> 1361 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bpage->busaddr =3D pmap_kextract(bp= age->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_K= SEG1(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. Thanks, JC. --0016364d26cb054440048f925db7 Content-Type: text/x-patch; charset=US-ASCII; name="mips-busdma.patch" Content-Disposition: attachment; filename="mips-busdma.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gdr0q3bx1 SW5kZXg6IHN5cy9taXBzL21pcHMvYnVzZG1hX21hY2hkZXAuYwo9PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMv bWlwcy9taXBzL2J1c2RtYV9tYWNoZGVwLmMJKHJldmlzaW9uIDIxMjI0NykKKysrIHN5cy9taXBz L21pcHMvYnVzZG1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bWFwLT5mbGFncyAmIERNQU1BUF9NQUxMT0NVU0VEKQogCQlmcmVlKHZhZGRyLCBNX0RFVkJVRik7 CiAgICAgICAgIGVsc2UKQEAgLTEzNjAsNyArMTM0OCw3IEBACiAJCX0KIAkJYnBhZ2UtPmJ1c2Fk ZHIgPSBwbWFwX2tleHRyYWN0KGJwYWdlLT52YWRkcik7CiAJCWJwYWdlLT52YWRkcl9ub2NhY2hl ID0gCi0JCSAgICAodm1fb2Zmc2V0X3QpTUlQU19QSFlTX1RPX0tTRUcxKGJwYWdlLT5idXNhZGRy KTsKKwkJICAgICh2bV9vZmZzZXRfdClwbWFwX21hcGRldihicGFnZS0+YnVzYWRkciwgUEFHRV9T SVpFKTsKIAkJbXR4X2xvY2soJmJvdW5jZV9sb2NrKTsKIAkJU1RBSUxRX0lOU0VSVF9UQUlMKCZi ei0+Ym91bmNlX3BhZ2VfbGlzdCwgYnBhZ2UsIGxpbmtzKTsKIAkJdG90YWxfYnBhZ2VzKys7Cg== --0016364d26cb054440048f925db7--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTim7zDxy9bYYvPT31t-mRB37NPpONsBHhouBPpG_>