20 Jan, 2021

1 commit

  • This is the 5.10.8 stable release

    * tag 'v5.10.8': (104 commits)
    Linux 5.10.8
    tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
    drm/panfrost: Remove unused variables in panfrost_job_close()
    ...

    Signed-off-by: Jason Liu

    Jason Liu
     

17 Jan, 2021

2 commits

  • commit f9d6f94132f01d2a552dcbab54fa56496638186d upstream.

    Without crc32, this driver fails to link:

    arm-linux-gnueabi-ld: drivers/net/phy/dp83640.o: in function `match':
    dp83640.c:(.text+0x476c): undefined reference to `crc32_le'

    Fixes: 539e44d26855 ("dp83640: Include hash in timestamp/packet matching")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Andrew Lunn
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • [ Upstream commit 1f685e6adbbe3c7b1bd9053be771b898d9efa655 ]

    ptp_ines.c uses devm_platform_ioremap_resource(), which is only
    built/available when CONFIG_HAS_IOMEM is enabled.
    CONFIG_HAS_IOMEM is not enabled for arch/s390/, so builds on S390
    have a build error:

    s390-linux-ld: drivers/ptp/ptp_ines.o: in function `ines_ptp_ctrl_probe':
    ptp_ines.c:(.text+0x17e6): undefined reference to `devm_platform_ioremap_resource'

    Prevent builds of ptp_ines.c when HAS_IOMEM is not set.

    Fixes: bad1eaa6ac31 ("ptp: Add a driver for InES time stamping IP core.")
    Signed-off-by: Randy Dunlap
    Reported-by: kernel test robot
    Link: lore.kernel.org/r/202101031125.ZEFCUiKi-lkp@intel.com
    Acked-by: Richard Cochran
    Link: https://lore.kernel.org/r/20210106042531.1351-1-rdunlap@infradead.org
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

14 Dec, 2020

2 commits


26 Nov, 2020

1 commit

  • Feed kstrtou8 with NULL terminated string.

    Changes since v1:
    -Use sscanf to get rid of adhoc string parse.
    Changes since v2:
    -Check if sscanf returns 3.

    Fixes: 7ea5fda2b132 ("ptp: ptp_clockmatrix: update to support 4.8.7 firmware")
    Signed-off-by: Min Li
    Link: https://lore.kernel.org/r/1606273115-25792-1-git-send-email-min.li.xe@renesas.com
    Signed-off-by: Jakub Kicinski

    Min Li
     

19 Sep, 2020

1 commit

  • The FIPER3 (fixed interval period pulse generator) is supported on
    DPAA2 and ENETC network controller hardware. This patch is to support
    it in ptp_qoriq driver.

    Signed-off-by: Yangbo Lu
    Acked-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Yangbo Lu
     

26 Aug, 2020

1 commit


24 Aug, 2020

1 commit


20 Aug, 2020

2 commits


06 Aug, 2020

1 commit

  • The way we define the phase (the difference between the time of the
    signal's rising edge, and the closest integer multiple of the period),
    it doesn't make sense to have a phase value equal or larger than 1
    period.

    So deny these settings coming from the user.

    Signed-off-by: Vladimir Oltean
    Acked-by: Richard Cochran
    Acked-by: Jacob Keller
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

31 Jul, 2020

1 commit

  • With 4.8.7 firmware, adjtime can change delta instead of absolute time,
    which greately increases snap accuracy. PPS alignment doesn't have to
    be set for every single TOD change. Other minor changes includes:
    adding more debug logs, increasing snap accuracy for pre 4.8.7 firmware
    and supporting new tcs2bin format.

    Signed-off-by: Min Li
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Min Li
     

20 Jul, 2020

1 commit

  • There are external event timestampers (PHCs with support for
    PTP_EXTTS_REQUEST) that timestamp both event edges.

    When those edges are very close (such as in the case of a short pulse),
    there is a chance that the collected timestamp might be of the rising,
    or of the falling edge, we never know.

    There are also PHCs capable of generating periodic output with a
    configurable duty cycle. This is good news, because we can space the
    rising and falling edge out enough in time, that the risks to overrun
    the 1-entry timestamp FIFO of the extts PHC are lower (example: the
    perout PHC can be configured for a period of 1 second, and an "on" time
    of 0.5 seconds, resulting in a duty cycle of 50%).

    A flag is introduced for signaling that an on time is present in the
    perout request structure, for preserving compatibility. Logically
    speaking, the duty cycle cannot exceed 100% and the PTP core checks for
    this.

    PHC drivers that don't support this flag emit a periodic output of an
    unspecified duty cycle, same as before.

    The duty cycle is encoded as an "on" time, similar to the "start" and
    "period" times, and reuses the reserved space while preserving overall
    binary layout.

    Pahole reported before:

    struct ptp_perout_request {
    struct ptp_clock_time start; /* 0 16 */
    struct ptp_clock_time period; /* 16 16 */
    unsigned int index; /* 32 4 */
    unsigned int flags; /* 36 4 */
    unsigned int rsv[4]; /* 40 16 */

    /* size: 56, cachelines: 1, members: 5 */
    /* last cacheline: 56 bytes */
    };

    And now:

    struct ptp_perout_request {
    struct ptp_clock_time start; /* 0 16 */
    struct ptp_clock_time period; /* 16 16 */
    unsigned int index; /* 32 4 */
    unsigned int flags; /* 36 4 */
    union {
    struct ptp_clock_time on; /* 40 16 */
    unsigned int rsv[4]; /* 40 16 */
    }; /* 40 16 */

    /* size: 56, cachelines: 1, members: 5 */
    /* last cacheline: 56 bytes */
    };

    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

26 Jun, 2020

1 commit

  • With legacy PM, drivers themselves were responsible for managing the
    device's power states and takes care of register states.

    After upgrading to the generic structure, PCI core will take care of
    required tasks and drivers should do only device-specific operations.

    In the case of ptp_pch, after removing PCI helper functions, .suspend()
    and .resume() became empty-body functions. Hence, define them NULL and
    use dev_pm_ops.

    Compile-tested only.

    Signed-off-by: Vaibhav Gupta
    Signed-off-by: David S. Miller

    Vaibhav Gupta
     

14 Jun, 2020

1 commit

  • Since commit 84af7a6194e4 ("checkpatch: kconfig: prefer 'help' over
    '---help---'"), the number of '---help---' has been gradually
    decreasing, but there are still more than 2400 instances.

    This commit finishes the conversion. While I touched the lines,
    I also fixed the indentation.

    There are a variety of indentation styles found.

    a) 4 spaces + '---help---'
    b) 7 spaces + '---help---'
    c) 8 spaces + '---help---'
    d) 1 space + 1 tab + '---help---'
    e) 1 tab + '---help---' (correct indentation)
    f) 1 tab + 1 space + '---help---'
    g) 1 tab + 2 spaces + '---help---'

    In order to convert all of them to 1 tab + 'help', I ran the
    following commend:

    $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

26 May, 2020

1 commit

  • In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase
    function to support phase offset control.") the PTP Hardware Clock
    interface expanded to support the ADJ_OFFSET offset mode. However,
    the implementation did not respect the traditional yet pedantic
    distinction between units of microseconds and nanoseconds signaled by
    the ADJ_NANO flag. This patch fixes the issue by adding logic to
    handle that flag.

    Signed-off-by: Richard Cochran
    Reviewed-by: Vincent Cheng
    Signed-off-by: David S. Miller

    Richard Cochran
     

03 May, 2020

3 commits


30 Apr, 2020

1 commit


26 Apr, 2020

2 commits


25 Apr, 2020

1 commit


22 Apr, 2020

1 commit

  • The '==' expression itself is bool, no need to convert it to bool again.
    This fixes the following coccicheck warning:

    drivers/ptp/ptp_ines.c:403:55-60: WARNING: conversion to bool not
    needed here
    drivers/ptp/ptp_ines.c:404:55-60: WARNING: conversion to bool not
    needed here

    Signed-off-by: Jason Yan
    Signed-off-by: David S. Miller

    Jason Yan
     

21 Apr, 2020

2 commits

  • Fix sparse warnings:

    drivers/ptp/ptp_idt82p33.c:26:5: warning: symbol 'sync_tod_timeout' was not declared. Should it be static?
    drivers/ptp/ptp_idt82p33.c:31:5: warning: symbol 'phase_snap_threshold' was not declared. Should it be static?

    Reported-by: Hulk Robot
    Signed-off-by: YueHaibing
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    YueHaibing
     
  • Fix sparse warning:

    drivers/ptp/ptp_kvm.c:25:1: warning:
    symbol 'kvm_ptp_lock' was not declared. Should it be static?

    Reported-by: Hulk Robot
    Signed-off-by: YueHaibing
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    YueHaibing
     

31 Mar, 2020

1 commit

  • The PTP Hardware Clock (PHC) subsystem offers an API for configuring
    programmable pins. User space sets or gets the settings using ioctls,
    and drivers verify dialed settings via a callback. Drivers may also
    query pin settings by calling the ptp_find_pin() method.

    Although the core subsystem protects concurrent access to the pin
    settings, the implementation places illogical restrictions on how
    drivers may call ptp_find_pin(). When enabling an auxiliary function
    via the .enable(on=1) callback, drivers may invoke the pin finding
    method, but when disabling with .enable(on=0) drivers are not
    permitted to do so. With the exception of the mv88e6xxx, all of the
    PHC drivers do respect this restriction, but still the locking pattern
    is both confusing and unnecessary.

    This patch changes the locking implementation to allow PHC drivers to
    freely call ptp_find_pin() from their .enable() and .verify()
    callbacks.

    V2 ChangeLog:
    - fixed spelling in the kernel doc
    - add Vladimir's tested by tag

    Signed-off-by: Richard Cochran
    Reported-by: Yangbo Lu
    Tested-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Richard Cochran
     

06 Mar, 2020

1 commit

  • Add a PTP clock driver called ptp_vmw, for guests running on VMware ESXi
    hypervisor. The driver attaches to a VMware virtual device called
    "precision clock" that provides a mechanism for querying host system time.
    Similar to existing virtual PTP clock drivers (e.g. ptp_kvm), ptp_vmw
    utilizes the kernel's PTP hardware clock API to implement a clock device
    that can be used as a reference in Chrony for synchronizing guest time with
    host.

    The driver is only applicable to x86 guests running in VMware virtual
    machines with precision clock virtual device present. It uses a VMware
    specific hypercall mechanism to read time from the device.

    Reviewed-by: Thomas Hellstrom
    Signed-off-by: Vivek Thampi
    Signed-off-by: David S. Miller

    Vivek Thampi
     

25 Feb, 2020

1 commit

  • The IDT 82P33 Synchronization Management Unit (SMU) family provides
    tools to manage timing references, clock sources and
    timing paths for IEEE 1588 / Precision Time Protocol (PTP) and
    Synchronous Ethernet (SyncE) based clocks. The device supports up
    to three independent timing paths that control: PTP clock synthesis;
    SyncE clock generation; and general purpose frequency translation.
    The device supports physical layer timing with Digital PLLs (DPLLs)
    and it supports packet based timing with Digitally Controlled
    Oscillators (DCOs). This patch adds support for ptp clock based on
    the device.

    Changes since v1:
    - As suggested by Richard Cochran:
    1. Replace _mask_bit_count with the existing hweight8
    2. Prefix all functions with idt82p33
    3. Fix white space issues in Kconfig and Makefile
    4. Remove forward declaration
    5. Use adjfine instead of adjfreq for better resolution

    - As suggested by David Miller:
    1. Replace CHAN_INIT macro with a static function
    idt82p33_channel_init
    2. Employ reverse christmas tree ordering for local
    variables
    3. Fix indentation problem by appropriate number of
    TAB then SPACE character

    Signed-off-by: Min Li
    Signed-off-by: David S. Miller

    Min Li
     

17 Feb, 2020

1 commit

  • The alarm function hadn't been supported by PTP clock driver.
    The recommended solution PHC + phc2sys + nanosleep provides
    best performance. So drop the code of alarm in ptp_qoriq driver.

    Signed-off-by: Yangbo Lu
    Signed-off-by: David S. Miller

    Yangbo Lu
     

20 Jan, 2020

1 commit


15 Jan, 2020

1 commit

  • There is a bug in ptp_clock_unregister(), where ptp_cleanup_pin_groups()
    first frees ptp->pin_{,dev_}attr, but then posix_clock_unregister() needs
    them to destroy a related sysfs device.

    These functions can not be just swapped, as posix_clock_unregister() frees
    ptp which is needed in the ptp_cleanup_pin_groups(). Fix this by calling
    ptp_cleanup_pin_groups() in ptp_clock_release(), right before ptp is freed.

    This makes this patch fix an UAF bug in a patch which fixes an UAF bug.

    Reported-by: Antti Laakso
    Fixes: a33121e5487b ("ptp: fix the race between the release of ptp_clock and cdev")
    Link: https://lore.kernel.org/netdev/3d2bd09735dbdaf003585ca376b7c1e5b69a19bd.camel@intel.com/
    Signed-off-by: Vladis Dronov
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Vladis Dronov
     

13 Jan, 2020

1 commit

  • The ixp46x ptp driver has a somewhat unusual setup, where the ptp
    driver and the ethernet driver are in different directories but
    access the same registers that are defined a platform specific
    header file.

    Moving everything into drivers/net/ makes it look more like most
    other ptp drivers and allows compile-testing this driver on
    other targets.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Linus Walleij
    Signed-off-by: Jakub Kicinski

    Arnd Bergmann
     

08 Jan, 2020

1 commit

  • Simplify and fix the version information displayed by the driver.
    The new info better relects what is needed to support the hardware.

    Prev:
    Version: 4.8.0, Pipeline 22169 0x4001, Rev 0, Bond 5, CSR 311, IRQ 2

    New:
    Version: 4.8.0, Id: 0x4001 Hw Rev: 5 OTP Config Select: 15

    - Remove pipeline, CSR and IRQ because version x.y.z already incorporates
    this information.
    - Remove bond number because it is not used.
    - Remove rev number because register was not implemented, always 0
    - Add HW Rev ID register to replace rev number
    - Add OTP config select to show the user configuration chosen by
    the configurable GPIO pins on start-up

    Signed-off-by: Vincent Cheng
    Signed-off-by: David S. Miller

    vincent cheng
     

03 Jan, 2020

1 commit


01 Jan, 2020

1 commit


31 Dec, 2019

2 commits

  • In order to effectively use the PTP kernel thread for tasks such as
    timestamping packets, allow the user control over stopping it, which is
    needed e.g. when the timestamping queues must be drained.

    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • In a case when a ptp chardev (like /dev/ptp0) is open but an underlying
    device is removed, closing this file leads to a race. This reproduces
    easily in a kvm virtual machine:

    ts# cat openptp0.c
    int main() { ... fp = fopen("/dev/ptp0", "r"); ... sleep(10); }
    ts# uname -r
    5.5.0-rc3-46cf053e
    ts# cat /proc/cmdline
    ... slub_debug=FZP
    ts# modprobe ptp_kvm
    ts# ./openptp0 &
    [1] 670
    opened /dev/ptp0, sleeping 10s...
    ts# rmmod ptp_kvm
    ts# ls /dev/ptp*
    ls: cannot access '/dev/ptp*': No such file or directory
    ts# ...woken up
    [ 48.010809] general protection fault: 0000 [#1] SMP
    [ 48.012502] CPU: 6 PID: 658 Comm: openptp0 Not tainted 5.5.0-rc3-46cf053e #25
    [ 48.014624] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
    [ 48.016270] RIP: 0010:module_put.part.0+0x7/0x80
    [ 48.017939] RSP: 0018:ffffb3850073be00 EFLAGS: 00010202
    [ 48.018339] RAX: 000000006b6b6b6b RBX: 6b6b6b6b6b6b6b6b RCX: ffff89a476c00ad0
    [ 48.018936] RDX: fffff65a08d3ea08 RSI: 0000000000000247 RDI: 6b6b6b6b6b6b6b6b
    [ 48.019470] ... ^^^ a slub poison
    [ 48.023854] Call Trace:
    [ 48.024050] __fput+0x21f/0x240
    [ 48.024288] task_work_run+0x79/0x90
    [ 48.024555] do_exit+0x2af/0xab0
    [ 48.024799] ? vfs_write+0x16a/0x190
    [ 48.025082] do_group_exit+0x35/0x90
    [ 48.025387] __x64_sys_exit_group+0xf/0x10
    [ 48.025737] do_syscall_64+0x3d/0x130
    [ 48.026056] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [ 48.026479] RIP: 0033:0x7f53b12082f6
    [ 48.026792] ...
    [ 48.030945] Modules linked in: ptp i6300esb watchdog [last unloaded: ptp_kvm]
    [ 48.045001] Fixing recursive fault but reboot is needed!

    This happens in:

    static void __fput(struct file *file)
    { ...
    if (file->f_op->release)
    file->f_op->release(inode, file); <<< cdev is kfree'd here
    if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL &&
    !(mode & FMODE_PATH))) {
    cdev_put(inode->i_cdev); <<< cdev fields are accessed here

    Namely:

    __fput()
    posix_clock_release()
    kref_put(&clk->kref, delete_clock) <<< the last reference
    delete_clock()
    delete_ptp_clock()
    kfree(ptp) <<< cdev is embedded in ptp
    cdev_put
    module_put(p->owner) <<< *p is kfree'd, bang!

    Here cdev is embedded in posix_clock which is embedded in ptp_clock.
    The race happens because ptp_clock's lifetime is controlled by two
    refcounts: kref and cdev.kobj in posix_clock. This is wrong.

    Make ptp_clock's sysfs device a parent of cdev with cdev_device_add()
    created especially for such cases. This way the parent device with its
    ptp_clock is not released until all references to the cdev are released.
    This adds a requirement that an initialized but not exposed struct
    device should be provided to posix_clock_register() by a caller instead
    of a simple dev_t.

    This approach was adopted from the commit 72139dfa2464 ("watchdog: Fix
    the race between the release of watchdog_core_data and cdev"). See
    details of the implementation in the commit 233ed09d7fda ("chardev: add
    helper function to register char devs with a struct device").

    Link: https://lore.kernel.org/linux-fsdevel/20191125125342.6189-1-vdronov@redhat.com/T/#u
    Analyzed-by: Stephen Johnston
    Analyzed-by: Vern Lovejoy
    Signed-off-by: Vladis Dronov
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Vladis Dronov
     

26 Dec, 2019

1 commit

  • The InES at the ZHAW offers a PTP time stamping IP core. The FPGA
    logic recognizes and time stamps PTP frames on the MII bus. This
    patch adds a driver for the core along with a device tree binding to
    allow hooking the driver to MII buses.

    Signed-off-by: Richard Cochran
    Signed-off-by: David S. Miller

    Richard Cochran