Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [Intel-gfx] [RFC PATCH] drm/ttm: Allow the driver to resolve a WW transaction rollback
Date: Thu, 25 May 2023 15:59:40 +0200	[thread overview]
Message-ID: <f7db4c6c-24df-b723-7710-490355082c24@amd.com> (raw)
In-Reply-To: <f5ac5b8ceacda35f435e7e6945429c2168314aae.camel@linux.intel.com>

Am 25.05.23 um 14:59 schrieb Thomas Hellström:
> On Fri, 2023-05-05 at 16:17 +0200, Thomas Hellström wrote:
>> Allow drivers to resolve a WW transaction rollback. This allows for
>> 1) Putting a lower-priority transaction to sleep allowing another to
>> succeed instead both fighting using trylocks.
>> 2) Letting the driver know whether a received -ENOMEM is the result
>> of
>> competition with another WW transaction, which can be resolved using
>> rollback and retry or a real -ENOMEM which should be propagated back
>> to user-space as a failure.
>>
>> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Christian, Any objections?

General idea sounds like what I had in mind as well, but I've moved both 
my office and household in the last two weeks and are now digging 
through >800 unread mails/patches.

Give me some days to catch up and I can take a detailed look.

Christian.

>
> /Thomas
>
>
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++++++++++--
>>   include/drm/ttm/ttm_bo.h     |  2 ++
>>   2 files changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>> b/drivers/gpu/drm/ttm/ttm_bo.c
>> index bd5dae4d1624..c3ccbea2be3e 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -561,6 +561,10 @@ static int ttm_mem_evict_wait_busy(struct
>> ttm_buffer_object *busy_bo,
>>          if (!busy_bo || !ticket)
>>                  return -EBUSY;
>>   
>> +       /* We want to resolve contention before trying to lock again.
>> */
>> +       if (ctx->propagate_edeadlk && ctx->contended_bo)
>> +               return  -EDEADLK;
>> +
>>          if (ctx->interruptible)
>>                  r = dma_resv_lock_interruptible(busy_bo->base.resv,
>>                                                            ticket);
>> @@ -575,7 +579,15 @@ static int ttm_mem_evict_wait_busy(struct
>> ttm_buffer_object *busy_bo,
>>          if (!r)
>>                  dma_resv_unlock(busy_bo->base.resv);
>>   
>> -       return r == -EDEADLK ? -EBUSY : r;
>> +       if (r == -EDEADLK) {
>> +               if (ctx->propagate_edeadlk) {
>> +                       ttm_bo_get(busy_bo);
>> +                       ctx->contended_bo = busy_bo;
>> +               }
>> +               r = -EBUSY;
>> +       }
>> +
>> +       return r;
>>   }
>>   
>>   int ttm_mem_evict_first(struct ttm_device *bdev,
>> @@ -816,7 +828,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object
>> *bo,
>>                          goto error;
>>          }
>>   
>> -       ret = -ENOMEM;
>> +       ret = (ctx->propagate_edeadlk && ctx->contended_bo) ? -
>> EDEADLK : -ENOMEM;
>>          if (!type_found) {
>>                  pr_err(TTM_PFX "No compatible memory type found\n");
>>                  ret = -EINVAL;
>> @@ -913,6 +925,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
>>                  if (ret)
>>                          return ret;
>>          }
>> +
>>          return 0;
>>   }
>>   EXPORT_SYMBOL(ttm_bo_validate);
>> diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
>> index 8b113c384236..d8e35a794ce5 100644
>> --- a/include/drm/ttm/ttm_bo.h
>> +++ b/include/drm/ttm/ttm_bo.h
>> @@ -181,8 +181,10 @@ struct ttm_operation_ctx {
>>          bool gfp_retry_mayfail;
>>          bool allow_res_evict;
>>          bool force_alloc;
>> +       bool propagate_edeadlk;
>>          struct dma_resv *resv;
>>          uint64_t bytes_moved;
>> +       struct ttm_buffer_object *contended_bo;
>>   };
>>   
>>   /**


      reply	other threads:[~2023-05-25 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 14:17 [Intel-gfx] [RFC PATCH] drm/ttm: Allow the driver to resolve a WW transaction rollback Thomas Hellström
2023-05-05 20:19 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for " Patchwork
2023-05-05 20:33 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2023-05-25 12:59 ` [Intel-gfx] [RFC PATCH] " Thomas Hellström
2023-05-25 13:59   ` Christian König [this message]

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=f7db4c6c-24df-b723-7710-490355082c24@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=thomas.hellstrom@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox