Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Inspur] Add Inspur Graphics PCI-E DRM Driver ([6.6] [Feature] : inspur-drm驱动合入)#834

Merged
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:inspur-drm
Jun 3, 2025
Merged

[Deepin-Kernel-SIG] [linux 6.6-y] [Inspur] Add Inspur Graphics PCI-E DRM Driver ([6.6] [Feature] : inspur-drm驱动合入)#834
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:inspur-drm

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented Jun 2, 2025

Add Inspur DRM driver for Inspur BMC SoC.

Link: https://gitee.com/anolis/cloud-kernel/pulls/3046

[ WangYuli: Edit the commit msg. ]

Summary by Sourcery

Add a complete Inspur DRM driver implementation including build integration, PCI device probing, display engine setup, memory management, interrupt handling, and power/clock control

New Features:

  • Introduce a new Inspur Graphics DRM driver for PCI-E BMC SoC under CONFIG_DRM_INSPUR
  • Add driver integration via Kconfig and Makefile entries to build the inspur-drm module
  • Implement display pipeline components (plane, CRTC, encoder, connector) with atomic helper support and mode setting
  • Provide GEM/TTM VRAM support, framebuffer dumb create, and VBlank interrupt handling
  • Integrate power management and register-based clock/PLL configuration for display hardware

Add Inspur DRM driver for Inspur BMC SoC.

Link: https://gitee.com/anolis/cloud-kernel/pulls/3046
Signed-off-by: wangkaiyuan <wangkaiyuan@inspur.com>
[ WangYuli: Edit the commit msg. ]
Signed-off-by: WangYuli <wangyuli@uniontech.com>
@Avenger-285714 Avenger-285714 requested a review from Copilot June 2, 2025 00:06
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 2, 2025

Reviewer's Guide

Introduces a new Inspur DRM driver by updating build configurations and adding a set of driver sources under drivers/gpu/drm/inspur/inspur-drm, implementing PCI probe, memory mapping, power management, atomic plane/CRTC/encoder/connector support, dumb buffer creation, VRAM management, and detailed hardware register definitions.

Sequence Diagram for Inspur DRM PCI Probe and Load

sequenceDiagram
    participant PCI_Subsystem as Kernel (PCI Subsystem)
    participant pci_driver as inspur_pci_driver_impl
    participant DRM_Core as Kernel (DRM Core)
    participant inspur_module as inspur_drm_module

    PCI_Subsystem->>pci_driver: inspur_pci_probe(pdev, id)
    pci_driver->>DRM_Core: drm_dev_alloc()
    Note right of pci_driver: dev created, priv allocated
    pci_driver->>PCI_Subsystem: pci_enable_device(pdev)
    pci_driver->>inspur_module: inspur_load(dev, id->driver_data)
    activate inspur_module
    inspur_module->>inspur_module: inspur_hw_init(priv)
    Note right of inspur_module: Maps MMIO & FB, configures HW
    inspur_module->>DRM_Core: drmm_vram_helper_init(dev, fb_base, fb_size)
    inspur_module->>inspur_module: inspur_kms_init(priv)
    activate inspur_module
    inspur_module->>inspur_module: inspur_de_init(priv)  // Init display engine (CRTC, Plane)
    inspur_module->>inspur_module: inspur_vdac_init(priv) // Init DAC (Encoder, Connector)
    deactivate inspur_module
    Note right of inspur_module: KMS components initialized
    inspur_module->>DRM_Core: drm_mode_config_reset(dev)
    deactivate inspur_module
    pci_driver->>DRM_Core: drm_dev_register(dev, id->driver_data)
    pci_driver->>DRM_Core: drm_fbdev_generic_setup(dev, depth)
Loading

Sequence Diagram for Inspur Plane Atomic Update

sequenceDiagram
    participant DRM_Core
    participant PlaneHelpers as inspur_plane_helper_funcs
    participant DriverPriv as inspur_drm_private_instance
    participant HW as Inspur Graphics Hardware

    DRM_Core->>PlaneHelpers: atomic_check(plane, atomic_state)
    activate PlaneHelpers
    PlaneHelpers->>PlaneHelpers: inspur_plane_atomic_check(plane, new_plane_state)
    Note right of PlaneHelpers: Validate plane state (src/crtc size, position, pitch)
    deactivate PlaneHelpers

    DRM_Core->>PlaneHelpers: atomic_update(plane, old_atomic_state)
    activate PlaneHelpers
    PlaneHelpers->>PlaneHelpers: inspur_plane_atomic_update(plane, old_plane_state)
    Note right of PlaneHelpers: Get framebuffer object (gbo)
    PlaneHelpers->>DRM_Core: drm_gem_vram_pin(gbo)
    PlaneHelpers->>DRM_Core: drm_gem_vram_offset(gbo)
    Note right of PlaneHelpers: Get GPU address (gpu_addr)
    PlaneHelpers->>DriverPriv: Access priv->mmio
    DriverPriv->>HW: writel(gpu_addr, mmio + INSPUR_CRT_FB_ADDRESS)
    DriverPriv->>HW: writel(fb_width_reg, mmio + INSPUR_CRT_FB_WIDTH)
    DriverPriv->>HW: writel(disp_ctl_reg, mmio + INSPUR_CRT_DISP_CTL) // Set pixel format
    deactivate PlaneHelpers
Loading

ER Diagram for Inspur DRM Driver Core Data Structures

erDiagram
    DRM_DEVICE {
        string name
        inspur_drm_private_ref dev_private
    }
    INSPUR_DRM_PRIVATE {
        drm_device_ref dev
        pointer mmio
        pointer fb_map
        inspur_fbdev_ref fbdev
        inspur_cursor cursor
        bool mode_config_initialized
        drm_atomic_state_ref suspend_state
    }
    INSPUR_FBDEV {
        drm_fb_helper helper
        drm_framebuffer_ref fb
        int size
    }
    INSPUR_CURSOR {
        drm_gem_vram_object_array gbo
        int next_index
    }
    INSPUR_DISPLAY_PLL_CONFIG {
        unsigned_long hdisplay
        unsigned_long vdisplay
        u32 pll1_config_value
        u32 pll2_config_value
    }

    DRM_DEVICE ||--o{ INSPUR_DRM_PRIVATE : "has (as dev_private)"
    INSPUR_DRM_PRIVATE }o--|| DRM_DEVICE : "points to (dev)"
    INSPUR_DRM_PRIVATE ||--|{ INSPUR_FBDEV : "aggregates"
    INSPUR_DRM_PRIVATE ||--|{ INSPUR_CURSOR : "aggregates"
    INSPUR_DRM_PRIVATE }o..o{ INSPUR_DISPLAY_PLL_CONFIG : "uses (indirectly for mode setting)"
Loading

Class Diagram for New Inspur DRM Driver Structures and Callbacks

classDiagram
    class inspur_drm_private {
        +void* mmio
        +void* fb_map
        +unsigned long fb_base
        +unsigned long fb_size
        +drm_device* dev
        +bool mode_config_initialized
        +drm_atomic_state* suspend_state
        +inspur_fbdev* fbdev
        +inspur_cursor cursor
        +inspur_set_power_mode(priv, mode) void
        +inspur_set_current_gate(priv, gate) void
        +inspur_hw_init(priv) int
        +inspur_kms_init(priv) int
        +inspur_de_init(priv) int
        +inspur_vdac_init(priv) int
    }
    class inspur_fbdev {
        +drm_fb_helper helper
        +drm_framebuffer* fb
        +int size
    }
    class inspur_cursor {
        +drm_gem_vram_object* gbo[2]
        +unsigned int next_index
    }
    class inspur_dislay_pll_config {
      <<Display PLL Configuration Data>>
      +unsigned long hdisplay
      +unsigned long vdisplay
      +u32 pll1_config_value
      +u32 pll2_config_value
    }
    inspur_drm_private "1" *-- "1" inspur_fbdev : owns
    inspur_drm_private "1" *-- "1" inspur_cursor : owns

    class inspur_pci_driver_callbacks {
        <<Static Callbacks for PCI Driver>>
        +inspur_pci_probe(pdev, ent) int
        +inspur_pci_remove(pdev) void
        +inspur_pci_shutdown(pdev) void
        +inspur_pm_suspend(dev) int
        +inspur_pm_resume(dev) int
    }

    class inspur_drm_driver_callbacks {
        <<Static Callbacks for DRM Driver>>
        +inspur_load(dev, flags) int
        +inspur_unload(dev) void
        +inspur_dumb_create(file, dev, args) int
        +inspur_drm_interrupt(irq, arg) irqreturn_t
    }
    inspur_pci_driver_callbacks ..> inspur_drm_driver_callbacks : (probe invokes load)
    inspur_drm_driver_callbacks ..> inspur_drm_private : (load creates & initializes private data)
Loading

File-Level Changes

Change Details Files
Enable CONFIG_DRM_INSPUR and integrate the new Inspur DRM driver into the build
  • Update top-level drivers/gpu/drm/Makefile to include inspur/
  • Add subdirectory Makefiles under drivers/gpu/drm/inspur and inspur-drm/
  • Add Kconfig entries for the new Inspur DRM driver
drivers/gpu/drm/Makefile
drivers/gpu/drm/inspur/Makefile
drivers/gpu/drm/inspur/inspur-drm/Makefile
drivers/gpu/drm/inspur/Kconfig
drivers/gpu/drm/inspur/inspur-drm/Kconfig
Define hardware register offsets and bitfield macros
  • Create inspur_drm_regs.h with register address constants
  • Define macros for power/gate control, PLL setup, display controller, cursor, and interrupt bits
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_regs.h
Implement driver registration, PCI probe/removal, and VRAM/KMS core init/unload
  • Add inspur_drm_drv.c with pci_driver structure, probe/remove, load/unload functions
  • Implement interrupt handler, GEM VRAM aperture removal, and drmm_vram_helper_init
  • Add inspur_drm_drv.h defining private structs, prototypes, and include dependencies
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_drv.c
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_drv.h
Implement display engine (DE) with atomic plane and CRTC helpers
  • Add inspur_drm_de.c defining inspur_plane_atomic_check/update and drm_plane helpers
  • Implement CRTC atomic begin/enable/disable/flush, dpms, mode_valid, and mode_set logic
  • Integrate PLL configuration and display_ctrl_adjust for mode programming
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_de.c
Implement encoder and connector support for KMS
  • Add inspur_drm_vdac.c with encoder mode_set and connector get_modes/mode_valid helpers
  • Register encoder and connector with drm_connector_init and drm_encoder_init
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_vdac.c
Provide dumb-buffer creation and mode_config functions
  • Add inspur_ttm.c implementing inspur_dumb_create using drm_gem_vram_fill_create_dumb
  • Define inspur_mode_funcs for atomic_check, atomic_commit, fb_create, and mode_valid
drivers/gpu/drm/inspur/inspur-drm/inspur_ttm.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

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Avenger-285714 Avenger-285714 requested a review from opsiff June 2, 2025 00:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds a new Inspur DRM driver for Inspur BMC SoC to the Linux 6.6-y kernel, providing hardware initialization, mode configuration, and integration with DRM core frameworks. Key changes include:

  • Implementation of dumb buffer creation in inspur_ttm.c.
  • Initialization of encoder and connector in inspur_drm_vdac.c.
  • Addition of register definitions, driver header files, and integration entries in Makefiles and Kconfig files.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
drivers/gpu/drm/inspur/inspur-drm/inspur_ttm.c Adds a function for dumb buffer creation using DRM helpers.
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_vdac.c Implements encoder and connector initialization with error messages.
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_regs.h Provides register definitions for the Inspur DRM driver.
drivers/gpu/drm/inspur/inspur-drm/inspur_drm_drv.h Declares driver and function prototypes for Inspur DRM.
drivers/gpu/drm/inspur/inspur-drm/Makefile Lists source files for the Inspur DRM driver.
drivers/gpu/drm/inspur/inspur-drm/Kconfig Configures module options for the Inspur DRM driver.
drivers/gpu/drm/inspur/Makefile Top-level Makefile addition for the Inspur DRM driver.
drivers/gpu/drm/inspur/Kconfig Integrates the Inspur DRM driver Kconfig into the DRM subsystem.
drivers/gpu/drm/Makefile, drivers/gpu/drm/Kconfig Updated to include the Inspur DRM driver in the build system.

struct drm_mode_create_dumb *args)
{

return drm_gem_vram_fill_create_dumb(file, dev, 0, 16, args);
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

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

Consider adding a comment to explain the rationale behind using the magic numbers (0 and 16) in this helper call to improve code clarity.

Copilot uses AI. Check for mistakes.

encoder = devm_kzalloc(dev->dev, sizeof(*encoder), GFP_KERNEL);
if (!encoder) {
DRM_ERROR("failed to alloc memory when init encoder\n");
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

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

Consider changing 'alloc' to 'allocate' for clearer error messaging.

Suggested change
DRM_ERROR("failed to alloc memory when init encoder\n");
DRM_ERROR("failed to allocate memory when initializing encoder\n");

Copilot uses AI. Check for mistakes.

connector = devm_kzalloc(dev->dev, sizeof(*connector), GFP_KERNEL);
if (!connector) {
DRM_ERROR("failed to alloc memory when init connector\n");
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

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

Consider changing 'alloc' to 'allocate' in the error message to improve clarity.

Suggested change
DRM_ERROR("failed to alloc memory when init connector\n");
DRM_ERROR("failed to allocate memory when init connector\n");

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@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 @Avenger-285714 - I've reviewed your changes - here's some feedback:

  • You never register your interrupt handler (via request_irq or pci_enable_msi), so inspur_drm_interrupt will never fire and free_irq in unload is unmatched—please add proper IRQ registration and teardown in inspur_load/inspur_unload.
  • The inspur_pll_table only covers five common modes but regs.h defines PLL settings for additional resolutions (e.g. 1280×800, 1440×900, 1680×1050, 1920×1200); please expand the table or log a warning when falling back to the default PLL.
  • The PADDING macro in inspur_drm_de.c is never used—consider removing it to clean up dead code.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.


gbo = drm_gem_vram_of_gem(state->fb->obj[0]);

ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Pinned GEM object is not unpinned after use

Add a call to drm_gem_vram_unpin() after programming the registers to avoid leaking a pin reference.

}

/* if found none, we use default value */
*pll1 = CRT_PLL1_NS_25MHZ;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Silent fallback to default PLL config

Please add a log message when defaulting to 25MHz to aid in diagnosing unsupported modes.

@Avenger-285714
Copy link
Copy Markdown
Member Author

使用LLVM20编译工具链手工检查,使能DRM_INSPUR可通过编译。

@opsiff opsiff merged commit 1792cfc into deepin-community:linux-6.6.y Jun 3, 2025
6 of 7 checks passed
@Avenger-285714 Avenger-285714 deleted the inspur-drm branch June 3, 2025 02:39
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.

4 participants