Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp31303lqf; Tue, 26 Mar 2024 13:19:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXY4RkPj+q6glNgwbCp9Nxrt6/A0NoPXmX8Zq36a1l55DqpCbo/LzRhiZoP5OQrdWLWF3jHNR1abU53/u5l1AMDns5RElJWsPjBbQXnw== X-Google-Smtp-Source: AGHT+IE4RpqGPHEqoZbS50fUsWNO0qxGanvQGm2ScZItQ44FRUHAUZiQmwwwWNE9gJjI85NgnCm2 X-Received: by 2002:a05:6a20:d807:b0:1a3:aa1f:4ce8 with SMTP id iv7-20020a056a20d80700b001a3aa1f4ce8mr2660940pzb.53.1711484393249; Tue, 26 Mar 2024 13:19:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711484393; cv=pass; d=google.com; s=arc-20160816; b=z5G5XRsN/FmMzFG8h5UZn2kHsGuUGLU8+OBe9qLHfat9g8DpAaYFdzTpcEh5dyt3WN C/PEKiuEzxAnucOZRXKNWD0iqnjReKI0YY/nEYoIqJ+FWqov009i4W5mj1aXih7L/jYo XJovLznn/QWqH3EWwh13DwKEuO36p8gxtEYeU9JktXy/qgD/4arozgxPmtW++06/BqoK JDbMxFOSJHWvyonUx1FzeefVFZsOlZKUp0z2/JGYo32TNTN8MGaI9AIfd3bmvwTiMHZq OXfT7W7CSYROw9BDSKl4XKoJnItSeG+vv7Ix9Wgbq3fUwL2u5XxxUt429FbNbfLGTBKA oung== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=iGTSsX93dvRHkGyPXPVZGiSgM6ztYpSq86uvj2mmT7M=; fh=PSqy2ZoKXxDSUh7CscPzOH26BIRwV8zVyVlNQPrGFxs=; b=VAT6IVa/NgFHFhN1UD8eCVPqmT1fl3RtWjey5xtt5co1C9SgCnSJtU6UJmZCjufoss rh05CdzunhVsYBjiCFxQKfCGU5DAAPqhkueO62X554dUTg6KTv2IK8a1I+rQ2ZZ8QdKh 5mGfrAmIXfrHOdoXgNduIZYX7Wz2Z1ukhTT3W9mfBTd9Ri2UiVKNPTaSL7esjf8JAsrW 6S3SQsLMWjqkmlQ+akzo4TWFpWA5ybYVuDU47wCP969L2MuCev5XcGix+l/hWYvicGYP bVnBKYdAkvUifahCBkW8/cRt83xSa2yncT4CJ4YcncXS1AFQ9DdqH3fbvzu46Ku+2eQ7 MNtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=ek8XSzD3; arc=pass (i=1 spf=pass spfdomain=alliedtelesis.co.nz dkim=pass dkdomain=alliedtelesis.co.nz dmarc=pass fromdomain=alliedtelesis.co.nz); spf=pass (google.com: domain of linux-kernel+bounces-119850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s141-20020a632c93000000b005e49cd9099bsi10409594pgs.739.2024.03.26.13.19.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 13:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=ek8XSzD3; arc=pass (i=1 spf=pass spfdomain=alliedtelesis.co.nz dkim=pass dkdomain=alliedtelesis.co.nz dmarc=pass fromdomain=alliedtelesis.co.nz); spf=pass (google.com: domain of linux-kernel+bounces-119850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7CA97B23EC4 for ; Tue, 26 Mar 2024 19:59:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C6B113D285; Tue, 26 Mar 2024 19:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="ek8XSzD3" Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCBE513D265 for ; Tue, 26 Mar 2024 19:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711483182; cv=none; b=UaPqdBM2HfL+3VPrtYXoaylKuff2wjOsMDa1QShRUoqJYkJwbwlseVkX27Du2jOXD9Z6JxyAtv3G9kq/FgyeIKMa4jNEMbGrzvHNmkRgN8VQzRL8WgJEP2aswd2cgYqBMI+2S+TmEYJpClrtnku+RAC/wDL/MUotbyeB/HtnlVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711483182; c=relaxed/simple; bh=uSY/5yUXpFhF37jtWsUF8uCAWH6WjFmsLCA3CUa7tYU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OTbtYWKOVmu4xdxZSJn6Xo764spQNQ0g/3hjieqRUhwb4+AVKJ5K+5TzTU0ocoKVT1OVzfVr+nWO1QL8QPl7T3cg8V5mXjjNrJMZ/wgZJcrf8rpkLj3AcINPUfY8RmLck4ot8weAY4UNLawBKn6SE/CmFFgBoZMDEnWF6G2z8S4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=ek8XSzD3; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 260CE2C02AF; Wed, 27 Mar 2024 08:59:30 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1711483170; bh=iGTSsX93dvRHkGyPXPVZGiSgM6ztYpSq86uvj2mmT7M=; h=From:To:Cc:Subject:Date:From; b=ek8XSzD3sbFT0pHnnuCVZMALK6ahKcLXLYTX9VOxHAE4zwWqxP7UAK+f32bfTJU3h GunD0fPAf9mmtbH76wqKw+U4flXHWHLyV3W1zumQXeaQR/aLT7LFZ343YFKnjUZGyh 9UsH/q9IHPHK5kI54N+gD6dKrGoTKU208nJcNsp7KiYHa/QUwGGHd6IRqikaF18dA5 FAfvaSPr4ycZ4Y8JG7jfRrKw2grXekDTMTQZYynxKzDYX16gFixAp3nURQPJaWvdWd 5p8sbr4NSlXnySgiDDixlb+Zn78vGBBXeSv3Uw8k6DcLd8+tU/OgpP5GemKMJU0Ujn UW6YPgbR5ouEA== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Wed, 27 Mar 2024 08:59:29 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id DAFFD13ED7B; Wed, 27 Mar 2024 08:59:29 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id D437E280A3F; Wed, 27 Mar 2024 08:59:29 +1300 (NZDT) From: Chris Packham To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH] uio: use threaded interrupts Date: Wed, 27 Mar 2024 08:59:27 +1300 Message-ID: <20240326195927.3265297-1-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.4 cv=KIH5D0Fo c=1 sm=1 tr=0 ts=66032921 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=K6JAEmCyrfEA:10 a=J0zaVX0nx6ystpX9sXEA:9 a=3ZKOabzyN94A:10 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Split the existing uio_interrupt into a hardirq handler and a thread function. The hardirq handler deals with the interrupt source in hardware, the thread function notifies userspace that there is an event to be handled. Signed-off-by: Chris Packham --- Notes: I find myself needing to have a UIO interrupt associated with an interrupt pin on a PCA9539 (yes I know, it's a terrible chip but HW engineers love it because it's cheap). =20 Prior to this the UIO registration fails with: =20 [ 6.484699] uio_pdrv_genirq detect-gpio-9: unable to register ui= o device [ 6.484722] uio_pdrv_genirq detect-gpio-9: probe with driver uio= _pdrv_genirq failed with error -22 =20 The -EINVAL ultimately comes from __setup_irq() where it knows the interrupt descriptor is nested but we haven't provided a thread_fn. drivers/uio/uio.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index bb77de6fa067..a86cf2e4f200 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -442,18 +442,27 @@ EXPORT_SYMBOL_GPL(uio_event_notify); * @irq: IRQ number, can be UIO_IRQ_CYCLIC for cyclic timer * @dev_id: Pointer to the devices uio_device structure */ -static irqreturn_t uio_interrupt(int irq, void *dev_id) +static irqreturn_t uio_interrupt_handler(int irq, void *dev_id) { struct uio_device *idev =3D (struct uio_device *)dev_id; irqreturn_t ret; =20 ret =3D idev->info->handler(irq, idev->info); if (ret =3D=3D IRQ_HANDLED) - uio_event_notify(idev->info); + ret =3D IRQ_WAKE_THREAD; =20 return ret; } =20 +static irqreturn_t uio_interrupt_thread(int irq, void *dev_id) +{ + struct uio_device *idev =3D (struct uio_device *)dev_id; + + uio_event_notify(idev->info); + + return IRQ_HANDLED; +} + struct uio_listener { struct uio_device *dev; s32 event_count; @@ -1024,8 +1033,8 @@ int __uio_register_device(struct module *owner, * FDs at the time of unregister and therefore may not be * freed until they are released. */ - ret =3D request_irq(info->irq, uio_interrupt, - info->irq_flags, info->name, idev); + ret =3D request_threaded_irq(info->irq, uio_interrupt_handler, uio_int= errupt_thread, + info->irq_flags, info->name, idev); if (ret) { info->uio_dev =3D NULL; goto err_request_irq; --=20 2.43.2