From owner-svn-src-all@freebsd.org Tue Nov 3 21:38:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E07E9464A89; Tue, 3 Nov 2020 21:38:59 +0000 (UTC) (envelope-from kibab@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CQjpW5X47z4Tgn; Tue, 3 Nov 2020 21:38:59 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1014210DD; Tue, 3 Nov 2020 21:38:59 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0A3LcxGV002127; Tue, 3 Nov 2020 21:38:59 GMT (envelope-from kibab@FreeBSD.org) Received: (from kibab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0A3LcxWt002126; Tue, 3 Nov 2020 21:38:59 GMT (envelope-from kibab@FreeBSD.org) Message-Id: <202011032138.0A3LcxWt002126@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kibab set sender to kibab@FreeBSD.org using -f From: Ilya Bakulin Date: Tue, 3 Nov 2020 21:38:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367306 - head/sys/cam/mmc X-SVN-Group: head X-SVN-Commit-Author: kibab X-SVN-Commit-Paths: head/sys/cam/mmc X-SVN-Commit-Revision: 367306 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Nov 2020 21:38:59 -0000 Author: kibab Date: Tue Nov 3 21:38:59 2020 New Revision: 367306 URL: https://svnweb.freebsd.org/changeset/base/367306 Log: Always return MMC errors from mmc_handle_reply() There are two ways to propagate the error in MMCCAM: * Using cmd.error which is set by the peripheral driver; * Using CCB status which is... also set by the driver. The problem is that those two error conditions don't necessarily match. This leads to the confusion when handling the MMC reply. So enforce the consistency by panicking if request is marked as completed successfully but MMC-level error is present (this hints to the programming error). Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D26925 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Tue Nov 3 20:43:01 2020 (r367305) +++ head/sys/cam/mmc/mmc_da.c Tue Nov 3 21:38:59 2020 (r367306) @@ -239,31 +239,29 @@ get_rca(struct cam_periph *periph) { /* * Figure out if CCB execution resulted in error. * Look at both CAM-level errors and on MMC protocol errors. + * + * Return value is always MMC error. */ static int mmc_handle_reply(union ccb *ccb) { - KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", ccb, ccb->ccb_h.func_code)); - /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - xpt_print_path(ccb->ccb_h.path); - printf("CMD%d failed, err %d (%s)\n", - ccb->mmcio.cmd.opcode, - ccb->mmcio.cmd.error, - mmc_errmsg[ccb->mmcio.cmd.error]); - return (EIO); - } - } else { - cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); - return (EIO); - } + /* CAM-level error should always correspond to MMC-level error */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) && + (ccb->mmcio.cmd.error != MMC_ERR_NONE)) + panic("CCB status is OK but MMC error != MMC_ERR_NONE"); - return (0); /* Normal return */ + if (ccb->mmcio.cmd.error != MMC_ERR_NONE) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + } + return (ccb->mmcio.cmd.error); } static uint32_t