Commit 8a9a0b8c authored by Jiakun Shuai's avatar Jiakun Shuai
Browse files

drm/ast: Fixed display error for ps23xx when using ast bmc card

phytium inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9NGXP


CVE: NA

-----------------------------------------------------------------

When the ast bmc card is detected on ps23xx SoCs, change the card's
vram to uncache mode to avoid unnecessary trouble.

Signed-off-by: default avatarWangHao <wanghao1851@phytium.com.cn>
Signed-off-by: default avatarJiakun Shuai <shuaijiakun1288@phytium.com.cn>
parent 8c04aa95
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;