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

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

Merge Pull Request from: @shuaijiakun 
 
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/7224

 

Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 8f312e9b 968ee436
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_private *priv = to_ast_private(dev);

	return priv->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 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,
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ struct ast_private {
	struct drm_encoder encoder;
	struct ast_connector connector;

	bool is_5c01_device;
	bool support_wide_screen;
	enum {
		ast_use_p2a,
+54 −0
Original line number Diff line number Diff line
@@ -74,6 +74,52 @@ static u32 ast_get_vram_size(struct ast_private *ast)
	return vram_size;
}

static int ast_driver_io_mem_reserve(struct ttm_bo_device *bdev,
									struct ttm_resource *mem)
{
	struct drm_vram_mm *vmm = drm_vram_mm_of_bdev(bdev);
	size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT;

	switch (mem->mem_type) {
	case TTM_PL_SYSTEM:     /* nothing to do */
			break;
	case TTM_PL_VRAM:
			mem->bus.offset = (mem->start << PAGE_SHIFT) + vmm->vram_base;
			mem->bus.is_iomem = true;

			mem->placement = TTM_PL_FLAG_UNCACHED;
			mem->bus.addr = ioremap(mem->bus.offset, bus_size);

			if (!mem->bus.addr)
				return -ENOMEM;

			break;
	default:
			return -EINVAL;
	}

	return 0;
}

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;
}

static void ast_mm_release(struct drm_device *dev, void *ptr)
{
	struct ast_private *ast = to_ast_private(dev);
@@ -86,6 +132,7 @@ static void ast_mm_release(struct drm_device *dev, void *ptr)
int ast_mm_init(struct ast_private *ast)
{
	struct drm_device *dev = &ast->base;
	struct pci_dev *pdev = to_pci_dev(dev->dev);
	u32 vram_size;
	int ret;

@@ -98,6 +145,13 @@ int ast_mm_init(struct ast_private *ast)
		return ret;
	}

	if (ast_pci_host_is_5c01(pdev->bus) && dev->vram_mm->bdev.driver) {
		ast->is_5c01_device = true;
		dev->vram_mm->bdev.driver->io_mem_reserve = ast_driver_io_mem_reserve;
	} else {
		ast->is_5c01_device = false;
	}

	arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
				   pci_resource_len(dev->pdev, 0));
	ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
+19 −2
Original line number Diff line number Diff line
@@ -250,7 +250,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);

	ret = drm_irq_install(dev, priv->irq);
@@ -281,8 +281,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 = {
@@ -382,7 +399,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