Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp29305lqq; Wed, 12 Jun 2024 15:29:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4jam8LjGCH51IRcxgoZdvjI9Zp+/fS+J6zLGpGXJi5BtHw2faxS04qdmmR6XO7zPev4DBmOpwLMJM6yOmVNVUpztvdRyDLK3lPUCMyQ== X-Google-Smtp-Source: AGHT+IEoD3/uB5WtGOu4J1U/dhdJypcuaK8eGQCgQCDDI0dWy3uVR/aTRFizq6Y8NXKdMPYrG+71 X-Received: by 2002:a05:6e02:1e0d:b0:374:9bc4:ce1a with SMTP id e9e14a558f8ab-375cd0f16c9mr34766885ab.20.1718231342584; Wed, 12 Jun 2024 15:29:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718231342; cv=pass; d=google.com; s=arc-20160816; b=wK2rY01qhCfN1atUb1UoQMa00UGRdUtaRtf06zW3rlXYvqRWSuZ0qwZFE0ap8MkxsN M/pQYCJ7MNymB3ud4jtl6Ibd8L30CVk2GLui1MlBWz3cItA0jOrzBPtDQF44O+gBkgWA Q71kDWw59VBda0DYUhip3cupkPg4lOzGQZHG8oV7YyVUYZVdJ5V7YoLaLC79ev9piYRZ TqB48GfVMFJaFx4d7xAvrJ3QPlyOsRnygwDfv87R7cO5nbA/G2vWy68zcmIbHqeNdjwq A+LBMsEXtGxat/+sdEYuuQeNkSoI3vkYlP/Fr0RHEmj9x9QjvW/GmrSw+ErVqaXCBc9e NF+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GlLfBbnX9FblBpW76gVStblANR7z9T1g0t5a6w4/nbU=; fh=0NV5Qd7nFFCbnRN2pg89rww6NkeJTM0qf/4o/F+S2qs=; b=KeEsWjpgqztQhKC7FY12QLeprfnGIcsvatCY/oziOYQNxm21E+JF3wQfvdgKFtxuIL gv7PqMkDnB+9HFSX0iCDT+9xVKV++vSu90DB55KDCc4u8qwKyfy1Uu78AFDeLB6pBRIf H3066bMW+rEp5RqJodBnNZtITWIKEOHf9E+qXCseFrVFUjqUs9tcSyIg/1UbQmZQl0+M /z80jKtMLpAgu6dWTshnU9co4eNeUvfh0oY87E0xKU5oLPbFheJwSF6q2iShpar1L3+Z cdglvqpTd9253CprSVrWZu51mw5pfpVLWh1uz76dnZ7PLJp4MFVtk+JSesHObzJjEVd1 O08Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gfkHK+Ch; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-212327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212327-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2760c321si12313267a12.557.2024.06.12.15.29.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:29:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gfkHK+Ch; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-212327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212327-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8ED1F281BA1 for ; Wed, 12 Jun 2024 22:29:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77F6712C499; Wed, 12 Jun 2024 22:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gfkHK+Ch" Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 2E52484D11 for ; Wed, 12 Jun 2024 22:28:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718231329; cv=none; b=jM34jtIIylp0jlj/KB1M9bVF9VlDjU/w9c1TBZYYvhAtFYTFzGqWW5Ic+FL5O0Jssd6zNZyafdnIKvH8DIsls7kFQwGlk2TexWztqz6K1XwF/iB8Lsb2Bfpj34Yx2ViD5Y1XINdbMAliFJZNJ2JD0DcYMl4hENKDbV9kodxGk5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718231329; c=relaxed/simple; bh=0YYBkjwBMNK9jlWYzSWYFWWhvwfI5jrnzT5YzQooxbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GxAZqRUB06NbjDrZhJpuMGxLkk7CT/z1VlSeXh6/R6nUPVDJVXgCSRyZEnX6qSIPpo/KsRKx6/5HdWl13oTLWJYI9WimSxdKUVz7AJeN0ER6/QBERv4weT2DHb3pLf2yewQ9/yImkmwWMGMdO/KqqC7fByaaCYE9sE3PGZO1J1Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=gfkHK+Ch; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2c2dee9d9a1so240504a91.3 for ; Wed, 12 Jun 2024 15:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231327; x=1718836127; 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; bh=GlLfBbnX9FblBpW76gVStblANR7z9T1g0t5a6w4/nbU=; b=gfkHK+ChkSFh+w/NVzSJJsuTIMrRcp/tKjaMKQciHGSPZTSKHm9kkkN4oS8mUlftDU rHFBs54t4sO4htN/cEEBqRYs9aJijgUnE8Z3yU3ik9zEoJa7v7IQUy/DTgBXDDTiKZa7 pbZ/Ej/owDBNt2fYjo1tCKY/LErTho2b0e1lA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231327; x=1718836127; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GlLfBbnX9FblBpW76gVStblANR7z9T1g0t5a6w4/nbU=; b=YIRunZ8H4lN8uiEFuYqYv6U2TO9O69w+RoINfpxl41DH8rMDEUunOlHJgWFkZdivGN v58yjqgvcUl36vI1x8shUZP5GeagiJMzeBZvWF4waKagalmyA36PNCxOxgN8/JIWA1Gl 1V6Me0s4ApPZU1GWp1evNGSO3aPqhKeAtii2ZsONiIH2klSYPhP32u373gSp0ewRpAfr 5zQsn8BqaDQSGoNKL3lNFVLItiV8bMI+fhkFUsr4QsIhEdXMKKXttPcj8j0+BY3TVHzA HEj/C1b8YXrPfGt5cp3HiM3QkqZeGqVItnIDpv+MBK6lEuNFvIWjvalKk3QKlj3hmwwD nnlQ== X-Forwarded-Encrypted: i=1; AJvYcCVBFCyjhiYozwDauL/bbAtY2XV88hjaZRMjObUEbwB1FCE845hjWoXDrcIc2TdfM0Pp0epFd4umpT26XHgCnUqvBkPXFpStT6Ig6ZVa X-Gm-Message-State: AOJu0Yz56SvtgctOsWND4MFi6W1BNrtTZDNtHtJwgymKDctqixC5Icwg TsGICcFFj6bgpoM2ol9FecGjougicn47fBe9g0AWQBJpFx92SCLfnsAD6NGwTw== X-Received: by 2002:a17:90b:4ad2:b0:2c4:ab32:b723 with SMTP id 98e67ed59e1d1-2c4ab32b8c3mr2926957a91.29.1718231327185; Wed, 12 Jun 2024 15:28:47 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f336d172sm87788575ad.247.2024.06.12.15.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:28:46 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Xinhui Pan , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Aurabindo Pillai , Candice Li , Daniel Vetter , David Airlie , Hamza Mahfooz , Hawking Zhang , Le Ma , Lijo Lazar , Ma Jun , Mario Limonciello , Shashank Sharma , Srinivasan Shanmugam , Thomas Zimmermann , Victor Lu , amd-gfx@lists.freedesktop.org, chenxuebing , linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] drm/amdgpu: Call drm_atomic_helper_shutdown() at shutdown time Date: Wed, 12 Jun 2024 15:28:04 -0700 Message-ID: <20240612152752.v2.8.I27914059cc822b52db9bf72b4013b525b60e06fd@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> 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: 8bit Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard Cc: Alex Deucher Cc: Christian König Cc: Xinhui Pan Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. ...and further, I'd say that this patch is more of a plea for help than a patch I think is actually right. I'm _fairly_ certain that drm/amdgpu needs this call at shutdown time but the logic is a bit hard for me to follow. I'd appreciate if anyone who actually knows what this should look like could illuminate me, or perhaps even just post a patch themselves! (no changes since v1) drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f87d53e183c3..c202a1d5ff5f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1197,6 +1197,7 @@ static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_device *bdev) int amdgpu_device_init(struct amdgpu_device *adev, uint32_t flags); void amdgpu_device_fini_hw(struct amdgpu_device *adev); +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev); void amdgpu_device_fini_sw(struct amdgpu_device *adev); int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 861ccff78af9..a8c4b8412e04 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4531,6 +4531,16 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) } +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev) +{ + if (adev->mode_info.mode_config_initialized) { + if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev))) + drm_helper_force_disable_all(adev_to_drm(adev)); + else + drm_atomic_helper_shutdown(adev_to_drm(adev)); + } +} + void amdgpu_device_fini_sw(struct amdgpu_device *adev) { int idx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index ea14f1c8f430..b34bf9259d5c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2409,6 +2409,8 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); struct amdgpu_device *adev = drm_to_adev(dev); + amdgpu_device_shutdown_hw(adev); + if (amdgpu_ras_intr_triggered()) return; -- 2.45.2.505.gda0bf45e8d-goog