From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Stach Subject: Re: [PATCH 3/4] drm/nouveau: hook up cache sync functions Date: Mon, 19 May 2014 11:44:56 +0200 Message-ID: <1400492696.8467.21.camel@weser.hi.pengutronix.de> References: <1400483458-9648-1-git-send-email-acourbot@nvidia.com> <1400483458-9648-4-git-send-email-acourbot@nvidia.com> <20140519084620.GB7138@ulmo> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140519084620.GB7138@ulmo> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: nouveau-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "Nouveau" To: Thierry Reding Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Ben Skeggs , linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-tegra@vger.kernel.org Am Montag, den 19.05.2014, 10:46 +0200 schrieb Thierry Reding: > On Mon, May 19, 2014 at 04:10:57PM +0900, Alexandre Courbot wrote: > > From: Lucas Stach > > > > Signed-off-by: Lucas Stach > > [acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org: make conditional and platform-friendly] > > Signed-off-by: Alexandre Courbot > > Perhaps having a propery commit message here would be good. > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c > [...] > > +#ifdef NOUVEAU_NEED_CACHE_SYNC > > +void > > +nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo) > > +{ > > + struct nouveau_device *device; > > + struct ttm_tt *ttm = nvbo->bo.ttm; > > + > > + device = nouveau_dev(nouveau_bdev(ttm->bdev)->dev); > > + > > + if (nvbo->bo.ttm && nvbo->bo.ttm->caching_state == tt_cached) > > + ttm_dma_tt_cache_sync_for_cpu((struct ttm_dma_tt *)nvbo->bo.ttm, > > + nv_device_base(device)); > > Can we be certain at this point that the struct ttm_tt is in fact a > struct ttm_dma_tt? Yes, for all cases except AGP, where things are mapped WC anyways (so caching_state is always != cached) nouveau_bo_driver uses nouveau_ttm_tt_create() as its ttm_tt_create callback. This in turn calls nouveau_sgdma_create_ttm() which uses ttm_dma_tt_init() unconditionally. Regards, Lucas -- Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754020AbaESJqN (ORCPT ); Mon, 19 May 2014 05:46:13 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:52033 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752667AbaESJqM (ORCPT ); Mon, 19 May 2014 05:46:12 -0400 Message-ID: <1400492696.8467.21.camel@weser.hi.pengutronix.de> Subject: Re: [PATCH 3/4] drm/nouveau: hook up cache sync functions From: Lucas Stach To: Thierry Reding Cc: Alexandre Courbot , gnurou@gmail.com, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Ben Skeggs , linux-tegra@vger.kernel.org Date: Mon, 19 May 2014 11:44:56 +0200 In-Reply-To: <20140519084620.GB7138@ulmo> References: <1400483458-9648-1-git-send-email-acourbot@nvidia.com> <1400483458-9648-4-git-send-email-acourbot@nvidia.com> <20140519084620.GB7138@ulmo> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5-2+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:6f8:1178:2:fa0f:41ff:fe58:4010 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Montag, den 19.05.2014, 10:46 +0200 schrieb Thierry Reding: > On Mon, May 19, 2014 at 04:10:57PM +0900, Alexandre Courbot wrote: > > From: Lucas Stach > > > > Signed-off-by: Lucas Stach > > [acourbot@nvidia.com: make conditional and platform-friendly] > > Signed-off-by: Alexandre Courbot > > Perhaps having a propery commit message here would be good. > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c > [...] > > +#ifdef NOUVEAU_NEED_CACHE_SYNC > > +void > > +nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo) > > +{ > > + struct nouveau_device *device; > > + struct ttm_tt *ttm = nvbo->bo.ttm; > > + > > + device = nouveau_dev(nouveau_bdev(ttm->bdev)->dev); > > + > > + if (nvbo->bo.ttm && nvbo->bo.ttm->caching_state == tt_cached) > > + ttm_dma_tt_cache_sync_for_cpu((struct ttm_dma_tt *)nvbo->bo.ttm, > > + nv_device_base(device)); > > Can we be certain at this point that the struct ttm_tt is in fact a > struct ttm_dma_tt? Yes, for all cases except AGP, where things are mapped WC anyways (so caching_state is always != cached) nouveau_bo_driver uses nouveau_ttm_tt_create() as its ttm_tt_create callback. This in turn calls nouveau_sgdma_create_ttm() which uses ttm_dma_tt_init() unconditionally. Regards, Lucas -- Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ |