Commit Graph

875604 Commits

Author SHA1 Message Date
Jiakun Shuai 6043d7860a Input: Add a new serio driver for Phytium PCI PS/2 controller
This driver supports Phytium PCI PS/2 controller.

Signed-off-by: Cheng Quan <chengquan@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Jiakun Shuai <shuaijiakun1288@phytium.com.cn>
(cherry picked from commit 399ce371c0)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:33 +08:00
Mao Hongbo e3d704f429 mmc-phytium-Add-support-for-the-Phytium-MMC
This patch adds the Phytium Multimedia Card Interface (MCI) driver.

Signed-off-by: Cheng Quan <chengquan@phytium.com.cn>
Signed-off-by: Lai Xueyu <laixueyu1280@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
(cherry picked from commit ea9baaf77c)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:32 +08:00
Mao Hongbo d4b6e6c8ec mmc-add-Phytium-SD-host-controller-support
Add support for the Phytium SD host controller driver.

Signed-off-by: Cheng Quan <chengquan@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
(cherry picked from commit e5d35c5590)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:32 +08:00
Mao Hongbo dc455b5c60 I3C driver support for Phytium desktop and embedded CPUs
Signed-off-by: Feng Jun <fengjun@phytium.com.cn>
Signed-off-by: Song Wenting <songwenting@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
(cherry picked from commit 89e4af5b21)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:32 +08:00
wangzhimin e937961354 Add Phytium ADC support
Phytium Pe220x SoCs includes an 8-channel, 10-bit single ended ADC
This patch add this ADC driver support

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 0b1dadff13)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:31 +08:00
wangzhimin f17c53e316 add Phytium w1 bus master driver
This patch adds support for the 1-wire master interface of Phytium.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 06cac346ea)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:31 +08:00
lishuo e0faf0d0f4 Input phytium keypad Add Phytium keypad driver
This patch adds support for Phytium keypad controller driver on Phytium SoCs.

Signed-off-by: Song Wenting <songwenting@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Shuo Li <lishuo@phytium.com.cn>
(cherry picked from commit 8fe5729e2d)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:31 +08:00
Malloy Liu 6f525d8d58 Add support for GD25Q128E, a 16MiB SPI Nor flash from GigaDevice
add new spi-nor flash support

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit 6ab4f737d9)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:30 +08:00
Malloy Liu 187c841190 Add driver for Phytium Hardware semaphore device found in E-series SoCs
add Phytium hwspinlock support for E-series Socs
verifyed on Phytium E2000D

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit effffb8226)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:30 +08:00
xuyan 6256809536 Phytium JPEG Encoder driver
Support for the Phytium JPEG Encoder Engine embedded in the Phytium SOCs.The engine can capture and compress video data from digital or analog sources.
Reviewed-by:maohongbo<maohongbo@phytium.com.cn>
Signed-off-by: Wang Min <wangmin@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>

(cherry picked from commit 6f9e10130c)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:30 +08:00
LiQian 02235ffc69 Add Phytium BT BMC driver support
adds a simple device driver to expose the BT interface
on Phytium SoC as a character device. Such SOCs are commonly
used as BMCs (BaseBoard Management Controllers) and this driver
implements the BMC side of the BT interface.

(cherry picked from commit ccb23948d0)
Signed-off-by: Alex Shi <alexsshi@tencent.com>

Conflicts:
	drivers/char/ipmi/Kconfig
	drivers/char/ipmi/Makefile
2024-06-11 21:23:29 +08:00
LiQian 9eaede7237 Add Phytium KCS IPMI BMC driver support
(cherry picked from commit 4d16c334ea)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:29 +08:00
Malloy Liu 64cd166e53 Add support for the Phytium QuadSPI controller driver
add support for the Phytium QuadSPI controller driver
verifyed on Phytium D2000

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit bce2cf32f3)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:29 +08:00
Mao Hongbo f13d8f3dcf xHCI-Add-XHCI_SLOWDOWN_QUIRK-quirk-for-phytium-xHCI
Since current Phytium Px210 xHCI host controller does not support
    USB Gen2(10Gbps) well, add the XHCI_SLOWDOWN_QUIRK quirk and
    modify the limited speed to 5Gbps.

    Signed-off-by: Feng Jun <fengjun@phytium.com.cn>
    Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>

