Skip to content

Commit

Permalink
Merge branch 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull poll annotations from Al Viro:
 "This introduces a __bitwise type for POLL### bitmap, and propagates
  the annotations through the tree. Most of that stuff is as simple as
  'make ->poll() instances return __poll_t and do the same to local
  variables used to hold the future return value'.

  Some of the obvious brainos found in process are fixed (e.g. POLLIN
  misspelled as POLL_IN). At that point the amount of sparse warnings is
  low and most of them are for genuine bugs - e.g. ->poll() instance
  deciding to return -EINVAL instead of a bitmap. I hadn't touched those
  in this series - it's large enough as it is.

  Another problem it has caught was eventpoll() ABI mess; select.c and
  eventpoll.c assumed that corresponding POLL### and EPOLL### were
  equal. That's true for some, but not all of them - EPOLL### are
  arch-independent, but POLL### are not.

  The last commit in this series separates userland POLL### values from
  the (now arch-independent) kernel-side ones, converting between them
  in the few places where they are copied to/from userland. AFAICS, this
  is the least disruptive fix preserving poll(2) ABI and making epoll()
  work on all architectures.

  As it is, it's simply broken on sparc - try to give it EPOLLWRNORM and
  it will trigger only on what would've triggered EPOLLWRBAND on other
  architectures. EPOLLWRBAND and EPOLLRDHUP, OTOH, are never triggered
  at all on sparc. With this patch they should work consistently on all
  architectures"

* 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits)
  make kernel-side POLL... arch-independent
  eventpoll: no need to mask the result of epi_item_poll() again
  eventpoll: constify struct epoll_event pointers
  debugging printk in sg_poll() uses %x to print POLL... bitmap
  annotate poll(2) guts
  9p: untangle ->poll() mess
  ->si_band gets POLL... bitmap stored into a user-visible long field
  ring_buffer_poll_wait() return value used as return value of ->poll()
  the rest of drivers/*: annotate ->poll() instances
  media: annotate ->poll() instances
  fs: annotate ->poll() instances
  ipc, kernel, mm: annotate ->poll() instances
  net: annotate ->poll() instances
  apparmor: annotate ->poll() instances
  tomoyo: annotate ->poll() instances
  sound: annotate ->poll() instances
  acpi: annotate ->poll() instances
  crypto: annotate ->poll() instances
  block: annotate ->poll() instances
  x86: annotate ->poll() instances
  ...
  • Loading branch information
torvalds committed Jan 31, 2018
2 parents 13ddd16 + c71d227 commit 168fe32
Show file tree
Hide file tree
Showing 387 changed files with 928 additions and 810 deletions.
1 change: 1 addition & 0 deletions arch/alpha/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
include include/uapi/asm-generic/Kbuild.asm

generic-y += bpf_perf_event.h
generic-y += poll.h
2 changes: 0 additions & 2 deletions arch/alpha/include/uapi/asm/poll.h

This file was deleted.

21 changes: 19 additions & 2 deletions arch/blackfin/include/uapi/asm/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@
#ifndef _UAPI__BFIN_POLL_H
#define _UAPI__BFIN_POLL_H

#define POLLWRNORM 4 /* POLLOUT */
#define POLLWRBAND 256
#ifndef __KERNEL__
#define POLLWRNORM POLLOUT
#define POLLWRBAND (__force __poll_t)256
#else
#define __ARCH_HAS_MANGLED_POLL
static inline __u16 mangle_poll(__poll_t val)
{
__u16 v = (__force __u16)val;
/* bit 9 -> bit 8, bit 8 -> bit 2 */
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
}

static inline __poll_t demangle_poll(__u16 v)
{
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
((v & 4) << 6));
}
#endif

#include <asm-generic/poll.h>

Expand Down
6 changes: 3 additions & 3 deletions arch/cris/arch-v10/drivers/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static ssize_t gpio_write(struct file *file, const char __user *buf,
size_t count, loff_t *off);
static int gpio_open(struct inode *inode, struct file *filp);
static int gpio_release(struct inode *inode, struct file *filp);
static unsigned int gpio_poll(struct file *filp, struct poll_table_struct *wait);
static __poll_t gpio_poll(struct file *filp, struct poll_table_struct *wait);

/* private data per open() of this driver */

Expand Down Expand Up @@ -141,9 +141,9 @@ static unsigned long dir_g_shadow; /* 1=output */
#define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B)


static unsigned int gpio_poll(struct file *file, poll_table *wait)
static __poll_t gpio_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
__poll_t mask = 0;
struct gpio_private *priv = file->private_data;
unsigned long data;
unsigned long flags;
Expand Down
8 changes: 4 additions & 4 deletions arch/cris/arch-v10/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static inline int sync_data_avail(struct sync_port *port);

static int sync_serial_open(struct inode *inode, struct file *file);
static int sync_serial_release(struct inode *inode, struct file *file);
static unsigned int sync_serial_poll(struct file *filp, poll_table *wait);
static __poll_t sync_serial_poll(struct file *filp, poll_table *wait);

