From nobody Tue Oct 19 15:16:01 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B5229180C138; Tue, 19 Oct 2021 15:16:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HYcl54mKxz3mgc; Tue, 19 Oct 2021 15:16:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83C0B1678B; Tue, 19 Oct 2021 15:16:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19JFG1XW083076; Tue, 19 Oct 2021 15:16:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFG1xZ083075; Tue, 19 Oct 2021 15:16:01 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:16:01 GMT Message-Id: <202110191516.19JFG1xZ083075@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 9abf1f741d54 - stable/12 - ciss(4): Properly handle data underrun. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9abf1f741d541a4a1ab684cc417cc6660b0cba1a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=9abf1f741d541a4a1ab684cc417cc6660b0cba1a commit 9abf1f741d541a4a1ab684cc417cc6660b0cba1a Author: Alexander Motin AuthorDate: 2021-09-19 17:45:51 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:13:31 +0000 ciss(4): Properly handle data underrun. For SCSI data underrun is a part of normal life. It should not be reported as error. This fixes MODE SENSE used by modern CAM. MFC after: 1 month (cherry picked from commit e8144a13e075ff13c1f162690c7f14dd3f0a4862) --- sys/dev/ciss/ciss.c | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index 3cfeb90e9f06..34d3aeb6dae8 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -2336,13 +2336,15 @@ _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_sta if (command_status != NULL) *command_status = ce->command_status; if (scsi_status != NULL) { - if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { + if (ce->command_status == CISS_CMD_STATUS_DATA_UNDERRUN) { + *scsi_status = SCSI_STATUS_OK; + } else if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { *scsi_status = ce->scsi_status; } else { *scsi_status = -1; } } - if (bootverbose) + if (bootverbose && ce->command_status != CISS_CMD_STATUS_DATA_UNDERRUN) ciss_printf(cr->cr_sc, "command status 0x%x (%s) scsi status 0x%x\n", ce->command_status, ciss_name_command_status(ce->command_status), ce->scsi_status); @@ -3318,28 +3320,17 @@ ciss_cam_complete(struct ciss_request *cr) * Extract status values from request. */ ciss_report_request(cr, &command_status, &scsi_status); - csio->scsi_status = scsi_status; - - /* - * Handle specific SCSI status values. - */ - switch(scsi_status) { - /* no status due to adapter error */ - case -1: - debug(0, "adapter error"); - csio->ccb_h.status |= CAM_REQ_CMP_ERR; - break; - - /* no status due to command completed OK */ - case SCSI_STATUS_OK: /* CISS_SCSI_STATUS_GOOD */ + switch(command_status) { + case CISS_CMD_STATUS_DATA_UNDERRUN: + csio->resid = ce->residual_count; + /* FALLTHROUGH */ + case CISS_CMD_STATUS_SUCCESS: + csio->scsi_status = scsi_status; debug(2, "SCSI_STATUS_OK"); csio->ccb_h.status |= CAM_REQ_CMP; break; - - /* check condition, sense data included */ - case SCSI_STATUS_CHECK_COND: /* CISS_SCSI_STATUS_CHECK_CONDITION */ - debug(0, "SCSI_STATUS_CHECK_COND sense size %d resid %d\n", - ce->sense_length, ce->residual_count); + case CISS_CMD_STATUS_TARGET_STATUS: + csio->scsi_status = scsi_status; bzero(&csio->sense_data, SSD_FULL_SIZE); bcopy(&ce->sense_info[0], &csio->sense_data, ce->sense_length); if (csio->sense_len > ce->sense_length) @@ -3348,22 +3339,11 @@ ciss_cam_complete(struct ciss_request *cr) csio->sense_resid = 0; csio->resid = ce->residual_count; csio->ccb_h.status |= CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; -#ifdef CISS_DEBUG - { - struct scsi_sense_data *sns = (struct scsi_sense_data *)&ce->sense_info[0]; - debug(0, "sense key %x", scsi_get_sense_key(sns, csio->sense_len - - csio->sense_resid, /*show_errors*/ 1)); - } -#endif break; - - case SCSI_STATUS_BUSY: /* CISS_SCSI_STATUS_BUSY */ - debug(0, "SCSI_STATUS_BUSY"); - csio->ccb_h.status |= CAM_SCSI_BUSY; + case CISS_CMD_STATUS_DATA_OVERRUN: + csio->ccb_h.status |= CAM_DATA_RUN_ERR; break; - default: - debug(0, "unknown status 0x%x", csio->scsi_status); csio->ccb_h.status |= CAM_REQ_CMP_ERR; break; }