From patchwork Tue Aug 15 09:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9901535 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 1C19360244 for ; Tue, 15 Aug 2017 09:52:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BD0328815 for ; Tue, 15 Aug 2017 09:52:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C0C28822; Tue, 15 Aug 2017 09:52:52 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9AA4E28815 for ; Tue, 15 Aug 2017 09:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753406AbdHOJww (ORCPT ); Tue, 15 Aug 2017 05:52:52 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:36026 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753473AbdHOJwv (ORCPT ); Tue, 15 Aug 2017 05:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q+yHoKHJlNHFQTDybrgLSmwSvcHEDlACEI+RP0J/48w=; b=q8NbsX/B+tuTL2YO7bpp0W5ca fkfMOA+1FCn90No5RU48t0Z93WNuT1MwZgu7FABdkFl6c4DLVvBiHrkhuBupKBeg0zN8RPM9m+gtR xNfx9HP55aG7GltuP6oNYIbu1qZ9C59ZMCefGY5uDjFVsgjNO4+WZ3ms3h67C+160YiaBgODwEaYN PNiPRro0QcT9QH2afRTfneQui+7tVoo7syq152bjqYopbcuaxRp3oCaSfKd7uYRGWoA/JeED8goO8 cZOfOhBwoOpR8wqg51WKTYxi8ZEgmPxs0ZLFyB4ezRumc1ToahghigrOQSvOzjfwOGVy08WwMC8BY T+vEw3tQA==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dhYWm-0007Bp-TN; Tue, 15 Aug 2017 09:52:49 +0000 From: Sagi Grimberg To: linux-nvme@lists.infradead.org, Christoph Hellwig , Keith Busch Cc: linux-block@vger.kernel.org Subject: [PATCH 11/12] nvme: add sed-opal ctrl manipulation in admin configuration Date: Tue, 15 Aug 2017 12:52:24 +0300 Message-Id: <1502790745-12569-12-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502790745-12569-1-git-send-email-sagi@grimberg.me> References: <1502790745-12569-1-git-send-email-sagi@grimberg.me> 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 Signed-off-by: Sagi Grimberg --- drivers/nvme/host/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 4344adff7134..19aa68f1fb4a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2743,6 +2743,7 @@ static void nvme_free_ctrl(struct kref *kref) put_device(ctrl->device); nvme_release_instance(ctrl); ida_destroy(&ctrl->ns_ida); + free_opal_dev(ctrl->opal_dev); ctrl->ops->free_ctrl(ctrl); } @@ -3007,6 +3008,7 @@ EXPORT_SYMBOL_GPL(nvme_destroy_admin_queue); int nvme_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) { + bool was_suspend = !!(ctrl->ctrl_config & NVME_CC_SHN_NORMAL); int error; error = ctrl->ops->alloc_admin_queue(ctrl); @@ -3052,6 +3054,16 @@ int nvme_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) if (error) goto out_cleanup_queue; + if (ctrl->oacs & NVME_CTRL_OACS_SEC_SUPP) { + if (!ctrl->opal_dev) + ctrl->opal_dev = init_opal_dev(ctrl, &nvme_sec_submit); + else if (was_suspend) + opal_unlock_from_suspend(ctrl->opal_dev); + } else { + free_opal_dev(ctrl->opal_dev); + ctrl->opal_dev = NULL; + } + return 0; out_cleanup_queue: