Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp814076pxb; Tue, 12 Apr 2022 14:11:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcDs8lgyKTATlfP2uVUqVqmtR9TaPb/Q5hUISog+gygthR9kodgyD8cvlKyjgjwgs7ExBT X-Received: by 2002:a17:902:ce04:b0:156:3be:8a86 with SMTP id k4-20020a170902ce0400b0015603be8a86mr40477491plg.152.1649797866324; Tue, 12 Apr 2022 14:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649797866; cv=none; d=google.com; s=arc-20160816; b=m/2u/c525BIcm/tOwgHA2ZNE3R9C4o4fPDCFDEbyIT7eR2CocGGNBH97Lloaa2oWRY lsH2NL1j7K/1waa3uRaMNrnd8ggwAKyv7Uq7SC4O0NZBj0jaV54KXjGh6S279pRnIHEj ur8t9xLNchS6xMXT8SDd33ieuR72mkhS0ib7kV2gxm/DYmmRdS9V47j5oxllXlP41UDO GA94b4Q01Bq2w3mTjUHW226Acy4HfKY7IG1X5xCBQL7I8Vl1ayIIaKd/L3T5CCMoc2Un 7FLEvwKblEcEbzi1vDhCtELMW/Ug3EoFyZnFsw1jLCWO1fOm3LIA7YpUMHdEMduqFL3N R2Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=HcYPVOnCq8jQP3IS7Bs5PRQZbE1j3or7OSrSz0g8SKg=; b=LpvOeRrElpPMFLBN/u/HTgSUW1gd+tS+OzgVRrwZmHBzoqEpZZ4eorbAIUQ/z7Dr6Q E5uklEtqBXmGeDGUO9NqjxzNjcKupbiDdsCgExlrobf6MPF0BWG8fLYdt963q+Inqok6 gsM5CC49TxHM4NEuVu4q+bwBoMbKqdydCy7C+NEtGsZTVh98UNbrMjm8QlMpMOMPPUiK Pry7dr66+kDbl0ssFf4cIKeSzssDozxSxRQWJWupVj8TF0ADoVKzGRIShZ4/v/i2xl7v igBN5dwaxNz+Z+ciYtk487z5Z5IVzCULeld5K4l6yuqIJGmgEnzFcJEZ1I4I4iIDwT0m Rs8A== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n23-20020a056a0007d700b004fda8fb990fsi11719020pfu.352.2022.04.12.14.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18F08E38B3; Tue, 12 Apr 2022 13:27:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391139AbiDLJ2Z (ORCPT + 99 others); Tue, 12 Apr 2022 05:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381855AbiDLIYP (ORCPT ); Tue, 12 Apr 2022 04:24:15 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9ED56203; Tue, 12 Apr 2022 00:57:50 -0700 (PDT) Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KcyhJ1rfkz67xbc; Tue, 12 Apr 2022 15:55:44 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 12 Apr 2022 09:57:45 +0200 Received: from [10.47.91.197] (10.47.91.197) 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; Tue, 12 Apr 2022 08:57:44 +0100 Message-ID: Date: Tue, 12 Apr 2022 08:57:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template To: "Ewan D. Milne" , Krzysztof Kozlowski , "James E.J. Bottomley" , "Martin K. Petersen" , "Alim Akhtar" , Avri Altman , "Doug Gilbert" , , CC: References: <20220408103027.311624-1-krzysztof.kozlowski@linaro.org> <2a88a992-641a-b3ff-fe39-7a61fff87cb6@huawei.com> <4c3be5b6-50ef-9e9a-6cee-9642df943342@linaro.org> <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.91.197] X-ClientProxiedBy: lhreml725-chm.china.huawei.com (10.201.108.76) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 08/04/2022 20:31, Ewan D. Milne wrote: > On Fri, 2022-04-08 at 13:57 +0100, John Garry wrote: >> On 08/04/2022 13:32, Krzysztof Kozlowski wrote: >>> On 08/04/2022 14:14, John Garry wrote: >>>> On 08/04/2022 11:30, Krzysztof Kozlowski wrote: >>>>> Several pointers to 'struct scsi_host_template' do not modify it, so >>>>> made them const for safety. >>>>> >>>> Is this standard practice? What is so special here? >>> This is standard practice and there is nothing special here. Pointers to >>> const are preferred because: >>> 1. They add safety if data is actually const. This is not yet the case, >>> but scsi_host_template allocation could be made const with some effort. > > This seems unlikely, because some drivers, e.g. vmw_pvscsi and scsi_debug, > modify the scsi_host_template based on things like module parameters. > The standard flow is: shost = scsi_host_alloc(sht, ) // modify shost, like shost->cmd_per_lun = 5; scsi_add_host(shost) Is there some reason for which those two drivers can't follow that? >> >> To me this seems better, but I think that some drivers might modify >> their scsi_host_template (so not possible) > > Several drivers modify scsi_host_template, e.g. .can_queue, .cmd_per_lun > > There is also code in lpfc_create_port() that initializes a scsi_host_template > that is embedded in the lpfc_hba struct. I don't think it gets modified after > scsi_add_host() but it seems like driver maintainers might expect to be able > to do so, in general. > Even so, I don't see why other drivers cannot declare their scsi_host_template as const. C would have no problem with sht not be being const for this: struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, ) thanks, John