5.4.33-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 170/232 crypto: ccree - protect against empty or NULL scatterlists
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit ce0fc6db38decf0d2919bfe783de6d6b76e421a9 upstream.
Deal gracefully with a NULL or empty scatterlist which can happen if both cryptlen and assoclen are zero and we're doing in-place AEAD encryption.
This fixes a crash when this causes us to try and map a NULL page, at least with some platforms / DMA mapping configs.
--- drivers/crypto/ccree/cc_buffer_mgr.c | 62 +++++++++++++++-------------------- drivers/crypto/ccree/cc_buffer_mgr.h | 1 2 files changed, 28 insertions(+), 35 deletions(-)
drivers/crypto/ccree/cc_buffer_mgr.c +27 -35
@@ -87,6 +87,8 @@ static unsigned int cc_get_sgl_nents(str {unsigned int nents =0 ; + *lbytes =0 ; +while (nbytes && sg_list) { nents++;/* get the number of bytes in the last entry */
@@ -95,6 +97,7 @@ static unsigned int cc_get_sgl_nents(str nbytes : sg_list->length; sg_list =sg_next (sg_list); } +dev_dbg (dev,"nents %d last bytes %d\n" , nents, *lbytes);return nents; }
@@ -290,37 +293,25 @@ static int cc_map_sg(struct device *dev, unsigned int nbytes, int direction, u32 *nents, u32 max_sg_nents, u32 *lbytes, u32 *mapped_nents) { - if (sg_is_last(sg)) { - /* One entry only case -set to DLLI */ - if (dma_map_sg(dev, sg, 1, direction) != 1) { - dev_err(dev, "dma_map_sg() single buffer failed\n"); -return -ENOMEM ; - } -dev_dbg (dev,"Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n" , - &sg_dma_address (sg),sg_page (sg),sg_virt (sg), - sg->offset, sg->length); - *lbytes = nbytes; - *nents =1 ; - *mapped_nents =1 ; - } else { /*sg_is_last*/ - *nents =cc_get_sgl_nents (dev, sg, nbytes, lbytes); -if (*nents > max_sg_nents) { - *nents =0 ; -dev_err (dev,"Too many fragments. current %d max %d\n" , - *nents, max_sg_nents); -return -ENOMEM ; - } -/* In case of mmu the number of mapped nents might -* be changed from the original sgl nents -*/ - *mapped_nents =dma_map_sg (dev, sg, *nents, direction); -if (*mapped_nents ==0 ) { - *nents =0 ; -dev_err (dev,"dma_map_sg() sg buffer failed\n" ); -return -ENOMEM ; - } + int ret = 0; + + *nents =cc_get_sgl_nents (dev, sg, nbytes, lbytes); +if (*nents > max_sg_nents) { + *nents =0 ; +dev_err (dev,"Too many fragments. current %d max %d\n" , + *nents, max_sg_nents); +return -ENOMEM ; } + ret =dma_map_sg (dev, sg, *nents, direction); +if (dma_mapping_error (dev, ret)) { + *nents =0 ; +dev_err (dev,"dma_map_sg() sg buffer failed %d\n" , ret); +return -ENOMEM ; + } + + *mapped_nents = ret; +return 0 ; }
@@ -555,11 +546,12 @@ void cc_unmap_aead_request(struct devicesg_virt (req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, areq_ctx->assoclen, req->cryptlen); -dma_unmap_sg (dev, req->src,sg_nents (req->src),DMA_BIDIRECTIONAL ); +dma_unmap_sg (dev, req->src, areq_ctx->src.mapped_nents, +DMA_BIDIRECTIONAL );if (req->src != req->dst) {dev_dbg (dev,"Unmapping dst sgl: req->dst=%pK\n" ,sg_virt (req->dst)); -dma_unmap_sg (dev, req->dst,sg_nents (req->dst), +dma_unmap_sg (dev, req->dst, areq_ctx->dst.mapped_nents,DMA_BIDIRECTIONAL ); } if (drvdata->coherent &&
@@ -881,7 +873,7 @@ static int cc_aead_chain_data(struct cc_ &src_last_bytes); sg_index = areq_ctx->src_sgl->length;//check where the data starts -while (sg_index <= size_to_skip) { +while (src_mapped_nents && (sg_index <= size_to_skip)) { src_mapped_nents--; offset -= areq_ctx->src_sgl->length; sgl =sg_next (areq_ctx->src_sgl);
@@ -908,7 +900,7 @@ static int cc_aead_chain_data(struct cc_ size_for_map +=crypto_aead_ivsize (tfm); rc =cc_map_sg (dev, req->dst, size_for_map,DMA_BIDIRECTIONAL , - &areq_ctx->dst.nents, + &areq_ctx->dst.mapped_nents,LLI_MAX_NUM_OF_DATA_ENTRIES , &dst_last_bytes, &dst_mapped_nents);if (rc)
@@ -921,7 +913,7 @@ static int cc_aead_chain_data(struct cc_ offset = size_to_skip;//check where the data starts -while (sg_index <= size_to_skip) { +while (dst_mapped_nents && sg_index <= size_to_skip) { dst_mapped_nents--; offset -= areq_ctx->dst_sgl->length; sgl =sg_next (areq_ctx->dst_sgl);
@@ -1123,7 +1115,7 @@ int cc_map_aead_request(struct cc_drvdatif (is_gcm4543) size_to_map +=crypto_aead_ivsize (tfm); rc =cc_map_sg (dev, req->src, size_to_map,DMA_BIDIRECTIONAL , - &areq_ctx->src.nents, + &areq_ctx->src.mapped_nents, (LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES +LLI_MAX_NUM_OF_DATA_ENTRIES ), &dummy, &mapped_nents);
drivers/crypto/ccree/cc_buffer_mgr.h +1 -0
@@ -25,6 +25,7 @@ enum cc_sg_cpy_direct {struct cc_mlli {cc_sram_addr_t sram_addr; +unsigned int mapped_nents;unsigned int nents;//sg nents unsigned int mlli_nents;//mlli nents might be different than the above };
Greg Kroah-Hartman
maintainerPATCH 135/232 mtd: spinand: Stop using spinand->oobbuf for buffering bad block markers
In reply to Greg Kroah-HartmanFrom: Frieder Schrempf <[email protected]>
commit 2148937501ee3d663e0010e519a553fea67ad103 upstream.
For reading and writing the bad block markers, spinand->oobbuf is currently used as a buffer for the marker bytes. During the underlying read and write operations to actually get/set the content of the OOB area, the content of spinand->oobbuf is reused and changed by accessing it through spinand->oobbuf and/or spinand->databuf.
This is a flaw in the original design of the SPI NAND core and at the latest from 13c15e07eedf ("mtd: spinand: Handle the case where PROGRAM LOAD does not reset the cache") on, it results in not having the bad block marker written at all, as the spinand->oobbuf is cleared to 0xff after setting the marker bytes to zero.
To fix it, we now just store the two bytes for the marker on the stack and let the read/write operations copy it from/to the page buffer later.
--- drivers/mtd/nand/spi/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mtd/nand/spi/core.c +7 -7
@@ -568,18 +568,18 @@ static int spinand_mtd_write(struct mtd_static bool spinand_isbad (struct nand_device *nand,const struct nand_pos *pos) {struct spinand_device *spinand =nand_to_spinand (nand); +u8 marker[2 ] = { };struct nand_page_io_req req = { .pos = *pos, - .ooblen =2 , + .ooblen =sizeof (marker), .ooboffs =0 , - .oobbuf.in = spinand->oobbuf, + .oobbuf.in = marker, .mode =MTD_OPS_RAW , }; -memset (spinand->oobbuf,0 ,2 );spinand_select_target (spinand, pos->target);spinand_read_page (spinand, &req, false); -if (spinand->oobbuf[0 ] !=0xff || spinand->oobbuf[1 ] !=0xff ) +if (marker[0 ] !=0xff || marker[1 ] !=0xff )return true;return false;
@@ -603,11 +603,12 @@ static int spinand_mtd_block_isbad(strucstatic int spinand_markbad (struct nand_device *nand,const struct nand_pos *pos) {struct spinand_device *spinand =nand_to_spinand (nand); +u8 marker[2 ] = { };struct nand_page_io_req req = { .pos = *pos, .ooboffs =0 , - .ooblen =2 , - .oobbuf.out = spinand->oobbuf, + .ooblen =sizeof (marker), + .oobbuf.out = marker, };int ret;
@@ -622,7 +623,6 @@ static int spinand_markbad(struct nand_dspinand_erase_op (spinand, pos); -memset (spinand->oobbuf,0 ,2 );return spinand_write_page (spinand, &req); }
Greg Kroah-Hartman
maintainerPATCH 166/232 XArray: Fix xas_pause for large multi-index entries
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit c36d451ad386b34f452fc3c8621ff14b9eaa31a6 upstream.
Inspired by the recent Coverity report, I looked for other places where the offset wasn't being converted to an unsigned long before being shifted, and I found one in xas_pause() when the entry being paused is of order >32.
--- lib/test_xarray.c | 37 +++++++++++++++++++++++++++++++++++++ lib/xarray.c | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-)
lib/test_xarray.c +37 -0
@@ -1156,6 +1156,42 @@ static noinline void check_find_entry(stXA_BUG_ON (xa, !xa_empty (xa)); } +static noinline void check_pause(struct xarray *xa) +{ +XA_STATE (xas, xa,0 ); +void *entry; +unsigned int order; +unsigned long index =1 ; +unsigned int count =0 ; + +for (order =0 ; order < order_limit; order++) { +XA_BUG_ON (xa,xa_store_order (xa, index, order, +xa_mk_index (index),GFP_KERNEL )); + index +=1UL << order; + } + +rcu_read_lock (); +xas_for_each (&xas, entry,ULONG_MAX ) { +XA_BUG_ON (xa, entry !=xa_mk_index (1UL << count)); + count++; + } +rcu_read_unlock (); +XA_BUG_ON (xa, count != order_limit); + + count =0 ; +xas_set (&xas,0 ); +rcu_read_lock (); +xas_for_each (&xas, entry,ULONG_MAX ) { +XA_BUG_ON (xa, entry !=xa_mk_index (1UL << count)); + count++; +xas_pause (&xas); + } +rcu_read_unlock (); +XA_BUG_ON (xa, count != order_limit); + +xa_destroy (xa); +} + static noinline void check_move_tiny(struct xarray *xa) {XA_STATE (xas, xa,0 );
@@ -1664,6 +1700,7 @@ static int xarray_checks(void)check_xa_alloc ();check_find (&array);check_find_entry (&array); +check_pause (&array);check_account (&array);check_destroy (&array);check_move (&array);
lib/xarray.c +1 -1
@@ -970,7 +970,7 @@ void xas_pause(struct xa_state *xas) xas->xa_node =XAS_RESTART ;if (node) { -unsigned int offset = xas->xa_offset; +unsigned long offset = xas->xa_offset;while (++offset <XA_CHUNK_SIZE ) {if (!xa_is_sibling (xa_entry (xas->xa, node, offset)))break ;
Greg Kroah-Hartman
maintainerPATCH 165/232 dm clone metadata: Fix return type of dm_clone_nr_of_hydrated_regions()
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit 81d5553d1288c2ec0390f02f84d71ca0f0f9f137 upstream.
dm_clone_nr_of_hydrated_regions() returns the number of regions that have been hydrated so far. In order to do so it employs bitmap_weight().
Until now, the return type of dm_clone_nr_of_hydrated_regions() was unsigned long.
Because bitmap_weight() returns an int, in case BITS_PER_LONG == 64 and the return value of bitmap_weight() is 2^31 (the maximum allowed number of regions for a device), the result is sign extended from 32 bits to 64 bits and an incorrect value is displayed, in the status output of dm-clone, as the number of hydrated regions.
Fix this by having dm_clone_nr_of_hydrated_regions() return an unsigned int.
--- drivers/md/dm-clone-metadata.c | 2 +- drivers/md/dm-clone-metadata.h | 2 +- drivers/md/dm-clone-target.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-clone-metadata.c +1 -1
@@ -656,7 +656,7 @@ bool dm_clone_is_range_hydrated(struct dreturn (bit >= (start + nr_regions)); } -unsigned long dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd) +unsigned int dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd) {return bitmap_weight (cmd->region_map, cmd->nr_regions); }
drivers/md/dm-clone-metadata.h +1 -1
@@ -154,7 +154,7 @@ bool dm_clone_is_range_hydrated(struct d/* * Returns the number of hydrated regions. */ -unsigned long dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd); +unsigned int dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd);/* * Returns the first unhydrated region with region_nr >= @start
drivers/md/dm-clone-target.c +1 -1
@@ -1455,7 +1455,7 @@ static void clone_status(struct dm_targe goto error; } - DMEMIT("%u %llu/%llu %llu %lu/%lu %u ", + DMEMIT("%u %llu/%llu %llu %u/%lu %u ", DM_CLONE_METADATA_BLOCK_SIZE, (unsigned long long)(nr_metadata_blocks - nr_free_metadata_blocks), (unsigned long long)nr_metadata_blocks,
Greg Kroah-Hartman
maintainerPATCH 164/232 dm clone: Add overflow check for number of regions
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit cd481c12269b4d276f1a52eda0ebd419079bfe3a upstream.
Add overflow check for clone->nr_regions variable, which holds the number of regions of the target.
The overflow can occur with sufficiently large devices, if BITS_PER_LONG == 32. E.g., if the region size is 8 sectors (4K), the overflow would occur for device sizes > 34359738360 sectors (~16TB).
This could result in multiple device sectors wrongly mapping to the same region number, due to the truncation from 64 bits to 32 bits, which would lead to data corruption.
--- drivers/md/dm-clone-target.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/md/dm-clone-target.c +11 -1
@@ -1775,6 +1775,7 @@ error:static int clone_ctr (struct dm_target *ti,unsigned int argc,char **argv) {int r; +sector_t nr_regions;struct clone *clone;struct dm_arg_set as;
@@ -1816,7 +1817,16 @@ static int clone_ctr(struct dm_target *t goto out_with_source_dev; clone->region_shift =__ffs (clone->region_size); - clone->nr_regions =dm_sector_div_up (ti->len, clone->region_size); + nr_regions =dm_sector_div_up (ti->len, clone->region_size); + +/* Check for overflow */ +if (nr_regions != (unsigned long )nr_regions) { + ti->error ="Too many regions. Consider increasing the region size" ; + r = -EOVERFLOW ; + goto out_with_source_dev; + } + + clone->nr_regions = nr_regions; r =validate_nr_regions (clone->nr_regions, &ti->error);if (r)
Greg Kroah-Hartman
maintainerPATCH 162/232 dm integrity: fix a crash with unusually large tag size
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit b93b6643e9b5a7f260b931e97f56ffa3fa65e26d upstream.
If the user specifies tag size larger than HASH_MAX_DIGESTSIZE, there's a crash in integrity_metadata().
--- drivers/md/dm-integrity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-integrity.c +2 -2
@@ -1514,7 +1514,7 @@ static void integrity_metadata(struct wostruct bio *bio =dm_bio_from_per_bio_data (dio,sizeof (struct dm_integrity_io ));char *checksums;unsigned extra_space =unlikely (digest_size > ic->tag_size) ? digest_size - ic->tag_size :0 ; -char checksums_onstack[HASH_MAX_DIGESTSIZE ]; +char checksums_onstack[max ((size_t )HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];unsigned sectors_to_process = dio->range.n_sectors;sector_t sector = dio->range.logical_sector;
@@ -1743,7 +1743,7 @@ retry_kmap: }while (++s < ic->sectors_per_block);#ifdef INTERNAL_VERIFY if (ic->internal_hash) { -char checksums_onstack[max (HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )]; +char checksums_onstack[max ((size_t )HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];integrity_sector_checksum (ic, logical_sector, mem + bv.bv_offset, checksums_onstack);if (unlikely (memcmp (checksums_onstack,journal_entry_tag (ic, je), ic->tag_size))) {
Greg Kroah-Hartman
maintainerPATCH 163/232 dm verity fec: fix memory leak in verity_fec_dtr
In reply to Greg Kroah-HartmanFrom: Shetty, Harshini X (EXT-Sony Mobile) <[email protected]>
commit 75fa601934fda23d2f15bf44b09c2401942d8e15 upstream.
Fix below kmemleak detected in verity_fec_ctr. output_pool is allocated for each dm-verity-fec device. But it is not freed when dm-table for the verity target is removed. Hence free the output mempool in destructor function verity_fec_dtr.
unreferenced object 0xffffffffa574d000 (size 4096):
comm "init", pid 1667, jiffies 4294894890 (age 307.168s) hex dump (first 32 bytes):
8e 36 00 98 66 a8 0b 9b 00 00 00 00 00 00 00 00 .6..f...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000060e82407>] __kmalloc+0x2b4/0x340
[<00000000dd99488f>] mempool_kmalloc+0x18/0x20
[<000000002560172b>] mempool_init_node+0x98/0x118
[<000000006c3574d2>] mempool_init+0x14/0x20
[<0000000008cb266e>] verity_fec_ctr+0x388/0x3b0
[<000000000887261b>] verity_ctr+0x87c/0x8d0
[<000000002b1e1c62>] dm_table_add_target+0x174/0x348
[<000000002ad89eda>] table_load+0xe4/0x328
[<000000001f06f5e9>] dm_ctl_ioctl+0x3b4/0x5a0
[<00000000bee5fbb7>] do_vfs_ioctl+0x5dc/0x928
[<00000000b475b8f5>] __arm64_sys_ioctl+0x70/0x98
[<000000005361e2e8>] el0_svc_common+0xa0/0x158
[<000000001374818f>] el0_svc_handler+0x6c/0x88
[<000000003364e9f4>] el0_svc+0x8/0xc
[<000000009d84cec9>] 0xffffffffffffffffDepends-on: 6f1c819c219f7 ("dm: convert to bioset_init()/mempool_init()")
--- drivers/md/dm-verity-fec.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-verity-fec.c +1 -0
@@ -551,6 +551,7 @@ void verity_fec_dtr(struct dm_verity *v)mempool_exit (&f->rs_pool);mempool_exit (&f->prealloc_pool);mempool_exit (&f->extra_pool); +mempool_exit (&f->output_pool);kmem_cache_destroy (f->cache);if (f->data_bufio)
Greg Kroah-Hartman
maintainerPATCH 158/232 sched/core: Remove duplicate assignment in sched_tick_remote()
In reply to Greg Kroah-HartmanFrom: Scott Wood <[email protected]>
commit 82e0516ce3a147365a5dd2a9bedd5ba43a18663d upstream.
A redundant "curr = rq->curr" was added; remove it.
--- kernel/sched/core.c | 1 - 1 file changed, 1 deletion(-)
kernel/sched/core.c +0 -1
@@ -3676,7 +3676,6 @@ static void sched_tick_remote(struct worif (cpu_is_offline (cpu)) goto out_unlock; - curr = rq->curr;update_rq_clock (rq);if (!is_idle_task (curr)) {
Greg Kroah-Hartman
maintainerPATCH 159/232 arm64: dts: allwinner: h5: Fix PMU compatible
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
commit 4ae7a3c3d7d31260f690d8d658f0365f3eca67a2 upstream.
The commit c35a516a4618 ("arm64: dts: allwinner: H5: Add PMU node") introduced support for the PMU found on the Allwinner H5. However, the binding only allows for a single compatible, while the patch was adding two.
Make sure we follow the binding.
--- arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +1 -2
@@ -77,8 +77,7 @@ }; pmu { - compatible = "arm,cortex-a53-pmu", - "arm,armv8-pmuv3"; + compatible = "arm,cortex-a53-pmu"; interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
Greg Kroah-Hartman
maintainerPATCH 153/232 mmc: sdhci-of-esdhc: fix esdhc_reset() for different controller versions
In reply to Greg Kroah-HartmanFrom: Yangbo Lu <[email protected]>
commit 2aa3d826adb578b26629a79b775a552cfe3fedf7 upstream.
This patch is to fix operating in esdhc_reset() for different controller versions, and to add bus-width restoring after data reset for eSDHC (verdor version <= 2.2).
Also add annotation for understanding.
--- drivers/mmc/host/sdhci-of-esdhc.c | 43 ++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +39 -4
@@ -734,23 +734,58 @@ static void esdhc_reset(struct sdhci_hos {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); -u32 val; +u32 val, bus_width =0 ; +/* +* Add delay to make sure all the DMA transfers are finished +* for quirk. +*/ if (esdhc->quirk_delay_before_data_reset && (mask &SDHCI_RESET_DATA ) && (host->flags &SDHCI_REQ_USE_DMA ))mdelay (5 ); +/* +* Save bus-width for eSDHC whose vendor version is 2.2 +* or lower for data reset. +*/ +if ((mask &SDHCI_RESET_DATA ) && + (esdhc->vendor_ver <=VENDOR_V_22 )) { + val =sdhci_readl (host,ESDHC_PROCTL ); + bus_width = val &ESDHC_CTRL_BUSWIDTH_MASK ; + } +sdhci_reset (host, mask); -sdhci_writel (host, host->ier,SDHCI_INT_ENABLE ); -sdhci_writel (host, host->ier,SDHCI_SIGNAL_ENABLE ); +/* +* Restore bus-width setting and interrupt registers for eSDHC +* whose vendor version is 2.2 or lower for data reset. +*/ +if ((mask &SDHCI_RESET_DATA ) && + (esdhc->vendor_ver <=VENDOR_V_22 )) { + val =sdhci_readl (host,ESDHC_PROCTL ); + val &= ~ESDHC_CTRL_BUSWIDTH_MASK ; + val |= bus_width; +sdhci_writel (host, val,ESDHC_PROCTL ); + +sdhci_writel (host, host->ier,SDHCI_INT_ENABLE ); +sdhci_writel (host, host->ier,SDHCI_SIGNAL_ENABLE ); + } -if (mask &SDHCI_RESET_ALL ) { +/* +* Some bits have to be cleaned manually for eSDHC whose spec +* version is higher than 3.0 for all reset. +*/ +if ((mask &SDHCI_RESET_ALL ) && + (esdhc->spec_ver >=SDHCI_SPEC_300 )) { val =sdhci_readl (host,ESDHC_TBCTL ); val &= ~ESDHC_TB_EN ;sdhci_writel (host, val,ESDHC_TBCTL ); +/* +* Initialize eSDHC_DLLCFG1[DLL_PD_PULSE_STRETCH_SEL] to +* 0 for quirk. +*/ if (esdhc->quirk_unreliable_pulse_detection) { val =sdhci_readl (host,ESDHC_DLLCFG1 ); val &= ~ESDHC_DLL_PD_PULSE_STRETCH_SEL ;
Greg Kroah-Hartman
maintainerPATCH 154/232 powerpc/pseries: Drop pointless static qualifier in vpa_debugfs_init()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit 11dd34f3eae5a468013bb161a1dcf1fecd2ca321 upstream.
There is no need to have the 'struct dentry *vpa_dir' variable static since new value always be assigned before use it.
--- arch/powerpc/platforms/pseries/lpar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/lpar.c +1 -1
@@ -1992,7 +1992,7 @@ static int __init vpa_debugfs_init(void) {char name[16 ];long i; -static struct dentry *vpa_dir; +struct dentry *vpa_dir;if (!firmware_has_feature (FW_FEATURE_SPLPAR ))return 0 ;
Greg Kroah-Hartman
maintainerPATCH 155/232 tools: gpio: Fix out-of-tree build regression
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
commit 82f04bfe2aff428b063eefd234679b2d693228ed upstream.
Commit 0161a94e2d1c7 ("tools: gpio: Correctly add make dependencies for gpio_utils") added a make rule for gpio-utils-in.o but used $(output) instead of the correct $(OUTPUT) for the output directory, breaking out-of-tree build (O=xx) with the following error:
No rule to make target 'out/tools/gpio/gpio-utils-in.o', needed by 'out/tools/gpio/lsgpio-in.o'. Stop.
Fix that.
--- tools/gpio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpio/Makefile +1 -1
@@ -35,7 +35,7 @@ $(OUTPUT)include/linux/gpio.h: ../../inc prepare: $(OUTPUT)include/linux/gpio.h -GPIO_UTILS_IN := $(output)gpio-utils-in.o +GPIO_UTILS_IN := $(OUTPUT)gpio-utils-in.o $(GPIO_UTILS_IN): prepare FORCE $(Q)$(MAKE) $(build)=gpio-utils
Greg Kroah-Hartman
maintainerPATCH 152/232 io_uring: honor original task RLIMIT_FSIZE
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 4ed734b0d0913e566a9d871e15d24eb240f269f7 upstream.
With the previous fixes for number of files open checking, I added some debug code to see if we had other spots where we're checking rlimit() against the async io-wq workers. The only one I found was file size checking, which we should also honor.
During write and fallocate prep, store the max file size and override that for the current ask if we're in io-wq worker context.
--- fs/io_uring.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/io_uring.c +11 -0
@@ -331,6 +331,7 @@ struct io_kiocb {#define REQ_F_ISREG 2048/* regular file */ #define REQ_F_MUST_PUNT 4096/* must be punted even for NONBLOCK */ #define REQ_F_TIMEOUT_NOSEQ 8192/* no timeout sequence */ +unsigned long fsize;u64 user_data;u32 result;u32 sequence;
@@ -1085,6 +1086,9 @@ static int io_prep_rw(struct io_kiocb *rif (S_ISREG (file_inode (req->file)->i_mode)) req->flags |=REQ_F_ISREG ; +if (force_nonblock) + req->fsize =rlimit (RLIMIT_FSIZE ); +/* * If the file doesn't support async, mark it as REQ_F_MUST_PUNT so * we know to async punt it even if it was opened O_NONBLOCK
@@ -1504,10 +1508,17 @@ static int io_write(struct io_kiocb *req } kiocb->ki_flags |=IOCB_WRITE ; +if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur = req->fsize; +if (file->f_op->write_iter) ret2 =call_write_iter (file, kiocb, &iter);else ret2 =loop_rw_iter (WRITE , file, kiocb, &iter); + +if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur =RLIM_INFINITY ; +if (!force_nonblock || ret2 != -EAGAIN ) {io_rw_done (kiocb, ret2); }else {
Greg Kroah-Hartman
maintainerPATCH 151/232 erofs: correct the remaining shrink objects
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 9d5a09c6f3b5fb85af20e3a34827b5d27d152b34 upstream.
The remaining count should not include successful
shrink attempts.
--- fs/erofs/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/utils.c +1 -1
@@ -294,7 +294,7 @@ static unsigned long erofs_shrink_scan(sspin_unlock (&erofs_sb_list_lock); sbi->shrinker_run_no = run_no; - freed +=erofs_shrink_workstation (sbi, nr, false); + freed +=erofs_shrink_workstation (sbi, nr - freed, false);spin_lock (&erofs_sb_list_lock);/* Get the next list element before we move this one */
Greg Kroah-Hartman
maintainerPATCH 150/232 crypto: mxs-dcp - fix scatterlist linearization for hash
In reply to Greg Kroah-HartmanFrom: Rosioru Dragos <[email protected]>
commit fa03481b6e2e82355c46644147b614f18c7a8161 upstream.
The incorrect traversal of the scatterlist, during the linearization phase lead to computing the hash value of the wrong input buffer. New implementation uses scatterwalk_map_and_copy()
to address this issue.
--- drivers/crypto/mxs-dcp.c | 54 ++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 28 deletions(-)
drivers/crypto/mxs-dcp.c +26 -28
@@ -20,6 +20,7 @@#include <crypto/sha.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> +#include <crypto/scatterwalk.h> #define DCP_MAX_CHANS 4#define DCP_BUF_SZ PAGE_SIZE
@@ -621,49 +622,46 @@ static int dcp_sha_req_to_buf(struct crystruct dcp_async_ctx *actx =crypto_ahash_ctx (tfm);struct dcp_sha_req_ctx *rctx =ahash_request_ctx (req);struct hash_alg_common *halg =crypto_hash_alg_common (tfm); -const int nents =sg_nents (req->src);uint8_t *in_buf = sdcp->coh->sha_in_buf;uint8_t *out_buf = sdcp->coh->sha_out_buf; -uint8_t *src_buf; -struct scatterlist *src; -unsigned int i, len, clen; +unsigned int i, len, clen, oft =0 ;int ret;int fin = rctx->fini;if (fin) rctx->fini =0 ; -for_each_sg (req->src, src, nents, i) { - src_buf =sg_virt (src); - len =sg_dma_len (src); + src = req->src; + len = req->nbytes; -do { -if (actx->fill + len >DCP_BUF_SZ ) - clen =DCP_BUF_SZ - actx->fill; -else - clen = len; +while (len) { +if (actx->fill + len >DCP_BUF_SZ ) + clen =DCP_BUF_SZ - actx->fill; +else + clen = len; -memcpy (in_buf + actx->fill, src_buf, clen); - len -= clen; - src_buf += clen; - actx->fill += clen; +scatterwalk_map_and_copy (in_buf + actx->fill, src, oft, clen, +0 ); -/* -* If we filled the buffer and still have some -* more data, submit the buffer. -*/ -if (len && actx->fill ==DCP_BUF_SZ ) { - ret =mxs_dcp_run_sha (req); -if (ret) -return ret; - actx->fill =0 ; - rctx->init =0 ; - } - }while (len); + len -= clen; + oft += clen; + actx->fill += clen; + +/* +* If we filled the buffer and still have some +* more data, submit the buffer. +*/ +if (len && actx->fill ==DCP_BUF_SZ ) { + ret =mxs_dcp_run_sha (req); +if (ret) +return ret; + actx->fill =0 ; + rctx->init =0 ; + } }if (fin) {
Greg Kroah-Hartman
maintainerPATCH 132/232 KVM: VMX: fix crash cleanup when KVM wasnt used
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit dbef2808af6c594922fe32833b30f55f35e9da6d upstream.
If KVM wasn't used at all before we crash the cleanup procedure fails with
BUG: unable to handle page fault for address: ffffffffffffffc8 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 23215067 P4D 23215067 PUD 23217067 PMD 0 Oops: 0000 [#8] SMP PTI CPU: 0 PID: 3542 Comm: bash Kdump: loaded Tainted: G D 5.6.0-rc2+ #823 RIP: 0010:crash_vmclear_local_loaded_vmcss.cold+0x19/0x51 [kvm_intel]
The root cause is that loaded_vmcss_on_cpu list is not yet initialized, we initialize it in hardware_enable() but this only happens when we start a VM.
Previously, we used to have a bitmap with enabled CPUs and that was preventing [masking] the issue.
Initialized loaded_vmcss_on_cpu list earlier, right before we assign crash_vmclear_loaded_vmcss pointer. blocked_vcpu_on_cpu list and blocked_vcpu_on_cpu_lock are moved altogether for consistency.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/vmx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx/vmx.c +7 -5
@@ -2228,10 +2228,6 @@ static int hardware_enable(void) !hv_get_vp_assist_page(cpu))return -EFAULT ; -INIT_LIST_HEAD (&per_cpu (loaded_vmcss_on_cpu, cpu)); -INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu)); -spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); -rdmsrl (MSR_IA32_FEATURE_CONTROL , old); test_bits =FEATURE_CONTROL_LOCKED ;
@@ -7996,7 +7992,7 @@ module_exit(vmx_exit);static int __init vmx_init (void ) { -int r; +int r, cpu;#if IS_ENABLED (CONFIG_HYPERV )/*
@@ -8050,6 +8046,12 @@ static int __init vmx_init(void)return r; } +for_each_possible_cpu (cpu) { +INIT_LIST_HEAD (&per_cpu (loaded_vmcss_on_cpu, cpu)); +INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu)); +spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); + } +#ifdef CONFIG_KEXEC_CORE rcu_assign_pointer (crash_vmclear_loaded_vmcss, crash_vmclear_local_loaded_vmcss);
Greg Kroah-Hartman
maintainerPATCH 142/232 btrfs: fix missing file extent item for hole after ranged fsync
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 95418ed1d10774cd9a49af6f39e216c1256f1eeb upstream.
When doing a fast fsync for a range that starts at an offset greater than zero, we can end up with a log that when replayed causes the respective inode miss a file extent item representing a hole if we are not using the NO_HOLES feature. This is because for fast fsyncs we don't log any extents that cover a range different from the one requested in the fsync.
Example scenario to trigger it:
$ mkfs.btrfs -O ^no-holes -f /dev/sdd $ mount /dev/sdd /mnt
# Create a file with a single 256K and fsync it to clear to full sync
# bit in the inode - we want the msync below to trigger a fast fsync. $ xfs_io -f -c "pwrite -S 0xab 0 256K" -c "fsync" /mnt/foo
# Force a transaction commit and wipe out the log tree.
$ sync
# Dirty 768K of data, increasing the file size to 1Mb, and flush only
# the range from 256K to 512K without updating the log tree # (sync_file_range() does not trigger fsync, it only starts writeback # and waits for it to finish).
$ xfs_io -c "pwrite -S 0xcd 256K 768K" /mnt/foo $ xfs_io -c "sync_range -abw 256K 256K" /mnt/foo
# Now dirty the range from 768K to 1M again and sync that range.
$ xfs_io -c "mmap -w 768K 256K" \
-c "mwrite -S 0xef 768K 256K" \
-c "msync -s 768K 256K" \
-c "munmap" \
/mnt/foo<power fail>
# Mount to replay the log.
$ mount /dev/sdd /mnt $ umount /mnt
$ btrfs check /dev/sdd
Opening filesystem to check...
Checking filesystem on /dev/sdd
UUID: 482fb574-b288-478e-a190-a9c44a78fca6
[1/7] checking root items
[2/7] checking extents
[3/7] checking free space cache
[4/7] checking fs roots
root 5 inode 257 errors 100, file extent discount
Found file extent holes:
start: 262144, len: 524288
ERROR: errors found in fs roots
found 720896 bytes used, error(s) found
total csum bytes: 512
total tree bytes: 131072
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 123514
file data blocks allocated: 589824
referenced 589824Fix this issue by setting the range to full (0 to LLONG_MAX) when the NO_HOLES feature is not enabled. This results in extra work being done but it gives the guarantee we don't end up with missing holes after replaying the log.
--- fs/btrfs/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/btrfs/file.c +10 -0
@@ -2074,6 +2074,16 @@ int btrfs_sync_file(struct file *file, lbtrfs_init_log_ctx (&ctx, inode);/* +* Set the range to full if the NO_HOLES feature is not enabled. +* This is to avoid missing file extent items representing holes after +* replaying the log. +*/ +if (!btrfs_fs_incompat (fs_info,NO_HOLES )) { + start =0 ; + end =LLONG_MAX ; + } + +/* * We write the dirty pages in the range and wait until they complete * out of the ->i_mutex. If so, we can flush the dirty pages by * multi-task, and make the performance up. See
Greg Kroah-Hartman
maintainerPATCH 86/232 ALSA: hda/realtek - Add quirk for MSI GL63
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 1d3aa4a5516d2e4933fe3cca11d3349ef63bc547 upstream.
MSI GL63 laptop requires the similar quirk like other MSI models, ALC1220_FIXUP_CLEVO_P950. The board BIOS doesn't provide a PCI SSID for the device, hence we need to take the codec SSID (1462:1275) instead.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -2447,6 +2447,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x1458 ,0xa0b8 ,"Gigabyte AZ370-Gaming" ,ALC1220_FIXUP_GB_DUAL_CODECS ),SND_PCI_QUIRK (0x1458 ,0xa0cd ,"Gigabyte X570 Aorus Master" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1228 ,"MSI-GP63" ,ALC1220_FIXUP_CLEVO_P950 ), +SND_PCI_QUIRK (0x1462 ,0x1275 ,"MSI-GL63" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1276 ,"MSI-GL73" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1293 ,"MSI-GP65" ,ALC1220_FIXUP_CLEVO_P950 ), SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Greg Kroah-Hartman
maintainerPATCH 140/232 btrfs: set update the uuid generation as soon as possible
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 75ec1db8717a8f0a9d9c8d033e542fdaa7b73898 upstream.
In my EIO stress testing I noticed I was getting forced to rescan the uuid tree pretty often, which was weird. This is because my error injection stuff would sometimes inject an error after log replay but before we loaded the UUID tree. If log replay committed the transaction it wouldn't have updated the uuid tree generation, but the tree was valid and didn't change, so there's no reason to not update the generation here.
Fix this by setting the BTRFS_FS_UPDATE_UUID_TREE_GEN bit immediately after reading all the fs roots if the uuid tree generation matches the fs generation. Then any transaction commits that happen during mount won't screw up our uuid tree state, forcing us to do needless uuid rescans.
--- fs/btrfs/disk-io.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +12 -2
@@ -3057,6 +3057,18 @@ retry_root_backup: fs_info->generation = generation; fs_info->last_trans_committed = generation; +/* +* If we have a uuid root and we're not being told to rescan we need to +* check the generation here so we can set the +* BTRFS_FS_UPDATE_UUID_TREE_GEN bit. Otherwise we could commit the +* transaction during a balance or the log replay without updating the +* uuid generation, and then if we crash we would rescan the uuid tree, +* even though it was perfectly fine. +*/ +if (fs_info->uuid_root && !btrfs_test_opt (fs_info,RESCAN_UUID_TREE ) && + fs_info->generation ==btrfs_super_uuid_tree_generation (disk_super)) +set_bit (BTRFS_FS_UPDATE_UUID_TREE_GEN , &fs_info->flags); + ret =btrfs_verify_dev_extents (fs_info);if (ret) { btrfs_err(fs_info,
@@ -3287,8 +3299,6 @@ retry_root_backup:close_ctree (fs_info);return ret; } - }else { -set_bit (BTRFS_FS_UPDATE_UUID_TREE_GEN , &fs_info->flags); }set_bit (BTRFS_FS_OPEN , &fs_info->flags);
Greg Kroah-Hartman
maintainerPATCH 143/232 btrfs: unset reloc control if we fail to recover
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit fb2d83eefef4e1c717205bac71cb1941edf8ae11 upstream.
If we fail to load an fs root, or fail to start a transaction we can bail without unsetting the reloc control, which leads to problems later when we free the reloc control but still have it attached to the file system.
In the normal path we'll end up calling unset_reloc_control() twice, but all it does is set fs_info->reloc_control = NULL, and we can only have one balance at a time so it's not racey.
--- fs/btrfs/relocation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/relocation.c +5 -5
@@ -4584,9 +4584,8 @@ int btrfs_recover_relocation(struct btrf trans =btrfs_join_transaction (rc->extent_root);if (IS_ERR (trans)) { -unset_reloc_control (rc); err =PTR_ERR (trans); - goto out_free; + goto out_unset; } rc->merge_reloc_tree =1 ;
@@ -4606,7 +4605,7 @@ int btrfs_recover_relocation(struct btrfif (IS_ERR (fs_root)) { err =PTR_ERR (fs_root);list_add_tail (&reloc_root->root_list, &reloc_roots); - goto out_free; + goto out_unset; } err =__add_reloc_root (reloc_root);
@@ -4616,7 +4615,7 @@ int btrfs_recover_relocation(struct btrf err =btrfs_commit_transaction (trans);if (err) - goto out_free; + goto out_unset;merge_reloc_roots (rc);
@@ -4632,7 +4631,8 @@ out_clean: ret =clean_dirty_subvols (rc);if (ret <0 && !err) err = ret; -out_free: +out_unset: +unset_reloc_control (rc);kfree (rc); out:if (!list_empty (&reloc_roots))
Greg Kroah-Hartman
maintainerPATCH 141/232 btrfs: drop block from cache on error in relocation
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 8e19c9732ad1d127b5575a10f4fbcacf740500ff upstream.
If we have an error while building the backref tree in relocation we'll process all the pending edges and then free the node. However if we integrated some edges into the cache we'll lose our link to those edges by simply freeing this node, which means we'll leak memory and references to any roots that we've found.
Instead we need to use remove_backref_node(), which walks through all of the edges that are still linked to this node and free's them up and drops any root references we may be holding.
--- fs/btrfs/relocation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/relocation.c +1 -1
@@ -1186,7 +1186,7 @@ out:free_backref_node (cache, lower); } -free_backref_node (cache, node); +remove_backref_node (cache, node);return ERR_PTR (err); }ASSERT (!node || !node->detached);
Greg Kroah-Hartman
maintainerPATCH 95/232 thermal: devfreq_cooling: inline all stubs for CONFIG_DEVFREQ_THERMAL=n
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
commit 3f5b9959041e0db6dacbea80bb833bff5900999f upstream.
When CONFIG_DEVFREQ_THERMAL is disabled all functions except of_devfreq_cooling_register_power() were already inlined. Also inline the last function to avoid compile errors when multiple drivers call of_devfreq_cooling_register_power() when CONFIG_DEVFREQ_THERMAL is not set. Compilation failed with the following message:
multiple definition of `of_devfreq_cooling_register_power'
(which then lists all usages of of_devfreq_cooling_register_power())
Thomas Zimmermann reported this problem [0] on a kernel config with CONFIG_DRM_LIMA={m,y}, CONFIG_DRM_PANFROST={m,y} and CONFIG_DEVFREQ_THERMAL=n after both, the lima and panfrost drivers gained devfreq cooling support.
[0] https://www.spinics.net/lists/dri-devel/msg252825.html
--- include/linux/devfreq_cooling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/devfreq_cooling.h +1 -1
@@ -75,7 +75,7 @@ void devfreq_cooling_unregister(struct t#else /* !CONFIG_DEVFREQ_THERMAL */ -struct thermal_cooling_device * +static inline struct thermal_cooling_device *of_devfreq_cooling_register_power (struct device_node *np,struct devfreq *df,struct devfreq_cooling_power *dfc_power) {
Greg Kroah-Hartman
maintainerPATCH 129/232 KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 31603d4fc2bb4f0815245d496cb970b27b4f636a upstream.
VMCLEAR all in-use VMCSes during a crash, even if kdump's NMI shootdown interrupted a KVM update of the percpu in-use VMCS list.
Because NMIs are not blocked by disabling IRQs, it's possible that crash_vmclear_local_loaded_vmcss() could be called while the percpu list of VMCSes is being modified, e.g. in the middle of list_add() in vmx_vcpu_load_vmcs(). This potential corner case was called out in the original commit[*], but the analysis of its impact was wrong.
Skipping the VMCLEARs is wrong because it all but guarantees that a loaded, and therefore cached, VMCS will live across kexec and corrupt memory in the new kernel. Corruption will occur because the CPU's VMCS cache is non-coherent, i.e. not snooped, and so the writeback of VMCS memory on its eviction will overwrite random memory in the new kernel. The VMCS will live because the NMI shootdown also disables VMX, i.e. the in-progress VMCLEAR will #UD, and existing Intel CPUs do not flush the VMCS cache on VMXOFF.
Furthermore, interrupting list_add() and list_del() is safe due to crash_vmclear_local_loaded_vmcss() using forward iteration. list_add() ensures the new entry is not visible to forward iteration unless the entire add completes, via WRITE_ONCE(prev->next, new). A bad "prev" pointer could be observed if the NMI shootdown interrupted list_del() or list_add(), but list_for_each_entry() does not consume ->prev.
In addition to removing the temporary disabling of VMCLEAR, open code loaded_vmcs_init() in __loaded_vmcs_clear() and reorder VMCLEAR so that the VMCS is deleted from the list only after it's been VMCLEAR'd. Deleting the VMCS before VMCLEAR would allow a race where the NMI shootdown could arrive between list_del() and vmcs_clear() and thus neither flow would execute a successful VMCLEAR. Alternatively, more code could be moved into loaded_vmcs_init(), but that gets rather silly as the only other user, alloc_loaded_vmcs(), doesn't need the smp_wmb() and would need to work around the list_del().
Update the smp_*() comments related to the list manipulation, and opportunistically reword them to improve clarity.
[*] https://patchwork.kernel.org/patch/1675731/#3720461
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/vmx.c | 67 +++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 51 deletions(-)
arch/x86/kvm/vmx/vmx.c +16 -51
@@ -648,43 +648,15 @@ void loaded_vmcs_init(struct loaded_vmcs }#ifdef CONFIG_KEXEC_CORE -/* -* This bitmap is used to indicate whether the vmclear -* operation is enabled on all cpus. All disabled by -* default. -*/ -static cpumask_t crash_vmclear_enabled_bitmap =CPU_MASK_NONE ; - -static inline void crash_enable_local_vmclear (int cpu) -{ -cpumask_set_cpu (cpu, &crash_vmclear_enabled_bitmap); -} - -static inline void crash_disable_local_vmclear (int cpu) -{ -cpumask_clear_cpu (cpu, &crash_vmclear_enabled_bitmap); -} - -static inline int crash_local_vmclear_enabled (int cpu) -{ -return cpumask_test_cpu (cpu, &crash_vmclear_enabled_bitmap); -} -static void crash_vmclear_local_loaded_vmcss (void ) {int cpu =raw_smp_processor_id ();struct loaded_vmcs *v; -if (!crash_local_vmclear_enabled (cpu)) -return ; -list_for_each_entry (v, &per_cpu (loaded_vmcss_on_cpu, cpu), loaded_vmcss_on_cpu_link)vmcs_clear (v->vmcs); } -#else -static inline void crash_enable_local_vmclear (int cpu) { } -static inline void crash_disable_local_vmclear (int cpu) { }#endif /* CONFIG_KEXEC_CORE */ static void __loaded_vmcs_clear (void *arg)
@@ -696,19 +668,24 @@ static void __loaded_vmcs_clear(void *arreturn ;/* vcpu migration can race with cpu offline */ if (per_cpu (current_vmcs, cpu) == loaded_vmcs->vmcs)per_cpu (current_vmcs, cpu) =NULL ; -crash_disable_local_vmclear (cpu); + +vmcs_clear (loaded_vmcs->vmcs); +if (loaded_vmcs->shadow_vmcs && loaded_vmcs->launched) +vmcs_clear (loaded_vmcs->shadow_vmcs); +list_del (&loaded_vmcs->loaded_vmcss_on_cpu_link);/* -* we should ensure updating loaded_vmcs->loaded_vmcss_on_cpu_link -* is before setting loaded_vmcs->vcpu to -1 which is done in -* loaded_vmcs_init. Otherwise, other cpu can see vcpu = -1 fist -* then adds the vmcs into percpu list before it is deleted. +* Ensure all writes to loaded_vmcs, including deleting it from its +* current percpu list, complete before setting loaded_vmcs->vcpu to +* -1, otherwise a different cpu can see vcpu == -1 first and add +* loaded_vmcs to its percpu list before it's deleted from this cpu's +* list. Pairs with the smp_rmb() in vmx_vcpu_load_vmcs(). */ smp_wmb (); -loaded_vmcs_init (loaded_vmcs); -crash_enable_local_vmclear (cpu); + loaded_vmcs->cpu =-1 ; + loaded_vmcs->launched =0 ; }void loaded_vmcs_clear (struct loaded_vmcs *loaded_vmcs)
@@ -1317,18 +1294,17 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpuif (!already_loaded) {loaded_vmcs_clear (vmx->loaded_vmcs);local_irq_disable (); -crash_disable_local_vmclear (cpu);/* -* Read loaded_vmcs->cpu should be before fetching -* loaded_vmcs->loaded_vmcss_on_cpu_link. -* See the comments in __loaded_vmcs_clear(). +* Ensure loaded_vmcs->cpu is read before adding loaded_vmcs to +* this cpu's percpu list, otherwise it may not yet be deleted +* from its previous cpu's percpu list. Pairs with the +* smb_wmb() in __loaded_vmcs_clear(). */ smp_rmb ();list_add (&vmx->loaded_vmcs->loaded_vmcss_on_cpu_link, &per_cpu (loaded_vmcss_on_cpu, cpu)); -crash_enable_local_vmclear (cpu);local_irq_enable (); }
@@ -2256,17 +2232,6 @@ static int hardware_enable(void)INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu));spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); -/* -* Now we can enable the vmclear operation in kdump -* since the loaded_vmcss_on_cpu list on this cpu -* has been initialized. -* -* Though the cpu is not in VMX operation now, there -* is no problem to enable the vmclear operation -* for the loaded_vmcss_on_cpu list is empty! -*/ -crash_enable_local_vmclear (cpu); -rdmsrl (MSR_IA32_FEATURE_CONTROL , old); test_bits =FEATURE_CONTROL_LOCKED ;
Greg Kroah-Hartman
maintainerPATCH 128/232 KVM: x86: Allocate new rmap and large page tracking when moving memslot
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit edd4fa37baa6ee8e44dc65523b27bd6fe44c94de upstream.
Reallocate a rmap array and recalcuate large page compatibility when moving an existing memslot to correctly handle the alignment properties of the new memslot. The number of rmap entries required at each level is dependent on the alignment of the memslot's base gfn with respect to that level, e.g. moving a large-page aligned memslot so that it becomes unaligned will increase the number of rmap entries needed at the now unaligned level.
Not updating the rmap array is the most obvious bug, as KVM accesses garbage data beyond the end of the rmap. KVM interprets the bad data as pointers, leading to non-canonical #GPs, unexpected #PFs, etc...
general protection fault: 0000 [#1] SMP CPU: 0 PID: 1909 Comm: move_memory_reg Not tainted 5.4.0-rc7+ #139 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:rmap_get_first+0x37/0x50 [kvm] Code: <48> 8b 3b 48 85 ff 74 ec e8 6c f4 ff ff 85 c0 74 e3 48 89 d8 5b c3 RSP: 0018:ffffc9000021bbc8 EFLAGS: 00010246 RAX: ffff00617461642e RBX: ffff00617461642e RCX: 0000000000000012 RDX: ffff88827400f568 RSI: ffffc9000021bbe0 RDI: ffff88827400f570 RBP: 0010000000000000 R08: ffffc9000021bd00 R09: ffffc9000021bda8 R10: ffffc9000021bc48 R11: 0000000000000000 R12: 0030000000000000 R13: 0000000000000000 R14: ffff88827427d700 R15: ffffc9000021bce8 FS: 00007f7eda014700(0000) GS:ffff888277a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7ed9216ff8 CR3: 0000000274391003 CR4: 0000000000162eb0 Call Trace: kvm_mmu_slot_set_dirty+0xa1/0x150 [kvm] __kvm_set_memory_region.part.64+0x559/0x960 [kvm] kvm_set_memory_region+0x45/0x60 [kvm] kvm_vm_ioctl+0x30f/0x920 [kvm] do_vfs_ioctl+0xa1/0x620 ksys_ioctl+0x66/0x70 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x4c/0x170 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f7ed9911f47 Code: <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 6f 2c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffc00937498 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000001ab0010 RCX: 00007f7ed9911f47 RDX: 0000000001ab1350 RSI: 000000004020ae46 RDI: 0000000000000004 RBP: 000000000000000a R08: 0000000000000000 R09: 00007f7ed9214700 R10: 00007f7ed92149d0 R11: 0000000000000246 R12: 00000000bffff000 R13: 0000000000000003 R14: 00007f7ed9215000 R15: 0000000000000000 Modules linked in: kvm_intel kvm irqbypass ---[ end trace 0c5f570b3358ca89 ]---
The disallow_lpage tracking is more subtle. Failure to update results in KVM creating large pages when it shouldn't, either due to stale data or again due to indexing beyond the end of the metadata arrays, which can lead to memory corruption and/or leaking data to guest/userspace.
Note, the arrays for the old memslot are freed by the unconditional call to kvm_free_memslot() in __kvm_set_memory_region().
--- arch/x86/kvm/x86.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/x86/kvm/x86.c +11 -0
@@ -9726,6 +9726,13 @@ int kvm_arch_create_memslot(struct kvm * {int i; +/* +* Clear out the previous array pointers for the KVM_MR_MOVE case. The +* old arrays will be freed by __kvm_set_memory_region() if installing +* the new memslot is successful. +*/ +memset (&slot->arch,0 ,sizeof (slot->arch)); +for (i =0 ; i <KVM_NR_PAGE_SIZES ; ++i) {struct kvm_lpage_info *linfo;unsigned long ugfn;
@@ -9807,6 +9814,10 @@ int kvm_arch_prepare_memory_region(struc const struct kvm_userspace_memory_region *mem, enum kvm_mr_change change) { + if (change == KVM_MR_MOVE) + return kvm_arch_create_memslot(kvm, memslot, + mem->memory_size >> PAGE_SHIFT); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 90/232 media: ti-vpe: cal: fix a kernel oops when unloading module
In reply to Greg Kroah-HartmanFrom: Benoit Parrot <[email protected]>
commit 80264809ea0a3fd2ee8251f31a9eb85d2c3fc77e upstream.
After the switch to use v4l2_async_notifier_add_subdev() and v4l2_async_notifier_cleanup(), unloading the ti_cal module would cause a kernel oops.
This was root cause to the fact that v4l2_async_notifier_cleanup() tries to kfree the asd pointer passed into v4l2_async_notifier_add_subdev().
In our case the asd reference was from a statically allocated struct. So in effect v4l2_async_notifier_cleanup() was trying to free a pointer that was not kalloc.
So here we switch to using a kzalloc struct instead of a static one. To achieve this we re-order some of the calls to prevent asd allocation from leaking.
--- drivers/media/platform/ti-vpe/cal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/platform/ti-vpe/cal.c +8 -5
@@ -266,8 +266,6 @@ struct cal_ctx {struct v4l2_subdev *sensor;struct v4l2_fwnode_endpoint endpoint; -struct v4l2_async_subdev asd; -struct v4l2_fh fh;struct cal_dev *dev;struct cc_data *cc;
@@ -1648,7 +1646,6 @@ static int of_cal_create_instance(struct parent = pdev->dev.of_node; - asd = &ctx->asd; endpoint = &ctx->endpoint; ep_node =NULL ;
@@ -1695,8 +1692,6 @@ static int of_cal_create_instance(structctx_dbg (3 , ctx,"can't get remote parent\n" ); goto cleanup_exit; } - asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode =of_fwnode_handle (sensor_node);v4l2_fwnode_endpoint_parse (of_fwnode_handle (ep_node), endpoint);
@@ -1726,9 +1721,17 @@ static int of_cal_create_instance(structv4l2_async_notifier_init (&ctx->notifier); + asd =kzalloc (sizeof (*asd),GFP_KERNEL ); +if (!asd) + goto cleanup_exit; + + asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; + asd->match.fwnode =of_fwnode_handle (sensor_node); + ret =v4l2_async_notifier_add_subdev (&ctx->notifier, asd);if (ret) {ctx_err (ctx,"Error adding asd\n" ); +kfree (asd); goto cleanup_exit; }
Greg Kroah-Hartman
maintainerPATCH 125/232 KVM: nVMX: Properly handle userspace interrupt window request
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit a1c77abb8d93381e25a8d2df3a917388244ba776 upstream.
Return true for vmx_interrupt_allowed() if the vCPU is in L2 and L1 has external interrupt exiting enabled. IRQs are never blocked in hardware if the CPU is in the guest (L2 from L1's perspective) when IRQs trigger VM-Exit.
The new check percolates up to kvm_vcpu_ready_for_interrupt_injection() and thus vcpu_run(), and so KVM will exit to userspace if userspace has requested an interrupt window (to inject an IRQ into L1).
Remove the @external_intr param from vmx_check_nested_events(), which is actually an indicator that userspace wants an interrupt window, e.g. it's named @req_int_win further up the stack. Injecting a VM-Exit into L1 to try and bounce out to L0 userspace is all kinds of broken and is no longer necessary.
Remove the hack in nested_vmx_vmexit() that attempted to workaround the breakage in vmx_check_nested_events() by only filling interrupt info if there's an actual interrupt pending. The hack actually made things worse because it caused KVM to _never_ fill interrupt info when the LAPIC resides in userspace (kvm_cpu_has_interrupt() queries interrupt.injected, which is always cleared by prepare_vmcs12() before reaching the hack in nested_vmx_vmexit()).
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx/nested.c | 18 ++++-------------- arch/x86/kvm/vmx/vmx.c | 9 +++++++-- arch/x86/kvm/x86.c | 10 +++++----- 4 files changed, 17 insertions(+), 22 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -1130,7 +1130,7 @@ struct kvm_x86_ops {bool (*pt_supported)(void );bool (*pku_supported)(void ); -int (*check_nested_events)(struct kvm_vcpu *vcpu,bool external_intr); +int (*check_nested_events)(struct kvm_vcpu *vcpu);void (*request_immediate_exit)(struct kvm_vcpu *vcpu);void (*sched_in)(struct kvm_vcpu *kvm,int cpu);
arch/x86/kvm/vmx/nested.c +4 -14
@@ -3460,7 +3460,7 @@ static void nested_vmx_inject_exception_nested_vmx_vmexit (vcpu,EXIT_REASON_EXCEPTION_NMI , intr_info, exit_qual); } -static int vmx_check_nested_events (struct kvm_vcpu *vcpu,bool external_intr) +static int vmx_check_nested_events (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu);unsigned long exit_qual;
@@ -3507,8 +3507,7 @@ static int vmx_check_nested_events(strucreturn 0 ; } -if ((kvm_cpu_has_interrupt (vcpu) || external_intr) && -nested_exit_on_intr (vcpu)) { +if (kvm_cpu_has_interrupt (vcpu) &&nested_exit_on_intr (vcpu)) {if (block_nested_events)return -EBUSY ;nested_vmx_vmexit (vcpu,EXIT_REASON_EXTERNAL_INTERRUPT ,0 ,0 );
@@ -4158,17 +4157,8 @@ void nested_vmx_vmexit(struct kvm_vcpu * vcpu->arch.mp_state =KVM_MP_STATE_RUNNABLE ;if (likely (!vmx->fail)) { -/* -* TODO: SDM says that with acknowledge interrupt on -* exit, bit 31 of the VM-exit interrupt information -* (valid interrupt) is always set to 1 on -* EXIT_REASON_EXTERNAL_INTERRUPT, so we shouldn't -* need kvm_cpu_has_interrupt(). See the commit -* message for details. -*/ -if (nested_exit_intr_ack_set (vcpu) && - exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT && -kvm_cpu_has_interrupt (vcpu)) { +if (exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT && +nested_exit_intr_ack_set (vcpu)) {int irq =kvm_cpu_get_interrupt (vcpu);WARN_ON (irq <0 ); vmcs12->vm_exit_intr_info = irq |
arch/x86/kvm/vmx/vmx.c +7 -2
@@ -4505,8 +4505,13 @@ static int vmx_nmi_allowed(struct kvm_vcstatic int vmx_interrupt_allowed (struct kvm_vcpu *vcpu) { -return (!to_vmx (vcpu)->nested.nested_run_pending && -vmcs_readl (GUEST_RFLAGS ) &X86_EFLAGS_IF ) && +if (to_vmx (vcpu)->nested.nested_run_pending) +return false; + +if (is_guest_mode (vcpu) &&nested_exit_on_intr (vcpu)) +return true; + +return (vmcs_readl (GUEST_RFLAGS ) &X86_EFLAGS_IF ) && !(vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); }
arch/x86/kvm/x86.c +5 -5
@@ -7555,7 +7555,7 @@ static void update_cr8_intercept(struct kvm_x86_ops->update_cr8_intercept (vcpu, tpr, max_irr); } -static int inject_pending_event (struct kvm_vcpu *vcpu,bool req_int_win) +static int inject_pending_event (struct kvm_vcpu *vcpu) {int r;
@@ -7591,7 +7591,7 @@ static int inject_pending_event(struct k* from L2 to L1. */ if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) { - r = kvm_x86_ops->check_nested_events (vcpu, req_int_win); + r = kvm_x86_ops->check_nested_events (vcpu);if (r !=0 )return r; }
@@ -7653,7 +7653,7 @@ static int inject_pending_event(struct k* KVM_REQ_EVENT only on certain events and not unconditionally? */ if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) { - r = kvm_x86_ops->check_nested_events (vcpu, req_int_win); + r = kvm_x86_ops->check_nested_events (vcpu);if (r !=0 )return r; }
@@ -8130,7 +8130,7 @@ static int vcpu_enter_guest(struct kvm_v goto out; } -if (inject_pending_event (vcpu, req_int_win) !=0 ) +if (inject_pending_event (vcpu) !=0 ) req_immediate_exit = true;else {/* Enable SMI/NMI/IRQ window open exits if needed.
@@ -8360,7 +8360,7 @@ static inline int vcpu_block(struct kvmstatic inline bool kvm_vcpu_running (struct kvm_vcpu *vcpu) {if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) - kvm_x86_ops->check_nested_events (vcpu, false); + kvm_x86_ops->check_nested_events (vcpu);return (vcpu->arch.mp_state ==KVM_MP_STATE_RUNNABLE && !vcpu->arch.apf.halted);
Greg Kroah-Hartman
maintainerPATCH 124/232 platform/x86: asus-wmi: Support laptops where the first battery is named BATT
In reply to Greg Kroah-HartmanFrom: Kristian Klausen <[email protected]>
commit 6b3586d45bba14f6912f37488090c37a3710e7b4 upstream.
The WMI method to set the charge threshold does not provide a way to specific a battery, so we assume it is the first/primary battery (by checking if the name is BAT0).
On some newer ASUS laptops (Zenbook UM431DA) though, the primary/first battery isn't named BAT0 but BATT, so we need to support that case.
--- drivers/platform/x86/asus-wmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/platform/x86/asus-wmi.c +4 -1
@@ -418,8 +418,11 @@ static int asus_wmi_battery_add(struct p {/* The WMI method does not provide a way to specific a battery, so we * just assume it is the first battery. +* Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first +* battery is named BATT. */ -if (strcmp (battery->desc->name,"BAT0" ) !=0 ) +if (strcmp (battery->desc->name,"BAT0" ) !=0 && +strcmp (battery->desc->name,"BATT" ) !=0 )return -ENODEV ; if (device_create_file(&battery->dev,
Greg Kroah-Hartman
maintainerPATCH 118/232 ath9k: Handle txpower changes even when TPC is disabled
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
commit 968ae2caad0782db5dbbabb560d3cdefd2945d38 upstream.
When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to reconfigure HW's maximum txpower.
This fixes 0dBm txpower setting when user attaches to an interface for the first time with the following scenario:
ieee80211_do_open()
ath9k_add_interface()
ath9k_set_txpower() /* Set TX power with not yet initialized
sc->hw->conf.power_level */
ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
raise IEEE80211_CONF_CHANGE_POWER */
ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */This issue can be reproduced with the following:
$ modprobe -r ath9k
$ modprobe ath9k
$ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
$ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
$ killall wpa_supplicant
$ iw dev /* TX power goes back to calibrated value and subsequent
calls will be fine */--- drivers/net/wireless/ath/ath9k/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/main.c +3 -0
@@ -1457,6 +1457,9 @@ static int ath9k_config(struct ieee80211ath_chanctx_set_channel (sc, ctx, &hw->conf.chandef); } +if (changed &IEEE80211_CONF_CHANGE_POWER ) +ath9k_set_txpower (sc,NULL ); +mutex_unlock (&sc->mutex);ath9k_ps_restore (sc);
Greg Kroah-Hartman
maintainerPATCH 122/232 x86/tsc_msr: Make MSR derived TSC frequency more accurate
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit fac01d11722c92a186b27ee26cd429a8066adfb5 upstream.
The "Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 4:
Model-Specific Registers" has the following table for the values from freq_desc_byt:
000B: 083.3 MHz
001B: 100.0 MHz
010B: 133.3 MHz
011B: 116.7 MHz
100B: 080.0 MHz
Notice how for e.g the 83.3 MHz value there are 3 significant digits, which translates to an accuracy of a 1000 ppm, where as a typical crystal oscillator is 20 - 100 ppm, so the accuracy of the frequency format used in the Software Developer’s Manual is not really helpful.
As far as we know Bay Trail SoCs use a 25 MHz crystal and Cherry Trail uses a 19.2 MHz crystal, the crystal is the source clock for a root PLL which outputs 1600 and 100 MHz. It is unclear if the root PLL outputs are used directly by the CPU clock PLL or if there is another PLL in between.
This does not matter though, we can model the chain of PLLs as a single PLL with a quotient equal to the quotients of all PLLs in the chain multiplied.
So we can create a simplified model of the CPU clock setup using a reference clock of 100 MHz plus a quotient which gets us as close to the frequency from the SDM as possible.
For the 83.3 MHz example from above this would give 100 MHz * 5 / 6 = 83 and 1/3 MHz, which matches exactly what has been measured on actual hardware.
Use a simplified PLL model with a reference clock of 100 MHz for all Bay and Cherry Trail models.
This has been tested on the following models:
CPU freq before: CPU freq after: Intel N2840 2165.800 MHz 2166.667 MHz Intel Z3736 1332.800 MHz 1333.333 MHz Intel Z3775 1466.300 MHz 1466.667 MHz Intel Z8350 1440.000 MHz 1440.000 MHz Intel Z8750 1600.000 MHz 1600.000 MHz
This fixes the time drifting by about 1 second per hour (20 - 30 seconds per day) on (some) devices which rely on the tsc_msr.c code to determine the TSC frequency.
--- arch/x86/kernel/tsc_msr.c | 97 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 11 deletions(-)
arch/x86/kernel/tsc_msr.c +86 -11
@@ -18,6 +18,28 @@#define MAX_NUM_FREQS 16/* 4 bits to select the frequency */ /* +* The frequency numbers in the SDM are e.g. 83.3 MHz, which does not contain a +* lot of accuracy which leads to clock drift. As far as we know Bay Trail SoCs +* use a 25 MHz crystal and Cherry Trail uses a 19.2 MHz crystal, the crystal +* is the source clk for a root PLL which outputs 1600 and 100 MHz. It is +* unclear if the root PLL outputs are used directly by the CPU clock PLL or +* if there is another PLL in between. +* This does not matter though, we can model the chain of PLLs as a single PLL +* with a quotient equal to the quotients of all PLLs in the chain multiplied. +* So we can create a simplified model of the CPU clock setup using a reference +* clock of 100 MHz plus a quotient which gets us as close to the frequency +* from the SDM as possible. +* For the 83.3 MHz example from above this would give us 100 MHz * 5 / 6 = +* 83 and 1/3 MHz, which matches exactly what has been measured on actual hw. +*/ +#define TSC_REFERENCE_KHZ 100000 + +struct muldiv { +u32 multiplier; +u32 divider; +}; + +/* * If MSR_PERF_STAT[31] is set, the maximum resolved bus ratio can be * read in MSR_PLATFORM_ID[12:8], otherwise in MSR_PERF_STAT[44:40]. * Unfortunately some Intel Atom SoCs aren't quite compliant to this,
@@ -26,6 +48,11 @@*/ struct freq_desc {bool use_msr_plat; +struct muldiv muldiv[MAX_NUM_FREQS ]; +/* +* Some CPU frequencies in the SDM do not map to known PLL freqs, in +* that case the muldiv array is empty and the freqs array is used. +*/ u32 freqs[MAX_NUM_FREQS ];u32 mask; };
@@ -47,31 +74,66 @@ static const struct freq_desc freq_desc_ .mask = 0x07, }; +/* +* Bay Trail SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 000: 100 * 5 / 6 = 83.3333 MHz +* 001: 100 * 1 / 1 = 100.0000 MHz +* 010: 100 * 4 / 3 = 133.3333 MHz +* 011: 100 * 7 / 6 = 116.6667 MHz +* 100: 100 * 4 / 5 = 80.0000 MHz +*/ static const struct freq_desc freq_desc_byt = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,116700 ,80000 ,0 ,0 ,0 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {7 ,6 }, + {4 ,5 } }, .mask =0x07 , }; +/* +* Cherry Trail SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0000: 100 * 5 / 6 = 83.3333 MHz +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +* 0011: 100 * 7 / 6 = 116.6667 MHz +* 0100: 100 * 4 / 5 = 80.0000 MHz +* 0101: 100 * 14 / 15 = 93.3333 MHz +* 0110: 100 * 9 / 10 = 90.0000 MHz +* 0111: 100 * 8 / 9 = 88.8889 MHz +* 1000: 100 * 7 / 8 = 87.5000 MHz +*/ static const struct freq_desc freq_desc_cht = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,116700 ,80000 ,93300 ,90000 , -88900 ,87500 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {7 ,6 }, + {4 ,5 }, {14 ,15 }, {9 ,10 }, {8 ,9 }, + {7 ,8 } }, .mask =0x0f , }; +/* +* Merriefield SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +*/ static const struct freq_desc freq_desc_tng = { .use_msr_plat = true, - .freqs = {0 ,100000 ,133300 ,0 ,0 ,0 ,0 ,0 }, + .muldiv = { {0 ,0 }, {1 ,1 }, {4 ,3 } }, .mask =0x07 , }; +/* +* Moorefield SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0000: 100 * 5 / 6 = 83.3333 MHz +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +* 0011: 100 * 1 / 1 = 100.0000 MHz +*/ static const struct freq_desc freq_desc_ann = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,100000 ,0 ,0 ,0 ,0 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {1 ,1 } }, .mask =0x0f , }; +/* 24 MHz crystal? : 24 * 13 / 4 = 78 MHz */ static const struct freq_desc freq_desc_lgm = { .use_msr_plat = true, .freqs = {78000 ,78000 ,78000 ,78000 ,78000 ,78000 ,78000 ,78000 },
@@ -97,9 +159,10 @@ static const struct x86_cpu_id tsc_msr_c*/ unsigned long cpu_khz_from_msr (void ) { -u32 lo, hi, ratio, freq; +u32 lo, hi, ratio, freq, tscref;const struct freq_desc *freq_desc;const struct x86_cpu_id *id; +const struct muldiv *md;unsigned long res;int index;
@@ -119,12 +182,24 @@ unsigned long cpu_khz_from_msr(void)/* Get FSB FREQ ID */ rdmsr (MSR_FSB_FREQ , lo, hi); index = lo & freq_desc->mask; + md = &freq_desc->muldiv[index]; -/* Map CPU reference clock freq ID(0-7) to CPU reference clock freq(KHz) */ - freq = freq_desc->freqs[index]; - -/* TSC frequency = maximum resolved freq * maximum resolved bus ratio */ - res = freq * ratio; +/* +* Note this also catches cases where the index points to an unpopulated +* part of muldiv, in that case the else will set freq and res to 0. +*/ +if (md->divider) { + tscref =TSC_REFERENCE_KHZ * md->multiplier; + freq =DIV_ROUND_CLOSEST (tscref, md->divider); +/* +* Multiplying by ratio before the division has better +* accuracy than just calculating freq * ratio. +*/ + res =DIV_ROUND_CLOSEST (tscref * ratio, md->divider); + }else { + freq = freq_desc->freqs[index]; + res = freq * ratio; + }if (freq ==0 )pr_err ("Error MSR_FSB_FREQ index %d is unknown\n" , index);
Greg Kroah-Hartman
maintainerPATCH 123/232 x86/entry/32: Add missing ASM_CLAC to general_protection entry
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 3d51507f29f2153a658df4a0674ec5b592b62085 upstream.
All exception entry points must have ASM_CLAC right at the beginning. The general_protection entry is missing one.
--- arch/x86/entry/entry_32.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/entry/entry_32.S +1 -0
@@ -1647,6 +1647,7 @@ ENTRY(int3) END(int3) ENTRY(general_protection) + ASM_CLAC pushl $do_general_protection jmp common_exception END(general_protection)
Greg Kroah-Hartman
maintainerPATCH 117/232 PM: sleep: wakeup: Skip wakeup_source_sysfs_remove() if device is not there
In reply to Greg Kroah-HartmanFrom: Neeraj Upadhyay <[email protected]>
commit 87de6594dc45dbf6819f3e0ef92f9331c5a9444c upstream.
Skip wakeup_source_sysfs_remove() to fix a NULL pinter dereference via ws->dev, if the wakeup source is unregistered before registering the wakeup class from device_add().
--- drivers/base/power/wakeup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/power/wakeup.c +3 -1
@@ -241,7 +241,9 @@ void wakeup_source_unregister(struct wak {if (ws) {wakeup_source_remove (ws); -wakeup_source_sysfs_remove (ws); +if (ws->dev) +wakeup_source_sysfs_remove (ws); +wakeup_source_destroy (ws); } }
Greg Kroah-Hartman
maintainerPATCH 116/232 PM / Domains: Allow no domain-idle-states DT property in genpd when parsing
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 56cb26891ea4180121265dc6b596015772c4a4b8 upstream.
Commit 2c361684803e ("PM / Domains: Don't treat zero found compatible idle states as an error"), moved of_genpd_parse_idle_states() towards allowing none compatible idle state to be found for the device node, rather than returning an error code.
However, it didn't consider that the "domain-idle-states" DT property may be missing as it's optional, which makes of_count_phandle_with_args() to return -ENOENT. Let's fix this to make the behaviour consistent.
--- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
@@ -2615,7 +2615,7 @@ static int genpd_iterate_idle_states(str ret =of_count_phandle_with_args (dn,"domain-idle-states" ,NULL );if (ret <=0 ) -return ret; +return ret == -ENOENT ?0 : ret;/* Loop over the phandles until all the requested entry is found */ of_for_each_phandle (&it, ret, dn,"domain-idle-states" ,NULL ,0 ) {
Greg Kroah-Hartman
maintainerPATCH 113/232 pstore: pstore_ftrace_seq_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit 6c871b7314dde9ab64f20de8f5aa3d01be4518e8 upstream.
In Aug 2018 NeilBrown noticed
commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") "Some ->next functions do not increment *pos when they return NULL... Note that such ->next functions are buggy and should be fixed.
A simple demonstration is
dd if=/proc/swaps bs=1000 skip=1
Choose any block size larger than the size of /proc/swaps. This will always show the whole last line of /proc/swaps"
/proc/swaps output was fixed recently, however there are lot of other affected files, and one of them is related to pstore subsystem.
If .next function does not change position index, following .show function will repeat output related to current position index.
There are at least 2 related problems:
- read after lseek beyond end of file, described above by NeilBrown "dd if=<AFFECTED_FILE> bs=1000 skip=1" will generate whole last list
- read after lseek on in middle of last line will output expected rest of last line but then repeat whole last line once again.
If .show() function generates multy-line output (like pstore_ftrace_seq_show() does ?) following bash script cycles endlessly
$ q=;while read -r r;do echo "$((++q)) $r";done < AFFECTED_FILE
Unfortunately I'm not familiar enough to pstore subsystem and was unable to find affected pstore-related file on my test node.
If .next function does not change position index, following .show function will repeat output related to current position index.
--- fs/pstore/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/pstore/inode.c +4 -1
@@ -87,11 +87,11 @@ static void *pstore_ftrace_seq_next(strustruct pstore_private *ps = s->private;struct pstore_ftrace_seq_data *data = v; + (*pos)++; data->off +=REC_SIZE ;if (data->off +REC_SIZE > ps->total_size)return NULL ; - (*pos)++;return data; }
@@ -101,6 +101,9 @@ static int pstore_ftrace_seq_show(structstruct pstore_ftrace_seq_data *data = v;struct pstore_ftrace_record *rec; +if (!data) +return 0 ; + rec = (struct pstore_ftrace_record *)(ps->record->buf + data->off); seq_printf(s, "CPU:%d ts:%llu %08lx %08lx %ps <- %pS\n",
Greg Kroah-Hartman
maintainerPATCH 109/232 cpu/hotplug: Ignore pm_wakeup_pending() for disable_nonboot_cpus()
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit e98eac6ff1b45e4e73f2e6031b37c256ccb5d36b upstream.
A recent change to freeze_secondary_cpus() which added an early abort if a wakeup is pending missed the fact that the function is also invoked for shutdown, reboot and kexec via disable_nonboot_cpus().
In case of disable_nonboot_cpus() the wakeup event needs to be ignored as the purpose is to terminate the currently running kernel.
Add a 'suspend' argument which is only set when the freeze is in context of a suspend operation. If not set then an eventually pending wakeup event is ignored.
--- include/linux/cpu.h | 12 +++++++++--- kernel/cpu.c | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-)
include/linux/cpu.h +9 -3
@@ -138,12 +138,18 @@ static inline void get_online_cpus(void)static inline void put_online_cpus (void ) {cpus_read_unlock (); }#ifdef CONFIG_PM_SLEEP_SMP -extern int freeze_secondary_cpus (int primary); +int __freeze_secondary_cpus (int primary,bool suspend); +static inline int freeze_secondary_cpus (int primary) +{ +return __freeze_secondary_cpus (primary, true); +} +static inline int disable_nonboot_cpus (void ) { -return freeze_secondary_cpus (0 ); +return __freeze_secondary_cpus (0 , false); } -extern void enable_nonboot_cpus (void ); + +void enable_nonboot_cpus (void );static inline int suspend_disable_secondary_cpus (void ) {
kernel/cpu.c +2 -2
@@ -1212,7 +1212,7 @@ EXPORT_SYMBOL_GPL(cpu_up);#ifdef CONFIG_PM_SLEEP_SMP static cpumask_var_t frozen_cpus; -int freeze_secondary_cpus (int primary) +int __freeze_secondary_cpus (int primary,bool suspend) {int cpu, error =0 ;
@@ -1237,7 +1237,7 @@ int freeze_secondary_cpus(int primary)if (cpu == primary)continue ; -if (pm_wakeup_pending ()) { +if (suspend &&pm_wakeup_pending ()) {pr_info ("Wakeup pending. Abort CPU freeze\n" ); error = -EBUSY ;break ;
Greg Kroah-Hartman
maintainerPATCH 106/232 tpm: tpm1_bios_measurements_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit d7a47b96ed1102551eb7325f97937e276fb91045 upstream.
If .next function does not change position index, following .show function will repeat output related to current position index.
In case of /sys/kernel/security/tpm0/ascii_bios_measurements and binary_bios_measurements:
1) read after lseek beyound end of file generates whole last line.
2) read after lseek to middle of last line generates expected end of last line and unexpected whole last line once again.
--- drivers/char/tpm/eventlog/tpm1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/eventlog/tpm1.c +1 -1
@@ -115,6 +115,7 @@ static void *tpm1_bios_measurements_nextu32 converted_event_size;u32 converted_event_type; + (*pos)++; converted_event_size =do_endian_conversion (event->event_size); v +=sizeof (struct tcpa_event ) + converted_event_size;
@@ -132,7 +133,6 @@ static void *tpm1_bios_measurements_next ((v + sizeof(struct tcpa_event) + converted_event_size) > limit))return NULL ; - (*pos)++;return v; }
Greg Kroah-Hartman
maintainerPATCH 104/232 sched/fair: Fix enqueue_task_fair warning
In reply to Greg Kroah-HartmanFrom: Vincent Guittot <[email protected]>
commit fe61468b2cbc2b7ce5f8d3bf32ae5001d4c434e9 upstream.
When a cfs rq is throttled, the latter and its child are removed from the leaf list but their nr_running is not changed which includes staying higher than 1. When a task is enqueued in this throttled branch, the cfs rqs must be added back in order to ensure correct ordering in the list but this can only happens if nr_running == 1.
When cfs bandwidth is used, we call unconditionnaly list_add_leaf_cfs_rq() when enqueuing an entity to make sure that the complete branch will be added.
Similarly unthrottle_cfs_rq() can stop adding cfs in the list when a parent is throttled. Iterate the remaining entity to ensure that the complete branch will be added in the list.
--- kernel/sched/fair.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
kernel/sched/fair.c +22 -4
@@ -3927,6 +3927,7 @@ static inline void check_schedstat_requi#endif } +static inline bool cfs_bandwidth_used (void );/* * MIGRATION
@@ -4005,10 +4006,16 @@ enqueue_entity(struct cfs_rq *cfs_rq, st__enqueue_entity (cfs_rq, se); se->on_rq =1 ; -if (cfs_rq->nr_running ==1 ) { +/* +* When bandwidth control is enabled, cfs might have been removed +* because of a parent been throttled but cfs->nr_running > 1. Try to +* add it unconditionnally. +*/ +if (cfs_rq->nr_running ==1 ||cfs_bandwidth_used ())list_add_leaf_cfs_rq (cfs_rq); + +if (cfs_rq->nr_running ==1 )check_enqueue_throttle (cfs_rq); - } }static void __clear_buddies_last (struct sched_entity *se)
@@ -4589,11 +4596,22 @@ void unthrottle_cfs_rq(struct cfs_rq *cfbreak ; } -assert_list_leaf_cfs_rq (rq); -if (!se)add_nr_running (rq, task_delta); +/* +* The cfs_rq_throttled() breaks in the above iteration can result in +* incomplete leaf list maintenance, resulting in triggering the +* assertion below. +*/ +for_each_sched_entity (se) { + cfs_rq =cfs_rq_of (se); + +list_add_leaf_cfs_rq (cfs_rq); + } + +assert_list_leaf_cfs_rq (rq); +/* Determine whether we need to wake up potentially idle CPU: */ if (rq->curr == rq->idle && rq->cfs.nr_running)resched_curr (rq);
Greg Kroah-Hartman
maintainerPATCH 88/232 media: hantro: Read be32 words starting at every fourth byte
In reply to Greg Kroah-HartmanFrom: Andrzej Pietrasiewicz <[email protected]>
commit e34bca49e4953e5c2afc0425303199a5fd515f82 upstream.
Since (luma/chroma)_qtable is an array of unsigned char, indexing it returns consecutive byte locations, but we are supposed to read the arrays in four-byte words. Consequently, we should be pointing get_unaligned_be32() at consecutive word locations instead.
--- drivers/staging/media/hantro/hantro_h1_jpeg_enc.c | 9 +++++++-- drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/staging/media/hantro/hantro_h1_jpeg_enc.c +7 -2
@@ -67,12 +67,17 @@ hantro_h1_jpeg_enc_set_qtable(struct han unsigned char *chroma_qtable) {u32 reg, i; +__be32 *luma_qtable_p; +__be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable;for (i =0 ; i <H1_JPEG_QUANT_TABLE_COUNT ; i++) { - reg =get_unaligned_be32 (&luma_qtable[i]); + reg =get_unaligned_be32 (&luma_qtable_p[i]);vepu_write_relaxed (vpu, reg,H1_REG_JPEG_LUMA_QUAT (i)); - reg =get_unaligned_be32 (&chroma_qtable[i]); + reg =get_unaligned_be32 (&chroma_qtable_p[i]);vepu_write_relaxed (vpu, reg,H1_REG_JPEG_CHROMA_QUAT (i)); } }
drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c +7 -2
@@ -98,12 +98,17 @@ rk3399_vpu_jpeg_enc_set_qtable(struct ha unsigned char *chroma_qtable) {u32 reg, i; +__be32 *luma_qtable_p; +__be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable;for (i =0 ; i <VEPU_JPEG_QUANT_TABLE_COUNT ; i++) { - reg =get_unaligned_be32 (&luma_qtable[i]); + reg =get_unaligned_be32 (&luma_qtable_p[i]);vepu_write_relaxed (vpu, reg,VEPU_REG_JPEG_LUMA_QUAT (i)); - reg =get_unaligned_be32 (&chroma_qtable[i]); + reg =get_unaligned_be32 (&chroma_qtable_p[i]);vepu_write_relaxed (vpu, reg,VEPU_REG_JPEG_CHROMA_QUAT (i)); } }
Greg Kroah-Hartman
maintainerPATCH 97/232 nvme-fc: Revert "add module to ops template to allow module references"
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 8c5c660529209a0e324c1c1a35ce3f83d67a2aa5 upstream.
The original patch was to resolve the lldd being able to be unloaded while being used to talk to the boot device of the system. However, the end result of the original patch is that any driver unload while a nvme controller is live via the lldd is now being prohibited. Given the module reference, the module teardown routine can't be called, thus there's no way, other than manual actions to terminate the controllers.
--- drivers/nvme/host/fc.c | 14 ++------------ drivers/nvme/target/fcloop.c | 1 - drivers/scsi/lpfc/lpfc_nvme.c | 2 -- drivers/scsi/qla2xxx/qla_nvme.c | 1 - include/linux/nvme-fc-driver.h | 4 ---- 5 files changed, 2 insertions(+), 20 deletions(-)
drivers/nvme/host/fc.c +2 -12
@@ -342,8 +342,7 @@ nvme_fc_register_localport(struct nvme_f !template->ls_req || !template->fcp_io || !template->ls_abort || !template->fcp_abort || !template->max_hw_queues || !template->max_sgl_segments || - !template->max_dif_sgl_segments || !template->dma_boundary || - !template->module) { + !template->max_dif_sgl_segments || !template->dma_boundary) { ret = -EINVAL ; goto out_reghost_failed; }
@@ -2016,7 +2015,6 @@ nvme_fc_ctrl_free(struct kref *ref) {struct nvme_fc_ctrl *ctrl = container_of(ref, struct nvme_fc_ctrl, ref); -struct nvme_fc_lport *lport = ctrl->lport;unsigned long flags;if (ctrl->ctrl.tagset) {
@@ -2043,7 +2041,6 @@ nvme_fc_ctrl_free(struct kref *ref)if (ctrl->ctrl.opts)nvmf_free_options (ctrl->ctrl.opts);kfree (ctrl); -module_put (lport->ops->module); } static void
@@ -3071,15 +3068,10 @@ nvme_fc_init_ctrl(struct device *dev, st goto out_fail; } -if (!try_module_get (lport->ops->module)) { - ret = -EUNATCH ; - goto out_free_ctrl; - } - idx =ida_simple_get (&nvme_fc_ctrl_cnt,0 ,0 ,GFP_KERNEL );if (idx <0 ) { ret = -ENOSPC ; - goto out_mod_put; + goto out_free_ctrl; } ctrl->ctrl.opts = opts;
@@ -3232,8 +3224,6 @@ out_free_queues: out_free_ida:put_device (ctrl->dev);ida_simple_remove (&nvme_fc_ctrl_cnt, ctrl->cnum); -out_mod_put: -module_put (lport->ops->module); out_free_ctrl:kfree (ctrl); out_fail:
drivers/nvme/target/fcloop.c +0 -1
@@ -850,7 +850,6 @@ fcloop_targetport_delete(struct nvmet_fc#define FCLOOP_DMABOUND_4G 0xFFFFFFFFstatic struct nvme_fc_port_template fctemplate = { - .module =THIS_MODULE , .localport_delete = fcloop_localport_delete, .remoteport_delete = fcloop_remoteport_delete, .create_queue = fcloop_create_queue,
drivers/scsi/lpfc/lpfc_nvme.c +0 -2
@@ -1976,8 +1976,6 @@ out_unlock:/* Declare and initialization an instance of the FC NVME template. */ static struct nvme_fc_port_template lpfc_nvme_template = { - .module =THIS_MODULE , -/* initiator-based functions */ .localport_delete = lpfc_nvme_localport_delete, .remoteport_delete = lpfc_nvme_remoteport_delete,
drivers/scsi/qla2xxx/qla_nvme.c +0 -1
@@ -610,7 +610,6 @@ static void qla_nvme_remoteport_delete(s }static struct nvme_fc_port_template qla_nvme_fc_transport = { - .module =THIS_MODULE , .localport_delete = qla_nvme_localport_delete, .remoteport_delete = qla_nvme_remoteport_delete, .create_queue = qla_nvme_alloc_queue,
include/linux/nvme-fc-driver.h +0 -4
@@ -270,8 +270,6 @@ struct nvme_fc_remote_port {* * Host/Initiator Transport Entrypoints/Parameters: * -* @module: The LLDD module using the interface -* * @localport_delete: The LLDD initiates deletion of a localport via * nvme_fc_deregister_localport(). However, the teardown is * asynchronous. This routine is called upon the completion of the
@@ -385,8 +383,6 @@ struct nvme_fc_remote_port {* Value is Mandatory. Allowed to be zero. */ struct nvme_fc_port_template { -struct module *module; -/* initiator-based functions */ void (*localport_delete)(struct nvme_fc_local_port *);void (*remoteport_delete)(struct nvme_fc_remote_port *);
Greg Kroah-Hartman
maintainerPATCH 52/232 cpufreq: imx6q: fix error handling
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit 3646f50a3838c5949a89ecbdb868497cdc05b8fd ]
When speed checking failed, direclty jumping to put_node label is not correct. Need jump to out_free_opp to avoid resources leak.
--- drivers/cpufreq/imx6q-cpufreq.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +5 -4
@@ -381,23 +381,24 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_reg; } +/* Because we have added the OPPs here, we must free them */ + free_opp = true; +if (of_machine_is_compatible ("fsl,imx6ul" ) ||of_machine_is_compatible ("fsl,imx6ull" )) { ret =imx6ul_opp_check_speed_grading (cpu_dev);if (ret) {if (ret == -EPROBE_DEFER ) - goto put_node; + goto out_free_opp;dev_err (cpu_dev,"failed to read ocotp: %d\n" , ret); - goto put_node; + goto out_free_opp; } }else {imx6q_opp_check_speed_grading (cpu_dev); } -/* Because we have added the OPPs here, we must free them */ - free_opp = true; num =dev_pm_opp_get_opp_count (cpu_dev);if (num <0 ) { ret = num;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 48/232 libata: Remove extra scsi_host_put() in ata_scsi_add_hosts()
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit 1d72f7aec3595249dbb83291ccac041a2d676c57 ]
If the call to scsi_add_host_with_dma() in ata_scsi_add_hosts() fails, then we may get use-after-free KASAN warns:
==================================================================
BUG: KASAN: use-after-free in kobject_put+0x24/0x180 Read of size 1 at addr ffff0026b8c80364 by task swapper/0/1 CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 5.6.0-rc3-00004-g5a71b206ea82-dirty #1765 Hardware name: Huawei TaiShan 200 (Model 2280)/BC82AMDD, BIOS 2280-V2 CS V3.B160.01 02/24/2020 Call trace: dump_backtrace+0x0/0x298 show_stack+0x14/0x20 dump_stack+0x118/0x190 print_address_description.isra.9+0x6c/0x3b8 __kasan_report+0x134/0x23c kasan_report+0xc/0x18 __asan_load1+0x5c/0x68 kobject_put+0x24/0x180 put_device+0x10/0x20 scsi_host_put+0x10/0x18 ata_devres_release+0x74/0xb0 release_nodes+0x2d0/0x470 devres_release_all+0x50/0x78 really_probe+0x2d4/0x560 driver_probe_device+0x7c/0x148 device_driver_attach+0x94/0xa0 __driver_attach+0xa8/0x110 bus_for_each_dev+0xe8/0x158 driver_attach+0x30/0x40 bus_add_driver+0x220/0x2e0 driver_register+0xbc/0x1d0 __pci_register_driver+0xbc/0xd0 ahci_pci_driver_init+0x20/0x28 do_one_initcall+0xf0/0x608 kernel_init_freeable+0x31c/0x384 kernel_init+0x10/0x118 ret_from_fork+0x10/0x18 Allocated by task 5: save_stack+0x28/0xc8 __kasan_kmalloc.isra.8+0xbc/0xd8 kasan_kmalloc+0xc/0x18 __kmalloc+0x1a8/0x280 scsi_host_alloc+0x44/0x678 ata_scsi_add_hosts+0x74/0x268 ata_host_register+0x228/0x488 ahci_host_activate+0x1c4/0x2a8 ahci_init_one+0xd18/0x1298 local_pci_probe+0x74/0xf0 work_for_cpu_fn+0x2c/0x48 process_one_work+0x488/0xc08 worker_thread+0x330/0x5d0 kthread+0x1c8/0x1d0 ret_from_fork+0x10/0x18 Freed by task 5: save_stack+0x28/0xc8 __kasan_slab_free+0x118/0x180 kasan_slab_free+0x10/0x18 slab_free_freelist_hook+0xa4/0x1a0 kfree+0xd4/0x3a0 scsi_host_dev_release+0x100/0x148 device_release+0x7c/0xe0 kobject_put+0xb0/0x180 put_device+0x10/0x20 scsi_host_put+0x10/0x18 ata_scsi_add_hosts+0x210/0x268 ata_host_register+0x228/0x488 ahci_host_activate+0x1c4/0x2a8 ahci_init_one+0xd18/0x1298 local_pci_probe+0x74/0xf0 work_for_cpu_fn+0x2c/0x48 process_one_work+0x488/0xc08 worker_thread+0x330/0x5d0 kthread+0x1c8/0x1d0 ret_from_fork+0x10/0x18
There is also refcount issue, as well:
WARNING: CPU: 1 PID: 1 at lib/refcount.c:28 refcount_warn_saturate+0xf8/0x170
The issue is that we make an erroneous extra call to scsi_host_put() for that host:
So in ahci_init_one()->ata_host_alloc_pinfo()->ata_host_alloc(), we setup a device release method - ata_devres_release() - which intends to release the SCSI hosts:
static void ata_devres_release(struct device *gendev, void *res)
{
...
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
if (!ap)
continue;
if (ap->scsi_host)
scsi_host_put(ap->scsi_host);
}
...
}However in the ata_scsi_add_hosts() error path, we also call scsi_host_put() for the SCSI hosts.
Fix by removing the the scsi_host_put() calls in ata_scsi_add_hosts() and leave this to ata_devres_release().
--- drivers/ata/libata-scsi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/ata/libata-scsi.c +3 -6
@@ -4553,22 +4553,19 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)*/ shost->max_host_blocked =1 ; - rc =scsi_add_host_with_dma (ap->scsi_host, - &ap->tdev, ap->host->dev); + rc =scsi_add_host_with_dma (shost, &ap->tdev, ap->host->dev);if (rc) - goto err_add; + goto err_alloc; }return 0 ; - err_add: -scsi_host_put (host->ports[i]->scsi_host); err_alloc:while (--i >=0 ) {struct Scsi_Host *shost = host->ports[i]->scsi_host; +/* scsi_host_put() is in ata_devres_release() */ scsi_remove_host (shost); -scsi_host_put (shost); }return rc; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 49/232 pstore/platform: fix potential mem leak if pstore_init_fs failed
In reply to Greg Kroah-HartmanFrom: chenqiwu <[email protected]>
[ Upstream commit 8a57d6d4ddfa41c49014e20493152c41a38fcbf8 ]
There is a potential mem leak when pstore_init_fs failed, since the pstore compression maybe unlikey to initialized successfully. We must clean up the allocation once this unlikey issue happens.
--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/pstore/platform.c +2 -2
@@ -823,9 +823,9 @@ static int __init pstore_init(void) ret =pstore_init_fs ();if (ret) -return ret; +free_buf_for_compression (); -return 0 ; +return ret; }late_initcall (pstore_init);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 84/232 ALSA: hda/realtek - Remove now-unnecessary XPS 13 headphone noise fixups
In reply to Greg Kroah-HartmanFrom: Thomas Hebb <[email protected]>
commit f36938aa7440f46a0a365f1cfde5f5985af2bef3 upstream.
patch_realtek.c has historically failed to properly configure the PC Beep Hidden Register for the ALC256 codec (among others). Depending on your kernel version, symptoms of this misconfiguration can range from chassis noise, picked up by a poorly-shielded PCBEEP trace, getting amplified and played on your internal speaker and/or headphones to loud feedback, which responds to the "Headphone Mic Boost" ALSA control, getting played through your headphones. For details of the problem, see the patch in this series titled "ALSA: hda/realtek - Set principled PC Beep configuration for ALC256", which fixes the configuration.
These symptoms have been most noticed on the Dell XPS 13 9350 and 9360, popular laptops that use the ALC256. As a result, several model-specific fixups have been introduced to try and fix the problem, the most egregious of which locks the "Headphone Mic Boost" control as a hack to minimize noise from a feedback loop that shouldn't have been there in the first place.
Now that the underlying issue has been fixed, remove all these fixups. Remaining fixups needed by the XPS 13 are all picked up by existing pin quirks.
This change should, for the XPS 13 9350/9360
- Significantly increase volume and audio quality on headphones
- Eliminate headphone popping on suspend/resume
- Allow "Headphone Mic Boost" to be set again, making the headphone jack fully usable as a microphone jack too.
--- Documentation/sound/hd-audio/models.rst | 2 - sound/pci/hda/patch_realtek.c | 34 -------------------------------- 2 files changed, 36 deletions(-)
Documentation/sound/hd-audio/models.rst +0 -2
@@ -216,8 +216,6 @@ alc298-dell-aio ALC298 fixups on Dell AIO machines alc275-dell-xps ALC275 fixups on Dell XPS models -alc256-dell-xps13 - ALC256 fixups on Dell XPS13 lenovo-spk-noise Workaround for speaker noise on Lenovo machines lenovo-hotkey
sound/pci/hda/patch_realtek.c +0 -34
@@ -5491,17 +5491,6 @@ static void alc271_hp_gate_mic_jack(stru } } -static void alc256_fixup_dell_xps_13_headphone_noise2 (struct hda_codec *codec, -const struct hda_fixup *fix, -int action) -{ -if (action !=HDA_FIXUP_ACT_PRE_PROBE ) -return ; - -snd_hda_codec_amp_stereo (codec,0x1a ,HDA_INPUT ,0 ,HDA_AMP_VOLMASK ,1 ); -snd_hda_override_wcaps (codec,0x1a ,get_wcaps (codec,0x1a ) & ~AC_WCAP_IN_AMP ); -} -static void alc269_fixup_limit_int_mic_boost (struct hda_codec *codec,const struct hda_fixup *fix,int action)
@@ -5916,8 +5905,6 @@ enum {ALC298_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE ,ALC275_FIXUP_DELL_XPS , -ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE , -ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2 ,ALC293_FIXUP_LENOVO_SPK_NOISE ,ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY , ALC255_FIXUP_DELL_SPK_NOISE,
@@ -6658,23 +6645,6 @@ static const struct hda_fixup alc269_fix {} } }, - [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE] = { - .type = HDA_FIXUP_VERBS, - .v.verbs = (const struct hda_verb []) { -/* Disable pass-through path for FRONT 14h */ - {0x20 ,AC_VERB_SET_COEF_INDEX ,0x36 }, - {0x20 ,AC_VERB_SET_PROC_COEF ,0x1737 }, - {} - }, - .chained = true, - .chain_id =ALC255_FIXUP_DELL1_MIC_NO_PRESENCE - }, - [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc256_fixup_dell_xps_13_headphone_noise2, - .chained = true, - .chain_id =ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE - }, [ALC293_FIXUP_LENOVO_SPK_NOISE] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_disable_aamix,
@@ -7172,17 +7142,14 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1028 ,0x06de ,"Dell" ,ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK ),SND_PCI_QUIRK (0x1028 ,0x06df ,"Dell" ,ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK ),SND_PCI_QUIRK (0x1028 ,0x06e0 ,"Dell" ,ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK ), -SND_PCI_QUIRK (0x1028 ,0x0704 ,"Dell XPS 13 9350" ,ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2 ),SND_PCI_QUIRK (0x1028 ,0x0706 ,"Dell Inspiron 7559" ,ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER ),SND_PCI_QUIRK (0x1028 ,0x0725 ,"Dell Inspiron 3162" ,ALC255_FIXUP_DELL_SPK_NOISE ),SND_PCI_QUIRK (0x1028 ,0x0738 ,"Dell Precision 5820" ,ALC269_FIXUP_NO_SHUTUP ), -SND_PCI_QUIRK (0x1028 ,0x075b ,"Dell XPS 13 9360" ,ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2 ),SND_PCI_QUIRK (0x1028 ,0x075c ,"Dell XPS 27 7760" ,ALC298_FIXUP_SPK_VOLUME ),SND_PCI_QUIRK (0x1028 ,0x075d ,"Dell AIO" ,ALC298_FIXUP_SPK_VOLUME ),SND_PCI_QUIRK (0x1028 ,0x07b0 ,"Dell Precision 7520" ,ALC295_FIXUP_DISABLE_DAC3 ),SND_PCI_QUIRK (0x1028 ,0x0798 ,"Dell Inspiron 17 7000 Gaming" ,ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER ),SND_PCI_QUIRK (0x1028 ,0x080c ,"Dell WYSE" ,ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE ), -SND_PCI_QUIRK (0x1028 ,0x082a ,"Dell XPS 13 9360" ,ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE2 ),SND_PCI_QUIRK (0x1028 ,0x084b ,"Dell" ,ALC274_FIXUP_DELL_AIO_LINEOUT_VERB ),SND_PCI_QUIRK (0x1028 ,0x084e ,"Dell" ,ALC274_FIXUP_DELL_AIO_LINEOUT_VERB ), SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
@@ -7536,7 +7503,6 @@ static const struct hda_model_fixup alc2 {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"}, {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"}, {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"}, - {.id = ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE, .name = "alc256-dell-xps13"}, {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"}, {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"}, {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
Greg Kroah-Hartman
maintainerPATCH 79/232 ALSA: pcm: oss: Fix regression by buffer overflow fix
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit ae769d3556644888c964635179ef192995f40793 upstream.
The recent fix for the OOB access in PCM OSS plugins (commitf2ecf903ef06: "ALSA: pcm: oss: Avoid plugin buffer overflow") caused a regression on OSS applications. The patch introduced the size check in client and slave size calculations to limit to each plugin's buffer size, but I overlooked that some code paths call those without allocating the buffer but just for estimation.
This patch fixes the bug by skipping the size check for those code paths while keeping checking in the actual transfer calls.
--- sound/core/oss/pcm_plugin.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
sound/core/oss/pcm_plugin.c +24 -8
@@ -196,7 +196,9 @@ int snd_pcm_plugin_free(struct snd_pcm_preturn 0 ; } -snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *plug,snd_pcm_uframes_t drv_frames) +static snd_pcm_sframes_t plug_client_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t drv_frames, +bool check_size) {struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;int stream;
@@ -209,7 +211,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_siif (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { plugin =snd_pcm_plug_last (plug);while (plugin && drv_frames >0 ) { -if (drv_frames > plugin->buf_frames) +if (check_size && drv_frames > plugin->buf_frames) drv_frames = plugin->buf_frames; plugin_prev = plugin->prev;if (plugin->src_frames)
@@ -222,7 +224,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_si plugin_next = plugin->next;if (plugin->dst_frames) drv_frames = plugin->dst_frames (plugin, drv_frames); -if (drv_frames > plugin->buf_frames) +if (check_size && drv_frames > plugin->buf_frames) drv_frames = plugin->buf_frames; plugin = plugin_next; }
@@ -231,7 +233,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_sireturn drv_frames; } -snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *plug,snd_pcm_uframes_t clt_frames) +static snd_pcm_sframes_t plug_slave_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t clt_frames, +bool check_size) {struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;snd_pcm_sframes_t frames;
@@ -252,14 +256,14 @@ snd_pcm_sframes_t snd_pcm_plug_slave_sizif (frames <0 )return frames; } -if (frames > plugin->buf_frames) +if (check_size && frames > plugin->buf_frames) frames = plugin->buf_frames; plugin = plugin_next; } }else if (stream ==SNDRV_PCM_STREAM_CAPTURE ) { plugin =snd_pcm_plug_last (plug);while (plugin) { -if (frames > plugin->buf_frames) +if (check_size && frames > plugin->buf_frames) frames = plugin->buf_frames; plugin_prev = plugin->prev;if (plugin->src_frames) {
@@ -274,6 +278,18 @@ snd_pcm_sframes_t snd_pcm_plug_slave_sizreturn frames; } +snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t drv_frames) +{ +return plug_client_size (plug, drv_frames, false); +} + +snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t clt_frames) +{ +return plug_slave_size (plug, clt_frames, false); +} +static int snd_pcm_plug_formats (const struct snd_mask *mask,snd_pcm_format_t format) {
@@ -630,7 +646,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_tra src_channels = dst_channels; plugin = next; } -return snd_pcm_plug_client_size (plug, frames); +return plug_client_size (plug, frames, true); }snd_pcm_sframes_t snd_pcm_plug_read_transfer (struct snd_pcm_substream *plug,struct snd_pcm_plugin_channel *dst_channels_final,snd_pcm_uframes_t size)
@@ -640,7 +656,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transnd_pcm_sframes_t frames = size;int err; - frames =snd_pcm_plug_slave_size (plug, frames); + frames =plug_slave_size (plug, frames, true);if (frames <0 )return frames;
Greg Kroah-Hartman
maintainerPATCH 80/232 ALSA: hda/realtek: Enable mute LED on an HP system
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit f5a88b0accc24c4a9021247d7a3124f90aa4c586 upstream.
The system in question uses ALC285, and it uses GPIO 0x04 to control its mute LED.
The mic mute LED can be controlled by GPIO 0x01, however the system uses DMIC so we should use that to control mic mute LED.
--- sound/pci/hda/patch_realtek.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/pci/hda/patch_realtek.c +12 -0
@@ -4008,6 +4008,12 @@ static void alc269_fixup_hp_gpio_led(stralc_fixup_hp_gpio_led (codec, action,0x08 ,0x10 ); } +static void alc285_fixup_hp_gpio_led (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +alc_fixup_hp_gpio_led (codec, action,0x04 ,0x00 ); +} +static void alc286_fixup_hp_gpio_led (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
@@ -5923,6 +5929,7 @@ enum {ALC294_FIXUP_ASUS_DUAL_SPK ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ,ALC294_FIXUP_ASUS_HPE , + ALC285_FIXUP_HP_GPIO_LED, }; static const struct hda_fixup alc269_fixups[] = {
@@ -7061,6 +7068,10 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC294_FIXUP_ASUS_HEADSET_MIC }, + [ALC285_FIXUP_HP_GPIO_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc285_fixup_hp_gpio_led, + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7208,6 +7219,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x83b9 ,"HP Spectre x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x8497 ,"HP Envy x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x84e7 ,"HP Pavilion 15" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ), +SND_PCI_QUIRK (0x103c ,0x8736 ,"HP" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Greg Kroah-Hartman
maintainerPATCH 81/232 ALSA: hda/realtek - a fake key event is triggered by running shutup
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 476c02e0b4fd9071d158f6a1a1dfea1d36ee0ffd upstream.
On the Lenovo X1C7 machines, after we plug the headset, the rt_resume() and rt_suspend() of the codec driver will be called periodically, the driver can't stay in the rt_suspend state even users doen't use the sound card.
Through debugging, I found when running rt_suspend(), it will call alc225_shutup(), in this function, it will change 3k pull down control by alc_update_coef_idx(codec, 0x4a, 0, 3 << 10), this will trigger a fake key event and that event will resume the codec, when codec suspend agin, it will trigger the fake key event one more time, this process will repeat.
If disable the key event before changing the pull down control, it will not trigger fake key event. It also needs to restore the pull down control and re-enable the key event, otherwise the system can't get key event when codec is in rt_suspend state.
Also move some functions ahead of alc225_shutup(), this can save the function declaration.
--- sound/pci/hda/patch_realtek.c | 170 ++++++++++++++++++++++++++---------------- 1 file changed, 107 insertions(+), 63 deletions(-)
sound/pci/hda/patch_realtek.c +107 -63
@@ -107,6 +107,7 @@ struct alc_spec { unsigned int done_hp_init:1; unsigned int no_shutup_pins:1; unsigned int ultra_low_power:1; + unsigned int has_hs_key:1;/* for PLL fix */ hda_nid_t pll_nid;
@@ -2982,6 +2983,107 @@ static int alc269_parse_auto_config(strureturn alc_parse_auto_config (codec, alc269_ignore, ssids); } +static const struct hda_jack_keymap alc_headset_btn_keymap[] = { + {SND_JACK_BTN_0 ,KEY_PLAYPAUSE }, + {SND_JACK_BTN_1 ,KEY_VOICECOMMAND }, + {SND_JACK_BTN_2 ,KEY_VOLUMEUP }, + {SND_JACK_BTN_3 ,KEY_VOLUMEDOWN }, + {} +}; + +static void alc_headset_btn_callback (struct hda_codec *codec, +struct hda_jack_callback *jack) +{ +int report =0 ; + +if (jack->unsol_res & (7 <<13 )) + report |=SND_JACK_BTN_0 ; + +if (jack->unsol_res & (1 <<16 |3 <<8 )) + report |=SND_JACK_BTN_1 ; + +/* Volume up key */ +if (jack->unsol_res & (7 <<23 )) + report |=SND_JACK_BTN_2 ; + +/* Volume down key */ +if (jack->unsol_res & (7 <<10 )) + report |=SND_JACK_BTN_3 ; + + jack->jack->button_state = report; +} + +static void alc_disable_headset_jack_key (struct hda_codec *codec) +{ +struct alc_spec *spec = codec->spec; + +if (!spec->has_hs_key) +return ; + +switch (codec->core.vendor_id) { +case 0x10ec0215 : +case 0x10ec0225 : +case 0x10ec0285 : +case 0x10ec0295 : +case 0x10ec0289 : +case 0x10ec0299 : +alc_write_coef_idx (codec,0x48 ,0x0 ); +alc_update_coef_idx (codec,0x49 ,0x0045 ,0x0 ); +alc_update_coef_idx (codec,0x44 ,0x0045 <<8 ,0x0 ); +break ; +case 0x10ec0236 : +case 0x10ec0256 : +alc_write_coef_idx (codec,0x48 ,0x0 ); +alc_update_coef_idx (codec,0x49 ,0x0045 ,0x0 ); +break ; + } +} + +static void alc_enable_headset_jack_key (struct hda_codec *codec) +{ +struct alc_spec *spec = codec->spec; + +if (!spec->has_hs_key) +return ; + +switch (codec->core.vendor_id) { +case 0x10ec0215 : +case 0x10ec0225 : +case 0x10ec0285 : +case 0x10ec0295 : +case 0x10ec0289 : +case 0x10ec0299 : +alc_write_coef_idx (codec,0x48 ,0xd011 ); +alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); +alc_update_coef_idx (codec,0x44 ,0x007f <<8 ,0x0045 <<8 ); +break ; +case 0x10ec0236 : +case 0x10ec0256 : +alc_write_coef_idx (codec,0x48 ,0xd011 ); +alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); +break ; + } +} + +static void alc_fixup_headset_jack (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + spec->has_hs_key =1 ; +snd_hda_jack_detect_enable_callback (codec,0x55 , + alc_headset_btn_callback); +snd_hda_jack_add_kctl (codec,0x55 ,"Headset Jack" , false, +SND_JACK_HEADSET , alc_headset_btn_keymap); +break ; +case HDA_FIXUP_ACT_INIT : +alc_enable_headset_jack_key (codec); +break ; + } +} +static void alc269vb_toggle_power_output (struct hda_codec *codec,int power_up) {alc_update_coef_idx (codec,0x04 ,1 <<11 , power_up ? (1 <<11 ) :0 );
@@ -3372,6 +3474,8 @@ static void alc225_shutup(struct hda_codif (!hp_pin) hp_pin =0x21 ; + +alc_disable_headset_jack_key (codec);/* 3k pull low control for Headset jack. */ alc_update_coef_idx (codec,0x4a ,0 ,3 <<10 );
@@ -3411,6 +3515,9 @@ static void alc225_shutup(struct hda_codalc_update_coef_idx (codec,0x4a ,3 <<4 ,2 <<4 );msleep (30 ); } + +alc_update_coef_idx (codec,0x4a ,3 <<10 ,0 ); +alc_enable_headset_jack_key (codec); }static void alc_default_init (struct hda_codec *codec)
@@ -5668,69 +5775,6 @@ static void alc285_fixup_invalidate_dacssnd_hda_override_wcaps (codec,0x03 ,0 ); } -static const struct hda_jack_keymap alc_headset_btn_keymap[] = { - {SND_JACK_BTN_0 ,KEY_PLAYPAUSE }, - {SND_JACK_BTN_1 ,KEY_VOICECOMMAND }, - {SND_JACK_BTN_2 ,KEY_VOLUMEUP }, - {SND_JACK_BTN_3 ,KEY_VOLUMEDOWN }, - {} -}; - -static void alc_headset_btn_callback (struct hda_codec *codec, -struct hda_jack_callback *jack) -{ -int report =0 ; - -if (jack->unsol_res & (7 <<13 )) - report |=SND_JACK_BTN_0 ; - -if (jack->unsol_res & (1 <<16 |3 <<8 )) - report |=SND_JACK_BTN_1 ; - -/* Volume up key */ -if (jack->unsol_res & (7 <<23 )) - report |=SND_JACK_BTN_2 ; - -/* Volume down key */ -if (jack->unsol_res & (7 <<10 )) - report |=SND_JACK_BTN_3 ; - - jack->jack->button_state = report; -} - -static void alc_fixup_headset_jack (struct hda_codec *codec, -const struct hda_fixup *fix,int action) -{ - -switch (action) { -case HDA_FIXUP_ACT_PRE_PROBE : -snd_hda_jack_detect_enable_callback (codec,0x55 , - alc_headset_btn_callback); -snd_hda_jack_add_kctl (codec,0x55 ,"Headset Jack" , false, -SND_JACK_HEADSET , alc_headset_btn_keymap); -break ; -case HDA_FIXUP_ACT_INIT : -switch (codec->core.vendor_id) { -case 0x10ec0215 : -case 0x10ec0225 : -case 0x10ec0285 : -case 0x10ec0295 : -case 0x10ec0289 : -case 0x10ec0299 : -alc_write_coef_idx (codec,0x48 ,0xd011 ); -alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); -alc_update_coef_idx (codec,0x44 ,0x007f <<8 ,0x0045 <<8 ); -break ; -case 0x10ec0236 : -case 0x10ec0256 : -alc_write_coef_idx (codec,0x48 ,0xd011 ); -alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); -break ; - } -break ; - } -} -static void alc295_fixup_chromebook (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
Greg Kroah-Hartman
maintainerPATCH 77/232 ALSA: hda: Fix potential access overflow in beep helper
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 0ad3f0b384d58f3bd1f4fb87d0af5b8f6866f41a upstream.
The beep control helper function blindly stores the values in two stereo channels no matter whether the actual control is mono or stereo. This is practically harmless, but it annoys the recently introduced sanity check, resulting in an error when the checker is enabled.
This patch corrects the behavior to store only on the defined array member.
--- sound/pci/hda/hda_beep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_beep.c +5 -1
@@ -290,8 +290,12 @@ int snd_hda_mixer_amp_switch_get_beep(st {struct hda_codec *codec =snd_kcontrol_chip (kcontrol);struct hda_beep *beep = codec->beep; +int chs =get_amp_channels (kcontrol); +if (beep && (!beep->enabled || !ctl_has_mute (kcontrol))) { - ucontrol->value.integer.value[0 ] = +if (chs &1 ) + ucontrol->value.integer.value[0 ] = beep->enabled; +if (chs &2 ) ucontrol->value.integer.value[1 ] = beep->enabled;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 46/232 block, bfq: move forward the getting of an extra ref in bfq_bfqq_move
In reply to Greg Kroah-HartmanFrom: Paolo Valente <[email protected]>
[ Upstream commit fd1bb3ae54a9a2e0c42709de861c69aa146b8955 ]
Commit ecedd3d7e199 ("block, bfq: get extra ref to prevent a queue from being freed during a group move") gets an extra reference to a bfq_queue before possibly deactivating it (temporarily), in bfq_bfqq_move(). This prevents the bfq_queue from disappearing before being reactivated in its new group.
Yet, the bfq_queue may also be expired (i.e., its service may be stopped) before the bfq_queue is deactivated. And also an expiration may lead to a premature freeing. This commit fixes this issue by simply moving forward the getting of the extra reference already introduced by commit ecedd3d7e199 ("block, bfq: get extra ref to prevent a queue from being freed during a group move").
--- block/bfq-cgroup.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
block/bfq-cgroup.c +7 -7
@@ -625,6 +625,12 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, {struct bfq_entity *entity = &bfqq->entity; +/* +* Get extra reference to prevent bfqq from being freed in +* next possible expire or deactivate. +*/ + bfqq->ref++; +/* If bfqq is empty, then bfq_bfqq_expire also invokes * bfq_del_bfqq_busy, thereby removing bfqq and its entity * from data structures related to current group. Otherwise we
@@ -635,12 +641,6 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,bfq_bfqq_expire (bfqd, bfqd->in_service_queue, false,BFQQE_PREEMPTED ); -/* -* get extra reference to prevent bfqq from being freed in -* next possible deactivate -*/ - bfqq->ref++; -if (bfq_bfqq_busy (bfqq))bfq_deactivate_bfqq (bfqd, bfqq, false, false);else if (entity->on_st)
@@ -660,7 +660,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,if (!bfqd->in_service_queue && !bfqd->rq_in_driver)bfq_schedule_dispatch (bfqd); -/* release extra ref taken above */ +/* release extra ref taken above, bfqq may happen to be freed now */ bfq_put_queue (bfqq); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 75/232 ALSA: usb-audio: Add mixer workaround for TRX40 and co
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 2a48218f8e23d47bd3e23cfdfb8aa9066f7dc3e6 upstream.
Some recent boards (supposedly with a new AMD platform) contain the USB audio class 2 device that is often tied with HD-audio. The device exposes an Input Gain Pad control (id=19, control=12) but this node doesn't behave correctly, returning an error for each inquiry of GET_MIN and GET_MAX that should have been mandatory.
As a workaround, simply ignore this node by adding a usbmix_name_map table entry. The currently known devices are:
* 0414:a002 - Gigabyte TRX40 Aorus Pro WiFi
* 0b05:1916 - ASUS ROG Zenith II
* 0b05:1917 - ASUS ROG Strix
* 0db0:0d64 - MSI TRX40 Creator
* 0db0:543d - MSI TRX40
--- sound/usb/mixer_maps.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
sound/usb/mixer_maps.c +28 -0
@@ -349,6 +349,14 @@ static const struct usbmix_name_map dell { 0 } }; +/* Some mobos shipped with a dummy HD-audio show the invalid GET_MIN/GET_MAX +* response for Input Gain Pad (id=19, control=12). Skip it. +*/ +static const struct usbmix_name_map asus_rog_map[] = { + {19 ,NULL ,12 },/* FU, Input Gain Pad */ + {} +}; +/* * Control map entries */
@@ -468,6 +476,26 @@ static struct usbmix_ctl_map usbmix_ctl_ .id = USB_ID(0x05a7, 0x1020), .map = bose_companion5_map, }, + { /* Gigabyte TRX40 Aorus Pro WiFi */ + .id = USB_ID(0x0414, 0xa002), + .map = asus_rog_map, + }, + { /* ASUS ROG Zenith II */ + .id = USB_ID(0x0b05, 0x1916), + .map = asus_rog_map, + }, + { /* ASUS ROG Strix */ + .id = USB_ID(0x0b05, 0x1917), + .map = asus_rog_map, + }, + { /* MSI TRX40 Creator */ + .id = USB_ID(0x0db0, 0x0d64), + .map = asus_rog_map, + }, + { /* MSI TRX40 */ + .id = USB_ID(0x0db0, 0x543d), + .map = asus_rog_map, + }, { 0 } /* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 72/232 ASoC: topology: use name_prefix for new kcontrol
In reply to Greg Kroah-HartmanFrom: 이경택 <[email protected]>
commit abca9e4a04fbe9c6df4d48ca7517e1611812af25 upstream.
Current topology doesn't add prefix of component to new kcontrol.
--- sound/soc/soc-topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-topology.c +1 -1
@@ -362,7 +362,7 @@ static int soc_tplg_add_kcontrol(structstruct snd_soc_component *comp = tplg->comp;return soc_tplg_add_dcontrol (comp->card->snd_card, - comp->dev, k,NULL , comp, kcontrol); + comp->dev, k, comp->name_prefix, comp, kcontrol); }/* remove a mixer kcontrol */
Greg Kroah-Hartman
maintainerPATCH 65/232 btrfs: qgroup: ensure qgroup_rescan_running is only set when the worker is at least queued
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit d61acbbf54c612ea9bf67eed609494cda0857b3a ]
[BUG]
There are some reports about btrfs wait forever to unmount itself, with the following call trace:
INFO: task umount:4631 blocked for more than 491 seconds.
Tainted: G X 5.3.8-2-default #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
umount D 0 4631 3337 0x00000000
Call Trace:
([<00000000174adf7a>] __schedule+0x342/0x748)
[<00000000174ae3ca>] schedule+0x4a/0xd8
[<00000000174b1f08>] schedule_timeout+0x218/0x420
[<00000000174af10c>] wait_for_common+0x104/0x1d8
[<000003ff804d6994>] btrfs_qgroup_wait_for_completion+0x84/0xb0 [btrfs]
[<000003ff8044a616>] close_ctree+0x4e/0x380 [btrfs]
[<0000000016fa3136>] generic_shutdown_super+0x8e/0x158
[<0000000016fa34d6>] kill_anon_super+0x26/0x40
[<000003ff8041ba88>] btrfs_kill_super+0x28/0xc8 [btrfs]
[<0000000016fa39f8>] deactivate_locked_super+0x68/0x98
[<0000000016fcb198>] cleanup_mnt+0xc0/0x140
[<0000000016d6a846>] task_work_run+0xc6/0x110
[<0000000016d04f76>] do_notify_resume+0xae/0xb8
[<00000000174b30ae>] system_call+0xe2/0x2c8[CAUSE]
The problem happens when we have called qgroup_rescan_init(), but not queued the worker. It can be caused mostly by error handling.
Qgroup ioctl thread | Unmount thread
----------------------------------------+-----------------------------------
| btrfs_qgroup_rescan() | |- qgroup_rescan_init() | | |- qgroup_rescan_running = true; | | | |- trans = btrfs_join_transaction() | | Some error happened | | | |- btrfs_qgroup_rescan() returns error | But qgroup_rescan_running == true; | | close_ctree() | |- btrfs_qgroup_wait_for_completion() | |- running == true; | |- wait_for_completion();
btrfs_qgroup_rescan_worker is never queued, thus no one is going to wake up close_ctree() and we get a deadlock.
All involved qgroup_rescan_init() callers are:
- btrfs_qgroup_rescan()
The example above. It's possible to trigger the deadlock when error happened.
- btrfs_quota_enable()
Not possible. Just after qgroup_rescan_init() we queue the work.
- btrfs_read_qgroup_config()
It's possible to trigger the deadlock. It only init the work, the work queueing happens in btrfs_qgroup_rescan_resume(). Thus if error happened in between, deadlock is possible.
We shouldn't set fs_info->qgroup_rescan_running just in qgroup_rescan_init(), as at that stage we haven't yet queued qgroup rescan worker to run.
[FIX]
Set qgroup_rescan_running before queueing the work, so that we ensure the rescan work is queued when we wait for it.
--- fs/btrfs/qgroup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +9 -2
@@ -1030,6 +1030,7 @@ out_add_root: ret =qgroup_rescan_init (fs_info,0 ,1 );if (!ret) {qgroup_rescan_zero_tracking (fs_info); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); }
@@ -3276,7 +3277,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, sizeof(fs_info->qgroup_rescan_progress)); fs_info->qgroup_rescan_progress.objectid = progress_objectid;init_completion (&fs_info->qgroup_rescan_completion); - fs_info->qgroup_rescan_running = true;spin_unlock (&fs_info->qgroup_lock);mutex_unlock (&fs_info->qgroup_rescan_lock);
@@ -3341,8 +3341,11 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info)qgroup_rescan_zero_tracking (fs_info); +mutex_lock (&fs_info->qgroup_rescan_lock); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); +mutex_unlock (&fs_info->qgroup_rescan_lock);return 0 ; }
@@ -3378,9 +3381,13 @@ int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,void btrfs_qgroup_rescan_resume (struct btrfs_fs_info *fs_info) { -if (fs_info->qgroup_flags &BTRFS_QGROUP_STATUS_FLAG_RESCAN ) +if (fs_info->qgroup_flags &BTRFS_QGROUP_STATUS_FLAG_RESCAN ) { +mutex_lock (&fs_info->qgroup_rescan_lock); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); +mutex_unlock (&fs_info->qgroup_rescan_lock); + } }/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 68/232 btrfs: track reloc roots based on their commit root bytenr
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit ea287ab157c2816bf12aad4cece41372f9d146b4 ]
We always search the commit root of the extent tree for looking up back references, however we track the reloc roots based on their current bytenr.
This is wrong, if we commit the transaction between relocating tree blocks we could end up in this code in build_backref_tree
if (key.objectid == key.offset) {
/*
* Only root blocks of reloc trees use backref
* pointing to itself.
*/
root = find_reloc_root(rc, cur->bytenr);
ASSERT(root);
cur->root = root;
break;}
find_reloc_root() is looking based on the bytenr we had in the commit root, but if we've COWed this reloc root we will not find that bytenr, and we will trip over the ASSERT(root).
Fix this by using the commit_root->start bytenr for indexing the commit root. Then we change the __update_reloc_root() caller to be used when we switch the commit root for the reloc root during commit.
This fixes the panic I was seeing when we started throttling relocation for delayed refs.
--- fs/btrfs/relocation.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
fs/btrfs/relocation.c +7 -10
@@ -1298,7 +1298,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)if (!node)return -ENOMEM ; - node->bytenr = root->node->start; + node->bytenr = root->commit_root->start; node->data = root;spin_lock (&rc->reloc_root_tree.lock);
@@ -1329,10 +1329,11 @@ static void __del_reloc_root(struct btrfs_root *root)if (rc && root->node) {spin_lock (&rc->reloc_root_tree.lock); rb_node =tree_search (&rc->reloc_root_tree.rb_root, - root->node->start); + root->commit_root->start);if (rb_node) { node = rb_entry(rb_node, struct mapping_node, rb_node);rb_erase (&node->rb_node, &rc->reloc_root_tree.rb_root); +RB_CLEAR_NODE (&node->rb_node); }spin_unlock (&rc->reloc_root_tree.lock);if (!node)
@@ -1350,7 +1351,7 @@ static void __del_reloc_root(struct btrfs_root *root)* helper to update the 'address of tree root -> reloc tree' * mapping */ -static int __update_reloc_root (struct btrfs_root *root,u64 new_bytenr) +static int __update_reloc_root (struct btrfs_root *root) {struct btrfs_fs_info *fs_info = root->fs_info;struct rb_node *rb_node;
@@ -1359,7 +1360,7 @@ static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)spin_lock (&rc->reloc_root_tree.lock); rb_node =tree_search (&rc->reloc_root_tree.rb_root, - root->node->start); + root->commit_root->start);if (rb_node) { node = rb_entry(rb_node, struct mapping_node, rb_node);rb_erase (&node->rb_node, &rc->reloc_root_tree.rb_root);
@@ -1371,7 +1372,7 @@ static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)BUG_ON ((struct btrfs_root *)node->data != root);spin_lock (&rc->reloc_root_tree.lock); - node->bytenr = new_bytenr; + node->bytenr = root->node->start; rb_node =tree_insert (&rc->reloc_root_tree.rb_root, node->bytenr, &node->rb_node);spin_unlock (&rc->reloc_root_tree.lock);
@@ -1529,6 +1530,7 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, }if (reloc_root->commit_root != reloc_root->node) { +__update_reloc_root (reloc_root);btrfs_set_root_node (root_item, reloc_root->node);free_extent_buffer (reloc_root->commit_root); reloc_root->commit_root =btrfs_root_node (reloc_root);
@@ -4718,11 +4720,6 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,BUG_ON (rc->stage ==UPDATE_DATA_PTRS && root->root_key.objectid ==BTRFS_DATA_RELOC_TREE_OBJECTID ); -if (root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) { -if (buf == root->node) -__update_reloc_root (root, cow->start); - } - level =btrfs_header_level (buf);if (btrfs_header_generation (buf) <=btrfs_root_last_snapshot (&root->root_item))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 45/232 PCI/switchtec: Fix init_completion race condition with poll_wait()
In reply to Greg Kroah-HartmanFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit efbdc769601f4d50018bf7ca50fc9f7c67392ece ]
The call to init_completion() in mrpc_queue_cmd() can theoretically race with the call to poll_wait() in switchtec_dev_poll().
poll() write()
switchtec_dev_poll() switchtec_dev_write()
poll_wait(&s->comp.wait); mrpc_queue_cmd()
init_completion(&s->comp)
init_waitqueue_head(&s->comp.wait)To my knowledge, no one has hit this bug.
Fix this by using reinit_completion() instead of init_completion() in mrpc_queue_cmd().
--- drivers/pci/switch/switchtec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/switch/switchtec.c +1 -1
@@ -175,7 +175,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)kref_get (&stuser->kref); stuser->read_len =sizeof (stuser->data);stuser_set_state (stuser,MRPC_QUEUED ); -init_completion (&stuser->comp); +reinit_completion (&stuser->comp);list_add_tail (&stuser->list, &stdev->mrpc_queue);mrpc_cmd_submit (stdev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 61/232 firmware: fix a double abort case with fw_load_sysfs_fallback
In reply to Greg Kroah-HartmanFrom: Junyong Sun <[email protected]>
[ Upstream commit bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 ]
fw_sysfs_wait_timeout may return err with -ENOENT at fw_load_sysfs_fallback and firmware is already in abort status, no need to abort again, so skip it.
This issue is caused by concurrent situation like below:
when thread 1# wait firmware loading, thread 2# may write -1 to abort loading and wakeup thread 1# before it timeout. so wait_for_completion_killable_timeout of thread 1# would return remaining time which is != 0 with fw_st->status FW_STATUS_ABORTED.And the results would be converted into err -ENOENT in __fw_state_wait_common and transfered to fw_load_sysfs_fallback in thread 1#.
The -ENOENT means firmware status is already at ABORTED, so fw_load_sysfs_fallback no need to get mutex to abort again.
-----------------------------
thread 1#,wait for loadingfw_load_sysfs_fallback
->fw_sysfs_wait_timeout
->__fw_state_wait_common
->wait_for_completion_killable_timeoutin __fw_state_wait_common,
...
93 ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout);
94 if (ret != 0 && fw_st->status == FW_STATUS_ABORTED)
95 return -ENOENT;
96 if (!ret)
97 return -ETIMEDOUT;
98
99 return ret < 0 ? ret : 0;
-----------------------------
thread 2#, write -1 to abort loadingfirmware_loading_store
->fw_load_abort
->__fw_load_abort
->fw_state_aborted
->__fw_state_set
->complete_allin __fw_state_set,
...
111 if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED)
112 complete_all(&fw_st->completion);
-------------------------------------------
BTW,the double abort issue would not cause kernel panic or create an issue, but slow down it sometimes.The change is just a minor optimization.
--- drivers/base/firmware_loader/fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/firmware_loader/fallback.c +1 -1
@@ -525,7 +525,7 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, } retval =fw_sysfs_wait_timeout (fw_priv, timeout); -if (retval <0 ) { +if (retval <0 && retval != -ENOENT ) {mutex_lock (&fw_lock);fw_load_abort (fw_sysfs);mutex_unlock (&fw_lock);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 62/232 spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 4f5ee75ea1718a09149460b3df993f389a67b56a ]
Currently the driver puts the process in interruptible sleep waiting for the interrupt train to finish transfer to/from the tx_buf and rx_buf.
But exiting the process with ctrl-c may make the kernel panic: the wait_event_interruptible call will return -ERESTARTSYS, which a proper driver implementation is perhaps supposed to handle, but nonetheless this one doesn't, and aborts the transfer altogether.
Actually when the task is interrupted, there is still a high chance that the dspi_interrupt is still triggering. And if dspi_transfer_one_message returns execution all the way to the spi_device driver, that can free the spi_message and spi_transfer structures, leaving the interrupts to access a freed tx_buf and rx_buf.
hexdump -C /dev/mtd0
00000000 00 75 68 75 0a ff ff ff ff ff ff ff ff ff ff ff
|.uhu............| 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * ^C[ 38.495955] fsl-dspi 2120000.spi: Waiting for transfer to complete failed! [ 38.503097] spi_master spi2: failed to transfer one message from queue [ 38.509729] Unable to handle kernel paging request at virtual address ffff800095ab3377 [ 38.517676] Mem abort info: [ 38.520474] ESR = 0x96000045 [ 38.523533] EC = 0x25: DABT (current EL), IL = 32 bits [ 38.528861] SET = 0, FnV = 0 [ 38.531921] EA = 0, S1PTW = 0 [ 38.535067] Data abort info: [ 38.537952] ISV = 0, ISS = 0x00000045 [ 38.541797] CM = 0, WnR = 1 [ 38.544771] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000082621000 [ 38.551494] [ffff800095ab3377] pgd=00000020fffff003, p4d=00000020fffff003, pud=0000000000000000 [ 38.560229] Internal error: Oops: 96000045 [#1] PREEMPT SMP [ 38.565819] Modules linked in: [ 38.568882] CPU: 0 PID: 2729 Comm: hexdump Not tainted 5.6.0-rc4-next-20200306-00052-gd8730cdc8a0b-dirty #193 [ 38.578834] Hardware name: Kontron SMARC-sAL28 (Single PHY) on SMARC Eval 2.0 carrier (DT) [ 38.587129] pstate: 20000085 (nzCv daIf -PAN -UAO) [ 38.591941] pc : ktime_get_real_ts64+0x3c/0x110 [ 38.596487] lr : spi_take_timestamp_pre+0x40/0x90 [ 38.601203] sp : ffff800010003d90 [ 38.604525] x29: ffff800010003d90 x28: ffff80001200e000 [ 38.609854] x27: ffff800011da9000 x26: ffff002079c40400 [ 38.615184] x25: ffff8000117fe018 x24: ffff800011daa1a0 [ 38.620513] x23: ffff800015ab3860 x22: ffff800095ab3377 [ 38.625841] x21: 000000000000146e x20: ffff8000120c3000 [ 38.631170] x19: ffff0020795f6e80 x18: ffff800011da9948 [ 38.636498] x17: 0000000000000000 x16: 0000000000000000 [ 38.641826] x15: ffff800095ab3377 x14: 0720072007200720 [ 38.647155] x13: 0720072007200765 x12: 0775076507750771 [ 38.652483] x11: 0720076d076f0772 x10: 0000000000000040 [ 38.657812] x9 : ffff8000108e2100 x8 : ffff800011dcabe8 [ 38.663139] x7 : 0000000000000000 x6 : ffff800015ab3a60 [ 38.668468] x5 : 0000000007200720 x4 : ffff800095ab3377 [ 38.673796] x3 : 0000000000000000 x2 : 0000000000000ab0 [ 38.679125] x1 : ffff800011daa000 x0 : 0000000000000026 [ 38.684454] Call trace: [ 38.686905] ktime_get_real_ts64+0x3c/0x110 [ 38.691100] spi_take_timestamp_pre+0x40/0x90 [ 38.695470] dspi_fifo_write+0x58/0x2c0 [ 38.699315] dspi_interrupt+0xbc/0xd0 [ 38.702987] __handle_irq_event_percpu+0x78/0x2c0 [ 38.707706] handle_irq_event_percpu+0x3c/0x90 [ 38.712161] handle_irq_event+0x4c/0xd0 [ 38.716008] handle_fasteoi_irq+0xbc/0x170 [ 38.720115] generic_handle_irq+0x2c/0x40 [ 38.724135] __handle_domain_irq+0x68/0xc0 [ 38.728243] gic_handle_irq+0xc8/0x160 [ 38.732000] el1_irq+0xb8/0x180 [ 38.735149] spi_nor_spimem_read_data+0xe0/0x140 [ 38.739779] spi_nor_read+0xc4/0x120 [ 38.743364] mtd_read_oob+0xa8/0xc0 [ 38.746860] mtd_read+0x4c/0x80 [ 38.750007] mtdchar_read+0x108/0x2a0 [ 38.753679] __vfs_read+0x20/0x50 [ 38.757002] vfs_read+0xa4/0x190 [ 38.760237] ksys_read+0x6c/0xf0 [ 38.763471] __arm64_sys_read+0x20/0x30 [ 38.767319] el0_svc_common.constprop.3+0x90/0x160 [ 38.772125] do_el0_svc+0x28/0x90 [ 38.775449] el0_sync_handler+0x118/0x190 [ 38.779468] el0_sync+0x140/0x180 [ 38.782793] Code: 91000294 1400000f d50339bf f9405e80 (f90002c0) [ 38.788910] ---[ end trace 55da560db4d6bef7 ]--- [ 38.793540] Kernel panic - not syncing: Fatal exception in interrupt [ 38.799914] SMP: stopping secondary CPUs [ 38.803849] Kernel Offset: disabled [ 38.807344] CPU features: 0x10002,20006008 [ 38.811451] Memory Limit: none [ 38.814513] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
So it is clear that the "interruptible" part isn't handled correctly. When the process receives a signal, one could either attempt a clean abort (which appears to be difficult with this hardware) or just keep restarting the sleep until the wait queue really completes. But checking in a loop for -ERESTARTSYS is a bit too complicated for this driver, so just make the sleep uninterruptible, to avoid all that nonsense.
The wait queue was actually restructured as a completion, after polling other drivers for the most "popular" approach.
--- drivers/spi/spi-fsl-dspi.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/spi/spi-fsl-dspi.c +6 -13
@@ -192,8 +192,7 @@ struct fsl_dspi {u8 bytes_per_word;const struct fsl_dspi_devtype_data *devtype_data; -wait_queue_head_t waitq; -u32 waitflags; +struct completion xfer_done;struct fsl_dspi_dma *dma; };
@@ -703,10 +702,8 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)if (!(spi_sr & (SPI_SR_EOQF |SPI_SR_TCFQF )))return IRQ_NONE ; -if (dspi_rxtx (dspi) ==0 ) { - dspi->waitflags =1 ; -wake_up_interruptible (&dspi->waitq); - } +if (dspi_rxtx (dspi) ==0 ) +complete (&dspi->xfer_done);return IRQ_HANDLED ; }
@@ -800,13 +797,9 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, status =dspi_poll (dspi); }while (status == -EINPROGRESS ); }else if (trans_mode !=DSPI_DMA_MODE ) { - status =wait_event_interruptible (dspi->waitq, - dspi->waitflags); - dspi->waitflags =0 ; +wait_for_completion (&dspi->xfer_done); +reinit_completion (&dspi->xfer_done); } -if (status) -dev_err (&dspi->pdev->dev, -"Waiting for transfer to complete failed!\n" );if (transfer->delay_usecs)udelay (transfer->delay_usecs);
@@ -1122,7 +1115,7 @@ static int dspi_probe(struct platform_device *pdev) goto out_clk_put; } -init_waitqueue_head (&dspi->waitq); +init_completion (&dspi->xfer_done); poll_mode:if (dspi->devtype_data->trans_mode ==DSPI_DMA_MODE ) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 59/232 irqchip/gic-v4: Provide irq_retrigger to avoid circular locking dependency
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 7809f7011c3bce650e502a98afeb05961470d865 ]
On a very heavily loaded D05 with GICv4, I managed to trigger the following lockdep splat:
[ 6022.598864] ======================================================
[ 6022.605031] WARNING: possible circular locking dependency detected
[ 6022.611200] 5.6.0-rc4-00026-geee7c7b0f498 #680 Tainted: G E
[ 6022.618061] ------------------------------------------------------
[ 6022.624227] qemu-system-aar/7569 is trying to acquire lock:
[ 6022.629789] ffff042f97606808 (&p->pi_lock){-.-.}, at: try_to_wake_up+0x54/0x7a0
[ 6022.637102]
[ 6022.637102] but task is already holding lock:
[ 6022.642921] ffff002fae424cf0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x5c/0x98
[ 6022.651350]
[ 6022.651350] which lock already depends on the new lock.
[ 6022.651350]
[ 6022.659512]
[ 6022.659512] the existing dependency chain (in reverse order) is:
[ 6022.666980]
[ 6022.666980] -> #2 (&irq_desc_lock_class){-.-.}:
[ 6022.672983] _raw_spin_lock_irqsave+0x50/0x78
[ 6022.677848] __irq_get_desc_lock+0x5c/0x98
[ 6022.682453] irq_set_vcpu_affinity+0x40/0xc0
[ 6022.687236] its_make_vpe_non_resident+0x6c/0xb8
[ 6022.692364] vgic_v4_put+0x54/0x70
[ 6022.696273] vgic_v3_put+0x20/0xd8
[ 6022.700183] kvm_vgic_put+0x30/0x48
[ 6022.704182] kvm_arch_vcpu_put+0x34/0x50
[ 6022.708614] kvm_sched_out+0x34/0x50
[ 6022.712700] __schedule+0x4bc/0x7f8
[ 6022.716697] schedule+0x50/0xd8
[ 6022.720347] kvm_arch_vcpu_ioctl_run+0x5f0/0x978
[ 6022.725473] kvm_vcpu_ioctl+0x3d4/0x8f8
[ 6022.729820] ksys_ioctl+0x90/0xd0
[ 6022.733642] __arm64_sys_ioctl+0x24/0x30
[ 6022.738074] el0_svc_common.constprop.3+0xa8/0x1e8
[ 6022.743373] do_el0_svc+0x28/0x88
[ 6022.747198] el0_svc+0x14/0x40
[ 6022.750761] el0_sync_handler+0x124/0x2b8
[ 6022.755278] el0_sync+0x140/0x180
[ 6022.759100]
[ 6022.759100] -> #1 (&rq->lock){-.-.}:
[ 6022.764143] _raw_spin_lock+0x38/0x50
[ 6022.768314] task_fork_fair+0x40/0x128
[ 6022.772572] sched_fork+0xe0/0x210
[ 6022.776484] copy_process+0x8c4/0x18d8
[ 6022.780742] _do_fork+0x88/0x6d8
[ 6022.784478] kernel_thread+0x64/0x88
[ 6022.788563] rest_init+0x30/0x270
[ 6022.792390] arch_call_rest_init+0x14/0x1c
[ 6022.796995] start_kernel+0x498/0x4c4
[ 6022.801164]
[ 6022.801164] -> #0 (&p->pi_lock){-.-.}:
[ 6022.806382] __lock_acquire+0xdd8/0x15c8
[ 6022.810813] lock_acquire+0xd0/0x218
[ 6022.814896] _raw_spin_lock_irqsave+0x50/0x78
[ 6022.819761] try_to_wake_up+0x54/0x7a0
[ 6022.824018] wake_up_process+0x1c/0x28
[ 6022.828276] wakeup_softirqd+0x38/0x40
[ 6022.832533] __tasklet_schedule_common+0xc4/0xf0
[ 6022.837658] __tasklet_schedule+0x24/0x30
[ 6022.842176] check_irq_resend+0xc8/0x158
[ 6022.846609] irq_startup+0x74/0x128
[ 6022.850606] __enable_irq+0x6c/0x78
[ 6022.854602] enable_irq+0x54/0xa0
[ 6022.858431] its_make_vpe_non_resident+0xa4/0xb8
[ 6022.863557] vgic_v4_put+0x54/0x70
[ 6022.867469] kvm_arch_vcpu_blocking+0x28/0x38
[ 6022.872336] kvm_vcpu_block+0x48/0x490
[ 6022.876594] kvm_handle_wfx+0x18c/0x310
[ 6022.880938] handle_exit+0x138/0x198
[ 6022.885022] kvm_arch_vcpu_ioctl_run+0x4d4/0x978
[ 6022.890148] kvm_vcpu_ioctl+0x3d4/0x8f8
[ 6022.894494] ksys_ioctl+0x90/0xd0
[ 6022.898317] __arm64_sys_ioctl+0x24/0x30
[ 6022.902748] el0_svc_common.constprop.3+0xa8/0x1e8
[ 6022.908046] do_el0_svc+0x28/0x88
[ 6022.911871] el0_svc+0x14/0x40
[ 6022.915434] el0_sync_handler+0x124/0x2b8
[ 6022.919951] el0_sync+0x140/0x180
[ 6022.923773]
[ 6022.923773] other info that might help us debug this:
[ 6022.923773]
[ 6022.931762] Chain exists of:
[ 6022.931762] &p->pi_lock --> &rq->lock --> &irq_desc_lock_class
[ 6022.931762]
[ 6022.942101] Possible unsafe locking scenario:
[ 6022.942101]
[ 6022.948007] CPU0 CPU1
[ 6022.952523] ---- ----
[ 6022.957039] lock(&irq_desc_lock_class);
[ 6022.961036] lock(&rq->lock);
[ 6022.966595] lock(&irq_desc_lock_class);
[ 6022.973109] lock(&p->pi_lock);
[ 6022.976324]
[ 6022.976324] *** DEADLOCK ***This is happening because we have a pending doorbell that requires retrigger. As SW retriggering is done in a tasklet, we trigger the circular dependency above.
The easy cop-out is to provide a retrigger callback that doesn't require acquiring any extra lock.
--- drivers/irqchip/irq-gic-v3-its.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +6 -0
@@ -2985,12 +2985,18 @@ static int its_vpe_set_irqchip_state(struct irq_data *d,return 0 ; } +static int its_vpe_retrigger (struct irq_data *d) +{ +return !its_vpe_set_irqchip_state (d,IRQCHIP_STATE_PENDING , true); +} +static struct irq_chip its_vpe_irq_chip = { .name ="GICv4-vpe" , .irq_mask = its_vpe_mask_irq, .irq_unmask = its_vpe_unmask_irq, .irq_eoi = irq_chip_eoi_parent, .irq_set_affinity = its_vpe_set_affinity, + .irq_retrigger = its_vpe_retrigger, .irq_set_irqchip_state = its_vpe_set_irqchip_state, .irq_set_vcpu_affinity = its_vpe_set_vcpu_affinity, };
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 60/232 md: check arrays is suspended in mddev_detach before call quiesce operations
In reply to Greg Kroah-HartmanFrom: Guoqing Jiang <[email protected]>
[ Upstream commit 6b40bec3b13278d21fa6c1ae7a0bdf2e550eed5f ]
Don't call quiesce(1) and quiesce(0) if array is already suspended, otherwise in level_store, the array is writable after mddev_detach in below part though the intention is to make array writable after resume.
mddev_suspend(mddev); mddev_detach(mddev); ... mddev_resume(mddev);
And it also causes calltrace as follows in [1].
[48005.653834] WARNING: CPU: 1 PID: 45380 at kernel/kthread.c:510 kthread_park+0x77/0x90 [...] [48005.653976] CPU: 1 PID: 45380 Comm: mdadm Tainted: G OE 5.4.10-arch1-1 #1 [48005.653979] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./J4105-ITX, BIOS P1.40 08/06/2018 [48005.653984] RIP: 0010:kthread_park+0x77/0x90 [48005.654015] Call Trace: [48005.654039] r5l_quiesce+0x3c/0x70 [raid456] [48005.654052] raid5_quiesce+0x228/0x2e0 [raid456] [48005.654073] mddev_detach+0x30/0x70 [md_mod] [48005.654090] level_store+0x202/0x670 [md_mod] [48005.654099] ? security_capable+0x40/0x60 [48005.654114] md_attr_store+0x7b/0xc0 [md_mod] [48005.654123] kernfs_fop_write+0xce/0x1b0 [48005.654132] vfs_write+0xb6/0x1a0 [48005.654138] ksys_write+0x67/0xe0 [48005.654146] do_syscall_64+0x4e/0x140 [48005.654155] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [48005.654161] RIP: 0033:0x7fa0c8737497
[1]: https://bugzilla.kernel.org/show_bug.cgi?id=206161
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -6040,7 +6040,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);static void mddev_detach (struct mddev *mddev) {md_bitmap_wait_behind_writes (mddev); -if (mddev->pers && mddev->pers->quiesce) { +if (mddev->pers && mddev->pers->quiesce && !mddev->suspended) { mddev->pers->quiesce (mddev,1 ); mddev->pers->quiesce (mddev,0 ); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 54/232 efi/x86: Ignore the memory attributes table on i386
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit dd09fad9d2caad2325a39b766ce9e79cfc690184 ]
Commit:
3a6b6c6fb23667fa ("efi: Make EFI_MEMORY_ATTRIBUTES_TABLE initialization common across all architectures")
moved the call to efi_memattr_init() from ARM specific to the generic EFI init code, in order to be able to apply the restricted permissions described in that table on x86 as well.
We never enabled this feature fully on i386, and so mapping and reserving this table is pointless. However, due to the early call to memblock_reserve(), the memory bookkeeping gets confused to the point where it produces the splat below when we try to map the memory later on:
------------[ cut here ]------------ ioremap on RAM at 0x3f251000 - 0x3fa1afff WARNING: CPU: 0 PID: 0 at arch/x86/mm/ioremap.c:166 __ioremap_caller ... Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.20.0 #48 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 EIP: __ioremap_caller.constprop.0+0x249/0x260 Code: 90 0f b7 05 4e 38 40 de 09 45 e0 e9 09 ff ff ff 90 8d 45 ec c6 05 ... EAX: 00000029 EBX: 00000000 ECX: de59c228 EDX: 00000001 ESI: 3f250fff EDI: 00000000 EBP: de3edf20 ESP: de3edee0 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00200296 CR0: 80050033 CR2: ffd17000 CR3: 1e58c000 CR4: 00040690 Call Trace: ioremap_cache+0xd/0x10 ? old_map_region+0x72/0x9d old_map_region+0x72/0x9d efi_map_region+0x8/0xa efi_enter_virtual_mode+0x260/0x43b start_kernel+0x329/0x3aa i386_start_kernel+0xa7/0xab startup_32_smp+0x164/0x168 ---[ end trace e15ccf6b9f356833 ]---
Let's work around this by disregarding the memory attributes table altogether on i386, which does not result in a loss of functionality or protection, given that we never consumed the contents.
--- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/efi.c +1 -1
@@ -562,7 +562,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, } } -if (efi_enabled (EFI_MEMMAP )) +if (!IS_ENABLED (CONFIG_X86_32 ) &&efi_enabled (EFI_MEMMAP ))efi_memattr_init ();efi_tpm_eventlog_init ();
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 58/232 usb: dwc3: core: add support for disabling SS instances in park mode
In reply to Greg Kroah-HartmanFrom: Neil Armstrong <[email protected]>
[ Upstream commit 7ba6b09fda5e0cb741ee56f3264665e0edc64822 ]
In certain circumstances, the XHCI SuperSpeed instance in park mode can fail to recover, thus on Amlogic G12A/G12B/SM1 SoCs when there is high load on the single XHCI SuperSpeed instance, the controller can crash like:
xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. xhci-hcd xhci-hcd.0.auto: Host halt failed, -110
xhci-hcd xhci-hcd.0.auto: xHCI host controller not responding, assume dead xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. hub 2-1.1:1.0: hub_ext_port_status failed (err = -22)
xhci-hcd xhci-hcd.0.auto: HC died; cleaning up
usb 2-1.1-port1: cannot reset (err = -22)
Setting the PARKMODE_DISABLE_SS bit in the DWC3_USB3_GUCTL1 mitigates the issue. The bit is described as :
"When this bit is set to '1' all SS bus instances in park mode are disabled"
Synopsys explains:
The GUCTL1.PARKMODE_DISABLE_SS is only available in dwc_usb3 controller running in host mode.
This should not be set for other IPs.
This can be disabled by default based on IP, but I recommend to have a property to enable this feature for devices that need this.
--- drivers/usb/dwc3/core.c | 5 +++++ drivers/usb/dwc3/core.h | 4 ++++ 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
@@ -992,6 +992,9 @@ static int dwc3_core_init(struct dwc3 *dwc)if (dwc->dis_tx_ipgap_linecheck_quirk) reg |=DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS ; +if (dwc->parkmode_disable_ss_quirk) + reg |=DWC3_GUCTL1_PARKMODE_DISABLE_SS ; +dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); }
@@ -1305,6 +1308,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis-del-phy-power-chg-quirk"); dwc->dis_tx_ipgap_linecheck_quirk =device_property_read_bool (dev,"snps,dis-tx-ipgap-linecheck-quirk" ); + dwc->parkmode_disable_ss_quirk =device_property_read_bool (dev, +"snps,parkmode-disable-ss-quirk" ); dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" );
drivers/usb/dwc3/core.h +4 -0
@@ -249,6 +249,7 @@#define DWC3_GUCTL_HSTINAUTORETRY BIT(14)/* Global User Control 1 Register */ +#define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17)#define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28)#define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24)
@@ -1024,6 +1025,8 @@ struct dwc3_scratchpad_array {* change quirk. * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate * check during HS transmit. +* @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed +* instances in park mode. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis
@@ -1215,6 +1218,7 @@ struct dwc3 { unsigned dis_u2_freeclk_exists_quirk:1; unsigned dis_del_phy_power_chg_quirk:1; unsigned dis_tx_ipgap_linecheck_quirk:1; + unsigned parkmode_disable_ss_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 53/232 x86/boot: Use unsigned comparison for addresses
In reply to Greg Kroah-HartmanFrom: Arvind Sankar <[email protected]>
[ Upstream commit 81a34892c2c7c809f9c4e22c5ac936ae673fb9a2 ]
The load address is compared with LOAD_PHYSICAL_ADDR using a signed comparison currently (using jge instruction).
When loading a 64-bit kernel using the new efi32_pe_entry() point added by:
97aa276579b2 ("efi/x86: Add true mixed mode entry point into .compat section")
using Qemu with -m 3072, the firmware actually loads us above 2Gb, resulting in a very early crash.
Use the JAE instruction to perform a unsigned comparison instead, as physical addresses should be considered unsigned.
--- arch/x86/boot/compressed/head_32.S | 2 +- arch/x86/boot/compressed/head_64.S | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/head_32.S +1 -1
@@ -106,7 +106,7 @@ ENTRY(startup_32) notl %eax andl %eax, %ebx cmpl $LOAD_PHYSICAL_ADDR, %ebx - jge 1f + jae 1f #endif movl $LOAD_PHYSICAL_ADDR, %ebx 1:
arch/x86/boot/compressed/head_64.S +2 -2
@@ -106,7 +106,7 @@ ENTRY(startup_32) notl %eax andl %eax, %ebx cmpl $LOAD_PHYSICAL_ADDR, %ebx - jge 1f + jae 1f #endif movl $LOAD_PHYSICAL_ADDR, %ebx 1:
@@ -297,7 +297,7 @@ ENTRY(startup_64) notq %rax andq %rax, %rbp cmpq $LOAD_PHYSICAL_ADDR, %rbp - jge 1f + jae 1f #endif movq $LOAD_PHYSICAL_ADDR, %rbp 1:
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 9/232 rxrpc: Fix call interruptibility handling
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit e138aa7d3271ac1b0690ae2c9b04d51468dce1d6 ]
Fix the interruptibility of kernel-initiated client calls so that they're either only interruptible when they're waiting for a call slot to come available or they're not interruptible at all. Either way, they're not interruptible during transmission.
This should help prevent StoreData calls from being interrupted when writeback is in progress. It doesn't, however, handle interruption during the receive phase.
Userspace-initiated calls are still interruptable. After the signal has been handled, sendmsg() will return the amount of data copied out of the buffer and userspace can perform another sendmsg() call to continue transmission.
--- fs/afs/rxrpc.c | 3 ++- include/net/af_rxrpc.h | 8 +++++++- net/rxrpc/af_rxrpc.c | 4 ++-- net/rxrpc/ar-internal.h | 4 ++-- net/rxrpc/call_object.c | 3 +-- net/rxrpc/conn_client.c | 13 +++++++++--- net/rxrpc/sendmsg.c | 44 +++++++++++++++++++++++++++++++++-------- 7 files changed, 60 insertions(+), 19 deletions(-)
fs/afs/rxrpc.c +2 -1
@@ -414,7 +414,8 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) afs_wake_up_async_call : afs_wake_up_call_waiter), call->upgrade, - call->intr, + (call->intr ?RXRPC_PREINTERRUPTIBLE : +RXRPC_UNINTERRUPTIBLE ), call->debug_id);if (IS_ERR (rxcall)) { ret =PTR_ERR (rxcall);
include/net/af_rxrpc.h +7 -1
@@ -16,6 +16,12 @@ struct sock;struct socket ;struct rxrpc_call ; +enum rxrpc_interruptibility { +RXRPC_INTERRUPTIBLE ,/* Call is interruptible */ +RXRPC_PREINTERRUPTIBLE ,/* Call can be cancelled whilst waiting for a slot */ +RXRPC_UNINTERRUPTIBLE ,/* Call should not be interruptible at all */ +}; +/* * Debug ID counter for tracing. */
@@ -41,7 +47,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *, gfp_t, rxrpc_notify_rx_t, bool, - bool, + enum rxrpc_interruptibility, unsigned int); int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *, struct msghdr *, size_t,
net/rxrpc/af_rxrpc.c +2 -2
@@ -285,7 +285,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,gfp_t gfp, rxrpc_notify_rx_t notify_rx, bool upgrade, - bool intr, + enum rxrpc_interruptibility interruptibility, unsigned int debug_id) { struct rxrpc_conn_parameters cp;
@@ -310,7 +310,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,memset (&p,0 ,sizeof (p)); p.user_call_ID = user_call_ID; p.tx_total_len = tx_total_len; - p.intr = intr; + p.interruptibility = interruptibility;memset (&cp,0 ,sizeof (cp)); cp.local = rx->local;
net/rxrpc/ar-internal.h +2 -2
@@ -489,7 +489,6 @@ enum rxrpc_call_flag {RXRPC_CALL_BEGAN_RX_TIMER ,/* We began the expect_rx_by timer */ RXRPC_CALL_RX_HEARD ,/* The peer responded at least once to this call */ RXRPC_CALL_RX_UNDERRUN ,/* Got data underrun */ -RXRPC_CALL_IS_INTR ,/* The call is interruptible */ RXRPC_CALL_DISCONNECTED, /* The call has been disconnected */ };
@@ -598,6 +597,7 @@ struct rxrpc_call {atomic_t usage;u16 service_id;/* service ID */ u8 security_ix;/* Security type */ +enum rxrpc_interruptibility interruptibility;/* At what point call may be interrupted */ u32 call_id;/* call ID on connection */ u32 cid;/* connection ID plus channel index */ int debug_id;/* debug ID for printks */
@@ -720,7 +720,7 @@ struct rxrpc_call_params {u32 normal;/* Max time since last call packet (msec) */ } timeouts;u8 nr_timeouts;/* Number of timeouts specified */ -bool intr;/* The call is interruptible */ +enum rxrpc_interruptibility interruptibility;/* How is interruptible is the call? */ };struct rxrpc_send_params {
net/rxrpc/call_object.c +1 -2
@@ -237,8 +237,7 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,return call; } -if (p->intr) -__set_bit (RXRPC_CALL_IS_INTR , &call->flags); + call->interruptibility = p->interruptibility; call->tx_total_len = p->tx_total_len; trace_rxrpc_call(call->debug_id, rxrpc_call_new_client, atomic_read(&call->usage),
net/rxrpc/conn_client.c +10 -3
@@ -655,13 +655,20 @@ static int rxrpc_wait_for_channel(struct rxrpc_call *call, gfp_t gfp)add_wait_queue_exclusive (&call->waitq, &myself);for (;;) { -if (test_bit (RXRPC_CALL_IS_INTR , &call->flags)) +switch (call->interruptibility) { +case RXRPC_INTERRUPTIBLE : +case RXRPC_PREINTERRUPTIBLE :set_current_state (TASK_INTERRUPTIBLE ); -else +break ; +case RXRPC_UNINTERRUPTIBLE : +default :set_current_state (TASK_UNINTERRUPTIBLE ); +break ; + }if (call->call_id)break ; -if (test_bit (RXRPC_CALL_IS_INTR , &call->flags) && +if ((call->interruptibility ==RXRPC_INTERRUPTIBLE || + call->interruptibility ==RXRPC_PREINTERRUPTIBLE ) &&signal_pending (current)) { ret = -ERESTARTSYS ;break ;
net/rxrpc/sendmsg.c +36 -8
74 lines not on this page · raw message
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 8/232 rxrpc: Abstract out the calculation of whether theres Tx space
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 158fe6665389964a1de212818b4a5c52b7f7aff4 ]
Abstract out the calculation of there being sufficient Tx buffer space. This is reproduced several times in the rxrpc sendmsg code.
--- net/rxrpc/sendmsg.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
net/rxrpc/sendmsg.c +18 -9
@@ -17,6 +17,21 @@#include <net/af_rxrpc.h> #include "ar-internal.h" +/* +* Return true if there's sufficient Tx queue space. +*/ +static bool rxrpc_check_tx_space (struct rxrpc_call *call,rxrpc_seq_t *_tx_win) +{ +unsigned int win_size = + min_t(unsigned int, call->tx_winsize, + call->cong_cwnd + call->cong_extra); +rxrpc_seq_t tx_win =READ_ONCE (call->tx_hard_ack); + +if (_tx_win) + *_tx_win = tx_win; +return call->tx_top - tx_win < win_size; +} +/* * Wait for space to appear in the Tx queue or a signal to occur. */
@@ -26,9 +41,7 @@ static int rxrpc_wait_for_tx_window_intr(struct rxrpc_sock *rx, {for (;;) {set_current_state (TASK_INTERRUPTIBLE ); -if (call->tx_top - call->tx_hard_ack < - min_t(unsigned int, call->tx_winsize, - call->cong_cwnd + call->cong_extra)) +if (rxrpc_check_tx_space (call,NULL ))return 0 ;if (call->state >=RXRPC_CALL_COMPLETE )
@@ -68,9 +81,7 @@ static int rxrpc_wait_for_tx_window_nonintr(struct rxrpc_sock *rx,set_current_state (TASK_UNINTERRUPTIBLE ); tx_win =READ_ONCE (call->tx_hard_ack); -if (call->tx_top - tx_win < - min_t(unsigned int, call->tx_winsize, - call->cong_cwnd + call->cong_extra)) +if (rxrpc_check_tx_space (call, &tx_win))return 0 ;if (call->state >=RXRPC_CALL_COMPLETE )
@@ -302,9 +313,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,_debug ("alloc" ); -if (call->tx_top - call->tx_hard_ack >= - min_t(unsigned int, call->tx_winsize, - call->cong_cwnd + call->cong_extra)) { +if (!rxrpc_check_tx_space (call,NULL )) { ret = -EAGAIN ;if (msg->msg_flags &MSG_DONTWAIT ) goto maybe_error;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 5/232 iwlwifi: mvm: Fix rate scale NSS configuration
In reply to Greg Kroah-HartmanFrom: Ilan Peer <[email protected]>
[ Upstream commit ce19801ba75a902ab515dda03b57738c708d0781 ]
The TLC configuration did not take into consideration the station's SMPS configuration, and thus configured rates for 2 NSS even if static SMPS was reported by the station. Fix this.
--- .../net/wireless/intel/iwlwifi/mvm/rs-fw.c | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +21 -8
@@ -6,7 +6,7 @@* GPL LICENSE SUMMARY * * Copyright(c) 2017 Intel Deutschland GmbH -* Copyright(c) 2018 - 2019 Intel Corporation +* Copyright(c) 2018 - 2020 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -27,7 +27,7 @@* BSD LICENSE * * Copyright(c) 2017 Intel Deutschland GmbH -* Copyright(c) 2018 - 2019 Intel Corporation +* Copyright(c) 2018 - 2020 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -195,11 +195,13 @@ rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta, {u16 supp;int i, highest_mcs; +u8 nss = sta->rx_nss; -for (i =0 ; i < sta->rx_nss; i++) { -if (i ==IWL_TLC_NSS_MAX ) -break ; +/* the station support only a single receive chain */ +if (sta->smps_mode ==IEEE80211_SMPS_STATIC ) + nss =1 ; +for (i =0 ; i < nss && i <IWL_TLC_NSS_MAX ; i++) { highest_mcs =rs_fw_vht_highest_rx_mcs_index (vht_cap, i +1 );if (!highest_mcs)continue ;
@@ -245,8 +247,13 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,u16 tx_mcs_160 =le16_to_cpu (sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_160);int i; +u8 nss = sta->rx_nss; -for (i =0 ; i < sta->rx_nss && i <IWL_TLC_NSS_MAX ; i++) { +/* the station support only a single receive chain */ +if (sta->smps_mode ==IEEE80211_SMPS_STATIC ) + nss =1 ; + +for (i =0 ; i < nss && i <IWL_TLC_NSS_MAX ; i++) {u16 _mcs_160 = (mcs_160 >> (2 * i)) &0x3 ;u16 _mcs_80 = (mcs_80 >> (2 * i)) &0x3 ;u16 _tx_mcs_160 = (tx_mcs_160 >> (2 * i)) &0x3 ;
@@ -307,8 +314,14 @@ static void rs_fw_set_supp_rates(struct ieee80211_sta *sta, cmd->mode =IWL_TLC_MNG_MODE_HT ; cmd->ht_rates[IWL_TLC_NSS_1 ][IWL_TLC_HT_BW_NONE_160 ] =cpu_to_le16 (ht_cap->mcs.rx_mask[0 ]); - cmd->ht_rates[IWL_TLC_NSS_2 ][IWL_TLC_HT_BW_NONE_160 ] = -cpu_to_le16 (ht_cap->mcs.rx_mask[1 ]); + +/* the station support only a single receive chain */ +if (sta->smps_mode ==IEEE80211_SMPS_STATIC ) + cmd->ht_rates[IWL_TLC_NSS_2 ][IWL_TLC_HT_BW_NONE_160 ] = +0 ; +else + cmd->ht_rates[IWL_TLC_NSS_2 ][IWL_TLC_HT_BW_NONE_160 ] = +cpu_to_le16 (ht_cap->mcs.rx_mask[1 ]); } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 40/232 irqchip/versatile-fpga: Handle chained IRQs properly
In reply to Greg Kroah-HartmanFrom: Sungbo Eo <[email protected]>
[ Upstream commit 486562da598c59e9f835b551d7cf19507de2d681 ]
Enclose the chained handler with chained_irq_{enter,exit}(), so that the muxed interrupts get properly acked.
This patch also fixes a reboot bug on OX820 SoC, where the jiffies timer interrupt is never acked. The kernel waits a clock tick forever in calibrate_delay_converge(), which leads to a boot hang.
--- drivers/irqchip/irq-versatile-fpga.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/irqchip/irq-versatile-fpga.c +10 -2
@@ -6,6 +6,7 @@#include <linux/irq.h> #include <linux/io.h> #include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> #include <linux/irqchip/versatile-fpga.h> #include <linux/irqdomain.h> #include <linux/module.h>
@@ -68,12 +69,16 @@ static void fpga_irq_unmask(struct irq_data *d)static void fpga_irq_handle (struct irq_desc *desc) { +struct irq_chip *chip =irq_desc_get_chip (desc);struct fpga_irq_data *f =irq_desc_get_handler_data (desc); -u32 status =readl (f->base +IRQ_STATUS ); +u32 status; + +chained_irq_enter (chip, desc); + status =readl (f->base +IRQ_STATUS );if (status ==0 ) {do_bad_IRQ (desc); -return ; + goto out; } do {
@@ -82,6 +87,9 @@ static void fpga_irq_handle(struct irq_desc *desc) status &= ~(1 << irq);generic_handle_irq (irq_find_mapping (f->domain, irq)); }while (status); + +out: +chained_irq_exit (chip, desc); }/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 39/232 debugfs: Check module state before warning in {full/open}_proxy_open()
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 275678e7a9be6a0ea9c1bb493e48abf2f4a01be5 ]
When the module is being removed, the module state is set to MODULE_STATE_GOING. At this point, try_module_get() fails. And when {full/open}_proxy_open() is being called,
it calls try_module_get() to try to hold module reference count. If it fails, it warns about the possibility of debugfs file leak.
If {full/open}_proxy_open() is called while the module is being removed, it fails to hold the module.
So, It warns about debugfs file leak. But it is not the debugfs file leak case. So, this patch just adds module state checking routine in the {full/open}_proxy_open().
Test commands:
#SHELL1
while :
do
modprobe netdevsim
echo 1 > /sys/bus/netdevsim/new_device
modprobe -rv netdevsim
done
#SHELL2
while :
do
cat /sys/kernel/debug/netdevsim/netdevsim1/ports/0/ipsec
done
Splat looks like:
[ 298.766738][T14664] debugfs file owner did not clean up at exit: ipsec [ 298.766766][T14664] WARNING: CPU: 2 PID: 14664 at fs/debugfs/file.c:312 full_proxy_open+0x10f/0x650 [ 298.768595][T14664] Modules linked in: netdevsim(-) openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 n][ 298.771343][T14664] CPU: 2 PID: 14664 Comm: cat Tainted: G W 5.5.0+ #1 [ 298.772373][T14664] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 298.773545][T14664] RIP: 0010:full_proxy_open+0x10f/0x650 [ 298.774247][T14664] Code: 48 c1 ea 03 80 3c 02 00 0f 85 c1 04 00 00 49 8b 3c 24 e8 e4 b5 78 ff 84 c0 75 2d 4c 89 ee 48 [ 298.776782][T14664] RSP: 0018:ffff88805b7df9b8 EFLAGS: 00010282[ 298.777583][T14664] RAX: dffffc0000000008 RBX: ffff8880511725c0 RCX: 0000000000000000 [ 298.778610][T14664] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffff8880540c5c14 [ 298.779637][T14664] RBP: 0000000000000000 R08: fffffbfff15235ad R09: 0000000000000000 [ 298.780664][T14664] R10: 0000000000000001 R11: 0000000000000000 R12: ffffffffc06b5000 [ 298.781702][T14664] R13: ffff88804c234a88 R14: ffff88804c22dd00 R15: ffffffff8a1b5660 [ 298.782722][T14664] FS: 00007fafa13a8540(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000 [ 298.783845][T14664] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 298.784672][T14664] CR2: 00007fafa0e9cd10 CR3: 000000004b286005 CR4: 00000000000606e0 [ 298.785739][T14664] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 298.786769][T14664] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 298.787785][T14664] Call Trace: [ 298.788237][T14664] do_dentry_open+0x63c/0xf50 [ 298.788872][T14664] ? open_proxy_open+0x270/0x270 [ 298.789524][T14664] ? __x64_sys_fchdir+0x180/0x180 [ 298.790169][T14664] ? inode_permission+0x65/0x390 [ 298.790832][T14664] path_openat+0xc45/0x2680 [ 298.791425][T14664] ? save_stack+0x69/0x80 [ 298.791988][T14664] ? save_stack+0x19/0x80 [ 298.792544][T14664] ? path_mountpoint+0x2e0/0x2e0 [ 298.793233][T14664] ? check_chain_key+0x236/0x5d0 [ 298.793910][T14664] ? sched_clock_cpu+0x18/0x170 [ 298.794527][T14664] ? find_held_lock+0x39/0x1d0 [ 298.795153][T14664] do_filp_open+0x16a/0x260
[ ... ]
--- fs/debugfs/file.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/debugfs/file.c +14 -4
@@ -175,8 +175,13 @@ static int open_proxy_open(struct inode *inode, struct file *filp)if (r) goto out; - real_fops =fops_get (real_fops); -if (!real_fops) { +if (!fops_get (real_fops)) { +#ifdef MODULE +if (real_fops->owner && + real_fops->owner->state ==MODULE_STATE_GOING ) + goto out; +#endif +/* Huh? Module did not clean up after itself at exit? */ WARN (1 ,"debugfs file owner did not clean up at exit: %pd" , dentry);
@@ -305,8 +310,13 @@ static int full_proxy_open(struct inode *inode, struct file *filp)if (r) goto out; - real_fops =fops_get (real_fops); -if (!real_fops) { +if (!fops_get (real_fops)) { +#ifdef MODULE +if (real_fops->owner && + real_fops->owner->state ==MODULE_STATE_GOING ) + goto out; +#endif +/* Huh? Module did not cleanup after itself at exit? */ WARN (1 ,"debugfs file owner did not clean up at exit: %pd" , dentry);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 38/232 block: keep bdi->io_pages in sync with max_sectors_kb for stacked devices
In reply to Greg Kroah-HartmanFrom: Konstantin Khlebnikov <[email protected]>
[ Upstream commit e74d93e96d721c4297f2a900ad0191890d2fc2b0 ]
Field bdi->io_pages added in commit 9491ae4aade6 ("mm: don't cap request size based on read-ahead setting") removes unneeded split of read requests.
Stacked drivers do not call blk_queue_max_hw_sectors(). Instead they set limits of their devices by blk_set_stacking_limits() + disk_stack_limits(). Field bio->io_pages stays zero until user set max_sectors_kb via sysfs.
This patch updates io_pages after merging limits in disk_stack_limits().
Commit c6d6e9b0f6b4 ("dm: do not allow readahead to limit IO size") fixed the same problem for device-mapper devices, this one fixes MD RAIDs.
--- block/blk-settings.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-settings.c +3 -0
@@ -664,6 +664,9 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,printk (KERN_NOTICE "%s: Warning: Device %s is misaligned\n" , top, bottom); } + + t->backing_dev_info->io_pages = + t->limits.max_sectors >> (PAGE_SHIFT -9 ); }EXPORT_SYMBOL (disk_stack_limits);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 37/232 dma-mapping: Fix dma_pgprot() for unencrypted coherent pages
In reply to Greg Kroah-HartmanFrom: Thomas Hellstrom <[email protected]>
[ Upstream commit 17c4a2ae15a7aaefe84bdb271952678c5c9cd8e1 ]
When dma_mmap_coherent() sets up a mapping to unencrypted coherent memory under SEV encryption and sometimes under SME encryption, it will actually set up an encrypted mapping rather than an unencrypted, causing devices that DMAs from that memory to read encrypted contents. Fix this.
When force_dma_unencrypted() returns true, the linear kernel map of the coherent pages have had the encryption bit explicitly cleared and the page content is unencrypted. Make sure that any additional PTEs we set up to these pages also have the encryption bit cleared by having dma_pgprot() return a protection with the encryption bit cleared in this case.
--- kernel/dma/mapping.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/dma/mapping.c +2 -0
@@ -169,6 +169,8 @@ EXPORT_SYMBOL(dma_get_sgtable_attrs);*/ pgprot_t dma_pgprot (struct device *dev,pgprot_t prot,unsigned long attrs) { +if (force_dma_unencrypted (dev)) + prot =pgprot_decrypted (prot);if (dev_is_dma_coherent (dev) || (IS_ENABLED (CONFIG_DMA_NONCOHERENT_CACHE_SYNC ) && (attrs &DMA_ATTR_NON_CONSISTENT )))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 36/232 x86: Dont let pgprot_modify() change the page encryption bit
In reply to Greg Kroah-HartmanFrom: Thomas Hellstrom <[email protected]>
[ Upstream commit 6db73f17c5f155dbcfd5e48e621c706270b84df0 ]
When SEV or SME is enabled and active, vm_get_page_prot() typically returns with the encryption bit set. This means that users of pgprot_modify(, vm_get_page_prot()) (mprotect_fixup(), do_mmap()) end up with a value of vma->vm_pg_prot that is not consistent with the intended protection of the PTEs.
This is also important for fault handlers that rely on the VMA vm_page_prot to set the page protection. Fix this by not allowing pgprot_modify() to change the encryption bit, similar to how it's done for PAT bits.
--- arch/x86/include/asm/pgtable.h | 7 +++++-- arch/x86/include/asm/pgtable_types.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/include/asm/pgtable.h +5 -2
@@ -624,12 +624,15 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)return __pmd (val); } -/* mprotect needs to preserve PAT bits when updating vm_page_prot */ +/* +* mprotect needs to preserve PAT and encryption bits when updating +* vm_page_prot +*/ #define pgprot_modify pgprot_modifystatic inline pgprot_t pgprot_modify (pgprot_t oldprot,pgprot_t newprot) {pgprotval_t preservebits =pgprot_val (oldprot) & _PAGE_CHG_MASK; -pgprotval_t addbits =pgprot_val (newprot); +pgprotval_t addbits =pgprot_val (newprot) & ~_PAGE_CHG_MASK;return __pgprot (preservebits | addbits); }
arch/x86/include/asm/pgtable_types.h +1 -1
@@ -123,7 +123,7 @@*/ #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \ _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \ - _PAGE_SOFT_DIRTY | _PAGE_DEVMAP) + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP | _PAGE_ENC)#define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE)/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 35/232 ACPI: EC: Do not clear boot_ec_is_ecdt in acpi_ec_add()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 65a691f5f8f0bb63d6a82eec7b0ffd193d8d8a5f ]
The reason for clearing boot_ec_is_ecdt in acpi_ec_add() (if a PNP0C09 device object matching the ECDT boot EC had been found in the namespace) was to cause acpi_ec_ecdt_start() to return early, but since the latter does not look at boot_ec_is_ecdt any more, acpi_ec_add() need not clear it.
Moreover, doing that may be confusing as it may cause "DSDT" to be printed instead of "ECDT" in the EC initialization completion message, so stop doing it.
While at it, split the EC initialization completion message into two messages, one regarding the boot EC and another one printed regardless of whether or not the EC at hand is the boot one.
--- drivers/acpi/ec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/ec.c +4 -2
@@ -1573,7 +1573,6 @@ static int acpi_ec_add(struct acpi_device *device)if (boot_ec && ec->command_addr == boot_ec->command_addr && ec->data_addr == boot_ec->data_addr) { - boot_ec_is_ecdt = false;/* * Trust PNP0C09 namespace location rather than * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1593,9 +1592,12 @@ static int acpi_ec_add(struct acpi_device *device)if (ec == boot_ec)acpi_handle_info (boot_ec->handle, -"Boot %s EC used to handle transactions and events\n" , +"Boot %s EC initialization complete\n" , boot_ec_is_ecdt ?"ECDT" :"DSDT" ); +acpi_handle_info (ec->handle, +"EC: Used to handle transactions and events\n" ); + device->driver_data = ec; ret = !!request_region (ec->data_addr,1 ,"EC data" );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 34/232 xhci: bail out early if driver cant accress host in resume
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
[ Upstream commit 72ae194704da212e2ec312ab182a96799d070755 ]
Bail out early if the xHC host needs to be reset at resume but driver can't access xHC PCI registers.
If xhci driver already fails to reset the controller then there is no point in attempting to free, re-initialize, re-allocate and re-start the host. If failure to access the host is detected later, failing the resume, xhci interrupts will be double freed when remove is called.
--- drivers/usb/host/xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +3 -1
@@ -1157,8 +1157,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)xhci_dbg (xhci,"Stop HCD\n" );xhci_halt (xhci);xhci_zero_64b_regs (xhci); -xhci_reset (xhci); + retval =xhci_reset (xhci);spin_unlock_irq (&xhci->lock); +if (retval) +return retval;xhci_cleanup_msix (xhci);xhci_dbg (xhci,"// Disabling event ring interrupts\n" );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 30/232 null_blk: Handle null_add_dev() failures properly
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit 9b03b713082a31a5b90e0a893c72aa620e255c26 ]
If null_add_dev() fails then null_del_dev() is called with a NULL argument. Make null_del_dev() handle this scenario correctly. This patch fixes the following KASAN complaint:
null-ptr-deref in null_del_dev+0x28/0x280 [null_blk]
Read of size 8 at addr 0000000000000000 by task find/1062 Call Trace: dump_stack+0xa5/0xe6 __kasan_report.cold+0x65/0x99 kasan_report+0x16/0x20 __asan_load8+0x58/0x90 null_del_dev+0x28/0x280 [null_blk] nullb_group_drop_item+0x7e/0xa0 [null_blk] client_drop_item+0x53/0x80 [configfs] configfs_rmdir+0x395/0x4e0 [configfs] vfs_rmdir+0xb6/0x220 do_rmdir+0x238/0x2c0 __x64_sys_unlinkat+0x75/0x90 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/block/null_blk_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/block/null_blk_main.c +6 -1
@@ -1382,7 +1382,12 @@ static void cleanup_queues(struct nullb *nullb)static void null_del_dev (struct nullb *nullb) { -struct nullb_device *dev = nullb->dev; +struct nullb_device *dev; + +if (!nullb) +return ; + + dev = nullb->dev;ida_simple_remove (&nullb_indexes, nullb->index);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 31/232 null_blk: fix spurious IO errors after failed past-wp access
In reply to Greg Kroah-HartmanFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit ff77042296d0a54535ddf74412c5ae92cb4ec76a ]
Steps to reproduce:
BLKRESETZONE zone 0 // force EIO pwrite(fd, buf, 4096, 4096); [issue more IO including zone ioctls]
It will start failing randomly including IO to unrelated zones because of ->error "reuse". Trigger can be partition detection as well if test is not run immediately which is even more entertaining.
The fix is of course to clear ->error where necessary.
--- drivers/block/null_blk_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/null_blk_main.c +2 -0
@@ -579,6 +579,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)if (tag !=-1U ) { cmd = &nq->cmds[tag]; cmd->tag = tag; + cmd->error =BLK_STS_OK ; cmd->nq = nq;if (nq->dev->irqmode ==NULL_IRQ_TIMER ) { hrtimer_init(&cmd->timer, CLOCK_MONOTONIC,
@@ -1335,6 +1336,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, cmd->timer.function = null_cmd_timer_expired; } cmd->rq = bd->rq; + cmd->error =BLK_STS_OK ; cmd->nq = nq;blk_mq_start_request (bd->rq);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 28/232 firmware: arm_sdei: fix double-lock on hibernate with shared events
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
[ Upstream commit 6ded0b61cf638bf9f8efe60ab8ba23db60ea9763 ]
SDEI has private events that must be registered on each CPU. When CPUs come and go they must re-register and re-enable their private events. Each event has flags to indicate whether this should happen to protect against an event being registered on a CPU coming online, while all the others are unregistering the event.
These flags are protected by the sdei_list_lock spinlock, because the cpuhp callbacks can't take the mutex.
Hibernate needs to unregister all events, but keep the in-memory re-register and re-enable as they are. sdei_unregister_shared() takes the spinlock to walk the list, then calls _sdei_event_unregister() on each shared event. _sdei_event_unregister() tries to take the same spinlock to update re-register and re-enable. This doesn't go so well.
Push the re-register and re-enable updates out to their callers. sdei_unregister_shared() doesn't want these values updated, so doesn't need to do anything.
This also fixes shared events getting lost over hibernate as this path made them look unregistered.
--- drivers/firmware/arm_sdei.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/firmware/arm_sdei.c +15 -17
@@ -491,11 +491,6 @@ static int _sdei_event_unregister(struct sdei_event *event) {lockdep_assert_held (&sdei_events_lock); -spin_lock (&sdei_list_lock); - event->reregister = false; - event->reenable = false; -spin_unlock (&sdei_list_lock); -if (event->type ==SDEI_EVENT_TYPE_SHARED )return sdei_api_event_unregister (event->event_num);
@@ -518,6 +513,11 @@ int sdei_event_unregister(u32 event_num)break ; } +spin_lock (&sdei_list_lock); + event->reregister = false; + event->reenable = false; +spin_unlock (&sdei_list_lock); + err =_sdei_event_unregister (event);if (err)break ;
@@ -585,26 +585,15 @@ static int _sdei_event_register(struct sdei_event *event)lockdep_assert_held (&sdei_events_lock); -spin_lock (&sdei_list_lock); - event->reregister = true; -spin_unlock (&sdei_list_lock); -if (event->type ==SDEI_EVENT_TYPE_SHARED )return sdei_api_event_register (event->event_num, sdei_entry_point, event->registered,SDEI_EVENT_REGISTER_RM_ANY ,0 ); - err =sdei_do_cross_call (_local_event_register, event); -if (err) { -spin_lock (&sdei_list_lock); - event->reregister = false; - event->reenable = false; -spin_unlock (&sdei_list_lock); - +if (err)sdei_do_cross_call (_local_event_unregister, event); - }return err; }
@@ -632,8 +621,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)break ; } +spin_lock (&sdei_list_lock); + event->reregister = true; +spin_unlock (&sdei_list_lock); + err =_sdei_event_register (event);if (err) { +spin_lock (&sdei_list_lock); + event->reregister = false; + event->reenable = false; +spin_unlock (&sdei_list_lock); +sdei_event_destroy (event);pr_warn ("Failed to register event %u: %d\n" , event_num, err);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 27/232 media: venus: hfi_parser: Ignore HEVC encoding for V1
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit c50cc6dc6c48300af63a6fbc71b647053c15fc80 ]
Some older MSM8916 Venus firmware versions also seem to indicate support for encoding HEVC, even though they really can't. This will lead to errors later because hfi_session_init() fails in this case.
HEVC is already ignored for "dec_codecs", so add the same for "enc_codecs" to make these old firmware versions work correctly.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/venus/hfi_parser.c +1 -0
@@ -181,6 +181,7 @@ static void parse_codecs(struct venus_core *core, void *data)if (IS_V1 (core)) { core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC ; core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK ; + core->enc_codecs &= ~HFI_VIDEO_CODEC_HEVC ; } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 23/232 i2c: pca-platform: Use platform_irq_get_optional
In reply to Greg Kroah-HartmanFrom: Chris Packham <[email protected]>
[ Upstream commit 14c1fe699cad9cb0acda4559c584f136d18fea50 ]
The interrupt is not required so use platform_irq_get_optional() to avoid error messages like
i2c-pca-platform 22080000.i2c: IRQ index 0 not found
--- drivers/i2c/busses/i2c-pca-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-pca-platform.c +1 -1
@@ -140,7 +140,7 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)int ret =0 ;int irq; - irq =platform_get_irq (pdev,0 ); + irq =platform_get_irq_optional (pdev,0 );/* If irq is 0, we do polling. */ if (irq <0 ) irq =0 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 22/232 i2c: st: fix missing struct parameter description
In reply to Greg Kroah-HartmanFrom: Alain Volmat <[email protected]>
[ Upstream commit f491c6687332920e296d0209e366fe2ca7eab1c6 ]
Fix a missing struct parameter description to allow warning free W=1 compilation.
--- drivers/i2c/busses/i2c-st.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-st.c +1 -0
@@ -434,6 +434,7 @@ static void st_i2c_wr_fill_tx_fifo(struct st_i2c_dev *i2c_dev)/** * st_i2c_rd_fill_tx_fifo() - Fill the Tx FIFO in read mode * @i2c_dev: Controller's private data +* @max: Maximum amount of data to fill into the Tx FIFO * * This functions fills the Tx FIFO with fixed pattern when * in read mode to trigger clock.
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 19/232 drm/scheduler: fix rare NULL ptr race
In reply to Greg Kroah-HartmanFrom: Yintian Tao <[email protected]>
[ Upstream commit 77bb2f204f1f0a53a602a8fd15816d6826212077 ]
There is one one corner case at dma_fence_signal_locked which will raise the NULL pointer problem just like below. ->dma_fence_signal
->dma_fence_signal_locked ->test_and_set_bit
here trigger dma_fence_release happen due to the zero of fence refcount.
->dma_fence_put
->dma_fence_release ->drm_sched_fence_release_scheduled ->call_rcu
here make the union fled “cb_list” at finished fence to NULL because struct rcu_head contains two pointer which is same as struct list_head cb_list
Therefore, to hold the reference of finished fence at drm_sched_process_job to prevent the null pointer during finished fence dma_fence_signal
[ 732.912867] BUG: kernel NULL pointer dereference, address: 0000000000000008 [ 732.914815] #PF: supervisor write access in kernel mode [ 732.915731] #PF: error_code(0x0002) - not-present page [ 732.916621] PGD 0 P4D 0 [ 732.917072] Oops: 0002 [#1] SMP PTI [ 732.917682] CPU: 7 PID: 0 Comm: swapper/7 Tainted: G OE 5.4.0-rc7 #1 [ 732.918980] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014 [ 732.920906] RIP: 0010:dma_fence_signal_locked+0x3e/0x100 [ 732.938569] Call Trace: [ 732.939003] <IRQ> [ 732.939364] dma_fence_signal+0x29/0x50 [ 732.940036] drm_sched_fence_finished+0x12/0x20 [gpu_sched] [ 732.940996] drm_sched_process_job+0x34/0xa0 [gpu_sched] [ 732.941910] dma_fence_signal_locked+0x85/0x100 [ 732.942692] dma_fence_signal+0x29/0x50 [ 732.943457] amdgpu_fence_process+0x99/0x120 [amdgpu] [ 732.944393] sdma_v4_0_process_trap_irq+0x81/0xa0 [amdgpu]
v2: hold the finished fence at drm_sched_process_job instead of
amdgpu_fence_process
v3: resume the blank line
--- drivers/gpu/drm/scheduler/sched_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +2 -0
@@ -627,7 +627,9 @@ static void drm_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb)trace_drm_sched_process_job (s_fence); +dma_fence_get (&s_fence->finished);drm_sched_fence_finished (s_fence); +dma_fence_put (&s_fence->finished);wake_up_interruptible (&sched->wake_up_worker); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 18/232 cxgb4/ptp: pass the sign of offset delta in FW CMD
In reply to Greg Kroah-HartmanFrom: Raju Rangoju <[email protected]>
[ Upstream commit 50e0d28d3808146cc19b0d5564ef4ba9e5bf3846 ]
cxgb4_ptp_fineadjtime() doesn't pass the signedness of offset delta in FW_PTP_CMD. Fix it by passing correct sign.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c +3 -0
@@ -246,6 +246,9 @@ static int cxgb4_ptp_fineadjtime(struct adapter *adapter, s64 delta) FW_PTP_CMD_PORTID_V(0)); c.retval_len16 =cpu_to_be32 (FW_CMD_LEN16_V (sizeof (c) /16 )); c.u.ts.sc =FW_PTP_SC_ADJ_FTIME ; + c.u.ts.sign = (delta <0 ) ?1 :0 ; +if (delta <0 ) + delta = -delta; c.u.ts.tm =cpu_to_be64 (delta); err =t4_wr_mbox (adapter, adapter->mbox, &c,sizeof (c),NULL );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 17/232 selftests/net: add definition for SOL_DCCP to fix compilation errors for old libc
In reply to Greg Kroah-HartmanFrom: Alan Maguire <[email protected]>
[ Upstream commit 83a9b6f639e9f6b632337f9776de17d51d969c77 ]
Many systems build/test up-to-date kernels with older libcs, and an older glibc (2.17) lacks the definition of SOL_DCCP in /usr/include/bits/socket.h (it was added in the 4.6 timeframe).
Adding the definition to the test program avoids a compilation failure that gets in the way of building tools/testing/selftests/net. The test itself will work once the definition is added; either skipping due to DCCP not being configured in the kernel under test or passing, so there are no other more up-to-date glibc dependencies here it seems beyond that missing definition.
--- tools/testing/selftests/net/reuseport_addr_any.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/net/reuseport_addr_any.c +4 -0
@@ -21,6 +21,10 @@#include <sys/socket.h> #include <unistd.h> +#ifndef SOL_DCCP +#define SOL_DCCP 269 +#endif +static const char *IP4_ADDR ="127.0.0.1" ;static const char *IP6_ADDR ="::1" ;static const char *IP4_MAPPED6 ="::ffff:127.0.0.1" ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 12/232 hinic: fix a bug of waitting for IO stopped
In reply to Greg Kroah-HartmanFrom: Luo bin <[email protected]>
[ Upstream commit 96758117dc528e6d84bd23d205e8cf7f31eda029 ]
it's unreliable for fw to check whether IO is stopped, so driver wait for enough time to ensure IO process is done in hw before freeing resources
--- .../net/ethernet/huawei/hinic/hinic_hw_dev.c | 51 +------------------ 1 file changed, 2 insertions(+), 49 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +2 -49
@@ -360,50 +360,6 @@ static int wait_for_db_state(struct hinic_hwdev *hwdev)return -EFAULT ; } -static int wait_for_io_stopped (struct hinic_hwdev *hwdev) -{ -struct hinic_cmd_io_status cmd_io_status; -struct hinic_hwif *hwif = hwdev->hwif; -struct pci_dev *pdev = hwif->pdev; -struct hinic_pfhwdev *pfhwdev; -unsigned long end; -u16 out_size; -int err; - -if (!HINIC_IS_PF (hwif) && !HINIC_IS_PPF (hwif)) { -dev_err (&pdev->dev,"Unsupported PCI Function type\n" ); -return -EINVAL ; - } - - pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); - - cmd_io_status.func_idx =HINIC_HWIF_FUNC_IDX (hwif); - - end = jiffies +msecs_to_jiffies (IO_STATUS_TIMEOUT ); -do { - err =hinic_msg_to_mgmt (&pfhwdev->pf_to_mgmt,HINIC_MOD_COMM , -HINIC_COMM_CMD_IO_STATUS_GET , - &cmd_io_status,sizeof (cmd_io_status), - &cmd_io_status, &out_size, -HINIC_MGMT_MSG_SYNC ); -if ((err) || (out_size !=sizeof (cmd_io_status))) { -dev_err (&pdev->dev,"Failed to get IO status, ret = %d\n" , - err); -return err; - } - -if (cmd_io_status.status ==IO_STOPPED ) { -dev_info (&pdev->dev,"IO stopped\n" ); -return 0 ; - } - -msleep (20 ); - }while (time_before (jiffies, end)); - -dev_err (&pdev->dev,"Wait for IO stopped - Timeout\n" ); -return -ETIMEDOUT ; -} -/** * clear_io_resource - set the IO resources as not active in the NIC * @hwdev: the NIC HW device
@@ -423,11 +379,8 @@ static int clear_io_resources(struct hinic_hwdev *hwdev)return -EINVAL ; } - err =wait_for_io_stopped (hwdev); -if (err) { -dev_err (&pdev->dev,"IO has not stopped yet\n" ); -return err; - } +/* sleep 100ms to wait for firmware stopping I/O */ +msleep (100 ); cmd_clear_io_res.func_idx =HINIC_HWIF_FUNC_IDX (hwif);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 16/232 hinic: fix wrong value of MIN_SKB_LEN
In reply to Greg Kroah-HartmanFrom: Luo bin <[email protected]>
[ Upstream commit 7296695fc16dd1761dbba8b68a9181c71cef0633 ]
the minimum value of skb len that hw supports is 32 rather than 17
--- drivers/net/ethernet/huawei/hinic/hinic_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic/hinic_tx.c +1 -1
@@ -45,7 +45,7 @@#define HW_CONS_IDX (sq) be16_to_cpu(*(u16 *)((sq)->hw_ci_addr)) -#define MIN_SKB_LEN 17 +#define MIN_SKB_LEN 32#define MAX_PAYLOAD_OFFSET 221#define TRANSPORT_OFFSET (l4_hdr, skb) ((u32)((l4_hdr) - (skb)->data))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 11/232 net: vxge: fix wrong __VA_ARGS__ usage
In reply to Greg Kroah-HartmanFrom: Zheng Wei <[email protected]>
[ Upstream commit b317538c47943f9903860d83cc0060409e12d2ff ]
printk in macro vxge_debug_ll uses __VA_ARGS__ without "##" prefix, it causes a build error when there is no variable arguments(e.g. only fmt is specified.).
--- drivers/net/ethernet/neterion/vxge/vxge-config.h | 2 +- drivers/net/ethernet/neterion/vxge/vxge-main.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/neterion/vxge/vxge-config.h +1 -1
@@ -2045,7 +2045,7 @@ vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);if ((level >=VXGE_ERR &&VXGE_COMPONENT_LL &VXGE_DEBUG_ERR_MASK ) || \ (level >=VXGE_TRACE &&VXGE_COMPONENT_LL &VXGE_DEBUG_TRACE_MASK ))\if ((mask &VXGE_DEBUG_MASK ) == mask) \ -printk (fmt"\n" , __VA_ARGS__); \ + printk(fmt "\n", ##__VA_ARGS__); \ } while (0) #else#define vxge_debug_ll (level, mask, fmt, ...)
drivers/net/ethernet/neterion/vxge/vxge-main.h +7 -7
@@ -452,49 +452,49 @@ int vxge_fw_upgrade(struct vxgedev *vdev, char *fw_name, int override);#if (VXGE_DEBUG_LL_CONFIG &VXGE_DEBUG_MASK )#define vxge_debug_ll_config (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, ##__VA_ARGS__)#else #define vxge_debug_ll_config (level, fmt, ...)#endif #if (VXGE_DEBUG_INIT &VXGE_DEBUG_MASK )#define vxge_debug_init (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, ##__VA_ARGS__)#else #define vxge_debug_init (level, fmt, ...)#endif #if (VXGE_DEBUG_TX &VXGE_DEBUG_MASK )#define vxge_debug_tx (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, ##__VA_ARGS__)#else #define vxge_debug_tx (level, fmt, ...)#endif #if (VXGE_DEBUG_RX &VXGE_DEBUG_MASK )#define vxge_debug_rx (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, ##__VA_ARGS__)#else #define vxge_debug_rx (level, fmt, ...)#endif #if (VXGE_DEBUG_MEM &VXGE_DEBUG_MASK )#define vxge_debug_mem (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, ##__VA_ARGS__)#else #define vxge_debug_mem (level, fmt, ...)#endif #if (VXGE_DEBUG_ENTRYEXIT &VXGE_DEBUG_MASK )#define vxge_debug_entryexit (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, ##__VA_ARGS__)#else #define vxge_debug_entryexit (level, fmt, ...)#endif #if (VXGE_DEBUG_INTR &VXGE_DEBUG_MASK )#define vxge_debug_intr (level, fmt, ...) \ - vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, __VA_ARGS__) + vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, ##__VA_ARGS__)#else #define vxge_debug_intr (level, fmt, ...)#endif
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 1/232 ARM: dts: sun8i-a83t-tbs-a711: HM5065 doesnt like such a high voltage
In reply to Greg Kroah-HartmanFrom: Ondrej Jirman <[email protected]>
[ Upstream commit a40550952c000667b20082d58077bc647da6c890 ]
Lowering the voltage solves the quick image degradation over time (minutes), that was probably caused by overheating.
--- arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts +2 -2
@@ -358,8 +358,8 @@ }; ®_dldo3 { - regulator-min-microvolt = <2800000>; - regulator-max-microvolt = <2800000>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; regulator-name = "vdd-csi"; };
Signature · 1 line
2.20.1
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.33 release. There are 232 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 18 Apr 2020 13:11:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.33-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 5.4.33-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.4.y
git commit: ccba204bf567bf5349e9635ea1fb8cd18d23c123
git describe: v5.4.32-233-gccba204bf567
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.4-oe/build/v5.4.32-233-gccba204bf567
No regressions (compared to build v5.4.31-42-gf163418797b9)
No fixes (compared to build v5.4.31-42-gf163418797b9)
Ran 34739 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- juno-r2-compat
- juno-r2-kasan
- nxp-ls2088
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
- x86-kasan
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* install-android-platform-tools-r2800
* libgpiod
* linux-log-parser
* ltp-cve-tests
* ltp-hugetlb-tests
* ltp-ipc-tests
* ltp-mm-tests
* ltp-sched-tests
* ltp-syscalls-tests
* kselftest
* kvm-unit-tests
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-io-tests
* ltp-math-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-securebits-tests
* network-basic-tests
* perf
* v4l2-compliance
* ltp-fs-tests
* ltp-open-posix-tests
* spectre-meltdown-checker-test
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.33 release. There are 232 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 18 Apr 2020 13:11:20 +0000. Anything received after that time might be too late.
Build results:
total: 157 pass: 157 fail: 0 Qemu test results: total: 427 pass: 427 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.33 release. There are 232 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 18 Apr 2020 13:11:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.33-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions. reboot and poweroff hang forever. The same problem I am seeing on Linux 5.7-rc1 and Linux 5.6.5-rc1 and now on 5.4.33-rc1.
I am starting bisect on 5.6.5.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.33 release. There are 232 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 18 Apr 2020 13:11:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.33-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.4:
13 builds: 13 pass, 0 fail
24 boots: 24 pass, 0 fail
40 tests: 40 pass, 0 failLinux version: 5.4.33-rc1-gccba204bf567
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic