Re: BUG: unable to handle kernel paging request in vsock_diag_dump

2017-10-26 Thread Stefan Hajnoczi
On Tue, Oct 24, 2017 at 08:14:01AM -0700, syzbot wrote:
> Hello,
> 
> syzkaller hit the following crash on
> 28f50eb20931f32a2ceeb6aba8fa2cd5ca96ad9f
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
> 
> 
> IP: read_pnet include/net/net_namespace.h:269 [inline]
> IP: sock_net include/net/sock.h:2299 [inline]
> IP: vsock_diag_dump+0x290/0xa80 net/vmw_vsock/diag.c:87

[   41.303353] BUG: unable to handle kernel paging request at fb70

Unfortunately the reproducer doesn't hit the issue on my machine (even
after multiple runs).

Is it possible to get the exact net/vmw_vsock/vsock_diag.ko file used in
this syzkaller run?  The machine code snippet below doesn't contain
enough context for me to understand the issue, and seeing the whole
module might help.

Thanks,
Stefan

> PGD 21fff4067 P4D 21fff4067 PUD 21fff3067 PMD 21fff2067 PTE 0
> Oops:  [#1] SMP KASAN
> Dumping ftrace buffer:
>(ftrace buffer empty)
> Modules linked in:
> CPU: 1 PID: 2986 Comm: syzkaller165749 Not tainted 4.14.0-rc3+ #76
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> task: 8801ceaaa1c0 task.stack: 8801ce0e
> RIP: 0010:read_pnet include/net/net_namespace.h:269 [inline]
> RIP: 0010:sock_net include/net/sock.h:2299 [inline]
> RIP: 0010:vsock_diag_dump+0x290/0xa80 net/vmw_vsock/diag.c:87
> RSP: 0018:8801ce0e73d0 EFLAGS: 00010a02
> RAX: 1f70 RBX: fb50 RCX: 
> RDX:  RSI: 83f09694 RDI: fb80
> RBP: 8801ce0e74e0 R08: 8801ce0e6d20 R09: 8801ce0e6d18
> R10: 8801ce0e6c90 R11: 110039d556cb R12: dc00
> R13:  R14: 87962d20 R15: 8801ce0e74b8
> FS:  0152a880() GS:8801db30() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: fb70 CR3: 0001ce70f000 CR4: 001406e0
> DR0:  DR1:  DR2: 
> DR3:  DR6: fffe0ff0 DR7: 0400
> Call Trace:
>  netlink_dump+0x46b/0xb90 net/netlink/af_netlink.c:2186
>  __netlink_dump_start+0x4e9/0x710 net/netlink/af_netlink.c:2278
>  netlink_dump_start include/linux/netlink.h:216 [inline]
>  vsock_diag_handler_dump+0x206/0x2c0 net/vmw_vsock/diag.c:161
>  __sock_diag_cmd net/core/sock_diag.c:231 [inline]
>  sock_diag_rcv_msg+0x204/0x390 net/core/sock_diag.c:263
>  netlink_rcv_skb+0x216/0x440 net/netlink/af_netlink.c:2408
>  sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:274
>  netlink_unicast_kernel net/netlink/af_netlink.c:1273 [inline]
>  netlink_unicast+0x4e8/0x6f0 net/netlink/af_netlink.c:1299
>  netlink_sendmsg+0xa4a/0xe70 net/netlink/af_netlink.c:1862
>  sock_sendmsg_nosec net/socket.c:633 [inline]
>  sock_sendmsg+0xca/0x110 net/socket.c:643
>  sock_write_iter+0x320/0x5e0 net/socket.c:912
>  call_write_iter include/linux/fs.h:1770 [inline]
>  do_iter_readv_writev+0x531/0x7f0 fs/read_write.c:673
>  do_iter_write+0x15a/0x540 fs/read_write.c:952
>  vfs_writev+0x18a/0x340 fs/read_write.c:997
>  do_writev+0xfc/0x2a0 fs/read_write.c:1032
>  SYSC_writev fs/read_write.c:1105 [inline]
>  SyS_writev+0x27/0x30 fs/read_write.c:1102
>  entry_SYSCALL_64_fastpath+0x1f/0xbe
> RIP: 0033:0x43fd69
> RSP: 002b:7fff5da11d98 EFLAGS: 0203 ORIG_RAX: 0014
> RAX: ffda RBX: 004002c8 RCX: 0043fd69
> RDX: 0001 RSI: 206a3ff0 RDI: 0003
> RBP: 0086 R08:  R09: 
> R10:  R11: 0203 R12: 004016d0
> R13: 00401760 R14:  R15: 
> Code: 69 07 00 00 48 8b 83 b0 04 00 00 49 39 c6 48 8d 98 50 fb ff ff 0f 84
> ce 03 00 00 e8 bb a2 9f fc 48 8d 7b 30 48 89 f8 48 c1 e8 03 <42> 80 3c 20 00
> 0f 85 2d 07 00 00 48 8b 85 70 ff ff ff 48 3b 43
> RIP: read_pnet include/net/net_namespace.h:269 [inline] RSP:
> 8801ce0e73d0
> RIP: sock_net include/net/sock.h:2299 [inline] RSP: 8801ce0e73d0
> RIP: vsock_diag_dump+0x290/0xa80 net/vmw_vsock/diag.c:87 RSP:
> 8801ce0e73d0
> CR2: fb70
> ---[ end trace 9852ce58edddbce7 ]---
> 
> 
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkal...@googlegroups.com.
> 
> syzbot will keep track of this bug report.
> Once a fix for this bug is committed, please reply to this email with:
> #syz fix: exact-commit-title
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> If it's a one-off invalid bug report, please reply with:
> #syz invalid
> Note: if the crash happens aga

Re: BUG: unable to handle kernel paging request in vsock_diag_dump

2017-10-26 Thread Stefan Hajnoczi
On Tue, Oct 24, 2017 at 08:14:01AM -0700, syzbot wrote:
> Hello,
> 
> syzkaller hit the following crash on
> 28f50eb20931f32a2ceeb6aba8fa2cd5ca96ad9f
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
> 
> 
> IP: read_pnet include/net/net_namespace.h:269 [inline]
> IP: sock_net include/net/sock.h:2299 [inline]
> IP: vsock_diag_dump+0x290/0xa80 net/vmw_vsock/diag.c:87

Feel free to ignore my previous reply, Cong Wang
 has already found the root cause.  Thank you!

Stefan
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: BUG: unable to handle kernel paging request in vsock_diag_dump

2017-10-26 Thread Dmitry Vyukov via Virtualization
On Thu, Oct 26, 2017 at 10:18 AM, Stefan Hajnoczi  wrote:
> On Tue, Oct 24, 2017 at 08:14:01AM -0700, syzbot wrote:
>> Hello,
>>
>> syzkaller hit the following crash on
>> 28f50eb20931f32a2ceeb6aba8fa2cd5ca96ad9f
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
>> compiler: gcc (GCC) 7.1.1 20170620
>> .config is attached
>> Raw console output is attached.
>> C reproducer is attached
>> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
>> for information about syzkaller reproducers
>>
>>
>> IP: read_pnet include/net/net_namespace.h:269 [inline]
>> IP: sock_net include/net/sock.h:2299 [inline]
>> IP: vsock_diag_dump+0x290/0xa80 net/vmw_vsock/diag.c:87
>
> Feel free to ignore my previous reply, Cong Wang
>  has already found the root cause.  Thank you!


Hi Stefan,

For future reference, you can recreate the build by using the provided
config, running make olddefconfig and building with compiler
referenced here:
https://github.com/google/syzkaller/blob/master/docs/syzbot.md#crash-does-not-reproduce
Also syzbot has obtained the provided crash report on the provided
reproducer on a freshly-booted machine, so the reproducer worked for
it somehow. You still may have a somewhat different setup, so it won't
reproduce for you, but I have high assurance that the reproducer is
valid.

Also please don't ignore this part. It will greatly help to keep the
whole process running. Otherwise the bot won't be able to provide all
crashes it finds.

> syzbot will keep track of this bug report.
> Once a fix for this bug is committed, please reply to this email with:
> #syz fix: exact-commit-title
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> Note: all commands must start from beginning of the line.

Thanks
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] maintainers: drop Chris Wright from pvops

2017-10-26 Thread Juergen Gross
Mails to chr...@sous-sol.org are not deliverable since several months.
Drop him as PARAVIRT_OPS maintainer.

Signed-off-by: Juergen Gross 
---
 MAINTAINERS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d85c08956875..af0cb69f6a3e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10179,7 +10179,6 @@ F:  Documentation/parport*.txt
 
 PARAVIRT_OPS INTERFACE
 M: Juergen Gross 
-M: Chris Wright 
 M: Alok Kataria 
 M: Rusty Russell 
 L: virtualization@lists.linux-foundation.org
-- 
2.12.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] virtio/ringtest: fix up need_event math

2017-10-26 Thread Jason Wang



On 2017年10月26日 09:48, Michael S. Tsirkin wrote:

last kicked event index must be updated unconditionally:
even if we don't need to kick, we do not want to re-check
the same entry for events.

Signed-off-by: Michael S. Tsirkin 
---
  tools/virtio/ringtest/ring.c | 24 +++-
  1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index 6b70c4e..d044a88 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -196,16 +196,18 @@ bool enable_call()
  
  void kick_available(void)

  {
+   bool need;
+
/* Flush in previous flags write */
/* Barrier C (for pairing) */
smp_mb();
-   if (!need_event(event->kick_index,
-   guest.avail_idx,
-   guest.kicked_avail_idx))
-   return;
+   need = need_event(event->kick_index,
+  guest.avail_idx,
+  guest.kicked_avail_idx);
  
  	guest.kicked_avail_idx = guest.avail_idx;

-   kick();
+   if (need)
+   kick();
  }
  
  /* host side */

@@ -265,14 +267,18 @@ bool use_buf(unsigned *lenp, void **bufp)
  
  void call_used(void)

  {
+   bool need;
+
/* Flush in previous flags write */
/* Barrier D (for pairing) */
smp_mb();
-   if (!need_event(event->call_index,
+
+   need = !need_event(event->call_index,
host.used_idx,
-   host.called_used_idx))
-   return;
+   host.called_used_idx);
  
  	host.called_used_idx = host.used_idx;

-   call();
+
+   if (need)
+   call();
  }


Acked-by: Jason Wang 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: BUG: unable to handle kernel paging request in vsock_diag_dump

2017-10-26 Thread Cong Wang
#syz fix: vsock: always call vsock_init_tables()
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] maintainers: drop Chris Wright from pvops

2017-10-26 Thread Chris Wright
Acked-by: Chris Wright 

;)


thanks,
-chris

On Oct 26, 2017 7:41 PM, "Rusty Russell"  wrote:

> Chris CC'd: He wasn't that hard to find.
>
> (linkedin says he's CTO of RedHat now.  I feel like an underachiever!)
>
> Cheers,
> Rusty.
>
> Juergen Gross  writes:
>
> > Mails to chr...@sous-sol.org are not deliverable since several months.
> > Drop him as PARAVIRT_OPS maintainer.
> >
> > Signed-off-by: Juergen Gross 
> > ---
> >  MAINTAINERS | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index d85c08956875..af0cb69f6a3e 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -10179,7 +10179,6 @@ F:Documentation/parport*.txt
> >
> >  PARAVIRT_OPS INTERFACE
> >  M:   Juergen Gross 
> > -M:   Chris Wright 
> >  M:   Alok Kataria 
> >  M:   Rusty Russell 
> >  L:   virtualization@lists.linux-foundation.org
> > --
> > 2.12.3
>
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH 00/11] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
Hi!

While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.

Boris and Daniel, was this approximately what you had in mind?

I have obviously not tested all of this with more than a compile,
but the first patch is enough to make the atmel-hlcdc driver
do what I need. The rest is just lots of removals and cleanup
made possible by the improved core.

Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere in this mostly mechanical change...

Cheers,
peda

Peter Rosin (11):
  drm/fb-helper: do a generic fb_setcmap helper in terms of crtc
.gamma_set
  drm: amd: remove dead code and pointless local lut storage
  drm: ast: remove dead code and pointless local lut storage
  drm: cirrus: remove dead code and pointless local lut storage
  dmr: gma500: remove dead code and pointless local lut storage
  drm: i915: remove dead code and pointless local lut storage
  drm: mgag200: remove dead code and pointless local lut storage
  drm: nouveau: remove dead code and pointless local lut storage
  drm: radeon: remove dead code and pointless local lut storage
  drm: stm: remove dead code and pointless local lut storage
  drm: remove unused and redundant callbacks

 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  24 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|   1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  27 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  27 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  27 ++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  27 ++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c|  23 -
 drivers/gpu/drm/ast/ast_drv.h   |   1 -
 drivers/gpu/drm/ast/ast_fb.c|  20 -
 drivers/gpu/drm/ast/ast_mode.c  |  26 ++
 drivers/gpu/drm/cirrus/cirrus_drv.h |   8 --
 drivers/gpu/drm/cirrus/cirrus_fbdev.c   |   2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c|  71 ---
 drivers/gpu/drm/drm_fb_helper.c | 131 +---
 drivers/gpu/drm/gma500/framebuffer.c|  22 -
 drivers/gpu/drm/gma500/gma_display.c|  32 +++
 drivers/gpu/drm/gma500/psb_intel_display.c  |   7 +-
 drivers/gpu/drm/gma500/psb_intel_drv.h  |   1 -
 drivers/gpu/drm/i915/intel_drv.h|   1 -
 drivers/gpu/drm/i915/intel_fbdev.c  |  31 ---
 drivers/gpu/drm/mgag200/mgag200_drv.h   |   5 --
 drivers/gpu/drm/mgag200/mgag200_fb.c|   2 -
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  62 -
 drivers/gpu/drm/nouveau/dispnv04/crtc.c |  26 ++
 drivers/gpu/drm/nouveau/nouveau_crtc.h  |   3 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |  22 -
 drivers/gpu/drm/nouveau/nv50_display.c  |  39 +++--
 drivers/gpu/drm/radeon/atombios_crtc.c  |   1 -
 drivers/gpu/drm/radeon/radeon_connectors.c  |   7 +-
 drivers/gpu/drm/radeon/radeon_display.c |  71 ++-
 drivers/gpu/drm/radeon/radeon_fb.c  |   2 -
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |   1 -
 drivers/gpu/drm/stm/ltdc.c  |  12 ---
 drivers/gpu/drm/stm/ltdc.h  |   1 -
 include/drm/drm_fb_helper.h |  32 ---
 include/drm/drm_modeset_helper_vtables.h|  16 
 36 files changed, 171 insertions(+), 640 deletions(-)

-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] virtio: virtio_mmio: make of_device_ids const.

2017-10-26 Thread Arvind Yadav
of_device_ids are not supposed to change at runtime. All functions
working with of_device_ids provided by  work with const
of_device_ids. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
   3647 608   04255109f drivers/virtio/virtio_mmio.o

File size after constify virtio_mmio_match.
   textdata bss dec hex filename
   4063 192   04255109f drivers/virtio/virtio_mmio.o

Signed-off-by: Arvind Yadav 
---
 drivers/virtio/virtio_mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 74dc717..badf61d 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -713,7 +713,7 @@ static void vm_unregister_cmdline_devices(void)
 
 /* Platform driver */
 
-static struct of_device_id virtio_mmio_match[] = {
+static const struct of_device_id virtio_mmio_match[] = {
{ .compatible = "virtio,mmio", },
{},
 };
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 02/11] drm: amd: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   | 24 
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |  1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   | 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   | 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c| 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c| 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 23 ---
 7 files changed, 28 insertions(+), 128 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c0d8c6f..7dc3780 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -312,31 +312,7 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, 
struct amdgpu_fbdev *rfb
return 0;
 }
 
-/** Sets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   amdgpu_crtc->lut_r[regno] = red >> 6;
-   amdgpu_crtc->lut_g[regno] = green >> 6;
-   amdgpu_crtc->lut_b[regno] = blue >> 6;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
- u16 *blue, int regno)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   *red = amdgpu_crtc->lut_r[regno] << 6;
-   *green = amdgpu_crtc->lut_g[regno] << 6;
-   *blue = amdgpu_crtc->lut_b[regno] << 6;
-}
-
 static const struct drm_fb_helper_funcs amdgpu_fb_helper_funcs = {
-   .gamma_set = amdgpu_crtc_fb_gamma_set,
-   .gamma_get = amdgpu_crtc_fb_gamma_get,
.fb_probe = amdgpufb_create,
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 43a9d3a..39f7eda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -369,7 +369,6 @@ struct amdgpu_atom_ss {
 struct amdgpu_crtc {
struct drm_crtc base;
int crtc_id;
-   u16 lut_r[256], lut_g[256], lut_b[256];
bool enabled;
bool can_tile;
uint32_t crtc_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 3c62c45..8e8c028 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2264,6 +2264,7 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
u32 tmp;
 
@@ -2301,11 +2302,14 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc 
*crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x0007);
 
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
-  (amdgpu_crtc->lut_r[i] << 20) |
-  (amdgpu_crtc->lut_g[i] << 10) |
-  (amdgpu_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 
tmp = RREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset);
@@ -2621,15 +2625,6 @@ static int dce_v10_0_crtc_gamma_set(struct drm_crtc 
*crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
 {
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   int i;
-
-   /* userspace palettes are always correct as is */
-   for (i = 0; i < size; i++) {
-   amdgpu_crtc->lut_r[i] = red[i] >> 6;
-   amdgpu_crtc->lut_g[i] = green[i] >> 6;
-   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
-   }
dce_v10_0_crtc_load_lut(crtc);
 
return 0;
@@ -2841,14 +2836,12 @@ static const struct drm_crtc_helper_funcs 
dce_v10_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v10_0_crtc_set_base_atomic,
.prepare = dce_v10_0_crtc_prepare,
.commit = dce_v10_0_crtc_commit,
-   .load_lut = dce_v10_0_crtc_load_lut,
.disable = dce_v10_0_crtc_disable,
 };
 
 static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int ind

[PATCH 04/11] drm: cirrus: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  8 
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 71 ---
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352..be2d7e48 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
struct drm_crtc base;
-   u8  lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
boolenabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 
-   /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
-
-
/* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
  struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..1fedab0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-   .gamma_set = cirrus_crtc_fb_gamma_set,
-   .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
 };
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 53f6f0f..a4c4a46 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   struct cirrus_device *cdev = dev->dev_private;
-   int i;
-
-   if (!crtc->enabled)
-   return;
-
-   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-   /* VGA registers */
-   WREG8(PALETTE_INDEX, i);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-   }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, 
u16 *red, u16 *green,
 u16 *blue, uint32_t size,
 struct drm_modeset_acquire_ctx *ctx)
 {
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct cirrus_device *cdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
-   for (i = 0; i < size; i++) {
-   cirrus_crtc->lut_r[i] = red[i];
-   cirrus_crtc->lut_g[i] = green[i];
-   cirrus_crtc->lut_b[i] = blue[i];
+   if (!crtc->enabled)
+   return 0;
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+   /* VGA registers */
+   WREG8(PALETTE_INDEX, i);
+   WREG8(PALETTE_DATA, *r++ >> 8);
+   WREG8(PALETTE_DATA, *g++ >> 8);
+   WREG8(PALETTE_DATA, *b++ >> 8);
}
-   cirrus_crtc_load_lut(crtc);
 
return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
-   .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
-   int i;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cde

[PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Peter Rosin
This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
totally obsolete.

I think the gamma_store can end up invalid on error. But the way I read
it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
this pesky legacy fbdev stuff be any better?

drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
it saves it to the gamma_store which should already be up to date with what
.gamma_get would return and is thus a nop. So, zap it.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 131 
 1 file changed, 40 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 574af01..cc2d55d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -229,22 +229,6 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
 
-static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct 
drm_fb_helper *helper)
-{
-   uint16_t *r_base, *g_base, *b_base;
-   int i;
-
-   if (helper->funcs->gamma_get == NULL)
-   return;
-
-   r_base = crtc->gamma_store;
-   g_base = r_base + crtc->gamma_size;
-   b_base = g_base + crtc->gamma_size;
-
-   for (i = 0; i < crtc->gamma_size; i++)
-   helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], 
&b_base[i], i);
-}
-
 static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
 {
uint16_t *r_base, *g_base, *b_base;
@@ -285,7 +269,6 @@ int drm_fb_helper_debug_enter(struct fb_info *info)
if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
continue;
 
-   drm_fb_helper_save_lut_atomic(mode_set->crtc, helper);
funcs->mode_set_base_atomic(mode_set->crtc,
mode_set->fb,
mode_set->x,
@@ -1167,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
 
-static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, u16 regno, struct fb_info *info)
-{
-   struct drm_fb_helper *fb_helper = info->par;
-   struct drm_framebuffer *fb = fb_helper->fb;
-
-   if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
-   u32 *palette;
-   u32 value;
-   /* place color in psuedopalette */
-   if (regno > 16)
-   return -EINVAL;
-   palette = (u32 *)info->pseudo_palette;
-   red >>= (16 - info->var.red.length);
-   green >>= (16 - info->var.green.length);
-   blue >>= (16 - info->var.blue.length);
-   value = (red << info->var.red.offset) |
-   (green << info->var.green.offset) |
-   (blue << info->var.blue.offset);
-   if (info->var.transp.length > 0) {
-   u32 mask = (1 << info->var.transp.length) - 1;
-
-   mask <<= info->var.transp.offset;
-   value |= mask;
-   }
-   palette[regno] = value;
-   return 0;
-   }
-
-   /*
-* The driver really shouldn't advertise pseudo/directcolor
-* visuals if it can't deal with the palette.
-*/
-   if (WARN_ON(!fb_helper->funcs->gamma_set ||
-   !fb_helper->funcs->gamma_get))
-   return -EINVAL;
-
-   WARN_ON(fb->format->cpp[0] != 1);
-
-   fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-   return 0;
-}
-
 /**
  * drm_fb_helper_setcmap - implementation for &fb_ops.fb_setcmap
  * @cmap: cmap to set
@@ -1220,51 +1159,61 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
 {
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
-   const struct drm_crtc_helper_funcs *crtc_funcs;
-   u16 *red, *green, *blue, *transp;
+   struct drm_modeset_acquire_ctx ctx;
struct drm_crtc *crtc;
-   int i, j, rc = 0;
-   int start;
+   u16 *r, *g, *b;
+   int i, ret;
 
if (oops_in_progress)
return -EBUSY;
 
-   drm_modeset_lock_all(dev);
+   if (cmap->start + cmap->len < cmap->start)
+   return -EINVAL;
+
+   drm_modeset_acquire_init(&ctx, 0);
+retry:
+   ret = drm_modeset_lock_all_ctx(dev, &ctx);
+   if (ret)
+   goto out;
if (!drm_fb_helper_is_bound(fb_helper)) {
-   drm_modeset_unlock_all(dev);
-   return -EBUSY;
+   ret = -EBUSY;
+   goto out;
}
 
for (i = 0; i < fb_helper->crtc_count; i++) {
crtc = fb_helper

[PATCH 03/11] drm: ast: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/ast/ast_drv.h  |  1 -
 drivers/gpu/drm/ast/ast_fb.c   | 20 
 drivers/gpu/drm/ast/ast_mode.c | 26 ++
 3 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 8880f0b..569a148 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -245,7 +245,6 @@ struct ast_connector {
 
 struct ast_crtc {
struct drm_crtc base;
-   u8 lut_r[256], lut_g[256], lut_b[256];
struct drm_gem_object *cursor_bo;
uint64_t cursor_addr;
int cursor_width, cursor_height;
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index 4ad4acd..dbabcac 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -255,27 +255,7 @@ static int astfb_create(struct drm_fb_helper *helper,
return ret;
 }
 
-static void ast_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-  u16 blue, int regno)
-{
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   ast_crtc->lut_r[regno] = red >> 8;
-   ast_crtc->lut_g[regno] = green >> 8;
-   ast_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-  u16 *blue, int regno)
-{
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   *red = ast_crtc->lut_r[regno] << 8;
-   *green = ast_crtc->lut_g[regno] << 8;
-   *blue = ast_crtc->lut_b[regno] << 8;
-}
-
 static const struct drm_fb_helper_funcs ast_fb_helper_funcs = {
-   .gamma_set = ast_fb_gamma_set,
-   .gamma_get = ast_fb_gamma_get,
.fb_probe = astfb_create,
 };
 
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index aaef0a6..724c16b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -63,15 +63,18 @@ static inline void ast_load_palette_index(struct 
ast_private *ast,
 static void ast_crtc_load_lut(struct drm_crtc *crtc)
 {
struct ast_private *ast = crtc->dev->dev_private;
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
+   u16 *r, *g, *b;
int i;
 
if (!crtc->enabled)
return;
 
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++)
-   ast_load_palette_index(ast, i, ast_crtc->lut_r[i],
-  ast_crtc->lut_g[i], ast_crtc->lut_b[i]);
+   ast_load_palette_index(ast, i, *r++ >> 8, *g++ >> 8, *b++ >> 8);
 }
 
 static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct 
drm_display_mode *mode,
@@ -633,7 +636,6 @@ static const struct drm_crtc_helper_funcs 
ast_crtc_helper_funcs = {
.mode_set = ast_crtc_mode_set,
.mode_set_base = ast_crtc_mode_set_base,
.disable = ast_crtc_disable,
-   .load_lut = ast_crtc_load_lut,
.prepare = ast_crtc_prepare,
.commit = ast_crtc_commit,
 
@@ -648,15 +650,6 @@ static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 
*red, u16 *green,
  u16 *blue, uint32_t size,
  struct drm_modeset_acquire_ctx *ctx)
 {
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   int i;
-
-   /* userspace palettes are always correct as is */
-   for (i = 0; i < size; i++) {
-   ast_crtc->lut_r[i] = red[i] >> 8;
-   ast_crtc->lut_g[i] = green[i] >> 8;
-   ast_crtc->lut_b[i] = blue[i] >> 8;
-   }
ast_crtc_load_lut(crtc);
 
return 0;
@@ -681,7 +674,6 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
 static int ast_crtc_init(struct drm_device *dev)
 {
struct ast_crtc *crtc;
-   int i;
 
crtc = kzalloc(sizeof(struct ast_crtc), GFP_KERNEL);
if (!crtc)
@@ -690,12 +682,6 @@ static int ast_crtc_init(struct drm_device *dev)
drm_crtc_init(dev, &crtc->base, &ast_crtc_funcs);
drm_mode_crtc_set_gamma_size(&crtc->base, 256);
drm_crtc_helper_add(&crtc->base, &ast_crtc_helper_funcs);
-
-   for (i = 0; i < 256; i++) {
-   crtc->lut_r[i] = i;
-   crtc->lut_g[i] = i;
-   crtc->lut_b[i] = i;
-   }
return 0;
 }
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


RE: [virtio-dev] packed ring layout proposal v2

2017-10-26 Thread Lior Narkis
> -Original Message-
> From: virtio-...@lists.oasis-open.org [mailto:virtio-...@lists.oasis-open.org]
> On Behalf Of Michael S. Tsirkin
> Sent: Wednesday, February 08, 2017 5:20 AM
> To: virtio-...@lists.oasis-open.org
> Cc: virtualization@lists.linux-foundation.org
> Subject: [virtio-dev] packed ring layout proposal v2
> 
> This is an update from v1 version.
> Changes:
> - update event suppression mechanism
> - separate options for indirect and direct s/g
> - lots of new features
> 
> ---
> 
> Performance analysis of this is in my kvm forum 2016 presentation.
> The idea is to have a r/w descriptor in a ring structure,
> replacing the used and available ring, index and descriptor
> buffer.
> 
> * Descriptor ring:
> 
> Guest adds descriptors with unique index values and DESC_HW set in flags.
> Host overwrites used descriptors with correct len, index, and DESC_HW
> clear.  Flags are always set/cleared last.
> 
> #define DESC_HW 0x0080
> 
> struct desc {
> __le64 addr;
> __le32 len;
> __le16 index;
> __le16 flags;
> };
> 
> When DESC_HW is set, descriptor belongs to device. When it is clear,
> it belongs to the driver.
> 
> We can use 1 bit to set direction
> /* This marks a buffer as write-only (otherwise read-only). */
> #define VRING_DESC_F_WRITE  2
> 

A valid bit per descriptor does not let the device do an efficient prefetch.
An alternative is to use a producer index(PI).
Using the PI posted by the driver, and the Consumer Index(CI) maintained by the 
device, the device knows how much work it has outstanding, so it can do the 
prefetch accordingly. 
There are few options for the device to acquire the PI.
Most efficient will be to write the PI in the doorbell together with the queue 
number.

I would like to raise the need for a Completion Queue(CQ).
Multiple Work Queues(hold the work descriptors, WQ in short) can be connected 
to a single CQ.
So when the device completes the work on the descriptor, it writes a Completion 
Queue Entry (CQE) to the CQ.
CQEs are continuous in memory so prefetching by the driver is efficient, 
although the device might complete work descriptors out of order.
The interrupt handler is connected to the CQ, so an allocation of a single CQ 
per core, with a single interrupt handler is possible although this core might 
be using multiple WQs.

One application for multiple WQs with a single CQ is Quality of Service(QoS).
A user can open a WQ per QoS value(pcp value for example), and the device will 
schedule the work accordingly.

> * Scatter/gather support
> 
> We can use 1 bit to chain s/g entries in a request, same as virtio 1.0:
> 
> /* This marks a buffer as continuing via the next field. */
> #define VRING_DESC_F_NEXT   1
> 
> Unlike virtio 1.0, all descriptors must have distinct ID values.
> 
> Also unlike virtio 1.0, use of this flag will be an optional feature
> (e.g. VIRTIO_F_DESC_NEXT) so both devices and drivers can opt out of it.
> 
> * Indirect buffers
> 
> Can be marked like in virtio 1.0:
> 
> /* This means the buffer contains a table of buffer descriptors. */
> #define VRING_DESC_F_INDIRECT   4
> 
> Unlike virtio 1.0, this is a table, not a list:
> struct indirect_descriptor_table {
> /* The actual descriptors (16 bytes each) */
> struct virtq_desc desc[len / 16];
> };
> 
> The first descriptor is located at start of the indirect descriptor
> table, additional indirect descriptors come immediately afterwards.
> DESC_F_WRITE is the only valid flag for descriptors in the indirect
> table. Others should be set to 0 and are ignored.  id is also set to 0
> and should be ignored.
> 
> virtio 1.0 seems to allow a s/g entry followed by
> an indirect descriptor. This does not seem useful,
> so we do not allow that anymore.
> 
> This support would be an optional feature, same as in virtio 1.0
> 
> * Batching descriptors:
> 
> virtio 1.0 allows passing a batch of descriptors in both directions, by
> incrementing the used/avail index by values > 1.  We can support this by
> chaining a list of descriptors through a bit the flags field.
> To allow use together with s/g, a different bit will be used.
> 
> #define VRING_DESC_F_BATCH_NEXT 0x0010
> 
> Batching works for both driver and device descriptors.
> 
> 
> 
> * Processing descriptors in and out of order
> 
> Device processing all descriptors in order can simply flip
> the DESC_HW bit as it is done with descriptors.
> 
> Device can write descriptors out in order as they are used, overwriting
> descriptors that are there.
> 
> Device must not use a descriptor until DESC_HW is set.
> It is only required to look at the first descriptor
> submitted.
> 
> Driver must not overwrite a descriptor until DESC_HW is clear.
> It is only required to look at the first descriptor
> submitted.
> 
> * Device specific descriptor flags
> We have a lot of unused space in the descriptor.  This can be put to
> good use by reserving some flag bits for device use.
> For example, network

Re: [virtio-dev] repost: af_packet vs virtio (was packed ring layout proposal v2)

2017-10-26 Thread Steven Luong
Michael,

I  have a question on s/g

On Thu, Apr 13, 2017 at 7:50 PM, Michael S. Tsirkin  wrote:

