From patchwork Fri Jul 19 22:02:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 11050663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28FF7138D for ; Fri, 19 Jul 2019 22:02:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B0F02873E for ; Fri, 19 Jul 2019 22:02:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F75C289CC; Fri, 19 Jul 2019 22:02:17 +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=-3.7 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 BB4DA2873E for ; Fri, 19 Jul 2019 22:02:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 764416E872; Fri, 19 Jul 2019 22:02:08 +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-eopbgr740045.outbound.protection.outlook.com [40.107.74.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BEB66E86B; Fri, 19 Jul 2019 22:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKW6tr8wVKS2UiIuuCQpk/TiZyeFQwWqFeb1CkQlC5IJIbjkfeV6fz95TWFyDITPOzcymOgVP29NmgPSFFNMqRiZcRNEw2u9UG7zeThJ2k8VkoGYerwB83w+jijrGOARyVVNUoDrBptULdW2FO0hwIzkhjU9o3urfN3l5cyWIfECWnDt2PIFry151R7VyVMAPgS86OkDJ5vTCJK3/kD9iirnGSxsxMJkkWEECegcm08ZD70nMap19LBBqykWfWylUc95fmtfYTK+Worm0m4aZbdsRBkETl3xltNwhl9AQMlPfH0XIXCEMFXzuhiD+H4qkAXJQTZ7Z/F4bsJgH2LK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FwOILOlrBvqJLknF7lig/bNDv35Zf2YXs3eje1W5fc=; b=dCao3Xa7TotXHP0tyxmZ9p8XnOdlyHiqwtBaMjyi9zvlXzZcbpXtba+Qcq/enF6NmBgFZD7TrVVEMhbO2w6/KxtMhvjoaf/djwJhHctPe/zMV7adcUciFmrnqWuMAVMicOhHeb3LVDrSS3Ma/d02kE6ghPvOwuPQ4rl/1VgaipeR/7M9jxFte5QfNxvpPz+LzNgePZVCfNiUF/2WCZ36IwvOhd2/R/NRX24Nxf+7o8irFCabK+n+u1v1HDn2s3tDNAhVUU1mIiVwV3RxyffHTQOBacmGeJqFaGTeJVDFvvY/zag4mL5f2DCRNkQ8sQgjUhp34CRxJi3aEsvgG1idPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none Received: from DM6PR12MB3947.namprd12.prod.outlook.com (10.255.174.156) by DM6PR12MB3915.namprd12.prod.outlook.com (10.255.174.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Fri, 19 Jul 2019 22:02:05 +0000 Received: from DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927]) by DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 22:02:05 +0000 From: "Kuehling, Felix" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" Subject: [PATCH 3/4] drm/ttm: Add release_notify callback to ttm_bo_driver Thread-Topic: [PATCH 3/4] drm/ttm: Add release_notify callback to ttm_bo_driver Thread-Index: AQHVPn2Z90vw1Ah1BEWOH9I1DqRQVQ== Date: Fri, 19 Jul 2019 22:02:05 +0000 Message-ID: <20190719220140.18968-3-Felix.Kuehling@amd.com> References: <20190719220140.18968-1-Felix.Kuehling@amd.com> In-Reply-To: <20190719220140.18968-1-Felix.Kuehling@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.55.251] x-mailer: git-send-email 2.17.1 x-clientproxiedby: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:1cb::28) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 06737b02-7cf8-4451-273a-08d70c94bc4a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB3915; x-ms-traffictypediagnostic: DM6PR12MB3915: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(189003)(199004)(66446008)(66556008)(66476007)(66946007)(5660300002)(66066001)(64756008)(478600001)(53936002)(25786009)(7736002)(305945005)(256004)(14444005)(6436002)(486006)(86362001)(6486002)(52116002)(76176011)(450100002)(476003)(50226002)(68736007)(186003)(8676002)(2616005)(1076003)(14454004)(6506007)(102836004)(11346002)(446003)(2906002)(99286004)(2501003)(386003)(36756003)(71200400001)(71190400001)(6512007)(26005)(81156014)(6116002)(3846002)(8936002)(110136005)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:DM6PR12MB3947.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TxQEmr4pPrdkBxQzqoscF8yWC2WpHT3aiKmf86Ba/1oPslEZVDdr4rKG+1iXYIKTDnSzDxi/gR8LE3WG7lH+RBacJAnO7q12GuALp49czP9xcQvpb4L1aW8OpV2joYQYX0ZI1Wnum6uSziAFNbKcXo4cBemUlZ94OE16UYpPwD9cgUsIgsnzPNs7lAm+E05r57MV7TiarTuwoa2orTHTgiZRU4n1FDGIvJYGC86Q/4DfK8NKcs9ew2+ywZG6isoGuYgcVcRDN0blGco1v3MjQZuTBMnRAF2CCLa79JptbLra09WqddkUY2fHs3GXoJVlxc8vfRAfb7VlXcibbhnaTtemZe7+fkc31A1sHHxZv4o+IV80zTIsYapjtbVjJxAeRPRnh2c70+OHJuSbEuqeP7Okez2aiANLu0vxfqCB7UE= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06737b02-7cf8-4451-273a-08d70c94bc4a X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 22:02:05.2012 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fkuehlin@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FwOILOlrBvqJLknF7lig/bNDv35Zf2YXs3eje1W5fc=; b=uLcMt99bzD0Rb2jhoShMqd+GMzrvDkEBYfb4n6wShYQdLGwYN/WDu+iD21OQLcstZne9+rURqciSejwVyU6+0DrckvJuTcTk9shdAhjgaFhNfGokZ17STJ172QE/CdQn9TQbk+JptyhE4hjbZV72tLkjcjgoa2c3do8Djb3AEmU= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.com; 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 This notifies the driver that a BO is about to be released. Releasing a BO also invokes the move_notify callback from ttm_bo_cleanup_memtype_use, but that happens too late for anything that would add fences to the BO and require a delayed delete. Signed-off-by: Felix Kuehling --- drivers/gpu/drm/ttm/ttm_bo.c | 3 +++ include/drm/ttm/ttm_bo_driver.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 58c403eda04e..2070e8a57ed8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -671,6 +671,9 @@ static void ttm_bo_release(struct kref *kref) struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; + if (bo->bdev->driver->release_notify) + bo->bdev->driver->release_notify(bo); + drm_vma_offset_remove(&bdev->vma_manager, &bo->vma_node); ttm_mem_io_lock(man, false); ttm_mem_io_free_vm(bo); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c9b8ba492f24..d69121c43e58 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -390,6 +390,16 @@ struct ttm_bo_driver { * notify driver that a BO was deleted from LRU. */ void (*del_from_lru_notify)(struct ttm_buffer_object *bo); + + /** + * Notify the driver that we're about to release a BO + * + * @bo: BO that is about to be released + * + * Gives the driver a chance to do any cleanup, including + * adding fences that may force a delayed delete + */ + void (*release_notify)(struct ttm_buffer_object *bo); }; /**