Re: [PATCH 0/3] staging: rtl8723bs: Replace sprintf with scnprintf

2021-03-01 Thread Hans de Goede
Hi,

On 3/1/21 2:12 PM, Candy Febriyanto wrote:
> This patchset replaces most calls to sprintf with scnprintf, thereby
> preventing potential buffer overflows. The rest I left alone because
> they write to a buffer passed by a caller that doesn't pass its size
> alongside it.
> 
> Candy Febriyanto (3):
>   staging: rtl8723bs: core: Replace sprintf with scnprintf
>   staging: rtl8723bs: hal: Replace sprintf with scnprintf
>   staging: rtl8723bs: os_dep: Replace sprintf with scnprintf
> 
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  3 +-
>  drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  |  4 +-
>  drivers/staging/rtl8723bs/hal/hal_com.c   | 45 ++-
>  .../staging/rtl8723bs/os_dep/ioctl_linux.c| 20 +
>  drivers/staging/rtl8723bs/os_dep/mlme_linux.c |  6 +--
>  5 files changed, 41 insertions(+), 37 deletions(-)

Thanks, the entire series looks good to me, for the series:

Reviewed-by: Hans de Goede 

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1 0/9] x86/platform: Remove SFI framework and users

2021-02-11 Thread Hans de Goede
arch/x86/platform/intel-mid/device_libs/Makefile
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
>>  delete mode 100644 arch/x86/platform/intel-mid/device_libs/platform_bma023.c
>>  delete mode 100644 arch/x86/platform/intel-mid/device_libs/platform_bt.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
>>  delete mode 100644 arch/x86/platform/intel-mid/device_libs/platform_lis331.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_max7315.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_mrfld_pinctrl.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_mrfld_sd.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_pcal9555a.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
>>  delete mode 100644 
>> arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
>>  delete mode 100644 arch/x86/platform/intel-mid/sfi.c
>>  delete mode 100644 arch/x86/platform/sfi/Makefile
>>  delete mode 100644 arch/x86/platform/sfi/sfi.c
>>  delete mode 100644 drivers/cpufreq/sfi-cpufreq.c
>>  delete mode 100644 drivers/sfi/Kconfig
>>  delete mode 100644 drivers/sfi/Makefile
>>  delete mode 100644 drivers/sfi/sfi_acpi.c
>>  delete mode 100644 drivers/sfi/sfi_core.c
>>  delete mode 100644 drivers/sfi/sfi_core.h
>>  delete mode 100644 include/linux/sfi.h
>>  delete mode 100644 include/linux/sfi_acpi.h
>>
>> --
> 
> All of this looks good to me, so I'm going to queue it up for 5.12
> unless there are objections against doing that.

That is fine by me (for the drivers/platform/x86 bits) :

Acked-by: Hans de Goede 

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: Add 024c:0627 to the list of SDIO device-ids

2020-10-29 Thread Hans de Goede
Hi,

On 10/29/20 2:52 PM, Brian O'Keefe wrote:
> Add 024c:0627 to the list of SDIO device-ids, based on hardware found in
> the wild. This hardware exists on at least some Acer SW1-011 tablets.
> 
> Signed-off-by: Brian O'Keefe 

Patch looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans

> ---
>  drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> index 5b1392deb0a7..7256d55fcc1b 100644
> --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> @@ -21,6 +21,7 @@ static const struct sdio_device_id sdio_ids[] =
> { SDIO_DEVICE(0x024c, 0x0525), },
> { SDIO_DEVICE(0x024c, 0x0623), },
> { SDIO_DEVICE(0x024c, 0x0626), },
> +   { SDIO_DEVICE(0x024c, 0x0627), },
> { SDIO_DEVICE(0x024c, 0xb723), },
> { /* end: all zeroes */ },
>  };
> --
> 2.25.1
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC] treewide: cleanup unreachable breaks

2020-10-18 Thread Hans de Goede
Hi Tom,

Quick self intro: I have take over drivers/platform/x86
maintainership from Andy.

On 10/17/20 6:09 PM, t...@redhat.com wrote:
> From: Tom Rix 
> 
> This is a upcoming change to clean up a new warning treewide.
> I am wondering if the change could be one mega patch (see below) or
> normal patch per file about 100 patches or somewhere half way by collecting
> early acks.
> 
> clang has a number of useful, new warnings see
> https://clang.llvm.org/docs/DiagnosticsReference.html
> 
> This change cleans up -Wunreachable-code-break
> https://clang.llvm.org/docs/DiagnosticsReference.html#wunreachable-code-break
> for 266 of 485 warnings in this week's linux-next, allyesconfig on x86_64.
> 
> The method of fixing was to look for warnings where the preceding statement
> was a simple statement and by inspection made the subsequent break unneeded.
> In order of frequency these look like
> 
> return and break
> 
>   switch (c->x86_vendor) {
>   case X86_VENDOR_INTEL:
>   intel_p5_mcheck_init(c);
>   return 1;
> - break;
> 
> goto and break
> 
>   default:
>   operation = 0; /* make gcc happy */
>   goto fail_response;
> - break;
> 
> break and break
>   case COLOR_SPACE_SRGB:
>   /* by pass */
>   REG_SET(OUTPUT_CSC_CONTROL, 0,
>   OUTPUT_CSC_GRPH_MODE, 0);
>   break;
> - break;
> 
> The exception to the simple statement, is a switch case with a block
> and the end of block is a return
> 
>   struct obj_buffer *buff = r->ptr;
>   return scnprintf(str, PRIV_STR_SIZE,
>   "size=%u\naddr=0x%X\n", buff->size,
>   buff->addr);
>   }
> - break;
> 
> Not considered obvious and excluded, breaks after
> multi level switches
> complicated if-else if-else blocks
> panic() or similar calls
> 
> And there is an odd addition of a 'fallthrough' in drivers/tty/nozomi.c

As Greg already mentioned please split this out into per subsystem patches.

I would be happy to take all the changes to drivers/platform/x86
code upstream as a single patch for all the files there.

Regards,

Hans


> ---
> 
> diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
> index 1c08cb9eb9f6..16ce86aed8e2 100644
> --- a/arch/x86/kernel/cpu/mce/core.c
> +++ b/arch/x86/kernel/cpu/mce/core.c
> @@ -1809,15 +1809,13 @@ static int __mcheck_cpu_ancient_init(struct 
> cpuinfo_x86 *c)
>  
>   switch (c->x86_vendor) {
>   case X86_VENDOR_INTEL:
>   intel_p5_mcheck_init(c);
>   return 1;
> - break;
>   case X86_VENDOR_CENTAUR:
>   winchip_mcheck_init(c);
>   return 1;
> - break;
>   default:
>   return 0;
>   }
>  
>   return 0;
> diff --git a/arch/x86/kernel/cpu/microcode/amd.c 
> b/arch/x86/kernel/cpu/microcode/amd.c
> index 3f6b137ef4e6..3d4a48336084 100644
> --- a/arch/x86/kernel/cpu/microcode/amd.c
> +++ b/arch/x86/kernel/cpu/microcode/amd.c
> @@ -213,11 +213,10 @@ static unsigned int __verify_patch_size(u8 family, u32 
> sh_psize, size_t buf_size
>   max_size = F14H_MPB_MAX_SIZE;
>   break;
>   default:
>   WARN(1, "%s: WTF family: 0x%x\n", __func__, family);
>   return 0;
> - break;
>   }
>  
>   if (sh_psize > min_t(u32, buf_size, max_size))
>   return 0;
>  
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 838b719ec7ce..d5411a166685 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -102,11 +102,10 @@ acpi_extract_package(union acpi_object *package,
>   printk(KERN_WARNING PREFIX "Invalid package 
> element"
> " [%d]: got number, expecting"
> " [%c]\n",
> i, format_string[i]);
>   return AE_BAD_DATA;
> - break;
>   }
>   break;
>  
>   case ACPI_TYPE_STRING:
>   case ACPI_TYPE_BUFFER:
> @@ -127,11 +126,10 @@ acpi_extract_package(union acpi_object *package,
>   printk(KERN_WARNING PREFIX "Invalid package 
> element"
> " [%d] got string/buffer,"
> " expecting [%c]\n",
> i, format_string[i]);
>   return AE_BAD_DATA;
> - break;
>   }
>   break;
>   case ACPI_TYPE_LOCAL_REFERENCE:
>   switch (format_string[i]) {
>

Re: [PATCH] staging: rtl8723bs: fix copy of overlapping memory

2020-01-27 Thread Hans de Goede

HI,

On 26-01-2020 23:05, Colin King wrote:

From: Colin Ian King 

Currently the rtw_sprintf prints the contents of thread_name
onto thread_name and this can lead to a potential copy of a
string over itself. Avoid this by printing the literal string RTWHALXT
instread of the contents of thread_name.

Addresses-Coverity: ("copy of overlapping memory")
Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Signed-off-by: Colin Ian King 


Patch looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
  drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c 
b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index b44e902ed338..890e0ecbeb2e 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -476,14 +476,13 @@ int rtl8723bs_xmit_thread(void *context)
s32 ret;
struct adapter *padapter;
struct xmit_priv *pxmitpriv;
-   u8 thread_name[20] = "RTWHALXT";
-
+   u8 thread_name[20];
  
  	ret = _SUCCESS;

padapter = context;
pxmitpriv = &padapter->xmitpriv;
  
-	rtw_sprintf(thread_name, 20, "%s-"ADPT_FMT, thread_name, ADPT_ARG(padapter));

+   rtw_sprintf(thread_name, 20, "RTWHALXT-" ADPT_FMT, ADPT_ARG(padapter));
thread_enter(thread_name);
  
  	DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] vboxsf: move out of staging to fs/

2019-11-13 Thread Hans de Goede

Hi,

On 13-11-2019 00:12, Linus Torvalds wrote:

On Tue, Nov 12, 2019 at 2:54 PM Greg Kroah-Hartman
 wrote:


Christoph, this is what you mean, right?  If so, I'll send this to Linus
later this week, or he can grab it right from this patch :)


No.

I was unhappy about a staging driver being added in rc7, but I went
"whatever, it's Greg's garbage"

There is no way in hell I will take a new filesystem in rc8.

Would you take that into stable? No, you wouldn't. Then why is this
being upstreamed now.

Honestly, I think I'll just delete the whole thing, since it shouldn't
have gone in in the first place. This is not how we add new
filesystems.


I understand you being unhappy with this.

The problem is that Al Viro, after an initial review around v2 or v3 of
the patch, which I believe I have fully addressed, has been ignoring
this patch / new fs for over a year now. I've pinged him repeatedly
both via email and on irc, but with no luck.  I guess he simply is
too busy with other stuff.

I did ask other fs developers to review and have gotten reviews
from David Howell and Christoph Hellwig. I've addressed all their
review remarks and I've had reviews of the newer versions with
just a few nitpicks remaining. I've also addressed those nitpicks.
But I never got an Acked-by or Reviewed-by from either of them
on any of the newer versions.

I even talked to various people about this at plumbers, but
I did not get any traction there either.

On the advice of Christoph I've asked Andrew Morton to take this
directly under fs/ instead, twice. When this all went no where I
went the staging route, with the current result.

So for 5.5, and assuming I can get David's and/or Christoph's
Acked-by, is is ok if I send this directly to you?

Regards,

Hans

p.s.

Christoph, David, can I get your Acked-by for the latest
version of the patch (v17) ?

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: rtl8723bs: Drop ACPI device ids

2019-11-11 Thread Hans de Goede
The driver only binds by SDIO device-ids, all the ACPI device-id does
is causing the driver to load unnecessarily on devices where the DSDT
contains a bogus OBDA8723 device.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index c48d2df97285..859f4a0afb95 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -24,13 +24,7 @@ static const struct sdio_device_id sdio_ids[] =
{ SDIO_DEVICE(0x024c, 0xb723), },
{ /* end: all zeroes */ },
 };
-static const struct acpi_device_id acpi_ids[] = {
-   {"OBDA8723", 0x},
-   {}
-};
-
 MODULE_DEVICE_TABLE(sdio, sdio_ids);
-MODULE_DEVICE_TABLE(acpi, acpi_ids);
 
 static int rtw_drv_init(struct sdio_func *func, const struct sdio_device_id 
*id);
 static void rtw_dev_remove(struct sdio_func *func);
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: rtl8723bs: Add 024c:0525 to the list of SDIO device-ids

2019-11-11 Thread Hans de Goede
Add 024c:0525 to the list of SDIO device-ids, based on a patch found
in the Android X86 kernels. According to that patch this device id is
used on the Alcatel Plus 10 device.

Reported-and-tested-by: youling257 
Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 12f683e2e0e2..c48d2df97285 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -18,6 +18,7 @@
 static const struct sdio_device_id sdio_ids[] =
 {
{ SDIO_DEVICE(0x024c, 0x0523), },
+   { SDIO_DEVICE(0x024c, 0x0525), },
{ SDIO_DEVICE(0x024c, 0x0623), },
{ SDIO_DEVICE(0x024c, 0x0626), },
{ SDIO_DEVICE(0x024c, 0xb723), },
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH -next] staging: Fix error return code in vboxsf_fill_super()

2019-11-06 Thread Hans de Goede

Hi,

On 06-11-2019 12:59, Wei Yongjun wrote:

Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: df4028658f9d ("staging: Add VirtualBox guest shared folder (vboxsf) 
support")
Signed-off-by: Wei Yongjun 


Good catch, thank you:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
  drivers/staging/vboxsf/super.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vboxsf/super.c b/drivers/staging/vboxsf/super.c
index 3913ffafa83b..0bf4d724aefd 100644
--- a/drivers/staging/vboxsf/super.c
+++ b/drivers/staging/vboxsf/super.c
@@ -176,8 +176,10 @@ static int vboxsf_fill_super(struct super_block *sb, 
struct fs_context *fc)
/* Turn source into a shfl_string and map the folder */
size = strlen(fc->source) + 1;
folder_name = kmalloc(SHFLSTRING_HEADER_SIZE + size, GFP_KERNEL);
-   if (!folder_name)
+   if (!folder_name) {
+   err = -ENOMEM;
goto fail_free;
+   }
folder_name->size = size;
folder_name->length = size - 1;
strlcpy(folder_name->string.utf8, fc->source, size);





___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v17] staging: Add VirtualBox guest shared folder (vboxsf) support

2019-10-28 Thread Hans de Goede
VirtualBox hosts can share folders with guests, this commit adds a
VFS driver implementing the Linux-guest side of this, allowing folders
exported by the host to be mounted under Linux.

This driver depends on the guest <-> host IPC functions exported by
the vboxguest driver.

Signed-off-by: Hans de Goede 
---
Changes in v17:
- Submit upstream through drivers/staging as this is not getting any
  traction on the fsdevel list
- Add TODO file
- vboxsf_free_inode uses sbi->idr, call rcu_barrier from put_super to make
  sure all delayed rcu free inodes are flushed

Changes in v16:
- Make vboxsf_parse_monolithic() static, reported-by: kbuild test robot

Changes in v15:
- Rebase on top of 5.4-rc1

Changes in v14
- Add a commment explaining possible read cache strategies and which one
  has been chosen
- Change pagecache-invalidation on open (inode_revalidate) to use
  invalidate_inode_pages2() so that mmap-ed pages are dropped from
  the cache too
- Add a comment to vboxsf_file_release explaining why the
  filemap_write_and_wait() call is done there
- Some minor code tweaks

Changes in v13
- Add SPDX tag to Makefile, use foo-y := to set objectfile list
- Drop kerneldoc headers stating the obvious from vfs callbacks,
  to avoid them going stale
- Replace sf_ prefix of functions and data-types with vboxsf_
- Use more normal naming scheme for sbi and private inode data:
struct vboxsf_sbi *sbi = VBOXSF_SBI(inode->i_sb);
struct vboxsf_inode *sf_i = VBOXSF_I(inode);
- Refactor directory reading code
- Use goto based unwinding instead of nested if-s in a number of places
- Consolidate dir unlink and rmdir inode_operations into a single function
- Use the page-cache for regular reads/writes too
- Directly set super_operations.free_inode to what used to be our
  vboxsf_i_callback, instead of setting super_operations.destroy_inode
  to a function which just does: call_rcu(&inode->i_rcu, vboxsf_i_callback);
- Use spinlock_irqsafe for ino_idr_lock
  vboxsf_free_inode may be called from a RCU callback, and thus from
  softirq context, so we need to use spinlock_irqsafe vboxsf_new_inode.
  On alloc_inode failure vboxsf_free_inode may be called from process
  context, so it too needs to use spinlock_irqsafe.

Changes in v12:
- Move make_kuid / make_kgid calls to option parsing time and add
  uid_valid / gid_valid checks.
- In init_fs_context call current_uid_gid() to init uid and gid
- Validate dmode, fmode, dmask and fmask options during option parsing
- Use correct types for various mount option variables (kuid_t, kgid_t, umode_t)
- Some small coding-style tweaks

Changes in v11:
- Convert to the new Documentation/filesystems/mount_api.txt mount API
- Fixed all the function kerneldoc comments to have things in the proper order
- Change type of d_type variable passed as type to dir_emit from int to
  unsigned int
- Replaced the fake-ino overflow test with the one suggested by David Howells
- Fixed various coding style issues

See cover-letter for full changelog including older versions
---
 MAINTAINERS  |   6 +
 drivers/staging/Kconfig  |   2 +
 drivers/staging/Makefile |   1 +
 drivers/staging/vboxsf/Kconfig   |  10 +
 drivers/staging/vboxsf/Makefile  |   5 +
 drivers/staging/vboxsf/TODO  |   7 +
 drivers/staging/vboxsf/dir.c | 418 +++
 drivers/staging/vboxsf/file.c| 370 ++
 drivers/staging/vboxsf/shfl_hostintf.h   | 901 +++
 drivers/staging/vboxsf/super.c   | 499 +
 drivers/staging/vboxsf/utils.c   | 550 ++
 drivers/staging/vboxsf/vboxsf_wrappers.c | 371 ++
 drivers/staging/vboxsf/vfsmod.h  | 138 
 13 files changed, 3278 insertions(+)
 create mode 100644 drivers/staging/vboxsf/Kconfig
 create mode 100644 drivers/staging/vboxsf/Makefile
 create mode 100644 drivers/staging/vboxsf/TODO
 create mode 100644 drivers/staging/vboxsf/dir.c
 create mode 100644 drivers/staging/vboxsf/file.c
 create mode 100644 drivers/staging/vboxsf/shfl_hostintf.h
 create mode 100644 drivers/staging/vboxsf/super.c
 create mode 100644 drivers/staging/vboxsf/utils.c
 create mode 100644 drivers/staging/vboxsf/vboxsf_wrappers.c
 create mode 100644 drivers/staging/vboxsf/vfsmod.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bf03aa6f2856..9637a5385a05 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17362,6 +17362,12 @@ F: include/linux/vbox_utils.h
 F: include/uapi/linux/vbox*.h
 F: drivers/virt/vboxguest/
 
+VIRTUAL BOX SHARED FOLDER VFS DRIVER:
+M: Hans de Goede 
+L: linux-fsde...@vger.kernel.org
+S: Maintained
+F: drivers/staging/vboxsf/*
+
 VIRTUAL SERIO DEVICE DRIVER
 M: Stephen Chandler Paul 
 S: Maintained
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index a490141a0e88..98f1baf09e70 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -127,4 +127,6

[PATCH v17 0/1] staging: Add VirtualBox guest shared folder (vboxsf) support

2019-10-28 Thread Hans de Goede
Hi Greg,

As discussed previously can you please take vboxsf upstream through
drivers/staging?

It has seen many revisions on the fsdevel list, but it seems that the
fsdevel people are to busy to pick it up.

Previous versions of this patch have been reviewed by Al Viro, David Howells
and Christoph Hellwig (all in the Cc) and I believe that the current
version addresses all their review remarks.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: rtl8723bs: Remove rtw_merge_string() function

2019-10-09 Thread Hans de Goede
The phy_Config*WithParaFile() functions were the only user of this
function.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/include/osdep_service_linux.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h 
b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index c582ede1ac12..a2d9de866c4b 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -127,13 +127,6 @@ static inline void rtw_netif_stop_queue(struct net_device 
*pnetdev)
netif_tx_stop_all_queues(pnetdev);
 }
 
-static inline void rtw_merge_string(char *dst, int dst_len, char *src1, char 
*src2)
-{
-   int len = 0;
-   len += snprintf(dst+len, dst_len - len, "%s", src1);
-   len += snprintf(dst+len, dst_len - len, "%s", src2);
-}
-
 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
 
 #define rtw_netdev_priv(netdev) (((struct rtw_netdev_priv_indicator 
*)netdev_priv(netdev))->priv)
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: rtl8723bs: Remove File operation APIs

2019-10-09 Thread Hans de Goede
rtl8723bs had 2 private file operation helpers:

rtw_is_file_readable()
rtw_retrive_from_file()

These were only used by the removed phy_Config*WithParaFile() functions,
so they can be removed now.

Signed-off-by: Hans de Goede 
---
 .../staging/rtl8723bs/include/osdep_service.h |   4 -
 .../staging/rtl8723bs/os_dep/osdep_service.c  | 136 --
 2 files changed, 140 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index 81a9c19ecc6a..a40cf7b60a69 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -171,10 +171,6 @@ extern void rtw_softap_lock_suspend(void);
 extern void rtw_softap_unlock_suspend(void);
 #endif
 
-/* File operation APIs, just for linux now */
-extern int rtw_is_file_readable(char *path);
-extern int rtw_retrive_from_file(char *path, u8 *buf, u32 sz);
-
 extern void rtw_free_netdev(struct net_device * netdev);
 
 
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c 
b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index 25a80041ce87..f5614e56371e 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -65,142 +65,6 @@ void _rtw_init_queue(struct __queue *pqueue)
spin_lock_init(&(pqueue->lock));
 }
 
-/*
-* Open a file with the specific @param path, @param flag, @param mode
-* @param fpp the pointer of struct file pointer to get struct file pointer 
while file opening is success
-* @param path the path of the file to open
-* @param flag file operation flags, please refer to linux document
-* @param mode please refer to linux document
-* @return Linux specific error code
-*/
-static int openFile(struct file **fpp, char *path, int flag, int mode)
-{
-   struct file *fp;
-
-   fp = filp_open(path, flag, mode);
-   if (IS_ERR(fp)) {
-   *fpp = NULL;
-   return PTR_ERR(fp);
-   }
-   else {
-   *fpp = fp;
-   return 0;
-   }
-}
-
-/*
-* Close the file with the specific @param fp
-* @param fp the pointer of struct file to close
-* @return always 0
-*/
-static int closeFile(struct file *fp)
-{
-   filp_close(fp, NULL);
-   return 0;
-}
-
-static int readFile(struct file *fp, char *buf, int len)
-{
-   int rlen = 0, sum = 0;
-
-   if (!fp->f_op || !fp->f_op->read)
-   return -EPERM;
-
-   while (sum < len) {
-   rlen = kernel_read(fp, buf + sum, len - sum, &fp->f_pos);
-   if (rlen > 0)
-   sum += rlen;
-   else if (0 != rlen)
-   return rlen;
-   else
-   break;
-   }
-
-   return sum;
-
-}
-
-/*
-* Test if the specifi @param path is a file and readable
-* @param path the path of the file to test
-* @return Linux specific error code
-*/
-static int isFileReadable(char *path)
-{
-   struct file *fp;
-   int ret = 0;
-   char buf;
-
-   fp = filp_open(path, O_RDONLY, 0);
-   if (IS_ERR(fp))
-   return PTR_ERR(fp);
-
-   if (readFile(fp, &buf, 1) != 1)
-   ret = -EINVAL;
-
-   filp_close(fp, NULL);
-   return ret;
-}
-
-/*
-* Open the file with @param path and retrive the file content into memory 
starting from @param buf for @param sz at most
-* @param path the path of the file to open and read
-* @param buf the starting address of the buffer to store file content
-* @param sz how many bytes to read at most
-* @return the byte we've read, or Linux specific error code
-*/
-static int retriveFromFile(char *path, u8 *buf, u32 sz)
-{
-   int ret = -1;
-   struct file *fp;
-
-   if (path && buf) {
-   ret = openFile(&fp, path, O_RDONLY, 0);
-
-   if (ret == 0) {
-   DBG_871X("%s openFile path:%s fp =%p\n", __func__, path 
, fp);
-
-   ret = readFile(fp, buf, sz);
-   closeFile(fp);
-
-   DBG_871X("%s readFile, ret:%d\n", __func__, ret);
-
-   } else {
-   DBG_871X("%s openFile path:%s Fail, ret:%d\n", 
__func__, path, ret);
-   }
-   } else {
-   DBG_871X("%s NULL pointer\n", __func__);
-   ret =  -EINVAL;
-   }
-   return ret;
-}
-
-/*
-* Test if the specifi @param path is a file and readable
-* @param path the path of the file to test
-* @return true or false
-*/
-int rtw_is_file_readable(char *path)
-{
-   if (isFileReadable(path) == 0)
-   return true;
-   else
-   return false;
-}
-
-/*
-* Open the file with @param path and retrive the file content into memory 
starting from @param buf for @param sz at most
-* @param path the path of the file to open and read
-* @param b

[PATCH 2/5] staging: rtl8723bs: Remove phy_Config*WithParaFile() functions

2019-10-09 Thread Hans de Goede
These are no longer used, so remove them and also remove various
struct definitions only used by these functions.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/hal/hal_com.c   |1 -
 .../staging/rtl8723bs/hal/hal_com_phycfg.c| 1076 -
 .../rtl8723bs/include/hal_com_phycfg.h|   26 -
 drivers/staging/rtl8723bs/include/hal_data.h  |   21 -
 4 files changed, 1124 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c 
b/drivers/staging/rtl8723bs/hal/hal_com.c
index eddd56abbb2d..109bd85b0cd8 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -30,7 +30,6 @@ void rtw_hal_data_deinit(struct adapter *padapter)
 {
if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */
if (padapter->HalData) {
-   phy_free_filebuf(padapter);
vfree(padapter->HalData);
padapter->HalData = NULL;
padapter->hal_data_sz = 0;
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6539bee9b5ba..eb7de3617d83 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -2202,1079 +2202,3 @@ void Hal_ChannelPlanToRegulation(struct adapter 
*Adapter, u16 ChannelPlan)
break;
}
 }
-
-
-static char file_path_bs[PATH_MAX];
-
-#define GetLineFromBuffer(buffer)   strsep(&buffer, "\n")
-
-int phy_ConfigMACWithParaFile(struct adapter *Adapter, char *pFileName)
-{
-   struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rlen = 0, rtStatus = _FAIL;
-   char *szLine, *ptmp;
-   u32 u4bRegOffset, u4bRegValue, u4bMove;
-
-   if (!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE))
-   return rtStatus;
-
-   memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
-
-   if ((pHalData->mac_reg_len == 0) && !pHalData->mac_reg) {
-   rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, 
pFileName);
-
-   if (rtw_is_file_readable(file_path_bs) == true) {
-   rlen = rtw_retrive_from_file(file_path_bs, 
pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
-   if (rlen > 0) {
-   rtStatus = _SUCCESS;
-   pHalData->mac_reg = vzalloc(rlen);
-   if (pHalData->mac_reg) {
-   memcpy(pHalData->mac_reg, 
pHalData->para_file_buf, rlen);
-   pHalData->mac_reg_len = rlen;
-   } else
-   DBG_871X("%s mac_reg alloc fail !\n", 
__func__);
-   }
-   }
-   } else {
-   if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != 
NULL)) {
-   memcpy(pHalData->para_file_buf, pHalData->mac_reg, 
pHalData->mac_reg_len);
-   rtStatus = _SUCCESS;
-   } else
-   DBG_871X("%s(): Critical Error !!!\n", __func__);
-   }
-
-   if (rtStatus == _SUCCESS) {
-   ptmp = pHalData->para_file_buf;
-   for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = 
GetLineFromBuffer(ptmp)) {
-   if (!IsCommentString(szLine)) {
-   /*  Get 1st hex value as register offset */
-   if (GetHexValueFromString(szLine, 
&u4bRegOffset, &u4bMove)) {
-   if (u4bRegOffset == 0x) /*  Ending. 
*/
-   break;
-
-   /*  Get 2nd hex value as register 
value. */
-   szLine += u4bMove;
-   if (GetHexValueFromString(szLine, 
&u4bRegValue, &u4bMove))
-   rtw_write8(Adapter, 
u4bRegOffset, (u8)u4bRegValue);
-   }
-   }
-   }
-   } else
-   DBG_871X("%s(): No File %s, Load from HWImg Array!\n", 
__func__, pFileName);
-
-   return rtStatus;
-}
-
-int phy_ConfigBBWithParaFile(
-   struct adapter *Adapter, char *pFileName, u32 ConfigType
-)
-{
-   struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rlen = 0, rtStatus = _FAIL;
-   char *szLine, *ptmp;
-   u32 u4bRegOffset, u4bRegValue, u4bMove;
-   char *pBuf = NULL;
-   u32 *pBufLen = NULL;
-
-   if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE))
-   return rtStatus;
-
-

[PATCH 1/5] staging: rtl8723bs: Remove phy_Config*With*ParaFile() calls

2019-10-09 Thread Hans de Goede
The rtl8723bs driver tries to load various parameters from disk,
circumventing the standard firmware loader mechanism and using DIY
code for this.

No devices which run the mainline kernel ship with these files and even
if these files were present then they still would not be loaded without
additional module parameters. To be precise the following 3 conditions
must all 3 be true for on disk parameters to be used:

1) The rtw_load_phy_file modparam must contain the mask for the type, this
   defaults to(LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) so with
   the default settings this condition is only true for:
   phy_ConfigBBWithPgParaFile()
   PHY_ConfigRFWithPowerLimitTableParaFile(); and
2) rtw_phy_file_path modparam must be set to say "/lib/firmware/"; and
3) Store a /lib/firmware/rtl8723b/XXX file in the expected format.

In practice all 3 being true never happens, so the
phy_Config*With*ParaFile() calls are nops, remove them.

The actual code implementing them will be removed in a separate patch.

Note the ODM_ConfigRFWithHeaderFile() and ODM_ConfigBBWithHeaderFile()
functions always return HAL_STATUS_SUCCESS, this patch makes use of this
to simplify the new code without the phy_Config*With*ParaFile() calls.

Signed-off-by: Hans de Goede 
---
 .../staging/rtl8723bs/hal/rtl8723b_phycfg.c   | 77 +++
 .../staging/rtl8723bs/hal/rtl8723b_rf6052.c   | 41 +-
 2 files changed, 13 insertions(+), 105 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index 6df2b58bdc67..cf23414d7224 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -362,24 +362,10 @@ void PHY_SetRFReg_8723B(
  */
 s32 PHY_MACConfig8723B(struct adapter *Adapter)
 {
-   int rtStatus = _SUCCESS;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   s8 *pszMACRegFile;
-   s8 sz8723MACRegFile[] = RTL8723B_PHY_MACREG;
-
-
-   pszMACRegFile = sz8723MACRegFile;
-
-   /*  */
-   /*  Config MAC */
-   /*  */
-   rtStatus = phy_ConfigMACWithParaFile(Adapter, pszMACRegFile);
-   if (rtStatus == _FAIL) {
-   ODM_ReadAndConfig_MP_8723B_MAC_REG(&pHalData->odmpriv);
-   rtStatus = _SUCCESS;
-   }
 
-   return rtStatus;
+   ODM_ReadAndConfig_MP_8723B_MAC_REG(&pHalData->odmpriv);
+   return _SUCCESS;
 }
 
 /**
@@ -427,17 +413,6 @@ static void phy_InitBBRFRegisterDefinition(struct adapter 
*Adapter)
 static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter)
 {
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rtStatus = _SUCCESS;
-   u8 sz8723BBRegFile[] = RTL8723B_PHY_REG;
-   u8 sz8723AGCTableFile[] = RTL8723B_AGC_TAB;
-   u8 sz8723BBBRegPgFile[] = RTL8723B_PHY_REG_PG;
-   u8 sz8723BRFTxPwrLmtFile[] = RTL8723B_TXPWR_LMT;
-   u8 *pszBBRegFile = NULL, *pszAGCTableFile = NULL, *pszBBRegPgFile = 
NULL, *pszRFTxPwrLmtFile = NULL;
-
-   pszBBRegFile = sz8723BBRegFile;
-   pszAGCTableFile = sz8723AGCTableFile;
-   pszBBRegPgFile = sz8723BBBRegPgFile;
-   pszRFTxPwrLmtFile = sz8723BRFTxPwrLmtFile;
 
/*  Read Tx Power Limit File */
PHY_InitTxPowerLimit(Adapter);
@@ -445,30 +420,14 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
Adapter->registrypriv.RegEnableTxPowerLimit == 1 ||
(Adapter->registrypriv.RegEnableTxPowerLimit == 2 && 
pHalData->EEPROMRegulatory == 1)
) {
-   if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, 
pszRFTxPwrLmtFile) == _FAIL) {
-   if (HAL_STATUS_SUCCESS != 
ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_TXPWR_LMT, 
(ODM_RF_RADIO_PATH_E)0))
-   rtStatus = _FAIL;
-   }
-
-   if (rtStatus != _SUCCESS) {
-   DBG_871X("%s():Read Tx power limit fail\n", __func__);
-   goto phy_BB8190_Config_ParaFile_Fail;
-   }
+   ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
+  CONFIG_RF_TXPWR_LMT, 0);
}
 
/*  */
/*  1. Read PHY_REG.TXT BB INIT!! */
/*  */
-   if (phy_ConfigBBWithParaFile(Adapter, pszBBRegFile, CONFIG_BB_PHY_REG) 
==
-   _FAIL) {
-   if (HAL_STATUS_SUCCESS != 
ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG))
-   rtStatus = _FAIL;
-   }
-
-   if (rtStatus != _SUCCESS) {
-   DBG_8192C("%s():Write BB Reg Fail!!", __func__);
-   goto phy_BB8190_Config_ParaFile_Fail;
-   }
+   ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG);
 
/*  If EEPROM or EFUSE autoload OK, We must config by 

[PATCH 3/5] staging: rtl8723bs: Remove phy_Config*WithParaFile() configuration leftovers

2019-10-09 Thread Hans de Goede
Now that the phy_Config*WithParaFile() functions have been removed nothing
is using these module-parameters and defines anymore.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/include/drv_types.h |  4 
 .../staging/rtl8723bs/include/rtl8723b_hal.h  | 15 --
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   | 20 ---
 3 files changed, 39 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/drv_types.h 
b/drivers/staging/rtl8723bs/include/drv_types.h
index 8d7fce1e39b7..6ec9087f2eb1 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -197,9 +197,6 @@ struct registry_priv
u8 RFE_Type;
u8  check_fw_ps;
 
-   u8 load_phy_file;
-   u8 RegDecryptCustomFile;
-
 #ifdef CONFIG_MULTI_VIR_IFACES
u8 ext_iface_num;/* primary/secondary iface is excluded */
 #endif
@@ -693,7 +690,6 @@ void rtw_indicate_wx_disassoc_event(struct adapter 
*padapter);
 void indicate_wx_scan_complete_event(struct adapter *padapter);
 int rtw_change_ifname(struct adapter *padapter, const char *ifname);
 
-extern char *rtw_phy_file_path;
 extern char *rtw_initmac;
 extern int rtw_mc2u_disable;
 extern int rtw_ht_enable;
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h 
b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
index 8f00ced1c697..f36516fa84c7 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
@@ -20,21 +20,6 @@
 #include "hal_phy_reg_8723b.h"
 #include "hal_phy_cfg.h"
 
-/*  */
-/* RTL8723B From file */
-/*  */
-#define RTL8723B_FW_IMG  "rtl8723b/FW_NIC.bin"
-#define RTL8723B_FW_WW_IMG   "rtl8723b/FW_WoWLAN.bin"
-#define RTL8723B_PHY_REG "rtl8723b/PHY_REG.txt"
-#define RTL8723B_PHY_RADIO_A "rtl8723b/RadioA.txt"
-#define RTL8723B_PHY_RADIO_B "rtl8723b/RadioB.txt"
-#define RTL8723B_TXPWR_TRACK "rtl8723b/TxPowerTrack.txt"
-#define RTL8723B_AGC_TAB "rtl8723b/AGC_TAB.txt"
-#define RTL8723B_PHY_MACREG  "rtl8723b/MAC_REG.txt"
-#define RTL8723B_PHY_REG_PG  "rtl8723b/PHY_REG_PG.txt"
-#define RTL8723B_PHY_REG_MP  "rtl8723b/PHY_REG_MP.txt"
-#define RTL8723B_TXPWR_LMT   "rtl8723b/TXPWR_LMT.txt"
-
 /*  */
 /* RTL8723B From header */
 /*  */
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c 
b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 5044f7373b8b..cb4c86728d26 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -201,24 +201,6 @@ MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 
1:Enable, 2: Depend on efuse
 module_param(rtw_tx_pwr_by_rate, int, 0644);
 MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on 
efuse");
 
-char *rtw_phy_file_path = "";
-module_param(rtw_phy_file_path, charp, 0644);
-MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter");
-/*  PHY FILE Bit Map */
-/*  BIT0 - MAC,0: non-support, 1: support */
-/*  BIT1 - BB, 0: non-support, 1: support */
-/*  BIT2 - BB_PG,  0: non-support, 1: support */
-/*  BIT3 - BB_MP,  0: non-support, 1: support */
-/*  BIT4 - RF, 0: non-support, 1: support */
-/*  BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */
-/*  BIT6 - RF_TXPWR_LMT,   0: non-support, 1: support */
-static int rtw_load_phy_file = (BIT2 | BIT6);
-module_param(rtw_load_phy_file, int, 0644);
-MODULE_PARM_DESC(rtw_load_phy_file, "PHY File Bit Map");
-static int rtw_decrypt_phy_file;
-module_param(rtw_decrypt_phy_file, int, 0644);
-MODULE_PARM_DESC(rtw_decrypt_phy_file, "Enable Decrypt PHY File");
-
 int _netdev_open(struct net_device *pnetdev);
 int netdev_open (struct net_device *pnetdev);
 static int netdev_close (struct net_device *pnetdev);
@@ -321,8 +303,6 @@ static void loadparam(struct adapter *padapter, _nic_hdl 
pnetdev)
registry_par->bEn_RFE = 1;
registry_par->RFE_Type = 64;
 
-   registry_par->load_phy_file = (u8)rtw_load_phy_file;
-   registry_par->RegDecryptCustomFile = (u8)rtw_decrypt_phy_file;
registry_par->qos_opt_enable = (u8)rtw_qos_opt_enable;
 
registry_par->hiq_filter = (u8)rtw_hiq_filter;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls

2019-10-09 Thread Hans de Goede

Hi Denis,

On 30-09-2019 13:01, Denis Efremov wrote:

memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is
called with "src == NULL && len == 0". This is an undefined behavior.
Moreover this if pre-condition "pBufLen && (*pBufLen == 0) && !pBuf"
is constantly false because it is a nested if in the else brach, i.e.,
"if (cond) { ... } else { if (cond) {...} }". This patch alters the
if condition to check "pBufLen && pBuf" pointers are not NULL.

Cc: Greg Kroah-Hartman 
Cc: Hans de Goede 
Cc: Bastien Nocera 
Cc: Larry Finger 
Cc: Jes Sorensen 
Cc: sta...@vger.kernel.org
Signed-off-by: Denis Efremov 
---
Not tested. I don't have the hardware. The fix is based on my guess.


Thsnk you for your patch.

So I've been doing some digging and this code normally never executes.

For this to execute the user would need to change the rtw_load_phy_file module
param from its default of 0x44 (LOAD_BB_PG_PARA_FILE | 
LOAD_RF_TXPWR_LMT_PARA_FILE)
to something which includes 0x02 (LOAD_BB_PARA_FILE) as mask.

And even with that param set for this code to actually do something /
for pBuf to ever not be NULL the following conditions would have to
be true:

1) Set the rtw_load_phy_file module param from its default of
   0x44 (LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) to something
   which includes 0x02 as mask; and
2) Set rtw_phy_file_path module parameter to say "/lib/firmware/"; and
3) Store a /lib/firmware/rtl8723b/PHY_REG.txt file in the expected format.

So I've come to the conclusion that all the phy_Config*WithParaFile functions
(and a bunch of stuff they use) can be removed.

I will prepare and submit a patch for this.

Regards,

Hans





  drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6539bee9b5ba..0902dc3c1825 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -2320,7 +2320,7 @@ int phy_ConfigBBWithParaFile(
}
}
} else {
-   if (pBufLen && (*pBufLen == 0) && !pBuf) {
+   if (pBufLen && pBuf) {
memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
rtStatus = _SUCCESS;
} else
@@ -2752,7 +2752,7 @@ int PHY_ConfigRFWithParaFile(
}
}
} else {
-   if (pBufLen && (*pBufLen == 0) && !pBuf) {
+   if (pBufLen && pBuf) {
memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
rtStatus = _SUCCESS;
} else



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: os_dep: Move common code to func

2019-07-29 Thread Hans de Goede

Hi,

On 25-07-19 20:31, Hariprasad Kelam wrote:

Inthis file all functions has below common functionality
1.Check flag padapter->bSurpriseRemoved
2.Get sdio_func structure from intf_hdl.

This patch introduces two new APIs
rtw_isadapter_removed,rtw_sdio_get_func which helps to do above common
functionality.

Signed-off-by: Hariprasad Kelam 


Looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
  drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 149 ++
  1 file changed, 41 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 50b8934..126429e 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -26,26 +26,38 @@ inline void rtw_sdio_set_irq_thd(struct dvobj_priv *dvobj, 
void *thd_hdl)
sdio_data->sys_sdio_irq_thd = thd_hdl;
  }
  
-u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)

+static s32 rtw_isadapter_removed(struct intf_hdl *pintfhdl)
  {
struct adapter *padapter;
+
+   padapter = pintfhdl->padapter;
+   return padapter->bSurpriseRemoved;
+}
+
+static struct sdio_func *rtw_sdio_get_func(struct intf_hdl *pintfhdl)
+{
struct dvobj_priv *psdiodev;
struct sdio_data *psdio;
  
+	psdiodev = pintfhdl->pintf_dev;

+   psdio = &psdiodev->intf_data;
+
+   return psdio->func;
+}
+
+u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
+{
u8 v = 0;
struct sdio_func *func;
bool claim_needed;
  
-	padapter = pintfhdl->padapter;

-   psdiodev = pintfhdl->pintf_dev;
-   psdio = &psdiodev->intf_data;
  
-	if (padapter->bSurpriseRemoved) {

+   if (rtw_isadapter_removed(pintfhdl)) {
/* DBG_871X(" %s (padapter->bSurpriseRemoved 
||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
return v;
}
  
-	func = psdio->func;

+   func = rtw_sdio_get_func(pintfhdl);
claim_needed = rtw_sdio_claim_host_needed(func);
  
  	if (claim_needed)

@@ -65,23 +77,15 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 
*err)
   */
  s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
  {
-   struct adapter *padapter;
-   struct dvobj_priv *psdiodev;
-   struct sdio_data *psdio;
-
int err = 0, i;
struct sdio_func *func;
  
-	padapter = pintfhdl->padapter;

-   psdiodev = pintfhdl->pintf_dev;
-   psdio = &psdiodev->intf_data;
-
-   if (padapter->bSurpriseRemoved) {
+   if (rtw_isadapter_removed(pintfhdl)) {
/* DBG_871X(" %s (padapter->bSurpriseRemoved 
||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
return err;
}
  
-	func = psdio->func;

+   func = rtw_sdio_get_func(pintfhdl);
  
  	for (i = 0; i < cnt; i++) {

pdata[i] = sdio_readb(func, addr+i, &err);
@@ -100,24 +104,16 @@ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, 
u32 cnt, u8 *pdata)
   */
  s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
  {
-   struct adapter *padapter;
-   struct dvobj_priv *psdiodev;
-   struct sdio_data *psdio;
-
int err = 0;
struct sdio_func *func;
bool claim_needed;
  
-	padapter = pintfhdl->padapter;

-   psdiodev = pintfhdl->pintf_dev;
-   psdio = &psdiodev->intf_data;
-
-   if (padapter->bSurpriseRemoved) {
+   if (rtw_isadapter_removed(pintfhdl)) {
/* DBG_871X(" %s (padapter->bSurpriseRemoved 
||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
return err;
}
  
-	func = psdio->func;

+   func = rtw_sdio_get_func(pintfhdl);
claim_needed = rtw_sdio_claim_host_needed(func);
  
  	if (claim_needed)

@@ -135,23 +131,15 @@ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, 
u32 cnt, u8 *pdata)
   */
  s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
  {
-   struct adapter *padapter;
-   struct dvobj_priv *psdiodev;
-   struct sdio_data *psdio;
-
int err = 0, i;
struct sdio_func *func;
  
-	padapter = pintfhdl->padapter;

-   psdiodev = pintfhdl->pintf_dev;
-   psdio = &psdiodev->intf_data;
-
-   if (padapter->bSurpriseRemoved) {
+   if (rtw_isadapter_removed(pintfhdl)) {
/* DBG_871X(" %s (padapter->bSurpriseRemoved 
||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
return err;
}
  
-	func = psdio->func;

+   func = rtw_sdio_get_func(pintfhdl);
  
  	for (i = 0; i < cnt; i++) {

sdio_writeb(func, pdata[i], addr+i, &err);
@@ -170,24 +158,16 @@ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl,

[PATCH] staging: rtl8723bs: Fix Coverity warning in rtw_dbg_port()

2019-05-21 Thread Hans de Goede
Fix the following Coverity warning:

File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function
rtw_dbg_port():

CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true.

if ((extra_arg & 0x07) > 0x07)
padapter->driver_ampdu_spacing = 0xFF;
else
padapter->driver_ampdu_spacing = extra_arg;

Reported-by: Colin Ian King 
Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 8fb03efd588b..5c70c17aee19 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -3101,7 +3101,7 @@ static int rtw_dbg_port(struct net_device *dev,
 
DBG_871X("enable driver 
ctrl ampdu density = %d\n", extra_arg);
 
-   if ((extra_arg & 0x07) 
> 0x07)
+   if (extra_arg > 0x07)

padapter->driver_ampdu_spacing = 0xFF;
else

padapter->driver_ampdu_spacing = extra_arg;
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: Add rtl8723bs sdio wifi driver

2019-05-21 Thread Hans de Goede

Hi,

On 5/21/19 3:49 PM, Colin Ian King wrote:

Hi,

static analysis with Coverity has detected an issues in the rtl8723bs
wifi driver:

File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function
rtw_dbg_port():

CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true.

 if ((extra_arg & 0x07) > 0x07)
 padapter->driver_ampdu_spacing = 0xFF;
 else
 padapter->driver_ampdu_spacing = extra_arg;


I'm not sure if the mask is (in)correct or the value it is being
compared to 0x07 is (in)correct (or both!)


Hmm, after looking at the rest of the code, it is clear that valid
values for driver_ampdu_spacing or 0 - 7, otherwise it should
be set to 0xff which means use the driver default.

I will send a patch fixing this.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: r8188eu: refactor recvframe_defrag()

2019-03-20 Thread Hans de Goede

Hi,

On 20-03-19 15:31, Ivan Safonov wrote:

Local variables pfhdr and prframe always have a same value,
so one of them is unnecessary.

Signed-off-by: Ivan Safonov 


Patch look good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/rtl8188eu/core/rtw_recv.c | 13 ++---
  1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 90eb1a025051..9075e3a2755a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1325,7 +1325,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
struct list_head *plist, *phead;
u8 wlanhdr_offset;
u8  curfragnum;
-   struct recv_frame *pfhdr, *pnfhdr;
+   struct recv_frame *pnfhdr;
struct recv_frame *prframe, *pnextrframe;
struct __queue *pfree_recv_queue;
  
@@ -1334,11 +1334,10 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
  
  	phead = get_list_head(defrag_q);

plist = phead->next;
-   pfhdr = list_entry(plist, struct recv_frame, list);
-   prframe = pfhdr;
+   prframe = list_entry(plist, struct recv_frame, list);
list_del_init(&prframe->list);
  
-	if (curfragnum != pfhdr->attrib.frag_num) {

+   if (curfragnum != prframe->attrib.frag_num) {
/* the first fragment number must be 0 */
/* free the whole queue */
rtw_free_recvframe(prframe, pfree_recv_queue);
@@ -1377,15 +1376,15 @@ static struct recv_frame *recvframe_defrag(struct 
adapter *adapter,
skb_pull(pnextrframe->pkt, wlanhdr_offset);
  
  		/* append  to first fragment frame's tail (if privacy frame, pull the ICV) */

-   skb_trim(prframe->pkt, prframe->pkt->len - 
pfhdr->attrib.icv_len);
+   skb_trim(prframe->pkt, prframe->pkt->len - 
prframe->attrib.icv_len);
  
  		/* memcpy */

-   memcpy(skb_tail_pointer(pfhdr->pkt), pnfhdr->pkt->data,
+   memcpy(skb_tail_pointer(prframe->pkt), pnfhdr->pkt->data,
   pnfhdr->pkt->len);
  
  		skb_put(prframe->pkt, pnfhdr->pkt->len);
  
-		pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;

+   prframe->attrib.icv_len = pnfhdr->attrib.icv_len;
plist = plist->next;
}
  


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3] staging: rtl8188eu: Fix potential NULL pointer dereference of kcalloc

2019-03-20 Thread Hans de Goede

Hi,

On 20-03-19 18:21, Aditya Pakki wrote:

hwxmits is allocated via kcalloc and not checked for failure before its
dereference. The patch fixes this problem by returning error upstream
in rtl8723bs, rtl8188eu.

Signed-off-by: Aditya Pakki 


Patch look good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
v2: Move signed off above version change log.
v1: Return error and remove print in case of failure, per Greg
---
  drivers/staging/rtl8188eu/core/rtw_xmit.c|  9 +++--
  drivers/staging/rtl8188eu/include/rtw_xmit.h |  2 +-
  drivers/staging/rtl8723bs/core/rtw_xmit.c| 14 +++---
  drivers/staging/rtl8723bs/include/rtw_xmit.h |  2 +-
  4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 1723a47a96b4..952f2ab51347 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -174,7 +174,9 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 
adapter *padapter)
  
  	pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
  
-	rtw_alloc_hwxmits(padapter);

+   res = rtw_alloc_hwxmits(padapter);
+   if (res == _FAIL)
+   goto exit;
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
  
  	for (i = 0; i < 4; i++)

@@ -1503,7 +1505,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct 
xmit_frame *pxmitframe)
return res;
  }
  
-void rtw_alloc_hwxmits(struct adapter *padapter)

+s32 rtw_alloc_hwxmits(struct adapter *padapter)
  {
struct hw_xmit *hwxmits;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -1512,6 +1514,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
  
  	pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry,

 sizeof(struct hw_xmit), GFP_KERNEL);
+   if (!pxmitpriv->hwxmits)
+   return _FAIL;
  
  	hwxmits = pxmitpriv->hwxmits;
  
@@ -1519,6 +1523,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter)

hwxmits[1] .sta_queue = &pxmitpriv->vi_pending;
hwxmits[2] .sta_queue = &pxmitpriv->be_pending;
hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
+   return _SUCCESS;
  }
  
  void rtw_free_hwxmits(struct adapter *padapter)

diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h 
b/drivers/staging/rtl8188eu/include/rtw_xmit.h
index 788f59c74ea1..ba7e15fbde72 100644
--- a/drivers/staging/rtl8188eu/include/rtw_xmit.h
+++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h
@@ -336,7 +336,7 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
  void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
  s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter 
*padapter);
  void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
-void rtw_alloc_hwxmits(struct adapter *padapter);
+s32 rtw_alloc_hwxmits(struct adapter *padapter);
  void rtw_free_hwxmits(struct adapter *padapter);
  s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
  
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c

index 094d61bcb469..b87f13a0b563 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -260,7 +260,9 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 
adapter *padapter)
}
}
  
-	rtw_alloc_hwxmits(padapter);

+   res = rtw_alloc_hwxmits(padapter);
+   if (res == _FAIL)
+   goto exit;
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
  
  	for (i = 0; i < 4; i++) {

@@ -2144,7 +2146,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct 
xmit_frame *pxmitframe)
return res;
  }
  
-void rtw_alloc_hwxmits(struct adapter *padapter)

+s32 rtw_alloc_hwxmits(struct adapter *padapter)
  {
struct hw_xmit *hwxmits;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -2155,10 +2157,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
  
  	pxmitpriv->hwxmits = rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry);
  
-	if (pxmitpriv->hwxmits == NULL) {

-   DBG_871X("alloc hwxmits fail!...\n");
-   return;
-   }
+   if (!pxmitpriv->hwxmits)
+   return _FAIL;
  
  	hwxmits = pxmitpriv->hwxmits;
  
@@ -2204,7 +2204,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
  
  	}
  
-

+   return _SUCCESS;
  }
  
  void rtw_free_hwxmits(struct adapter *padapter)

diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h 
b/drivers/staging/rtl8723bs/include/rtw_xmit.h
index 1b38b9182b31..37f42b2f22f1 100644
--- a/drivers/staging/rtl8723bs/include/rtw_xmit.h
+++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h
@@ -487,7 +487,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 
adapter *padapter);
  void _r

Re: [PATCH] staging: vboxvideo: fix vbox_dumb_create fail logic

2019-03-14 Thread Hans de Goede

Hi,

On 14-03-19 16:21, Sidong Yang wrote:

In function vbox_dumb_create() of vbox_main.c, It calls vbox_gem_create()
for creating drm_gem_object. and it calls  vbox_gem_handle_create() for handle.
If handle creation fails only, drm_gem_object should be released by calling
drm_gem_object_put_unlocked().


Nack.

On success drm_gem_handle_create does a drm_gem_object_get on success, since
we forgot about the gem_object afterwards (we only keep track of the
gem_handle with its embedded reference), we should release our
gem_object_reference on success, so that when the gem_handle gets free-ed
the gem_object also gets free-ed.

So we should release out reference on the gem_object in both the
success and failure paths and the old code is correct.

Also for drm-drivers, you should always Cc the dri-devel list.

Regards,

Hans

p.s.

In drm-misc-next vboxvideo has been moved out of staging, please base any
further vboxvideo patches on top of drm-misc-next.




Signed-off-by: Sidong Yang  > ---
  drivers/staging/vboxvideo/vbox_main.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index e1fb70a42d32..ca676ba37bb4 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -312,9 +312,10 @@ int vbox_dumb_create(struct drm_file *file,
return ret;
  
  	ret = drm_gem_handle_create(file, gobj, &handle);

-   drm_gem_object_put_unlocked(gobj);
-   if (ret)
+   if (ret) {
+   drm_gem_object_put_unlocked(gobj);
return ret;
+   }
  
  	args->handle = handle;
  


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: rtl8723bs: remove some dead code

2019-02-05 Thread Hans de Goede

Hi,

On 04-02-19 19:24, Dan Carpenter wrote:

"psecnetwork" is the address of &psecuritypriv->sec_bss.  Since
->sec_bss isn't the first member of the struct that means that
"psecnetwork" can't be NULL.

We can just remove this dead code.

Signed-off-by: Dan Carpenter 


Thanks, LGTM:

Reviewed-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 
  1 file changed, 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index ea2c187e56bd..91520ca3bbad 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -835,14 +835,6 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
}
  
  	psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;

-   if (psecnetwork == NULL) {
-   kfree(pcmd);
-   res = _FAIL;
-
-   RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd 
:psecnetwork == NULL!!!\n"));
-
-   goto exit;
-   }
  
  	memset(psecnetwork, 0, t_len);
  


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: rtl8723bs: change semaphores to completions

2018-12-11 Thread Hans de Goede

Hi Arnd,

Thank you for the patches.

On 10-12-18 22:40, Arnd Bergmann wrote:

This driver uses many semaphores, most of them are equivalent to
completions. The other copies of this driver got moved over to
completions a while ago, so do the same here.

In this usage scenario, the two are equivalent, so the behavior
should not change.

Signed-off-by: Arnd Bergmann 


The entire series looks good to me and I've also given it
a quick test run on a tablet with a rtl8723bs wifi chip:

Reviewed-by: Hans de Goede 

Regards,

Hans





---
  drivers/staging/rtl8723bs/core/rtw_cmd.c  | 20 -
  drivers/staging/rtl8723bs/core/rtw_mlme.c |  2 --
  drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  |  4 ++--
  drivers/staging/rtl8723bs/core/rtw_xmit.c |  8 +++
  .../staging/rtl8723bs/hal/rtl8723b_hal_init.c |  4 ++--
  .../staging/rtl8723bs/hal/rtl8723bs_xmit.c| 22 ---
  drivers/staging/rtl8723bs/hal/sdio_ops.c  |  2 +-
  drivers/staging/rtl8723bs/include/rtw_cmd.h   |  7 +++---
  drivers/staging/rtl8723bs/include/rtw_xmit.h  |  9 
  drivers/staging/rtl8723bs/os_dep/os_intfs.c   |  6 ++---
  drivers/staging/rtl8723bs/os_dep/xmit_linux.c |  2 +-
  11 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 830be63391b7..3d206c33eafa 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -166,10 +166,8 @@ sint   _rtw_init_cmd_priv(struct   cmd_priv 
*pcmdpriv)
  {
sint res = _SUCCESS;
  
-	sema_init(&(pcmdpriv->cmd_queue_sema), 0);

-   /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */
-   sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
-
+   init_completion(&pcmdpriv->cmd_queue_comp);
+   init_completion(&pcmdpriv->terminate_cmdthread_comp);
  
  	_rtw_init_queue(&(pcmdpriv->cmd_queue));
  
@@ -369,7 +367,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)

res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
  
  	if (res == _SUCCESS)

-   up(&pcmdpriv->cmd_queue_sema);
+   complete(&pcmdpriv->cmd_queue_comp);
  
  exit:

return res;
@@ -410,8 +408,8 @@ void rtw_stop_cmd_thread(struct adapter *adapter)
atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
adapter->cmdpriv.stop_req == 0) {
adapter->cmdpriv.stop_req = 1;
-   up(&adapter->cmdpriv.cmd_queue_sema);
-   down(&adapter->cmdpriv.terminate_cmdthread_sema);
+   complete(&adapter->cmdpriv.cmd_queue_comp);
+   wait_for_completion(&adapter->cmdpriv.terminate_cmdthread_comp);
}
  }
  
@@ -435,13 +433,13 @@ int rtw_cmd_thread(void *context)
  
  	pcmdpriv->stop_req = 0;

atomic_set(&(pcmdpriv->cmdthd_running), true);
-   up(&pcmdpriv->terminate_cmdthread_sema);
+   complete(&pcmdpriv->terminate_cmdthread_comp);
  
  	RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread \n"));
  
  	while (1) {

-   if (down_interruptible(&pcmdpriv->cmd_queue_sema)) {
-   DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" 
down_interruptible(&pcmdpriv->cmd_queue_sema) return != 0, break\n", 
FUNC_ADPT_ARG(padapter));
+   if 
(wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) {
+   DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" 
wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, break\n", 
FUNC_ADPT_ARG(padapter));
break;
}
  
@@ -581,7 +579,7 @@ int rtw_cmd_thread(void *context)

rtw_free_cmd_obj(pcmd);
} while (1);
  
-	up(&pcmdpriv->terminate_cmdthread_sema);

+   complete(&pcmdpriv->terminate_cmdthread_comp);
atomic_set(&(pcmdpriv->cmdthd_running), false);
  
  	thread_exit();

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 4c5d5cf9dfe0..81505f3bce8b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2373,8 +2373,6 @@ sint rtw_set_key(struct adapter *adapter, struct 
security_priv *psecuritypriv, s
  
  		INIT_LIST_HEAD(&pcmd->list);
  
-		/* sema_init(&(pcmd->cmd_sem), 0); */

-
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
} else{
setkey_hdl(adapter, (u8 *)psetkeyparm);
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 59a667753266..a0d8fbeecf9b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/driv

Re: [PATCH 1/2] staging: rtl8723bs: remove dead code, rtw_port_switch_chk()

2018-12-10 Thread Hans de Goede

Hi,

Thank you for the patches.

On 10-12-18 10:52, Michael Straube wrote:

The function rtw_port_switch_chk() returns always false.
Remove the function and related dead code.

Signed-off-by: Michael Straube 


Both patches look good to me:

Acked-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 ---
  .../staging/rtl8723bs/include/rtw_mlme_ext.h  |  1 -
  2 files changed, 35 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 8445d516c93d..35003d8d9ba4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -5334,13 +5334,6 @@ void report_add_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, int
return;
  }
  
-

-bool rtw_port_switch_chk(struct adapter *adapter)
-{
-   bool switch_needed = false;
-   return switch_needed;
-}
-
  /
  
  Following are the event callback functions

@@ -5414,7 +5407,6 @@ static void rtw_mlmeext_disconnect(struct adapter 
*padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct wlan_bssid_ex*pnetwork = (struct wlan_bssid_ex 
*)(&(pmlmeinfo->network));
-   u8 state_backup = (pmlmeinfo->state&0x03);
  
  	/* set_opmode_cmd(padapter, infra_client_with_mlme); */
  
@@ -5440,17 +5432,6 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter)
  
  	pmlmeinfo->state = WIFI_FW_NULL_STATE;
  
-	if (state_backup == WIFI_FW_STATION_STATE) {

-   if (rtw_port_switch_chk(padapter)) {
-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-   {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-   }
-
/* switch to the 20M Hz mode after disconnect */
pmlmeext->cur_bwmode = CHANNEL_WIDTH_20;
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
@@ -5530,9 +5511,6 @@ void mlmeext_joinbss_event_callback(struct adapter 
*padapter, int join_res)
rtw_hal_macid_wakeup(padapter, psta->mac_id);
}
  
-	if (rtw_port_switch_chk(padapter))

-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
join_type = 2;
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
  
@@ -6087,18 +6065,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)

rtw_auto_ap_start_beacon(padapter);
  #endif
  
-	if (rtw_port_switch_chk(padapter)) {

-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
-   if (psetop->mode == Ndis802_11APMode)
-   adapter_to_pwrctl(padapter)->fw_psmode_iface_id = 0xff; 
/* ap mode won't dowload rsvd pages */
-   else if (psetop->mode == Ndis802_11Infrastructure) {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-
if (psetop->mode == Ndis802_11APMode) {
/*  Do this after port switch to */
/*  prevent from downloading rsvd page to wrong port */
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h 
b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 4c3141882143..f6eabad4bbe0 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -648,7 +648,6 @@ void report_survey_event(struct adapter *padapter, union 
recv_frame *precv_frame
  void report_surveydone_event(struct adapter *padapter);
  void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
unsigned short reason);
  void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
int cam_idx);
-bool rtw_port_switch_chk(struct adapter *adapter);
  void report_wmm_edca_update(struct adapter *padapter);
  
  void beacon_timing_control(struct adapter *padapter);



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: Correct errors from checkpatch

2018-11-07 Thread Hans de Goede

Hi,

On 07-11-18 00:27, Josenivaldo Benito Jr wrote:

Correct following errors reported by checkpath.pl:

ERROR: space required before the open parenthesis '(' #265: FILE:
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c:265:
+   if(!precvframe) ')'

Also similar errors on line 274 and 283.

Signed-off-by: Josenivaldo Benito Jr 

---

I am new to the community, working on a study group called LKCamp.
Please provide any feedback to this patch so I can correct and learn.

Thanks
---
  drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c 
b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index 8507794..23d6cb6 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -262,7 +262,7 @@ static void rtl8723bs_recv_tasklet(void *priv)

while (ptr < precvbuf->ptail) {
precvframe = try_alloc_recvframe(precvpriv, precvbuf);
-   if(!precvframe)
+   if (!precvframe)
return;

/* rx desc parsing */
@@ -271,7 +271,7 @@ static void rtl8723bs_recv_tasklet(void *priv)

pattrib = &precvframe->u.hdr.attrib;

-   if(rx_crc_err(precvpriv, p_hal_data,
+   if (rx_crc_err(precvpriv, p_hal_data,
  pattrib, precvframe))


The rx_crc_err call is split over 2 lines here. Since you added a space
in the first line of the call you also need to add a space in front
of the pattrib, so that the p is below the first letter of the first
argument of the function call (and not below the '(' ).

So after the fix this should look like this:

if (rx_crc_err(precvpriv, p_hal_data,
   pattrib, precvframe))

Note this will only look good if your email client shows tabs correctly
and you are using a fixed-width font.



break;

@@ -280,7 +280,7 @@ static void rtl8723bs_recv_tasklet(void *priv)
pattrib->shift_sz +
pattrib->pkt_len;

-   if(pkt_exceeds_tail(precvpriv, ptr + pkt_offset,
+   if (pkt_exceeds_tail(precvpriv, ptr + pkt_offset,
precvbuf->ptail, precvframe))
break;


Same here.

Otherwise this looks good to me.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3] staging: vboxvideo: Remove unnecessary parentheses

2018-10-31 Thread Hans de Goede

Hi,

On 31-10-18 16:03, Shayenne da Luz Moura wrote:

Remove unneeded parentheses around the arguments of ||. This reduces
clutter and code behave in the same way.
Change suggested by checkpatch.pl.

vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 <
crtc->x'

Signed-off-by: Shayenne da Luz Moura 


Thank you.

Still looks good to me:

Acked-by: Hans de Goede 

Regards,

Hans




---
Changes in v2:
   - Make the commit message more clearer.

Changes in v3:
   - Update to apply patch to the latest kernel tree

  drivers/staging/vboxvideo/vbox_main.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 7466c1103ff6..ad0e0b62bd1e 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -122,10 +122,10 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
struct vbva_cmd_hdr cmd_hdr;
unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
  
-			if ((rects[i].x1 > crtc_x + mode->hdisplay) ||

-   (rects[i].y1 > crtc_y + mode->vdisplay) ||
-   (rects[i].x2 < crtc_x) ||
-   (rects[i].y2 < crtc_y))
+   if (rects[i].x1 > crtc_x + mode->hdisplay ||
+   rects[i].y1 > crtc_y + mode->vdisplay ||
+   rects[i].x2 < crtc_x ||
+   rects[i].y2 < crtc_y)
continue;
  
  			cmd_hdr.x = (s16)rects[i].x1;



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH 1/2] staging: vboxvideo: Change uint32_t to u32

2018-10-28 Thread Hans de Goede

Hi,

On 26-10-18 21:04, Shayenne da Luz Moura wrote:

This change was suggested by checkpath.pl.

CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Shayenne da Luz Moura 


So as already mentioned in response to the coverletter of
the first posting of this series.

The drm headers use uint32_t in the prototype definition of the callback
functions we are defining, so the vboxvideo code should use the same even
if the compiler does not warn about the callback implementation having
different parameter types in this case.

To be precise, the page_flip member of struct drm_crtc_funcs is defined as:

int (*page_flip)(struct drm_crtc *crtc,
 struct drm_framebuffer *fb,
 struct drm_pending_vblank_event *event,
 uint32_t flags,
 struct drm_modeset_acquire_ctx *ctx);

So our implementation before your patch exactly matches the prototype
which IMHO is the right thing to do.

Regards,

Hans





---
  drivers/staging/vboxvideo/vbox_mode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 79836c8fb909..8a1b117990b8 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -311,7 +311,7 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
  static int vbox_crtc_page_flip(struct drm_crtc *crtc,
   struct drm_framebuffer *fb,
   struct drm_pending_vblank_event *event,
-  uint32_t page_flip_flags,
+  u32 page_flip_flags,
   struct drm_modeset_acquire_ctx *ctx)
  {
struct vbox_private *vbox = crtc->dev->dev_private;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: vboxvideo: Remove unnecessary parentheses

2018-10-26 Thread Hans de Goede

Hi,

On 23-10-18 19:43, Shayenne da Luz Moura wrote:

Remove unneeded parentheses around the arguments of ||. This reduces
clutter and code behave in the same way.
Change suggested by checkpatch.pl.

vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 <
crtc->x'

Signed-off-by: Shayenne da Luz Moura 


Patch looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
Changes in v2:
   - Make the commit message more clearer.
  
  drivers/staging/vboxvideo/vbox_main.c | 8 

  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 429f6a453619..10a862674789 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -116,10 +116,10 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
struct vbva_cmd_hdr cmd_hdr;
unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
  
-			if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) ||

-   (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) ||
-   (rects[i].x2 < crtc->x) ||
-   (rects[i].y2 < crtc->y))
+   if (rects[i].x1 > crtc->x + crtc->hwmode.hdisplay ||
+   rects[i].y1 > crtc->y + crtc->hwmode.vdisplay ||
+   rects[i].x2 < crtc->x ||
+   rects[i].y2 < crtc->y)
continue;
  
  			cmd_hdr.x = (s16)rects[i].x1;



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/2] staging: vboxvideo: Remove chekpatch issues

2018-10-26 Thread Hans de Goede

Hi,

On 25-10-18 21:40, Shayenne da Luz Moura wrote:

This series cleans the following checkpatch.pl issues:

CHECK: Prefer kernel type 'u32' over 'uint32_t'
CHECK: Avoid using bool structure members because of possible alignment issues

Shayenne da Luz Moura (2):
   staging: vboxvideo: Change uint32_t to u32
   staging: vboxvideo: Use unsigned int instead bool


Why am I receiving only the cover letter of this series? Please resend
so that I get all the patches.

Also at least the first patch is wrong, the drm headers use uint32_t
in the prototype definition of the callback functions we are defining,
so the vboxvideo code should use the same even if the compiler does not
warn about the callback implementation having different parameter types
in this case.

Regards,

Hans






  drivers/staging/vboxvideo/vbox_drv.h| 14 +++---
  drivers/staging/vboxvideo/vbox_mode.c   |  2 +-
  drivers/staging/vboxvideo/vboxvideo_guest.h |  2 +-
  3 files changed, 9 insertions(+), 9 deletions(-)


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/6] staging: vboxvideo: Fixup some #ifdef-s

2018-10-22 Thread Hans de Goede

Hi,

On 22-10-18 17:42, Emil Velikov wrote:

On Mon, 22 Oct 2018 at 15:58, Hans de Goede  wrote:


Add #ifdef CONFIG_PM_SLEEP around the suspend/hibernate functions.

Remove unnecessary #ifdef CONFIG_COMPAT, the .compat_ioctl member is
always available and if CONFIG_COMPAT is not set then drm_compat_ioctl
is defined to NULL.

Signed-off-by: Hans de Goede 
---
  drivers/staging/vboxvideo/vbox_drv.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index f9f4c6c2a4e9..b6e6530aa4be 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -117,6 +117,7 @@ static void vbox_pci_remove(struct pci_dev *pdev)
 drm_dev_put(&vbox->ddev);
  }

+#ifdef CONFIG_PM_SLEEP
  static int vbox_pm_suspend(struct device *dev)


AFAICT Arnd has been annotating these as __maybe_unused


That only works in combinations with a macro like
SET_SYSTEM_SLEEP_PM_OPS(), which makes sure that we do not actually
set the .suspend, etc. members of dev_pm_ops when CONFIG_PM_SLEEP
is not set, so that the code actually gets compiled out.

We cannot use SET_SYSTEM_SLEEP_PM_OPS here, since the suspend
and hibernate paths differ.

Regards,

Hans


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/6] staging: vboxvideo: Add myself as MODULE_AUTHOR

2018-10-22 Thread Hans de Goede
Add myself as MODULE_AUTHOR.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index b6e6530aa4be..80d7395e48dc 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -277,5 +277,6 @@ module_init(vbox_init);
 module_exit(vbox_exit);
 
 MODULE_AUTHOR("Oracle Corporation");
+MODULE_AUTHOR("Hans de Goede ");
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL and additional rights");
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] staging: vboxvideo: Cleanup header use

2018-10-22 Thread Hans de Goede
Stop adding -Iinclude/drm to the CFLAGS and stop using the obsolete
"include-all" drm/drmP.h header.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/Makefile   | 2 --
 drivers/staging/vboxvideo/vbox_drv.c | 1 -
 drivers/staging/vboxvideo/vbox_drv.h | 2 +-
 drivers/staging/vboxvideo/vbox_fb.c  | 1 -
 drivers/staging/vboxvideo/vbox_ttm.c | 4 +++-
 5 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vboxvideo/Makefile 
b/drivers/staging/vboxvideo/Makefile
index 3f6094aa9cdf..1224f313af0c 100644
--- a/drivers/staging/vboxvideo/Makefile
+++ b/drivers/staging/vboxvideo/Makefile
@@ -1,6 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-ccflags-y := -Iinclude/drm
-
 vboxvideo-y :=  hgsmi_base.o modesetting.o vbva_base.o \
vbox_drv.o vbox_fb.o vbox_hgsmi.o vbox_irq.o vbox_main.o \
vbox_mode.o vbox_prime.o vbox_ttm.o
diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index d7440b9e5eea..9997beac00fb 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -11,7 +11,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include "vbox_drv.h"
diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index f82e594eca4b..cb0bc9201a7f 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -12,10 +12,10 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 8041d0c46a6b..af224eb5ebc1 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/vboxvideo/vbox_ttm.c 
b/drivers/staging/vboxvideo/vbox_ttm.c
index 74f2d271ddac..edc8686454bf 100644
--- a/drivers/staging/vboxvideo/vbox_ttm.c
+++ b/drivers/staging/vboxvideo/vbox_ttm.c
@@ -6,8 +6,10 @@
  * Authors: Dave Airlie 
  *  Michael Thayer 
  */
+#include 
+#include 
+#include 
 #include "vbox_drv.h"
-#include 
 
 static inline struct vbox_private *vbox_bdev(struct ttm_bo_device *bd)
 {
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/6] staging: vboxvideo: Address various review remarks

2018-10-22 Thread Hans de Goede
Hi All,

Note this series applies on top of my serious from a couple of days ago
which starts with
"[PATCH 1/6] staging: vboxvideo: Stop accessing crtc_state->active"

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] staging: vboxvideo: Drop DRM_MODE_FB_CMD define

2018-10-22 Thread Hans de Goede
This is a leftover from when the driver was out of tree and also build
against older kernels.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  | 4 +---
 drivers/staging/vboxvideo/vbox_fb.c   | 2 +-
 drivers/staging/vboxvideo/vbox_main.c | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index cb0bc9201a7f..e2a6b2b5bfc3 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -164,8 +164,6 @@ void vbox_hw_fini(struct vbox_private *vbox);
 int vbox_mode_init(struct vbox_private *vbox);
 void vbox_mode_fini(struct vbox_private *vbox);
 
-#define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-
 void vbox_report_caps(struct vbox_private *vbox);
 
 void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
@@ -174,7 +172,7 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
 
 int vbox_framebuffer_init(struct vbox_private *vbox,
  struct vbox_framebuffer *vbox_fb,
- const struct DRM_MODE_FB_CMD *mode_cmd,
+ const struct drm_mode_fb_cmd2 *mode_cmd,
  struct drm_gem_object *obj);
 
 int vboxfb_create(struct drm_fb_helper *helper,
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index af224eb5ebc1..d3a5255c93b6 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -51,7 +51,7 @@ int vboxfb_create(struct drm_fb_helper *helper,
struct vbox_private *vbox =
container_of(helper, struct vbox_private, fb_helper);
struct pci_dev *pdev = vbox->ddev.pdev;
-   struct DRM_MODE_FB_CMD mode_cmd;
+   struct drm_mode_fb_cmd2 mode_cmd;
struct drm_framebuffer *fb;
struct fb_info *info;
struct drm_gem_object *gobj;
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 1328f82a083d..8348e71c4c9d 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -103,7 +103,7 @@ static const struct drm_framebuffer_funcs vbox_fb_funcs = {
 
 int vbox_framebuffer_init(struct vbox_private *vbox,
  struct vbox_framebuffer *vbox_fb,
- const struct DRM_MODE_FB_CMD *mode_cmd,
+ const struct drm_mode_fb_cmd2 *mode_cmd,
  struct drm_gem_object *obj)
 {
int ret;
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] staging: vboxvideo: Use PCI_DEVICE() for our pci_id table

2018-10-22 Thread Hans de Goede
Use PCI_DEVICE() for our pci_id table and also simplify the terminating
entry tio just "{ }".

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index 9997beac00fb..f9f4c6c2a4e9 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -23,8 +23,8 @@ module_param_named(modeset, vbox_modeset, int, 0400);
 static struct drm_driver driver;
 
 static const struct pci_device_id pciidlist[] = {
-   { 0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-   { 0, 0, 0},
+   { PCI_DEVICE(0x80ee, 0xbeef) },
+   { }
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] staging: vboxvideo: Use DRM_FB_HELPER_DEFAULT_OPS

2018-10-22 Thread Hans de Goede
Use DRM_FB_HELPER_DEFAULT_OPS rather then open-coding it.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_fb.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index d3a5255c93b6..8a2f2e8b57c1 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -33,16 +33,10 @@ static struct fb_deferred_io vbox_defio = {
 
 static struct fb_ops vboxfb_ops = {
.owner = THIS_MODULE,
-   .fb_check_var = drm_fb_helper_check_var,
-   .fb_set_par = drm_fb_helper_set_par,
+   DRM_FB_HELPER_DEFAULT_OPS,
.fb_fillrect = drm_fb_helper_sys_fillrect,
.fb_copyarea = drm_fb_helper_sys_copyarea,
.fb_imageblit = drm_fb_helper_sys_imageblit,
-   .fb_pan_display = drm_fb_helper_pan_display,
-   .fb_blank = drm_fb_helper_blank,
-   .fb_setcmap = drm_fb_helper_setcmap,
-   .fb_debug_enter = drm_fb_helper_debug_enter,
-   .fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
 int vboxfb_create(struct drm_fb_helper *helper,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] staging: vboxvideo: Fixup some #ifdef-s

2018-10-22 Thread Hans de Goede
Add #ifdef CONFIG_PM_SLEEP around the suspend/hibernate functions.

Remove unnecessary #ifdef CONFIG_COMPAT, the .compat_ioctl member is
always available and if CONFIG_COMPAT is not set then drm_compat_ioctl
is defined to NULL.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index f9f4c6c2a4e9..b6e6530aa4be 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -117,6 +117,7 @@ static void vbox_pci_remove(struct pci_dev *pdev)
drm_dev_put(&vbox->ddev);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int vbox_pm_suspend(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
@@ -172,13 +173,16 @@ static const struct dev_pm_ops vbox_pm_ops = {
.poweroff = vbox_pm_poweroff,
.restore = vbox_pm_resume,
 };
+#endif
 
 static struct pci_driver vbox_pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
.probe = vbox_pci_probe,
.remove = vbox_pci_remove,
+#ifdef CONFIG_PM_SLEEP
.driver.pm = &vbox_pm_ops,
+#endif
 };
 
 static const struct file_operations vbox_fops = {
@@ -186,11 +190,9 @@ static const struct file_operations vbox_fops = {
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
+   .compat_ioctl = drm_compat_ioctl,
.mmap = vbox_mmap,
.poll = drm_poll,
-#ifdef CONFIG_COMPAT
-   .compat_ioctl = drm_compat_ioctl,
-#endif
.read = drm_read,
 };
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] drm/vboxvideo: Move vboxvideo driver out of staging

2018-10-22 Thread Hans de Goede

Hi,

Thank you for the review.

On 18-10-18 20:12, Sam Ravnborg wrote:

Hi Hans.

Just a bunch of random observations that I hope you find use of.

Sam


diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index cb88528e7b10..6b4d6c957da8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -315,6 +315,8 @@ source "drivers/gpu/drm/tve200/Kconfig"
  
  source "drivers/gpu/drm/xen/Kconfig"
  
+source "drivers/gpu/drm/vboxvideo/Kconfig"

+
  # Keep legacy drivers last
  
  menuconfig DRM_LEGACY

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index a6771cef85e2..133606802300 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -107,3 +107,4 @@ obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
  obj-$(CONFIG_DRM_PL111) += pl111/
  obj-$(CONFIG_DRM_TVE200) += tve200/
  obj-$(CONFIG_DRM_XEN) += xen/
+obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/


Is it the most logical place to add this in the end?
You are asking for merge problems if you do so, but then
the drm drivers does not seem to follow any good order
so this may be fine.


Right, just tagging the entry to the end seems to be what
all new driver additions do, so I'm just following that
example here.


+++ b/drivers/gpu/drm/vboxvideo/Makefile
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+ccflags-y := -Iinclude/drm

This should not be required.
If required then fix the offending #include


Fixed in the set of cleanup patches which I'm sending out
after this email.

Note these cleanup patches apply to the staging version of
the driver, I will do a new version of this patch after
someone has found the time to do a more thorough review.


+
+vboxvideo-y :=  hgsmi_base.o modesetting.o vbva_base.o \
+   vbox_drv.o vbox_fb.o vbox_hgsmi.o vbox_irq.o vbox_main.o \
+   vbox_mode.o vbox_prime.o vbox_ttm.o
+
+obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo.o
diff --git a/drivers/gpu/drm/vboxvideo/hgsmi_base.c 
b/drivers/gpu/drm/vboxvideo/hgsmi_base.c
new file mode 100644
index ..361d3193258e
--- /dev/null
+++ b/drivers/gpu/drm/vboxvideo/hgsmi_base.c
@@ -0,0 +1,207 @@
+// SPDX-License-Identifier: MIT
+/* Copyright (C) 2006-2017 Oracle Corporation */

2018?
General comment for all files.


I do not work for Oracle, so its not up to me to extend the copyright
claim.




+   union {
+   /* Opaque placeholder to make the union 8 bytes. */
+   u8 header_data[8];

Further down you have 2 x u32, so the union is guaranteed to be 64 bits.
So header_data is redundant.


The header_data member is used in the code.


+
+   /* HGSMI_BUFFER_HEADER_F_SEQ_SINGLE */
+   struct {
+   u32 reserved1;  /* A reserved field, initialize to 0. */
+   u32 reserved2;  /* A reserved field, initialize to 0. */
+   } buffer;





--- /dev/null
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright (C) 2013-2017 Oracle Corporation
+ * This file is based on ast_drv.c
+ * Copyright 2012 Red Hat Inc.
+ * Authors: Dave Airlie 
+ *  Michael Thayer 
+ */
+#include 
+#include 
+#include 
+
+#include 

We are trying to get rid of drmP - replace with more specific includes.
Goes for all uses of drmP.h


Fixed in the cleanup series.


+
+static int vbox_modeset = -1;
+
+MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
+module_param_named(modeset, vbox_modeset, int, 0400);
+
+static struct drm_driver driver;
+
+static const struct pci_device_id pciidlist[] = {
+   { 0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+   { 0, 0, 0},
+};

Use PCI_DEVICE()?


Ack, fixed in the cleanup series.


+static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
+{
+   struct vbox_private *vbox;
+   int ret = 0;
+
+   if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
+   return -ENODEV;
+
+   vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
+   if (!vbox)
+   return -ENOMEM;
+
+   ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
+   if (ret) {
+   kfree(vbox);
+   return ret;
+   }
+
+   vbox->ddev.pdev = pdev;
+   vbox->ddev.dev_private = vbox;
+   pci_set_drvdata(pdev, vbox);
+   mutex_init(&vbox->hw_mutex);
+
+   ret = pci_enable_device(pdev);
+   if (ret)
+   goto err_dev_put;
+
+   ret = vbox_hw_init(vbox);
+   if (ret)
+   goto err_pci_disable;
+
+   ret = vbox_mm_init(vbox);
+   if (ret)
+   goto err_hw_fini;
+
+   ret = vbox_mode_init(vbox);
+   if (ret)
+   goto err_mm_fini;
+
+   ret = vbox_irq_init(vbox);
+   if (ret)
+   goto err_mode_fini;
+
+   ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper,
+   &vbox_fb_helper_funcs, 32,
+   vbox->nu

[PATCH] drm/vboxvideo: Move vboxvideo driver out of staging

2018-10-18 Thread Hans de Goede
Now that it has been converted to use atomic-modesetting and all other
known issues have addressed too, the vboxvideo driver can be moved out of
staging.

Signed-off-by: Hans de Goede 
---
Note this commit only adds the driver to drivers/gpu/drm, it disables, but
does not remove the old version in staging yet. I've done that this way
since Daniel has indicated that he wanted to do a full review of the driver
and if I just move the files the patch will not be very useful for
reviewing.
---
 MAINTAINERS |   6 +
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/vboxvideo/Kconfig   |  15 +
 drivers/gpu/drm/vboxvideo/Makefile  |   8 +
 drivers/gpu/drm/vboxvideo/hgsmi_base.c  | 207 +
 drivers/gpu/drm/vboxvideo/hgsmi_ch_setup.h  |  32 +
 drivers/gpu/drm/vboxvideo/hgsmi_channels.h  |  34 +
 drivers/gpu/drm/vboxvideo/hgsmi_defs.h  |  73 ++
 drivers/gpu/drm/vboxvideo/modesetting.c | 123 +++
 drivers/gpu/drm/vboxvideo/vbox_drv.c| 280 ++
 drivers/gpu/drm/vboxvideo/vbox_drv.h| 284 ++
 drivers/gpu/drm/vboxvideo/vbox_fb.c | 166 
 drivers/gpu/drm/vboxvideo/vbox_hgsmi.c  |  95 ++
 drivers/gpu/drm/vboxvideo/vbox_irq.c| 177 
 drivers/gpu/drm/vboxvideo/vbox_main.c   | 361 
 drivers/gpu/drm/vboxvideo/vbox_mode.c   | 954 
 drivers/gpu/drm/vboxvideo/vbox_prime.c  |  56 ++
 drivers/gpu/drm/vboxvideo/vbox_ttm.c| 451 +
 drivers/gpu/drm/vboxvideo/vboxvideo.h   | 442 +
 drivers/gpu/drm/vboxvideo/vboxvideo_guest.h |  61 ++
 drivers/gpu/drm/vboxvideo/vboxvideo_vbe.h   |  54 ++
 drivers/gpu/drm/vboxvideo/vbva_base.c   | 214 +
 drivers/staging/Kconfig |   2 -
 drivers/staging/Makefile|   1 -
 25 files changed, 4096 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/vboxvideo/Kconfig
 create mode 100644 drivers/gpu/drm/vboxvideo/Makefile
 create mode 100644 drivers/gpu/drm/vboxvideo/hgsmi_base.c
 create mode 100644 drivers/gpu/drm/vboxvideo/hgsmi_ch_setup.h
 create mode 100644 drivers/gpu/drm/vboxvideo/hgsmi_channels.h
 create mode 100644 drivers/gpu/drm/vboxvideo/hgsmi_defs.h
 create mode 100644 drivers/gpu/drm/vboxvideo/modesetting.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_drv.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_drv.h
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_fb.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_hgsmi.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_irq.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_main.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_mode.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_prime.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vbox_ttm.c
 create mode 100644 drivers/gpu/drm/vboxvideo/vboxvideo.h
 create mode 100644 drivers/gpu/drm/vboxvideo/vboxvideo_guest.h
 create mode 100644 drivers/gpu/drm/vboxvideo/vboxvideo_vbe.h
 create mode 100644 drivers/gpu/drm/vboxvideo/vbva_base.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ba9e5da792ea..503e0dc84697 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15606,6 +15606,12 @@ S: Maintained
 F: drivers/virtio/virtio_input.c
 F: include/uapi/linux/virtio_input.h
 
+VIRTUAL BOX DRM DRIVER
+M: Hans de Goede 
+L: dri-de...@lists.freedesktop.org
+S: Maintained
+F: drivers/gpu/drm/vboxvideo/
+
 VIRTUAL BOX GUEST DEVICE DRIVER
 M: Hans de Goede 
 M: Arnd Bergmann 
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index cb88528e7b10..6b4d6c957da8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -315,6 +315,8 @@ source "drivers/gpu/drm/tve200/Kconfig"
 
 source "drivers/gpu/drm/xen/Kconfig"
 
+source "drivers/gpu/drm/vboxvideo/Kconfig"
+
 # Keep legacy drivers last
 
 menuconfig DRM_LEGACY
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index a6771cef85e2..133606802300 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -107,3 +107,4 @@ obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
 obj-$(CONFIG_DRM_PL111) += pl111/
 obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
+obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
diff --git a/drivers/gpu/drm/vboxvideo/Kconfig 
b/drivers/gpu/drm/vboxvideo/Kconfig
new file mode 100644
index ..1f4182e2e980
--- /dev/null
+++ b/drivers/gpu/drm/vboxvideo/Kconfig
@@ -0,0 +1,15 @@
+config DRM_VBOXVIDEO
+   tristate "Virtual Box Graphics Card"
+   depends on DRM && X86 && PCI
+   select DRM_KMS_HELPER
+   select DRM_TTM
+   select GENERIC_ALLOCATOR
+   help
+ This is a KMS driver for the virtual Graphics Card used in
+ Virtual Box virtual machines.
+
+ Although it is possible to build this driver built-in to the
+ kernel, it is

[PATCH 0/1] drm/vboxvideo: Move vboxvideo driver out of staging

2018-10-18 Thread Hans de Goede
Hi All,

Here is a patch wich adds a copy of the vboxvideo driver from staging
(as it will look like after the cleanup series I just posted).

The purpose of posting this as a copy rather then a patch just moving
the files is to give the DRM maintainers a chance to do a review before
it gets merged. With would not be possible with a patch with only file
renames in there.

I can post a patch doing the actual move / rename once the DRM maintainers
are happy with the code in staging.

About a patch doing the actual move, Greg, any tips on how to merge that
since it will be touching 2 trees and your staging tree will have the
last round of cleanups I presume.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] staging: vboxvideo: Stop disabling/enabling accel support on master set / drop

2018-10-18 Thread Hans de Goede
Userspace mode-setting (and thus also VESA) is not supported together with
modesetting. KMS userspace apps not properly marking the framebuffer as
dirty are also not supported.

So stop trying to accommodate this and simply enable accel
once at driver init.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c  | 19 -
 drivers/staging/vboxvideo/vbox_drv.h  |  2 -
 drivers/staging/vboxvideo/vbox_main.c | 60 +++
 3 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index ef4db193317b..d7440b9e5eea 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -207,21 +207,6 @@ static int vbox_master_set(struct drm_device *dev,
 */
vbox->initial_mode_queried = false;
 
-   mutex_lock(&vbox->hw_mutex);
-   /*
-* Disable VBVA when someone releases master in case the next person
-* tries tries to do VESA.
-*/
-   /** @todo work out if anyone is likely to and whether it will work. */
-   /*
-* Update: we also disable it because if the new master does not do
-* dirty rectangle reporting (e.g. old versions of Plymouth) then at
-* least the first screen will still be updated. We enable it as soon
-* as we receive a dirty rectangle report.
-*/
-   vbox_disable_accel(vbox);
-   mutex_unlock(&vbox->hw_mutex);
-
return 0;
 }
 
@@ -231,10 +216,6 @@ static void vbox_master_drop(struct drm_device *dev, 
struct drm_file *file_priv)
 
/* See vbox_master_set() */
vbox->initial_mode_queried = false;
-
-   mutex_lock(&vbox->hw_mutex);
-   vbox_disable_accel(vbox);
-   mutex_unlock(&vbox->hw_mutex);
 }
 
 static struct drm_driver driver = {
diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 57e9f1f3ba65..f82e594eca4b 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -166,8 +166,6 @@ void vbox_mode_fini(struct vbox_private *vbox);
 
 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
 
-void vbox_enable_accel(struct vbox_private *vbox);
-void vbox_disable_accel(struct vbox_private *vbox);
 void vbox_report_caps(struct vbox_private *vbox);
 
 void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 154afac28dda..1328f82a083d 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -27,40 +27,6 @@ static void vbox_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
kfree(fb);
 }
 
-void vbox_enable_accel(struct vbox_private *vbox)
-{
-   unsigned int i;
-   struct vbva_buffer *vbva;
-
-   if (!vbox->vbva_info || !vbox->vbva_buffers) {
-   /* Should never happen... */
-   DRM_ERROR("vboxvideo: failed to set up VBVA.\n");
-   return;
-   }
-
-   for (i = 0; i < vbox->num_crtcs; ++i) {
-   if (vbox->vbva_info[i].vbva)
-   continue;
-
-   vbva = (void __force *)vbox->vbva_buffers +
-   i * VBVA_MIN_BUFFER_SIZE;
-   if (!vbva_enable(&vbox->vbva_info[i],
-vbox->guest_pool, vbva, i)) {
-   /* very old host or driver error. */
-   DRM_ERROR("vboxvideo: vbva_enable failed\n");
-   return;
-   }
-   }
-}
-
-void vbox_disable_accel(struct vbox_private *vbox)
-{
-   unsigned int i;
-
-   for (i = 0; i < vbox->num_crtcs; ++i)
-   vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
-}
-
 void vbox_report_caps(struct vbox_private *vbox)
 {
u32 caps = VBVACAPS_DISABLE_CURSOR_INTEGRATION |
@@ -72,12 +38,7 @@ void vbox_report_caps(struct vbox_private *vbox)
hgsmi_send_caps_info(vbox->guest_pool, caps);
 }
 
-/*
- * Send information about dirty rectangles to VBVA.  If necessary we enable
- * VBVA first, as this is normally disabled after a change of master in case
- * the new master does not send dirty rectangle information (is this even
- * allowed?)
- */
+/* Send information about dirty rectangles to VBVA. */
 void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
   struct drm_clip_rect *rects,
   unsigned int num_rects)
@@ -97,8 +58,6 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer 
*fb,
crtc_x = crtc->primary->state->src_x >> 16;
crtc_y = crtc->primary->state->src_y >> 16;
 
-   vbox_enable_accel(vbox);
-
for (i = 0; i < num_rects; 

[PATCH 5/6] staging: vboxvideo: Change licence headers over to SPDX

2018-10-18 Thread Hans de Goede
All the files contain a MIT license header, replace this with:
SPDX-License-Identifier: MIT

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/hgsmi_base.c  | 23 ++--
 drivers/staging/vboxvideo/hgsmi_ch_setup.h  | 23 ++--
 drivers/staging/vboxvideo/hgsmi_channels.h  | 23 ++--
 drivers/staging/vboxvideo/hgsmi_defs.h  | 23 ++--
 drivers/staging/vboxvideo/modesetting.c | 23 ++--
 drivers/staging/vboxvideo/vbox_drv.c| 22 +--
 drivers/staging/vboxvideo/vbox_drv.h| 22 +--
 drivers/staging/vboxvideo/vbox_fb.c | 22 +--
 drivers/staging/vboxvideo/vbox_hgsmi.c  | 22 +--
 drivers/staging/vboxvideo/vbox_irq.c| 20 +
 drivers/staging/vboxvideo/vbox_main.c   | 22 +--
 drivers/staging/vboxvideo/vbox_mode.c   | 24 +
 drivers/staging/vboxvideo/vbox_prime.c  | 20 +
 drivers/staging/vboxvideo/vbox_ttm.c| 23 +---
 drivers/staging/vboxvideo/vboxvideo.h   | 24 ++---
 drivers/staging/vboxvideo/vboxvideo_guest.h | 23 ++--
 drivers/staging/vboxvideo/vboxvideo_vbe.h   | 23 ++--
 drivers/staging/vboxvideo/vbva_base.c   | 23 ++--
 18 files changed, 27 insertions(+), 378 deletions(-)

diff --git a/drivers/staging/vboxvideo/hgsmi_base.c 
b/drivers/staging/vboxvideo/hgsmi_base.c
index 3e1c578123f6..361d3193258e 100644
--- a/drivers/staging/vboxvideo/hgsmi_base.c
+++ b/drivers/staging/vboxvideo/hgsmi_base.c
@@ -1,24 +1,5 @@
-/*
- * Copyright (C) 2006-2017 Oracle Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
+// SPDX-License-Identifier: MIT
+/* Copyright (C) 2006-2017 Oracle Corporation */
 
 #include 
 #include "vbox_drv.h"
diff --git a/drivers/staging/vboxvideo/hgsmi_ch_setup.h 
b/drivers/staging/vboxvideo/hgsmi_ch_setup.h
index 3c3f82eb7909..4e93418d6a13 100644
--- a/drivers/staging/vboxvideo/hgsmi_ch_setup.h
+++ b/drivers/staging/vboxvideo/hgsmi_ch_setup.h
@@ -1,24 +1,5 @@
-/*
- * Copyright (C) 2006-2017 Oracle Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
+/* SPDX-License-Identifier: MIT */
+/* Copyright (C) 2006-2017 Oracle Corporation */
 
 #ifndef __HGSMI_CH_SETUP_H__
 #define __HGSMI_CH_SETUP_H__
diff --git a/drivers/staging/vboxvideo/hgsmi_channels.h 
b/drivers/staging/vboxvideo/hgsmi_channels.h
index a2a34b2167b4..9b83f4ff3faf 100644
--- a/drivers/staging/vboxvideo/hgsmi_channels.h
+++ b/drivers/staging/vboxvideo/hgsmi_channels.h
@@ -1,24 +1,5 @@
-/*
- * Copyright (C) 2006-2017 Oracle Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and assoc

[PATCH 4/6] staging: vboxvideo: Cleanup the comments

2018-10-18 Thread Hans de Goede
Some comments where still using docbook style comments, move these
either over to kerneldoc, or just make them regular comments.

Also remove a bunch of obsolete comments.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/hgsmi_base.c  |  72 +---
 drivers/staging/vboxvideo/hgsmi_ch_setup.h  |  17 +--
 drivers/staging/vboxvideo/modesetting.c |  44 
 drivers/staging/vboxvideo/vbox_drv.h|  10 +-
 drivers/staging/vboxvideo/vbox_irq.c|   6 +-
 drivers/staging/vboxvideo/vbox_main.c   |   8 +-
 drivers/staging/vboxvideo/vbox_mode.c   |  12 +-
 drivers/staging/vboxvideo/vbox_ttm.c|   8 +-
 drivers/staging/vboxvideo/vboxvideo.h   | 119 
 drivers/staging/vboxvideo/vboxvideo_guest.h |  27 +
 drivers/staging/vboxvideo/vboxvideo_vbe.h   |  11 --
 11 files changed, 117 insertions(+), 217 deletions(-)

diff --git a/drivers/staging/vboxvideo/hgsmi_base.c 
b/drivers/staging/vboxvideo/hgsmi_base.c
index 89a7cc989d5b..3e1c578123f6 100644
--- a/drivers/staging/vboxvideo/hgsmi_base.c
+++ b/drivers/staging/vboxvideo/hgsmi_base.c
@@ -29,9 +29,9 @@
 
 /**
  * Inform the host of the location of the host flags in VRAM via an HGSMI cmd.
- * @paramctx  the context of the guest heap to use.
- * @paramlocation the offset chosen for the flags within guest VRAM.
- * @returns 0 on success, -errno on failure
+ * Return: 0 or negative errno value.
+ * @ctx:The context of the guest heap to use.
+ * @location:   The offset chosen for the flags within guest VRAM.
  */
 int hgsmi_report_flags_location(struct gen_pool *ctx, u32 location)
 {
@@ -53,9 +53,9 @@ int hgsmi_report_flags_location(struct gen_pool *ctx, u32 
location)
 
 /**
  * Notify the host of HGSMI-related guest capabilities via an HGSMI command.
- * @paramctx the context of the guest heap to use.
- * @paramcapsthe capabilities to report, see vbva_caps.
- * @returns 0 on success, -errno on failure
+ * Return: 0 or negative errno value.
+ * @ctx:The context of the guest heap to use.
+ * @caps:   The capabilities to report, see vbva_caps.
  */
 int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps)
 {
@@ -91,11 +91,10 @@ int hgsmi_test_query_conf(struct gen_pool *ctx)
 
 /**
  * Query the host for an HGSMI configuration parameter via an HGSMI command.
- * @param  ctxthe context containing the heap used
- * @param  index  the index of the parameter to query,
- *@see vbva_conf32::index
- * @param  value_ret  where to store the value of the parameter on success
- * @returns 0 on success, -errno on failure
+ * Return: 0 or negative errno value.
+ * @ctx:The context containing the heap used.
+ * @index:  The index of the parameter to query.
+ * @value_ret:  Where to store the value of the parameter on success.
  */
 int hgsmi_query_conf(struct gen_pool *ctx, u32 index, u32 *value_ret)
 {
@@ -120,16 +119,15 @@ int hgsmi_query_conf(struct gen_pool *ctx, u32 index, u32 
*value_ret)
 
 /**
  * Pass the host a new mouse pointer shape via an HGSMI command.
- *
- * @param  ctx  the context containing the heap to be used
- * @param  flagscursor flags, @see VMMDevReqMousePointer::flags
- * @param  hot_xhorizontal position of the hot spot
- * @param  hot_yvertical position of the hot spot
- * @param  widthwidth in pixels of the cursor
- * @param  height   height in pixels of the cursor
- * @param  pixels   pixel data, @see VMMDevReqMousePointer for the format
- * @param  len  size in bytes of the pixel data
- * @returns 0 on success, -errno on failure
+ * Return: 0 or negative errno value.
+ * @ctx:The context containing the heap to be used.
+ * @flags:  Cursor flags.
+ * @hot_x:  Horizontal position of the hot spot.
+ * @hot_y:  Vertical position of the hot spot.
+ * @width:  Width in pixels of the cursor.
+ * @height: Height in pixels of the cursor.
+ * @pixels: Pixel data, @see VMMDevReqMousePointer for the format.
+ * @len:Size in bytes of the pixel data.
  */
 int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags,
   u32 hot_x, u32 hot_y, u32 width, u32 height,
@@ -195,13 +193,13 @@ int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 
flags,
  * Report the guest cursor position.  The host may wish to use this information
  * to re-position its own cursor (though this is currently unlikely).  The
  * current host cursor position is returned.
- * @param  ctx  The context containing the heap used.
- * @param  report_position  Are we reporting a position?
- * @param  xGuest cursor X position.
- * @param  yGuest cursor Y position.
- * @param  x_host   Host cursor X position is stored here.  Optional.
- * @param  y_host   Host cursor Y position is stored here.  Optional.
- * @returns 0 on success, -errno on failure

[PATCH 2/6] staging: vboxvideo: Keep old mode when disable crtc

2018-10-18 Thread Hans de Goede
On DPMS off we get a call to vbx_crtc_atomic_disable, followed by
a call to vbox_primary_atomic_update, at which point crtc_state->enable
is 0 and crtc_state->mode has been zero-ed. On a 0 width/height
vbox_do_modeset() falls back to 640x480, so this causes the guest Window
(its "monitor") to resize to 640x480 (and become black).

This commit makes us not look at crtc_state->mode when crtc_state->enable
is not set, so that we keep the old mode and just make the window go black.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 90486cf573cd..901a2a4b0848 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -190,7 +190,6 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 
 static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
-   struct drm_display_mode *mode,
int x, int y)
 {
struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
@@ -200,8 +199,11 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
 
mutex_lock(&vbox->hw_mutex);
 
-   vbox_crtc->width = mode->hdisplay;
-   vbox_crtc->height = mode->vdisplay;
+   if (crtc->state->enable) {
+   vbox_crtc->width = crtc->state->mode.hdisplay;
+   vbox_crtc->height = crtc->state->mode.vdisplay;
+   }
+
vbox_crtc->x = x;
vbox_crtc->y = y;
vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo);
@@ -301,7 +303,7 @@ static void vbox_primary_atomic_update(struct drm_plane 
*plane,
struct drm_crtc *crtc = plane->state->crtc;
struct drm_framebuffer *fb = plane->state->fb;
 
-   vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode,
+   vbox_crtc_set_base_and_mode(crtc, fb,
plane->state->src_x >> 16,
plane->state->src_y >> 16);
 }
@@ -312,7 +314,7 @@ static void vbox_primary_atomic_disable(struct drm_plane 
*plane,
struct drm_crtc *crtc = old_state->crtc;
 
/* vbox_do_modeset checks plane->state->fb and will disable if NULL */
-   vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode,
+   vbox_crtc_set_base_and_mode(crtc, old_state->fb,
old_state->src_x >> 16,
old_state->src_y >> 16);
 }
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] staging: vboxvideo: Drop duplicate vbox_err.h file

2018-10-18 Thread Hans de Goede
Switch to the more complete vbox_err.h file from include/linux which got
added with the merging of the vboxguest driver.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/hgsmi_base.c  |  4 +-
 drivers/staging/vboxvideo/modesetting.c |  4 +-
 drivers/staging/vboxvideo/vbox_err.h| 50 -
 drivers/staging/vboxvideo/vbox_main.c   |  3 +-
 drivers/staging/vboxvideo/vbva_base.c   |  4 +-
 5 files changed, 8 insertions(+), 57 deletions(-)
 delete mode 100644 drivers/staging/vboxvideo/vbox_err.h

diff --git a/drivers/staging/vboxvideo/hgsmi_base.c 
b/drivers/staging/vboxvideo/hgsmi_base.c
index 15ff5f42e2cd..89a7cc989d5b 100644
--- a/drivers/staging/vboxvideo/hgsmi_base.c
+++ b/drivers/staging/vboxvideo/hgsmi_base.c
@@ -20,8 +20,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include 
 #include "vbox_drv.h"
-#include "vbox_err.h"
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
 #include "hgsmi_channels.h"
@@ -70,7 +70,7 @@ int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps)
 
hgsmi_buffer_submit(ctx, p);
 
-   WARN_ON_ONCE(RT_FAILURE(p->rc));
+   WARN_ON_ONCE(p->rc < 0);
 
hgsmi_buffer_free(ctx, p);
 
diff --git a/drivers/staging/vboxvideo/modesetting.c 
b/drivers/staging/vboxvideo/modesetting.c
index 7616b8aab23a..e49c2c779726 100644
--- a/drivers/staging/vboxvideo/modesetting.c
+++ b/drivers/staging/vboxvideo/modesetting.c
@@ -20,8 +20,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include 
 #include "vbox_drv.h"
-#include "vbox_err.h"
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
 #include "hgsmi_channels.h"
@@ -130,7 +130,7 @@ int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int 
screens,
 
hgsmi_buffer_submit(ctx, p);
 
-   if (RT_FAILURE(p->rc)) {
+   if (p->rc < 0) {
hgsmi_buffer_free(ctx, p);
return -EIO;
}
diff --git a/drivers/staging/vboxvideo/vbox_err.h 
b/drivers/staging/vboxvideo/vbox_err.h
deleted file mode 100644
index 562db8630eb0..
--- a/drivers/staging/vboxvideo/vbox_err.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2017 Oracle Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef __VBOX_ERR_H__
-#define __VBOX_ERR_H__
-
-/**
- * @name VirtualBox virtual-hardware error macros
- * @{
- */
-
-#define VINF_SUCCESS0
-#define VERR_INVALID_PARAMETER  (-2)
-#define VERR_INVALID_POINTER(-6)
-#define VERR_NO_MEMORY  (-8)
-#define VERR_NOT_IMPLEMENTED(-12)
-#define VERR_INVALID_FUNCTION   (-36)
-#define VERR_NOT_SUPPORTED  (-37)
-#define VERR_TOO_MUCH_DATA  (-42)
-#define VERR_INVALID_STATE  (-79)
-#define VERR_OUT_OF_RESOURCES   (-80)
-#define VERR_ALREADY_EXISTS (-105)
-#define VERR_INTERNAL_ERROR (-225)
-
-#define RT_SUCCESS_NP(rc)   ((int)(rc) >= VINF_SUCCESS)
-#define RT_SUCCESS(rc)  (likely(RT_SUCCESS_NP(rc)))
-#define RT_FAILURE(rc)  (unlikely(!RT_SUCCESS_NP(rc)))
-
-/** @}  */
-
-#endif
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 7466c1103ff6..053dbad0ec23 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -27,11 +27,12 @@
  *  Michael Thayer 
  */
+
+#include 
 #include 
 #include 
 
 #include "vbox_drv.h"
-#include "vbox_err.h"
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
 
diff --git a/drivers/staging/vboxvideo/vbva_base.c 
b/drivers/staging/vboxvideo/vbva_base.c
index c10c782f94e1..42b02e1194f5 100644
--- a/drivers/staging/vboxvideo/vbva_base.c
+++ b/drivers/stagin

[PATCH 1/6] staging: vboxvideo: Stop accessing crtc_state->active

2018-10-18 Thread Hans de Goede
Atomic modesetting drivers should never check crtc_state->active directly,
instead check crtc_state->enable.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 6acc965247ff..90486cf573cd 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,7 +84,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
 
flags = VBVA_SCREEN_F_ACTIVE;
-   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->enable) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vboxvideo: make a couple of funcs static

2018-10-11 Thread Hans de Goede

Hi,

On 10-10-18 22:17, Craig Kewley wrote:

Fix Sparse warnings:
drivers/staging/vboxvideo/vbox_mode.c:309:6: warning:
symbol 'vbox_primary_atomic_disable' was not declared. Should it be static?

drivers/staging/vboxvideo/vbox_mode.c:452:6: warning:
symbol 'vbox_cursor_atomic_disable' was not declared. Should it be static?

Signed-off-by: Craig Kewley 


Thanks.

Reviewed-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/vboxvideo/vbox_mode.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 042e4f384df9..deed28c7a1db 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -306,8 +306,8 @@ static void vbox_primary_atomic_update(struct drm_plane 
*plane,
plane->state->src_y >> 16);
  }
  
-void vbox_primary_atomic_disable(struct drm_plane *plane,

-struct drm_plane_state *old_state)
+static void vbox_primary_atomic_disable(struct drm_plane *plane,
+   struct drm_plane_state *old_state)
  {
struct drm_crtc *crtc = old_state->crtc;
  
@@ -449,8 +449,8 @@ static void vbox_cursor_atomic_update(struct drm_plane *plane,

mutex_unlock(&vbox->hw_mutex);
  }
  
-void vbox_cursor_atomic_disable(struct drm_plane *plane,

-   struct drm_plane_state *old_state)
+static void vbox_cursor_atomic_disable(struct drm_plane *plane,
+  struct drm_plane_state *old_state)
  {
struct vbox_private *vbox =
container_of(plane->dev, struct vbox_private, ddev);


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vboxvideo: unlock on error in vbox_cursor_atomic_update()

2018-10-11 Thread Hans de Goede

Hi,

On 11-10-18 09:59, Dan Carpenter wrote:

We need to unlock before returning on this error path.

Fixes: 35f3288c453e ("staging: vboxvideo: Atomic phase 1: convert cursor to 
universal plane")
Signed-off-by: Dan Carpenter 


Thanks, the kbuild test robot had already notified me about this
but I did not get around to fixing it yet.

Fix looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 042e4f384df9..78a9c9b13ff6 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -424,6 +424,7 @@ static void vbox_cursor_atomic_update(struct drm_plane 
*plane,
/* pinning is done in prepare/cleanup framebuffer */
src = vbox_bo_kmap(bo);
if (IS_ERR(src)) {
+   mutex_unlock(&vbox->hw_mutex);
DRM_WARN("Could not kmap cursor bo, skipping update\n");
return;
}


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API

2018-10-06 Thread Hans de Goede

Hi,

On 05-10-18 18:01, Daniel Vetter wrote:

On Mon, Oct 01, 2018 at 11:20:04AM +0200, Hans de Goede wrote:

Hi,

On 01-10-18 09:25, Dan Carpenter wrote:

Why are you resending this?  It's because you added some more patches
on the end?  Just send those as a new series...


I accidentally numbered the cover-letter of the original series
01/15 instea dof 00/15 this confused Greg, so he asked for a resend.

Nothing is changed in the resend, otherwise I would have made
the series a v2 and not a resend.


I'm assuming this all lands for 4.20/5.0,


Yes Greg has the entire series queued up in staging-next.

Regards,

Hans
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-10-02 Thread Hans de Goede

Hi,

On 02-10-18 00:01, Daniel Vetter wrote:

On Mon, Oct 1, 2018 at 11:14 PM Hans de Goede  wrote:


Hi,

On 01-10-18 18:52, Daniel Vetter wrote:

On Mon, Oct 01, 2018 at 11:37:29AM +0200, Hans de Goede wrote:

Hi,

On 01-10-18 09:53, Daniel Vetter wrote:

On Wed, Sep 26, 2018 at 09:42:02PM +0200, Hans de Goede wrote:

Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 


Are you sure this does what you want it to do? Atomic helpers fully shut
down the screen when you do a dpms off, "just blanked" kinda doesn't exist
as a state by default.


Yes I'm sure I tested "xset dpms force off" and before this would
result in in the virtual monitors (just windows on the host) to resize to
640x480 and in that 640x480 still show part of the old contents.


Hm, this sounds a bit like a bug in your code somewhere, or at least not
100% converted over to atomic. From a driver pov it should be 100%
equivalent code between dpms off and the xrandr --off. If dpms shows some
garbage without this, then something is wrong.


I believe the 2 paths are different, xrandr --off actually does a modeset
disabling the crtc, where as xset dpms force off just changes the DPMS
property on the connector using the non atomic property ioctls leading to
the following call graph:

drm_mode_obj_set_property_ioctl()
set_property_atomic()
drm_atomic_connector_commit_dpms()

With the last one iterating over all connectors of the crtc to which
the connector in question is connected and then setting
crtc_state->active = false if all connectors have their dpms value
set to a value != DRM_MODE_DPMS_ON.

Followed by a drm_atomic_commit() so all that changes in this code
path is the active property of the crtc_state. Where as with a --off the
primary plane_state will get its fb (and crtc) set to NULL.


You're supposed to scan out black in this case, that's correct. But
you're also supposed to switch of the screen (well, scan out black
since that's all vbox allows from the guest side) if your
crtc_funcs->atomic_disable is called.

I think the correct fix is to just shut down the display
unconditionally in atomic_disable, and ignore ->active. The helpers
should take care of things for you already.


Currently my atomic_disable for the crtc is empty, so that may well be
the culprit. Can I just make this point to 
drm_atomic_helper_disable_planes_on_crtc ?
and do I need to do anything in atomic_enable to undo this then or will
the planes get re-enabled by the atomic core?


Also: plane going NULL is a side effect of the SETCRTC legacy2atomic
code only, for an atomic CRTC OFF you can see a disabled CRTC, but the
primary plane still having an attached framebuffer. Iirc
drm_plane_state->crtc will be set to NULL.


I do not think that that is correct, from include/drm/drm_atomic_helper.h:

static inline bool
drm_atomic_plane_disabling(struct drm_plane_state *old_plane_state,
   struct drm_plane_state *new_plane_state)
{
/*
 * When disabling a plane, CRTC and FB should always be NULL together.
 * Anything else should be considered a bug in the atomic core, so we
 * gently warn about it.
 */
WARN_ON((new_plane_state->crtc == NULL && new_plane_state->fb != NULL) |
(new_plane_state->crtc != NULL && new_plane_state->fb == NULL));

return old_plane_state->crtc && !new_plane_state->crtc;
}

So crtc->primary->state->fb will be NULL when crtc->primary->state->crtc is 
NULL.

I guess both could be non NULL but crtc->state->enable is false ?


So you need this code in
both cases, not only when active changes (but active will be clamped
to false when disabling the CRTC, so checking for ->active is simply
redundant).



The only difference is that for dpms off the helpers don't call
->cleanup_plane (and then ->prepare_plane on re-enabling), since the
framebuffers are supposed to stick around. Are you perchance doing some
modeset programming in there? That would be a bug in the atomic
implementation.

crtc_state->active should only be consulted from atomic_check callbacks.
I've added some pretty lengthy kerneldoc for this just recently, to
explain better how this is supposed to work.


See above, I believe that the code path which I point out changes
crtc_state->active without making any further changes.


Yup, that's all correct. It's just that your driver code shouldn't
need to look at this. See the kernel-doc for drm_crtc->active in
latest upstream.


Ok, I will take a look at this, I probably will not get around to this next
week. ATM I'm fixing some high prio bootsplash (plymouth) bugs related to
the flickerfree work for Fedora 29: 
https://hansdegoede.livejournal.com/19224.html


Re: [PATCH 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-10-01 Thread Hans de Goede

Hi,

On 01-10-18 18:52, Daniel Vetter wrote:

On Mon, Oct 01, 2018 at 11:37:29AM +0200, Hans de Goede wrote:

Hi,

On 01-10-18 09:53, Daniel Vetter wrote:

On Wed, Sep 26, 2018 at 09:42:02PM +0200, Hans de Goede wrote:

Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 


Are you sure this does what you want it to do? Atomic helpers fully shut
down the screen when you do a dpms off, "just blanked" kinda doesn't exist
as a state by default.


Yes I'm sure I tested "xset dpms force off" and before this would
result in in the virtual monitors (just windows on the host) to resize to
640x480 and in that 640x480 still show part of the old contents.


Hm, this sounds a bit like a bug in your code somewhere, or at least not
100% converted over to atomic. From a driver pov it should be 100%
equivalent code between dpms off and the xrandr --off. If dpms shows some
garbage without this, then something is wrong.


I believe the 2 paths are different, xrandr --off actually does a modeset
disabling the crtc, where as xset dpms force off just changes the DPMS
property on the connector using the non atomic property ioctls leading to
the following call graph:

drm_mode_obj_set_property_ioctl()
set_property_atomic()
drm_atomic_connector_commit_dpms()

With the last one iterating over all connectors of the crtc to which
the connector in question is connected and then setting
crtc_state->active = false if all connectors have their dpms value
set to a value != DRM_MODE_DPMS_ON.

Followed by a drm_atomic_commit() so all that changes in this code
path is the active property of the crtc_state. Where as with a --off the
primary plane_state will get its fb (and crtc) set to NULL.


The only difference is that for dpms off the helpers don't call
->cleanup_plane (and then ->prepare_plane on re-enabling), since the
framebuffers are supposed to stick around. Are you perchance doing some
modeset programming in there? That would be a bug in the atomic
implementation.

crtc_state->active should only be consulted from atomic_check callbacks.
I've added some pretty lengthy kerneldoc for this just recently, to
explain better how this is supposed to work.


See above, I believe that the code path which I point out changes
crtc_state->active without making any further changes.

I'm pretty new to all this, so I could be wrong, but this is what
I believe is happening.

Regards,

Hans







After this patch they become black instead.

Note somewhat related, Virtualbox does not allow closing a window from
within the guest, if the user wants to stop using an (extra) virtual monitor
it needs to be disabled in the VMs UI. Turning of a monitor through e.g.
"xrandr --output foo --off" just makes the window black.


Ok that's funny, but shouldn't be related to what's going on here.
-Daniel



Regards,

Hans





-Daniel


---
   drivers/staging/vboxvideo/vbox_drv.h  |  1 -
   drivers/staging/vboxvideo/vbox_mode.c | 28 ++-
   2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fccb3851d6a3..9cc20c182df1 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -139,7 +139,6 @@ struct vbox_connector {
   struct vbox_crtc {
struct drm_crtc base;
-   bool blanked;
bool disconnected;
unsigned int crtc_id;
u32 fb_offset;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index c4ec3fa49782..49ff9c4a6302 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
flags = VBVA_SCREEN_F_ACTIVE;
-   flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
   vbox_crtc->x * bpp / 8 +
vbox_crtc->y * pitch,
-  pitch, width, height,
-  vbox_crtc->blanked ? 0 : bpp, flags);
+  pitch, width, height, bpp, flags);
   }
   static int vbox_set_view(struct drm_crtc *crtc)
@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)
return 0;
   }
-static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = crtc->dev->dev_private;

Re: [PATCH 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-10-01 Thread Hans de Goede

Hi,

On 01-10-18 09:53, Daniel Vetter wrote:

On Wed, Sep 26, 2018 at 09:42:02PM +0200, Hans de Goede wrote:

Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 


Are you sure this does what you want it to do? Atomic helpers fully shut
down the screen when you do a dpms off, "just blanked" kinda doesn't exist
as a state by default.


Yes I'm sure I tested "xset dpms force off" and before this would
result in in the virtual monitors (just windows on the host) to resize to
640x480 and in that 640x480 still show part of the old contents.

After this patch they become black instead.

Note somewhat related, Virtualbox does not allow closing a window from
within the guest, if the user wants to stop using an (extra) virtual monitor
it needs to be disabled in the VMs UI. Turning of a monitor through e.g.
"xrandr --output foo --off" just makes the window black.

Regards,

Hans





-Daniel


---
  drivers/staging/vboxvideo/vbox_drv.h  |  1 -
  drivers/staging/vboxvideo/vbox_mode.c | 28 ++-
  2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fccb3851d6a3..9cc20c182df1 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -139,7 +139,6 @@ struct vbox_connector {
  
  struct vbox_crtc {

struct drm_crtc base;
-   bool blanked;
bool disconnected;
unsigned int crtc_id;
u32 fb_offset;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index c4ec3fa49782..49ff9c4a6302 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
  
  	flags = VBVA_SCREEN_F_ACTIVE;

-   flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
   vbox_crtc->x * bpp / 8 +
vbox_crtc->y * pitch,
-  pitch, width, height,
-  vbox_crtc->blanked ? 0 : bpp, flags);
+  pitch, width, height, bpp, flags);
  }
  
  static int vbox_set_view(struct drm_crtc *crtc)

@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)
return 0;
  }
  
-static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)

-{
-   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = crtc->dev->dev_private;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   vbox_crtc->blanked = false;
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   vbox_crtc->blanked = true;
-   break;
-   }
-
-   mutex_lock(&vbox->hw_mutex);
-   vbox_do_modeset(crtc);
-   mutex_unlock(&vbox->hw_mutex);
-}
-
  /*
   * Try to map the layout of virtual screens to the range of the input device.
   * Return true if we need to re-set the crtc modes due to screen offset
@@ -276,7 +254,6 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
  }
  
  static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {

-   .dpms = vbox_crtc_dpms,
.disable = vbox_crtc_disable,
.commit = vbox_crtc_commit,
.atomic_flush = vbox_crtc_atomic_flush,
@@ -861,7 +838,6 @@ static const struct drm_connector_helper_funcs 
vbox_connector_helper_funcs = {
  };
  
  static const struct drm_connector_funcs vbox_connector_funcs = {

-   .dpms = drm_helper_connector_dpms,
.detect = vbox_connector_detect,
.fill_modes = vbox_fill_modes,
.destroy = vbox_connector_destroy,
--
2.19.0

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



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API

2018-10-01 Thread Hans de Goede

Hi,

On 01-10-18 09:25, Dan Carpenter wrote:

Why are you resending this?  It's because you added some more patches
on the end?  Just send those as a new series...


I accidentally numbered the cover-letter of the original series
01/15 instea dof 00/15 this confused Greg, so he asked for a resend.

Nothing is changed in the resend, otherwise I would have made
the series a v2 and not a resend.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] staging: vboxvideo: Convert to atomic modesetting API

2018-10-01 Thread Hans de Goede

Hi,

On 01-10-18 09:51, Daniel Vetter wrote:

On Wed, Sep 26, 2018 at 09:41:51PM +0200, Hans de Goede wrote:

Hi All,

This series converts the vboxvideo driver to the modesetting API, once this
is merged I will submit a patch to move the driver out of staging and into
drivers/gpu/drm.

This series consists of 3 parts:

1) More cleanups / prep work for atomic conversion
2) The actual atomic conversion, this is modelled after the atomic conversion
of the qxl driver done by Gabriel Krisman Bertazi. Gabriel if you are
reading this, thank you for providing a roadmap how to go about this.
3) Restore some features which were lost by the atomic conversion +
more cleanups


Given how tiny vbox is it's easier if I just review the overall diff I
think. Overall = patch that adds the entire driver to drm, ignoring what's
been going on in staging. Please reply with that (I can do it locally, but
that doesn't allow me to conveniently reply&comment).


Yes I was planning on submitting a patch to move this out of staging and I
was expecting you (or other drm people) to review that.

I was waiting for things to be merged in staging first :)

I need to do one more bugfix for an issue kbuild caught and then I will
send the patch to move things.

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-29 Thread Hans de Goede

Hi,

On 28-09-18 14:38, Greg Kroah-Hartman wrote:

On Wed, Sep 26, 2018 at 09:41:52PM +0200, Hans de Goede wrote:

This cleanups 2 things:

1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.

2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.

Signed-off-by: Hans de Goede 


I have two patch 1/15 in this series, making it 16 patches?


It seems like I've accidentally numbered my cover-letter
as 01/15 instead of 00/15. Could that it be that that was the problem?


Something went odd on your end, can you please resend these properly?


Done.

Regards,

Hans
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-29 Thread Hans de Goede
This cleanups 2 things:

1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.

2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index bef99664d030..4f5d28aeca95 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -169,7 +169,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 {
struct drm_crtc *crtci;
struct drm_connector *connectori;
-   struct drm_framebuffer *fb1 = NULL;
+   struct drm_framebuffer *fb, *fb1 = NULL;
bool single_framebuffer = true;
bool old_single_framebuffer = vbox->single_framebuffer;
u16 width = 0, height = 0;
@@ -180,25 +180,25 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 * Same fall-back if this is the fbdev frame-buffer.
 */
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) {
+   fb = CRTC_FB(crtci);
+   if (!fb)
+   continue;
+
if (!fb1) {
-   fb1 = CRTC_FB(crtci);
+   fb1 = fb;
if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb)
break;
-   } else if (CRTC_FB(crtci) && fb1 != CRTC_FB(crtci)) {
+   } else if (fb != fb1) {
single_framebuffer = false;
}
}
+   if (!fb1)
+   return false;
+
if (single_framebuffer) {
vbox->single_framebuffer = true;
-   list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
-   head) {
-   if (!CRTC_FB(crtci))
-   continue;
-
-   vbox->input_mapping_width = CRTC_FB(crtci)->width;
-   vbox->input_mapping_height = CRTC_FB(crtci)->height;
-   break;
-   }
+   vbox->input_mapping_width = fb1->width;
+   vbox->input_mapping_height = fb1->height;
return old_single_framebuffer != vbox->single_framebuffer;
}
/* Otherwise calculate the total span of all screens. */
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 12/15] staging: vboxvideo: Replace crtc_helper enable/disable functions

