From patchwork Sun Nov 21 08:35:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12693201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B56B4C433EF for ; Sun, 21 Nov 2021 08:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zOuz/VPh3VEHbGZiHybRy+0ckaDZiDG6GsqZR9wDMDs=; b=tXk4zqEHFbrZKJ 3eOawGIOCj7ZWlGpZ0mbRq8mdzdygb/gxayaTudl7CSVtTE7b+lsQqeVUhiUWuBRI9qmLlSLpTlc+ d8ouB1wvAQ25CY+OGgvN5H2sfSF+klAJ9F9bWGubb6o+HlVvfgow4G1t6+OPNWa5EU2kZzDHLyT0P a8oO2JrdiiRZ7Jgn/pGCv0aBRVYGzOa7CRDglmFIJuQdNaR3fXPlzjQ7eSTmXGq95+L5TR/h2VlBD 2rM2CrsN8gnXs0aMK0Qe96h+42LpNT5cyacgCNYtZtyJmKfGhn2CmIBe5Dk3L1c5OR7pKri+3wIu6 0QY4Fj4MWv1aRVW473Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moiK9-00DMBR-Pj; Sun, 21 Nov 2021 08:35:45 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moiK5-00DMB3-SU for linux-arm-kernel@lists.infradead.org; Sun, 21 Nov 2021 08:35:43 +0000 Received: by mail-wm1-x32b.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so10998323wme.4 for ; Sun, 21 Nov 2021 00:35:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h1W02faQu+Szravq8WQw5MogG6/ITT6EryqDefYAc60=; b=prsKTRolTZAn/eLp8jy5tA8v6BeaTxkby23xqeYZ6awHFSgKsVm13oLN/jcEZ9SyIl I1Ywe/CZ+wOhuip2GCVpBVBa0K7XjExRe5HJsIs/Nlligz8qyTuaIlBV9GuoGuw1Jcgk CQ0B/F7MnQObw0ZX5G50GwOpx8FMOVYLcag09isovlJct6uD6A45u2VOXNC0HCcN78x0 yvxOcfI9/llc+5+ebilSShkZ9jfbd1LdHUY5KdaP7i3AayQOGN43XDAPlhJdhATs2BnB 8o8I97bJ07mxVenWWUkjDrXe23PDh6FqOharpfFWFfoSKH47Blo0BFBEIRRkRDuRmpmP 626w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h1W02faQu+Szravq8WQw5MogG6/ITT6EryqDefYAc60=; b=Ul+p3QlWs9J9ICbUmSvUleR2TPJEFgoLttMe6UatENZ7sG6VhMM3+EiJJfRHxsTOkS BfhziOTQPCrsJ1BqgNZUOcvMawlhj2EJqi5iUiS392BvL5vCxCCZ5LLqBnW4LuCjIAWo q+xOnzYyaEM4X/h9ZcGWOLDkVBwtcz0gSvRQK797diREcbOBOWetqRzDTrhsj7ptsbYN 4TjC31b9p7m6YbTSvh9mO3ZxP6/PpXd9uY4waVzrndRG3Joe/Z1m/6tsdg4OXdgPyzm2 m5CkFwkv/H9LHONyATLkFRGAc+vcGhmuO4Ed/bmwzuxqwUZBfPT1qqn7732lPzeTFvN3 cO/w== X-Gm-Message-State: AOAM5327S1WAiDO2hT8sshgsVGhAl5ZYqvcxX4ec9RkeQFth5MX/S2rD lxKHfGSd+wzmUDfYQ0ALlcA= X-Google-Smtp-Source: ABdhPJzCdBRcE5NpSYEOCmOLME4QneazaEDFzZrCDOhWB2wRMzb3iKPwCltWj7nYRNphcWEq9/+RwQ== X-Received: by 2002:a05:600c:358a:: with SMTP id p10mr17212213wmq.180.1637483739638; Sun, 21 Nov 2021 00:35:39 -0800 (PST) Received: from kista.localdomain (cpe-86-58-29-253.static.triera.net. [86.58.29.253]) by smtp.gmail.com with ESMTPSA id o1sm5100456wrn.63.2021.11.21.00.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 00:35:39 -0800 (PST) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Cc: samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH] bus: sunxi-rsb: Fix shutdown Date: Sun, 21 Nov 2021 09:35:37 +0100 Message-Id: <20211121083537.612473-1-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_003541_964800_68934F31 X-CRM114-Status: GOOD ( 12.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Function sunxi_rsb_hw_exit() is sometimes called with pm runtime disabled, so in such cases pm_runtime_resume() will fail with -EACCES. Instead of doing whole dance of enabling pm runtime and thus clock just to disable it again immediately, just check if disabling clock is needed. That way calling pm_runtime_resume() is not needed at all. Fixes: 4a0dbc12e618 ("bus: sunxi-rsb: Implement runtime power management") Signed-off-by: Jernej Skrabec --- drivers/bus/sunxi-rsb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 6f225dddc74f..4566e730ef2b 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -687,11 +687,11 @@ static int sunxi_rsb_hw_init(struct sunxi_rsb *rsb) static void sunxi_rsb_hw_exit(struct sunxi_rsb *rsb) { - /* Keep the clock and PM reference counts consistent. */ - if (pm_runtime_status_suspended(rsb->dev)) - pm_runtime_resume(rsb->dev); reset_control_assert(rsb->rstc); - clk_disable_unprepare(rsb->clk); + + /* Keep the clock and PM reference counts consistent. */ + if (!pm_runtime_status_suspended(rsb->dev)) + clk_disable_unprepare(rsb->clk); } static int __maybe_unused sunxi_rsb_runtime_suspend(struct device *dev)