> On Fri, Apr 14, 2017 at 05:42:58AM +0300, Michael S. Tsirkin wrote:
> > Hi all, I wanted to raise the question of similarities between virtio
> > and new zero copy af_packet interfaces.
> >
> > First I would like to mention that virtio device development isn't spec
> > limited - spec is there to help interoperability and add peace of mind
> > for people worried about IPR.
> >
> > So I tend to accept patches without requiring people write it up in the
> > spec as work on spec proceeds at its own pace - all I ask is that the
> > virtio mailing list is copied, this requires contributor to subscribe
> > and in the process contributor promises that it's ok for us to add this
> > to spec in the future.
> >
> > There shouldn't thus be a fundamental problem preventing use of virtio
> > format or reusing some of the code for af_packet, but it still might or
> > might not make sense - it was designed for CPU to CPU communication so
> > it seems to make sense though.  So I would like that discussion to
> > happen even if we decide against.
> >
> > And even if people decide against, the problem space is very similar.
> You
> > can look up packed ring layout proposal v2 - should I repost here?  Our
> > prototyping shows significant performance improvements from using it as
> > compared to head/tail layout.
> >
> > To start this discission I'm going to reply to this email reposting a
> > copy of the simplified virtio layout that might be appropriate for
> > af_packet as well.
>
> Here's the repost (slightly cut down) sorry about the duplicates.
>
> The idea is to have a r/w descriptor in a ring structure,
> replacing the used and available ring, index and descriptor
> buffer.
>
> * Descriptor ring:
>
> Guest adds descriptors with unique index values and DESC_HW set in flags.
> Host overwrites used descriptors with correct len, index, and DESC_HW
> clear.  Flags are always set/cleared last.
>
> #define DESC_HW 0x0080
>
> struct desc {
> __le64 addr;
> __le32 len;
> __le16 index;
> __le16 flags;
> };
>
> When DESC_HW is set, descriptor belongs to device. When it is clear,
> it belongs to the driver.
>
> We can use 1 bit to set direction
> /* This marks a buffer as write-only (otherwise read-only). */
> #define VRING_DESC_F_WRITE  2
>
> * Scatter/gather support
>
> We can use 1 bit to chain s/g entries in a request, same as virtio 1.0:
>
> /* This marks a buffer as continuing via the next field. */
>

This comment here is confusing to me. In 1.0, virtq_desc has the next
field. When the flag VRING_DESC_F_NEXT is set, the next entry to continue
is specified in the next field.

Here in 1.1, struct desc does not have the next field, only addr, len,
index, and flags. So when VRING_DESC_F_NEXT is set in struct desc's flags
field, where is the next entry to continue the current descriptor, the
entry immediately following the current entry? ie, if the current entry is
at index 10 in the descriptor table and its flags is set for
VRING_DESC_F_NEXT, is the entry continuing the current entry in index 11?

Steven


> #define VRING_DESC_F_NEXT   1
>
> Unlike virtio 1.0, all descriptors must have distinct ID values.
>
> Also unlike virtio 1.0, use of this flag will be an optional feature
> (e.g. VIRTIO_F_DESC_NEXT) so both devices and drivers can opt out of it.
>
> * Indirect buffers
>
> Can be marked like in virtio 1.0:
>
> /* This means the buffer contains a table of buffer descriptors. */
> #define VRING_DESC_F_INDIRECT   4
>
> Unlike virtio 1.0, this is a table, not a list:
> struct indirect_descriptor_table {
> /* The actual descriptors (16 bytes each) */
> struct virtq_desc desc[len / 16];
> };
>
> The first descriptor is located at start of the indirect descriptor
> table, additional indirect descriptors come immediately afterwards.
> DESC_F_WRITE is the only valid flag for descriptors in the indirect
> table. Others should be set to 0 and are ignored.  id is also set to 0
> and should be ignored.
>
> virtio 1.0 seems to allow a s/g entry followed by
> an indirect descriptor. This does not seem useful,
> so we do not allow that anymore.
>
> This support would be an optional feature, same as in virtio 1.0
>
> * Batching descriptors:
>
> virtio 1.0 allows passing a batch of descriptors in both directions, by
> incrementing the used/avail index by values > 1.  We can support this by
> chaining a list of descriptors through a bit the flags field.
> To allow use together with s/g, a different bit will be used.
>
> #define VRING_DESC_F_BATCH_NEXT 0x0010
>
> Batching works for both driver and device descriptors.
>
>
>
> * Processing descriptors in and out of order
>
> Device processing all descriptors in order can simply flip
> the DESC_HW bit as it is done with descriptors.
>
> Device can write descriptors out in order as they are used, overwriting
> descriptors that are there.
>
> D

[patch net-next 0/3] net/sched: Improve getting objects by indexes

2017-10-26 Thread Chris Mi
Using current TC code, it is very slow to insert a lot of rules.

In order to improve the rules update rate in TC,
we introduced the following two changes:
1) changed cls_flower to use IDR to manage the filters.
2) changed all act_xxx modules to use IDR instead of
   a small hash table

But IDR has a limitation that it uses int. TC handle uses u32.
To make sure there is no regression, we also changed IDR to use
unsigned long. All clients of IDR are changed to use new IDR API.

Chris Mi (3):
  idr: Use unsigned long instead of int
  net/sched: Change cls_flower to use IDR
  net/sched: Change act_api and act_xxx modules to use IDR

 block/bsg.c |   8 +-
 block/genhd.c   |  12 +-
 drivers/atm/nicstar.c   |  11 +-
 drivers/block/drbd/drbd_main.c  |  31 +--
 drivers/block/drbd/drbd_nl.c|  22 ++-
 drivers/block/drbd/drbd_proc.c  |   3 +-
 drivers/block/drbd/drbd_receiver.c  |  15 +-
 drivers/block/drbd/drbd_state.c |  34 ++--
 drivers/block/drbd/drbd_worker.c|   6 +-
 drivers/block/loop.c|  17 +-
 drivers/block/nbd.c |  20 +-
 drivers/block/zram/zram_drv.c   |   9 +-
 drivers/char/tpm/tpm-chip.c |  10 +-
 drivers/char/tpm/tpm.h  |   2 +-
 drivers/dca/dca-sysfs.c |   9 +-
 drivers/firewire/core-cdev.c|  18 +-
 drivers/firewire/core-device.c  |  15 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c |   9 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c |   6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c |   2 +-
 drivers/gpu/drm/drm_auth.c  |   9 +-
 drivers/gpu/drm/drm_connector.c |  10 +-
 drivers/gpu/drm/drm_context.c   |  20 +-
 drivers/gpu/drm/drm_dp_aux_dev.c|  11 +-
 drivers/gpu/drm/drm_drv.c   |   6 +-
 drivers/gpu/drm/drm_gem.c   |  19 +-
 drivers/gpu/drm/drm_info.c  |   2 +-
 drivers/gpu/drm/drm_mode_object.c   |  11 +-
 drivers/gpu/drm/drm_syncobj.c   |  18 +-
 drivers/gpu/drm/exynos/exynos_drm_ipp.c |  25 ++-
 drivers/gpu/drm/i915/gvt/display.c  |   2 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c|   2 +-
 drivers/gpu/drm/i915/gvt/vgpu.c |   9 +-
 drivers/gpu/drm/i915/i915_debugfs.c |   6 +-
 drivers/gpu/drm/i915/i915_gem_context.c |   9 +-
 drivers/gpu/drm/qxl/qxl_cmd.c   |   8 +-
 drivers/gpu/drm/qxl/qxl_release.c   |  14 +-
 drivers/gpu/drm/sis/sis_mm.c|   8 +-
 drivers/gpu/drm/tegra/drm.c |  10 +-
 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c|   3 +-
 drivers/gpu/drm/vgem/vgem_fence.c   |  12 +-
 drivers/gpu/drm/via/via_mm.c|   8 +-
 drivers/gpu/drm/virtio/virtgpu_kms.c|   5 +-
 drivers/gpu/drm/virtio/virtgpu_vq.c |   5 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c|   9 +-
 drivers/i2c/i2c-core-base.c |  19 +-
 drivers/infiniband/core/cm.c|   8 +-
 drivers/infiniband/core/cma.c   |  12 +-
 drivers/infiniband/core/rdma_core.c |   9 +-
 drivers/infiniband/core/sa_query.c  |  23 +--
 drivers/infiniband/core/ucm.c   |   7 +-
 drivers/infiniband/core/ucma.c  |  14 +-
 drivers/infiniband/hw/cxgb3/iwch.c  |   4 +-
 drivers/infiniband/hw/cxgb3/iwch.h  |   4 +-
 drivers/infiniband/hw/cxgb4/device.c|  18 +-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   4 +-
 drivers/infiniband/hw/hfi1/init.c   |   9 +-
 drivers/infiniband/hw/hfi1/vnic_main.c  |   6 +-
 drivers/infiniband/hw/mlx4/cm.c |  13 +-
 drivers/infiniband/hw/ocrdma/ocrdma_main.c  |   7 +-
 drivers/infiniband/hw/qib/qib_init.c|   9 +-
 drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c |  10 +-
 drivers/iommu/intel-svm.c   |   9 +-
 drivers/md/dm.c |  13 +-
 drivers/memstick/core/memstick.c|  10 +-
 drivers/memstick/core/ms_block.c|   9 +-
 drivers/memstick/core/mspro_block.c |  12 +-
 drivers/mfd/rtsx_pcr.c  |   9 +-
 drivers/misc/c2port/core.c  |   7 +-
 drivers/misc/cxl/context.c  |   8 +-
 drivers/misc/cxl/main.c |  15 +-
 drivers/misc/mei/main.c |   8 +-
 drivers/misc/mic/scif/scif_api.c|  11 +-
 drivers/misc/mic/scif/scif_ports.c

[patch net-next 2/3] net/sched: Change cls_flower to use IDR

2017-10-26 Thread Chris Mi
Currently, all filters with the same priority are linked in a doubly
linked list. Every filter should have a unique handle. To make the
handle unique, we need to iterate the list every time to see if the
handle exists or not when inserting a new filter. It is time-consuming.
For example, it takes about 5m3.169s to insert 64K rules.

This patch changes cls_flower to use IDR. With this patch, it
takes about 0m1.127s to insert 64K rules. The improvement is huge.

But please note that in this testing, all filters share the same action.
If every filter has a unique action, that is another bottleneck.
Follow-up patch in this patchset addresses that.

Signed-off-by: Chris Mi 
Signed-off-by: Jiri Pirko 
---
 net/sched/cls_flower.c | 55 +-
 1 file changed, 23 insertions(+), 32 deletions(-)

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 052e902..071f0ef 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -68,7 +68,6 @@ struct cls_fl_head {
struct rhashtable ht;
struct fl_flow_mask mask;
struct flow_dissector dissector;
-   u32 hgen;
bool mask_assigned;
struct list_head filters;
struct rhashtable_params ht_params;
@@ -76,6 +75,7 @@ struct cls_fl_head {
struct work_struct work;
struct rcu_head rcu;
};
+   struct idr handle_idr;
 };
 
 struct cls_fl_filter {
@@ -210,6 +210,7 @@ static int fl_init(struct tcf_proto *tp)
 
INIT_LIST_HEAD_RCU(&head->filters);
rcu_assign_pointer(tp->root, head);
+   idr_init(&head->handle_idr);
 
return 0;
 }
@@ -295,6 +296,9 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct 
cls_fl_filter *f)
 
 static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f)
 {
+   struct cls_fl_head *head = rtnl_dereference(tp->root);
+
+   idr_remove(&head->handle_idr, f->handle);
list_del_rcu(&f->list);
if (!tc_skip_hw(f->flags))
fl_hw_destroy_filter(tp, f);
@@ -327,6 +331,7 @@ static void fl_destroy(struct tcf_proto *tp)
 
list_for_each_entry_safe(f, next, &head->filters, list)
__fl_delete(tp, f);
+   idr_destroy(&head->handle_idr);
 
__module_get(THIS_MODULE);
call_rcu(&head->rcu, fl_destroy_rcu);
@@ -335,12 +340,8 @@ static void fl_destroy(struct tcf_proto *tp)
 static void *fl_get(struct tcf_proto *tp, u32 handle)
 {
struct cls_fl_head *head = rtnl_dereference(tp->root);
-   struct cls_fl_filter *f;
 
-   list_for_each_entry(f, &head->filters, list)
-   if (f->handle == handle)
-   return f;
-   return NULL;
+   return idr_find(&head->handle_idr, handle);
 }
 
 static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
@@ -859,27 +860,6 @@ static int fl_set_parms(struct net *net, struct tcf_proto 
*tp,
return 0;
 }
 
-static u32 fl_grab_new_handle(struct tcf_proto *tp,
- struct cls_fl_head *head)
-{
-   unsigned int i = 0x8000;
-   u32 handle;
-
-   do {
-   if (++head->hgen == 0x7FFF)
-   head->hgen = 1;
-   } while (--i > 0 && fl_get(tp, head->hgen));
-
-   if (unlikely(i == 0)) {
-   pr_err("Insufficient number of handles\n");
-   handle = 0;
-   } else {
-   handle = head->hgen;
-   }
-
-   return handle;
-}
-
 static int fl_change(struct net *net, struct sk_buff *in_skb,
 struct tcf_proto *tp, unsigned long base,
 u32 handle, struct nlattr **tca,
@@ -890,6 +870,7 @@ static int fl_change(struct net *net, struct sk_buff 
*in_skb,
struct cls_fl_filter *fnew;
struct nlattr **tb;
struct fl_flow_mask mask = {};
+   unsigned long idr_index;
int err;
 
if (!tca[TCA_OPTIONS])
@@ -920,13 +901,21 @@ static int fl_change(struct net *net, struct sk_buff 
*in_skb,
goto errout;
 
if (!handle) {
-   handle = fl_grab_new_handle(tp, head);
-   if (!handle) {
-   err = -EINVAL;
+   err = idr_alloc(&head->handle_idr, fnew, &idr_index,
+   1, 0x8000, GFP_KERNEL);
+   if (err)
goto errout;
-   }
+   fnew->handle = idr_index;
+   }
+
+   /* user specifies a handle and it doesn't exist */
+   if (handle && !fold) {
+   err = idr_alloc(&head->handle_idr, fnew, &idr_index,
+   handle, handle + 1, GFP_KERNEL);
+   if (err)
+   goto errout;
+   fnew->handle = idr_index;
}
-   fnew->handle = handle;
 
if (tb[TCA_FLOWER_FLAGS]) {
fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
@@ -980,6 +969,8 @@ static int fl_change(struct net *net,

[patch net-next 3/3] net/sched: Change act_api and act_xxx modules to use IDR

2017-10-26 Thread Chris Mi
Typically, each TC filter has its own action. All the actions of the
same type are saved in its hash table. But the hash buckets are too
small that it degrades to a list. And the performance is greatly
affected. For example, it takes about 0m11.914s to insert 64K rules.
If we convert the hash table to IDR, it only takes about 0m1.500s.
The improvement is huge.

But please note that the test result is based on previous patch that
cls_flower uses IDR.

Signed-off-by: Chris Mi 
Signed-off-by: Jiri Pirko 
---
 include/net/act_api.h  |  76 +-
 net/sched/act_api.c| 249 ++---
 net/sched/act_bpf.c|  17 ++--
 net/sched/act_connmark.c   |  16 ++-
 net/sched/act_csum.c   |  16 ++-
 net/sched/act_gact.c   |  16 ++-
 net/sched/act_ife.c|  20 ++--
 net/sched/act_ipt.c|  26 +++--
 net/sched/act_mirred.c |  19 ++--
 net/sched/act_nat.c|  16 ++-
 net/sched/act_pedit.c  |  18 ++--
 net/sched/act_police.c |  18 ++--
 net/sched/act_sample.c |  17 ++--
 net/sched/act_simple.c |  20 ++--
 net/sched/act_skbedit.c|  18 ++--
 net/sched/act_skbmod.c |  18 ++--
 net/sched/act_tunnel_key.c |  20 ++--
 net/sched/act_vlan.c   |  22 ++--
 18 files changed, 277 insertions(+), 345 deletions(-)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 26ffd83..8f3d5d8 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -10,12 +10,9 @@
 #include 
 #include 
 
-
-struct tcf_hashinfo {
-   struct hlist_head   *htab;
-   unsigned inthmask;
-   spinlock_t  lock;
-   u32 index;
+struct tcf_idrinfo {
+   spinlock_t  lock;
+   struct idr  action_idr;
 };
 
 struct tc_action_ops;
@@ -25,9 +22,8 @@ struct tc_action {
__u32   type; /* for backward 
compat(TCA_OLD_COMPAT) */
__u32   order;
struct list_headlist;
-   struct tcf_hashinfo *hinfo;
+   struct tcf_idrinfo  *idrinfo;
 
-   struct hlist_node   tcfa_head;
u32 tcfa_index;
int tcfa_refcnt;
int tcfa_bindcnt;
@@ -44,7 +40,6 @@ struct tc_action {
struct tc_cookie*act_cookie;
struct tcf_chain*goto_chain;
 };
-#define tcf_head   common.tcfa_head
 #define tcf_index  common.tcfa_index
 #define tcf_refcnt common.tcfa_refcnt
 #define tcf_bindcntcommon.tcfa_bindcnt
@@ -57,27 +52,6 @@ struct tc_action {
 #define tcf_lock   common.tcfa_lock
 #define tcf_rcucommon.tcfa_rcu
 
-static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
-{
-   return index & hmask;
-}
-
-static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask)
-{
-   int i;
-
-   spin_lock_init(&hf->lock);
-   hf->index = 0;
-   hf->hmask = mask;
-   hf->htab = kzalloc((mask + 1) * sizeof(struct hlist_head),
-  GFP_KERNEL);
-   if (!hf->htab)
-   return -ENOMEM;
-   for (i = 0; i < mask + 1; i++)
-   INIT_HLIST_HEAD(&hf->htab[i]);
-   return 0;
-}
-
 /* Update lastuse only if needed, to avoid dirtying a cache line.
  * We use a temp variable to avoid fetching jiffies twice.
  */
@@ -126,53 +100,51 @@ struct tc_action_ops {
 };
 
 struct tc_action_net {
-   struct tcf_hashinfo *hinfo;
+   struct tcf_idrinfo *idrinfo;
const struct tc_action_ops *ops;
 };
 
 static inline
 int tc_action_net_init(struct tc_action_net *tn,
-  const struct tc_action_ops *ops, unsigned int mask)
+  const struct tc_action_ops *ops)
 {
int err = 0;
 
-   tn->hinfo = kmalloc(sizeof(*tn->hinfo), GFP_KERNEL);
-   if (!tn->hinfo)
+   tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL);
+   if (!tn->idrinfo)
return -ENOMEM;
tn->ops = ops;
-   err = tcf_hashinfo_init(tn->hinfo, mask);
-   if (err)
-   kfree(tn->hinfo);
+   spin_lock_init(&tn->idrinfo->lock);
+   idr_init(&tn->idrinfo->action_idr);
return err;
 }
 
-void tcf_hashinfo_destroy(const struct tc_action_ops *ops,
- struct tcf_hashinfo *hinfo);
+void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
+struct tcf_idrinfo *idrinfo);
 
 static inline void tc_action_net_exit(struct tc_action_net *tn)
 {
-   tcf_hashinfo_destroy(tn->ops, tn->hinfo);
-   kfree(tn->hinfo);
+   tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
+   kfree(tn->idrinfo);
 }
 
 int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
   struct netlink_callback *cb, int type,
   const struct tc_action_ops *ops);
-int tcf_hash_search(struct tc_ac

Re: [PATCH v16 0/5] Virtio-balloon Enhancement

2017-10-26 Thread Damian Tometzki
Hello,

where i can found the patch in git.kernel.org ?

Best regards
Damian


Am Samstag, den 30.09.2017, 12:05 +0800 schrieb Wei Wang:
> This patch series enhances the existing virtio-balloon with the
> following
> new features:
> 1) fast ballooning: transfer ballooned pages between the guest and
> host in
> chunks using sgs, instead of one array each time; and
> 2) free page block reporting: a new virtqueue to report guest free
> pages
> to the host.
> 
> The second feature can be used to accelerate live migration of VMs.
> Here
> are some details:
> 
> Live migration needs to transfer the VM's memory from the source
> machine
> to the destination round by round. For the 1st round, all the VM's
> memory
> is transferred. From the 2nd round, only the pieces of memory that
> were
> written by the guest (after the 1st round) are transferred. One
> method
> that is popularly used by the hypervisor to track which part of
> memory is
> written is to write-protect all the guest memory.
> 
> The second feature enables the optimization of the 1st round memory
> transfer - the hypervisor can skip the transfer of guest free pages
> in the
> 1st round. It is not concerned that the memory pages are used after
> they
> are given to the hypervisor as a hint of the free pages, because they
> will
> be tracked by the hypervisor and transferred in the next round if
> they are
> used and written.
> 
> Change Log:
> v15->v16:
> 1) mm: stop reporting the free pfn range if the callback returns
> false;
> 2) mm: move some implementaion of walk_free_mem_block into a function
> to
> make the code layout looks better;
> 3) xbitmap: added some optimizations suggested by Matthew, please
> refer to
> the ChangLog in the xbitmap patch for details.
> 4) xbitmap: added a test suite
> 5) virtio-balloon: bail out with a warning when virtqueue_add_inbuf
> returns
> an error
> 6) virtio-balloon: some small code re-arrangement, e.g. detachinf
> used buf
> from the vq before adding a new buf
> 
> v14->v15:
> 1) mm: make the report callback return a bool value - returning 1 to
> stop
> walking through the free page list.
> 2) virtio-balloon: batching sgs of balloon pages till the vq is full
> 3) virtio-balloon: create a new workqueue, rather than using the
> default
> system_wq, to queue the free page reporting work item.
> 4) virtio-balloon: add a ctrl_vq to be a central control plane which
> will
> handle all the future control related commands between the host and
> guest.
> Add free page report as the first feature controlled under ctrl_vq,
> and
> the free_page_vq is a data plane vq dedicated to the transmission of
> free
> page blocks.
> 
> v13->v14:
> 1) xbitmap: move the code from lib/radix-tree.c to lib/xbitmap.c.
> 2) xbitmap: consolidate the implementation of xb_bit_set/clear/test
> into
> one xb_bit_ops.
> 3) xbitmap: add documents for the exported APIs.
> 4) mm: rewrite the function to walk through free page blocks.
> 5) virtio-balloon: when reporting a free page blcok to the device, if
> the
> vq is full (less likey to happen in practice), just skip reporting
> this
> block, instead of busywaiting till an entry gets released.
> 6) virtio-balloon: fail the probe function if adding the signal buf
> in
> init_vqs fails.
> 
> v12->v13:
> 1) mm: use a callback function to handle the the free page blocks
> from the
> report function. This avoids exposing the zone internal to a kernel
> module.
> 2) virtio-balloon: send balloon pages or a free page block using a
> single
> sg each time. This has the benefits of simpler implementation with no
> new
> APIs.
> 3) virtio-balloon: the free_page_vq is used to report free pages only
> (no
> multiple usages interleaving)
> 4) virtio-balloon: Balloon pages and free page blocks are sent via
> input
> sgs, and the completion signal to the host is sent via an output sg.
> 
> v11->v12:
> 1) xbitmap: use the xbitmap from Matthew Wilcox to record ballooned
> pages.
> 2) virtio-ring: enable the driver to build up a desc chain using
> vring
> desc.
> 3) virtio-ring: Add locking to the existing START_USE() and END_USE()
> macro to lock/unlock the vq when a vq operation starts/ends.
> 4) virtio-ring: add virtqueue_kick_sync() and virtqueue_kick_async()
> 5) virtio-balloon: describe chunks of ballooned pages and free pages
> blocks directly using one or more chains of desc from the vq.
> 
> v10->v11:
> 1) virtio_balloon: use vring_desc to describe a chunk;
> 2) virtio_ring: support to add an indirect desc table to virtqueue;
> 3)  virtio_balloon: use cmdq to report guest memory statistics.
> 
> v9->v10:
> 1) mm: put report_unused_page_block() under CONFIG_VIRTIO_BALLOON;
> 2) virtio-balloon: add virtballoon_validate();
> 3) virtio-balloon: msg format change;
> 4) virtio-balloon: move miscq handling to a task on
> system_freezable_wq;
> 5) virtio-balloon: code cleanup.
> 
> v8->v9:
> 1) Split the two new features, VIRTIO_BALLOON_F_BALLOON_CHUNKS and
> VIRTIO_BALLOON_F_MISC_VQ, which were mixed together in

[PATCH 07/11] drm: mgag200: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  5 ---
 drivers/gpu/drm/mgag200/mgag200_fb.c   |  2 --
 drivers/gpu/drm/mgag200/mgag200_mode.c | 62 --
 3 files changed, 15 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index c88b6ec..04f1dfb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -237,11 +237,6 @@ mgag200_bo(struct ttm_buffer_object *bo)
 {
return container_of(bo, struct mgag200_bo, bo);
 }
-   /* mgag200_crtc.c */
-void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
 
/* mgag200_mode.c */
 int mgag200_modeset_init(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 5d3b1fa..5cf980a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -258,8 +258,6 @@ static int mga_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs mga_fb_helper_funcs = {
-   .gamma_set = mga_crtc_fb_gamma_set,
-   .gamma_get = mga_crtc_fb_gamma_get,
.fb_probe = mgag200fb_create,
 };
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index adb411a..117bec3 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -27,15 +27,19 @@
 
 static void mga_crtc_load_lut(struct drm_crtc *crtc)
 {
-   struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct mga_device *mdev = dev->dev_private;
struct drm_framebuffer *fb = crtc->primary->fb;
+   u16 *r_ptr, *g_ptr, *b_ptr;
int i;
 
if (!crtc->enabled)
return;
 
+   r_ptr = crtc->gamma_store;
+   g_ptr = r_ptr + crtc->gamma_size;
+   b_ptr = g_ptr + crtc->gamma_size;
+
WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
if (fb && fb->format->cpp[0] * 8 == 16) {
@@ -46,25 +50,27 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
if (i > (MGAG200_LUT_SIZE >> 1)) {
r = b = 0;
} else {
-   r = mga_crtc->lut_r[i << 1];
-   b = mga_crtc->lut_b[i << 1];
+   r = *r_ptr++ >> 8;
+   b = *b_ptr++ >> 8;
+   r_ptr++;
+   b_ptr++;
}
} else {
-   r = mga_crtc->lut_r[i];
-   b = mga_crtc->lut_b[i];
+   r = *r_ptr++ >> 8;
+   b = *b_ptr++ >> 8;
}
/* VGA registers */
WREG8(DAC_INDEX + MGA1064_COL_PAL, r);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
WREG8(DAC_INDEX + MGA1064_COL_PAL, b);
}
return;
}
for (i = 0; i < MGAG200_LUT_SIZE; i++) {
/* VGA registers */
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_r[i]);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_b[i]);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *r_ptr++ >> 8);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *b_ptr++ >> 8);
}
 }
 
@@ -1396,14 +1402,6 @@ static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 
*red, u16 *green,
  u16 *blue, uint32_t size,
  struct drm_modeset_acquire_ctx *ctx)
 {
-   struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   mga_crtc->lut_r[i] = red[i] >> 8;
-   mga_crtc->lut_g[i] = green[i] >> 8;
-   mga_crtc->lut_b[i] = blue[i] >> 8;
-   }
mga_crtc_load_lut(crtc);
 
return 0;
@@ -1452,14 +1450,12 @@ static const struct drm_crtc_helper_funcs 
mga_helper_funcs = {
.mode_set_base = mga_crtc_mode_set_base,
 

[PATCH 06/11] drm: i915: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The driver stores lut values from the fbdev interface, and is able
to give them back, but does not appear to do anything with these
lut values. The generic fb helpers have replaced this function,
and may even have made the driver work for the C8 mode from the
fbdev interface. But that is untested.

Since the fb helper .gamma_set and .gamma_get are no longer used,
just kill the mysterious dead code.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/i915/intel_drv.h   |  1 -
 drivers/gpu/drm/i915/intel_fbdev.c | 31 ---
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 83dd409..503edf3 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -785,7 +785,6 @@ struct intel_crtc {
struct drm_crtc base;
enum pipe pipe;
enum plane plane;
-   u8 lut_r[256], lut_g[256], lut_b[256];
/*
 * Whether the crtc and the connected output pipeline is active. Implies
 * that crtc->enabled is set, i.e. the current mode configuration has
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index 03347c6..5bac953 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -281,27 +281,6 @@ static int intelfb_create(struct drm_fb_helper *helper,
return ret;
 }
 
-/** Sets the color ramps on behalf of RandR */
-static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-   intel_crtc->lut_r[regno] = red >> 8;
-   intel_crtc->lut_g[regno] = green >> 8;
-   intel_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, int regno)
-{
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-   *red = intel_crtc->lut_r[regno] << 8;
-   *green = intel_crtc->lut_g[regno] << 8;
-   *blue = intel_crtc->lut_b[regno] << 8;
-}
-
 static struct drm_fb_helper_crtc *
 intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
 {
@@ -370,7 +349,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_fb_helper_crtc *new_crtc;
-   struct intel_crtc *intel_crtc;
 
fb_conn = fb_helper->connector_info[i];
connector = fb_conn->connector;
@@ -412,13 +390,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
 
num_connectors_enabled++;
 
-   intel_crtc = to_intel_crtc(connector->state->crtc);
-   for (j = 0; j < 256; j++) {
-   intel_crtc->lut_r[j] = j;
-   intel_crtc->lut_g[j] = j;
-   intel_crtc->lut_b[j] = j;
-   }
-
new_crtc = intel_fb_helper_crtc(fb_helper,
connector->state->crtc);
 
@@ -519,8 +490,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
 
 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.initial_config = intel_fb_initial_config,
-   .gamma_set = intel_crtc_fb_gamma_set,
-   .gamma_get = intel_crtc_fb_gamma_get,
.fb_probe = intelfb_create,
 };
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 05/11] dmr: gma500: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .gamma_set and .gamma_get are no longer
used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

It is a bit strange that the fb helper .load_lut was not hooked
up, so this change may well make the driver work for the C8 mode
from the fbdev interface. But that is untested.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/gma500/framebuffer.c   | 22 
 drivers/gpu/drm/gma500/gma_display.c   | 32 ++
 drivers/gpu/drm/gma500/psb_intel_display.c |  7 +--
 drivers/gpu/drm/gma500/psb_intel_drv.h |  1 -
 4 files changed, 12 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 7da70b6..2570c7f 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -479,26 +479,6 @@ static struct drm_framebuffer *psb_user_framebuffer_create
return psb_framebuffer_create(dev, cmd, r);
 }
 
-static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
-   gma_crtc->lut_r[regno] = red >> 8;
-   gma_crtc->lut_g[regno] = green >> 8;
-   gma_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
-   u16 *green, u16 *blue, int regno)
-{
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
-   *red = gma_crtc->lut_r[regno] << 8;
-   *green = gma_crtc->lut_g[regno] << 8;
-   *blue = gma_crtc->lut_b[regno] << 8;
-}
-
 static int psbfb_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
 {
@@ -525,8 +505,6 @@ static int psbfb_probe(struct drm_fb_helper *helper,
 }
 
 static const struct drm_fb_helper_funcs psb_fb_helper_funcs = {
-   .gamma_set = psbfb_gamma_set,
-   .gamma_get = psbfb_gamma_get,
.fb_probe = psbfb_probe,
 };
 
diff --git a/drivers/gpu/drm/gma500/gma_display.c 
b/drivers/gpu/drm/gma500/gma_display.c
index e7fd356..f3c48a2 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -144,33 +144,32 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe];
int palreg = map->palette;
+   u16 *r, *g, *b;
int i;
 
/* The clocks have to be on to load the palette. */
if (!crtc->enabled)
return;
 
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
if (gma_power_begin(dev, false)) {
for (i = 0; i < 256; i++) {
REG_WRITE(palreg + 4 * i,
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]));
+ (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+ (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+ ((*b++ >> 8) + gma_crtc->lut_adj[i]));
}
gma_power_end(dev);
} else {
for (i = 0; i < 256; i++) {
/* FIXME: Why pipe[0] and not pipe[..._crtc->pipe]? */
dev_priv->regs.pipe[0].palette[i] =
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]);
+   (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+   (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+   ((*b++ >> 8) + gma_crtc->lut_adj[i]);
}
 
}
@@ -180,15 +179,6 @@ int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, 
u16 *green, u16 *blue,
   u32 size,
   struct drm_modeset_acquire_ctx *ctx)
 {
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   gma_crtc->lut_r[i] = red[i] >> 8;
-   gma_crtc->lut_g[i] = green[i] >> 8;
-   gma_crtc->lut_b[i] = blue[i] >> 8;
-   }
-
gma_crtc_load_lut(crtc);
 
return 0;
diff --git a/drivers/gpu/drm/gma500/psb_intel_d

Re: [PATCH v16 0/5] Virtio-balloon Enhancement

2017-10-26 Thread Damian Tometzki
Hello,

where i can found the patch in git.kernel.org ?


