Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp658573rdb; Mon, 15 Jan 2024 09:14:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCDl23mkgn6LmnJIQAEw6w6BMw8rJVC3FO2E3RawYTFQPJpOXhPcqswFwSllnvwxiFp0S/ X-Received: by 2002:a05:620a:31a2:b0:783:587f:c4d6 with SMTP id bi34-20020a05620a31a200b00783587fc4d6mr3665832qkb.10.1705338869496; Mon, 15 Jan 2024 09:14:29 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o15-20020a05620a110f00b0078317b4ef86si8125768qkk.741.2024.01.15.09.14.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 09:14:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26301-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K5R3vvli; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-26301-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26301-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 349401C21EC7 for ; Mon, 15 Jan 2024 17:14:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D341F18057; Mon, 15 Jan 2024 17:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="K5R3vvli" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3469018041 for ; Mon, 15 Jan 2024 17:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705338853; x=1736874853; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=yRMxCdjoqIkD75SEuJzObVSQ7nqozqsXnQwiAAoCr5k=; b=K5R3vvlivU+eZLYSGJgXAS2bJLVBam9IaEJGBLnggKDKBl3LLMMjB6dA yRF/AZexYcLifbu6C1ehq+3ONfhaXfVoEDLaUMZsVzxjYYY5oqgZJmouC TUZHtYBlKDjCupPfM1OlK7VPuMSAdnh/VFZGF/xFeg5OqRw5oyLVm5ttK w6HLqU3I5UpDHQUMVVn5hY3XyZ6cZa//WUnabLwOZ82vIgtLzKFIVOtCU 7slqjZfbj6DcWGsnuXhf+PibqlED+KdaOakwoEv58R9DoGg+yyD4RZDH1 tQZKNWpElWX2o4NqEyGdILEz+VrdJVC/tkfRsKufNhy6E4EjKSHqILdEV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="399336715" X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="399336715" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2024 09:14:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="18189248" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 15 Jan 2024 09:14:11 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 15 Jan 2024 09:14:11 -0800 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) 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; Mon, 15 Jan 2024 09:14:10 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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 via Frontend Transport; Mon, 15 Jan 2024 09:14:10 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) 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, 15 Jan 2024 09:14:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JxrAG7DgHuM0I+Mf+Kh++Ukeqni1bgCvagY6DpnKiQMy2RvNEdZxEoHcTrexExAoBIBbhVevfyEoe+sz/FMwxxx4hYXYa2X4iz0XWId9oINBuRNIsZ1JP0IOVXpD6+8CITYAKpmvh+KpmQUEHuDIdfynVYN+5pDt6/Lc48rL6Hqn38Bo6JNPZEJv/Yhd2ZO+6NzAn2tgkZhUqERr7vPjRPE3+bYdZXFOYKG2CDx+BQIRkRhroBDiHlGZQ/pEzkg7QWpsFNCZ/ji9sDPBsE4Uodxv9HmCbkCNZR1mHCa2kauBsN648RbagJjKZOnBquAVmeuwKs4kNDo/AlyZ9J0GCA== 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=dkhLHh0crXwXx0APrqjN+/BQ8dQyd7xvanE/ap6H1sA=; b=QCfyQjbv8bUDNugwO17lYHTfZSlp7D97+rQMa2oPkyqZtANCdhOUJpjzcPWtfxG2JN6ISjymFtPZK74+4LAUVaeX0EFSgf3Y1jP7eOPjkVfMGfSH02gBmQCJdh56SlksgNXiGAjbZfuBepacm993kqLrdMUFMlfCw0uOoyMmd6OL7kEg1khV3rwLVWxYA9w2OfVvPxScmUDJsiEpkXN/JeayptEvFSyLzkdYhVqvA31aUGlGRDfrkXQ1MwiAyuDphmvIyWw3bf8qwuc1BpZiuzpyRW5kip639op06d9R45Cc1VPAtWtSeW5DTOttSH9zfQrcWBZhxH3tPHniXlLM/g== 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 CY5PR11MB6391.namprd11.prod.outlook.com (2603:10b6:930:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18; Mon, 15 Jan 2024 17:14:08 +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.7181.020; Mon, 15 Jan 2024 17:14:08 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: , , CC: Rodrigo Vivi , Michal Wajdeczko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas , =?UTF-8?q?Ma=C3=ADra=20Canal?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v5 1/5] drm/managed: Add drmm_release_action Date: Mon, 15 Jan 2024 18:13:47 +0100 Message-ID: <20240115171351.504264-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115171351.504264-1-michal.winiarski@intel.com> References: <20240115171351.504264-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1P195CA0070.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::23) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|CY5PR11MB6391:EE_ X-MS-Office365-Filtering-Correlation-Id: ca5f2ebb-04d2-4f8a-cb22-08dc15ed6294 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pPkwDmBr21Q4b9G+OnCaQRJeje0rgn0WaWkhE0B1NBnrvG4wl0pgOTkhkrjmAc/WnikfaL4xXbpYroVOy4opZIpYxFgzaSOQEZnbTZ5bOfOUgl0OLCWZVhPmxHf4GSxmKG/TStKcmS8J9uX/ra4587grosIPQrrj114OOXnWE+4R5Coe9Anq4LtLBAjBGmQP7dZ4AdF8KOXyTznsdryAxQ6I4PcO6yDjijP6ghlw+dEAiJFjsivjt2nLUV1ibEZH7Nt5uSoa6KPp3BN/CSRj90JLz7VZAs0p5mZYy/ScUUAANO+uJdDCVPE2ZBvfkgMcatqHr8/WSRAPecqg+JfZVxOTvK1wFTfKS4G0EFrYVa2PRbICcgUl8dGad+5ZkzbDNsPqwUwZBCnGya35zpNdWlSJq6rgGOoZ4FYPFETOIy+YokGGi23HQKhYoGe9VYLpjewQ9U0BGEDhUB6Q8rh70vhToLxyYsXPEKbKS7cyf8eelvJS2F+7561lmCTbHTXKaFLH7opFMZIkTDXzrcdrU6gzbjJi7T0PCaZ8NXshkNmdvBIraYaWjhha2t7yl1wD 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)(39860400002)(366004)(376002)(396003)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(66946007)(6506007)(1076003)(6666004)(2616005)(478600001)(82960400001)(66476007)(86362001)(316002)(6486002)(83380400001)(66556008)(26005)(54906003)(5660300002)(8676002)(36756003)(6512007)(41300700001)(7416002)(38100700002)(4326008)(8936002)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ajRualpoUEw1bDF3NnJ2cTlOVWJrSGpneWFnUHlrU3lFS001SHMzSTJRS21w?= =?utf-8?B?Uk12MTV0MURRYkYzbVFEenQ4RUpiZVNxTUVZeUxBZ2ZnVTZNWC9rR0ZqNEFD?= =?utf-8?B?MG1Ga21PTzFjVUlKeTZ5UGJvMUFKUWEvQ2JrUDJhKzJCYUNZZ1gzMWRTQWtR?= =?utf-8?B?Z01DU0NQZ1FvWHMyKzBQM0U1eUl1NlBadVFyeVU5SkdMYU1rQ3hMNDN3YmF6?= =?utf-8?B?QXZ2R1ZIMk01aU1SNVArL1hxNGlOdWVXVHNucG1icFNQd3liekdudVV4K2Fw?= =?utf-8?B?cHRvZ2ZyTDhielZIeEhVSitOZm9zZ0VnMlpJd2JJVjl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GlvbStZcjAySDBRL05IT0FydWdJNi9nTWIySXV5Z2h0dFVTb0R4?= =?utf-8?B?dEE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: ca5f2ebb-04d2-4f8a-cb22-08dc15ed6294 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2024 17:14:08.6374 (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: D1gwLzPAeeLR3bv7MZfbkFuBpVoQ6mA/yDA4C9hO2tgqA1c8Pz+x5V27y4XxhPNy6L9IXUbRDgFcs0M2NiCBf18HN6OVdrCF+qE4pYl7mf8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6391 X-OriginatorOrg: intel.com 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; /** -- 2.43.0