31 Aug, 2016

1 commit

  • Many modules call misc_register and misc_deregister in its module init
    and exit methods without any additional code. This ends up being
    boilerplate. This patch adds helper macro module_misc_device(), that
    replaces module_init()/ module_exit() with template functions.

    This patch also converts drivers to use new macro.

    Change since v1:
    Add device.h include in miscdevice.h as module_driver macro was not
    available from other include files in some architectures.

    Signed-off-by: PrasannaKumar Muralidharan
    Signed-off-by: Greg Kroah-Hartman

    PrasannaKumar Muralidharan
     

28 Oct, 2015

1 commit

  • Debugging input devices, specifically laptop touchpads, can be tricky
    without having the physical device handy. Here we try to remedy that
    with userio. This module allows an application to connect to a character
    device provided by the kernel, and emulate any serio device. In
    combination with userspace programs that can record PS/2 devices and
    replay them through the /dev/userio device, this allows developers to
    debug driver issues on the PS/2 level with devices simply by requesting
    a recording from the user experiencing the issue without having to have
    the physical hardware in front of them.

    Signed-off-by: Stephen Chandler Paul
    Reviewed-by: David Herrmann
    Signed-off-by: Dmitry Torokhov

    Stephen Chandler Paul
     

06 Aug, 2015

1 commit

  • With well over 200+ users of this api, there are a mere 12 users that
    actually checked the return value of this function. And all of them
    really didn't do anything with that information as the system or module
    was shutting down no matter what.

    So stop pretending like it matters, and just return void from
    misc_deregister(). If something goes wrong in the call, you will get a
    WARNING splat in the syslog so you know how to fix up your driver.
    Other than that, there's nothing that can go wrong.

    Cc: Alasdair Kergon
    Cc: Neil Brown
    Cc: Oleg Drokin
    Cc: Andreas Dilger
    Cc: "Michael S. Tsirkin"
    Cc: Wim Van Sebroeck
    Cc: Christine Caulfield
    Cc: David Teigland
    Cc: Mark Fasheh
    Acked-by: Joel Becker
    Acked-by: Alexandre Belloni
    Acked-by: Alessandro Zummo
    Acked-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

25 Mar, 2015

1 commit

  • Add groups field to struct miscdevice for passing the attribute groups
    at device creation. In this way, the driver can avoid the manual call
    of device_create_file() after the device registration, which is
    basically a racy operation, in addition to the reduction of manual
    device_remove_file() calls.

    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     

28 May, 2014

1 commit


03 Apr, 2014

