From patchwork Fri Oct 18 09:28:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 176788 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp587851ill; Fri, 18 Oct 2019 02:28:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhdyyJSbn1AIY6TQneYi1RNuzCFP0omzU1PLESg9QwNTWHeFRNGx047ZcDAlxzC30ASQly X-Received: by 2002:a05:6402:17f1:: with SMTP id t17mr8353062edy.11.1571390933945; Fri, 18 Oct 2019 02:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571390933; cv=none; d=google.com; s=arc-20160816; b=a+XHQQmArDTzYH/8rmTBmlQpdCh9nFevqNqUwkeMIZuZPFO5aUwkCnTqBCx7JbzUGq EczhN8GJh5EBfuLffv6lXHh/oR/6AnA5zLIYlUn/y+LKm+dZGK3yId3/n+Fnnm6wNSiR raMebe23updncqLts9KbX1e9mFDkm7ePPKlkjJz6OGgS8FmTq9Kb/6fuX0mo4RgEqAUo 9ScR2skW8+cb0fywPi4vZXcgl51GVx/Xw2Df8mii+Fza9Zd3ayfe3rxvf+OTg/2Hc7Pd MF10Hf9cWNcrhJo1joPs3sqnuulxaiuC3IYaoR+ojlmHZ4GBh4qTOmeR1PA24fRKdZLR Ggew== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2zQ3DdxsRN52jblb9zywIzl2Di+YG8z5hUSeV7sQqSs=; b=HUL5m51HLfC9+Ir1p4zYD4NBwSl+FDqHSw1Gi4vah8Z3V7xJGtPbs+2M84QyYqIBd0 9N9si0OTOJ1cytb1r/ixp0X51CutanKJuSaQCf1ayvkrz8/3yCL78n3CSRMFPH0+dvOa oWPcpAUMMThCIMwbvIKyETlgpq1KpUkL+Onw+VsymF/W2p7Klg7Rroo7NrJB+I9tuPqV OgR8bbTspfK4n8Tm5wAk9M/PZdP5jbAdW7c3xzwJONdux1pQiLLcdt3gIleIl4X7LG0s lTZMMZP7kBDsU6BYuJJSluAUGLDk88FE+PZytRZN+j/ef6ZyuCaia9zBLwk552ORoC1y HjxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Imarxruy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay6si3186847edb.377.2019.10.18.02.28.53; Fri, 18 Oct 2019 02:28:53 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=Imarxruy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409668AbfJRJ2t (ORCPT + 26 others); Fri, 18 Oct 2019 05:28:49 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45526 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387757AbfJRJ2s (ORCPT ); Fri, 18 Oct 2019 05:28:48 -0400 Received: by mail-pf1-f193.google.com with SMTP id y72so3496446pfb.12 for ; Fri, 18 Oct 2019 02:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2zQ3DdxsRN52jblb9zywIzl2Di+YG8z5hUSeV7sQqSs=; b=ImarxruyGPcwgA9Yix4GV5gpXFGRncXMe/xRmupDsGnKBimIErWSuO8uyKPDZSuHob DEAH+b/+q4XTL/ZSBfhQRQA8qnTG4ZjNTHR4EHFLWcT9G+AOeZVtPZhmQBegmnSFN/rv uBB2CdZTqg+poL/mTnw/4VjuU+6H2/RnRejKeIlFdYVBS/AfJ51SkRX4c6lmP56xVXrv PuStzbPXk7SGBb27qGgj2OV/skRhExknMmrSvYbGJjAq0ti4hyv4NuA+j/HO/zWULrNd wlYWesKPXGn/leAFYT2rFNWQdNO9EyadIk6puXp15eos45MknjY9QiVZNRMLtXLbpr0j d7CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2zQ3DdxsRN52jblb9zywIzl2Di+YG8z5hUSeV7sQqSs=; b=ag/VXKF0b+h4EyCDIrormGLMZTAWgnawO6/S1/ki6KbRGDEQekxP4PIflgJsullhvK uvCtg/l6jIjgoIMsmNhA/VLH1UadkegdbXexRk+MpUymGIY+KSrWkDKNCQRi31sa9E9X ZnpTgj5Owk81H3RQWoOyAiKlujE0nH96qyCukAiXnB+W7gjGn6nUU1ZkUYnGSwlvQG2k WqnRaUDhd2/lsDxI4TA7xAcih99XfjGXNSEuhl5mk48mD2yDcCYpnPaSwHULvYujmkRe zYkFCjBqpdvaqBiOhQ8ZiDcyp2HeJh0Y8iq2Wdtv00mmtWek1q80zbyOTsrBCSf7iu9v /3gA== X-Gm-Message-State: APjAAAXuJcK6wqem+fRvok73RzeCrvxCs8h5uQ3xP8oscst+y3lfa1j/ XjWHyqUk/5G99s75HSDohO+A/A== X-Received: by 2002:a63:1f4e:: with SMTP id q14mr9167259pgm.144.1571390927910; Fri, 18 Oct 2019 02:28:47 -0700 (PDT) Received: from localhost ([122.172.151.112]) by smtp.gmail.com with ESMTPSA id z25sm5929736pfn.7.2019.10.18.02.28.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2019 02:28:47 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH] opp: Reinitialize the list_kref before adding the static OPPs again Date: Fri, 18 Oct 2019 14:58:41 +0530 Message-Id: <2700308706c0d46ca06eeb973079a1f18bf553dd.1571390916.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The list_kref reaches a count of 0 when all the static OPPs are removed, for example when dev_pm_opp_of_cpumask_remove_table() is called, though the actual OPP table may not get freed as it may still be referenced by other parts of the kernel, like from a call to dev_pm_opp_set_supported_hw(). And if we call dev_pm_opp_of_cpumask_add_table() again at this point, we must reinitialize the list_kref otherwise the kernel will hit a WARN() in kref infrastructure for incrementing a kref with value 0. Fixes: 11e1a1648298 ("opp: Don't decrement uninitialized list_kref") Reported-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 6dc41faf74b5..1cbb58240b80 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -663,6 +663,13 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) return 0; } + /* + * Re-initialize list_kref every time we add static OPPs to the OPP + * table as the reference count may be 0 after the last tie static OPPs + * were removed. + */ + kref_init(&opp_table->list_kref); + /* We have opp-table node now, iterate over it and add OPPs */ for_each_available_child_of_node(opp_table->np, np) { opp = _opp_add_static_v2(opp_table, dev, np);