Skip to content

Commit f9c25d9

Browse files
committed
Merge branch 'parisc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull more parisc updates from Helge Deller: - During this merge window O_NONBLOCK was changed to become 000200000, but we missed that the syscalls timerfd_create(), signalfd4(), eventfd2(), pipe2(), inotify_init1() and userfaultfd() do a strict bit-wise check of the flags parameter. To provide backward compatibility with existing userspace we introduce parisc specific wrappers for those syscalls which filter out the old O_NONBLOCK value and replaces it with the new one. - Prevent HIL bus driver to get stuck when keyboard or mouse isn't attached - Improve error return codes when setting rtc time - Minor documentation fix in pata_ns87415.c * 'parisc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: ata: pata_ns87415.c: Document support on parisc with superio chip parisc: Add wrapper syscalls to fix O_NONBLOCK flag usage hil/parisc: Disable HIL driver when it gets stuck parisc: Improve error return codes when setting rtc time
2 parents bd6aabc + 2e34ae0 commit f9c25d9

File tree

7 files changed

+111
-19
lines changed

7 files changed

+111
-19
lines changed

arch/parisc/kernel/sys_parisc.c

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
77
* Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
88
* Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
9-
* Copyright (C) 1999-2014 Helge Deller <[email protected]>
9+
* Copyright (C) 1999-2020 Helge Deller <[email protected]>
1010
*/
1111

1212
#include <linux/uaccess.h>
@@ -23,6 +23,7 @@
2323
#include <linux/utsname.h>
2424
#include <linux/personality.h>
2525
#include <linux/random.h>
26+
#include <linux/compat.h>
2627

2728
/* we construct an artificial offset for the mapping based on the physical
2829
* address of the kernel mapping variable */
@@ -373,3 +374,73 @@ long parisc_personality(unsigned long personality)
373374

374375
return err;
375376
}
377+
378+
/*
379+
* Up to kernel v5.9 we defined O_NONBLOCK as 000200004,
380+
* since then O_NONBLOCK is defined as 000200000.
381+
*
382+
* The following wrapper functions mask out the old
383+
* O_NDELAY bit from calls which use O_NONBLOCK.
384+
*
385+
* XXX: Remove those in year 2022 (or later)?
386+
*/
387+
388+
#define O_NONBLOCK_OLD 000200004
389+
#define O_NONBLOCK_MASK_OUT (O_NONBLOCK_OLD & ~O_NONBLOCK)
390+
391+
static int FIX_O_NONBLOCK(int flags)
392+
{
393+
if (flags & O_NONBLOCK_MASK_OUT) {
394+
struct task_struct *tsk = current;
395+
pr_warn_once("%s(%d) uses a deprecated O_NONBLOCK value.\n",
396+
tsk->comm, tsk->pid);
397+
}
398+
return flags & ~O_NONBLOCK_MASK_OUT;
399+
}
400+
401+
asmlinkage long parisc_timerfd_create(int clockid, int flags)
402+
{
403+
flags = FIX_O_NONBLOCK(flags);
404+
return sys_timerfd_create(clockid, flags);
405+
}
406+
407+
asmlinkage long parisc_signalfd4(int ufd, sigset_t __user *user_mask,
408+
size_t sizemask, int flags)
409+
{
410+
flags = FIX_O_NONBLOCK(flags);
411+
return sys_signalfd4(ufd, user_mask, sizemask, flags);
412+
}
413+
414+
#ifdef CONFIG_COMPAT
415+
asmlinkage long parisc_compat_signalfd4(int ufd,
416+
compat_sigset_t __user *user_mask,
417+
compat_size_t sizemask, int flags)
418+
{
419+
flags = FIX_O_NONBLOCK(flags);
420+
return compat_sys_signalfd4(ufd, user_mask, sizemask, flags);
421+
}
422+
#endif
423+
424+
asmlinkage long parisc_eventfd2(unsigned int count, int flags)
425+
{
426+
flags = FIX_O_NONBLOCK(flags);
427+
return sys_eventfd2(count, flags);
428+
}
429+
430+
asmlinkage long parisc_userfaultfd(int flags)
431+
{
432+
flags = FIX_O_NONBLOCK(flags);
433+
return sys_userfaultfd(flags);
434+
}
435+
436+
asmlinkage long parisc_pipe2(int __user *fildes, int flags)
437+
{
438+
flags = FIX_O_NONBLOCK(flags);
439+
return sys_pipe2(fildes, flags);
440+
}
441+
442+
asmlinkage long parisc_inotify_init1(int flags)
443+
{
444+
flags = FIX_O_NONBLOCK(flags);
445+
return sys_inotify_init1(flags);
446+
}