Am Samstag, den 30.09.2017, 12:05 +0800 schrieb Wei Wang:
> This patch series enhances the existing virtio-balloon with the
> following
> new features:
> 1) fast ballooning: transfer ballooned pages between the guest and
> host in
> chunks using sgs, instead of one array each time; and
> 2) free page block reporting: a new virtqueue to report guest free
> pages
> to the host.
> 
> The second feature can be used to accelerate live migration of VMs.
> Here
> are some details:
> 
> Live migration needs to transfer the VM's memory from the source
> machine
> to the destination round by round. For the 1st round, all the VM's
> memory
> is transferred. From the 2nd round, only the pieces of memory that
> were
> written by the guest (after the 1st round) are transferred. One
> method
> that is popularly used by the hypervisor to track which part of
> memory is
> written is to write-protect all the guest memory.
> 
> The second feature enables the optimization of the 1st round memory
> transfer - the hypervisor can skip the transfer of guest free pages
> in the
> 1st round. It is not concerned that the memory pages are used after
> they
> are given to the hypervisor as a hint of the free pages, because they
> will
> be tracked by the hypervisor and transferred in the next round if
> they are
> used and written.
> 
> Change Log:
> v15->v16:
> 1) mm: stop reporting the free pfn range if the callback returns
> false;
> 2) mm: move some implementaion of walk_free_mem_block into a function
> to
> make the code layout looks better;
> 3) xbitmap: added some optimizations suggested by Matthew, please
> refer to
> the ChangLog in the xbitmap patch for details.
> 4) xbitmap: added a test suite
> 5) virtio-balloon: bail out with a warning when virtqueue_add_inbuf
> returns
> an error
> 6) virtio-balloon: some small code re-arrangement, e.g. detachinf
> used buf
> from the vq before adding a new buf
> 
> v14->v15:
> 1) mm: make the report callback return a bool value - returning 1 to
> stop
> walking through the free page list.
> 2) virtio-balloon: batching sgs of balloon pages till the vq is full
> 3) virtio-balloon: create a new workqueue, rather than using the
> default
> system_wq, to queue the free page reporting work item.
> 4) virtio-balloon: add a ctrl_vq to be a central control plane which
> will
> handle all the future control related commands between the host and
> guest.
> Add free page report as the first feature controlled under ctrl_vq,
> and
> the free_page_vq is a data plane vq dedicated to the transmission of
> free
> page blocks.
> 
> v13->v14:
> 1) xbitmap: move the code from lib/radix-tree.c to lib/xbitmap.c.
> 2) xbitmap: consolidate the implementation of xb_bit_set/clear/test
> into
> one xb_bit_ops.
> 3) xbitmap: add documents for the exported APIs.
> 4) mm: rewrite the function to walk through free page blocks.
> 5) virtio-balloon: when reporting a free page blcok to the device, if
> the
> vq is full (less likey to happen in practice), just skip reporting
> this
> block, instead of busywaiting till an entry gets released.
> 6) virtio-balloon: fail the probe function if adding the signal buf
> in
> init_vqs fails.
> 
> v12->v13:
> 1) mm: use a callback function to handle the the free page blocks
> from the
> report function. This avoids exposing the zone internal to a kernel
> module.
> 2) virtio-balloon: send balloon pages or a free page block using a
> single
> sg each time. This has the benefits of simpler implementation with no
> new
> APIs.
> 3) virtio-balloon: the free_page_vq is used to report free pages only
> (no
> multiple usages interleaving)
> 4) virtio-balloon: Balloon pages and free page blocks are sent via
> input
> sgs, and the completion signal to the host is sent via an output sg.
> 
> v11->v12:
> 1) xbitmap: use the xbitmap from Matthew Wilcox to record ballooned
> pages.
> 2) virtio-ring: enable the driver to build up a desc chain using
> vring
> desc.
> 3) virtio-ring: Add locking to the existing START_USE() and END_USE()
> macro to lock/unlock the vq when a vq operation starts/ends.
> 4) virtio-ring: add virtqueue_kick_sync() and virtqueue_kick_async()
> 5) virtio-balloon: describe chunks of ballooned pages and free pages
> blocks directly using one or more chains of desc from the vq.
> 
> v10->v11:
> 1) virtio_balloon: use vring_desc to describe a chunk;
> 2) virtio_ring: support to add an indirect desc table to virtqueue;
> 3)  virtio_balloon: use cmdq to report guest memory statistics.
> 
> v9->v10:
> 1) mm: put report_unused_page_block() under CONFIG_VIRTIO_BALLOON;
> 2) virtio-balloon: add virtballoon_validate();
> 3) virtio-balloon: msg format change;
> 4) virtio-balloon: move miscq handling to a task on
> system_freezable_wq;
> 5) virtio-balloon: code cleanup.
> 
> v8->v9:
> 1) Split the two new features, VIRTIO_BALLOON_F_BALLOON_CHUNKS and
> VIRTIO_BALLOON_F_MISC_VQ, which were mixed together in the previous
> imple

[PATCH 08/11] drm: nouveau: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 26 --
 drivers/gpu/drm/nouveau/nouveau_crtc.h  |  3 ---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 22 ---
 drivers/gpu/drm/nouveau/nv50_display.c  | 39 ++---
 4 files changed, 21 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 4b4b0b4..8f689f1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -764,13 +764,18 @@ nv_crtc_gamma_load(struct drm_crtc *crtc)
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct drm_device *dev = nv_crtc->base.dev;
struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs;
+   u16 *r, *g, *b;
int i;
 
rgbs = (struct rgb 
*)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC;
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++) {
-   rgbs[i].r = nv_crtc->lut.r[i] >> 8;
-   rgbs[i].g = nv_crtc->lut.g[i] >> 8;
-   rgbs[i].b = nv_crtc->lut.b[i] >> 8;
+   rgbs[i].r = *r++ >> 8;
+   rgbs[i].g = *g++ >> 8;
+   rgbs[i].b = *b++ >> 8;
}
 
nouveau_hw_load_state_palette(dev, nv_crtc->index, 
&nv04_display(dev)->mode_reg);
@@ -792,13 +797,6 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, 
u16 *b,
  struct drm_modeset_acquire_ctx *ctx)
 {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   nv_crtc->lut.r[i] = r[i];
-   nv_crtc->lut.g[i] = g[i];
-   nv_crtc->lut.b[i] = b[i];
-   }
 
/* We need to know the depth before we upload, but it's possible to
 * get called before a framebuffer is bound.  If this is the case,
@@ -1095,7 +1093,6 @@ static const struct drm_crtc_helper_funcs 
nv04_crtc_helper_funcs = {
.mode_set = nv_crtc_mode_set,
.mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
-   .load_lut = nv_crtc_gamma_load,
.disable = nv_crtc_disable,
 };
 
@@ -1103,17 +1100,12 @@ int
 nv04_crtc_create(struct drm_device *dev, int crtc_num)
 {
struct nouveau_crtc *nv_crtc;
-   int ret, i;
+   int ret;
 
nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
if (!nv_crtc)
return -ENOMEM;
 
-   for (i = 0; i < 256; i++) {
-   nv_crtc->lut.r[i] = i << 8;
-   nv_crtc->lut.g[i] = i << 8;
-   nv_crtc->lut.b[i] = i << 8;
-   }
nv_crtc->lut.depth = 0;
 
nv_crtc->index = crtc_num;
diff --git a/drivers/gpu/drm/nouveau/nouveau_crtc.h 
b/drivers/gpu/drm/nouveau/nouveau_crtc.h
index 050fcf3..b7a18fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_crtc.h
+++ b/drivers/gpu/drm/nouveau/nouveau_crtc.h
@@ -61,9 +61,6 @@ struct nouveau_crtc {
 
struct {
struct nouveau_bo *nvbo;
-   uint16_t r[256];
-   uint16_t g[256];
-   uint16_t b[256];
int depth;
} lut;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2665a07..f770784 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -278,26 +278,6 @@ nouveau_fbcon_accel_init(struct drm_device *dev)
info->fbops = &nouveau_fbcon_ops;
 }
 
-static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
-   nv_crtc->lut.r[regno] = red;
-   nv_crtc->lut.g[regno] = green;
-   nv_crtc->lut.b[regno] = blue;
-}
-
-static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, int regno)
-{
-   struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
-   *red = nv_crtc->lut.r[regno];
-   *green = nv_crtc->lut.g[regno];
-   *blue = nv_crtc->lut.b[regno];
-}
-
 static void
 nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon)
 {
@@ -467,8 +447,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info)
 }
 
 static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
-   .gamma_set = nouveau_fbcon_gamma_set,
-   .gamma_get = nouveau_fbcon_gamma_get,
.fb_probe = nouveau_fbcon_create,
 };
 
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c 
b/drivers/gpu/drm/nouveau/nv50_display.c
index 775c1

[PATCH 09/11] drm: radeon: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/radeon/atombios_crtc.c  |  1 -
 drivers/gpu/drm/radeon/radeon_connectors.c  |  7 ++-
 drivers/gpu/drm/radeon/radeon_display.c | 71 -
 drivers/gpu/drm/radeon/radeon_fb.c  |  2 -
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  1 -
 5 files changed, 33 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index 3c492a0..02baaaf 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -2217,7 +2217,6 @@ static const struct drm_crtc_helper_funcs 
atombios_helper_funcs = {
.mode_set_base_atomic = atombios_crtc_set_base_atomic,
.prepare = atombios_crtc_prepare,
.commit = atombios_crtc_commit,
-   .load_lut = radeon_crtc_load_lut,
.disable = atombios_crtc_disable,
 };
 
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index 27affbd..2f642cb 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -773,12 +773,15 @@ static int radeon_connector_set_property(struct 
drm_connector *connector, struct
 
if (connector->encoder->crtc) {
struct drm_crtc *crtc  = connector->encoder->crtc;
-   const struct drm_crtc_helper_funcs *crtc_funcs = 
crtc->helper_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 
radeon_crtc->output_csc = radeon_encoder->output_csc;
 
-   (*crtc_funcs->load_lut)(crtc);
+   /*
+* Our .gamma_set assumes the .gamma_store has been
+* prefilled and don't care about its arguments.
+*/
+   crtc->funcs->gamma_set(crtc, NULL, NULL, NULL, 0, NULL);
}
}
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 17d3daf..8b7d7a0 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -42,6 +42,7 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -60,11 +61,14 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
WREG32(AVIVO_DC_LUT_WRITE_EN_MASK, 0x003f);
 
WREG8(AVIVO_DC_LUT_RW_INDEX, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(AVIVO_DC_LUT_30_COLOR,
-(radeon_crtc->lut_r[i] << 20) |
-(radeon_crtc->lut_g[i] << 10) |
-(radeon_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 
/* Only change bit 0 of LUT_SEL, other bits are set elsewhere */
@@ -76,6 +80,7 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -93,11 +98,14 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 
0x0007);
 
WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
-  (radeon_crtc->lut_r[i] << 20) |
-  (radeon_crtc->lut_g[i] << 10) |
-  (radeon_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 }
 
@@ -106,6 +114,7 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -135,11 +144,14 @@ static void dce5_crtc_load_lut(str

[PATCH 10/11] drm: stm: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helper .load_lut is no longer used, and can not
work right without also providing the fb helpers .gamma_set and
.gamma_get thus rendering the code in this driver suspect.

Just remove the dead code.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/stm/ltdc.c | 12 
 drivers/gpu/drm/stm/ltdc.h |  1 -
 2 files changed, 13 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 1b9483d..87829b9 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -375,17 +375,6 @@ static irqreturn_t ltdc_irq(int irq, void *arg)
  * DRM_CRTC
  */
 
-static void ltdc_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   unsigned int i, lay;
-
-   for (lay = 0; lay < ldev->caps.nb_layers; lay++)
-   for (i = 0; i < 256; i++)
-   reg_write(ldev->regs, LTDC_L1CLUTWR + lay * LAY_OFS,
- ldev->clut[i]);
-}
-
 static void ltdc_crtc_enable(struct drm_crtc *crtc)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
@@ -523,7 +512,6 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
-   .load_lut = ltdc_crtc_load_lut,
.enable = ltdc_crtc_enable,
.disable = ltdc_crtc_disable,
.mode_set_nofb = ltdc_crtc_mode_set_nofb,
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index d7a9c73..620ca55 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -27,7 +27,6 @@ struct ltdc_device {
struct drm_panel *panel;
struct mutex err_lock;  /* protecting error_status */
struct ltdc_caps caps;
-   u32 clut[256];  /* color look up table */
u32 error_status;
u32 irq_status;
 };
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [Nouveau] [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Michel Dänzer
On 21/06/17 05:14 PM, Daniel Vetter wrote:
> On Wed, Jun 21, 2017 at 04:59:31PM +0900, Michel Dänzer wrote:
>> On 21/06/17 04:38 PM, Daniel Vetter wrote:
>>> On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
 This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
 totally obsolete.

 I think the gamma_store can end up invalid on error. But the way I read
 it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
 this pesky legacy fbdev stuff be any better?

 drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
 it saves it to the gamma_store which should already be up to date with what
 .gamma_get would return and is thus a nop. So, zap it.
>>>
>>> Removing drm_fb_helper_save_lut_atomic should be a separate patch I
>>> think.
>>>  
 Signed-off-by: Peter Rosin 
>>
>> [...]
>>
 @@ -1167,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
 drm_fb_helper *fb_helper,
  }
  EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
  
 -static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 -   u16 blue, u16 regno, struct fb_info *info)
 -{
 -  struct drm_fb_helper *fb_helper = info->par;
 -  struct drm_framebuffer *fb = fb_helper->fb;
 -
 -  if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
>>>
>>> This case here seems gone, and it was also the pièce de résistance when I
>>> tried tackling fbdev lut support. As far as I understand this stuff we do
>>> not support FB_VISUAL_TRUECOLOR palette, and all that bitshifting here is
>>> pointless. But I'm honestly not really clear.
>>>
>>> I think removing this case should also be a separate patch, and I'd very
>>> much prefer that someone with some fbdev-clue would ack it.
>>
>> No need for anyone with fbdev-clue, just run fbset -i. :)

Adding Bartlomiej and the linux-fbdev list, just in case I'm wrong below.


>> fbcon uses a TRUECOLOR visual at depths > 8.
> 
> Then I understand even less what exactly this code does ... Should we keep
> it?

I think we need it. It updates the entries of info->pseudo_palette,
which is kind of a pseudocolor palette mapping 16 indices to pixel
values to write to the framebuffer.

If the setcolreg hook is removed, the setcmap hook needs to do this instead.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Michel Dänzer
On 21/06/17 04:38 PM, Daniel Vetter wrote:
> On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
>> This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
>> totally obsolete.
>>
>> I think the gamma_store can end up invalid on error. But the way I read
>> it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
>> this pesky legacy fbdev stuff be any better?
>>
>> drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
>> it saves it to the gamma_store which should already be up to date with what
>> .gamma_get would return and is thus a nop. So, zap it.
> 
> Removing drm_fb_helper_save_lut_atomic should be a separate patch I
> think.
>  
>> Signed-off-by: Peter Rosin 

[...]

>> @@ -1167,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
>> drm_fb_helper *fb_helper,
>>  }
>>  EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
>>  
>> -static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
>> - u16 blue, u16 regno, struct fb_info *info)
>> -{
>> -struct drm_fb_helper *fb_helper = info->par;
>> -struct drm_framebuffer *fb = fb_helper->fb;
>> -
>> -if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
> 
> This case here seems gone, and it was also the pièce de résistance when I
> tried tackling fbdev lut support. As far as I understand this stuff we do
> not support FB_VISUAL_TRUECOLOR palette, and all that bitshifting here is
> pointless. But I'm honestly not really clear.
> 
> I think removing this case should also be a separate patch, and I'd very
> much prefer that someone with some fbdev-clue would ack it.

No need for anyone with fbdev-clue, just run fbset -i. :) fbcon uses a
TRUECOLOR visual at depths > 8.


> It's a pre-existing bug, but should we also try to restore the fbdev lut
> in drm_fb_helper_restore_fbdev_mode_unlocked()? Would be yet another bug,
> but might be relevant for your use-case. Just try to run both an fbdev
> application and some kms-native thing, and then SIGKILL the native kms
> app.
> 
> But since pre-existing not really required, and probably too much effort.

I suspect something like that indeed needs to be done though. E.g.
killing Xorg results in fbcon continuing to use the LUT set by Xorg.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH 11/11] drm: remove unused and redundant callbacks

2017-10-26 Thread Peter Rosin
Drivers no longer have any need for these callbacks, and there are no
users. Zap. Zap-zap-zzzap-p-pp-p.

Signed-off-by: Peter Rosin 
---
 include/drm/drm_fb_helper.h  | 32 
 include/drm/drm_modeset_helper_vtables.h | 16 
 2 files changed, 48 deletions(-)

diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 119e5e4..80d9853 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -85,38 +85,6 @@ struct drm_fb_helper_surface_size {
  */
 struct drm_fb_helper_funcs {
/**
-* @gamma_set:
-*
-* Set the given gamma LUT register on the given CRTC.
-*
-* This callback is optional.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
-   /**
-* @gamma_get:
-*
-* Read the given gamma LUT register on the given CRTC, used to save the
-* current LUT when force-restoring the fbdev for e.g. kdbg.
-*
-* This callback is optional.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
-
-   /**
 * @fb_probe:
 *
 * Driver callback to allocate and initialize the fbdev info structure.
diff --git a/include/drm/drm_modeset_helper_vtables.h 
b/include/drm/drm_modeset_helper_vtables.h
index 85984b2..0773db9 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -267,22 +267,6 @@ struct drm_crtc_helper_funcs {
enum mode_set_atomic);
 
/**
-* @load_lut:
-*
-* Load a LUT prepared with the &drm_fb_helper_funcs.gamma_set vfunc.
-*
-* This callback is optional and is only used by the fbdev emulation
-* helpers.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*load_lut)(struct drm_crtc *crtc);
-
-   /**
 * @disable:
 *
 * This callback should be used to disable the CRTC. With the atomic
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Peter Rosin
On 2017-06-21 09:38, Daniel Vetter wrote:
> On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
>> This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
>> totally obsolete.
>>
>> I think the gamma_store can end up invalid on error. But the way I read
>> it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
>> this pesky legacy fbdev stuff be any better?
>>
>> drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
>> it saves it to the gamma_store which should already be up to date with what
>> .gamma_get would return and is thus a nop. So, zap it.
> 
> Removing drm_fb_helper_save_lut_atomic should be a separate patch I
> think.

Then 3 patches would be needed, first some hybrid thing that does it the
old way, but also stores the lut in .gamma_store, then the split-out that
removes drm_fb_helper_save_lut_atomic, then whatever is needed to get
to the desired code. I can certainly do that, but do you want me to?

I.e., the statement that drm_fb_helper_save_lut_atomic is a nop is only
true when (part of) the other patch is also considered.

>> Signed-off-by: Peter Rosin 
> 
>> ---
>>  drivers/gpu/drm/drm_fb_helper.c | 131 
>> 
>>  1 file changed, 40 insertions(+), 91 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c 
>> b/drivers/gpu/drm/drm_fb_helper.c
>> index 574af01..cc2d55d 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -229,22 +229,6 @@ int drm_fb_helper_remove_one_connector(struct 
>> drm_fb_helper *fb_helper,
>>  }
>>  EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
>>  
>> -static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct 
>> drm_fb_helper *helper)
>> -{
>> -uint16_t *r_base, *g_base, *b_base;
>> -int i;
>> -
>> -if (helper->funcs->gamma_get == NULL)
>> -return;
>> -
>> -r_base = crtc->gamma_store;
>> -g_base = r_base + crtc->gamma_size;
>> -b_base = g_base + crtc->gamma_size;
>> -
>> -for (i = 0; i < crtc->gamma_size; i++)
>> -helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], 
>> &b_base[i], i);
>> -}
>> -
>>  static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
>>  {
>>  uint16_t *r_base, *g_base, *b_base;
>> @@ -285,7 +269,6 @@ int drm_fb_helper_debug_enter(struct fb_info *info)
>>  if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
>>  continue;
>>  
>> -drm_fb_helper_save_lut_atomic(mode_set->crtc, helper);
>>  funcs->mode_set_base_atomic(mode_set->crtc,
>>  mode_set->fb,
>>  mode_set->x,
>> @@ -1167,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
>> drm_fb_helper *fb_helper,
>>  }
>>  EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
>>  
>> -static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
>> - u16 blue, u16 regno, struct fb_info *info)
>> -{
>> -struct drm_fb_helper *fb_helper = info->par;
>> -struct drm_framebuffer *fb = fb_helper->fb;
>> -
>> -if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
> 
> This case here seems gone, and it was also the pièce de résistance when I
> tried tackling fbdev lut support. As far as I understand this stuff we do
> not support FB_VISUAL_TRUECOLOR palette, and all that bitshifting here is
> pointless. But I'm honestly not really clear.

Oops, sorry, I simply missed that, I'll have a closer look...

> I think removing this case should also be a separate patch, and I'd very
> much prefer that someone with some fbdev-clue would ack it.
> 
>> -u32 *palette;
>> -u32 value;
>> -/* place color in psuedopalette */
>> -if (regno > 16)
>> -return -EINVAL;
>> -palette = (u32 *)info->pseudo_palette;
>> -red >>= (16 - info->var.red.length);
>> -green >>= (16 - info->var.green.length);
>> -blue >>= (16 - info->var.blue.length);
>> -value = (red << info->var.red.offset) |
>> -(green << info->var.green.offset) |
>> -(blue << info->var.blue.offset);
>> -if (info->var.transp.length > 0) {
>> -u32 mask = (1 << info->var.transp.length) - 1;
>> -
>> -mask <<= info->var.transp.offset;
>> -value |= mask;
>> -}
>> -palette[regno] = value;
>> -return 0;
>> -}
>> -
>> -/*
>> - * The driver really shouldn't advertise pseudo/directcolor
>> - * visuals if it can't deal with the palette.
>> - */
>> -if (WARN_ON(!fb_helper->funcs->gamma_set ||
>> -!fb_helper->funcs->gamma_get))
>> -return -EINVAL;
>> -
>> -WARN_ON(fb->format->cpp[0] != 1);
>> -
>> -fb_helper-

Re: [PATCH 08/11] drm: nouveau: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
On 2017-06-20 21:25, Peter Rosin wrote:
> The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
> no longer used. Remove the dead code and hook up the crtc .gamma_set
> to use the crtc gamma_store directly instead of duplicating that
> info locally.

[...]

> - for (i = 0; i < 256; i++) {
> - u16 r = nv_crtc->lut.r[i] >> 2;
> - u16 g = nv_crtc->lut.g[i] >> 2;
> - u16 b = nv_crtc->lut.b[i] >> 2;
> + r = crtc->gamma_store;
> + g = r + crtc->gamma_size;
> + b = g + crtc->gamma_size;
>  
> + for (i = 0; i < 256; i++) {
>   if (disp->disp->oclass < GF110_DISP) {
> - writew(r + 0x, lut + (i * 0x08) + 0);
> - writew(g + 0x, lut + (i * 0x08) + 2);
> - writew(b + 0x, lut + (i * 0x08) + 4);
> + writew((*r++ >> 2) + 0x, lut + (i * 0x08) + 0);
> + writew((*g++ >> 2) + 0x, lut + (i * 0x08) + 2);
> + writew((*b++ >> 2) + 0x, lut + (i * 0x08) + 4);
>   } else {
> - writew(r + 0x6000, lut + (i * 0x20) + 0);
> - writew(g + 0x6000, lut + (i * 0x20) + 2);
> - writew(b + 0x6000, lut + (i * 0x20) + 4);
> + writew((*r++ >> 2) + 0x6000, lut + (i * 0x20) + 0);
> + writew((*g++ >> 2) + 0x6000, lut + (i * 0x20) + 2);
> + writew((*b++ >> 2) + 0x6000, lut + (i * 0x20) + 4);
>   }
>   }
>  }

I forgot to mention this, but the above is very strange for
disp->disp->oclass >= GF110_DISP because 0x6000 interferes with
the 14 bits that appear to be the lut depth in the registers.

I suspect some other bit-shift should be used for that case?

Someone should probably consult a datasheet...

Cheers,
peda
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 03/14] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Peter Rosin
This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
totally obsolete.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 154 
 1 file changed, 63 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7ade384..58eb045 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1150,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
 
-static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, u16 regno, struct fb_info *info)
-{
-   struct drm_fb_helper *fb_helper = info->par;
-   struct drm_framebuffer *fb = fb_helper->fb;
-
-   if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
-   u32 *palette;
-   u32 value;
-   /* place color in psuedopalette */
-   if (regno > 16)
-   return -EINVAL;
-   palette = (u32 *)info->pseudo_palette;
-   red >>= (16 - info->var.red.length);
-   green >>= (16 - info->var.green.length);
-   blue >>= (16 - info->var.blue.length);
-   value = (red << info->var.red.offset) |
-   (green << info->var.green.offset) |
-   (blue << info->var.blue.offset);
-   if (info->var.transp.length > 0) {
-   u32 mask = (1 << info->var.transp.length) - 1;
-
-   mask <<= info->var.transp.offset;
-   value |= mask;
-   }
-   palette[regno] = value;
-   return 0;
-   }
-
-   /*
-* The driver really shouldn't advertise pseudo/directcolor
-* visuals if it can't deal with the palette.
-*/
-   if (WARN_ON(!fb_helper->funcs->gamma_set ||
-   !fb_helper->funcs->gamma_get))
-   return -EINVAL;
-
-   WARN_ON(fb->format->cpp[0] != 1);
-
-   fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-   return 0;
-}
-
 /**
  * drm_fb_helper_setcmap - implementation for &fb_ops.fb_setcmap
  * @cmap: cmap to set
@@ -1203,12 +1159,10 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
 {
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
-   const struct drm_crtc_helper_funcs *crtc_funcs;
-   u16 *red, *green, *blue, *transp;
+   struct drm_modeset_acquire_ctx ctx;
struct drm_crtc *crtc;
u16 *r, *g, *b;
-   int i, j, rc = 0;
-   int start;
+   int i, ret;
 
if (oops_in_progress)
return -EBUSY;
@@ -1216,65 +1170,83 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
if (cmap->start + cmap->len < cmap->start)
return -EINVAL;
 
-   drm_modeset_lock_all(dev);
+   drm_modeset_acquire_init(&ctx, 0);
+retry:
+   ret = drm_modeset_lock_all_ctx(dev, &ctx);
+   if (ret)
+   goto out;
if (!drm_fb_helper_is_bound(fb_helper)) {
-   drm_modeset_unlock_all(dev);
-   return -EBUSY;
+   ret = -EBUSY;
+   goto out;
}
 
for (i = 0; i < fb_helper->crtc_count; i++) {
-   crtc = fb_helper->crtc_info[i].mode_set.crtc;
-   crtc_funcs = crtc->helper_private;
-
-   red = cmap->red;
-   green = cmap->green;
-   blue = cmap->blue;
-   transp = cmap->transp;
-   start = cmap->start;
+   if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
+   u32 *palette;
+   int j;
 
-   if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
-   if (!crtc->gamma_size) {
-   rc = -EINVAL;
+   if (cmap->start + cmap->len > 16) {
+   ret = -EINVAL;
goto out;
}
 
-   if (cmap->start + cmap->len > crtc->gamma_size) {
-   rc = -EINVAL;
-   goto out;
+   palette = (u32 *)info->pseudo_palette;
+   for (j = 0; j < cmap->len; ++j) {
+   u16 red = cmap->red[j];
+   u16 green = cmap->green[j];
+   u16 blue = cmap->blue[j];
+   u32 value;
+
+   red >>= 16 - info->var.red.length;
+   green >>= 16 - info->var.green.length;
+   blue >>= 16 - info->var.blue.length;
+   value = (red << info->var.red.offset) |
+   

[PATCH v2 04/14] drm: amd: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   | 24 
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |  1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   | 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   | 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c| 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c| 27 +++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 23 ---
 7 files changed, 28 insertions(+), 128 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c0d8c6f..7dc3780 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -312,31 +312,7 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, 
struct amdgpu_fbdev *rfb
return 0;
 }
 
-/** Sets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   amdgpu_crtc->lut_r[regno] = red >> 6;
-   amdgpu_crtc->lut_g[regno] = green >> 6;
-   amdgpu_crtc->lut_b[regno] = blue >> 6;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
- u16 *blue, int regno)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   *red = amdgpu_crtc->lut_r[regno] << 6;
-   *green = amdgpu_crtc->lut_g[regno] << 6;
-   *blue = amdgpu_crtc->lut_b[regno] << 6;
-}
-
 static const struct drm_fb_helper_funcs amdgpu_fb_helper_funcs = {
-   .gamma_set = amdgpu_crtc_fb_gamma_set,
-   .gamma_get = amdgpu_crtc_fb_gamma_get,
.fb_probe = amdgpufb_create,
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 43a9d3a..39f7eda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -369,7 +369,6 @@ struct amdgpu_atom_ss {
 struct amdgpu_crtc {
struct drm_crtc base;
int crtc_id;
-   u16 lut_r[256], lut_g[256], lut_b[256];
bool enabled;
bool can_tile;
uint32_t crtc_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9f78c03..c958023 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2267,6 +2267,7 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
u32 tmp;
 
@@ -2304,11 +2305,14 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc 
*crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x0007);
 
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
-  (amdgpu_crtc->lut_r[i] << 20) |
-  (amdgpu_crtc->lut_g[i] << 10) |
-  (amdgpu_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 
tmp = RREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset);
@@ -2624,15 +2628,6 @@ static int dce_v10_0_crtc_gamma_set(struct drm_crtc 
*crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
 {
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   int i;
-
-   /* userspace palettes are always correct as is */
-   for (i = 0; i < size; i++) {
-   amdgpu_crtc->lut_r[i] = red[i] >> 6;
-   amdgpu_crtc->lut_g[i] = green[i] >> 6;
-   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
-   }
dce_v10_0_crtc_load_lut(crtc);
 
return 0;
@@ -2844,14 +2839,12 @@ static const struct drm_crtc_helper_funcs 
dce_v10_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v10_0_crtc_set_base_atomic,
.prepare = dce_v10_0_crtc_prepare,
.commit = dce_v10_0_crtc_commit,
-   .load_lut = dce_v10_0_crtc_load_lut,
.disable = dce_v10_0_crtc_disable,
 };
 
 static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int ind

[PATCH v2 02/14] drm/fb-helper: remove drm_fb_helper_save_lut_atomic

2017-10-26 Thread Peter Rosin
drm_fb_helper_save_lut_atomic is redundant since the .gamma_store is
now always kept up to date by drm_fb_helper_setcmap.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 25315fb..7ade384 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -229,22 +229,6 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
 
-static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct 
drm_fb_helper *helper)
-{
-   uint16_t *r_base, *g_base, *b_base;
-   int i;
-
-   if (helper->funcs->gamma_get == NULL)
-   return;
-
-   r_base = crtc->gamma_store;
-   g_base = r_base + crtc->gamma_size;
-   b_base = g_base + crtc->gamma_size;
-
-   for (i = 0; i < crtc->gamma_size; i++)
-   helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], 
&b_base[i], i);
-}
-
 static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
 {
uint16_t *r_base, *g_base, *b_base;
@@ -285,7 +269,6 @@ int drm_fb_helper_debug_enter(struct fb_info *info)
if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
continue;
 
-   drm_fb_helper_save_lut_atomic(mode_set->crtc, helper);
funcs->mode_set_base_atomic(mode_set->crtc,
mode_set->fb,
mode_set->x,
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 00/14] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
Hi!

While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.

I have obviously not tested all of this with more than a compile,
but patches 1 and 3 are enough to make the atmel-hlcdc driver
do what I need (when patched to support CLUT modes). The rest is
just lots of removals and cleanup made possible by the improved
core.

Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere in this mostly mechanical change...

Changes since v1:

- Rebased to next-20170621
- Split 1/11 into a preparatory patch, a cleanup patch and then
  the meat in 3/14.
- Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
- Removed the empty .gamma_get/.gamma_set fb helpers from the
  armada driver that I had somehow managed to ignore but which
  0day found real quick.
- Be less judgemental on drivers only providing .gamma_get and
  .gamma_set, but no .load_lut. That's actually a valid thing
  to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
- Add a comment about colliding bitfields in the nouveau driver.
- Remove gamma_set/gamma_get declarations from the radeon driver
  (the definitions were removed in v1).

Cheers,
peda

Peter Rosin (14):
  drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap
  drm/fb-helper: remove drm_fb_helper_save_lut_atomic
  drm/fb-helper: do a generic fb_setcmap helper in terms of crtc
.gamma_set
  drm: amd: remove dead code and pointless local lut storage
  drm: armada: remove dead empty functions
  drm: ast: remove dead code and pointless local lut storage
  drm: cirrus: remove dead code and pointless local lut storage
  drm: gma500: remove dead code and pointless local lut storage
  drm: i915: remove dead code and pointless local lut storage
  drm: mgag200: remove dead code and pointless local lut storage
  drm: nouveau: remove dead code and pointless local lut storage
  drm: radeon: remove dead code and pointless local lut storage
  drm: stm: remove dead code and pointless local lut storage
  drm: remove unused and redundant callbacks

 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  24 
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|   1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  27 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  27 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  27 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  27 ++---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c|  23 
 drivers/gpu/drm/armada/armada_crtc.c|  10 --
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_fbdev.c   |   2 -
 drivers/gpu/drm/ast/ast_drv.h   |   1 -
 drivers/gpu/drm/ast/ast_fb.c|  20 
 drivers/gpu/drm/ast/ast_mode.c  |  26 +
 drivers/gpu/drm/cirrus/cirrus_drv.h |   8 --
 drivers/gpu/drm/cirrus/cirrus_fbdev.c   |   2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c|  71 +++-
 drivers/gpu/drm/drm_fb_helper.c | 164 +---
 drivers/gpu/drm/gma500/framebuffer.c|  22 
 drivers/gpu/drm/gma500/gma_display.c|  32 ++
 drivers/gpu/drm/gma500/psb_intel_display.c  |   7 +-
 drivers/gpu/drm/gma500/psb_intel_drv.h  |   1 -
 drivers/gpu/drm/i915/intel_drv.h|   1 -
 drivers/gpu/drm/i915/intel_fbdev.c  |  31 --
 drivers/gpu/drm/mgag200/mgag200_drv.h   |   5 -
 drivers/gpu/drm/mgag200/mgag200_fb.c|   2 -
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  62 +++
 drivers/gpu/drm/nouveau/dispnv04/crtc.c |  26 ++---
 drivers/gpu/drm/nouveau/nouveau_crtc.h  |   3 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |  22 
 drivers/gpu/drm/nouveau/nv50_display.c  |  40 +++
 drivers/gpu/drm/radeon/atombios_crtc.c  |   1 -
 drivers/gpu/drm/radeon/radeon_connectors.c  |   7 +-
 drivers/gpu/drm/radeon/radeon_display.c |  71 +---
 drivers/gpu/drm/radeon/radeon_fb.c  |   2 -
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |   1 -
 drivers/gpu/drm/radeon/radeon_mode.h|   4 -
 drivers/gpu/drm/stm/ltdc.c  |  12 --
 drivers/gpu/drm/stm/ltdc.h  |   1 -
 include/drm/drm_fb_helper.h |  32 --
 include/drm/drm_modeset_helper_vtables.h|  16 ---
 40 files changed, 205 insertions(+), 658 deletions(-)

-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 01/14] drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap

2017-10-26 Thread Peter Rosin
I think the gamma_store can end up invalid on error. But the way I read
it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
this pesky legacy fbdev stuff be any better?

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 574af01..25315fb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1223,12 +1223,16 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
const struct drm_crtc_helper_funcs *crtc_funcs;
u16 *red, *green, *blue, *transp;
struct drm_crtc *crtc;
+   u16 *r, *g, *b;
int i, j, rc = 0;
int start;
 
if (oops_in_progress)
return -EBUSY;
 
+   if (cmap->start + cmap->len < cmap->start)
+   return -EINVAL;
+
drm_modeset_lock_all(dev);
if (!drm_fb_helper_is_bound(fb_helper)) {
drm_modeset_unlock_all(dev);
@@ -1245,6 +1249,29 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
transp = cmap->transp;
start = cmap->start;
 
+   if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
+   if (!crtc->gamma_size) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   if (cmap->start + cmap->len > crtc->gamma_size) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   memcpy(r + cmap->start, cmap->red,
+  cmap->len * sizeof(u16));
+   memcpy(g + cmap->start, cmap->green,
+  cmap->len * sizeof(u16));
+   memcpy(b + cmap->start, cmap->blue,
+  cmap->len * sizeof(u16));
+   }
+
for (j = 0; j < cmap->len; j++) {
u16 hred, hgreen, hblue, htransp = 0x;
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 06/14] drm: ast: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/ast/ast_drv.h  |  1 -
 drivers/gpu/drm/ast/ast_fb.c   | 20 
 drivers/gpu/drm/ast/ast_mode.c | 26 ++
 3 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 8880f0b..569a148 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -245,7 +245,6 @@ struct ast_connector {
 
 struct ast_crtc {
struct drm_crtc base;
-   u8 lut_r[256], lut_g[256], lut_b[256];
struct drm_gem_object *cursor_bo;
uint64_t cursor_addr;
int cursor_width, cursor_height;
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index 4ad4acd..dbabcac 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -255,27 +255,7 @@ static int astfb_create(struct drm_fb_helper *helper,
return ret;
 }
 
-static void ast_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-  u16 blue, int regno)
-{
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   ast_crtc->lut_r[regno] = red >> 8;
-   ast_crtc->lut_g[regno] = green >> 8;
-   ast_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-  u16 *blue, int regno)
-{
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   *red = ast_crtc->lut_r[regno] << 8;
-   *green = ast_crtc->lut_g[regno] << 8;
-   *blue = ast_crtc->lut_b[regno] << 8;
-}
-
 static const struct drm_fb_helper_funcs ast_fb_helper_funcs = {
-   .gamma_set = ast_fb_gamma_set,
-   .gamma_get = ast_fb_gamma_get,
.fb_probe = astfb_create,
 };
 
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index aaef0a6..724c16b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -63,15 +63,18 @@ static inline void ast_load_palette_index(struct 
ast_private *ast,
 static void ast_crtc_load_lut(struct drm_crtc *crtc)
 {
struct ast_private *ast = crtc->dev->dev_private;
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
+   u16 *r, *g, *b;
int i;
 
if (!crtc->enabled)
return;
 
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++)
-   ast_load_palette_index(ast, i, ast_crtc->lut_r[i],
-  ast_crtc->lut_g[i], ast_crtc->lut_b[i]);
+   ast_load_palette_index(ast, i, *r++ >> 8, *g++ >> 8, *b++ >> 8);
 }
 
 static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct 
drm_display_mode *mode,
@@ -633,7 +636,6 @@ static const struct drm_crtc_helper_funcs 
ast_crtc_helper_funcs = {
.mode_set = ast_crtc_mode_set,
.mode_set_base = ast_crtc_mode_set_base,
.disable = ast_crtc_disable,
-   .load_lut = ast_crtc_load_lut,
.prepare = ast_crtc_prepare,
.commit = ast_crtc_commit,
 
@@ -648,15 +650,6 @@ static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 
*red, u16 *green,
  u16 *blue, uint32_t size,
  struct drm_modeset_acquire_ctx *ctx)
 {
-   struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-   int i;
-
-   /* userspace palettes are always correct as is */
-   for (i = 0; i < size; i++) {
-   ast_crtc->lut_r[i] = red[i] >> 8;
-   ast_crtc->lut_g[i] = green[i] >> 8;
-   ast_crtc->lut_b[i] = blue[i] >> 8;
-   }
ast_crtc_load_lut(crtc);
 
return 0;
@@ -681,7 +674,6 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
 static int ast_crtc_init(struct drm_device *dev)
 {
struct ast_crtc *crtc;
-   int i;
 
crtc = kzalloc(sizeof(struct ast_crtc), GFP_KERNEL);
if (!crtc)
@@ -690,12 +682,6 @@ static int ast_crtc_init(struct drm_device *dev)
drm_crtc_init(dev, &crtc->base, &ast_crtc_funcs);
drm_mode_crtc_set_gamma_size(&crtc->base, 256);
drm_crtc_helper_add(&crtc->base, &ast_crtc_helper_funcs);
-
-   for (i = 0; i < 256; i++) {
-   crtc->lut_r[i] = i;
-   crtc->lut_g[i] = i;
-   crtc->lut_b[i] = i;
-   }
return 0;
 }
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 05/14] drm: armada: remove dead empty functions

2017-10-26 Thread Peter Rosin
The redundant fb helpers .gamma_set and .gamma_get are no longer used.
Remove the dead code.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/armada/armada_crtc.c  | 10 --
 drivers/gpu/drm/armada/armada_crtc.h  |  2 --
 drivers/gpu/drm/armada/armada_fbdev.c |  2 --
 3 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c 
b/drivers/gpu/drm/armada/armada_crtc.c
index 4fe19fd..96bccf8 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -334,16 +334,6 @@ static void armada_drm_vblank_off(struct armada_crtc 
*dcrtc)
armada_drm_plane_work_run(dcrtc, dcrtc->crtc.primary);
 }
 
-void armada_drm_crtc_gamma_set(struct drm_crtc *crtc, u16 r, u16 g, u16 b,
-   int idx)
-{
-}
-
-void armada_drm_crtc_gamma_get(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-   int idx)
-{
-}
-
 /* The mode_config.mutex will be held for this call */
 static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
 {
diff --git a/drivers/gpu/drm/armada/armada_crtc.h 
b/drivers/gpu/drm/armada/armada_crtc.h
index 7e8906d..bab11f4 100644
--- a/drivers/gpu/drm/armada/armada_crtc.h
+++ b/drivers/gpu/drm/armada/armada_crtc.h
@@ -102,8 +102,6 @@ struct armada_crtc {
 };
 #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
 
-void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
-void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
 void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
 
 void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 602dfea..5fa076d 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -118,8 +118,6 @@ static int armada_fb_probe(struct drm_fb_helper *fbh,
 }
 
 static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
-   .gamma_set  = armada_drm_crtc_gamma_set,
-   .gamma_get  = armada_drm_crtc_gamma_get,
.fb_probe   = armada_fb_probe,
 };
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 08/14] drm: gma500: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .gamma_set and .gamma_get are no longer
used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/gma500/framebuffer.c   | 22 
 drivers/gpu/drm/gma500/gma_display.c   | 32 ++
 drivers/gpu/drm/gma500/psb_intel_display.c |  7 +--
 drivers/gpu/drm/gma500/psb_intel_drv.h |  1 -
 4 files changed, 12 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 7da70b6..2570c7f 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -479,26 +479,6 @@ static struct drm_framebuffer *psb_user_framebuffer_create
return psb_framebuffer_create(dev, cmd, r);
 }
 
-static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
-   gma_crtc->lut_r[regno] = red >> 8;
-   gma_crtc->lut_g[regno] = green >> 8;
-   gma_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
-   u16 *green, u16 *blue, int regno)
-{
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
-   *red = gma_crtc->lut_r[regno] << 8;
-   *green = gma_crtc->lut_g[regno] << 8;
-   *blue = gma_crtc->lut_b[regno] << 8;
-}
-
 static int psbfb_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
 {
@@ -525,8 +505,6 @@ static int psbfb_probe(struct drm_fb_helper *helper,
 }
 
 static const struct drm_fb_helper_funcs psb_fb_helper_funcs = {
-   .gamma_set = psbfb_gamma_set,
-   .gamma_get = psbfb_gamma_get,
.fb_probe = psbfb_probe,
 };
 
diff --git a/drivers/gpu/drm/gma500/gma_display.c 
b/drivers/gpu/drm/gma500/gma_display.c
index e7fd356..f3c48a2 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -144,33 +144,32 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe];
int palreg = map->palette;
+   u16 *r, *g, *b;
int i;
 
/* The clocks have to be on to load the palette. */
if (!crtc->enabled)
return;
 
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
if (gma_power_begin(dev, false)) {
for (i = 0; i < 256; i++) {
REG_WRITE(palreg + 4 * i,
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]));
+ (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+ (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+ ((*b++ >> 8) + gma_crtc->lut_adj[i]));
}
gma_power_end(dev);
} else {
for (i = 0; i < 256; i++) {
/* FIXME: Why pipe[0] and not pipe[..._crtc->pipe]? */
dev_priv->regs.pipe[0].palette[i] =
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]);
+   (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+   (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+   ((*b++ >> 8) + gma_crtc->lut_adj[i]);
}
 
}
@@ -180,15 +179,6 @@ int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, 
u16 *green, u16 *blue,
   u32 size,
   struct drm_modeset_acquire_ctx *ctx)
 {
-   struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   gma_crtc->lut_r[i] = red[i] >> 8;
-   gma_crtc->lut_g[i] = green[i] >> 8;
-   gma_crtc->lut_b[i] = blue[i] >> 8;
-   }
-
gma_crtc_load_lut(crtc);
 
return 0;
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c 
b/drivers/gpu/drm/gma500/psb_intel_display.c
index 7b6c849..8762efa 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_displ

[PATCH v2 09/14] drm: i915: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The driver stores lut values from the fbdev interface, and is able
to give them back, but does not appear to do anything with these
lut values. The generic fb helpers have replaced this function,
and may even have made the driver work for the C8 mode from the
fbdev interface. But that is untested.

Since the fb helpers .gamma_set and .gamma_get are obsolete,
remove the dead code.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/i915/intel_drv.h   |  1 -
 drivers/gpu/drm/i915/intel_fbdev.c | 31 ---
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d93efb4..bc7bfa0 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -786,7 +786,6 @@ struct intel_crtc {
struct drm_crtc base;
enum pipe pipe;
enum plane plane;
-   u8 lut_r[256], lut_g[256], lut_b[256];
/*
 * Whether the crtc and the connected output pipeline is active. Implies
 * that crtc->enabled is set, i.e. the current mode configuration has
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index 03347c6..5bac953 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -281,27 +281,6 @@ static int intelfb_create(struct drm_fb_helper *helper,
return ret;
 }
 
-/** Sets the color ramps on behalf of RandR */
-static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-   intel_crtc->lut_r[regno] = red >> 8;
-   intel_crtc->lut_g[regno] = green >> 8;
-   intel_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, int regno)
-{
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-   *red = intel_crtc->lut_r[regno] << 8;
-   *green = intel_crtc->lut_g[regno] << 8;
-   *blue = intel_crtc->lut_b[regno] << 8;
-}
-
 static struct drm_fb_helper_crtc *
 intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
 {
@@ -370,7 +349,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_fb_helper_crtc *new_crtc;
-   struct intel_crtc *intel_crtc;
 
fb_conn = fb_helper->connector_info[i];
connector = fb_conn->connector;
@@ -412,13 +390,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
 
num_connectors_enabled++;
 
-   intel_crtc = to_intel_crtc(connector->state->crtc);
-   for (j = 0; j < 256; j++) {
-   intel_crtc->lut_r[j] = j;
-   intel_crtc->lut_g[j] = j;
-   intel_crtc->lut_b[j] = j;
-   }
-
new_crtc = intel_fb_helper_crtc(fb_helper,
connector->state->crtc);
 
@@ -519,8 +490,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper 
*fb_helper,
 
 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.initial_config = intel_fb_initial_config,
-   .gamma_set = intel_crtc_fb_gamma_set,
-   .gamma_get = intel_crtc_fb_gamma_get,
.fb_probe = intelfb_create,
 };
 
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 07/14] drm: cirrus: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  8 
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 71 ---
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352..be2d7e48 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
struct drm_crtc base;
-   u8  lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
boolenabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 
-   /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
-
-
/* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
  struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..1fedab0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-   .gamma_set = cirrus_crtc_fb_gamma_set,
-   .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
 };
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 53f6f0f..a4c4a46 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   struct cirrus_device *cdev = dev->dev_private;
-   int i;
-
-   if (!crtc->enabled)
-   return;
-
-   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-   /* VGA registers */
-   WREG8(PALETTE_INDEX, i);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-   }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, 
u16 *red, u16 *green,
 u16 *blue, uint32_t size,
 struct drm_modeset_acquire_ctx *ctx)
 {
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct cirrus_device *cdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
-   for (i = 0; i < size; i++) {
-   cirrus_crtc->lut_r[i] = red[i];
-   cirrus_crtc->lut_g[i] = green[i];
-   cirrus_crtc->lut_b[i] = blue[i];
+   if (!crtc->enabled)
+   return 0;
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+   /* VGA registers */
+   WREG8(PALETTE_INDEX, i);
+   WREG8(PALETTE_DATA, *r++ >> 8);
+   WREG8(PALETTE_DATA, *g++ >> 8);
+   WREG8(PALETTE_DATA, *b++ >> 8);
}
-   cirrus_crtc_load_lut(crtc);
 
return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
-   .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
-   int i;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cde

[PATCH v2 12/14] drm: radeon: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/radeon/atombios_crtc.c  |  1 -
 drivers/gpu/drm/radeon/radeon_connectors.c  |  7 ++-
 drivers/gpu/drm/radeon/radeon_display.c | 71 -
 drivers/gpu/drm/radeon/radeon_fb.c  |  2 -
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  1 -
 drivers/gpu/drm/radeon/radeon_mode.h|  4 --
 6 files changed, 33 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index 3c492a0..02baaaf 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -2217,7 +2217,6 @@ static const struct drm_crtc_helper_funcs 
atombios_helper_funcs = {
.mode_set_base_atomic = atombios_crtc_set_base_atomic,
.prepare = atombios_crtc_prepare,
.commit = atombios_crtc_commit,
-   .load_lut = radeon_crtc_load_lut,
.disable = atombios_crtc_disable,
 };
 
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index 27affbd..2f642cb 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -773,12 +773,15 @@ static int radeon_connector_set_property(struct 
drm_connector *connector, struct
 
if (connector->encoder->crtc) {
struct drm_crtc *crtc  = connector->encoder->crtc;
-   const struct drm_crtc_helper_funcs *crtc_funcs = 
crtc->helper_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 
radeon_crtc->output_csc = radeon_encoder->output_csc;
 
-   (*crtc_funcs->load_lut)(crtc);
+   /*
+* Our .gamma_set assumes the .gamma_store has been
+* prefilled and don't care about its arguments.
+*/
+   crtc->funcs->gamma_set(crtc, NULL, NULL, NULL, 0, NULL);
}
}
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 17d3daf..8b7d7a0 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -42,6 +42,7 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -60,11 +61,14 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
WREG32(AVIVO_DC_LUT_WRITE_EN_MASK, 0x003f);
 
WREG8(AVIVO_DC_LUT_RW_INDEX, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(AVIVO_DC_LUT_30_COLOR,
-(radeon_crtc->lut_r[i] << 20) |
-(radeon_crtc->lut_g[i] << 10) |
-(radeon_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 
/* Only change bit 0 of LUT_SEL, other bits are set elsewhere */
@@ -76,6 +80,7 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -93,11 +98,14 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 
0x0007);
 
WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
-  (radeon_crtc->lut_r[i] << 20) |
-  (radeon_crtc->lut_g[i] << 10) |
-  (radeon_crtc->lut_b[i] << 0));
+  ((*r++ & 0xffc0) << 14) |
+  ((*g++ & 0xffc0) << 4) |
+  (*b++ >> 6));
}
 }
 
@@ -106,6 +114,7 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ 

[PATCH v2 14/14] drm: remove unused and redundant callbacks

2017-10-26 Thread Peter Rosin
Drivers no longer have any need for these callbacks, and there are no
users. Zap. Zap-zap-zzzap-p-pp-p.

Signed-off-by: Peter Rosin 
---
 include/drm/drm_fb_helper.h  | 32 
 include/drm/drm_modeset_helper_vtables.h | 16 
 2 files changed, 48 deletions(-)

diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 119e5e4..80d9853 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -85,38 +85,6 @@ struct drm_fb_helper_surface_size {
  */
 struct drm_fb_helper_funcs {
/**
-* @gamma_set:
-*
-* Set the given gamma LUT register on the given CRTC.
-*
-* This callback is optional.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
-   /**
-* @gamma_get:
-*
-* Read the given gamma LUT register on the given CRTC, used to save the
-* current LUT when force-restoring the fbdev for e.g. kdbg.
-*
-* This callback is optional.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
-
-   /**
 * @fb_probe:
 *
 * Driver callback to allocate and initialize the fbdev info structure.
diff --git a/include/drm/drm_modeset_helper_vtables.h 
b/include/drm/drm_modeset_helper_vtables.h
index 85984b2..0773db9 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -267,22 +267,6 @@ struct drm_crtc_helper_funcs {
enum mode_set_atomic);
 
/**
-* @load_lut:
-*
-* Load a LUT prepared with the &drm_fb_helper_funcs.gamma_set vfunc.
-*
-* This callback is optional and is only used by the fbdev emulation
-* helpers.
-*
-* FIXME:
-*
-* This callback is functionally redundant with the core gamma table
-* support and simply exists because the fbdev hasn't yet been
-* refactored to use the core gamma table interfaces.
-*/
-   void (*load_lut)(struct drm_crtc *crtc);
-
-   /**
 * @disable:
 *
 * This callback should be used to disable the CRTC. With the atomic
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: BUG: KASAN: use-after-free in free_old_xmit_skbs

2017-10-26 Thread jean-philippe menil
2017-06-06 1:52 GMT+02:00 Michael S. Tsirkin :

> On Mon, Jun 05, 2017 at 05:08:25AM +0300, Michael S. Tsirkin wrote:
> > On Mon, Jun 05, 2017 at 12:48:53AM +0200, Jean-Philippe Menil wrote:
> > > Hi,
> > >
> > > while playing with xdp and ebpf, i'm hitting the following:
> > >
> > > [  309.993136]
> > > ==
> > > [  309.994735] BUG: KASAN: use-after-free in
> > > free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [  309.998396] Read of size 8 at addr 88006aa64220 by task sshd/323
> > > [  310.000650]
> > > [  310.002305] CPU: 1 PID: 323 Comm: sshd Not tainted 4.12.0-rc3+ #2
> > > [  310.004018] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS
> > > 1.10.2-20170228_101828-anatol 04/01/2014
> > > [  310.006495] Call Trace:
> > > [  310.007610]  dump_stack+0xb8/0x14c
> > > [  310.008748]  ? _atomic_dec_and_lock+0x174/0x174
> > > [  310.009998]  ? pm_qos_get_value.part.7+0x6/0x6
> > > [  310.011203]  print_address_description+0x6f/0x280
> > > [  310.012416]  kasan_report+0x27a/0x370
> > > [  310.013573]  ? free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [  310.014900]  __asan_report_load8_noabort+0x19/0x20
> > > [  310.016136]  free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [  310.017467]  ? virtnet_del_vqs+0xe0/0xe0 [virtio_net]
> > > [  310.018759]  ? packet_rcv+0x20d0/0x20d0
> > > [  310.019950]  ? dev_queue_xmit_nit+0x5cd/0xaf0
> > > [  310.021168]  start_xmit+0x1b4/0x1b10 [virtio_net]
> > > [  310.022413]  ? default_device_exit+0x2d0/0x2d0
> > > [  310.023634]  ? virtnet_remove+0xf0/0xf0 [virtio_net]
> > > [  310.024874]  ? update_load_avg+0x1281/0x29f0
> > > [  310.026059]  dev_hard_start_xmit+0x1ea/0x7f0
> > > [  310.027247]  ? validate_xmit_skb_list+0x100/0x100
> > > [  310.028470]  ? validate_xmit_skb+0x7f/0xc10
> > > [  310.029731]  ? netif_skb_features+0x920/0x920
> > > [  310.033469]  ? __skb_tx_hash+0x2f0/0x2f0
> > > [  310.035615]  ? validate_xmit_skb_list+0xa3/0x100
> > > [  310.037782]  sch_direct_xmit+0x2eb/0x7a0
> > > [  310.039842]  ? dev_deactivate_queue.constprop.29+0x230/0x230
> > > [  310.041980]  ? netdev_pick_tx+0x212/0x2b0
> > > [  310.043868]  __dev_queue_xmit+0x12fa/0x20b0
> > > [  310.045564]  ? netdev_pick_tx+0x2b0/0x2b0
> > > [  310.047210]  ? __account_cfs_rq_runtime+0x630/0x630
> > > [  310.048301]  ? update_stack_state+0x402/0x780
> > > [  310.049307]  ? account_entity_enqueue+0x730/0x730
> > > [  310.050322]  ? __rb_erase_color+0x27d0/0x27d0
> > > [  310.051286]  ? update_curr_fair+0x70/0x70
> > > [  310.052206]  ? enqueue_entity+0x2450/0x2450
> > > [  310.053124]  ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [  310.054082]  ? dequeue_entity+0x27a/0x1520
> > > [  310.054967]  ? bpf_prog_alloc+0x320/0x320
> > > [  310.055822]  ? yield_to_task_fair+0x110/0x110
> > > [  310.056708]  ? set_next_entity+0x2f2/0xa90
> > > [  310.057574]  ? dequeue_task_fair+0xc09/0x2ec0
> > > [  310.058457]  dev_queue_xmit+0x10/0x20
> > > [  310.059298]  ip_finish_output2+0xacf/0x12a0
> > > [  310.060160]  ? dequeue_entity+0x1520/0x1520
> > > [  310.063410]  ? ip_fragment.constprop.47+0x220/0x220
> > > [  310.065078]  ? ring_buffer_set_clock+0x50/0x50
> > > [  310.066677]  ? __switch_to+0x685/0xda0
> > > [  310.068166]  ? load_balance+0x38f0/0x38f0
> > > [  310.069544]  ? compat_start_thread+0x80/0x80
> > > [  310.070989]  ? trace_find_cmdline+0x60/0x60
> > > [  310.072402]  ? rt_cpu_seq_show+0x2d0/0x2d0
> > > [  310.073579]  ip_finish_output+0x407/0x880
> > > [  310.074441]  ? ip_finish_output+0x407/0x880
> > > [  310.075255]  ? update_stack_state+0x402/0x780
> > > [  310.076076]  ip_output+0x1c0/0x640
> > > [  310.076843]  ? ip_mc_output+0x1350/0x1350
> > > [  310.077642]  ? __sk_dst_check+0x164/0x370
> > > [  310.078441]  ? complete_formation.isra.53+0xa30/0xa30
> > > [  310.079313]  ? __read_once_size_nocheck.constprop.7+0x20/0x20
> > > [  310.080265]  ? sock_prot_inuse_add+0xa0/0xa0
> > > [  310.081097]  ? memcpy+0x45/0x50
> > > [  310.081850]  ? __copy_skb_header+0x1fa/0x280
> > > [  310.082676]  ip_local_out+0x70/0x90
> > > [  310.083448]  ip_queue_xmit+0x8a1/0x22a0
> > > [  310.084236]  ? ip_build_and_send_pkt+0xe80/0xe80
> > > [  310.085079]  ? tcp_v4_md5_lookup+0x13/0x20
> > > [  310.085884]  tcp_transmit_skb+0x187a/0x3e00
> > > [  310.086696]  ? __tcp_select_window+0xaf0/0xaf0
> > > [  310.087524]  ? sock_sendmsg+0xba/0xf0
> > > [  310.088298]  ? __vfs_write+0x4e0/0x960
> > > [  310.089074]  ? vfs_write+0x155/0x4b0
> > > [  310.089838]  ? SyS_write+0xf7/0x240
> > > [  310.090593]  ? do_syscall_64+0x235/0x5b0
> > > [  310.091372]  ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [  310.094690]  ? sock_sendmsg+0xba/0xf0
> > > [  310.096133]  ? do_syscall_64+0x235/0x5b0
> > > [  310.097593]  ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [  310.099157]  ? tcp_init_tso_segs+0x1e0/0x1e0
> > > [  310.100539]  ? radix_tree_lookup+0xd/0x10
> > > [  310.101894]  ? get_work_pool+0xcd/0x150
> > > [  3

[PATCH v2 10/14] drm: mgag200: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  5 ---
 drivers/gpu/drm/mgag200/mgag200_fb.c   |  2 --
 drivers/gpu/drm/mgag200/mgag200_mode.c | 62 --
 3 files changed, 15 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index c88b6ec..04f1dfb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -237,11 +237,6 @@ mgag200_bo(struct ttm_buffer_object *bo)
 {
return container_of(bo, struct mgag200_bo, bo);
 }
-   /* mgag200_crtc.c */
-void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
 
/* mgag200_mode.c */
 int mgag200_modeset_init(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 5d3b1fa..5cf980a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -258,8 +258,6 @@ static int mga_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs mga_fb_helper_funcs = {
-   .gamma_set = mga_crtc_fb_gamma_set,
-   .gamma_get = mga_crtc_fb_gamma_get,
.fb_probe = mgag200fb_create,
 };
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index f4b5358..5e9cd4c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -27,15 +27,19 @@
 
 static void mga_crtc_load_lut(struct drm_crtc *crtc)
 {
-   struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct mga_device *mdev = dev->dev_private;
struct drm_framebuffer *fb = crtc->primary->fb;
+   u16 *r_ptr, *g_ptr, *b_ptr;
int i;
 
if (!crtc->enabled)
return;
 
+   r_ptr = crtc->gamma_store;
+   g_ptr = r_ptr + crtc->gamma_size;
+   b_ptr = g_ptr + crtc->gamma_size;
+
WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
if (fb && fb->format->cpp[0] * 8 == 16) {
@@ -46,25 +50,27 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
if (i > (MGAG200_LUT_SIZE >> 1)) {
r = b = 0;
} else {
-   r = mga_crtc->lut_r[i << 1];
-   b = mga_crtc->lut_b[i << 1];
+   r = *r_ptr++ >> 8;
+   b = *b_ptr++ >> 8;
+   r_ptr++;
+   b_ptr++;
}
} else {
-   r = mga_crtc->lut_r[i];
-   b = mga_crtc->lut_b[i];
+   r = *r_ptr++ >> 8;
+   b = *b_ptr++ >> 8;
}
/* VGA registers */
WREG8(DAC_INDEX + MGA1064_COL_PAL, r);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
WREG8(DAC_INDEX + MGA1064_COL_PAL, b);
}
return;
}
for (i = 0; i < MGAG200_LUT_SIZE; i++) {
/* VGA registers */
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_r[i]);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
-   WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_b[i]);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *r_ptr++ >> 8);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
+   WREG8(DAC_INDEX + MGA1064_COL_PAL, *b_ptr++ >> 8);
}
 }
 
@@ -1399,14 +1405,6 @@ static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 
*red, u16 *green,
  u16 *blue, uint32_t size,
  struct drm_modeset_acquire_ctx *ctx)
 {
-   struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   mga_crtc->lut_r[i] = red[i] >> 8;
-   mga_crtc->lut_g[i] = green[i] >> 8;
-   mga_crtc->lut_b[i] = blue[i] >> 8;
-   }
mga_crtc_load_lut(crtc);
 
return 0;
@@ -1455,14 +1453,12 @@ static const struct drm_crtc_helper_funcs 
mga_helper_funcs = {
.mode_set_base = mga_crtc_mode_set_base,
 

[PATCH v2 13/14] drm: stm: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helper .load_lut is no longer used, and can not
work right without also providing the fb helpers .gamma_set and
.gamma_get thus rendering the code in this driver suspect.

Just remove the dead code.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/stm/ltdc.c | 12 
 drivers/gpu/drm/stm/ltdc.h |  1 -
 2 files changed, 13 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 1b9483d..87829b9 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -375,17 +375,6 @@ static irqreturn_t ltdc_irq(int irq, void *arg)
  * DRM_CRTC
  */
 
-static void ltdc_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   unsigned int i, lay;
-
-   for (lay = 0; lay < ldev->caps.nb_layers; lay++)
-   for (i = 0; i < 256; i++)
-   reg_write(ldev->regs, LTDC_L1CLUTWR + lay * LAY_OFS,
- ldev->clut[i]);
-}
-
 static void ltdc_crtc_enable(struct drm_crtc *crtc)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
@@ -523,7 +512,6 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
-   .load_lut = ltdc_crtc_load_lut,
.enable = ltdc_crtc_enable,
.disable = ltdc_crtc_disable,
.mode_set_nofb = ltdc_crtc_mode_set_nofb,
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index d7a9c73..620ca55 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -27,7 +27,6 @@ struct ltdc_device {
struct drm_panel *panel;
struct mutex err_lock;  /* protecting error_status */
struct ltdc_caps caps;
-   u32 clut[256];  /* color look up table */
u32 error_status;
u32 irq_status;
 };
-- 
2.1.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 11/14] drm: nouveau: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 26 -
 drivers/gpu/drm/nouveau/nouveau_crtc.h  |  3 ---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 22 --
 drivers/gpu/drm/nouveau/nv50_display.c  | 40 +++--
 4 files changed, 22 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 4b4b0b4..8f689f1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -764,13 +764,18 @@ nv_crtc_gamma_load(struct drm_crtc *crtc)
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct drm_device *dev = nv_crtc->base.dev;
struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs;
+   u16 *r, *g, *b;
int i;
 
rgbs = (struct rgb 
*)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC;
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++) {
-   rgbs[i].r = nv_crtc->lut.r[i] >> 8;
-   rgbs[i].g = nv_crtc->lut.g[i] >> 8;
-   rgbs[i].b = nv_crtc->lut.b[i] >> 8;
+   rgbs[i].r = *r++ >> 8;
+   rgbs[i].g = *g++ >> 8;
+   rgbs[i].b = *b++ >> 8;
}
 
