From patchwork Fri Oct 13 23:07:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 733917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09EDC41513 for ; Fri, 13 Oct 2023 23:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232273AbjJMXIE (ORCPT ); Fri, 13 Oct 2023 19:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjJMXID (ORCPT ); Fri, 13 Oct 2023 19:08:03 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 916A6BE for ; Fri, 13 Oct 2023 16:07:59 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5079f9675c6so836997e87.2 for ; Fri, 13 Oct 2023 16:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697238478; x=1697843278; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=ntpWA0KpoWbL2Mip0SNW/VcCmMEOAdpN3Qpqu/MvN+k=; b=iSMOv8rPVRXSMfZrkL+mUnc1wCEmwheuV7AP1QnoaFT9ntFpNhLF2SA4bUfvt/I8H2 VKtm6u0hdPJ5Jd3UFQUb7NT6x3R9NWysTV0QEBRgFugWlbULTOX2xlyOheyviT5IWq+k pnDk0uaEHUQnx0dnPCjFdsDkUYXrdOljWn6QzMEQR3uovCDvjyJlW6QhTI8+Mfa1JGuG hR/HcNdGp4QfRXhq7iw99eFJGaZeDZid6O3wspnEpgSQcxA4ZZ8pJIXNzFE8yN9PNjzW iaFJTfrfNw1sZ59kdh6T0H5XqPMRvafQ7aZ2HZQfrStFAOUpdQpq+BxhzUghBYapvoJm gxng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697238478; x=1697843278; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ntpWA0KpoWbL2Mip0SNW/VcCmMEOAdpN3Qpqu/MvN+k=; b=IR7TfSGgHF36tqy52uekimdXfoV+ON9BBu1TLF/PFZdmKzXXEMuWY04a7i+y+Z8peW cKxsjpT1dm8w9PV9dkc22xpdVz0rapBSZvxe0ZUXwKpEhQTmvMBtyiX4eWcF9Z9IRmv+ AI2WYMwth2kE9UMpTksLLAkuiicJi6EgUxB2YJLhApIOkrWDoLIPMTxJWeHetlcqma6w 1mVT4Qop+HFfISovGaGCFp2mWLJ786gdn3/UN/+S9E/m7sXRERkhgTJ37gH/IEEiCyRg kFsbXCs1BW+dRQG1dq1lBsQDpKElZme1U3KmHSY4Tsat/vxKBHPJl7Fpp2LRJgcW7kjS OUlg== X-Gm-Message-State: AOJu0Yy+EWOxewzgFjKkmGhQ0g58Q4VqyVDLvKCZQwWuTN0yjO6XeR7V QkDmEC3ytUlMR+VLZISAvXQxBw== X-Google-Smtp-Source: AGHT+IEJMwBj1J0JzYtqJnElPMCb2Qn7Ch45pieeJc7RnMmM9cj9AkGLOPOfCuprWfC3Xg3v4+RMlA== X-Received: by 2002:a05:6512:1246:b0:500:9839:b13a with SMTP id fb6-20020a056512124600b005009839b13amr30206505lfb.66.1697238477814; Fri, 13 Oct 2023 16:07:57 -0700 (PDT) Received: from [10.167.154.1] (178235177169.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.169]) by smtp.gmail.com with ESMTPSA id u13-20020ac248ad000000b00504818fcb07sm3553202lfg.266.2023.10.13.16.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 16:07:57 -0700 (PDT) From: Konrad Dybcio Date: Sat, 14 Oct 2023 01:07:46 +0200 Subject: [PATCH] drm/msm/a6xx: Fix up QMP handling MIME-Version: 1.0 Message-Id: <20231014-topic-a7xxv3-v1-1-616bc95f21ce@linaro.org> X-B4-Tracking: v=1; b=H4sIAMHNKWUC/x2N0QqDMAwAf0XyvEBTNxR/RfYQ2zgDUqV1UhD/f WGPd3DcBUWySoGhuSDLqUW3ZECPBsLC6SOo0Ri88y05euKx7RqQu1rPFqOb2UfqO08vsGTiIjh lTmGxKH3X1eSeZdb6f4zv+/4Bzr+H7HMAAAA= To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter Cc: Marijn Suijten , Rob Clark , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dan Carpenter , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697238476; l=2554; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=L0RoG9B+wKNyrZ4UA2Vwj13Xo0muadgjIRaCHVUzQ3I=; b=0Tz640xtbRU3aIFgDrl3cQRCFtrEfteAL/Yvax+E5GHso3rsWZ6bqFX9Y5eSvxekDoMSTJduI Bz7I7UTi6RMAfWwBf2cx/MoFPYBqP+UETorzEdjQS28mwPa60aYQxVG X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The commit referenced in the Fixes tag had a couple problems (as pointed out by Dan): - qmp_put was never called, resulting in refcnt leaks - failling to acquire the QMP mailbox on A7xx would not undo the probe function properly - the qmp_put call present in the code was unreachable Fix all of these issues. Reported-by: Dan Carpenter Fixes: 88a0997f2f94 ("drm/msm/a6xx: Send ACD state to QMP at GMU resume") Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) --- base-commit: e3b18f7200f45d66f7141136c25554ac1e82009b change-id: 20231014-topic-a7xxv3-d0fa2d187215 Best regards, diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 0555a0134fad..8c4900444b2c 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1558,6 +1558,9 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) dev_pm_domain_detach(gmu->gxpd, false); } + if (!IS_ERR_OR_NULL(gmu->qmp)) + qmp_put(gmu->qmp); + iounmap(gmu->mmio); if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc")) iounmap(gmu->rscc); @@ -1654,6 +1657,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; struct a6xx_gmu *gmu = &a6xx_gpu->gmu; struct platform_device *pdev = of_find_device_by_node(node); + struct device_link *link; int ret; if (!pdev) @@ -1777,15 +1781,17 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) goto err_mmio; } - if (!device_link_add(gmu->dev, gmu->cxpd, - DL_FLAG_PM_RUNTIME)) { + link = device_link_add(gmu->dev, gmu->cxpd, DL_FLAG_PM_RUNTIME); + if (!link) { ret = -ENODEV; goto detach_cxpd; } gmu->qmp = qmp_get(gmu->dev); - if (IS_ERR(gmu->qmp) && adreno_is_a7xx(adreno_gpu)) - return PTR_ERR(gmu->qmp); + if (IS_ERR(gmu->qmp) && adreno_is_a7xx(adreno_gpu)) { + ret = PTR_ERR(gmu->qmp); + goto remove_device_link; + } init_completion(&gmu->pd_gate); complete_all(&gmu->pd_gate); @@ -1810,8 +1816,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) return 0; - if (!IS_ERR_OR_NULL(gmu->qmp)) - qmp_put(gmu->qmp); +remove_device_link: + device_link_del(link); detach_cxpd: dev_pm_domain_detach(gmu->cxpd, false);