5.11.3-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 435/775 RDMA/hns: Remove the reserved WQE of SRQ
In reply to Greg Kroah-HartmanFrom: Wenpeng Liang <[email protected]>
[ Upstream commit 6ee00fbf733d7e17ca935e5636adfce605b10659 ]
Each SRQs contain an reserved WQE, it is inappropriate and should be removed.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 1 + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- drivers/infiniband/hw/hns/hns_roce_srq.c | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -0
@@ -54,6 +54,7 @@/* Hardware specification only for v1 engine */ #define HNS_ROCE_MIN_CQE_NUM 0x40#define HNS_ROCE_MIN_WQE_NUM 0x20 +#define HNS_ROCE_MIN_SRQ_WQE_NUM 1/* Hardware specification only for v1 engine */ #define HNS_ROCE_MAX_INNER_MTPT_NUM 0x7
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -3
@@ -860,7 +860,7 @@ int hns_roce_srqwq_overflow(struct hns_roce_srq *srq, int nreq)unsigned int cur; cur = idx_que->head - idx_que->tail; -return cur + nreq >= srq->wqe_cnt -1 ; +return cur + nreq >= srq->wqe_cnt; } static int find_empty_entry(struct hns_roce_idx_que *idx_que,
@@ -5350,7 +5350,7 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq,return -EINVAL ;if (srq_attr_mask &IB_SRQ_LIMIT ) { -if (srq_attr->srq_limit >= srq->wqe_cnt) +if (srq_attr->srq_limit > srq->wqe_cnt)return -EINVAL ; mailbox =hns_roce_alloc_cmd_mailbox (hr_dev);
@@ -5413,7 +5413,7 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) SRQC_BYTE_8_SRQ_LIMIT_WL_S); attr->srq_limit = limit_wl; - attr->max_wr = srq->wqe_cnt -1 ; + attr->max_wr = srq->wqe_cnt; attr->max_sge = srq->max_gs - srq->rsv_sge; out:
drivers/infiniband/hw/hns/hns_roce_srq.c +4 -2
@@ -322,7 +322,7 @@ int hns_roce_create_srq(struct ib_srq *ib_srq, max_sge =proc_srq_sge (hr_dev, srq, !!udata); -if (init_attr->attr.max_wr >= hr_dev->caps.max_srq_wrs || +if (init_attr->attr.max_wr > hr_dev->caps.max_srq_wrs || init_attr->attr.max_sge > max_sge) { ibdev_err(&hr_dev->ib_dev, "SRQ config error, depth = %u, sge = %d\n",
@@ -333,7 +333,9 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,mutex_init (&srq->mutex);spin_lock_init (&srq->lock); - srq->wqe_cnt =roundup_pow_of_two (init_attr->attr.max_wr +1 ); + init_attr->attr.max_wr =max_t (u32, init_attr->attr.max_wr, +HNS_ROCE_MIN_SRQ_WQE_NUM ); + srq->wqe_cnt =roundup_pow_of_two (init_attr->attr.max_wr); srq->max_gs =roundup_pow_of_two (init_attr->attr.max_sge + srq->rsv_sge); init_attr->attr.max_wr = srq->wqe_cnt;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 436/775 RDMA/siw: Fix calculation of tx_valid_cpus size
In reply to Greg Kroah-HartmanFrom: Kamal Heib <[email protected]>
[ Upstream commit 429fa9698957d1a910535ce5e33aedf5adfdabc1 ]
The size of tx_valid_cpus was calculated under the assumption that the numa nodes identifiers are continuous, which is not the case in all archs as this could lead to the following panic when trying to access an invalid tx_valid_cpus index, avoid the following panic by using nr_node_ids instead of num_online_nodes() to allocate the tx_valid_cpus size.
Kernel attempted to read user page (8) - exploit attempt? (uid: 0)
BUG: Kernel NULL pointer dereference on read at 0x00000008 Faulting instruction address: 0xc0080000081b4a90 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA PowerNV Modules linked in: siw(+) rfkill rpcrdma ib_isert iscsi_target_mod ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib rdma_ucm sunrpc ib_umad rdma_cm ib_cm iw_cm i40iw ib_uverbs ib_core i40e ses enclosure scsi_transport_sas ipmi_powernv ibmpowernv at24 ofpart ipmi_devintf regmap_i2c ipmi_msghandler powernv_flash uio_pdrv_genirq uio mtd opal_prd zram ip_tables xfs libcrc32c sd_mod t10_pi ast i2c_algo_bit drm_vram_helper drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec drm_ttm_helper ttm drm vmx_crypto aacraid drm_panel_orientation_quirks dm_mod CPU: 40 PID: 3279 Comm: modprobe Tainted: G W X --------- --- 5.11.0-0.rc4.129.eln108.ppc64le #2 NIP: c0080000081b4a90 LR: c0080000081b4a2c CTR: c0000000007ce1c0 REGS: c000000027fa77b0 TRAP: 0300 Tainted: G W X --------- --- (5.11.0-0.rc4.129.eln108.ppc64le) MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 44224882 XER: 00000000 CFAR: c0000000007ce200 DAR: 0000000000000008 DSISR: 40000000 IRQMASK: 0 GPR00: c0080000081b4a2c c000000027fa7a50 c0080000081c3900 0000000000000040 GPR04: c000000002023080 c000000012e1c300 000020072ad70000 0000000000000001 GPR08: c000000001726068 0000000000000008 0000000000000008 c0080000081b5758 GPR12: c0000000007ce1c0 c0000007fffc3000 00000001590b1e40 0000000000000000 GPR16: 0000000000000000 0000000000000001 000000011ad68fc8 00007fffcc09c5c8 GPR20: 0000000000000008 0000000000000000 00000001590b2850 00000001590b1d30 GPR24: 0000000000043d68 000000011ad67a80 000000011ad67a80 0000000000100000 GPR28: c000000012e1c300 c0000000020271c8 0000000000000001 c0080000081bf608 NIP [c0080000081b4a90] siw_init_cpulist+0x194/0x214 [siw] LR [c0080000081b4a2c] siw_init_cpulist+0x130/0x214 [siw] Call Trace: [c000000027fa7a50] [c0080000081b4a2c] siw_init_cpulist+0x130/0x214 [siw] (unreliable) [c000000027fa7a90] [c0080000081b4e68] siw_init_module+0x40/0x2a0 [siw] [c000000027fa7b30] [c0000000000124f4] do_one_initcall+0x84/0x2e0 [c000000027fa7c00] [c000000000267ffc] do_init_module+0x7c/0x350 [c000000027fa7c90] [c00000000026a180] __do_sys_init_module+0x210/0x250 [c000000027fa7db0] [c0000000000387e4] system_call_exception+0x134/0x230 [c000000027fa7e10] [c00000000000d660] system_call_common+0xf0/0x27c Instruction dump: 40810044 3d420000 e8bf0000 e88a82d0 3d420000 e90a82c8 792a1f24 7cc4302a 7d2642aa 79291f24 7d25482a 7d295214 <7d4048a8> 7d4a3b78 7d4049ad 40c2fff4
--- drivers/infiniband/sw/siw/siw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_main.c +1 -1
@@ -135,7 +135,7 @@ static struct {static int siw_init_cpulist (void ) { -int i, num_nodes =num_possible_nodes (); +int i, num_nodes = nr_node_ids;memset (siw_tx_thread,0 ,sizeof (siw_tx_thread));
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 437/775 RDMA/hns: Avoid filling sgid index when modifying QP to RTR
In reply to Greg Kroah-HartmanFrom: Weihang Li <[email protected]>
[ Upstream commit 773f841ab1aeb0134e3872eb3545592732db8218 ]
ULP usually set IB(V)_QP_AV when trying to modify QP to RTR if they want to record sgid index into QPC. For UD QPs, it is useless because it will be included in WQE. For RC QPs, it will be filled in hns_roce_set_path(). So sgid index shouldn't be filled by default. Then hns_get_gid_index() is moved to hns_roce_hw_v1.c because it is only called in it.
--- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 16 ++++++++++++++++ drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 11 ----------- drivers/infiniband/hw/hns/hns_roce_main.c | 16 ---------------- 3 files changed, 16 insertions(+), 27 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +16 -0
@@ -43,6 +43,22 @@#include "hns_roce_hem.h" #include "hns_roce_hw_v1.h" +/** +* hns_get_gid_index - Get gid index. +* @hr_dev: pointer to structure hns_roce_dev. +* @port: port, value range: 0 ~ MAX +* @gid_index: gid_index, value range: 0 ~ MAX +* Description: +* N ports shared gids, allocation method as follow: +* GID[0][0], GID[1][0],.....GID[N - 1][0], +* GID[0][0], GID[1][0],.....GID[N - 1][0], +* And so on +*/ +u8 hns_get_gid_index (struct hns_roce_dev *hr_dev,u8 port,int gid_index) +{ +return gid_index * hr_dev->caps.num_ports + port; +} +static void set_data_seg (struct hns_roce_wqe_data_seg *dseg,struct ib_sge *sg) { dseg->lkey =cpu_to_le32 (sg->lkey);
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -11
@@ -4254,7 +4254,6 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,struct hns_roce_v2_qp_context *context, struct hns_roce_v2_qp_context *qpc_mask) { - const struct ib_global_route *grh = rdma_ah_read_grh(&attr->ah_attr); struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);struct hns_roce_qp *hr_qp =to_hr_qp (ibqp);struct ib_device *ibdev = &hr_dev->ib_dev;
@@ -4262,7 +4261,6 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,dma_addr_t irrl_ba;enum ib_mtu mtu;u8 lp_pktn_ini; -u8 port_num;u64 *mtts;u8 *dmac;u8 *smac;
@@ -4343,15 +4341,6 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, V2_QPC_BYTE_56_DQPN_M, V2_QPC_BYTE_56_DQPN_S, 0); } -/* Configure GID index */ - port_num =rdma_ah_get_port_num (&attr->ah_attr); -roce_set_field (context->byte_20_smac_sgid_idx, -V2_QPC_BYTE_20_SGID_IDX_M ,V2_QPC_BYTE_20_SGID_IDX_S , -hns_get_gid_index (hr_dev, port_num -1 , - grh->sgid_index)); -roce_set_field (qpc_mask->byte_20_smac_sgid_idx, -V2_QPC_BYTE_20_SGID_IDX_M ,V2_QPC_BYTE_20_SGID_IDX_S ,0 ); -memcpy (&(context->dmac), dmac,sizeof (u32));roce_set_field (context->byte_52_udpspn_dmac,V2_QPC_BYTE_52_DMAC_M ,V2_QPC_BYTE_52_DMAC_S , *((u16 *)(&dmac[4 ])));
drivers/infiniband/hw/hns/hns_roce_main.c +0 -16
@@ -42,22 +42,6 @@#include "hns_roce_device.h" #include "hns_roce_hem.h" -/** -* hns_get_gid_index - Get gid index. -* @hr_dev: pointer to structure hns_roce_dev. -* @port: port, value range: 0 ~ MAX -* @gid_index: gid_index, value range: 0 ~ MAX -* Description: -* N ports shared gids, allocation method as follow: -* GID[0][0], GID[1][0],.....GID[N - 1][0], -* GID[0][0], GID[1][0],.....GID[N - 1][0], -* And so on -*/ -u8 hns_get_gid_index (struct hns_roce_dev *hr_dev,u8 port,int gid_index) -{ -return gid_index * hr_dev->caps.num_ports + port; -} -static int hns_roce_set_mac (struct hns_roce_dev *hr_dev,u8 port,u8 *addr) {u8 phy_port;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 438/775 RDMA/hns: Fix type of sq_signal_bits
In reply to Greg Kroah-HartmanFrom: Weihang Li <[email protected]>
[ Upstream commit ea4092f3b56b236d08890ea589506ebd76248c53 ]
This bit should be in type of enum ib_sig_type, or there will be a sparse warning.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -1
@@ -652,7 +652,7 @@ struct hns_roce_qp {struct hns_roce_db sdb;unsigned long en_flags;u32 doorbell_qpn; -u32 sq_signal_bits; +enum ib_sig_type sq_signal_bits;struct hns_roce_wq sq;struct hns_roce_mtr mtr;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 439/775 RDMA/hns: Add mapped page count checking for MTR
In reply to Greg Kroah-HartmanFrom: Xi Wang <[email protected]>
[ Upstream commit 9ea9a53ea93be1cc66729ceb920f0d07285d6bfd ]
Add the mapped page count checking flow to avoid invalid page size when creating MTR.
--- drivers/infiniband/hw/hns/hns_roce_hem.c | 9 ++-- drivers/infiniband/hw/hns/hns_roce_mr.c | 56 ++++++++++++++---------- 2 files changed, 40 insertions(+), 25 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hem.c +6 -3
@@ -1075,9 +1075,8 @@ static struct roce_hem_item *hem_list_alloc_item(struct hns_roce_dev *hr_dev,return NULL ;if (exist_bt) { - hem->addr =dma_alloc_coherent (hr_dev->dev, - count *BA_BYTE_LEN , - &hem->dma_addr,GFP_KERNEL ); + hem->addr =dma_alloc_coherent (hr_dev->dev, count *BA_BYTE_LEN , + &hem->dma_addr,GFP_KERNEL );if (!hem->addr) {kfree (hem);return NULL ;
@@ -1336,6 +1335,10 @@ static int hem_list_alloc_root_bt(struct hns_roce_dev *hr_dev,if (ba_num <1 )return -ENOMEM ; +if (ba_num > unit) +return -ENOBUFS ; + + ba_num =min_t (int, ba_num, unit);INIT_LIST_HEAD (&temp_root); offset = r->offset;/* indicate to last region */
drivers/infiniband/hw/hns/hns_roce_mr.c +34 -22
105 lines not on this page · raw message
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 440/775 RDMA/hns: Disable RQ inline by default
In reply to Greg Kroah-HartmanFrom: Lijun Ou <[email protected]>
[ Upstream commit 7373de9adb19aebed2781d3fdde576533d626d7a ]
This feature should only be enabled by querying capability from firmware.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -1
@@ -1883,7 +1883,6 @@ static void set_default_caps(struct hns_roce_dev *hr_dev) caps->flags =HNS_ROCE_CAP_FLAG_REREG_MR |HNS_ROCE_CAP_FLAG_ROCE_V1_V2 | -HNS_ROCE_CAP_FLAG_RQ_INLINE |HNS_ROCE_CAP_FLAG_RECORD_DB |HNS_ROCE_CAP_FLAG_SQ_RECORD_DB ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 441/775 clk: divider: fix initialization with parent_hw
In reply to Greg Kroah-HartmanFrom: Michael Tretter <[email protected]>
[ Upstream commit 0225daea08141b1dff681502d5af70b71e8b11ec ]
If a driver registers a divider clock with a parent_hw instead of the parent_name, the parent_hw is ignored and the clock does not have a parent.
Fix this by initializing the parents the same way they are initialized for clock gates.
--- drivers/clk/clk-divider.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/clk-divider.c +7 -2
@@ -494,8 +494,13 @@ struct clk_hw *__clk_hw_register_divider(struct device *dev,else init.ops = &clk_divider_ops; init.flags = flags; - init.parent_names = (parent_name ? &parent_name:NULL ); - init.num_parents = (parent_name ?1 :0 ); + init.parent_names = parent_name ? &parent_name :NULL ; + init.parent_hws = parent_hw ? &parent_hw :NULL ; + init.parent_data = parent_data; +if (parent_name || parent_hw || parent_data) + init.num_parents =1 ; +else + init.num_parents =0 ;/* struct clk_divider assignments */ div->reg = reg;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 442/775 spi: pxa2xx: Fix the controller numbering for Wildcat Point
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 54c5d3bfb0cfb7b31259765524567871dee11615 ]
Wildcat Point has two SPI controllers and added one is actually second one. Fix the numbering by adding the description of the first one.
--- drivers/spi/spi-pxa2xx-pci.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/spi/spi-pxa2xx-pci.c +19 -8
@@ -21,7 +21,8 @@ enum {PORT_BSW1 ,PORT_BSW2 ,PORT_CE4100 , - PORT_LPT, +PORT_LPT0 , + PORT_LPT1, }; struct pxa_spi_info {
@@ -57,8 +58,10 @@ static struct dw_dma_slave bsw1_rx_param = { .src_id = 7 };static struct dw_dma_slave bsw2_tx_param = { .dst_id =8 };static struct dw_dma_slave bsw2_rx_param = { .src_id =9 }; -static struct dw_dma_slave lpt_tx_param = { .dst_id =0 }; -static struct dw_dma_slave lpt_rx_param = { .src_id =1 }; +static struct dw_dma_slave lpt1_tx_param = { .dst_id =0 }; +static struct dw_dma_slave lpt1_rx_param = { .src_id =1 }; +static struct dw_dma_slave lpt0_tx_param = { .dst_id =2 }; +static struct dw_dma_slave lpt0_rx_param = { .src_id =3 };static bool lpss_dma_filter (struct dma_chan *chan,void *param) {
@@ -185,12 +188,19 @@ static struct pxa_spi_info spi_info_configs[] = { .num_chipselect = 1, .max_clk_rate = 50000000, }, - [PORT_LPT] = { + [PORT_LPT0] = { .type = LPSS_LPT_SSP, .port_id = 0, .setup = lpss_spi_setup, - .tx_param = &lpt_tx_param, - .rx_param = &lpt_rx_param, + .tx_param = &lpt0_tx_param, + .rx_param = &lpt0_rx_param, + }, + [PORT_LPT1] = { + .type = LPSS_LPT_SSP, + .port_id = 1, + .setup = lpss_spi_setup, + .tx_param = &lpt1_tx_param, + .rx_param = &lpt1_rx_param, }, };
@@ -285,8 +295,9 @@ static const struct pci_device_id pxa2xx_spi_pci_devices[] = { { PCI_VDEVICE(INTEL, 0x2290), PORT_BSW1 }, { PCI_VDEVICE(INTEL, 0x22ac), PORT_BSW2 }, { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, - { PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT }, - { }, + { PCI_VDEVICE(INTEL, 0x9ce5), PORT_LPT0 }, + { PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT1 }, + { } };MODULE_DEVICE_TABLE (pci, pxa2xx_spi_pci_devices);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 443/775 powerpc/uaccess: Avoid might_fault() when user access is enabled
In reply to Greg Kroah-HartmanFrom: Alexey Kardashevskiy <[email protected]>
[ Upstream commit 7d506ca97b665b95e698a53697dad99fae813c1a ]
The amount of code executed with enabled user space access (unlocked KUAP) should be minimal. However with CONFIG_PROVE_LOCKING or CONFIG_DEBUG_ATOMIC_SLEEP enabled, might_fault() calls into various parts of the kernel, and may even end up replaying interrupts which in turn may access user space and forget to restore the KUAP state.
The problem places are:
1. strncpy_from_user (and similar) which unlock KUAP and call unsafe_get_user -> __get_user_allowed -> __get_user_nocheck() with do_allow=false to skip KUAP as the caller took care of it.
2. __unsafe_put_user_goto() which is called with unlocked KUAP.
eg:
WARNING: CPU: 30 PID: 1 at arch/powerpc/include/asm/book3s/64/kup.h:324 arch_local_irq_restore+0x160/0x190
NIP arch_local_irq_restore+0x160/0x190
LR lock_is_held_type+0x140/0x200
Call Trace:
0xc00000007f392ff8 (unreliable)
___might_sleep+0x180/0x320
__might_fault+0x50/0xe0
filldir64+0x2d0/0x5d0
call_filldir+0xc8/0x180
ext4_readdir+0x948/0xb40
iterate_dir+0x1ec/0x240
sys_getdents64+0x80/0x290
system_call_exception+0x160/0x280
system_call_common+0xf0/0x27cChange __get_user_nocheck() to look at do_allow to decide whether to skip might_fault(). Since strncpy_from_user/etc call might_fault() anyway before unlocking KUAP, there should be no visible change.
Drop might_fault() in __unsafe_put_user_goto() as it is only called from unsafe_put_user(), which already has KUAP unlocked.
Since keeping might_fault() is still desirable for debugging, add calls to it in user_[read|write]_access_begin(). That also allows us to drop the is_kernel_addr() test, because there should be no code using user_[read|write]_access_begin() in order to access a kernel address.
--- arch/powerpc/include/asm/uaccess.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/uaccess.h +10 -3
@@ -216,8 +216,6 @@ do { \#define __put_user_nocheck_goto (x, ptr, size, label) \ do { \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ - if (!is_kernel_addr((unsigned long)__pu_addr)) \ - might_fault(); \ __chk_user_ptr(ptr); \ __put_user_size_goto((x), __pu_addr, (size), label); \ } while (0)
@@ -313,7 +311,7 @@ do { \__typeof__ (size) __gu_size = (size); \ \__chk_user_ptr (__gu_addr); \ -if (!is_kernel_addr ((unsigned long )__gu_addr)) \ +if (do_allow && !is_kernel_addr ((unsigned long )__gu_addr)) \might_fault (); \barrier_nospec (); \if (do_allow) \
@@ -508,6 +506,9 @@ static __must_check inline bool user_access_begin(const void __user *ptr, size_t {if (unlikely (!access_ok (ptr, len)))return false; + +might_fault (); +allow_read_write_user ((void __user *)ptr, ptr, len);return true; }
@@ -521,6 +522,9 @@ user_read_access_begin(const void __user *ptr, size_t len) {if (unlikely (!access_ok (ptr, len)))return false; + +might_fault (); +allow_read_from_user (ptr, len);return true; }
@@ -532,6 +536,9 @@ user_write_access_begin(const void __user *ptr, size_t len) {if (unlikely (!access_ok (ptr, len)))return false; + +might_fault (); +allow_write_to_user ((void __user *)ptr, len);return true; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 444/775 powerpc/kuap: Restore AMR after replaying soft interrupts
In reply to Greg Kroah-HartmanFrom: Alexey Kardashevskiy <[email protected]>
[ Upstream commit 60a707d0c99aff4eadb7fd334c5fd21df386723e ]
Since de78a9c42a79 ("powerpc: Add a framework for Kernel Userspace Access Protection"), user access helpers call user_{read|write}_access_{begin|end} when user space access is allowed.
Commit 890274c2dc4c ("powerpc/64s: Implement KUAP for Radix MMU") made the mentioned helpers program a AMR special register to allow such access for a short period of time, most of the time AMR is expected to block user memory access by the kernel.
Since the code accesses the user space memory, unsafe_get_user() calls might_fault() which calls arch_local_irq_restore() if either CONFIG_PROVE_LOCKING or CONFIG_DEBUG_ATOMIC_SLEEP is enabled. arch_local_irq_restore() then attempts to replay pending soft interrupts as KUAP regions have hardware interrupts enabled.
If a pending interrupt happens to do user access (performance interrupts do that), it enables access for a short period of time so after returning from the replay, the user access state remains blocked and if a user page fault happens - "Bug: Read fault blocked by AMR!" appears and SIGSEGV is sent.
An example trace:
Bug: Read fault blocked by AMR!
WARNING: CPU: 0 PID: 1603 at /home/aik/p/kernel/arch/powerpc/include/asm/book3s/64/kup-radix.h:145
CPU: 0 PID: 1603 Comm: amr Not tainted 5.10.0-rc6_v5.10-rc6_a+fstn1 #24
NIP: c00000000009ece8 LR: c00000000009ece4 CTR: 0000000000000000
REGS: c00000000dc63560 TRAP: 0700 Not tainted (5.10.0-rc6_v5.10-rc6_a+fstn1)
MSR: 8000000000021033 <SF,ME,IR,DR,RI,LE> CR: 28002888 XER: 20040000
CFAR: c0000000001fa928 IRQMASK: 1
GPR00: c00000000009ece4 c00000000dc637f0 c000000002397600 000000000000001f
GPR04: c0000000020eb318 0000000000000000 c00000000dc63494 0000000000000027
GPR08: c00000007fe4de68 c00000000dfe9180 0000000000000000 0000000000000001
GPR12: 0000000000002000 c0000000030a0000 0000000000000000 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 bfffffffffffffff
GPR20: 0000000000000000 c0000000134a4020 c0000000019c2218 0000000000000fe0
GPR24: 0000000000000000 0000000000000000 c00000000d106200 0000000040000000
GPR28: 0000000000000000 0000000000000300 c00000000dc63910 c000000001946730
NIP __do_page_fault+0xb38/0xde0
LR __do_page_fault+0xb34/0xde0
Call Trace:
__do_page_fault+0xb34/0xde0 (unreliable)
handle_page_fault+0x10/0x2c
--- interrupt: 300 at strncpy_from_user+0x290/0x440
LR = strncpy_from_user+0x284/0x440
strncpy_from_user+0x2f0/0x440 (unreliable)
getname_flags+0x88/0x2c0
do_sys_openat2+0x2d4/0x5f0
do_sys_open+0xcc/0x140
system_call_exception+0x160/0x240
system_call_common+0xf0/0x27cTo fix it save/restore the AMR when replaying interrupts, and also add a check if AMR was not blocked prior to replaying interrupts.
Originally found by syzkaller.
[mpe: Use normal commit citation format and add full oops log to
change log, move kuap_check_amr() into the restore routine to avoid warnings about unreconciled IRQ state]
--- arch/powerpc/kernel/irq.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
arch/powerpc/kernel/irq.c +26 -1
@@ -269,6 +269,31 @@ again: } } +#if defined(CONFIG_PPC_BOOK3S_64 ) && defined(CONFIG_PPC_KUAP ) +static inline void replay_soft_interrupts_irqrestore (void ) +{ +unsigned long kuap_state =get_kuap (); + +/* +* Check if anything calls local_irq_enable/restore() when KUAP is +* disabled (user access enabled). We handle that case here by saving +* and re-locking AMR but we shouldn't get here in the first place, +* hence the warning. +*/ +kuap_check_amr (); + +if (kuap_state !=AMR_KUAP_BLOCKED ) +set_kuap (AMR_KUAP_BLOCKED ); + +replay_soft_interrupts (); + +if (kuap_state !=AMR_KUAP_BLOCKED ) +set_kuap (kuap_state); +} +#else +#define replay_soft_interrupts_irqrestore () replay_soft_interrupts() +#endif + notrace void arch_local_irq_restore(unsigned long mask) {unsigned char irq_happened;
@@ -332,7 +357,7 @@ notrace void arch_local_irq_restore(unsigned long mask)irq_soft_mask_set (IRQS_ALL_DISABLED );trace_hardirqs_off (); -replay_soft_interrupts (); +replay_soft_interrupts_irqrestore (); local_paca->irq_happened =0 ;trace_hardirqs_on ();
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 445/775 regulator: qcom-rpmh: fix pm8009 ldo7
In reply to Greg Kroah-HartmanFrom: Jonathan Marek <[email protected]>
[ Upstream commit 20ccc362c3d20da734af896e075b74222589f2c0 ]
Use the correct name to avoid ldo7 commands being sent to ldo6's address.
--- drivers/regulator/qcom-rpmh-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +1 -1
@@ -937,7 +937,7 @@ static const struct rpmh_vreg_init_data pm8009_vreg_data[] = {RPMH_VREG ("ldo4" ,"ldo%s4" , &pmic5_nldo,"vdd-l4" ),RPMH_VREG ("ldo5" ,"ldo%s5" , &pmic5_pldo,"vdd-l5-l6" ),RPMH_VREG ("ldo6" ,"ldo%s6" , &pmic5_pldo,"vdd-l5-l6" ), - RPMH_VREG("ldo7", "ldo%s6", &pmic5_pldo_lv, "vdd-l7"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), {}, };
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 446/775 clk: aspeed: Fix APLL calculate formula from ast2600-A2
In reply to Greg Kroah-HartmanFrom: Ryan Chen <[email protected]>
[ Upstream commit 6286ce1e3ece54799f12775f8ce2a1cba9cbcfc5 ]
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
--- drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/clk/clk-ast2600.c +27 -10
@@ -17,7 +17,8 @@#define ASPEED_G6_NUM_CLKS 71 -#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 +#define CHIP_REVISION_ID GENMASK(23, 16)#define ASPEED_G6_RESET_CTRL 0x040#define ASPEED_G6_RESET_CTRL2 0x050
@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val)static struct clk_hw *ast2600_calc_apll (const char *name,u32 val) {unsigned int mult, div; +u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) { +if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + + mult = (m +1 ); + div = (n +1 ) * (p +1 ); + } }else { -/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -u32 m = (val >>5 ) &0x3f ; -u32 od = (val >>4 ) &0x1 ; -u32 n = val &0xf ; +if (val &BIT (20 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ +u32 m = (val >>5 ) &0x3f ; +u32 od = (val >>4 ) &0x1 ; +u32 n = val &0xf ; - mult = (2 - od) * (m +2 ); - div = n +1 ; + mult = (2 - od) * (m +2 ); + div = n +1 ; + } }return clk_hw_register_fixed_factor (NULL , name,"clkin" ,0 , mult, div);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 447/775 selftests/ftrace: Update synthetic event syntax errors
In reply to Greg Kroah-HartmanFrom: Tom Zanussi <[email protected]>
[ Upstream commit b5734e997e1117afb479ffda500e36fa91aea3e8 ]
Some of the synthetic event errors and positions have changed in the code - update those and add several more tests.
Also add a runtime check to ensure that the kernel supports dynamic strings in synthetic events, which these tests require.
--- .../trigger-synthetic_event_syntax_errors.tc | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic_event_syntax_errors.tc +27 -8
@@ -1,19 +1,38 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # description: event trigger - test synthetic_events syntax parser errors -# requires: synthetic_events error_log +# requires: synthetic_events error_log "char name[]' >> synthetic_events":README check_error() { # command-with-error-pos-by-^ ftrace_errlog_check 'synthetic_events' "$1" 'synthetic_events' } +check_dyn_error() { # command-with-error-pos-by-^ + ftrace_errlog_check 'synthetic_events' "$1" 'dynamic_events' +} + check_error 'myevent ^chr arg' # INVALID_TYPE -check_error 'myevent ^char str[];; int v' # INVALID_TYPE -check_error 'myevent char ^str]; int v' # INVALID_NAME -check_error 'myevent char ^str;[]' # INVALID_NAME -check_error 'myevent ^char str[; int v' # INVALID_TYPE -check_error '^mye;vent char str[]' # BAD_NAME -check_error 'myevent char str[]; ^int' # INVALID_FIELD -check_error '^myevent' # INCOMPLETE_CMD +check_error 'myevent ^unsigned arg' # INCOMPLETE_TYPE + +check_error 'myevent char ^str]; int v' # BAD_NAME +check_error '^mye-vent char str[]' # BAD_NAME +check_error 'myevent char ^st-r[]' # BAD_NAME + +check_error 'myevent char str;^[]' # INVALID_FIELD +check_error 'myevent char str; ^int' # INVALID_FIELD + +check_error 'myevent char ^str[; int v' # INVALID_ARRAY_SPEC +check_error 'myevent char ^str[kdjdk]' # INVALID_ARRAY_SPEC +check_error 'myevent char ^str[257]' # INVALID_ARRAY_SPEC + +check_error '^mye;vent char str[]' # INVALID_CMD +check_error '^myevent ; char str[]' # INVALID_CMD +check_error '^myevent; char str[]' # INVALID_CMD +check_error '^myevent ;char str[]' # INVALID_CMD +check_error '^; char str[]' # INVALID_CMD +check_error '^;myevent char str[]' # INVALID_CMD +check_error '^myevent' # INVALID_CMD + +check_dyn_error '^s:junk/myevent char str[' # INVALID_DYN_CMD exit 0
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 448/775 perf symbols: Use (long) for iterator for bfd symbols
In reply to Greg Kroah-HartmanFrom: Dmitry Safonov <[email protected]>
[ Upstream commit 96de68fff5ded8833bf5832658cb43c54f86ff6c ]
GCC (GCC) 8.4.0 20200304 fails to build perf with:
: util/symbol.c: In function 'dso__load_bfd_symbols':
: util/symbol.c:1626:16: error: comparison of integer expressions of different signednes
: for (i = 0; i < symbols_count; ++i) {
: ^
: util/symbol.c:1632:16: error: comparison of integer expressions of different signednes
: while (i + 1 < symbols_count &&
: ^
: util/symbol.c:1637:13: error: comparison of integer expressions of different signednes
: if (i + 1 < symbols_count &&
: ^
: cc1: all warnings being treated as errors
It's unlikely that the symtable will be that big, but the fix is an oneliner and as perf has CORE_CFLAGS += -Wextra, which makes build to fail together with CORE_CFLAGS += -Werror
--- tools/perf/util/symbol.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/symbol.c +1 -2
@@ -1561,12 +1561,11 @@ static int bfd2elf_binding(asymbol *symbol)int dso__load_bfd_symbols (struct dso *dso,const char *debugfile) {int err =-1 ; -long symbols_size, symbols_count; +long symbols_size, symbols_count, i;asection *section;asymbol **symbols, *sym;struct symbol *symbol;bfd *abfd; -u_int i;u64 start, len; abfd =bfd_openr (dso->long_name,NULL );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 449/775 regulator: bd718x7, bd71828, Fix dvs voltage levels
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
[ Upstream commit c294554111a835598b557db789d9ad2379b512a2 ]
The ROHM BD718x7 and BD71828 drivers support setting HW state specific voltages from device-tree. This is used also by various in-tree DTS files.
These drivers do incorrectly try to compose bit-map using enum values. By a chance this works for first two valid levels having values 1 and 2 - but setting values for the rest of the levels do indicate capability of setting values for first levels as well. Luckily the regulators which support setting values for SUSPEND/LPSR do usually also support setting values for RUN and IDLE too - thus this has not been such a fatal issue.
Fix this by defining the old enum values as bits and fixing the parsing code. This allows keeping existing IC specific drivers intact and only slightly changing the rohm-regulator.c
--- drivers/regulator/rohm-regulator.c | 9 ++++++--- include/linux/mfd/rohm-generic.h | 14 ++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-)
drivers/regulator/rohm-regulator.c +6 -3
@@ -52,9 +52,12 @@ int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,char *prop;unsigned int reg, mask, omask, oreg = desc->enable_reg; -for (i =0 ; i <ROHM_DVS_LEVEL_MAX && !ret; i++) { -if (dvs->level_map & (1 << i)) { -switch (i +1 ) { +for (i =0 ; i <ROHM_DVS_LEVEL_VALID_AMOUNT && !ret; i++) { +int bit; + + bit =BIT (i); +if (dvs->level_map & bit) { +switch (bit) {case ROHM_DVS_LEVEL_RUN : prop ="rohm,dvs-run-voltage" ; reg = dvs->run_reg;
include/linux/mfd/rohm-generic.h +6 -8
@@ -20,14 +20,12 @@ struct rohm_regmap_dev {struct regmap *regmap; }; -enum { -ROHM_DVS_LEVEL_UNKNOWN , -ROHM_DVS_LEVEL_RUN , -ROHM_DVS_LEVEL_IDLE , -ROHM_DVS_LEVEL_SUSPEND , -ROHM_DVS_LEVEL_LPSR , -ROHM_DVS_LEVEL_MAX =ROHM_DVS_LEVEL_LPSR , -}; +#define ROHM_DVS_LEVEL_RUN BIT(0) +#define ROHM_DVS_LEVEL_IDLE BIT(1) +#define ROHM_DVS_LEVEL_SUSPEND BIT(2) +#define ROHM_DVS_LEVEL_LPSR BIT(3) +#define ROHM_DVS_LEVEL_VALID_AMOUNT 4 +#define ROHM_DVS_LEVEL_UNKNOWN 0/** * struct rohm_dvs_config - dynamic voltage scaling register descriptions
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 450/775 spi: dw: Avoid stack content exposure
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 386f771aad15dd535f2368b4adc9958c0160edd4 ]
Since "data" is u32, &data is a "u32 *" type, which means pointer math will move in u32-sized steps. This was meant to be a byte offset, so cast &data to "char *" to aim the copy into the correct location.
Seen with -Warray-bounds (and found by Coverity):
In file included from ./include/linux/string.h:269,
from ./arch/powerpc/include/asm/paca.h:15,
from ./arch/powerpc/include/asm/current.h:13,
from ./include/linux/mutex.h:14,
from ./include/linux/notifier.h:14,
from ./include/linux/clk.h:14,
from drivers/spi/spi-dw-bt1.c:12:
In function 'memcpy',
inlined from 'dw_spi_bt1_dirmap_copy_from_map' at drivers/spi/spi-dw-bt1.c:87:3:./include/linux/fortify-string.h:20:29: warning: '__builtin_memcpy' offset 4 is out of the bounds [0, 4] of object 'data' with type 'u32' {aka 'unsigned int'} [-Warray-bounds]
20 | #define __underlying_memcpy __builtin_memcpy
| ^./include/linux/fortify-string.h:191:9: note: in expansion of macro '__underlying_memcpy'
191 | return __underlying_memcpy(p, q, size);
| ^~~~~~~~~~~~~~~~~~~
drivers/spi/spi-dw-bt1.c: In function 'dw_spi_bt1_dirmap_copy_from_map':
drivers/spi/spi-dw-bt1.c:77:6: note: 'data' declared here
77 | u32 data;
| ^~~~Addresses-Coverity: CID 1497771 Out-of-bounds access
--- drivers/spi/spi-dw-bt1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dw-bt1.c +1 -1
@@ -84,7 +84,7 @@ static void dw_spi_bt1_dirmap_copy_from_map(void *to, void __iomem *from, size_tif (shift) { chunk =min_t (size_t,4 - shift, len); data =readl_relaxed (from - shift); -memcpy (to, &data + shift, chunk); +memcpy (to, (char *)&data + shift, chunk); from += chunk; to += chunk; len -= chunk;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 451/775 spi: Skip zero-length transfers in spi_transfer_one_message()
In reply to Greg Kroah-HartmanFrom: Nicolas Saenz Julienne <[email protected]>
[ Upstream commit b306320322c9cfaa465bc2c7367acf6072b1ac0e ]
With the introduction of 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops") it has become apparent that some users might initiate zero-length SPI transfers. A fact the micro-optimization omitted, and which turned out to cause crashes[1].
Instead of changing the micro-optimization itself, use a bigger hammer and skip zero-length transfers altogether for drivers using the default transfer_one_message() implementation.
[1] https://github.com/raspberrypi/linux/issues/4100
--- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
@@ -1267,7 +1267,7 @@ static int spi_transfer_one_message(struct spi_controller *ctlr,ptp_read_system_prets (xfer->ptp_sts); } -if (xfer->tx_buf || xfer->rx_buf) { +if ((xfer->tx_buf || xfer->rx_buf) && xfer->len) {reinit_completion (&ctlr->xfer_completion); fallback_pio:
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 452/775 printk: avoid prb_first_valid_seq() where possible
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit 13791c80b0cdf54d92fc54221cdf490683b109de ]
If message sizes average larger than expected (more than 32 characters), the data_ring will wrap before the desc_ring. Once the data_ring wraps, it will start invalidating descriptors. These invalid descriptors hang around until they are eventually recycled when the desc_ring wraps. Readers do not care about invalid descriptors, but they still need to iterate past them. If the average message size is much larger than 32 characters, then there will be many invalid descriptors preceding the valid descriptors.
The function prb_first_valid_seq() always begins at the oldest descriptor and searches for the first valid descriptor. This can be rather expensive for the above scenario. And, in fact, because of its heavy usage in /dev/kmsg, there have been reports of long delays and even RCU stalls.
For code that does not need to search from the oldest record, replace prb_first_valid_seq() usage with prb_read_valid_*() functions, which provide a start sequence number to search from.
--- kernel/printk/printk.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
kernel/printk/printk.c +18 -10
@@ -735,9 +735,9 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,logbuf_lock_irq (); } -if (user->seq <prb_first_valid_seq (prb)) { +if (r->info->seq != user->seq) {/* our last seen message is gone, return error and reset */ - user->seq =prb_first_valid_seq (prb); + user->seq = r->info->seq; ret = -EPIPE ;logbuf_unlock_irq (); goto out;
@@ -812,6 +812,7 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)static __poll_t devkmsg_poll (struct file *file,poll_table *wait) {struct devkmsg_user *user = file->private_data; +struct printk_info info;__poll_t ret =0 ;if (!user)
@@ -820,9 +821,9 @@ static __poll_t devkmsg_poll(struct file *file, poll_table *wait)poll_wait (file, &log_wait, wait);logbuf_lock_irq (); -if (prb_read_valid (prb, user->seq,NULL )) { +if (prb_read_valid_info (prb, user->seq, &info,NULL )) {/* return error when data has vanished underneath us */ -if (user->seq <prb_first_valid_seq (prb)) +if (info.seq != user->seq) ret =EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLPRI ;else ret =EPOLLIN |EPOLLRDNORM ;
@@ -1559,6 +1560,7 @@ static void syslog_clear(void)int do_syslog (int type,char __user *buf,int len,int source) { +struct printk_info info;bool clear = false;static int saved_console_loglevel =LOGLEVEL_DEFAULT ;int error;
@@ -1629,9 +1631,14 @@ int do_syslog(int type, char __user *buf, int len, int source)/* Number of chars in the log buffer */ case SYSLOG_ACTION_SIZE_UNREAD :logbuf_lock_irq (); -if (syslog_seq <prb_first_valid_seq (prb)) { +if (!prb_read_valid_info (prb, syslog_seq, &info,NULL )) { +/* No unread messages. */ +logbuf_unlock_irq (); +return 0 ; + } +if (info.seq != syslog_seq) {/* messages are gone, move to first one */ - syslog_seq =prb_first_valid_seq (prb); + syslog_seq = info.seq; syslog_partial =0 ; }if (source ==SYSLOG_FROM_PROC ) {
@@ -1643,7 +1650,6 @@ int do_syslog(int type, char __user *buf, int len, int source) error =prb_next_seq (prb) - syslog_seq; }else {bool time = syslog_partial ? syslog_time : printk_time; -struct printk_info info;unsigned int line_count;u64 seq;
@@ -3429,9 +3435,11 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, goto out;logbuf_lock_irqsave (flags); -if (dumper->cur_seq <prb_first_valid_seq (prb)) { -/* messages are gone, move to first available one */ - dumper->cur_seq =prb_first_valid_seq (prb); +if (prb_read_valid_info (prb, dumper->cur_seq, &info,NULL )) { +if (info.seq != dumper->cur_seq) { +/* messages are gone, move to first available one */ + dumper->cur_seq = info.seq; + } }/* last entry */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 453/775 perf symbols: Fix return value when loading PE DSO
In reply to Greg Kroah-HartmanFrom: Nicholas Fraser <[email protected]>
[ Upstream commit 77771a97011fa9146ccfaf2983a3a2885dc57b6f ]
The first time dso__load() was called on a PE file it always returned -1 error. This caused the first call to map__find_symbol() to always fail on a PE file so the first sample from each PE file always had symbol <unknown>. Subsequent samples succeed however because the DSO is already loaded.
This fixes dso__load() to return 0 when successfully loading a DSO with libbfd.
--- tools/perf/util/symbol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c +3 -1
@@ -1866,8 +1866,10 @@ int dso__load(struct dso *dso, struct map *map)if (nsexit)nsinfo__mountns_enter (dso->nsinfo, &nsc); -if (bfdrc ==0 ) +if (bfdrc ==0 ) { + ret =0 ;break ; + }if (!is_reg || sirc <0 )continue ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 454/775 nfsd: register pernet ops last, unregister first
In reply to Greg Kroah-HartmanFrom: J. Bruce Fields <[email protected]>
[ Upstream commit bd5ae9288d6451bd346a1b4a59d4fe7e62ba29b7 ]
These pernet operations may depend on stuff set up or torn down in the module init/exit functions. And they may be called at any time in between. So it makes more sense for them to be the last to be registered in the init function, and the first to be unregistered in the exit function.
In particular, without this, the drc slab is being destroyed before all the per-net drcs are shut down, resulting in an "Objects remaining in nfsd_drc on __kmem_cache_shutdown()" warning in exit_nfsd.
--- fs/nfsd/nfsctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/nfsd/nfsctl.c +7 -7
@@ -1522,12 +1522,9 @@ static int __init init_nfsd(void)int retval;printk (KERN_INFO "Installing knfsd (copyright (C) 1996 [email protected]).\n" ); - retval =register_pernet_subsys (&nfsd_net_ops); -if (retval <0 ) -return retval; retval =register_cld_notifier ();if (retval) - goto out_unregister_pernet; +return retval; retval =nfsd4_init_slabs ();if (retval) goto out_unregister_notifier;
@@ -1544,9 +1541,14 @@ static int __init init_nfsd(void) goto out_free_lockd; retval =register_filesystem (&nfsd_fs_type);if (retval) + goto out_free_exports; + retval =register_pernet_subsys (&nfsd_net_ops); +if (retval <0 ) goto out_free_all;return 0 ; out_free_all: +unregister_pernet_subsys (&nfsd_net_ops); +out_free_exports:remove_proc_entry ("fs/nfs/exports" ,NULL );remove_proc_entry ("fs/nfs" ,NULL ); out_free_lockd:
@@ -1559,13 +1561,12 @@ out_free_slabs:nfsd4_free_slabs (); out_unregister_notifier:unregister_cld_notifier (); -out_unregister_pernet: -unregister_pernet_subsys (&nfsd_net_ops);return retval; } static void __exit exit_nfsd(void) { +unregister_pernet_subsys (&nfsd_net_ops);nfsd_drc_slab_free ();remove_proc_entry ("fs/nfs/exports" ,NULL );remove_proc_entry ("fs/nfs" ,NULL );
@@ -1575,7 +1576,6 @@ static void __exit exit_nfsd(void)nfsd4_exit_pnfs ();unregister_filesystem (&nfsd_fs_type);unregister_cld_notifier (); -unregister_pernet_subsys (&nfsd_net_ops); }MODULE_AUTHOR ("Olaf Kirch <[email protected]>" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 455/775 svcrdma: Hold private mutex while invoking rdma_accept()
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit 0ac24c320c4d89a9de6ec802591398b8675c7b3c ]
RDMA core mutex locking was restructured by commit d114c6feedfe ("RDMA/cma: Add missing locking to rdma_accept()") [Aug 2020]. When lock debugging is enabled, the RPC/RDMA server trips over the new lockdep assertion in rdma_accept() because it doesn't call rdma_accept() from its CM event handler.
As a temporary fix, have svc_rdma_accept() take the handler_mutex explicitly. In the meantime, let's consider how to restructure the RPC/RDMA transport to invoke rdma_accept() from the proper context.
Calls to svc_rdma_accept() are serialized with calls to svc_rdma_free() by the generic RPC server layer.
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +3 -3
@@ -475,9 +475,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)if (!svc_rdma_post_recvs (newxprt)) goto errout; -/* Swap out the handler */ - newxprt->sc_cm_id->event_handler = svc_rdma_cma_handler; -/* Construct RDMA-CM private message */ pmsg.cp_magic = rpcrdma_cmp_magic; pmsg.cp_version =RPCRDMA_CMP_VERSION ;
@@ -498,7 +495,10 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) } conn_param.private_data = &pmsg; conn_param.private_data_len =sizeof (pmsg); +rdma_lock_handler (newxprt->sc_cm_id); + newxprt->sc_cm_id->event_handler = svc_rdma_cma_handler; ret =rdma_accept (newxprt->sc_cm_id, &conn_param); +rdma_unlock_handler (newxprt->sc_cm_id);if (ret) {trace_svcrdma_accept_err (newxprt, ret); goto errout;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 456/775 ceph: fix flush_snap logic after putting caps
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit 64f36da5625f7f9853b86750eaa89d499d16a2e9 ]
A primary reason for skipping ceph_check_caps after putting the references was to avoid the locking in ceph_check_caps during a reconnect. __ceph_put_cap_refs can still call ceph_flush_snaps in that case though, and that takes many of the same inconvenient locks.
Fix the logic in __ceph_put_cap_refs to skip flushing snaps when the skip_checking_caps flag is set.
--- fs/ceph/caps.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ceph/caps.c +6 -4
@@ -3093,10 +3093,12 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,dout ("put_cap_refs %p had %s%s%s\n" , inode,ceph_cap_string (had), last ?" last" :"" , put ?" put" :"" ); -if (last && !skip_checking_caps) -ceph_check_caps (ci,0 ,NULL ); -else if (flushsnaps) -ceph_flush_snaps (ci,NULL ); +if (!skip_checking_caps) { +if (last) +ceph_check_caps (ci,0 ,NULL ); +else if (flushsnaps) +ceph_flush_snaps (ci,NULL ); + }if (wake)wake_up_all (&ci->i_cap_wq);while (put-- >0 )
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 457/775 RDMA/hns: Fixes missing error code of CMDQ
In reply to Greg Kroah-HartmanFrom: Lang Cheng <[email protected]>
[ Upstream commit 8f86e2eadac968200a6ab1d7074fc0f5cbc1e075 ]
When posting a multi-descriptors command, the error code of previous failed descriptors may be rewrote to 0 by a later successful descriptor.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -4
@@ -1264,7 +1264,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,u32 timeout =0 ;int handle =0 ;u16 desc_ret; -int ret =0 ; +int ret;int ntc;spin_lock_bh (&csq->lock);
@@ -1309,15 +1309,14 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,if (hns_roce_cmq_csq_done (hr_dev)) { complete = true; handle =0 ; + ret =0 ;while (handle < num) {/* get the result of hardware write back */ desc_to_use = &csq->desc[ntc]; desc[handle] = *desc_to_use;dev_dbg (hr_dev->dev,"Get cmq desc:\n" ); desc_ret =le16_to_cpu (desc[handle].retval); -if (desc_ret ==CMD_EXEC_SUCCESS ) - ret =0 ; -else +if (unlikely (desc_ret !=CMD_EXEC_SUCCESS )) ret = -EIO ; priv->cmq.last_status = desc_ret; ntc++;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 458/775 RDMA/ucma: Fix use-after-free bug in ucma_create_uevent
In reply to Greg Kroah-HartmanFrom: Avihai Horon <[email protected]>
[ Upstream commit fe454dc31e84f8c14cb8942fcb61666c9f40745b ]
ucma_process_join() allocates struct ucma_multicast mc and frees it if an error occurs during its run. Specifically, if an error occurs in copy_to_user(), a use-after-free might happen in the following scenario:
1. mc struct is allocated.
2. rdma_join_multicast() is called and succeeds. During its run, cma_iboe_join_multicast() enqueues a work that will later use the aforementioned mc struct.
3. copy_to_user() is called and fails.
4. mc struct is deallocated.
5. The work that was enqueued by cma_iboe_join_multicast() is run and calls ucma_create_uevent() which tries to access mc struct (which is freed by now).
Fix this bug by cancelling the work enqueued by cma_iboe_join_multicast(). Since cma_work_handler() frees struct cma_work, we don't use it in cma_iboe_join_multicast() so we can safely cancel the work later.
The following syzkaller report revealed it:
BUG: KASAN: use-after-free in ucma_create_uevent+0x2dd/0x;3f0 drivers/infiniband/core/ucma.c:272
Read of size 8 at addr ffff88810b3ad110 by task kworker/u8:1/108
CPU: 1 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
Workqueue: rdma_cm cma_work_handler
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xbe/0xf9 lib/dump_stack.c:118
print_address_description.constprop.0+0x3e/0×60 mm/kasan/report.c:385
__kasan_report mm/kasan/report.c:545 [inline]
kasan_report.cold+0x1f/0×37 mm/kasan/report.c:562
ucma_create_uevent+0x2dd/0×3f0 drivers/infiniband/core/ucma.c:272
ucma_event_handler+0xb7/0×3c0 drivers/infiniband/core/ucma.c:349
cma_cm_event_handler+0x5d/0×1c0 drivers/infiniband/core/cma.c:1977
cma_work_handler+0xfa/0×190 drivers/infiniband/core/cma.c:2718
process_one_work+0x54c/0×930 kernel/workqueue.c:2272
worker_thread+0x82/0×830 kernel/workqueue.c:2418
kthread+0x1ca/0×220 kernel/kthread.c:292
ret_from_fork+0x1f/0×30 arch/x86/entry/entry_64.S:296
Allocated by task 359:
kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
kasan_set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc mm/kasan/common.c:461 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:434
kmalloc include/linux/slab.h:552 [inline]
kzalloc include/linux/slab.h:664 [inline]
ucma_process_join+0x16e/0×3f0 drivers/infiniband/core/ucma.c:1453
ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
vfs_write fs/read_write.c:603 [inline]
vfs_write+0x191/0×4c0 fs/read_write.c:585
ksys_write+0x1a1/0×1e0 fs/read_write.c:658
do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 359:
kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
kasan_set_track+0x1c/0×30 mm/kasan/common.c:56
kasan_set_free_info+0x1b/0×30 mm/kasan/generic.c:355
__kasan_slab_free+0x112/0×160 mm/kasan/common.c:422
slab_free_hook mm/slub.c:1544 [inline]
slab_free_freelist_hook mm/slub.c:1577 [inline]
slab_free mm/slub.c:3142 [inline]
kfree+0xb3/0×3e0 mm/slub.c:4124
ucma_process_join+0x22d/0×3f0 drivers/infiniband/core/ucma.c:1497
ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
vfs_write fs/read_write.c:603 [inline]
vfs_write+0x191/0×4c0 fs/read_write.c:585
ksys_write+0x1a1/0×1e0 fs/read_write.c:658
do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
The buggy address belongs to the object at ffff88810b3ad100
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 16 bytes inside of
192-byte region [ffff88810b3ad100, ffff88810b3ad1c0)--- drivers/infiniband/core/cma.c | 70 ++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 29 deletions(-)
drivers/infiniband/core/cma.c +41 -29
@@ -352,7 +352,13 @@ struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev)struct cma_multicast {struct rdma_id_private *id_priv; -struct ib_sa_multicast *sa_mc; +union { +struct ib_sa_multicast *sa_mc; +struct { +struct work_struct work; +struct rdma_cm_event event; + } iboe_join; + };struct list_head list;void *context;struct sockaddr_storage addr;
@@ -1823,6 +1829,8 @@ static void destroy_mc(struct rdma_id_private *id_priv,cma_igmp_send (ndev, &mgid, false);dev_put (ndev); } + +cancel_work_sync (&mc->iboe_join.work); }kfree (mc); }
@@ -2683,6 +2691,28 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv,return (id_priv->query_id <0 ) ? id_priv->query_id :0 ; } +static void cma_iboe_join_work_handler (struct work_struct *work) +{ +struct cma_multicast *mc = + container_of(work, struct cma_multicast, iboe_join.work); +struct rdma_cm_event *event = &mc->iboe_join.event; +struct rdma_id_private *id_priv = mc->id_priv; +int ret; + +mutex_lock (&id_priv->handler_mutex); +if (READ_ONCE (id_priv->state) ==RDMA_CM_DESTROYING || +READ_ONCE (id_priv->state) ==RDMA_CM_DEVICE_REMOVAL ) + goto out_unlock; + + ret =cma_cm_event_handler (id_priv, event); +WARN_ON (ret); + +out_unlock: +mutex_unlock (&id_priv->handler_mutex); +if (event->event ==RDMA_CM_EVENT_MULTICAST_JOIN ) +rdma_destroy_ah_attr (&event->param.ud.ah_attr); +} +static void cma_work_handler (struct work_struct *_work) { struct cma_work *work = container_of(_work, struct cma_work, work);
@@ -4478,10 +4508,7 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)cma_make_mc_event (status, id_priv, multicast, &event, mc); ret =cma_cm_event_handler (id_priv, &event);rdma_destroy_ah_attr (&event.param.ud.ah_attr); -if (ret) { -destroy_id_handler_unlock (id_priv); -return 0 ; - } +WARN_ON (ret); out:mutex_unlock (&id_priv->handler_mutex);
@@ -4604,7 +4631,6 @@ static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,static int cma_iboe_join_multicast (struct rdma_id_private *id_priv,struct cma_multicast *mc) { -struct cma_work *work;struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;int err =0 ;struct sockaddr *addr = (struct sockaddr *)&mc->addr;
@@ -4618,10 +4644,6 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,if (cma_zero_addr (addr))return -EINVAL ; - work =kzalloc (sizeof *work,GFP_KERNEL ); -if (!work) -return -ENOMEM ; - gid_type = id_priv->cma_dev->default_gid_type[id_priv->id.port_num -rdma_start_port (id_priv->cma_dev->device)];cma_iboe_set_mgid (addr, &ib.rec.mgid, gid_type);
@@ -4632,10 +4654,9 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,if (dev_addr->bound_dev_if) ndev =dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if); -if (!ndev) { - err = -ENODEV ; - goto err_free; - } +if (!ndev) +return -ENODEV ; + ib.rec.rate =iboe_get_rate (ndev); ib.rec.hop_limit =1 ; ib.rec.mtu =iboe_get_mtu (ndev->mtu);
@@ -4653,24 +4674,15 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv, err = -ENOTSUPP ; }dev_put (ndev); -if (err || !ib.rec.mtu) { -if (!err) - err = -EINVAL ; - goto err_free; - } +if (err || !ib.rec.mtu) +return err ?: -EINVAL ; +rdma_ip2gid ((struct sockaddr *)&id_priv->id.route.addr.src_addr, &ib.rec.port_gid); - work->id = id_priv; -INIT_WORK (&work->work, cma_work_handler); -cma_make_mc_event (0 , id_priv, &ib, &work->event, mc); -/* Balances with cma_id_put() in cma_work_handler */ -cma_id_get (id_priv); -queue_work (cma_wq, &work->work); +INIT_WORK (&mc->iboe_join.work, cma_iboe_join_work_handler); +cma_make_mc_event (0 , id_priv, &ib, &mc->iboe_join.event, mc); +queue_work (cma_wq, &mc->iboe_join.work);return 0 ; - -err_free: -kfree (work); -return err; } int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 459/775 RDMA/rtrs-srv: Fix stack-out-of-bounds
In reply to Greg Kroah-HartmanFrom: Jack Wang <[email protected]>
[ Upstream commit e6daa8f61d8def10f0619fe51b4c794f69598e4f ]
BUG: KASAN: stack-out-of-bounds in _mlx4_ib_post_send+0x1bd2/0x2770 [mlx4_ib] Read of size 4 at addr ffff8880d5a7f980 by task kworker/0:1H/565 CPU: 0 PID: 565 Comm: kworker/0:1H Tainted: G O 5.4.84-storage #5.4.84-1+feature+linux+5.4.y+dbg+20201216.1319+b6b887b~deb10 Hardware name: Supermicro H8QG6/H8QG6, BIOS 3.00 09/04/2012 Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x96/0xe0 print_address_description.constprop.4+0x1f/0x300 ? irq_work_claim+0x2e/0x50 __kasan_report.cold.8+0x78/0x92 ? _mlx4_ib_post_send+0x1bd2/0x2770 [mlx4_ib] kasan_report+0x10/0x20 _mlx4_ib_post_send+0x1bd2/0x2770 [mlx4_ib] ? check_chain_key+0x1d7/0x2e0 ? _mlx4_ib_post_recv+0x630/0x630 [mlx4_ib] ? lockdep_hardirqs_on+0x1a8/0x290 ? stack_depot_save+0x218/0x56e ? do_profile_hits.isra.6.cold.13+0x1d/0x1d ? check_chain_key+0x1d7/0x2e0 ? save_stack+0x4d/0x80 ? save_stack+0x19/0x80 ? __kasan_slab_free+0x125/0x170 ? kfree+0xe7/0x3b0 rdma_write_sg+0x5b0/0x950 [rtrs_server]
The problem is when we send imm_wr, the type should be ib_rdma_wr, so hw driver like mlx4 can do rdma_wr(wr), so fix it by use the ib_rdma_wr as type for imm_wr.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 64 +++++++++++++------------- 1 file changed, 33 insertions(+), 31 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +33 -31
@@ -222,7 +222,8 @@ static int rdma_write_sg(struct rtrs_srv_op *id)dma_addr_t dma_addr = sess->dma_addr[id->msg_id];struct rtrs_srv_mr *srv_mr;struct rtrs_srv *srv = sess->srv; -struct ib_send_wr inv_wr, imm_wr; +struct ib_send_wr inv_wr; +struct ib_rdma_wr imm_wr;struct ib_rdma_wr *wr =NULL ;enum ib_send_flags flags;size_t sg_cnt;
@@ -274,15 +275,15 @@ static int rdma_write_sg(struct rtrs_srv_op *id)if (need_inval && always_invalidate) { wr->wr.next = &rwr.wr; rwr.wr.next = &inv_wr; - inv_wr.next = &imm_wr; + inv_wr.next = &imm_wr.wr; }else if (always_invalidate) { wr->wr.next = &rwr.wr; - rwr.wr.next = &imm_wr; + rwr.wr.next = &imm_wr.wr; }else if (need_inval) { wr->wr.next = &inv_wr; - inv_wr.next = &imm_wr; + inv_wr.next = &imm_wr.wr; }else { - wr->wr.next = &imm_wr; + wr->wr.next = &imm_wr.wr; }/* * From time to time we have to post signaled sends,
@@ -300,7 +301,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) inv_wr.ex.invalidate_rkey = rkey; } - imm_wr.next =NULL ; + imm_wr.wr.next =NULL ;if (always_invalidate) {struct rtrs_msg_rkey_rsp *msg;
@@ -321,22 +322,22 @@ static int rdma_write_sg(struct rtrs_srv_op *id) list.addr = srv_mr->iu->dma_addr; list.length =sizeof (*msg); list.lkey = sess->s.dev->ib_pd->local_dma_lkey; - imm_wr.sg_list = &list; - imm_wr.num_sge =1 ; - imm_wr.opcode =IB_WR_SEND_WITH_IMM ; + imm_wr.wr.sg_list = &list; + imm_wr.wr.num_sge =1 ; + imm_wr.wr.opcode =IB_WR_SEND_WITH_IMM ;ib_dma_sync_single_for_device (sess->s.dev->ib_dev, srv_mr->iu->dma_addr, srv_mr->iu->size,DMA_TO_DEVICE ); }else { - imm_wr.sg_list =NULL ; - imm_wr.num_sge =0 ; - imm_wr.opcode =IB_WR_RDMA_WRITE_WITH_IMM ; + imm_wr.wr.sg_list =NULL ; + imm_wr.wr.num_sge =0 ; + imm_wr.wr.opcode =IB_WR_RDMA_WRITE_WITH_IMM ; } - imm_wr.send_flags = flags; - imm_wr.ex.imm_data =cpu_to_be32 (rtrs_to_io_rsp_imm (id->msg_id, + imm_wr.wr.send_flags = flags; + imm_wr.wr.ex.imm_data =cpu_to_be32 (rtrs_to_io_rsp_imm (id->msg_id,0 , need_inval)); - imm_wr.wr_cqe = &io_comp_cqe; + imm_wr.wr.wr_cqe = &io_comp_cqe;ib_dma_sync_single_for_device (sess->s.dev->ib_dev, dma_addr, offset,DMA_BIDIRECTIONAL );
@@ -363,7 +364,8 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, {struct rtrs_sess *s = con->c.sess;struct rtrs_srv_sess *sess =to_srv_sess (s); -struct ib_send_wr inv_wr, imm_wr, *wr =NULL ; +struct ib_send_wr inv_wr, *wr =NULL ; +struct ib_rdma_wr imm_wr;struct ib_reg_wr rwr;struct rtrs_srv *srv = sess->srv;struct rtrs_srv_mr *srv_mr;
@@ -400,15 +402,15 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id,if (need_inval && always_invalidate) { wr = &inv_wr; inv_wr.next = &rwr.wr; - rwr.wr.next = &imm_wr; + rwr.wr.next = &imm_wr.wr; }else if (always_invalidate) { wr = &rwr.wr; - rwr.wr.next = &imm_wr; + rwr.wr.next = &imm_wr.wr; }else if (need_inval) { wr = &inv_wr; - inv_wr.next = &imm_wr; + inv_wr.next = &imm_wr.wr; }else { - wr = &imm_wr; + wr = &imm_wr.wr; }/* * From time to time we have to post signalled sends,
@@ -417,13 +419,13 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, flags = (atomic_inc_return (&con->wr_cnt) % srv->queue_depth) ?0 :IB_SEND_SIGNALED ; imm =rtrs_to_io_rsp_imm (id->msg_id, errno, need_inval); - imm_wr.next =NULL ; + imm_wr.wr.next =NULL ;if (always_invalidate) {struct ib_sge list;struct rtrs_msg_rkey_rsp *msg; srv_mr = &sess->mrs[id->msg_id]; - rwr.wr.next = &imm_wr; + rwr.wr.next = &imm_wr.wr; rwr.wr.opcode =IB_WR_REG_MR ; rwr.wr.wr_cqe = &local_reg_cqe; rwr.wr.num_sge =0 ;
@@ -440,21 +442,21 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, list.addr = srv_mr->iu->dma_addr; list.length =sizeof (*msg); list.lkey = sess->s.dev->ib_pd->local_dma_lkey; - imm_wr.sg_list = &list; - imm_wr.num_sge =1 ; - imm_wr.opcode =IB_WR_SEND_WITH_IMM ; + imm_wr.wr.sg_list = &list; + imm_wr.wr.num_sge =1 ; + imm_wr.wr.opcode =IB_WR_SEND_WITH_IMM ;ib_dma_sync_single_for_device (sess->s.dev->ib_dev, srv_mr->iu->dma_addr, srv_mr->iu->size,DMA_TO_DEVICE ); }else { - imm_wr.sg_list =NULL ; - imm_wr.num_sge =0 ; - imm_wr.opcode =IB_WR_RDMA_WRITE_WITH_IMM ; + imm_wr.wr.sg_list =NULL ; + imm_wr.wr.num_sge =0 ; + imm_wr.wr.opcode =IB_WR_RDMA_WRITE_WITH_IMM ; } - imm_wr.send_flags = flags; - imm_wr.wr_cqe = &io_comp_cqe; + imm_wr.wr.send_flags = flags; + imm_wr.wr.wr_cqe = &io_comp_cqe; - imm_wr.ex.imm_data =cpu_to_be32 (imm); + imm_wr.wr.ex.imm_data =cpu_to_be32 (imm); err =ib_post_send (id->con->c.qp, wr,NULL );if (unlikely (err))
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 460/775 RDMA/rtrs: Only allow addition of path to an already established session
In reply to Greg Kroah-HartmanFrom: Md Haris Iqbal <[email protected]>
[ Upstream commit 03e9b33a0fd677f554b03352646c13459bf60458 ]
While adding a path from the client side to an already established session, it was possible to provide the destination IP to a different server. This is dangerous.
This commit adds an extra member to the rtrs_msg_conn_req structure, named first_conn; which is supposed to notify if the connection request is the first for that session or not.
On the server side, if a session does not exist but the first_conn received inside the rtrs_msg_conn_req structure is 1, the connection request is failed. This signifies that the connection request is for an already existing session, and since the server did not find one, it is an wrong connection request.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 +++++++ drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 + drivers/infiniband/ulp/rtrs/rtrs-pri.h | 4 +++- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 21 +++++++++++++++------ 4 files changed, 26 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +7 -0
@@ -31,6 +31,8 @@*/ #define RTRS_RECONNECT_SEED 8 +#define FIRST_CONN 0x01 +MODULE_DESCRIPTION ("RDMA Transport Client" );MODULE_LICENSE ("GPL" );
@@ -1662,6 +1664,7 @@ static int rtrs_rdma_route_resolved(struct rtrs_clt_con *con) .cid_num = cpu_to_le16(sess->s.con_num), .recon_cnt = cpu_to_le16(sess->s.recon_cnt), }; + msg.first_conn = sess->for_new_clt ?FIRST_CONN :0 ;uuid_copy (&msg.sess_uuid, &sess->s.uuid);uuid_copy (&msg.paths_uuid, &clt->paths_uuid);
@@ -1747,6 +1750,8 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,scnprintf (sess->hca_name,sizeof (sess->hca_name), sess->s.dev->ib_dev->name); sess->s.src_addr = con->c.cm_id->route.addr.src_addr; +/* set for_new_clt, to allow future reconnect on any path */ + sess->for_new_clt =1 ; }return 0 ;
@@ -2676,6 +2681,8 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, err =PTR_ERR (sess); goto close_all_sess; } +if (!i) + sess->for_new_clt =1 ;list_add_tail_rcu (&sess->s.entry, &clt->paths_list); err =init_sess (sess);
drivers/infiniband/ulp/rtrs/rtrs-clt.h +1 -0
@@ -143,6 +143,7 @@ struct rtrs_clt_sess {int max_send_sge;u32 flags;struct kobject kobj; +u8 for_new_clt;struct rtrs_clt_stats *stats;/* cache hca_port and hca_name to display in sysfs */ u8 hca_port;
drivers/infiniband/ulp/rtrs/rtrs-pri.h +3 -1
@@ -188,7 +188,9 @@ struct rtrs_msg_conn_req {__le16 recon_cnt;uuid_t sess_uuid;uuid_t paths_uuid; -u8 reserved[12 ]; + u8 first_conn : 1; + u8 reserved_bits : 7; +u8 reserved[11 ]; };/**
drivers/infiniband/ulp/rtrs/rtrs-srv.c +15 -6
@@ -1334,7 +1334,8 @@ static void free_srv(struct rtrs_srv *srv) }static struct rtrs_srv *get_or_create_srv (struct rtrs_srv_ctx *ctx, -const uuid_t *paths_uuid) +const uuid_t *paths_uuid, +bool first_conn) {struct rtrs_srv *srv;int i;
@@ -1347,12 +1348,20 @@ static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx,return srv; } } +/* +* If this request is not the first connection request from the +* client for this session then fail and return error. +*/ +if (!first_conn) { +mutex_unlock (&ctx->srv_mutex); +return ERR_PTR (-ENXIO ); + }/* need to allocate a new srv */ srv =kzalloc (sizeof (*srv),GFP_KERNEL );if (!srv) {mutex_unlock (&ctx->srv_mutex); -return NULL ; +return ERR_PTR (-ENOMEM ); }INIT_LIST_HEAD (&srv->paths_list);
@@ -1387,7 +1396,7 @@ err_free_chunks: err_free_srv:kfree (srv); -return NULL ; +return ERR_PTR (-ENOMEM ); }static void put_srv (struct rtrs_srv *srv)
@@ -1788,13 +1797,13 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, goto reject_w_econnreset; } recon_cnt =le16_to_cpu (msg->recon_cnt); - srv =get_or_create_srv (ctx, &msg->paths_uuid); + srv =get_or_create_srv (ctx, &msg->paths_uuid, msg->first_conn);/* * "refcount == 0" happens if a previous thread calls get_or_create_srv * allocate srv, but chunks of srv are not allocated yet. */ -if (!srv ||refcount_read (&srv->refcount) ==0 ) { - err = -ENOMEM ; +if (IS_ERR (srv) ||refcount_read (&srv->refcount) ==0 ) { + err =PTR_ERR (srv); goto reject_w_err; }mutex_lock (&srv->paths_mutex);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 461/775 RDMA/rtrs-srv: fix memory leak by missing kobject free
In reply to Greg Kroah-HartmanFrom: Gioh Kim <[email protected]>
[ Upstream commit f7452a7e96c120d73100387d5f87de9fce7133cb ]
kmemleak reported an error as below:
unreferenced object 0xffff8880674b7640 (size 64):
comm "kworker/4:1H", pid 113, jiffies 4296403507 (age 507.840s)
hex dump (first 32 bytes):
69 70 3a 31 39 32 2e 31 36 38 2e 31 32 32 2e 31 ip:192.168.122.1
31 30 40 69 70 3a 31 39 32 2e 31 36 38 2e 31 32 10@ip:192.168.12
backtrace:
[<0000000054413611>] kstrdup+0x2e/0x60
[<0000000078e3120a>] kobject_set_name_vargs+0x2f/0xb0
[<00000000ca2be3ee>] kobject_init_and_add+0xb0/0x120
[<0000000062ba5e78>] rtrs_srv_create_sess_files+0x14c/0x314 [rtrs_server]
[<00000000b45b7217>] rtrs_srv_info_req_done+0x5b1/0x800 [rtrs_server]
[<000000008fc5aa8f>] __ib_process_cq+0x94/0x100 [ib_core]
[<00000000a9599cb4>] ib_cq_poll_work+0x32/0xc0 [ib_core]
[<00000000cfc376be>] process_one_work+0x4bc/0x980
[<0000000016e5c96a>] worker_thread+0x78/0x5c0
[<00000000c20b8be0>] kthread+0x191/0x1e0
[<000000006c9c0003>] ret_from_fork+0x3a/0x50It is caused by the not-freed kobject of rtrs_srv_sess. The kobject embedded in rtrs_srv_sess has ref-counter 2 after calling process_info_req(). Therefore it must call kobject_put twice. Currently it calls kobject_put only once at rtrs_srv_destroy_sess_files because kobject_del removes the state_in_sysfs flag and then kobject_put in free_sess() is not called.
This patch moves kobject_del() into free_sess() so that the kobject of rtrs_srv_sess can be freed. And also this patch adds the missing call of sysfs_remove_group() to clean-up the sysfs directory.
--- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +1 -1
@@ -305,7 +305,7 @@ void rtrs_srv_destroy_sess_files(struct rtrs_srv_sess *sess)if (sess->kobj.state_in_sysfs) {kobject_del (&sess->stats->kobj_stats);kobject_put (&sess->stats->kobj_stats); -kobject_del (&sess->kobj); +sysfs_remove_group (&sess->kobj, &rtrs_srv_sess_attr_group);kobject_put (&sess->kobj);rtrs_srv_destroy_once_sysfs_root_folders (sess);
drivers/infiniband/ulp/rtrs/rtrs-srv.c +4 -2
@@ -1476,10 +1476,12 @@ static bool __is_path_w_addr_exists(struct rtrs_srv *srv,static void free_sess (struct rtrs_srv_sess *sess) { -if (sess->kobj.state_in_sysfs) +if (sess->kobj.state_in_sysfs) { +kobject_del (&sess->kobj);kobject_put (&sess->kobj); -else + }else {kfree (sess); + } }static void rtrs_srv_close_work (struct work_struct *work)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 462/775 RDMA/rtrs-srv-sysfs: fix missing put_device
In reply to Greg Kroah-HartmanFrom: Gioh Kim <[email protected]>
[ Upstream commit e2853c49477d104c01d3c7944e1fb5074eb11d9f ]
put_device() decreases the ref-count and then the device will be cleaned-up, while at is also add missing put_device in rtrs_srv_create_once_sysfs_root_folders
This patch solves a kmemleak error as below:
unreferenced object 0xffff88809a7a0710 (size 8):
comm "kworker/4:1H", pid 113, jiffies 4295833049 (age 6212.380s)
hex dump (first 8 bytes):
62 6c 61 00 6b 6b 6b a5 bla.kkk.
backtrace:
[<0000000054413611>] kstrdup+0x2e/0x60
[<0000000078e3120a>] kobject_set_name_vargs+0x2f/0xb0
[<00000000f1a17a6b>] dev_set_name+0xab/0xe0
[<00000000d5502e32>] rtrs_srv_create_sess_files+0x2fb/0x314 [rtrs_server]
[<00000000ed11a1ef>] rtrs_srv_info_req_done+0x631/0x800 [rtrs_server]
[<000000008fc5aa8f>] __ib_process_cq+0x94/0x100 [ib_core]
[<00000000a9599cb4>] ib_cq_poll_work+0x32/0xc0 [ib_core]
[<00000000cfc376be>] process_one_work+0x4bc/0x980
[<0000000016e5c96a>] worker_thread+0x78/0x5c0
[<00000000c20b8be0>] kthread+0x191/0x1e0
[<000000006c9c0003>] ret_from_fork+0x3a/0x50--- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +2 -0
@@ -183,6 +183,7 @@ static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess) err = -ENOMEM ;pr_err ("kobject_create_and_add(): %d\n" , err);device_del (&srv->dev); +put_device (&srv->dev); goto unlock; }dev_set_uevent_suppress (&srv->dev, false);
@@ -208,6 +209,7 @@ rtrs_srv_destroy_once_sysfs_root_folders(struct rtrs_srv_sess *sess)kobject_put (srv->kobj_paths);mutex_unlock (&srv->paths_mutex);device_del (&srv->dev); +put_device (&srv->dev); }else {mutex_unlock (&srv->paths_mutex); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 463/775 RDMA/rtrs-srv: Do not pass a valid pointer to PTR_ERR()
In reply to Greg Kroah-HartmanFrom: Jack Wang <[email protected]>
[ Upstream commit ed408529679737a9a7ad816c8de5d59ba104bb11 ]
smatch gives the warning:
drivers/infiniband/ulp/rtrs/rtrs-srv.c:1805 rtrs_rdma_connect() warn: passing zero to 'PTR_ERR'
Which is trying to say smatch has shown that srv is not an error pointer and thus cannot be passed to PTR_ERR.
The solution is to move the list_add() down after full initilization of rtrs_srv. To avoid holding the srv_mutex too long, only hold it during the list operation as suggested by Leon.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +7 -13
@@ -1348,21 +1348,18 @@ static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx,return srv; } } +mutex_unlock (&ctx->srv_mutex);/* * If this request is not the first connection request from the * client for this session then fail and return error. */ -if (!first_conn) { -mutex_unlock (&ctx->srv_mutex); +if (!first_conn)return ERR_PTR (-ENXIO ); - }/* need to allocate a new srv */ srv =kzalloc (sizeof (*srv),GFP_KERNEL ); -if (!srv) { -mutex_unlock (&ctx->srv_mutex); +if (!srv)return ERR_PTR (-ENOMEM ); - }INIT_LIST_HEAD (&srv->paths_list);mutex_init (&srv->paths_mutex);
@@ -1372,8 +1369,6 @@ static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx, srv->ctx = ctx;device_initialize (&srv->dev); srv->dev.release = rtrs_srv_dev_release; -list_add (&srv->ctx_list, &ctx->srv_list); -mutex_unlock (&ctx->srv_mutex); srv->chunks =kcalloc (srv->queue_depth,sizeof (*srv->chunks),GFP_KERNEL );
@@ -1386,6 +1381,9 @@ static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx, goto err_free_chunks; }refcount_set (&srv->refcount,1 ); +mutex_lock (&ctx->srv_mutex); +list_add (&srv->ctx_list, &ctx->srv_list); +mutex_unlock (&ctx->srv_mutex);return srv;
@@ -1800,11 +1798,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, } recon_cnt =le16_to_cpu (msg->recon_cnt); srv =get_or_create_srv (ctx, &msg->paths_uuid, msg->first_conn); -/* -* "refcount == 0" happens if a previous thread calls get_or_create_srv -* allocate srv, but chunks of srv are not allocated yet. -*/ -if (IS_ERR (srv) ||refcount_read (&srv->refcount) ==0 ) { +if (IS_ERR (srv)) { err =PTR_ERR (srv); goto reject_w_err; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 464/775 Input: sur40 - fix an error code in sur40_probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit b0b7d2815839024e5181bd2572f5d8d4f65363b3 ]
If v4l2_ctrl_handler_setup() fails then probe() should return an error code instead of returning success.
--- drivers/input/touchscreen/sur40.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/touchscreen/sur40.c +1 -0
@@ -787,6 +787,7 @@ static int sur40_probe(struct usb_interface *interface,dev_err (&interface->dev,"Unable to register video controls." );v4l2_ctrl_handler_free (&sur40->hdl); + error = sur40->hdl.error; goto err_unreg_v4l2; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 465/775 perf record: Fix continue profiling after draining the buffer
In reply to Greg Kroah-HartmanFrom: Yang Jihong <[email protected]>
[ Upstream commit e16c2ce7c5ed5de881066c1fd10ba5c09af69559 ]
Commit da231338ec9c0987 ("perf record: Use an eventfd to wakeup when done") uses eventfd() to solve a rare race where the setting and checking of 'done' which add done_fd to pollfd. When draining buffer, revents of done_fd is 0 and evlist__filter_pollfd function returns a non-zero value. As a result, perf record does not stop profiling.
The following simple scenarios can trigger this condition:
# sleep 10 & # perf record -p $!
After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP, perf record indicates that buffer is draining and need to stop profiling. Use fdarray_flag__nonfilterable() to set done eventfd to nonfilterable objects, so that evlist__filter_pollfd() does not filter and check done eventfd.
--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +1 -1
@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;
tools/perf/util/evlist.c +8 -0
@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); } +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif +int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);
tools/perf/util/evlist.h +4 -0
@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 466/775 perf unwind: Set userdata for all __report_module() paths
In reply to Greg Kroah-HartmanFrom: Dave Rigby <[email protected]>
[ Upstream commit 4e1481445407b86a483616c4542ffdc810efb680 ]
When locating the DWARF module for a given address, __find_debuginfo() requires a 'struct dso' passed via the userdata argument.
However, this field is only set in __report_module() if the module is found in via dwfl_addrmodule(), not if it is found later via dwfl_report_elf().
Set userdata irrespective of how the DWARF module was found, as long as we found a module.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211801
--- tools/perf/util/unwind-libdw.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/util/unwind-libdw.c +8 -3
@@ -60,10 +60,8 @@ static int __report_module(struct addr_location *al, u64 ip, mod =dwfl_addrmodule (ui->dwfl, ip);if (mod) {Dwarf_Addr s; -void **userdatap; -dwfl_module_info (mod, &userdatap, &s,NULL ,NULL ,NULL ,NULL ,NULL ); - *userdatap = dso; +dwfl_module_info (mod,NULL , &s,NULL ,NULL ,NULL ,NULL ,NULL );if (s != al->map->start - al->map->pgoff) mod =0 ; }
@@ -79,6 +77,13 @@ static int __report_module(struct addr_location *al, u64 ip, al->map->start - al->map->pgoff, false); } +if (mod) { +void **userdatap; + +dwfl_module_info (mod, &userdatap,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ); + *userdatap = dso; + } +return mod &&dwfl_addrmodule (ui->dwfl, ip) == mod ?0 :-1 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 467/775 perf intel-pt: Fix missing CYC processing in PSB
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 03fb0f859b45d1eb05c984ab4bd3bef67e45ede2 ]
Add missing CYC packet processing when walking through PSB+. This improves the accuracy of timestamps that follow PSB+, until the next MTC.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +3 -0
@@ -1761,6 +1761,9 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)break ;case INTEL_PT_CYC : +intel_pt_calc_cyc_timestamp (decoder); +break ; +case INTEL_PT_VMCS :case INTEL_PT_MNT :case INTEL_PT_PAD :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 468/775 perf intel-pt: Fix premature IPC
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 20aa39708a5999b7921b27482a756766272286ac ]
The code assumed a change in cycle count means accurate IPC. That is not correct, for example when sampling both branches and instructions, or at a FUP packet (which is not CYC-eligible) address. Fix by using an explicit flag to indicate when IPC can be sampled.
--- .../util/intel-pt-decoder/intel-pt-decoder.c | 11 ++++++++++- .../util/intel-pt-decoder/intel-pt-decoder.h | 1 + tools/perf/util/intel-pt.c | 16 ++++++---------- 3 files changed, 17 insertions(+), 11 deletions(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +10 -1
@@ -2814,9 +2814,18 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder) }if (intel_pt_sample_time (decoder->pkt_state)) {intel_pt_update_sample_time (decoder); -if (decoder->sample_cyc) +if (decoder->sample_cyc) { decoder->sample_tot_cyc_cnt = decoder->tot_cyc_cnt; + decoder->state.flags |=INTEL_PT_SAMPLE_IPC ; + decoder->sample_cyc = false; + } } +/* +* When using only TSC/MTC to compute cycles, IPC can be +* sampled as soon as the cycle count changes. +*/ +if (!decoder->have_cyc) + decoder->state.flags |=INTEL_PT_SAMPLE_IPC ; } decoder->state.timestamp = decoder->sample_timestamp;
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +1 -0
@@ -17,6 +17,7 @@#define INTEL_PT_ABORT_TX (1 << 1)#define INTEL_PT_ASYNC (1 << 2)#define INTEL_PT_FUP_IP (1 << 3) +#define INTEL_PT_SAMPLE_IPC (1 << 4)enum intel_pt_sample_type {INTEL_PT_BRANCH =1 <<0 ,
tools/perf/util/intel-pt.c +6 -10
@@ -1381,7 +1381,8 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq) sample.branch_stack = (struct branch_stack *)&dummy_bs; } - sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_br_cyc_cnt; +if (ptq->state->flags &INTEL_PT_SAMPLE_IPC ) + sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_br_cyc_cnt;if (sample.cyc_cnt) { sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_br_insn_cnt; ptq->last_br_insn_cnt = ptq->ipc_insn_cnt;
@@ -1431,7 +1432,8 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)else sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt; - sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_in_cyc_cnt; +if (ptq->state->flags &INTEL_PT_SAMPLE_IPC ) + sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_in_cyc_cnt;if (sample.cyc_cnt) { sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_in_insn_cnt; ptq->last_in_insn_cnt = ptq->ipc_insn_cnt;
@@ -1966,14 +1968,8 @@ static int intel_pt_sample(struct intel_pt_queue *ptq) ptq->have_sample = false; -if (ptq->state->tot_cyc_cnt > ptq->ipc_cyc_cnt) { -/* -* Cycle count and instruction count only go together to create -* a valid IPC ratio when the cycle count changes. -*/ - ptq->ipc_insn_cnt = ptq->state->tot_insn_cnt; - ptq->ipc_cyc_cnt = ptq->state->tot_cyc_cnt; - } + ptq->ipc_insn_cnt = ptq->state->tot_insn_cnt; + ptq->ipc_cyc_cnt = ptq->state->tot_cyc_cnt;/* * Do PEBS first to allow for the possibility that the PEBS timestamp
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 469/775 perf intel-pt: Fix IPC with CYC threshold
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 6af4b60033e0ce0332fcdf256c965ad41942821a ]
The code assumed every CYC-eligible packet has a CYC packet, which is not the case when CYC thresholds are used. Fix by checking if a CYC packet is actually present in that case.
--- .../util/intel-pt-decoder/intel-pt-decoder.c | 27 +++++++++++++++++++ .../util/intel-pt-decoder/intel-pt-decoder.h | 1 + tools/perf/util/intel-pt.c | 13 +++++++++ 3 files changed, 41 insertions(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +27 -0
@@ -24,6 +24,13 @@#include "intel-pt-decoder.h" #include "intel-pt-log.h" +#define BITULL (x) (1ULL << (x)) + +/* IA32_RTIT_CTL MSR bits */ +#define INTEL_PT_CYC_ENABLE BITULL(1) +#define INTEL_PT_CYC_THRESHOLD (BITULL(22) | BITULL(21) | BITULL(20) | BITULL(19)) +#define INTEL_PT_CYC_THRESHOLD_SHIFT 19 +#define INTEL_PT_BLK_SIZE 1024#define BIT63 (((uint64_t)1 << 63))
@@ -167,6 +174,8 @@ struct intel_pt_decoder {uint64_t sample_tot_cyc_cnt;uint64_t base_cyc_cnt;uint64_t cyc_cnt_timestamp; +uint64_t ctl; +uint64_t cyc_threshold;double tsc_to_cyc;bool continuous_period;bool overflow;
@@ -204,6 +213,14 @@ static uint64_t intel_pt_lower_power_of_2(uint64_t x)return x << i; } +static uint64_t intel_pt_cyc_threshold (uint64_t ctl) +{ +if (!(ctl &INTEL_PT_CYC_ENABLE )) +return 0 ; + +return (ctl &INTEL_PT_CYC_THRESHOLD ) >>INTEL_PT_CYC_THRESHOLD_SHIFT ; +} +static void intel_pt_setup_period (struct intel_pt_decoder *decoder) {if (decoder->period_type ==INTEL_PT_PERIOD_TICKS ) {
@@ -245,12 +262,15 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params) decoder->flags = params->flags; + decoder->ctl = params->ctl; decoder->period = params->period; decoder->period_type = params->period_type; decoder->max_non_turbo_ratio = params->max_non_turbo_ratio; decoder->max_non_turbo_ratio_fp = params->max_non_turbo_ratio; + decoder->cyc_threshold =intel_pt_cyc_threshold (decoder->ctl); +intel_pt_setup_period (decoder); decoder->mtc_shift = params->mtc_period;
@@ -2017,6 +2037,7 @@ static int intel_pt_hop_trace(struct intel_pt_decoder *decoder, bool *no_tip, instatic int intel_pt_walk_trace (struct intel_pt_decoder *decoder) { +int last_packet_type =INTEL_PT_PAD ;bool no_tip = false;int err;
@@ -2025,6 +2046,12 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder)if (err)return err; next: +if (decoder->cyc_threshold) { +if (decoder->sample_cyc && last_packet_type !=INTEL_PT_CYC ) + decoder->sample_cyc = false; + last_packet_type = decoder->packet.type; + } +if (decoder->hop) {switch (intel_pt_hop_trace (decoder, &no_tip, &err)) {case HOP_IGNORE :
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +1 -0
@@ -244,6 +244,7 @@ struct intel_pt_params {void *data;bool return_compression;bool branch_enable; +uint64_t ctl;uint64_t period;enum intel_pt_period_type period_type;unsigned max_non_turbo_ratio;
tools/perf/util/intel-pt.c +13 -0
@@ -893,6 +893,18 @@ static bool intel_pt_sampling_mode(struct intel_pt *pt)return false; } +static u64 intel_pt_ctl (struct intel_pt *pt) +{ +struct evsel *evsel; +u64 config; + +evlist__for_each_entry (pt->session->evlist, evsel) { +if (intel_pt_get_config (pt, &evsel->core.attr, &config)) +return config; + } +return 0 ; +} +static u64 intel_pt_ns_to_ticks (const struct intel_pt *pt,u64 ns) {u64 quot, rem;
@@ -1026,6 +1038,7 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, params.data = ptq; params.return_compression =intel_pt_return_compression (pt); params.branch_enable =intel_pt_branch_enable (pt); + params.ctl =intel_pt_ctl (pt); params.max_non_turbo_ratio = pt->max_non_turbo_ratio; params.mtc_period =intel_pt_mtc_period (pt); params.tsc_ctc_ratio_n = pt->tsc_ctc_ratio_n;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 470/775 perf test: Fix unaligned access in sample parsing test
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit c5c97cadd7ed13381cb6b4bef5c841a66938d350 ]
The ubsan reported the following error. It was because sample's raw data missed u32 padding at the end. So it broke the alignment of the array after it.
The raw data contains an u32 size prefix so the data size should have an u32 padding after 8-byte aligned data.
27: Sample parsing :util/synthetic-events.c:1539:4:
runtime error: store to misaligned address 0x62100006b9bc for type
'__u64' (aka 'unsigned long long'), which requires 8 byte alignment0x62100006b9bc: note: pointer points here
00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
#0 0x561532a9fc96 in perf_event__synthesize_sample util/synthetic-events.c:1539:13
#1 0x5615327f4a4f in do_test tests/sample-parsing.c:284:8
#2 0x5615327f3f50 in test__sample_parsing tests/sample-parsing.c:381:9
#3 0x56153279d3a1 in run_test tests/builtin-test.c:424:9
#4 0x56153279c836 in test_and_print tests/builtin-test.c:454:9
#5 0x56153279b7eb in __cmd_test tests/builtin-test.c:675:4
#6 0x56153279abf0 in cmd_test tests/builtin-test.c:821:9
#7 0x56153264e796 in run_builtin perf.c:312:11
#8 0x56153264cf03 in handle_internal_command perf.c:364:8
#9 0x56153264e47d in run_argv perf.c:408:2
#10 0x56153264c9a9 in main perf.c:538:3
#11 0x7f137ab6fbbc in __libc_start_main (/lib64/libc.so.6+0x38bbc)
#12 0x561532596828 in _start ...SUMMARY: UndefinedBehaviorSanitizer: misaligned-pointer-use
util/synthetic-events.c:1539:4 in
--- tools/perf/tests/sample-parsing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/sample-parsing.c +1 -1
@@ -196,7 +196,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .data = {1, -1ULL, 211, 212, 213}, };u64 regs[64 ]; -const u64 raw_data[] = {0x123456780a0b0c0dULL ,0x1102030405060708ULL }; +const u32 raw_data[] = {0x12345678 ,0x0a0b0c0d ,0x11020304 ,0x05060708 ,0 };const u64 data[] = {0x2211443366558877ULL ,0 ,0xaabbccddeeff4321ULL };const u64 aux_data[] = {0xa55a ,0 ,0xeeddee ,0x0282028202820282 }; struct perf_sample sample = {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 471/775 Input: elo - fix an error code in elo_connect()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 0958351e93fa0ac142f6dd8bd844441594f30a57 ]
If elo_setup_10() fails then this should return an error code instead of success.
--- drivers/input/touchscreen/elo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elo.c +3 -1
@@ -341,8 +341,10 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)switch (elo->id) {case 0 :/* 10-byte protocol */ -if (elo_setup_10 (elo)) +if (elo_setup_10 (elo)) { + err = -EIO ; goto fail3; + }break ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 472/775 sparc64: only select COMPAT_BINFMT_ELF if BINFMT_ELF is set
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 80bddf5c93a99e11fc9faf7e4b575d01cecd45d3 ]
Currently COMPAT on SPARC64 selects COMPAT_BINFMT_ELF unconditionally, even when BINFMT_ELF is not enabled. This causes a kconfig warning.
Instead, just select COMPAT_BINFMT_ELF if BINFMT_ELF is enabled. This builds cleanly with no kconfig warnings.
WARNING: unmet direct dependencies detected for COMPAT_BINFMT_ELF
Depends on [n]: COMPAT [=y] && BINFMT_ELF [=n] Selected by [y]:
- COMPAT [=y] && SPARC64 [=y]
--- arch/sparc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/Kconfig +1 -1
@@ -494,7 +494,7 @@ config COMPAT bool depends on SPARC64 default y - select COMPAT_BINFMT_ELF + select COMPAT_BINFMT_ELF if BINFMT_ELF select HAVE_UID16 select ARCH_WANT_OLD_COMPAT_IPC select COMPAT_OLD_SIGACTION
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 473/775 sparc: fix led.c driver when PROC_FS is not enabled
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit b3554aa2470b5db1222c31e08ec9c29ab33eabc7 ]
Fix Sparc build when CONFIG_PROC_FS is not enabled.
Fixes this build error:arch/sparc/kernel/led.c:107:30: error: 'led_proc_ops' defined but not used [-Werror=unused-const-variable=]
107 | static const struct proc_ops led_proc_ops = {
| ^~~~~~~~~~~~cc1: all warnings being treated as errors
--- arch/sparc/kernel/led.c | 2 ++ 1 file changed, 2 insertions(+)
arch/sparc/kernel/led.c +2 -0
@@ -50,6 +50,7 @@ static void led_blink(struct timer_list *unused)add_timer (&led_blink_timer); } +#ifdef CONFIG_PROC_FS static int led_proc_show (struct seq_file *m,void *v) {if (get_auxio () &AUXIO_LED )
@@ -111,6 +112,7 @@ static const struct proc_ops led_proc_ops = { .proc_release = single_release, .proc_write = led_proc_write, }; +#endif static struct proc_dir_entry *led;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 474/775 Input: zinitix - fix return type of zinitix_init_touch()
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 836f308cb5c72d48e2dff8d3e64c3adb94f4710d ]
zinitix_init_touch() returns error code or 0 for success and therefore return type must be int, not bool.
--- drivers/input/touchscreen/zinitix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/zinitix.c +1 -1
@@ -190,7 +190,7 @@ static int zinitix_write_cmd(struct i2c_client *client, u16 reg)return 0 ; } -static bool zinitix_init_touch (struct bt541_ts_data *bt541) +static int zinitix_init_touch (struct bt541_ts_data *bt541) {struct i2c_client *client = bt541->client;int i;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 475/775 Input: st1232 - add IDLE state as ready condition
In reply to Greg Kroah-HartmanFrom: Michael Tretter <[email protected]>
[ Upstream commit 6524d8eac258452e547f8a49c8a965ac6dd8a161 ]
The st1232 can switch from NORMAL to IDLE state after the configured idle time (by default 8 s). If the st1232 is not reset during probe, it might already be ready but in IDLE state. Since it does not enter NORMAL state in this case, probe fails.
Fix the wait function to report the IDLE state as ready, too.
--- drivers/input/touchscreen/st1232.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/st1232.c +1 -1
@@ -94,7 +94,7 @@ static int st1232_ts_wait_ready(struct st1232_ts_data *ts)for (retries =10 ; retries; retries--) { error =st1232_ts_read_data (ts,REG_STATUS ,1 ); -if (!error && ts->read_buf[0 ] == (STATUS_NORMAL |ERROR_NONE )) +if (!error && ts->read_buf[0 ] == (STATUS_NORMAL |STATUS_IDLE |ERROR_NONE ))return 0 ;usleep_range (1000 ,2000 );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 476/775 ARM: 9065/1: OABI compat: fix build when EPOLL is not enabled
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit fd749fe4bcb00ad80d9eece709f804bb4ac6bf1e ]
When CONFIG_EPOLL is not set/enabled, sys_oabi-compat.c has build errors. Fix these by surrounding them with ifdef CONFIG_EPOLL/endif and providing stubs for the "EPOLL is not set" case.
../arch/arm/kernel/sys_oabi-compat.c: In function 'sys_oabi_epoll_ctl':../arch/arm/kernel/sys_oabi-compat.c:257:6: error: implicit declaration of function 'ep_op_has_event' [-Werror=implicit-function-declaration]
257 | if (ep_op_has_event(op) &&
| ^~~~~~~~~~~~~~~
../arch/arm/kernel/sys_oabi-compat.c:264:9: error: implicit declaration of function 'do_epoll_ctl'; did you mean 'sys_epoll_ctl'? [-Werror=implicit-function-declaration]
264 | return do_epoll_ctl(epfd, op, fd, &kernel, false);
| ^~~~~~~~~~~~--- arch/arm/kernel/sys_oabi-compat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm/kernel/sys_oabi-compat.c +15 -0
@@ -248,6 +248,7 @@ struct oabi_epoll_event {__u64 data; } __attribute__ ((packed,aligned(4))); +#ifdef CONFIG_EPOLL asmlinkage long sys_oabi_epoll_ctl (int epfd,int op,int fd,struct oabi_epoll_event __user *event) {
@@ -298,6 +299,20 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,kfree (kbuf);return err ? -EFAULT : ret; } +#else +asmlinkage long sys_oabi_epoll_ctl (int epfd,int op,int fd, +struct oabi_epoll_event __user *event) +{ +return -EINVAL ; +} + +asmlinkage long sys_oabi_epoll_wait (int epfd, +struct oabi_epoll_event __user *events, +int maxevents,int timeout) +{ +return -EINVAL ; +} +#endif struct oabi_sembuf {unsigned short sem_num;
Signature · 9 lines
2.27.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 477/775 Input: st1232 - fix NORMAL vs. IDLE state handling
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 1bff77f41a805b16b5355497c217656711601282 ]
NORMAL (0x0) and IDLE (0x4) are really two different states. Hence you cannot check for both using a bitmask, as that checks for IDLE only, breaking operation for devices that are in NORMAL state.
Fix the wait function to report either state as ready.
--- drivers/input/touchscreen/st1232.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/input/touchscreen/st1232.c +7 -2
@@ -94,8 +94,13 @@ static int st1232_ts_wait_ready(struct st1232_ts_data *ts)for (retries =10 ; retries; retries--) { error =st1232_ts_read_data (ts,REG_STATUS ,1 ); -if (!error && ts->read_buf[0 ] == (STATUS_NORMAL |STATUS_IDLE |ERROR_NONE )) -return 0 ; +if (!error) { +switch (ts->read_buf[0 ]) { +case STATUS_NORMAL |ERROR_NONE : +case STATUS_IDLE |ERROR_NONE : +return 0 ; + } + }usleep_range (1000 ,2000 ); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 478/775 misc: eeprom_93xx46: Fix module alias to enable module autoprobe
In reply to Greg Kroah-HartmanFrom: Aswath Govindraju <[email protected]>
[ Upstream commit 13613a2246bf531f5fc04e8e62e8f21a3d39bf1c ]
Fix module autoprobe by correcting module alias to match the string from /sys/class/.../spi1.0/modalias content.
--- drivers/misc/eeprom/eeprom_93xx46.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/eeprom/eeprom_93xx46.c +1 -1
@@ -511,4 +511,4 @@ module_spi_driver(eeprom_93xx46_driver);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Driver for 93xx46 EEPROMs" );MODULE_AUTHOR ("Anatolij Gustschin <[email protected]>" ); -MODULE_ALIAS ("spi:93xx46" ); +MODULE_ALIAS ("spi:eeprom-93xx46" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 479/775 phy: rockchip-emmc: emmc_phy_init() always return 0
In reply to Greg Kroah-HartmanFrom: Chris Ruehl <[email protected]>
[ Upstream commit 39961bd6b70e5a5d7c4b5483ad8e1db6b5765c60 ]
rockchip_emmc_phy_init() return variable is not set with the error value if clk_get() failed. 'emmcclk' is optional, thus use clk_get_optional() and if the return value != NULL make error processing and set the return code accordingly.
--- drivers/phy/rockchip/phy-rockchip-emmc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/phy/rockchip/phy-rockchip-emmc.c +5 -3
@@ -248,15 +248,17 @@ static int rockchip_emmc_phy_init(struct phy *phy)* - SDHCI driver to get the PHY * - SDHCI driver to init the PHY * -* The clock is optional, so upon any error we just set to NULL. +* The clock is optional, using clk_get_optional() to get the clock +* and do error processing if the return value != NULL * * NOTE: we don't do anything special for EPROBE_DEFER here. Given the * above expected use case, EPROBE_DEFER isn't sensible to expect, so * it's just like any other error. */ - rk_phy->emmcclk =clk_get (&phy->dev,"emmcclk" ); + rk_phy->emmcclk =clk_get_optional (&phy->dev,"emmcclk" );if (IS_ERR (rk_phy->emmcclk)) { -dev_dbg (&phy->dev,"Error getting emmcclk: %d\n" , ret); + ret =PTR_ERR (rk_phy->emmcclk); +dev_err (&phy->dev,"Error getting emmcclk: %d\n" , ret); rk_phy->emmcclk =NULL ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 480/775 phy: cadence-torrent: Fix error code in cdns_torrent_phy_probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 266df28f9ac16b0dff553d78bc3fb1c084b96b9d ]
This error path should return -EINVAL, but currently it returns success.
--- drivers/phy/cadence/phy-cadence-torrent.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/cadence/phy-cadence-torrent.c +1 -0
@@ -2298,6 +2298,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)if (total_num_lanes >MAX_NUM_LANES ) {dev_err (dev,"Invalid lane configuration\n" ); + ret = -EINVAL ; goto put_lnk_rst; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 481/775 misc: eeprom_93xx46: Add module alias to avoid breaking support for non device tree users
In reply to Greg Kroah-HartmanFrom: Aswath Govindraju <[email protected]>
[ Upstream commit 4540b9fbd8ebb21bb3735796d300a1589ee5fbf2 ]
Module alias "spi:93xx46" is used by non device tree users like drivers/misc/eeprom/digsy_mtc_eeprom.c and removing it will break support for them.
Fix this by adding back the module alias "spi:93xx46".
--- drivers/misc/eeprom/eeprom_93xx46.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/eeprom/eeprom_93xx46.c +1 -0
@@ -511,4 +511,5 @@ module_spi_driver(eeprom_93xx46_driver);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Driver for 93xx46 EEPROMs" );MODULE_AUTHOR ("Anatolij Gustschin <[email protected]>" ); +MODULE_ALIAS ("spi:93xx46" );MODULE_ALIAS ("spi:eeprom-93xx46" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 482/775 PCI: rcar: Always allocate MSI addresses in 32bit space
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit c4e0fec2f7ee013dbf86445394ff47f719408f99 ]
This fixes MSI operation on legacy PCI cards, which cannot issue 64bit MSIs. The R-Car controller only has one MSI trigger address instead of two, one for 64bit and one for 32bit MSI, set the address to 32bit PCIe space so that legacy PCI cards can also trigger MSIs.
--- drivers/pci/controller/pcie-rcar-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-rcar-host.c +1 -1
@@ -735,7 +735,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) }/* setup MSI data target */ - msi->pages =__get_free_pages (GFP_KERNEL ,0 ); + msi->pages =__get_free_pages (GFP_KERNEL |GFP_DMA32 ,0 );rcar_pcie_hw_enable_msi (host);return 0 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 483/775 soundwire: debugfs: use controller id instead of link_id
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 6d5e7af1f6f5924de5dd1ebe97675c2363100878 ]
link_id can be zero and if we have multiple controller instances in a system like Qualcomm debugfs will end-up with duplicate namespace resulting in incorrect debugfs entries.
Using id should give a unique debugfs directory entry and should fix below warning too.
"debugfs: Directory 'master-0' with parent 'soundwire' already present!"
--- drivers/soundwire/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soundwire/debugfs.c +1 -1
@@ -19,7 +19,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)return ;/* create the debugfs master-N */ -snprintf (name,sizeof (name),"master-%d" , bus->link_id); +snprintf (name,sizeof (name),"master-%d" , bus->id); bus->debugfs =debugfs_create_dir (name, sdw_debugfs_root); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 484/775 soundwire: cadence: fix ACK/NAK handling
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit db9d9f944f95e7f3aa60ac00cbd502415152c421 ]
The existing code reports a NAK only when ACK=0 This is not aligned with the SoundWire 1.x specifications.
Table 32 in the SoundWire 1.2 specification shows that a Device shall not set NAK=1 if ACK=1. But Table 33 shows the Combined Response may very well be NAK=1/ACK=1, e.g. if another Device than the one addressed reports a parity error.
NAK=1 signals a 'Command_Aborted', regardless of the ACK bit value.
Move the tests for NAK so that the NAK=1/ACK=1 combination is properly detected according to the specification.
--- drivers/soundwire/cadence_master.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soundwire/cadence_master.c +4 -4
@@ -484,10 +484,10 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns,if (!(cdns->response_buf[i] &CDNS_MCP_RESP_ACK )) { no_ack =1 ;dev_dbg_ratelimited (cdns->dev,"Msg Ack not received\n" ); -if (cdns->response_buf[i] &CDNS_MCP_RESP_NACK ) { - nack =1 ; -dev_err_ratelimited (cdns->dev,"Msg NACK received\n" ); - } + } +if (cdns->response_buf[i] &CDNS_MCP_RESP_NACK ) { + nack =1 ; +dev_err_ratelimited (cdns->dev,"Msg NACK received\n" ); } }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 485/775 pwm: rockchip: Enable APB clock during register access while probing
In reply to Greg Kroah-HartmanFrom: Simon South <[email protected]>
[ Upstream commit d9b657a5cdbd960de35dee7e06473caf44a9016f ]
Commit 457f74abbed0 ("pwm: rockchip: Keep enabled PWMs running while probing") modified rockchip_pwm_probe() to access a PWM device's registers directly to check whether or not the device is enabled, but did not also change the function so it first enables the device's APB clock to be certain the device can respond. This risks hanging the kernel on systems with PWM devices that use more than a single clock.
Avoid this by enabling the device's APB clock before accessing its registers (and disabling the clock when register access is complete).
--- drivers/pwm/pwm-rockchip.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pwm/pwm-rockchip.c +5 -3
@@ -330,9 +330,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev)return ret; } - ret =clk_prepare (pc->pclk); + ret =clk_prepare_enable (pc->pclk);if (ret) { -dev_err (&pdev->dev,"Can't prepare APB clk: %d\n" , ret); +dev_err (&pdev->dev,"Can't prepare enable APB clk: %d\n" , ret); goto err_clk; }
@@ -362,10 +362,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)if ((ctrl & enable_conf) != enable_conf)clk_disable (pc->clk); +clk_disable (pc->pclk); +return 0 ; err_pclk: -clk_unprepare (pc->pclk); +clk_disable_unprepare (pc->pclk); err_clk:clk_disable_unprepare (pc->clk);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 486/775 pwm: rockchip: rockchip_pwm_probe(): Remove superfluous clk_unprepare()
In reply to Greg Kroah-HartmanFrom: Simon South <[email protected]>
[ Upstream commit d5d8d675865ccddfe4da26c85f22c55cec663bf2 ]
If rockchip_pwm_probe() fails to register a PWM device it calls clk_unprepare() for the device's PWM clock, without having first disabled the clock and before jumping to an error handler that also unprepares it. This is likely to produce warnings from the kernel about the clock being unprepared when it is still enabled, and then being unprepared when it has already been unprepared.
Prevent these warnings by removing this unnecessary call to clk_unprepare().
--- drivers/pwm/pwm-rockchip.c | 1 - 1 file changed, 1 deletion(-)
drivers/pwm/pwm-rockchip.c +0 -1
@@ -351,7 +351,6 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ret =pwmchip_add (&pc->chip);if (ret <0 ) { -clk_unprepare (pc->clk);dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret); goto err_pclk; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 487/775 pwm: rockchip: Eliminate potential race condition when probing
In reply to Greg Kroah-HartmanFrom: Simon South <[email protected]>
[ Upstream commit d21ba5d6217bd5a6a696678385906ed1994b380b ]
Commit 48cf973cae33 ("pwm: rockchip: Avoid glitches on already running PWMs") introduced a potential race condition in rockchip_pwm_probe(): A consumer could enable an inactive PWM, or disable a running one, between rockchip_pwm_probe() registering the device via pwmchip_add() and checking whether it is enabled (to determine whether it was started by a bootloader). This could result in a device's PWM clock being either enabled once more than necessary, potentially causing it to continue running when no longer needed, or disabled once more than necessary, producing a warning from the kernel.
Eliminate these possibilities by modifying rockchip_pwm_probe() so it checks whether a device is enabled before registering it rather than after.
--- drivers/pwm/pwm-rockchip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pwm/pwm-rockchip.c +6 -3
@@ -288,6 +288,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)const struct of_device_id *id;struct rockchip_pwm_chip *pc;u32 enable_conf, ctrl; +bool enabled;int ret, count; id =of_match_device (rockchip_pwm_dt_ids, &pdev->dev);
@@ -349,6 +350,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev) pc->chip.of_pwm_n_cells =3 ; } + enable_conf = pc->data->enable_conf; + ctrl =readl_relaxed (pc->base + pc->data->regs.ctrl); + enabled = (ctrl & enable_conf) == enable_conf; + ret =pwmchip_add (&pc->chip);if (ret <0 ) {dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret);
@@ -356,9 +361,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) }/* Keep the PWM clk enabled if the PWM appears to be up and running. */ - enable_conf = pc->data->enable_conf; - ctrl =readl_relaxed (pc->base + pc->data->regs.ctrl); -if ((ctrl & enable_conf) != enable_conf) +if (!enabled)clk_disable (pc->clk);clk_disable (pc->pclk);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 488/775 PCI: xilinx-cpm: Fix reference count leak on error path
In reply to Greg Kroah-HartmanFrom: Pan Bian <[email protected]>
[ Upstream commit ae191d2e513ae5274224777ae67018a584074a28 ]
Also drop the reference count of the node on error path.
--- drivers/pci/controller/pcie-xilinx-cpm.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-xilinx-cpm.c +1 -0
@@ -404,6 +404,7 @@ static int xilinx_cpm_pcie_init_irq_domain(struct xilinx_cpm_pcie_port *port)return 0 ; out:xilinx_cpm_free_irq_domains (port); +of_node_put (pcie_intc_node);dev_err (dev,"Failed to allocate IRQ domains\n" );return -ENOMEM ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 489/775 VMCI: Use set_page_dirty_lock() when unregistering guest memory
In reply to Greg Kroah-HartmanFrom: Jorgen Hansen <[email protected]>
[ Upstream commit 5a16c535409f8dcb7568e20737309e3027ae3e49 ]
When the VMCI host support releases guest memory in the case where the VM was killed, the pinned guest pages aren't locked. Use set_page_dirty_lock() instead of set_page_dirty().
Testing done: Killed VM while having an active VMCI based vSocket connection and observed warning from ext4. With this fix, no warning was observed. Ran various vSocket tests without issues.
--- drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/vmw_vmci/vmci_queue_pair.c +1 -1
@@ -630,7 +630,7 @@ static void qp_release_pages(struct page **pages,for (i =0 ; i < num_pages; i++) {if (dirty) -set_page_dirty (pages[i]); +set_page_dirty_lock (pages[i]);put_page (pages[i]); pages[i] =NULL ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 490/775 PCI: Align checking of syscall user config accessors
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit ef9e4005cbaf022c6251263aa27836acccaef65d ]
After 34e3207205ef ("PCI: handle positive error codes"), pci_user_read_config_*() and pci_user_write_config_*() return 0 or negative errno values, not PCIBIOS_* values like PCIBIOS_SUCCESSFUL or PCIBIOS_BAD_REGISTER_NUMBER.
Remove comparisons with PCIBIOS_SUCCESSFUL and check only for non-zero. It happens that PCIBIOS_SUCCESSFUL is zero, so this is not a functional change, but it aligns this code with the user accessors.
--- drivers/pci/syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/syscall.c +5 -5
@@ -20,7 +20,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,u16 word;u32 dword;long err; -long cfg_ret; +int cfg_ret;if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -46,7 +46,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, } err = -EIO ; -if (cfg_ret !=PCIBIOS_SUCCESSFUL ) +if (cfg_ret) goto error;switch (len) {
@@ -105,7 +105,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_byte (dev, off, byte); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err) err = -EIO ;break ;
@@ -114,7 +114,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_word (dev, off, word); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err) err = -EIO ;break ;
@@ -123,7 +123,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_dword (dev, off, dword); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err) err = -EIO ;break ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 491/775 mei: hbm: call mei_set_devstate() on hbm stop response
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
[ Upstream commit 3a77df62deb2e62de0dc26c1cb763cc152329287 ]
Use mei_set_devstate() wrapper upon hbm stop command response, to trigger sysfs event.
--- drivers/misc/mei/hbm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hbm.c +1 -1
@@ -1373,7 +1373,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)return -EPROTO ; } - dev->dev_state =MEI_DEV_POWER_DOWN ; +mei_set_devstate (dev,MEI_DEV_POWER_DOWN );dev_info (dev->dev,"hbm: stop response: resetting.\n" );/* force the reset */ return -EPROTO ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 492/775 drm/msm: Fix MSM_INFO_GET_IOVA with carveout
In reply to Greg Kroah-HartmanFrom: Iskren Chernev <[email protected]>
[ Upstream commit 6cefa31e810404dafdfcdb94874146cea11626c2 ]
The msm_gem_get_iova should be guarded with gpu != NULL and not aspace != NULL, because aspace is NULL when using vram carveout.
--- drivers/gpu/drm/msm/msm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +2 -1
@@ -788,9 +788,10 @@ static int msm_ioctl_gem_info_iova(struct drm_device *dev, struct drm_file *file, struct drm_gem_object *obj, uint64_t *iova) { + struct msm_drm_private *priv = dev->dev_private;struct msm_file_private *ctx = file->driver_priv; -if (!ctx->aspace) +if (!priv->gpu)return -EINVAL ;/*
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 493/775 drm/msm: Add proper checks for GPU LLCC support
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 276619c0923f8fa6a82e60edb88a82468645362d ]
Domain attribute setting for LLCC is guarded by !IS_ERR check which works fine only when CONFIG_QCOM_LLCC=y but when it is disabled, the LLCC apis return NULL and that is not handled by IS_ERR check. Due to this, domain attribute for LLCC will be set even on GPUs which do not support it and cause issues, so correct this by using IS_ERR_OR_NULL checks appropriately. Meanwhile also cleanup comment block and remove unwanted blank line.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -1
@@ -1117,7 +1117,7 @@ static void a6xx_llc_slices_init(struct platform_device *pdev, a6xx_gpu->llc_slice =llcc_slice_getd (LLCC_GPU ); a6xx_gpu->htw_llc_slice =llcc_slice_getd (LLCC_GPUHTW ); -if (IS_ERR (a6xx_gpu->llc_slice) &&IS_ERR (a6xx_gpu->htw_llc_slice)) +if (IS_ERR_OR_NULL (a6xx_gpu->llc_slice) &&IS_ERR_OR_NULL (a6xx_gpu->htw_llc_slice)) a6xx_gpu->llc_mmio =ERR_PTR (-EINVAL ); }
drivers/gpu/drm/msm/adreno/adreno_gpu.c +5 -5
@@ -200,15 +200,15 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,if (!iommu)return NULL ; -if (adreno_is_a6xx (adreno_gpu)) {struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct io_pgtable_domain_attr pgtbl_cfg; +/* -* This allows GPU to set the bus attributes required to use system -* cache on behalf of the iommu page table walker. -*/ -if (!IS_ERR (a6xx_gpu->htw_llc_slice)) { +* This allows GPU to set the bus attributes required to use system +* cache on behalf of the iommu page table walker. +*/ +if (!IS_ERR_OR_NULL (a6xx_gpu->htw_llc_slice)) { pgtbl_cfg.quirks =IO_PGTABLE_QUIRK_ARM_OUTER_WBWA ;iommu_domain_set_attr (iommu,DOMAIN_ATTR_IO_PGTABLE_CFG , &pgtbl_cfg); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 494/775 drm/msm/dsi: Correct io_start for MSM8994 (20nm PHY)
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 33a7808ce1aea6e2edc1af25db25928137940c02 ]
The previous registers were *almost* correct, but instead of PHYs, they were pointing at DSI PLLs, resulting in the PHY id autodetection failing miserably.
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c +1 -1
@@ -139,7 +139,7 @@ const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs = { .disable = dsi_20nm_phy_disable, .init = msm_dsi_phy_init_common, }, - .io_start = { 0xfd998300, 0xfd9a0300 }, + .io_start = { 0xfd998500, 0xfd9a0500 }, .num_dsi_phy = 2, };
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 495/775 drm/msm/mdp5: Fix wait-for-commit for cmd panels
In reply to Greg Kroah-HartmanFrom: Iskren Chernev <[email protected]>
[ Upstream commit 68e4f01fddb4ead80e8c7084db489307f22c9cbb ]
Before the offending commit in msm_atomic_commit_tail wait_flush was called once per frame, after the commit was submitted. After it wait_flush is also called at the beginning to ensure previous potentially async commits are done.
For cmd panels the source of wait_flush is a ping-pong irq notifying a completion. The completion needs to be notified with complete_all so multiple waiting parties (new async committers) can proceed.
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +1 -1
@@ -1180,7 +1180,7 @@ static void mdp5_crtc_pp_done_irq(struct mdp_irq *irq, uint32_t irqstatus) struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, pp_done); -complete (&mdp5_crtc->pp_completion); +complete_all (&mdp5_crtc->pp_completion); }static void mdp5_crtc_wait_for_pp_done (struct drm_crtc *crtc)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 496/775 drm/msm: Fix race of GPU init vs timestamp power management.
In reply to Greg Kroah-HartmanFrom: Eric Anholt <[email protected]>
[ Upstream commit 7a7cbf2a819740674455ad36155c662367261296 ]
We were using the same force-poweron bit in the two codepaths, so they could race to have one of them lose GPU power early.
freedreno CI was seeing intermittent errors like:
[drm:_a6xx_gmu_set_oob] *ERROR* Timeout waiting for GMU OOB set GPU_SET: 0x0 and this issue could have contributed to it.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 25 ++++++++++++++++++++++--- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 8 ++++++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++-- 3 files changed, 32 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +22 -3
@@ -264,6 +264,16 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) } name ="GPU_SET" ;break ; +case GMU_OOB_PERFCOUNTER_SET : +if (gmu->legacy) { + request =GMU_OOB_PERFCOUNTER_REQUEST ; + ack =GMU_OOB_PERFCOUNTER_ACK ; + }else { + request =GMU_OOB_PERFCOUNTER_REQUEST_NEW ; + ack =GMU_OOB_PERFCOUNTER_ACK_NEW ; + } + name ="PERFCOUNTER" ; +break ;case GMU_OOB_BOOT_SLUMBER : request =GMU_OOB_BOOT_SLUMBER_REQUEST ; ack =GMU_OOB_BOOT_SLUMBER_ACK ;
@@ -301,9 +311,14 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)void a6xx_gmu_clear_oob (struct a6xx_gmu *gmu,enum a6xx_gmu_oob_state state) {if (!gmu->legacy) { -WARN_ON (state !=GMU_OOB_GPU_SET ); -gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET , -1 <<GMU_OOB_GPU_SET_CLEAR_NEW ); +if (state ==GMU_OOB_GPU_SET ) { +gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET , +1 <<GMU_OOB_GPU_SET_CLEAR_NEW ); + }else { +WARN_ON (state !=GMU_OOB_PERFCOUNTER_SET ); +gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET , +1 <<GMU_OOB_PERFCOUNTER_CLEAR_NEW ); + }return ; }
@@ -312,6 +327,10 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET ,1 <<GMU_OOB_GPU_SET_CLEAR );break ; +case GMU_OOB_PERFCOUNTER_SET : +gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET , +1 <<GMU_OOB_PERFCOUNTER_CLEAR ); +break ;case GMU_OOB_BOOT_SLUMBER :gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET ,1 <<GMU_OOB_BOOT_SLUMBER_CLEAR );
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +8 -0
@@ -156,6 +156,7 @@ enum a6xx_gmu_oob_state {GMU_OOB_BOOT_SLUMBER =0 ,GMU_OOB_GPU_SET ,GMU_OOB_DCVS_SET , + GMU_OOB_PERFCOUNTER_SET, };/* These are the interrupt / ack bits for each OOB request that are set
@@ -190,6 +191,13 @@ enum a6xx_gmu_oob_state {#define GMU_OOB_GPU_SET_ACK_NEW 31#define GMU_OOB_GPU_SET_CLEAR_NEW 31 +#define GMU_OOB_PERFCOUNTER_REQUEST 17 +#define GMU_OOB_PERFCOUNTER_ACK 25 +#define GMU_OOB_PERFCOUNTER_CLEAR 25 + +#define GMU_OOB_PERFCOUNTER_REQUEST_NEW 28 +#define GMU_OOB_PERFCOUNTER_ACK_NEW 30 +#define GMU_OOB_PERFCOUNTER_CLEAR_NEW 30void a6xx_hfi_init (struct a6xx_gmu *gmu);int a6xx_hfi_start (struct a6xx_gmu *gmu,int boot_state);
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -2
@@ -1171,12 +1171,12 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);/* Force the GPU power on so we can read this register */ -a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); +a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); *value =gpu_read64 (gpu,REG_A6XX_RBBM_PERFCTR_CP_0_LO ,REG_A6XX_RBBM_PERFCTR_CP_0_HI ); -a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); +a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET );return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 497/775 drm/msm: Fix races managing the OOB state for timestamp vs timestamps.
In reply to Greg Kroah-HartmanFrom: Eric Anholt <[email protected]>
[ Upstream commit 5f98b33b04c02c0d9088c7486c59d058696782f9 ]
Now that we're not racing with GPU setup, also fix races of timestamps against other timestamps. In freedreno CI, we were seeing this path trigger timeouts on setting the GMU bit, producing:
[drm:_a6xx_gmu_set_oob] *ERROR* Timeout waiting for GMU OOB set GPU_SET: 0x0
and this triggered especially on the first set of tests right after boot (it's probably easier to lose the race than one might think, given that we start many tests in parallel, and waiting for NFS to page in code probably means that lots of tests hit the same point of screen init at the same time). As of this patch, the message seems to have completely gone away.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4 -0
@@ -1169,6 +1169,9 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +static DEFINE_MUTEX (perfcounter_oob); + +mutex_lock (&perfcounter_oob);/* Force the GPU power on so we can read this register */ a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET );
@@ -1177,6 +1180,7 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) REG_A6XX_RBBM_PERFCTR_CP_0_HI);a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); +mutex_unlock (&perfcounter_oob);return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 498/775 drm/msm/kms: Make a lock_class_key for each crtc mutex
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit 6ec9351809612fa1c0256fb3e39b49b6100e2983 ]
Lockdep complains about an AA deadlock when rebooting the device.
base-commit: 19c329f6808995b142b3966301f217c831e7cf31
============================================
WARNING: possible recursive locking detected
5.4.91 #1 Not tainted
--------------------------------------------
reboot/5213 is trying to acquire lock:ffffff80d13391b0 (&kms->commit_lock[i]){+.+.}, at: lock_crtcs+0x60/0xa4
but task is already holding lock:ffffff80d1339110 (&kms->commit_lock[i]){+.+.}, at: lock_crtcs+0x60/0xa4
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----lock(&kms->commit_lock[i]);lock(&kms->commit_lock[i]);
*** DEADLOCK ***
May be due to missing lock nesting notation
6 locks held by reboot/5213:
__arm64_sys_reboot+0x148/0x2a0 device_shutdown+0x10c/0x2c4 drm_atomic_helper_shutdown+0x48/0xfc modeset_lock+0x120/0x24c lock_crtcs+0x60/0xa4 stack backtrace: CPU: 4 PID: 5213 Comm: reboot Not tainted 5.4.91 #1 Hardware name: Google Pompom (rev1) with LTE (DT) Call trace: dump_backtrace+0x0/0x1dc show_stack+0x24/0x30 dump_stack+0xfc/0x1a8 __lock_acquire+0xcd0/0x22b8 lock_acquire+0x1ec/0x240 __mutex_lock_common+0xe0/0xc84 mutex_lock_nested+0x48/0x58 lock_crtcs+0x60/0xa4 msm_atomic_commit_tail+0x348/0x570 commit_tail+0xdc/0x178 drm_atomic_helper_commit+0x160/0x168 drm_atomic_commit+0x68/0x80
This is because lockdep thinks all the locks taken in lock_crtcs() are the same lock, when they actually aren't. That's because we call mutex_init() in msm_kms_init() and that assigns one static key for every lock initialized in this loop. Let's allocate a dynamic number of lock_class_keys and assign them to each lock so that lockdep can figure out an AA deadlock isn't possible here.
--- drivers/gpu/drm/msm/msm_kms.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_kms.h +6 -2
@@ -157,6 +157,7 @@ struct msm_kms {* from the crtc's pending_timer close to end of the frame: */ struct mutex commit_lock[MAX_CRTCS ]; +struct lock_class_key commit_lock_keys[MAX_CRTCS ];unsigned pending_crtc_mask;struct msm_pending_timer pending_timers[MAX_CRTCS ]; };
@@ -166,8 +167,11 @@ static inline int msm_kms_init(struct msm_kms *kms, {unsigned i, ret; -for (i =0 ; i <ARRAY_SIZE (kms->commit_lock); i++) -mutex_init (&kms->commit_lock[i]); +for (i =0 ; i <ARRAY_SIZE (kms->commit_lock); i++) { +lockdep_register_key (&kms->commit_lock_keys[i]); +__mutex_init (&kms->commit_lock[i],"&kms->commit_lock[i]" , + &kms->commit_lock_keys[i]); + } kms->funcs = funcs;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 499/775 drm/msm/dp: trigger unplug event in msm_dp_display_disable
In reply to Greg Kroah-HartmanFrom: Judy Hsiao <[email protected]>
[ Upstream commit c703d5789590935c573bbd080a2166b72d51a017 ]
1. Trigger the unplug event in msm_dp_display_disable() to shutdown audio properly.
2. Reset the completion before signal the disconnect event.
--- drivers/gpu/drm/msm/dp/dp_display.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +4 -1
@@ -651,8 +651,8 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)dp_add_event (dp,EV_DISCONNECT_PENDING_TIMEOUT ,0 ,DP_TIMEOUT_5_SECOND );/* signal the disconnect event early to ensure proper teardown */ -dp_display_handle_plugged_change (g_dp_display, false);reinit_completion (&dp->audio_comp); +dp_display_handle_plugged_change (g_dp_display, false);dp_catalog_hpd_config_intr (dp->catalog,DP_DP_HPD_PLUG_INT_MASK |DP_DP_IRQ_HPD_INT_MASK , true);
@@ -890,6 +890,9 @@ static int dp_display_disable(struct dp_display_private *dp, u32 data)/* wait only if audio was enabled */ if (dp_display->audio_enabled) { +/* signal the disconnect event */ +reinit_completion (&dp->audio_comp); +dp_display_handle_plugged_change (dp_display, false);if (!wait_for_completion_timeout (&dp->audio_comp,HZ *5 ))DRM_ERROR ("audio comp timeout\n" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 500/775 vfio/iommu_type1: Populate full dirty when detach non-pinned group
In reply to Greg Kroah-HartmanFrom: Keqian Zhu <[email protected]>
[ Upstream commit d0a78f91761fcd837da1e7a4b0f8368873adc646 ]
If a group with non-pinned-page dirty scope is detached with dirty logging enabled, we should fully populate the dirty bitmaps at the time it's removed since we don't know the extent of its previous DMA, nor will the group be present to trigger the full bitmap when the user retrieves the dirty bitmap.
--- drivers/vfio/vfio_iommu_type1.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/vfio/vfio_iommu_type1.c +16 -1
@@ -236,6 +236,18 @@ static void vfio_dma_populate_bitmap(struct vfio_dma *dma, size_t pgsize) } } +static void vfio_iommu_populate_bitmap_full (struct vfio_iommu *iommu) +{ +struct rb_node *n; +unsigned long pgshift =__ffs (iommu->pgsize_bitmap); + +for (n =rb_first (&iommu->dma_list); n; n =rb_next (n)) { + struct vfio_dma *dma = rb_entry(n, struct vfio_dma, node); + +bitmap_set (dma->bitmap,0 , dma->size >> pgshift); + } +} +static int vfio_dma_bitmap_alloc_all (struct vfio_iommu *iommu,size_t pgsize) {struct rb_node *n;
@@ -2415,8 +2427,11 @@ detach_group_done:* Removal of a group without dirty tracking may allow the iommu scope * to be promoted. */ -if (update_dirty_scope) +if (update_dirty_scope) {update_pinned_page_dirty_scope (iommu); +if (iommu->dirty_page_tracking) +vfio_iommu_populate_bitmap_full (iommu); + }mutex_unlock (&iommu->lock); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 501/775 vfio/iommu_type1: Fix some sanity checks in detach group
In reply to Greg Kroah-HartmanFrom: Keqian Zhu <[email protected]>
[ Upstream commit 4a19f37a3dd3f29997735e61b25ddad24b8abe73 ]
vfio_sanity_check_pfn_list() is used to check whether pfn_list and notifier are empty when remove the external domain, so it makes a wrong assumption that only external domain will use the pinning interface.
Now we apply the pfn_list check when a vfio_dma is removed and apply the notifier check when all domains are removed.
--- drivers/vfio/vfio_iommu_type1.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
drivers/vfio/vfio_iommu_type1.c +8 -23
@@ -957,6 +957,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,static void vfio_remove_dma (struct vfio_iommu *iommu,struct vfio_dma *dma) { +WARN_ON (!RB_EMPTY_ROOT (&dma->pfn_list));vfio_unmap_unpin (iommu, dma, true);vfio_unlink_dma (iommu, dma);put_task_struct (dma->task);
@@ -2250,23 +2251,6 @@ static void vfio_iommu_unmap_unpin_reaccount(struct vfio_iommu *iommu) } } -static void vfio_sanity_check_pfn_list (struct vfio_iommu *iommu) -{ -struct rb_node *n; - - n =rb_first (&iommu->dma_list); -for (; n; n =rb_next (n)) { -struct vfio_dma *dma; - - dma = rb_entry(n, struct vfio_dma, node); - -if (WARN_ON (!RB_EMPTY_ROOT (&dma->pfn_list))) -break ; - } -/* mdev vendor driver must unregister notifier */ -WARN_ON (iommu->notifier.head); -} -/* * Called when a domain is removed in detach. It is possible that * the removed domain decided the iova aperture window. Modify the
@@ -2366,10 +2350,10 @@ static void vfio_iommu_type1_detach_group(void *iommu_data,kfree (group);if (list_empty (&iommu->external_domain->group_list)) { -vfio_sanity_check_pfn_list (iommu); - -if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER (iommu)) +if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER (iommu)) { +WARN_ON (iommu->notifier.head);vfio_iommu_unmap_unpin_all (iommu); + }kfree (iommu->external_domain); iommu->external_domain =NULL ;
@@ -2403,10 +2387,12 @@ static void vfio_iommu_type1_detach_group(void *iommu_data,*/ if (list_empty (&domain->group_list)) {if (list_is_singular (&iommu->domain_list)) { -if (!iommu->external_domain) +if (!iommu->external_domain) { +WARN_ON (iommu->notifier.head);vfio_iommu_unmap_unpin_all (iommu); -else + }else {vfio_iommu_unmap_unpin_reaccount (iommu); + } }iommu_domain_free (domain->domain);list_del (&domain->next);
@@ -2490,7 +2476,6 @@ static void vfio_iommu_type1_release(void *iommu_data)if (iommu->external_domain) {vfio_release_domain (iommu->external_domain, true); -vfio_sanity_check_pfn_list (iommu);kfree (iommu->external_domain); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 502/775 vfio-pci/zdev: fix possible segmentation fault issue
In reply to Greg Kroah-HartmanFrom: Max Gurtovoy <[email protected]>
[ Upstream commit 7e31d6dc2c78b2a0ba0039ca97ca98a581e8db82 ]
In case allocation fails, we must behave correctly and exit with error.
--- drivers/vfio/pci/vfio_pci_zdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/vfio/pci/vfio_pci_zdev.c +4 -0
@@ -74,6 +74,8 @@ static int zpci_util_cap(struct zpci_dev *zdev, struct vfio_pci_device *vdev,int ret; cap =kmalloc (cap_size,GFP_KERNEL ); +if (!cap) +return -ENOMEM ; cap->header.id =VFIO_DEVICE_INFO_CAP_ZPCI_UTIL ; cap->header.version =1 ;
@@ -98,6 +100,8 @@ static int zpci_pfip_cap(struct zpci_dev *zdev, struct vfio_pci_device *vdev,int ret; cap =kmalloc (cap_size,GFP_KERNEL ); +if (!cap) +return -ENOMEM ; cap->header.id =VFIO_DEVICE_INFO_CAP_ZPCI_PFIP ; cap->header.version =1 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 503/775 ext4: fix potential htree index checksum corruption
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
[ Upstream commit b5776e7524afbd4569978ff790864755c438bba7 ]
In the case where we need to do an interior node split, and immediately afterwards, we are unable to allocate a new directory leaf block due to ENOSPC, the directory index checksum's will not be filled in correctly (and indeed, will not be correctly journalled).
This looks like a bug that was introduced when we added largedir support. The original code doesn't make any sense (and should have been caught in code review), but it was hidden because most of the time, the index node checksum will be set by do_split(). But if do_split bails out due to ENOSPC, then ext4_handle_dirty_dx_node() won't get called, and so the directory index checksum field will not get set, leading to:
EXT4-fs error (device sdb): dx_probe:858: inode #6635543: block 4022: comm nfsd: Directory index failed checksum
Google-Bug-Id: 176345532
--- fs/ext4/namei.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ext4/namei.c +3 -4
@@ -2401,11 +2401,10 @@ again: (frame - 1)->bh);if (err) goto journal_error; -if (restart) { - err =ext4_handle_dirty_dx_node (handle, dir, - frame->bh); + err =ext4_handle_dirty_dx_node (handle, dir, + frame->bh); +if (err) goto journal_error; - } }else {struct dx_root *dxroot; memcpy((char *) entries2, (char *) entries,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 504/775 phy: USB_LGM_PHY should depend on X86
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 6b46e60a6943d629d69924be3169d8f214624ab2 ]
The Intel Lightning Mountain (LGM) USB3 USB is only present on Intel Lightning Mountain SoCs. Hence add a dependency on X86, to prevent asking the user about this driver when configuring a kernel without Intel Lightning Mountain platform support.
--- drivers/phy/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/phy/Kconfig +1 -0
@@ -52,6 +52,7 @@ config PHY_XGENE config USB_LGM_PHY tristate "INTEL Lightning Mountain USB PHY Driver" depends on USB_SUPPORT + depends on X86 || COMPILE_TEST select USB_PHY select REGULATOR select REGULATOR_FIXED_VOLTAGE
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 505/775 coresight: etm4x: Skip accessing TRCPDCR in save/restore
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
[ Upstream commit df81b43802f43c0954a55e5d513e8750a1ab4d31 ]
When the ETM is affected by Qualcomm errata, modifying the TRCPDCR could cause the system hang. Even though this is taken care of during enable/disable ETM, the ETM state save/restore could still access the TRCPDCR. Make sure we skip the access during the save/restore.
Found by code inspection.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +7 -5
@@ -1355,7 +1355,8 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) state->trcclaimset =readl (drvdata->base +TRCCLAIMCLR ); - state->trcpdcr =readl (drvdata->base +TRCPDCR ); +if (!drvdata->skip_power_up) + state->trcpdcr =readl (drvdata->base +TRCPDCR );/* wait for TRCSTATR.IDLE to go up */ if (coresight_timeout (drvdata->base,TRCSTATR ,TRCSTATR_IDLE_BIT ,1 )) {
@@ -1373,9 +1374,9 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)* potentially save power on systems that respect the TRCPDCR_PU * despite requesting software to save/restore state. */ -writel_relaxed ((state->trcpdcr & ~TRCPDCR_PU ), - drvdata->base +TRCPDCR ); - +if (!drvdata->skip_power_up) +writel_relaxed ((state->trcpdcr & ~TRCPDCR_PU ), + drvdata->base +TRCPDCR ); out:CS_LOCK (drvdata->base);return ret;
@@ -1469,7 +1470,8 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)writel_relaxed (state->trcclaimset, drvdata->base +TRCCLAIMSET ); -writel_relaxed (state->trcpdcr, drvdata->base +TRCPDCR ); +if (!drvdata->skip_power_up) +writel_relaxed (state->trcpdcr, drvdata->base +TRCPDCR ); drvdata->state_needs_restore = false;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 506/775 nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 72e008ce307fa2f35f6783997378b32e83122839 ]
This doesn't call of_node_put() on the error path so it leads to a memory leak.
--- drivers/nvmem/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/core.c +1 -0
@@ -713,6 +713,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) cell->name, nvmem->stride);/* Cells already added will be freed later. */ kfree_const (cell->name); +of_node_put (cell->np);kfree (cell);return -EINVAL ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 507/775 nvmem: core: skip child nodes not matching binding
In reply to Greg Kroah-HartmanFrom: Ahmad Fatoum <[email protected]>
[ Upstream commit 0445efacec75b85c2a3c176957ee050ba9be53f0 ]
The nvmem cell binding applies to all eeprom child nodes matching "^.*@[0-9a-f]+$" without taking a compatible into account.
Linux drivers, like at24, are even more extensive and assume _all_ at24 eeprom child nodes to be nvmem cells since e888d445ac33 ("nvmem: resolve cells from DT at registration time").
Since df5f3b6f5357 ("dt-bindings: nvmem: stm32: new property for data access"), the additionalProperties: True means it's Ok to have other properties as long as they don't match "^.*@[0-9a-f]+$".
The barebox bootloader extends the MTD partitions binding to EEPROM and can fix up following device tree node:
&eeprom {
partitions {
compatible = "fixed-partitions";
};
};This is allowed binding-wise, but drivers using nvmem_register() like at24 will fail to parse because the function expects all child nodes to have a reg property present. This results in the whole EEPROM driver probe failing despite the device tree being correct.
Fix this by skipping nodes lacking a reg property instead of returning an error. This effectively makes the drivers adhere to the binding because all nodes with a unit address must have a reg property and vice versa.
--- drivers/nvmem/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvmem/core.c +3 -1
@@ -682,7 +682,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)for_each_child_of_node (parent, child) { addr =of_get_property (child,"reg" , &len); -if (!addr || (len <2 *sizeof (u32))) { +if (!addr) +continue ; +if (len <2 *sizeof (u32)) {dev_err (dev,"nvmem: invalid reg on %pOF\n" , child);return -EINVAL ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 508/775 drm/msm: Fix legacy relocs path
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit c8d99bb938d3303989c4988caf090084073e85a2 ]
In moving code around, we ended up using the same pointer to copy_from_user() the relocs tables as we used for the cmd table entry, which is clearly not right. This went unnoticed because modern mesa on non-ancent kernels does not actually use relocs. But this broke ancient mesa on modern kernels.
--- drivers/gpu/drm/msm/msm_gem_submit.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +2 -0
@@ -198,6 +198,8 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, submit->cmd[i].idx = submit_cmd.submit_idx; submit->cmd[i].nr_relocs = submit_cmd.nr_relocs; + userptr =u64_to_user_ptr (submit_cmd.relocs); + sz =array_size (submit_cmd.nr_relocs,sizeof (struct drm_msm_gem_submit_reloc ));/* check for overflow: */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 509/775 soundwire: bus: use sdw_update_no_pm when initializing a device
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit b04c975e654cfdea6d691cd403b5a81cce7e593d ]
When a Slave device is resumed, it may resume the bus and restart the enumeration. During that process, we absolutely don't want to call regular read/write routines which will wait for the resume to complete, otherwise a deadlock occurs.
--- drivers/soundwire/bus.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/soundwire/bus.c +14 -2
@@ -489,6 +489,18 @@ sdw_read_no_pm(struct sdw_slave *slave, u32 addr)return buf; } +static int sdw_update_no_pm (struct sdw_slave *slave,u32 addr,u8 mask,u8 val) +{ +int tmp; + + tmp =sdw_read_no_pm (slave, addr); +if (tmp <0 ) +return tmp; + + tmp = (tmp & ~mask) | val; +return sdw_write_no_pm (slave, addr, tmp); +} +/** * sdw_nread() - Read "n" contiguous SDW Slave registers * @slave: SDW Slave
@@ -1256,7 +1268,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave) val = slave->prop.scp_int1_mask;/* Enable SCP interrupts */ - ret =sdw_update (slave,SDW_SCP_INTMASK1 , val, val); + ret =sdw_update_no_pm (slave,SDW_SCP_INTMASK1 , val, val);if (ret <0 ) {dev_err (slave->bus->dev,"SDW_SCP_INTMASK1 write failed:%d\n" , ret);
@@ -1271,7 +1283,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave) val = prop->dp0_prop->imp_def_interrupts; val |=SDW_DP0_INT_PORT_READY |SDW_DP0_INT_BRA_FAILURE ; - ret =sdw_update (slave,SDW_DP0_INTMASK , val, val); + ret =sdw_update_no_pm (slave,SDW_DP0_INTMASK , val, val);if (ret <0 )dev_err (slave->bus->dev,"SDW_DP0_INTMASK read failed:%d\n" , ret);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 510/775 soundwire: bus: use sdw_write_no_pm when setting the bus scale registers
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 299e9780b9196bcb15b26dfdccd3244eb072d560 ]
When a Slave device is resumed, it may resume the bus and restart the enumeration. During that process, we absolutely don't want to call regular read/write routines which will wait for the resume to complete, otherwise a deadlock occurs.
This patch fixes the same problem as the previous one, but is split to make the life of linux-stable maintainers less painful.
--- drivers/soundwire/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/soundwire/bus.c +3 -3
@@ -1222,7 +1222,7 @@ static int sdw_slave_set_frequency(struct sdw_slave *slave) } scale_index++; - ret =sdw_write (slave,SDW_SCP_BUS_CLOCK_BASE , base); + ret =sdw_write_no_pm (slave,SDW_SCP_BUS_CLOCK_BASE , base);if (ret <0 ) {dev_err (&slave->dev,"SDW_SCP_BUS_CLOCK_BASE write failed:%d\n" , ret);
@@ -1230,13 +1230,13 @@ static int sdw_slave_set_frequency(struct sdw_slave *slave) }/* initialize scale for both banks */ - ret =sdw_write (slave,SDW_SCP_BUSCLOCK_SCALE_B0 , scale_index); + ret =sdw_write_no_pm (slave,SDW_SCP_BUSCLOCK_SCALE_B0 , scale_index);if (ret <0 ) {dev_err (&slave->dev,"SDW_SCP_BUSCLOCK_SCALE_B0 write failed:%d\n" , ret);return ret; } - ret =sdw_write (slave,SDW_SCP_BUSCLOCK_SCALE_B1 , scale_index); + ret =sdw_write_no_pm (slave,SDW_SCP_BUSCLOCK_SCALE_B1 , scale_index);if (ret <0 )dev_err (&slave->dev,"SDW_SCP_BUSCLOCK_SCALE_B1 write failed:%d\n" , ret);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 511/775 soundwire: export sdw_write/read_no_pm functions
In reply to Greg Kroah-HartmanFrom: Bard Liao <[email protected]>
[ Upstream commit 167790abb90fa073d8341ee0e408ccad3d2109cd ]
sdw_write_no_pm and sdw_read_no_pm are useful when we want to do IO without touching PM.
--- drivers/soundwire/bus.c | 7 ++++--- include/linux/soundwire/sdw.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/soundwire/bus.c +4 -3
@@ -405,10 +405,11 @@ sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)return sdw_transfer (slave->bus, &msg); } -static int sdw_write_no_pm (struct sdw_slave *slave,u32 addr,u8 value) +int sdw_write_no_pm (struct sdw_slave *slave,u32 addr,u8 value) {return sdw_nwrite_no_pm (slave, addr,1 , &value); } +EXPORT_SYMBOL (sdw_write_no_pm);static int sdw_bread_no_pm (struct sdw_bus *bus,u16 dev_num,u32 addr)
@@ -476,8 +477,7 @@ int sdw_bwrite_no_pm_unlocked(struct sdw_bus *bus, u16 dev_num, u32 addr, u8 val }EXPORT_SYMBOL (sdw_bwrite_no_pm_unlocked); -static int -sdw_read_no_pm (struct sdw_slave *slave,u32 addr) +int sdw_read_no_pm (struct sdw_slave *slave,u32 addr) {u8 buf;int ret;
@@ -488,6 +488,7 @@ sdw_read_no_pm(struct sdw_slave *slave, u32 addr)else return buf; } +EXPORT_SYMBOL (sdw_read_no_pm);static int sdw_update_no_pm (struct sdw_slave *slave,u32 addr,u8 mask,u8 val) {
include/linux/soundwire/sdw.h +2 -0
@@ -1005,6 +1005,8 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus);int sdw_read (struct sdw_slave *slave,u32 addr);int sdw_write (struct sdw_slave *slave,u32 addr,u8 value); +int sdw_write_no_pm (struct sdw_slave *slave,u32 addr,u8 value); +int sdw_read_no_pm (struct sdw_slave *slave,u32 addr);int sdw_nread (struct sdw_slave *slave,u32 addr,size_t count,u8 *val);int sdw_nwrite (struct sdw_slave *slave,u32 addr,size_t count,u8 *val);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 512/775 soundwire: bus: fix confusion on device used by pm_runtime
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 973794e85610d9a716a897baa9007ff56e192826 ]
Intel stress-tests routinely report IO timeouts and invalid power management transitions. Upon further analysis, we seem to be using the wrong devices in pm_runtime calls.
Before reading and writing registers, we first need to make sure the Slave is fully resumed. The existing code attempts to do such that, however because of a confusion dating from 2017 and copy/paste, we end-up resuming the parent only instead of resuming the codec device.
This can lead to accesses to the Slave registers while the bus is still being configured and the Slave not enumerated, and as a result IO errors occur.
This is a classic problem, similar confusions happened for HDaudio between bus and codec device, leading to power management issues.
Fix by using the relevant device for all uses of pm_runtime functions.
--- drivers/soundwire/bus.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/soundwire/bus.c +9 -9
@@ -513,16 +513,16 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) {int ret; - ret =pm_runtime_get_sync (slave->bus->dev); + ret =pm_runtime_get_sync (&slave->dev);if (ret <0 && ret != -EACCES ) { -pm_runtime_put_noidle (slave->bus->dev); +pm_runtime_put_noidle (&slave->dev);return ret; } ret =sdw_nread_no_pm (slave, addr, count, val); -pm_runtime_mark_last_busy (slave->bus->dev); -pm_runtime_put (slave->bus->dev); +pm_runtime_mark_last_busy (&slave->dev); +pm_runtime_put (&slave->dev);return ret; }
@@ -539,16 +539,16 @@ int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) {int ret; - ret =pm_runtime_get_sync (slave->bus->dev); + ret =pm_runtime_get_sync (&slave->dev);if (ret <0 && ret != -EACCES ) { -pm_runtime_put_noidle (slave->bus->dev); +pm_runtime_put_noidle (&slave->dev);return ret; } ret =sdw_nwrite_no_pm (slave, addr, count, val); -pm_runtime_mark_last_busy (slave->bus->dev); -pm_runtime_put (slave->bus->dev); +pm_runtime_mark_last_busy (&slave->dev); +pm_runtime_put (&slave->dev);return ret; }
@@ -1453,7 +1453,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) ret =pm_runtime_get_sync (&slave->dev);if (ret <0 && ret != -EACCES ) {dev_err (&slave->dev,"Failed to resume device: %d\n" , ret); -pm_runtime_put_noidle (slave->bus->dev); +pm_runtime_put_noidle (&slave->dev);return ret; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 513/775 drm/msm/dp: Add a missing semi-colon
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit 182b4a2d251305201b6f9cae29067f7112f05835 ]
A missing semicolon here causes my external display to stop working. Indeed, missing the semicolon on the return statement leads to dp_panel_update_tu_timings() not existing because the compiler thinks it's part of the return statement of a void function, so it must not be important.
$ ./scripts/bloat-o-meter before.o after.o add/remove: 1/1 grow/shrink: 0/1 up/down: 7400/-7540 (-140) Function old new delta dp_panel_update_tu_timings - 7400 +7400 _dp_ctrl_calc_tu.constprop 18024 17900 -124 dp_panel_update_tu_timings.constprop 7416 - -7416 Total: Before=54440, After=54300, chg -0.26%
Add a semicolon so this function works like it used to.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +1 -1
@@ -631,7 +631,7 @@ static void _dp_ctrl_calc_tu(struct dp_tu_calc_input *in, tu =kzalloc (sizeof (*tu),GFP_KERNEL );if (!tu) -return +return ;dp_panel_update_tu_timings (in, tu);
Signature · 8 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Greg Kroah-Hartman
maintainerPATCH 514/775 misc: fastrpc: fix incorrect usage of dma_map_sgtable
In reply to Greg Kroah-HartmanFrom: Jonathan Marek <[email protected]>
[ Upstream commit b212658aebda82f92967bcbd4c7380d607c3d803 ]
dma_map_sgtable() returns 0 on success, which is the opposite of what this code was doing.
--- drivers/misc/fastrpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/fastrpc.c +4 -3
@@ -520,12 +520,13 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment, {struct fastrpc_dma_buf_attachment *a = attachment->priv;struct sg_table *table; +int ret; table = &a->sgt; -if (!dma_map_sgtable (attachment->dev, table, dir,0 )) -return ERR_PTR (-ENOMEM ); - + ret =dma_map_sgtable (attachment->dev, table, dir,0 ); +if (ret) + table =ERR_PTR (ret);return table; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 515/775 remoteproc/mediatek: acknowledge watchdog IRQ after handled
In reply to Greg Kroah-HartmanFrom: Tzung-Bi Shih <[email protected]>
[ Upstream commit 8c545f52dce44368fff524e13116e696e005c074 ]
Acknowledges watchdog IRQ after handled or kernel keeps receiving the interrupt.
--- drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/remoteproc/mtk_common.h +1 -0
@@ -47,6 +47,7 @@#define MT8192_CORE0_SW_RSTN_CLR 0x10000#define MT8192_CORE0_SW_RSTN_SET 0x10004 +#define MT8192_CORE0_WDT_IRQ 0x10030#define MT8192_CORE0_WDT_CFG 0x10034#define SCP_FW_VER_LEN 32
drivers/remoteproc/mtk_scp.c +11 -9
@@ -197,17 +197,19 @@ static void mt8192_scp_irq_handler(struct mtk_scp *scp) scp_to_host =readl (scp->reg_base +MT8192_SCP2APMCU_IPC_SET ); -if (scp_to_host &MT8192_SCP_IPC_INT_BIT ) +if (scp_to_host &MT8192_SCP_IPC_INT_BIT ) {scp_ipi_handler (scp); -else -scp_wdt_handler (scp, scp_to_host); -/* -* SCP won't send another interrupt until we clear -* MT8192_SCP2APMCU_IPC. -*/ -writel (MT8192_SCP_IPC_INT_BIT , - scp->reg_base +MT8192_SCP2APMCU_IPC_CLR ); +/* +* SCP won't send another interrupt until we clear +* MT8192_SCP2APMCU_IPC. +*/ +writel (MT8192_SCP_IPC_INT_BIT , + scp->reg_base +MT8192_SCP2APMCU_IPC_CLR ); + }else { +scp_wdt_handler (scp, scp_to_host); +writel (1 , scp->reg_base +MT8192_CORE0_WDT_IRQ ); + } }static irqreturn_t scp_irq_handler (int irq,void *priv)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 516/775 mhi: Fix double dma free
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit db4e8de1935b0202960e9ebb88ab93e8bd1e66b1 ]
mhi_deinit_chan_ctxt functionthat takes care of unitializing channel resources, including unmapping coherent MHI areas, can be called from different path in case of controller unregistering/removal:
- From a client driver remove callback, via mhi_unprepare_channel
- From mhi_driver_remove that unitialize all channels
mhi_driver_remove()
|-> driver->remove() | |-> mhi_unprepare_channel() | |-> mhi_deinit_chan_ctxt() |... |-> mhi_deinit_chan_ctxt()
This leads to double dma freeing...
Fix that by preventing deinit for already uninitialized channel.
--- drivers/bus/mhi/core/init.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bus/mhi/core/init.c +3 -0
@@ -552,6 +552,9 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, tre_ring = &mhi_chan->tre_ring; chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan]; +if (!chan_ctxt->rbase)/* Already uninitialized */ +return ; +mhi_free_coherent (mhi_cntrl, tre_ring->alloc_size, tre_ring->pre_aligned, tre_ring->dma_handle);vfree (buf_ring->base);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 517/775 regmap: sdw: use _no_pm functions in regmap_read/write
In reply to Greg Kroah-HartmanFrom: Bard Liao <[email protected]>
[ Upstream commit d288a5712ef961e16d588bbdb2d846e00b5ef154 ]
sdw_update_slave_status will be invoked when a codec is attached, and the codec driver will initialize the codec with regmap functions while the codec device is pm_runtime suspended.
regmap routines currently rely on regular SoundWire IO functions, which will call pm_runtime_get_sync()/put_autosuspend.
This causes a deadlock where the resume routine waits for an initialization complete signal that while the initialization complete can only be reached when the resume completes.
The only solution if we allow regmap functions to be used in resume operations as well as during codec initialization is to use _no_pm routines. The duty of making sure the bus is operational needs to be handled above the regmap level.
--- drivers/base/regmap/regmap-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap-sdw.c +2 -2
@@ -13,7 +13,7 @@ static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val)struct device *dev = context;struct sdw_slave *slave =dev_to_sdw_dev (dev); -return sdw_write (slave, reg, val); +return sdw_write_no_pm (slave, reg, val); }static int regmap_sdw_read (void *context,unsigned int reg,unsigned int *val)
@@ -22,7 +22,7 @@ static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val)struct sdw_slave *slave =dev_to_sdw_dev (dev);int read; - read =sdw_read (slave, reg); + read =sdw_read_no_pm (slave, reg);if (read <0 )return read;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 518/775 ext: EXT4_KUNIT_TESTS should depend on EXT4_FS instead of selecting it
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 302fdadeafe4be539f247abf25f61822e4a5a577 ]
EXT4_KUNIT_TESTS selects EXT4_FS, thus enabling an optional feature the user may not want to enable. Fix this by making the test depend on EXT4_FS instead.
--- fs/ext4/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/Kconfig +1 -2
@@ -103,8 +103,7 @@ config EXT4_DEBUG config EXT4_KUNIT_TESTS tristate "KUnit tests for ext4" if !KUNIT_ALL_TESTS - select EXT4_FS - depends on KUNIT + depends on EXT4_FS && KUNIT default KUNIT_ALL_TESTS help This builds the ext4 KUnit tests.
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 519/775 mailbox: sprd: correct definition of SPRD_OUTBOX_FIFO_FULL
In reply to Greg Kroah-HartmanFrom: Magnum Shan <[email protected]>
[ Upstream commit 4450f128c51160bfded6b483eba37d0628d7adb2 ]
According to the specification, bit[2] represents SPRD_OUTBOX_FIFO_FULL, not bit[0], so correct it.
--- drivers/mailbox/sprd-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/sprd-mailbox.c +1 -1
@@ -35,7 +35,7 @@#define SPRD_MBOX_IRQ_CLR BIT(0)/* Bit and mask definiation for outbox's SPRD_MBOX_FIFO_STS register */ -#define SPRD_OUTBOX_FIFO_FULL BIT(0) +#define SPRD_OUTBOX_FIFO_FULL BIT(2)#define SPRD_OUTBOX_FIFO_WR_SHIFT 16#define SPRD_OUTBOX_FIFO_RD_SHIFT 24#define SPRD_OUTBOX_FIFO_POS_MASK GENMASK(7, 0)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 520/775 device-dax: Fix default return code of range_parse()
In reply to Greg Kroah-HartmanFrom: Shiyang Ruan <[email protected]>
[ Upstream commit 7323fb22f05ff1d20498d267828870a5fbbaebd6 ]
The return value of range_parse() indicates the size when it is positive. The error code should be negative.
--- drivers/dax/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/bus.c +1 -1
@@ -1038,7 +1038,7 @@ static ssize_t range_parse(const char *opt, size_t len, struct range *range) {unsigned long long addr =0 ;char *start, *end, *str; -ssize_t rc =EINVAL ; +ssize_t rc = -EINVAL ; str =kstrdup (opt,GFP_KERNEL );if (!str)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 521/775 PCI: pci-bridge-emul: Fix array overruns, improve safety
In reply to Greg Kroah-HartmanFrom: Russell King <[email protected]>
[ Upstream commit f8ee579d53aca887d93f5f411462f25c085a5106 ]
We allow up to PCI_EXP_SLTSTA2 registers to be accessed, but the pcie_cap_regs_behavior[] array only covers up to PCI_EXP_RTSTA. Expand this array to avoid walking off the end of it.
Do the same for pci_regs_behavior for consistency[], and add a BUILD_BUG_ON() to also check the bridge->conf structure size.
--- drivers/pci/pci-bridge-emul.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/pci-bridge-emul.c +8 -3
@@ -21,8 +21,9 @@#include "pci-bridge-emul.h" #define PCI_BRIDGE_CONF_END PCI_STD_HEADER_SIZEOF +#define PCI_CAP_PCIE_SIZEOF (PCI_EXP_SLTSTA2 + 2)#define PCI_CAP_PCIE_START PCI_BRIDGE_CONF_END -#define PCI_CAP_PCIE_END (PCI_CAP_PCIE_START + PCI_EXP_SLTSTA2 + 2) +#define PCI_CAP_PCIE_END (PCI_CAP_PCIE_START + PCI_CAP_PCIE_SIZEOF)/** * struct pci_bridge_reg_behavior - register bits behaviors
@@ -46,7 +47,8 @@ struct pci_bridge_reg_behavior {u32 w1c; }; -static const struct pci_bridge_reg_behavior pci_regs_behavior[] = { +static const +struct pci_bridge_reg_behavior pci_regs_behavior[PCI_STD_HEADER_SIZEOF /4 ] = { [PCI_VENDOR_ID /4 ] = { .ro = ~0 }, [PCI_COMMAND /4 ] = { .rw = (PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
@@ -164,7 +166,8 @@ static const struct pci_bridge_reg_behavior pci_regs_behavior[] = { }, }; -static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { +static const +struct pci_bridge_reg_behavior pcie_cap_regs_behavior[PCI_CAP_PCIE_SIZEOF /4 ] = { [PCI_CAP_LIST_ID /4 ] = {/* * Capability ID, Next Capability Pointer and
@@ -260,6 +263,8 @@ static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = {int pci_bridge_emul_init (struct pci_bridge_emul *bridge,unsigned int flags) { +BUILD_BUG_ON (sizeof (bridge->conf) !=PCI_BRIDGE_CONF_END ); + bridge->conf.class_revision |=cpu_to_le32 (PCI_CLASS_BRIDGE_PCI <<16 ); bridge->conf.header_type =PCI_HEADER_TYPE_BRIDGE ; bridge->conf.cache_line_size =0x10 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 522/775 PCI: cadence: Fix DMA range mapping early return error
In reply to Greg Kroah-HartmanFrom: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 1002573ee33efef0988a9a546c075a9fa37d2498 ]
Function cdns_pcie_host_map_dma_ranges() iterates over a PCIe host bridge DMA ranges using the resource_list_for_each_entry() iterator, returning an error if cdns_pcie_host_bar_config() fails.
49e427e6bdd1 ("Merge branch 'pci/host-probe-refactor'") botched a merge so it *always* returned after the first DMA range, even if no error occurred.
Fix the error checking so we return early only when an error occurs.
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +3 -2
@@ -321,9 +321,10 @@ static int cdns_pcie_host_map_dma_ranges(struct cdns_pcie_rc *rc)resource_list_for_each_entry (entry, &bridge->dma_ranges) { err =cdns_pcie_host_bar_config (rc, entry); -if (err) +if (err) {dev_err (dev,"Fail to configure IB using dma-ranges\n" ); -return err; +return err; + } }return 0 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 523/775 i40e: Fix flow for IPv6 next header (extension header)
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit 92c6058024e87087cf1b99b0389d67c0a886360e ]
When a packet contains an IPv6 header with next header which is an extension header and not a protocol one, the kernel function skb_transport_header called with such sk_buff will return a pointer to the extension header and not to the TCP one.
The above explained call caused a problem with packet processing for skb with encapsulation for tunnel with I40E_TX_CTX_EXT_IP_IPV6. The extension header was not skipped at all.
The ipv6_skip_exthdr function does check if next header of the IPV6 header is an extension header and doesn't modify the l4_proto pointer if it points to a protocol header value so its safe to omit the comparison of exthdr and l4.hdr pointers. The ipv6_skip_exthdr can return value -1. This means that the skipping process failed and there is something wrong with the packet so it will be dropped.
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +6 -3
@@ -3113,13 +3113,16 @@ static int i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags, l4_proto = ip.v4->protocol; }else if (*tx_flags &I40E_TX_FLAGS_IPV6 ) { +int ret; + tunnel |=I40E_TX_CTX_EXT_IP_IPV6 ; exthdr = ip.hdr +sizeof (*ip.v6); l4_proto = ip.v6->nexthdr; -if (l4.hdr != exthdr) -ipv6_skip_exthdr (skb, exthdr - skb->data, - &l4_proto, &frag_off); + ret =ipv6_skip_exthdr (skb, exthdr - skb->data, + &l4_proto, &frag_off); +if (ret <0 ) +return -1 ; }/* define outer transport */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 524/775 i40e: Add zero-initialization of AQ command structures
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit d2c788f739b6f68090e968a2ee31b543701e795f ]
Zero-initialize AQ command data structures to comply with API specifications.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +6 -0
@@ -7667,6 +7667,8 @@ int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,if (filter->flags >=ARRAY_SIZE (flag_table))return I40E_ERR_CONFIG ; +memset (&cld_filter,0 ,sizeof (cld_filter)); +/* copy element needed to add cloud filter from filter */ i40e_set_cld_element (filter, &cld_filter);
@@ -7734,6 +7736,8 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi, !ipv6_addr_any(&filter->ip.v6.src_ip6))return -EOPNOTSUPP ; +memset (&cld_filter,0 ,sizeof (cld_filter)); +/* copy element needed to add cloud filter from filter */ i40e_set_cld_element (filter, &cld_filter.element);
@@ -11709,6 +11713,8 @@ i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf)struct i40e_aqc_configure_partition_bw_data bw_data;i40e_status status; +memset (&bw_data,0 ,sizeof (bw_data)); +/* Set the valid bit for this PF */ bw_data.pf_valid_bits =cpu_to_le16 (BIT (pf->hw.pf_id)); bw_data.max_bw[pf->hw.pf_id] = pf->max_bw &I40E_ALT_BW_VALUE_MASK ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 525/775 i40e: Fix overwriting flow control settings during driver loading
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 4cdb9f80dcd46aab3c0020b4a6920c22735c5d6e ]
During driver loading flow control settings were written to FW using a variable which was always zero, since it was being set only by ethtool. This behavior has been corrected and driver no longer overwrites the default FW/NVM settings.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 27 --------------------- 1 file changed, 27 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -27
@@ -10005,7 +10005,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)int old_recovery_mode_bit =test_bit (__I40E_RECOVERY_MODE, pf->state);struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];struct i40e_hw *hw = &pf->hw; -u8 set_fc_aq_fail =0 ;i40e_status ret;u32 val;int v;
@@ -10131,13 +10130,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)i40e_stat_str (&pf->hw, ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); -/* make sure our flow control settings are restored */ - ret =i40e_set_fc (&pf->hw, &set_fc_aq_fail, true); -if (ret) -dev_dbg (&pf->pdev->dev,"setting flow control: ret = %s last_status = %s\n" , -i40e_stat_str (&pf->hw, ret), -i40e_aq_str (&pf->hw, pf->hw.aq.asq_last_status)); -/* Rebuild the VSIs and VEBs that existed before reset. * They are still in our local switch element arrays, so only * need to rebuild the switch model in the HW.
@@ -14720,7 +14712,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)int err;u32 val;u32 i; -u8 set_fc_aq_fail; err =pci_enable_device_mem (pdev);if (err)
@@ -15054,24 +15045,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }INIT_LIST_HEAD (&pf->vsi[pf->lan_vsi]->ch_list); -/* Make sure flow control is set according to current settings */ - err =i40e_set_fc (hw, &set_fc_aq_fail, true); -if (set_fc_aq_fail &I40E_SET_FC_AQ_FAIL_GET ) -dev_dbg (&pf->pdev->dev, -"Set fc with err %s aq_err %s on get_phy_cap\n" , -i40e_stat_str (hw, err), -i40e_aq_str (hw, hw->aq.asq_last_status)); -if (set_fc_aq_fail &I40E_SET_FC_AQ_FAIL_SET ) -dev_dbg (&pf->pdev->dev, -"Set fc with err %s aq_err %s on set_phy_config\n" , -i40e_stat_str (hw, err), -i40e_aq_str (hw, hw->aq.asq_last_status)); -if (set_fc_aq_fail &I40E_SET_FC_AQ_FAIL_UPDATE ) -dev_dbg (&pf->pdev->dev, -"Set fc with err %s aq_err %s on get_link_info\n" , -i40e_stat_str (hw, err), -i40e_aq_str (hw, hw->aq.asq_last_status)); -/* if FDIR VSI was set up, start it now */ for (i =0 ; i < pf->num_alloc_vsi; i++) {if (pf->vsi[i] && pf->vsi[i]->type ==I40E_VSI_FDIR ) {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 526/775 i40e: Fix addition of RX filters after enabling FW LLDP agent
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 28b1208e7a7fa3ddc9345b022bb93e53d9dcc28a ]
Fix addition of VLAN filter for PF after enabling FW LLDP agent. Changing LLDP Agent causes FW to re-initialize per NVM settings. Remove default PF filter and move "Enable/Disable" to currently used reset flag.
Without this patch PF would try to add MAC VLAN filter with default switch filter present. This causes AQ error and sets promiscuous mode on.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 16 +++++++++------- drivers/net/ethernet/intel/i40e/i40e_main.c | 9 ++++----- 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +9 -7
@@ -4878,7 +4878,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)enum i40e_admin_queue_err adq_err;struct i40e_vsi *vsi = np->vsi;struct i40e_pf *pf = vsi->back; -bool is_reset_needed; +u32 reset_needed =0 ;i40e_status status;u32 i, j;
@@ -4923,9 +4923,11 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags) flags_complete: changed_flags = orig_flags ^ new_flags; - is_reset_needed = !!(changed_flags & (I40E_FLAG_VEB_STATS_ENABLED | -I40E_FLAG_LEGACY_RX |I40E_FLAG_SOURCE_PRUNING_DISABLED | -I40E_FLAG_DISABLE_FW_LLDP )); +if (changed_flags &I40E_FLAG_DISABLE_FW_LLDP ) + reset_needed =I40E_PF_RESET_AND_REBUILD_FLAG ; +if (changed_flags & (I40E_FLAG_VEB_STATS_ENABLED | +I40E_FLAG_LEGACY_RX |I40E_FLAG_SOURCE_PRUNING_DISABLED )) + reset_needed =BIT (__I40E_PF_RESET_REQUESTED);/* Before we finalize any flag changes, we need to perform some * checks to ensure that the changes are supported and safe.
@@ -5057,7 +5059,7 @@ flags_complete:case I40E_AQ_RC_EEXIST :dev_warn (&pf->pdev->dev,"FW LLDP agent is already running\n" ); - is_reset_needed = false; + reset_needed =0 ;break ;case I40E_AQ_RC_EPERM : dev_warn(&pf->pdev->dev,
@@ -5086,8 +5088,8 @@ flags_complete:/* Issue reset to cause things to take effect, as additional bits * are added we will need to create a mask of bits requiring reset */ -if (is_reset_needed) -i40e_do_reset (pf,BIT (__I40E_PF_RESET_REQUESTED), true); +if (reset_needed) +i40e_do_reset (pf, reset_needed, true);return 0 ; }
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -5
@@ -8537,11 +8537,6 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired)dev_dbg (&pf->pdev->dev,"PFR requested\n" );i40e_handle_reset_warning (pf, lock_acquired); -dev_info (&pf->pdev->dev, - pf->flags &I40E_FLAG_DISABLE_FW_LLDP ? -"FW LLDP is disabled\n" : -"FW LLDP is enabled\n" ); - }else if (reset_flags &I40E_PF_RESET_AND_REBUILD_FLAG ) {/* Request a PF Reset *
@@ -8549,6 +8544,10 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired)*/ i40e_prep_for_reset (pf, lock_acquired);i40e_reset_and_rebuild (pf, true, lock_acquired); +dev_info (&pf->pdev->dev, + pf->flags &I40E_FLAG_DISABLE_FW_LLDP ? +"FW LLDP is disabled\n" : +"FW LLDP is enabled\n" ); }else if (reset_flags &BIT_ULL (__I40E_REINIT_REQUESTED)) {int v;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 527/775 i40e: Fix VFs not created
In reply to Greg Kroah-HartmanFrom: Sylwester Dziedziuch <[email protected]>
[ Upstream commit dc8812626440fa6a27f1f3f654f6dc435e042e42 ]
When creating VFs they were sometimes not getting resources. It was caused by not executing i40e_reset_all_vfs due to flag __I40E_VF_DISABLE being set on PF. Because of this IAVF was never able to finish setup sequence never getting reset indication from PF.
Changed test_and_set_bit __I40E_VF_DISABLE in i40e_sync_filters_subtask to test_bit and removed clear_bit. This function should not set this bit it should only check if it hasn't been already set.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -2
@@ -2616,7 +2616,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)return ;if (!test_and_clear_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state))return ; -if (test_and_set_bit (__I40E_VF_DISABLE, pf->state)) { +if (test_bit (__I40E_VF_DISABLE, pf->state)) {set_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state);return ; }
@@ -2634,7 +2634,6 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf) } } } -clear_bit (__I40E_VF_DISABLE, pf->state); }/**
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 528/775 Take mmap lock in cacheflush syscall
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
[ Upstream commit c26958cb5a0d9053d1358258827638773f3d36ed ]
We need to take the mmap lock around find_vma() and subsequent use of the VMA. Otherwise, we can race with concurrent operations like munmap(), which can lead to use-after-free accesses to freed VMAs.
--- arch/nios2/kernel/sys_nios2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/nios2/kernel/sys_nios2.c +9 -2
@@ -22,6 +22,7 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op) {struct vm_area_struct *vma; +struct mm_struct *mm = current->mm;if (len ==0 )return 0 ;
@@ -34,16 +35,22 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,if (addr + len < addr)return -EFAULT ; +if (mmap_read_lock_killable (mm)) +return -EINTR ; +/* * Verify that the specified address region actually belongs * to this process. */ - vma =find_vma (current->mm, addr); -if (vma ==NULL || addr < vma->vm_start || addr + len > vma->vm_end) + vma =find_vma (mm, addr); +if (vma ==NULL || addr < vma->vm_start || addr + len > vma->vm_end) { +mmap_read_unlock (mm);return -EFAULT ; + }flush_cache_range (vma, addr, addr + len); +mmap_read_unlock (mm);return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 529/775 nios2: fixed broken sys_clone syscall
In reply to Greg Kroah-HartmanFrom: Andreas Oetken <[email protected]>
[ Upstream commit 9abcfcb20320e8f693e89d86573b58e6289931cb ]
The tls pointer must be pushed on the stack prior to calling nios2_clone as it is the 5th function argument. Prior handling of the tls pointer was done inside former called function copy_thread_tls using the r8 register from the current_pt_regs directly. This was a bad design and resulted in the current bug introduced in 04bd52fb.
--- arch/nios2/kernel/entry.S | 3 +++ 1 file changed, 3 insertions(+)
arch/nios2/kernel/entry.S +3 -0
@@ -389,7 +389,10 @@ ENTRY(ret_from_interrupt) */ ENTRY(sys_clone) SAVE_SWITCH_STACK + subi sp, sp, 4 /* make space for tls pointer */ + stw r8, 0(sp) /* pass tls pointer (r8) via stack (5th argument) */ call nios2_clone + addi sp, sp, 4 RESTORE_SWITCH_STACK ret
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 530/775 i40e: Fix add TC filter for IPv6
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 61c1e0eb8375def7c891bfe857bb795a57090526 ]
Fix insufficient distinction between IPv4 and IPv6 addresses when creating a filter.
IPv4 and IPv6 are kept in the same memory area. If IPv6 is added, then it's caught by IPv4 check, which leads to err -95.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -2
@@ -7731,7 +7731,8 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,return -EOPNOTSUPP ;/* adding filter using src_port/src_ip is not supported at this stage */ -if (filter->src_port || filter->src_ipv4 || +if (filter->src_port || + (filter->src_ipv4 && filter->n_proto !=ETH_P_IPV6 ) || !ipv6_addr_any (&filter->ip.v6.src_ip6))return -EOPNOTSUPP ;
@@ -7760,7 +7761,7 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,cpu_to_le16 (I40E_AQC_ADD_CLOUD_FILTER_MAC_VLAN_PORT ); } - }else if (filter->dst_ipv4 || + }else if ((filter->dst_ipv4 && filter->n_proto !=ETH_P_IPV6 ) || !ipv6_addr_any (&filter->ip.v6.dst_ip6)) { cld_filter.element.flags =cpu_to_le16 (I40E_AQC_ADD_CLOUD_FILTER_IP_PORT );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 531/775 i40e: Fix endianness conversions
In reply to Greg Kroah-HartmanFrom: Norbert Ciosek <[email protected]>
[ Upstream commit b32cddd2247cf730731f93f1967d0147a40682c7 ]
Fixes the following sparse warnings:
i40e_main.c:5953:32: warning: cast from restricted __le16 i40e_main.c:8008:29: warning: incorrect type in assignment (different base types)
i40e_main.c:8008:29: expected unsigned int [assigned] [usertype] ipa
i40e_main.c:8008:29: got restricted __le32 [usertype]
i40e_main.c:8008:29: warning: incorrect type in assignment (different base types)
i40e_main.c:8008:29: expected unsigned int [assigned] [usertype] ipa
i40e_main.c:8008:29: got restricted __le32 [usertype]
i40e_txrx.c:1950:59: warning: incorrect type in initializer (different base types)
i40e_txrx.c:1950:59: expected unsigned short [usertype] vlan_tag
i40e_txrx.c:1950:59: got restricted __le16 [usertype] l2tag1
i40e_txrx.c:1953:40: warning: cast to restricted __le16 i40e_xsk.c:448:38: warning: invalid assignment: |=
i40e_xsk.c:448:38: left side has type restricted __le64
i40e_xsk.c:448:38: right side has type int
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 12 ++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +6 -6
@@ -5920,7 +5920,7 @@ static int i40e_add_channel(struct i40e_pf *pf, u16 uplink_seid, ch->enabled_tc = !i40e_is_channel_macvlan (ch) && enabled_tc; ch->seid = ctxt.seid; ch->vsi_number = ctxt.vsi_number; - ch->stat_counter_idx =cpu_to_le16 (ctxt.info.stat_counter_idx); + ch->stat_counter_idx =le16_to_cpu (ctxt.info.stat_counter_idx);/* copy just the sections touched not the entire info * since not all sections are valid as returned by
@@ -7599,8 +7599,8 @@ static inline void i40e_set_cld_element(struct i40e_cloud_filter *filter, struct i40e_aqc_cloud_filters_element_data *cld) { - int i, j; u32 ipa; +int i;memset (cld,0 ,sizeof (*cld));ether_addr_copy (cld->outer_mac, filter->dst_mac);
@@ -7611,14 +7611,14 @@ i40e_set_cld_element(struct i40e_cloud_filter *filter,if (filter->n_proto ==ETH_P_IPV6 ) {#define IPV6_MAX_INDEX (ARRAY_SIZE(filter->dst_ipv6) - 1) -for (i =0 , j =0 ; i <ARRAY_SIZE (filter->dst_ipv6); - i++, j +=2 ) { +for (i =0 ; i <ARRAY_SIZE (filter->dst_ipv6); i++) { ipa =be32_to_cpu (filter->dst_ipv6[IPV6_MAX_INDEX - i]); - ipa =cpu_to_le32 (ipa); -memcpy (&cld->ipaddr.raw_v6.data[j], &ipa,sizeof (ipa)); + + *(__le32 *)&cld->ipaddr.raw_v6.data[i *2 ] =cpu_to_le32 (ipa); } }else { ipa =be32_to_cpu (filter->dst_ipv4); +memcpy (&cld->ipaddr.v4.data, &ipa,sizeof (ipa)); }
drivers/net/ethernet/intel/i40e/i40e_txrx.c +1 -1
@@ -1793,7 +1793,7 @@ void i40e_process_skb_fields(struct i40e_ring *rx_ring,skb_record_rx_queue (skb, rx_ring->queue_index);if (qword &BIT (I40E_RX_DESC_STATUS_L2TAG1P_SHIFT )) { -u16 vlan_tag = rx_desc->wb.qword0.lo_dword.l2tag1; +__le16 vlan_tag = rx_desc->wb.qword0.lo_dword.l2tag1;__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ),le16_to_cpu (vlan_tag));
drivers/net/ethernet/intel/i40e/i40e_xsk.c +1 -1
@@ -444,7 +444,7 @@ static void i40e_set_rs_bit(struct i40e_ring *xdp_ring)struct i40e_tx_desc *tx_desc; tx_desc =I40E_TX_DESC (xdp_ring, ntu); - tx_desc->cmd_type_offset_bsz |= (I40E_TX_DESC_CMD_RS <<I40E_TXD_QW1_CMD_SHIFT ); + tx_desc->cmd_type_offset_bsz |=cpu_to_le64 (I40E_TX_DESC_CMD_RS <<I40E_TXD_QW1_CMD_SHIFT ); }/**
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 532/775 octeontx2-af: Fix an off by one in rvu_dbg_qsize_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3a2eb515d1367c0f667b76089a6e727279c688b8 ]
This code does not allocate enough memory for the NUL terminator so it ends up putting it one character beyond the end of the buffer.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +1 -1
@@ -385,7 +385,7 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,u16 pcifunc;int ret, lf; - cmd_buf =memdup_user (buffer, count); + cmd_buf =memdup_user (buffer, count +1 );if (IS_ERR (cmd_buf))return -ENOMEM ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 533/775 pwm: iqs620a: Fix overflow and optimize calculations
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 72d6b2459dbd539c1369149e501fdc3dc8ddef16 ]
If state->duty_cycle is 0x100000000000000, the previous calculation of duty_scale overflows and yields a duty cycle ratio of 0% instead of 100%. Fix this by clamping the requested duty cycle to the maximal possible duty cycle first. This way it is possible to use a native integer division instead of a (depending on the architecture) more expensive 64bit division.
With this change in place duty_scale cannot be bigger than 256 which allows to simplify the calculation of duty_val.
--- drivers/pwm/pwm-iqs620a.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pwm/pwm-iqs620a.c +5 -3
@@ -46,7 +46,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, {struct iqs620_pwm_private *iqs620_pwm;struct iqs62x_core *iqs62x; -u64 duty_scale; +unsigned int duty_cycle; +unsigned int duty_scale;int ret;if (state->polarity !=PWM_POLARITY_NORMAL )
@@ -70,7 +71,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,* For lower duty cycles (e.g. 0), the PWM output is simply disabled to * allow an external pull-down resistor to hold the GPIO3/LTX pin low. */ - duty_scale =div_u64 (state->duty_cycle *256 ,IQS620_PWM_PERIOD_NS ); + duty_cycle =min_t (u64, state->duty_cycle,IQS620_PWM_PERIOD_NS ); + duty_scale = duty_cycle *256 /IQS620_PWM_PERIOD_NS ;mutex_lock (&iqs620_pwm->lock);
@@ -82,7 +84,7 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, }if (duty_scale) { -u8 duty_val =min_t (u64, duty_scale -1 ,0xff ); +u8 duty_val = duty_scale -1 ; ret =regmap_write (iqs62x->regmap,IQS620_PWM_DUTY_CYCLE , duty_val);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 534/775 ice: report correct max number of TCs
In reply to Greg Kroah-HartmanFrom: Dave Ertman <[email protected]>
[ Upstream commit 7dcf7aa01c7b9f18727cbe0f9cb4136f1c6cdcc2 ]
In the driver currently, we are reporting max number of TCs to the DCBNL callback as a kernel define set to 8. This is preventing userspace applications performing DCBx to correctly down map the TCs from requested to actual values.
Report the actual max TC value to userspace from the capability struct.
--- drivers/net/ethernet/intel/ice/ice_dcb_nl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_dcb_nl.c +1 -1
@@ -136,7 +136,7 @@ ice_dcbnl_getnumtcs(struct net_device *dev, int __always_unused tcid, u8 *num)if (!test_bit (ICE_FLAG_DCB_CAPABLE , pf->flags))return -EINVAL ; - *num =IEEE_8021QAZ_MAX_TCS ; + *num = pf->hw.func_caps.common_cap.maxtc;return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 535/775 ice: Account for port VLAN in VF max packet size calculation
In reply to Greg Kroah-HartmanFrom: Brett Creeley <[email protected]>
[ Upstream commit a6aa7c8f998f4afddd73410aa043dad38162ce9e ]
Currently if an AVF driver doesn't account for the possibility of a port VLAN when determining its max packet size then packets at MTU will be dropped. It is not the VF driver's responsibility to account for a port VLAN so fix this. To fix this, do the following:
1. Add a function that determines the max packet size a VF is allowed by using the port's max packet size and whether the VF is in a port VLAN. If a port VLAN is configured then a VF's max packet size will always be the port's max packet size minus VLAN_HLEN. Otherwise it will be the port's max packet size.
2. Use this function to verify the max packet size from the VF.
3. If there is a port VLAN configured then add 4 bytes (VLAN_HLEN) to the VF's max packet size configuration.
Also, the VIRTCHNL_OP_GET_VF_RESOURCES message provides the capability to communicate a VF's max packet size. Use the new function for this purpose.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +32 -1
@@ -1878,6 +1878,29 @@ static int ice_vc_get_ver_msg(struct ice_vf *vf, u8 *msg) sizeof(struct virtchnl_version_info)); } +/** +* ice_vc_get_max_frame_size - get max frame size allowed for VF +* @vf: VF used to determine max frame size +* +* Max frame size is determined based on the current port's max frame size and +* whether a port VLAN is configured on this VF. The VF is not aware whether +* it's in a port VLAN so the PF needs to account for this in max frame size +* checks and sending the max frame size to the VF. +*/ +static u16 ice_vc_get_max_frame_size (struct ice_vf *vf) +{ +struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx]; +struct ice_port_info *pi = vsi->port_info; +u16 max_frame_size; + + max_frame_size = pi->phy.link_info.max_frame_size; + +if (vf->port_vlan_info) + max_frame_size -=VLAN_HLEN ; + +return max_frame_size; +} +/** * ice_vc_get_vf_res_msg * @vf: pointer to the VF info
@@ -1960,6 +1983,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) vfres->max_vectors = pf->num_msix_per_vf; vfres->rss_key_size =ICE_VSIQF_HKEY_ARRAY_SIZE ; vfres->rss_lut_size =ICE_VSIQF_HLUT_ARRAY_SIZE ; + vfres->max_mtu =ice_vc_get_max_frame_size (vf); vfres->vsi_res[0 ].vsi_id = vf->lan_vsi_num; vfres->vsi_res[0 ].vsi_type =VIRTCHNL_VSI_SRIOV ;
@@ -2952,6 +2976,8 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)/* copy Rx queue info from VF into VSI */ if (qpi->rxq.ring_len >0 ) { +u16 max_frame_size =ice_vc_get_max_frame_size (vf); + num_rxq++; vsi->rx_rings[i]->dma = qpi->rxq.dma_ring_addr; vsi->rx_rings[i]->count = qpi->rxq.ring_len;
@@ -2964,7 +2990,7 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) } vsi->rx_buf_len = qpi->rxq.databuffer_size; vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len; -if (qpi->rxq.max_pkt_size >= (16 *1024 ) || +if (qpi->rxq.max_pkt_size > max_frame_size || qpi->rxq.max_pkt_size <64 ) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param;
@@ -2972,6 +2998,11 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) } vsi->max_frame = qpi->rxq.max_pkt_size; +/* add space for the port VLAN since the VF driver is not +* expected to account for it in the MTU calculation +*/ +if (vf->port_vlan_info) + vsi->max_frame +=VLAN_HLEN ; }/* VF can request to configure less than allocated queues or default
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 536/775 ice: Fix state bits on LLDP mode switch
In reply to Greg Kroah-HartmanFrom: Dave Ertman <[email protected]>
[ Upstream commit 0d4907f65dc8fc5e897ad19956fca1acb3b33bc8 ]
DCBX_CAP bits were not being adjusted when switching between SW and FW controlled LLDP.
Adjust bits to correctly indicate which mode the LLDP logic is in.
--- drivers/net/ethernet/intel/ice/ice.h | 2 -- drivers/net/ethernet/intel/ice/ice_dcb_nl.c | 4 ++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -2
@@ -443,9 +443,7 @@ struct ice_pf {struct ice_hw_port_stats stats_prev;struct ice_hw hw; u8 stat_prev_loaded:1; /* has previous stats been loaded */ -#ifdef CONFIG_DCB u16 dcbx_cap; -#endif /* CONFIG_DCB */ u32 tx_timeout_count;unsigned long tx_timeout_last_recovery;u32 tx_timeout_recovery_level;
drivers/net/ethernet/intel/ice/ice_dcb_nl.c +4 -0
@@ -160,6 +160,10 @@ static u8 ice_dcbnl_setdcbx(struct net_device *netdev, u8 mode) {struct ice_pf *pf =ice_netdev_to_pf (netdev); +/* if FW LLDP agent is running, DCBNL not allowed to change mode */ +if (test_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags)) +return ICE_DCB_NO_HW_CHG ; +/* No support for LLD_MANAGED modes or CEE+IEEE */ if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
drivers/net/ethernet/intel/ice/ice_ethtool.c +7 -0
@@ -8,6 +8,7 @@#include "ice_fltr.h" #include "ice_lib.h" #include "ice_dcb_lib.h" +#include <net/dcbnl.h> struct ice_stats {char stat_string[ETH_GSTRING_LEN ];
@@ -1238,6 +1239,9 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) status =ice_init_pf_dcb (pf, true);if (status)dev_warn (dev,"Fail to init DCB\n" ); + + pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED ; + pf->dcbx_cap |=DCB_CAP_DCBX_HOST ; }else {enum ice_status status;bool dcbx_agent_status;
@@ -1280,6 +1284,9 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)if (status)dev_dbg (dev,"Fail to enable MIB change events\n" ); + pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST ; + pf->dcbx_cap |=DCB_CAP_DCBX_LLD_MANAGED ; +ice_nway_reset (netdev); } }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 537/775 ice: update the number of available RSS queues
In reply to Greg Kroah-HartmanFrom: Henry Tieman <[email protected]>
[ Upstream commit 0393e46ac48a6832b1011c233ebcef84f8dbe4f5 ]
It was possible to have Rx queues that were not available for use by RSS. This would happen when increasing the number of Rx queues while there was a user defined RSS LUT.
Always update the number of available RSS queues when changing the number of Rx queues.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +19 -8
@@ -3328,6 +3328,18 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) ch->max_other = ch->other_count; } +/** +* ice_get_valid_rss_size - return valid number of RSS queues +* @hw: pointer to the HW structure +* @new_size: requested RSS queues +*/ +static int ice_get_valid_rss_size (struct ice_hw *hw,int new_size) +{ +struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; + +return min_t (int, new_size,BIT (caps->rss_table_entry_width)); +} +/** * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size * @vsi: VSI to reconfigure RSS LUT on
@@ -3355,14 +3367,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)return -ENOMEM ;/* set RSS LUT parameters */ -if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) { +if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) vsi->rss_size =1 ; - }else { -struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; - - vsi->rss_size =min_t (int, req_rss_size, -BIT (caps->rss_table_entry_width)); - } +else + vsi->rss_size =ice_get_valid_rss_size (hw, req_rss_size);/* create/set RSS LUT */ ice_fill_rss_lut (lut, vsi->rss_table_size, vsi->rss_size);
@@ -3441,9 +3449,12 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)ice_vsi_recfg_qs (vsi, new_rx, new_tx); -if (new_rx && !netif_is_rxfh_configured (dev)) +if (!netif_is_rxfh_configured (dev))return ice_vsi_set_dflt_rss_lut (vsi, new_rx); +/* Update rss_size due to change in Rx queues */ + vsi->rss_size =ice_get_valid_rss_size (&pf->hw, new_rx); +return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 538/775 dpaa_eth: fix the access method for the dpaa_napi_portal
In reply to Greg Kroah-HartmanFrom: Camelia Groza <[email protected]>
[ Upstream commit 433dfc99aa3e0acbf655b961d98eb690162f758f ]
The current use of container_of is flawed and unnecessary. Obtain the dpaa_napi_portal reference from the private percpu data instead.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +1 -1
@@ -2672,7 +2672,6 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal,u32 hash;u64 ns; - np = container_of(&portal, struct dpaa_napi_portal, p); dpaa_fq = container_of(fq, struct dpaa_fq, fq_base); fd_status =be32_to_cpu (fd->status); fd_format =qm_fd_get_format (fd);
@@ -2687,6 +2686,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, percpu_priv =this_cpu_ptr (priv->percpu_priv); percpu_stats = &percpu_priv->stats; + np = &percpu_priv->np;if (unlikely (dpaa_eth_napi_schedule (percpu_priv, portal, sched_napi)))return qman_cb_dqrr_stop;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 539/775 net: stmmac: fix CBS idleslope and sendslope calculation
In reply to Greg Kroah-HartmanFrom: Song, Yoong Siang <[email protected]>
[ Upstream commit 24877687b375f2c476ffb726ea915fc85df09e3d ]
When link speed is not 100 Mbps, port transmit rate and speed divider are set to 8 and 1000000 respectively. These values are incorrect for CBS idleslope and sendslope HW values calculation if the link speed is not 1 Gbps.
This patch adds switch statement to set the values of port transmit rate and speed divider for 10 Gbps, 5 Gbps, 2.5 Gbps, 1 Gbps, and 100 Mbps. Note that CBS is not supported at 10 Mbps.
--- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +26 -4
@@ -316,6 +316,32 @@ static int tc_setup_cbs(struct stmmac_priv *priv,if (!priv->dma_cap.av)return -EOPNOTSUPP ; +/* Port Transmit Rate and Speed Divider */ +switch (priv->speed) { +case SPEED_10000 : + ptr =32 ; + speed_div =10000000 ; +break ; +case SPEED_5000 : + ptr =32 ; + speed_div =5000000 ; +break ; +case SPEED_2500 : + ptr =8 ; + speed_div =2500000 ; +break ; +case SPEED_1000 : + ptr =8 ; + speed_div =1000000 ; +break ; +case SPEED_100 : + ptr =4 ; + speed_div =100000 ; +break ; +default : +return -EOPNOTSUPP ; + } + mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use;if (mode_to_use ==MTL_QUEUE_DCB && qopt->enable) { ret =stmmac_dma_qmode (priv, priv->ioaddr, queue,MTL_QUEUE_AVB );
@@ -332,10 +358,6 @@ static int tc_setup_cbs(struct stmmac_priv *priv, priv->plat->tx_queues_cfg[queue].mode_to_use =MTL_QUEUE_DCB ; } -/* Port Transmit Rate and Speed Divider */ - ptr = (priv->speed ==SPEED_100 ) ?4 :8 ; - speed_div = (priv->speed ==SPEED_100 ) ?100000 :1000000 ; -/* Final adjustments for HW */ value =div_s64 (qopt->idleslope *1024ll * ptr, speed_div); priv->plat->tx_queues_cfg[queue].idle_slope = value &GENMASK (31 ,0 );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 540/775 net/mlx4_core: Add missed mlx4_free_cmd_mailbox()
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 8eb65fda4a6dbd59cd5de24b106a10b6ee0d2176 ]
mlx4_do_mirror_rule() forgets to call mlx4_free_cmd_mailbox() to free the memory region allocated by mlx4_alloc_cmd_mailbox() before an exit.
Add the missed call to fix it.
--- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +1 -0
@@ -4986,6 +4986,7 @@ static int mlx4_do_mirror_rule(struct mlx4_dev *dev, struct res_fs_rule *fs_ruleif (!fs_rule->mirr_mbox) {mlx4_err (dev,"rule mirroring mailbox is null\n" ); +mlx4_free_cmd_mailbox (dev, mailbox);return -EINVAL ; }memcpy (mailbox->buf, fs_rule->mirr_mbox, fs_rule->mirr_mbox_size);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 541/775 PCI: rockchip: Make ep-gpios DT property optional
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit 58adbfb3ebec460e8b58875c682bafd866808e80 ]
The Rockchip PCIe controller DT binding clearly states that 'ep-gpios' is an optional property. And indeed there are boards that don't require it.
Make the driver follow the binding by using devm_gpiod_get_optional() instead of devm_gpiod_get().
--- drivers/pci/controller/pcie-rockchip.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/pcie-rockchip.c +6 -6
@@ -82,7 +82,7 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) } rockchip->mgmt_sticky_rst =devm_reset_control_get_exclusive (dev, -"mgmt-sticky" ); +"mgmt-sticky" );if (IS_ERR (rockchip->mgmt_sticky_rst)) {if (PTR_ERR (rockchip->mgmt_sticky_rst) != -EPROBE_DEFER )dev_err (dev,"missing mgmt-sticky reset property in node\n" );
@@ -118,11 +118,11 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) }if (rockchip->is_rc) { - rockchip->ep_gpio =devm_gpiod_get (dev,"ep" ,GPIOD_OUT_HIGH ); -if (IS_ERR (rockchip->ep_gpio)) { -dev_err (dev,"missing ep-gpios property in node\n" ); -return PTR_ERR (rockchip->ep_gpio); - } + rockchip->ep_gpio =devm_gpiod_get_optional (dev,"ep" , +GPIOD_OUT_HIGH ); +if (IS_ERR (rockchip->ep_gpio)) +return dev_err_probe (dev,PTR_ERR (rockchip->ep_gpio), +"failed to get ep GPIO\n" ); } rockchip->aclk_pcie =devm_clk_get (dev,"aclk" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 542/775 vxlan: move debug check after netdev unregister
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 92584ddf550ae72d492858c19d1f9025e07a9350 ]
The debug check must be done after unregister_netdevice_many() call -- the hlist_del_rcu() for this is done inside .ndo_stop.
This is the same with commit 0fda7600c2e1 ("geneve: move debug check after netdev unregister")
Test commands:
ip netns del A
ip netns add A
ip netns add B
ip netns exec B ip link add vxlan0 type vxlan vni 100 local 10.0.0.1 \
remote 10.0.0.2 dstport 4789 srcport 4789 4789
ip netns exec B ip link set vxlan0 netns A
ip netns exec A ip link set vxlan0 up
ip netns del B
Splat looks like:
[ 73.176249][ T7] ------------[ cut here ]------------ [ 73.178662][ T7] WARNING: CPU: 4 PID: 7 at drivers/net/vxlan.c:4743 vxlan_exit_batch_net+0x52e/0x720 [vxlan] [ 73.182597][ T7] Modules linked in: vxlan openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 mlx5_core nfp mlxfw ixgbevf tls sch_fq_codel nf_tables nfnetlink ip_tables x_tables unix [ 73.190113][ T7] CPU: 4 PID: 7 Comm: kworker/u16:0 Not tainted 5.11.0-rc7+ #838 [ 73.193037][ T7] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 73.196986][ T7] Workqueue: netns cleanup_net [ 73.198946][ T7] RIP: 0010:vxlan_exit_batch_net+0x52e/0x720 [vxlan] [ 73.201509][ T7] Code: 00 01 00 00 0f 84 39 fd ff ff 48 89 ca 48 c1 ea 03 80 3c 1a 00 0f 85 a6 00 00 00 89 c2 48 83 c2 02 49 8b 14 d4 48 85 d2 74 ce <0f> 0b eb ca e8 b9 51 db dd 84 c0 0f 85 4a fe ff ff 48 c7 c2 80 bc [ 73.208813][ T7] RSP: 0018:ffff888100907c10 EFLAGS: 00010286 [ 73.211027][ T7] RAX: 000000000000003c RBX: dffffc0000000000 RCX: ffff88800ec411f0 [ 73.213702][ T7] RDX: ffff88800a278000 RSI: ffff88800fc78c70 RDI: ffff88800fc78070 [ 73.216169][ T7] RBP: ffff88800b5cbdc0 R08: fffffbfff424de61 R09: fffffbfff424de61 [ 73.218463][ T7] R10: ffffffffa126f307 R11: fffffbfff424de60 R12: ffff88800ec41000 [ 73.220794][ T7] R13: ffff888100907d08 R14: ffff888100907c50 R15: ffff88800fc78c40 [ 73.223337][ T7] FS: 0000000000000000(0000) GS:ffff888114800000(0000) knlGS:0000000000000000 [ 73.225814][ T7] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 73.227616][ T7] CR2: 0000562b5cb4f4d0 CR3: 0000000105fbe001 CR4: 00000000003706e0 [ 73.229700][ T7] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 73.231820][ T7] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 73.233844][ T7] Call Trace: [ 73.234698][ T7] ? vxlan_err_lookup+0x3c0/0x3c0 [vxlan] [ 73.235962][ T7] ? ops_exit_list.isra.11+0x93/0x140 [ 73.237134][ T7] cleanup_net+0x45e/0x8a0
[ ... ]
--- drivers/net/vxlan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/vxlan.c +8 -3
@@ -4725,7 +4725,6 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head)struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan, *next;struct net_device *dev, *aux; -unsigned int h;for_each_netdev_safe (net, dev, aux)if (dev->rtnl_link_ops == &vxlan_link_ops)
@@ -4739,14 +4738,13 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head)unregister_netdevice_queue (vxlan->dev, head); } -for (h =0 ; h <PORT_HASH_SIZE ; ++h) -WARN_ON_ONCE (!hlist_empty (&vn->sock_list[h])); } static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) {struct net *net;LIST_HEAD (list); +unsigned int h;rtnl_lock ();list_for_each_entry (net, net_list, exit_list) {
@@ -4759,6 +4757,13 @@ static void __net_exit vxlan_exit_batch_net(struct list_head *net_list)unregister_netdevice_many (&list);rtnl_unlock (); + +list_for_each_entry (net, net_list, exit_list) { +struct vxlan_net *vn =net_generic (net, vxlan_net_id); + +for (h =0 ; h <PORT_HASH_SIZE ; ++h) +WARN_ON_ONCE (!hlist_empty (&vn->sock_list[h])); + } }static struct pernet_operations vxlan_net_ops = {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 543/775 wireguard: device: do not generate ICMP for non-IP packets
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
[ Upstream commit 99fff5264e7ab06f45b0ad60243475be0a8d0559 ]
If skb->protocol doesn't match the actual skb->data header, it's probably not a good idea to pass it off to icmp{,v6}_ndo_send, which is expecting to reply to a valid IP packet. So this commit has that early mismatch case jump to a later error label.
--- drivers/net/wireguard/device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireguard/device.c +4 -3
@@ -138,7 +138,7 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev)else if (skb->protocol ==htons (ETH_P_IPV6 ))net_dbg_ratelimited ("%s: No peer has allowed IPs matching %pI6\n" , dev->name, &ipv6_hdr (skb)->daddr); - goto err; + goto err_icmp; } family =READ_ONCE (peer->endpoint.addr.sa_family);
@@ -201,12 +201,13 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev) err_peer:wg_peer_put (peer); -err: - ++dev->stats.tx_errors; +err_icmp:if (skb->protocol ==htons (ETH_P_IP ))icmp_ndo_send (skb,ICMP_DEST_UNREACH ,ICMP_HOST_UNREACH ,0 );else if (skb->protocol ==htons (ETH_P_IPV6 ))icmpv6_ndo_send (skb,ICMPV6_DEST_UNREACH ,ICMPV6_ADDR_UNREACH ,0 ); +err: + ++dev->stats.tx_errors;kfree_skb (skb);return ret; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 544/775 wireguard: kconfig: use arm chacha even with no neon
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
[ Upstream commit bce2473927af8de12ad131a743f55d69d358c0b9 ]
The condition here was incorrect: a non-neon fallback implementation is available on arm32 when NEON is not supported.
--- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/Kconfig +1 -1
@@ -87,7 +87,7 @@ config WIREGUARD select CRYPTO_CURVE25519_X86 if X86 && 64BIT select ARM_CRYPTO if ARM select ARM64_CRYPTO if ARM64 - select CRYPTO_CHACHA20_NEON if (ARM || ARM64) && KERNEL_MODE_NEON + select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) select CRYPTO_POLY1305_NEON if ARM64 && KERNEL_MODE_NEON select CRYPTO_POLY1305_ARM if ARM select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 545/775 ocfs2: fix a use after free on error
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit c57d117f2b2f2a19b570c36f2819ef8d8210af20 ]
The error handling in this function frees "reg" but it is still on the "o2hb_all_regions" list so it will lead to a use after freew. Joseph Qi points out that we need to clear the bit in the "o2hb_region_bitmap" as well
--- fs/ocfs2/cluster/heartbeat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/ocfs2/cluster/heartbeat.c +7 -1
@@ -2042,7 +2042,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g o2hb_nego_timeout_handler, reg, NULL, ®->hr_handler_list);if (ret) - goto free; + goto remove_item; ret = o2net_register_handler(O2HB_NEGO_APPROVE_MSG, reg->hr_key, sizeof(struct o2hb_nego_msg),
@@ -2057,6 +2057,12 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g unregister_handler:o2net_unregister_handler_list (®->hr_handler_list); +remove_item: +spin_lock (&o2hb_live_lock); +list_del (®->hr_all_item); +if (o2hb_global_heartbeat_active ()) +clear_bit (reg->hr_region_num, o2hb_region_bitmap); +spin_unlock (&o2hb_live_lock); free:kfree (reg);return ERR_PTR (ret);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 546/775 mm: memcontrol: fix NR_ANON_THPS accounting in charge moving
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit b0ba3bff3e7bb6b58bb248bdd2f3d8ad52fd10c3 ]
Patch series "Convert all THP vmstat counters to pages", v6.
This patch series is aimed to convert all THP vmstat counters to pages.
The unit of some vmstat counters are pages, some are bytes, some are HPAGE_PMD_NR, and some are KiB. When we want to expose these vmstat counters to the userspace, we have to know the unit of the vmstat counters is which one. When the unit is bytes or kB, both clearly distinguishable by the B/KB suffix. But for the THP vmstat counters, we may make mistakes.
For example, the below is some bug fix for the THP vmstat counters:
- 7de2e9f195b9 ("mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg")
- The first commit in this series ("fix NR_ANON_THPS accounting in charge moving")
This patch series can make the code clear. And make all the unit of the THP vmstat counters in pages. Finally, the unit of the vmstat counters are pages, kB and bytes. The B/KB suffix can tell us that the unit is bytes or kB. The rest which is without suffix are pages.
In this series, I changed the following vmstat counters unit from HPAGE_PMD_NR to pages. However, there is no change to the print format of output to user space.
- NR_ANON_THPS
- NR_FILE_THPS
- NR_SHMEM_THPS
- NR_SHMEM_PMDMAPPED
- NR_FILE_PMDMAPPED
Doing this also can make the statistics more accuracy for the THP vmstat counters. This series is consistent with 8f182270dfec ("mm/swap.c: flush lru pvecs on compound page arrival").
Because we use struct per_cpu_nodestat to cache the vmstat counters, which leads to inaccurate statistics especially THP vmstat counters. In the systems with hundreds of processors it can be GBs of memory. For example, for a 96 CPUs system, the threshold is the maximum number of 125. And the per cpu counters can cache 23.4375 GB in total.
The THP page is already a form of batched addition (it will add 512 worth of memory in one go) so skipping the batching seems like sensible. Although every THP stats update overflows the per-cpu counter, resorting to atomic global updates. But it can make the statistics more accuracy for the THP vmstat counters. From this point of view, I think that do this converting is reasonable.
Thanks Hugh for mentioning this. This was inspired by Johannes and Roman. Thanks to them.
This patch (of 7):
The unit of NR_ANON_THPS is HPAGE_PMD_NR already. So it should inc/dec by one rather than nr_pages.
--- mm/memcontrol.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/memcontrol.c +2 -4
@@ -5637,10 +5637,8 @@ static int mem_cgroup_move_account(struct page *page,__mod_lruvec_state (from_vec,NR_ANON_MAPPED , -nr_pages);__mod_lruvec_state (to_vec,NR_ANON_MAPPED , nr_pages);if (PageTransHuge (page)) { -__mod_lruvec_state (from_vec,NR_ANON_THPS , - -nr_pages); -__mod_lruvec_state (to_vec,NR_ANON_THPS , - nr_pages); +__dec_lruvec_state (from_vec,NR_ANON_THPS ); +__inc_lruvec_state (to_vec,NR_ANON_THPS ); } }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 547/775 mm: memcontrol: fix slub memory accounting
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 96403bfe50c344b587ea53894954a9d152af1c9d ]
SLUB currently account kmalloc() and kmalloc_node() allocations larger than order-1 page per-node. But it forget to update the per-memcg vmstats. So it can lead to inaccurate statistics of "slab_unreclaimable" which is from memory.stat. Fix it by using mod_lruvec_page_state instead of mod_node_page_state.
--- mm/slab_common.c | 4 ++-- mm/slub.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
mm/slab_common.c +2 -2
@@ -837,8 +837,8 @@ void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) page =alloc_pages (flags, order);if (likely (page)) { ret =page_address (page); -mod_node_page_state (page_pgdat (page),NR_SLAB_UNRECLAIMABLE_B , -PAGE_SIZE << order); +mod_lruvec_page_state (page,NR_SLAB_UNRECLAIMABLE_B , +PAGE_SIZE << order); } ret =kasan_kmalloc_large (ret, size, flags);/* As ret might get tagged, call kmemleak hook after KASAN. */
mm/slub.c +4 -4
@@ -3999,8 +3999,8 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node) page =alloc_pages_node (node, flags, order);if (page) { ptr =page_address (page); -mod_node_page_state (page_pgdat (page),NR_SLAB_UNRECLAIMABLE_B , -PAGE_SIZE << order); +mod_lruvec_page_state (page,NR_SLAB_UNRECLAIMABLE_B , +PAGE_SIZE << order); }return kmalloc_large_node_hook (ptr, size, flags);
@@ -4131,8 +4131,8 @@ void kfree(const void *x)BUG_ON (!PageCompound (page));kfree_hook (object); -mod_node_page_state (page_pgdat (page),NR_SLAB_UNRECLAIMABLE_B , - -(PAGE_SIZE << order)); +mod_lruvec_page_state (page,NR_SLAB_UNRECLAIMABLE_B , + -(PAGE_SIZE << order));__free_pages (page, order);return ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 548/775 mm/memory.c: fix potential pte_unmap_unlock pte error
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit 90a3e375d324b2255b83e3dd29e99e2b05d82aaf ]
Since commit 42e4089c7890 ("x86/speculation/l1tf: Disallow non privileged high MMIO PROT_NONE mappings"), when the first pfn modify is not allowed, we would break the loop with pte unchanged. Then the wrong pte - 1 would be passed to pte_unmap_unlock.
Andi said:
"While the fix is correct, I'm not sure if it actually is a real bug.
Is there any architecture that would do something else than unlocking the underlying page? If it's just the underlying page then it should be always the same page, so no bug"
--- mm/memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/memory.c +3 -3
@@ -2165,11 +2165,11 @@ static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr, unsigned long end, unsigned long pfn, pgprot_t prot) { - pte_t *pte; + pte_t *pte, *mapped_pte;spinlock_t *ptl;int err =0 ; - pte =pte_alloc_map_lock (mm, pmd, addr, &ptl); + mapped_pte = pte =pte_alloc_map_lock (mm, pmd, addr, &ptl);if (!pte)return -ENOMEM ;arch_enter_lazy_mmu_mode ();
@@ -2183,7 +2183,7 @@ static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd, pfn++; }while (pte++, addr +=PAGE_SIZE , addr != end);arch_leave_lazy_mmu_mode (); -pte_unmap_unlock (pte -1 , ptl); +pte_unmap_unlock (mapped_pte, ptl);return err; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 549/775 mm/hugetlb: fix potential double free in hugetlb_register_node() error path
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit cc2205a67dec5a700227a693fc113441e73e4641 ]
In hugetlb_sysfs_add_hstate(), we would do kobject_put() on hstate_kobjs when failed to create sysfs group but forget to set hstate_kobjs to NULL. Then in hugetlb_register_node() error path, we may free it again via hugetlb_unregister_node().
--- mm/hugetlb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/hugetlb.c +3 -1
@@ -2988,8 +2988,10 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,return -ENOMEM ; retval =sysfs_create_group (hstate_kobjs[hi], hstate_attr_group); -if (retval) +if (retval) {kobject_put (hstate_kobjs[hi]); + hstate_kobjs[hi] =NULL ; + }return retval; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 550/775 mm/hugetlb: suppress wrong warning info when alloc gigantic page
In reply to Greg Kroah-HartmanFrom: Chen Wandun <[email protected]>
[ Upstream commit 7ecc956551f8a66618f71838c790a9b0b4f9ca10 ]
If hugetlb_cma is enabled, it will skip boot time allocation when allocating gigantic page, that doesn't means allocation failure, so suppress this warning info.
--- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/hugetlb.c +2 -2
@@ -2520,7 +2520,7 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)if (hstate_is_gigantic (h)) {if (hugetlb_cma_size) {pr_warn_once ("HugeTLB: hugetlb_cma is enabled, skip boot time allocation\n" ); -break ; + goto free; }if (!alloc_bootmem_huge_page (h))break ;
@@ -2538,7 +2538,7 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) h->max_huge_pages, buf, i); h->max_huge_pages = i; } - +free:kfree (node_alloc_noretry); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 551/775 mm/compaction: fix misbehaviors of fast_find_migrateblock()
In reply to Greg Kroah-HartmanFrom: Wonhyuk Yang <[email protected]>
[ Upstream commit 15d28d0d11609c7a4f217b3d85e26456d9beb134 ]
In the fast_find_migrateblock(), it iterates ocer the freelist to find the proper pageblock. But there are some misbehaviors.
First, if the page we found is equal to cc->migrate_pfn, it is considered that we didn't find a suitable pageblock. Secondly, if the loop was terminated because order is less than PAGE_ALLOC_COSTLY_ORDER, it could be considered that we found a suitable one. Thirdly, if the skip bit is set on the page block and we goto continue, it doesn't check nr_scanned. Fourthly, if the page block's skip bit is set, it checks that page block is the last of list, which is unnecessary.
--- mm/compaction.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
mm/compaction.c +12 -15
@@ -1702,6 +1702,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)unsigned long pfn = cc->migrate_pfn;unsigned long high_pfn;int order; +bool found_block = false;/* Skip hints are relied on to avoid repeats on the fast search */ if (cc->ignore_skip_hint)
@@ -1744,7 +1745,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) high_pfn =pageblock_start_pfn (cc->migrate_pfn + distance);for (order = cc->order -1 ; - order >=PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit; + order >=PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit; order--) {struct free_area *area = &cc->zone->free_area[order];struct list_head *freelist;
@@ -1759,7 +1760,11 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)list_for_each_entry (freepage, freelist, lru) {unsigned long free_pfn; - nr_scanned++; +if (nr_scanned++ >= limit) { +move_freelist_tail (freelist, freepage); +break ; + } + free_pfn =page_to_pfn (freepage);if (free_pfn < high_pfn) {/*
@@ -1768,12 +1773,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)* the list assumes an entry is deleted, not * reordered. */ -if (get_pageblock_skip (freepage)) { -if (list_is_last (freelist, &freepage->lru)) -break ; - +if (get_pageblock_skip (freepage))continue ; - }/* Reorder to so a future search skips recent pages */ move_freelist_tail (freelist, freepage);
@@ -1781,15 +1782,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)update_fast_start_pfn (cc, free_pfn); pfn =pageblock_start_pfn (free_pfn); cc->fast_search_fail =0 ; + found_block = true;set_pageblock_skip (freepage);break ; } - -if (nr_scanned >= limit) { - cc->fast_search_fail++; -move_freelist_tail (freelist, freepage); -break ; - } }spin_unlock_irqrestore (&cc->zone->lock, flags); }
@@ -1800,9 +1796,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)* If fast scanning failed then use a cached entry for a page block * that had free pages as the basis for starting a linear scan. */ -if (pfn == cc->migrate_pfn) +if (!found_block) { + cc->fast_search_fail++; pfn =reinit_migrate_pfn (cc); - + }return pfn; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 552/775 net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ8081
In reply to Greg Kroah-HartmanFrom: Christian Melki <[email protected]>
[ Upstream commit 764d31cacfe48440745c4bbb55a62ac9471c9f19 ]
Following a similar reinstate for the KSZ9031.
Older kernels would use the genphy_soft_reset if the PHY did not implement a .soft_reset.
Bluntly removing that default may expose a lot of situations where various PHYs/board implementations won't recover on various changes. Like with this implementation during a 4.9.x to 5.4.x LTS transition. I think it's a good thing to remove unwanted soft resets but wonder if it did open a can of worms?
Atleast this fixes one iMX6 FEC/RMII/8081 combo.
--- drivers/net/phy/micrel.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/micrel.c +1 -0
@@ -1295,6 +1295,7 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8081_type, .probe = kszphy_probe, .config_init = ksz8081_config_init, + .soft_reset = genphy_soft_reset, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 553/775 r8169: fix jumbo packet handling on RTL8168e
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 6cf739131a15e4177e58a1b4f2bede9d5da78552 ]
Josef reported [0] that using jumbo packets fails on RTL8168e. Aligning the values for register MaxTxPacketSize with the vendor driver fixes the problem.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=211827
--- drivers/net/ethernet/realtek/r8169_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +2 -2
@@ -2315,14 +2315,14 @@ static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp)static void r8168e_hw_jumbo_enable (struct rtl8169_private *tp) { -RTL_W8 (tp, MaxTxPacketSize,0x3f ); +RTL_W8 (tp, MaxTxPacketSize,0x24 );RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) | Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) |0x01 ); }static void r8168e_hw_jumbo_disable (struct rtl8169_private *tp) { -RTL_W8 (tp, MaxTxPacketSize,0x0c ); +RTL_W8 (tp, MaxTxPacketSize,0x3f );RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~0x01 ); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 554/775 NFSv4: Fixes for nfs4_bitmask_adjust()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 45901a231723a5a513ff08477983f3a274a6a910 ]
We don't want to ask for the ACL in a WRITE reply, since we don't have a preallocated buffer.
Instead of checking NFS_INO_INVALID_ACCESS, which is really about managing the access cache, we should look at the value of NFS_INO_INVALID_OTHER. Also ensure we assign the mode, owner and owner_group flags to the correct bit mask.
Finally, fix up the check for NFS_INO_INVALID_CTIME to retrieve the ctime, and add a check for NFS_INO_INVALID_CHANGE.
--- fs/nfs/nfs4proc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/nfs/nfs4proc.c +8 -7
@@ -5438,15 +5438,16 @@ static void nfs4_bitmask_adjust(__u32 *bitmask, struct inode *inode,if (cache_validity &NFS_INO_INVALID_ATIME ) bitmask[1 ] |=FATTR4_WORD1_TIME_ACCESS ; -if (cache_validity &NFS_INO_INVALID_ACCESS ) - bitmask[0 ] |=FATTR4_WORD1_MODE |FATTR4_WORD1_OWNER | -FATTR4_WORD1_OWNER_GROUP ; -if (cache_validity &NFS_INO_INVALID_ACL ) - bitmask[0 ] |=FATTR4_WORD0_ACL ; -if (cache_validity &NFS_INO_INVALID_LABEL ) +if (cache_validity &NFS_INO_INVALID_OTHER ) + bitmask[1 ] |=FATTR4_WORD1_MODE |FATTR4_WORD1_OWNER | +FATTR4_WORD1_OWNER_GROUP | +FATTR4_WORD1_NUMLINKS ; +if (label && label->len && cache_validity &NFS_INO_INVALID_LABEL ) bitmask[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; -if (cache_validity &NFS_INO_INVALID_CTIME ) +if (cache_validity &NFS_INO_INVALID_CHANGE ) bitmask[0 ] |=FATTR4_WORD0_CHANGE ; +if (cache_validity &NFS_INO_INVALID_CTIME ) + bitmask[1 ] |=FATTR4_WORD1_TIME_METADATA ;if (cache_validity &NFS_INO_INVALID_MTIME ) bitmask[1 ] |=FATTR4_WORD1_TIME_MODIFY ;if (cache_validity &NFS_INO_INVALID_SIZE )
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 555/775 KVM: SVM: Intercept INVPCID when its disabled to inject #UD
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 0a8ed2eaac102c746d8d114f2787f06cb3e55dfb ]
Intercept INVPCID if it's disabled in the guest, even when using NPT, as KVM needs to inject #UD in this case.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/svm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/svm/svm.c +4 -4
@@ -1105,12 +1105,12 @@ static u64 svm_write_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)static void svm_check_invpcid (struct vcpu_svm *svm) {/* -* Intercept INVPCID instruction only if shadow page table is -* enabled. Interception is not required with nested page table -* enabled. +* Intercept INVPCID if shadow paging is enabled to sync/free shadow +* roots, or if INVPCID is disabled in the guest to inject #UD. */ if (kvm_cpu_cap_has (X86_FEATURE_INVPCID )) { -if (!npt_enabled) +if (!npt_enabled || + !guest_cpuid_has (&svm->vcpu,X86_FEATURE_INVPCID ))svm_set_intercept (svm,INTERCEPT_INVPCID );else svm_clr_intercept (svm,INTERCEPT_INVPCID );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 556/775 KVM: x86/mmu: Expand collapsible SPTE zap for TDP MMU to ZONE_DEVICE and HugeTLB pages
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit c060c72ffeb448fbb5864faa1f672ebfe14dd25f ]
Zap SPTEs that are backed by ZONE_DEVICE pages when zappings SPTEs to rebuild them as huge pages in the TDP MMU. ZONE_DEVICE huge pages are managed differently than "regular" pages and are not compound pages. Likewise, PageTransCompoundMap() will not detect HugeTLB, so switch to PageCompound().
This matches the similar check in kvm_mmu_zap_collapsible_spte.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/tdp_mmu.c +2 -1
@@ -1067,7 +1067,8 @@ static void zap_collapsible_spte_range(struct kvm *kvm, pfn =spte_to_pfn (iter.old_spte);if (kvm_is_reserved_pfn (pfn) || - !PageTransCompoundMap (pfn_to_page (pfn))) + (!PageCompound (pfn_to_page (pfn)) && + !kvm_is_zone_device_pfn (pfn)))continue ;tdp_mmu_set_spte (kvm, &iter,0 );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 557/775 cifs: Fix inconsistent IS_ERR and PTR_ERR
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit af982da9a612295a91f367469f8945c916a20dfd ]
Fix inconsistent IS_ERR and PTR_ERR in cifs_find_swn_reg(). The proper pointer to be passed as argument to PTR_ERR() is share_name.
This bug was detected with the help of Coccinelle.
--- fs/cifs/cifs_swn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifs_swn.c +1 -1
@@ -272,7 +272,7 @@ static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)if (IS_ERR (share_name)) {int ret; - ret =PTR_ERR (net_name); + ret =PTR_ERR (share_name);cifs_dbg (VFS ,"%s: failed to extract share name from target '%s': %d\n" , __func__, tcon->treeName, ret);kfree (net_name);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 558/775 arm64: Add missing ISB after invalidating TLB in __primary_switch
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 9d41053e8dc115c92b8002c3db5f545d7602498b ]
Although there has been a bit of back and forth on the subject, it appears that invalidating TLBs requires an ISB instruction when FEAT_ETS is not implemented by the CPU.
Quoted 1 line
From the bible:
| In an implementation that does not implement FEAT_ETS, a TLB | maintenance instruction executed by a PE, PEx, can complete at any | time after it is issued, but is only guaranteed to be finished for a | PE, PEx, after the execution of DSB by the PEx followed by a Context | synchronization event
Add the missing ISB in __primary_switch, just in case.
--- arch/arm64/kernel/head.S | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/head.S +1 -0
@@ -882,6 +882,7 @@ SYM_FUNC_START_LOCAL(__primary_switch) tlbi vmalle1 // Remove any stale TLB entries dsb nsh + isb msr sctlr_el1, x19 // re-enable the MMU isb
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 559/775 i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
[ Upstream commit a1858ce0cfe31368b23ba55794e409fb57ced4a4 ]
The brcmstb_send_i2c_cmd currently has a condition that is (CMD_RD || CMD_WR) which always evaluates to true, while the obvious fix is to test whether the cmd variable passed as parameter holds one of these two values.
--- drivers/i2c/busses/i2c-brcmstb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-brcmstb.c +1 -1
@@ -316,7 +316,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, goto cmd_out; } -if ((CMD_RD ||CMD_WR ) && +if ((cmd ==CMD_RD || cmd ==CMD_WR ) &&bsc_readl (dev, iic_enable) &BSC_IIC_EN_NOACK_MASK ) { rc = -EREMOTEIO ; dev_dbg(dev->device, "controller received NOACK intr for %s\n",
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 560/775 i2c: exynos5: Preserve high speed master code
In reply to Greg Kroah-HartmanFrom: Mårten Lindahl <[email protected]>
[ Upstream commit f4ff0104d4c807a7f96aa3358c03d694895ee8ea ]
When the driver starts to send a message with the MASTER_ID field set (high speed), the whole I2C_ADDR register is overwritten including MASTER_ID as the SLV_ADDR_MAS field is set.
This patch preserves already written fields in I2C_ADDR when writing SLV_ADDR_MAS.
--- drivers/i2c/busses/i2c-exynos5.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-exynos5.c +7 -1
@@ -606,6 +606,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop)u32 i2c_ctl;u32 int_en =0 ;u32 i2c_auto_conf =0 ; +u32 i2c_addr =0 ;u32 fifo_ctl;unsigned long flags;unsigned short trig_lvl;
@@ -640,7 +641,12 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) int_en |=HSI2C_INT_TX_ALMOSTEMPTY_EN ; } -writel (HSI2C_SLV_ADDR_MAS (i2c->msg->addr), i2c->regs +HSI2C_ADDR ); + i2c_addr =HSI2C_SLV_ADDR_MAS (i2c->msg->addr); + +if (i2c->op_clock >=I2C_MAX_FAST_MODE_PLUS_FREQ ) + i2c_addr |=HSI2C_MASTER_ID (MASTER_ID (i2c->adap.nr)); + +writel (i2c_addr, i2c->regs +HSI2C_ADDR );writel (fifo_ctl, i2c->regs +HSI2C_FIFO_CTL );writel (i2c_ctl, i2c->regs +HSI2C_CTL );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 561/775 mm,thp,shmem: make khugepaged obey tmpfs mount flags
In reply to Greg Kroah-HartmanFrom: Rik van Riel <[email protected]>
[ Upstream commit cd89fb06509903f942a0ffe97ffa63034671ed0c ]
Currently if thp enabled=[madvise], mounting a tmpfs filesystem with huge=always and mmapping files from that tmpfs does not result in khugepaged collapsing those mappings, despite the mount flag indicating that it should.
Fix that by breaking up the blocks of tests in hugepage_vma_check a little bit, and testing things in the correct order.
--- include/linux/khugepaged.h | 2 ++ mm/khugepaged.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)
include/linux/khugepaged.h +2 -0
@@ -3,6 +3,7 @@#define _LINUX_KHUGEPAGED_H#include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */ +#include <linux/shmem_fs.h> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -57,6 +58,7 @@ static inline int khugepaged_enter(struct vm_area_struct *vma, {if (!test_bit (MMF_VM_HUGEPAGE , &vma->vm_mm->flags))if ((khugepaged_always () || + (shmem_file (vma->vm_file) &&shmem_huge_enabled (vma)) || (khugepaged_req_madv () && (vm_flags &VM_HUGEPAGE ))) && !(vm_flags &VM_NOHUGEPAGE ) && !test_bit (MMF_DISABLE_THP , &vma->vm_mm->flags))
mm/khugepaged.c +16 -6
@@ -442,18 +442,28 @@ static inline int khugepaged_test_exit(struct mm_struct *mm)static bool hugepage_vma_check (struct vm_area_struct *vma,unsigned long vm_flags) { -if ((!(vm_flags &VM_HUGEPAGE ) && !khugepaged_always ()) || - (vm_flags &VM_NOHUGEPAGE ) || +/* Explicitly disabled through madvise. */ +if ((vm_flags &VM_NOHUGEPAGE ) ||test_bit (MMF_DISABLE_THP , &vma->vm_mm->flags))return false; -if (shmem_file (vma->vm_file) || - (IS_ENABLED (CONFIG_READ_ONLY_THP_FOR_FS ) && - vma->vm_file && - (vm_flags &VM_DENYWRITE ))) { +/* Enabled via shmem mount options or sysfs settings. */ +if (shmem_file (vma->vm_file) &&shmem_huge_enabled (vma)) {return IS_ALIGNED ((vma->vm_start >>PAGE_SHIFT ) - vma->vm_pgoff,HPAGE_PMD_NR ); } + +/* THP settings require madvise. */ +if (!(vm_flags &VM_HUGEPAGE ) && !khugepaged_always ()) +return false; + +/* Read-only file mappings need to be aligned for THP to work. */ +if (IS_ENABLED (CONFIG_READ_ONLY_THP_FOR_FS ) && vma->vm_file && + (vm_flags &VM_DENYWRITE )) { +return IS_ALIGNED ((vma->vm_start >>PAGE_SHIFT ) - vma->vm_pgoff, +HPAGE_PMD_NR ); + } +if (!vma->anon_vma || vma->vm_ops)return false;if (vma_is_temporary_stack (vma))
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 562/775 mm: fix memory_failure() handling of dax-namespace metadata
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit 34dc45be4563f344d59ba0428416d0d265aa4f4d ]
Given 'struct dev_pagemap' spans both data pages and metadata pages be careful to consult the altmap if present to delineate metadata. In fact the pfn_first() helper already identifies the first valid data pfn, so export that helper for other code paths via pgmap_pfn_valid().
Other usage of get_dev_pagemap() are not a concern because those are operating on known data pfns having been looked up by get_user_pages(). I.e. metadata pfns are never user mapped.
--- include/linux/memremap.h | 6 ++++++ mm/memory-failure.c | 6 ++++++ mm/memremap.c | 15 +++++++++++++++ 3 files changed, 27 insertions(+)
include/linux/memremap.h +6 -0
@@ -137,6 +137,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);void devm_memunmap_pages (struct device *dev,struct dev_pagemap *pgmap);struct dev_pagemap *get_dev_pagemap (unsigned long pfn,struct dev_pagemap *pgmap); +bool pgmap_pfn_valid (struct dev_pagemap *pgmap,unsigned long pfn);unsigned long vmem_altmap_offset (struct vmem_altmap *altmap);void vmem_altmap_free (struct vmem_altmap *altmap,unsigned long nr_pfns);
@@ -165,6 +166,11 @@ static inline struct dev_pagemap *get_dev_pagemap(unsigned long pfn,return NULL ; } +static inline bool pgmap_pfn_valid (struct dev_pagemap *pgmap,unsigned long pfn) +{ +return false; +} +static inline unsigned long vmem_altmap_offset (struct vmem_altmap *altmap) {return 0 ;
mm/memory-failure.c +6 -0
@@ -1308,6 +1308,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,*/ put_page (page); +/* device metadata space is not recoverable */ +if (!pgmap_pfn_valid (pgmap, pfn)) { + rc = -ENXIO ; + goto out; + } +/* * Prevent the inode from being freed while we are interrogating * the address_space, typically this would be handled by
mm/memremap.c +15 -0
@@ -80,6 +80,21 @@ static unsigned long pfn_first(struct dev_pagemap *pgmap, int range_id)return pfn +vmem_altmap_offset (pgmap_altmap (pgmap)); } +bool pgmap_pfn_valid (struct dev_pagemap *pgmap,unsigned long pfn) +{ +int i; + +for (i =0 ; i < pgmap->nr_range; i++) { +struct range *range = &pgmap->ranges[i]; + +if (pfn >=PHYS_PFN (range->start) && + pfn <=PHYS_PFN (range->end)) +return pfn >=pfn_first (pgmap, i); + } + +return false; +} +static unsigned long pfn_end (struct dev_pagemap *pgmap,int range_id) {const struct range *range = &pgmap->ranges[range_id];
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 563/775 mm/rmap: fix potential pte_unmap on an not mapped pte
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit 5d5d19eda6b0ee790af89c45e3f678345be6f50f ]
For PMD-mapped page (usually THP), pvmw->pte is NULL. For PTE-mapped THP, pvmw->pte is mapped. But for HugeTLB pages, pvmw->pte is not mapped and set to the relevant page table entry. So in page_vma_mapped_walk_done(), we may do pte_unmap() for HugeTLB pte which is not mapped. Fix this by checking pvmw->page against PageHuge before trying to do pte_unmap().
--- include/linux/rmap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/rmap.h +2 -1
@@ -213,7 +213,8 @@ struct page_vma_mapped_walk {static inline void page_vma_mapped_walk_done (struct page_vma_mapped_walk *pvmw) { -if (pvmw->pte) +/* HugeTLB pte is set to the relevant page table entry without pte_mapped. */ +if (pvmw->pte && !PageHuge (pvmw->page))pte_unmap (pvmw->pte);if (pvmw->ptl)spin_unlock (pvmw->ptl);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 564/775 proc: use kvzalloc for our kernel buffer
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 4508943794efdd94171549c0bd52810e2f4ad9fe ]
Since
sysctl: pass kernel pointers to ->proc_handler
we have been pre-allocating a buffer to copy the data from the proc handlers into, and then copying that to userspace. The problem is this just blindly kzalloc()'s the buffer size passed in from the read, which in the case of our 'cat' binary was 64kib. Order-4 allocations are not awesome, and since we can potentially allocate up to our maximum order, so use kvzalloc for these buffers.
[[email protected]: changelog tweaks]
--- fs/proc/proc_sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/proc_sysctl.c +2 -2
@@ -571,7 +571,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter, error = -ENOMEM ;if (count >=KMALLOC_MAX_SIZE ) goto out; - kbuf =kzalloc (count +1 ,GFP_KERNEL ); + kbuf =kvzalloc (count +1 ,GFP_KERNEL );if (!kbuf) goto out;
@@ -600,7 +600,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter, error = count; out_free_buf: -kfree (kbuf); +kvfree (kbuf); out:sysctl_head_finish (head);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 565/775 csky: Fix a size determination in gpr_get()
In reply to Greg Kroah-HartmanFrom: Zhenzhong Duan <[email protected]>
[ Upstream commit 8bfb676492da208bd6dde0f22dff79840dbb5051 ]
"*" is missed in size determination as we are passing register set rather than a pointer.
--- arch/csky/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/csky/kernel/ptrace.c +1 -1
@@ -83,7 +83,7 @@ static int gpr_get(struct task_struct *target,/* Abiv1 regs->tls is fake and we need sync here. */ regs->tls =task_thread_info (target)->tp_value; -return membuf_write (&to, regs,sizeof (regs)); +return membuf_write (&to, regs,sizeof (*regs)); } static int gpr_set(struct task_struct *target,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 566/775 scsi: bnx2fc: Fix Kconfig warning & CNIC build errors
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit eefb816acb0162e94a85a857f3a55148f671d5a5 ]
CNIC depends on MMU, but since 'select' does not follow any dependency chains, SCSI_BNX2X_FCOE also needs to depend on MMU, so that erroneous configs are not generated, which cause build errors in cnic.
WARNING: unmet direct dependencies detected for CNIC
Depends on [n]: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_BROADCOM [=y] && PCI [=y] && (IPV6 [=n] || IPV6 [=n]=n) && MMU [=n] Selected by [y]:
- SCSI_BNX2X_FCOE [=y] && SCSI_LOWLEVEL [=y] && SCSI [=y] && PCI [=y] && (IPV6 [=n] || IPV6 [=n]=n) && LIBFC [=y] && LIBFCOE [=y]
riscv64-linux-ld: drivers/net/ethernet/broadcom/cnic.o: in function `.L154':
cnic.c:(.text+0x1094): undefined reference to `uio_event_notify'
riscv64-linux-ld: cnic.c:(.text+0x10bc): undefined reference to `uio_event_notify'
riscv64-linux-ld: drivers/net/ethernet/broadcom/cnic.o: in function `.L1442':
cnic.c:(.text+0x96a8): undefined reference to `__uio_register_device'
riscv64-linux-ld: drivers/net/ethernet/broadcom/cnic.o: in function `.L0 ':
cnic.c:(.text.unlikely+0x68): undefined reference to `uio_unregister_device'
--- drivers/scsi/bnx2fc/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/bnx2fc/Kconfig +1 -0
@@ -5,6 +5,7 @@ config SCSI_BNX2X_FCOE depends on (IPV6 || IPV6=n) depends on LIBFC depends on LIBFCOE + depends on MMU select NETDEVICES select ETHERNET select NET_VENDOR_BROADCOM
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 567/775 scsi: sd: sd_zbc: Dont pass GFP_NOIO to kvcalloc
In reply to Greg Kroah-HartmanFrom: Johannes Thumshirn <[email protected]>
[ Upstream commit 9acced3f58ad24407c1f9ebf53a8892c1e24cdb5 ]
Dan reported we're passing in GFP_NOIO to kvmalloc() which will then fallback to doing kmalloc() instead of an optional vmalloc() if the size exceeds kmalloc()s limits. This will break with drives that have zone numbers exceeding PAGE_SIZE/sizeof(u32).
Instead of passing in GFP_NOIO, enter an implicit GFP_NOIO allocation scope.
--- drivers/scsi/sd_zbc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/sd_zbc.c +5 -1
@@ -688,6 +688,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)unsigned int nr_zones = sdkp->rev_nr_zones;u32 max_append;int ret =0 ; +unsigned int flags;/* * For all zoned disks, initialize zone append emulation data if not
@@ -720,16 +721,19 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) disk->queue->nr_zones == nr_zones) goto unlock; + flags =memalloc_noio_save (); sdkp->zone_blocks = zone_blocks; sdkp->nr_zones = nr_zones; - sdkp->rev_wp_offset =kvcalloc (nr_zones,sizeof (u32),GFP_NOIO ); + sdkp->rev_wp_offset =kvcalloc (nr_zones,sizeof (u32),GFP_KERNEL );if (!sdkp->rev_wp_offset) { ret = -ENOMEM ; +memalloc_noio_restore (flags); goto unlock; } ret =blk_revalidate_disk_zones (disk, sd_zbc_revalidate_zones_cb); +memalloc_noio_restore (flags);kvfree (sdkp->rev_wp_offset); sdkp->rev_wp_offset =NULL ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 568/775 block: reopen the device in blkdev_reread_part
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 4601b4b130de2329fe06df80ed5d77265f2058e5 ]
Historically the BLKRRPART ioctls called into the now defunct ->revalidate method, which caused the sd driver to check if any media is present. When the ->revalidate method was removed this revalidation was lost, leading to lots of I/O errors when using the eject command. Fix this by reopening the device to rescan the partitions, and thus calling the revalidation logic in the sd driver.
--- block/ioctl.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
block/ioctl.c +14 -7
@@ -81,20 +81,27 @@ static int compat_blkpg_ioctl(struct block_device *bdev, }#endif -static int blkdev_reread_part (struct block_device *bdev) +static int blkdev_reread_part (struct block_device *bdev,fmode_t mode) { -int ret; +struct block_device *tmp;if (!disk_part_scan_enabled (bdev->bd_disk) ||bdev_is_partition (bdev))return -EINVAL ;if (!capable (CAP_SYS_ADMIN ))return -EACCES ; -mutex_lock (&bdev->bd_mutex); - ret =bdev_disk_changed (bdev, false); -mutex_unlock (&bdev->bd_mutex); +/* +* Reopen the device to revalidate the driver state and force a +* partition rescan. +*/ + mode &= ~FMODE_EXCL ; +set_bit (GD_NEED_PART_SCAN , &bdev->bd_disk->state); -return ret; + tmp =blkdev_get_by_dev (bdev->bd_dev, mode,NULL ); +if (IS_ERR (tmp)) +return PTR_ERR (tmp); +blkdev_put (tmp, mode); +return 0 ; } static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
@@ -498,7 +505,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, bdev->bd_bdi->ra_pages = (arg *512 ) /PAGE_SIZE ;return 0 ;case BLKRRPART : -return blkdev_reread_part (bdev); +return blkdev_reread_part (bdev, mode);case BLKTRACESTART :case BLKTRACESTOP :case BLKTRACETEARDOWN :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 569/775 block: fix logging on capacity change
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 452c0bf8754fbeffdf579465b82a3c2bbe373c95 ]
Local variable of 'capacity' stores the previous disk capacity, and 'size' variable records the latest disk capacity, so swap them for fixing logging on capacity change.
--- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
@@ -74,7 +74,7 @@ bool set_capacity_and_notify(struct gendisk *disk, sector_t size)return false;pr_info ("%s: detected capacity change from %lld to %lld\n" , - disk->disk_name, size, capacity); + disk->disk_name, capacity, size);/* * Historically we did not send a uevent for changes to/from an empty
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 570/775 ide/falconide: Fix module unload
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit 07f1dc8cc85bbfb2f9270f25060c4755f4509f45 ]
Unloading the falconide module results in a crash:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 Oops: 00000000 Modules linked in: falconide(-) PC: [<002930b2>] ide_host_remove+0x2e/0x1d2 SR: 2000 SP: 00b49e28 a2: 009b0f90 d0: 00000000 d1: 009b0f90 d2: 00000000 d3: 00b48000 d4: 003cef32 d5: 00299188 a0: 0086d000 a1: 0086d000
Process rmmod (pid: 322, task=009b0f90)
Frame format=7 eff addr=00000000 ssw=0505 faddr=00000000 wb 1 stat/addr/data: 0000 00000000 00000000
wb 2 stat/addr/data: 0000 00000000 00000000
wb 3 stat/addr/data: 0000 00000000 00018da9 push data: 00000000 00000000 00000000 00000000 Stack from 00b49e90:
004c456a 0027f176 0027cb0a 0027cb9e 00000000 0086d00a 2187d3f0 0027f0e0
00b49ebc 2187d1f6 00000000 00b49ec8 002811e8 0086d000 00b49ef0 0028024c
0086d00a 002800d6 00279a1a 00000001 00000001 0086d00a 2187d3f0 00279a58
00b49f1c 002802e0 0086d00a 2187d3f0 004c456a 0086d00a ef96af74 00000000
2187d3f0 002805d2 800de064 00b49f44 0027f088 2187d3f0 00ac1cf4 2187d3f0
004c43be 2187d3f0 00000000 2187d3f0 800b66a8 00b49f5c 00280776 2187d3f0
Call Trace: [<0027f176>] __device_driver_unlock+0x0/0x48
[<0027cb0a>] device_links_busy+0x0/0x94
[<0027cb9e>] device_links_unbind_consumers+0x0/0x130
[<0027f0e0>] __device_driver_lock+0x0/0x5a
[<2187d1f6>] falconide_remove+0x12/0x18 [falconide]
[<002811e8>] platform_drv_remove+0x1c/0x28
[<0028024c>] device_release_driver_internal+0x176/0x17c
[<002800d6>] device_release_driver_internal+0x0/0x17c
[<00279a1a>] get_device+0x0/0x22
[<00279a58>] put_device+0x0/0x18
[<002802e0>] driver_detach+0x56/0x82
[<002805d2>] driver_remove_file+0x0/0x24
[<0027f088>] bus_remove_driver+0x4c/0xa4
[<00280776>] driver_unregister+0x28/0x5a
[<00281a00>] platform_driver_unregister+0x12/0x18
[<2187d2a0>] ide_falcon_driver_exit+0x10/0x16 [falconide]
[<000764f0>] sys_delete_module+0x110/0x1f2
[<000e83ea>] sys_rename+0x1a/0x1e
[<00002e0c>] syscall+0x8/0xc
[<00188004>] ext4_multi_mount_protect+0x35a/0x3ce
Code: 0029 9188 4bf9 0027 aa1c 283c 003c ef32 <265c> 4a8b 6700 00b8 2043 2028 000c 0280 00ff ff00 6600 0176 40c0 7202 b2b9 004cDisabling lock debugging due to kernel taint
This happens because the driver_data pointer is uninitialized. Add the missing platform_set_drvdata() call. For clarity, use the matching platform_get_drvdata() as well.
--- drivers/ide/falconide.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ide/falconide.c +2 -1
@@ -164,6 +164,7 @@ static int __init falconide_init(struct platform_device *pdev)if (rc) goto err_free; +platform_set_drvdata (pdev, host);return 0 ; err_free:ide_host_free (host);
@@ -174,7 +175,7 @@ err:static int falconide_remove (struct platform_device *pdev) { -struct ide_host *host =dev_get_drvdata (&pdev->dev); +struct ide_host *host =platform_get_drvdata (pdev);ide_host_remove (host);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 571/775 scsi: sd: Fix Opal support
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit aaf15f8c6de932861f1fce6aeec6a89ac0e354b6 upstream.
The SCSI core has been modified recently such that it only processes PM requests if rpm_status != RPM_ACTIVE. Since some Opal requests are submitted while rpm_status != RPM_ACTIVE, set flag RQF_PM for Opal requests.
See also https://bugzilla.kernel.org/show_bug.cgi?id=211227.
[mkp: updated sha for PM patch]
--- drivers/scsi/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/sd.c +3 -3
@@ -707,9 +707,9 @@ static int sd_sec_submit(void *data, u16put_unaligned_be16 (spsp, &cdb[2 ]);put_unaligned_be32 (len, &cdb[6 ]); - ret =scsi_execute_req (sdev, cdb, - send ?DMA_TO_DEVICE :DMA_FROM_DEVICE , - buffer, len,NULL ,SD_TIMEOUT , sdkp->max_retries,NULL ); + ret =scsi_execute (sdev, cdb, send ?DMA_TO_DEVICE :DMA_FROM_DEVICE , + buffer, len,NULL ,NULL ,SD_TIMEOUT , sdkp->max_retries,0 , +RQF_PM ,NULL ); return ret <= 0 ? ret : -EIO; }#endif /* CONFIG_BLK_SED_OPAL */
Greg Kroah-Hartman
maintainerPATCH 572/775 blk-settings: align max_sectors on "logical_block_size" boundary
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 97f433c3601a24d3513d06f575a389a2ca4e11e4 upstream.
We get I/O errors when we run md-raid1 on the top of dm-integrity on the top of ramdisk.
device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1
device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8048, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8147, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8246, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8345, 0xbb
The ramdisk device has logical_block_size 512 and max_sectors 255. The dm-integrity device uses logical_block_size 4096 and it doesn't affect the "max_sectors" value - thus, it inherits 255 from the ramdisk. So, we have a device with max_sectors not aligned on logical_block_size.
The md-raid device sees that the underlying leg has max_sectors 255 and it will split the bios on 255-sector boundary, making the bios unaligned on logical_block_size.
In order to fix the bug, we round down max_sectors to logical_block_size.
--- block/blk-settings.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
block/blk-settings.c +12 -0
@@ -481,6 +481,14 @@ void blk_queue_io_opt(struct request_que }EXPORT_SYMBOL (blk_queue_io_opt); +static unsigned int blk_round_down_sectors (unsigned int sectors,unsigned int lbs) +{ + sectors =round_down (sectors, lbs >>SECTOR_SHIFT ); +if (sectors <PAGE_SIZE >>SECTOR_SHIFT ) + sectors =PAGE_SIZE >>SECTOR_SHIFT ; +return sectors; +} +/** * blk_stack_limits - adjust queue_limits for stacked devices * @t: the stacking driver limits (top device)
@@ -607,6 +615,10 @@ int blk_stack_limits(struct queue_limits ret =-1 ; } + t->max_sectors =blk_round_down_sectors (t->max_sectors, t->logical_block_size); + t->max_hw_sectors =blk_round_down_sectors (t->max_hw_sectors, t->logical_block_size); + t->max_dev_sectors =blk_round_down_sectors (t->max_dev_sectors, t->logical_block_size); +/* Discard alignment and granularity */ if (b->discard_granularity) { alignment =queue_limit_discard_alignment (b, start);
Greg Kroah-Hartman
maintainerPATCH 573/775 soundwire: intel: fix possible crash when no device is detected
In reply to Greg Kroah-HartmanFrom: Marcin Ślusarz <[email protected]>
commit 957e3f797917b36355766807b1d8a54a1ba0cfc9 upstream.
acpi_walk_namespace can return success without executing our callback which initializes info->handle.
If the random value in this structure is a valid address (which is on the stack, so it's quite possible), then nothing bad will happen, because:sdw_intel_scan_controller
-> acpi_bus_get_device
-> acpi_get_device_data
-> acpi_get_data_full
-> acpi_ns_validate_handle
will reject this handle.
However, if the value from the stack doesn't point to a valid address, we get this:
BUG: kernel NULL pointer dereference, address: 0000000000000050 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 6 PID: 472 Comm: systemd-udevd Tainted: G W 5.10.0-1-amd64 #1 Debian 5.10.4-1 Hardware name: HP HP Pavilion Laptop 15-cs3xxx/86E2, BIOS F.05 01/01/2020 RIP: 0010:acpi_ns_validate_handle+0x1a/0x23 Code: 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 1f 44 00 00 48 8d 57 ff 48 89 f8 48 83 fa fd 76 08 48 8b 05 0c b8 67 01 c3 <80> 7f 08 0f 74 02 31 c0 c3 0f 1f 44 00 00 48 8b 3d f6 b7 67 01 e8 RSP: 0000:ffffc388807c7b20 EFLAGS: 00010213 RAX: 0000000000000048 RBX: ffffc388807c7b70 RCX: 0000000000000000 RDX: 0000000000000047 RSI: 0000000000000246 RDI: 0000000000000048 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffffc0f5f4d1 R11: ffffffff8f0cb268 R12: 0000000000001001 R13: ffffffff8e33b160 R14: 0000000000000048 R15: 0000000000000000 FS: 00007f24548288c0(0000) GS:ffff9f781fb80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000050 CR3: 0000000106158004 CR4: 0000000000770ee0 PKRU: 55555554 Call Trace: acpi_get_data_full+0x4d/0x92 acpi_bus_get_device+0x1f/0x40 sdw_intel_acpi_scan+0x59/0x230 [soundwire_intel] ? strstr+0x22/0x60 ? dmi_matches+0x76/0xe0 snd_intel_dsp_driver_probe.cold+0xaf/0x163 [snd_intel_dspcfg] azx_probe+0x7a/0x970 [snd_hda_intel] local_pci_probe+0x42/0x80 ? _cond_resched+0x16/0x40 pci_device_probe+0xfd/0x1b0 really_probe+0x205/0x460 driver_probe_device+0xe1/0x150 device_driver_attach+0xa1/0xb0 __driver_attach+0x8a/0x150 ? device_driver_attach+0xb0/0xb0 ? device_driver_attach+0xb0/0xb0 bus_for_each_dev+0x78/0xc0 bus_add_driver+0x12b/0x1e0 driver_register+0x8b/0xe0 ? 0xffffffffc0f65000 do_one_initcall+0x44/0x1d0 ? do_init_module+0x23/0x250 ? kmem_cache_alloc_trace+0xf5/0x200 do_init_module+0x5c/0x250 __do_sys_finit_module+0xb1/0x110 do_syscall_64+0x33/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/soundwire/intel_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soundwire/intel_init.c +2 -1
@@ -405,11 +405,12 @@ int sdw_intel_acpi_scan(acpi_handle *par {acpi_status status; + info->handle =NULL ; status =acpi_walk_namespace (ACPI_TYPE_DEVICE , parent_handle,1 , sdw_intel_acpi_cb,NULL , info,NULL ); -if (ACPI_FAILURE (status)) +if (ACPI_FAILURE (status) || info->handle ==NULL )return -ENODEV ;return sdw_intel_scan_controller (info);
Greg Kroah-Hartman
maintainerPATCH 574/775 ACPI: property: Fix fwnode string properties matching
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit e1e6bd2995ac0e1ad0c2a2d906a06f59ce2ed293 upstream.
Property matching does not work for ACPI fwnodes if the value of the given property is not represented as a package in the _DSD package containing it. For example, the "compatible" property in the _DSD below
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () {"compatible", "ethernet-phy-ieee802.3-c45"}
}
})will not be found by fwnode_property_match_string(), because the ACPI code handling device properties does not regard the single value as a "list" in that case.
Namely, fwnode_property_match_string() invoked to match a given string property value first calls fwnode_property_read_string_array() with the last two arguments equal to NULL and 0, respectively, in order to count the items in the value of the given property, with the assumption that this value may be an array. For ACPI fwnodes, that operation is carried out by acpi_node_prop_read() which calls acpi_data_prop_read() for this purpose. However, when the return (val) pointer is NULL, that function only looks for a property whose value is a package without checking the single-value case at all.
To fix that, make acpi_data_prop_read() check the single-value case if its return pointer argument is NULL and modify acpi_data_prop_read_single() handling that case to attempt to read the value of the property if the return pointer is NULL and return 1 if that succeeds.
--- drivers/acpi/property.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-)
drivers/acpi/property.c +33 -11
@@ -787,9 +787,6 @@ static int acpi_data_prop_read_single(coconst union acpi_object *obj;int ret; -if (!val) -return -EINVAL ; -if (proptype >=DEV_PROP_U8 && proptype <=DEV_PROP_U64 ) { ret =acpi_data_get_property (data, propname,ACPI_TYPE_INTEGER , &obj);if (ret)
@@ -799,28 +796,43 @@ static int acpi_data_prop_read_single(cocase DEV_PROP_U8 :if (obj->integer.value >U8_MAX )return -EOVERFLOW ; - *(u8 *)val = obj->integer.value; + +if (val) + *(u8 *)val = obj->integer.value; +break ;case DEV_PROP_U16 :if (obj->integer.value >U16_MAX )return -EOVERFLOW ; - *(u16 *)val = obj->integer.value; + +if (val) + *(u16 *)val = obj->integer.value; +break ;case DEV_PROP_U32 :if (obj->integer.value >U32_MAX )return -EOVERFLOW ; - *(u32 *)val = obj->integer.value; + +if (val) + *(u32 *)val = obj->integer.value; +break ;default : - *(u64 *)val = obj->integer.value; +if (val) + *(u64 *)val = obj->integer.value; +break ; } + +if (!val) +return 1 ; }else if (proptype ==DEV_PROP_STRING ) { ret =acpi_data_get_property (data, propname,ACPI_TYPE_STRING , &obj);if (ret)return ret; - *(char **)val = obj->string.pointer; +if (val) + *(char **)val = obj->string.pointer;return 1 ; }else {
@@ -834,7 +846,7 @@ int acpi_dev_prop_read_single(struct acp {int ret; -if (!adev) +if (!adev || !val)return -EINVAL ; ret =acpi_data_prop_read_single (&adev->data, propname, proptype, val);
@@ -928,10 +940,20 @@ static int acpi_data_prop_read(const strconst union acpi_object *items;int ret; -if (val && nval ==1 ) { +if (nval ==1 || !val) { ret =acpi_data_prop_read_single (data, propname, proptype, val); -if (ret >=0 ) +/* +* The overflow error means that the property is there and it is +* single-value, but its type does not match, so return. +*/ +if (ret >=0 || ret == -EOVERFLOW )return ret; + +/* +* Reading this property as a single-value one failed, but its +* value may still be represented as one-element array, so +* continue. +*/ } ret =acpi_data_get_property_array (data, propname,ACPI_TYPE_ANY , &obj);
Greg Kroah-Hartman
maintainerPATCH 575/775 ACPI: configfs: add missing check after configfs_register_default_group()
In reply to Greg Kroah-HartmanFrom: Qinglang Miao <[email protected]>
commit 67e40054de86aae520ddc2a072d7f6951812a14f upstream.
A list_add corruption is reported by Hulk Robot like this:
==============list_add corruption.
Call Trace: link_obj+0xc0/0x1c0 link_group+0x21/0x140 configfs_register_subsystem+0xdb/0x380 acpi_configfs_init+0x25/0x1000 [acpi_configfs] do_one_initcall+0x149/0x820 do_init_module+0x1ef/0x720 load_module+0x35c8/0x4380 __do_sys_finit_module+0x10d/0x1a0 do_syscall_64+0x34/0x80
It's because of the missing check after configfs_register_default_group, where configfs_unregister_subsystem should be called once failure.
--- drivers/acpi/acpi_configfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/acpi/acpi_configfs.c +6 -1
@@ -268,7 +268,12 @@ static int __init acpi_configfs_init(voi acpi_table_group =configfs_register_default_group (root,"table" , &acpi_tables_type); -return PTR_ERR_OR_ZERO (acpi_table_group); +if (IS_ERR (acpi_table_group)) { +configfs_unregister_subsystem (&acpi_configfs); +return PTR_ERR (acpi_table_group); + } + +return 0 ; }module_init (acpi_configfs_init);
Greg Kroah-Hartman
maintainerPATCH 576/775 cpufreq: ACPI: Set cpuinfo.max_freq directly if max boost is known
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 538b0188da4653b9f4511a114f014354fb6fb7a5 upstream.
Commit 3c55e94c0ade ("cpufreq: ACPI: Extend frequency tables to cover boost frequencies") attempted to address a performance issue involving acpi-cpufreq, the schedutil governor and scale-invariance on x86 by extending the frequency tables created by acpi-cpufreq to cover the entire range of "turbo" (or "boost") frequencies, but that caused frequencies reported via /proc/cpuinfo and the scaling_cur_freq attribute in sysfs to change which may confuse users and monitoring tools.
For this reason, revert the part of commit 3c55e94c0ade adding the extra entry to the frequency table and use the observation that in principle cpuinfo.max_freq need not be equal to the maximum frequency listed in the frequency table for the given policy.
Namely, modify cpufreq_frequency_table_cpuinfo() to allow cpufreq drivers to set their own cpuinfo.max_freq above that frequency and change acpi-cpufreq to set cpuinfo.max_freq to the maximum boost frequency found via CPPC.
This should be sufficient to let all of the cpufreq subsystem know the real maximum frequency of the CPU without changing frequency reporting.
--- drivers/cpufreq/acpi-cpufreq.c | 62 ++++++++++------------------------------- drivers/cpufreq/freq_table.c | 8 ++++- 2 files changed, 23 insertions(+), 47 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +16 -46
@@ -54,7 +54,6 @@ struct acpi_cpufreq_data {unsigned int resume;unsigned int cpu_feature;unsigned int acpi_perf_cpu; -unsigned int first_perf_state;cpumask_var_t freqdomain_cpus;void (*cpu_freq_write)(struct acpi_pct_register *reg,u32 val);u32 (*cpu_freq_read)(struct acpi_pct_register *reg);
@@ -223,10 +222,10 @@ static unsigned extract_msr(struct cpufr perf =to_perf_data (data); -cpufreq_for_each_entry (pos, policy->freq_table + data->first_perf_state) +cpufreq_for_each_entry (pos, policy->freq_table)if (msr == perf->states[pos->driver_data].status)return pos->frequency; -return policy->freq_table[data->first_perf_state].frequency; +return policy->freq_table[0 ].frequency; }static unsigned extract_freq (struct cpufreq_policy *policy,u32 val)
@@ -365,7 +364,6 @@ static unsigned int get_cur_freq_on_cpu(struct cpufreq_policy *policy;unsigned int freq;unsigned int cached_freq; -unsigned int state;pr_debug ("%s (%d)\n" , __func__, cpu);
@@ -377,11 +375,7 @@ static unsigned int get_cur_freq_on_cpu(if (unlikely (!data || !policy->freq_table))return 0 ; - state =to_perf_data (data)->state; -if (state < data->first_perf_state) - state = data->first_perf_state; - - cached_freq = policy->freq_table[state].frequency; + cached_freq = policy->freq_table[to_perf_data (data)->state].frequency; freq =extract_freq (policy,get_cur_val (cpumask_of (cpu), data));if (freq != cached_freq) {/*
@@ -680,7 +674,6 @@ static int acpi_cpufreq_cpu_init(structstruct cpuinfo_x86 *c = &cpu_data (cpu);unsigned int valid_states =0 ;unsigned int result =0 ; -unsigned int state_count;u64 max_boost_ratio;unsigned int i;#ifdef CONFIG_SMP
@@ -795,28 +788,8 @@ static int acpi_cpufreq_cpu_init(struct goto err_unreg; } - state_count = perf->state_count +1 ; - - max_boost_ratio =get_max_boost_ratio (cpu); -if (max_boost_ratio) { -/* -* Make a room for one more entry to represent the highest -* available "boost" frequency. -*/ - state_count++; - valid_states++; - data->first_perf_state = valid_states; - }else { -/* -* If the maximum "boost" frequency is unknown, ask the arch -* scale-invariance code to use the "nominal" performance for -* CPU utilization scaling so as to prevent the schedutil -* governor from selecting inadequate CPU frequencies. -*/ -arch_set_max_freq_ratio (true); - } - - freq_table =kcalloc (state_count,sizeof (*freq_table),GFP_KERNEL ); + freq_table =kcalloc (perf->state_count +1 ,sizeof (*freq_table), +GFP_KERNEL );if (!freq_table) { result = -ENOMEM ; goto err_unreg;
@@ -851,27 +824,25 @@ static int acpi_cpufreq_cpu_init(struct } freq_table[valid_states].frequency =CPUFREQ_TABLE_END ; + max_boost_ratio =get_max_boost_ratio (cpu);if (max_boost_ratio) { -unsigned int state = data->first_perf_state; -unsigned int freq = freq_table[state].frequency; +unsigned int freq = freq_table[0 ].frequency;/* * Because the loop above sorts the freq_table entries in the * descending order, freq is the maximum frequency in the table. * Assume that it corresponds to the CPPC nominal frequency and -* use it to populate the frequency field of the extra "boost" -* frequency entry. +* use it to set cpuinfo.max_freq. */ - freq_table[0 ].frequency = freq * max_boost_ratio >>SCHED_CAPACITY_SHIFT ; + policy->cpuinfo.max_freq = freq * max_boost_ratio >>SCHED_CAPACITY_SHIFT ; + }else {/* -* The purpose of the extra "boost" frequency entry is to make -* the rest of cpufreq aware of the real maximum frequency, but -* the way to request it is the same as for the first_perf_state -* entry that is expected to cover the entire range of "boost" -* frequencies of the CPU, so copy the driver_data value from -* that entry. +* If the maximum "boost" frequency is unknown, ask the arch +* scale-invariance code to use the "nominal" performance for +* CPU utilization scaling so as to prevent the schedutil +* governor from selecting inadequate CPU frequencies. */ - freq_table[0 ].driver_data = freq_table[state].driver_data; +arch_set_max_freq_ratio (true); } policy->freq_table = freq_table;
@@ -947,8 +918,7 @@ static void acpi_cpufreq_cpu_ready(struc {struct acpi_processor_performance *perf =per_cpu_ptr (acpi_perf_data, policy->cpu); -struct acpi_cpufreq_data *data = policy->driver_data; -unsigned int freq = policy->freq_table[data->first_perf_state].frequency; +unsigned int freq = policy->freq_table[0 ].frequency;if (perf->states[0 ].core_frequency *1000 != freq)pr_warn (FW_WARN "P-state 0 is not max freq\n" );
drivers/cpufreq/freq_table.c +7 -1
@@ -52,7 +52,13 @@ int cpufreq_frequency_table_cpuinfo(stru } policy->min = policy->cpuinfo.min_freq = min_freq; - policy->max = policy->cpuinfo.max_freq = max_freq; + policy->max = max_freq; +/* +* If the driver has set its own cpuinfo.max_freq above max_freq, leave +* it as is. +*/ +if (policy->cpuinfo.max_freq < max_freq) + policy->max = policy->cpuinfo.max_freq = max_freq;if (policy->min == ~0 )return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 577/775 HID: logitech-dj: add support for keyboard events in eQUAD step 4 Gaming
In reply to Greg Kroah-HartmanFrom: Filipe Laíns <[email protected]>
commit ef07c116d98772952807492bd32a61f5af172a94 upstream.
In e400071a805d6229223a98899e9da8c6233704a1 I added support for the receiver that comes with the G602 device, but unfortunately I screwed up during testing and it seems the keyboard events were actually not being sent to userspace.
This resulted in keyboard events being broken in userspace, please backport the fix.
The receiver uses the normal 0x01 Logitech keyboard report descriptor, as expected, so it is just a matter of flagging it as supported.
Reported in
https://github.com/libratbag/libratbag/issues/1124
--- drivers/hid/hid-logitech-dj.c | 1 + 1 file changed, 1 insertion(+)
drivers/hid/hid-logitech-dj.c +1 -0
@@ -980,6 +980,7 @@ static void logi_hidpp_recv_queue_notif(case 0x07 : device_type ="eQUAD step 4 Gaming" ;logi_hidpp_dev_conn_notif_equad (hdev, hidpp_report, &workitem); + workitem.reports_supported |=STD_KEYBOARD ;break ;case 0x08 : device_type ="eQUAD step 4 for gamepads" ;
Greg Kroah-Hartman
maintainerPATCH 578/775 HID: wacom: Ignore attempts to overwrite the touch_max value from HID
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
commit 88f38846bfb1a452a3d47e38aeab20a4ceb74294 upstream.
The wacom_feature_mapping function is careful to only set the the touch_max value a single time, but this care does not extend to the wacom_wac_finger_event function. In particular, if a device sends multiple HID_DG_CONTACTMAX items in a single feature report, the driver will end up retaining the value of last item.
The HID descriptor for the Cintiq Companion 2 does exactly this. It incorrectly sets a "Report Count" of 2, which will cause the driver to process two HID_DG_CONTACTCOUNT items. The first item has the actual count, while the second item should have been declared as a constant zero. The constant zero is the value the driver ends up using, however, since it is the last HID_DG_CONTACTCOUNT in the report.
Report ID (16),
Usage (Contact Count Maximum), ; Contact count maximum (55h, static value) Report Count (2),
Logical Maximum (10),
Feature (Variable),
To address this, we add a check that the touch_max is not already set within the wacom_wac_finger_event function that processes the HID_DG_TOUCHMAX item. We emit a warning if the value is set and ignore the updated value.
This could potentially cause problems if there is a tablet which has a similar issue but requires the last item to be used. This is unlikely, however, since it would have to have a different non-zero value for HID_DG_CONTACTMAX earlier in the same report, which makes no sense except in the case of a firmware bug. Note that cases where the HID_DG_CONTACTMAX items are in different reports is already handled (and similarly ignored) by wacom_feature_mapping as mentioned above.
--- drivers/hid/wacom_wac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/wacom_wac.c +6 -1
@@ -2600,7 +2600,12 @@ static void wacom_wac_finger_event(struc wacom_wac->is_invalid_bt_frame = !value;return ;case HID_DG_CONTACTMAX : - features->touch_max = value; +if (!features->touch_max) { + features->touch_max = value; + }else { +hid_warn (hdev,"%s: ignoring attempt to overwrite non-zero touch_max " +"%d -> %d\n" , __func__, features->touch_max, value); + }return ; }
Greg Kroah-Hartman
maintainerPATCH 579/775 Input: raydium_ts_i2c - do not send zero length
In reply to Greg Kroah-HartmanFrom: jeffrey.lin <[email protected]>
commit fafd320ae51b9c72d371585b2501f86640ea7b7d upstream.
Add default write command package to prevent i2c quirk error of zero data length as Raydium touch firmware update is executed.
--- drivers/input/touchscreen/raydium_i2c_ts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/input/touchscreen/raydium_i2c_ts.c +2 -1
@@ -445,6 +445,7 @@ static int raydium_i2c_write_object(stru enum raydium_bl_ack state) {int error; +static const u8 cmd[] = {0xFF ,0x39 }; error =raydium_i2c_send (client,RM_CMD_BOOT_WRT , data, len);if (error) {
@@ -453,7 +454,7 @@ static int raydium_i2c_write_object(strureturn error; } - error =raydium_i2c_send (client,RM_CMD_BOOT_ACK ,NULL ,0 ); + error =raydium_i2c_send (client,RM_CMD_BOOT_ACK , cmd,sizeof (cmd));if (error) {dev_err (&client->dev,"Ack obj command failed: %d\n" , error);return error;
Greg Kroah-Hartman
maintainerPATCH 580/775 Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S
In reply to Greg Kroah-HartmanFrom: Olivier Crête <[email protected]>
commit 42ffcd1dba1796bcda386eb6f260df9fc23c90af upstream.
--- drivers/input/joystick/xpad.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/joystick/xpad.c +1 -0
@@ -305,6 +305,7 @@ static const struct xpad_device { { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 }, { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 }, { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE }, + { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE }, { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 }, { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
Greg Kroah-Hartman
maintainerPATCH 581/775 Input: joydev - prevent potential read overflow in ioctl
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 182d679b2298d62bf42bb14b12a8067b8e17b617 upstream.
The problem here is that "len" might be less than "joydev->nabs" so the loops which verfy abspam[i] and keypam[] might read beyond the buffer.
--- drivers/input/joydev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/input/joydev.c +5 -2
@@ -456,7 +456,7 @@ static int joydev_handle_JSIOCSAXMAP(strif (IS_ERR (abspam))return PTR_ERR (abspam); -for (i =0 ; i < joydev->nabs; i++) { +for (i =0 ; i < len && i < joydev->nabs; i++) {if (abspam[i] >ABS_MAX ) { retval = -EINVAL ; goto out;
@@ -480,6 +480,9 @@ static int joydev_handle_JSIOCSBTNMAP(stint i;int retval =0 ; +if (len %sizeof (*keypam)) +return -EINVAL ; + len =min (len,sizeof (joydev->keypam));/* Validate the map. */
@@ -487,7 +490,7 @@ static int joydev_handle_JSIOCSBTNMAP(stif (IS_ERR (keypam))return PTR_ERR (keypam); -for (i =0 ; i < joydev->nkey; i++) { +for (i =0 ; i < (len /2 ) && i < joydev->nkey; i++) {if (keypam[i] >KEY_MAX || keypam[i] <BTN_MISC ) { retval = -EINVAL ; goto out;
Greg Kroah-Hartman
maintainerPATCH 582/775 Input: i8042 - add ASUS Zenbook Flip to noselftest list
In reply to Greg Kroah-HartmanFrom: Marcos Paulo de Souza <[email protected]>
commit b5d6e7ab7fe7d186878142e9fc1a05e4c3b65eb9 upstream.
After commit 77b425399f6d ("Input: i8042 - use chassis info to skip selftest on Asus laptops"), all modern Asus laptops have the i8042 selftest disabled. It has done by using chassys type "10" (laptop).
The Asus Zenbook Flip suffers from similar suspend/resume issues, but it _sometimes_ work and sometimes it doesn't. Setting noselftest makes it work reliably. In this case, we need to add chassis type "31" (convertible) in order to avoid selftest in this device.
--- drivers/input/serio/i8042-x86ia64io.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +4 -0
@@ -588,6 +588,10 @@ static const struct dmi_system_id i8042_ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */ }, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /* Convertible Notebook */ + }, }, { } };
Greg Kroah-Hartman
maintainerPATCH 583/775 media: mceusb: Fix potential out-of-bounds shift
In reply to Greg Kroah-HartmanFrom: James Reynolds <[email protected]>
commit 1b43bad31fb0e00f45baf5b05bd21eb8d8ce7f58 upstream.
When processing a MCE_RSP_GETPORTSTATUS command, the bit index to set in ir->txports_cabled comes from response data, and isn't validated.
As ir->txports_cabled is a u8, nothing should be done if the bit index is greater than 7.
--- drivers/media/rc/mceusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/mceusb.c +1 -1
@@ -1169,7 +1169,7 @@ static void mceusb_handle_command(structswitch (subcmd) {/* the one and only 5-byte return value command */ case MCE_RSP_GETPORTSTATUS : -if (buf_in[5 ] ==0 ) +if (buf_in[5 ] ==0 && *hi <8 ) ir->txports_cabled |=1 << *hi;break ;
Greg Kroah-Hartman
maintainerPATCH 584/775 USB: serial: option: update interface mapping for ZTE P685M
In reply to Greg Kroah-HartmanFrom: Lech Perczak <[email protected]>
commit 6420a569504e212d618d4a4736e2c59ed80a8478 upstream.
This patch prepares for qmi_wwan driver support for the device. Previously "option" driver mapped itself to interfaces 0 and 3 (matching ff/ff/ff), while interface 3 is in fact a QMI port. Interfaces 1 and 2 (matching ff/00/00) expose AT commands, and weren't supported previously at all.
Without this patch, a possible conflict would exist if device ID was added to qmi_wwan driver for interface 3.
Update and simplify device ID to match interfaces 0-2 directly, to expose QCDM (0), PCUI (1), and modem (2) ports and avoid conflict with QMI (3), and ADB (4).
The modem is used inside ZTE MF283+ router and carriers identify it as such.
Interface mapping is:
0: QCDM, 1: AT (PCUI), 2: AT (Modem), 3: QMI, 4: ADB
T: Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#= 3 Spd=480 MxCh= 0 D: Ver= 2.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=19d2 ProdID=1275 Rev=f0.00 S: Manufacturer=ZTE,Incorporated S: Product=ZTE Technologies MSM S: SerialNumber=P685M510ZTED0000CP&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&0 C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan E: Ad=87(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +2 -1
@@ -1569,7 +1569,8 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1272, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1273, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1274, 0xff, 0xff, 0xff) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1275, 0xff, 0xff, 0xff) }, + { USB_DEVICE(ZTE_VENDOR_ID, 0x1275), /* ZTE P685M */ + .driver_info = RSVD(3) | RSVD(4) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1276, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1277, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1278, 0xff, 0xff, 0xff) },
Greg Kroah-Hartman
maintainerPATCH 585/775 usb: musb: Fix runtime PM race in musb_queue_resume_work
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 0eaa1a3714db34a59ce121de5733c3909c529463 upstream.
musb_queue_resume_work() would call the provided callback if the runtime PM status was 'active'. Otherwise, it would enqueue the request if the hardware was still suspended (musb->is_runtime_suspended is true).
This causes a race with the runtime PM handlers, as it is possible to be in the case where the runtime PM status is not yet 'active', but the hardware has been awaken (PM resume function has been called).
When hitting the race, the resume work was not enqueued, which probably triggered other bugs further down the stack. For instance, a telnet connection on Ingenic SoCs would result in a 50/50 chance of a segmentation fault somewhere in the musb code.
Rework the code so that either we call the callback directly if (musb->is_runtime_suspended == 0), or enqueue the query otherwise.
--- drivers/usb/musb/musb_core.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/usb/musb/musb_core.c +17 -14
@@ -2240,32 +2240,35 @@ int musb_queue_resume_work(struct musb * {struct musb_pending_work *w;unsigned long flags; +bool is_suspended;int error;if (WARN_ON (!callback))return -EINVAL ; -if (pm_runtime_active (musb->controller)) -return callback (musb, data); +spin_lock_irqsave (&musb->list_lock, flags); + is_suspended = musb->is_runtime_suspended; - w =devm_kzalloc (musb->controller,sizeof (*w),GFP_ATOMIC ); -if (!w) -return -ENOMEM ; +if (is_suspended) { + w =devm_kzalloc (musb->controller,sizeof (*w),GFP_ATOMIC ); +if (!w) { + error = -ENOMEM ; + goto out_unlock; + } + + w->callback = callback; + w->data = data; - w->callback = callback; - w->data = data; -spin_lock_irqsave (&musb->list_lock, flags); -if (musb->is_runtime_suspended) {list_add_tail (&w->node, &musb->pending_list); error =0 ; - }else { -dev_err (musb->controller,"could not add resume work %p\n" , - callback); -devm_kfree (musb->controller, w); - error = -EINPROGRESS ; } + +out_unlock:spin_unlock_irqrestore (&musb->list_lock, flags); +if (!is_suspended) + error =callback (musb, data); +return error; }EXPORT_SYMBOL_GPL (musb_queue_resume_work);
Greg Kroah-Hartman
maintainerPATCH 586/775 usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit a1679af85b2ae35a2b78ad04c18bb069c37330cc upstream.
Valid range for DEPCFG.bInterval_m1 is from 0 to 13, and it must be set to 0 when the controller operates in full-speed. See the programming guide for DEPCFG command section 3.2.2.1 (v3.30a).
--- drivers/usb/dwc3/gadget.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +11 -1
@@ -605,7 +605,17 @@ static int dwc3_gadget_set_ep_config(str params.param0 |=DWC3_DEPCFG_FIFO_NUMBER (dep->number >>1 );if (desc->bInterval) { - params.param1 |=DWC3_DEPCFG_BINTERVAL_M1 (desc->bInterval -1 ); +u8 bInterval_m1; + +/* +* Valid range for DEPCFG.bInterval_m1 is from 0 to 13, and it +* must be set to 0 when the controller operates in full-speed. +*/ + bInterval_m1 =min_t (u8, desc->bInterval -1 ,13 ); +if (dwc->gadget->speed ==USB_SPEED_FULL ) + bInterval_m1 =0 ; + + params.param1 |=DWC3_DEPCFG_BINTERVAL_M1 (bInterval_m1); dep->interval =1 << (desc->bInterval -1 ); }
Greg Kroah-Hartman
maintainerPATCH 587/775 usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit 4b049f55ed95cd889bcdb3034fd75e1f01852b38 upstream.
The dep->interval captures the number of frames/microframes per interval from bInterval. Fullspeed interrupt endpoint bInterval is the number of frames per interval and not 2^(bInterval - 1). So fix it here. This change is only for debugging purpose and should not affect the interrupt endpoint operation.
--- drivers/usb/dwc3/gadget.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +6 -1
@@ -615,8 +615,13 @@ static int dwc3_gadget_set_ep_config(strif (dwc->gadget->speed ==USB_SPEED_FULL ) bInterval_m1 =0 ; +if (usb_endpoint_type (desc) ==USB_ENDPOINT_XFER_INT && + dwc->gadget->speed ==USB_SPEED_FULL ) + dep->interval = desc->bInterval; +else + dep->interval =1 << (desc->bInterval -1 ); + params.param1 |=DWC3_DEPCFG_BINTERVAL_M1 (bInterval_m1); - dep->interval =1 << (desc->bInterval -1 ); }return dwc3_send_gadget_ep_cmd (dep,DWC3_DEPCMD_SETEPCONFIG , ¶ms);
Greg Kroah-Hartman
maintainerPATCH 588/775 USB: serial: ftdi_sio: fix FTX sub-integer prescaler
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 528222d0c8ce93e435a95cd1e476b60409dd5381 upstream.
The most-significant bit of the sub-integer-prescaler index is set in the high byte of the baudrate request wIndex also for FTX devices.
This fixes rates like 1152000 which got mapped to 1.2 MBd.
--- drivers/usb/serial/ftdi_sio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/serial/ftdi_sio.c +3 -2
@@ -1386,8 +1386,9 @@ static int change_speed(struct tty_struc index_value =get_ftdi_divisor (tty, port); value = (u16 )index_value; index = (u16)(index_value >>16 ); -if ((priv->chip_type ==FT2232C ) || (priv->chip_type ==FT2232H ) || - (priv->chip_type ==FT4232H ) || (priv->chip_type ==FT232H )) { +if (priv->chip_type ==FT2232C || priv->chip_type ==FT2232H || + priv->chip_type ==FT4232H || priv->chip_type ==FT232H || + priv->chip_type ==FTX ) {/* Probably the BM type needs the MSB of the encoded fractional * divider also moved like for the chips above. Any infos? */ index = (u16)((index <<8 ) | priv->interface);
Greg Kroah-Hartman
maintainerPATCH 589/775 USB: serial: pl2303: fix line-speed handling on newer chips
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 979d9cbe75b922ab1695b8ad5576115774f72e62 upstream.
The latest chip family (HXN) apparently does not support setting the line speed using divisors and instead needs to use the direct encoding scheme for all rates.
This specifically enables 50, 110, 134, 200 bps and other rates not supported by the original chip type.
--- drivers/usb/serial/pl2303.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/serial/pl2303.c +7 -1
@@ -183,6 +183,7 @@ struct pl2303_type_data {speed_t max_baud_rate;unsigned long quirks; unsigned int no_autoxonxoff:1; + unsigned int no_divisors:1; };struct pl2303_serial_private {
@@ -209,6 +210,7 @@ static const struct pl2303_type_data pl2 }, [TYPE_HXN ] = { .max_baud_rate =12000000 , + .no_divisors = true, }, };
@@ -571,8 +573,12 @@ static void pl2303_encode_baud_rate(stru baud =min_t (speed_t, baud, spriv->type->max_baud_rate);/* * Use direct method for supported baud rates, otherwise use divisors. +* Newer chip types do not support divisor encoding. */ - baud_sup =pl2303_get_supported_baud_rate (baud); +if (spriv->type->no_divisors) + baud_sup = baud; +else + baud_sup =pl2303_get_supported_baud_rate (baud);if (baud == baud_sup) baud =pl2303_encode_baud_rate_direct (buf, baud);