Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2492987pxa; Mon, 17 Aug 2020 10:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXpgToGd/q+xEWlOcCSjxiOoiuzEudt+CwwbLlSZSuAbpbpQ/mEST6SvAeF6Xigu9z6iyI X-Received: by 2002:aa7:df8a:: with SMTP id b10mr15594361edy.62.1597687115016; Mon, 17 Aug 2020 10:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597687115; cv=none; d=google.com; s=arc-20160816; b=xwWHHqBvngr9MpVe2YwkKSbNdhMaNXPAegJ2O4wMtfzPwcL+sSR1CelRVLSxoeFojC 6KyMoNCiVAXti/BKpqJK4wiFM9wmxl1QPRTugD7wOa3n3ui32/0iiod5UxxDmN7D+g4I fucb/lzG7IOrYVQOn15ID2bVQG93TcUWAp3ccwp2RAF3oUXHeiv863ixeu4REXFDMVe8 PcRXNESKrNVxjS2hhiJo+5WqjdefolGIP0vdORLL2RGRqPUeiLvrft7oBt3dxRXHCToa wti89uauy0cJBpR+U25YVVa/WH/+qp0aX5ZLcFZJ6ZhgK6kKH14eNfF9Cz2ISKB1bRwE aC5Q== 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=gvK2+fdo8t6rLVmeUHzJuTEaH920ut73tN9cIGTM0aIHAmAfXNjnxuqyVgQwH5Yqye 1zMWxhogoYiihlgtNkxEYWH1jgeb0DaqeVfk91FhHB5TtqhhO+xOE7NgPEbJ6l4UWsgx TcLRXyS+lF6Z44W5tspt1h+rkVlUxpiDn2P3ztEHeMV4VomSXKk7HzukaN6JpGuL9pD0 qnXDWNG4jOJITquDepe0HHv80irMcnIe79VrKP1ig7OdIoOQcCYtZuQf8xnJ1F/PT+lJ h2ZB93CPoYISnQ+E7GFCzFedUedAgGsqdBXVS+Mufudt/nm2Le25NOETzrN5BryvROmT Q5Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dUhK2vv4; 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 x6si11023557edr.497.2020.08.17.10.58.11; Mon, 17 Aug 2020 10:58:35 -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=dUhK2vv4; 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 S1731677AbgHQRyW (ORCPT + 99 others); Mon, 17 Aug 2020 13:54:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388609AbgHQQLU (ORCPT ); Mon, 17 Aug 2020 12:11:20 -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 0FFC520760; Mon, 17 Aug 2020 16:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680678; bh=tE+/jS+BvX9zc+s1uCDMixr7naVAWq9W2jUqiuF35ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dUhK2vv4wwMZWOydY/34/0rXUrTy+yHUZTf6qeVr7K7kc7mfc4uG84uHUiI346xfo 1A7enQKRvs84LNZvO7nkrpjz/Lb37OZ5zxQpDWGqS5YDKldoATMiPENjRn+1MTTIuL cO9Oips5fVfQM6I0N5iUK+MTsubz4JKpPanFYANI= 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 4.19 013/168] firmware: arm_scmi: Fix SCMI genpd domain probing Date: Mon, 17 Aug 2020 17:15:44 +0200 Message-Id: <20200817143734.386887260@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@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