From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.60 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795003903; b=jaNSb6TJDQ4t+8V2osvrs36eFwFZA8gsK/nxLqhSp6bwVaNknl90NXM8kwwQOy2F0PV6 luo9XxlEPWAvuzKLk+wSKzdvFECMjZDrDTBVXNbOeOikgIPiI2TkwUeHtzERyr1KRRoP0 L4iRHcgUho6Nqqs/rUjNWVlNJvyCQxrXLPiYnfZ8a3LwelWxo7SUzEED6xbrk0EmDBUFg vBiFxGILnsyCWwUU8LmcWf2qxSHW737G+SUQQ545tgVuMp3B49T/DaalpMQqX0cQ18G3v EeyiFhHXaGYT4aZzLGN7e8DZ5CZ8Mf52frOktjdSkiWyfYsVU/UAgESdLYWCiaaKvMw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795003903; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=qZOJfcPvfcPzFAhulRxEN69saoo9gATIT2uEQBXDjVE=; b=3yYdqeu1pmNFLPjnmMf1qBRfyA4GWX5JFvZoQ5tN/QabiS1a3YFJ/TZqw5MTSgU/lpJx RazSOil7bHS0d1p01f+gNnz+jiwcrG2AV3WgfBSLh7O/kIWT3E/Ml8u08h4b87r6gLmTy WbWk9ZC0BmjSQt1KlDM5xXfNlwsykYT3oXRYwtnM7rKCgYxmPcYXXusbzsiyc5hmX0Q/v ryCry4sYi+grvRFWCE8WZZZQzgvSCoBtqrSRSo+WolGB/0TcRyZW1Lp/9Y6bGOIFMcnnI x4pAsOF5bsl7dER2avlhLdn4FDGUciUUHUOu2VY55UfV6S+jOcZj1Hg+n0u/yDnDBEA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=bNB7njdO; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.60 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010060.outbound.protection.outlook.com [40.93.198.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C89C4606A31C for ; Wed, 18 Nov 2026 12:11:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C89C4606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com 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=bNB7njdO ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8NljqThW6rssSQnaoDTUT8SdA55LuzU1JU7PB0qHDAFu/kAIU/7oaw4SOfuVmIHfG/JnFPg9z1qkwxcMuMQVFIkVKGF7CB2sqNUELXrWnjv4QM6GxZPhX8CXyKBDoGU28B+mPbqbs12bZjIiAwtzVJaDc8Ek6UeS+YVIiPKfRnAhJGp0Hk8D8j9sVEBOxviDueVPIQ+8f7z3do8WOjqB1ZiTh3x2Wc1Wkkf25amOEREsAMyUfGbjMFV7wUpAwkzji+U4JZjpzQPSwR/Bp8WzWfxyxAIIeUKjaivOS6CCgg1kWUW7NPzpoC67zsYEgEi+lLATj5AGf6u/Tvbulbtyg== 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=qZOJfcPvfcPzFAhulRxEN69saoo9gATIT2uEQBXDjVE=; b=cbWSV2r8EDJY0iesYxl2y8kmsbmmBcjEl3G1pGxPmZXa98rIKhSYIeQP3Ne5fjPEDHbXa0LDI5nTcZw0HKrbYT20rDUYk+caiCJQ4/oiyDcyMVe83DdykAbXH8h2Q95U5Pd1Pm8Wum1XYzpri94fsCDri66Q5nfC+LUiybw+0wYicpD90q4I/9mgV0duc4gQmvc8WwCvc0smPvh+TKE9p5u8LUChmDMKKHOk8gZwg+UX/l8ODSAobiNL4iNrJpnMXIGdF4c7jR2TcV7YqkY8iBdj1fRhwh4atB2+Rdv8T55aS4Y+sj0cEFpf9UrRfYXE634+dv/pjb2gcI+TK3kZqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=qZOJfcPvfcPzFAhulRxEN69saoo9gATIT2uEQBXDjVE=; b=bNB7njdOFcC23ZE0crItsT/eC9kA7l4+6BbrKrWlgK3Y2/VtvnxyA5DlkBeXCfodKsHT5dFbreNBhRdhBKp7dSsEF9734E+l0eibNjOACd77sDye0PmfXKgsSQJMDz3ZyVXua+Zi50jP0NZNso4fFJrS7pmp4zw6Ej6szckNAWU= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) by DS0PR12MB8413.namprd12.prod.outlook.com (2603:10b6:8:f9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.615.10; Wed, 18 Nov 2026 12:11:40 +0000 Received: from PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::ce69:cfae:774d:a65c]) by PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::ce69:cfae:774d:a65c%3]) with mapi id 15.21.0615.013; Wed, 18 Nov 2026 12:11:39 +0000 Message-ID: Date: Wed, 18 Nov 2026 13:11:34 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] drm/radeon: stop the GPU before kexec To: Nickolai Zeldovich , Alex Deucher Cc: David Airlie , Simona Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20261117170328.56738-1-nickolai@csail.mit.edu> Content-Language: en-US From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: <20261117170328.56738-1-nickolai@csail.mit.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BL1P223CA0040.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:5b6::13) To PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5685:EE_|DS0PR12MB8413:EE_ X-MS-Office365-Filtering-Correlation-Id: 99cd6d5e-468b-4428-eeb2-08df456d19bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|22082099003|18002099003|6133799003|5023799004|11063799006|56012099006|261022075727099003|261028144727099003|10067099003|261021121427099003|261009223027099003|261021135927099003|261102123227099003|261026121527099003|261026140227099003|261022105027099003; X-Microsoft-Antispam-Message-Info: uGLaXhmo/FGBtqVGC4cotz8I2HbIU+bNYNBAqKfHksx6TvqTsr8kqV7mAlRNHRPLw2zBglIayK211+DKQwohSx9PkTQXtfevzzIWjhb9pqh9+UdbdOAK6RZXFoPf5p7CnG9ajoOTJIjtSbNHOVc/jzbwT11MZW4QmKe2pjnjePHTlOzC33RjitEcQI26AZVYH8cWXYEfFtv4rZ2ZzrTlDyYMqsdbLqdJaxhtnWJbFtaW4tNMZOzEFqaQ8g9HKgQSVpi04qTJSOBDDag/fQy14biV7iULQXGsKqsmyxhwyQCgeldH3Bj95ChraVduZTmD+CD41KBtxpu0pOUBDihgvRCAY/iBXSOqHPCyv/nGId/mC8n8j/pIa1DH5U65WjKmJaNPX2wvkoxSYsfTf6iEdxuAvqkWom4bUwBN3ruWUfFP6nk9ZKhj9m2/64X3CJ4CoLawhu7pGXjzJcp9gZf9XUEKfPTWrUOvFeUb6xbkxduxwNEXV89ll8X1cMXpvsrByFm5bvA84i387lUnT7oES5SsA7VNvht/lOqM+Zf/s4/T7fCNnED/DOW0jteqPaj3jWb4NXVIz4J62vS3Hbt7KFTR+rgaqbpKKxnslK+EFcQLyHXHhnpkMfFBAKZxK8nB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5685.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(376014)(22082099003)(18002099003)(6133799003)(5023799004)(11063799006)(56012099006)(261022075727099003)(261028144727099003)(10067099003)(261021121427099003)(261009223027099003)(261021135927099003)(261102123227099003)(261026121527099003)(261026140227099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dzIwbTc3ZFdMejViV2wzeGVZV0pMQ25jWm5abXF3b01wTUJLTDZQSFQzcEtM?= =?utf-8?B?QmNWbXJONVhuNjQzb1lsV1hvLzRuaW5TNStuL3M4dEZ5Y1FId0VRaDFQem95?= =?utf-8?B?R0JndjRnaGtVeDdEcjFBeDlnTGpXRmppVzV1L2pUR0pJRHFSRTdYT1lwSStI?= =?utf-8?B?dFB4dzNsWnNkU21nQ3Q1Wkh6aTJjOE1heWdkZm5qc25qdGc3VkJzVWdUalZI?= =?utf-8?B?Mkw1bmlXMWo5OGZMZ2o0UFM3aUJhd29seHdYbW1BSnhXeXlPbTBNbkpPVFEw?= =?utf-8?B?aDRnVGRmd3hXY3hKT00xQnZyc2pJcXdKZ2dUWWs1b0FINEVFd0tKUzUyOVJa?= =?utf-8?B?K29ESGx1NFBiVHIwNzA5NlNTQUxnNVl6U21WcnlxV2lKcU5xK2hrVDd0UHhD?= =?utf-8?B?RStNYk1VbFZGZjh6UVc0ZHhENnRCOWtrZ056K2owT2x2dlprN1NIZGxvNU9V?= =?utf-8?B?cG9vYmxDcUZwbUQzdEt4UTlVeTVKZlJ3YVZBOU5wL2xoYjJkS0VMczZ1eXNy?= =?utf-8?B?eERoVXBSTDJaSFQyVFRERVB1bXR0bmZmWGpmcUFYRVRsWEhyb21kaVh4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bf X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5685.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2026 12:11:39.8262 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ftz1aHi21c5GQ+MMy06rj9LFXryayS6OkDHJ+NNDCzad2mLmy4CmmpqqXcoP2rzK X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8413 On 11/17/26 18:03, Nickolai Zeldovich wrote: > On a kexec reboot, radeon leaves the GPU running, and on a system > without an IOMMU the GPU then writes into the next kernel's memory as > soon as radeon probes there. > > The PCI core clears bus mastering before the kexec, but the interrupt > handler (IH) stays enabled, with its ring and write-pointer writeback > mapped through the old kernel's GART. The new kernel's > evergreen_mc_program() raises page-flip interrupts before the new GART > is set up; the GPU holds the IH writes for them while bus mastering is > off and issues them, to the old kernel's pages, once r600_irq_init() > sets it again. Good catch. > Suspend the GPU in radeon_pci_shutdown() on kexec, as PPC64 and Loongson > already do on every shutdown. Normal shutdown and reboot are unchanged: > commit 8d13c187c42e ("Revert "drm/radeon: Fix EEH during kexec"") > removed the same call there because it hung some HD 5770 systems. Yeah that is clearly not the right approach. The kexec is often done to switch to a new kernel because the old one has encountered some severe problem, doing a HW suspend in such a situation is not guaranteed to work. What should be done instead is to fix the initialization order and/or disable GART before the bus mastering is enabled again. Even without kexec this situation can happen because the PCI reset handling on those HW generations is often not working correctly. So in situations like VM path through you run into the same problem after a spontaneous reset and there you don't have the change to suspend the HW. Regards, Christian. > > Tested on riscv64 with a Radeon HD 6450 by pointing the stale GART at > canary pages after a kexec: without this patch the page-flip interrupts > write IH entries into them, with it nothing is written. > > Signed-off-by: Nickolai Zeldovich > --- > > Notes: > Tested on a Milk-V Pioneer (SG2042, no IOMMU) with a Radeon HD 6450: > 9 of 9 kexec reboots of patched 7.4-rc3 into itself came up clean, with > radeon and the desktop running. Unpatched, kexec boots there > intermittently oopsed, logged "BUG: Bad rss-counter state" soon after > radeon probed, or hung early in boot. > > Commit 8d13c187c42e removed this call from every shutdown after two > HD 5770 x86 systems hung on shutdown and restart > (https://bugzilla.kernel.org/show_bug.cgi?id=205147), but the cause was > unclear. Kexec runs the same radeon_suspend_kms() as shutdown and only > skips the firmware that follows it. Shutdown and restart end in > different firmware paths and both hung, so the hang was more likely in > the suspend itself and may recur on kexec on those systems. Also, with > this patch the GPU reaches the next kernel in D3hot, so an early console > on it (vgacon, efifb) is not decoded until radeon wakes it; PPC64 has > done this since 2019, but it is untested on x86. > > Separately from any hang, I would expect that kexec without this patch > would let the GPU corrupt the new kernel's memory on those systems, as > it does here. If you prefer to avoid the full suspend, a narrower fix > would disable only the IH: clear rdev->ih.enabled and call > radeon_irq_set(), which on R600 through CIK turns off the IH ring and > all interrupt sources without waiting on the GPU. That skips the code > that may have hung, but leaves the CP, DMA, UVD and the old GART set up; > they stayed idle in my tests, but nothing stops them. > > Reproducer (Evergreen register offsets): run it as root after a kexec, > with radeon not loaded in the new kernel (modprobe.blacklist=radeon). It > points every entry of the old GART, still live in VRAM, at canary pages, > so stray GPU writes land there instead of in kernel memory; rewrites the > D1-D4 surface addresses to raise page-flip interrupts, as > evergreen_mc_program() does; sets bus master, as r600_irq_init() does; > and counts the canary bytes the GPU changed. The IH usually holds its > writes until bus master is set; in one run of eight it did not wait. > > gcc -std=c99 -D_GNU_SOURCE -O2 -o ihrepro ihrepro.c > echo 0 > /proc/sys/vm/compact_unevictable_allowed # canaries stay put > ./ihrepro > > old kernel unpatched: bus master off, IH on, GART on > 68 canary bytes written by the GPU > (four 16-byte IH entries, 4-byte write pointer) > old kernel patched: bus master off, IH off, GART off > 0 canary bytes written by the GPU > > #include > #include > #include > #include > #include > #include > > #define DEV "/sys/bus/pci/devices/0000:01:00.0/" > #define NPG 1024 > > static void *bar(const char *f) > { > int fd = open(f, O_RDWR | O_SYNC); > off_t sz = lseek(fd, 0, SEEK_END); > void *p = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); > return p == MAP_FAILED ? NULL : p; > } > > int main(void) > { > static const uint32_t crtc[] = { 0x0, 0xc00, 0x9800, 0xa400 }; > volatile uint32_t *mmio = bar(DEV "resource2"); > volatile uint64_t *vram = bar(DEV "resource0"); > int cfg = open(DEV "config", O_RDWR), pm = open("/proc/self/pagemap", O_RDONLY); > uint16_t cmd; > > if (!mmio || !vram || cfg < 0 || pm < 0) > return perror("open"), 1; > pread(cfg, &cmd, 2, 4); > printf("bus master %s, IH %s, GART %s\n", cmd & 4 ? "on" : "off", > mmio[0x3e00 / 4] & 1 ? "on" : "off", mmio[0x1410 / 4] & 1 ? "on" : "off"); > > /* point every GTT page of the old GART table at a canary page */ > uint8_t *c = mmap(NULL, NPG * 4096, PROT_READ | PROT_WRITE, > MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_LOCKED, -1, 0); > memset(c, 0xa5, NPG * 4096); > volatile uint64_t *pt = vram + ((uint64_t)mmio[0x153c / 4] << 12) / 8; > uint64_t flags = pt[0] & 0xfff, n = mmio[0x157c / 4] - mmio[0x155c / 4] + 1; > for (uint64_t i = 0; i < n; i++) { > uint64_t e; > pread(pm, &e, 8, ((uintptr_t)(c + (i % NPG) * 4096) / 4096) * 8); > pt[i] = ((e & ((1ULL << 55) - 1)) << 12) | flags; > } > mmio[0x5480 / 4] = 1; /* HDP flush */ > mmio[0x1470 / 4] = 1; /* GART TLB invalidate */ > > /* raise a page-flip interrupt on each CRTC, then enable bus master */ > for (int i = 0; i < 4; i++) > mmio[(0x6810 + crtc[i]) / 4] = mmio[(0x6810 + crtc[i]) / 4]; > sleep(1); > cmd |= 4; > pwrite(cfg, &cmd, 2, 4); > sleep(1); > > int hits = 0; > for (int i = 0; i < NPG * 4096; i++) > hits += c[i] != 0xa5; > printf("%d canary bytes written by the GPU\n", hits); > return hits != 0; > } > > This patch was written with the help of an AI tool. > > drivers/gpu/drm/radeon/radeon_drv.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c > index 53d06053dec8..cd786c3264ff 100644 > --- a/drivers/gpu/drm/radeon/radeon_drv.c > +++ b/drivers/gpu/drm/radeon/radeon_drv.c > @@ -31,6 +31,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -379,6 +380,10 @@ radeon_pci_shutdown(struct pci_dev *pdev) > * it breaks some other boards. > */ > radeon_suspend_kms(pci_get_drvdata(pdev), true, true, false); > +#else > + /* Clearing bus master does not stop the IH writing to stale addresses */ > + if (kexec_is_in_progress()) > + radeon_suspend_kms(pci_get_drvdata(pdev), true, true, false); > #endif > } > > > base-commit: 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4 > -- > 2.47.3 >