(cherry picked from commit 50f3eecbba)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:28 +08:00
lishuo cb18a9e935 DRM phytium Add Phytium Display Engine support
Phytium Display Engine support,DC/DP driver patch.
Signed-off-by: Yang Xun <yangxun@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Reviewed-by:Hongbo Mao<maohongbo@phytium.com.cn>
(cherry picked from commit efc4d36af4)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:28 +08:00
wangzhimin 2a45492359 Add support for PCIe endpoint controller support
Add PCIe endpoint controller driver for Phytium Pd2008 SoC.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 7eb97a92ef)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:27 +08:00
wangzhimin 3c39fb8af0 Add support for Phytium fan tacho driver support
Add a driver for fan tachometer and capture counter of Phytium SoCs.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit cf09b9c0f0)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:27 +08:00
wangzhimin 4b6f92875b Add support for Phytium INTx controller
Add an standalone irqchip driver to handle Phytium PCI legacy interrupt.
When processing legacy INTx interrupts on some Phytium SoCs, the interrupt
status registers have be cleared by software explicitly. We introduce this
standalone irqchip which sits between the PCI legacy interrupt and the GIC,
applying hierarchical irqdomain to integrate the ack in the existing INTx
processing flow.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit aa66828d35)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:23:25 +08:00
Marc Zyngier de8d123244 irqchip/gic-v3-its: Balance initial LPI affinity across CPUs
When mapping a LPI, the ITS driver picks the first possible
affinity, which is in most cases CPU0, assuming that if
that's not suitable, someone will come and set the affinity
to something more interesting.

It apparently isn't the case, and people complain of poor
performance when many interrupts are glued to the same CPU.
So let's place the interrupts by finding the "least loaded"
CPU (that is, the one that has the fewer LPIs mapped to it).
So called 'managed' interrupts are an interesting case where
the affinity is actually dictated by the kernel itself, and
we should honor this.

Reported-by: John Garry <john.garry@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: John Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/1575642904-58295-1-git-send-email-john.garry@huawei.com
Link: https://lore.kernel.org/r/20200515165752.121296-3-maz@kernel.org
(cherry picked from commit 840775cad1)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:53 +08:00
Marc Zyngier 52c593efad irqchip/gic-v3-its: Track LPI distribution on a per CPU basis
In order to improve the distribution of LPIs among CPUs, let start by
tracking the number of LPIs assigned to CPUs, both for managed and
non-managed interrupts (as separate counters).

Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: John Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/20200515165752.121296-2-maz@kernel.org
(cherry picked from commit aca60b181c)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:53 +08:00
wangzhimin 1f54b0f4da usb: phytium: Add support for Phytium USB controller
This patch adds the Phytium USBHS DRD controller support.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 8e4291c455)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:52 +08:00
wangzhimin 666b19bb8a usb: xhci: xhci-plat: Support for Phytium Pe220x
Add XHCI_RESET_ON_RESUME quirk for Phytium Pe220x
Phytium Pe220x xHCI host controller does not have suspend/resume
support. Therefore, use of the XHCI_RESET_ON_RESUME quirk is
mandatory in order to avoid failures after resume.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 33d50ca483)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:52 +08:00
wangzhimin 3523026413 dts: phytium: Add dts for Phytium Pe220x SoCs
Add initial device tree for Phytium Pe220x SoCs. Phytium Pe220x
series has three specs (Pe2201/Pe2202/Pe2204), distinguished by
the number of CPU core. Besides CPU cores, on-chip peripherals
also vary. Thus, we split them into three separate DTBs.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 1d5bb1d501)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:52 +08:00
Malloy Liu e6a5e0220d SPI platform driver support for Phytium desktop CPUS
SPI platform driver for Phytium desktop CPUs, such as FT-2000/4 and D2000.

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit 555ae1361a)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:51 +08:00
Chen Siyu 118c8fd2e9 Update pci_ids.h with the vendor ID for Phytium.
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
(cherry picked from commit b4a61a7b90)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:51 +08:00
Wei Tian 34d43e196f OPTEE driver support for Phytium CPUs
OPTEE driver support for Phytium CPUs, such as FT2000/4 and D2000.

