Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 4/5] HID: amd_sfh: Remove duplicate cleanup for SFH1.1
From: Basavaraj Natikar @ 2023-05-09  6:58 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, linux-input; +Cc: Basavaraj Natikar
In-Reply-To: <20230509065857.4170013-1-Basavaraj.Natikar@amd.com>

A duplicate cleanup is performed that is not necessary. As a result,
remove duplicate cleanup and use common cleanup.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
index bb8bd7892b67..2102d53bd51f 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
@@ -174,20 +174,8 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 			cl_data->is_any_sensor_enabled = true;
 			cl_data->sensor_sts[i] = SENSOR_ENABLED;
 			rc = amdtp_hid_probe(i, cl_data);
-			if (rc) {
-				mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
-				status = amd_sfh_wait_for_response
-					(privdata, cl_data->sensor_idx[i], DISABLE_SENSOR);
-				if (status == 0)
-					status = SENSOR_DISABLED;
-				if (status != SENSOR_ENABLED)
-					cl_data->sensor_sts[i] = SENSOR_DISABLED;
-				dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
-					cl_data->sensor_idx[i],
-					get_sensor_name(cl_data->sensor_idx[i]),
-					cl_data->sensor_sts[i]);
+			if (rc)
 				goto cleanup;
-			}
 		} else {
 			cl_data->sensor_sts[i] = SENSOR_DISABLED;
 		}
-- 
2.25.1


^ permalink raw reply related

* [PATCH 0/5] cleanups to amd-sfh
From: Basavaraj Natikar @ 2023-05-09  6:58 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, linux-input; +Cc: Basavaraj Natikar

Changes of code cleanup includes duplicate log removal, cleanup
sequence and spliting into multiple functional blocks.

Basavaraj Natikar (5):
  HID: amd_sfh: Remove unnecessary log
  HID: amd_sfh: Remove duplicate cleanup
  HID: amd_sfh: Split sensor and HID initialization
  HID: amd_sfh: Remove duplicate cleanup for SFH1.1
  HID: amd_sfh: Split sensor and HID initialization for SFH1.1

 drivers/hid/amd-sfh-hid/amd_sfh_client.c      | 47 ++++++-------------
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 24 +++-------
 2 files changed, 20 insertions(+), 51 deletions(-)

-- 
2.25.1


^ permalink raw reply

* [dtor-input:master] BUILD SUCCESS bcf784985e35fc39d682f0dde750162e7f54a1f0
From: kernel test robot @ 2023-05-09  5:37 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git master
branch HEAD: bcf784985e35fc39d682f0dde750162e7f54a1f0  Input: pwm-vibra - add support for enable GPIO

elapsed time: 722m

configs tested: 158
configs skipped: 12

The following configs have been built successfully.
More configs may be tested in the coming days.

tested configs:
alpha                            allyesconfig   gcc  
alpha        buildonly-randconfig-r006-20230508   gcc  
alpha                               defconfig   gcc  
alpha                randconfig-r001-20230507   gcc  
alpha                randconfig-r023-20230507   gcc  
alpha                randconfig-r032-20230507   gcc  
arc                              allyesconfig   gcc  
arc          buildonly-randconfig-r003-20230507   gcc  
arc                                 defconfig   gcc  
arc                  randconfig-r003-20230508   gcc  
arc                  randconfig-r043-20230507   gcc  
arc                  randconfig-r043-20230508   gcc  
arm                              allmodconfig   gcc  
arm                              allyesconfig   gcc  
arm          buildonly-randconfig-r001-20230507   gcc  
arm          buildonly-randconfig-r002-20230508   clang
arm          buildonly-randconfig-r003-20230507   gcc  
arm                                 defconfig   gcc  
arm                  randconfig-r023-20230508   clang
arm                  randconfig-r046-20230507   gcc  
arm                  randconfig-r046-20230508   clang
arm64                            allyesconfig   gcc  
arm64        buildonly-randconfig-r006-20230507   gcc  
arm64                               defconfig   gcc  
arm64                randconfig-r031-20230507   gcc  
csky                                defconfig   gcc  
csky                 randconfig-r014-20230508   gcc  
csky                 randconfig-r031-20230507   gcc  
hexagon              randconfig-r002-20230508   clang
hexagon              randconfig-r011-20230508   clang
hexagon              randconfig-r012-20230507   clang
hexagon              randconfig-r034-20230507   clang
hexagon              randconfig-r041-20230507   clang
hexagon              randconfig-r041-20230508   clang
hexagon              randconfig-r045-20230507   clang
hexagon              randconfig-r045-20230508   clang
i386                             allyesconfig   gcc  
i386                              debian-10.3   gcc  
i386                                defconfig   gcc  
i386                 randconfig-a001-20230508   clang
i386                          randconfig-a001   gcc  
i386                 randconfig-a002-20230508   clang
i386                          randconfig-a002   clang
i386                 randconfig-a003-20230508   clang
i386                          randconfig-a003   gcc  
i386                 randconfig-a004-20230508   clang
i386                          randconfig-a004   clang
i386                 randconfig-a005-20230508   clang
i386                          randconfig-a005   gcc  
i386                 randconfig-a006-20230508   clang
i386                          randconfig-a006   clang
i386                 randconfig-a011-20230508   gcc  
i386                 randconfig-a012-20230508   gcc  
i386                 randconfig-a013-20230508   gcc  
i386                 randconfig-a014-20230508   gcc  
i386                 randconfig-a015-20230508   gcc  
i386                 randconfig-a016-20230508   gcc  
i386                 randconfig-r015-20230508   gcc  
ia64                             allmodconfig   gcc  
ia64                                defconfig   gcc  
ia64                 randconfig-r006-20230507   gcc  
ia64                 randconfig-r035-20230507   gcc  
loongarch                        allmodconfig   gcc  
loongarch                         allnoconfig   gcc  
loongarch    buildonly-randconfig-r003-20230508   gcc  
loongarch                           defconfig   gcc  
loongarch            randconfig-r014-20230507   gcc  
loongarch            randconfig-r036-20230507   gcc  
m68k                             allmodconfig   gcc  
m68k         buildonly-randconfig-r004-20230508   gcc  
m68k                                defconfig   gcc  
m68k                 randconfig-r033-20230507   gcc  
microblaze   buildonly-randconfig-r002-20230507   gcc  
microblaze   buildonly-randconfig-r005-20230507   gcc  
microblaze           randconfig-r001-20230507   gcc  
microblaze           randconfig-r002-20230507   gcc  
microblaze           randconfig-r011-20230507   gcc  
microblaze           randconfig-r013-20230507   gcc  
microblaze           randconfig-r015-20230507   gcc  
microblaze           randconfig-r024-20230507   gcc  
mips                             allmodconfig   gcc  
mips                             allyesconfig   gcc  
mips                 randconfig-r005-20230508   gcc  
mips                 randconfig-r016-20230507   gcc  
mips                 randconfig-r021-20230508   clang
mips                 randconfig-r022-20230507   gcc  
mips                 randconfig-r022-20230508   clang
mips                 randconfig-r024-20230508   clang
mips                 randconfig-r025-20230508   clang
mips                 randconfig-r026-20230507   gcc  
nios2                               defconfig   gcc  
nios2                randconfig-r001-20230508   gcc  
nios2                randconfig-r021-20230507   gcc  
nios2                randconfig-r033-20230507   gcc  
nios2                randconfig-r036-20230507   gcc  
parisc       buildonly-randconfig-r006-20230507   gcc  
parisc                              defconfig   gcc  
parisc               randconfig-r023-20230507   gcc  
parisc64                            defconfig   gcc  
powerpc                          allmodconfig   gcc  
powerpc                           allnoconfig   gcc  
powerpc              randconfig-r004-20230507   gcc  
powerpc              randconfig-r006-20230507   gcc  
powerpc              randconfig-r026-20230508   gcc  
riscv                            allmodconfig   gcc  
riscv                             allnoconfig   gcc  
riscv        buildonly-randconfig-r004-20230507   clang
riscv        buildonly-randconfig-r005-20230508   gcc  
riscv                               defconfig   gcc  
riscv                randconfig-r013-20230507   clang
riscv                randconfig-r013-20230508   gcc  
riscv                randconfig-r014-20230507   clang
riscv                randconfig-r042-20230507   clang
riscv                randconfig-r042-20230508   gcc  
riscv                          rv32_defconfig   gcc  
s390                             allmodconfig   gcc  
s390                             allyesconfig   gcc  
s390         buildonly-randconfig-r001-20230508   gcc  
s390                                defconfig   gcc  
s390                 randconfig-r032-20230507   gcc  
s390                 randconfig-r044-20230507   clang
s390                 randconfig-r044-20230508   gcc  
sh                               allmodconfig   gcc  
sh           buildonly-randconfig-r002-20230507   gcc  
sh           buildonly-randconfig-r005-20230507   gcc  
sh                   randconfig-r005-20230507   gcc  
sparc        buildonly-randconfig-r004-20230507   gcc  
sparc                               defconfig   gcc  
sparc                randconfig-r003-20230507   gcc  
sparc                randconfig-r006-20230508   gcc  
sparc                randconfig-r015-20230507   gcc  
sparc                randconfig-r024-20230507   gcc  
sparc                randconfig-r035-20230507   gcc  
sparc64              randconfig-r004-20230508   gcc  
sparc64              randconfig-r012-20230508   gcc  
sparc64              randconfig-r021-20230507   gcc  
sparc64              randconfig-r022-20230507   gcc  
sparc64              randconfig-r026-20230507   gcc  
um                             i386_defconfig   gcc  
um                           x86_64_defconfig   gcc  
x86_64                            allnoconfig   gcc  
x86_64                           allyesconfig   gcc  
x86_64                              defconfig   gcc  
x86_64                                  kexec   gcc  
x86_64               randconfig-a001-20230508   clang
x86_64               randconfig-a002-20230508   clang
x86_64               randconfig-a003-20230508   clang
x86_64               randconfig-a004-20230508   clang
x86_64               randconfig-a005-20230508   clang
x86_64               randconfig-a006-20230508   clang
x86_64               randconfig-a011-20230508   gcc  
x86_64               randconfig-a012-20230508   gcc  
x86_64               randconfig-a013-20230508   gcc  
x86_64               randconfig-a014-20230508   gcc  
x86_64               randconfig-a015-20230508   gcc  
x86_64               randconfig-a016-20230508   gcc  
x86_64                               rhel-8.3   gcc  
xtensa               randconfig-r016-20230508   gcc  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply

* [PATCH] Input: psmouse - fix OOB access in Elantech protocol
From: Dmitry Torokhov @ 2023-05-09  3:55 UTC (permalink / raw)
  To: linux-input; +Cc: linux-kernel, jondaniel879

The kernel only allocate 5 MT slots; check that transmitted slot ID
falls within the acceptable range.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217417
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/mouse/elantech.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ece97f8c6a3e..2118b2075f43 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -674,10 +674,11 @@ static void process_packet_head_v4(struct psmouse *psmouse)
 	struct input_dev *dev = psmouse->dev;
 	struct elantech_data *etd = psmouse->private;
 	unsigned char *packet = psmouse->packet;
-	int id = ((packet[3] & 0xe0) >> 5) - 1;
+	int id;
 	int pres, traces;
 
-	if (id < 0)
+	id = ((packet[3] & 0xe0) >> 5) - 1;
+	if (id < 0 || id >= ETP_MAX_FINGERS)
 		return;
 
 	etd->mt[id].x = ((packet[1] & 0x0f) << 8) | packet[2];
@@ -707,7 +708,7 @@ static void process_packet_motion_v4(struct psmouse *psmouse)
 	int id, sid;
 
 	id = ((packet[0] & 0xe0) >> 5) - 1;
-	if (id < 0)
+	if (id < 0 || id >= ETP_MAX_FINGERS)
 		return;
 
 	sid = ((packet[3] & 0xe0) >> 5) - 1;
@@ -728,7 +729,7 @@ static void process_packet_motion_v4(struct psmouse *psmouse)
 	input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x);
 	input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y);
 
