Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5084391rwb; Wed, 21 Sep 2022 03:01:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7VmumWg9p/Dvu3wuAGJPQYBApCP7VzsNOv4zTfl4AwYjV25MTkPrcc9GUjQrQNJm/jXvmU X-Received: by 2002:a63:cf48:0:b0:439:7d1c:fedc with SMTP id b8-20020a63cf48000000b004397d1cfedcmr23986052pgj.281.1663754473976; Wed, 21 Sep 2022 03:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663754473; cv=none; d=google.com; s=arc-20160816; b=xdzoz599ZAIy8CtY5oI6WPFxRT3kigXRjuibHgOtMb61YQalOZ1RfC0F/lW9y0AjK/ o9SFRHzzvFtBD2n3yW+gHMuLkpCR9oiFXQWcwanC3V/FwzB2tfD1iYyie29/szfsZ08G +C1hNYNiK8+erR72DmgUJoZjTCnyZUAujRzx6pwklXJgDRJEt2DAj+jh4NjGjy8Y6Olc k63PxsUccA6D7v6Ra/1D2RZ7GXRQp5L1Ypw62/uNaIgp2R5+W4ClfQquH5eCkc/13rey IlCXNBNV7mjDK+ZCW7PZ1I0jtA4RqnpGfHESnsaHlk+7+ExHs0/vEe7elnevDziYnvsa 3JCA== 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=L3/r5Ak8WpSakIE1QHq77ag68ZhGd6b8ZYwWuOQDcEI=; b=Qkf/+I5fC7ljK4KOF6ThBXG0MopaCq1BrZb/TDofL+8+NbccdV9IZDUJYtEfKyTOy3 7edUL6Uh+TyqJlHxJtHGdsR2SOrlhMRV9bWJWs9NeTPuYkI15o2kJECKuiepi4VXc/lX r2Ps4QTN7/Dvsr5xIKTxrdfSrhmbTj8yVVhBmSlTleoVGXCv0+s948dPTgsD2H3o0kH3 P0Vv8jTtuTizkibeQjxXnGAWX/pR2x6egUvOxPIxH2xT5XIGYz1B+hxVIapp1ppiCPvH zdMxAdIS/tiwzR+b/0b0exhzFDKfAK6bhSoQiMzs/1ZV0oiboLaBsXq5NbvlGIlViON5 br9g== 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 a21-20020aa78655000000b0053e7495a394si2033377pfo.141.2022.09.21.03.01.01; Wed, 21 Sep 2022 03:01:13 -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 S231653AbiIUJWx (ORCPT + 99 others); Wed, 21 Sep 2022 05:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbiIUJWV (ORCPT ); Wed, 21 Sep 2022 05:22:21 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6991116; Wed, 21 Sep 2022 02:22:01 -0700 (PDT) Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MXXv34nPHz687SH; Wed, 21 Sep 2022 17:20:15 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 11:21:59 +0200 Received: from [10.195.245.235] (10.195.245.235) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 10:21:58 +0100 Message-ID: <55ee46e7-a07d-d1ef-72fd-1f99b2a04684@huawei.com> Date: Wed, 21 Sep 2022 10:21:57 +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 RFC 2/6] scsi: scsi_transport_sas: Allocate end device target id in the rphy alloc To: Damien Le Moal , , , , CC: , , , References: <1663669630-21333-1-git-send-email-john.garry@huawei.com> <1663669630-21333-3-git-send-email-john.garry@huawei.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.195.245.235] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,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 20/09/2022 23:02, Damien Le Moal wrote: >> >>       return &rdev->rphy; >>   } >>   EXPORT_SYMBOL(sas_end_device_alloc); >> @@ -1500,6 +1505,16 @@ struct sas_rphy *sas_expander_alloc(struct >> sas_port *parent, >>   } >>   EXPORT_SYMBOL(sas_expander_alloc); >> +static bool sas_rphy_end_device_valid_tproto(struct sas_rphy *rphy) >> +{ >> +    struct sas_identify *identify = &rphy->identify; >> + >> +    if (identify->target_port_protocols & >> +        (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA)) >> +        return true; >> +    return false; > > You could just do: > > return identify->target_port_protocols & >     (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA)) OK > >> +} >> + >>   /** >>    * sas_rphy_add  -  add a SAS remote PHY to the device hierarchy >>    * @rphy:    The remote PHY to be added >> @@ -1529,16 +1544,10 @@ int sas_rphy_add(struct sas_rphy *rphy) >>       mutex_lock(&sas_host->lock); >>       list_add_tail(&rphy->list, &sas_host->rphy_list); >> -    if (identify->device_type == SAS_END_DEVICE && >> -        (identify->target_port_protocols & >> -         (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA))) >> -        rphy->scsi_target_id = sas_host->next_target_id++; >> -    else if (identify->device_type == SAS_END_DEVICE) >> -        rphy->scsi_target_id = -1; >>       mutex_unlock(&sas_host->lock); >>       if (identify->device_type == SAS_END_DEVICE && > > You could move this check inside sas_rphy_end_device_valid_tproto(), > no ? > Yeah, I suppose I could. I might require a function rename with that. >> -        rphy->scsi_target_id != -1) { >> +        sas_rphy_end_device_valid_tproto(rphy)) { >>           int lun; >>           if (identify->target_port_protocols & SAS_PROTOCOL_SSP) >> @@ -1667,7 +1676,7 @@ static int sas_user_scan(struct Scsi_Host >> *shost, uint channel, >>       mutex_lock(&sas_host->lock); >>       list_for_each_entry(rphy, &sas_host->rphy_list, list) { >>           if (rphy->identify.device_type != SAS_END_DEVICE || >> -            rphy->scsi_target_id == -1) >> +            !sas_rphy_end_device_valid_tproto(rphy)) >>               continue; Thanks, John