Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 1/7] drm/xe: Introduce const cast helper
Date: Fri, 19 Jul 2024 18:55:43 +0200	[thread overview]
Message-ID: <280022b5-cbb0-405c-8285-92335edf5d3b@intel.com> (raw)
In-Reply-To: <gs32gpbe62ph7j3l7akrrtcc4z2wr3kv7xnezb3szwedcaezds@hohvqsmqilc2>



On 19.07.2024 18:32, Lucas De Marchi wrote:
> On Wed, Jul 17, 2024 at 09:51:49PM GMT, Michal Wajdeczko wrote:
>> Typically we want to preserve pointer constness when converting
>> from one xe pointer to another, but in some rare cases, like kunit
>> parameter conversions, we might want to discard this constness.
>> Add a helper that we will use to clearly indicate our intention.
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_device.h | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_device.h
>> b/drivers/gpu/drm/xe/xe_device.h
>> index 0a2a3e7fd402..c2b1f9f066bd 100644
>> --- a/drivers/gpu/drm/xe/xe_device.h
>> +++ b/drivers/gpu/drm/xe/xe_device.h
>> @@ -20,6 +20,11 @@ static inline struct xe_device
>> *pdev_to_xe_device(struct pci_dev *pdev)
>>     return pci_get_drvdata(pdev);
>> }
>>
>> +static inline struct xe_device *xe_device_const_cast(const struct
>> xe_device *xe)
>> +{
>> +    return pdev_to_xe_device(to_pci_dev(xe->drm.dev));
> 
> why are you going through pdev_to_xe_device() rather than doing what the
> function name says and just remove the const?

IIRC this was my initial way how to get rid of the const without doing a
forced cast and it was before I decided to introduce a helper for it and
before this helper was named this way ;)

and while explicit cast is more direct (and I can still do that way in
next rev if preferred), then it will be just pure C language concept,
while the potential advantage of doing that through pdev_to_xe_device()
is that it shows that this non-const xe pointer could be still obtained
indirectly, so it should be safe to do so

> 
> Lucas De Marchi
> 
>> +}
>> +
>> static inline struct xe_device *ttm_to_xe_device(struct ttm_device *ttm)
>> {
>>     return container_of(ttm, struct xe_device, ttm);
>> -- 
>> 2.43.0
>>

  reply	other threads:[~2024-07-19 16:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 19:51 [PATCH v2 0/7] Convert live tests to parameterized style Michal Wajdeczko
2024-07-17 19:51 ` [PATCH v2 1/7] drm/xe: Introduce const cast helper Michal Wajdeczko
2024-07-17 20:07   ` Cavitt, Jonathan
2024-07-17 21:38     ` Michal Wajdeczko
2024-07-19 16:32   ` Lucas De Marchi
2024-07-19 16:55     ` Michal Wajdeczko [this message]
2024-07-19 17:06       ` Lucas De Marchi
2024-07-17 19:51 ` [PATCH v2 2/7] drm/xe/tests: Add helpers for use in live tests Michal Wajdeczko
2024-07-17 20:14   ` Cavitt, Jonathan
2024-07-19 16:37   ` Lucas De Marchi
2024-07-19 17:20     ` Michal Wajdeczko
2024-07-17 19:51 ` [PATCH v2 3/7] drm/xe/tests: Convert xe_bo " Michal Wajdeczko
2024-07-17 20:15   ` Cavitt, Jonathan
2024-07-17 19:51 ` [PATCH v2 4/7] drm/xe/tests: Convert xe_dma_buf " Michal Wajdeczko
2024-07-17 20:17   ` Cavitt, Jonathan
2024-07-17 21:54     ` Michal Wajdeczko
2024-07-17 19:51 ` [PATCH v2 5/7] drm/xe/tests: Convert xe_migrate " Michal Wajdeczko
2024-07-17 20:17   ` Cavitt, Jonathan
2024-07-17 19:51 ` [PATCH v2 6/7] drm/xe/tests: Convert xe_mocs " Michal Wajdeczko
2024-07-17 20:18   ` Cavitt, Jonathan
2024-07-19 16:40   ` Lucas De Marchi
2024-07-17 19:51 ` [PATCH v2 7/7] drm/xe/tests: Skip xe_mocs live tests on VF device Michal Wajdeczko
2024-07-17 20:19   ` Cavitt, Jonathan
2024-07-19 16:41   ` Lucas De Marchi
2024-07-17 19:58 ` ✓ CI.Patch_applied: success for Convert live tests to parameterized style (rev2) Patchwork
2024-07-17 19:59 ` ✓ CI.checkpatch: " Patchwork
2024-07-17 20:00 ` ✓ CI.KUnit: " Patchwork
2024-07-17 20:12 ` ✓ CI.Build: " Patchwork
2024-07-17 20:14 ` ✓ CI.Hooks: " Patchwork
2024-07-17 20:16 ` ✓ CI.checksparse: " Patchwork
2024-07-17 20:40 ` ✗ CI.BAT: failure " Patchwork
2024-07-17 21:34   ` Michal Wajdeczko
2024-07-18  1:53 ` ✗ CI.FULL: " Patchwork
2024-07-18  7:11   ` Michal Wajdeczko

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=280022b5-cbb0-405c-8285-92335edf5d3b@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@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