Re: [CI v2] drm/fbdev: Fallback to non tiled mode if all tiles not present

2019-11-17 Thread Manasi Navare
Pushed tod rm-misc-next, thanks a lot Dave all the feedback and reviews.

Regards
Manasi

On Wed, Nov 13, 2019 at 02:29:52PM -0800, Manasi Navare wrote:
> In case of tiled displays, if we hotplug just one connector,
> fbcon currently just selects the preferred mode and if it is
> tiled mode then that becomes a problem if rest of the tiles are
> not present.
> So in the fbdev driver on hotplug when we probe the client modeset,
> if we dont find all the connectors for all tiles, then on a connector
> with one tile, just fallback to the first available non tiled mode
> to display over a single connector.
> On the hotplug of the consecutive tiled connectors, if the tiled mode
> no longer exists because of fbcon size limitation, then return
> no modes for consecutive tiles but retain the non tiled mode
> on the 0th tile.
> Use the same logic in case of connected boot case as well.
> This has been tested with Dell UP328K tiled monitor.
> 
> v2:
> * Set the modes on consecutive hotplugged tiles to no mode
> if tiled mode is pruned (Dave)
> v1:
> * Just handle the 1st connector hotplug case
> * v1 Reviewed-by: Dave Airlie 
> 
> Suggested-by: Ville Syrjälä 
> Suggested-by: Dave Airlie 
> Cc: Ville Syrjälä 
> Cc: Dave Airlie 
> Signed-off-by: Manasi Navare 
> Reviewed-by: Dave Airlie 
> ---
>  drivers/gpu/drm/drm_client_modeset.c | 70 
>  1 file changed, 70 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_client_modeset.c 
> b/drivers/gpu/drm/drm_client_modeset.c
> index 895b73f23079..f2150a0bac4c 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -114,6 +114,33 @@ drm_client_find_modeset(struct drm_client_dev *client, 
> struct drm_crtc *crtc)
>   return NULL;
>  }
>  
> +static struct drm_display_mode *
> +drm_connector_get_tiled_mode(struct drm_connector *connector)
> +{
> + struct drm_display_mode *mode;
> +
> + list_for_each_entry(mode, >modes, head) {
> + if (mode->hdisplay == connector->tile_h_size &&
> + mode->vdisplay == connector->tile_v_size)
> + return mode;
> + }
> + return NULL;
> +}
> +
> +static struct drm_display_mode *
> +drm_connector_fallback_non_tiled_mode(struct drm_connector *connector)
> +{
> + struct drm_display_mode *mode;
> +
> + list_for_each_entry(mode, >modes, head) {
> + if (mode->hdisplay == connector->tile_h_size &&
> + mode->vdisplay == connector->tile_v_size)
> + continue;
> + return mode;
> + }
> + return NULL;
> +}
> +
>  static struct drm_display_mode *
>  drm_connector_has_preferred_mode(struct drm_connector *connector, int width, 
> int height)
>  {
> @@ -348,8 +375,14 @@ static bool drm_client_target_preferred(struct 
> drm_connector **connectors,
>   struct drm_connector *connector;
>   u64 conn_configured = 0;
>   int tile_pass = 0;
> + int num_tiled_conns = 0;
>   int i;
>  
> + for (i = 0; i < connector_count; i++) {
> + if (connectors[i]->has_tile)
> + num_tiled_conns++;
> + }
> +
>  retry:
>   for (i = 0; i < connector_count; i++) {
>   connector = connectors[i];
> @@ -399,6 +432,28 @@ static bool drm_client_target_preferred(struct 
> drm_connector **connectors,
>   list_for_each_entry(modes[i], >modes, head)
>   break;
>   }
> + /*
> +  * In case of tiled mode if all tiles not present fallback to
> +  * first available non tiled mode.
> +  * After all tiles are present, try to find the tiled mode
> +  * for all and if tiled mode not present due to fbcon size
> +  * limitations, use first non tiled mode only for
> +  * tile 0,0 and set to no mode for all other tiles.
> +  */
> + if (connector->has_tile) {
> + if (num_tiled_conns <
> + connector->num_h_tile * connector->num_v_tile ||
> + (connector->tile_h_loc == 0 &&
> +  connector->tile_v_loc == 0 &&
> +  !drm_connector_get_tiled_mode(connector))) {
> + DRM_DEBUG_KMS("Falling back to non tiled mode 
> on Connector %d\n",
> +   connector->base.id);
> + modes[i] = 
> drm_connector_fallback_non_tiled_mode(connector);
> + } else {
> + modes[i] = 
> drm_connector_get_tiled_mode(connector);
> + }
> + }
> +
>   DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name :
> "none");
>   conn_configured |= BIT_ULL(i);
> @@ -515,6 +570,7 @@ static bool drm_client_firmware_config(struct 
> drm_client_dev *client,
>   bool fallback 

[Bug 112308] Screen flickering with 4k resolution on Prairie Falcon

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=112308

--- Comment #2 from Kai-Heng Feng  ---
Created attachment 145985
  --> https://bugs.freedesktop.org/attachment.cgi?id=145985=edit
kernel message without iommu

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 112308] Screen flickering with 4k resolution on Prairie Falcon

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=112308

--- Comment #1 from Kai-Heng Feng  ---
Created attachment 145984
  --> https://bugs.freedesktop.org/attachment.cgi?id=145984=edit
kernel message with iommu

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 112308] Screen flickering with 4k resolution on Prairie Falcon

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=112308

Bug ID: 112308
   Summary: Screen flickering with 4k resolution on Prairie Falcon
   Product: DRI
   Version: unspecified
  Hardware: Other
OS: All
Status: NEW
  Severity: not set
  Priority: not set
 Component: DRM/AMDgpu
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: kai.heng.f...@canonical.com

The issue is still there on amd-staging-drm-next branch.

The issue is gone with kernel parameter "iommu=off".

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCHv2 3/4] drm/komeda: use afbc helpers

2019-11-17 Thread james qian wang (Arm Technology China)
On Thu, Nov 14, 2019 at 11:12:13AM +0100, Daniel Vetter wrote:
> On Thu, Nov 14, 2019 at 2:52 AM james qian wang (Arm Technology China)
>  wrote:
> > On Wed, Nov 13, 2019 at 12:39:54PM +0100, Daniel Vetter wrote:
> > > On Wed, Nov 13, 2019 at 02:01:53AM +, james qian wang (Arm Technology 
> > > China) wrote:
> > > > On Fri, Nov 08, 2019 at 04:09:54PM +, Ayan Halder wrote:
> > > > > On Mon, Nov 04, 2019 at 11:12:27PM +0100, Andrzej Pietrasiewicz wrote:
> > > > > > There are afbc helpers available.
> > > > > >
> > > > > > Signed-off-by: Andrzej Pietrasiewicz 
> > > > > > ---
> > > > > >  .../arm/display/komeda/komeda_format_caps.h   |  1 -
> > > > > >  .../arm/display/komeda/komeda_framebuffer.c   | 44 
> > > > > > +++
> > > > > >  2 files changed, 17 insertions(+), 28 deletions(-)
> > > > > >
> > > > > > diff --git 
> > > > > > a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h 
> > > > > > b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> > > > > > index 32273cf18f7c..607eea80e60c 100644
> > > > > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> > > > > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> > > > > > @@ -33,7 +33,6 @@
> > > > > >
> > > > > >  #define AFBC_TH_LAYOUT_ALIGNMENT   8
> > > > > >  #define AFBC_HEADER_SIZE   16
> > > > > > -#define AFBC_SUPERBLK_ALIGNMENT128
> > > > > >  #define AFBC_SUPERBLK_PIXELS   256
> > > > > >  #define AFBC_BODY_START_ALIGNMENT  1024
> > > > > >  #define AFBC_TH_BODY_START_ALIGNMENT   4096
> > > > > > diff --git 
> > > > > > a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c 
> > > > > > b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> > > > > > index 1b01a625f40e..e9c87551a5b8 100644
> > > > > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> > > > > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> > > > > > @@ -4,6 +4,7 @@
> > > > > >   * Author: James.Qian.Wang 
> > > > > >   *
> > > > > >   */
> > > > > > +#include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > @@ -43,8 +44,7 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, 
> > > > > > struct drm_file *file,
> > > > > > struct drm_framebuffer *fb = >base;
> > > > > > const struct drm_format_info *info = fb->format;
> > > > > > struct drm_gem_object *obj;
> > > > > > -   u32 alignment_w = 0, alignment_h = 0, alignment_header, 
> > > > > > n_blocks, bpp;
> > > > > > -   u64 min_size;
> > > > > > +   u32 alignment_w = 0, alignment_h = 0, alignment_header, bpp;
> > > > > >
> > > > > > obj = drm_gem_object_lookup(file, mode_cmd->handles[0]);
> > > > > > if (!obj) {
> > > > > > @@ -52,19 +52,15 @@ komeda_fb_afbc_size_check(struct komeda_fb 
> > > > > > *kfb, struct drm_file *file,
> > > > > > return -ENOENT;
> > > > > > }
> > > > > >
> > > > > > -   switch (fb->modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) {
> > > > > > -   case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8:
> > > > > > -   alignment_w = 32;
> > > > > > -   alignment_h = 8;
> > > > > > -   break;
> > > > > > -   case AFBC_FORMAT_MOD_BLOCK_SIZE_16x16:
> > > > > > -   alignment_w = 16;
> > > > > > -   alignment_h = 16;
> > > > > > -   break;
> > > > > > -   default:
> > > > > > -   WARN(1, "Invalid AFBC_FORMAT_MOD_BLOCK_SIZE: 
> > > > > > %lld.\n",
> > > > > > -fb->modifier & 
> > > > > > AFBC_FORMAT_MOD_BLOCK_SIZE_MASK);
> > > > > > -   break;
> > > > > > +   if (!drm_afbc_get_superblk_wh(fb->modifier, _w, 
> > > > > > _h))
> > > > > > +   return -EINVAL;
> > > > > > +
> > > > > > +   if ((alignment_w != 16 || alignment_h != 16) &&
> > > > > > +   (alignment_w != 32 || alignment_h != 8)) {
> > > > > > +   DRM_DEBUG_KMS("Unsupported afbc tile w/h [%d/%d]\n",
> > > > > > + alignment_w, alignment_h);
> > > > > > +
> > > > > > +   return -EINVAL;
> > > > > To be honest, the previous code looks much more readable
> > > > > > }
> > > > > >
> > > > > > /* tiled header afbc */
> > > > > > @@ -84,20 +80,14 @@ komeda_fb_afbc_size_check(struct komeda_fb 
> > > > > > *kfb, struct drm_file *file,
> > > > > > goto check_failed;
> > > > > > }
> > > > > >
> > > > > > -   n_blocks = (kfb->aligned_w * kfb->aligned_h) / 
> > > > > > AFBC_SUPERBLK_PIXELS;
> > > > > > -   kfb->offset_payload = ALIGN(n_blocks * AFBC_HEADER_SIZE,
> > > > > > -   alignment_header);
> > > > > > -
> > > > > > bpp = komeda_get_afbc_format_bpp(info, fb->modifier);
> > > > > > -   kfb->afbc_size = kfb->offset_payload + n_blocks *
> > > > > > -ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8,
> > > > > > -   

RE: [PATCH][next] drm/amdgpu/powerplay: fix dereference before null check of pointer hwmgr

2019-11-17 Thread Quan, Evan
Reviewed-by: Evan Quan 

-Original Message-
From: Colin King  
Sent: Friday, November 15, 2019 5:48 PM
To: Rex Zhu ; Quan, Evan ; Deucher, 
Alexander ; Koenig, Christian 
; Zhou, David(ChunMing) ; David 
Airlie ; Daniel Vetter ; 
amd-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org
Cc: kernel-janit...@vger.kernel.org; linux-ker...@vger.kernel.org
Subject: [PATCH][next] drm/amdgpu/powerplay: fix dereference before null check 
of pointer hwmgr

From: Colin Ian King 

The assignment of adev dereferences pointer hwmgr before hwmgr is null checked, 
hence there is a potential null pointer deference issue. Fix this by assigning 
adev after the null check.

Addresses-Coverity: ("Dereference before null check")
Fixes: 0896d2f7ba4d ("drm/amdgpu/powerplay: properly set PP_GFXOFF_MASK")
Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 443625c83ec9..d2909c91d65b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -81,7 +81,7 @@ static void hwmgr_init_workload_prority(struct pp_hwmgr 
*hwmgr)
 
 int hwmgr_early_init(struct pp_hwmgr *hwmgr)  {
-   struct amdgpu_device *adev = hwmgr->adev;
+   struct amdgpu_device *adev;
 
if (!hwmgr)
return -EINVAL;
@@ -96,6 +96,8 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
hwmgr_init_workload_prority(hwmgr);
hwmgr->gfxoff_state_changed_by_workload = false;
 
+   adev = hwmgr->adev;
+
switch (hwmgr->chip_family) {
case AMDGPU_FAMILY_CI:
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
--
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

RE: [PATCH] drm/amd/powerplay: remove variable 'result' set but not used

2019-11-17 Thread Quan, Evan
Thanks. But it's better to return the 'result' out on 'result != 0'.

Regards,
Evan
-Original Message-
From: Chen Wandun  
Sent: Saturday, November 16, 2019 11:43 AM
To: Deucher, Alexander ; Quan, Evan 
; amd-...@lists.freedesktop.org; 
dri-devel@lists.freedesktop.org; linux-ker...@vger.kernel.org
Cc: chenwan...@huawei.com
Subject: [PATCH] drm/amd/powerplay: remove variable 'result' set but not used

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c: In function 
vegam_populate_smc_boot_level:
drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c:1364:6: warning: 
variable result set but not used [-Wunused-but-set-variable]

Signed-off-by: Chen Wandun 
---
 drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
index 2068eb0..fad78bf 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
@@ -1361,20 +1361,19 @@ static int vegam_populate_smc_uvd_level(struct pp_hwmgr 
*hwmgr,
 static int vegam_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
struct SMU75_Discrete_DpmTable *table)
 {
-   int result = 0;
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
 
table->GraphicsBootLevel = 0;
table->MemoryBootLevel = 0;
 
/* find boot level from dpm table */
-   result = phm_find_boot_level(&(data->dpm_table.sclk_table),
-   data->vbios_boot_state.sclk_bootup_value,
-   (uint32_t *)&(table->GraphicsBootLevel));
+   phm_find_boot_level(&(data->dpm_table.sclk_table),
+   data->vbios_boot_state.sclk_bootup_value,
+   (uint32_t *)&(table->GraphicsBootLevel));
 
-   result = phm_find_boot_level(&(data->dpm_table.mclk_table),
-   data->vbios_boot_state.mclk_bootup_value,
-   (uint32_t *)&(table->MemoryBootLevel));
+   phm_find_boot_level(&(data->dpm_table.mclk_table),
+   data->vbios_boot_state.mclk_bootup_value,
+   (uint32_t *)&(table->MemoryBootLevel));
 
table->BootVddc  = data->vbios_boot_state.vddc_bootup_value *
VOLTAGE_SCALE;
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH V12 6/6] docs: sample driver to demonstrate how to implement virtio-mdev framework

2019-11-17 Thread Jason Wang
This sample driver creates mdev device that simulate virtio net device
over virtio mdev transport. The device is implemented through vringh
and workqueue. A device specific dma ops is to make sure HVA is used
directly as the IOVA. This should be sufficient for kernel virtio
driver to work.

Only 'virtio' type is supported right now. I plan to add 'vhost' type
on top which requires some virtual IOMMU implemented in this sample
driver.

Signed-off-by: Jason Wang 
---
 MAINTAINERS|   1 +
 samples/Kconfig|  10 +
 samples/vfio-mdev/Makefile |   1 +
 samples/vfio-mdev/mvnet_loopback.c | 690 +
 4 files changed, 702 insertions(+)
 create mode 100644 samples/vfio-mdev/mvnet_loopback.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 4c2e41641f7a..c032049f3fa0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17228,6 +17228,7 @@ F:  net/vmw_vsock/virtio_transport.c
 F: drivers/net/vsockmon.c
 F: drivers/vhost/vsock.c
 F: tools/testing/vsock/
+F: samples/vfio-mdev/mvnet_loopback.c
 
 VIRTIO CONSOLE DRIVER
 M: Amit Shah 
diff --git a/samples/Kconfig b/samples/Kconfig
index c8dacb4dda80..1bef029cc977 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -131,6 +131,16 @@ config SAMPLE_VFIO_MDEV_MDPY
  mediated device.  It is a simple framebuffer and supports
  the region display interface (VFIO_GFX_PLANE_TYPE_REGION).
 
+config SAMPLE_VIRTIO_MDEV_NET_LOOPBACK
+   tristate "Build loopback VIRTIO net example mediated device sample code 
-- loadable modules only"
+   depends on MDEV_VIRTIO && VHOST_RING && m
+   help
+ Build a networking sample device for use as a virtio
+ mediated device. The device cooperates with virtio-mdev bus
+ driver to present an virtio ethernet driver for
+ kernel. It simply loopbacks all packets from its TX
+ virtqueue to its RX virtqueue.
+
 config SAMPLE_VFIO_MDEV_MDPY_FB
tristate "Build VFIO mdpy example guest fbdev driver -- loadable module 
only"
depends on FB && m
diff --git a/samples/vfio-mdev/Makefile b/samples/vfio-mdev/Makefile
index 10d179c4fdeb..817618569848 100644
--- a/samples/vfio-mdev/Makefile
+++ b/samples/vfio-mdev/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o
 obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY) += mdpy.o
 obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY_FB) += mdpy-fb.o
 obj-$(CONFIG_SAMPLE_VFIO_MDEV_MBOCHS) += mbochs.o
+obj-$(CONFIG_SAMPLE_VIRTIO_MDEV_NET_LOOPBACK) += mvnet_loopback.o
diff --git a/samples/vfio-mdev/mvnet_loopback.c 
b/samples/vfio-mdev/mvnet_loopback.c
new file mode 100644
index ..79059a177f39
--- /dev/null
+++ b/samples/vfio-mdev/mvnet_loopback.c
@@ -0,0 +1,690 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Mediated virtual virtio-net device driver.
+ *
+ * Copyright (c) 2019, Red Hat Inc. All rights reserved.
+ * Author: Jason Wang 
+ *
+ * Sample driver that creates mdev device that simulates ethernet loopback
+ * device.
+ *
+ * Usage:
+ *
+ * # modprobe virtio_mdev
+ * # modprobe mvnet_loopback
+ * # cd /sys/devices/virtual/mvnet_loopback/mvnet_loopback/ \
+ *  mdev_supported_types/mvnet_loopback-virtio
+ * # echo "83b8f4f2-509f-382f-3c1e-e6bfe0fa1001" > ./create
+ * # cd devices/83b8f4f2-509f-382f-3c1e-e6bfe0fa1001
+ * # ls -d virtio0
+ * virtio0
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define VERSION_STRING  "0.1"
+#define DRIVER_AUTHOR   "Red Hat Corporation"
+
+#define MVNET_CLASS_NAME "mvnet_loopback"
+#define MVNET_NAME   "mvnet_loopback"
+
+#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev"
+
+/*
+ * Global Structures
+ */
+
+static struct mvnet_dev {
+   struct class*vd_class;
+   struct idr  vd_idr;
+   struct device   dev;
+} mvnet_dev;
+
+struct mvnet_virtqueue {
+   struct vringh vring;
+   struct vringh_kiov iov;
+   unsigned short head;
+   bool ready;
+   u64 desc_addr;
+   u64 device_addr;
+   u64 driver_addr;
+   u32 num;
+   void *private;
+   irqreturn_t (*cb)(void *data);
+};
+
+#define MVNET_QUEUE_ALIGN PAGE_SIZE
+#define MVNET_QUEUE_MAX 256
+#define MVNET_DEVICE_ID 0x1
+#define MVNET_VENDOR_ID 0
+
+u64 mvnet_features = (1ULL << VIRTIO_F_ANY_LAYOUT) |
+(1ULL << VIRTIO_F_VERSION_1) |
+(1ULL << VIRTIO_F_IOMMU_PLATFORM);
+
+/* State of each mdev device */
+struct mvnet_state {
+   struct mvnet_virtqueue vqs[2];
+   struct work_struct work;
+   /* spinlock to synchronize virtqueue state */
+   spinlock_t lock;
+   struct mdev_device *mdev;
+   struct virtio_net_config config;
+   void *buffer;
+   u32 status;
+   u32 generation;
+   u64 features;
+   struct list_head next;
+};
+
+static struct mutex 

[PATCH V12 4/6] mdev: introduce mediated virtio bus

2019-11-17 Thread Jason Wang
This patch implements a mediated virtio bus over mdev framework. This
will be used by the future virtio-mdev and vhost-mdev on top to allow
driver from either userspace or kernel to control the device which is
capable of offloading virtio datapath.

Signed-off-by: Jason Wang 
---
 MAINTAINERS   |   2 +
 drivers/mdev/Kconfig  |  10 ++
 drivers/mdev/Makefile |   2 +
 drivers/mdev/virtio.c | 126 +++
 include/linux/mdev_virtio.h   | 163 ++
 include/linux/mod_devicetable.h   |   8 ++
 scripts/mod/devicetable-offsets.c |   3 +
 scripts/mod/file2alias.c  |  12 +++
 8 files changed, 326 insertions(+)
 create mode 100644 drivers/mdev/virtio.c
 create mode 100644 include/linux/mdev_virtio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 829428d8a9f5..4c2e41641f7a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17251,6 +17251,8 @@ F:  include/linux/virtio*.h
 F: include/uapi/linux/virtio_*.h
 F: drivers/crypto/virtio/
 F: mm/balloon_compaction.c
+F: include/linux/mdev_virtio.h
+F: drivers/mdev/virtio.c
 
 VIRTIO BLOCK AND SCSI DRIVERS
 M: "Michael S. Tsirkin" 
diff --git a/drivers/mdev/Kconfig b/drivers/mdev/Kconfig
index 4561f2d4178f..cd84d4670552 100644
--- a/drivers/mdev/Kconfig
+++ b/drivers/mdev/Kconfig
@@ -17,3 +17,13 @@ config VFIO_MDEV
  more details.
 
  If you don't know what do here, say N.
+
+config MDEV_VIRTIO
+   tristate "Mediated VIRTIO bus"
+   depends on VIRTIO && MDEV
+   default n
+   help
+ Proivdes a mediated BUS for virtio. It could be used by
+  either kenrel driver or userspace driver.
+
+ If you don't know what do here, say N.
diff --git a/drivers/mdev/Makefile b/drivers/mdev/Makefile
index 0b749e7f8ff4..eb14031c9944 100644
--- a/drivers/mdev/Makefile
+++ b/drivers/mdev/Makefile
@@ -1,5 +1,7 @@
 
 mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o
 mdev_vfio-y := vfio.o
+mdev_virtio-y := virtio.o
 obj-$(CONFIG_MDEV) += mdev.o
 obj-$(CONFIG_VFIO_MDEV) += mdev_vfio.o
+obj-$(CONFIG_MDEV_VIRTIO) += mdev_virtio.o
diff --git a/drivers/mdev/virtio.c b/drivers/mdev/virtio.c
new file mode 100644
index ..25de329615c4
--- /dev/null
+++ b/drivers/mdev/virtio.c
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Mediated VIRTIO bus
+ *
+ * Copyright (c) 2019, Red Hat. All rights reserved.
+ * Author: Jason Wang 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mdev_private.h"
+
+#define DRIVER_VERSION "0.1"
+#define DRIVER_AUTHOR  "Jason Wang"
+#define DRIVER_DESC"Mediated VIRTIO bus"
+
+struct bus_type mdev_virtio_bus_type;
+
+struct mdev_virtio_device {
+   struct mdev_device mdev;
+   const struct mdev_virtio_ops *ops;
+   u16 class_id;
+};
+
+#define to_mdev_virtio(mdev) container_of(mdev, \
+ struct mdev_virtio_device, mdev)
+#define to_mdev_virtio_drv(mdrv) container_of(mdrv, \
+ struct mdev_virtio_driver, drv)
+
+static int mdev_virtio_match(struct device *dev, struct device_driver *drv)
+{
+   unsigned int i;
+   struct mdev_device *mdev = mdev_from_dev(dev, _virtio_bus_type);
+   struct mdev_virtio_device *mdev_virtio = to_mdev_virtio(mdev);
+   struct mdev_driver *mdrv = to_mdev_driver(drv);
+   struct mdev_virtio_driver *mdrv_virtio = to_mdev_virtio_drv(mdrv);
+   const struct mdev_virtio_class_id *ids = mdrv_virtio->id_table;
+
+   if (!ids)
+   return 0;
+
+   for (i = 0; ids[i].id; i++)
+   if (ids[i].id == mdev_virtio->class_id)
+   return 1;
+   return 0;
+}
+
+static int mdev_virtio_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+   struct mdev_device *mdev = mdev_from_dev(dev, _virtio_bus_type);
+   struct mdev_virtio_device *mdev_virtio = to_mdev_virtio(mdev);
+
+   return add_uevent_var(env, "MODALIAS=mdev_virtio:c%02X",
+ mdev_virtio->class_id);
+}
+
+struct bus_type mdev_virtio_bus_type = {
+   .name   = "mdev_virtio",
+   .probe  = mdev_probe,
+   .remove = mdev_remove,
+   .match  = mdev_virtio_match,
+   .uevent = mdev_virtio_uevent,
+};
+EXPORT_SYMBOL(mdev_virtio_bus_type);
+
+void mdev_virtio_set_class_id(struct mdev_device *mdev, u16 class_id)
+{
+   struct mdev_virtio_device *mdev_virtio = to_mdev_virtio(mdev);
+
+   mdev_virtio->class_id = class_id;
+}
+EXPORT_SYMBOL(mdev_virtio_set_class_id);
+
+int mdev_virtio_register_device(struct device *dev,
+   const struct mdev_parent_ops *ops)
+{
+   return mdev_register_device(dev, ops, _virtio_bus_type,
+   sizeof(struct mdev_virtio_device));
+}
+EXPORT_SYMBOL(mdev_virtio_register_device);

[PATCH V12 5/6] virtio: introduce a mdev based transport

2019-11-17 Thread Jason Wang
This patch introduces a new mdev transport for virtio. This is used to
use kernel virtio driver to drive the mediated device that is capable
of populating virtqueue directly.

A new virtio-mdev driver will be registered to the mdev bus, when a
new virtio-mdev device is probed, it will register the device with
mdev based config ops. This means it is a software transport between
mdev driver and mdev device. The transport was implemented through
bus_ops of mdev parent.

Signed-off-by: Jason Wang 
---
 drivers/virtio/Kconfig   |  13 ++
 drivers/virtio/Makefile  |   1 +
 drivers/virtio/virtio_mdev.c | 409 +++
 include/linux/mdev_virtio.h  |   5 +
 4 files changed, 428 insertions(+)
 create mode 100644 drivers/virtio/virtio_mdev.c

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 078615cf2afc..6a89b3de97d3 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -43,6 +43,19 @@ config VIRTIO_PCI_LEGACY
 
  If unsure, say Y.
 
+config VIRTIO_MDEV
+   tristate "MDEV driver for virtio devices"
+   depends on MDEV_VIRTIO
+   default n
+   help
+ This driver provides support for virtio based paravirtual
+ device driver over MDEV bus. For this to be useful, you need
+ an appropriate virtio mdev device implementation that
+ operates on a physical device to allow the datapath of virtio
+ to be offloaded to hardware.
+
+ If unsure, say M.
+
 config VIRTIO_PMEM
tristate "Support for virtio pmem driver"
depends on VIRTIO
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 3a2b5c5dcf46..f2997b6c812f 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -6,3 +6,4 @@ virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
 virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
+obj-$(CONFIG_VIRTIO_MDEV) += virtio_mdev.o
diff --git a/drivers/virtio/virtio_mdev.c b/drivers/virtio/virtio_mdev.c
new file mode 100644
index ..7fdb42f055df
--- /dev/null
+++ b/drivers/virtio/virtio_mdev.c
@@ -0,0 +1,409 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * VIRTIO based driver for Mediated device
+ *
+ * Copyright (c) 2019, Red Hat. All rights reserved.
+ * Author: Jason Wang 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_VERSION  "0.1"
+#define DRIVER_AUTHOR   "Red Hat Corporation"
+#define DRIVER_DESC "VIRTIO based driver for Mediated device"
+
+#define to_virtio_mdev_device(dev) \
+   container_of(dev, struct virtio_mdev_device, vdev)
+
+struct virtio_mdev_device {
+   struct virtio_device vdev;
+   struct mdev_device *mdev;
+   u64 features;
+
+   /* The lock to protect virtqueue list */
+   spinlock_t lock;
+   /* List of virtio_mdev_vq_info */
+   struct list_head virtqueues;
+};
+
+struct virtio_mdev_vq_info {
+   /* the actual virtqueue */
+   struct virtqueue *vq;
+
+   /* the list node for the virtqueues list */
+   struct list_head node;
+};
+
+static struct mdev_device *vm_get_mdev(struct virtio_device *vdev)
+{
+   struct virtio_mdev_device *vm_dev = to_virtio_mdev_device(vdev);
+   struct mdev_device *mdev = vm_dev->mdev;
+
+   return mdev;
+}
+
+static void virtio_mdev_get(struct virtio_device *vdev, unsigned offset,
+   void *buf, unsigned len)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   const struct mdev_virtio_ops *ops = mdev_virtio_get_ops(mdev);
+
+   ops->get_config(mdev, offset, buf, len);
+}
+
+static void virtio_mdev_set(struct virtio_device *vdev, unsigned offset,
+   const void *buf, unsigned len)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   const struct mdev_virtio_ops *ops = mdev_virtio_get_ops(mdev);
+
+   ops->set_config(mdev, offset, buf, len);
+}
+
+static u32 virtio_mdev_generation(struct virtio_device *vdev)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   const struct mdev_virtio_ops *ops = mdev_virtio_get_ops(mdev);
+
+
+   if (ops->get_generation)
+   return ops->get_generation(mdev);
+
+   return 0;
+}
+
+static u8 virtio_mdev_get_status(struct virtio_device *vdev)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   const struct mdev_virtio_ops *ops = mdev_virtio_get_ops(mdev);
+
+   return ops->get_status(mdev);
+}
+
+static void virtio_mdev_set_status(struct virtio_device *vdev, u8 status)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   const struct mdev_virtio_ops *ops = mdev_virtio_get_ops(mdev);
+
+   return ops->set_status(mdev, status);
+}
+
+static void virtio_mdev_reset(struct virtio_device *vdev)
+{
+   struct mdev_device *mdev = vm_get_mdev(vdev);
+   

[PATCH V12 3/6] mdev: move to drivers/

2019-11-17 Thread Jason Wang
Mdev now is nothing VFIO specific, let's move it to upper
directory.

Signed-off-by: Jason Wang 
---
 MAINTAINERS   |  7 +--
 drivers/Kconfig   |  2 ++
 drivers/Makefile  |  1 +
 drivers/mdev/Kconfig  | 19 ++
 drivers/mdev/Makefile |  5 +
 drivers/{vfio => }/mdev/mdev_core.c   |  0
 drivers/{vfio => }/mdev/mdev_driver.c |  0
 drivers/{vfio => }/mdev/mdev_private.h|  0
 drivers/{vfio => }/mdev/mdev_sysfs.c  |  0
 .../{vfio/mdev/mdev_vfio.c => mdev/vfio.c}|  0
 drivers/vfio/mdev/Kconfig | 20 ---
 drivers/vfio/mdev/Makefile|  4 
 drivers/vfio/mdev/vfio_mdev.c |  2 --
 13 files changed, 32 insertions(+), 28 deletions(-)
 create mode 100644 drivers/mdev/Kconfig
 create mode 100644 drivers/mdev/Makefile
 rename drivers/{vfio => }/mdev/mdev_core.c (100%)
 rename drivers/{vfio => }/mdev/mdev_driver.c (100%)
 rename drivers/{vfio => }/mdev/mdev_private.h (100%)
 rename drivers/{vfio => }/mdev/mdev_sysfs.c (100%)
 rename drivers/{vfio/mdev/mdev_vfio.c => mdev/vfio.c} (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index d335949240dc..829428d8a9f5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17111,15 +17111,18 @@ T:git git://github.com/awilliam/linux-vfio.git
 S: Maintained
 F: Documentation/driver-api/vfio.rst
 F: drivers/vfio/
+F: drivers/mdev/vfio.c
 F: include/linux/vfio.h
 F: include/uapi/linux/vfio.h
 
-VFIO MEDIATED DEVICE DRIVERS
+MEDIATED DEVICE DRIVERS
+M: Alex Williamson 
 M: Kirti Wankhede 
+R: Cornelia Huck 
 L: k...@vger.kernel.org
 S: Maintained
 F: Documentation/driver-api/vfio-mediated-device.rst
-F: drivers/vfio/mdev/
+F: drivers/mdev
 F: include/linux/mdev.h
 F: include/linux/mdev_vfio.h
 F: samples/vfio-mdev/
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 8befa53f43be..3e2839048fe6 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -228,4 +228,6 @@ source "drivers/interconnect/Kconfig"
 
 source "drivers/counter/Kconfig"
 
+source "drivers/mdev/Kconfig"
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index aaef17cc6512..592e23f2e629 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -186,3 +186,4 @@ obj-$(CONFIG_SIOX)  += siox/
 obj-$(CONFIG_GNSS) += gnss/
 obj-$(CONFIG_INTERCONNECT) += interconnect/
 obj-$(CONFIG_COUNTER)  += counter/
+obj-$(CONFIG_MDEV) += mdev/
diff --git a/drivers/mdev/Kconfig b/drivers/mdev/Kconfig
new file mode 100644
index ..4561f2d4178f
--- /dev/null
+++ b/drivers/mdev/Kconfig
@@ -0,0 +1,19 @@
+
+config MDEV
+   tristate "Mediated device driver framework"
+   default n
+   help
+ Provides a framework to virtualize devices.
+
+ If you don't know what do here, say N.
+
+config VFIO_MDEV
+   tristate "VFIO Mediated device driver"
+depends on VFIO && MDEV
+default n
+   help
+ Proivdes a mediated BUS for userspace driver through VFIO
+ framework. See Documentation/vfio-mediated-device.txt for
+ more details.
+
+ If you don't know what do here, say N.
diff --git a/drivers/mdev/Makefile b/drivers/mdev/Makefile
new file mode 100644
index ..0b749e7f8ff4
--- /dev/null
+++ b/drivers/mdev/Makefile
@@ -0,0 +1,5 @@
+
+mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o
+mdev_vfio-y := vfio.o
+obj-$(CONFIG_MDEV) += mdev.o
+obj-$(CONFIG_VFIO_MDEV) += mdev_vfio.o
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/mdev/mdev_core.c
similarity index 100%
rename from drivers/vfio/mdev/mdev_core.c
rename to drivers/mdev/mdev_core.c
diff --git a/drivers/vfio/mdev/mdev_driver.c b/drivers/mdev/mdev_driver.c
similarity index 100%
rename from drivers/vfio/mdev/mdev_driver.c
rename to drivers/mdev/mdev_driver.c
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/mdev/mdev_private.h
similarity index 100%
rename from drivers/vfio/mdev/mdev_private.h
rename to drivers/mdev/mdev_private.h
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/mdev/mdev_sysfs.c
similarity index 100%
rename from drivers/vfio/mdev/mdev_sysfs.c
rename to drivers/mdev/mdev_sysfs.c
diff --git a/drivers/vfio/mdev/mdev_vfio.c b/drivers/mdev/vfio.c
similarity index 100%
rename from drivers/vfio/mdev/mdev_vfio.c
rename to drivers/mdev/vfio.c
diff --git a/drivers/vfio/mdev/Kconfig b/drivers/vfio/mdev/Kconfig
index 2e07ca915a96..9a9234c3e00e 100644
--- a/drivers/vfio/mdev/Kconfig
+++ b/drivers/vfio/mdev/Kconfig
@@ -1,24 +1,4 @@
 
-config MDEV
-   tristate "Mediated device driver framework"
-   default n
-   help
- Provides a framework to virtualize devices.
-
- If you don't know what do here, say N.
-
-config VFIO_MDEV
-   tristate "VFIO Mediated device driver"
-depends on 

[PATCH V12 1/6] mdev: make mdev bus agnostic

2019-11-17 Thread Jason Wang
Current mdev is tied to a VFIO specific "mdev" bus. This prevent mdev
from being used by other types of API/buses. So this patch tries to make
mdev bus agnostic through making a mdev core a thin module:

- decouple VFIO bus specific bits from mdev_core.c to mdev_vfio.c and
  introduce mdev_vfio module
- require to specify the type of bus when registering mdev device and
  mdev driver

With those modifications mdev become a generic module that could be
used by multiple types of virtual buses and devices.

Signed-off-by: Jason Wang 
---
 .../driver-api/vfio-mediated-device.rst   |  68 ++--
 MAINTAINERS   |   1 +
 drivers/gpu/drm/i915/gvt/kvmgt.c  |  10 +-
 drivers/s390/cio/vfio_ccw_ops.c   |   6 +-
 drivers/s390/crypto/vfio_ap_ops.c |  21 ++--
 drivers/s390/crypto/vfio_ap_private.h |   2 +-
 drivers/vfio/mdev/Kconfig |  17 ++-
 drivers/vfio/mdev/Makefile|   4 +-
 drivers/vfio/mdev/mdev_core.c | 104 +-
 drivers/vfio/mdev/mdev_driver.c   |  29 ++---
 drivers/vfio/mdev/mdev_private.h  |  13 ++-
 drivers/vfio/mdev/mdev_vfio.c |  48 
 drivers/vfio/mdev/vfio_mdev.c |   5 +-
 drivers/vfio/vfio_iommu_type1.c   |   6 +-
 include/linux/mdev.h  |  16 ++-
 include/linux/mdev_vfio.h |  25 +
 samples/vfio-mdev/mbochs.c|   8 +-
 samples/vfio-mdev/mdpy.c  |   8 +-
 samples/vfio-mdev/mtty.c  |   8 +-
 19 files changed, 270 insertions(+), 129 deletions(-)
 create mode 100644 drivers/vfio/mdev/mdev_vfio.c
 create mode 100644 include/linux/mdev_vfio.h

diff --git a/Documentation/driver-api/vfio-mediated-device.rst 
b/Documentation/driver-api/vfio-mediated-device.rst
index 25eb7d5b834b..1887d27a565e 100644
--- a/Documentation/driver-api/vfio-mediated-device.rst
+++ b/Documentation/driver-api/vfio-mediated-device.rst
@@ -49,35 +49,37 @@ devices as examples, as these devices are the first devices 
to use this module::
 
  +---+
  |   |
- | +---+ |  mdev_register_driver() +--+
- | |   | +<+  |
- | |  mdev | | |  |
- | |  bus  | +>+ vfio_mdev.ko |<-> VFIO user
- | |  driver   | | probe()/remove()|  |APIs
- | |   | | +--+
- | +---+ |
+ |   MDEV CORE   |  mdev_register_driver() +--+
+ |MODULE +<+  |
+ |mdev.ko| |  |
+ |   +>+ vfio_mdev.ko |<-> VFIO user
+ |   | probe()/remove()|  |APIs
+ |   | +--+
+ +---+---+---+
+ |  /|\
+ |   |
+callbacks|   | mdev_register_device()
+ |   | mdev_register_bus()
+\|/  |
+ +---+---+---+
+ |   |  mdev_vfio_register_device() +--+
+ |   +<-+  |
+ |   |  |  nvidia.ko   |<-> 
physical
+ |   +->+  |device
+ |   MDEV VFIO   |callbacks +--+
+ |   Physical|
+ |device |  mdev_vfio_register_device() +--+
+ |   interface   |<-+  |
+ |   |  |  i915.ko |<-> 
physical
+ | mdev_vfio.ko  +->+  |device
+ |   |callbacks +--+
+ |   |
+ |   |  mdev_vfio_register_device() +--+
+ |   +<-+  |
+ |   |  | ccw_device.ko|<-> 
physical
+ |   +->+  |device
+ |   |callbacks +--+
  |   |
- |  MDEV CORE|
- |   MODULE  |
- |   mdev.ko |
- | +---+ |  mdev_register_device() +--+
- | |   | +<+  |
- | |   | | |  nvidia.ko   |<-> physical
- | |   | +>+  |device
- | |   | |callbacks+--+
- | | Physical  | |
- | |  device   | |  mdev_register_device() +--+
- | | interface | 

[PATCH V12 2/6] mdev: split out VFIO bus specific parent ops

2019-11-17 Thread Jason Wang
The only thing left for generalizing mdev is the VFIO specific parent
ops. This is basically the open/release/read/write/ioctl/mmap.

To support this, mdev core is extend to support a specific size
of structure during create, this will allow to compose mdev structure
into mdev vfio structure and place the VFIO specific callbacks there
like:

struct mdev_vfio {
   struct mdev_device mdev;
   const struct mdev_vfio_ops *ops;
};

Helpers for setting and getting the ops were introduced to support
mdev vfio device to set ops and vfio mdev driver to use the ops.

Signed-off-by: Jason Wang 
---
 .../driver-api/vfio-mediated-device.rst   | 34 +--
 drivers/gpu/drm/i915/gvt/kvmgt.c  | 16 ---
 drivers/s390/cio/vfio_ccw_ops.c   | 17 +---
 drivers/s390/crypto/vfio_ap_ops.c | 13 --
 drivers/vfio/mdev/mdev_core.c |  5 ++-
 drivers/vfio/mdev/mdev_private.h  |  5 +++
 drivers/vfio/mdev/mdev_vfio.c | 30 -
 drivers/vfio/mdev/vfio_mdev.c | 38 
 include/linux/mdev.h  | 37 
 include/linux/mdev_vfio.h | 43 +++
 samples/vfio-mdev/mbochs.c| 18 +---
 samples/vfio-mdev/mdpy.c  | 19 +---
 samples/vfio-mdev/mtty.c  | 16 ---
 13 files changed, 189 insertions(+), 102 deletions(-)

diff --git a/Documentation/driver-api/vfio-mediated-device.rst 
b/Documentation/driver-api/vfio-mediated-device.rst
index 1887d27a565e..9045584e4ea3 100644
--- a/Documentation/driver-api/vfio-mediated-device.rst
+++ b/Documentation/driver-api/vfio-mediated-device.rst
@@ -153,26 +153,36 @@ callbacks per mdev parent device, per mdev type, or any 
other categorization.
 Vendor drivers are expected to be fully asynchronous in this respect or
 provide their own internal resource protection.)
 
-The callbacks in the mdev_parent_ops structure are as follows:
+A driver should use the mdev_parent_ops structure in the function call
+to register itself with the mdev core driver::
 
-* open: open callback of mediated device
-* close: close callback of mediated device
-* ioctl: ioctl callback of mediated device
+   extern int mdev_vfio_register_device(struct device *dev,
+ const struct mdev_parent_ops 
*ops);
+
+However, the mdev_parent_ops structure is not required in the function call
+that a driver should use to unregister itself with the mdev core driver::
+
+   extern void mdev_vfio_unregister_device(struct device *dev);
+
+The VFIO specific callbacks is abstracted in mdev_vfio_ops structure
+are as follows:
+
+* open: open callback of VFIO mediated device
+* close: close callback of VFIO mediated device
+* ioctl: ioctl callback of VFIO mediated device
 * read : read emulation callback
 * write: write emulation callback
 * mmap: mmap emulation callback
 
-A driver should use the mdev_parent_ops structure and bus type in the
-function call to register itself with the mdev core driver::
+During the creation of VFIO mediated device, mdev_vfio_ops need to be
+specified::
 
-   extern int  mdev_register_device(struct device *dev,
-const struct mdev_parent_ops *ops,
- struct bus_type *bus);
+void mdev_vfio_set_ops(struct mdev_device *mdev,
+const struct mdev_vfio_ops *ops);
 
-However, the mdev_parent_ops structure is not required in the function call
-that a driver should use to unregister itself with the mdev core driver::
+Those callbacks could be fetched by drivers through::
 
-   extern void mdev_unregister_device(struct device *dev);
+const struct mdev_vfio_ops *mdev_vfio_get_ops(struct mdev_device 
*mdev);
 
 
 Mediated Device Management Interface Through sysfs
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 8c02572c9b42..fbd1f1676c15 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -643,6 +643,8 @@ static void kvmgt_put_vfio_device(void *vgpu)
vfio_device_put(((struct intel_vgpu *)vgpu)->vdev.vfio_device);
 }
 
+static const struct mdev_vfio_ops intel_mdev_vfio_ops;
+
 static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
 {
struct intel_vgpu *vgpu = NULL;
@@ -678,6 +680,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct 
mdev_device *mdev)
 dev_name(mdev_dev(mdev)));
ret = 0;
 
+   mdev_vfio_set_ops(mdev, _mdev_vfio_ops);
 out:
return ret;
 }
@@ -1598,20 +1601,21 @@ static const struct attribute_group 
*intel_vgpu_groups[] = {
NULL,
 };
 
-static struct mdev_parent_ops intel_vgpu_ops = {
-   .mdev_attr_groups   = intel_vgpu_groups,
-   .create = intel_vgpu_create,
-   

[PATCH V12 0/6] mdev based hardware virtio offloading support

2019-11-17 Thread Jason Wang
Hi all:

There are hardwares that can do virtio datapath offloading while
having its own control path. This path tries to implement a mdev based
unified API to support using kernel virtio driver to drive those
devices. This is done by introducing a new mdev transport for virtio
(virtio_mdev) and register itself as a new kind of mdev driver. Then
it provides a unified way for kernel virtio driver to talk with mdev
device implementation.

Though the series only contains kernel driver support, the goal is to
make the transport generic enough to support userspace drivers. This
means vhost-mdev[1] could be built on top as well by resuing the
transport.

A sample driver is also implemented which simulate a virito-net
loopback ethernet device on top of vringh + workqueue. This could be
used as a reference implementation for real hardware driver.

Also a real IFC VF driver was also posted here[2] which is a good
reference for vendors who is interested in their own virtio datapath
offloading product.

Consider mdev framework only support VFIO device and driver right now,
this series also extend it to support other types. This is done
through decoupling VFIO specific bits out of mdev core and make mdev
an independent module that allows to be used by multiple types of
buses.

Pktgen test was done with virito-net + mvnet loop back device.

Please review.

[1] https://lkml.org/lkml/2019/11/5/424
[2] https://lkml.org/lkml/2019/11/5/227

Changes from V11:
- decouple VFIO specific bits out of mdev core
- make mdev an indepdent module to allow buses other than VFIO mdev
- allow structure composition of mdev through specifiy the size of
  mdev structure
- introduce mdev_vfio structure and store the VFIO specific callbacks
  there
- don't use "mdev" bus for virtio, use a new "mdev_virtio" bus, and
  store the virtio specific callbacks in mdev_virtio structure.
- do the class_id, matching on top of "mdev_virtio" bus

Changes from V10:
- rename mvnet to mvnet_loopback
- fix typo in the help text for sample Kconfig

Changes from V9:
- Tweak the help text for virito-mdev kconfig

Changes from V8:
- try silent checkpatch, some are still there becuase they were inherited
  from virtio_config_ops which needs to be resolved in an independent series
- tweak on the comment and doc
- remove VIRTIO_MDEV_F_VERSION_1 completely
- rename CONFIG_VIRTIO_MDEV_DEVICE to CONFIG_VIRTIO_MDEV

Changes from V7:
- drop {set|get}_mdev_features for virtio
- typo and comment style fixes

Changes from V6:
- rename ops files and compile guard

Changes from V5:
- use dev_warn() instead of WARN(1) when class id is not set
- validate id_table before trying to do matching between device and
  driver
- add wildcard for modpost script
- use unique name for id_table
- move get_mdev_features() to be the first member of virtio_device_ops
  and more comments for it
- typo fixes for the comments above virtio_mdev_ops

Changes from V4:
- keep mdev_set_class() for the device that doesn't use device ops
- use union for device ops pointer in mdev_device
- introduce class specific helper for getting is device ops
- use WARN_ON instead of BUG_ON in mdev_set_virtio_ops
- explain details of get_mdev_features() and get_vendor_id()
- distinguish the optional virito device ops from mandatory ones and
  make get_generation() optional
- rename vfio_mdev.h to vfio_mdev_ops.h, rename virito_mdev.h to
  virtio_mdev_ops.h
- don't abuse version fileds in virtio_mdev structure, use features
  instead
- fix warning during device remove
- style & docs tweaks and typo fixes

Changes from V3:
- document that class id (device ops) must be specified in create()
- add WARN() when trying to set class_id when it has already set
- add WARN() when class_id is not specified in create() and correctly
  return an error in this case
- correct the prototype of mdev_set_class() in the doc
- add documention of mdev_set_class()
- remove the unnecessary "class_id_fail" label when class id is not
  specified in create()
- convert id_table in vfio_mdev to const
- move mdev_set_class and its friends after mdev_uuid()
- suqash the patch of bus uevent into patch of introducing class id
- tweak the words in the docs per Cornelia suggestion
- tie class_id and device ops through class specific initialization
  routine like mdev_set_vfio_ops()
- typos fixes in the docs of virtio-mdev callbacks
- document the usage of virtqueues in struct virtio_mdev_device
- remove the useless vqs array in struct virtio_mdev_device
- rename MDEV_ID_XXX to MDEV_CLASS_ID_XXX

Changes from V2:
- fail when class_id is not specified
- drop the vringh patch
- match the doc to the code
- tweak the commit log
- move device_ops from parent to mdev device
- remove the unused MDEV_ID_VHOST

Changes from V1:
- move virtio_mdev.c to drivers/virtio
- store class_id in mdev_device instead of mdev_parent
- store device_ops in mdev_device instead of mdev_parent
- reorder the patch, vringh fix comes first
- really silent compiling warnings
- 

linux-next: manual merge of the drm tree with the kbuild tree

2019-11-17 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the drm tree got a conflict in:

  drivers/gpu/drm/i915/Kconfig.debug

between commit:

  fcbb8461fd23 ("kbuild: remove header compile test")

from the kbuild tree and commit:

  d30213e533fa ("drm/i915: Fix Kconfig indentation")

from the drm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/i915/Kconfig.debug
index 41c8e39a73ba,eea79125b3ea..
--- a/drivers/gpu/drm/i915/Kconfig.debug
+++ b/drivers/gpu/drm/i915/Kconfig.debug
@@@ -1,33 -1,34 +1,33 @@@
  # SPDX-License-Identifier: GPL-2.0-only
  config DRM_I915_WERROR
- bool "Force GCC to throw an error instead of a warning when compiling"
- # As this may inadvertently break the build, only allow the user
- # to shoot oneself in the foot iff they aim really hard
- depends on EXPERT
- # We use the dependency on !COMPILE_TEST to not be enabled in
- # allmodconfig or allyesconfig configurations
- depends on !COMPILE_TEST
- default n
- help
-   Add -Werror to the build flags for (and only for) i915.ko.
-   Do not enable this unless you are writing code for the i915.ko 
module.
- 
-   Recommended for driver developers only.
- 
-   If in doubt, say "N".
+   bool "Force GCC to throw an error instead of a warning when compiling"
+   # As this may inadvertently break the build, only allow the user
+   # to shoot oneself in the foot iff they aim really hard
+   depends on EXPERT
+   # We use the dependency on !COMPILE_TEST to not be enabled in
+   # allmodconfig or allyesconfig configurations
+   depends on !COMPILE_TEST
 -  select HEADER_TEST
+   default n
+   help
+ Add -Werror to the build flags for (and only for) i915.ko.
+ Do not enable this unless you are writing code for the i915.ko module.
+ 
+ Recommended for driver developers only.
+ 
+ If in doubt, say "N".
  
  config DRM_I915_DEBUG
- bool "Enable additional driver debugging"
- depends on DRM_I915
- select DEBUG_FS
- select PREEMPT_COUNT
- select REFCOUNT_FULL
- select I2C_CHARDEV
- select STACKDEPOT
- select DRM_DP_AUX_CHARDEV
- select X86_MSR # used by igt/pm_rpm
- select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks)
- select DRM_DEBUG_MM if DRM=y
+   bool "Enable additional driver debugging"
+   depends on DRM_I915
+   select DEBUG_FS
+   select PREEMPT_COUNT
+   select REFCOUNT_FULL
+   select I2C_CHARDEV
+   select STACKDEPOT
+   select DRM_DP_AUX_CHARDEV
+   select X86_MSR # used by igt/pm_rpm
+   select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks)
+   select DRM_DEBUG_MM if DRM=y
select DRM_DEBUG_SELFTEST
select DMABUF_SELFTESTS
select SW_SYNC # signaling validation framework (igt/syncobj*)


pgps92gU0s34x.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 1/2] drm/radeon: fix bad DMA from INTERRUPT_CNTL2

2019-11-17 Thread Sam Bobroff
The INTERRUPT_CNTL2 register expects a valid DMA address, but is
currently set with a GPU MC address.  This can cause problems on
systems that detect the resulting DMA read from an invalid address
(found on a Power8 guest).

Instead, use the DMA address of the dummy page because it will always
be safe.

Fixes: d8f60cfc9345 ("drm/radeon/kms: Add support for interrupts on r6xx/r7xx 
chips (v3)")
Fixes: 25a857fbe973 ("drm/radeon/kms: add support for interrupts on SI")
Fixes: a59781bbe528 ("drm/radeon: add support for interrupts on CIK (v5)")
Signed-off-by: Sam Bobroff 
---
v2 - Split amdgpu changes into separate patch.

 drivers/gpu/drm/radeon/cik.c  | 4 ++--
 drivers/gpu/drm/radeon/r600.c | 4 ++--
 drivers/gpu/drm/radeon/si.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 62eab82a64f9..897442754fd0 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -6969,8 +6969,8 @@ static int cik_irq_init(struct radeon_device *rdev)
}
 
