From patchwork Mon Dec 11 22:09:37 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: 13488144 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 33031C4332F for ; Mon, 11 Dec 2023 22:10:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC0F910E51D; Mon, 11 Dec 2023 22:09:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81D8310E50F; Mon, 11 Dec 2023 22:09: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=1702332593; x=1733868593; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=QycBI7Kt9PgTyJxaiH/+LWXtKXKuLCo9OVwQRLqdWtI=; b=ZsQB41Uv2TMUZA0G58La+butxODjhJbp78bpPrYbZ8tabTmvyB2vOotk BcAiTvpoPI843QP1Yb57sD1G7o4IsfY6cKhq2KG8RhEZXzm3/gWMT0tnl MVMI4XCSf8KUuhReusynyyZvFQYpdwENGx66PISyoxJKZZv4jTdYzgIB6 yhGDG+VCkgeqHF8s4f3kpHJU9qL5jsqSpHQm2lLS835wy0U3JwfoX+F0H W8q5im1uZZbOGb3y5EdBnDHdMckd2+95kgUDyQ5/5iA/MIest39fzhTOf D07P1LLZFUjeHn6gU1F145v4mys2+K8rvlet1aJLYjeQO6x84cZQtM2m/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="425842295" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="425842295" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 14:09:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="14682970" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Dec 2023 14:09:53 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 14:09:52 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 14:09:51 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx611.amr.corp.intel.com (10.22.229.24) 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, 11 Dec 2023 14:09:51 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Dec 2023 14:09:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mMek1QLLsm2FQ7nL/nAUwBNNcjnslX383Y5FkKKRaejNxNTAxpwNzXXZcFWklpotsM3vKpPNrQdMgZ3xHhVrPeZ3Q1LpjGmvg/u/ibi2QUEF6ovREUpsGZ+YGhLfVsFQnXtNR8GcCSOiJMdborP86bgkAMLZ5Q+wUbnoh3HdStIo9j93dR120DnY/1jgCPG0/0ChPBW94ljV37A0gskSYKxORlOSJL3QWvUGEP5cSgouZRwSssPeqn8vwjq2NV9WkYv7HJ5jTc6Imsvvl4z26GMZLFqu16OSh4akSWZ3DNdDZkL9iuhiPp5wpVzLtBlnLcvjPIRu9Rn3vCRo0EVwmA== 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=dhY5U+ttrKvMTGmRiDcyqgREAKaZdQB+4QdWSCPR8XUJuLDKfAGXDNqXVOy0x40djuHXAhNVE0i80jnsPcfoisol4WlT9K/7twL3QXlf/9H7vim2lieo8eZjgfM7foXxsZFZw+IlkZEVfbblK7F7ySm2sXHiAv42jXdaF2uw4kdsX4FMSeeOyXaZNlCuXmqsB2LbTdjyLi2uoTpT6gpajRnRCw/kLpO8CYaWT5lDEJUlwj6DNmGqMPZX4juWltQCP3FbmLmFCRZ/BC4bwlwJvZHtD3jcGi9v2hckiXG4hBQxnP/Y3OJThdVPEN4r2FULrjbW6cRKNhnKdKunYC80rQ== 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 DS0PR11MB8134.namprd11.prod.outlook.com (2603:10b6:8:15a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 22:09: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.7068.031; Mon, 11 Dec 2023 22:09:49 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v3 1/3] drm/managed: Add drmm_release_action Date: Mon, 11 Dec 2023 23:09:37 +0100 Message-ID: <20231211220939.215024-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231211220939.215024-1-michal.winiarski@intel.com> References: <20231211220939.215024-1-michal.winiarski@intel.com> X-ClientProxiedBy: WA0P291CA0021.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1::25) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|DS0PR11MB8134:EE_ X-MS-Office365-Filtering-Correlation-Id: e6877d91-4969-49c2-c793-08dbfa95e452 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QsKub+TJLD1kDng8cKLsmUsitTyoVtHYHc1ruuT414D35W1hNpfqNg6oppEu6FVoF4tAMdXp8k+iG+VqvncgPL6Wk72I6acl5+0b69zT9lxn+YP1rZqAMwANhMVGOKVEkhqjxn2Udjpwi3N71XqRrGnuXLQ6F1sMoXyr62INf0hrvRKurrw/ioeRQL+ywC+YPvm9FFiC7zrFtgmE8rro/IJ18W+Jb6iwEuD1l8AxosnszXB8IDaTQParuKnw9GfUNj9ug0Y8PH42NFh6jwuFArH5Ig+zB32SHnQ3yAcoz8JvpopfNNTsn8rfH7/5ruQJi4tdxbJdX+ustjEkvphBGp19mscD4dAfXtrJNWsXIokimRchmVPbNJ50CSGgm2U7BRuDBvPvANCNw35nRluVx8t+PFL/HSyBcD5Fj+FqmWgXOCNrPIudPgIKduYawIizy90u7ueqVEyuB1YK/cuExpLvIznFypa1/vtfIyEwwg9upNqfl0bmzbbY8cDsemz3t1t8m5ncWINIDDWSNL6DksEMKfMB+nadVCkP1TM38c5V1ALLyTCsmz/mTtR+UK/8 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)(346002)(376002)(39860400002)(396003)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(41300700001)(1076003)(26005)(83380400001)(2616005)(82960400001)(86362001)(36756003)(38100700002)(5660300002)(316002)(8936002)(8676002)(4326008)(2906002)(7416002)(6666004)(6512007)(6506007)(66476007)(54906003)(66946007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GO6/jryLDysyVJI2mKtO8jnusDZP?= =?utf-8?q?fBwKymvx6fY2vHr7aRLnVomfCpV8j2mSyJSmQn7K+i6k11KsTr1M/+C+NaUa4NAvs?= =?utf-8?q?o4vHHXXq0hw2q+Km0OMjF58BTbZIKTaoo6zuWtK6weEh8sDctEOg36bWNJ+ywcUCF?= =?utf-8?q?L5dXHc+mP0m9EuR3xomL4LhTfpOUFiNAN83tiFUcxKrnp+xYOvjIwW/Bc6KFPra+l?= =?utf-8?q?tKSt+y01YddqxKU+JBidzH/LY1n4gQqlxPPl+23xLPWiFpRybnEroN765SS5lJYgQ?= =?utf-8?q?199x34HSRbnfutaWFrJNwFEllHjnwWRAZt3M3bdoxTFbw9cV/x4D2SR/iAPm5APux?= =?utf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Lqs?= =?utf-8?q?asf7uXZzDceBLnQM7FJl2uyKzk0xAFC54ZnNadwSblTg8AlnJD8Cc4C76LiFIkYn0?= =?utf-8?q?xgw61wZin03iRLHkp3pgjmj4Jj1A5E5CVnnicwazF5vRaSik55y/W3/G02I3bXAtt?= =?utf-8?q?CIoLJWi1/PZSMTfzzQdaTV3JmxiRwp6mfT+AW9ZhoDdptmfMtJbj6QgGBS3MVsCXa?= =?utf-8?q?ZSs2oJcveiJi/4CjtZ3sB0N4ySG8jS+J8TCUvolr6Fcb4cY/vXllbVvPvAHnVqW02?= =?utf-8?q?V0jFiS4bJKOYisM5VJovNW43gqPbG11q+uQi/vbACCpyddE22r/B3W0qE1mEWk6oF?= =?utf-8?q?xh5gh9xP63WJSiFQCAwL0bdhW1dPq+Lt8g=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e6877d91-4969-49c2-c793-08dbfa95e452 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:09:49.2268 (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: CqOBUzTJewHEXVoqxNmQRkd9JhE7GGK1IN+Cf0kPCrGeRO+UY0LEBz/2xCAR3UB82wD9PylCBsf7N1QOxi6i5LhaJp7HtQvBjBEGA1yFFVE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB8134 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 Reviewed-by: Maxime Ripard --- 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 Mon Dec 11 22:09:38 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: 13488145 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 1D743C35273 for ; Mon, 11 Dec 2023 22:10:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5C2C10E51F; Mon, 11 Dec 2023 22:10:01 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6E9B10E51B; Mon, 11 Dec 2023 22:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702332598; x=1733868598; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/ymKimFLSiDeo/NVNz3x/mTKycmLWMpbqiCB7S8EMV4=; b=nQ9GdlqSNENy44DXGszQFxQUs3zVsiotGlcV0k6h+71ay2t5CsE26cEt fRAt9PbAZmAOMde8Fe08NXnVBaZLtXG4hePV71EeqocplC/QBOhyUilxK DjRVrNEZytXXI3MXYPnK8+7Tk7Q/3cmxiEvR9vaQP/so9NOFMCGPH4/7T gaaCSEFuIJeXC0DfUPUfGH0Z7CDBmdLZpN2mrb426fgzDM+ZIGvEIFold +ibNq/rMAoK/HQWwxpuqPd3R1DyihWUi4VVbALoFjOqrvpGnRuj256aqR kxQ5aF2fifaOBnJ5y8Y1J3n7MyH4+BmlAS+tL8uWdOrVrUkhqCejvT2uZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="1865670" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="1865670" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 14:09:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="776826861" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="776826861" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Dec 2023 14:09:57 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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, 11 Dec 2023 14:09:56 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.35 via Frontend Transport; Mon, 11 Dec 2023 14:09:56 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.40) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Dec 2023 14:09:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJ/nY9hnunXtpr8ubuVx9bVJuIi9WawXztpr+5UfYBSZeurAuESDT6c2rz+nFWFiLdCHrG0BJ/spsmiJ+6GP1TPWBQ7k0nMYW424RAJKipEbWThbZLBrL4B4UJ3cW0FBt63tRiTBcxyNNiUXsmHealOaNGBlzS8uLHIHtVzGGvUlK68ruUGU/qStPux8ejSaWa/kiTwteqolBCzZBfbPO3u9Q/PrQ84hOdnKiFeZ12osnHmirIy0fsU8i4Hu7s1UlSlv2uWxtVA+vlVUdVEFrSgmrxFsWTp2uc5vDocqIVVWFJ6VCEb1pijoNNDpJuYq0e1k0pBf3dKC69aZ03RQVg== 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=sIOvHiNhB1GGERAGve4YMpEIaydyZIfnAdB2dNv3AxQ=; b=Lf9Sj3f8dl2VJmEGz02T+dHWn9VjQYQfmo8okE8i5yGj51xlYjlXSxRiVlE14QHh1h6lu2giuVGnz/qB88gf/WYtqteZEr3fNeLlNpwgzkfqN8Psjma3xeikV6gapDGQJsuF5FdQLLL8nD7V0gx/dzjxViDFLBMfuU/6VKwweD493zpy2zTXygfUo/W1BJWsXeyZ+r1lVV+pbcmlpUd0sUye9PPMDnDeXqUvBm9hJYCSAeOVjq4JFFwkLDzDfAFqM7cwpQWVfe8qcUEu2E/VDXdpMIcoEGveiKG+0KtdoXciT5R7a1JvlJ0mYxJfoYV9coqt2EmhG0/mJh82Do6xtg== 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 DS0PR11MB8134.namprd11.prod.outlook.com (2603:10b6:8:15a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 22:09:53 +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.7068.031; Mon, 11 Dec 2023 22:09:53 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v3 2/3] drm/tests: managed: Extract device initialization into test init Date: Mon, 11 Dec 2023 23:09:38 +0100 Message-ID: <20231211220939.215024-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231211220939.215024-1-michal.winiarski@intel.com> References: <20231211220939.215024-1-michal.winiarski@intel.com> X-ClientProxiedBy: WA2P291CA0012.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1e::27) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|DS0PR11MB8134:EE_ X-MS-Office365-Filtering-Correlation-Id: e981944c-6e56-45c4-ff60-08dbfa95e6ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7uWAfarzlT3S+r/04m6MoQ2mhzGCFa9SoqfR897pWTdwjfnn8PRYqnLL9knPbqyG9pg6ODbg82osRRuxDtbkcNsghScf70dKIQBrYNjFHibRv7jzkj91TadyjODzuoAriopivLoyDBRR9G9+Rmf1E1FUiEaxh8HsuFVUvE4XON2AliAM1o2N5i1dNoWvSX/Ot9cXqQciJDLKGBbCnv0X91mFYwi8sv/vFQImKYl8rMZR0pirVIBfc38M3kvwRXHznrQd3RuRTWfBBUCwFdH93k2ABRgp0poJ1tM5M79kBSTih+8VbridGA6LBiiXfIkL9UW91vbMXQBBOBiwcrmvg4oSvJqhShbvzHbcygHnof4MyG0IUU3SN3Hq78WZ1Zo2qpJUpBMeJSauNKRRNzmFiV1Ms1/kR6gTGyaiWjKHDQpyFrgB+pb28jJIwn+D34f/V2K8KmGk6EUUQceZsPO64Q3mX0iQSaiTjy5z412dkhVdtZ6SrzAORvHfNXdtJYUrFjuJI4cgKiAJxbY2xw0AB8QWcwP9EkhTh8yPe51Z3JfMv+2mubpcfc1j/DVdsRWd 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)(346002)(376002)(39860400002)(396003)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(41300700001)(1076003)(26005)(83380400001)(2616005)(82960400001)(86362001)(36756003)(38100700002)(5660300002)(316002)(8936002)(8676002)(4326008)(2906002)(7416002)(6666004)(6512007)(6506007)(66476007)(54906003)(66946007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?U9PE9grlV/dj4PE5JoYJZjWTHoSO?= =?utf-8?q?DsMczOKO+grzMRWf7CauxdEpJkgNkbeJICJqfD+I/KfI/Wam9nCVLLK1Quow2SNHk?= =?utf-8?q?hIiO7utLAH3R831brb80+DoXHUzQHgWJMN16qVSc1pG2dzpvGYp1MN+Dk6PWVodg+?= =?utf-8?q?IBU6MpQDA9qjdFU4SJgvtkn96x3sYIQ+2kNPBQ0fMBAtJjyfJbZlC3NLg24FzglKM?= =?utf-8?q?zRLAZrHHgqohhMxswNySLF/G3eym8QJwrY1P2a/hghW+DUNzkhY7pWeUvf0FSJm1O?= =?utf-8?q?7PbXr4ohozJHAJN3sXARwmHwBZuN2HZkN7muhcquiuoDTFGi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4xgxpNW8mznx?= =?utf-8?q?F9GpavKDqQ0/flwO18zFZGxXYuqIBGpnpcHySt8yiN1+psuC58Xvxle2W4gC60rng?= =?utf-8?q?Swxpgp/6XfQY6zTxf11mJK/rT6uD2EmwcE6LPCn90APU82mKK3GnIr2I5GQ1kbrRA?= =?utf-8?q?Vxr1ZzH/j+5B3N+p1Bsp7WuOYzbiQAaQ+2xKmml91sw0KzVX85FBDMLdo2yd9/li3?= =?utf-8?q?Srwy2l97nIcGlx2ji3rOMmt0EItSydAagCkC15i1k/cClzfG6xT0pDrdbKQC3T7/J?= =?utf-8?q?xhpnIg5k5hL/SsFefpFdJw4L4eZmpBSHMwV6Wv48n1tYUVP4p7uLl0RBVj5chsP4B?= =?utf-8?q?G0ZP7VS0Mzs6B9Ou+o6YVpV6vUSTgQRxpA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e981944c-6e56-45c4-ff60-08dbfa95e6ad X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:09:53.1685 (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: mz27213IHC/FUoaZn7qkFuf1FvZNassZft3qMa/OMmnfuz9I2GU29Zi5BkjFHK1wMzU5JepUjbSI4NOVIgL1uGf64P/2H0voVWqu1r62giE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB8134 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. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/tests/drm_managed_test.c | 51 +++++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index 1652dca11d30c..15bd2474440b5 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; }; @@ -24,35 +25,54 @@ static void drm_action(struct drm_device *drm, void *ptr) wake_up_interruptible(&priv->action_wq); } +/* + * The test verifies that the release action is called automatically when the + * device is released. + */ static void drm_test_managed_run_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); + + 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_MSG(test, ret, 0, "Release action was not called"); +} + +static int drm_managed_test_init(struct kunit *test) { struct managed_test_priv *priv; - struct drm_device *drm; struct device *dev; - 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); + /* + * DRM device can't be embedded in priv, since priv->action_done needs + * to remain allocated beyond both parent device and drm_device + * lifetime. + */ + priv->drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*priv->drm), 0, + DRIVER_MODESET); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm); - ret = drmm_add_action_or_reset(drm, drm_action, priv); - KUNIT_EXPECT_EQ(test, ret, 0); - - ret = drm_dev_register(drm, 0); - KUNIT_ASSERT_EQ(test, ret, 0); + init_waitqueue_head(&priv->action_wq); - drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, dev); + test->priv = priv; - ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done, - msecs_to_jiffies(TEST_TIMEOUT_MS)); - KUNIT_EXPECT_GT(test, ret, 0); + return 0; } static struct kunit_case drm_managed_tests[] = { @@ -62,6 +82,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 Mon Dec 11 22:09:39 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: 13488146 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 3E3E2C4332F for ; Mon, 11 Dec 2023 22:10:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9FC810E520; Mon, 11 Dec 2023 22:10:07 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1644910E50F; Mon, 11 Dec 2023 22:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702332605; x=1733868605; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=8ZHJfGEvNOqDHN3zqfd4GyNmg1YXYB9tnrENzdLCu9o=; b=HOYa+DEHmMjinbIYSMpoJa8uMdVo2arL+D859de0o+Tn+jNNESXibrqb ARSoIR04ARxnSyGZOzOZoasLPbrSBm6/K2JJT2z++wSB7U8WMyUXjxYQd wTrTFViKQbC4lvS5Sccw+RXV2pBRXXrV4QTRV19MVjPms5kaHsLoQ+G6D NFHdPewXP4IkUf2DfvlpylFfnae0DkxcEuYrFK3XSMyc4LSNYxMp0oifF /gcRM6b8hdUoEDQpHQgUHYaX0wyyLS+EN9wUWlrDRRPapYuw4RMjWn2eJ 1lEb7XpWcKK4aiRA2CLEjKoUIcNGh4DCA5AKE2cPk2KXRbSNoxGvUOO9K w==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="8079369" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="8079369" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 14:10:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="1104642672" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="1104642672" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Dec 2023 14:10:02 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 14:10:02 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 14:10:02 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx612.amr.corp.intel.com (10.22.229.25) 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, 11 Dec 2023 14:10:02 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Dec 2023 14:10:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EPsibF39lMCwRCtwAocpYNrh+qV4pC3SExCrNmZxptRdytsFwtZeJspidv71c+uaTOAj2G625UApK3rFqjktSD9uu/CFodw+KaEek3Ym+B+HbEbL6J1fpYai6x7qMWxFKg+wUozAyBKo/9rPhMkHCF/4ZYmhmKNcpl65VXDdFmid1FN6ssqcfhCBi3tFTl5KcAkL8YVvQWi7TPmDLSBOOmf815mBZp4q4nK8HMQ7S3P56yxP9jvv/OZDvpvSVjNCEMceuCkOQ9JTYxRe+j9R/rCcHhlNxkexW3+5u2UHk6FZ1Pq88KFEM9UPGcJptvsIw2MgFxHTyxb6XZrFscmgAA== 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=8ryXkAWZ5wXCE84ofb91OXLyBorFS2gEbNPixt8PWlM=; b=mol2mwwiREFt92m4KgK8HBFuybQ/YJzBKeLWXa7+v4f+9N1ZZrfA8vo42uadgkaLcc2YFK5GovFqtdK4qt8DHzwOp6yh8Nwv3s8mRZ3zUWPsKGFIq7O8D3VRsMEXFKYPQnYWsranZLL9r23gLMTWdf5+cikNCGoCPyi/FrKIxwrsT4up6+rbLAPj6/GJqOq8wfABAIY5w8VVpuG3zKGTp5pIKqKUOnm/vFdBlsnCm+y3PL//ApC9jOG6AqMvb8K2pCOEcg82wuLFWP1uXD5Yz2wQtTYg97ATzdAm5KHHzkOxE+n5oAi9LHIvINEXreAXArRVJw/7Z4ZiNR+v3G/1Xw== 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 DS0PR11MB8134.namprd11.prod.outlook.com (2603:10b6:8:15a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 22:09:58 +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.7068.031; Mon, 11 Dec 2023 22:09:56 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v3 3/3] drm/tests: managed: Add a simple test for drmm_managed_release Date: Mon, 11 Dec 2023 23:09:39 +0100 Message-ID: <20231211220939.215024-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231211220939.215024-1-michal.winiarski@intel.com> References: <20231211220939.215024-1-michal.winiarski@intel.com> X-ClientProxiedBy: WA0P291CA0024.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1::26) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|DS0PR11MB8134:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a2368c8-8bc4-47df-d741-08dbfa95e8c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gYJDLA8jm1krYJJ4qZjrCJMHsHYLA5m9Dbnyod+SibcXSUyJ2+85CwhbdG8/bneef7x9xnKblek1i01lo57SVEuLGHRCFZqo2ds5lPlbfQ9EvGfWtHU3brtGM2EDqZDay+NAc4T5Rde89cPgo1kHcjj3qVTeZCGWncgUnVeJr6+NysNB1lsmJJybNGFdlKOqE7pKGgvQfs3izj8kLBzcLfzc6aMKZp6UJ59gHsgVV0bMMOZKhA+6iO+Syn9qkVXc+f7iAnLjEuWn1b2d/RS4DogeaBBh7RYjCZsepJM8HGTEKQOt1UB7aGsnqRSUXKqRCwp7Yf+iq2b3TX9Ga7MDwb2Tu3jyWaPTKrpFF0v4iJ4iZR+IoajLLPpaXY81RjpPbBosnaOsojEScHyizcP8vDpEDmEquQYrKPGhz2xZO9SsJVtYQaXT8VnowMaoQCRa2dpb02ghGHZHxcF+Nnu39RVAiezeg82wRdxpV9OLedp24oWAN8EauS8BYDy1xScjBrgamui7zYkfU82Dkeh+FLIp0x3WjVTZJb0dzlrdgL6hiN9WlgN2yz3FrcN40H5A 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)(346002)(376002)(39860400002)(396003)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(41300700001)(1076003)(26005)(83380400001)(2616005)(82960400001)(86362001)(36756003)(38100700002)(5660300002)(316002)(8936002)(8676002)(4326008)(2906002)(7416002)(6666004)(6512007)(6506007)(66476007)(54906003)(66946007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?U/QhdICo/kxp68Qe4NTgkDW+3fD5?= =?utf-8?q?hmuK+N0dXAOa1KuUlNAIMQH6HwuuQadjgmxdE2JoI6RdWfYauCHwj7tfQc7LhEPjh?= =?utf-8?q?yc5r1xkAJxS2kwxL2xiAh7XihUqvogGfsEqXkiYEfJyyqMRTZgG7u90HDiTewjetm?= =?utf-8?q?du+h/moyHJyJW5oxV/ujhZ95f3DXsfXMOHkuuKhoUIi9azWfzVkn08gYcAoDceFV1?= =?utf-8?q?inMDphS1ME+eGfthmKdAO4fdqFWr7XevXZbcBdLXopSzQuT39BZmwChXx/C6x0fXI?= =?utf-8?q?I8puKwgpcPmmeXJ7N/N0dEIg7agPcV22L47vV8yFY/nF/+gdyiQiQTf1zyqEuTor1?= =?utf-8?q?dJ5ZRci2BwVTtfabwZZh2umBrdWlLdHjrUmR63miBxaVZ67mKdXl317Mo5RrKxTtb?= =?utf-8?q?9z4Nv8zAJj5WUyPIwMwcmFy9NwlCfVWK6009pL65X3Zgu6Fadt2PBxjZ4ziA7gC3t?= =?utf-8?q?dwazb25ztZlZTEYJIRHUIudGCki1lzGErYUR3dqoii7AP7ha2+Ckr1/JOWftR9e3F?= =?utf-8?q?rUcsAL9eCVe7WxarMIu0jST8+5F3is9M3e7CwVX8R+uupTU/BaUjtxBj560BuFcdc?= =?utf-8?q?7ss875JbILciLPk6UgDUDGIZUsyf1FTYTdY+/HXbMMq1R0qNcIMnv6VrgkPs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TKa1FltkoCY4ludPobFr0skJSBI5WFDIjw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8a2368c8-8bc4-47df-d741-08dbfa95e8c8 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:09:56.6894 (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: ahbY00DytmGXK8nVU1RGxBMvjK8uoztiHm2PSRipO560a8g8/LWzjlW9TdWYAZ8EIXIWzGhf5QOKXx+O/8wVGiuTbn+QslZebnnzwLKD6ss= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB8134 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 | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index 15bd2474440b5..ef5e784afbc6d 100644 --- a/drivers/gpu/drm/tests/drm_managed_test.c +++ b/drivers/gpu/drm/tests/drm_managed_test.c @@ -48,6 +48,34 @@ static void drm_test_managed_run_action(struct kunit *test) KUNIT_EXPECT_GT_MSG(test, ret, 0, "Release action was not called"); } +/* + * The test verifies that the release action is called immediately when + * drmm_release_action is called and that it is not called for a second time + * when the device is released. + */ +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_MSG(test, priv->action_done, "Release action was not called"); + 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_MSG(test, ret, 0, "Unexpected release action call during cleanup"); +} + static int drm_managed_test_init(struct kunit *test) { struct managed_test_priv *priv; @@ -76,6 +104,7 @@ static int drm_managed_test_init(struct kunit *test) } static struct kunit_case drm_managed_tests[] = { + KUNIT_CASE(drm_test_managed_release_action), KUNIT_CASE(drm_test_managed_run_action), {} };