svn commit: r338304 - head/sys/dev/mmc

Marius Strobl marius at FreeBSD.org
Fri Aug 24 21:08:06 UTC 2018


Author: marius
Date: Fri Aug 24 21:08:05 2018
New Revision: 338304
URL: https://svnweb.freebsd.org/changeset/base/338304

Log:
  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.
  One more straight-forward solution would have been to change mmc(4) to not
  call mmcbr_get_retune_req() if the current transfer mode doesn't require
  re-tuning to begin with. However, for modes such as SDR50, it depends on
  the controller whether periodic re-tuning is need. Therefore, knowledge of
  whether a particular transfer mode does require re-tuning should be kept
  to the bridge drivers.
  This change is the generic version of r338271, as intended not requiring
  bridge drivers to be touched (unless transfer modes beyond high speed are
  to be supported that is).
  
  Approved by:	re (gjb)

Modified:
  head/sys/dev/mmc/mmcbrvar.h

Modified: head/sys/dev/mmc/mmcbrvar.h
==============================================================================
--- head/sys/dev/mmc/mmcbrvar.h	Fri Aug 24 20:44:58 2018	(r338303)
+++ head/sys/dev/mmc/mmcbrvar.h	Fri Aug 24 21:08:05 2018	(r338304)
@@ -97,7 +97,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)
@@ -105,6 +104,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)
 {


More information about the svn-src-head mailing list