The Paciugo

A collection of patches for the Linux kernel

Improved SPI driver for Samsung 24xx SOCs

The driver for the SPI master interface on Samsung 24xx SOCs in the mainline uses a workqueue because it's based on the generic bit-banging one. This could lead to very bad performance under heavy load conditions. I forward ported to kernel 2.6.27 the driver by Christer Weinigel. I just disabled the DMA part for now because on short transfers (< 32) it has a great overhead. The patch: spi-s3c24xx.diff

A trick when working with workqueues

Workqueues are a useful tool when programming in the Linux kernel-space. Unfortunately they scheduled with the same priority as other processes so under heavy load there could arise problems if a workqueue is servicing a piece of hardware that needs attention. With the patch worqueue-patch.diff you get a function that permits to give the highest (in the real-time or normal class for scheduling) to a workqueue. Example:

s->workqueue = create_freezeable_workqueue(b);
if (use_prio > 0) {
  extern void set_workqueue_max_prio(struct workqueue_struct *wq, int rt);

  if (use_prio > 1) {
    printk(KERN_DEBUG "hack enabled for %s RT\n", b);
    set_workqueue_max_prio(s->workqueue, 1);
  else {
    printk(KERN_DEBUG "hack enabled for %s\n", b);
    set_workqueue_max_prio(s->workqueue, 0);

Anyway keep in mind that workqueues are like processes, so if you have HZ set to 1000 (or a tickless kernel) smaller scheduling quantum time will give lower latency and so better response of the driver. Having kernel preemption enabled helps too.