static long sync_serial_ioctl(struct file *file,
unsigned int cmd, unsigned long arg);
Expand Down Expand Up @@ -654,12 +654,12 @@ static int sync_serial_release(struct inode *inode, struct file *file)



static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
static __poll_t sync_serial_poll(struct file *file, poll_table *wait)
{
int dev = MINOR(file_inode(file)->i_rdev);
unsigned int mask = 0;
__poll_t mask = 0;
struct sync_port *port;
DEBUGPOLL(static unsigned int prev_mask = 0);
DEBUGPOLL(static __poll_t prev_mask = 0);

port = &ports[dev];
poll_wait(file, &port->out_wait_q, wait);
Expand Down
8 changes: 4 additions & 4 deletions arch/cris/arch-v32/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static inline int sync_data_avail(struct sync_port *port);

static int sync_serial_open(struct inode *, struct file *);
static int sync_serial_release(struct inode *, struct file *);
static unsigned int sync_serial_poll(struct file *filp, poll_table *wait);
static __poll_t sync_serial_poll(struct file *filp, poll_table *wait);

static long sync_serial_ioctl(struct file *file,
unsigned int cmd, unsigned long arg);
Expand Down Expand Up @@ -555,13 +555,13 @@ static int sync_serial_release(struct inode *inode, struct file *file)
return 0;
}

static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
static __poll_t sync_serial_poll(struct file *file, poll_table *wait)
{
int dev = iminor(file_inode(file));
unsigned int mask = 0;
__poll_t mask = 0;
struct sync_port *port;
DEBUGPOLL(
static unsigned int prev_mask;
static __poll_t prev_mask;
);

port = &ports[dev];
Expand Down
21 changes: 18 additions & 3 deletions arch/frv/include/uapi/asm/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@
#ifndef _ASM_POLL_H
#define _ASM_POLL_H

#ifndef __KERNEL__
#define POLLWRNORM POLLOUT
#define POLLWRBAND 256
#define POLLWRBAND (__force __poll_t)256
#else
#define __ARCH_HAS_MANGLED_POLL
static inline __u16 mangle_poll(__poll_t val)
{
__u16 v = (__force __u16)val;
/* bit 9 -> bit 8, bit 8 -> bit 2 */
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
}

#include <asm-generic/poll.h>
static inline __poll_t demangle_poll(__u16 v)
{
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
((v & 4) << 6));
}
#endif

#include <asm-generic/poll.h>
#undef POLLREMOVE

#endif

1 change: 1 addition & 0 deletions arch/ia64/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ include include/uapi/asm-generic/Kbuild.asm

generic-y += bpf_perf_event.h
generic-y += kvm_para.h
generic-y += poll.h
2 changes: 0 additions & 2 deletions arch/ia64/include/uapi/asm/poll.h

This file was deleted.

4 changes: 2 additions & 2 deletions arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,12 +1644,12 @@ pfm_write(struct file *file, const char __user *ubuf,
return -EINVAL;
}

static unsigned int
static __poll_t
pfm_poll(struct file *filp, poll_table * wait)
{
pfm_context_t *ctx;
unsigned long flags;
unsigned int mask = 0;
__poll_t mask = 0;

if (PFM_IS_FILE(filp) == 0) {
printk(KERN_ERR "perfmon: pfm_poll: bad magic [%d]\n", task_pid_nr(current));
Expand Down
1 change: 1 addition & 0 deletions arch/m32r/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ include include/uapi/asm-generic/Kbuild.asm

generic-y += bpf_perf_event.h
generic-y += kvm_para.h
generic-y += poll.h
generic-y += siginfo.h
2 changes: 0 additions & 2 deletions arch/m32r/include/uapi/asm/poll.h

This file was deleted.

19 changes: 18 additions & 1 deletion arch/m68k/include/uapi/asm/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
#ifndef __m68k_POLL_H
#define __m68k_POLL_H

#ifndef __KERNEL__
#define POLLWRNORM POLLOUT
#define POLLWRBAND 256
#define POLLWRBAND (__force __poll_t)256
#else
#define __ARCH_HAS_MANGLED_POLL
static inline __u16 mangle_poll(__poll_t val)
{
__u16 v = (__force __u16)val;
/* bit 9 -> bit 8, bit 8 -> bit 2 */
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
}

static inline __poll_t demangle_poll(__u16 v)
{
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
((v & 4) << 6));
}
#endif

#include <asm-generic/poll.h>

Expand Down
19 changes: 18 additions & 1 deletion arch/mips/include/uapi/asm/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
#ifndef __ASM_POLL_H
#define __ASM_POLL_H

#ifndef __KERNEL__
#define POLLWRNORM POLLOUT
#define POLLWRBAND 0x0100
#define POLLWRBAND (__force __poll_t)0x0100
#else
#define __ARCH_HAS_MANGLED_POLL
static inline __u16 mangle_poll(__poll_t val)
{
__u16 v = (__force __u16)val;
/* bit 9 -> bit 8, bit 8 -> bit 2 */
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
}

static inline __poll_t demangle_poll(__u16 v)
{
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
((v & 4) << 6));
}
#endif

