5.4.102-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 172/340 i2c: i2c-qcom-geni: Add shutdown callback for i2c
In reply to Greg Kroah-HartmanFrom: Roja Rani Yarubandi <[email protected]>
[ Upstream commit e0371298ddc51761be257698554ea507ac8bf831 ]
If the hardware is still accessing memory after SMMU translation is disabled (as part of smmu shutdown callback), then the IOVAs (I/O virtual address) which it was using will go on the bus as the physical addresses which will result in unknown crashes like NoC/interconnect errors.
So, implement shutdown callback to i2c driver to stop on-going transfer and unmap DMA mappings during system "reboot" or "shutdown".
--- drivers/i2c/busses/i2c-qcom-geni.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +34 -0
@@ -377,6 +377,32 @@ static void geni_i2c_tx_msg_cleanup(struct geni_i2c_dev *gi2c, } } +static void geni_i2c_stop_xfer (struct geni_i2c_dev *gi2c) +{ +int ret; +u32 geni_status; +struct i2c_msg *cur; + +/* Resume device, as runtime suspend can happen anytime during transfer */ + ret =pm_runtime_get_sync (gi2c->se.dev); +if (ret <0 ) { +dev_err (gi2c->se.dev,"Failed to resume device: %d\n" , ret); +return ; + } + + geni_status =readl_relaxed (gi2c->se.base +SE_GENI_STATUS ); +if (geni_status &M_GENI_CMD_ACTIVE ) { + cur = gi2c->cur; +geni_i2c_abort_xfer (gi2c); +if (cur->flags &I2C_M_RD ) +geni_i2c_rx_msg_cleanup (gi2c, cur); +else +geni_i2c_tx_msg_cleanup (gi2c, cur); + } + +pm_runtime_put_sync_suspend (gi2c->se.dev); +} +static int geni_i2c_rx_one_msg (struct geni_i2c_dev *gi2c,struct i2c_msg *msg,u32 m_param) {
@@ -641,6 +667,13 @@ static int geni_i2c_remove(struct platform_device *pdev)return 0 ; } +static void geni_i2c_shutdown (struct platform_device *pdev) +{ +struct geni_i2c_dev *gi2c =platform_get_drvdata (pdev); + +geni_i2c_stop_xfer (gi2c); +} +static int __maybe_unused geni_i2c_runtime_suspend (struct device *dev) {int ret;
@@ -701,6 +734,7 @@ MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);static struct platform_driver geni_i2c_driver = { .probe = geni_i2c_probe, .remove = geni_i2c_remove, + .shutdown = geni_i2c_shutdown, .driver = { .name ="geni_i2c" , .pm = &geni_i2c_pm_ops,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 173/340 amba: Fix resource leak for drivers without .remove
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit de5d7adb89367bbc87b4e5ce7afe7ae9bd86dc12 ]
Consider an amba driver with a .probe but without a .remove callback (e.g. pl061_gpio_driver). The function amba_probe() is called to bind a device and so dev_pm_domain_attach() and others are called. As there is no remove callback amba_remove() isn't called at unbind time however and so calling dev_pm_domain_detach() is missed and the pm domain keeps active.
To fix this always use the core driver callbacks and handle missing amba callbacks there. For probe refuse registration as a driver without probe doesn't make sense.
--- drivers/amba/bus.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/amba/bus.c +12 -8
@@ -299,10 +299,11 @@ static int amba_remove(struct device *dev) {struct amba_device *pcdev =to_amba_device (dev);struct amba_driver *drv =to_amba_driver (dev->driver); -int ret; +int ret =0 ;pm_runtime_get_sync (dev); - ret = drv->remove (pcdev); +if (drv->remove) + ret = drv->remove (pcdev);pm_runtime_put_noidle (dev);/* Undo the runtime PM settings in amba_probe() */
@@ -319,7 +320,9 @@ static int amba_remove(struct device *dev)static void amba_shutdown (struct device *dev) {struct amba_driver *drv =to_amba_driver (dev->driver); - drv->shutdown (to_amba_device (dev)); + +if (drv->shutdown) + drv->shutdown (to_amba_device (dev)); }/**
@@ -332,12 +335,13 @@ static void amba_shutdown(struct device *dev)*/ int amba_driver_register (struct amba_driver *drv) { - drv->drv.bus = &amba_bustype; +if (!drv->probe) +return -EINVAL ; -#define SETFN (fn) if (drv->fn) drv->drv.fn = amba_##fn -SETFN (probe); -SETFN (remove); -SETFN (shutdown); + drv->drv.bus = &amba_bustype; + drv->drv.probe = amba_probe; + drv->drv.remove = amba_remove; + drv->drv.shutdown = amba_shutdown;return driver_register (&drv->drv); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 174/340 IB/mlx5: Return appropriate error code instead of ENOMEM
In reply to Greg Kroah-HartmanFrom: Parav Pandit <[email protected]>
[ Upstream commit d286ac1d05210695c312b9018b3aa7c2048e9aca ]
When mlx5_ib_stage_init_init() fails, return the error code related to failure instead of -ENOMEM.
--- drivers/infiniband/hw/mlx5/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/main.c +1 -2
@@ -6213,8 +6213,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) err_mp:mlx5_ib_cleanup_multiport_master (dev); - -return -ENOMEM ; +return err; }static int mlx5_ib_stage_flow_db_init (struct mlx5_ib_dev *dev)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 175/340 IB/cm: Avoid a loop when device has 255 ports
In reply to Greg Kroah-HartmanFrom: Parav Pandit <[email protected]>
[ Upstream commit 131be26750379592f0dd6244b2a90bbb504a10bb ]
When RDMA device has 255 ports, loop iterator i overflows. Due to which cm_add_one() port iterator loops infinitely. Use core provided port iterator to avoid the infinite loop.
--- drivers/infiniband/core/cm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/core/cm.c +4 -4
@@ -4336,7 +4336,7 @@ static void cm_add_one(struct ib_device *ib_device)unsigned long flags;int ret;int count =0 ; -u8 i; +unsigned int i; cm_dev =kzalloc (struct_size (cm_dev, port, ib_device->phys_port_cnt),GFP_KERNEL );
@@ -4348,7 +4348,7 @@ static void cm_add_one(struct ib_device *ib_device) cm_dev->going_down =0 ;set_bit (IB_MGMT_METHOD_SEND , reg_req.method_mask); -for (i =1 ; i <= ib_device->phys_port_cnt; i++) { + rdma_for_each_port (ib_device, i) {if (!rdma_cap_ib_cm (ib_device, i))continue ;
@@ -4427,7 +4427,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data) .clr_port_cap_mask = IB_PORT_CM_SUP };unsigned long flags; -int i; +unsigned int i;if (!cm_dev)return ;
@@ -4440,7 +4440,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data) cm_dev->going_down =1 ;spin_unlock_irq (&cm.lock); -for (i =1 ; i <= ib_device->phys_port_cnt; i++) { + rdma_for_each_port (ib_device, i) {if (!rdma_cap_ib_cm (ib_device, i))continue ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 176/340 tracepoint: Do not fail unregistering a probe due to memory failure
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit befe6d946551d65cddbd32b9cb0170b0249fd5ed ]
The list of tracepoint callbacks is managed by an array that is protected by RCU. To update this array, a new array is allocated, the updates are copied over to the new array, and then the list of functions for the tracepoint is switched over to the new array. After a completion of an RCU grace period, the old array is freed.
This process happens for both adding a callback as well as removing one. But on removing a callback, if the new array fails to be allocated, the callback is not removed, and may be used after it is freed by the clients of the tracepoint.
There's really no reason to fail if the allocation for a new array fails when removing a function. Instead, the function can simply be replaced by a stub function that could be cleaned up on the next modification of the array. That is, instead of calling the function registered to the tracepoint, it would call a stub function in its place.
[ Note, this version does use undefined compiler behavior (assuming that
a stub function with no parameters or return, can be called by a location that thinks it has parameters but still no return value. Static calls do the same thing, so this trick is not without precedent.
There's another solution that uses RCU tricks and is more complex, but can be an alternative if this solution becomes an issue.
]
--- kernel/tracepoint.c | 80 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 16 deletions(-)
kernel/tracepoint.c +64 -16
@@ -53,6 +53,12 @@ struct tp_probes {struct tracepoint_func probes[0 ]; }; +/* Called in removal of a func but failed to allocate a new tp_funcs */ +static void tp_stub_func (void ) +{ +return ; +} +static inline void *allocate_probes (int count) { struct tp_probes *p = kmalloc(struct_size(p, probes, count),
@@ -131,6 +137,7 @@ func_add(struct tracepoint_func **funcs, struct tracepoint_func *tp_func, {struct tracepoint_func *old, *new;int nr_probes =0 ; +int stub_funcs =0 ;int pos =-1 ;if (WARN_ON (!tp_func->func))
@@ -147,14 +154,34 @@ func_add(struct tracepoint_func **funcs, struct tracepoint_func *tp_func,if (old[nr_probes].func == tp_func->func && old[nr_probes].data == tp_func->data)return ERR_PTR (-EEXIST ); +if (old[nr_probes].func == tp_stub_func) + stub_funcs++; } } -/* + 2 : one for new probe, one for NULL func */ - new =allocate_probes (nr_probes +2 ); +/* + 2 : one for new probe, one for NULL func - stub functions */ + new =allocate_probes (nr_probes +2 - stub_funcs);if (new ==NULL )return ERR_PTR (-ENOMEM );if (old) { -if (pos <0 ) { +if (stub_funcs) { +/* Need to copy one at a time to remove stubs */ +int probes =0 ; + + pos =-1 ; +for (nr_probes =0 ; old[nr_probes].func; nr_probes++) { +if (old[nr_probes].func == tp_stub_func) +continue ; +if (pos <0 && old[nr_probes].prio < prio) + pos = probes++; + new[probes++] = old[nr_probes]; + } + nr_probes = probes; +if (pos <0 ) + pos = probes; +else + nr_probes--;/* Account for insertion */ + + }else if (pos <0 ) { pos = nr_probes;memcpy (new, old, nr_probes *sizeof (struct tracepoint_func )); }else {
@@ -188,8 +215,9 @@ static void *func_remove(struct tracepoint_func **funcs,/* (N -> M), (N > 1, M >= 0) probes */ if (tp_func->func) {for (nr_probes =0 ; old[nr_probes].func; nr_probes++) { -if (old[nr_probes].func == tp_func->func && - old[nr_probes].data == tp_func->data) +if ((old[nr_probes].func == tp_func->func && + old[nr_probes].data == tp_func->data) || + old[nr_probes].func == tp_stub_func) nr_del++; } }
@@ -208,14 +236,32 @@ static void *func_remove(struct tracepoint_func **funcs,/* N -> M, (N > 1, M > 0) */ /* + 1 for NULL */ new =allocate_probes (nr_probes - nr_del +1 ); -if (new ==NULL ) -return ERR_PTR (-ENOMEM ); -for (i =0 ; old[i].func; i++) -if (old[i].func != tp_func->func - || old[i].data != tp_func->data) - new[j++] = old[i]; - new[nr_probes - nr_del].func =NULL ; - *funcs = new; +if (new) { +for (i =0 ; old[i].func; i++) +if ((old[i].func != tp_func->func + || old[i].data != tp_func->data) + && old[i].func != tp_stub_func) + new[j++] = old[i]; + new[nr_probes - nr_del].func =NULL ; + *funcs = new; + }else { +/* +* Failed to allocate, replace the old function +* with calls to tp_stub_func. +*/ +for (i =0 ; old[i].func; i++) +if (old[i].func == tp_func->func && + old[i].data == tp_func->data) { + old[i].func = tp_stub_func; +/* Set the prio to the next event. */ +if (old[i +1 ].func) + old[i].prio = + old[i +1 ].prio; +else + old[i].prio =-1 ; + } + *funcs = old; + } }debug_print_probes (*funcs);return old;
@@ -271,10 +317,12 @@ static int tracepoint_remove_func(struct tracepoint *tp, tp_funcs =rcu_dereference_protected (tp->funcs,lockdep_is_held (&tracepoints_mutex)); old =func_remove (&tp_funcs, func); -if (IS_ERR (old)) { -WARN_ON_ONCE (PTR_ERR (old) != -ENOMEM ); +if (WARN_ON_ONCE (IS_ERR (old)))return PTR_ERR (old); - } + +if (tp_funcs == old) +/* Failed allocating new tp_funcs, replaced func with stub */ +return 0 ;if (!tp_funcs) {/* Removed last function */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 177/340 perf tools: Fix DSO filtering when not finding a map for a sampled address
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit c69bf11ad3d30b6bf01cfa538ddff1a59467c734 ]
When we lookup an address and don't find a map we should filter that sample if the user specified a list of --dso entries to filter on, fix it.
Before:
$ perf script
sleep 274800 2843.556162: 1 cycles:u: ffffffffbb26bff4 [unknown] ([unknown])
sleep 274800 2843.556168: 1 cycles:u: ffffffffbb2b047d [unknown] ([unknown])
sleep 274800 2843.556171: 1 cycles:u: ffffffffbb2706b2 [unknown] ([unknown])
sleep 274800 2843.556174: 6 cycles:u: ffffffffbb2b0267 [unknown] ([unknown])
sleep 274800 2843.556176: 59 cycles:u: ffffffffbb2b03b1 [unknown] ([unknown])
sleep 274800 2843.556180: 691 cycles:u: ffffffffbb26bff4 [unknown] ([unknown])
sleep 274800 2843.556189: 9160 cycles:u: 7fa9550eeaa3 __GI___tunables_init+0xf3 (/usr/lib64/ld-2.32.so)
sleep 274800 2843.556312: 86937 cycles:u: 7fa9550e157b _dl_lookup_symbol_x+0x4b (/usr/lib64/ld-2.32.so)
$So we have some samples we somehow didn't find in a map for, if we now do:
$ perf report --stdio --dso /usr/lib64/ld-2.32.so
# dso: /usr/lib64/ld-2.32.so
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'cycles:u'
# Event count (approx.): 96856
#
# Overhead Command Symbol
# ........ ....... ........................
#
89.76% sleep [.] _dl_lookup_symbol_x
9.46% sleep [.] __GI___tunables_init
0.71% sleep [k] 0xffffffffbb26bff4
0.06% sleep [k] 0xffffffffbb2b03b1
0.01% sleep [k] 0xffffffffbb2b0267
0.00% sleep [k] 0xffffffffbb2706b2
0.00% sleep [k] 0xffffffffbb2b047d
$After this patch we get the right output with just entries for the DSOs specified in --dso:
$ perf report --stdio --dso /usr/lib64/ld-2.32.so
# dso: /usr/lib64/ld-2.32.so
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'cycles:u'
# Event count (approx.): 96856
#
# Overhead Command Symbol
# ........ ....... ........................
#
89.76% sleep [.] _dl_lookup_symbol_x
9.46% sleep [.] __GI___tunables_init
$
#--- tools/perf/util/event.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/event.c +2 -0
@@ -597,6 +597,8 @@ int machine__resolve(struct machine *machine, struct addr_location *al, } al->sym =map__find_symbol (al->map, al->addr); + }else if (symbol_conf.dso_list) { + al->filtered |= (1 <<HIST_FILTER__DSO ); } if (symbol_conf.sym_list &&
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 178/340 perf vendor events arm64: Fix Ampere eMag event typo
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit 2bf797be81fa808f05f1a7a65916619132256a27 ]
The "briefdescription" for event 0x35 has a typo - fix it.
--- tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json +1 -1
@@ -114,7 +114,7 @@ "PublicDescription": "Level 2 access to instruciton TLB that caused a page table walk. This event counts on any instruciton access which causes L2I_TLB_REFILL to count", "EventCode": "0x35", "EventName": "L2I_TLB_ACCESS", - "BriefDescription": "L2D TLB access" + "BriefDescription": "L2I TLB access" }, { "PublicDescription": "Branch target buffer misprediction",
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 179/340 RDMA/rxe: Fix coding error in rxe_recv.c
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 7d9ae80e31df57dd3253e1ec514f0000aa588a81 ]
check_type_state() in rxe_recv.c is written as if the type bits in the packet opcode were a bit mask which is not correct. This patch corrects this code to compare all 3 type bits to the required type.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_recv.c +8 -3
@@ -36,21 +36,26 @@#include "rxe.h" #include "rxe_loc.h" +/* check that QP matches packet opcode type and is in a valid state */ static int check_type_state (struct rxe_dev *rxe,struct rxe_pkt_info *pkt,struct rxe_qp *qp) { +unsigned int pkt_type; +if (unlikely (!qp->valid)) goto err1; + pkt_type = pkt->opcode &0xe0 ; +switch (qp_type (qp)) {case IB_QPT_RC : -if (unlikely ((pkt->opcode &IB_OPCODE_RC ) !=0 )) { +if (unlikely (pkt_type !=IB_OPCODE_RC )) {pr_warn_ratelimited ("bad qp type\n" ); goto err1; }break ;case IB_QPT_UC : -if (unlikely (!(pkt->opcode &IB_OPCODE_UC ))) { +if (unlikely (pkt_type !=IB_OPCODE_UC )) {pr_warn_ratelimited ("bad qp type\n" ); goto err1; }
@@ -58,7 +63,7 @@ static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,case IB_QPT_UD :case IB_QPT_SMI :case IB_QPT_GSI : -if (unlikely (!(pkt->opcode &IB_OPCODE_UD ))) { +if (unlikely (pkt_type !=IB_OPCODE_UD )) {pr_warn_ratelimited ("bad qp type\n" ); goto err1; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 180/340 RDMA/rxe: Fix coding error in rxe_rcv_mcast_pkt
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 8fc1b7027fc162738d5a85c82410e501a371a404 ]
rxe_rcv_mcast_pkt() in rxe_recv.c can leak SKBs in error path code. The loop over the QPs attached to a multicast group creates new cloned SKBs for all but the last QP in the list and passes the SKB and its clones to rxe_rcv_pkt() for further processing. Any QPs that do not pass some checks are skipped. If the last QP in the list fails the tests the SKB is leaked. This patch checks if the SKB for the last QP was used and if not frees it. Also removes a redundant loop invariant assignment.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_recv.c +10 -6
@@ -305,7 +305,6 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)list_for_each_entry (mce, &mcg->qp_list, qp_list) { qp = mce->qp; - pkt =SKB_TO_PKT (skb);/* validate qp for incoming packet */ err =check_type_state (rxe, pkt, qp);
@@ -317,12 +316,18 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)continue ;/* for all but the last qp create a new clone of the -* skb and pass to the qp. +* skb and pass to the qp. If an error occurs in the +* checks for the last qp in the list we need to +* free the skb since it hasn't been passed on to +* rxe_rcv_pkt() which would free it later. */ -if (mce->qp_list.next != &mcg->qp_list) +if (mce->qp_list.next != &mcg->qp_list) { per_qp_skb =skb_clone (skb,GFP_ATOMIC ); -else + }else { per_qp_skb = skb; +/* show we have consumed the skb */ + skb =NULL ; + }if (unlikely (!per_qp_skb))continue ;
@@ -337,9 +342,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)rxe_drop_ref (mcg);/* drop ref from rxe_pool_get_key. */ -return ; - err1: +/* free skb if not consumed */ kfree_skb (skb); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 181/340 RDMA/rxe: Correct skb on loopback path
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 5120bf0a5fc15dec210a0fe0f39e4a256bb6e349 ]
rxe_net.c sends packets at the IP layer with skb->data pointing at the IP header but receives packets from a UDP tunnel with skb->data pointing at the UDP header. On the loopback path this was not correctly accounted for. This patch corrects for this by using sbk_pull() to strip the IP header from the skb on received packets.
--- drivers/infiniband/sw/rxe/rxe_net.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
@@ -453,6 +453,11 @@ int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb)void rxe_loopback (struct sk_buff *skb) { +if (skb->protocol ==htons (ETH_P_IP )) +skb_pull (skb,sizeof (struct iphdr )); +else +skb_pull (skb,sizeof (struct ipv6hdr )); +rxe_rcv (skb); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 182/340 spi: stm32: properly handle 0 byte transfer
In reply to Greg Kroah-HartmanFrom: Alain Volmat <[email protected]>
[ Upstream commit 2269f5a8b1a7b38651d62676b98182828f29d11a ]
On 0 byte transfer request, return straight from the xfer function after finalizing the transfer.
--- drivers/spi/spi-stm32.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi-stm32.c +4 -0
@@ -1668,6 +1668,10 @@ static int stm32_spi_transfer_one(struct spi_master *master,struct stm32_spi *spi =spi_master_get_devdata (master);int ret; +/* Don't do anything on 0 bytes transfers */ +if (transfer->len ==0 ) +return 0 ; + spi->tx_buf = transfer->tx_buf; spi->rx_buf = transfer->rx_buf; spi->tx_len = spi->tx_buf ? transfer->len :0 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 183/340 mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 26783d74cc6a440ee3ef9836a008a697981013d0 ]
The "req" struct is always added to the "wm831x->auxadc_pending" list, but it's only removed from the list on the success path. If a failure occurs then the "req" struct is freed but it's still on the list, leading to a use after free.
--- drivers/mfd/wm831x-auxadc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mfd/wm831x-auxadc.c +1 -2
@@ -93,11 +93,10 @@ static int wm831x_auxadc_read_irq(struct wm831x *wm831x,wait_for_completion_timeout (&req->done,msecs_to_jiffies (500 ));mutex_lock (&wm831x->auxadc_lock); - -list_del (&req->list); ret = req->val; out: +list_del (&req->list);mutex_unlock (&wm831x->auxadc_lock);kfree (req);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 184/340 powerpc/pseries/dlpar: handle ibm, configure-connector delay status
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
[ Upstream commit 768d70e19ba525debd571b36e6d0ab19956c63d7 ]
dlpar_configure_connector() has two problems in its handling of ibm,configure-connector's return status:
1. When the status is -2 (busy, call again), we call ibm,configure-connector again immediately without checking whether to schedule, which can result in monopolizing the CPU.
2. Extended delay status (9900..9905) goes completely unhandled, causing the configuration to unnecessarily terminate.
Fix both of these issues by using rtas_busy_delay().
--- arch/powerpc/platforms/pseries/dlpar.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/dlpar.c +3 -4
@@ -127,7 +127,6 @@ void dlpar_free_cc_nodes(struct device_node *dn)#define NEXT_PROPERTY 3#define PREV_PARENT 4#define MORE_MEMORY 5 -#define CALL_AGAIN -2#define ERR_CFG_USE -9003 struct device_node *dlpar_configure_connector(__be32 drc_index,
@@ -168,6 +167,9 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,spin_unlock (&rtas_data_buf_lock); +if (rtas_busy_delay (rc)) +continue ; +switch (rc) {case COMPLETE :break ;
@@ -216,9 +218,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, last_dn = last_dn->parent;break ; -case CALL_AGAIN : -break ; -case MORE_MEMORY :case ERR_CFG_USE :default :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 185/340 powerpc/8xx: Fix software emulation interrupt
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 903178d0ce6bb30ef80a3604ab9ee2b57869fbc9 ]
For unimplemented instructions or unimplemented SPRs, the 8xx triggers a "Software Emulation Exception" (0x1000). That interrupt doesn't set reason bits in SRR1 as the "Program Check Exception" does.
Go through emulation_assist_interrupt() to set REASON_ILLEGAL.
--- arch/powerpc/kernel/head_8xx.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/head_8xx.S +1 -1
@@ -191,7 +191,7 @@ SystemCall: /* On the MPC8xx, this is a software emulation interrupt. It occurs * for all unimplemented and illegal instructions. */ - EXCEPTION(0x1000, SoftEmu, program_check_exception, EXC_XFER_STD) + EXCEPTION(0x1000, SoftEmu, emulation_assist_interrupt, EXC_XFER_STD) /* Called from DataStoreTLBMiss when perf TLB misses events are activated */ #ifdef CONFIG_PERF_EVENTS
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 186/340 clk: qcom: gcc-msm8998: Fix Alpha PLL type for all GPLLs
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 292f75ecff07e8a07fe2e3e19b4b567d0b698842 ]
All of the GPLLs in the MSM8998 Global Clock Controller are Fabia PLLs and not generic alphas: this was producing bad effects over the entire clock tree of MSM8998, where any GPLL child clock was declaring a false clock rate, due to their parent also showing the same.
The issue resides in the calculation of the clock rate for the specific Alpha PLL type, where Fabia has a different register layout; switching the MSM8998 GPLLs to the correct Alpha Fabia PLL type fixes the rate (calculation) reading. While at it, also make these PLLs fixed since their rate is supposed to *never* be changed while the system runs, as this would surely crash the entire SoC.
Now all the children of all the PLLs are also complying with their specified clock table and system stability is improved.
--- drivers/clk/qcom/gcc-msm8998.c | 100 ++++++++++++++++----------------- 1 file changed, 50 insertions(+), 50 deletions(-)
drivers/clk/qcom/gcc-msm8998.c +50 -50
@@ -135,7 +135,7 @@ static struct pll_vco fabia_vco[] = {static struct clk_alpha_pll gpll0 = { .offset =0x0 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .vco_table = fabia_vco, .num_vco =ARRAY_SIZE (fabia_vco), .clkr = {
@@ -145,58 +145,58 @@ static struct clk_alpha_pll gpll0 = { .name = "gpll0", .parent_names = (const char *[]){ "xo" }, .num_parents = 1, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_fabia_ops, } }, };static struct clk_alpha_pll_postdiv gpll0_out_even = { .offset =0x0 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll0_out_even" , .parent_names = (const char *[]){"gpll0" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll0_out_main = { .offset =0x0 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll0_out_main" , .parent_names = (const char *[]){"gpll0" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll0_out_odd = { .offset =0x0 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll0_out_odd" , .parent_names = (const char *[]){"gpll0" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll0_out_test = { .offset =0x0 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll0_out_test" , .parent_names = (const char *[]){"gpll0" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll gpll1 = { .offset =0x1000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .vco_table = fabia_vco, .num_vco =ARRAY_SIZE (fabia_vco), .clkr = {
@@ -206,58 +206,58 @@ static struct clk_alpha_pll gpll1 = { .name = "gpll1", .parent_names = (const char *[]){ "xo" }, .num_parents = 1, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_fabia_ops, } }, };static struct clk_alpha_pll_postdiv gpll1_out_even = { .offset =0x1000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll1_out_even" , .parent_names = (const char *[]){"gpll1" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll1_out_main = { .offset =0x1000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll1_out_main" , .parent_names = (const char *[]){"gpll1" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll1_out_odd = { .offset =0x1000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll1_out_odd" , .parent_names = (const char *[]){"gpll1" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll1_out_test = { .offset =0x1000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll1_out_test" , .parent_names = (const char *[]){"gpll1" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll gpll2 = { .offset =0x2000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .vco_table = fabia_vco, .num_vco =ARRAY_SIZE (fabia_vco), .clkr = {
@@ -267,58 +267,58 @@ static struct clk_alpha_pll gpll2 = { .name = "gpll2", .parent_names = (const char *[]){ "xo" }, .num_parents = 1, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_fabia_ops, } }, };static struct clk_alpha_pll_postdiv gpll2_out_even = { .offset =0x2000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll2_out_even" , .parent_names = (const char *[]){"gpll2" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll2_out_main = { .offset =0x2000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll2_out_main" , .parent_names = (const char *[]){"gpll2" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll2_out_odd = { .offset =0x2000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll2_out_odd" , .parent_names = (const char *[]){"gpll2" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll2_out_test = { .offset =0x2000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll2_out_test" , .parent_names = (const char *[]){"gpll2" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll gpll3 = { .offset =0x3000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .vco_table = fabia_vco, .num_vco =ARRAY_SIZE (fabia_vco), .clkr = {
@@ -328,58 +328,58 @@ static struct clk_alpha_pll gpll3 = { .name = "gpll3", .parent_names = (const char *[]){ "xo" }, .num_parents = 1, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_fabia_ops, } }, };static struct clk_alpha_pll_postdiv gpll3_out_even = { .offset =0x3000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll3_out_even" , .parent_names = (const char *[]){"gpll3" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll3_out_main = { .offset =0x3000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll3_out_main" , .parent_names = (const char *[]){"gpll3" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll3_out_odd = { .offset =0x3000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll3_out_odd" , .parent_names = (const char *[]){"gpll3" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll3_out_test = { .offset =0x3000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll3_out_test" , .parent_names = (const char *[]){"gpll3" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll gpll4 = { .offset =0x77000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .vco_table = fabia_vco, .num_vco =ARRAY_SIZE (fabia_vco), .clkr = {
@@ -389,52 +389,52 @@ static struct clk_alpha_pll gpll4 = { .name = "gpll4", .parent_names = (const char *[]){ "xo" }, .num_parents = 1, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_fabia_ops, } }, };static struct clk_alpha_pll_postdiv gpll4_out_even = { .offset =0x77000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll4_out_even" , .parent_names = (const char *[]){"gpll4" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll4_out_main = { .offset =0x77000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll4_out_main" , .parent_names = (const char *[]){"gpll4" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll4_out_odd = { .offset =0x77000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll4_out_odd" , .parent_names = (const char *[]){"gpll4" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };static struct clk_alpha_pll_postdiv gpll4_out_test = { .offset =0x77000 , - .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], .clkr.hw.init = &(struct clk_init_data ){ .name ="gpll4_out_test" , .parent_names = (const char *[]){"gpll4" }, .num_parents =1 , - .ops = &clk_alpha_pll_postdiv_ops, + .ops = &clk_alpha_pll_postdiv_fabia_ops, }, };
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 187/340 RDMA/hns: Fixed wrong judgments in the goto branch
In reply to Greg Kroah-HartmanFrom: Wenpeng Liang <[email protected]>
[ Upstream commit bb74fe7e81c8b2b65c6a351a247fdb9a969cbaec ]
When an error occurs, the qp_table must be cleared, regardless of whether the SRQ feature is enabled.
--- drivers/infiniband/hw/hns/hns_roce_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_main.c +1 -2
@@ -848,8 +848,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)return 0 ; err_qp_table_free: -if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_SRQ ) -hns_roce_cleanup_qp_table (hr_dev); +hns_roce_cleanup_qp_table (hr_dev); err_cq_table_free:hns_roce_cleanup_cq_table (hr_dev);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 188/340 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
@@ -134,7 +134,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 189/340 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
@@ -657,7 +657,7 @@ struct hns_roce_qp {u8 rdb_en;u8 sdb_en;u32 doorbell_qpn; -u32 sq_signal_bits; +enum ib_sig_type sq_signal_bits;struct hns_roce_wq sq;struct ib_umem *umem;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 190/340 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 191/340 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
@@ -874,7 +874,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 192/340 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 67 -#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
@@ -189,18 +190,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 193/340 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
@@ -1523,12 +1523,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;
@@ -1546,9 +1543,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:
@@ -1562,13 +1564,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 );
@@ -1579,7 +1580,6 @@ static void __exit exit_nfsd(void)nfsd_fault_inject_cleanup ();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 194/340 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
@@ -1009,7 +1009,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);
@@ -1054,15 +1054,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 195/340 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
@@ -774,6 +774,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 196/340 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
@@ -1745,6 +1745,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 197/340 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
@@ -2637,9 +2637,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
@@ -1304,7 +1304,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;
@@ -1366,7 +1367,8 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) sample.stream_id = ptq->pt->instructions_id; 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;
@@ -1901,14 +1903,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 198/340 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
@@ -180,7 +180,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .data = {1, 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 };struct perf_sample sample = { .ip = 101,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 199/340 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 200/340 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
@@ -524,7 +524,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 201/340 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
@@ -510,4 +510,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 202/340 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
@@ -240,15 +240,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 203/340 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
@@ -510,4 +510,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 204/340 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
@@ -368,10 +368,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 205/340 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
@@ -361,7 +361,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 206/340 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 207/340 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 208/340 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
@@ -1300,7 +1300,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 209/340 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 210/340 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
@@ -1099,7 +1099,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 211/340 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
@@ -866,6 +866,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);
@@ -1974,23 +1975,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
@@ -2088,10 +2072,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 ;
@@ -2124,10 +2108,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);
@@ -2201,7 +2187,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 212/340 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
@@ -2405,11 +2405,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 213/340 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
@@ -345,6 +345,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 214/340 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
@@ -314,7 +314,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 215/340 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
@@ -12,7 +12,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)
@@ -21,7 +21,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 216/340 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
@@ -3093,13 +3093,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 217/340 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
@@ -7612,6 +7612,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);
@@ -7679,6 +7681,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);
@@ -11770,6 +11774,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 218/340 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
@@ -9959,7 +9959,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;
@@ -10085,13 +10084,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.
@@ -14774,7 +14766,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)
@@ -15096,24 +15087,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 219/340 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
@@ -4874,7 +4874,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;
@@ -4919,9 +4919,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.
@@ -5038,7 +5040,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,
@@ -5067,8 +5069,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
@@ -8485,11 +8485,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 *
@@ -8497,6 +8492,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 220/340 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
@@ -2603,7 +2603,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 ; }
@@ -2621,7 +2621,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 221/340 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 222/340 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
@@ -7676,7 +7676,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 ;
@@ -7705,7 +7706,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 223/340 vfio/type1: Use follow_pte()
In reply to Greg Kroah-HartmanFrom: Alex Williamson <[email protected]>
[ Upstream commit 07956b6269d3ed05d854233d5bb776dca91751dd ]
follow_pfn() doesn't make sure that we're using the correct page protections, get the pte with follow_pte() so that we can test protections and get the pfn from the pte.
--- drivers/vfio/vfio_iommu_type1.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/vfio/vfio_iommu_type1.c +13 -2
@@ -24,6 +24,7 @@#include <linux/compat.h> #include <linux/device.h> #include <linux/fs.h> +#include <linux/highmem.h> #include <linux/iommu.h> #include <linux/module.h> #include <linux/mm.h>
@@ -339,9 +340,11 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm, unsigned long vaddr, unsigned long *pfn, bool write_fault) { + pte_t *ptep; +spinlock_t *ptl;int ret; - ret =follow_pfn (vma, vaddr, pfn); + ret =follow_pte (vma->vm_mm, vaddr, &ptep, &ptl);if (ret) {bool unlocked = false;
@@ -355,9 +358,17 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,if (ret)return ret; - ret =follow_pfn (vma, vaddr, pfn); + ret =follow_pte (vma->vm_mm, vaddr, &ptep, &ptl); +if (ret) +return ret; } +if (write_fault && !pte_write (*ptep)) + ret = -EFAULT ; +else + *pfn =pte_pfn (*ptep); + +pte_unmap_unlock (ptep, ptl);return ret; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 224/340 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 225/340 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
@@ -4424,7 +4424,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)
@@ -4438,14 +4437,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)
@@ -4453,6 +4451,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 226/340 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
@@ -2052,7 +2052,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),
@@ -2067,6 +2067,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 227/340 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
@@ -1804,11 +1804,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 ();
@@ -1822,7 +1822,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 228/340 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
@@ -2812,8 +2812,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 229/340 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
@@ -1630,6 +1630,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)
@@ -1672,7 +1673,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;
@@ -1687,7 +1688,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) {/*
@@ -1696,12 +1701,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);
@@ -1709,15 +1710,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); }
@@ -1728,9 +1724,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 230/340 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
@@ -4077,7 +4077,7 @@ 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 );rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_512B );
@@ -4085,7 +4085,7 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)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 );rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 231/340 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
@@ -970,6 +970,7 @@ __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 232/340 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 233/340 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
@@ -214,7 +214,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 234/340 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 235/340 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
@@ -473,6 +473,14 @@ void blk_queue_stack_limits(struct reque }EXPORT_SYMBOL (blk_queue_stack_limits); +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)
@@ -586,6 +594,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 236/340 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
@@ -794,9 +794,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)
@@ -806,28 +803,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 {
@@ -841,7 +853,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);
@@ -935,10 +947,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 237/340 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
@@ -267,7 +267,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 238/340 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 239/340 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 240/340 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
@@ -410,6 +410,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) {
@@ -418,7 +419,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 241/340 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 242/340 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 243/340 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 244/340 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 245/340 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 246/340 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
@@ -2102,32 +2102,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 247/340 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
@@ -593,7 +593,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 248/340 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
@@ -603,8 +603,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 249/340 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 250/340 USB: serial: mos7840: fix error code in mos7840_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit a70aa7dc60099bbdcbd6faca42a915d80f31161e upstream.
This should return -ENOMEM instead of 0 if the kmalloc() fails.
--- drivers/usb/serial/mos7840.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7840.c +3 -1
@@ -1330,8 +1330,10 @@ static int mos7840_write(struct tty_struif (urb->transfer_buffer ==NULL ) { urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); -if (!urb->transfer_buffer) +if (!urb->transfer_buffer) { + bytes_sent = -ENOMEM ; goto exit; + } } transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );
Greg Kroah-Hartman
maintainerPATCH 251/340 USB: serial: mos7720: fix error code in mos7720_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit fea7372cbc40869876df0f045e367f6f97a1666c upstream.
This code should return -ENOMEM if the kmalloc() fails but instead it returns success.
--- drivers/usb/serial/mos7720.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7720.c +3 -1
@@ -1250,8 +1250,10 @@ static int mos7720_write(struct tty_struif (urb->transfer_buffer ==NULL ) { urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); -if (!urb->transfer_buffer) +if (!urb->transfer_buffer) { + bytes_sent = -ENOMEM ; goto exit; + } } transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );
Greg Kroah-Hartman
maintainerPATCH 252/340 ALSA: hda: Add another CometLake-H PCI ID
In reply to Greg Kroah-HartmanFrom: Kai Vehmanen <[email protected]>
commit 0d3070f5e6551d8a759619e85736e49a3bf40398 upstream.
Add one more HD Audio PCI ID for CometLake-H PCH.
--- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2447,6 +2447,8 @@ static const struct pci_device_id azx_id/* CometLake-H */ { PCI_DEVICE(0x8086, 0x06C8), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, + { PCI_DEVICE(0x8086, 0xf1c8), + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, /* CometLake-S */ { PCI_DEVICE(0x8086, 0xa3f0), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
Greg Kroah-Hartman
maintainerPATCH 253/340 ALSA: hda/realtek: modify EAPD in the ALC886
In reply to Greg Kroah-HartmanFrom: PeiSen Hou <[email protected]>
commit 4841b8e6318a7f0ae57c4e5ec09032ea057c97a8 upstream.
Modify 0x20 index 7 bit 5 to 1, make the 0x15 EAPD the same as 0x14.
--- sound/pci/hda/patch_realtek.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/pci/hda/patch_realtek.c +11 -0
@@ -1895,6 +1895,7 @@ enum {ALC889_FIXUP_FRONT_HP_NO_PRESENCE ,ALC889_FIXUP_VAIO_TT ,ALC888_FIXUP_EEE1601 , +ALC886_FIXUP_EAPD ,ALC882_FIXUP_EAPD ,ALC883_FIXUP_EAPD , ALC883_FIXUP_ACER_EAPD,
@@ -2228,6 +2229,15 @@ static const struct hda_fixup alc882_fix { } } }, + [ALC886_FIXUP_EAPD] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb[]) { + /* change to EAPD mode */ + { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, + { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 }, + { } + } + }, [ALC882_FIXUP_EAPD] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb[]) {
@@ -2500,6 +2510,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x106b ,0x4a00 ,"Macbook 5,2" ,ALC889_FIXUP_MBA11_VREF ),SND_PCI_QUIRK (0x1071 ,0x8258 ,"Evesham Voyaeger" ,ALC882_FIXUP_EAPD ), +SND_PCI_QUIRK (0x13fe ,0x1009 ,"Advantech MIT-W101" ,ALC886_FIXUP_EAPD ),SND_PCI_QUIRK (0x1458 ,0xa002 ,"Gigabyte EP45-DS3/Z87X-UD3H" ,ALC889_FIXUP_FRONT_HP_NO_PRESENCE ),SND_PCI_QUIRK (0x1458 ,0xa0b8 ,"Gigabyte AZ370-Gaming" ,ALC1220_FIXUP_GB_DUAL_CODECS ), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
Greg Kroah-Hartman
maintainerPATCH 254/340 Revert "bcache: Kill btree_io_wq"
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit 9f233ffe02e5cef611100cd8c5bcf4de26ca7bef upstream.
This reverts commit 56b30770b27d54d68ad51eccc6d888282b568cee.
With the btree using the system_wq, I seem to see a lot more desktop latency than I should.
After some more investigation, it looks like the original assumption of 56b3077 no longer is true, and bcache has a very high potential of congesting the system_wq. In turn, this introduces laggy desktop performance, IO stalls (at least with btrfs), and input events may be delayed.
So let's revert this. It's important to note that the semantics of using system_wq previously mean that btree_io_wq should be created before and destroyed after other bcache wqs to keep the same assumptions.
--- drivers/md/bcache/bcache.h | 2 ++ drivers/md/bcache/btree.c | 21 +++++++++++++++++++-- drivers/md/bcache/super.c | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-)
drivers/md/bcache/bcache.h +2 -0
@@ -1027,5 +1027,7 @@ void bch_debug_exit(void);void bch_debug_init (void );void bch_request_exit (void );int bch_request_init (void ); +void bch_btree_exit (void ); +int bch_btree_init (void );#endif /* _BCACHE_H */
drivers/md/bcache/btree.c +19 -2
@@ -99,6 +99,8 @@#define PTR_HASH (c, k) \ (((k)->ptr[0] >> c->bucket_bits) | PTR_GEN(k, 0)) +static struct workqueue_struct *btree_io_wq; +#define insert_lock (s, b) ((b)->level <= (s)->lock)/*
@@ -366,7 +368,7 @@ static void __btree_node_write_done(strubtree_complete_write (b, w);if (btree_node_dirty (b)) -schedule_delayed_work (&b->work,30 *HZ ); +queue_delayed_work (btree_io_wq, &b->work,30 *HZ );closure_return_with_destructor (cl, btree_node_write_unlock); }
@@ -539,7 +541,7 @@ static void bch_btree_leaf_dirty(structBUG_ON (!i->keys);if (!btree_node_dirty (b)) -schedule_delayed_work (&b->work,30 *HZ ); +queue_delayed_work (btree_io_wq, &b->work,30 *HZ );set_btree_node_dirty (b);
@@ -2659,3 +2661,18 @@ void bch_keybuf_init(struct keybuf *buf)spin_lock_init (&buf->lock);array_allocator_init (&buf->freelist); } + +void bch_btree_exit (void ) +{ +if (btree_io_wq) +destroy_workqueue (btree_io_wq); +} + +int __init bch_btree_init (void ) +{ + btree_io_wq =create_singlethread_workqueue ("bch_btree_io" ); +if (!btree_io_wq) +return -ENOMEM ; + +return 0 ; +}
drivers/md/bcache/super.c +4 -0
@@ -2652,6 +2652,7 @@ static void bcache_exit(void)destroy_workqueue (bcache_wq);if (bch_journal_wq)destroy_workqueue (bch_journal_wq); +bch_btree_exit ();if (bcache_major)unregister_blkdev (bcache_major,"bcache" );
@@ -2707,6 +2708,9 @@ static int __init bcache_init(void)return bcache_major; } +if (bch_btree_init ()) + goto err; + bcache_wq =alloc_workqueue ("bcache" ,WQ_MEM_RECLAIM ,0 );if (!bcache_wq) goto err;
Greg Kroah-Hartman
maintainerPATCH 255/340 bcache: Give btree_io_wq correct semantics again
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit d797bd9897e3559eb48d68368550d637d32e468c upstream.
Before killing btree_io_wq, the queue was allocated using create_singlethread_workqueue() which has WQ_MEM_RECLAIM. After killing it, it no longer had this property but system_wq is not single threaded.
Let's combine both worlds and make it multi threaded but able to reclaim memory.
--- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/btree.c +1 -1
@@ -2670,7 +2670,7 @@ void bch_btree_exit(void)int __init bch_btree_init (void ) { - btree_io_wq =create_singlethread_workqueue ("bch_btree_io" ); + btree_io_wq =alloc_workqueue ("bch_btree_io" ,WQ_MEM_RECLAIM ,0 );if (!btree_io_wq)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 256/340 bcache: Move journal work to new flush wq
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit afe78ab46f638ecdf80a35b122ffc92c20d9ae5d upstream.
This is potentially long running and not latency sensitive, let's get it out of the way of other latency sensitive events.
As observed in the previous commit, the system_wq comes easily congested by bcache, and this fixes a few more stalls I was observing every once in a while.
Let's not make this WQ_MEM_RECLAIM as it showed to reduce performance of boot and file system operations in my tests. Also, without WQ_MEM_RECLAIM, I no longer see desktop stalls. This matches the previous behavior as system_wq also does no memory reclaim:
Quoted 2 lines
//
workqueue.c:system_wq=alloc_workqueue("events", 0, 0);
--- drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/journal.c | 4 ++-- drivers/md/bcache/super.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/md/bcache/bcache.h +1 -0
@@ -986,6 +986,7 @@ void bch_write_bdev_super(struct cached_extern struct workqueue_struct *bcache_wq;extern struct workqueue_struct *bch_journal_wq; +extern struct workqueue_struct *bch_flush_wq;extern struct mutex bch_register_lock;extern struct list_head bch_cache_sets;
drivers/md/bcache/journal.c +2 -2
@@ -958,8 +958,8 @@ atomic_t *bch_journal(struct cache_set *journal_try_write (c); }else if (!w->dirty) { w->dirty = true; -schedule_delayed_work (&c->journal.work, -msecs_to_jiffies (c->journal_delay_ms)); +queue_delayed_work (bch_flush_wq, &c->journal.work, +msecs_to_jiffies (c->journal_delay_ms));spin_unlock (&c->journal.lock); }else {spin_unlock (&c->journal.lock);
drivers/md/bcache/super.c +16 -0
@@ -48,6 +48,7 @@ static int bcache_major;static DEFINE_IDA (bcache_device_idx);static wait_queue_head_t unregister_wait;struct workqueue_struct *bcache_wq; +struct workqueue_struct *bch_flush_wq;struct workqueue_struct *bch_journal_wq;
@@ -2652,6 +2653,8 @@ static void bcache_exit(void)destroy_workqueue (bcache_wq);if (bch_journal_wq)destroy_workqueue (bch_journal_wq); +if (bch_flush_wq) +destroy_workqueue (bch_flush_wq);bch_btree_exit ();if (bcache_major)
@@ -2715,6 +2718,19 @@ static int __init bcache_init(void)if (!bcache_wq) goto err; +/* +* Let's not make this `WQ_MEM_RECLAIM` for the following reasons: +* +* 1. It used `system_wq` before which also does no memory reclaim. +* 2. With `WQ_MEM_RECLAIM` desktop stalls, increased boot times, and +* reduced throughput can be observed. +* +* We still want to user our own queue to not congest the `system_wq`. +*/ + bch_flush_wq =alloc_workqueue ("bch_flush" ,0 ,0 ); +if (!bch_flush_wq) + goto err; + bch_journal_wq =alloc_workqueue ("bch_journal" ,WQ_MEM_RECLAIM ,0 );if (!bch_journal_wq) goto err;
Greg Kroah-Hartman
maintainerPATCH 257/340 drm/amd/display: Add vupdate_no_lock interrupts for DCN2.1
In reply to Greg Kroah-HartmanFrom: Rodrigo Siqueira <[email protected]>
commit 688f97ed3f5e339c0c2c09d9ee7ff23d5807b0a7 upstream.
When run igt@kms_vrr in a device that uses DCN2.1 architecture, we noticed multiple failures. Furthermore, when we tested a VRR demo, we noticed a system hang where the mouse pointer still works, but the entire system freezes; in this case, we don't see any dmesg warning or failure messages kernel. This happens due to a lack of vupdate_no_lock interrupt, making the userspace wait eternally to get the event back. For fixing this issue, we need to add the vupdate_no_lock interrupt in the interrupt list.
--- drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c | 22 +++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c +22 -0
@@ -168,6 +168,11 @@ static const struct irq_source_info_func .ack = NULL }; +static const struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = { + .set =NULL , + .ack =NULL +}; +#undef BASE_INNER#define BASE_INNER (seg) DMU_BASE__INST0_SEG ## seg
@@ -230,6 +235,17 @@ static const struct irq_source_info_func .funcs = &vblank_irq_info_funcs\ } +/* vupdate_no_lock_int_entry maps to DC_IRQ_SOURCE_VUPDATEx, to match semantic +* of DCE's DC_IRQ_SOURCE_VUPDATEx. +*/ +#define vupdate_no_lock_int_entry (reg_num)\ + [DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\ + IRQ_REG_ENTRY(OTG, reg_num,\ + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_INT_EN,\ + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_EVENT_CLEAR),\ + .funcs = &vupdate_no_lock_irq_info_funcs\ + } +#define vblank_int_entry (reg_num)\ [DC_IRQ_SOURCE_VBLANK1 + reg_num] = {\ IRQ_REG_ENTRY(OTG, reg_num,\
@@ -338,6 +354,12 @@ irq_source_info_dcn21[DAL_IRQ_SOURCES_NUvupdate_int_entry (3 ),vupdate_int_entry (4 ),vupdate_int_entry (5 ), +vupdate_no_lock_int_entry (0 ), +vupdate_no_lock_int_entry (1 ), +vupdate_no_lock_int_entry (2 ), +vupdate_no_lock_int_entry (3 ), +vupdate_no_lock_int_entry (4 ), +vupdate_no_lock_int_entry (5 ),vblank_int_entry (0 ),vblank_int_entry (1 ), vblank_int_entry(2),
Greg Kroah-Hartman
maintainerPATCH 258/340 drm/amdgpu: Set reference clock to 100Mhz on Renoir (v2)
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 6e80fb8ab04f6c4f377e2fd422bdd1855beb7371 upstream.
Fixes the rlc reference clock used for GPU timestamps. Value is 100Mhz. Confirmed with hardware team.
v2: reword commit message.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -0
@@ -276,6 +276,8 @@ static u32 soc15_get_xclk(struct amdgpu_ {u32 reference_clock = adev->clock.spll.reference_freq; +if (adev->asic_type ==CHIP_RENOIR ) +return 10000 ;if (adev->asic_type ==CHIP_RAVEN )return reference_clock /4 ;
Greg Kroah-Hartman
maintainerPATCH 259/340 drm/nouveau/kms: handle mDP connectors
In reply to Greg Kroah-HartmanFrom: Karol Herbst <[email protected]>
commit d1f5a3fc85566e9ddce9361ef180f070367e6eab upstream.
In some cases we have the handle those explicitly as the fallback connector type detection fails and marks those as eDP connectors.
Attempting to use such a connector with mutter leads to a crash of mutter as it ends up with two eDP displays.
Information is taken from the official DCB documentation.
--- drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h | 1 + drivers/gpu/drm/nouveau/nouveau_connector.c | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h +1 -0
@@ -14,6 +14,7 @@ enum dcb_connector_type {DCB_CONNECTOR_LVDS_SPWG =0x41 ,DCB_CONNECTOR_DP =0x46 , DCB_CONNECTOR_eDP =0x47 , + DCB_CONNECTOR_mDP =0x48 ,DCB_CONNECTOR_HDMI_0 =0x60 ,DCB_CONNECTOR_HDMI_1 =0x61 , DCB_CONNECTOR_HDMI_C = 0x63,
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -0
@@ -1240,6 +1240,7 @@ drm_conntype_from_dcb(enum dcb_connectorcase DCB_CONNECTOR_DMS59_DP0 :case DCB_CONNECTOR_DMS59_DP1 :case DCB_CONNECTOR_DP : +case DCB_CONNECTOR_mDP :case DCB_CONNECTOR_USB_C :return DRM_MODE_CONNECTOR_DisplayPort;case DCB_CONNECTOR_eDP :return DRM_MODE_CONNECTOR_eDP;case DCB_CONNECTOR_HDMI_0 :
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Greg Kroah-Hartman
maintainerPATCH 260/340 drm/sched: Cancel and flush all outstanding jobs before finish.
In reply to Greg Kroah-HartmanFrom: Andrey Grodzovsky <[email protected]>
commit e582951baabba3e278c97169d0acc1e09b24a72e upstream.
To avoid any possible use after free.
--- drivers/gpu/drm/scheduler/sched_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +3 -0
@@ -851,6 +851,9 @@ void drm_sched_fini(struct drm_gpu_schedif (sched->thread)kthread_stop (sched->thread); +/* Confirm no work left behind accessing device structures */ +cancel_delayed_work_sync (&sched->work_tdr); + sched->ready = false; }EXPORT_SYMBOL (drm_sched_fini);
Greg Kroah-Hartman
maintainerPATCH 261/340 erofs: initialized fields can only be observed after bit is set
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit ce063129181312f8781a047a50be439c5859747b upstream.
Currently, although set_bit() & test_bit() pairs are used as a fast- path for initialized configurations. However, these atomic ops are actually relaxed forms. Instead, load-acquire & store-release form is needed to make sure uninitialized fields won't be observed in advance here (yet no such corresponding bitops so use full barriers instead.)
--- fs/erofs/xattr.c | 10 +++++++++- fs/erofs/zmap.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-)
fs/erofs/xattr.c +9 -1
@@ -48,8 +48,14 @@ static int init_inode_xattrs(struct inodint ret =0 ;/* the most case is that xattrs of this inode are initialized. */ -if (test_bit (EROFS_I_EA_INITED_BIT , &vi->flags)) +if (test_bit (EROFS_I_EA_INITED_BIT , &vi->flags)) { +/* +* paired with smp_mb() at the end of the function to ensure +* fields will only be observed after the bit is set. +*/ +smp_mb ();return 0 ; + }if (wait_on_bit_lock (&vi->flags,EROFS_I_BL_XATTR_BIT ,TASK_KILLABLE ))return -ERESTARTSYS ;
@@ -137,6 +143,8 @@ static int init_inode_xattrs(struct inod }xattr_iter_end (&it, atomic_map); +/* paired with smp_mb() at the beginning of the function. */ +smp_mb ();set_bit (EROFS_I_EA_INITED_BIT , &vi->flags); out_unlock:
fs/erofs/zmap.c +9 -1
@@ -36,8 +36,14 @@ static int fill_inode_lazy(struct inodevoid *kaddr;struct z_erofs_map_header *h; -if (test_bit (EROFS_I_Z_INITED_BIT , &vi->flags)) +if (test_bit (EROFS_I_Z_INITED_BIT , &vi->flags)) { +/* +* paired with smp_mb() at the end of the function to ensure +* fields will only be observed after the bit is set. +*/ +smp_mb ();return 0 ; + }if (wait_on_bit_lock (&vi->flags,EROFS_I_BL_Z_BIT ,TASK_KILLABLE ))return -ERESTARTSYS ;
@@ -83,6 +89,8 @@ static int fill_inode_lazy(struct inode vi->z_physical_clusterbits[1 ] = vi->z_logical_clusterbits + ((h->h_clusterbits >>5 ) &7 ); +/* paired with smp_mb() at the beginning of the function */ +smp_mb ();set_bit (EROFS_I_Z_INITED_BIT , &vi->flags); unmap_done:kunmap_atomic (kaddr);
Greg Kroah-Hartman
maintainerPATCH 262/340 tpm_tis: Fix check_locality for correct locality acquisition
In reply to Greg Kroah-HartmanFrom: James Bottomley <[email protected]>
commit 3d9ae54af1d02a7c0edc55c77d7df2b921e58a87 upstream.
The TPM TIS specification says the TPM signals the acquisition of locality when the TMP_ACCESS_REQUEST_USE bit goes to one *and* the TPM_ACCESS_REQUEST_USE bit goes to zero. Currently we only check the former not the latter, so check both. Adding the check on TPM_ACCESS_REQUEST_USE should fix the case where the locality is re-requested before the TPM has released it. In this case the locality may get released briefly before it is reacquired, which causes all sorts of problems. However, with the added check, TPM_ACCESS_REQUEST_USE should remain 1 until the second request for the locality is granted.
--- drivers/char/tpm/tpm_tis_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +2 -1
@@ -125,7 +125,8 @@ static bool check_locality(struct tpm_chif (rc <0 )return false; -if ((access & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) == +if ((access & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID + |TPM_ACCESS_REQUEST_USE )) == (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) { priv->locality = l;return true;
Greg Kroah-Hartman
maintainerPATCH 263/340 tpm_tis: Clean up locality release
In reply to Greg Kroah-HartmanFrom: James Bottomley <[email protected]>
commit e42acf104d6e0bd7ccd2f09103d5be5e6d3c637c upstream.
The current release locality code seems to be based on the misunderstanding that the TPM interrupts when a locality is released:
it doesn't, only when the locality is acquired.
Furthermore, there seems to be no point in waiting for the locality to be released. All it does is penalize the last TPM user. However, if there's no next TPM user, this is a pointless wait and if there is a next TPM user, they'll pay the penalty waiting for the new locality (or possibly not if it's the same as the old locality).
Fix the code by making release_locality as simple write to release with no waiting for completion.
--- drivers/char/tpm/tpm_tis_core.c | 47 ---------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -46
@@ -135,58 +135,13 @@ static bool check_locality(struct tpm_chreturn false; } -static bool locality_inactive (struct tpm_chip *chip,int l) -{ -struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev); -int rc; -u8 access; - - rc =tpm_tis_read8 (priv,TPM_ACCESS (l), &access); -if (rc <0 ) -return false; - -if ((access & (TPM_ACCESS_VALID |TPM_ACCESS_ACTIVE_LOCALITY )) - ==TPM_ACCESS_VALID ) -return true; - -return false; -} -static int release_locality (struct tpm_chip *chip,int l) {struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev); -unsigned long stop, timeout; -long rc;tpm_tis_write8 (priv,TPM_ACCESS (l),TPM_ACCESS_ACTIVE_LOCALITY ); - stop = jiffies + chip->timeout_a; - -if (chip->flags &TPM_CHIP_FLAG_IRQ ) { -again: - timeout = stop - jiffies; -if ((long )timeout <=0 ) -return -1 ; - - rc =wait_event_interruptible_timeout (priv->int_queue, - (locality_inactive (chip, l)), - timeout); - -if (rc >0 ) -return 0 ; - -if (rc == -ERESTARTSYS &&freezing (current)) { -clear_thread_flag (TIF_SIGPENDING ); - goto again; - } - }else { -do { -if (locality_inactive (chip, l)) -return 0 ; -tpm_msleep (TPM_TIMEOUT ); - }while (time_before (jiffies, stop)); - } -return -1 ; +return 0 ; }static int request_locality (struct tpm_chip *chip,int l)
Greg Kroah-Hartman
maintainerPATCH 264/340 KEYS: trusted: Fix migratable=1 failing
In reply to Greg Kroah-HartmanFrom: Jarkko Sakkinen <[email protected]>
commit 8da7520c80468c48f981f0b81fc1be6599e3b0ad upstream.
Consider the following transcript:
$ keyctl add trusted kmk "new 32 blobauth=helloworld keyhandle=80000000 migratable=1" @u add_key: Invalid argument
The documentation has the following description:
migratable= 0|1 indicating permission to reseal to new PCR values,
default 1 (resealing allowed)
The consequence is that "migratable=1" should succeed. Fix this by allowing this condition to pass instead of return -EINVAL.
[*] Documentation/security/keys/trusted-encrypted.rst
--- security/keys/trusted.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/trusted.c +1 -1
@@ -805,7 +805,7 @@ static int getoptions(char *c, struct trcase Opt_migratable:if (*args[0 ].from =='0' ) pay->migratable =0 ; -else +else if (*args[0 ].from !='1' )return -EINVAL ;break ;case Opt_pcrlock:
Greg Kroah-Hartman
maintainerPATCH 265/340 btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 867ed321f90d06aaba84e2c91de51cd3038825ef upstream.
While testing my error handling patches, I added a error injection site at btrfs_inc_extent_ref, to validate the error handling I added was doing the correct thing. However I hit a pretty ugly corruption while doing this check, with the following error injection stack trace:
btrfs_inc_extent_ref
btrfs_copy_root
create_reloc_root
btrfs_init_reloc_root
btrfs_record_root_in_trans
btrfs_start_transaction
btrfs_update_inode
btrfs_update_time
touch_atime
file_accessed
btrfs_file_mmap
This is because we do not catch the error from btrfs_inc_extent_ref, which in practice would be ENOMEM, which means we lose the extent references for a root that has already been allocated and inserted, which is the problem. Fix this by aborting the transaction if we fail to do the reference modification.
--- fs/btrfs/ctree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +3 -2
@@ -260,9 +260,10 @@ int btrfs_copy_root(struct btrfs_trans_h ret =btrfs_inc_ref (trans, root, cow,1 ); else ret =btrfs_inc_ref (trans, root, cow,0 ); - -if (ret) +if (ret) { +btrfs_abort_transaction (trans, ret);return ret; + }btrfs_mark_buffer_dirty (cow); *cow_ret = cow;
Greg Kroah-Hartman
maintainerPATCH 266/340 btrfs: fix reloc root leak with 0 ref reloc roots on recovery
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit c78a10aebb275c38d0cfccae129a803fe622e305 upstream.
When recovering a relocation, if we run into a reloc root that has 0 refs we simply add it to the reloc_control->reloc_roots list, and then clean it up later. The problem with this is __del_reloc_root() doesn't do anything if the root isn't in the radix tree, which in this case it won't be because we never call __add_reloc_root() on the reloc_root.
This exit condition simply isn't correct really. During normal operation we can remove ourselves from the rb tree and then we're meant to clean up later at merge_reloc_roots() time, and this happens correctly. During recovery we're depending on free_reloc_roots() to drop our references, but we're short-circuiting.
Fix this by continuing to check if we're on the list and dropping ourselves from the reloc_control root list and dropping our reference appropriately. Change the corresponding BUG_ON() to an ASSERT() that does the correct thing if we aren't in the rb tree.
--- fs/btrfs/relocation.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/relocation.c +1 -3
@@ -1336,9 +1336,7 @@ static void __del_reloc_root(struct btrfRB_CLEAR_NODE (&node->rb_node); }spin_unlock (&rc->reloc_root_tree.lock); -if (!node) -return ; -BUG_ON ((struct btrfs_root *)node->data != root); +ASSERT (!node || (struct btrfs_root *)node->data == root); }spin_lock (&fs_info->trans_lock);
Greg Kroah-Hartman
maintainerPATCH 267/340 btrfs: splice remaining dirty_bgs onto the transaction dirty bg list
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 938fcbfb0cbcf532a1869efab58e6009446b1ced upstream.
While doing error injection testing with my relocation patches I hit the following assert:
assertion failed: list_empty(&block_group->dirty_list), in fs/btrfs/block-group.c:3356
------------[ cut here ]------------ kernel BUG at fs/btrfs/ctree.h:3357! invalid opcode: 0000 [#1] SMP NOPTI CPU: 0 PID: 24351 Comm: umount Tainted: G W 5.10.0-rc3+ #193 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 RIP: 0010:assertfail.constprop.0+0x18/0x1a RSP: 0018:ffffa09b019c7e00 EFLAGS: 00010282 RAX: 0000000000000056 RBX: ffff8f6492c18000 RCX: 0000000000000000 RDX: ffff8f64fbc27c60 RSI: ffff8f64fbc19050 RDI: ffff8f64fbc19050 RBP: ffff8f6483bbdc00 R08: 0000000000000000 R09: 0000000000000000 R10: ffffa09b019c7c38 R11: ffffffff85d70928 R12: ffff8f6492c18100 R13: ffff8f6492c18148 R14: ffff8f6483bbdd70 R15: dead000000000100 FS: 00007fbfda4cdc40(0000) GS:ffff8f64fbc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fbfda666fd0 CR3: 000000013cf66002 CR4: 0000000000370ef0 Call Trace: btrfs_free_block_groups.cold+0x55/0x55 close_ctree+0x2c5/0x306 ? fsnotify_destroy_marks+0x14/0x100 generic_shutdown_super+0x6c/0x100 kill_anon_super+0x14/0x30 btrfs_kill_super+0x12/0x20 deactivate_locked_super+0x36/0xa0 cleanup_mnt+0x12d/0x190 task_work_run+0x5c/0xa0 exit_to_user_mode_prepare+0x1b1/0x1d0 syscall_exit_to_user_mode+0x54/0x280 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This happened because I injected an error in btrfs_cow_block() while running the dirty block groups. When we run the dirty block groups, we splice the list onto a local list to process. However if an error occurs, we only cleanup the transactions dirty block group list, not any pending block groups we have on our locally spliced list.
In fact if we fail to allocate a path in this function we'll also fail to clean up the splice list.
Fix this by splicing the list back onto the transaction dirty block group list so that the block groups are cleaned up. Then add a 'out' label and have the error conditions jump to out so that the errors are handled properly. This also has the side-effect of fixing a problem where we would clear 'ret' on error because we unconditionally ran btrfs_run_delayed_refs().
--- fs/btrfs/block-group.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
fs/btrfs/block-group.c +12 -7
@@ -2391,8 +2391,10 @@ again:if (!path) { path =btrfs_alloc_path (); -if (!path) -return -ENOMEM ; +if (!path) { + ret = -ENOMEM ; + goto out; + } }/*
@@ -2487,16 +2489,14 @@ again:btrfs_put_block_group (cache);if (drop_reserve)btrfs_delayed_refs_rsv_release (fs_info,1 ); - -if (ret) -break ; -/* * Avoid blocking other tasks for too long. It might even save * us from writing caches for block groups that are going to be * removed. */ mutex_unlock (&trans->transaction->cache_write_mutex); +if (ret) + goto out;mutex_lock (&trans->transaction->cache_write_mutex); }mutex_unlock (&trans->transaction->cache_write_mutex);
@@ -2520,7 +2520,12 @@ again: goto again; }spin_unlock (&cur_trans->dirty_bgs_lock); - }else if (ret <0 ) { + } +out: +if (ret <0 ) { +spin_lock (&cur_trans->dirty_bgs_lock); +list_splice_init (&dirty, &cur_trans->dirty_bgs); +spin_unlock (&cur_trans->dirty_bgs_lock);btrfs_cleanup_dirty_bgs (cur_trans, fs_info); }
Greg Kroah-Hartman
maintainerPATCH 268/340 btrfs: fix extent buffer leak on failure to copy root
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 72c9925f87c8b74f36f8e75a4cd93d964538d3ca upstream.
At btrfs_copy_root(), if the call to btrfs_inc_ref() fails we end up returning without unlocking and releasing our reference on the extent buffer named "cow" we previously allocated with btrfs_alloc_tree_block().
So fix that by unlocking the extent buffer and dropping our reference on it before returning.
--- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
@@ -261,6 +261,8 @@ int btrfs_copy_root(struct btrfs_trans_helse ret =btrfs_inc_ref (trans, root, cow,0 );if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 269/340 crypto: arm64/sha - add missing module aliases
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 0df07d8117c3576f1603b05b84089742a118d10a upstream.
The accelerated, instruction based implementations of SHA1, SHA2 and SHA3 are autoloaded based on CPU capabilities, given that the code is modest in size, and widely used, which means that resolving the algo name, loading all compatible modules and picking the one with the highest priority is taken to be suboptimal.
However, if these algorithms are requested before this CPU feature based matching and autoloading occurs, these modules are not even considered, and we end up with suboptimal performance.
So add the missing module aliases for the various SHA implementations.
--- arch/arm64/crypto/sha1-ce-glue.c | 1 + arch/arm64/crypto/sha2-ce-glue.c | 2 ++ arch/arm64/crypto/sha3-ce-glue.c | 4 ++++ arch/arm64/crypto/sha512-ce-glue.c | 2 ++ 4 files changed, 9 insertions(+)
arch/arm64/crypto/sha1-ce-glue.c +1 -0
@@ -19,6 +19,7 @@MODULE_DESCRIPTION ("SHA1 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha1" );struct sha1_ce_state {struct sha1_state sst;
arch/arm64/crypto/sha2-ce-glue.c +2 -0
@@ -19,6 +19,8 @@MODULE_DESCRIPTION ("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha224" ); +MODULE_ALIAS_CRYPTO ("sha256" );struct sha256_ce_state {struct sha256_state sst;
arch/arm64/crypto/sha3-ce-glue.c +4 -0
@@ -23,6 +23,10 @@MODULE_DESCRIPTION ("SHA3 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha3-224" ); +MODULE_ALIAS_CRYPTO ("sha3-256" ); +MODULE_ALIAS_CRYPTO ("sha3-384" ); +MODULE_ALIAS_CRYPTO ("sha3-512" ); asmlinkage void sha3_ce_transform(u64 *st, const u8 *data, int blocks,int md_len);
arch/arm64/crypto/sha512-ce-glue.c +2 -0
@@ -23,6 +23,8 @@MODULE_DESCRIPTION ("SHA-384/SHA-512 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha384" ); +MODULE_ALIAS_CRYPTO ("sha512" ); asmlinkage void sha512_ce_transform(struct sha512_state *sst, u8 const *src,int blocks);
Greg Kroah-Hartman
maintainerPATCH 270/340 crypto: aesni - prevent misaligned buffers on the stack
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit a13ed1d15b07a04b1f74b2df61ff7a5e47f45dd8 upstream.
The GCM mode driver uses 16 byte aligned buffers on the stack to pass the IV to the asm helpers, but unfortunately, the x86 port does not guarantee that the stack pointer is 16 byte aligned upon entry in the first place. Since the compiler is not aware of this, it will not emit the additional stack realignment sequence that is needed, and so the alignment is not guaranteed to be more than 8 bytes.
So instead, allocate some padding on the stack, and realign the IV pointer by hand.
--- arch/x86/crypto/aesni-intel_glue.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
arch/x86/crypto/aesni-intel_glue.c +16 -12
@@ -707,7 +707,8 @@ static int gcmaes_crypt_by_sg(bool enc,struct crypto_aead *tfm =crypto_aead_reqtfm (req);unsigned long auth_tag_len =crypto_aead_authsize (tfm);const struct aesni_gcm_tfm_s *gcm_tfm = aesni_gcm_tfm; - struct gcm_context_data data AESNI_ALIGN_ATTR; +u8 databuf[sizeof (struct gcm_context_data ) + (AESNI_ALIGN -8 )]__aligned(8) ; +struct gcm_context_data *data =PTR_ALIGN ((void *)databuf,AESNI_ALIGN );struct scatter_walk dst_sg_walk = {};unsigned long left = req->cryptlen;unsigned long len, srclen, dstlen;
@@ -760,8 +761,7 @@ static int gcmaes_crypt_by_sg(bool enc, }kernel_fpu_begin (); - gcm_tfm->init (aes_ctx, &data, iv, - hash_subkey, assoc, assoclen); + gcm_tfm->init (aes_ctx, data, iv, hash_subkey, assoc, assoclen);if (req->src != req->dst) {while (left) { src =scatterwalk_map (&src_sg_walk);
@@ -771,10 +771,10 @@ static int gcmaes_crypt_by_sg(bool enc, len =min (srclen, dstlen);if (len) {if (enc) - gcm_tfm->enc_update (aes_ctx, &data, + gcm_tfm->enc_update (aes_ctx, data, dst, src, len);else - gcm_tfm->dec_update (aes_ctx, &data, + gcm_tfm->dec_update (aes_ctx, data, dst, src, len); } left -= len;
@@ -792,10 +792,10 @@ static int gcmaes_crypt_by_sg(bool enc, len =scatterwalk_clamp (&src_sg_walk, left);if (len) {if (enc) - gcm_tfm->enc_update (aes_ctx, &data, + gcm_tfm->enc_update (aes_ctx, data, src, src, len);else - gcm_tfm->dec_update (aes_ctx, &data, + gcm_tfm->dec_update (aes_ctx, data, src, src, len); } left -= len;
@@ -804,7 +804,7 @@ static int gcmaes_crypt_by_sg(bool enc,scatterwalk_done (&src_sg_walk,1 , left); } } - gcm_tfm->finalize (aes_ctx, &data, authTag, auth_tag_len); + gcm_tfm->finalize (aes_ctx, data, authTag, auth_tag_len);kernel_fpu_end ();if (!assocmem)
@@ -853,7 +853,8 @@ static int helper_rfc4106_encrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct aesni_rfc4106_gcm_ctx *ctx =aesni_rfc4106_gcm_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );unsigned int i;__be32 counter =cpu_to_be32 (1 );
@@ -880,7 +881,8 @@ static int helper_rfc4106_decrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct aesni_rfc4106_gcm_ctx *ctx =aesni_rfc4106_gcm_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );unsigned int i;if (unlikely (req->assoclen !=16 && req->assoclen !=20 ))
@@ -1010,7 +1012,8 @@ static int generic_gcmaes_encrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct generic_gcmaes_ctx *ctx =generic_gcmaes_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );__be32 counter =cpu_to_be32 (1 );memcpy (iv, req->iv,12 );
@@ -1026,7 +1029,8 @@ static int generic_gcmaes_decrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct generic_gcmaes_ctx *ctx =generic_gcmaes_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );memcpy (iv, req->iv,12 ); *((__be32 *)(iv+12 )) = counter;
Greg Kroah-Hartman
maintainerPATCH 271/340 crypto: sun4i-ss - checking sg length is not sufficient
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 7bdcd851fa7eb66e8922aa7f6cba9e2f2427a7cf upstream.
The optimized cipher function need length multiple of 4 bytes. But it get sometimes odd length.
This is due to SG data could be stored with an offset.
So the fix is to check also if the offset is aligned with 4 bytes.
--- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +2 -2
@@ -203,12 +203,12 @@ static int sun4i_ss_cipher_poll(struct s* we can use the SS optimized function */ while (in_sg && no_chunk ==1 ) { -if (in_sg->length %4 ) +if ((in_sg->length | in_sg->offset) &3u ) no_chunk =0 ; in_sg =sg_next (in_sg); }while (out_sg && no_chunk ==1 ) { -if (out_sg->length %4 ) +if ((out_sg->length | out_sg->offset) &3u ) no_chunk =0 ; out_sg =sg_next (out_sg); }
Greg Kroah-Hartman
maintainerPATCH 272/340 crypto: sun4i-ss - IV register does not work on A10 and A13
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit b756f1c8fc9d84e3f546d7ffe056c5352f4aab05 upstream.
Allwinner A10 and A13 SoC have a version of the SS which produce invalid IV in IVx register.
Instead of adding a variant for those, let's convert SS to produce IV directly from data.
--- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 34 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +28 -6
@@ -20,6 +20,7 @@ static int noinline_for_stack sun4i_ss_ounsigned int ivsize =crypto_skcipher_ivsize (tfm);struct sun4i_cipher_req_ctx *ctx =skcipher_request_ctx (areq);u32 mode = ctx->mode; +void *backup_iv =NULL ;/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */ u32 rx_cnt =SS_RX_DEFAULT ;u32 tx_cnt =0 ;
@@ -44,6 +45,13 @@ static int noinline_for_stack sun4i_ss_oreturn -EINVAL ; } +if (areq->iv && ivsize >0 && mode &SS_DECRYPTION ) { + backup_iv =kzalloc (ivsize,GFP_KERNEL ); +if (!backup_iv) +return -ENOMEM ; +scatterwalk_map_and_copy (backup_iv, areq->src, areq->cryptlen - ivsize, ivsize,0 ); + } +spin_lock_irqsave (&ss->slock, flags);for (i =0 ; i < op->keylen; i +=4 )
@@ -117,9 +125,12 @@ static int noinline_for_stack sun4i_ss_o }while (oleft);if (areq->iv) { -for (i =0 ; i <4 && i < ivsize /4 ; i++) { - v =readl (ss->base +SS_IV0 + i *4 ); - *(u32 *)(areq->iv + i *4 ) = v; +if (mode &SS_DECRYPTION ) { +memcpy (areq->iv, backup_iv, ivsize); +kfree_sensitive (backup_iv); + }else { +scatterwalk_map_and_copy (areq->iv, areq->dst, areq->cryptlen - ivsize, + ivsize,0 ); } }
@@ -176,6 +187,7 @@ static int sun4i_ss_cipher_poll(struct sunsigned int ileft = areq->cryptlen;unsigned int oleft = areq->cryptlen;unsigned int todo; +void *backup_iv =NULL ;struct sg_mapping_iter mi, mo;unsigned long pi =0 , po =0 ;/* progress for in and out */ bool miter_err;
@@ -219,6 +231,13 @@ static int sun4i_ss_cipher_poll(struct sif (need_fallback)return sun4i_ss_cipher_poll_fallback (areq); +if (areq->iv && ivsize >0 && mode &SS_DECRYPTION ) { + backup_iv =kzalloc (ivsize,GFP_KERNEL ); +if (!backup_iv) +return -ENOMEM ; +scatterwalk_map_and_copy (backup_iv, areq->src, areq->cryptlen - ivsize, ivsize,0 ); + } +spin_lock_irqsave (&ss->slock, flags);for (i =0 ; i < op->keylen; i +=4 )
@@ -347,9 +366,12 @@ static int sun4i_ss_cipher_poll(struct ssg_miter_stop (&mo); }if (areq->iv) { -for (i =0 ; i <4 && i < ivsize /4 ; i++) { - v =readl (ss->base +SS_IV0 + i *4 ); - *(u32 *)(areq->iv + i *4 ) = v; +if (mode &SS_DECRYPTION ) { +memcpy (areq->iv, backup_iv, ivsize); +kfree_sensitive (backup_iv); + }else { +scatterwalk_map_and_copy (areq->iv, areq->dst, areq->cryptlen - ivsize, + ivsize,0 ); } }
Greg Kroah-Hartman
maintainerPATCH 273/340 crypto: sun4i-ss - handle BigEndian for cipher
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 5ab6177fa02df15cd8a02a1f1fb361d2d5d8b946 upstream.
Ciphers produce invalid results on BE.
Key and IV need to be written in LE.
--- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +6 -6
@@ -54,13 +54,13 @@ static int noinline_for_stack sun4i_ss_ospin_lock_irqsave (&ss->slock, flags); -for (i =0 ; i < op->keylen; i +=4 ) -writel (*(op->key + i /4 ), ss->base +SS_KEY0 + i); +for (i =0 ; i < op->keylen /4 ; i++) +writesl (ss->base +SS_KEY0 + i *4 , &op->key[i],1 );if (areq->iv) {for (i =0 ; i <4 && i < ivsize /4 ; i++) { v = *(u32 *)(areq->iv + i *4 ); -writel (v, ss->base +SS_IV0 + i *4 ); +writesl (ss->base +SS_IV0 + i *4 , &v,1 ); } }writel (mode, ss->base +SS_CTL );
@@ -240,13 +240,13 @@ static int sun4i_ss_cipher_poll(struct sspin_lock_irqsave (&ss->slock, flags); -for (i =0 ; i < op->keylen; i +=4 ) -writel (*(op->key + i /4 ), ss->base +SS_KEY0 + i); +for (i =0 ; i < op->keylen /4 ; i++) +writesl (ss->base +SS_KEY0 + i *4 , &op->key[i],1 );if (areq->iv) {for (i =0 ; i <4 && i < ivsize /4 ; i++) { v = *(u32 *)(areq->iv + i *4 ); -writel (v, ss->base +SS_IV0 + i *4 ); +writesl (ss->base +SS_IV0 + i *4 , &v,1 ); } }writel (mode, ss->base +SS_CTL );
Greg Kroah-Hartman
maintainerPATCH 274/340 crypto: sun4i-ss - initialize need_fallback
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 4ec8977b921fd9d512701e009ce8082cb94b5c1c upstream.
The need_fallback is never initialized and seem to be always true at runtime. So all hardware operations are always bypassed.
--- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +1 -1
@@ -196,7 +196,7 @@ static int sun4i_ss_cipher_poll(struct sunsigned int obo =0 ;/* offset in bufo*/ unsigned int obl =0 ;/* length of data in bufo */ unsigned long flags; -bool need_fallback; +bool need_fallback = false;if (!areq->cryptlen)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 275/340 seccomp: Add missing return in non-void function
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 04b38d012556199ba4c31195940160e0c44c64f0 upstream.
We don't actually care about the value, since the kernel will panic before that; but a value should nonetheless be returned, otherwise the compiler will complain.
--- kernel/seccomp.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/seccomp.c +2 -0
@@ -921,6 +921,8 @@ static int __seccomp_filter(int this_sys const bool recheck_after_trace) {BUG (); + +return -1 ; }#endif
Greg Kroah-Hartman
maintainerPATCH 276/340 misc: rtsx: init of rts522a add OCP power off when no card is present
In reply to Greg Kroah-HartmanFrom: Ricky Wu <[email protected]>
commit 920fd8a70619074eac7687352c8f1c6f3c2a64a5 upstream.
Power down OCP for power consumption
when no SD/MMC card is present
--- drivers/misc/cardreader/rts5227.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/cardreader/rts5227.c +5 -0
@@ -338,6 +338,11 @@ static int rts522a_extra_init_hw(struct {rts5227_extra_init_hw (pcr); +/* Power down OCP for power consumption */ +if (!pcr->card_exist) +rtsx_pci_write_register (pcr,FPDCTL ,OC_POWER_DOWN , +OC_POWER_DOWN ); +rtsx_pci_write_register (pcr,FUNC_FORCE_CTL ,FUNC_FORCE_UPME_XMT_DBG ,FUNC_FORCE_UPME_XMT_DBG );rtsx_pci_write_register (pcr,PCLK_CTL ,0x04 ,0x04 );
Greg Kroah-Hartman
maintainerPATCH 277/340 drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue
In reply to Greg Kroah-HartmanFrom: Sabyrzhan Tasbolatov <[email protected]>
commit 2fd10bcf0310b9525b2af9e1f7aa9ddd87c3772e upstream.
syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue() when num_pages is 0x100001, giving queue_size + queue_page_size bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER condition.
queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000.
[1]
Call Trace: alloc_pages include/linux/gfp.h:547 [inline] kmalloc_order+0x40/0x130 mm/slab_common.c:837 kmalloc_order_trace+0x15/0x70 mm/slab_common.c:853 kmalloc_large include/linux/slab.h:481 [inline] __kmalloc+0x257/0x330 mm/slub.c:3959 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:682 [inline] qp_host_alloc_queue drivers/misc/vmw_vmci/vmci_queue_pair.c:540 [inline] qp_broker_create drivers/misc/vmw_vmci/vmci_queue_pair.c:1351 [inline] qp_broker_alloc+0x936/0x2740 drivers/misc/vmw_vmci/vmci_queue_pair.c:1739
--- drivers/misc/vmw_vmci/vmci_queue_pair.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/vmw_vmci/vmci_queue_pair.c +3 -0
@@ -537,6 +537,9 @@ static struct vmci_queue *qp_host_alloc_ queue_page_size = num_pages *sizeof (*queue->kernel_if->u.h.page); +if (queue_size + queue_page_size >KMALLOC_MAX_SIZE ) +return NULL ; + queue =kzalloc (queue_size + queue_page_size,GFP_KERNEL );if (queue) { queue->q_header =NULL ;
Greg Kroah-Hartman
maintainerPATCH 278/340 pstore: Fix typo in compression option name
In reply to Greg Kroah-HartmanFrom: Jiri Bohac <[email protected]>
commit 19d8e9149c27b689c6224f5c84b96a159342195a upstream.
Both pstore_compress() and decompress_record() use a mistyped config option name ("PSTORE_COMPRESSION" instead of "PSTORE_COMPRESS"). As a result compression and decompression of pstore records was always disabled.
Use the correct config option name.
--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/pstore/platform.c +2 -2
@@ -275,7 +275,7 @@ static int pstore_compress(const void *i {int ret; -if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION )) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ))return -EINVAL ; ret =crypto_comp_compress (tfm, in, inlen, out, &outlen);
@@ -664,7 +664,7 @@ static void decompress_record(struct pstint unzipped_len;char *unzipped, *workspace; -if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION ) || !record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */
Greg Kroah-Hartman
maintainerPATCH 279/340 dts64: mt7622: fix slow sd card access
In reply to Greg Kroah-HartmanFrom: Frank Wunderlich <[email protected]>
commit dc2e76175417e69c41d927dba75a966399f18354 upstream.
Fix extreme slow speed (200MB takes ~20 min) on writing sdcard on bananapi-r64 by adding reset-control for mmc1 like it's done for mmc0/emmc.
--- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +2 -0
@@ -698,6 +698,8 @@ clocks = <&pericfg CLK_PERI_MSDC30_1_PD>, <&topckgen CLK_TOP_AXI_SEL>; clock-names = "source", "hclk"; + resets = <&pericfg MT7622_PERI_MSDC1_SW_RST>; + reset-names = "hrst"; status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 280/340 staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c
In reply to Greg Kroah-HartmanFrom: Ilya Lipnitskiy <[email protected]>
commit 1f92798cbe7fe923479cff754dd06dd23d352e36 upstream.
Also use KBUILD_MODNAME for module name.
This driver is only used by RALINK MIPS MT7621 SoCs. Tested by building against that target using OpenWrt with Linux 5.10.10.
Fixes the following error:
error: the following would cause module name conflict:
drivers/dma/mediatek/mtk-hsdma.ko drivers/staging/mt7621-dma/mtk-hsdma.ko
---
drivers/staging/mt7621-dma/Makefile | 2
drivers/staging/mt7621-dma/hsdma-mt7621.c | 762 ++++++++++++++++++++++++++++++
drivers/staging/mt7621-dma/mtk-hsdma.c | 762 ------------------------------
3 files changed, 763 insertions(+), 763 deletions(-)
rename drivers/staging/mt7621-dma/{mtk-hsdma.c => hsdma-mt7621.c} (99%)drivers/staging/mt7621-dma/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o +obj-$(CONFIG_MTK_HSDMA) += hsdma-mt7621.o ccflags-y += -I$(srctree)/drivers/dma
drivers/staging/mt7621-dma/hsdma-mt7621.c new file +762 -0
762 lines not on this page · raw message
drivers/staging/mt7621-dma/mtk-hsdma.c deleted +0 -762
762 lines not on this page · raw message
Re: [PATCH 5.4 280/340] staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c
Sorry, I should have been more clear in my original email, but we don't strictly need this in 5.4 as the check only became fatal in 5.10 (actually, before 5.10, but 5.10 is the first stable release with it). Feel free to take or omit this from 5.4.
Quoted 1,567 lines · Greg Kroah-Hartman
From: Ilya Lipnitskiy <[email protected]>
commit
1f92798cbe7fe923479cff754dd06dd23d352e36upstream.Also use
KBUILD_MODNAMEfor module name.This driver is only used by RALINK MIPS MT7621 SoCs. Tested by building against that target using OpenWrt with Linux 5.10.10.
Fixes the following error:
error: the following would cause module name conflict:
drivers/dma/mediatek/mtk-hsdma.kodrivers/staging/mt7621-dma/mtk-hsdma.koCc Masahiro Yamada <[email protected]>Signed-off-by Ilya Lipnitskiy <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/staging/mt7621-dma/Makefile | 2 drivers/staging/mt7621-dma/hsdma-mt7621.c | 762 ++++++++++++++++++++++++++++++ drivers/staging/mt7621-dma/mtk-hsdma.c | 762 ------------------------------ 3 files changed, 763 insertions(+), 763 deletions(-) rename drivers/staging/mt7621-dma/{mtk-hsdma.c => hsdma-mt7621.c} (99%)drivers/staging/mt7621-dma/Makefile +1
-1@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o +obj-$(CONFIG_MTK_HSDMA) += hsdma-mt7621.o ccflags-y += -I$(srctree)/drivers/dmadrivers/staging/mt7621-dma/hsdma-mt7621.c new file +762
-0@@ -0,0 +1,762 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2015, Michael Lee <[email protected]> +* MTK HSDMA support +*/ + +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/list.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include <linux/irq.h> +#include <linux/of_dma.h> +#include <linux/reset.h> +#include <linux/of_device.h> + +#include "virt-dma.h" + +#define HSDMA_BASE_OFFSET 0x800 + +#define HSDMA_REG_TX_BASE 0x00 +#define HSDMA_REG_TX_CNT 0x04 +#define HSDMA_REG_TX_CTX 0x08 +#define HSDMA_REG_TX_DTX 0x0c +#define HSDMA_REG_RX_BASE 0x100 +#define HSDMA_REG_RX_CNT 0x104 +#define HSDMA_REG_RX_CRX 0x108 +#define HSDMA_REG_RX_DRX 0x10c +#define HSDMA_REG_INFO 0x200 +#define HSDMA_REG_GLO_CFG 0x204 +#define HSDMA_REG_RST_CFG 0x208 +#define HSDMA_REG_DELAY_INT 0x20c +#define HSDMA_REG_FREEQ_THRES 0x210 +#define HSDMA_REG_INT_STATUS 0x220 +#define HSDMA_REG_INT_MASK 0x228 +#define HSDMA_REG_SCH_Q01 0x280 +#define HSDMA_REG_SCH_Q23 0x284 + +#define HSDMA_DESCS_MAX 0xfff +#define HSDMA_DESCS_NUM 8 +#define HSDMA_DESCS_MASK (HSDMA_DESCS_NUM - 1) +#define HSDMA_NEXT_DESC (x) (((x) + 1) & HSDMA_DESCS_MASK) + +/* HSDMA_REG_INFO */ +#define HSDMA_INFO_INDEX_MASK 0xf +#define HSDMA_INFO_INDEX_SHIFT 24 +#define HSDMA_INFO_BASE_MASK 0xff +#define HSDMA_INFO_BASE_SHIFT 16 +#define HSDMA_INFO_RX_MASK 0xff +#define HSDMA_INFO_RX_SHIFT 8 +#define HSDMA_INFO_TX_MASK 0xff +#define HSDMA_INFO_TX_SHIFT 0 + +/* HSDMA_REG_GLO_CFG */ +#define HSDMA_GLO_TX_2B_OFFSET BIT(31) +#define HSDMA_GLO_CLK_GATE BIT(30) +#define HSDMA_GLO_BYTE_SWAP BIT(29) +#define HSDMA_GLO_MULTI_DMA BIT(10) +#define HSDMA_GLO_TWO_BUF BIT(9) +#define HSDMA_GLO_32B_DESC BIT(8) +#define HSDMA_GLO_BIG_ENDIAN BIT(7) +#define HSDMA_GLO_TX_DONE BIT(6) +#define HSDMA_GLO_BT_MASK 0x3 +#define HSDMA_GLO_BT_SHIFT 4 +#define HSDMA_GLO_RX_BUSY BIT(3) +#define HSDMA_GLO_RX_DMA BIT(2) +#define HSDMA_GLO_TX_BUSY BIT(1) +#define HSDMA_GLO_TX_DMA BIT(0) + +#define HSDMA_BT_SIZE_16BYTES (0 << HSDMA_GLO_BT_SHIFT) +#define HSDMA_BT_SIZE_32BYTES (1 << HSDMA_GLO_BT_SHIFT) +#define HSDMA_BT_SIZE_64BYTES (2 << HSDMA_GLO_BT_SHIFT) +#define HSDMA_BT_SIZE_128BYTES (3 << HSDMA_GLO_BT_SHIFT) + +#define HSDMA_GLO_DEFAULT (HSDMA_GLO_MULTI_DMA | \ + HSDMA_GLO_RX_DMA | HSDMA_GLO_TX_DMA | HSDMA_BT_SIZE_32BYTES) + +/* HSDMA_REG_RST_CFG */ +#define HSDMA_RST_RX_SHIFT 16 +#define HSDMA_RST_TX_SHIFT 0 + +/* HSDMA_REG_DELAY_INT */ +#define HSDMA_DELAY_INT_EN BIT(15) +#define HSDMA_DELAY_PEND_OFFSET 8 +#define HSDMA_DELAY_TIME_OFFSET 0 +#define HSDMA_DELAY_TX_OFFSET 16 +#define HSDMA_DELAY_RX_OFFSET 0 + +#define HSDMA_DELAY_INIT (x) (HSDMA_DELAY_INT_EN | \ + ((x) << HSDMA_DELAY_PEND_OFFSET)) +#define HSDMA_DELAY (x) ((HSDMA_DELAY_INIT(x) << \ + HSDMA_DELAY_TX_OFFSET) | HSDMA_DELAY_INIT(x)) + +/* HSDMA_REG_INT_STATUS */ +#define HSDMA_INT_DELAY_RX_COH BIT(31) +#define HSDMA_INT_DELAY_RX_INT BIT(30) +#define HSDMA_INT_DELAY_TX_COH BIT(29) +#define HSDMA_INT_DELAY_TX_INT BIT(28) +#define HSDMA_INT_RX_MASK 0x3 +#define HSDMA_INT_RX_SHIFT 16 +#define HSDMA_INT_RX_Q0 BIT(16) +#define HSDMA_INT_TX_MASK 0xf +#define HSDMA_INT_TX_SHIFT 0 +#define HSDMA_INT_TX_Q0 BIT(0) + +/* tx/rx dma desc flags */ +#define HSDMA_PLEN_MASK 0x3fff +#define HSDMA_DESC_DONE BIT(31) +#define HSDMA_DESC_LS0 BIT(30) +#define HSDMA_DESC_PLEN0 (_x) (((_x) & HSDMA_PLEN_MASK) << 16) +#define HSDMA_DESC_TAG BIT(15) +#define HSDMA_DESC_LS1 BIT(14) +#define HSDMA_DESC_PLEN1 (_x) ((_x) & HSDMA_PLEN_MASK) + +/* align 4 bytes */ +#define HSDMA_ALIGN_SIZE 3 +/* align size 128bytes */ +#define HSDMA_MAX_PLEN 0x3f80 + +struct hsdma_desc { +u32 addr0; +u32 flags; +u32 addr1; +u32 unused; +}; + +struct mtk_hsdma_sg { +dma_addr_t src_addr; +dma_addr_t dst_addr; +u32 len; +}; + +struct mtk_hsdma_desc { +struct virt_dma_desc vdesc; +unsigned int num_sgs; +struct mtk_hsdma_sg sg[1 ]; +}; + +struct mtk_hsdma_chan { +struct virt_dma_chan vchan; +unsigned int id; +dma_addr_t desc_addr; +int tx_idx; +int rx_idx; +struct hsdma_desc *tx_ring; +struct hsdma_desc *rx_ring; +struct mtk_hsdma_desc *desc; +unsigned int next_sg; +}; + +struct mtk_hsdam_engine { +struct dma_device ddev; +struct device_dma_parameters dma_parms; +void __iomem *base; +struct tasklet_struct task; +volatile unsigned long chan_issued; + +struct mtk_hsdma_chan chan[1 ]; +}; + +static inline struct mtk_hsdam_engine *mtk_hsdma_chan_get_dev ( +struct mtk_hsdma_chan *chan) +{ + return container_of(chan->vchan.chan.device, struct mtk_hsdam_engine, + ddev); +} + +static inline struct mtk_hsdma_chan *to_mtk_hsdma_chan (struct dma_chan *c) +{ + return container_of(c, struct mtk_hsdma_chan, vchan.chan); +} + +static inline struct mtk_hsdma_desc *to_mtk_hsdma_desc ( +struct virt_dma_desc *vdesc) +{ + return container_of(vdesc, struct mtk_hsdma_desc, vdesc); +} + +static inline u32 mtk_hsdma_read (struct mtk_hsdam_engine *hsdma,u32 reg) +{ +return readl (hsdma->base + reg); +} + +static inline void mtk_hsdma_write (struct mtk_hsdam_engine *hsdma, +unsigned int reg,u32 val) +{ +writel (val, hsdma->base + reg); +} + +static void mtk_hsdma_reset_chan (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ + chan->tx_idx =0 ; + chan->rx_idx =HSDMA_DESCS_NUM -1 ; + +mtk_hsdma_write (hsdma,HSDMA_REG_TX_CTX , chan->tx_idx); +mtk_hsdma_write (hsdma,HSDMA_REG_RX_CRX , chan->rx_idx); + +mtk_hsdma_write (hsdma,HSDMA_REG_RST_CFG , +0x1 << (chan->id +HSDMA_RST_TX_SHIFT )); +mtk_hsdma_write (hsdma,HSDMA_REG_RST_CFG , +0x1 << (chan->id +HSDMA_RST_RX_SHIFT )); +} + +static void hsdma_dump_reg (struct mtk_hsdam_engine *hsdma) +{ +dev_dbg (hsdma->ddev.dev,"tbase %08x, tcnt %08x, " \ +"tctx %08x, tdtx: %08x, rbase %08x, " \ +"rcnt %08x, rctx %08x, rdtx %08x\n" , +mtk_hsdma_read (hsdma,HSDMA_REG_TX_BASE ), +mtk_hsdma_read (hsdma,HSDMA_REG_TX_CNT ), +mtk_hsdma_read (hsdma,HSDMA_REG_TX_CTX ), +mtk_hsdma_read (hsdma,HSDMA_REG_TX_DTX ), +mtk_hsdma_read (hsdma,HSDMA_REG_RX_BASE ), +mtk_hsdma_read (hsdma,HSDMA_REG_RX_CNT ), +mtk_hsdma_read (hsdma,HSDMA_REG_RX_CRX ), +mtk_hsdma_read (hsdma,HSDMA_REG_RX_DRX )); + +dev_dbg (hsdma->ddev.dev,"info %08x, glo %08x, delay %08x, " \ +"intr_stat %08x, intr_mask %08x\n" , +mtk_hsdma_read (hsdma,HSDMA_REG_INFO ), +mtk_hsdma_read (hsdma,HSDMA_REG_GLO_CFG ), +mtk_hsdma_read (hsdma,HSDMA_REG_DELAY_INT ), +mtk_hsdma_read (hsdma,HSDMA_REG_INT_STATUS ), +mtk_hsdma_read (hsdma,HSDMA_REG_INT_MASK )); +} + +static void hsdma_dump_desc (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +struct hsdma_desc *tx_desc; +struct hsdma_desc *rx_desc; +int i; + +dev_dbg (hsdma->ddev.dev,"tx idx: %d, rx idx: %d\n" , + chan->tx_idx, chan->rx_idx); + +for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { + tx_desc = &chan->tx_ring[i]; + rx_desc = &chan->rx_ring[i]; + +dev_dbg (hsdma->ddev.dev,"%d tx addr0: %08x, flags %08x, " \ +"tx addr1: %08x, rx addr0 %08x, flags %08x\n" , + i, tx_desc->addr0, tx_desc->flags, \ + tx_desc->addr1, rx_desc->addr0, rx_desc->flags); + } +} + +static void mtk_hsdma_reset (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +int i; + +/* disable dma */ +mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,0 ); + +/* disable intr */ +mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,0 ); + +/* init desc value */ +for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { + chan->tx_ring[i].addr0 =0 ; + chan->tx_ring[i].flags =HSDMA_DESC_LS0 |HSDMA_DESC_DONE ; + } +for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { + chan->rx_ring[i].addr0 =0 ; + chan->rx_ring[i].flags =0 ; + } + +/* reset */ +mtk_hsdma_reset_chan (hsdma, chan); + +/* enable intr */ +mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,HSDMA_INT_RX_Q0 ); + +/* enable dma */ +mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,HSDMA_GLO_DEFAULT ); +} + +static int mtk_hsdma_terminate_all (struct dma_chan *c) +{ +struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); +struct mtk_hsdam_engine *hsdma =mtk_hsdma_chan_get_dev (chan); +unsigned long timeout; +LIST_HEAD (head); + +spin_lock_bh (&chan->vchan.lock); + chan->desc =NULL ; +clear_bit (chan->id, &hsdma->chan_issued); +vchan_get_all_descriptors (&chan->vchan, &head); +spin_unlock_bh (&chan->vchan.lock); + +vchan_dma_desc_free_list (&chan->vchan, &head); + +/* wait dma transfer complete */ + timeout = jiffies +msecs_to_jiffies (2000 ); +while (mtk_hsdma_read (hsdma,HSDMA_REG_GLO_CFG ) & + (HSDMA_GLO_RX_BUSY |HSDMA_GLO_TX_BUSY )) { +if (time_after_eq (jiffies, timeout)) { +hsdma_dump_desc (hsdma, chan); +mtk_hsdma_reset (hsdma, chan); +dev_err (hsdma->ddev.dev,"timeout, reset it\n" ); +break ; + } +cpu_relax (); + } + +return 0 ; +} + +static int mtk_hsdma_start_transfer (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +dma_addr_t src, dst; +size_t len, tlen; +struct hsdma_desc *tx_desc, *rx_desc; +struct mtk_hsdma_sg *sg; +unsigned int i; +int rx_idx; + + sg = &chan->desc->sg[0 ]; + len = sg->len; + chan->desc->num_sgs =DIV_ROUND_UP (len,HSDMA_MAX_PLEN ); + +/* tx desc */ + src = sg->src_addr; +for (i =0 ; i < chan->desc->num_sgs; i++) { + tx_desc = &chan->tx_ring[chan->tx_idx]; + +if (len >HSDMA_MAX_PLEN ) + tlen =HSDMA_MAX_PLEN ; +else + tlen = len; + +if (i &0x1 ) { + tx_desc->addr1 = src; + tx_desc->flags |=HSDMA_DESC_PLEN1 (tlen); + }else { + tx_desc->addr0 = src; + tx_desc->flags =HSDMA_DESC_PLEN0 (tlen); + +/* update index */ + chan->tx_idx =HSDMA_NEXT_DESC (chan->tx_idx); + } + + src += tlen; + len -= tlen; + } +if (i &0x1 ) + tx_desc->flags |=HSDMA_DESC_LS0 ; +else + tx_desc->flags |=HSDMA_DESC_LS1 ; + +/* rx desc */ + rx_idx =HSDMA_NEXT_DESC (chan->rx_idx); + len = sg->len; + dst = sg->dst_addr; +for (i =0 ; i < chan->desc->num_sgs; i++) { + rx_desc = &chan->rx_ring[rx_idx]; +if (len >HSDMA_MAX_PLEN ) + tlen =HSDMA_MAX_PLEN ; +else + tlen = len; + + rx_desc->addr0 = dst; + rx_desc->flags =HSDMA_DESC_PLEN0 (tlen); + + dst += tlen; + len -= tlen; + +/* update index */ + rx_idx =HSDMA_NEXT_DESC (rx_idx); + } + +/* make sure desc and index all up to date */ +wmb (); +mtk_hsdma_write (hsdma,HSDMA_REG_TX_CTX , chan->tx_idx); + +return 0 ; +} + +static int gdma_next_desc (struct mtk_hsdma_chan *chan) +{ +struct virt_dma_desc *vdesc; + + vdesc =vchan_next_desc (&chan->vchan); +if (!vdesc) { + chan->desc =NULL ; +return 0 ; + } + chan->desc =to_mtk_hsdma_desc (vdesc); + chan->next_sg =0 ; + +return 1 ; +} + +static void mtk_hsdma_chan_done (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +struct mtk_hsdma_desc *desc; +int chan_issued; + + chan_issued =0 ; +spin_lock_bh (&chan->vchan.lock); + desc = chan->desc; +if (likely (desc)) { +if (chan->next_sg == desc->num_sgs) { +list_del (&desc->vdesc.node); +vchan_cookie_complete (&desc->vdesc); + chan_issued =gdma_next_desc (chan); + } + }else { +dev_dbg (hsdma->ddev.dev,"no desc to complete\n" ); + } + +if (chan_issued) +set_bit (chan->id, &hsdma->chan_issued); +spin_unlock_bh (&chan->vchan.lock); +} + +static irqreturn_t mtk_hsdma_irq (int irq,void *devid) +{ +struct mtk_hsdam_engine *hsdma = devid; +u32 status; + + status =mtk_hsdma_read (hsdma,HSDMA_REG_INT_STATUS ); +if (unlikely (!status)) +return IRQ_NONE ; + +if (likely (status &HSDMA_INT_RX_Q0 )) +tasklet_schedule (&hsdma->task); +else +dev_dbg (hsdma->ddev.dev,"unhandle irq status %08x\n" , status); +/* clean intr bits */ +mtk_hsdma_write (hsdma,HSDMA_REG_INT_STATUS , status); + +return IRQ_HANDLED ; +} + +static void mtk_hsdma_issue_pending (struct dma_chan *c) +{ +struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); +struct mtk_hsdam_engine *hsdma =mtk_hsdma_chan_get_dev (chan); + +spin_lock_bh (&chan->vchan.lock); +if (vchan_issue_pending (&chan->vchan) && !chan->desc) { +if (gdma_next_desc (chan)) { +set_bit (chan->id, &hsdma->chan_issued); +tasklet_schedule (&hsdma->task); + }else { +dev_dbg (hsdma->ddev.dev,"no desc to issue\n" ); + } + } +spin_unlock_bh (&chan->vchan.lock); +} + +static struct dma_async_tx_descriptor *mtk_hsdma_prep_dma_memcpy ( +struct dma_chan *c,dma_addr_t dest,dma_addr_t src, +size_t len,unsigned long flags) +{ +struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); +struct mtk_hsdma_desc *desc; + +if (len <=0 ) +return NULL ; + + desc =kzalloc (sizeof (*desc),GFP_ATOMIC ); +if (!desc) { +dev_err (c->device->dev,"alloc memcpy decs error\n" ); +return NULL ; + } + + desc->sg[0 ].src_addr = src; + desc->sg[0 ].dst_addr = dest; + desc->sg[0 ].len = len; + +return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags); +} + +static enum dma_status mtk_hsdma_tx_status (struct dma_chan *c, +dma_cookie_t cookie, +struct dma_tx_state *state) +{ +return dma_cookie_status (c, cookie, state); +} + +static void mtk_hsdma_free_chan_resources (struct dma_chan *c) +{ +vchan_free_chan_resources (to_virt_chan (c)); +} + +static void mtk_hsdma_desc_free (struct virt_dma_desc *vdesc) +{ +kfree (container_of(vdesc ,struct mtk_hsdma_desc ,vdesc )); +} + +static void mtk_hsdma_tx (struct mtk_hsdam_engine *hsdma) +{ +struct mtk_hsdma_chan *chan; + +if (test_and_clear_bit (0 , &hsdma->chan_issued)) { + chan = &hsdma->chan[0 ]; +if (chan->desc) +mtk_hsdma_start_transfer (hsdma, chan); +else +dev_dbg (hsdma->ddev.dev,"chan 0 no desc to issue\n" ); + } +} + +static void mtk_hsdma_rx (struct mtk_hsdam_engine *hsdma) +{ +struct mtk_hsdma_chan *chan; +int next_idx, drx_idx, cnt; + + chan = &hsdma->chan[0 ]; + next_idx =HSDMA_NEXT_DESC (chan->rx_idx); + drx_idx =mtk_hsdma_read (hsdma,HSDMA_REG_RX_DRX ); + + cnt = (drx_idx - next_idx) &HSDMA_DESCS_MASK ; +if (!cnt) +return ; + + chan->next_sg += cnt; + chan->rx_idx = (chan->rx_idx + cnt) &HSDMA_DESCS_MASK ; + +/* update rx crx */ +wmb (); +mtk_hsdma_write (hsdma,HSDMA_REG_RX_CRX , chan->rx_idx); + +mtk_hsdma_chan_done (hsdma, chan); +} + +static void mtk_hsdma_tasklet (unsigned long arg) +{ +struct mtk_hsdam_engine *hsdma = (struct mtk_hsdam_engine *)arg; + +mtk_hsdma_rx (hsdma); +mtk_hsdma_tx (hsdma); +} + +static int mtk_hsdam_alloc_desc (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +int i; + + chan->tx_ring =dma_alloc_coherent (hsdma->ddev.dev, +2 *HSDMA_DESCS_NUM *sizeof (*chan->tx_ring), + &chan->desc_addr,GFP_ATOMIC | __GFP_ZERO); +if (!chan->tx_ring) + goto no_mem; + + chan->rx_ring = &chan->tx_ring[HSDMA_DESCS_NUM ]; + +/* init tx ring value */ +for (i =0 ; i <HSDMA_DESCS_NUM ; i++) + chan->tx_ring[i].flags =HSDMA_DESC_LS0 |HSDMA_DESC_DONE ; + +return 0 ; +no_mem: +return -ENOMEM ; +} + +static void mtk_hsdam_free_desc (struct mtk_hsdam_engine *hsdma, +struct mtk_hsdma_chan *chan) +{ +if (chan->tx_ring) { +dma_free_coherent (hsdma->ddev.dev, +2 *HSDMA_DESCS_NUM *sizeof (*chan->tx_ring), + chan->tx_ring, chan->desc_addr); + chan->tx_ring =NULL ; + chan->rx_ring =NULL ; + } +} + +static int mtk_hsdma_init (struct mtk_hsdam_engine *hsdma) +{ +struct mtk_hsdma_chan *chan; +int ret; +u32 reg; + +/* init desc */ + chan = &hsdma->chan[0 ]; + ret =mtk_hsdam_alloc_desc (hsdma, chan); +if (ret) +return ret; + +/* tx */ +mtk_hsdma_write (hsdma,HSDMA_REG_TX_BASE , chan->desc_addr); +mtk_hsdma_write (hsdma,HSDMA_REG_TX_CNT ,HSDMA_DESCS_NUM ); +/* rx */ +mtk_hsdma_write (hsdma,HSDMA_REG_RX_BASE , chan->desc_addr + + (sizeof (struct hsdma_desc ) *HSDMA_DESCS_NUM )); +mtk_hsdma_write (hsdma,HSDMA_REG_RX_CNT ,HSDMA_DESCS_NUM ); +/* reset */ +mtk_hsdma_reset_chan (hsdma, chan); + +/* enable rx intr */ +mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,HSDMA_INT_RX_Q0 ); + +/* enable dma */ +mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,HSDMA_GLO_DEFAULT ); + +/* hardware info */ + reg =mtk_hsdma_read (hsdma,HSDMA_REG_INFO ); +dev_info (hsdma->ddev.dev,"rx: %d, tx: %d\n" , + (reg >>HSDMA_INFO_RX_SHIFT ) &HSDMA_INFO_RX_MASK , + (reg >>HSDMA_INFO_TX_SHIFT ) &HSDMA_INFO_TX_MASK ); + +hsdma_dump_reg (hsdma); + +return ret; +} + +static void mtk_hsdma_uninit (struct mtk_hsdam_engine *hsdma) +{ +struct mtk_hsdma_chan *chan; + +/* disable dma */ +mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,0 ); + +/* disable intr */ +mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,0 ); + +/* free desc */ + chan = &hsdma->chan[0 ]; +mtk_hsdam_free_desc (hsdma, chan); + +/* tx */ +mtk_hsdma_write (hsdma,HSDMA_REG_TX_BASE ,0 ); +mtk_hsdma_write (hsdma,HSDMA_REG_TX_CNT ,0 ); +/* rx */ +mtk_hsdma_write (hsdma,HSDMA_REG_RX_BASE ,0 ); +mtk_hsdma_write (hsdma,HSDMA_REG_RX_CNT ,0 ); +/* reset */ +mtk_hsdma_reset_chan (hsdma, chan); +} + +static const struct of_device_id mtk_hsdma_of_match[] = { + { .compatible ="mediatek,mt7621-hsdma" }, + { }, +}; + +static int mtk_hsdma_probe (struct platform_device *pdev) +{ +const struct of_device_id *match; +struct mtk_hsdma_chan *chan; +struct mtk_hsdam_engine *hsdma; +struct dma_device *dd; +struct resource *res; +int ret; +int irq; +void __iomem *base; + + ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; + + match =of_match_device (mtk_hsdma_of_match, &pdev->dev); +if (!match) +return -EINVAL ; + + hsdma =devm_kzalloc (&pdev->dev,sizeof (*hsdma),GFP_KERNEL ); +if (!hsdma) +return -EINVAL ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + hsdma->base = base +HSDMA_BASE_OFFSET ; +tasklet_init (&hsdma->task, mtk_hsdma_tasklet, (unsigned long )hsdma); + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return -EINVAL ; + ret =devm_request_irq (&pdev->dev, irq, mtk_hsdma_irq, +0 ,dev_name (&pdev->dev), hsdma); +if (ret) { +dev_err (&pdev->dev,"failed to request irq\n" ); +return ret; + } + +device_reset (&pdev->dev); + + dd = &hsdma->ddev; +dma_cap_set (DMA_MEMCPY , dd->cap_mask); + dd->copy_align =HSDMA_ALIGN_SIZE ; + dd->device_free_chan_resources = mtk_hsdma_free_chan_resources; + dd->device_prep_dma_memcpy = mtk_hsdma_prep_dma_memcpy; + dd->device_terminate_all = mtk_hsdma_terminate_all; + dd->device_tx_status = mtk_hsdma_tx_status; + dd->device_issue_pending = mtk_hsdma_issue_pending; + dd->dev = &pdev->dev; + dd->dev->dma_parms = &hsdma->dma_parms; +dma_set_max_seg_size (dd->dev,HSDMA_MAX_PLEN ); +INIT_LIST_HEAD (&dd->channels); + + chan = &hsdma->chan[0 ]; + chan->id =0 ; + chan->vchan.desc_free = mtk_hsdma_desc_free; +vchan_init (&chan->vchan, dd); + +/* init hardware */ + ret =mtk_hsdma_init (hsdma); +if (ret) { +dev_err (&pdev->dev,"failed to alloc ring descs\n" ); +return ret; + } + + ret =dma_async_device_register (dd); +if (ret) { +dev_err (&pdev->dev,"failed to register dma device\n" ); + goto err_uninit_hsdma; + } + + ret =of_dma_controller_register (pdev->dev.of_node, + of_dma_xlate_by_chan_id, hsdma); +if (ret) { +dev_err (&pdev->dev,"failed to register of dma controller\n" ); + goto err_unregister; + } + +platform_set_drvdata (pdev, hsdma); + +return 0 ; + +err_unregister: +dma_async_device_unregister (dd); +err_uninit_hsdma: +mtk_hsdma_uninit (hsdma); +return ret; +} + +static int mtk_hsdma_remove (struct platform_device *pdev) +{ +struct mtk_hsdam_engine *hsdma =platform_get_drvdata (pdev); + +mtk_hsdma_uninit (hsdma); + +of_dma_controller_free (pdev->dev.of_node); +dma_async_device_unregister (&hsdma->ddev); + +return 0 ; +} + +static struct platform_driver mtk_hsdma_driver = { + .probe = mtk_hsdma_probe, + .remove = mtk_hsdma_remove, + .driver = { + .name =KBUILD_MODNAME , + .of_match_table = mtk_hsdma_of_match, + }, +}; +module_platform_driver (mtk_hsdma_driver); + +MODULE_AUTHOR ("Michael Lee <[email protected]>" ); +MODULE_DESCRIPTION ("MTK HSDMA driver" ); +MODULE_LICENSE ("GPL v2" );drivers/staging/mt7621-dma/mtk-hsdma.c deleted +0
-762@@ -1,762 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2015, Michael Lee <[email protected]> -* MTK HSDMA support -*/ - -#include <linux/dmaengine.h> -#include <linux/dma-mapping.h> -#include <linux/err.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/irq.h> -#include <linux/of_dma.h> -#include <linux/reset.h> -#include <linux/of_device.h> - -#include "virt-dma.h" - -#define HSDMA_BASE_OFFSET 0x800 - -#define HSDMA_REG_TX_BASE 0x00 -#define HSDMA_REG_TX_CNT 0x04 -#define HSDMA_REG_TX_CTX 0x08 -#define HSDMA_REG_TX_DTX 0x0c -#define HSDMA_REG_RX_BASE 0x100 -#define HSDMA_REG_RX_CNT 0x104 -#define HSDMA_REG_RX_CRX 0x108 -#define HSDMA_REG_RX_DRX 0x10c -#define HSDMA_REG_INFO 0x200 -#define HSDMA_REG_GLO_CFG 0x204 -#define HSDMA_REG_RST_CFG 0x208 -#define HSDMA_REG_DELAY_INT 0x20c -#define HSDMA_REG_FREEQ_THRES 0x210 -#define HSDMA_REG_INT_STATUS 0x220 -#define HSDMA_REG_INT_MASK 0x228 -#define HSDMA_REG_SCH_Q01 0x280 -#define HSDMA_REG_SCH_Q23 0x284 - -#define HSDMA_DESCS_MAX 0xfff -#define HSDMA_DESCS_NUM 8 -#define HSDMA_DESCS_MASK (HSDMA_DESCS_NUM - 1) -#define HSDMA_NEXT_DESC (x) (((x) + 1) & HSDMA_DESCS_MASK) - -/* HSDMA_REG_INFO */ -#define HSDMA_INFO_INDEX_MASK 0xf -#define HSDMA_INFO_INDEX_SHIFT 24 -#define HSDMA_INFO_BASE_MASK 0xff -#define HSDMA_INFO_BASE_SHIFT 16 -#define HSDMA_INFO_RX_MASK 0xff -#define HSDMA_INFO_RX_SHIFT 8 -#define HSDMA_INFO_TX_MASK 0xff -#define HSDMA_INFO_TX_SHIFT 0 - -/* HSDMA_REG_GLO_CFG */ -#define HSDMA_GLO_TX_2B_OFFSET BIT(31) -#define HSDMA_GLO_CLK_GATE BIT(30) -#define HSDMA_GLO_BYTE_SWAP BIT(29) -#define HSDMA_GLO_MULTI_DMA BIT(10) -#define HSDMA_GLO_TWO_BUF BIT(9) -#define HSDMA_GLO_32B_DESC BIT(8) -#define HSDMA_GLO_BIG_ENDIAN BIT(7) -#define HSDMA_GLO_TX_DONE BIT(6) -#define HSDMA_GLO_BT_MASK 0x3 -#define HSDMA_GLO_BT_SHIFT 4 -#define HSDMA_GLO_RX_BUSY BIT(3) -#define HSDMA_GLO_RX_DMA BIT(2) -#define HSDMA_GLO_TX_BUSY BIT(1) -#define HSDMA_GLO_TX_DMA BIT(0) - -#define HSDMA_BT_SIZE_16BYTES (0 << HSDMA_GLO_BT_SHIFT) -#define HSDMA_BT_SIZE_32BYTES (1 << HSDMA_GLO_BT_SHIFT) -#define HSDMA_BT_SIZE_64BYTES (2 << HSDMA_GLO_BT_SHIFT) -#define HSDMA_BT_SIZE_128BYTES (3 << HSDMA_GLO_BT_SHIFT) - -#define HSDMA_GLO_DEFAULT (HSDMA_GLO_MULTI_DMA | \ - HSDMA_GLO_RX_DMA | HSDMA_GLO_TX_DMA | HSDMA_BT_SIZE_32BYTES) - -/* HSDMA_REG_RST_CFG */ -#define HSDMA_RST_RX_SHIFT 16 -#define HSDMA_RST_TX_SHIFT 0 - -/* HSDMA_REG_DELAY_INT */ -#define HSDMA_DELAY_INT_EN BIT(15) -#define HSDMA_DELAY_PEND_OFFSET 8 -#define HSDMA_DELAY_TIME_OFFSET 0 -#define HSDMA_DELAY_TX_OFFSET 16 -#define HSDMA_DELAY_RX_OFFSET 0 - -#define HSDMA_DELAY_INIT (x) (HSDMA_DELAY_INT_EN | \ - ((x) << HSDMA_DELAY_PEND_OFFSET)) -#define HSDMA_DELAY (x) ((HSDMA_DELAY_INIT(x) << \ - HSDMA_DELAY_TX_OFFSET) | HSDMA_DELAY_INIT(x)) - -/* HSDMA_REG_INT_STATUS */ -#define HSDMA_INT_DELAY_RX_COH BIT(31) -#define HSDMA_INT_DELAY_RX_INT BIT(30) -#define HSDMA_INT_DELAY_TX_COH BIT(29) -#define HSDMA_INT_DELAY_TX_INT BIT(28) -#define HSDMA_INT_RX_MASK 0x3 -#define HSDMA_INT_RX_SHIFT 16 -#define HSDMA_INT_RX_Q0 BIT(16) -#define HSDMA_INT_TX_MASK 0xf -#define HSDMA_INT_TX_SHIFT 0 -#define HSDMA_INT_TX_Q0 BIT(0) - -/* tx/rx dma desc flags */ -#define HSDMA_PLEN_MASK 0x3fff -#define HSDMA_DESC_DONE BIT(31) -#define HSDMA_DESC_LS0 BIT(30) -#define HSDMA_DESC_PLEN0 (_x) (((_x) & HSDMA_PLEN_MASK) << 16) -#define HSDMA_DESC_TAG BIT(15) -#define HSDMA_DESC_LS1 BIT(14) -#define HSDMA_DESC_PLEN1 (_x) ((_x) & HSDMA_PLEN_MASK) - -/* align 4 bytes */ -#define HSDMA_ALIGN_SIZE 3 -/* align size 128bytes */ -#define HSDMA_MAX_PLEN 0x3f80 - -struct hsdma_desc { -u32 addr0; -u32 flags; -u32 addr1; -u32 unused; -}; - -struct mtk_hsdma_sg { -dma_addr_t src_addr; -dma_addr_t dst_addr; -u32 len; -}; - -struct mtk_hsdma_desc { -struct virt_dma_desc vdesc; -unsigned int num_sgs; -struct mtk_hsdma_sg sg[1 ]; -}; - -struct mtk_hsdma_chan { -struct virt_dma_chan vchan; -unsigned int id; -dma_addr_t desc_addr; -int tx_idx; -int rx_idx; -struct hsdma_desc *tx_ring; -struct hsdma_desc *rx_ring; -struct mtk_hsdma_desc *desc; -unsigned int next_sg; -}; - -struct mtk_hsdam_engine { -struct dma_device ddev; -struct device_dma_parameters dma_parms; -void __iomem *base; -struct tasklet_struct task; -volatile unsigned long chan_issued; - -struct mtk_hsdma_chan chan[1 ]; -}; - -static inline struct mtk_hsdam_engine *mtk_hsdma_chan_get_dev ( -struct mtk_hsdma_chan *chan) -{ - return container_of(chan->vchan.chan.device, struct mtk_hsdam_engine, - ddev); -} - -static inline struct mtk_hsdma_chan *to_mtk_hsdma_chan (struct dma_chan *c) -{ - return container_of(c, struct mtk_hsdma_chan, vchan.chan); -} - -static inline struct mtk_hsdma_desc *to_mtk_hsdma_desc ( -struct virt_dma_desc *vdesc) -{ - return container_of(vdesc, struct mtk_hsdma_desc, vdesc); -} - -static inline u32 mtk_hsdma_read (struct mtk_hsdam_engine *hsdma,u32 reg) -{ -return readl (hsdma->base + reg); -} - -static inline void mtk_hsdma_write (struct mtk_hsdam_engine *hsdma, -unsigned int reg,u32 val) -{ -writel (val, hsdma->base + reg); -} - -static void mtk_hsdma_reset_chan (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ - chan->tx_idx =0 ; - chan->rx_idx =HSDMA_DESCS_NUM -1 ; - -mtk_hsdma_write (hsdma,HSDMA_REG_TX_CTX , chan->tx_idx); -mtk_hsdma_write (hsdma,HSDMA_REG_RX_CRX , chan->rx_idx); - -mtk_hsdma_write (hsdma,HSDMA_REG_RST_CFG , -0x1 << (chan->id +HSDMA_RST_TX_SHIFT )); -mtk_hsdma_write (hsdma,HSDMA_REG_RST_CFG , -0x1 << (chan->id +HSDMA_RST_RX_SHIFT )); -} - -static void hsdma_dump_reg (struct mtk_hsdam_engine *hsdma) -{ -dev_dbg (hsdma->ddev.dev,"tbase %08x, tcnt %08x, " \ -"tctx %08x, tdtx: %08x, rbase %08x, " \ -"rcnt %08x, rctx %08x, rdtx %08x\n" , -mtk_hsdma_read (hsdma,HSDMA_REG_TX_BASE ), -mtk_hsdma_read (hsdma,HSDMA_REG_TX_CNT ), -mtk_hsdma_read (hsdma,HSDMA_REG_TX_CTX ), -mtk_hsdma_read (hsdma,HSDMA_REG_TX_DTX ), -mtk_hsdma_read (hsdma,HSDMA_REG_RX_BASE ), -mtk_hsdma_read (hsdma,HSDMA_REG_RX_CNT ), -mtk_hsdma_read (hsdma,HSDMA_REG_RX_CRX ), -mtk_hsdma_read (hsdma,HSDMA_REG_RX_DRX )); - -dev_dbg (hsdma->ddev.dev,"info %08x, glo %08x, delay %08x, " \ -"intr_stat %08x, intr_mask %08x\n" , -mtk_hsdma_read (hsdma,HSDMA_REG_INFO ), -mtk_hsdma_read (hsdma,HSDMA_REG_GLO_CFG ), -mtk_hsdma_read (hsdma,HSDMA_REG_DELAY_INT ), -mtk_hsdma_read (hsdma,HSDMA_REG_INT_STATUS ), -mtk_hsdma_read (hsdma,HSDMA_REG_INT_MASK )); -} - -static void hsdma_dump_desc (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -struct hsdma_desc *tx_desc; -struct hsdma_desc *rx_desc; -int i; - -dev_dbg (hsdma->ddev.dev,"tx idx: %d, rx idx: %d\n" , - chan->tx_idx, chan->rx_idx); - -for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { - tx_desc = &chan->tx_ring[i]; - rx_desc = &chan->rx_ring[i]; - -dev_dbg (hsdma->ddev.dev,"%d tx addr0: %08x, flags %08x, " \ -"tx addr1: %08x, rx addr0 %08x, flags %08x\n" , - i, tx_desc->addr0, tx_desc->flags, \ - tx_desc->addr1, rx_desc->addr0, rx_desc->flags); - } -} - -static void mtk_hsdma_reset (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -int i; - -/* disable dma */ -mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,0 ); - -/* disable intr */ -mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,0 ); - -/* init desc value */ -for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { - chan->tx_ring[i].addr0 =0 ; - chan->tx_ring[i].flags =HSDMA_DESC_LS0 |HSDMA_DESC_DONE ; - } -for (i =0 ; i <HSDMA_DESCS_NUM ; i++) { - chan->rx_ring[i].addr0 =0 ; - chan->rx_ring[i].flags =0 ; - } - -/* reset */ -mtk_hsdma_reset_chan (hsdma, chan); - -/* enable intr */ -mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,HSDMA_INT_RX_Q0 ); - -/* enable dma */ -mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,HSDMA_GLO_DEFAULT ); -} - -static int mtk_hsdma_terminate_all (struct dma_chan *c) -{ -struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); -struct mtk_hsdam_engine *hsdma =mtk_hsdma_chan_get_dev (chan); -unsigned long timeout; -LIST_HEAD (head); - -spin_lock_bh (&chan->vchan.lock); - chan->desc =NULL ; -clear_bit (chan->id, &hsdma->chan_issued); -vchan_get_all_descriptors (&chan->vchan, &head); -spin_unlock_bh (&chan->vchan.lock); - -vchan_dma_desc_free_list (&chan->vchan, &head); - -/* wait dma transfer complete */ - timeout = jiffies +msecs_to_jiffies (2000 ); -while (mtk_hsdma_read (hsdma,HSDMA_REG_GLO_CFG ) & - (HSDMA_GLO_RX_BUSY |HSDMA_GLO_TX_BUSY )) { -if (time_after_eq (jiffies, timeout)) { -hsdma_dump_desc (hsdma, chan); -mtk_hsdma_reset (hsdma, chan); -dev_err (hsdma->ddev.dev,"timeout, reset it\n" ); -break ; - } -cpu_relax (); - } - -return 0 ; -} - -static int mtk_hsdma_start_transfer (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -dma_addr_t src, dst; -size_t len, tlen; -struct hsdma_desc *tx_desc, *rx_desc; -struct mtk_hsdma_sg *sg; -unsigned int i; -int rx_idx; - - sg = &chan->desc->sg[0 ]; - len = sg->len; - chan->desc->num_sgs =DIV_ROUND_UP (len,HSDMA_MAX_PLEN ); - -/* tx desc */ - src = sg->src_addr; -for (i =0 ; i < chan->desc->num_sgs; i++) { - tx_desc = &chan->tx_ring[chan->tx_idx]; - -if (len >HSDMA_MAX_PLEN ) - tlen =HSDMA_MAX_PLEN ; -else - tlen = len; - -if (i &0x1 ) { - tx_desc->addr1 = src; - tx_desc->flags |=HSDMA_DESC_PLEN1 (tlen); - }else { - tx_desc->addr0 = src; - tx_desc->flags =HSDMA_DESC_PLEN0 (tlen); - -/* update index */ - chan->tx_idx =HSDMA_NEXT_DESC (chan->tx_idx); - } - - src += tlen; - len -= tlen; - } -if (i &0x1 ) - tx_desc->flags |=HSDMA_DESC_LS0 ; -else - tx_desc->flags |=HSDMA_DESC_LS1 ; - -/* rx desc */ - rx_idx =HSDMA_NEXT_DESC (chan->rx_idx); - len = sg->len; - dst = sg->dst_addr; -for (i =0 ; i < chan->desc->num_sgs; i++) { - rx_desc = &chan->rx_ring[rx_idx]; -if (len >HSDMA_MAX_PLEN ) - tlen =HSDMA_MAX_PLEN ; -else - tlen = len; - - rx_desc->addr0 = dst; - rx_desc->flags =HSDMA_DESC_PLEN0 (tlen); - - dst += tlen; - len -= tlen; - -/* update index */ - rx_idx =HSDMA_NEXT_DESC (rx_idx); - } - -/* make sure desc and index all up to date */ -wmb (); -mtk_hsdma_write (hsdma,HSDMA_REG_TX_CTX , chan->tx_idx); - -return 0 ; -} - -static int gdma_next_desc (struct mtk_hsdma_chan *chan) -{ -struct virt_dma_desc *vdesc; - - vdesc =vchan_next_desc (&chan->vchan); -if (!vdesc) { - chan->desc =NULL ; -return 0 ; - } - chan->desc =to_mtk_hsdma_desc (vdesc); - chan->next_sg =0 ; - -return 1 ; -} - -static void mtk_hsdma_chan_done (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -struct mtk_hsdma_desc *desc; -int chan_issued; - - chan_issued =0 ; -spin_lock_bh (&chan->vchan.lock); - desc = chan->desc; -if (likely (desc)) { -if (chan->next_sg == desc->num_sgs) { -list_del (&desc->vdesc.node); -vchan_cookie_complete (&desc->vdesc); - chan_issued =gdma_next_desc (chan); - } - }else { -dev_dbg (hsdma->ddev.dev,"no desc to complete\n" ); - } - -if (chan_issued) -set_bit (chan->id, &hsdma->chan_issued); -spin_unlock_bh (&chan->vchan.lock); -} - -static irqreturn_t mtk_hsdma_irq (int irq,void *devid) -{ -struct mtk_hsdam_engine *hsdma = devid; -u32 status; - - status =mtk_hsdma_read (hsdma,HSDMA_REG_INT_STATUS ); -if (unlikely (!status)) -return IRQ_NONE ; - -if (likely (status &HSDMA_INT_RX_Q0 )) -tasklet_schedule (&hsdma->task); -else -dev_dbg (hsdma->ddev.dev,"unhandle irq status %08x\n" , status); -/* clean intr bits */ -mtk_hsdma_write (hsdma,HSDMA_REG_INT_STATUS , status); - -return IRQ_HANDLED ; -} - -static void mtk_hsdma_issue_pending (struct dma_chan *c) -{ -struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); -struct mtk_hsdam_engine *hsdma =mtk_hsdma_chan_get_dev (chan); - -spin_lock_bh (&chan->vchan.lock); -if (vchan_issue_pending (&chan->vchan) && !chan->desc) { -if (gdma_next_desc (chan)) { -set_bit (chan->id, &hsdma->chan_issued); -tasklet_schedule (&hsdma->task); - }else { -dev_dbg (hsdma->ddev.dev,"no desc to issue\n" ); - } - } -spin_unlock_bh (&chan->vchan.lock); -} - -static struct dma_async_tx_descriptor *mtk_hsdma_prep_dma_memcpy ( -struct dma_chan *c,dma_addr_t dest,dma_addr_t src, -size_t len,unsigned long flags) -{ -struct mtk_hsdma_chan *chan =to_mtk_hsdma_chan (c); -struct mtk_hsdma_desc *desc; - -if (len <=0 ) -return NULL ; - - desc =kzalloc (sizeof (*desc),GFP_ATOMIC ); -if (!desc) { -dev_err (c->device->dev,"alloc memcpy decs error\n" ); -return NULL ; - } - - desc->sg[0 ].src_addr = src; - desc->sg[0 ].dst_addr = dest; - desc->sg[0 ].len = len; - -return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags); -} - -static enum dma_status mtk_hsdma_tx_status (struct dma_chan *c, -dma_cookie_t cookie, -struct dma_tx_state *state) -{ -return dma_cookie_status (c, cookie, state); -} - -static void mtk_hsdma_free_chan_resources (struct dma_chan *c) -{ -vchan_free_chan_resources (to_virt_chan (c)); -} - -static void mtk_hsdma_desc_free (struct virt_dma_desc *vdesc) -{ -kfree (container_of(vdesc ,struct mtk_hsdma_desc ,vdesc )); -} - -static void mtk_hsdma_tx (struct mtk_hsdam_engine *hsdma) -{ -struct mtk_hsdma_chan *chan; - -if (test_and_clear_bit (0 , &hsdma->chan_issued)) { - chan = &hsdma->chan[0 ]; -if (chan->desc) -mtk_hsdma_start_transfer (hsdma, chan); -else -dev_dbg (hsdma->ddev.dev,"chan 0 no desc to issue\n" ); - } -} - -static void mtk_hsdma_rx (struct mtk_hsdam_engine *hsdma) -{ -struct mtk_hsdma_chan *chan; -int next_idx, drx_idx, cnt; - - chan = &hsdma->chan[0 ]; - next_idx =HSDMA_NEXT_DESC (chan->rx_idx); - drx_idx =mtk_hsdma_read (hsdma,HSDMA_REG_RX_DRX ); - - cnt = (drx_idx - next_idx) &HSDMA_DESCS_MASK ; -if (!cnt) -return ; - - chan->next_sg += cnt; - chan->rx_idx = (chan->rx_idx + cnt) &HSDMA_DESCS_MASK ; - -/* update rx crx */ -wmb (); -mtk_hsdma_write (hsdma,HSDMA_REG_RX_CRX , chan->rx_idx); - -mtk_hsdma_chan_done (hsdma, chan); -} - -static void mtk_hsdma_tasklet (unsigned long arg) -{ -struct mtk_hsdam_engine *hsdma = (struct mtk_hsdam_engine *)arg; - -mtk_hsdma_rx (hsdma); -mtk_hsdma_tx (hsdma); -} - -static int mtk_hsdam_alloc_desc (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -int i; - - chan->tx_ring =dma_alloc_coherent (hsdma->ddev.dev, -2 *HSDMA_DESCS_NUM *sizeof (*chan->tx_ring), - &chan->desc_addr,GFP_ATOMIC | __GFP_ZERO); -if (!chan->tx_ring) - goto no_mem; - - chan->rx_ring = &chan->tx_ring[HSDMA_DESCS_NUM ]; - -/* init tx ring value */ -for (i =0 ; i <HSDMA_DESCS_NUM ; i++) - chan->tx_ring[i].flags =HSDMA_DESC_LS0 |HSDMA_DESC_DONE ; - -return 0 ; -no_mem: -return -ENOMEM ; -} - -static void mtk_hsdam_free_desc (struct mtk_hsdam_engine *hsdma, -struct mtk_hsdma_chan *chan) -{ -if (chan->tx_ring) { -dma_free_coherent (hsdma->ddev.dev, -2 *HSDMA_DESCS_NUM *sizeof (*chan->tx_ring), - chan->tx_ring, chan->desc_addr); - chan->tx_ring =NULL ; - chan->rx_ring =NULL ; - } -} - -static int mtk_hsdma_init (struct mtk_hsdam_engine *hsdma) -{ -struct mtk_hsdma_chan *chan; -int ret; -u32 reg; - -/* init desc */ - chan = &hsdma->chan[0 ]; - ret =mtk_hsdam_alloc_desc (hsdma, chan); -if (ret) -return ret; - -/* tx */ -mtk_hsdma_write (hsdma,HSDMA_REG_TX_BASE , chan->desc_addr); -mtk_hsdma_write (hsdma,HSDMA_REG_TX_CNT ,HSDMA_DESCS_NUM ); -/* rx */ -mtk_hsdma_write (hsdma,HSDMA_REG_RX_BASE , chan->desc_addr + - (sizeof (struct hsdma_desc ) *HSDMA_DESCS_NUM )); -mtk_hsdma_write (hsdma,HSDMA_REG_RX_CNT ,HSDMA_DESCS_NUM ); -/* reset */ -mtk_hsdma_reset_chan (hsdma, chan); - -/* enable rx intr */ -mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,HSDMA_INT_RX_Q0 ); - -/* enable dma */ -mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,HSDMA_GLO_DEFAULT ); - -/* hardware info */ - reg =mtk_hsdma_read (hsdma,HSDMA_REG_INFO ); -dev_info (hsdma->ddev.dev,"rx: %d, tx: %d\n" , - (reg >>HSDMA_INFO_RX_SHIFT ) &HSDMA_INFO_RX_MASK , - (reg >>HSDMA_INFO_TX_SHIFT ) &HSDMA_INFO_TX_MASK ); - -hsdma_dump_reg (hsdma); - -return ret; -} - -static void mtk_hsdma_uninit (struct mtk_hsdam_engine *hsdma) -{ -struct mtk_hsdma_chan *chan; - -/* disable dma */ -mtk_hsdma_write (hsdma,HSDMA_REG_GLO_CFG ,0 ); - -/* disable intr */ -mtk_hsdma_write (hsdma,HSDMA_REG_INT_MASK ,0 ); - -/* free desc */ - chan = &hsdma->chan[0 ]; -mtk_hsdam_free_desc (hsdma, chan); - -/* tx */ -mtk_hsdma_write (hsdma,HSDMA_REG_TX_BASE ,0 ); -mtk_hsdma_write (hsdma,HSDMA_REG_TX_CNT ,0 ); -/* rx */ -mtk_hsdma_write (hsdma,HSDMA_REG_RX_BASE ,0 ); -mtk_hsdma_write (hsdma,HSDMA_REG_RX_CNT ,0 ); -/* reset */ -mtk_hsdma_reset_chan (hsdma, chan); -} - -static const struct of_device_id mtk_hsdma_of_match[] = { - { .compatible ="mediatek,mt7621-hsdma" }, - { }, -}; - -static int mtk_hsdma_probe (struct platform_device *pdev) -{ -const struct of_device_id *match; -struct mtk_hsdma_chan *chan; -struct mtk_hsdam_engine *hsdma; -struct dma_device *dd; -struct resource *res; -int ret; -int irq; -void __iomem *base; - - ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); -if (ret) -return ret; - - match =of_match_device (mtk_hsdma_of_match, &pdev->dev); -if (!match) -return -EINVAL ; - - hsdma =devm_kzalloc (&pdev->dev,sizeof (*hsdma),GFP_KERNEL ); -if (!hsdma) -return -EINVAL ; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (base)) -return PTR_ERR (base); - hsdma->base = base +HSDMA_BASE_OFFSET ; -tasklet_init (&hsdma->task, mtk_hsdma_tasklet, (unsigned long )hsdma); - - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return -EINVAL ; - ret =devm_request_irq (&pdev->dev, irq, mtk_hsdma_irq, -0 ,dev_name (&pdev->dev), hsdma); -if (ret) { -dev_err (&pdev->dev,"failed to request irq\n" ); -return ret; - } - -device_reset (&pdev->dev); - - dd = &hsdma->ddev; -dma_cap_set (DMA_MEMCPY , dd->cap_mask); - dd->copy_align =HSDMA_ALIGN_SIZE ; - dd->device_free_chan_resources = mtk_hsdma_free_chan_resources; - dd->device_prep_dma_memcpy = mtk_hsdma_prep_dma_memcpy; - dd->device_terminate_all = mtk_hsdma_terminate_all; - dd->device_tx_status = mtk_hsdma_tx_status; - dd->device_issue_pending = mtk_hsdma_issue_pending; - dd->dev = &pdev->dev; - dd->dev->dma_parms = &hsdma->dma_parms; -dma_set_max_seg_size (dd->dev,HSDMA_MAX_PLEN ); -INIT_LIST_HEAD (&dd->channels); - - chan = &hsdma->chan[0 ]; - chan->id =0 ; - chan->vchan.desc_free = mtk_hsdma_desc_free; -vchan_init (&chan->vchan, dd); - -/* init hardware */ - ret =mtk_hsdma_init (hsdma); -if (ret) { -dev_err (&pdev->dev,"failed to alloc ring descs\n" ); -return ret; - } - - ret =dma_async_device_register (dd); -if (ret) { -dev_err (&pdev->dev,"failed to register dma device\n" ); - goto err_uninit_hsdma; - } - - ret =of_dma_controller_register (pdev->dev.of_node, - of_dma_xlate_by_chan_id, hsdma); -if (ret) { -dev_err (&pdev->dev,"failed to register of dma controller\n" ); - goto err_unregister; - } - -platform_set_drvdata (pdev, hsdma); - -return 0 ; - -err_unregister: -dma_async_device_unregister (dd); -err_uninit_hsdma: -mtk_hsdma_uninit (hsdma); -return ret; -} - -static int mtk_hsdma_remove (struct platform_device *pdev) -{ -struct mtk_hsdam_engine *hsdma =platform_get_drvdata (pdev); - -mtk_hsdma_uninit (hsdma); - -of_dma_controller_free (pdev->dev.of_node); -dma_async_device_unregister (&hsdma->ddev); - -return 0 ; -} - -static struct platform_driver mtk_hsdma_driver = { - .probe = mtk_hsdma_probe, - .remove = mtk_hsdma_remove, - .driver = { - .name ="hsdma-mt7621" , - .of_match_table = mtk_hsdma_of_match, - }, -}; -module_platform_driver (mtk_hsdma_driver); - -MODULE_AUTHOR ("Michael Lee <[email protected]>" ); -MODULE_DESCRIPTION ("MTK HSDMA driver" ); -MODULE_LICENSE ("GPL v2" );
Greg Kroah-Hartman
maintainerPATCH 281/340 staging: gdm724x: Fix DMA from stack
In reply to Greg Kroah-HartmanFrom: Amey Narkhede <[email protected]>
commit 7c3a0635cd008eaca9a734dc802709ee0b81cac5 upstream.
Stack allocated buffers cannot be used for DMA on all architectures so allocate hci_packet buffer using kmalloc.
--- drivers/staging/gdm724x/gdm_usb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/staging/gdm724x/gdm_usb.c +7 -3
@@ -56,20 +56,24 @@ static int gdm_usb_recv(void *priv_dev,static int request_mac_address (struct lte_udev *udev) { -u8 buf[16 ] = {0 ,}; -struct hci_packet *hci = (struct hci_packet *)buf; +struct hci_packet *hci;struct usb_device *usbdev = udev->usbdev;int actual;int ret =-1 ; + hci =kmalloc (struct_size (hci, data,1 ),GFP_KERNEL ); +if (!hci) +return -ENOMEM ; + hci->cmd_evt =gdm_cpu_to_dev16 (udev->gdm_ed,LTE_GET_INFORMATION ); hci->len =gdm_cpu_to_dev16 (udev->gdm_ed,1 ); hci->data[0 ] =MAC_ADDRESS ; - ret =usb_bulk_msg (usbdev,usb_sndbulkpipe (usbdev,2 ), buf,5 , + ret =usb_bulk_msg (usbdev,usb_sndbulkpipe (usbdev,2 ), hci,5 , &actual,1000 ); udev->request_mac_addr =1 ; +kfree (hci);return ret; }
Greg Kroah-Hartman
maintainerPATCH 282/340 staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table
In reply to Greg Kroah-HartmanFrom: Martin Kaiser <[email protected]>
commit 7a8d2f1908a59003e55ef8691d09efb7fbc51625 upstream.
The Edimax EW-7811UN V2 uses an RTL8188EU chipset and works with this driver.
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -41,6 +41,7 @@ static const struct usb_device_id rtw_us {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */ {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ + {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811UN V2 */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ {} /* Terminating entry */ };
Greg Kroah-Hartman
maintainerPATCH 283/340 media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt()
In reply to Greg Kroah-HartmanFrom: Pavel Machek <[email protected]>
commit 334de4b45892f7e67074e1b1b2ac36fd3e091118 upstream.
Loop was useless as it would always exit on the first iteration. Fix it with right condition.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -1
@@ -1288,7 +1288,7 @@ static int cio2_subdev_set_fmt(struct v4 fmt->format.code = formats[0 ].mbus_code;for (i =0 ; i <ARRAY_SIZE (formats); i++) { -if (formats[i].mbus_code == fmt->format.code) { +if (formats[i].mbus_code == mbus_code) { fmt->format.code = mbus_code;break ; }
Greg Kroah-Hartman
maintainerPATCH 284/340 x86/virt: Eat faults on VMXOFF in reboot flows
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit aec511ad153556640fb1de38bfe00c69464f997f upstream.
Silently ignore all faults on VMXOFF in the reboot flows as such faults are all but guaranteed to be due to the CPU not being in VMX root. Because (a) VMXOFF may be executed in NMI context, e.g. after VMXOFF but before CR4.VMXE is cleared, (b) there's no way to query the CPU's VMX state without faulting, and (c) the whole point is to get out of VMX root, eating faults is the simplest way to achieve the desired behaior.
Technically, VMXOFF can fault (or fail) for other reasons, but all other fault and failure scenarios are mode related, i.e. the kernel would have to magically end up in RM, V86, compat mode, at CPL>0, or running with the SMI Transfer Monitor active. The kernel is beyond hosed if any of those scenarios are encountered; trying to do something fancy in the error path to handle them cleanly is pointless.
Message-Id: <[email protected]>
--- arch/x86/include/asm/virtext.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/x86/include/asm/virtext.h +12 -5
@@ -30,15 +30,22 @@ static inline int cpu_has_vmx(void) } -/** Disable VMX on the current CPU +/** +* cpu_vmxoff() - Disable VMX on the current CPU * -* vmxoff causes a undefined-opcode exception if vmxon was not run -* on the CPU previously. Only call this function if you know VMX -* is enabled. +* Disable VMX and clear CR4.VMXE (even if VMXOFF faults) +* +* Note, VMXOFF causes a #UD if the CPU is !post-VMXON, but it's impossible to +* atomically track post-VMXON state, e.g. this may be called in NMI context. +* Eat all faults as all other faults on VMXOFF faults are mode related, i.e. +* faults are guaranteed to be due to the !post-VMXON check unless the CPU is +* magically in RM, VM86, compat mode, or at CPL>0. */ static inline void cpu_vmxoff (void ) { - asmvolatile ("vmxoff" ); +asm_volatile_goto ("1: vmxoff\n\t" + _ASM_EXTABLE(1b, %l[fault]) :::: fault); +fault:cr4_clear_bits (X86_CR4_VMXE ); }
Greg Kroah-Hartman
maintainerPATCH 285/340 x86/reboot: Force all cpus to exit VMX root if VMX is supported
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit ed72736183c45a413a8d6974dd04be90f514cb6b upstream.
Force all CPUs to do VMXOFF (via NMI shootdown) during an emergency reboot if VMX is _supported_, as VMX being off on the current CPU does not prevent other CPUs from being in VMX root (post-VMXON). This fixes a bug where a crash/panic reboot could leave other CPUs in VMX root and prevent them from being woken via INIT-SIPI-SIPI in the new kernel.
Message-Id: <[email protected]>
--- arch/x86/kernel/reboot.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-)
arch/x86/kernel/reboot.c +10 -19
@@ -538,29 +538,20 @@ static void emergency_vmx_disable_all(volocal_irq_disable ();/* -* We need to disable VMX on all CPUs before rebooting, otherwise -* we risk hanging up the machine, because the CPU ignore INIT -* signals when VMX is enabled. +* Disable VMX on all CPUs before rebooting, otherwise we risk hanging +* the machine, because the CPU blocks INIT when it's in VMX root. * -* We can't take any locks and we may be on an inconsistent -* state, so we use NMIs as IPIs to tell the other CPUs to disable -* VMX and halt. +* We can't take any locks and we may be on an inconsistent state, so +* use NMIs as IPIs to tell the other CPUs to exit VMX root and halt. * -* For safety, we will avoid running the nmi_shootdown_cpus() -* stuff unnecessarily, but we don't have a way to check -* if other CPUs have VMX enabled. So we will call it only if the -* CPU we are running on has VMX enabled. -* -* We will miss cases where VMX is not enabled on all CPUs. This -* shouldn't do much harm because KVM always enable VMX on all -* CPUs anyway. But we can miss it on the small window where KVM -* is still enabling VMX. +* Do the NMI shootdown even if VMX if off on _this_ CPU, as that +* doesn't prevent a different CPU from being in VMX root operation. */ -if (cpu_has_vmx () &&cpu_vmx_enabled ()) { -/* Disable VMX on this CPU. */ -cpu_vmxoff (); +if (cpu_has_vmx ()) { +/* Safely force _this_ CPU out of VMX root operation. */ +__cpu_emergency_vmxoff (); -/* Halt and disable VMX on the other CPUs */ +/* Halt and exit VMX root operation on the other CPUs. */ nmi_shootdown_cpus (vmxoff_nmi); }
Greg Kroah-Hartman
maintainerPATCH 286/340 powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
commit ed5b00a05c2ae95b59adc3442f45944ec632e794 upstream.
The "ibm,arch-vec-5-platform-support" property is a list of pairs of bytes representing the options and values supported by the platform firmware. At boot time, Linux scans this list and activates the available features it recognizes : Radix and XIVE.
A recent change modified the number of entries to loop on and 8 bytes, 4 pairs of { options, values } entries are always scanned. This is fine on KVM but not on PowerVM which can advertises less. As a consequence on this platform, Linux reads extra entries pointing to random data, interprets these as available features and tries to activate them, leading to a firmware crash in ibm,client-architecture-support.
Fix that by using the property length of "ibm,arch-vec-5-platform-support".
--- arch/powerpc/kernel/prom_init.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/kernel/prom_init.c +4 -8
@@ -1305,14 +1305,10 @@ static void __init prom_check_platform_sif (prop_len >sizeof (vec))prom_printf ("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n" , prop_len); -prom_getprop (prom.chosen,"ibm,arch-vec-5-platform-support" , - &vec,sizeof (vec)); -for (i =0 ; i <sizeof (vec); i +=2 ) { -prom_debug ("%d: index = 0x%x val = 0x%x\n" , i /2 - , vec[i] - , vec[i +1 ]); -prom_parse_platform_support (vec[i], vec[i +1 ], - &supported); +prom_getprop (prom.chosen,"ibm,arch-vec-5-platform-support" , &vec,sizeof (vec)); +for (i =0 ; i < prop_len; i +=2 ) { +prom_debug ("%d: index = 0x%x val = 0x%x\n" , i /2 , vec[i], vec[i +1 ]); +prom_parse_platform_support (vec[i], vec[i +1 ], &supported); } }
Greg Kroah-Hartman
maintainerPATCH 287/340 rcu: Pull deferred rcuog wake up to rcu_eqs_enter() callers
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 54b7429efffc99e845ba9381bee3244f012a06c2 upstream.
Deferred wakeup of rcuog kthreads upon RCU idle mode entry is going to be handled differently whether initiated by idle, user or guest. Prepare with pulling that control up to rcu_eqs_enter() callers.
--- kernel/rcu/tree.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +10 -1
@@ -579,7 +579,6 @@ static void rcu_eqs_enter(bool user)trace_rcu_dyntick (TPS ("Start" ), rdp->dynticks_nesting,0 ,atomic_read (&rdp->dynticks));WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) && !user && !is_idle_task (current)); rdp =this_cpu_ptr (&rcu_data); -do_nocb_deferred_wakeup (rdp);rcu_prepare_for_idle ();rcu_preempt_deferred_qs (current);WRITE_ONCE (rdp->dynticks_nesting,0 );/* Avoid irq-access tearing. */
@@ -600,7 +599,10 @@ static void rcu_eqs_enter(bool user)*/ void rcu_idle_enter (void ) { +struct rcu_data *rdp =this_cpu_ptr (&rcu_data); +lockdep_assert_irqs_disabled (); +do_nocb_deferred_wakeup (rdp);rcu_eqs_enter (false); }
@@ -618,7 +620,14 @@ void rcu_idle_enter(void)*/ void rcu_user_enter (void ) { +struct rcu_data *rdp =this_cpu_ptr (&rcu_data); +lockdep_assert_irqs_disabled (); + +instrumentation_begin (); +do_nocb_deferred_wakeup (rdp); +instrumentation_end (); +rcu_eqs_enter (true); }#endif /* CONFIG_NO_HZ_FULL */
Greg Kroah-Hartman
maintainerPATCH 288/340 rcu/nocb: Perform deferred wake up before last idles need_resched() check
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 43789ef3f7d61aa7bed0cb2764e588fc990c30ef upstream.
Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced.
Usually a local wake up happening while running the idle task is handled in one of the need_resched() checks carefully placed within the idle loop that can break to the scheduler.
Unfortunately the call to rcu_idle_enter() is already beyond the last generic need_resched() check and we may halt the CPU with a resched request unhandled, leaving the task hanging.
Fix this with splitting the rcuog wakeup handling from rcu_idle_enter() and place it before the last generic need_resched() check in the idle loop. It is then assumed that no call to call_rcu() will be performed after that in the idle loop until the CPU is put in low power mode.
--- include/linux/rcupdate.h | 2 ++ kernel/rcu/tree.c | 3 --- kernel/rcu/tree_plugin.h | 5 +++++ kernel/sched/idle.c | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
include/linux/rcupdate.h +2 -0
@@ -96,8 +96,10 @@ static inline void rcu_user_exit(void) {#ifdef CONFIG_RCU_NOCB_CPU void rcu_init_nohz (void ); +void rcu_nocb_flush_deferred_wakeup (void );#else /* #ifdef CONFIG_RCU_NOCB_CPU */ static inline void rcu_init_nohz (void ) { } +static inline void rcu_nocb_flush_deferred_wakeup (void ) { }#endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ /**
kernel/rcu/tree.c +0 -3
@@ -599,10 +599,7 @@ static void rcu_eqs_enter(bool user)*/ void rcu_idle_enter (void ) { -struct rcu_data *rdp =this_cpu_ptr (&rcu_data); -lockdep_assert_irqs_disabled (); -do_nocb_deferred_wakeup (rdp);rcu_eqs_enter (false); }
kernel/rcu/tree_plugin.h +5 -0
@@ -2190,6 +2190,11 @@ static void do_nocb_deferred_wakeup(strudo_nocb_deferred_wakeup_common (rdp); } +void rcu_nocb_flush_deferred_wakeup (void ) +{ +do_nocb_deferred_wakeup (this_cpu_ptr (&rcu_data)); +} +void __init rcu_init_nohz (void ) {int cpu;
kernel/sched/idle.c +1 -0
@@ -249,6 +249,7 @@ static void do_idle(void) }arch_cpu_idle_enter (); +rcu_nocb_flush_deferred_wakeup ();/* * In poll mode we reenable interrupts and spin. Also if we
Greg Kroah-Hartman
maintainerPATCH 289/340 rcu/nocb: Trigger self-IPI on late deferred wake up before user resume
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit f8bb5cae9616224a39cbb399de382d36ac41df10 upstream.
Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced.
Unfortunately the call to rcu_user_enter() is already past the last rescheduling opportunity before we resume to userspace or to guest mode. We may escape there with the woken task ignored.
The ultimate resort to fix every callsites is to trigger a self-IPI (nohz_full depends on arch to implement arch_irq_work_raise()) that will trigger a reschedule on IRQ tail or guest exit.
Eventually every site that want a saner treatment will need to carefully place a call to rcu_nocb_flush_deferred_wakeup() before the last explicit need_resched() check upon resume.
--- kernel/rcu/tree.c | 21 ++++++++++++++++++++- kernel/rcu/tree.h | 2 +- kernel/rcu/tree_plugin.h | 25 ++++++++++++++++--------- 3 files changed, 37 insertions(+), 11 deletions(-)
kernel/rcu/tree.c +20 -1
@@ -604,6 +604,18 @@ void rcu_idle_enter(void) }#ifdef CONFIG_NO_HZ_FULL + +/* +* An empty function that will trigger a reschedule on +* IRQ tail once IRQs get re-enabled on userspace resume. +*/ +static void late_wakeup_func (struct irq_work *work) +{ +} + +static DEFINE_PER_CPU(struct irq_work, late_wakeup_work) = +IRQ_WORK_INIT (late_wakeup_func); +/** * rcu_user_enter - inform RCU that we are resuming userspace. *
@@ -621,12 +633,19 @@ void rcu_user_enter(void)lockdep_assert_irqs_disabled (); +/* +* We may be past the last rescheduling opportunity in the entry code. +* Trigger a self IPI that will fire and reschedule once we resume to +* user/guest mode. +*/ instrumentation_begin (); -do_nocb_deferred_wakeup (rdp); +if (do_nocb_deferred_wakeup (rdp) &&need_resched ()) +irq_work_queue (this_cpu_ptr (&late_wakeup_work));instrumentation_end (); rcu_eqs_enter(true); } +#endif /* CONFIG_NO_HZ_FULL */ /*
kernel/rcu/tree.h +1 -1
@@ -438,7 +438,7 @@ static bool rcu_nocb_try_bypass(struct rstatic void __call_rcu_nocb_wake (struct rcu_data *rdp,bool was_empty,unsigned long flags);static int rcu_nocb_need_deferred_wakeup (struct rcu_data *rdp); -static void do_nocb_deferred_wakeup (struct rcu_data *rdp); +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp);static void rcu_boot_init_nocb_percpu_data (struct rcu_data *rdp);static void rcu_spawn_cpu_nocb_kthread (int cpu);static void __init rcu_spawn_nocb_kthreads (void );
kernel/rcu/tree_plugin.h +16 -9
@@ -1639,8 +1639,8 @@ bool rcu_is_nocb_cpu(int cpu)* Kick the GP kthread for this NOCB group. Caller holds ->nocb_lock * and this function releases it. */ -static void wake_nocb_gp (struct rcu_data *rdp,bool force, -unsigned long flags) +static bool wake_nocb_gp (struct rcu_data *rdp,bool force, +unsigned long flags) __releases(rdp->nocb_lock) {bool needwake = false;
@@ -1651,7 +1651,7 @@ static void wake_nocb_gp(struct rcu_datatrace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("AlreadyAwake" ));rcu_nocb_unlock_irqrestore (rdp, flags); -return ; +return false; }del_timer (&rdp->nocb_timer);rcu_nocb_unlock_irqrestore (rdp, flags);
@@ -1664,6 +1664,8 @@ static void wake_nocb_gp(struct rcu_dataraw_spin_unlock_irqrestore (&rdp_gp->nocb_gp_lock, flags);if (needwake)wake_up_process (rdp_gp->nocb_gp_kthread); + +return needwake; }/*
@@ -2155,20 +2157,23 @@ static int rcu_nocb_need_deferred_wakeup }/* Do a deferred wakeup of rcu_nocb_kthread(). */ -static void do_nocb_deferred_wakeup_common (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup_common (struct rcu_data *rdp) {unsigned long flags;int ndw; +int ret;rcu_nocb_lock_irqsave (rdp, flags);if (!rcu_nocb_need_deferred_wakeup (rdp)) {rcu_nocb_unlock_irqrestore (rdp, flags); -return ; +return false; } ndw =READ_ONCE (rdp->nocb_defer_wakeup);WRITE_ONCE (rdp->nocb_defer_wakeup,RCU_NOCB_WAKE_NOT ); -wake_nocb_gp (rdp, ndw ==RCU_NOCB_WAKE_FORCE , flags); + ret =wake_nocb_gp (rdp, ndw ==RCU_NOCB_WAKE_FORCE , flags);trace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("DeferredWake" )); + +return ret; }/* Do a deferred wakeup of rcu_nocb_kthread() from a timer handler. */
@@ -2184,10 +2189,11 @@ static void do_nocb_deferred_wakeup_time* This means we do an inexact common-case check. Note that if * we miss, ->nocb_timer will eventually clean things up. */ -static void do_nocb_deferred_wakeup (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp) {if (rcu_nocb_need_deferred_wakeup (rdp)) -do_nocb_deferred_wakeup_common (rdp); +return do_nocb_deferred_wakeup_common (rdp); +return false; }void rcu_nocb_flush_deferred_wakeup (void )
@@ -2527,8 +2533,9 @@ static int rcu_nocb_need_deferred_wakeupreturn false; } -static void do_nocb_deferred_wakeup (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp) { +return false; }static void rcu_spawn_cpu_nocb_kthread (int cpu)
Greg Kroah-Hartman
maintainerPATCH 290/340 floppy: reintroduce O_NDELAY fix
In reply to Greg Kroah-HartmanFrom: Jiri Kosina <[email protected]>
commit 8a0c014cd20516ade9654fc13b51345ec58e7be8 upstream.
This issue was originally fixed in 09954bad4 ("floppy: refactor open() flags handling").
The fix as a side-effect, however, introduce issue for open(O_ACCMODE) that is being used for ioctl-only open. I wrote a fix for that, but instead of it being merged, full revert of 09954bad4 was performed, re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
This is a forward-port of the original fix to current codebase; the original submission had the changelog below:
====
Commit 09954bad4 ("floppy: refactor open() flags handling"), as a side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that this is being used setfdprm userspace for ioctl-only open().
Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE) modes, while still keeping the original O_NDELAY bug fixed.
--- drivers/block/floppy.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/block/floppy.c +14 -13
@@ -4063,21 +4063,22 @@ static int floppy_open(struct block_deviif (UFDCS ->rawcmd ==1 )UFDCS ->rawcmd =2 ; -if (!(mode &FMODE_NDELAY )) { -if (mode & (FMODE_READ |FMODE_WRITE )) { -UDRS ->last_checked =0 ; -clear_bit (FD_OPEN_SHOULD_FAIL_BIT , &UDRS ->flags); -check_disk_change (bdev); -if (test_bit (FD_DISK_CHANGED_BIT , &UDRS ->flags)) - goto out; -if (test_bit (FD_OPEN_SHOULD_FAIL_BIT , &UDRS ->flags)) - goto out; - } - res = -EROFS ; -if ((mode &FMODE_WRITE ) && - !test_bit (FD_DISK_WRITABLE_BIT , &UDRS ->flags)) +if (mode & (FMODE_READ |FMODE_WRITE )) { +UDRS ->last_checked =0 ; +clear_bit (FD_OPEN_SHOULD_FAIL_BIT , &UDRS ->flags); +check_disk_change (bdev); +if (test_bit (FD_DISK_CHANGED_BIT , &UDRS ->flags)) + goto out; +if (test_bit (FD_OPEN_SHOULD_FAIL_BIT , &UDRS ->flags)) goto out; } + + res = -EROFS ; + +if ((mode &FMODE_WRITE ) && + !test_bit (FD_DISK_WRITABLE_BIT , &UDRS ->flags)) + goto out; +mutex_unlock (&open_lock);mutex_unlock (&floppy_mutex);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 291/340 arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails
In reply to Greg Kroah-HartmanFrom: qiuguorui1 <[email protected]>
commit 656d1d58d8e0958d372db86c24f0b2ea36f50888 upstream.
in function create_dtb(), if fdt_open_into() fails, we need to vfree buf before return.
--- arch/arm64/kernel/machine_kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kernel/machine_kexec_file.c +3 -1
@@ -150,8 +150,10 @@ static int create_dtb(struct kimage *ima/* duplicate a device tree blob */ ret =fdt_open_into (initial_boot_params, buf, buf_size); -if (ret) +if (ret) { +vfree (buf);return -EINVAL ; + } ret =setup_dtb (image, initrd_load_addr, initrd_len, cmdline, buf);
Greg Kroah-Hartman
maintainerPATCH 292/340 arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing
In reply to Greg Kroah-HartmanFrom: He Zhe <[email protected]>
commit d47422d953e258ad587b5edf2274eb95d08bdc7d upstream.
As stated in linux/errno.h, ENOTSUPP should never be seen by user programs. When we set up uprobe with 32-bit perf and arm64 kernel, we would see the following vague error without useful hint.
The sys_perf_event_open() syscall returned with 524 (INTERNAL ERROR:strerror_r(524, [buf], 128)=22)
Use EOPNOTSUPP instead to indicate such cases.
--- arch/arm64/kernel/probes/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/probes/uprobes.c +1 -1
@@ -38,7 +38,7 @@ int arch_uprobe_analyze_insn(struct arch/* TODO: Currently we do not support AARCH32 instruction probing */ if (mm->context.flags &MMCF_AARCH32 ) -return -ENOTSUPP ; +return -EOPNOTSUPP ;else if (!IS_ALIGNED (addr,AARCH64_INSN_SIZE ))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 293/340 watchdog: qcom: Remove incorrect usage of QCOM_WDT_ENABLE_IRQ
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
commit a4f3407c41605d14f09e490045d0609990cd5d94 upstream.
As per register documentation, QCOM_WDT_ENABLE_IRQ which is BIT(1) of watchdog control register is wakeup interrupt enable bit and not related to bark interrupt at all, BIT(0) is used for that. So remove incorrect usage of this bit when supporting bark irq for pre-timeout notification. Currently with this bit set and bark interrupt specified, pre-timeout notification and/or watchdog reset/bite does not occur.
--- drivers/watchdog/qcom-wdt.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/watchdog/qcom-wdt.c +1 -12
@@ -22,7 +22,6 @@ enum wdt_reg { };#define QCOM_WDT_ENABLE BIT(0) -#define QCOM_WDT_ENABLE_IRQ BIT(1)static const u32 reg_offset_data_apcs_tmr[] = { [WDT_RST ] =0x38 ,
@@ -58,16 +57,6 @@ struct qcom_wdt *to_qcom_wdt(struct watc return container_of(wdd, struct qcom_wdt, wdd); } -static inline int qcom_get_enable (struct watchdog_device *wdd) -{ -int enable =QCOM_WDT_ENABLE ; - -if (wdd->pretimeout) - enable |=QCOM_WDT_ENABLE_IRQ ; - -return enable; -} -static irqreturn_t qcom_wdt_isr (int irq,void *arg) {struct watchdog_device *wdd = arg;
@@ -86,7 +75,7 @@ static int qcom_wdt_start(struct watchdowritel (1 ,wdt_addr (wdt,WDT_RST ));writel (bark * wdt->rate,wdt_addr (wdt,WDT_BARK_TIME ));writel (wdd->timeout * wdt->rate,wdt_addr (wdt,WDT_BITE_TIME )); -writel (qcom_get_enable (wdd),wdt_addr (wdt,WDT_EN )); +writel (QCOM_WDT_ENABLE ,wdt_addr (wdt,WDT_EN ));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 294/340 watchdog: mei_wdt: request stop on unregister
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit 740c0a57b8f1e36301218bf549f3c9cc833a60be upstream.
The MEI bus has a special behavior on suspend it destroys all the attached devices, this is due to the fact that also firmware context is not persistent across power flows.
If watchdog on MEI bus is ticking before suspending the firmware times out and reports that the OS is missing watchdog tick. Send the stop command to the firmware on watchdog unregistered to eliminate the false event on suspend.
This does not make the things worse from the user-space perspective as a user-space should re-open watchdog device after suspending before this patch.
--- drivers/watchdog/mei_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/mei_wdt.c +1 -0
@@ -382,6 +382,7 @@ static int mei_wdt_register(struct mei_wwatchdog_set_drvdata (&wdt->wdd, wdt);watchdog_stop_on_reboot (&wdt->wdd); +watchdog_stop_on_unregister (&wdt->wdd); ret =watchdog_register_device (&wdt->wdd);if (ret)
Greg Kroah-Hartman
maintainerPATCH 295/340 mtd: spi-nor: sfdp: Fix last erase region marking
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 9166f4af32db74e1544a2149aef231ff24515ea3 upstream.
The place of spi_nor_region_mark_end() must be moved, because 'i' is re-used for the index of erase[].
--- drivers/mtd/spi-nor/spi-nor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +1 -2
@@ -3770,6 +3770,7 @@ spi_nor_init_non_uniform_erase_map(struc offset = (region[i].offset & ~SNOR_ERASE_FLAGS_MASK ) + region[i].size; } +spi_nor_region_mark_end (®ion[i -1 ]); save_uniform_erase_type = map->uniform_erase_type; map->uniform_erase_type = spi_nor_sort_erase_mask(map,
@@ -3793,8 +3794,6 @@ spi_nor_init_non_uniform_erase_map(strucif (!(regions_erase_type &BIT (erase[i].idx)))spi_nor_set_erase_type (&erase[i],0 ,0xFF ); -spi_nor_region_mark_end (®ion[i -1 ]); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 296/340 mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit abdf5a5ef9652bad4d58058bc22ddf23543ba3e1 upstream.
At the time spi_nor_region_check_overlay() is called, the erase types are sorted in ascending order of erase size. The 'erase_type' should be masked with 'BIT(erase[i].idx)' instead of 'BIT(i)'.
--- drivers/mtd/spi-nor/spi-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/spi-nor.c +1 -1
@@ -3700,7 +3700,7 @@ spi_nor_region_check_overlay(struct spi_int i;for (i =0 ; i <SNOR_ERASE_TYPE_MAX ; i++) { -if (!(erase_type &BIT (i))) +if (!(erase[i].size && erase_type &BIT (erase[i].idx)))continue ;if (region->size & erase[i].size_mask) {spi_nor_region_mark_overlay (region);
Greg Kroah-Hartman
maintainerPATCH 297/340 mtd: spi-nor: core: Fix erase type discovery for overlaid region
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 969b276718de37dfe66fce3a5633f611e8cd58fd upstream.
In case of overlaid regions in which their biggest erase size command overpasses in size the region's size, only the non-overlaid portion of the sector gets erased. For example, if a Sector Erase command is applied to a 256-kB range that is overlaid by 4-kB sectors, the overlaid 4-kB sectors are not affected by the erase.
For overlaid regions, 'region->size' is assigned to 'cmd->size' later in spi_nor_init_erase_cmd(), so 'erase->size' can be greater than 'len'.
--- drivers/mtd/spi-nor/spi-nor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +5 -4
@@ -1011,14 +1011,15 @@ spi_nor_find_best_erase_type(const struc erase = &map->erase_type[i]; +/* Alignment is not mandatory for overlaid regions */ +if (region->offset &SNOR_OVERLAID_REGION && + region->size <= len) +return erase; +/* Don't erase more than what the user has asked for. */ if (erase->size > len)continue ; -/* Alignment is not mandatory for overlaid regions */ -if (region->offset &SNOR_OVERLAID_REGION ) -return erase; -spi_nor_div_by_erase_size (erase, addr, &rem);if (rem)continue ;
Greg Kroah-Hartman
maintainerPATCH 298/340 mtd: spi-nor: core: Add erase size check for erase command initialization
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 58fa22f68fcaff20ce4d08a6adffa64f65ccd37d upstream.
Even if erase type is same as previous region, erase size can be different if the previous region is overlaid region. Since 'region->size' is assigned to 'cmd->size' for overlaid region, comparing 'erase->size' and 'cmd->size' can detect previous overlaid region.
--- drivers/mtd/spi-nor/spi-nor.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/spi-nor.c +1 -0
@@ -1153,6 +1153,7 @@ static int spi_nor_init_erase_cmd_list(s goto destroy_erase_cmd_list;if (prev_erase != erase || + erase->size != cmd->size || region->offset &SNOR_OVERLAID_REGION ) { cmd =spi_nor_init_erase_cmd (region, erase);if (IS_ERR (cmd)) {
Greg Kroah-Hartman
maintainerPATCH 299/340 mtd: spi-nor: hisi-sfc: Put child node np on error path
In reply to Greg Kroah-HartmanFrom: Pan Bian <[email protected]>
commit fe6653460ee7a7dbe0cd5fd322992af862ce5ab0 upstream.
Put the child node np when it fails to get or register device.
--- drivers/mtd/spi-nor/hisi-sfc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/hisi-sfc.c +3 -1
@@ -396,8 +396,10 @@ static int hisi_spi_nor_register_all(strfor_each_available_child_of_node (dev->of_node, np) { ret =hisi_spi_nor_register (np, host); -if (ret) +if (ret) { +of_node_put (np); goto fail; + }if (host->num_chip ==HIFMC_MAX_CHIP_NUM ) {dev_warn (dev,"Flash device number exceeds the maximum chipselect number\n" );
Greg Kroah-Hartman
maintainerPATCH 300/340 fs/affs: release old buffer head on error path
In reply to Greg Kroah-HartmanFrom: Pan Bian <[email protected]>
commit 70779b897395b330ba5a47bed84f94178da599f9 upstream.
The reference count of the old buffer head should be decremented on path that fails to get the new buffer head.
--- fs/affs/namei.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/affs/namei.c +3 -1
@@ -460,8 +460,10 @@ affs_xrename(struct inode *old_dir, strureturn -EIO ; bh_new =affs_bread (sb,d_inode (new_dentry)->i_ino); -if (!bh_new) +if (!bh_new) { +affs_brelse (bh_old);return -EIO ; + }/* Remove old header from its parent directory. */ affs_lock_dir (old_dir);
Greg Kroah-Hartman
maintainerPATCH 301/340 seq_file: document how per-entry resources are managed.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit b3656d8227f4c45812c6b40815d8f4e446ed372a upstream.
Patch series "Fix some seq_file users that were recently broken".
A recent change to seq_file broke some users which were using seq_file in a non-"standard" way ... though the "standard" isn't documented, so they can be excused. The result is a possible leak - of memory in one case, of references to a 'transport' in the other.
These three patches:
1/ document and explain the problem
2/ fix the problem user in x86
3/ fix the problem user in net/sctp
This patch (of 3):
Users of seq_file will sometimes find it convenient to take a resource, such as a lock or memory allocation, in the ->start or ->next operations. These are per-entry resources, distinct from per-session resources which are taken in ->start and released in ->stop.
The preferred management of these is release the resource on the subsequent call to ->next or ->stop.
However prior to Commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") it happened that ->show would always be called after ->start or ->next, and a few users chose to release the resource in ->show.
This is no longer reliable. Since the mentioned commit, ->next will always come after a successful ->show (to ensure m->index is updated correctly), so the original ordering cannot be maintained.
This patch updates the documentation to clearly state the required behaviour. Other patches will fix the few problematic users.
[[email protected]: fix typo, per Willy]
--- Documentation/filesystems/seq_file.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/filesystems/seq_file.txt +6 -0
@@ -192,6 +192,12 @@ between the calls to start() and stop(), is a reasonable thing to do. The seq_file code will also avoid taking any other locks while the iterator is active. +The iterater value returned by start() or next() is guaranteed to be +passed to a subsequent next() or stop() call. This allows resources +such as locks that were taken to be reliably released. There is *no* +guarantee that the iterator will be passed to show(), though in practice +it often will be. + Formatted output
Greg Kroah-Hartman
maintainerPATCH 302/340 x86: fix seq_file iteration for pat/memtype.c
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit 3d2fc4c082448e9c05792f9b2a11c1d5db408b85 upstream.
The memtype seq_file iterator allocates a buffer in the ->start and ->next functions and frees it in the ->show function. The preferred handling for such resources is to free them in the subsequent ->next or ->stop function call.
Since Commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") there is no guarantee that ->show will be called after ->next, so this function can now leak memory.
So move the freeing of the buffer to ->next and ->stop.
--- arch/x86/mm/pat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/mm/pat.c +2 -1
@@ -1132,12 +1132,14 @@ static void *memtype_seq_start(struct sestatic void *memtype_seq_next (struct seq_file *seq,void *v,loff_t *pos) { +kfree (v); ++*pos;return memtype_get_idx (*pos); }static void memtype_seq_stop (struct seq_file *seq,void *v) { +kfree (v); }static int memtype_seq_show (struct seq_file *seq,void *v)
@@ -1146,7 +1148,6 @@ static int memtype_seq_show(struct seq_fseq_printf (seq,"%s @ 0x%Lx-0x%Lx\n" ,cattr_name (print_entry->type), print_entry->start, print_entry->end); -kfree (print_entry);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 303/340 hugetlb: fix update_and_free_page contig page struct assumption
In reply to Greg Kroah-HartmanFrom: Mike Kravetz <[email protected]>
commit dbfee5aee7e54f83d96ceb8e3e80717fac62ad63 upstream.
page structs are not guaranteed to be contiguous for gigantic pages. The routine update_and_free_page can encounter a gigantic page, yet it assumes page structs are contiguous when setting page flags in subpages.
If update_and_free_page encounters non-contiguous page structs, we can see “BUG: Bad page state in process …” errors.
Non-contiguous page structs are generally not an issue. However, they can exist with a specific kernel configuration and hotplug operations. For
example: Configure the kernel with CONFIG_SPARSEMEM and !CONFIG_SPARSEMEM_VMEMMAP. Then, hotplug add memory for the area where the gigantic page will be allocated. Zi Yan outlined steps to reproduce here [1].
[1] https://lore.kernel.org/linux-mm/[email protected]/
--- mm/hugetlb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/hugetlb.c +4 -2
@@ -1192,14 +1192,16 @@ static inline void destroy_compound_gigastatic void update_and_free_page (struct hstate *h,struct page *page) {int i; +struct page *subpage = page;if (hstate_is_gigantic (h) && !gigantic_page_runtime_supported ())return ; h->nr_huge_pages--; h->nr_huge_pages_node[page_to_nid (page)]--; -for (i =0 ; i <pages_per_huge_page (h); i++) { - page[i].flags &= ~(1 << PG_locked |1 << PG_error | +for (i =0 ; i <pages_per_huge_page (h); + i++, subpage =mem_map_next (subpage, page, i)) { + subpage->flags &= ~(1 << PG_locked |1 << PG_error |1 << PG_referenced |1 << PG_dirty |1 << PG_active |1 << PG_private |1 << PG_writeback);
Greg Kroah-Hartman
maintainerPATCH 304/340 hugetlb: fix copy_huge_page_from_user contig page struct assumption
In reply to Greg Kroah-HartmanFrom: Mike Kravetz <[email protected]>
commit 3272cfc2525b3a2810a59312d7a1e6f04a0ca3ef upstream.
page structs are not guaranteed to be contiguous for gigantic pages. The routine copy_huge_page_from_user can encounter gigantic pages, yet it assumes page structs are contiguous when copying pages from user space.
Since page structs for the target gigantic page are not contiguous, the data copied from user space could overwrite other pages not associated with the gigantic page and cause data corruption.
Non-contiguous page structs are generally not an issue. However, they can exist with a specific kernel configuration and hotplug operations. For
example: Configure the kernel with CONFIG_SPARSEMEM and !CONFIG_SPARSEMEM_VMEMMAP. Then, hotplug add memory for the area where the gigantic page will be allocated.
--- mm/memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
mm/memory.c +6 -4
@@ -4718,17 +4718,19 @@ long copy_huge_page_from_user(struct pagvoid *page_kaddr;unsigned long i, rc =0 ;unsigned long ret_val = pages_per_huge_page *PAGE_SIZE ; +struct page *subpage = dst_page; -for (i =0 ; i < pages_per_huge_page; i++) { +for (i =0 ; i < pages_per_huge_page; + i++, subpage =mem_map_next (subpage, dst_page, i)) {if (allow_pagefault) - page_kaddr =kmap (dst_page + i); + page_kaddr =kmap (subpage);else - page_kaddr =kmap_atomic (dst_page + i); + page_kaddr =kmap_atomic (subpage); rc =copy_from_user (page_kaddr, (const void __user *)(src + i *PAGE_SIZE ),PAGE_SIZE );if (allow_pagefault) -kunmap (dst_page + i); +kunmap (subpage);else kunmap_atomic (page_kaddr);
Greg Kroah-Hartman
maintainerPATCH 305/340 arm64: Extend workaround for erratum 1024718 to all versions of Cortex-A55
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit c0b15c25d25171db4b70cc0b7dbc1130ee94017d upstream.
The erratum 1024718 affects Cortex-A55 r0p0 to r2p0. However we apply the work around for r0p0 - r1p0. Unfortunately this won't be fixed for the future revisions for the CPU. Thus extend the work around for all versions of A55, to cover for r2p0 and any future revisions.
--- arch/arm64/Kconfig | 2 +- arch/arm64/kernel/cpufeature.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -489,7 +489,7 @@ config ARM64_ERRATUM_1024718 help This option adds a workaround for ARM Cortex-A55 Erratum 1024718. - Affected Cortex-A55 cores (r0p0, r0p1, r1p0) could cause incorrect + Affected Cortex-A55 cores (all revisions) could cause incorrect update of the hardware dirty bit when the DBM/AP bits are updated without a break-before-make. The workaround is to disable the usage of hardware DBM locally on the affected cores. CPUs not affected by
arch/arm64/kernel/cpufeature.c +1 -1
@@ -1092,7 +1092,7 @@ static bool cpu_has_broken_dbm(void)/* List of CPUs which have broken DBM support. */ static const struct midr_range cpus[] = { #ifdef CONFIG_ARM64_ERRATUM_1024718 -MIDR_RANGE (MIDR_CORTEX_A55 ,0 ,0 ,1 ,0 ),// A55 r0p0 -r1p0 +MIDR_ALL_VERSIONS (MIDR_CORTEX_A55 ), #endif {}, };
Greg Kroah-Hartman
maintainerPATCH 306/340 media: smipcie: fix interrupt handling and IR timeout
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 6532923237b427ed30cc7b4486f6f1ccdee3c647 upstream.
After the first IR message, interrupts are no longer received. In addition, the code generates a timeout IR message of 10ms but sets the timeout value to 100ms, so no timeout was ever generated.
--- drivers/media/pci/smipcie/smipcie-ir.c | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-)
drivers/media/pci/smipcie/smipcie-ir.c +27 -21
@@ -60,39 +60,45 @@ static void smi_ir_decode(struct smi_rc {struct smi_dev *dev = ir->dev;struct rc_dev *rc_dev = ir->rc_dev; -u32 dwIRControl, dwIRData; -u8 index, ucIRCount, readLoop; +u32 control, data; +u8 index, ir_count, read_loop; - dwIRControl =smi_read (IR_Init_Reg); + control =smi_read (IR_Init_Reg); -if (dwIRControl & rbIRVld) { - ucIRCount = (u8 )smi_read (IR_Data_Cnt); +dev_dbg (&rc_dev->dev,"ircontrol: 0x%08x\n" , control); - readLoop = ucIRCount/4 ; -if (ucIRCount %4 ) - readLoop +=1 ; -for (index =0 ; index < readLoop; index++) { - dwIRData =smi_read (IR_DATA_BUFFER_BASE + (index *4 )); - - ir->irData[index*4 +0 ] = (u8)(dwIRData); - ir->irData[index*4 +1 ] = (u8)(dwIRData >>8 ); - ir->irData[index*4 +2 ] = (u8)(dwIRData >>16 ); - ir->irData[index*4 +3 ] = (u8)(dwIRData >>24 ); +if (control & rbIRVld) { + ir_count = (u8 )smi_read (IR_Data_Cnt); + +dev_dbg (&rc_dev->dev,"ircount %d\n" , ir_count); + + read_loop = ir_count /4 ; +if (ir_count %4 ) + read_loop +=1 ; +for (index =0 ; index < read_loop; index++) { + data =smi_read (IR_DATA_BUFFER_BASE + (index *4 )); +dev_dbg (&rc_dev->dev,"IRData 0x%08x\n" , data); + + ir->irData[index *4 +0 ] = (u8)(data); + ir->irData[index *4 +1 ] = (u8)(data >>8 ); + ir->irData[index *4 +2 ] = (u8)(data >>16 ); + ir->irData[index *4 +3 ] = (u8)(data >>24 ); } -smi_raw_process (rc_dev, ir->irData, ucIRCount); -smi_set (IR_Init_Reg, rbIRVld); +smi_raw_process (rc_dev, ir->irData, ir_count); } -if (dwIRControl & rbIRhighidle) { +if (control & rbIRhighidle) {struct ir_raw_event rawir = {}; +dev_dbg (&rc_dev->dev,"high idle\n" ); + rawir.pulse =0 ; rawir.duration =US_TO_NS (SMI_SAMPLE_PERIOD *SMI_SAMPLE_IDLEMIN );ir_raw_event_store_with_filter (rc_dev, &rawir); -smi_set (IR_Init_Reg, rbIRhighidle); } +smi_set (IR_Init_Reg, rbIRVld);ir_raw_event_handle (rc_dev); }
@@ -151,7 +157,7 @@ int smi_ir_init(struct smi_dev *dev) rc_dev->dev.parent = &dev->pci_dev->dev; rc_dev->map_name = dev->info->rc_map; - rc_dev->timeout =MS_TO_NS (100 ); + rc_dev->timeout =US_TO_NS (SMI_SAMPLE_PERIOD *SMI_SAMPLE_IDLEMIN ); rc_dev->rx_resolution =US_TO_NS (SMI_SAMPLE_PERIOD ); ir->rc_dev = rc_dev;
@@ -174,7 +180,7 @@ void smi_ir_exit(struct smi_dev *dev)struct smi_rc *ir = &dev->ir;struct rc_dev *rc_dev = ir->rc_dev; -smi_ir_stop (ir);rc_unregister_device (rc_dev); +smi_ir_stop (ir); ir->rc_dev =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 307/340 module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit ebfac7b778fac8b0e8e92ec91d0b055f046b4604 upstream.
clang-12 -fno-pic (since
https://github.com/llvm/llvm-project/commit/a084c0388e2a59b9556f2de0083333232da3f1d6)
can emit call __stack_chk_fail@PLT instead of call __stack_chk_fail on x86. The two forms should have identical behaviors on x86-64 but the former causes GNU as<2.37 to produce an unreferenced undefined symbol _GLOBAL_OFFSET_TABLE_.
(On x86-32, there is an R_386_PC32 vs R_386_PLT32 difference but the linker behavior is identical as far as Linux kernel is concerned.)
Simply ignore _GLOBAL_OFFSET_TABLE_ for now, like what scripts/mod/modpost.c:ignore_undef_symbol does. This also fixes the problem for gcc/clang -fpie and -fpic, which may emit call foo@PLT for external function calls on x86.
Note: ld -z defs and dynamic loaders do not error for unreferenced undefined symbols so the module loader is reading too much. If we ever need to ignore more symbols, the code should be refactored to ignore unreferenced symbols.
--- kernel/module.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
kernel/module.c +19 -2
@@ -2310,6 +2310,21 @@ static int verify_exported_symbols(strucreturn 0 ; } +static bool ignore_undef_symbol (Elf_Half emachine,const char *name) +{ +/* +* On x86, PIC code and Clang non-PIC code may have call foo@PLT. GNU as +* before 2.37 produces an unreferenced _GLOBAL_OFFSET_TABLE_ on x86-64. +* i386 has a similar problem but may not deserve a fix. +* +* If we ever have to ignore many symbols, consider refactoring the code to +* only warn if referenced by a relocation. +*/ +if (emachine ==EM_386 || emachine ==EM_X86_64 ) +return !strcmp (name,"_GLOBAL_OFFSET_TABLE_" ); +return false; +} +/* Change all symbols so that st_value encodes the pointer directly. */ static int simplify_symbols (struct module *mod,const struct load_info *info) {
@@ -2355,8 +2370,10 @@ static int simplify_symbols(struct modulbreak ; } -/* Ok if weak. */ -if (!ksym &&ELF_ST_BIND (sym[i].st_info) ==STB_WEAK ) +/* Ok if weak or ignored. */ +if (!ksym && + (ELF_ST_BIND (sym[i].st_info) ==STB_WEAK || +ignore_undef_symbol (info->hdr->e_machine, name)))break ; ret =PTR_ERR (ksym) ?: -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 308/340 mmc: sdhci-esdhc-imx: fix kernel panic when remove module
In reply to Greg Kroah-HartmanFrom: Frank Li <[email protected]>
commit a56f44138a2c57047f1ea94ea121af31c595132b upstream.
In sdhci_esdhc_imx_remove() the SDHCI_INT_STATUS in read. Under some circumstances, this may be done while the device is runtime suspended, triggering the below splat.
Fix the problem by adding a pm_runtime_get_sync(), before reading the register, which will turn on clocks etc making the device accessible again.
[ 1811.323148] mmc1: card aaaa removed [ 1811.347483] Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP [ 1811.354988] Modules linked in: sdhci_esdhc_imx(-) sdhci_pltfm sdhci cqhci mmc_block mmc_core [last unloaded: mmc_core] [ 1811.365726] CPU: 0 PID: 3464 Comm: rmmod Not tainted 5.10.1-sd-99871-g53835a2e8186 #5 [ 1811.373559] Hardware name: Freescale i.MX8DXL EVK (DT) [ 1811.378705] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) [ 1811.384723] pc : sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx] [ 1811.391090] lr : platform_drv_remove+0x2c/0x50 [ 1811.395536] sp : ffff800012c7bcb0 [ 1811.398855] x29: ffff800012c7bcb0 x28: ffff00002c72b900 [ 1811.404181] x27: 0000000000000000 x26: 0000000000000000 [ 1811.409497] x25: 0000000000000000 x24: 0000000000000000 [ 1811.414814] x23: ffff0000042b3890 x22: ffff800009127120 [ 1811.420131] x21: ffff00002c4c9580 x20: ffff0000042d0810 [ 1811.425456] x19: ffff0000042d0800 x18: 0000000000000020 [ 1811.430773] x17: 0000000000000000 x16: 0000000000000000 [ 1811.436089] x15: 0000000000000004 x14: ffff000004019c10 [ 1811.441406] x13: 0000000000000000 x12: 0000000000000020 [ 1811.446723] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 1811.452040] x9 : fefefeff6364626d x8 : 7f7f7f7f7f7f7f7f [ 1811.457356] x7 : 78725e6473607372 x6 : 0000000080808080 [ 1811.462673] x5 : 0000000000000000 x4 : 0000000000000000 [ 1811.467990] x3 : ffff800011ac1cb0 x2 : 0000000000000000 [ 1811.473307] x1 : ffff8000091214d4 x0 : ffff8000133a0030 [ 1811.478624] Call trace: [ 1811.481081] sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx] [ 1811.487098] platform_drv_remove+0x2c/0x50 [ 1811.491198] __device_release_driver+0x188/0x230 [ 1811.495818] driver_detach+0xc0/0x14c [ 1811.499487] bus_remove_driver+0x5c/0xb0 [ 1811.503413] driver_unregister+0x30/0x60 [ 1811.507341] platform_driver_unregister+0x14/0x20 [ 1811.512048] sdhci_esdhc_imx_driver_exit+0x1c/0x3a8 [sdhci_esdhc_imx] [ 1811.518495] __arm64_sys_delete_module+0x19c/0x230 [ 1811.523291] el0_svc_common.constprop.0+0x78/0x1a0 [ 1811.528086] do_el0_svc+0x24/0x90 [ 1811.531405] el0_svc+0x14/0x20 [ 1811.534461] el0_sync_handler+0x1a4/0x1b0 [ 1811.538474] el0_sync+0x174/0x180 [ 1811.541801] Code: a9025bf5 f9403e95 f9400ea0 9100c000 (b9400000) [ 1811.547902] ---[ end trace 3fb1a3bd48ff7be5 ]---
--- drivers/mmc/host/sdhci-esdhc-imx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -1
@@ -1589,9 +1589,10 @@ static int sdhci_esdhc_imx_remove(structstruct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct pltfm_imx_data *imx_data =sdhci_pltfm_priv (pltfm_host); -int dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff ); +int dead;pm_runtime_get_sync (&pdev->dev); + dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff );pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 309/340 powerpc/32s: Add missing call to kuep_lock on syscall entry
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 57fdfbce89137ae85cd5cef48be168040a47dd13 upstream.
Userspace Execution protection and fast syscall entry were implemented independently from each other and were both merged in kernel 5.2, leading to syscall entry missing userspace execution protection.
On syscall entry, execution of user space memory must be locked in the same way as on exception entry.
--- arch/powerpc/kernel/entry_32.S | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/entry_32.S +3 -0
@@ -336,6 +336,9 @@ trace_syscall_entry_irq_off: .globl transfer_to_syscall transfer_to_syscall: +#ifdef CONFIG_PPC_BOOK3S_32 + kuep_lock r11, r12 +#endif #ifdef CONFIG_TRACE_IRQFLAGS andi. r12,r9,MSR_EE beq- trace_syscall_entry_irq_off
Greg Kroah-Hartman
maintainerPATCH 310/340 spmi: spmi-pmic-arb: Fix hw_irq overflow
In reply to Greg Kroah-HartmanFrom: Subbaraman Narayanamurthy <[email protected]>
commit d19db80a366576d3ffadf2508ed876b4c1faf959 upstream.
Currently, when handling the SPMI summary interrupt, the hw_irq number is calculated based on SID, Peripheral ID, IRQ index and APID. This is then passed to irq_find_mapping() to see if a mapping exists for this hw_irq and if available, invoke the interrupt handler. Since the IRQ index uses an "int" type, hw_irq which is of unsigned long data type can take a large value when SID has its MSB set to 1 and the type conversion happens. Because of this, irq_find_mapping() returns 0 as there is no mapping for this hw_irq. This ends up invoking cleanup_irq() as if the interrupt is spurious whereas it is actually a valid interrupt. Fix this by using the proper data type (u32) for id.
--- drivers/spmi/spmi-pmic-arb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/spmi/spmi-pmic-arb.c +2 -3
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved. +* Copyright (c) 2012-2015, 2017, 2021, The Linux Foundation. All rights reserved. */ #include <linux/bitmap.h> #include <linux/delay.h>
@@ -505,8 +505,7 @@ static void cleanup_irq(struct spmi_pmicstatic void periph_interrupt (struct spmi_pmic_arb *pmic_arb,u16 apid) {unsigned int irq; -u32 status; -int id; +u32 status, id;u8 sid = (pmic_arb->apid_data[apid].ppid >>8 ) &0xF ;u8 per = pmic_arb->apid_data[apid].ppid &0xFF ;
Greg Kroah-Hartman
maintainerPATCH 311/340 gpio: pcf857x: Fix missing first interrupt
In reply to Greg Kroah-HartmanFrom: Maxim Kiselev <[email protected]>
commit a8002a35935aaefcd6a42ad3289f62bab947f2ca upstream.
If no n_latch value will be provided at driver probe then all pins will be used as an input:
gpio->out = ~n_latch;
In that case initial state for all pins is "one":
gpio->status = gpio->out;
So if pcf857x IRQ happens with change pin value from "zero" to "one" then we miss it, because of "one" from IRQ and "one" from initial state leaves corresponding pin unchanged:
change = (gpio->status ^ status) & gpio->irq_enabled;
The right solution will be to read actual state at driver probe.
--- drivers/gpio/gpio-pcf857x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pcf857x.c +1 -1
@@ -332,7 +332,7 @@ static int pcf857x_probe(struct i2c_clie* reset state. Otherwise it flags pins to be driven low. */ gpio->out = ~n_latch; - gpio->status = gpio->out; + gpio->status = gpio->read (gpio->client); status =devm_gpiochip_add_data (&client->dev, &gpio->chip, gpio);if (status <0 )
Greg Kroah-Hartman
maintainerPATCH 312/340 printk: fix deadlock when kernel panic
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
commit 8a8109f303e25a27f92c1d8edd67d7cbbc60a4eb upstream.
printk_safe_flush_on_panic() caused the following deadlock on our server:
CPU0: CPU1:
panic rcu_dump_cpu_stacks
kdump_nmi_shootdown_cpus nmi_trigger_cpumask_backtrace
register_nmi_handler(crash_nmi_callback) printk_safe_flush
__printk_safe_flush
raw_spin_lock_irqsave(&read_lock)
// send NMI to other processors
apic_send_IPI_allbutself(NMI_VECTOR)
// NMI interrupt, dead loop
crash_nmi_callback
printk_safe_flush_on_panic
printk_safe_flush
__printk_safe_flush
// deadlock
raw_spin_lock_irqsave(&read_lock)DEADLOCK: read_lock is taken on CPU1 and will never get released.
It happens when panic() stops a CPU by NMI while it has been in the middle of printk_safe_flush().
Handle the lock the same way as logbuf_lock. The printk_safe buffers are flushed only when both locks can be safely taken. It can avoid the deadlock _in this particular case_ at expense of losing contents of printk_safe buffers.
Note: It would actually be safe to re-init the locks when all CPUs were
stopped by NMI. But it would require passing this information from arch-specific code. It is not worth the complexity. Especially because logbuf_lock and printk_safe buffers have been obsoleted by the lockless ring buffer.
--- kernel/printk/printk_safe.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
kernel/printk/printk_safe.c +12 -4
@@ -43,6 +43,8 @@ struct printk_safe_seq_buf { static DEFINE_PER_CPU(struct printk_safe_seq_buf, safe_print_seq); static DEFINE_PER_CPU(int, printk_context); +static DEFINE_RAW_SPINLOCK (safe_read_lock); +#ifdef CONFIG_PRINTK_NMI static DEFINE_PER_CPU(struct printk_safe_seq_buf, nmi_print_seq);#endif
@@ -178,8 +180,6 @@ static void report_message_lost(struct p*/ static void __printk_safe_flush (struct irq_work *work) { -static raw_spinlock_t read_lock = -__RAW_SPIN_LOCK_INITIALIZER (read_lock);struct printk_safe_seq_buf *s = container_of(work, struct printk_safe_seq_buf, work);unsigned long flags;
@@ -193,7 +193,7 @@ static void __printk_safe_flush(struct i* different CPUs. This is especially important when printing * a backtrace. */ -raw_spin_lock_irqsave (&read_lock, flags); +raw_spin_lock_irqsave (&safe_read_lock, flags); i =0 ; more:
@@ -230,7 +230,7 @@ more: out:report_message_lost (s); -raw_spin_unlock_irqrestore (&read_lock, flags); +raw_spin_unlock_irqrestore (&safe_read_lock, flags); }/**
@@ -276,6 +276,14 @@ void printk_safe_flush_on_panic(void)raw_spin_lock_init (&logbuf_lock); } +if (raw_spin_is_locked (&safe_read_lock)) { +if (num_online_cpus () >1 ) +return ; + +debug_locks_off (); +raw_spin_lock_init (&safe_read_lock); + } +printk_safe_flush (); }
Greg Kroah-Hartman
maintainerPATCH 313/340 cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available
In reply to Greg Kroah-HartmanFrom: Chen Yu <[email protected]>
commit 6f67e060083a84a4cc364eab6ae40c717165fb0c upstream.
Currently, when turbo is disabled (either by BIOS or by the user), the intel_pstate driver reads the max non-turbo frequency from the package-wide MSR_PLATFORM_INFO(0xce) register.
However, on asymmetric platforms it is possible in theory that small and big core with HWP enabled might have different max non-turbo CPU frequency, because MSR_HWP_CAPABILITIES is per-CPU scope according to Intel Software Developer Manual.
The turbo max freq is already per-CPU in current code, so make similar change to the max non-turbo frequency as well.
--- drivers/cpufreq/intel_pstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +3 -2
@@ -1566,11 +1566,9 @@ static void intel_pstate_max_within_limistatic void intel_pstate_get_cpu_pstates (struct cpudata *cpu) { cpu->pstate.min_pstate = pstate_funcs.get_min (); - cpu->pstate.max_pstate = pstate_funcs.get_max (); cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical (); cpu->pstate.turbo_pstate = pstate_funcs.get_turbo (); cpu->pstate.scaling = pstate_funcs.get_scaling (); - cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;if (hwp_active && !hwp_mode_bdw) {unsigned int phy_max, current_max;
@@ -1578,9 +1576,12 @@ static void intel_pstate_get_cpu_pstatesintel_pstate_get_hwp_max (cpu->cpu, &phy_max, ¤t_max); cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; cpu->pstate.turbo_pstate = phy_max; + cpu->pstate.max_pstate =HWP_GUARANTEED_PERF (READ_ONCE (cpu->hwp_cap_cached)); }else { cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; + cpu->pstate.max_pstate = pstate_funcs.get_max (); } + cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;if (pstate_funcs.get_aperf_mperf_shift) cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift ();
Greg Kroah-Hartman
maintainerPATCH 314/340 s390/vtime: fix inline assembly clobber list
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
commit b29c5093820d333eef22f58cd04ec0d089059c39 upstream.
The stck/stckf instruction used within the inline assembly within do_account_vtime() changes the condition code. This is not reflected with the clobber list, and therefore might result in incorrect code generation.
It seems unlikely that the compiler could generate incorrect code considering the surrounding C code, but it must still be fixed.
--- arch/s390/kernel/vtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kernel/vtime.c +2 -1
@@ -136,7 +136,8 @@ static int do_account_vtime(struct task_" stck %1" /* Store current tod clock value */ #endif : "=Q" (S390_lowcore.last_update_timer), - "=Q" (S390_lowcore.last_update_clock)); +"=Q" (S390_lowcore.last_update_clock) + : : "cc"); clock = S390_lowcore.last_update_clock - clock; timer -= S390_lowcore.last_update_timer;
Greg Kroah-Hartman
maintainerPATCH 315/340 virtio/s390: implement virtio-ccw revision 2 correctly
In reply to Greg Kroah-HartmanFrom: Cornelia Huck <[email protected]>
commit 182f709c5cff683e6732d04c78e328de0532284f upstream.
CCW_CMD_READ_STATUS was introduced with revision 2 of virtio-ccw, and drivers should only rely on it being implemented when they negotiated at least that revision with the device.
However, virtio_ccw_get_status() issued READ_STATUS for any device operating at least at revision 1. If the device accepts READ_STATUS regardless of the negotiated revision (which some implementations like QEMU do, even though the spec currently does not allow it), everything works as intended. While a device rejecting the command should also be handled gracefully, we will not be able to see any changes the device makes to the status, such as setting NEEDS_RESET or setting the status to zero after a completed reset.
We negotiated the revision to at most 1, as we never bumped the maximum revision; let's do that now and properly send READ_STATUS only if we are operating at least at revision 2.
--- drivers/s390/virtio/virtio_ccw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/virtio/virtio_ccw.c +2 -2
@@ -117,7 +117,7 @@ struct virtio_rev_info { };/* the highest virtio-ccw revision we support */ -#define VIRTIO_CCW_REV_MAX 1 +#define VIRTIO_CCW_REV_MAX 2struct virtio_ccw_vq_info {struct virtqueue *vq;
@@ -952,7 +952,7 @@ static u8 virtio_ccw_get_status(struct vu8 old_status = vcdev->dma_area->status;struct ccw1 *ccw; -if (vcdev->revision <1 ) +if (vcdev->revision <2 )return vcdev->dma_area->status; ccw =ccw_device_dma_zalloc (vcdev->cdev,sizeof (*ccw));
Greg Kroah-Hartman
maintainerPATCH 316/340 um: mm: check more comprehensively for stub changes
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 47da29763ec9a153b9b685bff9db659e4e09e494 upstream.
If userspace tries to change the stub, we need to kill it, because otherwise it can escape the virtual machine. In a few cases the stub checks weren't good, e.g. if userspace just tries to
mmap(0x100000 - 0x1000, 0x3000, ...)
it could succeed to get a new private/anonymous mapping replacing the stubs. Fix this by checking everywhere, and checking for _overlap_, not just direct changes.
--- arch/um/kernel/tlb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/um/kernel/tlb.c +11 -1
@@ -126,6 +126,9 @@ static int add_mmap(unsigned long virt,struct host_vm_op *last;int fd =-1 , ret =0 ; +if (virt + len >STUB_START && virt <STUB_END ) +return -EINVAL ; +if (hvc->userspace) fd =phys_mapping (phys, &offset);else
@@ -163,7 +166,7 @@ static int add_munmap(unsigned long addrstruct host_vm_op *last;int ret =0 ; -if ((addr >=STUB_START ) && (addr <STUB_END )) +if (addr + len >STUB_START && addr <STUB_END )return -EINVAL ;if (hvc->index !=0 ) {
@@ -193,6 +196,9 @@ static int add_mprotect(unsigned long adstruct host_vm_op *last;int ret =0 ; +if (addr + len >STUB_START && addr <STUB_END ) +return -EINVAL ; +if (hvc->index !=0 ) { last = &hvc->ops[hvc->index -1 ]; if ((last->type == MPROTECT) &&
@@ -433,6 +439,10 @@ void flush_tlb_page(struct vm_area_strucstruct mm_id *mm_id; address &=PAGE_MASK ; + +if (address >=STUB_START && address <STUB_END ) + goto kill; + pgd =pgd_offset (mm, address);if (!pgd_present (*pgd)) goto kill;
Greg Kroah-Hartman
maintainerPATCH 317/340 f2fs: fix out-of-repair __setattr_copy()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit 2562515f0ad7342bde6456602c491b64c63fe950 upstream.
__setattr_copy() was copied from setattr_copy() in fs/attr.c, there is two missing patches doesn't cover this inner function, fix it.
Commit 7fa294c8991c ("userns: Allow chown and setgid preservation") Commit 23adbe12ef7d ("fs,userns: Change inode_capable to capable_wrt_inode_uidgid")
--- fs/f2fs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/file.c +2 -1
@@ -765,7 +765,8 @@ static void __setattr_copy(struct inodeif (ia_valid &ATTR_MODE ) {umode_t mode = attr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (inode->i_gid) && + !capable_wrt_inode_uidgid (inode,CAP_FSETID )) mode &= ~S_ISGID ;set_acl_inode (inode, mode); }
Greg Kroah-Hartman
maintainerPATCH 318/340 sparc32: fix a user-triggerable oops in clear_user()
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 7780918b36489f0b2f9a3749d7be00c2ceaec513 upstream.
Back in 2.1.29 the clear_user() guts (__bzero()) had been merged with memset(). Unfortunately, while all exception handlers had been copied, one of the exception table entries got lost. As the result, clear_user() starting at 128*n bytes before the end of page and spanning between 8 and 127 bytes into the next page would oops when the second page is unmapped. It's trivial to reproduce - all it takes is
main()
{
int fd = open("/dev/zero", O_RDONLY);
char *p = mmap(NULL, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON, -1, 0);
munmap(p + 8192, 8192);
read(fd, p + 8192 - 128, 192);
}which had been oopsing since March 1997. Says something about the quality of test coverage... ;-/ And while today sparc32 port is nearly dead, back in '97 it had been very much alive; in fact, sparc64 had only been in mainline for 3 months by that point...
--- arch/sparc/lib/memset.S | 1 + 1 file changed, 1 insertion(+)
arch/sparc/lib/memset.S +1 -0
@@ -142,6 +142,7 @@ __bzero: ZERO_LAST_BLOCKS(%o0, 0x48, %g2) ZERO_LAST_BLOCKS(%o0, 0x08, %g2) 13: + EXT(12b, 13b, 21f) be 8f andcc %o1, 4, %g0
Greg Kroah-Hartman
maintainerPATCH 319/340 spi: spi-synquacer: fix set_cs handling
In reply to Greg Kroah-HartmanFrom: Masahisa Kojima <[email protected]>
commit 1c9f1750f0305bf605ff22686fc0ac89c06deb28 upstream.
When the slave chip select is deasserted, DMSTOP bit must be set.
--- drivers/spi/spi-synquacer.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi-synquacer.c +4 -0
@@ -490,6 +490,10 @@ static void synquacer_spi_set_cs(struct val &= ~(SYNQUACER_HSSPI_DMPSEL_CS_MASK <<SYNQUACER_HSSPI_DMPSEL_CS_SHIFT ); val |= spi->chip_select <<SYNQUACER_HSSPI_DMPSEL_CS_SHIFT ; + +if (!enable) + val |=SYNQUACER_HSSPI_DMSTOP_STOP ; +writel (val, sspi->regs +SYNQUACER_HSSPI_REG_DMSTART ); }
Greg Kroah-Hartman
maintainerPATCH 320/340 gfs2: Dont skip dlm unlock if glock has an lvb
In reply to Greg Kroah-HartmanFrom: Bob Peterson <[email protected]>
commit 78178ca844f0eb88f21f31c7fde969384be4c901 upstream.
Patch fb6791d100d1 was designed to allow gfs2 to unmount quicker by skipping the step where it tells dlm to unlock glocks in EX with lvbs. This was done because when gfs2 unmounts a file system, it destroys the dlm lockspace shortly after it destroys the glocks so it doesn't need to unlock them all: the unlock is implied when the lockspace is destroyed by dlm.
However, that patch introduced a use-after-free in dlm: as part of its normal dlm_recoverd process, it can call ls_recovery to recover dead locks. In so doing, it can call recover_rsbs which calls recover_lvb for any mastered rsbs. Func recover_lvb runs through the list of lkbs queued to the given rsb (if the glock is cached but unlocked, it will still be queued to the lkb, but in NL--Unlocked--mode) and if it has an lvb, copies it to the rsb, thus trying to preserve the lkb. However, when gfs2 skips the dlm unlock step, it frees the glock and its lvb, which means dlm's function recover_lvb references the now freed lvb pointer, copying the freed lvb memory to the rsb.
This patch changes the check in gdlm_put_lock so that it calls dlm_unlock for all glocks that contain an lvb pointer.
--- fs/gfs2/lock_dlm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/gfs2/lock_dlm.c +2 -6
@@ -280,7 +280,6 @@ static void gdlm_put_lock(struct gfs2_gl {struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;struct lm_lockstruct *ls = &sdp->sd_lockstruct; -int lvb_needs_unlock =0 ;int error;if (gl->gl_lksb.sb_lkid ==0 ) {
@@ -293,13 +292,10 @@ static void gdlm_put_lock(struct gfs2_glgfs2_sbstats_inc (gl,GFS2_LKS_DCOUNT );gfs2_update_request_times (gl); -/* don't want to skip dlm_unlock writing the lvb when lock is ex */ - -if (gl->gl_lksb.sb_lvbptr && (gl->gl_state ==LM_ST_EXCLUSIVE )) - lvb_needs_unlock =1 ; +/* don't want to skip dlm_unlock writing the lvb when lock has one */ if (test_bit (SDF_SKIP_DLM_UNLOCK , &sdp->sd_flags) && - !lvb_needs_unlock) { + !gl->gl_lksb.sb_lvbptr) {gfs2_glock_free (gl);return ; }
Greg Kroah-Hartman
maintainerPATCH 321/340 gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 7009fa9cd9a5262944b30eb7efb1f0561d074b68 upstream.
When starting an iomap write, gfs2_quota_lock_check -> gfs2_quota_lock -> gfs2_quota_hold is called from gfs2_iomap_begin. At the end of the write, before unlocking the quotas, punch_hole -> gfs2_quota_hold can be called again in gfs2_iomap_end, which is incorrect and leads to a failed assertion. Instead, move the call to gfs2_quota_unlock before the call to punch_hole to fix that.
--- fs/gfs2/bmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/bmap.c +3 -3
@@ -1228,6 +1228,9 @@ static int gfs2_iomap_end(struct inode *gfs2_inplace_release (ip); +if (ip->i_qadata && ip->i_qadata->qa_qd_num) +gfs2_quota_unlock (ip); +if (length != written && (iomap->flags &IOMAP_F_NEW )) {/* Deallocate blocks that were just allocated. */ loff_t blockmask =i_blocksize (inode) -1 ;
@@ -1240,9 +1243,6 @@ static int gfs2_iomap_end(struct inode * } } -if (ip->i_qadata && ip->i_qadata->qa_qd_num) -gfs2_quota_unlock (ip); -if (unlikely (!written)) goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 322/340 dm: fix deadlock when swapping to encrypted device
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit a666e5c05e7c4aaabb2c5d58117b0946803d03d2 upstream.
The system would deadlock when swapping to a dm-crypt device. The reason is that for each incoming write bio, dm-crypt allocates memory that holds encrypted data. These excessive allocations exhaust all the memory and the result is either deadlock or OOM trigger.
This patch limits the number of in-flight swap bios, so that the memory consumed by dm-crypt is limited. The limit is enforced if the target set the "limit_swap_bios" variable and if the bio has REQ_SWAP set.
Non-swap bios are not affected becuase taking the semaphore would cause performance degradation.
This is similar to request-based drivers - they will also block when the number of requests is over the limit.
--- drivers/md/dm-core.h | 4 ++ drivers/md/dm-crypt.c | 1 drivers/md/dm.c | 60 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device-mapper.h | 5 +++ 4 files changed, 70 insertions(+)
drivers/md/dm-core.h +4 -0
@@ -106,6 +106,10 @@ struct mapped_device {struct block_device *bdev; +int swap_bios; +struct semaphore swap_bios_semaphore; +struct mutex swap_bios_lock; +struct dm_stats stats;/* for blk-mq request-based DM support */
drivers/md/dm-crypt.c +1 -0
@@ -2737,6 +2737,7 @@ static int crypt_ctr(struct dm_target *twake_up_process (cc->write_thread); ti->num_flush_bios =1 ; + ti->limit_swap_bios = true;return 0 ;
drivers/md/dm.c +60 -0
118 lines not on this page · raw message
include/linux/device-mapper.h +5 -0
@@ -316,6 +316,11 @@ struct dm_target {* whether or not its underlying devices have support. */ bool discards_supported:1; + +/* +* Set if we need to limit the number of in-flight bios when swapping. +*/ + bool limit_swap_bios:1; };/* Each target can link one of these into the table */
Greg Kroah-Hartman
maintainerPATCH 323/340 dm writecache: fix writing beyond end of underlying device when shrinking
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 4134455f2aafdfeab50cabb4cccb35e916034b93 upstream.
Do not attempt to write any data beyond the end of the underlying data device while shrinking it.
The DM writecache device must be suspended when the underlying data device is shrunk.
--- drivers/md/dm-writecache.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/md/dm-writecache.c +18 -0
@@ -142,6 +142,7 @@ struct dm_writecache {size_t metadata_sectors;size_t n_blocks;uint64_t seq_count; +sector_t data_device_sectors;void *block_start;struct wc_entry *entries;unsigned block_size;
@@ -918,6 +919,8 @@ static void writecache_resume(struct dm_wc_lock (wc); + wc->data_device_sectors =i_size_read (wc->dev->bdev->bd_inode) >>SECTOR_SHIFT ; +if (WC_MODE_PMEM (wc)) {persistent_memory_invalidate_cache (wc->memory_map, wc->memory_map_size); }else {
@@ -1488,6 +1491,10 @@ static bool wc_add_block(struct writebacvoid *address =memory_data (wc, e);persistent_memory_flush_cache (address, block_size); + +if (unlikely (bio_end_sector (&wb->bio) >= wc->data_device_sectors)) +return true; +return bio_add_page (&wb->bio,persistent_memory_page (address), block_size,persistent_memory_page_offset (address)) !=0 ; }
@@ -1559,6 +1566,9 @@ static void __writecache_writeback_pmem(if (writecache_has_error (wc)) { bio->bi_status =BLK_STS_IOERR ;bio_endio (bio); + }else if (unlikely (!bio_sectors (bio))) { + bio->bi_status =BLK_STS_OK ; +bio_endio (bio); }else {submit_bio (bio); }
@@ -1602,6 +1612,14 @@ static void __writecache_writeback_ssd(s e = f; } +if (unlikely (to.sector + to.count > wc->data_device_sectors)) { +if (to.sector >= wc->data_device_sectors) { +writecache_copy_endio (0 ,0 , c); +continue ; + } + from.count = to.count = wc->data_device_sectors - to.sector; + } +dm_kcopyd_copy (wc->dm_kcopyd, &from,1 , &to,0 , writecache_copy_endio, c);__writeback_throttle (wc, wbl);
Greg Kroah-Hartman
maintainerPATCH 324/340 dm era: Recover committed writeset after crash
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit de89afc1e40fdfa5f8b666e5d07c43d21a1d3be0 upstream.
Following a system crash, dm-era fails to recover the committed writeset for the current era, leading to lost writes. That is, we lose the information about what blocks were written during the affected era.
dm-era assumes that the writeset of the current era is archived when the device is suspended. So, when resuming the device, it just moves on to the next era, ignoring the committed writeset.
This assumption holds when the device is properly shut down. But, when the system crashes, the code that suspends the target never runs, so the writeset for the current era is not archived.
There are three issues that cause the committed writeset to get lost:
1. dm-era doesn't load the committed writeset when opening the metadata
2. The code that resizes the metadata wipes the information about the committed writeset (assuming it was loaded at step 1)
3. era_preresume() starts a new era, without taking into account that the current era might not have been archived, due to a system crash.
To fix this:
1. Load the committed writeset when opening the metadata
2. Fix the code that resizes the metadata to make sure it doesn't wipe the loaded writeset
3. Fix era_preresume() to check for a loaded writeset and archive it, before starting a new era.
--- drivers/md/dm-era-target.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/md/dm-era-target.c +9 -8
@@ -71,8 +71,6 @@ static size_t bitset_size(unsigned nr_bi*/ static int writeset_alloc (struct writeset *ws,dm_block_t nr_blocks) { - ws->md.nr_bits = nr_blocks; - ws->md.root =INVALID_WRITESET_ROOT ; ws->bits =vzalloc (bitset_size (nr_blocks));if (!ws->bits) {DMERR ("%s: couldn't allocate in memory bitset" , __func__);
@@ -85,12 +83,14 @@ static int writeset_alloc(struct writese/* * Wipes the in-core bitset, and creates a new on disk bitset. */ -static int writeset_init (struct dm_disk_bitset *info,struct writeset *ws) +static int writeset_init (struct dm_disk_bitset *info,struct writeset *ws, +dm_block_t nr_blocks) {int r; -memset (ws->bits,0 ,bitset_size (ws->md.nr_bits)); +memset (ws->bits,0 ,bitset_size (nr_blocks)); + ws->md.nr_bits = nr_blocks; r =setup_on_disk_bitset (info, ws->md.nr_bits, &ws->md.root);if (r) {DMERR ("%s: setup_on_disk_bitset failed" , __func__);
@@ -579,6 +579,7 @@ static int open_metadata(struct era_meta md->nr_blocks =le32_to_cpu (disk->nr_blocks); md->current_era =le32_to_cpu (disk->current_era); +ws_unpack (&disk->current_writeset, &md->current_writeset->md); md->writeset_tree_root =le64_to_cpu (disk->writeset_tree_root); md->era_array_root =le64_to_cpu (disk->era_array_root); md->metadata_snap =le64_to_cpu (disk->metadata_snap);
@@ -870,7 +871,6 @@ static int metadata_era_archive(struct e }ws_pack (&md->current_writeset->md, &value); - md->current_writeset->md.root =INVALID_WRITESET_ROOT ; keys[0 ] = md->current_era;__dm_bless_for_disk (&value);
@@ -882,6 +882,7 @@ static int metadata_era_archive(struct ereturn r; } + md->current_writeset->md.root =INVALID_WRITESET_ROOT ; md->archived_writesets = true;return 0 ;
@@ -898,7 +899,7 @@ static int metadata_new_era(struct era_mint r;struct writeset *new_writeset =next_writeset (md); - r =writeset_init (&md->bitset_info, new_writeset); + r =writeset_init (&md->bitset_info, new_writeset, md->nr_blocks);if (r) {DMERR ("%s: writeset_init failed" , __func__);return r;
@@ -951,7 +952,7 @@ static int metadata_commit(struct era_meint r;struct dm_block *sblock; -if (md->current_writeset->md.root !=SUPERBLOCK_LOCATION ) { +if (md->current_writeset->md.root !=INVALID_WRITESET_ROOT ) { r =dm_bitset_flush (&md->bitset_info, md->current_writeset->md.root, &md->current_writeset->md.root);if (r) {
@@ -1580,7 +1581,7 @@ static int era_preresume(struct dm_targestart_worker (era); - r =in_worker0 (era, metadata_new_era); + r =in_worker0 (era, metadata_era_rollover);if (r) {DMERR ("%s: metadata_era_rollover failed" , __func__);return r;
Greg Kroah-Hartman
maintainerPATCH 325/340 dm era: Verify the data block size hasnt changed
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit c8e846ff93d5eaa5384f6f325a1687ac5921aade upstream.
dm-era doesn't support changing the data block size of existing devices, so check explicitly that the requested block size for a new target matches the one stored in the metadata.
--- drivers/md/dm-era-target.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/md/dm-era-target.c +9 -1
@@ -564,6 +564,15 @@ static int open_metadata(struct era_meta } disk =dm_block_data (sblock); + +/* Verify the data block size hasn't changed */ +if (le32_to_cpu (disk->data_block_size) != md->block_size) { +DMERR ("changing the data block size (from %u to %llu) is not supported" , +le32_to_cpu (disk->data_block_size), md->block_size); + r = -EINVAL ; + goto bad; + } + r = dm_tm_open_with_sm(md->bm, SUPERBLOCK_LOCATION, disk->metadata_space_map_root, sizeof(disk->metadata_space_map_root),
@@ -575,7 +584,6 @@ static int open_metadata(struct era_metasetup_infos (md); - md->block_size =le32_to_cpu (disk->data_block_size); md->nr_blocks =le32_to_cpu (disk->nr_blocks); md->current_era =le32_to_cpu (disk->current_era);
Greg Kroah-Hartman
maintainerPATCH 326/340 dm era: Fix bitset memory leaks
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit 904e6b266619c2da5c58b5dce14ae30629e39645 upstream.
Deallocate the memory allocated for the in-core bitsets when destroying the target and in error paths.
--- drivers/md/dm-era-target.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/md/dm-era-target.c +6 -0
@@ -47,6 +47,7 @@ struct writeset {static void writeset_free (struct writeset *ws) {vfree (ws->bits); + ws->bits =NULL ; } static int setup_on_disk_bitset(struct dm_disk_bitset *info,
@@ -811,6 +812,8 @@ static struct era_metadata *metadata_opestatic void metadata_close (struct era_metadata *md) { +writeset_free (&md->writesets[0 ]); +writeset_free (&md->writesets[1 ]);destroy_persistent_data_objects (md);kfree (md); }
@@ -848,6 +851,7 @@ static int metadata_resize(struct era_me r =writeset_alloc (&md->writesets[1 ], *new_size);if (r) {DMERR ("%s: writeset_alloc failed for writeset 1" , __func__); +writeset_free (&md->writesets[0 ]);return r; }
@@ -858,6 +862,8 @@ static int metadata_resize(struct era_me &value, &md->era_array_root);if (r) {DMERR ("%s: dm_array_resize failed" , __func__); +writeset_free (&md->writesets[0 ]); +writeset_free (&md->writesets[1 ]);return r; }