nouveau_hw_load_state_palette(dev, nv_crtc->index, 
&nv04_display(dev)->mode_reg);
@@ -792,13 +797,6 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, 
u16 *b,
  struct drm_modeset_acquire_ctx *ctx)
 {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-   int i;
-
-   for (i = 0; i < size; i++) {
-   nv_crtc->lut.r[i] = r[i];
-   nv_crtc->lut.g[i] = g[i];
-   nv_crtc->lut.b[i] = b[i];
-   }
 
/* We need to know the depth before we upload, but it's possible to
 * get called before a framebuffer is bound.  If this is the case,
@@ -1095,7 +1093,6 @@ static const struct drm_crtc_helper_funcs 
nv04_crtc_helper_funcs = {
.mode_set = nv_crtc_mode_set,
.mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
-   .load_lut = nv_crtc_gamma_load,
.disable = nv_crtc_disable,
 };
 
@@ -1103,17 +1100,12 @@ int
 nv04_crtc_create(struct drm_device *dev, int crtc_num)
 {
struct nouveau_crtc *nv_crtc;
-   int ret, i;
+   int ret;
 
nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
if (!nv_crtc)
return -ENOMEM;
 
-   for (i = 0; i < 256; i++) {
-   nv_crtc->lut.r[i] = i << 8;
-   nv_crtc->lut.g[i] = i << 8;
-   nv_crtc->lut.b[i] = i << 8;
-   }
nv_crtc->lut.depth = 0;
 
nv_crtc->index = crtc_num;
diff --git a/drivers/gpu/drm/nouveau/nouveau_crtc.h 
b/drivers/gpu/drm/nouveau/nouveau_crtc.h
index 050fcf3..b7a18fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_crtc.h
+++ b/drivers/gpu/drm/nouveau/nouveau_crtc.h
@@ -61,9 +61,6 @@ struct nouveau_crtc {
 
struct {
struct nouveau_bo *nvbo;
-   uint16_t r[256];
-   uint16_t g[256];
-   uint16_t b[256];
int depth;
} lut;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2665a07..f770784 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -278,26 +278,6 @@ nouveau_fbcon_accel_init(struct drm_device *dev)
info->fbops = &nouveau_fbcon_ops;
 }
 
-static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-   u16 blue, int regno)
-{
-   struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
-   nv_crtc->lut.r[regno] = red;
-   nv_crtc->lut.g[regno] = green;
-   nv_crtc->lut.b[regno] = blue;
-}
-
-static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, int regno)
-{
-   struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
-   *red = nv_crtc->lut.r[regno];
-   *green = nv_crtc->lut.g[regno];
-   *blue = nv_crtc->lut.b[regno];
-}
-
 static void
 nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon)
 {
@@ -467,8 +447,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info)
 }
 
 static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
-   .gamma_set = nouveau_fbcon_gamma_set,
-   .gamma_get = nouveau_fbcon_gamma_get,
.fb_probe = nouveau_fbcon_create,
 };
 
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c 
b/drivers/gpu/drm/nouveau/nv50_display.c
index e3132a2

Re: [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Peter Rosin
On 2017-06-22 08:36, Daniel Vetter wrote:
> On Wed, Jun 21, 2017 at 11:40:52AM +0200, Peter Rosin wrote:
>> On 2017-06-21 09:38, Daniel Vetter wrote:
>>> On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
 This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
 totally obsolete.

 I think the gamma_store can end up invalid on error. But the way I read
 it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
 this pesky legacy fbdev stuff be any better?

 drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
 it saves it to the gamma_store which should already be up to date with what
 .gamma_get would return and is thus a nop. So, zap it.
>>>
>>> Removing drm_fb_helper_save_lut_atomic should be a separate patch I
>>> think.
>>
>> Then 3 patches would be needed, first some hybrid thing that does it the
>> old way, but also stores the lut in .gamma_store, then the split-out that
>> removes drm_fb_helper_save_lut_atomic, then whatever is needed to get
>> to the desired code. I can certainly do that, but do you want me to?
> 
> Explain that in the commit message and it's fine.

I did the split in v2, I assume that's ok too. Better in case anyone ever
needs to run a bisect on this...

>>> It's a pre-existing bug, but should we also try to restore the fbdev lut
>>> in drm_fb_helper_restore_fbdev_mode_unlocked()? Would be yet another bug,
>>> but might be relevant for your use-case. Just try to run both an fbdev
>>> application and some kms-native thing, and then SIGKILL the native kms
>>> app.
>>>
>>> But since pre-existing not really required, and probably too much effort.
>>
>> Good thing too, because I don't really know my way around this code...
> 
> Btw I cc'ed you on one of my patches in the fbdev locking series, we might
> need to do the same legacy vs. atomic split for the new lut code as I did
> for dpms. The rule with atomic is that you can't do multiple commits under
> drm_modeset_lock_all, you either have to do one overall atomic commit
> (preferred) or drop&reacquire locks again. This matters for LUT since
> you're updating the LUT on all CRTCs, which when using the gamma_set
> atomic helper would be multiple commits :-/

Ahh, ok, I see the problem.

> Using the dpms patch as template it shouldn't be too hard to address that
> for your patch here too.

Hmm, in that patch you handle the legacy case in a separate function, and
doing that for the lut case looks difficult when the atomic commit happens
inside the helper (typically drm_atomic_helper_legacy_gamma_set which
could perhaps be handled, but a real drag to handle for drivers that have
a custom crtc .gamma_set).

So, I'm aiming for the drop&reacquire approach...

However, I don't have all of that series, and I suspect that is why I do
not have any fb_helper->lock.

I'll send my best guess as a follow-up to patch 3/14 in v2.

Cheers,
peda
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 01/14] drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap

2017-10-26 Thread Peter Rosin
I think the gamma_store can end up invalid on error. But the way I read
it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
this pesky legacy fbdev stuff be any better?

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 27 +++
 1 file changed, 27 insertions(+)

This is an alternative version rebased on top of Daniels "fbdev helper
locking rework and deferred setup" series.

Cheers,
peda

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a4cfef9..c7122c9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1330,12 +1330,16 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
const struct drm_crtc_helper_funcs *crtc_funcs;
u16 *red, *green, *blue, *transp;
struct drm_crtc *crtc;
+   u16 *r, *g, *b;
int i, j, rc = 0;
int start;
 
if (oops_in_progress)
return -EBUSY;
 
+   if (cmap->start + cmap->len < cmap->start)
+   return -EINVAL;
+
mutex_lock(&fb_helper->lock);
if (!drm_fb_helper_is_bound(fb_helper)) {
mutex_unlock(&fb_helper->lock);
@@ -1353,6 +1357,29 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
transp = cmap->transp;
start = cmap->start;
 
+   if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
+   if (!crtc->gamma_size) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   if (cmap->start + cmap->len > crtc->gamma_size) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   memcpy(r + cmap->start, cmap->red,
+  cmap->len * sizeof(u16));
+   memcpy(g + cmap->start, cmap->green,
+  cmap->len * sizeof(u16));
+   memcpy(b + cmap->start, cmap->blue,
+  cmap->len * sizeof(u16));
+   }
+
for (j = 0; j < cmap->len; j++) {
u16 hred, hgreen, hblue, htransp = 0x;
 
-- 
2.1.4


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] char: virtio_console: constify port_attribute_group

2017-10-26 Thread Arvind Yadav
File size before:
   textdata bss dec hex filename
  13775 656  88   1451938b7 drivers/char/virtio_console.o

File size After adding 'const':
   textdata bss dec hex filename
  13839 592  88   1451938b7 drivers/char/virtio_console.o

Signed-off-by: Arvind Yadav 
---
 drivers/char/virtio_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ad843eb..06bd635 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1308,7 +1308,7 @@ static ssize_t show_port_name(struct device *dev,
NULL
 };
 
-static struct attribute_group port_attribute_group = {
+static const struct attribute_group port_attribute_group = {
.name = NULL,   /* put in device directory */
.attrs = port_sysfs_entries,
 };
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 03/14] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set

2017-10-26 Thread Peter Rosin
This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
totally obsolete.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/drm_fb_helper.c | 151 +---
 1 file changed, 63 insertions(+), 88 deletions(-)

This is an alternative version rebased on top of Daniel's "fbdev helper
locking rework and deferred setup" series.

And as noted by Daniel, .gamma_set does an atomic commit. Thus, the locks
needs to be dropped and reacquired for each crtc. So, that is fixed here
too. Doing it like this with a couple of individual alternative patches
instead of sending a whole new series since the dependency on Daniel's
series makes life somewhat difficult...

Cheers,
peda

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 4aceb59..aa025f1 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1257,50 +1257,6 @@ void drm_fb_helper_set_suspend_unlocked(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
 
-static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, u16 regno, struct fb_info *info)
-{
-   struct drm_fb_helper *fb_helper = info->par;
-   struct drm_framebuffer *fb = fb_helper->fb;
-
-   if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
-   u32 *palette;
-   u32 value;
-   /* place color in psuedopalette */
-   if (regno > 16)
-   return -EINVAL;
-   palette = (u32 *)info->pseudo_palette;
-   red >>= (16 - info->var.red.length);
-   green >>= (16 - info->var.green.length);
-   blue >>= (16 - info->var.blue.length);
-   value = (red << info->var.red.offset) |
-   (green << info->var.green.offset) |
-   (blue << info->var.blue.offset);
-   if (info->var.transp.length > 0) {
-   u32 mask = (1 << info->var.transp.length) - 1;
-
-   mask <<= info->var.transp.offset;
-   value |= mask;
-   }
-   palette[regno] = value;
-   return 0;
-   }
-
-   /*
-* The driver really shouldn't advertise pseudo/directcolor
-* visuals if it can't deal with the palette.
-*/
-   if (WARN_ON(!fb_helper->funcs->gamma_set ||
-   !fb_helper->funcs->gamma_get))
-   return -EINVAL;
-
-   WARN_ON(fb->format->cpp[0] != 1);
-
-   fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-   return 0;
-}
-
 /**
  * drm_fb_helper_setcmap - implementation for &fb_ops.fb_setcmap
  * @cmap: cmap to set
@@ -1310,12 +1266,10 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
 {
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
-   const struct drm_crtc_helper_funcs *crtc_funcs;
-   u16 *red, *green, *blue, *transp;
+   struct drm_modeset_acquire_ctx ctx;
struct drm_crtc *crtc;
u16 *r, *g, *b;
-   int i, j, rc = 0;
-   int start;
+   int i, ret = 0;
 
if (oops_in_progress)
return -EBUSY;
@@ -1329,61 +1283,82 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
fb_info *info)
return -EBUSY;
}
 
-   drm_modeset_lock_all(dev);
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   crtc = fb_helper->crtc_info[i].mode_set.crtc;
-   crtc_funcs = crtc->helper_private;
+   drm_modeset_acquire_init(&ctx, 0);
 
-   red = cmap->red;
-   green = cmap->green;
-   blue = cmap->blue;
-   transp = cmap->transp;
-   start = cmap->start;
+   for (i = 0; i < fb_helper->crtc_count; i++) {
+   if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
+   u32 *palette;
+   int j;
 
-   if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
-   if (!crtc->gamma_size) {
-   rc = -EINVAL;
-   goto out;
+   if (cmap->start + cmap->len > 16) {
+   ret = -EINVAL;
+   break;
}
 
-   if (cmap->start + cmap->len > crtc->gamma_size) {
-   rc = -EINVAL;
-   goto out;
+   palette = (u32 *)info->pseudo_palette;
+   for (j = 0; j < cmap->len; ++j) {
+   u16 red = cmap->red[j];
+   u16 green = cmap->green[j];
+   u16 blue = cmap->blue[j];
+   u32 value;
+
+   red >>= 16 - info->var.red.length;
+   

Re: [PATCH v2 13/14] drm: stm: remove dead code and pointless local lut storage

2017-10-26 Thread Philippe CORNU


On 06/22/2017 08:06 AM, Peter Rosin wrote:
> The redundant fb helper .load_lut is no longer used, and can not
> work right without also providing the fb helpers .gamma_set and
> .gamma_get thus rendering the code in this driver suspect.
> 

Hi Peter,
STM32 chipsets supports 8-bit CLUT mode but this driver version does not 
support it "yet" (final patch has not been upstreamed because it was a 
too big fbdev patch for simply adding CLUT...).

Regarding your patch below, if it helps you to ease the drm framework 
update then I am agree to "acknowledge it" asap, else if you are not in 
a hurry, I would prefer a better and definitive patch handling 8-bit 
CLUT properly and I am ok to help or/and to do it : )

Extra questions:
- any plan to update modetest with the DRM_FORMAT_C8 support + gamma 
get/set?
- do you have a simple way to test clut with fbdev, last year we where 
using an old version of the SDL but I am still looking for a small piece 
of code to do it (else I will do it myself but C8 on fbdev is not really 
a priority ;-)

best regards,
Philippe

> Just remove the dead code.
> 
> Signed-off-by: Peter Rosin 
> ---
>   drivers/gpu/drm/stm/ltdc.c | 12 
>   drivers/gpu/drm/stm/ltdc.h |  1 -
>   2 files changed, 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 1b9483d..87829b9 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -375,17 +375,6 @@ static irqreturn_t ltdc_irq(int irq, void *arg)
>* DRM_CRTC
>*/
>   
> -static void ltdc_crtc_load_lut(struct drm_crtc *crtc)
> -{
> - struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> - unsigned int i, lay;
> -
> - for (lay = 0; lay < ldev->caps.nb_layers; lay++)
> - for (i = 0; i < 256; i++)
> - reg_write(ldev->regs, LTDC_L1CLUTWR + lay * LAY_OFS,
> -   ldev->clut[i]);
> -}
> -
>   static void ltdc_crtc_enable(struct drm_crtc *crtc)
>   {
>   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> @@ -523,7 +512,6 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
>   }
>   
>   static struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
> - .load_lut = ltdc_crtc_load_lut,
>   .enable = ltdc_crtc_enable,
>   .disable = ltdc_crtc_disable,
>   .mode_set_nofb = ltdc_crtc_mode_set_nofb,
> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
> index d7a9c73..620ca55 100644
> --- a/drivers/gpu/drm/stm/ltdc.h
> +++ b/drivers/gpu/drm/stm/ltdc.h
> @@ -27,7 +27,6 @@ struct ltdc_device {
>   struct drm_panel *panel;
>   struct mutex err_lock;  /* protecting error_status */
>   struct ltdc_caps caps;
> - u32 clut[256];  /* color look up table */
>   u32 error_status;
>   u32 irq_status;
>   };
> 
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v2 13/14] drm: stm: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
On 2017-06-22 13:49, Philippe CORNU wrote:
> On 06/22/2017 08:06 AM, Peter Rosin wrote:
>> The redundant fb helper .load_lut is no longer used, and can not
>> work right without also providing the fb helpers .gamma_set and
>> .gamma_get thus rendering the code in this driver suspect.
>>
> 
> Hi Peter,
> STM32 chipsets supports 8-bit CLUT mode but this driver version does not 
> support it "yet" (final patch has not been upstreamed because it was a 
> too big fbdev patch for simply adding CLUT...).
> 
> Regarding your patch below, if it helps you to ease the drm framework 
> update then I am agree to "acknowledge it" asap, else if you are not in 
> a hurry, I would prefer a better and definitive patch handling 8-bit 
> CLUT properly and I am ok to help or/and to do it : )

Hi!

The thing is, without my series you will have to provide four callbacks.
The crtc .gamma_set and the three redundant fb helpers .gamma_get,
.gamma_set and .load_lut that pretty much does exactly what the crtc
.gamma_set is doing. Well not .gamma_get, but...

With my series, you only have to provide the crtc .gamma_set, which you
have to provide anyway. and ...the core will handle everything that
.gamma_get was used for...

I.e., your work to provide CLUT support should start with drm support,
which means the crtc .gamma_set, and then move on to the fbdev
emulation. And I have just eliminated the second step for you, and
as suger on top, you no longer have to convince the core drm maintainers
that adding a lot of fbdev emulation code is needed.

So, I think you actually want to wait for my series to land before adding
CLUT support.

> Extra questions:
> - any plan to update modetest with the DRM_FORMAT_C8 support + gamma 
> get/set?

I don't know that code base at all, but from the glimpse I got when browsing
it, it seemed like it was pretty hardwired to non-palettized modes. I ended
up having no need for it, see below...

> - do you have a simple way to test clut with fbdev, last year we where 
> using an old version of the SDL but I am still looking for a small piece 
> of code to do it (else I will do it myself but C8 on fbdev is not really 
> a priority ;-)

I'm doing pretty much the same thing, I have an application that requires
an old SDL, and I'm using the programs/demos/demo.c program from the very
old libggi as a second test app. But that's just because libggi is what
I'm most familiar with, and it doesn't try to be "nice" and do things
automatically, instead you have to manually insert helpers providing
e.g. palette emulation if the application assumes a palettized mode and
only truecolor modes are available from the HW. SDL tends to add those
things for you, making it less easy to test thing, but I'm not an
"SDL-guy", so there may very well exist some knobs I don't know about.

Oh, you probably didn't see this:
http://marc.info/?l=linux-kernel&m=149786920731175&w=4

It sports modeset-pal.c that sets the C8 mode, and does a 5 second
palette animation, w/o using fbdev. I used it instead of digging
further into modetest.

Cheers,
peda
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: BUG: KASAN: use-after-free in free_old_xmit_skbs

2017-10-26 Thread Jean-Philippe Menil

On 06/23/2017 10:43 AM, Jason Wang wrote:



On 2017年06月23日 02:53, Michael S. Tsirkin wrote:

On Thu, Jun 22, 2017 at 08:15:58AM +0200, jean-philippe menil wrote:

2017-06-06 1:52 GMT+02:00 Michael S. Tsirkin :

 On Mon, Jun 05, 2017 at 05:08:25AM +0300, Michael S. Tsirkin wrote:
 > On Mon, Jun 05, 2017 at 12:48:53AM +0200, Jean-Philippe Menil 
wrote:

 > > Hi,
 > >
 > > while playing with xdp and ebpf, i'm hitting the following:
 > >
 > > [  309.993136]
 > > 
==

 > > [  309.994735] BUG: KASAN: use-after-free in
 > > free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
 > > [  309.998396] Read of size 8 at addr 88006aa64220 by 
task sshd/323

 > > [  310.000650]
 > > [  310.002305] CPU: 1 PID: 323 Comm: sshd Not tainted 
4.12.0-rc3+ #2
 > > [  310.004018] Hardware name: QEMU Standard PC (i440FX + 
PIIX, 1996),

 BIOS
 > > 1.10.2-20170228_101828-anatol 04/01/2014

...


 >
 > Since commit 680557cf79f82623e2c4fd42733077d60a843513
 > virtio_net: rework mergeable buffer handling
 >
 > we no longer must do the resets, we now have enough space
 > to store a bit saying whether a buffer is xdp one or not.
 >
 > And that's probably a cleaner way to fix these issues than
 > try to find and fix the race condition.
 >
 > John?
 >
 > --
 > MST


 I think I see the source of the race. virtio net calls
 netif_device_detach and assumes no packets will be sent after
 this point. However, all it does is stop all queues so
 no new packets will be transmitted.

 Try locking with HARD_TX_LOCK?

 --
 MST


Hi Michael,

from what i see, the race appear when we hit virtnet_reset in 
virtnet_xdp_set.

virtnet_reset
   _remove_vq_common
 virtnet_del_vqs
   virtnet_free_queues
 kfree(vi->sq)
when the xdp program (with two instances of the program to trigger it 
faster)

is added or removed.

It's easily repeatable, with 2 cpus and 4 queues on the qemu command 
line,

running the xdp_ttl tool from Jesper.

For now, i'm able to continue my qualification, testing if xdp_qp is 
not null,

but do not seem to be a sustainable trick.
if (xdp_qp && vi->xdp_queues_pairs != xdp_qp)

Maybe it will be more clear to you with theses informations.

Best regards.

Jean-Philippe


I'm pretty clear about the issue here, I was trying to figure out a fix.
Jason, any thoughts?




Hi Jean:

Does the following fix this issue? (I can't reproduce it locally through 
xdp_ttl)


Thanks

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1f8c15c..3e65c3f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1801,7 +1801,9 @@ static void virtnet_freeze_down(struct 
virtio_device *vdev)

 /* Make sure no work handler is accessing the device */
 flush_work(&vi->config_work);

+   netif_tx_lock_bh(vi->dev);
 netif_device_detach(vi->dev);
+   netif_tx_unlock_bh(vi->dev);
 cancel_delayed_work_sync(&vi->refill);



Hi Jason,

unfortunately, same crash on same place, the lock did not help.

[  574.522886] 
==
[  574.527393] BUG: KASAN: use-after-free in 
free_old_xmit_skbs.isra.28+0x29b/0x2b0 [virtio_net]

[  574.531934] Read of size 8 at addr 88005d220020 by task iperf/2252
[  574.536296]
[  574.539729] CPU: 1 PID: 2252 Comm: iperf Not tainted 4.12.0-rc5+ #5
[  574.543916] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
BIOS 1.10.2-20170228_101828-anatol 04/01/2014

[  574.552046] Call Trace:
[  574.555648]  dump_stack+0xb3/0x10b
[  574.559471]  ? free_old_xmit_skbs.isra.28+0x29b/0x2b0 [virtio_net]
[  574.563578]  print_address_description+0x6a/0x280
[  574.567253]  ? free_old_xmit_skbs.isra.28+0x29b/0x2b0 [virtio_net]
[  574.571223]  kasan_report+0x22b/0x340
[  574.574698]  __asan_report_load8_noabort+0x14/0x20
[  574.578490]  free_old_xmit_skbs.isra.28+0x29b/0x2b0 [virtio_net]
[  574.582586]  ? dev_queue_xmit_nit+0x5fb/0x850
[  574.586348]  ? virtnet_del_vqs+0xf0/0xf0 [virtio_net]
[  574.590153]  ? __skb_clone+0x24a/0x7d0
[  574.593835]  start_xmit+0x15a/0x1620 [virtio_net]
[  574.597939]  dev_hard_start_xmit+0x17f/0x7e0
[  574.601832]  sch_direct_xmit+0x2a8/0x5d0
[  574.605665]  ? dev_deactivate_queue.constprop.31+0x150/0x150
[  574.609827]  __dev_queue_xmit+0x1124/0x18b0
[  574.613595]  ? selinux_ip_postroute+0x4b2/0xa90
[  574.617928]  ? netdev_pick_tx+0x2d0/0x2d0
[  574.621852]  ? mark_held_locks+0xc8/0x120
[  574.625673]  ? ip_finish_output+0x626/0x9b0
[  574.631679]  ? ip_finish_output2+0xb44/0x1160
[  574.637642]  dev_queue_xmit+0x17/0x20
[  574.641693]  ip_finish_output2+0xcd1/0x1160
[  574.645621]  ? do_add_counters+0x480/0x480
[  574.649554]  ? do_add_counters+0x403/0x480
[  574.653209]  ? ip_copy_metadata+0x630/0x630
[  574.657066]  ip_finish_output+0x626/0x9b0
[  574.

[PATCH] x86: Remove unnecessary return from void function

2017-10-26 Thread Anton Vasilyev
The patch removes unnecessary return from void function.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev 
---
 arch/x86/include/asm/paravirt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 55fa56f..a3dcf89 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -118,7 +118,7 @@ static inline u64 paravirt_read_msr(unsigned msr)
 static inline void paravirt_write_msr(unsigned msr,
  unsigned low, unsigned high)
 {
-   return PVOP_VCALL3(pv_cpu_ops.write_msr, msr, low, high);
+   PVOP_VCALL3(pv_cpu_ops.write_msr, msr, low, high);
 }
 
 static inline u64 paravirt_read_msr_safe(unsigned msr, int *err)
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: BUG: KASAN: use-after-free in free_old_xmit_skbs

2017-10-26 Thread Jean-Philippe Menil

On 06/26/2017 04:50 AM, Jason Wang wrote:



On 2017年06月24日 06:32, Cong Wang wrote:

On Fri, Jun 23, 2017 at 1:43 AM, Jason Wang  wrote:


On 2017年06月23日 02:53, Michael S. Tsirkin wrote:

On Thu, Jun 22, 2017 at 08:15:58AM +0200, jean-philippe menil wrote:

Hi Michael,

from what i see, the race appear when we hit virtnet_reset in
virtnet_xdp_set.
virtnet_reset
_remove_vq_common
  virtnet_del_vqs
virtnet_free_queues
  kfree(vi->sq)
when the xdp program (with two instances of the program to trigger it
faster)
is added or removed.

It's easily repeatable, with 2 cpus and 4 queues on the qemu command
line,
running the xdp_ttl tool from Jesper.

For now, i'm able to continue my qualification, testing if xdp_qp 
is not

null,
but do not seem to be a sustainable trick.
if (xdp_qp && vi->xdp_queues_pairs != xdp_qp)

Maybe it will be more clear to you with theses informations.

Best regards.

Jean-Philippe


I'm pretty clear about the issue here, I was trying to figure out a 
fix.

Jason, any thoughts?



Hi Jean:

Does the following fix this issue? (I can't reproduce it locally through
xdp_ttl)

It is tricky here.

 From my understanding of the code base, the tx_lock is not sufficient
here, because in virtnet_del_vqs() all vqs are deleted and one vp
maps to one txq.

I am afraid you have to add a spinlock somewhere to serialized
free_old_xmit_skbs() vs. vring_del_virtqueue(). As you can see
they are in different layers, so it is hard to figure out where to add
it...

Also, make sure we don't sleep inside the spinlock, I see a
synchronize_net().


Looks like I miss something. I thought free_old_xmit_skbs() were 
serialized in this case since we disable all tx queues after 
netif_tx_unlock_bh()?


Jean:

I thought this could be easily reproduced by e.g produce some traffic 
and in the same time try to attach an xdp program. But looks not. How do 
you trigger this? What's your qemu command line for this?


Thanks


Hi Jason,

this is how i trigger the bug:
- on the guest, tcpdump on on the interface
- on the guest, run iperf against the host
- on the guest, cat /sys/kernel/debug/tracing/trace_pipe
- on the guest, run one or two instances of xdp_ttl compiled with DEBUG 
uncommented, that i start stop, until i trigger the bug.


qemu command line is as follow:

qemu-system-x86_64 -name ubuntu --enable-kvm -machine pc,accel=kvm -smp 
2 -drive file=/dev/LocalDisk/ubuntu,if=virtio,format=raw -m 2048 -rtc 
base=localtime,clock=host -usbdevice tablet --balloon virtio -netdev 
tap,id=ubuntu-0,ifname=ubuntu-0,script=/home/jenfi/WORK/jp/qemu/if-up,downscript=/home/jenfi/WORK/jp/qemu/if-down,vhost=on,queues=4 
-device 
virtio-net-pci,netdev=ubuntu-0,mac=de:ad:be:ef:01:03,mq=on,guest_tso4=off,guest_tso6=off,guest_ecn=off,guest_ufo=off,vectors=2 
-vnc 127.0.0.1:3 -nographic -serial 
file:/home/jenfi/WORK/jp/qemu/ubuntu.out -monitor 
unix:/home/jenfi/WORK/jp/qemu/ubuntu.sock,server,nowait


Notice, the smp 2, queues to 4 and vectors to 2.
Seem that if fogot to mention that in the beginning of this thread, 
sorry for that.


Best regards.

Jean-Philippe
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH v2 00/14] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
On 2017-06-26 11:35, Daniel Vetter wrote:
> On Thu, Jun 22, 2017 at 08:06:23AM +0200, Peter Rosin wrote:
>> Hi!
>>
>> While trying to get CLUT support for the atmel_hlcdc driver, and
>> specifically for the emulated fbdev interface, I received some
>> push-back that my feeble in-driver attempts should be solved
>> by the core. This is my attempt to do it right.
>>
>> I have obviously not tested all of this with more than a compile,
>> but patches 1 and 3 are enough to make the atmel-hlcdc driver
>> do what I need (when patched to support CLUT modes). The rest is
>> just lots of removals and cleanup made possible by the improved
>> core.
>>
>> Please test, I would not be surprised if I have fouled up some
>> bit-manipulation somewhere in this mostly mechanical change...
>>
>> Changes since v1:
>>
>> - Rebased to next-20170621
>> - Split 1/11 into a preparatory patch, a cleanup patch and then
>>   the meat in 3/14.
>> - Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
>> - Removed the empty .gamma_get/.gamma_set fb helpers from the
>>   armada driver that I had somehow managed to ignore but which
>>   0day found real quick.
>> - Be less judgemental on drivers only providing .gamma_get and
>>   .gamma_set, but no .load_lut. That's actually a valid thing
>>   to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
>> - Add a comment about colliding bitfields in the nouveau driver.
>> - Remove gamma_set/gamma_get declarations from the radeon driver
>>   (the definitions were removed in v1).
> 
> Ok some nits/questions on the first three, but in principle looks all ok I
> think. The driver patches also look good (but I didn't yet carefully
> review all the conversion). What we might want to do is entirely remove
> driver's reliance on ->gamma_store (mostly amounts to in-lining the
> load_lut functions) and only update ->gamma_store after gamma_set returned
> successfully. But that's a bit more work.
> 
> Save/restoring it instead might be simpler to fix that bug, but since it's
> pre-existing also ok as follow-up.

I'm traveling and cannot make progress this week. The merge window is
also real close so this series will therefore probably miss it unless
something unexpected happens...

I'll get back to this for the next cycle, just a heads up.

Cheers,
peda
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] virtio_scsi: let host do exception handling

2017-10-26 Thread Martin K. Petersen

Paolo,

> virtio_scsi tries to do exception handling after the default 30
> seconds timeout expires.  However, it's better to let the host control
> the timeout, otherwise with a heavy I/O load it is likely that an
> abort will also timeout.  This leads to fatal errors like filesystems
> going offline.
>
> Disable the 'sd' timeout and allow the host to do exception handling,
> following the precedent of the storvsc driver.

Applied to 4.13/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [Qemu-devel] BUG: KASAN: use-after-free in free_old_xmit_skbs

2017-10-26 Thread Jean-Philippe Menil

On 06/27/2017 04:13 AM, Jason Wang wrote:



On 2017年06月26日 15:35, Jean-Philippe Menil wrote:

On 06/26/2017 04:50 AM, Jason Wang wrote:



On 2017年06月24日 06:32, Cong Wang wrote:
On Fri, Jun 23, 2017 at 1:43 AM, Jason Wang  
wrote:


On 2017年06月23日 02:53, Michael S. Tsirkin wrote:

On Thu, Jun 22, 2017 at 08:15:58AM +0200, jean-philippe menil wrote:

Hi Michael,

from what i see, the race appear when we hit virtnet_reset in
virtnet_xdp_set.
virtnet_reset
_remove_vq_common
  virtnet_del_vqs
virtnet_free_queues
  kfree(vi->sq)
when the xdp program (with two instances of the program to 
trigger it

faster)
is added or removed.

It's easily repeatable, with 2 cpus and 4 queues on the qemu command
line,
running the xdp_ttl tool from Jesper.

For now, i'm able to continue my qualification, testing if xdp_qp 
is not

null,
but do not seem to be a sustainable trick.
if (xdp_qp && vi->xdp_queues_pairs != xdp_qp)

Maybe it will be more clear to you with theses informations.

Best regards.

Jean-Philippe


I'm pretty clear about the issue here, I was trying to figure out 
a fix.

Jason, any thoughts?



Hi Jean:

Does the following fix this issue? (I can't reproduce it locally 
through

xdp_ttl)

It is tricky here.

 From my understanding of the code base, the tx_lock is not sufficient
here, because in virtnet_del_vqs() all vqs are deleted and one vp
maps to one txq.

I am afraid you have to add a spinlock somewhere to serialized
free_old_xmit_skbs() vs. vring_del_virtqueue(). As you can see
they are in different layers, so it is hard to figure out where to add
it...

Also, make sure we don't sleep inside the spinlock, I see a
synchronize_net().


Looks like I miss something. I thought free_old_xmit_skbs() were 
serialized in this case since we disable all tx queues after 
netif_tx_unlock_bh()?


Jean:

I thought this could be easily reproduced by e.g produce some traffic 
and in the same time try to attach an xdp program. But looks not. How 
do you trigger this? What's your qemu command line for this?


Thanks


Hi Jason,

this is how i trigger the bug:
- on the guest, tcpdump on on the interface
- on the guest, run iperf against the host
- on the guest, cat /sys/kernel/debug/tracing/trace_pipe
- on the guest, run one or two instances of xdp_ttl compiled with 
DEBUG uncommented, that i start stop, until i trigger the bug.


qemu command line is as follow:

