From patchwork Thu Jul 30 09:00:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11692531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61B4D6C1 for ; Thu, 30 Jul 2020 09:00:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4048A2072A for ; Thu, 30 Jul 2020 09:00:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dYWSgSa0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4048A2072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 330D46E89F; Thu, 30 Jul 2020 09:00:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4287F6E898 for ; Thu, 30 Jul 2020 09:00:30 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id q4so16164262edv.13 for ; Thu, 30 Jul 2020 02:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U1vUDdXxb12jmRKQKUQnzHWNXfr3SoITYVD9LR8yNa0=; b=dYWSgSa0bdNSfiQ3c9l2LRB6Cl5yuqfoyKZvkl8CwuALeATxy9dHL9KVTkK3fcB1uz OyC733GR0lDxlm1wxo916iSvGX4nkPqUTFQh3jSZy+UJJ78WefGwszGjuHSgoiyo4gVF DN+TBT+RwYn81no6KutenfLmyGCbxRoxehsuQFDihqdMsl624CLMWbismhJwCZu9+DCz XDB7IGcddAAjTy405xWtuxelI+RT9SpVlnnfpwG4Iho/J6cMMgj1szxpL9yZdc+CRngf WqIZVUoIdzXblXKpIlV84v2U1tTIMXBOh7LZ2aPwrDQlzVx25TgJvMvCA3OCrdk9lbge RNRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U1vUDdXxb12jmRKQKUQnzHWNXfr3SoITYVD9LR8yNa0=; b=PlfA9f9YmIXX4M3KU8BTYFmYahi18Wmpm4fMHAsmuSnFXF9Gnv9YYaVfGzCbrreSdD 5vlSDyDJGeb+Pm3qOQf/2yuVwdssALMRzLd8QRA95jx3UBL2jhOKz0vbnGZjo5eOybzu wQngz51vI1WY5AEQ8v7BitdZtLkx+4laUajPTqs+crQL/Mrt7FPBILuOhNV7EGdNR1YO Db+EgMUlnG+d/yTc7x+Te4MUXpwh8IKegAu2KBvbk7s2JCryjA/wzvbGpSG1YrTG9a4F 29bsgmoo0j4y4SJy5CLWoDrAGrc39U7LNxVWS4t+mf7QxmSaA6/GLpLbzoPDJw+Yjog4 pNpg== X-Gm-Message-State: AOAM532XO4w1rbkSIhplqfUYs2Mx4AcaejJeCwMBC51cgio/6AtqilPw nkOpWXSorGFU5pNGm8zhk1n1UlOY X-Google-Smtp-Source: ABdhPJzn3VSyYiJTjFMzr2DptnPMIA3RXbs9JFzbRTG80iFGf8aw/LZ+FWkivl3KBzoPSrUmUWSZ+w== X-Received: by 2002:a05:6402:17f7:: with SMTP id t23mr1664628edy.301.1596099628755; Thu, 30 Jul 2020 02:00:28 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:cb71:127d:d8c4:4acb]) by smtp.gmail.com with ESMTPSA id j24sm4968238ejv.32.2020.07.30.02.00.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 02:00:28 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/9] drm/nouveau: stop implementing init_mem_type Date: Thu, 30 Jul 2020 11:00:12 +0200 Message-Id: <20200730090015.17295-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730090015.17295-1-christian.koenig@amd.com> References: <20200730090015.17295-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Instead just initialize the memory type parameters before calling ttm_bo_init_mm. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- drivers/gpu/drm/nouveau/nouveau_bo.c | 48 --------------------- drivers/gpu/drm/nouveau/nouveau_ttm.c | 61 +++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index a3ad66ad3817..23ef9b1aaabc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -650,54 +650,6 @@ static int nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, struct ttm_mem_type_manager *man) { - struct nouveau_drm *drm = nouveau_bdev(bdev); - struct nvif_mmu *mmu = &drm->client.mmu; - - switch (type) { - case TTM_PL_SYSTEM: - break; - case TTM_PL_VRAM: - man->available_caching = TTM_PL_FLAG_UNCACHED | - TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - - if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { - /* Some BARs do not support being ioremapped WC */ - const u8 type = mmu->type[drm->ttm.type_vram].type; - if (type & NVIF_MEM_UNCACHED) { - man->available_caching = TTM_PL_FLAG_UNCACHED; - man->default_caching = TTM_PL_FLAG_UNCACHED; - } - - man->func = &nouveau_vram_manager; - man->use_io_reserve_lru = true; - } else { - man->func = &ttm_bo_manager_func; - } - break; - case TTM_PL_TT: - if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) - man->func = &nouveau_gart_manager; - else - if (!drm->agp.bridge) - man->func = &nv04_gart_manager; - else - man->func = &ttm_bo_manager_func; - - man->use_tt = true; - if (drm->agp.bridge) { - man->available_caching = TTM_PL_FLAG_UNCACHED | - TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - } else { - man->available_caching = TTM_PL_MASK_CACHING; - man->default_caching = TTM_PL_FLAG_CACHED; - } - - break; - default: - return -EINVAL; - } return 0; } diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index e89ea052cf71..b0012021ae12 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -180,6 +180,61 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind) return 0; } +static int +nouveau_ttm_init_vram(struct nouveau_drm *drm) +{ + struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM]; + struct nvif_mmu *mmu = &drm->client.mmu; + + man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; + man->default_caching = TTM_PL_FLAG_WC; + + if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { + /* Some BARs do not support being ioremapped WC */ + const u8 type = mmu->type[drm->ttm.type_vram].type; + + if (type & NVIF_MEM_UNCACHED) { + man->available_caching = TTM_PL_FLAG_UNCACHED; + man->default_caching = TTM_PL_FLAG_UNCACHED; + } + + man->func = &nouveau_vram_manager; + man->use_io_reserve_lru = true; + } else { + man->func = &ttm_bo_manager_func; + } + + return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, + drm->gem.vram_available >> PAGE_SHIFT); +} + +static int +nouveau_ttm_init_gtt(struct nouveau_drm *drm) +{ + struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT]; + + if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) + man->func = &nouveau_gart_manager; + else + if (!drm->agp.bridge) + man->func = &nv04_gart_manager; + else + man->func = &ttm_bo_manager_func; + + man->use_tt = true; + if (drm->agp.bridge) { + man->available_caching = TTM_PL_FLAG_UNCACHED | + TTM_PL_FLAG_WC; + man->default_caching = TTM_PL_FLAG_WC; + } else { + man->available_caching = TTM_PL_MASK_CACHING; + man->default_caching = TTM_PL_FLAG_CACHED; + } + + return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_TT, + drm->gem.gart_available >> PAGE_SHIFT); +} + int nouveau_ttm_init(struct nouveau_drm *drm) { @@ -237,8 +292,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1), device->func->resource_size(device, 1)); - ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, - drm->gem.vram_available >> PAGE_SHIFT); + ret = nouveau_ttm_init_vram(drm); if (ret) { NV_ERROR(drm, "VRAM mm init failed, %d\n", ret); return ret; @@ -254,8 +308,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) drm->gem.gart_available = drm->agp.size; } - ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_TT, - drm->gem.gart_available >> PAGE_SHIFT); + ret = nouveau_ttm_init_gtt(drm); if (ret) { NV_ERROR(drm, "GART mm init failed, %d\n", ret); return ret;