lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f7ded369-e384-db01-dc8c-6a5183f20409@suse.de>
Date:   Mon, 19 Jun 2023 16:22:26 +0200
From:   Thomas Zimmermann <tzimmermann@...e.de>
To:     Keith Zhao <keith.zhao@...rfivetech.com>,
        dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
        linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org
Cc:     Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Sumit Semwal <sumit.semwal@...aro.org>,
        Emil Renner Berthing <kernel@...il.dk>,
        Shengyang Chen <shengyang.chen@...rfivetech.com>,
        Conor Dooley <conor+dt@...nel.org>,
        Albert Ou <aou@...s.berkeley.edu>,
        Jagan Teki <jagan@...eble.ai>,
        Rob Herring <robh+dt@...nel.org>,
        Chris Morgan <macromorgan@...mail.com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Bjorn Andersson <andersson@...nel.org>,
        Changhuang Liang <changhuang.liang@...rfivetech.com>,
        Jack Zhu <jack.zhu@...rfivetech.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Shawn Guo <shawnguo@...nel.org>, christian.koenig@....com
Subject: Re: [PATCH 4/9] drm/verisilicon: Add gem driver for JH7110 SoC

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@...rfivetech.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



> +
> +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)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