[Freedreno] [PATCH] drm/msm: shake fist angrily at dma-mapping

2019-07-30 Thread Rob Clark
From: Rob Clark 

So, using dma_sync_* for our cache needs works out w/ dma iommu ops, but
it falls appart with dma direct ops.  The problem is that, depending on
display generation, we can have either set of dma ops (mdp4 and dpu have
iommu wired to mdss node, which maps to toplevel drm device, but mdp5
has iommu wired up to the mdp sub-node within mdss).

Fixes this splat on mdp5 devices:

   Unable to handle kernel paging request at virtual address 8000
   Mem abort info:
 ESR = 0x96000144
 Exception class = DABT (current EL), IL = 32 bits
 SET = 0, FnV = 0
 EA = 0, S1PTW = 0
   Data abort info:
 ISV = 0, ISS = 0x0144
 CM = 1, WnR = 1
   swapper pgtable: 4k pages, 48-bit VAs, pgdp=810e4000
   [8000] pgd=
   Internal error: Oops: 96000144 [#1] SMP
   Modules linked in: btqcomsmd btqca bluetooth cfg80211 ecdh_generic ecc 
rfkill libarc4 panel_simple msm wcnss_ctrl qrtr_smd drm_kms_helper venus_enc 
venus_dec videobuf2_dma_sg videobuf2_memops drm venus_core ipv6 qrtr 
qcom_wcnss_pil v4l2_mem2mem qcom_sysmon videobuf2_v4l2 qmi_helpers 
videobuf2_common crct10dif_ce mdt_loader qcom_common videodev qcom_glink_smem 
remoteproc bmc150_accel_i2c bmc150_magn_i2c bmc150_accel_core bmc150_magn 
snd_soc_lpass_apq8016 snd_soc_msm8916_analog mms114 mc nf_defrag_ipv6 
snd_soc_lpass_cpu snd_soc_apq8016_sbc industrialio_triggered_buffer kfifo_buf 
snd_soc_lpass_platform snd_soc_msm8916_digital drm_panel_orientation_quirks
   CPU: 2 PID: 33 Comm: kworker/2:1 Not tainted 5.3.0-rc2 #1
   Hardware name: Samsung Galaxy A5U (EUR) (DT)
   Workqueue: events deferred_probe_work_func
   pstate: 8005 (Nzcv daif -PAN -UAO)
   pc : __clean_dcache_area_poc+0x20/0x38
   lr : arch_sync_dma_for_device+0x28/0x30
   sp : 115736a0
   x29: 115736a0 x28: 0001
   x27: 800074830800 x26: 11478000
   x25:  x24: 0001
   x23: 11478a98 x22: 89fd1c10
   x21: 0001 x20: 800075ad0a00
   x19:  x18: 112b2000
   x17:  x16: 
   x15: fff0 x14: 11455d70
   x13:  x12: 0028
   x11: 0001 x10: 1106c000
   x9 : 7e0001d6b380 x8 : 1000
   x7 : 7e0001d6b380 x6 : 7e0001d6b382
   x5 :  x4 : 1000
   x3 : 003f x2 : 0040
   x1 : 80001000 x0 : 8000
   Call trace:
__clean_dcache_area_poc+0x20/0x38
dma_direct_sync_sg_for_device+0xb8/0xe8
get_pages+0x22c/0x250 [msm]
msm_gem_get_and_pin_iova+0xdc/0x168 [msm]
...

Fixes the combination of two patches:

Fixes: 0036bc73ccbe ("drm/msm: stop abusing dma_map/unmap for cache")
Fixes: 449fa54d6815 ("dma-direct: correct the physical addr in 
dma_direct_sync_sg_for_cpu/device")
Signed-off-by: Rob Clark 
---
I think it is time to revisit drm_cache support for arm64, but we need
something for v5.3 to keep things working.

armv7 support might be harder, but hopefully no one is changing dma-
mapping implementation much on armv7 and we can just limp along with
the current hack on 32b arm.

 drivers/gpu/drm/msm/msm_gem.c | 47 +++
 1 file changed, 42 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index c2114c748c2f..8cf6362e64bf 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -32,6 +32,46 @@ static bool use_pages(struct drm_gem_object *obj)
return !msm_obj->vram_node;
 }
 
+/*
+ * Cache sync.. this is a bit over-complicated, to fit dma-mapping
+ * API.  Really GPU cache is out of scope here (handled on cmdstream)
+ * and all we need to do is invalidate newly allocated pages before
+ * mapping to CPU as uncached/writecombine.
+ *
+ * On top of this, we have the added headache, that depending on
+ * display generation, the display's iommu may be wired up to either
+ * the toplevel drm device (mdss), or to the mdp sub-node, meaning
+ * that here we either have dma-direct or iommu ops.
+ *
+ * Let this be a cautionary tail of abstraction gone wrong.
+ */
+
+static void sync_for_device(struct msm_gem_object *msm_obj)
+{
+   struct device *dev = msm_obj->base.dev->dev;
+
+   if (get_dma_ops(dev)) {
+   dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+   } else {
+   dma_map_sg(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+   }
+}
+
+static void sync_for_cpu(struct msm_gem_object *msm_obj)
+{
+   struct device *dev = msm_obj->base.dev->dev;
+
+   if (get_dma_ops(dev)) {
+   dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+   } else {
+   dma_unmap_sg(dev, 

Re: [Freedreno] [PATCH v4 19/23] drm/bridge: dw-hdmi: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Sam Ravnborg
Hi Neil.

> > Signed-off-by: Andrzej Pietrasiewicz 
> > ---
> >  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 40 +++
> >  1 file changed, 20 insertions(+), 20 deletions(-)
> > 
...
> 
> Reviewed-by: Neil Armstrong 

There is now a much simpler v6 of this patch.
Care to take a look and ack/r-b?

Sam
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

Re: [Freedreno] [PATCH v6 00/24] Associate ddc adapters with connectors

2019-07-30 Thread Emil Velikov
On 2019/07/26, Andrzej Pietrasiewicz wrote:
> It is difficult for a user to know which of the i2c adapters is for which
> drm connector. This series addresses this problem.
> 
> The idea is to have a symbolic link in connector's sysfs directory, e.g.:
> 
> ls -l /sys/class/drm/card0-HDMI-A-1/ddc
> lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
>   -> ../../../../soc/1388.i2c/i2c-2
> 
> The user then knows that their card0-HDMI-A-1 uses i2c-2 and can e.g. run
> ddcutil:
> 
> ddcutil -b 2 getvcp 0x10
> VCP code 0x10 (Brightness): current value =90, max value =   100
> 
> The first patch in the series adds struct i2c_adapter pointer to struct
> drm_connector. If the field is used by a particular driver, then an
> appropriate symbolic link is created by the generic code, which is also added
> by this patch.
> 
> Patch 2 adds a new variant of drm_connector_init(), see the changelog
> below.
> 
> Patches 3..24 are examples of how to convert a driver to this new scheme.
> 
> v1..v2:
> 
> - used fixed name "ddc" for the symbolic link in order to make it easy for
> userspace to find the i2c adapter
> 
> v2..v3:
> 
> - converted as many drivers as possible.
> 
> v3..v4:
> 
> - added Reviewed-by for patch 01/23
> - moved "ddc" field assignment to before drm_connector_init() is called
> in msm, vc4, sti, mgag200, ast, amdgpu, radeon
> - simplified the code in amdgpu and radeon at the expense of some lines
> exceeding 80 characters as per Alex Deucher's suggestion
> - added i915
> 
> v4..v5:
> 
> - changed "include " to "struct i2c_adapter;"
> in drm_connector.h, consequently, added "include "
> in drm_sysfs.c.
> - added "drm_connector_init_with_ddc()" variant to ensure that the ddc
> field of drm_connector is preserved accross its invocation
> - accordingly changed invocations of drm_connector_init() in the
> touched drivers to use the new variant
> 
> v5..v6:
> 
> - improved subject line of patch 1
> - added kernel-doc for drm_connector_init_with_ddc()
> - improved kernel-doc for the ddc field of struct drm_connector
> - added Reviewed-by in patches 17 and 18
> - added Acked-by in patch 2
> - made the ownership of ddc i2c_adapter explicit in all patches,
> this made the affected patches much simpler
> 
> @Benjamin
> @Shawn
> 
> There were your Acked-by or Reviewed-by for some patches in v4, but now
> that the patches use the newly added function I'm not sure I can still
> include those tags without you actually confirming. Can I? Or can you
> please re-review? 
> 
> TODO: nouveau, gma500, omapdrm, panel-simple - if applicable.
> Other drivers are either already converted or don't mention neither
> "ddc" nor "i2c_adapter".
> 
Another way to check is to look for drm_get_edid. Sadly that also
highlights aux. dp/mst instances, which expose the DDC in another way.

For example comparing the diff stat wrt the following command shows
git grep -wc drm_get_edid -- drivers/gpu/drm/

> 
>  .../gpu/drm/amd/amdgpu/amdgpu_connectors.c|  96 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c:1
- as pointed out by Alex - mix of aux dp/mst and normal

>  drivers/gpu/drm/ast/ast_mode.c|  13 +-

drivers/gpu/drm/bridge/analogix-anx78xx.c:1
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c:1
- not applicable: aux dp/mst


>  drivers/gpu/drm/bridge/dumb-vga-dac.c |   6 +-

drivers/gpu/drm/bridge/sii902x.c:1
- normal instance(?) that should be updated at some point.

>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |   6 +-

drivers/gpu/drm/bridge/tc358767.c:1
- not applicable: aux dp/mst

>  drivers/gpu/drm/bridge/ti-tfp410.c|   6 +-

drivers/gpu/drm/drm_dp_mst_topology.c:3
- not applicable: aux dp/mst

>  drivers/gpu/drm/drm_connector.c   |  35 +
>  drivers/gpu/drm/drm_sysfs.c   |   8 +

drivers/gpu/drm/drm_edid.c:7
drivers/gpu/drm/drm_probe_helper.c:1
- unrelated

>  drivers/gpu/drm/exynos/exynos_hdmi.c  |   6 +-

drivers/gpu/drm/gma500/cdv_intel_dp.c:3
drivers/gpu/drm/gma500/cdv_intel_hdmi.c:2
drivers/gpu/drm/gma500/oaktrail_hdmi.c:1
drivers/gpu/drm/gma500/oaktrail_lvds.c:2
drivers/gpu/drm/gma500/psb_intel_modes.c:1
drivers/gpu/drm/gma500/psb_intel_sdvo.c:2
- should be updated at some point (as you pointed out).

>  drivers/gpu/drm/i915/display/intel_hdmi.c |  12 +-
drivers/gpu/drm/i915/intel_connector.c:1
drivers/gpu/drm/i915/intel_crt.c:2
- not too sure here

drivers/gpu/drm/i915/intel_dp.c:2
- not applicable: aux dp/mst

drivers/gpu/drm/i915/intel_lvds.c:1
drivers/gpu/drm/i915/intel_sdvo.c:2
- not too sure here


>  drivers/gpu/drm/imx/imx-ldb.c |   7 +-
>  drivers/gpu/drm/imx/imx-tve.c |   6 +-
>  drivers/gpu/drm/mediatek/mtk_hdmi.c   |   7 +-
>  drivers/gpu/drm/mgag200/mgag200_mode.c|  13 +-
>  drivers/gpu/drm/msm/hdmi/hdmi_connector.c |   6 +-
drivers/gpu/drm/msm/edp/edp_ctrl.c:1
- not applicable: aux dp/mst


Re: [Freedreno] [PATCH v6 16/24] drm: sti: Provide ddc symlink in hdmi connector sysfs directory

2019-07-30 Thread Benjamin Gaignard
Le ven. 26 juil. 2019 à 19:27, Andrzej Pietrasiewicz
 a écrit :
>
> Use the ddc pointer provided by the generic connector.
>
> Signed-off-by: Andrzej Pietrasiewicz 

Reviewed-by: Benjamin Gaignard 

> ---
>  drivers/gpu/drm/sti/sti_hdmi.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index f03d617edc4c..33d06e0a9168 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -1284,8 +1284,10 @@ static int sti_hdmi_bind(struct device *dev, struct 
> device *master, void *data)
>
> drm_connector->polled = DRM_CONNECTOR_POLL_HPD;
>
> -   drm_connector_init(drm_dev, drm_connector,
> -   _hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA);
> +   drm_connector_init_with_ddc(drm_dev, drm_connector,
> +   _hdmi_connector_funcs,
> +   DRM_MODE_CONNECTOR_HDMIA,
> +   hdmi->ddc_adapt);
> drm_connector_helper_add(drm_connector,
> _hdmi_connector_helper_funcs);
>
> --
> 2.17.1
>
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

Re: [Freedreno] [PATCH v6 21/24] drm/bridge: ti-tfp410: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Neil Armstrong
On 26/07/2019 19:23, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/bridge/ti-tfp410.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c 
> b/drivers/gpu/drm/bridge/ti-tfp410.c
> index dbf35c7bc85e..61cc2354ef1b 100644
> --- a/drivers/gpu/drm/bridge/ti-tfp410.c
> +++ b/drivers/gpu/drm/bridge/ti-tfp410.c
> @@ -134,8 +134,10 @@ static int tfp410_attach(struct drm_bridge *bridge)
>  
>   drm_connector_helper_add(>connector,
>_con_helper_funcs);
> - ret = drm_connector_init(bridge->dev, >connector,
> -  _con_funcs, dvi->connector_type);
> + ret = drm_connector_init_with_ddc(bridge->dev, >connector,
> +   _con_funcs,
> +   dvi->connector_type,
> +   dvi->ddc);
>   if (ret) {
>   dev_err(dvi->dev, "drm_connector_init() failed: %d\n", ret);
>   return ret;
> 

Reviewed-by: Neil Armstrong 
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

Re: [Freedreno] [PATCH v6 19/24] drm/bridge: dumb-vga-dac: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Neil Armstrong
On 26/07/2019 19:23, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/bridge/dumb-vga-dac.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
> b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> index d32885b906ae..8ef6539ae78a 100644
> --- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
> +++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> @@ -111,8 +111,10 @@ static int dumb_vga_attach(struct drm_bridge *bridge)
>  
>   drm_connector_helper_add(>connector,
>_vga_con_helper_funcs);
> - ret = drm_connector_init(bridge->dev, >connector,
> -  _vga_con_funcs, DRM_MODE_CONNECTOR_VGA);
> + ret = drm_connector_init_with_ddc(bridge->dev, >connector,
> +   _vga_con_funcs,
> +   DRM_MODE_CONNECTOR_VGA,
> +   vga->ddc);
>   if (ret) {
>   DRM_ERROR("Failed to initialize connector\n");
>   return ret;
> 

Reviewed-by: Neil Armstrong 
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

Re: [Freedreno] [PATCH v4 20/23] drm/bridge: ti-tfp410: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Neil Armstrong
On 11/07/2019 13:26, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/bridge/ti-tfp410.c | 19 +--
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c 
> b/drivers/gpu/drm/bridge/ti-tfp410.c
> index dbf35c7bc85e..e55358f0a5ba 100644
> --- a/drivers/gpu/drm/bridge/ti-tfp410.c
> +++ b/drivers/gpu/drm/bridge/ti-tfp410.c
> @@ -26,7 +26,6 @@ struct tfp410 {
>   unsigned intconnector_type;
>  
>   u32 bus_format;
> - struct i2c_adapter  *ddc;
>   struct gpio_desc*hpd;
>   int hpd_irq;
>   struct delayed_work hpd_work;
> @@ -55,10 +54,10 @@ static int tfp410_get_modes(struct drm_connector 
> *connector)
>   struct edid *edid;
>   int ret;
>  
> - if (!dvi->ddc)
> + if (!dvi->connector.ddc)
>   goto fallback;
>  
> - edid = drm_get_edid(connector, dvi->ddc);
> + edid = drm_get_edid(connector, dvi->connector.ddc);
>   if (!edid) {
>   DRM_INFO("EDID read failed. Fallback to standard modes\n");
>   goto fallback;
> @@ -98,8 +97,8 @@ tfp410_connector_detect(struct drm_connector *connector, 
> bool force)
>   return connector_status_disconnected;
>   }
>  
> - if (dvi->ddc) {
> - if (drm_probe_ddc(dvi->ddc))
> + if (dvi->connector.ddc) {
> + if (drm_probe_ddc(dvi->connector.ddc))
>   return connector_status_connected;
>   else
>   return connector_status_disconnected;
> @@ -297,8 +296,8 @@ static int tfp410_get_connector_properties(struct tfp410 
> *dvi)
>   if (!ddc_phandle)
>   goto fail;
>  
> - dvi->ddc = of_get_i2c_adapter_by_node(ddc_phandle);
> - if (dvi->ddc)
> + dvi->connector.ddc = of_get_i2c_adapter_by_node(ddc_phandle);
> + if (dvi->connector.ddc)
>   dev_info(dvi->dev, "Connector's ddc i2c bus found\n");
>   else
>   ret = -EPROBE_DEFER;
> @@ -367,7 +366,7 @@ static int tfp410_init(struct device *dev, bool i2c)
>  
>   return 0;
>  fail:
> - i2c_put_adapter(dvi->ddc);
> + i2c_put_adapter(dvi->connector.ddc);
>   if (dvi->hpd)
>   gpiod_put(dvi->hpd);
>   return ret;
> @@ -382,8 +381,8 @@ static int tfp410_fini(struct device *dev)
>  
>   drm_bridge_remove(>bridge);
>  
> - if (dvi->ddc)
> - i2c_put_adapter(dvi->ddc);
> + if (dvi->connector.ddc)
> + i2c_put_adapter(dvi->connector.ddc);
>   if (dvi->hpd)
>   gpiod_put(dvi->hpd);
>  
> 

Reviewed-by: Neil Armstrong 
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

Re: [Freedreno] [PATCH v4 19/23] drm/bridge: dw-hdmi: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Neil Armstrong
On 11/07/2019 13:26, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 40 +++
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
> b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index c6490949d9db..0b9c9f2619da 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -161,7 +161,6 @@ struct dw_hdmi {
>  
>   struct drm_display_mode previous_mode;
>  
> - struct i2c_adapter *ddc;
>   void __iomem *regs;
>   bool sink_is_hdmi;
>   bool sink_has_audio;
> @@ -1118,7 +1117,7 @@ static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi)
>   return false;
>  
>   /* Disable if no DDC bus */
> - if (!hdmi->ddc)
> + if (!hdmi->connector.ddc)
>   return false;
>  
>   /* Disable if SCDC is not supported, or if an HF-VSDB block is absent */
> @@ -1156,10 +1155,11 @@ void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi 
> *hdmi)
>  
>   /* Control for TMDS Bit Period/TMDS Clock-Period Ratio */
>   if (dw_hdmi_support_scdc(hdmi)) {
> + struct i2c_adapter *ddc = hdmi->connector.ddc;
>   if (mtmdsclock > HDMI14_MAX_TMDSCLK)
> - drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1);
> + drm_scdc_set_high_tmds_clock_ratio(ddc, 1);
>   else
> - drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 0);
> + drm_scdc_set_high_tmds_clock_ratio(ddc, 0);
>   }
>  }
>  EXPORT_SYMBOL_GPL(dw_hdmi_set_high_tmds_clock_ratio);
> @@ -1750,6 +1750,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
>   if (dw_hdmi_support_scdc(hdmi)) {
>   if (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK ||
>   hdmi_info->scdc.scrambling.low_rates) {
> + struct i2c_adapter *ddc = hdmi->connector.ddc;
>   /*
>* HDMI2.0 Specifies the following procedure:
>* After the Source Device has determined that
> @@ -1759,13 +1760,12 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
>* Source Devices compliant shall set the
>* Source Version = 1.
>*/
> - drm_scdc_readb(hdmi->ddc, SCDC_SINK_VERSION,
> -);
> - drm_scdc_writeb(hdmi->ddc, SCDC_SOURCE_VERSION,
> + drm_scdc_readb(ddc, SCDC_SINK_VERSION, );
> + drm_scdc_writeb(ddc, SCDC_SOURCE_VERSION,
>   min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION));
>  
>   /* Enabled Scrambling in the Sink */
> - drm_scdc_set_scrambling(hdmi->ddc, 1);
> + drm_scdc_set_scrambling(hdmi->connector.ddc, 1);
>  
>   /*
>* To activate the scrambler feature, you must ensure
> @@ -1781,7 +1781,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
>   hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL);
>   hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ,
>   HDMI_MC_SWRSTZ);
> - drm_scdc_set_scrambling(hdmi->ddc, 0);
> + drm_scdc_set_scrambling(hdmi->connector.ddc, 0);
>   }
>   }
>  
> @@ -2127,10 +2127,10 @@ static int dw_hdmi_connector_get_modes(struct 
> drm_connector *connector)
>   struct edid *edid;
>   int ret = 0;
>  
> - if (!hdmi->ddc)
> + if (!hdmi->connector.ddc)
>   return 0;
>  
> - edid = drm_get_edid(connector, hdmi->ddc);
> + edid = drm_get_edid(connector, hdmi->connector.ddc);
>   if (edid) {
>   dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
>   edid->width_cm, edid->height_cm);
> @@ -2548,9 +2548,9 @@ __dw_hdmi_probe(struct platform_device *pdev,
>  
>   ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
>   if (ddc_node) {
> - hdmi->ddc = of_get_i2c_adapter_by_node(ddc_node);
> + hdmi->connector.ddc = of_get_i2c_adapter_by_node(ddc_node);
>   of_node_put(ddc_node);
> - if (!hdmi->ddc) {
> + if (!hdmi->connector.ddc) {
>   dev_dbg(hdmi->dev, "failed to read ddc node\n");
>   return ERR_PTR(-EPROBE_DEFER);
>   }
> @@ -2689,7 +2689,7 @@ __dw_hdmi_probe(struct platform_device *pdev,
>   hdmi_init_clk_regenerator(hdmi);
>  
>   /* If DDC bus is not specified, try to register HDMI I2C bus */
> - if (!hdmi->ddc) {
> + if (!hdmi->connector.ddc) {
>   /* Look for (optional) stuff related to unwedging */
>  

Re: [Freedreno] [PATCH v4 18/23] drm/bridge: dumb-vga-dac: Provide ddc symlink in connector sysfs directory

2019-07-30 Thread Neil Armstrong
On 11/07/2019 13:26, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/bridge/dumb-vga-dac.c | 19 +--
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
> b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> index d32885b906ae..b4cc3238400a 100644
> --- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
> +++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> @@ -20,7 +20,6 @@ struct dumb_vga {
>   struct drm_bridge   bridge;
>   struct drm_connectorconnector;
>  
> - struct i2c_adapter  *ddc;
>   struct regulator*vdd;
>  };
>  
> @@ -42,10 +41,10 @@ static int dumb_vga_get_modes(struct drm_connector 
> *connector)
>   struct edid *edid;
>   int ret;
>  
> - if (IS_ERR(vga->ddc))
> + if (IS_ERR(vga->connector.ddc))
>   goto fallback;
>  
> - edid = drm_get_edid(connector, vga->ddc);
> + edid = drm_get_edid(connector, vga->connector.ddc);
>   if (!edid) {
>   DRM_INFO("EDID readout failed, falling back to standard 
> modes\n");
>   goto fallback;
> @@ -84,7 +83,7 @@ dumb_vga_connector_detect(struct drm_connector *connector, 
> bool force)
>* wire the DDC pins, or the I2C bus might not be working at
>* all.
>*/
> - if (!IS_ERR(vga->ddc) && drm_probe_ddc(vga->ddc))
> + if (!IS_ERR(vga->connector.ddc) && drm_probe_ddc(vga->connector.ddc))
>   return connector_status_connected;
>  
>   return connector_status_unknown;
> @@ -190,14 +189,14 @@ static int dumb_vga_probe(struct platform_device *pdev)
>   dev_dbg(>dev, "No vdd regulator found: %d\n", ret);
>   }
>  
> - vga->ddc = dumb_vga_retrieve_ddc(>dev);
> - if (IS_ERR(vga->ddc)) {
> - if (PTR_ERR(vga->ddc) == -ENODEV) {
> + vga->connector.ddc = dumb_vga_retrieve_ddc(>dev);
> + if (IS_ERR(vga->connector.ddc)) {
> + if (PTR_ERR(vga->connector.ddc) == -ENODEV) {
>   dev_dbg(>dev,
>   "No i2c bus specified. Disabling EDID 
> readout\n");
>   } else {
>   dev_err(>dev, "Couldn't retrieve i2c bus\n");
> - return PTR_ERR(vga->ddc);
> + return PTR_ERR(vga->connector.ddc);
>   }
>   }
>  
> @@ -216,8 +215,8 @@ static int dumb_vga_remove(struct platform_device *pdev)
>  
>   drm_bridge_remove(>bridge);
>  
> - if (!IS_ERR(vga->ddc))
> - i2c_put_adapter(vga->ddc);
> + if (!IS_ERR(vga->connector.ddc))
> + i2c_put_adapter(vga->connector.ddc);
>  
>   return 0;
>  }
> 

Reviewed-by: Neil Armstrong 
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno