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

!2495 [OLK 5.10]drm driver bug revise for hisilicon

Merge Pull Request from: @daiweizhong 
 
drm driver bug revise for hisilicon
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I89Y94
CVE: NA

[Content]
fix the bug which the hisilicon GPU driver reports an error when the os shutdown  
 
Link:https://gitee.com/openeuler/kernel/pulls/2495

 

Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 6f2b8180 3a2b5548
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -229,6 +229,21 @@ static int hibmc_hw_map(struct hibmc_drm_private *priv)
	return 0;
}

static void hibmc_hw_unmap(struct hibmc_drm_private *priv)
{
	struct drm_device *dev = priv->dev;

	if (priv->fb_map) {
		devm_iounmap(dev->dev, priv->fb_map);
		priv->fb_map = NULL;
	}

	if (priv->mmio) {
		devm_iounmap(dev->dev, priv->mmio);
		priv->mmio = NULL;
	}
}

static int hibmc_hw_init(struct hibmc_drm_private *priv)
{
	int ret;
@@ -254,6 +269,7 @@ static int hibmc_unload(struct drm_device *dev)
	pci_disable_msi(dev->pdev);
	hibmc_kms_fini(priv);
	hibmc_mm_fini(priv);
	hibmc_hw_unmap(priv);
	dev->dev_private = NULL;
	return 0;
}
@@ -368,6 +384,13 @@ static void hibmc_pci_remove(struct pci_dev *pdev)

	drm_dev_unregister(dev);
	hibmc_unload(dev);
	pci_disable_device(pdev);
	drm_dev_put(dev);
}

static void hibmc_pci_shutdown(struct pci_dev *pdev)
{
	hibmc_pci_remove(pdev);
}

static struct pci_device_id hibmc_pci_table[] = {
@@ -380,6 +403,7 @@ static struct pci_driver hibmc_pci_driver = {
	.id_table =	hibmc_pci_table,
	.probe =	hibmc_pci_probe,
	.remove =	hibmc_pci_remove,
	.shutdown = hibmc_pci_shutdown,
	.driver.pm = &hibmc_pm_ops,
};

+43 −3
Original line number Diff line number Diff line
@@ -18,6 +18,26 @@
#include "hibmc_drm_drv.h"
#include "hibmc_drm_regs.h"

#define HIBMC_STANDARD_VREFRESH		60

struct hibmc_resolution {
	int width;
	int height;
};

static const struct hibmc_resolution hibmc_mode_tables[] = {
	{800, 600},
	{1024, 768},
	{1152, 864},
	{1280, 768},
	{1280, 720},
	{1280, 960},
	{1280, 1024},
	{1600, 1200},
	{1920, 1080},
	{1920, 1200},
};

static int hibmc_connector_get_modes(struct drm_connector *connector)
{
	int count;
@@ -42,11 +62,31 @@ static int hibmc_connector_get_modes(struct drm_connector *connector)
	return count;
}

static enum drm_mode_status hibmc_connector_mode_valid(struct drm_connector *connector,
				      struct drm_display_mode *mode)
static int hibmc_valid_mode(int width, int height)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(hibmc_mode_tables); i++) {
		if ((hibmc_mode_tables[i].width == width) &&
			(hibmc_mode_tables[i].height == height)) {
			return MODE_OK;
		}
	}

	return MODE_NOMODE;
}

static enum drm_mode_status hibmc_connector_mode_valid(
	struct drm_connector *connector, struct drm_display_mode *mode)
{
	int vrefresh = drm_mode_vrefresh(mode);

	if ((vrefresh < HIBMC_STANDARD_VREFRESH - 1) ||
		(vrefresh > HIBMC_STANDARD_VREFRESH + 1))
		return MODE_NOMODE;

	return hibmc_valid_mode(mode->hdisplay, mode->vdisplay);
}

static void hibmc_connector_destroy(struct drm_connector *connector)
{