arch/parisc/kernel/syscalls/syscall.tbl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,17 @@
344344
304 common eventfd sys_eventfd
345345
305 32 fallocate parisc_fallocate
346346
305 64 fallocate sys_fallocate
347-
306 common timerfd_create sys_timerfd_create
347+
306 common timerfd_create parisc_timerfd_create
348348
307 32 timerfd_settime sys_timerfd_settime32
349349
307 64 timerfd_settime sys_timerfd_settime
350350
308 32 timerfd_gettime sys_timerfd_gettime32
351351
308 64 timerfd_gettime sys_timerfd_gettime
352-
309 common signalfd4 sys_signalfd4 compat_sys_signalfd4
353-
310 common eventfd2 sys_eventfd2
352+
309 common signalfd4 parisc_signalfd4 parisc_compat_signalfd4
353+
310 common eventfd2 parisc_eventfd2
354354
311 common epoll_create1 sys_epoll_create1
355355
312 common dup3 sys_dup3
356-
313 common pipe2 sys_pipe2
357-
314 common inotify_init1 sys_inotify_init1
356+
313 common pipe2 parisc_pipe2
357+
314 common inotify_init1 parisc_inotify_init1
358358
315 common preadv sys_preadv compat_sys_preadv
359359
316 common pwritev sys_pwritev compat_sys_pwritev
360360
317 common rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
@@ -387,7 +387,7 @@
387387
341 common bpf sys_bpf
388388
342 common execveat sys_execveat compat_sys_execveat
389389
343 common membarrier sys_membarrier
390-
344 common userfaultfd sys_userfaultfd
390+
344 common userfaultfd parisc_userfaultfd
391391
345 common mlock2 sys_mlock2
392392
346 common copy_file_range sys_copy_file_range
393393
347 common preadv2 sys_preadv2 compat_sys_preadv2

arch/parisc/kernel/time.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,16 @@ static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
180180
static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
181181
{
182182
time64_t secs = rtc_tm_to_time64(tm);
183-
184-
if (pdc_tod_set(secs, 0) < 0)
183+
int ret;
184+
185+
/* hppa has Y2K38 problem: pdc_tod_set() takes an u32 value! */
186+
ret = pdc_tod_set(secs, 0);
187+
if (ret != 0) {
188+
pr_warn("pdc_tod_set(%lld) returned error %d\n", secs, ret);
189+
if (ret == PDC_INVALID_ARG)
190+
return -EINVAL;
185191
return -EOPNOTSUPP;
192+
}
186193

187194
return 0;
188195
}

drivers/ata/pata_ns87415.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* pata_ns87415.c - NS87415 (non PARISC) PATA
3+
* pata_ns87415.c - NS87415 (and PARISC SUPERIO 87560) PATA
44
*
55
* (C) 2005 Red Hat <[email protected]>
66
*
@@ -16,7 +16,6 @@
1616
* systems. This has its own special mountain of errata.
1717
*
1818
* TODO:
19-
* Test PARISC SuperIO
2019
* Get someone to test on SPARC
2120
* Implement lazy pio/dma switching for better performance
2221
* 8bit shared timing.

