From patchwork Tue Aug 2 18:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 9260081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F6006048B for ; Tue, 2 Aug 2016 18:30:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06F3F28487 for ; Tue, 2 Aug 2016 18:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF970284F6; Tue, 2 Aug 2016 18:30:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A0F328487 for ; Tue, 2 Aug 2016 18:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754971AbcHBSaq (ORCPT ); Tue, 2 Aug 2016 14:30:46 -0400 Received: from mga14.intel.com ([192.55.52.115]:46786 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755417AbcHBS1I (ORCPT ); Tue, 2 Aug 2016 14:27:08 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 02 Aug 2016 11:27:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,461,1464678000"; d="scan'208";a="1018429210" Received: from theros.lm.intel.com ([10.232.112.65]) by fmsmga001.fm.intel.com with ESMTP; 02 Aug 2016 11:27:06 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Rafael J. Wysocki" , Dan Williams , Len Brown , linux-acpi@vger.kernel.org, linux-nvdimm@lists.01.org, "Lee, Chun-Yi" , stable@vger.kernel.org#v4.2+ Subject: [PATCH v2] libnvdimm, nd_blk: mask off reserved status bits Date: Tue, 2 Aug 2016 12:26:53 -0600 Message-Id: <20160802182653.6647-1-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160729205912.20436-1-ross.zwisler@linux.intel.com> References: <20160729205912.20436-1-ross.zwisler@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "NVDIMM Block Window Driver Writer's Guide": http://pmem.io/documents/ http://pmem.io/documents/NVDIMM_DriverWritersGuide-July-2016.pdf defines the layout of the block window status register. For the July 2016 version of the spec linked to above, this happens in Figure 4 on page 26. The only bits defined in this spec are bits 31, 5, 4, 2, 1 and 0. The rest of the bits in the status register are reserved, and there is a warning following the diagram that says: Note: The driver cannot assume the value of the RESERVED bits in the status register are zero. These reserved bits need to be masked off, and the driver must avoid checking the state of those bits. This change ensures that for hardware implementations that set these reserved bits in the status register, the driver won't incorrectly fail the block I/Os. Signed-off-by: Ross Zwisler Reviewed-by: Lee, Chun-Yi Cc: Dan Williams Cc: stable@vger.kernel.org # v4.2+ --- Changes from V1: - Rebased onto the v4.8 merge tree. As Joey points out the ND BLK code recently moved from drivers/acpi/nfit.c to drivers/acpi/nfit/core.c. Since we were in the merge window for v4.8 I didn't know what to use as a baseline, so I just used v4.7, which was apparently incorrect. Sorry about that. - Added Joey's reviewed-by. For stable kernels v4.2 and beyond the v1 patch for drivers/acpi/nfit.c applies cleanly and should be used. --- drivers/acpi/nfit/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 8c234dd..80cc7c0 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1527,11 +1527,12 @@ static u32 read_blk_stat(struct nfit_blk *nfit_blk, unsigned int bw) { struct nfit_blk_mmio *mmio = &nfit_blk->mmio[DCR]; u64 offset = nfit_blk->stat_offset + mmio->size * bw; + const u32 STATUS_MASK = 0x80000037; if (mmio->num_lines) offset = to_interleave_offset(offset, mmio); - return readl(mmio->addr.base + offset); + return readl(mmio->addr.base + offset) & STATUS_MASK; } static void write_blk_ctl(struct nfit_blk *nfit_blk, unsigned int bw,