<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/comedi, branch v6.8</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2024-03-05T14:21:45Z</updated>
<entry>
<title>comedi: comedi_test: Prevent timers rescheduling during deletion</title>
<updated>2024-03-05T14:21:45Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2024-02-14T10:07:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f53641a6e849034a44bf80f50245a75d7a376025'/>
<id>urn:sha1:f53641a6e849034a44bf80f50245a75d7a376025</id>
<content type='text'>
The comedi_test devices have a couple of timers (ai_timer and ao_timer)
that can be started to simulate hardware interrupts.  Their expiry
functions normally reschedule the timer.  The driver code calls either
del_timer_sync() or del_timer() to delete the timers from the queue, but
does not currently prevent the timers from rescheduling themselves so
synchronized deletion may be ineffective.

Add a couple of boolean members (one for each timer: ai_timer_enable and
ao_timer_enable) to the device private data structure to indicate
whether the timers are allowed to reschedule themselves.  Set the member
to true when adding the timer to the queue, and to false when deleting
the timer from the queue in the waveform_ai_cancel() and
waveform_ao_cancel() functions.

The del_timer_sync() function is also called from the waveform_detach()
function, but the timer enable members will already be set to false when
that function is called, so no change is needed there.

Fixes: 403fe7f34e33 ("staging: comedi: comedi_test: fix timer race conditions")
Cc: stable@vger.kernel.org # 4.4+
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20240214100747.16203-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: comedi_8255: Correct error in subdevice initialization</title>
<updated>2024-03-05T14:21:42Z</updated>
<author>
<name>Frej Drejhammar</name>
<email>frej.drejhammar@gmail.com</email>
</author>
<published>2024-02-11T17:58:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cfa9ba1ae0bef0681833a22d326174fe633caab5'/>
<id>urn:sha1:cfa9ba1ae0bef0681833a22d326174fe633caab5</id>
<content type='text'>
The refactoring done in commit 5c57b1ccecc7 ("comedi: comedi_8255: Rework
subdevice initialization functions") to the initialization of the io
field of struct subdev_8255_private broke all cards using the
drivers/comedi/drivers/comedi_8255.c module.

Prior to 5c57b1ccecc7, __subdev_8255_init() initialized the io field
in the newly allocated struct subdev_8255_private to the non-NULL
callback given to the function, otherwise it used a flag parameter to
select between subdev_8255_mmio and subdev_8255_io. The refactoring
removed that logic and the flag, as subdev_8255_mm_init() and
subdev_8255_io_init() now explicitly pass subdev_8255_mmio and
subdev_8255_io respectively to __subdev_8255_init(), only
__subdev_8255_init() never sets spriv-&gt;io to the supplied
callback. That spriv-&gt;io is NULL leads to a later BUG:

BUG: kernel NULL pointer dereference, address: 0000000000000000
PGD 0 P4D 0
Oops: 0010 [#1] SMP PTI
CPU: 1 PID: 1210 Comm: systemd-udevd Not tainted 6.7.3-x86_64 #1
Hardware name: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RIP: 0010:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
RSP: 0018:ffffa3f1c02d7b78 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff91f847aefd00 RCX: 000000000000009b
RDX: 0000000000000003 RSI: 0000000000000001 RDI: ffff91f840f6fc00
RBP: ffff91f840f6fc00 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 000000000000005f R12: 0000000000000000
R13: 0000000000000000 R14: ffffffffc0102498 R15: ffff91f847ce6ba8
FS:  00007f72f4e8f500(0000) GS:ffff91f8d5c80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 000000010540e000 CR4: 00000000000406f0
Call Trace:
 &lt;TASK&gt;
 ? __die_body+0x15/0x57
 ? page_fault_oops+0x2ef/0x33c
 ? insert_vmap_area.constprop.0+0xb6/0xd5
 ? alloc_vmap_area+0x529/0x5ee
 ? exc_page_fault+0x15a/0x489
 ? asm_exc_page_fault+0x22/0x30
 __subdev_8255_init+0x79/0x8d [comedi_8255]
 pci_8255_auto_attach+0x11a/0x139 [8255_pci]
 comedi_auto_config+0xac/0x117 [comedi]
 ? __pfx___driver_attach+0x10/0x10
 pci_device_probe+0x88/0xf9
 really_probe+0x101/0x248
 __driver_probe_device+0xbb/0xed
 driver_probe_device+0x1a/0x72
 __driver_attach+0xd4/0xed
 bus_for_each_dev+0x76/0xb8
 bus_add_driver+0xbe/0x1be
 driver_register+0x9a/0xd8
 comedi_pci_driver_register+0x28/0x48 [comedi_pci]
 ? __pfx_pci_8255_driver_init+0x10/0x10 [8255_pci]
 do_one_initcall+0x72/0x183
 do_init_module+0x5b/0x1e8
 init_module_from_file+0x86/0xac
 __do_sys_finit_module+0x151/0x218
 do_syscall_64+0x72/0xdb
 entry_SYSCALL_64_after_hwframe+0x6e/0x76
RIP: 0033:0x7f72f50a0cb9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 &lt;48&gt; 3d 01 f0 ff ff 73 01 c3 48 8b 0d 47 71 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffd47e512d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 0000562dd06ae070 RCX: 00007f72f50a0cb9
RDX: 0000000000000000 RSI: 00007f72f52d32df RDI: 000000000000000e
RBP: 0000000000000000 R08: 00007f72f5168b20 R09: 0000000000000000
R10: 0000000000000050 R11: 0000000000000246 R12: 00007f72f52d32df
R13: 0000000000020000 R14: 0000562dd06785c0 R15: 0000562dcfd0e9a8
 &lt;/TASK&gt;
Modules linked in: 8255_pci(+) comedi_8255 comedi_pci comedi intel_gtt e100(+) acpi_cpufreq rtc_cmos usbhid
CR2: 0000000000000000
---[ end trace 0000000000000000 ]---
RIP: 0010:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
RSP: 0018:ffffa3f1c02d7b78 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff91f847aefd00 RCX: 000000000000009b
RDX: 0000000000000003 RSI: 0000000000000001 RDI: ffff91f840f6fc00
RBP: ffff91f840f6fc00 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 000000000000005f R12: 0000000000000000
R13: 0000000000000000 R14: ffffffffc0102498 R15: ffff91f847ce6ba8
FS:  00007f72f4e8f500(0000) GS:ffff91f8d5c80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 000000010540e000 CR4: 00000000000406f0

This patch simply corrects the above mistake by initializing spriv-&gt;io
to the given io callback.

Fixes: 5c57b1ccecc7 ("comedi: comedi_8255: Rework subdevice initialization functions")
Signed-off-by: Frej Drejhammar &lt;frej.drejhammar@gmail.com&gt;
Cc: stable@vger.kernel.org
Acked-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Reviewed-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20240211175822.1357-1-frej.drejhammar@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers/comedi: use standard array-copy-function</title>
<updated>2023-12-07T02:08:45Z</updated>
<author>
<name>Philipp Stanner</name>
<email>pstanner@redhat.com</email>
</author>
<published>2023-11-03T11:29:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a070830096e44ddaa64931d831f07e944d920c79'/>
<id>urn:sha1:a070830096e44ddaa64931d831f07e944d920c79</id>
<content type='text'>
comedi_fops.c utilizes memdup_user() to copy a userspace array.

The new function memdup_array_user() provides a standardized way to copy
userspace-arrays. It makes it easier to see that an array is being
copied and, additionally, performs a generic overflow-check which might
help make the code more robust in case of changes in the future.

Replace memdup_user() with memdup_array_user().

Suggested-by: Dave Airlie &lt;airlied@redhat.com&gt;
Signed-off-by: Philipp Stanner &lt;pstanner@redhat.com&gt;
Reviewed-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20231103112932.75795-2-pstanner@redhat.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: add HAS_IOPORT dependencies again</title>
<updated>2023-10-05T11:34:05Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e6c1ccaa711aeca0191f9d9f036e688a2c52ab8c'/>
<id>urn:sha1:e6c1ccaa711aeca0191f9d9f036e688a2c52ab8c</id>
<content type='text'>
In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
not being declared. We thus need to add HAS_IOPORT as dependency for
those drivers using them.

This was previously done in commit b5c75b68b7de ("comedi: add HAS_IOPORT
dependencies"), but that has been reverted because it made it impossible
to select configuration options for several comedi drivers.  This is a
do-over that avoids that.

Since the original patch, modifications have been made to various comedi
modules so that they can still be built even if the port I/O functions
have not been declared, so the configuration options for building those
modules no longer need to depend on HAS_IOPORT.

Make the COMEDI_ISA_DRIVERS menu option (which allows configuration
options for ISA and PC/104 drivers to be selected) depend on HAS_IOPORT,
and also depend on ISA || ISA_BUS || PC104.

Co-developed-by: Arnd Bergmann &lt;arnd@kernel.org&gt;
Signed-off-by: Arnd Bergmann &lt;arnd@kernel.org&gt;
Co-developed-by: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-14-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: amplc_dio200_common: Conditionally remove I/O port support</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=88dd4797746ff93093728a48dd9a88cff95f4ca0'/>
<id>urn:sha1:88dd4797746ff93093728a48dd9a88cff95f4ca0</id>
<content type='text'>
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends will only be declared in the `HAS_IOPORT` configuration option
is enabled.

The amplc_dio200_common module is used by the amplc_dio200 module (for
ISA cards) and the amplc_dio200_pci module (for PCI and PCI Express
cards).  It supports both port I/O and memory-mapped I/O.

Port I/O and memory-mapped I/O is confined to the `dio200___read8()`,
`dio200___read32()`, `dio200___write8()` and `dio200___write32()`
functions.  Conditionally compile two versions of those functions.  If
the `CONFIG_HAS_IOPORT` macro is defined, call either the port I/O or
memory mapped I/O functions depending on the `mmio` member of the
`struct comedi_device`.  If the `CONFIG_HAS_IOPORT` macro is undefined
only call the memory-mapped I/O functions.

Add a run-time check to `amplc_dio200_common_attach()` to return an
error if the device wants to use port I/O when the `CONFIG_HAS_IOPORT`
macro is undefined.

The changes allow the module to be built even if the port I/O functions
have not been declared.

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-13-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: amplc_dio200_common: Refactor register access functions</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a3f2b80847e2b4dd7180872e69b84d515174c236'/>
<id>urn:sha1:a3f2b80847e2b4dd7180872e69b84d515174c236</id>
<content type='text'>
The `dio200_read8()`, `dio200_write8()`, `dio200_read32()` and
`dio200_write32()` functions apply a right-shift to the register offset
for some devices and then perform the actual register access.  Factor
the register access part out to new functions `dio200___read8()`,
`dio200___write8()`, `dio200___read32()`, and `dio200___write32()`.
This will reduce duplicated code in a subsequent patch that will
conditionally compile support for port I/O as part of the `HAS_IOPORT`
changes.

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-12-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: amplc_dio200_pci: Conditionally remove devices that use port I/O</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=772dcada0e733a567ad90cca7165c5fef2a1171c'/>
<id>urn:sha1:772dcada0e733a567ad90cca7165c5fef2a1171c</id>
<content type='text'>
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends will only be declared in the `HAS_IOPORT` configuration option
is enabled.

The amplc_dio200_pci module supports various Amplicon PCI and PCI
Express devices.  Some of the supported devices (the PCI ones) use port
I/O, and some of them (the PCIe ones) only use memory-mapped I/O.

Conditionally compile in support for the devices that need port I/O if
and only if the `CONFIG_HAS_IOPORT` macro is defined.

Add a run-time check in `dio200_pci_auto_attach()` to return an error if
the device actually requires port I/O (based on the PCI BAR resource
flags) but the `HAS_IOPORT` configuration option is not enabled.

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-11-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: ni_mio_common: Conditionally use I/O port or MMIO</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4e1bd6724b854808aa3b94f17f5c27da59a34ff4'/>
<id>urn:sha1:4e1bd6724b854808aa3b94f17f5c27da59a34ff4</id>
<content type='text'>
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends will only be declared in the `HAS_IOPORT` configuration option
is enabled.

The "ni_mio_common.c" file contains calls to both port I/O functions and
memory-mapped I/O functions.  The file is `#include`d by "ni_atmio.c",
"ni_mio_cs.c", and "ni_pcimio.c" for the ni_atmio, ni_mio_cs, and
ni_pcimio modules, respectively.  Only "ni_pcimio.c" defines the
`PCIDMA` macro before including "ni_mio_common.c" and various bits of
code in "ni_mio_common.c" is conditionally compiled according to whether
that macro is defined or not.  Currently, the port I/O function calls
are compiled in regardless of whether the `PCIDMA` macro is defined or
not.  However, the fact is that the ni_atmio and ni_mio_cs modules will
never call the memory-mapped I/O functions, and the ni_pcimio module
will never call the port I/O functions.

Calls to the port I/O and memory-mapped I/O functions is confined to the
`ni_writel()`, `ni_writew()`, `ni_writeb()`, `ni_readl()`, `ni_readw()`,
and `ni_readb()` functions which do a run-time test to decide whether to
call the port I/O functions or the memory-mapped I/O functions.
Conditionally compile two variants of the functions so they only call
the port I/O functions if the `PCIDMA` macro is undefined (for the
ni_atmio and ni_mio_cs modules), and only call the memory-mapped I/O
functions if the `PCIDMA` macro is defined (for the ni_pcimio module).

Add a run-time check in the `ni_E_init()` function to return an error if
the comedi device has been set up to use port I/O if `PCIDMA` is
defined, or has been set up to use memory-mapped I/O if `PCIDMA` is not
defined.

The changes make it possible to build the ni_pcimio module even if the
port I/O functions have not been declared.  (The ni_atmio and ni_mio_cs
modules do still require the port I/O functions to be declared.)

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-10-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: ni_labpc_common: Conditionally remove I/O port support</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a7b9ffd8c208d5911ba44a31e65d7c40400bbebd'/>
<id>urn:sha1:a7b9ffd8c208d5911ba44a31e65d7c40400bbebd</id>
<content type='text'>
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends will only be declared in the `HAS_IOPORT` configuration option
is enabled.

The ni_labpc_common module is used by the ni_labpc module (for ISA
cards), the ni_labpc_cs module (for PCMCIA cards), and the ni_labpc_pci
module (for PCI cards).  The ISA and PCMCIA cards use port I/O and the
PCI cards use memory-mapped I/O.

Conditionally compile the parts of the module that use the port I/O
functions so they are compiled if and only if the `CONFIG_HAS_IOPORT`
macro is defined, so that the module can be built if the port I/O
functions have not been declared.

Add a run-time check in the `labpc_common_attach()` to return an error
if the comedi device wants to use port I/O when the `CONFIG_HAS_IOPORT`
macro is undefined.

The changes allow the module to be built even if the port I/O functions
have not been declared.

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-9-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>comedi: comedi_8255: Conditionally remove I/O port support</title>
<updated>2023-10-05T11:34:04Z</updated>
<author>
<name>Ian Abbott</name>
<email>abbotti@mev.co.uk</email>
</author>
<published>2023-09-13T17:07:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7187a0939a1773e6a2663a02a6c456047a5e6289'/>
<id>urn:sha1:7187a0939a1773e6a2663a02a6c456047a5e6289</id>
<content type='text'>
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends will only be declared in the `HAS_IOPORT` configuration option
is enabled.

The comedi_8255 module supports both port I/O and memory-mapped I/O.

Conditionally compile the parts of the module that use port I/O if and
only if the `CONFIG_HAS_IOPORT` macro is defined so that it can still be
built if the port I/O functions have not been declared.  If the
`CONFIG_HAS_IOPORT` macro is undefined, replace the GPL-exported
`subdev_8255_io_init()` function with a dummy static inline version that
just returns `-ENXIO`.

Cc: Arnd Bergmann &lt;arnd@kernel.org&gt;
Cc: Niklas Schnelle &lt;schnelle@linux.ibm.com&gt;
Signed-off-by: Ian Abbott &lt;abbotti@mev.co.uk&gt;
Link: https://lore.kernel.org/r/20230913170712.111719-8-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
