From patchwork Fri Aug 23 10:15:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13774922 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 28A5AC531DC for ; Fri, 23 Aug 2024 10:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bIb+FksMIOJ64Q0IsP/5G/5OpyiFmNxQ3nT5nVYnW8k=; b=gfsw7hx11zu5bHHmCUOiRY2qvn 64Y2Iw/SzfeScBlTzvMBHGbe309XItfmJx75kVQx0ouka09JEOCP17m6/O85Nj4rj8dhcwOYtihMt Xwt1ZMp6A+lsncZRDW7Az4UGflagSAURxE9rwmh3eECg5Cwyqxfp7EYazOiTb2aAHav0AFklWM+9F cuv0b33ObotdsFDaT73HcLMOO7Dj8LagrHteTe9J6lvnbObXoe0tCtz2qWlrY+eT1+STlW9SAGY/d 3sTWo9nQR2djRZ6t1JOb7veDqdUfhB7FCvkSvPWQ9kNWnrr7us5uJfGKMgE/UxAKihiCHC0oF3/f+ M2bu4ljg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shRNS-0000000GIiw-2ZHg; Fri, 23 Aug 2024 10:18:42 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shRL1-0000000GHoM-1Up8 for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 10:16:12 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-53345fe848eso374593e87.2 for ; Fri, 23 Aug 2024 03:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408169; x=1725012969; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bIb+FksMIOJ64Q0IsP/5G/5OpyiFmNxQ3nT5nVYnW8k=; b=URqQ07B1rB6rGffMm5wMEWilbNCx7q3DW7bYFDeEZL7HXlnRh+6NIuJfeCczQ6833T KZVLunGswRiaomUIVfzDF5w3wRctnGVILsbJ+PYkHMU1T4bQXjJVsIq7Y2p4mAIspBBC erqd4p9g5j4Rgs7BdBQN5+SZyEE5+VYTm4RC2iUhY8RS2B7fE9aPaxzdx31bhVNqy+oA bE7gteHovcMheQViYoN1My3SHmHd5hV48AItOfdFQSPgkpJLowciY2kCbBd81/4wAbQB iuaVVO1c587vTy2kVEX+7j3WjrL3JwxhK26YXAewiR11bIB16i00k7Mw/sI+hKg6gW5m wsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408169; x=1725012969; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bIb+FksMIOJ64Q0IsP/5G/5OpyiFmNxQ3nT5nVYnW8k=; b=sJFxyvxD+lQ460/wxJ+mgudPYFbCLbONtavGqS1DRYQg5C/V1JnrDyuNVUZFeWsu8+ lURcRDchjL19tlarbzthhyoRvO/90Nna8DR2x2lNXoZu010zQpp0Vu+35+wuJ+xd0qKN VgjEZZ2dHWBcM76GRJx5ddqKGj54Dw1dpB3uGVnYwcHghwEU/4jzpbQ3NHmZih9X5jvz cUcWPlwTyu/twuBzEa1ott4kwgWWJHsVRVQlAYXHyiEzYlarSi1kIUzlRApwJqpMUOg7 Ch2p9+CwnuHMq3d8t6xE+3ocppWGnq82pA69Pfo754CGScD8AlTlAhGVpbsFaQ7TJv4l JtGw== X-Forwarded-Encrypted: i=1; AJvYcCWBSOmX5IX4sI0Z/1gLICsrZ9PBIp0K/YLGKTBGHOz3Moe6Qn5p90zzFfjvx8PkL6TnV3Hb8k/aW+G2Va4oaZGO@lists.infradead.org X-Gm-Message-State: AOJu0YyMf0mQgvB+WwrYe+DPHgWx9XQnTopPct+GJ5jbEEjMVvxxjKUr YMGk6JFs0U2p0dUOE/7cLuL0QFnkC1VgBEncDJCdCwDovrgAr/2DfSCGFQV55ec= X-Google-Smtp-Source: AGHT+IH2YdNwdbaIsW8x6JwUanSC2De/vmujuXIf/3MDm8QVZfLk7aokO3B6+oX3QzZfH0fhdLKHPg== X-Received: by 2002:a05:6512:23aa:b0:52f:c438:883c with SMTP id 2adb3069b0e04-5343876c643mr720470e87.1.1724408169146; Fri, 23 Aug 2024 03:16:09 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f2a1df5sm237912166b.68.2024.08.23.03.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:16:08 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 12:15:57 +0200 Subject: [PATCH 2/7] memory: emif: simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-b4-cleanup-h-guard-v1-2-01668915bd55@linaro.org> References: <20240823-b4-cleanup-h-guard-v1-0-01668915bd55@linaro.org> In-Reply-To: <20240823-b4-cleanup-h-guard-v1-0-01668915bd55@linaro.org> To: Santosh Shilimkar , Krzysztof Kozlowski , Roger Quadros , Tony Lindgren , Vladimir Zapolskiy , Miquel Raynal , Michal Simek Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3034; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dKvvXGp0G4rwTm+4rjJKl33390X+DCmUn8vg4x43GxU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyGFfrOD+/wW6Zo3iZXagedAsbyR4cF12jI3eS JPVjmdbm1uJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZshhXwAKCRDBN2bmhouD 11m6D/9n+H35P6ofeRJrA+nm522gpFEX5Eu7CMZi6f2sqzh+NqNhlZtFnclpnvwRGqagON9oSuR Y96OyUBnFBxMSfCmZRcrIfLch4iAFvRylrfFRV76JV5PDmUZSYKzKB0qfhFYjHrgN2buG9pC/bi 8i1N3h0X3QC0FBQ6YH3F7QHUgw7bN4/yylZkg0RIzz73pE4laH/Ue9yqBz7TqycgCamg+3NVfzB /R0x4qx8lnVE7kim5XODG+opwaJEqEFz7BP9Qv3PnrEIliml5EbBy7UbjgQGyZczd4RJgcoyNfw Eb345jjdaUPW4kAsN7Wkr+Fycxk2GWyOVJOhWU9Nm9YZlq1Xfgb3CxLymwYUIxcZbHZ3wupzjJT 0u4TgWe8y5dqx9ckkyWQdscun3CpXJ9IFn+aQidrHrX8j7lTwMBkzBAILGSM0U+KCCr7Yr2qQRJ iHo2kNPB93ds0C77lDSseIV5tcSs8wOzf4yTO1z1UFVK069j/2paS/n8YNX9fKt1qnPD9SfLpfY QlToLO+SLJGVGFsQYAhGuzqsDeuUX4TaqFvRgtyyZ1eYRUL6K2ADzBZRVPJmSzV8fiNjUrIcJZC O/iAkNEmtjQlYT7uuioAbBNleCl95X4GFK+alDrlRvo8YaIskbUU2a+YEk1sQMEkdsw2ohC+eqW m8iSd0+g4exq3eg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_031611_448805_6F61447F X-CRM114-Status: GOOD ( 16.93 ) 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 Simplify error handling (less gotos) over locks with guard(). The driver used file-scope variable 'irq_state' for storing IRQ state with spin_lock_irqsave, so move it into respective local scopes. This should be equivalent, but more readable (less global variables). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- Not tested on hardware, although I don't think that moving 'irq_state' scope would affect anything. --- drivers/memory/emif.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c index b32f3a8f9d71..99eb7d1baa5f 100644 --- a/drivers/memory/emif.c +++ b/drivers/memory/emif.c @@ -7,6 +7,7 @@ * Aneesh V * Santosh Shilimkar */ +#include #include #include #include @@ -68,7 +69,6 @@ struct emif_data { static struct emif_data *emif1; static DEFINE_SPINLOCK(emif_lock); -static unsigned long irq_state; static LIST_HEAD(device_list); static void do_emif_regdump_show(struct seq_file *s, struct emif_data *emif, @@ -522,18 +522,18 @@ static void setup_temperature_sensitive_regs(struct emif_data *emif, static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) { u32 old_temp_level; - irqreturn_t ret = IRQ_HANDLED; + irqreturn_t ret; struct emif_custom_configs *custom_configs; - spin_lock_irqsave(&emif_lock, irq_state); + guard(spinlock_irqsave)(&emif_lock); old_temp_level = emif->temperature_level; get_temperature_level(emif); if (unlikely(emif->temperature_level == old_temp_level)) { - goto out; + return IRQ_HANDLED; } else if (!emif->curr_regs) { dev_err(emif->dev, "temperature alert before registers are calculated, not de-rating timings\n"); - goto out; + return IRQ_HANDLED; } custom_configs = emif->plat_data->custom_configs; @@ -553,8 +553,7 @@ static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) * from thread context */ emif->temperature_level = SDRAM_TEMP_VERY_HIGH_SHUTDOWN; - ret = IRQ_WAKE_THREAD; - goto out; + return IRQ_WAKE_THREAD; } } @@ -570,10 +569,9 @@ static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) /* Temperature is going up - handle immediately */ setup_temperature_sensitive_regs(emif, emif->curr_regs); do_freq_update(); + ret = IRQ_HANDLED; } -out: - spin_unlock_irqrestore(&emif_lock, irq_state); return ret; } @@ -616,6 +614,7 @@ static irqreturn_t emif_interrupt_handler(int irq, void *dev_id) static irqreturn_t emif_threaded_isr(int irq, void *dev_id) { struct emif_data *emif = dev_id; + unsigned long irq_state; if (emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n");