From nobody Fri Aug 14 15:48:51 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 C3D1C45C6F7 for ; Fri, 14 Aug 2026 13:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714078; cv=none; b=LJ9+vstqpRM80i0zTMJFUeQBNaPajwCINtYz1YqJ8Cv9ZfO1TAkv9aBt/wOdnKojQf1UCkLT29nK+TZ6sQVAsXCTVD1y2yMQ/KFZtf+kc32Z6nAQqTOw+enfhD8wuhv7T53NE2ssdckiUYyoFcoM4kKG/b3aAuKWeMz1LDEuZ9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714078; c=relaxed/simple; bh=FdQIgYWQhkciDzpqIeBCg3rI5AHw3lueg6yJyzZrfwE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=R4vEnAMd7zuQBTP92ociIY0AXt1ggC18Wqm+wW3IT8fykfl+GWYLBMWEn6ZZD8NkaKRwO3867iNp/pnQ04u0xAO3eq484LLV4yG71/UN1ko7VXVmled6yCblHXJrMgwkUGgFuto3ck7KqXl66ctT6GHhB1v7MRiQ0F0/HgvU9IE= 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=czD3PTBc; arc=none smtp.client-ip=209.85.210.177 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="czD3PTBc" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-84e0688b7e8so760830b3a.1 for ; Fri, 14 Aug 2026 06:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786714076; x=1787318876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=MWWnpnQHVUIEDdKadx6AJONzCNBQuep858a4rr+92VI=; b=czD3PTBccPRx6JttxyWeDh7eHmQFrfCcHMcSrxlg/phTjEKC3BQg/v098/l2bUdWDR z3RNhAE598i6eSZI9iJ06R3PP8cr9k6biLl33Mvw30IWONzgwHOnnw1AcmN0+VNSMb07 IVA686hzgL1fS4s4dluar9Hp6D0FQPDzoM60m+FFJ2peaaycgJubiZCBNl9x6cB1ewBo ZoY6pyVTJRpxAPRTs6IuU0lPGHlA67kB+64gVvkwOPimUSkqW40aH3XkavUMqw7o3SzQ bZ2GE4je+4T/mErZO3pTUSB3w8S8q0dBQZH0Iil21SeoN3YAXK8IFsXl4UaUjGIeQTnn 1p9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786714076; x=1787318876; h=content-transfer-encoding:mime-version: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=MWWnpnQHVUIEDdKadx6AJONzCNBQuep858a4rr+92VI=; b=KY0+12U6AZWsWR0J+OQiwS7b/N2aob3o9gThPtFjzX5CrVYGkaWEDlAqWRC/PU3cVk crjNKhQBsfFwWuTheeeS4pmnGVt7DWq9QBdj7vNUA2GBlLmbrFV8BE1FY1ChY1Q1f2la o0Ucrr1C18uKuh7DB9uajeYFjGKXMpzoe43VKOBqYh2yahaBLQJ6MZQXcMmpsrmD3FKW x3tfhcEqs53GdvTFfG/dABxu0rRxwBoPoTa+7lgKiHY8fqWoF73fEdB46v6ZhY+362pj mL+E11tnlQBeQ0koKhDIZBAZa99XJaEzyIFUSnLZurnm00Xjl/c5iLgneqb56PVAeJMZ xvYw== X-Forwarded-Encrypted: i=1; AHgh+RpSm43gGiuLIGHr6pwr7WClHBTT1VRsV1pnRwVOvpDuSqXu7zGHgWzC2E0KU66wGysbhjvlO6P+oLRmOQs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7ba8CdErAFcM0rbA7nXeYpz7qaObdfRTNsQXQKhe9mWOLZuV8 XLfPDKkJnVLw6ygH19Q9ad4mdzC1+SMYKBf98DzAz04JLZbmF0tqvXKxwr6fO9RaOGvsUw== X-Gm-Gg: AR+sD12zcXuyW/ZO79/FkzOEfuWEfXsApYwBWDLHAmuZdM1vvb01jHZU+zzTqtUCkTU kufVYMJYJqLUlx+aLk4eLMMfTdaxdNP9sWYQM4biReswfSJcukPS5AOy8xzqTH21s2ETJw0d9QH nouaV9hOstlJ+cc1a6w+gY82ILE0rwuIo0jm393+nkaqivvi1C3dObe5xLI837ifmAXQsSVwgFQ xXKVH/r2ctkWM3+vtR61l9jD650D9riJC6B+OZV5d0uFE/idqr+ORvDY+Y8HXY4+3n1CBMbaLeq gPPBOF3P8OuZaXXSpiTMRK9Z79shiKU7nBEAp89XtrFgHSaj+iSTpAmryuLI4EkgDgmucJCqmUR /AMxj2NJKO4/uNWWDB7CyNaOMkm1dOa0s9Gu3Guu6D1jPN7uCUIFuer4NjCPQ6z6/9v/oDciv9M 7s1pq9U/AssigO2yI7EevV7V/tow3kbNbrBOHUfK4By5ojI0Ia8L+FCSip1drHQ0jyocHW/ib2J m0rjDfq0oCw45C5aYXuVO4= X-Received: by 2002:a05:6a00:2da3:b0:845:cdc1:a803 with SMTP id d2e1a72fcca58-84fddfe09a8mr5708980b3a.11.1786714075908; Fri, 14 Aug 2026 06:27:55 -0700 (PDT) Received: from localhost ([219.70.128.183]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8517d267305sm463541b3a.52.2026.08.14.06.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 06:27:55 -0700 (PDT) From: reza.jelveh@gmail.com X-Google-Original-From: reza.jelveh+git@gmail.com To: dri-devel@lists.freedesktop.org Cc: Min Ma , Lizhi Hou , Oded Gabbay , linux-kernel@vger.kernel.org, Reza Jelveh Subject: [PATCH] accel/amdxdna: Keep PCI power state in sync with runtime PM Date: Fri, 14 Aug 2026 21:27:43 +0800 Message-ID: <20260814132744.516105-1-reza.jelveh+git@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Reza Jelveh The platform powers the NPU down as soon as the driver stops its firmware, but aie2_hw_stop() never recorded that transition. The PCI core kept tracking the device as D0, so on the next system suspend the noirq phase attempted a D0-to-D3hot transition on a device whose config space returns 0xffffffff: Unable to change power state from D0 to D3hot, device inaccessible The platform's power state was then out of sync with the kernel's, the SMU idle condition was never met, and suspend-to-idle did not reach the deepest state. On resume, aie2_hw_start() re-enabled the device without requesting D0 first and failed reading the SMU mailbox (0xffffffff, -EINVAL), leaving the NPU dead until reboot. Record D3hot at the end of aie2_hw_stop(), while the device is still reachable, and request D0 at the beginning of aie2_hw_start(), so the kernel's PCI power state always matches the platform state. Skip the firmware stop in aie2_hw_suspend() when runtime PM has already stopped the device, and demote the "device is already stopped" message to debug level. Signed-off-by: Reza Jelveh --- drivers/accel/amdxdna/aie2_pci.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_= pci.c index a7b923005..ad14e4fc6 100644 --- a/drivers/accel/amdxdna/aie2_pci.c +++ b/drivers/accel/amdxdna/aie2_pci.c @@ -288,7 +288,7 @@ static void aie2_hw_stop(struct amdxdna_dev *xdna) struct amdxdna_dev_hdl *ndev =3D xdna->dev_handle; =20 if (ndev->dev_status <=3D AIE2_DEV_INIT) { - XDNA_ERR(xdna, "device is already stopped"); + XDNA_DBG(xdna, "device is already stopped"); return; } =20 @@ -301,6 +301,12 @@ static void aie2_hw_stop(struct amdxdna_dev *xdna) aie2_smu_fini(ndev); aie2_error_async_events_free(ndev); pci_disable_device(pdev); + /* + * The platform powers the NPU down once the firmware is stopped. + * Record D3hot while the device is still reachable, so the noirq + * suspend path does not attempt a stale D0 transition. + */ + pci_set_power_state(pdev, PCI_D3hot); =20 ndev->dev_status =3D AIE2_DEV_INIT; } @@ -318,6 +324,13 @@ static int aie2_hw_start(struct amdxdna_dev *xdna) return 0; } =20 + /* The platform powers the device down when the firmware is stopped. */ + ret =3D pci_set_power_state(pdev, PCI_D0); + if (ret) { + XDNA_ERR(xdna, "failed to power up device, ret %d", ret); + return ret; + } + ret =3D pci_enable_device(pdev); if (ret) { XDNA_ERR(xdna, "failed to enable device, ret %d", ret); @@ -427,12 +440,15 @@ static int aie2_hw_start(struct amdxdna_dev *xdna) =20 static int aie2_hw_suspend(struct amdxdna_dev *xdna) { + struct amdxdna_dev_hdl *ndev =3D xdna->dev_handle; struct amdxdna_client *client; =20 list_for_each_entry(client, &xdna->client_list, node) aie2_hwctx_suspend(client); =20 - aie2_hw_stop(xdna); + /* Runtime PM may already have stopped the device. */ + if (ndev->dev_status > AIE2_DEV_INIT) + aie2_hw_stop(xdna); =20 return 0; } --=20 2.55.0