From patchwork Thu Mar 30 23:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 77471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp205705vqo; Thu, 30 Mar 2023 16:40:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZX5wp8w4rk3laGVjTxj6OvscHfR9dBoo3aN2iessMqxQfPIdzWliyOBr1N/ie7PnsIlgzl X-Received: by 2002:a17:902:ec8b:b0:1a2:87a2:c91a with SMTP id x11-20020a170902ec8b00b001a287a2c91amr6881646plg.34.1680219658753; Thu, 30 Mar 2023 16:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680219658; cv=none; d=google.com; s=arc-20160816; b=SC0sB/WywjovnojAY577xTSvLGc3TDNua6dB6EkBWpMcCDHAOYKbMdbRUObIEOwBo4 4xcV//eUMs4RBa6//A9MqkXnqy6096gWX/xfjyhOSoJWC5jAVz5ApHoCj+YNIow36hdn AAVB4tJyVEJ/8+GYhoSfTgu2Ql9LlE1/e5uJt6hnMAwWohnw7wvHE6buWL+X35xL6+Iq Cm501I7BegppEehyXfr584S78/T4WSPedIBZg9f/UBpYwFf6AsjmulSOfRE3bSUf2P9T sQu40OR2oKWI8xnYx7nZnGlPGFrY5VY14rZ1TSLYkfsaFQgV4w+JubE3a4thb6QB1kZ1 SVBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gKYBmK1IVa52dJ8Yd581Rv9QR37AAvuQ9cm7SbojhKg=; b=xWNWUbORLhKTlEZGu5J5+evCc1d6E+d1QRDBsRfWY3FBeVluEycOXrLppbr7wSX+J/ H314ano+AMh3dSCz4nVboInXkaCvIlHnj9r0VCshkZTIx/1TYYWzLVon1LK8sGhRrELb eDaYJdswL/3oQh5XSInmhOAznbLiY7o4OzVwLXUiw0m04J1wyNhgENSRMEwyIODxdta8 oX+1RpcEcTUKrSAaVIysQzGQpn6fVe7zSYLaEQRfyy4OdTDOPZUogUaq0UFmpMiL55u/ 8+WkJdMRuknyd3Eb8PqKMXfZhmNg0bLVFVENXxuq5Kct2rPzY1GRxPcc2E9QWIvG60wF oYTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYLVf8N1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x23-20020a63fe57000000b0051372ec9317si849990pgj.767.2023.03.30.16.40.46; Thu, 30 Mar 2023 16:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYLVf8N1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbjC3XPd (ORCPT + 99 others); Thu, 30 Mar 2023 19:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbjC3XPc (ORCPT ); Thu, 30 Mar 2023 19:15:32 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28085D50E for ; Thu, 30 Mar 2023 16:15:31 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id q16so26618291lfe.10 for ; Thu, 30 Mar 2023 16:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680218129; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gKYBmK1IVa52dJ8Yd581Rv9QR37AAvuQ9cm7SbojhKg=; b=gYLVf8N1n65KjQ18ewInau6qSRnWQtAGfYEsyBEMZHwlZqL7OzVU4lR6alx2YWyOkm 1vXDdWn1ZF65Vap+R7nQF3cWDGRHC/OynalikGuRncZftTBOQaTLW2B8p1vDv7/5abd8 f2mpuvfvPZbZqyKZ8CBfp9qQwa3GVxla4yOzG9jj0j4+by7KzJ2xTAat0Wmi/BwJXJat ANM0MuSwGKyHd6VBQyPwbVFXvc+WgPSlEqy/04bOVgpABpd7EGwN18y8WPHl1VO6KSCA 9V4bKs4JKP5uiudSog/2XOLt7GJXZQgFRzzYTJ51wSyGRO8cWESXH5oefnQp9cAxHEXX T+KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680218129; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gKYBmK1IVa52dJ8Yd581Rv9QR37AAvuQ9cm7SbojhKg=; b=3VZSGXSWKmc9P8ORGSmm/6O87XbIMxmxTgffFWtKmLJNoQzhue10G5cfK1q8Yry2i1 lE3U/2z2H41zOOVSSDh60jqE2knmr9QmwOZSkiVslKdhCaRr6k8YXPcQMpE7L7xgGMQ8 abccEB05Tjs1Ntkc2c5Lo4NsoF4sEfuCnCY5ZHoXaVMZcIp68FSChJLGjflVHXzoMsmI lau+rx3BdC1a7VxXQQyYFQX8uLgqMzYW0WG2d1mximcnQokUCTNDYXkrfX5e81o+3aMF wRD95hbbZeLI6ETSr7RTb+6KjhSHIbMjn/wY+mCuAaWsAouNGUcx1Hlmr0zpYKidXMeH iJIg== X-Gm-Message-State: AAQBX9fVyvzML9S6L2+8C53Z9l3eUyqyFHZ9iqnOqVFezt60sB4mtpkD Vua2QWrF//lTsRaq2+dmvG29jw== X-Received: by 2002:a05:6512:11c3:b0:4d8:6f37:2611 with SMTP id h3-20020a05651211c300b004d86f372611mr6779352lfr.20.1680218129285; Thu, 30 Mar 2023 16:15:29 -0700 (PDT) Received: from localhost.localdomain (abxj225.neoplus.adsl.tpnet.pl. [83.9.3.225]) by smtp.gmail.com with ESMTPSA id g8-20020a19ac08000000b004dc4bb914c7sm123387lfc.201.2023.03.30.16.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 16:15:28 -0700 (PDT) From: Konrad Dybcio To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org Cc: marijn.suijten@somainline.org, Konrad Dybcio , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Johan Hovold , Akhil P Oommen , Nathan Chancellor , "Joel Fernandes (Google)" , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/msm/adreno: adreno_gpu: Use suspend() instead of idle() on load error Date: Fri, 31 Mar 2023 01:15:16 +0200 Message-Id: <20230330231517.2747024-1-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761838008855846703?= X-GMAIL-MSGID: =?utf-8?q?1761838008855846703?= The adreno_load_gpu() path is guarded by an error check on adreno_load_fw(). This function is responsible for loading Qualcomm-only-signed binaries (e.g. SQE and GMU FW for A6XX), but it does not take the vendor-signed ZAP blob into account. By embedding the SQE (and GMU, if necessary) firmware into the initrd/kernel, we can trigger and unfortunate path that would not bail out early and proceed with gpu->hw_init(). That will fail, as the ZAP loader path will not find the firmware and return back to adreno_load_gpu(). This error path involves pm_runtime_put_sync() which then calls idle() instead of suspend(). This is suboptimal, as it means that we're not going through the clean shutdown sequence. With at least A619_holi, this makes the GPU not wake up until it goes through at least one more start-fail-stop cycle. The pm_runtime_put_sync that appears in the error path actually does not guarantee that because of the earlier enabling of runtime autosuspend. Fix that by using pm_runtime_put_sync_suspend to force a clean shutdown. Test cases: 1. All firmware baked into kernel 2. error loading ZAP fw in initrd -> load from rootfs at DE start Both succeed on A619_holi (SM6375) and A630 (SDM845). Fixes: 0d997f95b70f ("drm/msm/adreno: fix runtime PM imbalance at gpu load") Signed-off-by: Konrad Dybcio Reviewed-by: Johan Hovold --- v1 -> v2: - Improve the commit message and the reasoning within drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index f61896629be6..59f3302e8167 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -477,7 +477,7 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) return gpu; err_put_rpm: - pm_runtime_put_sync(&pdev->dev); + pm_runtime_put_sync_suspend(&pdev->dev); err_disable_rpm: pm_runtime_disable(&pdev->dev);