-	if (sid >= 0) {
+	if (sid >= 0 && sid < ETP_MAX_FINGERS) {
 		etd->mt[sid].x += delta_x2 * weight;
 		etd->mt[sid].y -= delta_y2 * weight;
 		input_mt_slot(dev, sid);
-- 
2.40.1.521.gf1e218fcd8-goog


-- 
Dmitry

^ permalink raw reply related

* Re: [BUG] Kmemleak, possibly hiddev_connect(), in 6.3.0+ torvalds tree commit gfc4354c6e5c2
From: Greg Kroah-Hartman @ 2023-05-09  2:59 UTC (permalink / raw)
  To: Mirsad Goran Todorovac
  Cc: linux-usb, linux-kernel, linux-input, Benjamin Tissoires,
	Jiri Kosina
In-Reply-To: <c73471aa-522a-83a4-5614-506581604301@alu.unizg.hr>

On Tue, May 09, 2023 at 01:51:35AM +0200, Mirsad Goran Todorovac wrote:
> 
> 
> On 08. 05. 2023. 16:01, Greg Kroah-Hartman wrote:
> > On Mon, May 08, 2023 at 08:51:55AM +0200, Greg Kroah-Hartman wrote:
> > > On Mon, May 08, 2023 at 08:30:07AM +0200, Mirsad Goran Todorovac wrote:
> > > > Hi,
> > > > 
> > > > There seems to be a kernel memory leak in the USB keyboard driver.
> > > > 
> > > > The leaked memory allocs are 96 and 512 bytes.
> > > > 
> > > > The platform is Ubuntu 22.04 LTS on a assembled AMD Ryzen 9 with X670E PG
> > > > Lightning mobo,
> > > > and Genius SlimStar i220 GK-080012 keyboard.
> > > > 
> > > > (Logitech M100 HID mouse is not affected by the bug.)
> > > > 
> > > > BIOS is:
> > > > 
> > > >       *-firmware
> > > >            description: BIOS
> > > >            vendor: American Megatrends International, LLC.
> > > >            physical id: 0
> > > >            version: 1.21
> > > >            date: 04/26/2023
> > > >            size: 64KiB
> > > > 
> > > > The kernel is 6.3.0-torvalds-<id>-13466-gfc4354c6e5c2.
> > > > 
> > > > The keyboard is recognised as Chicony:
> > > > 
> > > >                   *-usb
> > > >                        description: Keyboard
> > > >                        product: CHICONY USB Keyboard
> > > >                        vendor: CHICONY
> > > >                        physical id: 2
> > > >                        bus info: usb@5:2
> > > >                        logical name: input35
> > > >                        logical name: /dev/input/event4
> > > >                        logical name: input35::capslock
> > > >                        logical name: input35::numlock
> > > >                        logical name: input35::scrolllock
> > > >                        logical name: input36
> > > >                        logical name: /dev/input/event5
> > > >                        logical name: input37
> > > >                        logical name: /dev/input/event6
> > > >                        logical name: input38
> > > >                        logical name: /dev/input/event8
> > > >                        version: 2.30
> > > >                        capabilities: usb-2.00 usb
> > > >                        configuration: driver=usbhid maxpower=100mA
> > > > speed=1Mbit/s
> > > > 
> > > > The bug is easily reproduced by unplugging the USB keyboard, waiting about a
> > > > couple of seconds,
> > > > and then reconnect and scan for memory leaks twice.
> > > > 
> > > > The kmemleak log is as follows [edited privacy info]:
> > > > 
> > > > root@hostname:/home/username# cat /sys/kernel/debug/kmemleak
> > > > unreferenced object 0xffff8dd020037c00 (size 96):
> > > >    comm "systemd-udevd", pid 435, jiffies 4294892550 (age 8909.356s)
> > > >    hex dump (first 32 bytes):
> > > >      5d 8e 4e b9 ff ff ff ff 00 00 00 00 00 00 00 00 ].N.............
> > > >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > > >    backtrace:
> > > >      [<ffffffffb81a74be>] __kmem_cache_alloc_node+0x22e/0x2b0
> > > >      [<ffffffffb8127b6e>] kmalloc_trace+0x2e/0xa0
> > > >      [<ffffffffb87543d9>] class_create+0x29/0x80
> > > >      [<ffffffffb8880d24>] usb_register_dev+0x1d4/0x2e0
> > > 
> > > As the call to class_create() in this path is now gone in 6.4-rc1, can
> > > you retry that release to see if this is still there or not?
> > 
> > No, wait, it's still there, I was looking at a development branch of
> > mine that isn't sent upstream yet.  And syzbot just reported the same
> > thing:
> > 	https://lore.kernel.org/r/00000000000058d15f05fb264013@google.com
> > 
> > So something's wrong here, let me dig into it tomorrow when I get a
> > chance...
> 
> If this could help, here is the bisect of the bug (I could not discern what
> could possibly be wrong):
> 
> user@host:~/linux/kernel/linux_torvalds$ git bisect log
> git bisect start
> # bad: [ac9a78681b921877518763ba0e89202254349d1b] Linux 6.4-rc1
> git bisect bad ac9a78681b921877518763ba0e89202254349d1b
> # good: [c9c3395d5e3dcc6daee66c6908354d47bf98cb0c] Linux 6.2
> git bisect good c9c3395d5e3dcc6daee66c6908354d47bf98cb0c
> # good: [85496c9b3bf8dbe15e2433d3a0197954d323cadc] Merge branch
> 'net-remove-some-rcu_bh-cruft'
> git bisect good 85496c9b3bf8dbe15e2433d3a0197954d323cadc
> # good: [b68ee1c6131c540a62ecd443be89c406401df091] Merge tag 'scsi-misc' of
> git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
> git bisect good b68ee1c6131c540a62ecd443be89c406401df091
> # bad: [888d3c9f7f3ae44101a3fd76528d3dd6f96e9fd0] Merge tag 'sysctl-6.4-rc1'
> of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
> git bisect bad 888d3c9f7f3ae44101a3fd76528d3dd6f96e9fd0
> # good: [34b62f186db9614e55d021f8c58d22fc44c57911] Merge tag
> 'pci-v6.4-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
> git bisect good 34b62f186db9614e55d021f8c58d22fc44c57911
> # good: [34da76dca4673ab1819830b4924bb5b436325b26] Merge tag
> 'for-linus-2023042601' of
> git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
> git bisect good 34da76dca4673ab1819830b4924bb5b436325b26
> # good: [97b2ff294381d05e59294a931c4db55276470cb5] Merge tag
> 'staging-6.4-rc1' of
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
> git bisect good 97b2ff294381d05e59294a931c4db55276470cb5
> # good: [2025b2ca8004c04861903d076c67a73a0ec6dfca] mcb-lpc: Reallocate
> memory region to avoid memory overlapping
> git bisect good 2025b2ca8004c04861903d076c67a73a0ec6dfca
> # bad: [d06f5a3f7140921ada47d49574ae6fa4de5e2a89] cdx: fix build failure due
> to sysfs 'bus_type' argument needing to be const
> git bisect bad d06f5a3f7140921ada47d49574ae6fa4de5e2a89
> # good: [dcfbb67e48a2becfce7990386e985b9c45098ee5] driver core: class: use
> lock_class_key already present in struct subsys_private
> git bisect good dcfbb67e48a2becfce7990386e985b9c45098ee5
> # bad: [6f14c02220c791d5c46b0f965b9340c58f3d503d] driver core: create
> class_is_registered()
> git bisect bad 6f14c02220c791d5c46b0f965b9340c58f3d503d
> # good: [2f9e87f5a2941b259336c7ea6c5a1499ede4554a] driver core: Add a
> comment to set_primary_fwnode() on nullifying
> git bisect good 2f9e87f5a2941b259336c7ea6c5a1499ede4554a
> # bad: [02fe26f25325b547b7a31a65deb0326c04bb5174] firmware_loader: Add debug
> message with checksum for FW file
> git bisect bad 02fe26f25325b547b7a31a65deb0326c04bb5174
> # good: [884f8ce42ccec9d0bf11d8bf9f111e5961ca1c82] driver core: class:
> implement class_get/put without the private pointer.
> git bisect good 884f8ce42ccec9d0bf11d8bf9f111e5961ca1c82
> # bad: [3f84aa5ec052dba960baca4ab8a352d43d47028e] base: soc: populate
> machine name in soc_device_register if empty
> git bisect bad 3f84aa5ec052dba960baca4ab8a352d43d47028e
> # bad: [7b884b7f24b42fa25e92ed724ad82f137610afaf] driver core: class.c:
> convert to only use class_to_subsys
> git bisect bad 7b884b7f24b42fa25e92ed724ad82f137610afaf
> # first bad commit: [7b884b7f24b42fa25e92ed724ad82f137610afaf] driver core:
> class.c: convert to only use class_to_subsys
> user@host:~/linux/kernel/linux_torvalds$

This helps a lot, thanks.  I got the reference counting wrong somewhere
in here, I thought I tested this better, odd it shows up now...

I'll try to work on it this week.

thanks,

greg k-h

^ permalink raw reply

* Re: [BUG] Kmemleak, possibly hiddev_connect(), in 6.3.0+ torvalds tree commit gfc4354c6e5c2
From: Mirsad Goran Todorovac @ 2023-05-08 23:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mirsad Goran Todorovac
  Cc: linux-usb, linux-kernel, linux-input, Benjamin Tissoires,
	Jiri Kosina
In-Reply-To: <2023050854-collage-dreamt-660c@gregkh>



On 08. 05. 2023. 16:01, Greg Kroah-Hartman wrote:
> On Mon, May 08, 2023 at 08:51:55AM +0200, Greg Kroah-Hartman wrote:
>> On Mon, May 08, 2023 at 08:30:07AM +0200, Mirsad Goran Todorovac wrote:
>>> Hi,
>>>
>>> There seems to be a kernel memory leak in the USB keyboard driver.
>>>
>>> The leaked memory allocs are 96 and 512 bytes.
>>>
>>> The platform is Ubuntu 22.04 LTS on a assembled AMD Ryzen 9 with X670E PG
>>> Lightning mobo,
>>> and Genius SlimStar i220 GK-080012 keyboard.
>>>
>>> (Logitech M100 HID mouse is not affected by the bug.)
>>>
>>> BIOS is:
>>>
>>>       *-firmware
>>>            description: BIOS
>>>            vendor: American Megatrends International, LLC.
>>>            physical id: 0
>>>            version: 1.21
>>>            date: 04/26/2023
>>>            size: 64KiB
>>>
>>> The kernel is 6.3.0-torvalds-<id>-13466-gfc4354c6e5c2.
>>>
>>> The keyboard is recognised as Chicony:
>>>
>>>                   *-usb
>>>                        description: Keyboard
>>>                        product: CHICONY USB Keyboard
>>>                        vendor: CHICONY
>>>                        physical id: 2
>>>                        bus info: usb@5:2
>>>                        logical name: input35
>>>                        logical name: /dev/input/event4
>>>                        logical name: input35::capslock
>>>                        logical name: input35::numlock
>>>                        logical name: input35::scrolllock
>>>                        logical name: input36
>>>                        logical name: /dev/input/event5
>>>                        logical name: input37
>>>                        logical name: /dev/input/event6
>>>                        logical name: input38
>>>                        logical name: /dev/input/event8
>>>                        version: 2.30
>>>                        capabilities: usb-2.00 usb
>>>                        configuration: driver=usbhid maxpower=100mA
>>> speed=1Mbit/s
>>>
>>> The bug is easily reproduced by unplugging the USB keyboard, waiting about a
>>> couple of seconds,
>>> and then reconnect and scan for memory leaks twice.
>>>
>>> The kmemleak log is as follows [edited privacy info]:
>>>
>>> root@hostname:/home/username# cat /sys/kernel/debug/kmemleak
>>> unreferenced object 0xffff8dd020037c00 (size 96):
>>>    comm "systemd-udevd", pid 435, jiffies 4294892550 (age 8909.356s)
>>>    hex dump (first 32 bytes):
>>>      5d 8e 4e b9 ff ff ff ff 00 00 00 00 00 00 00 00 ].N.............
>>>      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
>>>    backtrace:
>>>      [<ffffffffb81a74be>] __kmem_cache_alloc_node+0x22e/0x2b0
>>>      [<ffffffffb8127b6e>] kmalloc_trace+0x2e/0xa0
>>>      [<ffffffffb87543d9>] class_create+0x29/0x80
>>>      [<ffffffffb8880d24>] usb_register_dev+0x1d4/0x2e0
>>
>> As the call to class_create() in this path is now gone in 6.4-rc1, can
>> you retry that release to see if this is still there or not?
> 
> No, wait, it's still there, I was looking at a development branch of
> mine that isn't sent upstream yet.  And syzbot just reported the same
> thing:
> 	https://lore.kernel.org/r/00000000000058d15f05fb264013@google.com
> 
> So something's wrong here, let me dig into it tomorrow when I get a
> chance...

If this could help, here is the bisect of the bug (I could not discern 
what could possibly be wrong):

user@host:~/linux/kernel/linux_torvalds$ git bisect log
git bisect start
# bad: [ac9a78681b921877518763ba0e89202254349d1b] Linux 6.4-rc1
git bisect bad ac9a78681b921877518763ba0e89202254349d1b
# good: [c9c3395d5e3dcc6daee66c6908354d47bf98cb0c] Linux 6.2
git bisect good c9c3395d5e3dcc6daee66c6908354d47bf98cb0c
# good: [85496c9b3bf8dbe15e2433d3a0197954d323cadc] Merge branch 
'net-remove-some-rcu_bh-cruft'
git bisect good 85496c9b3bf8dbe15e2433d3a0197954d323cadc
# good: [b68ee1c6131c540a62ecd443be89c406401df091] Merge tag 'scsi-misc' 
of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
git bisect good b68ee1c6131c540a62ecd443be89c406401df091
# bad: [888d3c9f7f3ae44101a3fd76528d3dd6f96e9fd0] Merge tag 
'sysctl-6.4-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
git bisect bad 888d3c9f7f3ae44101a3fd76528d3dd6f96e9fd0
# good: [34b62f186db9614e55d021f8c58d22fc44c57911] Merge tag 
'pci-v6.4-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
git bisect good 34b62f186db9614e55d021f8c58d22fc44c57911
# good: [34da76dca4673ab1819830b4924bb5b436325b26] Merge tag 
'for-linus-2023042601' of 
git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
git bisect good 34da76dca4673ab1819830b4924bb5b436325b26
# good: [97b2ff294381d05e59294a931c4db55276470cb5] Merge tag 
'staging-6.4-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
git bisect good 97b2ff294381d05e59294a931c4db55276470cb5
# good: [2025b2ca8004c04861903d076c67a73a0ec6dfca] mcb-lpc: Reallocate 
memory region to avoid memory overlapping
git bisect good 2025b2ca8004c04861903d076c67a73a0ec6dfca
# bad: [d06f5a3f7140921ada47d49574ae6fa4de5e2a89] cdx: fix build failure 
due to sysfs 'bus_type' argument needing to be const
git bisect bad d06f5a3f7140921ada47d49574ae6fa4de5e2a89
# good: [dcfbb67e48a2becfce7990386e985b9c45098ee5] driver core: class: 
use lock_class_key already present in struct subsys_private
git bisect good dcfbb67e48a2becfce7990386e985b9c45098ee5
# bad: [6f14c02220c791d5c46b0f965b9340c58f3d503d] driver core: create 
class_is_registered()
git bisect bad 6f14c02220c791d5c46b0f965b9340c58f3d503d
# good: [2f9e87f5a2941b259336c7ea6c5a1499ede4554a] driver core: Add a 
comment to set_primary_fwnode() on nullifying
git bisect good 2f9e87f5a2941b259336c7ea6c5a1499ede4554a
# bad: [02fe26f25325b547b7a31a65deb0326c04bb5174] firmware_loader: Add 
debug message with checksum for FW file
git bisect bad 02fe26f25325b547b7a31a65deb0326c04bb5174
# good: [884f8ce42ccec9d0bf11d8bf9f111e5961ca1c82] driver core: class: 
implement class_get/put without the private pointer.
git bisect good 884f8ce42ccec9d0bf11d8bf9f111e5961ca1c82
# bad: [3f84aa5ec052dba960baca4ab8a352d43d47028e] base: soc: populate 
machine name in soc_device_register if empty
git bisect bad 3f84aa5ec052dba960baca4ab8a352d43d47028e
# bad: [7b884b7f24b42fa25e92ed724ad82f137610afaf] driver core: class.c: 
convert to only use class_to_subsys
git bisect bad 7b884b7f24b42fa25e92ed724ad82f137610afaf
# first bad commit: [7b884b7f24b42fa25e92ed724ad82f137610afaf] driver 
core: class.c: convert to only use class_to_subsys
user@host:~/linux/kernel/linux_torvalds$

