From patchwork Tue Aug 22 19:17:09 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: 716398 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 2372DEE49AF for ; Tue, 22 Aug 2023 19:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbjHVTUL (ORCPT ); Tue, 22 Aug 2023 15:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjHVTUK (ORCPT ); Tue, 22 Aug 2023 15:20:10 -0400 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE95E4C; Tue, 22 Aug 2023 12:19:57 -0700 (PDT) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-26d1e5f2c35so3351519a91.2; Tue, 22 Aug 2023 12:19:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692731997; x=1693336797; 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=4HG3YoYAAnJdyYVAHKUCDxsEfi+t2LMdlh/ycmxSocs=; b=cwZWvOR9Qtekp3X9Gvom0HFsTP+/zvwwX0z2AZDibwLuY9z1kb+cxnExF50Tr3jJLW QBS8BIiW/qesywi4c57uefVvALnEMQkU6R6dNJAvCklk+0Y0PjzdfqigHeyLesBgRllC Z0GpZpke1F2xJoq8s4sPmYmBxBvhdYa5b8zEtXBdWye++6zXFvGUlq99nfZiysy2f1hn fFKCfc8mMc0rVB+uN1We2J4ulV2/Yr4m6fTEX9r0oOLSCIgoA4RA3kfNAGho4Vg9OKZQ jMsG4TILGz7MGi/MwsJmTldWbMIA8dnE3biBRXaiZdmKHrckiepha5iRXZIMiCpLguXH 4fUw== X-Gm-Message-State: AOJu0YyoH3DBJvgsHV5uK8xor7aZhF66NBHbn/yOcighdnp1+rKhmzcX pFSjW4AYG36fZhtCdNzwB8o= X-Google-Smtp-Source: AGHT+IFpPTp7U/8cEvni25HsdjjvUU5eacNSd9GCwyZvepjcuveqs7xnPE9/C5uBWNkC8WVxKYDAvA== X-Received: by 2002:a17:90a:ee87:b0:268:4485:c868 with SMTP id i7-20020a17090aee8700b002684485c868mr8343525pjz.49.1692731997070; Tue, 22 Aug 2023 12:19:57 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:88be:bf57:de29:7cc]) by smtp.gmail.com with ESMTPSA id m11-20020a17090a414b00b002696bd123e4sm8081632pjg.46.2023.08.22.12.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 12:19:56 -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 , "Bao D . Nguyen" , Can Guo , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Bean Huo , Asutosh Das , Arthur Simchaev Subject: [PATCH v11 14/16] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Date: Tue, 22 Aug 2023 12:17:09 -0700 Message-ID: <20230822191822.337080-15-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230822191822.337080-1-bvanassche@acm.org> References: <20230822191822.337080-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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. Reviewed-by: Bao D. Nguyen Reviewed-by: Can Guo Cc: Martin K. Petersen Cc: Avri Altman 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 a08924972b20..68bf8e94eee6 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) int 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 0; - 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);