From nobody Thu Mar 24 01:16:48 2022 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 B96891A28741; Thu, 24 Mar 2022 01:16: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 4KP6km4V1Fz4VtW; Thu, 24 Mar 2022 01:16:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648084608; 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=1v5takR+RF90ga1mXxmSTbpzexiRAIOamH5aoECGDsE=; b=Mbd1RWzTwH6I7/+uqy6ie/f9b5IkmpCTWKToEm+EGM9ZTvmP7VLY+lR2hXI1PG91vXWmX5 I/30b9vlKD/Y7eYKujaIbtjkBgEHjSTu2kMCCbvhKGQZsPC2XSS5RopR/beNvd8/rBK1Ou gK9kEd0oNjuZHQTBsqwo/Vxol00PVCGSll3+7ZuxBajswI4ohy/CJLkWPn3dGhJ43vOq69 M0NrOKUVNcet4WOA+NPB0k9eoSFer4ONXChwuDCmqO7WHFVqUoCaRuEehQuZHM8hszYBa3 X+RPx9JGWGqjAvr9MEYivqrkSgeJPGjDsR59PBLV3G933TtrOBSFhpRXC11AYw== 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 6ED62647F; Thu, 24 Mar 2022 01:16:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22O1GmMI056114; Thu, 24 Mar 2022 01:16:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22O1Gmrm056113; Thu, 24 Mar 2022 01:16:48 GMT (envelope-from git) Date: Thu, 24 Mar 2022 01:16:48 GMT Message-Id: <202203240116.22O1Gmrm056113@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: 9b261d2e0a44 - main - rtsx: Display error if rtsx_read()/rtsx_write() fail. 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/main X-Git-Reftype: branch X-Git-Commit: 9b261d2e0a4490e436936c5f9209f7cc100b4787 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648084608; 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=1v5takR+RF90ga1mXxmSTbpzexiRAIOamH5aoECGDsE=; b=LG0hnAzgt9WtF2RBGMoYJBhGzpvrIpzaupQBQua6KFn6TmIEUbyB8opSRHr7TUm9r7L2zY 3rfD93e1xVuodnwwgf2WacPNx84Wa6yeeWxHyvSpKcFyvLK3mgSAK7gv7Cs+99pYc9zZib skuETf0QC/Qj5AXWWp1eiw2y8v0OmmOARUeS7pOJX9llhzqSjhLVaI05us0xBeSf0N6cw8 u3/lDuz7VBknx3wGVR5Jd+zOjo0T5K5FpHMXT4P+31/D/CTJ+PCyT56KDeiHpQGb79h3FO p0F7m089S7NhxW6h7LEPxJpM9T5o4DHpox44n3i+4CunjkUdQEYGaqA/Iex+Hg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648084608; a=rsa-sha256; cv=none; b=v21ebcQ2hpIJ3LvfMR+JDqqDivh6lBQNRl30GPiZgqnjWFherSs+QeAaGBlhYZ6jfV0Gdo 7E8kxVVQuAEJmozUuSkn2VHvNERn8EHSDhR4VJaLG5AUVCgQbin78tXFwcI38gar63+Ih+ pMXE9/DXn2PDJg2H/OmCMeE/2abDNzz9Kkv786GdzMpDh3Tt+WQOmGAwtf9q3yzXqak0ga I8p0+pvE86OGymzbdzpATIRO3OO/dqmVaruyMEiUnoAmykryTBhNZV4zLfNdVxO1rcOI3w COU5/2gBOm7KEJlqnsQljWTxIhRM2zCnjoFll/6h2qHajDaPDjdUPJn/5OXPPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=9b261d2e0a4490e436936c5f9209f7cc100b4787 commit 9b261d2e0a4490e436936c5f9209f7cc100b4787 Author: Henri Hennebert AuthorDate: 2022-03-24 01:01:00 +0000 Commit: Alexander Motin CommitDate: 2022-03-24 01:01:00 +0000 rtsx: Display error if rtsx_read()/rtsx_write() fail. MFC after: 1 week --- sys/dev/rtsx/rtsx.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/sys/dev/rtsx/rtsx.c b/sys/dev/rtsx/rtsx.c index a8e0e4adeba1..5664be67181f 100644 --- a/sys/dev/rtsx/rtsx.c +++ b/sys/dev/rtsx/rtsx.c @@ -99,7 +99,6 @@ struct rtsx_softc { int rtsx_res_id; /* bus memory resource id */ struct resource *rtsx_res; /* bus memory resource */ - int rtsx_res_type; /* bus memory resource type */ bus_space_tag_t rtsx_btag; /* host register set tag */ bus_space_handle_t rtsx_bhandle; /* host register set handle */ @@ -173,7 +172,7 @@ struct rtsx_softc { #define RTSX_RTL8411 0x5289 #define RTSX_RTL8411B 0x5287 -#define RTSX_VERSION "2.1e" +#define RTSX_VERSION "2.1f" static const struct rtsx_device { uint16_t vendor_id; @@ -1320,10 +1319,11 @@ static int rtsx_read(struct rtsx_softc *sc, uint16_t addr, uint8_t *val) { int tries = 1024; + uint32_t arg; uint32_t reg; - WRITE4(sc, RTSX_HAIMR, RTSX_HAIMR_BUSY | - (uint32_t)((addr & 0x3FFF) << 16)); + arg = RTSX_HAIMR_BUSY | (uint32_t)((addr & 0x3FFF) << 16); + WRITE4(sc, RTSX_HAIMR, arg); while (tries--) { reg = READ4(sc, RTSX_HAIMR); @@ -1332,7 +1332,12 @@ rtsx_read(struct rtsx_softc *sc, uint16_t addr, uint8_t *val) } *val = (reg & 0xff); - return ((tries == 0) ? ETIMEDOUT : 0); + if (tries > 0) { + return (0); + } else { + device_printf(sc->rtsx_dev, "rtsx_read(0x%x) timeout\n", arg); + return (ETIMEDOUT); + } } static int @@ -1368,21 +1373,25 @@ static int rtsx_write(struct rtsx_softc *sc, uint16_t addr, uint8_t mask, uint8_t val) { int tries = 1024; + uint32_t arg; uint32_t reg; - WRITE4(sc, RTSX_HAIMR, - RTSX_HAIMR_BUSY | RTSX_HAIMR_WRITE | - (uint32_t)(((addr & 0x3FFF) << 16) | - (mask << 8) | val)); + arg = RTSX_HAIMR_BUSY | RTSX_HAIMR_WRITE | + (uint32_t)(((addr & 0x3FFF) << 16) | + (mask << 8) | val); + WRITE4(sc, RTSX_HAIMR, arg); while (tries--) { reg = READ4(sc, RTSX_HAIMR); if (!(reg & RTSX_HAIMR_BUSY)) { - if (val != (reg & 0xff)) + if (val != (reg & 0xff)) { + device_printf(sc->rtsx_dev, "rtsx_write(0x%x) error reg=0x%x\n", arg, reg); return (EIO); + } return (0); } } + device_printf(sc->rtsx_dev, "rtsx_write(0x%x) timeout\n", arg); return (ETIMEDOUT); } @@ -3692,8 +3701,9 @@ rtsx_attach(device_t dev) #endif /* MMCCAM */ /* Initialize device. */ - if (rtsx_init(sc)) { - device_printf(dev, "Error during rtsx_init()\n"); + error = rtsx_init(sc); + if (error) { + device_printf(dev, "Error %d during rtsx_init()\n", error); goto destroy_rtsx_irq; }