From patchwork Tue Oct 27 07:57:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11859619 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 345DA139F for ; Tue, 27 Oct 2020 07:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BAE222281 for ; Tue, 27 Oct 2020 07:57:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JP1L/hqg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2508493AbgJ0H5O (ORCPT ); Tue, 27 Oct 2020 03:57:14 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39785 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508483AbgJ0H5N (ORCPT ); Tue, 27 Oct 2020 03:57:13 -0400 Received: by mail-pl1-f195.google.com with SMTP id x23so333096plr.6 for ; Tue, 27 Oct 2020 00:57:12 -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=WTGC2OTITxlQLtj5zM0pFSoVah1I+fME0Bx3VBUu+Yo=; b=JP1L/hqgpYoepOQ3ejAHcxMgOon16s5amlaf/SsSxdhvw982pStR+nZXKSo5OA2n1s H/c7cg+12r/pMF0SkpABvySTyVfTsrB20jVhtU96QhPOQfH1j/QRSWO10Zqmu2qYa1UI nX2jozFMAEfQFUbinMh2s9Y50XMv+S9qPCh2lnmWqq4WxfWzySBDDFmDfODOTbKYBgYr p+j+Cy2YcU0Z24CoAeKAC28TKgBQ1d92ZrWdDRZTw5TDHPhgsqzW86LmaoCU96J1Lh4t fdEgIqXkwtPvQ4qyrZwDAeIp1Ok3ME6HjZI4qqXaE/rq8NTBydolaxbpcqQlkra0cbSi xHsQ== 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=WTGC2OTITxlQLtj5zM0pFSoVah1I+fME0Bx3VBUu+Yo=; b=LtZ0YRRaC3gTb1pnmOwswpeNZNmt0r8OHHXXT39ZCSczsRPl0AGsQZ0VX8DmVRbV9C outTdzhyHqf44RdTWEdQO9hNqAO60+3XHGr/Y8T6XNO5M4qH16v/1q1gUPmGZlAWr0Ki rgCEpxJFeuFWnXi8gqw3z1j6WNQ6FPP6Zh5KZgp0+8cVithEBBP+JEmNSyS9BNSKxK2s 3yxx1d9rpRXMngJxhgyD1cICyyY5KAyAgiSd0EMS2ImREabgOaVcKOm9DIsIFAWm/BT9 9CW1+VlL+Bbxzxg83jg45oaD3KUV9sqMmNJkS2gRHmflvJvGc2qgYTwum7Pyu2V+Q3yI YVIQ== X-Gm-Message-State: AOAM533NKTS9x3NrPL/PH2tbUe714zeJ91DTlLivRf4qOUmG+OoJRc+B f4tRiJMNQbMHuV7Eja8E97RVxg== X-Google-Smtp-Source: ABdhPJwd354cCqeKi4ljRpmFshygrJuB4B086tJCKwr85zi67cGcxWbK7tBwaL8IV0iw93wYVTqRVw== X-Received: by 2002:a17:90a:d082:: with SMTP id k2mr905742pju.195.1603785431787; Tue, 27 Oct 2020 00:57:11 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id m13sm976201pjr.30.2020.10.27.00.57.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2020 00:57:11 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Rob Clark , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH] opp: Reduce the size of critical section in _opp_table_kref_release() Date: Tue, 27 Oct 2020 13:27:06 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There is a lot of stuff here which can be done outside of the big opp_table_lock, do that. This helps avoiding few circular dependency lockdeps around debugfs and interconnects. Reported-by: Rob Clark Reported-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd Tested-by: Dmitry Osipenko --- Rob: I know this only fixes the issue partially for you and I am still looking into that. I just wanted to get this merged in early as this fixes lockdep for other users as well. drivers/opp/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4ac4e7ce6b8b..0e0a5269dc82 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1181,6 +1181,10 @@ static void _opp_table_kref_release(struct kref *kref) struct opp_device *opp_dev, *temp; int i; + /* Drop the lock as soon as we can */ + list_del(&opp_table->node); + mutex_unlock(&opp_table_lock); + _of_clear_opp_table(opp_table); /* Release clk */ @@ -1208,10 +1212,7 @@ static void _opp_table_kref_release(struct kref *kref) mutex_destroy(&opp_table->genpd_virt_dev_lock); mutex_destroy(&opp_table->lock); - list_del(&opp_table->node); kfree(opp_table); - - mutex_unlock(&opp_table_lock); } void dev_pm_opp_put_opp_table(struct opp_table *opp_table)