Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp863329yba; Wed, 24 Apr 2019 10:49:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqx49p1fZHmAz9HkfEd5uKFCPyukqhXT0R8kF9zfA1ixFHqYpwzf2/ZNX37iah10oPC15esW X-Received: by 2002:a17:902:f83:: with SMTP id 3mr13507202plz.55.1556128179453; Wed, 24 Apr 2019 10:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556128179; cv=none; d=google.com; s=arc-20160816; b=NCfN6C/UzL0x9bx+mp2mMGCzYrQihxC8cAnhLD4h9QNCDqlh2TSscgnkoaIB4wuwvk OBShUSJLR0tXVnQFJVjqCbyUEi5MeBV2bNjohpy4EgUvlr4TQSIm4KHQaWhRotOlFy5H Ee8QOmWvhPWG2/J2BCaoKT42pILDFgpDDi08AfUzvZBogzJgNXCB84d7VzriUzApq/qt xLGFS3ztE3uewP8ImmLO3EHGdTkJ5b9fnf7Hym+10slNZZ5TD6UthfysonHjvtxQJbhA uKNZIfdhIaBj2mpzOMyP6FJwIWsXjuNeXsxVEjFTL/iz9Adz9l7gC57dcEqBNURO9q7O 1e0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DJGMRez60ZqsiOvd5f6KXvQ2Bx6x3CpKOGq8BCmtQmw=; b=DkTRzrieeTwRanxCm+UEbKpJqUKzaAgpGOpX3TdiJ7rghGBdZD3PswRNniimws3reP eJ698MNVm3ZabkhWH+OMhsxKjGKGZ24fwMEeFW9gpqnrl4Fbbzi1c6Q/fQnaOEugoslZ tX+PP7xAkyZn9JQVYoB2OF/RClmwFz5fqCbKkfdtq6gi8PZEnMHMs9SaWY/TRsJ1kAiU 9Db+u+EaNw1DJEKHY4o5fwfdu5mRDBJrJr2+Kjc6X9dscpCTUFpHFHdw2sirstfWMa5O 0BL2JpxIRg0VieU3ZBDujpdDATqTIn3VnZOqKZNCZ5lJINxGlAO+rhtKCEGf5PtuoMpS nyRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2h1fKLzQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si18544796pgo.122.2019.04.24.10.49.23; Wed, 24 Apr 2019 10:49:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2h1fKLzQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391339AbfDXRc2 (ORCPT + 99 others); Wed, 24 Apr 2019 13:32:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:59096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391330AbfDXRc0 (ORCPT ); Wed, 24 Apr 2019 13:32:26 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A739521903; Wed, 24 Apr 2019 17:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127145; bh=xiQ4MgSz/p6q4Qx87ghivdD2Fl6SPJvOd8a5hSQZNwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2h1fKLzQ/1qM+vfK7O8AT0p26LnMt2hfJwFl2MkKksiyw2Dhvr9ht7943X211JpwC mvlr7oivgDUjye14HDGAshE1Cu3YxhRCQ4nXE3nUGRpDhwA7jHlZOAr3Fg4CdyOQxd Ix4pYxdvlmFz0AbK248jr+yu9dkFNcMRdwVxWOr0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Toshi Kani , Dan Williams , Sasha Levin Subject: [PATCH 4.19 78/96] nfit/ars: Introduce scrub_flags Date: Wed, 24 Apr 2019 19:10:23 +0200 Message-Id: <20190424170925.089109303@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit e34b8252a3d2893ca55c82dbfcdaa302fa03d400 upstream. In preparation for introducing new flags to gate whether ARS results are stale, or poll the completion state, convert the existing flags to an unsigned long with enumerated values. This conversion allows the flags to be atomically updated outside of ->init_mutex. Reviewed-by: Toshi Kani Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/acpi/nfit/core.c | 30 +++++++++++++++++------------- drivers/acpi/nfit/nfit.h | 8 ++++++-- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index b5237a506464..6b5a3c3b4458 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1298,19 +1298,23 @@ static ssize_t scrub_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nvdimm_bus_descriptor *nd_desc; + struct acpi_nfit_desc *acpi_desc; ssize_t rc = -ENXIO; + bool busy; device_lock(dev); nd_desc = dev_get_drvdata(dev); - if (nd_desc) { - struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); - - mutex_lock(&acpi_desc->init_mutex); - rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, - acpi_desc->scrub_busy - && !acpi_desc->cancel ? "+\n" : "\n"); - mutex_unlock(&acpi_desc->init_mutex); + if (!nd_desc) { + device_unlock(dev); + return rc; } + acpi_desc = to_acpi_desc(nd_desc); + + mutex_lock(&acpi_desc->init_mutex); + busy = test_bit(ARS_BUSY, &acpi_desc->scrub_flags) + && !test_bit(ARS_CANCEL, &acpi_desc->scrub_flags); + rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, busy ? "+\n" : "\n"); + mutex_unlock(&acpi_desc->init_mutex); device_unlock(dev); return rc; } @@ -2960,7 +2964,7 @@ static unsigned int __acpi_nfit_scrub(struct acpi_nfit_desc *acpi_desc, lockdep_assert_held(&acpi_desc->init_mutex); - if (acpi_desc->cancel) + if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) return 0; if (query_rc == -EBUSY) { @@ -3034,7 +3038,7 @@ static void __sched_ars(struct acpi_nfit_desc *acpi_desc, unsigned int tmo) { lockdep_assert_held(&acpi_desc->init_mutex); - acpi_desc->scrub_busy = 1; + set_bit(ARS_BUSY, &acpi_desc->scrub_flags); /* note this should only be set from within the workqueue */ if (tmo) acpi_desc->scrub_tmo = tmo; @@ -3050,7 +3054,7 @@ static void notify_ars_done(struct acpi_nfit_desc *acpi_desc) { lockdep_assert_held(&acpi_desc->init_mutex); - acpi_desc->scrub_busy = 0; + clear_bit(ARS_BUSY, &acpi_desc->scrub_flags); acpi_desc->scrub_count++; if (acpi_desc->scrub_count_state) sysfs_notify_dirent(acpi_desc->scrub_count_state); @@ -3322,7 +3326,7 @@ int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc, struct nfit_spa *nfit_spa; mutex_lock(&acpi_desc->init_mutex); - if (acpi_desc->cancel) { + if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) { mutex_unlock(&acpi_desc->init_mutex); return 0; } @@ -3401,7 +3405,7 @@ void acpi_nfit_shutdown(void *data) mutex_unlock(&acpi_desc_lock); mutex_lock(&acpi_desc->init_mutex); - acpi_desc->cancel = 1; + set_bit(ARS_CANCEL, &acpi_desc->scrub_flags); cancel_delayed_work_sync(&acpi_desc->dwork); mutex_unlock(&acpi_desc->init_mutex); diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h index df31a2721573..94710e579598 100644 --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h @@ -181,6 +181,11 @@ struct nfit_mem { bool has_lsw; }; +enum scrub_flags { + ARS_BUSY, + ARS_CANCEL, +}; + struct acpi_nfit_desc { struct nvdimm_bus_descriptor nd_desc; struct acpi_table_header acpi_header; @@ -202,8 +207,7 @@ struct acpi_nfit_desc { unsigned int max_ars; unsigned int scrub_count; unsigned int scrub_mode; - unsigned int scrub_busy:1; - unsigned int cancel:1; + unsigned long scrub_flags; unsigned long dimm_cmd_force_en; unsigned long bus_cmd_force_en; unsigned long bus_nfit_cmd_force_en; -- 2.19.1