Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1324407yba; Wed, 24 Apr 2019 20:07:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7fZZlHCBlD0qS+4srDxqre/wQackPwBjO8Vx3GM7ulXdGx4eEONMkxioyOvpq4OtvJfMm X-Received: by 2002:a63:d816:: with SMTP id b22mr33882619pgh.349.1556161647717; Wed, 24 Apr 2019 20:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556161647; cv=none; d=google.com; s=arc-20160816; b=fx2vGb/vzZuqt7V3BW2/yERl163iW7C99sq9l+LN3yGlXvcEI+B1HnWpR1yg9XNraV ykCkD5jOQ8TNHR3rY67f0F+xy2iuo3waJz9ZnWXwvyXvCGGwYRGhjV5u227HsCj2XjUX GMlDUIPyL7QUjtpV3xNwZB2Ekx80AqFxknQKRsSvcS9hZVmrnZtRWwx5HFFvPgbJGn5+ lVtlvSvVpmpLqAKo3udqBnyDxZa8etf5x+dKiwVxMUnctrD8NoYPTJOyGMBveOC53b0x WS0pf3SRCb6bTl70ej7RaNfs6if2qhvk1UWAS/WP5B4Dr268jp4bUKlwKfQy/ZOpuY4V OplA== 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=wGKIDY8jfVxFEhe5DSia0ZzG7Z9fcDQUuCmxUjeXr18=; b=oAbN5GE8eHs5OO/vsGmXiFaW5TP4n/g+hLAx8gorBCeWIE1rjFoLy6Pp3wb9jaaACh 1LLEOyqtvm+F4DzksFygYOUl3OXra/0uvpaFNDTuUfps59M/zXhzgfP1QY/1muVeqvnv HhZuW2DUslLChhte0+3PvqEh2hhCDAuTWQ2U90KNInxlUj7apWYChkVSMe1PQW1ouf5E 6OpHEdjl6XoqUK8ixUb25WIMnVbgeMK8O4Z5kL44le/YCJYqv/Q+2IJhgfkpj3IPt69v vqTE5cszLlBFp1IIyFmpgdWOFvQDgblbbR3PqTwhW1vBLzg2gwwTGCdMZR290eMs/jkN Y1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mh65q8I0; 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 j127si22388345pfb.25.2019.04.24.20.07.11; Wed, 24 Apr 2019 20:07:27 -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=Mh65q8I0; 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 S2391856AbfDXRhv (ORCPT + 99 others); Wed, 24 Apr 2019 13:37:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:36826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392264AbfDXRhr (ORCPT ); Wed, 24 Apr 2019 13:37:47 -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 6D8C32054F; Wed, 24 Apr 2019 17:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127465; bh=ODyhJmbxpgUJ145tAlfCi8sB6HYJBxFgx8TPVbHkWa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mh65q8I0+YP0ttAmgXBM533onXP2dMwbmnVMlK8YRV4tdgjKqarjBpJECw8sqHRsN 1YqOmeHhU+fKSE1V+8NpkaauSM9qXwDombjeMy9Yiu1aQFZn31ltEAG61N67DRSmcw oC+b9gPLMjCHHpZ7q4RGUWxnL98cmyDl6nrthYdQ= 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 5.0 101/115] nfit/ars: Introduce scrub_flags Date: Wed, 24 Apr 2019 19:10:37 +0200 Message-Id: <20190424170930.666255693@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170924.797924502@linuxfoundation.org> References: <20190424170924.797924502@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 1a48c92eaed5..64308e669250 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1319,19 +1319,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; } @@ -3081,7 +3085,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) { @@ -3155,7 +3159,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; @@ -3171,7 +3175,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); @@ -3460,7 +3464,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; } @@ -3539,7 +3543,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 871fb3de3b30..897ce10192a0 100644 --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h @@ -210,6 +210,11 @@ struct nfit_mem { int family; }; +enum scrub_flags { + ARS_BUSY, + ARS_CANCEL, +}; + struct acpi_nfit_desc { struct nvdimm_bus_descriptor nd_desc; struct acpi_table_header acpi_header; @@ -231,8 +236,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