From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DEB93BBFAA for ; Fri, 10 Jul 2026 12:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783685028; cv=none; b=I8G1jnnIaDzAWLj8CWwywlWcedg9KiqMfYSXXUOPBEedtoMrFKPfQFjvOTJEzMbfrhD3rtAUpq80sBXs/xJfFlLNM1dKrHpVzdm/SFflsPfLHl+S2vKWIJ9UaDuPdYdJFp35CSC4rkIFOzB0AqnP/QayO9MUhW2lNkqxCdEFGj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783685028; c=relaxed/simple; bh=OREKIZK0iGj3uteTDVKgAFN89T5PXqY/U2nKVtnxfyw=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=DApojsW4MZjldTERD3drcYGe+8RzUB9+7YbO+nYBEQNfholhOym5vYh3LxpMyFbNfnDcq9t0sKF8064Rqs1i63/in8mydtyMW6GQ8X5GrD0X8dn5AMHmssh5rpO7KPjMCNlOe9+SitS3u3hscMpZjAWJ57Tl5sXiexHfBScoIiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ApoSlfe6; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ApoSlfe6" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-476a130c138so1110448f8f.0 for ; Fri, 10 Jul 2026 05:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783685025; x=1784289825; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=hksPX1U2TBlTextUaSByNI1aeIBAxfzf3b6cw/OY5vY=; b=ApoSlfe6oRK9ca4Wlb6q73Talh3kXRCY+l3/VATI4pnq9gQifBVO3glEwdAkkdATVn SZ7OIZQgwXHfxATUe+R5Pw9+D/wo+KzAWSGf96N6bDFHfrWcRPzsLy1TNmXaW97zQGaR 8cJl6ktTz4mYI49YwNUpykBWo2jLc3Rr+1lEzww67c5ApXgbsdZUjC+rfiFW73cSIelb 1B1q3jDgeb4Fii/HvpPpN2ffCpILMVcr0JXuHe13LkMnL94JO5LBcULEb1ryW+u/vwsP in77cOPTo/+IMfsc6WAG+KzvJn1IiUBNxGq4I2NbaBUspccIKjcF788i7iTNKxyPqBRg Ij6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783685025; x=1784289825; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=hksPX1U2TBlTextUaSByNI1aeIBAxfzf3b6cw/OY5vY=; b=nUGSR2lPrx/S0JttGcXlel4yy5fHQTgEOs5zHJB9m3w0JFVmuEZRuMoCm6Nh/ZYokD KmzhEqXpepOr8Zwls0Hecjl1aQ2/qYuv98Dml1ippuRmJSxWt/Hjf3KyhYYBbcmAEgZA JpUp7asPoHeFXkqh8FM+s7h2m+o/g4apGTTIPwh1p+jLIkiEdD0wODPZPqjjVmhhu0mf MGJkBmV4d3j24Jiy9D+9HwOMbPhyO6BoWrMLtts1WW6jssF8Q0wfgHrBYcNJB8PXin5x ZZ0nStnP6o1FMj3kzgUPndQS2sy+CIZdXQWt/goN4ahs7R2MPhH+fr3T39bPRCpHT+aq J78w== X-Forwarded-Encrypted: i=1; AHgh+RpjWXk1riyWVgcBxfSY16XeE1oVSEQyi9fvL3ahUSJ1gFOgy4f7QpExyRrBxHZDT1A5EY9NPGW4Zd0XquY=@vger.kernel.org X-Gm-Message-State: AOJu0YzzUqDt0pU7LJ1/uWMD0hgu6q+3Vurmk6fprhhp/gKrD+KlkutS L7BCyvy9DdpckU03pu3IelHIrGAY+vK8FnKs9JPOcRjYMymL1vlzU5AWhspgl4s+ X-Gm-Gg: AfdE7ckkb3+miVtM6Cu0JEnEW7BzAhqKfdxIwXOyfHXush6bGdnj2e91UFCvBQlWtNb tWm/GRHYzJ2HnoJnBFH4rbbzlw3/1BNo3k9CqXFj7J9w76v4/ZSBdFBbeC95WvmCgWFgnwOnQVq b34eT+ie/+UZA+DibEPdzqGl4dENvfPrzK4dZ0Ottied9mTc4vv4kSz3T58HEUsq9PjvOwIx6UT k5I3szXJ63yswVLXiUcTQfbbSIQfsRoaafCYVKNFaKqS5nzrgi6jEziUuzDPIa0AtE1GDAhsnBx po14bMnKgN47QCAqPHuwIbH5m1xkTIXEVvjt412TzS5sWf1v8TB3Pmafy4YqoBsrLGrLxFU6J9D X4o5Y1lzHIWRZ/hMAunm8yH0d0mrEAeu/R4g1gvRiWEqme1BFTc8+M/GVSBz1+3aiIG1FYWvM30 QFAWLnjOX5OeXV+icoDjG9dqhF3EGMc/VPjbVY0PaiYBeCvs4BvcrzIEAEH4zhlkX6ba02w4H/8 GVudqhFuzGW8oHqD25uYQfeLI/giUT31w== X-Received: by 2002:a05:6000:2007:b0:460:1301:dec6 with SMTP id ffacd0b85a97d-47df0715673mr12782183f8f.10.1783685025316; Fri, 10 Jul 2026 05:03:45 -0700 (PDT) Received: from localhost.localdomain (62-178-82-42.cable.dynamic.surfer.at. [62.178.82.42]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9e4d83bdsm59637487f8f.13.2026.07.10.05.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 05:03:44 -0700 (PDT) From: Christian Gmeiner Subject: [PATCH v3 0/2] drm/etnaviv: Add GPU reset counters for robustness Date: Fri, 10 Jul 2026 14:03:41 +0200 Message-Id: <20260710-etnaviv-reset-notification-v3-0-7a145c8a1d01@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/33NQQqDMBCF4atI1k1JokbtqvcoXYzpRAdaU5IQW sS7NwqFduPyfzDfzCygJwzsVMzMY6JAbspRHgpmRpgG5HTLzZRQWjSi5RgnSJS4x4CRTy6SJQM xn/FelI2sS5AAPcvA06Ol14ZfrrlHCtH59/YryXX9st0emyQXXFdGy6bqdFe3ZxrgTnA07sFWN 6kfS4pdS2WrE8Zib6xSoP6sZVk+pcmaIxEBAAA= X-Change-ID: 20260708-etnaviv-reset-notification-b037153a1aab To: Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, Christian Gmeiner X-Mailer: b4 0.14.3 The OpenGL robustness extensions (GL_KHR_robustness) and Vulkan (VK_ERROR_DEVICE_LOST) let an application detect a GPU reset and check whether its own context caused it, so it can throw away the broken context and build a new one. etnaviv already resets the GPU after a hang, but userspace has no way to learn about it. This series adds two counters and a RESET_QUERY ioctl that returns both in one call: - a global counter that counts every reset of a GPU core. - a context counter that only counts the resets the calling context was guilty of. Userspace samples both values and compares them later: if the context counter moved the context was guilty, if only the global counter moved the context was an innocent victim. That is all that is needed to implement glGetGraphicsResetStatus() and Vulkan device loss. The global counter is kept per GPU core and not per device, so a hang on one pipe does not look like an innocent reset to contexts that only use another pipe. The first patch is preparation: the counters are updated from the scheduler timeout worker, which can race with the DRM file being closed, so struct etnaviv_file_private becomes reference counted and every submit holds a reference. Link to the Mesa MR implementing the userspace side: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42826 Signed-off-by: Christian Gmeiner --- Changes in v3: - Update the reset counters and read them back under the GPU lock, so the RESET_QUERY ioctl cannot run between the two updates and report an innocent reset to the guilty context (Lucas). - Link to v2: https://lore.kernel.org/r/20260710-etnaviv-reset-notification-v2-0-90cfebcf22a2@igalia.com Changes in v2: - Replace the two GET_PARAM values with a dedicated RESET_QUERY ioctl that returns both counters in one call. The ioctl has a flags field that must be zero for now, so the query can later be extended to name a specific context once a DRM file can hold more than one context (Lucas). - Make the reset counters plain u32 instead of atomics (Lucas). - Use __u32 for the ioctl counter fields to match the internal counters, following i915 GET_RESET_STATS. - Link to v1: https://lore.kernel.org/r/20260709-etnaviv-reset-notification-v1-0-64c617496958@igalia.com --- Christian Gmeiner (2): drm/etnaviv: Reference count struct etnaviv_file_private drm/etnaviv: Add GPU reset counters drivers/gpu/drm/etnaviv/etnaviv_drv.c | 46 ++++++++++++++++++++++++++-- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 12 ++++++++ drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 5 ++- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 ++ drivers/gpu/drm/etnaviv/etnaviv_sched.c | 5 +++ include/uapi/drm/etnaviv_drm.h | 19 +++++++++++- 6 files changed, 85 insertions(+), 4 deletions(-) --- base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda change-id: 20260708-etnaviv-reset-notification-b037153a1aab Best regards, -- Christian Gmeiner