From patchwork Tue Apr 27 08:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225533 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 0E246C433ED for ; Tue, 27 Apr 2021 08:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9260600D4 for ; Tue, 27 Apr 2021 08:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235106AbhD0Ibu (ORCPT ); Tue, 27 Apr 2021 04:31:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:49134 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235058AbhD0Ibt (ORCPT ); Tue, 27 Apr 2021 04:31:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 109C2B00E; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 01/40] st: return error code in st_scsi_execute() Date: Tue, 27 Apr 2021 10:30:07 +0200 Message-Id: <20210427083046.31620-2-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The callers to st_scsi_execute already check for negative return values, so we can drop the use of DRIVER_ERROR and return the actual error code. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Acked-by: Kai Mäkisara --- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 9ca536aae784..23be6447e576 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -551,7 +551,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, data_direction == DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); if (IS_ERR(req)) - return DRIVER_ERROR << 24; + return PTR_ERR(req); rq = scsi_req(req); req->rq_flags |= RQF_QUIET; @@ -562,7 +562,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, GFP_KERNEL); if (err) { blk_put_request(req); - return DRIVER_ERROR << 24; + return err; } } From patchwork Tue Apr 27 08:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225537 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 0BA82C43460 for ; Tue, 27 Apr 2021 08:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9BEF600D4 for ; Tue, 27 Apr 2021 08:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235150AbhD0Ibw (ORCPT ); Tue, 27 Apr 2021 04:31:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:49174 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235096AbhD0Ibt (ORCPT ); Tue, 27 Apr 2021 04:31:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 16ED8B016; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 02/40] scsi_ioctl: return error code when blk_rq_map_kern() fails Date: Tue, 27 Apr 2021 10:30:08 +0200 Message-Id: <20210427083046.31620-3-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The callers of sg_scsi_ioctl() already check for negative return values, so we can drop the usage of DRIVER_ERROR and return the error from blk_rq_map_kern() instead. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- block/scsi_ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 6599bac0a78c..99d58786e0d5 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -488,9 +488,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, break; } - if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO)) { - err = DRIVER_ERROR << 24; - goto error; + if (bytes) { + err = blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO); + if (err) + goto error; } blk_execute_rq(disk, rq, 0); From patchwork Tue Apr 27 08:30:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225539 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 80D33C43462 for ; Tue, 27 Apr 2021 08:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D5CF600D4 for ; Tue, 27 Apr 2021 08:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235155AbhD0Ibx (ORCPT ); Tue, 27 Apr 2021 04:31:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:49142 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbhD0Ibt (ORCPT ); Tue, 27 Apr 2021 04:31:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 19C7EB019; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 03/40] scsi: Fixup calling convention for scsi_mode_sense() Date: Tue, 27 Apr 2021 10:30:09 +0200 Message-Id: <20210427083046.31620-4-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The description for scsi_mode_sense() claims to return the number of valid bytes on success, which is not what the code does. Additionally there is no gain in returning the scsi status, as everything the callers do is to check against scsi_result_is_good(), which is what scsi_mode_sense() does already. So change the calling convention to return a standard error code on failure, and 0 on success, and adapt the description and all callers. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_lib.c | 10 ++++++---- drivers/scsi/scsi_transport_sas.c | 9 ++++----- drivers/scsi/sd.c | 12 ++++++------ drivers/scsi/sr.c | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d7c0d5a5f263..ca9dbfa42cb7 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2135,9 +2135,7 @@ EXPORT_SYMBOL_GPL(scsi_mode_select); * @sshdr: place to put sense data (or NULL if no sense to be collected). * must be SCSI_SENSE_BUFFERSIZE big. * - * Returns zero if unsuccessful, or the header offset (either 4 - * or 8 depending on whether a six or ten byte command was - * issued) if successful. + * Returns zero if successful, or a negative error number on failure */ int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, @@ -2184,6 +2182,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, sshdr, timeout, retries, NULL); + if (result < 0) + return result; /* This code looks awful: what it's doing is making sure an * ILLEGAL REQUEST sense return identifies the actual command @@ -2228,13 +2228,15 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, data->block_descriptor_length = buffer[3]; } data->header_length = header_length; + result = 0; } else if ((status_byte(result) == CHECK_CONDITION) && scsi_sense_valid(sshdr) && sshdr->sense_key == UNIT_ATTENTION && retry_count) { retry_count--; goto retry; } - + if (result > 0) + result = -EIO; return result; } EXPORT_SYMBOL(scsi_mode_sense); diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index c9abed8429c9..4a96fb05731d 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -1229,16 +1229,15 @@ int sas_read_port_mode_page(struct scsi_device *sdev) char *buffer = kzalloc(BUF_SIZE, GFP_KERNEL), *msdata; struct sas_end_device *rdev = sas_sdev_to_rdev(sdev); struct scsi_mode_data mode_data; - int res, error; + int error; if (!buffer) return -ENOMEM; - res = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3, - &mode_data, NULL); + error = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3, + &mode_data, NULL); - error = -EINVAL; - if (!scsi_status_is_good(res)) + if (error) goto out; msdata = buffer + mode_data.header_length + diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index cb3c37d1e009..2ef2954375f4 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2670,18 +2670,18 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) * 5: Illegal Request, Sense Code 24: Invalid field in * CDB. */ - if (!scsi_status_is_good(res)) + if (res < 0) res = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL); /* * Third attempt: ask 255 bytes, as we did earlier. */ - if (!scsi_status_is_good(res)) + if (res < 0) res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255, &data, NULL); } - if (!scsi_status_is_good(res)) { + if (res < 0) { sd_first_printk(KERN_WARNING, sdkp, "Test WP failed, assume Write Enabled\n"); } else { @@ -2742,7 +2742,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len, &data, &sshdr); - if (!scsi_status_is_good(res)) + if (res < 0) goto bad_sense; if (!data.header_length) { @@ -2774,7 +2774,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len, &data, &sshdr); - if (scsi_status_is_good(res)) { + if (!res) { int offset = data.header_length + data.block_descriptor_length; while (offset < len) { @@ -2892,7 +2892,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT, sdkp->max_retries, &data, &sshdr); - if (!scsi_status_is_good(res) || !data.header_length || + if (res < 0 || !data.header_length || data.length < 6) { sd_first_printk(KERN_WARNING, sdkp, "getting Control mode page failed, assume no ATO\n"); diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index e4633b84c556..9b2ccf0c9a8c 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -911,7 +911,7 @@ static void get_capabilities(struct scsi_cd *cd) rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len, SR_TIMEOUT, 3, &data, NULL); - if (!scsi_status_is_good(rc) || data.length > ms_len || + if (rc < 0 || data.length > ms_len || data.header_length + data.block_descriptor_length > data.length) { /* failed, drive doesn't have capabilities mode page */ cd->cdi.speed = 1; From patchwork Tue Apr 27 08:30:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225541 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 AFBAAC433ED for ; Tue, 27 Apr 2021 08:31:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B5A46100B for ; Tue, 27 Apr 2021 08:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235160AbhD0Ibx (ORCPT ); Tue, 27 Apr 2021 04:31:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:49170 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235088AbhD0Ibt (ORCPT ); Tue, 27 Apr 2021 04:31:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1622BB011; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 04/40] scsi: reshuffle response handling in scsi_mode_sense() Date: Tue, 27 Apr 2021 10:30:10 +0200 Message-Id: <20210427083046.31620-5-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Reshuffle response handling in scsi_mode_sense() to make the code easier to follow. Suggested-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 75 ++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ca9dbfa42cb7..ba54b1ba5edb 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2190,54 +2190,53 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, * byte as the problem. MODE_SENSE commands can return * ILLEGAL REQUEST if the code page isn't supported */ - if (use_10_for_ms && !scsi_status_is_good(result) && - driver_byte(result) == DRIVER_SENSE) { - if (scsi_sense_valid(sshdr)) { + if (!scsi_status_is_good(result)) { + if (driver_byte(result) == DRIVER_SENSE && + scsi_sense_valid(sshdr)) { if ((sshdr->sense_key == ILLEGAL_REQUEST) && (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { /* * Invalid command operation code */ - sdev->use_10_for_ms = 0; + if (use_10_for_ms) { + sdev->use_10_for_ms = 0; + goto retry; + } + } + if ((status_byte(result) == CHECK_CONDITION) && + sshdr->sense_key == UNIT_ATTENTION && + retry_count) { + retry_count--; goto retry; } } + return -EIO; + } + if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b && + (modepage == 6 || modepage == 8))) { + /* Initio breakage? */ + header_length = 0; + data->length = 13; + data->medium_type = 0; + data->device_specific = 0; + data->longlba = 0; + data->block_descriptor_length = 0; + } else if (use_10_for_ms) { + data->length = buffer[0]*256 + buffer[1] + 2; + data->medium_type = buffer[2]; + data->device_specific = buffer[3]; + data->longlba = buffer[4] & 0x01; + data->block_descriptor_length = buffer[6]*256 + + buffer[7]; + } else { + data->length = buffer[0] + 1; + data->medium_type = buffer[1]; + data->device_specific = buffer[2]; + data->block_descriptor_length = buffer[3]; } + data->header_length = header_length; - if (scsi_status_is_good(result)) { - if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b && - (modepage == 6 || modepage == 8))) { - /* Initio breakage? */ - header_length = 0; - data->length = 13; - data->medium_type = 0; - data->device_specific = 0; - data->longlba = 0; - data->block_descriptor_length = 0; - } else if (use_10_for_ms) { - data->length = buffer[0]*256 + buffer[1] + 2; - data->medium_type = buffer[2]; - data->device_specific = buffer[3]; - data->longlba = buffer[4] & 0x01; - data->block_descriptor_length = buffer[6]*256 - + buffer[7]; - } else { - data->length = buffer[0] + 1; - data->medium_type = buffer[1]; - data->device_specific = buffer[2]; - data->block_descriptor_length = buffer[3]; - } - data->header_length = header_length; - result = 0; - } else if ((status_byte(result) == CHECK_CONDITION) && - scsi_sense_valid(sshdr) && - sshdr->sense_key == UNIT_ATTENTION && retry_count) { - retry_count--; - goto retry; - } - if (result > 0) - result = -EIO; - return result; + return 0; } EXPORT_SYMBOL(scsi_mode_sense); From patchwork Tue Apr 27 08:30:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225543 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 36E87C43460 for ; Tue, 27 Apr 2021 08:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E40F86113D for ; Tue, 27 Apr 2021 08:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235165AbhD0Ib4 (ORCPT ); Tue, 27 Apr 2021 04:31:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:49412 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235110AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3B464B01D; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 05/40] scsi_dh_alua: check for negative result value Date: Tue, 27 Apr 2021 10:30:11 +0200 Message-Id: <20210427083046.31620-6-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org scsi_execute will now return a negative error if there was an error prior to command submission; evaluate that instead if checking for DRIVER_ERROR. Signed-off-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_alua.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index efa8c0381476..0764ea647c6c 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -562,12 +562,12 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) kfree(buff); return SCSI_DH_OK; } - if (!scsi_sense_valid(&sense_hdr)) { + if (result < 0 || !scsi_sense_valid(&sense_hdr)) { sdev_printk(KERN_INFO, sdev, "%s: rtpg failed, result %d\n", ALUA_DH_NAME, retval); kfree(buff); - if (driver_byte(retval) == DRIVER_ERROR) + if (result < 0) return SCSI_DH_DEV_TEMP_BUSY; return SCSI_DH_IO; } @@ -791,11 +791,11 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg) retval = submit_stpg(sdev, pg->group_id, &sense_hdr); if (retval) { - if (!scsi_sense_valid(&sense_hdr)) { + if (retval < 0 || !scsi_sense_valid(&sense_hdr)) { sdev_printk(KERN_INFO, sdev, "%s: stpg failed, result %d", ALUA_DH_NAME, retval); - if (driver_byte(retval) == DRIVER_ERROR) + if (retval < 0) return SCSI_DH_DEV_TEMP_BUSY; } else { sdev_printk(KERN_INFO, sdev, "%s: stpg failed\n", From patchwork Tue Apr 27 08:30:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225549 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 D16EBC433B4 for ; Tue, 27 Apr 2021 08:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93C8A613B4 for ; Tue, 27 Apr 2021 08:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235175AbhD0IcA (ORCPT ); Tue, 27 Apr 2021 04:32:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:49410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235108AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 38AFAB01C; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 06/40] scsi: stop using DRIVER_ERROR Date: Tue, 27 Apr 2021 10:30:12 +0200 Message-Id: <20210427083046.31620-7-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Return the actual error code in __scsi_execute() (which, according to the documentation, should have happened anyway). And audit all callers to cope with negative return values from __scsi_execute() and friends. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- drivers/ata/libata-scsi.c | 8 ++++++++ drivers/scsi/ch.c | 3 ++- drivers/scsi/cxlflash/superpipe.c | 2 +- drivers/scsi/scsi.c | 2 ++ drivers/scsi/scsi_ioctl.c | 4 +++- drivers/scsi/scsi_lib.c | 15 +++++++++------ drivers/scsi/scsi_scan.c | 4 ++-- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 15 +++++++++------ drivers/scsi/sd_zbc.c | 2 +- drivers/scsi/sr_ioctl.c | 4 ++++ drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- include/scsi/scsi.h | 3 +++ 14 files changed, 47 insertions(+), 21 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 48b8934970f3..c5129b9e3afd 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -409,6 +409,10 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize, sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); + if (cmd_result < 0) { + rc = cmd_result; + goto error; + } if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ u8 *desc = sensebuf + 8; cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ @@ -490,6 +494,10 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0, sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); + if (cmd_result < 0) { + rc = cmd_result; + goto error; + } if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ u8 *desc = sensebuf + 8; cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index cb74ab1ae5a4..0e7d1214c3d8 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -198,7 +198,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, result = scsi_execute_req(ch->device, cmd, direction, buffer, buflength, &sshdr, timeout * HZ, MAX_RETRIES, NULL); - + if (result < 0) + return result; if (driver_byte(result) == DRIVER_SENSE) { if (debug) scsi_print_sense_hdr(ch->device, ch->name, &sshdr); diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index ee11ec340654..caa7c5fd233d 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -369,7 +369,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) goto out; } - if (driver_byte(result) == DRIVER_SENSE) { + if (result > 0 && driver_byte(result) == DRIVER_SENSE) { result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ if (result & SAM_STAT_CHECK_CONDITION) { switch (sshdr.sense_key) { diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index e9e2f0e15ac8..99dc6ec0b6e5 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -508,6 +508,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, &sshdr, 30 * HZ, 3, NULL); + if (result < 0) + return result; if (result && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 14872c9dc78c..d34e1b41dc71 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -101,6 +101,8 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, "Ioctl returned 0x%x\n", result)); + if (result < 0) + goto out; if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) { switch (sshdr.sense_key) { @@ -133,7 +135,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, break; } } - +out: SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, "IOCTL Releasing command\n")); return result; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ba54b1ba5edb..cd316e935281 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -245,20 +245,23 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, { struct request *req; struct scsi_request *rq; - int ret = DRIVER_ERROR << 24; + int ret; req = blk_get_request(sdev->request_queue, data_direction == DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); if (IS_ERR(req)) - return ret; - rq = scsi_req(req); + return PTR_ERR(req); - if (bufflen && blk_rq_map_kern(sdev->request_queue, req, - buffer, bufflen, GFP_NOIO)) - goto out; + rq = scsi_req(req); + if (bufflen) { + ret = blk_rq_map_kern(sdev->request_queue, req, + buffer, bufflen, GFP_NOIO); + if (ret) + goto out; + } rq->cmd_len = COMMAND_SIZE(cmd[0]); memcpy(rq->cmd, cmd, rq->cmd_len); rq->retries = retries; diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 9f1b7f3c650a..493f17bf26f2 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -616,7 +616,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, "scsi scan: INQUIRY %s with code 0x%x\n", result ? "failed" : "successful", result)); - if (result) { + if (result > 0) { /* * not-ready to ready transition [asc/ascq=0x28/0x0] * or power-on, reset [asc/ascq=0x29/0x0], continue. @@ -631,7 +631,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, (sshdr.ascq == 0)) continue; } - } else { + } else if (result == 0) { /* * if nothing was transferred, we try * again. It's a workaround for some USB diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index c37dd15d16d2..a9bb7ae2fafd 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -127,7 +127,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER, RQF_PM, NULL); - if (driver_byte(result) != DRIVER_SENSE || + if (result < 0 || driver_byte(result) != DRIVER_SENSE || sshdr->sense_key != UNIT_ATTENTION) break; } diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 2ef2954375f4..5733fbee2bae 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1658,7 +1658,7 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) &sshdr); /* failed to execute TUR, assume media not present */ - if (host_byte(retval)) { + if (retval < 0 || host_byte(retval)) { set_media_not_present(sdkp); goto out; } @@ -1719,6 +1719,9 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) if (res) { sd_print_result(sdkp, "Synchronize Cache(10) failed", res); + if (res < 0) + return res; + if (driver_byte(res) == DRIVER_SENSE) sd_print_sense_hdr(sdkp, sshdr); @@ -1825,7 +1828,7 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); - if (driver_byte(result) == DRIVER_SENSE && + if (result > 0 && driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) { sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); scsi_print_sense_hdr(sdev, NULL, &sshdr); @@ -2177,7 +2180,7 @@ sd_spinup_disk(struct scsi_disk *sdkp) ((driver_byte(the_result) == DRIVER_SENSE) && sense_valid && sshdr.sense_key == UNIT_ATTENTION))); - if (driver_byte(the_result) != DRIVER_SENSE) { + if (the_result < 0 || driver_byte(the_result) != DRIVER_SENSE) { /* no sense, TUR either succeeded or failed * with a status error */ if(!spintime && !scsi_status_is_good(the_result)) { @@ -2362,7 +2365,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, if (media_not_present(sdkp, &sshdr)) return -ENODEV; - if (the_result) { + if (the_result > 0) { sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST && @@ -2447,7 +2450,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, if (media_not_present(sdkp, &sshdr)) return -ENODEV; - if (the_result) { + if (the_result > 0) { sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == UNIT_ATTENTION && @@ -3591,7 +3594,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL); if (res) { sd_print_result(sdkp, "Start/Stop Unit failed", res); - if (driver_byte(res) == DRIVER_SENSE) + if (res > 0 && driver_byte(res) == DRIVER_SENSE) sd_print_sense_hdr(sdkp, &sshdr); if (scsi_sense_valid(&sshdr) && /* 0x3a is medium not present */ diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index e45d8d94574c..d4a79fdcfffe 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -116,7 +116,7 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf, sd_printk(KERN_ERR, sdkp, "REPORT ZONES start lba %llu failed\n", lba); sd_print_result(sdkp, "REPORT ZONES", result); - if (driver_byte(result) == DRIVER_SENSE && + if (result > 0 && driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return -EIO; diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 5703f8400b73..a78f2138d784 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -205,6 +205,10 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) cgc->timeout, IOCTL_RETRIES, 0, 0, NULL); /* Minimal error checking. Ignore cases we know about, and report the rest. */ + if (result < 0) { + err = result; + goto out; + } if (driver_byte(result) != 0) { switch (sshdr->sense_key) { case UNIT_ATTENTION: diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 0625da7a42ee..f743434073ac 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8487,7 +8487,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n", pwr_mode, ret); - if (driver_byte(ret) == DRIVER_SENSE) + if (ret > 0 && driver_byte(ret) == DRIVER_SENSE) scsi_print_sense_hdr(sdp, NULL, &sshdr); } diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index b9c86a7e3b97..1678b6f14af9 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -355,7 +355,7 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi) if (result == 0 && inq_result[0] >> 5) { /* PQ indicates the LUN is not attached */ scsi_remove_device(sdev); - } else if (host_byte(result) == DID_BAD_TARGET) { + } else if (result > 0 && host_byte(result) == DID_BAD_TARGET) { /* * If all LUNs of a virtio-scsi device are unplugged * it will respond with BAD TARGET on any INQUIRY diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 246ced401683..d0a24e55ad63 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -40,6 +40,9 @@ enum scsi_timeouts { */ static inline int scsi_status_is_good(int status) { + if (status < 0) + return false; + /* * FIXME: bit0 is listed as reserved in SCSI-2, but is * significant in SCSI-3. For now, we follow the SCSI-2 From patchwork Tue Apr 27 08:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225551 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 DC6A4C43470 for ; Tue, 27 Apr 2021 08:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0051613B4 for ; Tue, 27 Apr 2021 08:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235196AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:49422 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235124AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 46604B01F; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 07/40] scsi: introduce scsi_build_sense() Date: Tue, 27 Apr 2021 10:30:13 +0200 Message-Id: <20210427083046.31620-8-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduce scsi_build_sense() as a wrapper around scsi_build_sense_buffer() to format the buffer and set the correct SCSI status. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- drivers/ata/libata-scsi.c | 7 +-- drivers/s390/scsi/zfcp_scsi.c | 5 +-- drivers/scsi/3w-xxxx.c | 2 +- drivers/scsi/libiscsi.c | 5 +-- drivers/scsi/lpfc/lpfc_scsi.c | 54 ++++++++-------------- drivers/scsi/megaraid.c | 8 ++-- drivers/scsi/megaraid/megaraid_mbox.c | 14 +++--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 14 ++---- drivers/scsi/mvumi.c | 5 +-- drivers/scsi/myrb.c | 64 +++++++-------------------- drivers/scsi/myrs.c | 9 +--- drivers/scsi/ps3rom.c | 7 +-- drivers/scsi/qla2xxx/qla_isr.c | 15 ++----- drivers/scsi/scsi_debug.c | 11 ++--- drivers/scsi/scsi_lib.c | 18 ++++++++ drivers/scsi/smartpqi/smartpqi_init.c | 3 +- drivers/scsi/stex.c | 5 +-- include/scsi/scsi_cmnd.h | 3 ++ 18 files changed, 85 insertions(+), 164 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index c5129b9e3afd..10d0ef9e969d 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -196,9 +196,7 @@ void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, if (!cmd) return; - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - - scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq); + scsi_build_sense(cmd, d_sense, sk, asc, ascq); } void ata_scsi_set_sense_information(struct ata_device *dev, @@ -882,8 +880,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) * ATA PASS-THROUGH INFORMATION AVAILABLE * Always in descriptor format sense. */ - scsi_build_sense_buffer(1, cmd->sense_buffer, - RECOVERED_ERROR, 0, 0x1D); + scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D); } if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) { diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index d58bf79892f2..9da9b2b2a580 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -856,10 +856,7 @@ void zfcp_scsi_set_prot(struct zfcp_adapter *adapter) */ void zfcp_scsi_dif_sense_error(struct scsi_cmnd *scmd, int ascq) { - scsi_build_sense_buffer(1, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x10, ascq); - set_driver_byte(scmd, DRIVER_SENSE); - scmd->result |= SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 1, ILLEGAL_REQUEST, 0x10, ascq); set_host_byte(scmd, DID_SOFT_ERROR); } diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index a7292883b72b..7a0b4a44395d 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1977,7 +1977,7 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_c printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); tw_dev->state[request_id] = TW_S_COMPLETED; tw_state_request_finish(tw_dev, request_id); - scsi_build_sense_buffer(1, SCpnt->sense_buffer, ILLEGAL_REQUEST, 0x20, 0); + scsi_build_sense(SCpnt, 1, ILLEGAL_REQUEST, 0x20, 0); done(SCpnt); retval = 0; } diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 7ad11e42306d..3a485ad0204e 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -829,10 +829,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ascq = session->tt->check_protection(task, §or); if (ascq) { - sc->result = DRIVER_SENSE << 24 | - SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(1, sc->sense_buffer, - ILLEGAL_REQUEST, 0x10, ascq); + scsi_build_sense(sc, 1, ILLEGAL_REQUEST, 0x10, ascq); scsi_set_sense_information(sc->sense_buffer, SCSI_SENSE_BUFFERSIZE, sector); diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index eefbb9b22798..c478f1b45006 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -2869,10 +2869,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) } out: if (err_type == BGS_GUARD_ERR_MASK) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x1); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); + set_host_byte(cmd, DID_ABORT); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, "9069 BLKGRD: reftag %x grd_tag err %x != %x\n", @@ -2880,10 +2878,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) sum, guard_tag); } else if (err_type == BGS_REFTAG_ERR_MASK) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x3); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); + set_host_byte(cmd, DID_ABORT); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, @@ -2892,10 +2888,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) ref_tag, start_ref_tag); } else if (err_type == BGS_APPTAG_ERR_MASK) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x2); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); + set_host_byte(cmd, DID_ABORT); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, @@ -2954,10 +2948,8 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_guard_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x1); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); + set_host_byte(cmd, DID_ABORT); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, "9059 BLKGRD: Guard Tag error in cmd" @@ -2970,10 +2962,8 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_reftag_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x3); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); + set_host_byte(cmd, DID_ABORT); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, @@ -2987,10 +2977,8 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_apptag_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x2); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); + set_host_byte(cmd, DID_ABORT); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, @@ -3100,10 +3088,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_guard_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x1); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); + set_host_byte(cmd, DID_ABORT); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, "9055 BLKGRD: Guard Tag error in cmd " @@ -3116,10 +3102,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_reftag_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x3); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); + set_host_byte(cmd, DID_ABORT); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, @@ -3133,10 +3117,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, if (lpfc_bgs_get_apptag_err(bgstat)) { ret = 1; - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x2); - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); + set_host_byte(cmd, DID_ABORT); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 80f546976c7e..ae3f32f89381 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1596,11 +1596,9 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | (CHECK_CONDITION << 1); - } else { - cmd->sense_buffer[0] = 0x70; - cmd->sense_buffer[2] = ABORTED_COMMAND; - cmd->result |= (CHECK_CONDITION << 1); - } + } else + scsi_build_sense(cmd, 0, + ABORTED_COMMAND, 0, 0); } break; diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index b1a2d3536add..6a5b844a8499 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -1574,10 +1574,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) } if (scp->cmnd[1] & MEGA_SCSI_INQ_EVPD) { - scp->sense_buffer[0] = 0x70; - scp->sense_buffer[2] = ILLEGAL_REQUEST; - scp->sense_buffer[12] = MEGA_INVALID_FIELD_IN_CDB; - scp->result = CHECK_CONDITION << 1; + scsi_build_sense(scp, 0, ILLEGAL_REQUEST, + MEGA_INVALID_FIELD_IN_CDB, 0); return NULL; } @@ -2313,11 +2311,9 @@ megaraid_mbox_dpc(unsigned long devp) scp->result = DRIVER_SENSE << 24 | DID_OK << 16 | CHECK_CONDITION << 1; - } else { - scp->sense_buffer[0] = 0x70; - scp->sense_buffer[2] = ABORTED_COMMAND; - scp->result = CHECK_CONDITION << 1; - } + } else + scsi_build_sense(scp, 0, + ABORTED_COMMAND, 0, 0); } break; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index d00aca3c77ce..fbfbf40a3f66 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -5077,10 +5077,8 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) ascq = 0x00; break; } - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10, - ascq); - scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x10, ascq); + set_host_byte(scmd, DID_ABORT); } /** @@ -5837,12 +5835,8 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; - scmd->sense_buffer[0] = 0x70; - scmd->sense_buffer[2] = ILLEGAL_REQUEST; - scmd->sense_buffer[12] = 0x20; - scmd->sense_buffer[13] = 0; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, + 0x20, 0); } break; diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 9d5743627604..94f706eeb561 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2068,10 +2068,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba, return 0; error: - scmd->result = (DID_OK << 16) | (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x24, - 0); + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); return -1; } diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c index d9c82e211ae7..542ed88ef90d 100644 --- a/drivers/scsi/myrb.c +++ b/drivers/scsi/myrb.c @@ -1397,8 +1397,7 @@ myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd, static void myrb_request_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd) { - scsi_build_sense_buffer(0, scmd->sense_buffer, - NO_SENSE, 0, 0); + scsi_build_sense(scmd, 0, NO_SENSE, 0, 0); scsi_sg_copy_from_buffer(scmd, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); } @@ -1447,10 +1446,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, case INQUIRY: if (scmd->cmnd[1] & 1) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); } else { myrb_inquiry(cb, scmd); scmd->result = (DID_OK << 16); @@ -1465,10 +1461,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, if ((scmd->cmnd[2] & 0x3F) != 0x3F && (scmd->cmnd[2] & 0x3F) != 0x08) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); } else { myrb_mode_sense(cb, scmd, ldev_info); scmd->result = (DID_OK << 16); @@ -1479,20 +1472,14 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, if ((scmd->cmnd[1] & 1) || (scmd->cmnd[8] & 1)) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); scmd->scsi_done(scmd); return 0; } lba = get_unaligned_be32(&scmd->cmnd[2]); if (lba) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); scmd->scsi_done(scmd); return 0; } @@ -1506,10 +1493,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, case SEND_DIAGNOSTIC: if (scmd->cmnd[1] != 0x04) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); } else { /* Assume good status */ scmd->result = (DID_OK << 16); @@ -1519,10 +1503,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, case READ_6: if (ldev_info->state == MYRB_DEVICE_WO) { /* Data protect, attempt to read invalid data */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - DATA_PROTECT, 0x21, 0x06); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); scmd->scsi_done(scmd); return 0; } @@ -1536,10 +1517,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, case READ_10: if (ldev_info->state == MYRB_DEVICE_WO) { /* Data protect, attempt to read invalid data */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - DATA_PROTECT, 0x21, 0x06); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); scmd->scsi_done(scmd); return 0; } @@ -1553,10 +1531,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, case READ_12: if (ldev_info->state == MYRB_DEVICE_WO) { /* Data protect, attempt to read invalid data */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - DATA_PROTECT, 0x21, 0x06); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); scmd->scsi_done(scmd); return 0; } @@ -1569,9 +1544,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost, break; default: /* Illegal request, invalid opcode */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x20, 0); - scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0); scmd->scsi_done(scmd); return 0; } @@ -2352,25 +2325,19 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk, "Bad Data Encountered\n"); if (scmd->sc_data_direction == DMA_FROM_DEVICE) /* Unrecovered read error */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - MEDIUM_ERROR, 0x11, 0); + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x11, 0); else /* Write error */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - MEDIUM_ERROR, 0x0C, 0); - scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x0C, 0); break; case MYRB_STATUS_IRRECOVERABLE_DATA_ERROR: scmd_printk(KERN_ERR, scmd, "Irrecoverable Data Error\n"); if (scmd->sc_data_direction == DMA_FROM_DEVICE) /* Unrecovered read error, auto-reallocation failed */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - MEDIUM_ERROR, 0x11, 0x04); + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x11, 0x04); else /* Write error, auto-reallocation failed */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - MEDIUM_ERROR, 0x0C, 0x02); - scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x0C, 0x02); break; case MYRB_STATUS_LDRV_NONEXISTENT_OR_OFFLINE: dev_dbg(&scmd->device->sdev_gendev, @@ -2381,8 +2348,7 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk, dev_dbg(&scmd->device->sdev_gendev, "Attempt to Access Beyond End of Logical Drive"); /* Logical block address out of range */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - NOT_READY, 0x21, 0); + scsi_build_sense(scmd, 0, NOT_READY, 0x21, 0); break; case MYRB_STATUS_DEVICE_NONRESPONSIVE: dev_dbg(&scmd->device->sdev_gendev, "Device nonresponsive\n"); diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c index 3b68c68d1716..26326af23dbc 100644 --- a/drivers/scsi/myrs.c +++ b/drivers/scsi/myrs.c @@ -1600,9 +1600,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost, switch (scmd->cmnd[0]) { case REPORT_LUNS: - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, - 0x20, 0x0); - scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0x0); scmd->scsi_done(scmd); return 0; case MODE_SENSE: @@ -1612,10 +1610,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost, if ((scmd->cmnd[2] & 0x3F) != 0x3F && (scmd->cmnd[2] & 0x3F) != 0x08) { /* Illegal request, invalid field in CDB */ - scsi_build_sense_buffer(0, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x24, 0); - scmd->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); } else { myrs_mode_sense(cs, scmd, ldev_info); scmd->result = (DID_OK << 16); diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index ccb5771f1cb7..0f4b99d92f12 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c @@ -234,10 +234,8 @@ static int ps3rom_queuecommand_lck(struct scsi_cmnd *cmd, } if (res) { - memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); + scsi_build_sense(cmd, 0, ILLEGAL_REQUEST, 0, 0); cmd->result = res; - cmd->sense_buffer[0] = 0x70; - cmd->sense_buffer[2] = ILLEGAL_REQUEST; priv->curr_cmd = NULL; cmd->scsi_done(cmd); } @@ -319,8 +317,7 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data) goto done; } - scsi_build_sense_buffer(0, cmd->sense_buffer, sense_key, asc, ascq); - cmd->result = SAM_STAT_CHECK_CONDITION; + scsi_build_sense(cmd, 0, sense_key, asc, ascq); done: priv->curr_cmd = NULL; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 6e8f737a4af3..19fe2c1659d0 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -2694,31 +2694,22 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) /* check guard */ if (e_guard != a_guard) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x1); - set_driver_byte(cmd, DRIVER_SENSE); + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); set_host_byte(cmd, DID_ABORT); - cmd->result |= SAM_STAT_CHECK_CONDITION; return 1; } /* check ref tag */ if (e_ref_tag != a_ref_tag) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x3); - set_driver_byte(cmd, DRIVER_SENSE); + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); set_host_byte(cmd, DID_ABORT); - cmd->result |= SAM_STAT_CHECK_CONDITION; return 1; } /* check appl tag */ if (e_app_tag != a_app_tag) { - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, - 0x10, 0x2); - set_driver_byte(cmd, DRIVER_SENSE); + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); set_host_byte(cmd, DID_ABORT); - cmd->result |= SAM_STAT_CHECK_CONDITION; return 1; } diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 70165be10f00..f7e72d21749a 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -931,7 +931,7 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, } asc = c_d ? INVALID_FIELD_IN_CDB : INVALID_FIELD_IN_PARAM_LIST; memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); - scsi_build_sense_buffer(sdebug_dsense, sbuff, ILLEGAL_REQUEST, asc, 0); + scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); memset(sks, 0, sizeof(sks)); sks[0] = 0x80; if (c_d) @@ -957,17 +957,14 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) { - unsigned char *sbuff; - - sbuff = scp->sense_buffer; - if (!sbuff) { + if (!scp->sense_buffer) { sdev_printk(KERN_ERR, scp->device, "%s: sense_buffer is NULL\n", __func__); return; } - memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); + memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - scsi_build_sense_buffer(sdebug_dsense, sbuff, key, asc, asq); + scsi_build_sense(scp, sdebug_dsense, key, asc, asq); if (sdebug_verbose) sdev_printk(KERN_INFO, scp->device, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index cd316e935281..ea5e34e305e3 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -3264,3 +3264,21 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) return group_id; } EXPORT_SYMBOL(scsi_vpd_tpg_id); + +/** + * scsi_build_sense - build sense data for a command + * @scmd: scsi command for which the sense should be formatted + * @desc: Sense format (non-zero == descriptor format, + * 0 == fixed format) + * @key: Sense key + * @asc: Additional sense code + * @ascq: Additional sense code qualifier + * + **/ +void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) +{ + scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); + scmd->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | + SAM_STAT_CHECK_CONDITION; +} +EXPORT_SYMBOL_GPL(scsi_build_sense); diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 25c0409e98df..a112d9c3c548 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -3088,8 +3088,7 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request) } if (device_offline && sense_data_length == 0) - scsi_build_sense_buffer(0, scmd->sense_buffer, HARDWARE_ERROR, - 0x3e, 0x1); + scsi_build_sense(scmd, 0, HARDWARE_ERROR, 0x3e, 0x1); scmd->result = scsi_status; set_host_byte(scmd, host_byte); diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 12471208c7a8..3af2a2d3bfa2 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -398,11 +398,8 @@ static struct status_msg *stex_get_status(struct st_hba *hba) static void stex_invalid_field(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - /* "Invalid field in cdb" */ - scsi_build_sense_buffer(0, cmd->sense_buffer, ILLEGAL_REQUEST, 0x24, - 0x0); + scsi_build_sense(cmd, 0, ILLEGAL_REQUEST, 0x24, 0x0); done(cmd); } diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 83f7e520be48..b3eaf4b74b72 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -342,4 +342,7 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) return xfer_len; } +extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, + u8 key, u8 asc, u8 ascq); + #endif /* _SCSI_SCSI_CMND_H */ From patchwork Tue Apr 27 08:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225553 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 8FFEBC43460 for ; Tue, 27 Apr 2021 08:31:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63530611F2 for ; Tue, 27 Apr 2021 08:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235201AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:49418 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235121AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 45B91B01E; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 08/40] scsi: introduce scsi_status_is_check_condition() Date: Tue, 27 Apr 2021 10:30:14 +0200 Message-Id: <20210427083046.31620-9-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add a helper function scsi_status_is_check_condition() to encapsulate the frequent checks for SAM_STAT_CHECK_CONDITION. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- drivers/scsi/scsi.c | 2 +- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_lib.c | 2 +- include/scsi/scsi.h | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index f33f56680c59..9e229a1a4965 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -1005,7 +1005,7 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct) if (cmnd) { cmnd->result |= rsp->status; - if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) + if (scsi_status_is_check_condition(cmnd->result)) memcpy(cmnd->sense_buffer, rsp->data, be32_to_cpu(rsp->sense_data_len)); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 99dc6ec0b6e5..1ce46e6e6483 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -144,7 +144,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) (level > 1)) { scsi_print_result(cmd, "Done", disposition); scsi_print_command(cmd); - if (status_byte(cmd->result) == CHECK_CONDITION) + if (scsi_status_is_check_condition(cmd->result)) scsi_print_sense(cmd); if (level > 3) scmd_printk(KERN_INFO, cmd, diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index d8fafe77dbbe..0967021cc06e 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1258,7 +1258,7 @@ int scsi_eh_get_sense(struct list_head *work_q, current->comm)); break; } - if (status_byte(scmd->result) != CHECK_CONDITION) + if (!scsi_status_is_check_condition(scmd->result)) /* * don't request sense if there's no check condition * status because the error we're processing isn't one @@ -1774,7 +1774,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER); } - if (status_byte(scmd->result) != CHECK_CONDITION) + if (!scsi_status_is_check_condition(scmd->result)) return 0; check_type: diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ea5e34e305e3..c3f965cf4d0a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2206,7 +2206,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, goto retry; } } - if ((status_byte(result) == CHECK_CONDITION) && + if (scsi_status_is_check_condition(result) && sshdr->sense_key == UNIT_ATTENTION && retry_count) { retry_count--; diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index d0a24e55ad63..2c2d59251ef1 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -58,6 +58,21 @@ static inline int scsi_status_is_good(int status) (status == SAM_STAT_COMMAND_TERMINATED)); } +/** + * scsi_status_is_check_condition - check the status return. + * + * @status: the status passed up from the driver (including host and + * driver components) + * + * This returns true if the status code is SAM_STAT_CHECK_CONDITION. + */ +static inline int scsi_status_is_check_condition(int status) +{ + if (status < 0) + return false; + status &= 0xfe; + return status == SAM_STAT_CHECK_CONDITION; +} /* * standard mode-select header prepended to all mode-select commands From patchwork Tue Apr 27 08:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225559 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 7DD52C43462 for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C4B360234 for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235210AbhD0IcE (ORCPT ); Tue, 27 Apr 2021 04:32:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:49440 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235133AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 48AF8B020; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 09/40] scsi: Kill DRIVER_SENSE Date: Tue, 27 Apr 2021 10:30:15 +0200 Message-Id: <20210427083046.31620-10-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace the check for DRIVER_SENSE with a check for scsi_status_is_check_condition(). And audit all callsites to ensure the SAM status is set correctly. For backwards compability move the DRIVER_SENSE definition to sg.h, and update sg, bsg, and scsi_ioctl to set the DRIVER_SENSE driver_status whenever SAM_STAT_CHECK_CONDITION is present. Signed-off-by: Hannes Reinecke --- block/bsg.c | 2 ++ block/scsi_ioctl.c | 2 ++ drivers/ata/libata-scsi.c | 13 ++------ drivers/scsi/NCR5380.c | 2 +- drivers/scsi/advansys.c | 2 -- drivers/scsi/aic7xxx/aic79xx_osm.c | 19 +++++------- drivers/scsi/aic7xxx/aic7xxx_osm.c | 1 - drivers/scsi/arcmsr/arcmsr_hba.c | 1 - drivers/scsi/ch.c | 2 +- drivers/scsi/cxlflash/superpipe.c | 3 +- drivers/scsi/dc395x.c | 13 ++------ drivers/scsi/esp_scsi.c | 4 +-- drivers/scsi/megaraid.c | 8 ++--- drivers/scsi/megaraid/megaraid_mbox.c | 7 ++--- drivers/scsi/megaraid/megaraid_sas_base.c | 2 -- drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 - drivers/scsi/mvumi.c | 1 - drivers/scsi/scsi.c | 7 ----- drivers/scsi/scsi_debug.c | 4 +-- drivers/scsi/scsi_ioctl.c | 3 +- drivers/scsi/scsi_lib.c | 10 ++----- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 33 +++++++++++---------- drivers/scsi/sd_zbc.c | 3 +- drivers/scsi/sg.c | 7 +++-- drivers/scsi/stex.c | 4 +-- drivers/scsi/sym53c8xx_2/sym_glue.c | 6 ++-- drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/virtio_scsi.c | 3 +- drivers/scsi/vmw_pvscsi.c | 3 -- drivers/target/loopback/tcm_loop.c | 1 - drivers/usb/storage/cypress_atacb.c | 4 +-- drivers/xen/xen-scsiback.c | 3 +- include/scsi/sg.h | 11 +++++++ 35 files changed, 76 insertions(+), 115 deletions(-) diff --git a/block/bsg.c b/block/bsg.c index bd10922d5cbb..9e6ff0d71d25 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -97,6 +97,8 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr) hdr->device_status = sreq->result & 0xff; hdr->transport_status = host_byte(sreq->result); hdr->driver_status = driver_byte(sreq->result); + if (scsi_status_is_check_condition(sreq->result)) + hdr->driver_status = DRIVER_SENSE; hdr->info = 0; if (hdr->device_status || hdr->transport_status || hdr->driver_status) hdr->info |= SG_INFO_CHECK; diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 99d58786e0d5..b6b3541c6406 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -257,6 +257,8 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, hdr->msg_status = msg_byte(req->result); hdr->host_status = host_byte(req->result); hdr->driver_status = driver_byte(req->result); + if (scsi_status_is_check_condition(hdr->status)) + hdr->driver_status = DRIVER_SENSE; hdr->info = 0; if (hdr->masked_status || hdr->host_status || hdr->driver_status) hdr->info |= SG_INFO_CHECK; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 10d0ef9e969d..401990e87d50 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -411,13 +411,12 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) rc = cmd_result; goto error; } - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ + if (scsi_sense_valid(&sshdr)) {/* sense data available */ u8 *desc = sensebuf + 8; - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ /* If we set cc then ATA pass-through will cause a * check condition even if no error. Filter that. */ - if (cmd_result & SAM_STAT_CHECK_CONDITION) { + if (scsi_status_is_check_condition(cmd_result)) { if (sshdr.sense_key == RECOVERED_ERROR && sshdr.asc == 0 && sshdr.ascq == 0x1d) cmd_result &= ~SAM_STAT_CHECK_CONDITION; @@ -496,9 +495,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) rc = cmd_result; goto error; } - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ + if (scsi_sense_valid(&sshdr)) {/* sense data available */ u8 *desc = sensebuf + 8; - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ /* If we set cc then ATA pass-through will cause a * check condition even if no error. Filter that. */ @@ -864,8 +862,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - /* * Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. @@ -962,8 +958,6 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - if (ata_dev_disabled(dev)) { /* Device disabled after error recovery */ /* LOGICAL UNIT NOT READY, HARD RESET REQUIRED */ @@ -4202,7 +4196,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) case REQUEST_SENSE: ata_scsi_set_sense(dev, cmd, 0, 0, 0); - cmd->result = (DRIVER_SENSE << 24); break; /* if we reach this, then writeback caching is disabled, diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 2ddbcaa667d1..d7594b794d3c 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -542,7 +542,7 @@ static void complete_cmd(struct Scsi_Host *instance, scsi_eh_restore_cmnd(cmd, &hostdata->ses); } else { scsi_eh_restore_cmnd(cmd, &hostdata->ses); - set_driver_byte(cmd, DRIVER_SENSE); + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); } hostdata->sensing = NULL; } diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index e9516de8c18b..77c99fe11c81 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -6009,7 +6009,6 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG_PRT_SENSE(2, scp->sense_buffer, SCSI_SENSE_BUFFERSIZE); - set_driver_byte(scp, DRIVER_SENSE); } break; @@ -6760,7 +6759,6 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG_PRT_SENSE(2, scp->sense_buffer, SCSI_SENSE_BUFFERSIZE); - set_driver_byte(scp, DRIVER_SENSE); } break; diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 4f7102f8eeb0..92ea24a075b8 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1928,7 +1928,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, memcpy(cmd->sense_buffer, ahd_get_sense_buf(ahd, scb) + sense_offset, sense_size); - cmd->result |= (DRIVER_SENSE << 24); + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); #ifdef AHD_DEBUG if (ahd_debug & AHD_SHOW_SENSE) { @@ -2018,6 +2018,7 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd) int new_status = DID_OK; int do_fallback = 0; int scsi_status; + struct scsi_sense_data *sense; /* * Map CAM error codes into Linux Error codes. We @@ -2041,18 +2042,12 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd) switch(scsi_status) { case SAM_STAT_COMMAND_TERMINATED: case SAM_STAT_CHECK_CONDITION: - if ((cmd->result >> 24) != DRIVER_SENSE) { + sense = (struct scsi_sense_data *) + cmd->sense_buffer; + if (sense->extra_len >= 5 && + (sense->add_sense_code == 0x47 + || sense->add_sense_code == 0x48)) do_fallback = 1; - } else { - struct scsi_sense_data *sense; - - sense = (struct scsi_sense_data *) - cmd->sense_buffer; - if (sense->extra_len >= 5 && - (sense->add_sense_code == 0x47 - || sense->add_sense_code == 0x48)) - do_fallback = 1; - } break; default: break; diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index d33f5a00bf0b..8b3d472aa3cc 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1838,7 +1838,6 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc, if (sense_size < SCSI_SENSE_BUFFERSIZE) memset(&cmd->sense_buffer[sense_size], 0, SCSI_SENSE_BUFFERSIZE - sense_size); - cmd->result |= (DRIVER_SENSE << 24); #ifdef AHC_DEBUG if (ahc_debug & AHC_SHOW_SENSE) { int i; diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 4b79661275c9..8e4d7d0e649c 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1335,7 +1335,6 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb) memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length); sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS; sensebuffer->Valid = 1; - pcmd->result |= (DRIVER_SENSE << 24); } } diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 0e7d1214c3d8..b8f3d6d96cf3 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -200,7 +200,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, MAX_RETRIES, NULL); if (result < 0) return result; - if (driver_byte(result) == DRIVER_SENSE) { + if (scsi_sense_valid(&sshdr)) { if (debug) scsi_print_sense_hdr(ch->device, ch->name, &sshdr); errno = ch_find_errno(&sshdr); diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index caa7c5fd233d..df0ebabbf387 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -369,8 +369,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) goto out; } - if (result > 0 && driver_byte(result) == DRIVER_SENSE) { - result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ + if (result > 0 && scsi_sense_valid(&sshdr)) { if (result & SAM_STAT_CHECK_CONDITION) { switch (sshdr.sense_key) { case NO_SENSE: diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index be87d5a7583d..a713fe605dda 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -3239,16 +3239,9 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); - if (srb->total_xfer_length - && srb->total_xfer_length >= cmd->underflow) - cmd->result = - MK_RES_LNX(DRIVER_SENSE, DID_OK, - srb->end_message, CHECK_CONDITION); - /*SET_RES_DID(cmd->result,DID_OK) */ - else - cmd->result = - MK_RES_LNX(DRIVER_SENSE, DID_OK, - srb->end_message, CHECK_CONDITION); + cmd->result = + MK_RES(0, DID_OK, + srb->end_message, SAM_STAT_CHECK_CONDITION); goto ckc_e; } diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 342535ac0570..9a8c037a2f21 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -922,9 +922,7 @@ static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent, * saw originally. Also, report that we are providing * the sense data. */ - cmd->result = ((DRIVER_SENSE << 24) | - (DID_OK << 16) | - (SAM_STAT_CHECK_CONDITION << 0)); + cmd->result = SAM_STAT_CHECK_CONDITION; ent->flags &= ~ESP_CMD_FLAG_AUTOSENSE; if (esp_debug & ESP_DEBUG_AUTOSENSE) { diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index ae3f32f89381..1880471c632a 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1583,9 +1583,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) memcpy(cmd->sense_buffer, pthru->reqsensearea, 14); - cmd->result = (DRIVER_SENSE << 24) | - (DID_OK << 16) | - (CHECK_CONDITION << 1); + cmd->result = SAM_STAT_CHECK_CONDITION; } else { if (mbox->m_out.cmd == MEGA_MBOXCMD_EXTPTHRU) { @@ -1593,9 +1591,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) memcpy(cmd->sense_buffer, epthru->reqsensearea, 14); - cmd->result = (DRIVER_SENSE << 24) | - (DID_OK << 16) | - (CHECK_CONDITION << 1); + cmd->result = SAM_STAT_CHECK_CONDITION; } else scsi_build_sense(cmd, 0, ABORTED_COMMAND, 0, 0); diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 6a5b844a8499..674f1c6829f5 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -2299,8 +2299,7 @@ megaraid_mbox_dpc(unsigned long devp) memcpy(scp->sense_buffer, pthru->reqsensearea, 14); - scp->result = DRIVER_SENSE << 24 | - DID_OK << 16 | CHECK_CONDITION << 1; + scp->result = SAM_STAT_CHECK_CONDITION; } else { if (mbox->cmd == MBOXCMD_EXTPTHRU) { @@ -2308,9 +2307,7 @@ megaraid_mbox_dpc(unsigned long devp) memcpy(scp->sense_buffer, epthru->reqsensearea, 14); - scp->result = DRIVER_SENSE << 24 | - DID_OK << 16 | - CHECK_CONDITION << 1; + scp->result = SAM_STAT_CHECK_CONDITION; } else scsi_build_sense(scp, 0, ABORTED_COMMAND, 0, 0); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 4d4e9dbe5193..5c5fae5fc443 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3617,8 +3617,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, SCSI_SENSE_BUFFERSIZE); memcpy(cmd->scmd->sense_buffer, cmd->sense, hdr->sense_len); - - cmd->scmd->result |= DRIVER_SENSE << 24; } break; diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 2221175ae051..1a4bd75229cf 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -2051,7 +2051,6 @@ map_cmd_status(struct fusion_context *fusion, SCSI_SENSE_BUFFERSIZE); memcpy(scmd->sense_buffer, sense, SCSI_SENSE_BUFFERSIZE); - scmd->result |= DRIVER_SENSE << 24; } /* diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 94f706eeb561..f61250545025 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -1317,7 +1317,6 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd, if (ob_frame->rsp_flag & CL_RSP_FLAG_SENSEDATA) { memcpy(cmd->scmd->sense_buffer, ob_frame->payload, sizeof(struct mvumi_sense_data)); - scmd->result |= (DRIVER_SENSE << 24); } break; default: diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 1ce46e6e6483..d26025cf5de3 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -185,13 +185,6 @@ void scsi_finish_command(struct scsi_cmnd *cmd) if (atomic_read(&sdev->device_blocked)) atomic_set(&sdev->device_blocked, 0); - /* - * If we have valid sense information, then some kind of recovery - * must have taken place. Make a note of this. - */ - if (SCSI_SENSE_VALID(cmd)) - cmd->result |= (DRIVER_SENSE << 24); - SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, "Notifying upper driver of completion " "(result %x)\n", cmd->result)); diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index f7e72d21749a..517019c22187 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -851,10 +851,10 @@ static struct device_driver sdebug_driverfs_driver = { }; static const int check_condition_result = - (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + SAM_STAT_CHECK_CONDITION; static const int illegal_condition_result = - (DRIVER_SENSE << 24) | (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; + (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; static const int device_qfull_result = (DID_OK << 16) | SAM_STAT_TASK_SET_FULL; diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index d34e1b41dc71..0d13610cd6bf 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -103,8 +103,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, if (result < 0) goto out; - if (driver_byte(result) == DRIVER_SENSE && - scsi_sense_valid(&sshdr)) { + if (scsi_sense_valid(&sshdr)) { switch (sshdr.sense_key) { case ILLEGAL_REQUEST: if (cmd[0] == ALLOW_MEDIUM_REMOVAL) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index c3f965cf4d0a..612decaccfb5 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -627,8 +627,6 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) case DID_OK: /* * Also check the other bytes than the status byte in result - * to handle the case when a SCSI LLD sets result to - * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION. */ if (scsi_status_is_good(result) && (result & ~0xff) == 0) return BLK_STS_OK; @@ -824,7 +822,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) */ if (!level && __ratelimit(&_rs)) { scsi_print_result(cmd, NULL, FAILED); - if (driver_byte(result) == DRIVER_SENSE) + if (sense_valid) scsi_print_sense(cmd); scsi_print_command(cmd); } @@ -2194,8 +2192,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, * ILLEGAL REQUEST if the code page isn't supported */ if (!scsi_status_is_good(result)) { - if (driver_byte(result) == DRIVER_SENSE && - scsi_sense_valid(sshdr)) { + if (scsi_sense_valid(sshdr)) { if ((sshdr->sense_key == ILLEGAL_REQUEST) && (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { /* @@ -3278,7 +3275,6 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id); void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) { scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); - scmd->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | - SAM_STAT_CHECK_CONDITION; + scmd->result = SAM_STAT_CHECK_CONDITION; } EXPORT_SYMBOL_GPL(scsi_build_sense); diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 493f17bf26f2..7fb39bc17bf1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -623,7 +623,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, * INQUIRY should not yield UNIT_ATTENTION * but many buggy devices do so anyway. */ - if (driver_byte(result) == DRIVER_SENSE && + if (scsi_status_is_check_condition(result) && scsi_sense_valid(&sshdr)) { if ((sshdr.sense_key == UNIT_ATTENTION) && ((sshdr.asc == 0x28) || diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index a9bb7ae2fafd..5af7a10e9514 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -127,7 +127,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER, RQF_PM, NULL); - if (result < 0 || driver_byte(result) != DRIVER_SENSE || + if (result < 0 || !scsi_sense_valid(sshdr) || sshdr->sense_key != UNIT_ATTENTION) break; } diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 5733fbee2bae..66cb161667af 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1722,16 +1722,17 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) if (res < 0) return res; - if (driver_byte(res) == DRIVER_SENSE) + if (scsi_status_is_check_condition(res) && + scsi_sense_valid(sshdr)) { sd_print_sense_hdr(sdkp, sshdr); - /* we need to evaluate the error return */ - if (scsi_sense_valid(sshdr) && - (sshdr->asc == 0x3a || /* medium not present */ - sshdr->asc == 0x20 || /* invalid command */ - (sshdr->asc == 0x74 && sshdr->ascq == 0x71))) /* drive is password locked */ + /* we need to evaluate the error return */ + if (sshdr->asc == 0x3a || /* medium not present */ + sshdr->asc == 0x20 || /* invalid command */ + (sshdr->asc == 0x74 && sshdr->ascq == 0x71)) /* drive is password locked */ /* this is no error here */ return 0; + } switch (host_byte(res)) { /* ignore errors due to racing a disconnection */ @@ -1828,7 +1829,7 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); - if (result > 0 && driver_byte(result) == DRIVER_SENSE && + if (scsi_status_is_check_condition(result) && scsi_sense_valid(&sshdr)) { sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); scsi_print_sense_hdr(sdev, NULL, &sshdr); @@ -2072,7 +2073,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out = 0; - if (driver_byte(result) != DRIVER_SENSE && + if (!scsi_status_is_check_condition(result) && (!sense_valid || sense_deferred)) goto out; @@ -2175,12 +2176,12 @@ sd_spinup_disk(struct scsi_disk *sdkp) if (the_result) sense_valid = scsi_sense_valid(&sshdr); retries++; - } while (retries < 3 && + } while (retries < 3 && (!scsi_status_is_good(the_result) || - ((driver_byte(the_result) == DRIVER_SENSE) && + (scsi_status_is_check_condition(the_result) && sense_valid && sshdr.sense_key == UNIT_ATTENTION))); - if (the_result < 0 || driver_byte(the_result) != DRIVER_SENSE) { + if (!scsi_status_is_check_condition(the_result)) { /* no sense, TUR either succeeded or failed * with a status error */ if(!spintime && !scsi_status_is_good(the_result)) { @@ -2308,7 +2309,7 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, struct scsi_sense_hdr *sshdr, int sense_valid, int the_result) { - if (driver_byte(the_result) == DRIVER_SENSE) + if (sense_valid) sd_print_sense_hdr(sdkp, sshdr); else sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); @@ -3594,12 +3595,12 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL); if (res) { sd_print_result(sdkp, "Start/Stop Unit failed", res); - if (res > 0 && driver_byte(res) == DRIVER_SENSE) + if (res > 0 && scsi_sense_valid(&sshdr)) { sd_print_sense_hdr(sdkp, &sshdr); - if (scsi_sense_valid(&sshdr) && /* 0x3a is medium not present */ - sshdr.asc == 0x3a) - res = 0; + if (sshdr.asc == 0x3a) + res = 0; + } } /* SCSI error codes must not go to the generic layer */ diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index d4a79fdcfffe..186b5ff52c3a 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -116,8 +116,7 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf, sd_printk(KERN_ERR, sdkp, "REPORT ZONES start lba %llu failed\n", lba); sd_print_result(sdkp, "REPORT ZONES", result); - if (result > 0 && driver_byte(result) == DRIVER_SENSE && - scsi_sense_valid(&sshdr)) + if (result > 0 && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return -EIO; } diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 737cea9d908e..6b7d5f03fb2b 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -498,9 +498,11 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) old_hdr->host_status = hp->host_status; old_hdr->driver_status = hp->driver_status; if ((CHECK_CONDITION & hp->masked_status) || - (DRIVER_SENSE & hp->driver_status)) + (srp->sense_b && (srp->sense_b[0] & 0x70) == 0x70)) { + old_hdr->driver_status = DRIVER_SENSE; memcpy(old_hdr->sense_buffer, srp->sense_b, sizeof (old_hdr->sense_buffer)); + } switch (hp->host_status) { /* This setup of 'result' is for backward compatibility and is best ignored by the user who should use target, host + driver status */ @@ -574,7 +576,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) hp->sb_len_wr = 0; if ((hp->mx_sb_len > 0) && hp->sbp) { if ((CHECK_CONDITION & hp->masked_status) || - (DRIVER_SENSE & hp->driver_status)) { + (srp->sense_b && (srp->sense_b[0] & 0x70) == 0x70)) { int sb_len = SCSI_SENSE_BUFFERSIZE; sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ @@ -583,6 +585,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) err = -EFAULT; goto err_out; } + hp->driver_status = DRIVER_SENSE; hp->sb_len_wr = len; } } diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 3af2a2d3bfa2..491b435273a6 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -737,7 +737,7 @@ static void stex_scsi_done(struct st_ccb *ccb) result |= DID_OK << 16; break; case SAM_STAT_CHECK_CONDITION: - result |= DRIVER_SENSE << 24; + result |= DID_OK << 16; break; case SAM_STAT_BUSY: result |= DID_BUS_BUSY << 16; @@ -748,7 +748,7 @@ static void stex_scsi_done(struct st_ccb *ccb) } } else if (ccb->srb_status & SRB_SEE_SENSE) - result = DRIVER_SENSE << 24 | SAM_STAT_CHECK_CONDITION; + result = SAM_STAT_CHECK_CONDITION; else switch (ccb->srb_status) { case SRB_STATUS_SELECTION_TIMEOUT: result = DID_NO_CONNECT << 16; diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index d9a045f9858c..16b65fc4405c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -170,9 +170,8 @@ static int sym_xerr_cam_status(int cam_status, int x_status) void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) { struct scsi_cmnd *cmd = cp->cmd; - u_int cam_status, scsi_status, drv_status; + u_int cam_status, scsi_status; - drv_status = 0; cam_status = DID_OK; scsi_status = cp->ssss_status; @@ -186,7 +185,6 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) cp->xerr_status == 0) { cam_status = sym_xerr_cam_status(DID_OK, cp->sv_xerr_status); - drv_status = DRIVER_SENSE; /* * Bounce back the sense data to user. */ @@ -235,7 +233,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status); } scsi_set_resid(cmd, resid); - cmd->result = (drv_status << 24) | (cam_status << 16) | scsi_status; + cmd->result = (cam_status << 16) | scsi_status; } static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd *cmd) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f743434073ac..6d5d0f5a56be 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8487,7 +8487,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n", pwr_mode, ret); - if (ret > 0 && driver_byte(ret) == DRIVER_SENSE) + if (ret > 0 && scsi_sense_valid(&sshdr)) scsi_print_sense_hdr(sdp, NULL, &sshdr); } diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 1678b6f14af9..fd69a03d6137 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) min_t(u32, virtio32_to_cpu(vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); - if (resp->sense_len) - set_driver_byte(sc, DRIVER_SENSE); + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); } sc->scsi_done(sc); diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 8a79605d9652..f0707eaad9f7 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -576,9 +576,6 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, cmd->result = (DID_RESET << 16); } else { cmd->result = (DID_OK << 16) | sdstat; - if (sdstat == SAM_STAT_CHECK_CONDITION && - cmd->sense_buffer) - cmd->result |= (DRIVER_SENSE << 24); } } else switch (btstat) { diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 2687fd7d45db..6d0b0e67e79e 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -566,7 +566,6 @@ static int tcm_loop_queue_data_or_status(const char *func, memcpy(sc->sense_buffer, se_cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); sc->result = SAM_STAT_CHECK_CONDITION; - set_driver_byte(sc, DRIVER_SENSE); } else sc->result = scsi_status; diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index a6f3267bbef6..2f7093ba5a2f 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c @@ -221,11 +221,11 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) desc[12] = regs[6]; /* device */ desc[13] = regs[7]; /* command */ - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + srb->result = SAM_STAT_CHECK_CONDITION; } goto end; invalid_fld: - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + srb->result = SAM_STAT_CHECK_CONDITION; memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 55a4763da05e..3ec038cd4332 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1401,8 +1401,7 @@ static int scsiback_queue_status(struct se_cmd *se_cmd) if (se_cmd->sense_buffer && ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) - pending_req->result = (DRIVER_SENSE << 24) | - SAM_STAT_CHECK_CONDITION; + pending_req->result = SAM_STAT_CHECK_CONDITION; else pending_req->result = se_cmd->scsi_status; diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 7327e12f3373..6e52b71b52a0 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -131,6 +131,17 @@ struct compat_sg_io_hdr { #define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ #define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ +/* + * Obsolete DRIVER_SENSE driver byte + * + * Originally the SCSI midlayer would set the DRIVER_SENSE driver byte when + * a sense code was generated and a sense buffer was allocated. + * However, as nowadays every scsi command has a sense code allocated this + * distinction became moot as one could check the sense buffer directly. + * Consequently this byte is not set anymore from the midlayer, but SG will + * keep setting this byte to be compatible with previous releases. + */ +#define DRIVER_SENSE 0x08 typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ int host_no; /* as in "scsi" where 'n' is one of 0, 1, 2 etc */ From patchwork Tue Apr 27 08:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225547 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 9B2E9C43462 for ; Tue, 27 Apr 2021 08:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62D8B600D4 for ; Tue, 27 Apr 2021 08:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235185AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:49416 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235112AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44E65B007; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 10/40] scsi: do not use DRIVER_INVALID Date: Tue, 27 Apr 2021 10:30:16 +0200 Message-Id: <20210427083046.31620-11-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no point in returning DID_ABORT together with DRIVER_INVALID, as the caller couldn't care less where the abort originated. So drop the use of DRIVER_INVALID. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- drivers/scsi/hptiop.c | 2 +- drivers/scsi/mvumi.c | 4 ++-- drivers/scsi/vmw_pvscsi.c | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index db4c7a7ff4dd..61cda7b7624f 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -760,7 +760,7 @@ static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag, goto skip_resid; default: - scp->result = DRIVER_INVALID << 24 | DID_ABORT << 16; + scp->result = DID_ABORT << 16; break; } diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index f61250545025..6bb03d7a254d 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -1320,7 +1320,7 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd, } break; default: - scmd->result |= (DRIVER_INVALID << 24) | (DID_ABORT << 16); + scmd->result |= (DID_ABORT << 16); break; } @@ -2127,7 +2127,7 @@ static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd) else atomic_dec(&mhba->fw_outstanding); - scmd->result = (DRIVER_INVALID << 24) | (DID_ABORT << 16); + scmd->result = (DID_ABORT << 16); scmd->SCp.ptr = NULL; if (scsi_bufflen(scmd)) { dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd), diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index f0707eaad9f7..f57f8bc037d2 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -601,9 +601,6 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, case BTSTAT_LUNMISMATCH: case BTSTAT_TAGREJECT: case BTSTAT_BADMSG: - cmd->result = (DRIVER_INVALID << 24); - fallthrough; - case BTSTAT_HAHARDWARE: case BTSTAT_INVPHASE: case BTSTAT_HATIMEOUT: From patchwork Tue Apr 27 08:30:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225563 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 B5558C43460 for ; Tue, 27 Apr 2021 08:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70FDB611F2 for ; Tue, 27 Apr 2021 08:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235213AbhD0IcF (ORCPT ); Tue, 27 Apr 2021 04:32:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:49412 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235146AbhD0Ibw (ORCPT ); Tue, 27 Apr 2021 04:31:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 52621B0BE; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 11/40] scsi_error: use DID_TIME_OUT instead of DRIVER_TIMEOUT Date: Tue, 27 Apr 2021 10:30:17 +0200 Message-Id: <20210427083046.31620-12-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set DID_TIME_OUT instead of DRIVER_TIMEOUT when a command is finally marked as failed after error recovery. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 0967021cc06e..689ee628eff9 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2137,10 +2137,10 @@ void scsi_eh_flush_done_q(struct list_head *done_q) /* * If just we got sense for the device (called * scsi_eh_get_sense), scmd->result is already - * set, do not set DRIVER_TIMEOUT. + * set, do not set DID_TIME_OUT. */ if (!scmd->result) - scmd->result |= (DRIVER_TIMEOUT << 24); + scmd->result |= (DID_TIME_OUT << 16); SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, "%s: flush finish cmd\n", From patchwork Tue Apr 27 08:30:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225545 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 3827FC43461 for ; Tue, 27 Apr 2021 08:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F272D600D4 for ; Tue, 27 Apr 2021 08:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235181AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:49420 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235122AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 524F8B025; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 12/40] xen-scsiback: use DID_ERROR instead of DRIVER_ERROR Date: Tue, 27 Apr 2021 10:30:18 +0200 Message-Id: <20210427083046.31620-13-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org DRIVER_ERROR was supposed to signal an error generated by the driver, which xen-scsiback arguably isn't. Also the driver bytes don't have a detailed error recovery, so we should rather return DID_ERROR instead of DRIVER_ERROR. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- drivers/xen/xen-scsiback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 3ec038cd4332..b7f0ff80efe2 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -719,10 +719,10 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info, result = DID_NO_CONNECT; break; default: - result = DRIVER_ERROR; + result = DID_ERROR; break; } - scsiback_send_response(info, NULL, result << 24, 0, + scsiback_send_response(info, NULL, result << 16, 0, ring_req.rqid); return 1; } @@ -732,7 +732,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info, if (scsiback_gnttab_data_map(&ring_req, pending_req)) { scsiback_fast_flush_area(pending_req); scsiback_do_resp_with_sense(NULL, - DRIVER_ERROR << 24, 0, pending_req); + DID_ERROR << 16, 0, pending_req); transport_generic_free_cmd(&pending_req->se_cmd, 0); } else { scsiback_cmd_exec(pending_req); @@ -747,7 +747,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info, break; default: pr_err_ratelimited("invalid request\n"); - scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24, 0, + scsiback_do_resp_with_sense(NULL, DID_ERROR << 16, 0, pending_req); transport_generic_free_cmd(&pending_req->se_cmd, 0); break; From patchwork Tue Apr 27 08:30:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225555 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 2AB55C43461 for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD84E60234 for ; Tue, 27 Apr 2021 08:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235209AbhD0IcD (ORCPT ); Tue, 27 Apr 2021 04:32:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:49442 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235140AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4E4A0B024; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 13/40] xen-scsifront: compability status handling Date: Tue, 27 Apr 2021 10:30:19 +0200 Message-Id: <20210427083046.31620-14-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The Xen guest might run against arbitrary backends, so the driver might receive a status with driver_byte set. Map these errors to DID_ERROR to be consistent with recent changes. Signed-off-by: Hannes Reinecke --- drivers/scsi/xen-scsifront.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 259fc248d06c..ec9d399fbbd8 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -251,6 +251,7 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info, struct scsi_cmnd *sc; uint32_t id; uint8_t sense_len; + int result; id = ring_rsp->rqid; shadow = info->shadow[id]; @@ -261,7 +262,12 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info, scsifront_gnttab_done(info, shadow); scsifront_put_rqid(info, id); - sc->result = ring_rsp->rslt; + result = ring_rsp->rslt; + if (result >> 24) + set_host_byte(sc, DID_ERROR); + else + set_host_byte(sc, host_byte(result)); + set_status_byte(sc, result & 0xff); scsi_set_resid(sc, ring_rsp->residual_len); sense_len = min_t(uint8_t, VSCSIIF_SENSE_BUFFERSIZE, From patchwork Tue Apr 27 08:30:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225561 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 CFCA1C433ED for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 961F660234 for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235211AbhD0IcE (ORCPT ); Tue, 27 Apr 2021 04:32:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:49444 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235145AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4DE1AB023; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 14/40] scsi: Drop the now obsolete driver_byte definitions Date: Tue, 27 Apr 2021 10:30:20 +0200 Message-Id: <20210427083046.31620-15-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke The driver_byte field in the result is now unused, so we can drop the definitions. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- Documentation/scsi/scsi_mid_low_api.rst | 3 +-- block/bsg-lib.c | 2 +- block/bsg.c | 2 +- block/scsi_ioctl.c | 2 +- drivers/scsi/constants.c | 15 --------------- drivers/scsi/scsi_logging.c | 10 ++-------- drivers/scsi/sd.c | 9 ++++----- drivers/scsi/sr.c | 2 +- drivers/scsi/sr_ioctl.c | 2 +- drivers/scsi/st.c | 4 ++-- drivers/xen/xen-scsiback.c | 4 ++-- include/scsi/scsi.h | 16 ---------------- include/scsi/scsi_cmnd.h | 4 ---- include/scsi/sg.h | 2 ++ include/trace/events/scsi.h | 15 +-------------- 15 files changed, 19 insertions(+), 73 deletions(-) diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 5bc17d012b25..2c87eaa36296 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -1178,8 +1178,7 @@ Members of interest: target device). 'result' is a 32 bit unsigned integer that can be viewed as 4 related bytes. The SCSI status value is in the LSB. See include/scsi/scsi.h status_byte(), - msg_byte(), host_byte() and driver_byte() macros and - related constants. + msg_byte() and host_byte() macros and related constants. sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that should be written when the SCSI status (LSB of 'result') diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 330fede77271..cf1811261722 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c @@ -84,7 +84,7 @@ static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr) */ hdr->device_status = job->result & 0xff; hdr->transport_status = host_byte(job->result); - hdr->driver_status = driver_byte(job->result); + hdr->driver_status = 0; hdr->info = 0; if (hdr->device_status || hdr->transport_status || hdr->driver_status) hdr->info |= SG_INFO_CHECK; diff --git a/block/bsg.c b/block/bsg.c index 9e6ff0d71d25..33e3f82ed03a 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -96,7 +96,7 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr) */ hdr->device_status = sreq->result & 0xff; hdr->transport_status = host_byte(sreq->result); - hdr->driver_status = driver_byte(sreq->result); + hdr->driver_status = 0; if (scsi_status_is_check_condition(sreq->result)) hdr->driver_status = DRIVER_SENSE; hdr->info = 0; diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index b6b3541c6406..4dd61e36ee29 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -256,7 +256,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, hdr->masked_status = status_byte(req->result); hdr->msg_status = msg_byte(req->result); hdr->host_status = host_byte(req->result); - hdr->driver_status = driver_byte(req->result); + hdr->driver_status = 0; if (scsi_status_is_check_condition(hdr->status)) hdr->driver_status = DRIVER_SENSE; hdr->info = 0; diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 84d73f57292b..41bcfed08260 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -406,10 +406,6 @@ static const char * const hostbyte_table[]={ "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", "DID_NEXUS_FAILURE", "DID_ALLOC_FAILURE", "DID_MEDIUM_ERROR" }; -static const char * const driverbyte_table[]={ -"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", -"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; - const char *scsi_hostbyte_string(int result) { const char *hb_string = NULL; @@ -421,17 +417,6 @@ const char *scsi_hostbyte_string(int result) } EXPORT_SYMBOL(scsi_hostbyte_string); -const char *scsi_driverbyte_string(int result) -{ - const char *db_string = NULL; - int db = driver_byte(result); - - if (db < ARRAY_SIZE(driverbyte_table)) - db_string = driverbyte_table[db]; - return db_string; -} -EXPORT_SYMBOL(scsi_driverbyte_string); - #define scsi_mlreturn_name(result) { result, #result } static const struct value_name_pair scsi_mlreturn_arr[] = { scsi_mlreturn_name(NEEDS_RETRY), diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c index 8ea44c6595ef..2317717935e9 100644 --- a/drivers/scsi/scsi_logging.c +++ b/drivers/scsi/scsi_logging.c @@ -385,7 +385,6 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, size_t off, logbuf_len; const char *mlret_string = scsi_mlreturn_string(disposition); const char *hb_string = scsi_hostbyte_string(cmd->result); - const char *db_string = scsi_driverbyte_string(cmd->result); unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ; logbuf = scsi_log_reserve_buffer(&logbuf_len); @@ -426,13 +425,8 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, if (WARN_ON(off >= logbuf_len)) goto out_printk; - if (db_string) - off += scnprintf(logbuf + off, logbuf_len - off, - "driverbyte=%s ", db_string); - else - off += scnprintf(logbuf + off, logbuf_len - off, - "driverbyte=0x%02x ", - driver_byte(cmd->result)); + off += scnprintf(logbuf + off, logbuf_len - off, + "driverbyte=DRIVER_OK "); off += scnprintf(logbuf + off, logbuf_len - off, "cmd_age=%lus", cmd_age); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 66cb161667af..20739072f21a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3810,15 +3810,14 @@ void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result) { const char *hb_string = scsi_hostbyte_string(result); - const char *db_string = scsi_driverbyte_string(result); - if (hb_string || db_string) + if (hb_string) sd_printk(KERN_INFO, sdkp, "%s: Result: hostbyte=%s driverbyte=%s\n", msg, hb_string ? hb_string : "invalid", - db_string ? db_string : "invalid"); + "DRIVER_OK"); else sd_printk(KERN_INFO, sdkp, - "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n", - msg, host_byte(result), driver_byte(result)); + "%s: Result: hostbyte=0x%02x driverbyte=%s\n", + msg, host_byte(result), "DRIVER_OK"); } diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 9b2ccf0c9a8c..e9cb874f6891 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -338,7 +338,7 @@ static int sr_done(struct scsi_cmnd *SCpnt) * care is taken to avoid unnecessary additional work such as * memcpy's that could be avoided. */ - if (driver_byte(result) != 0 && /* An error occurred */ + if (status_byte(result) == SAM_STAT_CHECK_CONDITION && (SCpnt->sense_buffer[0] & 0x7f) == 0x70) { /* Sense current */ switch (SCpnt->sense_buffer[2]) { case MEDIUM_ERROR: diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index a78f2138d784..74348ead5b11 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -209,7 +209,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) err = result; goto out; } - if (driver_byte(result) != 0) { + if (status_byte(result) == SAM_STAT_CHECK_CONDITION) { switch (sshdr->sense_key) { case UNIT_ATTENTION: SDev->changed = 1; diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 23be6447e576..8ab12d07de31 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -390,8 +390,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) if (!debugging) { /* Abnormal conditions for tape */ if (!cmdstatp->have_sense) st_printk(KERN_WARNING, STp, - "Error %x (driver bt 0x%x, host bt 0x%x).\n", - result, driver_byte(result), host_byte(result)); + "Error %x (driver bt 0, host bt 0x%x).\n", + result, host_byte(result)); else if (cmdstatp->have_sense && scode != NO_SENSE && scode != RECOVERED_ERROR && diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index b7f0ff80efe2..a6bb2600a2d7 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -222,10 +222,10 @@ static void scsiback_print_status(char *sense_buffer, int errors, { struct scsiback_tpg *tpg = pending_req->v2p->tpg; - pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=%02x\n", + pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x\n", tpg->tport->tport_name, pending_req->v2p->lun, pending_req->cmnd[0], status_byte(errors), msg_byte(errors), - host_byte(errors), driver_byte(errors)); + host_byte(errors)); } static void scsiback_fast_flush_area(struct vscsibk_pend *req) diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 2c2d59251ef1..59c5e729f40c 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -181,20 +181,6 @@ static inline int scsi_is_wlun(u64 lun) #define DID_TRANSPORT_MARGINAL 0x14 /* Transport marginal errors */ #define DRIVER_OK 0x00 /* Driver status */ -/* - * These indicate the error that occurred, and what is available. - */ - -#define DRIVER_BUSY 0x01 -#define DRIVER_SOFT 0x02 -#define DRIVER_MEDIA 0x03 -#define DRIVER_ERROR 0x04 - -#define DRIVER_INVALID 0x05 -#define DRIVER_TIMEOUT 0x06 -#define DRIVER_HARD 0x07 -#define DRIVER_SENSE 0x08 - /* * Internal return values. */ @@ -226,12 +212,10 @@ enum scsi_disposition { * status byte = set from target device * msg_byte = return status from host adapter itself. * host_byte = set by low-level driver to indicate status. - * driver_byte = set by mid-level. */ #define status_byte(result) (((result) >> 1) & 0x7f) #define msg_byte(result) (((result) >> 8) & 0xff) #define host_byte(result) (((result) >> 16) & 0xff) -#define driver_byte(result) (((result) >> 24) & 0xff) #define sense_class(sense) (((sense) >> 4) & 0x7) #define sense_error(sense) ((sense) & 0xf) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index b3eaf4b74b72..a1eb7732aa1b 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -326,10 +326,6 @@ static inline void set_host_byte(struct scsi_cmnd *cmd, char status) cmd->result = (cmd->result & 0xff00ffff) | (status << 16); } -static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) -{ - cmd->result = (cmd->result & 0x00ffffff) | (status << 24); -} static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) { diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 6e52b71b52a0..f6b18591ed9d 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -142,6 +142,8 @@ struct compat_sg_io_hdr { * keep setting this byte to be compatible with previous releases. */ #define DRIVER_SENSE 0x08 +/* Obsolete driver_byte() declaration */ +#define driver_byte(result) (((result) >> 24) & 0xff) typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ int host_no; /* as in "scsi" where 'n' is one of 0, 1, 2 etc */ diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index f624969a4f14..428cca71c2ba 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -124,19 +124,6 @@ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \ scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) -#define scsi_driverbyte_name(result) { result, #result } -#define show_driverbyte_name(val) \ - __print_symbolic(val, \ - scsi_driverbyte_name(DRIVER_OK), \ - scsi_driverbyte_name(DRIVER_BUSY), \ - scsi_driverbyte_name(DRIVER_SOFT), \ - scsi_driverbyte_name(DRIVER_MEDIA), \ - scsi_driverbyte_name(DRIVER_ERROR), \ - scsi_driverbyte_name(DRIVER_INVALID), \ - scsi_driverbyte_name(DRIVER_TIMEOUT), \ - scsi_driverbyte_name(DRIVER_HARD), \ - scsi_driverbyte_name(DRIVER_SENSE)) - #define scsi_msgbyte_name(result) { result, #result } #define show_msgbyte_name(val) \ __print_symbolic(val, \ @@ -327,7 +314,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), - show_driverbyte_name(((__entry->result) >> 24) & 0xff), + "DRIVER_OK", show_hostbyte_name(((__entry->result) >> 16) & 0xff), show_msgbyte_name(((__entry->result) >> 8) & 0xff), show_statusbyte_name(__entry->result & 0xff)) From patchwork Tue Apr 27 08:30:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225573 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 ADC21C433B4 for ; Tue, 27 Apr 2021 08:31:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7788F600D4 for ; Tue, 27 Apr 2021 08:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235231AbhD0IcO (ORCPT ); Tue, 27 Apr 2021 04:32:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:49662 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbhD0IcA (ORCPT ); Tue, 27 Apr 2021 04:32:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 71B16B0EA; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 15/40] NCR5380: Fold SCSI message ABORT onto DID_ABORT Date: Tue, 27 Apr 2021 10:30:21 +0200 Message-Id: <20210427083046.31620-16-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The message byte can take only two values, COMMAND_COMPLETE and ABORT. So we can easily map ABORT to DID_ABORT and do not set the message byte. Signed-off-by: Hannes Reinecke --- drivers/scsi/NCR5380.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index d7594b794d3c..a74674941e7d 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -1815,6 +1815,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) switch (tmp) { case ABORT: + set_host_byte(cmd, DID_ABORT); + /* fallthrough */ case COMMAND_COMPLETE: /* Accept message by clearing ACK */ sink = 1; @@ -1826,9 +1828,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) hostdata->connected = NULL; hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); - cmd->result &= ~0xffff; - cmd->result |= cmd->SCp.Status; - cmd->result |= cmd->SCp.Message << 8; + set_status_byte(cmd, cmd->SCp.Status); set_resid_from_SCp(cmd); From patchwork Tue Apr 27 08:30:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225567 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 58D60C433B4 for ; Tue, 27 Apr 2021 08:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CC006113D for ; Tue, 27 Apr 2021 08:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235225AbhD0IcL (ORCPT ); Tue, 27 Apr 2021 04:32:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:49410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235166AbhD0Ib5 (ORCPT ); Tue, 27 Apr 2021 04:31:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 60DACB0D0; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 16/40] scsi: add get_{status,host}_byte() accessor function Date: Tue, 27 Apr 2021 10:30:22 +0200 Message-Id: <20210427083046.31620-17-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add accessor functions for the host and status byte. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- include/scsi/scsi_cmnd.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index a1eb7732aa1b..2c7b4102aa14 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -316,6 +316,11 @@ static inline void set_status_byte(struct scsi_cmnd *cmd, char status) cmd->result = (cmd->result & 0xffffff00) | status; } +static inline u8 get_status_byte(struct scsi_cmnd *cmd) +{ + return cmd->result & 0xff; +} + static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) { cmd->result = (cmd->result & 0xffff00ff) | (status << 8); @@ -326,6 +331,11 @@ static inline void set_host_byte(struct scsi_cmnd *cmd, char status) cmd->result = (cmd->result & 0xff00ffff) | (status << 16); } +static inline u8 get_host_byte(struct scsi_cmnd *cmd) +{ + return (cmd->result >> 16) & 0xff; +} + static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) { From patchwork Tue Apr 27 08:30:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225575 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 37D9EC43470 for ; Tue, 27 Apr 2021 08:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06361600EF for ; Tue, 27 Apr 2021 08:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235236AbhD0IcP (ORCPT ); Tue, 27 Apr 2021 04:32:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:49422 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235182AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7DCBFB123; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 17/40] scsi: add scsi_msg_to_host_byte() Date: Tue, 27 Apr 2021 10:30:23 +0200 Message-Id: <20210427083046.31620-18-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add helper to convert message byte into a host byte code. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- include/scsi/scsi_cmnd.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 2c7b4102aa14..69055c2044ff 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -336,6 +336,32 @@ static inline u8 get_host_byte(struct scsi_cmnd *cmd) return (cmd->result >> 16) & 0xff; } +/** + * scsi_msg_to_host_byte() - translate message byte + * + * Translate the SCSI parallel message byte to a matching + * host byte setting. A message of COMMAND_COMPLETE indicates + * a successful command execution, any other message indicate + * an error. As the messages themselves only have a meaning + * for the SCSI parallel protocol this function translates + * them into a matching host byte value for SCSI EH. + */ +static inline void scsi_msg_to_host_byte(struct scsi_cmnd *cmd, u8 msg) +{ + switch (msg) { + case COMMAND_COMPLETE: + break; + case ABORT_TASK_SET: + set_host_byte(cmd, DID_ABORT); + break; + case TARGET_RESET: + set_host_byte(cmd, DID_RESET); + break; + default: + set_host_byte(cmd, DID_ERROR); + break; + } +} static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) { From patchwork Tue Apr 27 08:30:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225565 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 DB5E2C43470 for ; Tue, 27 Apr 2021 08:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F1506100B for ; Tue, 27 Apr 2021 08:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235221AbhD0IcG (ORCPT ); Tue, 27 Apr 2021 04:32:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:49452 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235153AbhD0Ibw (ORCPT ); Tue, 27 Apr 2021 04:31:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 74907B10B; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 18/40] dc395: use standard macros to set SCSI result Date: Tue, 27 Apr 2021 10:30:24 +0200 Message-Id: <20210427083046.31620-19-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use standard macros to set the SCSI result and drop the internal ones. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/dc395x.c | 76 ++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index a713fe605dda..598448ece8d0 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -160,22 +160,6 @@ #define DC395x_write16(acb,address,value) outw((value), acb->io_port_base + (address)) #define DC395x_write32(acb,address,value) outl((value), acb->io_port_base + (address)) -/* cmd->result */ -#define RES_TARGET 0x000000FF /* Target State */ -#define RES_TARGET_LNX STATUS_MASK /* Only official ... */ -#define RES_ENDMSG 0x0000FF00 /* End Message */ -#define RES_DID 0x00FF0000 /* DID_ codes */ -#define RES_DRV 0xFF000000 /* DRIVER_ codes */ - -#define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)) -#define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1) - -#define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); } -#define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; } -#define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; } -#define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; } -#define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; } - #define TAG_NONE 255 /* @@ -986,7 +970,7 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s cmd, cmd->device->id, (u8)cmd->device->lun, cmd->cmnd[0]); /* Assume BAD_TARGET; will be cleared later */ - cmd->result = DID_BAD_TARGET << 16; + set_host_byte(cmd, DID_BAD_TARGET); /* ignore invalid targets */ if (cmd->device->id >= acb->scsi_host->max_id || @@ -1013,7 +997,8 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s /* set callback and clear result in the command */ cmd->scsi_done = done; - cmd->result = 0; + set_host_byte(cmd, DID_OK); + set_status_byte(cmd, SAM_STAT_GOOD); srb = list_first_entry_or_null(&acb->srb_free_list, struct ScsiReqBlk, list); @@ -1250,7 +1235,7 @@ static int dc395x_eh_abort(struct scsi_cmnd *cmd) free_tag(dcb, srb); list_add_tail(&srb->list, &acb->srb_free_list); dprintkl(KERN_DEBUG, "eh_abort: Command was waiting\n"); - cmd->result = DID_ABORT << 16; + set_host_byte(cmd, DID_ABORT); return SUCCESS; } srb = find_cmd(cmd, &dcb->srb_going_list); @@ -3178,6 +3163,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, srb, scsi_sg_count(cmd), srb->sg_index, srb->sg_count, scsi_sgtalbe(cmd)); status = srb->target_status; + set_host_byte(cmd, DID_OK); + set_status_byte(cmd, SAM_STAT_GOOD); if (srb->flag & AUTO_REQSENSE) { dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE1\n"); pci_unmap_srb_sense(acb, srb); @@ -3186,7 +3173,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, */ srb->flag &= ~AUTO_REQSENSE; srb->adapter_status = 0; - srb->target_status = CHECK_CONDITION << 1; + srb->target_status = SAM_STAT_CHECK_CONDITION; if (debug_enabled(DBG_1)) { switch (cmd->sense_buffer[2] & 0x0f) { case NOT_READY: @@ -3233,15 +3220,14 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, *((unsigned int *)(cmd->sense_buffer + 3))); } - if (status == (CHECK_CONDITION << 1)) { - cmd->result = DID_BAD_TARGET << 16; + if (status == SAM_STAT_CHECK_CONDITION) { + set_host_byte(cmd, DID_BAD_TARGET); goto ckc_e; } dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); - cmd->result = - MK_RES(0, DID_OK, - srb->end_message, SAM_STAT_CHECK_CONDITION); + set_msg_byte(cmd, srb->end_message); + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); goto ckc_e; } @@ -3251,10 +3237,10 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, /* * target status.......................... */ - if (status >> 1 == CHECK_CONDITION) { + if (status == SAM_STAT_CHECK_CONDITION) { request_sense(acb, dcb, srb); return; - } else if (status >> 1 == QUEUE_FULL) { + } else if (status == SAM_STAT_TASK_SET_FULL) { tempcnt = (u8)list_size(&dcb->srb_going_list); dprintkl(KERN_INFO, "QUEUE_FULL for dev <%02i-%i> with %i cmnds\n", dcb->target_id, dcb->target_lun, tempcnt); @@ -3270,13 +3256,12 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } else if (status == SCSI_STAT_SEL_TIMEOUT) { srb->adapter_status = H_SEL_TIMEOUT; srb->target_status = 0; - cmd->result = DID_NO_CONNECT << 16; + set_host_byte(cmd, DID_NO_CONNECT); } else { srb->adapter_status = 0; - SET_RES_DID(cmd->result, DID_ERROR); - SET_RES_MSG(cmd->result, srb->end_message); - SET_RES_TARGET(cmd->result, status); - + set_host_byte(cmd, DID_ERROR); + set_msg_byte(cmd, srb->end_message); + set_status_byte(cmd, status); } } else { /* @@ -3285,16 +3270,14 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, status = srb->adapter_status; if (status & H_OVER_UNDER_RUN) { srb->target_status = 0; - SET_RES_DID(cmd->result, DID_OK); - SET_RES_MSG(cmd->result, srb->end_message); + set_msg_byte(cmd, srb->end_message); } else if (srb->status & PARITY_ERROR) { - SET_RES_DID(cmd->result, DID_PARITY); - SET_RES_MSG(cmd->result, srb->end_message); + set_host_byte(cmd, DID_PARITY); + set_msg_byte(cmd, srb->end_message); } else { /* No error */ srb->adapter_status = 0; srb->target_status = 0; - SET_RES_DID(cmd->result, DID_OK); } } @@ -3315,15 +3298,15 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, base = scsi_kmap_atomic_sg(sg, scsi_sg_count(cmd), &offset, &len); ptr = (struct ScsiInqData *)(base + offset); - if (!ckc_only && (cmd->result & RES_DID) == 0 + if (!ckc_only && get_host_byte(cmd) == DID_OK && cmd->cmnd[2] == 0 && scsi_bufflen(cmd) >= 8 && dir != DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2) dcb->inquiry7 = ptr->Flags; /*if( srb->cmd->cmnd[0] == INQUIRY && */ /* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */ - if ((cmd->result == (DID_OK << 16) || - status_byte(cmd->result) == CHECK_CONDITION)) { + if ((get_host_byte(cmd) == DID_OK) || + (get_status_byte(cmd) == SAM_STAT_CHECK_CONDITION)) { if (!dcb->init_tcq_flag) { add_dev(acb, dcb, ptr); dcb->init_tcq_flag = 1; @@ -3350,7 +3333,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, if (srb != acb->tmp_srb) { /* Add to free list */ dprintkdbg(DBG_0, "srb_done: (0x%p) done result=0x%08x\n", - cmd, cmd->result); + cmd, cmd->result); list_move_tail(&srb->list, &acb->srb_free_list); } else { dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n"); @@ -3374,16 +3357,14 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, struct scsi_cmnd *p; list_for_each_entry_safe(srb, tmp, &dcb->srb_going_list, list) { - int result; - p = srb->cmd; - result = MK_RES(0, did_flag, 0, 0); printk("G:%p(%02i-%i) ", p, p->device->id, (u8)p->device->lun); list_del(&srb->list); free_tag(dcb, srb); list_add_tail(&srb->list, &acb->srb_free_list); - p->result = result; + set_host_byte(p, did_flag); + set_status_byte(p, SAM_STAT_GOOD); pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); if (force) { @@ -3404,14 +3385,13 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, /* Waiting queue */ list_for_each_entry_safe(srb, tmp, &dcb->srb_waiting_list, list) { - int result; p = srb->cmd; - result = MK_RES(0, did_flag, 0, 0); printk("W:%p<%02i-%i>", p, p->device->id, (u8)p->device->lun); list_move_tail(&srb->list, &acb->srb_free_list); - p->result = result; + set_host_byte(p, did_flag); + set_status_byte(p, SAM_STAT_GOOD); pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); if (force) { From patchwork Tue Apr 27 08:30:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225577 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 53DF4C43461 for ; Tue, 27 Apr 2021 08:31:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24A59600EF for ; Tue, 27 Apr 2021 08:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235235AbhD0IcP (ORCPT ); Tue, 27 Apr 2021 04:32:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:49680 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7D40BB122; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 19/40] dc395: translate message bytes Date: Tue, 27 Apr 2021 10:30:25 +0200 Message-Id: <20210427083046.31620-20-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Drop message byte setting if the host byte is already set, and translate message bytes into the related host bytes when evaluating an overrun or underrun. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/dc395x.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 598448ece8d0..24c7cefb0b78 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -3226,7 +3226,6 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); - set_msg_byte(cmd, srb->end_message); set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); goto ckc_e; @@ -3260,7 +3259,6 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } else { srb->adapter_status = 0; set_host_byte(cmd, DID_ERROR); - set_msg_byte(cmd, srb->end_message); set_status_byte(cmd, status); } } else { @@ -3270,10 +3268,9 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, status = srb->adapter_status; if (status & H_OVER_UNDER_RUN) { srb->target_status = 0; - set_msg_byte(cmd, srb->end_message); + scsi_msg_to_host_byte(cmd, srb->end_message); } else if (srb->status & PARITY_ERROR) { set_host_byte(cmd, DID_PARITY); - set_msg_byte(cmd, srb->end_message); } else { /* No error */ srb->adapter_status = 0; From patchwork Tue Apr 27 08:30:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225557 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 339C7C433B4 for ; Tue, 27 Apr 2021 08:31:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0544860234 for ; Tue, 27 Apr 2021 08:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235145AbhD0IcF (ORCPT ); Tue, 27 Apr 2021 04:32:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:49446 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235144AbhD0Ibv (ORCPT ); Tue, 27 Apr 2021 04:31:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 74F98B114; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 20/40] qlogicfas408: make ql_pcmd() a void function Date: Tue, 27 Apr 2021 10:30:26 +0200 Message-Id: <20210427083046.31620-21-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make ql_pcmd() a void function and set the SCSI result directly. Signed-off-by: Hannes Reinecke --- drivers/scsi/qlogicfas408.c | 75 ++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 136681ad18a5..a1eabdc7db09 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -256,7 +256,7 @@ static void ql_icmd(struct scsi_cmnd *cmd) * Process scsi command - usually after interrupt */ -static unsigned int ql_pcmd(struct scsi_cmnd *cmd) +static void ql_pcmd(struct scsi_cmnd *cmd) { unsigned int i, j; unsigned long k; @@ -274,13 +274,15 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) j = inb(qbase + 6); i = inb(qbase + 5); if (i == 0x20) { - return (DID_NO_CONNECT << 16); + set_host_byte(cmd, DID_NO_CONNECT); + return; } i |= inb(qbase + 5); /* the 0x10 bit can be set after the 0x08 */ if (i != 0x18) { printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i); ql_zap(priv); - return (DID_BAD_INTR << 16); + set_host_byte(cmd, DID_BAD_INTR); + return; } j &= 7; /* j = inb( qbase + 7 ) >> 5; */ @@ -293,9 +295,10 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n", j, i, inb(qbase + 7) & 0x1f); ql_zap(priv); - return (DID_ERROR << 16); + set_host_byte (cmd, DID_ERROR); + return; } - result = DID_OK; + if (inb(qbase + 7) & 0x1f) /* if some bytes in fifo */ outb(1, qbase + 3); /* clear fifo */ /* note that request_bufflen is the total xfer size when sg is used */ @@ -314,21 +317,24 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { if (priv->qabort) { REG0; - return ((priv->qabort == 1 ? - DID_ABORT : DID_RESET) << 16); + set_host_byte(cmd, + priv->qabort == 1 ? + DID_ABORT : DID_RESET); } buf = sg_virt(sg); if (ql_pdma(priv, phase, buf, sg->length)) break; } REG0; - rtrc(2) + rtrc(2); /* * Wait for irq (split into second state of irq handler * if this can take time) */ - if ((k = ql_wai(priv))) - return (k << 16); + if ((k = ql_wai(priv))) { + set_host_byte(cmd, k); + return; + } k = inb(qbase + 5); /* should be 0x10, bus service */ } @@ -344,19 +350,25 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) if (time_after_eq(jiffies, k)) { ql_zap(priv); - return (DID_TIME_OUT << 16); + set_host_byte(cmd, DID_TIME_OUT); + return; } /* FIXME: timeout ?? */ while (inb(qbase + 5)) cpu_relax(); /* clear pending ints */ - if (priv->qabort) - return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); + if (priv->qabort) { + set_host_byte(cmd, + priv->qabort == 1 ? DID_ABORT : DID_RESET); + return; + } outb(0x11, qbase + 3); /* get status and message */ - if ((k = ql_wai(priv))) - return (k << 16); + if ((k = ql_wai(priv))) { + set_host_byte(cmd, k); + return; + } i = inb(qbase + 5); /* get chip irq stat */ j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */ status = inb(qbase + 2); @@ -368,12 +380,14 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) */ if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) { printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j); - result = DID_ERROR; + set_host_byte(cmd, DID_ERROR); } outb(0x12, qbase + 3); /* done, disconnect */ - rtrc(1) - if ((k = ql_wai(priv))) - return (k << 16); + rtrc(1); + if ((k = ql_wai(priv))) { + set_host_byte(cmd, k); + return; + } /* * Should get bus service interrupt and disconnect interrupt @@ -385,12 +399,18 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) cpu_relax(); i |= inb(qbase + 5); } - rtrc(0) + rtrc(0); - if (priv->qabort) - return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); - - return (result << 16) | (message << 8) | (status & STATUS_MASK); + if (priv->qabort) { + set_host_byte(cmd, + priv->qabort == 1 ? DID_ABORT : DID_RESET); + return; + } + + set_host_byte(cmd, result); + set_msg_byte(cmd, message); + set_status_byte(cmd, status); + return; } /* @@ -415,7 +435,7 @@ static void ql_ihandl(void *dev_id) return; } icmd = priv->qlcmd; - icmd->result = ql_pcmd(icmd); + ql_pcmd(icmd); priv->qlcmd = NULL; /* * If result is CHECK CONDITION done calls qcommand to request @@ -443,8 +463,11 @@ static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *)) { struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + + set_host_byte(cmd, DID_OK); + set_status_byte(cmd, SAM_STAT_GOOD); if (scmd_id(cmd) == priv->qinitid) { - cmd->result = DID_BAD_TARGET << 16; + set_host_byte(cmd, DID_BAD_TARGET); done(cmd); return 0; } From patchwork Tue Apr 27 08:30:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225571 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 59565C433ED for ; Tue, 27 Apr 2021 08:31:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E3F7600EF for ; Tue, 27 Apr 2021 08:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235172AbhD0IcO (ORCPT ); Tue, 27 Apr 2021 04:32:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:49420 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235174AbhD0IcA (ORCPT ); Tue, 27 Apr 2021 04:32:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7B379B118; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 21/40] qlogicfas408: whitespace cleanup Date: Tue, 27 Apr 2021 10:30:27 +0200 Message-Id: <20210427083046.31620-22-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Hannes Reinecke --- drivers/scsi/qlogicfas408.c | 61 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index a1eabdc7db09..86de400ca81a 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -4,9 +4,9 @@ Use at your own risk. Support Tort Reform so you won't have to read all these silly disclaimers. - Copyright 1994, Tom Zerucha. + Copyright 1994, Tom Zerucha. tz@execpc.com - + Additional Code, and much appreciated help by Michael A. Griffith grif@cs.ucr.edu @@ -22,12 +22,12 @@ Functions as standalone, loadable, and PCMCIA driver, the latter from Dave Hinds' PCMCIA package. - + Cleaned up 26/10/2002 by Alan Cox as part of the 2.5 SCSI driver cleanup and audit. This driver still needs work on the following - - Non terminating hardware waits - - Some layering violations with its pcmcia stub + - Non terminating hardware waits + - Some layering violations with its pcmcia stub Redistributable under terms of the GNU General Public License @@ -92,8 +92,9 @@ static void ql_zap(struct qlogicfas408_priv *priv) /* * Do a pseudo-dma tranfer */ - -static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int reqlen) + +static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, + int reqlen) { int j; int qbase = priv->qbase; @@ -108,7 +109,7 @@ static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int request += 128; } while (reqlen >= 84 && !(j & 0xc0)) /* 2/3 */ - if ((j = inb(qbase + 8)) & 4) + if ((j = inb(qbase + 8)) & 4) { insl(qbase + 4, request, 21); reqlen -= 84; @@ -123,11 +124,11 @@ static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int /* until both empty and int (or until reclen is 0) */ rtrc(7) j = 0; - while (reqlen && !((j & 0x10) && (j & 0xc0))) + while (reqlen && !((j & 0x10) && (j & 0xc0))) { /* while bytes to receive and not empty */ j &= 0xc0; - while (reqlen && !((j = inb(qbase + 8)) & 0x10)) + while (reqlen && !((j = inb(qbase + 8)) & 0x10)) { *request++ = inb(qbase + 4); reqlen--; @@ -161,7 +162,7 @@ static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int j = 0; while (reqlen && !((j & 2) && (j & 0xc0))) { /* while bytes to send and not full */ - while (reqlen && !((j = inb(qbase + 8)) & 2)) + while (reqlen && !((j = inb(qbase + 8)) & 2)) { outb(*request++, qbase + 4); reqlen--; @@ -175,7 +176,7 @@ static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int } /* - * Wait for interrupt flag (polled - not real hardware interrupt) + * Wait for interrupt flag (polled - not real hardware interrupt) */ static int ql_wai(struct qlogicfas408_priv *priv) @@ -205,14 +206,14 @@ static int ql_wai(struct qlogicfas408_priv *priv) } /* - * Initiate scsi command - queueing handler + * Initiate scsi command - queueing handler * caller must hold host lock */ static void ql_icmd(struct scsi_cmnd *cmd) { struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); - int qbase = priv->qbase; + int qbase = priv->qbase; int int_type = priv->int_type; unsigned int i; @@ -253,7 +254,7 @@ static void ql_icmd(struct scsi_cmnd *cmd) } /* - * Process scsi command - usually after interrupt + * Process scsi command - usually after interrupt */ static void ql_pcmd(struct scsi_cmnd *cmd) @@ -329,7 +330,7 @@ static void ql_pcmd(struct scsi_cmnd *cmd) rtrc(2); /* * Wait for irq (split into second state of irq handler - * if this can take time) + * if this can take time) */ if ((k = ql_wai(priv))) { set_host_byte(cmd, k); @@ -339,9 +340,9 @@ static void ql_pcmd(struct scsi_cmnd *cmd) } /* - * Enter Status (and Message In) Phase + * Enter Status (and Message In) Phase */ - + k = jiffies + WATCHDOG; while (time_before(jiffies, k) && !priv->qabort && @@ -375,8 +376,8 @@ static void ql_pcmd(struct scsi_cmnd *cmd) message = inb(qbase + 2); /* - * Should get function complete int if Status and message, else - * bus serv if only status + * Should get function complete int if Status and message, else + * bus serv if only status */ if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) { printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j); @@ -390,9 +391,9 @@ static void ql_pcmd(struct scsi_cmnd *cmd) } /* - * Should get bus service interrupt and disconnect interrupt + * Should get bus service interrupt and disconnect interrupt */ - + i = inb(qbase + 5); /* should be bus service */ while (!priv->qabort && ((i & 0x20) != 0x20)) { barrier(); @@ -414,7 +415,7 @@ static void ql_pcmd(struct scsi_cmnd *cmd) } /* - * Interrupt handler + * Interrupt handler */ static void ql_ihandl(void *dev_id) @@ -438,8 +439,8 @@ static void ql_ihandl(void *dev_id) ql_pcmd(icmd); priv->qlcmd = NULL; /* - * If result is CHECK CONDITION done calls qcommand to request - * sense + * If result is CHECK CONDITION done calls qcommand to request + * sense */ (icmd->scsi_done) (icmd); } @@ -484,8 +485,8 @@ static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd, DEF_SCSI_QCMD(qlogicfas408_queuecommand) -/* - * Return bios parameters +/* + * Return bios parameters */ int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev, @@ -510,7 +511,7 @@ int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev, /* * Abort a command in progress */ - + int qlogicfas408_abort(struct scsi_cmnd *cmd) { struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); @@ -589,9 +590,9 @@ void qlogicfas408_setup(int qbase, int id, int int_type) int qlogicfas408_detect(int qbase, int int_type) { - REG1; + REG1; return (((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7) && - ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); + ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); } /* From patchwork Tue Apr 27 08:30:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225579 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 24D43C43460 for ; Tue, 27 Apr 2021 08:31:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1382606A5 for ; Tue, 27 Apr 2021 08:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235233AbhD0IcP (ORCPT ); Tue, 27 Apr 2021 04:32:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:49416 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235179AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 827E2B124; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 22/40] qlogicfas408: translate message to host byte status Date: Tue, 27 Apr 2021 10:30:28 +0200 Message-Id: <20210427083046.31620-23-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to the appropriate host byte. As error recovery would return DID_ERROR for any non-zero message byte the translation doesn't change the error handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/qlogicfas408.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 86de400ca81a..34546cb99ccd 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -409,7 +409,8 @@ static void ql_pcmd(struct scsi_cmnd *cmd) } set_host_byte(cmd, result); - set_msg_byte(cmd, message); + if (result == DID_OK && message != COMMAND_COMPLETE) + scsi_msg_to_host_byte(cmd, message); set_status_byte(cmd, status); return; } From patchwork Tue Apr 27 08:30:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225595 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 1C4B7C433B4 for ; Tue, 27 Apr 2021 08:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E130B611F2 for ; Tue, 27 Apr 2021 08:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235255AbhD0IcX (ORCPT ); Tue, 27 Apr 2021 04:32:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:49710 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235186AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 83654B127; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 23/40] nsp32: whitespace cleanup Date: Tue, 27 Apr 2021 10:30:29 +0200 Message-Id: <20210427083046.31620-24-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Hannes Reinecke --- drivers/scsi/nsp32.c | 415 +++++++++++++++++++++++-------------------- 1 file changed, 221 insertions(+), 194 deletions(-) diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 134bbd2d8b66..6d29908017f0 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -176,38 +176,40 @@ static nsp32_sync_table nsp32_sync_table_pci[] = { * function declaration */ /* module entry point */ -static int nsp32_probe (struct pci_dev *, const struct pci_device_id *); -static void nsp32_remove(struct pci_dev *); +static int nsp32_probe (struct pci_dev *, const struct pci_device_id *); +static void nsp32_remove(struct pci_dev *); static int __init init_nsp32 (void); static void __exit exit_nsp32 (void); /* struct struct scsi_host_template */ -static int nsp32_show_info (struct seq_file *, struct Scsi_Host *); +static int nsp32_show_info (struct seq_file *, struct Scsi_Host *); -static int nsp32_detect (struct pci_dev *pdev); -static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); -static const char *nsp32_info (struct Scsi_Host *); -static int nsp32_release (struct Scsi_Host *); +static int nsp32_detect (struct pci_dev *pdev); +static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); +static const char *nsp32_info (struct Scsi_Host *); +static int nsp32_release (struct Scsi_Host *); /* SCSI error handler */ -static int nsp32_eh_abort (struct scsi_cmnd *); -static int nsp32_eh_host_reset(struct scsi_cmnd *); +static int nsp32_eh_abort (struct scsi_cmnd *); +static int nsp32_eh_host_reset(struct scsi_cmnd *); /* generate SCSI message */ static void nsp32_build_identify(struct scsi_cmnd *); static void nsp32_build_nop (struct scsi_cmnd *); static void nsp32_build_reject (struct scsi_cmnd *); -static void nsp32_build_sdtr (struct scsi_cmnd *, unsigned char, unsigned char); +static void nsp32_build_sdtr (struct scsi_cmnd *, unsigned char, + unsigned char); /* SCSI message handler */ static int nsp32_busfree_occur(struct scsi_cmnd *, unsigned short); static void nsp32_msgout_occur (struct scsi_cmnd *); -static void nsp32_msgin_occur (struct scsi_cmnd *, unsigned long, unsigned short); +static void nsp32_msgin_occur (struct scsi_cmnd *, unsigned long, + unsigned short); static int nsp32_setup_sg_table (struct scsi_cmnd *); static int nsp32_selection_autopara(struct scsi_cmnd *); static int nsp32_selection_autoscsi(struct scsi_cmnd *); -static void nsp32_scsi_done (struct scsi_cmnd *); +static void nsp32_scsi_done (struct scsi_cmnd *); static int nsp32_arbitration (struct scsi_cmnd *, unsigned int); static int nsp32_reselection (struct scsi_cmnd *, unsigned char); static void nsp32_adjust_busfree (struct scsi_cmnd *, unsigned int); @@ -215,10 +217,13 @@ static void nsp32_restart_autoscsi (struct scsi_cmnd *, unsigned short); /* SCSI SDTR */ static void nsp32_analyze_sdtr (struct scsi_cmnd *); -static int nsp32_search_period_entry(nsp32_hw_data *, nsp32_target *, unsigned char); -static void nsp32_set_async (nsp32_hw_data *, nsp32_target *); -static void nsp32_set_max_sync (nsp32_hw_data *, nsp32_target *, unsigned char *, unsigned char *); -static void nsp32_set_sync_entry (nsp32_hw_data *, nsp32_target *, int, unsigned char); +static int nsp32_search_period_entry(nsp32_hw_data *, nsp32_target *, + unsigned char); +static void nsp32_set_async (nsp32_hw_data *, nsp32_target *); +static void nsp32_set_max_sync (nsp32_hw_data *, nsp32_target *, + unsigned char *, unsigned char *); +static void nsp32_set_sync_entry (nsp32_hw_data *, nsp32_target *, + int, unsigned char); /* SCSI bus status handler */ static void nsp32_wait_req (nsp32_hw_data *, int); @@ -234,16 +239,16 @@ static irqreturn_t do_nsp32_isr(int, void *); static int nsp32hw_init(nsp32_hw_data *); /* EEPROM handler */ -static int nsp32_getprom_param (nsp32_hw_data *); -static int nsp32_getprom_at24 (nsp32_hw_data *); -static int nsp32_getprom_c16 (nsp32_hw_data *); -static void nsp32_prom_start (nsp32_hw_data *); -static void nsp32_prom_stop (nsp32_hw_data *); -static int nsp32_prom_read (nsp32_hw_data *, int); -static int nsp32_prom_read_bit (nsp32_hw_data *); -static void nsp32_prom_write_bit(nsp32_hw_data *, int); -static void nsp32_prom_set (nsp32_hw_data *, int, int); -static int nsp32_prom_get (nsp32_hw_data *, int); +static int nsp32_getprom_param (nsp32_hw_data *); +static int nsp32_getprom_at24 (nsp32_hw_data *); +static int nsp32_getprom_c16 (nsp32_hw_data *); +static void nsp32_prom_start (nsp32_hw_data *); +static void nsp32_prom_stop (nsp32_hw_data *); +static int nsp32_prom_read (nsp32_hw_data *, int); +static int nsp32_prom_read_bit (nsp32_hw_data *); +static void nsp32_prom_write_bit(nsp32_hw_data *, int); +static void nsp32_prom_set (nsp32_hw_data *, int, int); +static int nsp32_prom_get (nsp32_hw_data *, int); /* debug/warning/info message */ static void nsp32_message (const char *, int, char *, char *, ...); @@ -356,8 +361,8 @@ static void nsp32_dmessage(const char *func, int line, int mask, char *fmt, ...) static void nsp32_build_identify(struct scsi_cmnd *SCpnt) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - int pos = data->msgout_len; - int mode = FALSE; + int pos = data->msgout_len; + int mode = FALSE; /* XXX: Auto DiscPriv detection is progressing... */ if (disc_priv == 0) { @@ -377,13 +382,13 @@ static void nsp32_build_sdtr(struct scsi_cmnd *SCpnt, unsigned char offset) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - int pos = data->msgout_len; + int pos = data->msgout_len; data->msgoutbuf[pos] = EXTENDED_MESSAGE; pos++; data->msgoutbuf[pos] = EXTENDED_SDTR_LEN; pos++; data->msgoutbuf[pos] = EXTENDED_SDTR; pos++; - data->msgoutbuf[pos] = period; pos++; - data->msgoutbuf[pos] = offset; pos++; + data->msgoutbuf[pos] = period; pos++; + data->msgoutbuf[pos] = offset; pos++; data->msgout_len = pos; } @@ -394,7 +399,7 @@ static void nsp32_build_sdtr(struct scsi_cmnd *SCpnt, static void nsp32_build_nop(struct scsi_cmnd *SCpnt) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - int pos = data->msgout_len; + int pos = data->msgout_len; if (pos != 0) { nsp32_msg(KERN_WARNING, @@ -412,12 +417,12 @@ static void nsp32_build_nop(struct scsi_cmnd *SCpnt) static void nsp32_build_reject(struct scsi_cmnd *SCpnt) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - int pos = data->msgout_len; + int pos = data->msgout_len; data->msgoutbuf[pos] = MESSAGE_REJECT; pos++; data->msgout_len = pos; } - + /* * timer */ @@ -450,7 +455,7 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) unsigned char phase; int i, ret; unsigned int msgout; - u16_le s; + u16_le s; nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "in"); @@ -482,7 +487,7 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) * the sending order of the message is: * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 * MCNT 2: MSG#1 -> MSG#2 - * MCNT 1: MSG#2 + * MCNT 1: MSG#2 */ msgout >>= 8; msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); @@ -494,7 +499,8 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) msgout = 0; } - // nsp_dbg(NSP32_DEBUG_AUTOSCSI, "sel time out=0x%x\n", nsp32_read2(base, SEL_TIME_OUT)); + // nsp_dbg(NSP32_DEBUG_AUTOSCSI, "sel time out=0x%x\n", + // nsp32_read2(base, SEL_TIME_OUT)); // nsp32_write2(base, SEL_TIME_OUT, SEL_TIMEOUT_TIME); /* @@ -520,10 +526,10 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) /* command control */ param->command_control = cpu_to_le16(CLEAR_CDB_FIFO_POINTER | - AUTOSCSI_START | - AUTO_MSGIN_00_OR_04 | - AUTO_MSGIN_02 | - AUTO_ATN ); + AUTOSCSI_START | + AUTO_MSGIN_00_OR_04 | + AUTO_MSGIN_02 | + AUTO_ATN ); /* transfer control */ @@ -555,9 +561,9 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) /* * transfer parameter to ASIC */ - nsp32_write4(base, SGT_ADR, data->auto_paddr); - nsp32_write2(base, COMMAND_CONTROL, CLEAR_CDB_FIFO_POINTER | - AUTO_PARAMETER ); + nsp32_write4(base, SGT_ADR, data->auto_paddr); + nsp32_write2(base, COMMAND_CONTROL, + CLEAR_CDB_FIFO_POINTER | AUTO_PARAMETER ); /* * Check arbitration @@ -599,7 +605,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) SCpnt->result = DID_BUS_BUSY << 16; status = 1; goto out; - } + } /* * clear execph @@ -616,13 +622,14 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) */ for (i = 0; i < SCpnt->cmd_len; i++) { nsp32_write1(base, COMMAND_DATA, SCpnt->cmnd[i]); - } + } nsp32_dbg(NSP32_DEBUG_CDB_CONTENTS, "CDB[0]=[0x%x]", SCpnt->cmnd[0]); /* * set SCSIOUT LATCH(initiator)/TARGET(target) (OR-ed) ID */ - nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, BIT(host_id) | BIT(target)); + nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, + BIT(host_id) | BIT(target)); /* * set SCSI MSGOUT REG @@ -642,7 +649,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) * the sending order of the message is: * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 * MCNT 2: MSG#1 -> MSG#2 - * MCNT 1: MSG#2 + * MCNT 1: MSG#2 */ msgout >>= 8; msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); @@ -662,7 +669,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) /* * set SREQ hazard killer sampling rate - * + * * TODO: sample_rate (BASE+0F) is 0 when internal clock = 40MHz. * check other internal clock! */ @@ -687,7 +694,8 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%x, id=0x%x", nsp32_read1(base, SYNC_REG), nsp32_read1(base, ACK_WIDTH), - nsp32_read4(base, SGT_ADR), nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); + nsp32_read4(base, SGT_ADR), + nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "msgout_len=%d, msgout=0x%x", data->msgout_len, msgout); @@ -716,10 +724,10 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) * start AUTO SCSI, kick off arbitration */ command = (CLEAR_CDB_FIFO_POINTER | - AUTOSCSI_START | + AUTOSCSI_START | AUTO_MSGIN_00_OR_04 | - AUTO_MSGIN_02 | - AUTO_ATN ); + AUTO_MSGIN_02 | + AUTO_ATN); nsp32_write2(base, COMMAND_CONTROL, command); /* @@ -739,9 +747,9 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) /* * Arbitration Status Check - * + * * Note: Arbitration counter is waited during ARBIT_GO is not lifting. - * Using udelay(1) consumes CPU time and system time, but + * Using udelay(1) consumes CPU time and system time, but * arbitration delay time is defined minimal 2.4us in SCSI * specification, thus udelay works as coarse grained wait timer. */ @@ -776,7 +784,7 @@ static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base) nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "arbit timeout"); SCpnt->result = DID_NO_CONNECT << 16; status = FALSE; - } + } /* * clear Arbit @@ -822,7 +830,8 @@ static int nsp32_reselection(struct scsi_cmnd *SCpnt, unsigned char newlun) * or current nexus is not existed, unexpected * reselection is occurred. Send reject message. */ - if (newid >= ARRAY_SIZE(data->lunt) || newlun >= ARRAY_SIZE(data->lunt[0])) { + if (newid >= ARRAY_SIZE(data->lunt) || + newlun >= ARRAY_SIZE(data->lunt[0])) { nsp32_msg(KERN_WARNING, "unknown id/lun"); return FALSE; } else if(data->lunt[newid][newlun].SCpnt == NULL) { @@ -876,7 +885,8 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) if (le32_to_cpu(sgt[i].len) > 0x10000) { nsp32_msg(KERN_ERR, - "can't transfer over 64KB at a time, size=0x%x", le32_to_cpu(sgt[i].len)); + "can't transfer over 64KB at a time, " + "size=0x%lx", le32_to_cpu(sgt[i].len)); return FALSE; } nsp32_dbg(NSP32_DEBUG_SGLIST, @@ -894,7 +904,8 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) return TRUE; } -static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) +static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, + void (*done)(struct scsi_cmnd *)) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; nsp32_target *target; @@ -904,8 +915,9 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "enter. target: 0x%x LUN: 0x%llx cmnd: 0x%x cmndlen: 0x%x " "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", - SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, - scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt)); + SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], + SCpnt->cmd_len, scsi_sg_count(SCpnt), scsi_sglist(SCpnt), + scsi_bufflen(SCpnt)); if (data->CurrentSC != NULL) { nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); @@ -966,7 +978,7 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s /* Build IDENTIFY */ nsp32_build_identify(SCpnt); - /* + /* * If target is the first time to transfer after the reset * (target don't have SDTR_DONE and SDTR_INITIATOR), sync * message SDTR is needed to do synchronous transfer. @@ -1051,9 +1063,9 @@ static int nsp32hw_init(nsp32_hw_data *data) nsp32_index_write2(base, CFG_LATE_CACHE, lc_reg & 0xffff); } - nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); - nsp32_write2(base, TRANSFER_CONTROL, 0); - nsp32_write4(base, BM_CNT, 0); + nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); + nsp32_write2(base, TRANSFER_CONTROL, 0); + nsp32_write4(base, BM_CNT, 0); nsp32_write2(base, SCSI_EXECUTE_PHASE, 0); do { @@ -1081,12 +1093,13 @@ static int nsp32hw_init(nsp32_hw_data *data) nsp32_index_read1(base, FIFO_EMPTY_SHLD_COUNT)); nsp32_index_write1(base, CLOCK_DIV, data->clock); - nsp32_index_write1(base, BM_CYCLE, MEMRD_CMD1 | SGT_AUTO_PARA_MEMED_CMD); + nsp32_index_write1(base, BM_CYCLE, + MEMRD_CMD1 | SGT_AUTO_PARA_MEMED_CMD); nsp32_write1(base, PARITY_CONTROL, 0); /* parity check is disable */ /* * initialize MISC_WRRD register - * + * * Note: Designated parameters is obeyed as following: * MISC_SCSI_DIRECTION_DETECTOR_SELECT: It must be set. * MISC_MASTER_TERMINATION_SELECT: It must be set. @@ -1101,10 +1114,10 @@ static int nsp32hw_init(nsp32_hw_data *data) */ nsp32_index_write2(base, MISC_WR, (SCSI_DIRECTION_DETECTOR_SELECT | - DELAYED_BMSTART | - MASTER_TERMINATION_SELECT | - BMREQ_NEGATE_TIMING_SEL | - AUTOSEL_TIMING_SEL | + DELAYED_BMSTART | + MASTER_TERMINATION_SELECT | + BMREQ_NEGATE_TIMING_SEL | + AUTOSEL_TIMING_SEL | BMSTOP_CHANGE2_NONDATA_PHASE)); nsp32_index_write1(base, TERM_PWR_CONTROL, 0); @@ -1125,15 +1138,16 @@ static int nsp32hw_init(nsp32_hw_data *data) * enable to select designated IRQ (except for * IRQSELECT_SERR, IRQSELECT_PERR, IRQSELECT_BMCNTERR) */ - nsp32_index_write2(base, IRQ_SELECT, IRQSELECT_TIMER_IRQ | - IRQSELECT_SCSIRESET_IRQ | - IRQSELECT_FIFO_SHLD_IRQ | - IRQSELECT_RESELECT_IRQ | - IRQSELECT_PHASE_CHANGE_IRQ | - IRQSELECT_AUTO_SCSI_SEQ_IRQ | - // IRQSELECT_BMCNTERR_IRQ | - IRQSELECT_TARGET_ABORT_IRQ | - IRQSELECT_MASTER_ABORT_IRQ ); + nsp32_index_write2(base, IRQ_SELECT, + IRQSELECT_TIMER_IRQ | + IRQSELECT_SCSIRESET_IRQ | + IRQSELECT_FIFO_SHLD_IRQ | + IRQSELECT_RESELECT_IRQ | + IRQSELECT_PHASE_CHANGE_IRQ | + IRQSELECT_AUTO_SCSI_SEQ_IRQ | + // IRQSELECT_BMCNTERR_IRQ | + IRQSELECT_TARGET_ABORT_IRQ | + IRQSELECT_MASTER_ABORT_IRQ ); nsp32_write2(base, IRQ_CONTROL, 0); /* PCI LED off */ @@ -1163,11 +1177,12 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) * IRQ check, then enable IRQ mask */ irq_stat = nsp32_read2(base, IRQ_STATUS); - nsp32_dbg(NSP32_DEBUG_INTR, + nsp32_dbg(NSP32_DEBUG_INTR, "enter IRQ: %d, IRQstatus: 0x%x", irq, irq_stat); /* is this interrupt comes from Ninja asic? */ if ((irq_stat & IRQSTATUS_ANY_IRQ) == 0) { - nsp32_dbg(NSP32_DEBUG_INTR, "shared interrupt: irq other 0x%x", irq_stat); + nsp32_dbg(NSP32_DEBUG_INTR, + "shared interrupt: irq other 0x%x", irq_stat); goto out2; } handled = 1; @@ -1207,7 +1222,8 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) if (SCpnt == NULL) { nsp32_msg(KERN_WARNING, "SCpnt==NULL this can't be happened"); - nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x", irq_stat, trans_stat); + nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x", + irq_stat, trans_stat); goto out; } @@ -1265,13 +1281,13 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) "Data in/out phase processed"); /* read BMCNT, SGT pointer addr */ - nsp32_dbg(NSP32_DEBUG_INTR, "BMCNT=0x%lx", + nsp32_dbg(NSP32_DEBUG_INTR, "BMCNT=0x%lx", nsp32_read4(base, BM_CNT)); - nsp32_dbg(NSP32_DEBUG_INTR, "addr=0x%lx", + nsp32_dbg(NSP32_DEBUG_INTR, "addr=0x%lx", nsp32_read4(base, SGT_ADR)); - nsp32_dbg(NSP32_DEBUG_INTR, "SACK=0x%lx", + nsp32_dbg(NSP32_DEBUG_INTR, "SACK=0x%lx", nsp32_read4(base, SACK_CNT)); - nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", + nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", nsp32_read4(base, SAVED_SACK_CNT)); scsi_set_resid(SCpnt, 0); /* all data transferred! */ @@ -1306,7 +1322,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) * Read CSB and substitute CSB for SCpnt->result * to save status phase stutas byte. * scsi error handler checks host_byte (DID_*: - * low level driver to indicate status), then checks + * low level driver to indicate status), then checks * status_byte (SCSI status byte). */ SCpnt->result = (int)nsp32_read1(base, SCSI_CSB_IN); @@ -1314,7 +1330,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) if (auto_stat & ILLEGAL_PHASE) { /* Illegal phase is detected. SACK is not back. */ - nsp32_msg(KERN_WARNING, + nsp32_msg(KERN_WARNING, "AUTO SCSI ILLEGAL PHASE OCCUR!!!!"); /* TODO: currently we don't have any action... bus reset? */ @@ -1367,7 +1383,8 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) break; default: nsp32_dbg(NSP32_DEBUG_INTR, "fifo/other phase"); - nsp32_dbg(NSP32_DEBUG_INTR, "irq_stat=0x%x trans_stat=0x%x", irq_stat, trans_stat); + nsp32_dbg(NSP32_DEBUG_INTR, "irq_stat=0x%x trans_stat=0x%x", + irq_stat, trans_stat); show_busphase(busphase); break; } @@ -1433,32 +1450,39 @@ static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host) { unsigned long flags; nsp32_hw_data *data; - int hostno; + int hostno; unsigned int base; unsigned char mode_reg; - int id, speed; - long model; + int id, speed; + long model; hostno = host->host_no; data = (nsp32_hw_data *)host->hostdata; base = host->io_port; seq_puts(m, "NinjaSCSI-32 status\n\n"); - seq_printf(m, "Driver version: %s, $Revision: 1.33 $\n", nsp32_release_version); - seq_printf(m, "SCSI host No.: %d\n", hostno); - seq_printf(m, "IRQ: %d\n", host->irq); - seq_printf(m, "IO: 0x%lx-0x%lx\n", host->io_port, host->io_port + host->n_io_port - 1); - seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", host->base, host->base + data->MmioLength - 1); - seq_printf(m, "sg_tablesize: %d\n", host->sg_tablesize); - seq_printf(m, "Chip revision: 0x%x\n", (nsp32_read2(base, INDEX_REG) >> 8) & 0xff); + seq_printf(m, "Driver version: %s, $Revision: 1.33 $\n", + nsp32_release_version); + seq_printf(m, "SCSI host No.: %d\n", hostno); + seq_printf(m, "IRQ: %d\n", host->irq); + seq_printf(m, "IO: 0x%lx-0x%lx\n", + host->io_port, host->io_port + host->n_io_port - 1); + seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", + host->base, host->base + data->MmioLength - 1); + seq_printf(m, "sg_tablesize: %d\n", + host->sg_tablesize); + seq_printf(m, "Chip revision: 0x%x\n", + (nsp32_read2(base, INDEX_REG) >> 8) & 0xff); mode_reg = nsp32_index_read1(base, CHIP_MODE); model = data->pci_devid->driver_data; #ifdef CONFIG_PM - seq_printf(m, "Power Management: %s\n", (mode_reg & OPTF) ? "yes" : "no"); + seq_printf(m, "Power Management: %s\n", + (mode_reg & OPTF) ? "yes" : "no"); #endif - seq_printf(m, "OEM: %ld, %s\n", (mode_reg & (OEM0|OEM1)), nsp32_model[model]); + seq_printf(m, "OEM: %ld, %s\n", + (mode_reg & (OEM0|OEM1)), nsp32_model[model]); spin_lock_irqsave(&(data->Lock), flags); seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); @@ -1476,7 +1500,7 @@ static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host) } if (data->target[id].sync_flag == SDTR_DONE) { - if (data->target[id].period == 0 && + if (data->target[id].period == 0 && data->target[id].offset == ASYNC_OFFSET ) { seq_puts(m, "async"); } else { @@ -1518,7 +1542,7 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt) * clear TRANSFERCONTROL_BM_START */ nsp32_write2(base, TRANSFER_CONTROL, 0); - nsp32_write4(base, BM_CNT, 0); + nsp32_write4(base, BM_CNT, 0); /* * call scsi_done @@ -1528,10 +1552,10 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt) /* * reset parameters */ - data->cur_lunt->SCpnt = NULL; - data->cur_lunt = NULL; - data->cur_target = NULL; - data->CurrentSC = NULL; + data->cur_lunt->SCpnt = NULL; + data->cur_lunt = NULL; + data->cur_target = NULL; + data->CurrentSC = NULL; } @@ -1553,7 +1577,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) nsp32_dbg(NSP32_DEBUG_BUSFREE, "enter execph=0x%x", execph); show_autophase(execph); - nsp32_write4(base, BM_CNT, 0); + nsp32_write4(base, BM_CNT, 0); nsp32_write2(base, TRANSFER_CONTROL, 0); /* @@ -1561,7 +1585,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) * * VALID: * Save Data Pointer is received. Adjust pointer. - * + * * NO-VALID: * SCSI-3 says if Save Data Pointer is not received, then we restart * processing and we can't adjust any SCSI data pointer in next data @@ -1574,7 +1598,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) * Check sack_cnt/saved_sack_cnt, then adjust sg table if * needed. */ - if (!(execph & MSGIN_00_VALID) && + if (!(execph & MSGIN_00_VALID) && ((execph & DATA_IN_PHASE) || (execph & DATA_OUT_PHASE))) { unsigned int sacklen, s_sacklen; @@ -1617,7 +1641,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) * no processing. */ } - + if (execph & MSGIN_03_VALID) { /* MsgIn03 was valid to be processed. No need processing. */ } @@ -1639,7 +1663,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) * negotiating. */ if (execph & (MSGIN_00_VALID | MSGIN_04_VALID)) { - /* + /* * If valid message is received, then * negotiation is succeeded. */ @@ -1667,12 +1691,12 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); SCpnt->SCp.Message = 0; - nsp32_dbg(NSP32_DEBUG_BUSFREE, + nsp32_dbg(NSP32_DEBUG_BUSFREE, "normal end stat=0x%x resid=0x%x\n", SCpnt->SCp.Status, scsi_get_resid(SCpnt)); - SCpnt->result = (DID_OK << 16) | - (SCpnt->SCp.Message << 8) | - (SCpnt->SCp.Status << 0); + SCpnt->result = (DID_OK << 16) | + (SCpnt->SCp.Message << 8) | + (SCpnt->SCp.Status << 0); nsp32_scsi_done(SCpnt); /* All operation is done */ return TRUE; @@ -1680,7 +1704,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) /* MsgIn 04: Disconnect */ SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); SCpnt->SCp.Message = 4; - + nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect"); return TRUE; } else { @@ -1706,12 +1730,12 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - int old_entry = data->cur_entry; - int new_entry; - int sg_num = data->cur_lunt->sg_num; - nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; - unsigned int restlen, sentlen; - u32_le len, addr; + int old_entry = data->cur_entry; + int new_entry; + int sg_num = data->cur_lunt->sg_num; + nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; + unsigned int restlen, sentlen; + u32_le len, addr; nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", scsi_get_resid(SCpnt)); @@ -1719,7 +1743,7 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; /* - * calculate new_entry from sack count and each sgt[].len + * calculate new_entry from sack count and each sgt[].len * calculate the byte which is intent to send */ sentlen = 0; @@ -1737,8 +1761,10 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen if (sentlen == s_sacklen) { /* XXX: confirm it's ok or not */ - /* In this case, it's ok because we are at - the head element of the sg. restlen is correctly calculated. */ + /* In this case, it's ok because we are at + * the head element of the sg. restlen is correctly + * calculated. + */ } /* calculate the rest length for transferring */ @@ -1753,7 +1779,7 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen /* set cur_entry with new_entry */ data->cur_entry = new_entry; - + return; last: @@ -1781,7 +1807,7 @@ static void nsp32_msgout_occur(struct scsi_cmnd *SCpnt) nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; unsigned int base = SCpnt->device->host->io_port; int i; - + nsp32_dbg(NSP32_DEBUG_MSGOUTOCCUR, "enter: msgout_len: 0x%x", data->msgout_len); @@ -1815,10 +1841,10 @@ static void nsp32_msgout_occur(struct scsi_cmnd *SCpnt) //nsp32_restart_autoscsi(SCpnt, command); nsp32_write2(base, COMMAND_CONTROL, (CLEAR_CDB_FIFO_POINTER | - AUTO_COMMAND_PHASE | - AUTOSCSI_RESTART | - AUTO_MSGIN_00_OR_04 | - AUTO_MSGIN_02 )); + AUTO_COMMAND_PHASE | + AUTOSCSI_RESTART | + AUTO_MSGIN_00_OR_04 | + AUTO_MSGIN_02 )); } /* * Write data with SACK, then wait sack is @@ -1918,9 +1944,9 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, unsigned char msgtype; unsigned char newlun; unsigned short command = 0; - int msgclear = TRUE; - long new_sgtp; - int ret; + int msgclear = TRUE; + long new_sgtp; + int ret; /* * read first message @@ -1960,7 +1986,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, goto reject; } } - + /* * processing messages except for IDENTIFY * @@ -1976,10 +2002,10 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, * These messages should not be occurred. * They should be processed on AutoSCSI sequencer. */ - nsp32_msg(KERN_WARNING, + nsp32_msg(KERN_WARNING, "unexpected message of AutoSCSI MsgIn: 0x%x", msg); break; - + case RESTORE_POINTERS: /* * AutoMsgIn03 is disabled, and HBA gets this message. @@ -2005,7 +2031,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, /* * set new sg pointer */ - new_sgtp = data->cur_lunt->sglun_paddr + + new_sgtp = data->cur_lunt->sglun_paddr + (data->cur_lunt->cur_entry * sizeof(nsp32_sgtable)); nsp32_write4(base, SGT_ADR, new_sgtp); @@ -2016,13 +2042,13 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, * These messages should not be occurred. * They should be processed on AutoSCSI sequencer. */ - nsp32_msg (KERN_WARNING, + nsp32_msg (KERN_WARNING, "unexpected message of AutoSCSI MsgIn: SAVE_POINTERS"); - + break; - + case MESSAGE_REJECT: - /* If previous message_out is sending SDTR, and get + /* If previous message_out is sending SDTR, and get message_reject from target, SDTR negotiation is failed */ if (data->cur_target->sync_flag & (SDTR_INITIATOR | SDTR_TARGET)) { @@ -2041,7 +2067,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, case LINKED_CMD_COMPLETE: case LINKED_FLG_CMD_COMPLETE: /* queue tag is not supported currently */ - nsp32_msg (KERN_WARNING, + nsp32_msg (KERN_WARNING, "unsupported message: 0x%x", msgtype); break; @@ -2094,7 +2120,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, } /* - * Reach here means regular length of each type of + * Reach here means regular length of each type of * extended messages. */ switch (data->msginbuf[2]) { @@ -2129,12 +2155,12 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, goto reject; /* not implemented yet */ break; - + default: goto reject; } break; - + default: goto reject; } @@ -2150,7 +2176,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, * AutoSCSI restart, at the same time MsgOutOccur should be * happened (however, such situation is really possible...?). */ - if (data->msgout_len > 0) { + if (data->msgout_len > 0) { nsp32_write4(base, SCSI_MSG_OUT, 0); command |= AUTO_ATN; } @@ -2192,7 +2218,7 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, return; reject: - nsp32_msg(KERN_WARNING, + nsp32_msg(KERN_WARNING, "invalid or unsupported MessageIn, rejected. " "current msg: 0x%x (len: 0x%x), processing msg: 0x%x", msg, data->msgin_len, msgtype); @@ -2203,15 +2229,15 @@ static void nsp32_msgin_occur(struct scsi_cmnd *SCpnt, } /* - * + * */ static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) { nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; - nsp32_target *target = data->cur_target; - unsigned char get_period = data->msginbuf[3]; - unsigned char get_offset = data->msginbuf[4]; - int entry; + nsp32_target *target = data->cur_target; + unsigned char get_period = data->msginbuf[3]; + unsigned char get_offset = data->msginbuf[4]; + int entry; nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "enter"); @@ -2219,16 +2245,16 @@ static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) * If this inititor sent the SDTR message, then target responds SDTR, * initiator SYNCREG, ACKWIDTH from SDTR parameter. * Messages are not appropriate, then send back reject message. - * If initiator did not send the SDTR, but target sends SDTR, + * If initiator did not send the SDTR, but target sends SDTR, * initiator calculator the appropriate parameter and send back SDTR. - */ + */ if (target->sync_flag & SDTR_INITIATOR) { /* * Initiator sent SDTR, the target responds and * send back negotiation SDTR. */ nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "target responds SDTR"); - + target->sync_flag &= ~SDTR_INITIATOR; target->sync_flag |= SDTR_DONE; @@ -2242,7 +2268,7 @@ static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) */ goto reject; } - + if (get_offset == ASYNC_OFFSET) { /* * Negotiation is succeeded, the target want @@ -2273,7 +2299,7 @@ static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) if (entry < 0) { /* - * Target want to use long period which is not + * Target want to use long period which is not * acceptable NinjaSCSI-32Bi/UDE. */ goto reject; @@ -2286,7 +2312,7 @@ static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) } else { /* Target send SDTR to initiator. */ nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "target send SDTR"); - + target->sync_flag |= SDTR_INITIATOR; /* offset: */ @@ -2409,7 +2435,7 @@ static void nsp32_set_max_sync(nsp32_hw_data *data, */ static void nsp32_set_sync_entry(nsp32_hw_data *data, nsp32_target *target, - int entry, + int entry, unsigned char offset) { unsigned char period, ackwidth, sample_rate; @@ -2438,7 +2464,7 @@ static void nsp32_set_sync_entry(nsp32_hw_data *data, static void nsp32_wait_req(nsp32_hw_data *data, int state) { unsigned int base = data->BaseAddress; - int wait_time = 0; + int wait_time = 0; unsigned char bus, req_bit; if (!((state == ASSERT) || (state == NEGATE))) { @@ -2450,7 +2476,7 @@ static void nsp32_wait_req(nsp32_hw_data *data, int state) do { bus = nsp32_read1(base, SCSI_BUS_MONITOR); if ((bus & BUSMON_REQ) == req_bit) { - nsp32_dbg(NSP32_DEBUG_WAIT, + nsp32_dbg(NSP32_DEBUG_WAIT, "wait_time: %d", wait_time); return; } @@ -2467,7 +2493,7 @@ static void nsp32_wait_req(nsp32_hw_data *data, int state) static void nsp32_wait_sack(nsp32_hw_data *data, int state) { unsigned int base = data->BaseAddress; - int wait_time = 0; + int wait_time = 0; unsigned char bus, ack_bit; if (!((state == ASSERT) || (state == NEGATE))) { @@ -2532,8 +2558,8 @@ static int nsp32_detect(struct pci_dev *pdev) struct Scsi_Host *host; /* registered host structure */ struct resource *res; nsp32_hw_data *data; - int ret; - int i, j; + int ret; + int i, j; nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); @@ -2610,7 +2636,7 @@ static int nsp32_detect(struct pci_dev *pdev) */ /* - * setup DMA + * setup DMA */ if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) != 0) { nsp32_msg (KERN_ERR, "failed to set PCI DMA mask"); @@ -2710,16 +2736,16 @@ static int nsp32_detect(struct pci_dev *pdev) goto free_sg_list; } - /* + /* * PCI IO register */ res = request_region(host->io_port, host->n_io_port, "nsp32"); if (res == NULL) { - nsp32_msg(KERN_ERR, + nsp32_msg(KERN_ERR, "I/O region 0x%x+0x%x is already used", data->BaseAddress, data->NumAddress); goto free_irq; - } + } ret = scsi_add_host(host, &pdev->dev); if (ret) { @@ -2743,7 +2769,7 @@ static int nsp32_detect(struct pci_dev *pdev) free_autoparam: dma_free_coherent(&pdev->dev, sizeof(nsp32_autoparam), data->autoparam, data->auto_paddr); - + scsi_unregister: scsi_host_put(host); @@ -2810,7 +2836,7 @@ static int nsp32_eh_abort(struct scsi_cmnd *SCpnt) } nsp32_write2(base, TRANSFER_CONTROL, 0); - nsp32_write2(base, BM_CNT, 0); + nsp32_write2(base, BM_CNT, 0); SCpnt->result = DID_ABORT << 16; nsp32_scsi_done(SCpnt); @@ -2833,8 +2859,8 @@ static void nsp32_do_bus_reset(nsp32_hw_data *data) * clear counter */ nsp32_write2(base, TRANSFER_CONTROL, 0); - nsp32_write4(base, BM_CNT, 0); - nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); + nsp32_write4(base, BM_CNT, 0); + nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); /* * fall back to asynchronous transfer mode @@ -2856,7 +2882,7 @@ static void nsp32_do_bus_reset(nsp32_hw_data *data) for(i = 0; i < 5; i++) { intrdat = nsp32_read2(base, IRQ_STATUS); /* dummy read */ nsp32_dbg(NSP32_DEBUG_BUSRESET, "irq:1: 0x%x", intrdat); - } + } data->CurrentSC = NULL; } @@ -2867,7 +2893,7 @@ static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt) unsigned int base = SCpnt->device->host->io_port; nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; - nsp32_msg(KERN_INFO, "Host Reset"); + nsp32_msg(KERN_INFO, "Host Reset"); nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); spin_lock_irq(SCpnt->device->host->host_lock); @@ -2942,13 +2968,13 @@ static int nsp32_getprom_param(nsp32_hw_data *data) * AT24C01A (Logitec: LHA-600S), AT24C02 (Melco Buffalo: IFC-USLP) data map: * * ROMADDR - * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) + * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) * Value 0x0: ASYNC, 0x0c: Ultra-20M, 0x19: Fast-10M * 0x07 : HBA Synchronous Transfer Period * Value 0: AutoSync, 1: Manual Setting * 0x08 - 0x0f : Not Used? (0x0) * 0x10 : Bus Termination - * Value 0: Auto[ON], 1: ON, 2: OFF + * Value 0: Auto[ON], 1: ON, 2: OFF * 0x11 : Not Used? (0) * 0x12 : Bus Reset Delay Time (0x03) * 0x13 : Bootable CD Support @@ -2956,7 +2982,7 @@ static int nsp32_getprom_param(nsp32_hw_data *data) * 0x14 : Device Scan * Bit 7 6 5 4 3 2 1 0 * | <-----------------> - * | SCSI ID: Value 0: Skip, 1: YES + * | SCSI ID: Value 0: Skip, 1: YES * |-> Value 0: ALL scan, Value 1: Manual * 0x15 - 0x1b : Not Used? (0) * 0x1c : Constant? (0x01) (clock div?) @@ -2967,10 +2993,10 @@ static int nsp32_getprom_param(nsp32_hw_data *data) */ static int nsp32_getprom_at24(nsp32_hw_data *data) { - int ret, i; - int auto_sync; + int ret, i; + int auto_sync; nsp32_target *target; - int entry; + int entry; /* * Reset time which is designated by EEPROM. @@ -3036,7 +3062,7 @@ static int nsp32_getprom_at24(nsp32_hw_data *data) * C16 110 (I-O Data: SC-NBD) data map: * * ROMADDR - * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) + * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) * Value 0x0: 20MB/S, 0x1: 10MB/S, 0x2: 5MB/S, 0x3: ASYNC * 0x07 : 0 (HBA Synchronous Transfer Period: Auto Sync) * 0x08 - 0x0f : Not Used? (0x0) @@ -3044,7 +3070,7 @@ static int nsp32_getprom_at24(nsp32_hw_data *data) * Value 0: PIO, 1: Busmater * 0x11 : Bus Reset Delay Time (0x00-0x20) * 0x12 : Bus Termination - * Value 0: Disable, 1: Enable + * Value 0: Disable, 1: Enable * 0x13 - 0x19 : Disconnection * Value 0: Disable, 1: Enable * 0x1a - 0x7c : Not Used? (0) @@ -3054,9 +3080,9 @@ static int nsp32_getprom_at24(nsp32_hw_data *data) */ static int nsp32_getprom_c16(nsp32_hw_data *data) { - int ret, i; + int ret, i; nsp32_target *target; - int entry, val; + int entry, val; /* * Reset time which is designated by EEPROM. @@ -3156,7 +3182,7 @@ static int nsp32_prom_read(nsp32_hw_data *data, int romaddr) for (i = 7; i >= 0; i--) { val += (nsp32_prom_read_bit(data) << i); } - + /* no ack */ nsp32_prom_write_bit(data, 1); @@ -3281,7 +3307,8 @@ static int nsp32_resume(struct pci_dev *pdev) nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; unsigned short reg; - nsp32_msg(KERN_INFO, "pci-resume: pdev=0x%p, slot=%s, host=0x%p", pdev, pci_name(pdev), host); + nsp32_msg(KERN_INFO, "pci-resume: pdev=0x%p, slot=%s, host=0x%p", + pdev, pci_name(pdev), host); pci_set_power_state(pdev, PCI_D0); pci_enable_wake (pdev, PCI_D0, 0); @@ -3316,13 +3343,13 @@ static int nsp32_probe(struct pci_dev *pdev, const struct pci_device_id *id) nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); - ret = pci_enable_device(pdev); + ret = pci_enable_device(pdev); if (ret) { nsp32_msg(KERN_ERR, "failed to enable pci device"); return ret; } - data->Pci = pdev; + data->Pci = pdev; data->pci_devid = id; data->IrqNumber = pdev->irq; data->BaseAddress = pci_resource_start(pdev, 0); @@ -3351,7 +3378,7 @@ static void nsp32_remove(struct pci_dev *pdev) nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); - scsi_remove_host(host); + scsi_remove_host(host); nsp32_release(host); @@ -3364,8 +3391,8 @@ static struct pci_driver nsp32_driver = { .probe = nsp32_probe, .remove = nsp32_remove, #ifdef CONFIG_PM - .suspend = nsp32_suspend, - .resume = nsp32_resume, + .suspend = nsp32_suspend, + .resume = nsp32_resume, #endif }; From patchwork Tue Apr 27 08:30:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225569 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 ECD69C433ED for ; Tue, 27 Apr 2021 08:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B454E600D4 for ; Tue, 27 Apr 2021 08:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235227AbhD0IcL (ORCPT ); Tue, 27 Apr 2021 04:32:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:49588 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235169AbhD0Ib5 (ORCPT ); Tue, 27 Apr 2021 04:31:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7D3D2B121; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 24/40] nsp32: do not set message byte Date: Tue, 27 Apr 2021 10:30:30 +0200 Message-Id: <20210427083046.31620-25-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The message byte always devolves to COMMAND_COMPLETE, so there is no point in setting it. Signed-off-by: Hannes Reinecke --- drivers/scsi/nsp32.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 6d29908017f0..56009eb248a7 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -948,7 +948,6 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, SCpnt->scsi_done = done; data->CurrentSC = SCpnt; SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; - SCpnt->SCp.Message = 0; scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); SCpnt->SCp.ptr = (char *)scsi_sglist(SCpnt); @@ -1690,12 +1689,10 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) nsp32_dbg(NSP32_DEBUG_BUSFREE, "command complete"); SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); - SCpnt->SCp.Message = 0; nsp32_dbg(NSP32_DEBUG_BUSFREE, "normal end stat=0x%x resid=0x%x\n", SCpnt->SCp.Status, scsi_get_resid(SCpnt)); SCpnt->result = (DID_OK << 16) | - (SCpnt->SCp.Message << 8) | (SCpnt->SCp.Status << 0); nsp32_scsi_done(SCpnt); /* All operation is done */ @@ -1703,7 +1700,6 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) } else if (execph & MSGIN_04_VALID) { /* MsgIn 04: Disconnect */ SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); - SCpnt->SCp.Message = 4; nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect"); return TRUE; @@ -1712,7 +1708,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) nsp32_msg(KERN_WARNING, "unexpected bus free occurred"); /* DID_ERROR? */ - //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Message << 8) | (SCpnt->SCp.Status << 0); + //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Status << 0); SCpnt->result = DID_ERROR << 16; nsp32_scsi_done(SCpnt); return TRUE; From patchwork Tue Apr 27 08:30:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225583 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 85852C433B4 for ; Tue, 27 Apr 2021 08:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53DF7600EF for ; Tue, 27 Apr 2021 08:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235244AbhD0IcR (ORCPT ); Tue, 27 Apr 2021 04:32:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:49442 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9AA86B133; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 25/40] wd33c93: translate message byte to host byte Date: Tue, 27 Apr 2021 10:30:31 +0200 Message-Id: <20210427083046.31620-26-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to the appropriate host byte. As error recovery would return DID_ERROR for any non-zero message byte the translation doesn't change the error handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/wd33c93.c | 43 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index a23277bb870e..4468bc45aaa4 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -1176,13 +1176,13 @@ wd33c93_intr(struct Scsi_Host *instance) if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE) cmd->SCp.Status = lun; if (cmd->cmnd[0] == REQUEST_SENSE - && cmd->SCp.Status != SAM_STAT_GOOD) - cmd->result = - (cmd-> - result & 0x00ffff) | (DID_ERROR << 16); - else - cmd->result = - cmd->SCp.Status | (cmd->SCp.Message << 8); + && cmd->SCp.Status != SAM_STAT_GOOD) { + set_host_byte(cmd, DID_ERROR); + } else { + set_host_byte(cmd, DID_OK); + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); + set_status_byte(cmd, cmd->SCp.Status); + } cmd->scsi_done(cmd); /* We are no longer connected to a target - check to see if @@ -1262,11 +1262,14 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected = NULL; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; - if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != SAM_STAT_GOOD) - cmd->result = - (cmd->result & 0x00ffff) | (DID_ERROR << 16); - else - cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); + if (cmd->cmnd[0] == REQUEST_SENSE && + cmd->SCp.Status != SAM_STAT_GOOD) { + set_host_byte(cmd, DID_ERROR); + } else { + set_host_byte(cmd, DID_OK); + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); + set_status_byte(cmd, cmd->SCp.Status); + } cmd->scsi_done(cmd); /* We are no longer connected to a target - check to see if @@ -1295,14 +1298,14 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; DB(DB_INTR, printk(":%d", cmd->SCp.Status)) - if (cmd->cmnd[0] == REQUEST_SENSE - && cmd->SCp.Status != SAM_STAT_GOOD) - cmd->result = - (cmd-> - result & 0x00ffff) | (DID_ERROR << 16); - else - cmd->result = - cmd->SCp.Status | (cmd->SCp.Message << 8); + if (cmd->cmnd[0] == REQUEST_SENSE + && cmd->SCp.Status != SAM_STAT_GOOD) { + set_host_byte(cmd, DID_ERROR); + } else { + set_host_byte(cmd, DID_OK); + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); + set_status_byte(cmd, cmd->SCp.Status); + } cmd->scsi_done(cmd); break; case S_PRE_TMP_DISC: From patchwork Tue Apr 27 08:30:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225581 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 D07AAC433ED for ; Tue, 27 Apr 2021 08:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A05D4606A5 for ; Tue, 27 Apr 2021 08:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235242AbhD0IcQ (ORCPT ); Tue, 27 Apr 2021 04:32:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:49418 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235183AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9633AB12C; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 26/40] mesh: translate message to host byte status Date: Tue, 27 Apr 2021 10:30:32 +0200 Message-Id: <20210427083046.31620-27-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to a host byte status. As the error recovery would map it to DID_ERROR anyway the translation doesn't change the SCSI error handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/mesh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 0a9f4e44ab2c..78b72bcf58fe 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -595,9 +595,10 @@ static void mesh_done(struct mesh_state *ms, int start_next) ms->current_req = NULL; tp->current_req = NULL; if (cmd) { - cmd->result = (ms->stat << 16) | cmd->SCp.Status; + set_host_byte(cmd, ms->stat); + set_status_byte(cmd, cmd->SCp.Status); if (ms->stat == DID_OK) - cmd->result |= cmd->SCp.Message << 8; + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); if (DEBUG_TARGET(cmd)) { printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", cmd->result, ms->data_ptr, scsi_bufflen(cmd)); @@ -993,7 +994,7 @@ static void handle_reset(struct mesh_state *ms) for (tgt = 0; tgt < 8; ++tgt) { tp = &ms->tgts[tgt]; if ((cmd = tp->current_req) != NULL) { - cmd->result = DID_RESET << 16; + set_host_byte(cmd, DID_RESET); tp->current_req = NULL; mesh_completed(ms, cmd); } @@ -1003,7 +1004,7 @@ static void handle_reset(struct mesh_state *ms) ms->current_req = NULL; while ((cmd = ms->request_q) != NULL) { ms->request_q = (struct scsi_cmnd *) cmd->host_scribble; - cmd->result = DID_RESET << 16; + set_host_byte(cmd, DID_RESET); mesh_completed(ms, cmd); } ms->phase = idle; From patchwork Tue Apr 27 08:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225591 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 1CF3CC43461 for ; Tue, 27 Apr 2021 08:31:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD6A6611F2 for ; Tue, 27 Apr 2021 08:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235188AbhD0IcW (ORCPT ); Tue, 27 Apr 2021 04:32:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:49444 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A18CEB13E; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 27/40] acornscsi: remove acornscsi_reportstatus() Date: Tue, 27 Apr 2021 10:30:33 +0200 Message-Id: <20210427083046.31620-28-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Unused. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/arm/acornscsi.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 248a5bfad153..8b75d896f393 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -2506,31 +2506,6 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt, DEF_SCSI_QCMD(acornscsi_queuecmd) -/* - * Prototype: void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, struct scsi_cmnd **SCpntp2, int result) - * Purpose : pass a result to *SCpntp1, and check if *SCpntp1 = *SCpntp2 - * Params : SCpntp1 - pointer to command to return - * SCpntp2 - pointer to command to check - * result - result to pass back to mid-level done function - * Returns : *SCpntp2 = NULL if *SCpntp1 is the same command structure as *SCpntp2. - */ -static inline void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, - struct scsi_cmnd **SCpntp2, - int result) -{ - struct scsi_cmnd *SCpnt = *SCpntp1; - - if (SCpnt) { - *SCpntp1 = NULL; - - SCpnt->result = result; - SCpnt->scsi_done(SCpnt); - } - - if (SCpnt == *SCpntp2) - *SCpntp2 = NULL; -} - enum res_abort { res_not_running, res_success, res_success_clear, res_snooze }; /* From patchwork Tue Apr 27 08:30:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225585 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 AC6B0C43460 for ; Tue, 27 Apr 2021 08:31:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77AD8600EF for ; Tue, 27 Apr 2021 08:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235245AbhD0IcR (ORCPT ); Tue, 27 Apr 2021 04:32:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:49708 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235112AbhD0IcB (ORCPT ); Tue, 27 Apr 2021 04:32:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9D922B13B; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 28/40] acornscsi: translate message byte to host byte Date: Tue, 27 Apr 2021 10:30:34 +0200 Message-Id: <20210427083046.31620-29-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to the appropriate host byte. As error recovery would return DID_ERROR for any non-zero message byte the translation doesn't change the error handling. And use SCSI result accessors while we're at it. Signed-off-by: Hannes Reinecke --- drivers/scsi/arm/acornscsi.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 8b75d896f393..84fc7a0c6ff4 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -794,7 +794,10 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, acornscsi_dma_cleanup(host); - SCpnt->result = result << 16 | host->scsi.SCp.Message << 8 | host->scsi.SCp.Status; + set_host_byte(SCpnt, result); + if (result == DID_OK) + scsi_msg_to_host_byte(SCpnt, host->scsi.SCp.Message); + set_status_byte(SCpnt, host->scsi.SCp.Status); /* * In theory, this should not happen. In practice, it seems to. @@ -833,12 +836,12 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, xfer_warn = 0; if (xfer_warn) { - switch (status_byte(SCpnt->result)) { - case CHECK_CONDITION: - case COMMAND_TERMINATED: - case BUSY: - case QUEUE_FULL: - case RESERVATION_CONFLICT: + switch (get_status_byte(SCpnt)) { + case SAM_STAT_CHECK_CONDITION: + case SAM_STAT_COMMAND_TERMINATED: + case SAM_STAT_BUSY: + case SAM_STAT_TASK_SET_FULL: + case SAM_STAT_RESERVATION_CONFLICT: break; default: @@ -2470,7 +2473,7 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt, if (acornscsi_cmdtype(SCpnt->cmnd[0]) == CMD_WRITE && (NO_WRITE & (1 << SCpnt->device->id))) { printk(KERN_CRIT "scsi%d.%c: WRITE attempted with NO_WRITE flag set\n", host->host->host_no, '0' + SCpnt->device->id); - SCpnt->result = DID_NO_CONNECT << 16; + set_host_byte(SCpnt, DID_NO_CONNECT); done(SCpnt); return 0; } @@ -2492,7 +2495,7 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt, unsigned long flags; if (!queue_add_cmd_ordered(&host->queues.issue, SCpnt)) { - SCpnt->result = DID_ERROR << 16; + set_host_byte(SCpnt, DID_ERROR); done(SCpnt); return 0; } From patchwork Tue Apr 27 08:30:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225589 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 B3F44C433B4 for ; Tue, 27 Apr 2021 08:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87CAC6100B for ; Tue, 27 Apr 2021 08:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235247AbhD0IcT (ORCPT ); Tue, 27 Apr 2021 04:32:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:49722 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235188AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A46E8B143; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 29/40] aha152x: modify done() to use separate status bytes Date: Tue, 27 Apr 2021 10:30:35 +0200 Message-Id: <20210427083046.31620-30-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of passing in the combined SCSI result value split them off into separate status, message, and host byte values. Signed-off-by: Hannes Reinecke --- drivers/scsi/aha152x.c | 43 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index d8e19afa7a14..f59d11f8080a 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -619,7 +619,8 @@ static struct { static irqreturn_t intr(int irq, void *dev_id); static void reset_ports(struct Scsi_Host *shpnt); static void aha152x_error(struct Scsi_Host *shpnt, char *msg); -static void done(struct Scsi_Host *shpnt, int error); +static void done(struct Scsi_Host *shpnt, unsigned char status_byte, + unsigned char msg_byte, unsigned char host_byte); /* diagnostics */ static void show_command(struct scsi_cmnd * ptr); @@ -1271,7 +1272,8 @@ static int aha152x_biosparam(struct scsi_device *sdev, struct block_device *bdev * Internal done function * */ -static void done(struct Scsi_Host *shpnt, int error) +static void done(struct Scsi_Host *shpnt, unsigned char status_byte, + unsigned char msg_byte, unsigned char host_byte) { if (CURRENT_SC) { if(DONE_SC) @@ -1281,7 +1283,9 @@ static void done(struct Scsi_Host *shpnt, int error) DONE_SC = CURRENT_SC; CURRENT_SC = NULL; - DONE_SC->result = error; + DONE_SC->result = status_byte; + set_msg_byte(DONE_SC, msg_byte); + set_host_byte(DONE_SC, host_byte); } else printk(KERN_ERR "aha152x: done() called outside of command\n"); } @@ -1376,13 +1380,16 @@ static void busfree_run(struct Scsi_Host *shpnt) if(CURRENT_SC->SCp.phase & completed) { /* target sent COMMAND COMPLETE */ - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16)); + done(shpnt, CURRENT_SC->SCp.Status, + CURRENT_SC->SCp.Message, DID_OK); } else if(CURRENT_SC->SCp.phase & aborted) { - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16)); + done(shpnt, CURRENT_SC->SCp.Status, + CURRENT_SC->SCp.Message, DID_ABORT); } else if(CURRENT_SC->SCp.phase & resetted) { - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16)); + done(shpnt, CURRENT_SC->SCp.Status, + CURRENT_SC->SCp.Message, DID_RESET); } else if(CURRENT_SC->SCp.phase & disconnected) { /* target sent DISCONNECT */ @@ -1394,7 +1401,8 @@ static void busfree_run(struct Scsi_Host *shpnt) CURRENT_SC = NULL; } else { - done(shpnt, DID_ERROR << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_ERROR); } #if defined(AHA152X_STAT) } else { @@ -1515,7 +1523,8 @@ static void seldo_run(struct Scsi_Host *shpnt) if (TESTLO(SSTAT0, SELDO)) { scmd_printk(KERN_ERR, CURRENT_SC, "aha152x: passing bus free condition\n"); - done(shpnt, DID_NO_CONNECT << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_NO_CONNECT); return; } @@ -1552,12 +1561,15 @@ static void selto_run(struct Scsi_Host *shpnt) CURRENT_SC->SCp.phase &= ~selecting; if (CURRENT_SC->SCp.phase & aborted) - done(shpnt, DID_ABORT << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_ABORT); else if (TESTLO(SSTAT0, SELINGO)) - done(shpnt, DID_BUS_BUSY << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_BUS_BUSY); else /* ARBITRATION won, but SELECTION failed */ - done(shpnt, DID_NO_CONNECT << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_NO_CONNECT); } /* @@ -1891,7 +1903,8 @@ static void cmd_init(struct Scsi_Host *shpnt) if (CURRENT_SC->SCp.sent_command) { scmd_printk(KERN_ERR, CURRENT_SC, "command already sent\n"); - done(shpnt, DID_ERROR << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_ERROR); return; } @@ -2231,7 +2244,8 @@ static int update_state(struct Scsi_Host *shpnt) static void parerr_run(struct Scsi_Host *shpnt) { scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n"); - done(shpnt, DID_PARITY << 16); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_PARITY); } /* @@ -2262,7 +2276,8 @@ static void rsti_run(struct Scsi_Host *shpnt) } if(CURRENT_SC && !CURRENT_SC->device->soft_reset) - done(shpnt, DID_RESET << 16 ); + done(shpnt, SAM_STAT_GOOD, + COMMAND_COMPLETE, DID_RESET); } From patchwork Tue Apr 27 08:30:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225597 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 BEE11C43461 for ; Tue, 27 Apr 2021 08:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BC416113D for ; Tue, 27 Apr 2021 08:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235259AbhD0IcY (ORCPT ); Tue, 27 Apr 2021 04:32:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:49754 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235204AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A9CA5B14D; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 30/40] aha152x: do not set message byte when calling scsi_done() Date: Tue, 27 Apr 2021 10:30:36 +0200 Message-Id: <20210427083046.31620-31-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The done() function is called with a host_byte indicating the actual error when the message byte is set. As the host byte takes precedence during error recovery we can drop setting the message byte if the host byte is set, too. The only other case is when the host byte is DID_OK, but in that case the message byte is always COMMAND_COMPLETE (ie 0), so we can drop it there, too. Signed-off-by: Hannes Reinecke --- drivers/scsi/aha152x.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index f59d11f8080a..b13b5c85f3de 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -620,7 +620,7 @@ static irqreturn_t intr(int irq, void *dev_id); static void reset_ports(struct Scsi_Host *shpnt); static void aha152x_error(struct Scsi_Host *shpnt, char *msg); static void done(struct Scsi_Host *shpnt, unsigned char status_byte, - unsigned char msg_byte, unsigned char host_byte); + unsigned char host_byte); /* diagnostics */ static void show_command(struct scsi_cmnd * ptr); @@ -1273,7 +1273,7 @@ static int aha152x_biosparam(struct scsi_device *sdev, struct block_device *bdev * */ static void done(struct Scsi_Host *shpnt, unsigned char status_byte, - unsigned char msg_byte, unsigned char host_byte) + unsigned char host_byte) { if (CURRENT_SC) { if(DONE_SC) @@ -1283,8 +1283,7 @@ static void done(struct Scsi_Host *shpnt, unsigned char status_byte, DONE_SC = CURRENT_SC; CURRENT_SC = NULL; - DONE_SC->result = status_byte; - set_msg_byte(DONE_SC, msg_byte); + set_status_byte(DONE_SC, status_byte); set_host_byte(DONE_SC, host_byte); } else printk(KERN_ERR "aha152x: done() called outside of command\n"); @@ -1380,16 +1379,13 @@ static void busfree_run(struct Scsi_Host *shpnt) if(CURRENT_SC->SCp.phase & completed) { /* target sent COMMAND COMPLETE */ - done(shpnt, CURRENT_SC->SCp.Status, - CURRENT_SC->SCp.Message, DID_OK); + done(shpnt, CURRENT_SC->SCp.Status, DID_OK); } else if(CURRENT_SC->SCp.phase & aborted) { - done(shpnt, CURRENT_SC->SCp.Status, - CURRENT_SC->SCp.Message, DID_ABORT); + done(shpnt, CURRENT_SC->SCp.Status, DID_ABORT); } else if(CURRENT_SC->SCp.phase & resetted) { - done(shpnt, CURRENT_SC->SCp.Status, - CURRENT_SC->SCp.Message, DID_RESET); + done(shpnt, CURRENT_SC->SCp.Status, DID_RESET); } else if(CURRENT_SC->SCp.phase & disconnected) { /* target sent DISCONNECT */ @@ -1401,8 +1397,7 @@ static void busfree_run(struct Scsi_Host *shpnt) CURRENT_SC = NULL; } else { - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_ERROR); + done(shpnt, SAM_STAT_GOOD, DID_ERROR); } #if defined(AHA152X_STAT) } else { @@ -1523,8 +1518,7 @@ static void seldo_run(struct Scsi_Host *shpnt) if (TESTLO(SSTAT0, SELDO)) { scmd_printk(KERN_ERR, CURRENT_SC, "aha152x: passing bus free condition\n"); - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_NO_CONNECT); + done(shpnt, SAM_STAT_GOOD, DID_NO_CONNECT); return; } @@ -1561,15 +1555,12 @@ static void selto_run(struct Scsi_Host *shpnt) CURRENT_SC->SCp.phase &= ~selecting; if (CURRENT_SC->SCp.phase & aborted) - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_ABORT); + done(shpnt, SAM_STAT_GOOD, DID_ABORT); else if (TESTLO(SSTAT0, SELINGO)) - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_BUS_BUSY); + done(shpnt, SAM_STAT_GOOD, DID_BUS_BUSY); else /* ARBITRATION won, but SELECTION failed */ - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_NO_CONNECT); + done(shpnt, SAM_STAT_GOOD, DID_NO_CONNECT); } /* @@ -1903,8 +1894,7 @@ static void cmd_init(struct Scsi_Host *shpnt) if (CURRENT_SC->SCp.sent_command) { scmd_printk(KERN_ERR, CURRENT_SC, "command already sent\n"); - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_ERROR); + done(shpnt, SAM_STAT_GOOD, DID_ERROR); return; } @@ -2244,8 +2234,7 @@ static int update_state(struct Scsi_Host *shpnt) static void parerr_run(struct Scsi_Host *shpnt) { scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n"); - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_PARITY); + done(shpnt, SAM_STAT_GOOD, DID_PARITY); } /* @@ -2268,7 +2257,7 @@ static void rsti_run(struct Scsi_Host *shpnt) kfree(ptr->host_scribble); ptr->host_scribble=NULL; - ptr->result = DID_RESET << 16; + set_host_byte(ptr, DID_RESET); ptr->scsi_done(ptr); } @@ -2276,8 +2265,7 @@ static void rsti_run(struct Scsi_Host *shpnt) } if(CURRENT_SC && !CURRENT_SC->device->soft_reset) - done(shpnt, SAM_STAT_GOOD, - COMMAND_COMPLETE, DID_RESET); + done(shpnt, SAM_STAT_GOOD, DID_RESET); } From patchwork Tue Apr 27 08:30:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225587 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 71F20C433B4 for ; Tue, 27 Apr 2021 08:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 493AC6113D for ; Tue, 27 Apr 2021 08:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235246AbhD0IcT (ORCPT ); Tue, 27 Apr 2021 04:32:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:49440 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235191AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B4547B158; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 31/40] advansys: do not set message byte in SCSI status Date: Tue, 27 Apr 2021 10:30:37 +0200 Message-Id: <20210427083046.31620-32-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The host byte in the SCSI status takes precedence during error recovery, so there is no point in setting the message byte in addition to a host byte which is not DID_OK. Signed-off-by: Hannes Reinecke --- drivers/scsi/advansys.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 77c99fe11c81..28748df36c2f 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -6773,14 +6773,12 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) case QD_ABORTED_BY_HOST: ASC_DBG(1, "QD_ABORTED_BY_HOST\n"); set_status_byte(scp, qdonep->d3.scsi_stat); - set_msg_byte(scp, qdonep->d3.scsi_msg); set_host_byte(scp, DID_ABORT); break; default: ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat); set_status_byte(scp, qdonep->d3.scsi_stat); - set_msg_byte(scp, qdonep->d3.scsi_msg); set_host_byte(scp, DID_ERROR); break; } From patchwork Tue Apr 27 08:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225599 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 315DEC433ED for ; Tue, 27 Apr 2021 08:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF729606A5 for ; Tue, 27 Apr 2021 08:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235220AbhD0Ic0 (ORCPT ); Tue, 27 Apr 2021 04:32:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:49746 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235124AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B63FCB163; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 32/40] fas216: translate message to host byte status Date: Tue, 27 Apr 2021 10:30:38 +0200 Message-Id: <20210427083046.31620-33-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to the appropriate host byte. As error recovery would return DID_ERROR for any non-zero message byte the translation doesn't change the error handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/arm/fas216.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 2e687ce60753..865f357a86be 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2042,8 +2042,10 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) { info->stats.fins += 1; - SCpnt->result = result << 16 | info->scsi.SCp.Message << 8 | - info->scsi.SCp.Status; + set_host_byte(SCpnt, result); + if (result == DID_OK) + scsi_msg_to_host_byte(SCpnt, info->scsi.SCp.Message); + set_status_byte(SCpnt, info->scsi.SCp.Status); fas216_log_command(info, LOG_CONNECT, SCpnt, "command complete, result=0x%08x", SCpnt->result); @@ -2051,8 +2053,7 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) /* * If the driver detected an error, we're all done. */ - if (host_byte(SCpnt->result) != DID_OK || - msg_byte(SCpnt->result) != COMMAND_COMPLETE) + if (get_host_byte(SCpnt->result) != DID_OK) goto done; /* From patchwork Tue Apr 27 08:30:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225593 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 A646FC43460 for ; Tue, 27 Apr 2021 08:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FE2F6113D for ; Tue, 27 Apr 2021 08:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235258AbhD0IcY (ORCPT ); Tue, 27 Apr 2021 04:32:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:49446 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235206AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C9203B169; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 33/40] fas216: Use get_status_byte() to avoid using linux-specific status codes Date: Tue, 27 Apr 2021 10:30:39 +0200 Message-Id: <20210427083046.31620-34-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver should be using the standard SAM_STAT_ values, and not the linux-specific ones. Signed-off-by: Hannes Reinecke --- drivers/scsi/arm/fas216.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 865f357a86be..017f0c9f74c8 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2060,15 +2060,15 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) * If the command returned CHECK_CONDITION or COMMAND_TERMINATED * status, request the sense information. */ - if (status_byte(SCpnt->result) == CHECK_CONDITION || - status_byte(SCpnt->result) == COMMAND_TERMINATED) + if (get_status_byte(SCpnt) == SAM_STAT_CHECK_CONDITION || + get_status_byte(SCpnt) == SAM_STAT_COMMAND_TERMINATED) goto request_sense; /* * If the command did not complete with GOOD status, * we are all done here. */ - if (status_byte(SCpnt->result) != GOOD) + if (get_status_byte(SCpnt) != SAM_STAT_GOOD) goto done; /* From patchwork Tue Apr 27 08:30:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225609 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 A63A1C43470 for ; Tue, 27 Apr 2021 08:31:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 786FB600EF for ; Tue, 27 Apr 2021 08:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235253AbhD0Ic3 (ORCPT ); Tue, 27 Apr 2021 04:32:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:50084 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235217AbhD0IcG (ORCPT ); Tue, 27 Apr 2021 04:32:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C4194B165; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 34/40] FlashPoint: Use standard SCSI definitions Date: Tue, 27 Apr 2021 10:30:40 +0200 Message-Id: <20210427083046.31620-35-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org No point in having the driver providing its own definitions. Signed-off-by: Hannes Reinecke --- drivers/scsi/FlashPoint.c | 165 ++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 96 deletions(-) diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c index 0464e37c806a..ee9e4028c0f3 100644 --- a/drivers/scsi/FlashPoint.c +++ b/drivers/scsi/FlashPoint.c @@ -304,40 +304,12 @@ typedef struct SCCBscam_info { } SCCBSCAM_INFO; -#define SCSI_REQUEST_SENSE 0x03 -#define SCSI_READ 0x08 -#define SCSI_WRITE 0x0A -#define SCSI_START_STOP_UNIT 0x1B -#define SCSI_READ_EXTENDED 0x28 -#define SCSI_WRITE_EXTENDED 0x2A -#define SCSI_WRITE_AND_VERIFY 0x2E - -#define SSGOOD 0x00 -#define SSCHECK 0x02 -#define SSQ_FULL 0x28 - -#define SMCMD_COMP 0x00 -#define SMEXT 0x01 -#define SMSAVE_DATA_PTR 0x02 -#define SMREST_DATA_PTR 0x03 -#define SMDISC 0x04 -#define SMABORT 0x06 -#define SMREJECT 0x07 -#define SMNO_OP 0x08 -#define SMPARITY 0x09 -#define SMDEV_RESET 0x0C -#define SMABORT_TAG 0x0D -#define SMINIT_RECOVERY 0x0F -#define SMREL_RECOVERY 0x10 #define SMIDENT 0x80 #define DISC_PRIV 0x40 -#define SMSYNC 0x01 -#define SMWDTR 0x03 #define SM8BIT 0x00 #define SM16BIT 0x01 -#define SMIGNORWR 0x23 /* Ignore Wide Residue */ #define SIX_BYTE_CMD 0x06 #define TWELVE_BYTE_CMD 0x0C @@ -1660,7 +1632,7 @@ static int FlashPoint_AbortCCB(void *pCurrCard, struct sccb *p_Sccb) p_Sccb->Sccb_scsistat = ABORT_ST; p_Sccb->Sccb_scsimsg = - SMABORT_TAG; + ABORT_TASK; if (((struct sccb_card *) pCurrCard)->currentSCCB == @@ -1812,7 +1784,7 @@ static int FlashPoint_HandleInterrupt(void *pcard) FPT_phaseChkFifo(ioport, thisCard); if (RD_HARPOON(ioport + hp_gp_reg_1) == - SMSAVE_DATA_PTR) { + SAVE_POINTERS) { WR_HARPOON(ioport + hp_gp_reg_1, 0x00); currSCCB->Sccb_XferState |= F_NO_DATA_YET; @@ -1865,7 +1837,7 @@ static int FlashPoint_HandleInterrupt(void *pcard) FPT_phaseChkFifo(ioport, thisCard); if (RD_HARPOON(ioport + hp_gp_reg_1) == - SMSAVE_DATA_PTR) { + SAVE_POINTERS) { WR_HARPOON(ioport + hp_gp_reg_1, 0x00); currSCCB->Sccb_XferState |= F_NO_DATA_YET; @@ -2258,7 +2230,7 @@ static unsigned char FPT_sfm(u32 port, struct sccb *pCurrSCCB) WR_HARPOON(port + hp_fiforead, 0); WR_HARPOON(port + hp_fifowrite, 0); if (pCurrSCCB != NULL) { - pCurrSCCB->Sccb_scsimsg = SMPARITY; + pCurrSCCB->Sccb_scsimsg = MSG_PARITY_ERROR; } message = 0x00; do { @@ -2411,7 +2383,7 @@ static void FPT_ssel(u32 port, unsigned char p_card) WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); - currSCCB->Sccb_scsimsg = SMDEV_RESET; + currSCCB->Sccb_scsimsg = TARGET_RESET; WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); auto_loaded = 1; @@ -2758,9 +2730,9 @@ static void FPT_sres(u32 port, unsigned char p_card, if (message == 0) { msgRetryCount++; if (msgRetryCount == 1) { - FPT_SendMsg(port, SMPARITY); + FPT_SendMsg(port, MSG_PARITY_ERROR); } else { - FPT_SendMsg(port, SMDEV_RESET); + FPT_SendMsg(port, TARGET_RESET); FPT_sssyncv(port, our_target, NARROW_SCSI, currTar_Info); @@ -2860,8 +2832,8 @@ static void FPT_SendMsg(u32 port, unsigned char message) WR_HARPOON(port + hp_portctrl_0, 0x00); - if ((message == SMABORT) || (message == SMDEV_RESET) || - (message == SMABORT_TAG)) { + if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || + (message == ABORT_TASK)) { while (! (RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { @@ -2893,7 +2865,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; - if (message == SMREST_DATA_PTR) { + if (message == RESTORE_POINTERS) { if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; @@ -2905,7 +2877,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) (AUTO_IMMED + DISCONNECT_START)); } - else if (message == SMCMD_COMP) { + else if (message == COMMAND_COMPLETE) { if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { currTar_Info->TarStatus &= @@ -2917,15 +2889,16 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) } - else if ((message == SMNO_OP) || (message >= SMIDENT) - || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { + else if ((message == NOP) || (message >= IDENTIFY_BASE) || + (message == INITIATE_RECOVERY) || + (message == RELEASE_RECOVERY)) { ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } - else if (message == SMREJECT) { + else if (message == MESSAGE_REJECT) { if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || (currSCCB->Sccb_scsistat == SELECT_WN_ST) || @@ -3026,19 +2999,19 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) } } - else if (message == SMEXT) { + else if (message == EXTENDED_MESSAGE) { ACCEPT_MSG(port); FPT_shandem(port, p_card, currSCCB); } - else if (message == SMIGNORWR) { + else if (message == IGNORE_WIDE_RESIDUE) { ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ message = FPT_sfm(port, currSCCB); - if (currSCCB->Sccb_scsimsg != SMPARITY) + if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); @@ -3047,7 +3020,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) else { currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; - currSCCB->Sccb_scsimsg = SMREJECT; + currSCCB->Sccb_scsimsg = MESSAGE_REJECT; ACCEPT_MSG_ATN(port); WR_HARPOON(port + hp_autostart_1, @@ -3073,7 +3046,7 @@ static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) message = FPT_sfm(port, pCurrSCCB); if (message) { - if (message == SMSYNC) { + if (message == EXTENDED_SDTR) { if (length == 0x03) { @@ -3081,10 +3054,10 @@ static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) FPT_stsyncn(port, p_card); } else { - pCurrSCCB->Sccb_scsimsg = SMREJECT; + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; ACCEPT_MSG_ATN(port); } - } else if (message == SMWDTR) { + } else if (message == EXTENDED_WDTR) { if (length == 0x02) { @@ -3092,7 +3065,7 @@ static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) FPT_stwidn(port, p_card); } else { - pCurrSCCB->Sccb_scsimsg = SMREJECT; + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; ACCEPT_MSG_ATN(port); WR_HARPOON(port + hp_autostart_1, @@ -3101,20 +3074,20 @@ static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) } } else { - pCurrSCCB->Sccb_scsimsg = SMREJECT; + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; ACCEPT_MSG_ATN(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } } else { - if (pCurrSCCB->Sccb_scsimsg != SMPARITY) + if (pCurrSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } } else { - if (pCurrSCCB->Sccb_scsimsg == SMPARITY) + if (pCurrSCCB->Sccb_scsimsg == MSG_PARITY_ERROR) WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } @@ -3148,10 +3121,10 @@ static unsigned char FPT_sisyncn(u32 port, unsigned char p_card, WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); WRW_HARPOON((port + SYNC_MSGS + 0), - (MPM_OP + AMSG_OUT + SMEXT)); + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); WRW_HARPOON((port + SYNC_MSGS + 4), - (MPM_OP + AMSG_OUT + SMSYNC)); + (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) @@ -3221,7 +3194,7 @@ static void FPT_stsyncn(u32 port, unsigned char p_card) sync_msg = FPT_sfm(port, currSCCB); - if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { + if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); return; @@ -3231,7 +3204,7 @@ static void FPT_stsyncn(u32 port, unsigned char p_card) offset = FPT_sfm(port, currSCCB); - if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { + if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); return; @@ -3343,9 +3316,11 @@ static void FPT_sisyncr(u32 port, unsigned char sync_pulse, unsigned char offset) { ARAM_ACCESS(port); - WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); + WRW_HARPOON((port + SYNC_MSGS + 0), + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); - WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMSYNC)); + WRW_HARPOON((port + SYNC_MSGS + 4), + (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); @@ -3388,10 +3363,10 @@ static unsigned char FPT_siwidn(u32 port, unsigned char p_card) WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); WRW_HARPOON((port + SYNC_MSGS + 0), - (MPM_OP + AMSG_OUT + SMEXT)); + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); WRW_HARPOON((port + SYNC_MSGS + 4), - (MPM_OP + AMSG_OUT + SMWDTR)); + (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + SM16BIT)); @@ -3436,7 +3411,7 @@ static void FPT_stwidn(u32 port, unsigned char p_card) width = FPT_sfm(port, currSCCB); - if ((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { + if ((width == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); return; @@ -3499,9 +3474,11 @@ static void FPT_stwidn(u32 port, unsigned char p_card) static void FPT_siwidr(u32 port, unsigned char width) { ARAM_ACCESS(port); - WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); + WRW_HARPOON((port + SYNC_MSGS + 0), + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); - WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMWDTR)); + WRW_HARPOON((port + SYNC_MSGS + 4), + (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); @@ -3682,7 +3659,7 @@ static void FPT_ssenss(struct sccb_card *pCurrCard) } currSCCB->CdbLength = SIX_BYTE_CMD; - currSCCB->Cdb[0] = SCSI_REQUEST_SENSE; + currSCCB->Cdb[0] = REQUEST_SENSE; currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ currSCCB->Cdb[2] = 0x00; currSCCB->Cdb[3] = 0x00; @@ -3939,13 +3916,9 @@ static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) */ if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || (currTar_Info->TarStatus & TAG_Q_TRYING)) { - p_sccb->Sccb_idmsg = - (unsigned char)(SMIDENT | DISC_PRIV) | p_sccb->Lun; - } - - else { - - p_sccb->Sccb_idmsg = (unsigned char)SMIDENT | p_sccb->Lun; + p_sccb->Sccb_idmsg = IDENTIFY(true, p_sccb->Lun); + } else { + p_sccb->Sccb_idmsg = IDENTIFY(false, p_sccb->Lun); } p_sccb->HostStatus = 0x00; @@ -3962,7 +3935,7 @@ static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card) */ p_sccb->Sccb_scsistat = BUS_FREE_ST; p_sccb->SccbStatus = SCCB_IN_PROCESS; - p_sccb->Sccb_scsimsg = SMNO_OP; + p_sccb->Sccb_scsimsg = NOP; } @@ -4167,7 +4140,7 @@ static void FPT_phaseMsgOut(u32 port, unsigned char p_card) message = currSCCB->Sccb_scsimsg; scsiID = currSCCB->TargID; - if (message == SMDEV_RESET) { + if (message == TARGET_RESET) { currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; currTar_Info->TarSyncCtrl = 0; @@ -4203,7 +4176,7 @@ static void FPT_phaseMsgOut(u32 port, unsigned char p_card) else if (currSCCB->Sccb_scsistat < COMMAND_ST) { - if (message == SMNO_OP) { + if (message == NOP) { currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; FPT_ssel(port, p_card); @@ -4211,13 +4184,13 @@ static void FPT_phaseMsgOut(u32 port, unsigned char p_card) } } else { - if (message == SMABORT) + if (message == ABORT_TASK_SET) FPT_queueFlushSccb(p_card, SCCB_COMPLETE); } } else { - message = SMABORT; + message = ABORT_TASK_SET; } WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); @@ -4232,8 +4205,8 @@ static void FPT_phaseMsgOut(u32 port, unsigned char p_card) WR_HARPOON(port + hp_portctrl_0, 0x00); - if ((message == SMABORT) || (message == SMDEV_RESET) || - (message == SMABORT_TAG)) { + if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || + (message == ABORT_TASK)) { while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { } @@ -4275,8 +4248,8 @@ static void FPT_phaseMsgOut(u32 port, unsigned char p_card) else { - if (message == SMPARITY) { - currSCCB->Sccb_scsimsg = SMNO_OP; + if (message == MSG_PARITY_ERROR) { + currSCCB->Sccb_scsimsg = NOP; WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } else { @@ -4306,7 +4279,7 @@ static void FPT_phaseMsgIn(u32 port, unsigned char p_card) } message = RD_HARPOON(port + hp_scsidata_0); - if ((message == SMDISC) || (message == SMSAVE_DATA_PTR)) { + if ((message == DISCONNECT) || (message == SAVE_POINTERS)) { WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + END_DATA_START)); @@ -4321,7 +4294,7 @@ static void FPT_phaseMsgIn(u32 port, unsigned char p_card) FPT_sdecm(message, port, p_card); } else { - if (currSCCB->Sccb_scsimsg != SMPARITY) + if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); @@ -4351,7 +4324,7 @@ static void FPT_phaseIllegal(u32 port, unsigned char p_card) currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; currSCCB->Sccb_scsistat = ABORT_ST; - currSCCB->Sccb_scsimsg = SMABORT; + currSCCB->Sccb_scsimsg = ABORT_TASK_SET; } ACCEPT_MSG_ATN(port); @@ -4650,9 +4623,9 @@ static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card) FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; - if (status_byte != SSGOOD) { + if (status_byte != SAM_STAT_GOOD) { - if (status_byte == SSQ_FULL) { + if (status_byte == SAM_STAT_TASK_SET_FULL) { if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. @@ -4784,7 +4757,7 @@ static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card) } - if (status_byte == SSCHECK) { + if (status_byte == SAM_STAT_CHECK_CONDITION) { if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. TarEEValue & EE_SYNC_MASK) { @@ -4806,7 +4779,7 @@ static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card) currSCCB->SccbStatus = SCCB_ERROR; currSCCB->TargetStatus = status_byte; - if (status_byte == SSCHECK) { + if (status_byte == SAM_STAT_CHECK_CONDITION) { FPT_sccbMgrTbl[p_card][currSCCB->TargID]. TarLUN_CA = 1; @@ -6868,14 +6841,14 @@ static void FPT_queueCmdComplete(struct sccb_card *pCurrCard, if ((p_sccb-> ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) && (p_sccb->HostStatus == SCCB_COMPLETE) - && (p_sccb->TargetStatus != SSCHECK)) - - if ((SCSIcmd == SCSI_READ) || - (SCSIcmd == SCSI_WRITE) || - (SCSIcmd == SCSI_READ_EXTENDED) || - (SCSIcmd == SCSI_WRITE_EXTENDED) || - (SCSIcmd == SCSI_WRITE_AND_VERIFY) || - (SCSIcmd == SCSI_START_STOP_UNIT) || + && (p_sccb->TargetStatus != SAM_STAT_CHECK_CONDITION)) + + if ((SCSIcmd == READ_6) || + (SCSIcmd == WRITE_6) || + (SCSIcmd == READ_10) || + (SCSIcmd == WRITE_10) || + (SCSIcmd == WRITE_VERIFY) || + (SCSIcmd == START_STOP) || (pCurrCard->globalFlags & F_NO_FILTER) ) p_sccb->HostStatus = SCCB_DATA_UNDER_RUN; From patchwork Tue Apr 27 08:30:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225601 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 50CF1C43462 for ; Tue, 27 Apr 2021 08:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E8336100B for ; Tue, 27 Apr 2021 08:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235292AbhD0Ic1 (ORCPT ); Tue, 27 Apr 2021 04:32:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:49790 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235208AbhD0IcC (ORCPT ); Tue, 27 Apr 2021 04:32:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C6DD3B168; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 35/40] fdomain: drop last argument to fdomain_finish_cmd() Date: Tue, 27 Apr 2021 10:30:41 +0200 Message-Id: <20210427083046.31620-36-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set the SCSI host status before calling fdomein_finish_cmd(), and drop the last argument to that function. Signed-off-by: Hannes Reinecke --- drivers/scsi/fdomain.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index 772bdc93930a..294dbfa5c761 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -202,11 +202,10 @@ static int fdomain_select(struct Scsi_Host *sh, int target) return 1; } -static void fdomain_finish_cmd(struct fdomain *fd, int result) +static void fdomain_finish_cmd(struct fdomain *fd) { outb(0, fd->base + REG_ICTL); fdomain_make_bus_idle(fd); - fd->cur_cmd->result = result; fd->cur_cmd->scsi_done(fd->cur_cmd); fd->cur_cmd = NULL; } @@ -273,7 +272,8 @@ static void fdomain_work(struct work_struct *work) if (cmd->SCp.phase & in_arbitration) { status = inb(fd->base + REG_ASTAT); if (!(status & ASTAT_ARB)) { - fdomain_finish_cmd(fd, DID_BUS_BUSY << 16); + set_host_byte(cmd, DID_BUS_BUSY); + fdomain_finish_cmd(fd); goto out; } cmd->SCp.phase = in_selection; @@ -290,7 +290,8 @@ static void fdomain_work(struct work_struct *work) if (!(status & BSTAT_BSY)) { /* Try again, for slow devices */ if (fdomain_select(cmd->device->host, scmd_id(cmd))) { - fdomain_finish_cmd(fd, DID_NO_CONNECT << 16); + set_host_byte(cmd, DID_NO_CONNECT); + fdomain_finish_cmd(fd); goto out; } /* Stop arbitration and enable parity */ @@ -333,7 +334,7 @@ static void fdomain_work(struct work_struct *work) break; case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */ cmd->SCp.Message = inb(fd->base + REG_SCSI_DATA); - if (!cmd->SCp.Message) + if (cmd->SCp.Message == COMMAND_COMPLETE) ++done; break; } @@ -359,9 +360,10 @@ static void fdomain_work(struct work_struct *work) fdomain_read_data(cmd); if (done) { - fdomain_finish_cmd(fd, (cmd->SCp.Status & 0xff) | - ((cmd->SCp.Message & 0xff) << 8) | - (DID_OK << 16)); + set_status_byte(cmd, cmd->SCp.Status); + set_msg_byte(cmd, cmd->SCp.Message); + set_host_byte(cmd, DID_OK); + fdomain_finish_cmd(fd); } else { if (cmd->SCp.phase & disconnect) { outb(ICTL_FIFO | ICTL_SEL | ICTL_REQ | FIFO_COUNT, @@ -439,10 +441,10 @@ static int fdomain_abort(struct scsi_cmnd *cmd) fdomain_make_bus_idle(fd); fd->cur_cmd->SCp.phase |= aborted; - fd->cur_cmd->result = DID_ABORT << 16; /* Aborts are not done well. . . */ - fdomain_finish_cmd(fd, DID_ABORT << 16); + set_host_byte(fd->cur_cmd, DID_ABORT); + fdomain_finish_cmd(fd); spin_unlock_irqrestore(sh->host_lock, flags); return SUCCESS; } From patchwork Tue Apr 27 08:30:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225603 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 E3DB4C43461 for ; Tue, 27 Apr 2021 08:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB8C6600EF for ; Tue, 27 Apr 2021 08:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235167AbhD0Ic2 (ORCPT ); Tue, 27 Apr 2021 04:32:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:49412 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235214AbhD0IcG (ORCPT ); Tue, 27 Apr 2021 04:32:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D52A6B16A; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 36/40] fdomain: translate message to host byte status Date: Tue, 27 Apr 2021 10:30:42 +0200 Message-Id: <20210427083046.31620-37-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of setting the message byte translate it to the appropriate host byte. As error recovery would return DID_ERROR for any non-zero message byte the translation doesn't change the error handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/fdomain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index 294dbfa5c761..eda2be534aa7 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -361,8 +361,8 @@ static void fdomain_work(struct work_struct *work) if (done) { set_status_byte(cmd, cmd->SCp.Status); - set_msg_byte(cmd, cmd->SCp.Message); set_host_byte(cmd, DID_OK); + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); fdomain_finish_cmd(fd); } else { if (cmd->SCp.phase & disconnect) { From patchwork Tue Apr 27 08:30:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225605 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 13EC6C433ED for ; Tue, 27 Apr 2021 08:31:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED651600EF for ; Tue, 27 Apr 2021 08:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235239AbhD0Ic3 (ORCPT ); Tue, 27 Apr 2021 04:32:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:49452 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235215AbhD0IcG (ORCPT ); Tue, 27 Apr 2021 04:32:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D5ACFB16B; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 37/40] scsi: drop message byte helper Date: Tue, 27 Apr 2021 10:30:43 +0200 Message-Id: <20210427083046.31620-38-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The message byte is now unused, so we can drop the helper to set the message byte and the check for message bytes during error recovery. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- block/scsi_ioctl.c | 2 +- drivers/scsi/scsi_error.c | 18 ++---------------- drivers/scsi/sg.c | 2 +- drivers/xen/xen-scsiback.c | 2 +- include/scsi/scsi.h | 3 +-- include/scsi/scsi_cmnd.h | 5 ----- 6 files changed, 6 insertions(+), 26 deletions(-) diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 4dd61e36ee29..d3089951afe6 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -254,7 +254,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, */ hdr->status = req->result & 0xff; hdr->masked_status = status_byte(req->result); - hdr->msg_status = msg_byte(req->result); + hdr->msg_status = COMMAND_COMPLETE; hdr->host_status = host_byte(req->result); hdr->driver_status = 0; if (scsi_status_is_check_condition(hdr->status)) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 689ee628eff9..3e6e456816fc 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -741,12 +741,6 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd) if (host_byte(scmd->result) != DID_OK) return FAILED; - /* - * next, check the message byte. - */ - if (msg_byte(scmd->result) != COMMAND_COMPLETE) - return FAILED; - /* * now, check the status byte to see if this indicates * anything special. @@ -1766,8 +1760,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) case DID_PARITY: return (scmd->request->cmd_flags & REQ_FAILFAST_DEV); case DID_ERROR: - if (msg_byte(scmd->result) == COMMAND_COMPLETE && - status_byte(scmd->result) == RESERVATION_CONFLICT) + if (status_byte(scmd->result) == RESERVATION_CONFLICT) return 0; fallthrough; case DID_SOFT_ERROR: @@ -1883,8 +1876,7 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) */ return SUCCESS; case DID_ERROR: - if (msg_byte(scmd->result) == COMMAND_COMPLETE && - status_byte(scmd->result) == RESERVATION_CONFLICT) + if (status_byte(scmd->result) == RESERVATION_CONFLICT) /* * execute reservation conflict processing code * lower down @@ -1912,12 +1904,6 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) return FAILED; } - /* - * next, check the message byte. - */ - if (msg_byte(scmd->result) != COMMAND_COMPLETE) - return FAILED; - /* * check the status byte to see if this indicates anything special. */ diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 6b7d5f03fb2b..065d9e682f06 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1376,7 +1376,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status) srp->header.status = 0xff & result; srp->header.masked_status = status_byte(result); - srp->header.msg_status = msg_byte(result); + srp->header.msg_status = COMMAND_COMPLETE; srp->header.host_status = host_byte(result); srp->header.driver_status = driver_byte(result); if ((sdp->sgdebug > 0) && diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index a6bb2600a2d7..bea22f71c782 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -224,7 +224,7 @@ static void scsiback_print_status(char *sense_buffer, int errors, pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x\n", tpg->tport->tport_name, pending_req->v2p->lun, - pending_req->cmnd[0], status_byte(errors), msg_byte(errors), + pending_req->cmnd[0], status_byte(errors), COMMAND_COMPLETE, host_byte(errors)); } diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 59c5e729f40c..8fe0c628d20b 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -210,11 +210,10 @@ enum scsi_disposition { * These are set by: * * status byte = set from target device - * msg_byte = return status from host adapter itself. + * msg_byte (unused) * host_byte = set by low-level driver to indicate status. */ #define status_byte(result) (((result) >> 1) & 0x7f) -#define msg_byte(result) (((result) >> 8) & 0xff) #define host_byte(result) (((result) >> 16) & 0xff) #define sense_class(sense) (((sense) >> 4) & 0x7) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 69055c2044ff..598b98e4702d 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -321,11 +321,6 @@ static inline u8 get_status_byte(struct scsi_cmnd *cmd) return cmd->result & 0xff; } -static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) -{ - cmd->result = (cmd->result & 0xffff00ff) | (status << 8); -} - static inline void set_host_byte(struct scsi_cmnd *cmd, char status) { cmd->result = (cmd->result & 0xff00ffff) | (status << 16); From patchwork Tue Apr 27 08:30:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225611 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 0F26FC43462 for ; Tue, 27 Apr 2021 08:31:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1F9160234 for ; Tue, 27 Apr 2021 08:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235263AbhD0Ica (ORCPT ); Tue, 27 Apr 2021 04:32:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:49410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235164AbhD0IcL (ORCPT ); Tue, 27 Apr 2021 04:32:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC5B8B16C; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 38/40] scsi: kill message byte Date: Tue, 27 Apr 2021 10:30:44 +0200 Message-Id: <20210427083046.31620-39-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove last vestiges of SCSI status message bytes. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- Documentation/scsi/scsi_mid_low_api.rst | 6 ++--- drivers/scsi/scsi_lib.c | 5 +--- include/trace/events/scsi.h | 33 +------------------------ 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 2c87eaa36296..8728204e2b76 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -1176,9 +1176,9 @@ Members of interest: of 0 implies a successfully completed command (and all data (if any) has been transferred to or from the SCSI target device). 'result' is a 32 bit unsigned integer that - can be viewed as 4 related bytes. The SCSI status value is - in the LSB. See include/scsi/scsi.h status_byte(), - msg_byte() and host_byte() macros and related constants. + can be viewed as 2 related bytes. The SCSI status value is + in the LSB. See include/scsi/scsi.h status_byte() and + host_byte() macros and related constants. sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that should be written when the SCSI status (LSB of 'result') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 612decaccfb5..e8617c6bbf7a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -625,10 +625,7 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) { switch (host_byte(result)) { case DID_OK: - /* - * Also check the other bytes than the status byte in result - */ - if (scsi_status_is_good(result) && (result & ~0xff) == 0) + if (scsi_status_is_good(result)) return BLK_STS_OK; return BLK_STS_IOERR; case DID_TRANSPORT_FAILFAST: diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 428cca71c2ba..370ade0d4093 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -124,37 +124,6 @@ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \ scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) -#define scsi_msgbyte_name(result) { result, #result } -#define show_msgbyte_name(val) \ - __print_symbolic(val, \ - scsi_msgbyte_name(COMMAND_COMPLETE), \ - scsi_msgbyte_name(EXTENDED_MESSAGE), \ - scsi_msgbyte_name(SAVE_POINTERS), \ - scsi_msgbyte_name(RESTORE_POINTERS), \ - scsi_msgbyte_name(DISCONNECT), \ - scsi_msgbyte_name(INITIATOR_ERROR), \ - scsi_msgbyte_name(ABORT_TASK_SET), \ - scsi_msgbyte_name(MESSAGE_REJECT), \ - scsi_msgbyte_name(NOP), \ - scsi_msgbyte_name(MSG_PARITY_ERROR), \ - scsi_msgbyte_name(LINKED_CMD_COMPLETE), \ - scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE), \ - scsi_msgbyte_name(TARGET_RESET), \ - scsi_msgbyte_name(ABORT_TASK), \ - scsi_msgbyte_name(CLEAR_TASK_SET), \ - scsi_msgbyte_name(INITIATE_RECOVERY), \ - scsi_msgbyte_name(RELEASE_RECOVERY), \ - scsi_msgbyte_name(CLEAR_ACA), \ - scsi_msgbyte_name(LOGICAL_UNIT_RESET), \ - scsi_msgbyte_name(SIMPLE_QUEUE_TAG), \ - scsi_msgbyte_name(HEAD_OF_QUEUE_TAG), \ - scsi_msgbyte_name(ORDERED_QUEUE_TAG), \ - scsi_msgbyte_name(IGNORE_WIDE_RESIDUE), \ - scsi_msgbyte_name(ACA), \ - scsi_msgbyte_name(QAS_REQUEST), \ - scsi_msgbyte_name(BUS_DEVICE_RESET), \ - scsi_msgbyte_name(ABORT)) - #define scsi_statusbyte_name(result) { result, #result } #define show_statusbyte_name(val) \ __print_symbolic(val, \ @@ -316,7 +285,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), "DRIVER_OK", show_hostbyte_name(((__entry->result) >> 16) & 0xff), - show_msgbyte_name(((__entry->result) >> 8) & 0xff), + "COMMAND_COMPLETE", show_statusbyte_name(__entry->result & 0xff)) ); From patchwork Tue Apr 27 08:30:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225607 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 30D46C43460 for ; Tue, 27 Apr 2021 08:31:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01A7B600EF for ; Tue, 27 Apr 2021 08:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235257AbhD0Ic3 (ORCPT ); Tue, 27 Apr 2021 04:32:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:50090 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235218AbhD0IcG (ORCPT ); Tue, 27 Apr 2021 04:32:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC804B16D; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 39/40] target: use standard SAM status types Date: Tue, 27 Apr 2021 10:30:45 +0200 Message-Id: <20210427083046.31620-40-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org target_complete_cmd() and friends requires a SAM status type, so passing GOOD here is actually wrong. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche --- drivers/target/target_core_alua.c | 6 +++--- drivers/target/target_core_iblock.c | 2 +- drivers/target/target_core_pr.c | 8 ++++---- drivers/target/target_core_pscsi.c | 2 +- drivers/target/target_core_sbc.c | 10 +++++----- drivers/target/target_core_spc.c | 14 +++++++------- drivers/target/target_core_xcopy.c | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 5517c7dd5144..3bb921345bce 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -123,7 +123,7 @@ target_emulate_report_referrals(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } @@ -255,7 +255,7 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) } transport_kunmap_data_sg(cmd); - target_complete_cmd_with_length(cmd, GOOD, rd_len + 4); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, rd_len + 4); return 0; } @@ -424,7 +424,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd) out: transport_kunmap_data_sg(cmd); if (!rc) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return rc; } diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index d6fdd1c61f90..deb2b8b64d20 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -474,7 +474,7 @@ iblock_execute_zero_out(struct block_device *bdev, struct se_cmd *cmd) if (ret) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 6fd5fec95539..4b94b085625b 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -234,7 +234,7 @@ target_scsi2_reservation_release(struct se_cmd *cmd) out_unlock: spin_unlock(&dev->dev_reservation_lock); out: - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } @@ -297,7 +297,7 @@ target_scsi2_reservation_reserve(struct se_cmd *cmd) spin_unlock(&dev->dev_reservation_lock); out: if (!ret) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; } @@ -3676,7 +3676,7 @@ target_scsi3_emulate_pr_out(struct se_cmd *cmd) } if (!ret) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; } @@ -4073,7 +4073,7 @@ target_scsi3_emulate_pr_in(struct se_cmd *cmd) } if (!ret) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; } diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index dac44caf77a3..d468343bd095 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -1044,7 +1044,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status) struct se_cmd *cmd = req->end_io_data; struct pscsi_plugin_task *pt = cmd->priv; int result = scsi_req(req)->result; - u8 scsi_status = status_byte(result) << 1; + u8 scsi_status = result & 0xff; if (scsi_status != SAM_STAT_GOOD) { pr_debug("PSCSI Status Byte exception at cmd: %p CDB:" diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 7b07e557dc8d..b32f4ee88e79 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -67,7 +67,7 @@ sbc_emulate_readcapacity(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); } - target_complete_cmd_with_length(cmd, GOOD, 8); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8); return 0; } @@ -130,7 +130,7 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); } - target_complete_cmd_with_length(cmd, GOOD, 32); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 32); return 0; } @@ -202,14 +202,14 @@ sbc_execute_write_same_unmap(struct se_cmd *cmd) return ret; } - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } static sense_reason_t sbc_emulate_noop(struct se_cmd *cmd) { - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } @@ -1245,7 +1245,7 @@ sbc_execute_unmap(struct se_cmd *cmd) err: transport_kunmap_data_sg(cmd); if (!ret) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; } diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 70a661801cb9..0756a690ea84 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -750,7 +750,7 @@ spc_emulate_inquiry(struct se_cmd *cmd) kfree(buf); if (!ret) - target_complete_cmd_with_length(cmd, GOOD, len); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, len); return ret; } @@ -1104,7 +1104,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); } - target_complete_cmd_with_length(cmd, GOOD, length); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, length); return 0; } @@ -1122,7 +1122,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) int i; if (!cmd->data_length) { - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } @@ -1165,7 +1165,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); if (!ret) - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; } @@ -1198,7 +1198,7 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); transport_kunmap_data_sg(cmd); - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } @@ -1265,7 +1265,7 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd) transport_kunmap_data_sg(cmd); } - target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8); + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8 + lun_count * 8); return 0; } EXPORT_SYMBOL(spc_emulate_report_luns); @@ -1273,7 +1273,7 @@ EXPORT_SYMBOL(spc_emulate_report_luns); static sense_reason_t spc_emulate_testunitready(struct se_cmd *cmd) { - target_complete_cmd(cmd, GOOD); + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index d31ed071cb08..44d76c304701 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -1011,7 +1011,7 @@ static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd) put_unaligned_be32(42, &p[0]); transport_kunmap_data_sg(se_cmd); - target_complete_cmd(se_cmd, GOOD); + target_complete_cmd(se_cmd, SAM_STAT_GOOD); return TCM_NO_SENSE; } From patchwork Tue Apr 27 08:30:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12225613 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 7DBC5C433ED for ; Tue, 27 Apr 2021 08:31:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49D8761159 for ; Tue, 27 Apr 2021 08:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235303AbhD0Icb (ORCPT ); Tue, 27 Apr 2021 04:32:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:50490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235166AbhD0IcM (ORCPT ); Tue, 27 Apr 2021 04:32:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id F217DB16E; Tue, 27 Apr 2021 08:31:06 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 40/40] scsi: drop obsolete linux-specific SCSI status codes Date: Tue, 27 Apr 2021 10:30:46 +0200 Message-Id: <20210427083046.31620-41-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427083046.31620-1-hare@suse.de> References: <20210427083046.31620-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Originally the SCSI subsystem has been using 'special' SCSI status codes, which were the SAM-specified ones but shifted by 1. As most drivers have now been modified to use the SAM-specified ones having two nearly identical sets of definitions only causes confusion for no good reason. And the linux-specifed SCSI status codes are marked obsolete since several years now. So drop them and use the SAM-specified status codes throughout. Signed-off-by: Hannes Reinecke Reviewed-by: Bart Van Assche Reviewed-by: Douglas Gilbert --- drivers/ata/libata-scsi.c | 2 +- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/scsi/3w-9xxx.c | 2 +- drivers/scsi/3w-xxxx.c | 4 +-- drivers/scsi/53c700.c | 6 ++-- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/arcmsr/arcmsr_hba.c | 4 +-- drivers/scsi/esas2r/esas2r_main.c | 2 +- drivers/scsi/megaraid.c | 4 +-- drivers/scsi/megaraid/megaraid_mbox.c | 4 +-- drivers/scsi/scsi_error.c | 48 +++++++++++++-------------- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/sr.c | 2 +- drivers/scsi/sr_ioctl.c | 2 +- drivers/xen/xen-scsiback.c | 2 +- include/scsi/scsi.h | 1 - include/scsi/scsi_proto.h | 22 +----------- include/scsi/sg.h | 20 +++++++++++ 18 files changed, 65 insertions(+), 66 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 401990e87d50..3aa4bb666616 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -642,7 +642,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, if (cmd->request->rq_flags & RQF_QUIET) qc->flags |= ATA_QCFLAG_QUIET; } else { - cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); + cmd->result = (DID_OK << 16) | SAM_STAT_TASK_SET_FULL; cmd->scsi_done(cmd); } diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 31f8aa2c40ed..62d9b70f7c63 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2232,7 +2232,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) * to reduce queue depth temporarily. */ scmnd->result = len == -ENOMEM ? - DID_OK << 16 | QUEUE_FULL << 1 : DID_ERROR << 16; + DID_OK << 16 | SAM_STAT_TASK_SET_FULL : DID_ERROR << 16; goto err_iu; } diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 47028f5e57ab..259393726ecb 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -1342,7 +1342,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance) /* If error, command failed */ if (error == 1) { /* Ask for a host reset */ - cmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + cmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; } /* Report residual bytes for single sgl */ diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 7a0b4a44395d..4ee485ab2714 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -429,7 +429,7 @@ static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill /* Additional sense code qualifier */ tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3]; - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */ } } @@ -2159,7 +2159,7 @@ static irqreturn_t tw_interrupt(int irq, void *dev_instance) /* If error, command failed */ if (error == 1) { /* Ask for a host reset */ - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; } /* Now complete the io */ diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index ab42feab233f..601a8df0bef3 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -979,10 +979,10 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, if (NCR_700_get_tag_neg_state(SCp->device) == NCR_700_DURING_TAG_NEGOTIATION) NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION); - + /* check for contingent allegiance conditions */ - if (hostdata->status[0] >> 1 == CHECK_CONDITION || - hostdata->status[0] >> 1 == COMMAND_TERMINATED) { + if (hostdata->status[0] == SAM_STAT_CHECK_CONDITION || + hostdata->status[0] == SAM_STAT_COMMAND_TERMINATED) { struct NCR_700_command_slot *slot = (struct NCR_700_command_slot *)SCp->host_scribble; if(slot->flags == NCR_700_FLAG_AUTOSENSE) { diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index a74674941e7d..8aa964cd54df 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -538,7 +538,7 @@ static void complete_cmd(struct Scsi_Host *instance, if (hostdata->sensing == cmd) { /* Autosense processing ends here */ - if (status_byte(cmd->result) != GOOD) { + if (get_status_byte(cmd) != SAM_STAT_GOOD) { scsi_eh_restore_cmnd(cmd, &hostdata->ses); } else { scsi_eh_restore_cmnd(cmd, &hostdata->ses); diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 8e4d7d0e649c..5ea5e6010449 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1326,7 +1326,7 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb) struct scsi_cmnd *pcmd = ccb->pcmd; struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)pcmd->sense_buffer; - pcmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + pcmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; if (sensebuffer) { int sense_data_length = sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE @@ -3242,7 +3242,7 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd, if (!ccb) return SCSI_MLQUEUE_HOST_BUSY; if (arcmsr_build_ccb( acb, ccb, cmd ) == FAILED) { - cmd->result = (DID_ERROR << 16) | (RESERVATION_CONFLICT << 1); + cmd->result = (DID_ERROR << 16) | SAM_STAT_RESERVATION_CONFLICT; cmd->scsi_done(cmd); return 0; } diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index a9dd6345f064..f7818df175a5 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1525,7 +1525,7 @@ void esas2r_complete_request_cb(struct esas2r_adapter *a, rq->cmd->result = ((esas2r_req_status_to_error(rq->req_stat) << 16) - | (rq->func_rsp.scsi_rsp.scsi_stat & STATUS_MASK)); + | rq->func_rsp.scsi_rsp.scsi_stat); if (rq->req_stat == RS_UNDERRUN) scsi_set_resid(rq->cmd, diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 1880471c632a..56910e94dbf2 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1611,7 +1611,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) */ if( cmd->cmnd[0] == TEST_UNIT_READY ) { cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + SAM_STAT_RESERVATION_CONFLICT; } else /* @@ -1623,7 +1623,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->cmnd[0] == RELEASE) ) { cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + SAM_STAT_RESERVATION_CONFLICT; } else #endif diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 674f1c6829f5..db36e4369c2d 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -2327,7 +2327,7 @@ megaraid_mbox_dpc(unsigned long devp) */ if (scp->cmnd[0] == TEST_UNIT_READY) { scp->result = DID_ERROR << 16 | - RESERVATION_CONFLICT << 1; + SAM_STAT_RESERVATION_CONFLICT; } else /* @@ -2338,7 +2338,7 @@ megaraid_mbox_dpc(unsigned long devp) scp->cmnd[0] == RELEASE)) { scp->result = DID_ERROR << 16 | - RESERVATION_CONFLICT << 1; + SAM_STAT_RESERVATION_CONFLICT; } else { scp->result = DID_BAD_TARGET << 16 | status; diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 3e6e456816fc..c6cd5a8e5c85 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -745,32 +745,32 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd) * now, check the status byte to see if this indicates * anything special. */ - switch (status_byte(scmd->result)) { - case GOOD: + switch (get_status_byte(scmd)) { + case SAM_STAT_GOOD: scsi_handle_queue_ramp_up(scmd->device); fallthrough; - case COMMAND_TERMINATED: + case SAM_STAT_COMMAND_TERMINATED: return SUCCESS; - case CHECK_CONDITION: + case SAM_STAT_CHECK_CONDITION: return scsi_check_sense(scmd); - case CONDITION_GOOD: - case INTERMEDIATE_GOOD: - case INTERMEDIATE_C_GOOD: + case SAM_STAT_CONDITION_MET: + case SAM_STAT_INTERMEDIATE: + case SAM_STAT_INTERMEDIATE_CONDITION_MET: /* * who knows? FIXME(eric) */ return SUCCESS; - case RESERVATION_CONFLICT: + case SAM_STAT_RESERVATION_CONFLICT: if (scmd->cmnd[0] == TEST_UNIT_READY) /* it is a success, we probed the device and * found it */ return SUCCESS; /* otherwise, we failed to send the command */ return FAILED; - case QUEUE_FULL: + case SAM_STAT_TASK_SET_FULL: scsi_handle_queue_full(scmd->device); fallthrough; - case BUSY: + case SAM_STAT_BUSY: return NEEDS_RETRY; default: return FAILED; @@ -1760,7 +1760,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) case DID_PARITY: return (scmd->request->cmd_flags & REQ_FAILFAST_DEV); case DID_ERROR: - if (status_byte(scmd->result) == RESERVATION_CONFLICT) + if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) return 0; fallthrough; case DID_SOFT_ERROR: @@ -1876,7 +1876,7 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) */ return SUCCESS; case DID_ERROR: - if (status_byte(scmd->result) == RESERVATION_CONFLICT) + if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) /* * execute reservation conflict processing code * lower down @@ -1907,15 +1907,15 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) /* * check the status byte to see if this indicates anything special. */ - switch (status_byte(scmd->result)) { - case QUEUE_FULL: + switch (get_status_byte(scmd)) { + case SAM_STAT_TASK_SET_FULL: scsi_handle_queue_full(scmd->device); /* * the case of trying to send too many commands to a * tagged queueing device. */ fallthrough; - case BUSY: + case SAM_STAT_BUSY: /* * device can't talk to us at the moment. Should only * occur (SAM-3) when the task queue is empty, so will cause @@ -1923,16 +1923,16 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) * device. */ return ADD_TO_MLQUEUE; - case GOOD: + case SAM_STAT_GOOD: if (scmd->cmnd[0] == REPORT_LUNS) scmd->device->sdev_target->expecting_lun_change = 0; scsi_handle_queue_ramp_up(scmd->device); fallthrough; - case COMMAND_TERMINATED: + case SAM_STAT_COMMAND_TERMINATED: return SUCCESS; - case TASK_ABORTED: + case SAM_STAT_TASK_ABORTED: goto maybe_retry; - case CHECK_CONDITION: + case SAM_STAT_CHECK_CONDITION: rtn = scsi_check_sense(scmd); if (rtn == NEEDS_RETRY) goto maybe_retry; @@ -1941,16 +1941,16 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) * to collect the sense and redo the decide * disposition */ return rtn; - case CONDITION_GOOD: - case INTERMEDIATE_GOOD: - case INTERMEDIATE_C_GOOD: - case ACA_ACTIVE: + case SAM_STAT_CONDITION_MET: + case SAM_STAT_INTERMEDIATE: + case SAM_STAT_INTERMEDIATE_CONDITION_MET: + case SAM_STAT_ACA_ACTIVE: /* * who knows? FIXME(eric) */ return SUCCESS; - case RESERVATION_CONFLICT: + case SAM_STAT_RESERVATION_CONFLICT: sdev_printk(KERN_INFO, scmd->device, "reservation conflict\n"); set_host_byte(scmd, DID_NEXUS_FAILURE); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e8617c6bbf7a..89b1bef5877c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -907,7 +907,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result, * if it can't fit). Treat SAM_STAT_CONDITION_MET and the related * intermediate statuses (both obsolete in SAM-4) as good. */ - if (status_byte(result) && scsi_status_is_good(result)) { + if ((result & 0xff) && scsi_status_is_good(result)) { result = 0; *blk_statp = BLK_STS_OK; } diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index e9cb874f6891..482a07b662a9 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -338,7 +338,7 @@ static int sr_done(struct scsi_cmnd *SCpnt) * care is taken to avoid unnecessary additional work such as * memcpy's that could be avoided. */ - if (status_byte(result) == SAM_STAT_CHECK_CONDITION && + if (scsi_status_is_check_condition(result) && (SCpnt->sense_buffer[0] & 0x7f) == 0x70) { /* Sense current */ switch (SCpnt->sense_buffer[2]) { case MEDIUM_ERROR: diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 74348ead5b11..b34a5332fd2d 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -209,7 +209,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) err = result; goto out; } - if (status_byte(result) == SAM_STAT_CHECK_CONDITION) { + if (scsi_status_is_check_condition(result)) { switch (sshdr->sense_key) { case UNIT_ATTENTION: SDev->changed = 1; diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index bea22f71c782..61ce0d142eea 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -224,7 +224,7 @@ static void scsiback_print_status(char *sense_buffer, int errors, pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x\n", tpg->tport->tport_name, pending_req->v2p->lun, - pending_req->cmnd[0], status_byte(errors), COMMAND_COMPLETE, + pending_req->cmnd[0], errors & 0xff, COMMAND_COMPLETE, host_byte(errors)); } diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 8fe0c628d20b..e39057c38208 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -213,7 +213,6 @@ enum scsi_disposition { * msg_byte (unused) * host_byte = set by low-level driver to indicate status. */ -#define status_byte(result) (((result) >> 1) & 0x7f) #define host_byte(result) (((result) >> 16) & 0xff) #define sense_class(sense) (((sense) >> 4) & 0x7) diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h index c36860111932..80bb1c5f11f1 100644 --- a/include/scsi/scsi_proto.h +++ b/include/scsi/scsi_proto.h @@ -202,27 +202,7 @@ struct scsi_varlen_cdb_hdr { #define SAM_STAT_ACA_ACTIVE 0x30 #define SAM_STAT_TASK_ABORTED 0x40 -/* - * Status codes. These are deprecated as they are shifted 1 bit right - * from those found in the SCSI standards. This causes confusion for - * applications that are ported to several OSes. Prefer SAM Status codes - * above. - */ - -#define GOOD 0x00 -#define CHECK_CONDITION 0x01 -#define CONDITION_GOOD 0x02 -#define BUSY 0x04 -#define INTERMEDIATE_GOOD 0x08 -#define INTERMEDIATE_C_GOOD 0x0a -#define RESERVATION_CONFLICT 0x0c -#define COMMAND_TERMINATED 0x11 -#define QUEUE_FULL 0x14 -#define ACA_ACTIVE 0x18 -#define TASK_ABORTED 0x20 - -#define STATUS_MASK 0xfe - +#define STATUS_MASK 0xfe /* * SENSE KEYS */ diff --git a/include/scsi/sg.h b/include/scsi/sg.h index f6b18591ed9d..49a393694b29 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -145,6 +145,26 @@ struct compat_sg_io_hdr { /* Obsolete driver_byte() declaration */ #define driver_byte(result) (((result) >> 24) & 0xff) +/* + * Original linux SCSI Status codes. They are shifted 1 bit right + * from those found in the SCSI standards. + */ + +#define GOOD 0x00 +#define CHECK_CONDITION 0x01 +#define CONDITION_GOOD 0x02 +#define BUSY 0x04 +#define INTERMEDIATE_GOOD 0x08 +#define INTERMEDIATE_C_GOOD 0x0a +#define RESERVATION_CONFLICT 0x0c +#define COMMAND_TERMINATED 0x11 +#define QUEUE_FULL 0x14 +#define ACA_ACTIVE 0x18 +#define TASK_ABORTED 0x20 + +/* Obsolete status_byte() declaration */ +#define status_byte(result) (((result) >> 1) & 0x7f) + typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ int host_no; /* as in "scsi" where 'n' is one of 0, 1, 2 etc */ int channel;