2018-09-29 Thread Hans de Goede
Replace vbox_crtc_commit and vbox_crtc_disable with
vbox_crtc_atomic_[en|dis]able which are the preferred callbacks for
these for atomic drivers.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 49ff9c4a6302..72fc6614179a 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -229,11 +229,13 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_enable(struct drm_crtc *crtc,
+   struct drm_crtc_state *old_crtc_state)
 {
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_disable(struct drm_crtc *crtc,
+struct drm_crtc_state *old_crtc_state)
 {
 }
 
@@ -254,8 +256,8 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .disable = vbox_crtc_disable,
-   .commit = vbox_crtc_commit,
+   .atomic_enable = vbox_crtc_atomic_enable,
+   .atomic_disable = vbox_crtc_atomic_disable,
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 02/15] staging: vboxvideo: Remove empty encoder_helper_funcs

2018-09-29 Thread Hans de Goede
All the encoder_helper_funcs are optional, and even setting the
drm_encoder_helper_funcs vtable itself is optional and may be left out
when not using any of the helper funcs, so lets drop all of this.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 34 ---
 1 file changed, 34 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4f5d28aeca95..babb02a1ebf2 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -466,39 +466,6 @@ static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
 
-static void vbox_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-}
-
-static bool vbox_mode_fixup(struct drm_encoder *encoder,
-   const struct drm_display_mode *mode,
-   struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
-static void vbox_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void vbox_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void vbox_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static const struct drm_encoder_helper_funcs vbox_enc_helper_funcs = {
-   .dpms = vbox_encoder_dpms,
-   .mode_fixup = vbox_mode_fixup,
-   .prepare = vbox_encoder_prepare,
-   .commit = vbox_encoder_commit,
-   .mode_set = vbox_encoder_mode_set,
-};
-
 static struct drm_encoder *vbox_encoder_init(struct drm_device *dev,
 unsigned int i)
 {
@@ -510,7 +477,6 @@ static struct drm_encoder *vbox_encoder_init(struct 
drm_device *dev,
 
drm_encoder_init(dev, &vbox_encoder->base, &vbox_enc_funcs,
 DRM_MODE_ENCODER_DAC, NULL);
-   drm_encoder_helper_add(&vbox_encoder->base, &vbox_enc_helper_funcs);
 
vbox_encoder->base.possible_crtcs = 1 << i;
return &vbox_encoder->base;
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic

2018-09-29 Thread Hans de Goede
Now that the state objects are wired up, we can:

1) Move to the final atomic handlers
2) Wire up atomic set_config helper
3) Switch to drm_mode_config_helper_suspend/resume for suspend/resume
4) Enable atomic modesetting ioctl

This is all done in one commit because doing this piecemeal leads to
an intermediate state which triggers WARN_ONs in the atomic code because
e.g. plane->fb is still being set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/TODO|  1 -
 drivers/staging/vboxvideo/vbox_drv.c  | 40 +--
 drivers/staging/vboxvideo/vbox_mode.c | 35 +++
 3 files changed, 17 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/vboxvideo/TODO b/drivers/staging/vboxvideo/TODO
index 468eea856ca6..2e0f99c3f10c 100644
--- a/drivers/staging/vboxvideo/TODO
+++ b/drivers/staging/vboxvideo/TODO
@@ -1,5 +1,4 @@
 TODO:
--Move the driver over to the atomic API
 -Get a full review from the drm-maintainers on dri-devel done on this driver
 -Extend this TODO with the results of that review
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c6a53b0ad66c..c3e14107da0d 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -132,35 +132,16 @@ static void vbox_pci_remove(struct pci_dev *pdev)
drm_dev_put(&vbox->ddev);
 }
 
-static int vbox_drm_freeze(struct vbox_private *vbox)
-{
-   drm_kms_helper_poll_disable(&vbox->ddev);
-
-   pci_save_state(vbox->ddev.pdev);
-
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
-
-   return 0;
-}
-
-static int vbox_drm_thaw(struct vbox_private *vbox)
-{
-   drm_mode_config_reset(&vbox->ddev);
-   drm_helper_resume_force_mode(&vbox->ddev);
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false);
-
-   return 0;
-}
-
 static int vbox_pm_suspend(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
int error;
 
-   error = vbox_drm_freeze(vbox);
+   error = drm_mode_config_helper_suspend(&vbox->ddev);
if (error)
return error;
 
+   pci_save_state(vbox->ddev.pdev);
pci_disable_device(vbox->ddev.pdev);
pci_set_power_state(vbox->ddev.pdev, PCI_D3hot);
 
@@ -170,39 +151,32 @@ static int vbox_pm_suspend(struct device *dev)
 static int vbox_pm_resume(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
-   int ret;
 
if (pci_enable_device(vbox->ddev.pdev))
return -EIO;
 
-   ret = vbox_drm_thaw(vbox);
-   if (ret)
-   return ret;
-
-   drm_kms_helper_poll_enable(&vbox->ddev);
-
-   return 0;
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_freeze(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static int vbox_pm_thaw(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_thaw(vbox);
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_poweroff(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static const struct dev_pm_ops vbox_pm_ops = {
@@ -280,7 +254,7 @@ static void vbox_master_drop(struct drm_device *dev, struct 
drm_file *file_priv)
 static struct drm_driver driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
-   DRIVER_PRIME,
+   DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
.lastclose = vbox_driver_lastclose,
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 54e6aac784f7..69a1e6c163b9 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -148,13 +148,6 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
mutex_unlock(&vbox->hw_mutex);
 }
 
-static bool vbox_crtc_mode_fixup(struct drm_crtc *crtc,
-const struct drm_display_mode *mode,
-struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -260,19 +253,10 @@ static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
-{
- 

[PATCH resend 05/15] staging: vboxvideo: Atomic phase 1: convert cursor to universal plane

2018-09-29 Thread Hans de Goede
In preparation for atomic conversion, let's use the transitional atomic
helpers drm_plane_helper_update/disable.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |   5 -
 drivers/staging/vboxvideo/vbox_mode.c | 386 +-
 2 files changed, 186 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 34c4d7fc6c8e..7fc668ff4465 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -116,11 +116,6 @@ struct vbox_private {
 * encompassing all screen ones or is the fbdev console active?
 */
bool single_framebuffer;
-   u32 cursor_width;
-   u32 cursor_height;
-   u32 cursor_hot_x;
-   u32 cursor_hot_y;
-   size_t cursor_data_size;
u8 cursor_data[CURSOR_DATA_SIZE];
 };
 
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e85b27f95def..75e112d33cf0 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -34,16 +34,12 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vbox_drv.h"
 #include "vboxvideo.h"
 #include "hgsmi_channels.h"
 
-static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
-   u32 handle, u32 width, u32 height,
-   s32 hot_x, s32 hot_y);
-static int vbox_cursor_move(struct drm_crtc *crtc, int x, int y);
-
 /**
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
@@ -318,14 +314,166 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .cursor_move = vbox_cursor_move,
-   .cursor_set2 = vbox_cursor_set2,
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_cursor_atomic_check(struct drm_plane *plane,
+   struct drm_plane_state *new_state)
+{
+   u32 width = new_state->crtc_w;
+   u32 height = new_state->crtc_h;
+
+   if (!new_state->fb)
+   return 0;
+
+   if (width > VBOX_MAX_CURSOR_WIDTH || height > VBOX_MAX_CURSOR_HEIGHT ||
+   width == 0 || height == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+/**
+ * Copy the ARGB image and generate the mask, which is needed in case the host
+ * does not support ARGB cursors.  The mask is a 1BPP bitmap with the bit set
+ * if the corresponding alpha value in the ARGB image is greater than 0xF0.
+ */
+static void copy_cursor_image(u8 *src, u8 *dst, u32 width, u32 height,
+ size_t mask_size)
+{
+   size_t line_size = (width + 7) / 8;
+   u32 i, j;
+
+   memcpy(dst + mask_size, src, width * height * 4);
+   for (i = 0; i < height; ++i)
+   for (j = 0; j < width; ++j)
+   if (((u32 *)src)[i * width + j] > 0xf000)
+   dst[i * line_size + j / 8] |= (0x80 >> (j % 8));
+}
+
+static void vbox_cursor_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+   struct vbox_private *vbox =
+   container_of(plane->dev, struct vbox_private, ddev);
+   struct vbox_crtc *vbox_crtc = to_vbox_crtc(plane->state->crtc);
+   struct drm_framebuffer *fb = plane->state->fb;
+   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
+   u32 width = plane->state->crtc_w;
+   u32 height = plane->state->crtc_h;
+   size_t data_size, mask_size;
+   u32 flags;
+   u8 *src;
+
+   /*
+* VirtualBox uses the host windowing system to draw the cursor so
+* moves are a no-op, we only need to upload new cursor sprites.
+*/
+   if (fb == old_state->fb)
+   return;
+
+   mutex_lock(&vbox->hw_mutex);
+
+   vbox_crtc->cursor_enabled = true;
+
+   /* pinning is done in prepare/cleanup framebuffer */
+   src = vbox_bo_kmap(bo);
+   if (IS_ERR(src)) {
+   DRM_WARN("Could not kmap cursor bo, skipping update\n");
+   return;
+   }
+
+   /*
+* The mask must be calculated based on the alpha
+* channel, one bit per ARGB word, and must be 32-bit
+* padded.
+*/
+   mask_size = ((width + 7) / 8 * height + 3) & ~3;
+   data_size = width * height * 4 + mask_size;
+
+   copy_cursor_image(src, vbox->cursor_data, width, height, mask_size);
+   vbox_bo_kunmap(bo);
+
+   flags = VBOX_MOUSE_POINTER_VISIBLE | VBOX_MOUSE_POINTER_SHAPE |
+   VBOX_MOUSE_PO

[PATCH resend 14/15] staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks

2018-09-29 Thread Hans de Goede
vbox_mode_valid always returns MODE_OK, which is also the default if no
mode_valid callback is defined.

vbox_best_single_encoder chains to drm_encoder_find, the drm-core will
call drm_encoder_find itself if there is no best_encoder call back.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4993a6cf6770..756544b53600 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -651,18 +651,6 @@ static void vbox_encoder_destroy(struct drm_encoder 
*encoder)
kfree(encoder);
 }
 
-static struct drm_encoder *vbox_best_single_encoder(struct drm_connector
-   *connector)
-{
-   int enc_id = connector->encoder_ids[0];
-
-   /* pick the encoder ids */
-   if (enc_id)
-   return drm_encoder_find(connector->dev, NULL, enc_id);
-
-   return NULL;
-}
-
 static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
@@ -820,12 +808,6 @@ static int vbox_get_modes(struct drm_connector *connector)
return num_modes;
 }
 
-static enum drm_mode_status vbox_mode_valid(struct drm_connector *connector,
-  struct drm_display_mode *mode)
-{
-   return MODE_OK;
-}
-
 static void vbox_connector_destroy(struct drm_connector *connector)
 {
drm_connector_unregister(connector);
@@ -862,9 +844,7 @@ static int vbox_fill_modes(struct drm_connector *connector, 
u32 max_x,
 }
 
 static const struct drm_connector_helper_funcs vbox_connector_helper_funcs = {
-   .mode_valid = vbox_mode_valid,
.get_modes = vbox_get_modes,
-   .best_encoder = vbox_best_single_encoder,
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 10/15] staging: vboxvideo: Restore page-flip support

2018-09-29 Thread Hans de Goede
Restore page-flip support now that the atomic conversion is complete.

Since the mode parameter to vbox_crtc_set_base_and_mode() now never
is NULL call drm_atomic_crtc_needs_modeset() to check if we need to
check for input-mapping changes, to avoid doing unnecesarry work on
a flip. And hookup the drm_atomic_helper_page_flip helper to implement
the page_flip callback.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 69a1e6c163b9..c4ec3fa49782 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -32,6 +32,7 @@
  *  Hans de Goede 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,6 +218,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
struct vbox_private *vbox = crtc->dev->dev_private;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
+   bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
mutex_lock(&vbox->hw_mutex);
 
@@ -227,7 +229,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo);
 
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
-   if (mode && vbox_set_up_input_mapping(vbox)) {
+   if (needs_modeset && vbox_set_up_input_mapping(vbox)) {
struct drm_crtc *crtci;
 
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
@@ -241,7 +243,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_set_view(crtc);
vbox_do_modeset(crtc);
 
-   if (mode)
+   if (needs_modeset)
hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
   vbox->input_mapping_width,
   vbox->input_mapping_height);
@@ -288,6 +290,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
+   .page_flip = drm_atomic_helper_page_flip,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
.reset = drm_atomic_helper_crtc_reset,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane

2018-09-29 Thread Hans de Goede
Use drm_plane_helpers for the primary plane and replace our custom
mode_set callback with drm_helper_crtc_mode_set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 116 --
 1 file changed, 90 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 75e112d33cf0..e560e36e7953 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -257,50 +257,48 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static int vbox_crtc_mode_set(struct drm_crtc *crtc,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode,
- int x, int y, struct drm_framebuffer *old_fb)
+static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
-   struct drm_framebuffer *new_fb = CRTC_FB(crtc);
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(new_fb)->obj);
-   int ret;
-
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (ret) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
-   return ret;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, new_fb, mode, x, y);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
+}
 
-   return 0;
+static void vbox_crtc_prepare(struct drm_crtc *crtc)
+{
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
+static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
+   /* We always set the mode when we set the fb/base */
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_crtc_state *old_crtc_state)
 {
+   struct drm_pending_vblank_event *event;
+   unsigned long flags;
+
+   if (crtc->state && crtc->state->event) {
+   event = crtc->state->event;
+   crtc->state->event = NULL;
+
+   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   }
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
.dpms = vbox_crtc_dpms,
.mode_fixup = vbox_crtc_mode_fixup,
-   .mode_set = vbox_crtc_mode_set,
+   .mode_set = drm_helper_crtc_mode_set,
+   .mode_set_nofb = vbox_crtc_mode_set_nofb,
.disable = vbox_crtc_disable,
.prepare = vbox_crtc_prepare,
.commit = vbox_crtc_commit,
+   .atomic_flush = vbox_crtc_atomic_flush,
 };
 
 static void vbox_crtc_reset(struct drm_crtc *crtc)
@@ -320,6 +318,63 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_primary_atomic_check(struct drm_plane *plane,
+struct drm_plane_state *new_state)
+{
+   return 0;
+}
+
+static void vbox_primary_atomic_update(struct drm_plane *plane,
+  struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = plane->state->crtc;
+   struct drm_framebuffer *fb = plane->state->fb;
+
+   vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode,
+   plane->state->src_x >> 16,
+   plane->state->src_y >> 16);
+}
+
+void vbox_primary_atomic_disable(struct drm_plane *plane,
+struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = old_state->crtc;
+
+   /* vbox_do_modeset checks plane->state->fb and will disable if NULL */
+   vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode,
+   old_state->src_x >> 16,
+   old_state->src_y >> 16);
+}
+
+static int vbox_primary_prepare_fb(struct drm_plane *plane,
+  struct drm_plane_state *new_state)
+{
+   struct vbox_bo *bo;
+   int ret;
+
+   if (!new_state->fb)
+   return 0;
+
+   bo = gem_to_vbox_bo(to_vbox_framebuffer(new_state->fb)->obj);
+   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
+   if (ret)
+   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
+
+   return ret;
+}
+
+static void vbox_primary_cleanup_fb(struct drm_plane *plane,
+   struct drm_plane_state *old_state)
+{
+   struct vbox_

[PATCH resend 03/15] staging: vboxvideo: Temporarily remove page_flip support

2018-09-29 Thread Hans de Goede
drm_mode_page_flip_ioctl() cannot deal with the in between phase of
the transitioning to atomic modeset support. Once we start using
drm_helper_crtc_mode_set(), we start setting plane->state on the primary
plane. But we are not fully atomic yet so then set both plane-state->fb
and plane->fb.

If both plane-state->fb and plane->fb are set drm_mode_page_flip_ioctl()
gets confused and stops calling drm_framebuffer_get() on the new fb while
still calling drm_framebuffer_put() on the old fb.

The current page_flip implementation expects drm_mode_page_flip_ioctl()
to take care of both and once we switch to drm_atomic_helper_page_flip()
that will expect neither to be done, taking care of both itself.

So for the transition we need to remove page_flip support and then after
the transition is complete and we set DRIVER_ATOMIC in our driver_features,
we can start using drm_atomic_helper_page_flip().

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 35 ---
 1 file changed, 35 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index babb02a1ebf2..adb6bcf989d1 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -282,40 +282,6 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
return 0;
 }
 
