5.9.4-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 146/391 rpmsg: glink: Use complete_all for open states
In reply to Greg Kroah-HartmanFrom: Chris Lew <[email protected]>
[ Upstream commit 4fcdaf6e28d11e2f3820d54dd23cd12a47ddd44e ]
The open_req and open_ack completion variables are the state variables to represet a remote channel as open. Use complete_all so there are no races with waiters and using completion_done.
--- drivers/rpmsg/qcom_glink_native.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rpmsg/qcom_glink_native.c +3 -3
@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)return -EINVAL ; } -complete (&channel->open_ack); +complete_all (&channel->open_ack);return 0 ; }
@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)__be32 *val = defaults;int size; -if (glink->intentless) +if (glink->intentless || !completion_done (&channel->open_ack))return 0 ; prop =of_find_property (np,"qcom,intents" ,NULL );
@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, channel->rcid = ret;spin_unlock_irqrestore (&glink->idr_lock, flags); -complete (&channel->open_req); +complete_all (&channel->open_req);if (create_device) { rpdev =kzalloc (sizeof (*rpdev),GFP_KERNEL );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 138/391 drm/amd/display: HDMI remote sink need mode validation for Linux
In reply to Greg Kroah-HartmanFrom: Fangzhi Zuo <[email protected]>
[ Upstream commit 95d620adb48f7728e67d82f56f756e8d451cf8d2 ]
[Why]
Currently mode validation is bypassed if remote sink exists. That leads to mode set issue when a BW bottle neck exists in the link path, e.g., a DP-to-HDMI converter that only supports HDMI 1.4.
Any invalid mode passed to Linux user space will cause the modeset failure due to limitation of Linux user space implementation.
[How]
Mode validation is skipped only if in edid override. For real remote sink, clock limit check should be done for HDMI remote sink.
Have HDMI related remote sink going through mode validation to elimiate modes which pixel clock exceeds BW limitation.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +1 -1
@@ -2441,7 +2441,7 @@ enum dc_status dc_link_validate_mode_timing(/* A hack to avoid failing any modes for EDID override feature on * topology change such as lower quality cable for DP or different dongle */ -if (link->remote_sinks[0 ]) +if (link->remote_sinks[0 ] && link->remote_sinks[0 ]->sink_signal ==SIGNAL_TYPE_VIRTUAL )return DC_OK ;/* Passive Dongle */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 179/391 nbd: make the config put is called before the notifying the waiter
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
[ Upstream commit 87aac3a80af5cbad93e63250e8a1e19095ba0d30 ]
There has one race case for ceph's rbd-nbd tool. When do mapping it may fail with EBUSY from ioctl(nbd, NBD_DO_IT), but actually the nbd device has already unmaped.
It dues to if just after the wake_up(), the recv_work() is scheduled out and defers calling the nbd_config_put(), though the map process has exited the "nbd->recv_task" is not cleared.
--- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
@@ -801,9 +801,9 @@ static void recv_work(struct work_struct *work)if (likely (!blk_should_fake_timeout (rq->q)))blk_mq_complete_request (rq); } +nbd_config_put (nbd);atomic_dec (&config->recv_threads);wake_up (&config->recv_wq); -nbd_config_put (nbd);kfree (args); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 188/391 mm: memcg/slab: uncharge during kmem_cache_free_bulk()
In reply to Greg Kroah-HartmanFrom: Bharata B Rao <[email protected]>
commit d1b2cf6cb84a9bd0de6f151512648dd1af82f80f upstream.
Object cgroup charging is done for all the objects during allocation, but during freeing, uncharging ends up happening for only one object in the case of bulk allocation/freeing.
Fix this by having a separate call to uncharge all the objects from kmem_cache_free_bulk() and by modifying memcg_slab_free_hook() to take care of bulk uncharging.
--- mm/slab.c | 2 +- mm/slab.h | 50 +++++++++++++++++++++++++++++++------------------- mm/slub.c | 3 ++- 3 files changed, 34 insertions(+), 21 deletions(-)
mm/slab.c +1 -1
@@ -3440,7 +3440,7 @@ void ___cache_free(struct kmem_cache *camemset (objp,0 , cachep->object_size);kmemleak_free_recursive (objp, cachep->flags); objp =cache_free_debugcheck (cachep, objp, caller); -memcg_slab_free_hook (cachep,virt_to_head_page (objp), objp); +memcg_slab_free_hook (cachep, &objp,1 );/* * Skip calling cache_free_alien() when the platform is not numa.
mm/slab.h +31 -19
69 lines not on this page · raw message
mm/slub.c +2 -1
@@ -3091,7 +3091,7 @@ static __always_inline void do_slab_freestruct kmem_cache_cpu *c;unsigned long tid; -memcg_slab_free_hook (s, page, head); +memcg_slab_free_hook (s, &head,1 ); redo:/* * Determine the currently cpus per cpu slab.
@@ -3253,6 +3253,7 @@ void kmem_cache_free_bulk(struct kmem_caif (WARN_ON (!size))return ; +memcg_slab_free_hook (s, p, size); do { struct detached_freelist df;
Greg Kroah-Hartman
maintainerPATCH 136/391 ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
[ Upstream commit 2c5b9bde95c96942f2873cea6ef383c02800e4a8 ]
In ACPI 6.3, the Memory Proximity Domain Attributes Structure changed substantially. One of those changes was that the flag for "Memory Proximity Domain field is valid" was deprecated.
This was because the field "Proximity Domain for the Memory" became a required field and hence having a validity flag makes no sense.
So the correct logic is to always assume the field is there. Current code assumes it never is.
--- drivers/acpi/numa/hmat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/numa/hmat.c +2 -1
@@ -424,7 +424,8 @@ static int __init hmat_parse_proximity_domain(union acpi_subtable_headers *headepr_info ("HMAT: Memory Flags:%04x Processor Domain:%u Memory Domain:%u\n" , p->flags, p->processor_PD, p->memory_PD); -if (p->flags &ACPI_HMAT_MEMORY_PD_VALID && hmat_revision ==1 ) { +if ((hmat_revision ==1 && p->flags &ACPI_HMAT_MEMORY_PD_VALID ) || + hmat_revision >1 ) { target =find_mem_target (p->memory_PD);if (!target) {pr_debug ("HMAT: Memory Domain missing from SRAT\n" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 190/391 selftests/x86/fsgsbase: Test PTRACE_PEEKUSER for GSBASE with invalid LDT GS
In reply to Greg Kroah-HartmanFrom: Andy Lutomirski <[email protected]>
commit 1b9abd1755ad947d7c9913e92e7837b533124c90 upstream.
This tests commit:
8ab49526b53d ("x86/fsgsbase/64: Fix NULL deref in 86_fsgsbase_read_task")
Unpatched kernels will OOPS.
--- tools/testing/selftests/x86/fsgsbase.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
tools/testing/selftests/x86/fsgsbase.c +65 -0
@@ -443,6 +443,68 @@ static void test_unexpected_base(void)#define USER_REGS_OFFSET (r) offsetof(struct user_regs_struct, r) +static void test_ptrace_write_gs_read_base (void ) +{ +int status; +pid_t child =fork (); + +if (child <0 ) +err (1 ,"fork" ); + +if (child ==0 ) { +printf ("[RUN]\tPTRACE_POKE GS, read GSBASE back\n" ); + +printf ("[RUN]\tARCH_SET_GS to 1\n" ); +if (syscall (SYS_arch_prctl,ARCH_SET_GS ,1 ) !=0 ) +err (1 ,"ARCH_SET_GS" ); + +if (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL ) !=0 ) +err (1 ,"PTRACE_TRACEME" ); + +raise (SIGTRAP ); +_exit (0 ); + } + +wait (&status); + +if (WSTOPSIG (status) ==SIGTRAP ) { +unsigned long base; +unsigned long gs_offset =USER_REGS_OFFSET (gs); +unsigned long base_offset =USER_REGS_OFFSET (gs_base); + +/* Read the initial base. It should be 1. */ + base =ptrace (PTRACE_PEEKUSER , child, base_offset,NULL ); +if (base ==1 ) { +printf ("[OK]\tGSBASE started at 1\n" ); + }else { + nerrs++; +printf ("[FAIL]\tGSBASE started at 0x%lx\n" , base); + } + +printf ("[RUN]\tSet GS = 0x7, read GSBASE\n" ); + +/* Poke an LDT selector into GS. */ +if (ptrace (PTRACE_POKEUSER , child, gs_offset,0x7 ) !=0 ) +err (1 ,"PTRACE_POKEUSER" ); + +/* And read the base. */ + base =ptrace (PTRACE_PEEKUSER , child, base_offset,NULL ); + +if (base ==0 || base ==1 ) { +printf ("[OK]\tGSBASE reads as 0x%lx with invalid GS\n" , base); + }else { + nerrs++; +printf ("[FAIL]\tGSBASE=0x%lx (should be 0 or 1)\n" , base); + } + } + +ptrace (PTRACE_CONT , child,NULL ,NULL ); + +wait (&status); +if (!WIFEXITED (status)) +printf ("[WARN]\tChild didn't exit cleanly.\n" ); +} +static void test_ptrace_write_gsbase (void ) {int status;
@@ -529,6 +591,9 @@ int main() shared_scratch =mmap (NULL ,4096 ,PROT_READ |PROT_WRITE ,MAP_ANONYMOUS |MAP_SHARED ,-1 ,0 ); +/* Do these tests before we have an LDT. */ +test_ptrace_write_gs_read_base (); +/* Probe FSGSBASE */ sethandler (SIGILL , sigill,0 );if (sigsetjmp (jmpbuf,1 ) ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 192/391 perf/x86/amd: Fix sampling Large Increment per Cycle events
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 26e52558ead4b39c0e0fe7bf08f82f5a9777a412 upstream.
Commit 5738891229a2 ("perf/x86/amd: Add support for Large Increment per Cycle Events") mistakenly zeroes the upper 16 bits of the count in set_period(). That's fine for counting with perf stat, but not sampling with perf record when only Large Increment events are being sampled. To enable sampling, we sign extend the upper 16 bits of the merged counter pair as described in the Family 17h PPRs:
"Software wanting to preload a value to a merged counter pair writes the high-order 16-bit value to the low-order 16 bits of the odd counter and then writes the low-order 48-bit value to the even counter. Reading the even counter of the merged counter pair returns the full 64-bit value."
--- arch/x86/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/core.c +2 -2
@@ -1286,11 +1286,11 @@ int x86_perf_event_set_period(struct perwrmsrl (hwc->event_base, (u64)(-left) & x86_pmu.cntval_mask);/* -* Clear the Merge event counter's upper 16 bits since +* Sign extend the Merge event counter's upper 16 bits since * we currently declare a 48-bit counter width */ if (is_counter_pair (hwc)) -wrmsrl (x86_pmu_event_addr (idx +1 ),0 ); +wrmsrl (x86_pmu_event_addr (idx +1 ),0xffff );/* * Due to erratum on certan cpu we need
Greg Kroah-Hartman
maintainerPATCH 193/391 perf/amd/uncore: Set all slices and threads to restore perf stat -a behaviour
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit c8fe99d0701fec9fb849ec880a86bc5592530496 upstream.
Commit 2f217d58a8a0 ("perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs") inadvertently changed the uncore driver's behaviour wrt perf tool invocations with or without a CPU list, specified with -C / --cpu=.
Change the behaviour of the driver to assume the former all-cpu (-a) case, which is the more commonly desired default. This fixes '-a -A' invocations without explicit cpu lists (-C) to not count L3 events only on behalf of the first thread of the first core in the L3 domain.
BEFORE:
Activity performed by the first thread of the last core (CPU#43) in CPU#40's L3 domain is not reported by CPU#40:
sudo perf stat -a -A -e l3_request_g1.caching_l3_cache_accesses taskset -c 43 perf bench mem memcpy -s 32mb -l 100 -f default
...
CPU36 21,835 l3_request_g1.caching_l3_cache_accesses CPU40 87,066 l3_request_g1.caching_l3_cache_accesses CPU44 17,360 l3_request_g1.caching_l3_cache_accesses
...
AFTER:
The L3 domain activity is now reported by CPU#40:
sudo perf stat -a -A -e l3_request_g1.caching_l3_cache_accesses taskset -c 43 perf bench mem memcpy -s 32mb -l 100 -f default
...
CPU36 354,891 l3_request_g1.caching_l3_cache_accesses CPU40 1,780,870 l3_request_g1.caching_l3_cache_accesses CPU44 315,062 l3_request_g1.caching_l3_cache_accesses
...
--- arch/x86/events/amd/uncore.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
arch/x86/events/amd/uncore.c +8 -20
@@ -181,28 +181,16 @@ static void amd_uncore_del(struct perf_e }/* -* Convert logical CPU number to L3 PMC Config ThreadMask format +* Return a full thread and slice mask until per-CPU is +* properly supported. */ -static u64 l3_thread_slice_mask (int cpu) +static u64 l3_thread_slice_mask (void ) { -u64 thread_mask, core =topology_core_id (cpu); -unsigned int shift, thread =0 ; +if (boot_cpu_data.x86 <=0x18 ) +return AMD64_L3_SLICE_MASK |AMD64_L3_THREAD_MASK ; -if (topology_smt_supported () && !topology_is_primary_thread (cpu)) - thread =1 ; - -if (boot_cpu_data.x86 <=0x18 ) { - shift =AMD64_L3_THREAD_SHIFT +2 * (core %4 ) + thread; - thread_mask =BIT_ULL (shift); - -return AMD64_L3_SLICE_MASK | thread_mask; - } - - core = (core <<AMD64_L3_COREID_SHIFT ) &AMD64_L3_COREID_MASK ; - shift =AMD64_L3_THREAD_SHIFT + thread; - thread_mask =BIT_ULL (shift); - -return AMD64_L3_EN_ALL_SLICES | core | thread_mask; +return AMD64_L3_EN_ALL_SLICES |AMD64_L3_EN_ALL_CORES | +AMD64_L3_F19H_THREAD_MASK ; }static int amd_uncore_event_init (struct perf_event *event)
@@ -232,7 +220,7 @@ static int amd_uncore_event_init(struct* For other events, the two fields do not affect the count. */ if (l3_mask &&is_llc_event (event)) - hwc->config |=l3_thread_slice_mask (event->cpu); + hwc->config |=l3_thread_slice_mask (); uncore =event_to_amd_uncore (event);if (!uncore)
Greg Kroah-Hartman
maintainerPATCH 194/391 perf/x86/amd/ibs: Dont include randomized bits in get_ibs_op_count()
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 680d69635005ba0e58fe3f4c52fc162b8fc743b0 upstream.
get_ibs_op_count() adds hardware's current count (IbsOpCurCnt) bits to its count regardless of hardware's valid status.
According to the PPR for AMD Family 17h Model 31h B0 55803 Rev 0.54, if the counter rolls over, valid status is set, and the lower 7 bits of IbsOpCurCnt are randomized by hardware.
Don't include those bits in the driver's event count.
--- arch/x86/events/amd/ibs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/events/amd/ibs.c +8 -4
@@ -335,11 +335,15 @@ static u64 get_ibs_op_count(u64 config) {u64 count =0 ; +/* +* If the internal 27-bit counter rolled over, the count is MaxCnt +* and the lower 7 bits of CurCnt are randomized. +* Otherwise CurCnt has the full 27-bit current counter value. +*/ if (config &IBS_OP_VAL ) - count += (config &IBS_OP_MAX_CNT ) <<4 ;/* cnt rolled over */ - -if (ibs_caps &IBS_CAPS_RDWROPCNT ) - count += (config &IBS_OP_CUR_CNT ) >>32 ; + count = (config &IBS_OP_MAX_CNT ) <<4 ; +else if (ibs_caps &IBS_CAPS_RDWROPCNT ) + count = (config &IBS_OP_CUR_CNT ) >>32 ;return count; }
Greg Kroah-Hartman
maintainerPATCH 196/391 spi: spi-mtk-nor: fix timeout calculation overflow
In reply to Greg Kroah-HartmanFrom: Chuanhong Guo <[email protected]>
commit 4cafaddedb5fbef9531202ee547784409fd0de33 upstream.
CLK_TO_US macro is used to calculate potential transfer time for various timeout handling. However it overflows on transfer bigger than 512 bytes because it first did (len * 8 * 1000000).
This controller typically operates at 45MHz. This patch did 2 things:
1. calculate clock / 1000000 first
2. add a 4M transfer size cap so that the final timeout in DMA reading doesn't overflow
--- drivers/spi/spi-mtk-nor.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-mtk-nor.c +5 -1
@@ -89,7 +89,7 @@// Buffered page program can do one 128-byte transfer #define MTK_NOR_PP_SIZE 128 -#define CLK_TO_US (sp, clkcnt) ((clkcnt) * 1000000 / sp->spi_freq) +#define CLK_TO_US (sp, clkcnt) DIV_ROUND_UP(clkcnt, sp->spi_freq / 1000000)struct mtk_nor {struct spi_controller *ctlr;
@@ -177,6 +177,10 @@ static int mtk_nor_adjust_op_size(structif ((op->addr.nbytes ==3 ) || (op->addr.nbytes ==4 )) {if ((op->data.dir ==SPI_MEM_DATA_IN ) &&mtk_nor_match_read (op)) { +// limit size to prevent timeout calculation overflow +if (op->data.nbytes >0x400000 ) + op->data.nbytes =0x400000 ; +if ((op->addr.val &MTK_NOR_DMA_ALIGN_MASK ) || (op->data.nbytes <MTK_NOR_DMA_ALIGN )) op->data.nbytes =1 ;
Greg Kroah-Hartman
maintainerPATCH 197/391 spi: sprd: Release DMA channel also on probe deferral
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 687a2e76186dcfa42f22c14b655c3fb159839e79 upstream.
If dma_request_chan() for TX channel fails with EPROBE_DEFER, the RX channel would not be released and on next re-probe it would be requested second time.
--- drivers/spi/spi-sprd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-sprd.c +1 -1
@@ -563,11 +563,11 @@ static int sprd_spi_dma_request(struct s ss->dma.dma_chan[SPRD_SPI_TX ] =dma_request_chan (ss->dev,"tx_chn" );if (IS_ERR_OR_NULL (ss->dma.dma_chan[SPRD_SPI_TX ])) { +dma_release_channel (ss->dma.dma_chan[SPRD_SPI_RX ]);if (PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]) == -EPROBE_DEFER )return PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]);dev_err (ss->dev,"request TX DMA channel failed!\n" ); -dma_release_channel (ss->dma.dma_chan[SPRD_SPI_RX ]);return PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]); }
Greg Kroah-Hartman
maintainerPATCH 198/391 extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chips
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 6aaad58c872db062f7ea2761421ca748bd0931cc upstream.
The driver uses atomic version of gpiod_set_value() without any real reason. It is called in a workqueue under mutex so it could sleep there. Changing it to "can_sleep" flavor allows to use the driver with all GPIO chips.
--- drivers/extcon/extcon-ptn5150.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/extcon/extcon-ptn5150.c +4 -4
@@ -127,7 +127,7 @@ static void ptn5150_irq_work(struct workcase PTN5150_DFP_ATTACHED :extcon_set_state_sync (info->edev,EXTCON_USB_HOST , false); -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 );extcon_set_state_sync (info->edev,EXTCON_USB , true);break ;
@@ -138,9 +138,9 @@ static void ptn5150_irq_work(struct work PTN5150_REG_CC_VBUS_DETECTION_MASK) >> PTN5150_REG_CC_VBUS_DETECTION_SHIFT);if (vbus) -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 );else -gpiod_set_value (info->vbus_gpiod,1 ); +gpiod_set_value_cansleep (info->vbus_gpiod,1 );extcon_set_state_sync (info->edev,EXTCON_USB_HOST , true);
@@ -156,7 +156,7 @@ static void ptn5150_irq_work(struct work EXTCON_USB_HOST, false);extcon_set_state_sync (info->edev,EXTCON_USB , false); -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 ); } }
Greg Kroah-Hartman
maintainerPATCH 200/391 hwmon: (pmbus/max34440) Fix OC fault limits
In reply to Greg Kroah-HartmanFrom: Steve Foreman <[email protected]>
commit 2b52278150c49559a472f2d6dd66f6f3b405378e upstream.
The max34* family have the IOUT_OC_WARN_LIMIT and IOUT_OC_CRIT_LIMIT registers swapped.
--- drivers/hwmon/pmbus/max34440.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/hwmon/pmbus/max34440.c +23 -0
@@ -31,6 +31,13 @@ enum chips { max34440, max34441, max3444#define MAX34440_STATUS_OT_FAULT BIT(5)#define MAX34440_STATUS_OT_WARN BIT(6) +/* +* The whole max344* family have IOUT_OC_WARN_LIMIT and IOUT_OC_FAULT_LIMIT +* swapped from the standard pmbus spec addresses. +*/ +#define MAX34440_IOUT_OC_WARN_LIMIT 0x46 +#define MAX34440_IOUT_OC_FAULT_LIMIT 0x4A +#define MAX34451_MFR_CHANNEL_CONFIG 0xe4#define MAX34451_MFR_CHANNEL_CONFIG_SEL_MASK 0x3f
@@ -49,6 +56,14 @@ static int max34440_read_word_data(strucconst struct max34440_data *data =to_max34440_data (info);switch (reg) { +case PMBUS_IOUT_OC_FAULT_LIMIT : + ret =pmbus_read_word_data (client, page, phase, +MAX34440_IOUT_OC_FAULT_LIMIT ); +break ; +case PMBUS_IOUT_OC_WARN_LIMIT : + ret =pmbus_read_word_data (client, page, phase, +MAX34440_IOUT_OC_WARN_LIMIT ); +break ;case PMBUS_VIRT_READ_VOUT_MIN : ret =pmbus_read_word_data (client, page, phase,MAX34440_MFR_VOUT_MIN );
@@ -115,6 +130,14 @@ static int max34440_write_word_data(struint ret;switch (reg) { +case PMBUS_IOUT_OC_FAULT_LIMIT : + ret =pmbus_write_word_data (client, page,MAX34440_IOUT_OC_FAULT_LIMIT , + word); +break ; +case PMBUS_IOUT_OC_WARN_LIMIT : + ret =pmbus_write_word_data (client, page,MAX34440_IOUT_OC_WARN_LIMIT , + word); +break ;case PMBUS_VIRT_RESET_POUT_HISTORY : ret =pmbus_write_word_data (client, page,MAX34446_MFR_POUT_PEAK ,0 );
Greg Kroah-Hartman
maintainerPATCH 201/391 media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 93df48d37c3f03886d84831992926333e7810640 upstream.
uvc_ctrl_add_info() calls uvc_ctrl_get_flags() which will override the fixed-up flags set by uvc_ctrl_fixup_xu_info().
uvc_ctrl_init_xu_ctrl() already calls uvc_ctrl_get_flags() before calling uvc_ctrl_add_info(), so the uvc_ctrl_get_flags() call in uvc_ctrl_add_info() is not necessary for xu ctrls.
This commit moves the uvc_ctrl_get_flags() call for normal controls from uvc_ctrl_add_info() to uvc_ctrl_init_ctrl(), so that we no longer call uvc_ctrl_get_flags() twice for xu controls and so that we no longer override the fixed-up flags set by uvc_ctrl_fixup_xu_info().
This fixes the xu motor controls not working properly on a Logitech 046d:08cc, and presumably also on the other Logitech models which have a quirk for this in the uvc_ctrl_fixup_xu_info() function.
--- drivers/media/usb/uvc/uvc_ctrl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +7 -7
@@ -2033,13 +2033,6 @@ static int uvc_ctrl_add_info(struct uvc_ goto done; } -/* -* Retrieve control flags from the device. Ignore errors and work with -* default flag values from the uvc_ctrl array when the device doesn't -* properly implement GET_INFO on standard controls. -*/ -uvc_ctrl_get_flags (dev, ctrl, &ctrl->info); - ctrl->initialized =1 ; uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
@@ -2262,6 +2255,13 @@ static void uvc_ctrl_init_ctrl(struct uvif (uvc_entity_match_guid (ctrl->entity, info->entity) && ctrl->index == info->index) {uvc_ctrl_add_info (dev, ctrl, info); +/* +* Retrieve control flags from the device. Ignore errors +* and work with default flag values from the uvc_ctrl +* array when the device doesn't properly implement +* GET_INFO on standard controls. +*/ +uvc_ctrl_get_flags (dev, ctrl, &ctrl->info);break ; } }
Greg Kroah-Hartman
maintainerPATCH 203/391 ACPI: configfs: Add missing config_item_put() to fix refcount leak
In reply to Greg Kroah-HartmanFrom: Hanjun Guo <[email protected]>
commit 9a2e849fb6de471b82d19989a7944d3b7671793c upstream.
config_item_put() should be called in the drop_item callback, to decrement refcount for the config item.
--- drivers/acpi/acpi_configfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpi_configfs.c +1 -0
@@ -228,6 +228,7 @@ static void acpi_table_drop_item(structACPI_INFO (("Host-directed Dynamic ACPI Table Unload" ));acpi_unload_table (table->index); +config_item_put (cfg); }static struct configfs_group_operations acpi_table_group_ops = {
Greg Kroah-Hartman
maintainerPATCH 202/391 fs: Dont invalidate page buffers in block_write_full_page()
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 6dbf7bb555981fb5faf7b691e8f6169fc2b2e63b upstream.
If block_write_full_page() is called for a page that is beyond current inode size, it will truncate page buffers for the page and return 0. This logic has been added in 2.5.62 in commit 81eb69062588 ("fix ext3 BUG due to race with truncate") in history.git tree to fix a problem with ext3 in data=ordered mode. This particular problem doesn't exist anymore because ext3 is long gone and ext4 handles ordered data differently. Also normally buffers are invalidated by truncate code and there's no need to specially handle this in ->writepage() code.
This invalidation of page buffers in block_write_full_page() is causing issues to filesystems (e.g. ext4 or ocfs2) when block device is shrunk under filesystem's hands and metadata buffers get discarded while being tracked by the journalling layer. Although it is obviously "not supported" it can cause kernel crashes like:
[ 7986.689400] BUG: unable to handle kernel NULL pointer dereference at +0000000000000008 [ 7986.697197] PGD 0 P4D 0 [ 7986.699724] Oops: 0002 [#1] SMP PTI [ 7986.703200] CPU: 4 PID: 203778 Comm: jbd2/dm-3-8 Kdump: loaded Tainted: G +O --------- - - 4.18.0-147.5.0.5.h126.eulerosv2r9.x86_64 #1 [ 7986.716438] Hardware name: Huawei RH2288H V3/BC11HGSA0, BIOS 1.57 08/11/2015 [ 7986.723462] RIP: 0010:jbd2_journal_grab_journal_head+0x1b/0x40 [jbd2] ... [ 7986.810150] Call Trace: [ 7986.812595] __jbd2_journal_insert_checkpoint+0x23/0x70 [jbd2] [ 7986.818408] jbd2_journal_commit_transaction+0x155f/0x1b60 [jbd2] [ 7986.836467] kjournald2+0xbd/0x270 [jbd2]
which is not great. The crash happens because bh->b_private is suddently NULL although BH_JBD flag is still set (this is because block_invalidatepage() cleared BH_Mapped flag and subsequent bh lookup found buffer without BH_Mapped set, called init_page_buffers() which has rewritten bh->b_private). So just remove the invalidation in block_write_full_page().
Note that the buffer cache invalidation when block device changes size is already careful to avoid similar problems by using invalidate_mapping_pages() which skips busy buffers so it was only this odd block_write_full_page() behavior that could tear down bdev buffers under filesystem's hands.
--- fs/buffer.c | 16 ---------------- 1 file changed, 16 deletions(-)
fs/buffer.c +0 -16
@@ -2771,16 +2771,6 @@ int nobh_writepage(struct page *page, ge/* Is the page fully outside i_size? (truncate in progress) */ offset = i_size & (PAGE_SIZE -1 );if (page->index >= end_index+1 || !offset) { -/* -* The page may have dirty, unmapped buffers. For example, -* they may have been added in ext3_writepage(). Make them -* freeable here, so the page does not leak. -*/ -#if 0 -/* Not really sure about this - do we need this ? */ -if (page->mapping->a_ops->invalidatepage) - page->mapping->a_ops->invalidatepage (page, offset); -#endif unlock_page (page);return 0 ;/* don't care */ }
@@ -2975,12 +2965,6 @@ int block_write_full_page(struct page *p/* Is the page fully outside i_size? (truncate in progress) */ offset = i_size & (PAGE_SIZE -1 );if (page->index >= end_index+1 || !offset) { -/* -* The page may have dirty, unmapped buffers. For example, -* they may have been added in ext3_writepage(). Make them -* freeable here, so the page does not leak. -*/ -do_invalidatepage (page,0 ,PAGE_SIZE );unlock_page (page);return 0 ;/* don't care */ }
Greg Kroah-Hartman
maintainerPATCH 205/391 ACPI: button: fix handling lid state changes when input device closed
In reply to Greg Kroah-HartmanFrom: [email protected] <[email protected]>
commit 21988a8e51479ceffe7b0568b170effabb708dfe upstream.
The original intent of 84d3f6b76447 was to delay evaluating lid state until all drivers have been loaded, with input device being opened from userspace serving as a signal for this condition. Let's ensure that state updates happen even if userspace closed (or in the future inhibited) input device.
Note that if we go through suspend/resume cycle we assume the system has been fully initialized even if LID input device has not been opened yet.
This has a side-effect of fixing access to input->users outside of input->mutex protections by the way of eliminating said accesses and using driver private flag.
--- drivers/acpi/button.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/acpi/button.c +7 -6
@@ -153,6 +153,7 @@ struct acpi_button {int last_state;ktime_t last_time;bool suspended; +bool lid_state_initialized; };static struct acpi_device *lid_device;
@@ -383,6 +384,8 @@ static int acpi_lid_update_state(structstatic void acpi_lid_initialize_state (struct acpi_device *device) { +struct acpi_button *button =acpi_driver_data (device); +switch (lid_init_state) {case ACPI_BUTTON_LID_INIT_OPEN : (void )acpi_lid_notify_state (device,1 );
@@ -394,13 +397,14 @@ static void acpi_lid_initialize_state(stdefault :break ; } + + button->lid_state_initialized = true; }static void acpi_button_notify (struct acpi_device *device,u32 event) {struct acpi_button *button =acpi_driver_data (device);struct input_dev *input; -int users;switch (event) {case ACPI_FIXED_HARDWARE_EVENT :
@@ -409,10 +413,7 @@ static void acpi_button_notify(struct accase ACPI_BUTTON_NOTIFY_STATUS : input = button->input;if (button->type ==ACPI_BUTTON_TYPE_LID ) { -mutex_lock (&button->input->mutex); - users = button->input->users; -mutex_unlock (&button->input->mutex); -if (users) +if (button->lid_state_initialized)acpi_lid_update_state (device, true); }else {int keycode;
@@ -457,7 +458,7 @@ static int acpi_button_resume(struct devstruct acpi_button *button =acpi_driver_data (device); button->suspended = false; -if (button->type ==ACPI_BUTTON_TYPE_LID && button->input->users) { +if (button->type ==ACPI_BUTTON_TYPE_LID ) { button->last_state = !!acpi_lid_evaluate_state (device); button->last_time =ktime_get ();acpi_lid_initialize_state (device);
Greg Kroah-Hartman
maintainerPATCH 206/391 ACPI / extlog: Check for RDMSR failure
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
commit 7cecb47f55e00282f972a1e0b09136c8cd938221 upstream.
extlog_init() uses rdmsrl() to read an MSR, which on older CPUs provokes a error message at boot:
unchecked MSR access error: RDMSR from 0x179 at rIP: 0xcd047307 (native_read_msr+0x7/0x40)
Use rdmsrl_safe() instead, and return -ENODEV if it fails.
--- drivers/acpi/acpi_extlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/acpi_extlog.c +3 -3
@@ -222,9 +222,9 @@ static int __init extlog_init(void)u64 cap;int rc; -rdmsrl (MSR_IA32_MCG_CAP , cap); - -if (!(cap &MCG_ELOG_P ) || !extlog_get_l1addr ()) +if (rdmsrl_safe (MSR_IA32_MCG_CAP , &cap) || + !(cap &MCG_ELOG_P ) || + !extlog_get_l1addr ())return -ENODEV ; rc = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 207/391 ACPI: video: use ACPI backlight for HP 635 Notebook
In reply to Greg Kroah-HartmanFrom: Alex Hung <[email protected]>
commit b226faab4e7890bbbccdf794e8b94276414f9058 upstream.
The default backlight interface is AMD's radeon_bl0 which does not work on this system, so use the ACPI backlight interface on it instead.
--- drivers/acpi/video_detect.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/acpi/video_detect.c +9 -0
@@ -282,6 +282,15 @@ static const struct dmi_system_id video_ DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"), }, }, +/* https://bugs.launchpad.net/bugs/1894667 */ + { + .callback = video_detect_force_video, + .ident = "HP 635 Notebook", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Hewlett-Packard" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"), + }, + }, /* Non win8 machines which need native backlight nevertheless */ {
Greg Kroah-Hartman
maintainerPATCH 208/391 ACPI: debug: dont allow debugging when ACPI is disabled
In reply to Greg Kroah-HartmanFrom: Jamie Iles <[email protected]>
commit 0fada277147ffc6d694aa32162f51198d4f10d94 upstream.
If ACPI is disabled then loading the acpi_dbg module will result in the following splat when lock debugging is enabled.
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
WARNING: CPU: 0 PID: 1 at kernel/locking/mutex.c:938 __mutex_lock+0xa10/0x1290 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc8+ #103 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x0/0x4d8 show_stack+0x34/0x48 dump_stack+0x174/0x1f8 panic+0x360/0x7a0 __warn+0x244/0x2ec report_bug+0x240/0x398 bug_handler+0x50/0xc0 call_break_hook+0x160/0x1d8 brk_handler+0x30/0xc0 do_debug_exception+0x184/0x340 el1_dbg+0x48/0xb0 el1_sync_handler+0x170/0x1c8 el1_sync+0x80/0x100 __mutex_lock+0xa10/0x1290 mutex_lock_nested+0x6c/0xc0 acpi_register_debugger+0x40/0x88 acpi_aml_init+0xc4/0x114 do_one_initcall+0x24c/0xb10 kernel_init_freeable+0x690/0x728 kernel_init+0x20/0x1e8 ret_from_fork+0x10/0x18
This is because acpi_debugger.lock has not been initialized as acpi_debugger_init() is not called when ACPI is disabled. Fail module loading to avoid this and any subsequent problems that might arise by trying to debug AML when ACPI is disabled.
--- drivers/acpi/acpi_dbg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/acpi_dbg.c +3 -0
@@ -749,6 +749,9 @@ static int __init acpi_aml_init(void) {int ret; +if (acpi_disabled) +return -ENODEV ; +/* Initialize AML IO interface */ mutex_init (&acpi_aml_io.lock);init_waitqueue_head (&acpi_aml_io.wait);
Greg Kroah-Hartman
maintainerPATCH 181/391 nvme-rdma: fix crash when connect rejected
In reply to Greg Kroah-HartmanFrom: Chao Leng <[email protected]>
[ Upstream commit 43efdb8e870ee0f58633fd579aa5b5185bf5d39e ]
A crash can happened when a connect is rejected. The host establishes
the connection after received ConnectReply, and then continues to send the fabrics Connect command. If the controller does not receive the ReadyToUse capsule, host may receive a ConnectReject reply.
Call nvme_rdma_destroy_queue_ib after the host received the RDMA_CM_EVENT_REJECTED event. Then when the fabrics Connect command times out, nvme_rdma_timeout calls nvme_rdma_complete_rq to fail the request. A crash happenes due to use after free in nvme_rdma_complete_rq.
nvme_rdma_destroy_queue_ib is redundant when handling the RDMA_CM_EVENT_REJECTED event as nvme_rdma_destroy_queue_ib is already called in connection failure handler.
--- drivers/nvme/host/rdma.c | 1 - 1 file changed, 1 deletion(-)
drivers/nvme/host/rdma.c +0 -1
@@ -1926,7 +1926,6 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,complete (&queue->cm_done);return 0 ;case RDMA_CM_EVENT_REJECTED : -nvme_rdma_destroy_queue_ib (queue); cm_error =nvme_rdma_conn_rejected (queue, ev);break ;case RDMA_CM_EVENT_ROUTE_ERROR :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 209/391 PCI/ACPI: Whitelist hotplug ports for D3 if power managed by ACPI
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit c6e331312ebfb52b7186e5d82d517d68b4d2f2d8 upstream.
Recent laptops with dual AMD GPUs fail to suspend the discrete GPU, thus causing lockups on system sleep and high power consumption at runtime. The discrete GPU would normally be suspended to D3cold by turning off ACPI _PR3 Power Resources of the Root Port above the GPU.
However on affected systems, the Root Port is hotplug-capable and pci_bridge_d3_possible() only allows hotplug ports to go to D3 if they belong to a Thunderbolt device or if the Root Port possesses a "HotPlugSupportInD3" ACPI property. Neither is the case on affected laptops. The reason for whitelisting only specific, known to work hotplug ports for D3 is that there have been reports of SkyLake Xeon-SP systems raising Hardware Error NMIs upon suspending their hotplug ports:
https://lore.kernel.org/linux-pci/20170503180426.GA4058@otc-nc-03/
But if a hotplug port is power manageable by ACPI (as can be detected through presence of Power Resources and corresponding _PS0 and _PS3 methods) then it ought to be safe to suspend it to D3. To this end, amend acpi_pci_bridge_d3() to whitelist such ports for D3.
--- drivers/pci/pci-acpi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pci/pci-acpi.c +10 -0
@@ -944,6 +944,16 @@ static bool acpi_pci_bridge_d3(struct pcif (!dev->is_hotplug_bridge)return false; +/* Assume D3 support if the bridge is power-manageable by ACPI. */ + adev =ACPI_COMPANION (&dev->dev); +if (!adev && !pci_dev_is_added (dev)) { + adev =acpi_pci_find_companion (&dev->dev); +ACPI_COMPANION_SET (&dev->dev, adev); + } + +if (adev &&acpi_device_power_manageable (adev)) +return true; +/* * Look for a special _DSD property for the root port and if it * is set we know the hierarchy behind it supports D3 just fine.
Greg Kroah-Hartman
maintainerPATCH 211/391 ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit e0e9ce390d7bc6a705653d4a8aa4ea92c9a65e53 upstream.
It turns out that in some cases there are EC events to flush in acpi_ec_dispatch_gpe() even though the ec_no_wakeup kernel parameter is set and the EC GPE is disabled while sleeping, so drop the ec_no_wakeup check that prevents those events from being processed from acpi_ec_dispatch_gpe().
--- drivers/acpi/ec.c | 3 --- 1 file changed, 3 deletions(-)
drivers/acpi/ec.c +0 -3
@@ -2011,9 +2011,6 @@ bool acpi_ec_dispatch_gpe(void)if (acpi_any_gpe_status_set (first_ec->gpe))return true; -if (ec_no_wakeup) -return false; -/* * Dispatch the EC GPE in-band, but do not report wakeup in any case * to allow the caller to process events properly after that.
Greg Kroah-Hartman
maintainerPATCH 213/391 io-wq: assign NUMA node locality if appropriate
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit a8b595b22d31f83b715511f59012f152a269d83b upstream.
There was an assumption that kthread_create_on_node() would properly set NUMA affinities in terms of CPUs allowed, but it doesn't. Make sure we do this when creating an io-wq context on NUMA.
Cc: [email protected]
Stefan Metzmacher <[email protected]>
--- fs/io-wq.c | 1 + 1 file changed, 1 insertion(+)
fs/io-wq.c +1 -0
@@ -654,6 +654,7 @@ static bool create_io_worker(struct io_wkfree (worker);return false; } +kthread_bind_mask (worker->task,cpumask_of_node (wqe->node));raw_spin_lock_irq (&wqe->lock);hlist_nulls_add_head_rcu (&worker->nulls_node, &wqe->free_list);
Greg Kroah-Hartman
maintainerPATCH 214/391 w1: mxc_w1: Fix timeout resolution problem leading to bus error
In reply to Greg Kroah-HartmanFrom: Martin Fuzzey <[email protected]>
commit c9723750a699c3bd465493ac2be8992b72ccb105 upstream.
On my platform (i.MX53) bus access sometimes fails with
w1_search: max_slave_count 64 reached, will continue next search.
The reason is the use of jiffies to implement a 200us timeout in mxc_w1_ds2_touch_bit().
On some platforms the jiffies timer resolution is insufficient for this.
Fix by replacing jiffies by ktime_get().
For consistency apply the same change to the other use of jiffies in mxc_w1_ds2_reset_bus().
--- drivers/w1/masters/mxc_w1.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/w1/masters/mxc_w1.c +7 -7
@@ -7,7 +7,7 @@#include <linux/clk.h> #include <linux/delay.h> #include <linux/io.h> -#include <linux/jiffies.h> +#include <linux/ktime.h> #include <linux/module.h> #include <linux/mod_devicetable.h> #include <linux/platform_device.h>
@@ -40,12 +40,12 @@ struct mxc_w1_device {static u8 mxc_w1_ds2_reset_bus (void *data) {struct mxc_w1_device *dev = data; -unsigned long timeout; +ktime_t timeout;writeb (MXC_W1_CONTROL_RPP , dev->regs +MXC_W1_CONTROL );/* Wait for reset sequence 511+512us, use 1500us for sure */ - timeout = jiffies +usecs_to_jiffies (1500 ); + timeout =ktime_add_us (ktime_get (),1500 );udelay (511 +512 );
@@ -55,7 +55,7 @@ static u8 mxc_w1_ds2_reset_bus(void *dat/* PST bit is valid after the RPP bit is self-cleared */ if (!(ctrl &MXC_W1_CONTROL_RPP ))return !(ctrl &MXC_W1_CONTROL_PST ); - }while (time_is_after_jiffies (timeout)); + }while (ktime_before (ktime_get (), timeout));return 1 ; }
@@ -68,12 +68,12 @@ static u8 mxc_w1_ds2_reset_bus(void *datstatic u8 mxc_w1_ds2_touch_bit (void *data,u8 bit) {struct mxc_w1_device *dev = data; -unsigned long timeout; +ktime_t timeout;writeb (MXC_W1_CONTROL_WR (bit), dev->regs +MXC_W1_CONTROL );/* Wait for read/write bit (60us, Max 120us), use 200us for sure */ - timeout = jiffies +usecs_to_jiffies (200 ); + timeout =ktime_add_us (ktime_get (),200 );udelay (60 );
@@ -83,7 +83,7 @@ static u8 mxc_w1_ds2_touch_bit(void *dat/* RDST bit is valid after the WR1/RD bit is self-cleared */ if (!(ctrl &MXC_W1_CONTROL_WR (bit)))return !!(ctrl &MXC_W1_CONTROL_RDST ); - }while (time_is_after_jiffies (timeout)); + }while (ktime_before (ktime_get (), timeout));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 215/391 fs/kernel_read_file: Remove FIRMWARE_PREALLOC_BUFFER enum
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit c307459b9d1fcb8bbf3ea5a4162979532322ef77 upstream.
FIRMWARE_PREALLOC_BUFFER is a "how", not a "what", and confuses the LSMs that are interested in filtering between types of things. The "how" should be an internal detail made uninteresting to the LSMs.
--- drivers/base/firmware_loader/main.c | 5 ++--- fs/exec.c | 7 ++++--- include/linux/fs.h | 1 - kernel/module.c | 2 +- security/integrity/digsig.c | 2 +- security/integrity/ima/ima_fs.c | 2 +- security/integrity/ima/ima_main.c | 6 ++---- 7 files changed, 11 insertions(+), 14 deletions(-)
drivers/base/firmware_loader/main.c +2 -3
@@ -470,14 +470,12 @@ fw_get_filesystem_firmware(struct deviceint i, len;int rc = -ENOENT ;char *path; -enum kernel_read_file_id id =READING_FIRMWARE ;size_t msize =INT_MAX ;void *buffer =NULL ;/* Already populated data member means we're loading into a buffer */ if (!decompress && fw_priv->data) { buffer = fw_priv->data; - id =READING_FIRMWARE_PREALLOC_BUFFER ; msize = fw_priv->allocated_size; }
@@ -501,7 +499,8 @@ fw_get_filesystem_firmware(struct device/* load firmware files from the mount namespace of init */ rc =kernel_read_file_from_path_initns (path, &buffer, - &size, msize, id); + &size, msize, +READING_FIRMWARE );if (rc) {if (rc != -ENOENT ) dev_warn(device, "loading %s failed with error %d\n",
fs/exec.c +4 -3
@@ -955,6 +955,7 @@ int kernel_read_file(struct file *file, {loff_t i_size, pos;ssize_t bytes =0 ; +void *allocated =NULL ;int ret;if (!S_ISREG (file_inode (file)->i_mode) || max_size <0 )
@@ -978,8 +979,8 @@ int kernel_read_file(struct file *file, goto out; } -if (id !=READING_FIRMWARE_PREALLOC_BUFFER ) - *buf =vmalloc (i_size); +if (!*buf) + *buf = allocated =vmalloc (i_size);if (!*buf) { ret = -ENOMEM ; goto out;
@@ -1008,7 +1009,7 @@ int kernel_read_file(struct file *file, out_free:if (ret <0 ) { -if (id !=READING_FIRMWARE_PREALLOC_BUFFER ) { +if (allocated) {vfree (*buf); *buf =NULL ; }
include/linux/fs.h +0 -1
@@ -2861,7 +2861,6 @@ extern int do_pipe_flags(int *, int);#define __kernel_read_file_id (id) \ id(UNKNOWN, unknown) \ id(FIRMWARE, firmware) \ - id(FIRMWARE_PREALLOC_BUFFER, firmware) \ id(MODULE, kernel-module) \ id(KEXEC_IMAGE, kexec-image) \ id(KEXEC_INITRAMFS, kexec-initramfs) \
kernel/module.c +1 -1
@@ -4028,7 +4028,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, c {struct load_info info = { };loff_t size; -void *hdr; +void *hdr =NULL ;int err; err =may_init_module ();
security/integrity/digsig.c +1 -1
@@ -169,7 +169,7 @@ int __init integrity_add_key(const unsigint __init integrity_load_x509 (const unsigned int id,const char *path) { -void *data; +void *data =NULL ;loff_t size;int rc;key_perm_t perm;
security/integrity/ima/ima_fs.c +1 -1
@@ -272,7 +272,7 @@ static const struct file_operations ima_static ssize_t ima_read_policy (char *path) { -void *data; +void *data =NULL ;char *datap;loff_t size;int rc, pathlen =strlen (path);
security/integrity/ima/ima_main.c +2 -4
@@ -621,19 +621,17 @@ void ima_post_path_mknod(struct dentry *int ima_read_file (struct file *file,enum kernel_read_file_id read_id) {/* -* READING_FIRMWARE_PREALLOC_BUFFER -* * Do devices using pre-allocated memory run the risk of the * firmware being accessible to the device prior to the completion * of IMA's signature verification any more than when using two -* buffers? +* buffers? It may be desirable to include the buffer address +* in this API and walk all the dma_map_single() mappings to check. */ return 0 ; }const int read_idmap[READING_MAX_ID ] = { [READING_FIRMWARE ] =FIRMWARE_CHECK , - [READING_FIRMWARE_PREALLOC_BUFFER ] =FIRMWARE_CHECK , [READING_MODULE ] =MODULE_CHECK , [READING_KEXEC_IMAGE ] =KEXEC_KERNEL_CHECK , [READING_KEXEC_INITRAMFS ] =KEXEC_INITRAMFS_CHECK ,
Greg Kroah-Hartman
maintainerPATCH 217/391 scsi: qla2xxx: Fix MPI reset needed message
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 7a6cdbd5e87515ebf6231b762ad903c7cff87b9c upstream.
When printing the message:
"MPI Heartbeat stop. MPI reset is not needed.."
..the wrong register was checked leading to always printing that MPI reset is not needed, even when it is needed. Fix the MPI reset message.
--- drivers/scsi/qla2xxx/qla_isr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_isr.c +1 -1
@@ -767,7 +767,7 @@ qla27xx_handle_8200_aen(scsi_qla_host_tql_log (ql_log_warn, vha,0x02f0 ,"MPI Heartbeat stop. MPI reset is%s needed. " "MB0[%xh] MB1[%xh] MB2[%xh] MB3[%xh]\n" , - mb[0 ] &BIT_8 ?"" :" not" , + mb[1 ] &BIT_8 ?"" :" not" , mb[0 ], mb[1 ], mb[2 ], mb[3 ]);if ((mb[1 ] &BIT_8 ) ==0 )
Greg Kroah-Hartman
maintainerPATCH 182/391 vmlinux.lds.h: Add PGO and AutoFDO input sections
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
commit eff8728fe69880d3f7983bec3fb6cea4c306261f upstream.
Basically, consider .text.{hot|unlikely|unknown}.* part of .text, too.
When compiling with profiling information (collected via PGO instrumentations or AutoFDO sampling), Clang will separate code into .text.hot, .text.unlikely, or .text.unknown sections based on profiling information. After D79600 (clang-11), these sections will have a trailing . suffix, ie. .text.hot., .text.unlikely., .text.unknown..
When using -ffunction-sections together with profiling infomation, either explicitly (FGKASLR) or implicitly (LTO), code may be placed in sections following the convention:
.text.hot.<foo>, .text.unlikely.<bar>, .text.unknown.<baz> where <foo>, <bar>, and <baz> are functions. (This produces one section per function; we generally try to merge these all back via linker script so that we don't have 50k sections).
For the above cases, we need to teach our linker scripts that such sections might exist and that we'd explicitly like them grouped together, otherwise we can wind up with code outside of the _stext/_etext boundaries that might not be mapped properly for some architectures, resulting in boot failures.
If the linker script is not told about possible input sections, then where the section is placed as output is a heuristic-laiden mess that's non-portable between linkers (ie. BFD and LLD), and has resulted in many hard to debug bugs. Kees Cook is working on cleaning this up by adding --orphan-handling=warn linker flag used in ARCH=powerpc to additional architectures. In the case of linker scripts, borrowing from the Zen of
Python: explicit is better than implicit.
Also, ld.bfd's internal linker script considers .text.hot AND .text.hot.* to be part of .text, as well as .text.unlikely and .text.unlikely.*. I didn't see support for .text.unknown.*, and didn't see Clang producing such code in our kernel builds, but I see code in LLVM that can produce such section names if profiling information is missing. That may point to a larger issue with generating or collecting profiles, but I would much rather be safe and explicit than have to debug yet another issue related to orphan section placement.
--- include/asm-generic/vmlinux.lds.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +4 -1
@@ -581,7 +581,10 @@*/ #define TEXT_TEXT \ ALIGN_FUNCTION(); \ - *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ + *(.text.hot .text.hot.*) \ + *(TEXT_MAIN .text.fixup) \ + *(.text.unlikely .text.unlikely.*) \ + *(.text.unknown .text.unknown.*) \ NOINSTR_TEXT \ *(.text..refcount) \ *(.ref.text) \
Greg Kroah-Hartman
maintainerPATCH 218/391 scsi: qla2xxx: Fix reset of MPI firmware
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 3e6efab865ac943f4ec43913eb665695737112b0 upstream.
Normally, the MPI firmware is reset when an MPI dump is collected. If an unsaved MPI dump exists in the driver, though, an alternate mechanism is used. This mechanism, which was not fully correct, is not recommended and instead an MPI dump template walk is suggested to perform the MPI reset.
To allow for the MPI dump template walk, extra space is reserved in the MPI dump buffer which gets used only when there is already an MPI dump in place.
--- drivers/scsi/qla2xxx/qla_attr.c | 10 ++++++-- drivers/scsi/qla2xxx/qla_gbl.h | 1 drivers/scsi/qla2xxx/qla_init.c | 2 + drivers/scsi/qla2xxx/qla_tmpl.c | 49 ++++++++++------------------------------ 4 files changed, 23 insertions(+), 39 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +8 -2
@@ -157,6 +157,14 @@ qla2x00_sysfs_write_fw_dump(struct file vha->host_no); }break ; +case 10 : +if (IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { +ql_log (ql_log_info, vha,0x70e9 , +"Issuing MPI firmware dump on host#%ld.\n" , + vha->host_no); + ha->isp_ops->mpi_fw_dump (vha,0 ); + } +break ; }return count; }
@@ -744,8 +752,6 @@ qla2x00_sysfs_write_reset(struct file *fqla83xx_idc_audit (vha,IDC_AUDIT_TIMESTAMP );qla83xx_idc_unlock (vha,0 );break ; - }else if (IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { -qla27xx_reset_mpi (vha); }else {/* Make sure FC side is not in reset */ WARN_ON_ONCE(qla2x00_wait_for_hba_online(vha) !=
drivers/scsi/qla2xxx/qla_gbl.h +0 -1
@@ -938,6 +938,5 @@ extern void qla24xx_process_purex_list(s/* nvme.c */ void qla_nvme_unregister_remote_port (struct fc_port *fcport); -void qla27xx_reset_mpi (scsi_qla_host_t *vha);void qla_handle_els_plogi_done (scsi_qla_host_t *vha,struct event_arg *ea);#endif /* _QLA_GBL_H */
drivers/scsi/qla2xxx/qla_init.c +2 -0
@@ -3298,6 +3298,8 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v j, fwdt->dump_size); dump_size += fwdt->dump_size; } +/* Add space for spare MPI fw dump. */ + dump_size += ha->fwdt[1 ].dump_size; }else { req_q_size = req->length *sizeof (request_t); rsp_q_size = rsp->length *sizeof (response_t);
drivers/scsi/qla2xxx/qla_tmpl.c +13 -36
84 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 185/391 md/raid5: fix oops during stripe resizing
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
commit b44c018cdf748b96b676ba09fdbc5b34fc443ada upstream.
KoWei reported crash during raid5 reshape:
[ 1032.252932] Oops: 0002 [#1] SMP PTI [...] [ 1032.252943] RIP: 0010:memcpy_erms+0x6/0x10 [...] [ 1032.252947] RSP: 0018:ffffba1ac0c03b78 EFLAGS: 00010286 [ 1032.252949] RAX: 0000784ac0000000 RBX: ffff91bec3d09740 RCX: 0000000000001000 [ 1032.252951] RDX: 0000000000001000 RSI: ffff91be6781c000 RDI: 0000784ac0000000 [ 1032.252953] RBP: ffffba1ac0c03bd8 R08: 0000000000001000 R09: ffffba1ac0c03bf8 [ 1032.252954] R10: 0000000000000000 R11: 0000000000000000 R12: ffffba1ac0c03bf8 [ 1032.252955] R13: 0000000000001000 R14: 0000000000000000 R15: 0000000000000000 [ 1032.252958] FS: 0000000000000000(0000) GS:ffff91becf500000(0000) knlGS:0000000000000000 [ 1032.252959] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1032.252961] CR2: 0000784ac0000000 CR3: 000000031780a002 CR4: 00000000001606e0 [ 1032.252962] Call Trace: [ 1032.252969] ? async_memcpy+0x179/0x1000 [async_memcpy] [ 1032.252977] ? raid5_release_stripe+0x8e/0x110 [raid456] [ 1032.252982] handle_stripe_expansion+0x15a/0x1f0 [raid456] [ 1032.252988] handle_stripe+0x592/0x1270 [raid456] [ 1032.252993] handle_active_stripes.isra.0+0x3cb/0x5a0 [raid456] [ 1032.252999] raid5d+0x35c/0x550 [raid456] [ 1032.253002] ? schedule+0x42/0xb0 [ 1032.253006] ? schedule_timeout+0x10e/0x160 [ 1032.253011] md_thread+0x97/0x160 [ 1032.253015] ? wait_woken+0x80/0x80 [ 1032.253019] kthread+0x104/0x140 [ 1032.253022] ? md_start_sync+0x60/0x60 [ 1032.253024] ? kthread_park+0x90/0x90 [ 1032.253027] ret_from_fork+0x35/0x40
This is because cache_size_mutex was unlocked too early in resize_stripes, which races with grow_one_stripe() that grow_one_stripe() allocates a stripe with wrong pool_size.
Fix this issue by unlocking cache_size_mutex after updating pool_size.
--- drivers/md/raid5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/raid5.c +2 -2
@@ -2429,8 +2429,6 @@ static int resize_stripes(struct r5conf }else err = -ENOMEM ; -mutex_unlock (&conf->cache_size_mutex); - conf->slab_cache = sc; conf->active_name =1 -conf->active_name;
@@ -2453,6 +2451,8 @@ static int resize_stripes(struct r5confif (!err) conf->pool_size = newsize; +mutex_unlock (&conf->cache_size_mutex); +return err; }
Greg Kroah-Hartman
maintainerPATCH 186/391 mmc: sdhci: Add LTR support for some Intel BYT based controllers
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 46f4a69ec8ed6ab9f6a6172afe50df792c8bc1b6 upstream.
Some Intel BYT based host controllers support the setting of latency tolerance. Accordingly, implement the PM QoS ->set_latency_tolerance() callback. The raw register values are also exposed via debugfs.
Intel EHL controllers require this support.
--- drivers/mmc/host/sdhci-pci-core.c | 154 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+)
drivers/mmc/host/sdhci-pci-core.c +154 -0
@@ -24,6 +24,8 @@#include <linux/iopoll.h> #include <linux/gpio.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> +#include <linux/debugfs.h> #include <linux/mmc/slot-gpio.h> #include <linux/mmc/sdhci-pci-data.h> #include <linux/acpi.h>
@@ -516,6 +518,8 @@ struct intel_host {bool rpm_retune_ok;u32 glk_rx_ctrl1;u32 glk_tun_val; +u32 active_ltr; +u32 idle_ltr; }; static const guid_t intel_dsm_guid =
@@ -760,6 +764,108 @@ static int intel_execute_tuning(struct mreturn 0 ; } +#define INTEL_ACTIVELTR 0x804 +#define INTEL_IDLELTR 0x808 + +#define INTEL_LTR_REQ BIT(15) +#define INTEL_LTR_SCALE_MASK GENMASK(11, 10) +#define INTEL_LTR_SCALE_1US (2 << 10) +#define INTEL_LTR_SCALE_32US (3 << 10) +#define INTEL_LTR_VALUE_MASK GENMASK(9, 0) + +static void intel_cache_ltr (struct sdhci_pci_slot *slot) +{ +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct sdhci_host *host = slot->host; + + intel_host->active_ltr =readl (host->ioaddr +INTEL_ACTIVELTR ); + intel_host->idle_ltr =readl (host->ioaddr +INTEL_IDLELTR ); +} + +static void intel_ltr_set (struct device *dev,s32 val) +{ +struct sdhci_pci_chip *chip =dev_get_drvdata (dev); +struct sdhci_pci_slot *slot = chip->slots[0 ]; +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct sdhci_host *host = slot->host; +u32 ltr; + +pm_runtime_get_sync (dev); + +/* +* Program latency tolerance (LTR) accordingly what has been asked +* by the PM QoS layer or disable it in case we were passed +* negative value or PM_QOS_LATENCY_ANY. +*/ + ltr =readl (host->ioaddr +INTEL_ACTIVELTR ); + +if (val ==PM_QOS_LATENCY_ANY || val <0 ) { + ltr &= ~INTEL_LTR_REQ ; + }else { + ltr |=INTEL_LTR_REQ ; + ltr &= ~INTEL_LTR_SCALE_MASK ; + ltr &= ~INTEL_LTR_VALUE_MASK ; + +if (val >INTEL_LTR_VALUE_MASK ) { + val >>=5 ; +if (val >INTEL_LTR_VALUE_MASK ) + val =INTEL_LTR_VALUE_MASK ; + ltr |=INTEL_LTR_SCALE_32US | val; + }else { + ltr |=INTEL_LTR_SCALE_1US | val; + } + } + +if (ltr == intel_host->active_ltr) + goto out; + +writel (ltr, host->ioaddr +INTEL_ACTIVELTR ); +writel (ltr, host->ioaddr +INTEL_IDLELTR ); + +/* Cache the values into lpss structure */ +intel_cache_ltr (slot); +out: +pm_runtime_put_autosuspend (dev); +} + +static bool intel_use_ltr (struct sdhci_pci_chip *chip) +{ +switch (chip->pdev->device) { +case PCI_DEVICE_ID_INTEL_BYT_EMMC : +case PCI_DEVICE_ID_INTEL_BYT_EMMC2 : +case PCI_DEVICE_ID_INTEL_BYT_SDIO : +case PCI_DEVICE_ID_INTEL_BYT_SD : +case PCI_DEVICE_ID_INTEL_BSW_EMMC : +case PCI_DEVICE_ID_INTEL_BSW_SDIO : +case PCI_DEVICE_ID_INTEL_BSW_SD : +return false; +default : +return true; + } +} + +static void intel_ltr_expose (struct sdhci_pci_chip *chip) +{ +struct device *dev = &chip->pdev->dev; + +if (!intel_use_ltr (chip)) +return ; + + dev->power.set_latency_tolerance = intel_ltr_set; +dev_pm_qos_expose_latency_tolerance (dev); +} + +static void intel_ltr_hide (struct sdhci_pci_chip *chip) +{ +struct device *dev = &chip->pdev->dev; + +if (!intel_use_ltr (chip)) +return ; + +dev_pm_qos_hide_latency_tolerance (dev); + dev->power.set_latency_tolerance =NULL ; +} +static void byt_probe_slot (struct sdhci_pci_slot *slot) {struct mmc_host_ops *ops = &slot->host->mmc_host_ops;
@@ -774,6 +880,43 @@ static void byt_probe_slot(struct sdhci_ ops->start_signal_voltage_switch = intel_start_signal_voltage_switch;device_property_read_u32 (dev,"max-frequency" , &mmc->f_max); + +if (!mmc->slotno) { + slot->chip->slots[mmc->slotno] = slot; +intel_ltr_expose (slot->chip); + } +} + +static void byt_add_debugfs (struct sdhci_pci_slot *slot) +{ +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct mmc_host *mmc = slot->host->mmc; +struct dentry *dir = mmc->debugfs_root; + +if (!intel_use_ltr (slot->chip)) +return ; + +debugfs_create_x32 ("active_ltr" ,0444 , dir, &intel_host->active_ltr); +debugfs_create_x32 ("idle_ltr" ,0444 , dir, &intel_host->idle_ltr); + +intel_cache_ltr (slot); +} + +static int byt_add_host (struct sdhci_pci_slot *slot) +{ +int ret =sdhci_add_host (slot->host); + +if (!ret) +byt_add_debugfs (slot); +return ret; +} + +static void byt_remove_slot (struct sdhci_pci_slot *slot,int dead) +{ +struct mmc_host *mmc = slot->host->mmc; + +if (!mmc->slotno) +intel_ltr_hide (slot->chip); }static int byt_emmc_probe_slot (struct sdhci_pci_slot *slot)
@@ -855,6 +998,8 @@ static int glk_emmc_add_host(struct sdhcif (ret) goto cleanup; +byt_add_debugfs (slot); +return 0 ; cleanup:
@@ -1032,6 +1177,8 @@ static const struct sdhci_pci_fixes sdhc#endif .allow_runtime_pm = true, .probe_slot = byt_emmc_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .quirks =SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | SDHCI_QUIRK_NO_LED, .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
@@ -1045,6 +1192,7 @@ static const struct sdhci_pci_fixes sdhc .allow_runtime_pm = true, .probe_slot = glk_emmc_probe_slot, .add_host = glk_emmc_add_host, + .remove_slot = byt_remove_slot, #ifdef CONFIG_PM_SLEEP .suspend = sdhci_cqhci_suspend, .resume = sdhci_cqhci_resume,
@@ -1075,6 +1223,8 @@ static const struct sdhci_pci_fixes sdhc SDHCI_QUIRK2_PRESET_VALUE_BROKEN, .allow_runtime_pm = true, .probe_slot = ni_byt_sdio_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
@@ -1092,6 +1242,8 @@ static const struct sdhci_pci_fixes sdhc SDHCI_QUIRK2_PRESET_VALUE_BROKEN, .allow_runtime_pm = true, .probe_slot = byt_sdio_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
@@ -1111,6 +1263,8 @@ static const struct sdhci_pci_fixes sdhc .allow_runtime_pm = true, .own_cd_for_runtime_pm = true, .probe_slot = byt_sd_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
Greg Kroah-Hartman
maintainerPATCH 178/391 arm64: dts: qcom: kitakami: Temporarily disable SDHCI1
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit e884fb6cc89dce1debeae33704edd7735a3d6d9c ]
There is an issue with Kitakami eMMCs dying when a quirk isn't addressed. Until that happens, disable it.
--- arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi +6 -1
@@ -221,7 +221,12 @@ }; &sdhc1 { - status = "okay"; + /* There is an issue with the eMMC causing permanent + * damage to the card if a quirk isn't addressed. + * Until it's fixed, disable the MMC so as not to brick + * devices. + */ + status = "disabled"; /* Downstream pushes 2.95V to the sdhci device, * but upstream driver REALLY wants to make vmmc 1.8v
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 187/391 mmc: sdhci-acpi: AMDI0040: Set SDHCI_QUIRK2_PRESET_VALUE_BROKEN
In reply to Greg Kroah-HartmanFrom: Raul E Rangel <[email protected]>
commit f23cc3ba491af77395cea3f9d51204398729f26b upstream.
This change fixes HS400 tuning for devices with invalid presets.
SDHCI presets are not currently used for eMMC HS/HS200/HS400, but are used for DDR52. The HS400 retuning sequence is:
HS400->DDR52->HS->HS200->Perform Tuning->HS->HS400
This means that when HS400 tuning happens, we transition through DDR52 for a very brief period. This causes presets to be enabled unintentionally and stay enabled when transitioning back to HS200 or HS400. Some firmware has invalid presets, so we end up with driver strengths that can cause I/O problems.
--- drivers/mmc/host/sdhci-acpi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/mmc/host/sdhci-acpi.c +37 -0
@@ -662,6 +662,43 @@ static int sdhci_acpi_emmc_amd_probe_slo (host->mmc->caps & MMC_CAP_1_8V_DDR)) host->mmc->caps2 =MMC_CAP2_HS400_1_8V ; +/* +* There are two types of presets out in the wild: +* 1) Default/broken presets. +* These presets have two sets of problems: +* a) The clock divisor for SDR12, SDR25, and SDR50 is too small. +* This results in clock frequencies that are 2x higher than +* acceptable. i.e., SDR12 = 25 MHz, SDR25 = 50 MHz, SDR50 = +* 100 MHz.x +* b) The HS200 and HS400 driver strengths don't match. +* By default, the SDR104 preset register has a driver strength of +* A, but the (internal) HS400 preset register has a driver +* strength of B. As part of initializing HS400, HS200 tuning +* needs to be performed. Having different driver strengths +* between tuning and operation is wrong. It results in different +* rise/fall times that lead to incorrect sampling. +* 2) Firmware with properly initialized presets. +* These presets have proper clock divisors. i.e., SDR12 => 12MHz, +* SDR25 => 25 MHz, SDR50 => 50 MHz. Additionally the HS200 and +* HS400 preset driver strengths match. +* +* Enabling presets for HS400 doesn't work for the following reasons: +* 1) sdhci_set_ios has a hard coded list of timings that are used +* to determine if presets should be enabled. +* 2) sdhci_get_preset_value is using a non-standard register to +* read out HS400 presets. The AMD controller doesn't support this +* non-standard register. In fact, it doesn't expose the HS400 +* preset register anywhere in the SDHCI memory map. This results +* in reading a garbage value and using the wrong presets. +* +* Since HS400 and HS200 presets must be identical, we could +* instead use the the SDR104 preset register. +* +* If the above issues are resolved we could remove this quirk for +* firmware that that has valid presets (i.e., SDR12 <= 12 MHz). +*/ + host->quirks2 |=SDHCI_QUIRK2_PRESET_VALUE_BROKEN ; + host->mmc_host_ops.select_drive_strength = amd_select_drive_strength; host->mmc_host_ops.set_ios = amd_set_ios; host->mmc_host_ops.execute_tuning = amd_sdhci_execute_tuning;
Greg Kroah-Hartman
maintainerPATCH 220/391 PM: runtime: Remove link state checks in rpm_get/put_supplier()
In reply to Greg Kroah-HartmanFrom: Xiang Chen <[email protected]>
commit d12544fb2aa9944b180c35914031a8384ab082c1 upstream.
To support runtime PM for hisi SAS driver (the driver is in directory drivers/scsi/hisi_sas), we add device link between scsi_device->sdev_gendev (consumer device) and hisi_hba->dev(supplier device) with flags DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE.
After runtime suspended consumers and supplier, unload the dirver which causes a hung.
We found that it called function device_release_driver_internal() to release the supplier device (hisi_hba->dev), as the device link was busy, it set the device link state to DL_STATE_SUPPLIER_UNBIND, and then it called device_release_driver_internal() to release the consumer device (scsi_device->sdev_gendev).
Then it would try to call pm_runtime_get_sync() to resume the consumer device, but because consumer-supplier relation existed, it would try to resume the supplier first, but as the link state was already DL_STATE_SUPPLIER_UNBIND, so it skipped resuming the supplier and only resumed the consumer which hanged (it sends IOs to resume scsi_device while the SAS controller is suspended).
Simple flow is as follows:
device_release_driver_internal -> (supplier device)
if device_links_busy ->
device_links_unbind_consumers ->
...
WRITE_ONCE(link->status, DL_STATE_SUPPLIER_UNBIND)
device_release_driver_internal (consumer device)
pm_runtime_get_sync -> (consumer device)
...
__rpm_callback ->
rpm_get_suppliers ->
if link->state == DL_STATE_SUPPLIER_UNBIND -> skip the action of resuming the supplier
...
pm_runtime_clean_up_links
...Correct suspend/resume ordering between a supplier device and its consumer devices (resume the supplier device before resuming consumer devices, and suspend consumer devices before suspending the supplier device) should be guaranteed by runtime PM, but the state checks in rpm_get_supplier() and rpm_put_supplier() break this rule, so remove them.
--- drivers/base/power/runtime.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/base/power/runtime.c +1 -4
@@ -291,8 +291,7 @@ static int rpm_get_suppliers(struct devi device_links_read_lock_held()) {int retval; -if (!(link->flags &DL_FLAG_PM_RUNTIME ) || -READ_ONCE (link->status) ==DL_STATE_SUPPLIER_UNBIND ) +if (!(link->flags &DL_FLAG_PM_RUNTIME ))continue ; retval =pm_runtime_get_sync (link->supplier);
@@ -312,8 +311,6 @@ static void rpm_put_suppliers(struct devlist_for_each_entry_rcu (link, &dev->links.suppliers, c_node,device_links_read_lock_held ()) { -if (READ_ONCE (link->status) ==DL_STATE_SUPPLIER_UNBIND ) -continue ;while (refcount_dec_not_one (&link->rpm_active))pm_runtime_put (link->supplier);
Greg Kroah-Hartman
maintainerPATCH 229/391 btrfs: use kvzalloc() to allocate clone_roots in btrfs_ioctl_send()
In reply to Greg Kroah-HartmanFrom: Denis Efremov <[email protected]>
commit 8eb2fd00153a3a96a19c62ac9c6d48c2efebe5e8 upstream.
btrfs_ioctl_send() used open-coded kvzalloc implementation earlier. The code was accidentally replaced with kzalloc() call [1]. Restore the original code by using kvzalloc() to allocate sctx->clone_roots.
[1] https://patchwork.kernel.org/patch/9757891/#20529627
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -7300,7 +7300,7 @@ long btrfs_ioctl_send(struct file *mnt_f alloc_size =sizeof (struct clone_root ) * (arg->clone_sources_count +1 ); - sctx->clone_roots =kzalloc (alloc_size,GFP_KERNEL ); + sctx->clone_roots =kvzalloc (alloc_size,GFP_KERNEL );if (!sctx->clone_roots) { ret = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 231/391 btrfs: reschedule when cloning lots of extents
In reply to Greg Kroah-HartmanFrom: Johannes Thumshirn <[email protected]>
commit 6b613cc97f0ace77f92f7bc112b8f6ad3f52baf8 upstream.
We have several occurrences of a soft lockup from fstest's generic/175 testcase, which look more or less like this one:
watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [xfs_io:10030] Kernel panic - not syncing: softlockup: hung tasks CPU: 0 PID: 10030 Comm: xfs_io Tainted: G L 5.9.0-rc5+ #768 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4-rebuilt.opensuse.org 04/01/2014 Call Trace: <IRQ> dump_stack+0x77/0xa0 panic+0xfa/0x2cb watchdog_timer_fn.cold+0x85/0xa5 ? lockup_detector_update_enable+0x50/0x50 __hrtimer_run_queues+0x99/0x4c0 ? recalibrate_cpu_khz+0x10/0x10 hrtimer_run_queues+0x9f/0xb0 update_process_times+0x28/0x80 tick_handle_periodic+0x1b/0x60 __sysvec_apic_timer_interrupt+0x76/0x210 asm_call_on_stack+0x12/0x20 </IRQ> sysvec_apic_timer_interrupt+0x7f/0x90 asm_sysvec_apic_timer_interrupt+0x12/0x20 RIP: 0010:btrfs_tree_unlock+0x91/0x1a0 [btrfs] RSP: 0018:ffffc90007123a58 EFLAGS: 00000282 RAX: ffff8881cea2fbe0 RBX: ffff8881cea2fbe0 RCX: 0000000000000000 RDX: ffff8881d23fd200 RSI: ffffffff82045220 RDI: ffff8881cea2fba0 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000032 R10: 0000160000000000 R11: 0000000000001000 R12: 0000000000001000 R13: ffff8882357fd5b0 R14: ffff88816fa76e70 R15: ffff8881cea2fad0 ? btrfs_tree_unlock+0x15b/0x1a0 [btrfs] btrfs_release_path+0x67/0x80 [btrfs] btrfs_insert_replace_extent+0x177/0x2c0 [btrfs] btrfs_replace_file_extents+0x472/0x7c0 [btrfs] btrfs_clone+0x9ba/0xbd0 [btrfs] btrfs_clone_files.isra.0+0xeb/0x140 [btrfs] ? file_update_time+0xcd/0x120 btrfs_remap_file_range+0x322/0x3b0 [btrfs] do_clone_file_range+0xb7/0x1e0 vfs_clone_file_range+0x30/0xa0 ioctl_file_clone+0x8a/0xc0 do_vfs_ioctl+0x5b2/0x6f0 __x64_sys_ioctl+0x37/0xa0 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f87977fc247 RSP: 002b:00007ffd51a2f6d8 EFLAGS: 00000206 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f87977fc247 RDX: 00007ffd51a2f710 RSI: 000000004020940d RDI: 0000000000000003 RBP: 0000000000000004 R08: 00007ffd51a79080 R09: 0000000000000000 R10: 00005621f11352f2 R11: 0000000000000206 R12: 0000000000000000 R13: 0000000000000000 R14: 00005621f128b958 R15: 0000000080000000 Kernel Offset: disabled ---[ end Kernel panic - not syncing: softlockup: hung tasks ]---
All of these lockup reports have the call chain btrfs_clone_files() -> btrfs_clone() in common. btrfs_clone_files() calls btrfs_clone() with both source and destination extents locked and loops over the source extent to create the clones.
Conditionally reschedule in the btrfs_clone() loop, to give some time back to other processes.
--- fs/btrfs/reflink.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/reflink.c +2 -0
@@ -520,6 +520,8 @@ process_slot: ret = -EINTR ; goto out; } + +cond_resched (); } ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 233/391 btrfs: skip devices without magic signature when mounting
In reply to Greg Kroah-HartmanFrom: Anand Jain <[email protected]>
commit 96c2e067ed3e3e004580a643c76f58729206b829 upstream.
Many things can happen after the device is scanned and before the device is mounted. One such thing is losing the BTRFS_MAGIC on the device. If it happens we still won't free that device from the memory and cause the userland confusion.
For example: As the BTRFS_IOC_DEV_INFO still carries the device path which does not have the BTRFS_MAGIC, 'btrfs fi show' still lists device which does not belong to the filesystem anymore:
$ mkfs.btrfs -fq -draid1 -mraid1 /dev/sda /dev/sdb $ wipefs -a /dev/sdb # /dev/sdb does not contain magic signature $ mount -o degraded /dev/sda /btrfs $ btrfs fi show -m Label: none uuid: 470ec6fb-646b-4464-b3cb-df1b26c527bd Total devices 2 FS bytes used 128.00KiB devid 1 size 3.00GiB used 571.19MiB path /dev/sda devid 2 size 3.00GiB used 571.19MiB path /dev/sdb
We need to distinguish the missing signature and invalid superblock, so add a specific error code ENODATA for that. This also fixes failure of fstest btrfs/198.
--- fs/btrfs/disk-io.c | 8 ++++++-- fs/btrfs/volumes.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-)
fs/btrfs/disk-io.c +6 -2
@@ -3482,8 +3482,12 @@ struct btrfs_super_block *btrfs_read_devreturn ERR_CAST (page); super =page_address (page); -if (btrfs_super_bytenr (super) != bytenr || -btrfs_super_magic (super) !=BTRFS_MAGIC ) { +if (btrfs_super_magic (super) !=BTRFS_MAGIC ) { +btrfs_release_disk_super (super); +return ERR_PTR (-ENODATA ); + } + +if (btrfs_super_bytenr (super) != bytenr) {btrfs_release_disk_super (super);return ERR_PTR (-EINVAL ); }
fs/btrfs/volumes.c +12 -6
@@ -1200,17 +1200,23 @@ static int open_fs_devices(struct btrfs_ {struct btrfs_device *device;struct btrfs_device *latest_dev =NULL ; +struct btrfs_device *tmp_device; flags |=FMODE_EXCL ; -list_for_each_entry (device, &fs_devices->devices, dev_list) { -/* Just open everything we can; ignore failures here */ -if (btrfs_open_one_device (fs_devices, device, flags, holder)) -continue ; +list_for_each_entry_safe (device, tmp_device, &fs_devices->devices, + dev_list) { +int ret; -if (!latest_dev || - device->generation > latest_dev->generation) + ret =btrfs_open_one_device (fs_devices, device, flags, holder); +if (ret ==0 && + (!latest_dev || device->generation > latest_dev->generation)) { latest_dev = device; + }else if (ret == -ENODATA ) { + fs_devices->num_devices--; +list_del (&device->dev_list); +btrfs_free_device (device); + } }if (fs_devices->open_devices ==0 )return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 232/391 btrfs: cleanup cow block on error
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 572c83acdcdafeb04e70aa46be1fa539310be20c upstream.
In fstest btrfs/064 a transaction abort in __btrfs_cow_block could lead to a system lockup. It gets stuck trying to write back inodes, and the write back thread was trying to lock an extent buffer:
$ cat /proc/2143497/stack [<0>] __btrfs_tree_lock+0x108/0x250 [<0>] lock_extent_buffer_for_io+0x35e/0x3a0 [<0>] btree_write_cache_pages+0x15a/0x3b0 [<0>] do_writepages+0x28/0xb0 [<0>] __writeback_single_inode+0x54/0x5c0 [<0>] writeback_sb_inodes+0x1e8/0x510 [<0>] wb_writeback+0xcc/0x440 [<0>] wb_workfn+0xd7/0x650 [<0>] process_one_work+0x236/0x560 [<0>] worker_thread+0x55/0x3c0 [<0>] kthread+0x13a/0x150 [<0>] ret_from_fork+0x1f/0x30
This is because we got an error while COWing a block, specifically here
if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) {
ret = btrfs_reloc_cow_block(trans, root, buf, cow);
if (ret) {
btrfs_abort_transaction(trans, ret);
return ret;
}
}[16402.241552] BTRFS: Transaction aborted (error -2) [16402.242362] WARNING: CPU: 1 PID: 2563188 at fs/btrfs/ctree.c:1074 __btrfs_cow_block+0x376/0x540 [16402.249469] CPU: 1 PID: 2563188 Comm: fsstress Not tainted 5.9.0-rc6+ #8 [16402.249936] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 [16402.250525] RIP: 0010:__btrfs_cow_block+0x376/0x540 [16402.252417] RSP: 0018:ffff9cca40e578b0 EFLAGS: 00010282 [16402.252787] RAX: 0000000000000025 RBX: 0000000000000002 RCX: ffff9132bbd19388 [16402.253278] RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff9132bbd19380 [16402.254063] RBP: ffff9132b41a49c0 R08: 0000000000000000 R09: 0000000000000000 [16402.254887] R10: 0000000000000000 R11: ffff91324758b080 R12: ffff91326ef17ce0 [16402.255694] R13: ffff91325fc0f000 R14: ffff91326ef176b0 R15: ffff9132815e2000 [16402.256321] FS: 00007f542c6d7b80(0000) GS:ffff9132bbd00000(0000) knlGS:0000000000000000 [16402.256973] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [16402.257374] CR2: 00007f127b83f250 CR3: 0000000133480002 CR4: 0000000000370ee0 [16402.257867] Call Trace: [16402.258072] btrfs_cow_block+0x109/0x230 [16402.258356] btrfs_search_slot+0x530/0x9d0 [16402.258655] btrfs_lookup_file_extent+0x37/0x40 [16402.259155] __btrfs_drop_extents+0x13c/0xd60 [16402.259628] ? btrfs_block_rsv_migrate+0x4f/0xb0 [16402.259949] btrfs_replace_file_extents+0x190/0x820 [16402.260873] btrfs_clone+0x9ae/0xc00 [16402.261139] btrfs_extent_same_range+0x66/0x90 [16402.261771] btrfs_remap_file_range+0x353/0x3b1 [16402.262333] vfs_dedupe_file_range_one.part.0+0xd5/0x140 [16402.262821] vfs_dedupe_file_range+0x189/0x220 [16402.263150] do_vfs_ioctl+0x552/0x700 [16402.263662] __x64_sys_ioctl+0x62/0xb0 [16402.264023] do_syscall_64+0x33/0x40 [16402.264364] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [16402.264862] RIP: 0033:0x7f542c7d15cb [16402.266901] RSP: 002b:00007ffd35944ea8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [16402.267627] RAX: ffffffffffffffda RBX: 00000000009d1968 RCX: 00007f542c7d15cb [16402.268298] RDX: 00000000009d2490 RSI: 00000000c0189436 RDI: 0000000000000003 [16402.268958] RBP: 00000000009d2520 R08: 0000000000000036 R09: 00000000009d2e64 [16402.269726] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002 [16402.270659] R13: 000000000001f000 R14: 00000000009d1970 R15: 00000000009d2e80 [16402.271498] irq event stamp: 0 [16402.271846] hardirqs last enabled at (0): [<0000000000000000>] 0x0 [16402.272497] hardirqs last disabled at (0): [<ffffffff910dbf59>] copy_process+0x6b9/0x1ba0 [16402.273343] softirqs last enabled at (0): [<ffffffff910dbf59>] copy_process+0x6b9/0x1ba0 [16402.273905] softirqs last disabled at (0): [<0000000000000000>] 0x0 [16402.274338] ---[ end trace 737874a5a41a8236 ]--- [16402.274669] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry [16402.276179] BTRFS info (device dm-9): forced readonly [16402.277046] BTRFS: error (device dm-9) in btrfs_replace_file_extents:2723: errno=-2 No such entry [16402.278744] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry [16402.279968] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry [16402.280582] BTRFS info (device dm-9): balance: ended with status: -30
The problem here is that as soon as we allocate the new block it is locked and marked dirty in the btree inode. This means that we could attempt to writeback this block and need to lock the extent buffer. However we're not unlocking it here and thus we deadlock.
Fix this by unlocking the cow block if we have any errors inside of __btrfs_cow_block, and also free it so we do not leak it.
--- fs/btrfs/ctree.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/ctree.c +6 -0
@@ -1061,6 +1061,8 @@ static noinline int __btrfs_cow_block(st ret =update_ref_for_cow (trans, root, buf, cow, &last_ref);if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow);btrfs_abort_transaction (trans, ret);return ret; }
@@ -1068,6 +1070,8 @@ static noinline int __btrfs_cow_block(stif (test_bit (BTRFS_ROOT_SHAREABLE , &root->state)) { ret =btrfs_reloc_cow_block (trans, root, buf, cow);if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow);btrfs_abort_transaction (trans, ret);return ret; }
@@ -1100,6 +1104,8 @@ static noinline int __btrfs_cow_block(stif (last_ref) { ret =tree_mod_log_free_eb (buf);if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 234/391 btrfs: tree-checker: validate number of chunk stripes and parity
In reply to Greg Kroah-HartmanFrom: Daniel Xu <[email protected]>
commit 85d07fbe09efd1c529ff3e025e2f0d2c6c96a1b7 upstream.
If there's no parity and num_stripes < ncopies, a crafted image can trigger a division by zero in calc_stripe_length().
The image was generated through fuzzing.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209587
--- fs/btrfs/tree-checker.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/btrfs/tree-checker.c +18 -0
@@ -760,18 +760,36 @@ int btrfs_check_chunk_valid(struct extenu64 type;u64 features;bool mixed = false; +int raid_index; +int nparity; +int ncopies; length =btrfs_chunk_length (leaf, chunk); stripe_len =btrfs_chunk_stripe_len (leaf, chunk); num_stripes =btrfs_chunk_num_stripes (leaf, chunk); sub_stripes =btrfs_chunk_sub_stripes (leaf, chunk); type =btrfs_chunk_type (leaf, chunk); + raid_index =btrfs_bg_flags_to_raid_index (type); + ncopies = btrfs_raid_array[raid_index].ncopies; + nparity = btrfs_raid_array[raid_index].nparity;if (!num_stripes) {chunk_err (leaf, chunk, logical,"invalid chunk num_stripes, have %u" , num_stripes);return -EUCLEAN ; } +if (num_stripes < ncopies) { +chunk_err (leaf, chunk, logical, +"invalid chunk num_stripes < ncopies, have %u < %d" , + num_stripes, ncopies); +return -EUCLEAN ; + } +if (nparity && num_stripes == nparity) { +chunk_err (leaf, chunk, logical, +"invalid chunk num_stripes == nparity, have %u == %d" , + num_stripes, nparity); +return -EUCLEAN ; + }if (!IS_ALIGNED (logical, fs_info->sectorsize)) { chunk_err(leaf, chunk, logical, "invalid chunk logical, have %llu should aligned to %u",
Greg Kroah-Hartman
maintainerPATCH 235/391 btrfs: fix use-after-free on readahead extent after failure to create it
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 83bc1560e02e25c6439341352024ebe8488f4fbd upstream.
If we fail to find suitable zones for a new readahead extent, we end up leaving a stale pointer in the global readahead extents radix tree (fs_info->reada_tree), which can trigger the following trace later on:
[13367.696354] BUG: kernel NULL pointer dereference, address: 00000000000000b0 [13367.696802] #PF: supervisor read access in kernel mode [13367.697249] #PF: error_code(0x0000) - not-present page [13367.697721] PGD 0 P4D 0 [13367.698171] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI [13367.698632] CPU: 6 PID: 851214 Comm: btrfs Tainted: G W 5.9.0-rc6-btrfs-next-69 #1 [13367.699100] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [13367.700069] RIP: 0010:__lock_acquire+0x20a/0x3970 [13367.700562] Code: ff 1f 0f b7 c0 48 0f (...) [13367.701609] RSP: 0018:ffffb14448f57790 EFLAGS: 00010046 [13367.702140] RAX: 0000000000000000 RBX: 29b935140c15e8cf RCX: 0000000000000000 [13367.702698] RDX: 0000000000000002 RSI: ffffffffb3d66bd0 RDI: 0000000000000046 [13367.703240] RBP: ffff8a52ba8ac040 R08: 00000c2866ad9288 R09: 0000000000000001 [13367.703783] R10: 0000000000000001 R11: 00000000b66d9b53 R12: ffff8a52ba8ac9b0 [13367.704330] R13: 0000000000000000 R14: ffff8a532b6333e8 R15: 0000000000000000 [13367.704880] FS: 00007fe1df6b5700(0000) GS:ffff8a5376600000(0000) knlGS:0000000000000000 [13367.705438] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [13367.705995] CR2: 00000000000000b0 CR3: 000000022cca8004 CR4: 00000000003706e0 [13367.706565] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [13367.707127] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [13367.707686] Call Trace: [13367.708246] ? ___slab_alloc+0x395/0x740 [13367.708820] ? reada_add_block+0xae/0xee0 [btrfs] [13367.709383] lock_acquire+0xb1/0x480 [13367.709955] ? reada_add_block+0xe0/0xee0 [btrfs] [13367.710537] ? reada_add_block+0xae/0xee0 [btrfs] [13367.711097] ? rcu_read_lock_sched_held+0x5d/0x90 [13367.711659] ? kmem_cache_alloc_trace+0x8d2/0x990 [13367.712221] ? lock_acquired+0x33b/0x470 [13367.712784] _raw_spin_lock+0x34/0x80 [13367.713356] ? reada_add_block+0xe0/0xee0 [btrfs] [13367.713966] reada_add_block+0xe0/0xee0 [btrfs] [13367.714529] ? btrfs_root_node+0x15/0x1f0 [btrfs] [13367.715077] btrfs_reada_add+0x117/0x170 [btrfs] [13367.715620] scrub_stripe+0x21e/0x10d0 [btrfs] [13367.716141] ? kvm_sched_clock_read+0x5/0x10 [13367.716657] ? __lock_acquire+0x41e/0x3970 [13367.717184] ? scrub_chunk+0x60/0x140 [btrfs] [13367.717697] ? find_held_lock+0x32/0x90 [13367.718254] ? scrub_chunk+0x60/0x140 [btrfs] [13367.718773] ? lock_acquired+0x33b/0x470 [13367.719278] ? scrub_chunk+0xcd/0x140 [btrfs] [13367.719786] scrub_chunk+0xcd/0x140 [btrfs] [13367.720291] scrub_enumerate_chunks+0x270/0x5c0 [btrfs] [13367.720787] ? finish_wait+0x90/0x90 [13367.721281] btrfs_scrub_dev+0x1ee/0x620 [btrfs] [13367.721762] ? rcu_read_lock_any_held+0x8e/0xb0 [13367.722235] ? preempt_count_add+0x49/0xa0 [13367.722710] ? __sb_start_write+0x19b/0x290 [13367.723192] btrfs_ioctl+0x7f5/0x36f0 [btrfs] [13367.723660] ? __fget_files+0x101/0x1d0 [13367.724118] ? find_held_lock+0x32/0x90 [13367.724559] ? __fget_files+0x101/0x1d0 [13367.724982] ? __x64_sys_ioctl+0x83/0xb0 [13367.725399] __x64_sys_ioctl+0x83/0xb0 [13367.725802] do_syscall_64+0x33/0x80 [13367.726188] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [13367.726574] RIP: 0033:0x7fe1df7add87 [13367.726948] Code: 00 00 00 48 8b 05 09 91 (...) [13367.727763] RSP: 002b:00007fe1df6b4d48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [13367.728179] RAX: ffffffffffffffda RBX: 000055ce1fb596a0 RCX: 00007fe1df7add87 [13367.728604] RDX: 000055ce1fb596a0 RSI: 00000000c400941b RDI: 0000000000000003 [13367.729021] RBP: 0000000000000000 R08: 00007fe1df6b5700 R09: 0000000000000000 [13367.729431] R10: 00007fe1df6b5700 R11: 0000000000000246 R12: 00007ffd922b07de [13367.729842] R13: 00007ffd922b07df R14: 00007fe1df6b4e40 R15: 0000000000802000 [13367.730275] Modules linked in: btrfs blake2b_generic xor (...) [13367.732638] CR2: 00000000000000b0 [13367.733166] ---[ end trace d298b6805556acd9 ]---
What happens is the following:
1) At reada_find_extent() we don't find any existing readahead extent for the metadata extent starting at logical address X;
2) So we proceed to create a new one. We then call btrfs_map_block() to get information about which stripes contain extent X;
3) After that we iterate over the stripes and create only one zone for the readahead extent - only one because reada_find_zone() returned NULL for all iterations except for one, either because a memory allocation failed or it couldn't find the block group of the extent (it may have just been deleted);
4) We then add the new readahead extent to the readahead extents radix tree at fs_info->reada_tree;
5) Then we iterate over each zone of the new readahead extent, and find that the device used for that zone no longer exists, because it was removed or it was the source device of a device replace operation. Since this left 'have_zone' set to 0, after finishing the loop we jump to the 'error' label, call kfree() on the new readahead extent and return without removing it from the radix tree at fs_info->reada_tree;
6) Any future call to reada_find_extent() for the logical address X will find the stale pointer in the readahead extents radix tree, increment its reference counter, which can trigger the use-after-free right away or return it to the caller reada_add_block() that results in the use-after-free of the example trace above.
So fix this by making sure we delete the readahead extent from the radix tree if we fail to setup zones for it (when 'have_zone = 0').
--- fs/btrfs/reada.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/reada.c +2 -0
@@ -445,6 +445,8 @@ static struct reada_extent *reada_find_e } have_zone =1 ; } +if (!have_zone) +radix_tree_delete (&fs_info->reada_tree, index);spin_unlock (&fs_info->reada_lock);up_read (&fs_info->dev_replace.rwsem);
Greg Kroah-Hartman
maintainerPATCH 221/391 btrfs: qgroup: fix wrong qgroup metadata reserve for delayed inode
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit b4c5d8fdfff3e2b6c4fa4a5043e8946dff500f8c upstream.
For delayed inode facility, qgroup metadata is reserved for it, and later freed.
However we're freeing more bytes than we reserved. In btrfs_delayed_inode_reserve_metadata():
num_bytes = btrfs_calc_metadata_size(fs_info, 1);
...
ret = btrfs_qgroup_reserve_meta_prealloc(root,
fs_info->nodesize, true);
...
if (!ret) {
node->bytes_reserved = num_bytes;But in btrfs_delayed_inode_release_metadata():
if (qgroup_free) btrfs_qgroup_free_meta_prealloc(node->root, node->bytes_reserved); else btrfs_qgroup_convert_reserved_meta(node->root, node->bytes_reserved);
This means, we're always releasing more qgroup metadata rsv than we have reserved.
This won't trigger selftest warning, as btrfs qgroup metadata rsv has extra protection against cases like quota enabled half-way.
But we still need to fix this problem any way.
This patch will use the same num_bytes for qgroup metadata rsv so we could handle it correctly.
--- fs/btrfs/delayed-inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/delayed-inode.c +1 -2
@@ -627,8 +627,7 @@ static int btrfs_delayed_inode_reserve_m*/ if (!src_rsv || (!trans->bytes_reserved && src_rsv->type !=BTRFS_BLOCK_RSV_DELALLOC )) { - ret =btrfs_qgroup_reserve_meta_prealloc (root, - fs_info->nodesize, true); + ret =btrfs_qgroup_reserve_meta_prealloc (root, num_bytes, true);if (ret <0 )return ret; ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes,
Greg Kroah-Hartman
maintainerPATCH 240/391 usb: dwc3: ep0: Fix ZLP for OUT ep0 requests
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit 66706077dc89c66a4777a4c6298273816afb848c upstream.
The current ZLP handling for ep0 requests is only for control IN requests. For OUT direction, DWC3 needs to check and setup for MPS alignment.
Usually, control OUT requests can indicate its transfer size via the wLength field of the control message. So usb_request->zero is usually not needed for OUT direction. To handle ZLP OUT for control endpoint, make sure the TRB is MPS size.
--- drivers/usb/dwc3/ep0.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/ep0.c +9 -2
@@ -942,12 +942,16 @@ static void dwc3_ep0_xfer_complete(strucstatic void __dwc3_ep0_do_control_data (struct dwc3 *dwc,struct dwc3_ep *dep,struct dwc3_request *req) { +unsigned int trb_length =0 ;int ret; req->direction = !!dep->number;if (req->request.length ==0 ) { -dwc3_ep0_prepare_one_trb (dep, dwc->ep0_trb_addr,0 , +if (!req->direction) + trb_length = dep->endpoint.maxpacket; + +dwc3_ep0_prepare_one_trb (dep, dwc->bounce_addr, trb_length,DWC3_TRBCTL_CONTROL_DATA , false); ret =dwc3_ep0_start_trans (dep); } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
@@ -994,9 +998,12 @@ static void __dwc3_ep0_do_control_data(s req->trb = &dwc->ep0_trb[dep->trb_enqueue -1 ]; +if (!req->direction) + trb_length = dep->endpoint.maxpacket; +/* Now prepare one extra TRB to align transfer size */ dwc3_ep0_prepare_one_trb (dep, dwc->bounce_addr, -0 ,DWC3_TRBCTL_CONTROL_DATA , + trb_length,DWC3_TRBCTL_CONTROL_DATA , false); ret =dwc3_ep0_start_trans (dep); }else {
Greg Kroah-Hartman
maintainerPATCH 241/391 usb: dwc3: gadget: Check MPS of the request length
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit ca3df3468eec87f6374662f7de425bc44c3810c1 upstream.
When preparing for SG, not all the entries are prepared at once. When resume, don't use the remaining request length to calculate for MPS alignment. Use the entire request->length to do that.
--- drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/gadget.c +2 -2
@@ -1095,6 +1095,8 @@ static void dwc3_prepare_one_trb_sg(strustruct scatterlist *s;int i;unsigned int length = req->request.length; +unsigned int maxp =usb_endpoint_maxp (dep->endpoint.desc); +unsigned int rem = length % maxp;unsigned int remaining = req->request.num_mapped_sgs - req->num_queued_sgs;
@@ -1106,8 +1108,6 @@ static void dwc3_prepare_one_trb_sg(stru length -=sg_dma_len (s);for_each_sg (sg, s, remaining, i) { -unsigned int maxp =usb_endpoint_maxp (dep->endpoint.desc); -unsigned int rem = length % maxp;unsigned int trb_length;unsigned chain = true;
Greg Kroah-Hartman
maintainerPATCH 242/391 usb: dwc3: gadget: Reclaim extra TRBs after request completion
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit 690e5c2dc29f8891fcfd30da67e0d5837c2c9df5 upstream.
An SG request may be partially completed (due to no available TRBs). Don't reclaim extra TRBs and clear the needs_extra_trb flag until the request is fully completed. Otherwise, the driver will reclaim the wrong TRB.
--- drivers/usb/dwc3/gadget.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/dwc3/gadget.c +5 -5
@@ -2732,6 +2732,11 @@ static int dwc3_gadget_ep_cleanup_comple ret =dwc3_gadget_ep_reclaim_trb_linear (dep, req, event, status); + req->request.actual = req->request.length - req->remaining; + +if (!dwc3_gadget_ep_request_completed (req)) + goto out; +if (req->needs_extra_trb) {unsigned int maxp =usb_endpoint_maxp (dep->endpoint.desc);
@@ -2747,11 +2752,6 @@ static int dwc3_gadget_ep_cleanup_comple req->needs_extra_trb = false; } - req->request.actual = req->request.length - req->remaining; - -if (!dwc3_gadget_ep_request_completed (req)) - goto out; -dwc3_gadget_giveback (dep, req, status); out:
Greg Kroah-Hartman
maintainerPATCH 243/391 usb: dwc3: core: add phy cleanup for probe error handling
In reply to Greg Kroah-HartmanFrom: Li Jun <[email protected]>
commit 03c1fd622f72c7624c81b64fdba4a567ae5ee9cb upstream.
Add the phy cleanup if dwc3 mode init fail, which is the missing part of de-init for dwc3 core init.
--- drivers/usb/dwc3/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/dwc3/core.c +11 -0
@@ -1564,6 +1564,17 @@ static int dwc3_probe(struct platform_de err5:dwc3_event_buffers_cleanup (dwc); + +usb_phy_shutdown (dwc->usb2_phy); +usb_phy_shutdown (dwc->usb3_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); + +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +phy_power_off (dwc->usb2_generic_phy); +phy_power_off (dwc->usb3_generic_phy); +dwc3_ulpi_exit (dwc); err4:
Greg Kroah-Hartman
maintainerPATCH 245/391 usb: dwc3: gadget: Resume pending requests after CLEAR_STALL
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit c503672abe1348f10f5a54a662336358c6e1a297 upstream.
The function driver may queue new requests right after halting the endpoint (i.e. queue new requests while the endpoint is stalled). There's no restriction preventing it from doing so. However, dwc3 currently drops those requests after CLEAR_STALL. The driver should only drop started requests. Keep the pending requests in the pending list to resume and process them after the host issues ClearFeature(Halt) to the endpoint.
--- drivers/usb/dwc3/gadget.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/usb/dwc3/gadget.c +14 -8
@@ -1628,8 +1628,13 @@ static int __dwc3_gadget_ep_queue(structif (dep->flags &DWC3_EP_WAIT_TRANSFER_COMPLETE )return 0 ; -/* Start the transfer only after the END_TRANSFER is completed */ -if (dep->flags &DWC3_EP_END_TRANSFER_PENDING ) { +/* +* Start the transfer only after the END_TRANSFER is completed +* and endpoint STALL is cleared. +*/ +if ((dep->flags &DWC3_EP_END_TRANSFER_PENDING ) || + (dep->flags &DWC3_EP_WEDGE ) || + (dep->flags &DWC3_EP_STALL )) { dep->flags |=DWC3_EP_DELAY_START ;return 0 ; }
@@ -1836,13 +1841,14 @@ int __dwc3_gadget_ep_set_halt(struct dwclist_for_each_entry_safe (req, tmp, &dep->started_list, list)dwc3_gadget_move_cancelled_request (req); -list_for_each_entry_safe (req, tmp, &dep->pending_list, list) -dwc3_gadget_move_cancelled_request (req); - -if (!(dep->flags &DWC3_EP_END_TRANSFER_PENDING )) { - dep->flags &= ~DWC3_EP_DELAY_START ; +if (!(dep->flags &DWC3_EP_END_TRANSFER_PENDING ))dwc3_gadget_ep_cleanup_cancelled_requests (dep); - } + +if ((dep->flags &DWC3_EP_DELAY_START ) && + !usb_endpoint_xfer_isoc (dep->endpoint.desc)) +__dwc3_gadget_kick_transfer (dep); + + dep->flags &= ~DWC3_EP_DELAY_START ; }return ret;
Greg Kroah-Hartman
maintainerPATCH 246/391 usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit d97c78a1908e59a1fdbcbece87cd0440b5d7a1f2 upstream.
According the programming guide (for all DWC3 IPs), when the driver handles ClearFeature(halt) request, it should issue CLEAR_STALL command _after_ the END_TRANSFER command completes. The END_TRANSFER command may take some time to complete. So, delay the ClearFeature(halt) request control status stage and wait for END_TRANSFER command completion interrupt. Only after END_TRANSFER command completes that the driver may issue CLEAR_STALL command.
--- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/ep0.c | 16 ++++++++++++++++ drivers/usb/dwc3/gadget.c | 40 ++++++++++++++++++++++++++++++++-------- drivers/usb/dwc3/gadget.h | 1 + 4 files changed, 50 insertions(+), 8 deletions(-)
drivers/usb/dwc3/core.h +1 -0
@@ -710,6 +710,7 @@ struct dwc3_ep {#define DWC3_EP_IGNORE_NEXT_NOSTREAM BIT(8)#define DWC3_EP_FORCE_RESTART_STREAM BIT(9)#define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) +#define DWC3_EP_PENDING_CLEAR_STALL BIT(11)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
drivers/usb/dwc3/ep0.c +16 -0
@@ -524,6 +524,11 @@ static int dwc3_ep0_handle_endpoint(stru ret =__dwc3_gadget_ep_set_halt (dep, set, true);if (ret)return -EINVAL ; + +/* ClearFeature(Halt) may need delayed status */ +if (!set && (dep->flags &DWC3_EP_END_TRANSFER_PENDING )) +return USB_GADGET_DELAYED_STATUS ; +break ;default :return -EINVAL ;
@@ -1049,6 +1054,17 @@ static void dwc3_ep0_do_control_status(s__dwc3_ep0_do_control_status (dwc, dep); } +void dwc3_ep0_send_delayed_status (struct dwc3 *dwc) +{ +unsigned int direction = !dwc->ep0_expect_in; + +if (dwc->ep0state !=EP0_STATUS_PHASE ) +return ; + + dwc->delayed_status = false; +__dwc3_ep0_do_control_status (dwc, dwc->eps[direction]); +} +static void dwc3_ep0_end_control_data (struct dwc3 *dwc,struct dwc3_ep *dep) {struct dwc3_gadget_ep_cmd_params params;
drivers/usb/dwc3/gadget.c +32 -8
@@ -1827,6 +1827,18 @@ int __dwc3_gadget_ep_set_halt(struct dwcreturn 0 ; } +dwc3_stop_active_transfer (dep, true, true); + +list_for_each_entry_safe (req, tmp, &dep->started_list, list) +dwc3_gadget_move_cancelled_request (req); + +if (dep->flags &DWC3_EP_END_TRANSFER_PENDING ) { + dep->flags |=DWC3_EP_PENDING_CLEAR_STALL ; +return 0 ; + } + +dwc3_gadget_ep_cleanup_cancelled_requests (dep); + ret =dwc3_send_clear_stall_ep_cmd (dep);if (ret) { dev_err(dwc->dev, "failed to clear STALL on %s\n",
@@ -1836,14 +1848,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc dep->flags &= ~(DWC3_EP_STALL |DWC3_EP_WEDGE ); -dwc3_stop_active_transfer (dep, true, true); - -list_for_each_entry_safe (req, tmp, &dep->started_list, list) -dwc3_gadget_move_cancelled_request (req); - -if (!(dep->flags &DWC3_EP_END_TRANSFER_PENDING )) -dwc3_gadget_ep_cleanup_cancelled_requests (dep); -if ((dep->flags &DWC3_EP_DELAY_START ) && !usb_endpoint_xfer_isoc (dep->endpoint.desc))__dwc3_gadget_kick_transfer (dep);
@@ -3003,6 +3007,26 @@ static void dwc3_endpoint_interrupt(stru dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING ; dep->flags &= ~DWC3_EP_TRANSFER_STARTED ;dwc3_gadget_ep_cleanup_cancelled_requests (dep); + +if (dep->flags &DWC3_EP_PENDING_CLEAR_STALL ) { +struct dwc3 *dwc = dep->dwc; + + dep->flags &= ~DWC3_EP_PENDING_CLEAR_STALL ; +if (dwc3_send_clear_stall_ep_cmd (dep)) { +struct usb_ep *ep0 = &dwc->eps[0 ]->endpoint; + +dev_err (dwc->dev,"failed to clear STALL on %s\n" , + dep->name); +if (dwc->delayed_status) +__dwc3_gadget_ep0_set_halt (ep0,1 ); +return ; + } + + dep->flags &= ~(DWC3_EP_STALL |DWC3_EP_WEDGE ); +if (dwc->delayed_status) +dwc3_ep0_send_delayed_status (dwc); + } +if ((dep->flags &DWC3_EP_DELAY_START ) && !usb_endpoint_xfer_isoc (dep->endpoint.desc))__dwc3_gadget_kick_transfer (dep);
drivers/usb/dwc3/gadget.h +1 -0
@@ -113,6 +113,7 @@ int dwc3_gadget_ep0_set_halt(struct usb_int dwc3_gadget_ep0_queue (struct usb_ep *ep,struct usb_request *request,gfp_t gfp_flags);int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol); +void dwc3_ep0_send_delayed_status (struct dwc3 *dwc);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
Greg Kroah-Hartman
maintainerPATCH 248/391 usb: cdc-acm: fix cooldown mechanism
In reply to Greg Kroah-HartmanFrom: Jerome Brunet <[email protected]>
commit 38203b8385bf6283537162bde7d499f830964711 upstream.
Commit a4e7279cd1d1 ("cdc-acm: introduce a cool down") is causing regression if there is some USB error, such as -EPROTO.
This has been reported on some samples of the Odroid-N2 using the Combee II Zibgee USB dongle.
Quoted 1 line
struct acm *acm =
container_of(work, struct acm, work)
is incorrect in case of a delayed work and causes warnings, usually from the workqueue:
Quoted 1 line
WARNING: CPU: 0 PID: 0 at kernel/workqueue.c:1474 __queue_work+0x480/0x528.
When this happens, USB eventually stops working completely after a while. Also the ACM_ERROR_DELAY bit is never set, so the cooldown mechanism previously introduced cannot be triggered and acm_submit_read_urb() is never called.
This changes makes the cdc-acm driver use a single delayed work, fixing the pointer arithmetic in acm_softint() and set the ACM_ERROR_DELAY when the cooldown mechanism appear to be needed.
--- drivers/usb/class/cdc-acm.c | 12 +++++------- drivers/usb/class/cdc-acm.h | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/usb/class/cdc-acm.c +5 -7
@@ -507,6 +507,7 @@ static void acm_read_bulk_callback(struc "%s - cooling babbling device\n", __func__);usb_mark_last_busy (acm->dev);set_bit (rb->index, &acm->urbs_in_error_delay); +set_bit (ACM_ERROR_DELAY , &acm->flags); cooldown = true;break ;default :
@@ -532,7 +533,7 @@ static void acm_read_bulk_callback(strucif (stopped || stalled || cooldown) {if (stalled) -schedule_work (&acm->work); +schedule_delayed_work (&acm->dwork,0 );else if (cooldown)schedule_delayed_work (&acm->dwork,HZ /2 );return ;
@@ -562,13 +563,13 @@ static void acm_write_bulk(struct urb *uacm_write_done (acm, wb);spin_unlock_irqrestore (&acm->write_lock, flags);set_bit (EVENT_TTY_WAKEUP , &acm->flags); -schedule_work (&acm->work); +schedule_delayed_work (&acm->dwork,0 ); }static void acm_softint (struct work_struct *work) {int i; - struct acm *acm = container_of(work, struct acm, work); + struct acm *acm = container_of(work, struct acm, dwork.work);if (test_bit (EVENT_RX_STALL , &acm->flags)) {smp_mb ();/* against acm_suspend() */
@@ -584,7 +585,7 @@ static void acm_softint(struct work_struif (test_and_clear_bit (ACM_ERROR_DELAY , &acm->flags)) {for (i =0 ; i < acm->rx_buflimit; i++)if (test_and_clear_bit (i, &acm->urbs_in_error_delay)) -acm_submit_read_urb (acm, i,GFP_NOIO ); +acm_submit_read_urb (acm, i,GFP_KERNEL ); }if (test_and_clear_bit (EVENT_TTY_WAKEUP , &acm->flags))
@@ -1364,7 +1365,6 @@ made_compressed_probe: acm->ctrlsize = ctrlsize; acm->readsize = readsize; acm->rx_buflimit = num_rx_buf; -INIT_WORK (&acm->work, acm_softint);INIT_DELAYED_WORK (&acm->dwork, acm_softint);init_waitqueue_head (&acm->wioctl);spin_lock_init (&acm->write_lock);
@@ -1574,7 +1574,6 @@ static void acm_disconnect(struct usb_in }acm_kill_urbs (acm); -cancel_work_sync (&acm->work);cancel_delayed_work_sync (&acm->dwork);tty_unregister_device (acm_tty_driver, acm->minor);
@@ -1617,7 +1616,6 @@ static int acm_suspend(struct usb_interfreturn 0 ;acm_kill_urbs (acm); -cancel_work_sync (&acm->work);cancel_delayed_work_sync (&acm->dwork); acm->urbs_in_error_delay =0 ;
drivers/usb/class/cdc-acm.h +1 -2
@@ -112,8 +112,7 @@ struct acm {# define ACM_ERROR_DELAY 3unsigned long urbs_in_error_delay;/* these need to be restarted after a delay */ struct usb_cdc_line_coding line;/* bits, stop, parity */ -struct work_struct work;/* work queue entry for various purposes*/ -struct delayed_work dwork;/* for cool downs needed in error recovery */ +struct delayed_work dwork;/* work queue entry for various purposes */ unsigned int ctrlin;/* input control lines (DCD, DSR, RI, break, overruns) */ unsigned int ctrlout;/* output control lines (DTR, RTS) */ struct async_icount iocount;/* counters for control line changes */
Greg Kroah-Hartman
maintainerPATCH 249/391 usb: typec: tcpm: reset hard_reset_count for any disconnect
In reply to Greg Kroah-HartmanFrom: Li Jun <[email protected]>
commit 2d9c6442a9c81f4f8dee678d0b3c183173ab1e2d upstream.
Current tcpm_detach() only reset hard_reset_count if port->attached is true, this may cause this counter clear is missed if the CC disconnect event is generated after tcpm_port_reset() is done by other events, e.g. VBUS off comes first before CC disconect for a power sink, in that case the first tcpm_detach() will only clear port->attached flag but leave hard_reset_count there because tcpm_port_is_disconnected() is still false, then later tcpm_detach() by CC disconnect will directly return due to port->attached is cleared, finally this will result tcpm will not try hard reset or error recovery for later attach.
ChiYuan reported this issue on his platform with below tcpm trace:
After power sink session setup after hard reset 2 times, detach from the power source and then attach:
[ 4848.046358] VBUS off [ 4848.046384] state change SNK_READY -> SNK_UNATTACHED [ 4848.050908] Setting voltage/current limit 0 mV 0 mA [ 4848.050936] polarity 0 [ 4848.052593] Requesting mux state 0, usb-role 0, orientation 0 [ 4848.053222] Start toggling [ 4848.086500] state change SNK_UNATTACHED -> TOGGLING [ 4848.089983] CC1: 0 -> 0, CC2: 3 -> 3 [state TOGGLING, polarity 0, connected] [ 4848.089993] state change TOGGLING -> SNK_ATTACH_WAIT [ 4848.090031] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms [ 4848.141162] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_ATTACH_WAIT, polarity 0, disconnected] [ 4848.141170] state change SNK_ATTACH_WAIT -> SNK_ATTACH_WAIT [ 4848.141184] pending state change SNK_ATTACH_WAIT -> SNK_UNATTACHED @20 ms [ 4848.163156] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [delayed 20 ms] [ 4848.163162] Start toggling [ 4848.216918] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [ 4848.216954] state change TOGGLING -> SNK_ATTACH_WAIT [ 4848.217080] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms [ 4848.231771] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_ATTACH_WAIT, polarity 0, disconnected] [ 4848.231800] state change SNK_ATTACH_WAIT -> SNK_ATTACH_WAIT [ 4848.231857] pending state change SNK_ATTACH_WAIT -> SNK_UNATTACHED @20 ms [ 4848.256022] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [delayed20 ms] [ 4848.256049] Start toggling [ 4848.871148] VBUS on [ 4848.885324] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [ 4848.885372] state change TOGGLING -> SNK_ATTACH_WAIT [ 4848.885548] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms [ 4849.088240] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed200 ms] [ 4849.088284] state change SNK_DEBOUNCED -> SNK_ATTACHED [ 4849.088291] polarity 1 [ 4849.088769] Requesting mux state 1, usb-role 2, orientation 2 [ 4849.088895] state change SNK_ATTACHED -> SNK_STARTUP [ 4849.088907] state change SNK_STARTUP -> SNK_DISCOVERY [ 4849.088915] Setting voltage/current limit 5000 mV 0 mA [ 4849.088927] vbus=0 charge:=1 [ 4849.090505] state change SNK_DISCOVERY -> SNK_WAIT_CAPABILITIES [ 4849.090828] pending state change SNK_WAIT_CAPABILITIES -> SNK_READY @240 ms [ 4849.335878] state change SNK_WAIT_CAPABILITIES -> SNK_READY [delayed240 ms]
this patch fix this issue by clear hard_reset_count at any cases of cc disconnect, í.e. don't check port->attached flag.
--- drivers/usb/typec/tcpm/tcpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -3
@@ -2789,6 +2789,9 @@ static void tcpm_reset_port(struct tcpm_static void tcpm_detach (struct tcpm_port *port) { +if (tcpm_port_is_disconnected (port)) + port->hard_reset_count =0 ; +if (!port->attached)return ;
@@ -2797,9 +2800,6 @@ static void tcpm_detach(struct tcpm_port port->tcpc->set_bist_data (port->tcpc, false); } -if (tcpm_port_is_disconnected (port)) - port->hard_reset_count =0 ; -tcpm_reset_port (port); }
Greg Kroah-Hartman
maintainerPATCH 250/391 usb: host: fsl-mph-dr-of: check return of dma_set_mask()
In reply to Greg Kroah-HartmanFrom: Ran Wang <[email protected]>
commit 3cd54a618834430a26a648d880dd83d740f2ae30 upstream.
fsl_usb2_device_register() should stop init if dma_set_mask() return error.
--- drivers/usb/host/fsl-mph-dr-of.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/host/fsl-mph-dr-of.c +6 -3
@@ -94,10 +94,13 @@ static struct platform_device *fsl_usb2_ pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; -if (!pdev->dev.dma_mask) +if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask; -else -dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + }else { + retval =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto error; + } retval =platform_device_add_data (pdev, pdata,sizeof (*pdata));if (retval)
Greg Kroah-Hartman
maintainerPATCH 252/391 USB: apple-mfi-fastcharge: dont probe unhandled devices
In reply to Greg Kroah-HartmanFrom: Bastien Nocera <[email protected]>
commit 0cb686692fd200db12dcfb8231e793c1c98aec41 upstream.
From: Bastien Nocera <[email protected]>
Contrary to the comment above the id table, we didn't implement a match function. This meant that every single Apple device that was already plugged in to the computer would have its device driver reprobed when the apple-mfi-fastcharge driver was loaded, eg. the SD card reader could be reprobed when the apple-mfi-fastcharge after pivoting root during boot up and the module became available.
Make sure that the driver probe isn't being run for unsupported devices by adding a match function that checks the product ID, in addition to the id_table checking the vendor ID.
--- drivers/usb/misc/apple-mfi-fastcharge.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/usb/misc/apple-mfi-fastcharge.c +12 -5
@@ -163,17 +163,23 @@ static const struct power_supply_desc ap .property_is_writeable = apple_mfi_fc_property_is_writeable }; +static bool mfi_fc_match (struct usb_device *udev) +{ +int idProduct; + + idProduct =le16_to_cpu (udev->descriptor.idProduct); +/* See comment above mfi_fc_id_table[] */ +return (idProduct >=0x1200 && idProduct <=0x12ff ); +} +static int mfi_fc_probe (struct usb_device *udev) {struct power_supply_config battery_cfg = {};struct mfi_device *mfi =NULL ; -int err, idProduct; +int err; - idProduct =le16_to_cpu (udev->descriptor.idProduct); -/* See comment above mfi_fc_id_table[] */ -if (idProduct <0x1200 || idProduct >0x12ff ) { +if (!mfi_fc_match (udev))return -ENODEV ; - } mfi =kzalloc (sizeof (struct mfi_device ),GFP_KERNEL );if (!mfi) {
@@ -220,6 +226,7 @@ static struct usb_device_driver mfi_fc_d .probe = mfi_fc_probe, .disconnect = mfi_fc_disconnect, .id_table = mfi_fc_id_table, + .match = mfi_fc_match, .generic_subclass = 1, };
Greg Kroah-Hartman
maintainerPATCH 253/391 drm/i915: Force VTd workarounds when running as a guest OS
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit 8195400f7ea95399f721ad21f4d663a62c65036f upstream.
If i915.ko is being used as a passthrough device, it does not know if the host is using intel_iommu. Mixing the iommu and gfx causes a few issues (such as scanout overfetch) which we need to workaround inside the driver, so if we detect we are running under a hypervisor, also assume the device access is being virtualised.
--- drivers/gpu/drm/i915/i915_drv.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +5 -1
@@ -33,6 +33,8 @@#include <uapi/drm/i915_drm.h> #include <uapi/drm/drm_fourcc.h> +#include <asm/hypervisor.h> +#include <linux/io-mapping.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h>
@@ -1716,7 +1718,9 @@ static inline bool intel_vtd_active(voidif (intel_iommu_gfx_mapped)return true;#endif -return false; + +/* Running as a guest, we assume the host is enforcing VT'd */ +return !hypervisor_is_type (X86_HYPER_NATIVE ); }static inline bool intel_scanout_needs_vtd_wa (struct drm_i915_private *dev_priv)
Greg Kroah-Hartman
maintainerPATCH 254/391 vt: keyboard, simplify vt_kdgkbsent
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 6ca03f90527e499dd5e32d6522909e2ad390896b upstream.
Use 'strlen' of the string, add one for NUL terminator and simply do 'copy_to_user' instead of the explicit 'for' loop. This makes the KDGKBSENT case more compact.
The only thing we need to take care about is NULL 'func_table[i]'. Use an empty string in that case.
The original check for overflow could never trigger as the func_buf strings are always shorter or equal to 'struct kbsentry's.
--- drivers/tty/vt/keyboard.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/tty/vt/keyboard.c +9 -19
@@ -1995,9 +1995,7 @@ out:int vt_do_kdgkb_ioctl (int cmd,struct kbsentry __user *user_kdgkb,int perm) {struct kbsentry *kbs; -char *p;u_char *q; -u_char __user *up;int sz, fnw_sz;int delta;char *first_free, *fj, *fnw;
@@ -2023,23 +2021,15 @@ int vt_do_kdgkb_ioctl(int cmd, struct kb i =array_index_nospec (kbs->kb_func,MAX_NR_FUNC );switch (cmd) { -case KDGKBSENT : - sz =sizeof (kbs->kb_string) -1 ;/* sz should have been -a struct member */ - up = user_kdgkb->kb_string; - p = func_table[i]; -if (p) -for ( ; *p && sz; p++, sz--) -if (put_user (*p, up++)) { - ret = -EFAULT ; - goto reterr; - } -if (put_user ('\0' , up)) { - ret = -EFAULT ; - goto reterr; - } -kfree (kbs); -return ((p && *p) ? -EOVERFLOW :0 ); +case KDGKBSENT : { +/* size should have been a struct member */ +unsigned char *from = func_table[i] ? :"" ; + + ret =copy_to_user (user_kdgkb->kb_string, from, +strlen (from) +1 ) ? -EFAULT :0 ; + + goto reterr; + }case KDSKBSENT :if (!perm) { ret = -EPERM ;
Greg Kroah-Hartman
maintainerPATCH 256/391 vt_ioctl: fix GIO_UNIMAP regression
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit d54654790302ccaa72589380dce060d376ef8716 upstream.
In commit 5ba127878722, we shuffled with the check of 'perm'. But my brain somehow inverted the condition in 'do_unimap_ioctl' (I thought it is ||, not &&), so GIO_UNIMAP stopped working completely.
Move the 'perm' checks back to do_unimap_ioctl and do them right again. In fact, this reverts this part of code to the pre-5ba127878722 state. Except 'perm' is now a bool.
--- drivers/tty/vt/vt_ioctl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/tty/vt/vt_ioctl.c +5 -6
@@ -550,7 +550,7 @@ static int vt_io_fontreset(struct consol }static inline int do_unimap_ioctl (int cmd,struct unimapdesc __user *user_ud, -struct vc_data *vc) +bool perm,struct vc_data *vc) {struct unimapdesc tmp;
@@ -558,9 +558,11 @@ static inline int do_unimap_ioctl(int cmreturn -EFAULT ;switch (cmd) {case PIO_UNIMAP : +if (!perm) +return -EPERM ;return con_set_unimap (vc, tmp.entry_ct, tmp.entries);case GIO_UNIMAP : -if (fg_console != vc->vc_num) +if (!perm && fg_console != vc->vc_num)return -EPERM ;return con_get_unimap (vc, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
@@ -640,10 +642,7 @@ static int vt_io_ioctl(struct vc_data *vcase PIO_UNIMAP :case GIO_UNIMAP : -if (!perm) -return -EPERM ; - -return do_unimap_ioctl (cmd, up, vc); +return do_unimap_ioctl (cmd, up, perm, vc);default :return -ENOIOCTLCMD ;
Greg Kroah-Hartman
maintainerPATCH 223/391 btrfs: qgroup: fix qgroup meta rsv leak for subvolume operations
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit e85fde5162bf1b242cbd6daf7dba0f9b457d592b upstream.
[BUG]
When quota is enabled for TEST_DEV, generic/013 sometimes fails like this:
generic/013 14s ... _check_dmesg: something found in dmesg (see xfstests-dev/results//generic/013.dmesg)
And with the following metadata leak:
BTRFS warning (device dm-3): qgroup 0/1370 has unreleased space, type 2 rsv 49152
------------[ cut here ]------------ WARNING: CPU: 2 PID: 47912 at fs/btrfs/disk-io.c:4078 close_ctree+0x1dc/0x323 [btrfs] Call Trace: btrfs_put_super+0x15/0x17 [btrfs] generic_shutdown_super+0x72/0x110 kill_anon_super+0x18/0x30 btrfs_kill_super+0x17/0x30 [btrfs] deactivate_locked_super+0x3b/0xa0 deactivate_super+0x40/0x50 cleanup_mnt+0x135/0x190 __cleanup_mnt+0x12/0x20 task_work_run+0x64/0xb0 __prepare_exit_to_usermode+0x1bc/0x1c0 __syscall_return_slowpath+0x47/0x230 do_syscall_64+0x64/0xb0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ---[ end trace a6cfd45ba80e4e06 ]--- BTRFS error (device dm-3): qgroup reserved space leaked BTRFS info (device dm-3): disk space caching is enabled BTRFS info (device dm-3): has skinny extents
[CAUSE]
The qgroup preallocated meta rsv operations of that offending root are:
btrfs_delayed_inode_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=131072 btrfs_delayed_inode_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=131072 btrfs_subvolume_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=49152 btrfs_delayed_inode_release_metadata: convert_meta_prealloc root=1370 num_bytes=-131072 btrfs_delayed_inode_release_metadata: convert_meta_prealloc root=1370 num_bytes=-131072
It's pretty obvious that, we reserve qgroup meta rsv in btrfs_subvolume_reserve_metadata(), but doesn't have corresponding release/convert calls in btrfs_subvolume_release_metadata().
This leads to the leakage.
[FIX]
To fix this bug, we should follow what we're doing in btrfs_delalloc_reserve_metadata(), where we reserve qgroup space, and add it to block_rsv->qgroup_rsv_reserved.
And free the qgroup reserved metadata space when releasing the block_rsv.
To do this, we need to change the btrfs_subvolume_release_metadata() to accept btrfs_root, and record the qgroup_to_release number, and call btrfs_qgroup_convert_reserved_meta() for it.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 2 +- fs/btrfs/ioctl.c | 6 +++--- fs/btrfs/root-tree.c | 13 +++++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -2619,7 +2619,7 @@ enum btrfs_flush_state {int btrfs_subvolume_reserve_metadata (struct btrfs_root *root,struct btrfs_block_rsv *rsv,int nitems,bool use_global_rsv); -void btrfs_subvolume_release_metadata (struct btrfs_fs_info *fs_info, +void btrfs_subvolume_release_metadata (struct btrfs_root *root,struct btrfs_block_rsv *rsv);void btrfs_delalloc_release_extents (struct btrfs_inode *inode,u64 num_bytes);
fs/btrfs/inode.c +1 -1
@@ -4051,7 +4051,7 @@ out_end_trans: err = ret; inode->i_flags |=S_DEAD ; out_release: -btrfs_subvolume_release_metadata (fs_info, &block_rsv); +btrfs_subvolume_release_metadata (root, &block_rsv); out_up_write:up_write (&fs_info->subvol_sem);if (err) {
fs/btrfs/ioctl.c +3 -3
@@ -618,7 +618,7 @@ static noinline int create_subvol(struct trans =btrfs_start_transaction (root,0 );if (IS_ERR (trans)) { ret =PTR_ERR (trans); -btrfs_subvolume_release_metadata (fs_info, &block_rsv); +btrfs_subvolume_release_metadata (root, &block_rsv); goto fail_free; } trans->block_rsv = &block_rsv;
@@ -742,7 +742,7 @@ fail:kfree (root_item); trans->block_rsv =NULL ; trans->bytes_reserved =0 ; -btrfs_subvolume_release_metadata (fs_info, &block_rsv); +btrfs_subvolume_release_metadata (root, &block_rsv); err =btrfs_commit_transaction (trans);if (err && !ret)
@@ -856,7 +856,7 @@ fail:if (ret && pending_snapshot->snap) pending_snapshot->snap->anon_dev =0 ;btrfs_put_root (pending_snapshot->snap); -btrfs_subvolume_release_metadata (fs_info, &pending_snapshot->block_rsv); +btrfs_subvolume_release_metadata (root, &pending_snapshot->block_rsv); free_pending:if (pending_snapshot->anon_dev)free_anon_bdev (pending_snapshot->anon_dev);
fs/btrfs/root-tree.c +11 -2
@@ -512,11 +512,20 @@ int btrfs_subvolume_reserve_metadata(strif (ret && qgroup_num_bytes)btrfs_qgroup_free_meta_prealloc (root, qgroup_num_bytes); +if (!ret) { +spin_lock (&rsv->lock); + rsv->qgroup_rsv_reserved += qgroup_num_bytes; +spin_unlock (&rsv->lock); + }return ret; } -void btrfs_subvolume_release_metadata (struct btrfs_fs_info *fs_info, +void btrfs_subvolume_release_metadata (struct btrfs_root *root,struct btrfs_block_rsv *rsv) { -btrfs_block_rsv_release (fs_info, rsv, (u64)-1 ,NULL ); +struct btrfs_fs_info *fs_info = root->fs_info; +u64 qgroup_to_release; + +btrfs_block_rsv_release (fs_info, rsv, (u64)-1 , &qgroup_to_release); +btrfs_qgroup_convert_reserved_meta (root, qgroup_to_release); }
Greg Kroah-Hartman
maintainerPATCH 257/391 HID: wacom: Avoid entering wacom_wac_pen_report for pad / battery
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
commit d9216d753b2b1406b801243b12aaf00a5ce5b861 upstream.
It has recently been reported that the "heartbeat" report from devices like the 2nd-gen Intuos Pro (PTH-460, PTH-660, PTH-860) or the 2nd-gen Bluetooth-enabled Intuos tablets (CTL-4100WL, CTL-6100WL) can cause the driver to send a spurious BTN_TOUCH=0 once per second in the middle of drawing. This can result in broken lines while drawing on Chrome OS.
The source of the issue has been traced back to a change which modified the driver to only call wacom_wac_pad_report() once per report instead of once per collection. As part of this change, pad-handling code was removed from wacom_wac_collection() under the assumption that the WACOM_PEN_FIELD and WACOM_TOUCH_FIELD checks would not be satisfied when a pad or battery collection was being processed.
To be clear, the macros WACOM_PAD_FIELD and WACOM_PEN_FIELD do not currently check exclusive conditions. In fact, most "pad" fields will also appear to be "pen" fields simply due to their presence inside of a Digitizer application collection. Because of this, the removal of the check from wacom_wac_collection() just causes pad / battery collections to instead trigger a call to wacom_wac_pen_report() instead. The pen report function in turn resets the tip switch state just prior to exiting, resulting in the observed BTN_TOUCH=0 symptom.
To correct this, we restore a version of the WACOM_PAD_FIELD check in wacom_wac_collection() and return early. This effectively prevents pad / battery collections from being reported until the very end of the report as originally intended.
--- drivers/hid/wacom_wac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/wacom_wac.c +3 -1
@@ -2773,7 +2773,9 @@ static int wacom_wac_collection(struct hif (report->type !=HID_INPUT_REPORT )return -1 ; -if (WACOM_PEN_FIELD (field) && wacom->wacom_wac.pen_input) +if (WACOM_PAD_FIELD (field)) +return 0 ; +else if (WACOM_PEN_FIELD (field) && wacom->wacom_wac.pen_input)wacom_wac_pen_report (hdev, report);else if (WACOM_FINGER_FIELD (field) && wacom->wacom_wac.touch_input)wacom_wac_finger_report (hdev, report);
Greg Kroah-Hartman
maintainerPATCH 259/391 tty: serial: 21285: fix lockup on open
In reply to Greg Kroah-HartmanFrom: Russell King <[email protected]>
commit 82776f6c75a90e1d2103e689b84a689de8f1aa02 upstream.
Commit 293f89959483 ("tty: serial: 21285: stop using the unused[] variable from struct uart_port") introduced a bug which stops the transmit interrupt being disabled when there are no characters to transmit - disabling the transmit interrupt at the interrupt controller is the only way to stop an interrupt storm. If this interrupt is not disabled when there are no transmit characters, we end up with an interrupt storm which prevents the machine making forward progress.
--- drivers/tty/serial/21285.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/21285.c +6 -6
@@ -50,25 +50,25 @@ static const char serial21285_name[] = "static bool is_enabled (struct uart_port *port,int bit) { -unsigned long private_data = (unsigned long )port->private_data; +unsigned long *private_data = (unsigned long *)&port->private_data; -if (test_bit (bit, &private_data)) +if (test_bit (bit, private_data))return true;return false; }static void enable (struct uart_port *port,int bit) { -unsigned long private_data = (unsigned long )port->private_data; +unsigned long *private_data = (unsigned long *)&port->private_data; -set_bit (bit, &private_data); +set_bit (bit, private_data); }static void disable (struct uart_port *port,int bit) { -unsigned long private_data = (unsigned long )port->private_data; +unsigned long *private_data = (unsigned long *)&port->private_data; -clear_bit (bit, &private_data); +clear_bit (bit, private_data); }#define is_tx_enabled (port) is_enabled(port, tx_enabled_bit)
Greg Kroah-Hartman
maintainerPATCH 224/391 btrfs: sysfs: init devices outside of the chunk_mutex
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit ca10845a56856fff4de3804c85e6424d0f6d0cde upstream.
While running btrfs/061, btrfs/073, btrfs/078, or btrfs/178 we hit the following lockdep splat:
======================================================
WARNING: possible circular locking dependency detected
5.9.0-rc3+ #4 Not tainted
------------------------------------------------------
kswapd0/100 is trying to acquire lock:
ffff96ecc22ef4a0 (&delayed_node->mutex){+.+.}-{3:3}, at: __btrfs_release_delayed_node.part.0+0x3f/0x330
but task is already holding lock:
ffffffff8dd74700 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #3 (fs_reclaim){+.+.}-{0:0}:
fs_reclaim_acquire+0x65/0x80 slab_pre_alloc_hook.constprop.0+0x20/0x200 kmem_cache_alloc+0x37/0x270 alloc_inode+0x82/0xb0 iget_locked+0x10d/0x2c0 kernfs_get_inode+0x1b/0x130 kernfs_get_tree+0x136/0x240 sysfs_get_tree+0x16/0x40 vfs_get_tree+0x28/0xc0 path_mount+0x434/0xc00 __x64_sys_mount+0xe3/0x120 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xa9
-> #2 (kernfs_mutex){+.+.}-{3:3}:
__mutex_lock+0x7e/0x7e0 kernfs_add_one+0x23/0x150 kernfs_create_link+0x63/0xa0 sysfs_do_create_link_sd+0x5e/0xd0 btrfs_sysfs_add_devices_dir+0x81/0x130 btrfs_init_new_device+0x67f/0x1250 btrfs_ioctl+0x1ef/0x2e20 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xa9
-> #1 (&fs_info->chunk_mutex){+.+.}-{3:3}:
__mutex_lock+0x7e/0x7e0 btrfs_chunk_alloc+0x125/0x3a0 find_free_extent+0xdf6/0x1210 btrfs_reserve_extent+0xb3/0x1b0 btrfs_alloc_tree_block+0xb0/0x310 alloc_tree_block_no_bg_flush+0x4a/0x60 __btrfs_cow_block+0x11a/0x530 btrfs_cow_block+0x104/0x220 btrfs_search_slot+0x52e/0x9d0 btrfs_insert_empty_items+0x64/0xb0 btrfs_insert_delayed_items+0x90/0x4f0 btrfs_commit_inode_delayed_items+0x93/0x140 btrfs_log_inode+0x5de/0x2020 btrfs_log_inode_parent+0x429/0xc90 btrfs_log_new_name+0x95/0x9b btrfs_rename2+0xbb9/0x1800 vfs_rename+0x64f/0x9f0 do_renameat2+0x320/0x4e0 __x64_sys_rename+0x1f/0x30 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xa9
-> #0 (&delayed_node->mutex){+.+.}-{3:3}:
__lock_acquire+0x119c/0x1fc0 lock_acquire+0xa7/0x3d0 __mutex_lock+0x7e/0x7e0 __btrfs_release_delayed_node.part.0+0x3f/0x330 btrfs_evict_inode+0x24c/0x500 evict+0xcf/0x1f0 dispose_list+0x48/0x70 prune_icache_sb+0x44/0x50 super_cache_scan+0x161/0x1e0 do_shrink_slab+0x178/0x3c0 shrink_slab+0x17c/0x290 shrink_node+0x2b2/0x6d0 balance_pgdat+0x30a/0x670 kswapd+0x213/0x4c0 kthread+0x138/0x160 ret_from_fork+0x1f/0x30
other info that might help us debug this:
Chain exists of:
&delayed_node->mutex --> kernfs_mutex --> fs_reclaim
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(kernfs_mutex);
lock(fs_reclaim);
lock(&delayed_node->mutex);*** DEADLOCK ***
3 locks held by kswapd0/100:
#0: ffffffff8dd74700 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30 #1: ffffffff8dd65c50 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0x115/0x290 #2: ffff96ed2ade30e0 (&type->s_umount_key#36){++++}-{3:3}, at: super_cache_scan+0x38/0x1e0
stack backtrace: CPU: 0 PID: 100 Comm: kswapd0 Not tainted 5.9.0-rc3+ #4 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 Call Trace: dump_stack+0x8b/0xb8 check_noncircular+0x12d/0x150 __lock_acquire+0x119c/0x1fc0 lock_acquire+0xa7/0x3d0 ? __btrfs_release_delayed_node.part.0+0x3f/0x330 __mutex_lock+0x7e/0x7e0 ? __btrfs_release_delayed_node.part.0+0x3f/0x330 ? __btrfs_release_delayed_node.part.0+0x3f/0x330 ? lock_acquire+0xa7/0x3d0 ? find_held_lock+0x2b/0x80 __btrfs_release_delayed_node.part.0+0x3f/0x330 btrfs_evict_inode+0x24c/0x500 evict+0xcf/0x1f0 dispose_list+0x48/0x70 prune_icache_sb+0x44/0x50 super_cache_scan+0x161/0x1e0 do_shrink_slab+0x178/0x3c0 shrink_slab+0x17c/0x290 shrink_node+0x2b2/0x6d0 balance_pgdat+0x30a/0x670 kswapd+0x213/0x4c0 ? _raw_spin_unlock_irqrestore+0x41/0x50 ? add_wait_queue_exclusive+0x70/0x70 ? balance_pgdat+0x670/0x670 kthread+0x138/0x160 ? kthread_create_worker_on_cpu+0x40/0x40 ret_from_fork+0x1f/0x30
This happens because we are holding the chunk_mutex at the time of adding in a new device. However we only need to hold the device_list_mutex, as we're going to iterate over the fs_devices devices. Move the sysfs init stuff outside of the chunk_mutex to get rid of this lockdep splat.
--- fs/btrfs/volumes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/volumes.c +4 -3
@@ -2613,9 +2613,6 @@ int btrfs_init_new_device(struct btrfs_fbtrfs_set_super_num_devices (fs_info->super_copy, orig_super_num_devices +1 ); -/* add sysfs device entry */ -btrfs_sysfs_add_devices_dir (fs_devices, device); -/* * we've got more storage, clear any full flags on the space * infos
@@ -2623,6 +2620,10 @@ int btrfs_init_new_device(struct btrfs_fbtrfs_clear_space_info_full (fs_info);mutex_unlock (&fs_info->chunk_mutex); + +/* Add sysfs device entry */ +btrfs_sysfs_add_devices_dir (fs_devices, device); +mutex_unlock (&fs_devices->device_list_mutex);if (seeding_dev) {
Greg Kroah-Hartman
maintainerPATCH 225/391 btrfs: tracepoints: output proper root owner for trace_find_free_extent()
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 437490fed3b0c9ae21af8f70e0f338d34560842b upstream.
The current trace event always output result like this:
find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=4(METADATA)
find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=4(METADATA)
find_free_extent: root=2(EXTENT_TREE) len=8192 empty_size=0 flags=1(DATA)
find_free_extent: root=2(EXTENT_TREE) len=8192 empty_size=0 flags=1(DATA)
find_free_extent: root=2(EXTENT_TREE) len=4096 empty_size=0 flags=1(DATA)
find_free_extent: root=2(EXTENT_TREE) len=4096 empty_size=0 flags=1(DATA)
T's saying we're allocating data extent for EXTENT tree, which is not even possible.
It's because we always use EXTENT tree as the owner for trace_find_free_extent() without using the @root from btrfs_reserve_extent().
This patch will change the parameter to use proper @root for trace_find_free_extent():
Now it looks much better:
find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
find_free_extent: root=5(FS_TREE) len=8192 empty_size=0 flags=1(DATA)
find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=1(DATA)
find_free_extent: root=5(FS_TREE) len=4096 empty_size=0 flags=1(DATA)
find_free_extent: root=5(FS_TREE) len=8192 empty_size=0 flags=1(DATA)
find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
find_free_extent: root=7(CSUM_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
find_free_extent: root=1(ROOT_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
--- fs/btrfs/extent-tree.c | 7 ++++--- include/trace/events/btrfs.h | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-)
fs/btrfs/extent-tree.c +4 -3
@@ -3918,11 +3918,12 @@ static int prepare_allocation(struct btr* |- Push harder to find free extents * |- If not found, re-iterate all block groups */ -static noinline int find_free_extent(struct btrfs_fs_info *fs_info, +static noinline int find_free_extent(struct btrfs_root *root,u64 ram_bytes,u64 num_bytes,u64 empty_size,u64 hint_byte_orig,struct btrfs_key *ins,u64 flags,int delalloc) { +struct btrfs_fs_info *fs_info = root->fs_info;int ret =0 ;int cache_block_group_error =0 ;struct btrfs_block_group *block_group =NULL ;
@@ -3954,7 +3955,7 @@ static noinline int find_free_extent(str ins->objectid =0 ; ins->offset =0 ; -trace_find_free_extent (fs_info, num_bytes, empty_size, flags); +trace_find_free_extent (root, num_bytes, empty_size, flags); space_info =btrfs_find_space_info (fs_info, flags);if (!space_info) {
@@ -4203,7 +4204,7 @@ int btrfs_reserve_extent(struct btrfs_ro flags =get_alloc_profile_by_root (root, is_data); again:WARN_ON (num_bytes < fs_info->sectorsize); - ret =find_free_extent (fs_info, ram_bytes, num_bytes, empty_size, + ret =find_free_extent (root, ram_bytes, num_bytes, empty_size, hint_byte, ins, flags, delalloc);if (!ret && !is_data) {btrfs_dec_block_group_reservations (fs_info, ins->objectid);
include/trace/events/btrfs.h +6 -4
@@ -1176,25 +1176,27 @@ DEFINE_EVENT(btrfs__reserved_extent, btTRACE_EVENT (find_free_extent, - TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, + TP_PROTO(const struct btrfs_root *root, u64 num_bytes, u64 empty_size, u64 data), -TP_ARGS (fs_info, num_bytes, empty_size, data), +TP_ARGS (root, num_bytes, empty_size, data),TP_STRUCT__entry_btrfs ( + __field( u64, root_objectid ) __field( u64, num_bytes ) __field( u64, empty_size )__field ( u64, data ) ), -TP_fast_assign_btrfs (fs_info, +TP_fast_assign_btrfs (root->fs_info, + __entry->root_objectid = root->root_key.objectid; __entry->num_bytes = num_bytes; __entry->empty_size = empty_size; __entry->data = data; ),TP_printk_btrfs ("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)" , -show_root_type (BTRFS_EXTENT_TREE_OBJECTID ), +show_root_type (__entry->root_objectid), __entry->num_bytes, __entry->empty_size, __entry->data,__print_flags ((unsigned long )__entry->data,"|" , BTRFS_GROUP_FLAGS))
Greg Kroah-Hartman
maintainerPATCH 219/391 scsi: qla2xxx: Fix crash on session cleanup with unload
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 50457dab670f396557e60c07f086358460876353 upstream.
On unload, session cleanup prematurely gave the signal for driver unload path to advance.
--- drivers/scsi/qla2xxx/qla_target.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +7 -6
@@ -1229,14 +1229,15 @@ void qlt_schedule_sess_for_deletion(strucase DSC_DELETE_PEND :return ;case DSC_DELETED : -if (tgt && tgt->tgt_stop && (tgt->sess_count ==0 )) -wake_up_all (&tgt->waitQ); -if (sess->vha->fcport_count ==0 ) -wake_up_all (&sess->vha->fcport_waitQ); -if (!sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN ] && - !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT ]) + !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT ]) { +if (tgt && tgt->tgt_stop && tgt->sess_count ==0 ) +wake_up_all (&tgt->waitQ); + +if (sess->vha->fcport_count ==0 ) +wake_up_all (&sess->vha->fcport_waitQ);return ; + }break ;case DSC_UPD_FCPORT :/*
Greg Kroah-Hartman
maintainerPATCH 227/391 btrfs: send, orphanize first all conflicting inodes when processing references
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 98272bb77bf4cc20ed1ffca89832d713e70ebf09 upstream.
When doing an incremental send it is possible that when processing the new references for an inode we end up issuing rename or link operations that have an invalid path, which contains the orphanized name of a directory before we actually orphanized it, causing the receiver to fail.
The following reproducer triggers such scenario:
$ cat reproducer.sh #!/bin/bash
mkfs.btrfs -f /dev/sdi >/dev/null
mount /dev/sdi /mnt/sdi
touch /mnt/sdi/a
touch /mnt/sdi/b
mkdir /mnt/sdi/testdir
# We want "a" to have a lower inode number then "testdir" (257 vs 259). mv /mnt/sdi/a /mnt/sdi/testdir/a
# Filesystem looks like:
#
# . (ino 256) # |----- testdir/ (ino 259) # | |----- a (ino 257) # | # |----- b (ino 258)
btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap1 btrfs send -f /tmp/snap1.send /mnt/sdi/snap1
# Now rename 259 to "testdir_2", then change the name of 257 to # "testdir" and make it a direct descendant of the root inode (256). # Also create a new link for inode 257 with the old name of inode 258. # By swapping the names and location of several inodes and create a
# nasty dependency chain of rename and link operations. mv /mnt/sdi/testdir/a /mnt/sdi/a2 touch /mnt/sdi/testdir/a mv /mnt/sdi/b /mnt/sdi/b2 ln /mnt/sdi/a2 /mnt/sdi/b mv /mnt/sdi/testdir /mnt/sdi/testdir_2 mv /mnt/sdi/a2 /mnt/sdi/testdir
# Filesystem now looks like:
#
# . (ino 256) # |----- testdir_2/ (ino 259) # | |----- a (ino 260) # | # |----- testdir (ino 257) # |----- b (ino 257) # |----- b2 (ino 258)
btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap2 btrfs send -f /tmp/snap2.send -p /mnt/sdi/snap1 /mnt/sdi/snap2
mkfs.btrfs -f /dev/sdj >/dev/null
mount /dev/sdj /mnt/sdj
btrfs receive -f /tmp/snap1.send /mnt/sdj
btrfs receive -f /tmp/snap2.send /mnt/sdj
umount /mnt/sdi
umount /mnt/sdj
When running the reproducer, the receive of the incremental send stream fails:
$ ./reproducer.sh Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap1' At subvol /mnt/sdi/snap1 Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap2' At subvol /mnt/sdi/snap2 At subvol snap1 At snapshot snap2 ERROR: link b -> o259-6-0/a failed: No such file or directory
The problem happens because of the following:
1) Before we start iterating the list of new references for inode 257, we generate its current path and store it at @valid_path, done at the very beginning of process_recorded_refs(). The generated path is "o259-6-0/a", containing the orphanized name for inode 259;
2) Then we iterate over the list of new references, which has the references "b" and "testdir" in that specific order;
3) We process reference "b" first, because it is in the list before reference "testdir". We then issue a link operation to create the new reference "b" using a target path corresponding to the content at @valid_path, which corresponds to "o259-6-0/a". However we haven't yet orphanized inode 259, its name is still "testdir", and not "o259-6-0". The orphanization of 259 did not happen yet because we will process the reference named "testdir" for inode 257 only in the next iteration of the loop that goes over the list of new references.
Fix the issue by having a preliminar iteration over all the new references at process_recorded_refs(). This iteration is responsible only for doing the orphanization of other inodes that have and old reference that conflicts with one of the new references of the inode we are currently processing. The emission of rename and link operations happen now in the next iteration of the new references.
A test case for fstests will follow soon.
--- fs/btrfs/send.c | 127 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 40 deletions(-)
fs/btrfs/send.c +87 -40
@@ -3880,52 +3880,56 @@ static int process_recorded_refs(struct goto out; } +/* +* Before doing any rename and link operations, do a first pass on the +* new references to orphanize any unprocessed inodes that may have a +* reference that conflicts with one of the new references of the current +* inode. This needs to happen first because a new reference may conflict +* with the old reference of a parent directory, so we must make sure +* that the path used for link and rename commands don't use an +* orphanized name when an ancestor was not yet orphanized. +* +* Example: +* +* Parent snapshot: +* +* . (ino 256) +* |----- testdir/ (ino 259) +* | |----- a (ino 257) +* | +* |----- b (ino 258) +* +* Send snapshot: +* +* . (ino 256) +* |----- testdir_2/ (ino 259) +* | |----- a (ino 260) +* | +* |----- testdir (ino 257) +* |----- b (ino 257) +* |----- b2 (ino 258) +* +* Processing the new reference for inode 257 with name "b" may happen +* before processing the new reference with name "testdir". If so, we +* must make sure that by the time we send a link command to create the +* hard link "b", inode 259 was already orphanized, since the generated +* path in "valid_path" already contains the orphanized name for 259. +* We are processing inode 257, so only later when processing 259 we do +* the rename operation to change its temporary (orphanized) name to +* "testdir_2". +*/ list_for_each_entry (cur, &sctx->new_refs, list) { -/* -* We may have refs where the parent directory does not exist -* yet. This happens if the parent directories inum is higher -* than the current inum. To handle this case, we create the -* parent directory out of order. But we need to check if this -* did already happen before due to other refs in the same dir. -*/ ret =get_cur_inode_state (sctx, cur->dir, cur->dir_gen);if (ret <0 ) goto out; -if (ret == inode_state_will_create) { - ret =0 ; -/* -* First check if any of the current inodes refs did -* already create the dir. -*/ -list_for_each_entry (cur2, &sctx->new_refs, list) { -if (cur == cur2) -break ; -if (cur2->dir == cur->dir) { - ret =1 ; -break ; - } - } - -/* -* If that did not happen, check if a previous inode -* did already create the dir. -*/ -if (!ret) - ret =did_create_dir (sctx, cur->dir); -if (ret <0 ) - goto out; -if (!ret) { - ret =send_create_inode (sctx, cur->dir); -if (ret <0 ) - goto out; - } - } +if (ret == inode_state_will_create) +continue ;/* -* Check if this new ref would overwrite the first ref of -* another unprocessed inode. If yes, orphanize the -* overwritten inode. If we find an overwritten ref that is -* not the first ref, simply unlink it. +* Check if this new ref would overwrite the first ref of another +* unprocessed inode. If yes, orphanize the overwritten inode. +* If we find an overwritten ref that is not the first ref, +* simply unlink it. */ ret = will_overwrite_ref(sctx, cur->dir, cur->dir_gen, cur->name, cur->name_len,
@@ -4002,6 +4006,49 @@ static int process_recorded_refs(structif (ret <0 ) goto out; } + } + + } + +list_for_each_entry (cur, &sctx->new_refs, list) { +/* +* We may have refs where the parent directory does not exist +* yet. This happens if the parent directories inum is higher +* than the current inum. To handle this case, we create the +* parent directory out of order. But we need to check if this +* did already happen before due to other refs in the same dir. +*/ + ret =get_cur_inode_state (sctx, cur->dir, cur->dir_gen); +if (ret <0 ) + goto out; +if (ret == inode_state_will_create) { + ret =0 ; +/* +* First check if any of the current inodes refs did +* already create the dir. +*/ +list_for_each_entry (cur2, &sctx->new_refs, list) { +if (cur == cur2) +break ; +if (cur2->dir == cur->dir) { + ret =1 ; +break ; + } + } + +/* +* If that did not happen, check if a previous inode +* did already create the dir. +*/ +if (!ret) + ret =did_create_dir (sctx, cur->dir); +if (ret <0 ) + goto out; +if (!ret) { + ret =send_create_inode (sctx, cur->dir); +if (ret <0 ) + goto out; + } }if (S_ISDIR (sctx->cur_inode_mode) && sctx->parent_root) {
Greg Kroah-Hartman
maintainerPATCH 226/391 btrfs: reschedule if necessary when logging directory items
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit bb56f02f26fe23798edb1b2175707419b28c752a upstream.
Logging directories with many entries can take a significant amount of time, and in some cases monopolize a cpu/core for a long time if the logging task doesn't happen to block often enough.
Johannes and Lu Fengqi reported test case generic/041 triggering a soft lockup when the kernel has CONFIG_SOFTLOCKUP_DETECTOR=y. For this test case we log an inode with 3002 hard links, and because the test removed one hard link before fsyncing the file, the inode logging causes the parent directory do be logged as well, which has 6004 directory items to log (3002 BTRFS_DIR_ITEM_KEY items plus 3002 BTRFS_DIR_INDEX_KEY items), so it can take a significant amount of time and trigger the soft lockup.
So just make tree-log.c:log_dir_items() reschedule when necessary, releasing the current search path before doing so and then resume from where it was before the reschedule.
The stack trace produced when the soft lockup happens is the following:
[10480.277653] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [xfs_io:28172] [10480.279418] Modules linked in: dm_thin_pool dm_persistent_data (...) [10480.284915] irq event stamp: 29646366 [10480.285987] hardirqs last enabled at (29646365): [<ffffffff85249b66>] __slab_alloc.constprop.0+0x56/0x60 [10480.288482] hardirqs last disabled at (29646366): [<ffffffff8579b00d>] irqentry_enter+0x1d/0x50 [10480.290856] softirqs last enabled at (4612): [<ffffffff85a00323>] __do_softirq+0x323/0x56c [10480.293615] softirqs last disabled at (4483): [<ffffffff85800dbf>] asm_call_on_stack+0xf/0x20 [10480.296428] CPU: 2 PID: 28172 Comm: xfs_io Not tainted 5.9.0-rc4-default+ #1248 [10480.298948] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014 [10480.302455] RIP: 0010:__slab_alloc.constprop.0+0x19/0x60 [10480.304151] Code: 86 e8 31 75 21 00 66 66 2e 0f 1f 84 00 00 00 (...) [10480.309558] RSP: 0018:ffffadbe09397a58 EFLAGS: 00000282 [10480.311179] RAX: ffff8a495ab92840 RBX: 0000000000000282 RCX: 0000000000000006 [10480.313242] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff85249b66 [10480.315260] RBP: ffff8a497d04b740 R08: 0000000000000001 R09: 0000000000000001 [10480.317229] R10: ffff8a497d044800 R11: ffff8a495ab93c40 R12: 0000000000000000 [10480.319169] R13: 0000000000000000 R14: 0000000000000c40 R15: ffffffffc01daf70 [10480.321104] FS: 00007fa1dc5c0e40(0000) GS:ffff8a497da00000(0000) knlGS:0000000000000000 [10480.323559] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [10480.325235] CR2: 00007fa1dc5befb8 CR3: 0000000004f8a006 CR4: 0000000000170ea0 [10480.327259] Call Trace: [10480.328286] ? overwrite_item+0x1f0/0x5a0 [btrfs] [10480.329784] __kmalloc+0x831/0xa20 [10480.331009] ? btrfs_get_32+0xb0/0x1d0 [btrfs] [10480.332464] overwrite_item+0x1f0/0x5a0 [btrfs] [10480.333948] log_dir_items+0x2ee/0x570 [btrfs] [10480.335413] log_directory_changes+0x82/0xd0 [btrfs] [10480.336926] btrfs_log_inode+0xc9b/0xda0 [btrfs] [10480.338374] ? init_once+0x20/0x20 [btrfs] [10480.339711] btrfs_log_inode_parent+0x8d3/0xd10 [btrfs] [10480.341257] ? dget_parent+0x97/0x2e0 [10480.342480] btrfs_log_dentry_safe+0x3a/0x50 [btrfs] [10480.343977] btrfs_sync_file+0x24b/0x5e0 [btrfs] [10480.345381] do_fsync+0x38/0x70 [10480.346483] __x64_sys_fsync+0x10/0x20 [10480.347703] do_syscall_64+0x2d/0x70 [10480.348891] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [10480.350444] RIP: 0033:0x7fa1dc80970b [10480.351642] Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 (...) [10480.356952] RSP: 002b:00007fffb3d081d0 EFLAGS: 00000293 ORIG_RAX: 000000000000004a [10480.359458] RAX: ffffffffffffffda RBX: 0000562d93d45e40 RCX: 00007fa1dc80970b [10480.361426] RDX: 0000562d93d44ab0 RSI: 0000562d93d45e60 RDI: 0000000000000003 [10480.363367] RBP: 0000000000000001 R08: 0000000000000000 R09: 00007fa1dc7b2a40 [10480.365317] R10: 0000562d93d0e366 R11: 0000000000000293 R12: 0000000000000001 [10480.367299] R13: 0000562d93d45290 R14: 0000562d93d45e40 R15: 0000562d93d45e60
--- fs/btrfs/tree-log.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/tree-log.c +8 -0
@@ -3615,6 +3615,7 @@ static noinline int log_dir_items(struct* search and this search we'll not find the key again and can just * bail. */ +search: ret =btrfs_search_slot (NULL , root, &min_key, path,0 ,0 );if (ret !=0 ) goto done;
@@ -3634,6 +3635,13 @@ static noinline int log_dir_items(structif (min_key.objectid != ino || min_key.type != key_type) goto done; + +if (need_resched ()) { +btrfs_release_path (path); +cond_resched (); + goto search; + } + ret =overwrite_item (trans, log, dst_path, src, i, &min_key);if (ret) {
Greg Kroah-Hartman
maintainerPATCH 270/391 iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 6b0cc5dce0725ae8f1a2883514da731c55eeb35e upstream.
This case is a bit different to the rest of the series. The driver was doing a regmap_bulk_read into a buffer that wasn't dma safe as it was on the stack with no guarantee of it being in a cacheline
on it's own. Fixing that also dealt with the data leak and
alignment issues that Lars-Peter pointed out.
Also removed some unaligned handling as we are now aligned.
Fixes tag is for the dma safe buffer issue. Potentially we would need to backport timestamp alignment futher but that is a totally different patch.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 12 +++++++++--- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 12 +++++------- 2 files changed, 14 insertions(+), 10 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +9 -3
@@ -122,6 +122,13 @@ struct inv_mpu6050_chip_config {u8 user_ctrl; }; +/* +* Maximum of 6 + 6 + 2 + 7 (for MPU9x50) = 21 round up to 24 and plus 8. +* May be less if fewer channels are enabled, as long as the timestamp +* remains 8 byte aligned +*/ +#define INV_MPU6050_OUTPUT_DATA_SIZE 32 +/** * struct inv_mpu6050_hw - Other important hardware information. * @whoami: Self identification byte from WHO_AM_I register
@@ -165,6 +172,7 @@ struct inv_mpu6050_hw {* @magn_raw_to_gauss: coefficient to convert mag raw value to Gauss. * @magn_orient: magnetometer sensor chip orientation if available. * @suspended_sensors: sensors mask of sensors turned off for suspend +* @data: dma safe buffer used for bulk reads. */ struct inv_mpu6050_state {struct mutex lock;
@@ -190,6 +198,7 @@ struct inv_mpu6050_state {s32 magn_raw_to_gauss[3 ];struct iio_mount_matrix magn_orient;unsigned int suspended_sensors; +u8 data[INV_MPU6050_OUTPUT_DATA_SIZE ]____cacheline_aligned ; };/*register and associated bit definition*/
@@ -334,9 +343,6 @@ struct inv_mpu6050_state {#define INV_ICM20608_TEMP_OFFSET 8170#define INV_ICM20608_TEMP_SCALE 3059976 -/* 6 + 6 + 2 + 7 (for MPU9x50) = 21 round up to 24 and plus 8 */ -#define INV_MPU6050_OUTPUT_DATA_SIZE 32 -#define INV_MPU6050_REG_INT_PIN_CFG 0x37#define INV_MPU6050_ACTIVE_HIGH 0x00#define INV_MPU6050_ACTIVE_LOW 0x80
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +5 -7
@@ -13,7 +13,6 @@#include <linux/interrupt.h> #include <linux/poll.h> #include <linux/math64.h> -#include <asm/unaligned.h> #include "inv_mpu_iio.h" /**
@@ -121,7 +120,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irstruct inv_mpu6050_state *st =iio_priv (indio_dev);size_t bytes_per_datum;int result; -u8 data[INV_MPU6050_OUTPUT_DATA_SIZE ];u16 fifo_count;s64 timestamp;int int_status;
@@ -160,11 +158,11 @@ irqreturn_t inv_mpu6050_read_fifo(int ir* read fifo_count register to know how many bytes are inside the FIFO * right now */ - result =regmap_bulk_read (st->map, st->reg->fifo_count_h, data, -INV_MPU6050_FIFO_COUNT_BYTE ); + result =regmap_bulk_read (st->map, st->reg->fifo_count_h, + st->data,INV_MPU6050_FIFO_COUNT_BYTE );if (result) goto end_session; - fifo_count =get_unaligned_be16 (&data[0 ]); + fifo_count =be16_to_cpup ((__be16 *)&st->data[0 ]);/* * Handle fifo overflow by resetting fifo.
@@ -182,7 +180,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irinv_mpu6050_update_period (st, pf->timestamp, nb);for (i =0 ; i < nb; ++i) { result =regmap_bulk_read (st->map, st->reg->fifo_r_w, - data, bytes_per_datum); + st->data, bytes_per_datum);if (result) goto flush_fifo;/* skip first samples if needed */
@@ -191,7 +189,7 @@ irqreturn_t inv_mpu6050_read_fifo(int ircontinue ; } timestamp =inv_mpu6050_get_timestamp (st); -iio_push_to_buffers_with_timestamp (indio_dev, data, timestamp); +iio_push_to_buffers_with_timestamp (indio_dev, st->data, timestamp); } end_session:
Greg Kroah-Hartman
maintainerPATCH 274/391 iio: ad7292: Fix of_node refcounting
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
commit b8a533f3c24b3b8f1fdbefc5ada6a7d5733d63e6 upstream.
When returning or breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the child node to possibly release the node.
--- drivers/iio/adc/ad7292.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7292.c +3 -1
@@ -310,8 +310,10 @@ static int ad7292_probe(struct spi_devicfor_each_available_child_of_node (spi->dev.of_node, child) { diff_channels =of_property_read_bool (child,"diff-channels" ); -if (diff_channels) +if (diff_channels) { +of_node_put (child);break ; + } }if (diff_channels) {
Greg Kroah-Hartman
maintainerPATCH 275/391 iio:adc:ti-adc0832 Fix alignment issue with timestamp
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 39e91f3be4cba51c1560bcda3a343ed1f64dc916 upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack.
We fix this issues by moving to a suitable structure in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc so no data can leak apart from previous readings. Note that previously no data could leak 'including' previous readings but I don't think it is an issue to potentially leak them like this now does.
In this case the postioning of the timestamp is depends on what other channels are enabled. As such we cannot use a structure to make the alignment explicit as it would be missleading by suggesting only one possible location for the timestamp.
--- drivers/iio/adc/ti-adc0832.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iio/adc/ti-adc0832.c +8 -3
@@ -29,6 +29,12 @@ struct adc0832 {struct regulator *reg;struct mutex lock;u8 mux_bits; +/* +* Max size needed: 16x 1 byte ADC data + 8 bytes timestamp +* May be shorter if not all channels are enabled subject +* to the timestamp remaining 8 byte aligned. +*/ +u8 data[24 ]__aligned(8) ;u8 tx_buf[2 ]____cacheline_aligned ;u8 rx_buf[2 ];
@@ -200,7 +206,6 @@ static irqreturn_t adc0832_trigger_handlstruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct adc0832 *adc =iio_priv (indio_dev); -u8 data[24 ] = { };/* 16x 1 byte ADC data + 8 bytes timestamp */ int scan_index;int i =0 ;
@@ -218,10 +223,10 @@ static irqreturn_t adc0832_trigger_handl goto out; } - data[i] = ret; + adc->data[i] = ret; i++; } -iio_push_to_buffers_with_timestamp (indio_dev, data, +iio_push_to_buffers_with_timestamp (indio_dev, adc->data,iio_get_time_ns (indio_dev)); out:mutex_unlock (&adc->lock);
Greg Kroah-Hartman
maintainerPATCH 277/391 iio:imu:st_lsm6dsx Fix alignment and data leak issues
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit c14edb4d0bdc53f969ea84c7f384472c28b1a9f8 upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to an array of suitable structures in the iio_priv() data.
This data is allocated with kzalloc so no data can leak apart from previous readings.
For the tagged path the data is aligned by using __aligned(8) for the buffer on the stack.
There has been a lot of churn in this driver, so likely backports may be needed for stable.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 6 +++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 42 +++++++++++++++---------- 2 files changed, 32 insertions(+), 16 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +6 -0
@@ -383,6 +383,7 @@ struct st_lsm6dsx_sensor {* @iio_devs: Pointers to acc/gyro iio_dev instances. * @settings: Pointer to the specific sensor settings in use. * @orientation: sensor chip orientation relative to main hardware. +* @scan: Temporary buffers used to align data before iio_push_to_buffers() */ struct st_lsm6dsx_hw {struct device *dev;
@@ -411,6 +412,11 @@ struct st_lsm6dsx_hw {const struct st_lsm6dsx_settings *settings;struct iio_mount_matrix orientation; +/* Ensure natural alignment of buffer elements */ +struct { +__le16 channels[3 ]; +s64 ts__aligned(8) ; + } scan[3 ]; };static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +26 -16
80 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 279/391 powerpc/drmem: Make lmb_size 64 bit
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
commit ec72024e35dddb88a81e40071c87ceb18b5ee835 upstream.
Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
This was found by code audit.
--- arch/powerpc/include/asm/drmem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/drmem.h +2 -2
@@ -20,7 +20,7 @@ struct drmem_lmb {struct drmem_lmb_info {struct drmem_lmb *lmbs;int n_lmbs; -u32 lmb_size; +u64 lmb_size; };extern struct drmem_lmb_info *drmem_info;
@@ -80,7 +80,7 @@ struct of_drconf_cell_v2 {#define DRCONF_MEM_RESERVED 0x00000080#define DRCONF_MEM_HOTREMOVABLE 0x00000100 -static inline u32 drmem_lmb_size (void ) +static inline u64 drmem_lmb_size (void ) {return drmem_info->lmb_size; }
Greg Kroah-Hartman
maintainerPATCH 280/391 rcu-tasks: Fix grace-period/unlock race in RCU Tasks Trace
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit ba3a86e47232ad9f76160929f33ac9c64e4d0567 upstream.
The more intense grace-period processing resulting from the 50x RCU Tasks Trace grace-period speedups exposed the following race condition:
o Task A running on CPU 0 executes rcu_read_lock_trace(),
entering a read-side critical section.
o When Task A eventually invokes rcu_read_unlock_trace()
to exit its read-side critical section, this function notes that the ->trc_reader_special.s flag is zero and and therefore invoke wil set ->trc_reader_nesting to zero using WRITE_ONCE(). But before that happens...
o The RCU Tasks Trace grace-period kthread running on some other
CPU interrogates Task A, but this fails because this task is currently running. This kthread therefore sends an IPI to CPU 0.
o CPU 0 receives the IPI, and thus invokes trc_read_check_handler().
Because Task A has not yet cleared its ->trc_reader_nesting counter, this function sees that Task A is still within its read-side critical section. This function therefore sets the ->trc_reader_nesting.b.need_qs flag, AKA the .need_qs flag.
Except that Task A has already checked the .need_qs flag, which is part of the ->trc_reader_special.s flag. The .need_qs flag therefore remains set until Task A's next rcu_read_unlock_trace().
o Task A now invokes synchronize_rcu_tasks_trace(), which cannot
start a new grace period until the current grace period completes. And thus cannot return until after that time.
But Task A's .need_qs flag is still set, which prevents the current grace period from completing. And because Task A is blocked, it will never execute rcu_read_unlock_trace() until its call to synchronize_rcu_tasks_trace() returns.
We are therefore deadlocked.
This race is improbable, but 80 hours of rcutorture made it happen twice. The race was possible before the grace-period speedup, but roughly 50x less probable. Several thousand hours of rcutorture would have been necessary to have a reasonable chance of making this happen before this 50x speedup.
This commit therefore eliminates this deadlock by setting ->trc_reader_nesting to a large negative number before checking the .need_qs and zeroing (or decrementing with respect to its initial value) ->trc_reader_nesting. For its part, the IPI handler's trc_read_check_handler() function adds a check for negative values, deferring evaluation of the task in this case. Taken together, these changes avoid this deadlock scenario.
--- include/linux/rcupdate_trace.h | 4 ++++ kernel/rcu/tasks.h | 6 ++++++ 2 files changed, 10 insertions(+)
include/linux/rcupdate_trace.h +4 -0
@@ -50,6 +50,7 @@ static inline void rcu_read_lock_trace(vstruct task_struct *t = current;WRITE_ONCE (t->trc_reader_nesting,READ_ONCE (t->trc_reader_nesting) +1 ); +barrier ();if (IS_ENABLED (CONFIG_TASKS_TRACE_RCU_READ_MB ) && t->trc_reader_special.b.need_mb)smp_mb ();// Pairs with update-side barriers
@@ -72,6 +73,9 @@ static inline void rcu_read_unlock_tracercu_lock_release (&rcu_trace_lock_map); nesting =READ_ONCE (t->trc_reader_nesting) -1 ; +barrier ();// Critical section before disabling. +// Disable IPI-based setting of .need_qs. +WRITE_ONCE (t->trc_reader_nesting,INT_MIN );if (likely (!READ_ONCE (t->trc_reader_special.s)) || nesting) {WRITE_ONCE (t->trc_reader_nesting, nesting);return ;// We assume shallow reader nesting.
kernel/rcu/tasks.h +6 -0
@@ -821,6 +821,12 @@ static void trc_read_check_handler(voidWRITE_ONCE (t->trc_reader_checked, true); goto reset_ipi; } +// If we are racing with an rcu_read_unlock_trace(), try again later. +if (unlikely (t->trc_reader_nesting <0 )) { +if (WARN_ON_ONCE (atomic_dec_and_test (&trc_n_readers_need_end))) +wake_up (&trc_wait); + goto reset_ipi; + }WRITE_ONCE (t->trc_reader_checked, true);// Get here if the task is in a read-side critical section. Set
Greg Kroah-Hartman
maintainerPATCH 282/391 rcu-tasks: Enclose task-list scan in rcu_read_lock()
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit f747c7e15d7bc71a967a94ceda686cf2460b69e8 upstream.
The rcu_tasks_trace_postgp() function uses for_each_process_thread() to scan the task list without the benefit of RCU read-side protection, which can result in use-after-free errors on task_struct structures. This error was missed because the TRACE01 rcutorture scenario enables lockdep, but also builds with CONFIG_PREEMPT_NONE=y. In this situation, preemption is disabled everywhere, so lockdep thinks everywhere can be a legitimate RCU reader. This commit therefore adds the needed rcu_read_lock() and rcu_read_unlock().
Note that this bug can occur only after an RCU Tasks Trace CPU stall warning, which by default only happens after a grace period has extended for ten minutes (yes, not a typo, minutes).
--- kernel/rcu/tasks.h | 2 ++ 1 file changed, 2 insertions(+)
kernel/rcu/tasks.h +2 -0
@@ -1078,9 +1078,11 @@ static void rcu_tasks_trace_postgp(strucif (ret)break ;// Count reached zero. // Stall warning time, so make a list of the offenders. +rcu_read_lock ();for_each_process_thread (g, t)if (READ_ONCE (t->trc_reader_special.b.need_qs))trc_add_holdout (t, &holdouts); +rcu_read_unlock (); firstreport = true;list_for_each_entry_safe (t, g, &holdouts, trc_holdout_list) {if (READ_ONCE (t->trc_reader_special.b.need_qs))
Greg Kroah-Hartman
maintainerPATCH 283/391 MIPS: DEC: Restore bootmem reservation for firmware working memory area
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
commit cf3af0a4d3b62ab48e0b90180ea161d0f5d4953f upstream.
Fix a crash on DEC platforms starting with:
VFS: Mounted root (nfs filesystem) on device 0:11. Freeing unused PROM memory: 124k freed
BUG: Bad page state in process swapper pfn:00001
page:(ptrval) refcount:0 mapcount:-128 mapping:00000000 index:0x1 pfn:0x1
flags: 0x0()
raw: 00000000 00000100 00000122 00000000 00000001 00000000 ffffff7f 00000000
page dumped because: nonzero mapcount
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 5.9.0-00858-g865c50e1d279 #1
Stack : 8065dc48 0000000b 8065d2b8 9bc27dcc 80645bfc 9bc259a4 806a1b97 80703124
80710000 8064a900 00000001 80099574 806b116c 1000ec00 9bc27d88 806a6f30
00000000 00000000 80645bfc 00000000 31232039 80706ba4 2e392e35 8039f348
2d383538 00000070 0000000a 35363867 00000000 806c2830 80710000 806b0000
80710000 8064a900 00000001 81000000 00000000 00000000 8035af2c 80700000
...
Call Trace:
[<8004bc5c>] show_stack+0x34/0x104
[<8015675c>] bad_page+0xfc/0x128
[<80157714>] free_pcppages_bulk+0x1f4/0x5dc
[<801591cc>] free_unref_page+0xc0/0x130
[<8015cb04>] free_reserved_area+0x144/0x1d8
[<805abd78>] kernel_init+0x20/0x100
[<80046070>] ret_from_kernel_thread+0x14/0x1cDisabling lock debugging due to kernel taint
caused by an attempt to free bootmem space that as from
commit b93ddc4f9156 ("mips: Reserve memory for the kernel image resources") has not been anymore reserved due to the removal of generic MIPS arch code that used to reserve all the memory from the beginning of RAM up to the kernel load address.
This memory does need to be reserved on DEC platforms however as it is used by REX firmware as working area, as per the TURBOchannel firmware specification[1]:
Table 2-2 REX Memory Regions
-------------------------------------------------------------------------
Starting Ending
Region Address Address Use
-------------------------------------------------------------------------
0 0xa0000000 0xa000ffff Restart block, exception vectors,
REX stack and bss
1 0xa0010000 0xa0017fff Keyboard or tty drivers
2 0xa0018000 0xa001f3ff 1) CRT driver
3 0xa0020000 0xa002ffff boot, cnfg, init and t objects
4 0xa0020000 0xa002ffff 64KB scratch space
-------------------------------------------------------------------------
1) Note that the last 3 Kbytes of region 2 are reserved for backward compatibility with previous system software.
-------------------------------------------------------------------------
(this table uses KSEG2 unmapped virtual addresses, which in the MIPS architecture are offset from physical addresses by a fixed value of 0xa0000000 and therefore the regions referred do correspond to the beginning of the physical address space) and we call into the firmware on several occasions throughout the bootstrap process. It is believed that pre-REX firmware used with non-TURBOchannel DEC platforms has the same requirements, as hinted by note #1 cited.
Recreate the discarded reservation then, in DEC platform code, removing the crash.
[1] "TURBOchannel Firmware Specification", On-line version, EK-TCAAD-FS-004, Digital Equipment Corporation, January 1993, Chapter 2 "System Module Firmware", p. 2-5
--- arch/mips/dec/setup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/mips/dec/setup.c +8 -1
@@ -6,7 +6,7 @@* for more details. * * Copyright (C) 1998 Harald Koerfgen -* Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki +* Copyright (C) 2000, 2001, 2002, 2003, 2005, 2020 Maciej W. Rozycki */ #include <linux/console.h> #include <linux/export.h>
@@ -15,6 +15,7 @@#include <linux/ioport.h> #include <linux/irq.h> #include <linux/irqnr.h> +#include <linux/memblock.h> #include <linux/param.h> #include <linux/percpu-defs.h> #include <linux/sched.h>
@@ -22,6 +23,7 @@#include <linux/types.h> #include <linux/pm.h> +#include <asm/addrspace.h> #include <asm/bootinfo.h> #include <asm/cpu.h> #include <asm/cpu-features.h>
@@ -29,7 +31,9 @@#include <asm/irq.h> #include <asm/irq_cpu.h> #include <asm/mipsregs.h> +#include <asm/page.h> #include <asm/reboot.h> +#include <asm/sections.h> #include <asm/time.h> #include <asm/traps.h> #include <asm/wbflush.h>
@@ -146,6 +150,9 @@ void __init plat_mem_setup(void) ioport_resource.start = ~0UL ; ioport_resource.end =0UL ; + +/* Stay away from the firmware working memory area for now. */ +memblock_reserve (PHYS_OFFSET ,__pa_symbol (&_text) -PHYS_OFFSET ); }/*
Greg Kroah-Hartman
maintainerPATCH 284/391 MIPS: configs: lb60: Fix defconfig not selecting correct board
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 7487abbe85afd02c35c283315cefc5e19c28d40f upstream.
Since INGENIC_GENERIC_BOARD was introduced, the JZ4740_QI_LB60 option is no longer the default, so the symbol has to be selected by the defconfig, otherwise the kernel built will be for a generic Ingenic board and won't have the Device Tree blob built-in.
--- arch/mips/configs/qi_lb60_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/configs/qi_lb60_defconfig +1 -0
@@ -8,6 +8,7 @@ CONFIG_EMBEDDED=y # CONFIG_COMPAT_BRK is not set CONFIG_SLAB=y CONFIG_MACH_INGENIC=y +CONFIG_JZ4740_QI_LB60=y CONFIG_HZ_100=y # CONFIG_SECCOMP is not set CONFIG_MODULES=y
Greg Kroah-Hartman
maintainerPATCH 288/391 powerpc/memhotplug: Make lmb size 64bit
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
commit 301d2ea6572386245c5d2d2dc85c3b5a737b85ac upstream.
Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
This was found by code audit.
--- arch/powerpc/platforms/pseries/hotplug-memory.c | 43 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 14 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +29 -14
@@ -277,7 +277,7 @@ static int dlpar_offline_lmb(struct drmereturn dlpar_change_lmb_state (lmb, false); } -static int pseries_remove_memblock (unsigned long base,unsigned int memblock_size) +static int pseries_remove_memblock (unsigned long base,unsigned long memblock_size) {unsigned long block_sz, start_pfn;int sections_per_block;
@@ -308,10 +308,11 @@ out:static int pseries_remove_mem_node (struct device_node *np) { -const __be32 *regs; +const __be32 *prop;unsigned long base; -unsigned int lmb_size; +unsigned long lmb_size;int ret = -EINVAL ; +int addr_cells, size_cells;/* * Check to see if we are actually removing memory
@@ -322,12 +323,19 @@ static int pseries_remove_mem_node(struc/* * Find the base address and size of the memblock */ - regs =of_get_property (np,"reg" ,NULL ); -if (!regs) + prop =of_get_property (np,"reg" ,NULL ); +if (!prop)return ret; - base =be64_to_cpu (*(unsigned long *)regs); - lmb_size =be32_to_cpu (regs[3 ]); + addr_cells =of_n_addr_cells (np); + size_cells =of_n_size_cells (np); + +/* +* "reg" property represents (addr,size) tuple. +*/ + base =of_read_number (prop, addr_cells); + prop += addr_cells; + lmb_size =of_read_number (prop, size_cells);pseries_remove_memblock (base, lmb_size);return 0 ;
@@ -564,7 +572,7 @@ static int dlpar_memory_remove_by_ic(u32#else static inline int pseries_remove_memblock (unsigned long base, -unsigned int memblock_size) +unsigned long memblock_size) {return -EOPNOTSUPP ; }
@@ -886,10 +894,11 @@ int dlpar_memory(struct pseries_hp_errorstatic int pseries_add_mem_node (struct device_node *np) { -const __be32 *regs; +const __be32 *prop;unsigned long base; -unsigned int lmb_size; +unsigned long lmb_size;int ret = -EINVAL ; +int addr_cells, size_cells;/* * Check to see if we are actually adding memory
@@ -900,12 +909,18 @@ static int pseries_add_mem_node(struct d/* * Find the base and size of the memblock */ - regs =of_get_property (np,"reg" ,NULL ); -if (!regs) + prop =of_get_property (np,"reg" ,NULL ); +if (!prop)return ret; - base =be64_to_cpu (*(unsigned long *)regs); - lmb_size =be32_to_cpu (regs[3 ]); + addr_cells =of_n_addr_cells (np); + size_cells =of_n_size_cells (np); +/* +* "reg" property represents (addr,size) tuple. +*/ + base =of_read_number (prop, addr_cells); + prop += addr_cells; + lmb_size =of_read_number (prop, size_cells);/* * Update memory region to represent the memory add
Greg Kroah-Hartman
maintainerPATCH 287/391 powerpc: Warn about use of smt_snooze_delay
In reply to Greg Kroah-HartmanFrom: Joel Stanley <[email protected]>
commit a02f6d42357acf6e5de6ffc728e6e77faf3ad217 upstream.
It's not done anything for a long time. Save the percpu variable, and emit a warning to remind users to not expect it to do anything.
This uses pr_warn_once instead of pr_warn_ratelimit as testing 'ppc64_cpu --smt=off' on a 24 core / 4 SMT system showed the warning to be noisy, as the online/offline loop is slow.
--- arch/powerpc/kernel/sysfs.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-)
arch/powerpc/kernel/sysfs.c +17 -25
@@ -32,29 +32,27 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); -/* -* SMT snooze delay stuff, 64-bit only for now -*/ -#ifdef CONFIG_PPC64 -/* Time in microseconds we delay before sleeping in the idle loop */ -static DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 }; +/* +* Snooze delay has not been hooked up since 3fa8cad82b94 ("powerpc/pseries/cpuidle: +* smt-snooze-delay cleanup.") and has been broken even longer. As was foretold in +* 2014: +* +* "ppc64_util currently utilises it. Once we fix ppc64_util, propose to clean +* up the kernel code." +* +* powerpc-utils stopped using it as of 1.3.8. At some point in the future this +* code should be removed. +*/ static ssize_t store_smt_snooze_delay (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { - struct cpu *cpu = container_of(dev, struct cpu, dev); -ssize_t ret; -long snooze; - - ret =sscanf (buf,"%ld" , &snooze); -if (ret !=1 ) -return -EINVAL ; - -per_cpu (smt_snooze_delay, cpu->dev.id) = snooze; +pr_warn_once ("%s (%d) stored to unsupported smt_snooze_delay, which has no effect.\n" , + current->comm, current->pid);return count; }
@@ -62,9 +60,9 @@ static ssize_t show_smt_snooze_delay(str struct device_attribute *attr, char *buf) { - struct cpu *cpu = container_of(dev, struct cpu, dev); - -return sprintf (buf,"%ld\n" ,per_cpu (smt_snooze_delay, cpu->dev.id)); + pr_warn_once("%s (%d) read from unsupported smt_snooze_delay\n", + current->comm, current->pid); +return sprintf (buf,"100\n" ); } static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
@@ -72,16 +70,10 @@ static DEVICE_ATTR(smt_snooze_delay, 064static int __init setup_smt_snooze_delay (char *str) { -unsigned int cpu; -long snooze; -if (!cpu_has_feature (CPU_FTR_SMT ))return 1 ; - snooze =simple_strtol (str,NULL ,10 ); -for_each_possible_cpu (cpu) -per_cpu (smt_snooze_delay, cpu) = snooze; - +pr_warn ("smt-snooze-delay command line option has no effect\n" );return 1 ; }__setup ("smt-snooze-delay=" , setup_smt_snooze_delay);
Greg Kroah-Hartman
maintainerPATCH 263/391 powerpc: Fix random segfault when freeing hugetlb range
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 542db12a9c42d1ce70c45091765e02f74c129f43 upstream.
The following random segfault is observed from time to time with map_hugetlb selftest:
root@localhost:~# ./map_hugetlb 1 19 524288 kB hugepages Mapping 1 Mbytes Segmentation fault
[ 31.219972] map_hugetlb[365]: segfault (11) at 117 nip 77974f8c lr 779a6834 code 1 in ld-2.23.so[77966000+21000] [ 31.220192] map_hugetlb[365]: code: 9421ffc0 480318d1 93410028 90010044 9361002c 93810030 93a10034 93c10038 [ 31.220307] map_hugetlb[365]: code: 93e1003c 93210024 8123007c 81430038 <80e90004> 814a0004 7f443a14 813a0004 [ 31.221911] BUG: Bad rss-counter state mm:(ptrval) type:MM_FILEPAGES val:33 [ 31.229362] BUG: Bad rss-counter state mm:(ptrval) type:MM_ANONPAGES val:5
This fault is due to hugetlb_free_pgd_range() freeing page tables that are also used by regular pages.
As explain in the comment at the beginning of hugetlb_free_pgd_range(), the verification done in free_pgd_range() on floor and ceiling is not done here, which means hugetlb_free_pte_range() can free outside the expected range.
As the verification cannot be done in hugetlb_free_pgd_range(), it must be done in hugetlb_free_pte_range().
--- arch/powerpc/mm/hugetlbpage.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
arch/powerpc/mm/hugetlbpage.c +16 -2
@@ -330,10 +330,24 @@ static void free_hugepd_range(struct mmu get_hugepd_cache_index(pdshift - shift)); } -static void hugetlb_free_pte_range (struct mmu_gather *tlb,pmd_t *pmd,unsigned long addr) +static void hugetlb_free_pte_range (struct mmu_gather *tlb,pmd_t *pmd, +unsigned long addr,unsigned long end, +unsigned long floor,unsigned long ceiling) { +unsigned long start = addr;pgtable_t token =pmd_pgtable (*pmd); + start &=PMD_MASK ; +if (start < floor) +return ; +if (ceiling) { + ceiling &=PMD_MASK ; +if (!ceiling) +return ; + } +if (end -1 > ceiling -1 ) +return ; +pmd_clear (pmd);pte_free_tlb (tlb, token, addr);mm_dec_nr_ptes (tlb->mm);
@@ -363,7 +377,7 @@ static void hugetlb_free_pmd_range(struc*/ WARN_ON (!IS_ENABLED (CONFIG_PPC_8xx)); -hugetlb_free_pte_range (tlb, pmd, addr); +hugetlb_free_pte_range (tlb, pmd, addr, end, floor, ceiling);continue ; }
Greg Kroah-Hartman
maintainerPATCH 290/391 powerpc/powermac: Fix low_sleep_handler with KUAP and KUEP
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 2c637d2df4ee4830e9d3eb2bd5412250522ce96e upstream.
low_sleep_handler() has an hardcoded restore of segment registers that doesn't take KUAP and KUEP into account.
Use head_32's load_segment_registers() routine instead.
--- arch/powerpc/kernel/head_32.S | 2 +- arch/powerpc/platforms/powermac/sleep.S | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/powerpc/kernel/head_32.S +1 -1
@@ -1002,7 +1002,7 @@ BEGIN_MMU_FTR_SECTION END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) blr -load_segment_registers: +_GLOBAL(load_segment_registers) li r0, NUM_USER_SEGMENTS /* load up user segment register values */ mtctr r0 /* for context 0 */ li r3, 0 /* Kp = 0, Ks = 0, VSID = 0 */
arch/powerpc/platforms/powermac/sleep.S +1 -8
@@ -294,14 +294,7 @@ grackle_wake_up: * we do any r1 memory access as we are not sure they * are in a sane state above the first 256Mb region */ - li r0,16 /* load up segment register values */ - mtctr r0 /* for context 0 */ - lis r3,0x2000 /* Ku = 1, VSID = 0 */ - li r4,0 -3: mtsrin r3,r4 - addi r3,r3,0x111 /* increment VSID */ - addis r4,r4,0x1000 /* address of next segment */ - bdnz 3b + bl load_segment_registers sync isync
Greg Kroah-Hartman
maintainerPATCH 293/391 powerpc/32: Fix vmap stack - Do not activate MMU before reading task struct
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit c118c7303ad528be8ff2aea8cd1ee15452c763f0 upstream.
We need r1 to be properly set before activating MMU, so reading task_struct->stack must be done with MMU off.
This means we need an additional register to play with MSR bits while r11 now points to the stack. For that, move r10 back to CR (As is already done for hash MMU) and use r10.
We still don't have r1 correct yet when we activate MMU. It is done in following patch.
--- arch/powerpc/kernel/head_32.S | 6 ------ arch/powerpc/kernel/head_32.h | 31 ++++++------------------------- 2 files changed, 6 insertions(+), 31 deletions(-)
arch/powerpc/kernel/head_32.S +0 -6
@@ -274,14 +274,8 @@ __secondary_hold_acknowledge: DO_KVM 0x200 MachineCheck: EXCEPTION_PROLOG_0 -#ifdef CONFIG_VMAP_STACK - li r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ - mtmsr r11 - isync -#endif #ifdef CONFIG_PPC_CHRP mfspr r11, SPRN_SPRG_THREAD - tovirt_vmstack r11, r11 lwz r11, RTAS_SP(r11) cmpwi cr1, r11, 0 bne cr1, 7f
arch/powerpc/kernel/head_32.h +6 -25
@@ -39,24 +39,13 @@ .endm .macro EXCEPTION_PROLOG_1 for_rtas=0 -#ifdef CONFIG_VMAP_STACK - .ifeq \for_rtas - li r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ - mtmsr r11 - isync - .endifsubi r11, r1,INT_FRAME_SIZE /* use r1 if kernel */ -#else - tophys(r11,r1) /* use tophys(r1) if kernel */ - subi r11, r11, INT_FRAME_SIZE /* alloc exc. frame */ -#endif beq 1f mfspr r11,SPRN_SPRG_THREAD - tovirt_vmstack r11, r11 lwz r11,TASK_STACK-THREAD(r11) addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE - tophys_novmstack r11, r11 1: + tophys_novmstack r11, r11 #ifdef CONFIG_VMAP_STACK mtcrf 0x7f, r11 bt 32 - THREAD_ALIGN_SHIFT, stack_overflow
@@ -64,12 +53,11 @@ .endm .macro EXCEPTION_PROLOG_2 handle_dar_dsisr=0 -#if defined(CONFIG_VMAP_STACK ) && defined(CONFIG_PPC_BOOK3S ) -BEGIN_MMU_FTR_SECTION +#ifdef CONFIG_VMAP_STACK mtcr r10 -FTR_SECTION_ELSE - stw r10, _CCR(r11) -ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_HPTE_TABLE) + li r10, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ + mtmsr r10 + isync#else stw r10,_CCR(r11) /* save registers */#endif
@@ -77,11 +65,9 @@ ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_HP stw r12,GPR12(r11) stw r9,GPR9(r11) stw r10,GPR10(r11) -#if defined(CONFIG_VMAP_STACK ) && defined(CONFIG_PPC_BOOK3S ) -BEGIN_MMU_FTR_SECTION +#ifdef CONFIG_VMAP_STACK mfcr r10 stw r10, _CCR(r11) -END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) #endif mfspr r12,SPRN_SPRG_SCRATCH1 stw r12,GPR11(r11)
@@ -97,11 +83,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_T stw r10, _DSISR(r11) .endif lwz r9, SRR1(r12) -#if defined(CONFIG_VMAP_STACK ) && defined(CONFIG_PPC_BOOK3S ) -BEGIN_MMU_FTR_SECTION andi. r10, r9, MSR_PR -END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) -#endif lwz r12, SRR0(r12)#else mfspr r12,SPRN_SRR0
@@ -328,7 +310,6 @@ label:#ifdef CONFIG_VMAP_STACK #ifdef CONFIG_SMP mfspr r11,SPRN_SPRG_THREAD - tovirt(r11, r11) lwz r11, TASK_CPU - THREAD(r11) slwi r11, r11, 3 addis r11, r11, emergency_ctx@ha
Greg Kroah-Hartman
maintainerPATCH 291/391 powerpc/mce: Avoid nmi_enter/exit in real mode on pseries hash
In reply to Greg Kroah-HartmanFrom: Ganesh Goudar <[email protected]>
commit 8d0e2101274358d9b6b1f27232b40253ca48bab5 upstream.
Use of nmi_enter/exit in real mode handler causes the kernel to panic and reboot on injecting SLB mutihit on pseries machine running in hash MMU mode, because these calls try to accesses memory outside RMO region in real mode handler where translation is disabled.
Add check to not to use these calls on pseries machine running in hash MMU mode.
--- arch/powerpc/kernel/mce.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/kernel/mce.c +3 -4
@@ -591,12 +591,11 @@ EXPORT_SYMBOL_GPL(machine_check_print_evlong notrace machine_check_early (struct pt_regs *regs) {long handled =0 ; -bool nested =in_nmi ();u8 ftrace_enabled =this_cpu_get_ftrace_enabled ();this_cpu_set_ftrace_enabled (0 ); - -if (!nested) +/* Do not use nmi_enter/exit for pseries hpte guest */ +if (radix_enabled () || !firmware_has_feature (FW_FEATURE_LPAR ))nmi_enter ();hv_nmi_check_nonrecoverable (regs);
@@ -607,7 +606,7 @@ long notrace machine_check_early(structif (ppc_md.machine_check_early) handled = ppc_md.machine_check_early (regs); -if (!nested) +if (radix_enabled () || !firmware_has_feature (FW_FEATURE_LPAR ))nmi_exit ();this_cpu_set_ftrace_enabled (ftrace_enabled);
Greg Kroah-Hartman
maintainerPATCH 261/391 tracing: Fix race in trace_open and buffer resize call
In reply to Greg Kroah-HartmanFrom: Gaurav Kohli <[email protected]>
commit bbeb97464eefc65f506084fd9f18f21653e01137 upstream.
Below race can come, if trace_open and resize of
cpu buffer is running parallely on different cpus
CPUX CPUY
ring_buffer_resize atomic_read(&buffer->resize_disabled)
tracing_opentracing_reset_online_cpus ring_buffer_reset_cpurb_reset_cpu
rb_update_pages remove/insert pages
resetting pointer
This race can cause data abort or some times infinte loop in rb_remove_pages and rb_insert_pages while checking pages for sanity.
Take buffer lock to fix this.
--- kernel/trace/ring_buffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/trace/ring_buffer.c +10 -0
@@ -4866,6 +4866,9 @@ void ring_buffer_reset_cpu(struct trace_if (!cpumask_test_cpu (cpu, buffer->cpumask))return ; +/* prevent another thread from changing buffer sizes */ +mutex_lock (&buffer->mutex); +atomic_inc (&cpu_buffer->resize_disabled);atomic_inc (&cpu_buffer->record_disabled);
@@ -4876,6 +4879,8 @@ void ring_buffer_reset_cpu(struct trace_atomic_dec (&cpu_buffer->record_disabled);atomic_dec (&cpu_buffer->resize_disabled); + +mutex_unlock (&buffer->mutex); }EXPORT_SYMBOL_GPL (ring_buffer_reset_cpu);
@@ -4889,6 +4894,9 @@ void ring_buffer_reset_online_cpus(strucstruct ring_buffer_per_cpu *cpu_buffer;int cpu; +/* prevent another thread from changing buffer sizes */ +mutex_lock (&buffer->mutex); +for_each_online_buffer_cpu (buffer, cpu) { cpu_buffer = buffer->buffers[cpu];
@@ -4907,6 +4915,8 @@ void ring_buffer_reset_online_cpus(strucatomic_dec (&cpu_buffer->record_disabled);atomic_dec (&cpu_buffer->resize_disabled); } + +mutex_unlock (&buffer->mutex); }/**
Greg Kroah-Hartman
maintainerPATCH 273/391 iio: adc: gyroadc: fix leak of device node iterator
In reply to Greg Kroah-HartmanFrom: Tobias Jordan <[email protected]>
commit da4410d4078ba4ead9d6f1027d6db77c5a74ecee upstream.
Add missing of_node_put calls when exiting the for_each_child_of_node loop in rcar_gyroadc_parse_subdevs early.
Also add goto-exception handling for the error paths in that loop.
--- drivers/iio/adc/rcar-gyroadc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/iio/adc/rcar-gyroadc.c +15 -6
@@ -357,7 +357,7 @@ static int rcar_gyroadc_parse_subdevs(st num_channels =ARRAY_SIZE (rcar_gyroadc_iio_channels_3);break ;default : -return -EINVAL ; + goto err_e_inval; }/*
@@ -374,7 +374,7 @@ static int rcar_gyroadc_parse_subdevs(stdev_err (dev,"Failed to get child reg property of ADC \"%pOFn\".\n" , child); -return ret; + goto err_of_node_put; }/* Channel number is too high. */
@@ -382,7 +382,7 @@ static int rcar_gyroadc_parse_subdevs(stdev_err (dev,"Only %i channels supported with %pOFn, but reg = <%i>.\n" , num_channels, child, reg); -return -EINVAL ; + goto err_e_inval; } }
@@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(stdev_err (dev,"Channel %i uses different ADC mode than the rest.\n" , reg); -return -EINVAL ; + goto err_e_inval; }/* Channel is valid, grab the regulator. */
@@ -401,7 +401,8 @@ static int rcar_gyroadc_parse_subdevs(stif (IS_ERR (vref)) {dev_dbg (dev,"Channel %i 'vref' supply not connected.\n" , reg); -return PTR_ERR (vref); + ret =PTR_ERR (vref); + goto err_of_node_put; } priv->vref[reg] = vref;
@@ -425,8 +426,10 @@ static int rcar_gyroadc_parse_subdevs(st* attached to the GyroADC at a time, so if we found it, * we can stop parsing here. */ -if (childmode ==RCAR_GYROADC_MODE_SELECT_1_MB88101A ) +if (childmode ==RCAR_GYROADC_MODE_SELECT_1_MB88101A ) { +of_node_put (child);break ; + } }if (first) {
@@ -435,6 +438,12 @@ static int rcar_gyroadc_parse_subdevs(st }return 0 ; + +err_e_inval: + ret = -EINVAL ; +err_of_node_put: +of_node_put (child); +return ret; }static void rcar_gyroadc_deinit_supplies (struct iio_dev *indio_dev)
Greg Kroah-Hartman
maintainerPATCH 272/391 iio:light:si1145: Fix timestamp alignment and prevent data leak.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 0456ecf34d466261970e0ff92b2b9c78a4908637 upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses a 24 byte array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable array in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc so no data can leak appart from previous readings.
Depending on the enabled channels, the location of the timestamp can be at various aligned offsets through the buffer. As such we any use of a structure to enforce this alignment would incorrectly suggest a single location for the timestamp. Comments adjusted to express this clearly in the code.
--- drivers/iio/light/si1145.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/iio/light/si1145.c +11 -8
@@ -168,6 +168,7 @@ struct si1145_part_info {* @part_info: Part information * @trig: Pointer to iio trigger * @meas_rate: Value of MEAS_RATE register. Only set in HW in auto mode +* @buffer: Used to pack data read from sensor. */ struct si1145_data {struct i2c_client *client;
@@ -179,6 +180,14 @@ struct si1145_data {bool autonomous;struct iio_trigger *trig;int meas_rate; +/* +* Ensure timestamp will be naturally aligned if present. +* Maximum buffer size (may be only partly used if not all +* channels are enabled): +* 6*2 bytes channels data + 4 bytes alignment + +* 8 bytes timestamp +*/ +u8 buffer[24 ]__aligned(8) ; };/*
@@ -440,12 +449,6 @@ static irqreturn_t si1145_trigger_handlestruct iio_poll_func *pf = private;struct iio_dev *indio_dev = pf->indio_dev;struct si1145_data *data =iio_priv (indio_dev); -/* -* Maximum buffer size: -* 6*2 bytes channels data + 4 bytes alignment + -* 8 bytes timestamp -*/ -u8 buffer[24 ];int i, j =0 ;int ret;u8 irq_status =0 ;
@@ -478,7 +481,7 @@ static irqreturn_t si1145_trigger_handle ret =i2c_smbus_read_i2c_block_data_or_emulated ( data->client, indio_dev->channels[i].address, -sizeof (u16) * run, &buffer[j]); +sizeof (u16) * run, &data->buffer[j]);if (ret <0 ) goto done; j += run *sizeof (u16);
@@ -493,7 +496,7 @@ static irqreturn_t si1145_trigger_handle goto done; } -iio_push_to_buffers_with_timestamp (indio_dev, buffer, +iio_push_to_buffers_with_timestamp (indio_dev, data->buffer,iio_get_time_ns (indio_dev)); done:
Greg Kroah-Hartman
maintainerPATCH 298/391 gfs2: Make sure we dont miss any delayed withdraws
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 5a61ae1402f15276ee4e003e198aab816958ca69 upstream.
Commit ca399c96e96e changes gfs2_log_flush to not withdraw the filesystem while holding the log flush lock, but it fails to check if the filesystem needs to be withdrawn once the log flush lock has been released. Likewise, commit f05b86db314d depends on gfs2_log_flush to trigger for delayed withdraws. Add that and clean up the code flow somewhat.
In gfs2_put_super, add a check for delayed withdraws that have been missed to prevent these kinds of bugs in the future.
--- fs/gfs2/log.c | 61 ++++++++++++++++++++++++++++---------------------------- fs/gfs2/super.c | 2 + fs/gfs2/util.h | 10 +++++++++ 3 files changed, 43 insertions(+), 30 deletions(-)
fs/gfs2/log.c +31 -30
@@ -954,10 +954,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp goto out;/* Log might have been flushed while we waited for the flush lock */ -if (gl && !test_bit (GLF_LFLUSH , &gl->gl_flags)) { -up_write (&sdp->sd_log_flush_lock); -return ; - } +if (gl && !test_bit (GLF_LFLUSH , &gl->gl_flags)) + goto out;trace_gfs2_log_flush (sdp,1 , flags);if (flags &GFS2_LOG_HEAD_FLUSH_SHUTDOWN )
@@ -971,25 +969,25 @@ void gfs2_log_flush(struct gfs2_sbd *sdpif (unlikely (state ==SFS_FROZEN ))if (gfs2_assert_withdraw_delayed (sdp, !tr->tr_num_buf_new && !tr->tr_num_databuf_new)) - goto out; + goto out_withdraw; }if (unlikely (state ==SFS_FROZEN ))if (gfs2_assert_withdraw_delayed (sdp, !sdp->sd_log_num_revoke)) - goto out; + goto out_withdraw;if (gfs2_assert_withdraw_delayed (sdp, sdp->sd_log_num_revoke == sdp->sd_log_committed_revoke)) - goto out; + goto out_withdraw;gfs2_ordered_write (sdp);if (gfs2_withdrawn (sdp)) - goto out; + goto out_withdraw;lops_before_commit (sdp, tr);if (gfs2_withdrawn (sdp)) - goto out; + goto out_withdraw;gfs2_log_submit_bio (&sdp->sd_log_bio,REQ_OP_WRITE );if (gfs2_withdrawn (sdp)) - goto out; + goto out_withdraw;if (sdp->sd_log_head != sdp->sd_log_flush_head) {log_flush_wait (sdp);
@@ -1000,7 +998,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdplog_write_header (sdp, flags); }if (gfs2_withdrawn (sdp)) - goto out; + goto out_withdraw;lops_after_commit (sdp, tr);gfs2_log_lock (sdp);
@@ -1020,7 +1018,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdpif (!sdp->sd_log_idle) {empty_ail1_list (sdp);if (gfs2_withdrawn (sdp)) - goto out; + goto out_withdraw;atomic_dec (&sdp->sd_log_blks_free);/* Adjust for unreserved buffer */ trace_gfs2_log_blocks (sdp,-1 );log_write_header (sdp, flags);
@@ -1033,27 +1031,30 @@ void gfs2_log_flush(struct gfs2_sbd *sdpatomic_set (&sdp->sd_freeze_state,SFS_FROZEN ); } -out: -if (gfs2_withdrawn (sdp)) { -trans_drain (tr); -/** -* If the tr_list is empty, we're withdrawing during a log -* flush that targets a transaction, but the transaction was -* never queued onto any of the ail lists. Here we add it to -* ail1 just so that ail_drain() will find and free it. -*/ -spin_lock (&sdp->sd_ail_lock); -if (tr &&list_empty (&tr->tr_list)) -list_add (&tr->tr_list, &sdp->sd_ail1_list); -spin_unlock (&sdp->sd_ail_lock); -ail_drain (sdp);/* frees all transactions */ - tr =NULL ; - } - +out_end:trace_gfs2_log_flush (sdp,0 , flags); +out:up_write (&sdp->sd_log_flush_lock); -gfs2_trans_free (sdp, tr); +if (gfs2_withdrawing (sdp)) +gfs2_withdraw (sdp); +return ; + +out_withdraw: +trans_drain (tr); +/** +* If the tr_list is empty, we're withdrawing during a log +* flush that targets a transaction, but the transaction was +* never queued onto any of the ail lists. Here we add it to +* ail1 just so that ail_drain() will find and free it. +*/ +spin_lock (&sdp->sd_ail_lock); +if (tr &&list_empty (&tr->tr_list)) +list_add (&tr->tr_list, &sdp->sd_ail1_list); +spin_unlock (&sdp->sd_ail_lock); +ail_drain (sdp);/* frees all transactions */ + tr =NULL ; + goto out_end; }/**
fs/gfs2/super.c +2 -0
@@ -702,6 +702,8 @@ restart:if (error)gfs2_io_error (sdp); } +WARN_ON (gfs2_withdrawing (sdp)); +/* At this point, we're through modifying the disk */ /* Release stuff */
fs/gfs2/util.h +10 -0
@@ -205,6 +205,16 @@ static inline bool gfs2_withdrawn(structtest_bit (SDF_WITHDRAWING , &sdp->sd_flags); } +/** +* gfs2_withdrawing - check if a withdraw is pending +* @sdp: the superblock +*/ +static inline bool gfs2_withdrawing (struct gfs2_sbd *sdp) +{ +return test_bit (SDF_WITHDRAWING , &sdp->sd_flags) && + !test_bit (SDF_WITHDRAWN , &sdp->sd_flags); +} +#define gfs2_tune_get (sdp, field) \ gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
Greg Kroah-Hartman
maintainerPATCH 294/391 powerpc/32: Fix vmap stack - Properly set r1 before activating MMU
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit da7bb43ab9da39bcfed0d146ce94e1f0cbae4ca0 upstream.
We need r1 to be properly set before activating MMU, otherwise any new exception taken while saving registers into the stack in exception prologs will use the user stack, which is wrong and will even lockup or crash when KUAP is selected.
Do that by switching the meaning of r11 and r1 until we have saved r1 to the stack: copy r1 into r11 and setup the new stack pointer in r1. To avoid complicating and impacting all generic and specific prolog code (and more), copy back r1 into r11 once r11 is save onto the stack.
We could get rid of copying r1 back and forth at the cost of rewriting everything to use r1 instead of r11 all the way when CONFIG_VMAP_STACK is set, but the effort is probably not worth it.
--- arch/powerpc/kernel/head_32.h | 43 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
arch/powerpc/kernel/head_32.h +29 -14
@@ -39,15 +39,24 @@ .endm .macro EXCEPTION_PROLOG_1 for_rtas=0 +#ifdef CONFIG_VMAP_STACK +mr r11, r1 + subi r1, r1, INT_FRAME_SIZE /* use r1 if kernel */ + beq 1f + mfspr r1,SPRN_SPRG_THREAD + lwz r1,TASK_STACK-THREAD(r1) + addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE +#else subi r11, r1, INT_FRAME_SIZE /* use r1 if kernel */ beq 1f mfspr r11,SPRN_SPRG_THREAD lwz r11,TASK_STACK-THREAD(r11) addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE +#endif 1: tophys_novmstack r11, r11 #ifdef CONFIG_VMAP_STACK - mtcrf 0x7f, r11 + mtcrf 0x7f, r1 bt 32 - THREAD_ALIGN_SHIFT, stack_overflow #endif .endm
@@ -62,6 +71,15 @@ stw r10,_CCR(r11) /* save registers */#endif mfspr r10, SPRN_SPRG_SCRATCH0 +#ifdef CONFIG_VMAP_STACK + stw r11,GPR1(r1) + stw r11,0(r1) + mr r11, r1 +#else + stw r1,GPR1(r11) + stw r1,0(r11) + tovirt(r1, r11) /* set new kernel sp */ +#endif stw r12,GPR12(r11) stw r9,GPR9(r11) stw r10,GPR10(r11)
@@ -89,9 +107,6 @@mfspr r12,SPRN_SRR0 mfspr r9,SPRN_SRR1 #endif - stw r1,GPR1(r11) - stw r1,0(r11) - tovirt_novmstack r1, r11 /* set new kernel sp */ #ifdef CONFIG_40x rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ #else
@@ -309,19 +324,19 @@ label: .macro vmap_stack_overflow_exception#ifdef CONFIG_VMAP_STACK #ifdef CONFIG_SMP -mfspr r11,SPRN_SPRG_THREAD - lwz r11, TASK_CPU - THREAD(r11) - slwi r11, r11, 3 - addis r11, r11, emergency_ctx@ha +mfspr r1,SPRN_SPRG_THREAD + lwz r1, TASK_CPU - THREAD(r1) + slwi r1, r1, 3 + addis r1, r1, emergency_ctx@ha #else - lis r11, emergency_ctx@ha + lis r1, emergency_ctx@ha #endif - lwz r11, emergency_ctx@l(r11) - cmpwi cr1, r11, 0 + lwz r1, emergency_ctx@l(r1) + cmpwi cr1, r1, 0 bne cr1, 1f - lis r11, init_thread_union@ha - addi r11, r11, init_thread_union@l -1: addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE + lis r1, init_thread_union@ha + addi r1, r1, init_thread_union@l +1: addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE EXCEPTION_PROLOG_2 SAVE_NVGPRS(r11) addi r3, r1, STACK_FRAME_OVERHEAD
Greg Kroah-Hartman
maintainerPATCH 267/391 drm/shme-helpers: Fix dma_buf_mmap forwarding bug
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
commit f49a51bfdc8ea717c97ccd4cc98b7e6daaa5553a upstream.
When we forward an mmap to the dma_buf exporter, they get to own everything. Unfortunately drm_gem_mmap_obj() overwrote vma->vm_private_data after the driver callback, wreaking the exporter complete. This was noticed because vb2_common_vm_close blew up on mali gpu with panfrost after commit 26d3ac3cb04d ("drm/shmem-helpers: Redirect mmap for imported dma-buf").
Unfortunately drm_gem_mmap_obj also acquires a surplus reference that we need to drop in shmem helpers, which is a bit of a mislayer situation. Maybe the entire dma_buf_mmap forwarding should be pulled into core gem code.
Note that the only two other drivers which forward mmap in their own code (etnaviv and exynos) get this somewhat right by overwriting the gem mmap code. But they seem to still have the leak. This might be a good excuse to move these drivers over to shmem helpers completely.
--- drivers/gpu/drm/drm_gem.c | 4 ++-- drivers/gpu/drm/drm_gem_shmem_helper.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -2
@@ -1085,6 +1085,8 @@ int drm_gem_mmap_obj(struct drm_gem_obje*/ drm_gem_object_get (obj); + vma->vm_private_data = obj; +if (obj->funcs && obj->funcs->mmap) { ret = obj->funcs->mmap (obj, vma);if (ret) {
@@ -1107,8 +1109,6 @@ int drm_gem_mmap_obj(struct drm_gem_obje vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); } - vma->vm_private_data = obj; -return 0 ; }EXPORT_SYMBOL (drm_gem_mmap_obj);
drivers/gpu/drm/drm_gem_shmem_helper.c +6 -1
@@ -594,8 +594,13 @@ int drm_gem_shmem_mmap(struct drm_gem_ob/* Remove the fake offset */ vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); -if (obj->import_attach) +if (obj->import_attach) { +/* Drop the reference drm_gem_mmap_obj() acquired.*/ +drm_gem_object_put (obj); + vma->vm_private_data =NULL ; +return dma_buf_mmap (obj->dma_buf, vma,0 ); + } shmem =to_drm_gem_shmem_obj (obj);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Greg Kroah-Hartman
maintainerPATCH 266/391 vdpa_sim: Fix DMA mask
In reply to Greg Kroah-HartmanFrom: Laurent Vivier <[email protected]>
commit 1eca16b231570c8ae57fb91fdfbc48eb52c6a93b upstream.
Since commit f959dcd6ddfd
("dma-direct: Fix potential NULL pointer dereference") an error is reported when we load vdpa_sim and virtio-vdpa:
[ 129.351207] net eth0: Unexpected TXQ (0) queue failure: -12
It seems that dma_mask is not initialized.
This patch initializes dma_mask() and calls dma_set_mask_and_coherent() to fix the problem.
Full log:
[ 128.548628] ------------[ cut here ]------------ [ 128.553268] WARNING: CPU: 23 PID: 1105 at kernel/dma/mapping.c:149 dma_map_page_attrs+0x14c/0x1d0 [ 128.562139] Modules linked in: virtio_net net_failover failover virtio_vdpa vdpa_sim vringh vhost_iotlb vdpa xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 nft_compat nft_counter nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink tun bridge stp llc iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi rfkill intel_rapl_msr intel_rapl_common isst_if_common sunrpc skx_edac nfit libnvdimm x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm mgag200 i2c_algo_bit irqbypass drm_kms_helper crct10dif_pclmul crc32_pclmul syscopyarea ghash_clmulni_intel iTCO_wdt sysfillrect iTCO_vendor_support sysimgblt rapl fb_sys_fops dcdbas intel_cstate drm acpi_ipmi ipmi_si mei_me dell_smbios intel_uncore ipmi_devintf mei i2c_i801 dell_wmi_descriptor wmi_bmof pcspkr lpc_ich i2c_smbus ipmi_msghandler acpi_power_meter ip_tables xfs libcrc32c sd_mod t10_pi sg ahci libahci libata megaraid_sas tg3 crc32c_intel wmi dm_mirror dm_region_hash dm_log [ 128.562188] dm_mod [ 128.651334] CPU: 23 PID: 1105 Comm: NetworkManager Tainted: G S I 5.10.0-rc1+ #59 [ 128.659939] Hardware name: Dell Inc. PowerEdge R440/04JN2K, BIOS 2.8.1 06/30/2020 [ 128.667419] RIP: 0010:dma_map_page_attrs+0x14c/0x1d0 [ 128.672384] Code: 1c 25 28 00 00 00 0f 85 97 00 00 00 48 83 c4 10 5b 5d 41 5c 41 5d c3 4c 89 da eb d7 48 89 f2 48 2b 50 18 48 89 d0 eb 8d 0f 0b <0f> 0b 48 c7 c0 ff ff ff ff eb c3 48 89 d9 48 8b 40 40 e8 2d a0 aa [ 128.691131] RSP: 0018:ffffae0f0151f3c8 EFLAGS: 00010246 [ 128.696357] RAX: ffffffffc06b7400 RBX: 00000000000005fa RCX: 0000000000000000 [ 128.703488] RDX: 0000000000000040 RSI: ffffcee3c7861200 RDI: ffff9e2bc16cd000 [ 128.710620] RBP: 0000000000000000 R08: 0000000000000002 R09: 0000000000000000 [ 128.717754] R10: 0000000000000002 R11: 0000000000000000 R12: ffff9e472cb291f8 [ 128.724886] R13: ffff9e2bc14da780 R14: ffff9e472bc20000 R15: ffff9e2bc1b14940 [ 128.732020] FS: 00007f887bae23c0(0000) GS:ffff9e4ac01c0000(0000) knlGS:0000000000000000 [ 128.740105] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 128.745852] CR2: 0000562bc09de998 CR3: 00000003c156c006 CR4: 00000000007706e0 [ 128.752982] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 128.760114] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 128.767247] PKRU: 55555554 [ 128.769961] Call Trace: [ 128.772418] virtqueue_add+0x81e/0xb00 [ 128.776176] virtqueue_add_inbuf_ctx+0x26/0x30 [ 128.780625] try_fill_recv+0x3a2/0x6e0 [virtio_net] [ 128.785509] virtnet_open+0xf9/0x180 [virtio_net] [ 128.790217] __dev_open+0xe8/0x180 [ 128.793620] __dev_change_flags+0x1a7/0x210 [ 128.797808] dev_change_flags+0x21/0x60 [ 128.801646] do_setlink+0x328/0x10e0 [ 128.805227] ? __nla_validate_parse+0x121/0x180 [ 128.809757] ? __nla_parse+0x21/0x30 [ 128.813338] ? inet6_validate_link_af+0x5c/0xf0 [ 128.817871] ? cpumask_next+0x17/0x20 [ 128.821535] ? __snmp6_fill_stats64.isra.54+0x6b/0x110 [ 128.826676] ? __nla_validate_parse+0x47/0x180 [ 128.831120] __rtnl_newlink+0x541/0x8e0 [ 128.834962] ? __nla_reserve+0x38/0x50 [ 128.838713] ? security_sock_rcv_skb+0x2a/0x40 [ 128.843158] ? netlink_deliver_tap+0x2c/0x1e0 [ 128.847518] ? netlink_attachskb+0x1d8/0x220 [ 128.851793] ? skb_queue_tail+0x1b/0x50 [ 128.855641] ? fib6_clean_node+0x43/0x170 [ 128.859652] ? _cond_resched+0x15/0x30 [ 128.863406] ? kmem_cache_alloc_trace+0x3a3/0x420 [ 128.868110] rtnl_newlink+0x43/0x60 [ 128.871602] rtnetlink_rcv_msg+0x12c/0x380 [ 128.875701] ? rtnl_calcit.isra.39+0x110/0x110 [ 128.880147] netlink_rcv_skb+0x50/0x100 [ 128.883987] netlink_unicast+0x1a5/0x280 [ 128.887913] netlink_sendmsg+0x23d/0x470 [ 128.891839] sock_sendmsg+0x5b/0x60 [ 128.895331] ____sys_sendmsg+0x1ef/0x260 [ 128.899255] ? copy_msghdr_from_user+0x5c/0x90 [ 128.903702] ___sys_sendmsg+0x7c/0xc0 [ 128.907369] ? dev_forward_change+0x130/0x130 [ 128.911731] ? sysctl_head_finish.part.29+0x24/0x40 [ 128.916616] ? new_sync_write+0x11f/0x1b0 [ 128.920628] ? mntput_no_expire+0x47/0x240 [ 128.924727] __sys_sendmsg+0x57/0xa0 [ 128.928309] do_syscall_64+0x33/0x40 [ 128.931887] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 128.936937] RIP: 0033:0x7f88792e3857 [ 128.940518] Code: c3 66 90 41 54 41 89 d4 55 48 89 f5 53 89 fb 48 83 ec 10 e8 0b ed ff ff 44 89 e2 48 89 ee 89 df 41 89 c0 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 48 89 44 24 08 e8 44 ed ff ff 48 [ 128.959263] RSP: 002b:00007ffdca60dea0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e [ 128.966827] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f88792e3857 [ 128.973960] RDX: 0000000000000000 RSI: 00007ffdca60def0 RDI: 000000000000000c [ 128.981095] RBP: 00007ffdca60def0 R08: 0000000000000000 R09: 0000000000000000 [ 128.988224] R10: 0000000000000001 R11: 0000000000000293 R12: 0000000000000000 [ 128.995357] R13: 0000000000000000 R14: 00007ffdca60e0a8 R15: 00007ffdca60e09c [ 129.002492] CPU: 23 PID: 1105 Comm: NetworkManager Tainted: G S I 5.10.0-rc1+ #59 [ 129.011093] Hardware name: Dell Inc. PowerEdge R440/04JN2K, BIOS 2.8.1 06/30/2020 [ 129.018571] Call Trace: [ 129.021027] dump_stack+0x57/0x6a [ 129.024346] __warn.cold.14+0xe/0x3d [ 129.027925] ? dma_map_page_attrs+0x14c/0x1d0 [ 129.032283] report_bug+0xbd/0xf0 [ 129.035602] handle_bug+0x44/0x80 [ 129.038922] exc_invalid_op+0x13/0x60 [ 129.042589] asm_exc_invalid_op+0x12/0x20 [ 129.046602] RIP: 0010:dma_map_page_attrs+0x14c/0x1d0 [ 129.051566] Code: 1c 25 28 00 00 00 0f 85 97 00 00 00 48 83 c4 10 5b 5d 41 5c 41 5d c3 4c 89 da eb d7 48 89 f2 48 2b 50 18 48 89 d0 eb 8d 0f 0b <0f> 0b 48 c7 c0 ff ff ff ff eb c3 48 89 d9 48 8b 40 40 e8 2d a0 aa [ 129.070311] RSP: 0018:ffffae0f0151f3c8 EFLAGS: 00010246 [ 129.075536] RAX: ffffffffc06b7400 RBX: 00000000000005fa RCX: 0000000000000000 [ 129.082669] RDX: 0000000000000040 RSI: ffffcee3c7861200 RDI: ffff9e2bc16cd000 [ 129.089803] RBP: 0000000000000000 R08: 0000000000000002 R09: 0000000000000000 [ 129.096936] R10: 0000000000000002 R11: 0000000000000000 R12: ffff9e472cb291f8 [ 129.104068] R13: ffff9e2bc14da780 R14: ffff9e472bc20000 R15: ffff9e2bc1b14940 [ 129.111200] virtqueue_add+0x81e/0xb00 [ 129.114952] virtqueue_add_inbuf_ctx+0x26/0x30 [ 129.119399] try_fill_recv+0x3a2/0x6e0 [virtio_net] [ 129.124280] virtnet_open+0xf9/0x180 [virtio_net] [ 129.128984] __dev_open+0xe8/0x180 [ 129.132390] __dev_change_flags+0x1a7/0x210 [ 129.136575] dev_change_flags+0x21/0x60 [ 129.140415] do_setlink+0x328/0x10e0 [ 129.143994] ? __nla_validate_parse+0x121/0x180 [ 129.148528] ? __nla_parse+0x21/0x30 [ 129.152107] ? inet6_validate_link_af+0x5c/0xf0 [ 129.156639] ? cpumask_next+0x17/0x20 [ 129.160306] ? __snmp6_fill_stats64.isra.54+0x6b/0x110 [ 129.165443] ? __nla_validate_parse+0x47/0x180 [ 129.169890] __rtnl_newlink+0x541/0x8e0 [ 129.173731] ? __nla_reserve+0x38/0x50 [ 129.177483] ? security_sock_rcv_skb+0x2a/0x40 [ 129.181928] ? netlink_deliver_tap+0x2c/0x1e0 [ 129.186286] ? netlink_attachskb+0x1d8/0x220 [ 129.190560] ? skb_queue_tail+0x1b/0x50 [ 129.194401] ? fib6_clean_node+0x43/0x170 [ 129.198411] ? _cond_resched+0x15/0x30 [ 129.202163] ? kmem_cache_alloc_trace+0x3a3/0x420 [ 129.206869] rtnl_newlink+0x43/0x60 [ 129.210361] rtnetlink_rcv_msg+0x12c/0x380 [ 129.214462] ? rtnl_calcit.isra.39+0x110/0x110 [ 129.218908] netlink_rcv_skb+0x50/0x100 [ 129.222747] netlink_unicast+0x1a5/0x280 [ 129.226672] netlink_sendmsg+0x23d/0x470 [ 129.230599] sock_sendmsg+0x5b/0x60 [ 129.234090] ____sys_sendmsg+0x1ef/0x260 [ 129.238015] ? copy_msghdr_from_user+0x5c/0x90 [ 129.242461] ___sys_sendmsg+0x7c/0xc0 [ 129.246128] ? dev_forward_change+0x130/0x130 [ 129.250487] ? sysctl_head_finish.part.29+0x24/0x40 [ 129.255368] ? new_sync_write+0x11f/0x1b0 [ 129.259381] ? mntput_no_expire+0x47/0x240 [ 129.263478] __sys_sendmsg+0x57/0xa0 [ 129.267058] do_syscall_64+0x33/0x40 [ 129.270639] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 129.275689] RIP: 0033:0x7f88792e3857 [ 129.279268] Code: c3 66 90 41 54 41 89 d4 55 48 89 f5 53 89 fb 48 83 ec 10 e8 0b ed ff ff 44 89 e2 48 89 ee 89 df 41 89 c0 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 48 89 44 24 08 e8 44 ed ff ff 48 [ 129.298015] RSP: 002b:00007ffdca60dea0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e [ 129.305581] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f88792e3857 [ 129.312712] RDX: 0000000000000000 RSI: 00007ffdca60def0 RDI: 000000000000000c [ 129.319846] RBP: 00007ffdca60def0 R08: 0000000000000000 R09: 0000000000000000 [ 129.326978] R10: 0000000000000001 R11: 0000000000000293 R12: 0000000000000000 [ 129.334109] R13: 0000000000000000 R14: 00007ffdca60e0a8 R15: 00007ffdca60e09c [ 129.341249] ---[ end trace c551e8028fbaf59d ]--- [ 129.351207] net eth0: Unexpected TXQ (0) queue failure: -12 [ 129.360445] net eth0: Unexpected TXQ (0) queue failure: -12 [ 129.824428] net eth0: Unexpected TXQ (0) queue failure: -12
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +3 -1
@@ -362,7 +362,9 @@ static struct vdpasim *vdpasim_create(vospin_lock_init (&vdpasim->iommu_lock); dev = &vdpasim->vdpa.dev; - dev->coherent_dma_mask =DMA_BIT_MASK (64 ); + dev->dma_mask = &dev->coherent_dma_mask; +if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 ))) + goto err_iommu;set_dma_ops (dev, &vdpasim_dma_ops); vdpasim->iommu =vhost_iotlb_alloc (2048 ,0 );
Greg Kroah-Hartman
maintainerPATCH 297/391 remoteproc: Fixup coredump debugfs disable request
In reply to Greg Kroah-HartmanFrom: Sibi Sankar <[email protected]>
commit 1894622636745237f882bfab47925afc48e122e0 upstream.
Fix the discrepancy observed between accepted input and read back value while disabling remoteproc coredump through the coredump debugfs entry.
--- drivers/remoteproc/remoteproc_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_debugfs.c +1 -1
@@ -94,7 +94,7 @@ static ssize_t rproc_coredump_write(stru goto out; } -if (!strncmp (buf,"disable" , count)) { +if (!strncmp (buf,"disabled" , count)) { rproc->dump_conf =RPROC_COREDUMP_DISABLED ; }else if (!strncmp (buf,"inline" , count)) { rproc->dump_conf =RPROC_COREDUMP_INLINE ;
Greg Kroah-Hartman
maintainerPATCH 268/391 iio: ltc2983: Fix of_node refcounting
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
commit b07c47bfab6f5c4c7182d23e854bbceaf7829c85 upstream.
When returning or breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the child node to possibly release the node.
--- drivers/iio/temperature/ltc2983.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/iio/temperature/ltc2983.c +13 -6
@@ -1285,18 +1285,20 @@ static int ltc2983_parse_dt(struct ltc29 ret =of_property_read_u32 (child,"reg" , &sensor.chan);if (ret) {dev_err (dev,"reg property must given for child nodes\n" ); -return ret; + goto put_child; }/* check if we have a valid channel */ if (sensor.chan <LTC2983_MIN_CHANNELS_NR || sensor.chan >LTC2983_MAX_CHANNELS_NR ) { + ret = -EINVAL ;dev_err (dev,"chan:%d must be from 1 to 20\n" , sensor.chan); -return -EINVAL ; + goto put_child; }else if (channel_avail_mask &BIT (sensor.chan)) { + ret = -EINVAL ;dev_err (dev,"chan:%d already in use\n" , sensor.chan); -return -EINVAL ; + goto put_child; } ret = of_property_read_u32(child, "adi,sensor-type",
@@ -1304,7 +1306,7 @@ static int ltc2983_parse_dt(struct ltc29if (ret) {dev_err (dev,"adi,sensor-type property must given for child nodes\n" ); -return ret; + goto put_child; } dev_dbg(dev, "Create new sensor, type %u, chann %u",
@@ -1334,13 +1336,15 @@ static int ltc2983_parse_dt(struct ltc29 st->sensors[chan] =ltc2983_adc_new (child, st, &sensor); }else {dev_err (dev,"Unknown sensor type %d\n" , sensor.type); -return -EINVAL ; + ret = -EINVAL ; + goto put_child; }if (IS_ERR (st->sensors[chan])) {dev_err (dev,"Failed to create sensor %ld" ,PTR_ERR (st->sensors[chan])); -return PTR_ERR (st->sensors[chan]); + ret =PTR_ERR (st->sensors[chan]); + goto put_child; }/* set generic sensor parameters */ st->sensors[chan]->chan = sensor.chan;
@@ -1351,6 +1355,9 @@ static int ltc2983_parse_dt(struct ltc29 }return 0 ; +put_child: +of_node_put (child); +return ret; }static int ltc2983_setup (struct ltc2983_data *st,bool assign_iio)
Greg Kroah-Hartman
maintainerPATCH 313/391 ia64: fix build error with !COREDUMP
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 7404840d87557c4092bf0272bce5e0354c774bf9 upstream.
Fix linkage error when CONFIG_BINFMT_ELF is selected but CONFIG_COREDUMP is not:
ia64-linux-ld: arch/ia64/kernel/elfcore.o: in function `elf_core_write_extra_phdrs':
elfcore.c:(.text+0x172): undefined reference to `dump_emit'
ia64-linux-ld: arch/ia64/kernel/elfcore.o: in function `elf_core_write_extra_data':
elfcore.c:(.text+0x2b2): undefined reference to `dump_emit'
--- arch/ia64/kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/Makefile +1 -1
@@ -41,7 +41,7 @@ obj-y += esi_stub.o # must be in kern endif obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o -obj-$(CONFIG_BINFMT_ELF) += elfcore.o +obj-$(CONFIG_ELF_CORE) += elfcore.o # fp_emulate() expects f2-f5,f16-f31 to contain the user-level state. CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
Greg Kroah-Hartman
maintainerPATCH 314/391 rtc: rx8010: dont modify the global rtc ops
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
commit d3b14296da69adb7825022f3224ac6137eb30abf upstream.
The way the driver is implemented is buggy for the (admittedly unlikely) use case where there are two RTCs with one having an interrupt configured and the second not. This is caused by the fact that we use a global rtc_class_ops struct which we modify depending on whether the irq number is present or not.
Fix it by using two const ops structs with and without alarm operations. While at it: not being able to request a configured interrupt is an error so don't ignore it and bail out of probe().
--- drivers/rtc/rtc-rx8010.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/rtc/rtc-rx8010.c +17 -7
@@ -407,16 +407,26 @@ static int rx8010_ioctl(struct device *d } } -static struct rtc_class_ops rx8010_rtc_ops = { +static const struct rtc_class_ops rx8010_rtc_ops_default = { .read_time = rx8010_get_time, .set_time = rx8010_set_time, .ioctl = rx8010_ioctl, }; +static const struct rtc_class_ops rx8010_rtc_ops_alarm = { + .read_time = rx8010_get_time, + .set_time = rx8010_set_time, + .ioctl = rx8010_ioctl, + .read_alarm = rx8010_read_alarm, + .set_alarm = rx8010_set_alarm, + .alarm_irq_enable = rx8010_alarm_irq_enable, +}; +static int rx8010_probe (struct i2c_client *client,const struct i2c_device_id *id) {struct i2c_adapter *adapter = client->adapter; +const struct rtc_class_ops *rtc_ops;struct rx8010_data *rx8010;int err =0 ;
@@ -447,16 +457,16 @@ static int rx8010_probe(struct i2c_clienif (err) {dev_err (&client->dev,"unable to request IRQ\n" ); - client->irq =0 ; - }else { - rx8010_rtc_ops.read_alarm = rx8010_read_alarm; - rx8010_rtc_ops.set_alarm = rx8010_set_alarm; - rx8010_rtc_ops.alarm_irq_enable = rx8010_alarm_irq_enable; +return err; } + + rtc_ops = &rx8010_rtc_ops_alarm; + }else { + rtc_ops = &rx8010_rtc_ops_default; } rx8010->rtc =devm_rtc_device_register (&client->dev, client->name, - &rx8010_rtc_ops,THIS_MODULE ); + rtc_ops,THIS_MODULE );if (IS_ERR (rx8010->rtc)) {dev_err (&client->dev,"unable to register the class device\n" );
Greg Kroah-Hartman
maintainerPATCH 315/391 i2c: imx: Fix external abort on interrupt in exit paths
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit e50e4f0b85be308a01b830c5fbdffc657e1a6dd0 upstream.
If interrupt comes late, during probe error path or device remove (could be triggered with CONFIG_DEBUG_SHIRQ), the interrupt handler i2c_imx_isr() will access registers with the clock being disabled. This leads to external abort on non-linefetch on Toradex Colibri VF50 module (with Vybrid VF5xx):
Unhandled fault: external abort on non-linefetch (0x1008) at 0x8882d003
Internal error: : 1008 [#1] ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 5.7.0 #607
Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
(i2c_imx_isr) from [<8017009c>] (free_irq+0x25c/0x3b0)
(free_irq) from [<805844ec>] (release_nodes+0x178/0x284)
(release_nodes) from [<80580030>] (really_probe+0x10c/0x348)
(really_probe) from [<80580380>] (driver_probe_device+0x60/0x170)
(driver_probe_device) from [<80580630>] (device_driver_attach+0x58/0x60)
(device_driver_attach) from [<805806bc>] (__driver_attach+0x84/0xc0)
(__driver_attach) from [<8057e228>] (bus_for_each_dev+0x68/0xb4)
(bus_for_each_dev) from [<8057f3ec>] (bus_add_driver+0x144/0x1ec)
(bus_add_driver) from [<80581320>] (driver_register+0x78/0x110)
(driver_register) from [<8010213c>] (do_one_initcall+0xa8/0x2f4)
(do_one_initcall) from [<80c0100c>] (kernel_init_freeable+0x178/0x1dc)
(kernel_init_freeable) from [<80807048>] (kernel_init+0x8/0x110)
(kernel_init) from [<80100114>] (ret_from_fork+0x14/0x20)Additionally, the i2c_imx_isr() could wake up the wait queue (imx_i2c_struct->queue) before its initialization happens.
The resource-managed framework should not be used for interrupt handling, because the resource will be released too late - after disabling clocks. The interrupt handler is not prepared for such case.
--- drivers/i2c/busses/i2c-imx.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-imx.c +13 -11
@@ -1171,14 +1171,6 @@ static int i2c_imx_probe(struct platformreturn ret; } -/* Request IRQ */ - ret =devm_request_irq (&pdev->dev, irq, i2c_imx_isr,IRQF_SHARED , - pdev->name, i2c_imx); -if (ret) { -dev_err (&pdev->dev,"can't claim irq %d\n" , irq); - goto clk_disable; - } -/* Init queue */ init_waitqueue_head (&i2c_imx->queue);
@@ -1197,6 +1189,14 @@ static int i2c_imx_probe(struct platformif (ret <0 ) goto rpm_disable; +/* Request IRQ */ + ret =request_threaded_irq (irq, i2c_imx_isr,NULL ,IRQF_SHARED , + pdev->name, i2c_imx); +if (ret) { +dev_err (&pdev->dev,"can't claim irq %d\n" , irq); + goto rpm_disable; + } +/* Set up clock divider */ i2c_imx->bitrate =I2C_MAX_STANDARD_MODE_FREQ ; ret = of_property_read_u32(pdev->dev.of_node,
@@ -1239,13 +1239,12 @@ static int i2c_imx_probe(struct platform clk_notifier_unregister:clk_notifier_unregister (i2c_imx->clk, &i2c_imx->clk_change_nb); +free_irq (irq, i2c_imx); rpm_disable:pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev); - -clk_disable:clk_disable_unprepare (i2c_imx->clk);return ret; }
@@ -1253,7 +1252,7 @@ clk_disable:static int i2c_imx_remove (struct platform_device *pdev) {struct imx_i2c_struct *i2c_imx =platform_get_drvdata (pdev); -int ret; +int irq, ret; ret =pm_runtime_get_sync (&pdev->dev);if (ret <0 )
@@ -1273,6 +1272,9 @@ static int i2c_imx_remove(struct platforimx_i2c_write_reg (0 , i2c_imx,IMX_I2C_I2SR );clk_notifier_unregister (i2c_imx->clk, &i2c_imx->clk_change_nb); + irq =platform_get_irq (pdev,0 ); +if (irq >=0 ) +free_irq (irq, i2c_imx);clk_disable_unprepare (i2c_imx->clk);pm_runtime_put_noidle (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 316/391 drm/amdgpu: dont map BO in reserved region
In reply to Greg Kroah-HartmanFrom: Madhav Chauhan <[email protected]>
commit c4aa8dff6091cc9536aeb255e544b0b4ba29faf4 upstream.
2MB area is reserved at top inside VM.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +10 -0
@@ -596,6 +596,7 @@ int amdgpu_gem_va_ioctl(struct drm_devicstruct ww_acquire_ctx ticket;struct list_head list, duplicates;uint64_t va_flags; +uint64_t vm_size;int r =0 ;if (args->va_address <AMDGPU_VA_RESERVED_SIZE ) {
@@ -616,6 +617,15 @@ int amdgpu_gem_va_ioctl(struct drm_devic args->va_address &=AMDGPU_GMC_HOLE_MASK ; + vm_size = adev->vm_manager.max_pfn *AMDGPU_GPU_PAGE_SIZE ; + vm_size -=AMDGPU_VA_RESERVED_SIZE ; +if (args->va_address + args->map_size > vm_size) { +dev_dbg (&dev->pdev->dev, +"va_address 0x%llx is in top reserved area 0x%llx\n" , + args->va_address + args->map_size, vm_size); +return -EINVAL ; + } +if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) {dev_dbg (&dev->pdev->dev,"invalid flags combination 0x%08X\n" , args->flags);
Greg Kroah-Hartman
maintainerPATCH 317/391 drm/amd/display: Fix incorrect backlight register offset for DCN
In reply to Greg Kroah-HartmanFrom: David Galiffi <[email protected]>
commit 651111be24aa4c8b62c10f6fff51d9ad82411249 upstream.
[Why]
Typo in backlight refactor introduced wrong register offset.
[How]SR(BIOS_SCRATCH_2) to NBIO_SR(BIOS_SCRATCH_2).
--- drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h +1 -1
@@ -54,7 +54,7 @@SR (BL_PWM_CNTL2 ), \SR (BL_PWM_PERIOD_CNTL ), \SR (BL_PWM_GRP1_REG_LOCK ), \ - SR(BIOS_SCRATCH_2) + NBIO_SR(BIOS_SCRATCH_2)#define DCE_PANEL_CNTL_SF (reg_name, field_name, post_fix)\ .field_name = reg_name ## __ ## field_name ## post_fix
Greg Kroah-Hartman
maintainerPATCH 320/391 drm/amdgpu: update golden setting for sienna_cichlid
In reply to Greg Kroah-HartmanFrom: Likun Gao <[email protected]>
commit 0d142232d9436acab3578ee995472f58adcbf201 upstream.
Update golden setting for sienna_cichlid.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
@@ -3091,6 +3091,7 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (GC ,0 , mmGL2C_ADDR_MATCH_MASK,0xffffffff ,0xffffffcf ),SOC15_REG_GOLDEN_VALUE (GC ,0 , mmGL2C_CM_CTRL1,0xff8fff0f ,0x580f1008 ),SOC15_REG_GOLDEN_VALUE (GC ,0 , mmGL2C_CTRL3,0xf7ffffff ,0x10f80988 ), +SOC15_REG_GOLDEN_VALUE (GC ,0 , mmLDS_CONFIG,0x00000020 ,0x00000020 ),SOC15_REG_GOLDEN_VALUE (GC ,0 , mmPA_CL_ENHANCE,0xf17fffff ,0x01200007 ),SOC15_REG_GOLDEN_VALUE (GC ,0 , mmPA_SC_BINNER_TIMEOUT_COUNTER,0xffffffff ,0x00000800 ), SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0xffffffbf, 0x00000820),
Greg Kroah-Hartman
maintainerPATCH 321/391 drm/amdgpu: correct the gpu reset handling for job != NULL case
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 207ac684792560acdb9e06f9d707ebf63c84b0e0 upstream.
Current code wrongly treat all cases as job == NULL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4374,7 +4374,7 @@ int amdgpu_device_gpu_recover(struct amd retry:/* Rest of adevs pre asic reset from XGMI hive. */ list_for_each_entry (tmp_adev, device_list_handle, gmc.xgmi.head) { r =amdgpu_device_pre_asic_reset (tmp_adev, -NULL , + (tmp_adev == adev) ? job :NULL , &need_full_reset);/*TODO Should we stop ?*/ if (r) {
Greg Kroah-Hartman
maintainerPATCH 322/391 drm/amdkfd: Use same SQ prefetch setting as amdgpu
In reply to Greg Kroah-HartmanFrom: Jay Cornwall <[email protected]>
commit d56b1980d7efe9ef08469e856fc0703d0cef65e4 upstream.
0 causes instruction fetch stall at cache line boundary under some conditions on Navi10. A non-zero prefetch is the preferred default in any case.
Fixes soft hang in Luxmark.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c +3 -2
@@ -58,8 +58,9 @@ static int update_qpd_v10(struct device_/* check if sh_mem_config register already configured */ if (qpd->sh_mem_config ==0 ) { qpd->sh_mem_config = -SH_MEM_ALIGNMENT_MODE_UNALIGNED << -SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT ; + (SH_MEM_ALIGNMENT_MODE_UNALIGNED << +SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT ) | + (3 <<SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT );#if 0 /* TODO: * This shouldn't be an issue with Navi10. Verify.
Greg Kroah-Hartman
maintainerPATCH 324/391 drm/amdgpu: add function to program pbb mode for sienna cichlid
In reply to Greg Kroah-HartmanFrom: Likun Gao <[email protected]>
commit 274c240c760ed4647ddae1f1b994e0dd3f71cbb1 upstream.
Add function for sienna_cichlid to force PBB workload mode to zero by checking whether there have SE been harvested.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +62 -0
@@ -112,6 +112,22 @@#define mmCP_HYP_ME_UCODE_DATA 0x5817#define mmCP_HYP_ME_UCODE_DATA_BASE_IDX 1 +//CC_GC_SA_UNIT_DISABLE +#define mmCC_GC_SA_UNIT_DISABLE 0x0fe9 +#define mmCC_GC_SA_UNIT_DISABLE_BASE_IDX 0 +#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT 0x8 +#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK 0x0000FF00L +//GC_USER_SA_UNIT_DISABLE +#define mmGC_USER_SA_UNIT_DISABLE 0x0fea +#define mmGC_USER_SA_UNIT_DISABLE_BASE_IDX 0 +#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT 0x8 +#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK 0x0000FF00L +//PA_SC_ENHANCE_3 +#define mmPA_SC_ENHANCE_3 0x1085 +#define mmPA_SC_ENHANCE_3_BASE_IDX 0 +#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO__SHIFT 0x3 +#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO_MASK 0x00000008L +MODULE_FIRMWARE ("amdgpu/navi10_ce.bin" );MODULE_FIRMWARE ("amdgpu/navi10_pfp.bin" );MODULE_FIRMWARE ("amdgpu/navi10_me.bin" );
@@ -3189,6 +3205,8 @@ static int gfx_v10_0_wait_for_rlc_autolostatic void gfx_v10_0_ring_emit_ce_meta (struct amdgpu_ring *ring,bool resume);static void gfx_v10_0_ring_emit_de_meta (struct amdgpu_ring *ring,bool resume);static void gfx_v10_0_ring_emit_frame_cntl (struct amdgpu_ring *ring,bool start,bool secure); +static u32 gfx_v10_3_get_disabled_sa (struct amdgpu_device *adev); +static void gfx_v10_3_program_pbb_mode (struct amdgpu_device *adev);static void gfx10_kiq_set_resources (struct amdgpu_ring *kiq_ring,uint64_t queue_mask) {
@@ -6929,6 +6947,9 @@ static int gfx_v10_0_hw_init(void *handlif (r)return r; +if (adev->asic_type ==CHIP_SIENNA_CICHLID ) +gfx_v10_3_program_pbb_mode (adev); +return r; }
@@ -8774,6 +8795,47 @@ static int gfx_v10_0_get_cu_info(structreturn 0 ; } +static u32 gfx_v10_3_get_disabled_sa (struct amdgpu_device *adev) +{ +uint32_t efuse_setting, vbios_setting, disabled_sa, max_sa_mask; + + efuse_setting =RREG32_SOC15 (GC ,0 , mmCC_GC_SA_UNIT_DISABLE); + efuse_setting &=CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK ; + efuse_setting >>=CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT ; + + vbios_setting =RREG32_SOC15 (GC ,0 , mmGC_USER_SA_UNIT_DISABLE); + vbios_setting &=GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK ; + vbios_setting >>=GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT ; + + max_sa_mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_sh_per_se * + adev->gfx.config.max_shader_engines); + disabled_sa = efuse_setting | vbios_setting; + disabled_sa &= max_sa_mask; + +return disabled_sa; +} + +static void gfx_v10_3_program_pbb_mode (struct amdgpu_device *adev) +{ +uint32_t max_sa_per_se, max_sa_per_se_mask, max_shader_engines; +uint32_t disabled_sa_mask, se_index, disabled_sa_per_se; + + disabled_sa_mask =gfx_v10_3_get_disabled_sa (adev); + + max_sa_per_se = adev->gfx.config.max_sh_per_se; + max_sa_per_se_mask = (1 << max_sa_per_se) -1 ; + max_shader_engines = adev->gfx.config.max_shader_engines; + +for (se_index =0 ; max_shader_engines > se_index; se_index++) { + disabled_sa_per_se = disabled_sa_mask >> (se_index * max_sa_per_se); + disabled_sa_per_se &= max_sa_per_se_mask; +if (disabled_sa_per_se == max_sa_per_se_mask) { +WREG32_FIELD15 (GC ,0 ,PA_SC_ENHANCE_3 ,FORCE_PBB_WORKLOAD_MODE_TO_ZERO ,1 ); +break ; + } + } +} +const struct amdgpu_ip_block_version gfx_v10_0_ip_block = { .type =AMD_IP_BLOCK_TYPE_GFX ,
Greg Kroah-Hartman
maintainerPATCH 326/391 drm/amd/display: Dont invoke kgdb_breakpoint() unconditionally
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 8b7dc1fe1a5c1093551f6cd7dfbb941bd9081c2e upstream.
ASSERT_CRITICAL() invokes kgdb_breakpoint() whenever either CONFIG_KGDB or CONFIG_HAVE_KGDB is set. This, however, may lead to a kernel panic when no kdb stuff is attached, since the kgdb_breakpoint() call issues INT3. It's nothing but a surprise for normal end-users.
For avoiding the pitfall, make the kgdb_breakpoint() call only when CONFIG_DEBUG_KERNEL_DC is set.
https://bugzilla.opensuse.org/show_bug.cgi?id=1177973
--- drivers/gpu/drm/amd/display/dc/os_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/os_types.h +1 -1
@@ -90,7 +90,7 @@* general debug capabilities * */ -#if defined(CONFIG_HAVE_KGDB ) || defined(CONFIG_KGDB ) +#if defined(CONFIG_DEBUG_KERNEL_DC ) && (defined(CONFIG_HAVE_KGDB ) || defined(CONFIG_KGDB ))#define ASSERT_CRITICAL (expr) do { \ if (WARN_ON(!(expr))) { \ kgdb_breakpoint(); \
Greg Kroah-Hartman
maintainerPATCH 327/391 drm/amd/display: Fix kernel panic by dal_gpio_open() error
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 920bb38c518408fa2600eaefa0af9e82cf48f166 upstream.
Currently both error code paths handled in dal_gpio_open_ex() issues ASSERT_CRITICAL(), and this leads to a kernel panic unnecessarily if CONFIG_KGDB is enabled. Since basically both are non-critical errors and can be recovered, drop those assert calls and use a safer one, BREAK_TO_DEBUGGER(), for allowing the debugging, instead.
--- drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c +2 -2
@@ -63,13 +63,13 @@ enum gpio_result dal_gpio_open_ex( enum gpio_mode mode) {if (gpio->pin) { -ASSERT_CRITICAL (false); +BREAK_TO_DEBUGGER ();return GPIO_RESULT_ALREADY_OPENED ; }// No action if allocation failed during gpio construct if (!gpio->hw_container.ddc) { -ASSERT_CRITICAL (false); +BREAK_TO_DEBUGGER ();return GPIO_RESULT_NON_SPECIFIC_ERROR ; } gpio->mode = mode;
Greg Kroah-Hartman
maintainerPATCH 325/391 drm/amdgpu: increase the reserved VM size to 2MB
In reply to Greg Kroah-HartmanFrom: Christian König <[email protected]>
commit 55bb919be4e4973cd037a04f527ecc6686800437 upstream.
Ideally this should be a multiple of the VM block size. 2MB should at least fit for Vega/Navi.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -2
@@ -112,8 +112,8 @@ struct amdgpu_bo_list_entry;#define AMDGPU_MMHUB_0 1#define AMDGPU_MMHUB_1 2 -/* hardcode that limit for now */ -#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20) +/* Reserve 2MB at top/bottom of address space for kernel use */ +#define AMDGPU_VA_RESERVED_SIZE (2ULL << 20)/* max vmids dedicated for process */ #define AMDGPU_VM_MAX_RESERVED_VMID 1
Greg Kroah-Hartman
maintainerPATCH 328/391 ceph: promote to unsigned long long before shifting
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit c403c3a2fbe24d4ed33e10cabad048583ebd4edf upstream.
On 32-bit systems, this shift will overflow for files larger than 4GB.
--- fs/ceph/addr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/addr.c +1 -1
@@ -1522,7 +1522,7 @@ static vm_fault_t ceph_filemap_fault(strstruct ceph_inode_info *ci =ceph_inode (inode);struct ceph_file_info *fi = vma->vm_file->private_data;struct page *pinned_page =NULL ; -loff_t off = vmf->pgoff <<PAGE_SHIFT ; +loff_t off = (loff_t )vmf->pgoff <<PAGE_SHIFT ;int want, got, err;sigset_t oldset;vm_fault_t ret =VM_FAULT_SIGBUS ;
Greg Kroah-Hartman
maintainerPATCH 331/391 net/sunrpc: Fix return value for sysctl sunrpc.transports
In reply to Greg Kroah-HartmanFrom: Artur Molchanov <[email protected]>
commit c09f56b8f68d4d536bff518227aea323b835b2ce upstream.
Fix returning value for sysctl sunrpc.transports.
Return error code from sysctl proc_handler function proc_do_xprt instead of number of the written bytes. Otherwise sysctl returns random garbage for this key.
Since v1:
- Handle negative returned value from memory_read_from_buffer as an error
--- net/sunrpc/sysctl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/sunrpc/sysctl.c +7 -1
@@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_tablereturn 0 ; } len =svc_print_xprts (tmpbuf,sizeof (tmpbuf)); -return memory_read_from_buffer (buffer, *lenp, ppos, tmpbuf, len); + *lenp =memory_read_from_buffer (buffer, *lenp, ppos, tmpbuf, len); + +if (*lenp <0 ) { + *lenp =0 ; +return -EINVAL ; + } +return 0 ; } static int
Greg Kroah-Hartman
maintainerPATCH 329/391 libceph: clear con->out_msg on Policy::stateful_server faults
In reply to Greg Kroah-HartmanFrom: Ilya Dryomov <[email protected]>
commit 28e1581c3b4ea5f98530064a103c6217bedeea73 upstream.
con->out_msg must be cleared on Policy::stateful_server (!CEPH_MSG_CONNECT_LOSSY) faults. Not doing so botches the reconnection attempt, because after writing the banner the messenger moves on to writing the data section of that message (either from where it got interrupted by the connection reset or from the beginning) instead of writing struct ceph_msg_connect. This results in a bizarre error message because the server sends CEPH_MSGR_TAG_BADPROTOVER but we think we wrote struct ceph_msg_connect:
libceph: mds0 (1)172.21.15.45:6828 socket error on write
ceph: mds0 reconnect start
libceph: mds0 (1)172.21.15.45:6829 socket closed (con state OPEN)
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch, my 32 != server's 32
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch
AFAICT this bug goes back to the dawn of the kernel client. The reason it survived for so long is that only MDS sessions are stateful and only two MDS messages have a data section:CEPH_MSG_CLIENT_RECONNECT (always, but reconnecting is rare) and CEPH_MSG_CLIENT_REQUEST (only when xattrs are involved). The connection has to get reset precisely when such message is being sent -- in this case it was the former.
--- net/ceph/messenger.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ceph/messenger.c +5 -0
@@ -2998,6 +2998,11 @@ static void con_fault(struct ceph_connecceph_msg_put (con->in_msg); con->in_msg =NULL ; } +if (con->out_msg) { +BUG_ON (con->out_msg->con != con); +ceph_msg_put (con->out_msg); + con->out_msg =NULL ; + }/* Requeue anything that hasn't been acked */ list_splice_init (&con->out_sent, &con->out_queue);
Greg Kroah-Hartman
maintainerPATCH 332/391 PCI: qcom: Make sure PCIe is reset before init for rev 2.1.0
In reply to Greg Kroah-HartmanFrom: Ansuel Smith <[email protected]>
commit d3d4d028afb785e52c55024d779089654f8302e7 upstream.
Qsdk U-Boot can incorrectly leave the PCIe interface in an undefined state if bootm command is used instead of bootipq. This is caused by the not deinit of PCIe when bootm is called. Reset the PCIe before init anyway to fix this U-Boot bug.
--- drivers/pci/controller/dwc/pcie-qcom.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +13 -0
@@ -302,6 +302,9 @@ static void qcom_pcie_deinit_2_1_0(strucreset_control_assert (res->por_reset);reset_control_assert (res->ext_reset);reset_control_assert (res->phy_reset); + +writel (1 , pcie->parf +PCIE20_PARF_PHY_CTRL ); +regulator_bulk_disable (ARRAY_SIZE (res->supplies), res->supplies); }
@@ -314,6 +317,16 @@ static int qcom_pcie_init_2_1_0(struct qu32 val;int ret; +/* reset the PCIe interface as uboot can leave it undefined state */ +reset_control_assert (res->pci_reset); +reset_control_assert (res->axi_reset); +reset_control_assert (res->ahb_reset); +reset_control_assert (res->por_reset); +reset_control_assert (res->ext_reset); +reset_control_assert (res->phy_reset); + +writel (1 , pcie->parf +PCIE20_PARF_PHY_CTRL ); + ret =regulator_bulk_enable (ARRAY_SIZE (res->supplies), res->supplies);if (ret <0 ) {dev_err (dev,"cannot enable regulators\n" );
Greg Kroah-Hartman
maintainerPATCH 333/391 ring-buffer: Return 0 on success from ring_buffer_resize()
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit 0a1754b2a97efa644aa6e84d1db5b17c42251483 upstream.
We don't need to check the new buffer size, and the return value had confused resize_buffer_duplicate_size().
...
ret = ring_buffer_resize(trace_buf->buffer, per_cpu_ptr(size_buf->data,cpu_id)->entries, cpu_id); if (ret == 0) per_cpu_ptr(trace_buf->data, cpu_id)->entries = per_cpu_ptr(size_buf->data, cpu_id)->entries;
...
--- kernel/trace/ring_buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/ring_buffer.c +4 -4
@@ -1952,18 +1952,18 @@ int ring_buffer_resize(struct trace_buff {struct ring_buffer_per_cpu *cpu_buffer;unsigned long nr_pages; -int cpu, err =0 ; +int cpu, err;/* * Always succeed at resizing a non-existent buffer: */ if (!buffer) -return size; +return 0 ;/* Make sure the requested buffer exists */ if (cpu_id !=RING_BUFFER_ALL_CPUS && !cpumask_test_cpu (cpu_id, buffer->cpumask)) -return size; +return 0 ; nr_pages =DIV_ROUND_UP (size,BUF_PAGE_SIZE );
@@ -2119,7 +2119,7 @@ int ring_buffer_resize(struct trace_buff }mutex_unlock (&buffer->mutex); -return size; +return 0 ; out_err:for_each_buffer_cpu (buffer, cpu) {
Greg Kroah-Hartman
maintainerPATCH 334/391 intel_idle: Ignore _CST if control cannot be taken from the platform
In reply to Greg Kroah-HartmanFrom: Mel Gorman <[email protected]>
commit 75af76d0a34e048651a6af311781d7206b6964c7 upstream.
e6d4f08a6776 ("intel_idle: Use ACPI _CST on server systems") avoids enabling c-states that have been disabled by the platform with the exception of C1E.
Unfortunately, BIOS implementations are not always consistent in terms of how capabilities are advertised and control cannot always be handed over. If control cannot be handed over then intel_idle reports that "ACPI _CST not found or not usable" but does not clear acpi_state_table.count meaning the information is still partially used.
This patch ignores ACPI information if CST control cannot be requested from the platform. This was only observed on a number of Haswell platforms that had identical CPUs but not identical BIOS versions. While this problem may be rare overall, 24 separate test cases bisected to this specific commit across 4 separate test machines and is worth addressing. If the situation occurs, the kernel behaves as it did before commit e6d4f08a6776 and uses any c-states that are discovered.
The affected test cases were all ones that involved a small number of processes -- exec microbenchmark, pipe microbenchmark, git test suite, netperf, tbench with one client and system call microbenchmark. Each case benefits from being able to use turboboost which is prevented if the lower c-states are unavailable. This may mask real regressions specific to older hardware so it is worth addressing.
C-state status before and after the patch
5.9.0-vanilla POLL latency:0 disabled:0 default:enabled 5.9.0-vanilla C1 latency:2 disabled:0 default:enabled 5.9.0-vanilla C1E latency:10 disabled:0 default:enabled 5.9.0-vanilla C3 latency:33 disabled:1 default:disabled 5.9.0-vanilla C6 latency:133 disabled:1 default:disabled 5.9.0-ignore-cst-v1r1 POLL latency:0 disabled:0 default:enabled 5.9.0-ignore-cst-v1r1 C1 latency:2 disabled:0 default:enabled 5.9.0-ignore-cst-v1r1 C1E latency:10 disabled:0 default:enabled 5.9.0-ignore-cst-v1r1 C3 latency:33 disabled:0 default:enabled 5.9.0-ignore-cst-v1r1 C6 latency:133 disabled:0 default:enabled
Patch enables C3/C6.
Netperf UDP_STREAM
netperf-udp
5.5.0 5.9.0
vanilla ignore-cst-v1r1
Hmean send-64 193.41 ( 0.00%) 226.54 * 17.13%*
Hmean send-128 392.16 ( 0.00%) 450.54 * 14.89%*
Hmean send-256 769.94 ( 0.00%) 881.85 * 14.53%*
Hmean send-1024 2994.21 ( 0.00%) 3468.95 * 15.85%*
Hmean send-2048 5725.60 ( 0.00%) 6628.99 * 15.78%*
Hmean send-3312 8468.36 ( 0.00%) 10288.02 * 21.49%*
Hmean send-4096 10135.46 ( 0.00%) 12387.57 * 22.22%*
Hmean send-8192 17142.07 ( 0.00%) 19748.11 * 15.20%*
Hmean send-16384 28539.71 ( 0.00%) 30084.45 * 5.41%*--- drivers/idle/intel_idle.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/idle/intel_idle.c +3 -4
@@ -1212,14 +1212,13 @@ static bool __init intel_idle_acpi_cst_eif (!intel_idle_cst_usable ())continue ; -if (!acpi_processor_claim_cst_control ()) { - acpi_state_table.count =0 ; -return false; - } +if (!acpi_processor_claim_cst_control ()) +break ;return true; } + acpi_state_table.count =0 ;pr_debug ("ACPI _CST not found or not usable\n" );return false; }
Greg Kroah-Hartman
maintainerPATCH 335/391 intel_idle: Fix max_cstate for processor models without C-state tables
In reply to Greg Kroah-HartmanFrom: Chen Yu <[email protected]>
commit 4e0ba5577dba686f96c1c10ef4166380667fdec7 upstream.
Currently intel_idle driver gets the c-state information from ACPI _CST if the processor model is not recognized by it. However the c-state in _CST starts with index 1 which is different from the index in intel_idle driver's internal c-state table.
While intel_idle_max_cstate_reached() was previously introduced to deal with intel_idle driver's internal c-state table, re-using this function directly on _CST is incorrect.
Fix this by subtracting 1 from the index when checking max_cstate in the _CST case.
For example, append intel_idle.max_cstate=1 in boot command line, Before the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name POLL
After the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name /sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL /sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI
--- drivers/idle/intel_idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/idle/intel_idle.c +1 -1
@@ -1235,7 +1235,7 @@ static void __init intel_idle_init_cstatstruct acpi_processor_cx *cx;struct cpuidle_state *state; -if (intel_idle_max_cstate_reached (cstate)) +if (intel_idle_max_cstate_reached (cstate -1 ))break ; cx = &acpi_state_table.states[cstate];
Greg Kroah-Hartman
maintainerPATCH 338/391 cpufreq: intel_pstate: Avoid missing HWP max updates in passive mode
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit e0be38ed4ab413ddd492118cf146369b86ee0ab5 upstream.
If the cpufreq policy max limit is changed when intel_pstate operates in the passive mode with HWP enabled and the "powersave" governor is used on top of it, the HWP max limit is not updated as appropriate.
Namely, in the "powersave" governor case, the target P-state is always equal to the policy min limit, so if the latter does not change, intel_cpufreq_adjust_hwp() is not invoked to update the HWP Request MSR due to the "target_pstate != old_pstate" check in intel_cpufreq_update_pstate(), so the HWP max limit is not updated as a result.
Also, if the CPUFREQ_NEED_UPDATE_LIMITS flag is not set for the driver and the target frequency does not change along with the policy max limit, the "target_freq == policy->cur" check in __cpufreq_driver_target() prevents the driver's ->target() callback from being invoked at all, so the HWP max limit is not updated.
To prevent that occurring, set the CPUFREQ_NEED_UPDATE_LIMITS flag in the intel_cpufreq driver structure if HWP is enabled and modify intel_cpufreq_update_pstate() to do the "target_pstate != old_pstate" check only in the non-HWP case and let intel_cpufreq_adjust_hwp() always run in the HWP case (it will update HWP Request only if the cached value of the register is different from the new one including the limits, so if neither the target P-state value nor the max limit changes, the register write will still be avoided).
--- drivers/cpufreq/intel_pstate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/cpufreq/intel_pstate.c +6 -7
@@ -2550,14 +2550,12 @@ static int intel_cpufreq_update_pstate(sint old_pstate = cpu->pstate.current_pstate; target_pstate =intel_pstate_prepare_request (cpu, target_pstate); -if (target_pstate != old_pstate) { +if (hwp_active) { +intel_cpufreq_adjust_hwp (cpu, target_pstate, fast_switch); + cpu->pstate.current_pstate = target_pstate; + }else if (target_pstate != old_pstate) { +intel_cpufreq_adjust_perf_ctl (cpu, target_pstate, fast_switch); cpu->pstate.current_pstate = target_pstate; -if (hwp_active) -intel_cpufreq_adjust_hwp (cpu, target_pstate, - fast_switch); -else -intel_cpufreq_adjust_perf_ctl (cpu, target_pstate, - fast_switch); } intel_cpufreq_trace(cpu, fast_switch ? INTEL_PSTATE_TRACE_FAST_SWITCH :
@@ -3014,6 +3012,7 @@ static int __init intel_pstate_init(void hwp_mode_bdw = id->driver_data; intel_pstate.attr = hwp_cpufreq_attrs; intel_cpufreq.attr = hwp_cpufreq_attrs; + intel_cpufreq.flags |=CPUFREQ_NEED_UPDATE_LIMITS ;if (!default_driver) default_driver = &intel_pstate;
Greg Kroah-Hartman
maintainerPATCH 339/391 vringh: fix __vringh_iov() when riov and wiov are different
In reply to Greg Kroah-HartmanFrom: Stefano Garzarella <[email protected]>
commit 5745bcfbbf89b158416075374254d3c013488f21 upstream.
If riov and wiov are both defined and they point to different objects, only riov is initialized. If the wiov is not initialized by the caller, the function fails returning -EINVAL and printing "Readable desc 0x... after writable" error message.
This issue happens when descriptors have both readable and writable buffers (eg. virtio-blk devices has virtio_blk_outhdr in the readable buffer and status as last byte of writable buffer) and we call __vringh_iov() to get both type of buffers in two different iovecs.
Let's replace the 'else if' clause with 'if' to initialize both riov and wiov if they are not NULL.
As checkpatch pointed out, we also avoid crashing the kernel when riov and wiov are both NULL, replacing BUG() with WARN_ON() and returning -EINVAL.
--- drivers/vhost/vringh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/vhost/vringh.c +5 -4
@@ -284,13 +284,14 @@ __vringh_iov(struct vringh *vrh, u16 i, desc_max = vrh->vring.num; up_next =-1 ; +/* You must want something! */ +if (WARN_ON (!riov && !wiov)) +return -EINVAL ; +if (riov) riov->i = riov->used =0 ; -else if (wiov) +if (wiov) wiov->i = wiov->used =0 ; -else -/* You must want something! */ -BUG ();for (;;) {void *addr;
Greg Kroah-Hartman
maintainerPATCH 340/391 ext4: fix leaking sysfs kobject after failed mount
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit cb8d53d2c97369029cc638c9274ac7be0a316c75 upstream.
ext4_unregister_sysfs() only deletes the kobject. The reference to it needs to be put separately, like ext4_put_super() does.
This addresses the syzbot report
"memory leak in kobject_set_name_vargs (3)"
(https://syzkaller.appspot.com/bug?extid=9f864abad79fae7c17e1).
--- fs/ext4/super.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/super.c +1 -0
@@ -4872,6 +4872,7 @@ cantfind_ext4: failed_mount8:ext4_unregister_sysfs (sb); +kobject_put (&sbi->s_kobj); failed_mount7:ext4_unregister_li_request (sb); failed_mount6:
Greg Kroah-Hartman
maintainerPATCH 341/391 ext4: fix error handling code in add_new_gdb
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
commit c9e87161cc621cbdcfc472fa0b2d81c63780c8f5 upstream.
When ext4_journal_get_write_access() fails, we should terminate the execution flow and release n_group_desc, iloc.bh, dind and gdb_bh.
--- fs/ext4/resize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/resize.c +3 -1
@@ -843,8 +843,10 @@ static int add_new_gdb(handle_t *handle,BUFFER_TRACE (dind,"get_write_access" ); err =ext4_journal_get_write_access (handle, dind); -if (unlikely (err)) +if (unlikely (err)) {ext4_std_error (sb, err); + goto errout; + }/* ext4_reserve_inode_write() gets a reference on the iloc */ err =ext4_reserve_inode_write (handle, inode, &iloc);
Greg Kroah-Hartman
maintainerPATCH 307/391 ubifs: Dont parse authentication mount options in remount process
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit bb674a4d4de1032837fcbf860a63939e66f0b7ad upstream.
There is no need to dump authentication options while remounting, because authentication initialization can only be doing once in the first mount process. Dumping authentication mount options in remount process may cause memory leak if UBIFS has already been mounted with old authentication mount options.
--- fs/ubifs/super.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
fs/ubifs/super.c +12 -6
@@ -1110,14 +1110,20 @@ static int ubifs_parse_options(struct ubbreak ; }case Opt_auth_key: - c->auth_key_name =kstrdup (args[0 ].from,GFP_KERNEL ); -if (!c->auth_key_name) -return -ENOMEM ; +if (!is_remount) { + c->auth_key_name =kstrdup (args[0 ].from, +GFP_KERNEL ); +if (!c->auth_key_name) +return -ENOMEM ; + }break ;case Opt_auth_hash_name: - c->auth_hash_name =kstrdup (args[0 ].from,GFP_KERNEL ); -if (!c->auth_hash_name) -return -ENOMEM ; +if (!is_remount) { + c->auth_hash_name =kstrdup (args[0 ].from, +GFP_KERNEL ); +if (!c->auth_hash_name) +return -ENOMEM ; + }break ;case Opt_ignore:break ;
Greg Kroah-Hartman
maintainerPATCH 308/391 ubifs: mount_ubifs: Release authentication resource in error handling path
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit e2a05cc7f8229e150243cdae40f2af9021d67a4a upstream.
Release the authentication related resource in some error handling branches in mount_ubifs().
--- fs/ubifs/super.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ubifs/super.c +6 -4
@@ -1331,7 +1331,7 @@ static int mount_ubifs(struct ubifs_info err =ubifs_read_superblock (c);if (err) - goto out_free; + goto out_auth; c->probing =0 ;
@@ -1343,18 +1343,18 @@ static int mount_ubifs(struct ubifs_infoubifs_err (c,"'compressor \"%s\" is not compiled in" ,ubifs_compr_name (c, c->default_compr)); err = -ENOTSUPP ; - goto out_free; + goto out_auth; } err =init_constants_sb (c);if (err) - goto out_free; + goto out_auth; sz =ALIGN (c->max_idx_node_sz, c->min_io_size) *2 ; c->cbuf =kmalloc (sz,GFP_NOFS );if (!c->cbuf) { err = -ENOMEM ; - goto out_free; + goto out_auth; } err =alloc_wbufs (c);
@@ -1629,6 +1629,8 @@ out_wbufs:free_wbufs (c); out_cbuf:kfree (c->cbuf); +out_auth: +ubifs_exit_authentication (c); out_free:kfree (c->write_reserve_buf);kfree (c->bu.buf);
Greg Kroah-Hartman
maintainerPATCH 309/391 perf vendor events amd: Add L2 Prefetch events for zen1
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 60d804521ec4cd01217a96f33cd1bb29e295333d upstream.
Later revisions of PPRs that post-date the original Family 17h events submission patch add these events.
Specifically, they were not in this 2017 revision of the F17h PPR:
Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors Rev 1.14 - April 15, 2017
But e.g., are included in this 2019 version of the PPR:
Processor Programming Reference (PPR) for AMD Family 17h Model 18h, Revision B1 Processors Rev. 3.14 - Sep 26, 2019
--- tools/perf/pmu-events/arch/x86/amdzen1/cache.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tools/perf/pmu-events/arch/x86/amdzen1/cache.json +18 -0
@@ -250,6 +250,24 @@ "UMask": "0x1" }, { + "EventName": "l2_pf_hit_l2", + "EventCode": "0x70", + "BriefDescription": "L2 prefetch hit in L2.", + "UMask": "0xff" + }, + { + "EventName": "l2_pf_miss_l2_hit_l3", + "EventCode": "0x71", + "BriefDescription": "L2 prefetcher hits in L3. Counts all L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit the L3.", + "UMask": "0xff" + }, + { + "EventName": "l2_pf_miss_l2_l3", + "EventCode": "0x72", + "BriefDescription": "L2 prefetcher misses in L3. All L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches.", + "UMask": "0xff" + }, + { "EventName": "l3_request_g1.caching_l3_cache_accesses", "EventCode": "0x01", "BriefDescription": "Caching: L3 cache accesses",
Greg Kroah-Hartman
maintainerPATCH 301/391 NFSv4.2: support EXCHGID4_FLAG_SUPP_FENCE_OPS 4.2 EXCHANGE_ID flag
In reply to Greg Kroah-HartmanFrom: Olga Kornievskaia <[email protected]>
commit 8c39076c276be0b31982e44654e2c2357473258a upstream.
RFC 7862 introduced a new flag that either client or server is allowed to set: EXCHGID4_FLAG_SUPP_FENCE_OPS.
Client needs to update its bitmask to allow for this flag value.
v2: changed minor version argument to unsigned int
--- fs/nfs/nfs4proc.c | 9 ++++++--- include/uapi/linux/nfs4.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +6 -3
@@ -8052,9 +8052,11 @@ int nfs4_proc_secinfo(struct inode *dir,* both PNFS and NON_PNFS flags set, and not having one of NON_PNFS, PNFS, or * DS flags set. */ -static int nfs4_check_cl_exchange_flags (u32 flags) +static int nfs4_check_cl_exchange_flags (u32 flags,u32 version) { -if (flags & ~EXCHGID4_FLAG_MASK_R ) +if (version >=2 && (flags & ~EXCHGID4_2_FLAG_MASK_R )) + goto out_inval; +else if (version <2 && (flags & ~EXCHGID4_FLAG_MASK_R )) goto out_inval;if ((flags &EXCHGID4_FLAG_USE_PNFS_MDS ) && (flags &EXCHGID4_FLAG_USE_NON_PNFS ))
@@ -8467,7 +8469,8 @@ static int _nfs4_proc_exchange_id(structif (status !=0 ) goto out; - status =nfs4_check_cl_exchange_flags (resp->flags); + status =nfs4_check_cl_exchange_flags (resp->flags, + clp->cl_mvops->minor_version);if (status !=0 ) goto out;
include/uapi/linux/nfs4.h +3 -0
@@ -139,6 +139,8 @@#define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000#define EXCHGID4_FLAG_CONFIRMED_R 0x80000000 + +#define EXCHGID4_FLAG_SUPP_FENCE_OPS 0x00000004/* * Since the validity of these bits depends on whether * they're set in the argument or response, have separate
@@ -146,6 +148,7 @@*/ #define EXCHGID4_FLAG_MASK_A 0x40070103#define EXCHGID4_FLAG_MASK_R 0x80070103 +#define EXCHGID4_2_FLAG_MASK_R 0x80070107#define SEQ4_STATUS_CB_PATH_DOWN 0x00000001#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002
Greg Kroah-Hartman
maintainerPATCH 343/391 ext4: fix invalid inode checksum
In reply to Greg Kroah-HartmanFrom: Luo Meng <[email protected]>
commit 1322181170bb01bce3c228b82ae3d5c6b793164f upstream.
During the stability test, there are some errors:
ext4_lookup:1590: inode #6967: comm fsstress: iget: checksum invalid.
If the inode->i_iblocks too big and doesn't set huge file flag, checksum will not be recalculated when update the inode information to it's buffer. If other inode marks the buffer dirty, then the inconsistent inode will be flushed to disk.
Fix this problem by checking i_blocks in advance.
--- fs/ext4/inode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/inode.c +6 -5
@@ -4982,6 +4982,12 @@ static int ext4_do_update_inode(handle_tif (ext4_test_inode_state (inode,EXT4_STATE_NEW ))memset (raw_inode,0 ,EXT4_SB (inode->i_sb)->s_inode_size); + err =ext4_inode_blocks_set (handle, raw_inode, ei); +if (err) { +spin_unlock (&ei->i_raw_lock); + goto out_brelse; + } + raw_inode->i_mode =cpu_to_le16 (inode->i_mode); i_uid =i_uid_read (inode); i_gid =i_gid_read (inode);
@@ -5015,11 +5021,6 @@ static int ext4_do_update_inode(handle_tEXT4_INODE_SET_XTIME (i_atime, inode, raw_inode);EXT4_EINODE_SET_XTIME (i_crtime, ei, raw_inode); - err =ext4_inode_blocks_set (handle, raw_inode, ei); -if (err) { -spin_unlock (&ei->i_raw_lock); - goto out_brelse; - } raw_inode->i_dtime =cpu_to_le32 (ei->i_dtime); raw_inode->i_flags =cpu_to_le32 (ei->i_flags &0xFFFFFFFF );if (likely (!test_opt2 (inode->i_sb,HURD_COMPAT )))
Greg Kroah-Hartman
maintainerPATCH 352/391 mmc: sdhci: Use Auto CMD Auto Select only when v4_mode is true
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
commit b3e1ea16fb39fb6e1a1cf1dbdd6738531de3dc7d upstream.
sdhci-of-dwcmshc meets an eMMC read performance regression with below command after commit 427b6514d095 ("mmc: sdhci: Add Auto CMD Auto Select support"):
dd if=/dev/mmcblk0 of=/dev/null bs=8192 count=100000
Before the commit, the above command gives 120MB/s After the commit, the above command gives 51.3 MB/s
So it looks like sdhci-of-dwcmshc expects Version 4 Mode for Auto CMD Auto Select. Fix the performance degradation by ensuring v4_mode is true to use Auto CMD Auto Select.
--- drivers/mmc/host/sdhci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +4 -2
@@ -1384,9 +1384,11 @@ static inline void sdhci_auto_cmd_select/* * In case of Version 4.10 or later, use of 'Auto CMD Auto * Select' is recommended rather than use of 'Auto CMD12 -* Enable' or 'Auto CMD23 Enable'. +* Enable' or 'Auto CMD23 Enable'. We require Version 4 Mode +* here because some controllers (e.g sdhci-of-dwmshc) expect it. */ -if (host->version >=SDHCI_SPEC_410 && (use_cmd12 || use_cmd23)) { +if (host->version >=SDHCI_SPEC_410 && host->v4_mode && + (use_cmd12 || use_cmd23)) { *mode |=SDHCI_TRNS_AUTO_SEL ; ctrl2 =sdhci_readw (host,SDHCI_HOST_CONTROL2 );
Greg Kroah-Hartman
maintainerPATCH 355/391 futex: Adjust absolute futex timeouts with per time namespace offset
In reply to Greg Kroah-HartmanFrom: Andrei Vagin <[email protected]>
commit c2f7d08cccf4af2ce6992feaabb9e68e4ae0bff3 upstream.
For all commands except FUTEX_WAIT, the timeout is interpreted as an absolute value. This absolute value is inside the task's time namespace and has to be converted to the host's time.
--- kernel/futex.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/futex.c +5 -0
@@ -39,6 +39,7 @@#include <linux/freezer.h> #include <linux/memblock.h> #include <linux/fault-inject.h> +#include <linux/time_namespace.h> #include <asm/futex.h>
@@ -3799,6 +3800,8 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad t =timespec64_to_ktime (ts);if (cmd ==FUTEX_WAIT ) t =ktime_add_safe (ktime_get (), t); +else if (!(op &FUTEX_CLOCK_REALTIME )) + t =timens_ktime_to_host (CLOCK_MONOTONIC , t); tp = &t; }/*
@@ -3991,6 +3994,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user t =timespec64_to_ktime (ts);if (cmd ==FUTEX_WAIT ) t =ktime_add_safe (ktime_get (), t); +else if (!(op &FUTEX_CLOCK_REALTIME )) + t =timens_ktime_to_host (CLOCK_MONOTONIC , t); tp = &t; } if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
Greg Kroah-Hartman
maintainerPATCH 356/391 drm/amdgpu/swsmu: drop smu i2c bus on navi1x
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 10105d0c9763f058f6a9a09f78397d5bf94dc94c upstream.
Stop registering the SMU i2c bus on navi1x. This leads to instability issues when userspace processes mess with the bus and also seems to cause display stability issues in some cases.
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +0 -26
@@ -2463,37 +2463,11 @@ static const struct i2c_algorithm navi10 .functionality = navi10_i2c_func, }; -static int navi10_i2c_control_init (struct smu_context *smu,struct i2c_adapter *control) -{ -struct amdgpu_device *adev =to_amdgpu_device (control); -int res; - - control->owner =THIS_MODULE ; - control->class =I2C_CLASS_SPD ; - control->dev.parent = &adev->pdev->dev; - control->algo = &navi10_i2c_algo; -snprintf (control->name,sizeof (control->name),"AMDGPU SMU" ); - - res =i2c_add_adapter (control); -if (res) -DRM_ERROR ("Failed to register hw i2c, err: %d\n" , res); - -return res; -} - -static void navi10_i2c_control_fini (struct smu_context *smu,struct i2c_adapter *control) -{ -i2c_del_adapter (control); -} - -static const struct pptable_funcs navi10_ppt_funcs = { .get_allowed_feature_mask = navi10_get_allowed_feature_mask, .set_default_dpm_table = navi10_set_default_dpm_table, .dpm_set_vcn_enable = navi10_dpm_set_vcn_enable, .dpm_set_jpeg_enable = navi10_dpm_set_jpeg_enable, - .i2c_init = navi10_i2c_control_init, - .i2c_fini = navi10_i2c_control_fini, .print_clk_levels = navi10_print_clk_levels, .force_clk_levels = navi10_force_clk_levels, .populate_umd_state_clk = navi10_populate_umd_state_clk,
Greg Kroah-Hartman
maintainerPATCH 357/391 drm/amd/pm: increase mclk switch threshold to 200 us
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 83da6eea3af669ee0b1f1bc05ffd6150af984994 upstream.
To avoid underflow seen on Polaris10 with some 3440x1440 144Hz displays. As the threshold of 190 us cuts too close to minVBlankTime of 192 us.
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +1 -1
@@ -2873,7 +2873,7 @@ static int smu7_vblank_too_short(structif (hwmgr->is_kicker) switch_limit_us = data->is_memory_gddr5 ?450 :150 ;else - switch_limit_us = data->is_memory_gddr5 ?190 :150 ; + switch_limit_us = data->is_memory_gddr5 ?200 :150 ;break ;case CHIP_VEGAM : switch_limit_us =30 ;
Greg Kroah-Hartman
maintainerPATCH 359/391 drm/amd/swsmu: add missing feature map for sienna_cichlid
In reply to Greg Kroah-HartmanFrom: Kevin Wang <[email protected]>
commit d48d7484d8dca1d4577fc53f1f826e68420d00eb upstream.
it will cause smu sysfs node of "pp_features" show error.
--- drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 1 + drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +1 -0
@@ -217,6 +217,7 @@ enum smu_clk_type {__SMU_DUMMY_MAP (DPM_MP0CLK ), \__SMU_DUMMY_MAP (DPM_LINK ), \__SMU_DUMMY_MAP (DPM_DCEFCLK ), \ +__SMU_DUMMY_MAP (DPM_XGMI ), \__SMU_DUMMY_MAP (DS_GFXCLK ), \__SMU_DUMMY_MAP (DS_SOCCLK ), \ __SMU_DUMMY_MAP(DS_LCLK), \
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c +3 -0
@@ -150,14 +150,17 @@ static struct cmn2asic_mapping sienna_ciFEA_MAP (DPM_GFXCLK ),FEA_MAP (DPM_GFX_GPO ),FEA_MAP (DPM_UCLK ), +FEA_MAP (DPM_FCLK ),FEA_MAP (DPM_SOCCLK ),FEA_MAP (DPM_MP0CLK ),FEA_MAP (DPM_LINK ),FEA_MAP (DPM_DCEFCLK ), +FEA_MAP (DPM_XGMI ),FEA_MAP (MEM_VDDCI_SCALING ),FEA_MAP (MEM_MVDD_SCALING ),FEA_MAP (DS_GFXCLK ),FEA_MAP (DS_SOCCLK ), +FEA_MAP (DS_FCLK ),FEA_MAP (DS_LCLK ),FEA_MAP (DS_DCEFCLK ), FEA_MAP(DS_UCLK),
Greg Kroah-Hartman
maintainerPATCH 360/391 drm/amd/psp: Fix sysfs: cannot create duplicate filename
In reply to Greg Kroah-HartmanFrom: Andrey Grodzovsky <[email protected]>
commit f1bcddffe46b349a82445a8d9efd5f5fcb72557f upstream.
psp sysfs not cleaned up on driver unload for sienna_cichlid
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
@@ -206,7 +206,8 @@ static int psp_sw_fini(void *handle) adev->psp.ta_fw =NULL ; } -if (adev->asic_type ==CHIP_NAVI10 ) +if (adev->asic_type ==CHIP_NAVI10 || + adev->asic_type ==CHIP_SIENNA_CICHLID )psp_sysfs_fini (adev);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 344/391 ext4: fix superblock checksum calculation race
In reply to Greg Kroah-HartmanFrom: Constantine Sapuntzakis <[email protected]>
commit acaa532687cdc3a03757defafece9c27aa667546 upstream.
The race condition could cause the persisted superblock checksum to not match the contents of the superblock, causing the superblock to be considered corrupt.
An example of the race follows. A first thread is interrupted in the middle of a checksum calculation. Then, another thread changes the superblock, calculates a new checksum, and sets it. Then, the first thread resumes and sets the checksum based on the older superblock.
To fix, serialize the superblock checksum calculation using the buffer header lock. While a spinlock is sufficient, the buffer header is already there and there is precedent for locking it (e.g. in ext4_commit_super).
Tested the patch by booting up a kernel with the patch, creating a filesystem and some files (including some orphans), and then unmounting and remounting the file system.
--- fs/ext4/super.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/ext4/super.c +11 -0
@@ -201,7 +201,18 @@ void ext4_superblock_csum_set(struct supif (!ext4_has_metadata_csum (sb))return ; +/* +* Locking the superblock prevents the scenario +* where: +* 1) a first thread pauses during checksum calculation. +* 2) a second thread updates the superblock, recalculates +* the checksum, and updates s_checksum +* 3) the first thread resumes and finishes its checksum calculation +* and updates s_checksum with a potentially stale or torn value. +*/ +lock_buffer (EXT4_SB (sb)->s_sbh); es->s_checksum =ext4_superblock_csum (sb, es); +unlock_buffer (EXT4_SB (sb)->s_sbh); } ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
Greg Kroah-Hartman
maintainerPATCH 363/391 arm64: berlin: Select DW_APB_TIMER_OF
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
commit b0fc70ce1f028e14a37c186d9f7a55e51439b83a upstream.
Berlin SoCs always contain some DW APB timers which can be used as an always-on broadcast timer.
--- arch/arm64/Kconfig.platforms | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
@@ -54,6 +54,7 @@ config ARCH_BCM_IPROC config ARCH_BERLIN bool "Marvell Berlin SoC Family" select DW_APB_ICTL + select DW_APB_TIMER_OF select GPIOLIB select PINCTRL help
Greg Kroah-Hartman
maintainerPATCH 364/391 cachefiles: Handle readpage error correctly
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 9480b4e75b7108ee68ecf5bc6b4bd68e8031c521 upstream.
If ->readpage returns an error, it has already unlocked the page.
--- fs/cachefiles/rdwr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cachefiles/rdwr.c +2 -1
@@ -121,7 +121,7 @@ static int cachefiles_read_reissue(struc_debug ("reissue read" ); ret = bmapping->a_ops->readpage (NULL , backpage);if (ret <0 ) - goto unlock_discard; + goto discard; }/* but the page may have been read before the monitor was installed, so
@@ -138,6 +138,7 @@ static int cachefiles_read_reissue(struc unlock_discard:unlock_page (backpage); +discard:spin_lock_irq (&object->work_lock);list_del (&monitor->op_link);spin_unlock_irq (&object->work_lock);
Greg Kroah-Hartman
maintainerPATCH 366/391 arm: dts: mt7623: add missing pause for switchport
In reply to Greg Kroah-HartmanFrom: Frank Wunderlich <[email protected]>
commit 36f0a5fc5284838c544218666c63ee8cfa46a9c3 upstream.
port6 of mt7530 switch (= cpu port 0) on bananapi-r2 misses pause option which causes rx drops on running iperf.
--- arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts +1 -0
@@ -192,6 +192,7 @@ fixed-link { speed = <1000>; full-duplex; + pause; }; }; };
Greg Kroah-Hartman
maintainerPATCH 368/391 ARM: dts: s5pv210: fix pinctrl property of "vibrator-en" regulator in Aries
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 2c6658c607a3af2ed7bd41dc57a3dd31537d023e upstream.
Fix typo in pinctrl property of "vibrator-en" fixed regulator in Aries family of boards. The error caused lack of pin configuration for the GPIO used in vibrator.
--- arch/arm/boot/dts/s5pv210-aries.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/s5pv210-aries.dtsi +1 -1
@@ -66,7 +66,7 @@ gpio = <&gpj1 1 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; - pinctr-0 = <&vibrator_ena>; + pinctrl-0 = <&vibrator_ena>; }; touchkey_vdd: regulator-fixed-1 {
Greg Kroah-Hartman
maintainerPATCH 367/391 ARM: aspeed: g5: Do not set sirq polarity
In reply to Greg Kroah-HartmanFrom: Joel Stanley <[email protected]>
commit c82bf6e133d30e0f9172a20807814fa28aef0f67 upstream.
A feature was added to the aspeed vuart driver to configure the vuart interrupt (sirq) polarity according to the LPC/eSPI strapping register.
Systems that depend on a active low behaviour (sirq_polarity set to 0) such as OpenPower boxes also use LPC, so this relationship does not hold. Jeremy confirms that the s2600st which is strapped for eSPI also does not have this relationship.
The property was added for a Tyan S7106 system which is not supported in the kernel tree. Should this or other systems wish to use this feature of the driver they should add it to the machine specific device tree.
--- arch/arm/boot/dts/aspeed-g5.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/aspeed-g5.dtsi +0 -1
@@ -425,7 +425,6 @@ interrupts = <8>; clocks = <&syscon ASPEED_CLK_APB>; no-loopback-test; - aspeed,sirq-polarity-sense = <&syscon 0x70 25>; status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 369/391 ARM: config: aspeed: Fix selection of media drivers
In reply to Greg Kroah-HartmanFrom: Joel Stanley <[email protected]>
commit 98c3f0a1b3ef83f6be6b212c970bee795e1a0467 upstream.
In the 5.7 merge window the media kconfig was restructued. For most platforms these changes set CONFIG_MEDIA_SUPPORT_FILTER=y which keeps unwanted drivers disabled.
The exception is if a config sets EMBEDDED or EXPERT (see b0cd4fb27665). In that case the filter is set to =n, causing a bunch of DVB tuner drivers (MEDIA_TUNER_*) to be accidentally enabled. This was noticed as it blew out the build time for the Aspeed defconfigs.
Enabling the filter means the Aspeed config also needs to set CONFIG_MEDIA_PLATFORM_SUPPORT=y in order to have the CONFIG_VIDEO_ASPEED driver enabled.
--- arch/arm/configs/aspeed_g4_defconfig | 3 ++- arch/arm/configs/aspeed_g5_defconfig | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/configs/aspeed_g4_defconfig +2 -1
@@ -160,7 +160,8 @@ CONFIG_SENSORS_TMP421=y CONFIG_SENSORS_W83773G=y CONFIG_WATCHDOG_SYSFS=y CONFIG_MEDIA_SUPPORT=y -CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_SUPPORT_FILTER=y +CONFIG_MEDIA_PLATFORM_SUPPORT=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_VIDEO_ASPEED=y CONFIG_DRM=y
arch/arm/configs/aspeed_g5_defconfig +2 -1
@@ -175,7 +175,8 @@ CONFIG_SENSORS_TMP421=y CONFIG_SENSORS_W83773G=y CONFIG_WATCHDOG_SYSFS=y CONFIG_MEDIA_SUPPORT=y -CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_SUPPORT_FILTER=y +CONFIG_MEDIA_PLATFORM_SUPPORT=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_VIDEO_ASPEED=y CONFIG_DRM=y
Greg Kroah-Hartman
maintainerPATCH 371/391 ARM: s3c24xx: fix missing system reset
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit f6d7cde84f6c5551586c8b9b68d70f8e6dc9a000 upstream.
Commit f6361c6b3880 ("ARM: S3C24XX: remove separate restart code") removed usage of the watchdog reset platform code in favor of the Samsung SoC watchdog driver. However the latter was not selected thus S3C24xx platforms lost reset abilities.
--- arch/arm/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/Kconfig +2 -0
@@ -506,8 +506,10 @@ config ARCH_S3C24XX select HAVE_S3C2410_WATCHDOG if WATCHDOG select HAVE_S3C_RTC if RTC_CLASS select NEED_MACH_IO_H + select S3C2410_WATCHDOG select SAMSUNG_ATAGS select USE_OF + select WATCHDOG help Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443 and S3C2450 SoCs based systems, such as the Simtec Electronics BAST
Greg Kroah-Hartman
maintainerPATCH 345/391 ext4: clear buffer verified flag if read meta block from disk
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
commit d9befedaafcf3a111428baa7c45b02923eab2d87 upstream.
The metadata buffer is no longer trusted after we read it from disk again because it is not uptodate for some reasons (e.g. failed to write back). Otherwise we may get below memory corruption problem in ext4_ext_split()->memset() if we read stale data from the newly allocated extent block on disk which has been failed to async write out but miss verify again since the verified bit has already been set on the buffer.
[ 29.774674] BUG: unable to handle kernel paging request at ffff88841949d000 ... [ 29.783317] Oops: 0002 [#2] SMP [ 29.784219] R10: 00000000000f4240 R11: 0000000000002e28 R12: ffff88842fa1c800 [ 29.784627] CPU: 1 PID: 126 Comm: kworker/u4:3 Tainted: G D W [ 29.785546] R13: ffffffff9cddcc20 R14: ffffffff9cddd420 R15: ffff88842fa1c2f8 [ 29.786679] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),BIOS ?-20190727_0738364 [ 29.787588] FS: 0000000000000000(0000) GS:ffff88842fa00000(0000) knlGS:0000000000000000 [ 29.789288] Workqueue: writeback wb_workfn [ 29.790319] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.790321] (flush-8:0) [ 29.790844] CR2: 0000000000000008 CR3: 00000004234f2000 CR4: 00000000000006f0 [ 29.791924] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 29.792839] RIP: 0010:__memset+0x24/0x30 [ 29.793739] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 29.794256] Code: 90 90 90 90 90 90 0f 1f 44 00 00 49 89 f9 48 89 d1 83 e2 07 48 c1 e9 033 [ 29.795161] Kernel panic - not syncing: Fatal exception in interrupt ... [ 29.808149] Call Trace: [ 29.808475] ext4_ext_insert_extent+0x102e/0x1be0 [ 29.809085] ext4_ext_map_blocks+0xa89/0x1bb0 [ 29.809652] ext4_map_blocks+0x290/0x8a0 [ 29.809085] ext4_ext_map_blocks+0xa89/0x1bb0 [ 29.809652] ext4_map_blocks+0x290/0x8a0 [ 29.810161] ext4_writepages+0xc85/0x17c0
...
Fix this by clearing buffer's verified bit if we read meta block from disk again.
--- fs/ext4/balloc.c | 1 + fs/ext4/extents.c | 1 + fs/ext4/ialloc.c | 1 + fs/ext4/inode.c | 5 ++++- fs/ext4/super.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)
fs/ext4/balloc.c +1 -0
@@ -494,6 +494,7 @@ ext4_read_block_bitmap_nowait(struct sup* submit the buffer_head for reading */ set_buffer_new (bh); +clear_buffer_verified (bh);trace_ext4_read_block_bitmap_load (sb, block_group, ignore_locked); bh->b_end_io = ext4_end_bitmap_read;get_bh (bh);
fs/ext4/extents.c +1 -0
@@ -501,6 +501,7 @@ __read_extent_tree_block(const char *funif (!bh_uptodate_or_lock (bh)) {trace_ext4_ext_load_extent (inode, pblk, _RET_IP_); +clear_buffer_verified (bh); err =bh_submit_read (bh);if (err <0 ) goto errout;
fs/ext4/ialloc.c +1 -0
@@ -188,6 +188,7 @@ ext4_read_inode_bitmap(struct super_bloc/* * submit the buffer_head for reading */ +clear_buffer_verified (bh);trace_ext4_load_inode_bitmap (sb, block_group); bh->b_end_io = ext4_end_bitmap_read;get_bh (bh);
fs/ext4/inode.c +4 -1
@@ -884,6 +884,7 @@ struct buffer_head *ext4_bread(handle_treturn bh;if (!bh ||ext4_buffer_uptodate (bh))return bh; +clear_buffer_verified (bh);ll_rw_block (REQ_OP_READ ,REQ_META |REQ_PRIO ,1 , &bh);wait_on_buffer (bh);if (buffer_uptodate (bh))
@@ -909,9 +910,11 @@ int ext4_bread_batch(struct inode *inodefor (i =0 ; i < bh_count; i++)/* Note that NULL bhs[i] is valid because of holes. */ -if (bhs[i] && !ext4_buffer_uptodate (bhs[i])) +if (bhs[i] && !ext4_buffer_uptodate (bhs[i])) { +clear_buffer_verified (bhs[i]);ll_rw_block (REQ_OP_READ ,REQ_META |REQ_PRIO ,1 , &bhs[i]); + }if (!wait)return 0 ;
fs/ext4/super.c +1 -0
@@ -156,6 +156,7 @@ ext4_sb_bread(struct super_block *sb, sereturn ERR_PTR (-ENOMEM );if (ext4_buffer_uptodate (bh))return bh; +clear_buffer_verified (bh);ll_rw_block (REQ_OP_READ ,REQ_META | op_flags,1 , &bh);wait_on_buffer (bh);if (buffer_uptodate (bh))
Greg Kroah-Hartman
maintainerPATCH 372/391 arm64: Change .weak to SYM_FUNC_START_WEAK_PI for arch/arm64/lib/mem*.S
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit ec9d78070de986ecf581ea204fd322af4d2477ec upstream.
Commit 39d114ddc682 ("arm64: add KASAN support") added .weak directives to arch/arm64/lib/mem*.S instead of changing the existing SYM_FUNC_START_PI macros. This can lead to the assembly snippet .weak memcpy ... .globl memcpy which will produce a STB_WEAK memcpy with GNU as but STB_GLOBAL memcpy with LLVM's integrated assembler before LLVM 12. LLVM 12 (since
https://reviews.llvm.org/D90108) will error on such an overridden symbol binding.
Use the appropriate SYM_FUNC_START_WEAK_PI instead.
--- arch/arm64/lib/memcpy.S | 3 +-- arch/arm64/lib/memmove.S | 3 +-- arch/arm64/lib/memset.S | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
arch/arm64/lib/memcpy.S +1 -2
@@ -56,9 +56,8 @@ stp \reg1, \reg2, [\ptr], \val .endm - .weak memcpy SYM_FUNC_START_ALIAS(__memcpy) -SYM_FUNC_START_PI(memcpy) +SYM_FUNC_START_WEAK_PI(memcpy) #include "copy_template.S" ret SYM_FUNC_END_PI(memcpy)
arch/arm64/lib/memmove.S +1 -2
@@ -45,9 +45,8 @@ C_h .req x12 D_l .req x13 D_h .req x14 - .weak memmove SYM_FUNC_START_ALIAS(__memmove) -SYM_FUNC_START_PI(memmove) +SYM_FUNC_START_WEAK_PI(memmove) cmp dstin, src b.lo __memcpy add tmp1, src, count
arch/arm64/lib/memset.S +1 -2
@@ -42,9 +42,8 @@ dst .req x8 tmp3w .req w9 tmp3 .req x9 - .weak memset SYM_FUNC_START_ALIAS(__memset) -SYM_FUNC_START_PI(memset) +SYM_FUNC_START_WEAK_PI(memset) mov dst, dstin /* Preserve return value. */ and A_lw, val, #255 orr A_lw, A_lw, A_lw, lsl #8
Greg Kroah-Hartman
maintainerPATCH 374/391 null_blk: synchronization fix for zoned device
In reply to Greg Kroah-HartmanFrom: Kanchan Joshi <[email protected]>
commit 35bc10b2eafbb701064b94f283b77c54d3304842 upstream.
Parallel write,read,zone-mgmt operations accessing/altering zone state and write-pointer may get into race. Avoid the situation by using a new spinlock for zoned device.
Concurrent zone-appends (on a zone) returning same write-pointer issue is also avoided using this lock.
--- drivers/block/null_blk.h | 1 + drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/block/null_blk.h +1 -0
@@ -44,6 +44,7 @@ struct nullb_device {unsigned int nr_zones;struct blk_zone *zones;sector_t zone_size_sects; +spinlock_t zone_lock;unsigned long size;/* device size in MB */ unsigned long completion_nsec;/* time in ns to complete a request */
drivers/block/null_blk_zoned.c +18 -4
@@ -45,6 +45,7 @@ int null_init_zoned_dev(struct nullb_devif (!dev->zones)return -ENOMEM ; +spin_lock_init (&dev->zone_lock);if (dev->zone_nr_conv >= dev->nr_zones) { dev->zone_nr_conv = dev->nr_zones -1 ; pr_info("changed the number of conventional zones to %u",
@@ -131,8 +132,11 @@ int null_report_zones(struct gendisk *di* So use a local copy to avoid corruption of the device zone * array. */ +spin_lock_irq (&dev->zone_lock);memcpy (&zone, &dev->zones[first_zone + i],sizeof (struct blk_zone )); +spin_unlock_irq (&dev->zone_lock); + error =cb (&zone, i, data);if (error)return error;
@@ -277,18 +281,28 @@ static blk_status_t null_zone_mgmt(strucblk_status_t null_process_zoned_cmd (struct nullb_cmd *cmd,enum req_opf op,sector_t sector,sector_t nr_sectors) { +blk_status_t sts; +struct nullb_device *dev = cmd->nq->dev; + +spin_lock_irq (&dev->zone_lock);switch (op) {case REQ_OP_WRITE : -return null_zone_write (cmd, sector, nr_sectors, false); + sts =null_zone_write (cmd, sector, nr_sectors, false); +break ;case REQ_OP_ZONE_APPEND : -return null_zone_write (cmd, sector, nr_sectors, true); + sts =null_zone_write (cmd, sector, nr_sectors, true); +break ;case REQ_OP_ZONE_RESET :case REQ_OP_ZONE_RESET_ALL :case REQ_OP_ZONE_OPEN :case REQ_OP_ZONE_CLOSE :case REQ_OP_ZONE_FINISH : -return null_zone_mgmt (cmd, op, sector); + sts =null_zone_mgmt (cmd, op, sector); +break ;default : -return null_process_cmd (cmd, op, sector, nr_sectors); + sts =null_process_cmd (cmd, op, sector, nr_sectors); } +spin_unlock_irq (&dev->zone_lock); + +return sts; }
Greg Kroah-Hartman
maintainerPATCH 375/391 coresight: cti: Initialize dynamic sysfs attributes
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit 80624263fa289b3416f7ca309491f1b75e579477 upstream.
With LOCKDEP enabled, CTI driver triggers the following splat due to uninitialized lock class for dynamically allocated attribute objects.
[ 5.372901] coresight etm0: CPU0: ETM v4.0 initialized [ 5.376694] coresight etm1: CPU1: ETM v4.0 initialized [ 5.380785] coresight etm2: CPU2: ETM v4.0 initialized [ 5.385851] coresight etm3: CPU3: ETM v4.0 initialized [ 5.389808] BUG: key ffff00000564a798 has not been registered! [ 5.392456] ------------[ cut here ]------------ [ 5.398195] DEBUG_LOCKS_WARN_ON(1) [ 5.398233] WARNING: CPU: 1 PID: 32 at kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x14c/0x260 [ 5.406149] Modules linked in: [ 5.415411] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.9.0-12034-gbbe85027ce80 #51 [ 5.418553] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 5.426453] Workqueue: events amba_deferred_retry_func [ 5.433299] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--) [ 5.438252] pc : lockdep_init_map_waits+0x14c/0x260 [ 5.444410] lr : lockdep_init_map_waits+0x14c/0x260 [ 5.449007] sp : ffff800012bbb720
...
[ 5.531561] Call trace: [ 5.536847] lockdep_init_map_waits+0x14c/0x260 [ 5.539027] __kernfs_create_file+0xa8/0x1c8 [ 5.543539] sysfs_add_file_mode_ns+0xd0/0x208 [ 5.548054] internal_create_group+0x118/0x3c8 [ 5.552307] internal_create_groups+0x58/0xb8 [ 5.556733] sysfs_create_groups+0x2c/0x38 [ 5.561160] device_add+0x2d8/0x768 [ 5.565148] device_register+0x28/0x38 [ 5.568537] coresight_register+0xf8/0x320 [ 5.572358] cti_probe+0x1b0/0x3f0
...
Fix this by initializing the attributes when they are allocated.
--- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +7 -0
@@ -1065,6 +1065,13 @@ static int cti_create_con_sysfs_attr(str } eattr->var = con; con->con_attrs[attr_idx] = &eattr->attr.attr; +/* +* Initialize the dynamically allocated attribute +* to avoid LOCKDEP splat. See include/linux/sysfs.h +* for more details. +*/ +sysfs_attr_init (con->con_attrs[attr_idx]); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 376/391 device property: Keep secondary firmware node secondary by type
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit d5dcce0c414fcbfe4c2037b66ac69ea5f9b3f75c upstream.
Behind primary and secondary we understand the type of the nodes which might define their ordering. However, if primary node gone, we can't maintain the ordering by definition of the linked list. Thus, by ordering secondary node becomes first in the list. But in this case the meaning of it is still secondary (or auxiliary). The type of the node is maintained by the secondary pointer in it:
secondary pointer Meaning
NULL or valid primary node
ERR_PTR(-ENODEV) secondary node
So, if by some reason we do the following sequence of calls
set_primary_fwnode(dev, NULL); set_primary_fwnode(dev, primary);
we should preserve secondary node.
This concept is supported by the description of set_primary_fwnode() along with implementation of set_secondary_fwnode(). Hence, fix the commit c15e1bdda436 to follow this as well.
--- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
@@ -4274,7 +4274,7 @@ void set_primary_fwnode(struct device *d }else {if (fwnode_is_primary (fn)) { dev->fwnode = fn->secondary; - fn->secondary =NULL ; + fn->secondary =ERR_PTR (-ENODEV ); }else { dev->fwnode =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 373/391 arm64: dts: marvell: espressobin: Add ethernet switch aliases
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit b64d814257b027e29a474bcd660f6372490138c7 upstream.
Espressobin boards have 3 ethernet ports and some of them got assigned more then one MAC address. MAC addresses are stored in U-Boot environment.
Since commit a2c7023f7075c ("net: dsa: read mac address from DT for slave device") kernel can use MAC addresses from DT for particular DSA port.
Currently Espressobin DTS file contains alias just for ethernet0.
This patch defines additional ethernet aliases in Espressobin DTS files, so bootloader can fill correct MAC address for DSA switch ports if more MAC addresses were specified.
DT alias ethernet1 is used for wan port, DT aliases ethernet2 and ethernet3 are used for lan ports for both Espressobin revisions (V5 and V7).
--- arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts | 10 ++++++-- arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts | 10 ++++++-- arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi | 12 ++++++---- 3 files changed, 24 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts +8 -2
@@ -20,17 +20,23 @@ compatible = "globalscale,espressobin-v7-emmc", "globalscale,espressobin-v7", "globalscale,espressobin", "marvell,armada3720", "marvell,armada3710"; + + aliases { + /* ethernet1 is wan port */ + ethernet1 = &switch0port3; + ethernet3 = &switch0port1; + }; }; &switch0 { ports { - port@1 { + switch0port1: port@1 { reg = <1>; label = "lan1"; phy-handle = <&switch0phy0>; }; - port@3 { + switch0port3: port@3 { reg = <3>; label = "wan"; phy-handle = <&switch0phy2>;
arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts +8 -2
@@ -19,17 +19,23 @@ model = "Globalscale Marvell ESPRESSOBin Board V7"; compatible = "globalscale,espressobin-v7", "globalscale,espressobin", "marvell,armada3720", "marvell,armada3710"; + + aliases { + /* ethernet1 is wan port */ + ethernet1 = &switch0port3; + ethernet3 = &switch0port1; + }; }; &switch0 { ports { - port@1 { + switch0port1: port@1 { reg = <1>; label = "lan1"; phy-handle = <&switch0phy0>; }; - port@3 { + switch0port3: port@3 { reg = <3>; label = "wan"; phy-handle = <&switch0phy2>;
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi +8 -4
@@ -13,6 +13,10 @@ / { aliases { ethernet0 = ð0; + /* for dsa slave device */ + ethernet1 = &switch0port1; + ethernet2 = &switch0port2; + ethernet3 = &switch0port3; serial0 = &uart0; serial1 = &uart1; };
@@ -120,7 +124,7 @@ #address-cells = <1>; #size-cells = <0>; - port@0 { + switch0port0: port@0 { reg = <0>; label = "cpu"; ethernet = <ð0>;
@@ -131,19 +135,19 @@ }; }; - port@1 { + switch0port1: port@1 { reg = <1>; label = "wan"; phy-handle = <&switch0phy0>; }; - port@2 { + switch0port2: port@2 { reg = <2>; label = "lan0"; phy-handle = <&switch0phy1>; }; - port@3 { + switch0port3: port@3 { reg = <3>; label = "lan1"; phy-handle = <&switch0phy2>;
Greg Kroah-Hartman
maintainerPATCH 381/391 staging: fieldbus: anybuss: jump to correct label in an error path
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
commit 7e97e4cbf30026b49b0145c3bfe06087958382c5 upstream.
In current code, controller_probe() misses to call ida_simple_remove() in an error path. Jump to correct label to fix it.
--- drivers/staging/fieldbus/anybuss/arcx-anybus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fieldbus/anybuss/arcx-anybus.c +1 -1
@@ -293,7 +293,7 @@ static int controller_probe(struct platf regulator =devm_regulator_register (dev, &can_power_desc, &config);if (IS_ERR (regulator)) { err =PTR_ERR (regulator); - goto out_reset; + goto out_ida; }/* make controller info visible to userspace */ cd->class_dev =kzalloc (sizeof (*cd->class_dev),GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 347/391 ext4: fix bs < ps issue reported with dioread_nolock mount opt
In reply to Greg Kroah-HartmanFrom: Ritesh Harjani <[email protected]>
commit d1e18b8824dd50cff255e6cecf515ea598eaf9f0 upstream.
left shifting m_lblk by blkbits was causing value overflow and hence it was not able to convert unwritten to written extent.
So, make sure we typecast it to loff_t before do left shift operation. Also in func ext4_convert_unwritten_io_end_vec(), make sure to initialize ret variable to avoid accidentally returning an uninitialized ret.
This patch fixes the issue reported in ext4 for bs < ps with dioread_nolock mount option.
--- fs/ext4/extents.c | 2 +- fs/ext4/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents.c +1 -1
@@ -4770,7 +4770,7 @@ int ext4_convert_unwritten_extents(handlint ext4_convert_unwritten_io_end_vec (handle_t *handle,ext4_io_end_t *io_end) { -int ret, err =0 ; +int ret =0 , err =0 ;struct ext4_io_end_vec *io_end_vec;/*
fs/ext4/inode.c +1 -1
@@ -2257,7 +2257,7 @@ static int mpage_process_page(struct mpa err =PTR_ERR (io_end_vec); goto out; } - io_end_vec->offset = mpd->map.m_lblk << blkbits; + io_end_vec->offset = (loff_t )mpd->map.m_lblk << blkbits; } *map_bh = true; goto out;
Greg Kroah-Hartman
maintainerPATCH 348/391 ext4: do not use extent after put_bh
In reply to Greg Kroah-HartmanFrom: yangerkun <[email protected]>
commit d7dce9e08595e80bf8039a81794809c66fe26431 upstream.
ext4_ext_search_right() will read more extent blocks and call put_bh after we get the information we need. However, ret_ex will break this and may cause use-after-free once pagecache has been freed. Fix it by copying the extent structure if needed.
--- fs/ext4/extents.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
fs/ext4/extents.c +15 -15
@@ -1472,16 +1472,16 @@ static int ext4_ext_search_left(struct i }/* -* search the closest allocated block to the right for *logical -* and returns it at @logical + it's physical address at @phys -* if *logical is the largest allocated block, the function -* returns 0 at @phys -* return value contains 0 (success) or error code +* Search the closest allocated block to the right for *logical +* and returns it at @logical + it's physical address at @phys. +* If not exists, return 0 and @phys is set to 0. We will return +* 1 which means we found an allocated block and ret_ex is valid. +* Or return a (< 0) error code. */ static int ext4_ext_search_right (struct inode *inode,struct ext4_ext_path *path,ext4_lblk_t *logical,ext4_fsblk_t *phys, -struct ext4_extent **ret_ex) +struct ext4_extent *ret_ex) {struct buffer_head *bh =NULL ;struct ext4_extent_header *eh;
@@ -1575,10 +1575,11 @@ got_index: found_extent: *logical =le32_to_cpu (ex->ee_block); *phys =ext4_ext_pblock (ex); - *ret_ex = ex; +if (ret_ex) + *ret_ex = *ex;if (bh)put_bh (bh); -return 0 ; +return 1 ; }/*
@@ -2869,8 +2870,8 @@ again:*/ lblk = ex_end +1 ; err =ext4_ext_search_right (inode, path, &lblk, &pblk, - &ex); -if (err) +NULL ); +if (err <0 ) goto out;if (pblk) { partial.pclu =EXT4_B2C (sbi, pblk);
@@ -4038,7 +4039,7 @@ int ext4_ext_map_blocks(handle_t *handle struct ext4_map_blocks *map, int flags) {struct ext4_ext_path *path =NULL ; -struct ext4_extent newex, *ex, *ex2; +struct ext4_extent newex, *ex, ex2;struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);ext4_fsblk_t newblock =0 , pblk;int err =0 , depth, ret;
@@ -4174,15 +4175,14 @@ int ext4_ext_map_blocks(handle_t *handleif (err) goto out; ar.lright = map->m_lblk; - ex2 =NULL ; err =ext4_ext_search_right (inode, path, &ar.lright, &ar.pright, &ex2); -if (err) +if (err <0 ) goto out;/* Check if the extent after searching to the right implies a * cluster we can use. */ -if ((sbi->s_cluster_ratio >1 ) && ex2 && -get_implied_cluster_alloc (inode->i_sb, map, ex2, path)) { +if ((sbi->s_cluster_ratio >1 ) && err && +get_implied_cluster_alloc (inode->i_sb, map, &ex2, path)) { ar.len = allocated = map->m_len; newblock = map->m_pblk; goto got_allocated_blocks;
Greg Kroah-Hartman
maintainerPATCH 349/391 drm/ttm: fix eviction valuable range check.
In reply to Greg Kroah-HartmanFrom: Dave Airlie <[email protected]>
commit fea456d82c19d201c21313864105876deabe148b upstream.
This was adding size to start, but pfn and start are in pages, so it should be using num_pages.
Not sure this fixes anything in the real world, just noticed it during refactoring.
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
@@ -694,7 +694,7 @@ bool ttm_bo_eviction_valuable(struct ttm/* Don't evict this BO if it's outside of the * requested placement range */ -if (place->fpfn >= (bo->mem.start + bo->mem.size) || +if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) || (place->lpfn && place->lpfn <= bo->mem.start))return false;
Greg Kroah-Hartman
maintainerPATCH 351/391 mmc: sdhci-of-esdhc: set timeout to max before tuning
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
commit 0add6e9b88d0632a25323aaf4987dbacb0e4ae64 upstream.
On rare occations there is the following error:
mmc0: Tuning timeout, falling back to fixed sampling clock
There are SD cards which takes a significant longer time to reply to the first CMD19 command. The eSDHC takes the data timeout value into account during the tuning period. The SDHCI core doesn't explicitly set this timeout for the tuning procedure. Thus on the slow cards, there might be a spurious "Buffer Read Ready" interrupt, which in turn triggers a wrong sequence of events. In the end this will lead to an unsuccessful tuning procedure and to the above error.
To workaround this, set the timeout to the maximum value (which is the best we can do) and the SDHCI core will take care of the proper timeout handling.
--- drivers/mmc/host/sdhci-of-esdhc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/mmc/host/sdhci-of-esdhc.c +11 -0
@@ -1069,6 +1069,17 @@ static int esdhc_execute_tuning(struct mesdhc_tuning_block_enable (host, true); +/* +* The eSDHC controller takes the data timeout value into account +* during tuning. If the SD card is too slow sending the response, the +* timer will expire and a "Buffer Read Ready" interrupt without data +* is triggered. This leads to tuning errors. +* +* Just set the timeout to the maximum value because the core will +* already take care of it in sdhci_send_tuning(). +*/ +sdhci_writeb (host,0xe ,SDHCI_TIMEOUT_CONTROL ); + hs400_tuning = host->flags &SDHCI_HS400_TUNING ; do {
Greg Kroah-Hartman
maintainerPATCH 385/391 cpufreq: Introduce cpufreq_driver_test_flags()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit a62f68f5ca53ab61cba2f0a410d0add7a6d54a52 upstream.
Add a helper function to test the flags of the cpufreq driver in use againt a given flags mask.
In particular, this will be needed to test the CPUFREQ_NEED_UPDATE_LIMITS cpufreq driver flag in the schedutil governor.
--- drivers/cpufreq/cpufreq.c | 12 ++++++++++++ include/linux/cpufreq.h | 1 + 2 files changed, 13 insertions(+)
drivers/cpufreq/cpufreq.c +12 -0
@@ -1904,6 +1904,18 @@ void cpufreq_resume(void) }/** +* cpufreq_driver_test_flags - Test cpufreq driver's flags against given ones. +* @flags: Flags to test against the current cpufreq driver's flags. +* +* Assumes that the driver is there, so callers must ensure that this is the +* case. +*/ +bool cpufreq_driver_test_flags (u16 flags) +{ +return !!(cpufreq_driver->flags & flags); +} + +/** * cpufreq_get_current_driver - return current driver's name * * Return the name string of the currently loaded cpufreq driver
include/linux/cpufreq.h +1 -0
@@ -428,6 +428,7 @@ struct cpufreq_driver {int cpufreq_register_driver (struct cpufreq_driver *driver_data);int cpufreq_unregister_driver (struct cpufreq_driver *driver_data); +bool cpufreq_driver_test_flags (u16 flags);const char *cpufreq_get_current_driver (void );void *cpufreq_get_driver_data (void );
Greg Kroah-Hartman
maintainerPATCH 386/391 cpufreq: schedutil: Always call driver if CPUFREQ_NEED_UPDATE_LIMITS is set
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit d1e7c2996e988866e7ceceb4641a0886885b7889 upstream.
Because sugov_update_next_freq() may skip a frequency update even if the need_freq_update flag has been set for the policy at hand, policy limits updates may not take effect as expected.
For example, if the intel_pstate driver operates in the passive mode with HWP enabled, it needs to update the HWP min and max limits when the policy min and max limits change, respectively, but that may not happen if the target frequency does not change along with the limit at hand. In particular, if the policy min is changed first, causing the target frequency to be adjusted to it, and the policy max limit is changed later to the same value, the HWP max limit will not be updated to follow it as expected, because the target frequency is still equal to the policy min limit and it will not change until that limit is updated.
To address this issue, modify get_next_freq() to let the driver callback run if the CPUFREQ_NEED_UPDATE_LIMITS cpufreq driver flag is set regardless of whether or not the new frequency to set is equal to the previous one.
--- kernel/sched/cpufreq_schedutil.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/sched/cpufreq_schedutil.c +4 -2
@@ -102,7 +102,8 @@ static bool sugov_should_update_freq(strstatic bool sugov_update_next_freq (struct sugov_policy *sg_policy,u64 time,unsigned int next_freq) { -if (sg_policy->next_freq == next_freq) +if (sg_policy->next_freq == next_freq && + !cpufreq_driver_test_flags (CPUFREQ_NEED_UPDATE_LIMITS ))return false; sg_policy->next_freq = next_freq;
@@ -175,7 +176,8 @@ static unsigned int get_next_freq(struct freq =map_util_freq (util, freq, max); -if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) +if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update && + !cpufreq_driver_test_flags (CPUFREQ_NEED_UPDATE_LIMITS ))return sg_policy->next_freq; sg_policy->need_freq_update = false;
Greg Kroah-Hartman
maintainerPATCH 387/391 vhost_vdpa: Return -EFAULT if copy_from_user() fails
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 7922460e33c81f41e0d2421417228b32e6fdbe94 upstream.
The copy_to/from_user() functions return the number of bytes which we weren't able to copy but the ioctl should return -EFAULT if they fail.
--- drivers/vhost/vdpa.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/vhost/vdpa.c +5 -5
@@ -428,12 +428,11 @@ static long vhost_vdpa_unlocked_ioctl(stvoid __user *argp = (void __user *)arg;u64 __user *featurep = argp;u64 features; -long r; +long r =0 ;if (cmd ==VHOST_SET_BACKEND_FEATURES ) { - r =copy_from_user (&features, featurep,sizeof (features)); -if (r) -return r; +if (copy_from_user (&features, featurep,sizeof (features))) +return -EFAULT ;if (features & ~VHOST_VDPA_BACKEND_FEATURES )return -EOPNOTSUPP ;vhost_set_backend_features (&v->vdev, features);
@@ -476,7 +475,8 @@ static long vhost_vdpa_unlocked_ioctl(stbreak ;case VHOST_GET_BACKEND_FEATURES : features =VHOST_VDPA_BACKEND_FEATURES ; - r =copy_to_user (featurep, &features,sizeof (features)); +if (copy_to_user (featurep, &features,sizeof (features))) + r = -EFAULT ;break ;default : r =vhost_dev_ioctl (&v->vdev, cmd, argp);
Greg Kroah-Hartman
maintainerPATCH 388/391 vdpa/mlx5: Fix error return in map_direct_mr()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
commit 7ba08e81cb4aec9724ab7674a5de49e7a341062c upstream.
Fix to return the variable "err" from the error handling case instead of "ret".
--- drivers/vdpa/mlx5/core/mr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/core/mr.c +2 -3
@@ -239,7 +239,6 @@ static int map_direct_mr(struct mlx5_vdpu64 paend;struct scatterlist *sg;struct device *dma = mvdev->mdev->device; -int ret;for (map =vhost_iotlb_itree_first (iotlb, mr->start, mr->end -1 ); map; map =vhost_iotlb_itree_next (map, start, mr->end -1 )) {
@@ -277,8 +276,8 @@ static int map_direct_mr(struct mlx5_vdp done: mr->log_size = log_entity_size; mr->nsg = nsg; - ret =dma_map_sg_attrs (dma, mr->sg_head.sgl, mr->nsg,DMA_BIDIRECTIONAL ,0 ); -if (!ret) + err =dma_map_sg_attrs (dma, mr->sg_head.sgl, mr->nsg,DMA_BIDIRECTIONAL ,0 ); +if (!err) goto err_map; err =create_direct_mr (mvdev, mr);
Greg Kroah-Hartman
maintainerPATCH 389/391 time: Prevent undefined behaviour in timespec64_to_ns()
In reply to Greg Kroah-HartmanFrom: Zeng Tao <[email protected]>
commit cb47755725da7b90fecbb2aa82ac3b24a7adb89b upstream.
UBSAN reports:
Undefined behaviour in ./include/linux/time64.h:127:27 signed integer overflow:
17179869187 * 1000000000 cannot be represented in type 'long long int'
Call Trace: timespec64_to_ns include/linux/time64.h:127 [inline] set_cpu_itimer+0x65c/0x880 kernel/time/itimer.c:180 do_setitimer+0x8e/0x740 kernel/time/itimer.c:245 __x64_sys_setitimer+0x14c/0x2c0 kernel/time/itimer.c:336 do_syscall_64+0xa1/0x540 arch/x86/entry/common.c:295
Commit bd40a175769d ("y2038: itimer: change implementation to timespec64") replaced the original conversion which handled time clamping correctly with timespec64_to_ns() which has no overflow protection.
Fix it in timespec64_to_ns() as this is not necessarily limited to the usage in itimers.
[ tglx: Added comment and adjusted the fixes tag ]
--- include/linux/time64.h | 4 ++++ kernel/time/itimer.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/time64.h +4 -0
@@ -124,6 +124,10 @@ static inline bool timespec64_valid_sett*/ static inline s64 timespec64_to_ns (const struct timespec64 *ts) { +/* Prevent multiplication overflow */ +if ((unsigned long long )ts->tv_sec >=KTIME_SEC_MAX ) +return KTIME_MAX ; +return ((s64 ) ts->tv_sec *NSEC_PER_SEC ) + ts->tv_nsec; }
kernel/time/itimer.c +0 -4
@@ -172,10 +172,6 @@ static void set_cpu_itimer(struct task_su64 oval, nval, ointerval, ninterval;struct cpu_itimer *it = &tsk->signal->it[clock_id]; -/* -* Use the to_ktime conversion because that clamps the maximum -* value to KTIME_MAX and avoid multiplication overflows. -*/ nval =timespec64_to_ns (&value->it_value); ninterval =timespec64_to_ns (&value->it_interval);
Greg Kroah-Hartman
maintainerPATCH 391/391 KVM: arm64: ARM_SMCCC_ARCH_WORKAROUND_1 doesnt return SMCCC_RET_NOT_REQUIRED
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
commit 1de111b51b829bcf01d2e57971f8fd07a665fa3f upstream.
According to the SMCCC spec[1](7.5.2 Discovery) the ARM_SMCCC_ARCH_WORKAROUND_1 function id only returns 0, 1, and SMCCC_RET_NOT_SUPPORTED.
0 is "workaround required and safe to call this function"
1 is "workaround not required but safe to call this function" SMCCC_RET_NOT_SUPPORTED is "might be vulnerable or might not be, who knows, I give up!"
SMCCC_RET_NOT_SUPPORTED might as well mean "workaround required, except calling this function may not work because it isn't implemented in some cases". Wonderful. We map this SMC call to
0 is SPECTRE_MITIGATED
1 is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
For KVM hypercalls (hvc), we've implemented this function id to return SMCCC_RET_NOT_SUPPORTED, 0, and SMCCC_RET_NOT_REQUIRED. One of those isn't supposed to be there. Per the code we call arm64_get_spectre_v2_state() to figure out what to return for this feature discovery call.
0 is SPECTRE_MITIGATED
SMCCC_RET_NOT_REQUIRED is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
Let's clean this up so that KVM tells the guest this mapping:
0 is SPECTRE_MITIGATED
1 is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
Note: SMCCC_RET_NOT_AFFECTED is 1 but isn't part of the SMCCC spec
--- arch/arm64/kvm/hypercalls.c | 2 +- include/linux/arm-smccc.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kvm/hypercalls.c +1 -1
@@ -31,7 +31,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu val =SMCCC_RET_SUCCESS ;break ;case KVM_BP_HARDEN_NOT_REQUIRED : - val =SMCCC_RET_NOT_REQUIRED ; + val =SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED ;break ; }break ;
include/linux/arm-smccc.h +2 -0
@@ -86,6 +86,8 @@ ARM_SMCCC_SMC_32, \ 0, 0x7fff) +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1 +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
Greg Kroah-Hartman
maintainerPATCH 383/391 staging: octeon: repair "fixed-link" support
In reply to Greg Kroah-HartmanFrom: Alexander Sverdlin <[email protected]>
commit 179f5dc36b0a1aa31538d7d8823deb65c39847b3 upstream.
The PHYs must be registered once in device probe function, not in device open callback because it's only possible to register them once.
--- drivers/staging/octeon/ethernet-mdio.c | 6 ------ drivers/staging/octeon/ethernet.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/staging/octeon/ethernet-mdio.c +0 -6
@@ -147,12 +147,6 @@ int cvm_oct_phy_setup_device(struct net_ phy_node =of_parse_phandle (priv->of_node,"phy-handle" ,0 );if (!phy_node &&of_phy_is_fixed_link (priv->of_node)) { -int rc; - - rc =of_phy_register_fixed_link (priv->of_node); -if (rc) -return rc; - phy_node =of_node_get (priv->of_node); }if (!phy_node)
drivers/staging/octeon/ethernet.c +9 -0
@@ -13,6 +13,7 @@#include <linux/phy.h> #include <linux/slab.h> #include <linux/interrupt.h> +#include <linux/of_mdio.h> #include <linux/of_net.h> #include <linux/if_ether.h> #include <linux/if_vlan.h>
@@ -892,6 +893,14 @@ static int cvm_oct_probe(struct platformbreak ; } +if (priv->of_node &&of_phy_is_fixed_link (priv->of_node)) { +if (of_phy_register_fixed_link (priv->of_node)) { +netdev_err (dev,"Failed to register fixed link for interface %d, port %d\n" , + interface, priv->port); + dev->netdev_ops =NULL ; + } + } +if (!dev->netdev_ops) {free_netdev (dev); }else if (register_netdev (dev) <0 ) {
Greg Kroah-Hartman
maintainerPATCH 191/391 perf/x86/intel: Fix Ice Lake event constraint table
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit 010cb00265f150bf82b23c02ad1fb87ce5c781e1 upstream.
An error occues when sampling non-PEBS INST_RETIRED.PREC_DIST(0x01c0) event.
perf record -e cpu/event=0xc0,umask=0x01/ -- sleep 1 Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu/event=0xc0,umask=0x01/).
/bin/dmesg | grep -i perf may provide additional information.
The idxmsk64 of the event is set to 0. The event never be successfully scheduled.
The event should be limit to the fixed counter 0.
--- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
@@ -243,7 +243,7 @@ static struct extra_reg intel_skl_extra_static struct event_constraint intel_icl_event_constraints[] = {FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ -INTEL_UEVENT_CONSTRAINT (0x1c0 ,0 ),/* INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ FIXED_EVENT_CONSTRAINT (0x0400 ,3 ),/* SLOTS */
Greg Kroah-Hartman
maintainerPATCH 247/391 usb: cdns3: Fix on-chip memory overflow issue
In reply to Greg Kroah-HartmanFrom: Pawel Laszczak <[email protected]>
commit 52d3967704aea6cb316d419a33a5e1d56d33a3c1 upstream.
Patch fixes issue caused setting On-chip memory overflow bit in usb_sts register. The issue occurred because EP_CFG register was set twice before USB_STS.CFGSTS was set. Every write operation on EP_CFG.BUFFERING causes that controller increases internal counter holding the number of reserved on-chip buffers. First time this register was updated in function cdns3_ep_config before delegating SET_CONFIGURATION request to class driver and again it was updated when class wanted to enable endpoint. This patch fixes this issue by configuring endpoints enabled by class driver in cdns3_gadget_ep_enable and others just before status stage.
--- drivers/usb/cdns3/ep0.c | 65 +++++++++++++++------------- drivers/usb/cdns3/gadget.c | 102 +++++++++++++++++++++++++-------------------- drivers/usb/cdns3/gadget.h | 3 - 3 files changed, 94 insertions(+), 76 deletions(-)
drivers/usb/cdns3/ep0.c +35 -30
@@ -137,48 +137,36 @@ static int cdns3_req_ep0_set_configurati struct usb_ctrlrequest *ctrl_req) {enum usb_device_state device_state = priv_dev->gadget.state; -struct cdns3_endpoint *priv_ep;u32 config =le16_to_cpu (ctrl_req->wValue);int result =0 ; -int i;switch (device_state) {case USB_STATE_ADDRESS : -/* Configure non-control EPs */ -for (i =0 ; i <CDNS3_ENDPOINTS_MAX_COUNT ; i++) { - priv_ep = priv_dev->eps[i]; -if (!priv_ep) -continue ; - -if (priv_ep->flags &EP_CLAIMED ) -cdns3_ep_config (priv_ep); - } - result =cdns3_ep0_delegate_req (priv_dev, ctrl_req); -if (result) -return result; - -if (!config) { -cdns3_hw_reset_eps_config (priv_dev); -usb_gadget_set_state (&priv_dev->gadget, -USB_STATE_ADDRESS ); - } +if (result || !config) + goto reset_config;break ;case USB_STATE_CONFIGURED : result =cdns3_ep0_delegate_req (priv_dev, ctrl_req); +if (!config && !result) + goto reset_config; -if (!config && !result) { -cdns3_hw_reset_eps_config (priv_dev); -usb_gadget_set_state (&priv_dev->gadget, -USB_STATE_ADDRESS ); - }break ;default : - result = -EINVAL ; +return -EINVAL ; } +return 0 ; + +reset_config: +if (result !=USB_GADGET_DELAYED_STATUS ) +cdns3_hw_reset_eps_config (priv_dev); + +usb_gadget_set_state (&priv_dev->gadget, +USB_STATE_ADDRESS ); +return result; }
@@ -705,6 +693,7 @@ static int cdns3_gadget_ep0_queue(structunsigned long flags;int ret =0 ;u8 zlp =0 ; +int i;spin_lock_irqsave (&priv_dev->lock, flags);trace_cdns3_ep0_queue (priv_dev, request);
@@ -718,6 +707,17 @@ static int cdns3_gadget_ep0_queue(struct/* send STATUS stage. Should be called only for SET_CONFIGURATION */ if (priv_dev->ep0_stage ==CDNS3_STATUS_STAGE ) {cdns3_select_ep (priv_dev,0x00 ); + +/* +* Configure all non-control EPs which are not enabled by class driver +*/ +for (i =0 ; i <CDNS3_ENDPOINTS_MAX_COUNT ; i++) { + priv_ep = priv_dev->eps[i]; +if (priv_ep && priv_ep->flags &EP_CLAIMED && + !(priv_ep->flags &EP_ENABLED )) +cdns3_ep_config (priv_ep,0 ); + } +cdns3_set_hw_configuration (priv_dev);cdns3_ep0_complete_setup (priv_dev,0 ,1 ); request->actual =0 ;
@@ -803,6 +803,7 @@ void cdns3_ep0_config(struct cdns3_devicstruct cdns3_usb_regs __iomem *regs;struct cdns3_endpoint *priv_ep;u32 max_packet_size =64 ; +u32 ep_cfg; regs = priv_dev->regs;
@@ -834,8 +835,10 @@ void cdns3_ep0_config(struct cdns3_devic BIT(0) | BIT(16)); } -writel (EP_CFG_ENABLE |EP_CFG_MAXPKTSIZE (max_packet_size), - ®s->ep_cfg); + ep_cfg =EP_CFG_ENABLE |EP_CFG_MAXPKTSIZE (max_packet_size); + +if (!(priv_ep->flags &EP_CONFIGURED )) +writel (ep_cfg, ®s->ep_cfg);writel (EP_STS_EN_SETUPEN |EP_STS_EN_DESCMISEN |EP_STS_EN_TRBERREN , ®s->ep_sts_en);
@@ -843,8 +846,10 @@ void cdns3_ep0_config(struct cdns3_devic/* init ep in */ cdns3_select_ep (priv_dev,USB_DIR_IN ); -writel (EP_CFG_ENABLE |EP_CFG_MAXPKTSIZE (max_packet_size), - ®s->ep_cfg); +if (!(priv_ep->flags &EP_CONFIGURED )) +writel (ep_cfg, ®s->ep_cfg); + + priv_ep->flags |=EP_CONFIGURED ;writel (EP_STS_EN_SETUPEN |EP_STS_EN_TRBERREN , ®s->ep_sts_en);
drivers/usb/cdns3/gadget.c +57 -45
177 lines not on this page · raw message
drivers/usb/cdns3/gadget.h +2 -1
@@ -1154,6 +1154,7 @@ struct cdns3_endpoint {#define EP_QUIRK_EXTRA_BUF_DET BIT(12)#define EP_QUIRK_EXTRA_BUF_EN BIT(13)#define EP_TDLCHK_EN BIT(15) +#define EP_CONFIGURED BIT(16)u32 flags;struct cdns3_request *descmis_req;
@@ -1351,7 +1352,7 @@ void cdns3_gadget_giveback(struct cdns3_int cdns3_init_ep0 (struct cdns3_device *priv_dev,struct cdns3_endpoint *priv_ep);void cdns3_ep0_config (struct cdns3_device *priv_dev); -void cdns3_ep_config (struct cdns3_endpoint *priv_ep); +int cdns3_ep_config (struct cdns3_endpoint *priv_ep,bool enable);void cdns3_check_ep0_interrupt_proceed (struct cdns3_device *priv_dev,int dir);int __cdns3_gadget_wakeup (struct cdns3_device *priv_dev);
Greg Kroah-Hartman
maintainerPATCH 390/391 time/sched_clock: Mark sched_clock_read_begin/retry() as notrace
In reply to Greg Kroah-HartmanFrom: Quanyang Wang <[email protected]>
commit 4cd2bb12981165f865d2b8ed92b446b52310ef74 upstream.
Since sched_clock_read_begin() and sched_clock_read_retry() are called by notrace function sched_clock(), they shouldn't be traceable either, or else ftrace_graph_caller will run into a dead loop on the path as below (arm for instance):
ftrace_graph_caller()
prepare_ftrace_return()
function_graph_enter()
ftrace_push_return_trace()
trace_clock_local()
sched_clock()
sched_clock_read_begin/retry()
--- kernel/time/sched_clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/time/sched_clock.c +2 -2
@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64return (cyc * mult) >> shift; } -struct clock_read_data *sched_clock_read_begin (unsigned int *seq) +notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq) { *seq =raw_read_seqcount_latch (&cd.seq);return cd.read_data + (*seq &1 ); } -int sched_clock_read_retry (unsigned int seq) +notrace int sched_clock_read_retry(unsigned int seq) {return read_seqcount_retry (&cd.seq, seq); }
Greg Kroah-Hartman
maintainerPATCH 342/391 ext4: implement swap_activate aops using iomap
In reply to Greg Kroah-HartmanFrom: Ritesh Harjani <[email protected]>
commit 0e6895ba00b7be45f3ab0d2107dda3ef1245f5b4 upstream.
After moving ext4's bmap to iomap interface, swapon functionality on files created using fallocate (which creates unwritten extents) are failing. This is since iomap_bmap interface returns 0 for unwritten extents and thus generic_swapfile_activate considers this as holes and hence bail out with below kernel msg :-
[340.915835] swapon: swapfile has holes
To fix this we need to implement ->swap_activate aops in ext4 which will use ext4_iomap_report_ops. Since we only need to return the list of extents so ext4_iomap_report_ops should be enough.
--- fs/ext4/inode.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/ext4/inode.c +11 -0
@@ -3601,6 +3601,13 @@ static int ext4_set_page_dirty(struct pareturn __set_page_dirty_buffers (page); } +static int ext4_iomap_swap_activate (struct swap_info_struct *sis, +struct file *file,sector_t *span) +{ +return iomap_swapfile_activate (sis, file, span, + &ext4_iomap_report_ops); +} +static const struct address_space_operations ext4_aops = { .readpage = ext4_readpage, .readahead = ext4_readahead,
@@ -3616,6 +3623,7 @@ static const struct address_space_operat .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .swap_activate = ext4_iomap_swap_activate, };static const struct address_space_operations ext4_journalled_aops = {
@@ -3632,6 +3640,7 @@ static const struct address_space_operat .direct_IO = noop_direct_IO, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .swap_activate = ext4_iomap_swap_activate, };static const struct address_space_operations ext4_da_aops = {
@@ -3649,6 +3658,7 @@ static const struct address_space_operat .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .swap_activate = ext4_iomap_swap_activate, };static const struct address_space_operations ext4_dax_aops = {
@@ -3657,6 +3667,7 @@ static const struct address_space_operat .set_page_dirty = noop_set_page_dirty, .bmap = ext4_bmap, .invalidatepage = noop_invalidatepage, + .swap_activate = ext4_iomap_swap_activate, };void ext4_set_aops (struct inode *inode)
Greg Kroah-Hartman
maintainerPATCH 350/391 mmc: sdhci-of-esdhc: make sure delay chain locked for HS400
In reply to Greg Kroah-HartmanFrom: Yangbo Lu <[email protected]>
commit 011fde48394b7dc8dfd6660d1013b26a00157b80 upstream.
For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.
This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.
--- drivers/mmc/host/sdhci-esdhc.h | 2 ++ drivers/mmc/host/sdhci-of-esdhc.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
drivers/mmc/host/sdhci-esdhc.h +2 -0
@@ -5,6 +5,7 @@* Copyright (c) 2007 Freescale Semiconductor, Inc. * Copyright (c) 2009 MontaVista Software, Inc. * Copyright (c) 2010 Pengutronix e.K. +* Copyright 2020 NXP * Author: Wolfram Sang <[email protected]> */
@@ -88,6 +89,7 @@/* DLL Config 0 Register */ #define ESDHC_DLLCFG0 0x160#define ESDHC_DLL_ENABLE 0x80000000 +#define ESDHC_DLL_RESET 0x40000000#define ESDHC_DLL_FREQ_SEL 0x08000000/* DLL Config 1 Register */
drivers/mmc/host/sdhci-of-esdhc.c +17 -0
@@ -4,6 +4,7 @@* * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc. * Copyright (c) 2009 MontaVista Software, Inc. +* Copyright 2020 NXP * * Authors: Xiaobo Xie <[email protected]> * Anton Vorontsov <[email protected]>
@@ -19,6 +20,7 @@#include <linux/clk.h> #include <linux/ktime.h> #include <linux/dma-mapping.h> +#include <linux/iopoll.h> #include <linux/mmc/host.h> #include <linux/mmc/mmc.h> #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdif (host->mmc->actual_clock ==MMC_HS200_MAX_DTR ) temp |=ESDHC_DLL_FREQ_SEL ;sdhci_writel (host, temp,ESDHC_DLLCFG0 ); + + temp |=ESDHC_DLL_RESET ; +sdhci_writel (host, temp,ESDHC_DLLCFG0 ); +udelay (1 ); + temp &= ~ESDHC_DLL_RESET ; +sdhci_writel (host, temp,ESDHC_DLLCFG0 ); + +/* Wait max 20 ms */ +if (read_poll_timeout (sdhci_readl, temp, + temp &ESDHC_DLL_STS_SLV_LOCK , +10 ,20000 , false, + host,ESDHC_DLLSTAT0 )) +pr_err ("%s: timeout for delay chain lock.\n" , +mmc_hostname (host->mmc)); + temp =sdhci_readl (host,ESDHC_TBCTL );sdhci_writel (host, temp |ESDHC_HS400_WNDW_ADJUST ,ESDHC_TBCTL );
Greg Kroah-Hartman
maintainerPATCH 384/391 staging: octeon: Drop on uncorrectable alignment or FCS error
In reply to Greg Kroah-HartmanFrom: Alexander Sverdlin <[email protected]>
commit 49d28ebdf1e30d806410eefc7de0a7a1ca5d747c upstream.
Currently in case of alignment or FCS error if the packet cannot be corrected it's still not dropped. Report the error properly and drop the packet while making the code around a little bit more readable.
--- drivers/staging/octeon/ethernet-rx.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/staging/octeon/ethernet-rx.c +19 -15
@@ -69,15 +69,17 @@ static inline int cvm_oct_check_rcv_erroelse port = work->word1.cn38xx.ipprt; -if ((work->word2.snoip.err_code ==10 ) && (work->word1.len <=64 )) { +if ((work->word2.snoip.err_code ==10 ) && (work->word1.len <=64 ))/* * Ignore length errors on min size packets. Some * equipment incorrectly pads packets to 64+4FCS * instead of 60+4FCS. Note these packets still get * counted as frame errors. */ - }else if (work->word2.snoip.err_code ==5 || - work->word2.snoip.err_code ==7 ) { +return 0 ; + +if (work->word2.snoip.err_code ==5 || + work->word2.snoip.err_code ==7 ) {/* * We received a packet with either an alignment error * or a FCS error. This may be signalling that we are
@@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_erro/* Port received 0xd5 preamble */ work->packet_ptr.s.addr += i +1 ; work->word1.len -= i +5 ; - }else if ((*ptr &0xf ) ==0xd ) { +return 0 ; + } + +if ((*ptr &0xf ) ==0xd ) {/* Port received 0xd preamble */ work->packet_ptr.s.addr += i; work->word1.len -= i +4 ;
@@ -118,21 +123,20 @@ static inline int cvm_oct_check_rcv_erro ((*(ptr +1 ) &0xf ) <<4 ); ptr++; } - }else { -printk_ratelimited ("Port %d unknown preamble, packet dropped\n" , - port); -cvm_oct_free_work (work); -return 1 ; +return 0 ; } + +printk_ratelimited ("Port %d unknown preamble, packet dropped\n" , + port); +cvm_oct_free_work (work); +return 1 ; } - }else { -printk_ratelimited ("Port %d receive error code %d, packet dropped\n" , - port, work->word2.snoip.err_code); -cvm_oct_free_work (work); -return 1 ; } -return 0 ; +printk_ratelimited ("Port %d receive error code %d, packet dropped\n" , + port, work->word2.snoip.err_code); +cvm_oct_free_work (work); +return 1 ; }static void copy_segments_to_skb (struct cvmx_wqe *work,struct sk_buff *skb)
Greg Kroah-Hartman
maintainerPATCH 382/391 staging: comedi: cb_pcidas: Allow 2-channel commands for AO subdevice
In reply to Greg Kroah-HartmanFrom: Ian Abbott <[email protected]>
commit 647a6002cb41d358d9ac5de101a8a6dc74748a59 upstream.
The "cb_pcidas" driver supports asynchronous commands on the analog output (AO) subdevice for those boards that have an AO FIFO. The code (in cb_pcidas_ao_check_chanlist() and cb_pcidas_ao_cmd()) to validate and set up the command supports output to a single channel or to two channels simultaneously (the boards have two AO channels). However, the code in cb_pcidas_auto_attach() that initializes the subdevices neglects to initialize the AO subdevice's len_chanlist member, leaving it set to 0, but the Comedi core will "correct" it to 1 if the driver neglected to set it. This limits commands to use a single channel (either channel 0 or 1), but the limit should be two channels. Set the AO subdevice's len_chanlist member to be the same value as the n_chan member, which will be 2.
--- drivers/staging/comedi/drivers/cb_pcidas.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/comedi/drivers/cb_pcidas.c +1 -0
@@ -1342,6 +1342,7 @@ static int cb_pcidas_auto_attach(structif (dev->irq && board->has_ao_fifo) { dev->write_subdev = s; s->subdev_flags |=SDF_CMD_WRITE ; + s->len_chanlist = s->n_chan; s->do_cmdtest = cb_pcidas_ao_cmdtest; s->do_cmd = cb_pcidas_ao_cmd; s->cancel = cb_pcidas_ao_cancel;
Greg Kroah-Hartman
maintainerPATCH 377/391 device property: Dont clear secondary pointer for shared primary firmware node
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit 99aed9227073fb34ce2880cbc7063e04185a65e1 upstream.
It appears that firmware nodes can be shared between devices. In such case when a (child) device is about to be deleted, its firmware node may be shared and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link of the shared primary firmware node.
In order to prevent that, check, if the device has a parent and parent's firmware node is shared with its child, and avoid crashing the link.
--- drivers/base/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/core.c +3 -1
@@ -4260,6 +4260,7 @@ static inline bool fwnode_is_primary(str*/ void set_primary_fwnode (struct device *dev,struct fwnode_handle *fwnode) { +struct device *parent = dev->parent;struct fwnode_handle *fn = dev->fwnode;if (fwnode) {
@@ -4274,7 +4275,8 @@ void set_primary_fwnode(struct device *d }else {if (fwnode_is_primary (fn)) { dev->fwnode = fn->secondary; - fn->secondary =ERR_PTR (-ENODEV ); +if (!(parent && fn == parent->fwnode)) + fn->secondary =ERR_PTR (-ENODEV ); }else { dev->fwnode =NULL ; }