From patchwork Thu Feb 8 06:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10206621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6643F60327 for ; Thu, 8 Feb 2018 06:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 555A2293A1 for ; Thu, 8 Feb 2018 06:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48C0B293B6; Thu, 8 Feb 2018 06:01:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E64A293A1 for ; Thu, 8 Feb 2018 06:01:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A1606E138; Thu, 8 Feb 2018 06:01:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0082.outbound.protection.outlook.com [104.47.33.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA7866E138 for ; Thu, 8 Feb 2018 06:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qNXKofTSsYMWzrMdC1/MNxi6los+WDjCtavaCep9rqI=; b=EjyDu5zBTwHM4ZtXC7zhOf5HVlp9ENHLClcJFDF/ry+HG8kI1eKq6aVfaV2mAsM9Lw+C7IFZBChJZ+Xz1MBhpkWXerqeAU78hQzltMO7zUhYKVBo729XthFkNDNpJVxp5c/mVdXmVW/ArmXBhlRqesXLWAqnMZ5txtDP8TDndzw= Received: from DM3PR12CA0089.namprd12.prod.outlook.com (10.161.151.161) by BN6PR12MB1618.namprd12.prod.outlook.com (10.172.23.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Thu, 8 Feb 2018 06:01:10 +0000 Received: from DM3NAM03FT024.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by DM3PR12CA0089.outlook.office365.com (2603:10b6:0:57::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.485.10 via Frontend Transport; Thu, 8 Feb 2018 06:01:10 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT024.mail.protection.outlook.com (10.152.82.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.464.13 via Frontend Transport; Thu, 8 Feb 2018 06:01:10 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Feb 2018 00:00:57 -0600 From: Chunming Zhou To: Subject: [PATCH 2/3] drm/amdgpu: only enable swiotlb alloc when need Date: Thu, 8 Feb 2018 14:00:16 +0800 Message-ID: <20180208060017.30780-2-david1.zhou@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180208060017.30780-1-david1.zhou@amd.com> References: <20180208060017.30780-1-david1.zhou@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(346002)(39380400002)(2980300002)(428003)(199004)(189003)(1076002)(47776003)(6916009)(478600001)(5660300001)(2950100002)(316002)(72206003)(16586007)(6666003)(76176011)(86362001)(336011)(51416003)(104016004)(77096007)(7696005)(186003)(53936002)(50466002)(4326008)(48376002)(50226002)(81166006)(81156014)(106466001)(26005)(305945005)(356003)(8936002)(97736004)(105586002)(68736007)(36756003)(2906002)(53416004)(54906003)(2351001)(8676002)(358055004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1618; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT024; 1:m3vebvqD66d+3/KwTOz5qAivnXawZFXpK+W6bBIKaqI+c+U90VJtetd7Vxzj6TOEqtQsUHghWJsZ8aw35fNgIphB3XRomL4rdoa/0JxD9nQCabJxexD1SUcMg8ofcPTd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 331536d6-81b0-42b3-48a3-08d56eb95a1a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BN6PR12MB1618; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1618; 3:5dH/VtySwbzMr3PL6buZ4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6WU6LjHW3DrxKns1fKxA9+G1fF5q9VkvR27JxPAI7AHy5gLGFStgvzTNBAlt2gmVj2lrvjsTa4eZqTBlIp1a/+fTLiFL+TJ5/k7he/hydLmKelUNd99jBS4vQ8b2WXktgZNJW8DoZZaM9DDcRnynSw2YihCFqn3vjqoGYH+y4TdOnst3C9z2KPXbZxNBts//uYRMo99jSwKRbdLA+Z3nGUXSHop0VBUZf190jqJMo/6A7vSMNpFrJ0tZeoL07j0DuKrWTBojv0lTBIH4jnD2skJJSNmZqaRMuMNz1RCVlMTATVP4eDa8OmgtDZ0hqRiWamOSwLqTaIVhZkc1Lr8w1dNlVUyLLUoPPkBiPFsfQNYyt8lrp9GdqzmiqSIhdjyKeB3kEgyvympqGIsW4HMka/rCivUfce6PlrdoKqVQKdcW0Lnuj1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3002001)(3231101)(2400082)(944501161)(93006095)(93003095)(10201501046)(6055026)(6041288)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:BN6PR12MB1618; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1618; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1618; 4:d5Iv/6P2fPljxBZIxIPeKJB8cdyV+MJKLPP55o9oscNxXnuL8PwwA9oe9vdLHX0FJ8roKB8bLUl642xViEf0Dzqxu7RV0i18iSDC5U4yGyQKqZh1TV9Av0zpR3LeDUjGgrzvmaXmgG4PK2Qb9KkNpSExvmOK4nm0GWpgAqRvSa4ILFQCFVX/5FBmw3zmR2pPL+E7worcaU2GlmTyFO2vAYMI2/aoHFxPuFwecxL5aeqsGLWOprOhu+Rp/AMrY5Vc7rNnGqWFTBWxyRNPxnOjnzZI0mqviVPs5UmIBGCzC4GetHpiktcCUI8gjfpAjQUy X-Forefront-PRVS: 0577AD41D6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1618; 23:FOAratXgaxfKkBEvtiS8/4SzCeddNOUS0jR8h+bDm?= =?us-ascii?Q?ZK7+ExdSkflDxqPvDIVthC1aa2hsxQu1uhXaNaWnJVBXdQQHqQQv+mcXSvaI?= =?us-ascii?Q?DX7wRuIesv7h884Y7w6GfKYaDhuT8XMpJYUa8bMISidTBZP8KCWcqoKC3c1w?= =?us-ascii?Q?ujd6gqi8tkgCS2fedydteLGjsttPAwQSTzaYqYNn41odnSO0A0HDU4ffGonb?= =?us-ascii?Q?qerzXQBpkWWH/7I5QR29asLMMU3D9oc1L0K586TxUQ/Z2HueMrB4zmnSoNut?= =?us-ascii?Q?22tJjfLQI+BM4Il/a7FH4WkBF5aZnhT251iHyBhoA3t80QEOfoECq+2yCZqH?= =?us-ascii?Q?rn3ggeK3DfES0PogC4+9Ey4KsRx9dLBMzUiMn6nXvM0pLUw1Nazdm3dwo1Kz?= =?us-ascii?Q?lUldAzj1d5VDFQTpB3wn3/reHLdZUOILXtYU9W/Z2HtYqcrPolu7duldgsHB?= =?us-ascii?Q?4ZJmhKM1D77c6CA5nWkmt1E/RrKUkgpAJrYmb4YyVXEELITzqHgwvJeGcQC2?= =?us-ascii?Q?Kuv1siDlMwBuIRR9k8mOO+huGbIJe0EYh4qGza8mDlZ2bmnwpPRWZ3Hk5+OT?= =?us-ascii?Q?hTQFrcsdOfzEbbxCUEkvNS7cMyoal630UdoawB6C2qkUhs/yJZLxhRvK9yyt?= =?us-ascii?Q?b51Qin9avLvKShvKOI5EH2KJCFtumcF+7H2jk8IpBTYBcnGQMBW/MopQR2DJ?= =?us-ascii?Q?CU9XcBIkGMaVep9dA5hO40plzJI77ZLMfAA1qWd+zJzNq2D6k7AIuVbj5s2U?= =?us-ascii?Q?mn4gQy++Uov+yTaFi2RIpyenkxMDyWEWbo/hNt2nSWNeAwllodxWEgDx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ARnsh7r05dDSlTEvUfVghv8=; 7:KVPqzg72r2z27mnxw3h3gobth3wsIkR9roo+dcKPG4m4/Dy+lVKfBFNs+OmoiV8bN0q5qK2yPb0VT8MagCWuhQ5WhaezGKj2iNzLbrJJAYJexssAkLRZ36REfihK23RRlSxSH82XSnD/e2FLJsKVIa2UKN55Z0Z9ZxO5iwd2Dw08zvImQUZnGq8sEp6urXwx+ku0uZyq61SLzZT9psceXeGJv5T5AuTjH2BzVoHVJzoKQ3xLu8oou8dufAf1tUS/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1618; 20:W/UliKHUUoZKx+McVH7wML5GIR9b9zUxe4gYMXAIKkKj8nQ+L9H0nkrpRDdGIuKS2M3dGgiV4NaL5tyYB7Ed76Y9x1Pa1sKYs5RcVcgFN9vJ1VXv4PLnXN2pUd1Qemsw5do/hyTvullDqoAB+PwYOkidFrk/WfjdPBC2b4lkCf4Qp1Aci7S9fo724s2NoAN9z/PV4DPL6f9vHMP9dBro4ijdyBdJgKSXNInZgTjMzgtuuu+sd310my0BSo4qpwBQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2018 06:01:10.0595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 331536d6-81b0-42b3-48a3-08d56eb95a1a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1618 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP get the max io mapping address of system memory to see if it is over our card accessing range. Change-Id: Ibc38dbd34a20af5b4a4b1ed154c14e1c58aa4c55 Signed-off-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 ++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 257424dd8a52..627a06185368 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1437,6 +1437,7 @@ struct amdgpu_device { const struct amdgpu_asic_funcs *asic_funcs; bool shutdown; bool need_dma32; + bool need_swiotlb; bool accel_working; struct work_struct reset_work; struct notifier_block acpi_nb; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 95f990140f2a..a021de9629ad 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1018,7 +1018,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, } #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (adev->need_swiotlb && swiotlb_nr_tbl()) { return ttm_dma_populate(>t->ttm, adev->dev, ctx); } #endif @@ -1045,7 +1045,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) adev = amdgpu_ttm_adev(ttm->bdev); #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (adev->need_swiotlb && swiotlb_nr_tbl()) { ttm_dma_unpopulate(>t->ttm, adev->dev); return; } @@ -2007,7 +2007,7 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); #ifdef CONFIG_SWIOTLB - if (!swiotlb_nr_tbl()) + if (!(adev->need_swiotlb && swiotlb_nr_tbl())) --count; #endif diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index 5eacc0819b66..63d0720ac21f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c @@ -22,6 +22,7 @@ */ #include #include +#include #include "amdgpu.h" #include "gmc_v6_0.h" #include "amdgpu_ucode.h" @@ -855,6 +856,7 @@ static int gmc_v6_0_sw_init(void *handle) adev->need_dma32 = false; dma_bits = adev->need_dma32 ? 32 : 40; + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { adev->need_dma32 = true; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index ce7f484f86f9..f70a81fcadec 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c @@ -22,6 +22,7 @@ */ #include #include +#include #include "amdgpu.h" #include "cikd.h" #include "cik.h" @@ -1003,6 +1004,7 @@ static int gmc_v7_0_sw_init(void *handle) */ adev->need_dma32 = false; dma_bits = adev->need_dma32 ? 32 : 40; + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { adev->need_dma32 = true; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index f53f3936fd4f..21fe9afb6e73 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -22,6 +22,7 @@ */ #include #include +#include #include "amdgpu.h" #include "gmc_v8_0.h" #include "amdgpu_ucode.h" @@ -1101,6 +1102,7 @@ static int gmc_v8_0_sw_init(void *handle) */ adev->need_dma32 = false; dma_bits = adev->need_dma32 ? 32 : 40; + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { adev->need_dma32 = true; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index 2c60981d2eec..8730768efd13 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -21,6 +21,7 @@ * */ #include +#include #include "amdgpu.h" #include "gmc_v9_0.h" #include "amdgpu_atomfirmware.h" @@ -879,6 +880,7 @@ static int gmc_v9_0_sw_init(void *handle) */ adev->need_dma32 = false; dma_bits = adev->need_dma32 ? 32 : 44; + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { adev->need_dma32 = true;