drm/radeon/kms: add ioport register access
Subsystems (2)
PATCH 1/1 drm/radeon/kms: add ioport register access
This is required for the NB_MISC regs on rs780/rs880 which means HDMI/DVI/DP ports using PCIEPHY won't work without it. It might also help with s/r (asic init) issues on other atombios cards.
Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=28774
and similar issues reported by Alberto Milone.
--- drivers/gpu/drm/radeon/atom.c | 5 +-- drivers/gpu/drm/radeon/atom.h | 2 + drivers/gpu/drm/radeon/radeon.h | 25 +++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/atom.c +2 -3
@@ -108,12 +108,11 @@ static uint32_t atom_iio_execute(struct atom_context *ctx, int base, base++;break ;case ATOM_IIO_READ : - temp = ctx->card->reg_read (ctx->card,CU16 (base +1 )); + temp = ctx->card->ioreg_read (ctx->card,CU16 (base +1 )); base +=3 ;break ;case ATOM_IIO_WRITE : - (void )ctx->card->reg_read (ctx->card,CU16 (base +1 )); - ctx->card->reg_write (ctx->card,CU16 (base +1 ), temp); + ctx->card->ioreg_write (ctx->card,CU16 (base +1 ), temp); base +=3 ;break ;case ATOM_IIO_CLEAR :
drivers/gpu/drm/radeon/atom.h +2 -0
@@ -113,6 +113,8 @@ struct card_info {struct drm_device *dev;void (* reg_write)(struct card_info *,uint32_t ,uint32_t );/* filled by driver */ uint32_t (* reg_read)(struct card_info *,uint32_t );/* filled by driver */ +void (* ioreg_write)(struct card_info *,uint32_t ,uint32_t );/* filled by driver */ +uint32_t (* ioreg_read)(struct card_info *,uint32_t );/* filled by driver */ void (* mc_write)(struct card_info *,uint32_t ,uint32_t );/* filled by driver */ uint32_t (* mc_read)(struct card_info *,uint32_t );/* filled by driver */ void (* pll_write)(struct card_info *,uint32_t ,uint32_t );/* filled by driver */
drivers/gpu/drm/radeon/radeon.h +25 -0
@@ -1030,6 +1030,9 @@ struct radeon_device {uint32_t pcie_reg_mask;radeon_rreg_t pciep_rreg;radeon_wreg_t pciep_wreg; +/* io port */ +void __iomem *rio_mem; +resource_size_t rio_mem_size;struct radeon_clock clock;struct radeon_mc mc;struct radeon_gart gart;
@@ -1111,6 +1114,26 @@ static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32 } } +static inline u32 r100_io_rreg (struct radeon_device *rdev,u32 reg) +{ +if (reg < rdev->rio_mem_size) +return ioread32 (rdev->rio_mem + reg); +else { +iowrite32 (reg, rdev->rio_mem +RADEON_MM_INDEX ); +return ioread32 (rdev->rio_mem +RADEON_MM_DATA ); + } +} + +static inline void r100_io_wreg (struct radeon_device *rdev,u32 reg,u32 v) +{ +if (reg < rdev->rio_mem_size) +iowrite32 (v, rdev->rio_mem + reg); +else { +iowrite32 (reg, rdev->rio_mem +RADEON_MM_INDEX ); +iowrite32 (v, rdev->rio_mem +RADEON_MM_DATA ); + } +} +/* * Cast helper */
@@ -1149,6 +1172,8 @@ static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32WREG32_PLL (reg, tmp_); \ } while (0)#define DREG32_SYS (sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg))) +#define RREG32_IO (reg) r100_io_rreg(rdev, (reg)) +#define WREG32_IO (reg, v) r100_io_wreg(rdev, (reg), (v))/* * Indirect registers accessor
drivers/gpu/drm/radeon/radeon_device.c +34 -0
@@ -415,6 +415,22 @@ static uint32_t cail_reg_read(struct card_info *info, uint32_t reg)return r; } +static void cail_ioreg_write (struct card_info *info,uint32_t reg,uint32_t val) +{ +struct radeon_device *rdev = info->dev->dev_private; + +WREG32_IO (reg*4 , val); +} + +static uint32_t cail_ioreg_read (struct card_info *info,uint32_t reg) +{ +struct radeon_device *rdev = info->dev->dev_private; +uint32_t r; + + r =RREG32_IO (reg*4 ); +return r; +} +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 ; + } +/* 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 ; }
Signature · 1 line
1.7.0.1
2010/6/30 Alex Deucher <[email protected]>:
Quoted 10 lines
This is required for the
NB_MISCregs on rs780/rs880 which means HDMI/DVI/DP ports using PCIEPHY won't work without it. It might also help with s/r (asic init) issues on other atombios cards.Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=28774
and similar issues reported by Alberto Milone.Signed-off-by Alex Deucher <[email protected]>
It really fixes FDO #28774, thanks Alex. As this is not regression fix, I guess it'll go for .36?
Signature · 5 lines
Rafał _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 20 lines
int
radeon_atombios_init(struct radeon_device *rdev){
structcard_info*atom_card_info=drivers/gpu/drm/radeon/radeon_device.c +6
-0@@ -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);
drivers/gpu/drm/radeon/radeon_device.c int radeon_device_init(struct radeon_device *rdev, · line 693
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_device.c +10
-0+ 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 testr100->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.
Dave.
Quoted 16 lines
drivers/gpu/drm/radeon/radeon_device.c +2
-1/* 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
Quoted 31 lines · Dave Airlie
Quoted 20 lines
int
radeon_atombios_init(struct radeon_device *rdev){
structcard_info*atom_card_info=(quoted diff) +6
-0@@ -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);Review int radeon_device_init(struct radeon_device *rdev, · line 693
Quoted 10 lines
(quoted diff) +10
-0+ 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; + } +
Quoted 8 lines
This is all bad, my main r600 stopped working after this, from my quick boot test
r100->r300are 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
Quoted 19 lines
Dave.
Quoted 13 lines
(quoted diff) +2
-1/* 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; } --Quoted 3 lines
1.7.0.1
From aa44b434805ef7d04198302a76fea20844702d37 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
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.
--- drivers/gpu/drm/radeon/radeon_device.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +17 -13
@@ -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
Signature · 1 line
1.7.0.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave, last time you decided to push this fix for 2.6.35, then resigned. After additional fix from Alex I can see this in drm-next only, not in drm-fixes or Linus's tree. Did you change your mind to postpone it until next merge window, or just forgot about this in drm-fixes?
Signature · 5 lines
Rafał _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainer2010/7/17 Rafał Miłecki <[email protected]>:
Quoted 5 lines
Dave, last time you decided to push this fix for 2.6.35, then resigned. After additional fix from Alex I can see this in drm-next only, not in drm-fixes or Linus's tree. Did you change your mind to postpone it until next merge window, or just forgot about this in drm-fixes?
It only gets one chance at fixes, so its in drm-next now.
Dave.
Quoted 4 lines
--
Rafał
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · W dniu 17 lipca 2010 11:27 użytkownik Dave Airlie <[email protected]> napisał:
2010/7/17 Rafał Miłecki <[email protected]>:
Quoted 5 lines
Dave, last time you decided to push this fix for 2.6.35, then resigned. After additional fix from Alex I can see this in drm-next only, not in drm-fixes or Linus's tree. Did you change your mind to postpone it until next merge window, or just forgot about this in drm-fixes?
It only gets one chance at fixes, so its in drm-next now.
OK, thanks for expl. :)
Signature · 5 lines
Rafał _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel