Message ID | 20240806221204.1560258-1-vladimir.zapolskiy@linaro.org (mailing list archive) |
---|---|
State | New |
Headers |
Received: from sy.mirrors.kernel.org ([147.75.48.161]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <linux-media+bounces-15868-patchwork=linuxtv.org@vger.kernel.org>) id 1sbiMd-0000Qx-0B for patchwork@linuxtv.org; Wed, 07 Aug 2024 15:14:11 +0000 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D4F2AB21399 for <patchwork@linuxtv.org>; Tue, 6 Aug 2024 22:12:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CB2D16F831; Tue, 6 Aug 2024 22:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V+yfIpi6" X-Original-To: linux-media@vger.kernel.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 0A6F2170A02 for <linux-media@vger.kernel.org>; Tue, 6 Aug 2024 22:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722982334; cv=none; b=Pcj2Spz0mgwIA/4gjK1WA7nG/lJQqAJ/5UIH3HF75NPKqMIj9s2/Mpi092BB1fkfYSNGuCKVAwzrWq7TmxuD3ajnBdGjVQDjGqKh7YRmgACjgtuL342SFfMletCRtc51u4q3YWgmOVfxdE9IvL+yoF1WOHcJ+r51xhU85o7q02g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722982334; c=relaxed/simple; bh=5aJc4EHpj1vONHQREXTuOWOsMSgpiahd582rZLbutcA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mS2dyvzUpbebtpVqz8IIGBgN5BMco5MxAFpMWc2Shdf/+47+im73HOyqo52CND/+su60J/jJv4KO2zvYXs00Hp8Kr0OpBEKTSuLuu+SMsk9iRNSpm2FprR8xIgFPhwW8WsinumEi7CvPFp4K8mwcD3VD9753gLwyNKgax51vrRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=V+yfIpi6; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-52ef9714673so149983e87.0 for <linux-media@vger.kernel.org>; Tue, 06 Aug 2024 15:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722982330; x=1723587130; 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; bh=NLn7OVhOIMRd/L579K/B7JfPiLgZys/OGn3zlhndMAQ=; b=V+yfIpi6R8wAgJcl6HD/Tf5LAwNYgtsj7AfImnUCCGgec8tlOHvd8C7Xd/IEfyQEpN 6wihCA6DMrCPR6IX4IoxrvVF7mA2mcRI11zcNYLU4ozWQuUslaNwiK0V6tHy0jWYmWQC z4gzk1x/dkukNZtcIhX+gwUw2bcme2760Il07cQjAoX80KnuJLQEm5kDQ/TDUONc9F8s ORak852oSMkknDgAG7vJjU8cGRaUoSYLT9HQqvCPCCsoD+YzrIsdhTMC3Gc3yJx7ut1H g/F3yDTzCjwczEeos2/cQyamdpfs+qT02YK88Elz+akgvMHI+OjXbm+erWhqvSoWYcvw Hjsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722982330; x=1723587130; 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=NLn7OVhOIMRd/L579K/B7JfPiLgZys/OGn3zlhndMAQ=; b=wCIFN3+9b0YgkxUj4kFb+KirYPX6wNKLn6Jk9FqsC2Xx1EQ69CuC+/k9rYDRASEqI1 5q4d4rPYdMxDZzBZqAX4msLvUO/QFgrkrP1z/KT8udAPOQA0/Ek3zDuh/OG/EaTnzJGb 2KbAMwNXXITCz1Ik5IxPHzm5stG16U20/ibkGFGp5nEuaYh6nioJp61Xcs5nDLQqwngT 3hAD/FuG5OLrH66XnxijgktO4u3i/TTy0Y3409qgapVTHqt1Vhfd7KFylca7Ngzm2SWx Lp/TjxeSIii+SrLhgWB+w4baBVQ2aIxNP/bQFKq8dyM2geh/lAkvCKTKhraUz1/mMY5M KN6A== X-Forwarded-Encrypted: i=1; AJvYcCVfmfIjSsCH4D4k0yO9e+mdTxslolNhaDpjbWMfeTyDpd9fljOrH0ynpQ1ynMD5Jd6oFHjaVjGdcyc4CA==@vger.kernel.org X-Gm-Message-State: AOJu0YzBbG9/unIMy+XE8RaK8tDWUI6EsK/LqdElG5N7fWD9fk0ZvgLA fF8sLUx7EQwvPKA6i/IejHHRtdCbVy3HE+C449IhQIkBgVWyoEnPoF8aGd+HnOs2TXROeAb5hkq G X-Google-Smtp-Source: AGHT+IFEx99eut+K85G0Of7/hdM4QziKPyBHUCtX6nuQ2eIenUQKbjMcNELUhhJCJfd3dC7rHeDZYA== X-Received: by 2002:a05:6512:39ca:b0:52f:3c:a81 with SMTP id 2adb3069b0e04-530bb36e47dmr5886196e87.3.1722982329983; Tue, 06 Aug 2024 15:12:09 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-530de465863sm3012e87.203.2024.08.06.15.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 15:12:09 -0700 (PDT) From: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org> To: Robert Foss <rfoss@kernel.org>, Bryan O'Donoghue <bryan.odonoghue@linaro.org> Cc: Todor Tomov <todor.too@gmail.com>, Konrad Dybcio <konrad.dybcio@linaro.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] media: qcom: camss: fix error path on configuration of power domains Date: Wed, 7 Aug 2024 01:12:04 +0300 Message-ID: <20240806221204.1560258-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: <linux-media.vger.kernel.org> List-Subscribe: <mailto:linux-media+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-media+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-LSpam-Score: -6.3 (------) X-LSpam-Report: No, score=-6.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no |
Series |
media: qcom: camss: fix error path on configuration of power domains
|
|
Commit Message
Vladimir Zapolskiy
Aug. 6, 2024, 10:12 p.m. UTC
There is a chance to meet runtime issues during configuration of CAMSS
power domains, because on the error path dev_pm_domain_detach() is
unexpectedly called with NULL or error pointer.
Fixes: 23aa4f0cd327 ("media: qcom: camss: Move VFE power-domain specifics into vfe.c")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/platform/qcom/camss/camss.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
Comments
On 07/08/2024 09:52, Vladimir Zapolskiy wrote: > On 8/7/24 11:39, Bryan O'Donoghue wrote: >> On 07/08/2024 00:37, Vladimir Zapolskiy wrote: >>> On 8/7/24 02:30, Bryan O'Donoghue wrote: >>>> On 07/08/2024 00:27, Vladimir Zapolskiy wrote: >>>>> Hi Bryan. >>>>> >>>>> On 8/7/24 02:15, Bryan O'Donoghue wrote: >>>>>> On 06/08/2024 23:12, Vladimir Zapolskiy wrote: >>>>>>> There is a chance to meet runtime issues during configuration of >>>>>>> CAMSS >>>>>>> power domains, because on the error path dev_pm_domain_detach() is >>>>>>> unexpectedly called with NULL or error pointer. >>>>>>> >>>>>>> Fixes: 23aa4f0cd327 ("media: qcom: camss: Move VFE power-domain >>>>>>> specifics into vfe.c") >>>>>>> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org> >>>>>> >>>>>> Have you tested this with and without named power domains in your >>>>>> dts ? >>>>>> The logic here is complex to support both the legacy non-named >>>>>> case and >>>>>> the updated named required case. >>>>> >>>>> The problem and the fix are pretty straightforward, if you notice any >>>>> issues >>>>> with it, please let me know. >>>>> >>>>> As it's said in the commit description the problem is unrelated to >>>>> named/not named >>>>> power domains, I tested the fix only on a platform without >>>>> "power-domain-names" >>>>> property in camss device tree node. >>>>> >>>>>> Could you also provide a backtrace of a failing camss_configure_pd() >>>>>> for >>>>>> the commit log. >>>>> >>>>> Sure, I believe anyone can get a backtrace simply by disabling >>>>> camcc at >>>>> build time, >>>>> so that camss power domain supplies disappear: >>>> >>>> Ah OK, that's how, proof positive if its not tested, its not working, >>>> I've extensively tested both named and non-named pds but, yep never >>>> with >>>> camcc switched off. >>>> >>>>> >>>>> [ 13.541205] Unable to handle kernel NULL pointer dereference at >>>>> virtual address 00000000000001a2 >>>>> [ 13.550224] Mem abort info: >>>>> [ 13.553110] ESR = 0x0000000096000004 >>>>> [ 13.556975] EC = 0x25: DABT (current EL), IL = 32 bits >>>>> [ 13.562438] SET = 0, FnV = 0 >>>>> [ 13.565580] EA = 0, S1PTW = 0 >>>>> [ 13.568813] FSC = 0x04: level 0 translation fault >>>>> [ 13.573824] Data abort info: >>>>> [ 13.576787] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 >>>>> [ 13.582424] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 >>>>> [ 13.587614] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 >>>>> [ 13.593074] user pgtable: 4k pages, 48-bit VAs, >>>>> pgdp=000000088a55a000 >>>>> [ 13.599693] [00000000000001a2] pgd=0000000000000000, >>>>> p4d=0000000000000000 >>>>> [ 13.606666] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP >>>>> [ 13.613104] Modules linked in: >>>>> >>>>> <snip> >>>>> >>>>> [ 13.632753] Workqueue: events_unbound deferred_probe_work_func >>>>> [ 13.638776] pstate: 23400009 (nzCv daif +PAN -UAO +TCO +DIT -SSBS >>>>> BTYPE=--) >>>>> [ 13.645926] pc : dev_pm_domain_detach+0x8/0x48 >>>>> [ 13.650521] lr : camss_probe+0x374/0x9c0 >>>>> [ 13.654577] sp : ffff800086ec3ab0 >>>>> [ 13.657985] x29: ffff800086ec3ab0 x28: ffff8000855079c0 x27: >>>>> ffff800085507000 >>>>> [ 13.665329] x26: ffff000800c4b040 x25: 0000000000000000 x24: >>>>> ffff00080aa72c20 >>>>> [ 13.672659] x23: ffff800083060588 x22: ffff000801397010 x21: >>>>> ffff800083060588 >>>>> [ 13.679989] x20: 00000000ffffff92 x19: ffff00080aa72880 x18: >>>>> ffffffffffffffff >>>>> [ 13.687318] x17: 6e6570656420676e x16: 69726f6e6769202c x15: >>>>> 0000000000000000 >>>>> [ 13.694648] x14: 000000000000003e x13: 0000000000000000 x12: >>>>> 0000000000000000 >>>>> [ 13.701988] x11: ffff00080b350460 x10: ffff00080b350248 x9 : >>>>> ffff800081ddcde4 >>>>> [ 13.709318] x8 : ffff00080b350270 x7 : 0000000000000001 x6 : >>>>> 8000003ff0000000 >>>>> [ 13.716658] x5 : ffff00080149a300 x4 : ffff000a72592b70 x3 : >>>>> 0000000000076404 >>>>> [ 13.723998] x2 : 0000000000000000 x1 : 0000000000000001 x0 : >>>>> ffffffffffffff92 >>>>> [ 13.731338] Call trace: >>>>> [ 13.733865] dev_pm_domain_detach+0x8/0x48 >>>>> [ 13.738081] platform_probe+0x70/0xf0 >>>>> [ 13.741864] really_probe+0xc4/0x2a8 >>>>> [ 13.745556] __driver_probe_device+0x80/0x140 >>>>> [ 13.750045] driver_probe_device+0x48/0x170 >>>>> [ 13.754355] __device_attach_driver+0xc0/0x148 >>>>> [ 13.758937] bus_for_each_drv+0x88/0xf0 >>>>> [ 13.762894] __device_attach+0xb0/0x1c0 >>>>> [ 13.766852] device_initial_probe+0x1c/0x30 >>>>> [ 13.771165] bus_probe_device+0xb4/0xc0 >>>>> [ 13.775124] deferred_probe_work_func+0x90/0xd0 >>>>> [ 13.779787] process_one_work+0x164/0x3e0 >>>>> [ 13.783920] worker_thread+0x310/0x420 >>>>> [ 13.787777] kthread+0x120/0x130 >>>>> [ 13.791123] ret_from_fork+0x10/0x20 >>>>> [ 13.794821] Code: 828a2cb8 ffff8000 aa1e03e9 d503201f (f9410802) >>>>> [ 13.801088] ---[ end trace 0000000000000000 ]--- >>>> >>>> I'd be obliged if you could add to your commit log and verify >>>> everything >>>> works for you with both named and unnamed power-domains. >>>> >>> >>> No objections to resend the change with an updated commit message, since >>> it raised a question, I can add information about a method how to >>> reproduce >>> the bug. >>> >>> However I would like to know your opinion about the change itself, are >>> there >>> any noticeable issues? Thank you in advance! >>> >>> -- >>> Best wishes, >>> Vladimir >> >> Why not just >> >> diff --git a/drivers/media/platform/qcom/camss/camss.c >> b/drivers/media/platform/qcom/camss/camss.c >> index 51b1d3550421a..9990af675190c 100644 >> --- a/drivers/media/platform/qcom/camss/camss.c >> +++ b/drivers/media/platform/qcom/camss/camss.c >> @@ -2162,7 +2162,8 @@ static int camss_configure_pd(struct camss *camss) >> return 0; >> >> fail_pm: >> - dev_pm_domain_detach(camss->genpd, true); >> + if (camss->genpd) >> + dev_pm_domain_detach(camss->genpd, true); >> >> >> ? >> > > Because your change is invalid strictly speaking, again you've missed > an error pointer case, but that's secondary, since it could be improved. > > However your change brings more of unnecessary complexity, because it > increases both cyclomatic complexity and increases LoC, when my change > reduces the values in both these metrics. > > My change makes the code way simpler, hopefully I managed to explain it. Cyclomatic complexity you know, I checked pmccabe drivers/media/platform/qcom/camss/camss.c base: 12 12 37 2088 81 drivers/media/platform/qcom/camss/camss.c(2088): camss_configure_pd vlad: 12 12 35 2088 78 drivers/media/platform/qcom/camss/camss.c(2088): camss_configure_pd bod: 13 13 38 2088 82 drivers/media/platform/qcom/camss/camss.c(2088): camss_configure_pd That's convincing enough for me, please add the kernel backtrace on your V2. --- bod
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 51b1d3550421..aa894be1461d 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -2130,10 +2130,8 @@ static int camss_configure_pd(struct camss *camss) if (camss->res->pd_name) { camss->genpd = dev_pm_domain_attach_by_name(camss->dev, camss->res->pd_name); - if (IS_ERR(camss->genpd)) { - ret = PTR_ERR(camss->genpd); - goto fail_pm; - } + if (IS_ERR(camss->genpd)) + return PTR_ERR(camss->genpd); } if (!camss->genpd) { @@ -2143,14 +2141,13 @@ static int camss_configure_pd(struct camss *camss) */ camss->genpd = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1); + if (IS_ERR(camss->genpd)) + return PTR_ERR(camss->genpd); } - if (IS_ERR_OR_NULL(camss->genpd)) { - if (!camss->genpd) - ret = -ENODEV; - else - ret = PTR_ERR(camss->genpd); - goto fail_pm; - } + + if (!camss->genpd) + return -ENODEV; + camss->genpd_link = device_link_add(camss->dev, camss->genpd, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);