From nobody Mon Feb 5 20:41:20 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 4TTJFF31gVz58yCX; Mon, 5 Feb 2024 20:41:21 +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 4TTJFD5bPcz4xDS; Mon, 5 Feb 2024 20:41:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707165680; 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=G7koAjXKNm1ztyMbFCnolD1ajYMPoMTY56QnHxtQXO8=; b=dcj6178rgbmXbRTkqcfSC6T6z3/j1TFwVv7wNxZHRlR9AG+TewGT0l2SEios11R2KBS45c gMXHfZmaHsDiVGBjOFa8a2MWLllZTdPHtQZK4KBOUbpKe1RFhlG7CoBk/kTBvyM6IPWqAp VVF8J3qJ+sn0wzkCjady+gBNZmtsD1P0rFDTvBtFCKv5t9mZBZDF9RyJpAftFmhRVk+N3/ GJavUt5i/s3ay7Bpv+6oKFra7VeBmWVVmvcZ7R7zJfQzS3HL06U0r8dwjibdJVupXGZNHw RoY/nC/W6jVX7tCnE3RyxxAPJRbF+iFLSZbBmkWp0DR3sjaHQF4avd0PXf8lcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707165680; 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=G7koAjXKNm1ztyMbFCnolD1ajYMPoMTY56QnHxtQXO8=; b=LYyIPqgyRE8KruShCxCbYKvBR+jHbi5kGZPYoUVHKbGMHCWkOOUIFx5SpwT74LyNfySr6v bLzke8sRgZnUnX55BhnSzUsHoD1Ks4PMLLxSOB33jLWIZI7lLl24IdAbS0kfOatJO+bekm F73tI8W5FajLgBzJyTo1uQH0q9c/ADnXgzSq9H7PEXRrsefrP2Nkx2v8W7kRyxjDQfApGS VFzT1ngiGnH9bZJ/qaqgFcIIIRHIYV+da1dGRZlcuCfU0fRrLQBTepuAUh6C7XnfdIszE4 14qJBQN3DXmNYufkHZ6Ez61A55IaTMK1+GzC+3G8yVPZCNjjWCiUi+El9MOPvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707165680; a=rsa-sha256; cv=none; b=af+Jbuniv6F19caEouBp8PCyqolyNagImwjVBmWZqOWwscThZsxS7aATMjSudOzr98Knsf zNeIrqAkas0l1JIyUqeOiS9+pn8gxjF8k/tbDKwQdMhPC2NfwtECWwaJLsUo1S7QqryT2/ HQJtrfKB64XTDNY4MXVRxIwRZoR+Snp24Ur0q143GvDPwBEJNw0QLr5g9mv4/AcAU4SUNw Pk1slDPHF4IHZMIqU5cTeYTpCX6/hwfKGeZ46F11KfkBP/r6JLpdUBfBZoVj2cvvDvg6HA v8BB9YsrL6A1kRbjMRLf3w7+IW6kXWxrc628ImqgyjfaWDdN0W4V+FITMbqzjw== 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 4TTJFD4Mp4zvPM; Mon, 5 Feb 2024 20:41:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 415KfKVL082435; Mon, 5 Feb 2024 20:41:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 415KfKwp082432; Mon, 5 Feb 2024 20:41:20 GMT (envelope-from git) Date: Mon, 5 Feb 2024 20:41:20 GMT Message-Id: <202402052041.415KfKwp082432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 7393d37b1224 - stable/13 - ntb_hw_plx: Workaround read-only scratchpad registers 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7393d37b12249aa26b0336136790cbcb33b690c2 Auto-Submitted: auto-generated The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7393d37b12249aa26b0336136790cbcb33b690c2 commit 7393d37b12249aa26b0336136790cbcb33b690c2 Author: Alexander Motin AuthorDate: 2024-01-27 21:51:46 +0000 Commit: Alexander Motin CommitDate: 2024-02-05 20:39:58 +0000 ntb_hw_plx: Workaround read-only scratchpad registers On several systems we've noticed that when NTB link goes down, the Physical Layer User Test Pattern registers we use as additional scratchpad registers (that is explicitly allowed by the chip specs) become read-only for about 100us. I see no explanation for this in the chip specs, neither why it was not seen before, may be a race. Since we do need these registers, workaround it by repeating writes until we succeed or 1ms timeout expire. MFC after: 1 week (cherry picked from commit 3883c6fbf232452098ba6ea802ef1426d83d2d68) --- sys/dev/ntb/ntb.h | 2 +- sys/dev/ntb/ntb_hw/ntb_hw_plx.c | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sys/dev/ntb/ntb.h b/sys/dev/ntb/ntb.h index 61dc2cac5faf..f5f85815103e 100644 --- a/sys/dev/ntb/ntb.h +++ b/sys/dev/ntb/ntb.h @@ -281,7 +281,7 @@ int ntb_mw_set_wc(device_t ntb, unsigned mw_idx, vm_memattr_t mode); uint8_t ntb_spad_count(device_t ntb); /* - * ntb_get_max_spads() - zero local scratch registers + * ntb_spad_clear() - zero local scratch registers * @ntb: pointer to ntb_softc instance * * This functions overwrites all local scratchpad registers with zeroes. diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c index 535a6f489e40..0e48903ad7b9 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c @@ -880,17 +880,33 @@ static int ntb_plx_spad_write(device_t dev, unsigned int idx, uint32_t val) { struct ntb_plx_softc *sc = device_get_softc(dev); - u_int off; + u_int off, t; if (idx >= sc->spad_count1 + sc->spad_count2) return (EINVAL); - if (idx < sc->spad_count1) + if (idx < sc->spad_count1) { off = sc->spad_off1 + idx * 4; - else + bus_write_4(sc->conf_res, off, val); + return (0); + } else { off = sc->spad_off2 + (idx - sc->spad_count1) * 4; - bus_write_4(sc->conf_res, off, val); - return (0); + /* + * For some reason when link goes down Test Pattern registers + * we use as additional scratchpad become read-only for about + * 100us. I see no explanation in specs, so just wait a bit. + */ + for (t = 0; t <= 1000; t++) { + bus_write_4(sc->conf_res, off, val); + if (bus_read_4(sc->conf_res, off) == val) + return (0); + DELAY(1); + } + device_printf(dev, + "Can't write Physical Layer User Test Pattern (0x%x)\n", + off); + return (EIO); + } } static void