All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio
@ 2015-04-28 12:04 Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG Jani Nikula
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

First reduce to use of the mmio global variable by switching to INREG
and OUTREG, and finally rename mmio to igt_global_mmio.

BR,
Jani.


Jani Nikula (10):
  lib: add 16 and 8 bit versions of INREG and OUTREG
  intel_reg: switch to INREG and OUTREG
  intel_backlight: switch to INREG and OUTREG
  intel_reg_checker: switch to INREG
  intel_reg_{read,write}: switch to INREG and OUTREG
  intel_watermark: switch to INREG
  intel_display_poller: use INREG and OUTREG
  intel_vga_{read,write}: use INREG and OUTREG
  tests/gen7_forcewake_mt: use local mmio variable
  rename global mmio variable to igt_global_mmio

 lib/intel_io.h               |  6 ++++-
 lib/intel_mmio.c             | 60 ++++++++++++++++++++++++++++++--------------
 tests/gen7_forcewake_mt.c    |  1 +
 tools/intel_backlight.c      | 20 ++++-----------
 tools/intel_display_poller.c |  8 +++---
 tools/intel_reg.c            | 12 ++++-----
 tools/intel_reg_checker.c    |  8 +-----
 tools/intel_reg_read.c       |  5 ++--
 tools/intel_reg_snapshot.c   |  2 +-
 tools/intel_reg_write.c      |  8 +++---
 tools/intel_vga_read.c       |  2 +-
 tools/intel_vga_write.c      |  2 +-
 tools/intel_watermark.c      |  2 +-
 13 files changed, 71 insertions(+), 65 deletions(-)

-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-05-04 15:12   ` Daniel Vetter
  2015-04-28 12:04 ` [PATCH i-g-t 02/10] intel_reg: switch to " Jani Nikula
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 lib/intel_io.h   |  4 ++++
 lib/intel_mmio.c | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 04aa3fd496b4..1c3b4445cd5b 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -43,7 +43,11 @@ void intel_register_write(uint32_t reg, uint32_t val);
 int intel_register_access_needs_fakewake(void);
 
 uint32_t INREG(uint32_t reg);
+uint16_t INREG16(uint32_t reg);
+uint8_t INREG8(uint32_t reg);
 void OUTREG(uint32_t reg, uint32_t val);
+void OUTREG16(uint32_t reg, uint16_t val);
+void OUTREG8(uint32_t reg, uint8_t val);
 
 /* sideband access functions from intel_iosf.c */
 uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 9a2ee27bd5e5..40ce94c8f600 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -324,6 +324,18 @@ uint32_t INREG(uint32_t reg)
 	return *(volatile uint32_t *)((volatile char *)mmio + reg);
 }
 
+/* 16-bit version of INREG */
+uint16_t INREG16(uint32_t reg)
+{
+	return *(volatile uint16_t *)((volatile char *)mmio + reg);
+}
+
+/* 8-bit version of INREG */
+uint8_t INREG8(uint32_t reg)
+{
+	return *((volatile uint8_t *)mmio + reg);
+}
+
 /**
  * OUTRET:
  * @reg: register offset
@@ -338,3 +350,15 @@ void OUTREG(uint32_t reg, uint32_t val)
 {
 	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
 }
+
+/* 16-bit version of OUTREG */
+void OUTREG16(uint32_t reg, uint16_t val)
+{
+	*(volatile uint16_t *)((volatile char *)mmio + reg) = val;
+}
+
+/* 8-bit version of OUTREG */
+void OUTREG8(uint32_t reg, uint8_t val)
+{
+	*((volatile uint8_t *)mmio + reg) = val;
+}
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 02/10] intel_reg: switch to INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 03/10] intel_backlight: " Jani Nikula
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_reg.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 975529d4555b..0f98266932e5 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -226,8 +226,7 @@ static int read_register(struct config *config, struct reg *reg, uint32_t *valp)
 
 	switch (reg->port_desc.port) {
 	case PORT_MMIO:
-		val = *(volatile uint32_t *)((volatile char*)mmio +
-					     reg->mmio_offset + reg->addr);
+		val = INREG(reg->mmio_offset + reg->addr);
 		break;
 	case PORT_PORTIO_VGA:
 		iopl(3);
@@ -235,7 +234,7 @@ static int read_register(struct config *config, struct reg *reg, uint32_t *valp)
 		iopl(0);
 		break;
 	case PORT_MMIO_VGA:
-		val = *((volatile uint8_t*)mmio + reg->addr);
+		val = INREG8(reg->addr);
 		break;
 	case PORT_BUNIT:
 	case PORT_PUNIT:
@@ -284,8 +283,7 @@ static int write_register(struct config *config, struct reg *reg, uint32_t val)
 
 	switch (reg->port_desc.port) {
 	case PORT_MMIO:
-		*(volatile uint32_t *)((volatile char *)mmio +
-				       reg->mmio_offset + reg->addr) = val;
+		OUTREG(reg->mmio_offset + reg->addr, val);
 		break;
 	case PORT_PORTIO_VGA:
 		if (val > 0xff) {
@@ -303,7 +301,7 @@ static int write_register(struct config *config, struct reg *reg, uint32_t val)
 				val, reg->port_desc.name);
 			return -1;
 		}
-		*((volatile uint8_t *)mmio + reg->addr) = val;
+		OUTREG8(reg->addr, val);
 		break;
 	case PORT_BUNIT:
 	case PORT_PUNIT:
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 03/10] intel_backlight: switch to INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 02/10] intel_reg: switch to " Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 04/10] intel_reg_checker: switch to INREG Jani Nikula
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_backlight.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index 17deb88d4be8..067fd4180968 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -36,24 +36,14 @@
 
 /* XXX PCH only today */
 
-static uint32_t reg_read(uint32_t reg)
-{
-	return *(volatile uint32_t *)((volatile char*)mmio + reg);
-}
-
-static void reg_write(uint32_t reg, uint32_t val)
-{
-	*(volatile uint32_t *)((volatile char*)mmio + reg) = val;
-}
-
 int main(int argc, char** argv)
 {
 	uint32_t current, max;
 
 	intel_mmio_use_pci_bar(intel_get_pci_device());
 
-	current = reg_read(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
-	max = reg_read(BLC_PWM_PCH_CTL2) >> 16;
+	current = INREG(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
+	max = INREG(BLC_PWM_PCH_CTL2) >> 16;
 
 	printf ("current backlight value: %d%%\n", current * 100 / max);
 
@@ -61,9 +51,9 @@ int main(int argc, char** argv)
 		uint32_t v = atoi (argv[1]) * max / 100;
 		if (v > max)
 			v = max;
-		reg_write(BLC_PWM_CPU_CTL,
-			  (reg_read(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
-		(void) reg_read(BLC_PWM_CPU_CTL);
+		OUTREG(BLC_PWM_CPU_CTL,
+		       (INREG(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
+		(void) INREG(BLC_PWM_CPU_CTL);
 		printf ("set backlight to %d%%\n", v * 100 / max);
 	}
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 04/10] intel_reg_checker: switch to INREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (2 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 03/10] intel_backlight: " Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 05/10] intel_reg_{read, write}: switch to INREG and OUTREG Jani Nikula
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_reg_checker.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index 22d979613ea1..2d6da70c3afa 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -32,16 +32,10 @@
 static uint32_t devid;
 static int gen;
 
-static inline uint32_t
-read_reg(uint32_t reg)
-{
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
-}
-
 static uint32_t
 read_and_print_reg(const char *name, uint32_t reg)
 {
-	uint32_t val = read_reg(reg);
+	uint32_t val = INREG(reg);
 
 	printf("%s (0x%x): 0x%08x\n", name, reg, val);
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 05/10] intel_reg_{read, write}: switch to INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (3 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 04/10] intel_reg_checker: switch to INREG Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 06/10] intel_watermark: switch to INREG Jani Nikula
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_reg_read.c  | 5 ++---
 tools/intel_reg_write.c | 8 +++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index 3b9129148878..46fa664b9085 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -51,8 +51,7 @@ static void dump_range(uint32_t start, uint32_t end)
 	int i;
 
 	for (i = start; i < end; i += 4)
-		printf("0x%X : 0x%X\n", i,
-		       *(volatile uint32_t *)((volatile char*)mmio + i));
+		printf("0x%X : 0x%X\n", i, INREG(i));
 }
 
 static void usage(char *cmdname)
@@ -130,7 +129,7 @@ int main(int argc, char** argv)
 			dump_range(reg, reg + (dwords * 4));
 
 			if (decode_bits)
-				bit_decode(*(volatile uint32_t *)((volatile char*)mmio + reg));
+				bit_decode(INREG(reg));
 		}
 	}
 
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index ff4e561ee4ab..b0ddffeb6593 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -35,7 +35,6 @@
 int main(int argc, char** argv)
 {
 	uint32_t reg, value;
-	volatile uint32_t *ptr;
 
 	if (argc < 3) {
 		printf("Usage: %s addr value\n", argv[0]);
@@ -47,11 +46,10 @@ int main(int argc, char** argv)
 	intel_register_access_init(intel_get_pci_device(), 0);
 	sscanf(argv[1], "0x%x", &reg);
 	sscanf(argv[2], "0x%x", &value);
-	ptr = (volatile uint32_t *)((volatile char *)mmio + reg);
 
-	printf("Value before: 0x%X\n", *ptr);
-	*ptr = value;
-	printf("Value after: 0x%X\n", *ptr);
+	printf("Value before: 0x%X\n", INREG(reg));
+	OUTREG(reg, value);
+	printf("Value after: 0x%X\n", INREG(reg));
 
 	intel_register_access_fini();
 	return 0;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 06/10] intel_watermark: switch to INREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (4 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 05/10] intel_reg_{read, write}: switch to INREG and OUTREG Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 07/10] intel_display_poller: use INREG and OUTREG Jani Nikula
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_watermark.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/intel_watermark.c b/tools/intel_watermark.c
index e5dee46db78f..0b7c5e5193ef 100644
--- a/tools/intel_watermark.c
+++ b/tools/intel_watermark.c
@@ -38,7 +38,7 @@ static uint32_t devid;
 
 static uint32_t read_reg(uint32_t addr)
 {
-	return *(volatile uint32_t *)((volatile char*)mmio + display_base + addr);
+	return INREG(display_base + addr);
 }
 
 struct gmch_wm {
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 07/10] intel_display_poller: use INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (5 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 06/10] intel_watermark: switch to INREG Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 08/10] intel_vga_{read, write}: " Jani Nikula
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_display_poller.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/intel_display_poller.c b/tools/intel_display_poller.c
index 2eab6c494f68..6d6ea21ca974 100644
--- a/tools/intel_display_poller.c
+++ b/tools/intel_display_poller.c
@@ -67,22 +67,22 @@ static void sighandler(int x)
 
 static uint16_t read_reg_16(uint32_t reg)
 {
-	return *(volatile uint16_t *)((volatile char*)mmio + vlv_offset + reg);
+	return INREG16(vlv_offset + reg);
 }
 
 static uint32_t read_reg(uint32_t reg)
 {
-	return *(volatile uint32_t *)((volatile char*)mmio + vlv_offset + reg);
+	return INREG(vlv_offset + reg);
 }
 
 static void write_reg_16(uint32_t reg, uint16_t val)
 {
-	*(volatile uint16_t *)((volatile char*)mmio + vlv_offset + reg) = val;
+	OUTREG16(vlv_offset + reg, val);
 }
 
 static void write_reg(uint32_t reg, uint32_t val)
 {
-	*(volatile uint32_t *)((volatile char*)mmio + vlv_offset + reg) = val;
+	OUTREG(vlv_offset + reg, val);
 }
 
 static int pipe_to_plane(uint32_t devid, int pipe)
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 08/10] intel_vga_{read, write}: use INREG and OUTREG
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (6 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 07/10] intel_display_poller: use INREG and OUTREG Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 09/10] tests/gen7_forcewake_mt: use local mmio variable Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 10/10] rename global mmio variable to igt_global_mmio Jani Nikula
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_vga_read.c  | 2 +-
 tools/intel_vga_write.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c
