From nobody Wed Oct 16 14:44:12 2024 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 4XTDHw3H1pz5Yc63; Wed, 16 Oct 2024 14:44:12 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XTDHw2Q7qz4VcV; Wed, 16 Oct 2024 14:44:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729089852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NwbnqU2/xr/jSYfJRcCFsnUTkFp6UyD0bNp7NfkkeVM=; b=iZDAIzqY8uU130XDrHW/2nS0wYOXE2kNBCBv1ObC2XWHXLiTLnD3RLSDcm2fdScuuPdWxN 8oRsuZfwii3UL1Qn0i+42h+QUSr1hjCEvTcZiILYxeZXzO5aCfk9B+VaBq9w8KGrwppMdy ZZZQBWkj24APBe3coXmv3EorUm7nFJUmha8TvrpEGazCkABxoWVnkUiu8wKZg513M6Aluq xFSJO+jG2h8NB0ML2RuPyEkrCXgLNOhBtrDiLCntNVW2H7o8ID5Ys+5UDh23hIU+/1zh9L jWgQE+ls1ytWiC+Goh7HbAuYbZiQk+Ht7hSWRcoIDNf8mK5/9pcFbFCeZZENTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729089852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NwbnqU2/xr/jSYfJRcCFsnUTkFp6UyD0bNp7NfkkeVM=; b=HQxOfVhu5o0cKpxAVfFZcpL83L2PmjXPrWhPxUlEQUOi5aRTBjVWtBM0tSgsyTywJDEjrg 0wd1irp3P/cnS+CrfCIqUW48rdXiYUVwbEqfG7T3pPr8hZXDFK/ndEWWSZMKJ8U+yRVy4S qf8Nk2LPX4zSBvylI0r8c+ZLHO9Qfc/+R4TVsEr8qJ85BUCUFBemJcCI752fQqI1JJNe8K 1KkTb/QXR6eTW8ud8k8FxbARIqy3OL3LCLwyQh8VmxLHkT/B18GU6dkFp12AqazggmII/c 61foWfcuhXkRfn33ZuAuUXJD6VrXz2o2QFiYaHXUT8h3C4hOrnvDovNu+oIGhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729089852; a=rsa-sha256; cv=none; b=e6i/UtBLp8H5ENblihj7hO9qDWb18/BU/I6RWbOD9lrRVNkax1JGmHQGPfYYu74KkAG4Ij BbJIaK6+mNF8E1OCOMCuqQoVzZjR8ErBzWLq9d+sTOTd4+gthrw5e3Jv+p5XAjrq0uTHzo Ufd9UNJlEckIGh7oOCUvnUYErvE+1xTZF8W6ja0HjpDknt3Nar7P1rZ2zV29fFGQaaOfrY ip62hWCJmEyAqxr4uBIhhz1osM93vvMZpmw5UXzlZjkhTv8ntHQKAmwqhnwQjD4wqBsjlD xzTYGL+Oe0FnxgK+kPV4sAs1RyU7GnOKTVpB8B2iYCe+F7GD1MAGGGlwlG2niQ== 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 4XTDHw20vcz199d; Wed, 16 Oct 2024 14:44:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49GEiC5I007142; Wed, 16 Oct 2024 14:44:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49GEiCa1007139; Wed, 16 Oct 2024 14:44:12 GMT (envelope-from git) Date: Wed, 16 Oct 2024 14:44:12 GMT Message-Id: <202410161444.49GEiCa1007139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: e360f8c8fecc - stable/13 - mps/mpr: Add workaround for firmware not responding to IOC_FACTS or IOC_INIT 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e360f8c8fecc78d8f2aa2aee46940ec5eca86c87 Auto-Submitted: auto-generated The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e360f8c8fecc78d8f2aa2aee46940ec5eca86c87 commit e360f8c8fecc78d8f2aa2aee46940ec5eca86c87 Author: prateek sethi AuthorDate: 2024-10-13 18:38:54 +0000 Commit: Warner Losh CommitDate: 2024-10-16 14:33:33 +0000 mps/mpr: Add workaround for firmware not responding to IOC_FACTS or IOC_INIT Sometimes, especially with older firmware, mps(4) would have trouble initializing the card in one of these two steps. Add in a retry after a short delay. Sean Bruno and Stephen McConnell thought this was OK in the bug discussions, but never committed it. Steve indicated the delay might not be necessary, but the OP clearly needed to make it longer to make things work. I've kept the delay, and added the suggested comment. Ported the iocfacts part to mpr as well, since we see similar errors about once every month or two over a few thousand controllers at work. We've not seen it with IOC_INIT as far back as I can query the error log database, so I didn't port that forward. We'll see if this helps, but won't know for sure until next year (so I'm committing it now since it won't hurt and might help). We usually see this failure in connection with complicated recovery operations with a drive that's failing, though, at least in the last year's worth of failures. It's not clear this is the same as OP or not. PR: 212841 Sponsored by: Netflix Co-authored-by: imp (cherry picked from commit c0e0e530ced057502f51d7a6086857305e08fae0) --- sys/dev/mpr/mpr.c | 23 ++++++++++++++++++----- sys/dev/mps/mps.c | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index f042f71825b5..f87b55c3dba5 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -1195,7 +1195,7 @@ mpr_get_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) { MPI2_DEFAULT_REPLY *reply; MPI2_IOC_FACTS_REQUEST request; - int error, req_sz, reply_sz; + int error, req_sz, reply_sz, retry = 0; MPR_FUNCTRACE(sc); mpr_dprint(sc, MPR_INIT, "%s entered\n", __func__); @@ -1204,13 +1204,26 @@ mpr_get_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) reply_sz = sizeof(MPI2_IOC_FACTS_REPLY); reply = (MPI2_DEFAULT_REPLY *)facts; + /* + * Retry sending the initialization sequence. Sometimes, especially with + * older firmware, the initialization process fails. Retrying allows the + * error to clear in the firmware. + */ bzero(&request, req_sz); request.Function = MPI2_FUNCTION_IOC_FACTS; - error = mpr_request_sync(sc, &request, reply, req_sz, reply_sz, 5); - - adjust_iocfacts_endianness(facts); - mpr_dprint(sc, MPR_TRACE, "facts->IOCCapabilities 0x%x\n", facts->IOCCapabilities); + while (retry < 5) { + error = mpr_request_sync(sc, &request, reply, req_sz, reply_sz, 5); + if (error == 0) + break; + mpr_dprint(sc, MPR_FAULT, "%s failed retry %d\n", __func__, retry); + DELAY(1000); + retry++; + } + if (error == 0) { + adjust_iocfacts_endianness(facts); + mpr_dprint(sc, MPR_TRACE, "facts->IOCCapabilities 0x%x\n", facts->IOCCapabilities); + } mpr_dprint(sc, MPR_INIT, "%s exit, error= %d\n", __func__, error); return (error); } diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index ca037071c298..33b64fe7f9cf 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -1127,7 +1127,7 @@ mps_get_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts) { MPI2_DEFAULT_REPLY *reply; MPI2_IOC_FACTS_REQUEST request; - int error, req_sz, reply_sz; + int error, req_sz, reply_sz, retry = 0; MPS_FUNCTRACE(sc); mps_dprint(sc, MPS_INIT, "%s entered\n", __func__); @@ -1136,10 +1136,21 @@ mps_get_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts) reply_sz = sizeof(MPI2_IOC_FACTS_REPLY); reply = (MPI2_DEFAULT_REPLY *)facts; + /* + * Retry sending the initialization sequence. Sometimes, especially with + * older firmware, the initialization process fails. Retrying allows the + * error to clear in the firmware. + */ bzero(&request, req_sz); request.Function = MPI2_FUNCTION_IOC_FACTS; - error = mps_request_sync(sc, &request, reply, req_sz, reply_sz, 5); - mps_dprint(sc, MPS_INIT, "%s exit error= %d\n", __func__, error); + while (retry < 5) { + error = mps_request_sync(sc, &request, reply, req_sz, reply_sz, 5); + if (error == 0) + break; + mps_dprint(sc, MPS_FAULT, "%s failed retry %d\n", __func__, retry); + DELAY(1000); + retry++; + } return (error); } @@ -1149,7 +1160,7 @@ mps_send_iocinit(struct mps_softc *sc) { MPI2_IOC_INIT_REQUEST init; MPI2_DEFAULT_REPLY reply; - int req_sz, reply_sz, error; + int req_sz, reply_sz, error, retry = 0; struct timeval now; uint64_t time_in_msec; @@ -1193,10 +1204,21 @@ mps_send_iocinit(struct mps_softc *sc) time_in_msec = (now.tv_sec * 1000 + now.tv_usec/1000); init.TimeStamp.High = htole32((time_in_msec >> 32) & 0xFFFFFFFF); init.TimeStamp.Low = htole32(time_in_msec & 0xFFFFFFFF); - - error = mps_request_sync(sc, &init, &reply, req_sz, reply_sz, 5); - if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS) - error = ENXIO; + /* + * Retry sending the initialization sequence. Sometimes, especially with + * older firmware, the initialization process fails. Retrying allows the + * error to clear in the firmware. + */ + while (retry < 5) { + error = mps_request_sync(sc, &init, &reply, req_sz, reply_sz, 5); + if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS) + error = ENXIO; + if (error == 0) + break; + mps_dprint(sc, MPS_FAULT, "%s failed retry %d\n", __func__, retry); + DELAY(1000); + retry++; + } mps_dprint(sc, MPS_INIT, "IOCInit status= 0x%x\n", reply.IOCStatus); mps_dprint(sc, MPS_INIT, "%s exit\n", __func__);