drm/mgag200: Support desktop chips
Subsystems (3)
Thomas Zimmermann
maintainerv2 cover drm/mgag200: Support desktop chips
This patchset puts device initialization in the correct order and adds support for G200 Desktop chips (PCI ids 0x520 and 0x521).
The patchset has already been reviewed. In v2 I changed the patch 8 to copy the BIOS ROM to system memory, which simplifies parsing.
The first 7 patches prepare the driver. Desktop chips would probably work without them, but since we're at it we can also do it right.
Patch 1 enables cached page mappings GEM buffers. SHMEM supports this well now and the MGA device does not access the buffer memory directly. So no corrupt display output is to be expected.
Patches 2 to 6 fix the initialization of device registers. Several fundamental registers were only set late during device initialization. This was probably not a problem in practice, as the VGA BIOS does the setup during POST anyway. These patches move the code to the beginning of the device initialization. If we ever have to POST an MGA device from the driver, the correct order of operations will matter.
G200SEs store a unique id in the device structure. Patch 7 moves the value to model-specific data area. This will be helpful for patch 8.
Patch 8 adds support for desktop chips' PCI ids. All the memory and modesetting code continues to work as before. The PLL setup code gets an additional helper for the new HW. PCI and DAC registers get a few new default values. Most significantly, the driver parses the VGA BIOS for clock settings. It's all separate from the server code, so no regressions are to be expected. The new HW support is based on an earlier patch the was posted in July 2017. [1]
Tested on G200EW and G200 AGP hardware by running the fbdev console, Weston and Gnome on Xorg.
v2:
* copy BIOS ROM to system memory; access with load/store
* fix typos
[1] https://lists.freedesktop.org/archives/dri-devel/2017-July/147647.html
Thomas Zimmermann (8):
drm/mgag200: Enable caching for SHMEM pages drm/mgag200: Move register initialization into helper function drm/mgag200: Initialize PCI registers early during device setup drm/mgag200: Enable MGA mode during device register initialization drm/mgag200: Set MISC memory flags in mm init code drm/mgag200: Clear <page> field during MM init drm/mgag200: Move G200SE's unique id into model-specific data drm/mgag200: Add support for G200 desktop cards
MAINTAINERS | 2 +- drivers/gpu/drm/mgag200/Kconfig | 12 +- drivers/gpu/drm/mgag200/mgag200_drv.c | 225 +++++++++++++++++++++++-- drivers/gpu/drm/mgag200/mgag200_drv.h | 19 ++- drivers/gpu/drm/mgag200/mgag200_mm.c | 8 + drivers/gpu/drm/mgag200/mgag200_mode.c | 153 ++++++++++------- drivers/gpu/drm/mgag200/mgag200_reg.h | 4 + 7 files changed, 340 insertions(+), 83 deletions(-)
--
2.27.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 1/8 drm/mgag200: Enable caching for SHMEM pages
SHMEM pages use write-combine caching by default, but can also use the platform's default page caching. Doing so may improve the performance of I/O on the framebuffer.
Mgag200's hardware does not access framebuffer pages directly (i.e., via DMA), so enabling caching does not have an effect on consistency of the framebuffer memory or the displayed data.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mgag200/mgag200_drv.c +1 -0
@@ -36,6 +36,7 @@ static struct drm_driver mgag200_driver = { .major = DRIVER_MAJOR, .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL, + .gem_create_object = drm_gem_shmem_create_object_cached, DRM_GEM_SHMEM_DRIVER_OPS, };
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 2/8 drm/mgag200: Move register initialization into helper function
In reply to Thomas ZimmermannThe mgag200 driver maps registers into the address space. Move the code into a separate helper function. No functional changes.
One small difference is in the handling of SDRAM/SGRAM. MGA devices can come with either SDRAM or SGRAM. So far, the driver checked for SDRAM, which is the common case. The patch moves this code into a separate helper and checks for SGRAM, which is the special case. The test itself is the same as before.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 37 ++++++++++++++++++++++----- drivers/gpu/drm/mgag200/mgag200_reg.h | 2 ++ 2 files changed, 32 insertions(+), 7 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +30 -7
@@ -44,18 +44,26 @@ static struct drm_driver mgag200_driver = {* DRM device */ -static int mgag200_device_init (struct mga_device *mdev,unsigned long flags) +static bool mgag200_has_sgram (struct mga_device *mdev) {struct drm_device *dev = &mdev->base; -int ret, option; +u32 option; +int ret; - mdev->flags =mgag200_flags_from_driver_data (flags); - mdev->type =mgag200_type_from_driver_data (flags); + ret =pci_read_config_dword (dev->pdev,PCI_MGA_OPTION , &option); +if (drm_WARN (dev, ret,"failed to read PCI config dword: %d\n" , ret)) +return false; + +return !!(option &PCI_MGA_OPTION_HARDPWMSK ); +} -pci_read_config_dword (dev->pdev,PCI_MGA_OPTION , &option); - mdev->has_sdram = !(option & (1 <<14 )); +static int mgag200_regs_init (struct mga_device *mdev) +{ +struct drm_device *dev = &mdev->base; + + mdev->has_sdram = !mgag200_has_sgram (mdev); -/* BAR 0 is the framebuffer, BAR 1 contains registers */ +/* BAR 1 contains registers */ mdev->rmmio_base =pci_resource_start (dev->pdev,1 ); mdev->rmmio_size =pci_resource_len (dev->pdev,1 );
@@ -69,6 +77,21 @@ static int mgag200_device_init(struct mga_device *mdev, unsigned long flags)if (mdev->rmmio ==NULL )return -ENOMEM ; +return 0 ; +} + +static int mgag200_device_init (struct mga_device *mdev,unsigned long flags) +{ +struct drm_device *dev = &mdev->base; +int ret; + + mdev->flags =mgag200_flags_from_driver_data (flags); + mdev->type =mgag200_type_from_driver_data (flags); + + ret =mgag200_regs_init (mdev); +if (ret) +return ret; +/* stash G200 SE model number for later use */ if (IS_G200_SE (mdev)) { mdev->unique_rev_id =RREG32 (0x1e24 );
drivers/gpu/drm/mgag200/mgag200_reg.h +2 -0
@@ -282,6 +282,8 @@#define PCI_MGA_OPTION2 0x50#define PCI_MGA_OPTION3 0x54 +#define PCI_MGA_OPTION_HARDPWMSK BIT(14) +#define RAMDAC_OFFSET 0x3c00/* TVP3026 direct registers */
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 3/8 drm/mgag200: Initialize PCI registers early during device setup
In reply to Thomas ZimmermannSo far, PCI option registers were initialized as part of modesetting, which is late in the process. As these registers control fundamental operation, they should be set early.
The patch moves the PCI option handling into device register setup, before even the device MMIO memory is being mapped. No functional changes made.
Moving the PCI code next to the device-register setup also allows to remove the has_sdram field from struct mga_device. The state is now local to the init helper.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 32 +++++++++++++++++++- drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_mode.c | 41 -------------------------- 3 files changed, 31 insertions(+), 43 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +31 -1
@@ -60,8 +60,38 @@ static bool mgag200_has_sgram(struct mga_device *mdev)static int mgag200_regs_init (struct mga_device *mdev) {struct drm_device *dev = &mdev->base; +u32 option, option2; + +switch (mdev->type) { +case G200_SE_A : +case G200_SE_B : +if (mgag200_has_sgram (mdev)) + option |=PCI_MGA_OPTION_HARDPWMSK ; + option2 =0x00008000 ; +break ; +case G200_WB : +case G200_EW3 : + option =0x41049120 ; + option2 =0x0000b000 ; +break ; +case G200_EV : + option =0x00000120 ; + option2 =0x0000b000 ; +break ; +case G200_EH : +case G200_EH3 : + option =0x00000120 ; + option2 =0x0000b000 ; +break ; +default : + option =0 ; + option2 =0 ; + } - mdev->has_sdram = !mgag200_has_sgram (mdev); +if (option) +pci_write_config_dword (dev->pdev,PCI_MGA_OPTION , option); +if (option2) +pci_write_config_dword (dev->pdev,PCI_MGA_OPTION2 , option2);/* BAR 1 contains registers */ mdev->rmmio_base =pci_resource_start (dev->pdev,1 );
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -1
@@ -161,7 +161,6 @@ struct mga_device {size_t vram_fb_available;enum mga_type type; -int has_sdram;int bpp_shifts[4 ];
drivers/gpu/drm/mgag200/mgag200_mode.c +0 -41
59 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
kernel test robot
build botRe: [PATCH v2 3/8] drm/mgag200: Initialize PCI registers early during device setup
I love your patch! Perhaps something to improve:
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on linus/master next-20200807]
[cannot apply to drm-exynos/exynos-drm-next drm-intel/for-linux-next tegra-drm/drm/tegra/for-next drm/drm-next v5.8] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-mgag200-Support-desktop-chips/20200730-183126 base: git://anongit.freedesktop.org/drm/drm-tip drm-tip config: x86_64-randconfig-m001-20200807 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/gpu/drm/mgag200/mgag200_drv.c:91 mgag200_regs_init() error: uninitialized symbol 'option'.
vim +/option +91 drivers/gpu/drm/mgag200/mgag200_drv.c
59
60 static int mgag200_regs_init(struct mga_device *mdev)
61 {
62 struct drm_device *dev = &mdev->base;
63 u32 option, option2;
64
65 switch (mdev->type) {
66 case G200_SE_A:
67 case G200_SE_B:
68 if (mgag200_has_sgram(mdev))
69 option |= PCI_MGA_OPTION_HARDPWMSK;
70 option2 = 0x00008000;
71 break;
72 case G200_WB:
73 case G200_EW3:
74 option = 0x41049120;
75 option2 = 0x0000b000;
76 break;
77 case G200_EV:
78 option = 0x00000120;
79 option2 = 0x0000b000;
80 break;
81 case G200_EH:
82 case G200_EH3:
83 option = 0x00000120;
84 option2 = 0x0000b000;
85 break;
86 default:
87 option = 0;
88 option2 = 0;
89 }
90
> 91 if (option)
92 pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option);
93 if (option2)
94 pci_write_config_dword(dev->pdev, PCI_MGA_OPTION2, option2);
95
96 /* BAR 1 contains registers */
97 mdev->rmmio_base = pci_resource_start(dev->pdev, 1);
98 mdev->rmmio_size = pci_resource_len(dev->pdev, 1);
99 100 if (!devm_request_mem_region(dev->dev, mdev->rmmio_base,
101 mdev->rmmio_size, "mgadrmfb_mmio")) {
102 drm_err(dev, "can't reserve mmio registers\n");
103 return -ENOMEM;
104 }
105
106 mdev->rmmio = pcim_iomap(dev->pdev, 1, 0);
107 if (mdev->rmmio == NULL)
108 return -ENOMEM;
109
110 return 0;
111 }
112
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Thomas Zimmermann
maintainerPATCH v2 4/8 drm/mgag200: Enable MGA mode during device register initialization
In reply to Thomas ZimmermannMGA cards can run in traditional VGA mode or an enhanced MGA mode; with the latter being required for KMS. So far, MGA mode was enabled during modesetting. As it's fundamental for device operation, the patch moves it next to the device register setup.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 5 +++++ drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +----- drivers/gpu/drm/mgag200/mgag200_reg.h | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +5 -0
@@ -61,6 +61,7 @@ static int mgag200_regs_init(struct mga_device *mdev) {struct drm_device *dev = &mdev->base;u32 option, option2; +u8 crtcext3;switch (mdev->type) {case G200_SE_A :
@@ -107,6 +108,10 @@ static int mgag200_regs_init(struct mga_device *mdev)if (mdev->rmmio ==NULL )return -ENOMEM ; +RREG_ECRT (0x03 , crtcext3); + crtcext3 |=MGAREG_CRTCEXT3_MGAMODE ; +WREG_ECRT (0x03 , crtcext3); +return 0 ; }
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -5
@@ -946,7 +946,7 @@ static void mgag200_set_dac_regs(struct mga_device *mdev)static void mgag200_init_regs (struct mga_device *mdev) { -u8 crtc11, crtcext3, crtcext4, misc; +u8 crtc11, crtcext4, misc;mgag200_set_dac_regs (mdev);
@@ -961,12 +961,8 @@ static void mgag200_init_regs(struct mga_device *mdev)WREG_CRT (14 ,0 );WREG_CRT (15 ,0 ); -RREG_ECRT (0x03 , crtcext3); - - crtcext3 |=BIT (7 );/* enable MGA mode */ crtcext4 =0x00 ; -WREG_ECRT (0x03 , crtcext3);WREG_ECRT (0x04 , crtcext4);RREG_CRT (0x11 , crtc11);
drivers/gpu/drm/mgag200/mgag200_reg.h +2 -0
@@ -256,6 +256,8 @@#define MGAREG_CRTCEXT1_VSYNCOFF BIT(5)#define MGAREG_CRTCEXT1_HSYNCOFF BIT(4) +#define MGAREG_CRTCEXT3_MGAMODE BIT(7) +/* Cursor X and Y position */ #define MGA_CURPOSXL 0x3c0c#define MGA_CURPOSXH 0x3c0d
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 5/8 drm/mgag200: Set MISC memory flags in mm init code
In reply to Thomas ZimmermannThe modesetting code initialized several memory-related flags in the MISC register. Move this code to MM initialization.
--- drivers/gpu/drm/mgag200/mgag200_mm.c | 6 ++++++ drivers/gpu/drm/mgag200/mgag200_mode.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mm.c +6 -0
@@ -90,9 +90,15 @@ static void mgag200_mm_release(struct drm_device *dev, void *ptr)int mgag200_mm_init (struct mga_device *mdev) {struct drm_device *dev = &mdev->base; +u8 misc;resource_size_t start, len;int ret; + misc =RREG8 (MGA_MISC_IN ); + misc |=MGAREG_MISC_RAMMAPEN | +MGAREG_MISC_HIGH_PG_SEL ; +WREG8 (MGA_MISC_OUT , misc); +/* BAR 0 is VRAM */ start =pci_resource_start (dev->pdev,0 ); len =pci_resource_len (dev->pdev,0 );
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -3
@@ -978,9 +978,7 @@ static void mgag200_init_regs(struct mga_device *mdev)WREG_ECRT (0x34 ,0x5 ); misc =RREG8 (MGA_MISC_IN ); - misc |=MGAREG_MISC_IOADSEL | -MGAREG_MISC_RAMMAPEN | -MGAREG_MISC_HIGH_PG_SEL ; + misc |=MGAREG_MISC_IOADSEL ;WREG8 (MGA_MISC_OUT , misc); }
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 6/8 drm/mgag200: Clear <page> field during MM init
In reply to Thomas ZimmermannThe modesetting code initialized the memory-related register CRTCEXT4. Move this code to MM initialization.
--- drivers/gpu/drm/mgag200/mgag200_mm.c | 2 ++ drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mm.c +2 -0
@@ -94,6 +94,8 @@ int mgag200_mm_init(struct mga_device *mdev)resource_size_t start, len;int ret; +WREG_ECRT (0x04 ,0x00 ); + misc =RREG8 (MGA_MISC_IN ); misc |=MGAREG_MISC_RAMMAPEN |MGAREG_MISC_HIGH_PG_SEL ;
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -5
@@ -946,7 +946,7 @@ static void mgag200_set_dac_regs(struct mga_device *mdev)static void mgag200_init_regs (struct mga_device *mdev) { -u8 crtc11, crtcext4, misc; +u8 crtc11, misc;mgag200_set_dac_regs (mdev);
@@ -961,10 +961,6 @@ static void mgag200_init_regs(struct mga_device *mdev)WREG_CRT (14 ,0 );WREG_CRT (15 ,0 ); - crtcext4 =0x00 ; - -WREG_ECRT (0x04 , crtcext4); -RREG_CRT (0x11 , crtc11); crtc11 &= ~(MGAREG_CRTC11_CRTCPROTECT | MGAREG_CRTC11_VINTEN |
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 7/8 drm/mgag200: Move G200SE's unique id into model-specific data
In reply to Thomas ZimmermannThe unique revision id is only useful for G200SE devices. Store the value in model-specific data within struct mga_device. While at it, the patch also adds an init helper for the value.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 19 +++++++++++++------ drivers/gpu/drm/mgag200/mgag200_drv.h | 8 ++++++-- drivers/gpu/drm/mgag200/mgag200_mode.c | 18 +++++++++++------- 3 files changed, 30 insertions(+), 15 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +13 -6
@@ -115,6 +115,17 @@ static int mgag200_regs_init(struct mga_device *mdev)return 0 ; } +static void mgag200_g200se_init_unique_id (struct mga_device *mdev) +{ +struct drm_device *dev = &mdev->base; + +/* stash G200 SE model number for later use */ + mdev->model.g200se.unique_rev_id =RREG32 (0x1e24 ); + +drm_dbg (dev,"G200 SE unique revision id is 0x%x\n" , + mdev->model.g200se.unique_rev_id); +} +static int mgag200_device_init (struct mga_device *mdev,unsigned long flags) {struct drm_device *dev = &mdev->base;
@@ -127,12 +138,8 @@ static int mgag200_device_init(struct mga_device *mdev, unsigned long flags)if (ret)return ret; -/* stash G200 SE model number for later use */ -if (IS_G200_SE (mdev)) { - mdev->unique_rev_id =RREG32 (0x1e24 ); -drm_dbg (dev,"G200 SE unique revision id is 0x%x\n" , - mdev->unique_rev_id); - } +if (IS_G200_SE (mdev)) +mgag200_g200se_init_unique_id (mdev); ret =mgag200_mm_init (mdev);if (ret)
drivers/gpu/drm/mgag200/mgag200_drv.h +6 -2
@@ -166,8 +166,12 @@ struct mga_device {int fb_mtrr; -/* SE model number stored in reg 0x1e24 */ -u32 unique_rev_id; +union { +struct { +/* SE model number stored in reg 0x1e24 */ +u32 unique_rev_id; + } g200se; + } model;struct mga_connector connector;struct drm_simple_display_pipe display_pipe;
drivers/gpu/drm/mgag200/mgag200_mode.c +11 -7
@@ -112,6 +112,7 @@ static inline void mga_wait_busy(struct mga_device *mdev)static int mga_g200se_set_plls (struct mga_device *mdev,long clock) { +u32 unique_rev_id = mdev->model.g200se.unique_rev_id;unsigned int vcomax, vcomin, pllreffreq;unsigned int delta, tmpdelta, permitteddelta;unsigned int testp, testm, testn;
@@ -121,7 +122,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)unsigned int fvv;unsigned int i; -if (mdev->unique_rev_id <=0x03 ) { +if (unique_rev_id <=0x03 ) { m = n = p =0 ; vcomax =320000 ;
@@ -219,7 +220,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)WREG_DAC (MGA1064_PIX_PLLC_N , n);WREG_DAC (MGA1064_PIX_PLLC_P , p); -if (mdev->unique_rev_id >=0x04 ) { +if (unique_rev_id >=0x04 ) {WREG_DAC (0x1a ,0x09 );msleep (20 );WREG_DAC (0x1a ,0x01 );
@@ -1183,12 +1184,13 @@ static void mgag200_g200se_set_hiprilvl(struct mga_device *mdev,const struct drm_display_mode *mode, const struct drm_framebuffer *fb) { + u32 unique_rev_id = mdev->model.g200se.unique_rev_id;unsigned int hiprilvl;u8 crtcext6; -if (mdev->unique_rev_id >=0x04 ) { +if (unique_rev_id >=0x04 ) { hiprilvl =0 ; - }else if (mdev->unique_rev_id >=0x02 ) { + }else if (unique_rev_id >=0x02 ) {unsigned int bpp;unsigned long mb;
@@ -1213,7 +1215,7 @@ static void mgag200_g200se_set_hiprilvl(struct mga_device *mdev,else hiprilvl =5 ; - }else if (mdev->unique_rev_id >=0x01 ) { + }else if (unique_rev_id >=0x01 ) { hiprilvl =3 ; }else { hiprilvl =4 ;
@@ -1337,7 +1339,9 @@ static enum drm_mode_status mga_vga_mode_valid(struct drm_connector *connector,int bpp =32 ;if (IS_G200_SE (mdev)) { -if (mdev->unique_rev_id ==0x01 ) { +u32 unique_rev_id = mdev->model.g200se.unique_rev_id; + +if (unique_rev_id ==0x01 ) {if (mode->hdisplay >1600 )return MODE_VIRTUAL_X ;if (mode->vdisplay >1200 )
@@ -1345,7 +1349,7 @@ static enum drm_mode_status mga_vga_mode_valid(struct drm_connector *connector,if (mga_vga_calculate_mode_bandwidth (mode, bpp) > (24400 *1024 ))return MODE_BANDWIDTH ; - }else if (mdev->unique_rev_id ==0x02 ) { + }else if (unique_rev_id ==0x02 ) {if (mode->hdisplay >1920 )return MODE_VIRTUAL_X ;if (mode->vdisplay >1200 )
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 8/8 drm/mgag200: Add support for G200 desktop cards
In reply to Thomas ZimmermannThis patch adds support for G200 desktop cards. We can reuse the whole memory and modesetting code. A few PCI and DAC register values have to be updated accordingly.
The most significant change is in the PLL setup. The driver parses the device's BIOS to retrieve clock limits and reference clocks. With no BIOS found, safe defaults are being used.
v2:
* copy BIOS ROM to system memory and access with regular load/store; resolves potential HW limitations
* fix some stray whitespaces
--- MAINTAINERS | 2 +- drivers/gpu/drm/mgag200/Kconfig | 12 +-- drivers/gpu/drm/mgag200/mgag200_drv.c | 137 ++++++++++++++++++++++++- drivers/gpu/drm/mgag200/mgag200_drv.h | 10 ++ drivers/gpu/drm/mgag200/mgag200_mode.c | 80 +++++++++++++++ 5 files changed, 232 insertions(+), 9 deletions(-)
MAINTAINERS +1 -1
@@ -5406,7 +5406,7 @@ S: Orphan / Obsolete F: drivers/gpu/drm/mga/ F: include/uapi/drm/mga_drm.h -DRM DRIVER FOR MGA G200 SERVER GRAPHICS CHIPS +DRM DRIVER FOR MGA G200 GRAPHICS CHIPS M: Dave Airlie <[email protected]> S: Odd Fixes F: drivers/gpu/drm/mgag200/
drivers/gpu/drm/mgag200/Kconfig +5 -7
@@ -1,13 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only config DRM_MGAG200 - tristate "Kernel modesetting driver for MGA G200 server engines" + tristate "Matrox G200" depends on DRM && PCI && MMU select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER help - This is a KMS driver for the MGA G200 server chips, it - does not support the original MGA G200 or any of the desktop - chips. It requires 0.3.0 of the modesetting userspace driver, - and a version of mga driver that will fail on KMS enabled - devices. - + This is a KMS driver for Matrox G200 chips. It supports the original + MGA G200 desktop chips and the server variants. It requires 0.3.0 + of the modesetting userspace driver, and a version of mga driver + that will fail on KMS enabled devices.
drivers/gpu/drm/mgag200/mgag200_drv.c +136 -1
161 lines not on this page · raw message
drivers/gpu/drm/mgag200/mgag200_drv.h +10 -0
@@ -38,6 +38,8 @@#define RREG32 (reg) ioread32(((void __iomem *)mdev->rmmio) + (reg))#define WREG32 (reg, v) iowrite32(v, ((void __iomem *)mdev->rmmio) + (reg)) +#define MGA_BIOS_OFFSET 0x7ffc +#define ATTR_INDEX 0x1fc0#define ATTR_DATA 0x1fc1
@@ -129,6 +131,8 @@ struct mga_mc { };enum mga_type { +G200_PCI , +G200_AGP ,G200_SE_A ,G200_SE_B ,G200_WB ,
@@ -167,12 +171,18 @@ struct mga_device {int fb_mtrr;union { +struct { +long ref_clk; +long pclk_min; +long pclk_max; + } g200;struct {/* SE model number stored in reg 0x1e24 */ u32 unique_rev_id; } g200se; } model; +struct mga_connector connector;struct drm_simple_display_pipe display_pipe; };
drivers/gpu/drm/mgag200/mgag200_mode.c +80 -0
98 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
kernel test robot
build botRe: [PATCH v2 8/8] drm/mgag200: Add support for G200 desktop cards
I love your patch! Yet something to improve:
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on drm-tip/drm-tip]
[also build test ERROR on next-20200730]
[cannot apply to drm-exynos/exynos-drm-next drm-intel/for-linux-next tegra-drm/drm/tegra/for-next linus/master drm/drm-next v5.8-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-mgag200-Support-desktop-chips/20200730-183126 base: git://anongit.freedesktop.org/drm/drm-tip drm-tip config: parisc-allyesconfig (attached as .config) compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
drivers/gpu/drm/mgag200/mgag200_drv.c: In function 'mgag200_g200_init_refclk':
>> drivers/gpu/drm/mgag200/mgag200_drv.c:232:9: error: implicit declaration of function 'vmalloc'; did you mean 'kvmalloc'? [-Werror=implicit-function-declaration]
232 | bios = vmalloc(size);
| ^~~~~~~
| kvmalloc
>> drivers/gpu/drm/mgag200/mgag200_drv.c:232:7: warning: assignment to 'unsigned char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
232 | bios = vmalloc(size);
| ^
>> drivers/gpu/drm/mgag200/mgag200_drv.c:244:2: error: implicit declaration of function 'vfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
244 | vfree(bios);
| ^~~~~
| kvfreecc1: some warnings being treated as errors
vim +232 drivers/gpu/drm/mgag200/mgag200_drv.c
216
217 static void mgag200_g200_init_refclk(struct mga_device *mdev)
218 {
219 struct drm_device *dev = &mdev->base;
220 unsigned char __iomem *rom;
221 unsigned char *bios;
222 size_t size;
223
224 mdev->model.g200.pclk_min = 50000;
225 mdev->model.g200.pclk_max = 230000;
226 mdev->model.g200.ref_clk = 27050;
227
228 rom = pci_map_rom(dev->pdev, &size);
229 if (!rom)
230 return;
231
> 232 bios = vmalloc(size); 233 if (!bios) 234 goto out; 235 memcpy_fromio(bios, rom, size); 236 237 if (size != 0 && bios[0] == 0x55 && bios[1] == 0xaa) 238 mgag200_g200_interpret_bios(mdev, bios, size); 239 240 drm_dbg_kms(dev, "pclk_min: %ld pclk_max: %ld ref_clk: %ld\n", 241 mdev->model.g200.pclk_min, mdev->model.g200.pclk_max, 242 mdev->model.g200.ref_clk); 243 > 244 vfree(bios);
245 out:
246 pci_unmap_rom(dev->pdev, rom);
247 }
248
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org