Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2581655imm; Sat, 13 Oct 2018 23:35:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV62xtmcLSpGUadAjsSwDLpU+ueoRFFQ89o8lBqRk33n/pBHGccBkCHSJNYJ7xNbQp0LmgSo4 X-Received: by 2002:a63:fd09:: with SMTP id d9-v6mr11852608pgh.164.1539498935725; Sat, 13 Oct 2018 23:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539498935; cv=none; d=google.com; s=arc-20160816; b=J/qGpblFVMi0XuC87XF4SS2RECXtJLkKd8y54rK+AqDBAMZoHjtIJ/JKJ5IdbrQhjN mC0zS59/gNuujSnzM6KomAEW/C4docwdDLAjfti6FYDLIxaiNpEdefjPIJVrtIqcbcyS b/FBGUJ6XmlYN5yl5+9OoXc4DzzvdA2ObXSSOlY1c05CyEo10o9nS/Y5JvhGqKFgK4YP OS2jxjiFi3TmKcAaQfvXqoxofHf835aISfJZkVMLknnIOsH8a3qcsiiLZVX8EOFxT80/ VRvUf5tRvYsqfm2FyETk0w4FwJBvGPZ33h2t0jOuFspSmUIskzfACCVJVFiJw6wMr4ij TnNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=yKr9VHkxkxG3vZPKxa20A45bd+0rCdnxXjp/UtlMtTc=; b=JTjDUdInt2Cr+Tc33jdf0hj1oOaFPtnWzyWR1GfDz/nqfl0V+jd1wL99f1Hqm7L38i jYGdm09LKXmLmdNS4a9kGgJ9RzgA8nY9/aMLR93I56c+b6wHYXDScxpUe6nXXNLz5GgN TKrn5uBqhlS5AwVy2cUzHFaYvv7UMxKAIk5q8H9ucWC52eKMf00ZLqCvN4bllMjqT2aj nTBKf/aQak6aU+fZ4Kh05RLo5Ic3nyk5xVgpSTKVbbF9asE9RAyupTZ3RNz/DCLjxpr+ DR35t8ljC9fAegeCsWoAoBUxEX0Ume6b5QuYRWs1RquF+wbmLqtrPEEYNZdSXR+o7iKP DV4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si944442pls.73.2018.10.13.23.35.21; Sat, 13 Oct 2018 23:35:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbeJNOOO (ORCPT + 99 others); Sun, 14 Oct 2018 10:14:14 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:42612 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbeJNOOO (ORCPT ); Sun, 14 Oct 2018 10:14:14 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 412E22A1CD; Sun, 14 Oct 2018 02:34:18 -0400 (EDT) To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Michael Schmitz , Hannes Reinecke , linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-Id: <7e8229dc8d3c27e7eff7e2111e2475fbf2521766.1539497520.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH v2 4/6] esp_scsi: Eliminate ESP_FLAG_DOING_SLOWCMD Date: Sun, 14 Oct 2018 17:12:00 +1100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The concept of a 'slow command' as it appears in esp_scsi is confusing because it could refer to an ESP command or a SCSI command. It turns out that it refers to a particular ESP select command which the driver also tracks as 'ESP_SELECT_MSGOUT'. For readability, it is better to use the terminology from the datasheets. The global ESP_FLAG_DOING_SLOWCMD flag is redundant anyway, as it can be inferred from esp->select_state. Remove the ESP_FLAG_DOING_SLOWCMD cruft and just use a boolean local variable. Tested-by: Stan Johnson Signed-off-by: Finn Thain Tested-by: Michael Schmitz --- drivers/scsi/esp_scsi.c | 57 +++++++++++++++++------------------------ drivers/scsi/esp_scsi.h | 3 +-- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index b7c41aa9927c..6ccaf818357e 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -478,17 +478,6 @@ static void esp_restore_pointers(struct esp *esp, struct esp_cmd_entry *ent) spriv->tot_residue = ent->saved_tot_residue; } -static void esp_check_command_len(struct esp *esp, struct scsi_cmnd *cmd) -{ - if (cmd->cmd_len == 6 || - cmd->cmd_len == 10 || - cmd->cmd_len == 12) { - esp->flags &= ~ESP_FLAG_DOING_SLOWCMD; - } else { - esp->flags |= ESP_FLAG_DOING_SLOWCMD; - } -} - static void esp_write_tgt_config3(struct esp *esp, int tgt) { if (esp->rev > ESP100A) { @@ -721,6 +710,7 @@ static void esp_maybe_execute_command(struct esp *esp) struct scsi_device *dev; struct scsi_cmnd *cmd; struct esp_cmd_entry *ent; + bool select_and_stop = false; int tgt, lun, i; u32 val, start_cmd; u8 *p; @@ -752,7 +742,8 @@ static void esp_maybe_execute_command(struct esp *esp) esp_map_dma(esp, cmd); esp_save_pointers(esp, ent); - esp_check_command_len(esp, cmd); + if (!(cmd->cmd_len == 6 || cmd->cmd_len == 10 || cmd->cmd_len == 12)) + select_and_stop = true; p = esp->command_block; @@ -793,9 +784,9 @@ static void esp_maybe_execute_command(struct esp *esp) tp->flags &= ~ESP_TGT_CHECK_NEGO; } - /* Process it like a slow command. */ - if (tp->flags & (ESP_TGT_NEGO_WIDE | ESP_TGT_NEGO_SYNC)) - esp->flags |= ESP_FLAG_DOING_SLOWCMD; + /* If there are multiple message bytes, use Select and Stop */ + if (esp->msg_out_len) + select_and_stop = true; } build_identify: @@ -808,23 +799,10 @@ static void esp_maybe_execute_command(struct esp *esp) /* ESP100 lacks select w/atn3 command, use select * and stop instead. */ - esp->flags |= ESP_FLAG_DOING_SLOWCMD; + select_and_stop = true; } - if (!(esp->flags & ESP_FLAG_DOING_SLOWCMD)) { - start_cmd = ESP_CMD_SELA; - if (ent->tag[0]) { - *p++ = ent->tag[0]; - *p++ = ent->tag[1]; - - start_cmd = ESP_CMD_SA3; - } - - for (i = 0; i < cmd->cmd_len; i++) - *p++ = cmd->cmnd[i]; - - esp->select_state = ESP_SELECT_BASIC; - } else { + if (select_and_stop) { esp->cmd_bytes_left = cmd->cmd_len; esp->cmd_bytes_ptr = &cmd->cmnd[0]; @@ -839,6 +817,19 @@ static void esp_maybe_execute_command(struct esp *esp) start_cmd = ESP_CMD_SELAS; esp->select_state = ESP_SELECT_MSGOUT; + } else { + start_cmd = ESP_CMD_SELA; + if (ent->tag[0]) { + *p++ = ent->tag[0]; + *p++ = ent->tag[1]; + + start_cmd = ESP_CMD_SA3; + } + + for (i = 0; i < cmd->cmd_len; i++) + *p++ = cmd->cmnd[i]; + + esp->select_state = ESP_SELECT_BASIC; } val = tgt; if (esp->rev == FASHME) @@ -1248,7 +1239,6 @@ static int esp_finish_select(struct esp *esp) esp_unmap_dma(esp, cmd); esp_free_lun_tag(ent, cmd->device->hostdata); tp->flags &= ~(ESP_TGT_NEGO_SYNC | ESP_TGT_NEGO_WIDE); - esp->flags &= ~ESP_FLAG_DOING_SLOWCMD; esp->cmd_bytes_ptr = NULL; esp->cmd_bytes_left = 0; } else { @@ -1299,9 +1289,8 @@ static int esp_finish_select(struct esp *esp) esp_flush_fifo(esp); } - /* If we are doing a slow command, negotiation, etc. - * we'll do the right thing as we transition to the - * next phase. + /* If we are doing a Select And Stop command, negotiation, etc. + * we'll do the right thing as we transition to the next phase. */ esp_event(esp, ESP_EVENT_CHECK_PHASE); return 0; diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h index db4b6ea94caa..d0c032803749 100644 --- a/drivers/scsi/esp_scsi.h +++ b/drivers/scsi/esp_scsi.h @@ -490,7 +490,6 @@ struct esp { u32 flags; #define ESP_FLAG_DIFFERENTIAL 0x00000001 #define ESP_FLAG_RESETTING 0x00000002 -#define ESP_FLAG_DOING_SLOWCMD 0x00000004 #define ESP_FLAG_WIDE_CAPABLE 0x00000008 #define ESP_FLAG_QUICKIRQ_CHECK 0x00000010 #define ESP_FLAG_DISABLE_SYNC 0x00000020 @@ -532,7 +531,7 @@ struct esp { u32 min_period; u32 radelay; - /* Slow command state. */ + /* ESP_CMD_SELAS command state */ u8 *cmd_bytes_ptr; int cmd_bytes_left; -- 2.18.1