Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96371606A31A for ; Tue, 1 Dec 2026 05:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=So0dn5xG Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36BC410EBE9; Tue, 1 Dec 2026 05:32:45 +0000 (UTC) Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013071.outbound.protection.outlook.com [40.107.201.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id E18DF10E94C for ; Tue, 1 Dec 2026 05:32:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y252456fCIjieS8cSWCpF2DlVJ/+poOVmb3Uy8ceRBOthZRajybULzlkQ1hGbe3bpLUw5iIgrk8Pz0hi8oNrrr3n44gilB8Toae1Uw7A5jLQE5Y4gMT0L24Rttppa2Z2bd6P0LbBFYW84YUP0StGh8y9DbkWs5HSaFvpKB4Ry7NO2bLwWNfdQTTqiiOJAozTeRE1iW/M0B3/KOcS06VVpTvjd9SeMOVpJmAevedEu9I0Q4IwlA0WMrRBFhbsENsjJahXNOKJSJCZaJJB8W3tJ3hR6b3KM+bNiJTdPPPMS+O8NgdKnEB+4+IIgwM9Q8LU5QlktSdn+/4p8m+cwasBwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zfeS2sZL9eZt750mlSVxFL1KRrOqIct0aekONmxsAXg=; b=H3Q1beyo0PvknPi6rVwgponeQObhl+dUCTYJwCwzPXcyX+1x2I7tnABEjg5RL5qiQqkFeQfhqB2+MzogG1Bp8/qztwHU2xM+8xj/BZ5xbyRl16gTYipOsIShQyt2NBaBdlVVR21afrJyg9pzGkivDLhTHVTDUdl90ZC1nF+5xYoMb7mwL7r+8OcUk0szALVvn7g+5OEXlcbyG/RU0Ff8Q5Fu9jlj0qrHfmr2qrHC567Ftly1yWE3Zm8q3SseloPavPVM0FDKAAjqiEeNcwkjegM+yr8KlVzoCBFYylDM6ENJ0UR3HoWZLh83Ik9ENmmWPHMBl7XfQ7pY4BCag4H+AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zfeS2sZL9eZt750mlSVxFL1KRrOqIct0aekONmxsAXg=; b=So0dn5xGAWYcKhmR3NoicfIh17FjdRf4A745lLaFCRSvkXSf3ZOhoFe/Ia0AMBBJFBndybIvs3nCyishn4T0TGN9mHuLSI1DTPECRCHx+uO4NtH66p5kfikJNG8iTl3V+96eax/hupymDj6L6u2rDZfXeJ4U0zkkZfgAEiueS9I= Received: from PH7PR03CA0018.namprd03.prod.outlook.com (2603:10b6:510:339::15) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 05:32:34 +0000 Received: from SJ5PEPF000001EE.namprd05.prod.outlook.com (2603:10b6:510:339:cafe::32) by PH7PR03CA0018.outlook.office365.com (2603:10b6:510:339::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 05:32:34 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ5PEPF000001EE.mail.protection.outlook.com (10.167.242.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 05:32:34 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 23:32:29 -0600 Received: from JesseDEV.amd.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Mon, 30 Nov 2026 23:32:27 -0600 From: Jesse Zhang To: CC: , Christian Koenig , Srinivasan Shanmugam , Jesse Zhang Subject: [PATCH v2 11/11] drm/amdgpu: Bound WAIT_EVENT records and report event loss Date: Tue, 1 Dec 2026 13:30:54 +0800 Message-ID: <20261201053159.2550315-12-Jesse.Zhang@amd.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261201053159.2550315-1-Jesse.Zhang@amd.com> References: <20261201053159.2550315-1-Jesse.Zhang@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EE:EE_|BY5PR12MB4145:EE_ X-MS-Office365-Filtering-Correlation-Id: 46c4d567-b7d2-4f91-ff57-08df4f6c80a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|1800799024|23010399003|82310400026|376014|10067099003|56012099006|261028144727099003|261021121427099003|261022075727099003|261022105027099003|261021123027099003|261026140227099003|261102123227099003|261026121527099003|261021135927099003|261009223027099003|22082099003|18002099003|11063799006; X-Microsoft-Antispam-Message-Info: jHHqglemou4jybNQxgxMJgeXlQ4iuNH0KVOEQBJ+Oc1HFS3SPSGE6gRZvJFTbyG41YZqcw1798E8inlw5rAA3OVLMCsWKjE0lsrvBXXj3hDy40rExIJpp6arE4QgSSgm3NtPPURTdLYGnGtJ+nVxUh2YtWNCEb1g7cHNJ9FdPBKq+5Q3SS7y5uURa+9ZjW8AcrlYPBY5gyguSoEV6BvpvRFyDMnRNCgkQC01/VlmtbwiBNLnrv7kauQ6O9gV6kAUhbBacqBDWQiR107cuTF0N7icbGVT2XyQaucUrEo38mUdkV4Suhi+AK2/XPC/txooykTwzXezZSJcyLD1soUXf8YG4n3BS0POWNVLCNuZ9CUKi8IJAk9XKkuR4YgoJxOo7xvrqcTA98eZYIFI5LmGYMl68QY7euTD1FDUq/EiEJ8Apqg2SZp5+v1Lf2Brg8LPZB9iEJgC+ndUFqZkxy+9C3n8m10E2WIUk53r+C5ZNBtC9NaMpkGdCUXr4WQM7Ggywys/ckHNg1Qx2L/acJg6ju15GVBbpGMGCfs8mNx8AUqfp0BIIaVvZ675R1F0Oj93/6dxBp2ZLxoHSRqjuVisXR8dDjcasxgWX4BMVAGSiQxDRf81m2kNR8UTU/H2Q3HhbzQqABmJYsoK5Jqyu71XQXZikk7MgryFKabr8YfiavmodLeHe/mIyp/3qxgpOBk3w5DckWy/4qLEK/a9yL0uLQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(1800799024)(23010399003)(82310400026)(376014)(10067099003)(56012099006)(261028144727099003)(261021121427099003)(261022075727099003)(261022105027099003)(261021123027099003)(261026140227099003)(261102123227099003)(261026121527099003)(261021135927099003)(261009223027099003)(22082099003)(18002099003)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FdZE6wRh6gEtfjF4c7Zz3qjEP+JhMr+HMxkPJyJfRch2/rgJFwLqr85vKqovEFhvm7fOM593wO2/IAW62EwAxQr5lrbvxNJpLzWoYcvPcbFkeiFKZYoj/Qx5cbVQr0vG0/JOhJM+TpZLy+uJOV2A2r5UH/2KUNpZ+JfMucPAE3m2DlCsf0X7bJ3qo+GnYH0eEfI4kfPkl9A2oGefzcRI96yZSbgS9MP1PfyPghxEv+tpvXCTbIX4ZwXJX8YKZj6hWyBHjcMwShH3PjU7knMIgV9lbHOnWm2Y/1E64qcjOkg6AFRYG+/bHV9qSmd7+ETuXQwCKuG9NUUNF4YuUGCgcpcCqIEpfUxz/5wvBHPUXrElIDDsHZH+VgNLEZVnaqS3gRtmXcu/qI+XGD+2QTSO9WQl9r4aTiqCA60/Qq34YM2Qd7PJFhLi35/vGNA88r+P X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 05:32:34.1721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46c4d567-b7d2-4f91-ff57-08df4f6c80a0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Srinivasan Shanmugam Limit pending WAIT_EVENT records to 1024 per DRM file and event type so an undrained event stream cannot grow the record list without bound. The queues of a DRM file share the limit of a queue-scoped event type. When the limit is reached or allocation fails, preserve existing records and set a loss indication for the source of the dropped event: the queue for a queue-scoped event, the DRM file for a device-scoped one. Return -EOVERFLOW to one WAIT_EVENT caller for that event type and source when no matching record is pending. Publish the record or loss indication before signalling EVENTFD. Document that an EVENTFD wakeup may have no matching metadata record. v2: Bound the records per event type and report a loss per event source, so unconsumed USERQ_EOP records no longer drop the records of other event types. (Jesse) Signed-off-by: Srinivasan Shanmugam Signed-off-by: Jesse Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 7 ++ .../gpu/drm/amd/amdgpu/amdgpu_wait_event.c | 96 +++++++++++++++---- .../gpu/drm/amd/amdgpu/amdgpu_wait_event.h | 16 +++- include/uapi/drm/amdgpu_drm.h | 17 ++++ 4 files changed, 114 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h index d0c808986b8c..3158fd946d8f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h @@ -111,6 +111,13 @@ struct amdgpu_usermode_queue { */ bool events_closed; + /* + * Mask of the queue-scoped event types which dropped a WAIT_EVENT + * record of this queue. Protected by the lock of the file's + * WAIT_EVENT manager. + */ + unsigned long events_lost; + union { struct { u64 queue_rb; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.c index 5135bdd90880..8fcc37b77ca5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.c @@ -27,12 +27,15 @@ #include #include #include +#include #include #include "amdgpu.h" #include "amdgpu_userq_internal.h" #include "amdgpu_wait_event.h" +#define AMDGPU_WAIT_EVENT_MAX_PENDING 1024 + /** * amdgpu_wait_event_deadline_to_jiffies - calculate remaining wait time * @deadline_ns: absolute CLOCK_MONOTONIC deadline in nanoseconds @@ -156,16 +159,37 @@ amdgpu_wait_event_match(const struct drm_amdgpu_wait_event *args, } /** - * amdgpu_wait_event_has_match - check for a matching pending record + * amdgpu_wait_event_lost - loss indication a wait request reports + * @mgr: per-file WAIT_EVENT manager + * @queue: resolved queue for a queue-scoped request, or NULL + * + * Losses are tracked for the source of the dropped event: the queue for a + * queue-scoped event type, the file for a device-scoped one. A waiter only + * sees the losses of the events it asks for. The caller holds @mgr->lock. + * + * Return: + * The mask holding the loss indication of the request. + */ +static unsigned long * +amdgpu_wait_event_lost(struct amdgpu_wait_event_mgr *mgr, + struct amdgpu_usermode_queue *queue) +{ + lockdep_assert_held(&mgr->lock); + + return queue ? &queue->events_lost : &mgr->overflow; +} + +/** + * amdgpu_wait_event_has_match - check for a pending record or loss indication * @mgr: per-file WAIT_EVENT manager * @args: WAIT_EVENT request * @queue: resolved queue for a queue-scoped request, or NULL * - * This helper is used as the waitqueue condition. It does not remove the - * matching record. + * This helper is used as the waitqueue condition. It does not remove a + * matching record or consume the loss indication. * * Return: - * True when a matching record is pending. + * True when a matching record or a matching loss indication is pending. */ static bool amdgpu_wait_event_has_match(struct amdgpu_wait_event_mgr *mgr, @@ -177,28 +201,36 @@ amdgpu_wait_event_has_match(struct amdgpu_wait_event_mgr *mgr, bool found = false; spin_lock_irqsave(&mgr->lock, flags); + if (test_bit(args->event_type, amdgpu_wait_event_lost(mgr, queue))) { + found = true; + goto unlock; + } + list_for_each_entry(rec, &mgr->pending, node) { if (amdgpu_wait_event_match(args, queue, rec)) { found = true; break; } } +unlock: spin_unlock_irqrestore(&mgr->lock, flags); return found; } /** - * amdgpu_wait_event_pop_match - remove the first matching record + * amdgpu_wait_event_pop_match - consume the first matching record or loss * @mgr: per-file WAIT_EVENT manager * @args: WAIT_EVENT request * @queue: resolved queue for a queue-scoped request, or NULL * - * Remove and return the first pending record matching the requested event. - * Removal provides single-consumer delivery. + * Remove and return the first pending record matching the request. If none + * matches, consume a pending loss indication of the request. A record or loss + * indication is consumed by only one waiter. * * Return: - * Matching record, or NULL when no matching record is pending. + * Matching record, ERR_PTR(-EOVERFLOW) when a loss indication is consumed, + * or NULL when neither is pending. */ static struct amdgpu_wait_event_record * amdgpu_wait_event_pop_match(struct amdgpu_wait_event_mgr *mgr, @@ -214,9 +246,15 @@ amdgpu_wait_event_pop_match(struct amdgpu_wait_event_mgr *mgr, continue; list_del(&rec->node); + mgr->pending_count[rec->data.event_type]--; found = rec; break; } + + if (!found && + __test_and_clear_bit(args->event_type, + amdgpu_wait_event_lost(mgr, queue))) + found = ERR_PTR(-EOVERFLOW); spin_unlock_irqrestore(&mgr->lock, flags); return found; @@ -276,7 +314,9 @@ void amdgpu_wait_event_mgr_init(struct amdgpu_wait_event_mgr *mgr) spin_lock_init(&mgr->lock); init_waitqueue_head(&mgr->wq); INIT_LIST_HEAD(&mgr->pending); + memset(mgr->pending_count, 0, sizeof(mgr->pending_count)); atomic64_set(&mgr->seqno, 0); + mgr->overflow = 0; mgr->dead = false; } @@ -302,9 +342,22 @@ static void amdgpu_wait_event_add_record(struct amdgpu_wait_event_mgr *mgr, struct amdgpu_wait_event_record *rec; unsigned long flags; + if (WARN_ON_ONCE(!event_type || + event_type >= AMDGPU_WAIT_EVENT_TYPE_COUNT)) + return; + + spin_lock_irqsave(&mgr->lock, flags); + if (mgr->dead) { + spin_unlock_irqrestore(&mgr->lock, flags); + return; + } + + if (mgr->pending_count[event_type] >= AMDGPU_WAIT_EVENT_MAX_PENDING) + goto overflow; + rec = kzalloc_obj(*rec, GFP_ATOMIC); if (!rec) - return; + goto overflow; if (queue) kref_get(&queue->refcount); @@ -314,14 +367,13 @@ static void amdgpu_wait_event_add_record(struct amdgpu_wait_event_mgr *mgr, if (meta) rec->data.u = meta->u; - spin_lock_irqsave(&mgr->lock, flags); - if (mgr->dead) { - spin_unlock_irqrestore(&mgr->lock, flags); - amdgpu_wait_event_record_free(rec); - return; - } - list_add_tail(&rec->node, &mgr->pending); + mgr->pending_count[event_type]++; + goto unlock; + +overflow: + __set_bit(event_type, amdgpu_wait_event_lost(mgr, queue)); +unlock: spin_unlock_irqrestore(&mgr->lock, flags); wake_up_interruptible(&mgr->wq); @@ -384,13 +436,11 @@ void amdgpu_wait_event_mgr_fini(struct amdgpu_wait_event_mgr *mgr) unsigned long flags; LIST_HEAD(removed); - /* - * Prevent new records from being published before detaching pending - * records and waking blocked waiters. - */ spin_lock_irqsave(&mgr->lock, flags); mgr->dead = true; list_splice_init(&mgr->pending, &removed); + memset(mgr->pending_count, 0, sizeof(mgr->pending_count)); + mgr->overflow = 0; spin_unlock_irqrestore(&mgr->lock, flags); list_for_each_entry_safe(rec, tmp, &removed, node) { @@ -425,7 +475,9 @@ void amdgpu_wait_event_remove_queue(struct amdgpu_wait_event_mgr *mgr, continue; list_move_tail(&rec->node, &removed); + mgr->pending_count[rec->data.event_type]--; } + queue->events_lost = 0; spin_unlock_irqrestore(&mgr->lock, flags); list_for_each_entry_safe(rec, tmp, &removed, node) { @@ -512,6 +564,10 @@ int amdgpu_wait_event_drm_ioctl(struct drm_device *dev, void *data, } rec = amdgpu_wait_event_pop_match(mgr, args, queue); + if (IS_ERR(rec)) { + ret = PTR_ERR(rec); + goto out_put_queue; + } if (rec) break; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.h index de0fc583d51f..74cee98ceae8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_wait_event.h @@ -37,6 +37,9 @@ struct amdgpu_usermode_queue; +/* Event types index the per-type state, 0 is not an event type. */ +#define AMDGPU_WAIT_EVENT_TYPE_COUNT (DRM_AMDGPU_EVENT_TYPE_GPU_RESET + 1) + /** * struct amdgpu_wait_event_record - pending WAIT_EVENT record * @node: link in the manager's pending-record list @@ -51,18 +54,27 @@ struct amdgpu_wait_event_record { /** * struct amdgpu_wait_event_mgr - per-file WAIT_EVENT manager - * @lock: protects @pending and @dead + * @lock: protects @pending, @pending_count, @overflow, @dead and the + * events_lost mask of the file's user queues * @wq: waitqueue used by blocked WAIT_EVENT ioctls * @pending: pending event records + * @pending_count: number of records on @pending, per event type * @seqno: per-file monotonically increasing event sequence number + * @overflow: mask of the device-scoped event types which dropped one or + * more records; awaiting loss reporting * @dead: prevents new records from being queued during teardown */ struct amdgpu_wait_event_mgr { - /* Protects @pending and @dead. */ + /* + * Protects @pending, @pending_count, @overflow, @dead and the + * events_lost mask of the file's user queues. + */ spinlock_t lock; wait_queue_head_t wq; struct list_head pending; + u32 pending_count[AMDGPU_WAIT_EVENT_TYPE_COUNT]; atomic64_t seqno; + unsigned long overflow; bool dead; }; diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 6bb2a75bf7fa..ecaadb04cab0 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h @@ -346,6 +346,23 @@ struct drm_amdgpu_wait_event_data { * event record to userspace. Matching records are consumed by a single * waiter. * + * Pending storage is bounded per DRM file and event type, so records of + * one event type which are not consumed do not take the place of another + * event type. The queues of a DRM file share the limit of a queue-scoped + * event type: the unconsumed records of one queue can use it up, and + * another queue is then told about its own dropped records with + * -EOVERFLOW. When a new record cannot be stored because the limit is + * reached or allocation fails, existing records are preserved and a loss + * indication is set for the source of the event: the queue for a + * queue-scoped event type, the DRM file for a device-scoped one. + * If no matching record is pending, a WAIT_EVENT for that event type and + * source consumes the indication and returns -EOVERFLOW without writing + * event metadata. The indication is consumed by one waiter. It reports + * that one or more of the requested records were lost, not how many. + * Userspace may continue draining records after -EOVERFLOW. + * Matching EVENTFD subscribers are notified when loss is recorded; an + * eventfd wakeup does not guarantee a matching metadata record. + * * Removing the selected queue cancels a queue-scoped wait with -ENOENT * when no matching record is available. A wait that obtains a record * concurrently with removal may still succeed. -- 2.50.1