linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Keith Zhao <keith.zhao@starfivetech.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Cc: Conor Dooley <conor+dt@kernel.org>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Emil Renner Berthing <kernel@esmil.dk>,
	christian.koenig@amd.com, Bjorn Andersson <andersson@kernel.org>,
	Chris Morgan <macromorgan@hotmail.com>,
	Changhuang Liang <changhuang.liang@starfivetech.com>,
	Jagan Teki <jagan@edgeble.ai>,
	Jack Zhu <jack.zhu@starfivetech.com>,
	Rob Herring <robh+dt@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Shengyang Chen <shengyang.chen@starfivetech.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>
Subject: Re: [PATCH 4/9] drm/verisilicon: Add gem driver for JH7110 SoC
Date: Wed, 21 Jun 2023 12:44:28 +0200	[thread overview]
Message-ID: <5b87fb5c-2f23-47c9-b6a8-623472115876@suse.de> (raw)
In-Reply-To: <f7ded369-e384-db01-dc8c-6a5183f20409@suse.de>


[-- Attachment #1.1: Type: text/plain, Size: 4281 bytes --]

Hi

Am 19.06.23 um 16:22 schrieb Thomas Zimmermann:
> Hi
> 
> Am 02.06.23 um 09:40 schrieb Keith Zhao:
>> This patch implements gem related APIs for JH7100 SoC.
> 
> please also see my other reply to this patch. My mail client had a bug 
> before I could finish it. Below are some more comments.
> 
>>
>> Signed-off-by: Keith Zhao <keith.zhao@starfivetech.com>
>> ---
> [...]
>> +#ifndef __VS_GEM_H__
>> +#define __VS_GEM_H__
>> +
>> +#include <linux/dma-buf.h>
>> +
>> +#include <drm/drm_gem.h>
>> +#include <drm/drm_prime.h>
>> +
>> +#include "vs_drv.h"
>> +/*
>> + *
>> + * @base: drm gem object.
>> + * @size: size requested from user
>> + * @cookie: cookie returned by dma_alloc_attrs
>> + *    - not kernel virtual address with DMA_ATTR_NO_KERNEL_MAPPING
>> + * @dma_addr: bus address(accessed by dma) to allocated memory region.
>> + *    - this address could be physical address without IOMMU and
>> + *    device address with IOMMU.
>> + * @dma_attrs: attribute for DMA API
>> + * @get_pages: flag for manually applying for non-contiguous memory.
>> + * @pages: Array of backing pages.
>> + * @sgt: Imported sg_table.
>> + *
>> + */
>> +struct vs_gem_object {
>> +    struct drm_gem_object    base;
>> +    size_t            size;
>> +    void            *cookie;
>> +    dma_addr_t        dma_addr;
>> +    u32                iova;
>> +    unsigned long    dma_attrs;
>> +    bool            get_pages;
>> +    struct page        **pages;
>> +    struct sg_table *sgt;
>> +};
>> +
>> +static inline
>> +struct vs_gem_object *to_vs_gem_object(struct drm_gem_object *obj)
>> +{
>> +    return container_of(obj, struct vs_gem_object, base);
>> +}
>> +
>> +struct vs_gem_object *vs_gem_create_object(struct drm_device *dev,
>> +                       size_t size);
>> +
>> +int vs_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map 
>> *map);
>> +void vs_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map 
>> *map);
> 
> I'd consider this bad style. Your functions are in the vs_ namespace, so 
> they should take a vs_gem_object as first argument. Rather implement 
> vs_gem_prime_vmap(struct vs_gem_object *vs_obj, struct iosys_map *map)
> and _vunmap() and _mmap().
> 
> For the callbacks in struct drm_gemobject_funcs, you can write small 
> wrappers around the helpers to do the type casting. See 
> drm_gem_shmem_object_mmap() and drm_gem_shmem_mmap() for an example.
> 
> https://elixir.bootlin.com/linux/latest/source/include/drm/drm_gem_shmem_helper.h#L233

I was thinking about my advise with the wrappers, but it doesn't seem so 
good after all. Maybe just ignore it. I think you should still rename 
the function to something like vs_gem_object_vmap(), etc.  So they name 
reflects that they operate on a struct drm_gem_object.

But many of the helpers in this file are only ever used in vs_gem.c. 
You should declare them static in the C file and remove them from this 
header.

Best regards
Thomas

