From patchwork Tue Feb 6 09:04:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10202509 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 66129601A1 for ; Tue, 6 Feb 2018 09:06:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E8C828ABB for ; Tue, 6 Feb 2018 09:06:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52BC728AC8; Tue, 6 Feb 2018 09:06:13 +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 C723528ABB for ; Tue, 6 Feb 2018 09:06:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B711189CCE; Tue, 6 Feb 2018 09:06:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DC9D89CA1; Tue, 6 Feb 2018 09:06:10 +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=WObYK+Q/1YiPQYLleJYaMYR5fR70mr7PR7URT8g8OqcXIU47i/k+bigRgTBskNPAnGtHrCeuq5Ef2rcmDvDEEkF0EHTk5GJGvxVsZsmS99lIW8P0cjtWR9/NS6trCfx10f3uMrqTmccVTClhQT7S+d4q7n4lzx3LFo27ZNM7qfU= Received: from BN6PR1201CA0002.namprd12.prod.outlook.com (10.174.238.12) by CY4PR1201MB0055.namprd12.prod.outlook.com (10.172.77.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 09:06:08 +0000 Received: from CO1NAM03FT016.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::200) by BN6PR1201CA0002.outlook.office365.com (2603:10b6:405:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.464.11 via Frontend Transport; Tue, 6 Feb 2018 09:06:07 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; shipmail.org; dkim=none (message not signed) header.d=none; shipmail.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 SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT016.mail.protection.outlook.com (10.152.80.170) 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; Tue, 6 Feb 2018 09:06:07 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Tue, 6 Feb 2018 03:06:05 -0600 From: Roger He To: , Subject: [PATCH 3/5] drm/ttm: use bit flag to replace allow_reserved_eviction in ttm_operation_ctx Date: Tue, 6 Feb 2018 17:04:32 +0800 Message-ID: <1517907874-21248-4-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517907874-21248-1-git-send-email-Hongbo.He@amd.com> References: <1517907874-21248-1-git-send-email-Hongbo.He@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)(346002)(396003)(376002)(39380400002)(39860400002)(2980300002)(428003)(189003)(199004)(105586002)(16586007)(36756003)(106466001)(4326008)(53416004)(104016004)(50226002)(316002)(68736007)(478600001)(81156014)(81166006)(72206003)(50466002)(336011)(97736004)(2906002)(8676002)(186003)(26005)(110136005)(76176011)(54906003)(51416003)(7696005)(77096007)(8936002)(59450400001)(48376002)(47776003)(86362001)(5660300001)(356003)(305945005)(2950100002)(6666003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB0055; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT016; 1:dYHp3aUk6HDzquu5rt3JvnBd1s7pDrxB2TVlEQ7KTpT9OOiXkIBzR7mR04AMDdQh7GXp0a7mp3RIY9vWna35koX+jquazPAyHMoM9hwxGiUw77+4E67ibXFUagjgon7n X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ba1cbdf-c9df-430c-47be-08d56d40db95 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:CY4PR1201MB0055; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0055; 3:g2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NUTgmXUOfxW+rYCBH3xXntl5LfCoTHW7yXlazGslnjhE+qr1FftFF7e6sNu94mkExQ2pI0tpi9Egm/mA/h6tX+SlFX6mjpgQTffm3KjpTDr+caV5nQ2i5/IDeIkkCYHHq0was6GCZRqQAqMdNnsZ1Kf4RcM4yT0zAgL9OIaHCuJQeeIQKGxwOGur/sEp1tS2cmf9x+sfPLhHsd0p+V+fthv2mEfKsi8Tm4wUtXSNs901EoSB7rw6XU0VMn2gIPXu+vDKGc/DsuYdCJ09BABrrLW/DHTYLjqcpQWFjmT5VjPkbtZKjedYPzhxnIeBfC2j8/04ycaWBgv3r7jKWql+RcglhEUipBBZs22HgVuN4lUHW5cK8mDmCohj0wi7Rm4rRv9X8/q6DmUp+u6I7SzIYr4k0rTq6ds3rR9CWCVqe1e71bbwluSov/c+V+4QYFK+z856EvJ 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)(8121501046)(5005006)(3231101)(2400082)(944501161)(93006095)(93003095)(3002001)(10201501046)(6055026)(6041288)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:CY4PR1201MB0055; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB0055; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0055; 4:eJWLcryoRUjTXzB0PeaZEefJ69OlwGST5VqrAQDXw1WXvayIpkI4a94kC2j2l7GWs43ZYseHEqwgBiOYPSuzX50mWeJt+TahjkF5h0smtFcywMlmfUQfju7X2I4Og7IaHz6syoF480vRDvywa0nd93Kt/zp+kA2TebD8UIhNwRm7LTYB1kVO+ik2F/EiAVI/RY82K7vYb22kBQ4WDycoldGUNn10MjkKSz2YQtlamTHiV2hpcMQrDVpqavrdje/Mw4/cKbMF803D7aN46zGCG+ReDcxgXN1Uei3lYDKsDeKWb+NvREzga0d/DrUm85BCJz6DzcvuD1z6N9nLyQYt4g== X-Forefront-PRVS: 0575F81B58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR1201MB0055; 23:FQ9/5jQ8eLte7NiWvI1Ra8FNRNYOpBx7ZHzoYcT?= =?us-ascii?Q?q+taj3URfObgvPNuPoneCVjdovVqqF/GJqAXNz+iEECFiPpoozg4FqnEZho8?= =?us-ascii?Q?NUB0RVCSjNmtP/32fMeZm+lRh8xy9H1HASMKKggPANjZWKhA4VCF2C9L5MrR?= =?us-ascii?Q?8iecaOv9EDHnVeTvdbO9dcJanp4hbXqKrDj6LvjeVx5dUkEZBGge8h7AXwZE?= =?us-ascii?Q?eWbi9czFCR9DKeDCNN9Vt8HopGgqBZAfUeViiHXNFhgYK3wk52ngKLAO6hFi?= =?us-ascii?Q?UjxaURa+9FhkiIfsSZ7mMN0AjzEKKgz+ZY9pBM3pS397hk0s/NHj80jzC+9P?= =?us-ascii?Q?TIqJ6Snimilj3hYkli/0l2O1MOIckdRsjB/fv2Fz2R5rtwWEfTjTMerpRiR9?= =?us-ascii?Q?GimM5ftsjZhxOQMTFN7woTcILkr9s/1AjLr3z33gd/9YMEExtTwZcmVcTq2W?= =?us-ascii?Q?WMyuaoIbVlheyhBQtTpU+ZfyeB3Xl9Fkzf28UF7+yg+ALQWBfS1g3Nqh8tKB?= =?us-ascii?Q?Nd5caeIOC1AhJf43KmPEkvyPAgpm+uiHVEALU5viS9chQNtTyD+ypBElS6Xw?= =?us-ascii?Q?+2Cn8gl7DQzsk0au0Ni+ihgws3qJ9X43j99hZ0jGqHHX0/8xkdk57/PUU4jR?= =?us-ascii?Q?spJ3/+g9KtZhJLOGsqTPcLDdY7jEArCCEoBrkEvEzgJ79reKTOVkV11W+M1q?= =?us-ascii?Q?YYNxP9FW5upjvffZi0kOCWzGSMYojWpVj47T98so+32hnITsqefJRcaIrEE+?= =?us-ascii?Q?E3GLpqipH5bd86ixzCcw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DyxDW6hcynL6466+i4YP7AnaNM=; 7:qDLJuvO2yUEoGCUzqSTFRR1Mky5yNmkjSjqRZ4HCIjerWwVlr3KXFBJATWK9YpcOTqX4IS2vWTHbDH7ux+KIxsueaN+xedxR5faFQRmn7p9pQ03FI74dDPpk11+ezP8t/TFpNQmHDdIihHe3/LBNiyFQNJPBAn/R2rkTFevAkIkzdurs0vodQQbO2nXFj3wnEbCDEh+/xL8W0kBQU6R+p1Fsu5FtO4+Xj0KzcU9QYyfVpWtf0SyWBmBu6bMlZ82R SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0055; 20:lxrGcl93vOO4pwMKyQEIfskkni7keRKXoFM+ADxoKNoq58eQumHsxqi670bwSAge/OJcHYIEBzXlD1QvCQUbluepiTNifumeyzCbUhPGWgewcbHw8pyTYx9Vjvohkb5ybY0RCz5piAwnF6n5FAaJduq4Bu5ErB0jB1AhuseKoGQtFwRZVtwgkaCiosXvn2i/OkYUZxL0EW/tCPPwACplMW3w5Yck52PGt5KhET5xYdhBx6XsB2Dq0jjcfqsulgsj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 09:06:07.0246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ba1cbdf-c9df-430c-47be-08d56d40db95 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=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0055 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 --- 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 *