drm/v3d: don't leak bin job if v3d_job_init fails.
Subsystems (48)
Sasha Levin
maintainerPATCH 26/330 dm table: do not allow request-based DM to stack on partitions
In reply to Sasha LevinFrom: Mike Snitzer <[email protected]>
[ Upstream commit 6ba01df72b4b63a26b4977790f58d8f775d2992c ]
Partitioned request-based devices cannot be used as underlying devices for request-based DM because no partition offsets are added to each incoming request. As such, until now, stacking on partitioned devices would _always_ result in data corruption (e.g. wiping the partition table, writing to other partitions, etc). Fix this by disallowing request-based stacking on partitions.
While at it, since all .request_fn support has been removed from block core, remove legacy dm-table code that differentiated between blk-mq and .request_fn request-based.
--- drivers/md/dm-table.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/md/dm-table.c +8 -19
@@ -918,21 +918,15 @@ bool dm_table_supports_dax(struct dm_table *t,static bool dm_table_does_not_support_partial_completion (struct dm_table *t); -struct verify_rq_based_data { -unsigned sq_count; -unsigned mq_count; -}; - -static int device_is_rq_based (struct dm_target *ti,struct dm_dev *dev, -sector_t start,sector_t len,void *data) +static int device_is_rq_stackable (struct dm_target *ti,struct dm_dev *dev, +sector_t start,sector_t len,void *data) { -struct request_queue *q =bdev_get_queue (dev->bdev); -struct verify_rq_based_data *v = data; +struct block_device *bdev = dev->bdev; +struct request_queue *q =bdev_get_queue (bdev); -if (queue_is_mq (q)) - v->mq_count++; -else - v->sq_count++; +/* request-based cannot stack on partitions! */ +if (bdev != bdev->bd_contains) +return false;return queue_is_mq (q); }
@@ -941,7 +935,6 @@ static int dm_table_determine_type(struct dm_table *t) {unsigned i;unsigned bio_based =0 , request_based =0 , hybrid =0 ; -struct verify_rq_based_data v = {.sq_count =0 , .mq_count =0 };struct dm_target *tgt;struct list_head *devices =dm_table_get_devices (t);enum dm_queue_mode live_md_type =dm_get_md_type (t->md);
@@ -1045,14 +1038,10 @@ verify_rq_based:/* Non-request-stackable devices can't be used for request-based dm */ if (!tgt->type->iterate_devices || - !tgt->type->iterate_devices (tgt, device_is_rq_based, &v)) { + !tgt->type->iterate_devices (tgt, device_is_rq_stackable,NULL )) {DMERR ("table load rejected: including non-request-stackable devices" );return -EINVAL ; } -if (v.sq_count >0 ) { -DMERR ("table load rejected: not all devices are blk-mq request-stackable" ); -return -EINVAL ; - }return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 37/330 ice: Fix to change Rx/Tx ring descriptor size via ethtool with DCBx
In reply to Sasha LevinFrom: Usha Ketineni <[email protected]>
[ Upstream commit c0a3665f71a2f086800abea4d9d14d28269089d6 ]
This patch fixes the call trace caused by the kernel when the Rx/Tx descriptor size change request is initiated via ethtool when DCB is configured. ice_set_ringparam() should use vsi->num_txq instead of vsi->alloc_txq as it represents the queues that are enabled in the driver when DCB is enabled/disabled. Otherwise, queue index being used can go out of range.
For example, when vsi->alloc_txq has 104 queues and with 3 TCS enabled via DCB, each TC gets 34 queues, vsi->num_txq will be 102 and only 102 queues will be enabled.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +7 -7
@@ -2635,14 +2635,14 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)netdev_info (netdev,"Changing Tx descriptor count from %d to %d\n" , vsi->tx_rings[0 ]->count, new_tx_cnt); - tx_rings =devm_kcalloc (&pf->pdev->dev, vsi->alloc_txq, + tx_rings =devm_kcalloc (&pf->pdev->dev, vsi->num_txq,sizeof (*tx_rings),GFP_KERNEL );if (!tx_rings) { err = -ENOMEM ; goto done; } -for (i =0 ; i < vsi->alloc_txq; i++) { +ice_for_each_txq (vsi, i) {/* clone ring and setup updated count */ tx_rings[i] = *vsi->tx_rings[i]; tx_rings[i].count = new_tx_cnt;
@@ -2667,14 +2667,14 @@ process_rx:netdev_info (netdev,"Changing Rx descriptor count from %d to %d\n" , vsi->rx_rings[0 ]->count, new_rx_cnt); - rx_rings =devm_kcalloc (&pf->pdev->dev, vsi->alloc_rxq, + rx_rings =devm_kcalloc (&pf->pdev->dev, vsi->num_rxq,sizeof (*rx_rings),GFP_KERNEL );if (!rx_rings) { err = -ENOMEM ; goto done; } -for (i =0 ; i < vsi->alloc_rxq; i++) { +ice_for_each_rxq (vsi, i) {/* clone ring and setup updated count */ rx_rings[i] = *vsi->rx_rings[i]; rx_rings[i].count = new_rx_cnt;
@@ -2712,7 +2712,7 @@ process_link:ice_down (vsi);if (tx_rings) { -for (i =0 ; i < vsi->alloc_txq; i++) { +ice_for_each_txq (vsi, i) {ice_free_tx_ring (vsi->tx_rings[i]); *vsi->tx_rings[i] = tx_rings[i]; }
@@ -2720,7 +2720,7 @@ process_link: }if (rx_rings) { -for (i =0 ; i < vsi->alloc_rxq; i++) { +ice_for_each_rxq (vsi, i) {ice_free_rx_ring (vsi->rx_rings[i]);/* copy the real tail offset */ rx_rings[i].tail = vsi->rx_rings[i]->tail;
@@ -2744,7 +2744,7 @@ process_link: free_tx:/* error cleanup if the Rx allocations failed after getting Tx */ if (tx_rings) { -for (i =0 ; i < vsi->alloc_txq; i++) +ice_for_each_txq (vsi, i)ice_free_tx_ring (&tx_rings[i]);devm_kfree (&pf->pdev->dev, tx_rings); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 56/330 gfs2: clean up iopen glock mess in gfs2_create_inode
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit 2c47c1be51fbded1f7baa2ceaed90f97932f79be ]
Before this patch, gfs2_create_inode had a use-after-free for the iopen glock in some error paths because it did this:
gfs2_glock_put(io_gl); fail_gunlock2: if (io_gl) clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
In some cases, the io_gl was used for create and only had one reference, so the glock might be freed before the clear_bit(). This patch tries to straighten it out by only jumping to the error paths where iopen is properly set, and moving the gfs2_glock_put after the clear_bit.
--- fs/gfs2/inode.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/gfs2/inode.c +7 -6
@@ -712,7 +712,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, error =gfs2_trans_begin (sdp, blocks,0 );if (error) - goto fail_gunlock2; + goto fail_free_inode;if (blocks >1 ) { ip->i_eattr = ip->i_no_addr +1 ;
@@ -723,7 +723,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_iopen_glops,CREATE , &io_gl);if (error) - goto fail_gunlock2; + goto fail_free_inode;BUG_ON (test_and_set_bit (GLF_INODE_CREATING , &io_gl->gl_flags));
@@ -732,7 +732,6 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, goto fail_gunlock2;glock_set_object (ip->i_iopen_gh.gh_gl, ip); -gfs2_glock_put (io_gl);gfs2_set_iop (inode);insert_inode_hash (inode);
@@ -765,6 +764,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,mark_inode_dirty (inode);d_instantiate (dentry, inode); +/* After instantiate, errors should result in evict which will destroy +* both inode and iopen glocks properly. */ if (file) { file->f_mode |=FMODE_CREATED ; error =finish_open (file, dentry, gfs2_open_common);
@@ -772,15 +773,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,gfs2_glock_dq_uninit (ghs);gfs2_glock_dq_uninit (ghs +1 );clear_bit (GLF_INODE_CREATING , &io_gl->gl_flags); +gfs2_glock_put (io_gl);return error; fail_gunlock3:glock_clear_object (io_gl, ip);gfs2_glock_dq_uninit (&ip->i_iopen_gh); -gfs2_glock_put (io_gl); fail_gunlock2: -if (io_gl) -clear_bit (GLF_INODE_CREATING , &io_gl->gl_flags); +clear_bit (GLF_INODE_CREATING , &io_gl->gl_flags); +gfs2_glock_put (io_gl); fail_free_inode:if (ip->i_gl) {glock_clear_object (ip->i_gl, ip);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 90/330 sctp: move trace_sctp_probe_path into sctp_outq_sack
In reply to Sasha LevinFrom: Kevin Kou <[email protected]>
[ Upstream commit f643ee295c1c63bc117fb052d4da681354d6f732 ]
The original patch bringed in the "SCTP ACK tracking trace event" feature was committed at Dec.20, 2017, it replaced jprobe usage with trace events, and bringed in two trace events, one is TRACE_EVENT(sctp_probe), another one is TRACE_EVENT(sctp_probe_path). The original patch intended to trigger the trace_sctp_probe_path in TRACE_EVENT(sctp_probe) as below code,
+TRACE_EVENT(sctp_probe,
+
+ TP_PROTO(const struct sctp_endpoint *ep,
+ const struct sctp_association *asoc,
+ struct sctp_chunk *chunk),
+
+ TP_ARGS(ep, asoc, chunk),
+
+ TP_STRUCT__entry(
+ __field(__u64, asoc)
+ __field(__u32, mark)
+ __field(__u16, bind_port)
+ __field(__u16, peer_port)
+ __field(__u32, pathmtu)
+ __field(__u32, rwnd)
+ __field(__u16, unack_data)
+ ),
+
+ TP_fast_assign(
+ struct sk_buff *skb = chunk->skb;
+
+ __entry->asoc = (unsigned long)asoc;
+ __entry->mark = skb->mark;
+ __entry->bind_port = ep->base.bind_addr.port;
+ __entry->peer_port = asoc->peer.port;
+ __entry->pathmtu = asoc->pathmtu;
+ __entry->rwnd = asoc->peer.rwnd;
+ __entry->unack_data = asoc->unack_data;
+
+ if (trace_sctp_probe_path_enabled()) {
+ struct sctp_transport *sp;
+
+ list_for_each_entry(sp, &asoc->peer.transport_addr_list,
+ transports) {
+ trace_sctp_probe_path(sp, asoc);
+ }
+ }
+ ),
But I found it did not work when I did testing, and trace_sctp_probe_path had no output, I finally found that there is trace buffer lock operation(trace_event_buffer_reserve) in include/trace/trace_events.h:
static notrace void \
trace_event_raw_event_##call(void *__data, proto) \
{ \
struct trace_event_file *trace_file = __data; \
struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
struct trace_event_buffer fbuffer; \
struct trace_event_raw_##call *entry; \
int __data_size; \
\
if (trace_trigger_soft_disabled(trace_file)) \
return; \
\
__data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
\
entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
sizeof(*entry) + __data_size); \
\
if (!entry) \
return; \
\
tstruct \
\
{ assign; } \
\
trace_event_buffer_commit(&fbuffer); \
}The reason caused no output of trace_sctp_probe_path is that trace_sctp_probe_path written in TP_fast_assign part of TRACE_EVENT(sctp_probe), and it will be placed( { assign; } ) after the trace_event_buffer_reserve() when compiler expands Macro,
entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
sizeof(*entry) + __data_size); \
\
if (!entry) \
return; \
\
tstruct \
\
{ assign; } \so trace_sctp_probe_path finally can not acquire trace_event_buffer and return no output, that is to say the nest of tracepoint entry function is not allowed. The function call flow is:
trace_sctp_probe()
-> trace_event_raw_event_sctp_probe()
-> lock buffer
-> trace_sctp_probe_path()
-> trace_event_raw_event_sctp_probe_path() --nested -> buffer has been locked and return no output.
This patch is to remove trace_sctp_probe_path from the TP_fast_assign part of TRACE_EVENT(sctp_probe) to avoid the nest of entry function, and trigger sctp_probe_path_trace in sctp_outq_sack.
After this patch, you can enable both events individually,
# cd /sys/kernel/debug/tracing # echo 1 > events/sctp/sctp_probe/enable # echo 1 > events/sctp/sctp_probe_path/enable
Or, you can enable all the events under sctp.
# echo 1 > events/sctp/enable
--- include/trace/events/sctp.h | 9 --------- net/sctp/outqueue.c | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-)
include/trace/events/sctp.h +0 -9
@@ -75,15 +75,6 @@ TRACE_EVENT(sctp_probe, __entry->pathmtu = asoc->pathmtu; __entry->rwnd = asoc->peer.rwnd; __entry->unack_data = asoc->unack_data; - -if (trace_sctp_probe_path_enabled ()) { -struct sctp_transport *sp; - -list_for_each_entry (sp, &asoc->peer.transport_addr_list, - transports) { -trace_sctp_probe_path (sp, asoc); - } - } ), TP_printk("asoc=%#llx mark=%#x bind_port=%d peer_port=%d pathmtu=%d "
net/sctp/outqueue.c +6 -0
@@ -36,6 +36,7 @@#include <net/sctp/sctp.h> #include <net/sctp/sm.h> #include <net/sctp/stream_sched.h> +#include <trace/events/sctp.h> /* Declare internal functions here. */ static int sctp_acked (struct sctp_sackhdr *sack,__u32 tsn);
@@ -1238,6 +1239,11 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk)/* Grab the association's destination address list. */ transport_list = &asoc->peer.transport_addr_list; +/* SCTP path tracepoint for congestion control debugging. */ +list_for_each_entry (transport, transport_list, transports) { +trace_sctp_probe_path (transport, asoc); + } + sack_ctsn =ntohl (sack->cum_tsn_ack); gap_ack_blocks =ntohs (sack->num_gap_ack_blocks); asoc->stats.gapcnt += gap_ack_blocks;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 145/330 iavf: use tc_cls_can_offload_and_chain0() instead of chain check
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit bb0858d8bc828ebc3eaa90be02a0f32bca3c2351 ]
Looks like the iavf code actually experienced a race condition, when a developer took code before the check for chain 0 was put to helper. So use tc_cls_can_offload_and_chain0() helper instead of direct check and move the check to _cb() so this is similar to i40e code.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -3
@@ -3077,9 +3077,6 @@ static int iavf_delete_clsflower(struct iavf_adapter *adapter,static int iavf_setup_tc_cls_flower (struct iavf_adapter *adapter,struct flow_cls_offload *cls_flower) { -if (cls_flower->common.chain_index) -return -EOPNOTSUPP ; -switch (cls_flower->command) {case FLOW_CLS_REPLACE :return iavf_configure_clsflower (adapter, cls_flower);
@@ -3103,6 +3100,11 @@ static int iavf_setup_tc_cls_flower(struct iavf_adapter *adapter,static int iavf_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) { +struct iavf_adapter *adapter = cb_priv; + +if (!tc_cls_can_offload_and_chain0 (adapter->netdev, type_data)) +return -EOPNOTSUPP ; +switch (type) {case TC_SETUP_CLSFLOWER :return iavf_setup_tc_cls_flower (cb_priv, type_data);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 180/330 KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones
In reply to Sasha LevinFrom: Gustavo Romero <[email protected]>
[ Upstream commit 1dff3064c764b5a51c367b949b341d2e38972bec ]
On P9 DD2.2 due to a CPU defect some TM instructions need to be emulated by KVM. This is handled at first by the hardware raising a softpatch interrupt when certain TM instructions that need KVM assistance are executed in the guest. Althought some TM instructions per Power ISA are invalid forms they can raise a softpatch interrupt too. For instance, 'tresume.' instruction as defined in the ISA must have bit 31 set (1), but an instruction that matches 'tresume.' PO and XO opcode fields but has bit 31 not set (0), like 0x7cfe9ddc, also raises a softpatch interrupt. Similarly for 'treclaim.' and 'trechkpt.' instructions with bit 31 = 0, i.e. 0x7c00075c and 0x7c0007dc, respectively. Hence, if a code like the following is executed in the guest it will raise a softpatch interrupt just like a 'tresume.' when the TM facility is enabled ('tabort. 0' in the example is used only to enable the TM facility):
int main() { asm("tabort. 0; .long 0x7cfe9ddc;"); }
Currently in such a case KVM throws a complete trace like:
[345523.705984] WARNING: CPU: 24 PID: 64413 at arch/powerpc/kvm/book3s_hv_tm.c:211 kvmhv_p9_tm_emulation+0x68/0x620 [kvm_hv] [345523.705985] Modules linked in: kvm_hv(E) xt_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp ip6table_mangle ip6table_nat
iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bridge stp llc sch_fq_codel ipmi_powernv at24 vmx_crypto ipmi_devintf ipmi_msghandler ibmpowernv uio_pdrv_genirq kvm opal_prd uio leds_powernv ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx libcrc32c xor raid6_pq raid1 raid0 multipath linear tg3 crct10dif_vpmsum crc32c_vpmsum ipr [last unloaded: kvm_hv]
[345523.706030] CPU: 24 PID: 64413 Comm: CPU 0/KVM Tainted: G W E 5.5.0+ #1
[345523.706031] NIP: c0080000072cb9c0 LR: c0080000072b5e80 CTR: c0080000085c7850
[345523.706034] REGS: c000000399467680 TRAP: 0700 Tainted: G W E (5.5.0+)
[345523.706034] MSR: 900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]> CR: 24022428 XER: 00000000
[345523.706042] CFAR: c0080000072b5e7c IRQMASK: 0
GPR00: c0080000072b5e80 c000000399467910 c0080000072db500 c000000375ccc720
GPR04: c000000375ccc720 00000003fbec0000 0000a10395dda5a6 0000000000000000
GPR08: 000000007cfe9ddc 7cfe9ddc000005dc 7cfe9ddc7c0005dc c0080000072cd530
GPR12: c0080000085c7850 c0000003fffeb800 0000000000000001 00007dfb737f0000
GPR16: c0002001edcca558 0000000000000000 0000000000000000 0000000000000001
GPR20: c000000001b21258 c0002001edcca558 0000000000000018 0000000000000000
GPR24: 0000000001000000 ffffffffffffffff 0000000000000001 0000000000001500
GPR28: c0002001edcc4278 c00000037dd80000 800000050280f033 c000000375ccc720
[345523.706062] NIP [c0080000072cb9c0] kvmhv_p9_tm_emulation+0x68/0x620 [kvm_hv]
[345523.706065] LR [c0080000072b5e80] kvmppc_handle_exit_hv.isra.53+0x3e8/0x798 [kvm_hv]
[345523.706066] Call Trace:
[345523.706069] [c000000399467910] [c000000399467940] 0xc000000399467940 (unreliable)
[345523.706071] [c000000399467950] [c000000399467980] 0xc000000399467980
[345523.706075] [c0000003994679f0] [c0080000072bd1c4] kvmhv_run_single_vcpu+0xa1c/0xb80 [kvm_hv]
[345523.706079] [c000000399467ac0] [c0080000072bd8e0] kvmppc_vcpu_run_hv+0x5b8/0xb00 [kvm_hv]
[345523.706087] [c000000399467b90] [c0080000085c93cc] kvmppc_vcpu_run+0x34/0x48 [kvm]
[345523.706095] [c000000399467bb0] [c0080000085c582c] kvm_arch_vcpu_ioctl_run+0x244/0x420 [kvm]
[345523.706101] [c000000399467c40] [c0080000085b7498] kvm_vcpu_ioctl+0x3d0/0x7b0 [kvm]
[345523.706105] [c000000399467db0] [c0000000004adf9c] ksys_ioctl+0x13c/0x170
[345523.706107] [c000000399467e00] [c0000000004adff8] sys_ioctl+0x28/0x80
[345523.706111] [c000000399467e20] [c00000000000b278] system_call+0x5c/0x68
[345523.706112] Instruction dump:
[345523.706114] 419e0390 7f8a4840 409d0048 6d497c00 2f89075d 419e021c 6d497c00 2f8907dd
[345523.706119] 419e01c0 6d497c00 2f8905dd 419e00a4 <0fe00000> 38210040 38600000 ebc1fff0and then treats the executed instruction as a 'nop'.
However the POWER9 User's Manual, in section "4.6.10 Book II Invalid Forms", informs that for TM instructions bit 31 is in fact ignored, thus for the TM-related invalid forms ignoring bit 31 and handling them like the valid forms is an acceptable way to handle them. POWER8 behaves the same way too.
This commit changes the handling of the cases here described by treating the TM-related invalid forms that can generate a softpatch interrupt just like their valid forms (w/ bit 31 = 1) instead of as a 'nop' and by gently reporting any other unrecognized case to the host and treating it as illegal instruction instead of throwing a trace and treating it as a 'nop'.
--- arch/powerpc/include/asm/kvm_asm.h | 3 +++ arch/powerpc/kvm/book3s_hv_tm.c | 28 ++++++++++++++++++++----- arch/powerpc/kvm/book3s_hv_tm_builtin.c | 16 ++++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/kvm_asm.h +3 -0
@@ -150,4 +150,7 @@#define KVM_INST_FETCH_FAILED -1 +/* Extract PO and XOP opcode fields */ +#define PO_XOP_OPCODE_MASK 0xfc0007fe +#endif /* __POWERPC_KVM_ASM_H__ */
arch/powerpc/kvm/book3s_hv_tm.c +23 -5
@@ -3,6 +3,8 @@* Copyright 2017 Paul Mackerras, IBM Corp. <[email protected]> */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/kvm_host.h> #include <asm/kvm_ppc.h>
@@ -44,7 +46,18 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)u64 newmsr, bescr;int ra, rs; -switch (instr &0xfc0007ff ) { +/* +* rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit +* in these instructions, so masking bit 31 out doesn't change these +* instructions. For treclaim., tsr., and trechkpt. instructions if bit +* 31 = 0 then they are per ISA invalid forms, however P9 UM, in section +* 4.6.10 Book II Invalid Forms, informs specifically that ignoring bit +* 31 is an acceptable way to handle these invalid forms that have +* bit 31 = 0. Moreover, for emulation purposes both forms (w/ and wo/ +* bit 31 set) can generate a softpatch interrupt. Hence both forms +* are handled below for these instructions so they behave the same way. +*/ +switch (instr &PO_XOP_OPCODE_MASK ) {case PPC_INST_RFID :/* XXX do we need to check for PR=0 here? */ newmsr = vcpu->arch.shregs.srr1;
@@ -105,7 +118,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = newmsr;return RESUME_GUEST ; -case PPC_INST_TSR : +/* ignore bit 31, see comment above */ +case (PPC_INST_TSR &PO_XOP_OPCODE_MASK ):/* check for PR=1 and arch 2.06 bit set in PCR */ if ((msr &MSR_PR ) && (vcpu->arch.vcore->pcr &PCR_ARCH_206 )) {/* generate an illegal instruction interrupt */
@@ -140,7 +154,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = msr;return RESUME_GUEST ; -case PPC_INST_TRECLAIM : +/* ignore bit 31, see comment above */ +case (PPC_INST_TRECLAIM &PO_XOP_OPCODE_MASK ):/* check for TM disabled in the HFSCR or MSR */ if (!(vcpu->arch.hfscr &HFSCR_TM )) {/* generate an illegal instruction interrupt */
@@ -176,7 +191,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr &= ~MSR_TS_MASK ;return RESUME_GUEST ; -case PPC_INST_TRECHKPT : +/* ignore bit 31, see comment above */ +case (PPC_INST_TRECHKPT &PO_XOP_OPCODE_MASK ):/* XXX do we need to check for PR=0 here? */ /* check for TM disabled in the HFSCR or MSR */ if (!(vcpu->arch.hfscr &HFSCR_TM )) {
@@ -208,6 +224,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) }/* What should we do here? We didn't recognize the instruction */ -WARN_ON_ONCE (1 ); +kvmppc_core_queue_program (vcpu,SRR1_PROGILL ); +pr_warn_ratelimited ("Unrecognized TM-related instruction %#x for emulation" , instr); +return RESUME_GUEST ; }
arch/powerpc/kvm/book3s_hv_tm_builtin.c +14 -2
@@ -23,7 +23,18 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu)u64 newmsr, msr, bescr;int rs; -switch (instr &0xfc0007ff ) { +/* +* rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit +* in these instructions, so masking bit 31 out doesn't change these +* instructions. For the tsr. instruction if bit 31 = 0 then it is per +* ISA an invalid form, however P9 UM, in section 4.6.10 Book II Invalid +* Forms, informs specifically that ignoring bit 31 is an acceptable way +* to handle TM-related invalid forms that have bit 31 = 0. Moreover, +* for emulation purposes both forms (w/ and wo/ bit 31 set) can +* generate a softpatch interrupt. Hence both forms are handled below +* for tsr. to make them behave the same way. +*/ +switch (instr &PO_XOP_OPCODE_MASK ) {case PPC_INST_RFID :/* XXX do we need to check for PR=0 here? */ newmsr = vcpu->arch.shregs.srr1;
@@ -73,7 +84,8 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = newmsr;return 1 ; -case PPC_INST_TSR : +/* ignore bit 31, see comment above */ +case (PPC_INST_TSR &PO_XOP_OPCODE_MASK ):/* we know the MSR has the TS field = S (0b01) here */ msr = vcpu->arch.shregs.msr;/* check for PR=1 and arch 2.06 bit set in PCR */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 193/330 perf cpumap: Fix snprintf overflow check
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d74b181a028bb5a468f0c609553eff6a8fdf4887 ]
'snprintf' returns the number of characters which would be generated for the given input.
If the returned value is *greater than* or equal to the buffer size, it means that the output has been truncated.
Fix the overflow test accordingly.
--- tools/perf/util/cpumap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/cpumap.c +5 -5
@@ -299,7 +299,7 @@ static void set_max_cpu_num(void)/* get the highest possible cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/cpu/possible" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -310,7 +310,7 @@ static void set_max_cpu_num(void)/* get the highest present cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/cpu/present" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -338,7 +338,7 @@ static void set_max_node_num(void)/* get the highest possible cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/node/possible" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -423,7 +423,7 @@ int cpu__setup_cpunode_map(void)return 0 ; n =snprintf (path,PATH_MAX ,"%s/devices/system/node" , mnt); -if (n =PATH_MAX ) { +if (n >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX );return -1 ; }
@@ -438,7 +438,7 @@ int cpu__setup_cpunode_map(void)continue ; n =snprintf (buf,PATH_MAX ,"%s/%s" , path, dent1->d_name); -if (n =PATH_MAX ) { +if (n >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX );continue ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 280/330 e1000: Do not perform reset in reset_task if we are already down
In reply to Sasha LevinFrom: Alexander Duyck <[email protected]>
[ Upstream commit 49ee3c2ab5234757bfb56a0b3a3cb422f427e3a3 ]
We are seeing a deadlock in e1000 down when NAPI is being disabled. Looking over the kernel function trace of the system it appears that the interface is being closed and then a reset is hitting which deadlocks the interface as the NAPI interface is already disabled.
To prevent this from happening I am disabling the reset task when __E1000_DOWN is already set. In addition code has been added so that we set the __E1000_DOWN while holding the __E1000_RESET flag in e1000_close in order to guarantee that the reset task will not run after we have started the close call.
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +14 -4
@@ -542,8 +542,13 @@ void e1000_reinit_locked(struct e1000_adapter *adapter)WARN_ON (in_interrupt ());while (test_and_set_bit (__E1000_RESETTING, &adapter->flags))msleep (1 ); -e1000_down (adapter); -e1000_up (adapter); + +/* only run the task if not already down */ +if (!test_bit (__E1000_DOWN, &adapter->flags)) { +e1000_down (adapter); +e1000_up (adapter); + } +clear_bit (__E1000_RESETTING, &adapter->flags); }
@@ -1433,10 +1438,15 @@ int e1000_close(struct net_device *netdev)struct e1000_hw *hw = &adapter->hw;int count =E1000_CHECK_RESET_COUNT ; -while (test_bit (__E1000_RESETTING, &adapter->flags) && count--) +while (test_and_set_bit (__E1000_RESETTING, &adapter->flags) && count--)usleep_range (10000 ,20000 ); -WARN_ON (test_bit (__E1000_RESETTING, &adapter->flags)); +WARN_ON (count <0 ); + +/* signal that we're down so that the reset task will no longer run */ +set_bit (__E1000_DOWN, &adapter->flags); +clear_bit (__E1000_RESETTING, &adapter->flags); +e1000_down (adapter);e1000_power_down_phy (adapter);e1000_free_irq (adapter);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 290/330 KVM: PPC: Book3S HV: Close race with page faults around memslot flushes
In reply to Sasha LevinFrom: Paul Mackerras <[email protected]>
[ Upstream commit 11362b1befeadaae4d159a8cddcdaf6b8afe08f9 ]
There is a potential race condition between hypervisor page faults and flushing a memslot. It is possible for a page fault to read the memslot before a memslot is updated and then write a PTE to the partition-scoped page tables after kvmppc_radix_flush_memslot has completed. (Note that this race has never been explicitly observed.)
To close this race, it is sufficient to increment the MMU sequence number while the kvm->mmu_lock is held. That will cause mmu_notifier_retry() to return true, and the page fault will then return to the guest without inserting a PTE.
--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/kvm/book3s_64_mmu_radix.c +5 -0
@@ -1104,6 +1104,11 @@ void kvmppc_radix_flush_memslot(struct kvm *kvm, kvm->arch.lpid); gpa +=PAGE_SIZE ; } +/* +* Increase the mmu notifier sequence number to prevent any page +* fault that read the memslot earlier from writing a PTE. +*/ + kvm->mmu_notifier_seq++;spin_unlock (&kvm->mmu_lock); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 307/330 mm: memcontrol: fix stat-corrupting race in charge moving
In reply to Sasha LevinFrom: Johannes Weiner <[email protected]>
[ Upstream commit abb242f57196dbaa108271575353a0453f6834ef ]
The move_lock is a per-memcg lock, but the VM accounting code that needs to acquire it comes from the page and follows page->mem_cgroup under RCU protection. That means that the page becomes unlocked not when we drop the move_lock, but when we update page->mem_cgroup. And that assignment doesn't imply any memory ordering. If that pointer write gets reordered against the reads of the page state - page_mapped, PageDirty etc. the state may change while we rely on it being stable and we can end up corrupting the counters.
Place an SMP memory barrier to make sure we're done with all page state by the time the new page->mem_cgroup becomes visible.
Also replace the open-coded move_lock with a lock_page_memcg() to make it more obvious what we're serializing against.
--- mm/memcontrol.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
mm/memcontrol.c +14 -12
@@ -5489,7 +5489,6 @@ static int mem_cgroup_move_account(struct page *page, {struct lruvec *from_vec, *to_vec;struct pglist_data *pgdat; -unsigned long flags;unsigned int nr_pages = compound ?hpage_nr_pages (page) :1 ;int ret;bool anon;
@@ -5516,18 +5515,13 @@ static int mem_cgroup_move_account(struct page *page, from_vec =mem_cgroup_lruvec (pgdat, from); to_vec =mem_cgroup_lruvec (pgdat, to); -spin_lock_irqsave (&from->move_lock, flags); +lock_page_memcg (page);if (!anon &&page_mapped (page)) {__mod_lruvec_state (from_vec,NR_FILE_MAPPED , -nr_pages);__mod_lruvec_state (to_vec,NR_FILE_MAPPED , nr_pages); } -/* -* move_lock grabbed above and caller set from->moving_account, so -* mod_memcg_page_state will serialize updates to PageDirty. -* So mapping should be stable for dirty pages. -*/ if (!anon &&PageDirty (page)) {struct address_space *mapping =page_mapping (page);
@@ -5543,15 +5537,23 @@ static int mem_cgroup_move_account(struct page *page, }/* +* All state has been migrated, let's switch to the new memcg. +* * It is safe to change page->mem_cgroup here because the page -* is referenced, charged, and isolated - we can't race with -* uncharging, charging, migration, or LRU putback. +* is referenced, charged, isolated, and locked: we can't race +* with (un)charging, migration, LRU putback, or anything else +* that would rely on a stable page->mem_cgroup. +* +* Note that lock_page_memcg is a memcg lock, not a page lock, +* to save space. As soon as we switch page->mem_cgroup to a +* new memcg that isn't locked, the above state can change +* concurrently again. Make sure we're truly done with it. */ +smp_mb (); -/* caller should have done css_get */ - page->mem_cgroup = to; + page->mem_cgroup = to;/* caller should have done css_get */ -spin_unlock_irqrestore (&from->move_lock, flags); +__unlock_page_memcg (from); ret =0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 1/330 drm/v3d: don't leak bin job if v3d_job_init fails.
From: Iago Toral Quiroga <[email protected]>
[ Upstream commit 0d352a3a8a1f26168d09f7073e61bb4b328e3bb9 ]
If the initialization of the job fails we need to kfree() it before returning.
--- drivers/gpu/drm/v3d/v3d_gem.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/v3d/v3d_gem.c +1 -0
@@ -565,6 +565,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, ret =v3d_job_init (v3d, file_priv, &bin->base, v3d_job_free, args->in_sync_bcl);if (ret) { +kfree (bin);v3d_job_put (&render->base);kfree (bin);return ret;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 2/330 kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec()
From: Iurii Zaikin <[email protected]>
[ Upstream commit 2cb80dbbbaba4f2f86f686c34cb79ea5cbfb0edb ]
KUnit tests for initialized data behavior of proc_dointvec that is explicitly checked in the code. Includes basic parsing tests including int min/max overflow.
--- kernel/Makefile | 2 + kernel/sysctl-test.c | 392 +++++++++++++++++++++++++++++++++++++++++++ lib/Kconfig.debug | 11 ++ 3 files changed, 405 insertions(+) create mode 100644 kernel/sysctl-test.c
kernel/Makefile +2 -0
@@ -115,6 +115,8 @@ obj-$(CONFIG_TORTURE_TEST) += torture.o obj-$(CONFIG_HAS_IOMEM) += iomem.o obj-$(CONFIG_RSEQ) += rseq.o +obj-$(CONFIG_SYSCTL_KUNIT_TEST) += sysctl-test.o + obj-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak.o KASAN_SANITIZE_stackleak.o := n KCOV_INSTRUMENT_stackleak.o := n
kernel/sysctl-test.c new file +392 -0
392 lines not on this page · raw message
lib/Kconfig.debug +11 -0
@@ -1939,6 +1939,17 @@ config TEST_SYSCTL If unsure, say N. +config SYSCTL_KUNIT_TEST + bool "KUnit test for sysctl" + depends on KUNIT + help + This builds the proc sysctl unit test, which runs on boot. + Tests the API contract and implementation correctness of sysctl. + For more information on KUnit and unit tests in general please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config TEST_UDELAY tristate "udelay test driver" help
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 7/330 drm/amd/display: Do not double-buffer DTO adjustments
In reply to Sasha LevinFrom: Wesley Chalmers <[email protected]>
[ Upstream commit 6bd0a112ec129615d23aa5d8d3dd0be0243989aa ]
[WHY]
When changing DPP global ref clock, DTO adjustments must take effect immediately, or else underflow may occur.
It appears the original decision to double-buffer DTO adjustments was made to prevent underflows that occur when raising DPP ref clock (which is not double-buffered), but that same decision causes similar issues when lowering DPP global ref clock. The better solution is to order the adjustments according to whether clocks are being raised or lowered.
--- .../gpu/drm/amd/display/dc/dcn20/dcn20_dccg.c | 26 ------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.c +0 -26
@@ -119,32 +119,6 @@ void dccg2_get_dccg_ref_freq(struct dccg *dccg,void dccg2_init (struct dccg *dccg) { -struct dcn_dccg *dccg_dcn =TO_DCN_DCCG (dccg); - -// Fallthrough intentional to program all available dpp_dto's -switch (dccg_dcn->base.ctx->dc->res_pool->pipe_count) { -case 6 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [5 ],1 ); -/* Fall through */ -case 5 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [4 ],1 ); -/* Fall through */ -case 4 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [3 ],1 ); -/* Fall through */ -case 3 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [2 ],1 ); -/* Fall through */ -case 2 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [1 ],1 ); -/* Fall through */ -case 1 : -REG_UPDATE (DPPCLK_DTO_CTRL ,DPPCLK_DTO_DB_EN [0 ],1 ); -break ; -default : -ASSERT (false); -break ; - } }static const struct dccg_funcs dccg2_funcs = {
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 8/330 drm/amdkfd: Fix race in gfx10 context restore handler
In reply to Sasha LevinFrom: Jay Cornwall <[email protected]>
[ Upstream commit c18cc2bb9e064d3a613d8276f2cab3984926a779 ]
Missing synchronization with VGPR restore leads to intermittent VGPR trashing in the user shader.
--- .../gpu/drm/amd/amdkfd/cwsr_trap_handler.h | 139 +++++++++--------- .../amd/amdkfd/cwsr_trap_handler_gfx10.asm | 1 + 2 files changed, 71 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h +70 -69
@@ -905,7 +905,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {0x7a5d0000 ,0x807c817c ,0x807aff7a ,0x00000080 ,0xbf0a717c ,0xbf85fff8 , -0xbf820141 ,0xbef4037e , +0xbf820142 ,0xbef4037e ,0x8775ff7f ,0x0000ffff ,0x8875ff75 ,0x00040000 , 0xbef60380, 0xbef703ff,
@@ -967,7 +967,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {0x725d0000 ,0xe0304080 ,0x725d0100 ,0xe0304100 ,0x725d0200 ,0xe0304180 , -0x725d0300 ,0xbf820031 , +0x725d0300 ,0xbf820032 ,0xbef603ff ,0x01000000 ,0xbef20378 ,0x8078ff78 , 0x00000400, 0xbefc0384,
@@ -992,83 +992,84 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {0x725d0000 ,0xe0304100 ,0x725d0100 ,0xe0304200 ,0x725d0200 ,0xe0304300 , -0x725d0300 ,0xb9782a05 , -0x80788178 ,0x907c9973 , -0x877c817c ,0xbf06817c , -0xbf850002 ,0x8f788978 , -0xbf820001 ,0x8f788a78 , -0xb9721e06 ,0x8f728a72 , -0x80787278 ,0x8078ff78 , -0x00000200 ,0x80f8ff78 , -0x00000050 ,0xbef603ff , -0x01000000 ,0xbefc03ff , -0x0000006c ,0x80f89078 , -0xf429003a ,0xf0000000 , -0xbf8cc07f ,0x80fc847c , -0xbf800000 ,0xbe803100 , -0xbe823102 ,0x80f8a078 , -0xf42d003a ,0xf0000000 , -0xbf8cc07f ,0x80fc887c , -0xbf800000 ,0xbe803100 , -0xbe823102 ,0xbe843104 , -0xbe863106 ,0x80f8c078 , -0xf431003a ,0xf0000000 , -0xbf8cc07f ,0x80fc907c , -0xbf800000 ,0xbe803100 , -0xbe823102 ,0xbe843104 , -0xbe863106 ,0xbe883108 , -0xbe8a310a ,0xbe8c310c , -0xbe8e310e ,0xbf06807c , -0xbf84fff0 ,0xb9782a05 , -0x80788178 ,0x907c9973 , -0x877c817c ,0xbf06817c , -0xbf850002 ,0x8f788978 , -0xbf820001 ,0x8f788a78 , -0xb9721e06 ,0x8f728a72 , -0x80787278 ,0x8078ff78 , -0x00000200 ,0xbef603ff , -0x01000000 ,0xf4211bfa , +0x725d0300 ,0xbf8c3f70 , +0xb9782a05 ,0x80788178 , +0x907c9973 ,0x877c817c , +0xbf06817c ,0xbf850002 , +0x8f788978 ,0xbf820001 , +0x8f788a78 ,0xb9721e06 , +0x8f728a72 ,0x80787278 , +0x8078ff78 ,0x00000200 , +0x80f8ff78 ,0x00000050 , +0xbef603ff ,0x01000000 , +0xbefc03ff ,0x0000006c , +0x80f89078 ,0xf429003a , +0xf0000000 ,0xbf8cc07f , +0x80fc847c ,0xbf800000 , +0xbe803100 ,0xbe823102 , +0x80f8a078 ,0xf42d003a , +0xf0000000 ,0xbf8cc07f , +0x80fc887c ,0xbf800000 , +0xbe803100 ,0xbe823102 , +0xbe843104 ,0xbe863106 , +0x80f8c078 ,0xf431003a , +0xf0000000 ,0xbf8cc07f , +0x80fc907c ,0xbf800000 , +0xbe803100 ,0xbe823102 , +0xbe843104 ,0xbe863106 , +0xbe883108 ,0xbe8a310a , +0xbe8c310c ,0xbe8e310e , +0xbf06807c ,0xbf84fff0 , +0xb9782a05 ,0x80788178 , +0x907c9973 ,0x877c817c , +0xbf06817c ,0xbf850002 , +0x8f788978 ,0xbf820001 , +0x8f788a78 ,0xb9721e06 , +0x8f728a72 ,0x80787278 , +0x8078ff78 ,0x00000200 , +0xbef603ff ,0x01000000 , +0xf4211bfa ,0xf0000000 , +0x80788478 ,0xf4211b3a ,0xf0000000 ,0x80788478 , -0xf4211b3a ,0xf0000000 , -0x80788478 ,0xf4211b7a , +0xf4211b7a ,0xf0000000 , +0x80788478 ,0xf4211eba ,0xf0000000 ,0x80788478 , -0xf4211eba ,0xf0000000 , -0x80788478 ,0xf4211efa , +0xf4211efa ,0xf0000000 , +0x80788478 ,0xf4211c3a ,0xf0000000 ,0x80788478 , -0xf4211c3a ,0xf0000000 , -0x80788478 ,0xf4211c7a , +0xf4211c7a ,0xf0000000 , +0x80788478 ,0xf4211e7a ,0xf0000000 ,0x80788478 , -0xf4211e7a ,0xf0000000 , -0x80788478 ,0xf4211cfa , +0xf4211cfa ,0xf0000000 , +0x80788478 ,0xf4211bba ,0xf0000000 ,0x80788478 , +0xbf8cc07f ,0xb9eef814 ,0xf4211bba ,0xf0000000 ,0x80788478 ,0xbf8cc07f , -0xb9eef814 ,0xf4211bba , -0xf0000000 ,0x80788478 , -0xbf8cc07f ,0xb9eef815 , -0xbef2036d ,0x876dff72 , -0x0000ffff ,0xbefc036f , -0xbefe037a ,0xbeff037b , -0x876f71ff ,0x000003ff , -0xb9ef4803 ,0xb9f9f816 , -0x876f71ff ,0xfffff800 , -0x906f8b6f ,0xb9efa2c3 , -0xb9f3f801 ,0x876fff72 , -0xfc000000 ,0x906f9a6f , -0x8f6f906f ,0xbef30380 , +0xb9eef815 ,0xbef2036d , +0x876dff72 ,0x0000ffff , +0xbefc036f ,0xbefe037a , +0xbeff037b ,0x876f71ff , +0x000003ff ,0xb9ef4803 , +0xb9f9f816 ,0x876f71ff , +0xfffff800 ,0x906f8b6f , +0xb9efa2c3 ,0xb9f3f801 , +0x876fff72 ,0xfc000000 , +0x906f9a6f ,0x8f6f906f , +0xbef30380 ,0x88736f73 , +0x876fff72 ,0x02000000 , +0x906f996f ,0x8f6f8f6f ,0x88736f73 ,0x876fff72 , -0x02000000 ,0x906f996f , -0x8f6f8f6f ,0x88736f73 , -0x876fff72 ,0x01000000 , -0x906f986f ,0x8f6f996f , -0x88736f73 ,0x876fff70 , -0x00800000 ,0x906f976f , -0xb9f3f807 ,0x87fe7e7e , -0x87ea6a6a ,0xb9f0f802 , -0xbf8a0000 ,0xbe80226c , -0xbf810000 ,0xbf9f0000 , +0x01000000 ,0x906f986f , +0x8f6f996f ,0x88736f73 , +0x876fff70 ,0x00800000 , +0x906f976f ,0xb9f3f807 , +0x87fe7e7e ,0x87ea6a6a , +0xb9f0f802 ,0xbf8a0000 , +0xbe80226c ,0xbf810000 ,0xbf9f0000 ,0xbf9f0000 ,0xbf9f0000 ,0xbf9f0000 , + 0xbf9f0000, 0x00000000, };static const uint32_t cwsr_trap_arcturus_hex[] = { 0xbf820001, 0xbf8202c4,
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm +1 -0
@@ -758,6 +758,7 @@ L_RESTORE_V0: buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256 buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*2 buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*3 + s_waitcnt vmcnt(0) /* restore SGPRs */ //will be 2+8+16*6
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 11/330 ath10k: fix array out-of-bounds access
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit c5329b2d5b8b4e41be14d31ee8505b4f5607bf9b ]
If firmware reports rate_max > WMI_TPC_RATE_MAX(WMI_TPC_FINAL_RATE_MAX) or num_tx_chain > WMI_TPC_TX_N_CHAIN, it will cause array out-of-bounds access, so print a warning and reset to avoid memory corruption.
Tested HW: QCA9984
Tested FW: 10.4-3.9.0.2-00035
--- drivers/net/wireless/ath/ath10k/debug.c | 2 +- drivers/net/wireless/ath/ath10k/wmi.c | 49 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath10k/debug.c +1 -1
@@ -1516,7 +1516,7 @@ static void ath10k_tpc_stats_print(struct ath10k_tpc_stats *tpc_stats, *len +=scnprintf (buf + *len, buf_len - *len,"No. Preamble Rate_code " ); -for (i =0 ; i <WMI_TPC_TX_N_CHAIN ; i++) +for (i =0 ; i < tpc_stats->num_tx_chain; i++) *len +=scnprintf (buf + *len, buf_len - *len,"tpc_value%d " , i);
drivers/net/wireless/ath/ath10k/wmi.c +31 -18
111 lines not on this page · raw message
Signature · 7 lines
2.25.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 9/330 dma-fence: Serialise signal enabling (dma_fence_enable_sw_signaling)
In reply to Sasha LevinFrom: Chris Wilson <[email protected]>
[ Upstream commit 9c98f021e4e717ffd9948fa65340ea3ef12b7935 ]
Make dma_fence_enable_sw_signaling() behave like its dma_fence_add_callback() and dma_fence_default_wait() counterparts and perform the test to enable signaling under the fence->lock, along with the action to do so. This ensure that should an implementation be trying to flush the cb_list (by signaling) on retirement before freeing the fence, it can do so in a race-free manner.
See also 0fc89b6802ba ("dma-fence: Simply wrap dma_fence_signal_locked with dma_fence_signal").
v2: Refactor all 3 enable_signaling paths to use a common function.
v3: Don't argue, just keep the tracepoint in the existing spot.
--- drivers/dma-buf/dma-fence.c | 78 +++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 43 deletions(-)
drivers/dma-buf/dma-fence.c +35 -43
@@ -273,6 +273,30 @@ void dma_fence_free(struct dma_fence *fence) }EXPORT_SYMBOL (dma_fence_free); +static bool __dma_fence_enable_signaling (struct dma_fence *fence) +{ +bool was_set; + +lockdep_assert_held (fence->lock); + + was_set =test_and_set_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , + &fence->flags); + +if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags)) +return false; + +if (!was_set && fence->ops->enable_signaling) { +trace_dma_fence_enable_signal (fence); + +if (!fence->ops->enable_signaling (fence)) { +dma_fence_signal_locked (fence); +return false; + } + } + +return true; +} +/** * dma_fence_enable_sw_signaling - enable signaling on fence * @fence: the fence to enable
@@ -285,19 +309,12 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence) {unsigned long flags; -if (!test_and_set_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , - &fence->flags) && - !test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags) && - fence->ops->enable_signaling) { -trace_dma_fence_enable_signal (fence); - -spin_lock_irqsave (fence->lock, flags); - -if (!fence->ops->enable_signaling (fence)) -dma_fence_signal_locked (fence); +if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags)) +return ; -spin_unlock_irqrestore (fence->lock, flags); - } +spin_lock_irqsave (fence->lock, flags); +__dma_fence_enable_signaling (fence); +spin_unlock_irqrestore (fence->lock, flags); }EXPORT_SYMBOL (dma_fence_enable_sw_signaling);
@@ -331,7 +348,6 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, {unsigned long flags;int ret =0 ; -bool was_set;if (WARN_ON (!fence || !func))return -EINVAL ;
@@ -343,25 +359,14 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,spin_lock_irqsave (fence->lock, flags); - was_set =test_and_set_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , - &fence->flags); - -if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags)) - ret = -ENOENT ; -else if (!was_set && fence->ops->enable_signaling) { -trace_dma_fence_enable_signal (fence); - -if (!fence->ops->enable_signaling (fence)) { -dma_fence_signal_locked (fence); - ret = -ENOENT ; - } - } - -if (!ret) { +if (__dma_fence_enable_signaling (fence)) { cb->func = func;list_add_tail (&cb->node, &fence->cb_list); - }else + }else {INIT_LIST_HEAD (&cb->node); + ret = -ENOENT ; + } +spin_unlock_irqrestore (fence->lock, flags);return ret;
@@ -461,7 +466,6 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)struct default_wait_cb cb;unsigned long flags;signed long ret = timeout ? timeout :1 ; -bool was_set;if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags))return ret;
@@ -473,21 +477,9 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) goto out; } - was_set =test_and_set_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , - &fence->flags); - -if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags)) +if (!__dma_fence_enable_signaling (fence)) goto out; -if (!was_set && fence->ops->enable_signaling) { -trace_dma_fence_enable_signal (fence); - -if (!fence->ops->enable_signaling (fence)) { -dma_fence_signal_locked (fence); - goto out; - } - } -if (!timeout) { ret =0 ; goto out;
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 12/330 ath10k: fix memory leak for tpc_stats_final
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit 486a8849843455298d49e694cca9968336ce2327 ]
The memory of ar->debug.tpc_stats_final is reallocated every debugfs reading, it should be freed in ath10k_debug_destroy() for the last allocation.
Tested HW: QCA9984
Tested FW: 10.4-3.9.0.2-00035
--- drivers/net/wireless/ath/ath10k/debug.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath10k/debug.c +1 -0
@@ -2532,6 +2532,7 @@ void ath10k_debug_destroy(struct ath10k *ar)ath10k_debug_fw_stats_reset (ar);kfree (ar->debug.tpc_stats); +kfree (ar->debug.tpc_stats_final); }int ath10k_debug_register (struct ath10k *ar)
Signature · 7 lines
2.25.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 4/330 scsi: mpt3sas: Free diag buffer without any status check
In reply to Sasha LevinFrom: Sreekanth Reddy <[email protected]>
[ Upstream commit 764f472ba4a7a0c18107ebfbe1a9f1f5f5a1e411 ]
Memory leak can happen when diag buffer is released but not unregistered (where buffer is deallocated) by the user. During module unload time driver is not deallocating the buffer if the buffer is in released state.
Deallocate the diag buffer during module unload time without any diag buffer status checks.
--- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_ctl.c +0 -6
@@ -3717,12 +3717,6 @@ mpt3sas_ctl_exit(ushort hbas_to_enumerate)for (i =0 ; i <MPI2_DIAG_BUF_TYPE_COUNT ; i++) {if (!ioc->diag_buffer[i])continue ; -if (!(ioc->diag_buffer_status[i] & -MPT3_DIAG_BUFFER_IS_REGISTERED )) -continue ; -if ((ioc->diag_buffer_status[i] & -MPT3_DIAG_BUFFER_IS_RELEASED )) -continue ; dma_free_coherent(&ioc->pdev->dev, ioc->diag_buffer_sz[i], ioc->diag_buffer[i],
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 10/330 scsi: qla2xxx: Add error handling for PLOGI ELS passthrough
In reply to Sasha LevinFrom: Quinn Tran <[email protected]>
[ Upstream commit c76ae845ea836d6128982dcbd41ac35c81e2de63 ]
Add error handling logic to ELS Passthrough relating to NVME devices. Current code does not parse error code to take proper recovery action, instead it re-logins with the same login parameters that encountered the error. Ex: nport handle collision.
--- drivers/scsi/qla2xxx/qla_iocb.c | 95 +++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +92 -3
@@ -2749,6 +2749,10 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)struct scsi_qla_host *vha = sp->vha;struct event_arg ea;struct qla_work_evt *e; +struct fc_port *conflict_fcport; +port_id_t cid;/* conflict Nport id */ +u32 *fw_status = sp->u.iocb_cmd.u.els_plogi.fw_status; +u16 lid; ql_dbg(ql_dbg_disc, vha, 0x3072, "%s ELS done rc %d hdl=%x, portid=%06x %8phC\n",
@@ -2760,14 +2764,99 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)if (sp->flags &SRB_WAKEUP_ON_COMP )complete (&lio->u.els_plogi.comp);else { -if (res) { -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); - }else { +switch (fw_status[0 ]) { +case CS_DATA_UNDERRUN : +case CS_COMPLETE :memset (&ea,0 ,sizeof (ea)); ea.fcport = fcport; ea.data[0 ] =MBS_COMMAND_COMPLETE ; ea.sp = sp;qla24xx_handle_plogi_done_event (vha, &ea); +break ; +case CS_IOCB_ERROR : +switch (fw_status[1 ]) { +case LSC_SCODE_PORTID_USED : + lid = fw_status[2 ] &0xffff ; +qlt_find_sess_invalidate_other (vha, +wwn_to_u64 (fcport->port_name), + fcport->d_id, lid, &conflict_fcport); +if (conflict_fcport) { +/* +* Another fcport shares the same +* loop_id & nport id; conflict +* fcport needs to finish cleanup +* before this fcport can proceed +* to login. +*/ + conflict_fcport->conflict = fcport; + fcport->login_pause =1 ; +ql_dbg (ql_dbg_disc, vha,0x20ed , +"%s %d %8phC pid %06x inuse with lid %#x post gidpn\n" , + __func__, __LINE__, + fcport->port_name, + fcport->d_id.b24, lid); + }else { +ql_dbg (ql_dbg_disc, vha,0x20ed , +"%s %d %8phC pid %06x inuse with lid %#x sched del\n" , + __func__, __LINE__, + fcport->port_name, + fcport->d_id.b24, lid); +qla2x00_clear_loop_id (fcport); +set_bit (lid, vha->hw->loop_id_map); + fcport->loop_id = lid; + fcport->keep_nport_handle =0 ; +qlt_schedule_sess_for_deletion (fcport); + } +break ; + +case LSC_SCODE_NPORT_USED : + cid.b.domain = (fw_status[2 ] >>16 ) &0xff ; + cid.b.area = (fw_status[2 ] >>8 ) &0xff ; + cid.b.al_pa = fw_status[2 ] &0xff ; + cid.b.rsvd_1 =0 ; + +ql_dbg (ql_dbg_disc, vha,0x20ec , +"%s %d %8phC lid %#x in use with pid %06x post gnl\n" , + __func__, __LINE__, fcport->port_name, + fcport->loop_id, cid.b24); +set_bit (fcport->loop_id, + vha->hw->loop_id_map); + fcport->loop_id =FC_NO_LOOP_ID ; +qla24xx_post_gnl_work (vha, fcport); +break ; + +case LSC_SCODE_NOXCB : + vha->hw->exch_starvation++; +if (vha->hw->exch_starvation >5 ) { +ql_log (ql_log_warn, vha,0xd046 , +"Exchange starvation. Resetting RISC\n" ); + vha->hw->exch_starvation =0 ; +set_bit (ISP_ABORT_NEEDED , + &vha->dpc_flags); +qla2xxx_wake_dpc (vha); + } +/* fall through */ +default : +ql_dbg (ql_dbg_disc, vha,0x20eb , +"%s %8phC cmd error fw_status 0x%x 0x%x 0x%x\n" , + __func__, sp->fcport->port_name, + fw_status[0 ], fw_status[1 ], fw_status[2 ]); + + fcport->flags &= ~FCF_ASYNC_SENT ; +set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +break ; + } +break ; + +default : +ql_dbg (ql_dbg_disc, vha,0x20eb , +"%s %8phC cmd error 2 fw_status 0x%x 0x%x 0x%x\n" , + __func__, sp->fcport->port_name, + fw_status[0 ], fw_status[1 ], fw_status[2 ]); + + sp->fcport->flags &= ~FCF_ASYNC_SENT ; +set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +break ; } e =qla2x00_alloc_work (vha,QLA_EVT_UNMAP );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 14/330 mm: fix double page fault on arm64 if PTE_AF is cleared
In reply to Sasha LevinFrom: Jia He <[email protected]>
[ Upstream commit 83d116c53058d505ddef051e90ab27f57015b025 ]
When we tested pmdk unit test [1] vmmalloc_fork TEST3 on arm64 guest, there will be a double page fault in __copy_from_user_inatomic of cow_user_page.
To reproduce the bug, the cmd is as follows after you deployed everything:
make -C src/test/vmmalloc_fork/ TEST_TIME=60m check
Below call trace is from arm64 do_page_fault for debugging purpose:
[ 110.016195] Call trace: [ 110.016826] do_page_fault+0x5a4/0x690 [ 110.017812] do_mem_abort+0x50/0xb0 [ 110.018726] el1_da+0x20/0xc4 [ 110.019492] __arch_copy_from_user+0x180/0x280 [ 110.020646] do_wp_page+0xb0/0x860 [ 110.021517] __handle_mm_fault+0x994/0x1338 [ 110.022606] handle_mm_fault+0xe8/0x180 [ 110.023584] do_page_fault+0x240/0x690 [ 110.024535] do_mem_abort+0x50/0xb0 [ 110.025423] el0_da+0x20/0x24
The pte info before __copy_from_user_inatomic is (PTE_AF is cleared):
[ffff9b007000] pgd=000000023d4f8003, pud=000000023da9b003,
pmd=000000023d4b3003, pte=360000298607bd3
As told by Catalin: "On arm64 without hardware Access Flag, copying from user will fail because the pte is old and cannot be marked young. So we always end up with zeroed page after fork() + CoW for pfn mappings. we don't always have a hardware-managed access flag on arm64."
This patch fixes it by calling pte_mkyoung. Also, the parameter is changed because vmf should be passed to cow_user_page()
Add a WARN_ON_ONCE when __copy_from_user_inatomic() returns error in case there can be some obscure use-case (by Kirill).
[1] https://github.com/pmem/pmdk/tree/master/src/test/vmmalloc_fork
--- mm/memory.c | 104 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 89 insertions(+), 15 deletions(-)
mm/memory.c +89 -15
@@ -118,6 +118,18 @@ int randomize_va_space __read_mostly =2 ;#endif +#ifndef arch_faults_on_old_pte +static inline bool arch_faults_on_old_pte (void ) +{ +/* +* Those arches which don't have hw access flag feature need to +* implement their own helper. By default, "true" means pagefault +* will be hit on old pte. +*/ +return true; +} +#endif +static int __init disable_randmaps (char *s) { randomize_va_space =0 ;
@@ -2145,32 +2157,82 @@ static inline int pte_unmap_same(struct mm_struct *mm, pmd_t *pmd,return same; } -static inline void cow_user_page (struct page *dst,struct page *src,unsigned long va,struct vm_area_struct *vma) +static inline bool cow_user_page (struct page *dst,struct page *src, +struct vm_fault *vmf) { +bool ret; +void *kaddr; +void __user *uaddr; +bool force_mkyoung; +struct vm_area_struct *vma = vmf->vma; +struct mm_struct *mm = vma->vm_mm; +unsigned long addr = vmf->address; +debug_dma_assert_idle (src); +if (likely (src)) { +copy_user_highpage (dst, src, addr, vma); +return true; + } +/* * If the source page was a PFN mapping, we don't have * a "struct page" for it. We do a best-effort copy by * just copying from the original user address. If that * fails, we just zero-fill it. Live with it. */ -if (unlikely (!src)) { -void *kaddr =kmap_atomic (dst); -void __user *uaddr = (void __user *)(va &PAGE_MASK ); + kaddr =kmap_atomic (dst); + uaddr = (void __user *)(addr &PAGE_MASK ); + +/* +* On architectures with software "accessed" bits, we would +* take a double page fault, so mark it accessed here. +*/ + force_mkyoung =arch_faults_on_old_pte () && !pte_young (vmf->orig_pte); +if (force_mkyoung) { +pte_t entry; + + vmf->pte =pte_offset_map_lock (mm, vmf->pmd, addr, &vmf->ptl); +if (!likely (pte_same (*vmf->pte, vmf->orig_pte))) { +/* +* Other thread has already handled the fault +* and we don't need to do anything. If it's +* not the case, the fault will be triggered +* again on the same address. +*/ + ret = false; + goto pte_unlock; + } + entry =pte_mkyoung (vmf->orig_pte); +if (ptep_set_access_flags (vma, addr, vmf->pte, entry,0 )) +update_mmu_cache (vma, addr, vmf->pte); + } + +/* +* This really shouldn't fail, because the page is there +* in the page tables. But it might just be unreadable, +* in which case we just give up and fill the result with +* zeroes. +*/ +if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) {/* -* This really shouldn't fail, because the page is there -* in the page tables. But it might just be unreadable, -* in which case we just give up and fill the result with -* zeroes. +* Give a warn in case there can be some obscure +* use-case */ -if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) -clear_page (kaddr); -kunmap_atomic (kaddr); -flush_dcache_page (dst); - }else -copy_user_highpage (dst, src, va, vma); +WARN_ON_ONCE (1 ); +clear_page (kaddr); + } + + ret = true; + +pte_unlock: +if (force_mkyoung) +pte_unmap_unlock (vmf->pte, vmf->ptl); +kunmap_atomic (kaddr); +flush_dcache_page (dst); + +return ret; }static gfp_t __get_fault_gfp_mask (struct vm_area_struct *vma)
@@ -2342,7 +2404,19 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) vmf->address);if (!new_page) goto oom; -cow_user_page (new_page, old_page, vmf->address, vma); + +if (!cow_user_page (new_page, old_page, vmf)) { +/* +* COW failed, if the fault was solved by other, +* it's fine. If not, userspace would re-fault on +* the same address and we will handle the fault +* from the second attempt. +*/ +put_page (new_page); +if (old_page) +put_page (old_page); +return 0 ; + } }if (mem_cgroup_try_charge_delay (new_page, mm,GFP_KERNEL , &memcg, false))
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 18/330 gma/gma500: fix a memory disclosure bug due to uninitialized bytes
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit 57a25a5f754ce27da2cfa6f413cfd366f878db76 ]
best_clock is an object that may be sent out. Object clock contains uninitialized bytes that are copied to best_clock, which leads to memory disclosure and information leak.
--- drivers/gpu/drm/gma500/cdv_intel_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/gma500/cdv_intel_display.c +2 -0
@@ -405,6 +405,8 @@ static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,struct gma_crtc *gma_crtc =to_gma_crtc (crtc);struct gma_clock_t clock; +memset (&clock,0 ,sizeof (clock)); +switch (refclk) {case 27000 :if (target <200000 ) {
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 22/330 drm/amd/display: Free gamma after calculating legacy transfer function
In reply to Sasha LevinFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit 0e3a7c2ec93b15f43a2653e52e9608484391aeaf ]
[Why]
We're leaking memory by not freeing the gamma used to calculate the transfer function for legacy gamma.
[How]
Release the gamma after we're done with it.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +2 -0
@@ -210,6 +210,8 @@ static int __set_legacy_tf(struct dc_transfer_func *func, res =mod_color_calculate_regamma_params (func, gamma, true, has_rom,NULL ); +dc_gamma_release (&gamma); +return res ?0 : -ENOMEM ; }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 20/330 soundwire: intel/cadence: fix startup sequence
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 49ea07d33d9a32c17e18b322e789507280ceb2a3 ]
Multiple changes squashed in single patch to avoid tick-tock effect and avoid breaking compilation/bisect
1. Per the hardware documentation, all changes to MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL need to be validated with a self-clearing write to MCP_CONFIG_UPDATE. Add a helper and do the update when the CONFIG is changed.
2. Move interrupt enable after interrupt handler registration
3. Add a new helper to start the hardware bus reset with maximum duration to make sure the Slave(s) correctly detect the reset pattern and to ensure electrical conflicts can be resolved.
4. flush command FIFOs
Better error handling will be provided after interrupt disable is provided in follow-up patches.
--- drivers/soundwire/cadence_master.c | 80 +++++++++++++++++++++--------- drivers/soundwire/cadence_master.h | 1 + drivers/soundwire/intel.c | 14 +++++- 3 files changed, 69 insertions(+), 26 deletions(-)
drivers/soundwire/cadence_master.c +56 -24
@@ -231,6 +231,22 @@ static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)return -EAGAIN ; } +/* +* all changes to the MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL +* need to be confirmed with a write to MCP_CONFIG_UPDATE +*/ +static int cdns_update_config (struct sdw_cdns *cdns) +{ +int ret; + + ret =cdns_clear_bit (cdns,CDNS_MCP_CONFIG_UPDATE , +CDNS_MCP_CONFIG_UPDATE_BIT ); +if (ret <0 ) +dev_err (cdns->dev,"Config update timedout\n" ); + +return ret; +} +/* * debugfs */
@@ -752,7 +768,38 @@ EXPORT_SYMBOL(sdw_cdns_thread);/* * init routines */ -static int _cdns_enable_interrupt (struct sdw_cdns *cdns) + +/** +* sdw_cdns_exit_reset() - Program reset parameters and start bus operations +* @cdns: Cadence instance +*/ +int sdw_cdns_exit_reset (struct sdw_cdns *cdns) +{ +/* program maximum length reset to be safe */ +cdns_updatel (cdns,CDNS_MCP_CONTROL , +CDNS_MCP_CONTROL_RST_DELAY , +CDNS_MCP_CONTROL_RST_DELAY ); + +/* use hardware generated reset */ +cdns_updatel (cdns,CDNS_MCP_CONTROL , +CDNS_MCP_CONTROL_HW_RST , +CDNS_MCP_CONTROL_HW_RST ); + +/* enable bus operations with clock and data */ +cdns_updatel (cdns,CDNS_MCP_CONFIG , +CDNS_MCP_CONFIG_OP , +CDNS_MCP_CONFIG_OP_NORMAL ); + +/* commit changes */ +return cdns_update_config (cdns); +} +EXPORT_SYMBOL (sdw_cdns_exit_reset); + +/** +* sdw_cdns_enable_interrupt() - Enable SDW interrupts and update config +* @cdns: Cadence instance +*/ +int sdw_cdns_enable_interrupt (struct sdw_cdns *cdns) {u32 mask;
@@ -784,24 +831,8 @@ static int _cdns_enable_interrupt(struct sdw_cdns *cdns)cdns_writel (cdns,CDNS_MCP_INTMASK , mask); -return 0 ; -} - -/** -* sdw_cdns_enable_interrupt() - Enable SDW interrupts and update config -* @cdns: Cadence instance -*/ -int sdw_cdns_enable_interrupt (struct sdw_cdns *cdns) -{ -int ret; - -_cdns_enable_interrupt (cdns); - ret =cdns_clear_bit (cdns,CDNS_MCP_CONFIG_UPDATE , -CDNS_MCP_CONFIG_UPDATE_BIT ); -if (ret <0 ) -dev_err (cdns->dev,"Config update timedout\n" ); - -return ret; +/* commit changes */ +return cdns_update_config (cdns); }EXPORT_SYMBOL (sdw_cdns_enable_interrupt);
@@ -975,6 +1006,10 @@ int sdw_cdns_init(struct sdw_cdns *cdns)cdns_writel (cdns,CDNS_MCP_SSP_CTRL0 ,CDNS_DEFAULT_SSP_INTERVAL );cdns_writel (cdns,CDNS_MCP_SSP_CTRL1 ,CDNS_DEFAULT_SSP_INTERVAL ); +/* flush command FIFOs */ +cdns_updatel (cdns,CDNS_MCP_CONTROL ,CDNS_MCP_CONTROL_CMD_RST , +CDNS_MCP_CONTROL_CMD_RST ); +/* Set cmd accept mode */ cdns_updatel (cdns,CDNS_MCP_CONTROL ,CDNS_MCP_CONTROL_CMD_ACCEPT ,CDNS_MCP_CONTROL_CMD_ACCEPT );
@@ -997,13 +1032,10 @@ int sdw_cdns_init(struct sdw_cdns *cdns)/* Set cmd mode for Tx and Rx cmds */ val &= ~CDNS_MCP_CONFIG_CMD ; -/* Set operation to normal */ - val &= ~CDNS_MCP_CONFIG_OP ; - val |=CDNS_MCP_CONFIG_OP_NORMAL ; -cdns_writel (cdns,CDNS_MCP_CONFIG , val); -return 0 ; +/* commit changes */ +return cdns_update_config (cdns); }EXPORT_SYMBOL (sdw_cdns_init);
drivers/soundwire/cadence_master.h +1 -0
@@ -161,6 +161,7 @@ irqreturn_t sdw_cdns_thread(int irq, void *dev_id);int sdw_cdns_init (struct sdw_cdns *cdns);int sdw_cdns_pdi_init (struct sdw_cdns *cdns,struct sdw_cdns_stream_config config); +int sdw_cdns_exit_reset (struct sdw_cdns *cdns);int sdw_cdns_enable_interrupt (struct sdw_cdns *cdns);#ifdef CONFIG_DEBUG_FS
drivers/soundwire/intel.c +12 -2
@@ -1050,8 +1050,6 @@ static int intel_probe(struct platform_device *pdev)if (ret) goto err_init; - ret =sdw_cdns_enable_interrupt (&sdw->cdns); -/* Read the PDI config and initialize cadence PDI */ intel_pdi_init (sdw, &config); ret =sdw_cdns_pdi_init (&sdw->cdns, config);
@@ -1069,6 +1067,18 @@ static int intel_probe(struct platform_device *pdev) goto err_init; } + ret =sdw_cdns_enable_interrupt (&sdw->cdns); +if (ret <0 ) { +dev_err (sdw->cdns.dev,"cannot enable interrupts\n" ); + goto err_init; + } + + ret =sdw_cdns_exit_reset (&sdw->cdns); +if (ret <0 ) { +dev_err (sdw->cdns.dev,"unable to exit bus reset sequence\n" ); + goto err_init; + } +/* Register DAIs */ ret =intel_register_dai (sdw);if (ret) {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 19/330 ASoC: kirkwood: fix IRQ error handling
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 175fc928198236037174e5c5c066fe3c4691903e ]
Propagate the error code from request_irq(), rather than returning -EBUSY.
--- sound/soc/kirkwood/kirkwood-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/kirkwood/kirkwood-dma.c +1 -1
@@ -132,7 +132,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) err =request_irq (priv->irq, kirkwood_dma_irq,IRQF_SHARED ,"kirkwood-i2s" , priv);if (err) -return -EBUSY ; +return err;/* * Enable Error interrupts. We're only ack'ing them but
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 17/330 xfs: fix inode fork extent count overflow
In reply to Sasha LevinFrom: Dave Chinner <[email protected]>
[ Upstream commit 3f8a4f1d876d3e3e49e50b0396eaffcc4ba71b08 ]
[commit message is verbose for discussion purposes - will trim it down later. Some questions about implementation details at the end.]
Zorro Lang recently ran a new test to stress single inode extent counts now that they are no longer limited by memory allocation. The test was simply:
# xfs_io -f -c "falloc 0 40t" /mnt/scratch/big-file # ~/src/xfstests-dev/punch-alternating /mnt/scratch/big-file
This test uncovered a problem where the hole punching operation appeared to finish with no error, but apparently only created 268M extents instead of the 10 billion it was supposed to.
Further, trying to punch out extents that should have been present resulted in success, but no change in the extent count. It looked like a silent failure.
While running the test and observing the behaviour in real time, I observed the extent coutn growing at ~2M extents/minute, and saw this after about an hour:
# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next ; \
Quoted 2 lines
sleep 60 ; \
xfs_io-f -c "stat"/mnt/scratch/big-file|grep next
fsxattr.nextents = 127657993
fsxattr.nextents = 129683339
#
And a few minutes later this:
# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next fsxattr.nextents = 4177861124 #
Ah, what? Where did that 4 billion extra extents suddenly come from?
Stop the workload, unmount, mount:
# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next fsxattr.nextents = 166044375 #
And it's back at the expected number. i.e. the extent count is correct on disk, but it's screwed up in memory. I loaded up the extent list, and immediately:
# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next fsxattr.nextents = 4192576215 #
It's bad again. So, where does that number come from? xfs_fill_fsxattr():
if (ip->i_df.if_flags & XFS_IFEXTENTS)
fa->fsx_nextents = xfs_iext_count(&ip->i_df);
else
fa->fsx_nextents = ip->i_d.di_nextents;And that's the behaviour I just saw in a nutshell. The on disk count is correct, but once the tree is loaded into memory, it goes whacky. Clearly there's something wrong with xfs_iext_count():
inline xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp)
{
return ifp->if_bytes / sizeof(struct xfs_iext_rec);
}Simple enough, but 134M extents is 2**27, and that's right about where things went wrong. A struct xfs_iext_rec is 16 bytes in size, which means 2**27 * 2**4 = 2**31 and we're right on target for an integer overflow. And, sure enough:
struct xfs_ifork {
int if_bytes; /* bytes in if_u1 */
....
Once we get 2**27 extents in a file, we overflow if_bytes and the in-core extent count goes wrong. And when we reach 2**28 extents, if_bytes wraps back to zero and things really start to go wrong there. This is where the silent failure comes from - only the first 2**28 extents can be looked up directly due to the overflow, all the extents above this index wrap back to somewhere in the first 2**28 extents. Hence with a regular pattern, trying to punch a hole in the range that didn't have holes mapped to a hole in the first 2**28 extents and so "succeeded" without changing anything. Hence "silent failure"...
Fix this by converting if_bytes to a int64_t and converting all the index variables and size calculations to use int64_t types to avoid overflows in future. Signed integers are still used to enable easy detection of extent count underflows. This enables scalability of extent counts to the limits of the on-disk format - MAXEXTNUM (2**31) extents.
Current testing is at over 500M extents and still going:
fsxattr.nextents = 517310478
--- fs/xfs/libxfs/xfs_attr_leaf.c | 18 ++++++++++-------- fs/xfs/libxfs/xfs_dir2_sf.c | 2 +- fs/xfs/libxfs/xfs_iext_tree.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 8 ++++---- fs/xfs/libxfs/xfs_inode_fork.h | 14 ++++++++------ 5 files changed, 24 insertions(+), 20 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +10 -8
@@ -453,13 +453,15 @@ xfs_attr_copy_value(* special case for dev/uuid inodes, they have fixed size data forks. */ int -xfs_attr_shortform_bytesfit (xfs_inode_t *dp,int bytes) +xfs_attr_shortform_bytesfit ( +struct xfs_inode *dp, +int bytes) { -int offset; -int minforkoff;/* lower limit on valid forkoff locations */ -int maxforkoff;/* upper limit on valid forkoff locations */ -int dsize; -xfs_mount_t *mp = dp->i_mount; +struct xfs_mount *mp = dp->i_mount; +int64_t dsize; +int minforkoff; +int maxforkoff; +int offset;/* rounded down */ offset = (XFS_LITINO (mp, dp->i_d.di_version) - bytes) >>3 ;
@@ -525,7 +527,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)* A data fork btree root must have space for at least * MINDBTPTRS key/ptr pairs if the data fork is small or empty. */ - minforkoff =max (dsize,XFS_BMDR_SPACE_CALC (MINDBTPTRS )); + minforkoff =max_t (int64_t, dsize,XFS_BMDR_SPACE_CALC (MINDBTPTRS )); minforkoff =roundup (minforkoff,8 ) >>3 ;/* attr fork btree root can have at least this many key/ptr pairs */
@@ -924,7 +926,7 @@ xfs_attr_shortform_verify(char *endp;struct xfs_ifork *ifp;int i; -int size; +int64_t size;ASSERT (ip->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ); ifp =XFS_IFORK_PTR (ip,XFS_ATTR_FORK );
fs/xfs/libxfs/xfs_dir2_sf.c +1 -1
@@ -628,7 +628,7 @@ xfs_dir2_sf_verify(int i;int i8count;int offset; -int size; +int64_t size;int error;uint8_t filetype;
fs/xfs/libxfs/xfs_iext_tree.c +1 -1
@@ -596,7 +596,7 @@ xfs_iext_realloc_root(struct xfs_ifork *ifp, struct xfs_iext_cursor *cur) { - size_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec); + int64_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec);void *new;/* account for the prev/next pointers */
fs/xfs/libxfs/xfs_inode_fork.c +4 -4
@@ -129,7 +129,7 @@ xfs_init_local_fork(struct xfs_inode *ip, int whichfork, const void *data, - int size) + int64_t size) { struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);int mem_size = size, real_size =0 ;
@@ -467,11 +467,11 @@ xfs_iroot_realloc(void xfs_idata_realloc (struct xfs_inode *ip, -int byte_diff, +int64_t byte_diff,int whichfork) {struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork); -int new_size = (int )ifp->if_bytes + byte_diff; +int64_t new_size = ifp->if_bytes + byte_diff;ASSERT (new_size >=0 );ASSERT (new_size <=XFS_IFORK_SIZE (ip, whichfork));
@@ -552,7 +552,7 @@ xfs_iextents_copy(struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork);struct xfs_iext_cursor icur;struct xfs_bmbt_irec rec; -int copied =0 ; +int64_t copied =0 ;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED ));ASSERT (ifp->if_bytes >0 );
fs/xfs/libxfs/xfs_inode_fork.h +8 -6
@@ -13,16 +13,16 @@ struct xfs_dinode;* File incore extent information, present for each of data & attr forks. */ struct xfs_ifork { -int if_bytes;/* bytes in if_u1 */ -unsigned int if_seq;/* fork mod counter */ +int64_t if_bytes;/* bytes in if_u1 */ struct xfs_btree_block *if_broot;/* file's incore btree root */ -short if_broot_bytes;/* bytes allocated for root */ -unsigned char if_flags;/* per-fork flags */ +unsigned int if_seq;/* fork mod counter */ int if_height;/* height of the extent tree */ union {void *if_root;/* extent tree root */ char *if_data;/* inline file data */ } if_u1; +short if_broot_bytes;/* bytes allocated for root */ +unsigned char if_flags;/* per-fork flags */ };/*
@@ -93,12 +93,14 @@ int xfs_iformat_fork(struct xfs_inode *, struct xfs_dinode *);void xfs_iflush_fork (struct xfs_inode *,struct xfs_dinode *,struct xfs_inode_log_item *,int );void xfs_idestroy_fork (struct xfs_inode *,int ); -void xfs_idata_realloc (struct xfs_inode *,int ,int ); +void xfs_idata_realloc (struct xfs_inode *ip,int64_t byte_diff, +int whichfork);void xfs_iroot_realloc (struct xfs_inode *,int ,int );int xfs_iread_extents (struct xfs_trans *,struct xfs_inode *,int );int xfs_iextents_copy (struct xfs_inode *,struct xfs_bmbt_rec *,int ); -void xfs_init_local_fork (struct xfs_inode *,int ,const void *,int ); +void xfs_init_local_fork (struct xfs_inode *ip,int whichfork, +const void *data,int64_t size);xfs_extnum_t xfs_iext_count (struct xfs_ifork *ifp); void xfs_iext_insert(struct xfs_inode *, struct xfs_iext_cursor *cur,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 36/330 drm/amdgpu/powerplay: fix AVFS handling with custom powerplay table
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 53dbc27ad5a93932ff1892a8e4ef266827d74a0f ]
When a custom powerplay table is provided, we need to update the OD VDDC flag to avoid AVFS being enabled when it shouldn't be.
--- drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +7 -0
@@ -3691,6 +3691,13 @@ static int vega10_set_power_state_tasks(struct pp_hwmgr *hwmgr,PP_ASSERT_WITH_CODE (!result, "Failed to upload PPtable!", return result); +/* +* If a custom pp table is loaded, set DPMTABLE_OD_UPDATE_VDDC flag. +* That effectively disables AVFS feature. +*/ +if (hwmgr->hardcode_pp_table !=NULL ) + data->need_update_dpm_table |=DPMTABLE_OD_UPDATE_VDDC ; +vega10_update_avfs (hwmgr);/*
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 32/330 dax: Fix alloc_dax_region() compile warning
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
[ Upstream commit 460370ab20b6cc174256e46e192adf01e730faf6 ]
PFN flags are (unsigned long long), fix the alloc_dax_region() calling convention to fix warnings of the form:
Quoted 1 line
Quoted 1 line
include/linux/pfn_t.h:18:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
--- drivers/dax/bus.c | 2 +- drivers/dax/bus.h | 2 +- drivers/dax/dax-private.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/dax/bus.c +1 -1
@@ -227,7 +227,7 @@ static void dax_region_unregister(void *region)struct dax_region *alloc_dax_region (struct device *parent,int region_id,struct resource *res,int target_node,unsigned int align, -unsigned long pfn_flags) +unsigned long long pfn_flags) {struct dax_region *dax_region;
drivers/dax/bus.h +1 -1
@@ -11,7 +11,7 @@ struct dax_region;void dax_region_put (struct dax_region *dax_region);struct dax_region *alloc_dax_region (struct device *parent,int region_id,struct resource *res,int target_node,unsigned int align, -unsigned long flags); +unsigned long long flags);enum dev_dax_subsys {DEV_DAX_BUS ,
drivers/dax/dax-private.h +1 -1
@@ -32,7 +32,7 @@ struct dax_region {struct device *dev;unsigned int align;struct resource res; -unsigned long pfn_flags; +unsigned long long pfn_flags; };/**
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 40/330 drm/amdgpu/powerplay/smu7: fix AVFS handling with custom powerplay table
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 901245624c7812b6c95d67177bae850e783b5212 ]
When a custom powerplay table is provided, we need to update the OD VDDC flag to avoid AVFS being enabled when it shouldn't be.
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +7 -0
@@ -3986,6 +3986,13 @@ static int smu7_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)"Failed to populate and upload SCLK MCLK DPM levels!" , result = tmp_result); +/* +* If a custom pp table is loaded, set DPMTABLE_OD_UPDATE_VDDC flag. +* That effectively disables AVFS feature. +*/ +if (hwmgr->hardcode_pp_table !=NULL ) + data->need_update_smu7_dpm_table |=DPMTABLE_OD_UPDATE_VDDC ; + tmp_result =smu7_update_avfs (hwmgr); PP_ASSERT_WITH_CODE((0 == tmp_result), "Failed to update avfs voltages!",
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 38/330 mtd: cfi_cmdset_0002: don't free cfi->cfiq in error path of cfi_amdstd_setup()
In reply to Sasha LevinFrom: Hou Tao <[email protected]>
[ Upstream commit 03976af89e3bd9489d542582a325892e6a8cacc0 ]
Else there may be a double-free problem, because cfi->cfiq will be freed by mtd_do_chip_probe() if both the two invocations of check_cmd_set() return failure.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/chips/cfi_cmdset_0002.c +0 -1
@@ -794,7 +794,6 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)kfree (mtd->eraseregions);kfree (mtd);kfree (cfi->cmdset_priv); -kfree (cfi->cfiq);return NULL ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 46/330 dmaengine: mediatek: hsdma_probe: fixed a memory leak when devm_request_irq fails
In reply to Sasha LevinFrom: Satendra Singh Thakur <[email protected]>
[ Upstream commit 1ff95243257fad07290dcbc5f7a6ad79d6e703e2 ]
When devm_request_irq fails, currently, the function dma_async_device_unregister gets called. This doesn't free the resources allocated by of_dma_controller_register. Therefore, we have called of_dma_controller_free for this purpose.
--- drivers/dma/mediatek/mtk-hsdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/mediatek/mtk-hsdma.c +3 -1
@@ -997,7 +997,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)if (err) {dev_err (&pdev->dev,"request_irq failed with err %d\n" , err); - goto err_unregister; + goto err_free; }platform_set_drvdata (pdev, hsdma);
@@ -1006,6 +1006,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev)return 0 ; +err_free: +of_dma_controller_free (pdev->dev.of_node); err_unregister:dma_async_device_unregister (dd);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 47/330 x86/kdump: Always reserve the low 1M when the crashkernel option is specified
In reply to Sasha LevinFrom: Lianbo Jiang <[email protected]>
[ Upstream commit 6f599d84231fd27e42f4ca2a786a6641e8cddf00 ]
On x86, purgatory() copies the first 640K of memory to a backup region because the kernel needs those first 640K for the real mode trampoline during boot, among others.
However, when SME is enabled, the kernel cannot properly copy the old memory to the backup area but reads only its encrypted contents. The result is that the crash tool gets invalid pointers when parsing vmcore:
crash> kmem -s|grep -i invalid
kmem: dma-kmalloc-512: slab:ffffd77680001c00 invalid freepointer:a6086ac099f0c5a4
kmem: dma-kmalloc-512: slab:ffffd77680001c00 invalid freepointer:a6086ac099f0c5a4 crash>
So reserve the remaining low 1M memory when the crashkernel option is specified (after reserving real mode memory) so that allocated memory does not fall into the low 1M area and thus the copying of the contents of the first 640k to a backup region in purgatory() can be avoided altogether.
This way, it does not need to be included in crash dumps or used for anything except the trampolines that must live in the low 1M.
[ bp: Heavily rewrite commit message, flip check logic in
crash_reserve_low_1M().]
--- arch/x86/include/asm/crash.h | 6 ++++++ arch/x86/kernel/crash.c | 15 +++++++++++++++ arch/x86/realmode/init.c | 2 ++ 3 files changed, 23 insertions(+)
arch/x86/include/asm/crash.h +6 -0
@@ -10,4 +10,10 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params);void crash_smp_send_stop (void ); +#ifdef CONFIG_KEXEC_CORE +void __init crash_reserve_low_1M (void ); +#else +static inline void __init crash_reserve_low_1M (void ) { } +#endif +#endif /* _ASM_X86_CRASH_H */
arch/x86/kernel/crash.c +15 -0
@@ -24,6 +24,7 @@#include <linux/export.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/memblock.h> #include <asm/processor.h> #include <asm/hardirq.h>
@@ -39,6 +40,7 @@#include <asm/virtext.h> #include <asm/intel_pt.h> #include <asm/crash.h> +#include <asm/cmdline.h> /* Used while preparing memory map entries for second kernel */ struct crash_memmap_data {
@@ -68,6 +70,19 @@ static inline void cpu_crash_vmclear_loaded_vmcss(void)rcu_read_unlock (); } +/* +* When the crashkernel option is specified, only use the low +* 1M for the real mode trampoline. +*/ +void __init crash_reserve_low_1M (void ) +{ +if (cmdline_find_option (boot_command_line,"crashkernel" ,NULL ,0 ) <0 ) +return ; + +memblock_reserve (0 ,1 <<20 ); +pr_info ("Reserving the low 1M of memory for crashkernel\n" ); +} +#if defined(CONFIG_SMP ) && defined(CONFIG_X86_LOCAL_APIC )static void kdump_nmi_callback (int cpu,struct pt_regs *regs)
arch/x86/realmode/init.c +2 -0
@@ -8,6 +8,7 @@#include <asm/pgtable.h> #include <asm/realmode.h> #include <asm/tlbflush.h> +#include <asm/crash.h> struct real_mode_header *real_mode_header;u32 *trampoline_cr4_features;
@@ -34,6 +35,7 @@ void __init reserve_real_mode(void)memblock_reserve (mem, size);set_real_mode_mem (mem); +crash_reserve_low_1M (); }static void __init setup_real_mode (void )
Signature · 7 lines
2.25.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Sasha Levin
maintainerPATCH 45/330 bcache: fix a lost wake-up problem caused by mca_cannibalize_lock
In reply to Sasha LevinFrom: Guoju Fang <[email protected]>
[ Upstream commit 34cf78bf34d48dddddfeeadb44f9841d7864997a ]
This patch fix a lost wake-up problem caused by the race between mca_cannibalize_lock and bch_cannibalize_unlock.
Consider two processes, A and B. Process A is executing mca_cannibalize_lock, while process B takes c->btree_cache_alloc_lock and is executing bch_cannibalize_unlock. The problem happens that after process A executes cmpxchg and will execute prepare_to_wait. In this timeslice process B executes wake_up, but after that process A executes prepare_to_wait and set the state to TASK_INTERRUPTIBLE. Then process A goes to sleep but no one will wake up it. This problem may cause bcache device to dead.
--- drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/btree.c | 12 ++++++++---- drivers/md/bcache/super.c | 1 + 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/md/bcache/bcache.h +1 -0
@@ -585,6 +585,7 @@ struct cache_set {*/ wait_queue_head_t btree_cache_wait;struct task_struct *btree_cache_alloc_lock; +spinlock_t btree_cannibalize_lock;/* * When we free a btree node, we increment the gen of the bucket the
drivers/md/bcache/btree.c +8 -4
@@ -886,15 +886,17 @@ out:static int mca_cannibalize_lock (struct cache_set *c,struct btree_op *op) { -struct task_struct *old; - - old =cmpxchg (&c->btree_cache_alloc_lock,NULL , current); -if (old && old != current) { +spin_lock (&c->btree_cannibalize_lock); +if (likely (c->btree_cache_alloc_lock ==NULL )) { + c->btree_cache_alloc_lock = current; + }else if (c->btree_cache_alloc_lock != current) {if (op)prepare_to_wait (&c->btree_cache_wait, &op->wait,TASK_UNINTERRUPTIBLE ); +spin_unlock (&c->btree_cannibalize_lock);return -EINTR ; } +spin_unlock (&c->btree_cannibalize_lock);return 0 ; }
@@ -929,10 +931,12 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct btree_op *op,*/ static void bch_cannibalize_unlock (struct cache_set *c) { +spin_lock (&c->btree_cannibalize_lock);if (c->btree_cache_alloc_lock == current) { c->btree_cache_alloc_lock =NULL ;wake_up (&c->btree_cache_wait); } +spin_unlock (&c->btree_cannibalize_lock); } static struct btree *mca_alloc(struct cache_set *c, struct btree_op *op,
drivers/md/bcache/super.c +1 -0
@@ -1798,6 +1798,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)sema_init (&c->sb_write_mutex,1 );mutex_init (&c->bucket_lock);init_waitqueue_head (&c->btree_cache_wait); +spin_lock_init (&c->btree_cannibalize_lock);init_waitqueue_head (&c->bucket_wait);init_waitqueue_head (&c->gc_wait);sema_init (&c->uuid_write_mutex,1 );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 41/330 USB: serial: mos7840: fix probe error handling
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 960fbd1ca584a5b4cd818255769769d42bfc6dbe ]
The driver would return success and leave the port structures half-initialised if any of the register accesses during probe fails.
This would specifically leave the port control urb unallocated, something which could trigger a NULL pointer dereference on interrupt events.
Fortunately the interrupt implementation is completely broken and has never even been enabled...
Note that the zero-length-enable register write used to set the zle-flag for all ports is moved to attach.
--- drivers/usb/serial/mos7840.c | 48 +++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-)
drivers/usb/serial/mos7840.c +28 -20
@@ -2090,6 +2090,23 @@ static int mos7840_calc_num_ports(struct usb_serial *serial,return num_ports; } +static int mos7840_attach (struct usb_serial *serial) +{ +struct device *dev = &serial->interface->dev; +int status; +u16 val; + +/* Zero Length flag enable */ + val =0x0f ; + status =mos7840_set_reg_sync (serial->port[0 ],ZLP_REG5 , val); +if (status <0 ) +dev_dbg (dev,"Writing ZLP_REG5 failed status-0x%x\n" , status); +else +dev_dbg (dev,"ZLP_REG5 Writing success status%d\n" , status); + +return status; +} +static int mos7840_port_probe (struct usb_serial_port *port) {struct usb_serial *serial = port->serial;
@@ -2147,7 +2164,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) mos7840_port->ControlRegOffset, &Data);if (status <0 ) {dev_dbg (&port->dev,"Reading ControlReg failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"ControlReg Reading success val is %x, status%d\n" , Data, status); Data |=0x08 ;/* setting driver done bit */
@@ -2159,7 +2176,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) mos7840_port->ControlRegOffset, Data);if (status <0 ) {dev_dbg (&port->dev,"Writing ControlReg failed(rx_disable) status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"ControlReg Writing success(rx_disable) status%d\n" , status);
@@ -2170,7 +2187,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) (__u16) (mos7840_port->DcrRegOffset + 0), Data);if (status <0 ) {dev_dbg (&port->dev,"Writing DCR0 failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"DCR0 Writing success status%d\n" , status);
@@ -2179,7 +2196,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) (__u16) (mos7840_port->DcrRegOffset + 1), Data);if (status <0 ) {dev_dbg (&port->dev,"Writing DCR1 failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"DCR1 Writing success status%d\n" , status);
@@ -2188,7 +2205,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) (__u16) (mos7840_port->DcrRegOffset + 2), Data);if (status <0 ) {dev_dbg (&port->dev,"Writing DCR2 failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"DCR2 Writing success status%d\n" , status);
@@ -2197,7 +2214,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) status =mos7840_set_reg_sync (port,CLK_START_VALUE_REGISTER , Data);if (status <0 ) {dev_dbg (&port->dev,"Writing CLK_START_VALUE_REGISTER failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"CLK_START_VALUE_REGISTER Writing success status%d\n" , status);
@@ -2214,7 +2231,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) status =mos7840_set_uart_reg (port,SCRATCH_PAD_REGISTER , Data);if (status <0 ) {dev_dbg (&port->dev,"Writing SCRATCH_PAD_REGISTER failed status-0x%x\n" , status); - goto out; + goto error; }else dev_dbg (&port->dev,"SCRATCH_PAD_REGISTER Writing success status%d\n" , status);
@@ -2228,7 +2245,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num)));if (status <0 ) {dev_dbg (&port->dev,"Writing ZLP_REG%d failed status-0x%x\n" , pnum +2 , status); - goto out; + goto error; }else dev_dbg (&port->dev,"ZLP_REG%d Writing success status%d\n" , pnum +2 , status); }else {
@@ -2240,7 +2257,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1));if (status <0 ) {dev_dbg (&port->dev,"Writing ZLP_REG%d failed status-0x%x\n" , pnum +1 , status); - goto out; + goto error; }else dev_dbg (&port->dev,"ZLP_REG%d Writing success status%d\n" , pnum +1 , status);
@@ -2280,17 +2297,7 @@ static int mos7840_port_probe(struct usb_serial_port *port)/* Turn off LED */ mos7840_set_led_sync (port,MODEM_CONTROL_REGISTER ,0x0300 ); } -out: -if (pnum == serial->num_ports -1 ) { -/* Zero Length flag enable */ - Data =0x0f ; - status =mos7840_set_reg_sync (serial->port[0 ],ZLP_REG5 , Data); -if (status <0 ) { -dev_dbg (&port->dev,"Writing ZLP_REG5 failed status-0x%x\n" , status); - goto error; - }else -dev_dbg (&port->dev,"ZLP_REG5 Writing success status%d\n" , status); - } +return 0 ; error:kfree (mos7840_port->led_dr);
@@ -2346,6 +2353,7 @@ static struct usb_serial_driver moschip7840_4port_device = { .unthrottle = mos7840_unthrottle, .calc_num_ports = mos7840_calc_num_ports, .probe = mos7840_probe, + .attach = mos7840_attach, .ioctl = mos7840_ioctl, .get_serial = mos7840_get_serial_info, .set_termios = mos7840_set_termios,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 34/330 f2fs: avoid kernel panic on corruption test
In reply to Sasha LevinFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit bc005a4d5347da68e690f78d365d8927c87dc85a ]
xfstests/generic/475 complains kernel warn/panic while testing corrupted disk.
--- fs/f2fs/node.c | 1 - 1 file changed, 1 deletion(-)
fs/f2fs/node.c +0 -1
@@ -2350,7 +2350,6 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,if (ret) {up_read (&nm_i->nat_tree_lock); -f2fs_bug_on (sbi, !mount);f2fs_err (sbi,"NAT is corrupt, run fsck to fix it" );return ret; }
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Sasha Levin
maintainerPATCH 51/330 fix dget_parent() fastpath race
In reply to Sasha LevinFrom: Al Viro <[email protected]>
[ Upstream commit e84009336711d2bba885fc9cea66348ddfce3758 ]
We are overoptimistic about taking the fast path there; seeing the same value in ->d_parent after having grabbed a reference to that parent does *not* mean that it has remained our parent all along.
That wouldn't be a big deal (in the end it is our parent and we have grabbed the reference we are about to return), but... the situation with barriers is messed up.
We might have hit the following sequence:
d is a dentry of /tmp/a/b
CPU1: CPU2:
parent = d->d_parent (i.e. dentry of /tmp/a)
rename /tmp/a/b to /tmp/b rmdir /tmp/a, making its dentry negative
grab reference to parent,
end up with cached parent->d_inode (NULL)
mkdir /tmp/a, rename /tmp/b to /tmp/a/b
recheck d->d_parent, which is back to original
decide that everything's fine and return the reference we'd got.
The trouble is, caller (on CPU1) will observe dget_parent() returning an apparently negative dentry. It actually is positive, but CPU1 has stale ->d_inode cached.
Use d->d_seq to see if it has been moved instead of rechecking ->d_parent.
NOTE: we are *NOT* going to retry on any kind of ->d_seq mismatch; we just go into the slow path in such case. We don't wait for ->d_seq to become even either - again, if we are racing with renames, we can bloody well go to slow path anyway.
--- fs/dcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/dcache.c +3 -1
@@ -903,17 +903,19 @@ struct dentry *dget_parent(struct dentry *dentry) {int gotref;struct dentry *ret; +unsigned seq;/* * Do optimistic parent lookup without any * locking. */ rcu_read_lock (); + seq =raw_seqcount_begin (&dentry->d_seq); ret =READ_ONCE (dentry->d_parent); gotref =lockref_get_not_zero (&ret->d_lockref);rcu_read_unlock ();if (likely (gotref)) { -if (likely (ret ==READ_ONCE (dentry->d_parent))) +if (!read_seqcount_retry (&dentry->d_seq, seq))return ret;dput (ret); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 53/330 RDMA/iw_cgxb4: Fix an error handling path in 'c4iw_connect()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9067f2f0b41d7e817fc8c5259bab1f17512b0147 ]
We should jump to fail3 in order to undo the 'xa_insert_irq()' call.
--- drivers/infiniband/hw/cxgb4/cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +2 -2
@@ -3382,7 +3382,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)if (raddr->sin_addr.s_addr ==htonl (INADDR_ANY )) { err =pick_local_ipaddrs (dev, cm_id);if (err) - goto fail2; + goto fail3; }/* find a route */
@@ -3404,7 +3404,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)if (ipv6_addr_type (&raddr6->sin6_addr) ==IPV6_ADDR_ANY ) { err =pick_local_ip6addrs (dev, cm_id);if (err) - goto fail2; + goto fail3; }/* find a route */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 64/330 f2fs: stop GC when the victim becomes fully valid
In reply to Sasha LevinFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 803e74be04b32f7785742dcabfc62116718fbb06 ]
We must stop GC, once the segment becomes fully valid. Otherwise, it can produce another dirty segments by moving valid blocks in the segment partially.
Ramon hit no free segment panic sometimes and saw this case happens when validating reliable file pinning feature.
--- fs/f2fs/gc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/f2fs/gc.c +8 -2
@@ -1012,8 +1012,14 @@ next_step:block_t start_bidx;nid_t nid =le32_to_cpu (entry->nid); -/* stop BG_GC if there is not enough free sections. */ -if (gc_type ==BG_GC &&has_not_enough_free_secs (sbi,0 ,0 )) +/* +* stop BG_GC if there is not enough free sections. +* Or, stop GC if the segment becomes fully valid caused by +* race condition along with SSR block allocation. +*/ +if ((gc_type ==BG_GC &&has_not_enough_free_secs (sbi,0 ,0 )) || +get_valid_blocks (sbi, segno, false) == + sbi->blocks_per_seg)return submitted;if (check_valid_map (sbi, segno, off) ==0 )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 67/330 s390: avoid misusing CALL_ON_STACK for task stack setup
In reply to Sasha LevinFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 7bcaad1f9fac889f5fcd1a383acf7e00d006da41 ]
CALL_ON_STACK is intended to be used for temporary stack switching with potential return to the caller.
When CALL_ON_STACK is misused to switch from nodat stack to task stack back_chain information would later lead stack unwinder from task stack into (per cpu) nodat stack which is reused for other purposes. This would yield confusing unwinding result or errors.
To avoid that introduce CALL_ON_STACK_NORETURN to be used instead. It makes sure that back_chain is zeroed and unwinder finishes gracefully ending up at task pt_regs.
--- arch/s390/include/asm/stacktrace.h | 11 +++++++++++ arch/s390/kernel/setup.c | 9 +-------- arch/s390/kernel/smp.c | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-)
arch/s390/include/asm/stacktrace.h +11 -0
@@ -111,4 +111,15 @@ struct stack_frame { r2; \ }) +#define CALL_ON_STACK_NORETURN (fn, stack) \ +({ \ + asm volatile( \ + " la 15,0(%[_stack])\n" \ + " xc %[_bc](8,15),%[_bc](15)\n" \ + " brasl 14,%[_fn]\n" \ + ::[_bc] "i" (offsetof(struct stack_frame, back_chain)), \ + [_stack] "a" (stack), [_fn] "X" (fn)); \ + BUG(); \ +}) +#endif /* _ASM_S390_STACKTRACE_H */
arch/s390/kernel/setup.c +1 -8
@@ -356,7 +356,6 @@ early_initcall(async_stack_realloc);void __init arch_call_rest_init (void ) { -struct stack_frame *frame;unsigned long stack; stack =stack_alloc ();
@@ -369,13 +368,7 @@ void __init arch_call_rest_init(void)set_task_stack_end_magic (current); stack +=STACK_INIT_OFFSET ; S390_lowcore.kernel_stack = stack; - frame = (struct stack_frame *) stack; -memset (frame,0 ,sizeof (*frame)); -/* Branch to rest_init on the new stack, never returns */ - asmvolatile ( -" la 15,0(%[_frame])\n" -" jg rest_init\n" - : : [_frame]"a" (frame)); +CALL_ON_STACK_NORETURN (rest_init, stack); }static void __init setup_lowcore_dat_off (void )
arch/s390/kernel/smp.c +1 -1
@@ -878,7 +878,7 @@ static void __no_sanitize_address smp_start_secondary(void *cpuvoid) S390_lowcore.restart_source =-1UL ;__ctl_load (S390_lowcore.cregs_save_area,0 ,15 );__load_psw_mask (PSW_KERNEL_BITS |PSW_MASK_DAT ); -CALL_ON_STACK (smp_init_secondary, S390_lowcore.kernel_stack,0 ); +CALL_ON_STACK_NORETURN (smp_init_secondary, S390_lowcore.kernel_stack); }/* Upping and downing of CPUs */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 69/330 drm/amdgpu: fix calltrace during kmd unload(v3)
In reply to Sasha LevinFrom: Monk Liu <[email protected]>
[ Upstream commit 82a829dc8c2bb03cc9b7e5beb1c5479aa3ba7831 ]
issue:
kernel would report a warning from a double unpin during the driver unloading on the CSB bo
why:
we unpin it during hw_fini, and there will be another unpin in sw_fini on CSB bo.
fix:
actually we don't need to pin/unpin it during hw_init/fini since it is created with kernel pinned, we only need to fullfill the CSB again during hw_init to prevent CSB/VRAM lost after S3
v2:get_csb in init_rlc so hw_init() will make CSIB content back even after reset or s3
v3:
use bo_create_kernel instead of bo_create_reserved for CSB otherwise the bo_free_kernel() on CSB is not aligned and would lead to its internal reserve pending there forever
take care of gfx7/8 as well
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 10 +---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 58 +------------------------ drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 + drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 40 +---------------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 40 +---------------- 5 files changed, 6 insertions(+), 144 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +1 -9
@@ -124,13 +124,12 @@ int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws)*/ int amdgpu_gfx_rlc_init_csb (struct amdgpu_device *adev) { -volatile u32 *dst_ptr;u32 dws;int r;/* allocate clear state block */ adev->gfx.rlc.clear_state_size = dws = adev->gfx.rlc.funcs->get_csb_size (adev); - r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE, + r = amdgpu_bo_create_kernel(adev, dws * 4, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, &adev->gfx.rlc.clear_state_obj, &adev->gfx.rlc.clear_state_gpu_addr,
@@ -141,13 +140,6 @@ int amdgpu_gfx_rlc_init_csb(struct amdgpu_device *adev)return r; } -/* set up the cs buffer */ - dst_ptr = adev->gfx.rlc.cs_ptr; - adev->gfx.rlc.funcs->get_csb_buffer (adev, dst_ptr); -amdgpu_bo_kunmap (adev->gfx.rlc.clear_state_obj); -amdgpu_bo_unpin (adev->gfx.rlc.clear_state_obj); -amdgpu_bo_unreserve (adev->gfx.rlc.clear_state_obj); -return 0 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -57
82 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2 -0
@@ -4554,6 +4554,8 @@ static int gfx_v7_0_hw_init(void *handle)gfx_v7_0_constants_init (adev); +/* init CSB */ + adev->gfx.rlc.funcs->get_csb_buffer (adev, adev->gfx.rlc.cs_ptr);/* init rlc */ r = adev->gfx.rlc.funcs->resume (adev);if (r)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -39
@@ -1321,39 +1321,6 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)return 0 ; } -static int gfx_v8_0_csb_vram_pin (struct amdgpu_device *adev) -{ -int r; - - r =amdgpu_bo_reserve (adev->gfx.rlc.clear_state_obj, false); -if (unlikely (r !=0 )) -return r; - - r =amdgpu_bo_pin (adev->gfx.rlc.clear_state_obj, -AMDGPU_GEM_DOMAIN_VRAM ); -if (!r) - adev->gfx.rlc.clear_state_gpu_addr = -amdgpu_bo_gpu_offset (adev->gfx.rlc.clear_state_obj); - -amdgpu_bo_unreserve (adev->gfx.rlc.clear_state_obj); - -return r; -} - -static void gfx_v8_0_csb_vram_unpin (struct amdgpu_device *adev) -{ -int r; - -if (!adev->gfx.rlc.clear_state_obj) -return ; - - r =amdgpu_bo_reserve (adev->gfx.rlc.clear_state_obj, true); -if (likely (r ==0 )) { -amdgpu_bo_unpin (adev->gfx.rlc.clear_state_obj); -amdgpu_bo_unreserve (adev->gfx.rlc.clear_state_obj); - } -} -static void gfx_v8_0_mec_fini (struct amdgpu_device *adev) {amdgpu_bo_free_kernel (&adev->gfx.mec.hpd_eop_obj,NULL ,NULL );
@@ -3917,6 +3884,7 @@ static void gfx_v8_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,static void gfx_v8_0_init_csb (struct amdgpu_device *adev) { + adev->gfx.rlc.funcs->get_csb_buffer (adev, adev->gfx.rlc.cs_ptr);/* csib */ WREG32 (mmRLC_CSIB_ADDR_HI, adev->gfx.rlc.clear_state_gpu_addr >>32 );
@@ -4837,10 +4805,6 @@ static int gfx_v8_0_hw_init(void *handle)gfx_v8_0_init_golden_registers (adev);gfx_v8_0_constants_init (adev); - r =gfx_v8_0_csb_vram_pin (adev); -if (r) -return r; - r = adev->gfx.rlc.funcs->resume (adev);if (r)return r;
@@ -4958,8 +4922,6 @@ static int gfx_v8_0_hw_fini(void *handle)pr_err ("rlc is busy, skip halt rlc\n" );amdgpu_gfx_rlc_exit_safe_mode (adev); -gfx_v8_0_csb_vram_unpin (adev); -return 0 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -39
@@ -1675,39 +1675,6 @@ static int gfx_v9_0_rlc_init(struct amdgpu_device *adev)return 0 ; } -static int gfx_v9_0_csb_vram_pin (struct amdgpu_device *adev) -{ -int r; - - r =amdgpu_bo_reserve (adev->gfx.rlc.clear_state_obj, false); -if (unlikely (r !=0 )) -return r; - - r =amdgpu_bo_pin (adev->gfx.rlc.clear_state_obj, -AMDGPU_GEM_DOMAIN_VRAM ); -if (!r) - adev->gfx.rlc.clear_state_gpu_addr = -amdgpu_bo_gpu_offset (adev->gfx.rlc.clear_state_obj); - -amdgpu_bo_unreserve (adev->gfx.rlc.clear_state_obj); - -return r; -} - -static void gfx_v9_0_csb_vram_unpin (struct amdgpu_device *adev) -{ -int r; - -if (!adev->gfx.rlc.clear_state_obj) -return ; - - r =amdgpu_bo_reserve (adev->gfx.rlc.clear_state_obj, true); -if (likely (r ==0 )) { -amdgpu_bo_unpin (adev->gfx.rlc.clear_state_obj); -amdgpu_bo_unreserve (adev->gfx.rlc.clear_state_obj); - } -} -static void gfx_v9_0_mec_fini (struct amdgpu_device *adev) {amdgpu_bo_free_kernel (&adev->gfx.mec.hpd_eop_obj,NULL ,NULL );
@@ -2596,6 +2563,7 @@ static void gfx_v9_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,static void gfx_v9_0_init_csb (struct amdgpu_device *adev) { + adev->gfx.rlc.funcs->get_csb_buffer (adev, adev->gfx.rlc.cs_ptr);/* csib */ WREG32_RLC (SOC15_REG_OFFSET (GC ,0 , mmRLC_CSIB_ADDR_HI), adev->gfx.rlc.clear_state_gpu_addr >>32 );
@@ -3888,10 +3856,6 @@ static int gfx_v9_0_hw_init(void *handle)gfx_v9_0_constants_init (adev); - r =gfx_v9_0_csb_vram_pin (adev); -if (r) -return r; - r = adev->gfx.rlc.funcs->resume (adev);if (r)return r;
@@ -3977,8 +3941,6 @@ static int gfx_v9_0_hw_fini(void *handle)gfx_v9_0_cp_enable (adev, false); adev->gfx.rlc.funcs->stop (adev); -gfx_v9_0_csb_vram_unpin (adev); -return 0 ; }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 62/330 CIFS: Use common error handling code in smb2_ioctl_query_info()
In reply to Sasha LevinFrom: Markus Elfring <[email protected]>
[ Upstream commit 2b1116bbe898aefdf584838448c6869f69851e0f ]
Move the same error code assignments so that such exception handling can be better reused at the end of this function.
This issue was detected by using the Coccinelle software.
--- fs/cifs/smb2ops.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
fs/cifs/smb2ops.c +23 -22
@@ -1565,35 +1565,32 @@ smb2_ioctl_query_info(const unsigned int xid,if (le32_to_cpu (io_rsp->OutputCount) < qi.input_buffer_length) qi.input_buffer_length =le32_to_cpu (io_rsp->OutputCount);if (qi.input_buffer_length >0 && -le32_to_cpu (io_rsp->OutputOffset) + qi.input_buffer_length > rsp_iov[1 ].iov_len) { - rc = -EFAULT ; - goto iqinf_exit; - } -if (copy_to_user (&pqi->input_buffer_length, &qi.input_buffer_length, -sizeof (qi.input_buffer_length))) { - rc = -EFAULT ; - goto iqinf_exit; - } +le32_to_cpu (io_rsp->OutputOffset) + qi.input_buffer_length + > rsp_iov[1 ].iov_len) + goto e_fault; + +if (copy_to_user (&pqi->input_buffer_length, + &qi.input_buffer_length, +sizeof (qi.input_buffer_length))) + goto e_fault; +if (copy_to_user ((void __user *)pqi +sizeof (struct smb_query_info ), (const void *)io_rsp +le32_to_cpu (io_rsp->OutputOffset), - qi.input_buffer_length)) { - rc = -EFAULT ; - goto iqinf_exit; - } + qi.input_buffer_length)) + goto e_fault; }else { pqi = (struct smb_query_info __user *)arg; qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1 ].iov_base;if (le32_to_cpu (qi_rsp->OutputBufferLength) < qi.input_buffer_length) qi.input_buffer_length =le32_to_cpu (qi_rsp->OutputBufferLength); -if (copy_to_user (&pqi->input_buffer_length, &qi.input_buffer_length, -sizeof (qi.input_buffer_length))) { - rc = -EFAULT ; - goto iqinf_exit; - } -if (copy_to_user (pqi +1 , qi_rsp->Buffer, qi.input_buffer_length)) { - rc = -EFAULT ; - goto iqinf_exit; - } +if (copy_to_user (&pqi->input_buffer_length, + &qi.input_buffer_length, +sizeof (qi.input_buffer_length))) + goto e_fault; + +if (copy_to_user (pqi +1 , qi_rsp->Buffer, + qi.input_buffer_length)) + goto e_fault; } iqinf_exit:
@@ -1609,6 +1606,10 @@ smb2_ioctl_query_info(const unsigned int xid,free_rsp_buf (resp_buftype[1 ], rsp_iov[1 ].iov_base);free_rsp_buf (resp_buftype[2 ], rsp_iov[2 ].iov_base);return rc; + +e_fault: + rc = -EFAULT ; + goto iqinf_exit; } static ssize_t
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 58/330 mt76: do not use devm API for led classdev
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 36f7e2b2bb1de86f0072cd49ca93d82b9e8fd894 ]
With the devm API, the unregister happens after the device cleanup is done, after which the struct mt76_dev which contains the led_cdev has already been freed. This leads to a use-after-free bug that can crash the system.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +10 -1
@@ -105,7 +105,15 @@ static int mt76_led_init(struct mt76_dev *dev) dev->led_al =of_property_read_bool (np,"led-active-low" ); } -return devm_led_classdev_register (dev->dev, &dev->led_cdev); +return led_classdev_register (dev->dev, &dev->led_cdev); +} + +static void mt76_led_cleanup (struct mt76_dev *dev) +{ +if (!dev->led_cdev.brightness_set && !dev->led_cdev.blink_set) +return ; + +led_classdev_unregister (&dev->led_cdev); } static void mt76_init_stream_cap(struct mt76_dev *dev,
@@ -360,6 +368,7 @@ void mt76_unregister_device(struct mt76_dev *dev) {struct ieee80211_hw *hw = dev->hw; +mt76_led_cleanup (dev);mt76_tx_status_check (dev,NULL , true);ieee80211_unregister_hw (hw); }
Signature · 7 lines
2.25.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Sasha Levin
maintainerPATCH 71/330 selftests/bpf: De-flake test_tcpbpf
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit ef8c84effce3c7a0b8196fcda8f430c815ab511c ]
It looks like BPF program that handles BPF_SOCK_OPS_STATE_CB state can race with the bpf_map_lookup_elem("global_map"); I sometimes see the failures in this test and re-running helps.
Since we know that we expect the callback to be called 3 times (one time for listener socket, two times for both ends of the connection), let's export this number and add simple retry logic around that.
Also, let's make EXPECT_EQ() not return on failure, but continue evaluating all conditions; that should make potential debugging easier.
With this fix in place I don't observe the flakiness anymore.
--- .../selftests/bpf/progs/test_tcpbpf_kern.c | 1 + tools/testing/selftests/bpf/test_tcpbpf.h | 1 + .../testing/selftests/bpf/test_tcpbpf_user.c | 25 +++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-)
tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c +1 -0
@@ -131,6 +131,7 @@ int bpf_testcb(struct bpf_sock_ops *skops) g.bytes_received = skops->bytes_received; g.bytes_acked = skops->bytes_acked; } + g.num_close_events++;bpf_map_update_elem (&global_map, &key, &g,BPF_ANY ); }
tools/testing/selftests/bpf/test_tcpbpf.h +1 -0
@@ -13,5 +13,6 @@ struct tcpbpf_globals {__u64 bytes_received;__u64 bytes_acked;__u32 num_listen; + __u32 num_close_events; };#endif
tools/testing/selftests/bpf/test_tcpbpf_user.c +18 -7
@@ -16,6 +16,9 @@#include "test_tcpbpf.h" +/* 3 comes from one listening socket + both ends of the connection */ +#define EXPECTED_CLOSE_EVENTS 3 +#define EXPECT_EQ (expected, actual, fmt) \ do { \ if ((expected) != (actual)) { \
@@ -23,13 +26,14 @@" Actual: %" fmt"\n" \" Expected: %" fmt"\n" , \ (actual), (expected)); \ - goto err; \ + ret--; \ } \ }while (0 ) int verify_result(const struct tcpbpf_globals *result) {__u32 expected_events; +int ret =0 ; expected_events = ((1 << BPF_SOCK_OPS_TIMEOUT_INIT) | (1 << BPF_SOCK_OPS_RWND_INIT) |
@@ -48,15 +52,15 @@ int verify_result(const struct tcpbpf_globals *result)EXPECT_EQ (0x80 , result->bad_cb_test_rv, PRIu32);EXPECT_EQ (0 , result->good_cb_test_rv, PRIu32);EXPECT_EQ (1 , result->num_listen, PRIu32); +EXPECT_EQ (EXPECTED_CLOSE_EVENTS , result->num_close_events, PRIu32); -return 0 ; -err: -return -1 ; +return ret; }int verify_sockopt_result (int sock_map_fd) {__u32 key =0 ; +int ret =0 ;int res;int rv;
@@ -69,9 +73,7 @@ int verify_sockopt_result(int sock_map_fd) rv =bpf_map_lookup_elem (sock_map_fd, &key, &res);EXPECT_EQ (0 , rv,"d" );EXPECT_EQ (1 , res,"d" ); -return 0 ; -err: -return -1 ; +return ret; } static int bpf_find_map(const char *test, struct bpf_object *obj,
@@ -96,6 +98,7 @@ int main(int argc, char **argv)int error =EXIT_FAILURE ;struct bpf_object *obj;int cg_fd =-1 ; +int retry =10 ;__u32 key =0 ;int rv;
@@ -134,12 +137,20 @@ int main(int argc, char **argv)if (sock_map_fd <0 ) goto err; +retry_lookup: rv =bpf_map_lookup_elem (map_fd, &key, &g);if (rv !=0 ) {printf ("FAILED: bpf_map_lookup_elem returns %d\n" , rv); goto err; } +if (g.num_close_events !=EXPECTED_CLOSE_EVENTS && retry--) { +printf ("Unexpected number of close events (%d), retrying!\n" , + g.num_close_events); +usleep (100 ); + goto retry_lookup; + } +if (verify_result (&g)) {printf ("FAILED: Wrong stats\n" ); goto err;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 61/330 SUNRPC: Capture completion of all RPC tasks
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit a264abad51d8ecb7954a2f6d9f1885b38daffc74 ]
RPC tasks on the backchannel never invoke xprt_complete_rqst(), so there is no way to report their tk_status at completion. Also, any RPC task that exits via rpc_exit_task() before it is replied to will also disappear without a trace.
Introduce a trace point that is symmetrical with rpc_task_begin that captures the termination status of each RPC task.
Sample trace output for callback requests initiated on the server:
kworker/u8:12-448 [003] 127.025240: rpc_task_end: task:50@3 flags=ASYNC|DYNAMIC|SOFT|SOFTCONN|SENT runstate=RUNNING|ACTIVE status=0 action=rpc_exit_task kworker/u8:12-448 [002] 127.567310: rpc_task_end: task:51@3 flags=ASYNC|DYNAMIC|SOFT|SOFTCONN|SENT runstate=RUNNING|ACTIVE status=0 action=rpc_exit_task kworker/u8:12-448 [001] 130.506817: rpc_task_end: task:52@3 flags=ASYNC|DYNAMIC|SOFT|SOFTCONN|SENT runstate=RUNNING|ACTIVE status=0 action=rpc_exit_task
Odd, though, that I never see trace_rpc_task_complete, either in the forward or backchannel. Should it be removed?
--- include/trace/events/sunrpc.h | 1 + net/sunrpc/sched.c | 1 + 2 files changed, 2 insertions(+)
include/trace/events/sunrpc.h +1 -0
@@ -165,6 +165,7 @@ DECLARE_EVENT_CLASS(rpc_task_running,DEFINE_RPC_RUNNING_EVENT (begin);DEFINE_RPC_RUNNING_EVENT (run_action);DEFINE_RPC_RUNNING_EVENT (complete); +DEFINE_RPC_RUNNING_EVENT (end); DECLARE_EVENT_CLASS(rpc_task_queued,
net/sunrpc/sched.c +1 -0
@@ -824,6 +824,7 @@ rpc_reset_task_statistics(struct rpc_task *task)*/ void rpc_exit_task (struct rpc_task *task) { +trace_rpc_task_end (task, task->tk_action); task->tk_action =NULL ;if (task->tk_ops->rpc_count_stats) task->tk_ops->rpc_count_stats (task, task->tk_calldata);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 70/330 arm64: insn: consistently handle exit text
In reply to Sasha LevinFrom: Mark Rutland <[email protected]>
[ Upstream commit ca2ef4ffabbef25644e02a98b0f48869f8be0375 ]
A kernel built with KASAN && FTRACE_WITH_REGS && !MODULES, produces a boot-time splat in the bowels of ftrace:
| [ 0.000000] ftrace: allocating 32281 entries in 127 pages | [ 0.000000] ------------[ cut here ]------------ | [ 0.000000] WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2019 ftrace_bug+0x27c/0x328 | [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.4.0-rc3-00008-g7f08ae53a7e3 #13 | [ 0.000000] Hardware name: linux,dummy-virt (DT) | [ 0.000000] pstate: 60000085 (nZCv daIf -PAN -UAO) | [ 0.000000] pc : ftrace_bug+0x27c/0x328 | [ 0.000000] lr : ftrace_init+0x640/0x6cc | [ 0.000000] sp : ffffa000120e7e00 | [ 0.000000] x29: ffffa000120e7e00 x28: ffff00006ac01b10 | [ 0.000000] x27: ffff00006ac898c0 x26: dfffa00000000000 | [ 0.000000] x25: ffffa000120ef290 x24: ffffa0001216df40 | [ 0.000000] x23: 000000000000018d x22: ffffa0001244c700 | [ 0.000000] x21: ffffa00011bf393c x20: ffff00006ac898c0 | [ 0.000000] x19: 00000000ffffffff x18: 0000000000001584 | [ 0.000000] x17: 0000000000001540 x16: 0000000000000007 | [ 0.000000] x15: 0000000000000000 x14: ffffa00010432770 | [ 0.000000] x13: ffff940002483519 x12: 1ffff40002483518 | [ 0.000000] x11: 1ffff40002483518 x10: ffff940002483518 | [ 0.000000] x9 : dfffa00000000000 x8 : 0000000000000001 | [ 0.000000] x7 : ffff940002483519 x6 : ffffa0001241a8c0 | [ 0.000000] x5 : ffff940002483519 x4 : ffff940002483519 | [ 0.000000] x3 : ffffa00011780870 x2 : 0000000000000001 | [ 0.000000] x1 : 1fffe0000d591318 x0 : 0000000000000000 | [ 0.000000] Call trace: | [ 0.000000] ftrace_bug+0x27c/0x328 | [ 0.000000] ftrace_init+0x640/0x6cc | [ 0.000000] start_kernel+0x27c/0x654 | [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x30/0x60 with crng_init=0 | [ 0.000000] ---[ end trace 0000000000000000 ]--- | [ 0.000000] ftrace faulted on writing | [ 0.000000] [<ffffa00011bf393c>] _GLOBAL__sub_D_65535_0___tracepoint_initcall_level+0x4/0x28 | [ 0.000000] Initializing ftrace call sites | [ 0.000000] ftrace record flags: 0 | [ 0.000000] (0) | [ 0.000000] expected tramp: ffffa000100b3344
This is due to an unfortunate combination of several factors.
Building with KASAN results in the compiler generating anonymous functions to register/unregister global variables against the shadow memory. These functions are placed in .text.startup/.text.exit, and given mangled names like _GLOBAL__sub_{I,D}_65535_0_$OTHER_SYMBOL. The kernel linker script places these in .init.text and .exit.text respectively, which are both discarded at runtime as part of initmem.
Building with FTRACE_WITH_REGS uses -fpatchable-function-entry=2, which also instruments KASAN's anonymous functions. When these are discarded with the rest of initmem, ftrace removes dangling references to these call sites.
Building without MODULES implicitly disables STRICT_MODULE_RWX, and causes arm64's patch_map() function to treat any !core_kernel_text() symbol as something that can be modified in-place. As core_kernel_text() is only true for .text and .init.text, with the latter depending on system_state < SYSTEM_RUNNING, we'll treat .exit.text as something that can be patched in-place. However, .exit.text is mapped read-only.
Hence in this configuration the ftrace init code blows up while trying to patch one of the functions generated by KASAN.
We could try to filter out the call sites in .exit.text rather than initializing them, but this would be inconsistent with how we handle .init.text, and requires hooking into core bits of ftrace. The behaviour of patch_map() is also inconsistent today, so instead let's clean that up and have it consistently handle .exit.text.
This patch teaches patch_map() to handle .exit.text at init time, preventing the boot-time splat above. The flow of patch_map() is reworked to make the logic clearer and minimize redundant conditionality.
--- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/insn.c | 22 ++++++++++++++++++---- arch/arm64/kernel/vmlinux.lds.S | 3 +++ 3 files changed, 22 insertions(+), 4 deletions(-)
arch/arm64/include/asm/sections.h +1 -0
@@ -15,6 +15,7 @@ extern char __hyp_text_start[], __hyp_text_end[];extern char __idmap_text_start[], __idmap_text_end[];extern char __initdata_begin[], __initdata_end[];extern char __inittext_begin[], __inittext_end[]; +extern char __exittext_begin[], __exittext_end[];extern char __irqentry_text_start[], __irqentry_text_end[];extern char __mmuoff_data_start[], __mmuoff_data_end[];extern char __entry_tramp_text_start[], __entry_tramp_text_end[];
arch/arm64/kernel/insn.c +18 -4
@@ -21,6 +21,7 @@#include <asm/fixmap.h> #include <asm/insn.h> #include <asm/kprobes.h> +#include <asm/sections.h> #define AARCH64_INSN_SF_BIT BIT(31)#define AARCH64_INSN_N_BIT BIT(22)
@@ -78,16 +79,29 @@ bool aarch64_insn_is_branch_imm(u32 insn)static DEFINE_RAW_SPINLOCK (patch_lock); +static bool is_exit_text (unsigned long addr) +{ +/* discarded with init text/data */ +return system_state <SYSTEM_RUNNING && + addr >= (unsigned long )__exittext_begin && + addr < (unsigned long )__exittext_end; +} + +static bool is_image_text (unsigned long addr) +{ +return core_kernel_text (addr) ||is_exit_text (addr); +} +static void __kprobes *patch_map (void *addr,int fixmap) {unsigned long uintaddr = (uintptr_t ) addr; -bool module = !core_kernel_text (uintaddr); +bool image =is_image_text (uintaddr);struct page *page; -if (module &&IS_ENABLED (CONFIG_STRICT_MODULE_RWX )) - page =vmalloc_to_page (addr); -else if (!module) +if (image) page =phys_to_page (__pa_symbol (addr)); +else if (IS_ENABLED (CONFIG_STRICT_MODULE_RWX )) + page =vmalloc_to_page (addr);else return addr;
arch/arm64/kernel/vmlinux.lds.S +3 -0
@@ -170,9 +170,12 @@ SECTIONS __inittext_begin = .; INIT_TEXT_SECTION(8) + + __exittext_begin = .; .exit.text : { ARM_EXIT_KEEP(EXIT_TEXT) } + __exittext_end = .; . = ALIGN(4); .altinstructions : {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 74/330 KVM: arm/arm64: vgic: Fix potential double free dist->spis in __kvm_vgic_destroy()
In reply to Sasha LevinFrom: Miaohe Lin <[email protected]>
[ Upstream commit 0bda9498dd45280e334bfe88b815ebf519602cc3 ]
In kvm_vgic_dist_init() called from kvm_vgic_map_resources(), if dist->vgic_model is invalid, dist->spis will be freed without set dist->spis = NULL. And in vgicv2 resources clean up path, __kvm_vgic_destroy() will be called to free allocated resources. And dist->spis will be freed again in clean up chain because we forget to set dist->spis = NULL in kvm_vgic_dist_init() failed path. So double free would happen.
--- virt/kvm/arm/vgic/vgic-init.c | 1 + 1 file changed, 1 insertion(+)
virt/kvm/arm/vgic/vgic-init.c +1 -0
@@ -177,6 +177,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)break ;default :kfree (dist->spis); + dist->spis =NULL ;return -EINVAL ; } }
Signature · 6 lines
2.25.1 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Sasha Levin
maintainerPATCH 59/330 mt76: add missing locking around ampdu action
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 1a817fa73c3b27a593aadf0029de24db1bbc1a3e ]
This is needed primarily to avoid races in dealing with rx aggregation related data structures
--- drivers/net/wireless/mediatek/mt76/mt7603/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7615/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 2 ++ 3 files changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/main.c +2 -0
@@ -561,6 +561,7 @@ mt7603_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mtxq = (struct mt76_txq *)txq->drv_priv; +mutex_lock (&dev->mt76.mutex);switch (action) {case IEEE80211_AMPDU_RX_START : mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
@@ -590,6 +591,7 @@ mt7603_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,ieee80211_stop_tx_ba_cb_irqsafe (vif, sta->addr, tid);break ; } +mutex_unlock (&dev->mt76.mutex);return 0 ; }
drivers/net/wireless/mediatek/mt76/mt7615/main.c +2 -0
@@ -455,6 +455,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mtxq = (struct mt76_txq *)txq->drv_priv; +mutex_lock (&dev->mt76.mutex);switch (action) {case IEEE80211_AMPDU_RX_START : mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
@@ -485,6 +486,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,ieee80211_stop_tx_ba_cb_irqsafe (vif, sta->addr, tid);break ; } +mutex_unlock (&dev->mt76.mutex);return 0 ; }
drivers/net/wireless/mediatek/mt76/mt76x02_util.c +2 -0
@@ -371,6 +371,7 @@ int mt76x02_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mtxq = (struct mt76_txq *)txq->drv_priv; +mutex_lock (&dev->mt76.mutex);switch (action) {case IEEE80211_AMPDU_RX_START : mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid,
@@ -400,6 +401,7 @@ int mt76x02_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,ieee80211_stop_tx_ba_cb_irqsafe (vif, sta->addr, tid);break ; } +mutex_unlock (&dev->mt76.mutex);return 0 ; }
Signature · 7 lines
2.25.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Sasha Levin
maintainerPATCH 83/330 drm/mcde: Handle pending vblank while disabling display
In reply to Sasha LevinFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 97de863673f07f424dd0666aefb4b6ecaba10171 ]
Disabling the display using MCDE currently results in a warning together with a delay caused by some timeouts:
mcde a0350000.mcde: MCDE display is disabled
------------[ cut here ]------------
WARNING: CPU: 0 PID: 20 at drivers/gpu/drm/drm_atomic_helper.c:2258 drm_atomic_helper_commit_hw_done+0xe0/0xe4
Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
Workqueue: events drm_mode_rmfb_work_fn
[<c010f468>] (unwind_backtrace) from [<c010b54c>] (show_stack+0x10/0x14)
[<c010b54c>] (show_stack) from [<c079dd90>] (dump_stack+0x84/0x98)
[<c079dd90>] (dump_stack) from [<c011d1b0>] (__warn+0xb8/0xd4)
[<c011d1b0>] (__warn) from [<c011d230>] (warn_slowpath_fmt+0x64/0xc4)
[<c011d230>] (warn_slowpath_fmt) from [<c0413048>] (drm_atomic_helper_commit_hw_done+0xe0/0xe4)
[<c0413048>] (drm_atomic_helper_commit_hw_done) from [<c04159cc>] (drm_atomic_helper_commit_tail_rpm+0x44/0x6c)
[<c04159cc>] (drm_atomic_helper_commit_tail_rpm) from [<c0415f5c>] (commit_tail+0x50/0x10c)
[<c0415f5c>] (commit_tail) from [<c04160dc>] (drm_atomic_helper_commit+0xbc/0x128)
[<c04160dc>] (drm_atomic_helper_commit) from [<c0430790>] (drm_framebuffer_remove+0x390/0x428)
[<c0430790>] (drm_framebuffer_remove) from [<c0430860>] (drm_mode_rmfb_work_fn+0x38/0x48)
[<c0430860>] (drm_mode_rmfb_work_fn) from [<c01368a8>] (process_one_work+0x1f0/0x43c)
[<c01368a8>] (process_one_work) from [<c0136d48>] (worker_thread+0x254/0x55c)
[<c0136d48>] (worker_thread) from [<c013c014>] (kthread+0x124/0x150)
[<c013c014>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
Exception stack(0xeb14dfb0 to 0xeb14dff8)
dfa0: 00000000 00000000 00000000 00000000
dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
---[ end trace 314909bcd4c7d50c ]---
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CRTC:32:crtc-0] flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CONNECTOR:34:DSI-1] flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [PLANE:31:plane-0] flip_done timed outThe reason for this is that there is a vblank event pending, but we never handle it after disabling the vblank interrupts.
Check if there is an vblank event pending when disabling the display, and clear it by sending a fake vblank event in that case.
--- drivers/gpu/drm/mcde/mcde_display.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/mcde/mcde_display.c +10 -0
@@ -946,6 +946,7 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)struct drm_crtc *crtc = &pipe->crtc;struct drm_device *drm = crtc->dev;struct mcde *mcde = drm->dev_private; +struct drm_pending_vblank_event *event;if (mcde->te_sync)drm_crtc_vblank_off (crtc);
@@ -953,6 +954,15 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)/* Disable FIFO A flow */ mcde_disable_fifo (mcde,MCDE_FIFO_A , true); + event = crtc->state->event; +if (event) { + crtc->state->event =NULL ; + +spin_lock_irq (&crtc->dev->event_lock); +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irq (&crtc->dev->event_lock); + } +dev_info (drm->dev,"MCDE display is disabled\n" ); }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 75/330 module: Remove accidental change of module_enable_x()
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
[ Upstream commit af74262337faa65d5ac2944553437d3f5fb29123 ]
When pulling in Divya Indi's patch, I made a minor fix to remove unneeded braces. I commited my fix up via "git commit -a --amend". Unfortunately, I didn't realize I had some changes I was testing in the module code, and those changes were applied to Divya's patch as well.
This reverts the accidental updates to the module code.
--- kernel/module.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/module.c +1 -5
@@ -3753,6 +3753,7 @@ static int complete_formation(struct module *mod, struct load_info *info)module_enable_ro (mod, false);module_enable_nx (mod); +module_enable_x (mod);/* Mark state as coming so strong_try_module_get() ignores us, * but kallsyms etc. can see us. */
@@ -3775,11 +3776,6 @@ static int prepare_coming_module(struct module *mod)if (err)return err; -/* Make module executable after ftrace is enabled */ -mutex_lock (&module_mutex); -module_enable_x (mod); -mutex_unlock (&module_mutex); -blocking_notifier_call_chain (&module_notify_list,MODULE_STATE_COMING , mod);return 0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 73/330 kernel/sys.c: avoid copying possible padding bytes in copy_to_user
In reply to Sasha LevinFrom: Joe Perches <[email protected]>
[ Upstream commit 5e1aada08cd19ea652b2d32a250501d09b02ff2e ]
Initialization is not guaranteed to zero padding bytes so use an explicit memset instead to avoid leaking any kernel content in any possible padding bytes.
--- kernel/sys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sys.c +3 -1
@@ -1279,11 +1279,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) { -struct oldold_utsname tmp = {}; +struct oldold_utsname tmp;if (!name)return -EFAULT ; +memset (&tmp,0 ,sizeof (tmp)); +down_read (&uts_sem);memcpy (&tmp.sysname, &utsname ()->sysname, __OLD_UTS_LEN);memcpy (&tmp.nodename, &utsname ()->nodename, __OLD_UTS_LEN);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 85/330 drm/scheduler: Avoid accessing freed bad job.
In reply to Sasha LevinFrom: Andrey Grodzovsky <[email protected]>
[ Upstream commit 135517d3565b48f4def3b1b82008bc17eb5d1c90 ]
Problem:
Due to a race between drm_sched_cleanup_jobs in sched thread and drm_sched_job_timedout in timeout work there is a possiblity that bad job was already freed while still being accessed from the timeout thread.
Fix:
Instead of just peeking at the bad job in the mirror list remove it from the list under lock and then put it back later when we are garanteed no race with main sched thread is possible which is after the thread is parked.
v2: Lock around processing ring_mirror_list in drm_sched_cleanup_jobs.
v3: Rebase on top of drm-misc-next. v2 is not needed anymore as drm_sched_get_cleanup_job already has a lock there.
v4: Fix comments to relfect latest code in drm-misc.
--- drivers/gpu/drm/scheduler/sched_main.c | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +27 -0
@@ -284,10 +284,21 @@ static void drm_sched_job_timedout(struct work_struct *work)unsigned long flags; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +/* Protects against concurrent deletion in drm_sched_get_cleanup_job */ +spin_lock_irqsave (&sched->job_list_lock, flags); job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node);if (job) { +/* +* Remove the bad job so it cannot be freed by concurrent +* drm_sched_cleanup_jobs. It will be reinserted back after sched->thread +* is parked at which point it's safe. +*/ +list_del_init (&job->node); +spin_unlock_irqrestore (&sched->job_list_lock, flags); + job->sched->ops->timedout_job (job);/*
@@ -298,6 +309,8 @@ static void drm_sched_job_timedout(struct work_struct *work) job->sched->ops->free_job (job); sched->free_guilty = false; } + }else { +spin_unlock_irqrestore (&sched->job_list_lock, flags); }spin_lock_irqsave (&sched->job_list_lock, flags);
@@ -369,6 +382,20 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad)kthread_park (sched->thread); +/* +* Reinsert back the bad job here - now it's safe as +* drm_sched_get_cleanup_job cannot race against us and release the +* bad job at this point - we parked (waited for) any in progress +* (earlier) cleanups and drm_sched_get_cleanup_job will not be called +* now until the scheduler thread is unparked. +*/ +if (bad && bad->sched == sched) +/* +* Add at the head of the queue to reflect it was the earliest +* job extracted. +*/ +list_add (&bad->node, &sched->ring_mirror_list); +/* * Iterate the job list from later to earlier one and either deactive * their HW callbacks or remove them from mirror list if they already
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 86/330 media: ti-vpe: cal: Restrict DMA to avoid memory corruption
In reply to Sasha LevinFrom: Nikhil Devshatwar <[email protected]>
[ Upstream commit 6e72eab2e7b7a157d554b8f9faed7676047be7c1 ]
When setting DMA for video capture from CSI channel, if the DMA size is not given, it ends up writing as much data as sent by the camera.
This may lead to overwriting the buffers causing memory corruption. Observed green lines on the default framebuffer.
Restrict the DMA to maximum height as specified in the S_FMT ioctl.
--- drivers/media/platform/ti-vpe/cal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/ti-vpe/cal.c +4 -2
@@ -678,12 +678,13 @@ static void pix_proc_config(struct cal_ctx *ctx) }static void cal_wr_dma_config (struct cal_ctx *ctx, -unsigned int width) +unsigned int width,unsigned int height) {u32 val; val =reg_read (ctx->dev,CAL_WR_DMA_CTRL (ctx->csi2_port));set_field (&val, ctx->csi2_port,CAL_WR_DMA_CTRL_CPORT_MASK ); +set_field (&val, height,CAL_WR_DMA_CTRL_YSIZE_MASK );set_field (&val,CAL_WR_DMA_CTRL_DTAG_PIX_DAT ,CAL_WR_DMA_CTRL_DTAG_MASK ); set_field(&val, CAL_WR_DMA_CTRL_MODE_CONST,
@@ -1306,7 +1307,8 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)csi2_lane_config (ctx);csi2_ctx_config (ctx);pix_proc_config (ctx); -cal_wr_dma_config (ctx, ctx->v_fmt.fmt.pix.bytesperline); +cal_wr_dma_config (ctx, ctx->v_fmt.fmt.pix.bytesperline, + ctx->v_fmt.fmt.pix.height);cal_wr_dma_addr (ctx, addr);csi2_ppi_enable (ctx);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 88/330 scsi: qla2xxx: Fix stuck session in GNL
In reply to Sasha LevinFrom: Quinn Tran <[email protected]>
[ Upstream commit e1217dc3edce62895595cf484af33b9e0379b7f3 ]
Fix race condition between GNL completion processing and GNL request. Late submission of GNL request was not seen by the GNL completion thread. This patch will re-submit the GNL request for late submission fcport.
--- drivers/scsi/qla2xxx/qla_init.c | 15 +++++++++++++-- drivers/scsi/qla2xxx/qla_target.c | 21 +++++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +13 -2
@@ -1002,7 +1002,7 @@ static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)set_bit (loop_id, vha->hw->loop_id_map); wwn =wwn_to_u64 (e->port_name); - ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x20e8, + ql_dbg(ql_dbg_disc, vha, 0x20e8, "%s %8phC %02x:%02x:%02x CLS %x/%x lid %x \n", __func__, (void *)&wwn, e->port_id[2], e->port_id[1], e->port_id[0], e->current_login_state, e->last_login_state,
@@ -1061,6 +1061,16 @@ static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)spin_lock_irqsave (&vha->hw->tgt.sess_lock, flags); vha->gnl.sent =0 ; +if (!list_empty (&vha->gnl.fcports)) { +/* retrigger gnl */ +list_for_each_entry_safe (fcport, tf, &vha->gnl.fcports, + gnl_entry) { +list_del_init (&fcport->gnl_entry); + fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +if (qla24xx_post_gnl_work (vha, fcport) ==QLA_SUCCESS ) +break ; + } + }spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags); sp->free (sp);
@@ -1995,7 +2005,7 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea)qla24xx_post_prli_work (vha, ea->fcport); }else {ql_dbg (ql_dbg_disc, vha,0x20ea , -"%s %d %8phC LoopID 0x%x in use with %06x. post gnl\n" , +"%s %d %8phC LoopID 0x%x in use with %06x. post gpdb\n" , __func__, __LINE__, ea->fcport->port_name, ea->fcport->loop_id, ea->fcport->d_id.b24);
@@ -2066,6 +2076,7 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea)set_bit (lid, vha->hw->loop_id_map); ea->fcport->loop_id = lid; ea->fcport->keep_nport_handle =0 ; + ea->fcport->logout_on_delete =1 ;qlt_schedule_sess_for_deletion (ea->fcport); }break ;
drivers/scsi/qla2xxx/qla_target.c +15 -6
@@ -957,7 +957,7 @@ void qlt_free_session_done(struct work_struct *work)struct qlt_plogi_ack_t *own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN ]; - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf084, + ql_dbg(ql_dbg_disc, vha, 0xf084, "%s: se_sess %p / sess %p from port %8phC loop_id %#04x" " s_id %02x:%02x:%02x logout %d keep %d els_logo %d\n", __func__, sess->se_sess, sess, sess->port_name, sess->loop_id,
@@ -1024,7 +1024,7 @@ void qlt_free_session_done(struct work_struct *work)while (!READ_ONCE (sess->logout_completed)) {if (!traced) { -ql_dbg (ql_dbg_tgt_mgt, vha,0xf086 , +ql_dbg (ql_dbg_disc, vha,0xf086 ,"%s: waiting for sess %p logout\n" , __func__, sess); traced = true;
@@ -1045,6 +1045,10 @@ void qlt_free_session_done(struct work_struct *work) (struct imm_ntfy_from_isp *)sess->iocb, SRB_NACK_LOGO); } +spin_lock_irqsave (&vha->work_lock, flags); + sess->flags &= ~FCF_ASYNC_SENT ; +spin_unlock_irqrestore (&vha->work_lock, flags); +spin_lock_irqsave (&ha->tgt.sess_lock, flags);if (sess->se_sess) { sess->se_sess =NULL ;
@@ -1108,7 +1112,7 @@ void qlt_free_session_done(struct work_struct *work)spin_unlock_irqrestore (&ha->tgt.sess_lock, flags); sess->free_pending =0 ; -ql_dbg (ql_dbg_tgt_mgt, vha,0xf001 , +ql_dbg (ql_dbg_disc, vha,0xf001 ,"Unregistration of sess %p %8phC finished fcp_cnt %d\n" , sess, sess->port_name, vha->fcport_count);
@@ -1151,6 +1155,11 @@ void qlt_unreg_sess(struct fc_port *sess)return ; } sess->free_pending =1 ; +/* +* Use FCF_ASYNC_SENT flag to block other cmds used in sess +* management from being sent. +*/ + sess->flags |=FCF_ASYNC_SENT ;spin_unlock_irqrestore (&sess->vha->work_lock, flags);if (sess->se_sess)
@@ -4580,7 +4589,7 @@ qlt_find_sess_invalidate_other(scsi_qla_host_t *vha, uint64_t wwn,/* find other sess with nport_id collision */ if (port_id.b24 == other_sess->d_id.b24) {if (loop_id != other_sess->loop_id) { -ql_dbg (ql_dbg_tgt_tmr, vha,0x1000c , +ql_dbg (ql_dbg_disc, vha,0x1000c ,"Invalidating sess %p loop_id %d wwn %llx.\n" , other_sess, other_sess->loop_id, other_wwn);
@@ -4596,7 +4605,7 @@ qlt_find_sess_invalidate_other(scsi_qla_host_t *vha, uint64_t wwn,* Another wwn used to have our s_id/loop_id * kill the session, but don't free the loop_id */ -ql_dbg (ql_dbg_tgt_tmr, vha,0xf01b , +ql_dbg (ql_dbg_disc, vha,0xf01b ,"Invalidating sess %p loop_id %d wwn %llx.\n" , other_sess, other_sess->loop_id, other_wwn);
@@ -4611,7 +4620,7 @@ qlt_find_sess_invalidate_other(scsi_qla_host_t *vha, uint64_t wwn,/* find other sess with nport handle collision */ if ((loop_id == other_sess->loop_id) && (loop_id !=FC_NO_LOOP_ID )) { -ql_dbg (ql_dbg_tgt_tmr, vha,0x1000d , +ql_dbg (ql_dbg_disc, vha,0x1000d ,"Invalidating sess %p loop_id %d wwn %llx.\n" , other_sess, other_sess->loop_id, other_wwn);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 94/330 drm/amd/display: Initialize DSC PPS variables to 0
In reply to Sasha LevinFrom: David Francis <[email protected]>
[ Upstream commit b6adc57cff616da18ff8cff028d2ddf585c97334 ]
For DSC MST, sometimes monitors would break out in full-screen static. The issue traced back to the PPS generation code, where these variables were being used uninitialized and were picking up garbage.
memset to 0 to avoid this
--- drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | 3 +++ drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +3 -0
@@ -496,6 +496,9 @@ bool dp_set_dsc_pps_sdp(struct pipe_ctx *pipe_ctx, bool enable)struct dsc_config dsc_cfg;uint8_t dsc_packed_pps[128 ]; +memset (&dsc_cfg,0 ,sizeof (dsc_cfg)); +memset (dsc_packed_pps,0 ,128 ); +/* Enable DSC hw block */ dsc_cfg.pic_width = stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right; dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom;
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c +3 -0
@@ -207,6 +207,9 @@ static bool dsc2_get_packed_pps(struct display_stream_compressor *dsc, const strstruct dsc_reg_values dsc_reg_vals;struct dsc_optc_config dsc_optc_cfg; +memset (&dsc_reg_vals,0 ,sizeof (dsc_reg_vals)); +memset (&dsc_optc_cfg,0 ,sizeof (dsc_optc_cfg)); +DC_LOG_DSC ("Getting packed DSC PPS for DSC Config:" );dsc_config_log (dsc, dsc_cfg);DC_LOG_DSC ("DSC Picture Parameter Set (PPS):" );
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 99/330 s390/cpum_sf: Use kzalloc and minor changes
In reply to Sasha LevinFrom: Thomas Richter <[email protected]>
[ Upstream commit 32dab6828c42f087439d3e2617dc7283546bd8f7 ]
Use kzalloc() to allocate auxiliary buffer structure initialized with all zeroes to avoid random value in trace output.
Avoid double access to SBD hardware flags.
--- arch/s390/kernel/perf_cpum_sf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/s390/kernel/perf_cpum_sf.c +4 -5
@@ -1429,8 +1429,8 @@ static int aux_output_begin(struct perf_output_handle *handle, idx = aux->empty_mark +1 ;for (i =0 ; i < range_scan; i++, idx++) { te =aux_sdb_trailer (aux, idx); - te->flags = te->flags & ~SDB_TE_BUFFER_FULL_MASK ; - te->flags = te->flags & ~SDB_TE_ALERT_REQ_MASK ; + te->flags &= ~(SDB_TE_BUFFER_FULL_MASK | +SDB_TE_ALERT_REQ_MASK ); te->overflow =0 ; }/* Save the position of empty SDBs */
@@ -1477,8 +1477,7 @@ static bool aux_set_alert(struct aux_buffer *aux, unsigned long alert_index, te =aux_sdb_trailer (aux, alert_index); do { orig_flags = te->flags; - orig_overflow = te->overflow; - *overflow = orig_overflow; + *overflow = orig_overflow = te->overflow; if (orig_flags & SDB_TE_BUFFER_FULL_MASK) { /* * SDB is already set by hardware.
@@ -1712,7 +1711,7 @@ static void *aux_buffer_setup(struct perf_event *event, void **pages, }/* Allocate aux_buffer struct for the event */ - aux =kmalloc (sizeof (struct aux_buffer ),GFP_KERNEL ); + aux =kzalloc (sizeof (struct aux_buffer ),GFP_KERNEL );if (!aux) goto no_aux; sfb = &aux->sfb;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 54/330 ubi: Fix producing anchor PEBs
In reply to Sasha LevinFrom: Sascha Hauer <[email protected]>
[ Upstream commit f9c34bb529975fe9f85b870a80c53a83a3c5a182 ]
When a new fastmap is about to be written UBI must make sure it has a free block for a fastmap anchor available. For this ubi_update_fastmap() calls ubi_ensure_anchor_pebs(). This stopped working with 2e8f08deabbc ("ubi: Fix races around ubi_refill_pools()"), with this commit the wear leveling code is blocked and can no longer produce free PEBs. UBI then more often than not falls back to write the new fastmap anchor to the same block it was already on which means the same erase block gets erased during each fastmap write and wears out quite fast.
As the locking prevents us from producing the anchor PEB when we actually need it, this patch changes the strategy for creating the anchor PEB. We no longer create it on demand right before we want to write a fastmap, but instead we create an anchor PEB right after we have written a fastmap. This gives us enough time to produce a new anchor PEB before it is needed. To make sure we have an anchor PEB for the very first fastmap write we call ubi_ensure_anchor_pebs() during initialisation as well.
--- drivers/mtd/ubi/fastmap-wl.c | 31 ++++++++++++++++++------------- drivers/mtd/ubi/fastmap.c | 14 +++++--------- drivers/mtd/ubi/ubi.h | 6 ++++-- drivers/mtd/ubi/wl.c | 32 ++++++++++++++------------------ drivers/mtd/ubi/wl.h | 1 - 5 files changed, 41 insertions(+), 43 deletions(-)
drivers/mtd/ubi/fastmap-wl.c +18 -13
@@ -57,18 +57,6 @@ static void return_unused_pool_pebs(struct ubi_device *ubi, } } -static int anchor_pebs_available (struct rb_root *root) -{ -struct rb_node *p; -struct ubi_wl_entry *e; - -ubi_rb_for_each_entry (p, e, root, u.rb) -if (e->pnum <UBI_FM_MAX_START ) -return 1 ; - -return 0 ; -} -/** * ubi_wl_get_fm_peb - find a physical erase block with a given maximal number. * @ubi: UBI device description object
@@ -277,8 +265,26 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)int ubi_ensure_anchor_pebs (struct ubi_device *ubi) {struct ubi_work *wrk; +struct ubi_wl_entry *anchor;spin_lock (&ubi->wl_lock); + +/* Do we already have an anchor? */ +if (ubi->fm_anchor) { +spin_unlock (&ubi->wl_lock); +return 0 ; + } + +/* See if we can find an anchor PEB on the list of free PEBs */ + anchor =ubi_wl_get_fm_peb (ubi,1 ); +if (anchor) { + ubi->fm_anchor = anchor; +spin_unlock (&ubi->wl_lock); +return 0 ; + } + +/* No luck, trigger wear leveling to produce a new anchor PEB */ + ubi->fm_do_produce_anchor =1 ;if (ubi->wl_scheduled) {spin_unlock (&ubi->wl_lock);return 0 ;
@@ -294,7 +300,6 @@ int ubi_ensure_anchor_pebs(struct ubi_device *ubi)return -ENOMEM ; } - wrk->anchor =1 ; wrk->func = &wear_leveling_worker;__schedule_ubi_work (ubi, wrk);return 0 ;
drivers/mtd/ubi/fastmap.c +5 -9
@@ -1543,14 +1543,6 @@ int ubi_update_fastmap(struct ubi_device *ubi)return 0 ; } - ret =ubi_ensure_anchor_pebs (ubi); -if (ret) { -up_write (&ubi->fm_eba_sem); -up_write (&ubi->work_sem); -up_write (&ubi->fm_protect); -return ret; - } - new_fm =kzalloc (sizeof (*new_fm),GFP_KERNEL );if (!new_fm) {up_write (&ubi->fm_eba_sem);
@@ -1621,7 +1613,8 @@ int ubi_update_fastmap(struct ubi_device *ubi) }spin_lock (&ubi->wl_lock); - tmp_e =ubi_wl_get_fm_peb (ubi,1 ); + tmp_e = ubi->fm_anchor; + ubi->fm_anchor =NULL ;spin_unlock (&ubi->wl_lock);if (old_fm) {
@@ -1673,6 +1666,9 @@ out_unlock:up_write (&ubi->work_sem);up_write (&ubi->fm_protect);kfree (old_fm); + +ubi_ensure_anchor_pebs (ubi); +return ret; err:
drivers/mtd/ubi/ubi.h +4 -2
@@ -491,6 +491,8 @@ struct ubi_debug_info {* @fm_work: fastmap work queue * @fm_work_scheduled: non-zero if fastmap work was scheduled * @fast_attach: non-zero if UBI was attached by fastmap +* @fm_anchor: The next anchor PEB to use for fastmap +* @fm_do_produce_anchor: If true produce an anchor PEB in wl * * @used: RB-tree of used physical eraseblocks * @erroneous: RB-tree of erroneous used physical eraseblocks
@@ -599,6 +601,8 @@ struct ubi_device {struct work_struct fm_work;int fm_work_scheduled;int fast_attach; +struct ubi_wl_entry *fm_anchor; +int fm_do_produce_anchor;/* Wear-leveling sub-system's stuff */ struct rb_root used;
@@ -789,7 +793,6 @@ struct ubi_attach_info {* @vol_id: the volume ID on which this erasure is being performed * @lnum: the logical eraseblock number * @torture: if the physical eraseblock has to be tortured -* @anchor: produce a anchor PEB to by used by fastmap * * The @func pointer points to the worker function. If the @shutdown argument is * not zero, the worker has to free the resources and exit immediately as the
@@ -805,7 +808,6 @@ struct ubi_work {int vol_id;int lnum;int torture; -int anchor; };#include "debug.h"
drivers/mtd/ubi/wl.c +14 -18
@@ -339,13 +339,6 @@ static struct ubi_wl_entry *find_wl_entry(struct ubi_device *ubi, } } -/* If no fastmap has been written and this WL entry can be used -* as anchor PEB, hold it back and return the second best WL entry -* such that fastmap can use the anchor PEB later. */ -if (prev_e && !ubi->fm_disabled && - !ubi->fm && e->pnum <UBI_FM_MAX_START ) -return prev_e; -return e; }
@@ -656,9 +649,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, {int err, scrubbing =0 , torture =0 , protect =0 , erroneous =0 ;int erase =0 , keep =0 , vol_id =-1 , lnum =-1 ; -#ifdef CONFIG_MTD_UBI_FASTMAP -int anchor = wrk->anchor; -#endif struct ubi_wl_entry *e1, *e2;struct ubi_vid_io_buf *vidb;struct ubi_vid_hdr *vid_hdr;
@@ -698,11 +688,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, }#ifdef CONFIG_MTD_UBI_FASTMAP -/* Check whether we need to produce an anchor PEB */ -if (!anchor) - anchor = !anchor_pebs_available (&ubi->free); - -if (anchor) { +if (ubi->fm_do_produce_anchor) { e1 =find_anchor_wl_entry (&ubi->used);if (!e1) goto out_cancel;
@@ -719,6 +705,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,self_check_in_wl_tree (ubi, e1, &ubi->used);rb_erase (&e1->u.rb, &ubi->used);dbg_wl ("anchor-move PEB %d to PEB %d" , e1->pnum, e2->pnum); + ubi->fm_do_produce_anchor = 0; }else if (!ubi->scrub.rb_node) {#else if (!ubi->scrub.rb_node) {
@@ -1051,7 +1038,6 @@ static int ensure_wear_leveling(struct ubi_device *ubi, int nested) goto out_cancel; } - wrk->anchor =0 ; wrk->func = &wear_leveling_worker;if (nested)__schedule_ubi_work (ubi, wrk);
@@ -1093,8 +1079,15 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk) err =sync_erase (ubi, e, wl_wrk->torture);if (!err) {spin_lock (&ubi->wl_lock); -wl_tree_add (e, &ubi->free); - ubi->free_count++; + +if (!ubi->fm_anchor && e->pnum <UBI_FM_MAX_START ) { + ubi->fm_anchor = e; + ubi->fm_do_produce_anchor =0 ; + }else { +wl_tree_add (e, &ubi->free); + ubi->free_count++; + } +spin_unlock (&ubi->wl_lock);/*
@@ -1882,6 +1875,9 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)if (err) goto out_free; +#ifdef CONFIG_MTD_UBI_FASTMAP +ubi_ensure_anchor_pebs (ubi); +#endif return 0 ; out_free:
drivers/mtd/ubi/wl.h +0 -1
@@ -2,7 +2,6 @@#ifndef UBI_WL_H #define UBI_WL_H #ifdef CONFIG_MTD_UBI_FASTMAP -static int anchor_pebs_available (struct rb_root *root);static void update_fastmap_work_fn (struct work_struct *wrk);static struct ubi_wl_entry *find_anchor_wl_entry (struct rb_root *root);static struct ubi_wl_entry *get_peb_for_wl (struct ubi_device *ubi);
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sasha Levin
maintainerPATCH 101/330 powerpc/powernv/ioda: Fix ref count for devices with their own PE
In reply to Sasha LevinFrom: Frederic Barrat <[email protected]>
[ Upstream commit 05dd7da76986937fb288b4213b1fa10dbe0d1b33 ]
The pci_dn structure used to store a pointer to the struct pci_dev, so taking a reference on the device was required. However, the pci_dev pointer was later removed from the pci_dn structure, but the reference was kept for the npu device.
See commit 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn").
We don't need to take a reference on the device when assigning the PE as the struct pnv_ioda_pe is cleaned up at the same time as the (physical) device is released. Doing so prevents the device from being released, which is a problem for opencapi devices, since we want to be able to remove them through PCI hotplug.
Now the ugly part: nvlink npu devices are not meant to be released. Because of the above, we've always leaked a reference and simply removing it now is dangerous and would likely require more work. There's currently no release device callback for nvlink devices for example. So to be safe, this patch leaks a reference on the npu device, but only for nvlink and not opencapi.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +12 -7
@@ -1062,14 +1062,13 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)return NULL ; } -/* NOTE: We get only one ref to the pci_dev for the pdn, not for the -* pointer in the PE data structure, both should be destroyed at the -* same time. However, this needs to be looked at more closely again -* once we actually start removing things (Hotplug, SR-IOV, ...) +/* NOTE: We don't get a reference for the pointer in the PE +* data structure, both the device and PE structures should be +* destroyed at the same time. However, removing nvlink +* devices will need some work. * * At some point we want to remove the PDN completely anyways */ -pci_dev_get (dev); pdn->pe_number = pe->pe_number; pe->flags =PNV_IODA_PE_DEV ; pe->pdev = dev;
@@ -1084,7 +1083,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)pnv_ioda_free_pe (pe); pdn->pe_number =IODA_INVALID_PE ; pe->pdev =NULL ; -pci_dev_put (dev);return NULL ; }
@@ -1205,6 +1203,14 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)struct pci_controller *hose =pci_bus_to_host (npu_pdev->bus);struct pnv_phb *phb = hose->private_data; +/* +* Intentionally leak a reference on the npu device (for +* nvlink only; this is not an opencapi path) to make sure it +* never goes away, as it's been the case all along and some +* work is needed otherwise. +*/ +pci_dev_get (npu_pdev); +/* * Due to a hardware errata PE#0 on the NPU is reserved for * error handling. This means we only have three PEs remaining
@@ -1228,7 +1234,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)*/ dev_info (&npu_pdev->dev,"Associating to existing PE %x\n" , pe_num); -pci_dev_get (npu_pdev); npu_pdn =pci_get_pdn (npu_pdev); rid = npu_pdev->bus->number <<8 | npu_pdn->devfn; npu_pdn->pe_number = pe_num;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 102/330 powerpc/eeh: Only dump stack once if an MMIO loop is detected
In reply to Sasha LevinFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 4e0942c0302b5ad76b228b1a7b8c09f658a1d58a ]
Many drivers don't check for errors when they get a 0xFFs response from an MMIO load. As a result after an EEH event occurs a driver can get stuck in a polling loop unless it some kind of internal timeout logic.
Currently EEH tries to detect and report stuck drivers by dumping a stack trace after eeh_dev_check_failure() is called EEH_MAX_FAILS times on an already frozen PE. The value of EEH_MAX_FAILS was chosen so that a dump would occur every few seconds if the driver was spinning in a loop. This results in a lot of spurious stack traces in the kernel log.
Fix this by limiting it to printing one stack trace for each PE freeze. If the driver is truely stuck the kernel's hung task detector is better suited to reporting the probelm anyway.
--- arch/powerpc/kernel/eeh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/eeh.c +1 -1
@@ -503,7 +503,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) rc =1 ;if (pe->state &EEH_PE_ISOLATED ) { pe->check_count++; -if (pe->check_count %EEH_MAX_FAILS ==0 ) { +if (pe->check_count ==EEH_MAX_FAILS ) { dn =pci_device_to_OF_node (dev);if (dn) location = of_get_property(dn, "ibm,loc-code",
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 104/330 tracing: Set kernel_stack's caller size properly
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit cbc3b92ce037f5e7536f6db157d185cd8b8f615c ]
I noticed when trying to use the trace-cmd python interface that reading the raw buffer wasn't working for kernel_stack events. This is because it uses a stubbed version of __dynamic_array that doesn't do the __data_loc trick and encode the length of the array into the field. Instead it just shows up as a size of 0. So change this to __array and set the len to FTRACE_STACK_ENTRIES since this is what we actually do in practice and matches how user_stack_trace works.
--- kernel/trace/trace_entries.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_entries.h +1 -1
@@ -174,7 +174,7 @@ FTRACE_ENTRY(kernel_stack, stack_entry,F_STRUCT (__field (int ,size ) - __dynamic_array(unsigned long, caller ) + __array( unsigned long, caller, FTRACE_STACK_ENTRIES ) ), F_printk("\t=> %ps\n\t=> %ps\n\t=> %ps\n"
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 108/330 ceph: ensure we have a new cap before continuing in fill_inode
In reply to Sasha LevinFrom: Jeff Layton <[email protected]>
[ Upstream commit 9a6bed4fe0c8bf57785cbc4db9f86086cb9b193d ]
If the caller passes in a NULL cap_reservation, and we can't allocate one then ensure that we fail gracefully.
--- fs/ceph/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ceph/inode.c +4 -1
@@ -754,8 +754,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page, info_caps =le32_to_cpu (info->cap.caps);/* prealloc new cap struct */ -if (info_caps &&ceph_snap (inode) ==CEPH_NOSNAP ) +if (info_caps &&ceph_snap (inode) ==CEPH_NOSNAP ) { new_cap =ceph_get_cap (mdsc, caps_reservation); +if (!new_cap) +return -ENOMEM ; + }/* * prealloc xattr data, if it looks like we'll need it. only
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 105/330 ext4: make dioread_nolock the default
In reply to Sasha LevinFrom: Theodore Ts'o <[email protected]>
[ Upstream commit 244adf6426ee31a83f397b700d964cff12a247d3 ]
This fixes the direct I/O versus writeback race which can reveal stale data, and it improves the tail latency of commits on slow devices.
--- fs/ext4/super.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ext4/super.c +4 -3
@@ -1546,6 +1546,7 @@ static const match_table_t tokens = { {Opt_auto_da_alloc, "auto_da_alloc"}, {Opt_noauto_da_alloc, "noauto_da_alloc"}, {Opt_dioread_nolock, "dioread_nolock"}, + {Opt_dioread_lock, "nodioread_nolock"}, {Opt_dioread_lock, "dioread_lock"}, {Opt_discard, "discard"}, {Opt_nodiscard, "nodiscard"},
@@ -3750,6 +3751,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)set_opt (sb,NO_UID32 );/* xattr user namespace & acls are now defaulted on */ set_opt (sb,XATTR_USER ); +set_opt (sb,DIOREAD_NOLOCK );#ifdef CONFIG_EXT4_FS_POSIX_ACL set_opt (sb,POSIX_ACL );#endif
@@ -3927,9 +3929,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)#endif if (test_opt (sb,DATA_FLAGS ) ==EXT4_MOUNT_JOURNAL_DATA ) { -printk_once (KERN_WARNING "EXT4-fs: Warning: mounting " -"with data=journal disables delayed " -"allocation and O_DIRECT support!\n" ); +printk_once (KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, and O_DIRECT support!\n" ); +clear_opt (sb,DIOREAD_NOLOCK );if (test_opt2 (sb,EXPLICIT_DELALLOC )) {ext4_msg (sb,KERN_ERR ,"can't mount with " "both data=journal and delalloc" );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 111/330 Bluetooth: Fix refcount use-after-free issue
In reply to Sasha LevinFrom: Manish Mandlik <[email protected]>
[ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ]
There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time.
If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is:
A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill()
where,sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED.
In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied.
In the race condition, following occurs:
A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill()
In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug.
Similar condition occurs at other places where teardown/sock_kill is happening:
l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill()
l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill()
l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill()
l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill()
Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan.
--- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-)
net/bluetooth/l2cap_core.c +15 -11
@@ -419,6 +419,9 @@ static void l2cap_chan_timeout(struct work_struct *work)BT_DBG ("chan %p state %s" , chan,state_to_string (chan->state));mutex_lock (&conn->chan_lock); +/* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling +* this work. No need to call l2cap_chan_hold(chan) here again. +*/ l2cap_chan_lock (chan);if (chan->state ==BT_CONNECTED || chan->state ==BT_CONFIG )
@@ -431,12 +434,12 @@ static void l2cap_chan_timeout(struct work_struct *work)l2cap_chan_close (chan, reason); -l2cap_chan_unlock (chan); - chan->ops->close (chan); -mutex_unlock (&conn->chan_lock); +l2cap_chan_unlock (chan);l2cap_chan_put (chan); + +mutex_unlock (&conn->chan_lock); }struct l2cap_chan *l2cap_chan_create (void )
@@ -1734,9 +1737,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)l2cap_chan_del (chan, err); -l2cap_chan_unlock (chan); - chan->ops->close (chan); + +l2cap_chan_unlock (chan);l2cap_chan_put (chan); }
@@ -4355,6 +4358,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,return 0 ; } +l2cap_chan_hold (chan);l2cap_chan_lock (chan); rsp.dcid =cpu_to_le16 (chan->scid);
@@ -4363,12 +4367,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown (chan); -l2cap_chan_hold (chan);l2cap_chan_del (chan,ECONNRESET ); -l2cap_chan_unlock (chan); - chan->ops->close (chan); + +l2cap_chan_unlock (chan);l2cap_chan_put (chan);mutex_unlock (&conn->chan_lock);
@@ -4400,20 +4403,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,return 0 ; } +l2cap_chan_hold (chan);l2cap_chan_lock (chan);if (chan->state !=BT_DISCONN ) {l2cap_chan_unlock (chan); +l2cap_chan_put (chan);mutex_unlock (&conn->chan_lock);return 0 ; } -l2cap_chan_hold (chan);l2cap_chan_del (chan,0 ); -l2cap_chan_unlock (chan); - chan->ops->close (chan); + +l2cap_chan_unlock (chan);l2cap_chan_put (chan);mutex_unlock (&conn->chan_lock);
net/bluetooth/l2cap_sock.c +13 -3
@@ -1042,7 +1042,7 @@ done: }/* Kill socket (only if zapped and orphan) -* Must be called on unlocked socket. +* Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill (struct sock *sk) {
@@ -1203,8 +1203,15 @@ static int l2cap_sock_release(struct socket *sock) err =l2cap_sock_shutdown (sock,2 ); +l2cap_chan_hold (l2cap_pi (sk)->chan); +l2cap_chan_lock (l2cap_pi (sk)->chan); +sock_orphan (sk);l2cap_sock_kill (sk); + +l2cap_chan_unlock (l2cap_pi (sk)->chan); +l2cap_chan_put (l2cap_pi (sk)->chan); +return err; }
@@ -1222,12 +1229,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)BT_DBG ("child chan %p state %s" , chan,state_to_string (chan->state)); +l2cap_chan_hold (chan);l2cap_chan_lock (chan); +__clear_chan_timer (chan);l2cap_chan_close (chan,ECONNRESET ); -l2cap_chan_unlock (chan); -l2cap_sock_kill (sk); + +l2cap_chan_unlock (chan); +l2cap_chan_put (chan); } }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 112/330 mm/swapfile.c: swap_next should increase position index
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit 10c8d69f314d557d94d74ec492575ae6a4f1eb1c ]
If seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
In Aug 2018 NeilBrown noticed commit 1f4aace60b0e ("fs/seq_file.c:
simplify seq_file iteration code and interface") "Some ->next functions do not increment *pos when they return NULL... Note that such ->next functions are buggy and should be fixed. A simple demonstration is
dd if=/proc/swaps bs=1000 skip=1
Choose any block size larger than the size of /proc/swaps. This will always show the whole last line of /proc/swaps"
Described problem is still actual. If you make lseek into middle of last output line following read will output end of last line and whole last line once again.
$ dd if=/proc/swaps bs=1 # usual output Filename Type Size Used Priority /dev/dm-0 partition 4194812 97536 -2 104+0 records in 104+0 records out 104 bytes copied
$ dd if=/proc/swaps bs=40 skip=1 # last line was generated twice dd: /proc/swaps: cannot skip to specified offset v/dm-0 partition 4194812 97536 -2 /dev/dm-0 partition 4194812 97536 -2 3+1 records in 3+1 records out 131 bytes copied
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +1 -1
@@ -2737,10 +2737,10 @@ static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)else type = si->type +1 ; + ++(*pos);for (; (si =swap_type_to_swap_info (type)); type++) {if (!(si->flags &SWP_USED ) || !si->swap_map)continue ; - ++*pos;return si; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 113/330 mm: pagewalk: fix termination condition in walk_pte_range()
In reply to Sasha LevinFrom: Steven Price <[email protected]>
[ Upstream commit c02a98753e0a36ba65a05818626fa6adeb4e7c97 ]
If walk_pte_range() is called with a 'end' argument that is beyond the last page of memory (e.g. ~0UL) then the comparison between 'addr' and 'end' will always fail and the loop will be infinite. Instead change the comparison to >= while accounting for overflow.
--- mm/pagewalk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/pagewalk.c +2 -2
@@ -16,9 +16,9 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, err = ops->pte_entry (pte, addr, addr +PAGE_SIZE , walk);if (err)break ; - addr +=PAGE_SIZE ; -if (addr == end) +if (addr >= end -PAGE_SIZE )break ; + addr +=PAGE_SIZE ; pte++; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 65/330 ASoC: max98090: remove msleep in PLL unlocked workaround
In reply to Sasha LevinFrom: Tzung-Bi Shih <[email protected]>
[ Upstream commit acb874a7c049ec49d8fc66c893170fb42c01bdf7 ]
It was observed Baytrail-based chromebooks could cause continuous PLL unlocked when using playback stream and capture stream simultaneously. Specifically, starting a capture stream after started a playback stream. As a result, the audio data could corrupt or turn completely silent.
As the datasheet suggested, the maximum PLL lock time should be 7 msec. The workaround resets the codec softly by toggling SHDN off and on if PLL failed to lock for 10 msec. Notably, there is no suggested hold time for SHDN off.
On Baytrail-based chromebooks, it would easily happen continuous PLL unlocked if there is a 10 msec delay between SHDN off and on. Removes the msleep().
--- sound/soc/codecs/max98090.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +7 -1
@@ -2112,10 +2112,16 @@ static void max98090_pll_work(struct max98090_priv *max98090)dev_info_ratelimited (component->dev,"PLL unlocked\n" ); +/* +* As the datasheet suggested, the maximum PLL lock time should be +* 7 msec. The workaround resets the codec softly by toggling SHDN +* off and on if PLL failed to lock for 10 msec. Notably, there is +* no suggested hold time for SHDN off. +*/ +/* Toggle shutdown OFF then ON */ snd_soc_component_update_bits (component,M98090_REG_DEVICE_SHUTDOWN ,M98090_SHDNN_MASK ,0 ); -msleep (10 );snd_soc_component_update_bits (component,M98090_REG_DEVICE_SHUTDOWN ,M98090_SHDNN_MASK ,M98090_SHDNN_MASK );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 119/330 drm/amd/display: fix workaround for incorrect double buffer register for DLG ADL and TTU
In reply to Sasha LevinFrom: Tony Cheng <[email protected]>
[ Upstream commit 85e148fb963d27152a14e6d399a47aed9bc99c15 ]
[Why]
these registers should have been double buffered. SW workaround we will have SW program the more aggressive (lower) values whenever we are upating this register, so we will not have underflow at expense of less optimzal request pattern.
[How]
there is a driver bug where we don't check for 0, which is uninitialzed HW default. since 0 is smaller than any value we need to program, driver end up with not programming these registers
--- .../gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c +25 -10
@@ -73,32 +73,47 @@ void apply_DEDCN21_142_wa_for_hostvm_deadline( struct _vcs_dpi_display_dlg_regs_st *dlg_attr) {struct dcn21_hubp *hubp21 =TO_DCN21_HUBP (hubp); -uint32_t cur_value; +uint32_t refcyc_per_vm_group_vblank; +uint32_t refcyc_per_vm_req_vblank; +uint32_t refcyc_per_vm_group_flip; +uint32_t refcyc_per_vm_req_flip; +const uint32_t uninitialized_hw_default =0 ; -REG_GET (VBLANK_PARAMETERS_5 ,REFCYC_PER_VM_GROUP_VBLANK , &cur_value); -if (cur_value > dlg_attr->refcyc_per_vm_group_vblank) +REG_GET (VBLANK_PARAMETERS_5 , +REFCYC_PER_VM_GROUP_VBLANK , &refcyc_per_vm_group_vblank); + +if (refcyc_per_vm_group_vblank == uninitialized_hw_default || + refcyc_per_vm_group_vblank > dlg_attr->refcyc_per_vm_group_vblank)REG_SET (VBLANK_PARAMETERS_5 ,0 ,REFCYC_PER_VM_GROUP_VBLANK , dlg_attr->refcyc_per_vm_group_vblank);REG_GET (VBLANK_PARAMETERS_6 , -REFCYC_PER_VM_REQ_VBLANK , - &cur_value); -if (cur_value > dlg_attr->refcyc_per_vm_req_vblank) +REFCYC_PER_VM_REQ_VBLANK , &refcyc_per_vm_req_vblank); + +if (refcyc_per_vm_req_vblank == uninitialized_hw_default || + refcyc_per_vm_req_vblank > dlg_attr->refcyc_per_vm_req_vblank)REG_SET (VBLANK_PARAMETERS_6 ,0 ,REFCYC_PER_VM_REQ_VBLANK , dlg_attr->refcyc_per_vm_req_vblank); -REG_GET (FLIP_PARAMETERS_3 ,REFCYC_PER_VM_GROUP_FLIP , &cur_value); -if (cur_value > dlg_attr->refcyc_per_vm_group_flip) +REG_GET (FLIP_PARAMETERS_3 , +REFCYC_PER_VM_GROUP_FLIP , &refcyc_per_vm_group_flip); + +if (refcyc_per_vm_group_flip == uninitialized_hw_default || + refcyc_per_vm_group_flip > dlg_attr->refcyc_per_vm_group_flip)REG_SET (FLIP_PARAMETERS_3 ,0 ,REFCYC_PER_VM_GROUP_FLIP , dlg_attr->refcyc_per_vm_group_flip); -REG_GET (FLIP_PARAMETERS_4 ,REFCYC_PER_VM_REQ_FLIP , &cur_value); -if (cur_value > dlg_attr->refcyc_per_vm_req_flip) +REG_GET (FLIP_PARAMETERS_4 , +REFCYC_PER_VM_REQ_FLIP , &refcyc_per_vm_req_flip); + +if (refcyc_per_vm_req_flip == uninitialized_hw_default || + refcyc_per_vm_req_flip > dlg_attr->refcyc_per_vm_req_flip)REG_SET (FLIP_PARAMETERS_4 ,0 ,REFCYC_PER_VM_REQ_FLIP , dlg_attr->refcyc_per_vm_req_flip);REG_SET (FLIP_PARAMETERS_5 ,0 ,REFCYC_PER_PTE_GROUP_FLIP_C , dlg_attr->refcyc_per_pte_group_flip_c); +REG_SET (FLIP_PARAMETERS_6 ,0 ,REFCYC_PER_META_CHUNK_FLIP_C , dlg_attr->refcyc_per_meta_chunk_flip_c); }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 110/330 tools/power/x86/intel_pstate_tracer: changes for python 3 compatibility
In reply to Sasha LevinFrom: Doug Smythies <[email protected]>
[ Upstream commit e749e09db30c38f1a275945814b0109e530a07b0 ]
Some syntax needs to be more rigorous for python 3. Backwards compatibility tested with python 2.7
--- .../intel_pstate_tracer.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)
tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +11 -11
@@ -11,11 +11,11 @@ then this utility enables and collects trace data for a user specified interval and generates performance plots. Prerequisites: - Python version 2.7.x + Python version 2.7.x or higher gnuplot 5.0 or higher - gnuplot-py 1.8 + gnuplot-py 1.8 or higher (Most of the distributions have these required packages. They may be called - gnuplot-py, phython-gnuplot. ) + gnuplot-py, phython-gnuplot or phython3-gnuplot, gnuplot-nox, ... ) HWP (Hardware P-States are disabled) Kernel config for Linux trace is enabled
@@ -181,7 +181,7 @@ def plot_pstate_cpu_with_sample(): g_plot('set xlabel "Samples"') g_plot('set ylabel "P-State"') g_plot('set title "{} : cpu pstate vs. sample : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_SAMPLE, C_TO) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -198,7 +198,7 @@ def plot_pstate_cpu(): # the following command is really cool, but doesn't work with the CPU masking option because it aborts on the first missing file. # plot_str = 'plot for [i=0:*] file=sprintf("cpu%03d.csv",i) title_s=sprintf("cpu%03d",i) file using 16:7 pt 7 ps 1 title title_s' # - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_TO) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -212,7 +212,7 @@ def plot_load_cpu(): g_plot('set ylabel "CPU load (percent)"') g_plot('set title "{} : cpu loads : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_LOAD) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -226,7 +226,7 @@ def plot_frequency_cpu(): g_plot('set ylabel "CPU Frequency (GHz)"') g_plot('set title "{} : cpu frequencies : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_FREQ) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -241,7 +241,7 @@ def plot_duration_cpu(): g_plot('set ylabel "Timer Duration (MilliSeconds)"') g_plot('set title "{} : cpu durations : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_DURATION) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -255,7 +255,7 @@ def plot_scaled_cpu(): g_plot('set ylabel "Scaled Busy (Unitless)"') g_plot('set title "{} : cpu scaled busy : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_SCALED) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -269,7 +269,7 @@ def plot_boost_cpu(): g_plot('set ylabel "CPU IO Boost (percent)"') g_plot('set title "{} : cpu io boost : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_BOOST) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
@@ -283,7 +283,7 @@ def plot_ghz_cpu(): g_plot('set ylabel "TSC Frequency (GHz)"') g_plot('set title "{} : cpu TSC Frequencies (Sanity check calculation) : {:%F %H:%M}"'.format(testname, datetime.now())) - title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ') + title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ') plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_GHZ) g_plot('title_list = "{}"'.format(title_list)) g_plot(plot_str)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 109/330 selftests/ftrace: fix glob selftest
In reply to Sasha LevinFrom: Sven Schnelle <[email protected]>
[ Upstream commit af4ddd607dff7aabd466a4a878e01b9f592a75ab ]
test.d/ftrace/func-filter-glob.tc is failing on s390 because it has ARCH_INLINE_SPIN_LOCK and friends set to 'y'. So the usual __raw_spin_lock symbol isn't in the ftrace function list. Change '*aw*lock' to '*spin*lock' which would hopefully match some of the locking functions on all platforms.
--- .../testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +1 -1
@@ -30,7 +30,7 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$' ftrace_filter_check 'schedule*' '^schedule.*$' # filter by *mid*end -ftrace_filter_check '*aw*lock' '.*aw.*lock$' +ftrace_filter_check '*pin*lock' '.*pin.*lock$' # filter by start*mid* ftrace_filter_check 'mutex*try*' '^mutex.*try.*'
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 120/330 audit: CONFIG_CHANGE don't log internal bookkeeping as an event
In reply to Sasha LevinFrom: Steve Grubb <[email protected]>
[ Upstream commit 70b3eeed49e8190d97139806f6fbaf8964306cdb ]
Common Criteria calls out for any action that modifies the audit trail to be recorded. That usually is interpreted to mean insertion or removal of rules. It is not required to log modification of the inode information since the watch is still in effect. Additionally, if the rule is a never rule and the underlying file is one they do not want events for, they get an event for this bookkeeping update against their wishes.
Since no device/inode info is logged at insertion and no device/inode information is logged on update, there is nothing meaningful being communicated to the admin by the CONFIG_CHANGE updated_rules event. One can assume that the rule was not "modified" because it is still watching the intended target. If the device or inode cannot be resolved, then audit_panic is called which is sufficient.
The correct resolution is to drop logging config_update events since the watch is still in effect but just on another unknown inode.
--- kernel/audit_watch.c | 2 -- 1 file changed, 2 deletions(-)
kernel/audit_watch.c +0 -2
@@ -302,8 +302,6 @@ static void audit_update_watch(struct audit_parent *parent,if (oentry->rule.exe)audit_remove_mark (oentry->rule.exe); -audit_watch_log_rule_change (r, owatch,"updated_rules" ); -call_rcu (&oentry->rcu, audit_free_rule_rcu); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 125/330 drm/omap: fix possible object reference leak
In reply to Sasha LevinFrom: Wen Yang <[email protected]>
[ Upstream commit 47340e46f34a3b1d80e40b43ae3d7a8da34a3541 ]
The call to of_find_matching_node returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:212:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function. drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
--- drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c +3 -1
@@ -192,7 +192,7 @@ static int __init omapdss_boot_init(void) dss =of_find_matching_node (NULL , omapdss_of_match);if (dss ==NULL || !of_device_is_available (dss)) -return 0 ; + goto put_node;omapdss_walk_device (dss, true);
@@ -217,6 +217,8 @@ static int __init omapdss_boot_init(void)kfree (n); } +put_node: +of_node_put (dss);return 0 ; }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 126/330 locking/lockdep: Decrement IRQ context counters when removing lock chain
In reply to Sasha LevinFrom: Waiman Long <[email protected]>
[ Upstream commit b3b9c187dc2544923a601733a85352b9ddaba9b3 ]
There are currently three counters to track the IRQ context of a lock chain - nr_hardirq_chains, nr_softirq_chains and nr_process_chains. They are incremented when a new lock chain is added, but they are not decremented when a lock chain is removed. That causes some of the statistic counts reported by /proc/lockdep_stats to be incorrect. IRQ
Fix that by decrementing the right counter when a lock chain is removed.
Since inc_chains() no longer accesses hardirq_context and softirq_context directly, it is moved out from the CONFIG_TRACE_IRQFLAGS conditional compilation block.
--- kernel/locking/lockdep.c | 40 +++++++++++++++++------------- kernel/locking/lockdep_internals.h | 6 +++++ 2 files changed, 29 insertions(+), 17 deletions(-)
kernel/locking/lockdep.c +23 -17
@@ -2302,18 +2302,6 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,return 0 ; } -static void inc_chains (void ) -{ -if (current->hardirq_context) - nr_hardirq_chains++; -else { -if (current->softirq_context) - nr_softirq_chains++; -else - nr_process_chains++; - } -} -#else static inline int check_irq_usage(struct task_struct *curr,
@@ -2321,13 +2309,27 @@ static inline int check_irq_usage(struct task_struct *curr, {return 1 ; } +#endif /* CONFIG_TRACE_IRQFLAGS */ -static inline void inc_chains (void ) +static void inc_chains (int irq_context) { - nr_process_chains++; +if (irq_context &LOCK_CHAIN_HARDIRQ_CONTEXT ) + nr_hardirq_chains++; +else if (irq_context &LOCK_CHAIN_SOFTIRQ_CONTEXT ) + nr_softirq_chains++; +else + nr_process_chains++; } -#endif /* CONFIG_TRACE_IRQFLAGS */ +static void dec_chains (int irq_context) +{ +if (irq_context &LOCK_CHAIN_HARDIRQ_CONTEXT ) + nr_hardirq_chains--; +else if (irq_context &LOCK_CHAIN_SOFTIRQ_CONTEXT ) + nr_softirq_chains--; +else + nr_process_chains--; +}static void print_deadlock_scenario (struct held_lock *nxt,struct held_lock *prv)
@@ -2847,7 +2849,7 @@ static inline int add_chain_cache(struct task_struct *curr,hlist_add_head_rcu (&chain->entry, hash_head);debug_atomic_inc (chain_lookup_misses); -inc_chains (); +inc_chains (chain->irq_context);return 1 ; }
@@ -3600,7 +3602,8 @@ lock_used:static inline unsigned int task_irq_context (struct task_struct *task) { -return 2 * !!task->hardirq_context + !!task->softirq_context; +return LOCK_CHAIN_HARDIRQ_CONTEXT * !!task->hardirq_context + +LOCK_CHAIN_SOFTIRQ_CONTEXT * !!task->softirq_context; } static int separate_irq_context(struct task_struct *curr,
@@ -4805,6 +4808,8 @@ recalc:return ;/* Overwrite the chain key for concurrent RCU readers. */ WRITE_ONCE (chain->chain_key, chain_key); +dec_chains (chain->irq_context); +/* * Note: calling hlist_del_rcu() from inside a * hlist_for_each_entry_rcu() loop is safe.
@@ -4826,6 +4831,7 @@ recalc: } *new_chain = *chain;hlist_add_head_rcu (&new_chain->entry,chainhashentry (chain_key)); +inc_chains (new_chain->irq_context);#endif }
kernel/locking/lockdep_internals.h +6 -0
@@ -106,6 +106,12 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =#define STACK_TRACE_HASH_SIZE 16384#endif +/* +* Bit definitions for lock_chain.irq_context +*/ +#define LOCK_CHAIN_SOFTIRQ_CONTEXT (1 << 0) +#define LOCK_CHAIN_HARDIRQ_CONTEXT (1 << 1) +#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 124/330 scsi: lpfc: Fix coverity errors in fmdi attribute handling
In reply to Sasha LevinFrom: James Smart <[email protected]>
[ Upstream commit 4cb9e1ddaa145be9ed67b6a7de98ca705a43f998 ]
Coverity reported a memory corruption error for the fdmi attributes routines:
CID 15768 [Memory Corruption] Out-of-bounds access on FDMI
Sloppy coding of the fmdi structures. In both the lpfc_fdmi_attr_def and lpfc_fdmi_reg_port_list structures, a field was placed at the start of payload that may have variable content. The field was given an arbitrary type (uint32_t). The code then uses the field name to derive an address, which it used in things such as memset and memcpy. The memset sizes or memcpy lengths were larger than the arbitrary type, thus coverity reported an error.
Fix by replacing the arbitrary fields with the real field structures describing the payload.
--- drivers/scsi/lpfc/lpfc_ct.c | 137 ++++++++++++++++++------------------ drivers/scsi/lpfc/lpfc_hw.h | 36 +++++----- 2 files changed, 85 insertions(+), 88 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +69 -68
@@ -2056,8 +2056,8 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,sizeof (struct lpfc_name )); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrWWN, &vport->fc_sparam.nodeName,sizeof (struct lpfc_name ));
@@ -2073,8 +2073,8 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));/* This string MUST be consistent with other FC platforms * supported by Broadcom.
@@ -2098,8 +2098,8 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString, phba->SerialNumber,sizeof (ae->un.AttrString));
@@ -2120,8 +2120,8 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString, phba->ModelName,sizeof (ae->un.AttrString));
@@ -2141,8 +2141,8 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString, phba->ModelDesc,sizeof (ae->un.AttrString));
@@ -2164,8 +2164,8 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t i, j, incr, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));/* Convert JEDEC ID to ascii for hardware version */ incr = vp->rev.biuRev;
@@ -2194,8 +2194,8 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString, lpfc_release_version,sizeof (ae->un.AttrString));
@@ -2216,8 +2216,8 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));if (phba->sli_rev ==LPFC_SLI_REV4 )lpfc_decode_firmware_rev (phba, ae->un.AttrString,1 );
@@ -2241,8 +2241,8 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));lpfc_decode_firmware_rev (phba, ae->un.AttrString,1 ); len = strnlen(ae->un.AttrString,
@@ -2261,8 +2261,8 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae)); snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s", init_utsname()->sysname,
@@ -2284,7 +2284,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =cpu_to_be32 (LPFC_MAX_CT_SIZE ); size =FOURBYTES +sizeof (uint32_t );
@@ -2300,8 +2300,8 @@ lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae)); len =lpfc_vport_symbolic_node_name (vport, ae->un.AttrString,256 );
@@ -2319,7 +2319,7 @@ lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;/* Nothing is defined for this currently */ ae->un.AttrInt =cpu_to_be32 (0 );
@@ -2336,7 +2336,7 @@ lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;/* Each driver instance corresponds to a single port */ ae->un.AttrInt =cpu_to_be32 (1 );
@@ -2353,8 +2353,8 @@ lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,sizeof (struct lpfc_name )); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrWWN, &vport->fabric_nodename,sizeof (struct lpfc_name ));
@@ -2372,8 +2372,8 @@ lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strlcat (ae->un.AttrString, phba->BIOSVersion,sizeof (ae->un.AttrString));
@@ -2393,7 +2393,7 @@ lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;/* Driver doesn't have access to this information */ ae->un.AttrInt =cpu_to_be32 (0 );
@@ -2410,8 +2410,8 @@ lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString,"EMULEX" ,sizeof (ae->un.AttrString));
@@ -2433,8 +2433,8 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,32 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae)); ae->un.AttrTypes[3 ] =0x02 ;/* Type 0x1 - ELS */ ae->un.AttrTypes[2 ] =0x01 ;/* Type 0x8 - FCP */
@@ -2459,7 +2459,7 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =0 ;if (!(phba->hba_flag &HBA_FCOE_MODE )) {
@@ -2513,7 +2513,7 @@ lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;if (!(phba->hba_flag &HBA_FCOE_MODE )) {switch (phba->fc_linkspeed) {
@@ -2583,7 +2583,7 @@ lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; hsp = (struct serv_parm *)&vport->fc_sparam; ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
@@ -2603,8 +2603,8 @@ lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));snprintf (ae->un.AttrString,sizeof (ae->un.AttrString),"/sys/class/scsi_host/host%d" , shost->host_no);
@@ -2624,8 +2624,8 @@ lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));scnprintf (ae->un.AttrString,sizeof (ae->un.AttrString),"%s" , vport->phba->os_host_name);
@@ -2645,8 +2645,8 @@ lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,sizeof (struct lpfc_name )); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrWWN, &vport->fc_sparam.nodeName,sizeof (struct lpfc_name ));
@@ -2663,8 +2663,8 @@ lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,sizeof (struct lpfc_name )); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrWWN, &vport->fc_sparam.portName,sizeof (struct lpfc_name ));
@@ -2681,8 +2681,8 @@ lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae)); len =lpfc_vport_symbolic_port_name (vport, ae->un.AttrString,256 ); len += (len &3 ) ? (4 - (len &3 )) :4 ;
@@ -2700,7 +2700,7 @@ lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;if (phba->fc_topology ==LPFC_TOPOLOGY_LOOP ) ae->un.AttrInt =cpu_to_be32 (LPFC_FDMI_PORTTYPE_NLPORT );else
@@ -2718,7 +2718,7 @@ lpfc_fdmi_port_attr_class(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =cpu_to_be32 (FC_COS_CLASS2 |FC_COS_CLASS3 ); size =FOURBYTES +sizeof (uint32_t ); ad->AttrLen =cpu_to_be16 (size);
@@ -2733,8 +2733,8 @@ lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,sizeof (struct lpfc_name )); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrWWN, &vport->fabric_portname,sizeof (struct lpfc_name ));
@@ -2751,8 +2751,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,32 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae)); ae->un.AttrTypes[3 ] =0x02 ;/* Type 0x1 - ELS */ ae->un.AttrTypes[2 ] =0x01 ;/* Type 0x8 - FCP */
@@ -2775,7 +2775,7 @@ lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;/* Link Up - operational */ ae->un.AttrInt =cpu_to_be32 (LPFC_FDMI_PORTSTATE_ONLINE ); size =FOURBYTES +sizeof (uint32_t );
@@ -2791,7 +2791,7 @@ lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; vport->fdmi_num_disc =lpfc_find_map_node (vport); ae->un.AttrInt =cpu_to_be32 (vport->fdmi_num_disc); size =FOURBYTES +sizeof (uint32_t );
@@ -2807,7 +2807,7 @@ lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =cpu_to_be32 (vport->fc_myDID); size =FOURBYTES +sizeof (uint32_t ); ad->AttrLen =cpu_to_be16 (size);
@@ -2822,8 +2822,8 @@ lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString,"Smart SAN Initiator" ,sizeof (ae->un.AttrString));
@@ -2843,8 +2843,8 @@ lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));memcpy (&ae->un.AttrString, &vport->fc_sparam.nodeName,sizeof (struct lpfc_name ));
@@ -2864,8 +2864,8 @@ lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString,"Smart SAN Version 2.0" ,sizeof (ae->un.AttrString));
@@ -2886,8 +2886,8 @@ lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t len, size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); + ae = &ad->AttrValue; +memset (ae,0 ,sizeof (*ae));strncpy (ae->un.AttrString, phba->ModelName,sizeof (ae->un.AttrString));
@@ -2906,7 +2906,7 @@ lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue;/* SRIOV (type 3) is not supported */ if (vport->vpi)
@@ -2926,7 +2926,7 @@ lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =cpu_to_be32 (0 ); size =FOURBYTES +sizeof (uint32_t ); ad->AttrLen =cpu_to_be16 (size);
@@ -2941,7 +2941,7 @@ lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport,struct lpfc_fdmi_attr_entry *ae;uint32_t size; - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; + ae = &ad->AttrValue; ae->un.AttrInt =cpu_to_be32 (1 ); size =FOURBYTES +sizeof (uint32_t ); ad->AttrLen =cpu_to_be16 (size);
@@ -3089,7 +3089,8 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,/* Registered Port List */ /* One entry (port) per adapter */ rh->rpl.EntryCnt =cpu_to_be32 (1 ); -memcpy (&rh->rpl.pe, &phba->pport->fc_sparam.portName, +memcpy (&rh->rpl.pe.PortName, + &phba->pport->fc_sparam.portName,sizeof (struct lpfc_name ));/* point to the HBA attribute block */
drivers/scsi/lpfc/lpfc_hw.h +16 -20
@@ -1340,25 +1340,8 @@ struct fc_rdp_res_frame {/* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */ #define SLI_CT_FDMI_Subtypes 0x10/* Management Service Subtype */ -/* -* Registered Port List Format -*/ -struct lpfc_fdmi_reg_port_list { -uint32_t EntryCnt; -uint32_t pe;/* Variable-length array */ -}; - -/* Definitions for HBA / Port attribute entries */ -struct lpfc_fdmi_attr_def {/* Defined in TLV format */ -/* Structure is in Big Endian format */ -uint32_t AttrType:16 ; -uint32_t AttrLen:16 ; -uint32_t AttrValue;/* Marks start of Value (ATTRIBUTE_ENTRY) */ -}; - -/* Attribute Entry */ struct lpfc_fdmi_attr_entry { union {
@@ -1369,7 +1352,13 @@ struct lpfc_fdmi_attr_entry { } un; }; -#define LPFC_FDMI_MAX_AE_SIZE sizeof(struct lpfc_fdmi_attr_entry) +struct lpfc_fdmi_attr_def {/* Defined in TLV format */ +/* Structure is in Big Endian format */ +uint32_t AttrType:16 ; +uint32_t AttrLen:16 ; +/* Marks start of Value (ATTRIBUTE_ENTRY) */ +struct lpfc_fdmi_attr_entry AttrValue; +} __packed;/* * HBA Attribute Block
@@ -1393,13 +1382,20 @@ struct lpfc_fdmi_hba_ident {struct lpfc_name PortName; }; +/* +* Registered Port List Format +*/ +struct lpfc_fdmi_reg_port_list { +uint32_t EntryCnt; +struct lpfc_fdmi_port_entry pe; +} __packed; +/* * Register HBA(RHBA) */ struct lpfc_fdmi_reg_hba {struct lpfc_fdmi_hba_ident hi; -struct lpfc_fdmi_reg_port_list rpl;/* variable-length array */ -/* struct lpfc_fdmi_attr_block ab; */ +struct lpfc_fdmi_reg_port_list rpl; };/*
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 132/330 perf test: Fix test trace+probe_vfs_getname.sh on s390
In reply to Sasha LevinFrom: Thomas Richter <[email protected]>
[ Upstream commit 2bbc83537614517730e9f2811195004b712de207 ]
This test places a kprobe to function getname_flags() in the kernel which has the following prototype:
struct filename *getname_flags(const char __user *filename, int flags, int *empty)
The 'filename' argument points to a filename located in user space memory.
Looking at commit 88903c464321c ("tracing/probe: Add ustring type for user-space string") the kprobe should indicate that user space memory is accessed.
Output before:
[root@m35lp76 perf]# ./perf test 66 67
66: Use vfs_getname probe to get syscall args filenames : FAILED!
67: Check open filename arg using perf trace + vfs_getname: FAILED! [root@m35lp76 perf]#
Output after:
[root@m35lp76 perf]# ./perf test 66 67
66: Use vfs_getname probe to get syscall args filenames : Ok
67: Check open filename arg using perf trace + vfs_getname: Ok [root@m35lp76 perf]#
Comments from Masami Hiramatsu:
This bug doesn't happen on x86 or other archs on which user address space and kernel address space is the same. On some arches (ppc64 in this case?) user address space is partially or completely the same as kernel address space.
(Yes, they switch the world when running into the kernel) In this case, we need to use different data access functions for each space.
That is why I introduced the "ustring" type for kprobe events.
As far as I can see, Thomas's patch is sane. Thomas, could you show us your result on your test environment?
Comments from Thomas Richter:
Test results for s/390 included above.
--- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/lib/probe_vfs_getname.sh +1 -1
@@ -14,7 +14,7 @@ add_probe_vfs_getname() { if [ $had_vfs_getname -eq 1 ] ; then line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \ - perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string" + perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring" fi }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 92/330 scsi: ufs: Make ufshcd_add_command_trace() easier to read
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit e4d2add7fd5bc64ee3e388eabe6b9e081cb42e11 ]
Since the lrbp->cmd expression occurs multiple times, introduce a new local variable to hold that pointer. This patch does not change any functionality.
--- drivers/scsi/ufs/ufshcd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufshcd.c +6 -6
@@ -334,27 +334,27 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba,u8 opcode =0 ;u32 intr, doorbell;struct ufshcd_lrb *lrbp = &hba->lrb[tag]; +struct scsi_cmnd *cmd = lrbp->cmd;int transfer_len =-1 ;if (!trace_ufshcd_command_enabled ()) {/* trace UPIU W/O tracing command */ -if (lrbp->cmd) +if (cmd)ufshcd_add_cmd_upiu_trace (hba, tag, str);return ; } -if (lrbp->cmd) {/* data phase exists */ +if (cmd) {/* data phase exists */ /* trace UPIU also */ ufshcd_add_cmd_upiu_trace (hba, tag, str); - opcode = (u8)(*lrbp->cmd->cmnd); + opcode = cmd->cmnd[0 ];if ((opcode ==READ_10 ) || (opcode ==WRITE_10 )) {/* * Currently we only fully trace read(10) and write(10) * commands */ -if (lrbp->cmd->request && lrbp->cmd->request->bio) - lba = - lrbp->cmd->request->bio->bi_iter.bi_sector; +if (cmd->request && cmd->request->bio) + lba = cmd->request->bio->bi_iter.bi_sector; transfer_len =be32_to_cpu ( lrbp->ucd_req_ptr->sc.exp_data_transfer_len); }
Signature · 7 lines
2.25.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Sasha Levin
maintainerPATCH 136/330 dmaengine: stm32-mdma: use vchan_terminate_vdesc() in .terminate_all
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit dfc708812a2acfc0ca56f56233b3c3e7b0d4ffe7 ]
To avoid race with vchan_complete, use the race free way to terminate running transfer.
Move vdesc->node list_del in stm32_mdma_start_transfer instead of in stm32_mdma_xfer_end to avoid another race in vchan_dma_desc_free_list.
--- drivers/dma/stm32-mdma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/dma/stm32-mdma.c +6 -3
@@ -1127,6 +1127,8 @@ static void stm32_mdma_start_transfer(struct stm32_mdma_chan *chan)return ; } +list_del (&vdesc->node); + chan->desc =to_stm32_mdma_desc (vdesc); hwdesc = chan->desc->node[0 ].hwdesc; chan->curr_hwdesc =0 ;
@@ -1242,8 +1244,10 @@ static int stm32_mdma_terminate_all(struct dma_chan *c)LIST_HEAD (head);spin_lock_irqsave (&chan->vchan.lock, flags); -if (chan->busy) { -stm32_mdma_stop (chan); +if (chan->desc) { +vchan_terminate_vdesc (&chan->desc->vdesc); +if (chan->busy) +stm32_mdma_stop (chan); chan->desc =NULL ; }vchan_get_all_descriptors (&chan->vchan, &head);
@@ -1331,7 +1335,6 @@ static enum dma_status stm32_mdma_tx_status(struct dma_chan *c,static void stm32_mdma_xfer_end (struct stm32_mdma_chan *chan) { -list_del (&chan->desc->vdesc.node);vchan_cookie_complete (&chan->desc->vdesc); chan->desc =NULL ; chan->busy = false;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 141/330 dmaengine: tegra-apb: Prevent race conditions on channel's freeing
In reply to Sasha LevinFrom: Dmitry Osipenko <[email protected]>
[ Upstream commit 8e84172e372bdca20c305d92d51d33640d2da431 ]
It's incorrect to check the channel's "busy" state without taking a lock. That shouldn't cause any real troubles, nevertheless it's always better not to have any race conditions in the code.
--- drivers/dma/tegra20-apb-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/tegra20-apb-dma.c +1 -2
@@ -1287,8 +1287,7 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc)dev_dbg (tdc2dev (tdc),"Freeing channel %d\n" , tdc->id); -if (tdc->busy) -tegra_dma_terminate_all (dc); +tegra_dma_terminate_all (dc);spin_lock_irqsave (&tdc->lock, flags);list_splice_init (&tdc->pending_sg_req, &sg_req_list);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 143/330 drm/amd/display: dal_ddc_i2c_payloads_create can fail causing panic
In reply to Sasha LevinFrom: Aric Cyr <[email protected]>
[ Upstream commit 6a6c4a4d459ecacc9013c45dcbf2bc9747fdbdbd ]
[Why]
Since the i2c payload allocation can fail need to check return codes
[How]
Clean up i2c payload allocations and check for errors
--- .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +25 -27
@@ -126,22 +126,16 @@ struct aux_payloads {struct vector payloads; }; -static struct i2c_payloads *dal_ddc_i2c_payloads_create (struct dc_context *ctx,uint32_t count) +static bool dal_ddc_i2c_payloads_create ( +struct dc_context *ctx, +struct i2c_payloads *payloads, +uint32_t count) { -struct i2c_payloads *payloads; - - payloads =kzalloc (sizeof (struct i2c_payloads ),GFP_KERNEL ); - -if (!payloads) -return NULL ; -if (dal_vector_construct ( &payloads->payloads, ctx, count,sizeof (struct i2c_payload ))) -return payloads; - -kfree (payloads); -return NULL ; +return true; +return false; }static struct i2c_payload *dal_ddc_i2c_payloads_get (struct i2c_payloads *p)
@@ -154,14 +148,12 @@ static uint32_t dal_ddc_i2c_payloads_get_count(struct i2c_payloads *p)return p->payloads.count; } -static void dal_ddc_i2c_payloads_destroy (struct i2c_payloads **p) +static void dal_ddc_i2c_payloads_destroy (struct i2c_payloads *p) { -if (!p || !*p) +if (!p)return ; -dal_vector_destruct (&(*p)->payloads); -kfree (*p); - *p =NULL ; +dal_vector_destruct (&p->payloads); }#define DDC_MIN (a, b) (((a) < (b)) ? (a) : (b))
@@ -521,9 +513,13 @@ bool dal_ddc_service_query_ddc_data(uint32_t payloads_num = write_payloads + read_payloads; +if (write_size >EDID_SEGMENT_SIZE || read_size >EDID_SEGMENT_SIZE )return false; +if (!payloads_num) +return false; +/*TODO: len of payload data for i2c and aux is uint8!!!!, * but we want to read 256 over i2c!!!!*/ if (dal_ddc_service_is_in_aux_transaction_mode (ddc)) {
@@ -556,23 +552,25 @@ bool dal_ddc_service_query_ddc_data( ret =dc_link_aux_transfer_with_retries (ddc, &read_payload); }else { -struct i2c_payloads *payloads = -dal_ddc_i2c_payloads_create (ddc->ctx, payloads_num); +struct i2c_command command = {0 }; +struct i2c_payloads payloads; + +if (!dal_ddc_i2c_payloads_create (ddc->ctx, &payloads, payloads_num)) +return false; -struct i2c_command command = { - .payloads =dal_ddc_i2c_payloads_get (payloads), - .number_of_payloads =0 , - .engine =DDC_I2C_COMMAND_ENGINE , - .speed = ddc->ctx->dc->caps.i2c_speed_in_khz }; + command.payloads =dal_ddc_i2c_payloads_get (&payloads); + command.number_of_payloads =0 ; + command.engine =DDC_I2C_COMMAND_ENGINE ; + command.speed = ddc->ctx->dc->caps.i2c_speed_in_khz;dal_ddc_i2c_payloads_add ( - payloads, address, write_size, write_buf, true); + &payloads, address, write_size, write_buf, true);dal_ddc_i2c_payloads_add ( - payloads, address, read_size, read_buf, false); + &payloads, address, read_size, read_buf, false); command.number_of_payloads = -dal_ddc_i2c_payloads_get_count (payloads); +dal_ddc_i2c_payloads_get_count (&payloads); ret = dm_helpers_submit_i2c( ddc->ctx,
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 139/330 bpf: Remove recursion prevention from rcu free callback
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
[ Upstream commit 8a37963c7ac9ecb7f86f8ebda020e3f8d6d7b8a0 ]
If an element is freed via RCU then recursion into BPF instrumentation functions is not a concern. The element is already detached from the map and the RCU callback does not hold any locks on which a kprobe, perf event or tracepoint attached BPF program could deadlock.
--- kernel/bpf/hashtab.c | 8 -------- 1 file changed, 8 deletions(-)
kernel/bpf/hashtab.c +0 -8
@@ -664,15 +664,7 @@ static void htab_elem_free_rcu(struct rcu_head *head) struct htab_elem *l = container_of(head, struct htab_elem, rcu);struct bpf_htab *htab = l->htab; -/* must increment bpf_prog_active to avoid kprobe+bpf triggering while -* we're calling kfree, otherwise deadlock is possible if kprobes -* are placed somewhere inside of slub -*/ -preempt_disable (); -__this_cpu_inc (bpf_prog_active);htab_elem_free (htab, l); -__this_cpu_dec (bpf_prog_active); -preempt_enable (); }static void htab_put_fd_value (struct bpf_htab *htab,struct htab_elem *l)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 93/330 scsi: ufs: Fix a race condition in the tracing code
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit eacf36f5bebde5089dddb3d5bfcbeab530b01f8a ]
Starting execution of a command before tracing a command may cause the completion handler to free data while it is being traced. Fix this race by tracing a command before it is submitted.
--- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
@@ -1888,12 +1888,12 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) { hba->lrb[task_tag].issue_time_stamp =ktime_get (); hba->lrb[task_tag].compl_time_stamp =ktime_set (0 ,0 ); +ufshcd_add_command_trace (hba, task_tag,"send" );ufshcd_clk_scaling_start_busy (hba);__set_bit (task_tag, &hba->outstanding_reqs);ufshcd_writel (hba,1 << task_tag,REG_UTP_TRANSFER_REQ_DOOR_BELL );/* Make sure that doorbell is committed immediately */ wmb (); -ufshcd_add_command_trace (hba, task_tag,"send" ); }/**
Signature · 7 lines
2.25.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Sasha Levin
maintainerPATCH 144/330 drm/omap: dss: Cleanup DSS ports on initialisation failure
In reply to Sasha LevinFrom: Laurent Pinchart <[email protected]>
[ Upstream commit 2a0a3ae17d36fa86dcf7c8e8d7b7f056ebd6c064 ]
When the DSS initialises its output DPI and SDI ports, failures don't clean up previous successfully initialised ports. This can lead to resource leak or memory corruption. Fix it.
--- drivers/gpu/drm/omapdrm/dss/dss.c | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/gpu/drm/omapdrm/dss/dss.c +26 -17
@@ -1151,46 +1151,38 @@ static const struct dss_features dra7xx_dss_feats = { .has_lcd_clk_src = true, }; -static int dss_init_ports (struct dss_device *dss) +static void __dss_uninit_ports (struct dss_device *dss,unsigned int num_ports) {struct platform_device *pdev = dss->pdev;struct device_node *parent = pdev->dev.of_node;struct device_node *port;unsigned int i; -int r; -for (i =0 ; i < dss->feat->num_ports; i++) { +for (i =0 ; i < num_ports; i++) { port =of_graph_get_port_by_id (parent, i);if (!port)continue ;switch (dss->feat->ports[i]) {case OMAP_DISPLAY_TYPE_DPI : - r =dpi_init_port (dss, pdev, port, dss->feat->model); -if (r) -return r; +dpi_uninit_port (port);break ; -case OMAP_DISPLAY_TYPE_SDI : - r =sdi_init_port (dss, pdev, port); -if (r) -return r; +sdi_uninit_port (port);break ; -default :break ; } } - -return 0 ; } -static void dss_uninit_ports (struct dss_device *dss) +static int dss_init_ports (struct dss_device *dss) {struct platform_device *pdev = dss->pdev;struct device_node *parent = pdev->dev.of_node;struct device_node *port; -int i; +unsigned int i; +int r;for (i =0 ; i < dss->feat->num_ports; i++) { port =of_graph_get_port_by_id (parent, i);
@@ -1199,15 +1191,32 @@ static void dss_uninit_ports(struct dss_device *dss)switch (dss->feat->ports[i]) {case OMAP_DISPLAY_TYPE_DPI : -dpi_uninit_port (port); + r =dpi_init_port (dss, pdev, port, dss->feat->model); +if (r) + goto error;break ; +case OMAP_DISPLAY_TYPE_SDI : -sdi_uninit_port (port); + r =sdi_init_port (dss, pdev, port); +if (r) + goto error;break ; +default :break ; } } + +return 0 ; + +error: +__dss_uninit_ports (dss, i); +return r; +} + +static void dss_uninit_ports (struct dss_device *dss) +{ +__dss_uninit_ports (dss, dss->feat->num_ports); }static int dss_video_pll_probe (struct dss_device *dss)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 142/330 soundwire: bus: disable pm_runtime in sdw_slave_delete
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit dff70572e9a3a1a01d9dbc2279faa784d95f41b6 ]
Before removing the slave device, disable pm_runtime to prevent any race condition with the resume being executed after the bus and slave devices are removed.
Since this pm_runtime_disable() is handled in common routines, implementations of Slave drivers do not need to call it in their .remove() routine.
--- drivers/soundwire/bus.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soundwire/bus.c +2 -0
@@ -113,6 +113,8 @@ static int sdw_delete_slave(struct device *dev, void *data)struct sdw_slave *slave =dev_to_sdw_dev (dev);struct sdw_bus *bus = slave->bus; +pm_runtime_disable (dev); +sdw_slave_debugfs_exit (slave);mutex_lock (&bus->bus_lock);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 77/330 ALSA: hda: enable regmap internal locking
In reply to Sasha LevinFrom: Kai Vehmanen <[email protected]>
[ Upstream commit 8e85def5723eccea30ebf22645673692ab8cb3e2 ]
This reverts commit 42ec336f1f9d ("ALSA: hda: Disable regmap internal locking").
Without regmap locking, there is a race between snd_hda_codec_amp_init() and PM callbacks issuing regcache_sync(). This was caught by following kernel warning trace:
<4> [358.080081] WARNING: CPU: 2 PID: 4157 at drivers/base/regmap/regcache.c:498 regcache_cache_only+0xf5/0x130 [...]
<4> [358.080148] Call Trace:
<4> [358.080158] snd_hda_codec_amp_init+0x4e/0x100 [snd_hda_codec]
<4> [358.080169] snd_hda_codec_amp_init_stereo+0x40/0x80 [snd_hda_codec]
--- sound/hda/hdac_regmap.c | 1 - 1 file changed, 1 deletion(-)
sound/hda/hdac_regmap.c +0 -1
@@ -363,7 +363,6 @@ static const struct regmap_config hda_regmap_cfg = { .reg_write = hda_reg_write, .use_single_read = true, .use_single_write = true, - .disable_locking = true, };/**
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 154/330 drm/amd/display: fix image corruption with ODM 2:1 DSC 2 slice
In reply to Sasha LevinFrom: Wenjing Liu <[email protected]>
[ Upstream commit df8e34ac27e8a0d8dce364628226c5619693c3fd ]
[why]
When combining two or more pipes in DSC mode, there will always be more than 1 slice per line. In this case, as per DSC rules, the sink device is expecting that the ICH is reset at the end of each slice line (i.e. ICH_RESET_AT_END_OF_LINE must be configured based on the number of slices at the output of ODM). It is recommended that software set ICH_RESET_AT_END_OF_LINE = 0xF for each DSC in the ODM combine. However the current code only set ICH_RESET_AT_END_OF_LINE = 0xF when number of slice per DSC engine is greater than 1 instead of number of slice per output after ODM combine.
[how]
Add is_odm in dsc config. Set ICH_RESET_AT_END_OF_LINE = 0xF if either is_odm or number of slice per DSC engine is greater than 1.
--- drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | 2 ++ drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 1 + drivers/gpu/drm/amd/display/dc/inc/hw/dsc.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +2 -0
@@ -400,6 +400,7 @@ void dp_set_dsc_on_stream(struct pipe_ctx *pipe_ctx, bool enable) dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg;ASSERT (dsc_cfg.dc_dsc_cfg.num_slices_h % opp_cnt ==0 ); dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt;
@@ -504,6 +505,7 @@ bool dp_set_dsc_pps_sdp(struct pipe_ctx *pipe_ctx, bool enable) dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg;DC_LOG_DSC (" " );
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c +1 -1
@@ -351,6 +351,7 @@ static bool dsc_prepare_config(const struct dsc_config *dsc_cfg, struct dsc_reg_ dsc_reg_vals->pps.block_pred_enable = dsc_cfg->dc_dsc_cfg.block_pred_enable; dsc_reg_vals->pps.line_buf_depth = dsc_cfg->dc_dsc_cfg.linebuf_depth; dsc_reg_vals->alternate_ich_encoding_en = dsc_reg_vals->pps.dsc_version_minor ==1 ?0 :1 ; + dsc_reg_vals->ich_reset_at_eol = (dsc_cfg->is_odm || dsc_reg_vals->num_slices_h >1 ) ?0xF :0 ;// TODO: in addition to validating slice height (pic height must be divisible by slice height), // see what happens when the same condition doesn't apply for slice_width/pic_width.
@@ -513,7 +514,6 @@ static void dsc_update_from_dsc_parameters(struct dsc_reg_values *reg_vals, cons reg_vals->pps.rc_buf_thresh[i] = reg_vals->pps.rc_buf_thresh[i] >>6 ; reg_vals->rc_buffer_model_size = dsc_params->rc_buffer_model_size; - reg_vals->ich_reset_at_eol = reg_vals->num_slices_h ==1 ?0 :0xf ; }static void dsc_write_to_registers (struct display_stream_compressor *dsc,const struct dsc_reg_values *reg_vals)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +1 -0
@@ -2275,6 +2275,7 @@ static bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx) + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg; dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt;
drivers/gpu/drm/amd/display/dc/inc/hw/dsc.h +1 -0
@@ -36,6 +36,7 @@ struct dsc_config {uint32_t pic_height;enum dc_pixel_encoding pixel_encoding;enum dc_color_depth color_depth;/* Bits per component */ +bool is_odm;struct dc_dsc_config dc_dsc_cfg; };
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 151/330 Bluetooth: guard against controllers sending zero'd events
In reply to Sasha LevinFrom: Alain Michaud <[email protected]>
[ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ]
Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition.
--- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/hci_event.c +6 -0
@@ -5853,6 +5853,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)u8 status =0 , event = hdr->evt, req_evt =0 ;u16 opcode =HCI_OP_NOP ; +if (!event) { +bt_dev_warn (hdev,"Received unexpected HCI Event 00000000" ); + goto done; + } +if (hdev->sent_cmd &&bt_cb (hdev->sent_cmd)->hci.req_event == event) {struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode =__le16_to_cpu (cmd_hdr->opcode);
@@ -6064,6 +6069,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)req_complete_skb (hdev, status, opcode, orig_skb); } +done:kfree_skb (orig_skb);kfree_skb (skb); hdev->stat.evt_rx++;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 149/330 ASoC: SOF: ipc: check ipc return value before data copy
In reply to Sasha LevinFrom: Jaska Uimonen <[email protected]>
[ Upstream commit 1919b42ca4ad75a2397081164661af3ce5a7b8f4 ]
In tx_wait_done the ipc payload is copied before the DSP transaction error code is checked. This might lead to corrupted data in kernel side even though the error would be handled later. It is also pointless to copy the data in case of error. So change the order of error check and copy.
--- sound/soc/sof/ipc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/ipc.c +7 -5
@@ -215,15 +215,17 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,snd_sof_trace_notify_for_error (ipc->sdev); ret = -ETIMEDOUT ; }else { -/* copy the data returned from DSP */ ret = msg->reply_error; -if (msg->reply_size) -memcpy (reply_data, msg->reply_data, msg->reply_size); -if (ret <0 ) +if (ret <0 ) {dev_err (sdev->dev,"error: ipc error for 0x%x size %zu\n" , hdr->cmd, msg->reply_size); -else + }else {ipc_log_header (sdev->dev,"ipc tx succeeded" , hdr->cmd); +if (msg->reply_size) +/* copy the data returned from DSP */ +memcpy (reply_data, msg->reply_data, + msg->reply_size); + } }return ret;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 157/330 mm: avoid data corruption on CoW fault into PFN-mapped VMA
In reply to Sasha LevinFrom: "Kirill A. Shutemov" <[email protected]>
[ Upstream commit c3e5ea6ee574ae5e845a40ac8198de1fb63bb3ab ]
Jeff Moyer has reported that one of xfstests triggers a warning when run on DAX-enabled filesystem:
WARNING: CPU: 76 PID: 51024 at mm/memory.c:2317 wp_page_copy+0xc40/0xd50 ... wp_page_copy+0x98c/0xd50 (unreliable) do_wp_page+0xd8/0xad0 __handle_mm_fault+0x748/0x1b90 handle_mm_fault+0x120/0x1f0 __do_page_fault+0x240/0xd70 do_page_fault+0x38/0xd0 handle_page_fault+0x10/0x30
The warning happens on failed __copy_from_user_inatomic() which tries to copy data into a CoW page.
This happens because of race between MADV_DONTNEED and CoW page fault:
CPU0 CPU1
handle_mm_fault()
do_wp_page()
wp_page_copy()
do_wp_page()
madvise(MADV_DONTNEED)
zap_page_range()
zap_pte_range()
ptep_get_and_clear_full()
<TLB flush>
__copy_from_user_inatomic()
sees empty PTE and fails
WARN_ON_ONCE(1)
clear_page()The solution is to re-try __copy_from_user_inatomic() under PTL after checking that PTE is matches the orig_pte.
The second copy attempt can still fail, like due to non-readable PTE, but there's nothing reasonable we can do about, except clearing the CoW page.
--- mm/memory.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
mm/memory.c +27 -8
@@ -2163,7 +2163,7 @@ static inline bool cow_user_page(struct page *dst, struct page *src,bool ret;void *kaddr;void __user *uaddr; -bool force_mkyoung; +bool locked = false;struct vm_area_struct *vma = vmf->vma;struct mm_struct *mm = vma->vm_mm;unsigned long addr = vmf->address;
@@ -2188,11 +2188,11 @@ static inline bool cow_user_page(struct page *dst, struct page *src,* On architectures with software "accessed" bits, we would * take a double page fault, so mark it accessed here. */ - force_mkyoung =arch_faults_on_old_pte () && !pte_young (vmf->orig_pte); -if (force_mkyoung) { +if (arch_faults_on_old_pte () && !pte_young (vmf->orig_pte)) {pte_t entry; vmf->pte =pte_offset_map_lock (mm, vmf->pmd, addr, &vmf->ptl); + locked = true;if (!likely (pte_same (*vmf->pte, vmf->orig_pte))) {/* * Other thread has already handled the fault
@@ -2216,18 +2216,37 @@ static inline bool cow_user_page(struct page *dst, struct page *src,* zeroes. */ if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) { +if (locked) + goto warn; + +/* Re-validate under PTL if the page is still mapped */ + vmf->pte =pte_offset_map_lock (mm, vmf->pmd, addr, &vmf->ptl); + locked = true; +if (!likely (pte_same (*vmf->pte, vmf->orig_pte))) { +/* The PTE changed under us. Retry page fault. */ + ret = false; + goto pte_unlock; + } +/* -* Give a warn in case there can be some obscure -* use-case +* The same page can be mapped back since last copy attampt. +* Try to copy again under PTL. */ -WARN_ON_ONCE (1 ); -clear_page (kaddr); +if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) { +/* +* Give a warn in case there can be some obscure +* use-case +*/ +warn: +WARN_ON_ONCE (1 ); +clear_page (kaddr); + } } ret = true; pte_unlock: -if (force_mkyoung) +if (locked)pte_unmap_unlock (vmf->pte, vmf->ptl);kunmap_atomic (kaddr);flush_dcache_page (dst);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 158/330 drm/amdgpu: increase atombios cmd timeout
In reply to Sasha LevinFrom: John Clements <[email protected]>
[ Upstream commit 1b3460a8b19688ad3033b75237d40fa580a5a953 ]
mitigates race condition on BACO reset between GPU bootcode and driver reload
--- drivers/gpu/drm/amd/amdgpu/atom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +2 -2
@@ -744,8 +744,8 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg) cjiffies = jiffies;if (time_after (cjiffies, ctx->last_jump_jiffies)) { cjiffies -= ctx->last_jump_jiffies; -if ((jiffies_to_msecs (cjiffies) >5000 )) { -DRM_ERROR ("atombios stuck in loop for more than 5secs aborting\n" ); +if ((jiffies_to_msecs (cjiffies) >10000 )) { +DRM_ERROR ("atombios stuck in loop for more than 10secs aborting\n" ); ctx->abort = true; } }else {
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 150/330 media: go7007: Fix URB type for interrupt handling
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit a3ea410cac41b19a5490aad7fe6d9a9a772e646e ]
Josef reported that his old-and-good Plextor ConvertX M402U video converter spews lots of WARNINGs on the recent kernels, and it turned out that the device uses a bulk endpoint for interrupt handling just like 2250 board.
For fixing it, generalize the check with the proper verification of the endpoint instead of hard-coded board type check.
--- drivers/media/usb/go7007/go7007-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/go7007/go7007-usb.c +3 -1
@@ -1044,6 +1044,7 @@ static int go7007_usb_probe(struct usb_interface *intf,struct go7007_usb *usb;const struct go7007_usb_board *board;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_host_endpoint *ep;unsigned num_i2c_devs;char *name;int video_pipe, i, v_urb_len;
@@ -1140,7 +1141,8 @@ static int go7007_usb_probe(struct usb_interface *intf,if (usb->intr_urb->transfer_buffer ==NULL ) goto allocfail; -if (go->board_id ==GO7007_BOARDID_SENSORAY_2250 ) + ep = usb->usbdev->ep_in[4 ]; +if (usb_endpoint_type (&ep->desc) ==USB_ENDPOINT_XFER_BULK ) usb_fill_bulk_urb(usb->intr_urb, usb->usbdev, usb_rcvbulkpipe(usb->usbdev, 4), usb->intr_urb->transfer_buffer, 2*sizeof(u16),
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 160/330 drm/amd/display: Stop if retimer is not available
In reply to Sasha LevinFrom: Rodrigo Siqueira <[email protected]>
[ Upstream commit a0e40018dcc3f59a10ca21d58f8ea8ceb1b035ac ]
Raven provides retimer feature support that requires i2c interaction in order to make it work well, all settings required for this configuration are loaded from the Atom bios which include the i2c address. If the retimer feature is not available, we should abort the attempt to set this feature, otherwise, it makes the following line return I2C_CHANNEL_OPERATION_NO_RESPONSE:
i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer));
...
if (!i2c_success)
ASSERT(i2c_success);
This ends up causing problems with hotplugging HDMI displays on Raven, and causes retimer settings to warn like so:
WARNING: CPU: 1 PID: 429 at
drivers/gpu/drm/amd/amdgpu/../dal/dc/core/dc_link.c:1998 write_i2c_retimer_setting+0xc2/0x3c0 [amdgpu] Modules linked in:edac_mce_amd ccp kvm irqbypass binfmt_misc crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel amdgpu(+) snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi aesni_intel snd_seq amd_iommu_v2 gpu_sched aes_x86_64 crypto_simd cryptd glue_helper snd_seq_device ttm drm_kms_helper snd_timer eeepc_wmi wmi_bmof asus_wmi sparse_keymap drm mxm_wmi snd k10temp fb_sys_fops syscopyarea sysfillrect sysimgblt soundcore joydev input_leds mac_hid sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 igb i2c_algo_bit hid_generic usbhid i2c_piix4 dca ahci hid libahci video wmi gpio_amdpt gpio_generic CPU: 1 PID: 429 Comm:
systemd-udevd Tainted: G W 5.2.0-rc1sept162019+ #1
Hardware name: System manufacturer System Product Name/ROG STRIX B450-F GAMING, BIOS 2605 08/06/2019 RIP: 0010:write_i2c_retimer_setting+0xc2/0x3c0 [amdgpu] Code: ff 0f b6 4d ce 44 0f b6 45 cf 44 0f b6 c8 45 89 cf 44 89 e2 48 c7 c6 f0 34 bc c0 bf 04 00 00 00 e8 63 b0 90 ff 45 84 ff 75 02 <0f> 0b 42 0f b6 04 73 8d 50 f6 80 fa 02 77 8c 3c 0a 0f 85 c8 00 00 RSP: 0018:ffffa99d02726fd0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffa99d02727035 RCX: 0000000000000006 RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffff976acc857440 RBP: ffffa99d02727018 R08: 0000000000000002 R09: 000000000002a600 R10: ffffe90610193680 R11: 00000000000005e3 R12: 000000000000005d R13: ffff976ac4b201b8 R14: 0000000000000001 R15: 0000000000000000 FS: 00007f14f99e1680(0000) GS:ffff976acc840000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fdf212843b8 CR3: 0000000408906000 CR4: 00000000003406e0 Call Trace: core_link_enable_stream+0x626/0x680 [amdgpu] dce110_apply_ctx_to_hw+0x414/0x4e0 [amdgpu] dc_commit_state+0x331/0x5e0 [amdgpu] ? drm_calc_timestamping_constants+0xf9/0x150 [drm] amdgpu_dm_atomic_commit_tail+0x395/0x1e00 [amdgpu] ? dm_plane_helper_prepare_fb+0x20c/0x280 [amdgpu] commit_tail+0x42/0x70 [drm_kms_helper] drm_atomic_helper_commit+0x10c/0x120 [drm_kms_helper] amdgpu_dm_atomic_commit+0x95/0xa0 [amdgpu] drm_atomic_commit+0x4a/0x50 [drm] restore_fbdev_mode_atomic+0x1c0/0x1e0 [drm_kms_helper] restore_fbdev_mode+0x4c/0x160 [drm_kms_helper] ? _cond_resched+0x19/0x40 drm_fb_helper_restore_fbdev_mode_unlocked+0x4e/0xa0 [drm_kms_helper] drm_fb_helper_set_par+0x2d/0x50 [drm_kms_helper] fbcon_init+0x471/0x630 visual_init+0xd5/0x130 do_bind_con_driver+0x20a/0x430 do_take_over_console+0x7d/0x1b0 do_fbcon_takeover+0x5c/0xb0 fbcon_event_notify+0x6cd/0x8a0 notifier_call_chain+0x4c/0x70 blocking_notifier_call_chain+0x43/0x60 fb_notifier_call_chain+0x1b/0x20 register_framebuffer+0x254/0x360 __drm_fb_helper_initial_config_and_unlock+0x2c5/0x510 [drm_kms_helper] drm_fb_helper_initial_config+0x35/0x40 [drm_kms_helper] amdgpu_fbdev_init+0xcd/0x100 [amdgpu] amdgpu_device_init+0x1156/0x1930 [amdgpu] amdgpu_driver_load_kms+0x8d/0x2e0 [amdgpu] drm_dev_register+0x12b/0x1c0 [drm] amdgpu_pci_probe+0xd3/0x160 [amdgpu] local_pci_probe+0x47/0xa0 pci_device_probe+0x142/0x1b0 really_probe+0xf5/0x3d0 driver_probe_device+0x11b/0x130 device_driver_attach+0x58/0x60 __driver_attach+0xa3/0x140 ? device_driver_attach+0x60/0x60 ? device_driver_attach+0x60/0x60 bus_for_each_dev+0x74/0xb0 ? kmem_cache_alloc_trace+0x1a3/0x1c0 driver_attach+0x1e/0x20 bus_add_driver+0x147/0x220 ? 0xffffffffc0cb9000 driver_register+0x60/0x100 ? 0xffffffffc0cb9000 __pci_register_driver+0x5a/0x60 amdgpu_init+0x74/0x83 [amdgpu] do_one_initcall+0x4a/0x1fa ? _cond_resched+0x19/0x40 ? kmem_cache_alloc_trace+0x3f/0x1c0 ? __vunmap+0x1cc/0x200 do_init_module+0x5f/0x227 load_module+0x2330/0x2b40 __do_sys_finit_module+0xfc/0x120 ? __do_sys_finit_module+0xfc/0x120 __x64_sys_finit_module+0x1a/0x20 do_syscall_64+0x5a/0x130 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f14f9500839 Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89
f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 1f f6 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007fff9bc4f5a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 000055afb5abce30 RCX: 00007f14f9500839
RDX: 0000000000000000 RSI: 000055afb5ace0f0 RDI: 0000000000000017
RBP: 000055afb5ace0f0 R08: 0000000000000000 R09: 000000000000000a
R10: 0000000000000017 R11: 0000000000000246 R12: 0000000000000000
R13: 000055afb5aad800 R14: 0000000000020000 R15: 0000000000000000
---[ end trace c286e96563966f08 ]---
This commit reworks the way that we handle i2c write for retimer in the way that we abort this configuration if the feature is not available in the device. For debug sake, we kept a simple log message in case the retimer is not available.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 67 ++++++++----------- 1 file changed, 29 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +29 -38
@@ -1733,8 +1733,7 @@ static void write_i2c_retimer_setting( slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A * needs to be set to 1 on every 0xA-0xC write.
@@ -1752,8 +1751,7 @@ static void write_i2c_retimer_setting( pipe_ctx->stream->link->ddc, slave_address, &offset, 1, &value, 1);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } buffer[0 ] = offset;
@@ -1765,8 +1763,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } } }
@@ -1786,8 +1783,7 @@ static void write_i2c_retimer_setting( slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A * needs to be set to 1 on every 0xA-0xC write.
@@ -1805,8 +1801,7 @@ static void write_i2c_retimer_setting( pipe_ctx->stream->link->ddc, slave_address, &offset, 1, &value, 1);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } buffer[0 ] = offset;
@@ -1818,8 +1813,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } } }
@@ -1837,8 +1831,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x00 to 0x23 */ buffer[0 ] =0x00 ;
@@ -1849,8 +1842,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0xff to 0x00 */ buffer[0 ] =0xff ;
@@ -1861,10 +1853,14 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } + +return ; + +i2c_write_fail: +DC_LOG_DEBUG ("Set retimer failed" ); } static void write_i2c_default_retimer_setting(
@@ -1889,8 +1885,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1901,8 +1896,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0B to 0xDA or 0xD8 */ buffer[0 ] =0x0B ;
@@ -1913,8 +1907,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1925,8 +1918,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0C to 0x1D or 0x91 */ buffer[0 ] =0x0C ;
@@ -1937,8 +1929,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1949,8 +1940,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;if (is_vga_mode) {
@@ -1965,8 +1955,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x00 to 0x23 */ buffer[0 ] =0x00 ;
@@ -1977,8 +1966,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0xff to 0x00 */ buffer[0 ] =0xff ;
@@ -1989,9 +1977,13 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d end here\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } + +return ; + +i2c_write_fail: +DC_LOG_DEBUG ("Set default retimer failed" ); } static void write_i2c_redriver_setting(
@@ -2020,8 +2012,7 @@ static void write_i2c_redriver_setting( slave_address, buffer[3], buffer[4], buffer[5], buffer[6], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); +DC_LOG_DEBUG ("Set redriver failed" ); }static void enable_link_hdmi (struct pipe_ctx *pipe_ctx)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 161/330 clk: imx: Fix division by zero warning on pfdv2
In reply to Sasha LevinFrom: Anson Huang <[email protected]>
[ Upstream commit 28b2f82e0383e27476be8a5e13d2aea07ebeb275 ]
Fix below division by zero warning:
[ 3.176443] Division by zero in kernel. [ 3.181809] CPU: 0 PID: 88 Comm: kworker/0:2 Not tainted 5.3.0-rc2-next-20190730-63758-ge08da51-dirty #124 [ 3.191817] Hardware name: Freescale i.MX7ULP (Device Tree) [ 3.197821] Workqueue: events dbs_work_handler [ 3.202849] [<c01127d8>] (unwind_backtrace) from [<c010cd80>] (show_stack+0x10/0x14) [ 3.211058] [<c010cd80>] (show_stack) from [<c0c77e68>] (dump_stack+0xd8/0x110) [ 3.218820] [<c0c77e68>] (dump_stack) from [<c0c753c0>] (Ldiv0_64+0x8/0x18) [ 3.226263] [<c0c753c0>] (Ldiv0_64) from [<c05984b4>] (clk_pfdv2_set_rate+0x54/0xac) [ 3.234487] [<c05984b4>] (clk_pfdv2_set_rate) from [<c059192c>] (clk_change_rate+0x1a4/0x698) [ 3.243468] [<c059192c>] (clk_change_rate) from [<c0591a08>] (clk_change_rate+0x280/0x698) [ 3.252180] [<c0591a08>] (clk_change_rate) from [<c0591fc0>] (clk_core_set_rate_nolock+0x1a0/0x278) [ 3.261679] [<c0591fc0>] (clk_core_set_rate_nolock) from [<c05920c8>] (clk_set_rate+0x30/0x64) [ 3.270743] [<c05920c8>] (clk_set_rate) from [<c089cb88>] (imx7ulp_set_target+0x184/0x2a4) [ 3.279501] [<c089cb88>] (imx7ulp_set_target) from [<c0896358>] (__cpufreq_driver_target+0x188/0x514) [ 3.289196] [<c0896358>] (__cpufreq_driver_target) from [<c0899b0c>] (od_dbs_update+0x130/0x15c) [ 3.298438] [<c0899b0c>] (od_dbs_update) from [<c089a5d0>] (dbs_work_handler+0x2c/0x5c) [ 3.306914] [<c089a5d0>] (dbs_work_handler) from [<c0156858>] (process_one_work+0x2ac/0x704) [ 3.315826] [<c0156858>] (process_one_work) from [<c0156cdc>] (worker_thread+0x2c/0x574) [ 3.324404] [<c0156cdc>] (worker_thread) from [<c015cfe8>] (kthread+0x134/0x148) [ 3.332278] [<c015cfe8>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20) [ 3.339858] Exception stack(0xe82d5fb0 to 0xe82d5ff8) [ 3.345314] 5fa0: 00000000 00000000 00000000 00000000 [ 3.353926] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 3.362519] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
--- drivers/clk/imx/clk-pfdv2.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/clk/imx/clk-pfdv2.c +6 -0
@@ -139,6 +139,12 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate,u32 val;u8 frac; +if (!rate) +return -EINVAL ; + +/* PFD can NOT change rate without gating */ +WARN_ON (clk_pfdv2_is_enabled (hw)); + tmp = tmp *18 + rate /2 ;do_div (tmp, rate); frac = tmp;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 163/330 s390/irq: replace setup_irq() by request_irq()
In reply to Sasha LevinFrom: afzal mohammed <[email protected]>
[ Upstream commit 8719b6d29d2851fa84c4074bb2e5adc022911ab8 ]
request_irq() is preferred over setup_irq(). Invocations of setup_irq() occur after memory allocators are ready.
Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized.
Hence replace setup_irq() by request_irq().
[1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos
Message-Id: <[email protected]>
--- arch/s390/kernel/irq.c | 8 ++------ drivers/s390/cio/airq.c | 8 ++------ drivers/s390/cio/cio.c | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-)
arch/s390/kernel/irq.c +2 -6
@@ -294,11 +294,6 @@ static irqreturn_t do_ext_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction external_interrupt = { - .name ="EXT" , - .handler = do_ext_interrupt, -}; -void __init init_ext_interrupts (void ) {int idx;
@@ -308,7 +303,8 @@ void __init init_ext_interrupts(void)irq_set_chip_and_handler (EXT_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (EXT_INTERRUPT , &external_interrupt); +if (request_irq (EXT_INTERRUPT , do_ext_interrupt,0 ,"EXT" ,NULL )) +panic ("Failed to register EXT interrupt\n" ); }static DEFINE_SPINLOCK (irq_subclass_lock);
drivers/s390/cio/airq.c +2 -6
@@ -105,16 +105,12 @@ static irqreturn_t do_airq_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction airq_interrupt = { - .name ="AIO" , - .handler = do_airq_interrupt, -}; -void __init init_airq_interrupts (void ) {irq_set_chip_and_handler (THIN_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (THIN_INTERRUPT , &airq_interrupt); +if (request_irq (THIN_INTERRUPT , do_airq_interrupt,0 ,"AIO" ,NULL )) +panic ("Failed to register AIO interrupt\n" ); }static inline unsigned long iv_size (unsigned long bits)
drivers/s390/cio/cio.c +2 -6
@@ -563,16 +563,12 @@ static irqreturn_t do_cio_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction io_interrupt = { - .name ="I/O" , - .handler = do_cio_interrupt, -}; -void __init init_cio_interrupts (void ) {irq_set_chip_and_handler (IO_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (IO_INTERRUPT , &io_interrupt); +if (request_irq (IO_INTERRUPT , do_cio_interrupt,0 ,"I/O" ,NULL )) +panic ("Failed to register I/O interrupt\n" ); }#ifdef CONFIG_CCW_CONSOLE
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 162/330 cpu-topology: Fix the potential data corruption
In reply to Sasha LevinFrom: Zeng Tao <[email protected]>
[ Upstream commit 4a33691c4cea9eb0a7c66e87248be4637e14b180 ]
Currently there are only 10 bytes to store the cpu-topology 'name' information. Only 10 bytes copied into cluster/thread/core names.
If the cluster ID exceeds 2-digit number, it will result in the data corruption, and ending up in a dead loop in the parsing routines. The same applies to the thread names with more that 3-digit number.
This issue was found using the boundary tests under virtualised environment like QEMU.
Let us increase the buffer to fix such potential issues.
--- drivers/base/arch_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/arch_topology.c +2 -2
@@ -270,7 +270,7 @@ static int __init get_cpu_for_node(struct device_node *node)static int __init parse_core (struct device_node *core,int package_id,int core_id) { -char name[10 ]; +char name[20 ];bool leaf = true;int i =0 ;int cpu;
@@ -317,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,static int __init parse_cluster (struct device_node *cluster,int depth) { -char name[10 ]; +char name[20 ];bool leaf = true;bool has_cores = false;struct device_node *c;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 116/330 ALSA: hda: Clear RIRB status before reading WP
In reply to Sasha LevinFrom: Mohan Kumar <[email protected]>
[ Upstream commit 6d011d5057ff88ee556c000ac6fe0be23bdfcd72 ]
RIRB interrupt status getting cleared after the write pointer is read causes a race condition, where last response(s) into RIRB may remain unserviced by IRQ, eventually causing azx_rirb_get_response to fall back to polling mode. Clearing the RIRB interrupt status ahead of write pointer access ensures that this condition is avoided.
--- sound/pci/hda/hda_controller.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/pci/hda/hda_controller.c +9 -2
@@ -1159,16 +1159,23 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)if (snd_hdac_bus_handle_stream_irq (bus, status, stream_update)) active = true; -/* clear rirb int */ status =azx_readb (chip,RIRBSTS );if (status &RIRB_INT_MASK ) { +/* +* Clearing the interrupt status here ensures that no +* interrupt gets masked after the RIRB wp is read in +* snd_hdac_bus_update_rirb. This avoids a possible +* race condition where codec response in RIRB may +* remain unserviced by IRQ, eventually falling back +* to polling mode in azx_rirb_get_response. +*/ +azx_writeb (chip,RIRBSTS ,RIRB_INT_MASK ); active = true;if (status &RIRB_INT_RESPONSE ) {if (chip->driver_caps &AZX_DCAPS_CTX_WORKAROUND )udelay (80 );snd_hdac_bus_update_rirb (bus); } -azx_writeb (chip,RIRBSTS ,RIRB_INT_MASK ); } }while (active && ++repeat <10 );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 166/330 ath10k: use kzalloc to read for ath10k_sdio_hif_diag_read
In reply to Sasha LevinFrom: Wen Gong <[email protected]>
[ Upstream commit 402f2992b4d62760cce7c689ff216ea3bf4d6e8a ]
When use command to read values, it crashed.
command:
dd if=/sys/kernel/debug/ieee80211/phy0/ath10k/mem_value count=1 bs=4 skip=$((0x100233))
It will call to ath10k_sdio_hif_diag_read with address = 0x4008cc and buf_len = 4.
Then system crash:
[ 1786.013258] Unable to handle kernel paging request at virtual address ffffffc00bd45000 [ 1786.013273] Mem abort info: [ 1786.013281] ESR = 0x96000045 [ 1786.013291] Exception class = DABT (current EL), IL = 32 bits [ 1786.013299] SET = 0, FnV = 0 [ 1786.013307] EA = 0, S1PTW = 0 [ 1786.013314] Data abort info: [ 1786.013322] ISV = 0, ISS = 0x00000045 [ 1786.013330] CM = 0, WnR = 1 [ 1786.013342] swapper pgtable: 4k pages, 39-bit VAs, pgdp = 000000008542a60e [ 1786.013350] [ffffffc00bd45000] pgd=0000000000000000, pud=0000000000000000 [ 1786.013368] Internal error: Oops: 96000045 [#1] PREEMPT SMP [ 1786.013609] Process swapper/0 (pid: 0, stack limit = 0x0000000084b153c6) [ 1786.013623] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.86 #137 [ 1786.013631] Hardware name: MediaTek krane sku176 board (DT) [ 1786.013643] pstate: 80000085 (Nzcv daIf -PAN -UAO) [ 1786.013662] pc : __memcpy+0x94/0x180 [ 1786.013678] lr : swiotlb_tbl_unmap_single+0x84/0x150 [ 1786.013686] sp : ffffff8008003c60 [ 1786.013694] x29: ffffff8008003c90 x28: ffffffae96411f80 [ 1786.013708] x27: ffffffae960d2018 x26: ffffff8019a4b9a8 [ 1786.013721] x25: 0000000000000000 x24: 0000000000000001 [ 1786.013734] x23: ffffffae96567000 x22: 00000000000051d4 [ 1786.013747] x21: 0000000000000000 x20: 00000000fe6e9000 [ 1786.013760] x19: 0000000000000004 x18: 0000000000000020 [ 1786.013773] x17: 0000000000000001 x16: 0000000000000000 [ 1786.013787] x15: 00000000ffffffff x14: 00000000000044c0 [ 1786.013800] x13: 0000000000365ba4 x12: 0000000000000000 [ 1786.013813] x11: 0000000000000001 x10: 00000037be6e9000 [ 1786.013826] x9 : ffffffc940000000 x8 : 000000000bd45000 [ 1786.013839] x7 : 0000000000000000 x6 : ffffffc00bd45000 [ 1786.013852] x5 : 0000000000000000 x4 : 0000000000000000 [ 1786.013865] x3 : 0000000000000c00 x2 : 0000000000000004 [ 1786.013878] x1 : fffffff7be6e9004 x0 : ffffffc00bd45000 [ 1786.013891] Call trace: [ 1786.013903] __memcpy+0x94/0x180 [ 1786.013914] unmap_single+0x6c/0x84 [ 1786.013925] swiotlb_unmap_sg_attrs+0x54/0x80 [ 1786.013938] __swiotlb_unmap_sg_attrs+0x8c/0xa4 [ 1786.013952] msdc_unprepare_data+0x6c/0x84 [ 1786.013963] msdc_request_done+0x58/0x84 [ 1786.013974] msdc_data_xfer_done+0x1a0/0x1c8 [ 1786.013985] msdc_irq+0x12c/0x17c [ 1786.013996] __handle_irq_event_percpu+0xe4/0x250 [ 1786.014006] handle_irq_event_percpu+0x28/0x68 [ 1786.014015] handle_irq_event+0x48/0x78 [ 1786.014026] handle_fasteoi_irq+0xd0/0x1a0 [ 1786.014039] __handle_domain_irq+0x84/0xc4 [ 1786.014050] gic_handle_irq+0x124/0x1a4 [ 1786.014059] el1_irq+0xb0/0x128 [ 1786.014072] cpuidle_enter_state+0x298/0x328 [ 1786.014082] cpuidle_enter+0x30/0x40 [ 1786.014094] do_idle+0x190/0x268 [ 1786.014104] cpu_startup_entry+0x24/0x28 [ 1786.014116] rest_init+0xd4/0xe0 [ 1786.014126] start_kernel+0x30c/0x38c [ 1786.014139] Code: f8408423 f80084c3 36100062 b8404423 (b80044c3) [ 1786.014150] ---[ end trace 3b02ddb698ea69ee ]--- [ 1786.015415] Kernel panic - not syncing: Fatal exception in interrupt [ 1786.015433] SMP: stopping secondary CPUs [ 1786.015447] Kernel Offset: 0x2e8d200000 from 0xffffff8008000000 [ 1786.015458] CPU features: 0x0,2188200c [ 1786.015466] Memory Limit: none
For sdio chip, it need the memory which is kmalloc, if it is vmalloc from ath10k_mem_value_read, then it have a memory error. kzalloc of ath10k_sdio_hif_diag_read32 is the correct type, so add kzalloc in ath10k_sdio_hif_diag_read to replace the buffer which is vmalloc from ath10k_mem_value_read.
This patch only effect sdio chip.
Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.
--- drivers/net/wireless/ath/ath10k/sdio.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/sdio.c +14 -4
@@ -1582,23 +1582,33 @@ static int ath10k_sdio_hif_diag_read(struct ath10k *ar, u32 address, void *buf, size_t buf_len) {int ret; +void *mem; + + mem =kzalloc (buf_len,GFP_KERNEL ); +if (!mem) +return -ENOMEM ;/* set window register to start read cycle */ ret =ath10k_sdio_write32 (ar,MBOX_WINDOW_READ_ADDR_ADDRESS , address);if (ret) {ath10k_warn (ar,"failed to set mbox window read address: %d" , ret); -return ret; + goto out; }/* read the data */ - ret =ath10k_sdio_read (ar,MBOX_WINDOW_DATA_ADDRESS , buf, buf_len); + ret =ath10k_sdio_read (ar,MBOX_WINDOW_DATA_ADDRESS , mem, buf_len);if (ret) {ath10k_warn (ar,"failed to read from mbox window data address: %d\n" , ret); -return ret; + goto out; } -return 0 ; +memcpy (buf, mem, buf_len); + +out: +kfree (mem); + +return ret; } static int ath10k_sdio_hif_diag_read32(struct ath10k *ar, u32 address,
Signature · 7 lines
2.25.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 167/330 scsi: aacraid: Disabling TM path and only processing IOP reset
In reply to Sasha LevinFrom: Sagar Biradar <[email protected]>
[ Upstream commit bef18d308a2215eff8c3411a23d7f34604ce56c3 ]
Fixes the occasional adapter panic when sg_reset is issued with -d, -t, -b and -H flags. Removal of command type HBA_IU_TYPE_SCSI_TM_REQ in aac_hba_send since iu_type, request_id and fib_flags are not populated. Device and target reset handlers are made to send TMF commands only when reset_state is 0.
--- drivers/scsi/aacraid/commsup.c | 2 +- drivers/scsi/aacraid/linit.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-)
drivers/scsi/aacraid/commsup.c +1 -1
@@ -728,7 +728,7 @@ int aac_hba_send(u8 command, struct fib *fibptr, fib_callback callback, hbacmd->request_id =cpu_to_le32 ((((u32)(fibptr - dev->fibs)) <<2 ) +1 ); fibptr->flags |=FIB_CONTEXT_FLAG_SCSI_CMD ; - }else if (command !=HBA_IU_TYPE_SCSI_TM_REQ ) + }else return -EINVAL ;
drivers/scsi/aacraid/linit.c +25 -9
@@ -723,7 +723,11 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) status =aac_hba_send (HBA_IU_TYPE_SCSI_TM_REQ , fib, (fib_callback ) aac_hba_callback, (void *) cmd); - +if (status != -EINPROGRESS ) { +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + }/* Wait up to 15 secs for completion */ for (count =0 ; count <15 ; ++count) {if (cmd->SCp.sent_command) {
@@ -902,11 +906,11 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) info = &aac->hba_map[bus][cid]; -if (info->devtype !=AAC_DEVTYPE_NATIVE_RAW && - info->reset_state >0 ) +if (!(info->devtype ==AAC_DEVTYPE_NATIVE_RAW && + !(info->reset_state >0 )))return FAILED ; -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" , +pr_err ("%s: Host device reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); fib =aac_fib_alloc (aac);
@@ -921,7 +925,12 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) status =aac_hba_send (command, fib, (fib_callback ) aac_tmf_callback, (void *) info); - +if (status != -EINPROGRESS ) { + info->reset_state =0 ; +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + }/* Wait up to 15 seconds for completion */ for (count =0 ; count <15 ; ++count) {if (info->reset_state ==0 ) {
@@ -960,11 +969,11 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) info = &aac->hba_map[bus][cid]; -if (info->devtype !=AAC_DEVTYPE_NATIVE_RAW && - info->reset_state >0 ) +if (!(info->devtype ==AAC_DEVTYPE_NATIVE_RAW && + !(info->reset_state >0 )))return FAILED ; -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" , +pr_err ("%s: Host target reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); fib =aac_fib_alloc (aac);
@@ -981,6 +990,13 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) (fib_callback ) aac_tmf_callback, (void *) info); +if (status != -EINPROGRESS ) { + info->reset_state =0 ; +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + } +/* Wait up to 15 seconds for completion */ for (count =0 ; count <15 ; ++count) {if (info->reset_state <=0 ) {
@@ -1033,7 +1049,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd) } } -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); +pr_err ("%s: Host bus reset request. SCSI hang ?\n" ,AAC_DRIVERNAME );/* * Check the health of the controller
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 176/330 rtc: ds1374: fix possible race condition
In reply to Sasha LevinFrom: Alexandre Belloni <[email protected]>
[ Upstream commit c11af8131a4e7ba1960faed731ee7e84c2c13c94 ]
The RTC IRQ is requested before the struct rtc_device is allocated, this may lead to a NULL pointer dereference in the IRQ handler.
To fix this issue, allocating the rtc_device struct before requesting the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device to register the RTC device.
--- drivers/rtc/rtc-ds1374.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ds1374.c +9 -6
@@ -620,6 +620,10 @@ static int ds1374_probe(struct i2c_client *client,if (!ds1374)return -ENOMEM ; + ds1374->rtc =devm_rtc_allocate_device (&client->dev); +if (IS_ERR (ds1374->rtc)) +return PTR_ERR (ds1374->rtc); + ds1374->client = client;i2c_set_clientdata (client, ds1374);
@@ -641,12 +645,11 @@ static int ds1374_probe(struct i2c_client *client,device_set_wakeup_capable (&client->dev,1 ); } - ds1374->rtc =devm_rtc_device_register (&client->dev, client->name, - &ds1374_rtc_ops,THIS_MODULE ); -if (IS_ERR (ds1374->rtc)) { -dev_err (&client->dev,"unable to register the class device\n" ); -return PTR_ERR (ds1374->rtc); - } + ds1374->rtc->ops = &ds1374_rtc_ops; + + ret =rtc_register_device (ds1374->rtc); +if (ret) +return ret;#ifdef CONFIG_RTC_DRV_DS1374_WDT save_client = client;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 179/330 intel_th: Disallow multi mode on devices where it's broken
In reply to Sasha LevinFrom: Alexander Shishkin <[email protected]>
[ Upstream commit 397c7729665a3b07a7b4ce7215173df8e9112809 ]
Some versions of Intel TH have an issue that prevents the multi mode of MSU from working correctly, resulting in no trace data and potentially stuck MSU pipeline.
Disable multi mode on such devices.
--- drivers/hwtracing/intel_th/intel_th.h | 2 ++ drivers/hwtracing/intel_th/msu.c | 11 +++++++++-- drivers/hwtracing/intel_th/pci.c | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/hwtracing/intel_th/intel_th.h +2 -0
@@ -47,11 +47,13 @@ struct intel_th_output {/** * struct intel_th_drvdata - describes hardware capabilities and quirks * @tscu_enable: device needs SW to enable time stamping unit +* @multi_is_broken: device has multiblock mode is broken * @has_mintctl: device has interrupt control (MINTCTL) register * @host_mode_only: device can only operate in 'host debugger' mode */ struct intel_th_drvdata {unsigned int tscu_enable :1 , + multi_is_broken :1 , has_mintctl :1 , host_mode_only :1 ; };
drivers/hwtracing/intel_th/msu.c +9 -2
@@ -157,7 +157,8 @@ struct msc {/* config */ unsigned int enabled : 1, wrap : 1, - do_irq : 1; + do_irq : 1, + multi_is_broken : 1;unsigned int mode;unsigned int burst_len;unsigned int index;
@@ -1665,7 +1666,7 @@ static int intel_th_msc_init(struct msc *msc) {atomic_set (&msc->user_count,-1 ); - msc->mode =MSC_MODE_MULTI ; + msc->mode = msc->multi_is_broken ?MSC_MODE_SINGLE :MSC_MODE_MULTI ;mutex_init (&msc->buf_mutex);INIT_LIST_HEAD (&msc->win_list);INIT_LIST_HEAD (&msc->iter_list);
@@ -1877,6 +1878,9 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,return -EINVAL ; found: +if (i ==MSC_MODE_MULTI && msc->multi_is_broken) +return -EOPNOTSUPP ; +mutex_lock (&msc->buf_mutex); ret =0 ;
@@ -2083,6 +2087,9 @@ static int intel_th_msc_probe(struct intel_th_device *thdev)if (!res) msc->do_irq =1 ; +if (INTEL_TH_CAP (to_intel_th (thdev), multi_is_broken)) + msc->multi_is_broken =1 ; + msc->index = thdev->id; msc->thdev = thdev;
drivers/hwtracing/intel_th/pci.c +6 -2
@@ -120,6 +120,10 @@ static void intel_th_pci_remove(struct pci_dev *pdev)pci_free_irq_vectors (pdev); } +static const struct intel_th_drvdata intel_th_1x_multi_is_broken = { + .multi_is_broken =1 , +}; +static const struct intel_th_drvdata intel_th_2x = { .tscu_enable =1 , .has_mintctl =1 ,
@@ -152,7 +156,7 @@ static const struct pci_device_id intel_th_pci_id_table[] = { {/* Kaby Lake PCH-H */ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6), - .driver_data = (kernel_ulong_t)0, + .driver_data = (kernel_ulong_t)&intel_th_1x_multi_is_broken, }, {/* Denverton */
@@ -207,7 +211,7 @@ static const struct pci_device_id intel_th_pci_id_table[] = { {/* Comet Lake PCH-V */ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa3a6), - .driver_data = (kernel_ulong_t)&intel_th_2x, + .driver_data = (kernel_ulong_t)&intel_th_1x_multi_is_broken, }, {/* Ice Lake NNPI */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 181/330 drm/msm: fix leaks if initialization fails
In reply to Sasha LevinFrom: Pavel Machek <[email protected]>
[ Upstream commit 66be340f827554cb1c8a1ed7dea97920b4085af2 ]
We should free resources in unlikely case of allocation failure.
--- drivers/gpu/drm/msm/msm_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +4 -2
@@ -444,8 +444,10 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)if (!dev->dma_parms) { dev->dma_parms =devm_kzalloc (dev,sizeof (*dev->dma_parms),GFP_KERNEL ); -if (!dev->dma_parms) -return -ENOMEM ; +if (!dev->dma_parms) { + ret = -ENOMEM ; + goto err_msm_uninit; + } }dma_set_max_seg_size (dev,DMA_BIT_MASK (32 ));
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 182/330 drm/msm/a5xx: Always set an OPP supported hardware value
In reply to Sasha LevinFrom: Jordan Crouse <[email protected]>
[ Upstream commit 0478b4fc5f37f4d494245fe7bcce3f531cf380e9 ]
If the opp table specifies opp-supported-hw as a property but the driver has not set a supported hardware value the OPP subsystem will reject all the table entries.
Set a "default" value that will match the default table entries but not conflict with any possible real bin values. Also fix a small memory leak and free the buffer allocated by nvmem_cell_read().
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +20 -7
@@ -1407,18 +1407,31 @@ static const struct adreno_gpu_funcs funcs = {static void check_speed_bin (struct device *dev) {struct nvmem_cell *cell; -u32 bin, val; +u32 val; + +/* +* If the OPP table specifies a opp-supported-hw property then we have +* to set something with dev_pm_opp_set_supported_hw() or the table +* doesn't get populated so pick an arbitrary value that should +* ensure the default frequencies are selected but not conflict with any +* actual bins +*/ + val =0x80 ; cell =nvmem_cell_get (dev,"speed_bin" ); -/* If a nvmem cell isn't defined, nothing to do */ -if (IS_ERR (cell)) -return ; +if (!IS_ERR (cell)) { +void *buf =nvmem_cell_read (cell,NULL ); + +if (!IS_ERR (buf)) { +u8 bin = *((u8 *) buf); - bin = *((u32 *)nvmem_cell_read (cell,NULL )); -nvmem_cell_put (cell); + val = (1 << bin); +kfree (buf); + } - val = (1 << bin); +nvmem_cell_put (cell); + }dev_pm_opp_set_supported_hw (dev, &val,1 ); }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 178/330 RDMA/cm: Remove a race freeing timewait_info
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit bede86a39d9dc3387ac00dcb8e1ac221676b2f25 ]
When creating a cm_id during REQ the id immediately becomes visible to the other MAD handlers, and shortly after the state is moved to IB_CM_REQ_RCVD
This allows cm_rej_handler() to run concurrently and free the work:
CPU 0 CPU1
cm_req_handler()
ib_create_cm_id()
cm_match_req()
id_priv->state = IB_CM_REQ_RCVD
cm_rej_handler()
cm_acquire_id()
spin_lock(&id_priv->lock)
switch (id_priv->state)
case IB_CM_REQ_RCVD:
cm_reset_to_idle()
kfree(id_priv->timewait_info);
goto destroy
destroy:
kfree(id_priv->timewait_info);
id_priv->timewait_info = NULLCausing a double free or worse.
Do not free the timewait_info without also holding the id_priv->lock. Simplify this entire flow by making the free unconditional during cm_destroy_id() and removing the confusing special case error unwind during creation of the timewait_info.
This also fixes a leak of the timewait if cm_destroy_id() is called in IB_CM_ESTABLISHED with an XRC TGT QP. The state machine will be left in ESTABLISHED while it needed to transition through IB_CM_TIMEWAIT to release the timewait pointer.
Also fix a leak of the timewait_info if the caller mis-uses the API and does ib_send_cm_reqs().
--- drivers/infiniband/core/cm.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/infiniband/core/cm.c +15 -10
@@ -1092,14 +1092,22 @@ retest:break ; } -spin_lock_irq (&cm.lock); +spin_lock_irq (&cm_id_priv->lock); +spin_lock (&cm.lock); +/* Required for cleanup paths related cm_req_handler() */ +if (cm_id_priv->timewait_info) { +cm_cleanup_timewait (cm_id_priv->timewait_info); +kfree (cm_id_priv->timewait_info); + cm_id_priv->timewait_info =NULL ; + }if (!list_empty (&cm_id_priv->altr_list) && (!cm_id_priv->altr_send_port_not_ready))list_del (&cm_id_priv->altr_list);if (!list_empty (&cm_id_priv->prim_list) && (!cm_id_priv->prim_send_port_not_ready))list_del (&cm_id_priv->prim_list); -spin_unlock_irq (&cm.lock); +spin_unlock (&cm.lock); +spin_unlock_irq (&cm_id_priv->lock);cm_free_id (cm_id->local_id);cm_deref_id (cm_id_priv);
@@ -1416,7 +1424,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,/* Verify that we're not in timewait. */ cm_id_priv = container_of(cm_id, struct cm_id_private, id);spin_lock_irqsave (&cm_id_priv->lock, flags); -if (cm_id->state !=IB_CM_IDLE ) { +if (cm_id->state !=IB_CM_IDLE ||WARN_ON (cm_id_priv->timewait_info)) {spin_unlock_irqrestore (&cm_id_priv->lock, flags); ret = -EINVAL ; goto out;
@@ -1434,12 +1442,12 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, param->ppath_sgid_attr, &cm_id_priv->av, cm_id_priv);if (ret) - goto error1; + goto out;if (param->alternate_path) { ret =cm_init_av_by_path (param->alternate_path,NULL , &cm_id_priv->alt_av, cm_id_priv);if (ret) - goto error1; + goto out; } cm_id->service_id = param->service_id; cm_id->service_mask = ~cpu_to_be64 (0 );
@@ -1457,7 +1465,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, ret =cm_alloc_msg (cm_id_priv, &cm_id_priv->msg);if (ret) - goto error1; + goto out; req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad;cm_format_req (req_msg, cm_id_priv, param);
@@ -1480,7 +1488,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,return 0 ; error2:cm_free_msg (cm_id_priv->msg); -error1:kfree (cm_id_priv->timewait_info); out:return ret; }EXPORT_SYMBOL (ib_send_cm_req);
@@ -1965,7 +1972,7 @@ static int cm_req_handler(struct cm_work *work)pr_debug ("%s: local_id %d, no listen_cm_id_priv\n" , __func__,be32_to_cpu (cm_id->local_id)); ret = -EINVAL ; - goto free_timeinfo; + goto destroy; } cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
@@ -2050,8 +2057,6 @@ static int cm_req_handler(struct cm_work *work) rejected:atomic_dec (&cm_id_priv->refcount);cm_deref_id (listen_cm_id_priv); -free_timeinfo: -kfree (cm_id_priv->timewait_info); destroy:ib_destroy_cm_id (cm_id);return ret;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 177/330 nfsd: Don't add locks to closed or closing open stateids
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit a451b12311aa8c96c6f6e01c783a86995dc3ec6b ]
In NFSv4, the lock stateids are tied to the lockowner, and the open stateid, so that the action of closing the file also results in either an automatic loss of the locks, or an error of the form NFS4ERR_LOCKS_HELD.
In practice this means we must not add new locks to the open stateid after the close process has been invoked. In fact doing so, can result in the following panic:
kernel BUG at lib/list_debug.c:51!
invalid opcode: 0000 [#1] SMP NOPTI
CPU: 2 PID: 1085 Comm: nfsd Not tainted 5.6.0-rc3+ #2 Hardware name: VMware, Inc. VMware7,1/440BX Desktop Reference Platform, BIOS VMW71.00V.14410784.B64.1908150010 08/15/2019 RIP: 0010:__list_del_entry_valid.cold+0x31/0x55 Code: 1a 3d 9b e8 74 10 c2 ff 0f 0b 48 c7 c7 f0 1a 3d 9b e8 66 10 c2 ff 0f 0b 48 89 f2 48 89 fe 48 c7 c7 b0 1a 3d 9b e8 52 10 c2 ff <0f> 0b 48 89 fe 4c 89 c2 48 c7 c7 78 1a 3d 9b e8 3e 10 c2 ff 0f 0b RSP: 0018:ffffb296c1d47d90 EFLAGS: 00010246 RAX: 0000000000000054 RBX: ffff8ba032456ec8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff8ba039e99cc8 RDI: ffff8ba039e99cc8 RBP: ffff8ba032456e60 R08: 0000000000000781 R09: 0000000000000003 R10: 0000000000000000 R11: 0000000000000001 R12: ffff8ba009a4abe0 R13: ffff8ba032456e8c R14: 0000000000000000 R15: ffff8ba00adb01d8 FS: 0000000000000000(0000) GS:ffff8ba039e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb213f0b008 CR3: 00000001347de006 CR4: 00000000003606e0 Call Trace: release_lock_stateid+0x2b/0x80 [nfsd] nfsd4_free_stateid+0x1e9/0x210 [nfsd] nfsd4_proc_compound+0x414/0x700 [nfsd] ? nfs4svc_decode_compoundargs+0x407/0x4c0 [nfsd] nfsd_dispatch+0xc1/0x200 [nfsd] svc_process_common+0x476/0x6f0 [sunrpc] ? svc_sock_secure_port+0x12/0x30 [sunrpc] ? svc_recv+0x313/0x9c0 [sunrpc] ? nfsd_svc+0x2d0/0x2d0 [nfsd] svc_process+0xd4/0x110 [sunrpc] nfsd+0xe3/0x140 [nfsd] kthread+0xf9/0x130 ? nfsd_destroy+0x50/0x50 [nfsd] ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
The fix is to ensure that lock creation tests for whether or not the open stateid is unhashed, and to fail if that is the case.
--- fs/nfsd/nfs4state.c | 73 ++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 30 deletions(-)
fs/nfsd/nfs4state.c +43 -30
@@ -495,6 +495,8 @@ find_any_file(struct nfs4_file *f) {struct nfsd_file *ret; +if (!f) +return NULL ;spin_lock (&f->fi_lock); ret =__nfs4_get_fd (f,O_RDWR );if (!ret) {
@@ -1273,6 +1275,12 @@ static void nfs4_put_stateowner(struct nfs4_stateowner *sop)nfs4_free_stateowner (sop); } +static bool +nfs4_ol_stateid_unhashed (const struct nfs4_ol_stateid *stp) +{ +return list_empty (&stp->st_perfile); +} +static bool unhash_ol_stateid (struct nfs4_ol_stateid *stp) {struct nfs4_file *fp = stp->st_stid.sc_file;
@@ -1343,9 +1351,11 @@ static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) {lockdep_assert_held (&stp->st_stid.sc_client->cl_lock); +if (!unhash_ol_stateid (stp)) +return false;list_del_init (&stp->st_locks);nfs4_unhash_stid (&stp->st_stid); -return unhash_ol_stateid (stp); +return true; }static void release_lock_stateid (struct nfs4_ol_stateid *stp)
@@ -1410,13 +1420,12 @@ static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp,static bool unhash_open_stateid (struct nfs4_ol_stateid *stp,struct list_head *reaplist) { -bool unhashed; -lockdep_assert_held (&stp->st_stid.sc_client->cl_lock); - unhashed =unhash_ol_stateid (stp); +if (!unhash_ol_stateid (stp)) +return false;release_open_stateid_locks (stp, reaplist); -return unhashed; +return true; }static void release_open_stateid (struct nfs4_ol_stateid *stp)
@@ -6267,21 +6276,21 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, }static struct nfs4_ol_stateid * -find_lock_stateid (struct nfs4_lockowner *lo,struct nfs4_file *fp) +find_lock_stateid (const struct nfs4_lockowner *lo, +const struct nfs4_ol_stateid *ost) {struct nfs4_ol_stateid *lst; -struct nfs4_client *clp = lo->lo_owner.so_client; -lockdep_assert_held (&clp->cl_lock); +lockdep_assert_held (&ost->st_stid.sc_client->cl_lock); -list_for_each_entry (lst, &lo->lo_owner.so_stateids, st_perstateowner) { -if (lst->st_stid.sc_type !=NFS4_LOCK_STID ) -continue ; -if (lst->st_stid.sc_file == fp) { -refcount_inc (&lst->st_stid.sc_count); -return lst; +/* If ost is not hashed, ost->st_locks will not be valid */ +if (!nfs4_ol_stateid_unhashed (ost)) +list_for_each_entry (lst, &ost->st_locks, st_locks) { +if (lst->st_stateowner == &lo->lo_owner) { +refcount_inc (&lst->st_stid.sc_count); +return lst; + } } - }return NULL ; }
@@ -6297,11 +6306,11 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,mutex_lock_nested (&stp->st_mutex,OPEN_STATEID_MUTEX ); retry:spin_lock (&clp->cl_lock); -spin_lock (&fp->fi_lock); - retstp =find_lock_stateid (lo, fp); +if (nfs4_ol_stateid_unhashed (open_stp)) + goto out_close; + retstp =find_lock_stateid (lo, open_stp);if (retstp) - goto out_unlock; - + goto out_found;refcount_inc (&stp->st_stid.sc_count); stp->st_stid.sc_type =NFS4_LOCK_STID ; stp->st_stateowner =nfs4_get_stateowner (&lo->lo_owner);
@@ -6310,22 +6319,26 @@ retry: stp->st_access_bmap =0 ; stp->st_deny_bmap = open_stp->st_deny_bmap; stp->st_openstp = open_stp; +spin_lock (&fp->fi_lock);list_add (&stp->st_locks, &open_stp->st_locks);list_add (&stp->st_perstateowner, &lo->lo_owner.so_stateids);list_add (&stp->st_perfile, &fp->fi_stateids); -out_unlock:spin_unlock (&fp->fi_lock);spin_unlock (&clp->cl_lock); -if (retstp) { -if (nfsd4_lock_ol_stateid (retstp) != nfs_ok) { -nfs4_put_stid (&retstp->st_stid); - goto retry; - } -/* To keep mutex tracking happy */ -mutex_unlock (&stp->st_mutex); - stp = retstp; - }return stp; +out_found: +spin_unlock (&clp->cl_lock); +if (nfsd4_lock_ol_stateid (retstp) != nfs_ok) { +nfs4_put_stid (&retstp->st_stid); + goto retry; + } +/* To keep mutex tracking happy */ +mutex_unlock (&stp->st_mutex); +return retstp; +out_close: +spin_unlock (&clp->cl_lock); +mutex_unlock (&stp->st_mutex); +return NULL ; } static struct nfs4_ol_stateid *
@@ -6340,7 +6353,7 @@ find_or_create_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fi, *new = false;spin_lock (&clp->cl_lock); - lst =find_lock_stateid (lo, fi); + lst =find_lock_stateid (lo, ost);spin_unlock (&clp->cl_lock);if (lst !=NULL ) {if (nfsd4_lock_ol_stateid (lst) == nfs_ok)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 187/330 btrfs: do not init a reloc root if we aren't relocating
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit 2abc726ab4b83db774e315c660ab8da21477092f ]
We previously were checking if the root had a dead root before accessing root->reloc_root in order to avoid a use-after-free type bug. However this scenario happens after we've unset the reloc control, so we would have been saved if we'd simply checked for fs_info->reloc_control. At this point during relocation we no longer need to be creating new reloc roots, so simply move this check above the reloc_root checks to avoid any future races and confusion.
--- fs/btrfs/relocation.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
fs/btrfs/relocation.c +16 -4
@@ -1468,6 +1468,10 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,int clear_rsv =0 ;int ret; +if (!rc || !rc->create_reloc_tree || + root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) +return 0 ; +/* * The subvolume has reloc tree but the swap is finished, no need to * create/update the dead reloc tree
@@ -1481,10 +1485,6 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,return 0 ; } -if (!rc || !rc->create_reloc_tree || - root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) -return 0 ; -if (!trans->reloc_reserved) { rsv = trans->block_rsv; trans->block_rsv = rc->block_rsv;
@@ -2336,6 +2336,18 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, trans =NULL ; goto out; } + +/* +* At this point we no longer have a reloc_control, so we can't +* depend on btrfs_init_reloc_root to update our last_trans. +* +* But that's ok, we started the trans handle on our +* corresponding fs_root, which means it's been added to the +* dirty list. At commit time we'll still call +* btrfs_update_reloc_root() and update our root item +* appropriately. +*/ + reloc_root->last_trans = trans->transid; trans->block_rsv = rc->block_rsv; replaced =0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 188/330 btrfs: free the reloc_control in a consistent way
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit 1a0afa0ecfc4dbc8d7583d03cafd3f68f781df0c ]
If we have an error while processing the reloc roots we could leak roots that were added to rc->reloc_roots before we hit the error. We could have also not removed the reloc tree mapping from our rb_tree, so clean up any remaining nodes in the reloc root rb_tree.
--- fs/btrfs/relocation.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/btrfs/relocation.c +14 -2
@@ -4354,6 +4354,18 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)return rc; } +static void free_reloc_control (struct reloc_control *rc) +{ +struct mapping_node *node, *tmp; + +free_reloc_roots (&rc->reloc_roots); +rbtree_postorder_for_each_entry_safe (node, tmp, + &rc->reloc_root_tree.rb_root, rb_node) +kfree (node); + +kfree (rc); +} +/* * Print the block group being relocated */
@@ -4486,7 +4498,7 @@ out:btrfs_dec_block_group_ro (rc->block_group);iput (rc->data_inode);btrfs_put_block_group (rc->block_group); -kfree (rc); +free_reloc_control (rc);return err; }
@@ -4659,7 +4671,7 @@ out_clean: err = ret; out_unset:unset_reloc_control (rc); -kfree (rc); +free_reloc_control (rc); out:if (!list_empty (&reloc_roots))free_reloc_roots (&reloc_roots);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 131/330 ALSA: usb-audio: Don't create a mixer element with bogus volume range
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit e9a0ef0b5ddcbc0d56c65aefc0f18d16e6f71207 ]
Some USB-audio descriptors provide a bogus volume range (e.g. volume min and max are identical), which confuses user-space. This patch makes the driver skipping such a control element.
--- sound/usb/mixer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer.c +10 -0
@@ -1684,6 +1684,16 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,/* get min/max values */ get_min_max_with_quirks (cval,0 , kctl); +/* skip a bogus volume range */ +if (cval->max <= cval->min) { +usb_audio_dbg (mixer->chip, +"[%d] FU [%s] skipped due to invalid volume\n" , + cval->head.id, kctl->id.name); +snd_ctl_free_one (kctl); +return ; + } + +if (control ==UAC_FU_VOLUME ) {check_mapped_dB (map, cval);if (cval->dBmin < cval->dBmax || !cval->initialized) {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 192/330 serial: 8250: 8250_omap: Terminate DMA before pushing data on RX timeout
In reply to Sasha LevinFrom: Vignesh Raghavendra <[email protected]>
[ Upstream commit 7cf4df30a98175033e9849f7f16c46e96ba47f41 ]
Terminate and flush DMA internal buffers, before pushing RX data to higher layer. Otherwise, this will lead to data corruption, as driver would end up pushing stale buffer data to higher layer while actual data is still stuck inside DMA hardware and has yet not arrived at the memory.
While at that, replace deprecated dmaengine_terminate_all() with dmaengine_terminate_async().
--- drivers/tty/serial/8250/8250_omap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +4 -2
@@ -790,7 +790,10 @@ static void __dma_rx_do_complete(struct uart_8250_port *p)dmaengine_tx_status (dma->rxchan, dma->rx_cookie, &state); count = dma->rx_size - state.residue; - +if (count < dma->rx_size) +dmaengine_terminate_async (dma->rxchan); +if (!count) + goto unlock; ret =tty_insert_flip_string (tty_port, dma->rx_buf, count); p->port.icount.rx += ret;
@@ -852,7 +855,6 @@ static void omap_8250_rx_dma_flush(struct uart_8250_port *p)spin_unlock_irqrestore (&priv->rx_dma_lock, flags);__dma_rx_do_complete (p); -dmaengine_terminate_all (dma->rxchan); }static int omap_8250_rx_dma (struct uart_8250_port *p)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 191/330 serial: 8250_omap: Fix sleeping function called from invalid context during probe
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 4ce35a3617c0ac758c61122b2218b6c8c9ac9398 ]
When booting j721e the following bug is printed:
[ 1.154821] BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
[ 1.154827] in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 12, name: kworker/0:1
[ 1.154832] 3 locks held by kworker/0:1/12:
[ 1.154836] #0: ffff000840030728 ((wq_completion)events){+.+.}, at: process_one_work+0x1d4/0x6e8
[ 1.154852] #1: ffff80001214fdd8 (deferred_probe_work){+.+.}, at: process_one_work+0x1d4/0x6e8
[ 1.154860] #2: ffff00084060b170 (&dev->mutex){....}, at: __device_attach+0x38/0x138
[ 1.154872] irq event stamp: 63096
[ 1.154881] hardirqs last enabled at (63095): [<ffff800010b74318>] _raw_spin_unlock_irqrestore+0x70/0x78
[ 1.154887] hardirqs last disabled at (63096): [<ffff800010b740d8>] _raw_spin_lock_irqsave+0x28/0x80
[ 1.154893] softirqs last enabled at (62254): [<ffff800010080c88>] _stext+0x488/0x564
[ 1.154899] softirqs last disabled at (62247): [<ffff8000100fdb3c>] irq_exit+0x114/0x140
[ 1.154906] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.6.0-rc6-next-20200318-00094-g45e4089b0bd3 #221
[ 1.154911] Hardware name: Texas Instruments K3 J721E SoC (DT)
[ 1.154917] Workqueue: events deferred_probe_work_func
[ 1.154923] Call trace:
[ 1.154928] dump_backtrace+0x0/0x190
[ 1.154933] show_stack+0x14/0x20
[ 1.154940] dump_stack+0xe0/0x148
[ 1.154946] ___might_sleep+0x150/0x1f0
[ 1.154952] __might_sleep+0x4c/0x80
[ 1.154957] wait_for_completion_timeout+0x40/0x140
[ 1.154964] ti_sci_set_device_state+0xa0/0x158
[ 1.154969] ti_sci_cmd_get_device_exclusive+0x14/0x20
[ 1.154977] ti_sci_dev_start+0x34/0x50
[ 1.154984] genpd_runtime_resume+0x78/0x1f8
[ 1.154991] __rpm_callback+0x3c/0x140
[ 1.154996] rpm_callback+0x20/0x80
[ 1.155001] rpm_resume+0x568/0x758
[ 1.155007] __pm_runtime_resume+0x44/0xb0
[ 1.155013] omap8250_probe+0x2b4/0x508
[ 1.155019] platform_drv_probe+0x50/0xa0
[ 1.155023] really_probe+0xd4/0x318
[ 1.155028] driver_probe_device+0x54/0xe8
[ 1.155033] __device_attach_driver+0x80/0xb8
[ 1.155039] bus_for_each_drv+0x74/0xc0
[ 1.155044] __device_attach+0xdc/0x138
[ 1.155049] device_initial_probe+0x10/0x18
[ 1.155053] bus_probe_device+0x98/0xa0
[ 1.155058] deferred_probe_work_func+0x74/0xb0
[ 1.155063] process_one_work+0x280/0x6e8
[ 1.155068] worker_thread+0x48/0x430
[ 1.155073] kthread+0x108/0x138
[ 1.155079] ret_from_fork+0x10/0x18To fix the bug we need to first call pm_runtime_enable() prior to any pm_runtime calls.
--- drivers/tty/serial/8250/8250_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +1 -1
@@ -1234,6 +1234,7 @@ static int omap8250_probe(struct platform_device *pdev)spin_lock_init (&priv->rx_dma_lock);device_init_wakeup (&pdev->dev, true); +pm_runtime_enable (&pdev->dev);pm_runtime_use_autosuspend (&pdev->dev);/*
@@ -1247,7 +1248,6 @@ static int omap8250_probe(struct platform_device *pdev)pm_runtime_set_autosuspend_delay (&pdev->dev,-1 );pm_runtime_irq_safe (&pdev->dev); -pm_runtime_enable (&pdev->dev);pm_runtime_get_sync (&pdev->dev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 194/330 net: axienet: Convert DMA error handler to a work queue
In reply to Sasha LevinFrom: Andre Przywara <[email protected]>
[ Upstream commit 24201a64770afe2e17050b2ab9e8c0e24e9c23b2 ]
The DMA error handler routine is currently a tasklet, scheduled to run after the DMA error IRQ was handled.
However it needs to take the MDIO mutex, which is not allowed to do in a tasklet. A kernel (with debug options) complains consequently:
[ 614.050361] net eth0: DMA Tx error 0x174019
[ 614.064002] net eth0: Current BD is at: 0x8f84aa0ce
[ 614.080195] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935
[ 614.109484] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 40, name: kworker/u4:4
[ 614.135428] 3 locks held by kworker/u4:4/40:
[ 614.149075] #0: ffff000879863328 ((wq_completion)rpciod){....}, at: process_one_work+0x1f0/0x6a8
[ 614.177528] #1: ffff80001251bdf8 ((work_completion)(&task->u.tk_work)){....}, at: process_one_work+0x1f0/0x6a8
[ 614.209033] #2: ffff0008784e0110 (sk_lock-AF_INET-RPC){....}, at: tcp_sendmsg+0x24/0x58
[ 614.235429] CPU: 0 PID: 40 Comm: kworker/u4:4 Not tainted 5.6.0-rc3-00926-g4a165a9d5921 #26
[ 614.260854] Hardware name: ARM Test FPGA (DT)
[ 614.274734] Workqueue: rpciod rpc_async_schedule
[ 614.289022] Call trace:
[ 614.296871] dump_backtrace+0x0/0x1a0
[ 614.308311] show_stack+0x14/0x20
[ 614.318751] dump_stack+0xbc/0x100
[ 614.329403] ___might_sleep+0xf0/0x140
[ 614.341018] __might_sleep+0x4c/0x80
[ 614.352201] __mutex_lock+0x5c/0x8a8
[ 614.363348] mutex_lock_nested+0x1c/0x28
[ 614.375654] axienet_dma_err_handler+0x38/0x388
[ 614.389999] tasklet_action_common.isra.15+0x160/0x1a8
[ 614.405894] tasklet_action+0x24/0x30
[ 614.417297] efi_header_end+0xe0/0x494
[ 614.429020] irq_exit+0xd0/0xd8
[ 614.439047] __handle_domain_irq+0x60/0xb0
[ 614.451877] gic_handle_irq+0xdc/0x2d0
[ 614.463486] el1_irq+0xcc/0x180
[ 614.473451] __tcp_transmit_skb+0x41c/0xb58
[ 614.486513] tcp_write_xmit+0x224/0x10a0
[ 614.498792] __tcp_push_pending_frames+0x38/0xc8
[ 614.513126] tcp_rcv_established+0x41c/0x820
[ 614.526301] tcp_v4_do_rcv+0x8c/0x218
[ 614.537784] __release_sock+0x5c/0x108
[ 614.549466] release_sock+0x34/0xa0
[ 614.560318] tcp_sendmsg+0x40/0x58
[ 614.571053] inet_sendmsg+0x40/0x68
[ 614.582061] sock_sendmsg+0x18/0x30
[ 614.593074] xs_sendpages+0x218/0x328
[ 614.604506] xs_tcp_send_request+0xa0/0x1b8
[ 614.617461] xprt_transmit+0xc8/0x4f0
[ 614.628943] call_transmit+0x8c/0xa0
[ 614.640028] __rpc_execute+0xbc/0x6f8
[ 614.651380] rpc_async_schedule+0x28/0x48
[ 614.663846] process_one_work+0x298/0x6a8
[ 614.676299] worker_thread+0x40/0x490
[ 614.687687] kthread+0x134/0x138
[ 614.697804] ret_from_fork+0x10/0x18
[ 614.717319] xilinx_axienet 7fe00000.ethernet eth0: Link is Down
[ 615.748343] xilinx_axienet 7fe00000.ethernet eth0: Link is Up - 1Gbps/Full - flow control offSince tasklets are not really popular anymore anyway, lets convert this over to a work queue, which can sleep and thus can take the MDIO mutex.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +1 -1
@@ -435,7 +435,7 @@ struct axienet_local {void __iomem *regs;void __iomem *dma_regs; -struct tasklet_struct dma_err_tasklet; +struct work_struct dma_err_task;int tx_irq;int rx_irq;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12 -12
@@ -806,7 +806,7 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)/* Write to the Rx channel control register */ axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); -tasklet_schedule (&lp->dma_err_tasklet); +schedule_work (&lp->dma_err_task);axienet_dma_out32 (lp,XAXIDMA_TX_SR_OFFSET , status); } out:
@@ -855,7 +855,7 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)/* write to the Rx channel control register */ axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); -tasklet_schedule (&lp->dma_err_tasklet); +schedule_work (&lp->dma_err_task);axienet_dma_out32 (lp,XAXIDMA_RX_SR_OFFSET , status); } out:
@@ -891,7 +891,7 @@ static irqreturn_t axienet_eth_irq(int irq, void *_ndev)return IRQ_HANDLED ; } -static void axienet_dma_err_handler (unsigned long data); +static void axienet_dma_err_handler (struct work_struct *work);/** * axienet_open - Driver open routine.
@@ -935,9 +935,8 @@ static int axienet_open(struct net_device *ndev)phylink_start (lp->phylink); -/* Enable tasklets for Axi DMA error handling */ -tasklet_init (&lp->dma_err_tasklet, axienet_dma_err_handler, - (unsigned long ) lp); +/* Enable worker thread for Axi DMA error handling */ +INIT_WORK (&lp->dma_err_task, axienet_dma_err_handler);/* Enable interrupts for Axi DMA Tx */ ret = request_irq(lp->tx_irq, axienet_tx_irq, IRQF_SHARED,
@@ -966,7 +965,7 @@ err_rx_irq: err_tx_irq:phylink_stop (lp->phylink);phylink_disconnect_phy (lp->phylink); -tasklet_kill (&lp->dma_err_tasklet); +cancel_work_sync (&lp->dma_err_task);dev_err (lp->dev,"request_irq() failed\n" );return ret; }
@@ -1025,7 +1024,7 @@ static int axienet_stop(struct net_device *ndev)axienet_mdio_enable (lp);mutex_unlock (&lp->mii_bus->mdio_lock); -tasklet_kill (&lp->dma_err_tasklet); +cancel_work_sync (&lp->dma_err_task);if (lp->eth_irq >0 )free_irq (lp->eth_irq, ndev);
@@ -1505,17 +1504,18 @@ static const struct phylink_mac_ops axienet_phylink_ops = { };/** -* axienet_dma_err_handler - Tasklet handler for Axi DMA Error -* @data: Data passed +* axienet_dma_err_handler - Work queue task for Axi DMA Error +* @work: pointer to work_struct * * Resets the Axi DMA and Axi Ethernet devices, and reconfigures the * Tx/Rx BDs. */ -static void axienet_dma_err_handler (unsigned long data) +static void axienet_dma_err_handler (struct work_struct *work) {u32 axienet_status;u32 cr, i; -struct axienet_local *lp = (struct axienet_local *) data; + struct axienet_local *lp = container_of(work, struct axienet_local, + dma_err_task);struct net_device *ndev = lp->ndev;struct axidma_bd *cur_p;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 199/330 exec: Fix a deadlock in strace
In reply to Sasha LevinFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 3e74fabd39710ee29fa25618d2c2b40cfa7d76c7 ]
This fixes a deadlock in the tracer when tracing a multi-threaded application that calls execve while more than one thread are running.
I observed that when running strace on the gcc test suite, it always blocks after a while, when expect calls execve, because other threads have to be terminated. They send ptrace events, but the strace is no longer able to respond, since it is blocked in vm_access.
The deadlock is always happening when strace needs to access the tracees process mmap, while another thread in the tracee starts to execve a child process, but that cannot continue until the PTRACE_EVENT_EXIT is handled and the WIFEXITED event is received:
strace D 0 30614 30584 0x00000000
Call Trace: __schedule+0x3ce/0x6e0 schedule+0x5c/0xd0 schedule_preempt_disabled+0x15/0x20 __mutex_lock.isra.13+0x1ec/0x520 __mutex_lock_killable_slowpath+0x13/0x20 mutex_lock_killable+0x28/0x30 mm_access+0x27/0xa0 process_vm_rw_core.isra.3+0xff/0x550 process_vm_rw+0xdd/0xf0 __x64_sys_process_vm_readv+0x31/0x40 do_syscall_64+0x64/0x220 entry_SYSCALL_64_after_hwframe+0x44/0xa9
expect D 0 31933 30876 0x80004003
Call Trace: __schedule+0x3ce/0x6e0 schedule+0x5c/0xd0 flush_old_exec+0xc4/0x770 load_elf_binary+0x35a/0x16c0 search_binary_handler+0x97/0x1d0 __do_execve_file.isra.40+0x5d4/0x8a0 __x64_sys_execve+0x49/0x60 do_syscall_64+0x64/0x220 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This changes mm_access to use the new exec_update_mutex instead of cred_guard_mutex.
This patch is based on the following patch by Eric W. Biederman:
"[PATCH 0/5] Infrastructure to allow fixing exec deadlocks"
--- kernel/fork.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/fork.c +2 -2
@@ -1221,7 +1221,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)struct mm_struct *mm;int err; - err =mutex_lock_killable (&task->signal->cred_guard_mutex); + err =mutex_lock_killable (&task->signal->exec_update_mutex);if (err)return ERR_PTR (err);
@@ -1231,7 +1231,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)mmput (mm); mm =ERR_PTR (-EACCES ); } -mutex_unlock (&task->signal->cred_guard_mutex); +mutex_unlock (&task->signal->exec_update_mutex);return mm; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 198/330 exec: Add exec_update_mutex to replace cred_guard_mutex
In reply to Sasha LevinFrom: "Eric W. Biederman" <[email protected]>
[ Upstream commit eea9673250db4e854e9998ef9da6d4584857f0ea ]
The cred_guard_mutex is problematic as it is held over possibly indefinite waits for userspace. The possible indefinite waits for userspace that I have identified are: The cred_guard_mutex is held in PTRACE_EVENT_EXIT waiting for the tracer. The cred_guard_mutex is held over "put_user(0, tsk->clear_child_tid)" in exit_mm(). The cred_guard_mutex is held over "get_user(futex_offset, ...") in exit_robust_list. The cred_guard_mutex held over copy_strings.
The functions get_user and put_user can trigger a page fault which can potentially wait indefinitely in the case of userfaultfd or if userspace implements part of the page fault path.
In any of those cases the userspace process that the kernel is waiting for might make a different system call that winds up taking the cred_guard_mutex and result in deadlock.
Holding a mutex over any of those possibly indefinite waits for userspace does not appear necessary. Add exec_update_mutex that will just cover updating the process during exec where the permissions and the objects pointed to by the task struct may be out of sync.
The plan is to switch the users of cred_guard_mutex to exec_update_mutex one by one. This lets us move forward while still being careful and not introducing any regressions.
Ref: 45c1a159b85b ("Add PTRACE_O_TRACEVFORKDONE and PTRACE_O_TRACEEXIT facilities.")
Ref: 456f17cd1a28 ("[PATCH] user-vm-unlock-2.5.31-A2")
--- fs/exec.c | 22 +++++++++++++++++++--- include/linux/binfmts.h | 8 +++++++- include/linux/sched/signal.h | 9 ++++++++- init/init_task.c | 1 + kernel/fork.c | 1 + 5 files changed, 36 insertions(+), 5 deletions(-)
fs/exec.c +19 -3
@@ -1007,16 +1007,26 @@ ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) }EXPORT_SYMBOL (read_code); +/* +* Maps the mm_struct mm into the current task struct. +* On success, this function returns with the mutex +* exec_update_mutex locked. +*/ static int exec_mmap (struct mm_struct *mm) {struct task_struct *tsk;struct mm_struct *old_mm, *active_mm; +int ret;/* Notify parent that we're no longer interested in the old VM */ tsk = current; old_mm = current->mm;exec_mm_release (tsk, old_mm); + ret =mutex_lock_killable (&tsk->signal->exec_update_mutex); +if (ret) +return ret; +if (old_mm) {sync_mm_rss (old_mm);/*
@@ -1028,9 +1038,11 @@ static int exec_mmap(struct mm_struct *mm)down_read (&old_mm->mmap_sem);if (unlikely (old_mm->core_state)) {up_read (&old_mm->mmap_sem); +mutex_unlock (&tsk->signal->exec_update_mutex);return -EINTR ; } } +task_lock (tsk); active_mm = tsk->active_mm;membarrier_exec_mmap (mm);
@@ -1285,11 +1297,12 @@ int flush_old_exec(struct linux_binprm * bprm) goto out;/* -* After clearing bprm->mm (to mark that current is using the -* prepared mm now), we have nothing left of the original +* After setting bprm->called_exec_mmap (to mark that current is +* using the prepared mm now), we have nothing left of the original * process. If anything from here on returns an error, the check * in search_binary_handler() will SEGV current. */ + bprm->called_exec_mmap =1 ; bprm->mm =NULL ;set_fs (USER_DS );
@@ -1423,6 +1436,8 @@ static void free_bprm(struct linux_binprm *bprm) {free_arg_pages (bprm);if (bprm->cred) { +if (bprm->called_exec_mmap) +mutex_unlock (¤t->signal->exec_update_mutex);mutex_unlock (¤t->signal->cred_guard_mutex);abort_creds (bprm->cred); }
@@ -1472,6 +1487,7 @@ void install_exec_creds(struct linux_binprm *bprm)* credentials; any time after this it may be unlocked. */ security_bprm_committed_creds (bprm); +mutex_unlock (¤t->signal->exec_update_mutex);mutex_unlock (¤t->signal->cred_guard_mutex); }EXPORT_SYMBOL (install_exec_creds);
@@ -1663,7 +1679,7 @@ int search_binary_handler(struct linux_binprm *bprm)read_lock (&binfmt_lock);put_binfmt (fmt); -if (retval <0 && !bprm->mm) { +if (retval <0 && bprm->called_exec_mmap) {/* we got to flush_old_exec() and failed after it */ read_unlock (&binfmt_lock);force_sigsegv (SIGSEGV );
include/linux/binfmts.h +7 -1
@@ -44,7 +44,13 @@ struct linux_binprm {* exec has happened. Used to sanitize execution environment * and to set AT_SECURE auxv for glibc. */ - secureexec:1 ; + secureexec:1 , +/* +* Set by flush_old_exec, when exec_mmap has been called. +* This is past the point of no return, when the +* exec_update_mutex has been taken. +*/ + called_exec_mmap:1;#ifdef __alpha__ unsigned int taso:1;#endif
include/linux/sched/signal.h +8 -1
@@ -224,7 +224,14 @@ struct signal_struct {struct mutex cred_guard_mutex;/* guard against foreign influences on * credential calculations -* (notably. ptrace) */ +* (notably. ptrace) +* Deprecated do not use in new code. +* Use exec_update_mutex instead. +*/ +struct mutex exec_update_mutex;/* Held while task_struct is being +* updated during exec, and may have +* inconsistent permissions. +*/ } __randomize_layout;/*
init/init_task.c +1 -0
@@ -26,6 +26,7 @@ static struct signal_struct init_signals = { .multiprocess = HLIST_HEAD_INIT, .rlim = INIT_RLIMITS, .cred_guard_mutex = __MUTEX_INITIALIZER(init_signals.cred_guard_mutex), + .exec_update_mutex =__MUTEX_INITIALIZER (init_signals.exec_update_mutex), #ifdef CONFIG_POSIX_TIMERS .posix_timers =LIST_HEAD_INIT (init_signals.posix_timers), .cputimer = {
kernel/fork.c +1 -0
@@ -1586,6 +1586,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) sig->oom_score_adj_min = current->signal->oom_score_adj_min;mutex_init (&sig->cred_guard_mutex); +mutex_init (&sig->exec_update_mutex);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 200/330 selftests/ptrace: add test cases for dead-locks
In reply to Sasha LevinFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 2de4e82318c7f9d34f4b08599a612cd4cd10bf0b ]
This adds test cases for ptrace deadlocks.
Additionally fixes a compile problem in get_syscall_info.c, observed with gcc-4.8.4:
get_syscall_info.c: In function 'get_syscall_info':
get_syscall_info.c:93:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) {
^
get_syscall_info.c:93:3: note: use option -std=c99 or -std=gnu99 to compile
your code
--- tools/testing/selftests/ptrace/Makefile | 4 +- tools/testing/selftests/ptrace/vmaccess.c | 86 +++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/ptrace/vmaccess.c
tools/testing/selftests/ptrace/Makefile +2 -2
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -iquote../../../../include/uapi -Wall +CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall -TEST_GEN_PROGS := get_syscall_info peeksiginfo +TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess include ../lib.mk
tools/testing/selftests/ptrace/vmaccess.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 201/330 kernel/kcmp.c: Use new infrastructure to fix deadlocks in execve
In reply to Sasha LevinFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 454e3126cb842388e22df6b3ac3da44062c00765 ]
This changes kcmp_epoll_target to use the new exec_update_mutex instead of cred_guard_mutex.
This should be safe, as the credentials are only used for reading, and furthermore ->mm and ->sighand are updated on execve, but only under the new exec_update_mutex.
--- kernel/kcmp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/kcmp.c +4 -4
@@ -173,8 +173,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,/* * One should have enough rights to inspect task details. */ - ret =kcmp_lock (&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); + ret =kcmp_lock (&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex);if (ret) goto err; if (!ptrace_may_access(task1, PTRACE_MODE_READ_REALCREDS) ||
@@ -229,8 +229,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, } err_unlock: -kcmp_unlock (&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); +kcmp_unlock (&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex); err:put_task_struct (task1);put_task_struct (task2);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 211/330 IB/iser: Always check sig MR before putting it to the free pool
In reply to Sasha LevinFrom: Sergey Gorenko <[email protected]>
[ Upstream commit 26e28deb813eed908cf31a6052870b6493ec0e86 ]
libiscsi calls the check_protection transport handler only if SCSI-Respose is received. So, the handler is never called if iSCSI task is completed for some other reason like a timeout or error handling. And this behavior looks correct. But the iSER does not handle this case properly because it puts a non-checked signature MR to the free pool. Then the error occurs at reusing the MR because it is not allowed to invalidate a signature MR without checking.
This commit adds an extra check to iser_unreg_mem_fastreg(), which is a part of the task cleanup flow. Now the signature MR is checked there if it is needed.
--- drivers/infiniband/ulp/iser/iser_memory.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/iser/iser_memory.c +18 -3
@@ -292,12 +292,27 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, {struct iser_device *device = iser_task->iser_conn->ib_conn.device;struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; +struct iser_fr_desc *desc; +struct ib_mr_status mr_status; -if (!reg->mem_h) + desc = reg->mem_h; +if (!desc)return ; - device->reg_ops->reg_desc_put (&iser_task->iser_conn->ib_conn, - reg->mem_h); +/* +* The signature MR cannot be invalidated and reused without checking. +* libiscsi calls the check_protection transport handler only if +* SCSI-Response is received. And the signature MR is not checked if +* the task is completed for some other reason like a timeout or error +* handling. That's why we must check the signature MR here before +* putting it to the free pool. +*/ +if (unlikely (desc->sig_protected)) { + desc->sig_protected = false; +ib_check_mr_status (desc->rsc.sig_mr,IB_MR_CHECK_SIG_STATUS , + &mr_status); + } + device->reg_ops->reg_desc_put (&iser_task->iser_conn->ib_conn, desc); reg->mem_h =NULL ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 216/330 PCI: Use ioremap(), not phys_to_virt() for platform ROM
In reply to Sasha LevinFrom: Mikel Rychliski <[email protected]>
[ Upstream commit 72e0ef0e5f067fd991f702f0b2635d911d0cf208 ]
On some EFI systems, the video BIOS is provided by the EFI firmware. The boot stub code stores the physical address of the ROM image in pdev->rom. Currently we attempt to access this pointer using phys_to_virt(), which doesn't work with CONFIG_HIGHMEM.
On these systems, attempting to load the radeon module on a x86_32 kernel can result in the following:
BUG: unable to handle page fault for address: 3e8ed03c #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page *pde = 00000000 Oops: 0000 [#1] PREEMPT SMP CPU: 0 PID: 317 Comm: systemd-udevd Not tainted 5.6.0-rc3-next-20200228 #2 Hardware name: Apple Computer, Inc. MacPro1,1/Mac-F4208DC8, BIOS MP11.88Z.005C.B08.0707021221 07/02/07 EIP: radeon_get_bios+0x5ed/0xe50 [radeon] Code: 00 00 84 c0 0f 85 12 fd ff ff c7 87 64 01 00 00 00 00 00 00 8b 47 08 8b 55 b0 e8 1e 83 e1 d6 85 c0 74 1a 8b 55 c0 85 d2 74 13 <80> 38 55 75 0e 80 78 01 aa 0f 84 a4 03 00 00 8d 74 26 00 68 dc 06 EAX: 3e8ed03c EBX: 00000000 ECX: 3e8ed03c EDX: 00010000 ESI: 00040000 EDI: eec04000 EBP: eef3fc60 ESP: eef3fbe0 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010206 CR0: 80050033 CR2: 3e8ed03c CR3: 2ec77000 CR4: 000006d0 Call Trace: r520_init+0x26/0x240 [radeon] radeon_device_init+0x533/0xa50 [radeon] radeon_driver_load_kms+0x80/0x220 [radeon] drm_dev_register+0xa7/0x180 [drm] radeon_pci_probe+0x10f/0x1a0 [radeon] pci_device_probe+0xd4/0x140
Fix the issue by updating all drivers which can access a platform provided ROM. Instead of calling the helper function pci_platform_rom() which uses phys_to_virt(), call ioremap() directly on the pdev->rom.
radeon_read_platform_bios() previously directly accessed an __iomem pointer. Avoid this by calling memcpy_fromio() instead of kmemdup().
pci_platform_rom() now has no remaining callers, so remove it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 31 +++++++++++-------- .../drm/nouveau/nvkm/subdev/bios/shadowpci.c | 17 ++++++++-- drivers/gpu/drm/radeon/radeon_bios.c | 30 +++++++++++------- drivers/pci/rom.c | 17 ---------- include/linux/pci.h | 1 - 5 files changed, 52 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +18 -13
@@ -192,30 +192,35 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)static bool amdgpu_read_platform_bios (struct amdgpu_device *adev) { -uint8_t __iomem *bios; -size_t size; +phys_addr_t rom = adev->pdev->rom; +size_t romlen = adev->pdev->romlen; +void __iomem *bios; adev->bios =NULL ; - bios =pci_platform_rom (adev->pdev, &size); -if (!bios) { +if (!rom || romlen ==0 )return false; - } - adev->bios =kzalloc (size,GFP_KERNEL ); -if (adev->bios ==NULL ) + adev->bios =kzalloc (romlen,GFP_KERNEL ); +if (!adev->bios)return false; -memcpy_fromio (adev->bios, bios, size); + bios =ioremap (rom, romlen); +if (!bios) + goto free_bios; -if (!check_atom_bios (adev->bios, size)) { -kfree (adev->bios); -return false; - } +memcpy_fromio (adev->bios, bios, romlen); +iounmap (bios); - adev->bios_size = size; +if (!check_atom_bios (adev->bios, romlen)) + goto free_bios; + + adev->bios_size = romlen;return true; +free_bios: +kfree (adev->bios); +return false; }#ifdef CONFIG_ACPI
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +15 -2
@@ -101,9 +101,13 @@ platform_init(struct nvkm_bios *bios, const char *name)else return ERR_PTR (-ENODEV ); +if (!pdev->rom || pdev->romlen ==0 ) +return ERR_PTR (-ENODEV ); +if ((priv =kmalloc (sizeof (*priv),GFP_KERNEL ))) { + priv->size = pdev->romlen;if (ret = -ENODEV , - (priv->rom =pci_platform_rom (pdev, &priv->size))) + (priv->rom =ioremap (pdev->rom, pdev->romlen)))return priv;kfree (priv); }
@@ -111,11 +115,20 @@ platform_init(struct nvkm_bios *bios, const char *name)return ERR_PTR (ret); } +static void +platform_fini (void *data) +{ +struct priv *priv = data; + +iounmap (priv->rom); +kfree (priv); +} +const struct nvbios_source nvbios_platform = { .name ="PLATFORM" , .init = platform_init, - .fini = (void (*)(void *))kfree, + .fini = platform_fini, .read = pcirom_read, .rw = true, };
drivers/gpu/drm/radeon/radeon_bios.c +19 -11
@@ -108,25 +108,33 @@ static bool radeon_read_bios(struct radeon_device *rdev)static bool radeon_read_platform_bios (struct radeon_device *rdev) { -uint8_t __iomem *bios; -size_t size; +phys_addr_t rom = rdev->pdev->rom; +size_t romlen = rdev->pdev->romlen; +void __iomem *bios; rdev->bios =NULL ; - bios =pci_platform_rom (rdev->pdev, &size); -if (!bios) { +if (!rom || romlen ==0 )return false; - } -if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { + rdev->bios =kzalloc (romlen,GFP_KERNEL ); +if (!rdev->bios)return false; - } - rdev->bios =kmemdup (bios, size,GFP_KERNEL ); -if (rdev->bios ==NULL ) { -return false; - } + + bios =ioremap (rom, romlen); +if (!bios) + goto free_bios; + +memcpy_fromio (rdev->bios, bios, romlen); +iounmap (bios); + +if (rdev->bios[0 ] !=0x55 || rdev->bios[1 ] !=0xaa ) + goto free_bios;return true; +free_bios: +kfree (rdev->bios); +return false; }#ifdef CONFIG_ACPI
drivers/pci/rom.c +0 -17
@@ -195,20 +195,3 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)pci_disable_rom (pdev); }EXPORT_SYMBOL (pci_unmap_rom); - -/** -* pci_platform_rom - provides a pointer to any ROM image provided by the -* platform -* @pdev: pointer to pci device struct -* @size: pointer to receive size of pci window over ROM -*/ -void __iomem *pci_platform_rom (struct pci_dev *pdev,size_t *size) -{ -if (pdev->rom && pdev->romlen) { - *size = pdev->romlen; -return phys_to_virt ((phys_addr_t )pdev->rom); - } - -return NULL ; -} -EXPORT_SYMBOL (pci_platform_rom);
include/linux/pci.h +0 -1
@@ -1216,7 +1216,6 @@ int pci_enable_rom(struct pci_dev *pdev);void pci_disable_rom (struct pci_dev *pdev);void __iomem __must_check *pci_map_rom (struct pci_dev *pdev,size_t *size);void pci_unmap_rom (struct pci_dev *pdev,void __iomem *rom); -void __iomem __must_check *pci_platform_rom (struct pci_dev *pdev,size_t *size);/* Power management related routines */ int pci_save_state (struct pci_dev *dev);
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 210/330 RDMA/rxe: Set sys_image_guid to be aligned with HW IB devices
In reply to Sasha LevinFrom: Zhu Yanjun <[email protected]>
[ Upstream commit d0ca2c35dd15a3d989955caec02beea02f735ee6 ]
The RXE driver doesn't set sys_image_guid and user space applications see zeros. This causes to pyverbs tests to fail with the following traceback, because the IBTA spec requires to have valid sys_image_guid.
Traceback (most recent call last):
File "./tests/test_device.py", line 51, in test_query_device
self.verify_device_attr(attr)
File "./tests/test_device.py", line 74, in verify_device_attr
assert attr.sys_image_guid != 0
In order to fix it, set sys_image_guid to be equal to node_guid.
Before:
5: rxe0: ... node_guid 5054:00ff:feaa:5363 sys_image_guid 0000:0000:0000:0000
After:
5: rxe0: ... node_guid 5054:00ff:feaa:5363 sys_image_guid 5054:00ff:feaa:5363
--- drivers/infiniband/sw/rxe/rxe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +2 -0
@@ -116,6 +116,8 @@ static void rxe_init_device_param(struct rxe_dev *rxe) rxe->attr.max_fast_reg_page_list_len =RXE_MAX_FMR_PAGE_LIST_LEN ; rxe->attr.max_pkeys =RXE_MAX_PKEYS ; rxe->attr.local_ca_ack_delay =RXE_LOCAL_CA_ACK_DELAY ; +addrconf_addr_eui48 ((unsigned char *)&rxe->attr.sys_image_guid, + rxe->ndev->dev_addr); rxe->max_ucontext =RXE_MAX_UCONTEXT ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 209/330 xfs: prohibit fs freezing when using empty transactions
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 27fb5a72f50aa770dd38b0478c07acacef97e3e7 ]
I noticed that fsfreeze can take a very long time to freeze an XFS if there happens to be a GETFSMAP caller running in the background. I also happened to notice the following in dmesg:
------------[ cut here ]------------ WARNING: CPU: 2 PID: 43492 at fs/xfs/xfs_super.c:853 xfs_quiesce_attr+0x83/0x90 [xfs] Modules linked in: xfs libcrc32c ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 ip_set_hash_ip ip_set_hash_net xt_tcpudp xt_set ip_set_hash_mac ip_set nfnetlink ip6table_filter ip6_tables bfq iptable_filter sch_fq_codel ip_tables x_tables nfsv4 af_packet [last unloaded: xfs] CPU: 2 PID: 43492 Comm: xfs_io Not tainted 5.6.0-rc4-djw #rc4 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-1ubuntu1 04/01/2014 RIP: 0010:xfs_quiesce_attr+0x83/0x90 [xfs] Code: 7c 07 00 00 85 c0 75 22 48 89 df 5b e9 96 c1 00 00 48 c7 c6 b0 2d 38 a0 48 89 df e8 57 64 ff ff 8b 83 7c 07 00 00 85 c0 74 de <0f> 0b 48 89 df 5b e9 72 c1 00 00 66 90 0f 1f 44 00 00 41 55 41 54 RSP: 0018:ffffc900030f3e28 EFLAGS: 00010202 RAX: 0000000000000001 RBX: ffff88802ac54000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffff81e4a6f0 RDI: 00000000ffffffff RBP: ffff88807859f070 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000010 R12: 0000000000000000 R13: ffff88807859f388 R14: ffff88807859f4b8 R15: ffff88807859f5e8 FS: 00007fad1c6c0fc0(0000) GS:ffff88807e000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0c7d237000 CR3: 0000000077f01003 CR4: 00000000001606a0 Call Trace: xfs_fs_freeze+0x25/0x40 [xfs] freeze_super+0xc8/0x180 do_vfs_ioctl+0x70b/0x750 ? __fget_files+0x135/0x210 ksys_ioctl+0x3a/0xb0 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x50/0x1a0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
These two things appear to be related. The assertion trips when another thread initiates a fsmap request (which uses an empty transaction) after the freezer waited for m_active_trans to hit zero but before the the freezer executes the WARN_ON just prior to calling xfs_log_quiesce.
The lengthy delays in freezing happen because the freezer calls xfs_wait_buftarg to clean out the buffer lru list. Meanwhile, the GETFSMAP caller is continuing to grab and release buffers, which means that it can take a very long time for the buffer lru list to empty out.
We fix both of these races by calling sb_start_write to obtain freeze protection while using empty transactions for GETFSMAP and for metadata scrubbing. The other two users occur during mount, during which time we cannot fs freeze.
--- fs/xfs/scrub/scrub.c | 9 +++++++++ fs/xfs/xfs_fsmap.c | 9 +++++++++ fs/xfs/xfs_trans.c | 5 +++++ 3 files changed, 23 insertions(+)
fs/xfs/scrub/scrub.c +9 -0
@@ -167,6 +167,7 @@ xchk_teardown(xfs_irele (sc->ip); sc->ip =NULL ; } +sb_end_write (sc->mp->m_super);if (sc->flags &XCHK_REAPING_DISABLED )xchk_start_reaping (sc);if (sc->flags &XCHK_HAS_QUOTAOFFLOCK ) {
@@ -489,6 +490,14 @@ xfs_scrub_metadata( sc.ops = &meta_scrub_ops[sm->sm_type]; sc.sick_mask =xchk_health_mask_for_scrub_type (sm->sm_type); retry_op: +/* +* If freeze runs concurrently with a scrub, the freeze can be delayed +* indefinitely as we walk the filesystem and iterate over metadata +* buffers. Freeze quiesces the log (which waits for the buffer LRU to +* be emptied) and that won't happen while checking is running. +*/ +sb_start_write (mp->m_super); +/* Set up for the operation. */ error = sc.ops->setup (&sc, ip);if (error)
fs/xfs/xfs_fsmap.c +9 -0
@@ -895,6 +895,14 @@ xfs_getfsmap( info.format_arg = arg; info.head = head; +/* +* If fsmap runs concurrently with a scrub, the freeze can be delayed +* indefinitely as we walk the rmapbt and iterate over metadata +* buffers. Freeze quiesces the log (which waits for the buffer LRU to +* be emptied) and that won't happen while we're reading buffers. +*/ +sb_start_write (mp->m_super); +/* For each device we support... */ for (i =0 ; i <XFS_GETFSMAP_DEVS ; i++) {/* Is this device within the range the user asked for? */
@@ -934,6 +942,7 @@ xfs_getfsmap(if (tp)xfs_trans_cancel (tp); +sb_end_write (mp->m_super); head->fmh_oflags =FMH_OF_DEV_T ;return error; }
fs/xfs/xfs_trans.c +5 -0
@@ -306,6 +306,11 @@ xfs_trans_alloc(* * Note the zero-length reservation; this transaction MUST be cancelled * without any dirty data. +* +* Callers should obtain freeze protection to avoid two conflicts with fs +* freezing: (1) having active transactions trip the m_active_trans ASSERTs; +* and (2) grabbing buffers at the same time that freeze is trying to drain +* the buffer LRU list. */ int xfs_trans_alloc_empty(
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 223/330 drm/amdgpu/vcn2.0: stall DPG when WPTR/RPTR reset
In reply to Sasha LevinFrom: James Zhu <[email protected]>
[ Upstream commit ef563ff403404ef2f234abe79bdd9f04ab6481c9 ]
Add vcn dpg harware synchronization to fix race condition issue between vcn driver and hardware.
--- drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +16 -0
@@ -1026,6 +1026,10 @@ static int vcn_v2_0_start_dpg_mode(struct amdgpu_device *adev, bool indirect) tmp =REG_SET_FIELD (tmp,UVD_RBC_RB_CNTL ,RB_RPTR_WR_EN ,1 );WREG32_SOC15 (UVD ,0 , mmUVD_RBC_RB_CNTL, tmp); +/* Stall DPG before WPTR/RPTR reset */ +WREG32_P (SOC15_REG_OFFSET (UVD ,0 , mmUVD_POWER_STATUS), +UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK , + ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK );/* set the write pointer delay */ WREG32_SOC15 (UVD ,0 , mmUVD_RBC_RB_WPTR_CNTL,0 );
@@ -1048,6 +1052,9 @@ static int vcn_v2_0_start_dpg_mode(struct amdgpu_device *adev, bool indirect)WREG32_SOC15 (UVD ,0 , mmUVD_RBC_RB_WPTR,lower_32_bits (ring->wptr)); +/* Unstall DPG */ +WREG32_P (SOC15_REG_OFFSET (UVD ,0 , mmUVD_POWER_STATUS), +0 , ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK );return 0 ; }
@@ -1357,8 +1364,13 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK , UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK, ret_code); +/* Stall DPG before WPTR/RPTR reset */ +WREG32_P (SOC15_REG_OFFSET (UVD ,0 , mmUVD_POWER_STATUS), +UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK , + ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK );/* Restore */ ring = &adev->vcn.inst->ring_enc[0 ]; + ring->wptr =0 ;WREG32_SOC15 (UVD ,0 , mmUVD_RB_BASE_LO, ring->gpu_addr);WREG32_SOC15 (UVD ,0 , mmUVD_RB_BASE_HI,upper_32_bits (ring->gpu_addr));WREG32_SOC15 (UVD ,0 , mmUVD_RB_SIZE, ring->ring_size /4 );
@@ -1366,6 +1378,7 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,WREG32_SOC15 (UVD ,0 , mmUVD_RB_WPTR,lower_32_bits (ring->wptr)); ring = &adev->vcn.inst->ring_enc[1 ]; + ring->wptr =0 ;WREG32_SOC15 (UVD ,0 , mmUVD_RB_BASE_LO2, ring->gpu_addr);WREG32_SOC15 (UVD ,0 , mmUVD_RB_BASE_HI2,upper_32_bits (ring->gpu_addr));WREG32_SOC15 (UVD ,0 , mmUVD_RB_SIZE2, ring->ring_size /4 );
@@ -1374,6 +1387,9 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,WREG32_SOC15 (UVD ,0 , mmUVD_RBC_RB_WPTR,RREG32_SOC15 (UVD ,0 , mmUVD_SCRATCH2) &0x7FFFFFFF ); +/* Unstall DPG */ +WREG32_P (SOC15_REG_OFFSET (UVD ,0 , mmUVD_POWER_STATUS), +0 , ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK ); SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON,
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 221/330 PCI: pciehp: Fix MSI interrupt race
In reply to Sasha LevinFrom: Stuart Hayes <[email protected]>
[ Upstream commit 8edf5332c39340b9583cf9cba659eb7ec71f75b5 ]
Without this commit, a PCIe hotplug port can stop generating interrupts on hotplug events, so device adds and removals will not be seen:
The pciehp interrupt handler pciehp_isr() reads the Slot Status register and then writes back to it to clear the bits that caused the interrupt. If a different interrupt event bit gets set between the read and the write, pciehp_isr() returns without having cleared all of the interrupt event bits. If this happens when the MSI isn't masked (which by default it isn't in handle_edge_irq(), and which it will never be when MSI per-vector masking is not supported), we won't get any more hotplug interrupts from that device.
That is expected behavior, according to the PCIe Base Spec r5.0, section 6.7.3.4, "Software Notification of Hot-Plug Events".
Because the Presence Detect Changed and Data Link Layer State Changed event bits can both get set at nearly the same time when a device is added or removed, this is more likely to happen than it might seem. The issue was found (and can be reproduced rather easily) by connecting and disconnecting an NVMe storage device on at least one system model where the NVMe devices were being connected to an AMD PCIe port (PCI device 0x1022/0x1483).
Fix the issue by modifying pciehp_isr() to loop back and re-read the Slot Status register immediately after writing to it, until it sees that all of the event status bits have been cleared.
[lukas: drop loop count limitation, write "events" instead of "status", don't loop back in INTx and poll modes, tweak code comment & commit msg]
--- drivers/pci/hotplug/pciehp_hpc.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +20 -6
@@ -529,7 +529,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)struct controller *ctrl = (struct controller *)dev_id;struct pci_dev *pdev =ctrl_dev (ctrl);struct device *parent = pdev->dev.parent; -u16 status, events; +u16 status, events =0 ;/* * Interrupts only occur in D3hot or shallower and only if enabled
@@ -554,6 +554,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) } } +read_status:pcie_capability_read_word (pdev,PCI_EXP_SLTSTA , &status);if (status == (u16 ) ~0 ) {ctrl_info (ctrl,"%s: no response from device\n" , __func__);
@@ -566,24 +567,37 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)* Slot Status contains plain status bits as well as event * notification bits; right now we only want the event bits. */ - events = status & (PCI_EXP_SLTSTA_ABP |PCI_EXP_SLTSTA_PFD | -PCI_EXP_SLTSTA_PDC |PCI_EXP_SLTSTA_CC | -PCI_EXP_SLTSTA_DLLSC ); + status &=PCI_EXP_SLTSTA_ABP |PCI_EXP_SLTSTA_PFD | +PCI_EXP_SLTSTA_PDC |PCI_EXP_SLTSTA_CC | +PCI_EXP_SLTSTA_DLLSC ;/* * If we've already reported a power fault, don't report it again * until we've done something to handle it. */ if (ctrl->power_fault_detected) - events &= ~PCI_EXP_SLTSTA_PFD ; + status &= ~PCI_EXP_SLTSTA_PFD ; + events |= status;if (!events) {if (parent)pm_runtime_put (parent);return IRQ_NONE ; } -pcie_capability_write_word (pdev,PCI_EXP_SLTSTA , events); +if (status) { +pcie_capability_write_word (pdev,PCI_EXP_SLTSTA , events); + +/* +* In MSI mode, all event bits must be zero before the port +* will send a new interrupt (PCIe Base Spec r5.0 sec 6.7.3.4). +* So re-read the Slot Status register in case a bit was set +* between read and write. +*/ +if (pci_dev_msi_enabled (pdev) && !pciehp_poll_mode) + goto read_status; + } +ctrl_dbg (ctrl,"pending interrupts %#06x from Slot Status\n" , events);if (parent)pm_runtime_put (parent);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 225/330 mm/kmemleak.c: use address-of operator on section symbols
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit b0d14fc43d39203ae025f20ef4d5d25d9ccf4be1 ]
Clang warns:
mm/kmemleak.c:1955:28: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
^
mm/kmemleak.c:1955:60: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
--- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
@@ -1947,7 +1947,7 @@ void __init kmemleak_init(void)create_object ((unsigned long )__bss_start, __bss_stop - __bss_start,KMEMLEAK_GREY ,GFP_ATOMIC );/* only register .data..ro_after_init if not within .data */ -if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) +if (&__start_ro_after_init < &_sdata || &__end_ro_after_init > &_edata)create_object ((unsigned long )__start_ro_after_init, __end_ro_after_init - __start_ro_after_init,KMEMLEAK_GREY ,GFP_ATOMIC );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 222/330 NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests()
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit 08ca8b21f760c0ed5034a5c122092eec22ccf8f4 ]
When a subrequest is being detached from the subgroup, we want to ensure that it is not holding the group lock, or in the process of waiting for the group lock.
--- fs/nfs/pagelist.c | 67 +++++++++++++++++++++++++++------------- fs/nfs/write.c | 10 ++++-- include/linux/nfs_page.h | 2 ++ 3 files changed, 55 insertions(+), 24 deletions(-)
fs/nfs/pagelist.c +45 -22
@@ -133,47 +133,70 @@ nfs_async_iocounter_wait(struct rpc_task *task, struct nfs_lock_context *l_ctx)EXPORT_SYMBOL_GPL (nfs_async_iocounter_wait);/* -* nfs_page_group_lock - lock the head of the page group -* @req - request in group that is to be locked +* nfs_page_set_headlock - set the request PG_HEADLOCK +* @req: request that is to be locked * -* this lock must be held when traversing or modifying the page -* group list +* this lock must be held when modifying req->wb_head * * return 0 on success, < 0 on error */ int -nfs_page_group_lock (struct nfs_page *req) +nfs_page_set_headlock (struct nfs_page *req) { -struct nfs_page *head = req->wb_head; - -WARN_ON_ONCE (head != head->wb_head); - -if (!test_and_set_bit (PG_HEADLOCK , &head->wb_flags)) +if (!test_and_set_bit (PG_HEADLOCK , &req->wb_flags))return 0 ; -set_bit (PG_CONTENDED1 , &head->wb_flags); +set_bit (PG_CONTENDED1 , &req->wb_flags);smp_mb__after_atomic (); -return wait_on_bit_lock (&head->wb_flags,PG_HEADLOCK , +return wait_on_bit_lock (&req->wb_flags,PG_HEADLOCK ,TASK_UNINTERRUPTIBLE ); }/* -* nfs_page_group_unlock - unlock the head of the page group -* @req - request in group that is to be unlocked +* nfs_page_clear_headlock - clear the request PG_HEADLOCK +* @req: request that is to be locked */ void -nfs_page_group_unlock (struct nfs_page *req) +nfs_page_clear_headlock (struct nfs_page *req) { -struct nfs_page *head = req->wb_head; - -WARN_ON_ONCE (head != head->wb_head); -smp_mb__before_atomic (); -clear_bit (PG_HEADLOCK , &head->wb_flags); +clear_bit (PG_HEADLOCK , &req->wb_flags);smp_mb__after_atomic (); -if (!test_bit (PG_CONTENDED1 , &head->wb_flags)) +if (!test_bit (PG_CONTENDED1 , &req->wb_flags))return ; -wake_up_bit (&head->wb_flags,PG_HEADLOCK ); +wake_up_bit (&req->wb_flags,PG_HEADLOCK ); +} + +/* +* nfs_page_group_lock - lock the head of the page group +* @req: request in group that is to be locked +* +* this lock must be held when traversing or modifying the page +* group list +* +* return 0 on success, < 0 on error +*/ +int +nfs_page_group_lock (struct nfs_page *req) +{ +int ret; + + ret =nfs_page_set_headlock (req); +if (ret || req->wb_head == req) +return ret; +return nfs_page_set_headlock (req->wb_head); +} + +/* +* nfs_page_group_unlock - unlock the head of the page group +* @req: request in group that is to be unlocked +*/ +void +nfs_page_group_unlock (struct nfs_page *req) +{ +if (req != req->wb_head) +nfs_page_clear_headlock (req->wb_head); +nfs_page_clear_headlock (req); }/*
fs/nfs/write.c +8 -2
@@ -425,22 +425,28 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, destroy_list = (subreq->wb_this_page == old_head) ?NULL : subreq->wb_this_page; +/* Note: lock subreq in order to change subreq->wb_head */ +nfs_page_set_headlock (subreq);WARN_ON_ONCE (old_head != subreq->wb_head);/* make sure old group is not used */ subreq->wb_this_page = subreq; + subreq->wb_head = subreq;clear_bit (PG_REMOVE , &subreq->wb_flags);/* Note: races with nfs_page_group_destroy() */ if (!kref_read (&subreq->wb_kref)) {/* Check if we raced with nfs_page_group_destroy() */ -if (test_and_clear_bit (PG_TEARDOWN , &subreq->wb_flags)) +if (test_and_clear_bit (PG_TEARDOWN , &subreq->wb_flags)) { +nfs_page_clear_headlock (subreq);nfs_free_request (subreq); + }else +nfs_page_clear_headlock (subreq);continue ; } +nfs_page_clear_headlock (subreq); - subreq->wb_head = subreq;nfs_release_request (old_head);if (test_and_clear_bit (PG_INODE_REF , &subreq->wb_flags)) {
include/linux/nfs_page.h +2 -0
@@ -142,6 +142,8 @@ extern void nfs_unlock_and_release_request(struct nfs_page *);extern int nfs_page_group_lock (struct nfs_page *);extern void nfs_page_group_unlock (struct nfs_page *);extern bool nfs_page_group_sync_on_bit (struct nfs_page *,unsigned int ); +extern int nfs_page_set_headlock (struct nfs_page *req); +extern void nfs_page_clear_headlock (struct nfs_page *req);extern bool nfs_async_iocounter_wait (struct rpc_task *,struct nfs_lock_context *);/*
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 226/330 mm/filemap.c: clear page error before actual read
In reply to Sasha LevinFrom: Xianting Tian <[email protected]>
[ Upstream commit faffdfa04fa11ccf048cebdde73db41ede0679e0 ]
Mount failure issue happens under the scenario: Application forked dozens of threads to mount the same number of cramfs images separately in docker, but several mounts failed with high probability. Mount failed due to the checking result of the page(read from the superblock of loop dev) is not uptodate after wait_on_page_locked(page) returned in function cramfs_read:
wait_on_page_locked(page);
if (!PageUptodate(page)) {
...
}The reason of the checking result of the page not uptodate: systemd-udevd read the loopX dev before mount, because the status of loopX is Lo_unbound at this time, so loop_make_request directly trigger the calling of io_end handler end_buffer_async_read, which called SetPageError(page). So It caused the page can't be set to uptodate in function end_buffer_async_read:
if(page_uptodate && !PageError(page)) {
SetPageUptodate(page);
}Then mount operation is performed, it used the same page which is just accessed by systemd-udevd above, Because this page is not uptodate, it will launch a actual read via submit_bh, then wait on this page by calling wait_on_page_locked(page). When the I/O of the page done, io_end handler end_buffer_async_read is called, because no one cleared the page error(during the whole read path of mount), which is caused by systemd-udevd reading, so this page is still in "PageError" status, which can't be set to uptodate in function end_buffer_async_read, then caused mount failure.
But sometimes mount succeed even through systemd-udeved read loopX dev just before, The reason is systemd-udevd launched other loopX read just between step 3.1 and 3.2, the steps as below:
1, loopX dev default status is Lo_unbound;
2, systemd-udved read loopX dev (page is set to PageError); 3, mount operation
1) set loopX status to Lo_bound; ==>systemd-udevd read loopX dev<==
2) read loopX dev(page has no error)
3) mount succeed
As the loopX dev status is set to Lo_bound after step 3.1, so the other loopX dev read by systemd-udevd will go through the whole I/O stack, part of the call trace as below:
SYS_read
vfs_read
do_sync_read
blkdev_aio_read
generic_file_aio_read
do_generic_file_read:
ClearPageError(page);
mapping->a_ops->readpage(filp, page);here, mapping->a_ops->readpage() is blkdev_readpage. In latest kernel, some function name changed, the call trace as below:
blkdev_read_iter
generic_file_read_iter
generic_file_buffered_read:
/*
* A previous I/O error may have been due to temporary
* failures, eg. mutipath errors.
* Pg_error will be set again if readpage fails.
*/
ClearPageError(page);
/* Start the actual read. The read will unlock the page*/
error=mapping->a_ops->readpage(flip, page);We can see ClearPageError(page) is called before the actual read, then the read in step 3.2 succeed.
This patch is to add the calling of ClearPageError just before the actual read of read path of cramfs mount. Without the patch, the call trace as below when performing cramfs mount:
do_mount
cramfs_read
cramfs_blkdev_read
read_cache_page
do_read_cache_page:
filler(data, page);
or
mapping->a_ops->readpage(data, page);With the patch, the call trace as below when performing mount:
do_mount
cramfs_read
cramfs_blkdev_read
read_cache_page:
do_read_cache_page:
ClearPageError(page); <== new add
filler(data, page);
or
mapping->a_ops->readpage(data, page);With the patch, mount operation trigger the calling of ClearPageError(page) before the actual read, the page has no error if no additional page error happen when I/O done.
--- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/filemap.c +8 -0
@@ -2845,6 +2845,14 @@ filler:unlock_page (page); goto out; } + +/* +* A previous I/O error may have been due to temporary +* failures. +* Clear page error before actual read, PG_error will be +* set again if read page fails. +*/ +ClearPageError (page); goto filler; out:
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 228/330 mm/vmscan.c: fix data races using kswapd_classzone_idx
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 5644e1fbbfe15ad06785502bbfe5751223e5841d ]
pgdat->kswapd_classzone_idx could be accessed concurrently in wakeup_kswapd(). Plain writes and reads without any lock protection result in data races. Fix them by adding a pair of READ|WRITE_ONCE() as well as saving a branch (compilers might well optimize the original code in an unintentional way anyway). While at it, also take care of pgdat->kswapd_order and non-kswapd threads in allow_direct_reclaim(). The data races were reported by KCSAN,
BUG: KCSAN: data-race in wakeup_kswapd / wakeup_kswapd
write to 0xffff9f427ffff2dc of 4 bytes by task 7454 on cpu 13:
wakeup_kswapd+0xf1/0x400 wakeup_kswapd at mm/vmscan.c:3967 wake_all_kswapds+0x59/0xc0 wake_all_kswapds at mm/page_alloc.c:4241 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_slowpath at mm/page_alloc.c:4512 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x16e/0x6f0 __handle_mm_fault+0xcd5/0xd40 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
1 lock held by mtest01/7454:
#0: ffff9f425afe8808 (&mm->mmap_sem#2){++++}, at:
do_page_fault+0x143/0x6f9 do_user_addr_fault at arch/x86/mm/fault.c:1405 (inlined by) do_page_fault at arch/x86/mm/fault.c:1539 irq event stamp: 6944085 count_memcg_event_mm+0x1a6/0x270 count_memcg_event_mm+0x119/0x270 __do_softirq+0x34c/0x57c irq_exit+0xa2/0xc0
read to 0xffff9f427ffff2dc of 4 bytes by task 7472 on cpu 38:
wakeup_kswapd+0xc8/0x400 wake_all_kswapds+0x59/0xc0 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x16e/0x6f0 __handle_mm_fault+0xcd5/0xd40 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
1 lock held by mtest01/7472:
#0: ffff9f425a9ac148 (&mm->mmap_sem#2){++++}, at:
do_page_fault+0x143/0x6f9 irq event stamp: 6793561 count_memcg_event_mm+0x1a6/0x270 count_memcg_event_mm+0x119/0x270 __do_softirq+0x34c/0x57c irq_exit+0xa2/0xc0 BUG: KCSAN: data-race in kswapd / wakeup_kswapd
write to 0xffff90973ffff2dc of 4 bytes by task 820 on cpu 6:
kswapd+0x27c/0x8d0 kthread+0x1e0/0x200 ret_from_fork+0x27/0x50
read to 0xffff90973ffff2dc of 4 bytes by task 6299 on cpu 0:
wakeup_kswapd+0xf3/0x450 wake_all_kswapds+0x59/0xc0 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x170/0x700 __handle_mm_fault+0xc9f/0xd00 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
--- mm/vmscan.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-)
mm/vmscan.c +26 -19
@@ -3160,8 +3160,9 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)/* kswapd must be awake if processes are being throttled */ if (!wmark_ok &&waitqueue_active (&pgdat->kswapd_wait)) { - pgdat->kswapd_classzone_idx =min (pgdat->kswapd_classzone_idx, - (enum zone_type )ZONE_NORMAL ); +if (READ_ONCE (pgdat->kswapd_classzone_idx) >ZONE_NORMAL ) +WRITE_ONCE (pgdat->kswapd_classzone_idx,ZONE_NORMAL ); +wake_up_interruptible (&pgdat->kswapd_wait); }
@@ -3793,9 +3794,9 @@ out:static enum zone_type kswapd_classzone_idx (pg_data_t *pgdat,enum zone_type prev_classzone_idx) { -if (pgdat->kswapd_classzone_idx ==MAX_NR_ZONES ) -return prev_classzone_idx; -return pgdat->kswapd_classzone_idx; +enum zone_type curr_idx =READ_ONCE (pgdat->kswapd_classzone_idx); + +return curr_idx ==MAX_NR_ZONES ? prev_classzone_idx : curr_idx; } static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
@@ -3839,8 +3840,11 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o* the previous request that slept prematurely. */ if (remaining) { - pgdat->kswapd_classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); - pgdat->kswapd_order =max (pgdat->kswapd_order, reclaim_order); +WRITE_ONCE (pgdat->kswapd_classzone_idx, +kswapd_classzone_idx (pgdat, classzone_idx)); + +if (READ_ONCE (pgdat->kswapd_order) < reclaim_order) +WRITE_ONCE (pgdat->kswapd_order, reclaim_order); }finish_wait (&pgdat->kswapd_wait, &wait);
@@ -3917,12 +3921,12 @@ static int kswapd(void *p) tsk->flags |=PF_MEMALLOC |PF_SWAPWRITE |PF_KSWAPD ;set_freezable (); - pgdat->kswapd_order =0 ; - pgdat->kswapd_classzone_idx =MAX_NR_ZONES ; +WRITE_ONCE (pgdat->kswapd_order,0 ); +WRITE_ONCE (pgdat->kswapd_classzone_idx,MAX_NR_ZONES );for ( ; ; ) {bool ret; - alloc_order = reclaim_order = pgdat->kswapd_order; + alloc_order = reclaim_order =READ_ONCE (pgdat->kswapd_order); classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); kswapd_try_sleep:
@@ -3930,10 +3934,10 @@ kswapd_try_sleep: classzone_idx);/* Read the new order and classzone_idx */ - alloc_order = reclaim_order = pgdat->kswapd_order; + alloc_order = reclaim_order =READ_ONCE (pgdat->kswapd_order); classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); - pgdat->kswapd_order =0 ; - pgdat->kswapd_classzone_idx =MAX_NR_ZONES ; +WRITE_ONCE (pgdat->kswapd_order,0 ); +WRITE_ONCE (pgdat->kswapd_classzone_idx,MAX_NR_ZONES ); ret =try_to_freeze ();if (kthread_should_stop ())
@@ -3977,20 +3981,23 @@ void wakeup_kswapd(struct zone *zone, gfp_t gfp_flags, int order, enum zone_type classzone_idx) {pg_data_t *pgdat; +enum zone_type curr_idx;if (!managed_zone (zone))return ;if (!cpuset_zone_allowed (zone, gfp_flags))return ; + pgdat = zone->zone_pgdat; + curr_idx =READ_ONCE (pgdat->kswapd_classzone_idx); + +if (curr_idx ==MAX_NR_ZONES || curr_idx < classzone_idx) +WRITE_ONCE (pgdat->kswapd_classzone_idx, classzone_idx); + +if (READ_ONCE (pgdat->kswapd_order) < order) +WRITE_ONCE (pgdat->kswapd_order, order); -if (pgdat->kswapd_classzone_idx ==MAX_NR_ZONES ) - pgdat->kswapd_classzone_idx = classzone_idx; -else - pgdat->kswapd_classzone_idx =max (pgdat->kswapd_classzone_idx, - classzone_idx); - pgdat->kswapd_order =max (pgdat->kswapd_order, order);if (!waitqueue_active (&pgdat->kswapd_wait))return ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 232/330 drm/amdgpu/sriov add amdgpu_amdkfd_pre_reset in gpu reset
In reply to Sasha LevinFrom: Jack Zhang <[email protected]>
[ Upstream commit 04bef61e5da18c2b301c629a209ccdba4d4c6fbb ]
kfd_pre_reset will free mem_objs allocated by kfd_gtt_sa_allocate
Without this change, sriov tdr code path will never free those allocated memories and get memory leak.
v2:add a bugfix for kiq ring test fail
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ 3 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +3 -0
@@ -644,6 +644,9 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd,uint32_t temp;struct v10_compute_mqd *m =get_mqd (mqd); +if (amdgpu_sriov_vf (adev) && adev->in_gpu_reset) +return 0 ; +#if 0 unsigned long flags;int retry;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +3 -0
@@ -540,6 +540,9 @@ int kgd_gfx_v9_hqd_destroy(struct kgd_dev *kgd, void *mqd,uint32_t temp;struct v9_mqd *m =get_mqd (mqd); +if (amdgpu_sriov_vf (adev) && adev->in_gpu_reset) +return 0 ; +if (adev->in_gpu_reset)return -EIO ;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -3466,6 +3466,8 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,if (r)return r; +amdgpu_amdkfd_pre_reset (adev); +/* Resume IP prior to SMC */ r =amdgpu_device_ip_reinit_early_sriov (adev);if (r)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 230/330 nvmet-rdma: fix double free of rdma queue
In reply to Sasha LevinFrom: Israel Rukshin <[email protected]>
[ Upstream commit 21f9024355e58772ec5d7fc3534aa5e29d72a8b6 ]
In case rdma accept fails at nvmet_rdma_queue_connect(), release work is scheduled. Later on, a new RDMA CM event may arrive since we didn't destroy the cm-id and call nvmet_rdma_queue_connect_fail(), which schedule another release work. This will cause calling nvmet_rdma_free_queue twice. To fix this we implicitly destroy the cm_id with non-zero ret code, which guarantees that new rdma_cm events will not arrive afterwards. Also add a qp pointer to nvmet_rdma_queue structure, so we can use it when the cm_id pointer is NULL or was destroyed.
--- drivers/nvme/target/rdma.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/nvme/target/rdma.c +18 -12
@@ -75,6 +75,7 @@ enum nvmet_rdma_queue_state {struct nvmet_rdma_queue {struct rdma_cm_id *cm_id; +struct ib_qp *qp;struct nvmet_port *port;struct ib_cq *cq;atomic_t sq_wr_avail;
@@ -464,7 +465,7 @@ static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,if (ndev->srq) ret =ib_post_srq_recv (ndev->srq, &cmd->wr,NULL );else - ret =ib_post_recv (cmd->queue->cm_id->qp, &cmd->wr,NULL ); + ret =ib_post_recv (cmd->queue->qp, &cmd->wr,NULL );if (unlikely (ret))pr_err ("post_recv cmd failed\n" );
@@ -503,7 +504,7 @@ static void nvmet_rdma_release_rsp(struct nvmet_rdma_rsp *rsp)atomic_add (1 + rsp->n_rdma, &queue->sq_wr_avail);if (rsp->n_rdma) { -rdma_rw_ctx_destroy (&rsp->rw, queue->cm_id->qp, +rdma_rw_ctx_destroy (&rsp->rw, queue->qp, queue->cm_id->port_num, rsp->req.sg, rsp->req.sg_cnt,nvmet_data_dir (&rsp->req)); }
@@ -587,7 +588,7 @@ static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc)WARN_ON (rsp->n_rdma <=0 );atomic_add (rsp->n_rdma, &queue->sq_wr_avail); -rdma_rw_ctx_destroy (&rsp->rw, queue->cm_id->qp, +rdma_rw_ctx_destroy (&rsp->rw, queue->qp, queue->cm_id->port_num, rsp->req.sg, rsp->req.sg_cnt,nvmet_data_dir (&rsp->req)); rsp->n_rdma =0 ;
@@ -742,7 +743,7 @@ static bool nvmet_rdma_execute_command(struct nvmet_rdma_rsp *rsp) }if (nvmet_rdma_need_data_in (rsp)) { -if (rdma_rw_ctx_post (&rsp->rw, queue->cm_id->qp, +if (rdma_rw_ctx_post (&rsp->rw, queue->qp, queue->cm_id->port_num, &rsp->read_cqe,NULL ))nvmet_req_complete (&rsp->req,NVME_SC_DATA_XFER_ERROR ); }else {
@@ -1025,6 +1026,7 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)pr_err ("failed to create_qp ret= %d\n" , ret); goto err_destroy_cq; } + queue->qp = queue->cm_id->qp;atomic_set (&queue->sq_wr_avail, qp_attr.cap.max_send_wr);
@@ -1053,11 +1055,10 @@ err_destroy_cq:static void nvmet_rdma_destroy_queue_ib (struct nvmet_rdma_queue *queue) { -struct ib_qp *qp = queue->cm_id->qp; - -ib_drain_qp (qp); -rdma_destroy_id (queue->cm_id); -ib_destroy_qp (qp); +ib_drain_qp (queue->qp); +if (queue->cm_id) +rdma_destroy_id (queue->cm_id); +ib_destroy_qp (queue->qp);ib_free_cq (queue->cq); }
@@ -1291,9 +1292,12 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id, ret =nvmet_rdma_cm_accept (cm_id, queue, &event->param.conn);if (ret) { -schedule_work (&queue->release_work); -/* Destroying rdma_cm id is not needed here */ -return 0 ; +/* +* Don't destroy the cm_id in free path, as we implicitly +* destroy the cm_id here with non-zero ret code. +*/ + queue->cm_id =NULL ; + goto free_queue; }mutex_lock (&nvmet_rdma_queue_mutex);
@@ -1302,6 +1306,8 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,return 0 ; +free_queue: +nvmet_rdma_free_queue (queue); put_device:kref_put (&ndev->ref, nvmet_rdma_free_dev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 233/330 mm/mmap.c: initialize align_offset explicitly for vm_unmapped_area
In reply to Sasha LevinFrom: Jaewon Kim <[email protected]>
[ Upstream commit 09ef5283fd96ac424ef0e569626f359bf9ab86c9 ]
On passing requirement to vm_unmapped_area, arch_get_unmapped_area and arch_get_unmapped_area_topdown did not set align_offset. Internally on both unmapped_area and unmapped_area_topdown, if info->align_mask is 0, then info->align_offset was meaningless.
But commit df529cabb7a2 ("mm: mmap: add trace point of vm_unmapped_area") always prints info->align_offset even though it is uninitialized.
Fix this uninitialized value issue by setting it to 0 explicitly.
Before:
vm_unmapped_area: addr=0x755b155000 err=0 total_vm=0x15aaf0 flags=0x1 len=0x109000 lo=0x8000 hi=0x75eed48000 mask=0x0 ofs=0x4022
After:
vm_unmapped_area: addr=0x74a4ca1000 err=0 total_vm=0x168ab1 flags=0x1 len=0x9000 lo=0x8000 hi=0x753d94b000 mask=0x0 ofs=0x0
--- mm/mmap.c | 2 ++ 1 file changed, 2 insertions(+)
mm/mmap.c +2 -0
@@ -2126,6 +2126,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = mmap_end; info.align_mask =0 ; + info.align_offset =0 ; return vm_unmapped_area(&info); }#endif
@@ -2167,6 +2168,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.low_limit =max (PAGE_SIZE , mmap_min_addr); info.high_limit =arch_get_mmap_base (addr, mm->mmap_base); info.align_mask =0 ; + info.align_offset =0 ; addr =vm_unmapped_area (&info);/*
Signature · 1 line
2.25.1
Quoted 8 lines · Sasha Levin
From: Iago Toral Quiroga <[email protected]>
[ Upstream commit
0d352a3a8a1f26168d09f7073e61bb4b328e3bb9]If the initialization of the job fails we need to
kfree()it before returning.
Quoted 6 lines
Signed-off-by Iago Toral Quiroga <[email protected]>Signed-off-by Eric Anholt <[email protected]>Fixes a783a09ee76d ("drm/v3d: Refactor job management.")Reviewed-by Eric Anholt <[email protected]>Signed-off-by Sasha Levin <[email protected]>
You're double freeing with this patch, the bug is already solved.
Quoted 17 lines
--- drivers/gpu/drm/v3d/v3d_gem.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/v3d/v3d_gem.c +1
-1@@ -565,6 +565,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, ret =v3d_job_init (v3d, file_priv, &bin->base, v3d_job_free, args->in_sync_bcl);if (ret) { +kfree (bin);v3d_job_put (&render->base);kfree (bin);return ret; --
Quoted 2 lines
2.25.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 236/330 serial: uartps: Wait for tx_empty in console setup
In reply to Sasha LevinFrom: Raviteja Narayanam <[email protected]>
[ Upstream commit 42e11948ddf68b9f799cad8c0ddeab0a39da33e8 ]
On some platforms, the log is corrupted while console is being registered. It is observed that when set_termios is called, there are still some bytes in the FIFO to be transmitted.
So, wait for tx_empty inside cdns_uart_console_setup before calling set_termios.
--- drivers/tty/serial/xilinx_uartps.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/serial/xilinx_uartps.c +8 -0
@@ -1248,6 +1248,7 @@ static int cdns_uart_console_setup(struct console *co, char *options)int bits =8 ;int parity ='n' ;int flow ='n' ; +unsigned long time_out;if (!port->membase) { pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n",
@@ -1258,6 +1259,13 @@ static int cdns_uart_console_setup(struct console *co, char *options)if (options)uart_parse_options (options, &baud, &parity, &bits, &flow); +/* Wait for tx_empty before setting up the console */ + time_out = jiffies +usecs_to_jiffies (TX_TIMEOUT ); + +while (time_before (jiffies, time_out) && +cdns_uart_tx_empty (port) !=TIOCSER_TEMT ) +cpu_relax (); +return uart_set_options (port, co, baud, parity, bits, flow); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 231/330 workqueue: Remove the warning in wq_worker_sleeping()
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 62849a9612924a655c67cf6962920544aa5c20db ]
The kernel test robot triggered a warning with the following race:
task-ctx A interrupt-ctx B
worker
-> process_one_work()
-> work_item()
-> schedule();
-> sched_submit_work()
-> wq_worker_sleeping()
-> ->sleeping = 1
atomic_dec_and_test(nr_running)
__schedule(); *interrupt*
async_page_fault()
-> local_irq_enable();
-> schedule();
-> sched_submit_work()
-> wq_worker_sleeping()
-> if (WARN_ON(->sleeping)) return
-> __schedule()
-> sched_update_worker()
-> wq_worker_running()
-> atomic_inc(nr_running);
-> ->sleeping = 0;
-> sched_update_worker()
-> wq_worker_running()
if (!->sleeping) returnIn this context the warning is pointless everything is fine. An interrupt before wq_worker_sleeping() will perform the ->sleeping assignment (0 -> 1 > 0) twice.
An interrupt after wq_worker_sleeping() will trigger the warning and nr_running will be decremented (by A) and incremented once (only by B, A will skip it). This is the case until the ->sleeping is zeroed again in wq_worker_running().
Remove the WARN statement because this condition may happen. Document that preemption around wq_worker_sleeping() needs to be disabled to protect ->sleeping and not just as an optimisation.
--- kernel/sched/core.c | 3 ++- kernel/workqueue.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
kernel/sched/core.c +2 -1
@@ -4199,7 +4199,8 @@ static inline void sched_submit_work(struct task_struct *tsk)* it wants to wake up a task to maintain concurrency. * As this function is called inside the schedule() context, * we disable preemption to avoid it calling schedule() again -* in the possible wakeup of a kworker. +* in the possible wakeup of a kworker and because wq_worker_sleeping() +* requires it. */ if (tsk->flags &PF_WQ_WORKER ) {preempt_disable ();
kernel/workqueue.c +4 -2
@@ -864,7 +864,8 @@ void wq_worker_running(struct task_struct *task)* @task: task going to sleep * * This function is called from schedule() when a busy worker is -* going to sleep. +* going to sleep. Preemption needs to be disabled to protect ->sleeping +* assignment. */ void wq_worker_sleeping (struct task_struct *task) {
@@ -881,7 +882,8 @@ void wq_worker_sleeping(struct task_struct *task) pool = worker->pool; -if (WARN_ON_ONCE (worker->sleeping)) +/* Return if preempted before wq_worker_running() was reached */ +if (worker->sleeping)return ; worker->sleeping =1 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 234/330 ALSA: hda: Skip controller resume if not needed
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit c4c8dd6ef807663e42a5f04ea77cd62029eb99fa ]
The HD-audio controller does system-suspend and resume operations by directly calling its helpers __azx_runtime_suspend() and __azx_runtime_resume(). However, in general, we don't have to resume always the device fully at the system resume; typically, if a device has been runtime-suspended, we can leave it to runtime resume.
Usually for achieving this, the driver would call pm_runtime_force_suspend() and pm_runtime_force_resume() pairs in the system suspend and resume ops. Unfortunately, this doesn't work for the resume path in our case. For handling the jack detection at the system resume, a child codec device may need the (literally) forcibly resume even if it's been runtime-suspended, and for that, the controller device must be also resumed even if it's been suspended.
This patch is an attempt to improve the situation. It replaces the direct __azx_runtime_suspend()/_resume() calls with with pm_runtime_force_suspend() and pm_runtime_force_resume() with a slight trick as we've done for the codec side. More exactly:
- azx_has_pm_runtime() check is dropped from azx_runtime_suspend() and azx_runtime_resume(), so that it can be properly executed from the system-suspend/resume path
- The WAKEEN handling depends on the card's power state now; it's set and cleared only for the runtime-suspend
- azx_resume() checks whether any codec may need the forcible resume beforehand. If the forcible resume is required, it does temporary PM refcount up/down for actually triggering the runtime resume.
- A new helper function, hda_codec_need_resume(), is introduced for checking whether the codec needs a forcible runtime-resume, and the existing code is rewritten with that.
--- include/sound/hda_codec.h | 5 +++++ sound/pci/hda/hda_codec.c | 2 +- sound/pci/hda/hda_intel.c | 38 +++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 12 deletions(-)
include/sound/hda_codec.h +5 -0
@@ -494,6 +494,11 @@ void snd_hda_update_power_acct(struct hda_codec *codec);static inline void snd_hda_set_power_save (struct hda_bus *bus,int delay) {}#endif +static inline bool hda_codec_need_resume (struct hda_codec *codec) +{ +return !codec->relaxed_resume && codec->jacktbl.used; +} +#ifdef CONFIG_SND_HDA_PATCH_LOADER /* * patch firmware
sound/pci/hda/hda_codec.c +1 -1
@@ -2958,7 +2958,7 @@ static int hda_codec_runtime_resume(struct device *dev)static int hda_codec_force_resume (struct device *dev) {struct hda_codec *codec =dev_to_hda_codec (dev); -bool forced_resume = !codec->relaxed_resume && codec->jacktbl.used; +bool forced_resume =hda_codec_need_resume (codec);int ret;/* The get/put pair below enforces the runtime resume even if the
sound/pci/hda/hda_intel.c +27 -11
@@ -1025,7 +1025,7 @@ static int azx_suspend(struct device *dev) chip = card->private_data; bus =azx_bus (chip);snd_power_change_state (card, SNDRV_CTL_POWER_D3hot); -__azx_runtime_suspend (chip); +pm_runtime_force_suspend (dev);if (bus->irq >=0 ) {free_irq (bus->irq, chip); bus->irq =-1 ;
@@ -1041,7 +1041,9 @@ static int azx_suspend(struct device *dev)static int azx_resume (struct device *dev) {struct snd_card *card =dev_get_drvdata (dev); +struct hda_codec *codec;struct azx *chip; +bool forced_resume = false;if (!azx_is_pm_ready (card))return 0 ;
@@ -1052,7 +1054,20 @@ static int azx_resume(struct device *dev) chip->msi =0 ;if (azx_acquire_irq (chip,1 ) <0 )return -EIO ; -__azx_runtime_resume (chip, false); + +/* check for the forced resume */ +list_for_each_codec (codec, &chip->bus) { +if (hda_codec_need_resume (codec)) { + forced_resume = true; +break ; + } + } + +if (forced_resume) +pm_runtime_get_noresume (dev); +pm_runtime_force_resume (dev); +if (forced_resume) +pm_runtime_put (dev);snd_power_change_state (card,SNDRV_CTL_POWER_D0 );trace_azx_resume (chip);
@@ -1099,12 +1114,12 @@ static int azx_runtime_suspend(struct device *dev)if (!azx_is_pm_ready (card))return 0 ; chip = card->private_data; -if (!azx_has_pm_runtime (chip)) -return 0 ;/* enable controller wake up event */ -azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) | -STATESTS_INT_MASK ); +if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ) { +azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) | +STATESTS_INT_MASK ); + }__azx_runtime_suspend (chip);trace_azx_runtime_suspend (chip);
@@ -1115,17 +1130,18 @@ static int azx_runtime_resume(struct device *dev) {struct snd_card *card =dev_get_drvdata (dev);struct azx *chip; +bool from_rt =snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ;if (!azx_is_pm_ready (card))return 0 ; chip = card->private_data; -if (!azx_has_pm_runtime (chip)) -return 0 ; -__azx_runtime_resume (chip, true); +__azx_runtime_resume (chip, from_rt);/* disable controller Wake Up event*/ -azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) & - ~STATESTS_INT_MASK ); +if (from_rt) { +azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) & + ~STATESTS_INT_MASK ); + }trace_azx_runtime_resume (chip);return 0 ;
Signature · 1 line
2.25.1