All of lore.kernel.org
 help / color / mirror / Atom feed
* PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
@ 2022-12-04  3:06 Zopolis0
  2022-12-04  3:32 ` Randy Dunlap
  2022-12-04  3:36 ` Al Viro
  0 siblings, 2 replies; 10+ messages in thread
From: Zopolis0 @ 2022-12-04  3:06 UTC (permalink / raw)
  To: linux-kernel

----NOT PART OF PATCH----
I'm sending this to the open mailing list because get_maintainer.pl
couldn't come up with anything better.

Anyways, just upstreaming
https://github.com/Zopolis4/gc-linux/commit/e6829693235dda1c494737e28542de2711ce0055,
with the second fix to come.

I've left the commits intact, as they were already signed off. If
there were bug fixes, I would have sent them as an additional patch,
which I will probably do for the other patches to upstream.

These patches don't depend on any other patches that need to be
upstreamed, unlike many of the other gc-linux patches.
----NOT PART OF PATCH----

From 7c625cb05dd90f29ce310c598dc84a195ca52b9f Mon Sep 17 00:00:00 2001
From: Albert Herranz <albert_herranz@yahoo.es>
Date: Thu, 22 Jan 2009 20:31:39 +0100
Subject: [PATCH 1/2] gamecube/wii: graphic quantization registers driver (GQR)

Add support for accessing the Graphic Quantization Registers of the
Nintendo GameCube and Wii video game consoles PowerPC processor via
the proc filesystem.

The Graphic Quantization Registers can be used to influence how the
psql* and psqst* instructions operate.

Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
---
 drivers/misc/Kconfig   |   9 +++
 drivers/misc/Makefile  |   1 +
 drivers/misc/gcn-gqr.c | 129 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 drivers/misc/gcn-gqr.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 358ad56f6524..83525024c5ee 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -57,6 +57,15 @@ config DUMMY_IRQ
    The sole purpose of this module is to help with debugging of systems on
    which spurious IRQs would happen on disabled IRQ vector.

+config GAMECUBE_GQR
+ tristate "Nintendo GameCube/Wii Graphic Quantization Registers (GQR)"
+ depends on GAMECUBE_COMMON
+ help
+          This option enables device driver support for the Gekko/Broadway
+   processors' Graphic Quantization Registers.
+   These registers are used with the psql and psqst instructions.
+   The registers will appear in /proc/sys/gqr.
+
 config IBM_ASM
  tristate "Device driver for IBM RSA service processor"
  depends on X86 && PCI && INPUT
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index ac9b3e757ba1..cebdac81a336 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
 obj-$(CONFIG_DS1682) += ds1682.o
 obj-$(CONFIG_C2PORT) += c2port/
 obj-$(CONFIG_HMC6352) += hmc6352.o
+obj-$(CONFIG_GAMECUBE_GQR) += gcn-gqr.o
 obj-y += eeprom/
 obj-y += cb710/
 obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