From: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Tian wei <tianwei@phytium.com.cn>
Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit a0f9867a4d)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:51 +08:00
liqian cfd2453d13 GPIO driver support for Phytium desktop and embedded CPUs
GPIO dirver fix patch. Support Phytiumm Desktop and Embedded CPUs, such as D2000 and E2000.

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit c2a5e2beae)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:50 +08:00
wangzhimin b4e38c43b9 This patch makes stmmac driver support SBSA compatible Phytium
SoC's on-chip RGMII.

Signed-off-by: wangzhimin <wangzhimin1179@phytium.com.cn>
(cherry picked from commit 4611897533)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:50 +08:00
Wang Nan 43dd0e35f4 RTC driver support for Phytium desktop and embedded CPUs
RTC driver function fix patch Support Phytium desktop and embedded processors, such as D2000 and E2000

Reviewed-by: Wang Nan <wangnan1505@phytium.com.cn>
(cherry picked from commit 00f079b210)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:49 +08:00
Wei Tian 9cd366d0b7 HDA driver support for Phytium desktop
(cherry picked from commit 61b278c01b)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:49 +08:00
JianChao Sheng 9b68c04c3f serial driver support for Phytium desktop and embedded CPUs
serial driver function fix patch. Support Phytium desktop and embedded processors, such as D2000.

Reviewed-by:JianChao Sheng <shengjianchao@phytium.com.cn>
(cherry picked from commit 92e0f87830)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:49 +08:00
Chen 91005b7f50 mailbox driver support for Phytium desktop and embedded CPUs
Mailbox driver function patch. Support Phytium desktop and embedded processors, such as D2000 and E2000.

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit f6e90a3999)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:48 +08:00
Chen Siyu 336d83440a dt-bindings-can-phytium-Add-bindings-for-Phytium-CAN
add-Phytium-CAN-controller-support

reviewed-by: Chen Siyu <chensiyu1321@phytium.com.cn>
Signed-off-by: Cheng Quan <chengquan@phytium.com.cn>
Signed-off-by: Li Zhengguang <lizhengguang1317@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Chen Siyu <chensiyu1321@phytium.com.cn>
(cherry picked from commit 213232efb8)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:48 +08:00
Chen Baozi 903a7a8578 Add MAINTAINERS entry for Phytium SoC family with myself as the
maintainer.

Signed-off-by: Chen siyu <chensiyu1321@phytium.com.cn>
(cherry picked from commit 98728ad782)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:47 +08:00
Jiakun Shuai 80ed68fc2e I2C driver support for Phytium Desktop CPUs
I2C driver function fix patch. Support Phytium desktop and embedded processors, such as D2000 and E2000.

Reviewed-by: Hongbo Mao <maohongbo@phytium.com.cn>
(cherry picked from commit 5ec3d87d62)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:47 +08:00
Jianping Liu 22599f9f53 irqlatency: add irq latency monitor support
Long irq latency will affect other latency, such as answer a net
packet. Add a ko to debug long irq latency, account the delay
and show the stack.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
(cherry picked from commit 9056a7a86e)
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:47 +08:00
Kairui Song 90bce3e26e dist: config: clean up LOCALVERSION related config
To avoid Kbuild from touching kernel versioning, ensure relate configs
are clean.

Signed-off-by: Kairui Song <kasong@tencent.com>
2024-06-11 21:18:46 +08:00
Jianping Liu b6e6cd46c2 fix gcc compile floating-point computation program when using option -march=native
When compile UnixBench, using command as below:
	gcc -o pgms/float -Wall -pedantic -O0 -march=native -mtune=native -I ./src -DTIME -Ddatum=float src/arith.c
It will have an error:
	src/arith.c: In function ‘dumb_stuff’:
	src/arith.c:89:5: error: ‘+nofp’ feature modifier is incompatible with floating-point code

The root cause is that gcc will read /proc/cpuinfo, get supported features from the line begin with 'Features'.
But tk4 haven't 'Features', it using 'flags' instead, which causing gcc can't get the supported features.

The correct usage is "Features:" always, just a buggy patch change it to
'flags' stupidly. Now change it back.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:46 +08:00
Alex Shi 43a4a510ff config: remove LOCALVERSION
Signed-off-by: Alex Shi <alexsshi@tencent.com>
2024-06-11 21:18:46 +08:00
Xinghui Li d285a21e4e fuse: fix one null ptr issue in fuse_dev_ioctl
commit opencloudos.

In this code snippet, there is a potential risk when cmd is
FUSE_DEV_IOC_RECOVERY, and either fud or fud->fc is empty. This
could lead to severe null pointer issues, so we perform a non-null
check before using them.

Fixes: e1c207b3e7cdfd98("fuse: add a dev ioctl for recovery")
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:45 +08:00
Zhen Lei 89f94b88f4 fbmem: Do not delete the mode that is still in use
commit 0af778269a upstream.

The execution of fb_delete_videomode() is not based on the result of the
previous fbcon_mode_deleted(). As a result, the mode is directly deleted,
regardless of whether it is still in use, which may cause UAF.

==================================================================
BUG: KASAN: use-after-free in fb_mode_is_equal+0x36e/0x5e0 \
drivers/video/fbdev/core/modedb.c:924
Read of size 4 at addr ffff88807e0ddb1c by task syz-executor.0/18962

CPU: 2 PID: 18962 Comm: syz-executor.0 Not tainted 5.10.45-rc1+ #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ...
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x137/0x1be lib/dump_stack.c:118
 print_address_description+0x6c/0x640 mm/kasan/report.c:385
 __kasan_report mm/kasan/report.c:545 [inline]
 kasan_report+0x13d/0x1e0 mm/kasan/report.c:562
 fb_mode_is_equal+0x36e/0x5e0 drivers/video/fbdev/core/modedb.c:924
 fbcon_mode_deleted+0x16a/0x220 drivers/video/fbdev/core/fbcon.c:2746
 fb_set_var+0x1e1/0xdb0 drivers/video/fbdev/core/fbmem.c:975
 do_fb_ioctl+0x4d9/0x6e0 drivers/video/fbdev/core/fbmem.c:1108
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 18960:
 kasan_save_stack mm/kasan/common.c:48 [inline]
 kasan_set_track+0x3d/0x70 mm/kasan/common.c:56
 kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0x108/0x140 mm/kasan/common.c:422
 slab_free_hook mm/slub.c:1541 [inline]
 slab_free_freelist_hook+0xd6/0x1a0 mm/slub.c:1574
 slab_free mm/slub.c:3139 [inline]
 kfree+0xca/0x3d0 mm/slub.c:4121
 fb_delete_videomode+0x56a/0x820 drivers/video/fbdev/core/modedb.c:1104
 fb_set_var+0x1f3/0xdb0 drivers/video/fbdev/core/fbmem.c:978
 do_fb_ioctl+0x4d9/0x6e0 drivers/video/fbdev/core/fbmem.c:1108
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 13ff178ccd ("fbcon: Call fbcon_mode_deleted/new_modelist directly")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: <stable@vger.kernel.org> # v5.3+
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712085544.2828-1-thunder.leizhen@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:45 +08:00
Sun Ke b97c15e96b nbd: Fix NULL pointer in flush_workqueue
commit 79ebe9110f upstream.

Open /dev/nbdX first, the config_refs will be 1 and
the pointers in nbd_device are still null. Disconnect
/dev/nbdX, then reference a null recv_workq. The
protection by config_refs in nbd_genl_disconnect is useless.

