From patchwork Thu May 13 22:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 437598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 997CCC43460 for ; Thu, 13 May 2021 22:38:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EE34610EA for ; Thu, 13 May 2021 22:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233332AbhEMWjT (ORCPT ); Thu, 13 May 2021 18:39:19 -0400 Received: from mail-pf1-f177.google.com ([209.85.210.177]:34726 "EHLO mail-pf1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbhEMWjS (ORCPT ); Thu, 13 May 2021 18:39:18 -0400 Received: by mail-pf1-f177.google.com with SMTP id 10so23147966pfl.1 for ; Thu, 13 May 2021 15:38:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tIX5CSrqlFqAKpWAJvmKJ1rzEbqvrwxZubFYH1DN5o4=; b=B7JIWWLCrUNWu1hwapJC+0tmDHt0jOVV1glVeoE3igwEqmjINehXVQ+Oi4iwqdMj3U n0Rjmb1WHFeenEIzr6wczu1cZntprWS//fLDt9N01K8shBv3T+73+s/ZgEZyGhvrE62z cmxYW7+CL2o+0daw7olysQZmyy9cmajhK7w1HM+t3kgbs/9iVwsQ/QwGrKFMw+3KKes9 1ApJdcC/tkKpBQExY7tXOL+6UG1th0kaewVYYXCd5rm6K4MkldpsXtcTsUqR+5k7awJP r8ogkkG7n57UqmClcyEhGGe2I01LanIBEaGAMcM6PlnNQP9OvVXpVkaiIwCZnSQdAJtU b+0g== X-Gm-Message-State: AOAM532rSDkkKs5nFf3D/dn85010nABEZjWzf/evQgTJ/B7CTHvgSqzw VhEIgGPWJTy8R5GFUm3U38c= X-Google-Smtp-Source: ABdhPJz2+B3NF+TIRWPr9YrWHgP71P7pPsM9YnXWGJbgnacqQE/bHoF2pwiI237N1xJL6Fe7MazANA== X-Received: by 2002:a63:7a0f:: with SMTP id v15mr3195149pgc.100.1620945487398; Thu, 13 May 2021 15:38:07 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:54a8:4531:57a:cfd8]) by smtp.gmail.com with ESMTPSA id j23sm2852582pfh.179.2021.05.13.15.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 15:38:06 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jaegeuk Kim , linux-scsi@vger.kernel.org, Bart Van Assche , Sagi Grimberg Subject: [PATCH v3 2/8] iser: Use scsi_get_sector() instead of scsi_get_lba() Date: Thu, 13 May 2021 15:37:51 -0700 Message-Id: <20210513223757.3938-3-bvanassche@acm.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513223757.3938-1-bvanassche@acm.org> References: <20210513223757.3938-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_get_sector() instead of scsi_get_lba() since the name of the latter is confusing. This patch does not change any functionality. Reviewed-by: Sagi Grimberg Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/infiniband/ulp/iser/iser_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 136f6c4492e0..d6bbf1bf428c 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c @@ -949,7 +949,7 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, sector_t sector_off = mr_status.sig_err.sig_err_offset; sector_div(sector_off, sector_size + 8); - *sector = scsi_get_lba(iser_task->sc) + sector_off; + *sector = scsi_get_sector(iser_task->sc) + sector_off; iser_err("PI error found type %d at sector %llx " "expected %x vs actual %x\n", From patchwork Thu May 13 22:37:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 437597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EBC4C433ED for ; Thu, 13 May 2021 22:38:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0039A613CD for ; Thu, 13 May 2021 22:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbhEMWjY (ORCPT ); Thu, 13 May 2021 18:39:24 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:52113 "EHLO mail-pj1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbhEMWjV (ORCPT ); Thu, 13 May 2021 18:39:21 -0400 Received: by mail-pj1-f49.google.com with SMTP id k5so4693624pjj.1 for ; Thu, 13 May 2021 15:38:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G1uH0Qqhl+VItQLjiPAhxwr5Xmm1kr0yUknPMfVM2WY=; b=NSPKwcJwR2RoPdrW5zfYwunvYSxphBANV6jCpkAyIc95JjCnCzdYwJPuQSEDehjOa4 Fi2FfEMvTvOPkwRfwWUUECvENfilCcUBsbg98eeYuDecCHsbKKrD38X/NVNACS/pR7Rj K8HcnmICfs0HuYUhUvuV6OfqaxzeoLGtOICUXwdzhpmbhJ4/CKsCMXDyx0WUCRI1OHtO wkjALCinOMbC4oANn4X+opvrpWXrq/L1LhGdwctItpxdxK0fniwObIHVmMnMY2i7GQ7K soOAl8Uq72YGeJfB4v9xzUTVdTaIcqXW7HgjDpf8/CxqVelsjQxE74j/5/wkJqDAqTGQ BE2Q== X-Gm-Message-State: AOAM530z+2X6zbgKH+BUf11GVRnfwtXWJjOXZmG5vv0L3jbO3lvu4Fnw bOLQkgHQkIHX54uW3FfGZ7M= X-Google-Smtp-Source: ABdhPJxwzdGTiqMbMHw8kyM4WAb8zOAAdGnuyQ0di0+g4Lfh1Nx8yBptv27VJqBTqpsJc/jvVEoVSw== X-Received: by 2002:a17:90a:b796:: with SMTP id m22mr47808240pjr.220.1620945490295; Thu, 13 May 2021 15:38:10 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:54a8:4531:57a:cfd8]) by smtp.gmail.com with ESMTPSA id j23sm2852582pfh.179.2021.05.13.15.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 15:38:09 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jaegeuk Kim , linux-scsi@vger.kernel.org, Bart Van Assche , Lee Duncan , Artur Paszkiewicz Subject: [PATCH v3 4/8] isci: Use scsi_get_sector() instead of scsi_get_lba() Date: Thu, 13 May 2021 15:37:53 -0700 Message-Id: <20210513223757.3938-5-bvanassche@acm.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513223757.3938-1-bvanassche@acm.org> References: <20210513223757.3938-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_get_sector() instead of scsi_get_lba() since the name of the latter is confusing. Additionally, use lower_32_bits() instead of open-coding it. This patch does not change any functionality. Reviewed-by: Lee Duncan Cc: Artur Paszkiewicz Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/scsi/isci/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index e7c6cb4c1556..ad24ddbcaea3 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c @@ -341,7 +341,7 @@ static void scu_ssp_ireq_dif_insert(struct isci_request *ireq, u8 type, u8 op) tc->reserved_E8_0 = 0; if ((type & SCSI_PROT_DIF_TYPE1) || (type & SCSI_PROT_DIF_TYPE2)) - tc->ref_tag_seed_gen = scsi_get_lba(scmd) & 0xffffffff; + tc->ref_tag_seed_gen = lower_32_bits(scsi_get_sector(scmd)); else if (type & SCSI_PROT_DIF_TYPE3) tc->ref_tag_seed_gen = 0; } @@ -369,7 +369,7 @@ static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) tc->app_tag_gen = 0; if ((type & SCSI_PROT_DIF_TYPE1) || (type & SCSI_PROT_DIF_TYPE2)) - tc->ref_tag_seed_verify = scsi_get_lba(scmd) & 0xffffffff; + tc->ref_tag_seed_verify = lower_32_bits(scsi_get_sector(scmd)); else if (type & SCSI_PROT_DIF_TYPE3) tc->ref_tag_seed_verify = 0; From patchwork Thu May 13 22:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 437596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36604C43461 for ; Thu, 13 May 2021 22:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D2E3610EA for ; Thu, 13 May 2021 22:38:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbhEMWjZ (ORCPT ); Thu, 13 May 2021 18:39:25 -0400 Received: from mail-pf1-f170.google.com ([209.85.210.170]:38846 "EHLO mail-pf1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233689AbhEMWjX (ORCPT ); Thu, 13 May 2021 18:39:23 -0400 Received: by mail-pf1-f170.google.com with SMTP id k19so23024915pfu.5 for ; Thu, 13 May 2021 15:38:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jnR4DC0GInW4O0dC8OWaA+yRYG0YljiNTsBIUHiO75k=; b=hStWdimjwTy/QD3HVCgmJUSeD+IA92jewK93iiHgAng4Hplrn4GKKP18GWe87vesdR Aj7/pcvi6mM1jjtVpVoBJvJXs9N+p+P3uzbE+Mdp8Hp8Go47i+R9xTTil9f4rO3mi3kf 8IzoUX8028H7YbKAJTlxJ+J9KxwunlGLM3vHcpLTdQfvzP6g+afnl3JQUGTeeswLipLQ LwTkDEy6jvm1juCRil//0PLMtXFuDk7dYuua4dXX798M5DBqbJslPOLIcpt8R6GUV4YW XIypJn9fRlY+d8MuuUyql1rwKnT6CRZKumaP7wMVLwZAo7wS2eLJvVYnR41NgAkyyD2o CCnQ== X-Gm-Message-State: AOAM533FXxlKClwvCUIxyaqrnTUo4i0+jqpT4zmwTyoD6vWiX5BCOfwB Exwh4UA4x8pm2LdW+jH4A768DGmvtB8= X-Google-Smtp-Source: ABdhPJxtXenSxPIlpsBB+Cd14mmi15KzXfDc5L0BLNMhMfMDOcL0DL4yukGavan7M3OLi+mCPAkerA== X-Received: by 2002:a62:8389:0:b029:27d:28f4:d583 with SMTP id h131-20020a6283890000b029027d28f4d583mr42939393pfe.33.1620945493094; Thu, 13 May 2021 15:38:13 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:54a8:4531:57a:cfd8]) by smtp.gmail.com with ESMTPSA id j23sm2852582pfh.179.2021.05.13.15.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 15:38:12 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jaegeuk Kim , linux-scsi@vger.kernel.org, Bart Van Assche , Nilesh Javali Subject: [PATCH v3 6/8] qla2xxx: Use scsi_get_sector() instead of scsi_get_lba() Date: Thu, 13 May 2021 15:37:55 -0700 Message-Id: <20210513223757.3938-7-bvanassche@acm.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513223757.3938-1-bvanassche@acm.org> References: <20210513223757.3938-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_get_sector() instead of scsi_get_lba() since the name of the latter is confusing. Additionally, use lower_32_bits() instead of open-coding it. This patch does not change any functionality. Cc: Nilesh Javali Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/scsi/qla2xxx/qla_iocb.c | 9 +++------ drivers/scsi/qla2xxx/qla_isr.c | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 38b5bdde2405..28e30a7e8883 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -778,8 +778,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt, * No check for ql2xenablehba_err_chk, as it would be an * I/O error if hba tag generation is not done. */ - pkt->ref_tag = cpu_to_le32((uint32_t) - (0xffffffff & scsi_get_lba(cmd))); + pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd))); if (!qla2x00_hba_err_chk_enabled(sp)) break; @@ -799,8 +798,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt, pkt->app_tag_mask[0] = 0x0; pkt->app_tag_mask[1] = 0x0; - pkt->ref_tag = cpu_to_le32((uint32_t) - (0xffffffff & scsi_get_lba(cmd))); + pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd))); if (!qla2x00_hba_err_chk_enabled(sp)) break; @@ -824,8 +822,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt, * 16 bit app tag. */ case SCSI_PROT_DIF_TYPE1: - pkt->ref_tag = cpu_to_le32((uint32_t) - (0xffffffff & scsi_get_lba(cmd))); + pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd))); pkt->app_tag = cpu_to_le16(0); pkt->app_tag_mask[0] = 0x0; pkt->app_tag_mask[1] = 0x0; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 67229af4c142..24d406411f81 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -2632,7 +2632,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) "DIF ERROR in cmd 0x%x lba 0x%llx act ref" " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app" " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n", - cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag, + cmd->cmnd[0], (u64)scsi_get_sector(cmd), a_ref_tag, e_ref_tag, a_app_tag, e_app_tag, a_guard, e_guard); /* @@ -2644,10 +2644,10 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) (scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3 || a_ref_tag == be32_to_cpu(T10_PI_REF_ESCAPE))) { uint32_t blocks_done, resid; - sector_t lba_s = scsi_get_lba(cmd); + sector_t sector = scsi_get_sector(cmd); /* 2TB boundary case covered automatically with this */ - blocks_done = e_ref_tag - (uint32_t)lba_s + 1; + blocks_done = e_ref_tag - (uint32_t)sector + 1; resid = scsi_bufflen(cmd) - (blocks_done * cmd->device->sector_size); @@ -2677,7 +2677,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) if (k != blocks_done) { ql_log(ql_log_warn, vha, 0x302f, "unexpected tag values tag:lba=%x:%llx)\n", - e_ref_tag, (unsigned long long)lba_s); + e_ref_tag, (u64)sector); return 1; } From patchwork Thu May 13 22:37:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 437595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87042C433ED for ; Thu, 13 May 2021 22:38:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B05461405 for ; Thu, 13 May 2021 22:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233706AbhEMWjg (ORCPT ); Thu, 13 May 2021 18:39:36 -0400 Received: from mail-pj1-f53.google.com ([209.85.216.53]:54215 "EHLO mail-pj1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbhEMWjZ (ORCPT ); Thu, 13 May 2021 18:39:25 -0400 Received: by mail-pj1-f53.google.com with SMTP id p17so14289776pjz.3 for ; Thu, 13 May 2021 15:38:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qmOu6yPUVAiTvr3F59u7miUtgTGmA7jI0Rn33W48iFc=; b=K8LxL1QNiEidk/LYCO1bPM7YrSNYObUg7QReioEJE2MN3GC2tTqmJNHs5cAI+Sd9Zw sMCvZC57J/pRf65q/nr6uFs1VLNM71aYul+9zAhLYRYxLS6lF6NqyHRnchHBnzQwEgOG ZH5W+0npuxlSKlIXNd8xKa9jDoLzUZI2vFKA0vzY9PyQLwChUen33QQ2G5it+mSzGNnx FIIQEVLwM3zy551RkVY5KiqAgfqId83t8XLrSWtqrIl9ebrzRlc7j07swF3CPwutEtit K148u51W2Z98V0dSaMLItUtgAVi6RDQfIcepHStbHQNTNcXKoWGU+pUAO9abVF/XxNL6 lj6A== X-Gm-Message-State: AOAM532bGR79bV12IkfR/4wxSzYfTmE/si/87shXnODh5/DKOoVFltPR /Gvru892oGov4r/5pkw/WtU= X-Google-Smtp-Source: ABdhPJwnR90Cz57iKrYkodxmlfIvCfT7JGEav8hVx15wkJMDRSUmQ3XTZDBJW1rT1ya8VxBEODIv6g== X-Received: by 2002:a17:90a:8902:: with SMTP id u2mr48474902pjn.143.1620945494663; Thu, 13 May 2021 15:38:14 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:54a8:4531:57a:cfd8]) by smtp.gmail.com with ESMTPSA id j23sm2852582pfh.179.2021.05.13.15.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 15:38:14 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jaegeuk Kim , linux-scsi@vger.kernel.org, Bart Van Assche , Can Guo , Alim Akhtar , Avri Altman , Stanley Chu , Bean Huo , Adrian Hunter Subject: [PATCH v3 7/8] ufs: Fix the tracing code Date: Thu, 13 May 2021 15:37:56 -0700 Message-Id: <20210513223757.3938-8-bvanassche@acm.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513223757.3938-1-bvanassche@acm.org> References: <20210513223757.3938-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_get_sector() instead of scsi_get_lba() since the name of the latter is confusing. Use scsi_get_sector() for all SCSI requests since all SCSI requests have a block layer request attached and hence calling scsi_get_sector() is allowed. Convert the scsi_get_sector() result from sector_t into an LBA with sectors_to_logical(). Since READ(10), WRITE(10), READ(16) and WRITE(16) all have a GROUP NUMBER field, extract the GROUP NUMBER field for all four SCSI commands. Apply the 0x3f mask to that field since the upper two bits are reserved. Rename the 'transfer_len' variable into 'affected_bytes' since it represents the number of bytes affected on the storage medium instead of the size of the SCSI data buffer. Cc: Can Guo Cc: Alim Akhtar Cc: Avri Altman Cc: Stanley Chu Cc: Bean Huo Cc: Adrian Hunter Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/scsi/ufs/ufshcd.c | 34 +++++++++++++++------------------- include/trace/events/ufs.h | 10 +++++----- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ab707a2c3796..75310ac95b3d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include "../sd.h" #include "ufshcd.h" #include "ufs_quirks.h" #include "unipro.h" @@ -369,7 +371,7 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, u32 intr, doorbell; struct ufshcd_lrb *lrbp = &hba->lrb[tag]; struct scsi_cmnd *cmd = lrbp->cmd; - int transfer_len = -1; + int affected_bytes = -1; if (!trace_ufshcd_command_enabled()) { /* trace UPIU W/O tracing command */ @@ -381,30 +383,24 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, if (cmd) { /* data phase exists */ /* trace UPIU also */ ufshcd_add_cmd_upiu_trace(hba, tag, str_t); - opcode = cmd->cmnd[0]; - if ((opcode == READ_10) || (opcode == WRITE_10)) { - /* - * Currently we only fully trace read(10) and write(10) - * commands - */ - if (cmd->request && cmd->request->bio) - lba = cmd->request->bio->bi_iter.bi_sector; - transfer_len = be32_to_cpu( - lrbp->ucd_req_ptr->sc.exp_data_transfer_len); - if (opcode == WRITE_10) - group_id = lrbp->cmd->cmnd[6]; - } else if (opcode == UNMAP) { - if (cmd->request) { - lba = scsi_get_lba(cmd); - transfer_len = blk_rq_bytes(cmd->request); - } + lba = sectors_to_logical(cmd->device, scsi_get_sector(cmd)); + affected_bytes = blk_rq_bytes(cmd->request); + switch (cmd->cmnd[0]) { + case READ_10: + case WRITE_10: + group_id = lrbp->cmd->cmnd[6] & 0x3f; + break; + case READ_16: + case WRITE_16: + group_id = lrbp->cmd->cmnd[14] & 0x3f; + break; } } intr = ufshcd_readl(hba, REG_INTERRUPT_STATUS); doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); trace_ufshcd_command(dev_name(hba->dev), str_t, tag, - doorbell, transfer_len, intr, lba, opcode, group_id); + doorbell, affected_bytes, intr, lba, opcode, group_id); } static void ufshcd_print_clk_freqs(struct ufs_hba *hba) diff --git a/include/trace/events/ufs.h b/include/trace/events/ufs.h index 599739ee7b20..71055021de91 100644 --- a/include/trace/events/ufs.h +++ b/include/trace/events/ufs.h @@ -268,10 +268,10 @@ DEFINE_EVENT(ufshcd_template, ufshcd_wl_runtime_resume, TRACE_EVENT(ufshcd_command, TP_PROTO(const char *dev_name, enum ufs_trace_str_t str_t, - unsigned int tag, u32 doorbell, int transfer_len, u32 intr, + unsigned int tag, u32 doorbell, int affected_bytes, u32 intr, u64 lba, u8 opcode, u8 group_id), - TP_ARGS(dev_name, str_t, tag, doorbell, transfer_len, + TP_ARGS(dev_name, str_t, tag, doorbell, affected_bytes, intr, lba, opcode, group_id), TP_STRUCT__entry( @@ -279,7 +279,7 @@ TRACE_EVENT(ufshcd_command, __field(enum ufs_trace_str_t, str_t) __field(unsigned int, tag) __field(u32, doorbell) - __field(int, transfer_len) + __field(int, affected_bytes) __field(u32, intr) __field(u64, lba) __field(u8, opcode) @@ -291,7 +291,7 @@ TRACE_EVENT(ufshcd_command, __entry->str_t = str_t; __entry->tag = tag; __entry->doorbell = doorbell; - __entry->transfer_len = transfer_len; + __entry->affected_bytes = affected_bytes; __entry->intr = intr; __entry->lba = lba; __entry->opcode = opcode; @@ -301,7 +301,7 @@ TRACE_EVENT(ufshcd_command, TP_printk( "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x (%s), group_id: 0x%x", show_ufs_cmd_trace_str(__entry->str_t), __get_str(dev_name), - __entry->tag, __entry->doorbell, __entry->transfer_len, + __entry->tag, __entry->doorbell, __entry->affected_bytes, __entry->intr, __entry->lba, (u32)__entry->opcode, str_opcode(__entry->opcode), (u32)__entry->group_id )