qemu-system-x86_64 -name ubuntu --enable-kvm -machine pc,accel=kvm 
-smp 2 -drive file=/dev/LocalDisk/ubuntu,if=virtio,format=raw -m 2048 
-rtc base=localtime,clock=host -usbdevice tablet --balloon virtio 
-netdev 
tap,id=ubuntu-0,ifname=ubuntu-0,script=/home/jenfi/WORK/jp/qemu/if-up,downscript=/home/jenfi/WORK/jp/qemu/if-down,vhost=on,queues=4 
-device 
virtio-net-pci,netdev=ubuntu-0,mac=de:ad:be:ef:01:03,mq=on,guest_tso4=off,guest_tso6=off,guest_ecn=off,guest_ufo=off,vectors=2 
-vnc 127.0.0.1:3 -nographic -serial 
file:/home/jenfi/WORK/jp/qemu/ubuntu.out -monitor 
unix:/home/jenfi/WORK/jp/qemu/ubuntu.sock,server,nowait


Notice, the smp 2, queues to 4 and vectors to 2.
Seem that if fogot to mention that in the beginning of this thread, 
sorry for that.


Best regards.

Jean-Philippe



Thanks Jean, I manage to reproduce the issue.

I thought netif_tx_unlock_bh() will do tx lock but looks not, that's why 
previous patch doesn't work.


Could you please this this patch? (At least it can't trigger the warning 
after more than 20 times of xdp start/stop).


diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1f8c15c..a18f859 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1802,6 +1802,7 @@ static void virtnet_freeze_down(struct 
virtio_device *vdev)

 flush_work(&vi->config_work);

 netif_device_detach(vi->dev);
+   netif_tx_disable(vi->dev);
 cancel_delayed_work_sync(&vi->refill);

 if (netif_running(vi->dev)) {




Hi Jason,

Seem to do the trick !
with your patch, i'm unable to repeat the problem anymore (running more 
than 2h without any issue).


Best regards.

Jean-Philippe
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH 1/1] Update my email address

2017-10-26 Thread Cornelia Huck
Signed-off-by: Cornelia Huck 
---
 MAINTAINERS | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 767e9d202adf..84155d593bba 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7285,7 +7285,7 @@ F:arch/powerpc/kvm/
 
 KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
 M: Christian Borntraeger 
-M: Cornelia Huck 
+M: Cornelia Huck 
 L: linux-s...@vger.kernel.org
 W: http://www.ibm.com/developerworks/linux/linux390/
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git
@@ -11060,7 +11060,7 @@ S:  Supported
 F: drivers/iommu/s390-iommu.c
 
 S390 VFIO-CCW DRIVER
-M: Cornelia Huck 
+M: Cornelia Huck 
 M: Dong Jia Shi 
 L: linux-s...@vger.kernel.org
 L: k...@vger.kernel.org
@@ -13569,7 +13569,7 @@ F:  include/uapi/linux/virtio_*.h
 F: drivers/crypto/virtio/
 
 VIRTIO DRIVERS FOR S390
-M: Cornelia Huck 
+M: Cornelia Huck 
 M: Halil Pasic 
 L: linux-s...@vger.kernel.org
 L: virtualization@lists.linux-foundation.org
-- 
2.13.0

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 0/1] Change email address

2017-10-26 Thread Cornelia Huck
New employer, new address. Make sure people use the right one.

Christian, Martin, it's probably quickest if one of you takes this.

Cornelia Huck (1):
  Update my email address

 MAINTAINERS | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.13.0

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm: qxl: constify ttm_place structures.

2017-10-26 Thread Arvind Yadav
ttm_place are not supposed to change at runtime. All functions
working with ttm_place provided by  work
with const ttm_place. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
   3485 184 2643933 f5d drivers/gpu/drm/qxl/qxl_ttm.o

File size After adding 'const':
   textdata bss dec hex filename
   3501 152 2643917 f4d drivers/gpu/drm/qxl/qxl_ttm.o

Signed-off-by: Arvind Yadav 
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 0fdedee..900fb8a 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -187,7 +187,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
struct ttm_placement *placement)
 {
struct qxl_bo *qbo;
-   static struct ttm_place placements = {
+   static const struct ttm_place placements = {
.fpfn = 0,
.lpfn = 0,
.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 1/1] Update my email address

2017-10-26 Thread Thomas Huth
On 04.07.2017 11:30, Cornelia Huck wrote:
> Signed-off-by: Cornelia Huck 
> ---
>  MAINTAINERS | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 767e9d202adf..84155d593bba 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -7285,7 +7285,7 @@ F:  arch/powerpc/kvm/
>  
>  KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
>  M:   Christian Borntraeger 
> -M:   Cornelia Huck 
> +M:   Cornelia Huck 
>  L:   linux-s...@vger.kernel.org
>  W:   http://www.ibm.com/developerworks/linux/linux390/
>  T:   git git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git
> @@ -11060,7 +11060,7 @@ S:Supported
>  F:   drivers/iommu/s390-iommu.c
>  
>  S390 VFIO-CCW DRIVER
> -M:   Cornelia Huck 
> +M:   Cornelia Huck 
>  M:   Dong Jia Shi 
>  L:   linux-s...@vger.kernel.org
>  L:   k...@vger.kernel.org
> @@ -13569,7 +13569,7 @@ F:include/uapi/linux/virtio_*.h
>  F:   drivers/crypto/virtio/
>  
>  VIRTIO DRIVERS FOR S390
> -M:   Cornelia Huck 
> +M:   Cornelia Huck 
>  M:   Halil Pasic 
>  L:   linux-s...@vger.kernel.org
>  L:   virtualization@lists.linux-foundation.org
> 

Reviewed-by: Thomas Huth 




signature.asc
Description: OpenPGP digital signature
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH] drm: ttm: virtio-gpu: dma-buf: Constify ttm_place structures.

2017-10-26 Thread Arvind Yadav
ttm_place are not supposed to change at runtime. All functions
working with ttm_place provided by  work
with const ttm_place. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
   2315 184   02499 9c3 drivers/gpu/drm/virtio/virtgpu_ttm.o

File size After adding 'const':
   textdata bss dec hex filename
   2347 152   02499 9c3 drivers/gpu/drm/virtio/virtgpu_ttm.o

Signed-off-by: Arvind Yadav 
---
 drivers/gpu/drm/virtio/virtgpu_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c 
b/drivers/gpu/drm/virtio/virtgpu_ttm.c
index 4e8e27d..012d5bc 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
@@ -234,7 +234,7 @@ static int virtio_gpu_init_mem_type(struct ttm_bo_device 
*bdev, uint32_t type,
 static void virtio_gpu_evict_flags(struct ttm_buffer_object *bo,
struct ttm_placement *placement)
 {
-   static struct ttm_place placements = {
+   static const struct ttm_place placements = {
.fpfn  = 0,
.lpfn  = 0,
.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM,
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v3 00/16] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
Hi!

While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.

I have obviously not tested all of this with more than a compile,
but patches 1 through 5 are enough to make the atmel-hlcdc driver
do what I need. The rest is just lots of removals and cleanup made
possible by the improved core.

Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere, or if I have misunderstood something
about atomics...

Changes since v2:
- Added patch 1/16 which factors out pseudo-palette handling.
- Removed the if (cmap->start + cmap->len < cmap->start)
  sanity check on the assumption that the fbdev core handles it.
- Added patch 4/16 which factors out atomic state and commit
  handling from drm_atomic_helper_legacy_gamma_set to
  drm_mode_gamma_set_ioctl.
- Do one atomic commit for all affected crtc.
- Removed a now obsolete note in include/drm/drm_crtc.h (ammended
  the last patch).
- Cc list is getting long, so I have redused the list for the
  individual patches. If you would like to get the full series
  (or nothing at all) for the next round (if that is needed) just
  say so.

Changes since v1:

- Rebased to next-20170621
- Split 1/11 into a preparatory patch, a cleanup patch and then
  the meat in 3/14.
- Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
- Removed the empty .gamma_get/.gamma_set fb helpers from the
  armada driver that I had somehow managed to ignore but which
  0day found real quick.
- Be less judgemental on drivers only providing .gamma_get and
  .gamma_set, but no .load_lut. That's actually a valid thing
  to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
- Add a comment about colliding bitfields in the nouveau driver.
- Remove gamma_set/gamma_get declarations from the radeon driver
  (the definitions were removed in v1).

Cheers,
peda

Peter Rosin (16):
  drm/fb-helper: factor out pseudo-palette
  drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap
  drm/fb-helper: remove drm_fb_helper_save_lut_atomic
  drm/color-mgmt: move atomic state/commit out from .gamma_set
  drm/fb-helper: do a generic fb_setcmap helper in terms of crtc
.gamma_set
  drm: amd: remove dead code and pointless local lut storage
  drm: armada: remove dead empty functions
  drm: ast: remove dead code and pointless local lut storage
  drm: cirrus: remove dead code and pointless local lut storage
  drm: gma500: remove dead code and pointless local lut storage
  drm: i915: remove dead code and pointless local lut storage
  drm: mgag200: remove dead code and pointless local lut storage
  drm: nouveau: remove dead code and pointless local lut storage
  drm: radeon: remove dead code and pointless local lut storage
  drm: stm: remove dead code and pointless local lut storage
  drm: remove unused and redundant callbacks

 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  24 
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|   1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  29 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  29 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  29 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  29 ++---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c|  25 +---
 drivers/gpu/drm/armada/armada_crtc.c|  10 --
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_fbdev.c   |   2 -
 drivers/gpu/drm/ast/ast_drv.h   |   1 -
 drivers/gpu/drm/ast/ast_fb.c|  20 ---
 drivers/gpu/drm/ast/ast_mode.c  |  28 +---
 drivers/gpu/drm/cirrus/cirrus_drv.h |   8 --
 drivers/gpu/drm/cirrus/cirrus_fbdev.c   |   2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c|  73 +++
 drivers/gpu/drm/drm_atomic_helper.c |  37 ++
 drivers/gpu/drm/drm_color_mgmt.c|  27 +++-
 drivers/gpu/drm/drm_fb_helper.c | 195 +---
 drivers/gpu/drm/gma500/framebuffer.c|  22 
 drivers/gpu/drm/gma500/gma_display.c|  34 ++---
 drivers/gpu/drm/gma500/gma_display.h|   2 +-
 drivers/gpu/drm/gma500/psb_intel_display.c  |   7 +-
 drivers/gpu/drm/gma500/psb_intel_drv.h  |   1 -
 drivers/gpu/drm/i915/intel_drv.h|   1 -
 drivers/gpu/drm/i915/intel_fbdev.c  |  31 -
 drivers/gpu/drm/mgag200/mgag200_drv.h   |   5 -
 drivers/gpu/drm/mgag200/mgag200_fb.c|   2 -
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  64 +++--
 drivers/gpu/drm/nouveau/dispnv04/crtc.c |  28 ++--
 drivers/gpu/drm/nouveau/nouveau_crtc.h  |   3 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |  22 
 drivers/gpu/drm/nouveau/nv50_display.c  |  42 ++
 drivers/gpu/drm/radeon/atombios_crtc.c  |   1 -
 drivers/gpu/drm/radeon/radeon_connectors.c  |   7 +-
 drivers/gpu/drm/radeon/radeon_display.c |  7

[PATCH v3 04/16] drm/color-mgmt: move atomic state/commit out from .gamma_set

2017-10-26 Thread Peter Rosin
Handle the atomics directly in the ioctl instead, in preparation for the
fb_setcmap helper needing to commit the gamma map for several crtc in one
commit.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  2 +-
 drivers/gpu/drm/ast/ast_mode.c   |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c |  2 +-
 drivers/gpu/drm/drm_atomic_helper.c  | 37 +++-
 drivers/gpu/drm/drm_color_mgmt.c | 27 ++-
 drivers/gpu/drm/gma500/gma_display.c |  2 +-
 drivers/gpu/drm/gma500/gma_display.h |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c  |  2 +-
 drivers/gpu/drm/nouveau/nv50_display.c   |  2 +-
 drivers/gpu/drm/radeon/radeon_display.c  |  2 +-
 drivers/gpu/drm/vc4/vc4_crtc.c   |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  2 +-
 include/drm/drm_atomic_helper.h  |  2 +-
 include/drm/drm_crtc.h   |  3 +--
 20 files changed, 52 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9f78c03..31c977b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2622,7 +2622,7 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 
 static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
u16 *blue, uint32_t size,
-   struct drm_modeset_acquire_ctx *ctx)
+   struct drm_crtc_state *state)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 4bcf01d..cf42640 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2642,7 +2642,7 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 
 static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
u16 *blue, uint32_t size,
-   struct drm_modeset_acquire_ctx *ctx)
+   struct drm_crtc_state *state)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index fd134a4..045014d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2494,7 +2494,7 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
 
 static int dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
   u16 *blue, uint32_t size,
-  struct drm_modeset_acquire_ctx *ctx)
+  struct drm_crtc_state *state)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index a9e8695..ee9389f 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2473,7 +2473,7 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 
 static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
   u16 *blue, uint32_t size,
-  struct drm_modeset_acquire_ctx *ctx)
+  struct drm_crtc_state *state)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 90bb083..f194dfc 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -166,7 +166,7 @@ static void dce_virtual_bandwidth_update(struct 
amdgpu_device *adev)
 
 static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
  u16 *green, u16 *blue, uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
+ struct drm_crtc_state *state)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index aaef0a6..6f0335b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -646,7 +646,7 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
  u16 *blue, uint32_t size,
-

Re: [Intel-gfx] [PATCH v3 00/16] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
On 2017-07-05 08:08, Daniel Vetter wrote:
> On Tue, Jul 04, 2017 at 12:36:56PM +0200, Peter Rosin wrote:
>> Hi!
>>
>> While trying to get CLUT support for the atmel_hlcdc driver, and
>> specifically for the emulated fbdev interface, I received some
>> push-back that my feeble in-driver attempts should be solved
>> by the core. This is my attempt to do it right.
>>
>> I have obviously not tested all of this with more than a compile,
>> but patches 1 through 5 are enough to make the atmel-hlcdc driver
>> do what I need. The rest is just lots of removals and cleanup made
>> possible by the improved core.
>>
>> Please test, I would not be surprised if I have fouled up some
>> bit-manipulation somewhere, or if I have misunderstood something
>> about atomics...
>>
>> Changes since v2:
>> - Added patch 1/16 which factors out pseudo-palette handling.
>> - Removed the if (cmap->start + cmap->len < cmap->start)
>>   sanity check on the assumption that the fbdev core handles it.
>> - Added patch 4/16 which factors out atomic state and commit
>>   handling from drm_atomic_helper_legacy_gamma_set to
>>   drm_mode_gamma_set_ioctl.
>> - Do one atomic commit for all affected crtc.
>> - Removed a now obsolete note in include/drm/drm_crtc.h (ammended
>>   the last patch).
>> - Cc list is getting long, so I have redused the list for the
>>   individual patches. If you would like to get the full series
>>   (or nothing at all) for the next round (if that is needed) just
>>   say so.
> 
> Is this still on top of my locking rework? I tried to apply patches 1-3,
> but there's minor conflicts ...
> -Daniel

v3 has the same base as v2. I collected your locking rework sometime
after june 21, you have perhaps changed things since? I saw an update
of that dpms patch you Cc me, but figured there were no significant
changes that I needed to handle since I didn't get the full set
this time either. A bad assumption it seems...

Anyway, the base I have for v3 (and v2) is linux next-20170621 plus
the following locking rework commits (in reverse order):

Author: Thierry Reding 
Date: Wed Jun 21 20:28:15 2017 +0200
Subject: drm/hisilicon: Remove custom FB helper deferred setup

Author: Thierry Reding 
Date: Wed Jun 21 20:28:14 2017 +0200
Subject: drm/exynos: Remove custom FB helper deferred setup

Author: Thierry Reding 
Date: Wed Jun 21 20:28:13 2017 +0200
Subject: drm/fb-helper: Support deferred setup

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:12 2017 +0200
Subject: drm/fb-helper: Split dpms handling into legacy and atomic paths

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:11 2017 +0200
Subject: drm/fb-helper: Stop using mode_config.mutex for internals

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:10 2017 +0200
Subject: drm/fb-helper: Push locking into restore_fbdev_mode_atomic|legacy

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:09 2017 +0200
Subject: drm/fb-helper: Push locking into pan_display_atomic|legacy

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:08 2017 +0200
Subject: drm/fb-helper: Drop locking from the vsync wait ioctl code

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:07 2017 +0200
Subject: drm/fb-helper: Push locking in fb_is_bound

Author: Thierry Reding 
Date: Wed Jun 21 20:28:06 2017 +0200
Subject: drm/fb-helper: Add top-level lock

Author: Daniel Vetter 
Date: Wed Jun 21 20:28:05 2017 +0200
Subject: drm/i915: Drop FBDEV #ifdev in mst code

Author: Thierry Reding 
Date: Wed Jun 21 20:28:04 2017 +0200
Subject: drm/fb-helper: Push down modeset lock into FB helpers

Cheers,
peda
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v3 09/16] drm: cirrus: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  8 
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 71 ---
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352..be2d7e48 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
struct drm_crtc base;
-   u8  lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
boolenabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 
-   /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
-
-
/* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
  struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..1fedab0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-   .gamma_set = cirrus_crtc_fb_gamma_set,
-   .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
 };
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 2b4c2c3..92ff7de 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   struct cirrus_device *cdev = dev->dev_private;
-   int i;
-
-   if (!crtc->enabled)
-   return;
-
-   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-   /* VGA registers */
-   WREG8(PALETTE_INDEX, i);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-   }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, 
u16 *red, u16 *green,
 u16 *blue, uint32_t size,
 struct drm_crtc_state *state)
 {
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct cirrus_device *cdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
-   for (i = 0; i < size; i++) {
-   cirrus_crtc->lut_r[i] = red[i];
-   cirrus_crtc->lut_g[i] = green[i];
-   cirrus_crtc->lut_b[i] = blue[i];
+   if (!crtc->enabled)
+   return 0;
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+   /* VGA registers */
+   WREG8(PALETTE_INDEX, i);
+   WREG8(PALETTE_DATA, *r++ >> 8);
+   WREG8(PALETTE_DATA, *g++ >> 8);
+   WREG8(PALETTE_DATA, *b++ >> 8);
}
-   cirrus_crtc_load_lut(crtc);
 
return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
-   .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
-   int i;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cdev->mode

[PATCH v4 00/14] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
Hi!

While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.

I have obviously not tested all of this with more than a compile,
but patches 1 and 3 are enough to make the atmel-hlcdc driver
do what I need. The rest is just lots of removals and cleanup made
possible by the other improvements.

Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere, or if I have misunderstood something
about atomics...

Changes since v3:
- Rebased onto drm-misc-next and dropped patches 1-3 from v3, since
  they are already merged.
- Dropped the v3 patch 4/16 ("drm/color-mgmt: move atomic state/commit
  out from .gamma_set") since the atomic setcmap no longer uses
  the crtc .gamma_set callback.
- Added patch 1/14 which exports drm_atomic_replace_property_blob...
- ...and patch 2/14 which uses this new export to simplify
  drm_atomic_helper_legacy_gamma_set.
- Big changes to patch 3/14 (was 5/16 in v3). It had various locking
  issues and the atomic setcmap is rather different.

Changes since v2:
- Added patch 1/16 which factors out pseudo-palette handling.
- Removed the if (cmap->start + cmap->len < cmap->start)
  sanity check on the assumption that the fbdev core handles it.
- Added patch 4/16 which factors out atomic state and commit
  handling from drm_atomic_helper_legacy_gamma_set to
  drm_mode_gamma_set_ioctl.
- Do one atomic commit for all affected crtc.
- Removed a now obsolete note in include/drm/drm_crtc.h (ammended
  the last patch).
- Cc list is getting long, so I have redused the list for the
  individual patches. If you would like to get the full series
  (or nothing at all) for the next round (if that is needed) just
  say so.

Changes since v1:

- Rebased to next-20170621
- Split 1/11 into a preparatory patch, a cleanup patch and then
  the meat in 3/14.
- Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
- Removed the empty .gamma_get/.gamma_set fb helpers from the
  armada driver that I had somehow managed to ignore but which
  0day found real quick.
- Be less judgemental on drivers only providing .gamma_get and
  .gamma_set, but no .load_lut. That's actually a valid thing
  to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
- Add a comment about colliding bitfields in the nouveau driver.
- Remove gamma_set/gamma_get declarations from the radeon driver
  (the definitions were removed in v1).

Cheers,
peda

Peter Rosin (14):
  drm/atomic: export drm_atomic_replace_property_blob
  drm/atomic-helper: update lut props directly in ..._legacy_gamma_set
  drm/fb-helper: separate the fb_setcmap helper into atomic and legacy
paths
  drm: amd: remove dead code and pointless local lut storage
  drm: armada: remove dead empty functions
  drm: ast: remove dead code and pointless local lut storage
  drm: cirrus: remove dead code and pointless local lut storage
  drm: gma500: remove dead code and pointless local lut storage
  drm: i915: remove dead code and pointless local lut storage
  drm: mgag200: remove dead code and pointless local lut storage
  drm: nouveau: remove dead code and pointless local lut storage
  drm: radeon: remove dead code and pointless local lut storage
  drm: stm: remove dead code and pointless local lut storage
  drm: remove unused and redundant callbacks

 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  24 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|   1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c|  23 ---
 drivers/gpu/drm/armada/armada_crtc.c|  10 --
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_fbdev.c   |   2 -
 drivers/gpu/drm/ast/ast_drv.h   |   1 -
 drivers/gpu/drm/ast/ast_fb.c|  20 ---
 drivers/gpu/drm/ast/ast_mode.c  |  26 +---
 drivers/gpu/drm/cirrus/cirrus_drv.h |   8 -
 drivers/gpu/drm/cirrus/cirrus_fbdev.c   |   2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c|  71 ++---
 drivers/gpu/drm/drm_atomic.c|  17 +-
 drivers/gpu/drm/drm_atomic_helper.c |  23 +--
 drivers/gpu/drm/drm_fb_helper.c | 232 +++-
 drivers/gpu/drm/gma500/framebuffer.c|  22 ---
 drivers/gpu/drm/gma500/gma_display.c|  32 ++--
 drivers/gpu/drm/gma500/psb_intel_display.c  |   7 +-
 drivers/gpu/drm/gma500/psb_intel_drv.h  |   1 -
 drivers/gpu/drm/i915/intel_drv.h|   1 -
 drivers/gpu/drm/i915/intel_fbdev.c  |  31 
 drivers/gpu/drm/mgag200/mgag200_drv.h   |   5 -
 drivers/gpu/drm/mgag200/mgag200_fb.c|   2 -
 drivers/gpu/drm/mgag200/mgag200_mode.c  | 

[PATCH v5 00/14] improve the fb_setcmap helper

2017-10-26 Thread Peter Rosin
Hi!

While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.

I have obviously not tested all of this with more than a compile,
but patches 1 and 3 are enough to make the atmel-hlcdc driver
do what I need. The rest is just lots of removals and cleanup made
possible by the other improvements.

Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere, or if I have misunderstood something
about atomics...

Changes since v5:
- Rebased onto fresher drm-misc-next.
- Instead of just exporting drm_atomic_replace_propery_blob(), move
  it to drm_propery.c, rename it to drm_property_replace_blob() and
  change its semantics to return if the blob was replaced.
- Install the same gamma_lut blob for all crtc, regardless of any
  variation in the gamma_lut state for the individual crtc prior to
  the fbdev setcmap call.
- Add acks from Daniel for patches 4-14.

Changes since v3:
- Rebased onto drm-misc-next and dropped patches 1-3 from v3, since
  they are already merged.
- Dropped the v3 patch 4/16 ("drm/color-mgmt: move atomic state/commit
  out from .gamma_set") since the atomic setcmap no longer uses
  the crtc .gamma_set callback.
- Added patch 1/14 which exports drm_atomic_replace_property_blob...
- ...and patch 2/14 which uses this new export to simplify
  drm_atomic_helper_legacy_gamma_set.
- Big changes to patch 3/14 (was 5/16 in v3). It had various locking
  issues and the atomic setcmap is rather different.

Changes since v2:
- Added patch 1/16 which factors out pseudo-palette handling.
- Removed the if (cmap->start + cmap->len < cmap->start)
  sanity check on the assumption that the fbdev core handles it.
- Added patch 4/16 which factors out atomic state and commit
  handling from drm_atomic_helper_legacy_gamma_set to
  drm_mode_gamma_set_ioctl.
- Do one atomic commit for all affected crtc.
- Removed a now obsolete note in include/drm/drm_crtc.h (ammended
  the last patch).
- Cc list is getting long, so I have redused the list for the
  individual patches. If you would like to get the full series
  (or nothing at all) for the next round (if that is needed) just
  say so.

Changes since v1:
- Rebased to next-20170621
- Split 1/11 into a preparatory patch, a cleanup patch and then
  the meat in 3/14.
- Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
- Removed the empty .gamma_get/.gamma_set fb helpers from the
  armada driver that I had somehow managed to ignore but which
  0day found real quick.
- Be less judgemental on drivers only providing .gamma_get and
  .gamma_set, but no .load_lut. That's actually a valid thing
  to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
- Add a comment about colliding bitfields in the nouveau driver.
- Remove gamma_set/gamma_get declarations from the radeon driver
  (the definitions were removed in v1).

Cheers,
peda

Peter Rosin (14):
  drm: rename, adjust and export drm_atomic_replace_property_blob
  drm/atomic-helper: update lut props directly in ..._legacy_gamma_set
  drm/fb-helper: separate the fb_setcmap helper into atomic and legacy
paths
  drm: amd: remove dead code and pointless local lut storage
  drm: armada: remove dead empty functions
  drm: ast: remove dead code and pointless local lut storage
  drm: cirrus: remove dead code and pointless local lut storage
  drm: gma500: remove dead code and pointless local lut storage
  drm: i915: remove dead code and pointless local lut storage
  drm: mgag200: remove dead code and pointless local lut storage
  drm: nouveau: remove dead code and pointless local lut storage
  drm: radeon: remove dead code and pointless local lut storage
  drm: stm: remove dead code and pointless local lut storage
  drm: remove unused and redundant callbacks

 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  24 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|   1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  27 +---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c|  23 ---
 drivers/gpu/drm/armada/armada_crtc.c|  10 --
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_fbdev.c   |   2 -
 drivers/gpu/drm/ast/ast_drv.h   |   1 -
 drivers/gpu/drm/ast/ast_fb.c|  20 ---
 drivers/gpu/drm/ast/ast_mode.c  |  26 +---
 drivers/gpu/drm/cirrus/cirrus_drv.h |   8 -
 drivers/gpu/drm/cirrus/cirrus_fbdev.c   |   2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c|  71 ++---
 drivers/gpu/drm/drm_atomic.c|  30 +---
 drivers/gpu/drm/drm_atomic_helper.c |  20 +--
 drivers/gpu/drm/drm_fb_helper.c | 231 +++-
 drivers/gpu/d

[PATCH v4 07/14] drm: cirrus: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  8 
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 71 ---
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352..be2d7e48 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
struct drm_crtc base;
-   u8  lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
boolenabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 
-   /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
-
-
/* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
  struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..1fedab0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-   .gamma_set = cirrus_crtc_fb_gamma_set,
-   .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
 };
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 53f6f0f..a4c4a46 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   struct cirrus_device *cdev = dev->dev_private;
-   int i;
-
-   if (!crtc->enabled)
-   return;
-
-   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-   /* VGA registers */
-   WREG8(PALETTE_INDEX, i);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-   }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, 
u16 *red, u16 *green,
 u16 *blue, uint32_t size,
 struct drm_modeset_acquire_ctx *ctx)
 {
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct cirrus_device *cdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
-   for (i = 0; i < size; i++) {
-   cirrus_crtc->lut_r[i] = red[i];
-   cirrus_crtc->lut_g[i] = green[i];
-   cirrus_crtc->lut_b[i] = blue[i];
+   if (!crtc->enabled)
+   return 0;
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+   /* VGA registers */
+   WREG8(PALETTE_INDEX, i);
+   WREG8(PALETTE_DATA, *r++ >> 8);
+   WREG8(PALETTE_DATA, *g++ >> 8);
+   WREG8(PALETTE_DATA, *b++ >> 8);
}
-   cirrus_crtc_load_lut(crtc);
 
return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
-   .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
-   int i;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cde

[PATCH v5 07/14] drm: cirrus: remove dead code and pointless local lut storage

2017-10-26 Thread Peter Rosin
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Acked-by: Daniel Vetter 
Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  8 
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 -
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 71 ---
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352d96f7..be2d7e488062 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
struct drm_crtc base;
-   u8  lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
boolenabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 
-   /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-u16 *blue, int regno);
-
-
/* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
  struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58eeadc9d..1fedab03f659 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-   .gamma_set = cirrus_crtc_fb_gamma_set,
-   .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
 };
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 53f6f0f84206..a4c4a465b385 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   struct cirrus_device *cdev = dev->dev_private;
-   int i;
-
-   if (!crtc->enabled)
-   return;
-
-   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-   /* VGA registers */
-   WREG8(PALETTE_INDEX, i);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-   WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-   }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, 
u16 *red, u16 *green,
 u16 *blue, uint32_t size,
 struct drm_modeset_acquire_ctx *ctx)
 {
-   struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct cirrus_device *cdev = dev->dev_private;
+   u16 *r, *g, *b;
int i;
 
-   for (i = 0; i < size; i++) {
-   cirrus_crtc->lut_r[i] = red[i];
-   cirrus_crtc->lut_g[i] = green[i];
-   cirrus_crtc->lut_b[i] = blue[i];
+   if (!crtc->enabled)
+   return 0;
+
+   r = crtc->gamma_store;
+   g = r + crtc->gamma_size;
+   b = g + crtc->gamma_size;
+
+   for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+   /* VGA registers */
+   WREG8(PALETTE_INDEX, i);
+   WREG8(PALETTE_DATA, *r++ >> 8);
+   WREG8(PALETTE_DATA, *g++ >> 8);
+   WREG8(PALETTE_DATA, *b++ >> 8);
}
-   cirrus_crtc_load_lut(crtc);
 
return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
-   .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
-   int i;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_

[RFC PATCH 12/33] Change __FIXADDR_TOP to leave room for the hypervisor.

2017-10-26 Thread Solen win2
supp...@btc.com

all
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH 7/8] drm: Nuke drm_atomic_helper_connector_dpms

2017-10-26 Thread Philippe CORNU


On 07/25/2017 10:01 AM, Daniel Vetter wrote:
> It's dead code, the core handles all this directly now.
> 
> The only special case is nouveau and tda988x which used one function
> for both legacy modeset code and -nv50 atomic world instead of 2
> vtables. But amounts to exactly the same.
> 
> v2: Rebase over the panel/brideg refactorings in stm/ltdc.
> 
> Signed-off-by: Daniel Vetter 
> Cc: Archit Taneja 
> Cc: Andrzej Hajda 
> Cc: Laurent Pinchart 
> Cc: Peter Senna Tschudin 
> Cc: Martin Donnelly 
> Cc: Martyn Welch 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: David Airlie 
> Cc: Inki Dae 
> Cc: Joonyoung Shim 
> Cc: Seung-Woo Kim 
> Cc: Kyungmin Park 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Stefan Agner 
> Cc: Alison Wang 
> Cc: Russell King 
> Cc: Philipp Zabel 
> Cc: CK Hu 
> Cc: Matthias Brugger 
> Cc: Neil Armstrong 
> Cc: Carlo Caione 
> Cc: Kevin Hilman 
> Cc: Marek Vasut 
> Cc: Ben Skeggs 
> Cc: Tomi Valkeinen 
> Cc: Eric Anholt 
> Cc: Mark Yao 
> Cc: Heiko Stuebner 
> Cc: Benjamin Gaignard 
> Cc: Vincent Abriou 
> Cc: Yannick Fertre 
> Cc: Philippe Cornu 

Tested-by: Philippe Cornu  (on stm)

Many thanks
Philippe :-)

> Cc: Maxime Ripard 
> Cc: Chen-Yu Tsai 
> Cc: Thierry Reding 
> Cc: Jonathan Hunter 
> Cc: Jyri Sarha 
> Cc: Gerd Hoffmann 
> Cc: Shawn Guo 
> Cc: John Stultz 
> Cc: Lars-Peter Clausen 
> Cc: Sergei Shtylyov 
> Cc: Jeffy Chen 
> Cc: Tomeu Vizoso 
> Cc: Yakir Yang 
> Cc: Marek Szyprowski 
> Cc: Jose Abreu 
> Cc: Romain Perier 
> Cc: Kieran Bingham 
> Cc: Xinliang Liu 
> Cc: Alexey Brodkin 
> Cc: Alex Deucher 
> Cc: Rongrong Zou 
> Cc: Rob Clark 
> Cc: Hai Li 
> Cc: "Noralf Trønnes" 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: intel-...@lists.freedesktop.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-amlo...@lists.infradead.org
> Cc: nouv...@lists.freedesktop.org
> Cc: linux-renesas-...@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> Cc: linux-te...@vger.kernel.org
> Cc: virtualization@lists.linux-foundation.org
> Cc: zain wang 
> Cc: Baoyou Xie 
> Cc: Boris Brezillon 
> ---
>   drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   |  1 -
>   drivers/gpu/drm/bridge/analogix-anx78xx.c  |  1 -
>   drivers/gpu/drm/bridge/analogix/analogix_dp_core.c |  1 -
>   drivers/gpu/drm/bridge/dumb-vga-dac.c  |  1 -
>   .../drm/bridge/megachips-stdp-ge-b850v3-fw.c   |  1 -
>   drivers/gpu/drm/bridge/nxp-ptn3460.c   |  1 -
>   drivers/gpu/drm/bridge/panel.c |  1 -
>   drivers/gpu/drm/bridge/parade-ps8622.c |  1 -
>   drivers/gpu/drm/bridge/sii902x.c   |  1 -
>   drivers/gpu/drm/bridge/synopsys/dw-hdmi.c  |  1 -
>   drivers/gpu/drm/bridge/tc358767.c  |  1 -
>   drivers/gpu/drm/bridge/ti-tfp410.c |  1 -
>   drivers/gpu/drm/drm_atomic_helper.c| 79 
> --
>   drivers/gpu/drm/exynos/exynos_drm_dpi.c|  1 -
>   drivers/gpu/drm/exynos/exynos_drm_dsi.c|  1 -
>   drivers/gpu/drm/exynos/exynos_drm_vidi.c   |  1 -
>   drivers/gpu/drm/exynos/exynos_hdmi.c   |  1 -
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c  |  1 -
>   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c   |  1 -
>   drivers/gpu/drm/i2c/tda998x_drv.c  | 10 +--
>   drivers/gpu/drm/i915/intel_crt.c   |  1 -
>   drivers/gpu/drm/i915/intel_dp.c|  1 -
>   drivers/gpu/drm/i915/intel_dp_mst.c|  1 -
>   drivers/gpu/drm/i915/intel_dsi.c   |  1 -
>   drivers/gpu/drm/i915/intel_dvo.c   |  1 -
>   drivers/gpu/drm/i915/intel_hdmi.c  |  1 -
>   drivers/gpu/drm/i915/intel_lvds.c  |  1 -
>   drivers/gpu/drm/i915/intel_sdvo.c  |  1 -
>   drivers/gpu/drm/i915/intel_tv.c|  1 -
>   drivers/gpu/drm/imx/imx-ldb.c  |  1 -
>   drivers/gpu/drm/imx/imx-tve.c  |  1 -
>   drivers/gpu/drm/imx/parallel-display.c |  1 -
>   drivers/gpu/drm/mediatek/mtk_dsi.c |  1 -
>   drivers/gpu/drm/mediatek/mtk_hdmi.c|  1 -
>   drivers/gpu/drm/meson/meson_venc_cvbs.c|  1 -
>   drivers/gpu/drm/msm/dsi/dsi_manager.c  |  1 -
>   drivers/gpu/drm/msm/edp/edp_connector.c|  1 -
>   drivers/gpu/drm/msm/hdmi/hdmi_connector.c  |  1 -
>   drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c |  1 -
>   drivers/gpu/drm/mxsfb/mxsfb_out.c  |  1 -
>   drivers/gpu/drm/nouveau/nouveau_connector.c| 12 +---
>   drivers/gpu/drm/nouveau/nv50_display.c |  1 -
>   drivers/gpu/drm/omapdrm/omap_connector.c   |  1 -
>   drivers/gpu/drm/pl111/pl111_connector.c|  1 -
>   drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c  |  1 -
>   drivers/gpu/drm/rockchip/cdn-dp-core.c   

Re: [PATCH 7/8] drm: Nuke drm_atomic_helper_connector_dpms

2017-10-26 Thread Shawn Guo
On Tue, Jul 25, 2017 at 10:01:21AM +0200, Daniel Vetter wrote:
> It's dead code, the core handles all this directly now.
> 
> The only special case is nouveau and tda988x which used one function
> for both legacy modeset code and -nv50 atomic world instead of 2
> vtables. But amounts to exactly the same.
> 
> v2: Rebase over the panel/brideg refactorings in stm/ltdc.
> 
> Signed-off-by: Daniel Vetter 
...
>  drivers/gpu/drm/zte/zx_hdmi.c  |  1 -
>  drivers/gpu/drm/zte/zx_tvenc.c |  1 -
>  drivers/gpu/drm/zte/zx_vga.c   |  1 -

Acked-by: Shawn Guo 
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: Performance regression with virtio_net

2017-10-26 Thread Seth Forshee
On Fri, Jul 28, 2017 at 12:30:54AM +0300, Michael S. Tsirkin wrote:
> On Thu, Jul 27, 2017 at 04:14:30PM -0500, Seth Forshee wrote:
> > On Thu, Jul 27, 2017 at 11:38:52PM +0300, Michael S. Tsirkin wrote:
> > > On Thu, Jul 27, 2017 at 12:09:42PM -0500, Seth Forshee wrote:
> > > > I'm seeing a performance regression with virtio_net that looks to have
> > > > started in 4.12-rc1. I only see it in one context though, downloading
> > > > snap packages from the Ubuntu snap store. For example:
> > > > 
> > > >  
> > > > https://api.snapcraft.io/api/v1/snaps/download/b8X2psL1ryVrPt5WEmpYiqfr5emixTd7_1797.snap
> > > > 
> > > > which redirects to Internap's CDN. Normally this downloads in a few
> > > > seconds at ~10 MB/s, but with 4.12 and 4.13 it takes minutes with a rate
> > > > of ~150 KB/s. Everything else I've tried downloads as normal speeds.
> > > 
> > > So just wget that URL should be enough?
> > 
> > Yes. Note that sometimes it starts out faster then slows down.
> > > > I bisected this to 680557cf79f8 "virtio_net: rework mergeable buffer
> > > > handling". If I revert this on top of 4.13-rc2 (along with other changes
> > > > needed to successfully revert it) speeds return to normal.
> > > > 
> > > > Thanks,
> > > > Seth
> > > 
> > > 
> > > Interesting. A more likely suspect would be
> > > e377fcc8486d40867c6c217077ad0fa40977e060 - could you please try
> > > reverting that one instead?
> > 
> > I tried it, and I still get slow download speeds. I did test at
> > 680557cf79f82623e2c4fd42733077d60a843513 during the bisect so I'm
> > reasonably confident that this is the one where things went bad.
> > > Also, could you please look at mergeable_rx_buffer_size in sysfs with
> > > and without the change?
> > 
> > In all cases (stock 4.13-rc2, 680557cf79f8 reverted, and e377fcc8486d
> > reverted) mergeable_rx_buffer_size was 1536.
> > 
> > Thanks,
> > Seth
> 
> Do you see any error counters incrementing after it slows down?

I see rx_dropped and rx_length_errors increasing in lockstep once it
slows down.

Thanks,
Seth
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Performance regression with virtio_net

2017-10-26 Thread Seth Forshee
I'm seeing a performance regression with virtio_net that looks to have
started in 4.12-rc1. I only see it in one context though, downloading
snap packages from the Ubuntu snap store. For example:

 
https://api.snapcraft.io/api/v1/snaps/download/b8X2psL1ryVrPt5WEmpYiqfr5emixTd7_1797.snap

which redirects to Internap's CDN. Normally this downloads in a few
seconds at ~10 MB/s, but with 4.12 and 4.13 it takes minutes with a rate
of ~150 KB/s. Everything else I've tried downloads as normal speeds.

I bisected this to 680557cf79f8 "virtio_net: rework mergeable buffer
handling". If I revert this on top of 4.13-rc2 (along with other changes
needed to successfully revert it) speeds return to normal.

Thanks,
Seth
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] mm: don't zero ballooned pages

2017-10-26 Thread ZhenweiPi

on qemu upstream, code in qemu/util/osdep.c

int qemu_madvise(void *addr, size_t len, int advice)

{

if (advice == QEMU_MADV_INVALID) {

errno = EINVAL;

return -1;

}

#if defined(CONFIG_MADVISE)

return madvise(addr, len, advice);

#elif defined(CONFIG_POSIX_MADVISE)

return posix_madvise(addr, len, advice);

#else

errno = EINVAL;

return -1;

#endif

}

Host OS maybe not support MADV_DONTNEED.
And madvise syscall uses more time.


On 07/31/2017 02:55 PM, Michal Hocko wrote:

On Mon 31-07-17 12:13:33, Wei Wang wrote:

Ballooned pages will be marked as MADV_DONTNEED by the hypervisor and
shouldn't be given to the host ksmd to scan.

Could you point me where this MADV_DONTNEED is done, please?


Therefore, it is not
necessary to zero ballooned pages, which is very time consuming when
the page amount is large. The ongoing fast balloon tests show that the
time to balloon 7G pages is increased from ~491ms to 2.8 seconds with
__GFP_ZERO added. So, this patch removes the flag.

Please make it obvious that this is a revert of bb01b64cfab7
("mm/balloon_compaction.c: enqueue zero page to balloon device").


Signed-off-by: Wei Wang 
---
  mm/balloon_compaction.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 9075aa5..b06d9fe 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -24,7 +24,7 @@ struct page *balloon_page_enqueue(struct balloon_dev_info 
*b_dev_info)
  {
unsigned long flags;
struct page *page = alloc_page(balloon_mapping_gfp_mask() |
-   __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_ZERO);
+  __GFP_NOMEMALLOC | __GFP_NORETRY);
if (!page)
return NULL;
  
--

2.7.4



___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 7/8] drm: Nuke drm_atomic_helper_connector_dpms

2017-10-26 Thread Noralf Trønnes


Den 25.07.2017 10.01, skrev Daniel Vetter:

It's dead code, the core handles all this directly now.

The only special case is nouveau and tda988x which used one function
for both legacy modeset code and -nv50 atomic world instead of 2
vtables. But amounts to exactly the same.

v2: Rebase over the panel/brideg refactorings in stm/ltdc.

Signed-off-by: Daniel Vetter 

...

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
index ec43fb7ad9e4..79b6687977d3 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
@@ -71,7 +71,6 @@ static void tinydrm_connector_destroy(struct drm_connector 
*connector)
  }
  
  static const struct drm_connector_funcs tinydrm_connector_funcs = {

-   .dpms = drm_atomic_helper_connector_dpms,
.reset = drm_atomic_helper_connector_reset,
.detect = tinydrm_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,


Acked-by: Noralf Trønnes 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: Performance regression with virtio_net

2017-10-26 Thread Seth Forshee
On Thu, Jul 27, 2017 at 11:38:52PM +0300, Michael S. Tsirkin wrote:
> On Thu, Jul 27, 2017 at 12:09:42PM -0500, Seth Forshee wrote:
> > I'm seeing a performance regression with virtio_net that looks to have
> > started in 4.12-rc1. I only see it in one context though, downloading
> > snap packages from the Ubuntu snap store. For example:
> > 
> >  
> > https://api.snapcraft.io/api/v1/snaps/download/b8X2psL1ryVrPt5WEmpYiqfr5emixTd7_1797.snap
> > 
> > which redirects to Internap's CDN. Normally this downloads in a few
> > seconds at ~10 MB/s, but with 4.12 and 4.13 it takes minutes with a rate
> > of ~150 KB/s. Everything else I've tried downloads as normal speeds.
> 
> So just wget that URL should be enough?

Yes. Note that sometimes it starts out faster then slows down.

> > I bisected this to 680557cf79f8 "virtio_net: rework mergeable buffer
> > handling". If I revert this on top of 4.13-rc2 (along with other changes
> > needed to successfully revert it) speeds return to normal.
> > 
> > Thanks,
> > Seth
> 
> 
> Interesting. A more likely suspect would be
> e377fcc8486d40867c6c217077ad0fa40977e060 - could you please try
> reverting that one instead?

I tried it, and I still get slow download speeds. I did test at
680557cf79f82623e2c4fd42733077d60a843513 during the bisect so I'm
reasonably confident that this is the one where things went bad.

> Also, could you please look at mergeable_rx_buffer_size in sysfs with
> and without the change?

In all cases (stock 4.13-rc2, 680557cf79f8 reverted, and e377fcc8486d
reverted) mergeable_rx_buffer_size was 1536.

Thanks,
Seth
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] mm: don't zero ballooned pages

2017-10-26 Thread ZhenweiPi

On 07/31/2017 03:51 PM, Michal Hocko wrote:


On Mon 31-07-17 15:41:49, Wei Wang wrote:

>On 07/31/2017 02:55 PM, Michal Hocko wrote:

> >On Mon 31-07-17 12:13:33, Wei Wang wrote:

> >>Ballooned pages will be marked as MADV_DONTNEED by the hypervisor and
> >>shouldn't be given to the host ksmd to scan.

> >Could you point me where this MADV_DONTNEED is done, please?

>
>Sure. It's done in the hypervisor when the balloon pages are received.
>
>Please see line 40 at
>https://github.com/qemu/qemu/blob/master/hw/virtio/virtio-balloon.c

And one more thing. I am not familiar with ksm much. But how is
MADV_DONTNEED even helping? This madvise is not sticky - aka it will
unmap the range without leaving any note behind. AFAICS the only way
to have vma scanned is to have VM_MERGEABLE and that is an opt in:
See Documentation/vm/ksm.txt
"
KSM only operates on those areas of address space which an application
has advised to be likely candidates for merging, by using the madvise(2)
system call: int madvise(addr, length, MADV_MERGEABLE).
"

So what exactly is going on here? The original patch looks highly
suspicious as well. If somebody wants to make that memory mergable then
the user of that memory should zero them out.


Kernel starts a kthread named "ksmd". ksmd scans the VM_MERGEABLE

memory, and merge the same pages.(same page means memcmp(page1,

page2, PAGESIZE) == 0).

Guest can not use ballooned pages, and these pages will not be accessed

in a long time. Kswapd on host will swap these pages out and get more

free memory.

Rather than swapping, KSM has better performence.  Presently pages in

the balloon device have random value,  they usually cannot be merged.

So enqueue zero pages will resolve this problem.

Because MADV_DONTNEED depends on host os capability and hypervisor capability,
I prefer to enqueue zero pages to balloon device and made this patch.

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH 00/29] DRM API conversions

2017-10-26 Thread Cihangir Akturk
This patch set replaces the occurrences of drm_*_reference() and
drm_*_unreference() with the new drm_*_get() and drm_*_put() functions.
All patches in the series do the same thing, converting to the new APIs.
I created patches per DRM driver as suggested by Daniel Vetter.

Background:

In the kernel, reference counting APIs use *_get(), *_put() style naming
to reference-count the objects. But DRM subsystem uses a different
naming for them such as *_reference(), *_unreference() which is
inconsistent with the other reference counting APIs in the kernel. To
solve this consistency issue, Thierry Reding introduced a couple of
functions and compatibility aliases in the following commits for them.

commit 020a218f95bd3ceff7dd1022ff7ebc0497bc7bf9
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:38 2017 +0100

drm: Introduce drm_mode_object_{get,put}()

commit ad09360750afa18a0a0ce0253d6ea6033abc22e7
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:39 2017 +0100

drm: Introduce drm_connector_{get,put}()

commit a4a69da06bc11a937a6e417938b1bb698ee1fa46
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:40 2017 +0100

drm: Introduce drm_framebuffer_{get,put}()

commit e6b62714e87c8811d5564b6a0738dcde63a51774
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:41 2017 +0100

drm: Introduce drm_gem_object_{get,put}()

commit 6472e5090be7c78749a3c279b4faae87ab835c40
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:42 2017 +0100

drm: Introduce drm_property_blob_{get,put}()


This patch set was generated using the following shell script:

#!/bin/sh

path=$1

do_replace() {
local pattern=$1
local replacement=$2

git grep -lw "${pattern}" -- "${path}/*.[hc]" |\
xargs -r sed -i "s/\b$pattern\b/$replacement/g"
}

do_replace drm_mode_object_reference drm_mode_object_get
do_replace drm_mode_object_unreference drm_mode_object_put
do_replace drm_connector_reference drm_connector_get
do_replace drm_connector_unreference drm_connector_put
do_replace drm_framebuffer_reference drm_framebuffer_get
do_replace drm_framebuffer_unreference drm_framebuffer_put
do_replace drm_gem_object_reference drm_gem_object_get
do_replace drm_gem_object_unreference drm_gem_object_put
do_replace __drm_gem_object_unreference __drm_gem_object_put
do_replace drm_gem_object_unreference_unlocked drm_gem_object_put_unlocked
do_replace drm_property_reference_blob drm_property_blob_get
do_replace drm_property_unreference_blob drm_property_blob_put

Cihangir Akturk (29):
  drm/amdgpu: switch to drm_*{get,put} helpers
  drm: mali-dp: switch to drm_*{get,put} helpers
  drm/armada: switch to drm_*{get,put} helpers
  drm/ast: switch to drm_*{get,put} helpers
  drm/atmel-hlcdc: switch to drm_*{get,put} helpers
  drm/bochs: switch to drm_*{get,put} helpers
  drm/cirrus: switch to drm_*{get,put} helpers
  drm/etnaviv: switch to drm_*{get,put} helpers
  drm/exynos: switch to drm_*{get,put} helpers
  drm/gma500: switch to drm_*{get,put} helpers
  drm/hisilicon: switch to drm_*{get,put} helpers
  drm/i915: switch to drm_*{get,put} helpers
  drm/imx: switch to drm_*{get,put} helpers
  drm/mediatek: switch to drm_*{get,put} helpers
  drm/mgag200: switch to drm_*{get,put} helpers
  drm/msm: switch to drm_*{get,put} helpers
  drm/nouveau: switch to drm_*{get,put} helpers
  drm/omap: switch to drm_*{get,put} helpers
  drm/qxl: switch to drm_*{get,put} helpers
  drm/radeon: switch to drm_*{get,put} helpers
  drm/rockchip: switch to drm_*{get,put} helpers
  drm/tegra: switch to drm_*{get,put} helpers
  drm/tilcdc: switch to drm_*{get,put} helpers
  drm/udl: switch to drm_*{get,put} helpers
  drm/vc4: switch to drm_*{get,put} helpers
  drm/vgem: switch to drm_*{get,put} helpers
  drm/virtio: switch to drm_*{get,put} helpers
  drm/vmwgfx: switch to drm_*{get,put} helpers
  staging: vboxvideo: switch to drm_*{get,put} helpers

 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c|  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c   | 22 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  6 ++---
 drivers/gpu/drm/arm/malidp_planes.c   |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c  | 22 -
 drivers/gpu/drm/armada/armada_drv.c   |  2 +-
 drivers/gpu/drm/armada/armada_fb.c|  8 +++---
 drivers/gpu/drm/armada/armada_fbdev.c |  6 ++---
 drivers/gpu/drm/armada/armada_gem.c   | 14 +--
 drivers/gpu/drm/armada/armada_overlay.c   |  4 +--
 drivers/gpu/drm/ast/ast_fb.c  |  2 +-
 drivers/gpu/drm/ast/ast_main.c| 10 
 drivers/g

[PATCH 19/29] drm/qxl: switch to drm_*{get,put} helpers

