Unverified Commit 39023e2d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7583 [OLK-6.6] Fixed display error for ps23xx when using ast and pe2201 bmc card

Merge Pull Request from: @shuaijiakun 
 
bugzilla: https://gitee.com/openeuler/kernel/issues/I9NGXP

When the ast and pe2201 bmc card is detected on ps23xx SoCs, change the card's vram to uncache mode to avoid unnecessary trouble. 
 
Link:https://gitee.com/openeuler/kernel/pulls/7583

 

Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 377fe983 8a9a0b8c
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -50,11 +50,31 @@ module_param_named(modeset, ast_modeset, int, 0400);

DEFINE_DRM_GEM_FOPS(ast_fops);

#define DRM_AST_VRAM_TYPE_DEVICE 0x0
#define DRM_IOCTL_AST_VRAM_TYPE_DEVICE	DRM_IO(DRM_COMMAND_BASE\
	+ DRM_AST_VRAM_TYPE_DEVICE)

static int ast_ioctl_check_5c01_device(struct drm_device *dev, void *data,
				struct drm_file *file_priv)
{
	struct ast_device *ast = to_ast_device(dev);

	return ast->is_5c01_device ? 1 : 0;
}

static const struct drm_ioctl_desc ast_ioctls[] = {
	/* for test, none so far */
	DRM_IOCTL_DEF_DRV(AST_VRAM_TYPE_DEVICE, ast_ioctl_check_5c01_device,
						DRM_AUTH|DRM_UNLOCKED),
};

static const struct drm_driver ast_driver = {
	.driver_features = DRIVER_ATOMIC |
			   DRIVER_GEM |
			   DRIVER_MODESET,

	.ioctls = ast_ioctls,
	.num_ioctls = ARRAY_SIZE(ast_ioctls),
	.fops = &ast_fops,
	.name = DRIVER_NAME,
	.desc = DRIVER_DESC,
+3 −0
Original line number Diff line number Diff line
@@ -231,6 +231,9 @@ struct ast_device {
		} bmc;
	} output;

	struct ttm_device *bdev;

	bool is_5c01_device;
	bool support_wide_screen;
	enum {
		ast_use_p2a,
+33 −1
Original line number Diff line number Diff line
@@ -30,6 +30,12 @@

#include <drm/drm_managed.h>
#include <drm/drm_print.h>
#include <drm/drm_gem_vram_helper.h>

#include <drm/ttm/ttm_resource.h>
#include <drm/ttm/ttm_tt.h>
#include <drm/ttm/ttm_range_manager.h>
#include <drm/ttm/ttm_placement.h>

#include "ast_drv.h"

@@ -71,6 +77,25 @@ static u32 ast_get_vram_size(struct ast_device *ast)
	return vram_size;
}

static bool ast_pci_host_is_5c01(struct pci_bus *bus)
{
	struct pci_bus *child = bus;
	struct pci_dev *root = NULL;

	while (child) {
		if (child->parent->parent)
			child = child->parent;
		else
			break;
	}

	root = child->self;

	if ((root->vendor == 0x1db7) && (root->device == 0x5c01))
		return true;
	return false;
}

int ast_mm_init(struct ast_device *ast)
{
	struct drm_device *dev = &ast->base;
@@ -87,7 +112,14 @@ int ast_mm_init(struct ast_device *ast)

	vram_size = ast_get_vram_size(ast);

	if (ast_pci_host_is_5c01(pdev->bus)) {
		ast->is_5c01_device = true;
		ast->vram = devm_ioremap(dev->dev, base, vram_size);
	} else {
		ast->is_5c01_device = false;
		ast->vram = devm_ioremap_wc(dev->dev, base, vram_size);
	}

	if (!ast->vram)
		return -ENOMEM;

+19 −2
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ static int phytium_display_load(struct drm_device *dev, unsigned long flags)
		goto failed_modeset_init;
	}

	if (priv->support_memory_type & MEMORY_TYPE_VRAM)
	if (priv->support_memory_type & (MEMORY_TYPE_VRAM_WC | MEMORY_TYPE_VRAM_DEVICE))
		priv->vram_hw_init(priv);

	phytium_irq_preinstall(dev);
@@ -285,8 +285,25 @@ static void phytium_display_unload(struct drm_device *dev)
	drm_mode_config_cleanup(dev);
}

/* phytium display specific ioctls
 * The device specific ioctl range is 0x40 to 0x79.
 */
#define DRM_PHYTIUM_VRAM_TYPE_DEVICE	0x0
#define DRM_IOCTL_PHYTIUM_VRAM_TYPE_DEVICE	DRM_IO(DRM_COMMAND_BASE\
	+ DRM_PHYTIUM_VRAM_TYPE_DEVICE)

static int phytium_ioctl_check_vram_device(struct drm_device *dev, void *data,
				struct drm_file *file_priv)
{
	struct phytium_display_private *priv = dev->dev_private;

	return ((priv->support_memory_type == MEMORY_TYPE_VRAM_DEVICE) ? 1 : 0);
}

static const struct drm_ioctl_desc phytium_ioctls[] = {
	/* for test, none so far */
	DRM_IOCTL_DEF_DRV(PHYTIUM_VRAM_TYPE_DEVICE, phytium_ioctl_check_vram_device,
						DRM_AUTH|DRM_UNLOCKED),
};

static const struct file_operations phytium_drm_driver_fops = {
@@ -378,7 +395,7 @@ static int phytium_display_pm_resume(struct drm_device *dev)
	phytium_crtc_resume(dev);
	phytium_gem_resume(dev);

	if (priv->support_memory_type & MEMORY_TYPE_VRAM)
	if (priv->support_memory_type & (MEMORY_TYPE_VRAM_WC | MEMORY_TYPE_VRAM_DEVICE))
		priv->vram_hw_init(priv);

	ret = drm_atomic_helper_resume(dev, dev->mode_config.suspend_state);
+2 −1
Original line number Diff line number Diff line
@@ -49,9 +49,10 @@ enum phytium_mem_state_type {
	PHYTIUM_MEM_STATE_TYPE_COUNT,
};

#define MEMORY_TYPE_VRAM		0x1
#define MEMORY_TYPE_VRAM_WC		0x1
#define MEMORY_TYPE_SYSTEM_CARVEOUT	0x2
#define MEMORY_TYPE_SYSTEM_UNIFIED	0x4
#define MEMORY_TYPE_VRAM_DEVICE		0x8

#define IS_PLATFORM(priv, p) ((priv)->info.platform_mask & BIT(p))

Loading