diff mbox series

[02/10] drm/xe: add kdev_to_xe_device() helper and use it

Message ID 55d57008c0f9bcfc089cf8b940e531c770f43454.1722263308.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/xe & drm/i915: drvdata usage changes | expand

Commit Message

Jani Nikula July 29, 2024, 2:30 p.m. UTC
There are enough users for kernel device to xe device conversion, add a
helper for it.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/xe/xe_device.h    | 5 +++++
 drivers/gpu/drm/xe/xe_gsc_proxy.c | 9 ++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

Comments

Gustavo Sousa Aug. 1, 2024, 4:41 p.m. UTC | #1
Quoting Jani Nikula (2024-07-29 11:30:03-03:00)
>There are enough users for kernel device to xe device conversion, add a
>helper for it.
>
>Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>---
> drivers/gpu/drm/xe/xe_device.h    | 5 +++++
> drivers/gpu/drm/xe/xe_gsc_proxy.c | 9 ++-------
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
>index db6cc8d0d6b8..2c96f1b2aafd 100644
>--- a/drivers/gpu/drm/xe/xe_device.h
>+++ b/drivers/gpu/drm/xe/xe_device.h
>@@ -15,6 +15,11 @@ static inline struct xe_device *to_xe_device(const struct drm_device *dev)
>         return container_of(dev, struct xe_device, drm);
> }
> 
>+static inline struct xe_device *kdev_to_xe_device(struct device *kdev)

Nitpick: Although there are some places that do it differently, it seems
it is very common to use "dev" to refer to the generic struct device, so
I would s/kdev/dev/ here.

In any case:

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>

>+{
>+        return dev_get_drvdata(kdev);
>+}
>+
> static inline struct xe_device *pdev_to_xe_device(struct pci_dev *pdev)
> {
>         return pci_get_drvdata(pdev);
>diff --git a/drivers/gpu/drm/xe/xe_gsc_proxy.c b/drivers/gpu/drm/xe/xe_gsc_proxy.c
>index aa812a2bc3ed..28e6a7a1d282 100644
>--- a/drivers/gpu/drm/xe/xe_gsc_proxy.c
>+++ b/drivers/gpu/drm/xe/xe_gsc_proxy.c
>@@ -62,11 +62,6 @@ gsc_to_gt(struct xe_gsc *gsc)
>         return container_of(gsc, struct xe_gt, uc.gsc);
> }
> 
>-static inline struct xe_device *kdev_to_xe(struct device *kdev)
>-{
>-        return dev_get_drvdata(kdev);
>-}
>-
> bool xe_gsc_proxy_init_done(struct xe_gsc *gsc)
> {
>         struct xe_gt *gt = gsc_to_gt(gsc);
>@@ -345,7 +340,7 @@ void xe_gsc_proxy_irq_handler(struct xe_gsc *gsc, u32 iir)
> static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
>                                        struct device *mei_kdev, void *data)
> {
>-        struct xe_device *xe = kdev_to_xe(xe_kdev);
>+        struct xe_device *xe = kdev_to_xe_device(xe_kdev);
>         struct xe_gt *gt = xe->tiles[0].media_gt;
>         struct xe_gsc *gsc = &gt->uc.gsc;
> 
>@@ -360,7 +355,7 @@ static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
> static void xe_gsc_proxy_component_unbind(struct device *xe_kdev,
>                                           struct device *mei_kdev, void *data)
> {
>-        struct xe_device *xe = kdev_to_xe(xe_kdev);
>+        struct xe_device *xe = kdev_to_xe_device(xe_kdev);
>         struct xe_gt *gt = xe->tiles[0].media_gt;
>         struct xe_gsc *gsc = &gt->uc.gsc;
> 
>-- 
>2.39.2
>
Jani Nikula Aug. 6, 2024, 12:10 p.m. UTC | #2
On Thu, 01 Aug 2024, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
> Quoting Jani Nikula (2024-07-29 11:30:03-03:00)
>>There are enough users for kernel device to xe device conversion, add a
>>helper for it.
>>
>>Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>>---
>> drivers/gpu/drm/xe/xe_device.h    | 5 +++++
>> drivers/gpu/drm/xe/xe_gsc_proxy.c | 9 ++-------
>> 2 files changed, 7 insertions(+), 7 deletions(-)
>>
>>diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
>>index db6cc8d0d6b8..2c96f1b2aafd 100644
>>--- a/drivers/gpu/drm/xe/xe_device.h
>>+++ b/drivers/gpu/drm/xe/xe_device.h
>>@@ -15,6 +15,11 @@ static inline struct xe_device *to_xe_device(const struct drm_device *dev)
>>         return container_of(dev, struct xe_device, drm);
>> }
>> 
>>+static inline struct xe_device *kdev_to_xe_device(struct device *kdev)
>
> Nitpick: Although there are some places that do it differently, it seems
> it is very common to use "dev" to refer to the generic struct device, so
> I would s/kdev/dev/ here.

I think kdev is often used to distinguish from struct drm_device *dev.

> In any case:
>
> Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>

Thanks,
Jani.

>
>>+{
>>+        return dev_get_drvdata(kdev);
>>+}
>>+
>> static inline struct xe_device *pdev_to_xe_device(struct pci_dev *pdev)
>> {
>>         return pci_get_drvdata(pdev);
>>diff --git a/drivers/gpu/drm/xe/xe_gsc_proxy.c b/drivers/gpu/drm/xe/xe_gsc_proxy.c
>>index aa812a2bc3ed..28e6a7a1d282 100644
>>--- a/drivers/gpu/drm/xe/xe_gsc_proxy.c
>>+++ b/drivers/gpu/drm/xe/xe_gsc_proxy.c
>>@@ -62,11 +62,6 @@ gsc_to_gt(struct xe_gsc *gsc)
>>         return container_of(gsc, struct xe_gt, uc.gsc);
>> }
>> 
>>-static inline struct xe_device *kdev_to_xe(struct device *kdev)
>>-{
>>-        return dev_get_drvdata(kdev);
>>-}
>>-
>> bool xe_gsc_proxy_init_done(struct xe_gsc *gsc)
>> {
>>         struct xe_gt *gt = gsc_to_gt(gsc);
>>@@ -345,7 +340,7 @@ void xe_gsc_proxy_irq_handler(struct xe_gsc *gsc, u32 iir)
>> static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
>>                                        struct device *mei_kdev, void *data)
>> {
>>-        struct xe_device *xe = kdev_to_xe(xe_kdev);
>>+        struct xe_device *xe = kdev_to_xe_device(xe_kdev);
>>         struct xe_gt *gt = xe->tiles[0].media_gt;
>>         struct xe_gsc *gsc = &gt->uc.gsc;
>> 
>>@@ -360,7 +355,7 @@ static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
>> static void xe_gsc_proxy_component_unbind(struct device *xe_kdev,
>>                                           struct device *mei_kdev, void *data)
>> {
>>-        struct xe_device *xe = kdev_to_xe(xe_kdev);
>>+        struct xe_device *xe = kdev_to_xe_device(xe_kdev);
>>         struct xe_gt *gt = xe->tiles[0].media_gt;
>>         struct xe_gsc *gsc = &gt->uc.gsc;
>> 
>>-- 
>>2.39.2
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
index db6cc8d0d6b8..2c96f1b2aafd 100644
--- a/drivers/gpu/drm/xe/xe_device.h
+++ b/drivers/gpu/drm/xe/xe_device.h
@@ -15,6 +15,11 @@  static inline struct xe_device *to_xe_device(const struct drm_device *dev)
 	return container_of(dev, struct xe_device, drm);
 }
 
+static inline struct xe_device *kdev_to_xe_device(struct device *kdev)
+{
+	return dev_get_drvdata(kdev);
+}
+
 static inline struct xe_device *pdev_to_xe_device(struct pci_dev *pdev)
 {
 	return pci_get_drvdata(pdev);
diff --git a/drivers/gpu/drm/xe/xe_gsc_proxy.c b/drivers/gpu/drm/xe/xe_gsc_proxy.c
index aa812a2bc3ed..28e6a7a1d282 100644
--- a/drivers/gpu/drm/xe/xe_gsc_proxy.c
+++ b/drivers/gpu/drm/xe/xe_gsc_proxy.c
@@ -62,11 +62,6 @@  gsc_to_gt(struct xe_gsc *gsc)
 	return container_of(gsc, struct xe_gt, uc.gsc);
 }
 
-static inline struct xe_device *kdev_to_xe(struct device *kdev)
-{
-	return dev_get_drvdata(kdev);
-}
-
 bool xe_gsc_proxy_init_done(struct xe_gsc *gsc)
 {
 	struct xe_gt *gt = gsc_to_gt(gsc);
@@ -345,7 +340,7 @@  void xe_gsc_proxy_irq_handler(struct xe_gsc *gsc, u32 iir)
 static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
 				       struct device *mei_kdev, void *data)
 {
-	struct xe_device *xe = kdev_to_xe(xe_kdev);
+	struct xe_device *xe = kdev_to_xe_device(xe_kdev);
 	struct xe_gt *gt = xe->tiles[0].media_gt;
 	struct xe_gsc *gsc = &gt->uc.gsc;
 
@@ -360,7 +355,7 @@  static int xe_gsc_proxy_component_bind(struct device *xe_kdev,
 static void xe_gsc_proxy_component_unbind(struct device *xe_kdev,
 					  struct device *mei_kdev, void *data)
 {
-	struct xe_device *xe = kdev_to_xe(xe_kdev);
+	struct xe_device *xe = kdev_to_xe_device(xe_kdev);
 	struct xe_gt *gt = xe->tiles[0].media_gt;
 	struct xe_gsc *gsc = &gt->uc.gsc;