diff --git a/drivers/misc/gcn-gqr.c b/drivers/misc/gcn-gqr.c
new file mode 100644
index 000000000000..66482653f8ef
--- /dev/null
+++ b/drivers/misc/gcn-gqr.c
@@ -0,0 +1,129 @@
+/*
+ * drivers/misc/gcn-gqr.c
+ *
+ * Nintendo GameCube GQR driver
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2004 Todd Jeffreys <todd@voidpointer.org>
+ * Copyright (C) 2007,2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/ctype.h>
+#include <linux/sysctl.h>
+#include <linux/types.h>
+#include <linux/uaccess.h>
+
+static u32 gqr_values[8];
+static struct ctl_table_header *gqr_table_header;
+
+#define SPR_GQR0 912
+#define SPR_GQR1 913
+#define SPR_GQR2 914
+#define SPR_GQR3 915
+#define SPR_GQR4 916
+#define SPR_GQR5 917
+#define SPR_GQR6 918
+#define SPR_GQR7 919
+
+#define MFSPR_CASE(i) case (i): (*((u32 *)table->data) = mfspr(SPR_GQR##i))
+#define MTSPR_CASE(i) case (i): mtspr(SPR_GQR##i, *((u32 *)table->data))
+
+static int proc_dogqr(ctl_table *table, int write, struct file *file,
+       void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ int r;
+
+ if (!write) { /* if they are reading, update the variable */
+ switch (table->data - (void *)gqr_values) {
+ MFSPR_CASE(0); break;
+ MFSPR_CASE(1); break;
+ MFSPR_CASE(2); break;
+ MFSPR_CASE(3); break;
+ MFSPR_CASE(4); break;
+ MFSPR_CASE(5); break;
+ MFSPR_CASE(6); break;
+ MFSPR_CASE(7); break;
+ default:
+ return -EFAULT; /* shouldn't happen */
+ }
+ }
+
+ r = proc_dointvec(table, write, file, buffer, lenp, ppos);
+
+ if ((r == 0) && write) {  /* if they are writing, update the reg */
+ switch (table->data - (void *)gqr_values) {
+ MTSPR_CASE(0); break;
+ MTSPR_CASE(1); break;
+ MTSPR_CASE(2); break;
+ MTSPR_CASE(3); break;
+ MTSPR_CASE(4); break;
+ MTSPR_CASE(5); break;
+ MTSPR_CASE(6); break;
+ MTSPR_CASE(7); break;
+ default:
+ return -EFAULT; /* shouldn't happen */
+ }
+ }
+
+ return r;
+}
+
+#define DECLARE_GQR(i) {  \
+ .ctl_name     = CTL_UNNUMBERED,       \
+ .procname     = "gqr" #i,         \
+ .data         = gqr_values + i,   \
+ .maxlen       = sizeof(int),      \
+ .mode         = 0644,             \
+ .proc_handler = &proc_dogqr       \
+ }
+
+static ctl_table gqr_members[] = {
+ DECLARE_GQR(0),
+ DECLARE_GQR(1),
+ DECLARE_GQR(2),
+ DECLARE_GQR(3),
+ DECLARE_GQR(4),
+ DECLARE_GQR(5),
+ DECLARE_GQR(6),
+ DECLARE_GQR(7),
+ { .ctl_name = 0 }
+};
+
+static ctl_table gqr_table[] = {
+ {
+ .ctl_name = CTL_UNNUMBERED,
+ .procname = "gqr",
+ .mode     = 0555,
+ .child    = gqr_members,
+ },
+ { .ctl_name = 0 }
+};
+
+int __init gcngqr_init(void)
+{
+ gqr_table_header = register_sysctl_table(gqr_table);
+ if (!gqr_table_header) {
+ printk(KERN_ERR "Unable to register GQR sysctl table\n");
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+void __exit gcngqr_exit(void)
+{
+ unregister_sysctl_table(gqr_table_header);
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Todd Jeffreys <todd@voidpointer.org>");
+module_init(gcngqr_init);
+module_exit(gcngqr_exit);
-- 
2.38.1

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-04  3:06 PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR) Zopolis0
@ 2022-12-04  3:32 ` Randy Dunlap
  2022-12-05 22:14   ` Zopolis0
  2022-12-05 22:15   ` Zopolis0
  2022-12-04  3:36 ` Al Viro
  1 sibling, 2 replies; 10+ messages in thread
From: Randy Dunlap @ 2022-12-04  3:32 UTC (permalink / raw)
  To: Zopolis0, linux-kernel

Hi--

On 12/3/22 19:06, Zopolis0 wrote:
> ----NOT PART OF PATCH----
> I'm sending this to the open mailing list because get_maintainer.pl
> couldn't come up with anything better.
> 

MAINTAINTERS file:

CHAR and MISC DRIVERS
M:	Arnd Bergmann <arnd@arndb.de>
M:	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
S:	Supported
F:	drivers/char/
F:	drivers/misc/


> Anyways, just upstreaming
> https://github.com/Zopolis4/gc-linux/commit/e6829693235dda1c494737e28542de2711ce0055,
> with the second fix to come.
> 
> I've left the commits intact, as they were already signed off. If
> there were bug fixes, I would have sent them as an additional patch,
> which I will probably do for the other patches to upstream.

Please read Documentation/process/submitting-patches.rst.
Search for "Signed-off-by:".

Most relevant:

Any further SoBs (Signed-off-by:'s) following the author's SoB are from
people handling and transporting the patch, but were not involved in its
development. SoB chains should reflect the **real** route a patch took
as it was propagated to the maintainers and ultimately to Linus, with
the first SoB entry signalling primary authorship of a single author.

and

The Signed-off-by: tag indicates that the signer was involved in the
development of the patch, or that he/she was in the patch's delivery path.


and lastly, gmail has (apparently) munged the whitespace in the patch
so that it is awful... or it was never done correctly if gmail didn't
munge it.

> These patches don't depend on any other patches that need to be
> upstreamed, unlike many of the other gc-linux patches.
> ----NOT PART OF PATCH----
> 
> From 7c625cb05dd90f29ce310c598dc84a195ca52b9f Mon Sep 17 00:00:00 2001
> From: Albert Herranz <albert_herranz@yahoo.es>
> Date: Thu, 22 Jan 2009 20:31:39 +0100
> Subject: [PATCH 1/2] gamecube/wii: graphic quantization registers driver (GQR)
> 
> Add support for accessing the Graphic Quantization Registers of the
> Nintendo GameCube and Wii video game consoles PowerPC processor via
> the proc filesystem.
> 
> The Graphic Quantization Registers can be used to influence how the
> psql* and psqst* instructions operate.
> 
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
> ---
>  drivers/misc/Kconfig   |   9 +++
>  drivers/misc/Makefile  |   1 +
>  drivers/misc/gcn-gqr.c | 129 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 139 insertions(+)
>  create mode 100644 drivers/misc/gcn-gqr.c
> 
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 358ad56f6524..83525024c5ee 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -57,6 +57,15 @@ config DUMMY_IRQ
>     The sole purpose of this module is to help with debugging of systems on
>     which spurious IRQs would happen on disabled IRQ vector.
> 
> +config GAMECUBE_GQR
> + tristate "Nintendo GameCube/Wii Graphic Quantization Registers (GQR)"
> + depends on GAMECUBE_COMMON
> + help
> +          This option enables device driver support for the Gekko/Broadway
> +   processors' Graphic Quantization Registers.
> +   These registers are used with the psql and psqst instructions.
> +   The registers will appear in /proc/sys/gqr.
> +
>  config IBM_ASM
>   tristate "Device driver for IBM RSA service processor"
>   depends on X86 && PCI && INPUT
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index ac9b3e757ba1..cebdac81a336 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -33,6 +33,7 @@ obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
>  obj-$(CONFIG_DS1682) += ds1682.o
>  obj-$(CONFIG_C2PORT) += c2port/
>  obj-$(CONFIG_HMC6352) += hmc6352.o
> +obj-$(CONFIG_GAMECUBE_GQR) += gcn-gqr.o
>  obj-y += eeprom/
>  obj-y += cb710/
>  obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
> diff --git a/drivers/misc/gcn-gqr.c b/drivers/misc/gcn-gqr.c
> new file mode 100644
> index 000000000000..66482653f8ef
> --- /dev/null
> +++ b/drivers/misc/gcn-gqr.c
> @@ -0,0 +1,129 @@
> +/*
> + * drivers/misc/gcn-gqr.c
> + *
> + * Nintendo GameCube GQR driver
> + * Copyright (C) 2004-2009 The GameCube Linux Team
> + * Copyright (C) 2004 Todd Jeffreys <todd@voidpointer.org>
> + * Copyright (C) 2007,2008,2009 Albert Herranz
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + */

Preferably just use an SPDX-License-Identifier line above.

-- 
~Randy

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-04  3:06 PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR) Zopolis0
  2022-12-04  3:32 ` Randy Dunlap
@ 2022-12-04  3:36 ` Al Viro
  1 sibling, 0 replies; 10+ messages in thread
From: Al Viro @ 2022-12-04  3:36 UTC (permalink / raw)
  To: Zopolis0; +Cc: linux-kernel

On Sun, Dec 04, 2022 at 02:06:06PM +1100, Zopolis0 wrote:

> +static u32 gqr_values[8];
> +static struct ctl_table_header *gqr_table_header;
> +
> +#define SPR_GQR0 912
> +#define SPR_GQR1 913
> +#define SPR_GQR2 914
> +#define SPR_GQR3 915
> +#define SPR_GQR4 916
> +#define SPR_GQR5 917
> +#define SPR_GQR6 918
> +#define SPR_GQR7 919
> +
> +#define MFSPR_CASE(i) case (i): (*((u32 *)table->data) = mfspr(SPR_GQR##i))
> +#define MTSPR_CASE(i) case (i): mtspr(SPR_GQR##i, *((u32 *)table->data))
> +
> +static int proc_dogqr(ctl_table *table, int write, struct file *file,
> +       void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + int r;
> +
> + if (!write) { /* if they are reading, update the variable */
> + switch (table->data - (void *)gqr_values) {

That looks very fishy.  First of all, you clearly have table->data set
(by DECLARE_GQR below) to gqr_values + <interger from 0 to 7>.  Trivial
C quiz: what would the value of
	(void *)(gqr_values + 7) - (void *)gqr_values
be, if gqr_values is declared as an array of unsigned int?

	IOW, the values in that switch are wrong.  If anything,
you want (u32 *)table->data - gqr_values.  What's more, SPR_GQR<n>
is simply 912 + n, innit?  So all the crap with switches and ##
is pointless - that thing should simply be

	unsigned reg = (u32 *)table->data - gqr_values;
	
	if (WARN_ON_ONCE(reg > 7))
		return -EINVAL;

	if (!write)
		gqr_values[reg] = mfspr(SPR_GQR0 + reg);

	r = proc_dointvec(table, write, buffer, lenp, ppos);

	if (!r && write) /* if they are writing, update the reg */
		mtspr(SPR_GQR0 + reg, gqr_values[reg]);

	return r;

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-04  3:32 ` Randy Dunlap
@ 2022-12-05 22:14   ` Zopolis0
  2022-12-05 22:56     ` Randy Dunlap
  2022-12-05 22:15   ` Zopolis0
  1 sibling, 1 reply; 10+ messages in thread
From: Zopolis0 @ 2022-12-05 22:14 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

> MAINTAINTERS file:

> CHAR and MISC DRIVERS
> M:      Arnd Bergmann <arnd@arndb.de>
> M:      Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> S:      Supported
> F:      drivers/char/
> F:      drivers/misc/

Should I re-send the patches to those then?

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-04  3:32 ` Randy Dunlap
  2022-12-05 22:14   ` Zopolis0
@ 2022-12-05 22:15   ` Zopolis0
  2022-12-05 23:01     ` Randy Dunlap
  1 sibling, 1 reply; 10+ messages in thread
From: Zopolis0 @ 2022-12-05 22:15 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

> and lastly, gmail has (apparently) munged the whitespace in the patch
> so that it is awful... or it was never done correctly if gmail didn't
> munge it.

In that case, would it be acceptable to send the patches as attatchements?

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-05 22:14   ` Zopolis0
@ 2022-12-05 22:56     ` Randy Dunlap
  0 siblings, 0 replies; 10+ messages in thread
From: Randy Dunlap @ 2022-12-05 22:56 UTC (permalink / raw)
  To: Zopolis0; +Cc: linux-kernel



On 12/5/22 14:14, Zopolis0 wrote:
>> MAINTAINTERS file:
> 
>> CHAR and MISC DRIVERS
>> M:      Arnd Bergmann <arnd@arndb.de>
>> M:      Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> S:      Supported
>> F:      drivers/char/
>> F:      drivers/misc/
> 
> Should I re-send the patches to those then?

Probably. I would.

-- 
~Randy

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-05 22:15   ` Zopolis0
@ 2022-12-05 23:01     ` Randy Dunlap
  2022-12-06  5:20       ` Zopolis0
  0 siblings, 1 reply; 10+ messages in thread
From: Randy Dunlap @ 2022-12-05 23:01 UTC (permalink / raw)
  To: Zopolis0; +Cc: linux-kernel



On 12/5/22 14:15, Zopolis0 wrote:
>> and lastly, gmail has (apparently) munged the whitespace in the patch
>> so that it is awful... or it was never done correctly if gmail didn't
>> munge it.
> 
> In that case, would it be acceptable to send the patches as attatchements?

The maintainers could just ignore it or reply to it that it should be
posted inline so that it can be reviewed and commented on.
It's up to them.

Other (better) options are to use an email account/interface
that does not corrupt whitespace OR use 'git send-email' (which
does not require that you be using 'git').

-- 
~Randy

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-05 23:01     ` Randy Dunlap
@ 2022-12-06  5:20       ` Zopolis0
  2022-12-06  5:36         ` Randy Dunlap
  0 siblings, 1 reply; 10+ messages in thread
From: Zopolis0 @ 2022-12-06  5:20 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

> Other (better) options are to use an email account/interface
> that does not corrupt whitespace OR use 'git send-email' (which
> does not require that you be using 'git').

Git send-email doesn't work with gmail anymore, and I've never had any
whitespace troubles with gmail inline patches in the past.

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-06  5:20       ` Zopolis0
@ 2022-12-06  5:36         ` Randy Dunlap
  2022-12-06  6:01           ` Zopolis0
  0 siblings, 1 reply; 10+ messages in thread
From: Randy Dunlap @ 2022-12-06  5:36 UTC (permalink / raw)
  To: Zopolis0; +Cc: linux-kernel



On 12/5/22 21:20, Zopolis0 wrote:
>> Other (better) options are to use an email account/interface
>> that does not corrupt whitespace OR use 'git send-email' (which
>> does not require that you be using 'git').
> 
> Git send-email doesn't work with gmail anymore, and I've never had any
> whitespace troubles with gmail inline patches in the past.

(for the latter part:) Do you mean when using the gmail web UI?
I've never seen that protect whitespace correctly.

-- 
~Randy

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

* Re: PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR)
  2022-12-06  5:36         ` Randy Dunlap
@ 2022-12-06  6:01           ` Zopolis0
  0 siblings, 0 replies; 10+ messages in thread
From: Zopolis0 @ 2022-12-06  6:01 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

> (for the latter part:) Do you mean when using the gmail web UI?
> I've never seen that protect whitespace correctly.

Web, yeah, using plain text mode. It doesn't work on mobile though.

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

end of thread, other threads:[~2022-12-06  6:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-04  3:06 PATCH [1/2] gamecube/wii: graphic quantization registers driver (GQR) Zopolis0
2022-12-04  3:32 ` Randy Dunlap
2022-12-05 22:14   ` Zopolis0
2022-12-05 22:56     ` Randy Dunlap
2022-12-05 22:15   ` Zopolis0
2022-12-05 23:01     ` Randy Dunlap
2022-12-06  5:20       ` Zopolis0
2022-12-06  5:36         ` Randy Dunlap
2022-12-06  6:01           ` Zopolis0
2022-12-04  3:36 ` Al Viro

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.