From patchwork Wed Aug 16 19:53:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 13355601 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7772BC25B5C for ; Wed, 16 Aug 2023 19:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345957AbjHPT40 (ORCPT ); Wed, 16 Aug 2023 15:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345989AbjHPT4M (ORCPT ); Wed, 16 Aug 2023 15:56:12 -0400 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18DC82D50; Wed, 16 Aug 2023 12:56:01 -0700 (PDT) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6889656eb58so486538b3a.1; Wed, 16 Aug 2023 12:56:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692215760; x=1692820560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JezTmlByBxxwVL/c+JEFvGZtx2Wv2zOwYtr9WnFCI4Q=; b=FAVnHv+TY52CRAGTAq87i+E0sl+IDlHebTvM60FbImy/zHUD027io9iV3Qw4U6JlmB NPrD8RmX4uF4LPQtTJW7ZxtGdfeZjGbjnl/SfnKbwqH15Q/njVyXQjavKQ7wZoir1liV kbal2JsFH0oDoZWafr0WBGGCSPDPiCIpdyY5p88hawwecLvnY1quZc9Utz+rfs1x77Bx Yu3ZjrSaQUzydR/QMVzZg8zbnkaImPg89s3jyHtS+gksz6hmK32PoFYhqZJ08iNZpbqT TwjiiHWjEjYlrdQRzUbcJ9Q6SayWAaPR8rY3JDZChyI+lLHFgX7XdAogEvshU3iIfRGR zlog== X-Gm-Message-State: AOJu0YwiFlJ0t9SpIlBj/qlShWNkKOs9I5a197fPfPsaz58zMN74yZ8B THOHf8LyBJO89CyaQztC1Vs= X-Google-Smtp-Source: AGHT+IG7ypN2mncc9Kbis3KBEAngXyHI4rQgea1EUr4Nb+qS+zhJv1LRKuwAN8QFNY5mB/GzALOH5Q== X-Received: by 2002:a05:6a00:1792:b0:682:f529:6d69 with SMTP id s18-20020a056a00179200b00682f5296d69mr3499666pfg.7.1692215760229; Wed, 16 Aug 2023 12:56:00 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:7141:e456:f574:7de0]) by smtp.gmail.com with ESMTPSA id r26-20020a62e41a000000b0068890c19c49sm1588508pfh.180.2023.08.16.12.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 12:55:59 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Avri Altman , Damien Le Moal , Ming Lei , "James E.J. Bottomley" , Stanley Chu , Can Guo , Bean Huo , Asutosh Das , "Bao D. Nguyen" , Arthur Simchaev Subject: [PATCH v9 15/17] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Date: Wed, 16 Aug 2023 12:53:27 -0700 Message-ID: <20230816195447.3703954-16-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.694.ge786442a9b-goog In-Reply-To: <20230816195447.3703954-1-bvanassche@acm.org> References: <20230816195447.3703954-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Calls to ufshcd_auto_hibern8_update() are already serialized: this function is either called if user space software is not running (preparing to suspend) or from a single sysfs store callback function. Kernfs serializes sysfs .store() callbacks. No functionality is changed. This patch makes the next patch in this series easier to read. Cc: Martin K. Petersen Cc: Avri Altman Cc: Christoph Hellwig Cc: Damien Le Moal Cc: Ming Lei Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index f1bba459b46f..39000c018d8b 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4347,21 +4347,13 @@ static void ufshcd_configure_auto_hibern8(struct ufs_hba *hba) void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) { - unsigned long flags; - bool update = false; + const u32 cur_ahit = READ_ONCE(hba->ahit); - if (!ufshcd_is_auto_hibern8_supported(hba)) + if (!ufshcd_is_auto_hibern8_supported(hba) || cur_ahit == ahit) return; - spin_lock_irqsave(hba->host->host_lock, flags); - if (hba->ahit != ahit) { - hba->ahit = ahit; - update = true; - } - spin_unlock_irqrestore(hba->host->host_lock, flags); - - if (update && - !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { + WRITE_ONCE(hba->ahit, ahit); + if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { ufshcd_rpm_get_sync(hba); ufshcd_hold(hba); ufshcd_configure_auto_hibern8(hba);