From a0e052ce2a796d005064b8bfb0d1bc78475d5642 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Wed, 1 Apr 2020 12:02:32 -0600 Subject: [PATCH 1/2] msm: kgsl: Remove legacy platform probe table Remove the legacy platform id_table and just rely on the standard of_match_table instead. Use the standard macro for specifying the match table pointer and set the MODULE_DEVICE_TABLE. Change-Id: Ic0dedbad84f80b28d1885a7326324eb67ef97d9b Signed-off-by: Jordan Crouse --- drivers/gpu/msm/adreno.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index fd3a2c378442..cd37ab764648 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -764,18 +764,13 @@ static int adreno_identify_gpu(struct adreno_device *adreno_dev) return 0; } -static const struct platform_device_id adreno_id_table[] = { - { "kgsl-3d0", (unsigned long) &device_3d0, }, - {}, -}; - -MODULE_DEVICE_TABLE(platform, adreno_id_table); - static const struct of_device_id adreno_match_table[] = { { .compatible = "qcom,kgsl-3d0", .data = &device_3d0 }, - {} + { }, }; +MODULE_DEVICE_TABLE(of, adreno_match_table); + /* Dynamically build the OPP table for the GPU device */ static void adreno_build_opp_table(struct device *dev, struct kgsl_pwrctrl *pwr) { @@ -1311,18 +1306,13 @@ static void adreno_setup_device(struct adreno_device *adreno_dev) static int adreno_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - const struct of_device_id *of_id; struct adreno_device *adreno_dev; struct kgsl_device *device; int status; unsigned int priv = 0; u32 size, hwrev; - of_id = of_match_device(adreno_match_table, &pdev->dev); - if (!of_id) - return -EINVAL; - - adreno_dev = (struct adreno_device *) of_id->data; + adreno_dev = (struct adreno_device *) of_device_get_match_data(dev); /* Initialize the adreno device structure */ adreno_setup_device(adreno_dev); @@ -1499,17 +1489,12 @@ static void _adreno_free_memories(struct adreno_device *adreno_dev) static void adreno_unbind(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - const struct of_device_id *of_id; struct adreno_device *adreno_dev; struct kgsl_device *device; struct adreno_gpudev *gpudev; - of_id = of_match_device(adreno_match_table, &pdev->dev); - if (!of_id) - return; + adreno_dev = (struct adreno_device *) of_device_get_match_data(dev); - adreno_dev = (struct adreno_device *) of_id->data; device = KGSL_DEVICE(adreno_dev); gpudev = ADRENO_GPU_DEVICE(adreno_dev); @@ -3781,11 +3766,10 @@ static const struct dev_pm_ops adreno_pm_ops = { static struct platform_driver adreno_platform_driver = { .probe = adreno_probe, .remove = adreno_remove, - .id_table = adreno_id_table, .driver = { .name = "kgsl-3d", .pm = &adreno_pm_ops, - .of_match_table = adreno_match_table, + .of_match_table = of_match_ptr(adreno_match_table), } }; From 3f65d0a911eb279a9ce6d950488096e66f084d6f Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Mon, 6 Apr 2020 09:50:04 -0600 Subject: [PATCH 2/2] msm: kgsl: Allow compatible string matching for gpu devices Allow a GPU definition to specify a compatible string to match a GPU target. If specified a matching compatible string will take priority over the GPU chipid match. Change-Id: Ic0dedbadd998dcc8e8f9bc5de2e383870258ad48 Signed-off-by: Jordan Crouse --- drivers/gpu/msm/adreno.c | 24 +++++++++++++++++------- drivers/gpu/msm/adreno.h | 5 +++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index cd37ab764648..388198f24f84 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -615,7 +615,8 @@ static inline bool _rev_match(unsigned int id, unsigned int entry) return (entry == ANY_ID || entry == id); } -static inline const struct adreno_gpu_core *_get_gpu_core(unsigned int chipid) +static const struct adreno_gpu_core * +_get_gpu_core(struct platform_device *pdev, unsigned int chipid) { unsigned int core = ADRENO_CHIPID_CORE(chipid); unsigned int major = ADRENO_CHIPID_MAJOR(chipid); @@ -623,6 +624,15 @@ static inline const struct adreno_gpu_core *_get_gpu_core(unsigned int chipid) unsigned int patchid = ADRENO_CHIPID_PATCH(chipid); int i; + /* Check to see if any of the entries match on a compatible string */ + for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) { + if (adreno_gpulist[i]->compatible && + of_device_is_compatible(pdev->dev.of_node, + adreno_gpulist[i]->compatible)) + return adreno_gpulist[i]; + } + + for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) { if (core == adreno_gpulist[i]->core && _rev_match(major, adreno_gpulist[i]->major) && @@ -718,16 +728,16 @@ adreno_update_soc_hw_revision_quirks(struct adreno_device *adreno_dev, of_node_put(node); } -static int adreno_identify_gpu(struct adreno_device *adreno_dev) +static int adreno_identify_gpu(struct platform_device *pdev, + struct adreno_device *adreno_dev) { - struct kgsl_device *device = KGSL_DEVICE(adreno_dev); struct adreno_gpudev *gpudev; int i; - adreno_dev->gpucore = _get_gpu_core(adreno_dev->chipid); + adreno_dev->gpucore = _get_gpu_core(pdev, adreno_dev->chipid); if (adreno_dev->gpucore == NULL) { - dev_crit(&device->pdev->dev, + dev_crit(&pdev->dev, "Unknown GPU chip ID %8.8X\n", adreno_dev->chipid); return -ENODEV; } @@ -737,7 +747,7 @@ static int adreno_identify_gpu(struct adreno_device *adreno_dev) * message */ if (adreno_dev->gpucore->features & ADRENO_DEPRECATED) { - dev_err(&device->pdev->dev, + dev_err(&pdev->dev, "Support for GPU %d.%d.%d.%d has been deprecated\n", adreno_dev->gpucore->core, adreno_dev->gpucore->major, @@ -1340,7 +1350,7 @@ static int adreno_bind(struct device *dev) device->speed_bin = status; /* Get the chip ID from the DT and set up target specific parameters */ - if (adreno_identify_gpu(adreno_dev)) + if (adreno_identify_gpu(pdev, adreno_dev)) return -ENODEV; status = adreno_of_get_power(adreno_dev, pdev); diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index f1cda8da3c56..82fd5095470a 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -340,6 +340,11 @@ struct adreno_reglist { struct adreno_gpu_core { enum adreno_gpurev gpurev; unsigned int core, major, minor, patchid; + /** + * @compatible: If specified, use the compatible string to match the + * device + */ + const char *compatible; unsigned long features; struct adreno_gpudev *gpudev; unsigned long gmem_base;