/* setup interrupt control */
-   /* XXX this should actually be a bus address, not an MC address. same 
on older asics */
-   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
+   /* set dummy read address to dummy page address */
+   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
interrupt_cntl = RREG32(INTERRUPT_CNTL);
/* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
without msi
 * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index e937cc01910d..033bc466a862 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3696,8 +3696,8 @@ int r600_irq_init(struct radeon_device *rdev)
}
 
/* setup interrupt control */
-   /* set dummy read address to ring address */
-   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
+   /* set dummy read address to dummy page address */
+   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
interrupt_cntl = RREG32(INTERRUPT_CNTL);
/* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
without msi
 * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 05894d198a79..1d8efb0eefdb 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -5997,8 +5997,8 @@ static int si_irq_init(struct radeon_device *rdev)
}
 
/* setup interrupt control */
-   /* set dummy read address to ring address */
-   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
+   /* set dummy read address to dummy page address */
+   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
interrupt_cntl = RREG32(INTERRUPT_CNTL);
/* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
without msi
 * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
-- 
2.22.0.216.g00a2a96fc9

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 2/2] drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2

2019-11-17 Thread Sam Bobroff
The INTERRUPT_CNTL2 register expects a valid DMA address, but is
currently set with a GPU MC address.  This can cause problems on
systems that detect the resulting DMA read from an invalid address
(found on a Power8 guest).

Instead, use the DMA address of the dummy page because it will always
be safe.

Fixes: 27ae10641e9c ("drm/amdgpu: add interupt handler implementation for si 
v3")
Signed-off-by: Sam Bobroff 
---
v2 * New in this version.

 drivers/gpu/drm/amd/amdgpu/si_ih.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c 
b/drivers/gpu/drm/amd/amdgpu/si_ih.c
index 57bb5f9e08b2..88ae27a5a03d 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c
@@ -64,7 +64,8 @@ static int si_ih_irq_init(struct amdgpu_device *adev)
u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
 
si_ih_disable_interrupts(adev);
-   WREG32(INTERRUPT_CNTL2, adev->irq.ih.gpu_addr >> 8);
+   /* set dummy read address to dummy page address */
+   WREG32(INTERRUPT_CNTL2, adev->dummy_page_addr >> 8);
interrupt_cntl = RREG32(INTERRUPT_CNTL);
interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE;
interrupt_cntl &= ~IH_REQ_NONSNOOP_EN;
-- 
2.22.0.216.g00a2a96fc9

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 0/2] fix bad DMA from INTERRUPT_CNTL2

2019-11-17 Thread Sam Bobroff
A couple of notes:
- Initial discussion:
  https://lists.freedesktop.org/archives/dri-devel/2019-November/244090.html
- I have only tested the case that uses r600_irq_init(), but they are all very
  similar.

Cheers,
Sam.

Patch set changelog follows:

Patch set v2: 
Patch 1/2: drm/radeon: fix bad DMA from INTERRUPT_CNTL2
- Split amdgpu changes into separate patch.
Patch 2/2 (new in this version): drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2

Patch set v1:
Patch 1/1: drm/radeon drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2

Sam Bobroff (2):
  drm/radeon: fix bad DMA from INTERRUPT_CNTL2
  drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2

 drivers/gpu/drm/amd/amdgpu/si_ih.c | 3 ++-
 drivers/gpu/drm/radeon/cik.c   | 4 ++--
 drivers/gpu/drm/radeon/r600.c  | 4 ++--
 drivers/gpu/drm/radeon/si.c| 4 ++--
 4 files changed, 8 insertions(+), 7 deletions(-)

-- 
2.22.0.216.g00a2a96fc9

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/1] drm/radeon drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2

2019-11-17 Thread Sam Bobroff
On Fri, Nov 15, 2019 at 09:58:18AM -0500, Alex Deucher wrote:
> On Thu, Nov 14, 2019 at 9:05 PM Sam Bobroff  wrote:
> >
> > The INTERRUPT_CNTL2 register expects a valid DMA address, but is
> > currently set with a GPU MC address.  This can cause problems on
> > systems that detect the resulting DMA read from an invalid address
> > (found on a Power8 guest).
> >
> > Instead, use the DMA address of the dummy page because it will always
> > be safe.
> >
> > Fixes: d8f60cfc9345 ("drm/radeon/kms: Add support for interrupts on 
> > r6xx/r7xx chips (v3)")
> > Fixes: 25a857fbe973 ("drm/radeon/kms: add support for interrupts on SI")
> > Fixes: a59781bbe528 ("drm/radeon: add support for interrupts on CIK (v5)")
> > Fixes: 27ae10641e9c ("drm/amdgpu: add interupt handler implementation for 
> > si v3")
> > Signed-off-by: Sam Bobroff 
> 
> Can you split this into two patches, one for radeon and one for
> amdgpu?  I'll apply them.
> 
> Thanks!
> 
> Alex

No problem at all, I'll post it as v2.

Cheers,
Sam.
> 
> > ---
> > A couple of notes:
> > - Initial discussion:
> >   https://lists.freedesktop.org/archives/dri-devel/2019-November/244090.html
> > - I have only tested the case that uses r600_irq_init(), but they are all 
> > very
> >   similar.
> > - I've included a fixes tag for each change, but I don't know if that's the
> >   right thing to do in this case (please feel free to fix them on commit or
> >   whatever).
> >
> > Cheers,
> > Sam.
> >
> >  drivers/gpu/drm/amd/amdgpu/si_ih.c | 3 ++-
> >  drivers/gpu/drm/radeon/cik.c   | 4 ++--
> >  drivers/gpu/drm/radeon/r600.c  | 4 ++--
> >  drivers/gpu/drm/radeon/si.c| 4 ++--
> >  4 files changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c 
> > b/drivers/gpu/drm/amd/amdgpu/si_ih.c
> > index 57bb5f9e08b2..88ae27a5a03d 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/si_ih.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c
> > @@ -64,7 +64,8 @@ static int si_ih_irq_init(struct amdgpu_device *adev)
> > u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
> >
> > si_ih_disable_interrupts(adev);
> > -   WREG32(INTERRUPT_CNTL2, adev->irq.ih.gpu_addr >> 8);
> > +   /* set dummy read address to dummy page address */
> > +   WREG32(INTERRUPT_CNTL2, adev->dummy_page_addr >> 8);
> > interrupt_cntl = RREG32(INTERRUPT_CNTL);
> > interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE;
> > interrupt_cntl &= ~IH_REQ_NONSNOOP_EN;
> > diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
> > index 62eab82a64f9..897442754fd0 100644
> > --- a/drivers/gpu/drm/radeon/cik.c
> > +++ b/drivers/gpu/drm/radeon/cik.c
> > @@ -6969,8 +6969,8 @@ static int cik_irq_init(struct radeon_device *rdev)
> > }
> >
> > /* setup interrupt control */
> > -   /* XXX this should actually be a bus address, not an MC address. 
> > same on older asics */
> > -   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
> > +   /* set dummy read address to dummy page address */
> > +   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
> > interrupt_cntl = RREG32(INTERRUPT_CNTL);
> > /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
> > without msi
> >  * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
> > diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> > index e937cc01910d..033bc466a862 100644
> > --- a/drivers/gpu/drm/radeon/r600.c
> > +++ b/drivers/gpu/drm/radeon/r600.c
> > @@ -3696,8 +3696,8 @@ int r600_irq_init(struct radeon_device *rdev)
> > }
> >
> > /* setup interrupt control */
> > -   /* set dummy read address to ring address */
> > -   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
> > +   /* set dummy read address to dummy page address */
> > +   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
> > interrupt_cntl = RREG32(INTERRUPT_CNTL);
> > /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
> > without msi
> >  * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
> > diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
> > index 05894d198a79..1d8efb0eefdb 100644
> > --- a/drivers/gpu/drm/radeon/si.c
> > +++ b/drivers/gpu/drm/radeon/si.c
> > @@ -5997,8 +5997,8 @@ static int si_irq_init(struct radeon_device *rdev)
> > }
> >
> > /* setup interrupt control */
> > -   /* set dummy read address to ring address */
> > -   WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
> > +   /* set dummy read address to dummy page address */
> > +   WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
> > interrupt_cntl = RREG32(INTERRUPT_CNTL);
> > /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled 
> > without msi
> >  * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
> > --
> > 2.22.0.216.g00a2a96fc9
> >


signature.asc

[Bug 110795] Unable to install on latest Ubuntu (19.04)

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110795

--- Comment #38 from Utku Helvacı (tuxutku)  ---
I made a script to only install opencl:
https://gist.github.com/tuxutku/79daa2edca131c1525a136b650cdbe0a

its basically re-implementation of opencl-amd AUR package for ubuntu

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 109955] amdgpu [RX Vega 64] system freeze while gaming (VSYNC enabled)

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109955

har...@gmx.de changed:

   What|Removed |Added

Summary|amdgpu [RX Vega 64] system  |amdgpu [RX Vega 64] system
   |freeze while gaming |freeze while gaming (VSYNC
   ||enabled)

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 109955] amdgpu [RX Vega 64] system freeze while gaming

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109955

--- Comment #136 from har...@gmx.de ---
Thank you for testing and reporting back.

I think the crashes are caused by voltage drops, followed by a hardware
failure.
That would explain the many different kernel logs too, because from the drivers
pow, it is randomly.

If vsync is enabled, mclk level is switched at least twice per frame (down/up).
And in some cases i have seen more switches inside a frame. 

I am not sure, if this fast memory clock level switching, multiple times during
a frame really useful? It saves not much power, but makes the system instable,
apparently.

I don't think this is wanted behavior, it looks more like a firmware bug, imo.

Maybe an opensource driver developer can help us to understand?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 109955] amdgpu [RX Vega 64] system freeze while gaming

2019-11-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109955

--- Comment #135 from Rodney A Morris  ---
(In reply to haro41 from comment #127)
> (In reply to Rodney A Morris from comment #126)
> > If you want someone to apply your changes in bug report no. 110777 to the
> > kernel for testing, I can so but will not be to it until this weekend. 
>  
> ... thanks for you reply. Yes, that was the idea and would be very nice...
> 
> Since i thing the proposed fix is more relevant to this very thread, let me
> repeat the proposed patch here:
> 
> in 'drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c':
> 
> static void vega10_notify_smc_display_change(struct pp_hwmgr *hwmgr,
> bool has_disp)
> {
>   smum_send_msg_to_smc_with_parameter(hwmgr,
>   PPSMC_MSG_SetUclkFastSwitch,
>   has_disp ? 1 : 0);
> /* proposed fix for crashes because of frequently mclk level 0/1 switching */
>   smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetUclkDownHyst, 
> 1);
> }
> 
> Only module 'amdgpu.ko' needs to be rebuild and copied, like this:
> 
> $ cd /home/user/linux-5.x.x && make -j8 -C . M=drivers/gpu/drm/amd/amdgpu
> 
> # cp /home/user/linux-5.x.x/drivers/gpu/drm/amd/amdgpu/amdgpu.ko
> /lib/modules/5.x.x/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko &&
> update-initramfs -u
> 
> ... 'user' and 'x.x' have to be adapted, most likely ...

I applied the patch and recompiled the kernel with the modified amdgpu driver. 
Unfortunately, the patch did not resolve my issues.  I experienced a crash with
the same symptoms as before within 20 minutes of playing Battletech and within
40 minutes of playing Stellaris.  Again, limiting the HMB memory clock to
levels 1,2, and 3 prevents the system from crashing, indicating that something
with the switching of the memory clock between level 0 and 1, 2, and 3 are
causing the crash.

Interestingly, the debug output indicates a possible problem in
amdgpu/../display/dc/dc_helper.c at, I am guessing, line 332.  If I have time
later this week, I may take a look at the code in that file.  Here are the
pertinent details from the Stellaris crash.

Distro:  Fedora
Kernel:  5.3.11

dmesg crash output:

[19792.781681] [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx timeout,
signaled seq=3875204, emitted seq=3875205
[19792.781727] [drm:amdgpu_job_timedout [amdgpu]] *ERROR* Process information:
process stellaris pid 13309 thread stellaris:cs0 pid 13310
[19792.781731] amdgpu :06:00.0: GPU reset begin!
[19792.798997] pcieport :00:03.0: AER: Uncorrected (Non-Fatal) error
received: :00:03.0
[19792.799004] pcieport :00:03.0: AER: PCIe Bus Error: severity=Uncorrected
(Non-Fatal), type=Transaction Layer, (Requester ID)
[19792.799006] pcieport :00:03.0: AER:   device [8086:6f08] error
status/mask=4000/
[19792.799007] pcieport :00:03.0: AER:[14] CmpltTO   
(First)
[19792.84] pcieport :00:03.0: AER: Device recovery failed
[19794.419525] amdgpu: [powerplay] No response from smu
[19794.419542] amdgpu: [powerplay] Failed message: 0xe, input parameter: 0x0,
error code: 0x0
[19796.043441] amdgpu: [powerplay] No response from smu
[19797.665903] amdgpu: [powerplay] No response from smu
[19797.665907] amdgpu: [powerplay] Failed message: 0x42, input parameter: 0x1,
error code: 0x0
[19799.287749] amdgpu: [powerplay] No response from smu
[19800.910845] amdgpu: [powerplay] No response from smu
[19800.910850] amdgpu: [powerplay] Failed message: 0x24, input parameter: 0x0,
error code: 0x0
[19800.977846] [drm] REG_WAIT timeout 10us * 3500 tries - dce_mi_free_dmif
line:634
[19800.977855] [ cut here ]
[19800.977967] WARNING: CPU: 10 PID: 15123 at
drivers/gpu/drm/amd/amdgpu/../display/dc/dc_helper.c:332
generic_reg_wait.cold+0x31/0x53 [amdgpu]
[19800.977968] Modules linked in: rfcomm xt_CHECKSUM xt_MASQUERADE nf_nat_tftp
nf_conntrack_tftp tun bridge stp llc nf_conntrack_netbios_ns
nf_conntrack_broadcast xt_CT ip6t_REJECT nf_reject_ipv6 ip6t_rpfilter
ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute ip6table_nat
ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_nat
iptable_mangle iptable_raw iptable_security nf_conntrack nf_defrag_ipv6
nf_defrag_ipv4 libcrc32c ip_set nfnetlink ebtable_filter ebtables
ip6table_filter ip6_tables iptable_filter cmac bnep nct6775 hwmon_vid vfat fat
intel_rapl_msr intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
kvm_intel kvm iTCO_wdt iTCO_vendor_support irqbypass iwlmvm crct10dif_pclmul
snd_hda_codec_realtek crc32_pclmul snd_hda_codec_generic ledtrig_audio
snd_hda_codec_hdmi ghash_clmulni_intel mac80211 snd_hda_intel intel_cstate
snd_hda_codec libarc4 intel_uncore snd_hda_core btusb snd_hwdep btrtl
intel_rapl_perf btbcm iwlwifi snd_seq btintel snd_seq_device
[19800.977994]  bluetooth joydev mxm_wmi snd_pcm cfg80211 snd_timer
ecdh_generic ecc rfkill snd mei_me soundcore i2c_i801 

Re: [PATCH v7 0/2] drm: bridge: Add NWL MIPI DSI host controller support

2019-11-17 Thread Guido Günther
Hi,
On Sat, Oct 19, 2019 at 04:12:23PM +0200, Guido Günther wrote:
> This adds initial support for the NWL MIPI DSI Host controller found on i.MX8
> SoCs.

Is there anything i can do to move this forward? As far as i can tell
all review comments should be addressed.
Cheers,
 -- Guido

> 
> It adds support for the i.MX8MQ but the same IP core can also be found on e.g.
> i.MX8QXP. I added the necessary hooks to support other imx8 variants but since
> I only have imx8mq boards to test I omitted the platform data for other SoCs.
> 
> The code is based on NXPs BSP so I added Robert Chiras as
> Co-authored-by.
> 
> The most notable changes over the BSP driver are
>  - Calculate HS mode timing from phy_configure_opts_mipi_dphy
>  - Perform all clock setup via DT
>  - Merge nwl-imx and nwl drivers
>  - Add B0 silion revision quirk
>  - become a bridge driver to hook into mxsfb / dcss
>imx-display-subsystem so it makes sense to make it drive a bridge for dsi 
> as
>well).
>  - Use panel_bridge to attach the panel
>  - Use multiplex framework instead of accessing syscon directly
> 
> This has been tested on a Librem 5 devkit using mxsfb with Robert's patches[1]
> and the rocktech-jh057n00900 panel driver on next-20191018. The DCSS can later
> on also act as input source too.
> 
> Changes from v7:
> - Per review comments by Andrzej Hajda
>   
> https://lore.kernel.org/linux-arm-kernel/c86b7ca2-7799-eafd-c380-e4b551520...@samsung.com/
>   - Drop spare empty line
>   - handle nwl_dsi_write errors
>   - better handle read errors
>   - unwind in case of error in nwl_dsi_enable
>   - use bridge_to_dsi() instead of accessing driver_private
>   - don't log on -EPROBEDEFER when fething the reset controller
>   - use endpoint number to determine input
> - Spotted by kbuild test robot 
>   
> https://lore.kernel.org/linux-arm-kernel/201909230644.qfskbnf9%25...@intel.com/
>   Use signed return type for nwl_dsi_get_dpi_pixel_format
> - Drop connector type from drm_panel_bridge_add
> - Don't forget to set an error value on dsi reads
> 
> Changes from v5:
> - Per review comments by Andrzej Hajda
>   https://lists.freedesktop.org/archives/dri-devel/2019-September/235281.html
>   - Fix include file ordering
>   - Add a comment to nwl_dsi_platform_data that will allow to add support
> at least for the i.MX8QM
>   - Merge driver into a single file plus the register defs in a separate 
> header
> - Make more functions and structs static
> 
> Changes from v4:
> - Collect Reviewed-by: from Rob Herring, thanks!
>   https://lists.freedesktop.org/archives/dri-devel/2019-September/233979.html
> - Spotted by kbuild test robot 
>   https://lists.freedesktop.org/archives/dri-devel/2019-September/233860.html
>   https://lists.freedesktop.org/archives/dri-devel/2019-September/233863.html
>   - fix format string for size_t
>   - Use DIV64_U64_ROUND_UP to fix build on 32 bit architectures
> We can't use simple shift sind d and n are similar in size and
> we need full precision
> - Fix debug cfg_t_post debug print out
> - Avoid PSEC_PER_SEC
> - Move timeout / overflow handling out of nwl_dsi_finish_transmission,
>   it would never end up being reported since the call to the function
>   was guarded by flags.
> - Drop 'support for' from KConfig title to make it match the other
>   drivers in that submenu
> 
> Changes from v3:
> - Per review comments by Robert Chiras
>   https://lists.freedesktop.org/archives/dri-devel/2019-August/232580.html
>   - Add Robert's {Signed-off,Tested}-by:
>   - Respect number of lanes when calculting bandwidth limits
>   - Drop duplicate NWL_DSI_ENABLE_MULT_PKTS setup
> - Per testing by Rober Chiras
>   https://lists.freedesktop.org/archives/dri-devel/2019-August/233688.html
>   - Drop duplicate (and too early) drm_bridge_add() in nwl_dir_probe() that
> made mxsfb fail to connect to the bridge since the panel_bridge was not up
> yet. drm_bridge_add() happens in nwl_dsi_host_attach() where after the
> panel_bridge was set up.
> - Per review comments by Rob Herring on bindings
>   https://lists.freedesktop.org/archives/dri-devel/2019-August/233196.html
>   - drop description from power-domains and resets
>   - allow BSD 2 clause license as well
>   - make ports more specific
>   - add #address-cells, #size-cells as required
>   - use additionalProperties
>   - panel is of type object
> 
> Changes from v2:
> - Per review comments by Rob Herring
>   https://lists.freedesktop.org/archives/dri-devel/2019-August/230448.html
>   - bindings:
> - Simplify by restricting to fsl,imx8mq-nwl-dsi
> - document reset lines
> - add port@{0,1}
> - use a real compatible string for the panel
> - resets are required
> - Per review comments by Arnd Bergmann
>   https://lists.freedesktop.org/archives/dri-devel/2019-August/230868.html
>   - Don't access iomuxc_gpr regs directly. This allows us to drop the
> first patch in the series with the iomuxc_gpr field defines.
> - Per review comments 

[PATCH 2/3] drm/gma500: remove set but not used variable 'error'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/gma500/psb_irq.c: In function psb_sgx_interrupt:
drivers/gpu/drm/gma500/psb_irq.c:210:6: warning: variable error set but not 
used [-Wunused-but-set-variable]

It is introduced by commit 64a4aff283ac ("drm/gma500:
Add support for SGX interrupts"), but never used, so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/gma500/psb_irq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index e6265fb..dc6a73a 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -194,7 +194,6 @@ static void psb_sgx_interrupt(struct drm_device *dev, u32 
stat_1, u32 stat_2)
 {
struct drm_psb_private *dev_priv = dev->dev_private;
u32 val, addr;
-   int error = false;

if (stat_1 & _PSB_CE_TWOD_COMPLETE)
val = PSB_RSGX32(PSB_CR_2D_BLIT_STATUS);
@@ -229,7 +228,6 @@ static void psb_sgx_interrupt(struct drm_device *dev, u32 
stat_1, u32 stat_2)

DRM_ERROR("\tMMU failing address is 0x%08x.\n",
  (unsigned int)addr);
-   error = true;
}
}

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 42/42] drm/panel: Move OMAP's DSI command mode panel driver

2019-11-17 Thread Sebastian Reichel
The panel driver is no longer using any OMAP specific APIs, so
let's move it into the generic panel directory.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/Kconfig | 6 --
 drivers/gpu/drm/omapdrm/displays/Makefile| 1 -
 drivers/gpu/drm/panel/Kconfig| 9 +
 drivers/gpu/drm/panel/Makefile   | 1 +
 .../gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c   | 0
 5 files changed, 10 insertions(+), 7 deletions(-)
 rename drivers/gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c (100%)

diff --git a/drivers/gpu/drm/omapdrm/displays/Kconfig 
b/drivers/gpu/drm/omapdrm/displays/Kconfig
index 240dda102845..1175811a55ac 100644
--- a/drivers/gpu/drm/omapdrm/displays/Kconfig
+++ b/drivers/gpu/drm/omapdrm/displays/Kconfig
@@ -23,10 +23,4 @@ config DRM_OMAP_CONNECTOR_ANALOG_TV
help
  Driver for a generic analog TV connector.
 
-config DRM_OMAP_PANEL_DSI_CM
-   tristate "Generic DSI Command Mode Panel"
-   depends on BACKLIGHT_CLASS_DEVICE
-   help
- Driver for generic DSI command mode panels.
-
 endmenu
diff --git a/drivers/gpu/drm/omapdrm/displays/Makefile 
b/drivers/gpu/drm/omapdrm/displays/Makefile
index cb76859dc574..68ff8b1d051a 100644
--- a/drivers/gpu/drm/omapdrm/displays/Makefile
+++ b/drivers/gpu/drm/omapdrm/displays/Makefile
@@ -3,4 +3,3 @@ obj-$(CONFIG_DRM_OMAP_ENCODER_OPA362) += encoder-opa362.o
 obj-$(CONFIG_DRM_OMAP_ENCODER_TPD12S015) += encoder-tpd12s015.o
 obj-$(CONFIG_DRM_OMAP_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DRM_OMAP_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
-obj-$(CONFIG_DRM_OMAP_PANEL_DSI_CM) += panel-dsi-cm.o
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index f152bc4eeb53..91520907d3c6 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -39,6 +39,15 @@ config DRM_PANEL_SIMPLE
  that it can be automatically turned off when the panel goes into a
  low power state.
 
+config DRM_PANEL_DSI_CM
+   tristate "support for generic DSI command mode panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ DRM panel driver for DSI command mode panels with support for
+ embedded and external backlights.
+
 config DRM_PANEL_FEIYANG_FY07024DI26A30D
tristate "Feiyang FY07024DI26A30-D MIPI-DSI LCD panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index b6cd39fe0f20..2afed2ae171c 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
+obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += 
panel-feiyang-fy07024di26a30d.o
 obj-$(CONFIG_DRM_PANEL_ILITEK_IL9322) += panel-ilitek-ili9322.o
 obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9881C) += panel-ilitek-ili9881c.o
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
similarity index 100%
rename from drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
rename to drivers/gpu/drm/panel/panel-dsi-cm.c
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 1/6] drm/radeon: remove set but not used variable 'size', 'relocs_chunk'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/r600_cs.c: In function r600_cs_track_validate_cb:
drivers/gpu/drm/radeon/r600_cs.c:353:22: warning: variable size set but not 
used [-Wunused-but-set-variable]
drivers/gpu/drm/radeon/r600_cs.c: In function r600_cs_track_validate_db:
drivers/gpu/drm/radeon/r600_cs.c:520:27: warning: variable size set but not 
used [-Wunused-but-set-variable]
drivers/gpu/drm/radeon/r600_cs.c: In function r600_dma_cs_next_reloc:
drivers/gpu/drm/radeon/r600_cs.c:2345:26: warning: variable relocs_chunk set 
but not used [-Wunused-but-set-variable]

The first 'size' is not used since commit f30df2fad0c9 ("drm/radeon/r600:
fix tiling issues in CS checker.")

The second 'size' is introduced by commit 88f50c80748b ("drm/radeon/kms:
add htile support to the cs checker v3"), but never used, so remove it.

'relocs_chunk' is not used since commit 9305ede6afe2 ("radeon/kms:
fix dma relocation checking")

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/r600_cs.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index d6c28a5..49e8266 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -350,7 +350,7 @@ static void r600_cs_track_init(struct r600_cs_track *track)
 static int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
 {
struct r600_cs_track *track = p->track;
-   u32 slice_tile_max, size, tmp;
+   u32 slice_tile_max, tmp;
u32 height, height_align, pitch, pitch_align, depth_align;
u64 base_offset, base_align;
struct array_mode_checker array_check;
@@ -360,7 +360,6 @@ static int r600_cs_track_validate_cb(struct 
radeon_cs_parser *p, int i)
/* When resolve is used, the second colorbuffer has always 1 sample. */
unsigned nsamples = track->is_resolve && i == 1 ? 1 : track->nsamples;

-   size = radeon_bo_size(track->cb_color_bo[i]) - 
track->cb_color_bo_offset[i];
format = G_0280A0_FORMAT(track->cb_color_info[i]);
if (!r600_fmt_is_valid_color(format)) {
dev_warn(p->dev, "%s:%d cb invalid format %d for %d (0x%08X)\n",
@@ -517,7 +516,7 @@ static int r600_cs_track_validate_cb(struct 
radeon_cs_parser *p, int i)
 static int r600_cs_track_validate_db(struct radeon_cs_parser *p)
 {
struct r600_cs_track *track = p->track;
-   u32 nviews, bpe, ntiles, size, slice_tile_max, tmp;
+   u32 nviews, bpe, ntiles, slice_tile_max, tmp;
u32 height_align, pitch_align, depth_align;
u32 pitch = 8192;
u32 height = 8192;
@@ -564,7 +563,6 @@ static int r600_cs_track_validate_db(struct 
radeon_cs_parser *p)
}
ib[track->db_depth_size_idx] = S_028000_SLICE_TILE_MAX(tmp - 1) 
| (track->db_depth_size & 0x3FF);
} else {
-   size = radeon_bo_size(track->db_bo);
/* pitch in pixels */
pitch = (G_028000_PITCH_TILE_MAX(track->db_depth_size) + 1) * 8;
slice_tile_max = G_028000_SLICE_TILE_MAX(track->db_depth_size) 
+ 1;
@@ -2342,7 +2340,6 @@ int r600_cs_parse(struct radeon_cs_parser *p)
 int r600_dma_cs_next_reloc(struct radeon_cs_parser *p,
   struct radeon_bo_list **cs_reloc)
 {
-   struct radeon_cs_chunk *relocs_chunk;
unsigned idx;

*cs_reloc = NULL;
@@ -2350,7 +2347,6 @@ int r600_dma_cs_next_reloc(struct radeon_cs_parser *p,
DRM_ERROR("No relocation chunk !\n");
return -EINVAL;
}
-   relocs_chunk = p->chunk_relocs;
idx = p->dma_reloc_idx;
if (idx >= p->nrelocs) {
DRM_ERROR("Relocs at %d after relocations chunk end %d !\n",
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 29/42] drm/omap: dsi: do ULPS in host driver

2019-11-17 Thread Sebastian Reichel
Move ULPS handling into the DSI host controller, so that we
no longer need a custom API for the DSI client.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 273 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  61 +++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   2 -
 3 files changed, 62 insertions(+), 274 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index f73b8f489f82..56398e2aec2d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -16,7 +16,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -69,21 +68,13 @@ struct panel_drv_data {
 
bool intro_printed;
 
-   struct workqueue_struct *workqueue;
-
bool ulps_enabled;
-   unsigned int ulps_timeout;
-   struct delayed_work ulps_work;
 };
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
-static int dsicm_panel_reset(struct panel_drv_data *ddata);
-
-static void dsicm_ulps_work(struct work_struct *work);
-
 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
 {
struct backlight_device *backlight;
@@ -207,94 +198,6 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
return 0;
 }
 
-static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
-{
-   if (ddata->ulps_timeout > 0)
-   queue_delayed_work(ddata->workqueue, >ulps_work,
-   msecs_to_jiffies(ddata->ulps_timeout));
-}
-
-static void dsicm_cancel_ulps_work(struct panel_drv_data *ddata)
-{
-   cancel_delayed_work(>ulps_work);
-}
-
-static int dsicm_enter_ulps(struct panel_drv_data *ddata)
-{
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   if (ddata->ulps_enabled)
-   return 0;
-
-   dsicm_cancel_ulps_work(ddata);
-
-   r = _dsicm_enable_te(ddata, false);
-   if (r)
-   goto err;
-
-   src->ops->dsi.ulps(src, true);
-
-   ddata->ulps_enabled = true;
-
-   return 0;
-
-err:
-   dev_err(>dsi->dev, "enter ULPS failed");
-   dsicm_panel_reset(ddata);
-
-   ddata->ulps_enabled = false;
-
-   dsicm_queue_ulps_work(ddata);
-
-   return r;
-}
-
-static int dsicm_exit_ulps(struct panel_drv_data *ddata)
-{
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   if (!ddata->ulps_enabled)
-   return 0;
-
-   src->ops->dsi.ulps(src, false);
-   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
-
-   r = _dsicm_enable_te(ddata, ddata->te_enabled);
-   if (r) {
-   dev_err(>dsi->dev, "failed to re-enable TE");
-   goto err2;
-   }
-
-   dsicm_queue_ulps_work(ddata);
-
-   ddata->ulps_enabled = false;
-
-   return 0;
-
-err2:
-   dev_err(>dsi->dev, "failed to exit ULPS");
-
-   r = dsicm_panel_reset(ddata);
-   if (!r)
-   ddata->ulps_enabled = false;
-
-   dsicm_queue_ulps_work(ddata);
-
-   return r;
-}
-
-static int dsicm_wake_up(struct panel_drv_data *ddata)
-{
-   if (ddata->ulps_enabled)
-   return dsicm_exit_ulps(ddata);
-
-   dsicm_cancel_ulps_work(ddata);
-   dsicm_queue_ulps_work(ddata);
-   return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(>dev);
@@ -312,11 +215,8 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(>lock);
 
if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (!r) {
-   r = dsicm_dcs_write_1(ddata,
-   MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
-   }
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+ level);
}
 
mutex_unlock(>lock);
@@ -343,18 +243,12 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
u8 errors = 0;
-   int r;
+   int r = -ENODEV;
 
mutex_lock(>lock);
 
-   if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (!r)
-   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
-   );
-   } else {
-   r = -ENODEV;
-   }
+   if (ddata->enabled)
+   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, );
 
mutex_unlock(>lock);
 
@@ -369,17 +263,12 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
u8 id1, id2, id3;
-   int r;
+   int r = -ENODEV;
 
mutex_lock(>lock);
 
-   if 

[RFCv1 36/42] drm/omap: panel-dsi-cm: support unbinding

2019-11-17 Thread Sebastian Reichel
Now, that the driver implements the common DRM panel API
the unbind no longer needs to be suppressed.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 0148f40eceb2..f607b3dfa31f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -598,7 +598,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
return r;
 }
 
-static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
+static int dsicm_remove(struct mipi_dsi_device *dsi)
 {
struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 
@@ -628,11 +628,10 @@ MODULE_DEVICE_TABLE(of, dsicm_of_match);
 
 static struct mipi_dsi_driver dsicm_driver = {
.probe = dsicm_probe,
-   .remove = __exit_p(dsicm_remove),
+   .remove = dsicm_remove,
.driver = {
.name = "panel-dsi-cm",
.of_match_table = dsicm_of_match,
-   .suppress_bind_attrs = true,
},
 };
 module_mipi_dsi_driver(dsicm_driver);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 23/42] drm/omap: dsi: lp/hs switching support for transfer()

2019-11-17 Thread Sebastian Reichel
Integrate low-power / high-speed bus switching into transfer
function and drop the omapdrm specific enable_hs() callback.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  6 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 13 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  2 --
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 170cbc78fbef..5603dae0fd0f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -269,7 +269,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0;
 
src->ops->enable(src);
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
r = _dsicm_enable_te(ddata, true);
if (r) {
@@ -574,7 +574,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
+   ddata->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
r = dsicm_sleep_out(ddata);
if (r)
@@ -617,7 +617,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
ddata->intro_printed = true;
}
 
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
return 0;
 err:
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 32271870e74c..8eb323adb30a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -45,6 +45,9 @@ struct dsi_reg { u16 module; u16 idx; };
 
 #define DSI_REG(mod, idx)  ((const struct dsi_reg) { mod, idx })
 
+/* returns true iff both arguments logically differs */
+#define NEQV(a, b) (!(a) ^ !(b))
+
 /* DSI Protocol Engine */
 
 #define DSI_PROTO  0
@@ -329,6 +332,7 @@ struct dsi_data {
int irq;
 
bool is_enabled;
+   bool in_lp_mode;
 
struct clk *dss_clk;
struct regmap *syscon;
@@ -2431,6 +2435,8 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int channel,
/* start the DDR clock by sending a NULL packet */
if (dsi->vm_timings.ddr_clk_always_on && enable)
dsi_vc_send_null(dsi, channel);
+
+   dsi->in_lp_mode = !enable;
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
@@ -4697,6 +4703,11 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
struct dsi_data *dsi = host_to_omap(host);
struct omap_dss_device *dssdev = >output;
 
+   if (NEQV(msg->flags & MIPI_DSI_MSG_USE_LPM, dsi->in_lp_mode)) {
+   dsi_vc_enable_hs(dssdev, msg->channel,
+!(msg->flags & MIPI_DSI_MSG_USE_LPM));
+   }
+
switch (msg->type) {
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
@@ -4757,8 +4768,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
.disable = dsi_display_disable,
 
-   .enable_hs = dsi_vc_enable_hs,
-
.set_config = dsi_set_config,
 
.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index cd9769711b58..5bcc14d9f737 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -294,8 +294,6 @@ struct omapdss_dsi_ops {
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
 
-   void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
-   bool enable);
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 
int (*update)(struct omap_dss_device *dssdev, int channel,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/amd/powerplay: remove variable 'result' set but not used

2019-11-17 Thread Chen Wandun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c: In function 
vegam_populate_smc_boot_level:
drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c:1364:6: warning: 
variable result set but not used [-Wunused-but-set-variable]

Signed-off-by: Chen Wandun 
---
 drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
index 2068eb0..fad78bf 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
@@ -1361,20 +1361,19 @@ static int vegam_populate_smc_uvd_level(struct pp_hwmgr 
*hwmgr,
 static int vegam_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
struct SMU75_Discrete_DpmTable *table)
 {
-   int result = 0;
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
 
table->GraphicsBootLevel = 0;
table->MemoryBootLevel = 0;
 
/* find boot level from dpm table */
-   result = phm_find_boot_level(&(data->dpm_table.sclk_table),
-   data->vbios_boot_state.sclk_bootup_value,
-   (uint32_t *)&(table->GraphicsBootLevel));
+   phm_find_boot_level(&(data->dpm_table.sclk_table),
+   data->vbios_boot_state.sclk_bootup_value,
+   (uint32_t *)&(table->GraphicsBootLevel));
 
-   result = phm_find_boot_level(&(data->dpm_table.mclk_table),
-   data->vbios_boot_state.mclk_bootup_value,
-   (uint32_t *)&(table->MemoryBootLevel));
+   phm_find_boot_level(&(data->dpm_table.mclk_table),
+   data->vbios_boot_state.mclk_bootup_value,
+   (uint32_t *)&(table->MemoryBootLevel));
 
table->BootVddc  = data->vbios_boot_state.vddc_bootup_value *
VOLTAGE_SCALE;
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] video: fbdev: arcfb: add missed free_irq

2019-11-17 Thread Chuhong Yuan
The driver forgets to free irq in remove which is requested in
probe.
Add the missed call to fix it.

Signed-off-by: Chuhong Yuan 
---
 drivers/video/fbdev/arcfb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
index a48741aab240..7aed01f001a4 100644
--- a/drivers/video/fbdev/arcfb.c
+++ b/drivers/video/fbdev/arcfb.c
@@ -590,8 +590,11 @@ static int arcfb_probe(struct platform_device *dev)
 static int arcfb_remove(struct platform_device *dev)
 {
struct fb_info *info = platform_get_drvdata(dev);
+   struct arcfb_par *par = info->par;
 
if (info) {
+   if (irq)
+   free_irq(par->irq, info);
unregister_framebuffer(info);
vfree((void __force *)info->screen_base);
framebuffer_release(info);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 38/42] drm/omap: panel-dsi-cm: do not power on/off twice

2019-11-17 Thread Sebastian Reichel
Make sure, that we only power on/off the device once.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 90132d1d1f5d..7f6b1129862a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -290,6 +290,9 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
u8 id1, id2, id3;
int r;
 
+   if (ddata->enabled)
+   return 0;
+
r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r) {
dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
@@ -354,6 +357,9 @@ static int dsicm_power_off(struct panel_drv_data *ddata)
 {
int r;
 
+   if (!ddata->enabled)
+   return 0;
+
ddata->enabled = 0;
 
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 18/42] drm/omap: dsi: drop unused get_te()

2019-11-17 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 13 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index e309a556c700..b2eb834c9eff 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -919,18 +919,6 @@ static int dsicm_enable_te(struct omap_dss_device *dssdev, 
bool enable)
return r;
 }
 
-static int dsicm_get_te(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   int r;
-
-   mutex_lock(>lock);
-   r = ddata->te_enabled;
-   mutex_unlock(>lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1002,7 +990,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
.sync   = dsicm_sync,
 
.enable_te  = dsicm_enable_te,
-   .get_te = dsicm_get_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 742088b8f570..9be1c659d3a4 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -412,7 +412,6 @@ struct omap_dss_driver {
int (*sync)(struct omap_dss_device *dssdev);
 
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-   int (*get_te)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 3/6] drm/radeon: remove set but not used variable 'dig_connector'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/atombios_dp.c: In function radeon_dp_get_panel_mode:
drivers/gpu/drm/radeon/atombios_dp.c:415:36: warning: variable dig_connector 
set but not used [-Wunused-but-set-variable]

It is not used since commit 379dfc25e257 ("drm/radeon/dp:
switch to the common i2c over aux code")

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/atombios_dp.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_dp.c 
b/drivers/gpu/drm/radeon/atombios_dp.c
index 6f38375..911735f 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -412,7 +412,6 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
struct drm_device *dev = encoder->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_connector *radeon_connector = 
to_radeon_connector(connector);
-   struct radeon_connector_atom_dig *dig_connector;
int panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
u16 dp_bridge = 
radeon_connector_encoder_get_dp_bridge_encoder_id(connector);
u8 tmp;
@@ -423,8 +422,6 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
if (!radeon_connector->con_priv)
return panel_mode;

-   dig_connector = radeon_connector->con_priv;
-
if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
/* DP bridge chips */
if (drm_dp_dpcd_readb(_connector->ddc_bus->aux,
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 34/42] drm/omap: dsi: implement check timings

2019-11-17 Thread Sebastian Reichel
Implement check timings, which will check if its possible to
configure the clocks for the provided mode using the same code
as the set_config() hook.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 70 +++
 1 file changed, 44 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 754815068927..1b57f516618a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -283,6 +283,11 @@ struct dsi_isr_tables {
struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
 };
 
+struct dsi_lp_clock_info {
+   unsigned long lp_clk;
+   u16 lp_clk_div;
+};
+
 struct dsi_clk_calc_ctx {
struct dsi_data *dsi;
struct dss_pll *pll;
@@ -297,16 +302,12 @@ struct dsi_clk_calc_ctx {
 
struct dss_pll_clock_info dsi_cinfo;
struct dispc_clock_info dispc_cinfo;
+   struct dsi_lp_clock_info user_lp_cinfo;
 
struct videomode vm;
struct omap_dss_dsi_videomode_timings dsi_vm;
 };
 
-struct dsi_lp_clock_info {
-   unsigned long lp_clk;
-   u16 lp_clk_div;
-};
-
 struct dsi_module_id_data {
u32 address;
int id;
@@ -4794,44 +4795,55 @@ static bool dsi_is_video_mode(struct omap_dss_device 
*dssdev)
return (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE);
 }
 
-static int dsi_set_config(struct omap_dss_device *dssdev,
-   const struct drm_display_mode *mode)
+static int __dsi_calc_config(struct dsi_data *dsi,
+   const struct drm_display_mode *mode,
+   struct dsi_clk_calc_ctx *ctx)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   struct dsi_clk_calc_ctx ctx;
-   struct videomode vm;
struct omap_dss_dsi_config cfg = dsi->config;
+   struct videomode vm;
bool ok;
int r;
 
drm_display_mode_to_videomode(mode, );
-   cfg.vm = 
-
-   mutex_lock(>lock);
 
+   cfg.vm = 
cfg.mode = dsi->mode;
cfg.pixel_format = dsi->pix_fmt;
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
-   ok = dsi_vm_calc(dsi, , );
+   ok = dsi_vm_calc(dsi, , ctx);
else
-   ok = dsi_cm_calc(dsi, , );
+   ok = dsi_cm_calc(dsi, , ctx);
 
-   if (!ok) {
-   DSSERR("failed to find suitable DSI clock settings\n");
-   r = -EINVAL;
-   goto err;
-   }
+   if (!ok)
+   return -EINVAL;
+
+   dsi_pll_calc_dsi_fck(dsi, >dsi_cinfo);
 
-   dsi_pll_calc_dsi_fck(dsi, _cinfo);
+   r = dsi_lp_clock_calc(ctx->dsi_cinfo.clkout[HSDIV_DSI],
+   cfg.lp_clk_min, cfg.lp_clk_max, >user_lp_cinfo);
+   if (r)
+   return r;
+
+   return 0;
+}
 
-   r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-   cfg.lp_clk_min, cfg.lp_clk_max, >user_lp_cinfo);
+static int dsi_set_config(struct omap_dss_device *dssdev,
+   const struct drm_display_mode *mode)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct dsi_clk_calc_ctx ctx;
+   int r;
+
+   mutex_lock(>lock);
+
+   r = __dsi_calc_config(dsi, mode, );
if (r) {
-   DSSERR("failed to find suitable DSI LP clock settings\n");
+   DSSERR("failed to find suitable DSI clock settings\n");
goto err;
}
 
+   dsi->user_lp_cinfo = ctx.user_lp_cinfo;
dsi->user_dsi_cinfo = ctx.dsi_cinfo;
dsi->user_dispc_cinfo = ctx.dispc_cinfo;
 
@@ -5008,11 +5020,17 @@ static void dsi_set_timings(struct omap_dss_device 
*dssdev,
 static int dsi_check_timings(struct omap_dss_device *dssdev,
 struct drm_display_mode *mode)
 {
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct dsi_clk_calc_ctx ctx;
+   int r;
+
DSSDBG("dsi_check_timings\n");
 
-   /* TODO */
+   mutex_lock(>lock);
+   r = __dsi_calc_config(dsi, mode, );
+   mutex_unlock(>lock);
 
-   return 0;
+   return r;
 }
 
 static int dsi_connect(struct omap_dss_device *src,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 0/3] drm/gma500: remove some set but not used variables

2019-11-17 Thread zhengbin
zhengbin (3):
  drm/gma500: remove set but not used variable 'htotal'
  drm/gma500: remove set but not used variable 'error'
  drm/gma500: remove set but not used variable 'is_hdmi','is_crt'

 drivers/gpu/drm/gma500/cdv_intel_display.c | 7 ++-
 drivers/gpu/drm/gma500/oaktrail_hdmi.c | 4 +---
 drivers/gpu/drm/gma500/psb_irq.c   | 2 --
 3 files changed, 3 insertions(+), 10 deletions(-)

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 4/6] drm/radeon: remove set but not used variable 'radeon_connector'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/radeon_display.c: In function 
radeon_crtc_scaling_mode_fixup:
drivers/gpu/drm/radeon/radeon_display.c:1685:27: warning: variable 
radeon_connector set but not used [-Wunused-but-set-variable]

It is not used since commit 377bd8a98d7d ("drm/radeon:
use a fetch function to get the edid")

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/radeon_display.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index e81b01f..84d3d885 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1687,7 +1687,6 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct radeon_encoder *radeon_encoder;
struct drm_connector *connector;
-   struct radeon_connector *radeon_connector;
bool first = true;
u32 src_v = 1, dst_v = 1;
u32 src_h = 1, dst_h = 1;
@@ -1700,7 +1699,6 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
continue;
radeon_encoder = to_radeon_encoder(encoder);
connector = radeon_get_connector_for_encoder(encoder);
-   radeon_connector = to_radeon_connector(connector);

if (first) {
/* set scaling */
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 33/42] drm/omap: dsi: use atomic helper for dirtyfb

2019-11-17 Thread Sebastian Reichel
We can simply use the atomic helper for
handling the dirtyfb callback.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c |  6 +-
 drivers/gpu/drm/omapdrm/omap_crtc.h |  1 -
 drivers/gpu/drm/omapdrm/omap_fb.c   | 21 ++---
 3 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 80ed1b15ba49..2129cba7f4e2 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -346,13 +346,9 @@ void omap_crtc_framedone_irq(struct drm_crtc *crtc, 
uint32_t irqstatus)
wake_up(_crtc->pending_wait);
 }
 
-void omap_crtc_flush(struct drm_crtc *crtc)
+static void omap_crtc_flush(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-   struct omap_crtc_state *omap_state = to_omap_crtc_state(crtc->state);
-
-   if (!omap_state->manually_updated)
-   return;
 
if (!delayed_work_pending(_crtc->update_work))
schedule_delayed_work(_crtc->update_work, 0);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h 
b/drivers/gpu/drm/omapdrm/omap_crtc.h
index 2fd57751ae2b..fe88f78f9711 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.h
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -31,6 +31,5 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc);
 void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
 void omap_crtc_framedone_irq(struct drm_crtc *crtc, uint32_t irqstatus);
-void omap_crtc_flush(struct drm_crtc *crtc);
 
 #endif /* __OMAPDRM_CRTC_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c 
b/drivers/gpu/drm/omapdrm/omap_fb.c
index 9aeab81dfb90..b0e972945252 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "omap_dmm_tiler.h"
 #include "omap_drv.h"
@@ -55,28 +56,10 @@ struct omap_framebuffer {
struct mutex lock;
 };
 
-static int omap_framebuffer_dirty(struct drm_framebuffer *fb,
- struct drm_file *file_priv,
- unsigned flags, unsigned color,
- struct drm_clip_rect *clips,
- unsigned num_clips)
-{
-   struct drm_crtc *crtc;
-
-   drm_modeset_lock_all(fb->dev);
-
-   drm_for_each_crtc(crtc, fb->dev)
-   omap_crtc_flush(crtc);
-
-   drm_modeset_unlock_all(fb->dev);
-
-   return 0;
-}
-
 static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
.create_handle = drm_gem_fb_create_handle,
-   .dirty = omap_framebuffer_dirty,
.destroy = drm_gem_fb_destroy,
+   .dirty = drm_atomic_helper_dirtyfb,
 };
 
 static u32 get_linear_addr(struct drm_framebuffer *fb,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 09/42] drm/omap: dsi: simplify read functions

2019-11-17 Thread Sebastian Reichel
Simplify the read related message handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 109 +-
 1 file changed, 33 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 696727673c6a..c22d438ae2b5 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2741,60 +2741,6 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev,
return 0;
 }
 
-static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
-   u8 dcs_cmd)
-{
-   int r;
-
-   if (dsi->debug_read)
-   DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
-   channel, dcs_cmd);
-
-   r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
-   if (r) {
-   DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
-   " failed\n", channel, dcs_cmd);
-   return r;
-   }
-
-   return 0;
-}
-
-static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-   const u8 *reqdata, int reqlen)
-{
-   u16 data;
-   u8 data_type;
-   int r;
-
-   if (dsi->debug_read)
-   DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n",
-   channel, reqlen);
-
-   if (reqlen == 0) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
-   data = 0;
-   } else if (reqlen == 1) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
-   data = reqdata[0];
-   } else if (reqlen == 2) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
-   data = reqdata[0] | (reqdata[1] << 8);
-   } else {
-   BUG();
-   return -EINVAL;
-   }
-
-   r = dsi_vc_send_short(dsi, channel, data_type, data, 0);
-   if (r) {
-   DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
-   " failed\n", channel, reqlen);
-   return r;
-   }
-
-   return 0;
-}
-
 static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
   int buflen, enum dss_dsi_content_type type)
 {
@@ -2903,61 +2849,75 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, 
int channel, u8 *buf,
return r;
 }
 
-static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 
dcs_cmd,
-   u8 *buf, int buflen)
+static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
+   u8 dcs_cmd = ((u8*) msg->tx_buf)[0];
 
-   r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
+   r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
if (r)
goto err;
 
-   r = dsi_vc_send_bta_sync(dssdev, channel);
+   r = dsi_vc_send_bta_sync(dssdev, msg->channel);
if (r)
goto err;
 
-   r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
+   r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len,
DSS_DSI_CONTENT_DCS);
if (r < 0)
goto err;
 
-   if (r != buflen) {
+   if (r != msg->rx_len) {
r = -EIO;
goto err;
}
 
return 0;
 err:
-   DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd);
+   DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
+   msg->channel, dcs_cmd);
return r;
 }
 
-static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-   const u8 *reqdata, int reqlen, u8 *buf, int buflen)
+static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct mipi_dsi_packet packet;
+   u16 data;
int r;
 
-   r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
+   r = mipi_dsi_create_packet(, msg);
+   if (r < 0)
+   goto err;
+
+   data = packet.header[1] | (packet.header[2] << 8);
+
+   r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
if (r)
-   return r;
+   goto err;
 
-   r = dsi_vc_send_bta_sync(dssdev, channel);
+   r = dsi_vc_send_bta_sync(dssdev, msg->channel);
if (r)
-   return r;
+   goto err;
 
-   r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
+   r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len,
DSS_DSI_CONTENT_GENERIC);
if (r < 0)
-   

[RFCv1 21/42] drm/omap: dsi: use pixel-format and mode from attach

2019-11-17 Thread Sebastian Reichel
In order to reduce the amount of custom functionality, this moves
handling of pixel format and DSI mode from set_config() to dsi
attach.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 --
 drivers/gpu/drm/omapdrm/dss/dsi.c | 20 +--
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 994880022d0c..e4120d484f4c 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -550,8 +550,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
u8 id1, id2, id3;
int r;
struct omap_dss_dsi_config dsi_config = {
-   .mode = OMAP_DSS_DSI_CMD_MODE,
-   .pixel_format = MIPI_DSI_FMT_RGB888,
.vm = >vm,
.hs_clk_min = 15000,
.hs_clk_max = 3,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 3cd749cae15c..32271870e74c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4583,18 +4583,19 @@ static int dsi_set_config(struct omap_dss_device 
*dssdev,
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
struct dsi_clk_calc_ctx ctx;
+   struct omap_dss_dsi_config cfg = *config;
bool ok;
int r;
 
mutex_lock(>lock);
 
-   dsi->pix_fmt = config->pixel_format;
-   dsi->mode = config->mode;
+   cfg.mode = dsi->mode;
+   cfg.pixel_format = dsi->pix_fmt;
 
-   if (config->mode == OMAP_DSS_DSI_VIDEO_MODE)
-   ok = dsi_vm_calc(dsi, config, );
+   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+   ok = dsi_vm_calc(dsi, , );
else
-   ok = dsi_cm_calc(dsi, config, );
+   ok = dsi_cm_calc(dsi, , );
 
if (!ok) {
DSSERR("failed to find suitable DSI clock settings\n");
@@ -4605,7 +4606,7 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
dsi_pll_calc_dsi_fck(dsi, _cinfo);
 
r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-   config->lp_clk_min, config->lp_clk_max, >user_lp_cinfo);
+   cfg.lp_clk_min, cfg.lp_clk_max, >user_lp_cinfo);
if (r) {
DSSERR("failed to find suitable DSI LP clock settings\n");
goto err;
@@ -4784,6 +4785,13 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
}
 
dsi->vc[channel].dest = client;
+
+   dsi->pix_fmt = client->format;
+   if (client->mode_flags & MIPI_DSI_MODE_VIDEO)
+   dsi->mode = OMAP_DSS_DSI_VIDEO_MODE;
+   else
+   dsi->mode = OMAP_DSS_DSI_CMD_MODE;
+
return 0;
 }
 
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 39/42] drm/omap: dsi: return proper error code from dsi_update_all()

2019-11-17 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1b57f516618a..bc96f74f1740 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3987,7 +3987,7 @@ static int dsi_update_all(struct omap_dss_device *dssdev)
return r;
}
 
-   return 0;
+   return r;
 }
 
 /* Display funcs */
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 07/42] drm/omap: dsi: drop virtual channel logic

2019-11-17 Thread Sebastian Reichel
This drops the virtual channel logic. Afterwards DSI clients
request their channel number and get the virtual channel with
the same number or -EBUSY if already in use.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 11 ++---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 46 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 +-
 3 files changed, 12 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 05974059f231..b505bfd221fc 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -769,19 +769,12 @@ static int dsicm_connect(struct omap_dss_device *src,
struct device *dev = >pdev->dev;
int r;
 
-   r = src->ops->dsi.request_vc(src, >channel);
+   r = src->ops->dsi.request_vc(src, ddata->channel);
if (r) {
dev_err(dev, "failed to get virtual channel\n");
return r;
}
 
-   r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH);
-   if (r) {
-   dev_err(dev, "failed to set VC_ID\n");
-   src->ops->dsi.release_vc(src, ddata->channel);
-   return r;
-   }
-
ddata->src = src;
return 0;
 }
@@ -1216,6 +1209,8 @@ static int dsicm_probe_of(struct platform_device *pdev)
struct display_timing timing;
int err;
 
+   ddata->channel = TCH;
+
ddata->reset_gpio = devm_gpiod_get(>dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) {
err = PTR_ERR(ddata->reset_gpio);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index de4ec6055490..4d55e7c9cd65 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -350,7 +350,6 @@ struct dsi_data {
struct omap_dss_device *dssdev;
enum fifo_size tx_fifo_size;
enum fifo_size rx_fifo_size;
-   int vc_id;
} vc[4];
 
struct mutex lock;
@@ -2579,7 +2578,7 @@ static inline void dsi_vc_write_long_header(struct 
dsi_data *dsi, int channel,
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
-   data_id = data_type | dsi->vc[channel].vc_id << 6;
+   data_id = data_type | channel << 6;
 
val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
FLD_VAL(ecc, 31, 24);
@@ -2683,7 +2682,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int 
channel, u8 data_type,
return -EINVAL;
}
 
-   data_id = data_type | dsi->vc[channel].vc_id << 6;
+   data_id = data_type | channel << 6;
 
r = (data_id << 0) | (data << 8) | (ecc << 24);
 
@@ -4783,45 +4782,19 @@ static enum omap_channel dsi_get_channel(struct 
dsi_data *dsi)
}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
+static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
-   if (!dsi->vc[i].dssdev) {
-   dsi->vc[i].dssdev = dssdev;
-   *channel = i;
-   return 0;
-   }
-   }
 
-   DSSERR("cannot get VC for display %s", dssdev->name);
-   return -ENOSPC;
-}
-
-static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int 
vc_id)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if (vc_id < 0 || vc_id > 3) {
-   DSSERR("VC ID out of range\n");
-   return -EINVAL;
-   }
-
-   if (channel < 0 || channel > 3) {
-   DSSERR("Virtual Channel out of range\n");
+   if (channel < 0 || channel > 3)
return -EINVAL;
-   }
 
-   if (dsi->vc[channel].dssdev != dssdev) {
-   DSSERR("Virtual Channel not allocated to display %s\n",
-   dssdev->name);
-   return -EINVAL;
+   if (dsi->vc[channel].dssdev) {
+   DSSERR("cannot get VC for display %s", dssdev->name);
+   return -EBUSY;
}
 
-   dsi->vc[channel].vc_id = vc_id;
-
+   dsi->vc[channel].dssdev = dssdev;
return 0;
 }
 
@@ -4832,7 +4805,6 @@ static void dsi_release_vc(struct omap_dss_device 
*dssdev, int channel)
if ((channel >= 0 && channel <= 3) &&
dsi->vc[channel].dssdev == dssdev) {
dsi->vc[channel].dssdev = NULL;
-   dsi->vc[channel].vc_id = 0;
}
 }
 
@@ -4937,7 +4909,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.enable_te = dsi_enable_te,
 
.request_vc = dsi_request_vc,
-   .set_vc_id = dsi_set_vc_id,
.release_vc = dsi_release_vc,
 
.transfer = omap_dsi_transfer,
@@ -5393,7 +5364,6 @@ static 

[RFCv1 27/42] drm/omap: dsi: untangle ulps ops from enable/disable

2019-11-17 Thread Sebastian Reichel
Create a custom function pointer for ULPS and use it instead of
reusing disable/enable functions for ULPS mode switch. This allows
us to use the common disable/enable functions pointers for DSI.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  8 ++--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 38 ++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  5 +--
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 36101d9ba84d..f73b8f489f82 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -233,7 +233,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   src->ops->dsi.disable(src, false, true);
+   src->ops->dsi.ulps(src, true);
 
ddata->ulps_enabled = true;
 
@@ -258,7 +258,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
if (!ddata->ulps_enabled)
return 0;
 
-   src->ops->enable(src);
+   src->ops->dsi.ulps(src, false);
ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
r = _dsicm_enable_te(ddata, ddata->te_enabled);
@@ -586,7 +586,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.disable(src, true, false);
+   src->ops->disable(src);
 err_regulators:
r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r)
@@ -612,7 +612,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
dsicm_hw_reset(ddata);
}
 
-   src->ops->dsi.disable(src, true, false);
+   src->ops->disable(src);
 
r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 8387abea21a5..d200b7a6f93c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4062,13 +4062,10 @@ static void dsi_display_uninit_dsi(struct dsi_data 
*dsi, bool disconnect_lanes,
}
 }
 
-static void dsi_display_enable(struct omap_dss_device *dssdev)
+static void dsi_display_ulps_enable(struct dsi_data *dsi)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
-   DSSDBG("dsi_display_enable\n");
-
WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(>lock);
@@ -4091,16 +4088,19 @@ static void dsi_display_enable(struct omap_dss_device 
*dssdev)
dsi_runtime_put(dsi);
 err_get_dsi:
mutex_unlock(>lock);
-   DSSDBG("dsi_display_enable FAILED\n");
+   DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void dsi_display_disable(struct omap_dss_device *dssdev,
-   bool disconnect_lanes, bool enter_ulps)
+static void dsi_display_enable(struct omap_dss_device *dssdev)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   DSSDBG("dsi_display_enable\n");
+   dsi_display_ulps_enable(dsi);
+}
 
-   DSSDBG("dsi_display_disable\n");
-
+static void dsi_display_ulps_disable(struct dsi_data *dsi,
+   bool disconnect_lanes, bool enter_ulps)
+{
WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(>lock);
@@ -4117,6 +4117,23 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
mutex_unlock(>lock);
 }
 
+static void dsi_display_disable(struct omap_dss_device *dssdev)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   DSSDBG("dsi_display_disable\n");
+   dsi_display_ulps_disable(dsi, true, false);
+}
+
+static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   DSSDBG("dsi_ulps\n");
+   if (enable)
+   dsi_display_ulps_disable(dsi, false, true);
+   else
+   dsi_display_ulps_enable(dsi);
+}
+
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
dsi->te_enabled = enable;
@@ -4818,9 +4835,10 @@ static const struct omap_dss_device_ops dsi_ops = {
.connect = dsi_connect,
.disconnect = dsi_disconnect,
.enable = dsi_display_enable,
+   .disable = dsi_display_disable,
 
.dsi = {
-   .disable = dsi_display_disable,
+   .ulps = dsi_ulps,
 
.set_config = dsi_set_config,
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 2d6ab948a6dd..ad525cf80ad8 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -287,10 +287,9 @@ struct omapdss_hdmi_ops {
 };
 
 struct omapdss_dsi_ops {
-   void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
-   bool enter_ulps);
-
/* bus configuration */
+   void (*ulps)(struct omap_dss_device *dssdev, bool enable);
+
   

Re: [PATCH v2] drm/tegra: Turn off and reset hardware across suspend-resume

2019-11-17 Thread Dmitry Osipenko
14.11.2019 23:31, Thierry Reding пишет:
> On Sun, Aug 11, 2019 at 09:39:32PM +0300, Dmitry Osipenko wrote:
>> The drivers core bumps runtime PM refcount during of entering into
>> suspend to workaround some problem where parent device may become turned
>> off before its children. In order to disable and reset CRTCs/HDMI/etc
>> hardware, the runtime PM needs to be "forced" into suspend mode.
>>
>> Signed-off-by: Dmitry Osipenko 
>> ---
>>
>> Changelog:
>>
>> v2: The SYSTEM_SLEEP_PM_OPS are now set for all of the relevant drivers and
>> not only for the DC because turned out that they all should enforce the
>> suspending.
>>
>>  drivers/gpu/drm/tegra/dc.c| 2 ++
>>  drivers/gpu/drm/tegra/dpaux.c | 2 ++
>>  drivers/gpu/drm/tegra/dsi.c   | 2 ++
>>  drivers/gpu/drm/tegra/hdmi.c  | 2 ++
>>  drivers/gpu/drm/tegra/hub.c   | 2 ++
>>  drivers/gpu/drm/tegra/sor.c   | 2 ++
>>  drivers/gpu/drm/tegra/vic.c   | 2 ++
>>  7 files changed, 14 insertions(+)
> 
> I'm not exactly sure I understand why this is necessary. Runtime PM is
> controlled by the drivers themselves so that when an output (say SOR) is
> disabled, it drops the runtime PM reference. The idea is that since the
> disabled output is no longer needed it can just go into a low power mode
> which on Tegra usually means clocks off and reset asserted (and in some
> cases also power domain off).
> 
> DRM/KMS has system-level suspend support, which we use to disable all
> outputs when entering suspend. I see that, unfortunately, this doesn't
> seem to actually cause the devices to runtime suspend. I'm pretty sure
> that this used to work at some point, so I don't know what changed. I'd
> have to look into this a little more. The core doing something like this
> behind the driver's back seems wrong and having to force the device into
> suspend mode seems like it's just piling up on the workarounds.

Please let me know if you'll find a better solution.

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 13/42] drm/omap: panel-dsi-cm: use DSI helpers

2019-11-17 Thread Sebastian Reichel
After converting the driver to mipi_dsi_device we can use the generic
message helpers to simplify the driver a lot.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 126 +++---
 1 file changed, 18 insertions(+), 108 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index e2e56cc1cd61..e6c0a6e5aa1d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -138,62 +138,22 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_READ,
-   .tx_len = 1,
-   .tx_buf = _cmd,
-   .rx_len = 1,
-   .rx_buf = data
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
-}
-
-static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
-{
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE,
-   .tx_buf = _cmd,
-   .tx_len = 1,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
+   return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const u8 buf[] = { dcs_cmd, param };
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-   .tx_buf = ,
-   .tx_len = 2,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
+   return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, , 1);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
-   const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE,
-   .tx_buf = ,
-   .tx_len = 1,
-   };
 
hw_guard_wait(ddata);
 
-   r = dsi->host->ops->transfer(dsi->host, );
+   r = mipi_dsi_dcs_enter_sleep_mode(ddata->dsi);
if (r)
return r;
 
@@ -210,7 +170,7 @@ static int dsicm_sleep_out(struct panel_drv_data *ddata)
 
hw_guard_wait(ddata);
 
-   r = dsicm_dcs_write_0(ddata, MIPI_DCS_EXIT_SLEEP_MODE);
+   r = mipi_dsi_dcs_exit_sleep_mode(ddata->dsi);
if (r)
return r;
 
@@ -248,46 +208,15 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
u16 y1 = y;
u16 y2 = y + h - 1;
 
-   const u8 paramX[] = {
-   MIPI_DCS_SET_COLUMN_ADDRESS,
-   (x1 >> 8) & 0xff,
-   (x1 >> 0) & 0xff,
-   (x2 >> 8) & 0xff,
-   (x2 >> 0) & 0xff,
-   };
-
-   const struct mipi_dsi_msg msgX = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_GENERIC_LONG_WRITE,
-   .tx_buf = paramX,
-   .tx_len = 5,
-   };
-
-   const u8 paramY[] = {
-   MIPI_DCS_SET_PAGE_ADDRESS,
-   (y1 >> 8) & 0xff,
-   (y1 >> 0) & 0xff,
-   (y2 >> 8) & 0xff,
-   (y2 >> 0) & 0xff,
-   };
-
-   const struct mipi_dsi_msg msgY = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_GENERIC_LONG_WRITE,
-   .tx_buf = paramY,
-   .tx_len = 5,
-   };
-
-
-   r = dsi->host->ops->transfer(dsi->host, );
-   if (r)
+   r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
+   if (r < 0)
return r;
 
-   r = dsi->host->ops->transfer(dsi->host, );
-   if (r)
+   r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
+   if (r < 0)
return r;
 
-   return r;
+   return 0;
 }
 
 static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
@@ -681,12 +610,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_PIXEL_FORMAT,
-   MIPI_DCS_PIXEL_FMT_24BIT);
+   r = mipi_dsi_dcs_set_pixel_format(ddata->dsi, MIPI_DCS_PIXEL_FMT_24BIT);
if (r)
goto err;
 
-   r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_ON);
+   r = mipi_dsi_dcs_set_display_on(ddata->dsi);
if (r)
goto err;
 
@@ -732,7 +660,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
src->ops->dsi.disable_video_output(src, ddata->channel);
 

[RFCv1 05/42] drm/omap: panel-dsi-cm: convert to transfer API

2019-11-17 Thread Sebastian Reichel
This converts the panel-dsi-cm driver to use the transfer
API instead of specific functions, so that the specific
functions can be unexported and squashed into the generic
transfer function.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 133 +-
 1 file changed, 96 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 9214d66cfdc7..05974059f231 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
struct omap_dss_device *src = ddata->src;
-   int r;
-   u8 buf[1];
-
-   r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1);
-
-   if (r < 0)
-   return r;
-
-   *data = buf[0];
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_READ,
+   .tx_len = 1,
+   .tx_buf = _cmd,
+   .rx_len = 1,
+   .rx_buf = data
+   };
 
-   return 0;
+   return src->ops->dsi.transfer(src, );
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
struct omap_dss_device *src = ddata->src;
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE,
+   .tx_buf = _cmd,
+   .tx_len = 1,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, _cmd, 1);
+   return src->ops->dsi.transfer(src, );
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
struct omap_dss_device *src = ddata->src;
-   u8 buf[2] = { dcs_cmd, param };
+   const u8 buf[] = { dcs_cmd, param };
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
+   .tx_buf = ,
+   .tx_len = 2,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2);
+   return src->ops->dsi.transfer(src, );
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
struct omap_dss_device *src = ddata->src;
-   u8 cmd;
int r;
+   const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE,
+   .tx_buf = ,
+   .tx_len = 1,
+   };
 
hw_guard_wait(ddata);
 
-   cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, , 1);
+   r = src->ops->dsi.transfer(src, );
if (r)
return r;
 
@@ -233,28 +249,44 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
u16 y1 = y;
u16 y2 = y + h - 1;
 
-   u8 buf[5];
-   buf[0] = MIPI_DCS_SET_COLUMN_ADDRESS;
-   buf[1] = (x1 >> 8) & 0xff;
-   buf[2] = (x1 >> 0) & 0xff;
-   buf[3] = (x2 >> 8) & 0xff;
-   buf[4] = (x2 >> 0) & 0xff;
+   const u8 paramX[] = {
+   MIPI_DCS_SET_COLUMN_ADDRESS,
+   (x1 >> 8) & 0xff,
+   (x1 >> 0) & 0xff,
+   (x2 >> 8) & 0xff,
+   (x2 >> 0) & 0xff,
+   };
 
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, 
sizeof(buf));
-   if (r)
-   return r;
+   const struct mipi_dsi_msg msgX = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_GENERIC_LONG_WRITE,
+   .tx_buf = paramX,
+   .tx_len = 5,
+   };
 
-   buf[0] = MIPI_DCS_SET_PAGE_ADDRESS;
-   buf[1] = (y1 >> 8) & 0xff;
-   buf[2] = (y1 >> 0) & 0xff;
-   buf[3] = (y2 >> 8) & 0xff;
-   buf[4] = (y2 >> 0) & 0xff;
+   const u8 paramY[] = {
+   MIPI_DCS_SET_PAGE_ADDRESS,
+   (y1 >> 8) & 0xff,
+   (y1 >> 0) & 0xff,
+   (y2 >> 8) & 0xff,
+   (y2 >> 0) & 0xff,
+   };
 
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, 
sizeof(buf));
+   const struct mipi_dsi_msg msgY = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_GENERIC_LONG_WRITE,
+   .tx_buf = paramY,
+   .tx_len = 5,
+   };
+
+
+   r = src->ops->dsi.transfer(src, );
if (r)
return r;
 
-   src->ops->dsi.bta_sync(src, ddata->channel);
+   r = src->ops->dsi.transfer(src, );
+   if (r)
+   return r;
 
return r;
 }
@@ -991,6 +1023,27 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
return r;
 }
 
+static int dsicm_set_max_rx_packet_size(struct omap_dss_device 

[RFCv1 12/42] drm/omap: dsi: introduce mipi_dsi_host

2019-11-17 Thread Sebastian Reichel
This moves from custom platform driver infrastructure to mipi_dsi_host
and mipi_dsi_device. Note, that this is a graduate step and the driver
only uses the devices types and transfer function, but not yet the new
device binding style or drm_panel.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 119 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  54 ++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   4 -
 3 files changed, 102 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b505bfd221fc..e2e56cc1cd61 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -39,13 +38,13 @@
 #define DCS_GET_ID30xdc
 
 struct panel_drv_data {
+   struct mipi_dsi_device *dsi;
+
struct omap_dss_device dssdev;
struct omap_dss_device *src;
 
struct videomode vm;
 
-   struct platform_device *pdev;
-
struct mutex lock;
 
struct backlight_device *bldev;
@@ -139,7 +138,7 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_READ,
@@ -149,12 +148,12 @@ static int dsicm_dcs_read_1(struct panel_drv_data *ddata, 
u8 dcs_cmd, u8 *data)
.rx_buf = data
};
 
-   return src->ops->dsi.transfer(src, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE,
@@ -162,12 +161,12 @@ static int dsicm_dcs_write_0(struct panel_drv_data 
*ddata, u8 dcs_cmd)
.tx_len = 1,
};
 
-   return src->ops->dsi.transfer(src, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const u8 buf[] = { dcs_cmd, param };
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
@@ -176,13 +175,13 @@ static int dsicm_dcs_write_1(struct panel_drv_data 
*ddata, u8 dcs_cmd, u8 param)
.tx_len = 2,
};
 
-   return src->ops->dsi.transfer(src, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
const struct mipi_dsi_msg msg = {
@@ -194,7 +193,7 @@ static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
hw_guard_wait(ddata);
 
-   r = src->ops->dsi.transfer(src, );
+   r = dsi->host->ops->transfer(dsi->host, );
if (r)
return r;
 
@@ -242,7 +241,7 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 
*id1, u8 *id2, u8 *id3)
 static int dsicm_set_update_window(struct panel_drv_data *ddata,
u16 x, u16 y, u16 w, u16 h)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
u16 x1 = x;
u16 x2 = x + w - 1;
@@ -280,11 +279,11 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
};
 
 
-   r = src->ops->dsi.transfer(src, );
+   r = dsi->host->ops->transfer(dsi->host, );
if (r)
return r;
 
-   r = src->ops->dsi.transfer(src, );
+   r = dsi->host->ops->transfer(dsi->host, );
if (r)
return r;
 
@@ -327,7 +326,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
return 0;
 
 err:
-   dev_err(>pdev->dev, "enter ULPS failed");
+   dev_err(>dsi->dev, "enter ULPS failed");
dsicm_panel_reset(ddata);
 
ddata->ulps_enabled = false;
@@ -350,7 +349,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 
r = _dsicm_enable_te(ddata, true);
if (r) {
-   dev_err(>pdev->dev, "failed to re-enable TE");
+   dev_err(>dsi->dev, "failed to re-enable TE");
goto err2;
}
 
@@ -364,7 +363,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0;
 
 err2:
-   dev_err(>pdev->dev, "failed to exit ULPS");
+  

[RFCv1 14/42] drm/omap: dsi: request VC via mipi_dsi_attach

2019-11-17 Thread Sebastian Reichel
Drop custom request_vc/release_vc callbacks by using the
generic mipi_dsi_attach/mipi_dsi_detach functions.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 24 +---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 61 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 -
 3 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index e6c0a6e5aa1d..ddc6dd671cd0 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -693,14 +693,6 @@ static int dsicm_connect(struct omap_dss_device *src,
 struct omap_dss_device *dst)
 {
struct panel_drv_data *ddata = to_panel_data(dst);
-   struct device *dev = >dsi->dev;
-   int r;
-
-   r = src->ops->dsi.request_vc(src, ddata->channel);
-   if (r) {
-   dev_err(dev, "failed to get virtual channel\n");
-   return r;
-   }
 
ddata->src = src;
return 0;
@@ -711,7 +703,6 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 {
struct panel_drv_data *ddata = to_panel_data(dst);
 
-   src->ops->dsi.release_vc(src, ddata->channel);
ddata->src = NULL;
 }
 
@@ -1278,8 +1269,21 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
goto err_bl;
}
 
+   dsi->lanes = 3;
+   dsi->format = MIPI_DSI_FMT_RGB888;
+   dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
+ MIPI_DSI_MODE_EOT_PACKET;
+   dsi->hs_rate = 3;
+   dsi->lp_rate = 1000;
+
+   r = mipi_dsi_attach(dsi);
+   if (r < 0)
+   goto err_dsi_attach;
+
return 0;
 
+err_dsi_attach:
+   sysfs_remove_group(>dev.kobj, _attr_group);
 err_bl:
destroy_workqueue(ddata->workqueue);
 err_reg:
@@ -1296,6 +1300,8 @@ static int __exit dsicm_remove(struct mipi_dsi_device 
*dsi)
 
dev_dbg(>dev, "remove\n");
 
+   mipi_dsi_detach(dsi);
+
omapdss_device_unregister(dssdev);
 
if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c4107fe5a53d..3cd749cae15c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -349,7 +349,7 @@ struct dsi_data {
 
struct {
enum dsi_vc_source source;
-   struct omap_dss_device *dssdev;
+   struct mipi_dsi_device *dest;
enum fifo_size tx_fifo_size;
enum fifo_size rx_fifo_size;
} vc[4];
@@ -4690,32 +4690,6 @@ static enum omap_channel dsi_get_channel(struct dsi_data 
*dsi)
}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if (channel < 0 || channel > 3)
-   return -EINVAL;
-
-   if (dsi->vc[channel].dssdev) {
-   DSSERR("cannot get VC for display %s", dssdev->name);
-   return -EBUSY;
-   }
-
-   dsi->vc[channel].dssdev = dssdev;
-   return 0;
-}
-
-static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if ((channel >= 0 && channel <= 3) &&
-   dsi->vc[channel].dssdev == dssdev) {
-   dsi->vc[channel].dssdev = NULL;
-   }
-}
-
 static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
  const struct mipi_dsi_msg *msg)
 {
@@ -4792,23 +4766,40 @@ static const struct omap_dss_device_ops dsi_ops = {
.update = dsi_update,
 
.enable_te = dsi_enable_te,
-
-   .request_vc = dsi_request_vc,
-   .release_vc = dsi_release_vc,
},
 };
 
 int omap_dsi_host_attach(struct mipi_dsi_host *host,
-struct mipi_dsi_device *dsi)
+struct mipi_dsi_device *client)
 {
-   /* TODO: convert driver from custom binding method to this one */
+   struct dsi_data *dsi = host_to_omap(host);
+   unsigned int channel = client->channel;
+
+   if (channel > 3)
+   return -EINVAL;
+
+   if (dsi->vc[channel].dest) {
+   DSSERR("cannot get VC for display %s", dev_name(>dev));
+   return -EBUSY;
+   }
+
+   dsi->vc[channel].dest = client;
return 0;
 }
 
 int omap_dsi_host_detach(struct mipi_dsi_host *host,
-struct mipi_dsi_device *dsi)
+struct mipi_dsi_device *client)
 {
-   /* TODO: convert driver from custom binding method to this one */
+   struct dsi_data *dsi = host_to_omap(host);
+   unsigned int channel = client->channel;
+
+   if (channel > 3)
+   return -EINVAL;
+
+   if (dsi->vc[channel].dest != client)
+

[RFCv1 17/42] drm/omap: dsi: drop unused memory_read()

2019-11-17 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 93 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 -
 2 files changed, 97 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index cc25bd0b501f..e309a556c700 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -931,97 +931,6 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
return r;
 }
 
-static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
-u16 size)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct mipi_dsi_device *dsi = ddata->dsi;
-
-   return mipi_dsi_set_maximum_return_packet_size(dsi, size);
-}
-
-static int dsicm_memory_read(struct omap_dss_device *dssdev,
-   void *buf, size_t size,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   struct omap_dss_device *src = ddata->src;
-   int r;
-   int first = 1;
-   int plen;
-   unsigned int buf_used = 0;
-
-   if (size < w * h * 3)
-   return -ENOMEM;
-
-   mutex_lock(>lock);
-
-   if (!ddata->enabled) {
-   r = -ENODEV;
-   goto err1;
-   }
-
-   size = min((u32)w * h * 3,
-  ddata->vm.hactive * ddata->vm.vactive * 3);
-
-   src->ops->dsi.bus_lock(src);
-
-   r = dsicm_wake_up(ddata);
-   if (r)
-   goto err2;
-
-   /* plen 1 or 2 goes into short packet. until checksum error is fixed,
-* use short packets. plen 32 works, but bigger packets seem to cause
-* an error. */
-   if (size % 2)
-   plen = 1;
-   else
-   plen = 2;
-
-   dsicm_set_update_window(ddata, x, y, w, h);
-
-   r = dsicm_set_max_rx_packet_size(dssdev, plen);
-   if (r)
-   goto err2;
-
-   while (buf_used < size) {
-   u8 dcs_cmd = first ? 0x2e : 0x3e;
-   first = 0;
-
-   r = mipi_dsi_dcs_read(dsi, dcs_cmd,
- buf + buf_used, size - buf_used);
-   if (r < 0) {
-   dev_err(dssdev->dev, "read error\n");
-   goto err3;
-   }
-
-   buf_used += r;
-
-   if (r < plen) {
-   dev_err(>dsi->dev, "short read\n");
-   break;
-   }
-
-   if (signal_pending(current)) {
-   dev_err(>dsi->dev, "signal pending, "
-   "aborting memory read\n");
-   r = -ERESTARTSYS;
-   goto err3;
-   }
-   }
-
-   r = buf_used;
-
-err3:
-   dsicm_set_max_rx_packet_size(dssdev, 1);
-err2:
-   src->ops->dsi.bus_unlock(src);
-err1:
-   mutex_unlock(>lock);
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1094,8 +1003,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
 
.enable_te  = dsicm_enable_te,
.get_te = dsicm_get_te,
-
-   .memory_read= dsicm_memory_read,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 28faacb9636b..742088b8f570 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -413,10 +413,6 @@ struct omap_dss_driver {
 
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
int (*get_te)(struct omap_dss_device *dssdev);
-
-   int (*memory_read)(struct omap_dss_device *dssdev,
-   void *buf, size_t size,
-   u16 x, u16 y, u16 w, u16 h);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 37/42] drm/omap: panel-dsi-cm: fix remove()

2019-11-17 Thread Sebastian Reichel
The remove function should disable the panel by
calling the unprepare() function before the panel
is disconnected from MIPI bus instead of trying
to reset it.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index f607b3dfa31f..90132d1d1f5d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -604,6 +604,8 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
 
dev_dbg(>dev, "remove\n");
 
+   drm_panel_unprepare(>panel);
+
mipi_dsi_detach(dsi);
 
drm_panel_remove(>panel);
@@ -613,9 +615,6 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
if (ddata->extbldev)
put_device(>extbldev->dev);
 
-   /* reset, to be sure that the panel is in a valid state */
-   dsicm_hw_reset(ddata);
-
return 0;
 }
 
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 25/42] drm/omap: dsi: drop custom enable_te() API

2019-11-17 Thread Sebastian Reichel
Instead of using the custon enable_te() API, this automatically
enables/disables TE core support when a matching packet is send
to the panel.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  3 --
 drivers/gpu/drm/omapdrm/dss/dsi.c | 33 ++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 --
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 9a259e0d9e97..787f953168ec 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -772,7 +772,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
-   struct omap_dss_device *src = ddata->src;
struct mipi_dsi_device *dsi = ddata->dsi;
int r;
 
@@ -781,8 +780,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, 
bool enable)
else
r = mipi_dsi_dcs_set_tear_off(dsi);
 
-   src->ops->dsi.enable_te(src, enable);
-
/* possible panel bug */
msleep(100);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 8f900cf1aed7..8060009fbfb9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4117,10 +4117,8 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
mutex_unlock(>lock);
 }
 
-static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
+static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
dsi->te_enabled = enable;
 
if (dsi->te_gpio) {
@@ -4730,6 +4728,7 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
 {
struct dsi_data *dsi = host_to_omap(host);
struct omap_dss_device *dssdev = >output;
+   int r;
 
if (NEQV(msg->flags & MIPI_DSI_MSG_USE_LPM, dsi->in_lp_mode)) {
dsi_vc_enable_hs(dssdev, msg->channel,
@@ -4746,16 +4745,34 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
case MIPI_DSI_DCS_LONG_WRITE:
case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
case MIPI_DSI_NULL_PACKET:
-   return dsi_vc_write_common(dssdev, msg);
+   r = dsi_vc_write_common(dssdev, msg);
+   break;
case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
-   return dsi_vc_generic_read(dssdev, msg);
+   r = dsi_vc_generic_read(dssdev, msg);
+   break;
case MIPI_DSI_DCS_READ:
-   return dsi_vc_dcs_read(dssdev, msg);
+   r = dsi_vc_dcs_read(dssdev, msg);
+   break;
+   default:
+   r = -EINVAL;
+   break;
}
 
-   return -EINVAL;
+   if (r < 0)
+   return r;
+
+   if (msg->type == MIPI_DSI_DCS_SHORT_WRITE ||
+   msg->type == MIPI_DSI_DCS_SHORT_WRITE_PARAM) {
+   u8 cmd = ((u8*) msg->tx_buf)[0];
+   if (cmd == MIPI_DCS_SET_TEAR_OFF)
+   dsi_enable_te(dsi, false);
+   else if(cmd == MIPI_DCS_SET_TEAR_ON)
+   dsi_enable_te(dsi, true);
+   }
+
+   return 0;
 }
 
 static int dsi_get_clocks(struct dsi_data *dsi)
@@ -4802,8 +4819,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.disable_video_output = dsi_disable_video_output,
 
.update = dsi_update,
-
-   .enable_te = dsi_enable_te,
},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5bcc14d9f737..ca52b08c57db 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -294,8 +294,6 @@ struct omapdss_dsi_ops {
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
 
-   int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-
int (*update)(struct omap_dss_device *dssdev, int channel,
void (*callback)(int, void *), void *data);
 
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 08/42] drm/omap: dsi: simplify write function

2019-11-17 Thread Sebastian Reichel
Simplify the write related messages handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/Kconfig |   1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 144 +++-
 2 files changed, 33 insertions(+), 112 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 956f23e1452d..1d7e31824ff3 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -94,6 +94,7 @@ config OMAP2_DSS_SDI
 
 config OMAP2_DSS_DSI
bool "DSI support"
+   select DRM_MIPI_DSI
 default n
help
  MIPI DSI (Display Serial Interface) support.
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4d55e7c9cd65..696727673c6a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2696,97 +2696,49 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int 
channel)
return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
 }
 
-static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
- const u8 *data, int len,
- enum dss_dsi_content_type type)
+static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct mipi_dsi_packet packet;
int r;
 
-   if (len == 0) {
-   BUG_ON(type == DSS_DSI_CONTENT_DCS);
-   r = dsi_vc_send_short(dsi, channel,
-   MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0);
-   } else if (len == 1) {
-   r = dsi_vc_send_short(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
-   MIPI_DSI_DCS_SHORT_WRITE, data[0], 0);
-   } else if (len == 2) {
-   r = dsi_vc_send_short(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
-   MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-   data[0] | (data[1] << 8), 0);
+   r = mipi_dsi_create_packet(, msg);
+   if (r < 0)
+   return r;
+
+   if (mipi_dsi_packet_format_is_short(msg->type)) {
+   u16 data = packet.header[1] | (packet.header[2] << 8);
+   r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
} else {
-   r = dsi_vc_send_long(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_LONG_WRITE :
-   MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
+   r = dsi_vc_send_long(dsi, msg->channel, msg->type,
+  msg->tx_buf, msg->tx_len, 0);
}
 
-   return r;
-}
-
-static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   return dsi_vc_write_nosync_common(dsi, channel, data, len,
-   DSS_DSI_CONTENT_DCS);
-}
-
-static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int 
channel,
-   const u8 *data, int len)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   return dsi_vc_write_nosync_common(dsi, channel, data, len,
-   DSS_DSI_CONTENT_GENERIC);
-}
-
-static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-  int channel, const u8 *data, int len,
-  enum dss_dsi_content_type type)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   int r;
+   if (r < 0)
+   return r;
 
-   r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
-   if (r)
-   goto err;
+   /*
+* we do not always have to do the BTA sync, for example we can
+* improve performance by setting the update window information
+* without sending BTA sync between the commands. In that case
+* we can return earily.
+*/
 
-   r = dsi_vc_send_bta_sync(dssdev, channel);
-   if (r)
-   goto err;
+   r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+   if (r) {
+   DSSERR("bta sync failed\n");
+   return r;
+   }
 
/* RX_FIFO_NOT_EMPTY */
-   if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+   if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
DSSERR("rx fifo not empty after write, dumping data:\n");
-   dsi_vc_flush_receive_data(dsi, channel);
-   r = 

[RFCv1 32/42] drm/omap: dsi: convert to drm_panel

2019-11-17 Thread Sebastian Reichel
This converts the DSI module to expect common drm_panel display
drivers instead of dssdev based ones.

This commit is WIP. We somehow need to know the panels resolution
in omap_dsi_host_attach(), so that we can properly configure the
DSI bus clock before enabling the bus. The control bus must be
enabled at this point, so that the panel can use it.

Other drivers run drm_panel_attach() in their dsi host attach,
which makes it possible to call drm_panel_get_modes() afterwards
and the get the correct mode from the connector.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 217 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 141 ++--
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |   1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  22 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  17 +-
 5 files changed, 205 insertions(+), 193 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 18020ac43a83..84b0e79c025e 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -6,8 +6,6 @@
  * Author: Tomi Valkeinen 
  */
 
-/* #define DEBUG */
-
 #include 
 #include 
 #include 
@@ -20,11 +18,14 @@
 #include 
 
 #include 
+#include 
+#include 
+#include 
 
+#include 
 #include 
 #include 
-
-#include "../dss/omapdss.h"
+#include 
 
 #define DCS_READ_NUM_ERRORS0x05
 #define DCS_GET_ID10xda
@@ -35,11 +36,8 @@
 
 struct panel_drv_data {
struct mipi_dsi_device *dsi;
-
-   struct omap_dss_device dssdev;
-   struct omap_dss_device *src;
-
-   struct videomode vm;
+   struct drm_panel panel;
+   struct drm_display_mode mode;
 
struct mutex lock;
 
@@ -71,7 +69,11 @@ struct panel_drv_data {
bool ulps_enabled;
 };
 
-#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+
+static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
+{
+   return container_of(panel, struct panel_drv_data, panel);
+}
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
@@ -285,10 +287,15 @@ static void dsicm_hw_reset(struct panel_drv_data *ddata)
 
 static int dsicm_power_on(struct panel_drv_data *ddata)
 {
-   struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
 
+   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r) {
+   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
+   return r;
+   }
+
dsicm_hw_reset(ddata);
 
ddata->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
@@ -322,10 +329,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
-   if (r)
-   goto err;
-
ddata->enabled = 1;
 
if (!ddata->intro_printed) {
@@ -342,18 +345,17 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
+   regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+
return r;
 }
 
-static void dsicm_power_off(struct panel_drv_data *ddata)
+static int dsicm_power_off(struct panel_drv_data *ddata)
 {
-   struct omap_dss_device *src = ddata->src;
int r;
 
ddata->enabled = 0;
 
-   src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
-
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
if (!r)
r = dsicm_sleep_in(ddata);
@@ -363,52 +365,17 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
"error disabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata);
}
-}
 
-static int dsicm_connect(struct omap_dss_device *src,
-struct omap_dss_device *dst)
-{
-   struct panel_drv_data *ddata = to_panel_data(dst);
-
-   ddata->src = src;
-   return 0;
-}
-
-static void dsicm_disconnect(struct omap_dss_device *src,
-struct omap_dss_device *dst)
-{
-   struct panel_drv_data *ddata = to_panel_data(dst);
-
-   ddata->src = NULL;
-}
-
-static void dsicm_pre_enable(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-   int r;
-   struct omap_dss_dsi_config dsi_config = {
-   .vm = >vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
-
-   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r) {
-   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
-   }
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if 

[RFCv1 06/42] drm/omap: dsi: unexport specific data transfer functions

2019-11-17 Thread Sebastian Reichel
After converting all DSI drivers, unexport the specific transfer
functions.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 20 
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7560411f8ed6..de4ec6055490 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4941,18 +4941,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.release_vc = dsi_release_vc,
 
.transfer = omap_dsi_transfer,
-
-   .dcs_write = dsi_vc_dcs_write,
-   .dcs_write_nosync = dsi_vc_dcs_write_nosync,
-   .dcs_read = dsi_vc_dcs_read,
-
-   .gen_write = dsi_vc_generic_write,
-   .gen_write_nosync = dsi_vc_generic_write_nosync,
-   .gen_read = dsi_vc_generic_read,
-
-   .bta_sync = dsi_vc_send_bta_sync,
-
-   .set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 04952c291537..79ae4073c35f 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -316,26 +316,6 @@ struct omapdss_dsi_ops {
/* data transfer */
ssize_t (*transfer)(struct omap_dss_device *dssdev,
const struct mipi_dsi_msg *msg);
-
-   int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
-   u8 *data, int len);
-
-   int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*gen_read)(struct omap_dss_device *dssdev, int channel,
-   const u8 *reqdata, int reqlen,
-   u8 *data, int len);
-
-   int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
-
-   int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
-   int channel, u16 plen);
 };
 
 struct omap_dss_device_ops {
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 24/42] drm/omap: dsi: move TE GPIO handling into core

2019-11-17 Thread Sebastian Reichel
In preparation for removing custom DSS calls from the DSI
panel driver, this moves support for external tearing event
GPIOs into the DSI host driver. This way tearing events are
always handled in the core resulting in simplification of
the panel drivers.

The TE GPIO acquisition follows works in the same way as the
exynos DSI implementation.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 101 +
 drivers/gpu/drm/omapdrm/dss/dsi.c | 140 --
 2 files changed, 135 insertions(+), 106 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 5603dae0fd0f..9a259e0d9e97 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -54,7 +54,6 @@ struct panel_drv_data {
 
/* panel HW configuration from DT or platform data */
struct gpio_desc *reset_gpio;
-   struct gpio_desc *ext_te_gpio;
 
struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
@@ -68,10 +67,6 @@ struct panel_drv_data {
 
bool te_enabled;
 
-   atomic_t do_update;
-
-   struct delayed_work te_timeout_work;
-
bool intro_printed;
 
struct workqueue_struct *workqueue;
@@ -83,8 +78,6 @@ struct panel_drv_data {
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
-static irqreturn_t dsicm_te_isr(int irq, void *data);
-static void dsicm_te_timeout_work_callback(struct work_struct *work);
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
 static int dsicm_panel_reset(struct panel_drv_data *ddata);
@@ -240,9 +233,6 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   if (ddata->ext_te_gpio)
-   disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
src->ops->dsi.disable(src, false, true);
 
ddata->ulps_enabled = true;
@@ -271,15 +261,12 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
src->ops->enable(src);
ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
-   r = _dsicm_enable_te(ddata, true);
+   r = _dsicm_enable_te(ddata, ddata->te_enabled);
if (r) {
dev_err(>dsi->dev, "failed to re-enable TE");
goto err2;
}
 
-   if (ddata->ext_te_gpio)
-   enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
dsicm_queue_ulps_work(ddata);
 
ddata->ulps_enabled = false;
@@ -290,11 +277,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
dev_err(>dsi->dev, "failed to exit ULPS");
 
r = dsicm_panel_reset(ddata);
-   if (!r) {
-   if (ddata->ext_te_gpio)
-   enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
+   if (!r)
ddata->ulps_enabled = false;
-   }
 
dsicm_queue_ulps_work(ddata);
 
@@ -745,43 +729,6 @@ static void dsicm_framedone_cb(int err, void *data)
src->ops->dsi.bus_unlock(src);
 }
 
-static irqreturn_t dsicm_te_isr(int irq, void *data)
-{
-   struct panel_drv_data *ddata = data;
-   struct omap_dss_device *src = ddata->src;
-   int old;
-   int r;
-
-   old = atomic_cmpxchg(>do_update, 1, 0);
-
-   if (old) {
-   cancel_delayed_work(>te_timeout_work);
-
-   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
-   ddata);
-   if (r)
-   goto err;
-   }
-
-   return IRQ_HANDLED;
-err:
-   dev_err(>dsi->dev, "start update failed\n");
-   src->ops->dsi.bus_unlock(src);
-   return IRQ_HANDLED;
-}
-
-static void dsicm_te_timeout_work_callback(struct work_struct *work)
-{
-   struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
-   te_timeout_work.work);
-   struct omap_dss_device *src = ddata->src;
-
-   dev_err(>dsi->dev, "TE not received for 250ms!\n");
-
-   atomic_set(>do_update, 0);
-   src->ops->dsi.bus_unlock(src);
-}
-
 static int dsicm_update(struct omap_dss_device *dssdev,
u16 x, u16 y, u16 w, u16 h)
 {
@@ -809,16 +756,10 @@ static int dsicm_update(struct omap_dss_device *dssdev,
if (r)
goto err;
 
-   if (ddata->te_enabled && ddata->ext_te_gpio) {
-   schedule_delayed_work(>te_timeout_work,
-   msecs_to_jiffies(250));
-   atomic_set(>do_update, 1);
-   } else {
-   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
-   ddata);
-   if (r)
-   goto err;
-   }
+   r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
+   ddata);
+   if (r)
+   goto err;
 
/* 

[PATCH libdrm v4] modetest: Add support for setting mode having floating vertical refresh rate

2019-11-17 Thread Devarsh Thakkar
For the scenario where user may require to modeset with a mode
supporting a fractional value for vertical refresh-rate,
appropriate mode can be selected by searching for mode
having matching fractional vertical refresh rate using
below equation.

vrefresh = (1000 * pixel clock) / (htotal * vtotal) Hz.

We do this way since driver doesn't return float value of vrefresh
as it use int for vrefresh in struct drm_mode_info, but we can derive
the actual value using pixel clock, horizontal total size and
vertical total size values.

So for e.g. if user want to select mode having 59.94 Hz as refresh rate
then with this patch it be can done as shown in below command,
given there is an appropriate mode is available :

modetest -M xlnx -s 39:1920x1080-59.94@BG24 -v

NOTE: Above command was tested on xilinx DRM driver with DP
monitor which was supporting mode having 59.94 Hz refresh rate.

V2: Update commit message
V3: Update with below changes as per review comments :
  1) Use epsilon for vrefresh comparison
  2) Use implicit type-casting wherever possible
V4: Keep patch version history on main commit message

Signed-off-by: Devarsh Thakkar 
Reviewed-by: Ville Syrjälä 
---
 tests/modetest/modetest.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index e66be66..b4edfcb 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -54,6 +54,7 @@
 #ifdef HAVE_SYS_SELECT_H
 #include 
 #endif
+#include 
 
 #include "xf86drm.h"
 #include "xf86drmMode.h"
@@ -795,7 +796,7 @@ struct pipe_arg {
uint32_t crtc_id;
char mode_str[64];
char format_str[5];
-   unsigned int vrefresh;
+   float vrefresh;
unsigned int fourcc;
drmModeModeInfo *mode;
struct crtc *crtc;
@@ -822,11 +823,12 @@ struct plane_arg {
 
 static drmModeModeInfo *
 connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
-const unsigned int vrefresh)
+   const float vrefresh)
 {
drmModeConnector *connector;
drmModeModeInfo *mode;
int i;
+   float mode_vrefresh;
 
connector = get_connector_by_id(dev, con_id);
if (!connector || !connector->count_modes)
@@ -839,9 +841,11 @@ connector_find_mode(struct device *dev, uint32_t con_id, 
const char *mode_str,
 * first mode that match with the name. Else, return 
the mode that match
 * the name and the specified vertical refresh 
frequency.
 */
+   mode_vrefresh = mode->clock * 1000.00
+   / (mode->htotal * mode->vtotal);
if (vrefresh == 0)
return mode;
-   else if (mode->vrefresh == vrefresh)
+   else if (fabs(mode_vrefresh - vrefresh) < 0.005)
return mode;
}
}
@@ -1393,8 +1397,8 @@ static void atomic_set_mode(struct device *dev, struct 
pipe_arg *pipes, unsigned
if (pipe->mode == NULL)
continue;
 
-   printf("setting mode %s-%dHz on connectors ",
-  pipe->mode_str, pipe->mode->vrefresh);
+   printf("setting mode %s-%.2fHz on connectors ",
+  pipe->mode_str, pipe->vrefresh);
for (j = 0; j < pipe->num_cons; ++j) {
printf("%s, ", pipe->cons[j]);
add_property(dev, pipe->con_ids[j], "CRTC_ID", 
pipe->crtc->crtc->crtc_id);
@@ -1476,8 +1480,8 @@ static void set_mode(struct device *dev, struct pipe_arg 
*pipes, unsigned int co
if (pipe->mode == NULL)
continue;
 
-   printf("setting mode %s-%dHz@%s on connectors ",
-  pipe->mode_str, pipe->mode->vrefresh, pipe->format_str);
+   printf("setting mode %s-%.2fHz@%s on connectors ",
+  pipe->mode_str, pipe->vrefresh, pipe->format_str);
for (j = 0; j < pipe->num_cons; ++j)
printf("%s, ", pipe->cons[j]);
printf("crtc %d\n", pipe->crtc->crtc->crtc_id);
@@ -1713,7 +1717,7 @@ static int parse_connector(struct pipe_arg *pipe, const 
char *arg)
pipe->mode_str[len] = '\0';
 
if (*p == '-') {
-   pipe->vrefresh = strtoul(p + 1, , 10);
+   pipe->vrefresh = strtof(p + 1, );
p = endp;
}
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 04/42] drm/omap: dsi: add generic transfer function

2019-11-17 Thread Sebastian Reichel
This prepares the driver for becoming a mipi_dsi_host implementation,
which provides a generic transfer function instead of all kind of
different read/write functions. The implementation will become more
elegant after unexporting the specific functions in the following
patches.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 52 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
 2 files changed, 55 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bf6131e5fa14..7560411f8ed6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4836,6 +4836,56 @@ static void dsi_release_vc(struct omap_dss_device 
*dssdev, int channel)
}
 }
 
+static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
+const struct mipi_dsi_msg *msg)
+{
+   /*
+* no_sync can be used to optimize performance by sending
+* e.g. column and page information without syncing in
+* between. It's not absolutley required, so postpone this
+* feature for now.
+*/
+   bool no_sync = false;
+   u16 val;
+
+   switch (msg->type) {
+   case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+   case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+   case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+   case MIPI_DSI_GENERIC_LONG_WRITE:
+   if (no_sync)
+   return dsi_vc_generic_write_nosync(dssdev, msg->channel,
+ msg->tx_buf, msg->tx_len);
+   else
+   return dsi_vc_generic_write(dssdev, msg->channel,
+   msg->tx_buf, msg->tx_len);
+   case MIPI_DSI_DCS_SHORT_WRITE:
+   case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+   case MIPI_DSI_DCS_LONG_WRITE:
+   if (no_sync)
+   return dsi_vc_dcs_write_nosync(dssdev, msg->channel,
+ msg->tx_buf, msg->tx_len);
+   else
+   return dsi_vc_dcs_write(dssdev, msg->channel,
+   msg->tx_buf, msg->tx_len);
+   case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+   case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+   case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+   return dsi_vc_generic_read(dssdev, msg->channel, msg->tx_buf,
+   msg->tx_len, msg->rx_buf, msg->rx_len);
+   case MIPI_DSI_DCS_READ:
+   return dsi_vc_dcs_read(dssdev, msg->channel,
+   ((u8*) msg->tx_buf)[0],
+   msg->rx_buf, msg->rx_len);
+   case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
+   val = le16_to_cpu(*((__le16*) msg->tx_buf));
+   return dsi_vc_set_max_rx_packet_size(dssdev, msg->channel, val);
+   case MIPI_DSI_NULL_PACKET:
+   return dsi_vc_send_null(to_dsi_data(dssdev), msg->channel);
+   }
+
+   return -EINVAL;
+}
 
 static int dsi_get_clocks(struct dsi_data *dsi)
 {
@@ -4890,6 +4940,8 @@ static const struct omap_dss_device_ops dsi_ops = {
.set_vc_id = dsi_set_vc_id,
.release_vc = dsi_release_vc,
 
+   .transfer = omap_dsi_transfer,
+
.dcs_write = dsi_vc_dcs_write,
.dcs_write_nosync = dsi_vc_dcs_write_nosync,
.dcs_read = dsi_vc_dcs_read,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ae1a4600dab2..04952c291537 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -314,6 +314,9 @@ struct omapdss_dsi_ops {
void (*release_vc)(struct omap_dss_device *dssdev, int channel);
 
/* data transfer */
+   ssize_t (*transfer)(struct omap_dss_device *dssdev,
+   const struct mipi_dsi_msg *msg);
+
int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
const u8 *data, int len);
int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 01/42] omap/drm: drop unused dsi.configure_pins

2019-11-17 Thread Sebastian Reichel
The panel-dsi-cm's ddata->pin_config is always NULL, so this
callback is never called. Instead the DSI encoder gets the pin
configuration directly from DT.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 11 ---
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  2 --
 3 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 564e3e1a1891..c3ddf98f4ec6 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -68,8 +68,6 @@ struct panel_drv_data {
int width_mm;
int height_mm;
 
-   struct omap_dsi_pin_config pin_config;
-
/* runtime variables */
bool enabled;
 
@@ -623,15 +621,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
}
}
 
-   if (ddata->pin_config.num_pins > 0) {
-   r = src->ops->dsi.configure_pins(src, >pin_config);
-   if (r) {
-   dev_err(>pdev->dev,
-   "failed to configure DSI pins\n");
-   goto err_vddi;
-   }
-   }
-
r = src->ops->dsi.set_config(src, _config);
if (r) {
dev_err(>pdev->dev, "failed to configure DSI\n");
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index da16ea095f13..8e3664368c4f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4892,7 +4892,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
.enable_hs = dsi_vc_enable_hs,
 
-   .configure_pins = dsi_configure_pins,
.set_config = dsi_set_config,
 
.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 79f6b195c7cf..75e506b88733 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -299,8 +299,6 @@ struct omapdss_dsi_ops {
/* bus configuration */
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
-   int (*configure_pins)(struct omap_dss_device *dssdev,
-   const struct omap_dsi_pin_config *pin_cfg);
 
void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
bool enable);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 3/3] drm/gma500: remove set but not used variable 'is_hdmi', 'is_crt'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/gma500/cdv_intel_display.c: In function cdv_intel_crtc_mode_set:
drivers/gpu/drm/gma500/cdv_intel_display.c:594:7: warning: variable is_hdmi set 
but not used [-Wunused-but-set-variable]
drivers/gpu/drm/gma500/cdv_intel_display.c: In function cdv_intel_crtc_mode_set:
drivers/gpu/drm/gma500/cdv_intel_display.c:593:7: warning: variable is_crt set 
but not used [-Wunused-but-set-variable]

They are not used since commit acd7ef927e06 ("gma500:
Update the Cedarview clock handling")

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/gma500/cdv_intel_display.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c 
b/drivers/gpu/drm/gma500/cdv_intel_display.c
index 8b78494..334a203 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_display.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_display.c
@@ -582,8 +582,8 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
struct gma_clock_t clock;
u32 dpll = 0, dspcntr, pipeconf;
bool ok;
-   bool is_crt = false, is_lvds = false, is_tv = false;
-   bool is_hdmi = false, is_dp = false;
+   bool is_lvds = false, is_tv = false;
+   bool is_dp = false;
struct drm_mode_config *mode_config = >mode_config;
struct drm_connector *connector;
const struct gma_limit_t *limit;
@@ -607,10 +607,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
is_tv = true;
break;
case INTEL_OUTPUT_ANALOG:
-   is_crt = true;
-   break;
case INTEL_OUTPUT_HDMI:
-   is_hdmi = true;
break;
case INTEL_OUTPUT_DISPLAYPORT:
is_dp = true;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/gma500: remove set but not used variable 'channel_eq'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/gma500/cdv_intel_dp.c: In function 
cdv_intel_dp_complete_link_train:
drivers/gpu/drm/gma500/cdv_intel_dp.c:1596:7: warning: variable channel_eq set 
but not used [-Wunused-but-set-variable]

It is never used, so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c 
b/drivers/gpu/drm/gma500/cdv_intel_dp.c
index 570b595..5772b2d 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
@@ -1594,7 +1594,6 @@ cdv_intel_dp_complete_link_train(struct gma_encoder 
*encoder)
 {
struct drm_device *dev = encoder->base.dev;
struct cdv_intel_dp *intel_dp = encoder->dev_priv;
-   bool channel_eq = false;
int tries, cr_tries;
u32 reg;
uint32_t DP = intel_dp->DP;
@@ -1602,7 +1601,6 @@ cdv_intel_dp_complete_link_train(struct gma_encoder 
*encoder)
/* channel equalization */
tries = 0;
cr_tries = 0;
-   channel_eq = false;

DRM_DEBUG_KMS("\n");
reg = DP | DP_LINK_TRAIN_PAT_2;
@@ -1648,7 +1646,6 @@ cdv_intel_dp_complete_link_train(struct gma_encoder 
*encoder)

if (cdv_intel_channel_eq_ok(encoder)) {
DRM_DEBUG_KMS("PT2 train is done\n");
-   channel_eq = true;
break;
}

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 40/42] drm/omap: dsi: support panel un/re-binding

2019-11-17 Thread Sebastian Reichel
This adds support for unbinding the panel driver
and have working output again when the panel is
bound again later. This is important, since the
generic panel drivers do not suppress the unbind
properties and the panel module might be unloaded.

Also this adds support for unbinding the DSI encoder
and gets back to running setup when the encoder is
rebound later. Making this possible is just a side-
effect of panel unbinding support.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/base.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c  | 63 ++
 2 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index a1970b9db6ab..f85697784e26 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -217,7 +217,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
dst ? dev_name(dst->dev) : "NULL");
 
if (!dst) {
-   WARN_ON(!src->bridge && !src->panel);
+   WARN_ON(src->type != OMAP_DISPLAY_TYPE_DSI && !src->bridge && 
!src->panel);
return;
}
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bc96f74f1740..5996e39500c6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "omapdss.h"
 #include "dss.h"
@@ -440,6 +441,9 @@ struct dsi_data {
struct omap_dss_dsi_videomode_timings vm_timings;
 
struct omap_dss_device output;
+
+   struct drm_device *drm_dev;
+   struct drm_connector *connector;
 };
 
 struct dsi_packet_sent_handler_data {
@@ -5143,6 +5147,7 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 struct mipi_dsi_device *client)
 {
struct dsi_data *dsi = host_to_omap(host);
+   struct omap_dss_device *dssdev = >output;
unsigned int channel = client->channel;
struct drm_panel *panel;
int r;
@@ -5188,7 +5193,18 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 
dsi->ulps_auto_idle = !!(client->mode_flags & MIPI_DSI_MODE_ULPS_IDLE);
 
+   dssdev->panel = panel;
+
+   if (dsi->connector) {
+   dsi->connector->status = connector_status_connected;
+   drm_panel_attach(panel, dsi->connector);
+   }
+
dsi_bus_unlock(dsi);
+
+   if (dsi->drm_dev && dsi->drm_dev->mode_config.poll_enabled)
+   drm_kms_helper_hotplug_event(dsi->drm_dev);
+
return 0;
 }
 
@@ -5196,6 +5212,7 @@ int omap_dsi_host_detach(struct mipi_dsi_host *host,
 struct mipi_dsi_device *client)
 {
struct dsi_data *dsi = host_to_omap(host);
+   struct omap_dss_device *dssdev = >output;
unsigned int channel = client->channel;
 
if (channel > 3)
@@ -5204,8 +5221,28 @@ int omap_dsi_host_detach(struct mipi_dsi_host *host,
if (dsi->vc[channel].dest != client)
return -EINVAL;
 
+   if (!dssdev->panel)
+   return -EINVAL;
+
+   dsi_bus_lock(dsi);
+
+   /* HACK: steal connector and drm_dev from panel */
+   dsi->connector = dssdev->panel->connector;
+   dsi->drm_dev = dssdev->panel->drm;
+
+   if (dsi->connector) {
+   dsi->connector->status = connector_status_disconnected;
+   drm_panel_detach(dssdev->panel);
+   dssdev->panel = NULL;
+   }
+
omap_dsi_unregister_te_irq(dsi);
dsi->vc[channel].dest = NULL;
+   dsi_bus_unlock(dsi);
+
+   if (dsi->drm_dev && dsi->drm_dev->mode_config.poll_enabled)
+   drm_kms_helper_hotplug_event(dsi->drm_dev);
+
return 0;
 }
 
@@ -5373,6 +5410,12 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
dsi->debugfs.clks = dss_debugfs_create_file(dss, name,
dsi_dump_dsi_clocks, dsi);
 
+   r = mipi_dsi_host_register(>host);
+   if (r < 0) {
+   dev_err(dev, "failed to register DSI host: %d\n", r);
+   return r;
+   }
+
return 0;
 }
 
