Date: Wed, 5 Sep 2018 20:43:47 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r338476 - stable/11/sys/dev/mmc Message-ID: <201809052043.w85KhlIO058885@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Wed Sep 5 20:43:46 2018 New Revision: 338476 URL: https://svnweb.freebsd.org/changeset/base/338476 Log: MFC: r338304 The read accessors generated by __BUS_ACCESSOR() have the problem that they don't check the result of BUS_READ_IVAR(9) and silently return stack garbage on failure in case a bus doesn't implement a particular instance variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ, yet, this in turn can cause mmc(4) to get into a state in which re-tuning seems to be necessary but is inappropriate, causing mmc_wait_for_request() to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and instead provide a version of the latter which returns retune_req_none if reading MMCBR_IVAR_RETUNE_REQ fails. Modified: stable/11/sys/dev/mmc/mmcbrvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mmc/mmcbrvar.h ============================================================================== --- stable/11/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:13:28 2018 (r338475) +++ stable/11/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:43:46 2018 (r338476) @@ -95,7 +95,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int) MMCBR_ACCESSOR(mode, MODE, int) MMCBR_ACCESSOR(ocr, OCR, int) MMCBR_ACCESSOR(power_mode, POWER_MODE, int) -MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int) MMCBR_ACCESSOR(vdd, VDD, int) MMCBR_ACCESSOR(vccq, VCCQ, int) MMCBR_ACCESSOR(caps, CAPS, int) @@ -103,6 +102,20 @@ MMCBR_ACCESSOR(timing, TIMING, int) MMCBR_ACCESSOR(max_data, MAX_DATA, int) MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int) +static int __inline +mmcbr_get_retune_req(device_t dev) +{ + uintptr_t v; + + if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev, + MMCBR_IVAR_RETUNE_REQ, &v) != 0)) + return (retune_req_none); + return ((int)v); +} + +/* + * Convenience wrappers for the mmcbr interface + */ static int __inline mmcbr_update_ios(device_t dev) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809052043.w85KhlIO058885>