Re: [PATCH 6/6] drm/amdgpu: Make struct drm_driver const

2020-11-05 Thread Luben Tuikov
On 2020-11-05 10:36, Daniel Vetter wrote:
> On Wed, Nov 04, 2020 at 11:04:25AM +0100, Daniel Vetter wrote:
>> From: Luben Tuikov 
>>
>> Make the definition of struct drm_driver
>> a constant, to follow the latest developments
>> in the DRM layer.
>>
>> Signed-off-by: Luben Tuikov 
>> [danvet: Rebase onto devm_drm_dev_alloc patch and drop the freesync
>> ioctl line again that escaped from internal trees.]
>> Signed-off-by: Daniel Vetter 
> 
> Entire series merged to drm-misc-next, with an irc ack from Alex for this
> one here. Thanks everyone who helped out with patches and reviews!
> -Daniel

Great! Thanks.

Regards,
Luben

> 
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 31 +
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 24 +--
>>  2 files changed, 28 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> index 8b30915aa972..d6fced7a9a03 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> @@ -40,6 +40,7 @@
>>  #include "amdgpu.h"
>>  #include "amdgpu_irq.h"
>>  #include "amdgpu_dma_buf.h"
>> +#include "amdgpu_sched.h"
>>  
>>  #include "amdgpu_amdkfd.h"
>>  
>> @@ -1094,7 +1095,7 @@ static const struct pci_device_id pciidlist[] = {
>>  
>>  MODULE_DEVICE_TABLE(pci, pciidlist);
>>  
>> -static struct drm_driver kms_driver;
>> +static const struct drm_driver amdgpu_kms_driver;
>>  
>>  static int amdgpu_pci_probe(struct pci_dev *pdev,
>>  const struct pci_device_id *ent)
>> @@ -1165,7 +1166,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
>>  if (ret)
>>  return ret;
>>  
>> -adev = devm_drm_dev_alloc(>dev, _driver, typeof(*adev), ddev);
>> +adev = devm_drm_dev_alloc(>dev, _kms_driver, 
>> typeof(*adev), ddev);
>>  if (IS_ERR(adev))
>>  return PTR_ERR(adev);
>>  
>> @@ -1509,7 +1510,29 @@ int amdgpu_file_to_fpriv(struct file *filp, struct 
>> amdgpu_fpriv **fpriv)
>>  return 0;
>>  }
>>  
>> -static struct drm_driver kms_driver = {
>> +int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file 
>> *filp);
>> +
>> +const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_VM, amdgpu_vm_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_SCHED, amdgpu_sched_ioctl, DRM_MASTER),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_BO_LIST, amdgpu_bo_list_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_FENCE_TO_HANDLE, 
>> amdgpu_cs_fence_to_handle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
>> +/* KMS */
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_MMAP, amdgpu_gem_mmap_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_WAIT_IDLE, amdgpu_gem_wait_idle_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_CS, amdgpu_cs_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_INFO, amdgpu_info_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_CS, amdgpu_cs_wait_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_FENCES, amdgpu_cs_wait_fences_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, 
>> DRM_AUTH|DRM_RENDER_ALLOW),
>> +};
>> +
>> +static const struct drm_driver amdgpu_kms_driver = {
>>  .driver_features =
>>  DRIVER_ATOMIC |
>>  DRIVER_GEM |
>> @@ -1520,6 +1543,7 @@ static struct drm_driver kms_driver = {
>>  .lastclose = amdgpu_driver_lastclose_kms,
>>  .irq_handler = amdgpu_irq_handler,
>>  .ioctls = amdgpu_ioctls_kms,
>> +.num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms),
>>  .dumb_create = amdgpu_mode_dumb_create,
>>  .dumb_map_offset = amdgpu_mode_dumb_mmap,
>>  .fops = _driver_kms_fops,
>> @@ -1572,7 +1596,6 @@ static int __init amdgpu_init(void)
>>  goto error_fence;
>>  
>>  DRM_INFO("amdgpu kernel modesetting enabled.\n");
>> -kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
>>  amdgpu_register_atpx_handler();
>>  
>>  /* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index efda38349a03..ab6d9f1186c2 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -29,7 +29,6 @@
>>  #include "amdgpu.h"
>>  

Re: [PATCH 6/6] drm/amdgpu: Make struct drm_driver const

2020-11-05 Thread Daniel Vetter
On Wed, Nov 04, 2020 at 11:04:25AM +0100, Daniel Vetter wrote:
> From: Luben Tuikov 
> 
> Make the definition of struct drm_driver
> a constant, to follow the latest developments
> in the DRM layer.
> 
> Signed-off-by: Luben Tuikov 
> [danvet: Rebase onto devm_drm_dev_alloc patch and drop the freesync
> ioctl line again that escaped from internal trees.]
> Signed-off-by: Daniel Vetter 

Entire series merged to drm-misc-next, with an irc ack from Alex for this
one here. Thanks everyone who helped out with patches and reviews!
-Daniel

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 31 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 24 +--
>  2 files changed, 28 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 8b30915aa972..d6fced7a9a03 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -40,6 +40,7 @@
>  #include "amdgpu.h"
>  #include "amdgpu_irq.h"
>  #include "amdgpu_dma_buf.h"
> +#include "amdgpu_sched.h"
>  
>  #include "amdgpu_amdkfd.h"
>  
> @@ -1094,7 +1095,7 @@ static const struct pci_device_id pciidlist[] = {
>  
>  MODULE_DEVICE_TABLE(pci, pciidlist);
>  
> -static struct drm_driver kms_driver;
> +static const struct drm_driver amdgpu_kms_driver;
>  
>  static int amdgpu_pci_probe(struct pci_dev *pdev,
>   const struct pci_device_id *ent)
> @@ -1165,7 +1166,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
>   if (ret)
>   return ret;
>  
> - adev = devm_drm_dev_alloc(>dev, _driver, typeof(*adev), ddev);
> + adev = devm_drm_dev_alloc(>dev, _kms_driver, 
> typeof(*adev), ddev);
>   if (IS_ERR(adev))
>   return PTR_ERR(adev);
>  
> @@ -1509,7 +1510,29 @@ int amdgpu_file_to_fpriv(struct file *filp, struct 
> amdgpu_fpriv **fpriv)
>   return 0;
>  }
>  
> -static struct drm_driver kms_driver = {
> +int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file 
> *filp);
> +
> +const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_VM, amdgpu_vm_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_SCHED, amdgpu_sched_ioctl, DRM_MASTER),
> + DRM_IOCTL_DEF_DRV(AMDGPU_BO_LIST, amdgpu_bo_list_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_FENCE_TO_HANDLE, 
> amdgpu_cs_fence_to_handle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
> + /* KMS */
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_MMAP, amdgpu_gem_mmap_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_WAIT_IDLE, amdgpu_gem_wait_idle_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_CS, amdgpu_cs_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_INFO, amdgpu_info_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_CS, amdgpu_cs_wait_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_FENCES, amdgpu_cs_wait_fences_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, 
> DRM_AUTH|DRM_RENDER_ALLOW),
> +};
> +
> +static const struct drm_driver amdgpu_kms_driver = {
>   .driver_features =
>   DRIVER_ATOMIC |
>   DRIVER_GEM |
> @@ -1520,6 +1543,7 @@ static struct drm_driver kms_driver = {
>   .lastclose = amdgpu_driver_lastclose_kms,
>   .irq_handler = amdgpu_irq_handler,
>   .ioctls = amdgpu_ioctls_kms,
> + .num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms),
>   .dumb_create = amdgpu_mode_dumb_create,
>   .dumb_map_offset = amdgpu_mode_dumb_mmap,
>   .fops = _driver_kms_fops,
> @@ -1572,7 +1596,6 @@ static int __init amdgpu_init(void)
>   goto error_fence;
>  
>   DRM_INFO("amdgpu kernel modesetting enabled.\n");
> - kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
>   amdgpu_register_atpx_handler();
>  
>   /* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index efda38349a03..ab6d9f1186c2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -29,7 +29,6 @@
>  #include "amdgpu.h"
>  #include 
>  #include 
> -#include "amdgpu_sched.h"
>  #include "amdgpu_uvd.h"
>  #include "amdgpu_vce.h"
>  #include "atom.h"
> @@ -480,7 +479,7 @@ static int 

[PATCH 6/6] drm/amdgpu: Make struct drm_driver const

2020-11-04 Thread Daniel Vetter
From: Luben Tuikov 

Make the definition of struct drm_driver
a constant, to follow the latest developments
in the DRM layer.

Signed-off-by: Luben Tuikov 
[danvet: Rebase onto devm_drm_dev_alloc patch and drop the freesync
ioctl line again that escaped from internal trees.]
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 31 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 24 +--
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 8b30915aa972..d6fced7a9a03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -40,6 +40,7 @@
 #include "amdgpu.h"
 #include "amdgpu_irq.h"
 #include "amdgpu_dma_buf.h"
+#include "amdgpu_sched.h"
 
 #include "amdgpu_amdkfd.h"
 
@@ -1094,7 +1095,7 @@ static const struct pci_device_id pciidlist[] = {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
-static struct drm_driver kms_driver;
+static const struct drm_driver amdgpu_kms_driver;
 
 static int amdgpu_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
@@ -1165,7 +1166,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;
 
-   adev = devm_drm_dev_alloc(>dev, _driver, typeof(*adev), ddev);
+   adev = devm_drm_dev_alloc(>dev, _kms_driver, 
typeof(*adev), ddev);
if (IS_ERR(adev))
return PTR_ERR(adev);
 
@@ -1509,7 +1510,29 @@ int amdgpu_file_to_fpriv(struct file *filp, struct 
amdgpu_fpriv **fpriv)
return 0;
 }
 
-static struct drm_driver kms_driver = {
+int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file 
*filp);
+
+const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_VM, amdgpu_vm_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_SCHED, amdgpu_sched_ioctl, DRM_MASTER),
+   DRM_IOCTL_DEF_DRV(AMDGPU_BO_LIST, amdgpu_bo_list_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_FENCE_TO_HANDLE, 
amdgpu_cs_fence_to_handle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
+   /* KMS */
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_MMAP, amdgpu_gem_mmap_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_WAIT_IDLE, amdgpu_gem_wait_idle_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_CS, amdgpu_cs_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_INFO, amdgpu_info_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_CS, amdgpu_cs_wait_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_FENCES, amdgpu_cs_wait_fences_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
+};
+
+static const struct drm_driver amdgpu_kms_driver = {
.driver_features =
DRIVER_ATOMIC |
DRIVER_GEM |
@@ -1520,6 +1543,7 @@ static struct drm_driver kms_driver = {
.lastclose = amdgpu_driver_lastclose_kms,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
+   .num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms),
.dumb_create = amdgpu_mode_dumb_create,
.dumb_map_offset = amdgpu_mode_dumb_mmap,
.fops = _driver_kms_fops,
@@ -1572,7 +1596,6 @@ static int __init amdgpu_init(void)
goto error_fence;
 
DRM_INFO("amdgpu kernel modesetting enabled.\n");
-   kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
amdgpu_register_atpx_handler();
 
/* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index efda38349a03..ab6d9f1186c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -29,7 +29,6 @@
 #include "amdgpu.h"
 #include 
 #include 
-#include "amdgpu_sched.h"
 #include "amdgpu_uvd.h"
 #include "amdgpu_vce.h"
 #include "atom.h"
@@ -480,7 +479,7 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
  * etc. (all asics).
  * Returns 0 on success, -EINVAL on failure.
  */
-static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct 
drm_file *filp)
+int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file 
*filp)
 {
struct amdgpu_device *adev = drm_to_adev(dev);
struct drm_amdgpu_info *info =