index e635c59cda3b..ea5070577a1e 100644
--- a/tools/intel_vga_read.c
+++ b/tools/intel_vga_read.c
@@ -37,7 +37,7 @@
 static uint8_t read_reg(uint32_t reg, bool use_mmio)
 {
 	if (use_mmio)
-		return *((volatile uint8_t *)mmio + reg);
+		return INREG8(reg);
 	else
 		return inb(reg);
 }
diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c
index 4fb09d6a247a..821596246a2a 100644
--- a/tools/intel_vga_write.c
+++ b/tools/intel_vga_write.c
@@ -37,7 +37,7 @@
 static void write_reg(uint32_t reg, uint8_t val, bool use_mmio)
 {
 	if (use_mmio)
-		*((volatile uint8_t *)mmio + reg) = val;
+		OUTREG8(reg, val);
 	else
 		outb(val, reg);
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 09/10] tests/gen7_forcewake_mt: use local mmio variable
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (7 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 08/10] intel_vga_{read, write}: " Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  2015-04-28 12:04 ` [PATCH i-g-t 10/10] rename global mmio variable to igt_global_mmio Jani Nikula
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

igfx_get_mmio() uses the global mmio variable by accident. Use a local
variable instead.

The intention is to rename the global variable later on, so shadowing it
here does not matter.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tests/gen7_forcewake_mt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index 8337847c41d5..78730787150a 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -88,6 +88,7 @@ static struct pci_device *__igfx_get(void)
 static void *igfx_get_mmio(void)
 {
 	struct pci_device *pci = __igfx_get();
+	void *mmio = NULL;
 	int error;
 
 	igt_skip_on(pci == NULL);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH i-g-t 10/10] rename global mmio variable to igt_global_mmio
  2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
                   ` (8 preceding siblings ...)
  2015-04-28 12:04 ` [PATCH i-g-t 09/10] tests/gen7_forcewake_mt: use local mmio variable Jani Nikula
