From patchwork Thu Sep 4 07:47:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 4843231 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 70DA49F390 for ; Thu, 4 Sep 2014 07:47:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B408520200 for ; Thu, 4 Sep 2014 07:47:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E3444201CE for ; Thu, 4 Sep 2014 07:47:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BFAF56E6F6; Thu, 4 Sep 2014 00:47:36 -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 395E56E6F6 for ; Thu, 4 Sep 2014 00:47:35 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id s847lTBX032330; Thu, 4 Sep 2014 02:47:31 -0500 Message-ID: <1409816849.4246.34.camel@pasglop> Subject: [PATCH 9/9] drm/ttm: Sanity check mapping attributes on powerpc in ttm_io_prot() From: Benjamin Herrenschmidt To: dri-devel@lists.freedesktop.org Date: Thu, 04 Sep 2014 17:47:29 +1000 X-Mailer: Evolution 3.12.2 Mime-Version: 1.0 Cc: =?ISO-8859-1?Q?J=E9r=F4me?= Glisse 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.8 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 all current cache coherent powerpc processors, it is not legit to map system memory non-cachable. This will cause aliases with the linear mapping which can be fatal. The TTM should generally avoid it after Jerome placement patches but let's add a sanity check anyway to catch any possible remaining issue. Signed-off-by: Benjamin Herrenschmidt --- drivers/gpu/drm/ttm/ttm_bo_util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index ef2ac3c..48095be 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -37,6 +37,9 @@ #include #include #include +#if defined(__powerpc__) +#include +#endif void ttm_bo_free_old_node(struct ttm_buffer_object *bo) { @@ -498,6 +501,20 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) tmp = pgprot_noncached(tmp); #endif +#if defined(__powerpc__) && !defined(CONFIG_NOT_COHERENT_CACHE) + /* + * Using a non-cachable mapping of system memory on + * cache coherent powerpc's can be fatal, let's make + * sure this doesn't happen and warn if it does. The + * only exception is powermac with AGP which has to + * take the risk. + */ + if (!machine_is(powermac) && + ((caching_flags & TTM_PL_FLAG_SYSTEM) || + (caching_flags & TTM_PL_FLAG_TT))) { + pr_err_once("TTM: Attempt to use a non-cached" + " mapping on RAM unsupported !\n"); + return tmp; } #endif #if defined(__ia64__) || defined(__arm__) || defined(__powerpc__)