Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4902933rdh; Wed, 29 Nov 2023 14:16:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOMpmoqvEivV1msoj/C9oeg2qa3vLKvF8Z0sXsNSKzok9+wq69wPYpXEZJBYW17ysTIBal X-Received: by 2002:a17:902:7409:b0:1cf:a2e7:f851 with SMTP id g9-20020a170902740900b001cfa2e7f851mr19811171pll.32.1701296180210; Wed, 29 Nov 2023 14:16:20 -0800 (PST) Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b17-20020a170902b61100b001cf8be14168si1547690pls.552.2023.11.29.14.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 14:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LdJAcQGy; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A884F80765F3; Wed, 29 Nov 2023 14:15:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234756AbjK2WO6 (ORCPT + 99 others); Wed, 29 Nov 2023 17:14:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231402AbjK2WO4 (ORCPT ); Wed, 29 Nov 2023 17:14:56 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD30B2 for ; Wed, 29 Nov 2023 14:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701296102; x=1732832102; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=QycBI7Kt9PgTyJxaiH/+LWXtKXKuLCo9OVwQRLqdWtI=; b=LdJAcQGyEcMrqFa+vgAccrfZW//bkSSxJsr+1uXtygQhmVKAbUAW+y3/ N9x20Q6gtJgDy8TuOLP+hYjMg04KmWwCjRGd4X1AmoDAxfWzblnEjkhwV //5flBMawXfa2uYKzmuv8uh/3C1BjTxsCkcRTguBjS5KwtWWUdjvKWJR+ M/pP7bV8eY0bpFJwn/g6NuRjOVcpoMhYyOOGLmIKS4WNcZ8Cmu/Glt4w2 cyPv6r64Ke13zs6C1wBmgioqjA8BVOWwVodV95rPId6roLRS5M7WRfv17 QcjhKAIujTimEiJ8QHYtm/55Upyxq2ntjDnD3wUqZJcCgoLwj7Zz+jZFR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="11935312" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="11935312" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 14:14:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="912984151" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="912984151" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 29 Nov 2023 14:14:48 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.34; Wed, 29 Nov 2023 14:14:48 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Wed, 29 Nov 2023 14:14:48 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Wed, 29 Nov 2023 14:14:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IVptYmUGJp5F3k0ylP+qIo/rE+U1KK+MjvDjGGgENiYFXEX2M8G+GT12rJ5+wFQzfVr6flN6GAT3sTmOOxM1tbASBRc+0+LNsRIOsy89T+/tg709c1f+zCzeUZ9x7FpqBH1GgxI0boggeluJwrJlDj53qWTTEaSEt9dNBOl61O09fFn8Jaqbkg2cvn7AkY17IRPCjss9iEAGsNk2uisnV/DEhkhtThel7oqjlNgR/PMwkoSDGRbUYBCzGHKcqjbvMWnI9tu26QkKlL+931zmvA3fUno0dbFnuMEKHCTiJXtCIJPzXqY6sUbfid2af22ns7eHI5WpwoWC+50UWhTlkQ== 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=GeBqhSc2Q/Udmk7YaIAddHCxzY1XZReQJxVLmCKpLXFr9UiYMuZ5nt+CI5FMTYzZC6V6U6u3yr9OJQsRTTefUDPaCoEjX2fB5Kmvr4N+boYHt8QfdGT9ZRnquTQAHvBqMJVp4v5N3SHyFmwwL917AQ+PsBSisczGw1BoWwDRqgcQG4f0D+ZOldnuZB6WBl8b9VhTYPiNqOBnurhqdrIrLSEsAOuzMs2Y0+AWejEznM9QA1qEDh3NDFuD2SZhxaNHPRoTAgAMHcdkOlXEwohFE2C98o1LWivcsNBz0LIDtn+RCf3U5xz1dE+88OXB5a66EKxJZ4QRLvOnDO9mkolTEA== 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 CYYPR11MB8432.namprd11.prod.outlook.com (2603:10b6:930:be::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Wed, 29 Nov 2023 22:14: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.015; Wed, 29 Nov 2023 22:14:45 +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 1/2] drm/managed: Add drmm_release_action Date: Wed, 29 Nov 2023 23:14:11 +0100 Message-ID: <20231129221412.1180549-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231129221412.1180549-1-michal.winiarski@intel.com> References: <20231129221412.1180549-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: WA2P291CA0044.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1f::20) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|CYYPR11MB8432:EE_ X-MS-Office365-Filtering-Correlation-Id: f2a50c92-ea8f-4863-7dab-08dbf1289806 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uxMFSmOZIQJYVb+NrQ5AmIpk5hyr81KUOkQL8z020l306l2mZ9f7rboUFztSNWD+Jd02lB3OxGo/84CmvyDtJdHGjwOMgqYbDC53OXZVsFxOFvakVJRUvYTNNCCfyHtzPNw6aR3XZBb5E9qpD/G5I0SfbgSscbF/+PNF+RTYQb0eQNYXYris9oAhZK5EGIHCPWmwSh/8dXxuJX4wvSeUVJKZ0t3nJDZG8WtUmXuwImZ2FTsi8BLhuWGMulyUsr21q5+Buz80CHDYFO5ppftqs7ro6W5PntOSg7s2xD2mClnN+nUzEgt6xGD/tQKBJsP9751EIkk7a4RhsHxH4JK+L/0/vf5jz/1/us3G3V1PXqntFZ06TwMkEtN+hMUtPwNjf9ou3JPqBJa/nHxdJhpMnHdp7rHTOQGINUgzZ6l47UGnlD2FrEt8qZhZM8j2SxLBmGRO6rMa03y2qtl6T3LAz4Okr9wSEo1C8b+3PWvl1Un2AtIllc80MbvExhvfounCdTywjc01RGQpcQjY0b+at/6QHTO/GE2nltgL7qZltyGgfWcOzkDJkRKP8MF4jsJzLM5R6t98AwMWPq7ND00/tXLF1vHdn3bz/bh/M2X2Ek9zXoOTSsjj+VnMcjpCZPAB 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)(366004)(396003)(376002)(346002)(136003)(39860400002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(36756003)(6506007)(41300700001)(38100700002)(2906002)(83380400001)(7416002)(82960400001)(5660300002)(26005)(86362001)(1076003)(2616005)(202311291699003)(8936002)(4326008)(8676002)(6666004)(6512007)(6486002)(478600001)(66946007)(54906003)(66556008)(66476007)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U0NYVjlqdHBQcEhHV2ttYVZmNjVNYUhNZUFaQXp0dGxYbThjeXZwQUlXZXBs?= =?utf-8?B?NTkrcTd1QUhhWFVpSWJKajFwc0JINktHQkpOS0pjd21QM1BKZjllVGFPMjBB?= =?utf-8?B?bE5tSXRKaXQ4UUF2U095SklpZ3lWdnR2UTlpay84M2RMS0tpOWRQUzBsbmtU?= =?utf-8?B?cTBrRVg4R1RhTENsQ0l1YmllVkNSZGdVam9oVkxlK053MHhFZWpsMzJWY2ZS?= =?utf-8?B?SUtvSWVXTmtYaUFpRzdzY3ZIazQwU3hCOGZWSWs0angzc1JKTFlHWUNZTE1F?= =?utf-8?B?T2hDQ2xPeWxVaVMzZEJPN2RINnFVeE9EU3kwN0pnR0YvVml6ODBpcWZjeU1U?= =?utf-8?B?T0lyMk8wNWszL2pFZ2M4VG9GR2llTkFEY0hqNzZmR1RRTzBYam1JUGc5VTBI?= =?utf-8?B?aThoWUhVNE9tL1RjMXg4NmtaWDhCcnBaYlNSaHpvM1FyK1I5MTh6cjlKSFFN?= =?utf-8?B?UVhpdVdNa29zWGdTYUZON2tIOXY1U0RoR0d2S0VrNlZYMk9raTNuZ1dHSmV6?= =?utf-8?B?TWhpZW1PbFUrazBLWjIrdmVOREFHSXZPM0ZxZGZRZlE3SThGaE1qcEp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xOHhOSDhEeFEyc0VmdFN0?= =?utf-8?B?QnNjanZwcUhJMktHd1hpZXRvbzFDaWxBMkxOK2oyVVdpTktKQmlyRWNqSjZJ?= =?utf-8?B?Q1NhdEk2U1cxVUpPV1MyRWlQTzMvZEd3Tmd3UEtJeE5TSXc2M2NLRDdKRWdK?= =?utf-8?B?Wldab2hSRktpS3BiWGNweENIY1h1Q1JwVkNyVUJWd3lZZjIwNFBLWGpjK05j?= =?utf-8?B?VEQwbUJCSGFqY0hTODZQZzNrcWNYWUVTUTJMTmdXbmtCUU9zd09CM25zMFBC?= =?utf-8?B?ZkRBSlliUytuNTFCTjYxMy9GWHEzZ1o1aHBERElzWGxsNDVYME4zQktsa3N5?= =?utf-8?B?QU1rMmw2UUFLYUg1ZzhYcEFCZmdWdTBQK09vYk1MMHhONzQyYjdUWTA2WU9z?= =?utf-8?B?TkZsamdtaHhoMWVzVENNK3BoQS9LN0E0WVNlUlNnYVRKQUttanFsYTJ3Yllq?= =?utf-8?B?TExhaVBTN3E4c2xNZnZqenhtUnY3WVViN0ZNNVBIcmRVMVc3bVpSbGk2UE5v?= =?utf-8?B?bERBZHNQOFJaYkhESlFRNHgyNThGZEt4S2UwVTZXQUd0NEJSL250TnpiZHhD?= =?utf-8?B?Z3g4a09JN0ZoeGJ1Mk9BMXBWZXdlWTVFQ0ViSm92NjJFVnN0SnczMEhxWmdq?= =?utf-8?B?ck9DdW9DK0ZxRmpvSHNHanJkZkptMkYzWmluMjVFTWpOak5PbG5ZN2JLQUVr?= =?utf-8?B?eUE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: f2a50c92-ea8f-4863-7dab-08dbf1289806 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:14:45.5696 (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: lfvecdOGDugG0VjZp4LfQVMqZrDkvSJ+ZZaihKkDq19M3fpyw564pkkuatWYhJvij74ZKOtWkmYLm1vtLEZW1W/Z5+zJUEASeayKFyzVKmA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR11MB8432 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 14:15:25 -0800 (PST) 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; /** -- 2.43.0