Received: by 10.192.165.148 with SMTP id m20csp2542372imm; Sun, 22 Apr 2018 09:12:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+20ZGg7FcnmTG2gN4Ec7TdBLCTwIQD0Z9fRSfUCA0zn8ZSWxNOTMg7jSfcQUwk5aPA9MkD X-Received: by 10.101.98.202 with SMTP id m10mr9357759pgv.348.1524413524467; Sun, 22 Apr 2018 09:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413524; cv=none; d=google.com; s=arc-20160816; b=Q9zXsUi+psvBHActIXZgcYrB/k7z5I11DKzpU4RMdC0nCbAgBb/ILUPZ1197o0zoiU Qb/k6QH3d+hz8vuD0j9lxRITsVL0ea3Oicw2IgmyQnFIaFD3h0ODlHbe2NWx4Im1xn1Z IfFyGr6gsDQuKqYhKx65gnmDo093xNIl44QaPSLlPITIOwxlV/q+Q8kaS/vBBWbArKEe 8/lBv+48MKRmjJ3Ca8hNWmlVdxcHmOQqEoYXXSzW3hFEHHsRH1Jx+bmfQz+RgqF4RJfd f4uWeC2PAauTk/sqVSbr7DYS/N3rWPtWVo2xjtN8wyj4jnaGxXl9lkzJf9a6BRNPIH1B eR0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vOom//KUqaMu47U/mqEZYrdBk5E8FFC5/O43m9EZSCo=; b=cJBUoAtkJgMnUoLvhntNmFr8yTZAlDsqeAobo2ihAyKrcvuEEbJrQJzElWPlmoF7gq hphV0ewRVOqiJ13T5Z2m8DdVu6z1vhtOqMo9fpxZTJXWau9Y0+WHyKaVfFjSo5aHDRgp IvOB8rCkgSwY7wUsiIaWOIzBk+mb8yvu3dc4Vw61XFzFwVxZVs+a8QKhFL4Quk4a99w2 J6aTTZ7b0KOjHlCFwwoROzqTbyXVp65eiX7j7FBPw0POk5q+sVP+5/WtWeQw7EiOk/yK 1tGyLWVztO+EXHaGcC7CG6SnzvjTiQVwCFVy6+68etx7wEPJmCjhGJm4Ld9K4KUyF6cF lpNg== ARC-Authentication-Results: i=1; mx.google.com; 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 x9-v6si10041174plv.159.2018.04.22.09.11.50; Sun, 22 Apr 2018 09:12:04 -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; 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 S1754048AbeDVQKw (ORCPT + 99 others); Sun, 22 Apr 2018 12:10:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752513AbeDVN4I (ORCPT ); Sun, 22 Apr 2018 09:56:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29AD48FF; Sun, 22 Apr 2018 13:56:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erik Schmauss , Dan Williams Subject: [PATCH 4.16 039/196] acpi, nfit: rework NVDIMM leaf method detection Date: Sun, 22 Apr 2018 15:50:59 +0200 Message-Id: <20180422135106.106592879@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams commit 466d1493ea830789a2f063f478aaed2e324f0d3d upstream. Some BIOSen do not handle 0-byte transfer lengths for the _LSR and _LSW (label storage read/write) methods. This causes Linux to fallback to the deprecated _DSM path, or otherwise disable label support. Introduce acpi_nvdimm_has_method() to detect whether a method is available rather than calling the method, require _LSI and _LSR to be paired, and require read support before enabling write support. Cc: Fixes: 4b27db7e26cd ("acpi, nfit: add support for the _LS...") Suggested-by: Erik Schmauss Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++-------------------- drivers/acpi/nfit/nfit.h | 5 ++--- 2 files changed, 23 insertions(+), 23 deletions(-) --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -196,7 +196,7 @@ static int xlat_nvdimm_status(struct nvd * In the _LSI, _LSR, _LSW case the locked status is * communicated via the read/write commands */ - if (nfit_mem->has_lsi) + if (nfit_mem->has_lsr) break; if (status >> 16 & ND_CONFIG_LOCKED) @@ -483,7 +483,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_desc min_t(u32, 256, in_buf.buffer.length), true); /* call the BIOS, prefer the named methods over _DSM if available */ - if (nvdimm && cmd == ND_CMD_GET_CONFIG_SIZE && nfit_mem->has_lsi) + if (nvdimm && cmd == ND_CMD_GET_CONFIG_SIZE && nfit_mem->has_lsr) out_obj = acpi_label_info(handle); else if (nvdimm && cmd == ND_CMD_GET_CONFIG_DATA && nfit_mem->has_lsr) { struct nd_cmd_get_config_data_hdr *p = buf; @@ -1654,12 +1654,23 @@ static void acpi_nvdimm_notify(acpi_hand device_unlock(dev->parent); } +static bool acpi_nvdimm_has_method(struct acpi_device *adev, char *method) +{ + acpi_handle handle; + acpi_status status; + + status = acpi_get_handle(adev->handle, method, &handle); + + if (ACPI_SUCCESS(status)) + return true; + return false; +} + static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc, struct nfit_mem *nfit_mem, u32 device_handle) { struct acpi_device *adev, *adev_dimm; struct device *dev = acpi_desc->dev; - union acpi_object *obj; unsigned long dsm_mask; const guid_t *guid; int i; @@ -1732,25 +1743,15 @@ static int acpi_nfit_add_dimm(struct acp 1ULL << i)) set_bit(i, &nfit_mem->dsm_mask); - obj = acpi_label_info(adev_dimm->handle); - if (obj) { - ACPI_FREE(obj); - nfit_mem->has_lsi = 1; - dev_dbg(dev, "%s: has _LSI\n", dev_name(&adev_dimm->dev)); - } - - obj = acpi_label_read(adev_dimm->handle, 0, 0); - if (obj) { - ACPI_FREE(obj); - nfit_mem->has_lsr = 1; + if (acpi_nvdimm_has_method(adev_dimm, "_LSI") + && acpi_nvdimm_has_method(adev_dimm, "_LSR")) { dev_dbg(dev, "%s: has _LSR\n", dev_name(&adev_dimm->dev)); + nfit_mem->has_lsr = true; } - obj = acpi_label_write(adev_dimm->handle, 0, 0, NULL); - if (obj) { - ACPI_FREE(obj); - nfit_mem->has_lsw = 1; + if (nfit_mem->has_lsr && acpi_nvdimm_has_method(adev_dimm, "_LSW")) { dev_dbg(dev, "%s: has _LSW\n", dev_name(&adev_dimm->dev)); + nfit_mem->has_lsw = true; } return 0; @@ -1839,10 +1840,10 @@ static int acpi_nfit_register_dimms(stru cmd_mask |= nfit_mem->dsm_mask & NVDIMM_STANDARD_CMDMASK; } - if (nfit_mem->has_lsi) + if (nfit_mem->has_lsr) { set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask); - if (nfit_mem->has_lsr) set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask); + } if (nfit_mem->has_lsw) set_bit(ND_CMD_SET_CONFIG_DATA, &cmd_mask); --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h @@ -171,9 +171,8 @@ struct nfit_mem { struct resource *flush_wpq; unsigned long dsm_mask; int family; - u32 has_lsi:1; - u32 has_lsr:1; - u32 has_lsw:1; + bool has_lsr; + bool has_lsw; }; struct acpi_nfit_desc {