Have a nice day and God bless.

Best regards,
Mirsad

^ permalink raw reply

* Re: [PATCH v3 1/3] Input: ads7846 - Convert to use software nodes
From: Linus Walleij @ 2023-05-08 21:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Mark Brown, Bartosz Golaszewski, Andreas Kemnade, Helge Deller,
	Ulf Hansson, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mips, linux-input, linux-spi, linux-fbdev, dri-devel,
	linux-mmc
In-Reply-To: <ZFlpYff6I5V6JiH1@google.com>

On Mon, May 8, 2023 at 11:28 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Mon, May 08, 2023 at 11:23:44PM +0200, Linus Walleij wrote:

> > > This needs to be
> > >
> > >         return !gpiod_get_value_raw(ts->gpio_pendown);
> >
> > There is no such function. The gpio descriptor runpath simply assumes that
> > device trees can be trusted.
>
> Sorry, this was supposed to be gpiod_get_raw_value():
>
> https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpiolib.c#L2854

I missed it, I should have very well understood you meant that one...
I just read the file too sloppily.

> Yeah, we we can land the DT fixes ahead of the driver change that would
> be great. Otherwise we need a temporary application of
> gpiod_get_raw_value().

If the patch is fine I will send it to the SoC tree and ask for it to be
applied as a fix.

Yours,
Linus Walleij

^ permalink raw reply

* Re: [PATCH v3 3/3] ARM: omap1: Fix up the Nokia 770 board device IRQs
From: Linus Walleij @ 2023-05-08 21:28 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson, linux-omap, linux-arm-kernel,
	linux-kernel, linux-mips, linux-input, linux-spi, linux-fbdev,
	dri-devel, linux-mmc
In-Reply-To: <ZFkSiM9GRfN5n7n4@surfacebook>

On Mon, May 8, 2023 at 5:17 PM <andy.shevchenko@gmail.com> wrote:

> > +             GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
> > +                         GPIO_ACTIVE_HIGH),
>
> Missing terminator.

Darn I missed this comment in v4, I have fixed it in my tree, I will see if
there are more comments for v4 before I resend.

Yours,
Linus Walleij

^ permalink raw reply

* Re: [PATCH v3 1/3] Input: ads7846 - Convert to use software nodes
From: Dmitry Torokhov @ 2023-05-08 21:28 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Mark Brown, Bartosz Golaszewski, Andreas Kemnade, Helge Deller,
	Ulf Hansson, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mips, linux-input, linux-spi, linux-fbdev, dri-devel,
	linux-mmc
In-Reply-To: <CACRpkdZUXOTOK9CObdXuHQx4PMD3ykMKco8X5ijchkZ8cEmQvA@mail.gmail.com>

On Mon, May 08, 2023 at 11:23:44PM +0200, Linus Walleij wrote:
> On Fri, May 5, 2023 at 8:08 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> 
> > > -     return !gpio_get_value(ts->gpio_pendown);
> > > +     return !gpiod_get_value(ts->gpio_pendown);
> >
> > This needs to be
> >
> >         return !gpiod_get_value_raw(ts->gpio_pendown);
> 
> There is no such function. The gpio descriptor runpath simply assumes that
> device trees can be trusted.

Sorry, this was supposed to be gpiod_get_raw_value():

https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpiolib.c#L2854

> 
> > I looked at various DTSes we have and they use a mix of active high and
> > active low annotations, so we have to go with the "raw" variant for now,
> > and then update to normal one once we update bad DTSes.
> 
> I just sighed and fixed all the device trees :D

Yeah, we we can land the DT fixes ahead of the driver change that would
be great. Otherwise we need a temporary application of
gpiod_get_raw_value().

> 
> Yours,
> Linus Walleij

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v4 1/4] Input: ads7846 - Convert to use software nodes
From: Dmitry Torokhov @ 2023-05-08 21:24 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Mark Brown, Bartosz Golaszewski, Andreas Kemnade, Helge Deller,
	Ulf Hansson, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mips, linux-input, linux-spi, linux-fbdev, dri-devel,
	linux-mmc
In-Reply-To: <20230430-nokia770-regression-v4-1-9b6dc5536b17@linaro.org>

On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> The Nokia 770 is using GPIOs from the global numberspace on the
> CBUS node to pass down to the LCD controller. This regresses when we
> let the OMAP GPIO driver use dynamic GPIO base.
> 
> The Nokia 770 now has dynamic allocation of IRQ numbers, so this
> needs to be fixed for it to work.
> 
> As this is the only user of LCD MIPID we can easily augment the
> driver to use a GPIO descriptor instead and resolve the issue.
> 
> The platform data .shutdown() callback wasn't even used in the
> code, but we encode a shutdown asserting RESET in the remove()
> callback for completeness sake.
> 
> The CBUS also has the ADS7846 touchscreen attached.
> 
> Populate the devices on the Nokia 770 CBUS I2C using software
> nodes instead of platform data quirks. This includes the LCD
> and the ADS7846 touchscreen so the conversion just brings the LCD
> along with it as software nodes is an all-or-nothing design
> pattern.
> 
> The ADS7846 has some limited support for using GPIO descriptors,
> let's convert it over completely to using device properties and then
> fix all remaining boardfile users to provide all platform data using
> software nodes.
> 
> Dump the of includes and of_match_ptr() in the ADS7846 driver as part
> of the job.
> 
> Since we have to move ADS7846 over to obtaining the GPIOs it is
> using exclusively from descriptors, we provide descriptor tables
> for the two remaining in-kernel boardfiles using ADS7846:
> 
> - PXA Spitz
> - MIPS Alchemy DB1000 development board
> 
> It was too hard for me to include software node conversion of
> these two remaining users at this time: the spitz is using a
> hscync callback in the platform data that would require further
> GPIO descriptor conversion of the Spitz, and moving the hsync
> callback down into the driver: it will just become too big of
> a job, but it can be done separately.
> 
> The MIPS Alchemy DB1000 is simply something I cannot test, so take
> the easier approach of just providing some GPIO descriptors in
> this case as I don't want the patch to grow too intrusive.
> 
> As we see that several device trees have incorrect polarity flags
> and just expect to bypass the gpiolib polarity handling, fix up
> all device trees too, in a separate patch.
> 
> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Fix all board file polarity flags to be active low, because
>   this pendown signal is active low.
> - Fix all erroneous device trees too.
> - Drop some unnecessary commas.
> ChangeLog v2->v3:
> - Drop leftover OF ifdefs no longer needed and causing compile
>   errors.
> ---
>  arch/arm/mach-omap1/board-nokia770.c    |  98 +++++++++++++++++----------
>  arch/arm/mach-pxa/spitz.c               |  11 +++-
>  arch/mips/alchemy/devboards/db1000.c    |  11 +++-
>  drivers/input/touchscreen/ads7846.c     | 113 ++++++++++++--------------------

For input:

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

In general:

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v3 1/3] Input: ads7846 - Convert to use software nodes
From: Linus Walleij @ 2023-05-08 21:23 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Mark Brown, Bartosz Golaszewski, Andreas Kemnade, Helge Deller,
	Ulf Hansson, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mips, linux-input, linux-spi, linux-fbdev, dri-devel,
	linux-mmc
In-Reply-To: <ZFVGMiuRT+e2eVXw@google.com>

On Fri, May 5, 2023 at 8:08 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> > -     return !gpio_get_value(ts->gpio_pendown);
> > +     return !gpiod_get_value(ts->gpio_pendown);
>
> This needs to be
>
>         return !gpiod_get_value_raw(ts->gpio_pendown);

There is no such function. The gpio descriptor runpath simply assumes that
device trees can be trusted.

> I looked at various DTSes we have and they use a mix of active high and
> active low annotations, so we have to go with the "raw" variant for now,
> and then update to normal one once we update bad DTSes.

I just sighed and fixed all the device trees :D

Yours,
Linus Walleij

^ permalink raw reply

* [PATCH v4 4/4] ARM: dts: Fix erroneous ADS touchscreen polarities
From: Linus Walleij @ 2023-05-08 21:20 UTC (permalink / raw)
  To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mips,
	linux-input, linux-spi, linux-fbdev, dri-devel, linux-mmc,
	Linus Walleij
In-Reply-To: <20230430-nokia770-regression-v4-0-9b6dc5536b17@linaro.org>

Several device tree files get the polarity of the pendown-gpios
wrong: this signal is active low. Fix up all incorrect flags, so
that operating systems can rely on the flag being correctly set.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog ->v4
- New patch as issue was pointed out by Dmitry. Can be merged
  separately.
---
 arch/arm/boot/dts/am57xx-cl-som-am57x.dts          | 2 +-
 arch/arm/boot/dts/at91sam9261ek.dts                | 2 +-
 arch/arm/boot/dts/imx7d-pico-hobbit.dts            | 2 +-
 arch/arm/boot/dts/imx7d-sdb.dts                    | 2 +-
 arch/arm/boot/dts/omap3-cm-t3x.dtsi                | 2 +-
 arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi | 2 +-
 arch/arm/boot/dts/omap3-lilly-a83x.dtsi            | 2 +-
 arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi    | 2 +-
 arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi    | 2 +-
 arch/arm/boot/dts/omap3-pandora-common.dtsi        | 2 +-
 arch/arm/boot/dts/omap5-cm-t54.dts                 | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/arm/boot/dts/am57xx-cl-som-am57x.dts b/arch/arm/boot/dts/am57xx-cl-som-am57x.dts
