]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/panfrost: Support cache-coherent integrations
authorRobin Murphy <robin.murphy@arm.com>
Tue, 22 Sep 2020 14:16:49 +0000 (15:16 +0100)
committerNeil Armstrong <narmstrong@baylibre.com>
Fri, 30 Oct 2020 09:08:08 +0000 (10:08 +0100)
When the GPU's ACE-Lite interface is fully wired up and capable of
snooping CPU caches, it may be described as "dma-coherent" in
devicetree, which will already inform the DMA layer not to perform
unnecessary cache maintenance. However, we still need to ensure that
the GPU uses the appropriate cacheable outer-shareable attributes in
order to generate the requisite snoop signals, and that CPU mappings
don't create a mismatch by using a non-cacheable type either.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/7024ce18c1cb1a226e918037d49175571db0b436.1600780574.git.robin.murphy@arm.com
drivers/gpu/drm/panfrost/panfrost_device.h
drivers/gpu/drm/panfrost/panfrost_drv.c
drivers/gpu/drm/panfrost/panfrost_gem.c
drivers/gpu/drm/panfrost/panfrost_mmu.c

index 2e9cbd1c4a58eef76dd360dfea6d29fea47ca90e..140e004a37902f9730a22913b5beac366a11537f 100644 (file)
@@ -88,6 +88,7 @@ struct panfrost_device {
        /* pm_domains for devices with more than one. */
        struct device *pm_domain_devs[MAX_PM_DOMAINS];
        struct device_link *pm_domain_links[MAX_PM_DOMAINS];
+       bool coherent;
 
        struct panfrost_features features;
        const struct panfrost_compatible *comp;
index 37d4cb7a5491c4a58ea1a3102ac3f05032e4a9fc..6e5dedacb777c42570d6320d680fcb94b4a0c63d 100644 (file)
@@ -587,6 +587,8 @@ static int panfrost_probe(struct platform_device *pdev)
        if (!pfdev->comp)
                return -ENODEV;
 
+       pfdev->coherent = device_get_dma_attr(&pdev->dev) == DEV_DMA_COHERENT;
+
        /* Allocate and initialze the DRM device. */
        ddev = drm_dev_alloc(&panfrost_drm_driver, &pdev->dev);
        if (IS_ERR(ddev))
index 33355dd302f11f30ebaee684b2988f484f767501..cdf1a8754ebaef56153a89a82c619815dc3b995f 100644 (file)
@@ -220,6 +220,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = {
  */
 struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size)
 {
+       struct panfrost_device *pfdev = dev->dev_private;
        struct panfrost_gem_object *obj;
 
        obj = kzalloc(sizeof(*obj), GFP_KERNEL);
@@ -229,6 +230,7 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
        INIT_LIST_HEAD(&obj->mappings.list);
        mutex_init(&obj->mappings.lock);
        obj->base.base.funcs = &panfrost_gem_funcs;
+       obj->base.map_cached = pfdev->coherent;
 
        return &obj->base.base;
 }
index e8f7b11352d27ba38aa2d576e32b886518690992..8852fd378f7a52ffb10391e502fe2069763bc108 100644 (file)
@@ -371,6 +371,7 @@ int panfrost_mmu_pgtable_alloc(struct panfrost_file_priv *priv)
                .pgsize_bitmap  = SZ_4K | SZ_2M,
                .ias            = FIELD_GET(0xff, pfdev->features.mmu_features),
                .oas            = FIELD_GET(0xff00, pfdev->features.mmu_features),
+               .coherent_walk  = pfdev->coherent,
                .tlb            = &mmu_tlb_ops,
                .iommu_dev      = pfdev->dev,
        };