> 
> 
> 
>> +
>> +int vs_gem_prime_mmap(struct drm_gem_object *obj,
>> +              struct vm_area_struct *vma);
>> +
>> +int vs_gem_dumb_create(struct drm_file *file_priv,
>> +               struct drm_device *drm,
>> +               struct drm_mode_create_dumb *args);
>> +
>> +int vs_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>> +
>> +struct sg_table *vs_gem_prime_get_sg_table(struct drm_gem_object *obj);
>> +
>> +struct drm_gem_object *vs_gem_prime_import(struct drm_device *dev,
>> +                       struct dma_buf *dma_buf);
>> +struct drm_gem_object *
>> +vs_gem_prime_import_sg_table(struct drm_device *dev,
>> +                 struct dma_buf_attachment *attach,
>> +                 struct sg_table *sgt);
>> +
>> +#endif /* __VS_GEM_H__ */
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-06-21 10:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02  7:40 [PATCH 0/9] Add DRM driver for StarFive SoC JH7110 Keith Zhao
2023-06-02  7:40 ` [PATCH 1/9] dt-bindings: display: Add yamls for JH7110 display subsystem Keith Zhao
2023-06-02 18:21   ` Conor Dooley
2023-06-06 18:41     ` Shengyu Qu
2023-06-06 22:22       ` Heiko Stübner
2023-06-06 22:37         ` Conor Dooley
2023-06-07  6:41           ` Maxime Ripard
2023-06-07  8:02             ` Keith Zhao
2023-06-07  8:40           ` Heiko Stübner
2023-06-07  7:35   ` Krzysztof Kozlowski
2023-06-02  7:40 ` [PATCH 2/9] riscv: dts: starfive: jh7110: add dc&hdmi controller node Keith Zhao
2023-06-07  7:38   ` Krzysztof Kozlowski
2023-06-02  7:40 ` [PATCH 3/9] drm/verisilicon: Add basic drm driver Keith Zhao
2023-06-07  8:53   ` Lucas Stach
2023-07-25  3:12     ` Keith Zhao
2023-07-25 11:23       ` Keith Zhao
2023-06-19 12:59   ` Thomas Zimmermann
2023-07-07 18:09     ` Nicolas Dufresne
2023-07-08 19:11       ` Thomas Zimmermann
2023-07-13 15:14         ` Nicolas Dufresne
2023-07-03 18:42   ` Shengyu Qu
2023-07-04  6:09     ` Keith Zhao
2023-06-02  7:40 ` [PATCH 4/9] drm/verisilicon: Add gem driver for JH7110 SoC Keith Zhao
2023-06-19 13:18   ` Thomas Zimmermann
2023-07-20 10:00     ` Keith Zhao
2023-06-19 14:22   ` Thomas Zimmermann
2023-06-21 10:44     ` Thomas Zimmermann [this message]
2023-06-02  7:40 ` [PATCH 5/9] drm/verisilicon: Add mode config funcs Keith Zhao
2023-06-21 11:04   ` Thomas Zimmermann
2023-07-21  9:06     ` Keith Zhao
2023-06-02  7:40 ` [PATCH 6/9] drm/verisilicon: Add drm crtc funcs Keith Zhao
2023-06-30 11:55   ` Thomas Zimmermann
2023-07-21 11:57     ` Keith Zhao
2023-07-21 12:32       ` Sam Ravnborg
2023-06-02  7:40 ` [PATCH 7/9] drm/verisilicon: Add drm plane funcs Keith Zhao
2023-06-30 12:14   ` Thomas Zimmermann
2023-07-10 16:46   ` Shengyu Qu
2023-07-11  1:44     ` Keith Zhao
2023-06-02  7:40 ` [PATCH 8/9] drm/verisilicon: Add verisilicon dc controller driver Keith Zhao
2023-06-30 12:36   ` Thomas Zimmermann
2023-06-02  7:40 ` [PATCH 9/9] drm/verisilicon: Add starfive hdmi driver Keith Zhao
2023-06-05  8:08   ` Philipp Zabel
2023-06-05  9:56   ` Maxime Ripard
2023-06-23  2:38   ` Hoegeun Kwon
2023-06-26  5:34     ` Keith Zhao
2023-06-22 18:19 ` [PATCH 0/9] Add DRM driver for StarFive SoC JH7110 Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b87fb5c-2f23-47c9-b6a8-623472115876@suse.de \
    --to=tzimmermann@suse.de \
    --cc=andersson@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=changhuang.liang@starfivetech.com \
    --cc=christian.koenig@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jack.zhu@starfivetech.com \
    --cc=jagan@edgeble.ai \
    --cc=keith.zhao@starfivetech.com \
    --cc=kernel@esmil.dk \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=macromorgan@hotmail.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=shengyang.chen@starfivetech.com \
    --cc=sumit.semwal@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).