Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp734977rwi; Thu, 27 Oct 2022 07:03:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM702Acp1X95h59WXmWVDbBYJe9NG/64dD+y4vdnbK9P4wCoPBMXGoQUpIPzap0ZaNqFTpWw X-Received: by 2002:aa7:df04:0:b0:45b:cb0d:856a with SMTP id c4-20020aa7df04000000b0045bcb0d856amr46920758edy.180.1666879433941; Thu, 27 Oct 2022 07:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666879433; cv=none; d=google.com; s=arc-20160816; b=ADbGEX6eyqA2f2Vsdhav/STkcUkh/mEq8ulSDIblLYDaYMC/Up9kR5Vk5JhYNyeOIl 7WXCOSy++QIDAiBGl0RVVji/zCiwfAK7+rRx2YbD/xKKAzyA5ILfbg1qddBZWuARupa9 BZEvOr66qywfkQ9PCAYDu3vUFcujk9KfI2gmzcoq9UDJT6nAI+NgLSOp+3OvpMou/VPh vT/BVAYHeh7IJMoZ2EqzXACQxPROMXjYBZ73vIALMxglkSGqw8YWbqOmV8q01bKzzuWJ rmHP3bCsqmhsPHLdGaiiFaEJF+fEolcUe1oSXMFUtbaD7q5fvK6lzh5c2rFQHvZOh/g5 TXng== 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:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=6vU8vlBe1NmH+Y8hhVFNTdabTpguN3wNwqYkXSRqXNw=; b=HRBRQBsLeSFeTTiAD3lZjBTO4C2g5E+q6E6MtRyoZfVMRe4TuQySp9OzhCT6K1c2f1 JUdk7/xSQPG/BcgPN+1rbqf325j5Ch05eKvA0dFoPV+OggtThE/F35Bouj2zDhRLNeWi nnNVzgi5HMtX+u2a5E5+kE4qBoR/6xPDaH9ybbu1hjffF7P3OcULkODEeLmbnsgOyjw+ Si6F7lfKs6wGgzzY9t9kVcV+40BsM3gC1VHSfL2uRh0qpMUTPFQzhd8KeX4IgGokHa3w PFCKxEwOf1Bz8sqWZQdhr9Om/bcXWI1Ueg6/9V9u5Ml7xqnZ2bt9LBeDX19xMK5yRRau y1DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMR4DON5; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=qEr+EWEG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a170906175800b0078df1c345dasi1023720eje.534.2022.10.27.07.03.26; Thu, 27 Oct 2022 07:03:53 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMR4DON5; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=qEr+EWEG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235904AbiJ0NDF (ORCPT + 99 others); Thu, 27 Oct 2022 09:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235861AbiJ0NDD (ORCPT ); Thu, 27 Oct 2022 09:03:03 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA99175792; Thu, 27 Oct 2022 06:03:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5246A21D35; Thu, 27 Oct 2022 13:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1666875781; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vU8vlBe1NmH+Y8hhVFNTdabTpguN3wNwqYkXSRqXNw=; b=yMR4DON5E2/9m+BnomQU+UpYr4Q1Zdm7v0aJ0HpBCTsVlWjkFzansIMo66WOK3Rnta0WnL B3LRaNWse0JPeb/Mij3Ways7jwHzkk24BGNcvVF75lKJij+NukIIsedd+m4OR2VuQ+UHcz AD7JuTyl8SBGYrKPPUqFgZvwBbsopC4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1666875781; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vU8vlBe1NmH+Y8hhVFNTdabTpguN3wNwqYkXSRqXNw=; b=qEr+EWEG0kSSrZzav6o334GkEDPqeEs0fYGFuPv2ylmYwEZPFvJeijRE10Tpv0l0+FSb2i 9625IKD2r9j7iFBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 85140134CA; Thu, 27 Oct 2022 13:03:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FFRBHoSBWmOmXAAAMHmgww (envelope-from ); Thu, 27 Oct 2022 13:03:00 +0000 Message-ID: <3ef0347f-f3e2-cf08-2b27-f65a7afe82a2@suse.de> Date: Thu, 27 Oct 2022 15:02:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand() Content-Language: en-US To: John Garry , Damien Le Moal , jejb@linux.ibm.com, martin.petersen@oracle.com, bvanassche@acm.org, hch@lst.de, ming.lei@redhat.com, niklas.cassel@wdc.com Cc: axboe@kernel.dk, jinpu.wang@cloud.ionos.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linuxarm@huawei.com References: <1666693976-181094-1-git-send-email-john.garry@huawei.com> <1666693976-181094-3-git-send-email-john.garry@huawei.com> <08fdb698-0df3-7bc8-e6af-7d13cc96acfa@opensource.wdc.com> <83d9dc82-ea37-4a3c-7e67-1c097f777767@huawei.com> From: Hannes Reinecke In-Reply-To: <83d9dc82-ea37-4a3c-7e67-1c097f777767@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 On 10/27/22 11:56, John Garry wrote: > On 27/10/2022 02:45, Damien Le Moal wrote: >> On 10/25/22 19:32, John Garry wrote: >>> Add callback to queue reserved commands - call it "internal" as this is >>> what libata uses. >>> >>> Also add it to the base ATA SHT. >>> >>> Signed-off-by: John Garry >>> --- >>>   drivers/ata/libata-scsi.c | 14 ++++++++++++++ >>>   include/linux/libata.h    |  5 ++++- >>>   2 files changed, 18 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c >>> index 30d7c90b0c35..0d6f37d80137 100644 >>> --- a/drivers/ata/libata-scsi.c >>> +++ b/drivers/ata/libata-scsi.c >>> @@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device >>> *sdev, struct ata_device *dev) >>>       return 0; >>>   } >>> +int ata_internal_queuecommand(struct Scsi_Host *shost, struct >>> scsi_cmnd *scmd) >>> +{ >>> +    struct ata_port *ap; >>> +    int res; >>> + >>> +    ap = ata_shost_to_port(shost); >> >> You can have this initialization together with the ap declaration. >> >>> +    spin_lock_irq(ap->lock); >>> +    res = ata_sas_queuecmd(scmd, ap); >>> +    spin_unlock_irq(ap->lock); >>> + >>> +    return res; >>> +} >>> +EXPORT_SYMBOL_GPL(ata_internal_queuecommand); >> >> I am officially lost here. Do not see why this function is needed... > > The general idea in this series is to send ATA internal commands as > requests. And this function is used as the SCSI midlayer to queue > reserved commands. See how it is plugged into __ATA_BASE_SHT, below. > > So we have this overall flow: > > ata_exec_internal_sg(): >  -> alloc request >  -> blk_execute_rq_nowait() >      ... -> scsi_queue_rq() >         -> sht->reserved_queuecommd() >             -> ata_internal_queuecommand() > > And then we have ata_internal_queuecommand() -> ata_sas_queuecmd() -> > ata_scsi_queue_internal() -> ata_qc_issue(). > > Hope it makes sense. > > Thanks, > John > >> >>> + >>>   /** >>>    *    ata_scsi_slave_config - Set SCSI device attributes >>>    *    @sdev: SCSI device to examine >>> diff --git a/include/linux/libata.h b/include/linux/libata.h >>> index 8938b584520f..f09c5dca16ce 100644 >>> --- a/include/linux/libata.h >>> +++ b/include/linux/libata.h >>> @@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(struct >>> scsi_device *sdev, >>>                     sector_t capacity, int geom[]); >>>   extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev); >>>   extern int ata_scsi_slave_config(struct scsi_device *sdev); >>> +extern int ata_internal_queuecommand(struct Scsi_Host *shost, >>> +                struct scsi_cmnd *scmd); >>>   extern void ata_scsi_slave_destroy(struct scsi_device *sdev); >>>   extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, >>>                          int queue_depth); >>> @@ -1391,7 +1393,8 @@ extern const struct attribute_group >>> *ata_common_sdev_groups[]; >>>       .slave_destroy        = ata_scsi_slave_destroy,    \ >>>       .bios_param        = ata_std_bios_param,        \ >>>       .unlock_native_capacity    = ata_scsi_unlock_native_capacity,\ >>> -    .max_sectors        = ATA_MAX_SECTORS_LBA48 >>> +    .max_sectors        = ATA_MAX_SECTORS_LBA48,\ >>> +    .reserved_queuecommand = ata_internal_queuecommand >>>   #define ATA_SUBBASE_SHT(drv_name)                \ >>>       __ATA_BASE_SHT(drv_name),                \ >> > But that means we can't use it before the SCSI host is initialized; some HBAs require to send commands before the host can be initialized properly. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman