All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: andrzej.hajda@intel.com
Cc: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org
Subject: [bug report] drm/exynos/iommu: merge IOMMU and DMA code
Date: Thu, 12 Oct 2023 12:44:46 +0300	[thread overview]
Message-ID: <33e52277-1349-472b-a55b-ab5c3462bfcf@moroto.mountain> (raw)

Hello Andrzej Hajda,

The patch 67fbf3a3ef84: "drm/exynos/iommu: merge IOMMU and DMA code"
from Oct 12, 2018 (linux-next), leads to the following Smatch static
checker warning:

	drivers/gpu/drm/exynos/exynos_drm_dma.c:120 exynos_drm_register_dma()
	warn: 'mapping' isn't an ERR_PTR

drivers/gpu/drm/exynos/exynos_drm_dma.c
    95 int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
    96                             void **dma_priv)
    97 {
    98         struct exynos_drm_private *priv = drm->dev_private;
    99 
    100         if (!priv->dma_dev) {
    101                 priv->dma_dev = dev;
    102                 DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n",
    103                          dev_name(dev));
    104         }
    105 
    106         if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU))
    107                 return 0;
    108 
    109         if (!priv->mapping) {
    110                 void *mapping;
    111 
    112                 if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
    113                         mapping = arm_iommu_create_mapping(&platform_bus_type,
    114                                 EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
    115                 else if (IS_ENABLED(CONFIG_IOMMU_DMA))
    116                         mapping = iommu_get_domain_for_dev(priv->dma_dev);

arm_iommu_create_mapping() and iommu_get_domain_for_dev() seem to return
NULL on error.

    117                 else
    118                         mapping = ERR_PTR(-ENODEV);
    119 
--> 120                 if (IS_ERR(mapping))
    121                         return PTR_ERR(mapping);

Smatch uses the pre-compiled code so it says that mapping is always NULL
on this config...

    122                 priv->mapping = mapping;
    123         }
    124 
    125         return drm_iommu_attach_device(drm, dev, dma_priv);
    126 }

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@linaro.org>
To: andrzej.hajda@intel.com
Cc: linux-samsung-soc@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [bug report] drm/exynos/iommu: merge IOMMU and DMA code
Date: Thu, 12 Oct 2023 12:44:46 +0300	[thread overview]
Message-ID: <33e52277-1349-472b-a55b-ab5c3462bfcf@moroto.mountain> (raw)

Hello Andrzej Hajda,

The patch 67fbf3a3ef84: "drm/exynos/iommu: merge IOMMU and DMA code"
from Oct 12, 2018 (linux-next), leads to the following Smatch static
checker warning:

	drivers/gpu/drm/exynos/exynos_drm_dma.c:120 exynos_drm_register_dma()
	warn: 'mapping' isn't an ERR_PTR

drivers/gpu/drm/exynos/exynos_drm_dma.c
    95 int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
    96                             void **dma_priv)
    97 {
    98         struct exynos_drm_private *priv = drm->dev_private;
    99 
    100         if (!priv->dma_dev) {
    101                 priv->dma_dev = dev;
    102                 DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n",
    103                          dev_name(dev));
    104         }
    105 
    106         if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU))
    107                 return 0;
    108 
    109         if (!priv->mapping) {
    110                 void *mapping;
    111 
    112                 if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
    113                         mapping = arm_iommu_create_mapping(&platform_bus_type,
    114                                 EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
    115                 else if (IS_ENABLED(CONFIG_IOMMU_DMA))
    116                         mapping = iommu_get_domain_for_dev(priv->dma_dev);

arm_iommu_create_mapping() and iommu_get_domain_for_dev() seem to return
NULL on error.

    117                 else
    118                         mapping = ERR_PTR(-ENODEV);
    119 
--> 120                 if (IS_ERR(mapping))
    121                         return PTR_ERR(mapping);

Smatch uses the pre-compiled code so it says that mapping is always NULL
on this config...

    122                 priv->mapping = mapping;
    123         }
    124 
    125         return drm_iommu_attach_device(drm, dev, dma_priv);
    126 }

regards,
dan carpenter

             reply	other threads:[~2023-10-12  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  9:44 Dan Carpenter [this message]
2023-10-12  9:44 ` [bug report] drm/exynos/iommu: merge IOMMU and DMA code Dan Carpenter

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=33e52277-1349-472b-a55b-ab5c3462bfcf@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.