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; /**