[  656.366194] BUG: kernel NULL pointer dereference, address: 0000000000000020
[  656.368943] #PF: supervisor write access in kernel mode
[  656.369844] #PF: error_code(0x0002) - not-present page
[  656.370717] PGD 10cc87067 P4D 10cc87067 PUD 1074b4067 PMD 0
[  656.371693] Oops: 0002 [#1] SMP
[  656.372242] CPU: 5 PID: 7977 Comm: nbd-client Not tainted 5.11.0-rc5-00040-g76c057c84d28 #1
[  656.373661] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
[  656.375904] RIP: 0010:mutex_lock+0x29/0x60
[  656.376627] Code: 00 0f 1f 44 00 00 55 48 89 fd 48 83 05 6f d7 fe 08 01 e8 7a c3 ff ff 48 83 05 6a d7 fe 08 01 31 c0 65 48 8b 14 25 00 6d 01 00 <f0> 48 0f b1 55 d
[  656.378934] RSP: 0018:ffffc900005eb9b0 EFLAGS: 00010246
[  656.379350] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[  656.379915] RDX: ffff888104cf2600 RSI: ffffffffaae8f452 RDI: 0000000000000020
[  656.380473] RBP: 0000000000000020 R08: 0000000000000000 R09: ffff88813bd6b318
[  656.381039] R10: 00000000000000c7 R11: fefefefefefefeff R12: ffff888102710b40
[  656.381599] R13: ffffc900005eb9e0 R14: ffffffffb2930680 R15: ffff88810770ef00
[  656.382166] FS:  00007fdf117ebb40(0000) GS:ffff88813bd40000(0000) knlGS:0000000000000000
[  656.382806] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  656.383261] CR2: 0000000000000020 CR3: 0000000100c84000 CR4: 00000000000006e0
[  656.383819] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  656.384370] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  656.384927] Call Trace:
[  656.385111]  flush_workqueue+0x92/0x6c0
[  656.385395]  nbd_disconnect_and_put+0x81/0xd0
[  656.385716]  nbd_genl_disconnect+0x125/0x2a0
[  656.386034]  genl_family_rcv_msg_doit.isra.0+0x102/0x1b0
[  656.386422]  genl_rcv_msg+0xfc/0x2b0
[  656.386685]  ? nbd_ioctl+0x490/0x490
[  656.386954]  ? genl_family_rcv_msg_doit.isra.0+0x1b0/0x1b0
[  656.387354]  netlink_rcv_skb+0x62/0x180
[  656.387638]  genl_rcv+0x34/0x60
[  656.387874]  netlink_unicast+0x26d/0x590
[  656.388162]  netlink_sendmsg+0x398/0x6c0
[  656.388451]  ? netlink_rcv_skb+0x180/0x180
[  656.388750]  ____sys_sendmsg+0x1da/0x320
[  656.389038]  ? ____sys_recvmsg+0x130/0x220
[  656.389334]  ___sys_sendmsg+0x8e/0xf0
[  656.389605]  ? ___sys_recvmsg+0xa2/0xf0
[  656.389889]  ? handle_mm_fault+0x1671/0x21d0
[  656.390201]  __sys_sendmsg+0x6d/0xe0
[  656.390464]  __x64_sys_sendmsg+0x23/0x30
[  656.390751]  do_syscall_64+0x45/0x70
[  656.391017]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

To fix it, just add if (nbd->recv_workq) to nbd_disconnect_and_put().

Fixes: e9e006f5fc ("nbd: fix max number of supported devs")
Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20210512114331.1233964-2-sunke32@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:44 +08:00
Alison Schofield e298dc5383 x86, sched: Treat Intel SNC topology as default, COD as exception
commit 2c88d45edb uptream.

Commit 1340ccfa9a ("x86,sched: Allow topologies where NUMA nodes
share an LLC") added a vendor and model specific check to never
call topology_sane() for Intel Skylake Server systems where NUMA
nodes share an LLC.

Intel Ice Lake and Sapphire Rapids CPUs also enumerate an LLC that is
shared by multiple NUMA nodes. The LLC on these CPUs is shared for
off-package data access but private to the NUMA node for on-package
access. Rather than managing a list of allowable SNC topologies, make
this SNC topology the default, and treat Intel's Cluster-On-Die (COD)
topology as the exception.

In SNC mode, Sky Lake, Ice Lake, and Sapphire Rapids servers do not
emit this warning:

sched: CPU #3's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.

Intel-SIG: commit 2c88d45edb x86, sched: Treat Intel SNC topology as default,
COD as exception.
Backport for avoiding smpboot warning with SNC mode.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20210310190233.31752-1-alison.schofield@intel.com
[ Huaisheng Ye amend commit log ]
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:44 +08:00
Xiaochen Shen 68974a46ed dmaengine: idxd: Fix max batch size for Intel IAA
commit e8dbd6445d upstream.

>From Intel IAA spec [1], Intel IAA does not support batch processing.

Two batch related default values for IAA are incorrect in current code:
(1) The max batch size of device is set during device initialization,
    that indicates batch is supported. It should be always 0 on IAA.
(2) The max batch size of work queue is set to WQ_DEFAULT_MAX_BATCH (32)
    as the default value regardless of Intel DSA or IAA device during
    work queue setup and cleanup. It should be always 0 on IAA.

Fix the issues by setting the max batch size of device and max batch
size of work queue to 0 on IAA device, that means batch is not
supported.

[1]: https://cdrdv2.intel.com/v1/dl/getContent/721858

【【SPR内核开发】SPR系列patch合入kernel+kvm】http://tapd.oa.com/Virtualization/prong/stories/view/1020422237869387499
--story=869387499 【SPR内核开发】SPR系列patch合入kernel+kvm

Fixes: 23084545db ("dmaengine: idxd: set max_xfer and max_batch for RO device")
Fixes: 92452a72eb ("dmaengine: idxd: set defaults for wq configs")
Fixes: bfe1d56091 ("dmaengine: idxd: Init and probe for Intel data accelerators")
Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20220930201528.18621-2-xiaochen.shen@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Chen Zhuo <sagazchen@tencent.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:44 +08:00
Andy Shevchenko ce1f9ef1de include/linux/list.h: add a macro to test if entry is pointing to the head
commit e130816164 upstream.

Add a macro to test if entry is pointing to the head of the list which is
useful in cases like:

  list_for_each_entry(pos, &head, member) {
    if (cond)
      break;
  }
  if (list_entry_is_head(pos, &head, member))
    return -ERRNO;

that allows to avoid additional variable to be added to track if loop has
not been stopped in the middle.

While here, convert list_for_each_entry*() family of macros to use a new one.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lkml.kernel.org/r/20200929134342.51489-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:43 +08:00
Kan Liang eb6d9b7c1b perf/x86/intel: Support CPUID 10.ECX to disable fixed counters
commit 32451614da upstream.

With Architectural Performance Monitoring Version 5, CPUID 10.ECX cpu
leaf indicates the fixed counter enumeration. This extends the previous
count to a bitmap which allows disabling even lower fixed counters.
It could be used by a Hypervisor.

The existing intel_ctrl variable is used to remember the bitmask of the
counters. All code that reads all counters is fixed to check this extra
bitmask.

Intel-SIG: commit 32451614da perf/x86/intel: Support CPUID 10.ECX to
disable fixed counters
Backport for Sapphire Rapids core PMU support.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Originally-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-6-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:43 +08:00
Kan Liang 880fd22ea4 perf/x86/intel: Add perf core PMU support for Sapphire Rapids
commit 61b985e3e7 upstream.

Add perf core PMU support for the Intel Sapphire Rapids server, which is
the successor of the Intel Ice Lake server. The enabling code is based
on Ice Lake, but there are several new features introduced.

The event encoding is changed and simplified, e.g., the event codes
which are below 0x90 are restricted to counters 0-3. The event codes
which above 0x90 are likely to have no restrictions. The event
constraints, extra_regs(), and hardware cache events table are changed
accordingly.

A new Precise Distribution (PDist) facility is introduced, which
further minimizes the skid when a precise event is programmed on the GP
counter 0. Enable the Precise Distribution (PDist) facility with :ppp
event. For this facility to work, the period must be initialized with a
value larger than 127. Add spr_limit_period() to apply the limit for
:ppp event.

Two new data source fields, data block & address block, are added in the
PEBS Memory Info Record for the load latency event. To enable the
feature,
- An auxiliary event has to be enabled together with the load latency
  event on Sapphire Rapids. A new flag PMU_FL_MEM_LOADS_AUX is
  introduced to indicate the case. A new event, mem-loads-aux, is
  exposed to sysfs for the user tool.
  Add a check in hw_config(). If the auxiliary event is not detected,
  return an unique error -ENODATA.
- The union perf_mem_data_src is extended to support the new fields.
- Ice Lake and earlier models do not support block information, but the
  fields may be set by HW on some machines. Add pebs_no_block to
  explicitly indicate the previous platforms which don't support the new
  block fields. Accessing the new block fields are ignored on those
  platforms.

A new store Latency facility is introduced, which leverages the PEBS
facility where it can provide additional information about sampled
stores. The additional information includes the data address, memory
auxiliary info (e.g. Data Source, STLB miss) and the latency of the
store access. To enable the facility, the new event (0x02cd) has to be
programed on the GP counter 0. A new flag PERF_X86_EVENT_PEBS_STLAT is
introduced to indicate the event. The store_latency_data() is introduced
to parse the memory auxiliary info.

The layout of access latency field of PEBS Memory Info Record has been
changed. Two latency, instruction latency (bit 15:0) and cache access
latency (bit 47:32) are recorded.
- The cache access latency is similar to previous memory access latency.
  For loads, the latency starts by the actual cache access until the
  data is returned by the memory subsystem.
  For stores, the latency starts when the demand write accesses the L1
  data cache and lasts until the cacheline write is completed in the
  memory subsystem.
  The cache access latency is stored in low 32bits of the sample type
  PERF_SAMPLE_WEIGHT_STRUCT.
- The instruction latency starts by the dispatch of the load operation
  for execution and lasts until completion of the instruction it belongs
  to.
  Add a new flag PMU_FL_INSTR_LATENCY to indicate the instruction
  latency support. The instruction latency is stored in the bit 47:32
  of the sample type PERF_SAMPLE_WEIGHT_STRUCT.

Extends the PERF_METRICS MSR to feature TMA method level 2 metrics. The
lower half of the register is the TMA level 1 metrics (legacy). The
upper half is also divided into four 8-bit fields for the new level 2
metrics. Expose all eight Topdown metrics events to user space.

The full description for the SPR features can be found at Intel
Architecture Instruction Set Extensions and Future Features
Programming Reference, 319433-041.

Intel-SIG: commit 61b985e3e7 perf/x86/intel: Add perf core PMU
support for Sapphire Rapids
Backport for Sapphire Rapids core PMU support.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-5-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:43 +08:00
Kan Liang 387fdcbbf8 perf/x86/intel: Filter unsupported Topdown metrics event
commit 1ab5f235c1 upstream.

Intel Sapphire Rapids server will introduce 8 metrics events. Intel
Ice Lake only supports 4 metrics events. A perf tool user may mistakenly
use the unsupported events via RAW format on Ice Lake. The user can
still get a value from the unsupported Topdown metrics event once the
following Sapphire Rapids enabling patch is applied.

To enable the 8 metrics events on Intel Sapphire Rapids, the
INTEL_TD_METRIC_MAX has to be updated, which impacts the
is_metric_event(). The is_metric_event() is a generic function.
On Ice Lake, the newly added SPR metrics events will be mistakenly
accepted as metric events on creation. At runtime, the unsupported
Topdown metrics events will be updated.

Add a variable num_topdown_events in x86_pmu to indicate the available
number of the Topdown metrics event on the platform. Apply the number
into is_metric_event(). Only the supported Topdown metrics events
should be created as metrics events.

Apply the num_topdown_events in icl_update_topdown_event() as well. The
function can be reused by the following patch.

Intel-SIG: commit 1ab5f235c1 perf/x86/intel: Filter unsupported
Topdown metrics event
Backport for Sapphire Rapids core PMU support.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-4-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:42 +08:00
Kan Liang 7d04210670 perf/x86/intel: Factor out intel_update_topdown_event()
commit 628d923a3c upstream.

Similar to Ice Lake, Intel Sapphire Rapids server also supports the
topdown performance metrics feature. The difference is that Intel
Sapphire Rapids server extends the PERF_METRICS MSR to feature TMA
method level two metrics, which will introduce 8 metrics events. Current
icl_update_topdown_event() only check 4 level one metrics events.

Factor out intel_update_topdown_event() to facilitate the code sharing
between Ice Lake and Sapphire Rapids.

Intel-SIG: commit 628d923a3c perf/x86/intel: Factor out
intel_update_topdown_event()
Backport for Sapphire Rapids core PMU support.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-3-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:42 +08:00
Kan Liang bc2637e898 perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT
commit 2a6c6b7d7a upstream.

Current PERF_SAMPLE_WEIGHT sample type is very useful to expresses the
cost of an action represented by the sample. This allows the profiler
to scale the samples to be more informative to the programmer. It could
also help to locate a hotspot, e.g., when profiling by memory latencies,
the expensive load appear higher up in the histograms. But current
PERF_SAMPLE_WEIGHT sample type is solely determined by one factor. This
could be a problem, if users want two or more factors to contribute to
the weight. For example, Golden Cove core PMU can provide both the
instruction latency and the cache Latency information as factors for the
memory profiling.

For current X86 platforms, although meminfo::latency is defined as a
u64, only the lower 32 bits include the valid data in practice (No
memory access could last than 4G cycles). The higher 32 bits can be used
to store new factors.

Add a new sample type, PERF_SAMPLE_WEIGHT_STRUCT, to indicate the new
sample weight structure. It shares the same space as the
PERF_SAMPLE_WEIGHT sample type.

Users can apply either the PERF_SAMPLE_WEIGHT sample type or the
PERF_SAMPLE_WEIGHT_STRUCT sample type to retrieve the sample weight, but
they cannot apply both sample types simultaneously.

Currently, only X86 and PowerPC use the PERF_SAMPLE_WEIGHT sample type.
- For PowerPC, there is nothing changed for the PERF_SAMPLE_WEIGHT
  sample type. There is no effect for the new PERF_SAMPLE_WEIGHT_STRUCT
  sample type. PowerPC can re-struct the weight field similarly later.
- For X86, the same value will be dumped for the PERF_SAMPLE_WEIGHT
  sample type or the PERF_SAMPLE_WEIGHT_STRUCT sample type for now.
  The following patches will apply the new factors for the
  PERF_SAMPLE_WEIGHT_STRUCT sample type.

The field in the union perf_sample_weight should be shared among
different architectures. A generic name is required, but it's hard to
abstract a name that applies to all architectures. For example, on X86,
the fields are to store all kinds of latency. While on PowerPC, it
stores MMCRA[TECX/TECM], which should not be latency. So a general name
prefix 'var$NUM' is used here.

Intel-SIG: commit 2a6c6b7d7a perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT
Backport for Sapphire Rapids core PMU support.
Note: This backported patch has some deviations from upstream version.
To avoid enum hole in perf_event_sample_format struct, we added
PERF_SAMPLE_{AUX,CGROUP,DATA_PAGE_SIZE,CODE_PAGE_SIZE} to file
include/uapi/linux/perf_event.h, but didn't backport the full patchsets
that introducing these enumeration values. To avoid mishandling of these
sampling formats, we added check to perf_copy_attr() in
kernel/events/core.c, to make sure -EINVAL always being returned for
these lack-of-kernel-support sampling formats.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-2-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:41 +08:00