@@ -5380,6 +5423,8 @@ static void dsi_unbind(struct device *dev, struct device 
*master, void *data)
 {
struct dsi_data *dsi = dev_get_drvdata(dev);
 
+   mipi_dsi_host_unregister(>host);
+
dss_debugfs_remove_file(dsi->debugfs.clks);
dss_debugfs_remove_file(dsi->debugfs.irqs);
dss_debugfs_remove_file(dsi->debugfs.regs);
@@ -5401,7 +5446,6 @@ static const struct component_ops dsi_component_ops = {
 static int dsi_init_output(struct dsi_data *dsi)
 {
struct omap_dss_device *out = >output;
-   int r;
 
out->dev = dsi->dev;
out->id = dsi->module_id == 0 ?
@@ -5417,10 +5461,6 @@ static int dsi_init_output(struct dsi_data *dsi)
   | DRM_BUS_FLAG_DE_HIGH
 

[PATCH 2/6] drm/radeon: remove set but not used variable 'backbias_response_time'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/si_dpm.c: In function si_program_response_times:
drivers/gpu/drm/radeon/si_dpm.c:3640:29: warning: variable 
backbias_response_time set but not used [-Wunused-but-set-variable]

It is introduced by commit a9e61410921b ("drm/radeon/kms:
add dpm support for SI (v7)"), but never used, so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/si_dpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index a0b382a..8148a78 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -3640,14 +3640,13 @@ static int si_notify_smc_display_change(struct 
radeon_device *rdev,

 static void si_program_response_times(struct radeon_device *rdev)
 {
-   u32 voltage_response_time, backbias_response_time, acpi_delay_time, 
vbi_time_out;
+   u32 voltage_response_time, acpi_delay_time, vbi_time_out;
u32 vddc_dly, acpi_dly, vbi_dly;
u32 reference_clock;

si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1);

voltage_response_time = (u32)rdev->pm.dpm.voltage_response_time;
-   backbias_response_time = (u32)rdev->pm.dpm.backbias_response_time;

if (voltage_response_time == 0)
voltage_response_time = 1000;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 02/42] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*

2019-11-17 Thread Sebastian Reichel
This replaces OMAP specific enum for pixel format with
common implementation.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c | 49 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +---
 3 files changed, 20 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index c3ddf98f4ec6..9214d66cfdc7 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -595,7 +595,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
int r;
struct omap_dss_dsi_config dsi_config = {
.mode = OMAP_DSS_DSI_CMD_MODE,
-   .pixel_format = OMAP_DSS_DSI_FMT_RGB888,
+   .pixel_format = MIPI_DSI_FMT_RGB888,
.vm = >vm,
.hs_clk_min = 15000,
.hs_clk_max = 3,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 8e3664368c4f..fa81fbf3442e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -34,6 +34,7 @@
 #include 
 
 #include 
+#include 
 
 #include "omapdss.h"
 #include "dss.h"
@@ -410,7 +411,7 @@ struct dsi_data {
 
struct dss_lcd_mgr_config mgr_config;
struct videomode vm;
-   enum omap_dss_dsi_pixel_format pix_fmt;
+   enum mipi_dsi_pixel_format pix_fmt;
enum omap_dss_dsi_mode mode;
struct omap_dss_dsi_videomode_timings vm_timings;
 
@@ -514,22 +515,6 @@ static inline bool wait_for_bit_change(struct dsi_data 
*dsi,
return false;
 }
 
-static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
-{
-   switch (fmt) {
-   case OMAP_DSS_DSI_FMT_RGB888:
-   case OMAP_DSS_DSI_FMT_RGB666:
-   return 24;
-   case OMAP_DSS_DSI_FMT_RGB666_PACKED:
-   return 18;
-   case OMAP_DSS_DSI_FMT_RGB565:
-   return 16;
-   default:
-   BUG();
-   return 0;
-   }
-}
-
 #ifdef DSI_PERF_MEASURE
 static void dsi_perf_mark_setup(struct dsi_data *dsi)
 {
@@ -3239,7 +3224,7 @@ static void dsi_config_vp_num_line_buffers(struct 
dsi_data *dsi)
int num_line_buffers;
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
const struct videomode *vm = >vm;
/*
 * Don't use line buffers if width is greater than the video
@@ -3370,7 +3355,7 @@ static void dsi_config_cmd_mode_interleaving(struct 
dsi_data *dsi)
int tclk_trail, ths_exit, exiths_clk;
bool ddr_alwon;
const struct videomode *vm = >vm;
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
int ndl = dsi->num_lanes_used - 1;
int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.mX[HSDIV_DSI] + 1;
int hsa_interleave_hs = 0, hsa_interleave_lp = 0;
@@ -3498,7 +3483,7 @@ static int dsi_proto_config(struct dsi_data *dsi)
dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true);
dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true);
 
-   switch (dsi_get_pixel_size(dsi->pix_fmt)) {
+   switch (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt)) {
case 16:
buswidth = 0;
break;
@@ -3619,7 +3604,7 @@ static void dsi_proto_timings(struct dsi_data *dsi)
int window_sync = dsi->vm_timings.window_sync;
bool hsync_end;
const struct videomode *vm = >vm;
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
int tl, t_he, width_bytes;
 
hsync_end = dsi->vm_timings.trans_mode == 
OMAP_DSS_DSI_PULSE_MODE;
@@ -3726,7 +3711,7 @@ static int dsi_configure_pins(struct omap_dss_device 
*dssdev,
 static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
u8 data_type;
u16 word_count;
int r;
@@ -3737,16 +3722,16 @@ static int dsi_enable_video_output(struct 
omap_dss_device *dssdev, int channel)
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
switch (dsi->pix_fmt) {
-   case OMAP_DSS_DSI_FMT_RGB888:
+   case MIPI_DSI_FMT_RGB888:
data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
break;
-   case OMAP_DSS_DSI_FMT_RGB666:
+   case MIPI_DSI_FMT_RGB666:
data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
break;
-   

[PATCH 1/3] drm/gma500: remove set but not used variable 'htotal'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/gma500/oaktrail_hdmi.c: In function htotal_calculate:
drivers/gpu/drm/gma500/oaktrail_hdmi.c:160:6: warning: variable htotal set but 
not used [-Wunused-but-set-variable]

It is introduced by commit 39ec748f7174 ("gma600: Enable HDMI support"),
but never used, so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/gma500/oaktrail_hdmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/oaktrail_hdmi.c 
b/drivers/gpu/drm/gma500/oaktrail_hdmi.c
index f4c5208..f437023 100644
--- a/drivers/gpu/drm/gma500/oaktrail_hdmi.c
+++ b/drivers/gpu/drm/gma500/oaktrail_hdmi.c
@@ -159,9 +159,7 @@ static void oaktrail_hdmi_audio_disable(struct drm_device 
*dev)

 static unsigned int htotal_calculate(struct drm_display_mode *mode)
 {
-   u32 htotal, new_crtc_htotal;
-
-   htotal = (mode->crtc_hdisplay - 1) | ((mode->crtc_htotal - 1) << 16);
+   u32 new_crtc_htotal;

/*
 * 1024 x 768  new_crtc_htotal = 0x1024;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 10/42] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg

2019-11-17 Thread Sebastian Reichel
Simplify the DSI encoder by using mipi_dsi_msg for
dsi_vc_send_long and dsi_vc_send_short. Further improvements
require cleaning up the channel allocation code first.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 92 +++
 1 file changed, 45 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c22d438ae2b5..d39b84409656 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2599,30 +2599,36 @@ static inline void dsi_vc_write_long_payload(struct 
dsi_data *dsi, int channel,
dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
 }
 
-static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-   const u8 *data, u16 len, u8 ecc)
+static int dsi_vc_send_long(struct dsi_data *dsi,
+   const struct mipi_dsi_msg *msg)
 {
+   struct mipi_dsi_packet pkg;
/*u32 val; */
int i;
const u8 *p;
int r = 0;
u8 b1, b2, b3, b4;
 
+   r = mipi_dsi_create_packet(, msg);
+   if (r < 0)
+   return r;
+
if (dsi->debug_write)
-   DSSDBG("dsi_vc_send_long, %d bytes\n", len);
+   DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
 
/* len + header */
-   if (dsi->vc[channel].tx_fifo_size * 32 * 4 < len + 4) {
+   if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
DSSERR("unable to send long packet: packet too long.\n");
return -EINVAL;
}
 
-   dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-   dsi_vc_write_long_header(dsi, channel, data_type, len, ecc);
+   dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len,
+pkg.header[3]);
 
-   p = data;
-   for (i = 0; i < len >> 2; i++) {
+   p = msg->tx_buf;
+   for (i = 0; i < msg->tx_len >> 2; i++) {
if (dsi->debug_write)
DSSDBG("\tsending full packet %d\n", i);
 
@@ -2631,10 +2637,10 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
channel, u8 data_type,
b3 = *p++;
b4 = *p++;
 
-   dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4);
+   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
}
 
-   i = len % 4;
+   i = msg->tx_len % 4;
if (i) {
b1 = 0; b2 = 0; b3 = 0;
 
@@ -2656,64 +2662,64 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
channel, u8 data_type,
break;
}
 
-   dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0);
+   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
}
 
return r;
 }
 
-static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
-u16 data, u8 ecc)
+static int dsi_vc_send_short(struct dsi_data *dsi,
+const struct mipi_dsi_msg *msg)
 {
+   struct mipi_dsi_packet pkg;
u32 r;
-   u8 data_id;
+
+   r = mipi_dsi_create_packet(, msg);
+   if (r < 0)
+   return r;
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
if (dsi->debug_write)
DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
-   channel,
-   data_type, data & 0xff, (data >> 8) & 0xff);
+   msg->channel,
+   msg->type, pkg.header[1], pkg.header[2]);
 
-   dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) {
+   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
DSSERR("ERROR FIFO FULL, aborting transfer\n");
return -EINVAL;
}
 
-   data_id = data_type | channel << 6;
-
-   r = (data_id << 0) | (data << 8) | (ecc << 24);
+   r = pkg.header[3] << 24 | pkg.header[2] << 16 | pkg.header[1] << 8 |
+   pkg.header[0];
 
-   dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r);
+   dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(msg->channel), r);
 
return 0;
 }
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 {
-   return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
+   const struct mipi_dsi_msg msg = {
+   .channel = channel,
+   .type = MIPI_DSI_NULL_PACKET,
+   };
+
+   return dsi_vc_send_long(dsi, );
 }
 
 static int dsi_vc_write_common(struct omap_dss_device *dssdev,
   const struct mipi_dsi_msg *msg)
 {
   

[PATCH 6/6] drm/radeon: remove set but not used variable 'tv_pll_cntl1'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/radeon_legacy_tv.c: In function 
radeon_legacy_tv_mode_set:
drivers/gpu/drm/radeon/radeon_legacy_tv.c:538:24: warning: variable 
tv_pll_cntl1 set but not used [-Wunused-but-set-variable]

It is introduced by commit 4ce001abafaf ("drm/radeon/kms:
add initial radeon tv-out support."), but never used,
so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/radeon_legacy_tv.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_legacy_tv.c 
b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
index f132eec..d9df7f3 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_tv.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
@@ -537,7 +537,7 @@ void radeon_legacy_tv_mode_set(struct drm_encoder *encoder,
uint32_t tv_master_cntl, tv_rgb_cntl, tv_dac_cntl;
uint32_t tv_modulator_cntl1, tv_modulator_cntl2;
uint32_t tv_vscaler_cntl1, tv_vscaler_cntl2;
-   uint32_t tv_pll_cntl, tv_pll_cntl1, tv_ftotal;
+   uint32_t tv_pll_cntl, tv_ftotal;
uint32_t tv_y_fall_cntl, tv_y_rise_cntl, tv_y_saw_tooth_cntl;
uint32_t m, n, p;
const uint16_t *hor_timing;
@@ -709,12 +709,6 @@ void radeon_legacy_tv_mode_set(struct drm_encoder *encoder,
(((n >> 9) & RADEON_TV_N0HI_MASK) << RADEON_TV_N0HI_SHIFT) |
((p & RADEON_TV_P_MASK) << RADEON_TV_P_SHIFT);

-   tv_pll_cntl1 = (((4 & RADEON_TVPCP_MASK) << RADEON_TVPCP_SHIFT) |
-   ((4 & RADEON_TVPVG_MASK) << RADEON_TVPVG_SHIFT) |
-   ((1 & RADEON_TVPDC_MASK) << RADEON_TVPDC_SHIFT) |
-   RADEON_TVCLK_SRC_SEL_TVPLL |
-   RADEON_TVPLL_TEST_DIS);
-
tv_dac->tv.tv_uv_adr = 0xc8;

if (tv_dac->tv_std == TV_STD_NTSC ||
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 16/42] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines

2019-11-17 Thread Sebastian Reichel
Drop local definition of common MIPI DCS 1.3 defines.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 426c660af264..cc25bd0b501f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -28,8 +28,6 @@
 #include "../dss/omapdss.h"
 
 #define DCS_READ_NUM_ERRORS0x05
-#define DCS_BRIGHTNESS 0x51
-#define DCS_CTRL_DISPLAY   0x53
 #define DCS_GET_ID10xda
 #define DCS_GET_ID20xdb
 #define DCS_GET_ID30xdc
@@ -333,8 +331,10 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
src->ops->dsi.bus_lock(src);
 
r = dsicm_wake_up(ddata);
-   if (!r)
-   r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
+   if (!r) {
+   r = dsicm_dcs_write_1(ddata,
+   MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
+   }
 
src->ops->dsi.bus_unlock(src);
}
@@ -597,11 +597,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, 0xff);
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, DCS_CTRL_DISPLAY,
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_WRITE_CONTROL_DISPLAY,
(1<<2) | (1<<5));   /* BL | BCTRL */
if (r)
goto err;
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 41/42] ARM: dts: omap4-droid4: add panel compatible

2019-11-17 Thread Sebastian Reichel
Add Droid 4 specific compatible value in addition to the
generic one, so that we have the ability to add panel
specific quirks in the future.

Signed-off-by: Sebastian Reichel 
---
 arch/arm/boot/dts/omap4-droid4-xt894.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts 
b/arch/arm/boot/dts/omap4-droid4-xt894.dts
index 6af0a9288940..d5668998aa9d 100644
--- a/arch/arm/boot/dts/omap4-droid4-xt894.dts
+++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts
@@ -203,7 +203,7 @@
};
 
lcd0: panel@0 {
-   compatible = "panel-dsi-cm";
+   compatible = "motorola,droid4-panel", "panel-dsi-cm";
reg = <0>;
label = "lcd0";
vddi-supply = <_regulator>;
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 26/42] drm/omap: dsi: do bus locking in host driver

2019-11-17 Thread Sebastian Reichel
This moves the bus locking into the host driver and unexports
the custom API in preparation for drm_panel support.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 46 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 33 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 --
 3 files changed, 23 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 787f953168ec..36101d9ba84d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -298,7 +298,6 @@ static int dsicm_wake_up(struct panel_drv_data *ddata)
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(>dev);
-   struct omap_dss_device *src = ddata->src;
int r = 0;
int level;
 
@@ -313,15 +312,11 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(>lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r) {
r = dsicm_dcs_write_1(ddata,
MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
}
-
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(>lock);
@@ -347,21 +342,16 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
u8 errors = 0;
int r;
 
mutex_lock(>lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
);
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -378,20 +368,15 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
 
mutex_lock(>lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_get_id(ddata, , , );
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -409,7 +394,6 @@ static ssize_t dsicm_store_ulps(struct device *dev,
const char *buf, size_t count)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
unsigned long t;
int r;
 
@@ -420,14 +404,10 @@ static ssize_t dsicm_store_ulps(struct device *dev,
mutex_lock(>lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
if (t)
r = dsicm_enter_ulps(ddata);
else
r = dsicm_wake_up(ddata);
-
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(>lock);
@@ -457,7 +437,6 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
const char *buf, size_t count)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
unsigned long t;
int r;
 
@@ -470,9 +449,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
 
if (ddata->enabled) {
/* dsicm_wake_up will restart the timer */
-   src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata);
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(>lock);
@@ -673,17 +650,11 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
int r;
 
mutex_lock(>lock);
 
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_power_on(ddata);
-
-   src->ops->dsi.bus_unlock(src);
-
if (r)
goto err;
 
@@ -700,7 +671,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 static void dsicm_disable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
int r;
 
dsicm_bl_power(ddata, false);
@@ -709,24 +679,19 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
 
dsicm_cancel_ulps_work(ddata);
 
-   

[RFCv1 15/42] drm/omap: panel-dsi-cm: drop hardcoded VC

2019-11-17 Thread Sebastian Reichel
Use dsi->channel everywhere, which originates from DT.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 20 +++
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ddc6dd671cd0..426c660af264 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -27,9 +27,6 @@
 
 #include "../dss/omapdss.h"
 
-/* DSI Virtual channel. Hardcoded for now. */
-#define TCH 0
-
 #define DCS_READ_NUM_ERRORS0x05
 #define DCS_BRIGHTNESS 0x51
 #define DCS_CTRL_DISPLAY   0x53
@@ -73,7 +70,6 @@ struct panel_drv_data {
bool te_enabled;
 
atomic_t do_update;
-   int channel;
 
struct delayed_work te_timeout_work;
 
@@ -274,7 +270,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0;
 
src->ops->enable(src);
-   src->ops->dsi.enable_hs(src, ddata->channel, true);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
r = _dsicm_enable_te(ddata, true);
if (r) {
@@ -591,7 +587,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.enable_hs(src, ddata->channel, false);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
 
r = dsicm_sleep_out(ddata);
if (r)
@@ -622,7 +618,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = src->ops->dsi.enable_video_output(src, ddata->channel);
+   r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
if (r)
goto err;
 
@@ -634,7 +630,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
ddata->intro_printed = true;
}
 
-   src->ops->dsi.enable_hs(src, ddata->channel, true);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
return 0;
 err:
@@ -658,7 +654,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
int r;
 
-   src->ops->dsi.disable_video_output(src, ddata->channel);
+   src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
if (!r)
@@ -777,7 +773,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data)
if (old) {
cancel_delayed_work(>te_timeout_work);
 
-   r = src->ops->dsi.update(src, ddata->channel, 
dsicm_framedone_cb,
+   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
ddata);
if (r)
goto err;
@@ -834,7 +830,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
msecs_to_jiffies(250));
atomic_set(>do_update, 1);
} else {
-   r = src->ops->dsi.update(src, ddata->channel, 
dsicm_framedone_cb,
+   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
ddata);
if (r)
goto err;
@@ -1110,8 +1106,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
struct display_timing timing;
int err;
 
-   ddata->channel = TCH;
-
ddata->reset_gpio = devm_gpiod_get(>dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) {
err = PTR_ERR(ddata->reset_gpio);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 03/42] drm/omap: constify write buffers

2019-11-17 Thread Sebastian Reichel
The write buffers are not modified, so they can be constant.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 24 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index fa81fbf3442e..bf6131e5fa14 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2601,11 +2601,11 @@ static inline void dsi_vc_write_long_payload(struct 
dsi_data *dsi, int channel,
 }
 
 static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-   u8 *data, u16 len, u8 ecc)
+   const u8 *data, u16 len, u8 ecc)
 {
/*u32 val; */
int i;
-   u8 *p;
+   const u8 *p;
int r = 0;
u8 b1, b2, b3, b4;
 
@@ -2698,7 +2698,7 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int 
channel)
 }
 
 static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
- u8 *data, int len,
+ const u8 *data, int len,
  enum dss_dsi_content_type type)
 {
int r;
@@ -2729,7 +2729,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data 
*dsi, int channel,
 }
 
 static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len)
+   const u8 *data, int len)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2738,7 +2738,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device 
*dssdev, int channel,
 }
 
 static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int 
channel,
-   u8 *data, int len)
+   const u8 *data, int len)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2747,7 +2747,7 @@ static int dsi_vc_generic_write_nosync(struct 
omap_dss_device *dssdev, int chann
 }
 
 static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-  int channel, u8 *data, int len,
+  int channel, const u8 *data, int len,
   enum dss_dsi_content_type type)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
@@ -2776,15 +2776,15 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev,
return r;
 }
 
-static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 
*data,
-   int len)
+static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel,
+   const u8 *data, int len)
 {
return dsi_vc_write_common(dssdev, channel, data, len,
DSS_DSI_CONTENT_DCS);
 }
 
-static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, 
u8 *data,
-   int len)
+static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel,
+   const u8 *data, int len)
 {
return dsi_vc_write_common(dssdev, channel, data, len,
DSS_DSI_CONTENT_GENERIC);
@@ -2810,7 +2810,7 @@ static int dsi_vc_dcs_send_read_request(struct dsi_data 
*dsi, int channel,
 }
 
 static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-   u8 *reqdata, int reqlen)
+   const u8 *reqdata, int reqlen)
 {
u16 data;
u8 data_type;
@@ -2983,7 +2983,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device 
*dssdev, int channel, u8 dcs_c
 }
 
 static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-   u8 *reqdata, int reqlen, u8 *buf, int buflen)
+   const u8 *reqdata, int reqlen, u8 *buf, int buflen)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 6dd08d096eed..ae1a4600dab2 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -315,18 +315,18 @@ struct omapdss_dsi_ops {
 
/* data transfer */
int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
u8 *data, int len);
 
int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);

[PATCH v2 RESEND] drm/edid: no CEA v3 extension is not an error

2019-11-17 Thread Jean Delvare
It is fine for displays without audio functionality to not implement
CEA v3 extension in their EDID. Do not return an error in that case,
instead return 0 as if there was a CEA v3 extension with no audio or
speaker block.

This fixes the second half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Signed-off-by: Jean Delvare 
Reviewed-by: Ville Syrjälä 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Sean Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
---
Already sent on: 2019-09-04

Changes since v1:
 * Treat CEA extension version < 3 as non-error too (suggested by Ville
   Syrjälä)

 drivers/gpu/drm/drm_edid.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-5.4-rc7.orig/drivers/gpu/drm/drm_edid.c   2019-11-15 
12:09:03.186725414 +0100
+++ linux-5.4-rc7/drivers/gpu/drm/drm_edid.c2019-11-15 14:21:41.676073451 
+0100
@@ -4186,12 +4186,12 @@ int drm_edid_to_sad(struct edid *edid, s
cea = drm_find_cea_extension(edid);
if (!cea) {
DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-   return -ENOENT;
+   return 0;
}
 
if (cea_revision(cea) < 3) {
DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
-   return -ENOTSUPP;
+   return 0;
}
 
if (cea_db_offsets(cea, , )) {
@@ -4247,12 +4247,12 @@ int drm_edid_to_speaker_allocation(struc
cea = drm_find_cea_extension(edid);
if (!cea) {
DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-   return -ENOENT;
+   return 0;
}
 
if (cea_revision(cea) < 3) {
DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
-   return -ENOTSUPP;
+   return 0;
}
 
if (cea_db_offsets(cea, , )) {


-- 
Jean Delvare
SUSE L3 Support
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 2/2] drm/nouveau: remove set but not used variable 'mem'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/nouveau/nouveau_ttm.c: In function nouveau_vram_manager_new:
drivers/gpu/drm/nouveau/nouveau_ttm.c:66:22: warning: variable mem set but not 
used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/nouveau_ttm.c: In function nouveau_gart_manager_new:
drivers/gpu/drm/nouveau/nouveau_ttm.c:106:22: warning: variable mem set but not 
used [-Wunused-but-set-variable]

The first 'mem' is introduced by commit 9ce523cc3bf2 ("drm/nouveau:
separate buffer object backing memory from nvkm structures"),
but never used, so remove it.

The second 'mem' is not used since commit d7722134b825 ("drm/nouveau:
switch over to new memory and vmm interfaces")

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 77a0c6a..7ca0a24 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -63,14 +63,12 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 {
struct nouveau_bo *nvbo = nouveau_bo(bo);
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
-   struct nouveau_mem *mem;
int ret;

if (drm->client.device.info.ram_size == 0)
return -ENOMEM;

ret = nouveau_mem_new(>master, nvbo->kind, nvbo->comp, reg);
-   mem = nouveau_mem(reg);
if (ret)
return ret;

@@ -103,11 +101,9 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
 {
struct nouveau_bo *nvbo = nouveau_bo(bo);
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
-   struct nouveau_mem *mem;
int ret;

ret = nouveau_mem_new(>master, nvbo->kind, nvbo->comp, reg);
-   mem = nouveau_mem(reg);
if (ret)
return ret;

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 0/6] drm/radeon: remove some set but not used variables

2019-11-17 Thread zhengbin
zhengbin (6):
  drm/radeon: remove set but not used variable 'size','relocs_chunk'
  drm/radeon: remove set but not used variable 'backbias_response_time'
  drm/radeon: remove set but not used variable 'dig_connector'
  drm/radeon: remove set but not used variable 'radeon_connector'
  drm/radeon: remove set but not used variable 'blocks'
  drm/radeon: remove set but not used variable 'tv_pll_cntl1'

 drivers/gpu/drm/radeon/atombios_dp.c  | 3 ---
 drivers/gpu/drm/radeon/r600_cs.c  | 8 ++--
 drivers/gpu/drm/radeon/radeon_combios.c   | 3 +--
 drivers/gpu/drm/radeon/radeon_display.c   | 2 --
 drivers/gpu/drm/radeon/radeon_legacy_tv.c | 8 +---
 drivers/gpu/drm/radeon/si_dpm.c   | 3 +--
 6 files changed, 5 insertions(+), 22 deletions(-)

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 31/42] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations

2019-11-17 Thread Sebastian Reichel
Complete the direction reversal of the DSS device enable/disable
operations started by 19b4200d8f4b ("drm/omap: Reverse direction
of the DSS device enable/disable operations").

This effectively drops the requirement of calling DSS specific
code from the DSI panel driver moving it a bit further to a
standard drm_panel driver.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 75 ++-
 drivers/gpu/drm/omapdrm/omap_encoder.c| 20 ++---
 2 files changed, 44 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 9bfc262f5c5a..18020ac43a83 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -288,27 +288,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
-   struct omap_dss_dsi_config dsi_config = {
-   .vm = >vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
-
-   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r) {
-   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
-   return r;
-   }
-
-   r = src->ops->dsi.set_config(src, _config);
-   if (r) {
-   dev_err(>dsi->dev, "failed to configure DSI\n");
-   goto err_regulators;
-   }
-
-   src->ops->enable(src);
 
dsicm_hw_reset(ddata);
 
@@ -363,12 +342,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->disable(src);
-err_regulators:
-   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r)
-   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
-
return r;
 }
 
@@ -377,6 +350,8 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
int r;
 
+   ddata->enabled = 0;
+
src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
@@ -388,14 +363,6 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
"error disabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata);
}
-
-   src->ops->disable(src);
-
-   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r)
-   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
-
-   ddata->enabled = 0;
 }
 
 static int dsicm_connect(struct omap_dss_device *src,
@@ -415,6 +382,30 @@ static void dsicm_disconnect(struct omap_dss_device *src,
ddata->src = NULL;
 }
 
+static void dsicm_pre_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *src = ddata->src;
+   int r;
+   struct omap_dss_dsi_config dsi_config = {
+   .vm = >vm,
+   .hs_clk_min = 15000,
+   .hs_clk_max = 3,
+   .lp_clk_min = 700,
+   .lp_clk_max = 1000,
+   };
+
+   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r) {
+   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
+   }
+
+   r = src->ops->dsi.set_config(src, _config);
+   if (r) {
+   dev_err(>dsi->dev, "failed to configure DSI\n");
+   }
+}
+
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
@@ -449,6 +440,16 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(>lock);
 }
 