@ 2015-04-28 12:04 ` Jani Nikula
  9 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-04-28 12:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Global variable names should reflect the fact that they are indeed
global, and at the very least they should not be as short as just
"mmio". Rename mmio to igt_global_mmio.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 lib/intel_io.h             |  2 +-
 lib/intel_mmio.c           | 44 +++++++++++++++++++++-----------------------
 tools/intel_reg.c          |  2 +-
 tools/intel_reg_snapshot.c |  2 +-
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 1c3b4445cd5b..e2d6b4705be3 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -32,7 +32,7 @@
 #include <pciaccess.h>
 
 /* register access helpers from intel_mmio.c */
-extern void *mmio;
+extern void *igt_global_mmio;
 void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
 void intel_mmio_use_dump_file(char *file);
 
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 40ce94c8f600..3a7631417df7 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -69,7 +69,7 @@
  *
  * Pointer to the register range. It is not recommended to use this directly.
  */
-void *mmio;
+void *igt_global_mmio;
 
 static struct _mmio_data {
 	int inited;
@@ -83,9 +83,9 @@ static struct _mmio_data {
  * intel_mmio_use_dump_file:
  * @file: name of the register dump file to open
  *
- * Sets up #mmio to point at the data contained in @file. This allows the same
- * code to get reused for dumping and decoding from running hardware as from
- * register dumps.
+ * Sets up #igt_global_mmio to point at the data contained in @file. This allows
+ * the same code to get reused for dumping and decoding from running hardware as
+ * from register dumps.
  */
 void
 intel_mmio_use_dump_file(char *file)
@@ -98,8 +98,8 @@ intel_mmio_use_dump_file(char *file)
 		      "Couldn't open %s\n", file);
 
 	fstat(fd, &st);
-	mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-	igt_fail_on_f(mmio == MAP_FAILED,
+	igt_global_mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+	igt_fail_on_f(igt_global_mmio == MAP_FAILED,
 		      "Couldn't mmap %s\n", file);
 	close(fd);
 }
@@ -108,9 +108,7 @@ intel_mmio_use_dump_file(char *file)
  * intel_mmio_use_pci_bar:
  * @pci_dev: intel gracphis pci device
  *
- * Sets up #mmio to point at the data contained in @file. This allows the same
- * code to get reused for dumping and decoding from running hardware as from
- * register dumps.
+ * Sets up #igt_global_mmio to point at the mmio bar.
  *
  * @pci_dev can be obtained from intel_get_pci_device().
  */
@@ -139,7 +137,7 @@ intel_mmio_use_pci_bar(struct pci_device *pci_dev)
 				      pci_dev->regions[mmio_bar].base_addr,
 				      mmio_size,
 				      PCI_DEV_MAP_FLAG_WRITABLE,
-				      &mmio);
+				      &igt_global_mmio);
 
 	igt_fail_on_f(error != 0,
 		      "Couldn't map MMIO region\n");
@@ -160,7 +158,7 @@ release_forcewake_lock(int fd)
  * handling and also allows register access to be checked with an explicit
  * whitelist.
  *
- * It also initializes #mmio like intel_mmio_use_pci_bar().
+ * It also initializes #igt_global_mmio like intel_mmio_use_pci_bar().
  *
  * @pci_dev can be obtained from intel_get_pci_device().
  */
@@ -170,10 +168,10 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
 	int ret;
 
 	/* after old API is deprecated, remove this */
-	if (mmio == NULL)
+	if (igt_global_mmio == NULL)
 		intel_mmio_use_pci_bar(pci_dev);
 
-	igt_assert(mmio != NULL);
+	igt_assert(igt_global_mmio != NULL);
 
 	if (mmio_data.inited)
 		return -1;
@@ -266,7 +264,7 @@ intel_register_read(uint32_t reg)
 	}
 
 read_out:
-	ret = *(volatile uint32_t *)((volatile char *)mmio + reg);
+	ret = *(volatile uint32_t *)((volatile char *)igt_global_mmio + reg);
 out:
 	return ret;
 }
@@ -303,7 +301,7 @@ intel_register_write(uint32_t reg, uint32_t val)
 		      "Register write blocked for safety ""(*0x%08x = 0x%x)\n", reg, val);
 
 write_out:
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint32_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 
@@ -314,26 +312,26 @@ write_out:
  * 32-bit read of the register at @offset. This function only works when the new
  * register access helper is initialized with intel_register_access_init().
  *
- * This function directly accesses the #mmio without safety checks.
+ * This function directly accesses the #igt_global_mmio without safety checks.
  *
  * Returns:
  * The value read from the register.
  */
 uint32_t INREG(uint32_t reg)
 {
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
+	return *(volatile uint32_t *)((volatile char *)igt_global_mmio + reg);
 }
 
 /* 16-bit version of INREG */
 uint16_t INREG16(uint32_t reg)
 {
-	return *(volatile uint16_t *)((volatile char *)mmio + reg);
+	return *(volatile uint16_t *)((volatile char *)igt_global_mmio + reg);
 }
 
 /* 8-bit version of INREG */
 uint8_t INREG8(uint32_t reg)
 {
-	return *((volatile uint8_t *)mmio + reg);
+	return *((volatile uint8_t *)igt_global_mmio + reg);
 }
 
 /**
@@ -344,21 +342,21 @@ uint8_t INREG8(uint32_t reg)
  * 32-bit write to the register at @offset. This function only works when the new
  * register access helper is initialized with intel_register_access_init().
  *
- * This function directly accesses the #mmio without safety checks.
+ * This function directly accesses the #igt_global_mmio without safety checks.
  */
 void OUTREG(uint32_t reg, uint32_t val)
 {
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint32_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 /* 16-bit version of OUTREG */
 void OUTREG16(uint32_t reg, uint16_t val)
 {
-	*(volatile uint16_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint16_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 /* 8-bit version of OUTREG */
 void OUTREG8(uint32_t reg, uint8_t val)
 {
-	*((volatile uint8_t *)mmio + reg) = val;
+	*((volatile uint8_t *)igt_global_mmio + reg) = val;
 }
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 0f98266932e5..090cc25613b9 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -491,7 +491,7 @@ static int intel_reg_snapshot(struct config *config, int argc, char *argv[])
 	intel_mmio_use_pci_bar(config->pci_dev);
 
 	/* XXX: error handling */
-	write(1, mmio, config->pci_dev->regions[mmio_bar].size);
+	write(1, igt_global_mmio, config->pci_dev->regions[mmio_bar].size);
 
 	if (config->verbosity > 0)
 		printf("use this with --mmio=FILE --devid=0x%04X\n",
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index b756bf690217..50dafd6a6ac4 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -45,7 +45,7 @@ int main(int argc, char** argv)
 	else
 		mmio_bar = 0;
 
-	ret = write(1, mmio, pci_dev->regions[mmio_bar].size);
+	ret = write(1, igt_global_mmio, pci_dev->regions[mmio_bar].size);
 	assert(ret > 0);
 
 	return 0;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG
  2015-04-28 12:04 ` [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG Jani Nikula
@ 2015-05-04 15:12   ` Daniel Vetter
  2015-05-05 10:18     ` Jani Nikula
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel Vetter @ 2015-05-04 15:12 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Tue, Apr 28, 2015 at 03:04:26PM +0300, Jani Nikula wrote:
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  lib/intel_io.h   |  4 ++++
>  lib/intel_mmio.c | 24 ++++++++++++++++++++++++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/lib/intel_io.h b/lib/intel_io.h
> index 04aa3fd496b4..1c3b4445cd5b 100644
> --- a/lib/intel_io.h
> +++ b/lib/intel_io.h
> @@ -43,7 +43,11 @@ void intel_register_write(uint32_t reg, uint32_t val);
>  int intel_register_access_needs_fakewake(void);
>  
>  uint32_t INREG(uint32_t reg);
> +uint16_t INREG16(uint32_t reg);
> +uint8_t INREG8(uint32_t reg);
>  void OUTREG(uint32_t reg, uint32_t val);
> +void OUTREG16(uint32_t reg, uint16_t val);
> +void OUTREG8(uint32_t reg, uint8_t val);
>  
>  /* sideband access functions from intel_iosf.c */
>  uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
> diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
> index 9a2ee27bd5e5..40ce94c8f600 100644
> --- a/lib/intel_mmio.c
> +++ b/lib/intel_mmio.c
> @@ -324,6 +324,18 @@ uint32_t INREG(uint32_t reg)
>  	return *(volatile uint32_t *)((volatile char *)mmio + reg);
>  }
>  
> +/* 16-bit version of INREG */

