From owner-dev-commits-src-all@freebsd.org Thu Jul 22 17:19:58 2021 Return-Path: Delivered-To: dev-commits-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 53C696622C7; Thu, 22 Jul 2021 17:19:58 +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 4GVzjB1pZjz4Wpp; Thu, 22 Jul 2021 17:19:58 +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 2734915D2F; Thu, 22 Jul 2021 17:19:58 +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 16MHJwiG092164; Thu, 22 Jul 2021 17:19:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16MHJwhJ092163; Thu, 22 Jul 2021 17:19:58 GMT (envelope-from git) Date: Thu, 22 Jul 2021 17:19:58 GMT Message-Id: <202107221719.16MHJwhJ092163@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: f5ca54f31268 - stable/13 - mmc_cam_sim_default_action: do not touch the ccb after dispatching it MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f5ca54f31268534b8b2032aa888e5b6870062dae Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 17:19:58 -0000 The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=f5ca54f31268534b8b2032aa888e5b6870062dae commit f5ca54f31268534b8b2032aa888e5b6870062dae Author: Andriy Gapon AuthorDate: 2021-07-09 14:53:17 +0000 Commit: Emmanuel Vadot CommitDate: 2021-07-22 17:19:38 +0000 mmc_cam_sim_default_action: do not touch the ccb after dispatching it If MMC_SIM_CAM_REQUEST() is successful the ccb could be running or being completed as the method returns. Modifying the ccb status could override whatever status was already set by a MMC driver. I am not sure what was the purpose of setting the status to CAM_REQ_INVALID in the success path. I assume that it was to catch a possibility that the ccb could be completed without its status explicitly set. So, I am keeping the code, it's just moved to before the MMC_SIM_CAM_REQUEST call. Without this change I was getting random and phantom EIO errors on Rock64 running off an SD card (dwmmc driver) plus occasional panics like: Memory modified after free 0xffffa00003985800(2040) val=6 @ 0xffffa00003985854 panic: Most recently used by CAM CCB MFC after: 1 week (cherry picked from commit 66c183f43f0c05ed9238ed9c1859c0c9df7b66dd) --- sys/cam/mmc/mmc_sim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/cam/mmc/mmc_sim.c b/sys/cam/mmc/mmc_sim.c index 1500e3f6f1cd..6fe38f26d339 100644 --- a/sys/cam/mmc/mmc_sim.c +++ b/sys/cam/mmc/mmc_sim.c @@ -150,11 +150,10 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) break; case XPT_MMC_IO: { + ccb->ccb_h.status = CAM_REQ_INVALID; rv = MMC_SIM_CAM_REQUEST(mmc_sim->dev, ccb); if (rv != 0) ccb->ccb_h.status = CAM_SIM_QUEUED; - else - ccb->ccb_h.status = CAM_REQ_INVALID; return; /* NOTREACHED */ break;