Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2636026pxa; Mon, 17 Aug 2020 15:05:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfxMJArds0QIdlpmzkQkQ13zI+emr8kKeqqr1qz6HRQujySG0KA/XdiIn911SPE/w+apTL X-Received: by 2002:a17:906:1756:: with SMTP id d22mr17032217eje.29.1597701906480; Mon, 17 Aug 2020 15:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701906; cv=none; d=google.com; s=arc-20160816; b=ImRTeFsmZXtVE7dV8NeqFWmCxYfgcmMt8a6eN+6YX/uz/EKirZKnUQbWR2Jd6mVuRh RL54EP2phGlbjk1pvE3nN9eh6jOuQJiO3+eqNPbeGjORpUzd2cXLxtBohvI4ZMvVN2IQ o+0+PLH1bb3kvaA16PddEyoHXV035nzmyijCd6T2zCqrM8QXyTGt9fOldqVjtzYrrXJy n5Gu+ci/AD66WEKM1IERFYxiHdyjWGdIzRcn3Nb73rQnvsffmKskVy6U6XiPaooDHUQt 64yvV0m8yB71cCfBYuHESUkY/1+tIM9vgqJUHWd3lgd8mPYjmmx3HQr/c3qGBBnxOO/l PeHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+MgrtIFT9nbgdSasw17U+2Q8+UyTOz5qnoudczods/k=; b=kRo5SsIrGHf9BfgiN6NZ7WkYsdFLUdhuzKNF0GbtE7x3jq4f3XqbF7eHBZ2BMFgyc5 J1CZfnbDK5tI+j+g1n4d0ziZ98HV9aSZE21Is2lsAxLjMQ9sa2ePWutUY/V4grFW73/6 e6cWhOVcqQhfBwNHk1O9Y3Zkr142Tq0txrjhvijs9T47KWTG19gssjuRmAz83fmXeK4W HtvviNjDWmga+eIiG3rPyHmWjozq2nZn7p8rlcpYK4gQ50eiG43kdeTa46JxW4NEJe1V rf4DPOMXQ+c2CJQXHCVkARWBhHChhyHxDl+BVj6btRuvm1s61cc5hzK0FhfJ3+EhlMaw O5hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CjqlLSva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si11811726ejf.352.2020.08.17.15.04.43; Mon, 17 Aug 2020 15:05:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CjqlLSva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387780AbgHQP56 (ORCPT + 99 others); Mon, 17 Aug 2020 11:57:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387498AbgHQPmR (ORCPT ); Mon, 17 Aug 2020 11:42:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9F7020825; Mon, 17 Aug 2020 15:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678936; bh=8JV+rmwC4TMJFgVYMg7/BZTrgWw4TMd4Hsvprj762is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CjqlLSvaHskA9fG8zSPhU0VUAqskSuWDAIgIY8tYihWiooIgeEc7UI1udEsNUg+f3 8zWyyZQ4S6dLSOSHOJFi6DCekoVrlOdE509TTm2TJ1CM9OMq4VugStntftSS8gvYTI 745/umgMEEvO59Z6hPxx8pJ7Mhy/a9Ob9gAEeEk0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Sasha Levin Subject: [PATCH 5.7 023/393] firmware: arm_scmi: Fix SCMI genpd domain probing Date: Mon, 17 Aug 2020 17:11:13 +0200 Message-Id: <20200817143820.725680164@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cristian Marussi [ Upstream commit e0f1a30cf184821499eeb67daedd7a3f21bbcb0b ] When, at probe time, an SCMI communication failure inhibits the capacity to query power domains states, such domains should be skipped. Registering partially initialized SCMI power domains with genpd will causes kernel panic. arm-scmi timed out in resp(caller: scmi_power_state_get+0xa4/0xd0) scmi-power-domain scmi_dev.2: failed to get state for domain 9 Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Mem abort info: ESR = 0x96000006 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000006 CM = 0, WnR = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=00000009f3691000 [0000000000000000] pgd=00000009f1ca0003, p4d=00000009f1ca0003, pud=00000009f35ea003, pmd=0000000000000000 Internal error: Oops: 96000006 [#1] PREEMPT SMP CPU: 2 PID: 381 Comm: bash Not tainted 5.8.0-rc1-00011-gebd118c2cca8 #2 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jan 3 2020 Internal error: Oops: 96000006 [#1] PREEMPT SMP pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--) pc : of_genpd_add_provider_onecell+0x98/0x1f8 lr : of_genpd_add_provider_onecell+0x48/0x1f8 Call trace: of_genpd_add_provider_onecell+0x98/0x1f8 scmi_pm_domain_probe+0x174/0x1e8 scmi_dev_probe+0x90/0xe0 really_probe+0xe4/0x448 driver_probe_device+0xfc/0x168 device_driver_attach+0x7c/0x88 bind_store+0xe8/0x128 drv_attr_store+0x2c/0x40 sysfs_kf_write+0x4c/0x60 kernfs_fop_write+0x114/0x230 __vfs_write+0x24/0x50 vfs_write+0xbc/0x1e0 ksys_write+0x70/0xf8 __arm64_sys_write+0x24/0x30 el0_svc_common.constprop.3+0x94/0x160 do_el0_svc+0x2c/0x98 el0_sync_handler+0x148/0x1a8 el0_sync+0x158/0x180 Do not register any power domain that failed to be queried with genpd. Fixes: 898216c97ed2 ("firmware: arm_scmi: add device power domain support using genpd") Link: https://lore.kernel.org/r/20200619220330.12217-1-cristian.marussi@arm.com Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/scmi_pm_domain.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c index bafbfe358f97d..9e44479f02842 100644 --- a/drivers/firmware/arm_scmi/scmi_pm_domain.c +++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c @@ -85,7 +85,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) for (i = 0; i < num_domains; i++, scmi_pd++) { u32 state; - domains[i] = &scmi_pd->genpd; + if (handle->power_ops->state_get(handle, i, &state)) { + dev_warn(dev, "failed to get state for domain %d\n", i); + continue; + } scmi_pd->domain = i; scmi_pd->handle = handle; @@ -94,13 +97,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_on = scmi_pd_power_on; - if (handle->power_ops->state_get(handle, i, &state)) { - dev_warn(dev, "failed to get state for domain %d\n", i); - continue; - } - pm_genpd_init(&scmi_pd->genpd, NULL, state == SCMI_POWER_STATE_GENERIC_OFF); + + domains[i] = &scmi_pd->genpd; } scmi_pd_data->domains = domains; -- 2.25.1