All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 1/3] lib/intel_memory_regions: Add helper which creates supported dma-buf set
Date: Wed, 2 Mar 2022 13:48:28 +0200	[thread overview]
Message-ID: <2928dc5c-eb45-e6d8-b572-09b0198161af@intel.com> (raw)
In-Reply-To: <20220301075803.117058-2-zbigniew.kempczynski@intel.com>

Reviewed-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Tested-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>

If the https://patchwork.freedesktop.org/series/100737/ patch (currently 
under review) is applied to the i915, you can see that the 
igt@prime_mmap test works normally in dg1.

On 3/1/22 9:58 AM, Zbigniew Kempczyński wrote:
> As different systems support or not dma-buf add function helper which
> will create set of supported by dma-buf memory regions.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>   lib/i915/intel_memory_region.c | 61 ++++++++++++++++++++++++++++++++++
>   lib/i915/intel_memory_region.h |  3 ++
>   2 files changed, 64 insertions(+)
> 
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index a8759e069..a2db74566 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -332,6 +332,67 @@ char *memregion_dynamic_subtest_name(struct igt_collection *set)
>   	return name;
>   }
>   
> +struct mmap_supported_region {
> +	uint32_t region;
> +	struct igt_list_head link;
> +};
> +
> +/**
> + * get_dma_buf_mmap_supported_set:
> + * @i915: i915 drm file descriptor
> + * @set: memory regions set
> + *
> + * Function constructs set with regions which supports dma-buf mapping.
> + *
> + * Returns: set of regions which allows do dma-buf mmap or NULL otherwise.
> + *
> + * Note: set (igt_collection) need to be destroyed after use.
> + */
> +struct igt_collection *
> +get_dma_buf_mmap_supported_set(int i915, struct igt_collection *set)
> +{
> +	struct igt_collection *region, *supported_set = NULL;
> +	uint32_t reg;
> +	int dma_buf_fd;
> +	char *ptr;
> +	uint32_t handle, bosize = 4096;
> +	int count = 0;
> +	struct mmap_supported_region *mreg, *tmp;
> +	IGT_LIST_HEAD(region_list);
> +
> +	for_each_combination(region, 1, set) {
> +		reg = igt_collection_get_value(region, 0);
> +		handle = gem_create_in_memory_regions(i915, bosize, reg);
> +
> +		dma_buf_fd = prime_handle_to_fd(i915, handle);
> +		ptr = mmap(NULL, bosize, PROT_READ, MAP_SHARED, dma_buf_fd, 0);
> +		if (ptr != MAP_FAILED) {
> +			mreg = malloc(sizeof(*mreg));
> +			igt_assert(mreg);
> +			mreg->region = reg;
> +			igt_list_add_tail(&mreg->link, &region_list);
> +			count++;
> +		}
> +		munmap(ptr, bosize);
> +		gem_close(i915, handle);
> +		close(dma_buf_fd);
> +	}
> +
> +	if (count) {
> +		int i = 0;
> +
> +		supported_set = igt_collection_create(count);
> +
> +		igt_list_for_each_entry_safe(mreg, tmp, &region_list, link) {
> +			igt_collection_set_value(supported_set, i++, mreg->region);
> +			igt_list_del(&mreg->link);
> +			free(mreg);
> +		}
> +	}
> +
> +	return supported_set;
> +}
> +
>   /**
>    * intel_dump_gpu_meminfo:
>    * @info: pointer to drm_i915_query_memory_regions structure
> diff --git a/lib/i915/intel_memory_region.h b/lib/i915/intel_memory_region.h
> index 936e7d1c8..bd92267b6 100644
> --- a/lib/i915/intel_memory_region.h
> +++ b/lib/i915/intel_memory_region.h
> @@ -111,6 +111,9 @@ __get_memory_region_set(struct drm_i915_query_memory_regions *regions,
>   	__get_memory_region_set(regions, arr__, ARRAY_SIZE(arr__)); \
>   })
>   
> +struct igt_collection *
> +get_dma_buf_mmap_supported_set(int i915, struct igt_collection *set);
> +
>   char *memregion_dynamic_subtest_name(struct igt_collection *set);
>   
>   void intel_dump_gpu_meminfo(const struct drm_i915_query_memory_regions *info);
> 

  reply	other threads:[~2022-03-02 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  7:58 [igt-dev] [PATCH i-g-t 0/3] Use supported dma-buf regions in prime_mmap* Zbigniew Kempczyński
2022-03-01  7:58 ` [igt-dev] [PATCH i-g-t 1/3] lib/intel_memory_regions: Add helper which creates supported dma-buf set Zbigniew Kempczyński
2022-03-02 11:48   ` Gwan-gyeong Mun [this message]
2022-03-01  7:58 ` [igt-dev] [PATCH i-g-t 2/3] tests/prime_mmap: Iterate over dma-buf supported memory regions Zbigniew Kempczyński
2022-03-01 12:38   ` Kamil Konieczny
2022-03-02 11:49   ` Gwan-gyeong Mun
2022-03-02 11:54     ` Gwan-gyeong Mun
2022-03-01  7:58 ` [igt-dev] [PATCH i-g-t 3/3] tests/prime_mmap_coherency.c: Use intel_bb and intel_buf to remove libdrm dependency Zbigniew Kempczyński
2022-03-01  8:44 ` [igt-dev] ✓ Fi.CI.BAT: success for Use supported dma-buf regions in prime_mmap* (rev2) Patchwork
2022-03-01 15:35 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2022-03-02  8:06 [igt-dev] [PATCH i-g-t 0/3] Use supported dma-buf regions in prime_mmap* Zbigniew Kempczyński
2022-03-02  8:06 ` [igt-dev] [PATCH i-g-t 1/3] lib/intel_memory_regions: Add helper which creates supported dma-buf set Zbigniew Kempczyński
2022-03-02  9:37   ` Kamil Konieczny
2022-03-02 12:23   ` Gwan-gyeong Mun
2022-03-03 11:46     ` Zbigniew Kempczyński
2022-02-28 13:03 [igt-dev] [PATCH i-g-t 0/3] Use supported dma-buf regions in prime_mmap* Zbigniew Kempczyński
2022-02-28 13:03 ` [igt-dev] [PATCH i-g-t 1/3] lib/intel_memory_regions: Add helper which creates supported dma-buf set Zbigniew Kempczyński
2022-02-28 21:33   ` Kamil Konieczny
2022-03-02  8:15     ` Zbigniew Kempczyński

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=2928dc5c-eb45-e6d8-b572-09b0198161af@intel.com \
    --to=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.