#include <asm-generic/poll.h>

Expand Down
4 changes: 2 additions & 2 deletions arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ static int file_release(struct inode *inode, struct file *filp)
return rtlx_release(iminor(inode));
}

static unsigned int file_poll(struct file *file, poll_table *wait)
static __poll_t file_poll(struct file *file, poll_table *wait)
{
int minor = iminor(file_inode(file));
unsigned int mask = 0;
__poll_t mask = 0;

poll_wait(file, &channel_wqs[minor].rt_queue, wait);
poll_wait(file, &channel_wqs[minor].lx_queue, wait);
Expand Down
1 change: 1 addition & 0 deletions arch/mn10300/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
include include/uapi/asm-generic/Kbuild.asm

generic-y += bpf_perf_event.h
generic-y += poll.h
generic-y += siginfo.h
2 changes: 0 additions & 2 deletions arch/mn10300/include/uapi/asm/poll.h

This file was deleted.

2 changes: 1 addition & 1 deletion arch/powerpc/kernel/rtasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
return error;
}

static unsigned int rtas_log_poll(struct file *file, poll_table * wait)
static __poll_t rtas_log_poll(struct file *file, poll_table * wait)
{
poll_wait(file, &rtas_log_wait, wait);
if (rtas_log_size)
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/cell/spufs/backing_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ static u32 spu_backing_mbox_stat_read(struct spu_context *ctx)
return ctx->csa.prob.mb_stat_R;
}

static unsigned int spu_backing_mbox_stat_poll(struct spu_context *ctx,
unsigned int events)
static __poll_t spu_backing_mbox_stat_poll(struct spu_context *ctx,
__poll_t events)
{
int ret;
__poll_t ret;
u32 stat;

ret = 0;
Expand Down
16 changes: 8 additions & 8 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,10 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
return count;
}

static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
static __poll_t spufs_ibox_poll(struct file *file, poll_table *wait)
{
struct spu_context *ctx = file->private_data;
unsigned int mask;
__poll_t mask;

poll_wait(file, &ctx->ibox_wq, wait);

Expand Down Expand Up @@ -898,10 +898,10 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
return count;
}

static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
static __poll_t spufs_wbox_poll(struct file *file, poll_table *wait)
{
struct spu_context *ctx = file->private_data;
unsigned int mask;
__poll_t mask;

poll_wait(file, &ctx->wbox_wq, wait);

Expand Down Expand Up @@ -1690,11 +1690,11 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
return ret;
}

static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)
{
struct spu_context *ctx = file->private_data;
u32 free_elements, tagstatus;
unsigned int mask;
__poll_t mask;

poll_wait(file, &ctx->mfc_wq, wait);

Expand Down Expand Up @@ -2455,11 +2455,11 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
return cnt == 0 ? error : cnt;
}

static unsigned int spufs_switch_log_poll(struct file *file, poll_table *wait)
static __poll_t spufs_switch_log_poll(struct file *file, poll_table *wait)
{
struct inode *inode = file_inode(file);
struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
unsigned int mask = 0;
__poll_t mask = 0;
int rc;

poll_wait(file, &ctx->switch_log->wait, wait);
Expand Down
5 changes: 2 additions & 3 deletions arch/powerpc/platforms/cell/spufs/hw_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ static u32 spu_hw_mbox_stat_read(struct spu_context *ctx)
return in_be32(&ctx->spu->problem->mb_stat_R);
}

static unsigned int spu_hw_mbox_stat_poll(struct spu_context *ctx,
unsigned int events)
static __poll_t spu_hw_mbox_stat_poll(struct spu_context *ctx, __poll_t events)
{
struct spu *spu = ctx->spu;
int ret = 0;
__poll_t ret = 0;
u32 stat;

spin_lock_irq(&spu->register_lock);
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/cell/spufs/spufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ struct mfc_dma_command {
struct spu_context_ops {
int (*mbox_read) (struct spu_context * ctx, u32 * data);
u32(*mbox_stat_read) (struct spu_context * ctx);
unsigned int (*mbox_stat_poll)(struct spu_context *ctx,
unsigned int events);
__poll_t (*mbox_stat_poll)(struct spu_context *ctx, __poll_t events);
int (*ibox_read) (struct spu_context * ctx, u32 * data);
int (*wbox_write) (struct spu_context * ctx, u32 data);
u32(*signal1_read) (struct spu_context * ctx);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/opal-prd.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static bool opal_msg_queue_empty(void)
return ret;
}

static unsigned int opal_prd_poll(struct file *file,
static __poll_t opal_prd_poll(struct file *file,
struct poll_table_struct *wait)
{
poll_wait(file, &opal_prd_msg_wait, wait);
Expand Down
1 change: 1 addition & 0 deletions arch/score/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
include include/uapi/asm-generic/Kbuild.asm

generic-y += bpf_perf_event.h
generic-y += poll.h
generic-y += siginfo.h
7 changes: 0 additions & 7 deletions arch/score/include/uapi/asm/poll.h

This file was deleted.

Loading

0 comments on commit 168fe32

Please sign in to comment.