index 2fc9a5d5e0c0..625b9b311b49 100644
--- a/arch/arm/boot/dts/am57xx-cl-som-am57x.dts
+++ b/arch/arm/boot/dts/am57xx-cl-som-am57x.dts
@@ -527,7 +527,7 @@ touchscreen@1 {
 
 		interrupt-parent = <&gpio1>;
 		interrupts = <31 0>;
-		pendown-gpio = <&gpio1 31 0>;
+		pendown-gpio = <&gpio1 31 GPIO_ACTIVE_LOW>;
 
 
 		ti,x-min = /bits/ 16 <0x0>;
diff --git a/arch/arm/boot/dts/at91sam9261ek.dts b/arch/arm/boot/dts/at91sam9261ek.dts
index 88869ca874d1..045cb253f23a 100644
--- a/arch/arm/boot/dts/at91sam9261ek.dts
+++ b/arch/arm/boot/dts/at91sam9261ek.dts
@@ -156,7 +156,7 @@ tsc2046@2 {
 					compatible = "ti,ads7843";
 					interrupts-extended = <&pioC 2 IRQ_TYPE_EDGE_BOTH>;
 					spi-max-frequency = <3000000>;
-					pendown-gpio = <&pioC 2 GPIO_ACTIVE_HIGH>;
+					pendown-gpio = <&pioC 2 GPIO_ACTIVE_LOW>;
 
 					ti,x-min = /bits/ 16 <150>;
 					ti,x-max = /bits/ 16 <3830>;
diff --git a/arch/arm/boot/dts/imx7d-pico-hobbit.dts b/arch/arm/boot/dts/imx7d-pico-hobbit.dts
index d917dc4f2f22..6ad39dca7009 100644
--- a/arch/arm/boot/dts/imx7d-pico-hobbit.dts
+++ b/arch/arm/boot/dts/imx7d-pico-hobbit.dts
@@ -64,7 +64,7 @@ ads7846@0 {
 		interrupt-parent = <&gpio2>;
 		interrupts = <7 0>;
 		spi-max-frequency = <1000000>;
-		pendown-gpio = <&gpio2 7 0>;
+		pendown-gpio = <&gpio2 7 GPIO_ACTIVE_LOW>;
 		vcc-supply = <&reg_3p3v>;
 		ti,x-min = /bits/ 16 <0>;
 		ti,x-max = /bits/ 16 <4095>;
diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts
index f483bc0afe5e..234e5fc647b2 100644
--- a/arch/arm/boot/dts/imx7d-sdb.dts
+++ b/arch/arm/boot/dts/imx7d-sdb.dts
@@ -205,7 +205,7 @@ tsc2046@0 {
 		pinctrl-0 = <&pinctrl_tsc2046_pendown>;
 		interrupt-parent = <&gpio2>;
 		interrupts = <29 0>;
-		pendown-gpio = <&gpio2 29 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio2 29 GPIO_ACTIVE_LOW>;
 		touchscreen-max-pressure = <255>;
 		wakeup-source;
 	};
diff --git a/arch/arm/boot/dts/omap3-cm-t3x.dtsi b/arch/arm/boot/dts/omap3-cm-t3x.dtsi
index e61b8a2bfb7d..51baedf1603b 100644
--- a/arch/arm/boot/dts/omap3-cm-t3x.dtsi
+++ b/arch/arm/boot/dts/omap3-cm-t3x.dtsi
@@ -227,7 +227,7 @@ ads7846@0 {
 
 		interrupt-parent = <&gpio2>;
 		interrupts = <25 0>;		/* gpio_57 */
-		pendown-gpio = <&gpio2 25 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio2 25 GPIO_ACTIVE_LOW>;
 
 		ti,x-min = /bits/ 16 <0x0>;
 		ti,x-max = /bits/ 16 <0x0fff>;
diff --git a/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi b/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi
index 3decc2d78a6c..a7f99ae0c1fe 100644
--- a/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi
+++ b/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi
@@ -54,7 +54,7 @@ ads7846@0 {
 
 		interrupt-parent = <&gpio1>;
 		interrupts = <27 0>;		/* gpio_27 */
-		pendown-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio1 27 GPIO_ACTIVE_LOW>;
 
 		ti,x-min = /bits/ 16 <0x0>;
 		ti,x-max = /bits/ 16 <0x0fff>;
diff --git a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
index c595afe4181d..d310b5c7bac3 100644
--- a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
+++ b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
@@ -311,7 +311,7 @@ tsc2046@0 {
 		interrupt-parent = <&gpio1>;
 		interrupts = <8 0>;   /* boot6 / gpio_8 */
 		spi-max-frequency = <1000000>;
-		pendown-gpio = <&gpio1 8 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio1 8 GPIO_ACTIVE_LOW>;
 		vcc-supply = <&reg_vcc3>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&tsc2048_pins>;
diff --git a/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi b/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi
index 1d6e88f99eb3..c3570acc35fa 100644
--- a/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi
@@ -149,7 +149,7 @@ ads7846@0 {
 
 		interrupt-parent = <&gpio4>;
 		interrupts = <18 0>;			/* gpio_114 */
-		pendown-gpio = <&gpio4 18 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio4 18 GPIO_ACTIVE_LOW>;
 
 		ti,x-min = /bits/ 16 <0x0>;
 		ti,x-max = /bits/ 16 <0x0fff>;
diff --git a/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi b/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi
index 7e30f9d45790..d95a0e130058 100644
--- a/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi
@@ -160,7 +160,7 @@ ads7846@0 {
 
 		interrupt-parent = <&gpio4>;
 		interrupts = <18 0>;			/* gpio_114 */
-		pendown-gpio = <&gpio4 18 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio4 18 GPIO_ACTIVE_LOW>;
 
 		ti,x-min = /bits/ 16 <0x0>;
 		ti,x-max = /bits/ 16 <0x0fff>;
diff --git a/arch/arm/boot/dts/omap3-pandora-common.dtsi b/arch/arm/boot/dts/omap3-pandora-common.dtsi
index 559853764487..4c3b6bab179c 100644
--- a/arch/arm/boot/dts/omap3-pandora-common.dtsi
+++ b/arch/arm/boot/dts/omap3-pandora-common.dtsi
@@ -651,7 +651,7 @@ tsc2046@0 {
 		pinctrl-0 = <&penirq_pins>;
 		interrupt-parent = <&gpio3>;
 		interrupts = <30 IRQ_TYPE_NONE>;	/* GPIO_94 */
-		pendown-gpio = <&gpio3 30 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio3 30 GPIO_ACTIVE_LOW>;
 		vcc-supply = <&vaux4>;
 
 		ti,x-min = /bits/ 16 <0>;
diff --git a/arch/arm/boot/dts/omap5-cm-t54.dts b/arch/arm/boot/dts/omap5-cm-t54.dts
index 2d87b9fc230e..af288d63a26a 100644
--- a/arch/arm/boot/dts/omap5-cm-t54.dts
+++ b/arch/arm/boot/dts/omap5-cm-t54.dts
@@ -354,7 +354,7 @@ ads7846@0 {
 
 		interrupt-parent = <&gpio1>;
 		interrupts = <15 0>;			/* gpio1_wk15 */
-		pendown-gpio = <&gpio1 15 GPIO_ACTIVE_HIGH>;
+		pendown-gpio = <&gpio1 15 GPIO_ACTIVE_LOW>;
 
 
 		ti,x-min = /bits/ 16 <0x0>;

-- 
2.34.1


^ permalink raw reply related

* [PATCH v4 3/4] ARM: omap1: Fix up the Nokia 770 board device IRQs
From: Linus Walleij @ 2023-05-08 21:20 UTC (permalink / raw)
  To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mips,
	linux-input, linux-spi, linux-fbdev, dri-devel, linux-mmc,
	Linus Walleij
In-Reply-To: <20230430-nokia770-regression-v4-0-9b6dc5536b17@linaro.org>

The platform devices on the Nokia 770 is using some
board-specific IRQs that get statically assigned to platform
devices in the boardfile.

This does not work with dynamic IRQ chip bases.

Utilize the NULL device to define some board-specific
GPIO lookups and use these to immediately look up the
same GPIOs, convert to IRQ numbers and pass as resources
to the devices. This is ugly but should work.

Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-omap1/board-nokia770.c | 57 ++++++++++++++++++++++++++++--------
 1 file changed, 44 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 218c928f71b3..8965df2c250d 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -6,7 +6,7 @@
  */
 #include <linux/clkdev.h>
 #include <linux/irq.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio/property.h>
 #include <linux/kernel.h>
@@ -250,19 +250,25 @@ static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
 
 static void __init nokia770_cbus_init(void)
 {
-	const int retu_irq_gpio = 62;
-	const int tahvo_irq_gpio = 40;
-
-	if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
-		return;
-	if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) {
-		gpio_free(retu_irq_gpio);
-		return;
+	struct gpio_desc *d;
+	int irq;
+
+	d = gpiod_get(NULL, "retu_irq", GPIOD_IN);
+	if (IS_ERR(d)) {
+		pr_err("Unable to get CBUS Retu IRQ GPIO descriptor\n");
+	} else {
+		irq = gpiod_to_irq(d);
+		irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
+		nokia770_i2c_board_info_2[0].irq = irq;
+	}
+	d = gpiod_get(NULL, "tahvo_irq", GPIOD_IN);
+	if (IS_ERR(d)) {
+		pr_err("Unable to get CBUS Tahvo IRQ GPIO descriptor\n");
+	} else {
+		irq = gpiod_to_irq(d);
+		irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
+		nokia770_i2c_board_info_2[1].irq = irq;
 	}
-	irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
-	irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING);
-	nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio);
-	nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
 	i2c_register_board_info(2, nokia770_i2c_board_info_2,
 				ARRAY_SIZE(nokia770_i2c_board_info_2));
 	device_create_managed_software_node(&nokia770_cbus_device.dev,
@@ -275,8 +281,25 @@ static void __init nokia770_cbus_init(void)
 }
 #endif /* CONFIG_I2C_CBUS_GPIO */
 
+static struct gpiod_lookup_table nokia770_irq_gpio_table = {
+	.dev_id = NULL,
+	.table = {
+		/* GPIO used by SPI device 1 */
+		GPIO_LOOKUP("gpio-0-15", 15, "ads7846_irq",
+			    GPIO_ACTIVE_HIGH),
+		/* GPIO used for retu IRQ */
+		GPIO_LOOKUP("gpio-48-63", 15, "retu_irq",
+			    GPIO_ACTIVE_HIGH),
+		/* GPIO used for tahvo IRQ */
+		GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
+			    GPIO_ACTIVE_HIGH),
+	},
+};
+
 static void __init omap_nokia770_init(void)
 {
+	struct gpio_desc *d;
+
 	/* On Nokia 770, the SleepX signal is masked with an
 	 * MPUIO line by default.  It has to be unmasked for it
 	 * to become functional */
@@ -288,6 +311,14 @@ static void __init omap_nokia770_init(void)
 
 	software_node_register_node_group(nokia770_gpiochip_nodes);
 	platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
+
+	gpiod_add_lookup_table(&nokia770_irq_gpio_table);
+	d = gpiod_get(NULL, "ads7846_irq", GPIOD_IN);
+	if (IS_ERR(d))
+		pr_err("Unable to get ADS7846 IRQ GPIO descriptor\n");
+	else
+		nokia770_spi_board_info[1].irq = gpiod_to_irq(d);
+
 	spi_register_board_info(nokia770_spi_board_info,
 				ARRAY_SIZE(nokia770_spi_board_info));
 	omap_serial_init();

-- 
2.34.1


^ permalink raw reply related

* [PATCH v4 2/4] ARM/mmc: Convert old mmci-omap to GPIO descriptors
From: Linus Walleij @ 2023-05-08 21:20 UTC (permalink / raw)
  To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mips,
	linux-input, linux-spi, linux-fbdev, dri-devel, linux-mmc,
	Linus Walleij
In-Reply-To: <20230430-nokia770-regression-v4-0-9b6dc5536b17@linaro.org>

A recent change to the OMAP driver making it use a dynamic GPIO
base created problems with some old OMAP1 board files, among
them Nokia 770, SX1 and also the OMAP2 Nokia n8x0.

Fix up all instances of GPIOs being used for the MMC driver
by pushing the handling of power, slot selection and MMC
"cover" into the driver as optional GPIOs.

This is maybe not the most perfect solution as the MMC
framework have some central handlers for some of the
stuff, but it at least makes the situtation better and
solves the immediate issue.

Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-omap1/board-nokia770.c   | 43 ++++++-----------
 arch/arm/mach-omap1/board-sx1-mmc.c    |  1 -
 arch/arm/mach-omap2/board-n8x0.c       | 85 +++++++++++-----------------------
 drivers/mmc/host/omap.c                | 46 +++++++++++++++++-
 include/linux/platform_data/mmc-omap.h |  2 -
 5 files changed, 83 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 8a1f2572deea..218c928f71b3 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -183,27 +183,23 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
 
 #if IS_ENABLED(CONFIG_MMC_OMAP)
 
-#define NOKIA770_GPIO_MMC_POWER		41
-#define NOKIA770_GPIO_MMC_SWITCH	23
-
-static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
-				int vdd)
-{
-	gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
-	return 0;
-}
-
-static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
-{
-	return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
-}
+static struct gpiod_lookup_table nokia770_mmc_gpio_table = {
+	.dev_id = "mmci-omap",
+	.table = {
+		/* Slot index 0, VSD power, GPIO 41 */
+		GPIO_LOOKUP_IDX("gpio-32-47", 9,
+				"vsd", 0, GPIO_ACTIVE_HIGH),
+		/* Slot index 0, switch, GPIO 23 */
+		GPIO_LOOKUP_IDX("gpio-16-31", 7,
+				"cover", 0, GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
 
 static struct omap_mmc_platform_data nokia770_mmc2_data = {
 	.nr_slots                       = 1,
 	.max_freq                       = 12000000,
 	.slots[0]       = {
-		.set_power		= nokia770_mmc_set_power,
-		.get_cover_state	= nokia770_mmc_get_cover_state,
 		.ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
 		.name                   = "mmcblk",
 	},
@@ -213,20 +209,7 @@ static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
 
 static void __init nokia770_mmc_init(void)
 {
-	int ret;
-
-	ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
-	if (ret < 0)
-		return;
-	gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
-
-	ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
-	if (ret < 0) {
-		gpio_free(NOKIA770_GPIO_MMC_POWER);
-		return;
-	}
-	gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
-
+	gpiod_add_lookup_table(&nokia770_mmc_gpio_table);
 	/* Only the second MMC controller is used */
 	nokia770_mmc_data[1] = &nokia770_mmc2_data;
 	omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
diff --git a/arch/arm/mach-omap1/board-sx1-mmc.c b/arch/arm/mach-omap1/board-sx1-mmc.c
index f1c160924dfe..f183a8448a7b 100644
--- a/arch/arm/mach-omap1/board-sx1-mmc.c
+++ b/arch/arm/mach-omap1/board-sx1-mmc.c
@@ -9,7 +9,6 @@
  * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
  */
 
-#include <linux/gpio.h>
 #include <linux/platform_device.h>
 
 #include "hardware.h"
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 3353b0a923d9..baa2f0341aed 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -11,6 +11,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -170,22 +171,32 @@ static struct spi_board_info n800_spi_board_info[] __initdata = {
  * GPIO23 and GPIO9		slot 2 EMMC on N810
  *
  */
-#define N8X0_SLOT_SWITCH_GPIO	96
-#define N810_EMMC_VSD_GPIO	23
-#define N810_EMMC_VIO_GPIO	9
-
 static int slot1_cover_open;
 static int slot2_cover_open;
 static struct device *mmc_device;
 
-static int n8x0_mmc_switch_slot(struct device *dev, int slot)
-{
-#ifdef CONFIG_MMC_DEBUG
-	dev_dbg(dev, "Choose slot %d\n", slot + 1);
-#endif
-	gpio_set_value(N8X0_SLOT_SWITCH_GPIO, slot);
-	return 0;
-}
+static struct gpiod_lookup_table nokia8xx_mmc_gpio_table = {
+	.dev_id = "mmci-omap",
+	.table = {
+		/* Slot switch, GPIO 96 */
+		GPIO_LOOKUP("gpio-80-111", 16,
+			    "switch", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table nokia810_mmc_gpio_table = {
+	.dev_id = "mmci-omap",
+	.table = {
+		/* Slot index 1, VSD power, GPIO 23 */
+		GPIO_LOOKUP_IDX("gpio-16-31", 7,
+				"vsd", 1, GPIO_ACTIVE_HIGH),
+		/* Slot index 1, VIO power, GPIO 9 */
+		GPIO_LOOKUP_IDX("gpio-0-15", 9,
+				"vsd", 1, GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
 
 static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
 					int power_on, int vdd)
@@ -256,31 +267,13 @@ static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
 	return 0;
 }
 
-static void n810_set_power_emmc(struct device *dev,
-					 int power_on)
-{
-	dev_dbg(dev, "Set EMMC power %s\n", power_on ? "on" : "off");
-
-	if (power_on) {
-		gpio_set_value(N810_EMMC_VSD_GPIO, 1);
-		msleep(1);
-		gpio_set_value(N810_EMMC_VIO_GPIO, 1);
-		msleep(1);
-	} else {
-		gpio_set_value(N810_EMMC_VIO_GPIO, 0);
-		msleep(50);
-		gpio_set_value(N810_EMMC_VSD_GPIO, 0);
-		msleep(50);
-	}
-}
-
 static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on,
 			      int vdd)
 {
 	if (board_is_n800() || slot == 0)
 		return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd);
 
-	n810_set_power_emmc(dev, power_on);
+	/* The n810 power will be handled by GPIO code in the driver */
 
 	return 0;
 }
@@ -418,13 +411,6 @@ static void n8x0_mmc_shutdown(struct device *dev)
 static void n8x0_mmc_cleanup(struct device *dev)
 {
 	menelaus_unregister_mmc_callback();
-
-	gpio_free(N8X0_SLOT_SWITCH_GPIO);
-
-	if (board_is_n810()) {
-		gpio_free(N810_EMMC_VSD_GPIO);
-		gpio_free(N810_EMMC_VIO_GPIO);
-	}
 }
 
 /*
@@ -433,7 +419,6 @@ static void n8x0_mmc_cleanup(struct device *dev)
  */
 static struct omap_mmc_platform_data mmc1_data = {
 	.nr_slots			= 0,
-	.switch_slot			= n8x0_mmc_switch_slot,
 	.init				= n8x0_mmc_late_init,
 	.cleanup			= n8x0_mmc_cleanup,
 	.shutdown			= n8x0_mmc_shutdown,
@@ -463,14 +448,9 @@ static struct omap_mmc_platform_data mmc1_data = {
 
 static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
 
-static struct gpio n810_emmc_gpios[] __initdata = {
-	{ N810_EMMC_VSD_GPIO, GPIOF_OUT_INIT_LOW,  "MMC slot 2 Vddf" },
-	{ N810_EMMC_VIO_GPIO, GPIOF_OUT_INIT_LOW,  "MMC slot 2 Vdd"  },
-};
-
 static void __init n8x0_mmc_init(void)
 {
-	int err;
+	gpiod_add_lookup_table(&nokia8xx_mmc_gpio_table);
 
 	if (board_is_n810()) {
 		mmc1_data.slots[0].name = "external";
@@ -483,20 +463,7 @@ static void __init n8x0_mmc_init(void)
 		 */
 		mmc1_data.slots[1].name = "internal";
 		mmc1_data.slots[1].ban_openended = 1;
-	}
-
-	err = gpio_request_one(N8X0_SLOT_SWITCH_GPIO, GPIOF_OUT_INIT_LOW,
-			       "MMC slot switch");
-	if (err)
-		return;
-
-	if (board_is_n810()) {
-		err = gpio_request_array(n810_emmc_gpios,
-					 ARRAY_SIZE(n810_emmc_gpios));
-		if (err) {
-			gpio_free(N8X0_SLOT_SWITCH_GPIO);
-			return;
-		}
+		gpiod_add_lookup_table(&nokia810_mmc_gpio_table);
 	}
 
 	mmc1_data.nr_slots = 2;
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index ce78edfb402b..a14af21f12da 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -26,6 +26,7 @@
 #include <linux/clk.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
+#include <linux/gpio/consumer.h>
 #include <linux/platform_data/mmc-omap.h>
 
 
@@ -111,6 +112,9 @@ struct mmc_omap_slot {
 	struct mmc_request      *mrq;
 	struct mmc_omap_host    *host;
 	struct mmc_host		*mmc;
+	struct gpio_desc	*vsd;
+	struct gpio_desc	*vio;
+	struct gpio_desc	*cover;
 	struct omap_mmc_slot_data *pdata;
 };
 
@@ -133,6 +137,7 @@ struct mmc_omap_host {
 	int			irq;
 	unsigned char		bus_mode;
 	unsigned int		reg_shift;
+	struct gpio_desc	*slot_switch;
 
 	struct work_struct	cmd_abort_work;
 	unsigned		abort:1;
@@ -216,8 +221,13 @@ static void mmc_omap_select_slot(struct mmc_omap_slot *slot, int claimed)
 
 	if (host->current_slot != slot) {
 		OMAP_MMC_WRITE(host, CON, slot->saved_con & 0xFC00);
-		if (host->pdata->switch_slot != NULL)
-			host->pdata->switch_slot(mmc_dev(slot->mmc), slot->id);
+		if (host->slot_switch)
+			/*
+			 * With two slots and a simple GPIO switch, setting
+			 * the GPIO to 0 selects slot ID 0, setting it to 1
+			 * selects slot ID 1.
+			 */
+			gpiod_set_value(host->slot_switch, slot->id);
 		host->current_slot = slot;
 	}
 
@@ -297,6 +307,9 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled)
 static inline
 int mmc_omap_cover_is_open(struct mmc_omap_slot *slot)
 {
+	/* If we have a GPIO then use that */
+	if (slot->cover)
+		return gpiod_get_value(slot->cover);
 	if (slot->pdata->get_cover_state)
 		return slot->pdata->get_cover_state(mmc_dev(slot->mmc),
 						    slot->id);
@@ -1106,6 +1119,11 @@ static void mmc_omap_set_power(struct mmc_omap_slot *slot, int power_on,
 
 	host = slot->host;
 
+	if (slot->vsd)
+		gpiod_set_value(slot->vsd, power_on);
+	if (slot->vio)
+		gpiod_set_value(slot->vio, power_on);
+
 	if (slot->pdata->set_power != NULL)
 		slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on,
 					vdd);
@@ -1240,6 +1258,23 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 	slot->power_mode = MMC_POWER_UNDEFINED;
 	slot->pdata = &host->pdata->slots[id];
 
+	/* Check for some optional GPIO controls */
+	slot->vsd = gpiod_get_index_optional(host->dev, "vsd",
+					     id, GPIOD_OUT_LOW);
+	if (IS_ERR(slot->vsd))
+		return dev_err_probe(host->dev, PTR_ERR(slot->vsd),
+				     "error looking up VSD GPIO\n");
+	slot->vio = gpiod_get_index_optional(host->dev, "vio",
+					     id, GPIOD_OUT_LOW);
+	if (IS_ERR(slot->vio))
+		return dev_err_probe(host->dev, PTR_ERR(slot->vio),
+				     "error looking up VIO GPIO\n");
+	slot->cover = gpiod_get_index_optional(host->dev, "cover",
+						id, GPIOD_IN);
+	if (IS_ERR(slot->cover))
+		return dev_err_probe(host->dev, PTR_ERR(slot->cover),
+				     "error looking up cover switch GPIO\n");
+
 	host->slots[id] = slot;
 
 	mmc->caps = 0;
@@ -1349,6 +1384,13 @@ static int mmc_omap_probe(struct platform_device *pdev)
 	if (IS_ERR(host->virt_base))
 		return PTR_ERR(host->virt_base);
 
+	host->slot_switch = gpiod_get_optional(host->dev, "switch",
+					       GPIOD_OUT_LOW);
+	if (IS_ERR(host->slot_switch))
+		return dev_err_probe(host->dev, PTR_ERR(host->slot_switch),
+				     "error looking up slot switch GPIO\n");
+
+
 	INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work);
 	INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work);
 
diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
index 91051e9907f3..054d0c3c5ec5 100644
--- a/include/linux/platform_data/mmc-omap.h
+++ b/include/linux/platform_data/mmc-omap.h
@@ -20,8 +20,6 @@ struct omap_mmc_platform_data {
 	 * maximum frequency on the MMC bus */
 	unsigned int max_freq;
 
-	/* switch the bus to a new slot */
-	int (*switch_slot)(struct device *dev, int slot);
 	/* initialize board-specific MMC functionality, can be NULL if
 	 * not supported */
 	int (*init)(struct device *dev);

-- 
2.34.1


^ permalink raw reply related

* [PATCH v4 1/4] Input: ads7846 - Convert to use software nodes
From: Linus Walleij @ 2023-05-08 21:20 UTC (permalink / raw)
  To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mips,
	linux-input, linux-spi, linux-fbdev, dri-devel, linux-mmc,
	Linus Walleij
In-Reply-To: <20230430-nokia770-regression-v4-0-9b6dc5536b17@linaro.org>

The Nokia 770 is using GPIOs from the global numberspace on the
CBUS node to pass down to the LCD controller. This regresses when we
let the OMAP GPIO driver use dynamic GPIO base.

The Nokia 770 now has dynamic allocation of IRQ numbers, so this
needs to be fixed for it to work.

As this is the only user of LCD MIPID we can easily augment the
driver to use a GPIO descriptor instead and resolve the issue.

The platform data .shutdown() callback wasn't even used in the
code, but we encode a shutdown asserting RESET in the remove()
callback for completeness sake.

The CBUS also has the ADS7846 touchscreen attached.

Populate the devices on the Nokia 770 CBUS I2C using software
nodes instead of platform data quirks. This includes the LCD
and the ADS7846 touchscreen so the conversion just brings the LCD
along with it as software nodes is an all-or-nothing design
pattern.

The ADS7846 has some limited support for using GPIO descriptors,
let's convert it over completely to using device properties and then
fix all remaining boardfile users to provide all platform data using
software nodes.

Dump the of includes and of_match_ptr() in the ADS7846 driver as part
of the job.

Since we have to move ADS7846 over to obtaining the GPIOs it is
using exclusively from descriptors, we provide descriptor tables
for the two remaining in-kernel boardfiles using ADS7846:

- PXA Spitz
- MIPS Alchemy DB1000 development board

It was too hard for me to include software node conversion of
these two remaining users at this time: the spitz is using a
hscync callback in the platform data that would require further
GPIO descriptor conversion of the Spitz, and moving the hsync
callback down into the driver: it will just become too big of
a job, but it can be done separately.

The MIPS Alchemy DB1000 is simply something I cannot test, so take
the easier approach of just providing some GPIO descriptors in
this case as I don't want the patch to grow too intrusive.

As we see that several device trees have incorrect polarity flags
and just expect to bypass the gpiolib polarity handling, fix up
all device trees too, in a separate patch.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v3->v4:
- Fix all board file polarity flags to be active low, because
  this pendown signal is active low.
- Fix all erroneous device trees too.
- Drop some unnecessary commas.
ChangeLog v2->v3:
- Drop leftover OF ifdefs no longer needed and causing compile
  errors.
---
 arch/arm/mach-omap1/board-nokia770.c    |  98 +++++++++++++++++----------
 arch/arm/mach-pxa/spitz.c               |  11 +++-
 arch/mips/alchemy/devboards/db1000.c    |  11 +++-
 drivers/input/touchscreen/ads7846.c     | 113 ++++++++++++--------------------
 drivers/video/fbdev/omap/lcd_mipid.c    |  10 +++
 include/linux/platform_data/lcd-mipid.h |   2 -
 include/linux/spi/ads7846.h             |   2 -
 7 files changed, 135 insertions(+), 112 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index a501a473ffd6..8a1f2572deea 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -8,15 +8,16 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/input.h>
 #include <linux/omapfb.h>
 
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/workqueue.h>
 #include <linux/delay.h>
 
@@ -35,6 +36,25 @@
 #include "clock.h"
 #include "mmc.h"
 
+static const struct software_node nokia770_mpuio_gpiochip_node = {
+	.name = "mpuio",
+};
+
+static const struct software_node nokia770_gpiochip1_node = {
+	.name = "gpio-0-15",
+};
+
+static const struct software_node nokia770_gpiochip2_node = {
+	.name = "gpio-16-31",
+};
+
+static const struct software_node *nokia770_gpiochip_nodes[] = {
+	&nokia770_mpuio_gpiochip_node,
+	&nokia770_gpiochip1_node,
+	&nokia770_gpiochip2_node,
+	NULL
+};
+
 #define ADS7846_PENDOWN_GPIO	15
 
 static const unsigned int nokia770_keymap[] = {
@@ -85,40 +105,46 @@ static struct platform_device *nokia770_devices[] __initdata = {
 	&nokia770_kp_device,
 };
 
-static void mipid_shutdown(struct mipid_platform_data *pdata)
-{
-	if (pdata->nreset_gpio != -1) {
-		printk(KERN_INFO "shutdown LCD\n");
-		gpio_set_value(pdata->nreset_gpio, 0);
-		msleep(120);
-	}
-}
-
-static struct mipid_platform_data nokia770_mipid_platform_data = {
-	.shutdown = mipid_shutdown,
-};
+static struct mipid_platform_data nokia770_mipid_platform_data = { };
 
 static const struct omap_lcd_config nokia770_lcd_config __initconst = {
 	.ctrl_name	= "hwa742",
 };
 
+static const struct property_entry nokia770_mipid_props[] = {
+	PROPERTY_ENTRY_GPIO("reset-gpios", &nokia770_gpiochip1_node,
+			    13, GPIO_ACTIVE_LOW),
+	{ }
+};
+
+static const struct software_node nokia770_mipid_swnode = {
+	.name = "lcd_mipid",
+	.properties = nokia770_mipid_props,
+};
+
 static void __init mipid_dev_init(void)
 {
-	nokia770_mipid_platform_data.nreset_gpio = 13;
 	nokia770_mipid_platform_data.data_lines = 16;
 
 	omapfb_set_lcd_config(&nokia770_lcd_config);
 }
 
-static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
-	.x_max		= 0x0fff,
-	.y_max		= 0x0fff,
-	.x_plate_ohms	= 180,
-	.pressure_max	= 255,
-	.debounce_max	= 10,
-	.debounce_tol	= 3,
-	.debounce_rep	= 1,
-	.gpio_pendown	= ADS7846_PENDOWN_GPIO,
+static const struct property_entry nokia770_ads7846_props[] = {
+	PROPERTY_ENTRY_U32("touchscreen-size-x", 4096),
+	PROPERTY_ENTRY_U32("touchscreen-size-y", 4096),
+	PROPERTY_ENTRY_U32("touchscreen-max-pressure", 256),
+	PROPERTY_ENTRY_U32("touchscreen-average-samples", 10),
+	PROPERTY_ENTRY_U16("ti,x-plate-ohms", 180),
+	PROPERTY_ENTRY_U16("ti,debounce-tol", 3),
+	PROPERTY_ENTRY_U16("ti,debounce-rep", 1),
+	PROPERTY_ENTRY_GPIO("pendown-gpios", &nokia770_gpiochip1_node,
+			    ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW),
+	{ }
+};
+
+static const struct software_node nokia770_ads7846_swnode = {
+	.name = "ads7846",
+	.properties = nokia770_ads7846_props,
 };
 
 static struct spi_board_info nokia770_spi_board_info[] __initdata = {
@@ -128,13 +154,14 @@ static struct spi_board_info nokia770_spi_board_info[] __initdata = {
 		.chip_select    = 3,
 		.max_speed_hz   = 12000000,
 		.platform_data	= &nokia770_mipid_platform_data,
+		.swnode         = &nokia770_mipid_swnode,
 	},
 	[1] = {
 		.modalias       = "ads7846",
 		.bus_num        = 2,
 		.chip_select    = 0,
 		.max_speed_hz   = 2500000,
-		.platform_data	= &nokia770_ads7846_platform_data,
+		.swnode         = &nokia770_ads7846_swnode,
 	},
 };
 
@@ -212,14 +239,16 @@ static inline void nokia770_mmc_init(void)
 #endif
 
 #if IS_ENABLED(CONFIG_I2C_CBUS_GPIO)
-static struct gpiod_lookup_table nokia770_cbus_gpio_table = {
-	.dev_id = "i2c-cbus-gpio.2",
-	.table = {
-		GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */
-		GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */
-		GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */
-		{ },
-	},
+
+static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 9, 0),
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 10, 0),
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 11, 0),
+};
+
+static const struct property_entry nokia770_ads7846_props[] = {
+	PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
+	{ }
 };
 
 static struct platform_device nokia770_cbus_device = {
@@ -253,7 +282,8 @@ static void __init nokia770_cbus_init(void)
 	nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
 	i2c_register_board_info(2, nokia770_i2c_board_info_2,
 				ARRAY_SIZE(nokia770_i2c_board_info_2));
-	gpiod_add_lookup_table(&nokia770_cbus_gpio_table);
+	device_create_managed_software_node(&nokia770_cbus_device.dev,
+					    nokia770_cbus_props, NULL);
 	platform_device_register(&nokia770_cbus_device);
 }
 #else /* CONFIG_I2C_CBUS_GPIO */
@@ -273,8 +303,8 @@ static void __init omap_nokia770_init(void)
 	/* Unmask SleepX signal */
 	omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
 
+	software_node_register_node_group(nokia770_gpiochip_nodes);
 	platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
-	nokia770_spi_board_info[1].irq = gpio_to_irq(15);
 	spi_register_board_info(nokia770_spi_board_info,
 				ARRAY_SIZE(nokia770_spi_board_info));
 	omap_serial_init();
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 4325bdc2b9ff..28e376e06fdc 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -506,10 +506,18 @@ static struct ads7846_platform_data spitz_ads7846_info = {
 	.x_plate_ohms		= 419,
 	.y_plate_ohms		= 486,
 	.pressure_max		= 1024,
-	.gpio_pendown		= SPITZ_GPIO_TP_INT,
 	.wait_for_sync		= spitz_ads7846_wait_for_hsync,
 };
 
+static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
+	.dev_id = "spi2.0",
+	.table = {
+		GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
+			    "pendown", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static void spitz_bl_kick_battery(void)
 {
 	void (*kick_batt)(void);
@@ -594,6 +602,7 @@ static void __init spitz_spi_init(void)
 	else
 		gpiod_add_lookup_table(&spitz_lcdcon_gpio_table);
 
+	gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
 	gpiod_add_lookup_table(&spitz_spi_gpio_table);
 	pxa2xx_set_spi_info(2, &spitz_spi_info);
 	spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c
index 2c52ee27b4f2..79d66faa8482 100644
--- a/arch/mips/alchemy/devboards/db1000.c
+++ b/arch/mips/alchemy/devboards/db1000.c
@@ -381,13 +381,21 @@ static struct platform_device db1100_mmc1_dev = {
 static struct ads7846_platform_data db1100_touch_pd = {
 	.model		= 7846,
 	.vref_mv	= 3300,
-	.gpio_pendown	= 21,
 };
 
 static struct spi_gpio_platform_data db1100_spictl_pd = {
 	.num_chipselect = 1,
 };
 
+static struct gpiod_lookup_table db1100_touch_gpio_table = {
+	.dev_id = "spi0.0",
+	.table = {
+		GPIO_LOOKUP("alchemy-gpio2", 21,
+			    "pendown", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static struct spi_board_info db1100_spi_info[] __initdata = {
 	[0] = {
 		.modalias	 = "ads7846",
@@ -474,6 +482,7 @@ int __init db1000_dev_setup(void)
 		pfc |= (1 << 0);	/* SSI0 pins as GPIOs */
 		alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
 
+		gpiod_add_lookup_table(&db1100_touch_gpio_table);
 		spi_register_board_info(db1100_spi_info,
 					ARRAY_SIZE(db1100_spi_info));
 
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index bb1058b1e7fd..40eb27f1b23f 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -24,11 +24,8 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/pm.h>
-#include <linux/of.h>
-#include <linux/of_gpio.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 #include <linux/gpio/consumer.h>
-#include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/regulator/consumer.h>
@@ -140,7 +137,7 @@ struct ads7846 {
 	int			(*filter)(void *data, int data_idx, int *val);
 	void			*filter_data;
 	int			(*get_pendown_state)(void);
-	int			gpio_pendown;
+	struct gpio_desc	*gpio_pendown;
 
 	void			(*wait_for_sync)(void);
 };
@@ -223,7 +220,7 @@ static int get_pendown_state(struct ads7846 *ts)
 	if (ts->get_pendown_state)
 		return ts->get_pendown_state();
 
-	return !gpio_get_value(ts->gpio_pendown);
+	return gpiod_get_value(ts->gpio_pendown);
 }
 
 static void ads7846_report_pen_up(struct ads7846 *ts)
@@ -989,8 +986,6 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 				 struct ads7846 *ts,
 				 const struct ads7846_platform_data *pdata)
 {
-	int err;
-
 	/*
 	 * REVISIT when the irq can be triggered active-low, or if for some
 	 * reason the touchscreen isn't hooked up, we don't need to access
@@ -999,25 +994,15 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 
 	if (pdata->get_pendown_state) {
 		ts->get_pendown_state = pdata->get_pendown_state;
-	} else if (gpio_is_valid(pdata->gpio_pendown)) {
-
-		err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown,
-					    GPIOF_IN, "ads7846_pendown");
-		if (err) {
-			dev_err(&spi->dev,
-				"failed to request/setup pendown GPIO%d: %d\n",
-				pdata->gpio_pendown, err);
-			return err;
+	} else {
+		ts->gpio_pendown = gpiod_get(&spi->dev, "pendown", GPIOD_IN);
+		if (IS_ERR(ts->gpio_pendown)) {
+			dev_err(&spi->dev, "failed to request pendown GPIO\n");
+			return PTR_ERR(ts->gpio_pendown);
 		}
-
-		ts->gpio_pendown = pdata->gpio_pendown;
-
 		if (pdata->gpio_pendown_debounce)
-			gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
+			gpiod_set_debounce(ts->gpio_pendown,
 					   pdata->gpio_pendown_debounce);
-	} else {
-		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
-		return -EINVAL;
 	}
 
 	return 0;
@@ -1119,7 +1104,6 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
 	return 0;
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id ads7846_dt_ids[] = {
 	{ .compatible = "ti,tsc2046",	.data = (void *) 7846 },
 	{ .compatible = "ti,ads7843",	.data = (void *) 7843 },
@@ -1130,20 +1114,14 @@ static const struct of_device_id ads7846_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, ads7846_dt_ids);
 
-static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
+static const struct ads7846_platform_data *ads7846_get_props(struct device *dev)
 {
 	struct ads7846_platform_data *pdata;
-	struct device_node *node = dev->of_node;
-	const struct of_device_id *match;
+	const struct platform_device_id *pdev_id;
 	u32 value;
 
-	if (!node) {
-		dev_err(dev, "Device does not have associated DT data\n");
-		return ERR_PTR(-EINVAL);
-	}
-
-	match = of_match_device(ads7846_dt_ids, dev);
-	if (!match) {
+	pdev_id = device_get_match_data(dev);
+	if (!pdev_id) {
 		dev_err(dev, "Unknown device model\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -1152,60 +1130,51 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	if (!pdata)
 		return ERR_PTR(-ENOMEM);
 
-	pdata->model = (unsigned long)match->data;
+	pdata->model = (unsigned long)pdev_id->driver_data;
 
-	of_property_read_u16(node, "ti,vref-delay-usecs",
-			     &pdata->vref_delay_usecs);
-	of_property_read_u16(node, "ti,vref-mv", &pdata->vref_mv);
-	pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on");
+	device_property_read_u16(dev, "ti,vref-delay-usecs",
+				 &pdata->vref_delay_usecs);
+	device_property_read_u16(dev, "ti,vref-mv", &pdata->vref_mv);
+	pdata->keep_vref_on = device_property_read_bool(dev, "ti,keep-vref-on");
 
-	pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy");
+	pdata->swap_xy = device_property_read_bool(dev, "ti,swap-xy");
 
-	of_property_read_u16(node, "ti,settle-delay-usec",
-			     &pdata->settle_delay_usecs);
-	of_property_read_u16(node, "ti,penirq-recheck-delay-usecs",
-			     &pdata->penirq_recheck_delay_usecs);
+	device_property_read_u16(dev, "ti,settle-delay-usec",
+				 &pdata->settle_delay_usecs);
+	device_property_read_u16(dev, "ti,penirq-recheck-delay-usecs",
+				 &pdata->penirq_recheck_delay_usecs);
 
-	of_property_read_u16(node, "ti,x-plate-ohms", &pdata->x_plate_ohms);
-	of_property_read_u16(node, "ti,y-plate-ohms", &pdata->y_plate_ohms);
+	device_property_read_u16(dev, "ti,x-plate-ohms", &pdata->x_plate_ohms);
+	device_property_read_u16(dev, "ti,y-plate-ohms", &pdata->y_plate_ohms);
 
-	of_property_read_u16(node, "ti,x-min", &pdata->x_min);
-	of_property_read_u16(node, "ti,y-min", &pdata->y_min);
-	of_property_read_u16(node, "ti,x-max", &pdata->x_max);
-	of_property_read_u16(node, "ti,y-max", &pdata->y_max);
+	device_property_read_u16(dev, "ti,x-min", &pdata->x_min);
+	device_property_read_u16(dev, "ti,y-min", &pdata->y_min);
+	device_property_read_u16(dev, "ti,x-max", &pdata->x_max);
+	device_property_read_u16(dev, "ti,y-max", &pdata->y_max);
 
 	/*
 	 * touchscreen-max-pressure gets parsed during
 	 * touchscreen_parse_properties()
 	 */
-	of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
-	if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
+	device_property_read_u16(dev, "ti,pressure-min", &pdata->pressure_min);
+	if (!device_property_read_u32(dev, "touchscreen-min-pressure", &value))
 		pdata->pressure_min = (u16) value;
-	of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
+	device_property_read_u16(dev, "ti,pressure-max", &pdata->pressure_max);
 
-	of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
-	if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
+	device_property_read_u16(dev, "ti,debounce-max", &pdata->debounce_max);
+	if (!device_property_read_u32(dev, "touchscreen-average-samples", &value))
 		pdata->debounce_max = (u16) value;
-	of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
-	of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
+	device_property_read_u16(dev, "ti,debounce-tol", &pdata->debounce_tol);
+	device_property_read_u16(dev, "ti,debounce-rep", &pdata->debounce_rep);
 
-	of_property_read_u32(node, "ti,pendown-gpio-debounce",
+	device_property_read_u32(dev, "ti,pendown-gpio-debounce",
 			     &pdata->gpio_pendown_debounce);
 
-	pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
-			of_property_read_bool(node, "linux,wakeup");
-
-	pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
+	pdata->wakeup = device_property_read_bool(dev, "wakeup-source") ||
+			device_property_read_bool(dev, "linux,wakeup");
 
 	return pdata;
 }
-#else
-static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
-{
-	dev_err(dev, "no platform data defined\n");
-	return ERR_PTR(-EINVAL);
-}
-#endif
 
 static void ads7846_regulator_disable(void *regulator)
 {
@@ -1269,7 +1238,7 @@ static int ads7846_probe(struct spi_device *spi)
 
 	pdata = dev_get_platdata(dev);
 	if (!pdata) {
-		pdata = ads7846_probe_dt(dev);
+		pdata = ads7846_get_props(dev);
 		if (IS_ERR(pdata))
 			return PTR_ERR(pdata);
 	}
@@ -1426,7 +1395,7 @@ static struct spi_driver ads7846_driver = {
 	.driver = {
 		.name	= "ads7846",
 		.pm	= pm_sleep_ptr(&ads7846_pm),
-		.of_match_table = of_match_ptr(ads7846_dt_ids),
+		.of_match_table = ads7846_dt_ids,
 	},
 	.probe		= ads7846_probe,
 	.remove		= ads7846_remove,
diff --git a/drivers/video/fbdev/omap/lcd_mipid.c b/drivers/video/fbdev/omap/lcd_mipid.c
index 03cff39d392d..e4a7f0b824ff 100644
--- a/drivers/video/fbdev/omap/lcd_mipid.c
+++ b/drivers/video/fbdev/omap/lcd_mipid.c
@@ -7,6 +7,7 @@
  */
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
@@ -41,6 +42,7 @@ struct mipid_device {
 						   when we can issue the
 						   next sleep in/out command */
 	unsigned long	hw_guard_wait;		/* max guard time in jiffies */
+	struct gpio_desc	*reset;
 
 	struct omapfb_device	*fbdev;
 	struct spi_device	*spi;
@@ -556,6 +558,12 @@ static int mipid_spi_probe(struct spi_device *spi)
 		return -ENOMEM;
 	}
 
+	/* This will de-assert RESET if active */
+	md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(md->reset))
+		return dev_err_probe(&spi->dev, PTR_ERR(md->reset),
+				     "no reset GPIO line\n");
+
 	spi->mode = SPI_MODE_0;
 	md->spi = spi;
 	dev_set_drvdata(&spi->dev, md);
@@ -574,6 +582,8 @@ static void mipid_spi_remove(struct spi_device *spi)
 {
 	struct mipid_device *md = dev_get_drvdata(&spi->dev);
 
+	/* Asserts RESET */
+	gpiod_set_value(md->reset, 1);
 	mipid_disable(&md->panel);
 	kfree(md);
 }
diff --git a/include/linux/platform_data/lcd-mipid.h b/include/linux/platform_data/lcd-mipid.h
index 63f05eb23827..4927cfc5158c 100644
--- a/include/linux/platform_data/lcd-mipid.h
+++ b/include/linux/platform_data/lcd-mipid.h
@@ -15,10 +15,8 @@ enum mipid_test_result {
 #ifdef __KERNEL__
 
 struct mipid_platform_data {
-	int	nreset_gpio;
 	int	data_lines;
 
-	void	(*shutdown)(struct mipid_platform_data *pdata);
 	void	(*set_bklight_level)(struct mipid_platform_data *pdata,
 				     int level);
 	int	(*get_bklight_level)(struct mipid_platform_data *pdata);
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index d424c1aadf38..a04c1c34c344 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -35,8 +35,6 @@ struct ads7846_platform_data {
 	u16	debounce_tol;		/* tolerance used for filtering */
 	u16	debounce_rep;		/* additional consecutive good readings
 					 * required after the first two */
-	int	gpio_pendown;		/* the GPIO used to decide the pendown
-					 * state if get_pendown_state == NULL */
 	int	gpio_pendown_debounce;	/* platform specific debounce time for
 					 * the gpio_pendown */
 	int	(*get_pendown_state)(void);

-- 
2.34.1


^ permalink raw reply related

* [PATCH v4 0/4] Fix up Nokia 770 regression
From: Linus Walleij @ 2023-05-08 21:20 UTC (permalink / raw)
  To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mips,
	linux-input, linux-spi, linux-fbdev, dri-devel, linux-mmc,
	Linus Walleij

A recent change to use dynamic GPIO base allocation in the
OMAP GPIO driver caused a regression in some OMAP1 boards.
This series fixes up the Nokia 770 board from 2005:
https://en.wikipedia.org/wiki/Nokia_770_Internet_Tablet

I don't know how urgent the fix is, you decide. For me,
it is fair if fringe systems get fixed in due time, as
they are hardly anyones main development laptop.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v4:
- Fix up the polarity issues identified by Dmitry.
- Fix all erronous device trees as well.
- Link to v3: https://lore.kernel.org/r/20230430-nokia770-regression-v3-0-a6d0a89ffa8b@linaro.org

Changes in v3:
- Fix a compile error in the ADS7846 driver by dropping some
  leftover OF ifdeffery.
- Link to v2: https://lore.kernel.org/r/20230430-nokia770-regression-v2-0-984ed3ca5444@linaro.org

Changes in v2:
- Thoroughly rewrote the approach taken for the ADS7846 touchscreen
  following Dmitry's ambition to go a step further and take a swnode
  approach to this conversion: I'm fine with that, the patch just
  get a bit bigger.
- Picked up Ulf's ACK on the MMC patch.
- Link to v1: https://lore.kernel.org/r/20230430-nokia770-regression-v1-0-97704e36b094@linaro.org

---
Linus Walleij (4):
      Input: ads7846 - Convert to use software nodes
      ARM/mmc: Convert old mmci-omap to GPIO descriptors
      ARM: omap1: Fix up the Nokia 770 board device IRQs
      ARM: dts: Fix erroneous ADS touchscreen polarities

 arch/arm/boot/dts/am57xx-cl-som-am57x.dts          |   2 +-
 arch/arm/boot/dts/at91sam9261ek.dts                |   2 +-
 arch/arm/boot/dts/imx7d-pico-hobbit.dts            |   2 +-
 arch/arm/boot/dts/imx7d-sdb.dts                    |   2 +-
 arch/arm/boot/dts/omap3-cm-t3x.dtsi                |   2 +-
 arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi |   2 +-
 arch/arm/boot/dts/omap3-lilly-a83x.dtsi            |   2 +-
 arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi    |   2 +-
 arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi    |   2 +-
 arch/arm/boot/dts/omap3-pandora-common.dtsi        |   2 +-
 arch/arm/boot/dts/omap5-cm-t54.dts                 |   2 +-
 arch/arm/mach-omap1/board-nokia770.c               | 198 +++++++++++++--------
 arch/arm/mach-omap1/board-sx1-mmc.c                |   1 -
 arch/arm/mach-omap2/board-n8x0.c                   |  85 +++------
 arch/arm/mach-pxa/spitz.c                          |  11 +-
 arch/mips/alchemy/devboards/db1000.c               |  11 +-
 drivers/input/touchscreen/ads7846.c                | 113 +++++-------
 drivers/mmc/host/omap.c                            |  46 ++++-
 drivers/video/fbdev/omap/lcd_mipid.c               |  10 ++
 include/linux/platform_data/lcd-mipid.h            |   2 -
 include/linux/platform_data/mmc-omap.h             |   2 -
 include/linux/spi/ads7846.h                        |   2 -
 22 files changed, 273 insertions(+), 230 deletions(-)
---
base-commit: ac9a78681b921877518763ba0e89202254349d1b
change-id: 20230430-nokia770-regression-2b5a07497ec9

Best regards,
-- 
Linus Walleij <linus.walleij@linaro.org>


^ permalink raw reply

* Re: [PATCH v3 1/3] Input: ads7846 - Convert to use software nodes
From: Linus Walleij @ 2023-05-08 20:54 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson, linux-omap, linux-arm-kernel,
	linux-kernel, linux-mips, linux-input, linux-spi, linux-fbdev,
	dri-devel, linux-mmc
In-Reply-To: <ZFkSMBhw5UaWdpsM@surfacebook>

On Mon, May 8, 2023 at 5:16 PM <andy.shevchenko@gmail.com> wrote:
> Fri, May 05, 2023 at 01:16:55PM +0200, Linus Walleij kirjoitti:

> > The Nokia 770 is using GPIOs from the global numberspace on the
> > CBUS node to pass down to the LCD controller. This regresses when we
> > let the OMAP GPIO driver use dynamic GPIO base.
(...)

> >  #include <linux/gpio.h>
>
> Do we need it after this patch?

Yes, but it is finally removed in patch 3/3!

Fixed the rest, thanks!

Yours,
Linus Walleij

^ permalink raw reply

* Re: [BUG] Kmemleak, possibly hiddev_connect(), in 6.3.0+ torvalds tree commit gfc4354c6e5c2
From: Mirsad Goran Todorovac @ 2023-05-08 17:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mirsad Goran Todorovac
  Cc: linux-usb, linux-kernel, linux-input, Benjamin Tissoires,
	Jiri Kosina
In-Reply-To: <2023050854-collage-dreamt-660c@gregkh>

On 08. 05. 2023. 16:01, Greg Kroah-Hartman wrote:

> On Mon, May 08, 2023 at 08:51:55AM +0200, Greg Kroah-Hartman wrote:
>> On Mon, May 08, 2023 at 08:30:07AM +0200, Mirsad Goran Todorovac wrote:
>>> Hi,
>>>
>>> There seems to be a kernel memory leak in the USB keyboard driver.
>>>
>>> The leaked memory allocs are 96 and 512 bytes.
>>>
>>> The platform is Ubuntu 22.04 LTS on a assembled AMD Ryzen 9 with X670E PG
>>> Lightning mobo,
>>> and Genius SlimStar i220 GK-080012 keyboard.
>>>
>>> (Logitech M100 HID mouse is not affected by the bug.)
>>>
>>> BIOS is:
>>>
>>>       *-firmware
>>>            description: BIOS
>>>            vendor: American Megatrends International, LLC.
>>>            physical id: 0
>>>            version: 1.21
>>>            date: 04/26/2023
>>>            size: 64KiB
>>>
>>> The kernel is 6.3.0-torvalds-<id>-13466-gfc4354c6e5c2.
>>>
>>> The keyboard is recognised as Chicony:
>>>
>>>                   *-usb
>>>                        description: Keyboard
>>>                        product: CHICONY USB Keyboard
>>>                        vendor: CHICONY
>>>                        physical id: 2
>>>                        bus info: usb@5:2
>>>                        logical name: input35
>>>                        logical name: /dev/input/event4
>>>                        logical name: input35::capslock
>>>                        logical name: input35::numlock
>>>                        logical name: input35::scrolllock
>>>                        logical name: input36
>>>                        logical name: /dev/input/event5
>>>                        logical name: input37
>>>                        logical name: /dev/input/event6
>>>                        logical name: input38
>>>                        logical name: /dev/input/event8
>>>                        version: 2.30
>>>                        capabilities: usb-2.00 usb
>>>                        configuration: driver=usbhid maxpower=100mA
>>> speed=1Mbit/s
>>>
>>> The bug is easily reproduced by unplugging the USB keyboard, waiting about a
>>> couple of seconds,
>>> and then reconnect and scan for memory leaks twice.
>>>
>>> The kmemleak log is as follows [edited privacy info]:
>>>
>>> root@hostname:/home/username# cat /sys/kernel/debug/kmemleak
>>> unreferenced object 0xffff8dd020037c00 (size 96):
>>>    comm "systemd-udevd", pid 435, jiffies 4294892550 (age 8909.356s)
>>>    hex dump (first 32 bytes):
>>>      5d 8e 4e b9 ff ff ff ff 00 00 00 00 00 00 00 00 ].N.............
>>>      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
>>>    backtrace:
>>>      [<ffffffffb81a74be>] __kmem_cache_alloc_node+0x22e/0x2b0
>>>      [<ffffffffb8127b6e>] kmalloc_trace+0x2e/0xa0
>>>      [<ffffffffb87543d9>] class_create+0x29/0x80
>>>      [<ffffffffb8880d24>] usb_register_dev+0x1d4/0x2e0
>> As the call to class_create() in this path is now gone in 6.4-rc1, can
>> you retry that release to see if this is still there or not?
> No, wait, it's still there, I was looking at a development branch of
> mine that isn't sent upstream yet.  And syzbot just reported the same
> thing:
> 	https://lore.kernel.org/r/00000000000058d15f05fb264013@google.com
>
> So something's wrong here, let me dig into it tomorrow when I get a
> chance...

Hi,

I can confirm that the leak is still present in 6.4-rc1:

root@host:/home/user# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff9e6b57bd8ea0 (size 96):
   comm "systemd-udevd", pid 322, jiffies 4294892584 (age 123.516s)
   hex dump (first 32 bytes):
     a4 90 ee b6 ff ff ff ff 00 00 00 00 00 00 00 00 ................
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   backtrace:
     [<ffffffffb5ba74be>] __kmem_cache_alloc_node+0x22e/0x2b0
     [<ffffffffb5b27b6e>] kmalloc_trace+0x2e/0xa0
     [<ffffffffb6154959>] class_create+0x29/0x80
     [<ffffffffb62812a4>] usb_register_dev+0x1d4/0x2e0
     [<ffffffffc066ebab>] hiddev_connect+0x11b/0x1b0 [usbhid]
     [<ffffffffc0629d4e>] hid_connect+0xde/0x580 [hid]
     [<ffffffffc062a24c>] hid_hw_start+0x4c/0x70 [hid]
     [<ffffffffc05e8092>] hid_generic_probe+0x32/0x40 [hid_generic]
     [<ffffffffc062a450>] hid_device_probe+0x100/0x170 [hid]
     [<ffffffffb6152602>] really_probe+0x1b2/0x420
     [<ffffffffb61528fe>] __driver_probe_device+0x7e/0x170
     [<ffffffffb6152a23>] driver_probe_device+0x23/0xa0
     [<ffffffffb6152cc8>] __driver_attach+0xe8/0x1e0
     [<ffffffffb614fe6e>] bus_for_each_dev+0x7e/0xd0
     [<ffffffffb6151da2>] driver_attach+0x22/0x30
     [<ffffffffb61513f0>] bus_add_driver+0x120/0x220
unreferenced object 0xffff9e6b58d75800 (size 512):
   comm "systemd-udevd", pid 322, jiffies 4294892584 (age 123.516s)
   hex dump (first 32 bytes):
     00 58 d7 58 6b 9e ff ff 00 58 d7 58 6b 9e ff ff .X.Xk....X.Xk...
     00 00 00 00 00 00 00 00 a4 90 ee b6 ff ff ff ff ................
   backtrace:
     [<ffffffffb5ba74be>] __kmem_cache_alloc_node+0x22e/0x2b0
     [<ffffffffb5b27b6e>] kmalloc_trace+0x2e/0xa0
     [<ffffffffb6154812>] class_register+0x32/0x140
     [<ffffffffb6154974>] class_create+0x44/0x80
     [<ffffffffb62812a4>] usb_register_dev+0x1d4/0x2e0
     [<ffffffffc066ebab>] hiddev_connect+0x11b/0x1b0 [usbhid]
     [<ffffffffc0629d4e>] hid_connect+0xde/0x580 [hid]
     [<ffffffffc062a24c>] hid_hw_start+0x4c/0x70 [hid]
     [<ffffffffc05e8092>] hid_generic_probe+0x32/0x40 [hid_generic]
     [<ffffffffc062a450>] hid_device_probe+0x100/0x170 [hid]
     [<ffffffffb6152602>] really_probe+0x1b2/0x420
     [<ffffffffb61528fe>] __driver_probe_device+0x7e/0x170
     [<ffffffffb6152a23>] driver_probe_device+0x23/0xa0
     [<ffffffffb6152cc8>] __driver_attach+0xe8/0x1e0
     [<ffffffffb614fe6e>] bus_for_each_dev+0x7e/0xd0
     [<ffffffffb6151da2>] driver_attach+0x22/0x30
root@host:/home/user#

Would you need a bisect on this one? Maybe it would help.

Best regards,
Mirsad



^ permalink raw reply

* Re: [PATCH 0/4] Add haptics support to Nexus 5 using pwm-vibra driver
From: Dmitry Torokhov @ 2023-05-08 16:44 UTC (permalink / raw)
  To: Luca Weiss
  Cc: ~postmarketos/upstreaming, phone-devel, Rob Herring,
	Krzysztof Kozlowski, Sebastian Reichel, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Brian Masney, linux-input,
	devicetree, linux-kernel, linux-arm-msm
In-Reply-To: <20230427-hammerhead-vibra-v1-0-e87eeb94da51@z3ntu.xyz>

On Thu, Apr 27, 2023 at 10:34:25PM +0200, Luca Weiss wrote:
> A while ago Brian Masney sent some patches for a clk-vibrator which was
> then succeeded by the idea of a clk-pwm driver that "converts" a clock
> into a PWM and to use the existing pwm-vibra driver.
> 
> Since clk-pwm has landed last year we can finally add haptics support
> upstream.
> 
> We just need to add support for an enable GPIO to the pwm-vibra driver
> since that also needs to be high for the haptics to work on this device.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
> Luca Weiss (4):
>       dt-bindings: input: pwm-vibrator: Add enable-gpio
>       Input: pwm-vibra - add newline to dev_err prints
>       Input: pwm-vibra - add support for enable GPIO
>       ARM: dts: qcom: msm8974-hammerhead: Add vibrator

Applied patches 1-3, thank you.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v2 2/2] power: supply: remove unneeded include of linux/leds.h
From: Sebastian Reichel @ 2023-05-08 12:22 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Jiri Kosina, Benjamin Tissoires, linux-pm, linux-kernel,
	linux-input
In-Reply-To: <20230212-include-power_supply-leds-v2-2-e9910a3f5837@weissschuh.net>

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

Hi,

On Tue, May 02, 2023 at 06:28:45AM +0200, Thomas Weißschuh wrote:
> Instead of including the full linux/leds.h header file a single
> forward-declaration is enough.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---

Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  include/linux/power_supply.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index a427f13c757f..dc5e17e8c919 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -14,10 +14,11 @@
>  
>  #include <linux/device.h>
>  #include <linux/workqueue.h>
> -#include <linux/leds.h>
>  #include <linux/spinlock.h>
>  #include <linux/notifier.h>
>  
> +struct led_trigger;
> +
>  /*
>   * All voltages, currents, charges, energies, time and temperatures in uV,
>   * µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
> 
> -- 
> 2.40.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [regression] Bug 217394 - IRQ override skipping breaks the Aya Neo Air Plus 6800U keyboard buttons
From: Dmitry Torokhov @ 2023-05-08 15:17 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Thorsten Leemhuis, Limonciello, Mario,
	Linux regressions mailing list, Chuanhong Guo, linux-input,
	Rafael J. Wysocki, ACPI Devel Maling List, LKML
In-Reply-To: <f60edac7-8ba9-216e-568b-2fb2aeb72cfb@amd.com>

On Sun, May 07, 2023 at 07:45:01AM -0500, Mario Limonciello wrote:
> 
> On 5/6/23 01:47, Thorsten Leemhuis wrote:
> > On 03.05.23 21:00, Dmitry Torokhov wrote:
> > > On Wed, May 03, 2023 at 11:11:33AM -0500, Limonciello, Mario wrote:
> > > > On 5/3/2023 7:58 AM, Linux regression tracking (Thorsten Leemhuis) wrote:
> > > > > I noticed a regression report in bugzilla.kernel.org. As many (most?)
> > > > > kernel developers don't keep an eye on it, I decided to forward it by mail.
> > > > > 
> > > > > Chuanhong Guo, apparently it's cause by a change of yours.
> > BTW, there is another report caused by the change:
> > https://bugzilla.kernel.org/show_bug.cgi?id=217406
> > 
> > ```
> > I have an HP Pavilion Aero 13 laptop that comes with an AMD Ryzen 7735U
> > CPU and an up-to-date BIOS. Using any kernel version that is strictly
> > greater than 5.19.9 on it is causing the typing with the integrated
> > keyboard to be extremely slow. "Slow" is subjective but let's say [...]"
> > ```
> > 
> > /me wonders how many machines out there show problems we never hear about
> > 
> > Anyway:
> > 
> > > > > Note, you have to use bugzilla to reach the reporter, as I sadly[1] can
> > > > > not CCed them in mails like this.
> > > > > 
> > > > > Quoting from https://bugzilla.kernel.org/show_bug.cgi?id=217394 :
> > > > > 
> > > > > >    Matthew 2023-05-03 02:28:33 UTC
> > > > > > 
> > > > > > Reverting the changes found in this patch fixes the issue:
> > > > > > > https://lore.kernel.org/all/20220712020058.90374-1-gch981213@gmail.com/
> > > > > > With that patch the AT Translated Set 2 Keyboard doesn't show up with the evtest and is not usable.
> > > > > > 
> > > > > > Hardware:
> > > > > > 
> > > > > > Aya Neo Air Plus
> > > > > > AMD Ryzen 7 6800U
> > > > > See the ticket for more details.
> > > > > 
> > > > > BTW: there apparently is another IRQ override needed for a different
> > > > > machine. See https://bugzilla.kernel.org/show_bug.cgi?id=216804#c8 for
> > > > > details (ignore the comments before that, the quirk entry for that
> > > > > machine was merged; comment 8 and all related to it really should have a
> > > > > separate bug; that's also why this partly fall through the cracks here
> > > > > :-/ ). The user is currently trying to create a patch.
> > > > > 
> > > > Something I'm wondering about is if it's possible for i8042 to detect the
> > > > polarity is incorrect when it probes and
> > > > to try to correct it.
> > > > 
> > > > If we could do that we can probably drop 9946e39fe8d0 ("ACPI: resource: skip
> > > > IRQ override on AMD Zen platforms")
> > > > to fix this issue along with all the other quirks that have collected over
> > > > time on i8042 polarity issues.
> > > 8042 is shared between multiple platforms and is quite fragile as it is.
> > > If there are issues in AMD firmware and you know the polarity that is
> > > needed for 8042 on these platforms you should add a proper fixup for
> > > override. Maybe you should only skip override for IRQ 1?
> > Stupid question from the peanut gallery: does anyone know what Windows
> > is doing on those machines? I wonder if this is one of those situation
> > where we just must follow suite to make things work reliably long term
> > for users, even if that might mean 8042 needs to be modified.

Maybe Windows simply selects "falling edge" trigger in the driver? They
do not need to deal with multiple atchitectures, so it may work for
them.

> > 
> > Or is the problem likely to go away with new hardware?
> > 
> > Ciao, Thorsten
> > 
> > P.S.: BTW:
> > 
> > #regzbot link: https://bugzilla.kernel.org/show_bug.cgi?id=217406
> I've got the same question.  This issue doesn't happen in AMD's
> reference platform; it's not in AMD's firmware.
> It seems to be happening in some OEM platforms only.
> 
> Dmitry,
> 
> Can you think about what a polarity detection scheme would look
> like for i8042?  If it's put in the error path (device not responding to
> probe)
> I would think it should be relatively low risk to otherwise working
> hardware.

Mario, I feel strongly that this kind of kludges belong in the platform
handling code. If you know the polarity of keyboard interrupt on AMD
platforms and that it is sometimes described incorrectly in the firmware
you should fix it up in the code that deals with the firmware.

We have some code trying to test AUX interrupt and it has all kinds of
exceptions because many ECs do not implement AUX LOOP command properly,
on some the interrupt is not delivered for the LOOP command and so
forth. It is a disaster. I shudder to think about trying to use KBD
LOOP.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v3 3/3] ARM: omap1: Fix up the Nokia 770 board device IRQs
From: andy.shevchenko @ 2023-05-08 15:17 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson, linux-omap, linux-arm-kernel,
	linux-kernel, linux-mips, linux-input, linux-spi, linux-fbdev,
	dri-devel, linux-mmc
In-Reply-To: <20230430-nokia770-regression-v3-3-a6d0a89ffa8b@linaro.org>

Fri, May 05, 2023 at 01:16:57PM +0200, Linus Walleij kirjoitti:
> The platform devices on the Nokia 770 is using some
> board-specific IRQs that get statically assigned to platform
> devices in the boardfile.
> 
> This does not work with dynamic IRQ chip bases.
> 
> Utilize the NULL device to define some board-specific
> GPIO lookups and use these to immediately look up the
> same GPIOs, convert to IRQ numbers and pass as resources
> to the devices. This is ugly but should work.

...

> +static struct gpiod_lookup_table nokia770_irq_gpio_table = {
> +	.dev_id = NULL,
> +	.table = {
> +		/* GPIO used by SPI device 1 */
> +		GPIO_LOOKUP("gpio-0-15", 15, "ads7846_irq",
> +			    GPIO_ACTIVE_HIGH),
> +		/* GPIO used for retu IRQ */
> +		GPIO_LOOKUP("gpio-48-63", 15, "retu_irq",
> +			    GPIO_ACTIVE_HIGH),
> +		/* GPIO used for tahvo IRQ */
> +		GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
> +			    GPIO_ACTIVE_HIGH),

Missing terminator.

> +	},
> +};

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH v3 1/3] Input: ads7846 - Convert to use software nodes
From: andy.shevchenko @ 2023-05-08 15:16 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Thomas Bogendoerfer,
	Dmitry Torokhov, Mark Brown, Bartosz Golaszewski, Andreas Kemnade,
	Helge Deller, Ulf Hansson, linux-omap, linux-arm-kernel,
	linux-kernel, linux-mips, linux-input, linux-spi, linux-fbdev,
	dri-devel, linux-mmc
In-Reply-To: <20230430-nokia770-regression-v3-1-a6d0a89ffa8b@linaro.org>

Fri, May 05, 2023 at 01:16:55PM +0200, Linus Walleij kirjoitti:
> The Nokia 770 is using GPIOs from the global numberspace on the
> CBUS node to pass down to the LCD controller. This regresses when we
> let the OMAP GPIO driver use dynamic GPIO base.
> 
> The Nokia 770 now has dynamic allocation of IRQ numbers, so this
> needs to be fixed for it to work.
> 
> As this is the only user of LCD MIPID we can easily augment the
> driver to use a GPIO descriptor instead and resolve the issue.
> 
> The platform data .shutdown() callback wasn't even used in the
> code, but we encode a shutdown asserting RESET in the remove()
> callback for completeness sake.
> 
> The CBUS also has the ADS7846 touchscreen attached.
> 
> Populate the devices on the Nokia 770 CBUS I2C using software
> nodes instead of platform data quirks. This includes the LCD
> and the ADS7846 touchscreen so the conversion just brings the LCD
> along with it as software nodes is an all-or-nothing design
> pattern.
> 
> The ADS7846 has some limited support for using GPIO descriptors,
> let's convert it over completely to using device properties and then
> fix all remaining boardfile users to provide all platform data using
> software nodes.
> 
> Dump the of includes and of_match_ptr() in the ADS7846 driver as part
> of the job.
> 
> Since we have to move ADS7846 over to obtaining the GPIOs it is
> using exclusively from descriptors, we provide descriptor tables
> for the two remaining in-kernel boardfiles using ADS7846:
> 
> - PXA Spitz
> - MIPS Alchemy DB1000 development board
> 
> It was too hard for me to include software node conversion of
> these two remaining users at this time: the spitz is using a
> hscync callback in the platform data that would require further
> GPIO descriptor conversion of the Spitz, and moving the hsync
> callback down into the driver: it will just become too big of
> a job, but it can be done separately.
> 
> The MIPS Alchemy DB1000 is simply something I cannot test, so take
> the easier approach of just providing some GPIO descriptors in
> this case as I don't want the patch to grow too intrusive.

...

>  #include <linux/gpio.h>

Do we need it after this patch?

>  #include <linux/gpio/machine.h>
> +#include <linux/gpio/property.h>

...

> +static const struct software_node *nokia770_gpiochip_nodes[] = {
> +	&nokia770_mpuio_gpiochip_node,
> +	&nokia770_gpiochip1_node,
> +	&nokia770_gpiochip2_node,
> +	NULL,

Comma is redundant for the terminator entry.

> +};

...

> +static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
> +	.dev_id = "spi2.0",
> +	.table = {
> +		GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
> +			    "pendown", GPIO_ACTIVE_HIGH),
> +		{ },

Ditto.

> +	},
> +};

...

> +static struct gpiod_lookup_table db1100_touch_gpio_table = {
> +	.dev_id = "spi0.0",
> +	.table = {
> +		GPIO_LOOKUP("alchemy-gpio2", 21,
> +			    "pendown", GPIO_ACTIVE_HIGH),
> +		{ },

Ditto.

> +	},
> +};

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH] drivers: input: input: Fix possible sleep-in-atomic bug in input_alloc_absinfo()
From: Dmitry Torokhov @ 2023-05-08 15:01 UTC (permalink / raw)
  To: Teng Qi; +Cc: rydberg, linux-input, linux-kernel
In-Reply-To: <CALyQVay-_StW8ZghzF0DUp75UFZvssh-RcPC-DvHPgFLt0np=w@mail.gmail.com>

On Mon, May 08, 2023 at 03:13:19PM +0800, Teng Qi wrote:
> Thank you for an alternative solution. I will take a closer look at the
> patch
> you CCed me on.
> However, I am still confused about why this cannot happen in practice.
> Could you provide more information?

The only call to input_abs_set_val() in the event processing code that
is running in an atomic context (under spinlock) is done for
ABS_MT_SLOT, and the call is protected by checks ensuring that
multitouch was set up properly for the device. This includes allocating
absinfo. Therefore while the code may trip up static analyzers the
problem will not happen in practice with the current code.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [BUG] Kmemleak, possibly hiddev_connect(), in 6.3.0+ torvalds tree commit gfc4354c6e5c2
From: Greg Kroah-Hartman @ 2023-05-08 14:01 UTC (permalink / raw)
  To: Mirsad Goran Todorovac
  Cc: linux-usb, linux-kernel, linux-input, Benjamin Tissoires,
	Jiri Kosina
In-Reply-To: <2023050824-juiciness-catching-9290@gregkh>

On Mon, May 08, 2023 at 08:51:55AM +0200, Greg Kroah-Hartman wrote:
> On Mon, May 08, 2023 at 08:30:07AM +0200, Mirsad Goran Todorovac wrote:
> > Hi,
> > 
> > There seems to be a kernel memory leak in the USB keyboard driver.
> > 
> > The leaked memory allocs are 96 and 512 bytes.
> > 
> > The platform is Ubuntu 22.04 LTS on a assembled AMD Ryzen 9 with X670E PG
> > Lightning mobo,
> > and Genius SlimStar i220 GK-080012 keyboard.
> > 
> > (Logitech M100 HID mouse is not affected by the bug.)
> > 
> > BIOS is:
> > 
> >      *-firmware
> >           description: BIOS
> >           vendor: American Megatrends International, LLC.
> >           physical id: 0
> >           version: 1.21
> >           date: 04/26/2023
> >           size: 64KiB
> > 
> > The kernel is 6.3.0-torvalds-<id>-13466-gfc4354c6e5c2.
> > 
> > The keyboard is recognised as Chicony:
> > 
> >                  *-usb
> >                       description: Keyboard
> >                       product: CHICONY USB Keyboard
> >                       vendor: CHICONY
> >                       physical id: 2
> >                       bus info: usb@5:2
> >                       logical name: input35
> >                       logical name: /dev/input/event4
> >                       logical name: input35::capslock
> >                       logical name: input35::numlock
> >                       logical name: input35::scrolllock
> >                       logical name: input36
> >                       logical name: /dev/input/event5
> >                       logical name: input37
> >                       logical name: /dev/input/event6
> >                       logical name: input38
> >                       logical name: /dev/input/event8
> >                       version: 2.30
> >                       capabilities: usb-2.00 usb
> >                       configuration: driver=usbhid maxpower=100mA
> > speed=1Mbit/s
> > 
> > The bug is easily reproduced by unplugging the USB keyboard, waiting about a
> > couple of seconds,
> > and then reconnect and scan for memory leaks twice.
> > 
> > The kmemleak log is as follows [edited privacy info]:
> > 
> > root@hostname:/home/username# cat /sys/kernel/debug/kmemleak
> > unreferenced object 0xffff8dd020037c00 (size 96):
> >   comm "systemd-udevd", pid 435, jiffies 4294892550 (age 8909.356s)
> >   hex dump (first 32 bytes):
> >     5d 8e 4e b9 ff ff ff ff 00 00 00 00 00 00 00 00 ].N.............
> >     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> >   backtrace:
> >     [<ffffffffb81a74be>] __kmem_cache_alloc_node+0x22e/0x2b0
> >     [<ffffffffb8127b6e>] kmalloc_trace+0x2e/0xa0
> >     [<ffffffffb87543d9>] class_create+0x29/0x80
> >     [<ffffffffb8880d24>] usb_register_dev+0x1d4/0x2e0
> 
> As the call to class_create() in this path is now gone in 6.4-rc1, can
> you retry that release to see if this is still there or not?

No, wait, it's still there, I was looking at a development branch of
mine that isn't sent upstream yet.  And syzbot just reported the same
thing:
	https://lore.kernel.org/r/00000000000058d15f05fb264013@google.com

So something's wrong here, let me dig into it tomorrow when I get a
chance...

thanks,

greg k-h

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox