From patchwork Thu Feb 8 09:05:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10206747 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 89D2360327 for ; Thu, 8 Feb 2018 09:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A7F29051 for ; Thu, 8 Feb 2018 09:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E5BD29424; Thu, 8 Feb 2018 09:06:15 +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 C8A6829051 for ; Thu, 8 Feb 2018 09:06:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 928986E422; Thu, 8 Feb 2018 09:06:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0082.outbound.protection.outlook.com [104.47.38.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78A4F6E410; Thu, 8 Feb 2018 09:06: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=RZluIiuXAcQu3UTTgQ0fyicVxzk+OaBVe6BLHMGpGIA=; b=DQZe1KOPoELnLE72v3cFbqGWOuh9xc9F26pcIYgEIkPDdqwY9me3lQN5t6CVh+bWiu5uer7JlkrsqqgXgHim07ZxKQ8+ZdyMoVyB4aBbVzWJb6NS38NUiOs0ntwVPeuKjRAeZIYuPT2ppJi13Pz5FQlMhVRzm2YZjwSGLzYXgfM= Received: from BN4PR12CA0009.namprd12.prod.outlook.com (10.164.241.19) by BN6SPR00MB03.namprd12.prod.outlook.com (10.172.112.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.11; Thu, 8 Feb 2018 09:06:10 +0000 Received: from CO1NAM03FT063.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by BN4PR12CA0009.outlook.office365.com (2603:10b6:403:2::19) 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 09:06:09 +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 CO1NAM03FT063.mail.protection.outlook.com (10.152.81.61) 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 09:06:09 +0000 Received: from roger-build-server.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 03:06:01 -0600 From: Roger He To: , Subject: [PATCH 1/4] drm/ttm: use bit flag to replace allow_reserved_eviction in ttm_operation_ctx Date: Thu, 8 Feb 2018 17:05:58 +0800 Message-ID: <1518080761-12952-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 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)(39380400002)(346002)(376002)(39860400002)(396003)(2980300002)(428003)(189003)(199004)(2906002)(106466001)(59450400001)(81166006)(50226002)(81156014)(8676002)(97736004)(8936002)(51416003)(356003)(305945005)(86362001)(7696005)(5660300001)(47776003)(48376002)(104016004)(50466002)(186003)(336011)(53416004)(110136005)(54906003)(16586007)(316002)(26005)(77096007)(6666003)(105586002)(53936002)(478600001)(68736007)(4326008)(36756003)(450100002)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6SPR00MB03; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT063; 1:lCxLUxTdtqSA9GC8jtplP+YSLNRxEh3IqIN+6CEL/JB93T9vfhrdqosL5CT/Gk/yEuDsmBwRefRC/YVya07BuS/UCAqyyAvwIftK5NSRiKemjfI44vAIdz2atJxcrr2h X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0c973ad-e752-411a-41fd-08d56ed331a3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:BN6SPR00MB03; X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 3:n4kAwu1dHZl+qR1nb24fOIpx12Cckkdrv7f3VHbr+aIIRdI7d6ozKrh32UU64KFczACIz7Mzt2y+iTf6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UVOfqnzY93L2PoqAk2MRt+MVXrlbkG8+yo375ca0eK3FcsqaCAqzEpWLnsYRvmr5lHMfrC26GaK5bG7ezmxTz+GAVLS8VbDgQ27vHyUKVaP6ZwjjxEw1voQ1AtJ47t+zFP4aG4kuMnNfZVu7DIEbe7bdwXktHbLdeyns9WL3dg8l7Adg9lve6xQpyEqlV8ejUzUDw0pqtpguaU8G2GeHi90u6TY39RnvXB+dXxktboFPpaiUJFvknTKojMKl7rnyDquVAKDpeWq66a6avNt97H+eN7JFNz/0okATHYCSLZvprhSCXsrnjLJBKWIZpV3K0SN0EaKhmDY4pLS4Y3O+rJDC9/cx3oyoGAyA0IeipqlJ6nZZ5lT7eeQg X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(10201501046)(3002001)(93006095)(93003095)(6055026)(6041288)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BN6SPR00MB03; BCL:0; PCL:0; RULEID:; SRVR:BN6SPR00MB03; X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 4:Ck7t0+ostJN3/z4cIVuBP234bfmQJwoLDLG6Q4KQFlmptQ9I10/c8qthNYGEAHexICuLDkO4vwTu7DDKaMi30yQz7LsvGm2Cye/G8TxDkYahzK6GRTsYrWHnGQY6nES85nYOXO5wTpRNajyGZtCW5voGUEhJ8XTPMwp33fwicTnDGOXiDujDVVg9NQOMiqx1vxQvQMp1RPjNAodV9bDHVAsSRWciX67LBJ5v/pWueOTGCidCxJBNvzhNr7NlhOFwyGucQuOKbKaZV4Tvrxd21O0YzHzQAuvlrs5h3Wuw67z6LBZhUeu3qjxQ8jRhxtifiMZIOeDg3tkcVCwXp+Rq1A== X-Forefront-PRVS: 0577AD41D6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6SPR00MB03; 23:/PjTgvhLfU/7i/CqCmfzRf1Vi/zhTwk7yUR2j0U/QE?= =?us-ascii?Q?SyAV58iGANYGcYUHejxPzLX6C2z+C5htFMGQ3LFJCJOEhl98Y+7c+NDpetMo?= =?us-ascii?Q?lr2SHV1imKcjz5xQao+8q5jQFg94GSyyx/6mzIfO9Kh0FgXcExwUg/f/cfnI?= =?us-ascii?Q?9ngDR4xNUumo95RL/x1DQXxVpa7JhRjArmWg5Kg7MsyPnThOd9tvynV/5QkT?= =?us-ascii?Q?ufMNprqqxjK4X6LMmovTnBF7yhMG+dwVQz89iSG5hHql1xq12fKmmoxeMgpd?= =?us-ascii?Q?U1oy9OYWBoxf+BNLsNUzuOGIm7+31sWXMmh8vb5kXCRPVxRhRGf7ihe/NhTu?= =?us-ascii?Q?AcaloTGrLSj3NarLT2nClOc3jjoTuIWpm0I8UuIu0oIUWmhIlL80ZB9zyyye?= =?us-ascii?Q?qoqnmCH6mNJMpX+lwLKMJbPMVp0T4CNMBPI/SJ1fT248iqKYLouNQbLqnbFo?= =?us-ascii?Q?qU2uzq+MraYBzop6osyRYoNyPEBWZvDemFqf8j9zjE63V4HKErS133c0jVAm?= =?us-ascii?Q?nYich+O3FRQoktZxTIOpFa4hjXmADOfTaw9kilay+YubqntsLZuuD79XjvZh?= =?us-ascii?Q?QygKgmDgLI9sghORNznAP/VxUU0jRnfT4jna09xeQhJXy/6716SiQzPYt9Vp?= =?us-ascii?Q?IzTEf8HqSX9AfNTJ+fYp0Scsdj83KcC8llVBZl7fXAzq1X+t1gyzaiAoOekg?= =?us-ascii?Q?4zqocHY8HWgoOXxLPiTAm/elL8Oz7KmjfFGEK+8qZsSuqkOmOxI2SqWcx6v4?= =?us-ascii?Q?APBnO55Gy852aS6Z/uft9R1zoqBaNw73sBSYhWCL93CVGP7Xh2z9TwzHeCue?= =?us-ascii?Q?O2VGsUjJ5zU3e3YRi5lzEX0T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HhE8HWBAfljJwhzNNbFTnrdnvNVZ/qi5cGURutzisMM+7u7BBxtn1jlxxMdBb7nKEoet1G8lDAj9bNS/vse8EpnBeYPGp76OVJj5Np0sAaMretqOYuz55wZe2L/+XPxTH+7hgCcChb+xQvyp7xqK1Y6h5vK4SCw7nF20 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 20:VxiHM0TA16hm02blZUxoRL/JpU8byPAO1vZKncjnwvllDI99Knk3s0zKk/xzrT/7GfOAcLXQg2RXd/2PAJTTZBxFuitLAxpkRXDI1tuS9DEdDMp7fEVWNE+QtFbCKXYy0NCX8qyvZm8uquH+sZ8ZnC9tI0APo5HL2G2/B5Anzj0cX+tWjqxukTzpzSlsanPWQVHMIEnBbDKRmrq7NyfyfDcUMJeK5GB+q1LbRK0KlhlQ3w+th5g4EcgU/ziS6lhb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2018 09:06:09.0855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0c973ad-e752-411a-41fd-08d56ed331a3 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: BN6SPR00MB03 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: Roger He , Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP for saving memory and more bit flag can be used in future Signed-off-by: Roger He Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- include/drm/ttm/ttm_bo_api.h | 7 +++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index eaa3cb0..dc34b50 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -346,8 +346,8 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, struct ttm_operation_ctx ctx = { .interruptible = true, .no_wait_gpu = false, - .allow_reserved_eviction = false, - .resv = bo->tbo.resv + .resv = bo->tbo.resv, + .flags = 0 }; uint32_t domain; int r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 512612e..0338ef6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -341,8 +341,8 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, struct ttm_operation_ctx ctx = { .interruptible = !kernel, .no_wait_gpu = false, - .allow_reserved_eviction = true, - .resv = resv + .resv = resv, + .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT }; struct amdgpu_bo *bo; enum ttm_bo_type type; diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index d90b1cf1..a907311 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -730,7 +730,8 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo, *locked = false; if (bo->resv == ctx->resv) { reservation_object_assert_held(bo->resv); - if (ctx->allow_reserved_eviction || !list_empty(&bo->ddestroy)) + if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT + || !list_empty(&bo->ddestroy)) ret = true; } else { *locked = reservation_object_trylock(bo->resv); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 2cd025c..872ff6c 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -263,8 +263,8 @@ struct ttm_bo_kmap_obj { * * @interruptible: Sleep interruptible if sleeping. * @no_wait_gpu: Return immediately if the GPU is busy. - * @allow_reserved_eviction: Allow eviction of reserved BOs. * @resv: Reservation object to allow reserved evictions with. + * @flags: Including the following flags * * Context for TTM operations like changing buffer placement or general memory * allocation. @@ -272,11 +272,14 @@ struct ttm_bo_kmap_obj { struct ttm_operation_ctx { bool interruptible; bool no_wait_gpu; - bool allow_reserved_eviction; struct reservation_object *resv; uint64_t bytes_moved; + uint32_t flags; }; +/* Allow eviction of reserved BOs */ +#define TTM_OPT_FLAG_ALLOW_RES_EVICT 0x1 + /** * ttm_bo_reference - reference a struct ttm_buffer_object *