Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 366AF3988F8 for ; Wed, 23 Sep 2026 02:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131669; cv=none; b=NWTI/eczVFENFLweT3++qmYq470R1VcEACQorsqEe546wpGT1kdkgLkBvMaDMLxZrMFpDVsZ6yrtzU5SAJuPZ52J0SvUd5VosIYHUAgrPUU//33mB8bKzhEZtaTfaEdxgEdVM/LT9tVkNaMHZgliVhIXE6lmftzdnPhteZ8z9l4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131669; c=relaxed/simple; bh=wo8SHfxAmhbT/LTEGB0VBJScaVQSOrmd3rG4wgtOkXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ReQOts46ntCfgUM2JxDNy0NpdEVZ+KE4gBtE/MoX5bKUXOah5NpqfRueg723gJfop7u3zUd5NfJd+5xzlDK956ggWOd1S6aMLQWxDzQCKOtN/ljPZFBENly/2rUa/+u0pnlMXgTukgrbx2Cs8s5EYqZqPZ2kHODVzuQklxNLh5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D7Fi/aWl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D7Fi/aWl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 252CC1F000FF; Wed, 23 Sep 2026 02:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790131665; bh=PV+cEnriZF+l4QEPTr7ul+dvACa9ikzoXjSwGqPJB+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D7Fi/aWlAdVxgapNfRQ284FiM0JPphtLw/Ng29Wo3KramKBW9uLPERAuoW8ZSIuDv kvspNqrOvmDHtHYWdPscaCVy3uUL8T6TbEE0fqYEVjVu6RGXKSqOG64D775RHpwK9v jOaPELV0RgY/SX/Q/Qe+Gh8BWwYg5cD1aRYDHxHamUIAJtfzUSqqmkfX0oWfx9DzB+ CsgABc/pT/qOWEDEcJovGnplS8CIcV5t6sC6zN9hpWHyDrE95gemgzDuVcjli/q1fv I9WtVQh4IA3LPclQyR+NgGSXREnPlOe1iR/aOUHizoDXHn0YDruvfj/nnJaMVzFJaf PzaWgg5kEVWQQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Chengjun Yao , Asad Kamal , Alex Deucher , Sasha Levin Subject: [PATCH 6.1.y] drm/amdgpu: fix rmmio iounmap skipped on device removal Date: Tue, 22 Sep 2026 22:47:43 -0400 Message-ID: <20260923024743.1045912-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026092242-unknown-blazing-f3e2@gregkh> References: <2026092242-unknown-blazing-f3e2@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chengjun Yao [ Upstream commit 5155002b03b24ba3ef91c5c313b8cf0171b24904 ] amdgpu_pci_remove() calls drm_dev_unplug() before fini_sw(), so drm_dev_enter() is already false there and the iounmap() guarded by it is skipped. This .remove path runs on both hot-unplug and plain rmmod, so the register BAR ioremap mapping leaks one instance per unload. Unmap rmmio unconditionally (guard only on non-NULL) and drop the now unused idx. Fixes: 62d5f9f7110a ("drm/amdgpu: Unmap MMIO mappings when device is not unplugged") Signed-off-by: Chengjun Yao Reviewed-by: Asad Kamal Signed-off-by: Alex Deucher (cherry picked from commit dd6f86a97260e5207d3329ad03aa89fdad61b1e6) Cc: stable@vger.kernel.org [ retained the existing DRM-guarded doorbell cleanup and its required idx variable. ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index f17577ed6252f..8d5e6dfea11ae 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4212,10 +4212,12 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) vga_client_unregister(adev->pdev); - if (drm_dev_enter(adev_to_drm(adev), &idx)) { - + if (adev->rmmio) { iounmap(adev->rmmio); adev->rmmio = NULL; + } + + if (drm_dev_enter(adev_to_drm(adev), &idx)) { amdgpu_device_doorbell_fini(adev); drm_dev_exit(idx); } -- 2.53.0