Date: Tue, 3 Nov 2020 21:38:59 +0000 (UTC) From: Ilya Bakulin <kibab@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367306 - head/sys/cam/mmc Message-ID: <202011032138.0A3LcxWt002126@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011032138.0A3LcxWt002126>