gtkdoc is missing here for these new functions. And while at it please
also do the s/OUTRET/OUTREG/ type ;-)

Otherise entire series looks really nifty and has my Ack.

Cheers, Daniel

> +uint16_t INREG16(uint32_t reg)
> +{
> +	return *(volatile uint16_t *)((volatile char *)mmio + reg);
> +}
> +
> +/* 8-bit version of INREG */
> +uint8_t INREG8(uint32_t reg)
> +{
> +	return *((volatile uint8_t *)mmio + reg);
> +}
> +
>  /**
>   * OUTRET:
>   * @reg: register offset
> @@ -338,3 +350,15 @@ void OUTREG(uint32_t reg, uint32_t val)
>  {
>  	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
>  }
> +
> +/* 16-bit version of OUTREG */
> +void OUTREG16(uint32_t reg, uint16_t val)
> +{
> +	*(volatile uint16_t *)((volatile char *)mmio + reg) = val;
> +}
> +
> +/* 8-bit version of OUTREG */
> +void OUTREG8(uint32_t reg, uint8_t val)
> +{
> +	*((volatile uint8_t *)mmio + reg) = val;
> +}
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG
  2015-05-04 15:12   ` Daniel Vetter
@ 2015-05-05 10:18     ` Jani Nikula
  0 siblings, 0 replies; 13+ messages in thread
