Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3498612imu; Mon, 14 Jan 2019 04:12:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN4s3H6gNj972UPrKYSDNtJ7z/QwnVwXXkL6D2uphxeSnaDIrn6RS2y3n64696V38vvEGIdB X-Received: by 2002:a17:902:2c83:: with SMTP id n3mr25418321plb.104.1547467932918; Mon, 14 Jan 2019 04:12:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547467932; cv=none; d=google.com; s=arc-20160816; b=QJtc1jd5cGRjOoHh+R5DqvcPlB8eoUAFmE2JhfdchtHYvzP555iOftLaEWdSmhc1Ng b7ISsj5BiNvdvQB1bov/YgYMwvUTdAlgz3aVpzqNU7Mcs2hFQG31/MxxNh0AfBfQlcAp s22Uj8LPiS0tf3v7v79qQI3Fjh6RzJYofhc/NbmDnSMdW3gs+jYBn29Zeb1pmqYresmE J22un8YJGQ7wsQWXxcClLFlYoXXRavXOcbQe3sgK6BD5pW53F01xLRqlVpDiqPbpQGtS 4EJ+bcZSsXf8PGhHOw23Cqu6NXXAdzDdWZS3URVDfbX3q1OsXBUzVNIxqQAfKgahRI8z RtuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=3qVXYFzTGSv0wakCE2Rv0iRr8dkbWrREdIEc3Olxk7I=; b=Oh802gbl4lBGErk4F2ukh49ZafChX0koxyrEDwfLoJLsP3pCLOXQDybm6p4u3ISHVd 7y/4sdaoSq+kxGF1IbFnECRw+LFDLo0V53r1lQpuDkiMvRRVQPjoqK9XVj2yQiPUZduq clF1Ns8l0hDWviehLigsFTe2CrXdSbYBkNlws5/45dNniOroYmWu/qLT8rC5ZjoYewcw P1S98W0wMHZDq1SLbJlW0No3gRPeBLkRjNfmXk23+KNuY3BGAajatOvSDPupF3U7iF3k FQoNUYSut593QrNCrnuQhDYulhYzIqqG7QbvjhkyCbMcw9Nw4RiVxDkfsmC/FusHmVCR 3+2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u72si199645pgc.360.2019.01.14.04.11.56; Mon, 14 Jan 2019 04:12:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbfANMKo (ORCPT + 99 others); Mon, 14 Jan 2019 07:10:44 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:45742 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726436AbfANMKn (ORCPT ); Mon, 14 Jan 2019 07:10:43 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 630A371401E80BC863A6; Mon, 14 Jan 2019 20:10:41 +0800 (CST) Received: from [127.0.0.1] (10.202.226.43) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Mon, 14 Jan 2019 20:10:30 +0800 Subject: Re: [PATCH] scsi: isci: initialize shost fully before calling scsi_add_host() To: "Martin K. Petersen" References: <20190108205043.3122-1-logang@deltatee.com> <20190109184105.GB22070@lst.de> <8d96b40d-fc83-9218-9479-3de423594ddb@huawei.com> CC: Christoph Hellwig , Logan Gunthorpe , , , , Intel SCU Linux support , Artur Paszkiewicz , "James E.J. Bottomley" , Jens Axboe , Jeff Moyer , chenxiang From: John Garry Message-ID: <0ffaf166-c7e5-b135-fdc5-bcac24148e62@huawei.com> Date: Mon, 14 Jan 2019 12:10:23 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.43] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/2019 02:34, Martin K. Petersen wrote: > > John, > >> So how about just drop these APIs and let the user set the shost >> protection parameters directly, like other shost parameters, > > The protection interfaces here obviously predate the block layer > allocation changes that made this particular issue pop up. > >> which should make it a bit clearer when these should be set, >> i.e. before scsi_add_host()? > > In general, I am not so keen on the somewhat messy intersection between > the host parameters and the host template. The static host templates > made lots of sense in the days of Seagate ST01 and fixed hardware > capabilities. But reality is that most modern controllers have to query > firmware interfaces to figure out what their actual capabilities are. Hi Martin, I am not suggested setting the parameters via scsi host template, but rather dynamically (as we currently do) but just drop the set helper functions, like: shost->max_channel = 1; shost->max_cmd_len = 16; ... if (hisi_hba->prot_mask) { dev_info(dev, "Registering for DIF/DIX prot_mask=0x%x\n", prot_mask); - scsi_host_set_prot(hisi_hba->shost, prot_mask); + shost->prot_capabilities = prot_mask; } rc = scsi_add_host(shost, dev); if (rc) goto err_out_ha; rc = sas_register_ha(sha); if (rc) goto err_out_register_ha; I find that it is not crystal clear when scsi_host_set_prot() and scsi_host_set_guard() should be called, but not so for setting the shost parameters directly, which is common. > > So in this case I think that accessor functions are actually better > because they allow us to print a big fat warning when you twiddle > something you shouldn't post-initialization. So that's something I think > we could--and should--improve. > Sure, this is an alternative, but I would rather make it obvious when these parameters should be set so that this would not be required. Thanks, John