Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2910233ybc; Thu, 14 Nov 2019 00:42:00 -0800 (PST) X-Google-Smtp-Source: APXvYqwgtQhNgdr4lInZflkvSsw4eIjgSO2VyVRva1UMauU/lOmdHWbmuLyDUPd1oP0gX3PMVmqh X-Received: by 2002:a17:906:d0d2:: with SMTP id bq18mr7024908ejb.217.1573720920531; Thu, 14 Nov 2019 00:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573720920; cv=none; d=google.com; s=arc-20160816; b=oVvlc/pXt1pAUAPtJ/7CAH3NFK2qJjeKgk/zuqu2cFzccP2zkzQ5JLwoskaRXKvc7K iqLOup3433x7fhqzHCKW4bkmLx42Gms8yJ8ROMtZh0kbvlJyN8XzaygiafLW4P2eo6a+ ihdbYkr9SySi9m4yPXll6y9hNtpHnFU/4bbhnkrGgHAdNq0l42QLIUZkkAQ6URKO8A85 6Rg1bpZdaFM47QxHow5kX8ON5Mxhk2l5DDjX7Nk6Ocv2HbKi8wEwED0MnCR9TJ8wNjBE E0S9T9wwx9fU5x6ejNb3lafYE0Il4ilsNn7dMdXZT+iZSNlAmRVS0hjyPxvIoS/ffcHp H65Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=iPJY8eMCm08nB+zy7CztAq4dqq7+2vUSvcWj8TIB9d0=; b=RC4Hn+s6IQDrRRENqx1wd280kRwM6xwkMI9jZVQk/j5jzXeiR8B7lbv+hDVIKKoNH/ L154EH/fD1Cn+0OkqTajputAeMbLNX73no2uOZ/MDvpKdVaLG/R/eZj41SBJ5C5QUazz KaHpTnhoHomHAQ8UYOJs++8vCsXKxOvps3Cu8/G6O2WjGh9uXqn17p7o6xlNIFKoGUUY jj3RlzrFpfDj4i6eh0hNc5CkvyPLFLMmNgG3mg9w3pfFpIqXWfCU/BmDCpet457mq5C7 YUHrzhrIaugnjSKV2ZA+HhnbqYrCqjWPvXbq1oJ5rK903H/f+5xOI/fkq537/m6Twlnn b1FQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si2857023ejf.351.2019.11.14.00.41.35; Thu, 14 Nov 2019 00:42:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbfKNIkn (ORCPT + 99 others); Thu, 14 Nov 2019 03:40:43 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:35848 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfKNIkm (ORCPT ); Thu, 14 Nov 2019 03:40:42 -0500 Received: by mail-ot1-f68.google.com with SMTP id f10so4189810oto.3; Thu, 14 Nov 2019 00:40:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iPJY8eMCm08nB+zy7CztAq4dqq7+2vUSvcWj8TIB9d0=; b=g/BwmTLPlTBSY3vl8srpUxhptcc1dDNv/1P2jZYzUTlh74PeDfNVjMxjcjgnMHp6G8 TxyBEah0OdBBkpi4IFmPaD3+4jr4Mpn6gtE2XR4StbwZrxDp2wXZCD0qMnQIyrhAIu5I A3jzBhhohqvBXLmY+hRbYF0aYbgNjaF7gTxPcug5x7HKRKkr6B8FZL3GPNi3IrJRO5TL Aan9+cDHDmlk8GiyPCcN3e2sPVR3U5yQWY1aN7TI1Ugfj5lAIe22Fh0cZY/JKlT/R0IW J+hC0FJlrBv2FDglGvTxmDk1KOuYgx90wAsfX2mwcD/KfWNtf4oSzWe1WZ6H9u2sw/Xc B7Qw== X-Gm-Message-State: APjAAAXHDtG+gAwbY3A0XkQqU26/FL8U9Ym8jqwXE/ok98qd3DWe1Rfu OUi+GUYR7R7pEBb3X6/2obI6kItcsqkbIHo4ohg= X-Received: by 2002:a9d:7d01:: with SMTP id v1mr5967204otn.167.1573720841882; Thu, 14 Nov 2019 00:40:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 14 Nov 2019 09:40:30 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: Register cpufreq drivers only after CPU devices are registered To: Viresh Kumar Cc: Rafael Wysocki , Linux PM , Vincent Guittot , Bjorn Andersson , Amit Kucheria , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 14, 2019 at 4:36 AM Viresh Kumar wrote: > > The cpufreq core heavily depends on the availability of the struct > device for CPUs and if they aren't available at the time cpufreq driver > is registered, we will never succeed in making cpufreq work. > > This happens due to following sequence of events: > > - cpufreq_register_driver() > - subsys_interface_register() > - return 0; //successful registration of driver > > ... at a later point of time > > - register_cpu(); > - device_register(); > - bus_probe_device(); > - sif->add_dev(); > - cpufreq_add_dev(); > - get_cpu_device(); //FAILS > - per_cpu(cpu_sys_devices, num) = &cpu->dev; //used by get_cpu_device() > - return 0; //CPU registered successfully > > Because the per-cpu variable cpu_sys_devices is set only after the CPU > device is regsitered, cpufreq will never be able to get it when > cpufreq_add_dev() is called. > > This patch avoids this failure by making sure device structure of at > least CPU0 is available when the cpufreq driver is registered, else > return -EPROBE_DEFER. > > Reported-by: Bjorn Andersson > Signed-off-by: Amit Kucheria > Signed-off-by: Viresh Kumar > --- > @Amit: I have added your sob without asking as you were involved in > getting us to this patch, you did a lot of testing yesterday to find the > root cause. Co-developed-by is for that, so I used it in the commit. > @Rafael: This fixes the issues reported by Bjorn on Amit's series and so > should land before Amit's series, if at all this is acceptable to you. Well, yes it is. Applied for 5.5 with a reworded subject, thanks!