[PATCH] drivers: staging: comedi: fix function prototypes
Add names of parameters to function prototypes in comedi PCI. Checkpatch reports now no errors. Signed-off-by: Piotr Gregor --- drivers/staging/comedi/comedi_pci.h | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_pci.h b/drivers/staging/comedi/comedi_pci.h index 4005cc9..7dfd892 100644 --- a/drivers/staging/comedi/comedi_pci.h +++ b/drivers/staging/comedi/comedi_pci.h @@ -34,18 +34,20 @@ #define PCI_VENDOR_ID_RTD 0x1435 #define PCI_VENDOR_ID_HUMUSOFT 0x186c -struct pci_dev *comedi_to_pci_dev(struct comedi_device *); +struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev); -int comedi_pci_enable(struct comedi_device *); -void comedi_pci_disable(struct comedi_device *); -void comedi_pci_detach(struct comedi_device *); +int comedi_pci_enable(struct comedi_device *dev); +void comedi_pci_disable(struct comedi_device *dev); +void comedi_pci_detach(struct comedi_device *dev); -int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *, +int comedi_pci_auto_config(struct pci_dev *pcidev, struct comedi_driver *driver, unsigned long context); -void comedi_pci_auto_unconfig(struct pci_dev *); +void comedi_pci_auto_unconfig(struct pci_dev *pcidev); -int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *); -void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); +int comedi_pci_driver_register(struct comedi_driver *comedi_driver, + struct pci_driver *pci_driver); +void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver, + struct pci_driver *pci_driver); /** * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[BUG] drivers: staging: comedi: do not call blocking ops when !TASK_RUNNING; state=1
Calling blocking operations from wrong context. Kernel: Linux piotrpc 4.4.70-rt83 #1 SMP PREEMPT RT Thu Jul 13 08:42:02 BST 2017 x86_64 GNU/Linux [ 80.542018] NOHZ: local_softirq_pending 80 [ 125.175471] [ cut here ] [ 125.175491] WARNING: CPU: 0 PID: 1497 at kernel/sched/core.c:7833 __might_sleep+0x9f/0xb0() [ 125.175728] do not call blocking ops when !TASK_RUNNING; state=1 set at [] comedi_read+0x1a1/0x610 [comedi] [ 125.175735] Modules linked in: cpufreq_conservative cpufreq_powersave cpufreq_userspace cfg80211 nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace fscache sunrpc nls_ascii nls_cp437 vfat fat snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic intel_rapl joydev intel_powerclamp coretemp kvm drbg efi_pstore ansi_cprng irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd i915 serio_raw pcspkr efivars snd_hda_intel amplc_dio200_pci(C) amplc_dio200_common(C) snd_hda_codec iTCO_wdt comedi_8254(C) comedi_pci(C) iTCO_vendor_support comedi(C) snd_hda_core snd_hwdep snd_pcm drm_kms_helper snd_timer drm snd mei_me soundcore mei i2c_algo_bit shpchp eeepc_wmi asus_wmi sparse_keymap mxm_wmi battery hci_uart btbcm btqca btintel [ 125.175824] bluetooth [ 125.175825] wmi [ 125.175826] rfkill [ 125.175827] video [ 125.175828] intel_lpss_acpi [ 125.175830] intel_lpss [ 125.175831] evdev [ 125.175832] mfd_core [ 125.175833] acpi_als [ 125.175834] acpi_pad [ 125.175835] kfifo_buf [ 125.175836] button [ 125.175838] industrialio [ 125.175839] fuse [ 125.175840] parport_pc [ 125.175841] ppdev [ 125.175842] lp [ 125.175843] parport [ 125.175844] autofs4 [ 125.175845] ext4 [ 125.175846] crc16 [ 125.175847] mbcache [ 125.175848] jbd2 [ 125.175849] hid_generic [ 125.175851] usbhid [ 125.175852] sg [ 125.175853] sr_mod [ 125.175854] cdrom [ 125.175855] sd_mod [ 125.175856] crc32c_intel [ 125.175857] ahci [ 125.175858] libahci [ 125.175859] psmouse [ 125.175860] xhci_pci [ 125.175861] libata [ 125.175862] r8169 [ 125.175864] i2c_i801 [ 125.175865] mii [ 125.175866] xhci_hcd [ 125.175867] tg3 [ 125.175868] ptp [ 125.175869] scsi_mod [ 125.175870] usbcore [ 125.175871] pps_core [ 125.175872] libphy [ 125.175873] usb_common [ 125.175874] fan [ 125.175875] thermal [ 125.175876] i2c_hid [ 125.175877] hid [ 125.175878] fjes [ 125.175926] CPU: 0 PID: 1497 Comm: txrx Tainted: GWC 4.4.70-rt83 #1 [ 125.175928] Hardware name: NOVATECH LTD PC-XB04472/H110M-C, BIOS 3019 01/06/2017 [ 125.175935] 8802205b3cb0 81387160 8802205b3cf8 [ 125.175940] 0009 8802205b3ce8 81089766 c057ca60 [ 125.175944] 02dc 0001 0001 [ 125.175945] Call Trace: [ 125.175955] [] dump_stack+0x85/0xc5 [ 125.175963] [] warn_slowpath_common+0x86/0xe0 [ 125.175971] [] warn_slowpath_fmt+0x4c/0x50 [ 125.175980] [] ? trace_preempt_on+0x1a7/0x2b0 [ 125.175985] [] ? schedule+0x55/0xe0 [ 125.175994] [] ? comedi_read+0x1a1/0x610 [comedi] [ 125.176001] [] ? comedi_read+0x1a1/0x610 [comedi] [ 125.176005] [] __might_sleep+0x9f/0xb0 [ 125.176012] [] __might_fault+0x3b/0xb0 [ 125.176020] [] comedi_read+0x3df/0x610 [comedi] [ 125.176034] [] ? wake_up_process+0x20/0x20 [ 125.176044] [] __vfs_read+0x28/0xe0 [ 125.176053] [] ? security_file_permission+0xa6/0xc0 [ 125.176060] [] ? rw_verify_area+0x53/0xf0 [ 125.176066] [] vfs_read+0x89/0x130 [ 125.176074] [] SyS_read+0x49/0xb0 [ 125.176084] [] entry_SYSCALL_64_fastpath+0x16/0x7a [ 125.176095] ---[ end trace 0003 ]--- cheers, Piotr ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [BUG] drivers: staging: comedi: do not call blocking ops when !TASK_RUNNING; state=1
Hi Ian, I am afraid I have more problems with running Comedi on rt-patched kernel than only that. I am still trying to figure out the specific reason - hopefully it is my fault and I scrued up my own code, but so far it seems pcie215 support doesn't work at least in the same way on rt-patched kernel as it was on non-rt. I will dig it a little bit harder, likely coming with another bug reports shoud they be observed. Do you know about other experience other people may have using Comedi for pcie215 on rt-patched kernels, specifically 4.4.70? Has Comedi been tested on rt kernels by yourself? cheers, Piotr On Mon, Jul 17, 2017 at 05:02:45PM +0100, Ian Abbott wrote: > On 17/07/17 15:48, Piotr Gregor wrote: > >Calling blocking operations from wrong context. > >Kernel: > > > >Linux piotrpc 4.4.70-rt83 #1 SMP PREEMPT RT Thu Jul 13 08:42:02 BST 2017 > >x86_64 GNU/Linux > > > >[ 80.542018] NOHZ: local_softirq_pending 80 > >[ 125.175471] [ cut here ] > >[ 125.175491] WARNING: CPU: 0 PID: 1497 at kernel/sched/core.c:7833 > >__might_sleep+0x9f/0xb0() > >[ 125.175728] do not call blocking ops when !TASK_RUNNING; state=1 set at > >[] comedi_read+0x1a1/0x610 [comedi] > >[ 125.175735] Modules linked in: cpufreq_conservative cpufreq_powersave > >cpufreq_userspace cfg80211 nfsd auth_rpcgss oid_registry nfs_acl nfs lockd > >grace fscache sunrpc nls_ascii nls_cp437 vfat fat snd_hda_codec_hdmi > >snd_hda_codec_realtek snd_hda_codec_generic intel_rapl joydev > >intel_powerclamp coretemp kvm drbg efi_pstore ansi_cprng irqbypass > >crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 lrw > >gf128mul glue_helper ablk_helper cryptd i915 serio_raw pcspkr efivars > >snd_hda_intel amplc_dio200_pci(C) amplc_dio200_common(C) snd_hda_codec > >iTCO_wdt comedi_8254(C) comedi_pci(C) iTCO_vendor_support comedi(C) > >snd_hda_core snd_hwdep snd_pcm drm_kms_helper snd_timer drm snd mei_me > >soundcore mei i2c_algo_bit shpchp eeepc_wmi asus_wmi sparse_keymap mxm_wmi > >battery hci_uart btbcm btqca btintel > >[ 125.175824] bluetooth > >[ 125.175825] wmi > >[ 125.175826] rfkill > >[ 125.175827] video > >[ 125.175828] intel_lpss_acpi > >[ 125.175830] intel_lpss > >[ 125.175831] evdev > >[ 125.175832] mfd_core > >[ 125.175833] acpi_als > >[ 125.175834] acpi_pad > >[ 125.175835] kfifo_buf > >[ 125.175836] button > >[ 125.175838] industrialio > >[ 125.175839] fuse > >[ 125.175840] parport_pc > >[ 125.175841] ppdev > >[ 125.175842] lp > >[ 125.175843] parport > >[ 125.175844] autofs4 > >[ 125.175845] ext4 > >[ 125.175846] crc16 > >[ 125.175847] mbcache > >[ 125.175848] jbd2 > >[ 125.175849] hid_generic > >[ 125.175851] usbhid > >[ 125.175852] sg > >[ 125.175853] sr_mod > >[ 125.175854] cdrom > >[ 125.175855] sd_mod > >[ 125.175856] crc32c_intel > >[ 125.175857] ahci > >[ 125.175858] libahci > >[ 125.175859] psmouse > >[ 125.175860] xhci_pci > >[ 125.175861] libata > >[ 125.175862] r8169 > >[ 125.175864] i2c_i801 > >[ 125.175865] mii > >[ 125.175866] xhci_hcd > >[ 125.175867] tg3 > >[ 125.175868] ptp > >[ 125.175869] scsi_mod > >[ 125.175870] usbcore > >[ 125.175871] pps_core > >[ 125.175872] libphy > >[ 125.175873] usb_common > >[ 125.175874] fan > >[ 125.175875] thermal > >[ 125.175876] i2c_hid > >[ 125.175877] hid > >[ 125.175878] fjes > > > >[ 125.175926] CPU: 0 PID: 1497 Comm: txrx Tainted: GWC > >4.4.70-rt83 #1 > >[ 125.175928] Hardware name: NOVATECH LTD PC-XB04472/H110M-C, BIOS 3019 > >01/06/2017 > >[ 125.175935] 8802205b3cb0 81387160 > >8802205b3cf8 > >[ 125.175940] 0009 8802205b3ce8 81089766 > >c057ca60 > >[ 125.175944] 02dc 0001 > >0001 > >[ 125.175945] Call Trace: > >[ 125.175955] [] dump_stack+0x85/0xc5 > >[ 125.175963] [] warn_slowpath_common+0x86/0xe0 > >[ 125.175971] [] warn_slowpath_fmt+0x4c/0x50 > >[ 125.175980] [] ? trace_preempt_on+0x1a7/0x2b0 > >[ 125.175985] [] ? schedule+0x55/0xe0 > >[ 125.175994] [] ? comedi_read+0x1a1/0x610 [comedi] > >[ 125.176001] [] ? comedi_read+0x1a1/0x610 [comedi] > >[ 125.176005] [] __might_sleep+0x9f/0xb0 > >[ 125.176012] [] __might_fault+0x3b/0xb0 > >[ 125.176020] [] comedi_read+0x3df/0x6
[PATCH] drivers: staging: comedi: Add ftrace support
6.11200411685624E-011 Standard Deviation 0.000 007 818 Kurtosis8.9662160643 Skewness2.333413546 Range 0.000 070 000 Minimum 0.000 010 000 Maximum 0.000 080 000 Sum 0.012072 Count 625 Testing environment cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz stepping: 3 microcode : 0xa0 cpu MHz : 799.929 cache size : 8192 KB physical id : 0 siblings: 8 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat pln pts dtherm hwp hwp_notify hwp_act_window hwp_epp intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 bugs: bogomips: 6812.95 clflush size: 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: (...) uname -a Linux piotrpc 4.4.70-rt83 #1 SMP PREEMPT RT Thu Jul 13 08:42:02 BST 2017 x86_64 GNU/Linux RAM: 8GB Signed-off-by: Piotr Gregor --- drivers/staging/comedi/drivers/Makefile| 2 ++ .../staging/comedi/drivers/amplc_dio200_common.c | 5 +++ drivers/staging/comedi/drivers/comedi-trace.h | 42 ++ 3 files changed, 49 insertions(+) create mode 100644 drivers/staging/comedi/drivers/comedi-trace.h diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 0c8cfa7..1511a064 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -143,5 +143,7 @@ obj-$(CONFIG_COMEDI_NI_LABPC_ISADMA)+= ni_labpc_isadma.o obj-$(CONFIG_COMEDI_8255) += comedi_8255.o obj-$(CONFIG_COMEDI_8255_SA) += 8255.o obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o +CFLAGS_amplc_dio200_common.o = -I$(src) +#EXTRA_CFLAGS = -I$(src) obj-$(CONFIG_COMEDI_AMPLC_PC236) += amplc_pc236_common.o obj-$(CONFIG_COMEDI_DAS08) += das08.o diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index f6e4e98..fa356db 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -28,6 +28,9 @@ #include "comedi_8254.h" #include "8255.h" /* only for register defines */ +#define CREATE_TRACE_POINTS +#include "comedi-trace.h" + /* 200 series registers */ #define DIO200_IO_SIZE 0x20 #define DIO200_PCIE_IO_SIZE0x4000 @@ -482,8 +485,10 @@ static irqreturn_t dio200_interrupt(int irq, void *d) struct comedi_subdevice *s = dev->read_subdev; int handled; + trace_comedi_event(0); if (!dev->attached) return IRQ_NONE; + trace_comedi_event(1); handled = dio200_handle_read_intr(dev, s); diff --git a/drivers/staging/comedi/drivers/comedi-trace.h b/drivers/staging/comedi/drivers/comedi-trace.h new file mode 100644 index 000..1fa0a19 --- /dev/null +++ b/drivers/staging/comedi/drivers/comedi-trace.h @@ -0,0 +1,42 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM comedi + +#if !defined(_TRACE_COMEDI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_COMEDI_H + +#include + +/* + * Tracepoint for calling from various places inside Comedi. + * Takes simple id and prints it to the trace log if trace + * events from Comedi are enabled. + * + * Currently following tracepoints are in use: + * + * Id : Description + * 0 Enter the interrupt of amplc_dio200_common + * 1 Called from same ISR of amplc_dio200_common if IRQ is handled + * + * If you would like to add new tracepoint just add a call to + * trace_comedi_event(id) + * with id incremented. + */ +TRACE_EVENT(comedi_event, + TP_PROTO(__u8 id), + TP_ARGS(id), + TP_STRUCT__entry( +__field(__u8, id) + ), + TP_fast_assign( + __entry->id = id; + ), + TP_printk("[%u]", __entry->id) +); + +#endif /* _TRACE_COMEDI_H */ + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE comedi-trace +#include -- 2.1.4 -- Piotr Gregor ___
[PATCH] drivers: staging: comedi: Add ftrace support
6.11200411685624E-011 Standard Deviation 0.000 007 818 Kurtosis8.9662160643 Skewness2.333413546 Range 0.000 070 000 Minimum 0.000 010 000 Maximum 0.000 080 000 Sum 0.012072 Count 625 Testing environment cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz stepping: 3 microcode : 0xa0 cpu MHz : 799.929 cache size : 8192 KB physical id : 0 siblings: 8 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat pln pts dtherm hwp hwp_notify hwp_act_window hwp_epp intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 bugs: bogomips: 6812.95 clflush size: 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: (...) uname -a Linux piotrpc 4.4.70-rt83 #1 SMP PREEMPT RT Thu Jul 13 08:42:02 BST 2017 x86_64 GNU/Linux RAM: 8GB Signed-off-by: Piotr Gregor --- drivers/staging/comedi/drivers/Makefile| 2 ++ .../staging/comedi/drivers/amplc_dio200_common.c | 5 +++ drivers/staging/comedi/drivers/comedi-trace.h | 42 ++ 3 files changed, 49 insertions(+) create mode 100644 drivers/staging/comedi/drivers/comedi-trace.h diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 0c8cfa7..1511a064 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -143,5 +143,7 @@ obj-$(CONFIG_COMEDI_NI_LABPC_ISADMA)+= ni_labpc_isadma.o obj-$(CONFIG_COMEDI_8255) += comedi_8255.o obj-$(CONFIG_COMEDI_8255_SA) += 8255.o obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o +CFLAGS_amplc_dio200_common.o = -I$(src) +#EXTRA_CFLAGS = -I$(src) obj-$(CONFIG_COMEDI_AMPLC_PC236) += amplc_pc236_common.o obj-$(CONFIG_COMEDI_DAS08) += das08.o diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index f6e4e98..fa356db 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -28,6 +28,9 @@ #include "comedi_8254.h" #include "8255.h" /* only for register defines */ +#define CREATE_TRACE_POINTS +#include "comedi-trace.h" + /* 200 series registers */ #define DIO200_IO_SIZE 0x20 #define DIO200_PCIE_IO_SIZE0x4000 @@ -482,8 +485,10 @@ static irqreturn_t dio200_interrupt(int irq, void *d) struct comedi_subdevice *s = dev->read_subdev; int handled; + trace_comedi_event(0); if (!dev->attached) return IRQ_NONE; + trace_comedi_event(1); handled = dio200_handle_read_intr(dev, s); diff --git a/drivers/staging/comedi/drivers/comedi-trace.h b/drivers/staging/comedi/drivers/comedi-trace.h new file mode 100644 index 000..1fa0a19 --- /dev/null +++ b/drivers/staging/comedi/drivers/comedi-trace.h @@ -0,0 +1,42 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM comedi + +#if !defined(_TRACE_COMEDI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_COMEDI_H + +#include + +/* + * Tracepoint for calling from various places inside Comedi. + * Takes simple id and prints it to the trace log if trace + * events from Comedi are enabled. + * + * Currently following tracepoints are in use: + * + * Id : Description + * 0 Enter the interrupt of amplc_dio200_common + * 1 Called from same ISR of amplc_dio200_common if IRQ is handled + * + * If you would like to add new tracepoint just add a call to + * trace_comedi_event(id) + * with id incremented. + */ +TRACE_EVENT(comedi_event, + TP_PROTO(__u8 id), + TP_ARGS(id), + TP_STRUCT__entry( +__field(__u8, id) + ), + TP_fast_assign( + __entry->id = id; + ), + TP_printk("[%u]", __entry->id) +); + +#endif /* _TRACE_COMEDI_H */ + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE comedi-trace +#include -- 2.1.4
Re: [PATCH] drivers: staging: comedi: Add ftrace support
On Wed, Jul 19, 2017 at 04:21:06PM +0200, Greg Kroah-Hartman wrote: > On Wed, Jul 19, 2017 at 02:57:28PM +0100, Piotr Gregor wrote: > > + * Id : Description > > + * 0 Enter the interrupt of amplc_dio200_common > > + * 1 Called from same ISR of amplc_dio200_common if IRQ is handled > > That is a very device-specific tracepoint, do we really want each driver > to be able to set these up? > > Why can't ftrace handle this type of thing instead? > > thanks, > > greg k-h There is obviously sched* class of ftrace event, though if one wants to measure the latency introduced by the _driver_ than one needs to raise event from the specific place in the driver's code. I do not exclude the possibility that there may be even better way to chieve this and it's already implemented in ftrace. But I didn't see it based on what I have seen so far. There is sched_wakeup event - I used it as a moment the sleeper is awoken, but it is not exactly when ISR starts to run. For example: -0 [005] dN..3.. 335059.686293: sched_wakeup: comm=ktimersoftd/5 pid=51 prio=98 target_cpu=005 -0 [005] dN.h3.. 335059.686310: sched_wakeup: comm=irq/19-pcie215 pid=28912 prio=49 target_cpu=005 -0 [004] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/4 pid=42 prio=120 target_cpu=004 -0 [000] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/0 pid=10 prio=120 target_cpu=000 -0 [007] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/7 pid=66 prio=120 target_cpu=007 -0 [003] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/3 pid=34 prio=120 target_cpu=003 -0 [006] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/6 pid=58 prio=120 target_cpu=006 -0 [002] dN.h3.. 335059.686323: sched_wakeup: comm=rcuc/2 pid=26 prio=120 target_cpu=002 irq/19-pcie215-28912 [005] .11 335059.686328: pcie215_isr: IRQ# [8568], IRQ spurious# [0], IRQ status [00] -0 [003] dN..3.. 335059.686334: sched_wakeup: comm=ksoftirqd/3 pid=36 prio=120 target_cpu=003 If I used sched_wakeup I would start counting time from 335059.686310 but ISR started running at 335059.686328, i.e. 18 us later. cheers, Piotr ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] drivers: staging: comedi: Add ftrace support
On Wed, Jul 19, 2017 at 2:25 PM, Dan Carpenter wrote: > Everyone please delete this confidential email. Piotr is leakier than > the Trump administration! > Sanity level of Dan's assessments is less than half the average level of Hillary's supporter! ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: comedi_fops: do not call blocking ops when !TASK_RUNNING
On Fri, Jul 28, 2017 at 04:22:31PM +0100, Ian Abbott wrote: > Comedi's read and write file operation handlers (`comedi_read()` and > `comedi_write()`) currently call `copy_to_user()` or `copy_from_user()` > whilst in the `TASK_INTERRUPTIBLE` state, which falls foul of the > `might_fault()` checks when enabled. Fix it by setting the current task > state back to `TASK_RUNNING` a bit earlier before calling these > functions. > > Reported-by: Piotr Gregor > Signed-off-by: Ian Abbott > Cc: # 4.5+ > --- > Note: stable kernel versions 4.4 and earlier will need a slightly more > extensive change in `comedi_write()` than provided by this patch due to > a call to `mutex_lock()` whilst in the `TASK_INTERRUPTIBLE` state. > --- > drivers/staging/comedi/comedi_fops.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/staging/comedi/comedi_fops.c > b/drivers/staging/comedi/comedi_fops.c > index ca11be21f64b..34ca7823255d 100644 > --- a/drivers/staging/comedi/comedi_fops.c > +++ b/drivers/staging/comedi/comedi_fops.c > @@ -2396,6 +2396,7 @@ static ssize_t comedi_write(struct file *file, const > char __user *buf, > continue; > } > > + set_current_state(TASK_RUNNING); > wp = async->buf_write_ptr; > n1 = min(n, async->prealloc_bufsz - wp); > n2 = n - n1; > @@ -2528,6 +2529,8 @@ static ssize_t comedi_read(struct file *file, char > __user *buf, size_t nbytes, > } > continue; > } > + > + set_current_state(TASK_RUNNING); > rp = async->buf_read_ptr; > n1 = min(n, async->prealloc_bufsz - rp); > n2 = n - n1; > -- > 2.13.2 > Hi Ian, I will be able to test this in a couple of days. cheers, Piotr ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] drivers: staging: Add driver for Amplicon PCIe215
This is a small and simple driver for handling of external interrupt signal asserted on pins of Amplicon's PCIe215 board. There is already a Comedi driver subsystem in kernel which handles that (and more) board, but that framework while offering more flexibility brings also additional complexity at the cost of being generic. In some cases the simpler, more compact solution may be preferred. The purpose of this driver is therefore to handle interrupt feature of the PCIe215, while being small, simple and reliable. Signed-off-by: Piotr Gregor --- drivers/staging/Kconfig |2 + drivers/staging/Makefile|1 + drivers/staging/pcie215/Kconfig |7 + drivers/staging/pcie215/Makefile|4 + drivers/staging/pcie215/README | 155 + drivers/staging/pcie215/TODO|9 + drivers/staging/pcie215/pcie215-trace.h | 51 ++ drivers/staging/pcie215/pcie215.c | 1068 +++ drivers/staging/pcie215/pcie215_ioctl.h | 22 + 9 files changed, 1319 insertions(+) create mode 100644 drivers/staging/pcie215/Kconfig create mode 100644 drivers/staging/pcie215/Makefile create mode 100644 drivers/staging/pcie215/README create mode 100644 drivers/staging/pcie215/TODO create mode 100644 drivers/staging/pcie215/pcie215-trace.h create mode 100644 drivers/staging/pcie215/pcie215.c create mode 100644 drivers/staging/pcie215/pcie215_ioctl.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index ef28a1cb64ae..d9b4156d38b8 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -112,4 +112,6 @@ source "drivers/staging/typec/Kconfig" source "drivers/staging/vboxvideo/Kconfig" +source "drivers/staging/pcie215/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 2918580bdb9e..786b2e84ae60 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -45,3 +45,4 @@ obj-$(CONFIG_GREYBUS) += greybus/ obj-$(CONFIG_BCM2835_VCHIQ)+= vc04_services/ obj-$(CONFIG_CRYPTO_DEV_CCREE) += ccree/ obj-$(CONFIG_DRM_VBOXVIDEO)+= vboxvideo/ +obj-$(CONFIG_PCIE215) += pcie215/ diff --git a/drivers/staging/pcie215/Kconfig b/drivers/staging/pcie215/Kconfig new file mode 100644 index ..9bb507dbb640 --- /dev/null +++ b/drivers/staging/pcie215/Kconfig @@ -0,0 +1,7 @@ +config PCIE215 + tristate "PCIe215 Driver for PCIe215 interrupt" + depends on PCI + default n + ---help--- + This driver allows user space processes to react to external interrupts signalled on pins of PCIe215. + diff --git a/drivers/staging/pcie215/Makefile b/drivers/staging/pcie215/Makefile new file mode 100644 index ..af70668a4619 --- /dev/null +++ b/drivers/staging/pcie215/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_PCIE215) += pcie215.o + +CFLAGS_pcie215.o = -I$(src) + diff --git a/drivers/staging/pcie215/README b/drivers/staging/pcie215/README new file mode 100644 index ..bce7b442216f --- /dev/null +++ b/drivers/staging/pcie215/README @@ -0,0 +1,155 @@ + +1. PCIE215 +2. IOCTL +2.1. PCIE215_IOCTL_IRQ_DISABLE +2.2. PCIE215_IOCTL_IRQ_TRIGGERS_ENABLE +2.3. PCIE215_IOCTL_IRQ_TRIGGERS_DISABLE +3. MODULE PARAMETERS +4. COMPILATION +5. INSTALLATION AND USAGE +6. DEBUG/LOGGING +7. EXAMPLES + + +1. PCIE215 + +This is a driver for interrupts generated by Amplicon's PCIe215 +signal processing controller. It enables user space processes to react +to the external signals asserted on pins of PCIe215 board. + + +2. IOCTL + +Driver uses ioctl magic '4' and implements three ioctl calls: + +2.1. PCIE215_IOCTL_IRQ_ENABLE + +This call enables/disables interrupt generation by board's fpga, +Altera Cyclone IV. It accepts 8-bit integer argument (0 - disable, 1 - enable). + +Usage: +ioctl(fd, PCIE215_IOCTL_IRQ_ENABLE, 0); +Disables interrupts. + +ioctl(fd, PCIE215_IOCTL_IRQ_ENABLE, 1); +Enables interrupts. + +2.2. PCIE215_IOCTL_IRQ_TRIGGERS_ENABLE + +This call enables interrupts on specific pins passed as bitmask +argument. Argument is an 8 bit unsigned integer, with appropriate bit +set to 1 to enable triggering: + + 1 Enable PPI X C0 (pin 44) + 2 Enable PPI X C3 (pin 24) + 4 Enable PPI Y C0 (pin 70) + 8 Enable PPI Y C3 (pin 11) + +Pins set to 1 in the bitmask are _added_ to current mask, +so that previously enabled pins are still enabled after +new pins have been enabled. + +2.3. PCIE215_IOCTL_IRQ_TRIGGERS_DISABLE + +This call disables interrupt triggering on specified pins. Pins set to 1 +are removed from the set of enabled pins. + + +3. MODULE PARAMETERS + +Module accepts one optional parameter: triggers. This parameter may be passed +to insmod and/or modprobe to set enabled IRQ pins at module loa
Re: [PATCH] drivers: staging: Add driver for Amplicon PCIe215
On Fri, Sep 01, 2017 at 08:57:50AM +0200, Greg Kroah-Hartman wrote: > On Thu, Aug 31, 2017 at 05:54:58PM +0100, Piotr Gregor wrote: > > This is a small and simple driver for handling of external > > interrupt signal asserted on pins of Amplicon's PCIe215 board. > > There is already a Comedi driver subsystem in kernel which handles > > that (and more) board, but that framework while offering more > > flexibility brings also additional complexity at the cost of being generic. > > > > In some cases the simpler, more compact solution may be preferred. > > Note, having different drivers for the same hardware platform in the > kernel tree is a mess, and generally discouraged. I've handled this in > the past and we hated every minute of it. Agree. > > What is wrong with the comedi interface instead? For a user who needs only the interruption, this driver is preferred. The reason is that using Comedi framework requires knowledge of Comedi framework. There is no reason user should spend time learning additional software if what he needs can be achieved in a simpler way. Comedi allows you to do many things, but this means you must tell Comedi what is what you want. If you want to use Comedi for interrupt you end up learning how to configure Comedi so it can setup the driver, so that the driver will setup the board correctly. Once you know this, you have plenty of Comedi related code in your program and you are dependent on Comedi drivers and Comedi interface to them. It also means that after handling interrupt in kernel, the code control path visits plenty of Comedi related logic, before it uderstands what it is configured to do now and returns to your user space program. Using this driver means insmod followed by 2 ioctl to enable interrupt generation and set up enabled pins. I tried to make it return to user space as quickly as possible after the ISR is entered. > > And custom ioctls for a single hardware device is horrid, what's wrong > with using the uio interface for something like this? > You are right. This would be something TODO. > And finally, why staging? While I know I wouldn't accept merging this > into the main portion of the kernel, why do you feel that adding this to > drivers/staging/ is ok? What's so wrong with it (well, becides the > previous questions), that dumping it here is the properly location? There is nothing wrong, probably it should be submitted there. I thought it would be good to know your thoughts on this and improve things like ioctl interface if needed. > > > The purpose of this driver is therefore to handle interrupt > > feature of the PCIe215, while being small, simple and reliable. > > Why isn't comedi reliable? It isn't small and simple. This driver implements interrupt handling simpler and more efficiently. There is ftrace support in it, that's because I tested latency of wake up introduced by this driver and compared to Comedi framework. The result was 19.31 us on average for Comedi, and it was few microsecods less for this driver. It was also just recently when we found a bug on rt kernel 4.4.70 in Comedi code related to sleep/wake up. If it didn't aim to give all that flexibility this bug would not be there. Nothing bad happened, bug was fixed, but it shows how you are dependent on unrelated things you shouldn't have to worry about. > > thanks, > > greg k-h Thank you, Piotr ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel