aboutsummaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2021-04-20Merge branch 'kvm-arm64/ptp' into kvmarm-master/nextMarc Zyngier1-1/+2
Signed-off-by: Marc Zyngier <[email protected]>
2021-04-20ptp: Don't print an error if ptp_kvm is not supportedJon Hunter1-1/+2
Commit 300bb1fe7671 ("ptp: arm/arm64: Enable ptp_kvm for arm/arm64") enable ptp_kvm support for ARM platforms and for any ARM platform that does not support this, the following error message is displayed ... ERR KERN fail to initialize ptp_kvm For platforms that do not support ptp_kvm this error is a bit misleading and so fix this by only printing this message if the error returned by kvm_arch_ptp_init() is not -EOPNOTSUPP. Note that -EOPNOTSUPP is only returned by ARM platforms today if ptp_kvm is not supported. Fixes: 300bb1fe7671 ("ptp: arm/arm64: Enable ptp_kvm for arm/arm64") Signed-off-by: Jon Hunter <[email protected]> Acked-by: Richard Cochran <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2021-04-20platform/surface: aggregator: fix a bit testDan Carpenter1-1/+1
The "funcs" variable is a u64. If "func" is more than 31 then the BIT() shift will wrap instead of testing the high bits. Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem") Reported-by: kernel test robot <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Maximilian Luz <[email protected]> Link: https://lore.kernel.org/r/YH6UUhJhGk3mk13b@mwanda Signed-off-by: Hans de Goede <[email protected]>
2021-04-20platform/x86: intel_pmc_core: Fix "unsigned 'ret' is never less than zero" ↵Hans de Goede1-1/+1
smatch warning Change the type of ret form a size_t to a ssize_t, matching the prototype of simple_write_to_buffer(), fixing this warning reported by smatch: drivers/platform/x86/intel_pmc_core.c:1369 pmc_core_lpm_latch_mode_write() warn: unsigned 'ret' is never less than zero. Fixes: 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode") Cc: David E. Box <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2021-04-20block/rnbd: Use strscpy instead of strlcpyDima Stepanov3-8/+8
During checkpatch analyzing the following warning message was found: WARNING:STRLCPY: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Fix it by using strscpy calls instead of strlcpy. Signed-off-by: Dima Stepanov <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt-sysfs: Remove copy buffer overlap in rnbd_clt_get_path_nameDima Stepanov1-5/+1
cppcheck report the following error: rnbd/rnbd-clt-sysfs.c:522:36: error: The variable 'buf' is used both as a parameter and as destination in snprintf(). The origin and destination buffers overlap. Quote from glibc (C-library) documentation (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): "If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined." [sprintfOverlappingData] Fix it by initializing the buf variable in the first snprintf call. Fixes: 91f4acb2801c ("block/rnbd-clt: support mapping two devices") Signed-off-by: Dima Stepanov <[email protected]> Cc: Arnd Bergmann <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Remove max_segment_sizeJack Wang4-13/+5
We always map with SZ_4K, so do not need max_segment_size. Cc: Leon Romanovsky <[email protected]> Cc: [email protected] Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Md Haris Iqbal <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Acked-by: Jason Gunthorpe <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Generate kobject_uevent when the rnbd device state changesMd Haris Iqbal2-1/+9
When an RTRS session state changes, the transport layer generates an event to RNBD. Then RNBD will change the state of the RNBD client device accordingly. This commit add kobject_uevent when the RNBD device state changes. With this udev rules can be configured to react accordingly. Signed-off-by: Md Haris Iqbal <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-srv: Remove unused arguments of rnbd_srv_rdma_evGioh Kim3-28/+18
struct rtrs_srv is not used when handling rnbd_srv_rdma_ev messages, so cleaned up rdma_ev function pointer in rtrs_srv_ops also is changed. Cc: Leon Romanovsky <[email protected]> Cc: [email protected] Signed-off-by: Aleksei Marov <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Acked-by: Jason Gunthorpe <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Support polling mode for IO latency optimizationGioh Kim6-34/+181
RNBD can make double-queues for irq-mode and poll-mode. For example, on 4-CPU system 8 request-queues are created, 4 for irq-mode and 4 for poll-mode. If the IO has HIPRI flag, the block-layer will call .poll function of RNBD. Then IO is sent to the poll-mode queue. Add optional nr_poll_queues argument for map_devices interface. To support polling of RNBD, RTRS client creates connections for both of irq-mode and direct-poll-mode. For example, on 4-CPU system it could've create 5 connections: con[0] => user message (softirq cq) con[1:4] => softirq cq After this patch, it can create 9 connections: con[0] => user message (softirq cq) con[1:4] => softirq cq con[5:8] => DIRECT-POLL cq Cc: Leon Romanovsky <[email protected]> Cc: [email protected] Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Acked-by: Jason Gunthorpe <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Fix missing a memory free when unloading the moduleGioh Kim1-3/+7
When unloading the rnbd-clt module, it does not free a memory including the filename of the symbolic link to /sys/block/rnbdX. It is found by kmemleak as below. unreferenced object 0xffff9f1a83d3c740 (size 16): comm "bash", pid 736, jiffies 4295179665 (age 9841.310s) hex dump (first 16 bytes): 21 64 65 76 21 6e 75 6c 6c 62 30 40 62 6c 61 00 !dev!nullb0@bla. backtrace: [<0000000039f0c55e>] 0xffffffffc0456c24 [<000000001aab9513>] kernfs_fop_write+0xcf/0x1c0 [<00000000db5aa4b3>] vfs_write+0xdb/0x1d0 [<000000007a2e2207>] ksys_write+0x65/0xe0 [<00000000055e280a>] do_syscall_64+0x50/0x1b0 [<00000000c2b51831>] entry_SYSCALL_64_after_hwframe+0x49/0xbe Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Improve find_or_create_sess() return checkTom Rix1-6/+4
clang static analysis reports this problem rnbd-clt.c:1212:11: warning: Branch condition evaluates to a garbage value else if (!first) ^~~~~~ This is triggered in the find_and_get_or_create_sess() call because the variable first is not initialized and the earlier check is specifically for if (sess == ERR_PTR(-ENOMEM)) This is false positive. But the if-check can be reduced by initializing first to false and then returning if the call to find_or_creat_sess() does not set it to true. When it remains false, either sess will be valid or not. The not case is caught by find_and_get_or_create_sess()'s caller rnbd_clt_map_device() sess = find_and_get_or_create_sess(...); if (IS_ERR(sess)) return ERR_CAST(sess); Since find_and_get_or_create_sess() initializes first to false setting it in find_or_create_sess() is not needed. Signed-off-by: Tom Rix <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-srv: Remove force_close file after holding a lockGioh Kim3-6/+7
We changed the rnbd_srv_sess_dev_force_close to use try-lock because rnbd_srv_sess_dev_force_close and process_msg_close can generate a deadlock. Now rnbd_srv_sess_dev_force_close would do nothing if it fails to get the lock. So removing the force_close file should be moved to after the lock. Or the force_close file is removed but the others are not removed. Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Md Haris Iqbal <[email protected]> Signed-off-by: Jack Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallelGioh Kim1-1/+3
We got a warning message below. When server tries to close one session by force, it locks the sysfs interface and locks the srv_sess lock. The problem is that client can send a request to close at the same time. By close request, server locks the srv_sess lock and locks the sysfs to remove the sysfs interfaces. The simplest way to prevent that situation could be just use mutex_trylock. [ 234.153965] ====================================================== [ 234.154093] WARNING: possible circular locking dependency detected [ 234.154219] 5.4.84-storage #5.4.84-1+feature+linux+5.4.y+dbg+20201216.1319+b6b887b~deb10 Tainted: G O [ 234.154381] ------------------------------------------------------ [ 234.154531] kworker/1:1H/618 is trying to acquire lock: [ 234.154651] ffff8887a09db0a8 (kn->count#132){++++}, at: kernfs_remove_by_name_ns+0x40/0x80 [ 234.154819] but task is already holding lock: [ 234.154965] ffff8887ae5f6518 (&srv_sess->lock){+.+.}, at: rnbd_srv_rdma_ev+0x144/0x1590 [rnbd_server] [ 234.155132] which lock already depends on the new lock. [ 234.155311] the existing dependency chain (in reverse order) is: [ 234.155462] -> #1 (&srv_sess->lock){+.+.}: [ 234.155614] __mutex_lock+0x134/0xcb0 [ 234.155761] rnbd_srv_sess_dev_force_close+0x36/0x50 [rnbd_server] [ 234.155889] rnbd_srv_dev_session_force_close_store+0x69/0xc0 [rnbd_server] [ 234.156042] kernfs_fop_write+0x13f/0x240 [ 234.156162] vfs_write+0xf3/0x280 [ 234.156278] ksys_write+0xba/0x150 [ 234.156395] do_syscall_64+0x62/0x270 [ 234.156513] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 234.156632] -> #0 (kn->count#132){++++}: [ 234.156782] __lock_acquire+0x129e/0x23a0 [ 234.156900] lock_acquire+0xf3/0x210 [ 234.157043] __kernfs_remove+0x42b/0x4c0 [ 234.157161] kernfs_remove_by_name_ns+0x40/0x80 [ 234.157282] remove_files+0x3f/0xa0 [ 234.157399] sysfs_remove_group+0x4a/0xb0 [ 234.157519] rnbd_srv_destroy_dev_session_sysfs+0x19/0x30 [rnbd_server] [ 234.157648] rnbd_srv_rdma_ev+0x14c/0x1590 [rnbd_server] [ 234.157775] process_io_req+0x29a/0x6a0 [rtrs_server] [ 234.157924] __ib_process_cq+0x8c/0x100 [ib_core] [ 234.158709] ib_cq_poll_work+0x31/0xb0 [ib_core] [ 234.158834] process_one_work+0x4e5/0xaa0 [ 234.158958] worker_thread+0x65/0x5c0 [ 234.159078] kthread+0x1e0/0x200 [ 234.159194] ret_from_fork+0x24/0x30 [ 234.159309] other info that might help us debug this: [ 234.159513] Possible unsafe locking scenario: [ 234.159658] CPU0 CPU1 [ 234.159775] ---- ---- [ 234.159891] lock(&srv_sess->lock); [ 234.160005] lock(kn->count#132); [ 234.160128] lock(&srv_sess->lock); [ 234.160250] lock(kn->count#132); [ 234.160364] *** DEADLOCK *** [ 234.160536] 3 locks held by kworker/1:1H/618: [ 234.160677] #0: ffff8883ca1ed528 ((wq_completion)ib-comp-wq){+.+.}, at: process_one_work+0x40a/0xaa0 [ 234.160840] #1: ffff8883d2d5fe10 ((work_completion)(&cq->work)){+.+.}, at: process_one_work+0x40a/0xaa0 [ 234.161003] #2: ffff8887ae5f6518 (&srv_sess->lock){+.+.}, at: rnbd_srv_rdma_ev+0x144/0x1590 [rnbd_server] [ 234.161168] stack backtrace: [ 234.161312] CPU: 1 PID: 618 Comm: kworker/1:1H Tainted: G O 5.4.84-storage #5.4.84-1+feature+linux+5.4.y+dbg+20201216.1319+b6b887b~deb10 [ 234.161490] Hardware name: Supermicro H8QG6/H8QG6, BIOS 3.00 09/04/2012 [ 234.161643] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] [ 234.161765] Call Trace: [ 234.161910] dump_stack+0x96/0xe0 [ 234.162028] check_noncircular+0x29e/0x2e0 [ 234.162148] ? print_circular_bug+0x100/0x100 [ 234.162267] ? register_lock_class+0x1ad/0x8a0 [ 234.162385] ? __lock_acquire+0x68e/0x23a0 [ 234.162505] ? trace_event_raw_event_lock+0x190/0x190 [ 234.162626] __lock_acquire+0x129e/0x23a0 [ 234.162746] ? register_lock_class+0x8a0/0x8a0 [ 234.162866] lock_acquire+0xf3/0x210 [ 234.162982] ? kernfs_remove_by_name_ns+0x40/0x80 [ 234.163127] __kernfs_remove+0x42b/0x4c0 [ 234.163243] ? kernfs_remove_by_name_ns+0x40/0x80 [ 234.163363] ? kernfs_fop_readdir+0x3b0/0x3b0 [ 234.163482] ? strlen+0x1f/0x40 [ 234.163596] ? strcmp+0x30/0x50 [ 234.163712] kernfs_remove_by_name_ns+0x40/0x80 [ 234.163832] remove_files+0x3f/0xa0 [ 234.163948] sysfs_remove_group+0x4a/0xb0 [ 234.164068] rnbd_srv_destroy_dev_session_sysfs+0x19/0x30 [rnbd_server] [ 234.164196] rnbd_srv_rdma_ev+0x14c/0x1590 [rnbd_server] [ 234.164345] ? _raw_spin_unlock_irqrestore+0x43/0x50 [ 234.164466] ? lockdep_hardirqs_on+0x1a8/0x290 [ 234.164597] ? mlx4_ib_poll_cq+0x927/0x1280 [mlx4_ib] [ 234.164732] ? rnbd_get_sess_dev+0x270/0x270 [rnbd_server] [ 234.164859] process_io_req+0x29a/0x6a0 [rtrs_server] [ 234.164982] ? rnbd_get_sess_dev+0x270/0x270 [rnbd_server] [ 234.165130] __ib_process_cq+0x8c/0x100 [ib_core] [ 234.165279] ib_cq_poll_work+0x31/0xb0 [ib_core] [ 234.165404] process_one_work+0x4e5/0xaa0 [ 234.165550] ? pwq_dec_nr_in_flight+0x160/0x160 [ 234.165675] ? do_raw_spin_lock+0x119/0x1d0 [ 234.165796] worker_thread+0x65/0x5c0 [ 234.165914] ? process_one_work+0xaa0/0xaa0 [ 234.166031] kthread+0x1e0/0x200 [ 234.166147] ? kthread_create_worker_on_cpu+0xc0/0xc0 [ 234.166268] ret_from_fork+0x24/0x30 [ 234.251591] rnbd_server L243: </dev/loop1@close_device_session>: Device closed [ 234.604221] rnbd_server L264: RTRS Session close_device_session disconnected Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Md Haris Iqbal <[email protected]> Signed-off-by: Jack Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Replace {NO_WAIT,WAIT} with RTRS_PERMIT_{WAIT,NOWAIT}Gioh Kim3-30/+22
They are defined with the same value and similar meaning, let's remove one of them, then we can remove {WAIT,NOWAIT}. Also change the type of 'wait' from 'int' to 'enum wait_type' to make it clear. Cc: Leon Romanovsky <[email protected]> Cc: [email protected] Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Md Haris Iqbal <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Acked-by: Jason Gunthorpe <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd: Kill destroy_device_cbGuoqing Jiang1-11/+4
We can use destroy_device directly since destroy_device_cb is just the wrapper of destroy_device. Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Danil Kipnis <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd: Kill rnbd_clt_destroy_default_groupGuoqing Jiang3-7/+1
No need to have it since we can call sysfs_remove_group in the rnbd_clt_destroy_sysfs_files. Then rnbd_clt_destroy_sysfs_files is paired with it's counterpart rnbd_clt_create_sysfs_files. Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Danil Kipnis <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Move add_disk(dev->gd) to rnbd_clt_setup_gen_diskGuoqing Jiang1-2/+1
It makes more sense to add gendisk in rnbd_clt_setup_gen_disk, instead of do it in rnbd_clt_map_device. Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Danil Kipnis <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Remove some arguments from rnbd_client_setup_deviceGuoqing Jiang1-4/+3
Remove them since both sess and idx can be dereferenced from dev. And sess is not used in the function. Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Danil Kipnis <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20block/rnbd-clt: Remove some arguments from insert_dev_if_not_exists_devpathGuoqing Jiang1-5/+4
Remove 'pathname' and 'sess' since we can dereference it from 'dev'. Signed-off-by: Guoqing Jiang <[email protected]> Reviewed-by: Danil Kipnis <[email protected]> Signed-off-by: Gioh Kim <[email protected]> Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undefDenis Efremov1-2/+0
FLOPPY_SILENT_DCL_CLEAR is not defined anywhere and comes from pre-git era. Just drop this undef. There is FD_SILENT_DCL_CLEAR which is really used. Signed-off-by: Denis Efremov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20floppy: cleanups: use memcpy() to copy reply_bufferDenis Efremov1-4/+1
Use memcpy() in raw_cmd_done() to copy reply_buffer instead of a for loop. Signed-off-by: Denis Efremov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20floppy: cleanups: use memset() to zero reply_bufferDenis Efremov1-3/+1
Use memset() to zero reply buffer in raw_cmd_copyin() instead of a for loop. Signed-off-by: Denis Efremov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20floppy: cleanups: use ST0 as reply_buffer index 0Denis Efremov1-6/+6
Use ST0 as 0 index for reply_buffer array. get_fdc_version() is the only function that uses index 0 directly instead of the ST0 define. Signed-off-by: Denis Efremov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
2021-04-20power: supply: bq256xx: add kerneldoc for structure membersKrzysztof Kozlowski1-0/+2
Document members of structure to fix W=1 warnings like: drivers/power/supply/bq256xx_charger.c:240: warning: Function parameter or member 'charger' not described in 'bq256xx_device' Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-04-20power: supply: act8945a: correct kerneldocKrzysztof Kozlowski1-1/+1
Remove incorrect kerneldoc marker to fix W=1 warning: drivers/power/supply/act8945a_charger.c:22: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-04-20power: supply: max17040: remove unneeded double castKrzysztof Kozlowski1-2/+1
There is no need for double explicit cast from of_device_get_match_data() (uintptr_t and then to target enum) because implicit conversion from uintptr_t to enum is straightforward (uintptr_t is a integer type). Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-04-20power: supply: max17040: handle device_property_read_u8_array() failureKrzysztof Kozlowski1-5/+4
The device_property_read_u8_array() call should not fail because it is preceded with device_property_count_u8() and check for number of readable u8 values. However the code is more obvious and easier to read if the return value of device_property_read_u8_array() is checked. Otherwise reader needs to investigate whether really there is no risk of using random stack values of 'rcomp' variable. Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-04-20power: supply: max14577: remove unneeded variable initializationKrzysztof Kozlowski1-1/+1
The local 'current_bits' variable does not have to be initialized because all cases in following switch() either return or initialize it. Addresses-Coverity: Unused value Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-04-20hwmon: Remove amd_energy driverGuenter Roeck2-389/+0
Commit 60268b0e8258 ("hwmon: (amd_energy) modify the visibility of the counters") restricted visibility of AMD energy counters to work around a side-channel attack using energy data to determine which instructions are executed. The attack is described in 'PLATYPUS: Software-based Power Side-Channel Attacks on x86'. It relies on quick and accurate energy readings. This change made the counters provided by the amd_energy driver effectively unusable for non-provileged users. However, unprivileged read access is the whole point of hardware monitoring attributes. An attempt to remedy the situation by limiting and randomizing access to chip registers was rejected by AMD. Since the driver is for all practical purposes unusable, remove it. Cc: Naveen Krishna Chatradhi <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus) Introduce PMBUS symbol namespaceGuenter Roeck36-19/+54
Exported pmbus symbols are only supposed to be used from PMBus code. Introduce PMBUS symbol namespace to prevent misuse from other code. Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus) Add pmbus driver for MAX15301Erik Rosen3-0/+199
Add pmbus driver support for Maxim MAX15301 InTune Automatically Compensated Digital PoL Controller with Driver and PMBus Telemetry Even though the specification does not specifically mention it, extensive empirical testing has revealed that auto-detection of limit-registers will fail in a random fashion unless the delay parameter is set to above about 80us. The default delay is set to 100us to include some safety margin. This patch is tested on a Flex BMR461 converter module. Signed-off-by: Erik Rosen <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Added rationale for delay to driver header] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (sch5627) Remove unnecessary error pathArmin Wolf1-45/+25
Calling remove() on error whould have only unregistered the watchdog, and since a failure in registering him is considered non-fatal and happens last, remove the error path and return the error codes directly. Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (sch5627) Use devres functionArmin Wolf1-10/+5
Use devm_hwmon_device_register_with_info() and remove hwmon_dev from sch5627_data struct as it is not needed anymore. Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus/pxe1610) don't bail out when not all pages are activePaul Fertser1-0/+9
Certain VRs might be configured to use only the first output channel and so the mode for the second will be 0. Handle this gracefully. Fixes: b9fa0a3acfd8 ("hwmon: (pmbus/core) Add support for vid mode detection per page bases") Signed-off-by: Paul Fertser <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: Add driver for fsp-3y PSUs and PDUsVáclav Kubernát3-0/+264
This patch adds support for these devices: - YH-5151E - the PDU - YM-2151E - the PSU The device datasheet says that the devices support PMBus 1.2, but in my testing, a lot of the commands aren't supported and if they are, they sometimes behave strangely or inconsistently. For example, writes to the PAGE command requires using PEC, otherwise the write won't work and the page won't switch, even though, the standard says that PEC is optional. On the other hand, writes to SMBALERT don't require PEC. Because of this, the driver is mostly reverse engineered with the help of a tool called pmbus_peek written by David Brownell (and later adopted by my colleague Jan Kundrát). The device also has some sort of a timing issue when switching pages, which is explained further in the code. Because of this, the driver support is limited. It exposes only the values that have been tested to work correctly. Signed-off-by: Václav Kubernát <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Fixed up "missing braces around initializer" from 0-day] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (intel-m10-bmc-hwmon) add sensor support of Intel D5005 cardMatthew Gerlach2-0/+132
Like the Intel N3000 card, the Intel D5005 has a MAX10 based BMC. This commit adds support for the D5005 sensors that are monitored by the MAX10 BMC. Signed-off-by: Matthew Gerlach <[email protected]> Signed-off-by: Russ Weight <[email protected]> Acked-by: Lee Jones <[email protected]> Reviewed-by: Tom Rix <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (sch5627) Split sch5627_update_device()Armin Wolf1-33/+69
An error in sch5627_update_device() could cause sch5627_read() to fail even if the error did not affect the target sensor type. Split sch5627_update_device() to prevent that. Tested on a Fujitsu Esprimo P720. Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (sch5627) Convert to hwmon_device_register_with_info()Armin Wolf1-232/+112
hwmon_device_register() is deprecated. Convert driver to use hwmon_device_register_with_info() and remove sysfs attributes which are now being handled by the hwmon subsystem. Channel handling was inspired by corsair-cpro. Tested on a Fujitsu Esprimo P720. Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Replaced 0 with NULL] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (nct6683) remove useless functionJiapeng Chong1-11/+0
Fix the following clang warning: drivers/hwmon/nct6683.c:491:19: warning: unused function 'in_to_reg' [-Wunused-function]. Reported-by: Abaci Robot <[email protected]> Signed-off-by: Jiapeng Chong <[email protected]> Link: https://lore.kernel.org/r/1618293770-55307-1-git-send-email-jiapeng.chong@linux.alibaba.com Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (dell-smm) Add Dell Latitude E7440 to fan control whitelistSebastian Oechsle1-0/+8
Allow manual PWM control on Dell Latitude E7440. Reviewed-by: Pali Rohár <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Oechsle <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (mlxreg-fan) Add support for fan drawers capability and present registersVadim Pasternak1-1/+50
Add support for fan drawer's capability and present registers in order to set mapping between the fan drawers and tachometers. Some systems are equipped with fan drawers with one tachometer inside. Others with fan drawers with several tachometers inside. Using present register along with tachometer-to-drawer mapping allows to skip reading missed tachometers and expose input for them as zero, instead of exposing fault code returned by hardware. Signed-off-by: Vadim Pasternak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus/tps53679) Add support for TI TPS53676Erik Rosen2-3/+52
Add support for TI TPS53676 controller to the tps53679 pmbus driver The driver uses the USER_DATA_03 register to figure out how many phases are enabled and to which channel they are assigned, and sets the number of pages and phases accordingly. Signed-off-by: Erik Rosen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (ftsteutates) Rudimentary typo fixesBhaskar Chowdhury1-1/+1
s/Temprature/Temperature/ s/revsion/revision/ Signed-off-by: Bhaskar Chowdhury <[email protected]> Acked-by: Randy Dunlap <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus) Add driver for BluTek BPA-RS600Chris Packham3-0/+182
The BPA-RS600 is a compact 600W AC to DC removable power supply module. Signed-off-by: Chris Packham <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Added bpa-rs600 to index.rst] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: replace snprintf in show functions with sysfs_emitGuenter Roeck24-150/+151
coccicheck complains about the use of snprintf() in sysfs show functions. drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf This results in a large number of patch submissions. Fix it all in one go using the following coccinelle rules. Use sysfs_emit instead of scnprintf or sprintf since that makes more sense. @depends on patch@ identifier show, dev, attr, buf; @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \), + sysfs_emit(buf, ...); ...> } @depends on patch@ identifier show, dev, attr, buf, rc; @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) { <... rc = - snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \), + sysfs_emit(buf, ...); ...> } While at it, remove unnecessary braces and as well as unnecessary else after return statements to address checkpatch warnings in the resulting patch. Cc: Zihao Tang <[email protected]> Cc: Jay Fang <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (pmbus) Replace - with _ in device names before registrationChris Packham1-1/+7
The hwmon sysfs ABI requires that the `name` property doesn't include any dashes. But when the pmbus code picks the name up from the device tree it quite often does. Replace '-' with '_' before registering the device. Signed-off-by: Chris Packham <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: add driver for NZXT Kraken X42/X52/X62/X72Jonas Malaco3-0/+245
These are "all-in-one" CPU liquid coolers that can be monitored and controlled through a proprietary USB HID protocol. While the models have differently sized radiators and come with varying numbers of fans, they are all indistinguishable at the software level. The driver exposes fan/pump speeds and coolant temperature through the standard hwmon sysfs interface. Fan and pump control, while supported by the devices, are not currently exposed. The firmware accepts up to 61 trip points per channel (fan/pump), but the same set of trip temperatures has to be maintained for both; with pwmX_auto_point_Y_temp attributes, users would need to maintain this invariant themselves. Instead, fan and pump control, as well as LED control (which the device also supports for 9 addressable RGB LEDs on the CPU water block) are left for existing and already mature user-space tools, which can still be used alongside the driver, thanks to hidraw. A link to one, which I also maintain, is provided in the documentation. The implementation is based on USB traffic analysis. It has been runtime tested on x86_64, both as a built-in driver and as a module. Signed-off-by: Jonas Malaco <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Removed unnecessary spinlock.h include] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: (ina2xx) Convert sysfs sprintf/snprintf family to sysfs_emitZihao Tang1-5/+4
Fix the following coccicheck warning: drivers/hwmon/ina2xx.c:313:8-16: WARNING: use scnprintf or sprintf drivers/hwmon/ina2xx.c:453:8-16: WARNING: use scnprintf or sprintf drivers/hwmon/ina2xx.c:484:8-16: WARNING: use scnprintf or sprintf drivers/hwmon/ina2xx.c:540:8-16: WARNING: use scnprintf or sprintf Signed-off-by: Zihao Tang <[email protected]> Signed-off-by: Jay Fang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
2021-04-20hwmon: Use kobj_to_dev()Guenter Roeck6-12/+12
coccinelle complains about WARNING opportunity for kobj_to_dev() in several files, resulting in one-by-one patch submissions. Handle all remaining instances in one go. Signed-off-by: Guenter Roeck <[email protected]>