From patchwork Thu Jun 9 10:29:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 580546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 003C3CCA47E for ; Thu, 9 Jun 2022 10:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243021AbiFIKhM (ORCPT ); Thu, 9 Jun 2022 06:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242791AbiFIKg3 (ORCPT ); Thu, 9 Jun 2022 06:36:29 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9ED213AC4; Thu, 9 Jun 2022 03:36:14 -0700 (PDT) Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LJgQb0tMMz67ycH; Thu, 9 Jun 2022 18:32:39 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 12:36:12 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 11:36:09 +0100 From: John Garry To: , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required Date: Thu, 9 Jun 2022 18:29:06 +0800 Message-ID: <1654770559-101375-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1654770559-101375-1-git-send-email-john.garry@huawei.com> References: <1654770559-101375-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When the shost supports reserved commands then allocate the SCSI host sdev. As noted later, we need to use this for libata internal commands. Signed-off-by: John Garry --- drivers/scsi/hosts.c | 5 +++++ include/scsi/scsi_host.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5c9b05a8fec8..67930a61b222 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -298,6 +298,8 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, scsi_proc_host_add(shost); scsi_autopm_put_host(shost); + if (shost->nr_reserved_cmds) + shost->sdev = scsi_get_host_dev(shost); // TODO: Add error handling return error; /* @@ -360,6 +362,9 @@ static void scsi_host_dev_release(struct device *dev) if (shost->shost_state != SHOST_CREATED) put_device(parent); + if (shost->sdev) + scsi_free_host_dev(shost->sdev); + kfree(shost); } diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 88c8504395c8..2e14d65b7444 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -566,6 +566,7 @@ struct Scsi_Host { wait_queue_head_t host_wait; struct scsi_host_template *hostt; struct scsi_transport_template *transportt; + struct scsi_device *sdev; /* Area to keep a shared tag map */ struct blk_mq_tag_set tag_set;