drm/i915/gmbus: Increase the Bytes per Rd/Wr Op
authorRamalingam C <ramalingam.c@intel.com>
Thu, 28 Jun 2018 13:34:48 +0000 (19:04 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 12 Jul 2018 15:31:28 +0000 (17:31 +0200)
GMBUS HW supports 511Bytes as Max Bytes per single RD/WR op. Instead of
enabling the 511Bytes per RD/WR cycle on legacy platforms for no
absolute ROIs, this change allows the max bytes per op upto 511Bytes
from Gen9 onwards.

v2:
  No Change.
v3:
  Inline function for max_xfer_size and renaming of the macro.[Jani]
v4:
  Extra brackets removed [ville]
  Commit msg is modified.
v5:
  Collecting the Reviewed-By received.

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1530192889-5789-2-git-send-email-ramalingam.c@intel.com
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_i2c.c

index b95bab7..2da870a 100644 (file)
@@ -3152,6 +3152,7 @@ enum i915_power_well_id {
 #define   GMBUS_CYCLE_STOP     (4 << 25)
 #define   GMBUS_BYTE_COUNT_SHIFT 16
 #define   GMBUS_BYTE_COUNT_MAX   256U
+#define   GEN9_GMBUS_BYTE_COUNT_MAX 511U
 #define   GMBUS_SLAVE_INDEX_SHIFT 8
 #define   GMBUS_SLAVE_ADDR_SHIFT 1
 #define   GMBUS_SLAVE_READ     (1 << 0)
index 97606c1..82bb9c3 100644 (file)
@@ -361,6 +361,13 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv)
        return ret;
 }
 
+static inline
+unsigned int gmbus_max_xfer_size(struct drm_i915_private *dev_priv)
+{
+       return INTEL_GEN(dev_priv) >= 9 ? GEN9_GMBUS_BYTE_COUNT_MAX :
+              GMBUS_BYTE_COUNT_MAX;
+}
+
 static int
 gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv,
                      unsigned short addr, u8 *buf, unsigned int len,
@@ -400,7 +407,7 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
        int ret;
 
        do {
-               len = min(rx_size, GMBUS_BYTE_COUNT_MAX);
+               len = min(rx_size, gmbus_max_xfer_size(dev_priv));
 
                ret = gmbus_xfer_read_chunk(dev_priv, msg->addr,
                                            buf, len, gmbus1_index);
@@ -462,7 +469,7 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
        int ret;
 
        do {
-               len = min(tx_size, GMBUS_BYTE_COUNT_MAX);
+               len = min(tx_size, gmbus_max_xfer_size(dev_priv));
 
                ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len,
                                             gmbus1_index);