drivers/input/serio/hil_mlc.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ EXPORT_SYMBOL(hil_mlc_unregister);
7474
static LIST_HEAD(hil_mlcs);
7575
static DEFINE_RWLOCK(hil_mlcs_lock);
7676
static struct timer_list hil_mlcs_kicker;
77-
static int hil_mlcs_probe;
77+
static int hil_mlcs_probe, hil_mlc_stop;
7878

7979
static void hil_mlcs_process(unsigned long unused);
8080
static DECLARE_TASKLET_DISABLED_OLD(hil_mlcs_tasklet, hil_mlcs_process);
@@ -702,9 +702,13 @@ static int hilse_donode(hil_mlc *mlc)
702702
if (!mlc->ostarted) {
703703
mlc->ostarted = 1;
704704
mlc->opacket = pack;
705-
mlc->out(mlc);
705+
rc = mlc->out(mlc);
706706
nextidx = HILSEN_DOZE;
707707
write_unlock_irqrestore(&mlc->lock, flags);
708+
if (rc) {
709+
hil_mlc_stop = 1;
710+
return 1;
711+
}
708712
break;
709713
}
710714
mlc->ostarted = 0;
@@ -715,8 +719,13 @@ static int hilse_donode(hil_mlc *mlc)
715719

716720
case HILSE_CTS:
717721
write_lock_irqsave(&mlc->lock, flags);
718-
nextidx = mlc->cts(mlc) ? node->bad : node->good;
722+
rc = mlc->cts(mlc);
723+
nextidx = rc ? node->bad : node->good;
719724
write_unlock_irqrestore(&mlc->lock, flags);
725+
if (rc) {
726+
hil_mlc_stop = 1;
727+
return 1;
728+
}
720729
break;
721730

722731
default:
@@ -780,6 +789,12 @@ static void hil_mlcs_process(unsigned long unused)
780789

781790
static void hil_mlcs_timer(struct timer_list *unused)
782791
{
792+
if (hil_mlc_stop) {
793+
/* could not send packet - stop immediately. */
794+
pr_warn(PREFIX "HIL seems stuck - Disabling HIL MLC.\n");
795+
return;
796+
}
797+
783798
hil_mlcs_probe = 1;
784799
tasklet_schedule(&hil_mlcs_tasklet);
785800
/* Re-insert the periodic task. */

drivers/input/serio/hp_sdc_mlc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc)
210210
priv->tseq[2] = 1;
211211
priv->tseq[3] = 0;
212212
priv->tseq[4] = 0;
213-
__hp_sdc_enqueue_transaction(&priv->trans);
213+
return __hp_sdc_enqueue_transaction(&priv->trans);
214214
busy:
215215
return 1;
216216
done:
@@ -219,7 +219,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc)
219219
return 0;
220220
}
221221

222-
static void hp_sdc_mlc_out(hil_mlc *mlc)
222+
static int hp_sdc_mlc_out(hil_mlc *mlc)
223223
{
224224
struct hp_sdc_mlc_priv_s *priv;
225225

@@ -234,7 +234,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
234234
do_data:
235235
if (priv->emtestmode) {
236236
up(&mlc->osem);
237-
return;
237+
return 0;
238238
}
239239
/* Shouldn't be sending commands when loop may be busy */
240240
BUG_ON(down_trylock(&mlc->csem));
@@ -296,7 +296,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
296296
BUG_ON(down_trylock(&mlc->csem));
297297
}
298298
enqueue:
299-
hp_sdc_enqueue_transaction(&priv->trans);
299+
return hp_sdc_enqueue_transaction(&priv->trans);
300300
}
301301

302302
static int __init hp_sdc_mlc_init(void)

include/linux/hil_mlc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct hilse_node {
103103

104104
/* Methods for back-end drivers, e.g. hp_sdc_mlc */
105105
typedef int (hil_mlc_cts) (hil_mlc *mlc);
106-
typedef void (hil_mlc_out) (hil_mlc *mlc);
106+
typedef int (hil_mlc_out) (hil_mlc *mlc);
107107
typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout);
108108

109109
struct hil_mlc_devinfo {

0 commit comments

Comments
 (0)