From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 64C9078F2B for ; Sun, 9 Aug 2026 08:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786265388; cv=none; b=reBaJxjOTNrgy+iEcLY09qAuXhOMDufuEFoK5fb8/3LzTTMQl38t+5IyGLbT8goYeFxeYKCEdU2hsuVMN8SdM1JSV9eOH2Dn4fBkRr6wE+vP65aHCFg2Ee2e6Egsw2XbES/7SmcLgP0TveS5K0h/OTqy9uX1F9C19/uxkT5PjzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786265388; c=relaxed/simple; bh=mlq/3tdlJrEy6qPNfLBgSwS1uRqxNWYL9wgbN6jmUmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oEP3ncUVC9K6qE1XnexiAcw5EmWAj45zD5duaiLZHpBqzQAaHDvtqlOhO7Y2UDKoOsqBmmJb5vGgob5PlZcaylzVIwDuDAPDCMSed6htiM5UWhHq7HBx40mGd+zLma5nSjidLMawZ9vo3AWZTOI4ihqKbA4lkDEDz5XLUKubmn8= 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=aKW3rW22; arc=none smtp.client-ip=209.85.215.176 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="aKW3rW22" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-cbe3fed2f58so639294a12.3 for ; Sun, 09 Aug 2026 01:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786265387; x=1786870187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=82v9sYNKKB3ALGXPfLnFRe1IYhxbaPWojRznailPiqg=; b=aKW3rW222XW8YCKBaMudnmeDQdT/RiDCeJAIlW4Rv0Ucg8MKFXBo0VkcF/FiH0FaNI +TPDSb1clnoE2Vzr2tcZkaJW/jLFjq9gCda7nIE7iYUFVTzLzQeuite3JtRLRvUUkh9Q /3UIwUhSI+89Dx1i9+euCmil3P8q884M6lsP+f+8RA0cNBtwp3uNuM8WB1lUfTWZOddE TnyBf+sVjxqMCRmlsDKbKoHSFeZcVq3EbiwZ1EVaTPmW+4Kz8bop9CrpHIyL/clqmqwt qgqni2TarB/BXgYZ/WYgehbDpt3Z/FDpkn82YzvUVsTJfa22xSZrYTnRZrTGb3j7ZHp3 KQ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786265387; x=1786870187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=82v9sYNKKB3ALGXPfLnFRe1IYhxbaPWojRznailPiqg=; b=iDHK5D4sYP9c4o/1Gsszc9ZFRl3F378C92tl5X7suLdWNr7IwpGrtFN6RuC6APiKJf /ZhlxTqID+lQjxNH7aWIRqg9Ig1a6ntl25DRBfSe7Z6rfPxgM1cqB0DyVJkN1n8iCQ3l PUDywaJ8NgUorHTpDOUuK4CN910Yl4dklpbrpEcO9LhCAyJIK6nvdj97ytyqkJhbjasV 3gHNokd6i/FxBomqPNifayzcC9EwZyC1ujdfZY13yU7mcH852scYJRPpKU3WhoJM7n7v OBtYYEaEiswQbzLIYTqd+/b2mYFjXWjPoGAlZioHdPGwFtzG3WWyCktok0SWrUw64m22 gNHg== X-Forwarded-Encrypted: i=1; AHgh+RoWkG0uWELjtYcuO3TrsQ6m9VD/zS8LiZLJO/Mu2AotMOxvekS8Fz8kTYWYX36D9qwzgIl6LdD74rRBnV8=@vger.kernel.org X-Gm-Message-State: AOJu0Yzh2DN8I6tkCfI16RYLRYstEMIWF5ceTJVUEbX3ujp0ilYX/oxS DhNooX69vlZUxcM+qs9zgyg+nwb6GRciJOBqIlIUFjTaHliWxLzL4Ysi X-Gm-Gg: AR+sD11GAQOEb3G8N8ouRhN18HJecYBDSjg783y9S2JsdsuPIf/AmuJh+ylum6oQkiv 5JcWIoJYmlaxI9jL8xvX+bos+nwVujVaETV2WRWJhQj5bp9AM6J1lJjjMWbdTf0DAl1ILJRnJqO PoKai5c8lFopwn+8RCN65Nnf2+qyM0h0uoUA1vXg8K/FOUlxH4M95pae60ZlDFeR20+auF4P8qC MXb6pAyCZossvc6HQNhdNP4t72KHWGQRUUllkzeifT3BtMCA0Yj+s5nQI/iK/iS6J9k635U9GtT rJXKImDPeQ7AHQhB4ZjVOuUFRWq6+McA0jQrpeSZuURqKFsJATYSswHZBIg9D/WdEKfLqE7Uf4c hI3BdV3FENBCBmFFpNW/fuyvc0WbCBQ16CVm9saF+FxLZlPbTkVfzAogah7LcXzroF4qyT6dorh yKrtSTrB1T9L8HT+pYdCppdT3vesekwYUNh7sOW6O3c3oqLXKXwUSzu3EYU+ah+b6b9SI440CKE hnVDp5nTGo= X-Received: by 2002:a05:6a21:600f:b0:3c3:8651:b317 with SMTP id adf61e73a8af0-3cb85e2b72fmr40290617637.10.1786265386693; Sun, 09 Aug 2026 01:49:46 -0700 (PDT) Received: from localhost.localdomain ([103.178.205.91]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86fc7bsm28800025eec.1.2026.08.09.01.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2026 01:49:46 -0700 (PDT) From: Sreeraj S Kurup To: alexander.deucher@amd.com, christian.koenig@amd.com Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, airlied@gmail.com, simona@ffwll.ch, Sreeraj S Kurup Subject: [PATCH v4 3/6] drm/amdgpu/aca: Fix inverted validation logic and list cleanup Date: Sun, 9 Aug 2026 08:47:32 +0000 Message-ID: <20260809084735.9743-4-sreekuttan2156239@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260809084735.9743-1-sreekuttan2156239@gmail.com> References: <20260809084735.9743-1-sreekuttan2156239@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit aca_handle_is_valid() returned false if !list_empty(&handle->node) evaluated to true. Because active registered handles have non-empty nodes in the handle list, valid handles evaluated as invalid. Consequently, amdgpu_aca_get_error_data() returned -EOPNOTSUPP whenever aca_handle_is_valid() evaluated to true. Fix the logic in aca_handle_is_valid() to verify that the handle is non-NULL, contains a valid mask, and is currently registered in the list. Update amdgpu_aca_get_error_data() to check for invalid handles and return 0 instead of -EOPNOTSUPP so non-ACA blocks in global RAS queries pass through safely without breaking error telemetry. Additionally, modify remove_aca_handle() to unlink handle->node under mgr->lock using list_del_init() prior to calling aca_fini_error_cache(). Standard list_del() leaves node pointers poisoned, causing !list_empty() in aca_handle_is_valid() to evaluate to true for removed handles. Unlinking under lock first prevents concurrent list traversals from racing on node pointers and stops background queries from referencing destroyed error cache mutexes during handle teardown. Signed-off-by: Sreeraj S Kurup --- drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c index c76664af9902..c35f6be2ef77 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c @@ -586,10 +586,7 @@ static int __aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *h static bool aca_handle_is_valid(struct aca_handle *handle) { - if (!handle->mask || !list_empty(&handle->node)) - return false; - - return true; + return handle && handle->mask && !list_empty(&handle->node); } int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *handle, @@ -599,8 +596,8 @@ int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *han if (!handle || !err_data) return -EINVAL; - if (aca_handle_is_valid(handle)) - return -EOPNOTSUPP; + if (!aca_handle_is_valid(handle)) + return 0; if ((type < 0) || (!(BIT(type) & handle->mask))) return 0; @@ -716,9 +713,13 @@ static void remove_aca_handle(struct aca_handle *handle) { struct aca_handle_manager *mgr = handle->mgr; - aca_fini_error_cache(handle); - list_del(&handle->node); + mutex_lock(&mgr->lock); + list_del_init(&handle->node); mgr->nr_handles--; + mutex_unlock(&mgr->lock); + aca_fini_error_cache(handle); + kfree(handle); + } static void remove_aca_sysfs(struct aca_handle *handle) -- 2.54.0