2017-10-26 Thread Cihangir Akturk
drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() adn should not be
used by new code. So convert all users of compatibility functions to use
the new APIs.

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/qxl/qxl_display.c | 4 ++--
 drivers/gpu/drm/qxl/qxl_dumb.c| 2 +-
 drivers/gpu/drm/qxl/qxl_fb.c  | 6 +++---
 drivers/gpu/drm/qxl/qxl_gem.c | 2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c   | 4 ++--
 drivers/gpu/drm/qxl/qxl_object.c  | 6 +++---
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 03fe182..7aa5097 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -306,7 +306,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer 
*fb)
 {
struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(qxl_fb->obj);
+   drm_gem_object_put_unlocked(qxl_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(qxl_fb);
 }
@@ -1109,7 +1109,7 @@ qxl_user_framebuffer_create(struct drm_device *dev,
ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj, &qxl_fb_funcs);
if (ret) {
kfree(qxl_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 5e65d5d..a0c9e73 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -81,6 +81,6 @@ int qxl_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
qobj = gem_to_qxl_bo(gobj);
*offset_p = qxl_bo_mmap_offset(qobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 573e7e9..47a25b0 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -95,7 +95,7 @@ static void qxlfb_destroy_pinned_object(struct drm_gem_object 
*gobj)
qxl_bo_kunmap(qbo);
qxl_bo_unpin(qbo);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
 }
 
 int qxl_get_handle_for_primary_fb(struct qxl_device *qdev,
@@ -320,11 +320,11 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
qxl_bo_unpin(qbo);
}
if (fb && ret) {
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
drm_framebuffer_cleanup(fb);
kfree(fb);
}
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index 85f5467..f5c1e78 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -98,7 +98,7 @@ int qxl_gem_object_create_with_handle(struct qxl_device *qdev,
return r;
/* drop reference from allocate - handle holds it now */
*qobj = gem_to_qxl_bo(gobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 0b82a87..dfefd45 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -121,7 +121,7 @@ static int qxlhw_handle_to_bo(struct drm_file *file_priv, 
uint64_t handle,
qobj = gem_to_qxl_bo(gobj);
 
ret = qxl_release_list_add(release, qobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -342,7 +342,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, 
void *data,
qxl_bo_unreserve(qobj);
 
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 9a7eef7..cdf1455 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -211,13 +211,13 @@ void qxl_bo_unref(struct qxl_bo **bo)
if ((*bo) == NULL)
return;
 
-   drm_gem_object_unreference_unlocked(&(*bo)->gem_base);
+   drm_gem_object_put_unlocked(&(*bo)->gem_base);
*bo = NULL;
 }
 
 struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo)
 {
-   drm_gem_object_reference(&bo->gem_base);
+   drm_gem_object_get(&bo->gem_base);
return bo;
 }
 
@@ -316,7 +316,7 @@ void qxl_bo_force_delete(struct qxl_device *qdev)
list_del_init(&bo->list);
mutex_unlock(&qdev->gem.mutex);
/* this should unref the ttm bo */
-   drm_gem_object_unreference_unlocked(&bo->gem_bas

[PATCH 06/29] drm/bochs: switch to drm_*{get,put} helpers

2017-10-26 Thread Cihangir Akturk
drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() adn should not be
used by new code. So convert all users of compatibility functions to use
the new APIs.

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c| 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c 
b/drivers/gpu/drm/bochs/bochs_fbdev.c
index c38deff..502f9d9 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -145,7 +145,7 @@ static int bochs_fbdev_destroy(struct bochs_device *bochs)
drm_fb_helper_unregister_fbi(&bochs->fb.helper);
 
if (gfb->obj) {
-   drm_gem_object_unreference_unlocked(gfb->obj);
+   drm_gem_object_put_unlocked(gfb->obj);
gfb->obj = NULL;
}
 
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index c4cadb6..881b784 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -417,7 +417,7 @@ int bochs_dumb_create(struct drm_file *file, struct 
drm_device *dev,
return ret;
 
ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -457,7 +457,7 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct 
drm_device *dev,
bo = gem_to_bochs_bo(obj);
*offset = bochs_bo_mmap_offset(bo);
 
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return 0;
 }
 
@@ -467,7 +467,7 @@ static void bochs_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 {
struct bochs_framebuffer *bochs_fb = to_bochs_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(bochs_fb->obj);
+   drm_gem_object_put_unlocked(bochs_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
@@ -518,13 +518,13 @@ bochs_user_framebuffer_create(struct drm_device *dev,
 
bochs_fb = kzalloc(sizeof(*bochs_fb), GFP_KERNEL);
if (!bochs_fb) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM);
}
 
ret = bochs_framebuffer_init(dev, bochs_fb, mode_cmd, obj);
if (ret) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
kfree(bochs_fb);
return ERR_PTR(ret);
}
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 07/29] drm/cirrus: switch to drm_*{get,put} helpers

2017-10-26 Thread Cihangir Akturk
drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() adn should not be
used by new code. So convert all users of compatibility functions to use
the new APIs.

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 +-
 drivers/gpu/drm/cirrus/cirrus_main.c  | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..c0b9a29 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -252,7 +252,7 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
drm_fb_helper_unregister_fbi(&gfbdev->helper);
 
if (gfb->obj) {
-   drm_gem_object_unreference_unlocked(gfb->obj);
+   drm_gem_object_put_unlocked(gfb->obj);
gfb->obj = NULL;
}
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index e7fc95f..b5f5285 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -18,7 +18,7 @@ static void cirrus_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 {
struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(cirrus_fb->obj);
+   drm_gem_object_put_unlocked(cirrus_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
@@ -67,13 +67,13 @@ cirrus_user_framebuffer_create(struct drm_device *dev,
 
cirrus_fb = kzalloc(sizeof(*cirrus_fb), GFP_KERNEL);
if (!cirrus_fb) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM);
}
 
ret = cirrus_framebuffer_init(dev, cirrus_fb, mode_cmd, obj);
if (ret) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
kfree(cirrus_fb);
return ERR_PTR(ret);
}
@@ -261,7 +261,7 @@ int cirrus_dumb_create(struct drm_file *file,
return ret;
 
ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -310,7 +310,7 @@ cirrus_dumb_mmap_offset(struct drm_file *file,
bo = gem_to_cirrus_bo(obj);
*offset = cirrus_bo_mmap_offset(bo);
 
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
return 0;
 }
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 3/3] char: virtio: constify attribute_group structures.

2017-10-26 Thread Arvind Yadav
attribute_group are not supposed to change at runtime. All functions
working with attribute_group provided by  work with
const attribute_group. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/char/virtio_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ad843eb..06bd635 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1308,7 +1308,7 @@ static ssize_t show_port_name(struct device *dev,
NULL
 };
 
-static struct attribute_group port_attribute_group = {
+static const struct attribute_group port_attribute_group = {
.name = NULL,   /* put in device directory */
.attrs = port_sysfs_entries,
 };
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [virtio-dev] repost: af_packet vs virtio (was packed ring layout proposal v2)

2017-10-26 Thread Adam Tao
On Wed, Aug 02, 2017 at 04:50:03PM +0300, Michael S. Tsirkin wrote:
> On Tue, Aug 01, 2017 at 08:54:27PM -0700, Steven Luong wrote:
> > * Descriptor ring:
> > 
> > Guest adds descriptors with unique index values and DESC_HW set in 
> > flags.
> > Host overwrites used descriptors with correct len, index, and DESC_HW
> > clear.? Flags are always set/cleared last.
> > 
> > #define DESC_HW 0x0080
> > 
> > struct desc {
> > ? ? ? ? __le64 addr;
> > ? ? ? ? __le32 len;
> > ? ? ? ? __le16 index;
> > ? ? ? ? __le16 flags;
> > };
> > 
> > When DESC_HW is set, descriptor belongs to device. When it is clear,
> > it belongs to the driver.
> > 
> > We can use 1 bit to set direction
> > /* This marks a buffer as write-only (otherwise read-only). */
> > #define VRING_DESC_F_WRITE? ? ? 2
> > 
> > * Scatter/gather support
> > 
> > We can use 1 bit to chain s/g entries in a request, same as virtio 1.0:
> > 
> > /* This marks a buffer as continuing via the next field. */
next field seems like a structure field in the software, maybe we need
to change the "next field" to "next desc" to avoid misunderstanding.
> > 
> > 
> > This comment here is confusing to me. In 1.0, virtq_desc has the next field.
> > When the flag VRING_DESC_F_NEXT is set, the next entry to continue is 
> > specified
> > in the next field.
> > 
> > Here in 1.1, struct desc does not have the next field, only addr, len, 
> > index,
> > and flags. So when VRING_DESC_F_NEXT is set in struct desc's flags field, 
> > where
> > is the next entry to continue the current descriptor, the entry immediately
> > following the current entry? ie, if the current entry is at index 10 in the
> > descriptor table and its flags is set for VRING_DESC_F_NEXT, is the entry
> > continuing the current entry in index 11?
> > 
> > Steven
> 
> Exactly, you got it right.
> 
> -
> To unsubscribe, e-mail: virtio-dev-unsubscr...@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-h...@lists.oasis-open.org
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Joe Kniss
Because all drivers currently use gem objects for framebuffer planes,
the virtual create_handle() is not required.  This change adds a
struct drm_gem_object *gems[4] field to drm_framebuffer and removes
create_handle() function pointer from drm_framebuffer_funcs.  The
corresponding *_create_handle() function is removed from each driver.

In many cases this change eliminates a struct *_framebuffer object,
as the only need for the derived struct is the addition of the gem
object pointer.

TESTED: compiled: allyesconfig ARCH=x86,arm platforms:i915, rockchip

Signed-off-by: Joe Kniss 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c  | 50 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   | 20 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |  8 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   | 19 +++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   | 19 +++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c| 19 +++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c| 19 +++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  6 +--
 drivers/gpu/drm/armada/armada_crtc.c |  2 +-
 drivers/gpu/drm/armada/armada_fb.c   | 13 ++---
 drivers/gpu/drm/armada/armada_fb.h   |  2 -
 drivers/gpu/drm/drm_fb_cma_helper.c  | 78 ++--
 drivers/gpu/drm/drm_framebuffer.c| 27 +-
 drivers/gpu/drm/exynos/exynos_drm_fb.c   | 61 +++---
 drivers/gpu/drm/gma500/accel_2d.c|  2 +-
 drivers/gpu/drm/gma500/framebuffer.c | 40 +++---
 drivers/gpu/drm/gma500/framebuffer.h |  3 +-
 drivers/gpu/drm/gma500/gma_display.c |  8 +--
 drivers/gpu/drm/gma500/mdfld_intel_display.c |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c   |  2 +-
 drivers/gpu/drm/i915/i915_debugfs.c  |  4 +-
 drivers/gpu/drm/i915/intel_display.c | 47 ++---
 drivers/gpu/drm/i915/intel_drv.h |  3 +-
 drivers/gpu/drm/i915/intel_fbdev.c   | 10 ++--
 drivers/gpu/drm/mediatek/mtk_drm_fb.c| 66 ++-
 drivers/gpu/drm/msm/msm_fb.c | 41 ---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c  | 10 ++--
 drivers/gpu/drm/nouveau/dispnv04/overlay.c   | 19 +++
 drivers/gpu/drm/nouveau/nouveau_display.c| 45 +++-
 drivers/gpu/drm/nouveau/nouveau_display.h|  1 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c  | 31 ++-
 drivers/gpu/drm/nouveau/nv50_display.c   | 22 
 drivers/gpu/drm/omapdrm/omap_fb.c| 54 ---
 drivers/gpu/drm/qxl/qxl_display.c| 73 --
 drivers/gpu/drm/qxl/qxl_draw.c   |  6 +--
 drivers/gpu/drm/qxl/qxl_drv.h| 12 ++---
 drivers/gpu/drm/qxl/qxl_fb.c | 24 -
 drivers/gpu/drm/radeon/atombios_crtc.c   | 22 +++-
 drivers/gpu/drm/radeon/radeon_device.c   |  6 +--
 drivers/gpu/drm/radeon/radeon_display.c  | 50 +++---
 drivers/gpu/drm/radeon/radeon_fb.c   | 20 +++
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c  | 16 +++---
 drivers/gpu/drm/radeon/radeon_mode.h |  8 +--
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c   | 65 ---
 drivers/gpu/drm/tegra/drm.h  |  8 +--
 drivers/gpu/drm/tegra/fb.c   | 64 +++
 drivers/gpu/drm/tinydrm/mipi-dbi.c   |  1 -
 drivers/gpu/drm/tinydrm/repaper.c|  1 -
 include/drm/drm_framebuffer.h| 26 ++
 50 files changed, 420 insertions(+), 741 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6279956e92a4..6d7995c1a8f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2421,7 +2421,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
suspend, bool fbcon)
/* unpin the front buffers and cursors */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   struct amdgpu_framebuffer *rfb = 
to_amdgpu_framebuffer(crtc->primary->fb);
+   struct drm_framebuffer *fb = crtc->primary->fb;
struct amdgpu_bo *robj;
 
if (amdgpu_crtc->cursor_bo) {
@@ -2433,10 +2433,10 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
suspend, bool fbcon)
}
}
 
-   if (rfb == NULL || rfb->obj == NULL) {
+   if (fb == NULL || fb->gem_objs[0] == NULL) {
continue;
}
-   robj = gem_to_amdgpu_bo(rfb->obj);
+   robj = gem_to_amdgpu_bo(fb->gem_objs[0]);
/* don't unpin kernel fb objects */
if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {
  

[PATCH 27/29] drm/virtio: switch to drm_*{get,put} helpers

2017-10-26 Thread Cihangir Akturk
drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() adn should not be
used by new code. So convert all users of compatibility functions to use
the new APIs.

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/virtio/virtgpu_display.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_gem.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_ioctl.c   | 14 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index d51bd45..ef2d450 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -53,7 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
struct virtio_gpu_framebuffer *virtio_gpu_fb
= to_virtio_gpu_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj);
+   drm_gem_object_put_unlocked(virtio_gpu_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(virtio_gpu_fb);
 }
@@ -326,7 +326,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj);
if (ret) {
kfree(virtio_gpu_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c 
b/drivers/gpu/drm/virtio/virtgpu_gem.c
index cc025d8..78da210 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -72,7 +72,7 @@ int virtio_gpu_gem_create(struct drm_file *file,
*obj_p = &obj->gem_base;
 
/* drop reference from allocate - handle holds it now */
-   drm_gem_object_unreference_unlocked(&obj->gem_base);
+   drm_gem_object_put_unlocked(&obj->gem_base);
 
*handle_p = handle;
return 0;
@@ -137,7 +137,7 @@ int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
obj = gem_to_virtio_gpu_obj(gobj);
*offset_p = virtio_gpu_object_mmap_offset(obj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index b94bd54..461f81a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -86,7 +86,7 @@ static void virtio_gpu_unref_list(struct list_head *head)
bo = buf->bo;
qobj = container_of(bo, struct virtio_gpu_object, tbo);
 
-   drm_gem_object_unreference_unlocked(&qobj->gem_base);
+   drm_gem_object_put_unlocked(&qobj->gem_base);
}
 }
 
@@ -261,7 +261,7 @@ static int virtio_gpu_resource_create_ioctl(struct 
drm_device *dev, void *data,
ret = virtio_gpu_object_attach(vgdev, qobj, res_id, NULL);
} else {
/* use a gem reference since unref list undoes them */
-   drm_gem_object_reference(&qobj->gem_base);
+   drm_gem_object_get(&qobj->gem_base);
mainbuf.bo = &qobj->tbo;
list_add(&mainbuf.head, &validate_list);
 
@@ -304,7 +304,7 @@ static int virtio_gpu_resource_create_ioctl(struct 
drm_device *dev, void *data,
}
return ret;
}
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
rc->res_handle = res_id; /* similiar to a VM address */
rc->bo_handle = handle;
@@ -341,7 +341,7 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device 
*dev, void *data,
 
ri->size = qobj->gem_base.size;
ri->res_handle = qobj->hw_res_handle;
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
@@ -389,7 +389,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct 
drm_device *dev,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -439,7 +439,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct 
drm_device *dev, void *data,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -462,7 +462,7 @@ static int virtio_gpu_wait_ioctl(struct drm_device *dev, 
void *data,
nowait = true;
ret = virtio_gpu_object_wait(qobj, nowait);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/l

Re: [Intel-gfx] [PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Joe Kniss via Virtualization
I didn't mean to add libdrm, sorry, there is a separate change for that.
I'll double check and test the drivers that don't implement the virtual.

Thanks for the quick reply!

-j

On Tue, Aug 8, 2017 at 4:50 PM, Dave Airlie  wrote:

> On 9 August 2017 at 09:42, Joe Kniss  wrote:
> > Because all drivers currently use gem objects for framebuffer planes,
> > the virtual create_handle() is not required.  This change adds a
> > struct drm_gem_object *gems[4] field to drm_framebuffer and removes
> > create_handle() function pointer from drm_framebuffer_funcs.  The
> > corresponding *_create_handle() function is removed from each driver.
> >
> > In many cases this change eliminates a struct *_framebuffer object,
> > as the only need for the derived struct is the addition of the gem
> > object pointer.
>
> Why the libdrm in the tag? this isn't for libdrm.
>
> This will break drivers that don't current implement the virtual at all.
>
> I think vwmgfx.
>
> The current code checks if the virtual is there before callng it, this code
> just calls the gem code always.
>
> Dave.
>



-- 
Dr. Joe Michael Kniss |  Google ChromeOS |  d...@google.com   |
1-801-898-7977
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Sean Paul
On Tue, Aug 08, 2017 at 04:42:37PM -0700, Joe Kniss wrote:
> Because all drivers currently use gem objects for framebuffer planes,
> the virtual create_handle() is not required.  This change adds a
> struct drm_gem_object *gems[4] field to drm_framebuffer and removes
> create_handle() function pointer from drm_framebuffer_funcs.  The
> corresponding *_create_handle() function is removed from each driver.
> 
> In many cases this change eliminates a struct *_framebuffer object,
> as the only need for the derived struct is the addition of the gem
> object pointer.

Hi Joe,
Thank you for the patch.

I think this would be easier to review if it were in 3 pieces:
1/3- add gem_objs to fb
2/3- driver conversion to gem_objs
3/3- remove create_handle()
> 
> TESTED: compiled: allyesconfig ARCH=x86,arm platforms:i915, rockchip

Aside from Dave's comment about vmwgfx, I'm also getting link errors:
ERROR: "mtk_fb_get_gem_obj" [drivers/gpu/drm/mediatek/mediatek-drm.ko] 
undefined!

Consider using the drm-misc configs located here for your compile tests:
https://cgit.freedesktop.org/drm/drm-tip/tree/?h=rerere-cache

Sean
> 
> Signed-off-by: Joe Kniss 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |  6 +--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c  | 50 +++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   | 20 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |  8 +--
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   | 19 +++
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   | 19 +++
>  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c| 19 +++
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c| 19 +++
>  drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  6 +--
>  drivers/gpu/drm/armada/armada_crtc.c |  2 +-
>  drivers/gpu/drm/armada/armada_fb.c   | 13 ++---
>  drivers/gpu/drm/armada/armada_fb.h   |  2 -
>  drivers/gpu/drm/drm_fb_cma_helper.c  | 78 
> ++--
>  drivers/gpu/drm/drm_framebuffer.c| 27 +-
>  drivers/gpu/drm/exynos/exynos_drm_fb.c   | 61 +++---
>  drivers/gpu/drm/gma500/accel_2d.c|  2 +-
>  drivers/gpu/drm/gma500/framebuffer.c | 40 +++---
>  drivers/gpu/drm/gma500/framebuffer.h |  3 +-
>  drivers/gpu/drm/gma500/gma_display.c |  8 +--
>  drivers/gpu/drm/gma500/mdfld_intel_display.c |  2 +-
>  drivers/gpu/drm/gma500/oaktrail_crtc.c   |  2 +-
>  drivers/gpu/drm/i915/i915_debugfs.c  |  4 +-
>  drivers/gpu/drm/i915/intel_display.c | 47 ++---
>  drivers/gpu/drm/i915/intel_drv.h |  3 +-
>  drivers/gpu/drm/i915/intel_fbdev.c   | 10 ++--
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c| 66 ++-
>  drivers/gpu/drm/msm/msm_fb.c | 41 ---
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c  | 10 ++--
>  drivers/gpu/drm/nouveau/dispnv04/overlay.c   | 19 +++
>  drivers/gpu/drm/nouveau/nouveau_display.c| 45 +++-
>  drivers/gpu/drm/nouveau/nouveau_display.h|  1 -
>  drivers/gpu/drm/nouveau/nouveau_fbcon.c  | 31 ++-
>  drivers/gpu/drm/nouveau/nv50_display.c   | 22 
>  drivers/gpu/drm/omapdrm/omap_fb.c| 54 ---
>  drivers/gpu/drm/qxl/qxl_display.c| 73 --
>  drivers/gpu/drm/qxl/qxl_draw.c   |  6 +--
>  drivers/gpu/drm/qxl/qxl_drv.h| 12 ++---
>  drivers/gpu/drm/qxl/qxl_fb.c | 24 -
>  drivers/gpu/drm/radeon/atombios_crtc.c   | 22 +++-
>  drivers/gpu/drm/radeon/radeon_device.c   |  6 +--
>  drivers/gpu/drm/radeon/radeon_display.c  | 50 +++---
>  drivers/gpu/drm/radeon/radeon_fb.c   | 20 +++
>  drivers/gpu/drm/radeon/radeon_legacy_crtc.c  | 16 +++---
>  drivers/gpu/drm/radeon/radeon_mode.h |  8 +--
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c   | 65 ---
>  drivers/gpu/drm/tegra/drm.h  |  8 +--
>  drivers/gpu/drm/tegra/fb.c   | 64 +++
>  drivers/gpu/drm/tinydrm/mipi-dbi.c   |  1 -
>  drivers/gpu/drm/tinydrm/repaper.c|  1 -
>  include/drm/drm_framebuffer.h| 26 ++
>  50 files changed, 420 insertions(+), 741 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 6279956e92a4..6d7995c1a8f9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2421,7 +2421,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
> suspend, bool fbcon)
>   /* unpin the front buffers and cursors */
>   list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> - struct amdgpu_framebuffer *rfb = 
> to_amdgpu_framebuffer(crtc->primary->fb);
> +

[PATCH v2 19/29] drm/qxl: switch to drm_*_get(), drm_*_put() helpers

2017-10-26 Thread Cihangir Akturk
Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference()
and drm_*_unreference() helpers.

drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() and should not be
used by new code. So convert all users of compatibility functions to
use the new APIs.

Generated by: scripts/coccinelle/api/drm-get-put.cocci

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/qxl/qxl_display.c | 4 ++--
 drivers/gpu/drm/qxl/qxl_dumb.c| 2 +-
 drivers/gpu/drm/qxl/qxl_fb.c  | 6 +++---
 drivers/gpu/drm/qxl/qxl_gem.c | 2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c   | 4 ++--
 drivers/gpu/drm/qxl/qxl_object.c  | 6 +++---
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 03fe182..7aa5097 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -306,7 +306,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer 
*fb)
 {
struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(qxl_fb->obj);
+   drm_gem_object_put_unlocked(qxl_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(qxl_fb);
 }
@@ -1109,7 +1109,7 @@ qxl_user_framebuffer_create(struct drm_device *dev,
ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj, &qxl_fb_funcs);
if (ret) {
kfree(qxl_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 5e65d5d..a0c9e73 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -81,6 +81,6 @@ int qxl_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
qobj = gem_to_qxl_bo(gobj);
*offset_p = qxl_bo_mmap_offset(qobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 573e7e9..47a25b0 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -95,7 +95,7 @@ static void qxlfb_destroy_pinned_object(struct drm_gem_object 
*gobj)
qxl_bo_kunmap(qbo);
qxl_bo_unpin(qbo);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
 }
 
 int qxl_get_handle_for_primary_fb(struct qxl_device *qdev,
@@ -320,11 +320,11 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
qxl_bo_unpin(qbo);
}
if (fb && ret) {
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
drm_framebuffer_cleanup(fb);
kfree(fb);
}
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index 85f5467..f5c1e78 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -98,7 +98,7 @@ int qxl_gem_object_create_with_handle(struct qxl_device *qdev,
return r;
/* drop reference from allocate - handle holds it now */
*qobj = gem_to_qxl_bo(gobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 0b82a87..dfefd45 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -121,7 +121,7 @@ static int qxlhw_handle_to_bo(struct drm_file *file_priv, 
uint64_t handle,
qobj = gem_to_qxl_bo(gobj);
 
ret = qxl_release_list_add(release, qobj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -342,7 +342,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, 
void *data,
qxl_bo_unreserve(qobj);
 
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 9a7eef7..cdf1455 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -211,13 +211,13 @@ void qxl_bo_unref(struct qxl_bo **bo)
if ((*bo) == NULL)
return;
 
-   drm_gem_object_unreference_unlocked(&(*bo)->gem_base);
+   drm_gem_object_put_unlocked(&(*bo)->gem_base);
*bo = NULL;
 }
 
 struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo)
 {
-   drm_gem_object_reference(&bo->gem_base);
+   drm_gem_object_get(&bo->gem_base);
return bo;
 }
 
@@ -316,7 +316,7 @@ void qxl_bo_force_delete(struct qxl_device *qdev)
list_del_init(&bo->list);

Re: [PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Joe Kniss via Virtualization
On Wed, Aug 9, 2017 at 12:14 PM, Noralf Trønnes  wrote:
>
> Den 09.08.2017 01.42, skrev Joe Kniss:
>>
>> Because all drivers currently use gem objects for framebuffer planes,
>> the virtual create_handle() is not required.  This change adds a
>> struct drm_gem_object *gems[4] field to drm_framebuffer and removes
>> create_handle() function pointer from drm_framebuffer_funcs.  The
>> corresponding *_create_handle() function is removed from each driver.
>>
>> In many cases this change eliminates a struct *_framebuffer object,
>> as the only need for the derived struct is the addition of the gem
>> object pointer.
>>
>> TESTED: compiled: allyesconfig ARCH=x86,arm platforms:i915, rockchip
>>
>> Signed-off-by: Joe Kniss 
>> ---
>
>
> Hi Joe,
>
> I'm also looking into adding gem objs to drm_framebuffer in this patch:
> [PATCH v2 01/22] drm: Add GEM backed framebuffer library
> https://lists.freedesktop.org/archives/dri-devel/2017-August/149782.html
>

Great.  There's only minimal overlap here.  I'll rebase this change on yours
once it's in.

> [...]
>
>> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
>> b/drivers/gpu/drm/drm_fb_cma_helper.c
>> index ade319d10e70..f5f011b910b1 100644
>> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
>> @@ -31,14 +31,9 @@
>> #define DEFAULT_FBDEFIO_DELAY_MS 50
>>   -struct drm_fb_cma {
>> -   struct drm_framebuffer  fb;
>> -   struct drm_gem_cma_object   *obj[4];
>> -};
>> -
>>   struct drm_fbdev_cma {
>> struct drm_fb_helperfb_helper;
>> -   struct drm_fb_cma   *fb;
>> +   struct drm_framebuffer  *fb;
>
>
> This fb pointer isn't necessary, since fb_helper already has one.
>

I'll remove it... but I am sure when I look deeper there will be more
of these in the various drivers too.

> Noralf.
>
>

-joe
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH v2 06/29] drm/bochs: switch to drm_*_get(), drm_*_put() helpers

2017-10-26 Thread Cihangir Akturk
Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference()
and drm_*_unreference() helpers.

drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() and should not be
used by new code. So convert all users of compatibility functions to
use the new APIs.

Generated by: scripts/coccinelle/api/drm-get-put.cocci

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c| 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c 
b/drivers/gpu/drm/bochs/bochs_fbdev.c
index c38deff..502f9d9 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -145,7 +145,7 @@ static int bochs_fbdev_destroy(struct bochs_device *bochs)
drm_fb_helper_unregister_fbi(&bochs->fb.helper);
 
if (gfb->obj) {
-   drm_gem_object_unreference_unlocked(gfb->obj);
+   drm_gem_object_put_unlocked(gfb->obj);
gfb->obj = NULL;
}
 
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index c4cadb6..881b784 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -417,7 +417,7 @@ int bochs_dumb_create(struct drm_file *file, struct 
drm_device *dev,
return ret;
 
ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -457,7 +457,7 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct 
drm_device *dev,
bo = gem_to_bochs_bo(obj);
*offset = bochs_bo_mmap_offset(bo);
 
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return 0;
 }
 
@@ -467,7 +467,7 @@ static void bochs_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 {
struct bochs_framebuffer *bochs_fb = to_bochs_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(bochs_fb->obj);
+   drm_gem_object_put_unlocked(bochs_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
@@ -518,13 +518,13 @@ bochs_user_framebuffer_create(struct drm_device *dev,
 
bochs_fb = kzalloc(sizeof(*bochs_fb), GFP_KERNEL);
if (!bochs_fb) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM);
}
 
ret = bochs_framebuffer_init(dev, bochs_fb, mode_cmd, obj);
if (ret) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
kfree(bochs_fb);
return ERR_PTR(ret);
}
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2 00/29] DRM API Conversions

2017-10-26 Thread Cihangir Akturk
Changes since v1:

- This time patches were generated with coccinelle instead of my own
  script, as suggested by Daniel Vetter.
- Fixed the typo in commit messages. s/adn/and

Note: I've included r-b, a-b tags, as these patches are identical to v1
except for the file: drivers/gpu/drm/i915/i915_gem_object.h

This patch set replaces the occurrences of drm_*_reference() and
drm_*_unreference() with the new drm_*_get() and drm_*_put() functions.
All patches in the series do the same thing, converting to the new APIs.
I created patches per DRM driver as suggested by Daniel Vetter.

This patch set was generated by scripts/coccinelle/api/drm-get-put.cocci

Previous thread can be reached at:
https://marc.info/?l=dri-devel&m=150178288816047

Background:

In the kernel, reference counting APIs use *_get(), *_put() style naming
to reference-count the objects. But DRM subsystem uses a different
naming for them such as *_reference(), *_unreference() which is
inconsistent with the other reference counting APIs in the kernel. To
solve this consistency issue, Thierry Reding introduced a couple of
functions and compatibility aliases in the following commits for them.

commit 020a218f95bd3ceff7dd1022ff7ebc0497bc7bf9
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:38 2017 +0100

drm: Introduce drm_mode_object_{get,put}()

commit ad09360750afa18a0a0ce0253d6ea6033abc22e7
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:39 2017 +0100

drm: Introduce drm_connector_{get,put}()

commit a4a69da06bc11a937a6e417938b1bb698ee1fa46
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:40 2017 +0100

drm: Introduce drm_framebuffer_{get,put}()

commit e6b62714e87c8811d5564b6a0738dcde63a51774
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:41 2017 +0100

drm: Introduce drm_gem_object_{get,put}()

commit 6472e5090be7c78749a3c279b4faae87ab835c40
Author: Thierry Reding 
Date:   Tue Feb 28 15:46:42 2017 +0100

drm: Introduce drm_property_blob_{get,put}()

Cihangir Akturk (29):
  drm/amdgpu: switch to drm_*_get(), drm_*_put() helpers
  drm: mali-dp: switch to drm_*_get(), drm_*_put() helpers
  drm/armada: switch to drm_*_get(), drm_*_put() helpers
  drm/ast: switch to drm_*_get(), drm_*_put() helpers
  drm/atmel-hlcdc: switch to drm_*_get(), drm_*_put() helpers
  drm/bochs: switch to drm_*_get(), drm_*_put() helpers
  drm/cirrus: switch to drm_*_get(), drm_*_put() helpers
  drm/etnaviv: switch to drm_*_get(), drm_*_put() helpers
  drm/exynos: switch to drm_*_get(), drm_*_put() helpers
  drm/gma500: switch to drm_*_get(), drm_*_put() helpers
  drm/hisilicon: switch to drm_*_get(), drm_*_put() helpers
  drm/i915: switch to drm_*_get(), drm_*_put() helpers
  drm/imx: switch to drm_*_get(), drm_*_put() helpers
  drm/mediatek: switch to drm_*_get(), drm_*_put() helpers
  drm/mgag200: switch to drm_*_get(), drm_*_put() helpers
  drm/msm: switch to drm_*_get(), drm_*_put() helpers
  drm/nouveau: switch to drm_*_get(), drm_*_put() helpers
  drm/omap: switch to drm_*_get(), drm_*_put() helpers
  drm/qxl: switch to drm_*_get(), drm_*_put() helpers
  drm/radeon: switch to drm_*_get(), drm_*_put() helpers
  drm/rockchip: switch to drm_*_get(), drm_*_put() helpers
  drm/tegra: switch to drm_*_get(), drm_*_put() helpers
  drm/tilcdc: switch to drm_*_get(), drm_*_put() helpers
  drm/udl: switch to drm_*_get(), drm_*_put() helpers
  drm/vc4: switch to drm_*_get(), drm_*_put() helpers
  drm/vgem: switch to drm_*_get(), drm_*_put() helpers
  drm/virtio: switch to drm_*_get(), drm_*_put() helpers
  drm/vmwgfx: switch to drm_*_get(), drm_*_put() helpers
  staging: vboxvideo: switch to drm_*_get(), drm_*_put() helpers

 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c|  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c   | 22 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  6 ++---
 drivers/gpu/drm/arm/malidp_planes.c   |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c  | 22 -
 drivers/gpu/drm/armada/armada_drv.c   |  2 +-
 drivers/gpu/drm/armada/armada_fb.c|  8 +++---
 drivers/gpu/drm/armada/armada_fbdev.c |  6 ++---
 drivers/gpu/drm/armada/armada_gem.c   | 14 +--
 drivers/gpu/drm/armada/armada_overlay.c   |  4 +--
 drivers/gpu/drm/ast/ast_fb.c  |  2 +-
 drivers/gpu/drm/ast/ast_main.c| 10 
 drivers/gpu/drm/ast/ast_mode.c|  6 ++---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c   |  8 +++---
 drivers/gpu/drm/bochs/bochs_fbdev.c   |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c  

[PATCH v2 07/29] drm/cirrus: switch to drm_*_get(), drm_*_put() helpers

2017-10-26 Thread Cihangir Akturk
Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference()
and drm_*_unreference() helpers.

drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() and should not be
used by new code. So convert all users of compatibility functions to
use the new APIs.

Generated by: scripts/coccinelle/api/drm-get-put.cocci

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  2 +-
 drivers/gpu/drm/cirrus/cirrus_main.c  | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..c0b9a29 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -252,7 +252,7 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
drm_fb_helper_unregister_fbi(&gfbdev->helper);
 
if (gfb->obj) {
-   drm_gem_object_unreference_unlocked(gfb->obj);
+   drm_gem_object_put_unlocked(gfb->obj);
gfb->obj = NULL;
}
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index e7fc95f..b5f5285 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -18,7 +18,7 @@ static void cirrus_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 {
struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(cirrus_fb->obj);
+   drm_gem_object_put_unlocked(cirrus_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
@@ -67,13 +67,13 @@ cirrus_user_framebuffer_create(struct drm_device *dev,
 
cirrus_fb = kzalloc(sizeof(*cirrus_fb), GFP_KERNEL);
if (!cirrus_fb) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM);
}
 
ret = cirrus_framebuffer_init(dev, cirrus_fb, mode_cmd, obj);
if (ret) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
kfree(cirrus_fb);
return ERR_PTR(ret);
}
@@ -261,7 +261,7 @@ int cirrus_dumb_create(struct drm_file *file,
return ret;
 
ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -310,7 +310,7 @@ cirrus_dumb_mmap_offset(struct drm_file *file,
bo = gem_to_cirrus_bo(obj);
*offset = cirrus_bo_mmap_offset(bo);
 
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
return 0;
 }
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Noralf Trønnes


Den 09.08.2017 01.42, skrev Joe Kniss:

Because all drivers currently use gem objects for framebuffer planes,
the virtual create_handle() is not required.  This change adds a
struct drm_gem_object *gems[4] field to drm_framebuffer and removes
create_handle() function pointer from drm_framebuffer_funcs.  The
corresponding *_create_handle() function is removed from each driver.

In many cases this change eliminates a struct *_framebuffer object,
as the only need for the derived struct is the addition of the gem
object pointer.

TESTED: compiled: allyesconfig ARCH=x86,arm platforms:i915, rockchip

Signed-off-by: Joe Kniss 
---


Hi Joe,

I'm also looking into adding gem objs to drm_framebuffer in this patch:
[PATCH v2 01/22] drm: Add GEM backed framebuffer library
https://lists.freedesktop.org/archives/dri-devel/2017-August/149782.html

[...]


diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index ade319d10e70..f5f011b910b1 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -31,14 +31,9 @@
  
  #define DEFAULT_FBDEFIO_DELAY_MS 50
  
-struct drm_fb_cma {

-   struct drm_framebuffer  fb;
-   struct drm_gem_cma_object   *obj[4];
-};
-
  struct drm_fbdev_cma {
struct drm_fb_helperfb_helper;
-   struct drm_fb_cma   *fb;
+   struct drm_framebuffer  *fb;


This fb pointer isn't necessary, since fb_helper already has one.

Noralf.


const struct drm_framebuffer_funcs *fb_funcs;
  };
  
@@ -72,7 +67,6 @@ struct drm_fbdev_cma {

   *
   * static struct drm_framebuffer_funcs driver_fb_funcs = {
   * .destroy   = drm_fb_cma_destroy,
- * .create_handle = drm_fb_cma_create_handle,
   * .dirty = driver_fb_dirty,
   * };
   *
@@ -90,67 +84,50 @@ static inline struct drm_fbdev_cma *to_fbdev_cma(struct 
drm_fb_helper *helper)
return container_of(helper, struct drm_fbdev_cma, fb_helper);
  }
  
-static inline struct drm_fb_cma *to_fb_cma(struct drm_framebuffer *fb)

-{
-   return container_of(fb, struct drm_fb_cma, fb);
-}
-
  void drm_fb_cma_destroy(struct drm_framebuffer *fb)
  {
-   struct drm_fb_cma *fb_cma = to_fb_cma(fb);
int i;
  
  	for (i = 0; i < 4; i++) {

-   if (fb_cma->obj[i])
-   drm_gem_object_put_unlocked(&fb_cma->obj[i]->base);
+   if (fb->gem_objs[i])
+   drm_gem_object_put_unlocked(fb->gem_objs[i]);
}
  
  	drm_framebuffer_cleanup(fb);

-   kfree(fb_cma);
+   kfree(fb);
  }
  EXPORT_SYMBOL(drm_fb_cma_destroy);
  
-int drm_fb_cma_create_handle(struct drm_framebuffer *fb,

-   struct drm_file *file_priv, unsigned int *handle)
-{
-   struct drm_fb_cma *fb_cma = to_fb_cma(fb);
-
-   return drm_gem_handle_create(file_priv,
-   &fb_cma->obj[0]->base, handle);
-}
-EXPORT_SYMBOL(drm_fb_cma_create_handle);
-
  static struct drm_framebuffer_funcs drm_fb_cma_funcs = {
.destroy= drm_fb_cma_destroy,
-   .create_handle  = drm_fb_cma_create_handle,
  };
  
-static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev,

+static struct drm_framebuffer *drm_fb_cma_alloc(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_gem_cma_object **obj,
unsigned int num_planes, const struct drm_framebuffer_funcs *funcs)
  {
-   struct drm_fb_cma *fb_cma;
+   struct drm_framebuffer *fb;
int ret;
int i;
  
-	fb_cma = kzalloc(sizeof(*fb_cma), GFP_KERNEL);

-   if (!fb_cma)
+   fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+   if (!fb)
return ERR_PTR(-ENOMEM);
  
-	drm_helper_mode_fill_fb_struct(dev, &fb_cma->fb, mode_cmd);

+   drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
  
  	for (i = 0; i < num_planes; i++)

-   fb_cma->obj[i] = obj[i];
+   fb->gem_objs[i] = &obj[i]->base;
  
-	ret = drm_framebuffer_init(dev, &fb_cma->fb, funcs);

+   ret = drm_framebuffer_init(dev, fb, funcs);
if (ret) {
dev_err(dev->dev, "Failed to initialize framebuffer: %d\n", 
ret);
-   kfree(fb_cma);
+   kfree(fb);
return ERR_PTR(ret);
}
  
-	return fb_cma;

+   return fb;
  }
  
  /**

@@ -171,7 +148,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct 
drm_device *dev,
const struct drm_framebuffer_funcs *funcs)
  {
const struct drm_format_info *info;
-   struct drm_fb_cma *fb_cma;
+   struct drm_framebuffer *fb;
struct drm_gem_cma_object *objs[4];
struct drm_gem_object *obj;
int ret;
@@ -205,13 +182,13 @@ struct drm_framebuffer 
*drm_fb_cma_create_with_funcs(struct drm_device *dev,
objs[i] = to_drm_gem_cma_obj(obj);
}
  
-	fb_cma = drm_fb_cma_alloc(dev, mode_cmd, objs, i, funcs);

-   if (IS_ERR(fb_cma)) {
-   ret = PTR_ERR(f

Re: [PATCH libdrm] drm: Remove create_handle() drm_framebuffer "virtual".

2017-10-26 Thread Joe Kniss via Virtualization
On Wed, Aug 9, 2017 at 4:13 PM, Joe Kniss  wrote:
> On Wed, Aug 9, 2017 at 12:14 PM, Noralf Trønnes  wrote:
>>
>> Den 09.08.2017 01.42, skrev Joe Kniss:
>>>
>>> Because all drivers currently use gem objects for framebuffer planes,
>>> the virtual create_handle() is not required.  This change adds a
>>> struct drm_gem_object *gems[4] field to drm_framebuffer and removes
>>> create_handle() function pointer from drm_framebuffer_funcs.  The
>>> corresponding *_create_handle() function is removed from each driver.
>>>
>>> In many cases this change eliminates a struct *_framebuffer object,
>>> as the only need for the derived struct is the addition of the gem
>>> object pointer.
>>>
>>> TESTED: compiled: allyesconfig ARCH=x86,arm platforms:i915, rockchip
>>>
>>> Signed-off-by: Joe Kniss 
>>> ---
>>
>>
>> Hi Joe,
>>
>> I'm also looking into adding gem objs to drm_framebuffer in this patch:
>> [PATCH v2 01/22] drm: Add GEM backed framebuffer library
>> https://lists.freedesktop.org/archives/dri-devel/2017-August/149782.html
>>
>
> Great.  There's only minimal overlap here.  I'll rebase this change on yours
> once it's in.
>
>> [...]
>>
>>> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
>>> b/drivers/gpu/drm/drm_fb_cma_helper.c
>>> index ade319d10e70..f5f011b910b1 100644
>>> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
>>> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
>>> @@ -31,14 +31,9 @@
>>> #define DEFAULT_FBDEFIO_DELAY_MS 50
>>>   -struct drm_fb_cma {
>>> -   struct drm_framebuffer  fb;
>>> -   struct drm_gem_cma_object   *obj[4];
>>> -};
>>> -
>>>   struct drm_fbdev_cma {
>>> struct drm_fb_helperfb_helper;
>>> -   struct drm_fb_cma   *fb;
>>> +   struct drm_framebuffer  *fb;
>>
>>
>> This fb pointer isn't necessary, since fb_helper already has one.
>>

So, looking deeper into this, it seems that the struct
drm_framebuffer_funcs *fb_funcs is also redundant here?  In which case
this whole struct can go...

>
> I'll remove it... but I am sure when I look deeper there will be more
> of these in the various drivers too.
>
>> Noralf.
>>
>>
>
> -joe
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH v3 05/28] drm/bochs: switch to drm_*_get(), drm_*_put() helpers

2017-10-26 Thread Cihangir Akturk
Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference()
and drm_*_unreference() helpers.

drm_*_reference() and drm_*_unreference() functions are just
compatibility alias for drm_*_get() and drm_*_put() and should not be
used by new code. So convert all users of compatibility functions to
use the new APIs.

Generated by: scripts/coccinelle/api/drm-get-put.cocci

Signed-off-by: Cihangir Akturk 
---
 drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c| 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c 
b/drivers/gpu/drm/bochs/bochs_fbdev.c
index 14eb8d0..6f0cf36 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -144,7 +144,7 @@ static int bochs_fbdev_destroy(struct bochs_device *bochs)
drm_fb_helper_unregister_fbi(&bochs->fb.helper);
 
if (gfb->obj) {
-   drm_gem_object_unreference_unlocked(gfb->obj);
+   drm_gem_object_put_unlocked(gfb->obj);
gfb->obj = NULL;
}
 
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index c4cadb6..881b784 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -417,7 +417,7 @@ int bochs_dumb_create(struct drm_file *file, struct 
drm_device *dev,
return ret;
 
ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
if (ret)
return ret;
 
@@ -457,7 +457,7 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct 
drm_device *dev,
bo = gem_to_bochs_bo(obj);
*offset = bochs_bo_mmap_offset(bo);
 
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return 0;
 }
 
@@ -467,7 +467,7 @@ static void bochs_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 {
struct bochs_framebuffer *bochs_fb = to_bochs_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(bochs_fb->obj);
+   drm_gem_object_put_unlocked(bochs_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
@@ -518,13 +518,13 @@ bochs_user_framebuffer_create(struct drm_device *dev,
 
bochs_fb = kzalloc(sizeof(*bochs_fb), GFP_KERNEL);
if (!bochs_fb) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM);
}
 
ret = bochs_framebuffer_init(dev, bochs_fb, mode_cmd, obj);
if (ret) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
kfree(bochs_fb);
return ERR_PTR(ret);
}
-- 
2.7.4

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v2 0/2] virtio_scsi: Set can_queue based on size of virtqueue.

2017-10-26 Thread Martin K. Petersen

Richard,

> v1 was here:
>
>   https://lkml.org/lkml/2017/8/10/689
>
> v1 -> v2:
>
>   Remove .can_queue field from the templates.

Applied to 4.14/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


  1   2   3   >