All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: linaro-mm-sig@lists.linaro.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org
Subject: Re: [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14
Date: Tue, 18 Feb 2020 14:20:02 +0100	[thread overview]
Message-ID: <cb607ed5-eaeb-5332-d1de-77cae8512c1d@gmail.com> (raw)
In-Reply-To: <20191105102045.GC10326@phenom.ffwll.local>

Am 05.11.19 um 11:20 schrieb Daniel Vetter:
> On Tue, Oct 29, 2019 at 11:40:45AM +0100, Christian König wrote:
> [SNIP]
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index d377b4ca66bf..ce293cee76ed 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -529,6 +529,10 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>   		    exp_info->ops->dynamic_mapping))
>>   		return ERR_PTR(-EINVAL);
>>   
>> +	if (WARN_ON(!exp_info->ops->dynamic_mapping &&
>> +		    (exp_info->ops->pin || exp_info->ops->unpin)))
>> +		return ERR_PTR(-EINVAL);
> Imo make this stronger, have a dynamic mapping iff there's both a pin and
> unpin function. Otherwise this doesn't make a lot of sense to me.

I want to avoid that for the initial implementation. So far dynamic only 
meant that we have the new locking semantics.

We could make that mandatory after this patch set when amdgpu is 
migrated and has implemented the necessary callbacks.

>> [SNIP]
>> @@ -821,13 +877,23 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
>>   		return attach->sgt;
>>   	}
>>   
>> -	if (dma_buf_is_dynamic(attach->dmabuf))
>> +	if (dma_buf_is_dynamic(attach->dmabuf)) {
>>   		dma_resv_assert_held(attach->dmabuf->resv);
>> +		if (!attach->importer_ops->move_notify) {
> Imo just require ->move_notify for importers that give you an ops
> function. Doesn't really make sense to allow dynamic without support
> ->move_notify.

Same thing here. We could make that mandatory and clean it up after 
migrating amdgpu.

>> [SNIP]
>> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
>> index af73f835c51c..7456bb937635 100644
>> --- a/include/linux/dma-buf.h
>> +++ b/include/linux/dma-buf.h
>> @@ -93,14 +93,40 @@ struct dma_buf_ops {
>>   	 */
>>   	void (*detach)(struct dma_buf *, struct dma_buf_attachment *);
>>   
>> +	/**
>> +	 * @pin:
>> +	 *
>> +	 * This is called by dma_buf_pin and lets the exporter know that the
>> +	 * DMA-buf can't be moved any more.
> I think we should add a warning here that pinning is only ok for limited
> use-cases (like scanout or similar), and not as part of general buffer
> management.
>
> i915 uses temporary pins through it's execbuf management (and everywhere
> else), so we have a _lot_ of people in dri-devel with quite different
> ideas of what this might be for :-)

Yeah, that is also a good idea for us. Wrote a one liner, but you might 
want to double check the wording.

>> [SNIP]
>> @@ -141,9 +167,6 @@ struct dma_buf_ops {
>>   	 *
>>   	 * This is called by dma_buf_unmap_attachment() and should unmap and
>>   	 * release the &sg_table allocated in @map_dma_buf, and it is mandatory.
>> -	 * It should also unpin the backing storage if this is the last mapping
>> -	 * of the DMA buffer, it the exporter supports backing storage
>> -	 * migration.
> This is still valid for non-dynamic exporters. Imo keep but clarify that.

OK, changed.

>> [SNIP]
>> @@ -438,16 +491,19 @@ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf)
>>   static inline bool
>>   dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach)
>>   {
>> -	return attach->dynamic_mapping;
>> +	return !!attach->importer_ops;
> Hm why not do the same for exporters, and make them dynamic iff they have
> pin/unpin?

Same thing as before, to migrate amdgpu to the new interface first and 
then make it mandatory.

I think I will just write a cleanup patch into the series which comes 
after the amdgpu changes.

Thanks,
Christian.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: linaro-mm-sig@lists.linaro.org, intel-gfx@lists.freedesktop.org,
	sumit.semwal@linaro.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14
Date: Tue, 18 Feb 2020 14:20:02 +0100	[thread overview]
Message-ID: <cb607ed5-eaeb-5332-d1de-77cae8512c1d@gmail.com> (raw)
In-Reply-To: <20191105102045.GC10326@phenom.ffwll.local>

Am 05.11.19 um 11:20 schrieb Daniel Vetter:
> On Tue, Oct 29, 2019 at 11:40:45AM +0100, Christian König wrote:
> [SNIP]
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index d377b4ca66bf..ce293cee76ed 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -529,6 +529,10 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>   		    exp_info->ops->dynamic_mapping))
>>   		return ERR_PTR(-EINVAL);
>>   
>> +	if (WARN_ON(!exp_info->ops->dynamic_mapping &&
>> +		    (exp_info->ops->pin || exp_info->ops->unpin)))
>> +		return ERR_PTR(-EINVAL);
> Imo make this stronger, have a dynamic mapping iff there's both a pin and
> unpin function. Otherwise this doesn't make a lot of sense to me.

I want to avoid that for the initial implementation. So far dynamic only 
meant that we have the new locking semantics.

We could make that mandatory after this patch set when amdgpu is 
migrated and has implemented the necessary callbacks.

>> [SNIP]
>> @@ -821,13 +877,23 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
>>   		return attach->sgt;
>>   	}
>>   
>> -	if (dma_buf_is_dynamic(attach->dmabuf))
>> +	if (dma_buf_is_dynamic(attach->dmabuf)) {
>>   		dma_resv_assert_held(attach->dmabuf->resv);
>> +		if (!attach->importer_ops->move_notify) {
> Imo just require ->move_notify for importers that give you an ops
> function. Doesn't really make sense to allow dynamic without support
> ->move_notify.

Same thing here. We could make that mandatory and clean it up after 
migrating amdgpu.

>> [SNIP]
>> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
>> index af73f835c51c..7456bb937635 100644
>> --- a/include/linux/dma-buf.h
>> +++ b/include/linux/dma-buf.h
>> @@ -93,14 +93,40 @@ struct dma_buf_ops {
>>   	 */
>>   	void (*detach)(struct dma_buf *, struct dma_buf_attachment *);
>>   
>> +	/**
>> +	 * @pin:
>> +	 *
>> +	 * This is called by dma_buf_pin and lets the exporter know that the
>> +	 * DMA-buf can't be moved any more.
> I think we should add a warning here that pinning is only ok for limited
> use-cases (like scanout or similar), and not as part of general buffer
> management.
>
> i915 uses temporary pins through it's execbuf management (and everywhere
> else), so we have a _lot_ of people in dri-devel with quite different
> ideas of what this might be for :-)

Yeah, that is also a good idea for us. Wrote a one liner, but you might 
want to double check the wording.

>> [SNIP]
>> @@ -141,9 +167,6 @@ struct dma_buf_ops {
>>   	 *
>>   	 * This is called by dma_buf_unmap_attachment() and should unmap and
>>   	 * release the &sg_table allocated in @map_dma_buf, and it is mandatory.
>> -	 * It should also unpin the backing storage if this is the last mapping
>> -	 * of the DMA buffer, it the exporter supports backing storage
>> -	 * migration.
> This is still valid for non-dynamic exporters. Imo keep but clarify that.

OK, changed.

>> [SNIP]
>> @@ -438,16 +491,19 @@ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf)
>>   static inline bool
>>   dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach)
>>   {
>> -	return attach->dynamic_mapping;
>> +	return !!attach->importer_ops;
> Hm why not do the same for exporters, and make them dynamic iff they have
> pin/unpin?

Same thing as before, to migrate amdgpu to the new interface first and 
then make it mandatory.

I think I will just write a cleanup patch into the series which comes 
after the amdgpu changes.

Thanks,
Christian.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, sumit.semwal@linaro.org,
	linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14
Date: Tue, 18 Feb 2020 14:20:02 +0100	[thread overview]
Message-ID: <cb607ed5-eaeb-5332-d1de-77cae8512c1d@gmail.com> (raw)
In-Reply-To: <20191105102045.GC10326@phenom.ffwll.local>

Am 05.11.19 um 11:20 schrieb Daniel Vetter:
> On Tue, Oct 29, 2019 at 11:40:45AM +0100, Christian König wrote:
> [SNIP]
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index d377b4ca66bf..ce293cee76ed 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -529,6 +529,10 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>   		    exp_info->ops->dynamic_mapping))
>>   		return ERR_PTR(-EINVAL);
>>   
>> +	if (WARN_ON(!exp_info->ops->dynamic_mapping &&
>> +		    (exp_info->ops->pin || exp_info->ops->unpin)))
>> +		return ERR_PTR(-EINVAL);
> Imo make this stronger, have a dynamic mapping iff there's both a pin and
> unpin function. Otherwise this doesn't make a lot of sense to me.

I want to avoid that for the initial implementation. So far dynamic only 
meant that we have the new locking semantics.

We could make that mandatory after this patch set when amdgpu is 
migrated and has implemented the necessary callbacks.

>> [SNIP]
>> @@ -821,13 +877,23 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
>>   		return attach->sgt;
>>   	}
>>   
>> -	if (dma_buf_is_dynamic(attach->dmabuf))
>> +	if (dma_buf_is_dynamic(attach->dmabuf)) {
>>   		dma_resv_assert_held(attach->dmabuf->resv);
>> +		if (!attach->importer_ops->move_notify) {
> Imo just require ->move_notify for importers that give you an ops
> function. Doesn't really make sense to allow dynamic without support
> ->move_notify.

Same thing here. We could make that mandatory and clean it up after 
migrating amdgpu.

>> [SNIP]
>> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
>> index af73f835c51c..7456bb937635 100644
>> --- a/include/linux/dma-buf.h
>> +++ b/include/linux/dma-buf.h
>> @@ -93,14 +93,40 @@ struct dma_buf_ops {
>>   	 */
>>   	void (*detach)(struct dma_buf *, struct dma_buf_attachment *);
>>   
>> +	/**
>> +	 * @pin:
>> +	 *
>> +	 * This is called by dma_buf_pin and lets the exporter know that the
>> +	 * DMA-buf can't be moved any more.
> I think we should add a warning here that pinning is only ok for limited
> use-cases (like scanout or similar), and not as part of general buffer
> management.
>
> i915 uses temporary pins through it's execbuf management (and everywhere
> else), so we have a _lot_ of people in dri-devel with quite different
> ideas of what this might be for :-)

Yeah, that is also a good idea for us. Wrote a one liner, but you might 
want to double check the wording.

>> [SNIP]
>> @@ -141,9 +167,6 @@ struct dma_buf_ops {
>>   	 *
>>   	 * This is called by dma_buf_unmap_attachment() and should unmap and
>>   	 * release the &sg_table allocated in @map_dma_buf, and it is mandatory.
>> -	 * It should also unpin the backing storage if this is the last mapping
>> -	 * of the DMA buffer, it the exporter supports backing storage
>> -	 * migration.
> This is still valid for non-dynamic exporters. Imo keep but clarify that.

OK, changed.

>> [SNIP]
>> @@ -438,16 +491,19 @@ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf)
>>   static inline bool
>>   dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach)
>>   {
>> -	return attach->dynamic_mapping;
>> +	return !!attach->importer_ops;
> Hm why not do the same for exporters, and make them dynamic iff they have
> pin/unpin?

Same thing as before, to migrate amdgpu to the new interface first and 
then make it mandatory.

I think I will just write a cleanup patch into the series which comes 
after the amdgpu changes.

Thanks,
Christian.

  reply	other threads:[~2020-02-18 13:20 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 10:40 RFC: Unpinned DMA-buf handling Christian König
2019-10-29 10:40 ` Christian König
2019-10-29 10:40 ` [Intel-gfx] " Christian König
2019-10-29 10:40 ` [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14 Christian König
2019-10-29 10:40   ` Christian König
2019-10-29 10:40   ` [Intel-gfx] " Christian König
2019-11-05 10:20   ` Daniel Vetter
2019-11-05 10:20     ` Daniel Vetter
2019-11-05 10:20     ` [Intel-gfx] " Daniel Vetter
2020-02-18 13:20     ` Christian König [this message]
2020-02-18 13:20       ` Christian König
2020-02-18 13:20       ` [Intel-gfx] " Christian König
2020-02-18 14:14       ` Daniel Vetter
2020-02-18 14:14         ` Daniel Vetter
2020-02-18 14:14         ` [Intel-gfx] " Daniel Vetter
2019-10-29 10:40 ` [PATCH 2/5] drm/ttm: remove the backing store if no placement is given Christian König
2019-10-29 10:40   ` Christian König
2019-10-29 10:40   ` [Intel-gfx] " Christian König
2019-10-29 10:40 ` [PATCH 3/5] drm/amdgpu: use allowed_domains for exported DMA-bufs Christian König
2019-10-29 10:40   ` Christian König
2019-10-29 10:40   ` [Intel-gfx] " Christian König
2019-10-29 10:40 ` [PATCH 4/5] drm/amdgpu: add amdgpu_dma_buf_pin/unpin Christian König
2019-10-29 10:40   ` Christian König
2019-10-29 10:40   ` [Intel-gfx] " Christian König
2019-10-29 10:40 ` [PATCH 5/5] drm/amdgpu: implement amdgpu_gem_prime_move_notify Christian König
2019-10-29 10:40   ` Christian König
2019-10-29 10:40   ` [Intel-gfx] " Christian König
2019-11-05 10:52   ` Daniel Vetter
2019-11-05 10:52     ` Daniel Vetter
2019-11-05 10:52     ` [Intel-gfx] " Daniel Vetter
2019-11-05 13:39     ` Christian König
2019-11-05 13:39       ` Christian König
2019-11-05 13:39       ` [Intel-gfx] " Christian König
2019-11-05 13:50       ` Daniel Vetter
2019-11-05 13:50         ` Daniel Vetter
2019-11-05 13:50         ` [Intel-gfx] " Daniel Vetter
2019-11-05 13:50         ` Daniel Vetter
2019-11-05 15:20         ` Koenig, Christian
2019-11-05 15:20           ` Koenig, Christian
2019-11-05 15:20           ` [Intel-gfx] " Koenig, Christian
2019-11-05 15:20           ` Koenig, Christian
2019-11-05 15:23           ` Daniel Vetter
2019-11-05 15:23             ` Daniel Vetter
2019-11-05 15:23             ` [Intel-gfx] " Daniel Vetter
2019-11-05 15:23             ` Daniel Vetter
2019-10-29 17:38 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] dma-buf: add dynamic DMA-buf handling v14 Patchwork
2019-10-29 17:38   ` [Intel-gfx] " Patchwork
2019-10-29 18:09 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-10-29 18:09   ` [Intel-gfx] " Patchwork
2019-11-05 13:46 ` RFC: Unpinned DMA-buf handling Daniel Vetter
2019-11-05 13:46   ` Daniel Vetter
2019-11-05 13:46   ` [Intel-gfx] " Daniel Vetter
2019-11-05 13:46   ` Daniel Vetter
  -- strict thread matches above, loose matches on Subject: below --
2020-02-17 15:45 Christian König
2020-02-17 15:45 ` [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14 Christian König
2020-02-17 15:45   ` Christian König
2020-02-17 15:50   ` Christian König
2020-02-17 15:50     ` Christian König

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=cb607ed5-eaeb-5332-d1de-77cae8512c1d@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.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 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.