Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3963905pxb; Mon, 4 Oct 2021 13:51:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfXwSqyf/7BAqSF7JuCfpmkqjiom+n8WWE4f9SacDcfl5duN03vRw4WwwrvC6+1DqyqrPe X-Received: by 2002:a17:906:81da:: with SMTP id e26mr19604692ejx.296.1633380659791; Mon, 04 Oct 2021 13:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380659; cv=none; d=google.com; s=arc-20160816; b=f8vIdWxLXQhdrvDXWKC72LE/I+aLFCdKdCoQp8bWysbkuiYAsZaz10zw5FG8p3E5Ec 8YndmJr8aRu8aDuxJcRdDhboPpRd2DKIHF7OeUCVqYOV1Ylw3Os2AfJIMVXvc3SseYzS jY2cM6EtHkMIP2OhDb38jCVlBpUt0xU5VkLgUSoeFb3ag9E8QImGAzlhnFm8g/nX2X0h BgFV+0N1WHKbsDBay4UK+dBbOwRPTaxBvCxkHKK3wIh5AiCbPS9f13p5CQ/KaTmBDHhI HxWtDQ++hysyeQlhkzjn8CcEha0ZFy6ZbcaRDvAAobP7ALzP1x0zysqIlsOO+MmE8oSx pDQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A51Kj0bkzv1gzlTcSrL7tie6hTw7q5FUt/5Oe7Shurg=; b=CPYKVCjqQ9PQ6bLe+pg12aYFj4MZ+IhmiF1iBe7a69sec1dG2oxDwC2qdPUBQDxlWv x2vd8e96GQiy7bZpgFJ69+xeWNXEn4c3yVjBiSsC1fPq7UL0u2OucMh6z+UYDzNEBkhu 8n8GGyFwwZUFvwIRpjthAOr4oJyVCvXUWnmBF7lPU/58JKNovkzyJa8hunfx2ePUREE3 cx0p/Mk0HNGRNfvP82MTsq4KcgXmR5OGL3Dc7NylJt2LhavBToh8zggJqPrbY/OLlKsJ fxDRTaFR27mC/4U5vvQKH6iK+KuKx7KxoyfTl0xmrclDLZcx4AGMz3Q1UGe4JKJxEUcf CSaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RODvKJ97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si19306152eja.677.2021.10.04.13.50.36; Mon, 04 Oct 2021 13:50:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RODvKJ97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238624AbhJDNkx (ORCPT + 99 others); Mon, 4 Oct 2021 09:40:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:52372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238599AbhJDNis (ORCPT ); Mon, 4 Oct 2021 09:38:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D8F06140B; Mon, 4 Oct 2021 13:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353476; bh=BpI0cUMAS8ZxEG1xRyUiaDcdMUNc+wakU1qwxRloUFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RODvKJ97kI81SVX/JIPGm/LeyIWpEEQUsta4oXQq93yiN4sWt2HgH4X3M1DfafTH7 jbu4t8Z/sFCr2fh2Aam0b9bZb6och829Vt4+60E2GSPb4JbZakgclVxxoHIbD9DIVb 5aRv0Xwu9uiJVY5xzbaPHDQxlJcS1ocoT5PxlPII= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Peter , Orlando Chamberlain , Aditya Garg , Keith Busch , Christoph Hellwig , Jens Axboe Subject: [PATCH 5.14 144/172] nvme: add command id quirk for apple controllers Date: Mon, 4 Oct 2021 14:53:14 +0200 Message-Id: <20211004125049.615573689@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch commit a2941f6aa71a72be2c82c0a168523a492d093530 upstream. Some apple controllers use the command id as an index to implementation specific data structures and will fail if the value is out of bounds. The nvme driver's recently introduced command sequence number breaks this controller. Provide a quirk so these spec incompliant controllers can function as before. The driver will not have the ability to detect bad completions when this quirk is used, but we weren't previously checking this anyway. The quirk bit was selected so that it can readily apply to stable. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214509 Cc: Sven Peter Reported-by: Orlando Chamberlain Reported-by: Aditya Garg Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Tested-by: Sven Peter Link: https://lore.kernel.org/r/20210927154306.387437-1-kbusch@kernel.org Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/core.c | 4 +++- drivers/nvme/host/nvme.h | 6 ++++++ drivers/nvme/host/pci.c | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -980,6 +980,7 @@ EXPORT_SYMBOL_GPL(nvme_cleanup_cmd); blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) { struct nvme_command *cmd = nvme_req(req)->cmd; + struct nvme_ctrl *ctrl = nvme_req(req)->ctrl; blk_status_t ret = BLK_STS_OK; if (!(req->rq_flags & RQF_DONTPREP)) { @@ -1028,7 +1029,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ return BLK_STS_IOERR; } - nvme_req(req)->genctr++; + if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN)) + nvme_req(req)->genctr++; cmd->common.command_id = nvme_cid(req); trace_nvme_setup_cmd(req, cmd); return ret; --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -149,6 +149,12 @@ enum nvme_quirks { * 48 bits. */ NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16), + + /* + * The controller requires the command_id value be be limited, so skip + * encoding the generation sequence number. + */ + NVME_QUIRK_SKIP_CID_GEN = (1 << 17), }; /* --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3282,7 +3282,8 @@ static const struct pci_device_id nvme_i { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005), .driver_data = NVME_QUIRK_SINGLE_VECTOR | NVME_QUIRK_128_BYTES_SQES | - NVME_QUIRK_SHARED_TAGS }, + NVME_QUIRK_SHARED_TAGS | + NVME_QUIRK_SKIP_CID_GEN }, { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, { 0, }