+static void dsicm_post_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   int r;
+
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
+}
+
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct mipi_dsi_device *dsi = ddata->dsi;
@@ -502,8 +503,10 @@ static const struct omap_dss_device_ops dsicm_ops = {
.connect= dsicm_connect,
.disconnect = dsicm_disconnect,
 
+   .pre_enable = dsicm_pre_enable,
.enable = dsicm_enable,
.disable= dsicm_disable,
+   .post_disable   = dsicm_post_disable,
 
.get_modes  = dsicm_get_modes,
.check_timings  = dsicm_check_timings,
@@ -666,8 +669,6 @@ static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 
omapdss_device_unregister(dssdev);
 
-   if 

[RFCv1 22/42] drm/omap: panel-dsi-cm: use bulk regulator API

2019-11-17 Thread Sebastian Reichel
Use bulk regulator API to simplify the code. This also switches
from _optional variant to normal variant, which will provide a
dummy regulator (i.e. if some always-enabled regulator is not
described in DT).

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 65 ++-
 1 file changed, 21 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index e4120d484f4c..170cbc78fbef 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -32,6 +32,8 @@
 #define DCS_GET_ID20xdb
 #define DCS_GET_ID30xdc
 
+#define DCS_REGULATOR_SUPPLY_NUM 2
+
 struct panel_drv_data {
struct mipi_dsi_device *dsi;
 
@@ -54,8 +56,7 @@ struct panel_drv_data {
struct gpio_desc *reset_gpio;
struct gpio_desc *ext_te_gpio;
 
-   struct regulator *vpnl;
-   struct regulator *vddi;
+   struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
bool use_dsi_backlight;
 
@@ -557,28 +558,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
.lp_clk_max = 1000,
};
 
-   if (ddata->vpnl) {
-   r = regulator_enable(ddata->vpnl);
-   if (r) {
-   dev_err(>dsi->dev,
-   "failed to enable VPNL: %d\n", r);
-   return r;
-   }
-   }
-
-   if (ddata->vddi) {
-   r = regulator_enable(ddata->vddi);
-   if (r) {
-   dev_err(>dsi->dev,
-   "failed to enable VDDI: %d\n", r);
-   goto err_vpnl;
-   }
+   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r) {
+   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
+   return r;
}
 
r = src->ops->dsi.set_config(src, _config);
if (r) {
dev_err(>dsi->dev, "failed to configure DSI\n");
-   goto err_vddi;
+   goto err_regulators;
}
 
src->ops->enable(src);
@@ -637,12 +626,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
dsicm_hw_reset(ddata);
 
src->ops->dsi.disable(src, true, false);
-err_vddi:
-   if (ddata->vddi)
-   regulator_disable(ddata->vddi);
-err_vpnl:
-   if (ddata->vpnl)
-   regulator_disable(ddata->vpnl);
+err_regulators:
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
 
return r;
 }
@@ -666,10 +653,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
src->ops->dsi.disable(src, true, false);
 
-   if (ddata->vddi)
-   regulator_disable(ddata->vddi);
-   if (ddata->vpnl)
-   regulator_disable(ddata->vpnl);
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
 
ddata->enabled = 0;
 }
@@ -973,21 +959,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
ddata->height_mm = 0;
of_property_read_u32(node, "height-mm", >height_mm);
 
-   ddata->vpnl = devm_regulator_get_optional(>dev, "vpnl");
-   if (IS_ERR(ddata->vpnl)) {
-   err = PTR_ERR(ddata->vpnl);
-   if (err == -EPROBE_DEFER)
-   return err;
-   ddata->vpnl = NULL;
-   }
-
-   ddata->vddi = devm_regulator_get_optional(>dev, "vddi");
-   if (IS_ERR(ddata->vddi)) {
-   err = PTR_ERR(ddata->vddi);
-   if (err == -EPROBE_DEFER)
-   return err;
-   ddata->vddi = NULL;
-   }
+   ddata->supplies[0].supply = "vpnl";
+   ddata->supplies[1].supply = "vddi";
+   err = devm_regulator_bulk_get(>dev, DCS_REGULATOR_SUPPLY_NUM,
+ ddata->supplies);
+   if (err)
+   return err;
 
backlight = of_parse_phandle(node, "backlight", 0);
if (backlight) {
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 19/42] drm/omap: dsi: drop unused enable_te()

2019-11-17 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 39 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 -
 2 files changed, 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b2eb834c9eff..164f3a30d7f2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -882,43 +882,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, 
bool enable)
return r;
 }
 
-static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   mutex_lock(>lock);
-
-   if (ddata->te_enabled == enable)
-   goto end;
-
-   src->ops->dsi.bus_lock(src);
-
-   if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (r)
-   goto err;
-
-   r = _dsicm_enable_te(ddata, enable);
-   if (r)
-   goto err;
-   }
-
-   ddata->te_enabled = enable;
-
-   src->ops->dsi.bus_unlock(src);
-end:
-   mutex_unlock(>lock);
-
-   return 0;
-err:
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(>lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -988,8 +951,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 static const struct omap_dss_driver dsicm_dss_driver = {
.update = dsicm_update,
.sync   = dsicm_sync,
-
-   .enable_te  = dsicm_enable_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9be1c659d3a4..bc583346af4d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -410,8 +410,6 @@ struct omap_dss_driver {
int (*update)(struct omap_dss_device *dssdev,
   u16 x, u16 y, u16 w, u16 h);
int (*sync)(struct omap_dss_device *dssdev);
-
-   int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 00/42] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel

2019-11-17 Thread Sebastian Reichel
This updates the existing omapdrm DSI code, so that it uses
common drm_mipi_dsi API and drm_panel instead of custom API.
I did not implement support for drm_bridge, since I do not
own any hardware needing this and it does not seem to be a
supported scenario with the old DSS code.

The patchset has been tested with Droid 4 using Linux console,
X.org and Weston. While I found some issues, I could not find
any regressions compared to the current state (*). Combined with
Laurent's effort this will remove all custom panel/connector
drivers from omapdrm and allow more cleanups in the DSS code.

I pushed this patchset into the following branch:

https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git/log/?h=omapdrm-dsi-drm-panel

(*) When display is used as console for dmesg one can see an
ugly deadlock on shutdown. I have not yet found the root
cause for this problem, but that already exists with
current mainline implementation.

 -- Sebastian

Sebastian Reichel (42):
  omap/drm: drop unused dsi.configure_pins
  drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  drm/omap: constify write buffers
  drm/omap: dsi: add generic transfer function
  drm/omap: panel-dsi-cm: convert to transfer API
  drm/omap: dsi: unexport specific data transfer functions
  drm/omap: dsi: drop virtual channel logic
  drm/omap: dsi: simplify write function
  drm/omap: dsi: simplify read functions
  drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  ARM: dts: omap: add channel to DSI panels
  drm/omap: dsi: introduce mipi_dsi_host
  drm/omap: panel-dsi-cm: use DSI helpers
  drm/omap: dsi: request VC via mipi_dsi_attach
  drm/omap: panel-dsi-cm: drop hardcoded VC
  drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  drm/omap: dsi: drop unused memory_read()
  drm/omap: dsi: drop unused get_te()
  drm/omap: dsi: drop unused enable_te()
  drm/omap: dsi: drop useless sync()
  drm/omap: dsi: use pixel-format and mode from attach
  drm/omap: panel-dsi-cm: use bulk regulator API
  drm/omap: dsi: lp/hs switching support for transfer()
  drm/omap: dsi: move TE GPIO handling into core
  drm/omap: dsi: drop custom enable_te() API
  drm/omap: dsi: do bus locking in host driver
  drm/omap: dsi: untangle ulps ops from enable/disable
  drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE
  drm/omap: dsi: do ULPS in host driver
  drm/omap: dsi: move panel refresh function to host
  drm/omap: dsi: Reverse direction of the DSS device enable/disable
operations
  drm/omap: dsi: convert to drm_panel
  drm/omap: dsi: use atomic helper for dirtyfb
  drm/omap: dsi: implement check timings
  drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO
  drm/omap: panel-dsi-cm: support unbinding
  drm/omap: panel-dsi-cm: fix remove()
  drm/omap: panel-dsi-cm: do not power on/off twice
  drm/omap: dsi: return proper error code from dsi_update_all()
  drm/omap: dsi: support panel un/re-binding
  ARM: dts: omap4-droid4: add panel compatible
  drm/panel: Move OMAP's DSI command mode panel driver

 .../bindings/display/panel/panel-dsi-cm.txt   |4 +-
 arch/arm/boot/dts/omap3-n950.dts  |3 +-
 arch/arm/boot/dts/omap3.dtsi  |3 +
 arch/arm/boot/dts/omap4-droid4-xt894.dts  |5 +-
 arch/arm/boot/dts/omap4-sdp.dts   |6 +-
 arch/arm/boot/dts/omap4.dtsi  |6 +
 arch/arm/boot/dts/omap5.dtsi  |6 +
 drivers/gpu/drm/omapdrm/displays/Kconfig  |6 -
 drivers/gpu/drm/omapdrm/displays/Makefile |1 -
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 1387 -
 drivers/gpu/drm/omapdrm/dss/Kconfig   |1 +
 drivers/gpu/drm/omapdrm/dss/base.c|2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c | 1019 
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   81 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |   37 +-
 drivers/gpu/drm/omapdrm/omap_crtc.h   |1 -
 drivers/gpu/drm/omapdrm/omap_encoder.c|   20 +-
 drivers/gpu/drm/omapdrm/omap_fb.c |   21 +-
 drivers/gpu/drm/panel/Kconfig |9 +
 drivers/gpu/drm/panel/Makefile|1 +
 drivers/gpu/drm/panel/panel-dsi-cm.c  |  646 
 include/drm/drm_mipi_dsi.h|2 +
 23 files changed, 1385 insertions(+), 1883 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
 create mode 100644 drivers/gpu/drm/panel/panel-dsi-cm.c


base-commit: 17cc51390c141662748dbbc2fe98f3ed10f2e13e
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 28/42] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE

2019-11-17 Thread Sebastian Reichel
DSI command mode panels are self-refreshing displays, that
can be updated very rarely for static images. For this kind
of scenario some panels support, that the DSI bus switches
into ULPS mode until the panel needs to be refreshed.

This is problematic on some panels, so introduce a flag to
signal the DSI host implementation that the panel allows
going into ULPS mode.

Signed-off-by: Sebastian Reichel 
---
 include/drm/drm_mipi_dsi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 13cf2ae59f6c..5f2e3e6fb013 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -131,6 +131,8 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct 
device_node *node);
 #define MIPI_DSI_CLOCK_NON_CONTINUOUS  BIT(10)
 /* transmit data in low power */
 #define MIPI_DSI_MODE_LPM  BIT(11)
+/* allow going into ULPS mode while command mode panel is not updated */
+#define MIPI_DSI_MODE_ULPS_IDLEBIT(12)
 
 enum mipi_dsi_pixel_format {
MIPI_DSI_FMT_RGB888,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 6/8] drm/xen: Simplify fb_create

2019-11-17 Thread Oleksandr Andrushchenko
On 11/15/19 11:21 AM, Daniel Vetter wrote:
> The current code is a pretty good wtf moment, since we drop the
> reference before we use it. It's not a big deal, because a) we only
> use the pointer, so doesn't blow up and the real reason b) fb->obj[0]
> already holds a full reference for us.
>
> Might as well take the real pointer ins't of complicated games that
> baffle.
>
> Signed-off-by: Daniel Vetter 
> Cc: Oleksandr Andrushchenko 
> Cc: xen-de...@lists.xenproject.org
Reviewed-by: Oleksandr Andrushchenko 
> ---
>   drivers/gpu/drm/xen/xen_drm_front_kms.c | 9 +
>   1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/xen/xen_drm_front_kms.c 
> b/drivers/gpu/drm/xen/xen_drm_front_kms.c
> index ff506bc99414..4f34c5208180 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front_kms.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front_kms.c
> @@ -63,14 +63,7 @@ fb_create(struct drm_device *dev, struct drm_file *filp,
>   if (IS_ERR_OR_NULL(fb))
>   return fb;
>   
> - gem_obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
> - if (!gem_obj) {
> - DRM_ERROR("Failed to lookup GEM object\n");
> - ret = -ENOENT;
> - goto fail;
> - }
> -
> - drm_gem_object_put_unlocked(gem_obj);
> + gem_obj = fb->obj[0];
>   
>   ret = xen_drm_front_fb_attach(drm_info->front_info,
> xen_drm_front_dbuf_to_cookie(gem_obj),
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 35/42] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO

2019-11-17 Thread Sebastian Reichel
Use DEVICE_ATTR_RO helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 84b0e79c025e..0148f40eceb2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -219,7 +219,7 @@ static const struct backlight_ops dsicm_bl_ops = {
.update_status  = dsicm_bl_update_status,
 };
 
-static ssize_t dsicm_num_errors_show(struct device *dev,
+static ssize_t num_dsi_errors_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -239,7 +239,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", errors);
 }
 
-static ssize_t dsicm_hw_revision_show(struct device *dev,
+static ssize_t hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -259,8 +259,8 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
 }
 
-static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
-static DEVICE_ATTR(hw_revision, S_IRUGO, dsicm_hw_revision_show, NULL);
+static DEVICE_ATTR_RO(num_dsi_errors);
+static DEVICE_ATTR_RO(hw_revision);
 
 static struct attribute *dsicm_attrs[] = {
_attr_num_dsi_errors.attr,
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 0/2] drm/nouveau: remove some set but not used variables

2019-11-17 Thread zhengbin
zhengbin (2):
  drm/nouveau: remove set but not used variable 'pclks','width'
  drm/nouveau: remove set but not used variable 'mem'

 drivers/gpu/drm/nouveau/dispnv04/arb.c | 6 ++
 drivers/gpu/drm/nouveau/nouveau_ttm.c  | 4 
 2 files changed, 2 insertions(+), 8 deletions(-)

--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 5/6] drm/radeon: remove set but not used variable 'blocks'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/radeon/radeon_combios.c: In function 
radeon_combios_get_power_modes:
drivers/gpu/drm/radeon/radeon_combios.c:2638:10: warning: variable blocks set 
but not used [-Wunused-but-set-variable]

It is introduced by commit 56278a8edace ("drm/radeon/kms:
pull power mode info from bios tables (v3)"), but never used,
so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/radeon/radeon_combios.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_combios.c 
b/drivers/gpu/drm/radeon/radeon_combios.c
index c18ae15..8779412 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -2638,7 +2638,7 @@ void radeon_combios_get_power_modes(struct radeon_device 
*rdev)
 {
struct drm_device *dev = rdev->ddev;
u16 offset, misc, misc2 = 0;
-   u8 rev, blocks, tmp;
+   u8 rev, tmp;
int state_index = 0;
struct radeon_i2c_bus_rec i2c_bus;

@@ -2731,7 +2731,6 @@ void radeon_combios_get_power_modes(struct radeon_device 
*rdev)
offset = combios_get_table_offset(dev, 
COMBIOS_POWERPLAY_INFO_TABLE);
if (offset) {
rev = RBIOS8(offset);
-   blocks = RBIOS8(offset + 0x2);
/* power mode 0 tends to be the only valid one */
rdev->pm.power_state[state_index].num_clock_modes = 1;
rdev->pm.power_state[state_index].clock_info[0].mclk = 
RBIOS32(offset + 0x5 + 0x2);
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 20/42] drm/omap: dsi: drop useless sync()

2019-11-17 Thread Sebastian Reichel
The DSI sync() function only locks the bus and then releases
it again. Currently the only invocation is directly before
update(), which locks the bus anyways.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c| 18 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  1 -
 drivers/gpu/drm/omapdrm/omap_crtc.c|  3 ---
 3 files changed, 22 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 164f3a30d7f2..994880022d0c 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -845,23 +845,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
return r;
 }
 
-static int dsicm_sync(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-
-   dev_dbg(>dsi->dev, "sync\n");
-
-   mutex_lock(>lock);
-   src->ops->dsi.bus_lock(src);
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(>lock);
-
-   dev_dbg(>dsi->dev, "sync done\n");
-
-   return 0;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct omap_dss_device *src = ddata->src;
@@ -950,7 +933,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 
 static const struct omap_dss_driver dsicm_dss_driver = {
.update = dsicm_update,
-   .sync   = dsicm_sync,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index bc583346af4d..cd9769711b58 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -409,7 +409,6 @@ struct omap_dss_device {
 struct omap_dss_driver {
int (*update)(struct omap_dss_device *dssdev,
   u16 x, u16 y, u16 w, u16 h);
-   int (*sync)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 3c5ddbf30e97..8b469eaa5005 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -379,9 +379,6 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
return;
}
 
-   if (dssdrv->sync)
-   dssdrv->sync(dssdev);
-
ret = dssdrv->update(dssdev, 0, 0, mode->hdisplay, mode->vdisplay);
if (ret < 0) {
spin_lock_irq(>event_lock);
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 30/42] drm/omap: dsi: move panel refresh function to host

2019-11-17 Thread Sebastian Reichel
This moves the panel refresh/update function from the panel
driver into the DSI host driver to prepare for common drm_panel
support.

Signed-off-by: Sebastian Reichel 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  68 
 drivers/gpu/drm/omapdrm/dss/dsi.c | 101 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   7 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  11 +-
 4 files changed, 97 insertions(+), 90 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 56398e2aec2d..9bfc262f5c5a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -177,27 +177,6 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 
*id1, u8 *id2, u8 *id3)
return 0;
 }
 
-static int dsicm_set_update_window(struct panel_drv_data *ddata,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   int r;
-   u16 x1 = x;
-   u16 x2 = x + w - 1;
-   u16 y1 = y;
-   u16 y2 = y + h - 1;
-
-   r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
-   if (r < 0)
-   return r;
-
-   r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
-   if (r < 0)
-   return r;
-
-   return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(>dev);
@@ -470,48 +449,6 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(>lock);
 }
 
-static void dsicm_framedone_cb(int err, void *data)
-{
-   struct panel_drv_data *ddata = data;
-
-   dev_dbg(>dsi->dev, "framedone, err %d\n", err);
-   mutex_unlock(>lock);
-}
-
-static int dsicm_update(struct omap_dss_device *dssdev,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   dev_dbg(>dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
-
-   mutex_lock(>lock);
-
-   if (!ddata->enabled) {
-   r = 0;
-   goto err;
-   }
-
-   /* XXX no need to send this every frame, but dsi break if not done */
-   r = dsicm_set_update_window(ddata, 0, 0, ddata->vm.hactive,
-   ddata->vm.vactive);
-   if (r)
-   goto err;
-
-   r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
-   ddata);
-   if (r)
-   goto err;
-
-   /* note: no unlock here. unlock is src framedone_cb */
-   return 0;
-err:
-   mutex_unlock(>lock);
-   return r;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct mipi_dsi_device *dsi = ddata->dsi;
@@ -572,10 +509,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
.check_timings  = dsicm_check_timings,
 };
 
-static const struct omap_dss_driver dsicm_dss_driver = {
-   .update = dsicm_update,
-};
-
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
struct device_node *node = dsi->dev.of_node;
@@ -660,7 +593,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
dssdev = >dssdev;
dssdev->dev = dev;
dssdev->ops = _ops;
-   dssdev->driver = _dss_driver;
dssdev->type = OMAP_DISPLAY_TYPE_DSI;
dssdev->display = true;
dssdev->owner = THIS_MODULE;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 35c0ce72cd15..66ad7dbc66a2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -217,6 +217,9 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+  const struct mipi_dsi_msg *msg);
+
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC0
 #define HSDIV_DSI  1
@@ -386,9 +389,6 @@ struct dsi_data {
 
struct delayed_work ulps_work;
 
-   void (*framedone_callback)(int, void *);
-   void *framedone_data;
-
struct delayed_work framedone_timeout_work;
 
 #ifdef DSI_CATCH_MISSING_TE
@@ -3809,8 +3809,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, 
int error)
dsi_set_ulps_auto(dsi, true);
dsi_bus_unlock(dsi);
 
-   dsi->framedone_callback(error, dsi->framedone_data);
-
if (!error)
dsi_perf_show(dsi, "DISPC");
 }
@@ -3842,6 +3840,8 @@ static void dsi_framedone_irq_callback(void *data)
 
cancel_delayed_work(>framedone_timeout_work);
 
+   DSSDBG("Framedone received!\n");
+
dsi_handle_framedone(dsi, 0);
 }
 
@@ -3863,17 +3863,69 @@ static int _dsi_update(struct dsi_data *dsi)
return 0;
 }
 
-static int 

[PATCH] video: fbdev: vesafb: add missed release_region

2019-11-17 Thread Chuhong Yuan
This driver calls request_region in probe but forgets to call
release_region in probe failure and remove.
Add the missed calls to fix it.

Signed-off-by: Chuhong Yuan 
---
 drivers/video/fbdev/vesafb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index d9c08f6c2155..fbb196a8bbf6 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -468,6 +468,7 @@ static int vesafb_probe(struct platform_device *dev)
fb_info(info, "%s frame buffer device\n", info->fix.id);
return 0;
 err:
+   release_region(0x3c0, 32);
arch_phys_wc_del(par->wc_cookie);
if (info->screen_base)
iounmap(info->screen_base);
@@ -480,6 +481,7 @@ static int vesafb_remove(struct platform_device *pdev)
 {
struct fb_info *info = platform_get_drvdata(pdev);
 
+   release_region(0x3c0, 32);
unregister_framebuffer(info);
framebuffer_release(info);
 
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RFCv1 11/42] ARM: dts: omap: add channel to DSI panels

2019-11-17 Thread Sebastian Reichel
The standard binding for DSI requires, that the channel number
of the panel is encoded in DT. This adds the channel number in
all OMAP3-5 boards, in preparation for using common infrastructure.

Signed-off-by: Sebastian Reichel 
---
 .../devicetree/bindings/display/panel/panel-dsi-cm.txt  | 4 +++-
 arch/arm/boot/dts/omap3-n950.dts| 3 ++-
 arch/arm/boot/dts/omap3.dtsi| 3 +++
 arch/arm/boot/dts/omap4-droid4-xt894.dts| 3 ++-
 arch/arm/boot/dts/omap4-sdp.dts | 6 --
 arch/arm/boot/dts/omap4.dtsi| 6 ++
 arch/arm/boot/dts/omap5.dtsi| 6 ++
 7 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt 
b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
index dce48eb9db57..f92d5c9adfc5 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
+++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
@@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel
 
 Required properties:
 - compatible: "panel-dsi-cm"
+- reg: DSI channel number
 
 Optional properties:
 - label: a symbolic name for the panel
@@ -15,9 +16,10 @@ Required nodes:
 Example
 ---
 
-lcd0: display {
+lcd0: panel@0 {
compatible = "tpo,taal", "panel-dsi-cm";
label = "lcd0";
+   reg = <0>;
 
reset-gpios = < 6 GPIO_ACTIVE_HIGH>;
 
diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 9886bf8b90ab..d1dfafde351e 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -225,8 +225,9 @@
};
};
 
-   lcd0: display {
+   lcd0: panel@0 {
compatible = "nokia,himalaya", "panel-dsi-cm";
+   reg = <0>;
label = "lcd0";
 
pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 4043ecb38016..b872b933f2cb 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -771,6 +771,9 @@
ti,hwmods = "dss_dsi1";
clocks = <_alwon_fck>, <_alwon_fck>;
clock-names = "fck", "sys_clk";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
};
 
rfbi: encoder@48050800 {
diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts 
b/arch/arm/boot/dts/omap4-droid4-xt894.dts
index a40fe8d49da6..6af0a9288940 100644
--- a/arch/arm/boot/dts/omap4-droid4-xt894.dts
+++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts
@@ -202,8 +202,9 @@
};
};
 
-   lcd0: display {
+   lcd0: panel@0 {
compatible = "panel-dsi-cm";
+   reg = <0>;
label = "lcd0";
vddi-supply = <_regulator>;
reset-gpios = < 5 GPIO_ACTIVE_HIGH>;  /* gpio101 */
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index 91480ac1f328..8a8307517dab 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -662,8 +662,9 @@
};
};
 
-   lcd0: display {
+   lcd0: panel@0 {
compatible = "tpo,taal", "panel-dsi-cm";
+   reg = <0>;
label = "lcd0";
 
reset-gpios = < 6 GPIO_ACTIVE_HIGH>;  /* 102 */
@@ -687,8 +688,9 @@
};
};
 
-   lcd1: display {
+   lcd1: panel@0 {
compatible = "tpo,taal", "panel-dsi-cm";
+   reg = <0>;
label = "lcd1";
 
reset-gpios = < 8 GPIO_ACTIVE_HIGH>;  /* 104 */
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 7cc95bc1598b..a0807cd90eff 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -403,6 +403,9 @@
clocks = <_dss_clkctrl 
OMAP4_DSS_CORE_CLKCTRL 8>,
 <_dss_clkctrl 
OMAP4_DSS_CORE_CLKCTRL 10>;
clock-names = "fck", "sys_clk";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
};
 
dsi2: encoder@58005000 {
@@ -417,6 +420,9 @@
clocks = <_dss_clkctrl 
OMAP4_DSS_CORE_CLKCTRL 8>,
 <_dss_clkctrl 
OMAP4_DSS_CORE_CLKCTRL 10>;
clock-names = "fck", "sys_clk";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
};
 
hdmi: encoder@58006000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi 

[PATCH 1/2] drm/nouveau: remove set but not used variable 'pclks', 'width'

2019-11-17 Thread zhengbin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/nouveau/dispnv04/arb.c: In function nv04_calc_arb:
drivers/gpu/drm/nouveau/dispnv04/arb.c:59:21: warning: variable pclks set but 
not used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/dispnv04/arb.c: In function nv04_calc_arb:
drivers/gpu/drm/nouveau/dispnv04/arb.c:58:21: warning: variable width set but 
not used [-Wunused-but-set-variable]

It is introduced by commit 6ee738610f41 ("drm/nouveau:
Add DRM driver for NVIDIA GPUs"), but never used,
so remove it.

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/gpu/drm/nouveau/dispnv04/arb.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c 
b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index 3624955..9d4a2d9 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -53,8 +53,8 @@ struct nv_sim_state {
 static void
 nv04_calc_arb(struct nv_fifo_info *fifo, struct nv_sim_state *arb)
 {
-   int pagemiss, cas, width, bpp;
-   int nvclks, mclks, pclks, crtpagemiss;
+   int pagemiss, cas, bpp;
+   int nvclks, mclks, crtpagemiss;
int found, mclk_extra, mclk_loop, cbs, m1, p1;
int mclk_freq, pclk_freq, nvclk_freq;
int us_m, us_n, us_p, crtc_drain_rate;
@@ -65,11 +65,9 @@ nv04_calc_arb(struct nv_fifo_info *fifo, struct nv_sim_state 
*arb)
nvclk_freq = arb->nvclk_khz;
pagemiss = arb->mem_page_miss;
cas = arb->mem_latency;
-   width = arb->memory_width >> 6;
bpp = arb->bpp;
cbs = 128;

-   pclks = 2;
nvclks = 10;
mclks = 13 + cas;
mclk_extra = 3;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel