From nobody Fri Jan 19 17:09:48 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 4TGmM0672rz56wYq; Fri, 19 Jan 2024 17:09:48 +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 4TGmM05CzBz4K0p; Fri, 19 Jan 2024 17:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705684188; 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=uXGzE7M4SKqqQMW1e/AUg6laWPchnzuaVdY13Vl2R+c=; b=d6QRrapxsPvFslVeOq3aMh1O01jQHVPflfynC5SGMyFiyxOdEyWNMu3ntx34xxE+AO7zlc CcYL+V6WgwISv1/MObHM9IGqY2s/NFx/oALelTWSTJVb7CcmoNsCsMz5DWrn/Q+KMN7PUa /jAVpx9w7ffUOYtIhQ+PtFmAJILuK4UXO9656iVzz3prlv2vwGuYjeaxkZdAn+T0GcVMp3 jugxoPRhFGLPXz+XmPLGZf+sYVwSEyXdF1ePsm0WQqEpJvb26eRnm70sdcQcuchS9zftxd r5Ay0SRYF5cQa0VkMlPAraCnxnlTL3ZpNL2XdWVNBHSCabGLQVTfLpO3f6kM/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705684188; 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=uXGzE7M4SKqqQMW1e/AUg6laWPchnzuaVdY13Vl2R+c=; b=M6prVcWE9TcQQbzd6PkTv/QAXrHKLnN120g7N3Qr/fFVjHa3XRj61KY2gf3kMxGX8Kglia x2q25dv+S3cf3kHgTIcRn1sjL63b14v5AXBbJFCdQIk+LrVbXU6h6p/07yumpKDdTwmzYc wDxuhaB0EKFr220mJZUUL9C+FEHAXA7qh1Ikj92mJcxeRgl/y1cmqSTGy7DgE3euWsb42Z 7hppJIwRyT/DxytOpuk4fBL2IXwbBu7TK+npL4PBmSaIGLExYGtKrJuc5xo7gDdJIr+BOg DL6U7eCtEFTmsqg0q/3G7u7fCI9ueZENmo6B5bE9suqzKVBHMQHMUZLxoev6BA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705684188; a=rsa-sha256; cv=none; b=KDikI89zSaGv7vdlxsWVyYi+brQForT5QCphsqz+VeALY6jzH27nckm7q0ZPgteWqC5EHR nK5T+nvD2b7lxK0+kQ0LhT45trekmTKii1QJzqHbMcyxfOUxV5FuKsOZM+jm0VRhH5RyI8 UtAPR8HBQ2fbwZmHc3IcxRSUOPEAQkpTX+jcjQxJjmQ0HOb9OuqGm88lCeNIYV0Mfh1YUU araLI5IZ87AKnWc3W6n2e/vJAilbyTprcUFl6oIUSFJCN2EIEnjCMwLx75Z+JXdBtK66HP z2l4IGe6kOGZuWbj7ATpxeo+dsq0HlFLL1Wk9t+fxaNe/eeherFxCY4OT/G/wQ== 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 4TGmM04HgBz10LJ; Fri, 19 Jan 2024 17:09:48 +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 40JH9m7j079495; Fri, 19 Jan 2024 17:09:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JH9msp079492; Fri, 19 Jan 2024 17:09:48 GMT (envelope-from git) Date: Fri, 19 Jan 2024 17:09:48 GMT Message-Id: <202401191709.40JH9msp079492@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: 396e8e987adf - stable/13 - ig4: Fix FIFO depths detection 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: 396e8e987adfca485b8b16fd7eee4e368ec1a288 Auto-Submitted: auto-generated The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=396e8e987adfca485b8b16fd7eee4e368ec1a288 commit 396e8e987adfca485b8b16fd7eee4e368ec1a288 Author: Alexander Motin AuthorDate: 2023-12-24 00:02:49 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 17:04:38 +0000 ig4: Fix FIFO depths detection At least on my Tiger Lake-LP queue depth detection failed before the ig4iic_set_config() call, resulting in no FIFO use. Moving it after solves the problem, getting proper 64 bytes size. On my Dell XPS 13 9310 with iichid(4) touchscreen and touchpad this by few times reduces context switch rate in the driver, and probably also improves the I2C bus utilization. MFC after: 1 month (cherry picked from commit 9c9d7fdd9f0041783955c5f540ac55a900877c0c) --- sys/dev/ichiic/ig4_iic.c | 50 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/sys/dev/ichiic/ig4_iic.c b/sys/dev/ichiic/ig4_iic.c index 92028b58c7d4..96909dd2d3f3 100644 --- a/sys/dev/ichiic/ig4_iic.c +++ b/sys/dev/ichiic/ig4_iic.c @@ -847,23 +847,6 @@ ig4iic_get_config(ig4iic_softc_t *sc) sc->cfg.txfifo_depth = IG4_PARAM1_TXFIFO_DEPTH(v); if (IG4_PARAM1_RXFIFO_DEPTH(v) != 0) sc->cfg.rxfifo_depth = IG4_PARAM1_RXFIFO_DEPTH(v); - } else { - /* - * Hardware does not allow FIFO Threshold Levels value to be - * set larger than the depth of the buffer. If an attempt is - * made to do that, the actual value set will be the maximum - * depth of the buffer. - */ - v = reg_read(sc, IG4_REG_TX_TL); - reg_write(sc, IG4_REG_TX_TL, v | IG4_FIFO_MASK); - sc->cfg.txfifo_depth = - (reg_read(sc, IG4_REG_TX_TL) & IG4_FIFO_MASK) + 1; - reg_write(sc, IG4_REG_TX_TL, v); - v = reg_read(sc, IG4_REG_RX_TL); - reg_write(sc, IG4_REG_RX_TL, v | IG4_FIFO_MASK); - sc->cfg.rxfifo_depth = - (reg_read(sc, IG4_REG_RX_TL) & IG4_FIFO_MASK) + 1; - reg_write(sc, IG4_REG_RX_TL, v); } /* Override hardware config with IC_clock-based counter values */ @@ -915,8 +898,6 @@ ig4iic_get_config(ig4iic_softc_t *sc) printf(" Fast: 0x%04hx:0x%04hx:0x%04hx\n", sc->cfg.fs_scl_hcnt, sc->cfg.fs_scl_lcnt, sc->cfg.fs_sda_hold); - printf(" FIFO: RX:0x%04x: TX:0x%04x\n", - sc->cfg.rxfifo_depth, sc->cfg.txfifo_depth); } } @@ -1012,6 +993,36 @@ ig4iic_set_config(ig4iic_softc_t *sc, bool reset) return (0); } +static void +ig4iic_get_fifo(ig4iic_softc_t *sc) +{ + uint32_t v; + + /* + * Hardware does not allow FIFO Threshold Levels value to be set larger + * than the depth of the buffer. If an attempt is made to do that, the + * actual value set will be the maximum depth of the buffer. + */ + if (sc->cfg.txfifo_depth == 0) { + v = reg_read(sc, IG4_REG_TX_TL); + reg_write(sc, IG4_REG_TX_TL, v | IG4_FIFO_MASK); + sc->cfg.txfifo_depth = + (reg_read(sc, IG4_REG_TX_TL) & IG4_FIFO_MASK) + 1; + reg_write(sc, IG4_REG_TX_TL, v); + } + if (sc->cfg.rxfifo_depth == 0) { + v = reg_read(sc, IG4_REG_RX_TL); + reg_write(sc, IG4_REG_RX_TL, v | IG4_FIFO_MASK); + sc->cfg.rxfifo_depth = + (reg_read(sc, IG4_REG_RX_TL) & IG4_FIFO_MASK) + 1; + reg_write(sc, IG4_REG_RX_TL, v); + } + if (bootverbose) { + printf(" FIFO: RX:0x%04x: TX:0x%04x\n", + sc->cfg.rxfifo_depth, sc->cfg.txfifo_depth); + } +} + /* * Called from ig4iic_pci_attach/detach() */ @@ -1028,6 +1039,7 @@ ig4iic_attach(ig4iic_softc_t *sc) error = ig4iic_set_config(sc, IG4_HAS_ADDREGS(sc->version)); if (error) goto done; + ig4iic_get_fifo(sc); sc->iicbus = device_add_child(sc->dev, "iicbus", -1); if (sc->iicbus == NULL) {