From patchwork Thu Sep 4 02:15:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 4842161 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06FB7C0338 for ; Thu, 4 Sep 2014 02:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 197DD20251 for ; Thu, 4 Sep 2014 02:16:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F1AB32024F for ; Thu, 4 Sep 2014 02:16:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 444BD6E0EC; Wed, 3 Sep 2014 19:16:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by gabe.freedesktop.org (Postfix) with ESMTP id E37A86E0EC for ; Wed, 3 Sep 2014 19:16:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id s842FlAm020370; Wed, 3 Sep 2014 21:15:49 -0500 Message-ID: <1409796948.25089.6.camel@pasglop> Subject: Re: TTM placement & caching issue/questions From: Benjamin Herrenschmidt To: Jerome Glisse Date: Thu, 04 Sep 2014 12:15:48 +1000 In-Reply-To: <20140904015548.GB4835@gmail.com> References: <1409789547.30640.136.camel@pasglop> <20140904015548.GB4835@gmail.com> X-Mailer: Evolution 3.12.2 Mime-Version: 1.0 Cc: Alex Deucher , linuxppc-dev@ozlabs.org, Michel =?ISO-8859-1?Q?D=E4nzer?= , Christian Koenig , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2014-09-03 at 21:55 -0400, Jerome Glisse wrote: > So i think we need to get a platform flags and or set_pages_array_wc|uc > needs to fail and this would fallback to cached mapping if the fallback > code still works. So if your arch properly return and error for those > cache changing function then you should be fine. > > This also means that we need to fix ttm_tt_set_placement_caching so that > when it returns an error it switches to cached mapping. Which will always > work. Can't I just filter the mem_type definitions in the mem_type_manager with something along that totally untested patch ? Or do I *also* need to make those set_page_array_* things fail ? --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1308,6 +1308,24 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned } EXPORT_SYMBOL(ttm_bo_evict_mm); +static void ttm_bo_filter_mem_type(struct ttm_bo_device *bdev, unsigned type, + struct ttm_mem_type_manager *man) +{ + /* + * On some architectures/patforms, we cannot allow non-cachable + * mappings of system memory. This can be a problem with AGP on + * old G5 systems vs. TTM_PL_TT but we don't really have a choice + * at this point on ppc64 at least and the AGP on these never + * worked reliably anyway. + */ +#if defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) + if (type == TTM_PL_SYSTEM || type == TTM_PL_TT) { + man->available_caching &= TTM_PL_FLAG_CACHED; + man->default_caching &= man->available_caching; + } +#endif +} + int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, unsigned long p_size) { @@ -1327,6 +1345,8 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned ty return ret; man->bdev = bdev; + ttm_bo_filter_mem_type(bdev, type, man); + ret = 0; if (type != TTM_PL_SYSTEM) { ret = (*man->func->init)(man, p_size);