From nobody Thu Mar 31 01:49:15 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 9BB5B1A51E2C; Thu, 31 Mar 2022 01:49:16 +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 4KTR701c5hz4myg; Thu, 31 Mar 2022 01:49:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648691356; 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=XTBdNG4iTAq9V7fq9SOlbTe/EiiNG1v5PZvykgVPirU=; b=PJOBGIaL9noE4tG2E3ySzMH0165hQ4VsI4f0YPksUjI3uU6vq+3FrnfeIBImAejjkmOmPV 2klSCgfhWCQAENnGTUL5C+Ro1sDwAa2pLLk/mZN9Xjpp1Y+kgvDCVvom4fsVkz8YkBBlXj jS31Xveaj7UwUE/xnaGv5m85Yklhb+detA4QFvK72kSunPW7YNdwUuhh3IFjckwSxwQo6K 2Ha0typKb0d6zlnsxK8IGSVhHLBPHA+JAev8pR/fcSG1Tm000qdGaZqoujPMJtv5W5mR3K VTLxZB6ppw7hq/BA0hirPhiCbVaXcyWlfOqcvzzKx1AU2++g6LoaE6sLm8XX1g== 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 099891EA8F; Thu, 31 Mar 2022 01:49:16 +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 22V1nFGm035601; Thu, 31 Mar 2022 01:49:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22V1nFML035600; Thu, 31 Mar 2022 01:49:15 GMT (envelope-from git) Date: Thu, 31 Mar 2022 01:49:15 GMT Message-Id: <202203310149.22V1nFML035600@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: c1a9422b9962 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: c1a9422b99623e3d8024d2c739ebc75954ef2e86 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648691356; 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=XTBdNG4iTAq9V7fq9SOlbTe/EiiNG1v5PZvykgVPirU=; b=wtrSggeDG63Kn2jyxMZoVvV4df9PakpVRUsAWk/zIiyhaRh5aqxex5VT6ZB2L6HshBpYry cFhZyYUMZib8m2RqmUjOHhJ5VaZw23Dp7TPQdn2NpvmFOXmhu3FaO3Ju3WNtIR6MeonIAQ ld++UU4ngJzdT6rp+nW55SPTPa9C1nVwQysvkzjEfB2SJUUsLlbFs6P6xU79Cne8U4qLNE sEngZVlehlohmbKJiEakwIVrreYFtd9I74HtwizAbA84xspWZO/gluAILNkx8UwQoqYCry Ane6/smbUbpNgo+ozVMCZd/yn4s/pFcF62XWmbqPdK5LVoCE1jlE/oeyrrfUng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648691356; a=rsa-sha256; cv=none; b=LffB9GYzcvajvcDQzrV7vRMT5WbOh6hcqFMBh4WGJ6d2kcowdzW0FLbBYUm+RCMAMHu7zI tZQKupSuFLuiFIpfGl/8hqQ/3tEcjAvm69z0zFS2ky1mT8LDx2sEE9War0mnCcx2Uk65bg wOuKUg0x95pIj/mNlRWaD4wUGE3gLRJ2de4uOMFXSy7pLazQ54JOX+oSVUwOmQIz6afGyH 4QGPTOvgW8nQRD7eFIkqVhPs4ZSxLhcSWS3u0/J86fPaPWIkb4IrBtwTdasM/pAT2V6RpT +DxX0wH5nDE182pXeu3Jg4tdbF6LrGZZ8nF2OtoddJoYkrmLFMuBJbGWXSwOLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c1a9422b99623e3d8024d2c739ebc75954ef2e86 commit c1a9422b99623e3d8024d2c739ebc75954ef2e86 Author: Henri Hennebert AuthorDate: 2022-03-24 01:01:00 +0000 Commit: Alexander Motin CommitDate: 2022-03-31 01:48:24 +0000 rtsx: Display error if rtsx_read()/rtsx_write() fail. MFC after: 1 week (cherry picked from commit 9b261d2e0a4490e436936c5f9209f7cc100b4787) --- 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; }