1 commit

  • Pull networking updates from David Miller:
    "Here is my initial pull request for the networking subsystem during
    this merge window:

    1) Support for ESN in AH (RFC 4302) from Fan Du.

    2) Add full kernel doc for ethtool command structures, from Ben
    Hutchings.

    3) Add BCM7xxx PHY driver, from Florian Fainelli.

    4) Export computed TCP rate information in netlink socket dumps, from
    Eric Dumazet.

    5) Allow IPSEC SA to be dumped partially using a filter, from Nicolas
    Dichtel.

    6) Convert many drivers to pci_enable_msix_range(), from Alexander
    Gordeev.

    7) Record SKB timestamps more efficiently, from Eric Dumazet.

    8) Switch to microsecond resolution for TCP round trip times, also
    from Eric Dumazet.

    9) Clean up and fix 6lowpan fragmentation handling by making use of
    the existing inet_frag api for it's implementation.

    10) Add TX grant mapping to xen-netback driver, from Zoltan Kiss.

    11) Auto size SKB lengths when composing netlink messages based upon
    past message sizes used, from Eric Dumazet.

    12) qdisc dumps can take a long time, add a cond_resched(), From Eric
    Dumazet.

    13) Sanitize netpoll core and drivers wrt. SKB handling semantics.
    Get rid of never-used-in-tree netpoll RX handling. From Eric W
    Biederman.

    14) Support inter-address-family and namespace changing in VTI tunnel
    driver(s). From Steffen Klassert.

    15) Add Altera TSE driver, from Vince Bridgers.

    16) Optimizing csum_replace2() so that it doesn't adjust the checksum
    by checksumming the entire header, from Eric Dumazet.

    17) Expand BPF internal implementation for faster interpreting, more
    direct translations into JIT'd code, and much cleaner uses of BPF
    filtering in non-socket ocntexts. From Daniel Borkmann and Alexei
    Starovoitov"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1976 commits)
    netpoll: Use skb_irq_freeable to make zap_completion_queue safe.
    net: Add a test to see if a skb is freeable in irq context
    qlcnic: Fix build failure due to undefined reference to `vxlan_get_rx_port'
    net: ptp: move PTP classifier in its own file
    net: sxgbe: make "core_ops" static
    net: sxgbe: fix logical vs bitwise operation
    net: sxgbe: sxgbe_mdio_register() frees the bus
    Call efx_set_channels() before efx->type->dimension_resources()
    xen-netback: disable rogue vif in kthread context
    net/mlx4: Set proper build dependancy with vxlan
    be2net: fix build dependency on VxLAN
    mac802154: make csma/cca parameters per-wpan
    mac802154: allow only one WPAN to be up at any given time
    net: filter: minor: fix kdoc in __sk_run_filter
    netlink: don't compare the nul-termination in nla_strcmp
    can: c_can: Avoid led toggling for every packet.
    can: c_can: Simplify TX interrupt cleanup
    can: c_can: Store dlc private
    can: c_can: Reduce register access
    can: c_can: Make the code readable
    ...

    Linus Torvalds
     

19 Feb, 2014

2 commits

  • Signed-off-by: Lucas De Marchi
    Signed-off-by: Greg Kroah-Hartman

    Lucas De Marchi
     
  • Commit bfacbb9 (Bluetooth: Use devname:vhci module alias for virtual HCI
    driver) added the module alias to hci_vhci module so it's possible to
    create the /dev/vhci node. However creating an alias without
    specifying the minor doesn't allow us to create the node ahead,
    triggerring module auto-load when it's first accessed.

    Starting with depmod from kmod 16 we started to warn if there's a
    devname alias without specifying the major and minor.

    Let's do the same done for uhid, kvm, fuse and others, specifying a
    fixed minor. In systems with systemd as the init the following will
    happen: on early boot systemd will call "kmod static-nodes" to read
    /lib/modules/$(uname -r)/modules.devname and then create the nodes. When
    first accessed these "dead" nodes will trigger the module loading.

    Signed-off-by: Lucas De Marchi
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Marcel Holtmann

    Lucas De Marchi
     

20 Dec, 2013

1 commit

  • VFIO currently allocates it's own dynamic chardev range, reserving the
    first minor for the control part of the interface (/dev/vfio/vfio) and
    the remainder for VFIO groups (/dev/vfio/$GROUP). This works, but it
    doesn't support auto loading. For instance when libvirt checks for
    VFIO support it looks for /dev/vfio/vfio, which currently doesn't
    exist unless the vfio module is loaded. By converting the control
    device to a misc driver and reserving a static minor, we can enable
    auto loading.

    Reserving the minor is a prerequist to that conversion. Minor 196
    is unused by anything currently in the kernel.

    Suggested-by: Paolo Bonzini
    Signed-off-by: Alex Williamson
    Acked-by: Greg Kroah-Hartman

    Alex Williamson
     

13 Nov, 2013

1 commit

  • Pull fuse updates from Miklos Szeredi:
    "This adds a ->writepage() implementation to fuse, improving mmaped
    writeout and paving the way for buffered writeback.

    And there's a patch to add a fix minor number for /dev/cuse, similarly
    to /dev/fuse"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
    fuse: writepages: protect secondary requests from fuse file release
    fuse: writepages: update bdi writeout when deleting secondary request
    fuse: writepages: crop secondary requests
    fuse: writepages: roll back changes if request not found
    cuse: add fix minor number to /dev/cuse
    fuse: writepage: skip already in flight
    fuse: writepages: handle same page rewrites
    fuse: writepages: fix aggregation
    fuse: fix race in fuse_writepages()
    fuse: Implement writepages callback
    fuse: don't BUG on no write file
    fuse: lock page in mkwrite
    fuse: Prepare to handle multiple pages in writeback
    fuse: Getting file for writeback helper

    Linus Torvalds
     

01 Oct, 2013

1 commit

  • This allows udev (or more recently systemd-tmpfiles) to create /dev/cuse on
    boot, in the same way as /dev/fuse is currently created, and the corresponding
    module to be loaded on first access.

    The corresponding functionalty was introduced for fuse in commit 578454f.

    Signed-off-by: Tom Gundersen
    Cc: Kay Sievers
    Signed-off-by: Miklos Szeredi

    Tom Gundersen
     

26 Sep, 2013

1 commit

  • udev has this nice feature of creating "dead" /dev/ device-nodes if
    it finds a devnode: modalias. Once the node is accessed, the kernel
    automatically loads the module that provides the node. However, this
    requires udev to know the major:minor code to use for the node. This
    feature was introduced by:

    commit 578454ff7eab61d13a26b568f99a89a2c9edc881
    Author: Kay Sievers
    Date: Thu May 20 18:07:20 2010 +0200

    driver core: add devname module aliases to allow module on-demand auto-loading

    However, uhid uses dynamic minor numbers so this doesn't actually work. We
    need to load uhid to know which minor it's going to use.

    Hence, allocate a static minor (just like uinput does) and we're good
    to go.

    Reported-by: Tom Gundersen
    Signed-off-by: David Herrmann
    Signed-off-by: Jiri Kosina

    David Herrmann
     

01 Dec, 2012

1 commit


20 Jul, 2012

1 commit

  • When MCA error occurs, it would be handled by Xen hypervisor first,
    and then the error information would be sent to initial domain for logging.

    This patch gets error information from Xen hypervisor and convert
    Xen format error into Linux format mcelog. This logic is basically
    self-contained, not touching other kernel components.

    By using tools like mcelog tool users could read specific error information,
    like what they did under native Linux.

    To test follow directions outlined in Documentation/acpi/apei/einj.txt

    Acked-and-tested-by: Borislav Petkov
    Signed-off-by: Ke, Liping
    Signed-off-by: Jiang, Yunhong
    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Liu, Jinsong
    Signed-off-by: Konrad Rzeszutek Wilk

    Liu, Jinsong
     

14 Jan, 2012

1 commit

  • By adding some module aliases, programs (or users) won't have to explicitly
    call modprobe. Vhost-net will always be available if built into the kernel.
    It does require assigning a permanent minor number for depmod to work.

    Also:
    - use C99 style initialization.
    - add missing entry in documentation for loop-control

    Signed-off-by: Stephen Hemminger
    Acked-By: Kay Sievers
    Signed-off-by: David S. Miller

    stephen hemminger
     

04 Jan, 2012

1 commit


01 Nov, 2011

2 commits

  • By removing the implicit presence of module.h from this file, we
    will see things like:

    In file included from fs/dlm/user.c:9:
    include/linux/miscdevice.h:50: error: field ‘list’ has incomplete type
    include/linux/miscdevice.h:54: error: expected specifier-qualifier-list before ‘mode_t’

    Call out lists.h and types.h for inclusion to fix each of the
    above respectively.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     
  • This file has a define MODULE_ALIAS_MISCDEV which in turn will
    use the MODULE_ALIAS define, but only if the former is explicitly
    used by modular device driver code (and such code should be
    already including module.h).

    Delete the include, since module.h is such a giant thing that we
    don't want it implicitly sneaking into compiles where it isn't
    specifically required.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

01 Aug, 2011

1 commit

  • Loop devices today have a fixed pre-allocated number of usually 8.
    The number can only be changed at module init time. To find a free
    device to use, /dev/loop%i needs to be scanned, and all devices need
    to be opened until a free one is possibly found.

    This adds a new /dev/loop-control device node, that allows to
    dynamically find or allocate a free device, and to add and remove loop
    devices from the running system:
    LOOP_CTL_ADD adds a specific device. Arg is the number
    of the device. It returns the device i or a negative
    error code.

    LOOP_CTL_REMOVE removes a specific device, Arg is the
    number the device. It returns the device i or a negative
    error code.

    LOOP_CTL_GET_FREE finds the next unbound device or allocates
    a new one. No arg is given. It returns the device i or a
    negative error code.

    The loop kernel module gets automatically loaded when
    /dev/loop-control is accessed the first time. The alias
    specified in the module, instructs udev to create this
    'dead' device node, even when the module is not loaded.

    Example:
    cfd = open("/dev/loop-control", O_RDWR);

    # add a new specific loop device
    err = ioctl(cfd, LOOP_CTL_ADD, devnr);

    # remove a specific loop device
    err = ioctl(cfd, LOOP_CTL_REMOVE, devnr);

    # find or allocate a free loop device to use
    devnr = ioctl(cfd, LOOP_CTL_GET_FREE);

    sprintf(loopname, "/dev/loop%i", devnr);
    ffd = open("backing-file", O_RDWR);
    lfd = open(loopname, O_RDWR);
    err = ioctl(lfd, LOOP_SET_FD, ffd);

    Cc: Tejun Heo
    Cc: Karel Zak
    Signed-off-by: Kay Sievers
    Signed-off-by: Jens Axboe

    Kay Sievers
     

21 Aug, 2010

1 commit

  • Recent modprobe and udev versions allow to create device nodes
    for modules which are not loaded. Only the first access will cause
    the in-kernel module loader to pull-in the module. Systems which
    never access the device node will not needlessly load the module,
    and no longer need init scripts or other facilities to unconditionally
    load it.

    Signed-off-by: Kay Sievers
    Signed-off-by: Dmitry Torokhov

    Kay Sievers
     

12 Aug, 2010

1 commit


09 Jun, 2010

1 commit

  • 10, 233 is allocated officially to /dev/kmview which is shipping in
    Ubuntu and Debian distributions. vhost_net seem to have borrowed it
    without making a proper request and this causes regressions in the other
    distributions.

    vhost_net can use a dynamic minor so use that instead. Also update the
    file with a comment to try and avoid future misunderstandings.

    cc: stable@kernel.org
    Signed-off-by: Alan Cox
    [ We should have caught this before 2.6.34 got released. - Linus ]
    Signed-off-by: Linus Torvalds

    Alan Cox
     

26 May, 2010

1 commit

  • This adds:
    alias: devname:
    to some common kernel modules, which will allow the on-demand loading
    of the kernel module when the device node is accessed.

    Ideally all these modules would be compiled-in, but distros seems too
    much in love with their modularization that we need to cover the common
    cases with this new facility. It will allow us to remove a bunch of pretty
    useless init scripts and modprobes from init scripts.

    The static device node aliases will be carried in the module itself. The
    program depmod will extract this information to a file in the module directory:
    $ cat /lib/modules/2.6.34-00650-g537b60d-dirty/modules.devname
    # Device nodes to trigger on-demand module loading.
    microcode cpu/microcode c10:184
    fuse fuse c10:229
    ppp_generic ppp c108:0
    tun net/tun c10:200
    dm_mod mapper/control c10:235

    Udev will pick up the depmod created file on startup and create all the
    static device nodes which the kernel modules specify, so that these modules
    get automatically loaded when the device node is accessed:
    $ /sbin/udevd --debug
    ...
    static_dev_create_from_modules: mknod '/dev/cpu/microcode' c10:184
    static_dev_create_from_modules: mknod '/dev/fuse' c10:229
    static_dev_create_from_modules: mknod '/dev/ppp' c108:0
    static_dev_create_from_modules: mknod '/dev/net/tun' c10:200
    static_dev_create_from_modules: mknod '/dev/mapper/control' c10:235
    udev_rules_apply_static_dev_perms: chmod '/dev/net/tun' 0666
    udev_rules_apply_static_dev_perms: chmod '/dev/fuse' 0666

    A few device nodes are switched to statically allocated numbers, to allow
    the static nodes to work. This might also useful for systems which still run
    a plain static /dev, which is completely unsafe to use with any dynamic minor
    numbers.

    Note:
    The devname aliases must be limited to the *common* and *single*instance*
    device nodes, like the misc devices, and never be used for conceptually limited
    systems like the loop devices, which should rather get fixed properly and get a
    control node for losetup to talk to, instead of creating a random number of
    device nodes in advance, regardless if they are ever used.

    This facility is to hide the mess distros are creating with too modualized
    kernels, and just to hide that these modules are not compiled-in, and not to
    paper-over broken concepts. Thanks! :)

    Cc: Greg Kroah-Hartman
    Cc: David S. Miller
    Cc: Miklos Szeredi
    Cc: Chris Mason
    Cc: Alasdair G Kergon
    Cc: Tigran Aivazian
    Cc: Ian Kent
    Signed-Off-By: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

15 Jan, 2010

1 commit

  • What it is: vhost net is a character device that can be used to reduce
    the number of system calls involved in virtio networking.
    Existing virtio net code is used in the guest without modification.

    There's similarity with vringfd, with some differences and reduced scope
    - uses eventfd for signalling
    - structures can be moved around in memory at any time (good for
    migration, bug work-arounds in userspace)
    - write logging is supported (good for migration)
    - support memory table and not just an offset (needed for kvm)

    common virtio related code has been put in a separate file vhost.c and
    can be made into a separate module if/when more backends appear. I used
    Rusty's lguest.c as the source for developing this part : this supplied
    me with witty comments I wouldn't be able to write myself.

    What it is not: vhost net is not a bus, and not a generic new system
    call. No assumptions are made on how guest performs hypercalls.
    Userspace hypervisors are supported as well as kvm.

    How it works: Basically, we connect virtio frontend (configured by
    userspace) to a backend. The backend could be a network device, or a tap
    device. Backend is also configured by userspace, including vlan/mac
    etc.

    Status: This works for me, and I haven't see any crashes.
    Compared to userspace, people reported improved latency (as I save up to
    4 system calls per packet), as well as better bandwidth and CPU
    utilization.

    Features that I plan to look at in the future:
    - mergeable buffers
    - zero copy
    - scalability tuning: figure out the best threading model to use

    Note on RCU usage (this is also documented in vhost.h, near
    private_pointer which is the value protected by this variant of RCU):
    what is happening is that the rcu_dereference() is being used in a
    workqueue item. The role of rcu_read_lock() is taken on by the start of
    execution of the workqueue item, of rcu_read_unlock() by the end of
    execution of the workqueue item, and of synchronize_rcu() by
    flush_workqueue()/flush_work(). In the future we might need to apply
    some gcc attribute or sparse annotation to the function passed to
    INIT_WORK(). Paul's ack below is for this RCU usage.

    (Includes fixes by Alan Cox ,
    David L Stevens ,
    Chris Wright )

    Acked-by: Rusty Russell
    Acked-by: Arnd Bergmann
    Acked-by: "Paul E. McKenney"
    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: David S. Miller

    Michael S. Tsirkin
     

20 Sep, 2009

1 commit

  • This allows subsytems to provide devtmpfs with non-default permissions
    for the device node. Instead of the default mode of 0600, null, zero,
    random, urandom, full, tty, ptmx now have a mode of 0666, which allows
    non-privileged processes to access standard device nodes in case no
    other userspace process applies the expected permissions.

    This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.

    Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

16 Jun, 2009

1 commit


14 Mar, 2009

1 commit


26 Nov, 2008

1 commit


20 Apr, 2008

1 commit

  • After 2.6.24 there was a plan to make the PM core acquire all device
    semaphores during a suspend/hibernation to protect itself from
    concurrent operations involving device objects. That proved to be
    too heavy-handed and we found a better way to achieve the goal, but
    before it happened, we had introduced the functions
    device_pm_schedule_removal() and destroy_suspended_device() to allow
    drivers to "safely" destroy a suspended device and we had adapted some
    drivers to use them. Now that these functions are no longer necessary,
    it seems reasonable to remove them and modify their users to use the
    normal device unregistration instead.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

06 Feb, 2008

1 commit


03 May, 2007

1 commit


02 Dec, 2006

1 commit


27 Jun, 2006

1 commit


29 Mar, 2006

1 commit

  • Mark the f_ops members of inodes as const, as well as fix the
    ripple-through this causes by places that copy this f_ops and then "do
    stuff" with it.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds