From patchwork Wed Feb 22 17:15:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Bauer X-Patchwork-Id: 9587247 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 7672D600CA for ; Wed, 22 Feb 2017 17:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 686F51FE85 for ; Wed, 22 Feb 2017 17:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D15E285C3; Wed, 22 Feb 2017 17:27:54 +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=ham 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 CDA1E1FE85 for ; Wed, 22 Feb 2017 17:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932901AbdBVR1w (ORCPT ); Wed, 22 Feb 2017 12:27:52 -0500 Received: from mga03.intel.com ([134.134.136.65]:40090 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932846AbdBVR1v (ORCPT ); Wed, 22 Feb 2017 12:27:51 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2017 09:26:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,195,1484035200"; d="scan'208";a="61181800" Received: from sbauer-z170x-ud5.lm.intel.com ([10.232.112.157]) by orsmga004.jf.intel.com with ESMTP; 22 Feb 2017 09:26:09 -0800 From: Scott Bauer To: linux-block@vger.kernel.org Cc: axboe@fb.com, keith.busch@intel.com, jonathan.derrick@intel.com, hch@lst.de, linux-nvme@lists.infradead.org, Scott Bauer Subject: [PATCH 2/3] nvme/pci: re-check security protocol support after reset Date: Wed, 22 Feb 2017 10:15:07 -0700 Message-Id: <1487783708-16285-3-git-send-email-scott.bauer@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487783708-16285-1-git-send-email-scott.bauer@intel.com> References: <1487783708-16285-1-git-send-email-scott.bauer@intel.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A device may change capabilities after each reset, e.g. due to a firmware upgrade. We should thus check for Security Send/Receive and OPAL support after each reset. Based on patches from Christoph and Keith. Signed-off-by: Scott Bauer --- drivers/nvme/host/pci.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index ddc51ad..f660fc2 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1739,7 +1739,7 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl) if (dev->ctrl.admin_q) blk_put_queue(dev->ctrl.admin_q); kfree(dev->queues); - kfree(dev->ctrl.opal_dev); + free_opal_dev(dev->ctrl.opal_dev); kfree(dev); } @@ -1789,14 +1789,17 @@ static void nvme_reset_work(struct work_struct *work) if (result) goto out; - if ((dev->ctrl.oacs & NVME_CTRL_OACS_SEC_SUPP) && !dev->ctrl.opal_dev) { - dev->ctrl.opal_dev = - init_opal_dev(&dev->ctrl, &nvme_sec_submit); + if (dev->ctrl.oacs & NVME_CTRL_OACS_SEC_SUPP) { + if (!dev->ctrl.opal_dev) + dev->ctrl.opal_dev = + init_opal_dev(&dev->ctrl, &nvme_sec_submit); + else if (was_suspend) + opal_unlock_from_suspend(dev->ctrl.opal_dev); + } else { + free_opal_dev(dev->ctrl.opal_dev); + dev->ctrl.opal_dev = NULL; } - if (was_suspend) - opal_unlock_from_suspend(dev->ctrl.opal_dev); - result = nvme_setup_io_queues(dev); if (result) goto out;