Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2656785pxa; Mon, 17 Aug 2020 15:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAFilsf6GmGCR4Ooe+fIZrKCF25ZWQWUmndeyt+NFY4208xHFAY8ADe0GHSXT6doujrJ0Y X-Received: by 2002:a17:906:f24c:: with SMTP id gy12mr16944378ejb.275.1597704132743; Mon, 17 Aug 2020 15:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704132; cv=none; d=google.com; s=arc-20160816; b=HDeft0nBWqb/u1B7OV0stBNv9F7vPDT5M/dxqaizPyXEVLq7m/qe31UFW/vY87i9nN R2jH2JNa+H45KdHvg+h52qApjAdCCc4UvOiQrRRLdg6WX8JGAgjVL2CE4jZTG622qGrz RTRhTD1X6/dGWOeqGUjVp7+FlU9qL85BXTt+CJcpGtHfh5J3SBzn9g3ffyOqXcX1wIfa DKp6gK28+UVT9/DGGwBiwOb564cZkRtqZl3HZdEOKMXwuqLCyaAip1D2l2ZR0WJ2UpAP UOlQ0bNTAU5LNtfrcRvKIlDhND6jFHDZU384GUgRrsq2BJd/ZBDu9czQDmas4F079cnJ plHA== 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=kzXmOsEK0GJFuSRkQdgrYbF/E6u3LJ1mgS3jev8SsfA=; b=Eb4u6JlrRYRtElCPt64CKExrPxxYOjIgVJqfw6loAB5KPhg11rlc2leDDlaTSUTuJs XdszVvTX42RIsg3WRjxHMi+1m+8DnDiU16oK68UMLmsQ6PPiWlonPi2MdK8JvXh+Osv0 W13VTBZogoJBbuKVNawcDHFA/v/pqQKHFTkC1uB+oGs655/U6bCAVC8HwiUJbUbbt1iP 1egdNE4AoZERXKvo46FhiKkIz2hfhyQBXqJELZfpUyuOKCvTEYvlwXsIXNGAlQiCDILs Z+qrdc9MqTiQBpDb+2NZXhI2H3S/m+R5EGvYQhCU3gIJI8wRmRZX321W12fXI94XmgKl ik/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n54xZULf; 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 n9si11538140edo.79.2020.08.17.15.41.49; Mon, 17 Aug 2020 15:42:12 -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=n54xZULf; 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 S2391250AbgHQSe1 (ORCPT + 99 others); Mon, 17 Aug 2020 14:34:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:47506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731001AbgHQQAJ (ORCPT ); Mon, 17 Aug 2020 12:00:09 -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 5FD1920729; Mon, 17 Aug 2020 16:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680008; bh=tE+/jS+BvX9zc+s1uCDMixr7naVAWq9W2jUqiuF35ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n54xZULfaGhcY4/Rgj4dZGDBFy/j3fqhvzKdahSz34n4mB2wXDXP//3B7GNuU4NqO gSNrfDTn8OU+62a93JdFdIZl3AiczcgVlLlk8x8MxrUI71GAvQ+PAB3EjsQvNE38LJ qVhzoV/zxgKJWy+ZOLQvf+GvC7g186FurHyPMNDw= 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.4 018/270] firmware: arm_scmi: Fix SCMI genpd domain probing Date: Mon, 17 Aug 2020 17:13:39 +0200 Message-Id: <20200817143756.698669069@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 87f737e01473c..041f8152272bf 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