From patchwork Fri Jan 26 18:29:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 10186715 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 60F3160383 for ; Fri, 26 Jan 2018 18:29:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51EF4297F7 for ; Fri, 26 Jan 2018 18:29:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466B529BC8; Fri, 26 Jan 2018 18:29:47 +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=-2.6 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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 CA6C2297F7 for ; Fri, 26 Jan 2018 18:29:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7F796E735; Fri, 26 Jan 2018 18:29:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0085.outbound.protection.outlook.com [104.47.34.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 570F36E62B; Fri, 26 Jan 2018 18:29:27 +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=GwUc0m8r0uMxrihD3dPlwJFc5Yg2bsAxO6fGo4F0uEI=; b=IgDooHzqVrFyn67JNEjCIU/KIiy98mY81xq5ZryeN3DfJz2z5UJc8CAKxW9waAjlTtGrxkefjZgF96cBSA9A3pRiD/RK8uHKx5yZ5bb03xLqqipjr8MZHniYcWuSfHa674iCKEzqGzn3Dn1u1Xyv1a6D9IgT0r7kLvt98Nu8DHk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by DM5PR1201MB0076.namprd12.prod.outlook.com (10.174.106.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 26 Jan 2018 18:29:25 +0000 From: Tom St Denis To: amd-gfx@lists.freedesktop.org Subject: [PATCH 02/12] drm/ttm: Add a default BO destructor to simplify code Date: Fri, 26 Jan 2018 13:29:01 -0500 Message-Id: <20180126182911.20761-3-tom.stdenis@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180126182911.20761-1-tom.stdenis@amd.com> References: <20180126182911.20761-1-tom.stdenis@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: MWHPR03CA0027.namprd03.prod.outlook.com (10.174.173.144) To DM5PR1201MB0076.namprd12.prod.outlook.com (10.174.106.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9256164b-48db-4897-c3a4-08d564eabab3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM5PR1201MB0076; X-Microsoft-Exchange-Diag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nukBRZWtNw2lhaBcmwdH6teUirUQ9Bkoi5XE+/ZePD/dRGC/mIfCiRfQfsqZobMiAjFolfvQkLPtVKqSCcWDrPBFYdZJ8b/Fc6UUlGfAHe4+R0CnppEn1/43quUUxc7kBUvXfz7mvDH0an/BKqjUZo193W+FWuwrbfwaBqSUX4j4nDaV0PRmWsq6zFyUyY2TB1OOEitvDwmVJ2Q8ETXBLYLWGN1ZI5Fe137nez/jfAQMmL5h7XwrTIGa4Rc3v9wB55VIJvCwzsDaN6LughuPhWNLW7p645hdEX1mWEPg013CTOPe6capltBuGwYt8Q9ncJ3GE00ThvkHfCayDpDqH4m6OzqaDExI0UGs9IAn8G0Z3Oio; 4:rfaKh6evUTzEGR6noIoaWsGZHuSToZaop7Jxq0Q0tZTt65qBMHCZKyHsMGl9UGXYTIdPtKVk5xeLo4//xdJdEVZdvl6ARBVHl0FkzvER+PO5uzuJF7MtHsVjcYSwZExpkVYJHVivCzoCyANwK41tMw4r/02BgrUdihVwUQOCbjW0ezsex7c9LapS0u0HIABwp9zOqAxaok3SrbAd5IMoPn87n0X+ZJIVxkr7u60CxAitF9/GzqJSMuKfrfo/Ft4XuVASVXwVLeiXg23WDHPljsyFy1Z2idcsWUim1bCQvI/I2wClrHkgP3jL25EI2wGF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231075)(2400081)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR1201MB0076; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB0076; X-Forefront-PRVS: 05641FD966 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(366004)(39860400002)(376002)(396003)(39380400002)(346002)(199004)(189003)(6916009)(2950100002)(6666003)(7736002)(305945005)(5660300001)(1076002)(6486002)(6116002)(3846002)(53936002)(86362001)(51416003)(16526019)(81156014)(7696005)(52116002)(186003)(26005)(8676002)(97736004)(386003)(50226002)(53416004)(76176011)(8936002)(81166006)(25786009)(36756003)(316002)(478600001)(72206003)(47776003)(50466002)(68736007)(16586007)(48376002)(450100002)(66066001)(4326008)(2361001)(106356001)(105586002)(2906002)(2351001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0076; H:fx8.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR1201MB0076; 23:0UcnLimOb0pWMGa9Pg1Meqg+LZKeMY5YYJo9hkZ?= =?us-ascii?Q?bveRDETFwl5lh8poZ9B6R8yRidVzy42DUW/4F9Dp8Iu56cno72uYZePuswbY?= =?us-ascii?Q?mY3e7EQZNdA5jYg6z8UMWLglaIftWoJARPDGhVumWovSrBLhoaAvtnvqv7A2?= =?us-ascii?Q?vgY4846p69euh6rtJ4dX4bo/YLSRh5LKIWszUuuckrJbRdV9wuvUphXHufD+?= =?us-ascii?Q?1v9JNL8n+A7vdailujb2RGv0z6S0e7mobiUTopJI8igjaxc+FbtkDVSKsNA7?= =?us-ascii?Q?mb+MN+lTwsv98jNCiywV3rSboz8aGhJj0MCnDaC6lDblPUmG/uiQlu7PJ+b+?= =?us-ascii?Q?wWLovfkJGXVdg2Z6RUCpo6tZl6Vekog9rRfbX+1BjCLMSD6DRVEoT0hvLQyf?= =?us-ascii?Q?yQGQ6Q7MaMzsQLBDUMcmqrvvDrFlyGYCPKC9PmCt2Xg94Xf2gaNkEVNxKXc7?= =?us-ascii?Q?dWjQd2hrmF8gwDYtbHx2HCamEZ0NoEXliVrqOqUt+4F2zJJcjDWt4f+KR6Eo?= =?us-asc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otNmmYKzzW09dfrOIBOdW+vDF/GQHB/vjcwmncvQum4+rDPox3CpMcbzQ0DbaHaNPBh7VCEr/p6nQKJwuk7eX5bcvB1WNwzneo0B2qfwAjaARSp3yd9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2018 18:29:25.4011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9256164b-48db-4897-c3a4-08d564eabab3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0076 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: Tom St Denis , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tom St Denis --- drivers/gpu/drm/ttm/ttm_bo.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 8cf89da7030d..4e85c32fea26 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -49,6 +49,12 @@ static struct attribute ttm_bo_count = { .mode = S_IRUGO }; +/* default destructor */ +static void ttm_bo_default_destroy(struct ttm_buffer_object *bo) +{ + kfree(bo); +}; + static inline int ttm_mem_type_from_place(const struct ttm_place *place, uint32_t *mem_type) { @@ -147,10 +153,7 @@ static void ttm_bo_release_list(struct kref *list_kref) dma_fence_put(bo->moving); reservation_object_fini(&bo->ttm_resv); mutex_destroy(&bo->wu_mutex); - if (bo->destroy) - bo->destroy(bo); - else - kfree(bo); + bo->destroy(bo); ttm_mem_global_free(bdev->glob->mem_glob, acc_size); } @@ -1176,7 +1179,8 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, ttm_mem_global_free(mem_glob, acc_size); return -EINVAL; } - bo->destroy = destroy; + bo->destroy = + (destroy == NULL) ? ttm_bo_default_destroy : destroy; kref_init(&bo->kref); kref_init(&bo->list_kref);