From patchwork Tue Dec 5 01:22:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13479277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84239C4167B for ; Tue, 5 Dec 2023 01:22:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D79A10E457; Tue, 5 Dec 2023 01:22:48 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F5C710E45B; Tue, 5 Dec 2023 01:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701739366; x=1733275366; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=QycBI7Kt9PgTyJxaiH/+LWXtKXKuLCo9OVwQRLqdWtI=; b=gSp6JM2rsgP7JkjG/9Zz4pfsxBaNRI7wjJ+rjwaA8plHTxQm7P3u6uXi N3+bSHqdRoPmJw6YkxgkL+Gwwytvqpd/5FQH4NO2b7d42eZW1VaIBzBKJ 0+6traldpRtdEfBwRLlryHrWoFF/Q4lT161iHVCJraswzVYumWFeBLl+2 KGvXVhOeXArgJTSlDuLws052aRMbl7FJhnyG+vZpD4pYcGneuVjmeFfDa 7brz/rwF739eVQbVManm2QkIUmZnKx5/fVkS7US912gD2SoQEWwPaqQCD SanUrYjuNKwgRsmkKNMEEsLLy1kS9yJLVbsFlamb2CkMuPVBAZhimv72F w==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="393558948" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="393558948" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 17:22:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="12157625" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Dec 2023 17:22:45 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Dec 2023 17:22:44 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:44 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 4 Dec 2023 17:22:44 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7nja0BmgCNTAti3zneL+cpjtBNKMXX15raGYyVQSMHjiy53RAJ5gzBRVCT8aGJDj0skEm536fFXbl9SqBVcVfDWwKtAPneAg+I7Onr6Kl0DIQCoNjZnzeoqiHrmztfHabeJSSfbVchn5ibj4KmPE2N3+qoX0m7WvxgvcR84IfWav/UA4t+MKvyKc8qGqXNsJwrRtO7M27dUM51uVfA+n7c6ANmv/yp8x0cetm6Mvtv4G4DT2O2IDiJ+fwF0XxsdvOr62BJDk518uITS92/1DMaSiVxlPk2MiUwa3sGKvNsYES0cMoxLt00CchJq4PXI/ntxwra4cx31WUtaS7RdtA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZmFrd6XZVfmcX6t5o754wGjAQjnYdG1Cx10L3HP9BJc=; b=Q4EUpqX6kWRLGuvt3/KUYwyGKQvU0YLyHf6vhlm6XVXnKDn0x6U2UbWkxKrPbR69jjFb+QhTqvAPq11DVcQ/15j5lYd6HMM87Vw4LvazkSGP36DkLhBTsPYyiBpx9xSpGVaJaMu2O9A7LW6V8kTS5FR6wqohcs3RWumJ6BDRvV+6oEcUEegq4XWYTKDWe2tJ68Ra4QV25yyfkzQtcMMu0TS7kR2xFCnVl4keOtNWRbLYBqJTPud3xlDKayGxmtqEGJxCyPrUSuNZZZUuILYX5qpn1Tctr9vjyAf18x9F0Dh4OXEADFU/mEMKFG979O+dg0GHBKC/LD2j+/WMTOgpHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by SJ2PR11MB7618.namprd11.prod.outlook.com (2603:10b6:a03:4cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33; Tue, 5 Dec 2023 01:22:42 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821%4]) with mapi id 15.20.7046.033; Tue, 5 Dec 2023 01:22:42 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v2 1/3] drm/managed: Add drmm_release_action Date: Tue, 5 Dec 2023 02:22:08 +0100 Message-ID: <20231205012210.1491532-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205012210.1491532-1-michal.winiarski@intel.com> References: <20231205012210.1491532-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR0P281CA0001.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::6) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|SJ2PR11MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: e817bebe-8eed-4671-5363-08dbf530ad58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6bu8NWCaOVbUsb+fY2BiwyUXmPvzdaTUEEBFzyra2XZI9GpXJFgor9Ri0/94RpgF1PaPrtuH8NLbpcV1lWZ6JhLbvkLDbU3hjTGVlHcyPtyNqlZbntv5aEBSkMusb5y7plI979DI0wkC1dTzytrty1Zb9jfQJAu2DrB9GknL5jdk06nHZ74xEe81NuBTxUtc4DKor/Ho46qyhMPhfFhQWv6h6OYXkkgxAFTTXK5cmc/kV29U3jtUbz5dMoRfkxaplbOcLv5P9wZ8YtHHecSzUIiRsDDh6PYC4v7PmIN/t5GonaEgy0uHB8heJHfoVsS30ipP8i5GkNeMepHDIXcwCVioBTWPelVASCmpKDKY8VqMVSEdKPrz8S/u45yz4D4Bha0s+kL5I4FFtuh+VWCJVVVAjIR4jgCL+usv1AoLivs8rF0fMjdHE6XlCIQc1aI4gHrJfxCQSu0CoZ6Zx3KY2Sm9x6VbzJYQTwUnbuHthIrbIHWfUupFBu3PAobRiXismvNl54WxEeeGxA0YASgOkoaLafiFO4wS89lQTp3ZbmXlkXU+asG9BuB8fBiRXaj9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(396003)(39860400002)(346002)(376002)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(5660300002)(86362001)(4326008)(8676002)(8936002)(2906002)(7416002)(41300700001)(6512007)(36756003)(1076003)(6506007)(2616005)(82960400001)(6666004)(83380400001)(6486002)(478600001)(26005)(38100700002)(316002)(54906003)(66476007)(66556008)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FXfWYd/UXCAsyix+EBirta8DfilQ?= =?utf-8?q?P5VTwaaP6wblnWppQcyrUP0BE5/RZ6wxgRyiK6xSci1PZIqXIzgzjX7xzr/GTxZ0P?= =?utf-8?q?NBmSsfbn5O+Noy4G9rFSIhGLiDrJuTb5KgBxQI5wz3YzxMM1LbjzuvIbrS7XRlSRW?= =?utf-8?q?36vDHfBspuPVrsvqlmd4G8Z4cf4vQQoqw5HQvEi0BwiYa6wBncqXKOmZhuIcWLWxs?= =?utf-8?q?96Ami4TK2Hiua2+d/Zxk2rnC13f01B+tnky0Br47pdGJpqhZ0BoXrrMzoRFYjcU2+?= =?utf-8?q?ljyxHgtyeategxTQpYWLdDogju/R9DZCi0wgQd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5WRkN4wcnn?= =?utf-8?q?QpZXXt6ojc/dmY7RWYkiYWVDMoL3Z5Vv/hO/LaFO1r4qI46JQAKtKZpoLkudD6prE?= =?utf-8?q?OseebuOrrzz63CV/eppR/zzWuvlFt+XP2iOLh+Lc43/Dr8z5dUcAgU8T547SuqlFe?= =?utf-8?q?ujygiLunvA00+PL61T+Ll6h5hqHPDarpc5WLJLaJmpFndO+dzXP7qPgUJ/WtUuy1j?= =?utf-8?q?L9P3IBFkbTAlf7hN3gaeVaDJ4RuP5cgR8oAovOls/kZ0U9yhxNmqtwyUy1dfpM6XL?= =?utf-8?q?z2JAcMHKeH0jT/aJTbH4j0tnHgX+yR9qkzk7rT7vPcPXZPHQXBHdcwBjf3jtO9+yE?= =?utf-8?q?nph0efITcW4xQIo1f2c/gCRD6RLgJ1Y+UQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e817bebe-8eed-4671-5363-08dbf530ad58 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2023 01:22:41.9900 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: stmUWHLHEIj1LzVZW/RIG/Xc/pQte28+MPBdEtctp5RaHGOelqjQIONDUBo9UrCTwMnNrd5/fKP9pkBUfYKoFoqK5e4FKj0jeJzD7GFa1Lw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB7618 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , Maxime Ripard , Thomas Zimmermann , Rodrigo Vivi , Michal Wajdeczko Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Similar to devres equivalent, it allows to call the "release" action directly and remove the resource from the managed resources list. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/drm_managed.c | 39 +++++++++++++++++++++++++++++++++++ include/drm/drm_managed.h | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c index bcd111404b128..7646f67bda4e4 100644 --- a/drivers/gpu/drm/drm_managed.c +++ b/drivers/gpu/drm/drm_managed.c @@ -176,6 +176,45 @@ int __drmm_add_action_or_reset(struct drm_device *dev, } EXPORT_SYMBOL(__drmm_add_action_or_reset); +/** + * drmm_release_action - release a managed action from a &drm_device + * @dev: DRM device + * @action: function which would be called when @dev is released + * @data: opaque pointer, passed to @action + * + * This function calls the @action previously added by drmm_add_action() + * immediately. + * The @action is removed from the list of cleanup actions for @dev, + * which means that it won't be called in the final drm_dev_put(). + */ +void drmm_release_action(struct drm_device *dev, + drmres_release_t action, + void *data) +{ + struct drmres *dr_match = NULL, *dr; + unsigned long flags; + + spin_lock_irqsave(&dev->managed.lock, flags); + list_for_each_entry_reverse(dr, &dev->managed.resources, node.entry) { + if (dr->node.release == action) { + if (!data || (data && *(void **)dr->data == data)) { + dr_match = dr; + del_dr(dev, dr_match); + break; + } + } + } + spin_unlock_irqrestore(&dev->managed.lock, flags); + + if (WARN_ON(!dr_match)) + return; + + action(dev, data); + + free_dr(dr_match); +} +EXPORT_SYMBOL(drmm_release_action); + /** * drmm_kmalloc - &drm_device managed kmalloc() * @dev: DRM device diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h index ad08f834af408..f547b09ca0239 100644 --- a/include/drm/drm_managed.h +++ b/include/drm/drm_managed.h @@ -45,6 +45,10 @@ int __must_check __drmm_add_action_or_reset(struct drm_device *dev, drmres_release_t action, void *data, const char *name); +void drmm_release_action(struct drm_device *dev, + drmres_release_t action, + void *data); + void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) __malloc; /** From patchwork Tue Dec 5 01:22:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13479278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABCC6C10DC1 for ; Tue, 5 Dec 2023 01:22:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0897610E45C; Tue, 5 Dec 2023 01:22:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 97AB210E459; Tue, 5 Dec 2023 01:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701739369; x=1733275369; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=fjOvoKoE7FoYZU8Y5WeV6FhrhaR4HqmgoZB73ZCk9u0=; b=EgIKtLAKZriE4axa4A0aPNuZO7YirsUGmzPAzwO4iLiqraEgh5ps1yaT d+J/y62qTLuHKHI8LadRD7nbiYywvaI4+Vy2e9f/KDImriSFgELyuWaNZ 2jrWUIIs0AuX8mGQJc45hiXii+L55Pc/zxxak2gdShCKOg5ehCKdTV7af av69knq0oulZikVvqKYkYzzbQ6t7YQXSq5TASkDFocUa1hayleR+rF7Ab vIDsJzDKDk4EaCeFCg3KioVk+afXLVXeYj/9bf3qH8FUJhhJ4HYD2QlFv hPbCqXPyFum9Oa+vhCq3T5YyE0kSlZ2m95oEXVtac4rG8xD87Z23e2qkz g==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="7151574" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="7151574" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 17:22:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="841256618" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="841256618" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Dec 2023 17:22:48 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Dec 2023 17:22:48 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:47 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 4 Dec 2023 17:22:47 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GL/6cWlbCHSBbsAnAPY3+TILqVezCWHwnhSoC+bm9mCaZjdnlBJ5iJAibWdmQMbNuJQpEpmvYObxIHkteXNHhZIZnK5fVfq3YTEWOXz1TMHIYB13K3kbWaIMzpeX5T876v8ccEQ9sEIdCdA4vZ4KDert2Qw+f0+nFZbd/bRDTXbwP9Ilp6LAM6Txe17Xg0mBH0dug8plDPZvd/PkSYqaklDddzTU44OHbv5UHGPY+udVhAkm/zQ2EscHzvGtfkRpPZomQoc/dPSxUhz7jEPLAU0cKSJJCHhvZq8mjEFJ9w3dypcbiIIIUGrMxtfq7vfNtEkRsMXShLICqqZJsiuUaQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k2D/ATJrcGk0fCVN5kw/QrKrkOcarnok80rueSo9RRk=; b=nxTWTbVIyi6lH+J3EA+Tesh3JgFLs8JtBYae992uDfyCqydg4AZ3lAaWi1r5V8kTc2zIwGXzW9RVypuXHqpq/QgimXpDCzyTRnoDFD5u+RO6ptPBi/QkQonvPOdNO1hX0FLPoM9NotJOF8Cu+BPMZqOiOqzSmFgnfH9xTinpFqb73cl30btDUZcVmg/i/NSritt92I60PHrL6bi5B0126VcVJq15y0EgIGEgoqkzRo81aINsH3n2i1u31JLPsUJi2TPOkFX8JDc0bPaEPMa/Uex0xjc+bJJPYEI900YCe2h9vVFtPBEczTTpk6sZoydmGlJlBeDX/lPEyJQsPhFwqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by SJ2PR11MB7618.namprd11.prod.outlook.com (2603:10b6:a03:4cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33; Tue, 5 Dec 2023 01:22:45 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821%4]) with mapi id 15.20.7046.033; Tue, 5 Dec 2023 01:22:45 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v2 2/3] drm/tests: managed: Extract device initialization into test init Date: Tue, 5 Dec 2023 02:22:09 +0100 Message-ID: <20231205012210.1491532-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205012210.1491532-1-michal.winiarski@intel.com> References: <20231205012210.1491532-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR0P281CA0067.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::21) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|SJ2PR11MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 4de0bfa0-4a5e-4d13-a688-08dbf530af88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VJUE+rlFvwU86Bs8nmF95SHEpB3vBL/EbYUr07wxeikmsbqsozyAszIytO/LAsC1F9L72U0y4naOhqIV6xnADm3lUF4vaNdAj4bAc/hjJIeXb2xkIJbNSdqITpSMEIc4BrTQtQsx5Il7uWNUNyx20ui+ksSebHayb9ms3fplALEbxH7PuMIJUdj6VLOX+O1myQYfvBO6aY5w5L8oXTGRpbpr/l83OoFki3zChRBAdZBrSaDHqi+epoMR/koVt/X1wg7Qdax4RdK/Zi6cbx+s0z2GKaGr4W0Di8gHSpKuq9ftAVCuyTUlLINrhcKN6a7gO/dNnnleycXP6SnYFOrq2vEL8r1/PSsWX+zlMwjhujLntTUdPg8qr4rckPP6CHuv7oZnR/X5uRVPUz+7sieick4atENO7nDq9BRk4ZQjXXhTbCCOFs8BIRzr9eTT/Pm8MWGWlyjYF1qf5dybQm8vmAgJCUubNBS4ZxpVLT7X+e/IYtsel4UUNI40LLZGUjiHQ/ai73zh+oClgCTtfEHtlsQT9S0H79T21NIQjy0yXOTu7wMuNTWnEjKd4mowfebT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(396003)(39860400002)(346002)(376002)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(5660300002)(86362001)(4326008)(8676002)(8936002)(2906002)(7416002)(41300700001)(6512007)(36756003)(1076003)(6506007)(2616005)(82960400001)(6666004)(83380400001)(6486002)(478600001)(26005)(38100700002)(316002)(54906003)(66476007)(66556008)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?YB30VFif/UPEBevrE4KtifzN6dnq?= =?utf-8?q?i+q3Syr6vPKsgzH3vqO955ak7ipaPNJN/Z7Q4Of4naH8g2k4kyQJ6gA1IHzYUNmvY?= =?utf-8?q?VTG40c6A1lfg4YaoV1V5pR3QAAayFJLOywAB8LOKuV3s1458rrjjBXWkpJNgJMEUH?= =?utf-8?q?rJgdCQ34H21u0fWXB9p1GJyi3aI+jtzqBiav0Glg6va5Qj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SdnHJAw8DmaSzL?= =?utf-8?q?KRsNiAHP7ASYWEznmuh2YMttKrkZBZSzlNJ1j0mmlFWf5VfuvNOxndUsn1voWOxcC?= =?utf-8?q?xDrhhipbk/L+92X/1Tw1WxJKqe5movTmPQsW9whl148vW0gT0JGtF0958cBx4TdDt?= =?utf-8?q?v0jmoIhAr67XYLdEI6Wi57ctyTkTesU6OKiDm6Kj/9DcREnji3lFsbGB6zLdVAM9G?= =?utf-8?q?5GUmeGcUv+/K4ZPo2Tc+OCpS/xLS1fq5dL4wljcnSNEEMAEGLwqEJg0SmGG9EWzOI?= =?utf-8?q?9RTmoBR13ZI+6z40+iaQ4fEKY6ZK8kp0r0T9Sy+BMKUy1xKRPdGHPAJnHrN9xsAf6?= =?utf-8?q?QoPNbH5aF07sPh/oSbRjRgsPWT1nkNasfTsxZjvBWDqcOh3V2RtPslA7omBN4Qn2G?= =?utf-8?q?i+776uMzQmOw/WeBrnENIcYvYxjLF287pKjK1dhwf98Sgz4QOthPfJuKrHzXbv613?= =?utf-8?q?2/r1v3KTscSH0ICDaf3hHDqvkaaDCaiXxA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4de0bfa0-4a5e-4d13-a688-08dbf530af88 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2023 01:22:45.6560 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gH16Y5fcsXL3NE3EBKP1Qdb//yY6cjYY+I84G9XYlD6YcB6QAeaa5dq68K1VOfpqjYA+OfubnG6GO0ib0pFMKo0NvngrCM+IU/WR/7EO+ro= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB7618 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , Maxime Ripard , Thomas Zimmermann , Rodrigo Vivi , Michal Wajdeczko Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It simplifies the process of extending the test suite with additional test cases without unnecessary duplication. Additionally, store drm_device inside priv to simplify the lifetime management by tying priv lifetime with parent struct device. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/tests/drm_managed_test.c | 43 ++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index 1652dca11d30c..cabe6360aef71 100644 --- a/drivers/gpu/drm/tests/drm_managed_test.c +++ b/drivers/gpu/drm/tests/drm_managed_test.c @@ -12,6 +12,7 @@ #define TEST_TIMEOUT_MS 100 struct managed_test_priv { + struct drm_device drm; bool action_done; wait_queue_head_t action_wq; }; @@ -26,35 +27,42 @@ static void drm_action(struct drm_device *drm, void *ptr) static void drm_test_managed_run_action(struct kunit *test) { - struct managed_test_priv *priv; - struct drm_device *drm; - struct device *dev; + struct managed_test_priv *priv = test->priv; int ret; - priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); - init_waitqueue_head(&priv->action_wq); - - dev = drm_kunit_helper_alloc_device(test); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); - - drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm); - - ret = drmm_add_action_or_reset(drm, drm_action, priv); + ret = drmm_add_action_or_reset(&priv->drm, drm_action, priv); KUNIT_EXPECT_EQ(test, ret, 0); - ret = drm_dev_register(drm, 0); + ret = drm_dev_register(&priv->drm, 0); KUNIT_ASSERT_EQ(test, ret, 0); - drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, dev); + drm_dev_unregister(&priv->drm); + drm_kunit_helper_free_device(test, priv->drm.dev); ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done, msecs_to_jiffies(TEST_TIMEOUT_MS)); KUNIT_EXPECT_GT(test, ret, 0); } +static int drm_managed_test_init(struct kunit *test) +{ + struct managed_test_priv *priv; + struct device *dev; + + dev = drm_kunit_helper_alloc_device(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + + priv = drm_kunit_helper_alloc_drm_device(test, dev, struct managed_test_priv, drm, + DRIVER_MODESET); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); + + init_waitqueue_head(&priv->action_wq); + + test->priv = priv; + + return 0; +} + static struct kunit_case drm_managed_tests[] = { KUNIT_CASE(drm_test_managed_run_action), {} @@ -62,6 +70,7 @@ static struct kunit_case drm_managed_tests[] = { static struct kunit_suite drm_managed_test_suite = { .name = "drm-test-managed", + .init = drm_managed_test_init, .test_cases = drm_managed_tests }; From patchwork Tue Dec 5 01:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13479279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 762DCC10DC1 for ; Tue, 5 Dec 2023 01:22:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90E7410E45D; Tue, 5 Dec 2023 01:22:56 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A0BD010E45E; Tue, 5 Dec 2023 01:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701739373; x=1733275373; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=aRifm0Me2U9O34n/oQ6CPrUSgbLhIJcV5MtRX1vCz74=; b=T7wkc/5kmGCc1QZDsbX2CqPnTvpnCaYpRviC+K1A5a5S1d++py1WGXpt s29i0QWd4zrUbpQv5A5gA2+3QjcPMi05jxe/E2q5EO7zf1f0DQuaHx8Iv rX320gyKfgG5idChgFWRiy+h+N09DNOZklQ13vL/aXW7Ro9T3mYGkYOXN XOcSjY+O3byLMMPoUETfuj7YcffOzf0VWJNDMwSVRcCgrHyVyVdMjZzSb t3E3bpwiOva2V+Z28c77PvC922q0HBp+pWGTYg8+efWEa1pBNlGKJ7hl0 c7iLHyJVizhjFkFtxLsXhnS8YsUvj6hIKEpS2zPjjYZhR+WTxCj5HmNfL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="458146050" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="458146050" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 17:22:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018040896" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="1018040896" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga006.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Dec 2023 17:22:51 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Dec 2023 17:22:51 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:51 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 4 Dec 2023 17:22:51 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 4 Dec 2023 17:22:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1mrqQTcMWCbgqEsGrMI4XeId8fBDo9oaFaGbc48kE+FBArWwh7VQwpegft8+tgB2BJHaabNTPV33X4Lzc+H/qntTakLGC3hDKs8WOmkbgmN/YXzVrOTk6meMiQ1ybsvyaItGAck9iXZ9N0PXFBdiuxRXdQtCuklbrjrRRhEcxbZBzZVIOcvSeodJUwuat4u3hS4V/mfaycRedWtaFiWqlRWNPO5AnDULWaJm/K7S+3ithtIVJFo047FmXuDurvmq1InntHPD8d4cRJFcU320XS14/O81uFsHBbF+NDF+cROMwB42oX9PFWl4aFAKl8Q2Xr/u/LJpEvA/Wctjs1hiw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n1D1n6oGDS7l5jbHFt+IJ4EQ8qlpb/zPM56IAVknpNU=; b=hABGpGVg9DIAkPVwVFAIxrCPhb80WDoL3EGY6gc6R1Iu0sq9IYkj1NlTN8222utlI1bCZnBRM60PqcINlHpWulCK6gJAJQg6tKrdm6aE7IiPIOVhFfXPocVjpkUa4+tdMT5rrvr0aFQfaT1TZ7vBH01Rtw1L+TM0yjjImahwTH2cAb9NqrAdv2qz/U5ZIpHK6Aw9GlRs/MpmqUgbGDejCs1qIRjsuGfZb0D9qvBe5B/hKqvp1QyOtLAuSf3Z39y66gSfvec1E7Ex8T4wLycjHCWyZ5a9KN12trtf/pbhS3qT38+BUt1Gimh9T8t6hItTruHLxD8u3xac5YSLTmCImQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by SJ2PR11MB7618.namprd11.prod.outlook.com (2603:10b6:a03:4cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33; Tue, 5 Dec 2023 01:22:49 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821%4]) with mapi id 15.20.7046.033; Tue, 5 Dec 2023 01:22:49 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v2 3/3] drm/tests: managed: Add a simple test for drmm_managed_release Date: Tue, 5 Dec 2023 02:22:10 +0100 Message-ID: <20231205012210.1491532-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205012210.1491532-1-michal.winiarski@intel.com> References: <20231205012210.1491532-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR2P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9d::15) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|SJ2PR11MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 37c54863-bea7-426b-e709-08dbf530b186 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o2q5ZPRgVk3sq4iNySsObK5bgo4ettvskfnyrQIi0EknTYI4d5ZnPSRkEkU+0A0yXDdrtUEIvhi+kSOIKhTQrzSw8A2VELvDE3ApuxQXPFAYPQ6nheVYGmwlg4qzUT+D6iid10rEhoM67+2aCiDT/4EYHizuRworW8nhVriFuvnoB/J/x7Xq98G4EbxlCKYKtJ/UAXH7j3F9EPAl13UiBvcH52tiL0Q+BHVtyiFDa37IKFysz4Q61bFpNICuoTgYtWh4DEO7azzYNYW2OY7IMMmv+At/ARJmxPjp4ne357a7Pkjsqj1ueUO2p54pPu22oVd01uCn3oplLlh4bmZTSq4RW1Bm9CaRV7dEMksYoEiA9utbUI4YGlrHN/cbyaVkLC0HC6oZbGc8IsYqrEjjVMTHWJZcboRKRSI8rIsn7zccAHGx7lKW35/fcRUFep/KKSSnSHS9uPOGI70KOu7faMjW7jMzrpUGn2TAQSqUnqfogaxTodl1pMppMgi+iCvCyONjJPd2l89m3gOCt/OXtUIdV42CVw2Q0Li7hVK11WzhRZrKy6snHRXdUPuCo5wZ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(396003)(39860400002)(346002)(376002)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(5660300002)(86362001)(4326008)(8676002)(8936002)(2906002)(7416002)(41300700001)(6512007)(36756003)(1076003)(6506007)(2616005)(82960400001)(6666004)(6486002)(478600001)(26005)(38100700002)(316002)(54906003)(66476007)(66556008)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yF32LTE+q3ttEHapaWQqNdNK1uvl?= =?utf-8?q?mGsZTcYGx2mDKtBI+mJkKzh0ly83vgVgnjAljWbITGGvMlOr76YklYIZponoDRObJ?= =?utf-8?q?+1X8OED7trL5e9WaqvO1sAqVPlbXmRaoCCE4AAnmY2uYpdUQvnZWdp5dPubDIsOYf?= =?utf-8?q?eilXjwirMeDb9ecv8LUHvL72+pH1G/3+0dp1UUOM6ugI9BDyMZ/euMfbc+xNXqBMb?= =?utf-8?q?pv4mo8c7xoXHEfKxAXcIA2kDNMEc8c82V0G50XxBhzap5RGmiEqBBZVdMLeTPpJXy?= =?utf-8?q?MZ+fBXflNbgb44lUVxmzsTwb1d0jowBu/e+bnPER5WB2YSLV62uthaBSnuX0xH0Xj?= =?utf-8?q?W5ioBIl2KPjdkvGf6p8J1gymYeo8nEV9PsEpPR4IqsVXsUGA9fyptw5OG/h9LjJ0a?= =?utf-8?q?5R7OFrecCzELNRqkSTsD4/Rb7Ic5fBq1fzqf5dTQKGR4rcqLiUYMGZb4AouFTx8c/?= =?utf-8?q?uX2xJqmq9ll3uTaNu27qn6qaJlzX0s/yFHfjkfphokCxJ+dn1is9fdqlYPxMPbfOP?= =?utf-8?q?j4CruDplUgLKqkgHzDA3YBHWRXVttrD3nvqprnX2YH6sNpaiRKJOXg9sD8QMlrZ0Q?= =?utf-8?q?bQmrX5rYYpPBhh6P5EpFTWv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nMyPULZx6SQ+TaNl5BrdY/afG8rrC/zaEQiZF/QqgzqN0?= =?utf-8?q?sjMwD9YmrruPnpvVBQ6YChwS6cwyKzRR/g=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 37c54863-bea7-426b-e709-08dbf530b186 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2023 01:22:49.0966 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iPnLs9LdKvrfZ8a4qa0Ub3JCNZ3PyW6Gq1ZiXntJlrCMXZA+VIR9FlOrwIBYF8cAeOgTiEXCoWKhbuG04LaoZF4zSxeWHyyB1frvIdc3HVQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB7618 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , Maxime Ripard , Thomas Zimmermann , Rodrigo Vivi , Michal Wajdeczko Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a simple test that checks whether the action is indeed called right away and that it is not called on the final drm_dev_put(). Signed-off-by: Michał Winiarski --- drivers/gpu/drm/tests/drm_managed_test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index cabe6360aef71..8dfbea21c35c5 100644 --- a/drivers/gpu/drm/tests/drm_managed_test.c +++ b/drivers/gpu/drm/tests/drm_managed_test.c @@ -44,6 +44,29 @@ static void drm_test_managed_run_action(struct kunit *test) KUNIT_EXPECT_GT(test, ret, 0); } +static void drm_test_managed_release_action(struct kunit *test) +{ + struct managed_test_priv *priv = test->priv; + int ret; + + ret = drmm_add_action_or_reset(&priv->drm, drm_action, priv); + KUNIT_EXPECT_EQ(test, ret, 0); + + ret = drm_dev_register(&priv->drm, 0); + KUNIT_ASSERT_EQ(test, ret, 0); + + drmm_release_action(&priv->drm, drm_action, priv); + KUNIT_EXPECT_TRUE(test, priv->action_done); + priv->action_done = false; + + drm_dev_unregister(&priv->drm); + drm_kunit_helper_free_device(test, priv->drm.dev); + + ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done, + msecs_to_jiffies(TEST_TIMEOUT_MS)); + KUNIT_EXPECT_EQ(test, ret, 0); +} + static int drm_managed_test_init(struct kunit *test) { struct managed_test_priv *priv; @@ -65,6 +88,7 @@ static int drm_managed_test_init(struct kunit *test) static struct kunit_case drm_managed_tests[] = { KUNIT_CASE(drm_test_managed_run_action), + KUNIT_CASE(drm_test_managed_release_action), {} };