Re: [PATCH 1/3] drm/v3d: fix up register addresses for V3D 7.x

2023-09-29 Thread itoral
On 2023-09-28 15:03, Maira Canal wrote:
> Hi Iago,
> 
> On 9/28/23 08:45, Iago Toral Quiroga wrote:
> 
> Please, add a commit message and your s-o-b to the patch. Here is a reference 
> on how to format your patches [1].
> 
> Also, please, run checkpatch on this patch and address the warnings.
> 
> [1] https://docs.kernel.org/process/submitting-patches.html
> 
>> ---
>>   drivers/gpu/drm/v3d/v3d_debugfs.c | 173 +-
>>   drivers/gpu/drm/v3d/v3d_gem.c |   3 +
>>   drivers/gpu/drm/v3d/v3d_irq.c |  47 
>>   drivers/gpu/drm/v3d/v3d_regs.h|  51 -
>>   drivers/gpu/drm/v3d/v3d_sched.c   |  41 ---
>>   5 files changed, 200 insertions(+), 115 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c 
>> b/drivers/gpu/drm/v3d/v3d_debugfs.c
>> index 330669f51fa7..90b2b5b2710c 100644
>> --- a/drivers/gpu/drm/v3d/v3d_debugfs.c
>> +++ b/drivers/gpu/drm/v3d/v3d_debugfs.c
>> @@ -12,69 +12,83 @@
>>   #include "v3d_drv.h"
>>   #include "v3d_regs.h"
>>   
> 
> [...]
> 
>> diff --git a/drivers/gpu/drm/v3d/v3d_regs.h b/drivers/gpu/drm/v3d/v3d_regs.h
>> index 3663e0d6bf76..9fbcbfedaae1 100644
>> --- a/drivers/gpu/drm/v3d/v3d_regs.h
>> +++ b/drivers/gpu/drm/v3d/v3d_regs.h
>> @@ -57,6 +57,7 @@
>>   #define V3D_HUB_INT_MSK_STS0x0005c
>>   #define V3D_HUB_INT_MSK_SET0x00060
>>   #define V3D_HUB_INT_MSK_CLR0x00064
>> +# define V3D_V7_HUB_INT_GMPV   BIT(6)
>>   # define V3D_HUB_INT_MMU_WRV   BIT(5)
>>   # define V3D_HUB_INT_MMU_PTI   BIT(4)
>>   # define V3D_HUB_INT_MMU_CAP   BIT(3)
>> @@ -64,6 +65,7 @@
>>   # define V3D_HUB_INT_TFUC  BIT(1)
>>   # define V3D_HUB_INT_TFUF  BIT(0)
>>   +/* GCA registers only exist in V3D < 41 */
>>   #define V3D_GCA_CACHE_CTRL 0xc
>>   # define V3D_GCA_CACHE_CTRL_FLUSH  BIT(0)
>>   @@ -87,6 +89,7 @@
>>   # define V3D_TOP_GR_BRIDGE_SW_INIT_1_V3D_CLK_108_SW_INIT BIT(0)
>> #define V3D_TFU_CS 0x00400
>> +#define V3D_V7_TFU_CS  0x00700
> 
> What do you think about something like
> 
> #define V3D_TFU_CS(ver)   (ver >= 71) ? 0x00700 : 0x00400
> 
> I believe that the code would get much cleaner and would avoid a bunch
> of the if statements that you used.
> 
> I would apply this format to all the new registers.

Sure, that sounds good. Thanks!

Iago

> Best Regards,
> - Maíra
> 
>>   /* Stops current job, empties input fifo. */
>>   # define V3D_TFU_CS_TFURST BIT(31)
>>   # define V3D_TFU_CS_CVTCT_MASK V3D_MASK(23, 16)
>> @@ -96,6 +99,7 @@
>>   # define V3D_TFU_CS_BUSY   BIT(0)
>> #define V3D_TFU_SU 0x00404
>> +#define V3D_V7_TFU_SU  0x00704
>>   /* Interrupt when FINTTHR input slots are free (0 = disabled) */
>>   # define V3D_TFU_SU_FINTTHR_MASK   V3D_MASK(13, 8)
>>   # define V3D_TFU_SU_FINTTHR_SHIFT  8
>> @@ -107,38 +111,53 @@
>>   # define V3D_TFU_SU_THROTTLE_SHIFT 0
>> #define V3D_TFU_ICFG   0x00408
>> +#define V3D_V7_TFU_ICFG0x00708
>>   /* Interrupt when the conversion is complete. */
>>   # define V3D_TFU_ICFG_IOC  BIT(0)
>> /* Input Image Address */
>>   #define V3D_TFU_IIA0x0040c
>> +#define V3D_V7_TFU_IIA 0x0070c
>>   /* Input Chroma Address */
>>   #define V3D_TFU_ICA0x00410
>> +#define V3D_V7_TFU_ICA 0x00710
>>   /* Input Image Stride */
>>   #define V3D_TFU_IIS0x00414
>> +#define V3D_V7_TFU_IIS 0x00714
>>   /* Input Image U-Plane Address */
>>   #define V3D_TFU_IUA0x00418
>> +#define V3D_V7_TFU_IUA 0x00718
>> +/* Image output config (VD 7.x only) */
>> +#define V3D_V7_TFU_IOC 0x0071c
>>   /* Output Image Address */
>>   #define V3D_TFU_IOA0x0041c
>> +#define V3D_V7_TFU_IOA 0x00720
>>   /* Image Output Size */
>>   #define V3D_TFU_IOS0x00420
>> +#define V3D_V7_TFU_IOS 0x00724
>>   /* TFU YUV Coefficient 0 */
>>   #define V3D_TFU_COEF0  0x00424
>> -/* Use these regs instead of the defaults. */
>> +#define V3D_V7_TFU_COEF0   0x00728
>> +/* Use these regs instead of the defaults 

Re: [PATCH 2/3] drm/v3d: update UAPI to match user-space for V3D 7.x

2023-09-29 Thread itoral
On 2023-09-28 15:05, Maira Canal wrote:
> Hi Iago,
> 
> On 9/28/23 08:45, Iago Toral Quiroga wrote:
>> V3D t.x takes a new parameter to configure TFU jobs that needs
> 
> I believe t.x should be 7.x.
> 
>> to be provided by user space.
> 
> As I mentioned before, please, add your s-o-b.
> 
>> ---
>>   include/uapi/drm/v3d_drm.h | 5 +
>>   1 file changed, 5 insertions(+)
>> 
>> diff --git a/include/uapi/drm/v3d_drm.h b/include/uapi/drm/v3d_drm.h
>> index 3dfc0af8756a..1a7d7a689de3 100644
>> --- a/include/uapi/drm/v3d_drm.h
>> +++ b/include/uapi/drm/v3d_drm.h
>> @@ -319,6 +319,11 @@ struct drm_v3d_submit_tfu {
>>  /* Pointer to an array of ioctl extensions*/
>>  __u64 extensions;
>> +
>> +struct {
>> +__u32 ioc;
>> +__u32 pad;
>> +} v71;
> 
> Is there any possibility that the name of the struct could be more
> meaningful?

The v71 stands for the hardware version where this field was introduced,
so I am not sure how much more meaningful we can make it :)

The idea for this was to pack version-specific fields into structs named
vXX so that you can quickly tell in which version specific fields
started being relevant directly from the code without having to look for
documentation elsewhere. I don't have a better alternative for the name,
since the point is to make the version explicit, but I am open to
suggestions if you have any.

Of course, we can also get rid of the struct if you prefer that, but
then we should document explicitly that this field only applies to v71
hardware and we would lose the explicit versioning when accessing the
field from the code (unless we decide to add the v71 as a prefix or
suffix in the ioc field, but that is kind of the same thing).

Iago

> 
> Best Regards,
> - Maíra
> 
>>   };
>> /* Submits a compute shader for dispatch.  This job will block on any