From nobody Wed Oct 16 14:32:03 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 4XTD1v3xNSz5YbQM; Wed, 16 Oct 2024 14:32:03 +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 4XTD1v3Sjpz4Rqp; Wed, 16 Oct 2024 14:32:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729089123; 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=GgDGzcFyPvM2WE+onfaKQYV85Sd97CfvTkQsk+nmZKA=; b=Fq7l3l7hQ3pgjTs2+8Fw1oHI0I2mdUAIVvm8TgnZRRIcC3cvG+xvcWwT08cOe25kGOXtQ8 OPLBlmYdY0dBP6hzNgVWrK99ngX859DOuSvvA9hyLU5hN8EIjbHnh5CqRB/gdkUvkydECn t0euQxB6ixNAaM+cE41Nu/WT5UEF3yZqTIGlI12a2onCFyViWZ94ReBDCTOlMKRf8B7NF9 pJWm7FiernGzBh8/K6YXkGjH5yDVDKEIxP0zJFT3D7hZ8nYFega/oPb6EE/pXswPhF7V0F MSX6gru0u87guseB6E08McGWUGdeSnc47Q2yAaSfC9CC+IcWwXchr3xhoGfrPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729089123; 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=GgDGzcFyPvM2WE+onfaKQYV85Sd97CfvTkQsk+nmZKA=; b=dZwotaZIzLUNAHAI4J5VlqhsHiYoi2vXTZ9Reh/ULjL815mloK1h+FeuqBRkWT5ruXY4Pn pQ90xpfodvb2tHWWIZD+11/04LFT+adaK6UWpcyB/wMIePQLqo6Zgc0OHJyxD4LEPM/n4s f/yTXKz4AJtSV0JQ6EtO3SX5L6LiIqRQLd+YmGKgYoente66b75JIw/qdq3f5sUcVwyJog 4RGkK9pvsiL32FTq5p2RLu7g91C84KcccPtHrGbn3otmlqeysYm/3WNcuzvB9F2SnDzmzq e16oPirvwrCZw4wjfhIzAMCM0kJMu7/3v3GbUVNfk07Wh5IeC3xOsZrgwJ2m+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729089123; a=rsa-sha256; cv=none; b=Od1+f/Ykj7GB6w84UwVyW8bLH0PJAYA+BQS8CKPIlTIEC3Nl/F3BdHnRKeV0N49bLhRdPg XtBED4C2vCT8LN2icZtp0Dq+l6/1tl72fEROKf4p1vh32l+2woBB5YbXpcc3IJC1u5IS1/ G/eSQrkODnuvmIk2jqFT54MbMh1/DyQSrq7VsUCVbTB8QN5Ap8cexh4g111WdlpDUuFXhK 34cQ9GO9BSoZIQn7OouSXsp+ZWyqnhwM2YEd22KYmbBeVJJMISe+SxRaNFBvw0BYR2Dt0F /p/y7Wd0EUh/tpHaAaOFJDDDtnwWR2x42mCYPi5AE01D09e5/h7EtNdJBdzRzA== 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 4XTD1v331Gz18fp; Wed, 16 Oct 2024 14:32:03 +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 49GEW3a3089571; Wed, 16 Oct 2024 14:32:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49GEW3L4089568; Wed, 16 Oct 2024 14:32:03 GMT (envelope-from git) Date: Wed, 16 Oct 2024 14:32:03 GMT Message-Id: <202410161432.49GEW3L4089568@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: b57229a80465 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: b57229a80465b390a31fb30b3127c4cb93d8987f Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b57229a80465b390a31fb30b3127c4cb93d8987f commit b57229a80465b390a31fb30b3127c4cb93d8987f Author: prateek sethi AuthorDate: 2024-10-13 18:38:54 +0000 Commit: Warner Losh CommitDate: 2024-10-16 14:19:21 +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 d5c02f9608ca..d1c572e40669 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 adad2450a3d4..9dfa0471ac0a 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__);