From patchwork Mon Jun 29 22:54:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2205912 for ; Mon, 29 Jun 2020 22:55:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C46A820702 for ; Mon, 29 Jun 2020 22:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728409AbgF2WzI (ORCPT ); Mon, 29 Jun 2020 18:55:08 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:36212 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgF2WzH (ORCPT ); Mon, 29 Jun 2020 18:55:07 -0400 Received: by mail-pj1-f66.google.com with SMTP id h22so8649094pjf.1 for ; Mon, 29 Jun 2020 15:55:06 -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=2sO4M/I6KZtr0qUW3pRrWNvAvtKK9SHCZ3zIc16BBCk=; b=YbXLyPsc1qCylt+wx6SbHCqdD6YgoO3IgkuXzk4/KcrTT39eDtnr5Bae73vfhfmQse 7rO4qffY/8muH46is3vf4RlfWNyGi/RyYKKbTfOISL1HWz/WfindWDtCDXeXEaRYMrpD sippoY/M/1L2egIUM8U/F/ZC+QLpzAdNmORcNNer5ze0UEtymHT6le803m2nfj7HoB2w LfjQCy+hI7X6nScBxAGTL2Z4Fomxfptlta9iR0yJ9BC3mD+YobZNtCNVF9uBV9YHGVRd rLo16TzoLo4pr8mSWxnruF3oXq31oayTMkH9BUv/JUVXY7Tkf4qwo+iv5PdkW9+Wk6+h r00w== X-Gm-Message-State: AOAM531hqFdXkNn1oRPXDooWPU1iFBE5TqMcbajzv11gpywaL7FUNF56 naN8xnxvuNV64gU6kWlPRL90Tgh/pzw= X-Google-Smtp-Source: ABdhPJyt8LUwn9tEoJpwq4vKzZc4Y+bppMSq4DCh95VP8pukq8Ekd91gILIHFZpBAGeFPhRB8/i7tQ== X-Received: by 2002:a17:90b:fd3:: with SMTP id gd19mr20596322pjb.83.1593471306431; Mon, 29 Jun 2020 15:55:06 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 1/9] qla2xxx: Check the size of struct fcp_hdr at compile time Date: Mon, 29 Jun 2020 15:54:46 -0700 Message-Id: <20200629225454.22863-2-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since struct fcp_hdr is used to exchange data with the firmware, check its size at compile time. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 188aa5f02c01..f7e9b5bc0b26 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1971,6 +1971,7 @@ static int __init tcm_qla2xxx_init(void) BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64); BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64); BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64); + BUILD_BUG_ON(sizeof(struct fcp_hdr) != 24); BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24); BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64); From patchwork Mon Jun 29 22:54:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632783 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D49792A for ; Mon, 29 Jun 2020 22:55:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FCE420702 for ; Mon, 29 Jun 2020 22:55:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728468AbgF2WzJ (ORCPT ); Mon, 29 Jun 2020 18:55:09 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:39736 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgF2WzJ (ORCPT ); Mon, 29 Jun 2020 18:55:09 -0400 Received: by mail-pj1-f67.google.com with SMTP id b92so8643681pjc.4 for ; Mon, 29 Jun 2020 15:55:08 -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=4ilOEN7XUE2540HfcY3bba214XMb8Srj8q70FUW95sE=; b=tVn7HZnYDC2Zrfm4JZLdcyPYT8XIW5r5RbLm/502ls6KuDZIx1BbHk+adGPCg57oEb PuNuZINg/TUm4eOvi+foWtVKuZ5CnSAnqdORCD8OkUt33XdrtpKpVY6a3FwvAuADBXtS wD4R6IZsUmSLjckOgFva5eGae4wBEbhEdQ37jygO5jrd7ae9MmM9suflZ6geFKaHwEWm CVmGZiWVGEkdEMX72rl++ZqI+/76PQcC8MoomUfBCnNgxp4Fuzangi7UfdT+RWgvzhOv x702BSyai1obpLby2fn8krDGtVBO9CQ5wYXh5pAflzu/TcVcSIsoSzlJMUkzn2d7ehJA Vkpw== X-Gm-Message-State: AOAM532Zr0F8vZTreLyXw0UqJ6ZuHC7jDS7oNpsmG+bULr7mS7XDIrLh 637AdfVkQv7Ujf9ITkQSYoc= X-Google-Smtp-Source: ABdhPJwD4vMLjbyOSSwrKmcr+6PK/VQc+GtOcMX7qE/gkw+4jy0sSJFigszSPL4aHoEFSihdkYnYlg== X-Received: by 2002:a17:902:7896:: with SMTP id q22mr14799453pll.338.1593471308014; Mon, 29 Jun 2020 15:55:08 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:07 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 2/9] qla2xxx: Remove the __packed annotation from struct fcp_hdr and fcp_hdr_le Date: Mon, 29 Jun 2020 15:54:47 -0700 Message-Id: <20200629225454.22863-3-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove the __packed annotation from struct fcp_hdr* because that annotation is not necessary for these data structures. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 010f12523b2a..1cff7c69d448 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -258,7 +258,7 @@ struct fcp_hdr { __be16 ox_id; uint16_t rx_id; __le32 parameter; -} __packed; +}; struct fcp_hdr_le { le_id_t d_id; @@ -273,7 +273,7 @@ struct fcp_hdr_le { __le16 rx_id; __le16 ox_id; __le32 parameter; -} __packed; +}; #define F_CTL_EXCH_CONTEXT_RESP BIT_23 #define F_CTL_SEQ_CONTEXT_RESIP BIT_22 From patchwork Mon Jun 29 22:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632785 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 281B492A for ; Mon, 29 Jun 2020 22:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A6E420780 for ; Mon, 29 Jun 2020 22:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728493AbgF2WzL (ORCPT ); Mon, 29 Jun 2020 18:55:11 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35846 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgF2WzK (ORCPT ); Mon, 29 Jun 2020 18:55:10 -0400 Received: by mail-pl1-f194.google.com with SMTP id j4so7677227plk.3 for ; Mon, 29 Jun 2020 15:55:09 -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=HZ7cTZEpamxkssXb8i/G6iTr/lV89FSt/1GQloGQWP8=; b=kTgNIY+0+08Qk4A/11R6235fiB98CYt0aO4MkfGQwpkJajB/t3ZjslKJvWCfpsjDbG MZ65wdravZpNM5U5PuGL7RTfKxFnM8L9dhVnEBxqZkkiXt+aWoXmEYuNtScDH+tsk8Du z/uhQenHkABECFtNJciUbhpAvChJQI2jlBqISktJUtcHqxaEqDotlH9i2amXxRDAOyTM UidokMuptj1o2Dyp1xp9uCAOBGxruOlPaABjHs5TP0zPjroVl1wF7DbVi6l42NERvU3S UrWazmZYTs+y5z1zh9uAdY0uuNY16DQHHpWTtgiwCSvPVRJHEJ6tbFSprZqNpPQqHT2Q lMhA== X-Gm-Message-State: AOAM533d3w5xfZjTmM5CSk512jj9Sp2kB/9Yfy1P8AmUIxhxL3y4BJJS /N+WZj5w7D6WypLFf0jgB8E= X-Google-Smtp-Source: ABdhPJxyVp1sNRk9M+h+4gggPOTGcDEMbVZVQ2vIJTpe9bQgbkvJyypEbL/ZBD2PXPXDBFKMBqP2ZA== X-Received: by 2002:a17:90b:2350:: with SMTP id ms16mr11288250pjb.224.1593471309534; Mon, 29 Jun 2020 15:55:09 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:08 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 3/9] qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read Date: Mon, 29 Jun 2020 15:54:48 -0700 Message-Id: <20200629225454.22863-4-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Return early instead of having a single return statement at the end of this function. This patch fixes the following sparse warning: qla_nx.c:1018: qla82xx_flash_wait_write_finish() error: uninitialized symbol 'val'. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nx.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 0baf55b7e88f..ff365b434a02 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -966,26 +966,21 @@ qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val) static int qla82xx_flash_wait_write_finish(struct qla_hw_data *ha) { - long timeout = 0; - uint32_t done = 1 ; uint32_t val; - int ret = 0; + int i, ret; scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ABYTE_CNT, 0); - while ((done != 0) && (ret == 0)) { + for (i = 0; i < 50000; i++) { ret = qla82xx_read_status_reg(ha, &val); - done = val & 1; - timeout++; + if (ret < 0 || (val & 1) == 0) + return ret; udelay(10); cond_resched(); - if (timeout >= 50000) { - ql_log(ql_log_warn, vha, 0xb00d, - "Timeout reached waiting for write finish.\n"); - return -1; - } } - return ret; + ql_log(ql_log_warn, vha, 0xb00d, + "Timeout reached waiting for write finish.\n"); + return -1; } static int From patchwork Mon Jun 29 22:54:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD309912 for ; Mon, 29 Jun 2020 22:55:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD42B20702 for ; Mon, 29 Jun 2020 22:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728556AbgF2WzM (ORCPT ); Mon, 29 Jun 2020 18:55:12 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33819 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgF2WzM (ORCPT ); Mon, 29 Jun 2020 18:55:12 -0400 Received: by mail-pl1-f196.google.com with SMTP id o1so1102855plk.1 for ; Mon, 29 Jun 2020 15:55:11 -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=g9xVjHzCg0wskyJL6JySNkn8fsSLAlFJ7WsgYLGLYKs=; b=W5x9NLh9Jjpj6nuV7YwQFKdFAnTGpLhxnkHU0j+hk4tGtbL9X9rqJ02eXivLUarY0u MfjRXvcKky6yMRXkqyo6bieM46u5il3NF2rRdkhT18wzR6M2dPCtDYqIu1+NH7kSTpL/ Mipto1z3BayDQAe463ETB3GmJdUXe5ycoXcmZ3sxh4brPGnvpP2Nkt2aV/1Dybq4ImQp vaIScxatXivV387TpdZkYF3WRnTs3kDmaDT82aeKGRJ/28s0Q3pbsIwm5+GHFp6tcdDB 8NSGFaUE4ecgZDXyNZ2LpOMUoS73TGYtRt+RAnv3w7Q9guNVTWtOuhQoK3LbAZEvSKhr eT0A== X-Gm-Message-State: AOAM532/5suheJzZ/KemqkrcxaGWp1m8Gp7o8TUnBtauBq8I6Agx2MtE hYXFe98iElhSVtVdg87588s3BCeOPMY= X-Google-Smtp-Source: ABdhPJw54926qGuhEC1hmuKcUYyqXl+qVy/SK7uV/TjRhU0KTpRFQUJtvNXKzJxxb6mZ1BrNVnhAEQ== X-Received: by 2002:a17:902:7b89:: with SMTP id w9mr3658339pll.175.1593471311072; Mon, 29 Jun 2020 15:55:11 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:10 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Shyam Sundar , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 4/9] qla2xxx: Initialize 'n' before using it Date: Mon, 29 Jun 2020 15:54:49 -0700 Message-Id: <20200629225454.22863-5-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The following code: qla82xx_rom_fast_read(ha, 0, &n) only initializes 'n' if it succeeds. Since 'n' may be reported in a debug message even if no ROM reads succeeded, initialize 'n' to zero. This patch fixes the following sparse warning: qla_nx.c:1218: qla82xx_pinit_from_rom() error: uninitialized symbol 'n'. Reviewed-by: Daniel Wagner Reviewed-by: Shyam Sundar Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index ff365b434a02..71273eb634d3 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -1167,6 +1167,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) * Offset 4: Offset and number of addr/value pairs * that present in CRB initialize sequence */ + n = 0; if (qla82xx_rom_fast_read(ha, 0, &n) != 0 || n != 0xcafecafeUL || qla82xx_rom_fast_read(ha, 4, &n) != 0) { ql_log(ql_log_fatal, vha, 0x006e, From patchwork Mon Jun 29 22:54:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 727DC92A for ; Mon, 29 Jun 2020 22:55:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C06620786 for ; Mon, 29 Jun 2020 22:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbgF2WzO (ORCPT ); Mon, 29 Jun 2020 18:55:14 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:33496 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzN (ORCPT ); Mon, 29 Jun 2020 18:55:13 -0400 Received: by mail-pj1-f68.google.com with SMTP id gc15so1258288pjb.0 for ; Mon, 29 Jun 2020 15:55: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=JJfxNrKKcLvoNDjxOhPtlO9Z+XbDfNF+OP1B6dUZvjE=; b=AUJVF1pINgJObGhGU3h2n54SjI2IN+Z1FGBWa+rXMcNVt04HE/DZvCdwk/+FX7Kmwu RSAVJXtrkUOQG6eAVdJTisn0yxYdII1QIVY5XYXG3fcrZKvBOUFX92lr57ah9AHNFBID hbxRg6RyNDz1ZLImiQYUsh+NZOV+qJfcu9p7a4CNVpdkvV+/+XRsquhqov8HKLP7icNz fatlEJHxX+bbO0KSZAf7ad+o1qscdpP4Hn0Rhagw8NjgA3rlbBrzIvL3klVKtVqccdk7 OCzRDgQt/IZO829iaNxP1TCZYs/uQVtfykeJA/Pot8kcoBwgzEoiCjZYYIotxcZZMfzp 2aVA== X-Gm-Message-State: AOAM530WezIUkXMBl1ETrbJpCvdoy/4bBqp7lglGW/v3VWIpzSPGtcz1 Ncedl7Kzg3M3mwiqsEx6nbPLPU8ohlM= X-Google-Smtp-Source: ABdhPJxXz6QQbMaZxz2VXwWshOd+Ka5zriFWu+z6lAGTZLhmVr+jDnOTZ0ySpkiDNdQxGeqkWTFsmQ== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr14495971plb.250.1593471312710; Mon, 29 Jun 2020 15:55:12 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:11 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 5/9] qla2xxx: Remove a superfluous cast Date: Mon, 29 Jun 2020 15:54:50 -0700 Message-Id: <20200629225454.22863-6-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove an unnecessary cast because it prevents the compiler to perform type checking. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche Reviewed-by: Shyam Sundar --- drivers/scsi/qla2xxx/qla_bsg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 88c0338a2ec7..67efde1d4b8e 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -223,8 +223,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job) /* validate fcp priority data */ - if (!qla24xx_fcp_prio_cfg_valid(vha, - (struct qla_fcp_prio_cfg *) ha->fcp_prio_cfg, 1)) { + if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1)) { bsg_reply->result = (DID_ERROR << 16); ret = -EINVAL; /* If buffer was invalidatic int From patchwork Mon Jun 29 22:54:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0F7B912 for ; Mon, 29 Jun 2020 22:55:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB4CB2063A for ; Mon, 29 Jun 2020 22:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728585AbgF2WzP (ORCPT ); Mon, 29 Jun 2020 18:55:15 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:35457 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzP (ORCPT ); Mon, 29 Jun 2020 18:55:15 -0400 Received: by mail-pj1-f66.google.com with SMTP id i4so8652411pjd.0 for ; Mon, 29 Jun 2020 15:55:14 -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=Wozg3uqgdUM3vwrgu+WARaaqs5hSy4N1wL+Q7LcUj2g=; b=s9UJNnOQope6bz6LgpOGz5HoXAXypwluMjN20bBmHPgirGw7HTuK+oQ2STKwo4Sq4e t7c7Ulz8KnjJzIsylQ7NEaMulm7RxtcjEaGINzOww5mzBQKgv2i8RhEBlJ9v8XmPEpr+ Em4weqRjPe0zmAR3gIfwjxQ2XknQ8v8XoWGWjRBC4iSkObIV84I+872W2R8a4zWy5Lrx 48zInbMTyDshnUFexRQIYIVFxBFA0vX92y+1zVStHsJ8R9jXQmUZvhkIZVGkoAt8d+7Z xhsCgXiefGFW5b3+//vd5M/UorZpGrNlC+eocmik3btnsO+9rEc/irnRZur4EWNmx3TK cecw== X-Gm-Message-State: AOAM531kf0whdQskulbMcAMHZAvqKztP6PMUkbetjMmSItIf2STAJjpy 18TBqjOBGvxB6LF5ONF0PV0= X-Google-Smtp-Source: ABdhPJznyBSJ0GRZ9Nh8Mjfbo0H2ASp92iMR/NuBYXEI9A/z018LyB7q8XekWPQsYWEIRHFqVHlQ1A== X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr10027973plp.312.1593471314264; Mon, 29 Jun 2020 15:55:14 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:13 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 6/9] qla2xxx: Make __qla2x00_alloc_iocbs() initialize 32 bits of request_t.handle Date: Mon, 29 Jun 2020 15:54:51 -0700 Message-Id: <20200629225454.22863-7-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The request_t 'handle' member is 32-bits wide, hence use wrt_reg_dword(). Change the cast in the wrt_reg_byte() call to make it clear that a regular pointer is casted to an __iomem pointer. Note: 'pkt' points to I/O memory for the qlafx00 adapter family and to coherent memory for all other adapter families. This patch fixes the following Coverity complaint: CID 358864 (#1 of 1): Reliance on integer endianness (INCOMPATIBLE_CAST) incompatible_cast: Pointer &pkt->handle points to an object whose effective type is unsigned int (32 bits, unsigned) but is dereferenced as a narrower unsigned short (16 bits, unsigned). This may lead to unexpected results depending on machine endianness. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Fixes: 8ae6d9c7eb10 ("[SCSI] qla2xxx: Enhancements to support ISPFx00.") Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_iocb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 1d3c58c5f0e2..e3d2dea0b057 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2305,8 +2305,8 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp) pkt = req->ring_ptr; memset(pkt, 0, REQUEST_ENTRY_SIZE); if (IS_QLAFX00(ha)) { - wrt_reg_byte((void __iomem *)&pkt->entry_count, req_cnt); - wrt_reg_word((void __iomem *)&pkt->handle, handle); + wrt_reg_byte((u8 __force __iomem *)&pkt->entry_count, req_cnt); + wrt_reg_dword((__le32 __force __iomem *)&pkt->handle, handle); } else { pkt->entry_count = req_cnt; pkt->handle = handle; From patchwork Mon Jun 29 22:54:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 707A9912 for ; Mon, 29 Jun 2020 22:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 630DB2067D for ; Mon, 29 Jun 2020 22:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728614AbgF2WzR (ORCPT ); Mon, 29 Jun 2020 18:55:17 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40591 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzR (ORCPT ); Mon, 29 Jun 2020 18:55:17 -0400 Received: by mail-pf1-f196.google.com with SMTP id u5so8534658pfn.7 for ; Mon, 29 Jun 2020 15:55:16 -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=7xa6NFI+S11VWHfwvQSsdqPE2V3UYkuUqqGGNmptq44=; b=iXUXw0nv8+OO7DAFfEaREMsZfWewGWOdQXGNL8+v/EAk45WPQM3wILzvIRuBR1S7UR BJ1k18jewWRUJoI0rIGREjXoe+qHuqQ924G+/8JxK1FPf2cKByfQRYrzqgMJdF87Y4im wl5wlje8RtJeKMn9eYJP7BNU7RWkyTUIiPJhICy3jSNaxTFpMMheujcwLr8WWYTFS2ZT YAEW6O0zzgaDoGWLcJvLvpTADwxJfvE3trfii9O9XmmUOsnLrSYRHMhwiPG9WQiyR5f3 v3MLhUTBzsHVgRojCv/sSyvdwO5Qb0m0JmGWGi/LQu7tE2NNemx7cBxBGvK5rgGKBtcY j7kw== X-Gm-Message-State: AOAM531uBoWSfPaSwZZ83S+y3H7ttIyusJQwJCreWqAJhOFYJw5HYDTd xhFznc9g5AjCodt+ZjuSJUCwaGXyCDg= X-Google-Smtp-Source: ABdhPJzivQbT7mYtD71pZidu4L8m252lttzTO8nY97j0s44ZnhqmHFrtWIFZh4wGf1Ow2fTOaScFAg== X-Received: by 2002:a62:2743:: with SMTP id n64mr15950295pfn.163.1593471315831; Mon, 29 Jun 2020 15:55:15 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 7/9] qla2xxx: Fix a Coverity complaint in qla2100_fw_dump() Date: Mon, 29 Jun 2020 15:54:52 -0700 Message-Id: <20200629225454.22863-8-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 'cnt' can exceed the size of the risc_ram[] array. Prevent that Coverity complains by rewriting an address calculation expression. This patch fixes the following Coverity complaint: CID 337803 (#1 of 1): Out-of-bounds read (OVERRUN) 109. overrun-local: Overrunning array of 122880 bytes at byte offset 122880 by dereferencing pointer &fw->risc_ram[cnt]. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_dbg.c | 2 +- drivers/scsi/qla2xxx/qla_dbg.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 19005710f7f6..41493bd53fc0 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1063,7 +1063,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha) } if (rval == QLA_SUCCESS) - qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]); + qla2xxx_copy_queues(ha, &fw->queue_dump[0]); qla2xxx_dump_post_process(base_vha, rval); } diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h index 54ed020e6f75..91eb6901815c 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.h +++ b/drivers/scsi/qla2xxx/qla_dbg.h @@ -53,6 +53,7 @@ struct qla2100_fw_dump { __be16 fpm_b0_reg[64]; __be16 fpm_b1_reg[64]; __be16 risc_ram[0xf000]; + u8 queue_dump[]; }; struct qla24xx_fw_dump { From patchwork Mon Jun 29 22:54:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE150912 for ; Mon, 29 Jun 2020 22:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF4842067D for ; Mon, 29 Jun 2020 22:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728628AbgF2WzS (ORCPT ); Mon, 29 Jun 2020 18:55:18 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35854 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzS (ORCPT ); Mon, 29 Jun 2020 18:55:18 -0400 Received: by mail-pl1-f196.google.com with SMTP id j4so7677360plk.3 for ; Mon, 29 Jun 2020 15:55:17 -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=c4qWr2leQEMpUXEVFjPfdW12G03OefomdvgWKeskTnI=; b=i28hM9IOhmjXWFrn+XKLODT7c+H8sqoG5+yDfO9tVPX52inyjgl1pPt3iKPtNIQFyF I8DbsFWv6K1x5YnH6udO/HR9uF28uelvh3YShKlPsGxieKvfI5p4DXq9u7X8BoOcL94c i+sriiUlbbC3Kf0ha6sItCL2EjfAUxJS5ypmucdnAdyEbGc7u28zsMLuSQYM1VFQWqTT Ojv5yh5lu4wfCP6TpBzwXUcJckKuXFJSGfcq9SC84WcHAb5gMEG0pEvLQssa5qPZQ3Cy Waw+5XZFtEStzxhDCpxyMoOtRGlUATEeeHlAJhWop9UM8ryd9xC+mmVejpoHxMJroHhN +hww== X-Gm-Message-State: AOAM53022BqzfeGy5bTp/3bzHwShW//KZCRL7TGzmmk27IPCEqZ0jUT0 XIW+XtLPPqudeCn5JUw5kHc= X-Google-Smtp-Source: ABdhPJzfnXHIApUxnEgvl16qYX5ucRlWfiwZ4U2ymLrFhzNQWjP42/x0oT1Nf7yDQTEz2Q09x4CvQg== X-Received: by 2002:a17:90b:801:: with SMTP id bk1mr20363180pjb.2.1593471317392; Mon, 29 Jun 2020 15:55:17 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:16 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 8/9] qla2xxx: Make qla2x00_restart_isp() easier to read Date: Mon, 29 Jun 2020 15:54:53 -0700 Message-Id: <20200629225454.22863-9-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of using complicated control flow to only have one return statement at the end of qla2x00_restart_isp(), return an error status as soon as it is known that this function will fail. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_init.c | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index d2717e7cf22a..8c739abf5589 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -6996,36 +6996,41 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) static int qla2x00_restart_isp(scsi_qla_host_t *vha) { - int status = 0; + int status; struct qla_hw_data *ha = vha->hw; /* If firmware needs to be loaded */ if (qla2x00_isp_firmware(vha)) { vha->flags.online = 0; status = ha->isp_ops->chip_diag(vha); - if (!status) - status = qla2x00_setup_chip(vha); + if (status) + return status; + status = qla2x00_setup_chip(vha); + if (status) + return status; } - if (!status && !(status = qla2x00_init_rings(vha))) { - clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); - ha->flags.chip_reset_done = 1; + status = qla2x00_init_rings(vha); + if (status) + return status; - /* Initialize the queues in use */ - qla25xx_init_queues(ha); + clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); + ha->flags.chip_reset_done = 1; - status = qla2x00_fw_ready(vha); - if (!status) { - /* Issue a marker after FW becomes ready. */ - qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); - set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); - } + /* Initialize the queues in use */ + qla25xx_init_queues(ha); + status = qla2x00_fw_ready(vha); + if (status) { /* if no cable then assume it's good */ - if ((vha->device_flags & DFLG_NO_CABLE)) - status = 0; + return vha->device_flags & DFLG_NO_CABLE ? 0 : status; } - return (status); + + /* Issue a marker after FW becomes ready. */ + qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); + + return 0; } static int From patchwork Mon Jun 29 22:54:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11632797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 109B792A for ; Mon, 29 Jun 2020 22:55:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDA282067D for ; Mon, 29 Jun 2020 22:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728638AbgF2WzU (ORCPT ); Mon, 29 Jun 2020 18:55:20 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44605 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzU (ORCPT ); Mon, 29 Jun 2020 18:55:20 -0400 Received: by mail-pg1-f193.google.com with SMTP id j19so2132927pgm.11 for ; Mon, 29 Jun 2020 15:55:19 -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=sXoyxTA9nquAbHQWx0ETGGYQKA6A8CSQCoKl/HAnywk=; b=m4R4uttvm0sGG1N6kX908vRGH3JHgV4oqYCPk6vNtI7EfLs5Ayyi5AewQw5LCi2Nlu JgzSKc3sTNGZAavSPnaHT+zyR4jxnCNUB7Osvfhk85ia7me8Txsk6CXssX+jBLIir/S+ tlgHbqcwe4KhB4RNBzNb4oGyvUR3ZEy7k+PlzbSYML5vDU5QZNigxw8qJv7yevGAqWWF JQDG+2OhUlp0BYNm9p2db/N0jJcFnpo0+G1vvXH0DJUY5Fh5ZKgtIbUF+tQECvbwoPwm /8SbENFDe9Nr3JWFdjCnF+0dg+WwzAFvnoIUcEVE8avRAcxbdIouBGNWnGsvYprPElDS TXtA== X-Gm-Message-State: AOAM531Cz0GvWz3/Of58V3kzgYyJLtWWiGsOTChcLRQFWba8ml9NTyOQ mqDJAczFdZjUUZCXlxZ+ZWg= X-Google-Smtp-Source: ABdhPJzADcnlSqb2xN2XfLnqnNlGfkPPccToj/tAxEABpJfb7IVKSbsYoK0ksHubcf7jWgmF1pMNyg== X-Received: by 2002:a05:6a00:15ca:: with SMTP id o10mr16531571pfu.169.1593471318930; Mon, 29 Jun 2020 15:55:18 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:18 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 9/9] qla2xxx: Introduce a function for computing the debug message prefix Date: Mon, 29 Jun 2020 15:54:54 -0700 Message-Id: <20200629225454.22863-10-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of repeating the code for generating a debug message prefix six times, introduce a function for computing the debug message prefix. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_dbg.c | 96 ++++++++++++---------------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 41493bd53fc0..911c7852e660 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -2447,6 +2447,23 @@ qla83xx_fw_dump(scsi_qla_host_t *vha) /* Driver Debug Functions. */ /****************************************************************************/ +/* Write the debug message prefix into @pbuf. */ +static void ql_dbg_prefix(char *pbuf, int pbuf_size, + const scsi_qla_host_t *vha, uint msg_id) +{ + if (vha) { + const struct pci_dev *pdev = vha->hw->pdev; + + /* []-:: */ + snprintf(pbuf, pbuf_size, "%s [%s]-%04x:%ld: ", QL_MSGHDR, + dev_name(&(pdev->dev)), msg_id, vha->host_no); + } else { + /* []-: : */ + snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR, + "0000:00:00.0", msg_id); + } +} + /* * This function is for formatting and logging debug information. * It is to be used when vha is available. It formats the message @@ -2465,41 +2482,19 @@ ql_dbg(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...) { va_list va; struct va_format vaf; + char pbuf[64]; va_start(va, fmt); vaf.fmt = fmt; vaf.va = &va; - if (!ql_mask_match(level)) { - char pbuf[64]; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id, - vha->host_no); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + if (!ql_mask_match(level)) trace_ql_dbg_log(pbuf, &vaf); - va_end(va); - return; - } - - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - pr_warn("%s [%s]-%04x:%ld: %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, - vha->host_no, &vaf); - } else { - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf); - } + else + pr_warn("%s%pV", pbuf, &vaf); va_end(va); @@ -2524,6 +2519,7 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) { va_list va; struct va_format vaf; + char pbuf[128]; if (pdev == NULL) return; @@ -2535,9 +2531,8 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &va; - /* : Message */ - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf); + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id + ql_dbg_offset); + pr_warn("%s%pV", pbuf, &vaf); va_end(va); } @@ -2565,16 +2560,7 @@ ql_log(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...) if (level > ql_errlev) return; - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); va_start(va, fmt); @@ -2625,10 +2611,7 @@ ql_log_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) if (level > ql_errlev) return; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, dev_name(&(pdev->dev)), id); - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id); va_start(va, fmt); @@ -2724,16 +2707,7 @@ ql_log_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, if (level > ql_errlev) return; - if (qpair != NULL) { - const struct pci_dev *pdev = qpair->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, id); va_start(va, fmt); @@ -2777,6 +2751,7 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, { va_list va; struct va_format vaf; + char pbuf[128]; if (!ql_mask_match(level)) return; @@ -2786,16 +2761,9 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, vaf.fmt = fmt; vaf.va = &va; - if (qpair != NULL) { - const struct pci_dev *pdev = qpair->pdev; - /* : Message */ - pr_warn("%s [%s]-%04x: %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, - &vaf); - } else { - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf); - } + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, + id + ql_dbg_offset); + pr_warn("%s%pV", pbuf, &vaf); va_end(va);