From: Jani Nikula @ 2015-05-05 10:18 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

On Mon, 04 May 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, Apr 28, 2015 at 03:04:26PM +0300, Jani Nikula wrote:
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  lib/intel_io.h   |  4 ++++
>>  lib/intel_mmio.c | 24 ++++++++++++++++++++++++
>>  2 files changed, 28 insertions(+)
>> 
>> diff --git a/lib/intel_io.h b/lib/intel_io.h
>> index 04aa3fd496b4..1c3b4445cd5b 100644
>> --- a/lib/intel_io.h
>> +++ b/lib/intel_io.h
>> @@ -43,7 +43,11 @@ void intel_register_write(uint32_t reg, uint32_t val);
>>  int intel_register_access_needs_fakewake(void);
>>  
>>  uint32_t INREG(uint32_t reg);
>> +uint16_t INREG16(uint32_t reg);
>> +uint8_t INREG8(uint32_t reg);
>>  void OUTREG(uint32_t reg, uint32_t val);
>> +void OUTREG16(uint32_t reg, uint16_t val);
>> +void OUTREG8(uint32_t reg, uint8_t val);
>>  
>>  /* sideband access functions from intel_iosf.c */
>>  uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
>> diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
>> index 9a2ee27bd5e5..40ce94c8f600 100644
>> --- a/lib/intel_mmio.c
>> +++ b/lib/intel_mmio.c
>> @@ -324,6 +324,18 @@ uint32_t INREG(uint32_t reg)
>>  	return *(volatile uint32_t *)((volatile char *)mmio + reg);
>>  }
>>  
>> +/* 16-bit version of INREG */
>
> gtkdoc is missing here for these new functions. And while at it please
> also do the s/OUTRET/OUTREG/ type ;-)
>
> Otherise entire series looks really nifty and has my Ack.

Fixed and pushed the series.

Jani.


>
> Cheers, Daniel
>
>> +uint16_t INREG16(uint32_t reg)
>> +{
>> +	return *(volatile uint16_t *)((volatile char *)mmio + reg);
>> +}
>> +
>> +/* 8-bit version of INREG */
>> +uint8_t INREG8(uint32_t reg)
>> +{
>> +	return *((volatile uint8_t *)mmio + reg);
>> +}
>> +
>>  /**
>>   * OUTRET:
>>   * @reg: register offset
>> @@ -338,3 +350,15 @@ void OUTREG(uint32_t reg, uint32_t val)
>>  {
>>  	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
>>  }
>> +
>> +/* 16-bit version of OUTREG */
>> +void OUTREG16(uint32_t reg, uint16_t val)
>> +{
>> +	*(volatile uint16_t *)((volatile char *)mmio + reg) = val;
>> +}
>> +
>> +/* 8-bit version of OUTREG */
>> +void OUTREG8(uint32_t reg, uint8_t val)
>> +{
>> +	*((volatile uint8_t *)mmio + reg) = val;
>> +}
>> -- 
>> 2.1.4
>> 
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-05-05 10:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 12:04 [PATCH i-g-t 00/10] rename mmio global variable to igt_global_mmio Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 01/10] lib: add 16 and 8 bit versions of INREG and OUTREG Jani Nikula
2015-05-04 15:12   ` Daniel Vetter
2015-05-05 10:18     ` Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 02/10] intel_reg: switch to " Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 03/10] intel_backlight: " Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 04/10] intel_reg_checker: switch to INREG Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 05/10] intel_reg_{read, write}: switch to INREG and OUTREG Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 06/10] intel_watermark: switch to INREG Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 07/10] intel_display_poller: use INREG and OUTREG Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 08/10] intel_vga_{read, write}: " Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 09/10] tests/gen7_forcewake_mt: use local mmio variable Jani Nikula
2015-04-28 12:04 ` [PATCH i-g-t 10/10] rename global mmio variable to igt_global_mmio Jani Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.