ALSA: hda: Flush interrupts on disabling
Subsystems (34)
Sasha Levin
maintainerPATCH 147/203 ALSA: firewire-motu: add support for MOTU 4pre
In reply to Sasha LevinFrom: Takashi Sakamoto <[email protected]>
[ Upstream commit 6af86bdb8ad41f4cf1292d3b10857dc322758328 ]
MOTU 4pre was launched in 2012 by MOTU, Inc. This commit allows userspace applications can transmit and receive PCM frames and MIDI messages for this model via ALSA PCM interface and RawMidi/Sequencer interfaces.
The device supports MOTU protocol version 3. Unlike the other devices, the device is simply designed. The size of data block is fixed to 10 quadlets during available sampling rates (44.1 - 96.0 kHz). Each data block includes 1 source packet header, 2 data chunks for messages, 8 data chunks for PCM samples and 2 data chunks for padding to quadlet alignment. The device has no MIDI, optical, BNC and AES/EBU interfaces.
Like support for the other MOTU devices, the quality of playback sound is not enough good with periodical noise yet.
$ python2 crpp < ~/git/am-config-rom/motu/motu-4pre.img
ROM header and bus information block
-----------------------------------------------------------------
400 041078cc bus_info_length 4, crc_length 16, crc 30924
404 31333934 bus_name "1394"
408 20ff7000 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 255, max_rec 7 (256)
40c 0001f200 company_id 0001f2 |
410 000a41c5 device_id 00000a41c5 | EUI-64 0001f200000a41c5 root directory
-----------------------------------------------------------------
414 0004ef04 directory_length 4, crc 61188
418 030001f2 vendor
41c 0c0083c0 node capabilities per IEEE 1394
420 d1000002 --> unit directory at 428
424 8d000005 --> eui-64 leaf at 438 unit directory at 428
-----------------------------------------------------------------
428 0003ceda directory_length 3, crc 52954 42c 120001f2 specifier id 430 13000045 version 434 17103800 model
eui-64 leaf at 438
-----------------------------------------------------------------
438 0002d248 leaf_length 2, crc 53832
43c 0001f200 company_id 0001f2 |
440 000a41c5 device_id 00000a41c5 | EUI-64 0001f200000a41c5--- sound/firewire/motu/motu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/firewire/motu/motu.c +12 -0
@@ -247,6 +247,17 @@ static const struct snd_motu_spec motu_audio_express = { .analog_out_ports = 4, }; +static const struct snd_motu_spec motu_4pre = { + .name ="4pre" , + .protocol = &snd_motu_protocol_v3, + .flags =SND_MOTU_SPEC_SUPPORT_CLOCK_X2 | +SND_MOTU_SPEC_TX_MICINST_CHUNK | +SND_MOTU_SPEC_TX_RETURN_CHUNK | +SND_MOTU_SPEC_RX_SEPARETED_MAIN , + .analog_in_ports =2 , + .analog_out_ports =2 , +}; +#define SND_MOTU_DEV_ENTRY (model, data) \ { \ .match_flags = IEEE1394_MATCH_VENDOR_ID | \
@@ -265,6 +276,7 @@ static const struct ieee1394_device_id motu_id_table[] = {SND_MOTU_DEV_ENTRY (0x000015 , &motu_828mk3),/* FireWire only. */ SND_MOTU_DEV_ENTRY (0x000035 , &motu_828mk3),/* Hybrid. */ SND_MOTU_DEV_ENTRY (0x000033 , &motu_audio_express), +SND_MOTU_DEV_ENTRY (0x000045 , &motu_4pre), { } };MODULE_DEVICE_TABLE (ieee1394, motu_id_table);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 148/203 arm64: lse: Make ARM64_LSE_ATOMICS depend on JUMP_LABEL
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit b32baf91f60fb9c7010bff87e68132f2ce31d9a8 ]
Support for LSE atomic instructions (CONFIG_ARM64_LSE_ATOMICS) relies on a static key to select between the legacy LL/SC implementation which is available on all arm64 CPUs and the super-duper LSE implementation which is available on CPUs implementing v8.1 and later.
Unfortunately, when building a kernel with CONFIG_JUMP_LABEL disabled (e.g. because the toolchain doesn't support 'asm goto'), the static key inside the atomics code tries to use atomics itself. This results in a mess of circular includes and a build failure:
In file included from ./arch/arm64/include/asm/lse.h:11,
from ./arch/arm64/include/asm/atomic.h:16,
from ./include/linux/atomic.h:7,
from ./include/asm-generic/bitops/atomic.h:5,
from ./arch/arm64/include/asm/bitops.h:26,
from ./include/linux/bitops.h:19,
from ./include/linux/kernel.h:12,
from ./include/asm-generic/bug.h:18,
from ./arch/arm64/include/asm/bug.h:26,
from ./include/linux/bug.h:5,
from ./include/linux/page-flags.h:10,
from kernel/bounds.c:10:
./include/linux/jump_label.h: In function ‘static_key_count’:
./include/linux/jump_label.h:254:9: error: implicit declaration of function ‘atomic_read’ [-Werror=implicit-function-declaration]
return atomic_read(&key->enabled);
^~~~~~~~~~~[ ... more of the same ... ]
Since LSE atomic instructions are not critical to the operation of the kernel, make them depend on JUMP_LABEL at compile time.
--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -1263,6 +1263,7 @@ config ARM64_PAN config ARM64_LSE_ATOMICS bool "Atomic instructions" + depends on JUMP_LABEL default y help As part of the Large System Extensions, ARMv8.1 introduces new
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 149/203 iommu/amd: Silence warnings under memory pressure
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 3d708895325b78506e8daf00ef31549476e8586a ]
When running heavy memory pressure workloads, the system is throwing endless warnings,
smartpqi 0000:23:00.0: AMD-Vi: IOMMU mapping error in map_sg (io-pages:
5 reason: -12)
Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019 swapper/10: page allocation failure: order:0, mode:0xa20(GFP_ATOMIC), nodemask=(null),cpuset=/,mems_allowed=0,4 Call Trace: <IRQ> dump_stack+0x62/0x9a warn_alloc.cold.43+0x8a/0x148 __alloc_pages_nodemask+0x1a5c/0x1bb0 get_zeroed_page+0x16/0x20 iommu_map_page+0x477/0x540 map_sg+0x1ce/0x2f0 scsi_dma_map+0xc6/0x160 pqi_raid_submit_scsi_cmd_with_io_request+0x1c3/0x470 [smartpqi] do_IRQ+0x81/0x170 common_interrupt+0xf/0xf </IRQ>
because the allocation could fail from iommu_map_page(), and the volume of this call could be huge which may generate a lot of serial console output and cosumes all CPUs.
Fix it by silencing the warning in this call site, and there is still a dev_err() later to notify the failure.
--- drivers/iommu/amd_iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/amd_iommu.c +3 -1
@@ -2577,7 +2577,9 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, bus_addr = address + s->dma_address + (j <<PAGE_SHIFT ); phys_addr = (sg_phys (s) &PAGE_MASK ) + (j <<PAGE_SHIFT ); - ret =iommu_map_page (domain, bus_addr, phys_addr,PAGE_SIZE , prot,GFP_ATOMIC ); + ret =iommu_map_page (domain, bus_addr, phys_addr, +PAGE_SIZE , prot, +GFP_ATOMIC | __GFP_NOWARN);if (ret) goto out_unmap;
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 150/203 ASoC: Intel: Haswell: Adjust machine device private context
In reply to Sasha LevinFrom: Cezary Rojewski <[email protected]>
[ Upstream commit ca964edf0ddbfec2cb10b3d251d09598e7ca9b13 ]
Apart from Haswell machines, all other devices have their private data set to snd_soc_acpi_mach instance.
Changes for HSW/ BDW boards introduced with series:
https://patchwork.kernel.org/cover/10782035/
added support for dai_link platform_name adjustments within card probe routines. These take for granted private_data points to snd_soc_acpi_mach whereas for Haswell, it's sst_pdata instead. Change private context of platform_device - representing machine board - to address this.
--- sound/soc/intel/common/sst-acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/common/sst-acpi.c +2 -1
@@ -141,11 +141,12 @@ static int sst_acpi_probe(struct platform_device *pdev) }platform_set_drvdata (pdev, sst_acpi); + mach->pdata = sst_pdata;/* register machine driver */ sst_acpi->pdev_mach =platform_device_register_data (dev, mach->drv_name,-1 , - sst_pdata,sizeof (*sst_pdata)); + mach,sizeof (*mach));if (IS_ERR (sst_acpi->pdev_mach))return PTR_ERR (sst_acpi->pdev_mach);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 151/203 libata/ahci: Drop PCS quirk for Denverton and beyond
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
[ Upstream commit c312ef176399e04fc5f7f2809d9a589751fbf6d9 ]
The Linux ahci driver has historically implemented a configuration fixup for platforms / platform-firmware that fails to enable the ports prior to OS hand-off at boot. The fixup was originally implemented way back before ahci moved from drivers/scsi/ to drivers/ata/, and was updated in 2007 via commit 49f290903935 "ahci: update PCS programming". The quirk sets a port-enable bitmap in the PCS register at offset 0x92.
This quirk could be applied generically up until the arrival of the Denverton (DNV) platform. The DNV AHCI controller architecture supports more than 6 ports and along with that the PCS register location and format were updated to allow for more possible ports in the bitmap. DNV AHCI expands the register to 32-bits and moves it to offset 0x94.
As it stands there are no known problem reports with existing Linux trying to set bits at offset 0x92 which indicates that the quirk is not applicable. Likely it is not applicable on a wider range of platforms, but it is difficult to discern which platforms if any still depend on the quirk.
Rather than try to fix the PCS quirk to consider the DNV register layout instead require explicit opt-in. The assumption is that the OS driver need not touch this register, and platforms can be added with a new boad_ahci_pcs7 board-id when / if problematic platforms are found in the future. The logic in ahci_intel_pcs_quirk() looks for all Intel AHCI instances with "legacy" board-ids and otherwise skips the quirk if the board was matched by class-code.
--- drivers/ata/ahci.c | 116 +++++++++++++++++++++++++++------------------ drivers/ata/ahci.h | 2 + 2 files changed, 71 insertions(+), 47 deletions(-)
drivers/ata/ahci.c +69 -47
@@ -65,6 +65,12 @@ enum board_ids { board_ahci_sb700,/* for SB700 and SB800 */ board_ahci_vt8251, +/* +* board IDs for Intel chipsets that support more than 6 ports +* *and* end up needing the PCS quirk. +*/ + board_ahci_pcs7, +/* aliases */ board_ahci_mcp_linux = board_ahci_mcp65, board_ahci_mcp67 = board_ahci_mcp65,
@@ -220,6 +226,12 @@ static const struct ata_port_info ahci_port_info[] = { .udma_mask = ATA_UDMA6, .port_ops = &ahci_vt8251_ops, }, + [board_ahci_pcs7] = { + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_ops, + }, }; static const struct pci_device_id ahci_pci_tbl[] = {
@@ -264,26 +276,26 @@ static const struct pci_device_id ahci_pci_tbl[] = { { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci_mobile }, /* PCH M RAID */ { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ - { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */ - { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b0), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b1), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b2), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b3), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b4), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b5), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b6), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b7), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bE), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bF), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c0), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c1), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c2), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c3), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c4), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c5), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c6), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c7), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cE), board_ahci_pcs7 }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cF), board_ahci_pcs7 }, /* DNV AHCI */ { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ { PCI_VDEVICE(INTEL, 0x1c03), board_ahci_mobile }, /* CPT M AHCI */ { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
@@ -623,30 +635,6 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev,ahci_save_initial_config (&pdev->dev, hpriv); } -static int ahci_pci_reset_controller (struct ata_host *host) -{ -struct pci_dev *pdev =to_pci_dev (host->dev); -int rc; - - rc =ahci_reset_controller (host); -if (rc) -return rc; - -if (pdev->vendor ==PCI_VENDOR_ID_INTEL ) { -struct ahci_host_priv *hpriv = host->private_data; -u16 tmp16; - -/* configure PCS */ -pci_read_config_word (pdev,0x92 , &tmp16); -if ((tmp16 & hpriv->port_map) != hpriv->port_map) { - tmp16 |= hpriv->port_map; -pci_write_config_word (pdev,0x92 , tmp16); - } - } - -return 0 ; -} -static void ahci_pci_init_controller (struct ata_host *host) {struct ahci_host_priv *hpriv = host->private_data;
@@ -849,7 +837,7 @@ static int ahci_pci_device_runtime_resume(struct device *dev)struct ata_host *host =pci_get_drvdata (pdev);int rc; - rc =ahci_pci_reset_controller (host); + rc =ahci_reset_controller (host);if (rc)return rc;ahci_pci_init_controller (host);
@@ -884,7 +872,7 @@ static int ahci_pci_device_resume(struct device *dev)ahci_mcp89_apple_enable (pdev);if (pdev->dev.power.power_state.event ==PM_EVENT_SUSPEND ) { - rc =ahci_pci_reset_controller (host); + rc =ahci_reset_controller (host);if (rc)return rc;
@@ -1619,6 +1607,34 @@ static void ahci_update_initial_lpm_policy(struct ata_port *ap, ap->target_lpm_policy = policy; } +static void ahci_intel_pcs_quirk (struct pci_dev *pdev,struct ahci_host_priv *hpriv) +{ +const struct pci_device_id *id =pci_match_id (ahci_pci_tbl, pdev); +u16 tmp16; + +/* +* Only apply the 6-port PCS quirk for known legacy platforms. +*/ +if (!id || id->vendor !=PCI_VENDOR_ID_INTEL ) +return ; +if (((enum board_ids ) id->driver_data) < board_ahci_pcs7) +return ; + +/* +* port_map is determined from PORTS_IMPL PCI register which is +* implemented as write or write-once register. If the register +* isn't programmed, ahci automatically generates it from number +* of ports, which is good enough for PCS programming. It is +* otherwise expected that platform firmware enables the ports +* before the OS boots. +*/ +pci_read_config_word (pdev,PCS_6 , &tmp16); +if ((tmp16 & hpriv->port_map) != hpriv->port_map) { + tmp16 |= hpriv->port_map; +pci_write_config_word (pdev,PCS_6 , tmp16); + } +} +static int ahci_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {unsigned int board_id = ent->driver_data;
@@ -1731,6 +1747,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)/* save initial config */ ahci_pci_save_initial_config (pdev, hpriv); +/* +* If platform firmware failed to enable ports, try to enable +* them here. +*/ +ahci_intel_pcs_quirk (pdev, hpriv); +/* prepare host */ if (hpriv->cap &HOST_CAP_NCQ ) { pi.flags |=ATA_FLAG_NCQ ;
@@ -1840,7 +1862,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc)return rc; - rc =ahci_pci_reset_controller (host); + rc =ahci_reset_controller (host);if (rc)return rc;
drivers/ata/ahci.h +2 -0
@@ -247,6 +247,8 @@ enum {ATA_FLAG_ACPI_SATA |ATA_FLAG_AN ,ICH_MAP =0x90 ,/* ICH MAP register */ +PCS_6 =0x92 ,/* 6 port PCS */ +PCS_7 =0x94 ,/* 7+ port PCS (Denverton) */ /* em constants */ EM_MAX_SLOTS = 8,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 152/203 iommu/iova: Avoid false sharing on fq_timer_on
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 0d87308cca2c124f9bce02383f1d9632c9be89c4 ]
In commit 14bd9a607f90 ("iommu/iova: Separate atomic variables to improve performance") Jinyu Qi identified that the atomic_cmpxchg() in queue_iova() was causing a performance loss and moved critical fields so that the false sharing would not impact them.
However, avoiding the false sharing in the first place seems easy. We should attempt the atomic_cmpxchg() no more than 100 times per second. Adding an atomic_read() will keep the cache line mostly shared.
This false sharing came with commit 9a005a800ae8
("iommu/iova: Add flush timer").
--- drivers/iommu/iova.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/iova.c +3 -1
@@ -577,7 +577,9 @@ void queue_iova(struct iova_domain *iovad,spin_unlock_irqrestore (&fq->lock, flags); -if (atomic_cmpxchg (&iovad->fq_timer_on,0 ,1 ) ==0 ) +/* Avoid false sharing as much as possible. */ +if (!atomic_read (&iovad->fq_timer_on) && + !atomic_cmpxchg (&iovad->fq_timer_on,0 ,1 ))mod_timer (&iovad->fq_timer, jiffies +msecs_to_jiffies (IOVA_FQ_TIMEOUT )); }
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 153/203 libtraceevent: Change users plugin directory
In reply to Sasha LevinFrom: Tzvetomir Stoyanov <[email protected]>
[ Upstream commit e97fd1383cd77c467d2aed7fa4e596789df83977 ]
To be compliant with XDG user directory layout, the user's plugin directory is changed from ~/.traceevent/plugins to ~/.local/lib/traceevent/plugins/
--- tools/lib/traceevent/Makefile | 6 +++--- tools/lib/traceevent/event-plugin.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/traceevent/Makefile +3 -3
@@ -62,15 +62,15 @@ set_plugin_dir := 1 # Set plugin_dir to preffered global plugin location # If we install under $HOME directory we go under -# $(HOME)/.traceevent/plugins +# $(HOME)/.local/lib/traceevent/plugins # # We dont set PLUGIN_DIR in case we install under $HOME # directory, because by default the code looks under: -# $(HOME)/.traceevent/plugins by default. +# $(HOME)/.local/lib/traceevent/plugins by default. # ifeq ($(plugin_dir),) ifeq ($(prefix),$(HOME)) -override plugin_dir = $(HOME)/.traceevent/plugins +override plugin_dir = $(HOME)/.local/lib/traceevent/plugins set_plugin_dir := 0 else override plugin_dir = $(libdir)/traceevent/plugins
tools/lib/traceevent/event-plugin.c +1 -1
@@ -18,7 +18,7 @@#include "event-utils.h" #include "trace-seq.h" -#define LOCAL_PLUGIN_DIR ".traceevent/plugins" +#define LOCAL_PLUGIN_DIR ".local/lib/traceevent/plugins/" static struct registered_plugin_options { struct registered_plugin_options *next;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 154/203 ASoC: dt-bindings: sun4i-spdif: Fix dma-names warning
In reply to Sasha LevinFrom: Maxime Ripard <[email protected]>
[ Upstream commit 1a8e7cdfa4f5872bf0c202d09bff6628aba6b9f6 ]
Even though the H6 compatible has been properly added, the exeption for the number of DMA channels hasn't been updated, leading in a validation warning.
Fix this.
--- .../devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml +3 -1
@@ -70,7 +70,9 @@ allOf: properties: compatible: contains: - const: allwinner,sun8i-h3-spdif + enum: + - allwinner,sun8i-h3-spdif + - allwinner,sun50i-h6-spdif then: properties:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 155/203 ARM: dts: exynos: Mark LDO10 as always-on on Peach Pit/Pi Chromebooks
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 5b0eeeaa37615df37a9a30929b73e9defe61ca84 ]
Commit aff138bf8e37 ("ARM: dts: exynos: Add TMU nodes regulator supply for Peach boards") assigned LDO10 to Exynos Thermal Measurement Unit, but it turned out that it supplies also some other critical parts and board freezes/crashes when it is turned off.
The mentioned commit made Exynos TMU a consumer of that regulator and in typical case Exynos TMU driver keeps it enabled from early boot. However there are such configurations (example is multi_v7_defconfig), in which some of the regulators are compiled as modules and are not available from early boot. In such case it may happen that LDO10 is turned off by regulator core, because it has no consumers yet (in this case consumer drivers cannot get it, because the supply regulators for it are not yet available). This in turn causes the board to crash. This patch restores 'always-on' property for the LDO10 regulator.
--- arch/arm/boot/dts/exynos5420-peach-pit.dts | 1 + arch/arm/boot/dts/exynos5800-peach-pi.dts | 1 + 2 files changed, 2 insertions(+)
arch/arm/boot/dts/exynos5420-peach-pit.dts +1 -0
@@ -440,6 +440,7 @@ regulator-name = "vdd_ldo10"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; + regulator-always-on; regulator-state-mem { regulator-off-in-suspend; };
arch/arm/boot/dts/exynos5800-peach-pi.dts +1 -0
@@ -440,6 +440,7 @@ regulator-name = "vdd_ldo10"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; + regulator-always-on; regulator-state-mem { regulator-off-in-suspend; };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 156/203 x86/amd_nb: Add PCI device IDs for family 17h, model 70h
In reply to Sasha LevinFrom: Marcel Bocu <[email protected]>
[ Upstream commit af4e1c5eca95bed1192d8dc45c8ed63aea2209e8 ]
The AMD Ryzen gen 3 processors came with a different PCI IDs for the function 3 & 4 which are used to access the SMN interface. The root PCI address however remained at the same address as the model 30h.
Adding the F3/F4 PCI IDs respectively to the misc and link ids appear to be sufficient for k10temp, so let's add them and follow up on the patch if other functions need more tweaking.
Vicki Pfau sent an identical patch after I checked that no-one had written this patch. I would have been happy about dropping my patch but unlike for his patch series, I had already Cc:ed the x86 people and they already reviewed the changes. Since Vicki has not answered to any email after his initial series, let's assume she is on vacation and let's avoid duplication of reviews from the maintainers and merge my series. To acknowledge Vicki's anteriority, I added her S-o-b to the patch.
v2, suggested by Guenter Roeck and Brian Woods:
- rename from 71h to 70h
--- arch/x86/kernel/amd_nb.c | 3 +++ include/linux/pci_ids.h | 1 + 2 files changed, 4 insertions(+)
arch/x86/kernel/amd_nb.c +3 -0
@@ -21,6 +21,7 @@#define PCI_DEVICE_ID_AMD_17H_DF_F4 0x1464#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F4 0x15ec#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F4 0x1494 +#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F4 0x1444/* Protect the PCI config register pairs used for SMN and DF indirect access. */ static DEFINE_MUTEX (smn_mutex);
@@ -50,6 +51,7 @@ const struct pci_device_id amd_nb_misc_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) }, {} };EXPORT_SYMBOL_GPL (amd_nb_misc_ids);
@@ -63,6 +65,7 @@ static const struct pci_device_id amd_nb_link_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) }, {} };
include/linux/pci_ids.h +1 -0
@@ -548,6 +548,7 @@#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F3 0x1493 +#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F3 0x1443#define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703#define PCI_DEVICE_ID_AMD_LANCE 0x2000#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 157/203 ACPI: custom_method: fix memory leaks
In reply to Sasha LevinFrom: Wenwen Wang <[email protected]>
[ Upstream commit 03d1571d9513369c17e6848476763ebbd10ec2cb ]
In cm_write(), 'buf' is allocated through kzalloc(). In the following execution, if an error occurs, 'buf' is not deallocated, leading to memory leaks. To fix this issue, free 'buf' before returning the error.
--- drivers/acpi/custom_method.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/custom_method.c +4 -1
@@ -49,8 +49,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,if ((*ppos > max_size) || (*ppos + count > max_size) || (*ppos + count < count) || - (count > uncopied_bytes)) + (count > uncopied_bytes)) { +kfree (buf);return -EINVAL ; + }if (copy_from_user (buf + (*ppos), user_buf, count)) {kfree (buf);
@@ -70,6 +72,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,add_taint (TAINT_OVERRIDDEN_ACPI_TABLE ,LOCKDEP_NOW_UNRELIABLE ); } +kfree (buf);return count; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 158/203 ACPI / PCI: fix acpi_pci_irq_enable() memory leak
In reply to Sasha LevinFrom: Wenwen Wang <[email protected]>
[ Upstream commit 29b49958cf73b439b17fa29e9a25210809a6c01c ]
In acpi_pci_irq_enable(), 'entry' is allocated by kzalloc() in acpi_pci_irq_check_entry() (invoked from acpi_pci_irq_lookup()). However, it is not deallocated if acpi_pci_irq_valid() returns false, leading to a memory leak. To fix this issue, free 'entry' before returning 0.
--- drivers/acpi/pci_irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/pci_irq.c +3 -1
@@ -449,8 +449,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)* No IRQ known to the ACPI subsystem - maybe the BIOS / * driver reported one, then use it. Exit in any case. */ -if (!acpi_pci_irq_valid (dev, pin)) +if (!acpi_pci_irq_valid (dev, pin)) { +kfree (entry);return 0 ; + }if (acpi_isa_register_gsi (dev)) dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 159/203 closures: fix a race on wakeup from closure_sync
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
[ Upstream commit a22a9602b88fabf10847f238ff81fde5f906fef7 ]
The race was when a thread using closure_sync() notices cl->s->done == 1 before the thread calling closure_put() calls wake_up_process(). Then, it's possible for that thread to return and exit just before wake_up_process() is called - so we're trying to wake up a process that no longer exists.
rcu_read_lock() is sufficient to protect against this, as there's an rcu barrier somewhere in the process teardown path.
--- drivers/md/bcache/closure.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/md/bcache/closure.c +8 -2
@@ -105,8 +105,14 @@ struct closure_syncer {static void closure_sync_fn (struct closure *cl) { - cl->s->done =1 ; -wake_up_process (cl->s->task); +struct closure_syncer *s = cl->s; +struct task_struct *p; + +rcu_read_lock (); + p =READ_ONCE (s->task); + s->done =1 ; +wake_up_process (p); +rcu_read_unlock (); } void __sched __closure_sync(struct closure *cl)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 160/203 hwmon: (k10temp) Add support for AMD family 17h, model 70h CPUs
In reply to Sasha LevinFrom: Marcel Bocu <[email protected]>
[ Upstream commit 12163cfbfc0f804cc7d27bc20e8d266ce7459260 ]
It would seem like model 70h is behaving in the same way as model 30h, so let's just add the new F3 PCI ID to the list of compatible devices.
Unlike previous Ryzen/Threadripper, Ryzen gen 3 processors do not need temperature offsets anymore. This has been reported in the press and verified on my Ryzen 3700X by checking that the idle temperature reported by k10temp is matching the temperature reported by the firmware.
Vicki Pfau sent an identical patch after I checked that no-one had written this patch. I would have been happy about dropping my patch but unlike for his patch series, I had already Cc:ed the x86 people and they already reviewed the changes. Since Vicki has not answered to any email after his initial series, let's assume she is on vacation and let's avoid duplication of reviews from the maintainers and merge my series. To acknowledge Vicki's anteriority, I added her S-o-b to the patch.
v2, suggested by Guenter Roeck and Brian Woods:
- rename from 71h to 70h
--- drivers/hwmon/k10temp.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/k10temp.c +1 -0
@@ -349,6 +349,7 @@ static const struct pci_device_id k10temp_id_table[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) }, + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) }, { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 161/203 hwmon: (acpi_power_meter) Change log level for 'unsafe software power cap'
In reply to Sasha LevinFrom: Wang Shenran <[email protected]>
[ Upstream commit 6e4d91aa071810deac2cd052161aefb376ecf04e ]
At boot time, the acpi_power_meter driver logs the following error level
message: "Ignoring unsafe software power cap". Having read about it from a few sources, it seems that the error message can be quite misleading.
While the message can imply that Linux is ignoring the fact that the system is operating in potentially dangerous conditions, the truth is the driver found an ACPI_PMC object that supports software power capping. The driver simply decides not to use it, perhaps because it doesn't support the object.
The best solution is probably changing the log level from error to warning. All sources I have found, regarding the error, have downplayed its significance. There is not much of a reason for it to be on error level, while causing potential confusions or misinterpretations.
--- drivers/hwmon/acpi_power_meter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/acpi_power_meter.c +2 -2
@@ -681,8 +681,8 @@ static int setup_attrs(struct acpi_power_meter_resource *resource)if (resource->caps.flags &POWER_METER_CAN_CAP ) {if (!can_cap_in_hardware ()) { -dev_err (&resource->acpi_dev->dev, -"Ignoring unsafe software power cap!\n" ); +dev_warn (&resource->acpi_dev->dev, +"Ignoring unsafe software power cap!\n" ); goto skip_unsafe_cap; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 162/203 md/raid1: fail run raid1 array when active disk less than one
In reply to Sasha LevinFrom: Yufen Yu <[email protected]>
[ Upstream commit 07f1a6850c5d5a65c917c3165692b5179ac4cb6b ]
When run test case:
mdadm -CR /dev/md1 -l 1 -n 4 /dev/sd[a-d] --assume-clean --bitmap=internal mdadm -S /dev/md1
mdadm -A /dev/md1 /dev/sd[b-c] --run --force
mdadm --zero /dev/sda mdadm /dev/md1 -a /dev/sda
echo offline > /sys/block/sdc/device/state
echo offline > /sys/block/sdb/device/state
sleep 5
mdadm -S /dev/md1
echo running > /sys/block/sdb/device/state echo running > /sys/block/sdc/device/state mdadm -A /dev/md1 /dev/sd[a-c] --run --force
mdadm run fail with kernel message as follow:
[ 172.986064] md: kicking non-fresh sdb from array! [ 173.004210] md: kicking non-fresh sdc from array! [ 173.022383] md/raid1:md1: active with 0 out of 4 mirrors [ 173.022406] md1: failed to create bitmap (-5)
In fact, when active disk in raid1 array less than one, we need to return fail in raid1_run().
--- drivers/md/raid1.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/md/raid1.c +12 -1
@@ -3129,6 +3129,13 @@ static int raid1_run(struct mddev *mddev) !test_bit (In_sync, &conf->mirrors[i].rdev->flags) || test_bit(Faulty, &conf->mirrors[i].rdev->flags)) mddev->degraded++; +/* +* RAID1 needs at least one disk in active +*/ +if (conf->raid_disks - mddev->degraded <1 ) { + ret = -EINVAL ; + goto abort; + }if (conf->raid_disks - mddev->degraded ==1 ) mddev->recovery_cp = MaxSector;
@@ -3162,8 +3169,12 @@ static int raid1_run(struct mddev *mddev) ret =md_integrity_register (mddev);if (ret) {md_unregister_thread (&mddev->thread); -raid1_free (mddev, conf); + goto abort; } +return 0 ; + +abort: +raid1_free (mddev, conf);return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 163/203 dmaengine: ti: edma: Do not reset reserved paRAM slots
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit c5dbe60664b3660f5ac5854e21273ea2e7ff698f ]
Skip resetting paRAM slots marked as reserved as they might be used by other cores.
--- drivers/dma/ti/edma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/dma/ti/edma.c +6 -3
@@ -2273,9 +2273,6 @@ static int edma_probe(struct platform_device *pdev) ecc->default_queue = info->default_queue; -for (i =0 ; i < ecc->num_slots; i++) -edma_write_slot (ecc, i, &dummy_paramset); -if (info->rsv) {/* Set the reserved slots in inuse list */ rsv_slots = info->rsv->rsv_slots;
@@ -2288,6 +2285,12 @@ static int edma_probe(struct platform_device *pdev) } } +for (i =0 ; i < ecc->num_slots; i++) { +/* Reset only unused - not reserved - paRAM slots */ +if (!test_bit (i, ecc->slot_inuse)) +edma_write_slot (ecc, i, &dummy_paramset); + } +/* Clear the xbar mapped channels in unused list */ xbar_chans = info->xbar_chans;if (xbar_chans) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 164/203 kprobes: Prohibit probing on BUG() and WARN() address
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit e336b4027775cb458dc713745e526fa1a1996b2a ]
Since BUG() and WARN() may use a trap (e.g. UD2 on x86) to get the address where the BUG() has occurred, kprobes can not do single-step out-of-line that instruction. So prohibit probing on such address.
Without this fix, if someone put a kprobe on WARN(), the kernel will crash with invalid opcode error instead of outputing warning message, because kernel can not find correct bug address.
--- include/linux/bug.h | 5 +++++ kernel/kprobes.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
include/linux/bug.h +5 -0
@@ -47,6 +47,11 @@ void generic_bug_clear_once(void);#else /* !CONFIG_GENERIC_BUG */ +static inline void *find_bug (unsigned long bugaddr) +{ +return NULL ; +} +static inline enum bug_trap_type report_bug (unsigned long bug_addr,struct pt_regs *regs) {
kernel/kprobes.c +2 -1
@@ -1514,7 +1514,8 @@ static int check_kprobe_address_safe(struct kprobe *p,/* Ensure it is not in reserved area nor out of text */ if (!kernel_text_address ((unsigned long ) p->addr) ||within_kprobe_blacklist ((unsigned long ) p->addr) || -jump_label_text_reserved (p->addr, p->addr)) { +jump_label_text_reserved (p->addr, p->addr) || +find_bug ((unsigned long )p->addr)) { ret = -EINVAL ; goto out; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 165/203 x86/mm: Fix cpumask_of_node() error condition
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit bc04a049f058a472695aa22905d57e2b1f4c77d9 ]
When CONFIG_DEBUG_PER_CPU_MAPS=y we validate that the @node argument of cpumask_of_node() is a valid node_id. It however forgets to check for negative numbers. Fix this by explicitly casting to unsigned int.
(unsigned)node >= nr_node_ids
verifies: 0 <= node < nr_node_ids
Also ammend the error message to match the condition.
--- arch/x86/mm/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/numa.c +2 -2
@@ -861,9 +861,9 @@ void numa_remove_cpu(int cpu)*/ const struct cpumask *cpumask_of_node (int node) { -if (node >= nr_node_ids) { +if ((unsigned )node >= nr_node_ids) {printk (KERN_WARNING -"cpumask_of_node(%d): node > nr_node_ids(%u)\n" , +"cpumask_of_node(%d): (unsigned)node >= nr_node_ids(%u)\n" , node, nr_node_ids);dump_stack ();return cpu_none_mask;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 166/203 irqchip/sifive-plic: set max threshold for ignored handlers
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 9ce06497c2722a0f9109e4cc3ce35b7a69617886 ]
When running in M-mode, the S-mode plic handlers are still listed in the device tree. Ignore them by setting the maximum threshold.
--- drivers/irqchip/irq-sifive-plic.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/irqchip/irq-sifive-plic.c +10 -2
@@ -244,6 +244,7 @@ static int __init plic_init(struct device_node *node,struct plic_handler *handler;irq_hw_number_t hwirq;int cpu, hartid; +u32 threshold =0 ;if (of_irq_parse_one (node, i, &parent)) {pr_err ("failed to parse parent for context %d.\n" , i);
@@ -266,10 +267,16 @@ static int __init plic_init(struct device_node *node,continue ; } +/* +* When running in M-mode we need to ignore the S-mode handler. +* Here we assume it always comes later, but that might be a +* little fragile. +*/ handler =per_cpu_ptr (&plic_handlers, cpu);if (handler->present) {pr_warn ("handler already present for context %d.\n" , i); -continue ; + threshold =0xffffffff ; + goto done; } handler->present = true;
@@ -279,8 +286,9 @@ static int __init plic_init(struct device_node *node, handler->enable_base = plic_regs +ENABLE_BASE + i *ENABLE_PER_HART ; +done:/* priority must be > threshold to trigger an interrupt */ -writel (0 , handler->hart_base +CONTEXT_THRESHOLD ); +writel (threshold, handler->hart_base +CONTEXT_THRESHOLD );for (hwirq =1 ; hwirq <= nr_irqs; hwirq++)plic_toggle (handler, hwirq,0 ); nr_handlers++;
Signature · 7 lines
2.20.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Sasha Levin
maintainerPATCH 167/203 s390/crypto: xts-aes-s390 fix extra run-time crypto self tests finding
In reply to Sasha LevinFrom: Harald Freudenberger <[email protected]>
[ Upstream commit 9e323d45ba94262620a073a3f9945ca927c07c71 ]
With 'extra run-time crypto self tests' enabled, the selftest for s390-xts fails with
alg: skcipher: xts-aes-s390 encryption unexpectedly succeeded on test vector "random: len=0 klen=64"; expected_error=-22, cfg="random: inplace use_digest nosimd src_divs=[2.61%@+4006, 84.44%@+21, 1.55%@+13, 4.50%@+344, 4.26%@+21, 2.64%@+27]"
This special case with nbytes=0 is not handled correctly and this fix now makes sure that -EINVAL is returned when there is en/decrypt called with 0 bytes to en/decrypt.
--- arch/s390/crypto/aes_s390.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/crypto/aes_s390.c +6 -0
@@ -586,6 +586,9 @@ static int xts_aes_encrypt(struct blkcipher_desc *desc,struct s390_xts_ctx *xts_ctx =crypto_blkcipher_ctx (desc->tfm);struct blkcipher_walk walk; +if (!nbytes) +return -EINVAL ; +if (unlikely (!xts_ctx->fc))return xts_fallback_encrypt (desc, dst, src, nbytes);
@@ -600,6 +603,9 @@ static int xts_aes_decrypt(struct blkcipher_desc *desc,struct s390_xts_ctx *xts_ctx =crypto_blkcipher_ctx (desc->tfm);struct blkcipher_walk walk; +if (!nbytes) +return -EINVAL ; +if (unlikely (!xts_ctx->fc))return xts_fallback_decrypt (desc, dst, src, nbytes);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 168/203 irqchip/gic-v3-its: Fix LPI release for Multi-MSI devices
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit c9c96e30ecaa0aafa225aa1a5392cb7db17c7a82 ]
When allocating a range of LPIs for a Multi-MSI capable device, this allocation extended to the closest power of 2.
But on the release path, the interrupts are released one by one. This results in not releasing the "extra" range, leaking the its_device. Trying to reprobe the device will then fail.
Fix it by releasing the LPIs the same way we allocate them.
--- drivers/irqchip/irq-gic-v3-its.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +4 -5
@@ -2641,14 +2641,13 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,struct its_node *its = its_dev->its;int i; +bitmap_release_region (its_dev->event_map.lpi_map, +its_get_event_id (irq_domain_get_irq_data (domain, virq)), +get_count_order (nr_irqs)); +for (i =0 ; i < nr_irqs; i++) {struct irq_data *data =irq_domain_get_irq_data (domain, virq + i); -u32 event =its_get_event_id (data); - -/* Mark interrupt index as unused */ -clear_bit (event, its_dev->event_map.lpi_map); -/* Nuke the entry in the domain */ irq_domain_reset_irq_data (data); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 169/203 x86/platform/uv: Fix kmalloc() NULL check routine
In reply to Sasha LevinFrom: Austin Kim <[email protected]>
[ Upstream commit 864b23f0169d5bff677e8443a7a90dfd6b090afc ]
The result of kmalloc() should have been checked ahead of below statement:
pqp = (struct bau_pq_entry *)vp;
Move BUG_ON(!vp) before above statement.
--- arch/x86/platform/uv/tlb_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/platform/uv/tlb_uv.c +2 -2
@@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode) plsize = (DEST_Q_SIZE +1 ) *sizeof (struct bau_pq_entry ); vp =kmalloc_node (plsize,GFP_KERNEL , node); - pqp = (struct bau_pq_entry *)vp; -BUG_ON (!pqp); +BUG_ON (!vp); + pqp = (struct bau_pq_entry *)vp; cp = (char *)pqp +31 ; pqp = (struct bau_pq_entry *)(((unsigned long )cp >>5 ) <<5 );
Signature · 1 line
2.20.1
Greg KH
maintainerRe: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine
Quoted 41 lines · Sasha Levin
From: Austin Kim <[email protected]>
[ Upstream commit
864b23f0169d5bff677e8443a7a90dfd6b090afc]The result of
kmalloc()should have been checked ahead of below statement:pqp = (struct bau_pq_entry *)vp;Move
BUG_ON(!vp)before above statement.Signed-off-by Austin Kim <[email protected]>Cc Dimitri Sivanich <[email protected]>Cc Hedi Berriche <[email protected]>Cc Linus Torvalds <[email protected]>Cc Mike Travis <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Russ Anderson <[email protected]>Cc Steve Wahl <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/x86/platform/uv/tlb_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/platform/uv/tlb_uv.c +0
-0@@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode)
arch/x86/platform/uv/tlb_uv.c static void pq_init(int node, int pnode) · line 1812
Quoted 10 lines
arch/x86/platform/uv/tlb_uv.c +2
-2plsize = (DEST_Q_SIZE +1 ) *sizeof (struct bau_pq_entry ); vp =kmalloc_node (plsize,GFP_KERNEL , node); - pqp = (struct bau_pq_entry *)vp; -BUG_ON (!pqp); +BUG_ON (!vp); + pqp = (struct bau_pq_entry *)vp; cp = (char *)pqp +31 ; pqp = (struct bau_pq_entry *)(((unsigned long )cp >>5 ) <<5 );
How did this even get merged in the first place? I thought a number of us complained about it.
This isn't any change in code, and the original is just fine, the author didn't realize how C works :(
Please drop this.
thanks,
greg k-h
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine
Quoted 56 lines · Greg KH
Quoted 41 lines · Sasha Levin
From: Austin Kim <[email protected]>
[ Upstream commit
864b23f0169d5bff677e8443a7a90dfd6b090afc]The result of
kmalloc()should have been checked ahead of below statement:pqp = (struct bau_pq_entry *)vp;Move
BUG_ON(!vp)before above statement.Signed-off-by Austin Kim <[email protected]>Cc Dimitri Sivanich <[email protected]>Cc Hedi Berriche <[email protected]>Cc Linus Torvalds <[email protected]>Cc Mike Travis <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Russ Anderson <[email protected]>Cc Steve Wahl <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/x86/platform/uv/tlb_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/platform/uv/tlb_uv.c +0
-0@@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode)arch/x86/platform/uv/tlb_uv.c static void pq_init(int node, int pnode) · line 1812
Quoted 10 lines
arch/x86/platform/uv/tlb_uv.c +2
-2plsize = (DEST_Q_SIZE +1 ) *sizeof (struct bau_pq_entry ); vp =kmalloc_node (plsize,GFP_KERNEL , node); - pqp = (struct bau_pq_entry *)vp; -BUG_ON (!pqp); +BUG_ON (!vp); + pqp = (struct bau_pq_entry *)vp; cp = (char *)pqp +31 ; pqp = (struct bau_pq_entry *)(((unsigned long )cp >>5 ) <<5 );How did this even get merged in the first place? I thought a number of us complained about it.
Quoted 4 lines
This isn't any change in code, and the original is just fine, the author didn't realize how C works :(
Please drop this.
Heh, I've dropped it.
RE: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine
From: Sasha Levin
Quoted 16 lines
Sent: 01 October 2019 17:06
Subject: Re: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fixkmalloc()NULL check routineQuoted 12 lines · Greg KH
Quoted 11 lines · Sasha Levin
From: Austin Kim <[email protected]>
[ Upstream commit
864b23f0169d5bff677e8443a7a90dfd6b090afc]The result of
kmalloc()should have been checked ahead of below statement:pqp = (struct bau_pq_entry *)vp;Move
BUG_ON(!vp)before above statement.Signed-off-by Austin Kim <[email protected]>
...
Quoted 24 lines
Quoted 24 lines
Quoted 10 lines
--- arch/x86/platform/uv/tlb_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/platform/uv/tlb_uv.c +0
-0@@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode)arch/x86/platform/uv/tlb_uv.c static void pq_init(int node, int pnode) · line 1812
Quoted 10 lines
arch/x86/platform/uv/tlb_uv.c +2
-2plsize = (DEST_Q_SIZE +1 ) *sizeof (struct bau_pq_entry ); vp =kmalloc_node (plsize,GFP_KERNEL , node); - pqp = (struct bau_pq_entry *)vp; -BUG_ON (!pqp); +BUG_ON (!vp); + pqp = (struct bau_pq_entry *)vp; cp = (char *)pqp +31 ; pqp = (struct bau_pq_entry *)(((unsigned long )cp >>5 ) <<5 );How did this even get merged in the first place? I thought a number of us complained about it.
Quoted 2 lines
Quoted 2 lines
This isn't any change in code, and the original is just fine, the author didn't realize how C works :(
Mind you, the code itself if pretty horrid. Looks like it is aligning to 32 bytes, easier done by:
pqp = (void *)((unsigned long)vp + 31 & ~31);
(and there's a roundup macro to obfuscate it somewhere.)
But I'd also expect to see a matching '+ 31' in the size passed to kmalloc(). Not to mention a comment!
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine
Quoted 52 lines · David Laight
From: Sasha Levin
Quoted 16 lines
Sent: 01 October 2019 17:06
Subject: Re: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fixkmalloc()NULL check routineQuoted 12 lines · Greg KH
Quoted 11 lines · Sasha Levin
From: Austin Kim <[email protected]>
[ Upstream commit
864b23f0169d5bff677e8443a7a90dfd6b090afc]The result of
kmalloc()should have been checked ahead of below statement:pqp = (struct bau_pq_entry *)vp;Move
BUG_ON(!vp)before above statement.Signed-off-by Austin Kim <[email protected]>...
Quoted 24 lines
Quoted 24 lines
Quoted 10 lines
--- arch/x86/platform/uv/tlb_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/platform/uv/tlb_uv.c +0
-0@@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode)arch/x86/platform/uv/tlb_uv.c static void pq_init(int node, int pnode) · line 1812
Quoted 10 lines
arch/x86/platform/uv/tlb_uv.c +2
-2plsize = (DEST_Q_SIZE +1 ) *sizeof (struct bau_pq_entry ); vp =kmalloc_node (plsize,GFP_KERNEL , node); - pqp = (struct bau_pq_entry *)vp; -BUG_ON (!pqp); +BUG_ON (!vp); + pqp = (struct bau_pq_entry *)vp; cp = (char *)pqp +31 ; pqp = (struct bau_pq_entry *)(((unsigned long )cp >>5 ) <<5 );How did this even get merged in the first place? I thought a number of us complained about it.
Quoted 2 lines
Quoted 2 lines
This isn't any change in code, and the original is just fine, the author didn't realize how C works :(
Mind you, the code itself if pretty horrid. Looks like it is aligning to 32 bytes, easier done by:
pqp = (void *)((unsigned long)vp + 31 & ~31);(and there's a roundup macro to obfuscate it somewhere.)
But I'd also expect to see a matching '+ 31' in the size passed tokmalloc(). Not to mention a comment!
Quoted 6 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Thanks, I will put all of these comments in my notes. This whole function is slated to move to a specialized UV APIC driver since it uses a unique scaling feature available in the UV hardware. (The original author has long retired.)
-Mike
Sasha Levin
maintainerPATCH 170/203 x86/cpu: Add Tiger Lake to Intel family
In reply to Sasha LevinFrom: Gayatri Kammela <[email protected]>
[ Upstream commit 6e1c32c5dbb4b90eea8f964c2869d0bde050dbe0 ]
Add the model numbers/CPUIDs of Tiger Lake mobile and desktop to the Intel family.
--- arch/x86/include/asm/intel-family.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/intel-family.h +3 -0
@@ -73,6 +73,9 @@#define INTEL_FAM6_ICELAKE_MOBILE 0x7E#define INTEL_FAM6_ICELAKE_NNPI 0x9D +#define INTEL_FAM6_TIGERLAKE_L 0x8C +#define INTEL_FAM6_TIGERLAKE 0x8D +/* "Small Core" Processors (Atom) */ #define INTEL_FAM6_ATOM_BONNELL 0x1C/* Diamondville, Pineview */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 171/203 platform/x86: intel_pmc_core: Do not ioremap RAM
In reply to Sasha LevinFrom: "M. Vefa Bicakci" <[email protected]>
[ Upstream commit 7d505758b1e556cdf65a5e451744fe0ae8063d17 ]
On a Xen-based PVH virtual machine with more than 4 GiB of RAM, intel_pmc_core fails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM:
ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fff
WARNING: CPU: 1 PID: 434 at arch/x86/mm/ioremap.c:186 __ioremap_caller.constprop.0+0x2aa/0x2c0 ... Call Trace: ? pmc_core_probe+0x87/0x2d0 [intel_pmc_core] pmc_core_probe+0x87/0x2d0 [intel_pmc_core]
This issue appears to manifest itself because of the following fallback mechanism in the driver:
if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT;
The validity of address PMC_BASE_ADDR_DEFAULT (i.e., 0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if address PMC_BASE_ADDR_DEFAULT is in RAM, then the driver will not attempt to ioremap the aforementioned address.
--- drivers/platform/x86/intel_pmc_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/intel_pmc_core.c +6 -2
@@ -878,10 +878,14 @@ static int pmc_core_probe(struct platform_device *pdev)if (pmcdev->map == &spt_reg_map && !pci_dev_present (pmc_pci_ids)) pmcdev->map = &cnp_reg_map; -if (lpit_read_residency_count_address (&slp_s0_addr)) +if (lpit_read_residency_count_address (&slp_s0_addr)) { pmcdev->base_addr =PMC_BASE_ADDR_DEFAULT ; -else + +if (page_is_ram (PHYS_PFN (pmcdev->base_addr))) +return -ENODEV ; + }else { pmcdev->base_addr = slp_s0_addr - pmcdev->map->slp_s0_offset; + } pmcdev->regbase =ioremap (pmcdev->base_addr, pmcdev->map->regmap_length);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 172/203 platform/x86: intel_pmc_core_pltdrv: Module removal warning fix
In reply to Sasha LevinFrom: "M. Vefa Bicakci" <[email protected]>
[ Upstream commit 0b43e41e93815ecd9616759cf5d64d3a7be8e6fb ]
Prior to this commit, removing the intel_pmc_core_pltdrv module would cause the following warning:
Device 'intel_pmc_core.0' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt.
WARNING: CPU: 0 PID: 2202 at drivers/base/core.c:1238 device_release+0x6f/0x80
This commit hence adds an empty release function for the driver.
--- drivers/platform/x86/intel_pmc_core_pltdrv.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/intel_pmc_core_pltdrv.c +8 -0
@@ -18,8 +18,16 @@#include <asm/cpu_device_id.h> #include <asm/intel-family.h> +static void intel_pmc_core_release (struct device *dev) +{ +/* Nothing to do. */ +} +static struct platform_device pmc_core_device = { .name ="intel_pmc_core" , + .dev = { + .release = intel_pmc_core_release, + }, };/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 173/203 ASoC: es8316: support fixed and variable both clock rates
In reply to Sasha LevinFrom: Katsuhiro Suzuki <[email protected]>
[ Upstream commit ebe02a5b9ef05e3b812af3d628cdf6206d9ba610 ]
This patch supports some type of machine drivers that set 0 to mclk when sound device goes to idle state. After applied this patch, sysclk == 0 means there is no constraint of sound rate and other values will set constraints which is derived by sysclk setting.
Original code refuses sysclk == 0 setting. But some boards and SoC (such as RockPro64 and RockChip I2S) has connected SoC MCLK out to ES8316 MCLK in. In this case, SoC side I2S will choose suitable frequency of MCLK such as fs * mclk-fs when user starts playing or capturing.
Bad scenario as follows (mclk-fs = 256):
- Initialize sysclk by correct value (Ex. 12.288MHz)
- ES8316 set constraints of PCM rate by sysclk
48kHz (1/256), 32kHz (1/384), 30.720kHz (1/400),
24kHz (1/512), 16kHz (1/768), 12kHz (1/1024) - Play 48kHz sound, it's acceptable
- Sysclk is not changed
- Play 32kHz sound, it's acceptable
- Set sysclk by 8.192MHz (= fs * mclk-fs = 32k * 256)
- ES8316 set constraints of PCM rate by sysclk
32kHz (1/256), 21.33kHz (1/384), 20.48kHz (1/400),
16kHz (1/512), 10.66kHz (1/768), 8kHz (1/1024)- Play 48kHz again, but it's NOT acceptable because constraints list does not allow 48kHz
--- sound/soc/codecs/es8316.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-)
sound/soc/codecs/es8316.c +20 -15
@@ -368,8 +368,12 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, es8316->sysclk = freq; -if (freq ==0 ) +if (freq ==0 ) { + es8316->sysclk_constraints.list =NULL ; + es8316->sysclk_constraints.count =0 ; +return 0 ; + }/* Limit supported sample rates to ones that can be autodetected * by the codec running in slave mode.
@@ -444,17 +448,10 @@ static int es8316_pcm_startup(struct snd_pcm_substream *substream,struct snd_soc_component *component = dai->component;struct es8316_priv *es8316 =snd_soc_component_get_drvdata (component); -if (es8316->sysclk ==0 ) { -dev_err (component->dev,"No sysclk provided\n" ); -return -EINVAL ; - } - -/* The set of sample rates that can be supported depends on the -* MCLK supplied to the CODEC. -*/ -snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &es8316->sysclk_constraints); +if (es8316->sysclk_constraints.list) +snd_pcm_hw_constraint_list (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_RATE , + &es8316->sysclk_constraints);return 0 ; }
@@ -466,11 +463,19 @@ static int es8316_pcm_hw_params(struct snd_pcm_substream *substream,struct snd_soc_component *component = dai->component;struct es8316_priv *es8316 =snd_soc_component_get_drvdata (component);u8 wordlen =0 ; +int i; -if (!es8316->sysclk) { -dev_err (component->dev,"No MCLK configured\n" ); -return -EINVAL ; +/* Validate supported sample rates that are autodetected from MCLK */ +for (i =0 ; i <NR_SUPPORTED_MCLK_LRCK_RATIOS ; i++) { +const unsigned int ratio = supported_mclk_lrck_ratios[i]; + +if (es8316->sysclk % ratio !=0 ) +continue ; +if (es8316->sysclk / ratio ==params_rate (params)) +break ; } +if (i ==NR_SUPPORTED_MCLK_LRCK_RATIOS ) +return -EINVAL ;switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE :
Signature · 1 line
2.20.1
Mark Brown
maintainerRe: [PATCH AUTOSEL 5.3 173/203] ASoC: es8316: support fixed and variable both clock rates
Quoted 8 lines · Sasha Levin
From: Katsuhiro Suzuki <[email protected]>
[ Upstream commit
ebe02a5b9ef05e3b812af3d628cdf6206d9ba610]This patch supports some type of machine drivers that set 0 to mclk when sound device goes to idle state. After applied this patch, sysclk == 0 means there is no constraint of sound rate and other values will set constraints which is derived by sysclk setting.
This is a new feature and clearly out of scope for stable.
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.3 173/203] ASoC: es8316: support fixed and variable both clock rates
Quoted 11 lines · Mark Brown
Quoted 8 lines · Sasha Levin
From: Katsuhiro Suzuki <[email protected]>
[ Upstream commit
ebe02a5b9ef05e3b812af3d628cdf6206d9ba610]This patch supports some type of machine drivers that set 0 to mclk when sound device goes to idle state. After applied this patch, sysclk == 0 means there is no constraint of sound rate and other values will set constraints which is derived by sysclk setting.
This is a new feature and clearly out of scope for stable.
I've dropped it, thanks!
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 174/203 SoC: simple-card-utils: set 0Hz to sysclk when shutdown
In reply to Sasha LevinFrom: Katsuhiro Suzuki <[email protected]>
[ Upstream commit 2458adb8f92ad4d07ef7ab27c5bafa1d3f4678d6 ]
This patch set 0Hz to sysclk when shutdown the card.
Some codecs set rate constraints that derives from sysclk. This mechanism works correctly if machine drivers give fixed frequency.
But simple-audio and audio-graph card set variable clock rate if 'mclk-fs' property exists. In this case, rate constraints will go bad scenario. For example a codec accepts three limited rates (mclk / 256, mclk / 384, mclk / 512).
Bad scenario as follows (mclk-fs = 256):
- Initialize sysclk by correct value (Ex. 12.288MHz)
- Codec set constraints of PCM rate by sysclk 48kHz (1/256), 32kHz (1/384), 24kHz (1/512)
- Play 48kHz sound, it's acceptable
- Sysclk is not changed
- Play 32kHz sound, it's acceptable
- Set sysclk to 8.192MHz (= fs * mclk-fs = 32k * 256)
- Codec set constraints of PCM rate by sysclk 32kHz (1/256), 21.33kHz (1/384), 16kHz (1/512)
- Play 48kHz again, but it's NOT acceptable because constraints do not allow 48kHz
So codecs treat 0Hz sysclk as signal of applying no constraints to avoid this problem.
--- sound/soc/generic/simple-card-utils.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/generic/simple-card-utils.c +7 -0
@@ -213,10 +213,17 @@ EXPORT_SYMBOL_GPL(asoc_simple_startup);void asoc_simple_shutdown (struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai = rtd->codec_dai; +struct snd_soc_dai *cpu_dai = rtd->cpu_dai;struct asoc_simple_priv *priv =snd_soc_card_get_drvdata (rtd->card);struct simple_dai_props *dai_props =simple_priv_to_props (priv, rtd->num); +if (dai_props->mclk_fs) { +snd_soc_dai_set_sysclk (codec_dai,0 ,0 ,SND_SOC_CLOCK_IN ); +snd_soc_dai_set_sysclk (cpu_dai,0 ,0 ,SND_SOC_CLOCK_OUT ); + } +asoc_simple_clk_disable (dai_props->cpu_dai);asoc_simple_clk_disable (dai_props->codec_dai);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 175/203 ASoC: dmaengine: Make the pcm->name equal to pcm->id if the name is not set
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 2ec42f3147e1610716f184b02e65d7f493eed925 ]
Some tools use the snd_pcm_info_get_name() to try to identify PCMs or for other purposes.
Currently it is left empty with the dmaengine-pcm, in this case copy the pcm->id string as pcm->name.
For example IGT is using this to find the HDMI PCM for testing audio on it.
--- sound/soc/soc-generic-dmaengine-pcm.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/soc-generic-dmaengine-pcm.c +6 -0
@@ -306,6 +306,12 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)if (!dmaengine_pcm_can_report_residue (dev, pcm->chan[i])) pcm->flags |=SND_DMAENGINE_PCM_FLAG_NO_RESIDUE ; + +if (rtd->pcm->streams[i].pcm->name[0 ] =='\0' ) { +strncpy (rtd->pcm->streams[i].pcm->name, + rtd->pcm->streams[i].pcm->id, +sizeof (rtd->pcm->streams[i].pcm->name)); + } }return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 176/203 tools/power/x86/intel-speed-select: Fix memory leak
In reply to Sasha LevinFrom: Prarit Bhargava <[email protected]>
[ Upstream commit 3bc3d30ca324bfc3045a1a7fe1f5fe5ad5d92fd9 ]
cpumasks are allocated by calling the alloc_cpu_mask() function and are never free'd. They should be free'd after the commands have run.
Fix the memory leaks by calling free_cpu_set().
--- tools/power/x86/intel-speed-select/isst-config.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
tools/power/x86/intel-speed-select/isst-config.c +11 -5
@@ -603,6 +603,10 @@ static int isst_fill_platform_info(void)close (fd); +if (isst_platform_info.api_version > supported_api_ver) { +printf ("Incompatible API versions; Upgrade of tool is required\n" ); +return -1 ; + }return 0 ; }
@@ -1529,6 +1533,7 @@ static void cmdline(int argc, char **argv) {int opt;int option_index =0 ; +int ret;static struct option long_options[] = { {"cpu" , required_argument,0 ,'c' },
@@ -1590,13 +1595,14 @@ static void cmdline(int argc, char **argv)set_max_cpu_num ();set_cpu_present_cpu_mask ();set_cpu_target_cpu_mask (); -isst_fill_platform_info (); -if (isst_platform_info.api_version > supported_api_ver) { -printf ("Incompatible API versions; Upgrade of tool is required\n" ); -exit (0 ); - } + ret =isst_fill_platform_info (); +if (ret) + goto out;process_command (argc, argv); +out: +free_cpu_set (present_cpumask); +free_cpu_set (target_cpumask); }int main (int argc,char **argv)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 177/203 spi: bcm2835: Work around DONE bit erratum
In reply to Sasha LevinFrom: Lukas Wunner <[email protected]>
[ Upstream commit 4c524191c0a21d758b519087c64f84348095e940 ]
Commit 3bd7f6589f67 ("spi: bcm2835: Overcome sglist entry length limitation") amended the BCM2835 SPI driver with support for DMA transfers whose buffers are not aligned to 4 bytes and require more than one sglist entry.
When testing this feature with upcoming commits to speed up TX-only and RX-only transfers, I noticed that SPI transmission sometimes breaks. A function introduced by the commit, bcm2835_spi_transfer_prologue(), performs one or two PIO transmissions as a prologue to the actual DMA transmission. It turns out that the breakage goes away if the DONE bit in the CS register is set when ending such a PIO transmission.
The DONE bit signifies emptiness of the TX FIFO. According to the spec, the bit is of type RO, so writing it should never have any effect. Perhaps the spec is wrong and the bit is actually of type RW1C. E.g. the I2C controller on the BCM2835 does have an RW1C DONE bit which needs to be cleared by the driver. Another, possibly more likely explanation is that it's a hardware erratum since the issue does not occur consistently.
Either way, amend bcm2835_spi_transfer_prologue() to always write the DONE bit.
Usually a transmission is ended by bcm2835_spi_reset_hw(). If the transmission was successful, the TX FIFO is empty and thus the DONE bit is set when bcm2835_spi_reset_hw() reads the CS register. The bit is then written back to the register, so we happen to do the right thing.
However if DONE is not set, e.g. because transmission is aborted with a non-empty TX FIFO, the bit won't be written by bcm2835_spi_reset_hw() and it seems possible that transmission might subsequently break. To be on the safe side, likewise amend bcm2835_spi_reset_hw() to always write the bit.
--- drivers/spi/spi-bcm2835.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm2835.c +12 -2
@@ -319,6 +319,13 @@ static void bcm2835_spi_reset_hw(struct spi_controller *ctlr)BCM2835_SPI_CS_INTD |BCM2835_SPI_CS_DMAEN | BCM2835_SPI_CS_TA); +/* +* Transmission sometimes breaks unless the DONE bit is written at the +* end of every transfer. The spec says it's a RO bit. Either the +* spec is wrong and the bit is actually of type RW1C, or it's a +* hardware erratum. +*/ + cs |=BCM2835_SPI_CS_DONE ;/* and reset RX/TX FIFOS */ cs |=BCM2835_SPI_CS_CLEAR_RX |BCM2835_SPI_CS_CLEAR_TX ;
@@ -477,7 +484,9 @@ static void bcm2835_spi_transfer_prologue(struct spi_controller *ctlr,bcm2835_wr_fifo_count (bs, bs->rx_prologue);bcm2835_wait_tx_fifo_empty (bs);bcm2835_rd_fifo_count (bs, bs->rx_prologue); -bcm2835_spi_reset_hw (ctlr); +bcm2835_wr (bs,BCM2835_SPI_CS , cs |BCM2835_SPI_CS_CLEAR_RX + |BCM2835_SPI_CS_CLEAR_TX + |BCM2835_SPI_CS_DONE ); dma_sync_single_for_device(ctlr->dma_rx->device->dev, sg_dma_address(&tfr->rx_sg.sgl[0]),
@@ -498,7 +507,8 @@ static void bcm2835_spi_transfer_prologue(struct spi_controller *ctlr, | BCM2835_SPI_CS_DMAEN);bcm2835_wr_fifo_count (bs, tx_remaining);bcm2835_wait_tx_fifo_empty (bs); -bcm2835_wr (bs,BCM2835_SPI_CS , cs |BCM2835_SPI_CS_CLEAR_TX ); +bcm2835_wr (bs,BCM2835_SPI_CS , cs |BCM2835_SPI_CS_CLEAR_TX + |BCM2835_SPI_CS_DONE ); }if (likely (!bs->tx_spillover)) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 178/203 io_uring: fix wrong sequence setting logic
In reply to Sasha LevinFrom: Jackie Liu <[email protected]>
[ Upstream commit 8776f3fa15a5cd213c4dfab7ddaf557983374ea6 ]
Sqo_thread will get sqring in batches, which will cause ctx->cached_sq_head to be added in batches. if one of these sqes is set with the DRAIN flag, then he will never get a chance to process, and finally sqo_thread will not exit.
--- fs/io_uring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/io_uring.c +3 -1
@@ -288,6 +288,7 @@ struct io_ring_ctx {struct sqe_submit {const struct io_uring_sqe *sqe;unsigned short index; +u32 sequence;bool has_user;bool needs_lock;bool needs_fixed_file;
@@ -2040,7 +2041,7 @@ static int io_req_set_file(struct io_ring_ctx *ctx, const struct sqe_submit *s,if (flags &IOSQE_IO_DRAIN ) { req->flags |=REQ_F_IO_DRAIN ; - req->sequence = ctx->cached_sq_head -1 ; + req->sequence = s->sequence; }if (!io_op_needs_file (s->sqe))
@@ -2247,6 +2248,7 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)if (head < ctx->sq_entries) { s->index = head; s->sqe = &ctx->sq_sqes[head]; + s->sequence = ctx->cached_sq_head; ctx->cached_sq_head++;return true; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 179/203 block: make rq sector size accessible for block stats
In reply to Sasha LevinFrom: Hou Tao <[email protected]>
[ Upstream commit 3d24430694077313c75c6b89f618db09943621e4 ]
Currently rq->data_len will be decreased by partial completion or zeroed by completion, so when blk_stat_add() is invoked, data_len will be zero and there will never be samples in poll_cb because blk_mq_poll_stats_bkt() will return -1 if data_len is zero.
We could move blk_stat_add() back to __blk_mq_complete_request(), but that would make the effort of trying to call ktime_get_ns() once in vain. Instead we can reuse throtl_size field, and use it for both block stats and block throttle, and adjust the logic in blk_mq_poll_stats_bkt() accordingly.
--- block/blk-mq.c | 11 +++++------ block/blk-throttle.c | 3 ++- include/linux/blkdev.h | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-)
block/blk-mq.c +5 -6
@@ -44,12 +44,12 @@ static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb);static int blk_mq_poll_stats_bkt (const struct request *rq) { -int ddir, bytes, bucket; +int ddir, sectors, bucket; ddir =rq_data_dir (rq); - bytes =blk_rq_bytes (rq); + sectors =blk_rq_stats_sectors (rq); - bucket = ddir +2 *(ilog2 (bytes) -9 ); + bucket = ddir +2 *ilog2 (sectors);if (bucket <0 )return -1 ;
@@ -330,6 +330,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,else rq->start_time_ns =0 ; rq->io_start_time_ns =0 ; + rq->stats_sectors =0 ; rq->nr_phys_segments =0 ;#if defined(CONFIG_BLK_DEV_INTEGRITY ) rq->nr_integrity_segments =0 ;
@@ -673,9 +674,7 @@ void blk_mq_start_request(struct request *rq)if (test_bit (QUEUE_FLAG_STATS , &q->queue_flags)) { rq->io_start_time_ns =ktime_get_ns (); -#ifdef CONFIG_BLK_DEV_THROTTLING_LOW - rq->throtl_size =blk_rq_sectors (rq); -#endif + rq->stats_sectors =blk_rq_sectors (rq); rq->rq_flags |=RQF_STATS ;rq_qos_issue (q, rq); }
block/blk-throttle.c +2 -1
@@ -2246,7 +2246,8 @@ void blk_throtl_stat_add(struct request *rq, u64 time_ns)struct request_queue *q = rq->q;struct throtl_data *td = q->td; -throtl_track_latency (td, rq->throtl_size,req_op (rq), time_ns >>10 ); +throtl_track_latency (td,blk_rq_stats_sectors (rq),req_op (rq), + time_ns >>10 ); }void blk_throtl_bio_endio (struct bio *bio)
include/linux/blkdev.h +12 -3
@@ -202,9 +202,12 @@ struct request {#ifdef CONFIG_BLK_WBT unsigned short wbt_flags;#endif -#ifdef CONFIG_BLK_DEV_THROTTLING_LOW -unsigned short throtl_size; -#endif +/* +* rq sectors used for blk stats. It has the same value +* with blk_rq_sectors(rq), except that it never be zeroed +* by completion. +*/ +unsigned short stats_sectors;/* * Number of scatter-gather DMA addr+len pairs after
@@ -903,6 +906,7 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)* blk_rq_err_bytes() : bytes left till the next error boundary * blk_rq_sectors() : sectors left in the entire request * blk_rq_cur_sectors() : sectors left in the current segment +* blk_rq_stats_sectors() : sectors of the entire request used for stats */ static inline sector_t blk_rq_pos (const struct request *rq) {
@@ -931,6 +935,11 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)return blk_rq_cur_bytes (rq) >>SECTOR_SHIFT ; } +static inline unsigned int blk_rq_stats_sectors (const struct request *rq) +{ +return rq->stats_sectors; +} +#ifdef CONFIG_BLK_DEV_ZONED static inline unsigned int blk_rq_zone_no (struct request *rq) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 180/203 raid5: don't set STRIPE_HANDLE to stripe which is in batch list
In reply to Sasha LevinFrom: Guoqing Jiang <[email protected]>
[ Upstream commit 6ce220dd2f8ea71d6afc29b9a7524c12e39f374a ]
If stripe in batch list is set with STRIPE_HANDLE flag, then the stripe could be set with STRIPE_ACTIVE by the handle_stripe function. And if error happens to the batch_head at the same time, break_stripe_batch_list is called, then below warning could happen (the same report in [1]), it means a member of batch list was set with STRIPE_ACTIVE.
[7028915.431770] stripe state: 2001 [7028915.431815] ------------[ cut here ]------------ [7028915.431828] WARNING: CPU: 18 PID: 29089 at drivers/md/raid5.c:4614 break_stripe_batch_list+0x203/0x240 [raid456] [...] [7028915.431879] CPU: 18 PID: 29089 Comm: kworker/u82:5 Tainted: G O 4.14.86-1-storage #4.14.86-1.2~deb9 [7028915.431881] Hardware name: Supermicro SSG-2028R-ACR24L/X10DRH-iT, BIOS 3.1 06/18/2018 [7028915.431888] Workqueue: raid5wq raid5_do_work [raid456] [7028915.431890] task: ffff9ab0ef36d7c0 task.stack: ffffb72926f84000 [7028915.431896] RIP: 0010:break_stripe_batch_list+0x203/0x240 [raid456] [7028915.431898] RSP: 0018:ffffb72926f87ba8 EFLAGS: 00010286 [7028915.431900] RAX: 0000000000000012 RBX: ffff9aaa84a98000 RCX: 0000000000000000 [7028915.431901] RDX: 0000000000000000 RSI: ffff9ab2bfa15458 RDI: ffff9ab2bfa15458 [7028915.431902] RBP: ffff9aaa8fb4e900 R08: 0000000000000001 R09: 0000000000002eb4 [7028915.431903] R10: 00000000ffffffff R11: 0000000000000000 R12: ffff9ab1736f1b00 [7028915.431904] R13: 0000000000000000 R14: ffff9aaa8fb4e900 R15: 0000000000000001 [7028915.431906] FS: 0000000000000000(0000) GS:ffff9ab2bfa00000(0000) knlGS:0000000000000000 [7028915.431907] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [7028915.431908] CR2: 00007ff953b9f5d8 CR3: 0000000bf4009002 CR4: 00000000003606e0 [7028915.431909] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [7028915.431910] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [7028915.431910] Call Trace: [7028915.431923] handle_stripe+0x8e7/0x2020 [raid456] [7028915.431930] ? __wake_up_common_lock+0x89/0xc0 [7028915.431935] handle_active_stripes.isra.58+0x35f/0x560 [raid456] [7028915.431939] raid5_do_work+0xc6/0x1f0 [raid456]
Also commit 59fc630b8b5f9f ("RAID5: batch adjacent full stripe write") said "If a stripe is added to batch list, then only the first stripe of the list should be put to handle_list and run handle_stripe."
So don't set STRIPE_HANDLE to stripe which is already in batch list, otherwise the stripe could be put to handle_list and run handle_stripe, then the above warning could be triggered.
[1]. https://www.spinics.net/lists/raid/msg62552.html
--- drivers/md/raid5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid5.c +2 -1
@@ -5718,7 +5718,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi) do_flush = false; } -set_bit (STRIPE_HANDLE , &sh->state); +if (!sh->batch_head) +set_bit (STRIPE_HANDLE , &sh->state);clear_bit (STRIPE_DELAYED , &sh->state); if ((!sh->batch_head || sh == sh->batch_head) && (bi->bi_opf & REQ_SYNC) &&
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 181/203 mmc: core: Clarify sdio_irq_pending flag for MMC_CAP2_SDIO_IRQ_NOTHREAD
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit 36d57efb4af534dd6b442ea0b9a04aa6dfa37abe ]
The sdio_irq_pending flag is used to let host drivers indicate that it has signaled an IRQ. If that is the case and we only have a single SDIO func that have claimed an SDIO IRQ, our assumption is that we can avoid reading the SDIO_CCCR_INTx register and just call the SDIO func irq handler immediately. This makes sense, but the flag is set/cleared in a somewhat messy order, let's fix that up according to below.
First, the flag is currently set in sdio_run_irqs(), which is executed as a work that was scheduled from sdio_signal_irq(). To make it more implicit that the host have signaled an IRQ, let's instead immediately set the flag in sdio_signal_irq(). This also makes the behavior consistent with host drivers that uses the legacy, mmc_signal_sdio_irq() API. This have no functional impact, because we don't expect host drivers to call sdio_signal_irq() until after the work (sdio_run_irqs()) have been executed anyways.
Second, currently we never clears the flag when using the sdio_run_irqs() work, but only when using the sdio_irq_thread(). Let make the behavior consistent, by moving the flag to be cleared inside the common process_sdio_pending_irqs() function. Additionally, tweak the behavior of the flag slightly, by avoiding to clear it unless we processed the SDIO IRQ. The purpose with this at this point, is to keep the information about whether there have been an SDIO IRQ signaled by the host, so at system resume we can decide to process it without reading the SDIO_CCCR_INTx register.
--- drivers/mmc/core/sdio_irq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/core/sdio_irq.c +6 -3
@@ -31,6 +31,7 @@ static int process_sdio_pending_irqs(struct mmc_host *host) {struct mmc_card *card = host->card;int i, ret, count; +bool sdio_irq_pending = host->sdio_irq_pending;unsigned char pending;struct sdio_func *func;
@@ -38,13 +39,16 @@ static int process_sdio_pending_irqs(struct mmc_host *host)if (mmc_card_suspended (card))return 0 ; +/* Clear the flag to indicate that we have processed the IRQ. */ + host->sdio_irq_pending = false; +/* * Optimization, if there is only 1 function interrupt registered * and we know an IRQ was signaled then call irq handler directly. * Otherwise do the full probe. */ func = card->sdio_single_irq; -if (func && host->sdio_irq_pending) { +if (func && sdio_irq_pending) { func->irq_handler (func);return 1 ; }
@@ -96,7 +100,6 @@ static void sdio_run_irqs(struct mmc_host *host) {mmc_claim_host (host);if (host->sdio_irqs) { - host->sdio_irq_pending = true;process_sdio_pending_irqs (host);if (host->ops->ack_sdio_irq) host->ops->ack_sdio_irq (host);
@@ -114,6 +117,7 @@ void sdio_irq_work(struct work_struct *work)void sdio_signal_irq (struct mmc_host *host) { + host->sdio_irq_pending = true;queue_delayed_work (system_wq, &host->sdio_irq_work,0 ); }EXPORT_SYMBOL_GPL (sdio_signal_irq);
@@ -159,7 +163,6 @@ static int sdio_irq_thread(void *_host)if (ret)break ; ret =process_sdio_pending_irqs (host); - host->sdio_irq_pending = false;mmc_release_host (host);/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 182/203 sched/psi: Correct overly pessimistic size calculation
In reply to Sasha LevinFrom: Miles Chen <miles.chen-NuS5LvNUpcJWk0Htik3J/[email protected]>
[ Upstream commit 4adcdcea717cb2d8436bef00dd689aa5bc76f11b ]
When passing a equal or more then 32 bytes long string to psi_write(), psi_write() copies 31 bytes to its buf and overwrites buf[30] with '\0'. Which makes the input string 1 byte shorter than it should be.
Fix it by copying sizeof(buf) bytes when nbytes >= sizeof(buf).
This does not cause problems in normal use case like:
"some 500000 10000000" or "full 500000 10000000" because they are less than 32 bytes in length.
/* assuming nbytes == 35 */ char buf[32]; buf_size = min(nbytes, (sizeof(buf) - 1)); /* buf_size = 31 */ if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; buf[buf_size - 1] = '\0'; /* buf[30] = '\0' */
Before:
%cd /proc/pressure/
%echo "123456789|123456789|123456789|1234" > memory
[ 22.473497] nbytes=35,buf_size=31 [ 22.473775] 123456789|123456789|123456789| (print 30 chars) %sh: write error: Invalid argument
%echo "123456789|123456789|123456789|1" > memory
[ 64.916162] nbytes=32,buf_size=31 [ 64.916331] 123456789|123456789|123456789| (print 30 chars) %sh: write error: Invalid argument
After:
%cd /proc/pressure/
%echo "123456789|123456789|123456789|1234" > memory
[ 254.837863] nbytes=35,buf_size=32 [ 254.838541] 123456789|123456789|123456789|1 (print 31 chars) %sh: write error: Invalid argument
%echo "123456789|123456789|123456789|1" > memory
[ 9965.714935] nbytes=32,buf_size=32 [ 9965.715096] 123456789|123456789|123456789|1 (print 31 chars) %sh: write error: Invalid argument
Also remove the superfluous parentheses.
--- kernel/sched/psi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/psi.c +1 -1
@@ -1198,7 +1198,7 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf,if (static_branch_likely (&psi_disabled))return -EOPNOTSUPP ; - buf_size =min (nbytes, (sizeof (buf) -1 )); + buf_size =min (nbytes,sizeof (buf));if (copy_from_user (buf, user_buf, buf_size))return -EFAULT ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 183/203 mmc: sdhci: Fix incorrect switch to HS mode
In reply to Sasha LevinFrom: Al Cooper <[email protected]>
[ Upstream commit c894e33ddc1910e14d6f2a2016f60ab613fd8b37 ]
When switching from any MMC speed mode that requires 1.8v (HS200, HS400 and HS400ES) to High Speed (HS) mode, the system ends up configured for SDR12 with a 50MHz clock which is an illegal mode.
This happens because the SDHCI_CTRL_VDD_180 bit in the SDHCI_HOST_CONTROL2 register is left set and when this bit is set, the speed mode is controlled by the SDHCI_CTRL_UHS field in the SDHCI_HOST_CONTROL2 register. The SDHCI_CTRL_UHS field will end up being set to 0 (SDR12) by sdhci_set_uhs_signaling() because there is no UHS mode being set.
The fix is to change sdhci_set_uhs_signaling() to set the SDHCI_CTRL_UHS field to SDR25 (which is the same as HS) for any switch to HS mode.
This was found on a new eMMC controller that does strict checking of the speed mode and the corresponding clock rate. It caused the switch to HS400 mode to fail because part of the sequence to switch to HS400 requires a switch from HS200 to HS before going to HS400.
--- drivers/mmc/host/sdhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +3 -1
@@ -1849,7 +1849,9 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing) ctrl_2 |=SDHCI_CTRL_UHS_SDR104 ; else if (timing == MMC_TIMING_UHS_SDR12) ctrl_2 |= SDHCI_CTRL_UHS_SDR12; - else if (timing == MMC_TIMING_UHS_SDR25) + else if (timing == MMC_TIMING_SD_HS || + timing == MMC_TIMING_MMC_HS || + timing == MMC_TIMING_UHS_SDR25) ctrl_2 |= SDHCI_CTRL_UHS_SDR25; else if (timing == MMC_TIMING_UHS_SDR50) ctrl_2 |= SDHCI_CTRL_UHS_SDR50;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 184/203 mmc: core: Add helper function to indicate if SDIO IRQs is enabled
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit bd880b00697befb73eff7220ee20bdae4fdd487b ]
To avoid each host driver supporting SDIO IRQs, from keeping track internally about if SDIO IRQs has been claimed, let's introduce a common helper function, sdio_irq_claimed().
The function returns true if SDIO IRQs are claimed, via using the information about the number of claimed irqs. This is safe, even without any locks, as long as the helper function is called only from runtime/system suspend callbacks of the host driver.
--- include/linux/mmc/host.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/linux/mmc/host.h +9 -0
@@ -493,6 +493,15 @@ void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq);void mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq); +/* +* May be called from host driver's system/runtime suspend/resume callbacks, +* to know if SDIO IRQs has been claimed. +*/ +static inline bool sdio_irq_claimed (struct mmc_host *host) +{ +return host->sdio_irqs >0 ; +} +static inline void mmc_signal_sdio_irq (struct mmc_host *host) { host->ops->enable_sdio_irq (host,0 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 185/203 mmc: dw_mmc: Re-store SDIO IRQs mask at system resume
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit 7c526608d5afb62cbc967225e2ccaacfdd142e9d ]
In cases when SDIO IRQs have been enabled, runtime suspend is prevented by the driver. However, this still means dw_mci_runtime_suspend|resume() gets called during system suspend/resume, via pm_runtime_force_suspend|resume(). This means during system suspend/resume, the register context of the dw_mmc device most likely loses its register context, even in cases when SDIO IRQs have been enabled.
To re-enable the SDIO IRQs during system resume, the dw_mmc driver currently relies on the mmc core to re-enable the SDIO IRQs when it resumes the SDIO card, but this isn't the recommended solution. Instead, it's better to deal with this locally in the dw_mmc driver, so let's do that.
--- drivers/mmc/host/dw_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/dw_mmc.c +4 -0
@@ -3460,6 +3460,10 @@ int dw_mci_runtime_resume(struct device *dev)/* Force setup bus to guarantee available clock output */ dw_mci_setup_bus (host->slot, true); +/* Re-enable SDIO interrupts. */ +if (sdio_irq_claimed (host->slot->mmc)) +__dw_mci_enable_sdio_irq (host->slot,1 ); +/* Now that slots are all setup, we can enable card detect */ dw_mci_enable_cd (host);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 186/203 raid5: don't increment read_errors on EILSEQ return
In reply to Sasha LevinFrom: Nigel Croxon <[email protected]>
[ Upstream commit b76b4715eba0d0ed574f58918b29c1b2f0fa37a8 ]
While MD continues to count read errors returned by the lower layer. If those errors are -EILSEQ, instead of -EIO, it should NOT increase the read_errors count.
When RAID6 is set up on dm-integrity target that detects massive corruption, the leg will be ejected from the array. Even if the issue is correctable with a sector re-write and the array has necessary redundancy to correct it.
The leg is ejected because it runs up the rdev->read_errors beyond conf->max_nr_stripes. The return status in dm-drypt when there is a data integrity error is -EILSEQ (BLK_STS_PROTECTION).
--- drivers/md/raid5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid5.c +2 -1
@@ -2526,7 +2526,8 @@ static void raid5_end_read_request(struct bio * bi)int set_bad =0 ;clear_bit (R5_UPTODATE , &sh->dev[i].flags); -atomic_inc (&rdev->read_errors); +if (!(bi->bi_status ==BLK_STS_PROTECTION )) +atomic_inc (&rdev->read_errors);if (test_bit (R5_ReadRepl, &sh->dev[i].flags)) pr_warn_ratelimited( "md/raid:%s: read error on replacement device (sector %llu on %s).\n",
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 187/203 mmc: mtk-sd: Re-store SDIO IRQs mask at system resume
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit 1c81d69d4c98aab56c5a7d5a810f84aefdb37e9b ]
In cases when SDIO IRQs have been enabled, runtime suspend is prevented by the driver. However, this still means msdc_runtime_suspend|resume() gets called during system suspend/resume, via pm_runtime_force_suspend|resume().
This means during system suspend/resume, the register context of the mtk-sd device most likely loses its register context, even in cases when SDIO IRQs have been enabled.
To re-enable the SDIO IRQs during system resume, the mtk-sd driver currently relies on the mmc core to re-enable the SDIO IRQs when it resumes the SDIO card, but this isn't the recommended solution. Instead, it's better to deal with this locally in the mtk-sd driver, so let's do that.
--- drivers/mmc/host/mtk-sd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/mtk-sd.c +3 -0
@@ -2421,6 +2421,9 @@ static void msdc_restore_reg(struct msdc_host *host) }else {writel (host->save_para.pad_tune, host->base + tune_reg); } + +if (sdio_irq_claimed (host->mmc)) +__msdc_enable_sdio_irq (host,1 ); }static int msdc_runtime_suspend (struct device *dev)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 188/203 media: technisat-usb2: break out of loop at end of buffer
In reply to Sasha LevinFrom: Sean Young <[email protected]>
[ Upstream commit 0c4df39e504bf925ab666132ac3c98d6cbbe380b ]
Ensure we do not access the buffer beyond the end if no 0xff byte is encountered.
--- drivers/media/usb/dvb-usb/technisat-usb2.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/media/usb/dvb-usb/technisat-usb2.c +10 -12
@@ -608,10 +608,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)static int technisat_usb2_get_ir (struct dvb_usb_device *d) {struct technisat_usb2_state *state = d->priv; -u8 *buf = state->buf; -u8 *b; -int ret;struct ir_raw_event ev; +u8 *buf = state->buf; +int i, ret; buf[0 ] =GET_IR_DATA_VENDOR_REQUEST ; buf[1 ] =0x08 ;
@@ -647,26 +646,25 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)return 0 ;/* no key pressed */ /* decoding */ - b = buf+1 ;#if 0 deb_rc ("RC: %d " , ret); -debug_dump (b, ret, deb_rc); +debug_dump (buf +1 , ret, deb_rc);#endif ev.pulse =0 ; -while (1 ) { - ev.pulse = !ev.pulse; - ev.duration = (*b *FIRMWARE_CLOCK_DIVISOR *FIRMWARE_CLOCK_TICK ) /1000 ; -ir_raw_event_store (d->rc_dev, &ev); - - b++; -if (*b ==0xff ) { +for (i =1 ; i <ARRAY_SIZE (state->buf); i++) { +if (buf[i] ==0xff ) { ev.pulse =0 ; ev.duration =888888 *2 ;ir_raw_event_store (d->rc_dev, &ev);break ; } + + ev.pulse = !ev.pulse; + ev.duration = (buf[i] *FIRMWARE_CLOCK_DIVISOR * +FIRMWARE_CLOCK_TICK ) /1000 ; +ir_raw_event_store (d->rc_dev, &ev); }ir_raw_event_handle (d->rc_dev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 189/203 libertas: Add missing sentinel at end of if_usb.c fw_table
In reply to Sasha LevinFrom: Kevin Easton <[email protected]>
[ Upstream commit 764f3f1ecffc434096e0a2b02f1a6cc964a89df6 ]
This sentinel tells the firmware loading process when to stop.
--- drivers/net/wireless/marvell/libertas/if_usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/marvell/libertas/if_usb.c +2 -1
@@ -50,7 +50,8 @@ static const struct lbs_fw_table fw_table[] = { { MODEL_8388, "libertas/usb8388_v5.bin", NULL }, { MODEL_8388, "libertas/usb8388.bin", NULL }, { MODEL_8388, "usb8388.bin", NULL }, - { MODEL_8682, "libertas/usb8682.bin", NULL } + { MODEL_8682, "libertas/usb8682.bin", NULL }, + { 0, NULL, NULL } }; static const struct usb_device_id if_usb_table[] = {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 190/203 e1000e: add workaround for possible stalled packet
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit e5e9a2ecfe780975820e157b922edee715710b66 ]
This works around a possible stalled packet issue, which may occur due to clock recovery from the PCH being too slow, when the LAN is transitioning from K1 at 1G link speed.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204057
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 10 ++++++++++ drivers/net/ethernet/intel/e1000e/ich8lan.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +10 -0
@@ -1429,6 +1429,16 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)else phy_reg |=0xFA ;e1e_wphy_locked (hw,I217_PLL_CLOCK_GATE_REG , phy_reg); + +if (speed ==SPEED_1000 ) { + hw->phy.ops.read_reg_locked (hw,HV_PM_CTRL , + &phy_reg); + + phy_reg |=HV_PM_CTRL_K1_CLK_REQ ; + + hw->phy.ops.write_reg_locked (hw,HV_PM_CTRL , + phy_reg); + } } hw->phy.ops.release (hw);
drivers/net/ethernet/intel/e1000e/ich8lan.h +1 -1
@@ -210,7 +210,7 @@/* PHY Power Management Control */ #define HV_PM_CTRL PHY_REG(770, 17) -#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100 +#define HV_PM_CTRL_K1_CLK_REQ 0x200#define HV_PM_CTRL_K1_ENABLE 0x4000#define I217_PLL_CLOCK_GATE_REG PHY_REG(772, 28)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 191/203 ALSA: hda - Add a quirk model for fixing Huawei Matebook X right speaker
In reply to Sasha LevinFrom: Tomas Espeleta <[email protected]>
[ Upstream commit a2ef03fe617a8365fb7794531b11ba587509a9b9 ]
[ This is rather a revival of the patch Tomas sent in months ago, but
applying only with the quirk model option -- tiwai ]
Hard coded coefficients to make Huawuei Matebook X right speaker work. The Matebook X has a ALC298, please refer to bug 197801 on how these numbers were reverse engineered from the Windows driver
The reversed engineered sequence represents a repeating pattern of verbs, and the only values that are changing periodically are written on indexes 0x23 and 0x25:
0x500, 0x230x400, VALUE10x500, 0x250x400, VALUE2
* skipped reading sequences (0x500 - 0xc00 sequences are ignored)
* static values from reverse engineering are used
NOTE: since a significant risk is still considered, this is provided as an experimental fix that isn't applied as default for now. For enabling the fix, you'll have to choose huawei-mbx-stereo via model option of snd-hda-intel module.
If we get feedback from users that this works stably, we may apply it per default.
[ Some coding style fixes and replacement with AC_VERB_* by tiwai ]
--- Documentation/sound/hd-audio/models.rst | 3 + sound/pci/hda/patch_realtek.c | 74 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
Documentation/sound/hd-audio/models.rst +3 -0
@@ -260,6 +260,9 @@ alc295-hp-x360 HP Spectre X360 fixups alc-sense-combo Headset button support for Chrome platform +huawei-mbx-stereo + Enable initialization verbs for Huawei MBX stereo speakers; + might be risky, try this at your own risk ALC66x/67x/892 ==============
sound/pci/hda/patch_realtek.c +74 -0
98 lines not on this page · raw message
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 192/203 ALSA: hda - Drop unsol event handler for Intel HDMI codecs
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit f2dbe87c5ac1f88e6007ba1f1374f4bd8a197fb6 ]
We don't need to deal with the unsol events for Intel chips that are tied with the graphics via audio component notifier. Although the presence of the audio component is checked at the beginning of hdmi_unsol_event(), better to short cut by dropping unsol_event ops.
--- sound/pci/hda/patch_hdmi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +8 -1
@@ -2616,6 +2616,8 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec,/* precondition and allocation for Intel codecs */ static int alloc_intel_hdmi (struct hda_codec *codec) { +int err; +/* requires i915 binding */ if (!codec->bus->core.audio_component) {codec_info (codec,"No i915 binding for Intel HDMI/DP codec\n" );
@@ -2624,7 +2626,12 @@ static int alloc_intel_hdmi(struct hda_codec *codec)return -ENODEV ; } -return alloc_generic_hdmi (codec); + err =alloc_generic_hdmi (codec); +if (err <0 ) +return err; +/* no need to handle unsol events */ + codec->patch_ops.unsol_event =NULL ; +return 0 ; }/* parse and post-process for Intel codecs */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 193/203 drm/amd/powerplay/smu7: enforce minimal VBITimeout (v2)
In reply to Sasha LevinFrom: Ahzo <[email protected]>
[ Upstream commit f659bb6dae58c113805f92822e4c16ddd3156b79 ]
This fixes screen corruption/flickering on 75 Hz displays.
v2: make print statement debug only (Alex)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102646
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +5 -0
@@ -4068,6 +4068,11 @@ static int smu7_program_display_gap(struct pp_hwmgr *hwmgr) data->frame_time_x2 = frame_time_in_us *2 /100 ; +if (data->frame_time_x2 <280 ) { +pr_debug ("%s: enforce minimal VBITimeout: %d -> 280\n" , __func__, data->frame_time_x2); + data->frame_time_x2 =280 ; + } + display_gap2 = pre_vbi_time_in_us * (ref_clock /100 );cgs_write_ind_register (hwmgr->device,CGS_IND_REG__SMC , ixCG_DISPLAY_GAP_CNTL2, display_gap2);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 194/203 media: ttusb-dec: Fix info-leak in ttusb_dec_send_command()
In reply to Sasha LevinFrom: Tomas Bortoli <[email protected]>
[ Upstream commit a10feaf8c464c3f9cfdd3a8a7ce17e1c0d498da1 ]
The function at issue does not always initialize each byte allocated for 'b' and can therefore leak uninitialized memory to a USB device in the call to usb_bulk_msg()
Use kzalloc() instead of kmalloc()
--- drivers/media/usb/ttusb-dec/ttusb_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/ttusb-dec/ttusb_dec.c +1 -1
@@ -319,7 +319,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,dprintk ("%s\n" , __func__); - b =kmalloc (COMMAND_PACKET_SIZE +4 ,GFP_KERNEL ); + b =kzalloc (COMMAND_PACKET_SIZE +4 ,GFP_KERNEL );if (!b)return -ENOMEM ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 195/203 drm: fix module name in edid_firmware log message
In reply to Sasha LevinFrom: Jani Nikula <[email protected]>
[ Upstream commit ade925995b172f1d7410d1c665b2f47c5e99bef0 ]
The module is drm_kms_helper, not drm_kms_firmware.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204549
--- drivers/gpu/drm/drm_kms_helper_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_kms_helper_common.c +1 -1
@@ -40,7 +40,7 @@ MODULE_LICENSE("GPL and additional rights");/* Backward compatibility for drm_kms_helper.edid_firmware */ static int edid_firmware_set (const char *val,const struct kernel_param *kp) { -DRM_NOTE ("drm_kms_firmware.edid_firmware is deprecated, please use drm.edid_firmware instead.\n" ); +DRM_NOTE ("drm_kms_helper.edid_firmware is deprecated, please use drm.edid_firmware instead.\n" );return __drm_set_edid_firmware_path (val); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 196/203 ALSA: hda/realtek - Blacklist PC beep for Lenovo ThinkCentre M73/93
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 051c78af14fcd74a22b5af45548ad9d588247cc7 ]
Lenovo ThinkCentre M73 and M93 don't seem to have a proper beep although the driver tries to probe and set up blindly. Blacklist these machines for suppressing the beep creation.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -1058,6 +1058,9 @@ static const struct snd_pci_quirk beep_white_list[] = {SND_PCI_QUIRK (0x1043 ,0x834a ,"EeePC" ,1 ),SND_PCI_QUIRK (0x1458 ,0xa002 ,"GA-MA790X" ,1 ),SND_PCI_QUIRK (0x8086 ,0xd613 ,"Intel" ,1 ), +/* blacklist -- no beep available */ +SND_PCI_QUIRK (0x17aa ,0x309e ,"Lenovo ThinkCentre M73" ,0 ), + SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0), {} };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 197/203 iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 93d051550ee02eaff9a2541d825605a7bd778027 ]
Raven Ridge systems may have malfunction touchpad or hang at boot if incorrect IVRS IOAPIC is provided by BIOS.
Users already found correct "ivrs_ioapic=" values, let's put them inside kernel to workaround buggy BIOS.
--- drivers/iommu/Makefile | 2 +- drivers/iommu/amd_iommu.h | 14 +++++ drivers/iommu/amd_iommu_init.c | 5 +- drivers/iommu/amd_iommu_quirks.c | 92 ++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 drivers/iommu/amd_iommu.h create mode 100644 drivers/iommu/amd_iommu_quirks.c
drivers/iommu/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o obj-$(CONFIG_IOMMU_IOVA) += iova.o obj-$(CONFIG_OF_IOMMU) += of_iommu.o obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o -obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o +obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o amd_iommu_quirks.o obj-$(CONFIG_AMD_IOMMU_DEBUGFS) += amd_iommu_debugfs.o obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
drivers/iommu/amd_iommu.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef AMD_IOMMU_H +#define AMD_IOMMU_H + +int __init add_special_device (u8 type,u8 id,u16 *devid,bool cmd_line); + +#ifdef CONFIG_DMI +void amd_iommu_apply_ivrs_quirks (void ); +#else +static void amd_iommu_apply_ivrs_quirks (void ) { } +#endif + +#endif
drivers/iommu/amd_iommu_init.c +4 -1
@@ -32,6 +32,7 @@#include <asm/irq_remapping.h> #include <linux/crash_dump.h> +#include "amd_iommu.h" #include "amd_iommu_proto.h" #include "amd_iommu_types.h" #include "irq_remapping.h"
@@ -1002,7 +1003,7 @@ static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu,set_iommu_for_device (iommu, devid); } -static int __init add_special_device (u8 type,u8 id,u16 *devid,bool cmd_line) +int __init add_special_device (u8 type,u8 id,u16 *devid,bool cmd_line) {struct devid_map *entry;struct list_head *list;
@@ -1153,6 +1154,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,if (ret)return ret; +amd_iommu_apply_ivrs_quirks (); +/* * First save the recommended feature enable bits from ACPI */
drivers/iommu/amd_iommu_quirks.c new file +92 -0
92 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 198/203 zd1211rw: remove false assertion from zd_mac_clear()
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
[ Upstream commit 7a2eb7367fdea72e448d1a847aa857f6caf8ea2f ]
The function is called before the lock which is asserted was ever used. Just remove it.
--- drivers/net/wireless/zydas/zd1211rw/zd_mac.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/zydas/zd1211rw/zd_mac.c +0 -1
@@ -223,7 +223,6 @@ void zd_mac_clear(struct zd_mac *mac) {flush_workqueue (zd_workqueue);zd_chip_clear (&mac->chip); -lockdep_assert_held (&mac->lock);ZD_MEMCLEAR (mac,sizeof (struct zd_mac )); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 199/203 btrfs: delayed-inode: Kill the BUG_ON() in btrfs_delete_delayed_dir_index()
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 933c22a7512c5c09b1fdc46b557384efe8d03233 ]
There is one report of fuzzed image which leads to BUG_ON() in btrfs_delete_delayed_dir_index().
Although that fuzzed image can already be addressed by enhanced extent-tree error handler, it's still better to hunt down more BUG_ON().
This patch will hunt down two BUG_ON()s in btrfs_delete_delayed_dir_index():
- One for error from btrfs_delayed_item_reserve_metadata() Instead of BUG_ON(), we output an error message and free the item. And return the error.
All callers of this function handles the error by aborting current trasaction.
- One for possible EEXIST from __btrfs_add_delayed_deletion_item() That function can return -EEXIST.
We already have a good enough error message for that, only need to clean up the reserved metadata space and allocated item.
To help above cleanup, also modifiy __btrfs_remove_delayed_item() called in btrfs_release_delayed_item(), to skip unassociated item.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203253
--- fs/btrfs/delayed-inode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/btrfs/delayed-inode.c +11 -2
@@ -474,6 +474,9 @@ static void __btrfs_remove_delayed_item(struct btrfs_delayed_item *delayed_item)struct rb_root_cached *root;struct btrfs_delayed_root *delayed_root; +/* Not associated with any delayed_node */ +if (!delayed_item->delayed_node) +return ; delayed_root = delayed_item->delayed_node->root->fs_info->delayed_root;BUG_ON (!delayed_root);
@@ -1525,7 +1528,12 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,* we have reserved enough space when we start a new transaction, * so reserving metadata failure is impossible. */ -BUG_ON (ret); +if (ret <0 ) { +btrfs_err (trans->fs_info, +"metadata reservation failed for delayed dir item deltiona, should have been reserved" ); +btrfs_release_delayed_item (item); + goto end; + }mutex_lock (&node->mutex); ret =__btrfs_add_delayed_deletion_item (node, item);
@@ -1534,7 +1542,8 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,"err add delayed dir index item(index: %llu) into the deletion tree of the delayed node(root id: %llu, inode id: %llu, errno: %d)" , index, node->root->root_key.objectid, node->inode_id, ret); -BUG (); +btrfs_delayed_item_release_metadata (dir->root, item); +btrfs_release_delayed_item (item); }mutex_unlock (&node->mutex); end:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 200/203 btrfs: extent-tree: Make sure we only allocate extents from block groups with the same type
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 2a28468e525f3924efed7f29f2bc5a2926e7e19a ]
[BUG]
With fuzzed image and MIXED_GROUPS super flag, we can hit the following BUG_ON():
kernel BUG at fs/btrfs/delayed-ref.c:491!
invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
CPU: 0 PID: 1849 Comm: sync Tainted: G O 5.2.0-custom #27 RIP: 0010:update_existing_head_ref.cold+0x44/0x46 [btrfs] Call Trace: add_delayed_ref_head+0x20c/0x2d0 [btrfs] btrfs_add_delayed_tree_ref+0x1fc/0x490 [btrfs] btrfs_free_tree_block+0x123/0x380 [btrfs] __btrfs_cow_block+0x435/0x500 [btrfs] btrfs_cow_block+0x110/0x240 [btrfs] btrfs_search_slot+0x230/0xa00 [btrfs] ? __lock_acquire+0x105e/0x1e20 btrfs_insert_empty_items+0x67/0xc0 [btrfs] alloc_reserved_file_extent+0x9e/0x340 [btrfs] __btrfs_run_delayed_refs+0x78e/0x1240 [btrfs] ? kvm_clock_read+0x18/0x30 ? __sched_clock_gtod_offset+0x21/0x50 btrfs_run_delayed_refs.part.0+0x4e/0x180 [btrfs] btrfs_run_delayed_refs+0x23/0x30 [btrfs] btrfs_commit_transaction+0x53/0x9f0 [btrfs] btrfs_sync_fs+0x7c/0x1c0 [btrfs] ? __ia32_sys_fdatasync+0x20/0x20 sync_fs_one_sb+0x23/0x30 iterate_supers+0x95/0x100 ksys_sync+0x62/0xb0 __ia32_sys_sync+0xe/0x20 do_syscall_64+0x65/0x240 entry_SYSCALL_64_after_hwframe+0x49/0xbe
[CAUSE]
This situation is caused by several factors:
- Fuzzed image
The extent tree of this fs missed one backref for extent tree root. So we can allocated space from that slot.
- MIXED_BG feature
Super block has MIXED_BG flag.
- No mixed block groups exists
All block groups are just regular ones.
This makes data space_info->block_groups[] contains metadata block groups. And when we reserve space for data, we can use space in metadata block group.
Then we hit the following file operations:
- fallocate
We need to allocate data extents.
find_free_extent() choose to use the metadata block to allocate space from, and choose the space of extent tree root, since its backref is missing.
This generate one delayed ref head with is_data = 1.
- extent tree update
We need to update extent tree at run_delayed_ref time.
This generate one delayed ref head with is_data = 0, for the same bytenr of old extent tree root.
Then we trigger the BUG_ON().
[FIX]
The quick fix here is to check block_group->flags before using it.
The problem can only happen for MIXED_GROUPS fs. Regular filesystems won't have space_info with DATA|METADATA flag, and no way to hit the bug.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203255
--- fs/btrfs/extent-tree.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/extent-tree.c +8 -0
@@ -5751,6 +5751,14 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,*/ if ((flags & extra) && !(block_group->flags & extra)) goto loop; + +/* +* This block group has different flags than we want. +* It's possible that we have MIXED_GROUP flag but no +* block group is mixed. Just skip such block group. +*/ +btrfs_release_block_group (block_group, delalloc); +continue ; } have_block_group:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 201/203 btrfs: tree-checker: Add ROOT_ITEM check
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 259ee7754b6793af8bdd77f9ca818bc41cfe9541 ]
This patch will introduce ROOT_ITEM check, which includes:
- Key->objectid and key->offset check
Currently only some easy check, e.g. 0 as rootid is invalid.
- Item size check
Root item size is fixed.
- Generation checks
Generation, generation_v2 and last_snapshot should not be greater than super generation + 1
- Level and alignment check
Level should be in [0, 7], and bytenr must be aligned to sector size.
- Flags check
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203261
--- fs/btrfs/tree-checker.c | 92 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
fs/btrfs/tree-checker.c +92 -0
@@ -821,6 +821,95 @@ static int check_inode_item(struct extent_buffer *leaf,return 0 ; } +static int check_root_item (struct extent_buffer *leaf,struct btrfs_key *key, +int slot) +{ +struct btrfs_fs_info *fs_info = leaf->fs_info; +struct btrfs_root_item ri; +const u64 valid_root_flags =BTRFS_ROOT_SUBVOL_RDONLY | +BTRFS_ROOT_SUBVOL_DEAD ; + +/* No such tree id */ +if (key->objectid ==0 ) { +generic_err (leaf, slot,"invalid root id 0" ); +return -EUCLEAN ; + } + +/* +* Some older kernel may create ROOT_ITEM with non-zero offset, so here +* we only check offset for reloc tree whose key->offset must be a +* valid tree. +*/ +if (key->objectid ==BTRFS_TREE_RELOC_OBJECTID && key->offset ==0 ) { +generic_err (leaf, slot,"invalid root id 0 for reloc tree" ); +return -EUCLEAN ; + } + +if (btrfs_item_size_nr (leaf, slot) !=sizeof (ri)) { +generic_err (leaf, slot, +"invalid root item size, have %u expect %zu" , +btrfs_item_size_nr (leaf, slot),sizeof (ri)); + } + +read_extent_buffer (leaf, &ri,btrfs_item_ptr_offset (leaf, slot), +sizeof (ri)); + +/* Generation related */ +if (btrfs_root_generation (&ri) > +btrfs_super_generation (fs_info->super_copy) +1 ) { +generic_err (leaf, slot, +"invalid root generation, have %llu expect (0, %llu]" , +btrfs_root_generation (&ri), +btrfs_super_generation (fs_info->super_copy) +1 ); +return -EUCLEAN ; + } +if (btrfs_root_generation_v2 (&ri) > +btrfs_super_generation (fs_info->super_copy) +1 ) { +generic_err (leaf, slot, +"invalid root v2 generation, have %llu expect (0, %llu]" , +btrfs_root_generation_v2 (&ri), +btrfs_super_generation (fs_info->super_copy) +1 ); +return -EUCLEAN ; + } +if (btrfs_root_last_snapshot (&ri) > +btrfs_super_generation (fs_info->super_copy) +1 ) { +generic_err (leaf, slot, +"invalid root last_snapshot, have %llu expect (0, %llu]" , +btrfs_root_last_snapshot (&ri), +btrfs_super_generation (fs_info->super_copy) +1 ); +return -EUCLEAN ; + } + +/* Alignment and level check */ +if (!IS_ALIGNED (btrfs_root_bytenr (&ri), fs_info->sectorsize)) { +generic_err (leaf, slot, +"invalid root bytenr, have %llu expect to be aligned to %u" , +btrfs_root_bytenr (&ri), fs_info->sectorsize); +return -EUCLEAN ; + } +if (btrfs_root_level (&ri) >=BTRFS_MAX_LEVEL ) { +generic_err (leaf, slot, +"invalid root level, have %u expect [0, %u]" , +btrfs_root_level (&ri),BTRFS_MAX_LEVEL -1 ); +return -EUCLEAN ; + } +if (ri.drop_level >=BTRFS_MAX_LEVEL ) { +generic_err (leaf, slot, +"invalid root level, have %u expect [0, %u]" , + ri.drop_level,BTRFS_MAX_LEVEL -1 ); +return -EUCLEAN ; + } + +/* Flags check */ +if (btrfs_root_flags (&ri) & ~valid_root_flags) { +generic_err (leaf, slot, +"invalid root flags, have 0x%llx expect mask 0x%llx" , +btrfs_root_flags (&ri), valid_root_flags); +return -EUCLEAN ; + } +return 0 ; +} +/* * Common point to switch the item-specific validation. */
@@ -856,6 +945,9 @@ static int check_leaf_item(struct extent_buffer *leaf,case BTRFS_INODE_ITEM_KEY : ret =check_inode_item (leaf, key, slot);break ; +case BTRFS_ROOT_ITEM_KEY : + ret =check_root_item (leaf, key, slot); +break ; }return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 202/203 btrfs: Detect unbalanced tree with empty leaf before crashing btree operations
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 62fdaa52a3d00a875da771719b6dc537ca79fce1 ]
[BUG]
With crafted image, btrfs will panic at btree operations:
kernel BUG at fs/btrfs/ctree.c:3894!
invalid opcode: 0000 [#1] SMP PTI
CPU: 0 PID: 1138 Comm: btrfs-transacti Not tainted 5.0.0-rc8+ #9 RIP: 0010:__push_leaf_left+0x6b6/0x6e0 RSP: 0018:ffffc0bd4128b990 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffa0a4ab8f0e38 RCX: 0000000000000000 RDX: ffffa0a280000000 RSI: 0000000000000000 RDI: ffffa0a4b3814000 RBP: ffffc0bd4128ba38 R08: 0000000000001000 R09: ffffc0bd4128b948 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000240 R13: ffffa0a4b556fb60 R14: ffffa0a4ab8f0af0 R15: ffffa0a4ab8f0af0 FS: 0000000000000000(0000) GS:ffffa0a4b7a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f2461c80020 CR3: 000000022b32a006 CR4: 00000000000206f0 Call Trace: ? _cond_resched+0x1a/0x50 push_leaf_left+0x179/0x190 btrfs_del_items+0x316/0x470 btrfs_del_csums+0x215/0x3a0 __btrfs_free_extent.isra.72+0x5a7/0xbe0 __btrfs_run_delayed_refs+0x539/0x1120 btrfs_run_delayed_refs+0xdb/0x1b0 btrfs_commit_transaction+0x52/0x950 ? start_transaction+0x94/0x450 transaction_kthread+0x163/0x190 kthread+0x105/0x140 ? btrfs_cleanup_transaction+0x560/0x560 ? kthread_destroy_worker+0x50/0x50 ret_from_fork+0x35/0x40 Modules linked in: ---[ end trace c2425e6e89b5558f ]---
[CAUSE]
The offending csum tree looks like this:
checksum tree key (CSUM_TREE ROOT_ITEM 0)
node 29741056 level 1 items 14 free 107 generation 19 owner CSUM_TREE
... key (EXTENT_CSUM EXTENT_CSUM 85975040) block 29630464 gen 17 key (EXTENT_CSUM EXTENT_CSUM 89911296) block 29642752 gen 17 <<< key (EXTENT_CSUM EXTENT_CSUM 92274688) block 29646848 gen 17 ...
leaf 29630464 items 6 free space 1 generation 17 owner CSUM_TREE
item 0 key (EXTENT_CSUM EXTENT_CSUM 85975040) itemoff 3987 itemsize 8 range start 85975040 end 85983232 length 8192 ...
leaf 29642752 items 0 free space 3995 generation 17 owner 0
^ empty leaf invalid owner ^
leaf 29646848 items 1 free space 602 generation 17 owner CSUM_TREE
item 0 key (EXTENT_CSUM EXTENT_CSUM 92274688) itemoff 627 itemsize 3368 range start 92274688 end 95723520 length 3448832
So we have a corrupted csum tree where one tree leaf is completely empty, causing unbalanced btree, thus leading to unexpected btree balance error.
[FIX]
For this particular case, we handle it in two directions to catch it:
- Check if the tree block is empty through btrfs_verify_level_key() So that invalid tree blocks won't be read out through btrfs_search_slot() and its variants.
- Check 0 tree owner in tree checker
NO tree is using 0 as its tree owner, detect it and reject at tree block read time.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202821
--- fs/btrfs/disk-io.c | 10 ++++++++++ fs/btrfs/tree-checker.c | 6 ++++++ 2 files changed, 16 insertions(+)
fs/btrfs/disk-io.c +10 -0
@@ -416,6 +416,16 @@ int btrfs_verify_level_key(struct extent_buffer *eb, int level,*/ if (btrfs_header_generation (eb) > fs_info->last_trans_committed)return 0 ; + +/* We have @first_key, so this @eb must have at least one item */ +if (btrfs_header_nritems (eb) ==0 ) { +btrfs_err (fs_info, +"invalid tree nritems, bytenr=%llu nritems=0 expect >0" , + eb->start); +WARN_ON (IS_ENABLED (CONFIG_BTRFS_DEBUG )); +return -EUCLEAN ; + } +if (found_level)btrfs_node_key_to_cpu (eb, &found_key,0 );else
fs/btrfs/tree-checker.c +6 -0
@@ -991,6 +991,12 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data) owner);return -EUCLEAN ; } +/* Unknown tree */ +if (owner ==0 ) { +generic_err (leaf,0 , +"invalid owner, root 0 is not defined" ); +return -EUCLEAN ; + }return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 203/203 kvm: Nested KVM MMUs need PAE root too
In reply to Sasha LevinFrom: Jiří Paleček <[email protected]>
[ Upstream commit 1cfff4d9a5d01fa61e5768a6afffc81ae1c8ecb9 ]
On AMD processors, in PAE 32bit mode, nested KVM instances don't work. The L0 host get a kernel OOPS, which is related to arch.mmu->pae_root being NULL.
The reason for this is that when setting up nested KVM instance, arch.mmu is set to &arch.guest_mmu (while normally, it would be &arch.root_mmu). However, the initialization and allocation of pae_root only creates it in root_mmu. KVM code (ie. in mmu_alloc_shadow_roots) then accesses arch.mmu->pae_root, which is the unallocated arch.guest_mmu->pae_root.
This fix just allocates (and frees) pae_root in both guest_mmu and root_mmu (and also lm_root if it was allocated). The allocation is subject to previous restrictions ie. it won't allocate anything on 64-bit and AFAIK not on Intel.
--- arch/x86/kvm/mmu.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
arch/x86/kvm/mmu.c +22 -8
@@ -5611,13 +5611,13 @@ slot_handle_leaf(struct kvm *kvm, struct kvm_memory_slot *memslot, PT_PAGE_TABLE_LEVEL, lock_flush_tlb); } -static void free_mmu_pages (struct kvm_vcpu *vcpu) +static void free_mmu_pages (struct kvm_mmu *mmu) { -free_page ((unsigned long )vcpu->arch.mmu->pae_root); -free_page ((unsigned long )vcpu->arch.mmu->lm_root); +free_page ((unsigned long )mmu->pae_root); +free_page ((unsigned long )mmu->lm_root); } -static int alloc_mmu_pages (struct kvm_vcpu *vcpu) +static int alloc_mmu_pages (struct kvm_vcpu *vcpu,struct kvm_mmu *mmu) {struct page *page;int i;
@@ -5638,9 +5638,9 @@ static int alloc_mmu_pages(struct kvm_vcpu *vcpu)if (!page)return -ENOMEM ; - vcpu->arch.mmu->pae_root =page_address (page); + mmu->pae_root =page_address (page);for (i =0 ; i <4 ; ++i) - vcpu->arch.mmu->pae_root[i] =INVALID_PAGE ; + mmu->pae_root[i] =INVALID_PAGE ;return 0 ; }
@@ -5648,6 +5648,7 @@ static int alloc_mmu_pages(struct kvm_vcpu *vcpu)int kvm_mmu_create (struct kvm_vcpu *vcpu) {uint i; +int ret; vcpu->arch.mmu = &vcpu->arch.root_mmu; vcpu->arch.walk_mmu = &vcpu->arch.root_mmu;
@@ -5665,7 +5666,19 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu) vcpu->arch.guest_mmu.prev_roots[i] =KVM_MMU_ROOT_INFO_INVALID ; vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa; -return alloc_mmu_pages (vcpu); + + ret =alloc_mmu_pages (vcpu, &vcpu->arch.guest_mmu); +if (ret) +return ret; + + ret =alloc_mmu_pages (vcpu, &vcpu->arch.root_mmu); +if (ret) + goto fail_allocate_root; + +return ret; + fail_allocate_root: +free_mmu_pages (&vcpu->arch.guest_mmu); +return ret; }
@@ -6168,7 +6181,8 @@ unsigned long kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm)void kvm_mmu_destroy (struct kvm_vcpu *vcpu) {kvm_mmu_unload (vcpu); -free_mmu_pages (vcpu); +free_mmu_pages (&vcpu->arch.root_mmu); +free_mmu_pages (&vcpu->arch.guest_mmu);mmu_free_memory_caches (vcpu); }
Signature · 1 line
2.20.1