-static int vbox_crtc_page_flip(struct drm_crtc *crtc,
-  struct drm_framebuffer *fb,
-  struct drm_pending_vblank_event *event,
-  uint32_t page_flip_flags,
-  struct drm_modeset_acquire_ctx *ctx)
-{
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
-   struct drm_framebuffer *old_fb = CRTC_FB(crtc);
-   unsigned long flags;
-   int rc;
-
-   rc = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (rc) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", rc);
-   return rc;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, fb, NULL, 0, 0);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
-
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
-
-   if (event)
-   drm_crtc_send_vblank_event(crtc, event);
-
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
-
-   return 0;
-}
-
 static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
@@ -353,7 +319,6 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
-   .page_flip = vbox_crtc_page_flip,
.destroy = vbox_crtc_destroy,
 };
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 13/15] staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check

2018-09-29 Thread Hans de Goede
Extend our planes atomic_check callbacks to be more thorough by calling
the drm_atomic_helper_check_plane_state helper.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 30 ++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 72fc6614179a..4993a6cf6770 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -280,7 +280,19 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
 static int vbox_primary_atomic_check(struct drm_plane *plane,
 struct drm_plane_state *new_state)
 {
-   return 0;
+   struct drm_crtc_state *crtc_state = NULL;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   return drm_atomic_helper_check_plane_state(new_state, crtc_state,
+  DRM_PLANE_HELPER_NO_SCALING,
+  DRM_PLANE_HELPER_NO_SCALING,
+  false, true);
 }
 
 static void vbox_primary_atomic_update(struct drm_plane *plane,
@@ -337,8 +349,24 @@ static void vbox_primary_cleanup_fb(struct drm_plane 
*plane,
 static int vbox_cursor_atomic_check(struct drm_plane *plane,
struct drm_plane_state *new_state)
 {
+   struct drm_crtc_state *crtc_state = NULL;
u32 width = new_state->crtc_w;
u32 height = new_state->crtc_h;
+   int ret;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   ret = drm_atomic_helper_check_plane_state(new_state, crtc_state,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING,
+ true, true);
+   if (ret)
+   return ret;
 
if (!new_state->fb)
return 0;
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-09-29 Thread Hans de Goede
Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_mode.c | 28 ++-
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fccb3851d6a3..9cc20c182df1 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -139,7 +139,6 @@ struct vbox_connector {
 
 struct vbox_crtc {
struct drm_crtc base;
-   bool blanked;
bool disconnected;
unsigned int crtc_id;
u32 fb_offset;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index c4ec3fa49782..49ff9c4a6302 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
 
flags = VBVA_SCREEN_F_ACTIVE;
-   flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
   vbox_crtc->x * bpp / 8 +
vbox_crtc->y * pitch,
-  pitch, width, height,
-  vbox_crtc->blanked ? 0 : bpp, flags);
+  pitch, width, height, bpp, flags);
 }
 
 static int vbox_set_view(struct drm_crtc *crtc)
@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)
return 0;
 }
 
-static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = crtc->dev->dev_private;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   vbox_crtc->blanked = false;
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   vbox_crtc->blanked = true;
-   break;
-   }
-
-   mutex_lock(&vbox->hw_mutex);
-   vbox_do_modeset(crtc);
-   mutex_unlock(&vbox->hw_mutex);
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -276,7 +254,6 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .dpms = vbox_crtc_dpms,
.disable = vbox_crtc_disable,
.commit = vbox_crtc_commit,
.atomic_flush = vbox_crtc_atomic_flush,
@@ -861,7 +838,6 @@ static const struct drm_connector_helper_funcs 
vbox_connector_helper_funcs = {
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-   .dpms = drm_helper_connector_dpms,
.detect = vbox_connector_detect,
.fill_modes = vbox_fill_modes,
.destroy = vbox_connector_destroy,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->*

2018-09-29 Thread Hans de Goede
Once we are fully atomic plane->fb will always be NULL and we also
should not access things like crtc->enabled and crt->[hw]mode.

Now that we've wired up the state object handlers, we always have a
plane_state and crtc_state so change the code referencing plane->fb and
crtc->* to use the data from the plane_state and crt_state instead.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_main.c | 16 +++-
 drivers/staging/vboxvideo/vbox_mode.c | 15 +++
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 7fc668ff4465..fccb3851d6a3 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -199,7 +199,6 @@ int vbox_mode_init(struct vbox_private *vbox);
 void vbox_mode_fini(struct vbox_private *vbox);
 
 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-#define CRTC_FB(crtc) ((crtc)->primary->fb)
 
 void vbox_enable_accel(struct vbox_private *vbox);
 void vbox_disable_accel(struct vbox_private *vbox);
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 95100c5976e4..3b82d483ab51 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -102,24 +102,30 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
   unsigned int num_rects)
 {
struct vbox_private *vbox = fb->dev->dev_private;
+   struct drm_display_mode *mode;
struct drm_crtc *crtc;
+   int crtc_x, crtc_y;
unsigned int i;
 
mutex_lock(&vbox->hw_mutex);
list_for_each_entry(crtc, &fb->dev->mode_config.crtc_list, head) {
-   if (CRTC_FB(crtc) != fb)
+   if (crtc->primary->state->fb != fb)
continue;
 
+   mode = &crtc->state->mode;
+   crtc_x = crtc->primary->state->src_x >> 16;
+   crtc_y = crtc->primary->state->src_y >> 16;
+
vbox_enable_accel(vbox);
 
for (i = 0; i < num_rects; ++i) {
struct vbva_cmd_hdr cmd_hdr;
unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
 
-   if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) ||
-   (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) ||
-   (rects[i].x2 < crtc->x) ||
-   (rects[i].y2 < crtc->y))
+   if ((rects[i].x1 > crtc_x + mode->hdisplay) ||
+   (rects[i].y1 > crtc_y + mode->vdisplay) ||
+   (rects[i].x2 < crtc_x) ||
+   (rects[i].y2 < crtc_y))
continue;
 
cmd_hdr.x = (s16)rects[i].x1;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index cb897b672752..54e6aac784f7 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -46,6 +46,7 @@
  */
 static void vbox_do_modeset(struct drm_crtc *crtc)
 {
+   struct drm_framebuffer *fb = crtc->primary->state->fb;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
int width, height, bpp, pitch;
@@ -55,8 +56,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
vbox = crtc->dev->dev_private;
width = vbox_crtc->width ? vbox_crtc->width : 640;
height = vbox_crtc->height ? vbox_crtc->height : 480;
-   bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
-   pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+   bpp = fb ? fb->format->cpp[0] * 8 : 32;
+   pitch = fb ? fb->pitches[0] : width * bpp / 8;
x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
@@ -66,14 +67,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 * VirtualBox, certain parts of the code still assume that the first
 * screen is programmed this way, so try to fake it.
 */
-   if (vbox_crtc->crtc_id == 0 && crtc->enabled &&
+   if (vbox_crtc->crtc_id == 0 && fb &&
vbox_crtc->fb_offset / pitch < 0x - crtc->y &&
vbox_crtc->fb_offset % (bpp / 8) == 0) {
vbox_write_ioport(VBE_DISPI_INDEX_XRES, width);
vbox_write_ioport(VBE_DISPI_INDEX_YRES, height);
vbox_write_ioport(VBE_DISPI_INDEX_VIRT_WIDT

[PATCH resend 04/15] staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc

2018-09-29 Thread Hans de Goede
When setting a mode we not only pass the mode to the hypervisor,
but also information on how to map / translate input coordinates
for the emulated USB tablet.  This input-mapping may change when
the mode on *another* crtc changes.

This means that sometimes we must do a modeset on other crtc-s then
the one being changed to update the input-mapping. Including crtc-s
which may be disabled inside the guest (shown as a black window
on the host unless closed by the user).

With atomic modesetting the mode-info of disabled crtcs gets zeroed
yet we need it when updating the input-map to avoid resizing the
window as a side effect of a mode_set on another crtc.

This commit adds caching of the mode info into out private vbox_crtc
struct so that we always have the info at hand when we need it.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  | 20 +++
 drivers/staging/vboxvideo/vbox_mode.c | 28 +++
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 6c52cbd9e91e..34c4d7fc6c8e 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -151,6 +151,26 @@ struct vbox_crtc {
bool cursor_enabled;
u32 x_hint;
u32 y_hint;
+   /*
+* When setting a mode we not only pass the mode to the hypervisor,
+* but also information on how to map / translate input coordinates
+* for the emulated USB tablet.  This input-mapping may change when
+* the mode on *another* crtc changes.
+*
+* This means that sometimes we must do a modeset on other crtc-s then
+* the one being changed to update the input-mapping. Including crtc-s
+* which may be disabled inside the guest (shown as a black window
+* on the host unless closed by the user).
+*
+* With atomic modesetting the mode-info of disabled crtcs gets zeroed
+* yet we need it when updating the input-map to avoid resizing the
+* window as a side effect of a mode_set on another crtc. Therefor we
+* cache the info of the last mode below.
+*/
+   u32 width;
+   u32 height;
+   u32 x;
+   u32 y;
 };
 
 struct vbox_encoder {
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index adb6bcf989d1..e85b27f95def 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -48,8 +48,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc, int x, int 
y);
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
  */
-static void vbox_do_modeset(struct drm_crtc *crtc,
-   const struct drm_display_mode *mode)
+static void vbox_do_modeset(struct drm_crtc *crtc)
 {
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
@@ -58,12 +57,12 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
s32 x_offset, y_offset;
 
vbox = crtc->dev->dev_private;
-   width = mode->hdisplay ? mode->hdisplay : 640;
-   height = mode->vdisplay ? mode->vdisplay : 480;
+   width = vbox_crtc->width ? vbox_crtc->width : 640;
+   height = vbox_crtc->height ? vbox_crtc->height : 480;
bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
-   x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
-   y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint;
+   x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
+   y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
/*
 * This is the old way of setting graphics modes.  It assumed one screen
@@ -82,9 +81,9 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
vbox_write_ioport(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
vbox_write_ioport(
VBE_DISPI_INDEX_X_OFFSET,
-   vbox_crtc->fb_offset % pitch / bpp * 8 + crtc->x);
+   vbox_crtc->fb_offset % pitch / bpp * 8 + vbox_crtc->x);
vbox_write_ioport(VBE_DISPI_INDEX_Y_OFFSET,
- vbox_crtc->fb_offset / pitch + crtc->y);
+ vbox_crtc->fb_offset / pitch + vbox_crtc->y);
}
 
flags = VBVA_SCREEN_F_ACTIVE;
@@ -93,7 +92,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   

[PATCH resend 07/15] staging: vboxvideo: Atomic phase 2: Wire up state object handlers

2018-09-29 Thread Hans de Goede
Wire up state object handlers for the crtc-s and the planes, call
drm_mode_config_reset() after creating all the crtc-s and encoders and
remove the legacy drm_helper_disable_unused_functions() call.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_fb.c   |  3 ---
 drivers/staging/vboxvideo/vbox_mode.c | 15 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index b8b42f9aafae..8a9d56762659 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -216,9 +216,6 @@ int vbox_fbdev_init(struct vbox_private *vbox)
if (ret)
goto err_fini;
 
-   /* disable all the possible outputs/crtcs before entering KMS mode */
-   drm_helper_disable_unused_functions(dev);
-
ret = drm_fb_helper_initial_config(&fbdev->helper, 32);
if (ret)
goto err_fini;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e560e36e7953..cb897b672752 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -301,10 +301,6 @@ static const struct drm_crtc_helper_funcs 
vbox_crtc_helper_funcs = {
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-static void vbox_crtc_reset(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_destroy(struct drm_crtc *crtc)
 {
drm_crtc_cleanup(crtc);
@@ -312,10 +308,12 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
+   .reset = drm_atomic_helper_crtc_reset,
+   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
 static int vbox_primary_atomic_check(struct drm_plane *plane,
@@ -527,6 +525,9 @@ static const struct drm_plane_funcs vbox_cursor_plane_funcs 
= {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_plane_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static const uint32_t vbox_primary_plane_formats[] = {
@@ -546,6 +547,9 @@ static const struct drm_plane_funcs 
vbox_primary_plane_funcs = {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_primary_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
@@ -982,6 +986,7 @@ int vbox_mode_init(struct vbox_private *vbox)
goto err_drm_mode_cleanup;
}
 
+   drm_mode_config_reset(dev);
return 0;
 
 err_drm_mode_cleanup:
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 15/15] staging: vboxvideo: Use more drm_fb_helper functions

2018-09-29 Thread Hans de Goede
Store fbhelper and afb struct directly in vbox_private and use
drm_fb_helper_fbdev_setup to replace vbox_fbdev_init, note we cannot use
drm_fb_helper_fbdev_teardown since we use a private framebuffer for the
fbdev.

And replace vbox_driver_lastclose with drm_fb_helper_lastclose.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c  | 10 +++-
 drivers/staging/vboxvideo/vbox_drv.h  | 28 +++
 drivers/staging/vboxvideo/vbox_fb.c   | 70 ++-
 drivers/staging/vboxvideo/vbox_main.c | 12 -
 drivers/staging/vboxvideo/vbox_mode.c |  2 +-
 5 files changed, 31 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c3e14107da0d..257030460fb6 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -49,6 +49,10 @@ static const struct pci_device_id pciidlist[] = {
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
+   .fb_probe = vboxfb_create,
+};
+
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
 {
struct vbox_private *vbox;
@@ -92,7 +96,9 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (ret)
goto err_mode_fini;
 
-   ret = vbox_fbdev_init(vbox);
+   ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper,
+   &vbox_fb_helper_funcs, 32,
+   vbox->num_crtcs);
if (ret)
goto err_irq_fini;
 
@@ -257,7 +263,7 @@ static struct drm_driver driver = {
DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
-   .lastclose = vbox_driver_lastclose,
+   .lastclose = drm_fb_helper_lastclose,
.master_set = vbox_master_set,
.master_drop = vbox_master_drop,
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 9cc20c182df1..73395a7536c5 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -72,11 +72,16 @@
sizeof(struct hgsmi_host_flags))
 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
 
-struct vbox_fbdev;
+struct vbox_framebuffer {
+   struct drm_framebuffer base;
+   struct drm_gem_object *obj;
+};
 
 struct vbox_private {
/* Must be first; or we must define our own release callback */
struct drm_device ddev;
+   struct drm_fb_helper fb_helper;
+   struct vbox_framebuffer afb;
 
u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers;
@@ -91,8 +96,6 @@ struct vbox_private {
/** Array of structures for receiving mode hints. */
struct vbva_modehint *last_mode_hints;
 
-   struct vbox_fbdev *fbdev;
-
int fb_mtrr;
 
struct {
@@ -122,8 +125,6 @@ struct vbox_private {
 #undef CURSOR_PIXEL_COUNT
 #undef CURSOR_DATA_SIZE
 
-void vbox_driver_lastclose(struct drm_device *dev);
-
 struct vbox_gem_object;
 
 struct vbox_connector {
@@ -171,20 +172,6 @@ struct vbox_encoder {
struct drm_encoder base;
 };
 
-struct vbox_framebuffer {
-   struct drm_framebuffer base;
-   struct drm_gem_object *obj;
-};
-
-struct vbox_fbdev {
-   struct drm_fb_helper helper;
-   struct vbox_framebuffer afb;
-   int size;
-   struct ttm_bo_kmap_obj mapping;
-   int x1, y1, x2, y2; /* dirty rect */
-   spinlock_t dirty_lock;
-};
-
 #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
 #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
 #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
@@ -212,7 +199,8 @@ int vbox_framebuffer_init(struct vbox_private *vbox,
  const struct DRM_MODE_FB_CMD *mode_cmd,
  struct drm_gem_object *obj);
 
-int vbox_fbdev_init(struct vbox_private *vbox);
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes);
 void vbox_fbdev_fini(struct vbox_private *vbox);
 
 struct vbox_bo {
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 8a9d56762659..ee25f3a03934 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -66,13 +66,11 @@ static struct fb_ops vboxfb_ops = {
.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
-static int vboxfb_create(struct drm_fb_helper *helper,
-struct drm_fb_helper_surface_size *sizes)
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes)
 {
-   struct vbox_fbdev *fbdev =
-   container_of(helper, struct vbox_fbdev, helper);
-   struct vbox_private *vbox = container_of(fbdev->helper.dev,
-struct vbox_privat

[PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API

2018-09-29 Thread Hans de Goede
Hi All,

This series converts the vboxvideo driver to the modesetting API, once this
is merged I will submit a patch to move the driver out of staging and into
drivers/gpu/drm.

This series consists of 3 parts:

1) More cleanups / prep work for atomic conversion
2) The actual atomic conversion, this is modelled after the atomic conversion
   of the qxl driver done by Gabriel Krisman Bertazi. Gabriel if you are
   reading this, thank you for providing a roadmap how to go about this.
3) Restore some features which were lost by the atomic conversion +
   more cleanups

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] mmc: Add mmc_force_detect_change_begin / _end functions

2018-09-26 Thread Hans de Goede

Hi,

On 26-09-18 16:44, Frieder Schrempf wrote:

Hi,

On Fri, Feb 09, 2018 at 03:01:00PM +0100, Ulf Hansson wrote:

[...]

>> > I'd like to know if any progress has been made on that problem 

(I may

>> > have missed patches).
>> > Had you had the time to look at the issue?
>>
>> I have looked at the issue, but not manage to cook some patches 

for it.

>>
>> However, it's on my top of my TODO list for mmc. No promises, but
>> perhaps and hopefully I manage to get something posted during the
>> coming release cycle.


I would be interested in a ESP8089 driver in mainline and that's why I want to 
pick up this discussion.

What is the current status of the "mmc_reprobe_device" implementation, that 
Hans was explaining and Ulf wanted to provide some months ago?


Ulf did eventually write a new way to deal with this and then Quentin
did manage to get the esp8089 driver to work with it, the new function
to use for this is added by this commit:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/mmc/core?id=1433269c4d2461be1f36db5dbb453976b38996ff

I'm not sure what the status of upstreaming the ep8089 driver is now
that we've this in place.

Quentin, do you have a version of the esp8089 driver somewhere
which will work correctly with the new mmc_sw_reset() function?

Also what is the status of adding this driver to say staging?

Regards,

Hans





BTW, I am not on any of the mailing lists involved, so I tried to recreate the 
proper mail headers manually for the reply to the correct thread.

Thanks,
Frieder


>>
>
> Cool! If you ever need some testing, I'd be glad to test your patches
> (even if they are in a draft/RFC state).
>
> Also, when you send patches, I'd appreciate being Cc'ed so that I can
> put my Tested-by :) Thanks!

Absolutely! I appreciate it.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] staging: vboxvideo: Restore page-flip support

2018-09-26 Thread Hans de Goede
Restore page-flip support now that the atomic conversion is complete.

Since the mode parameter to vbox_crtc_set_base_and_mode() now never
is NULL call drm_atomic_crtc_needs_modeset() to check if we need to
check for input-mapping changes, to avoid doing unnecesarry work on
a flip. And hookup the drm_atomic_helper_page_flip helper to implement
the page_flip callback.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 69a1e6c163b9..c4ec3fa49782 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -32,6 +32,7 @@
  *  Hans de Goede 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,6 +218,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
struct vbox_private *vbox = crtc->dev->dev_private;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
+   bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
mutex_lock(&vbox->hw_mutex);
 
@@ -227,7 +229,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo);
 
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
-   if (mode && vbox_set_up_input_mapping(vbox)) {
+   if (needs_modeset && vbox_set_up_input_mapping(vbox)) {
struct drm_crtc *crtci;
 
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
@@ -241,7 +243,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_set_view(crtc);
vbox_do_modeset(crtc);
 
-   if (mode)
+   if (needs_modeset)
hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
   vbox->input_mapping_width,
   vbox->input_mapping_height);
@@ -288,6 +290,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
+   .page_flip = drm_atomic_helper_page_flip,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
.reset = drm_atomic_helper_crtc_reset,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/15] staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks

2018-09-26 Thread Hans de Goede
vbox_mode_valid always returns MODE_OK, which is also the default if no
mode_valid callback is defined.

vbox_best_single_encoder chains to drm_encoder_find, the drm-core will
call drm_encoder_find itself if there is no best_encoder call back.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4993a6cf6770..756544b53600 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -651,18 +651,6 @@ static void vbox_encoder_destroy(struct drm_encoder 
*encoder)
kfree(encoder);
 }
 
-static struct drm_encoder *vbox_best_single_encoder(struct drm_connector
-   *connector)
-{
-   int enc_id = connector->encoder_ids[0];
-
-   /* pick the encoder ids */
-   if (enc_id)
-   return drm_encoder_find(connector->dev, NULL, enc_id);
-
-   return NULL;
-}
-
 static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
@@ -820,12 +808,6 @@ static int vbox_get_modes(struct drm_connector *connector)
return num_modes;
 }
 
-static enum drm_mode_status vbox_mode_valid(struct drm_connector *connector,
-  struct drm_display_mode *mode)
-{
-   return MODE_OK;
-}
-
 static void vbox_connector_destroy(struct drm_connector *connector)
 {
drm_connector_unregister(connector);
@@ -862,9 +844,7 @@ static int vbox_fill_modes(struct drm_connector *connector, 
u32 max_x,
 }
 
 static const struct drm_connector_helper_funcs vbox_connector_helper_funcs = {
-   .mode_valid = vbox_mode_valid,
.get_modes = vbox_get_modes,
-   .best_encoder = vbox_best_single_encoder,
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/15] staging: vboxvideo: Use more drm_fb_helper functions

2018-09-26 Thread Hans de Goede
Store fbhelper and afb struct directly in vbox_private and use
drm_fb_helper_fbdev_setup to replace vbox_fbdev_init, note we cannot use
drm_fb_helper_fbdev_teardown since we use a private framebuffer for the
fbdev.

And replace vbox_driver_lastclose with drm_fb_helper_lastclose.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c  | 10 +++-
 drivers/staging/vboxvideo/vbox_drv.h  | 28 +++
 drivers/staging/vboxvideo/vbox_fb.c   | 70 ++-
 drivers/staging/vboxvideo/vbox_main.c | 12 -
 drivers/staging/vboxvideo/vbox_mode.c |  2 +-
 5 files changed, 31 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c3e14107da0d..257030460fb6 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -49,6 +49,10 @@ static const struct pci_device_id pciidlist[] = {
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
+   .fb_probe = vboxfb_create,
+};
+
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
 {
struct vbox_private *vbox;
@@ -92,7 +96,9 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (ret)
goto err_mode_fini;
 
-   ret = vbox_fbdev_init(vbox);
+   ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper,
+   &vbox_fb_helper_funcs, 32,
+   vbox->num_crtcs);
if (ret)
goto err_irq_fini;
 
@@ -257,7 +263,7 @@ static struct drm_driver driver = {
DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
-   .lastclose = vbox_driver_lastclose,
+   .lastclose = drm_fb_helper_lastclose,
.master_set = vbox_master_set,
.master_drop = vbox_master_drop,
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 9cc20c182df1..73395a7536c5 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -72,11 +72,16 @@
sizeof(struct hgsmi_host_flags))
 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
 
-struct vbox_fbdev;
+struct vbox_framebuffer {
+   struct drm_framebuffer base;
+   struct drm_gem_object *obj;
+};
 
 struct vbox_private {
/* Must be first; or we must define our own release callback */
struct drm_device ddev;
+   struct drm_fb_helper fb_helper;
+   struct vbox_framebuffer afb;
 
u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers;
@@ -91,8 +96,6 @@ struct vbox_private {
/** Array of structures for receiving mode hints. */
struct vbva_modehint *last_mode_hints;
 
-   struct vbox_fbdev *fbdev;
-
int fb_mtrr;
 
struct {
@@ -122,8 +125,6 @@ struct vbox_private {
 #undef CURSOR_PIXEL_COUNT
 #undef CURSOR_DATA_SIZE
 
-void vbox_driver_lastclose(struct drm_device *dev);
-
 struct vbox_gem_object;
 
 struct vbox_connector {
@@ -171,20 +172,6 @@ struct vbox_encoder {
struct drm_encoder base;
 };
 
-struct vbox_framebuffer {
-   struct drm_framebuffer base;
-   struct drm_gem_object *obj;
-};
-
-struct vbox_fbdev {
-   struct drm_fb_helper helper;
-   struct vbox_framebuffer afb;
-   int size;
-   struct ttm_bo_kmap_obj mapping;
-   int x1, y1, x2, y2; /* dirty rect */
-   spinlock_t dirty_lock;
-};
-
 #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
 #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
 #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
@@ -212,7 +199,8 @@ int vbox_framebuffer_init(struct vbox_private *vbox,
  const struct DRM_MODE_FB_CMD *mode_cmd,
  struct drm_gem_object *obj);
 
-int vbox_fbdev_init(struct vbox_private *vbox);
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes);
 void vbox_fbdev_fini(struct vbox_private *vbox);
 
 struct vbox_bo {
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 8a9d56762659..ee25f3a03934 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -66,13 +66,11 @@ static struct fb_ops vboxfb_ops = {
.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
-static int vboxfb_create(struct drm_fb_helper *helper,
-struct drm_fb_helper_surface_size *sizes)
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes)
 {
-   struct vbox_fbdev *fbdev =
-   container_of(helper, struct vbox_fbdev, helper);
-   struct vbox_private *vbox = container_of(fbdev->helper.dev,
-struct vbox_privat

[PATCH 03/15] staging: vboxvideo: Temporarily remove page_flip support

2018-09-26 Thread Hans de Goede
drm_mode_page_flip_ioctl() cannot deal with the in between phase of
the transitioning to atomic modeset support. Once we start using
drm_helper_crtc_mode_set(), we start setting plane->state on the primary
plane. But we are not fully atomic yet so then set both plane-state->fb
and plane->fb.

If both plane-state->fb and plane->fb are set drm_mode_page_flip_ioctl()
gets confused and stops calling drm_framebuffer_get() on the new fb while
still calling drm_framebuffer_put() on the old fb.

The current page_flip implementation expects drm_mode_page_flip_ioctl()
to take care of both and once we switch to drm_atomic_helper_page_flip()
that will expect neither to be done, taking care of both itself.

So for the transition we need to remove page_flip support and then after
the transition is complete and we set DRIVER_ATOMIC in our driver_features,
we can start using drm_atomic_helper_page_flip().

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 35 ---
 1 file changed, 35 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index babb02a1ebf2..adb6bcf989d1 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -282,40 +282,6 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
return 0;
 }
 
-static int vbox_crtc_page_flip(struct drm_crtc *crtc,
-  struct drm_framebuffer *fb,
-  struct drm_pending_vblank_event *event,
-  uint32_t page_flip_flags,
-  struct drm_modeset_acquire_ctx *ctx)
-{
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
-   struct drm_framebuffer *old_fb = CRTC_FB(crtc);
-   unsigned long flags;
-   int rc;
-
-   rc = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (rc) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", rc);
-   return rc;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, fb, NULL, 0, 0);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
-
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
-
-   if (event)
-   drm_crtc_send_vblank_event(crtc, event);
-
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
-
-   return 0;
-}
-
 static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
@@ -353,7 +319,6 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
-   .page_flip = vbox_crtc_page_flip,
.destroy = vbox_crtc_destroy,
 };
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane

2018-09-26 Thread Hans de Goede
Use drm_plane_helpers for the primary plane and replace our custom
mode_set callback with drm_helper_crtc_mode_set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 116 --
 1 file changed, 90 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 75e112d33cf0..e560e36e7953 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -257,50 +257,48 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static int vbox_crtc_mode_set(struct drm_crtc *crtc,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode,
- int x, int y, struct drm_framebuffer *old_fb)
+static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
-   struct drm_framebuffer *new_fb = CRTC_FB(crtc);
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(new_fb)->obj);
-   int ret;
-
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (ret) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
-   return ret;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, new_fb, mode, x, y);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
+}
 
-   return 0;
+static void vbox_crtc_prepare(struct drm_crtc *crtc)
+{
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
+static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
+   /* We always set the mode when we set the fb/base */
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_crtc_state *old_crtc_state)
 {
+   struct drm_pending_vblank_event *event;
+   unsigned long flags;
+
+   if (crtc->state && crtc->state->event) {
+   event = crtc->state->event;
+   crtc->state->event = NULL;
+
+   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   }
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
.dpms = vbox_crtc_dpms,
.mode_fixup = vbox_crtc_mode_fixup,
-   .mode_set = vbox_crtc_mode_set,
+   .mode_set = drm_helper_crtc_mode_set,
+   .mode_set_nofb = vbox_crtc_mode_set_nofb,
.disable = vbox_crtc_disable,
.prepare = vbox_crtc_prepare,
.commit = vbox_crtc_commit,
+   .atomic_flush = vbox_crtc_atomic_flush,
 };
 
 static void vbox_crtc_reset(struct drm_crtc *crtc)
@@ -320,6 +318,63 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_primary_atomic_check(struct drm_plane *plane,
+struct drm_plane_state *new_state)
+{
+   return 0;
+}
+
+static void vbox_primary_atomic_update(struct drm_plane *plane,
+  struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = plane->state->crtc;
+   struct drm_framebuffer *fb = plane->state->fb;
+
+   vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode,
+   plane->state->src_x >> 16,
+   plane->state->src_y >> 16);
+}
+
+void vbox_primary_atomic_disable(struct drm_plane *plane,
+struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = old_state->crtc;
+
+   /* vbox_do_modeset checks plane->state->fb and will disable if NULL */
+   vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode,
+   old_state->src_x >> 16,
+   old_state->src_y >> 16);
+}
+
+static int vbox_primary_prepare_fb(struct drm_plane *plane,
+  struct drm_plane_state *new_state)
+{
+   struct vbox_bo *bo;
+   int ret;
+
+   if (!new_state->fb)
+   return 0;
+
+   bo = gem_to_vbox_bo(to_vbox_framebuffer(new_state->fb)->obj);
+   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
+   if (ret)
+   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
+
+   return ret;
+}
+
+static void vbox_primary_cleanup_fb(struct drm_plane *plane,
+   struct drm_plane_state *old_state)
+{
+   struct vbox_

[PATCH 12/15] staging: vboxvideo: Replace crtc_helper enable/disable functions

2018-09-26 Thread Hans de Goede
Replace vbox_crtc_commit and vbox_crtc_disable with
vbox_crtc_atomic_[en|dis]able which are the preferred callbacks for
these for atomic drivers.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 49ff9c4a6302..72fc6614179a 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -229,11 +229,13 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_enable(struct drm_crtc *crtc,
+   struct drm_crtc_state *old_crtc_state)
 {
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_disable(struct drm_crtc *crtc,
+struct drm_crtc_state *old_crtc_state)
 {
 }
 
@@ -254,8 +256,8 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .disable = vbox_crtc_disable,
-   .commit = vbox_crtc_commit,
+   .atomic_enable = vbox_crtc_atomic_enable,
+   .atomic_disable = vbox_crtc_atomic_disable,
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/15] staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check

2018-09-26 Thread Hans de Goede
Extend our planes atomic_check callbacks to be more thorough by calling
the drm_atomic_helper_check_plane_state helper.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 30 ++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 72fc6614179a..4993a6cf6770 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -280,7 +280,19 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
 static int vbox_primary_atomic_check(struct drm_plane *plane,
 struct drm_plane_state *new_state)
 {
-   return 0;
+   struct drm_crtc_state *crtc_state = NULL;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   return drm_atomic_helper_check_plane_state(new_state, crtc_state,
+  DRM_PLANE_HELPER_NO_SCALING,
+  DRM_PLANE_HELPER_NO_SCALING,
+  false, true);
 }
 
 static void vbox_primary_atomic_update(struct drm_plane *plane,
@@ -337,8 +349,24 @@ static void vbox_primary_cleanup_fb(struct drm_plane 
*plane,
 static int vbox_cursor_atomic_check(struct drm_plane *plane,
struct drm_plane_state *new_state)
 {
+   struct drm_crtc_state *crtc_state = NULL;
u32 width = new_state->crtc_w;
u32 height = new_state->crtc_h;
+   int ret;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   ret = drm_atomic_helper_check_plane_state(new_state, crtc_state,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING,
+ true, true);
+   if (ret)
+   return ret;
 
if (!new_state->fb)
return 0;
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/15] staging: vboxvideo: Remove empty encoder_helper_funcs

2018-09-26 Thread Hans de Goede
All the encoder_helper_funcs are optional, and even setting the
drm_encoder_helper_funcs vtable itself is optional and may be left out
when not using any of the helper funcs, so lets drop all of this.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 34 ---
 1 file changed, 34 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4f5d28aeca95..babb02a1ebf2 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -466,39 +466,6 @@ static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
 
-static void vbox_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-}
-
-static bool vbox_mode_fixup(struct drm_encoder *encoder,
-   const struct drm_display_mode *mode,
-   struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
-static void vbox_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void vbox_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void vbox_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static const struct drm_encoder_helper_funcs vbox_enc_helper_funcs = {
-   .dpms = vbox_encoder_dpms,
-   .mode_fixup = vbox_mode_fixup,
-   .prepare = vbox_encoder_prepare,
-   .commit = vbox_encoder_commit,
-   .mode_set = vbox_encoder_mode_set,
-};
-
 static struct drm_encoder *vbox_encoder_init(struct drm_device *dev,
 unsigned int i)
 {
@@ -510,7 +477,6 @@ static struct drm_encoder *vbox_encoder_init(struct 
drm_device *dev,
 
drm_encoder_init(dev, &vbox_encoder->base, &vbox_enc_funcs,
 DRM_MODE_ENCODER_DAC, NULL);
-   drm_encoder_helper_add(&vbox_encoder->base, &vbox_enc_helper_funcs);
 
vbox_encoder->base.possible_crtcs = 1 << i;
return &vbox_encoder->base;
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/15] staging: vboxvideo: Atomic phase 1: convert cursor to universal plane

2018-09-26 Thread Hans de Goede
In preparation for atomic conversion, let's use the transitional atomic
helpers drm_plane_helper_update/disable.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |   5 -
 drivers/staging/vboxvideo/vbox_mode.c | 386 +-
 2 files changed, 186 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 34c4d7fc6c8e..7fc668ff4465 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -116,11 +116,6 @@ struct vbox_private {
 * encompassing all screen ones or is the fbdev console active?
 */
bool single_framebuffer;
-   u32 cursor_width;
-   u32 cursor_height;
-   u32 cursor_hot_x;
-   u32 cursor_hot_y;
-   size_t cursor_data_size;
u8 cursor_data[CURSOR_DATA_SIZE];
 };
 
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e85b27f95def..75e112d33cf0 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -34,16 +34,12 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vbox_drv.h"
 #include "vboxvideo.h"
 #include "hgsmi_channels.h"
 
-static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
-   u32 handle, u32 width, u32 height,
-   s32 hot_x, s32 hot_y);
-static int vbox_cursor_move(struct drm_crtc *crtc, int x, int y);
-
 /**
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
@@ -318,14 +314,166 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .cursor_move = vbox_cursor_move,
-   .cursor_set2 = vbox_cursor_set2,
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_cursor_atomic_check(struct drm_plane *plane,
+   struct drm_plane_state *new_state)
+{
+   u32 width = new_state->crtc_w;
+   u32 height = new_state->crtc_h;
+
+   if (!new_state->fb)
+   return 0;
+
+   if (width > VBOX_MAX_CURSOR_WIDTH || height > VBOX_MAX_CURSOR_HEIGHT ||
+   width == 0 || height == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+/**
+ * Copy the ARGB image and generate the mask, which is needed in case the host
+ * does not support ARGB cursors.  The mask is a 1BPP bitmap with the bit set
+ * if the corresponding alpha value in the ARGB image is greater than 0xF0.
+ */
+static void copy_cursor_image(u8 *src, u8 *dst, u32 width, u32 height,
+ size_t mask_size)
+{
+   size_t line_size = (width + 7) / 8;
+   u32 i, j;
+
+   memcpy(dst + mask_size, src, width * height * 4);
+   for (i = 0; i < height; ++i)
+   for (j = 0; j < width; ++j)
+   if (((u32 *)src)[i * width + j] > 0xf000)
+   dst[i * line_size + j / 8] |= (0x80 >> (j % 8));
+}
+
+static void vbox_cursor_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+   struct vbox_private *vbox =
+   container_of(plane->dev, struct vbox_private, ddev);
+   struct vbox_crtc *vbox_crtc = to_vbox_crtc(plane->state->crtc);
+   struct drm_framebuffer *fb = plane->state->fb;
+   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
+   u32 width = plane->state->crtc_w;
+   u32 height = plane->state->crtc_h;
+   size_t data_size, mask_size;
+   u32 flags;
+   u8 *src;
+
+   /*
+* VirtualBox uses the host windowing system to draw the cursor so
+* moves are a no-op, we only need to upload new cursor sprites.
+*/
+   if (fb == old_state->fb)
+   return;
+
+   mutex_lock(&vbox->hw_mutex);
+
+   vbox_crtc->cursor_enabled = true;
+
+   /* pinning is done in prepare/cleanup framebuffer */
+   src = vbox_bo_kmap(bo);
+   if (IS_ERR(src)) {
+   DRM_WARN("Could not kmap cursor bo, skipping update\n");
+   return;
+   }
+
+   /*
+* The mask must be calculated based on the alpha
+* channel, one bit per ARGB word, and must be 32-bit
+* padded.
+*/
+   mask_size = ((width + 7) / 8 * height + 3) & ~3;
+   data_size = width * height * 4 + mask_size;
+
+   copy_cursor_image(src, vbox->cursor_data, width, height, mask_size);
+   vbox_bo_kunmap(bo);
+
+   flags = VBOX_MOUSE_POINTER_VISIBLE | VBOX_MOUSE_POINTER_SHAPE |
+   VBOX_MOUSE_PO

[PATCH 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic

2018-09-26 Thread Hans de Goede
Now that the state objects are wired up, we can:

1) Move to the final atomic handlers
2) Wire up atomic set_config helper
3) Switch to drm_mode_config_helper_suspend/resume for suspend/resume
4) Enable atomic modesetting ioctl

This is all done in one commit because doing this piecemeal leads to
an intermediate state which triggers WARN_ONs in the atomic code because
e.g. plane->fb is still being set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/TODO|  1 -
 drivers/staging/vboxvideo/vbox_drv.c  | 40 +--
 drivers/staging/vboxvideo/vbox_mode.c | 35 +++
 3 files changed, 17 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/vboxvideo/TODO b/drivers/staging/vboxvideo/TODO
index 468eea856ca6..2e0f99c3f10c 100644
--- a/drivers/staging/vboxvideo/TODO
+++ b/drivers/staging/vboxvideo/TODO
@@ -1,5 +1,4 @@
 TODO:
--Move the driver over to the atomic API
 -Get a full review from the drm-maintainers on dri-devel done on this driver
 -Extend this TODO with the results of that review
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c6a53b0ad66c..c3e14107da0d 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -132,35 +132,16 @@ static void vbox_pci_remove(struct pci_dev *pdev)
drm_dev_put(&vbox->ddev);
 }
 
-static int vbox_drm_freeze(struct vbox_private *vbox)
-{
-   drm_kms_helper_poll_disable(&vbox->ddev);
-
-   pci_save_state(vbox->ddev.pdev);
-
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
-
-   return 0;
-}
-
-static int vbox_drm_thaw(struct vbox_private *vbox)
-{
-   drm_mode_config_reset(&vbox->ddev);
-   drm_helper_resume_force_mode(&vbox->ddev);
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false);
-
-   return 0;
-}
-
 static int vbox_pm_suspend(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
int error;
 
-   error = vbox_drm_freeze(vbox);
+   error = drm_mode_config_helper_suspend(&vbox->ddev);
if (error)
return error;
 
+   pci_save_state(vbox->ddev.pdev);
pci_disable_device(vbox->ddev.pdev);
pci_set_power_state(vbox->ddev.pdev, PCI_D3hot);
 
@@ -170,39 +151,32 @@ static int vbox_pm_suspend(struct device *dev)
 static int vbox_pm_resume(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
-   int ret;
 
if (pci_enable_device(vbox->ddev.pdev))
return -EIO;
 
-   ret = vbox_drm_thaw(vbox);
-   if (ret)
-   return ret;
-
-   drm_kms_helper_poll_enable(&vbox->ddev);
-
-   return 0;
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_freeze(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static int vbox_pm_thaw(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_thaw(vbox);
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_poweroff(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static const struct dev_pm_ops vbox_pm_ops = {
@@ -280,7 +254,7 @@ static void vbox_master_drop(struct drm_device *dev, struct 
drm_file *file_priv)
 static struct drm_driver driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
-   DRIVER_PRIME,
+   DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
.lastclose = vbox_driver_lastclose,
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 54e6aac784f7..69a1e6c163b9 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -148,13 +148,6 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
mutex_unlock(&vbox->hw_mutex);
 }
 
-static bool vbox_crtc_mode_fixup(struct drm_crtc *crtc,
-const struct drm_display_mode *mode,
-struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -260,19 +253,10 @@ static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
-{
- 

[PATCH 07/15] staging: vboxvideo: Atomic phase 2: Wire up state object handlers

2018-09-26 Thread Hans de Goede
Wire up state object handlers for the crtc-s and the planes, call
drm_mode_config_reset() after creating all the crtc-s and encoders and
remove the legacy drm_helper_disable_unused_functions() call.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_fb.c   |  3 ---
 drivers/staging/vboxvideo/vbox_mode.c | 15 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index b8b42f9aafae..8a9d56762659 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -216,9 +216,6 @@ int vbox_fbdev_init(struct vbox_private *vbox)
if (ret)
goto err_fini;
 
-   /* disable all the possible outputs/crtcs before entering KMS mode */
-   drm_helper_disable_unused_functions(dev);
-
ret = drm_fb_helper_initial_config(&fbdev->helper, 32);
if (ret)
goto err_fini;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e560e36e7953..cb897b672752 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -301,10 +301,6 @@ static const struct drm_crtc_helper_funcs 
vbox_crtc_helper_funcs = {
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-static void vbox_crtc_reset(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_destroy(struct drm_crtc *crtc)
 {
drm_crtc_cleanup(crtc);
@@ -312,10 +308,12 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
+   .reset = drm_atomic_helper_crtc_reset,
+   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
 static int vbox_primary_atomic_check(struct drm_plane *plane,
@@ -527,6 +525,9 @@ static const struct drm_plane_funcs vbox_cursor_plane_funcs 
= {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_plane_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static const uint32_t vbox_primary_plane_formats[] = {
@@ -546,6 +547,9 @@ static const struct drm_plane_funcs 
vbox_primary_plane_funcs = {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_primary_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
@@ -982,6 +986,7 @@ int vbox_mode_init(struct vbox_private *vbox)
goto err_drm_mode_cleanup;
}
 
+   drm_mode_config_reset(dev);
return 0;
 
 err_drm_mode_cleanup:
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->*

2018-09-26 Thread Hans de Goede
Once we are fully atomic plane->fb will always be NULL and we also
should not access things like crtc->enabled and crt->[hw]mode.

Now that we've wired up the state object handlers, we always have a
plane_state and crtc_state so change the code referencing plane->fb and
crtc->* to use the data from the plane_state and crt_state instead.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_main.c | 16 +++-
 drivers/staging/vboxvideo/vbox_mode.c | 15 +++
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 7fc668ff4465..fccb3851d6a3 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -199,7 +199,6 @@ int vbox_mode_init(struct vbox_private *vbox);
 void vbox_mode_fini(struct vbox_private *vbox);
 
 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-#define CRTC_FB(crtc) ((crtc)->primary->fb)
 
 void vbox_enable_accel(struct vbox_private *vbox);
 void vbox_disable_accel(struct vbox_private *vbox);
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 95100c5976e4..3b82d483ab51 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -102,24 +102,30 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
   unsigned int num_rects)
 {
struct vbox_private *vbox = fb->dev->dev_private;
+   struct drm_display_mode *mode;
struct drm_crtc *crtc;
+   int crtc_x, crtc_y;
unsigned int i;
 
mutex_lock(&vbox->hw_mutex);
list_for_each_entry(crtc, &fb->dev->mode_config.crtc_list, head) {
-   if (CRTC_FB(crtc) != fb)
+   if (crtc->primary->state->fb != fb)
continue;
 
+   mode = &crtc->state->mode;
+   crtc_x = crtc->primary->state->src_x >> 16;
+   crtc_y = crtc->primary->state->src_y >> 16;
+
vbox_enable_accel(vbox);
 
for (i = 0; i < num_rects; ++i) {
struct vbva_cmd_hdr cmd_hdr;
unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
 
-   if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) ||
-   (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) ||
-   (rects[i].x2 < crtc->x) ||
-   (rects[i].y2 < crtc->y))
+   if ((rects[i].x1 > crtc_x + mode->hdisplay) ||
+   (rects[i].y1 > crtc_y + mode->vdisplay) ||
+   (rects[i].x2 < crtc_x) ||
+   (rects[i].y2 < crtc_y))
continue;
 
cmd_hdr.x = (s16)rects[i].x1;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index cb897b672752..54e6aac784f7 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -46,6 +46,7 @@
  */
 static void vbox_do_modeset(struct drm_crtc *crtc)
 {
+   struct drm_framebuffer *fb = crtc->primary->state->fb;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
int width, height, bpp, pitch;
@@ -55,8 +56,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
vbox = crtc->dev->dev_private;
width = vbox_crtc->width ? vbox_crtc->width : 640;
height = vbox_crtc->height ? vbox_crtc->height : 480;
-   bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
-   pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+   bpp = fb ? fb->format->cpp[0] * 8 : 32;
+   pitch = fb ? fb->pitches[0] : width * bpp / 8;
x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
@@ -66,14 +67,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 * VirtualBox, certain parts of the code still assume that the first
 * screen is programmed this way, so try to fake it.
 */
-   if (vbox_crtc->crtc_id == 0 && crtc->enabled &&
+   if (vbox_crtc->crtc_id == 0 && fb &&
vbox_crtc->fb_offset / pitch < 0x - crtc->y &&
vbox_crtc->fb_offset % (bpp / 8) == 0) {
vbox_write_ioport(VBE_DISPI_INDEX_XRES, width);
vbox_write_ioport(VBE_DISPI_INDEX_YRES, height);
vbox_write_ioport(VBE_DISPI_INDEX_VIRT_WIDT

[PATCH 04/15] staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc

2018-09-26 Thread Hans de Goede
When setting a mode we not only pass the mode to the hypervisor,
but also information on how to map / translate input coordinates
for the emulated USB tablet.  This input-mapping may change when
the mode on *another* crtc changes.

This means that sometimes we must do a modeset on other crtc-s then
the one being changed to update the input-mapping. Including crtc-s
which may be disabled inside the guest (shown as a black window
on the host unless closed by the user).

With atomic modesetting the mode-info of disabled crtcs gets zeroed
yet we need it when updating the input-map to avoid resizing the
window as a side effect of a mode_set on another crtc.

This commit adds caching of the mode info into out private vbox_crtc
struct so that we always have the info at hand when we need it.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  | 20 +++
 drivers/staging/vboxvideo/vbox_mode.c | 28 +++
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 6c52cbd9e91e..34c4d7fc6c8e 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -151,6 +151,26 @@ struct vbox_crtc {
bool cursor_enabled;
u32 x_hint;
u32 y_hint;
+   /*
+* When setting a mode we not only pass the mode to the hypervisor,
+* but also information on how to map / translate input coordinates
+* for the emulated USB tablet.  This input-mapping may change when
+* the mode on *another* crtc changes.
+*
+* This means that sometimes we must do a modeset on other crtc-s then
+* the one being changed to update the input-mapping. Including crtc-s
+* which may be disabled inside the guest (shown as a black window
+* on the host unless closed by the user).
+*
+* With atomic modesetting the mode-info of disabled crtcs gets zeroed
+* yet we need it when updating the input-map to avoid resizing the
+* window as a side effect of a mode_set on another crtc. Therefor we
+* cache the info of the last mode below.
+*/
+   u32 width;
+   u32 height;
+   u32 x;
+   u32 y;
 };
 
 struct vbox_encoder {
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index adb6bcf989d1..e85b27f95def 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -48,8 +48,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc, int x, int 
y);
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
  */
-static void vbox_do_modeset(struct drm_crtc *crtc,
-   const struct drm_display_mode *mode)
+static void vbox_do_modeset(struct drm_crtc *crtc)
 {
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
@@ -58,12 +57,12 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
s32 x_offset, y_offset;
 
vbox = crtc->dev->dev_private;
-   width = mode->hdisplay ? mode->hdisplay : 640;
-   height = mode->vdisplay ? mode->vdisplay : 480;
+   width = vbox_crtc->width ? vbox_crtc->width : 640;
+   height = vbox_crtc->height ? vbox_crtc->height : 480;
bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
-   x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
-   y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint;
+   x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
+   y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
/*
 * This is the old way of setting graphics modes.  It assumed one screen
@@ -82,9 +81,9 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
vbox_write_ioport(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
vbox_write_ioport(
VBE_DISPI_INDEX_X_OFFSET,
-   vbox_crtc->fb_offset % pitch / bpp * 8 + crtc->x);
+   vbox_crtc->fb_offset % pitch / bpp * 8 + vbox_crtc->x);
vbox_write_ioport(VBE_DISPI_INDEX_Y_OFFSET,
- vbox_crtc->fb_offset / pitch + crtc->y);
+ vbox_crtc->fb_offset / pitch + vbox_crtc->y);
}
 
flags = VBVA_SCREEN_F_ACTIVE;
@@ -93,7 +92,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   

[PATCH 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-09-26 Thread Hans de Goede
Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_mode.c | 28 ++-
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fccb3851d6a3..9cc20c182df1 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -139,7 +139,6 @@ struct vbox_connector {
 
 struct vbox_crtc {
struct drm_crtc base;
-   bool blanked;
bool disconnected;
unsigned int crtc_id;
u32 fb_offset;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index c4ec3fa49782..49ff9c4a6302 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
 
flags = VBVA_SCREEN_F_ACTIVE;
-   flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
   vbox_crtc->x * bpp / 8 +
vbox_crtc->y * pitch,
-  pitch, width, height,
-  vbox_crtc->blanked ? 0 : bpp, flags);
+  pitch, width, height, bpp, flags);
 }
 
 static int vbox_set_view(struct drm_crtc *crtc)
@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)
return 0;
 }
 
-static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = crtc->dev->dev_private;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   vbox_crtc->blanked = false;
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   vbox_crtc->blanked = true;
-   break;
-   }
-
-   mutex_lock(&vbox->hw_mutex);
-   vbox_do_modeset(crtc);
-   mutex_unlock(&vbox->hw_mutex);
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -276,7 +254,6 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .dpms = vbox_crtc_dpms,
.disable = vbox_crtc_disable,
.commit = vbox_crtc_commit,
.atomic_flush = vbox_crtc_atomic_flush,
@@ -861,7 +838,6 @@ static const struct drm_connector_helper_funcs 
vbox_connector_helper_funcs = {
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-   .dpms = drm_helper_connector_dpms,
.detect = vbox_connector_detect,
.fill_modes = vbox_fill_modes,
.destroy = vbox_connector_destroy,
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] staging: vboxvideo: Convert to atomic modesetting API

2018-09-26 Thread Hans de Goede
Hi All,

This series converts the vboxvideo driver to the modesetting API, once this
is merged I will submit a patch to move the driver out of staging and into
drivers/gpu/drm.

This series consists of 3 parts:

1) More cleanups / prep work for atomic conversion
2) The actual atomic conversion, this is modelled after the atomic conversion
   of the qxl driver done by Gabriel Krisman Bertazi. Gabriel if you are
   reading this, thank you for providing a roadmap how to go about this.
3) Restore some features which were lost by the atomic conversion +
   more cleanups

Regards,

Hans

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-26 Thread Hans de Goede
This cleanups 2 things:

1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.

2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index bef99664d030..4f5d28aeca95 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -169,7 +169,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 {
struct drm_crtc *crtci;
struct drm_connector *connectori;
-   struct drm_framebuffer *fb1 = NULL;
+   struct drm_framebuffer *fb, *fb1 = NULL;
bool single_framebuffer = true;
bool old_single_framebuffer = vbox->single_framebuffer;
u16 width = 0, height = 0;
@@ -180,25 +180,25 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 * Same fall-back if this is the fbdev frame-buffer.
 */
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) {
+   fb = CRTC_FB(crtci);
+   if (!fb)
+   continue;
+
if (!fb1) {
-   fb1 = CRTC_FB(crtci);
+   fb1 = fb;
if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb)
break;
-   } else if (CRTC_FB(crtci) && fb1 != CRTC_FB(crtci)) {
+   } else if (fb != fb1) {
single_framebuffer = false;
}
}
+   if (!fb1)
+   return false;
+
if (single_framebuffer) {
vbox->single_framebuffer = true;
-   list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
-   head) {
-   if (!CRTC_FB(crtci))
-   continue;
-
-   vbox->input_mapping_width = CRTC_FB(crtci)->width;
-   vbox->input_mapping_height = CRTC_FB(crtci)->height;
-   break;
-   }
+   vbox->input_mapping_width = fb1->width;
+   vbox->input_mapping_height = fb1->height;
return old_single_framebuffer != vbox->single_framebuffer;
}
/* Otherwise calculate the total span of all screens. */
-- 
2.19.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/12] staging: vboxvideo: Move bo_[un]resere calls into vbox_bo_[un]pin

2018-09-18 Thread Hans de Goede
We always need to reserve the bo around a pin / unpin, so move the
reservation there.

This allows removing the vbox_fb_[un]pin helpers.

Note this means that we now no longer hold the bo reserved while
k[un]mapping it in vbox_fb.c this is fine as it is not necessary
to hold it reserved for this.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  2 +-
 drivers/staging/vboxvideo/vbox_fb.c   | 27 --
 drivers/staging/vboxvideo/vbox_mode.c | 54 ---
 drivers/staging/vboxvideo/vbox_ttm.c  | 32 +---
 4 files changed, 42 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 6a4d3b382e79..fffde1713101 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -245,7 +245,7 @@ int vbox_bo_create(struct vbox_private *vbox, int size, int 
align,
 int vbox_gem_create(struct vbox_private *vbox,
u32 size, bool iskernel, struct drm_gem_object **obj);
 
-int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag);
 int vbox_bo_unpin(struct vbox_bo *bo);
 
 static inline int vbox_bo_reserve(struct vbox_bo *bo, bool no_wait)
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 0e5550fa7c57..bdc87d02ecc5 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -104,18 +104,11 @@ static int vboxfb_create(struct drm_fb_helper *helper,
 
bo = gem_to_vbox_bo(gobj);
 
-   ret = vbox_bo_reserve(bo, false);
+   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
if (ret)
return ret;
 
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-   if (ret) {
-   vbox_bo_unreserve(bo);
-   return ret;
-   }
-
ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
-   vbox_bo_unreserve(bo);
if (ret) {
DRM_ERROR("failed to kmap fbcon\n");
return ret;
@@ -153,6 +146,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
   sizes->fb_height);
 
+   gpu_addr = vbox_bo_gpu_offset(bo);
info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr;
info->fix.smem_len = vbox->available_vram_size - gpu_addr;
 
@@ -190,17 +184,12 @@ void vbox_fbdev_fini(struct vbox_private *vbox)
if (afb->obj) {
struct vbox_bo *bo = gem_to_vbox_bo(afb->obj);
 
-   if (!vbox_bo_reserve(bo, false)) {
-   if (bo->kmap.virtual)
-   ttm_bo_kunmap(&bo->kmap);
-   /*
-* QXL does this, but is it really needed before
-* freeing?
-*/
-   if (bo->pin_count)
-   vbox_bo_unpin(bo);
-   vbox_bo_unreserve(bo);
-   }
+   if (bo->kmap.virtual)
+   ttm_bo_kunmap(&bo->kmap);
+
+   if (bo->pin_count)
+   vbox_bo_unpin(bo);
+
drm_gem_object_put_unlocked(afb->obj);
afb->obj = NULL;
}
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 910ea19931c9..bef99664d030 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -221,40 +221,6 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
return old_single_framebuffer != vbox->single_framebuffer;
 }
 
-static int vbox_fb_pin(struct drm_framebuffer *fb, u32 pl_flag, u64 *addr)
-{
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
-   int ret;
-
-   ret = vbox_bo_reserve(bo, false);
-   if (ret)
-   return ret;
-
-   ret = vbox_bo_pin(bo, pl_flag, addr);
-   vbox_bo_unreserve(bo);
-   return ret;
-}
-
-static void vbox_fb_unpin(struct drm_framebuffer *fb)
-{
-   struct vbox_bo *bo;
-   int ret;
-
-   if (!fb)
-   return;
-
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
-
-   ret = vbox_bo_reserve(bo, false);
-   if (ret) {
-   DRM_ERROR("Error %d reserving fb bo, leaving it pinned\n", ret);
-   return;
-   }
-
-   vbox_bo_unpin(bo);
-   vbox_bo_unreserve(bo);
-}
-
 static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_display_mode *mode,
@@ -296,17 +262,22 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,

[PATCH 12/12] staging: vboxvideo: Add vbox_bo_k[un]map helper functions

2018-09-18 Thread Hans de Goede
Add vbox_bo_k[un]map helper functions instead of having code directly
poking struct vbox_bo internals.

While touch neighboring code anyways also fix a return -PTR_ERR(info),
which should be return PTR_ERR(info).

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h |  2 ++
 drivers/staging/vboxvideo/vbox_fb.c  | 19 +++
 drivers/staging/vboxvideo/vbox_ttm.c | 28 +++-
 3 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fffde1713101..6c52cbd9e91e 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -269,6 +269,8 @@ static inline void vbox_bo_unreserve(struct vbox_bo *bo)
 void vbox_ttm_placement(struct vbox_bo *bo, int domain);
 int vbox_bo_push_sysram(struct vbox_bo *bo);
 int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
+void *vbox_bo_kmap(struct vbox_bo *bo);
+void vbox_bo_kunmap(struct vbox_bo *bo);
 
 /* vbox_prime.c */
 int vbox_gem_prime_pin(struct drm_gem_object *obj);
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index bdc87d02ecc5..b8b42f9aafae 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -108,15 +108,14 @@ static int vboxfb_create(struct drm_fb_helper *helper,
if (ret)
return ret;
 
-   ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
-   if (ret) {
-   DRM_ERROR("failed to kmap fbcon\n");
-   return ret;
-   }
-
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info))
-   return -PTR_ERR(info);
+   return PTR_ERR(info);
+
+   info->screen_size = size;
+   info->screen_base = (char __iomem *)vbox_bo_kmap(bo);
+   if (IS_ERR(info->screen_base))
+   return PTR_ERR(info->screen_base);
 
info->par = fbdev;
 
@@ -150,9 +149,6 @@ static int vboxfb_create(struct drm_fb_helper *helper,
info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr;
info->fix.smem_len = vbox->available_vram_size - gpu_addr;
 
-   info->screen_base = (char __iomem *)bo->kmap.virtual;
-   info->screen_size = size;
-
 #ifdef CONFIG_DRM_KMS_FB_HELPER
info->fbdefio = &vbox_defio;
fb_deferred_io_init(info);
@@ -184,8 +180,7 @@ void vbox_fbdev_fini(struct vbox_private *vbox)
if (afb->obj) {
struct vbox_bo *bo = gem_to_vbox_bo(afb->obj);
 
-   if (bo->kmap.virtual)
-   ttm_bo_kunmap(&bo->kmap);
+   vbox_bo_kunmap(bo);
 
if (bo->pin_count)
vbox_bo_unpin(bo);
diff --git a/drivers/staging/vboxvideo/vbox_ttm.c 
b/drivers/staging/vboxvideo/vbox_ttm.c
index bd0a1603764e..5ecfa7629173 100644
--- a/drivers/staging/vboxvideo/vbox_ttm.c
+++ b/drivers/staging/vboxvideo/vbox_ttm.c
@@ -418,8 +418,10 @@ int vbox_bo_push_sysram(struct vbox_bo *bo)
if (bo->pin_count)
return 0;
 
-   if (bo->kmap.virtual)
+   if (bo->kmap.virtual) {
ttm_bo_kunmap(&bo->kmap);
+   bo->kmap.virtual = NULL;
+   }
 
vbox_ttm_placement(bo, TTM_PL_FLAG_SYSTEM);
 
@@ -448,3 +450,27 @@ int vbox_mmap(struct file *filp, struct vm_area_struct 
*vma)
 
return ttm_bo_mmap(filp, vma, &vbox->ttm.bdev);
 }
+
+void *vbox_bo_kmap(struct vbox_bo *bo)
+{
+   int ret;
+
+   if (bo->kmap.virtual)
+   return bo->kmap.virtual;
+
+   ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
+   if (ret) {
+   DRM_ERROR("Error kmapping bo: %d\n", ret);
+   return NULL;
+   }
+
+   return bo->kmap.virtual;
+}
+
+void vbox_bo_kunmap(struct vbox_bo *bo)
+{
+   if (bo->kmap.virtual) {
+   ttm_bo_kunmap(&bo->kmap);
+   bo->kmap.virtual = NULL;
+   }
+}
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/12] staging: vboxvideo: Embed drm_device into driver structure

2018-09-18 Thread Hans de Goede
This is the recommended way to create the drm_device structure,
according to DRM documentation.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c  | 110 +++---
 drivers/staging/vboxvideo/vbox_drv.h  |  17 ++--
 drivers/staging/vboxvideo/vbox_fb.c   |  19 ++---
 drivers/staging/vboxvideo/vbox_irq.c  |   8 +-
 drivers/staging/vboxvideo/vbox_main.c |  30 +++
 drivers/staging/vboxvideo/vbox_mode.c |  36 -
 drivers/staging/vboxvideo/vbox_ttm.c  |  13 ++-
 7 files changed, 111 insertions(+), 122 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index 410a1f35b746..c4290d4b4a53 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -51,35 +51,31 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
 {
-   struct vbox_private *vbox = NULL;
-   struct drm_device *dev = NULL;
+   struct vbox_private *vbox;
int ret = 0;
 
if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
return -ENODEV;
 
-   dev = drm_dev_alloc(&driver, &pdev->dev);
-   if (IS_ERR(dev))
-   return PTR_ERR(dev);
+   vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
+   if (!vbox)
+   return -ENOMEM;
 
-   ret = pci_enable_device(pdev);
-   if (ret)
-   goto err_dev_put;
-
-   dev->pdev = pdev;
-   pci_set_drvdata(pdev, dev);
-
-   vbox = devm_kzalloc(&pdev->dev, sizeof(*vbox), GFP_KERNEL);
-   if (!vbox) {
-   ret = -ENOMEM;
-   goto err_pci_disable;
+   ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
+   if (ret) {
+   kfree(vbox);
+   return ret;
}
 
-   dev->dev_private = vbox;
-   vbox->dev = dev;
-
+   vbox->ddev.pdev = pdev;
+   vbox->ddev.dev_private = vbox;
+   pci_set_drvdata(pdev, vbox);
mutex_init(&vbox->hw_mutex);
 
+   ret = pci_enable_device(pdev);
+   if (ret)
+   goto err_dev_put;
+
ret = vbox_hw_init(vbox);
if (ret)
goto err_pci_disable;
@@ -88,7 +84,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (ret)
goto err_hw_fini;
 
-   ret = vbox_mode_init(dev);
+   ret = vbox_mode_init(vbox);
if (ret)
goto err_mm_fini;
 
@@ -96,22 +92,22 @@ static int vbox_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (ret)
goto err_mode_fini;
 
-   ret = vbox_fbdev_init(dev);
+   ret = vbox_fbdev_init(vbox);
if (ret)
goto err_irq_fini;
 
-   ret = drm_dev_register(dev, 0);
+   ret = drm_dev_register(&vbox->ddev, 0);
if (ret)
goto err_fbdev_fini;
 
return 0;
 
 err_fbdev_fini:
-   vbox_fbdev_fini(dev);
+   vbox_fbdev_fini(vbox);
 err_irq_fini:
vbox_irq_fini(vbox);
 err_mode_fini:
-   vbox_mode_fini(dev);
+   vbox_mode_fini(vbox);
 err_mm_fini:
vbox_mm_fini(vbox);
 err_hw_fini:
@@ -119,110 +115,100 @@ static int vbox_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 err_pci_disable:
pci_disable_device(pdev);
 err_dev_put:
-   drm_dev_put(dev);
+   drm_dev_put(&vbox->ddev);
return ret;
 }
 
 static void vbox_pci_remove(struct pci_dev *pdev)
 {
-   struct drm_device *dev = pci_get_drvdata(pdev);
-   struct vbox_private *vbox = dev->dev_private;
+   struct vbox_private *vbox = pci_get_drvdata(pdev);
 
-   drm_dev_unregister(dev);
-   vbox_fbdev_fini(dev);
+   drm_dev_unregister(&vbox->ddev);
+   vbox_fbdev_fini(vbox);
vbox_irq_fini(vbox);
-   vbox_mode_fini(dev);
+   vbox_mode_fini(vbox);
vbox_mm_fini(vbox);
vbox_hw_fini(vbox);
-   drm_dev_put(dev);
+   drm_dev_put(&vbox->ddev);
 }
 
-static int vbox_drm_freeze(struct drm_device *dev)
+static int vbox_drm_freeze(struct vbox_private *vbox)
 {
-   struct vbox_private *vbox = dev->dev_private;
-
-   drm_kms_helper_poll_disable(dev);
+   drm_kms_helper_poll_disable(&vbox->ddev);
 
-   pci_save_state(dev->pdev);
+   pci_save_state(vbox->ddev.pdev);
 
drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
 
return 0;
 }
 
-static int vbox_drm_thaw(struct drm_device *dev)
+static int vbox_drm_thaw(struct vbox_private *vbox)
 {
-   struct vbox_private *vbox = dev->dev_private;
-
-   drm_mode_config_reset(dev);
-   drm_helper_resume_force_mode(dev);
+   drm_mode_config_reset(&vbox->ddev);
+   drm_helper_resume_force_mode(&vbox->ddev);
drm_fb_helper_set_suspend_unlocked(&vbox->fbdev-&g

[PATCH 10/12] staging: vboxvideo: Fix NULL ptr deref in vbox_set_up_input_mapping()

2018-09-18 Thread Hans de Goede
When vbox_set_up_input_mapping() gets called the first crtc might be
disable and not have a fb at all, triggering a NUL ptr deref at:

vbox->input_mapping_width = CRTC_FB(crtci)->width;

Instead of using the fb from the crtc with id 0, just use the fb from
the first crtc with a fb. This is in the single_framebuffer = true path,
so all crtc-s point to the same fb anyways.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 1a2416a59fe0..910ea19931c9 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -189,17 +189,17 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
}
}
if (single_framebuffer) {
+   vbox->single_framebuffer = true;
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
head) {
-   if (to_vbox_crtc(crtci)->crtc_id != 0)
+   if (!CRTC_FB(crtci))
continue;
 
-   vbox->single_framebuffer = true;
vbox->input_mapping_width = CRTC_FB(crtci)->width;
vbox->input_mapping_height = CRTC_FB(crtci)->height;
-   return old_single_framebuffer !=
-  vbox->single_framebuffer;
+   break;
}
+   return old_single_framebuffer != vbox->single_framebuffer;
}
/* Otherwise calculate the total span of all screens. */
list_for_each_entry(connectori, &vbox->ddev.mode_config.connector_list,
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/12] staging: vboxvideo: Move pin / unpin of fb out of vbox_crtc_set_base_and_mode

2018-09-18 Thread Hans de Goede
Move pin / unpin of fb out of vbox_crtc_set_base_and_mode() so that it can
be used to implement the atomic_update drm_plane_helper_func for the primary
plane.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  5 +++
 drivers/staging/vboxvideo/vbox_mode.c | 52 ++-
 drivers/staging/vboxvideo/vbox_ttm.c  |  5 ---
 3 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 5034c6bd5445..6a4d3b382e79 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -220,6 +220,11 @@ static inline struct vbox_bo *vbox_bo(struct 
ttm_buffer_object *bo)
 
 #define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base)
 
+static inline u64 vbox_bo_gpu_offset(struct vbox_bo *bo)
+{
+   return bo->bo.offset;
+}
+
 int vbox_dumb_create(struct drm_file *file,
 struct drm_device *dev,
 struct drm_mode_create_dumb *args);
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 6d7a89524fbf..1a2416a59fe0 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -255,28 +255,18 @@ static void vbox_fb_unpin(struct drm_framebuffer *fb)
vbox_bo_unreserve(bo);
 }
 
-static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
-  struct drm_framebuffer *old_fb,
-  struct drm_framebuffer *new_fb,
-  struct drm_display_mode *mode,
-  int x, int y)
+static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
+   struct drm_framebuffer *fb,
+   struct drm_display_mode *mode,
+   int x, int y)
 {
+   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
struct vbox_private *vbox = crtc->dev->dev_private;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   u64 gpu_addr;
-   int ret;
-
-   /* Prepare: pin the new framebuffer bo */
-   ret = vbox_fb_pin(new_fb, TTM_PL_FLAG_VRAM, &gpu_addr);
-   if (ret) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
-   return ret;
-   }
 
-   /* Commit: Update hardware to use the new fb */
mutex_lock(&vbox->hw_mutex);
 
-   vbox_crtc->fb_offset = gpu_addr;
+   vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo);
 
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
if (mode && vbox_set_up_input_mapping(vbox)) {
@@ -299,11 +289,6 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
   vbox->input_mapping_height);
 
mutex_unlock(&vbox->hw_mutex);
-
-   /* Cleanup: unpin the old fb */
-   vbox_fb_unpin(old_fb);
-
-   return 0;
 }
 
 static int vbox_crtc_mode_set(struct drm_crtc *crtc,
@@ -311,8 +296,19 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
  struct drm_display_mode *adjusted_mode,
  int x, int y, struct drm_framebuffer *old_fb)
 {
-   return vbox_crtc_set_base_and_mode(crtc, old_fb, CRTC_FB(crtc),
-  mode, x, y);
+   int ret;
+
+   ret = vbox_fb_pin(CRTC_FB(crtc), TTM_PL_FLAG_VRAM, NULL);
+   if (ret) {
+   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
+   return ret;
+   }
+
+   vbox_crtc_set_base_and_mode(crtc, CRTC_FB(crtc), mode, x, y);
+
+   vbox_fb_unpin(old_fb);
+
+   return 0;
 }
 
 static int vbox_crtc_page_flip(struct drm_crtc *crtc,
@@ -324,9 +320,15 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc,
unsigned long flags;
int rc;
 
-   rc = vbox_crtc_set_base_and_mode(crtc, CRTC_FB(crtc), fb, NULL, 0, 0);
-   if (rc)
+   rc = vbox_fb_pin(fb, TTM_PL_FLAG_VRAM, NULL);
+   if (rc) {
+   DRM_WARN("Error %d pinning new fb, out of video mem?\n", rc);
return rc;
+   }
+
+   vbox_crtc_set_base_and_mode(crtc, fb, NULL, 0, 0);
+
+   vbox_fb_unpin(CRTC_FB(crtc));
 
spin_lock_irqsave(&crtc->dev->event_lock, flags);
 
diff --git a/drivers/staging/vboxvideo/vbox_ttm.c 
b/drivers/staging/vboxvideo/vbox_ttm.c
index 7b8eac30faca..0e14556dcd6b 100644
--- a/drivers/staging/vboxvideo/vbox_ttm.c
+++ b/drivers/staging/vboxvideo/vbox_ttm.c
@@ -343,11 +343,6 @@ int vbox_bo_create(struct vbox_private *vbox, int size, 
int align,
return ret;
 }
 
-static inline u64 vbox_bo_gpu_offset(struct vbox_bo *bo)
-{
-   return bo->bo.offset;
-}
-
 int vbox_bo_pin(struct vbox

[PATCH 08/12] staging: vboxvideo: Init fb_info.fix.smem once from fbdev_create

2018-09-18 Thread Hans de Goede
The fbdev compat fb gets pinned into VRAM at creation and then gets pinned
a second time when set as scanout buffer and unpinned when replaced, this
means its pin count never becomes less then 1, so it is always at the same
address and there is no need for the vbox_fbdev_set_base() call.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_fb.c   | 14 +-
 drivers/staging/vboxvideo/vbox_mode.c |  3 ---
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 28ffdffe877a..5034c6bd5445 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -201,7 +201,6 @@ int vbox_framebuffer_init(struct vbox_private *vbox,
 
 int vbox_fbdev_init(struct vbox_private *vbox);
 void vbox_fbdev_fini(struct vbox_private *vbox);
-void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr);
 
 struct vbox_bo {
struct ttm_buffer_object bo;
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 11b6364ed14a..0e5550fa7c57 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -80,6 +80,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
struct drm_gem_object *gobj;
struct vbox_bo *bo;
int size, ret;
+   u64 gpu_addr;
u32 pitch;
 
mode_cmd.width = sizes->surface_width;
@@ -107,7 +108,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
if (ret)
return ret;
 
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
if (ret) {
vbox_bo_unreserve(bo);
return ret;
@@ -152,6 +153,9 @@ static int vboxfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
   sizes->fb_height);
 
+   info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr;
+   info->fix.smem_len = vbox->available_vram_size - gpu_addr;
+
info->screen_base = (char __iomem *)bo->kmap.virtual;
info->screen_size = size;
 
@@ -241,11 +245,3 @@ int vbox_fbdev_init(struct vbox_private *vbox)
drm_fb_helper_fini(&fbdev->helper);
return ret;
 }
-
-void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr)
-{
-   struct fb_info *fbdev = vbox->fbdev->helper.fbdev;
-
-   fbdev->fix.smem_start = fbdev->apertures->ranges[0].base + gpu_addr;
-   fbdev->fix.smem_len = vbox->available_vram_size - gpu_addr;
-}
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index f35045ce154b..6d7a89524fbf 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -276,9 +276,6 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
/* Commit: Update hardware to use the new fb */
mutex_lock(&vbox->hw_mutex);
 
-   if (&vbox->fbdev->afb == to_vbox_framebuffer(new_fb))
-   vbox_fbdev_set_base(vbox, gpu_addr);
-
vbox_crtc->fb_offset = gpu_addr;
 
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/12] staging: vboxvideo: Expose creation of universal primary plane

2018-09-18 Thread Hans de Goede
Let's expose the primary plane initialization inside the vboxvideo driver
in preparation for universal planes and atomic.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 78 +--
 1 file changed, 74 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 3beae9d65a09..f35045ce154b 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -382,21 +382,91 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.destroy = vbox_crtc_destroy,
 };
 
+static const uint32_t vbox_primary_plane_formats[] = {
+   DRM_FORMAT_XRGB,
+   DRM_FORMAT_ARGB,
+};
+
+static const struct drm_plane_funcs vbox_primary_plane_funcs = {
+   .update_plane   = drm_primary_helper_update,
+   .disable_plane  = drm_primary_helper_disable,
+   .destroy= drm_primary_helper_destroy,
+};
+
+static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
+  unsigned int possible_crtcs,
+  enum drm_plane_type type)
+{
+   const struct drm_plane_helper_funcs *helper_funcs = NULL;
+   const struct drm_plane_funcs *funcs;
+   struct drm_plane *plane;
+   const uint32_t *formats;
+   int num_formats;
+   int err;
+
+   if (type == DRM_PLANE_TYPE_PRIMARY) {
+   funcs = &vbox_primary_plane_funcs;
+   formats = vbox_primary_plane_formats;
+   num_formats = ARRAY_SIZE(vbox_primary_plane_formats);
+   } else {
+   return ERR_PTR(-EINVAL);
+   }
+
+   plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+   if (!plane)
+   return ERR_PTR(-ENOMEM);
+
+   err = drm_universal_plane_init(&vbox->ddev, plane, possible_crtcs,
+  funcs, formats, num_formats,
+  NULL, type, NULL);
+   if (err)
+   goto free_plane;
+
+   drm_plane_helper_add(plane, helper_funcs);
+
+   return plane;
+
+free_plane:
+   kfree(plane);
+   return ERR_PTR(-EINVAL);
+}
+
 static struct vbox_crtc *vbox_crtc_init(struct drm_device *dev, unsigned int i)
 {
+   struct vbox_private *vbox =
+   container_of(dev, struct vbox_private, ddev);
struct vbox_crtc *vbox_crtc;
+   struct drm_plane *primary;
+   int ret;
 
vbox_crtc = kzalloc(sizeof(*vbox_crtc), GFP_KERNEL);
if (!vbox_crtc)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
+
+   primary = vbox_create_plane(vbox, 1 << i, DRM_PLANE_TYPE_PRIMARY);
+   if (IS_ERR(primary)) {
+   ret = PTR_ERR(primary);
+   goto free_mem;
+   }
 
vbox_crtc->crtc_id = i;
 
-   drm_crtc_init(dev, &vbox_crtc->base, &vbox_crtc_funcs);
+   ret = drm_crtc_init_with_planes(dev, &vbox_crtc->base, primary, NULL,
+   &vbox_crtc_funcs, NULL);
+   if (ret)
+   goto clean_primary;
+
drm_mode_crtc_set_gamma_size(&vbox_crtc->base, 256);
drm_crtc_helper_add(&vbox_crtc->base, &vbox_crtc_helper_funcs);
 
return vbox_crtc;
+
+clean_primary:
+   drm_plane_cleanup(primary);
+   kfree(primary);
+free_mem:
+   kfree(vbox_crtc);
+   return ERR_PTR(ret);
 }
 
 static void vbox_encoder_destroy(struct drm_encoder *encoder)
@@ -750,8 +820,8 @@ int vbox_mode_init(struct vbox_private *vbox)
/* vbox_cursor_init(dev); */
for (i = 0; i < vbox->num_crtcs; ++i) {
vbox_crtc = vbox_crtc_init(dev, i);
-   if (!vbox_crtc) {
-   ret = -ENOMEM;
+   if (IS_ERR(vbox_crtc)) {
+   ret = PTR_ERR(vbox_crtc);
goto err_drm_mode_cleanup;
}
encoder = vbox_encoder_init(dev, i);
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/12] staging: vboxvideo: Add fl_flag argument to vbox_fb_pin() helper

2018-09-18 Thread Hans de Goede
Allow specifying where to pin the framebuffer bo, so that this helper can
be used from the cursor code too.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 13696ba19c4f..3beae9d65a09 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -221,7 +221,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
return old_single_framebuffer != vbox->single_framebuffer;
 }
 
-static int vbox_fb_pin(struct drm_framebuffer *fb, u64 *addr)
+static int vbox_fb_pin(struct drm_framebuffer *fb, u32 pl_flag, u64 *addr)
 {
struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
int ret;
@@ -230,7 +230,7 @@ static int vbox_fb_pin(struct drm_framebuffer *fb, u64 
*addr)
if (ret)
return ret;
 
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, addr);
+   ret = vbox_bo_pin(bo, pl_flag, addr);
vbox_bo_unreserve(bo);
return ret;
 }
@@ -267,7 +267,7 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
int ret;
 
/* Prepare: pin the new framebuffer bo */
-   ret = vbox_fb_pin(new_fb, &gpu_addr);
+   ret = vbox_fb_pin(new_fb, TTM_PL_FLAG_VRAM, &gpu_addr);
if (ret) {
DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
return ret;
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/12] staging: vboxvideo: Let DRM core handle connector registering

2018-09-18 Thread Hans de Goede
Registering the connector explicitly right after creation is not necessary
for modesetting drivers, because drm_dev_register already takes care of
this on the core side, by calling drm_modeset_register_all.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e7d70ced5bfd..70701a6054c2 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -690,7 +690,6 @@ static int vbox_connector_init(struct drm_device *dev,
   dev->mode_config.suggested_x_property, 0);
drm_object_attach_property(&connector->base,
   dev->mode_config.suggested_y_property, 0);
-   drm_connector_register(connector);
 
drm_connector_attach_encoder(connector, encoder);
 
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/12] staging: vboxvideo: Fold vbox_drm_resume() into vbox_pm_resume()

2018-09-18 Thread Hans de Goede
vbox_pm_resume() is the only caller of vbox_drm_resume(), so squash the
2 functions into 1.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c4290d4b4a53..c6a53b0ad66c 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -152,22 +152,6 @@ static int vbox_drm_thaw(struct vbox_private *vbox)
return 0;
 }
 
-static int vbox_drm_resume(struct vbox_private *vbox)
-{
-   int ret;
-
-   if (pci_enable_device(vbox->ddev.pdev))
-   return -EIO;
-
-   ret = vbox_drm_thaw(vbox);
-   if (ret)
-   return ret;
-
-   drm_kms_helper_poll_enable(&vbox->ddev);
-
-   return 0;
-}
-
 static int vbox_pm_suspend(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
@@ -186,8 +170,18 @@ static int vbox_pm_suspend(struct device *dev)
 static int vbox_pm_resume(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
+   int ret;
 
-   return vbox_drm_resume(vbox);
+   if (pci_enable_device(vbox->ddev.pdev))
+   return -EIO;
+
+   ret = vbox_drm_thaw(vbox);
+   if (ret)
+   return ret;
+
+   drm_kms_helper_poll_enable(&vbox->ddev);
+
+   return 0;
 }
 
 static int vbox_pm_freeze(struct device *dev)
-- 
2.19.0.rc1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   4   >