From patchwork Tue Nov 14 21:16:25 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: 13455995 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 71625C4167D for ; Tue, 14 Nov 2023 21:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234052AbjKNVTz (ORCPT ); Tue, 14 Nov 2023 16:19:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234054AbjKNVTy (ORCPT ); Tue, 14 Nov 2023 16:19:54 -0500 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E415CB; Tue, 14 Nov 2023 13:19:51 -0800 (PST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1cc0d0a0355so46992055ad.3; Tue, 14 Nov 2023 13:19:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699996791; x=1700601591; 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=5hCFLPJyNlTWaTqcc9sUMaTozBjdPIt45oPYglqkq3o=; b=RW4CqW7F4Xt5rA+bjzJCokFQ8aujIxw3PNtFCXewDSt4dvivI+xtvY1l+f/um08/QV LzABUrYkCtf1zyGFWDwMTHiprEG7ZWydP7jjDeEw8CtWxGibYDtm3lY6tx/OEVrIMl5q xMacO6FNydUxyd4g5xrCEVXA6lYNSuPDD6uG5Nsa5gY2QDuvzRdrR48K3zww0qgJ+Vuw 8zBGPuHMdnion/SLTFEb8Z48XDRwZpknFKZtM9WpCfJ6Qf4yHoWjopMv6nzjkj8b8XTk eZIYOt5hxUYnzhhqWNsaHc2RKq1uulHO9m5WJXx09RTG+EAvIaCADkeYGRipEcE8NiA4 JiEg== X-Gm-Message-State: AOJu0YwATh9Vrvpx50CHTijXSUTRBxnJL6CmxPHFkozobFj9rib8yolz nXNeNUQYf2wGGon3zw5HcNs= X-Google-Smtp-Source: AGHT+IGjEFlMza2Psi0NVqhMLIkOTPPm++q44fMEJoZwAmywnvytORTc1xG5dWNYMm2lBUTrXmOGiw== X-Received: by 2002:a17:903:234b:b0:1cc:9781:4782 with SMTP id c11-20020a170903234b00b001cc97814782mr4427268plh.62.1699996790717; Tue, 14 Nov 2023 13:19:50 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:0:1000:8411:2278:ad72:cefb:4d49]) by smtp.gmail.com with ESMTPSA id ix7-20020a170902f80700b001c71ec1866fsm6169288plb.258.2023.11.14.13.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 13:19:50 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Bart Van Assche , "Bao D . Nguyen" , Can Guo , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Manivannan Sadhasivam , Asutosh Das , Peter Wang , Bean Huo , Arthur Simchaev Subject: [PATCH v15 17/19] scsi: ufs: Simplify ufshcd_auto_hibern8_update() Date: Tue, 14 Nov 2023 13:16:25 -0800 Message-ID: <20231114211804.1449162-18-bvanassche@acm.org> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog In-Reply-To: <20231114211804.1449162-1-bvanassche@acm.org> References: <20231114211804.1449162-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 a4f25131a78c..73cdf9917e02 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4411,21 +4411,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);