Skip to content

drm/verisilicon: unconditionally use the DC device as dma_dev #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Icenowy
Copy link

@Icenowy Icenowy commented Jul 16, 2025

As the display-subsystem is outside of the soc device tree node (where the dma-noncoherent property is added), it's assumed to be coherent, and lead to allocated memory being not properly mapped (still cached).

Unconditionally use the DC device (which is in the soc node) as dma_dev to fix framebuffer mapping issue.

Summary by Sourcery

Always use the DC device as the DMA device in Verisilicon DRM to ensure proper framebuffer mapping and reflect that change in function naming.

Bug Fixes:

  • Fix framebuffer mapping by unconditionally assigning the DC device as dma_dev

Enhancements:

  • Rename vs_drm_iommu_attach_device/detach_device to vs_drm_dma_attach_device/detach_device
  • Update DC binding code and error messages to use the new DMA attach/detach APIs and unconditionally set/reset priv->dma_dev

As the display-subsystem is outside of the soc device tree node (where
the dma-noncoherent property is added), it's assumed to be coherent,
and lead to allocated memory being not properly mapped (still cached).

Unconditionally use the DC device (which is in the soc node) as dma_dev
to fix framebuffer mapping issue.

Signed-off-by: Icenowy Zheng <[email protected]>
Copy link

sourcery-ai bot commented Jul 16, 2025

Reviewer's Guide

This PR ensures the DC device is always used as the DMA device by assigning dma_dev before any IOMMU checks and refining detach logic, renames the IOMMU-specific attach/detach APIs to reflect DMA semantics, and updates the DC driver to invoke the new DMA functions with corrected log messages.

Class diagram for updated DMA attach/detach API in Verisilicon DRM driver

classDiagram
    class vs_drm_private {
        +struct device *dma_dev
        +struct iommu_domain *domain
        +unsigned int pitch_alignment
    }
    class drm_device {
        +void *dev_private
        +struct device *dev
    }
    vs_drm_private <.. drm_device : dev_private

    class vs_drm_dma_attach_device {
        +int vs_drm_dma_attach_device(struct drm_device *drm_dev, struct device *dev)
    }
    class vs_drm_dma_detach_device {
        +void vs_drm_dma_detach_device(struct drm_device *drm_dev, struct device *dev)
    }
    drm_device <.. vs_drm_dma_attach_device
    drm_device <.. vs_drm_dma_detach_device
Loading

Class diagram for DC device binding and DMA device assignment

classDiagram
    class dc_bind {
        +int dc_bind(struct device *dev, struct device *master, void *data)
    }
    class dc_unbind {
        +void dc_unbind(struct device *dev, struct device *master, void *data)
    }
    class vs_drm_dma_attach_device {
        +int vs_drm_dma_attach_device(struct drm_device *drm_dev, struct device *dev)
    }
    class vs_drm_dma_detach_device {
        +void vs_drm_dma_detach_device(struct drm_device *drm_dev, struct device *dev)
    }
    dc_bind --> vs_drm_dma_attach_device : calls
    dc_unbind --> vs_drm_dma_detach_device : calls
Loading

File-Level Changes

Change Details Files
Unconditionally use DC device as dma_dev
  • Assign priv->dma_dev before IOMMU check in attach
  • Remove redundant dma_dev assignment inside IOMMU block
  • Move dma_dev reset to before IOMMU detach and guard by matching device
drivers/gpu/drm/verisilicon/vs_drv.c
Rename IOMMU attach/detach functions to DMA semantics
  • Rename vs_drm_iommu_attach_device to vs_drm_dma_attach_device
  • Rename vs_drm_iommu_detach_device to vs_drm_dma_detach_device
  • Update function prototypes in vs_drv.h
drivers/gpu/drm/verisilicon/vs_drv.c
drivers/gpu/drm/verisilicon/vs_drv.h
Update DC driver to use renamed DMA functions
  • Replace vs_drm_iommu_* calls with vs_drm_dma_* in dc_bind/dc_unbind
  • Adjust dev_err message to reference DMA device
drivers/gpu/drm/verisilicon/vs_dc.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Icenowy - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@RevySR RevySR merged commit 33f4949 into revyos:th1520-lts Jul 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants