From nobody Sun Dec 24 00:10:13 2023 X-Original-To: dev-commits-src-main@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 4SyLyY3Dv5z55CDM; Sun, 24 Dec 2023 00:10:13 +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 4SyLyY2kLBz3JvB; Sun, 24 Dec 2023 00:10:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703376613; 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=jHFBEkTjVlkgQ2XSbMe/ep6bDACkyAtxpV0ZM82mGYA=; b=GdBO3n7MZsOv4C4zwQF9AV1NB5CtN6a1JjOnopWkZKpZZiifgJw1DigyOHXitQB3OQS3zg tHw3GYaYhcJZOS+SB7MkqOKQeXne5qnaqwdCEvVzhMdgxtJRAamuM5dmWsTXq4o4MqmyKu 6z9wUfU5I3R8HyVmt6GcKRcJ0cL+py9qSA5Aqe8aaQehceRcE5M9RioPMQa/nFDxXH6IeV HgYXx1o9z6copi7gTgHVgvYNlxeOkSfKTi7Gxq9z3ebsHWrittrQiBHvDGLMtSHMjOdSlN vRQ2W46OuJJ8nZqgeYVES7n2uZsE2lDiHbdrvTRiQiqRZIZBHvOXRYgn1Z2Yeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703376613; a=rsa-sha256; cv=none; b=yDPCBg0vukLZQ6ACcp5i65yos06C4xnsZUkdfShVzU0LogljoD6atFJtap4LBlOpy/WEaX dynI4sjlajri6xyhG9+ojF4Ei7g2rSgSD8QzKEd7BMbHGZKIsJHUQX3Gn8TxZbvr7UzEkz pYmWkIZXFApQkkAf+ilcdj+EFXM2kweACKRiS2Nx8v6cuHHoOLw5fLqy8PC5gGoszwVSlK ETJc7shL2c9DuYdzF6kwyEWSLOO0G3LRNG8ktpUJBdXNbe2eIi9u8Szfudf5R7xOyolxmh v4kgzoiVTGCmgzVyri4jrqpDd4W2PeqR2iE5qjEa7GZzAbbQ6DES/KQMaq70nA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703376613; 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=jHFBEkTjVlkgQ2XSbMe/ep6bDACkyAtxpV0ZM82mGYA=; b=FaHEmpmzJ0YL628AE8OdTXrHed2dThaYya3xj1Z4pVSAvCBo3+9+ys+bZlzSOtr2O4+DKL T8zPHBUKA+2MyfmPyyH34yyoJBFhBUlwMtNLV3NcvDjImcMBqRBXQVw5jtj2/umzTTJ2Fx qCLaaLd0A7rcKkMLkSnQSkXG7BDO1G0djSYhOPTbAAa2qEq9idG8BzwJnm2QyHjZLMozq2 7TBU+WRGZ8Xv0J5cGJrpcJiqSwDVcM+nbinKSjeMMsezizYlj5GRIg1KEeITmJ486lHixm B5p/68b6HkJ+zIQFEpXzIqS/Q9KZjMX/3X5XEAAKCGMYR9rlXFB/Zr5/RjQEQA== 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 4SyLyY1nLsz1KhZ; Sun, 24 Dec 2023 00:10:13 +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 3BO0ADtD055909; Sun, 24 Dec 2023 00:10:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO0ADU0055900; Sun, 24 Dec 2023 00:10:13 GMT (envelope-from git) Date: Sun, 24 Dec 2023 00:10:13 GMT Message-Id: <202312240010.3BO0ADU0055900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 9c9d7fdd9f00 - main - ig4: Fix FIFO depths detection List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 9c9d7fdd9f0041783955c5f540ac55a900877c0c Auto-Submitted: auto-generated The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=9c9d7fdd9f0041783955c5f540ac55a900877c0c commit 9c9d7fdd9f0041783955c5f540ac55a900877c0c Author: Alexander Motin AuthorDate: 2023-12-24 00:02:49 +0000 Commit: Alexander Motin CommitDate: 2023-12-24 00:02:49 +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 --- 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 3dc72c458b24..4ab36ef660ed 100644 --- a/sys/dev/ichiic/ig4_iic.c +++ b/sys/dev/ichiic/ig4_iic.c @@ -850,23 +850,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 */ @@ -918,8 +901,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); } } @@ -1015,6 +996,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() */ @@ -1031,6 +1042,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) {