From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: TTM and AGP conflicts Date: Tue, 3 Jan 2012 17:59:34 -0500 Message-ID: <20120103225933.GA14711@phenom.dumpdata.com> References: <20120103224340.GA3026@homer.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by gabe.freedesktop.org (Postfix) with ESMTP id 109D89EB02 for ; Tue, 3 Jan 2012 15:01:15 -0800 (PST) Content-Disposition: inline In-Reply-To: <20120103224340.GA3026@homer.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Jerome Glisse Cc: DRI development list List-Id: dri-devel@lists.freedesktop.org On Tue, Jan 03, 2012 at 05:43:40PM -0500, Jerome Glisse wrote: > On Fri, Dec 23, 2011 at 01:19:43AM +0000, James Simmons wrote: > > = > > > > Hi! > > > > > > > > =A0 =A0 =A0 =A0I updated the openchrome tree and while testing on t= he AGP system > > > > discovered some interesting problems with the new TTM changes. The > > > > problems center around the ttm_tt_[un]populate which I modeled afte= r the > > > > radeon and nouveau driver. > > > > =A0 =A0 =A0 =A0First problem I noticed was on a AGP system that my = ttm_tt_populate > > > > function would oops. Tracking it down I found the problem was the > > > > ttm_agp_tt_create calls ttm_tt_init instead of ttm_dma_tt_init so o= nce my > > > > ttm_tt_populate function would attempt to touch the dma_address it = would > > > > oops. The second issue is the assumption of the cast for struct ttm= _tt in > > > > both the populate and unpopulate function. For the AGP case the pro= per > > > > case would be to ttm_agp_backend. > > > > =A0 =A0 =A0 =A0At this point my assumption is the ttm_bo_move funct= ion has to be > > > > rewritten to handle the AGP case to avoid calling ttm_tt_bind and i= n all > > > > cases ttm_tt_bind needs to be avoided. Looking at the radeon and no= uveau > > > > drivers I don't see that testing happening. Am I just missing somet= hing? > > > = > > > Happens on AGP radeons as well: > > > https://bugs.freedesktop.org/show_bug.cgi?id=3D43719 > > = > > So I'm not crazy, so this needs to be fixed. Here is what my = > > understanding of the TTM layer is. My impression is that struct ttm_bo_= driver > > handles multiple domains, AGP, pcie etc and in each method you have to = > > handle each specific domain you support. Also *move gives the impressio= n of > > moving between these different domains. = > > Where as for struct ttm_backend_func was more for allocating from > > a specific domain. Also I never saw a clear way to handle multiple back= ends. = > > For example my AGP systems can also do pci dma as well. = > = > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/dri-devel > = > Attached is patch to fix this, so sorry about that, i must have lost my > agp change along the way when working on the patchset. This patch is not > extensively tested, i will do more testing tomorrow on more gpu, might > even found an nvidia agp i can try. Again sorry for breaking this. Hey Jerome, Was going to look at this week and see how it performs before (and after) the squash ttm bind+populate operation. Any thoughts of what benchmarks I should run? Fyi, I've some NVidia AGP cards. We both live in Boston so could meet up. And I could ask you about the patches I sent - not clear if you want to me squash the patch 2 and 3 together or just redo them diffrently. > = > Cheers, > Jerome > >From 99a6eee89a43bce155a93ab6d71ea041aac10680 Mon Sep 17 00:00:00 2001 > From: Jerome Glisse > Date: Tue, 3 Jan 2012 17:37:37 -0500 > Subject: [PATCH] ttm: fix agp since ttm tt rework > = > ttm tt rework modified the way we allocate and populate the > ttm_tt structure, the AGP side was missing some bit to properly > work. Fix those and fix radeon and nouveau AGP support. > = > Tested on radeon only so far. > = > Signed-off-by: Jerome Glisse > --- > drivers/gpu/drm/nouveau/nouveau_bo.c | 13 +++++++++++++ > drivers/gpu/drm/radeon/radeon_ttm.c | 11 +++++++++++ > drivers/gpu/drm/ttm/ttm_agp_backend.c | 17 +++++++++++++++++ > drivers/gpu/drm/ttm/ttm_tt.c | 2 ++ > include/drm/ttm/ttm_bo_driver.h | 2 ++ > 5 files changed, 45 insertions(+), 0 deletions(-) > = > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouve= au/nouveau_bo.c > index 8cf4a48..724b41a 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_bo.c > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c > @@ -1066,6 +1066,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) > dev_priv =3D nouveau_bdev(ttm->bdev); > dev =3D dev_priv->dev; > = > +#if __OS_HAS_AGP > + if (dev_priv->gart_info.type =3D=3D NOUVEAU_GART_AGP) { > + return ttm_agp_tt_populate(ttm); > + } > +#endif > + > #ifdef CONFIG_SWIOTLB > if (swiotlb_nr_tbl()) { > return ttm_dma_populate((void *)ttm, dev->dev); > @@ -1105,6 +1111,13 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) > dev_priv =3D nouveau_bdev(ttm->bdev); > dev =3D dev_priv->dev; > = > +#if __OS_HAS_AGP > + if (dev_priv->gart_info.type =3D=3D NOUVEAU_GART_AGP) { > + ttm_agp_tt_unpopulate(ttm); > + return; > + } > +#endif > + > #ifdef CONFIG_SWIOTLB > if (swiotlb_nr_tbl()) { > ttm_dma_unpopulate((void *)ttm, dev->dev); > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon= /radeon_ttm.c > index b0ebaf8..dc73d77 100644 > --- a/drivers/gpu/drm/radeon/radeon_ttm.c > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c > @@ -588,6 +588,11 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) > return 0; > = > rdev =3D radeon_get_rdev(ttm->bdev); > +#if __OS_HAS_AGP > + if (rdev->flags & RADEON_IS_AGP) { > + return ttm_agp_tt_populate(ttm); > + } > +#endif > = > #ifdef CONFIG_SWIOTLB > if (swiotlb_nr_tbl()) { > @@ -624,6 +629,12 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *= ttm) > unsigned i; > = > rdev =3D radeon_get_rdev(ttm->bdev); > +#if __OS_HAS_AGP > + if (rdev->flags & RADEON_IS_AGP) { > + ttm_agp_tt_unpopulate(ttm); > + return; > + } > +#endif > = > #ifdef CONFIG_SWIOTLB > if (swiotlb_nr_tbl()) { > diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/= ttm_agp_backend.c > index 14ebd36..747c141 100644 > --- a/drivers/gpu/drm/ttm/ttm_agp_backend.c > +++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c > @@ -31,6 +31,7 @@ > = > #include "ttm/ttm_module.h" > #include "ttm/ttm_bo_driver.h" > +#include "ttm/ttm_page_alloc.h" > #ifdef TTM_HAS_AGP > #include "ttm/ttm_placement.h" > #include > @@ -97,6 +98,7 @@ static void ttm_agp_destroy(struct ttm_tt *ttm) > = > if (agp_be->mem) > ttm_agp_unbind(ttm); > + ttm_tt_fini(ttm); > kfree(agp_be); > } > = > @@ -129,4 +131,19 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_devic= e *bdev, > } > EXPORT_SYMBOL(ttm_agp_tt_create); > = > +int ttm_agp_tt_populate(struct ttm_tt *ttm) > +{ > + if (ttm->state !=3D tt_unpopulated) > + return 0; > + > + return ttm_pool_populate(ttm); > +} > +EXPORT_SYMBOL(ttm_agp_tt_populate); > + > +void ttm_agp_tt_unpopulate(struct ttm_tt *ttm) > +{ > + ttm_pool_unpopulate(ttm); > +} > +EXPORT_SYMBOL(ttm_agp_tt_unpopulate); > + > #endif > diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c > index 58e1fa1..2f75d20 100644 > --- a/drivers/gpu/drm/ttm/ttm_tt.c > +++ b/drivers/gpu/drm/ttm/ttm_tt.c > @@ -191,6 +191,7 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_dev= ice *bdev, > ttm->page_flags =3D page_flags; > ttm->dummy_read_page =3D dummy_read_page; > ttm->state =3D tt_unpopulated; > + ttm->swap_storage =3D NULL; > = > ttm_tt_alloc_page_directory(ttm); > if (!ttm->pages) { > @@ -222,6 +223,7 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struc= t ttm_bo_device *bdev, > ttm->page_flags =3D page_flags; > ttm->dummy_read_page =3D dummy_read_page; > ttm->state =3D tt_unpopulated; > + ttm->swap_storage =3D NULL; > = > INIT_LIST_HEAD(&ttm_dma->pages_list); > ttm_dma_tt_alloc_page_directory(ttm_dma); > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_dri= ver.h > index 2be8891..d43e892 100644 > --- a/include/drm/ttm/ttm_bo_driver.h > +++ b/include/drm/ttm/ttm_bo_driver.h > @@ -1030,6 +1030,8 @@ extern struct ttm_tt *ttm_agp_tt_create(struct ttm_= bo_device *bdev, > struct agp_bridge_data *bridge, > unsigned long size, uint32_t page_flags, > struct page *dummy_read_page); > +int ttm_agp_tt_populate(struct ttm_tt *ttm); > +void ttm_agp_tt_unpopulate(struct ttm_tt *ttm); > #endif > = > #endif > -- = > 1.7.5.4 > = > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel