Re: [PATCH] drm/radeon/kms: add ioport register access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 7, 2010 at 12:29 AM, Dave Airlie <airlied@xxxxxxxxx> wrote:
>>  int radeon_atombios_init(struct radeon_device *rdev)
>>  {
>>        struct card_info *atom_card_info =
>> @@ -427,6 +443,9 @@ int radeon_atombios_init(struct radeon_device *rdev)
>>        atom_card_info->dev = rdev->ddev;
>>        atom_card_info->reg_read = cail_reg_read;
>>        atom_card_info->reg_write = cail_reg_write;
>> +       /* needed for iio ops */
>> +       atom_card_info->ioreg_read = cail_ioreg_read;
>> +       atom_card_info->ioreg_write = cail_ioreg_write;
>>        atom_card_info->mc_read = cail_mc_read;
>>        atom_card_info->mc_write = cail_mc_write;
>>        atom_card_info->pll_read = cail_pll_read;
>> @@ -659,6 +678,19 @@ int radeon_device_init(struct radeon_device *rdev,
>>        DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)rdev->rmmio_base);
>>        DRM_INFO("register mmio size: %u\n", (unsigned)rdev->rmmio_size);
>>
>> +       /* io port mapping */
>> +       if (rdev->family >= CHIP_RV770) {
>> +               rdev->rio_mem_size = pci_resource_len(rdev->pdev, 4);
>> +               rdev->rio_mem = pci_iomap(rdev->pdev, 4, rdev->rio_mem_size);
>> +       } else {
>> +               rdev->rio_mem_size = pci_resource_len(rdev->pdev, 1);
>> +               rdev->rio_mem = pci_iomap(rdev->pdev, 1, rdev->rio_mem_size);
>> +       }
>> +       if (rdev->rio_mem == NULL) {
>> +               iounmap(rdev->rmmio);
>> +               return -EIO;
>> +       }
>> +
>
> This is all bad, my main r600 stopped working after this, from my
> quick boot test
> r100->r300 are all port 1, discrete r480 and upwards (not sure about
> rv410) is port 4,
> IGP, rs480 is port 1, rs690 is port 4, rs780 is port 1. We need to
> either guarantee these work
> or fallback gracefully instead of failing to load the driver.
>

The attached patch should handle it gracefully.

Alex

> Dave.
>
>>        /* if we have > 1 VGA cards, then disable the radeon VGA resources */
>>        /* this will fail for cards that aren't VGA class devices, just
>>         * ignore it */
>> @@ -701,6 +733,8 @@ void radeon_device_fini(struct radeon_device *rdev)
>>        destroy_workqueue(rdev->wq);
>>        vga_switcheroo_unregister_client(rdev->pdev);
>>        vga_client_register(rdev->pdev, NULL, NULL, NULL);
>> +       pci_iounmap(rdev->pdev, rdev->rio_mem);
>> +       rdev->rio_mem = NULL;
>>        iounmap(rdev->rmmio);
>>        rdev->rmmio = NULL;
>>  }
>> --
>> 1.7.0.1
>>
>>
>
From aa44b434805ef7d04198302a76fea20844702d37 Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexdeucher@xxxxxxxxx>
Date: Wed, 7 Jul 2010 01:54:57 -0400
Subject: [PATCH] drm/radeon/kms: ioport fixes

Walk the pci resources and make sure to use the I/O resource.
Unfortunately, the pci I/O resource number varies between
asic families.  If we don't find an I/O resource fall back
the the previous behavior of using MMIO for ATOM IIO.

Signed-off-by: Alex Deucher <alexdeucher@xxxxxxxxx>
---
 drivers/gpu/drm/radeon/radeon_device.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index fa85a34..d3e86f4 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -444,8 +444,14 @@ int radeon_atombios_init(struct radeon_device *rdev)
 	atom_card_info->reg_read = cail_reg_read;
 	atom_card_info->reg_write = cail_reg_write;
 	/* needed for iio ops */
-	atom_card_info->ioreg_read = cail_ioreg_read;
-	atom_card_info->ioreg_write = cail_ioreg_write;
+	if (rdev->rio_mem) {
+		atom_card_info->ioreg_read = cail_ioreg_read;
+		atom_card_info->ioreg_write = cail_ioreg_write;
+	} else {
+		DRM_ERROR("Unable to find PCI I/O BAR; using MMIO for ATOM IIO\n");
+		atom_card_info->ioreg_read = cail_reg_read;
+		atom_card_info->ioreg_write = cail_reg_write;
+	}
 	atom_card_info->mc_read = cail_mc_read;
 	atom_card_info->mc_write = cail_mc_write;
 	atom_card_info->pll_read = cail_pll_read;
@@ -592,7 +598,7 @@ int radeon_device_init(struct radeon_device *rdev,
 		       struct pci_dev *pdev,
 		       uint32_t flags)
 {
-	int r;
+	int r, i;
 	int dma_bits;
 
 	rdev->shutdown = false;
@@ -679,17 +685,15 @@ int radeon_device_init(struct radeon_device *rdev,
 	DRM_INFO("register mmio size: %u\n", (unsigned)rdev->rmmio_size);
 
 	/* io port mapping */
-	if (rdev->family >= CHIP_RV770) {
-		rdev->rio_mem_size = pci_resource_len(rdev->pdev, 4);
-		rdev->rio_mem = pci_iomap(rdev->pdev, 4, rdev->rio_mem_size);
-	} else {
-		rdev->rio_mem_size = pci_resource_len(rdev->pdev, 1);
-		rdev->rio_mem = pci_iomap(rdev->pdev, 1, rdev->rio_mem_size);
-	}
-	if (rdev->rio_mem == NULL) {
-		iounmap(rdev->rmmio);
-		return -EIO;
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		if (pci_resource_flags(rdev->pdev, i) & IORESOURCE_IO) {
+			rdev->rio_mem_size = pci_resource_len(rdev->pdev, i);
+			rdev->rio_mem = pci_iomap(rdev->pdev, i, rdev->rio_mem_size);
+			break;
+		}
 	}
+	if (rdev->rio_mem == NULL)
+		DRM_ERROR("Unable to find PCI I/O BAR\n");
 
 	/* if we have > 1 VGA cards, then disable the radeon VGA resources */
 	/* this will fail for cards that aren't VGA class devices, just
-- 
1.7.0.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux