Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp282666iol; Thu, 9 Jun 2022 03:55:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFFT24Zb0iOQuI1hk3HDWgnx1BlzZM0wc1DeEsYz4pfcupLYFdGsxLr753NlxiwcfnwcK+ X-Received: by 2002:aa7:8e0b:0:b0:50d:6d7f:54d with SMTP id c11-20020aa78e0b000000b0050d6d7f054dmr106570533pfr.29.1654772155710; Thu, 09 Jun 2022 03:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654772155; cv=none; d=google.com; s=arc-20160816; b=K22ZG7pdbEFDnIiKWP0unxrPMGt/JzTzJxYGs9FIx3yqaaXWNhSdTJQy6FIhTioJIn jumtnM7oEjU/o47qyYL0PyCd69nyoQlUN6NpmLRsOoNzEQFCGV2oxj5YOivyyK3bkGwO 4ZS+cAMIcnSoIUDd0WQhmtK20JaPFQuCgT6NiMZu5oYuXfTnaKTw6qAOT62eF/3FBD68 zshiyXR/JYBEpOMkvPlzx1ywfRZqcjhMJU/8qHJbjuuZfcFdRcWvMW/M1usHH5OCzbZJ XD8+jy6akfh/BqLIz6DTUUoWkEPqUiWo1AcvSNohhAVz46Y04ljMPfxLHxSgaYxWZQeN WFxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ZLJWja2JTlFOl85q44T0LuTY6X0PPfpfnUEvFbGH5/E=; b=QI5s/9KBRS1tgDJ4FpERjBl8Ndu6cYTeE66rAorvWJfej2c2DOnCOQSW8Ok3SPf7jW QlSMTkaeOK7dHRi3QZewa6gXV4jRYW8DXEs1e0/Q18M7nmfeFDsU3gPPModE7zBPlz4L yeLvLCmhxu3NjlrU0ilCfbFiYpcX2tFv+6irrjNSsb8cUKbYnyAuozRz5qffrlpO5sGb 1B2A1QM3q4rhpP1RuZ+PQNM2Z7i0W8WObxMAGCCDd/1VeQSI2V6Ost7GQzbCFeOECZ2g Unxfz+qdJ0TAS0G0w51WW68kaQASh7f47DGuILy0bYV4TkQB16XPQif8L0Drr6US5/c3 C0dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d129-20020a636887000000b003fdfb59d31asi10307111pgc.568.2022.06.09.03.55.42; Thu, 09 Jun 2022 03:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243112AbiFIKhV (ORCPT + 99 others); Thu, 9 Jun 2022 06:37:21 -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 Content-Type: text/plain 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 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.26.2