From patchwork Tue Mar 27 03:32:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10309161 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 CD32D605D2 for ; Tue, 27 Mar 2018 03:32:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC3732963B for ; Tue, 27 Mar 2018 03:32:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0E5B2979A; Tue, 27 Mar 2018 03:32:21 +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=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 6713E29A07 for ; Tue, 27 Mar 2018 03:32:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 989C66E532; Tue, 27 Mar 2018 03:32:17 +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-bn3nam01on0077.outbound.protection.outlook.com [104.47.33.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 099E66E101; Tue, 27 Mar 2018 03:32:15 +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=8RWxRSfg9hsgljeAvPopTj84q+AqtY7gHw94beQy+gM=; b=f4lC/FE1dj898DZY2aRCNScqHJpSOhORc92fvDNWk6nIfRarvM811bKriT2QF7TkrZAOlHn60DTr12hhY/XU4NPdbBgKjya1Y0VyHUiXZRUCkfdnxiR37GY31h5E+zNqKDBBjaeMhdT+G/nKmRxcVTUAuF0sS1KRVRNAV7njBEM= Received: from MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) by MWHPR1201MB0206.namprd12.prod.outlook.com (10.174.99.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Tue, 27 Mar 2018 03:32:13 +0000 Received: from MWHPR1201MB0127.namprd12.prod.outlook.com ([fe80::4962:1f7b:d630:84b6]) by MWHPR1201MB0127.namprd12.prod.outlook.com ([fe80::4962:1f7b:d630:84b6%18]) with mapi id 15.20.0609.012; Tue, 27 Mar 2018 03:32:13 +0000 From: "He, Roger" To: =?utf-8?B?Q2hyaXN0aWFuIEvDtm5pZw==?= , "linaro-mm-sig@lists.linaro.org" , "linux-media@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" Subject: RE: [PATCH 2/5] drm/ttm: keep a reference to transfer pipelined BOs Thread-Topic: [PATCH 2/5] drm/ttm: keep a reference to transfer pipelined BOs Thread-Index: AQHTvSmjmc8oehZDP0qx30U8B/yIHaPjffWg Date: Tue, 27 Mar 2018 03:32:13 +0000 Message-ID: References: <20180316132049.1748-1-christian.koenig@amd.com> <20180316132049.1748-3-christian.koenig@amd.com> In-Reply-To: <20180316132049.1748-3-christian.koenig@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Hongbo.He@amd.com; x-originating-ip: [116.228.147.241] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR1201MB0206; 7:vkYncrMCkatV27mktfVxVEvmEBVvtmrEcMGI2/GZCTuKIfYXScS+fR9wAGwFXfU7WRePCo3UJxc8fUjKt6ZvGV4oLpw6YcTHpCUUdVEYz55oWUXukMUjgumX5gyE6IKYX9PiXjaFD4ke9DALSg69Jnadb+rVB4+FEu6I+rDedVNeew0BgVKgeKmECpxZK9oEeZ9O8i1mvZBcWtz/ru7z7N+nbVijnllVGkLCerkwd6Z1483RzrokqRg6pvZu6er+; 20:Fdfb+0tfxIzklQptMKp+6gKG2Z9vUo2aHT99xo/lBCSuYGxt1RJEuxQA6y0NVt9Vk2ZJWJ6mqXqx0O6OTtWjiZDj7fW9tVWngzjINk+y5/rBfyAo/+YFpaa73uhRucE+B6JtznBoHJJpAwtCvCv/mxmmH5XQ+LmicZKla3qVr9Byp2FxiWW/BAf/bhk12QLqfgz1tUBvyYcvPncKJQGV3qA+GdavRyCowpNMmlW9eBdxZlArExWiirYx4BZswyru x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 65314ab2-4bd3-484d-1e9e-08d593935514 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR1201MB0206; x-ms-traffictypediagnostic: MWHPR1201MB0206: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(767451399110)(217544274631240)(1553240931313); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:MWHPR1201MB0206; BCL:0; PCL:0; RULEID:; SRVR:MWHPR1201MB0206; x-forefront-prvs: 0624A2429E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(366004)(376002)(346002)(39860400002)(199004)(189003)(13464003)(7736002)(3660700001)(110136005)(5250100002)(55016002)(6246003)(6306002)(86362001)(9686003)(2201001)(3280700002)(53936002)(102836004)(316002)(186003)(486005)(486005)(2501003)(6506007)(25786009)(229853002)(2900100001)(66066001)(26005)(53546011)(5660300001)(39060400002)(76176011)(2906002)(478600001)(72206003)(446003)(99286004)(68736007)(14454004)(966005)(81166006)(97736004)(105586002)(106356001)(74316002)(7696005)(305945005)(11346002)(8936002)(3846002)(8676002)(6116002)(81156014)(33656002)(6436002)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0206; H:MWHPR1201MB0127.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 1aEsW/tl3FsQBYlmBO/t0QE41ZwNJpmnQtIABa0/UbfZsCS6pZNXkmAVJ9YZ0m9DFhWeZ1FMMOpvLJX716dVWuE9gkrtz1Emh3kbhlRXTN6cxrNjgehfMpj+7lpHSoPCLceJgtGJ6Tj/pu+TbVJ5lH5OC+2ONeUezsmuMExgrIFM3tiQ38GegvumATQeSeI30KWcf6hvQL5S2FVMXC0OcIgWBUpl1ffau0I09KCL8/Nos/Tje2E5zwPMZtZu1D4BAK2fspBYMSnLlBlRZPuJXaoWnco48Je3CyoJgsxsBfgVjL+cy1SW6kcTfaA4cFYrSoPIkyNm30jxKv8aH9inyg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65314ab2-4bd3-484d-1e9e-08d593935514 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2018 03:32:13.8400 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0206 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Roger He -----Original Message----- From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf Of Christian K?nig Sent: Friday, March 16, 2018 9:21 PM To: linaro-mm-sig@lists.linaro.org; linux-media@vger.kernel.org; dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org Subject: [PATCH 2/5] drm/ttm: keep a reference to transfer pipelined BOs Make sure the transfered BO is never destroy before the transfer BO. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) static void ttm_transfered_destroy(struct ttm_buffer_object *bo) { - kfree(bo); + struct ttm_transfer_obj *fbo; + + fbo = container_of(bo, struct ttm_transfer_obj, base); + ttm_bo_unref(&fbo->bo); + kfree(fbo); } /** @@ -456,14 +465,15 @@ static void ttm_transfered_destroy(struct ttm_buffer_object *bo) static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, struct ttm_buffer_object **new_obj) { - struct ttm_buffer_object *fbo; + struct ttm_transfer_obj *fbo; int ret; fbo = kmalloc(sizeof(*fbo), GFP_KERNEL); if (!fbo) return -ENOMEM; - *fbo = *bo; + fbo->base = *bo; + fbo->bo = ttm_bo_reference(bo); /** * Fix up members that we shouldn't copy directly: @@ -471,25 +481,25 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, */ atomic_inc(&bo->bdev->glob->bo_count); - INIT_LIST_HEAD(&fbo->ddestroy); - INIT_LIST_HEAD(&fbo->lru); - INIT_LIST_HEAD(&fbo->swap); - INIT_LIST_HEAD(&fbo->io_reserve_lru); - mutex_init(&fbo->wu_mutex); - fbo->moving = NULL; - drm_vma_node_reset(&fbo->vma_node); - atomic_set(&fbo->cpu_writers, 0); - - kref_init(&fbo->list_kref); - kref_init(&fbo->kref); - fbo->destroy = &ttm_transfered_destroy; - fbo->acc_size = 0; - fbo->resv = &fbo->ttm_resv; - reservation_object_init(fbo->resv); - ret = reservation_object_trylock(fbo->resv); + INIT_LIST_HEAD(&fbo->base.ddestroy); + INIT_LIST_HEAD(&fbo->base.lru); + INIT_LIST_HEAD(&fbo->base.swap); + INIT_LIST_HEAD(&fbo->base.io_reserve_lru); + mutex_init(&fbo->base.wu_mutex); + fbo->base.moving = NULL; + drm_vma_node_reset(&fbo->base.vma_node); + atomic_set(&fbo->base.cpu_writers, 0); + + kref_init(&fbo->base.list_kref); + kref_init(&fbo->base.kref); + fbo->base.destroy = &ttm_transfered_destroy; + fbo->base.acc_size = 0; + fbo->base.resv = &fbo->base.ttm_resv; + reservation_object_init(fbo->base.resv); + ret = reservation_object_trylock(fbo->base.resv); WARN_ON(!ret); - *new_obj = fbo; + *new_obj = &fbo->base; return 0; } -- 2.14.1 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 1f730b3f18e5..1ee20558ee31 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -39,6 +39,11 @@ #include #include +struct ttm_transfer_obj { + struct ttm_buffer_object base; + struct ttm_buffer_object *bo; +}; + void ttm_bo_free_old_node(struct ttm_buffer_object *bo) { ttm_bo_mem_put(bo, &bo->mem); @@ -435,7 +440,11 @@ EXPORT_SYMBOL(ttm_bo_move_memcpy);