media: ov6650: Fix control handler not freed on init error
Subsystems (41)
Sasha Levin
maintainerPATCH 192/350 iio: dln2-adc: fix iio_triggered_buffer_postenable() position
In reply to Sasha LevinFrom: Alexandru Ardelean <[email protected]>
[ Upstream commit a7bddfe2dfce1d8859422124abe1964e0ecd386e ]
The iio_triggered_buffer_postenable() hook should be called first to attach the poll function. The iio_triggered_buffer_predisable() hook is called last (as is it should).
This change moves iio_triggered_buffer_postenable() to be called first. It adds iio_triggered_buffer_predisable() on the error paths of the postenable hook.
For the predisable hook, some code-paths have been changed to make sure that the iio_triggered_buffer_predisable() hook gets called in case there is an error before it.
--- drivers/iio/adc/dln2-adc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/iio/adc/dln2-adc.c +14 -6
@@ -524,6 +524,10 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)u16 conflict;unsigned int trigger_chan; + ret =iio_triggered_buffer_postenable (indio_dev); +if (ret) +return ret; +mutex_lock (&dln2->mutex);/* Enable ADC */
@@ -537,6 +541,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev) (int)conflict); ret = -EBUSY ; } +iio_triggered_buffer_predisable (indio_dev);return ret; }
@@ -550,6 +555,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)mutex_unlock (&dln2->mutex);if (ret <0 ) {dev_dbg (&dln2->pdev->dev,"Problem in %s\n" , __func__); +iio_triggered_buffer_predisable (indio_dev);return ret; } }else {
@@ -557,12 +563,12 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)mutex_unlock (&dln2->mutex); } -return iio_triggered_buffer_postenable (indio_dev); +return 0 ; }static int dln2_adc_triggered_buffer_predisable (struct iio_dev *indio_dev) { -int ret; +int ret, ret2;struct dln2_adc *dln2 =iio_priv (indio_dev);mutex_lock (&dln2->mutex);
@@ -577,12 +583,14 @@ static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev) ret =dln2_adc_set_port_enabled (dln2, false,NULL );mutex_unlock (&dln2->mutex); -if (ret <0 ) { +if (ret <0 )dev_dbg (&dln2->pdev->dev,"Problem in %s\n" , __func__); -return ret; - } -return iio_triggered_buffer_predisable (indio_dev); + ret2 =iio_triggered_buffer_predisable (indio_dev); +if (ret ==0 ) + ret = ret2; + +return ret; }static const struct iio_buffer_setup_ops dln2_adc_buffer_setup_ops = {
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerRe: [PATCH AUTOSEL 5.4 192/350] iio: dln2-adc: fix iio_triggered_buffer_postenable() position
Quoted 8 lines · On Tue, 10 Dec 2019 16:04:57 -0500 Sasha Levin <[email protected]> wrote:
From: Alexandru Ardelean <[email protected]>
[ Upstream commit
a7bddfe2dfce1d8859422124abe1964e0ecd386e]The
iio_triggered_buffer_postenable()hook should be called first to attach the poll function. Theiio_triggered_buffer_predisable()hook is called last (as is it should).
Quoted 6 lines
This change moves
iio_triggered_buffer_postenable()to be called first. It addsiio_triggered_buffer_predisable()on the error paths of the postenable hook.
For the predisable hook, some code-paths have been changed to make sure that theiio_triggered_buffer_predisable()hook gets called in case there is an error before it.
Again, fixing logic to allow a more generic rework rather than actual bug.
I didn't do a very good job of adding notes to all of these to indicate they weren't stable material. Sorry about that.
Note I am fairly careful about tagging fixes that should go to stable...
Jonathan
Quoted 73 lines
Signed-off-by Alexandru Ardelean <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/iio/adc/dln2-adc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)drivers/iio/adc/dln2-adc.c +14
-6@@ -524,6 +524,10 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)u16 conflict;unsigned int trigger_chan; + ret =iio_triggered_buffer_postenable (indio_dev); +if (ret) +return ret; +mutex_lock (&dln2->mutex);/* Enable ADC */ @@ -537,6 +541,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev) (int)conflict); ret = -EBUSY ; } +iio_triggered_buffer_predisable (indio_dev);return ret; }@@ -550,6 +555,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)mutex_unlock (&dln2->mutex);if (ret <0 ) {dev_dbg (&dln2->pdev->dev,"Problem in %s\n" , __func__); +iio_triggered_buffer_predisable (indio_dev);return ret; } }else {@@ -557,12 +563,12 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)mutex_unlock (&dln2->mutex); } -return iio_triggered_buffer_postenable (indio_dev); +return 0 ; }static int dln2_adc_triggered_buffer_predisable (struct iio_dev *indio_dev) { -int ret; +int ret, ret2;struct dln2_adc *dln2 =iio_priv (indio_dev);mutex_lock (&dln2->mutex);@@ -577,12 +583,14 @@ static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev) ret =dln2_adc_set_port_enabled (dln2, false,NULL );mutex_unlock (&dln2->mutex); -if (ret <0 ) { +if (ret <0 )dev_dbg (&dln2->pdev->dev,"Problem in %s\n" , __func__); -return ret; - } -return iio_triggered_buffer_predisable (indio_dev); + ret2 =iio_triggered_buffer_predisable (indio_dev); +if (ret ==0 ) + ret = ret2; + +return ret; }static const struct iio_buffer_setup_ops dln2_adc_buffer_setup_ops = {
Sasha Levin
maintainerPATCH 193/350 libbpf: Fix error handling in bpf_map__reuse_fd()
In reply to Sasha LevinFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit d1b4574a4b86565325ef2e545eda8dfc9aa07c60 ]
bpf_map__reuse_fd() was calling close() in the error path before returning an error value based on errno. However, close can change errno, so that can lead to potentially misleading error messages. Instead, explicitly store errno in the err variable before each goto.
--- tools/lib/bpf/libbpf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
tools/lib/bpf/libbpf.c +10 -4
@@ -1897,16 +1897,22 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)return -errno; new_fd =open ("/" ,O_RDONLY |O_CLOEXEC ); -if (new_fd <0 ) +if (new_fd <0 ) { + err = -errno; goto err_free_new_name; + } new_fd =dup3 (fd, new_fd,O_CLOEXEC ); -if (new_fd <0 ) +if (new_fd <0 ) { + err = -errno; goto err_close_new_fd; + } err =zclose (map->fd); -if (err) +if (err) { + err = -errno; goto err_close_new_fd; + }free (map->name); map->fd = new_fd;
@@ -1925,7 +1931,7 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)close (new_fd); err_free_new_name:free (new_name); -return -errno; +return err; }int bpf_map__resize (struct bpf_map *map,__u32 max_entries)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 194/350 Bluetooth: Fix advertising duplicated flags
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 6012b9346d8959194c239fd60a62dfec98d43048 ]
Instances may have flags set as part of its data in which case the code should not attempt to add it again otherwise it can cause duplication:
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 35
Handle: 0x00
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x06
Flags: 0x04
BR/EDR Not Supported
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported--- net/bluetooth/hci_request.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/bluetooth/hci_request.c +9 -0
@@ -1273,6 +1273,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) instance_flags =get_adv_instance_flags (hdev, instance); +/* If instance already has the flags set skip adding it once +* again. +*/ +if (adv_instance &&eir_get_data (adv_instance->adv_data, + adv_instance->adv_data_len,EIR_FLAGS , +NULL )) + goto skip_flags; +/* The Add Advertising command allows userspace to set both the general * and limited discoverable flags. */
@@ -1305,6 +1313,7 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) } } +skip_flags:if (adv_instance) {memcpy (ptr, adv_instance->adv_data, adv_instance->adv_data_len);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 195/350 ALSA: pcm: Fix missing check of the new non-cached buffer type
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 6111fd2370eecae9f11bfdc08ba097e0b51fcfd3 ]
The check for the mmap support via hw_support_mmap() function misses the case where the device is with SNDRV_DMA_TYPE_DEV_UC, which should have been treated equally as SNDRV_DMA_TYPE_DEV. Let's fix it.
Note that this bug doesn't hit any practical problem, because SNDRV_DMA_TYPE_DEV_UC is used only for x86-specific drivers (snd-hda-intel and snd-intel8x0) for the specific platforms that need the non-cached buffers. And, on such platforms, hw_support_mmap() already returns true in anyway. That's the reason I didn't put Cc-to-stable mark here. This is only for any theoretical future extension.
--- sound/core/pcm_native.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/pcm_native.c +2 -1
@@ -222,7 +222,8 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream)return false;if (substream->ops->mmap || - substream->dma_buffer.dev.type !=SNDRV_DMA_TYPE_DEV ) + (substream->dma_buffer.dev.type !=SNDRV_DMA_TYPE_DEV && + substream->dma_buffer.dev.type !=SNDRV_DMA_TYPE_DEV_UC ))return true;return dma_can_mmap (substream->dma_buffer.dev.dev);
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Sasha Levin
maintainerPATCH 196/350 spi: sifive: disable clk when probe fails and remove
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit a725272bda77e61c1b4de85c7b0c875b2ea639b6 ]
The driver forgets to disable and unprepare clk when probe fails and remove.
Add the calls to fix the problem.
--- drivers/spi/spi-sifive.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/spi/spi-sifive.c +7 -4
@@ -357,14 +357,14 @@ static int sifive_spi_probe(struct platform_device *pdev)if (!cs_bits) {dev_err (&pdev->dev,"Could not auto probe CS lines\n" ); ret = -EINVAL ; - goto put_master; + goto disable_clk; } num_cs =ilog2 (cs_bits) +1 ;if (num_cs >SIFIVE_SPI_MAX_CS ) {dev_err (&pdev->dev,"Invalid number of spi slaves\n" ); ret = -EINVAL ; - goto put_master; + goto disable_clk; }/* Define our master */
@@ -393,7 +393,7 @@ static int sifive_spi_probe(struct platform_device *pdev) dev_name(&pdev->dev), spi);if (ret) {dev_err (&pdev->dev,"Unable to bind to interrupt\n" ); - goto put_master; + goto disable_clk; } dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
@@ -402,11 +402,13 @@ static int sifive_spi_probe(struct platform_device *pdev) ret =devm_spi_register_master (&pdev->dev, master);if (ret <0 ) {dev_err (&pdev->dev,"spi_register_master failed\n" ); - goto put_master; + goto disable_clk; }return 0 ; +disable_clk: +clk_disable_unprepare (spi->clk); put_master:spi_master_put (master);
@@ -420,6 +422,7 @@ static int sifive_spi_remove(struct platform_device *pdev)/* Disable all the interrupts just in case */ sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); +clk_disable_unprepare (spi->clk);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 197/350 ASoC: SOF: imx: fix reverse CONFIG_SND_SOC_SOF_OF dependency
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit f9ad75468453b019b92c5296e6a04bf7c37f49e4 ]
updated solution to the problem reported with randconfig:
CONFIG_SND_SOC_SOF_IMX depends on CONFIG_SND_SOC_SOF, but is in turn referenced by the sof-of-dev driver. This creates a reverse dependency that manifests in a link error when CONFIG_SND_SOC_SOF_OF is built-in but CONFIG_SND_SOC_SOF_IMX=m:
sound/soc/sof/sof-of-dev.o:(.data+0x118): undefined reference to `sof_imx8_ops'
use def_trisate to propagate the right settings without select.
--- sound/soc/sof/imx/Kconfig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/soc/sof/imx/Kconfig +6 -2
@@ -11,8 +11,8 @@ config SND_SOC_SOF_IMX_TOPLEVEL if SND_SOC_SOF_IMX_TOPLEVEL -config SND_SOC_SOF_IMX8 - tristate "SOF support for i.MX8" +config SND_SOC_SOF_IMX8_SUPPORT + bool "SOF support for i.MX8" depends on IMX_SCU depends on IMX_DSP help
@@ -20,4 +20,8 @@ config SND_SOC_SOF_IMX8 Say Y if you have such a device. If unsure select "N". +config SND_SOC_SOF_IMX8 + def_tristate SND_SOC_SOF_OF + depends on SND_SOC_SOF_IMX8_SUPPORT + endif ## SND_SOC_SOF_IMX_IMX_TOPLEVEL
Signature · 1 line
2.20.1
Mark Brown
maintainerRe: [PATCH AUTOSEL 5.4 197/350] ASoC: SOF: imx: fix reverse CONFIG_SND_SOC_SOF_OF dependency
Quoted 10 lines · Sasha Levin
From: Pierre-Louis Bossart <[email protected]>
[ Upstream commit
f9ad75468453b019b92c5296e6a04bf7c37f49e4]updated solution to the problem reported with randconfig:
CONFIG_SND_SOC_SOF_IMXdepends onCONFIG_SND_SOC_SOF, but is in turn referenced by the sof-of-dev driver. This creates a reverse dependency that manifests in a link error whenCONFIG_SND_SOC_SOF_OFis built-in butCONFIG_SND_SOC_SOF_IMX=m:
Are you sure this doesn't depend on any other Kconfig changes?
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.4 197/350] ASoC: SOF: imx: fix reverse CONFIG_SND_SOC_SOF_OF dependency
Quoted 5 lines · Mark Brown
Quoted 4 lines · Sasha Levin
From: Pierre-Louis Bossart <[email protected]>
[ Upstream commit
f9ad75468453b019b92c5296e6a04bf7c37f49e4]
Quoted 8 lines
Quoted 6 lines
updated solution to the problem reported with randconfig:
CONFIG_SND_SOC_SOF_IMXdepends onCONFIG_SND_SOC_SOF, but is in turn referenced by the sof-of-dev driver. This creates a reverse dependency that manifests in a link error whenCONFIG_SND_SOC_SOF_OFis built-in butCONFIG_SND_SOC_SOF_IMX=m:Are you sure this doesn't depend on any other
Kconfigchanges?
Nope, but it didn't fail my build tests.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 198/350 pinctrl: qcom: sc7180: Add missing tile info in SDC_QDSD_PINGROUP/UFS_RESET
In reply to Sasha LevinFrom: Rajendra Nayak <[email protected]>
[ Upstream commit 81898a44f288607cb3b11a42aed6efb646891c19 ]
The SDC_QDSD_PINGROUP/UFS_RESET macros are missing the .tile info needed to calculate the right register offsets. Adding them here and also adjusting the offsets accordingly.
--- drivers/pinctrl/qcom/pinctrl-sc7180.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/pinctrl/qcom/pinctrl-sc7180.c +10 -8
@@ -77,6 +77,7 @@ enum { .intr_cfg_reg = 0, \ .intr_status_reg = 0, \ .intr_target_reg = 0, \ + .tile = SOUTH, \ .mux_bit = -1, \ .pull_bit = pull, \ .drv_bit = drv, \
@@ -102,6 +103,7 @@ enum { .intr_cfg_reg = 0, \ .intr_status_reg = 0, \ .intr_target_reg = 0, \ + .tile = SOUTH, \ .mux_bit = -1, \ .pull_bit = 3, \ .drv_bit = 0, \
@@ -1087,14 +1089,14 @@ static const struct msm_pingroup sc7180_groups[] = { [116] = PINGROUP(116, WEST, qup04, qup04, _, _, _, _, _, _, _), [117] = PINGROUP(117, WEST, dp_hot, _, _, _, _, _, _, _, _), [118] = PINGROUP(118, WEST, _, _, _, _, _, _, _, _, _), - [119] = UFS_RESET(ufs_reset, 0x97f000), - [120] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x97a000, 15, 0), - [121] = SDC_QDSD_PINGROUP(sdc1_clk, 0x97a000, 13, 6), - [122] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x97a000, 11, 3), - [123] = SDC_QDSD_PINGROUP(sdc1_data, 0x97a000, 9, 0), - [124] = SDC_QDSD_PINGROUP(sdc2_clk, 0x97b000, 14, 6), - [125] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x97b000, 11, 3), - [126] = SDC_QDSD_PINGROUP(sdc2_data, 0x97b000, 9, 0), + [119] = UFS_RESET(ufs_reset, 0x7f000), + [120] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x7a000, 15, 0), + [121] = SDC_QDSD_PINGROUP(sdc1_clk, 0x7a000, 13, 6), + [122] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x7a000, 11, 3), + [123] = SDC_QDSD_PINGROUP(sdc1_data, 0x7a000, 9, 0), + [124] = SDC_QDSD_PINGROUP(sdc2_clk, 0x7b000, 14, 6), + [125] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x7b000, 11, 3), + [126] = SDC_QDSD_PINGROUP(sdc2_data, 0x7b000, 9, 0), };static const struct msm_pinctrl_soc_data sc7180_pinctrl = {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 199/350 pinctrl: amd: fix __iomem annotation in amd_gpio_irq_handler()
In reply to Sasha LevinFrom: "Ben Dooks (Codethink)" <[email protected]>
[ Upstream commit 10ff58aa3c2e2a093b6ad615a7e3d8bb0dc613e5 ]
The regs pointer in amd_gpio_irq_handler() should have __iomem on it, so add that to fix the following sparse warnings:
drivers/pinctrl/pinctrl-amd.c:555:14: warning: incorrect type in assignment (different address spaces)drivers/pinctrl/pinctrl-amd.c:555:14: expected unsigned int [usertype] *regsdrivers/pinctrl/pinctrl-amd.c:555:14: got void [noderef] <asn:2> *basedrivers/pinctrl/pinctrl-amd.c:563:34: warning: incorrect type in argument 1 (different address spaces)drivers/pinctrl/pinctrl-amd.c:563:34: expected void const volatile [noderef] <asn:2> *addrdrivers/pinctrl/pinctrl-amd.c:563:34: got unsigned int [usertype] *drivers/pinctrl/pinctrl-amd.c:580:34: warning: incorrect type in argument 1 (different address spaces)drivers/pinctrl/pinctrl-amd.c:580:34: expected void const volatile [noderef] <asn:2> *addrdrivers/pinctrl/pinctrl-amd.c:580:34: got unsigned int [usertype] *drivers/pinctrl/pinctrl-amd.c:587:25: warning: incorrect type in argument 2 (different address spaces)drivers/pinctrl/pinctrl-amd.c:587:25: expected void volatile [noderef] <asn:2> *addrdrivers/pinctrl/pinctrl-amd.c:587:25: got unsigned int [usertype] *
--- drivers/pinctrl/pinctrl-amd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-amd.c +2 -1
@@ -540,7 +540,8 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)irqreturn_t ret =IRQ_NONE ;unsigned int i, irqnr;unsigned long flags; -u32 *regs, regval; +u32 __iomem *regs; +u32 regval;u64 status, mask;/* Read the wake status */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 200/350 ixgbe: protect TX timestamping from API misuse
In reply to Sasha LevinFrom: Manjunath Patil <[email protected]>
[ Upstream commit 07066d9dc3d2326fbad8f7b0cb0120cff7b7dedb ]
HW timestamping can only be requested for a packet if the NIC is first setup via ioctl(SIOCSHWTSTAMP). If this step was skipped, then the ixgbe driver still allowed TX packets to request HW timestamping. In this situation, we see 'clearing Tx Timestamp hang' noise in the log.
Fix this by checking that the NIC is configured for HW TX timestamping before accepting a HW TX timestamping request.
Similar-to:
commit 26bd4e2db06b ("igb: protect TX timestamping from API misuse") commit 0a6f2f05a2f5 ("igb: Fix a test with HWTSTAMP_TX_ON")
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
@@ -8639,7 +8639,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) && adapter->ptp_clock) { -if (!test_and_set_bit_lock (__IXGBE_PTP_TX_IN_PROGRESS, +if (adapter->tstamp_config.tx_type ==HWTSTAMP_TX_ON && + !test_and_set_bit_lock (__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state)) {skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; tx_flags |=IXGBE_TX_FLAGS_TSTAMP ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 201/350 cpufreq: sun50i: Fix CPU speed bin detection
In reply to Sasha LevinFrom: Ondrej Jirman <[email protected]>
[ Upstream commit c23734487fb44ee16c1b007ba72d793c085e4ec4 ]
I have observed failures to boot on Orange Pi 3, because this driver determined that my SoC is from the normal bin, but my SoC only works reliably with the OPP values for the slowest bin.
By querying H6 owners, it was found that e-fuse values found in the wild are in the range of 1-3, value of 7 was not reported, yet. From this and from unused defines in BSP code, it can be assumed that meaning of efuse values on H6 actually is:
- 1 = slowest bin
- 2 = normal bin
- 3 = fastest bin
Vendor code actually treats 0 and 2 as invalid efuse values, but later treats all invalid values as a normal bin. This looks like a mistake in bin detection code, that was plastered over by a hack in cpufreq code, so let's not repeat it here. It probably only works because there are no SoCs in the wild with efuse value of 0, and fast bin SoCs are made to use normal bin OPP tables, which is also safe.
Let's play it safe and interpret 0 as the slowest bin, but fix detection of other bins to match this research. More research will be done before actual OPP tables are merged.
--- drivers/cpufreq/sun50i-cpufreq-nvmem.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/cpufreq/sun50i-cpufreq-nvmem.c +10 -15
@@ -25,7 +25,7 @@static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev;/** -* sun50i_cpufreq_get_efuse() - Parse and return efuse value present on SoC +* sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value * @versions: Set to the value parsed from efuse * * Returns 0 if success.
@@ -69,21 +69,16 @@ static int sun50i_cpufreq_get_efuse(u32 *versions)return PTR_ERR (speedbin); efuse_value = (*speedbin >>NVMEM_SHIFT ) &NVMEM_MASK ; -switch (efuse_value) { -case 0b0001 : - *versions =1 ; -break ; -case 0b0011 : - *versions =2 ; -break ; -default : -/* -* For other situations, we treat it as bin0. -* This vf table can be run for any good cpu. -*/ + +/* +* We treat unexpected efuse values as if the SoC was from +* the slowest bin. Expected efuse values are 1-3, slowest +* to fastest. +*/ +if (efuse_value >=1 && efuse_value <=3 ) + *versions = efuse_value -1 ; +else *versions =0 ; -break ; - }kfree (speedbin);return 0 ;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 202/350 media: rcar_drif: fix a memory disclosure
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit d39083234c60519724c6ed59509a2129fd2aed41 ]
"f->fmt.sdr.reserved" is uninitialized. As other peer drivers like msi2500 and airspy do, the fix initializes it to avoid memory disclosures.
--- drivers/media/platform/rcar_drif.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/rcar_drif.c +1 -0
@@ -912,6 +912,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv, {struct rcar_drif_sdr *sdr =video_drvdata (file); +memset (f->fmt.sdr.reserved,0 ,sizeof (f->fmt.sdr.reserved)); f->fmt.sdr.pixelformat = sdr->fmt->pixelformat; f->fmt.sdr.buffersize = sdr->fmt->buffersize;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 203/350 media: v4l2-core: fix touch support in v4l_g_fmt
In reply to Sasha LevinFrom: Vandana BN <[email protected]>
[ Upstream commit 545b618cfb5cadacd00c25066b9a36540e5ca9e9 ]
v4l_s_fmt, for VFL_TYPE_TOUCH, sets unneeded members of the v4l2_pix_format structure to default values.This was missing in v4l_g_fmt, which would lead to failures in v4l2-compliance tests.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +18 -15
@@ -1466,10 +1466,26 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,return ret; } +static void v4l_pix_format_touch (struct v4l2_pix_format *p) +{ +/* +* The v4l2_pix_format structure contains fields that make no sense for +* touch. Set them to default values in this case. +*/ + + p->field =V4L2_FIELD_NONE ; + p->colorspace =V4L2_COLORSPACE_RAW ; + p->flags =0 ; + p->ycbcr_enc =0 ; + p->quantization =0 ; + p->xfer_func =0 ; +} +static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {struct v4l2_format *p = arg; +struct video_device *vfd =video_devdata (file);int ret =check_fmt (file, p->type);if (ret)
@@ -1507,6 +1523,8 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, ret = ops->vidioc_g_fmt_vid_cap (file, fh, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +if (vfd->vfl_type ==VFL_TYPE_TOUCH ) +v4l_pix_format_touch (&p->fmt.pix);return ret;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :return ops->vidioc_g_fmt_vid_cap_mplane (file, fh, arg);
@@ -1544,21 +1562,6 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,return -EINVAL ; } -static void v4l_pix_format_touch (struct v4l2_pix_format *p) -{ -/* -* The v4l2_pix_format structure contains fields that make no sense for -* touch. Set them to default values in this case. -*/ - - p->field =V4L2_FIELD_NONE ; - p->colorspace =V4L2_COLORSPACE_RAW ; - p->flags =0 ; - p->ycbcr_enc =0 ; - p->quantization =0 ; - p->xfer_func =0 ; -} -static int v4l_s_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 204/350 nvme: introduce "Command Aborted By host" status code
In reply to Sasha LevinFrom: Max Gurtovoy <[email protected]>
[ Upstream commit 2dc3947b53f573e8a75ea9cbec5588df88ca502e ]
Fix the status code of canceled requests initiated by the host according to TP4028 (Status Code 0x371):
"Command Aborted By host: The command was aborted as a result of host action (e.g., the host disconnected the Fabric connection)."
Also in a multipath environment, unless otherwise specified, errors of this type (path related) should be retried using a different path, if one is available.
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 1 + include/linux/nvme.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -313,7 +313,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)if (blk_mq_request_completed (req))return true; -nvme_req (req)->status =NVME_SC_HOST_PATH_ERROR ; +nvme_req (req)->status =NVME_SC_HOST_ABORTED_CMD ;blk_mq_complete_request (req);return true; }
drivers/nvme/host/multipath.c +1 -0
@@ -95,6 +95,7 @@ void nvme_failover_req(struct request *req) }break ;case NVME_SC_HOST_PATH_ERROR : +case NVME_SC_HOST_ABORTED_CMD :/* * Temporary transport disruption in talking to the controller. * Try to send on a new path.
include/linux/nvme.h +1 -0
@@ -1368,6 +1368,7 @@ enum {NVME_SC_ANA_INACCESSIBLE =0x302 ,NVME_SC_ANA_TRANSITION =0x303 ,NVME_SC_HOST_PATH_ERROR =0x370 , +NVME_SC_HOST_ABORTED_CMD =0x371 ,NVME_SC_CRD =0x1800 , NVME_SC_DNR = 0x4000,
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 205/350 media: staging/imx: Use a shorter name for driver
In reply to Sasha LevinFrom: Fabio Estevam <[email protected]>
[ Upstream commit ce22c6f242b6d7b5e0318da2c92b5b00b5bbc698 ]
Currently v4l2-compliance tool returns the following output:
Compliance test for imx-media-captu device /dev/video0:
Driver Info:
Driver name : imx-media-captu
Card type : imx-media-capture
...
The driver name string is limited to 16 characters, so provide a shorter name so that we can have a better output.
While at it, use the same shorter name for driver and card.
--- drivers/staging/media/imx/imx-media-capture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/media/imx/imx-media-capture.c +4 -2
@@ -26,6 +26,8 @@#include <media/imx.h> #include "imx-media.h" +#define IMX_CAPTURE_NAME "imx-capture" +struct capture_priv {struct imx_media_video_dev vdev;
@@ -69,8 +71,8 @@ static int vidioc_querycap(struct file *file, void *fh, {struct capture_priv *priv =video_drvdata (file); -strscpy (cap->driver,"imx-media-capture" ,sizeof (cap->driver)); -strscpy (cap->card,"imx-media-capture" ,sizeof (cap->card)); +strscpy (cap->driver,IMX_CAPTURE_NAME ,sizeof (cap->driver)); +strscpy (cap->card,IMX_CAPTURE_NAME ,sizeof (cap->card));snprintf (cap->bus_info,sizeof (cap->bus_info),"platform:%s" , priv->src_sd->name);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 206/350 nvmem: imx-ocotp: reset error status on probe
In reply to Sasha LevinFrom: Lucas Stach <[email protected]>
[ Upstream commit c33c585f1b3a99d53920bdac614aca461d8db06f ]
If software running before the OCOTP driver is loaded left the controller with the error status pending, the driver will never be able to complete the read timing setup. Reset the error status on probe to make sure the controller is in usable state.
--- drivers/nvmem/imx-ocotp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvmem/imx-ocotp.c +4 -0
@@ -521,6 +521,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)if (IS_ERR (priv->clk))return PTR_ERR (priv->clk); +clk_prepare_enable (priv->clk); +imx_ocotp_clr_err_if_set (priv->base); +clk_disable_unprepare (priv->clk); + priv->params =of_device_get_match_data (&pdev->dev); imx_ocotp_nvmem_config.size =4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 207/350 nvmem: core: fix nvmem_cell_write inline function
In reply to Sasha LevinFrom: Sebastian Reichel <[email protected]>
[ Upstream commit 9b8303fc6efa724bd6a90656434fbde2cc6ceb2c ]
nvmem_cell_write's buf argument uses different types based on the configuration of CONFIG_NVMEM. The function prototype for enabled NVMEM uses 'void *' type, but the static dummy function for disabled NVMEM uses 'const char *' instead. Fix the different behaviour by always expecting a 'void *' typed buf argument.
--- include/linux/nvmem-consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nvmem-consumer.h +1 -1
@@ -118,7 +118,7 @@ static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) }static inline int nvmem_cell_write (struct nvmem_cell *cell, -const char *buf,size_t len) +void *buf,size_t len) {return -EOPNOTSUPP ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 208/350 ASoC: SOF: topology: set trigger order for FE DAI link
In reply to Sasha LevinFrom: Ranjani Sridharan <[email protected]>
[ Upstream commit 5eee2b3f60065a2530d13f28e771be48b989eb4c ]
Set trigger order for FE DAI links to SND_SOC_DPCM_TRIGGER_POST to trigger the BE DAI's before the FE DAI's. This prevents the xruns seen on playback pipelines using the link DMA.
--- sound/soc/sof/topology.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/sof/topology.c +4 -0
@@ -2828,6 +2828,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,if (!link->no_pcm) { link->nonatomic = true; +/* set trigger order */ + link->trigger[0 ] =SND_SOC_DPCM_TRIGGER_POST ; + link->trigger[1 ] =SND_SOC_DPCM_TRIGGER_POST ; +/* nothing more to do for FE dai links */ return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 209/350 media: vivid: media_device_cleanup was called too early
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 8ffd573c25e5fac1daeeffc592e2ed6bc6a3d947 ]
Running the contrib/test/test-media script in v4l-utils with the vivid argument will cause this kernel warning:
[ 104.748720] videodev: v4l2_release [ 104.748731] ------------[ cut here ]------------ [ 104.748750] DEBUG_LOCKS_WARN_ON(lock->magic != lock) [ 104.748790] WARNING: CPU: 6 PID: 1823 at kernel/locking/mutex.c:938 __mutex_lock+0x919/0xc10 [ 104.748800] Modules linked in: rc_cec vivid v4l2_tpg videobuf2_dma_contig cec rc_core v4l2_dv_timings videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc vmw_balloon vmw_vmci button vmwgfx [ 104.748845] CPU: 6 PID: 1823 Comm: sleep Not tainted 5.4.0-rc1-test-no #150 [ 104.748853] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/29/2019 [ 104.748867] RIP: 0010:__mutex_lock+0x919/0xc10 [ 104.748878] Code: 59 83 e8 9a fc 16 ff 44 8b 05 23 61 38 01 45 85 c0 0f 85 ef f7 ff ff 48 c7 c6 a0 1f 87 82 48 c7 c7 a0 1e 87 82 e8 cd bb f7 fe <0f> 0b e9 d5 f7 ff ff f6 c3 04 0f 84 3b fd ff ff 49 89 df 41 83 e7 [ 104.748886] RSP: 0018:ffff88811a357b80 EFLAGS: 00010286 [ 104.748895] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 104.748902] RDX: 0000000000000003 RSI: 0000000000000004 RDI: ffffed102346af62 [ 104.748910] RBP: ffff88811a357cf0 R08: ffffffff81217c91 R09: fffffbfff061c271 [ 104.748917] R10: fffffbfff061c270 R11: ffffffff830e1383 R12: ffff8881a46103c0 [ 104.748924] R13: 0000000000000000 R14: ffff8881a4614f90 R15: ffff8881a46153d0 [ 104.748933] FS: 0000000000000000(0000) GS:ffff8881b6780000(0000) knlGS:0000000000000000 [ 104.748940] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 104.748949] CR2: 00007f163fc9ca20 CR3: 0000000003013004 CR4: 00000000001606e0 [ 104.749036] Call Trace: [ 104.749051] ? _raw_spin_unlock+0x1f/0x30 [ 104.749067] ? llist_add_batch+0x33/0x50 [ 104.749081] ? tick_nohz_tick_stopped+0x19/0x30 [ 104.749130] ? v4l2_release.cold+0x6c/0xd6 [videodev] [ 104.749143] ? mutex_lock_io_nested+0xb80/0xb80 [ 104.749153] ? vprintk_emit+0xf2/0x220 [ 104.749191] ? vivid_req_validate+0x40/0x40 [vivid] [ 104.749201] ? printk+0xad/0xde [ 104.749211] ? kmsg_dump_rewind_nolock+0x54/0x54 [ 104.749226] ? locks_remove_file+0x78/0x2b0 [ 104.749248] ? __fsnotify_update_child_dentry_flags.part.0+0x170/0x170 [ 104.749281] ? vivid_req_validate+0x40/0x40 [vivid] [ 104.749321] ? v4l2_release.cold+0x6c/0xd6 [videodev] [ 104.749361] v4l2_release.cold+0x6c/0xd6 [videodev] [ 104.749378] __fput+0x15a/0x390 [ 104.749393] task_work_run+0xb2/0xe0 [ 104.749407] do_exit+0x4d0/0x1200 [ 104.749422] ? do_user_addr_fault+0x367/0x610 [ 104.749431] ? release_task+0x990/0x990 [ 104.749449] ? rwsem_spin_on_owner+0x170/0x170 [ 104.749463] ? vmacache_find+0xb2/0x100 [ 104.749476] do_group_exit+0x85/0x130 [ 104.749487] __x64_sys_exit_group+0x23/0x30 [ 104.749500] do_syscall_64+0x5e/0x1c0 [ 104.749511] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 104.749520] RIP: 0033:0x7f163fc5c9d6 [ 104.749536] Code: Bad RIP value. [ 104.749543] RSP: 002b:00007ffe6f3bec58 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 [ 104.749553] RAX: ffffffffffffffda RBX: 00007f163fd4d760 RCX: 00007f163fc5c9d6 [ 104.749560] RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000 [ 104.749567] RBP: 0000000000000000 R08: 00000000000000e7 R09: ffffffffffffff80 [ 104.749574] R10: 00007ffe6f3beb24 R11: 0000000000000246 R12: 00007f163fd4d760 [ 104.749581] R13: 0000000000000002 R14: 00007f163fd56428 R15: 0000000000000000 [ 104.749597] ---[ end trace 66f20f73fc0daf79 ]---
This is caused by media_device_cleanup() which destroys v4l2_dev->mdev->req_queue_mutex. But v4l2_release() tries to lock that mutex after media_device_cleanup() is called.
By moving media_device_cleanup() to the v4l2_device's release function it is guaranteed that the mutex is valid whenever v4l2_release is called.
--- drivers/media/platform/vivid/vivid-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/vivid/vivid-core.c +3 -1
@@ -616,6 +616,9 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev)vivid_free_controls (dev);v4l2_device_unregister (&dev->v4l2_dev); +#ifdef CONFIG_MEDIA_CONTROLLER +media_device_cleanup (&dev->mdev); +#endif vfree (dev->scaled_line);vfree (dev->blended_line);vfree (dev->edid);
@@ -1580,7 +1583,6 @@ static int vivid_remove(struct platform_device *pdev)#ifdef CONFIG_MEDIA_CONTROLLER media_device_unregister (&dev->mdev); -media_device_cleanup (&dev->mdev);#endif if (dev->has_vid_cap) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 210/350 spi: dw: Fix Designware SPI loopback
In reply to Sasha LevinFrom: Thor Thayer <[email protected]>
[ Upstream commit 1403cfa69d310781f9548951c97725c67ffcf613 ]
The SPI_LOOP is set in spi->mode but not propagated to the register. A previous patch removed the bit during a cleanup.
--- drivers/spi/spi-dw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-dw.c +2 -1
@@ -308,7 +308,8 @@ static int dw_spi_transfer_one(struct spi_controller *master, cr0 = (transfer->bits_per_word -1 ) | (chip->type <<SPI_FRF_OFFSET ) | ((((spi->mode &SPI_CPOL ) ?1 :0 ) <<SPI_SCOL_OFFSET ) | - (((spi->mode &SPI_CPHA ) ?1 :0 ) <<SPI_SCPH_OFFSET )) + (((spi->mode &SPI_CPHA ) ?1 :0 ) <<SPI_SCPH_OFFSET ) | + (((spi->mode &SPI_LOOP ) ?1 :0 ) <<SPI_SRL_OFFSET )) | (chip->tmode <<SPI_TMOD_OFFSET );/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 211/350 rfkill: allocate static minor
In reply to Sasha LevinFrom: Marcel Holtmann <[email protected]>
[ Upstream commit 8670b2b8b029a6650d133486be9d2ace146fd29a ]
udev has a feature of creating /dev/<node> device-nodes if it finds a devnode:<node> modalias. This allows for auto-loading of modules that provide the node. This requires to use a statically allocated minor number for misc character devices.
However, rfkill uses dynamic minor numbers and prevents auto-loading of the module. So allocate the next static misc minor number and use it for rfkill.
--- include/linux/miscdevice.h | 1 + net/rfkill/core.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
include/linux/miscdevice.h +1 -0
@@ -57,6 +57,7 @@#define UHID_MINOR 239#define USERIO_MINOR 240#define VHOST_VSOCK_MINOR 241 +#define RFKILL_MINOR 242#define MISC_DYNAMIC_MINOR 255struct device ;
net/rfkill/core.c +7 -2
@@ -1316,10 +1316,12 @@ static const struct file_operations rfkill_fops = { .llseek = no_llseek, }; +#define RFKILL_NAME "rfkill" +static struct miscdevice rfkill_miscdev = { - .name ="rfkill" , .fops = &rfkill_fops, - .minor =MISC_DYNAMIC_MINOR , + .name =RFKILL_NAME , + .minor =RFKILL_MINOR , };static int __init rfkill_init (void )
@@ -1371,3 +1373,6 @@ static void __exit rfkill_exit(void)class_unregister (&rfkill_class); }module_exit (rfkill_exit); + +MODULE_ALIAS_MISCDEV (RFKILL_MINOR ); +MODULE_ALIAS ("devname:" RFKILL_NAME );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.4 211/350] rfkill: allocate static minor
Quoted 13 lines · Sasha Levin
From: Marcel Holtmann <[email protected]>
[ Upstream commit
8670b2b8b029a6650d133486be9d2ace146fd29a]udev has a feature of creating /dev/<node> device-nodes if it finds a devnode:<node> modalias. This allows for auto-loading of modules that provide the node. This requires to use a statically allocated minor number for misc character devices.
However, rfkill uses dynamic minor numbers and prevents auto-loading of the module. So allocate the next static misc minor number and use it for rfkill.
Quoted 8 lines
Signed-off-by Marcel Holtmann <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- include/linux/miscdevice.h | 1 + net/rfkill/core.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
I'll go queue this up for 5.4.y now, as that's the only place that should need it.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 212/350 bnx2x: Fix PF-VF communication over multi-cos queues.
In reply to Sasha LevinFrom: Manish Chopra <[email protected]>
[ Upstream commit dc5a3d79c345871439ffe72550b604fcde9770e1 ]
PF driver doesn't enable tx-switching for all cos queues/clients, which causes packets drop from PF to VF. Fix this by enabling tx-switching on all cos queues/clients.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +11 -5
@@ -2397,15 +2397,21 @@ static int bnx2x_set_pf_tx_switching(struct bnx2x *bp, bool enable)/* send the ramrod on all the queues of the PF */ for_each_eth_queue (bp, i) {struct bnx2x_fastpath *fp = &bp->fp[i]; +int tx_idx;/* Set the appropriate Queue object */ q_params.q_obj = &bnx2x_sp_obj (bp, fp).q_obj; -/* Update the Queue state */ - rc =bnx2x_queue_state_change (bp, &q_params); -if (rc) { -BNX2X_ERR ("Failed to configure Tx switching\n" ); -return rc; +for (tx_idx =FIRST_TX_COS_INDEX ; + tx_idx < fp->max_cos; tx_idx++) { + q_params.params.update.cid_index = tx_idx; + +/* Update the Queue state */ + rc =bnx2x_queue_state_change (bp, &q_params); +if (rc) { +BNX2X_ERR ("Failed to configure Tx switching\n" ); +return rc; + } } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 213/350 spi: img-spfi: fix potential double release
In reply to Sasha LevinFrom: Pan Bian <[email protected]>
[ Upstream commit e9a8ba9769a0e354341bc6cc01b98aadcea1dfe9 ]
The channels spfi->tx_ch and spfi->rx_ch are not set to NULL after they are released. As a result, they will be released again, either on the error handling branch in the same function or in the corresponding remove function, i.e. img_spfi_remove(). This patch fixes the bug by setting the two members to NULL.
--- drivers/spi/spi-img-spfi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-img-spfi.c +2 -0
@@ -673,6 +673,8 @@ static int img_spfi_probe(struct platform_device *pdev)dma_release_channel (spfi->tx_ch);if (spfi->rx_ch)dma_release_channel (spfi->rx_ch); + spfi->tx_ch =NULL ; + spfi->rx_ch =NULL ;dev_warn (spfi->dev,"Failed to get DMA channels, falling back to PIO mode\n" ); }else { master->dma_tx = spfi->tx_ch;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 214/350 ALSA: timer: Limit max amount of slave instances
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit fdea53fe5de532969a332d6e5e727f2ad8bf084d ]
The fuzzer tries to open the timer instances as much as possible, and this may cause a system hiccup easily. We've already introduced the cap for the max number of available instances for the h/w timers, and we should put such a limit also to the slave timers, too.
This patch introduces the limit to the multiple opened slave timers. The upper limit is hard-coded to 1000 for now, which should suffice for any practical usages up to now.
--- sound/core/timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/core/timer.c +10 -0
@@ -74,6 +74,9 @@ static LIST_HEAD(snd_timer_slave_list);/* lock for slave active lists */ static DEFINE_SPINLOCK (slave_active_lock); +#define MAX_SLAVE_INSTANCES 1000 +static int num_slaves; +static DEFINE_MUTEX (register_mutex);static int snd_timer_free (struct snd_timer *timer);
@@ -252,6 +255,10 @@ int snd_timer_open(struct snd_timer_instance **ti, err = -EINVAL ; goto unlock; } +if (num_slaves >=MAX_SLAVE_INSTANCES ) { + err = -EBUSY ; + goto unlock; + } timeri =snd_timer_instance_new (owner,NULL );if (!timeri) { err = -ENOMEM ;
@@ -261,6 +268,7 @@ int snd_timer_open(struct snd_timer_instance **ti, timeri->slave_id = tid->device; timeri->flags |=SNDRV_TIMER_IFLG_SLAVE ;list_add_tail (&timeri->open_list, &snd_timer_slave_list); + num_slaves++; err =snd_timer_check_slave (timeri);if (err <0 ) {snd_timer_close_locked (timeri, &card_dev_to_put);
@@ -356,6 +364,8 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri, }list_del (&timeri->open_list); +if (timeri->flags &SNDRV_TIMER_IFLG_SLAVE ) + num_slaves--;/* force to stop the timer */ snd_timer_stop (timeri);
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Sasha Levin
maintainerPATCH 215/350 RDMA/core: Fix return code when modify_port isn't supported
In reply to Sasha LevinFrom: Kamal Heib <[email protected]>
[ Upstream commit 55bfe905fa97633438c13fb029aed85371d85480 ]
Improve return code from ib_modify_port() by doing the following:
- Use "-EOPNOTSUPP" instead "-ENOSYS" which is the proper return code
- Allow only fake IB_PORT_CM_SUP manipulation for RoCE providers that didn't implement the modify_port callback, otherwise return "-EOPNOTSUPP"
--- drivers/infiniband/core/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +5 -1
@@ -2409,8 +2409,12 @@ int ib_modify_port(struct ib_device *device, rc = device->ops.modify_port (device, port_num, port_modify_mask, port_modify); + else if (rdma_protocol_roce(device, port_num) && + ((port_modify->set_port_cap_mask & ~IB_PORT_CM_SUP) == 0 || + (port_modify->clr_port_cap_mask & ~IB_PORT_CM_SUP) == 0)) + rc =0 ; else - rc =rdma_protocol_roce (device, port_num) ?0 : -ENOSYS ; + rc = -EOPNOTSUPP ;return rc; }EXPORT_SYMBOL (ib_modify_port);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 216/350 drm: msm: a6xx: fix debug bus register configuration
In reply to Sasha LevinFrom: Sharat Masetty <[email protected]>
[ Upstream commit 7f4009c4bbea4438b50f3b12d1c57da3f5cd8db3 ]
Fix the cx debugbus related register configuration, to collect accurate bus data during gpu snapshot. This helps with complete snapshot dump and also complete proper GPU recovery.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +12 -12
@@ -352,26 +352,26 @@ static void a6xx_get_debugbus(struct msm_gpu *gpu, cxdbg =ioremap (res->start,resource_size (res));if (cxdbg) { -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_CNTLT , +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLT ,A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT (0xf )); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_CNTLM , +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLM ,A6XX_DBGC_CFG_DBGBUS_CNTLM_ENABLE (0xf )); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_IVTL_0 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_IVTL_1 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_IVTL_2 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_IVTL_3 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_3 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_BYTEL_0 , +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_0 ,0x76543210 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_BYTEL_1 , +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1 ,0xFEDCBA98 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_MASKL_0 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_MASKL_1 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_MASKL_2 ,0 ); -cxdbg_write (cxdbg,REG_A6XX_DBGC_CFG_DBGBUS_MASKL_3 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_0 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_1 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_2 ,0 ); +cxdbg_write (cxdbg,REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_3 ,0 ); } a6xx_state->debugbus = state_kcalloc(a6xx_state,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 217/350 rtlwifi: fix memory leak in rtl92c_set_fw_rsvdpagepkt()
In reply to Sasha LevinFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit 5174f1e41074b5186608badc2e89441d021e8c08 ]
This leak was found by testing the EDIMAX EW-7612 on Raspberry Pi 3B+ with Linux 5.4-rc5 (multi_v7_defconfig + rtlwifi + kmemleak) and noticed a single memory leak during probe:
unreferenced object 0xec13ee40 (size 176):
comm "kworker/u8:1", pid 36, jiffies 4294939321 (age 5580.790s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<fc1bbb3e>] __netdev_alloc_skb+0x9c/0x164
[<863dfa6e>] rtl92c_set_fw_rsvdpagepkt+0x254/0x340 [rtl8192c_common]
[<9572be0d>] rtl92cu_set_hw_reg+0xf48/0xfa4 [rtl8192cu]
[<116df4d8>] rtl_op_bss_info_changed+0x234/0x96c [rtlwifi]
[<8933575f>] ieee80211_bss_info_change_notify+0xb8/0x264 [mac80211]
[<d4061e86>] ieee80211_assoc_success+0x934/0x1798 [mac80211]
[<e55adb56>] ieee80211_rx_mgmt_assoc_resp+0x174/0x314 [mac80211]
[<5974629e>] ieee80211_sta_rx_queued_mgmt+0x3f4/0x7f0 [mac80211]
[<d91091c6>] ieee80211_iface_work+0x208/0x318 [mac80211]
[<ac5fcae4>] process_one_work+0x22c/0x564
[<f5e6d3b6>] worker_thread+0x44/0x5d8
[<82c7b073>] kthread+0x150/0x154
[<b43e1b7d>] ret_from_fork+0x14/0x2c
[<794dff30>] 0x0It is because 8192cu doesn't implement usb_cmd_send_packet(), and this patch just frees the skb within the function to resolve memleak problem by now. Since 8192cu doesn't turn on fwctrl_lps that needs to download command packet for firmware via the function, applying this patch doesn't affect driver behavior.
--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c +2 -0
@@ -1540,6 +1540,8 @@ static bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)* This is maybe necessary: * rtlpriv->cfg->ops->fill_tx_cmddesc(hw, buffer, 1, 1, skb); */ +dev_kfree_skb (skb); +return true; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 218/350 perf probe: Fix to find range-only function instance
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit b77afa1f810f37bd8a36cb1318178dfe2d7af6b6 ]
Fix die_is_func_instance() to find range-only function instance.
In some case, a function instance can be made without any low PC or entry PC, but only with address ranges by optimization. (e.g. cold text partially in "text.unlikely" section) To find such function instance, we have to check the range attribute too.
--- tools/perf/util/dwarf-aux.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/dwarf-aux.c +5 -1
@@ -318,10 +318,14 @@ bool die_is_func_def(Dwarf_Die *dw_die)bool die_is_func_instance (Dwarf_Die *dw_die) {Dwarf_Addr tmp; +Dwarf_Attribute attr_mem;/* Actually gcc optimizes non-inline as like as inlined */ -return !dwarf_func_inline (dw_die) &&dwarf_entrypc (dw_die, &tmp) ==0 ; +return !dwarf_func_inline (dw_die) && + (dwarf_entrypc (dw_die, &tmp) ==0 || +dwarf_attr (dw_die, DW_AT_ranges, &attr_mem) !=NULL ); } +/** * die_get_data_member_location - Get the data-member offset * @mb_die: a DIE of a member of a data structure
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 219/350 perf cs-etm: Fix definition of macro TO_CS_QUEUE_NR
In reply to Sasha LevinFrom: Leo Yan <[email protected]>
[ Upstream commit 9d604aad4bb022e848dec80d6fe5f73fe87061a2 ]
Macro TO_CS_QUEUE_NR definition has a typo, which uses 'trace_id_chan' as its parameter, this doesn't match with its definition body which uses 'trace_chan_id'. So renames the parameter to 'trace_chan_id'.
It's luck to have a local variable 'trace_chan_id' in the function cs_etm__setup_queue(), even we wrongly define the macro TO_CS_QUEUE_NR, the local variable 'trace_chan_id' is used rather than the macro's parameter 'trace_id_chan'; so the compiler doesn't complain for this before.
After renaming the parameter, it leads to a compiling error due cs_etm__setup_queue() has no variable 'trace_id_chan'. This patch uses the variable 'trace_chan_id' for the macro so that fixes the compiling error.
--- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/cs-etm.c +2 -2
@@ -110,7 +110,7 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq);* encode the etm queue number as the upper 16 bit and the channel as * the lower 16 bit. */ -#define TO_CS_QUEUE_NR (queue_nr, trace_id_chan) \ +#define TO_CS_QUEUE_NR (queue_nr, trace_chan_id) \ (queue_nr << 16 | trace_chan_id)#define TO_QUEUE_NR (cs_queue_nr) (cs_queue_nr >> 16)#define TO_TRACE_CHAN_ID (cs_queue_nr) (cs_queue_nr & 0x0000ffff)
@@ -819,7 +819,7 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm,* Note that packets decoded above are still in the traceID's packet * queue and will be processed in cs_etm__process_queues(). */ - cs_queue_nr =TO_CS_QUEUE_NR (queue_nr, trace_id_chan); + cs_queue_nr =TO_CS_QUEUE_NR (queue_nr, trace_chan_id); ret =auxtrace_heap__add (&etm->heap, cs_queue_nr, timestamp); out:return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 220/350 perf probe: Fix to list probe event with correct line number
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 3895534dd78f0fd4d3f9e05ee52b9cdd444a743e ]
Since debuginfo__find_probe_point() uses dwarf_entrypc() for finding the entry address of the function on which a probe is, it will fail when the function DIE has only ranges attribute.
To fix this issue, use die_entrypc() instead of dwarf_entrypc().
Without this fix, perf probe -l shows incorrect offset:
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)With this:
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)Committer testing:
Before:
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579765152@kernel/cpu.c)
[root@quaco ~]#
After:
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
[root@quaco ~]#
--- tools/perf/util/probe-finder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +2 -2
@@ -1578,7 +1578,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,/* Get function entry information */ func = basefunc =dwarf_diename (&spdie);if (!func || -dwarf_entrypc (&spdie, &baseaddr) !=0 || +die_entrypc (&spdie, &baseaddr) !=0 ||dwarf_decl_line (&spdie, &baseline) !=0 ) { lineno =0 ; goto post;
@@ -1595,7 +1595,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,while (die_find_top_inlinefunc (&spdie, (Dwarf_Addr )addr, &indie)) {/* There is an inline function */ -if (dwarf_entrypc (&indie, &_addr) ==0 && +if (die_entrypc (&indie, &_addr) ==0 && _addr == addr) {/* * addr is at an inline function entry.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 221/350 perf jevents: Fix resource leak in process_mapfile() and main()
In reply to Sasha LevinFrom: Yunfeng Ye <[email protected]>
[ Upstream commit 1785fbb73896dbd9d27a406f0d73047df42db710 ]
There are memory leaks and file descriptor resource leaks in process_mapfile() and main().
Fix this by adding free(), fclose() and free_arch_std_events() on the error paths.
--- tools/perf/pmu-events/jevents.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/pmu-events/jevents.c +11 -2
@@ -758,6 +758,7 @@ static int process_mapfile(FILE *outfp, char *fpath)char *line, *p;int line_num;char *tblname; +int ret =0 ;pr_info ("%s: Processing mapfile %s\n" , prog, fpath);
@@ -769,6 +770,7 @@ static int process_mapfile(FILE *outfp, char *fpath)if (!mapfp) {pr_info ("%s: Error %s opening %s\n" , prog,strerror (errno), fpath); +free (line);return -1 ; }
@@ -795,7 +797,8 @@ static int process_mapfile(FILE *outfp, char *fpath)/* TODO Deal with lines longer than 16K */ pr_info ("%s: Mapfile %s: line %d too long, aborting\n" , prog, fpath, line_num); -return -1 ; + ret =-1 ; + goto out; } line[strlen (line)-1 ] ='\0' ;
@@ -825,7 +828,9 @@ static int process_mapfile(FILE *outfp, char *fpath) out:print_mapping_table_suffix (outfp); -return 0 ; +fclose (mapfp); +free (line); +return ret; }/*
@@ -1122,6 +1127,7 @@ int main(int argc, char *argv[]) goto empty_map; }else if (rc <0 ) {/* Make build fail */ +fclose (eventsfp);free_arch_std_events ();return 1 ; }else if (rc) {
@@ -1134,6 +1140,7 @@ int main(int argc, char *argv[]) goto empty_map; }else if (rc <0 ) {/* Make build fail */ +fclose (eventsfp);free_arch_std_events ();return 1 ; }else if (rc) {
@@ -1151,6 +1158,8 @@ int main(int argc, char *argv[])if (process_mapfile (eventsfp, mapfile)) {pr_info ("%s: Error processing mapfile %s\n" , prog, mapfile);/* Make build fail */ +fclose (eventsfp); +free_arch_std_events ();return 1 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 222/350 perf probe: Walk function lines in lexical blocks
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit acb6a7047ac2146b723fef69ee1ab6b7143546bf ]
Since some inlined functions are in lexical blocks of given function, we have to recursively walk through the DIE tree. Without this fix, perf-probe -L can miss the inlined functions which is in a lexical block (like if (..) { func() } case.)
However, even though, to walk the lines in a given function, we don't need to follow the children DIE of inlined functions because those do not have any lines in the specified function.
We need to walk though whole trees only if we walk all lines in a given file, because an inlined function can include another inlined function in the same file.
--- tools/perf/util/dwarf-aux.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
tools/perf/util/dwarf-aux.c +9 -5
@@ -678,10 +678,9 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)if (lw->retval !=0 )return DIE_FIND_CB_END ; } +if (!lw->recursive) +return DIE_FIND_CB_SIBLING ; } -if (!lw->recursive) -/* Don't need to search recursively */ -return DIE_FIND_CB_SIBLING ;if (addr) { fname =dwarf_decl_file (in_die);
@@ -728,6 +727,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data) {struct __line_walk_param *lw = data; +/* +* Since inlined function can include another inlined function in +* the same file, we need to walk in it recursively. +*/ lw->retval =__die_walk_funclines (sp_die, true, lw->callback, lw->data);if (lw->retval !=0 )return DWARF_CB_ABORT ;
@@ -817,8 +820,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)*/ if (rt_die != cu_die)/* -* Don't need walk functions recursively, because nested -* inlined functions don't have lines of the specified DIE. +* Don't need walk inlined functions recursively, because +* inner inlined functions don't have the lines of the +* specified function. */ ret =__die_walk_funclines (rt_die, false, callback, data);else {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 223/350 perf probe: Fix to probe an inline function which has no entry pc
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit eb6933b29d20bf2c3053883d409a53f462c1a3ac ]
Fix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as probe_point_search_cb(), use die_entrypc() to get the entry address in probe_point_inline_cb() too.
Without this patch:
# perf probe -D __amd_put_nb_event_constraints
Failed to get entry address of __amd_put_nb_event_constraints.
Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.With this patch:
# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
Committer testing:
Before:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.
[root@quaco ~]#
After:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]#
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -942,7 +942,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 224/350 perf probe: Fix to show ranges of variables in functions without entry_pc
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit af04dd2f8ebaa8fbd46f698714acbf43da14da45 ]
Fix to show ranges of variables (--range and --vars option) in functions which DIE has only ranges but no entry_pc attribute.
Without this fix:
# perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> (No matched variables)
With this fix:
# perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> [VAL] int cpu @<clear_tasks_mm_cpumask+[0-35,317-317,2052-2059]>
Committer testing:
Before:
[root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
Available variables at clear_tasks_mm_cpumask
@<clear_tasks_mm_cpumask+0>
(No matched variables)
[root@quaco ~]#After:
[root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
Available variables at clear_tasks_mm_cpumask
@<clear_tasks_mm_cpumask+0>
[VAL] int cpu @<clear_tasks_mm_cpumask+[0-23,23-105,105-106,106-106,1843-1850,1850-1862]>
[root@quaco ~]#Using it:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask cpu Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask with cpu)
You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c with cpu)
[root@quaco ~]#
[root@quaco ~]# perf trace -e probe:*cpumask
^C[root@quaco ~]#
--- tools/perf/util/dwarf-aux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/dwarf-aux.c +2 -2
@@ -997,7 +997,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;
@@ -1060,7 +1060,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 225/350 perf probe: Fix to show inlined function callsite without entry_pc
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 18e21eb671dc87a4f0546ba505a89ea93598a634 ]
Fix 'perf probe --line' option to show inlined function callsite lines even if the function DIE has only ranges.
Without this:
# perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
__amd_put_nb_event_constraints(cpuc, event);
5 }With this patch:
# perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
4 __amd_put_nb_event_constraints(cpuc, event);
5 }Committer testing:
Before:
[root@quaco ~]# perf probe -L amd_put_event_constraints
<amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
struct perf_event *event)
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
__amd_put_nb_event_constraints(cpuc, event);
5 } PMU_FORMAT_ATTR(event, "config:0-7,32-35");
PMU_FORMAT_ATTR(umask, "config:8-15" );[root@quaco ~]#
After:
[root@quaco ~]# perf probe -L amd_put_event_constraints
<amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
struct perf_event *event)
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
4 __amd_put_nb_event_constraints(cpuc, event);
5 } PMU_FORMAT_ATTR(event, "config:0-7,32-35");
PMU_FORMAT_ATTR(umask, "config:8-15" ); [root@quaco ~]# perf probe amd_put_event_constraints:4 Added new event:
probe:amd_put_event_constraints (on amd_put_event_constraints:4)
You can now use it in all perf tools, such as:
perf record -e probe:amd_put_event_constraints -aR sleep 1
[root@quaco ~]#
[root@quaco ~]# perf probe -l
probe:amd_put_event_constraints (on amd_put_event_constraints:4@arch/x86/events/amd/core.c) probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
[root@quaco ~]#
Using it:
[root@quaco ~]# perf trace -e probe:*
^C[root@quaco ~]#
Ok, Intel system here... :-)
--- tools/perf/util/dwarf-aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dwarf-aux.c +1 -1
@@ -673,7 +673,7 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)if (dwarf_tag (in_die) == DW_TAG_inlined_subroutine) { fname =die_get_call_file (in_die); lineno =die_get_call_lineno (in_die); -if (fname && lineno >0 &&dwarf_entrypc (in_die, &addr) ==0 ) { +if (fname && lineno >0 &&die_entrypc (in_die, &addr) ==0 ) { lw->retval = lw->callback (fname, lineno, addr, lw->data);if (lw->retval !=0 )return DIE_FIND_CB_END ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 226/350 libsubcmd: Use -O0 with DEBUG=1
In reply to Sasha LevinFrom: James Clark <[email protected]>
[ Upstream commit 22bd8f1b5a1dd168ba4eba27cb17643a11012f5d ]
When a 'make DEBUG=1' build is done, the command parser is still built with -O6 and is hard to step through, fix it making it use -O0 in that case.
--- tools/lib/subcmd/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/subcmd/Makefile +3 -1
@@ -28,7 +28,9 @@ ifeq ($(DEBUG),0) endif endif -ifeq ($(CC_NO_CLANG), 0) +ifeq ($(DEBUG),1) + CFLAGS += -O0 +else ifeq ($(CC_NO_CLANG), 0) CFLAGS += -O3 else CFLAGS += -O6
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 227/350 perf probe: Fix to probe a function which has no entry pc
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 5d16dbcc311d91267ddb45c6da4f187be320ecee ]
Fix 'perf probe' to probe a function which has no entry pc or low pc but only has ranges attribute.
probe_point_search_cb() uses dwarf_entrypc() to get the probe address, but that doesn't work for the function DIE which has only ranges attribute. Use die_entrypc() instead.
Without this fix:
# perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.With this:
# perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0
Committer testing:
Before:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco ~]#
After:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask)
You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
[root@quaco ~]#
Using it with 'perf trace':
[root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask
Doesn't seem to be used in x86_64:
$ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu) ./arch/xtensa/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/csky/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/sh/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/arm/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/powerpc/mm/nohash/mmu_context.c: clear_tasks_mm_cpumask(cpu); $ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu); $ find . -name "*.S" | xargs grep clear_tasks_mm_cpumask $
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -994,7 +994,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data) param->retval =find_probe_point_by_line (pf); }else if (die_is_func_instance (sp_die)) {/* Instances always have the entry address */ -dwarf_entrypc (sp_die, &pf->addr); +die_entrypc (sp_die, &pf->addr);/* But in some case the entry address is 0 */ if (pf->addr ==0 ) { pr_debug("%s has no entry PC. Skipped\n",
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 228/350 perf tools: Fix cross compile for ARM64
In reply to Sasha LevinFrom: John Garry <[email protected]>
[ Upstream commit 71f699078b154fcb1c9162fd0208ada9ce532ffc ]
Currently when cross compiling perf tool for ARM64 on my x86 machine I get this error:
arch/arm64/util/sym-handling.c:9:10: fatal error: gelf.h: No such file or directory
#include <gelf.h>
For the build, libelf is reported off:
Auto-detecting system features:
...
... libelf: [ OFF ]
Indeed, test-libelf is not built successfully:
more ./build/feature/test-libelf.make.output test-libelf.c:2:10: fatal error: libelf.h: No such file or directory
#include <libelf.h>
^~~~~~~~~~compilation terminated.
I have no such problems natively compiling on ARM64, and I did not previously have this issue for cross compiling. Fix by relocating the gelf.h include.
--- tools/perf/arch/arm64/util/sym-handling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/arch/arm64/util/sym-handling.c +2 -1
@@ -6,9 +6,10 @@#include "symbol.h" // for the elf__needs_adjust_symbols() prototype #include <stdbool.h> -#include <gelf.h> #ifdef HAVE_LIBELF_SUPPORT +#include <gelf.h> +bool elf__needs_adjust_symbols (GElf_Ehdr ehdr) { return ehdr.e_type == ET_EXEC ||
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 229/350 perf tools: Splice events onto evlist even on error
In reply to Sasha LevinFrom: Ian Rogers <[email protected]>
[ Upstream commit 8e8714c3d157568b7a769917a5e05573bbaf5af0 ]
If event parsing fails the event list is leaked, instead splice the list onto the out result and let the caller cleanup.
An example input for parse_events found by libFuzzer that reproduces this memory leak is 'm{'.
--- tools/perf/util/parse-events.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
tools/perf/util/parse-events.c +11 -6
@@ -1927,15 +1927,20 @@ int parse_events(struct evlist *evlist, const char *str, ret =parse_events__scanner (str, &parse_state,PE_START_EVENTS );perf_pmu__parse_cleanup (); + +if (!ret &&list_empty (&parse_state.list)) { +WARN_ONCE (true,"WARNING: event parser found nothing\n" ); +return -1 ; + } + +/* +* Add list to the evlist even with errors to allow callers to clean up. +*/ +perf_evlist__splice_list_tail (evlist, &parse_state.list); +if (!ret) {struct evsel *last; -if (list_empty (&parse_state.list)) { -WARN_ONCE (true,"WARNING: event parser found nothing\n" ); -return -1 ; - } - -perf_evlist__splice_list_tail (evlist, &parse_state.list); evlist->nr_groups += parse_state.nr_groups; last =evlist__last (evlist); last->cmdline_group_boundary = true;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 230/350 drm/amdgpu: disallow direct upload save restore list from gfx driver
In reply to Sasha LevinFrom: Hawking Zhang <[email protected]>
[ Upstream commit 58f46d4b65021083ef4b4d49c6e2c58e5783f626 ]
Direct uploading save/restore list via mmio register writes breaks the security policy. Instead, the driver should pass s&r list to psp.
For all the ASICs that use rlc v2_1 headers, the driver actually upload s&r list twice, in non-psp ucode front door loading phase and gfx pg initialization phase. The latter is not allowed.
VG12 is the only exception where the driver still keeps legacy approach for S&R list uploading. In theory, this can be elimnated if we have valid srcntl ucode for VG12.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -2930,7 +2930,8 @@ static void gfx_v9_0_init_pg(struct amdgpu_device *adev)* And it's needed by gfxoff feature. */ if (adev->gfx.rlc.is_rlc_v2_1) { -gfx_v9_1_init_rlc_save_restore_list (adev); +if (adev->asic_type ==CHIP_VEGA12 ) +gfx_v9_1_init_rlc_save_restore_list (adev);gfx_v9_0_enable_save_restore_machine (adev); }
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 231/350 drm/amd/powerplay: fix struct init in renoir_print_clk_levels
In reply to Sasha LevinFrom: Raul E Rangel <[email protected]>
[ Upstream commit d942070575910fdb687b9c8fd5467704b2f77c24 ]
drivers/gpu/drm/amd/powerplay/renoir_ppt.c:186:2: error: missing braces around initializer [-Werror=missing-braces]
SmuMetrics_t metrics = {0};
^--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +3 -1
@@ -183,11 +183,13 @@ static int renoir_print_clk_levels(struct smu_context *smu,int i, size =0 , ret =0 ;uint32_t cur_value =0 , value =0 , count =0 , min =0 , max =0 ;DpmClocks_t *clk_table = smu->smu_table.clocks_table; -SmuMetrics_t metrics = {0 }; +SmuMetrics_t metrics;if (!clk_table || clk_type >=SMU_CLK_COUNT )return -EINVAL ; +memset (&metrics,0 ,sizeof (metrics)); + ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)&metrics, false);if (ret)
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 232/350 drm/amdgpu: fix potential double drop fence reference
In reply to Sasha LevinFrom: Pan Bian <[email protected]>
[ Upstream commit 946ab8db6953535a3a88c957db8328beacdfed9d ]
The object fence is not set to NULL after its reference is dropped. As a result, its reference may be dropped again if error occurs after that, which may lead to a use after free bug. To avoid the issue, fence is explicitly set to NULL after dropping its reference.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -0
@@ -138,6 +138,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) }dma_fence_put (fence); + fence =NULL ; r =amdgpu_bo_kmap (vram_obj, &vram_map);if (r) {
@@ -183,6 +184,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) }dma_fence_put (fence); + fence =NULL ; r =amdgpu_bo_kmap (gtt_obj[i], >t_map);if (r) {
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 233/350 ice: Check for null pointer dereference when setting rings
In reply to Sasha LevinFrom: Michal Swiatkowski <[email protected]>
[ Upstream commit eb0ee8abfeb9ff4b98e8e40217b8667bfb08587a ]
Without this check rebuild vsi can lead to kernel panic.
--- drivers/net/ethernet/intel/ice/ice_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +14 -4
@@ -3970,8 +3970,13 @@ int ice_vsi_setup_tx_rings(struct ice_vsi *vsi) }ice_for_each_txq (vsi, i) { - vsi->tx_rings[i]->netdev = vsi->netdev; - err =ice_setup_tx_ring (vsi->tx_rings[i]); +struct ice_ring *ring = vsi->tx_rings[i]; + +if (!ring) +return -EINVAL ; + + ring->netdev = vsi->netdev; + err =ice_setup_tx_ring (ring);if (err)break ; }
@@ -3996,8 +4001,13 @@ int ice_vsi_setup_rx_rings(struct ice_vsi *vsi) }ice_for_each_rxq (vsi, i) { - vsi->rx_rings[i]->netdev = vsi->netdev; - err =ice_setup_rx_ring (vsi->rx_rings[i]); +struct ice_ring *ring = vsi->rx_rings[i]; + +if (!ring) +return -EINVAL ; + + ring->netdev = vsi->netdev; + err =ice_setup_rx_ring (ring);if (err)break ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 234/350 xen/gntdev: Use select for DMA_SHARED_BUFFER
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit fa6614d8ef13c63aac52ad7c07c5e69ce4aba3dd ]
DMA_SHARED_BUFFER can not be enabled by the user (it represents a library set in the kernel). The kconfig convention is to use select for such symbols so they are turned on implicitly when the user enables a kconfig that needs them.
Otherwise the XEN_GNTDEV_DMABUF kconfig is overly difficult to enable.
--- drivers/xen/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/xen/Kconfig +2 -1
@@ -141,7 +141,8 @@ config XEN_GNTDEV config XEN_GNTDEV_DMABUF bool "Add support for dma-buf grant access device driver extension" - depends on XEN_GNTDEV && XEN_GRANT_DMA_ALLOC && DMA_SHARED_BUFFER + depends on XEN_GNTDEV && XEN_GRANT_DMA_ALLOC + select DMA_SHARED_BUFFER help Allows userspace processes and kernel modules to use Xen backed dma-buf implementation. With this extension grant references to
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Sasha Levin
maintainerPATCH 235/350 perf parse: If pmu configuration fails free terms
In reply to Sasha LevinFrom: Ian Rogers <[email protected]>
[ Upstream commit 38f2c4226e6bc3e8c41c318242821ba5dc825aba ]
Avoid a memory leak when the configuration fails.
--- tools/perf/util/parse-events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/parse-events.c +8 -1
@@ -1365,8 +1365,15 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,if (get_config_terms (head_config, &config_terms))return -ENOMEM ; -if (perf_pmu__config (pmu, &attr, head_config, parse_state->error)) +if (perf_pmu__config (pmu, &attr, head_config, parse_state->error)) { +struct perf_evsel_config_term *pos, *tmp; + +list_for_each_entry_safe (pos, tmp, &config_terms, list) { +list_del_init (&pos->list); +free (pos); + }return -EINVAL ; + } evsel = __add_event(list, &parse_state->idx, &attr, get_config_name(head_config), pmu,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 236/350 perf probe: Skip overlapped location on searching variables
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit dee36a2abb67c175265d49b9a8c7dfa564463d9a ]
Since debuginfo__find_probes() callback function can be called with the location which already passed, the callback function must filter out such overlapped locations.
add_probe_trace_event() has already done it by commit 1a375ae7659a ("perf probe: Skip same probe address for a given line"), but add_available_vars() doesn't. Thus perf probe -v shows same address repeatedly as below:
# perf probe -V vfs_read:18
Available variables at vfs_read:18
@<vfs_read+217>
char* buf
loff_t* pos
ssize_t ret
struct file* file
@<vfs_read+217>
char* buf
loff_t* pos
ssize_t ret
struct file* file
@<vfs_read+226>
char* buf
loff_t* pos
ssize_t ret
struct file* fileWith this fix, perf probe -V shows it correctly:
# perf probe -V vfs_read:18
Available variables at vfs_read:18
@<vfs_read+217>
char* buf
loff_t* pos
ssize_t ret
struct file* file
@<vfs_read+226>
char* buf
loff_t* pos
ssize_t ret
struct file* file--- tools/perf/util/probe-finder.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/perf/util/probe-finder.c +20 -0
@@ -1425,6 +1425,18 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)return DIE_FIND_CB_END ; } +static bool available_var_finder_overlap (struct available_var_finder *af) +{ +int i; + +for (i =0 ; i < af->nvls; i++) { +if (af->pf.addr == af->vls[i].point.address) +return true; + } +return false; + +} +/* Add a found vars into available variables list */ static int add_available_vars (Dwarf_Die *sc_die,struct probe_finder *pf) {
@@ -1435,6 +1447,14 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)Dwarf_Die die_mem;int ret; +/* +* For some reason (e.g. different column assigned to same address), +* this callback can be called with the address which already passed. +* Ignore it first. +*/ +if (available_var_finder_overlap (af)) +return 0 ; +/* Check number of tevs */ if (af->nvls == af->max_vls) {pr_warning ("Too many( > %d) probe point found.\n" , af->max_vls);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 237/350 net: avoid potential false sharing in neighbor related code
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 25c7a6d1f90e208ec27ca854b1381ed39842ec57 ]
There are common instances of the following construct :
if (n->confirmed != now) n->confirmed = now;
A C compiler could legally remove the conditional.
Use READ_ONCE()/WRITE_ONCE() to avoid this problem.
--- include/net/arp.h | 4 ++-- include/net/ndisc.h | 8 ++++---- include/net/sock.h | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-)
include/net/arp.h +2 -2
@@ -57,8 +57,8 @@ static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)unsigned long now = jiffies;/* avoid dirtying neighbour */ -if (n->confirmed != now) - n->confirmed = now; +if (READ_ONCE (n->confirmed) != now) +WRITE_ONCE (n->confirmed, now); }rcu_read_unlock_bh (); }
include/net/ndisc.h +4 -4
@@ -414,8 +414,8 @@ static inline void __ipv6_confirm_neigh(struct net_device *dev,unsigned long now = jiffies;/* avoid dirtying neighbour */ -if (n->confirmed != now) - n->confirmed = now; +if (READ_ONCE (n->confirmed) != now) +WRITE_ONCE (n->confirmed, now); }rcu_read_unlock_bh (); }
@@ -431,8 +431,8 @@ static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,unsigned long now = jiffies;/* avoid dirtying neighbour */ -if (n->confirmed != now) - n->confirmed = now; +if (READ_ONCE (n->confirmed) != now) +WRITE_ONCE (n->confirmed, now); }rcu_read_unlock_bh (); }
include/net/sock.h +6 -6
@@ -1940,8 +1940,8 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);static inline void sk_dst_confirm (struct sock *sk) { -if (!sk->sk_dst_pending_confirm) - sk->sk_dst_pending_confirm =1 ; +if (!READ_ONCE (sk->sk_dst_pending_confirm)) +WRITE_ONCE (sk->sk_dst_pending_confirm,1 ); }static inline void sock_confirm_neigh (struct sk_buff *skb,struct neighbour *n)
@@ -1951,10 +1951,10 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)unsigned long now = jiffies;/* avoid dirtying neighbour */ -if (n->confirmed != now) - n->confirmed = now; -if (sk && sk->sk_dst_pending_confirm) - sk->sk_dst_pending_confirm =0 ; +if (READ_ONCE (n->confirmed) != now) +WRITE_ONCE (n->confirmed, now); +if (sk &&READ_ONCE (sk->sk_dst_pending_confirm)) +WRITE_ONCE (sk->sk_dst_pending_confirm,0 ); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 238/350 perf probe: Return a better scope DIE if there is no best scope
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit c701636aeec4c173208697d68da6e4271125564b ]
Make find_best_scope() returns innermost DIE at given address if there is no best matched scope DIE. Since Gcc sometimes generates intuitively strange line info which is out of inlined function address range, we need this fixup.
Without this, sometimes perf probe failed to probe on a line inside an inlined function:
# perf probe -D ksys_open:3
Failed to find scope of probe point.
Error: Failed to add events.With this fix, 'perf probe' can probe it:
# perf probe -D ksys_open:3 p:probe/ksys_open _text+25707308 p:probe/ksys_open_1 _text+25710596 p:probe/ksys_open_2 _text+25711114 p:probe/ksys_open_3 _text+25711343 p:probe/ksys_open_4 _text+25714058 p:probe/ksys_open_5 _text+2819653 p:probe/ksys_open_6 _text+2819701
--- tools/perf/util/probe-finder.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +16 -1
@@ -756,6 +756,16 @@ static int find_best_scope_cb(Dwarf_Die *fn_die, void *data)return 0 ; } +/* Return innermost DIE */ +static int find_inner_scope_cb (Dwarf_Die *fn_die,void *data) +{ +struct find_scope_param *fsp = data; + +memcpy (fsp->die_mem, fn_die,sizeof (Dwarf_Die)); + fsp->found = true; +return 1 ; +} +/* Find an appropriate scope fits to given conditions */ static Dwarf_Die *find_best_scope (struct probe_finder *pf,Dwarf_Die *die_mem) {
@@ -767,8 +777,13 @@ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem) .die_mem = die_mem, .found = false, }; +int ret; -cu_walk_functions_at (&pf->cu_die, pf->addr, find_best_scope_cb, &fsp); + ret =cu_walk_functions_at (&pf->cu_die, pf->addr, find_best_scope_cb, + &fsp); +if (!ret && !fsp.found) +cu_walk_functions_at (&pf->cu_die, pf->addr, + find_inner_scope_cb, &fsp);return fsp.found ? die_mem :NULL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 239/350 perf probe: Fix to show calling lines of inlined functions
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 86c0bf8539e7f46d91bd105e55eda96e0064caef ]
Fix to show calling lines of inlined functions (where an inline function is called).
die_walk_lines() filtered out the lines inside inlined functions based on the address. However this also filtered out the lines which call those inlined functions from the target function.
To solve this issue, check the call_file and call_line attributes and do not filter out if it matches to the line information.
Without this fix, perf probe -L doesn't show some lines correctly. (don't see the lines after 17)
# perf probe -L vfs_read
<vfs_read@/home/mhiramat/ksrc/linux/fs/read_write.c:0>
0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
1 {
2 ssize_t ret; 4 if (!(file->f_mode & FMODE_READ))
return -EBADF;
6 if (!(file->f_mode & FMODE_CAN_READ))
return -EINVAL;
8 if (unlikely(!access_ok(buf, count)))
return -EFAULT;
11 ret = rw_verify_area(READ, file, pos, count);
12 if (!ret) {
13 if (count > MAX_RW_COUNT)
count = MAX_RW_COUNT;
15 ret = __vfs_read(file, buf, count, pos);
16 if (ret > 0) {
fsnotify_access(file);
add_rchar(current, ret);
}With this fix:
# perf probe -L vfs_read
<vfs_read@/home/mhiramat/ksrc/linux/fs/read_write.c:0>
0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
1 {
2 ssize_t ret; 4 if (!(file->f_mode & FMODE_READ))
return -EBADF;
6 if (!(file->f_mode & FMODE_CAN_READ))
return -EINVAL;
8 if (unlikely(!access_ok(buf, count)))
return -EFAULT;
11 ret = rw_verify_area(READ, file, pos, count);
12 if (!ret) {
13 if (count > MAX_RW_COUNT)
count = MAX_RW_COUNT;
15 ret = __vfs_read(file, buf, count, pos);
16 if (ret > 0) {
17 fsnotify_access(file);
18 add_rchar(current, ret);
}
20 inc_syscr(current);
}--- tools/perf/util/dwarf-aux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/util/dwarf-aux.c +9 -1
@@ -755,7 +755,7 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)Dwarf_Lines *lines;Dwarf_Line *line;Dwarf_Addr addr; -const char *fname, *decf =NULL ; +const char *fname, *decf =NULL , *inf =NULL ;int lineno, ret =0 ;int decl =0 , inl;Dwarf_Die die_mem, *cu_die;
@@ -799,13 +799,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)*/ if (!dwarf_haspc (rt_die, addr))continue ; +if (die_find_inlinefunc (rt_die, addr, &die_mem)) { +/* Call-site check */ + inf =die_get_call_file (&die_mem); +if ((inf && !strcmp (inf, decf)) && +die_get_call_lineno (&die_mem) == lineno) + goto found; +dwarf_decl_line (&die_mem, &inl);if (inl != decl || decf !=dwarf_decl_file (&die_mem))continue ; } } +found:/* Get source line */ fname =dwarf_linesrc (line,NULL ,NULL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 240/350 perf probe: Skip end-of-sequence and non statement lines
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit f4d99bdfd124823a81878b44b5e8750b97f73902 ]
Skip end-of-sequence and non-statement lines while walking through lines list.
The "end-of-sequence" line information means:
"the current address is that of the first byte after the
end of a sequence of target machine instructions."
(DWARF version 4 spec 6.2.2)
This actually means out of scope and we can not probe on it.
On the other hand, the statement lines (is_stmt) means:
"the current instruction is a recommended breakpoint location.
A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement."
(DWARF version 4 spec 6.2.2)
So, non-statement line info also should be skipped.
These can reduce unneeded probe points and also avoid an error.
E.g. without this patch:
# perf probe -a "clear_tasks_mm_cpumask:1"
Added new events:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_3 (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_4 (on clear_tasks_mm_cpumask:1)You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask_4 -aR sleep 1
#
This puts 5 probes on one line, but acutally it's not inlined function. This is because there are many non statement instructions at the function prologue.
With this patch:
# perf probe -a "clear_tasks_mm_cpumask:1"
Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
#
Now perf-probe skips unneeded addresses.
Committer testing:
Slightly different results, but similar:
Before:
# uname -a
Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
#
# perf probe -a "clear_tasks_mm_cpumask:1"
Added new events:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask_2 -aR sleep 1
#
After:
# perf probe -a "clear_tasks_mm_cpumask:1"
Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
#--- tools/perf/util/dwarf-aux.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/util/dwarf-aux.c +7 -0
@@ -760,6 +760,7 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)int decl =0 , inl;Dwarf_Die die_mem, *cu_die;size_t nlines, i; +bool flag;/* Get the CU die */ if (dwarf_tag (rt_die) != DW_TAG_compile_unit) {
@@ -790,6 +791,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) "Possible error in debuginfo.\n");continue ; } +/* Skip end-of-sequence */ +if (dwarf_lineendsequence (line, &flag) !=0 || flag) +continue ; +/* Skip Non statement line-info */ +if (dwarf_linebeginstatement (line, &flag) !=0 || !flag) +continue ;/* Filter lines based on address */ if (rt_die != cu_die) {/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 241/350 perf probe: Filter out instances except for inlined subroutine and subprogram
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit da6cb952a89efe24bb76c4971370d485737a2d85 ]
Filter out instances except for inlined_subroutine and subprogram DIE in die_walk_instances() and die_is_func_instance().
This fixes an issue that perf probe sets some probes on calling address instead of a target function itself.
When perf probe walks on instances of an abstruct origin (a kind of function prototype of inlined function), die_walk_instances() can also pass a GNU_call_site (a GNU extension for call site) to callback. Since it is not an inlined instance of target function, we have to filter out when searching a probe point.
Without this patch, perf probe sets probes on call site address too.This can happen on some function which is marked "inlined", but has actual symbol. (I'm not sure why GCC mark it "inlined"):
# perf probe -D vfs_read p:probe/vfs_read _text+2500017 p:probe/vfs_read_1 _text+2499468 p:probe/vfs_read_2 _text+2499563 p:probe/vfs_read_3 _text+2498876 p:probe/vfs_read_4 _text+2498512 p:probe/vfs_read_5 _text+2498627
With this patch:
Slightly different results, similar tho:
# perf probe -D vfs_read p:probe/vfs_read _text+2498512
Committer testing:
# uname -a Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Before:
# perf probe -D vfs_read p:probe/vfs_read _text+3131557 p:probe/vfs_read_1 _text+3130975 p:probe/vfs_read_2 _text+3131047 p:probe/vfs_read_3 _text+3130380 p:probe/vfs_read_4 _text+3130000 # uname -a Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux #
After:
# perf probe -D vfs_read p:probe/vfs_read _text+3130000 #
--- tools/perf/util/dwarf-aux.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
tools/perf/util/dwarf-aux.c +13 -6
@@ -312,18 +312,22 @@ bool die_is_func_def(Dwarf_Die *dw_die)* @dw_die: a DIE * * Ensure that this DIE is an instance (which has an entry address). -* This returns true if @dw_die is a function instance. If not, you need to -* call die_walk_instances() to find actual instances. +* This returns true if @dw_die is a function instance. If not, the @dw_die +* must be a prototype. You can use die_walk_instances() to find actual +* instances. **/ bool die_is_func_instance (Dwarf_Die *dw_die) {Dwarf_Addr tmp;Dwarf_Attribute attr_mem; +int tag =dwarf_tag (dw_die); -/* Actually gcc optimizes non-inline as like as inlined */ -return !dwarf_func_inline (dw_die) && - (dwarf_entrypc (dw_die, &tmp) ==0 || -dwarf_attr (dw_die, DW_AT_ranges, &attr_mem) !=NULL ); +if (tag != DW_TAG_subprogram && + tag != DW_TAG_inlined_subroutine) +return false; + +return dwarf_entrypc (dw_die, &tmp) ==0 || +dwarf_attr (dw_die, DW_AT_ranges, &attr_mem) !=NULL ; }/**
@@ -602,6 +606,9 @@ static int __die_walk_instances_cb(Dwarf_Die *inst, void *data)Dwarf_Die *origin;int tmp; +if (!die_is_func_instance (inst)) +return DIE_FIND_CB_CONTINUE ; + attr =dwarf_attr (inst, DW_AT_abstract_origin, &attr_mem);if (attr ==NULL )return DIE_FIND_CB_CONTINUE ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 242/350 libbpf: Fix negative FD close() in xsk_setup_xdp_prog()
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 9656b346b280c3e49c8a116c3a715f966633b161 ]
Fix issue reported by static analysis (Coverity). If bpf_prog_get_fd_by_id() fails, xsk_lookup_bpf_maps() will fail as well and clean-up code will attempt close() with fd=-1. Fix by checking bpf_prog_get_fd_by_id() return result and exiting early.
--- tools/lib/bpf/xsk.c | 2 ++ 1 file changed, 2 insertions(+)
tools/lib/bpf/xsk.c +2 -0
@@ -466,6 +466,8 @@ static int xsk_setup_xdp_prog(struct xsk_socket *xsk) } }else { xsk->prog_fd =bpf_prog_get_fd_by_id (prog_id); +if (xsk->prog_fd <0 ) +return -errno; err =xsk_lookup_bpf_maps (xsk);if (err) {close (xsk->prog_fd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 243/350 s390/bpf: Use kvcalloc for addrs array
In reply to Sasha LevinFrom: Ilya Leoshkevich <[email protected]>
[ Upstream commit 166f11d11f6f70439830d09bfa5552ec1b368494 ]
A BPF program may consist of 1m instructions, which means JIT instruction-address mapping can be as large as 4m. s390 has FORCE_MAX_ZONEORDER=9 (for memory hotplug reasons), which means maximum kmalloc size is 1m. This makes it impossible to JIT programs with more than 256k instructions.
Fix by using kvcalloc, which falls back to vmalloc for larger allocations. An alternative would be to use a radix tree, but that is not supported by bpf_prog_fill_jited_linfo.
--- arch/s390/net/bpf_jit_comp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +3 -2
@@ -23,6 +23,7 @@#include <linux/filter.h> #include <linux/init.h> #include <linux/bpf.h> +#include <linux/mm.h> #include <asm/cacheflush.h> #include <asm/dis.h> #include <asm/facility.h>
@@ -1369,7 +1370,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) }memset (&jit,0 ,sizeof (jit)); - jit.addrs =kcalloc (fp->len +1 ,sizeof (*jit.addrs),GFP_KERNEL ); + jit.addrs =kvcalloc (fp->len +1 ,sizeof (*jit.addrs),GFP_KERNEL );if (jit.addrs ==NULL ) { fp = orig_fp; goto out;
@@ -1422,7 +1423,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)if (!fp->is_func || extra_pass) {bpf_prog_fill_jited_linfo (fp, jit.addrs +1 ); free_addrs: -kfree (jit.addrs); +kvfree (jit.addrs);kfree (jit_data); fp->aux->jit_data =NULL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 244/350 cgroup: freezer: don't change task and cgroups status unnecessarily
In reply to Sasha LevinFrom: Honglei Wang <[email protected]>
[ Upstream commit 742e8cd3e1ba6f19cad6d912f8d469df5557d0fd ]
It's not necessary to adjust the task state and revisit the state of source and destination cgroups if the cgroups are not in freeze state and the task itself is not frozen.
And in this scenario, it wakes up the task who's not supposed to be ready to run.
Don't do the unnecessary task state adjustment can help stop waking up the task without a reason.
--- kernel/cgroup/freezer.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/cgroup/freezer.c +9 -0
@@ -230,6 +230,15 @@ void cgroup_freezer_migrate_task(struct task_struct *task,if (task->flags &PF_KTHREAD )return ; +/* +* It's not necessary to do changes if both of the src and dst cgroups +* are not freezing and task is not frozen. +*/ +if (!test_bit (CGRP_FREEZE , &src->flags) && + !test_bit (CGRP_FREEZE , &dst->flags) && + !task->frozen) +return ; +/* * Adjust counters of freezing and frozen tasks. * Note, that if the task is frozen, but the destination cgroup is not
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 245/350 selftests: proc: Make va_max 1MB
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 2f3571ea71311bbb2cbb9c3bbefc9c1969a3e889 ]
Currently proc-self-map-files-002.c sets va_max (max test address of user virtual address) to 4GB, but it is too big for 32bit arch and 1UL << 32 is overflow on 32bit long.
Also since this value should be enough bigger than vm.mmap_min_addr (64KB or 32KB by default), 1MB should be enough.
Make va_max 1MB unconditionally.
--- tools/testing/selftests/proc/proc-self-map-files-002.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/proc-self-map-files-002.c +5 -1
@@ -47,7 +47,11 @@ static void fail(const char *fmt, unsigned long a, unsigned long b)int main (void ) {const int PAGE_SIZE =sysconf (_SC_PAGESIZE); -const unsigned long va_max =1UL <<32 ; +/* +* va_max must be enough bigger than vm.mmap_min_addr, which is +* 64KB/32KB by default. (depends on CONFIG_LSM_MMAP_MIN_ADDR) +*/ +const unsigned long va_max =1UL <<20 ;unsigned long va;void *p;int fd;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 246/350 drm/amdgpu: Avoid accidental thread reactivation.
In reply to Sasha LevinFrom: Andrey Grodzovsky <[email protected]>
[ Upstream commit a28fda312a9fabdf0e5f5652449d6197c9fb0a90 ]
Problem:
During GPU reset we call the GPU scheduler to suspend it's thread, those two functions in amdgpu also suspend and resume the sceduler for their needs but this can collide with GPU reset in progress and accidently restart a suspended thread before time.
Fix:
Serialize with GPU reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10 -0
@@ -859,6 +859,9 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)struct amdgpu_device *adev = dev->dev_private;int r =0 , i; +/* Avoid accidently unparking the sched thread during GPU reset */ +mutex_lock (&adev->lock_reset); +/* hold on the scheduler */ for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) {struct amdgpu_ring *ring = adev->rings[i];
@@ -884,6 +887,8 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)kthread_unpark (ring->sched.thread); } +mutex_unlock (&adev->lock_reset); +return 0 ; }
@@ -1036,6 +1041,9 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)if (!fences)return -ENOMEM ; +/* Avoid accidently unparking the sched thread during GPU reset */ +mutex_lock (&adev->lock_reset); +/* stop the scheduler */ kthread_park (ring->sched.thread);
@@ -1075,6 +1083,8 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)/* restart the scheduler */ kthread_unpark (ring->sched.thread); +mutex_unlock (&adev->lock_reset); +ttm_bo_unlock_delayed_workqueue (&adev->mman.bdev, resched);if (fences)
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 247/350 media: exynos4-is: fix wrong mdev and v4l2 dev order in error path
In reply to Sasha LevinFrom: Seung-Woo Kim <[email protected]>
[ Upstream commit 4d741cbd58bf889c8a68cf6e592a7892b5c2802e ]
When driver is built as module and probe during insmod is deferred because of sensor subdevs, there is NULL pointer deference because mdev is cleaned up and then access it from v4l2_device_unregister(). Fix the wrong mdev and v4l2 dev order in error path of probe.
This fixes below null pointer deference:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ca026f68 [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM [...] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) PC is at ida_free+0x7c/0x160 LR is at xas_start+0x44/0x204 [...] [<c0dafd60>] (ida_free) from [<c083c20c>] (__media_device_unregister_entity+0x18/0xc0) [<c083c20c>] (__media_device_unregister_entity) from [<c083c2e0>] (media_device_unregister_entity+0x2c/0x38) [<c083c2e0>] (media_device_unregister_entity) from [<c0843404>] (v4l2_device_release+0xd0/0x104) [<c0843404>] (v4l2_device_release) from [<c0632558>] (device_release+0x28/0x98) [<c0632558>] (device_release) from [<c0db1204>] (kobject_put+0xa4/0x208) [<c0db1204>] (kct_put) from [<bf00bac4>] (fimc_capture_subdev_unregistered+0x58/0x6c [s5p_fimc]) [<bf00bac4>] (fimc_capture_subdev_unregistered [s5p_fimc]) from [<c084a1cc>] (v4l2_device_unregister_subdev+0x6c/0xa8) [<c084a1cc>] (v4l2_device_unregister_subdev) from [<c084a350>] (v4l2_device_unregister+0x64/0x94) [<c084a350>] (v4l2_device_unregister) from [<bf0101ac>] (fimc_md_probe+0x4ec/0xaf8 [s5p_fimc]) [...]
--- drivers/media/platform/exynos4-is/media-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +4 -3
@@ -1457,12 +1457,12 @@ static int fimc_md_probe(struct platform_device *pdev) ret =v4l2_device_register (dev, &fmd->v4l2_dev);if (ret <0 ) {v4l2_err (v4l2_dev,"Failed to register v4l2_device: %d\n" , ret); -return ret; + goto err_md; } ret =fimc_md_get_clocks (fmd);if (ret) - goto err_md; + goto err_v4l2dev; ret =fimc_md_get_pinctrl (fmd);if (ret <0 ) {
@@ -1519,9 +1519,10 @@ static int fimc_md_probe(struct platform_device *pdev)fimc_md_unregister_entities (fmd); err_clk:fimc_md_put_clocks (fmd); +err_v4l2dev: +v4l2_device_unregister (&fmd->v4l2_dev); err_md:media_device_cleanup (&fmd->media_dev); -v4l2_device_unregister (&fmd->v4l2_dev);return ret; }
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 248/350 ath10k: fix get invalid tx rate for Mesh metric
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit 05a11003a56507023f18d3249a4d4d119c0a3e9c ]
ath10k does not provide transmit rate info per MSDU in tx completion, mark that as -1 so mac80211 will ignore the rates. This fixes mac80211 update Mesh link metric with invalid transmit rate info.
Tested HW: QCA9984
Tested FW: 10.4-3.9.0.2-00035
--- drivers/net/wireless/ath/ath10k/txrx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath10k/txrx.c +2 -0
@@ -95,6 +95,8 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt, info =IEEE80211_SKB_CB (msdu);memset (&info->status,0 ,sizeof (info->status)); + info->status.rates[0 ].idx =-1 ; +trace_ath10k_txrx_tx_unref (ar, tx_done->msdu_id);if (!(info->flags &IEEE80211_TX_CTL_NO_ACK ))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 249/350 fsi: core: Fix small accesses and unaligned offsets via sysfs
In reply to Sasha LevinFrom: Andrew Jeffery <[email protected]>
[ Upstream commit 9f4c2b516b4f031e3cd0e45957f4150b3c1a083d ]
Subtracting the offset delta from four-byte alignment lead to wrapping of the requested length where count is less than off. Generalise the length handling to enable and optimise aligned access sizes for all offset and size combinations. The new formula produces the following results for given offset and count values:
offset count | length
--------------+-------
0 1 | 1
0 2 | 2
0 3 | 2
0 4 | 4
0 5 | 4
1 1 | 1
1 2 | 1
1 3 | 1
1 4 | 1
1 5 | 1
2 1 | 1
2 2 | 2
2 3 | 2
2 4 | 2
2 5 | 2
3 1 | 1
3 2 | 1
3 3 | 1
3 4 | 1
3 5 | 1
We might need something like this for the cfam chardevs as well, for example we don't currently implement any alignment restrictions / handling in the hardware master driver.
--- drivers/fsi/fsi-core.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/fsi/fsi-core.c +27 -4
@@ -544,6 +544,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)return 0 ; } +static unsigned long aligned_access_size (size_t offset,size_t count) +{ +unsigned long offset_unit, count_unit; + +/* Criteria: +* +* 1. Access size must be less than or equal to the maximum access +* width or the highest power-of-two factor of offset +* 2. Access size must be less than or equal to the amount specified by +* count +* +* The access width is optimal if we can calculate 1 to be strictly +* equal while still satisfying 2. +*/ + +/* Find 1 by the bottom bit of offset (with a 4 byte access cap) */ + offset_unit =BIT (__builtin_ctzl (offset |4 )); + +/* Find 2 by the top bit of count */ + count_unit =BIT (8 *sizeof (unsigned long ) -1 -__builtin_clzl (count)); + +/* Constrain the maximum access width to the minimum of both criteria */ +return BIT (__builtin_ctzl (offset_unit | count_unit)); +} +static ssize_t fsi_slave_sysfs_raw_read (struct file *file,struct kobject *kobj,struct bin_attribute *attr,char *buf,loff_t off,size_t count)
@@ -559,8 +584,7 @@ static ssize_t fsi_slave_sysfs_raw_read(struct file *file,return -EINVAL ;for (total_len =0 ; total_len < count; total_len += read_len) { - read_len =min_t (size_t, count,4 ); - read_len -= off &0x3 ; + read_len =aligned_access_size (off, count - total_len); rc =fsi_slave_read (slave, off, buf + total_len, read_len);if (rc)
@@ -587,8 +611,7 @@ static ssize_t fsi_slave_sysfs_raw_write(struct file *file,return -EINVAL ;for (total_len =0 ; total_len < count; total_len += write_len) { - write_len =min_t (size_t, count,4 ); - write_len -= off &0x3 ; + write_len =aligned_access_size (off, count - total_len); rc =fsi_slave_write (slave, off, buf + total_len, write_len);if (rc)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 250/350 selftests: net: Fix printf format warnings on arm
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 670cd6849ea36ea4df2f2941cf4717dff8755abe ]
Fix printf format warnings on arm (and other 32bit arch).
- udpgso.c and udpgso_bench_tx use %lu for size_t but it should be unsigned long long on 32bit arch.
- so_txtime.c uses %ld for int64_t, but it should be unsigned long long on 32bit arch.
--- tools/testing/selftests/net/so_txtime.c | 4 ++-- tools/testing/selftests/net/udpgso.c | 3 ++- tools/testing/selftests/net/udpgso_bench_tx.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
tools/testing/selftests/net/so_txtime.c +2 -2
@@ -105,8 +105,8 @@ static void do_recv_one(int fdr, struct timed_send *ts) tstop = (gettime_ns () - glob_tstart) /1000 ; texpect = ts->delay_us >=0 ? ts->delay_us :0 ; -fprintf (stderr,"payload:%c delay:%ld expected:%ld (us)\n" , - rbuf[0 ], tstop, texpect); +fprintf (stderr,"payload:%c delay:%lld expected:%lld (us)\n" , + rbuf[0 ], (long long )tstop, (long long )texpect);if (rbuf[0 ] != ts->data)error (1 ,0 ,"payload mismatch. expected %c" , ts->data);
tools/testing/selftests/net/udpgso.c +2 -1
@@ -440,7 +440,8 @@ static bool __send_one(int fd, struct msghdr *msg, int flags)if (ret ==-1 )error (1 , errno,"sendmsg" );if (ret != msg->msg_iov->iov_len) -error (1 ,0 ,"sendto: %d != %lu" , ret, msg->msg_iov->iov_len); +error (1 ,0 ,"sendto: %d != %llu" , ret, + (unsigned long long )msg->msg_iov->iov_len);if (msg->msg_flags)error (1 ,0 ,"sendmsg: return flags 0x%x\n" , msg->msg_flags);
tools/testing/selftests/net/udpgso_bench_tx.c +2 -1
@@ -405,7 +405,8 @@ static int send_udp_segment(int fd, char *data)if (ret ==-1 )error (1 , errno,"sendmsg" );if (ret != iov.iov_len) -error (1 ,0 ,"sendmsg: %u != %lu\n" , ret, iov.iov_len); +error (1 ,0 ,"sendmsg: %u != %llu\n" , ret, + (unsigned long long )iov.iov_len);return 1 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 251/350 EDAC/ghes: Fix locking and memory barrier issues
In reply to Sasha LevinFrom: Robert Richter <[email protected]>
[ Upstream commit 23f61b9fc5cc10d87f66e50518707eec2a0fbda1 ]
The ghes registration and refcount is broken in several ways:
* ghes_edac_register() returns with success for a 2nd instance even if a first instance's registration is still running. This is not correct as the first instance may fail later. A subsequent registration may not finish before the first. Parallel registrations must be avoided.
* The refcount was increased even if a registration failed. This leads to stale counters preventing the device from being released.
* The ghes refcount may not be decremented properly on unregistration. Always decrement the refcount once ghes_edac_unregister() is called to keep the refcount sane.
* The ghes_pvt pointer is handed to the irq handler before registration finished.
* The mci structure could be freed while the irq handler is running.
Fix this by adding a mutex to ghes_edac_register(). This mutex serializes instances to register and unregister. The refcount is only increased if the registration succeeded. This makes sure the refcount is in a consistent state after registering or unregistering a device.
Note: A spinlock cannot be used here as the code section may sleep.
The ghes_pvt is protected by ghes_lock now. This ensures the pointer is not updated before registration was finished or while the irq handler is running. It is unset before unregistering the device including necessary (implicit) memory barriers making the changes visible to other CPUs. Thus, the device can not be used anymore by an interrupt.
Also, rename ghes_init to ghes_refcount for better readability and switch to refcount API.
A refcount is needed because there can be multiple GHES structures being defined (see ACPI 6.3 specification, 18.3.2.7 Generic Hardware Error Source, "Some platforms may describe multiple Generic Hardware Error Source structures with different notification types, ...").
Another approach to use the mci's device refcount (get_device()) and have a release function does not work here. A release function will be called only for device_release() with the last put_device() call. The device must be deleted *before* that with device_del(). This is only possible by maintaining an own refcount.
[ bp: touchups. ]
--- drivers/edac/ghes_edac.c | 90 +++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 24 deletions(-)
drivers/edac/ghes_edac.c +66 -24
@@ -26,9 +26,18 @@ struct ghes_edac_pvt {char msg[80 ]; }; -static atomic_t ghes_init =ATOMIC_INIT (0 ); +static refcount_t ghes_refcount =REFCOUNT_INIT (0 ); + +/* +* Access to ghes_pvt must be protected by ghes_lock. The spinlock +* also provides the necessary (implicit) memory barrier for the SMP +* case to make the pointer visible on another CPU. +*/ static struct ghes_edac_pvt *ghes_pvt; +/* GHES registration mutex */ +static DEFINE_MUTEX (ghes_reg_mutex); +/* * Sync with other, potentially concurrent callers of * ghes_edac_report_mem_error(). We don't know what the
@@ -79,9 +88,8 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } -static int get_dimm_smbios_index (u16 handle) +static int get_dimm_smbios_index (struct mem_ctl_info *mci,u16 handle) { -struct mem_ctl_info *mci = ghes_pvt->mci;int i;for (i =0 ; i < mci->tot_dimms; i++) {
@@ -198,14 +206,11 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)enum hw_event_mc_err_type type;struct edac_raw_error_desc *e;struct mem_ctl_info *mci; -struct ghes_edac_pvt *pvt = ghes_pvt; +struct ghes_edac_pvt *pvt;unsigned long flags;char *p;u8 grain_bits; -if (!pvt) -return ; -/* * We can do the locking below because GHES defers error processing * from NMI to IRQ context. Whenever that changes, we'd at least
@@ -216,6 +221,10 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)spin_lock_irqsave (&ghes_lock, flags); + pvt = ghes_pvt; +if (!pvt) + goto unlock; + mci = pvt->mci; e = &mci->error_desc;
@@ -348,7 +357,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , mem_err->mem_dev_handle); - index =get_dimm_smbios_index (mem_err->mem_dev_handle); + index =get_dimm_smbios_index (mci, mem_err->mem_dev_handle);if (index >=0 ) { e->top_layer = index; e->enable_per_layer_report = true;
@@ -443,6 +452,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) grain_bits, e->syndrome, pvt->detail_location);edac_raw_mc_handle_error (type, mci, e); + +unlock:spin_unlock_irqrestore (&ghes_lock, flags); }
@@ -457,10 +468,12 @@ static struct acpi_platform_list plat_list[] = {int ghes_edac_register (struct ghes *ghes,struct device *dev) {bool fake = false; -int rc, num_dimm =0 ; +int rc =0 , num_dimm =0 ;struct mem_ctl_info *mci; +struct ghes_edac_pvt *pvt;struct edac_mc_layer layers[1 ];struct ghes_edac_dimm_fill dimm_fill; +unsigned long flags;int idx =-1 ;if (IS_ENABLED (CONFIG_X86 )) {
@@ -472,11 +485,14 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) idx =0 ; } +/* finish another registration/unregistration instance first */ +mutex_lock (&ghes_reg_mutex); +/* * We have only one logical memory controller to which all DIMMs belong. */ -if (atomic_inc_return (&ghes_init) >1 ) -return 0 ; +if (refcount_inc_not_zero (&ghes_refcount)) + goto unlock;/* Get the number of DIMMs */ dmi_walk (ghes_edac_count_dimms, &num_dimm);
@@ -494,12 +510,13 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) mci =edac_mc_alloc (0 ,ARRAY_SIZE (layers), layers,sizeof (struct ghes_edac_pvt ));if (!mci) {pr_info ("Can't allocate memory for EDAC data\n" ); -return -ENOMEM ; + rc = -ENOMEM ; + goto unlock; } - ghes_pvt = mci->pvt_info; - ghes_pvt->ghes = ghes; - ghes_pvt->mci = mci; + pvt = mci->pvt_info; + pvt->ghes = ghes; + pvt->mci = mci; mci->pdev = dev; mci->mtype_cap =MEM_FLAG_EMPTY ;
@@ -541,23 +558,48 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)if (rc <0 ) {pr_info ("Can't register at EDAC core\n" );edac_mc_free (mci); -return -ENODEV ; + rc = -ENODEV ; + goto unlock; } -return 0 ; + +spin_lock_irqsave (&ghes_lock, flags); + ghes_pvt = pvt; +spin_unlock_irqrestore (&ghes_lock, flags); + +/* only increment on success */ +refcount_inc (&ghes_refcount); + +unlock: +mutex_unlock (&ghes_reg_mutex); + +return rc; }void ghes_edac_unregister (struct ghes *ghes) {struct mem_ctl_info *mci; +unsigned long flags; -if (!ghes_pvt) -return ; +mutex_lock (&ghes_reg_mutex); -if (atomic_dec_return (&ghes_init)) -return ; +if (!refcount_dec_and_test (&ghes_refcount)) + goto unlock; - mci = ghes_pvt->mci; +/* +* Wait for the irq handler being finished. +*/ +spin_lock_irqsave (&ghes_lock, flags); + mci = ghes_pvt ? ghes_pvt->mci :NULL ; ghes_pvt =NULL ; -edac_mc_del_mc (mci->pdev); -edac_mc_free (mci); +spin_unlock_irqrestore (&ghes_lock, flags); + +if (!mci) + goto unlock; + + mci =edac_mc_del_mc (mci->pdev); +if (mci) +edac_mc_free (mci); + +unlock: +mutex_unlock (&ghes_reg_mutex); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 252/350 media: pvrusb2: Fix oops on tear-down when radio support is not present
In reply to Sasha LevinFrom: Mike Isely <[email protected]>
[ Upstream commit 7f404ae9cf2a285f73b3c18ab9303d54b7a3d8e1 ]
In some device configurations there's no radio or radio support in the driver. That's OK, as the driver sets itself up accordingly. However on tear-down in these caes it's still trying to tear down radio related context when there isn't anything there, leading to dereferences through a null pointer and chaos follows.
How this bug survived unfixed for 11 years in the pvrusb2 driver is a mystery to me.
[hverkuil: fix two checkpatch warnings]
--- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +7 -2
@@ -898,8 +898,12 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)pvr2_v4l2_dev_disassociate_parent (vp->dev_video);pvr2_v4l2_dev_disassociate_parent (vp->dev_radio);if (!list_empty (&vp->dev_video->devbase.fh_list) || - !list_empty (&vp->dev_radio->devbase.fh_list)) + (vp->dev_radio && + !list_empty (&vp->dev_radio->devbase.fh_list))) { +pvr2_trace (PVR2_TRACE_STRUCT , +"pvr2_v4l2 internal_check exit-empty id=%p" , vp);return ; + }pvr2_v4l2_destroy_no_lock (vp); }
@@ -935,7 +939,8 @@ static int pvr2_v4l2_release(struct file *file)kfree (fhp);if (vp->channel.mc_head->disconnect_flag &&list_empty (&vp->dev_video->devbase.fh_list) && -list_empty (&vp->dev_radio->devbase.fh_list)) { + (!vp->dev_radio || +list_empty (&vp->dev_radio->devbase.fh_list))) {pvr2_v4l2_destroy_no_lock (vp); }return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 253/350 soundwire: intel: fix PDI/stream mapping for Bulk
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit c134f914e9f55b7817e2bae625ec0e5f1379f7cd ]
The previous formula is incorrect for PDI0/1, the mapping is not linear but has a discontinuity between PDI1 and PDI2.
This change has no effect on PCM PDIs (same mapping).
--- drivers/soundwire/intel.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/soundwire/intel.c +8 -2
@@ -479,7 +479,10 @@ intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)unsigned int link_id = sdw->instance;int pdi_conf =0 ; - pdi->intel_alh_id = (link_id *16 ) + pdi->num +5 ; +/* the Bulk and PCM streams are not contiguous */ + pdi->intel_alh_id = (link_id *16 ) + pdi->num +3 ; +if (pdi->num >=2 ) + pdi->intel_alh_id +=2 ;/* * Program stream parameters to stream SHIM register
@@ -508,7 +511,10 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)unsigned int link_id = sdw->instance;unsigned int conf; - pdi->intel_alh_id = (link_id *16 ) + pdi->num +5 ; +/* the Bulk and PCM streams are not contiguous */ + pdi->intel_alh_id = (link_id *16 ) + pdi->num +3 ; +if (pdi->num >=2 ) + pdi->intel_alh_id +=2 ;/* Program Stream config ALH register */ conf =intel_readl (alh,SDW_ALH_STRMZCFG (pdi->intel_alh_id));
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 254/350 crypto: atmel - Fix authenc support when it is set to m
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
[ Upstream commit 1520c72596dde7f22b8bd6bed3ef7df2b8b7ef39 ]
As it is if CONFIG_CRYPTO_DEV_ATMEL_AUTHENC is set to m it is in effect disabled. This patch fixes it by using IS_ENABLED instead of ifdef.
--- drivers/crypto/atmel-aes.c | 18 +++++++++--------- drivers/crypto/atmel-authenc.h | 2 +- drivers/crypto/atmel-sha.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/crypto/atmel-aes.c +9 -9
@@ -145,7 +145,7 @@ struct atmel_aes_xts_ctx {u32 key2[AES_KEYSIZE_256 /sizeof (u32)]; }; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC) struct atmel_aes_authenc_ctx { struct atmel_aes_base_ctx base; struct atmel_sha_authenc_ctx *auth;
@@ -157,7 +157,7 @@ struct atmel_aes_reqctx {u32 lastc[AES_BLOCK_SIZE /sizeof (u32)]; }; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC) struct atmel_aes_authenc_reqctx { struct atmel_aes_reqctx base;
@@ -486,13 +486,13 @@ static inline bool atmel_aes_is_encrypt(const struct atmel_aes_dev *dd)return (dd->flags &AES_FLAGS_ENCRYPT ); } -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )static void atmel_aes_authenc_complete (struct atmel_aes_dev *dd,int err);#endif static inline int atmel_aes_complete (struct atmel_aes_dev *dd,int err) { -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )if (dd->ctx->is_aead)atmel_aes_authenc_complete (dd, err);#endif
@@ -1973,7 +1973,7 @@ static struct crypto_alg aes_xts_alg = { } }; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )/* authenc aead functions */ static int atmel_aes_authenc_start (struct atmel_aes_dev *dd);
@@ -2460,7 +2460,7 @@ static void atmel_aes_unregister_algs(struct atmel_aes_dev *dd) {int i; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )if (dd->caps.has_authenc)for (i =0 ; i <ARRAY_SIZE (aes_authenc_algs); i++)crypto_unregister_aead (&aes_authenc_algs[i]);
@@ -2507,7 +2507,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd) goto err_aes_xts_alg; } -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )if (dd->caps.has_authenc) {for (i =0 ; i <ARRAY_SIZE (aes_authenc_algs); i++) { err =crypto_register_aead (&aes_authenc_algs[i]);
@@ -2519,7 +2519,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)return 0 ; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )/* i = ARRAY_SIZE(aes_authenc_algs); */ err_aes_authenc_alg:for (j =0 ; j < i; j++)
@@ -2709,7 +2709,7 @@ static int atmel_aes_probe(struct platform_device *pdev)atmel_aes_get_cap (aes_dd); -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )if (aes_dd->caps.has_authenc && !atmel_sha_authenc_is_ready ()) { err = -EPROBE_DEFER ; goto iclk_unprepare;
drivers/crypto/atmel-authenc.h +1 -1
@@ -12,7 +12,7 @@#ifndef __ATMEL_AUTHENC_H__#define __ATMEL_AUTHENC_H__ -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )#include <crypto/authenc.h> #include <crypto/hash.h>
drivers/crypto/atmel-sha.c +1 -1
@@ -2212,7 +2212,7 @@ static struct ahash_alg sha_hmac_algs[] = { }, }; -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )/* authenc functions */ static int atmel_sha_authenc_init2 (struct atmel_sha_dev *dd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 255/350 ice: delay less
In reply to Sasha LevinFrom: Mitch Williams <[email protected]>
[ Upstream commit 88bb432a55de8ae62106305083a8bfbb23b01ad2 ]
Shorten the delay for SQ responses, but increase the number of loops. Max delay time is unchanged, but some operations complete much more quickly.
In the process, add a new define to make the delay count and delay time more explicit. Add comments to make things more explicit.
This fixes a problem with VF resets failing on with many VFs.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 2 +- drivers/net/ethernet/intel/ice/ice_controlq.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +1 -1
@@ -948,7 +948,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,if (ice_sq_done (hw, cq))break ; -mdelay (1 ); +udelay (ICE_CTL_Q_SQ_CMD_USEC ); total_delay++; }while (total_delay < cq->sq_cmd_timeout);
drivers/net/ethernet/intel/ice/ice_controlq.h +3 -2
@@ -31,8 +31,9 @@ enum ice_ctl_q { ICE_CTL_Q_MAILBOX, }; -/* Control Queue default settings */ -#define ICE_CTL_Q_SQ_CMD_TIMEOUT 250/* msecs */ +/* Control Queue timeout settings - max delay 250ms */ +#define ICE_CTL_Q_SQ_CMD_TIMEOUT 2500/* Count 2500 times */ +#define ICE_CTL_Q_SQ_CMD_USEC 100/* Check every 100usec */ struct ice_ctl_q_ring {void *dma_head;/* Virtual address to DMA head */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 256/350 iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit fc3f6ad7f5dc6c899fbda0255865737bac88c2e0 ]
Since st_lsm6dsx i2c master controller relies on accel device as trigger and slave devices can run at different ODRs we must select an accel_odr >= slave_odr. Report real accel ODR in st_lsm6dsx_check_odr() in order to properly set sensor frequency in st_lsm6dsx_write_raw and avoid to report unsupported frequency
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +5 -4
@@ -985,8 +985,7 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val)return -EINVAL ; *val = odr_table->odr_avl[i].val; - -return 0 ; +return odr_table->odr_avl[i].hz; } static u16 st_lsm6dsx_check_odr_dependency(struct st_lsm6dsx_hw *hw, u16 odr,
@@ -1149,8 +1148,10 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,case IIO_CHAN_INFO_SAMP_FREQ : {u8 data; - err =st_lsm6dsx_check_odr (sensor, val, &data); -if (!err) + val =st_lsm6dsx_check_odr (sensor, val, &data); +if (val <0 ) + err = val; +else sensor->odr = val;break ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 257/350 media: si470x-i2c: add missed operations in remove
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 2df200ab234a86836a8879a05a8007d6b884eb14 ]
The driver misses calling v4l2_ctrl_handler_free and v4l2_device_unregister in remove like what is done in probe failure. Add the calls to fix it.
--- drivers/media/radio/si470x/radio-si470x-i2c.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/radio/si470x/radio-si470x-i2c.c +2 -0
@@ -482,6 +482,8 @@ static int si470x_i2c_remove(struct i2c_client *client)if (radio->gpio_reset)gpiod_set_value (radio->gpio_reset,0 ); +v4l2_ctrl_handler_free (&radio->hdl); +v4l2_device_unregister (&radio->v4l2_dev);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 258/350 media: cedrus: Use helpers to access capture queue
In reply to Sasha LevinFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 1fd50a2c294457508f06b8b631d01a58de81cdd2 ]
Accessing capture queue structue directly is not safe. Use helpers for that.
--- drivers/staging/media/sunxi/cedrus/cedrus.h | 8 ++++++-- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus.h +6 -2
@@ -179,12 +179,16 @@ static inline dma_addr_t cedrus_buf_addr(struct vb2_buffer *buf,static inline dma_addr_t cedrus_dst_buf_addr (struct cedrus_ctx *ctx,int index,unsigned int plane) { -struct vb2_buffer *buf; +struct vb2_buffer *buf =NULL ; +struct vb2_queue *vq;if (index <0 )return 0 ; - buf = ctx->fh.m2m_ctx->cap_q_ctx.q.bufs[index]; + vq =v4l2_m2m_get_vq (ctx->fh.m2m_ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); +if (vq) + buf =vb2_get_buffer (vq, index); +return buf ?cedrus_buf_addr (buf, &ctx->dst_fmt, plane) :0 ; }
drivers/staging/media/sunxi/cedrus/cedrus_h264.c +6 -2
@@ -96,7 +96,7 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx,const struct v4l2_ctrl_h264_decode_params *decode = run->h264.decode_params;const struct v4l2_ctrl_h264_slice_params *slice = run->h264.slice_params;const struct v4l2_ctrl_h264_sps *sps = run->h264.sps; -struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; +struct vb2_queue *cap_q;struct cedrus_buffer *output_buf;struct cedrus_dev *dev = ctx->dev;unsigned long used_dpbs =0 ;
@@ -104,6 +104,8 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx,unsigned int output =0 ;unsigned int i; + cap_q =v4l2_m2m_get_vq (ctx->fh.m2m_ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); +memset (pic_list,0 ,sizeof (pic_list));for (i =0 ; i <ARRAY_SIZE (decode->dpb); i++) {
@@ -167,12 +169,14 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx, enum cedrus_h264_sram_off sram) {const struct v4l2_ctrl_h264_decode_params *decode = run->h264.decode_params; -struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; +struct vb2_queue *cap_q;struct cedrus_dev *dev = ctx->dev;u8 sram_array[CEDRUS_MAX_REF_IDX ];unsigned int i;size_t size; + cap_q =v4l2_m2m_get_vq (ctx->fh.m2m_ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); +memset (sram_array,0 ,sizeof (sram_array));for (i =0 ; i < num_ref; i++) {
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 259/350 media: v4l2-ctrl: Lock main_hdl on operations of requests_queued.
In reply to Sasha LevinFrom: Pi-Hsun Shih <[email protected]>
[ Upstream commit df4a3e7f88e3b0d7ae46d70b9ff8e3c0ea730785 ]
There's a race condition between the list_del_init in the v4l2_ctrl_request_complete, and the list_add_tail in the v4l2_ctrl_request_queue, since they can be called in different thread and the requests_queued list is not protected by a lock. This can lead to that the v4l2_ctrl_handler is still in the requests_queued list while the request_is_queued is already set to false, which would cause use-after-free if the v4l2_ctrl_handler is later released.
Fix this by locking the ->lock of main_hdl (which is the owner of the requests_queued list) when doing list operations on the ->requests_queued list.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +7 -0
@@ -3144,6 +3144,7 @@ static void v4l2_ctrl_request_queue(struct media_request_object *obj)struct v4l2_ctrl_handler *prev_hdl =NULL ;struct v4l2_ctrl_ref *ref_ctrl, *ref_ctrl_prev =NULL ; +mutex_lock (main_hdl->lock);if (list_empty (&main_hdl->requests_queued)) goto queue;
@@ -3175,18 +3176,22 @@ static void v4l2_ctrl_request_queue(struct media_request_object *obj) queue:list_add_tail (&hdl->requests_queued, &main_hdl->requests_queued); hdl->request_is_queued = true; +mutex_unlock (main_hdl->lock); }static void v4l2_ctrl_request_unbind (struct media_request_object *obj) {struct v4l2_ctrl_handler *hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj); +struct v4l2_ctrl_handler *main_hdl = obj->priv;list_del_init (&hdl->requests); +mutex_lock (main_hdl->lock);if (hdl->request_is_queued) {list_del_init (&hdl->requests_queued); hdl->request_is_queued = false; } +mutex_unlock (main_hdl->lock); }static void v4l2_ctrl_request_release (struct media_request_object *obj)
@@ -4128,9 +4133,11 @@ void v4l2_ctrl_request_complete(struct media_request *req,v4l2_ctrl_unlock (ctrl); } +mutex_lock (main_hdl->lock);WARN_ON (!hdl->request_is_queued);list_del_init (&hdl->requests_queued); hdl->request_is_queued = false; +mutex_unlock (main_hdl->lock);media_request_object_complete (obj);media_request_object_put (obj); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 260/350 iio: cros_ec_baro: set info_mask_shared_by_all_available field
In reply to Sasha LevinFrom: Gwendal Grignou <[email protected]>
[ Upstream commit e9a4cbcaaa391ef44d623d548ee715e77265030c ]
Field was already set for light/proximity and
accelerometer/gyroscope/magnetometer sensors.
--- drivers/iio/pressure/cros_ec_baro.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/pressure/cros_ec_baro.c +3 -0
@@ -114,6 +114,7 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev,static const struct iio_info cros_ec_baro_info = { .read_raw = &cros_ec_baro_read, .write_raw = &cros_ec_baro_write, + .read_avail = &cros_ec_sensors_core_read_avail, };static int cros_ec_baro_probe (struct platform_device *pdev)
@@ -149,6 +150,8 @@ static int cros_ec_baro_probe(struct platform_device *pdev)BIT (IIO_CHAN_INFO_SCALE ) |BIT (IIO_CHAN_INFO_SAMP_FREQ ) |BIT (IIO_CHAN_INFO_FREQUENCY ); + channel->info_mask_shared_by_all_available = +BIT (IIO_CHAN_INFO_SAMP_FREQ ); channel->scan_type.realbits =CROS_EC_SENSOR_BITS ; channel->scan_type.storagebits =CROS_EC_SENSOR_BITS ; channel->scan_type.shift =0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 261/350 EDAC/ghes: Fix grain calculation
In reply to Sasha LevinFrom: Robert Richter <[email protected]>
[ Upstream commit 7088e29e0423d3195e09079b4f849ec4837e5a75 ]
The current code to convert a physical address mask to a grain (defined as granularity in bytes) is:
e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
This is broken in several ways:
1) It calculates to wrong grain values. E.g., a physical address mask of ~0xfff should give a grain of 0x1000. Without considering PAGE_MASK, there is an off-by-one. Things are worse when also filtering it with ~PAGE_MASK. This will calculate to a grain with the upper bits set. In the example it even calculates to ~0.
2) The grain does not depend on and is unrelated to the kernel's page-size. The page-size only matters when unmapping memory in memory_failure(). Smaller grains are wrongly rounded up to the page-size, on architectures with a configurable page-size (e.g. arm64) this could round up to the even bigger page-size of the hypervisor.
Fix this with:
e->grain = ~mem_err->physical_addr_mask + 1;
The grain_bits are defined as:
grain = 1 << grain_bits;
Change also the grain_bits calculation accordingly, it is the same formula as in edac_mc.c now and the code can be unified.
The value in ->physical_addr_mask coming from firmware is assumed to be contiguous, but this is not sanity-checked. However, in case the mask is non-contiguous, a conversion to grain_bits effectively converts the grain bit mask to a power of 2 by rounding it up.
--- drivers/edac/ghes_edac.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/edac/ghes_edac.c +8 -2
@@ -231,6 +231,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)/* Cleans the error report buffer */ memset (e,0 ,sizeof (*e)); e->error_count =1 ; + e->grain =1 ;strcpy (e->label,"unknown label" ); e->msg = pvt->msg; e->other_detail = pvt->other_detail;
@@ -326,7 +327,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)/* Error grain */ if (mem_err->validation_bits &CPER_MEM_VALID_PA_MASK ) - e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); + e->grain = ~mem_err->physical_addr_mask +1 ;/* Memory error location, mapped on e->location */ p = e->location;
@@ -442,8 +443,13 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)if (p > pvt->other_detail) *(p -1 ) ='\0' ; +/* Sanity-check driver-supplied grain value. */ +if (WARN_ON_ONCE (!e->grain)) + e->grain =1 ; + + grain_bits =fls_long (e->grain -1 ); +/* Generate the trace event */ - grain_bits =fls_long (e->grain);snprintf (pvt->detail_location,sizeof (pvt->detail_location),"APEI location: %s %s" , e->location, e->other_detail); trace_mc_event(type, e->msg, e->label, e->error_count,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 262/350 media: vicodec: media_device_cleanup was called too early
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 693c5f144aeb9636ae161a3c61a838c50b2ae41c ]
Running the contrib/test/test-media script in v4l-utils with the vicodec argument will cause this kernel warning:
[ 372.298824] ------------[ cut here ]------------ [ 372.298848] DEBUG_LOCKS_WARN_ON(lock->magic != lock) [ 372.298896] WARNING: CPU: 11 PID: 2220 at kernel/locking/mutex.c:938 __mutex_lock+0x919/0xc10 [ 372.298907] Modules linked in: vicodec v4l2_mem2mem vivid rc_cec v4l2_tpg videobuf2_dma_contig cec rc_core v4l2_dv_timings videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc vmw_balloon vmw_vmci button vmwgfx [last unloaded: vimc] [ 372.298961] CPU: 11 PID: 2220 Comm: sleep Not tainted 5.4.0-rc1-test-no #150 [ 372.298970] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/29/2019 [ 372.298983] RIP: 0010:__mutex_lock+0x919/0xc10 [ 372.298995] Code: 59 83 e8 9a fc 16 ff 44 8b 05 23 61 38 01 45 85 c0 0f 85 ef f7 ff ff 48 c7 c6 a0 1f 87 82 48 c7 c7 a0 1e 87 82 e8 cd bb f7 fe <0f> 0b e9 d5 f7 ff ff f6 c3 04 0f 84 3b fd ff ff 49 89 df 41 83 e7 [ 372.299004] RSP: 0018:ffff8881b400fb80 EFLAGS: 00010286 [ 372.299014] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 372.299022] RDX: 0000000000000003 RSI: 0000000000000004 RDI: ffffed1036801f62 [ 372.299030] RBP: ffff8881b400fcf0 R08: ffffffff81217c91 R09: fffffbfff061c271 [ 372.299038] R10: fffffbfff061c270 R11: ffffffff830e1383 R12: ffff88814761dc80 [ 372.299046] R13: 0000000000000000 R14: ffff88814761cbf0 R15: ffff88814761d030 [ 372.299055] FS: 0000000000000000(0000) GS:ffff8881b68c0000(0000) knlGS:0000000000000000 [ 372.299063] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 372.299071] CR2: 00007f606d78aa20 CR3: 0000000003013002 CR4: 00000000001606e0 [ 372.299153] Call Trace: [ 372.299176] ? __kasan_slab_free+0x12f/0x180 [ 372.299187] ? kmem_cache_free+0x9b/0x250 [ 372.299200] ? do_exit+0xcdf/0x1200 [ 372.299210] ? do_group_exit+0x85/0x130 [ 372.299220] ? __x64_sys_exit_group+0x23/0x30 [ 372.299231] ? do_syscall_64+0x5e/0x1c0 [ 372.299241] ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 372.299295] ? v4l2_release+0xed/0x190 [videodev] [ 372.299309] ? mutex_lock_io_nested+0xb80/0xb80 [ 372.299323] ? find_held_lock+0x85/0xa0 [ 372.299335] ? fsnotify+0x5b0/0x600 [ 372.299351] ? locks_remove_file+0x78/0x2b0 [ 372.299363] ? __fsnotify_update_child_dentry_flags.part.0+0x170/0x170 [ 372.299383] ? vidioc_querycap+0x50/0x50 [vicodec] [ 372.299426] ? v4l2_release+0xed/0x190 [videodev] [ 372.299467] v4l2_release+0xed/0x190 [videodev] [ 372.299484] __fput+0x15a/0x390 [ 372.299499] task_work_run+0xb2/0xe0 [ 372.299512] do_exit+0x4d0/0x1200 [ 372.299528] ? do_user_addr_fault+0x367/0x610 [ 372.299538] ? release_task+0x990/0x990 [ 372.299552] ? rwsem_spin_on_owner+0x170/0x170 [ 372.299567] ? vmacache_find+0xb2/0x100 [ 372.299580] do_group_exit+0x85/0x130 [ 372.299592] __x64_sys_exit_group+0x23/0x30 [ 372.299602] do_syscall_64+0x5e/0x1c0 [ 372.299614] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 372.299624] RIP: 0033:0x7f606d74a9d6 [ 372.299640] Code: Bad RIP value. [ 372.299648] RSP: 002b:00007fff65364468 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 [ 372.299658] RAX: ffffffffffffffda RBX: 00007f606d83b760 RCX: 00007f606d74a9d6 [ 372.299666] RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000 [ 372.299673] RBP: 0000000000000000 R08: 00000000000000e7 R09: ffffffffffffff80 [ 372.299681] R10: 00007fff65364334 R11: 0000000000000246 R12: 00007f606d83b760 [ 372.299689] R13: 0000000000000002 R14: 00007f606d844428 R15: 0000000000000000 [ 372.299704] ---[ end trace add7d62ca4bc65e3 ]---
This is caused by media_device_cleanup() which destroys v4l2_dev->mdev->req_queue_mutex. But v4l2_release() tries to lock that mutex after media_device_cleanup() is called.
By moving media_device_cleanup() to the v4l2_device's release function it is guaranteed that the mutex is valid whenever v4l2_release is called.
--- drivers/media/platform/vicodec/vicodec-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/vicodec/vicodec-core.c +3 -1
@@ -2139,6 +2139,9 @@ static void vicodec_v4l2_dev_release(struct v4l2_device *v4l2_dev)v4l2_m2m_release (dev->stateful_enc.m2m_dev);v4l2_m2m_release (dev->stateful_dec.m2m_dev);v4l2_m2m_release (dev->stateless_dec.m2m_dev); +#ifdef CONFIG_MEDIA_CONTROLLER +media_device_cleanup (&dev->mdev); +#endif kfree (dev); }
@@ -2250,7 +2253,6 @@ static int vicodec_remove(struct platform_device *pdev)v4l2_m2m_unregister_media_controller (dev->stateful_enc.m2m_dev);v4l2_m2m_unregister_media_controller (dev->stateful_dec.m2m_dev);v4l2_m2m_unregister_media_controller (dev->stateless_dec.m2m_dev); -media_device_cleanup (&dev->mdev);#endif video_unregister_device (&dev->stateful_enc.vfd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 263/350 media: vim2m: media_device_cleanup was called too early
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 9f22e88a4bba270d3427684cee84dfbf67489e86 ]
Running the contrib/test/test-media script in v4l-utils with the vim2m argument will cause this kernel warning:
[ 554.430157] ------------[ cut here ]------------ [ 554.433034] DEBUG_LOCKS_WARN_ON(lock->magic != lock) [ 554.433064] WARNING: CPU: 0 PID: 616 at kernel/locking/mutex.c:938 __mutex_lock+0xd7a/0x1380 [ 554.439736] Modules linked in: vim2m v4l2_mem2mem vivid rc_cec videobuf2_dma_contig v4l2_dv_timings cec videobuf2_vmalloc videobuf2_memops v4l2_tpg videobuf2_v4l2 videobuf2_common videodev mc rc_core [last unloaded: vivid] [ 554.445794] CPU: 0 PID: 616 Comm: sleep Not tainted 5.4.0-rc1-virtme #1 [ 554.448481] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014 [ 554.453088] RIP: 0010:__mutex_lock+0xd7a/0x1380 [ 554.454955] Code: d2 0f 85 de 05 00 00 44 8b 05 82 d9 f7 00 45 85 c0 0f 85 bf f3 ff ff 48 c7 c6 e0 30 a6 b7 48 c7 c7 e0 2e a6 b7 e8 5c 76 36 fe <0f> 0b e9 a5 f3 ff ff 65 48 8b 1c 25 80 ef 01 00 be 08 00 00 00 48 [ 554.462836] RSP: 0018:ffff88803a4cfad0 EFLAGS: 00010282 [ 554.465129] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffffb5a3d24f [ 554.468143] RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffffb85273f4 [ 554.471000] RBP: ffff88803a4cfc50 R08: fffffbfff701e681 R09: fffffbfff701e681 [ 554.473990] R10: fffffbfff701e680 R11: ffffffffb80f3403 R12: 0000000000000000 [ 554.476831] R13: dffffc0000000000 R14: ffffffffb9714f00 R15: ffff888053103fc8 [ 554.479622] FS: 00007fac6358a540(0000) GS:ffff88805d000000(0000) knlGS:0000000000000000 [ 554.482673] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 554.484949] CR2: 00007fac6343faf0 CR3: 0000000036c22000 CR4: 00000000003406f0 [ 554.487811] Call Trace: [ 554.488860] ? v4l2_release+0x1b8/0x390 [videodev] [ 554.490818] ? do_exit+0x946/0x2980 [ 554.492269] ? mutex_lock_io_nested+0x1250/0x1250 [ 554.494128] ? __lock_acquire+0xe90/0x3c30 [ 554.495774] ? fsnotify_first_mark+0x120/0x120 [ 554.497487] ? vim2m_device_release+0x50/0x50 [vim2m] [ 554.499469] ? v4l2_release+0x1b8/0x390 [videodev] [ 554.501493] v4l2_release+0x1b8/0x390 [videodev] [ 554.503430] __fput+0x256/0x790 [ 554.504711] task_work_run+0x109/0x190 [ 554.506145] do_exit+0x95e/0x2980 [ 554.507421] ? vfs_lock_file+0x21/0xf0 [ 554.509013] ? find_held_lock+0x33/0x1c0 [ 554.510382] ? __close_fd+0xee/0x190 [ 554.511862] ? release_task.part.21+0x1310/0x1310 [ 554.513701] ? lock_downgrade+0x6d0/0x6d0 [ 554.515299] do_group_exit+0xeb/0x2d0 [ 554.516862] __x64_sys_exit_group+0x35/0x40 [ 554.518610] do_syscall_64+0x90/0x450 [ 554.520142] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 554.522289] RIP: 0033:0x7fac6348ecf6 [ 554.523876] Code: Bad RIP value. [ 554.525294] RSP: 002b:00007ffe6373dc58 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 [ 554.528555] RAX: ffffffffffffffda RBX: 00007fac6357f760 RCX: 00007fac6348ecf6 [ 554.531537] RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000 [ 554.534709] RBP: 0000000000000000 R08: 00000000000000e7 R09: ffffffffffffff80 [ 554.536752] R10: 00007ffe6373db24 R11: 0000000000000246 R12: 00007fac6357f760 [ 554.538643] R13: 0000000000000002 R14: 00007fac63588428 R15: 0000000000000000 [ 554.540634] irq event stamp: 21731 [ 554.541618] hardirqs last enabled at (21731): [<ffffffffb75b3cd4>] _raw_spin_unlock_irq+0x24/0x30 [ 554.544145] hardirqs last disabled at (21730): [<ffffffffb75b3ada>] _raw_spin_lock_irq+0xa/0x40 [ 554.547027] softirqs last enabled at (20148): [<ffffffffb780064d>] __do_softirq+0x64d/0x906 [ 554.550385] softirqs last disabled at (19857): [<ffffffffb5926bd5>] irq_exit+0x175/0x1a0 [ 554.553668] ---[ end trace a389c80c2ca84244 ]---
This is caused by media_device_cleanup() which destroys v4l2_dev->mdev->req_queue_mutex. But v4l2_release() tries to lock that mutex after media_device_cleanup() is called.
By moving media_device_cleanup() to the video_device's release function it is guaranteed that the mutex is valid whenever v4l2_release is called.
--- drivers/media/platform/vim2m.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/vim2m.c +3 -1
@@ -1275,6 +1275,9 @@ static void vim2m_device_release(struct video_device *vdev)v4l2_device_unregister (&dev->v4l2_dev);v4l2_m2m_release (dev->m2m_dev); +#ifdef CONFIG_MEDIA_CONTROLLER +media_device_cleanup (&dev->mdev); +#endif kfree (dev); }
@@ -1399,7 +1402,6 @@ static int vim2m_remove(struct platform_device *pdev)#ifdef CONFIG_MEDIA_CONTROLLER media_device_unregister (&dev->mdev);v4l2_m2m_unregister_media_controller (dev->m2m_dev); -media_device_cleanup (&dev->mdev);#endif video_unregister_device (&dev->vfd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 264/350 spi: pxa2xx: Add missed security checks
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 5eb263ef08b5014cfc2539a838f39d2fd3531423 ]
pxa2xx_spi_init_pdata misses checks for devm_clk_get and platform_get_irq.
Add checks for them to fix the bugs.
Since ssp->clk and ssp->irq are used in probe, they are mandatory here. So we cannot use _optional() for devm_clk_get and platform_get_irq.
--- drivers/spi/spi-pxa2xx.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-pxa2xx.c +6 -0
@@ -1565,7 +1565,13 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)#endif ssp->clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (ssp->clk)) +return NULL ; + ssp->irq =platform_get_irq (pdev,0 ); +if (ssp->irq <0 ) +return NULL ; + ssp->type = type; ssp->pdev = pdev; ssp->port_id =pxa2xx_spi_get_port_id (adev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 265/350 ASoC: rt5677: Mark reg RT5677_PWR_ANLG2 as volatile
In reply to Sasha LevinFrom: Ben Zhang <[email protected]>
[ Upstream commit eabf424f7b60246c76dcb0ea6f1e83ef9abbeaa6 ]
The codec dies when RT5677_PWR_ANLG2(MX-64h) is set to 0xACE1 while it's streaming audio over SPI. The DSP firmware turns on PLL2 (MX-64 bit 8) when SPI streaming starts. However regmap does not believe that register can change by itself. When BST1 (bit 15) is turned on with regmap_update_bits(), it doesn't read the register first before write, so PLL2 power bit is cleared by accident.
Marking MX-64h as volatile in regmap solved the issue.
--- sound/soc/codecs/rt5677.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/rt5677.c +1 -0
@@ -298,6 +298,7 @@ static bool rt5677_volatile_register(struct device *dev, unsigned int reg)case RT5677_I2C_MASTER_CTRL7 :case RT5677_I2C_MASTER_CTRL8 :case RT5677_HAP_GENE_CTRL2 : +case RT5677_PWR_ANLG2 :/* Modified by DSP firmware */ case RT5677_PWR_DSP_ST :case RT5677_PRIV_DATA :case RT5677_ASRC_22 :
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Sasha Levin
maintainerPATCH 266/350 iio: dac: ad5446: Add support for new AD5600 DAC
In reply to Sasha LevinFrom: Stefan Popa <[email protected]>
[ Upstream commit 6376cbe549fffb378403cee78efd26b8a2c8e450 ]
The AD5600 is a single channel, 16-bit resolution, voltage output digital to analog converter (DAC). The AD5600 uses a 3-wire SPI interface. It is part of the AD5541 family of DACs.
The ad5446 IIO driver implements support for some of these DACs (in the AD5441 family), so the change is a simple entry in this driver.
--- drivers/iio/dac/Kconfig | 4 ++-- drivers/iio/dac/ad5446.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/iio/dac/Kconfig +2 -2
@@ -60,8 +60,8 @@ config AD5446 help Say yes here to build support for Analog Devices AD5300, AD5301, AD5310, AD5311, AD5320, AD5321, AD5444, AD5446, AD5450, AD5451, AD5452, AD5453, - AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5602, AD5611, AD5612, - AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs + AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5600, AD5601, AD5602, AD5611, + AD5612, AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs as well as Texas Instruments DAC081S101, DAC101S101, DAC121S101. To compile this driver as a module, choose M here: the
drivers/iio/dac/ad5446.c +6 -0
@@ -327,6 +327,7 @@ enum ad5446_supported_spi_device_ids {ID_AD5541A ,ID_AD5512A ,ID_AD5553 , +ID_AD5600 ,ID_AD5601 ,ID_AD5611 , ID_AD5621,
@@ -381,6 +382,10 @@ static const struct ad5446_chip_info ad5446_spi_chip_info[] = { .channel = AD5446_CHANNEL(14, 16, 0), .write = ad5446_write, }, + [ID_AD5600] = { + .channel = AD5446_CHANNEL(16, 16, 0), + .write = ad5446_write, + }, [ID_AD5601] = { .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 6), .write = ad5446_write,
@@ -448,6 +453,7 @@ static const struct spi_device_id ad5446_spi_ids[] = { {"ad5542a", ID_AD5541A}, /* ad5541a and ad5542a are compatible */ {"ad5543", ID_AD5541A}, /* ad5541a and ad5543 are compatible */ {"ad5553", ID_AD5553}, + {"ad5600", ID_AD5600}, {"ad5601", ID_AD5601}, {"ad5611", ID_AD5611}, {"ad5621", ID_AD5621},
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 267/350 bpf, testing: Workaround a verifier failure for test_progs
In reply to Sasha LevinFrom: Yonghong Song <[email protected]>
[ Upstream commit b7a0d65d80a0c5034b366392624397a0915b7556 ]
With latest llvm compiler, running test_progs will have the following verifier failure for test_sysctl_loop1.o:
libbpf: load bpf program failed: Permission denied
libbpf: -- BEGIN DUMP LOG ---
libbpf:
invalid indirect read from stack var_off (0x0; 0xff)+196 size 7
...
libbpf: -- END LOG --
libbpf: failed to load program 'cgroup/sysctl'
libbpf: failed to load object 'test_sysctl_loop1.o'
The related bytecode looks as below:
0000000000000308 LBB0_8:
97: r4 = r10
98: r4 += -288
99: r4 += r7
100: w8 &= 255
101: r1 = r10
102: r1 += -488
103: r1 += r8
104: r2 = 7
105: r3 = 0
106: call 106
107: w1 = w0
108: w1 += -1
109: if w1 > 6 goto -24 <LBB0_5>
110: w0 += w8
111: r7 += 8
112: w8 = w0
113: if r7 != 224 goto -17 <LBB0_8>And source code:
for (i = 0; i < ARRAY_SIZE(tcp_mem); ++i) {
ret = bpf_strtoul(value + off, MAX_ULONG_STR_LEN, 0,
tcp_mem + i);
if (ret <= 0 || ret > MAX_ULONG_STR_LEN)
return 0;
off += ret & MAX_ULONG_STR_LEN;
}Current verifier is not able to conclude that register w0 before '+' at insn 110 has a range of 1 to 7 and thinks it is from 0 - 255. This leads to more conservative range for w8 at insn 112, and later verifier complaint.
Let us workaround this issue until we found a compiler and/or verifier solution. The workaround in this patch is to make variable 'ret' volatile, which will force a reload and then '&' operation to ensure better value range. With this patch, I got the below byte code for the loop:
0000000000000328 LBB0_9:
101: r4 = r10
102: r4 += -288
103: r4 += r7
104: w8 &= 255
105: r1 = r10
106: r1 += -488
107: r1 += r8
108: r2 = 7
109: r3 = 0
110: call 106
111: *(u32 *)(r10 - 64) = r0
112: r1 = *(u32 *)(r10 - 64)
113: if w1 s< 1 goto -28 <LBB0_5>
114: r1 = *(u32 *)(r10 - 64)
115: if w1 s> 7 goto -30 <LBB0_5>
116: r1 = *(u32 *)(r10 - 64)
117: w1 &= 7
118: w1 += w8
119: r7 += 8
120: w8 = w1
121: if r7 != 224 goto -21 <LBB0_9>Insn 117 did the '&' operation and we got more precise value range for 'w8' at insn 120. The test is happy then:
#3/17 test_sysctl_loop1.o:OK
--- tools/testing/selftests/bpf/progs/test_sysctl_loop1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/test_sysctl_loop1.c +4 -1
@@ -44,7 +44,10 @@ int sysctl_tcp_mem(struct bpf_sysctl *ctx)unsigned long tcp_mem[TCP_MEM_LOOPS ] = {};char value[MAX_VALUE_STR_LEN ];unsigned char i, off =0 ; -int ret; +/* a workaround to prevent compiler from generating +* codes verifier cannot handle yet. +*/ +volatile int ret;if (ctx->write)return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 268/350 iio: adis16480: Fix scales factors
In reply to Sasha LevinFrom: Nuno Sá <[email protected]>
[ Upstream commit 49549cb23a2926eba70bb634e361daea0f319794 ]
This patch fixes the scales for the gyroscope, accelerometer and barometer. The pressure scale was just wrong. For the others, the scale factors were not taking into account that a 32bit word is being read from the device.
--- drivers/iio/imu/adis16480.c | 77 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 36 deletions(-)
drivers/iio/imu/adis16480.c +41 -36
@@ -623,9 +623,13 @@ static int adis16480_read_raw(struct iio_dev *indio_dev, *val2 = (st->chip_info->temp_scale %1000 ) *1000 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_PRESSURE : - *val =0 ; - *val2 =4000 ;/* 40ubar = 0.004 kPa */ -return IIO_VAL_INT_PLUS_MICRO ; +/* +* max scale is 1310 mbar +* max raw value is 32767 shifted for 32bits +*/ + *val =131 ;/* 1310mbar = 131 kPa */ + *val2 =32767 <<16 ; +return IIO_VAL_FRACTIONAL ;default :return -EINVAL ; }
@@ -786,13 +790,14 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels),/* -* storing the value in rad/degree and the scale in degree -* gives us the result in rad and better precession than -* storing the scale directly in rad. +* Typically we do IIO_RAD_TO_DEGREE in the denominator, which +* is exactly the same as IIO_DEGREE_TO_RAD in numerator, since +* it gives better approximation. However, in this case we +* cannot do it since it would not fit in a 32bit variable. */ - .gyro_max_val = IIO_RAD_TO_DEGREE(22887), - .gyro_max_scale = 300, - .accel_max_val = IIO_M_S_2_TO_G(21973), + .gyro_max_val = 22887 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(300), + .accel_max_val = IIO_M_S_2_TO_G(21973 << 16), .accel_max_scale = 18, .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000,
@@ -802,9 +807,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16480] = { .channels = adis16480_channels, .num_channels = ARRAY_SIZE(adis16480_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(22500), - .gyro_max_scale = 450, - .accel_max_val = IIO_M_S_2_TO_G(12500), + .gyro_max_val = 22500 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(450), + .accel_max_val = IIO_M_S_2_TO_G(12500 << 16), .accel_max_scale = 10, .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000,
@@ -814,9 +819,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16485] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(22500), - .gyro_max_scale = 450, - .accel_max_val = IIO_M_S_2_TO_G(20000), + .gyro_max_val = 22500 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(450), + .accel_max_val = IIO_M_S_2_TO_G(20000 << 16), .accel_max_scale = 5, .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000,
@@ -826,9 +831,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16488] = { .channels = adis16480_channels, .num_channels = ARRAY_SIZE(adis16480_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(22500), - .gyro_max_scale = 450, - .accel_max_val = IIO_M_S_2_TO_G(22500), + .gyro_max_val = 22500 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(450), + .accel_max_val = IIO_M_S_2_TO_G(22500 << 16), .accel_max_scale = 18, .temp_scale = 5650, /* 5.65 milli degree Celsius */ .int_clk = 2460000,
@@ -838,9 +843,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16495_1] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(20000), - .gyro_max_scale = 125, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 20000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(125), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 8, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
@@ -851,9 +856,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16495_2] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(18000), - .gyro_max_scale = 450, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 18000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(450), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 8, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
@@ -864,9 +869,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16495_3] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(20000), - .gyro_max_scale = 2000, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 20000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(2000), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 8, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
@@ -877,9 +882,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16497_1] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(20000), - .gyro_max_scale = 125, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 20000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(125), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 40, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
@@ -890,9 +895,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16497_2] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(18000), - .gyro_max_scale = 450, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 18000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(450), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 40, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
@@ -903,9 +908,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = { [ADIS16497_3] = { .channels = adis16485_channels, .num_channels = ARRAY_SIZE(adis16485_channels), - .gyro_max_val = IIO_RAD_TO_DEGREE(20000), - .gyro_max_scale = 2000, - .accel_max_val = IIO_M_S_2_TO_G(32000), + .gyro_max_val = 20000 << 16, + .gyro_max_scale = IIO_DEGREE_TO_RAD(2000), + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16), .accel_max_scale = 40, .temp_scale = 12500, /* 12.5 milli degree Celsius */ .int_clk = 4250000,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 269/350 ASoC: Intel: kbl_rt5663_rt5514_max98927: Add dmic format constraint
In reply to Sasha LevinFrom: Yu-Hsuan Hsu <[email protected]>
[ Upstream commit e2db787bdcb4f2722ecf410168f0583764634e45 ]
On KBL platform, the microphone is attached to external codec(rt5514) instead of PCH. However, TDM slot between PCH and codec is 16 bits only. In order to avoid setting wrong format, we should add a constraint to force to use 16 bits format forever.
--- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +3 -0
@@ -400,6 +400,9 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_CHANNELS , dmic_constraints); + runtime->hw.formats =SNDRV_PCM_FMTBIT_S16_LE ; +snd_pcm_hw_constraint_msbits (runtime,0 ,16 ,16 ); +return snd_pcm_hw_constraint_list (substream->runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , &constraints_rates); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 270/350 net: dsa: sja1105: Disallow management xmit during switch reset
In reply to Sasha LevinFrom: Vladimir Oltean <[email protected]>
[ Upstream commit af580ae2dcb250719857b4b7024bd4bb0c2e05fb ]
The purpose here is to avoid ptp4l fail due to this condition:
timed out while polling for tx timestamp
increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug port 1: send peer delay request failed
So either reset the switch before the management frame was sent, or after it was timestamped as well, but not in the middle.
The condition may arise either due to a true timeout (i.e. because re-uploading the static config takes time), or due to the TX timestamp actually getting lost due to reset. For the former we can increase tx_timestamp_timeout in userspace, for the latter we need this patch.
Locking all traffic during switch reset does not make sense at all, though. Forcing all CPU-originated traffic to potentially block waiting for a sleepable context to send > 800 bytes over SPI is not a good idea. Flows that are autonomously forwarded by the switch will get dropped anyway during switch reset no matter what. So just let all other CPU-originated traffic be dropped as well.
--- drivers/net/dsa/sja1105/sja1105_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/dsa/sja1105/sja1105_main.c +4 -0
@@ -1389,6 +1389,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv)int speed_mbps[SJA1105_NUM_PORTS ];int rc, i; +mutex_lock (&priv->mgmt_lock); + mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG ].entries;/* Back up the dynamic link speed changed by sja1105_adjust_port_config
@@ -1420,6 +1422,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv) goto out; } out: +mutex_unlock (&priv->mgmt_lock); +return rc; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 271/350 r8169: respect EEE user setting when restarting network
In reply to Sasha LevinFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 7ec3f872bc85ada93db34448d73bb399d6b82c2c ]
Currently, if network is re-started, we advertise all supported EEE modes, thus potentially overriding a manual adjustment the user made e.g. via ethtool. Be friendly to the user and preserve a manual setting on network re-start.
--- drivers/net/ethernet/realtek/r8169_main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +15 -3
@@ -680,6 +680,7 @@ struct rtl8169_private {struct rtl8169_counters *counters;struct rtl8169_tc_offsets tc_offset;u32 saved_wolopts; +int eee_adv;const char *fw_name;struct rtl_fw *rtl_fw;
@@ -2075,6 +2076,10 @@ static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data) } ret =phy_ethtool_set_eee (tp->phydev, data); + +if (!ret) + tp->eee_adv =phy_read_mmd (dev->phydev,MDIO_MMD_AN , +MDIO_AN_EEE_ADV ); out:pm_runtime_put_noidle (d);return ret;
@@ -2105,10 +2110,16 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {static void rtl_enable_eee (struct rtl8169_private *tp) {struct phy_device *phydev = tp->phydev; -int supported =phy_read_mmd (phydev,MDIO_MMD_PCS ,MDIO_PCS_EEE_ABLE ); +int adv; + +/* respect EEE advertisement the user may have set */ +if (tp->eee_adv >=0 ) + adv = tp->eee_adv; +else + adv =phy_read_mmd (phydev,MDIO_MMD_PCS ,MDIO_PCS_EEE_ABLE ); -if (supported >0 ) -phy_write_mmd (phydev,MDIO_MMD_AN ,MDIO_AN_EEE_ADV , supported); +if (adv >=0 ) +phy_write_mmd (phydev,MDIO_MMD_AN ,MDIO_AN_EEE_ADV , adv); }static void rtl8169_get_mac_version (struct rtl8169_private *tp)
@@ -7064,6 +7075,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->pci_dev = pdev; tp->msg_enable =netif_msg_init (debug.msg_enable,R8169_MSG_DEFAULT ); tp->supports_gmii = ent->driver_data ==RTL_CFG_NO_GBIT ?0 :1 ; + tp->eee_adv =-1 ;/* Get the *optional* external "ether_clk" used on some boards */ rc =rtl_get_ether_clk (tp);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 272/350 s390/disassembler: don't hide instruction addresses
In reply to Sasha LevinFrom: Ilya Leoshkevich <[email protected]>
[ Upstream commit 544f1d62e3e6c6e6d17a5e56f6139208acb5ff46 ]
Due to kptr_restrict, JITted BPF code is now displayed like this:
000000000b6ed1b2: ebdff0800024 stmg %r13,%r15,128(%r15) 000000004cde2ba0: 41d0f040 la %r13,64(%r15) 00000000fbad41b0: a7fbffa0 aghi %r15,-96
Leaking kernel addresses to dmesg is not a concern in this case, because this happens only when JIT debugging is explicitly activated, which only root can do.
Use %px in this particular instance, and also to print an instruction address in show_code and PCREL (e.g. brasl) arguments in print_insn. While at present functionally equivalent to %016lx, %px is recommended by Documentation/core-api/printk-formats.rst for such cases.
--- arch/s390/kernel/dis.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/s390/kernel/dis.c +7 -6
@@ -461,10 +461,11 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr) ptr +=sprintf (ptr,"%%c%i" , value); else if (operand->flags & OPERAND_VR) ptr += sprintf(ptr, "%%v%i", value); - else if (operand->flags & OPERAND_PCREL) - ptr += sprintf(ptr, "%lx", (signed int) value - + addr); - else if (operand->flags & OPERAND_SIGNED) + else if (operand->flags & OPERAND_PCREL) { +void *pcrel = (void *)((int )value + addr); + + ptr +=sprintf (ptr,"%px" , pcrel); + } else if (operand->flags & OPERAND_SIGNED) ptr += sprintf(ptr, "%i", value); else ptr += sprintf(ptr, "%u", value);
@@ -536,7 +537,7 @@ void show_code(struct pt_regs *regs)else *ptr++ =' ' ; addr = regs->psw.addr + start -32 ; - ptr +=sprintf (ptr,"%016lx: " , addr); + ptr +=sprintf (ptr,"%px: " , (void *)addr);if (start + opsize >= end)break ;for (i =0 ; i < opsize; i++)
@@ -564,7 +565,7 @@ void print_fn_code(unsigned char *code, unsigned long len) opsize =insn_length (*code);if (opsize > len)break ; - ptr +=sprintf (ptr,"%p: " , code); + ptr +=sprintf (ptr,"%px: " , code);for (i =0 ; i < opsize; i++) ptr +=sprintf (ptr,"%02x" , code[i]); *ptr++ ='\t' ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 273/350 mailbox: tegra: Fix superfluous IRQ error message
In reply to Sasha LevinFrom: Jon Hunter <[email protected]>
[ Upstream commit c745da8d4320c49e54662c0a8f7cb6b8204f44c4 ]
Commit 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()") added an error message to avoid drivers having to print an error message when IRQ lookup fails. However, there are some cases where IRQs are optional and so new optional versions of the platform_get_irq*() APIs have been added for these cases.
The IRQs for Tegra HSP module are optional because not all instances of the module have the doorbell and all of the shared interrupts. Hence, since the above commit was applied the following error messages are now seen on Tegra194 ...
ERR KERN tegra-hsp c150000.hsp: IRQ doorbell not found ERR KERN tegra-hsp c150000.hsp: IRQ shared0 not found
The Tegra HSP driver deliberately does not fail if these are not found and so fix the above errors by updating the Tegra HSP driver to use the platform_get_irq_byname_optional() API.
--- drivers/mailbox/tegra-hsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/tegra-hsp.c +2 -2
@@ -657,7 +657,7 @@ static int tegra_hsp_probe(struct platform_device *pdev) hsp->num_db = (value >> HSP_nDB_SHIFT) & HSP_nINT_MASK; hsp->num_si = (value >> HSP_nSI_SHIFT) & HSP_nINT_MASK; - err =platform_get_irq_byname (pdev,"doorbell" ); + err =platform_get_irq_byname_optional (pdev,"doorbell" );if (err >=0 ) hsp->doorbell_irq = err;
@@ -677,7 +677,7 @@ static int tegra_hsp_probe(struct platform_device *pdev)if (!name)return -ENOMEM ; - err =platform_get_irq_byname (pdev, name); + err =platform_get_irq_byname_optional (pdev, name);if (err >=0 ) { hsp->shared_irqs[i] = err; count++;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 274/350 net: ethernet: ti: Add dependency for TI_DAVINCI_EMAC
In reply to Sasha LevinFrom: Mao Wenan <[email protected]>
[ Upstream commit b2ef81dcdf3835bd55e5f97ff30131bb327be7fa ]
If TI_DAVINCI_EMAC=y and GENERIC_ALLOCATOR is not set,
below erros can be seen:drivers/net/ethernet/ti/davinci_cpdma.o: In function `cpdma_desc_pool_destroy.isra.14':
davinci_cpdma.c:(.text+0x359): undefined reference to gen_pool_size' davinci_cpdma.c:(.text+0x365): undefined reference to gen_pool_avail' davinci_cpdma.c:(.text+0x373): undefined reference to gen_pool_avail' davinci_cpdma.c:(.text+0x37f): undefined reference to gen_pool_size' drivers/net/ethernet/ti/davinci_cpdma.o: In function `__cpdma_chan_free':
davinci_cpdma.c:(.text+0x4a2): undefined reference to gen_pool_free_owner' drivers/net/ethernet/ti/davinci_cpdma.o: In function cpdma_chan_submit_si':
davinci_cpdma.c:(.text+0x66c): undefined reference to gen_pool_alloc_algo_owner' davinci_cpdma.c:(.text+0x805): undefined reference to gen_pool_free_owner' drivers/net/ethernet/ti/davinci_cpdma.o: In function `cpdma_ctlr_create':
davinci_cpdma.c:(.text+0xabd): undefined reference to devm_gen_pool_create' davinci_cpdma.c:(.text+0xb79): undefined reference to gen_pool_add_owner' drivers/net/ethernet/ti/davinci_cpdma.o: In function `cpdma_check_free_tx_desc':
davinci_cpdma.c:(.text+0x16c6): undefined reference to `gen_pool_avail'
This patch mades TI_DAVINCI_EMAC select GENERIC_ALLOCATOR.
--- drivers/net/ethernet/ti/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/Kconfig +1 -0
@@ -22,6 +22,7 @@ config TI_DAVINCI_EMAC depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 ) || COMPILE_TEST select TI_DAVINCI_MDIO select PHYLIB + select GENERIC_ALLOCATOR ---help--- This driver supports TI's DaVinci Ethernet .
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 275/350 nvme: Discard workaround for non-conformant devices
In reply to Sasha LevinFrom: Eduard Hasenleithner <[email protected]>
[ Upstream commit 530436c45ef2e446c12538a400e465929a0b3ade ]
Users observe IOMMU related errors when performing discard on nvme from non-compliant nvme devices reading beyond the end of the DMA mapped ranges to discard.
Two different variants of this behavior have been observed: SM22XX controllers round up the read size to a multiple of 512 bytes, and Phison E12 unconditionally reads the maximum discard size allowed by the spec (256 segments or 4kB).
Make nvme_setup_discard unconditionally allocate the maximum DSM buffer so the driver DMA maps a memory range that will always succeed.
--- drivers/nvme/host/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +9 -3
@@ -611,8 +611,14 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,struct nvme_dsm_range *range;struct bio *bio; - range =kmalloc_array (segments,sizeof (*range), -GFP_ATOMIC | __GFP_NOWARN); +/* +* Some devices do not consider the DSM 'Number of Ranges' field when +* determining how much data to DMA. Always allocate memory for maximum +* number of segments to prevent device reading beyond end of buffer. +*/ +static const size_t alloc_size =sizeof (*range) *NVME_DSM_MAX_RANGES ; + + range =kzalloc (alloc_size,GFP_ATOMIC | __GFP_NOWARN);if (!range) {/* * If we fail allocation our range, fallback to the controller
@@ -652,7 +658,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, req->special_vec.bv_page =virt_to_page (range); req->special_vec.bv_offset =offset_in_page (range); - req->special_vec.bv_len =sizeof (*range) * segments; + req->special_vec.bv_len = alloc_size; req->rq_flags |=RQF_SPECIAL_PAYLOAD ;return BLK_STS_OK ;
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 276/350 net: bcmgenet: Add RGMII_RXID support
In reply to Sasha LevinFrom: Stefan Wahren <[email protected]>
[ Upstream commit da38802211cc3fd294211a642932edb09e3af632 ]
This adds the missing support for the PHY mode RGMII_RXID. It's necessary for the Raspberry Pi 4.
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmmii.c +5 -0
@@ -281,6 +281,11 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)bcmgenet_sys_writel (priv,PORT_MODE_EXT_GPHY ,SYS_PORT_CTRL );break ; + +case PHY_INTERFACE_MODE_RGMII_RXID : + phy_name ="external RGMII (RX delay)" ; + port_ctrl =PORT_MODE_EXT_GPHY ; +break ;default :dev_err (kdev,"unknown phy mode: %d\n" , priv->phy_interface);return -EINVAL ;
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.4 276/350] net: bcmgenet: Add RGMII_RXID support
Quoted 11 lines · Sasha Levin
From: Stefan Wahren <[email protected]>
[ Upstream commit
da38802211cc3fd294211a642932edb09e3af632]This adds the missing support for the PHY mode
RGMII_RXID. It's necessary for the Raspberry Pi 4.Signed-off-by Stefan Wahren <[email protected]>Acked-by Florian Fainelli <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>
There are more changes required to make the GENET controller on the Pi 4 to work, how and why this was selected? Same comment applies to the 4.19 automatic selection.
Signature · 1 line
Florian
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.4 276/350] net: bcmgenet: Add RGMII_RXID support
Quoted 8 lines · Florian Fainelli
Quoted 7 lines · Sasha Levin
From: Stefan Wahren <[email protected]>
[ Upstream commit
da38802211cc3fd294211a642932edb09e3af632]This adds the missing support for the PHY mode
RGMII_RXID. It's necessary for the Raspberry Pi 4.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Stefan Wahren <[email protected]>Acked-by Florian Fainelli <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>There are more changes required to make the GENET controller on the Pi 4 to work, how and why this was selected? Same comment applies to the 4.19 automatic selection.
I'll just drop it then, thanks.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 277/350 tpm: Add a flag to indicate TPM power is managed by firmware
In reply to Sasha LevinFrom: Stephen Boyd <[email protected]>
[ Upstream commit 2e2ee5a2db06c4b81315514b01d06fe5644342e9 ]
On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag, TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.
--- drivers/char/tpm/tpm-interface.c | 8 +++++++- drivers/char/tpm/tpm.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +7 -1
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/spinlock.h> +#include <linux/suspend.h> #include <linux/freezer.h> #include <linux/tpm_eventlog.h>
@@ -394,7 +395,11 @@ int tpm_pm_suspend(struct device *dev)return -ENODEV ;if (chip->flags &TPM_CHIP_FLAG_ALWAYS_POWERED ) -return 0 ; + goto suspended; + +if ((chip->flags &TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED ) && + !pm_suspend_via_firmware ()) + goto suspended;if (!tpm_chip_start (chip)) {if (chip->flags &TPM_CHIP_FLAG_TPM2 )
@@ -405,6 +410,7 @@ int tpm_pm_suspend(struct device *dev)tpm_chip_stop (chip); } +suspended:return rc; }EXPORT_SYMBOL_GPL (tpm_pm_suspend);
drivers/char/tpm/tpm.h +1 -0
@@ -162,6 +162,7 @@ enum tpm_chip_flags {TPM_CHIP_FLAG_VIRTUAL =BIT (3 ),TPM_CHIP_FLAG_HAVE_TIMEOUTS =BIT (4 ),TPM_CHIP_FLAG_ALWAYS_POWERED =BIT (5 ), + TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6), };#define to_tpm_chip (d) container_of(d, struct tpm_chip, dev)
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.4 277/350] tpm: Add a flag to indicate TPM power is managed by firmware
Quoted 12 lines · Sasha Levin
From: Stephen Boyd <[email protected]>
[ Upstream commit
2e2ee5a2db06c4b81315514b01d06fe5644342e9]On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag,
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.
Are the patches needed to support CR50 (which need this patch) going to be applied to v5.4.y as well ? If not, what is the purpose of applying this patch to v5.4.y ?
Thanks,
Guenter
Quoted 67 lines
Cc Andrey Pronin <[email protected]>Cc Duncan Laurie <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Guenter Roeck <[email protected]>Cc Alexander Steffen <[email protected]>Cc Heiko Stuebner <[email protected]>Tested-by Heiko Stuebner <[email protected]>Reviewed-by Heiko Stuebner <[email protected]>Signed-off-by Stephen Boyd <[email protected]>Reviewed-by Jarkko Sakkinen <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/char/tpm/tpm-interface.c | 8 +++++++- drivers/char/tpm/tpm.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)drivers/char/tpm/tpm-interface.c +7
-1@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/spinlock.h> +#include <linux/suspend.h> #include <linux/freezer.h> #include <linux/tpm_eventlog.h> @@ -394,7 +395,11 @@ int tpm_pm_suspend(struct device *dev)return -ENODEV ;if (chip->flags &TPM_CHIP_FLAG_ALWAYS_POWERED ) -return 0 ; + goto suspended; + +if ((chip->flags &TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED ) && + !pm_suspend_via_firmware ()) + goto suspended;if (!tpm_chip_start (chip)) {if (chip->flags &TPM_CHIP_FLAG_TPM2 )@@ -405,6 +410,7 @@ int tpm_pm_suspend(struct device *dev)tpm_chip_stop (chip); } +suspended:return rc; }EXPORT_SYMBOL_GPL (tpm_pm_suspend);drivers/char/tpm/tpm.h +1
-1@@ -162,6 +162,7 @@ enum tpm_chip_flags {TPM_CHIP_FLAG_VIRTUAL =BIT (3 ),TPM_CHIP_FLAG_HAVE_TIMEOUTS =BIT (4 ),TPM_CHIP_FLAG_ALWAYS_POWERED =BIT (5 ), + TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6), };#define to_tpm_chip (d) container_of(d, struct tpm_chip, dev) --2.20.1
Re: [PATCH AUTOSEL 5.4 277/350] tpm: Add a flag to indicate TPM power is managed by firmware
Quoted 14 lines · Guenter Roeck
Quoted 12 lines · Sasha Levin
From: Stephen Boyd <[email protected]>
[ Upstream commit
2e2ee5a2db06c4b81315514b01d06fe5644342e9]On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag,
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.
Quoted 6 lines
Are the patches needed to support CR50 (which need this patch) going to be applied to v5.4.y as well ? If not, what is the purpose of applying this patch to v5.4.y ?
Thanks,
Guenter
Thanks Guenter. I think not.
/Jarkko
Re: [PATCH AUTOSEL 5.4 277/350] tpm: Add a flag to indicate TPM power is managed by firmware
Quoted 16 lines · Jarkko Sakkinen
Quoted 14 lines · Guenter Roeck
Quoted 12 lines · Sasha Levin
From: Stephen Boyd <[email protected]>
[ Upstream commit
2e2ee5a2db06c4b81315514b01d06fe5644342e9]On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag,
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.
Quoted 9 lines
Quoted 6 lines
Are the patches needed to support CR50 (which need this patch) going to be applied to v5.4.y as well ? If not, what is the purpose of applying this patch to v5.4.y ?
Thanks,
GuenterThanks Guenter. I think not.
Thought so. In that case this patch should be dropped.
Guenter
Re: [PATCH AUTOSEL 5.4 277/350] tpm: Add a flag to indicate TPM power is managed by firmware
Quoted 22 lines · Guenter Roeck
Quoted 20 lines · Jarkko Sakkinen
Quoted 18 lines · Guenter Roeck
Quoted 12 lines · Sasha Levin
From: Stephen Boyd <[email protected]>
[ Upstream commit
2e2ee5a2db06c4b81315514b01d06fe5644342e9]On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag,
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.Are the patches needed to support CR50 (which need this patch) going to be applied to v5.4.y as well ? If not, what is the purpose of applying this patch to v5.4.y ?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Thanks,
GuenterThanks Guenter. I think not.
Thought so. In that case this patch should be dropped.
Guenter
I fully agree with you.
/Jarkko
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.4 277/350] tpm: Add a flag to indicate TPM power is managed by firmware
Quoted 26 lines · Jarkko Sakkinen
Quoted 25 lines · Guenter Roeck
Quoted 23 lines · Jarkko Sakkinen
Quoted 20 lines · Guenter Roeck
Quoted 12 lines · Sasha Levin
From: Stephen Boyd <[email protected]>
[ Upstream commit
2e2ee5a2db06c4b81315514b01d06fe5644342e9]On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag,
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.Are the patches needed to support CR50 (which need this patch) going to be applied to v5.4.y as well ? If not, what is the purpose of applying this patch to v5.4.y ?
Thanks,
Guenter
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Thanks Guenter. I think not.
Thought so. In that case this patch should be dropped.
Guenter
I fully agree with you.
I've dropped it, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 278/350 parport: load lowlevel driver if ports not found
In reply to Sasha LevinFrom: Sudip Mukherjee <[email protected]>
[ Upstream commit 231ec2f24dad18d021b361045bbd618ba62a274e ]
Usually all the distro will load the parport low level driver as part of their initialization. But we can get into a situation where all the parallel port drivers are built as module and we unload all the modules at a later time. Then if we just do "modprobe parport" it will only load the parport module and will not load the low level driver which will actually register the ports. So, check the bus if there is any parport registered, if not, load the low level driver.
We can get into the above situation with all distro but only Suse has setup the alias for "parport_lowlevel" and so it only works in Suse. Users of Debian based distro will need to load the lowlevel module manually.
--- drivers/parport/share.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/parport/share.c +21 -0
@@ -230,6 +230,18 @@ static int port_check(struct device *dev, void *dev_drv)return 0 ; } +/* +* Iterates through all the devices connected to the bus and return 1 +* if the device is a parallel port. +*/ + +static int port_detect (struct device *dev,void *dev_drv) +{ +if (is_parport (dev)) +return 1 ; +return 0 ; +} +/** * parport_register_driver - register a parallel port device driver * @drv: structure describing the driver
@@ -282,6 +294,15 @@ int __parport_register_driver(struct parport_driver *drv, struct module *owner,if (ret)return ret; +/* +* check if bus has any parallel port registered, if +* none is found then load the lowlevel driver. +*/ + ret =bus_for_each_dev (&parport_bus_type,NULL ,NULL , + port_detect); +if (!ret) +get_lowlevel_driver (); +mutex_lock (®istration_lock);if (drv->match_port) bus_for_each_dev(&parport_bus_type, NULL, drv,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 279/350 bcache: fix static checker warning in bcache_device_free()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 2d8869518a525c9bce5f5268419df9dfbe3dfdeb ]
Commit cafe56359144 ("bcache: A block layer cache") leads to the following static checker warning:
./drivers/md/bcache/super.c:770 bcache_device_free()
warn: variable dereferenced before check 'd->disk' (see line 766)drivers/md/bcache/super.c
762 static void bcache_device_free(struct bcache_device *d) 763 {
764 lockdep_assert_held(&bch_register_lock);
765
766 pr_info("%s stopped", d->disk->disk_name);
^^^^^^^^^Unchecked dereference.
767
768 if (d->c)
769 bcache_device_detach(d);
770 if (d->disk && d->disk->flags & GENHD_FL_UP)
^^^^^^^
Check too late.
771 del_gendisk(d->disk);
772 if (d->disk && d->disk->queue)
773 blk_cleanup_queue(d->disk->queue);
774 if (d->disk) {
775 ida_simple_remove(&bcache_device_idx,
776 first_minor_to_idx(d->disk->first_minor));
777 put_disk(d->disk);
778 }
779It is not 100% sure that the gendisk struct of bcache device will always be there, the warning makes sense when there is problem in block core.
This patch tries to remove the static checking warning by checking d->disk to avoid NULL pointer deferences.
--- drivers/md/bcache/super.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/md/bcache/super.c +16 -8
@@ -761,20 +761,28 @@ static inline int idx_to_first_minor(int idx)static void bcache_device_free (struct bcache_device *d) { +struct gendisk *disk = d->disk; +lockdep_assert_held (&bch_register_lock); -pr_info ("%s stopped" , d->disk->disk_name); +if (disk) +pr_info ("%s stopped" , disk->disk_name); +else +pr_err ("bcache device (NULL gendisk) stopped" );if (d->c)bcache_device_detach (d); -if (d->disk && d->disk->flags &GENHD_FL_UP ) -del_gendisk (d->disk); -if (d->disk && d->disk->queue) -blk_cleanup_queue (d->disk->queue); -if (d->disk) { + +if (disk) { +if (disk->flags &GENHD_FL_UP ) +del_gendisk (disk); + +if (disk->queue) +blk_cleanup_queue (disk->queue); +ida_simple_remove (&bcache_device_idx, -first_minor_to_idx (d->disk->first_minor)); -put_disk (d->disk); +first_minor_to_idx (disk->first_minor)); +put_disk (disk); }bioset_exit (&d->bio_split);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 280/350 cpufreq: Register drivers only after CPU devices have been registered
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit 46770be0cf94149ca48be87719bda1d951066644 ]
The cpufreq core heavily depends on the availability of the struct device for CPUs and if they aren't available at the time cpufreq driver is registered, we will never succeed in making cpufreq work.
This happens due to following sequence of events:
- cpufreq_register_driver()
- subsys_interface_register()
- return 0; //successful registration of driver
... at a later point of time
- register_cpu();
- device_register();
- bus_probe_device();
- sif->add_dev();
- cpufreq_add_dev();
- get_cpu_device(); //FAILS
- per_cpu(cpu_sys_devices, num) = &cpu->dev; //used by get_cpu_device()
- return 0; //CPU registered successfully
Because the per-cpu variable cpu_sys_devices is set only after the CPU device is regsitered, cpufreq will never be able to get it when cpufreq_add_dev() is called.
This patch avoids this failure by making sure device structure of at least CPU0 is available when the cpufreq driver is registered, else return -EPROBE_DEFER.
--- drivers/cpufreq/cpufreq.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/cpufreq/cpufreq.c +7 -0
@@ -2634,6 +2634,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)if (cpufreq_disabled ())return -ENODEV ; +/* +* The cpufreq core depends heavily on the availability of device +* structure, make sure they are available before proceeding further. +*/ +if (!get_cpu_device (0 )) +return -EPROBE_DEFER ; + if (!driver_data || !driver_data->verify || !driver_data->init || !(driver_data->setpolicy || driver_data->target_index || driver_data->target) ||
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 281/350 qtnfmac: fix debugfs support for multiple cards
In reply to Sasha LevinFrom: Sergey Matyukevich <[email protected]>
[ Upstream commit dd4c2260dab04f5ae7bdb79b9470e7da56f48145 ]
Fix merge artifact for commit 0b68fe10b8e8 ("qtnfmac: modify debugfs to support multiple cards") and finally add debugfs support for multiple qtnfmac wireless cards.
--- drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c +5 -1
@@ -130,6 +130,8 @@ static int qtnf_dbg_shm_stats(struct seq_file *s, void *data)int qtnf_pcie_fw_boot_done (struct qtnf_bus *bus) { +struct qtnf_pcie_bus_priv *priv =get_bus_priv (bus); +char card_id[64 ];int ret; bus->fw_state =QTNF_FW_STATE_BOOT_DONE ;
@@ -137,7 +139,9 @@ int qtnf_pcie_fw_boot_done(struct qtnf_bus *bus)if (ret) {pr_err ("failed to attach core\n" ); }else { -qtnf_debugfs_init (bus,DRV_NAME ); +snprintf (card_id,sizeof (card_id),"%s:%s" , +DRV_NAME ,pci_name (priv->pdev)); +qtnf_debugfs_init (bus, card_id);qtnf_debugfs_add_entry (bus,"mps" , qtnf_dbg_mps_show);qtnf_debugfs_add_entry (bus,"msi_enabled" , qtnf_dbg_msi_show);qtnf_debugfs_add_entry (bus,"shm_stats" , qtnf_dbg_shm_stats);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 282/350 qtnfmac: fix invalid channel information output
In reply to Sasha LevinFrom: Sergey Matyukevich <[email protected]>
[ Upstream commit 24227a9e956a7c9913a7e6e7199a9ae3f540fe88 ]
Do not attempt to print frequency for an invalid channel provided by firmware. That channel may simply not exist.
--- drivers/net/wireless/quantenna/qtnfmac/event.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/event.c +4 -3
@@ -171,8 +171,9 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,return -EPROTO ; } -pr_debug ("VIF%u.%u: BSSID:%pM status:%u\n" , - vif->mac->macid, vif->vifid, join_info->bssid, status); +pr_debug ("VIF%u.%u: BSSID:%pM chan:%u status:%u\n" , + vif->mac->macid, vif->vifid, join_info->bssid, +le16_to_cpu (join_info->chan.chan.center_freq), status);if (status !=WLAN_STATUS_SUCCESS ) goto done;
@@ -181,7 +182,7 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,if (!cfg80211_chandef_valid (&chandef)) {pr_warn ("MAC%u.%u: bad channel freq=%u cf1=%u cf2=%u bw=%u\n" , vif->mac->macid, vif->vifid, - chandef.chan->center_freq, + chandef.chan ? chandef.chan->center_freq :0 , chandef.center_freq1, chandef.center_freq2, chandef.width);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 283/350 x86/crash: Add a forward declaration of struct kimage
In reply to Sasha LevinFrom: Lianbo Jiang <[email protected]>
[ Upstream commit 112eee5d06007dae561f14458bde7f2a4879ef4e ]
Add a forward declaration of struct kimage to the crash.h header because future changes will invoke a crash-specific function from the realmode init path and the compiler will complain otherwise like this:
In file included from arch/x86/realmode/init.c:11:
./arch/x86/include/asm/crash.h:5:32: warning: ‘struct kimage’ declared inside\
parameter list will not be visible outside of this definition or declaration
5 | int crash_load_segments(struct kimage *image);
| ^~~~~~
./arch/x86/include/asm/crash.h:6:37: warning: ‘struct kimage’ declared inside\
parameter list will not be visible outside of this definition or declaration
6 | int crash_copy_backup_region(struct kimage *image);
| ^~~~~~ ./arch/x86/include/asm/crash.h:7:39: warning: ‘struct kimage’ declared inside\
parameter list will not be visible outside of this definition or declaration
7 | int crash_setup_memmap_entries(struct kimage *image,
|
[ bp: Rewrite the commit message. ]
--- arch/x86/include/asm/crash.h | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/include/asm/crash.h +2 -0
@@ -2,6 +2,8 @@#ifndef _ASM_X86_CRASH_H#define _ASM_X86_CRASH_H +struct kimage ; +int crash_load_segments (struct kimage *image);int crash_copy_backup_region (struct kimage *image); int crash_setup_memmap_entries(struct kimage *image,
Signature · 7 lines
2.20.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Sasha Levin
maintainerPATCH 284/350 qtnfmac: fix using skb after free
In reply to Sasha LevinFrom: Sergey Matyukevich <[email protected]>
[ Upstream commit 4a33f21cef84b1b933958c99ed5dac1726214b35 ]
KASAN reported use-after-free error:
[ 995.220767] BUG: KASAN: use-after-free in qtnf_cmd_send_with_reply+0x169/0x3e0 [qtnfmac] [ 995.221098] Read of size 2 at addr ffff888213d1ded0 by task kworker/1:1/71
The issue in qtnf_cmd_send_with_reply impacts all the commands that do not need response other then return code. For such commands, consume_skb is used for response skb and right after that return code in response skb is accessed.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +4 -2
@@ -83,6 +83,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,struct qlink_cmd *cmd;struct qlink_resp *resp =NULL ;struct sk_buff *resp_skb =NULL ; +int resp_res =0 ;u16 cmd_id;u8 mac_id;u8 vif_id;
@@ -113,6 +114,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, } resp = (struct qlink_resp *)resp_skb->data; + resp_res =le16_to_cpu (resp->result); ret =qtnf_cmd_check_reply_header (resp, cmd_id, mac_id, vif_id, const_resp_size);if (ret)
@@ -128,8 +130,8 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,else consume_skb (resp_skb); -if (!ret && resp) -return qtnf_cmd_resp_result_decode (le16_to_cpu (resp->result)); +if (!ret) +return qtnf_cmd_resp_result_decode (resp_res);pr_warn ("VIF%u.%u: cmd 0x%.4X failed: %d\n" , mac_id, vif_id, cmd_id, ret);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 285/350 RDMA/qib: Validate ->show()/store() callbacks before calling them
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit 7ee23491b39259ae83899dd93b2a29ef0f22f0a7 ]
The permissions of the read-only or write-only sysfs files can be changed (as root) and the user can then try to read a write-only file or write to a read-only file which will lead to kernel crash here.
Protect against that by always validating the show/store callbacks.
--- drivers/infiniband/hw/qib/qib_sysfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/hw/qib/qib_sysfs.c +6 -0
@@ -301,6 +301,9 @@ static ssize_t qib_portattr_show(struct kobject *kobj,struct qib_pportdata *ppd = container_of(kobj, struct qib_pportdata, pport_kobj); +if (!pattr->show) +return -EIO ; +return pattr->show (ppd, buf); }
@@ -312,6 +315,9 @@ static ssize_t qib_portattr_store(struct kobject *kobj,struct qib_pportdata *ppd = container_of(kobj, struct qib_pportdata, pport_kobj); +if (!pattr->store) +return -EIO ; +return pattr->store (ppd, buf, len); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 286/350 RDMA/efa: Clear the admin command buffer prior to its submission
In reply to Sasha LevinFrom: Gal Pressman <[email protected]>
[ Upstream commit 64c264872b8879e2ab9017eefe9514d4c045c60e ]
We cannot rely on the entry memcpy as we only copy the actual size of the command, the rest of the bytes must be memset to zero.
Currently providing non-zero memory will not have any user visible impact. However, since admin commands are extendable (in a backwards compatible way) everything beyond the size of the command must be cleared to prevent issues in the future.
--- drivers/infiniband/hw/efa/efa_com.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/efa/efa_com.c +4 -1
@@ -317,6 +317,7 @@ static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queu struct efa_admin_acq_entry *comp, size_t comp_size_in_bytes) { +struct efa_admin_aq_entry *aqe;struct efa_comp_ctx *comp_ctx;u16 queue_size_mask;u16 cmd_id;
@@ -350,7 +351,9 @@ static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queureinit_completion (&comp_ctx->wait_event); -memcpy (&aq->sq.entries[pi], cmd, cmd_size_in_bytes); + aqe = &aq->sq.entries[pi]; +memset (aqe,0 ,sizeof (*aqe)); +memcpy (aqe, cmd, cmd_size_in_bytes); aq->sq.pc++;atomic64_inc (&aq->stats.submitted_cmd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 287/350 tracing: use kvcalloc for tgid_map array allocation
In reply to Sasha LevinFrom: Yuming Han <[email protected]>
[ Upstream commit 6ee40511cb838f9ced002dff7131bca87e3ccbdd ]
Fail to allocate memory for tgid_map, because it requires order-6 page. detail as:
c3 sh: page allocation failure: order:6,
mode:0x140c0c0(GFP_KERNEL), nodemask=(null)
c3 sh cpuset=/ mems_allowed=0
c3 CPU: 3 PID: 5632 Comm: sh Tainted: G W O 4.14.133+ #10
c3 Hardware name: Generic DT based system
c3 Backtrace:
c3 [<c010bdbc>] (dump_backtrace) from [<c010c08c>](show_stack+0x18/0x1c) c3 [<c010c074>] (show_stack) from [<c0993c54>](dump_stack+0x84/0xa4)
c3 [<c0993bd0>] (dump_stack) from [<c0229858>](warn_alloc+0xc4/0x19c)
c3 [<c0229798>] (warn_alloc) from [<c022a6e4>](__alloc_pages_nodemask+0xd18/0xf28) c3 [<c02299cc>] (__alloc_pages_nodemask) from [<c0248344>](kmalloc_order+0x20/0x38) c3 [<c0248324>] (kmalloc_order) from [<c0248380>](kmalloc_order_trace+0x24/0x108) c3 [<c024835c>] (kmalloc_order_trace) from [<c01e6078>](set_tracer_flag+0xb0/0x158) c3 [<c01e5fc8>] (set_tracer_flag) from [<c01e6404>](trace_options_core_write+0x7c/0xcc) c3 [<c01e6388>] (trace_options_core_write) from [<c0278b1c>](__vfs_write+0x40/0x14c) c3 [<c0278adc>] (__vfs_write) from [<c0278e10>](vfs_write+0xc4/0x198)
c3 [<c0278d4c>] (vfs_write) from [<c027906c>](SyS_write+0x6c/0xd0)
c3 [<c0279000>] (SyS_write) from [<c01079a0>](ret_fast_syscall+0x0/0x54)
Switch to use kvcalloc to avoid unexpected allocation failures.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -4609,7 +4609,7 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)if (mask ==TRACE_ITER_RECORD_TGID ) {if (!tgid_map) - tgid_map =kcalloc (PID_MAX_DEFAULT +1 , + tgid_map =kvcalloc (PID_MAX_DEFAULT +1 ,sizeof (*tgid_map),GFP_KERNEL );if (!tgid_map) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 288/350 MIPS: ralink: enable PCI support only if driver for mt7621 SoC is selected
In reply to Sasha LevinFrom: Sergio Paracuellos <[email protected]>
[ Upstream commit 3b2fa0c92686562ac0b8cf00c0326a45814f8e18 ]
Some versions of SoC MT7621 have three PCI express hosts. Some boards make use of those PCI through the staging driver mt7621-pci. Recently PCI support has been removed from MT7621 Soc kernel configuration due to a build error. This makes imposible to compile staging driver and produces a regression for gnubee based boards. Enable support for PCI again but enable it only if staging mt7621-pci driver is selected.
--- arch/mips/ralink/Kconfig | 1 + drivers/staging/mt7621-pci/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
arch/mips/ralink/Kconfig +1 -0
@@ -51,6 +51,7 @@ choice select MIPS_GIC select COMMON_CLK select CLKSRC_MIPS_GIC + select HAVE_PCI if PCI_MT7621 endchoice choice
drivers/staging/mt7621-pci/Kconfig +0 -1
@@ -2,7 +2,6 @@ config PCI_MT7621 tristate "MediaTek MT7621 PCI Controller" depends on RALINK - depends on PCI select PCI_DRIVERS_GENERIC help This selects a driver for the MediaTek MT7621 PCI Controller.
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 289/350 tracing/kprobe: Check whether the non-suffixed symbol is notrace
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit c7411a1a126f649be71526a36d4afac9e5aefa13 ]
Check whether the non-suffixed symbol is notrace, since suffixed symbols are generated by the compilers for optimization. Based on these suffixed symbols, notrace check might not work because some of them are just a partial code of the original function. (e.g. cold-cache (unlikely) code is separated from original
function as FUNCTION.cold.XX)
For example, without this fix,
# echo p device_add.cold.67 > /sys/kernel/debug/tracing/kprobe_events sh: write error: Invalid argument
# cat /sys/kernel/debug/tracing/error_log
[ 135.491035] trace_kprobe: error: Failed to register probe event
Command: p device_add.cold.67
^
# dmesg | tail -n 1
[ 135.488599] trace_kprobe: Could not probe notrace function device_add.cold.67With this,
# echo p device_add.cold.66 > /sys/kernel/debug/tracing/kprobe_events # cat /sys/kernel/debug/kprobes/list ffffffff81599de9 k device_add.cold.66+0x0 [DISABLED]
Actually, kprobe blacklist already did similar thing, see within_kprobe_blacklist().
--- kernel/trace/trace_kprobe.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
kernel/trace/trace_kprobe.c +24 -3
@@ -435,11 +435,10 @@ static int disable_trace_kprobe(struct trace_event_call *call,#if defined(CONFIG_KPROBES_ON_FTRACE ) && \ !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE ) -static bool within_notrace_func (struct trace_kprobe *tk) +static bool __within_notrace_func (unsigned long addr) { -unsigned long offset, size, addr; +unsigned long offset, size; - addr =trace_kprobe_address (tk);if (!addr || !kallsyms_lookup_size_offset (addr, &size, &offset))return false;
@@ -452,6 +451,28 @@ static bool within_notrace_func(struct trace_kprobe *tk)*/ return !ftrace_location_range(addr, addr + size - 1); } + +static bool within_notrace_func (struct trace_kprobe *tk) +{ +unsigned long addr = addr =trace_kprobe_address (tk); +char symname[KSYM_NAME_LEN ], *p; + +if (!__within_notrace_func (addr)) +return false; + +/* Check if the address is on a suffixed-symbol */ +if (!lookup_symbol_name (addr, symname)) { + p =strchr (symname,'.' ); +if (!p) +return true; + *p ='\0' ; + addr = (unsigned long )kprobe_lookup_name (symname,0 ); +if (addr) +return __within_notrace_func (addr); + } + +return true; +}#else #define within_notrace_func (tk) (false)#endif
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 290/350 bcache: fix deadlock in bcache_allocator
In reply to Sasha LevinFrom: Andrea Righi <[email protected]>
[ Upstream commit 84c529aea182939e68f618ed9813740c9165c7eb ]
bcache_allocator can call the following:
bch_allocator_thread()
-> bch_prio_write()
-> bch_bucket_alloc()
-> wait on &ca->set->bucket_waitBut the wake up event on bucket_wait is supposed to come from bch_allocator_thread() itself => deadlock:
[ 1158.490744] INFO: task bcache_allocato:15861 blocked for more than 10 seconds. [ 1158.495929] Not tainted 5.3.0-050300rc3-generic #201908042232 [ 1158.500653] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1158.504413] bcache_allocato D 0 15861 2 0x80004000 [ 1158.504419] Call Trace: [ 1158.504429] __schedule+0x2a8/0x670 [ 1158.504432] schedule+0x2d/0x90 [ 1158.504448] bch_bucket_alloc+0xe5/0x370 [bcache] [ 1158.504453] ? wait_woken+0x80/0x80 [ 1158.504466] bch_prio_write+0x1dc/0x390 [bcache] [ 1158.504476] bch_allocator_thread+0x233/0x490 [bcache] [ 1158.504491] kthread+0x121/0x140 [ 1158.504503] ? invalidate_buckets+0x890/0x890 [bcache] [ 1158.504506] ? kthread_park+0xb0/0xb0 [ 1158.504510] ret_from_fork+0x35/0x40
Fix by making the call to bch_prio_write() non-blocking, so that bch_allocator_thread() never waits on itself.
Moreover, make sure to wake up the garbage collector thread when bch_prio_write() is failing to allocate buckets.
--- drivers/md/bcache/alloc.c | 5 ++++- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 27 +++++++++++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-)
drivers/md/bcache/alloc.c +4 -1
@@ -377,7 +377,10 @@ static int bch_allocator_thread(void *arg)if (!fifo_full (&ca->free_inc)) goto retry_invalidate; -bch_prio_write (ca); +if (bch_prio_write (ca, false) <0 ) { + ca->invalidate_needs_gc =1 ; +wake_up_gc (ca->set); + } } } out:
drivers/md/bcache/bcache.h +1 -1
@@ -977,7 +977,7 @@ bool bch_cached_dev_error(struct cached_dev *dc); __printf(2, 3)bool bch_cache_set_error (struct cache_set *c,const char *fmt, ...); -void bch_prio_write (struct cache *ca); +int bch_prio_write (struct cache *ca,bool wait);void bch_write_bdev_super (struct cached_dev *dc,struct closure *parent);extern struct workqueue_struct *bcache_wq;
drivers/md/bcache/super.c +21 -6
@@ -529,12 +529,29 @@ static void prio_io(struct cache *ca, uint64_t bucket, int op,closure_sync (cl); } -void bch_prio_write (struct cache *ca) +int bch_prio_write (struct cache *ca,bool wait) {int i;struct bucket *b;struct closure cl; +pr_debug ("free_prio=%zu, free_none=%zu, free_inc=%zu" , +fifo_used (&ca->free[RESERVE_PRIO ]), +fifo_used (&ca->free[RESERVE_NONE ]), +fifo_used (&ca->free_inc)); + +/* +* Pre-check if there are enough free buckets. In the non-blocking +* scenario it's better to fail early rather than starting to allocate +* buckets and do a cleanup later in case of failure. +*/ +if (!wait) { +size_t avail =fifo_used (&ca->free[RESERVE_PRIO ]) + +fifo_used (&ca->free[RESERVE_NONE ]); +if (prio_buckets (ca) > avail) +return -ENOMEM ; + } +closure_init_stack (&cl);lockdep_assert_held (&ca->set->bucket_lock);
@@ -544,9 +561,6 @@ void bch_prio_write(struct cache *ca)atomic_long_add (ca->sb.bucket_size *prio_buckets (ca), &ca->meta_sectors_written); -//pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free), -// fifo_used(&ca->free_inc), fifo_used(&ca->unused)); -for (i =prio_buckets (ca) -1 ; i >=0 ; --i) {long bucket;struct prio_set *p = ca->disk_buckets;
@@ -564,7 +578,7 @@ void bch_prio_write(struct cache *ca) p->magic =pset_magic (&ca->sb); p->csum =bch_crc64 (&p->magic,bucket_bytes (ca) -8 ); - bucket =bch_bucket_alloc (ca,RESERVE_PRIO , true); + bucket =bch_bucket_alloc (ca,RESERVE_PRIO , wait);BUG_ON (bucket ==-1 );mutex_unlock (&ca->set->bucket_lock);
@@ -593,6 +607,7 @@ void bch_prio_write(struct cache *ca) ca->prio_last_buckets[i] = ca->prio_buckets[i]; } +return 0 ; }static void prio_read (struct cache *ca,uint64_t bucket)
@@ -1962,7 +1977,7 @@ static int run_cache_set(struct cache_set *c)mutex_lock (&c->bucket_lock);for_each_cache (ca, c, i) -bch_prio_write (ca); +bch_prio_write (ca, true);mutex_unlock (&c->bucket_lock); err ="cannot allocate new UUID bucket" ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 291/350 iwlwifi: mvm: fix unaligned read of rx_pkt_status
In reply to Sasha LevinFrom: Wang Xuerui <[email protected]>
[ Upstream commit c5aaa8be29b25dfe1731e9a8b19fd91b7b789ee3 ]
This is present since the introduction of iwlmvm.
Example stack trace on MIPS:
[<ffffffffc0789328>] iwl_mvm_rx_rx_mpdu+0xa8/0xb88 [iwlmvm] [<ffffffffc0632b40>] iwl_pcie_rx_handle+0x420/0xc48 [iwlwifi]
Tested with a Wireless AC 7265 for ~6 months, confirmed to fix the problem. No other unaligned accesses are spotted yet.
--- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +2 -1
@@ -60,6 +60,7 @@* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#include <asm/unaligned.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include "iwl-trans.h"
@@ -357,7 +358,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi, rx_res = (struct iwl_rx_mpdu_res_start *)pkt->data; hdr = (struct ieee80211_hdr *)(pkt->data +sizeof (*rx_res)); len =le16_to_cpu (rx_res->byte_count); - rx_pkt_status =le32_to_cpup ((__le32 *) + rx_pkt_status =get_unaligned_le32 ((__le32 *) (pkt->data +sizeof (*rx_res) + len));/* Dont use dev_alloc_skb(), we'll have enough headroom once
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 292/350 ASoC: wm8904: fix regcache handling
In reply to Sasha LevinFrom: Michael Walle <[email protected]>
[ Upstream commit e9149b8c00d25dbaef1aa174fc604bed207e576d ]
The current code assumes that the power is turned off in SND_SOC_BIAS_OFF. If there are no actual regulator the codec isn't turned off and the registers are not reset to their default values but the regcache is still marked as dirty. Thus a value might not be written to the hardware if it is set to the default value. Do a software reset before turning off the power to make sure the registers are always reset to their default states.
--- sound/soc/codecs/wm8904.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/wm8904.c +1 -0
@@ -1917,6 +1917,7 @@ static int wm8904_set_bias_level(struct snd_soc_component *component,snd_soc_component_update_bits (component,WM8904_BIAS_CONTROL_0 ,WM8904_BIAS_ENA ,0 ); +snd_soc_component_write (component,WM8904_SW_RESET_AND_ID ,0 );regcache_cache_only (wm8904->regmap, true);regcache_mark_dirty (wm8904->regmap);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 293/350 regulator: core: Let boot-on regulators be powered off
In reply to Sasha LevinFrom: Pascal Paillet <[email protected]>
[ Upstream commit 089b3f61ecfc43ca4ea26d595e1d31ead6de3f7b ]
Boot-on regulators are always kept on because their use_count value is now incremented at boot time and never cleaned.
Only increment count value for alway-on regulators. regulator_late_cleanup() is now able to power off boot-on regulators when unused.
--- drivers/regulator/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/core.c +3 -1
@@ -1403,7 +1403,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,rdev_err (rdev,"failed to enable\n" );return ret; } - rdev->use_count++; + +if (rdev->constraints->always_on) + rdev->use_count++; }print_constraints (rdev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 294/350 spi: tegra20-slink: add missed clk_unprepare
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 04358e40ba96d687c0811c21d9dede73f5244a98 ]
The driver misses calling clk_unprepare in probe failure and remove. Add the calls to fix it.
--- drivers/spi/spi-tegra20-slink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-tegra20-slink.c +4 -1
@@ -1073,7 +1073,7 @@ static int tegra_slink_probe(struct platform_device *pdev) ret =clk_enable (tspi->clk);if (ret <0 ) {dev_err (&pdev->dev,"Clock enable failed %d\n" , ret); - goto exit_free_master; + goto exit_clk_unprepare; } spi_irq =platform_get_irq (pdev,0 );
@@ -1146,6 +1146,8 @@ static int tegra_slink_probe(struct platform_device *pdev)free_irq (spi_irq, tspi); exit_clk_disable:clk_disable (tspi->clk); +exit_clk_unprepare: +clk_unprepare (tspi->clk); exit_free_master:spi_master_put (master);return ret;
@@ -1159,6 +1161,7 @@ static int tegra_slink_remove(struct platform_device *pdev)free_irq (tspi->irq, tspi);clk_disable (tspi->clk); +clk_unprepare (tspi->clk);if (tspi->tx_dma_chan)tegra_slink_deinit_dma_param (tspi, false);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 295/350 tun: fix data-race in gro_normal_list()
In reply to Sasha LevinFrom: Petar Penkov <[email protected]>
[ Upstream commit c39e342a050a4425348e6fe7f75827c0a1a7ebc5 ]
There is a race in the TUN driver between napi_busy_loop and napi_gro_frags. This commit resolves the race by adding the NAPI struct via netif_tx_napi_add, instead of netif_napi_add, which disables polling for the NAPI struct.
KCSAN reported:
BUG: KCSAN: data-race in gro_normal_list.part.0 / napi_busy_loop
write to 0xffff8880b5d474b0 of 4 bytes by task 11205 on cpu 0:
gro_normal_list.part.0+0x77/0xb0 net/core/dev.c:5682 gro_normal_list net/core/dev.c:5678 [inline] gro_normal_one net/core/dev.c:5692 [inline] napi_frags_finish net/core/dev.c:5705 [inline] napi_gro_frags+0x625/0x770 net/core/dev.c:5778 tun_get_user+0x2150/0x26a0 drivers/net/tun.c:1976 tun_chr_write_iter+0x79/0xd0 drivers/net/tun.c:2022 call_write_iter include/linux/fs.h:1895 [inline] do_iter_readv_writev+0x487/0x5b0 fs/read_write.c:693 do_iter_write fs/read_write.c:970 [inline] do_iter_write+0x13b/0x3c0 fs/read_write.c:951 vfs_writev+0x118/0x1c0 fs/read_write.c:1015 do_writev+0xe3/0x250 fs/read_write.c:1058 __do_sys_writev fs/read_write.c:1131 [inline] __se_sys_writev fs/read_write.c:1128 [inline] __x64_sys_writev+0x4e/0x60 fs/read_write.c:1128 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
read to 0xffff8880b5d474b0 of 4 bytes by task 11168 on cpu 1:
gro_normal_list net/core/dev.c:5678 [inline] napi_busy_loop+0xda/0x4f0 net/core/dev.c:6126 sk_busy_loop include/net/busy_poll.h:108 [inline] __skb_recv_udp+0x4ad/0x560 net/ipv4/udp.c:1689 udpv6_recvmsg+0x29e/0xe90 net/ipv6/udp.c:288 inet6_recvmsg+0xbb/0x240 net/ipv6/af_inet6.c:592 sock_recvmsg_nosec net/socket.c:871 [inline] sock_recvmsg net/socket.c:889 [inline] sock_recvmsg+0x92/0xb0 net/socket.c:885 sock_read_iter+0x15f/0x1e0 net/socket.c:967 call_read_iter include/linux/fs.h:1889 [inline] new_sync_read+0x389/0x4f0 fs/read_write.c:414 __vfs_read+0xb1/0xc0 fs/read_write.c:427 vfs_read fs/read_write.c:461 [inline] vfs_read+0x143/0x2c0 fs/read_write.c:446 ksys_read+0xd5/0x1b0 fs/read_write.c:587 __do_sys_read fs/read_write.c:597 [inline] __se_sys_read fs/read_write.c:595 [inline] __x64_sys_read+0x4c/0x60 fs/read_write.c:595 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 11168 Comm: syz-executor.0 Not tainted 5.4.0-rc6+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- drivers/net/tun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/tun.c +2 -2
@@ -313,8 +313,8 @@ static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile, tfile->napi_enabled = napi_en; tfile->napi_frags_enabled = napi_en && napi_frags;if (napi_en) { -netif_napi_add (tun->dev, &tfile->napi, tun_napi_poll, -NAPI_POLL_WEIGHT ); +netif_tx_napi_add (tun->dev, &tfile->napi, tun_napi_poll, +NAPI_POLL_WEIGHT );napi_enable (&tfile->napi); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 296/350 xhci-pci: Allow host runtime PM as default also for Intel Ice Lake xHCI
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit 07a594f353655b1628f598add352e7e754f44869 ]
Intel Ice Lake has two xHCI controllers one on PCH and the other as part of the CPU itself. The latter is also part of the so called Type C Subsystem (TCSS) sharing ACPI power resources with the PCIe root ports and the Thunderbolt controllers. In order to put the whole TCSS block into D3cold the xHCI needs to be runtime suspended as well when idle.
For this reason allow runtime PM as default for Ice Lake TCSS xHCI controller.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -48,6 +48,7 @@#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0 +#define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9#define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
@@ -212,7 +213,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device ==PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI)) + pdev->device ==PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI)) xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 297/350 crypto: virtio - deal with unsupported input sizes
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 19c5da7d4a2662e85ea67d2d81df57e038fde3ab ]
Return -EINVAL for input sizes that are not a multiple of the AES block size, since they are not supported by our CBC chaining mode.
While at it, remove the pr_err() that reports unsupported key sizes being used: we shouldn't spam the kernel log with that.
--- drivers/crypto/virtio/virtio_crypto_algs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/crypto/virtio/virtio_crypto_algs.c +10 -2
@@ -105,8 +105,6 @@ virtio_crypto_alg_validate_key(int key_len, uint32_t *alg) *alg =VIRTIO_CRYPTO_CIPHER_AES_CBC ;break ;default : -pr_err ("virtio_crypto: Unsupported key length: %d\n" , - key_len);return -EINVAL ; }return 0 ;
@@ -484,6 +482,11 @@ static int virtio_crypto_ablkcipher_encrypt(struct ablkcipher_request *req)/* Use the first data virtqueue as default */ struct data_queue *data_vq = &vcrypto->data_vq[0 ]; +if (!req->nbytes) +return 0 ; +if (req->nbytes %AES_BLOCK_SIZE ) +return -EINVAL ; + vc_req->dataq = data_vq; vc_req->alg_cb = virtio_crypto_dataq_sym_callback; vc_sym_req->ablkcipher_ctx = ctx;
@@ -504,6 +507,11 @@ static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req)/* Use the first data virtqueue as default */ struct data_queue *data_vq = &vcrypto->data_vq[0 ]; +if (!req->nbytes) +return 0 ; +if (req->nbytes %AES_BLOCK_SIZE ) +return -EINVAL ; + vc_req->dataq = data_vq; vc_req->alg_cb = virtio_crypto_dataq_sym_callback; vc_sym_req->ablkcipher_ctx = ctx;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 297/350 crypto: virtio - deal with unsupported input sizes
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 19c5da7d4a2662e85ea67d2d81df57e038fde3ab ]
Return -EINVAL for input sizes that are not a multiple of the AES block size, since they are not supported by our CBC chaining mode.
While at it, remove the pr_err() that reports unsupported key sizes being used: we shouldn't spam the kernel log with that.
--- drivers/crypto/virtio/virtio_crypto_algs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/crypto/virtio/virtio_crypto_algs.c +10 -2
@@ -105,8 +105,6 @@ virtio_crypto_alg_validate_key(int key_len, uint32_t *alg) *alg =VIRTIO_CRYPTO_CIPHER_AES_CBC ;break ;default : -pr_err ("virtio_crypto: Unsupported key length: %d\n" , - key_len);return -EINVAL ; }return 0 ;
@@ -484,6 +482,11 @@ static int virtio_crypto_ablkcipher_encrypt(struct ablkcipher_request *req)/* Use the first data virtqueue as default */ struct data_queue *data_vq = &vcrypto->data_vq[0 ]; +if (!req->nbytes) +return 0 ; +if (req->nbytes %AES_BLOCK_SIZE ) +return -EINVAL ; + vc_req->dataq = data_vq; vc_req->alg_cb = virtio_crypto_dataq_sym_callback; vc_sym_req->ablkcipher_ctx = ctx;
@@ -504,6 +507,11 @@ static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req)/* Use the first data virtqueue as default */ struct data_queue *data_vq = &vcrypto->data_vq[0 ]; +if (!req->nbytes) +return 0 ; +if (req->nbytes %AES_BLOCK_SIZE ) +return -EINVAL ; + vc_req->dataq = data_vq; vc_req->alg_cb = virtio_crypto_dataq_sym_callback; vc_sym_req->ablkcipher_ctx = ctx;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 298/350 mmc: tmio: Add MMC_CAP_ERASE to allow erase/discard/trim requests
In reply to Sasha LevinFrom: Eugeniu Rosca <[email protected]>
[ Upstream commit c91843463e9e821dc3b48fe37e3155fa38299f6e ]
Isolated initially to renesas_sdhi_internal_dmac [1], Ulf suggested adding MMC_CAP_ERASE to the TMIO mmc core:
On Fri, Nov 15, 2019 at 10:27:25AM +0100, Ulf Hansson wrote:
-- snip --
This test and due to the discussions with Wolfram and you in this thread, I would actually suggest that you enable MMC_CAP_ERASE for all tmio variants, rather than just for this particular one.
In other words, set the cap in tmio_mmc_host_probe() should be fine, as it seems none of the tmio variants supports HW busy detection at this point.
-- snip --
Testing on R-Car H3ULCB-KF doesn't reveal any issues (v5.4-rc7):
root@rcar-gen3:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT mmcblk0 179:0 0 59.2G 0 disk <--- eMMC mmcblk0boot0 179:8 0 4M 1 disk mmcblk0boot1 179:16 0 4M 1 disk mmcblk1 179:24 0 30G 0 disk <--- SD card
root@rcar-gen3:~# time blkdiscard /dev/mmcblk0 real 0m8.659s user 0m0.001s sys 0m1.920s
root@rcar-gen3:~# time blkdiscard /dev/mmcblk1 real 0m1.176s user 0m0.001s sys 0m0.124s
[1] https://lore.kernel.org/linux-renesas-soc/[email protected]/
--- drivers/mmc/host/tmio_mmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/tmio_mmc_core.c +1 -1
@@ -1184,7 +1184,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)if (ret == -EPROBE_DEFER )return ret; - mmc->caps |=MMC_CAP_4_BIT_DATA | pdata->capabilities; + mmc->caps |=MMC_CAP_ERASE |MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2; mmc->max_segs = pdata->max_segs ? :32 ; mmc->max_blk_size =TMIO_MAX_BLK_SIZE ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 299/350 btrfs: don't prematurely free work in end_workqueue_fn()
In reply to Sasha LevinFrom: Omar Sandoval <[email protected]>
[ Upstream commit 9be490f1e15c34193b1aae17da58e14dd9f55a95 ]
Currently, end_workqueue_fn() frees the end_io_wq entry (which embeds the work item) and then calls bio_endio(). This is another potential instance of the bug in "btrfs: don't prematurely free work in run_ordered_work()".
In particular, the endio call may depend on other work items. For example, btrfs_end_dio_bio() can call btrfs_subio_endio_read() -> __btrfs_correct_data_nocsum() -> dio_read_error() -> submit_dio_repair_bio(), which submits a bio that is also completed through a end_workqueue_fn() work item. However, __btrfs_correct_data_nocsum() waits for the newly submitted bio to complete, thus it depends on another work item.
This example currently usually works because we use different workqueue helper functions for BTRFS_WQ_ENDIO_DATA and BTRFS_WQ_ENDIO_DIO_REPAIR. However, it may deadlock with stacked filesystems and is fragile overall. The proper fix is to free the work item at the very end of the work function, so let's do that.
--- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
@@ -1657,8 +1657,8 @@ static void end_workqueue_fn(struct btrfs_work *work) bio->bi_status = end_io_wq->status; bio->bi_private = end_io_wq->private; bio->bi_end_io = end_io_wq->end_io; -kmem_cache_free (btrfs_end_io_wq_cache, end_io_wq);bio_endio (bio); +kmem_cache_free (btrfs_end_io_wq_cache, end_io_wq); }static int cleaner_kthread (void *arg)
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.4 299/350] btrfs: don't prematurely free work in end_workqueue_fn()
Quoted 23 lines · Sasha Levin
From: Omar Sandoval <[email protected]>
[ Upstream commit
9be490f1e15c34193b1aae17da58e14dd9f55a95]Currently,
end_workqueue_fn()frees theend_io_wqentry (which embeds the work item) and then callsbio_endio(). This is another potential instance of the bug in "btrfs: don't prematurely free work inrun_ordered_work()".In particular, the endio call may depend on other work items. For example,
btrfs_end_dio_bio()can callbtrfs_subio_endio_read()->__btrfs_correct_data_nocsum()->dio_read_error()->submit_dio_repair_bio(), which submits a bio that is also completed through aend_workqueue_fn()work item. However,__btrfs_correct_data_nocsum()waits for the newly submitted bio to complete, thus it depends on another work item.This example currently usually works because we use different workqueue helper functions for
BTRFS_WQ_ENDIO_DATAandBTRFS_WQ_ENDIO_DIO_REPAIR. However, it may deadlock with stacked filesystems and is fragile overall. The proper fix is to free the work item at the very end of the work function, so let's do that.
Quoted 5 lines
Reviewed-by Johannes Thumshirn <[email protected]>Signed-off-by Omar Sandoval <[email protected]>Reviewed-by David Sterba <[email protected]>Signed-off-by David Sterba <[email protected]>Signed-off-by Sasha Levin <[email protected]>
The were more patches in the series, all contain "don't prematurely free work in" and were part of a rework of async work processing. They're fixing a very uncommon usecase, so if there's desire to backport them the whole series needs to go in.
In the autosel list, there are only 2 and without the important fix.
c495dcd6fbe1 btrfs: don't prematurely free work in run_ordered_work() 9be490f1e15c btrfs: don't prematurely free work in end_workqueue_fn() e732fe95e4ca btrfs: don't prematurely free work in reada_start_machine_worker() 57d4f0b86327 btrfs: don't prematurely free work in scrub_missing_raid56_worker()
a0cac0ec961f btrfs: get rid of unique workqueue helper functions
- this is only a cleanup that removes code obsoleted by the fixes above, probably out of scope of stable
I have intentionally not tagged the patches for stable, the usecase is is specific to one user (FB), the known reproducer is only their workload and the fixes are in their kernel already.
So if there's desire to add the patches to stable trees, then it has to be the whole series, but I don't see a strong reason for it.
Re: [PATCH AUTOSEL 5.4 299/350] btrfs: don't prematurely free work in end_workqueue_fn()
Quoted 35 lines · David Sterba
Quoted 23 lines · Sasha Levin
From: Omar Sandoval <[email protected]>
[ Upstream commit
9be490f1e15c34193b1aae17da58e14dd9f55a95]Currently,
end_workqueue_fn()frees theend_io_wqentry (which embeds the work item) and then callsbio_endio(). This is another potential instance of the bug in "btrfs: don't prematurely free work inrun_ordered_work()".In particular, the endio call may depend on other work items. For example,
btrfs_end_dio_bio()can callbtrfs_subio_endio_read()->__btrfs_correct_data_nocsum()->dio_read_error()->submit_dio_repair_bio(), which submits a bio that is also completed through aend_workqueue_fn()work item. However,__btrfs_correct_data_nocsum()waits for the newly submitted bio to complete, thus it depends on another work item.This example currently usually works because we use different workqueue helper functions for
BTRFS_WQ_ENDIO_DATAandBTRFS_WQ_ENDIO_DIO_REPAIR. However, it may deadlock with stacked filesystems and is fragile overall. The proper fix is to free the work item at the very end of the work function, so let's do that.Quoted 5 lines
Reviewed-by Johannes Thumshirn <[email protected]>Signed-off-by Omar Sandoval <[email protected]>Reviewed-by David Sterba <[email protected]>Signed-off-by David Sterba <[email protected]>Signed-off-by Sasha Levin <[email protected]>The were more patches in the series, all contain "don't prematurely free work in" and were part of a rework of async work processing. They're fixing a very uncommon usecase, so if there's desire to backport them the whole series needs to go in.
Quoted 6 lines
In the autosel list, there are only 2 and without the important fix.
c495dcd6fbe1btrfs: don't prematurely free work inrun_ordered_work()9be490f1e15cbtrfs: don't prematurely free work inend_workqueue_fn()e732fe95e4cabtrfs: don't prematurely free work inreada_start_machine_worker()57d4f0b86327btrfs: don't prematurely free work inscrub_missing_raid56_worker()
I've queued all 4, thanks!
Quoted 10 lines
a0cac0ec961fbtrfs: get rid of unique workqueue helper functions
- this is only a cleanup that removes code obsoleted by the fixes above, probably out of scope of stableI have intentionally not tagged the patches for stable, the usecase is is specific to one user (FB), the known reproducer is only their workload and the fixes are in their kernel already.
So if there's desire to add the patches to stable trees, then it has to be the whole series, but I don't see a strong reason for it.
If it's upstream and broken then it's relevant, it doesn't matter if its one user or a million users.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 300/350 btrfs: don't prematurely free work in run_ordered_work()
In reply to Sasha LevinFrom: Omar Sandoval <[email protected]>
[ Upstream commit c495dcd6fbe1dce51811a76bb85b4675f6494938 ]
We hit the following very strange deadlock on a system with Btrfs on a loop device backed by another Btrfs filesystem:
1. The top (loop device) filesystem queues an async_cow work item from cow_file_range_async(). We'll call this work X.
2. Worker thread A starts work X (normal_work_helper()).
3. Worker thread A executes the ordered work for the top filesystem (run_ordered_work()).
4. Worker thread A finishes the ordered work for work X and frees X (work->ordered_free()).
5. Worker thread A executes another ordered work and gets blocked on I/O to the bottom filesystem (still in run_ordered_work()).
6. Meanwhile, the bottom filesystem allocates and queues an async_cow work item which happens to be the recently-freed X.
7. The workqueue code sees that X is already being executed by worker thread A, so it schedules X to be executed _after_ worker thread A finishes (see the find_worker_executing_work() call in process_one_work()).
Now, the top filesystem is waiting for I/O on the bottom filesystem, but the bottom filesystem is waiting for the top filesystem to finish, so we deadlock.
This happens because we are breaking the workqueue assumption that a work item cannot be recycled while it still depends on other work. Fix it by waiting to free the work item until we are done with all of the related ordered work.
P.S.:
One might ask why the workqueue code doesn't try to detect a recycled work item. It actually does try by checking whether the work item has the same work function (find_worker_executing_work()), but in our case the function is the same. This is the only key that the workqueue code has available to compare, short of adding an additional, layer-violating "custom key". Considering that we're the only ones that have ever hit this, we should just play by the rules.
Unfortunately, we haven't been able to create a minimal reproducer other than our full container setup using a compress-force=zstd filesystem on top of another compress-force=zstd filesystem.
--- fs/btrfs/async-thread.c | 56 ++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-)
fs/btrfs/async-thread.c +44 -12
@@ -252,16 +252,17 @@ static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) } } -static void run_ordered_work (struct __btrfs_workqueue *wq) +static void run_ordered_work (struct __btrfs_workqueue *wq, +struct btrfs_work *self) {struct list_head *list = &wq->ordered_list;struct btrfs_work *work;spinlock_t *lock = &wq->list_lock;unsigned long flags; +void *wtag; +bool free_self = false;while (1 ) { -void *wtag; -spin_lock_irqsave (lock, flags);if (list_empty (list))break ;
@@ -287,16 +288,47 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)list_del (&work->ordered_list);spin_unlock_irqrestore (lock, flags); -/* -* We don't want to call the ordered free functions with the -* lock held though. Save the work as tag for the trace event, -* because the callback could free the structure. -*/ - wtag = work; - work->ordered_free (work); -trace_btrfs_all_work_done (wq->fs_info, wtag); +if (work == self) { +/* +* This is the work item that the worker is currently +* executing. +* +* The kernel workqueue code guarantees non-reentrancy +* of work items. I.e., if a work item with the same +* address and work function is queued twice, the second +* execution is blocked until the first one finishes. A +* work item may be freed and recycled with the same +* work function; the workqueue code assumes that the +* original work item cannot depend on the recycled work +* item in that case (see find_worker_executing_work()). +* +* Note that the work of one Btrfs filesystem may depend +* on the work of another Btrfs filesystem via, e.g., a +* loop device. Therefore, we must not allow the current +* work item to be recycled until we are really done, +* otherwise we break the above assumption and can +* deadlock. +*/ + free_self = true; + }else { +/* +* We don't want to call the ordered free functions with +* the lock held though. Save the work as tag for the +* trace event, because the callback could free the +* structure. +*/ + wtag = work; + work->ordered_free (work); +trace_btrfs_all_work_done (wq->fs_info, wtag); + } }spin_unlock_irqrestore (lock, flags); + +if (free_self) { + wtag = self; + self->ordered_free (self); +trace_btrfs_all_work_done (wq->fs_info, wtag); + } }static void normal_work_helper (struct btrfs_work *work)
@@ -324,7 +356,7 @@ static void normal_work_helper(struct btrfs_work *work) work->func (work);if (need_order) {set_bit (WORK_DONE_BIT , &work->flags); -run_ordered_work (wq); +run_ordered_work (wq, work); }if (!need_order)trace_btrfs_all_work_done (wq->fs_info, wtag);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 301/350 sched/uclamp: Fix overzealous type replacement
In reply to Sasha LevinFrom: Valentin Schneider <[email protected]>
[ Upstream commit 7763baace1b738d65efa46d68326c9406311c6bf ]
Some uclamp helpers had their return type changed from 'unsigned int' to 'enum uclamp_id' by commit
0413d7f33e60 ("sched/uclamp: Always use 'enum uclamp_id' for clamp_id values")
but it happens that some do return a value in the [0, SCHED_CAPACITY_SCALE] range, which should really be unsigned int. The affected helpers are uclamp_none(), uclamp_rq_max_value() and uclamp_eff_value(). Fix those up.
Note that this doesn't lead to any obj diff using a relatively recent aarch64 compiler (8.3-2019.03). The current code of e.g. uclamp_eff_value() properly returns an 11 bit value (bits_per(1024)) and doesn't seem to do anything funny. I'm still marking this as fixing the above commit to be on the safe side.
--- kernel/sched/core.c | 6 +++--- kernel/sched/sched.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -3
@@ -810,7 +810,7 @@ static inline unsigned int uclamp_bucket_base_value(unsigned int clamp_value)return UCLAMP_BUCKET_DELTA *uclamp_bucket_id (clamp_value); } -static inline enum uclamp_id uclamp_none (enum uclamp_id clamp_id) +static inline unsigned int uclamp_none (enum uclamp_id clamp_id) {if (clamp_id ==UCLAMP_MIN )return 0 ;
@@ -853,7 +853,7 @@ static inline void uclamp_idle_reset(struct rq *rq, enum uclamp_id clamp_id, }static inline -enum uclamp_id uclamp_rq_max_value (struct rq *rq,enum uclamp_id clamp_id, +unsigned int uclamp_rq_max_value (struct rq *rq,enum uclamp_id clamp_id,unsigned int clamp_value) {struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket;
@@ -918,7 +918,7 @@ uclamp_eff_get(struct task_struct *p, enum uclamp_id clamp_id)return uc_req; } -enum uclamp_id uclamp_eff_value (struct task_struct *p,enum uclamp_id clamp_id) +unsigned int uclamp_eff_value (struct task_struct *p,enum uclamp_id clamp_id) {struct uclamp_se uc_eff;
kernel/sched/sched.h +1 -1
@@ -2309,7 +2309,7 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {}#endif /* CONFIG_CPU_FREQ */ #ifdef CONFIG_UCLAMP_TASK -enum uclamp_id uclamp_eff_value (struct task_struct *p,enum uclamp_id clamp_id); +unsigned int uclamp_eff_value (struct task_struct *p,enum uclamp_id clamp_id); static __always_inline unsigned int uclamp_util_with(struct rq *rq, unsigned int util,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 302/350 ASoC: wm2200: add missed operations in remove and probe failure
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 2dab09be49a1e7a4dd13cb47d3a1441a2ef33a87 ]
This driver misses calls to pm_runtime_disable and regulator_bulk_disable in remove and a call to free_irq in probe failure.
Add the calls to fix it.
--- sound/soc/codecs/wm2200.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/codecs/wm2200.c +5 -0
@@ -2410,6 +2410,8 @@ static int wm2200_i2c_probe(struct i2c_client *i2c, err_pm_runtime:pm_runtime_disable (&i2c->dev); +if (i2c->irq) +free_irq (i2c->irq, wm2200); err_reset:if (wm2200->pdata.reset)gpio_set_value_cansleep (wm2200->pdata.reset,0 );
@@ -2426,12 +2428,15 @@ static int wm2200_i2c_remove(struct i2c_client *i2c) {struct wm2200_priv *wm2200 =i2c_get_clientdata (i2c); +pm_runtime_disable (&i2c->dev);if (i2c->irq)free_irq (i2c->irq, wm2200);if (wm2200->pdata.reset)gpio_set_value_cansleep (wm2200->pdata.reset,0 );if (wm2200->pdata.ldo_ena)gpio_set_value_cansleep (wm2200->pdata.ldo_ena,0 ); +regulator_bulk_disable (ARRAY_SIZE (wm2200->core_supplies), + wm2200->core_supplies);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 303/350 spi: st-ssc4: add missed pm_runtime_disable
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit cd050abeba2a95fe5374eec28ad2244617bcbab6 ]
The driver forgets to call pm_runtime_disable in probe failure and remove.
Add the missed calls to fix it.
--- drivers/spi/spi-st-ssc4.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/spi/spi-st-ssc4.c +3 -0
@@ -381,6 +381,7 @@ static int spi_st_probe(struct platform_device *pdev)return 0 ; clk_disable: +pm_runtime_disable (&pdev->dev);clk_disable_unprepare (spi_st->clk); put_master:spi_master_put (master);
@@ -392,6 +393,8 @@ static int spi_st_remove(struct platform_device *pdev)struct spi_master *master =platform_get_drvdata (pdev);struct spi_st *spi_st =spi_master_get_devdata (master); +pm_runtime_disable (&pdev->dev); +clk_disable_unprepare (spi_st->clk);pinctrl_pm_select_sleep_state (&pdev->dev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 304/350 ASoC: wm5100: add missed pm_runtime_disable
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit b1176bbb70866f24099cd2720283c7219fb4a81c ]
The driver forgets to call pm_runtime_disable in remove and probe failure.
Add the calls to fix it.
--- sound/soc/codecs/wm5100.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wm5100.c +2 -0
@@ -2617,6 +2617,7 @@ static int wm5100_i2c_probe(struct i2c_client *i2c,return ret; err_reset: +pm_runtime_disable (&i2c->dev);if (i2c->irq)free_irq (i2c->irq, wm5100);wm5100_free_gpio (i2c);
@@ -2640,6 +2641,7 @@ static int wm5100_i2c_remove(struct i2c_client *i2c) {struct wm5100_priv *wm5100 =i2c_get_clientdata (i2c); +pm_runtime_disable (&i2c->dev);if (i2c->irq)free_irq (i2c->irq, wm5100);wm5100_free_gpio (i2c);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 305/350 perf/core: Fix the mlock accounting, again
In reply to Sasha LevinFrom: Alexander Shishkin <[email protected]>
[ Upstream commit 36b3db03b4741b8935b68fffc7e69951d8d70a89 ]
Commit:
5e6c3c7b1ec2 ("perf/aux: Fix tracking of auxiliary trace buffer allocation")
tried to guess the correct combination of arithmetic operations that would undo the AUX buffer's mlock accounting, and failed, leaking the bottom part when an allocation needs to be charged partially to both user->locked_vm and mm->pinned_vm, eventually leaving the user with no locked bonus:
$ perf record -e intel_pt//u -m1,128 uname [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.061 MB perf.data ]
$ perf record -e intel_pt//u -m1,128 uname Permission error mapping pages. Consider increasing /proc/sys/kernel/perf_event_mlock_kb, or try again with a smaller value of -m/--mmap_pages. (current value: 1,128)
Fix this by subtracting both locked and pinned counts when AUX buffer is unmapped.
--- kernel/events/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/events/core.c +2 -4
@@ -5607,10 +5607,8 @@ static void perf_mmap_close(struct vm_area_struct *vma)perf_pmu_output_stop (event);/* now it's safe to free the pages */ -if (!rb->aux_mmap_locked) -atomic_long_sub (rb->aux_nr_pages, &mmap_user->locked_vm); -else -atomic64_sub (rb->aux_mmap_locked, &vma->vm_mm->pinned_vm); +atomic_long_sub (rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->locked_vm); +atomic64_sub (rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);/* this has to be the last one */ rb_free_aux (rb);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 306/350 selftests, bpf: Fix test_tc_tunnel hanging
In reply to Sasha LevinFrom: Jiri Benc <[email protected]>
[ Upstream commit 3b054b7133b4ad93671c82e8d6185258e3f1a7a5 ]
When run_kselftests.sh is run, it hangs after test_tc_tunnel.sh. The reason is test_tc_tunnel.sh ensures the server ('nc -l') is run all the time, starting it again every time it is expected to terminate. The exception is the final client_connect: the server is not started anymore, which ensures no process is kept running after the test is finished.
For a sit test, though, the script is terminated prematurely without the final client_connect and the 'nc' process keeps running. This in turn causes the run_one function in kselftest/runner.sh to hang forever, waiting for the runaway process to finish.
Ensure a remaining server is terminated on cleanup.
--- tools/testing/selftests/bpf/test_tc_tunnel.sh | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/bpf/test_tc_tunnel.sh +5 -0
@@ -62,6 +62,10 @@ cleanup() { if [[ -f "${infile}" ]]; then rm "${infile}" fi + + if [[ -n $server_pid ]]; then + kill $server_pid 2> /dev/null + fi } server_listen() {
@@ -77,6 +81,7 @@ client_connect() { verify_data() { wait "${server_pid}" + server_pid= # sha1sum returns two fields [sha1] [filepath] # convert to bash array and access first elem insum=($(sha1sum ${infile}))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 307/350 selftests, bpf: Workaround an alu32 sub-register spilling issue
In reply to Sasha LevinFrom: Yonghong Song <[email protected]>
[ Upstream commit 2ea2612b987ad703235c92be21d4e98ee9c2c67c ]
Currently, with latest llvm trunk, selftest test_progs failed obj file test_seg6_loop.o with the following error in verifier:
infinite loop detected at insn 76
The byte code sequence looks like below, and noted that alu32 has been turned off by default for better generated codes in general:
48: w3 = 100
49: *(u32 *)(r10 - 68) = r3
...
; if (tlv.type == SR6_TLV_PADDING) {
76: if w3 == 5 goto -18 <LBB0_19>
...
85: r1 = *(u32 *)(r10 - 68)
; for (int i = 0; i < 100; i++) {
86: w1 += -1
87: if w1 == 0 goto +5 <LBB0_20>
88: *(u32 *)(r10 - 68) = r1The main reason for verification failure is due to partial spills at r10 - 68 for induction variable "i".
Current verifier only handles spills with 8-byte values. The above 4-byte value spill to stack is treated to STACK_MISC and its content is not saved. For the above example:
w3 = 100
R3_w=inv100 fp-64_w=inv1086626730498
*(u32 *)(r10 - 68) = r3
R3_w=inv100 fp-64_w=inv1086626730498
...
r1 = *(u32 *)(r10 - 68)
R1_w=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff))
fp-64=inv1086626730498To resolve this issue, verifier needs to be extended to track sub-registers in spilling, or llvm needs to enhanced to prevent sub-register spilling in register allocation phase. The former will increase verifier complexity and the latter will need some llvm "hacking".
Let us workaround this issue by declaring the induction variable as "long" type so spilling will happen at non sub-register level. We can revisit this later if sub-register spilling causes similar or other verification issues.
--- tools/testing/selftests/bpf/progs/test_seg6_loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/test_seg6_loop.c +3 -1
@@ -132,8 +132,10 @@ static __always_inline int is_valid_tlv_boundary(struct __sk_buff *skb, *pad_off =0 ;// we can only go as far as ~10 TLVs due to the BPF max stack size +// workaround: define induction variable "i" as "long" instead +// of "int" to prevent alu32 sub-register spilling. #pragma clang loop unroll(disable) -for (int i =0 ; i <100 ; i++) { +for (long i =0 ; i <100 ; i++) {struct sr6_tlv_t tlv;if (cur_off == *tlv_off)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 308/350 bnxt_en: Return proper error code for non-existent NVM variable
In reply to Sasha LevinFrom: Vasundhara Volam <[email protected]>
[ Upstream commit 05069dd4c577f9b143dfd243d55834333c4470c5 ]
For NVM params that are not supported in the current NVM configuration, return the error as -EOPNOTSUPP.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +8 -1
@@ -311,10 +311,17 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg, }else { rc =hwrm_send_message_silent (bp, msg, msg_len,HWRM_CMD_TIMEOUT ); -if (!rc) +if (!rc) {bnxt_copy_from_nvm_data (val, data, nvm_param.nvm_num_bits, nvm_param.dl_num_bytes); + }else { +struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; + +if (resp->cmd_err == +NVM_GET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST ) + rc = -EOPNOTSUPP ; + } }dma_free_coherent (&bp->pdev->dev,sizeof (*data), data, data_dma_addr);if (rc == -EACCES )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 309/350 net: phy: avoid matching all-ones clause 45 PHY IDs
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit b95e86d846b63b02ecdc94802ddbeaf9005fb6d9 ]
We currently match clause 45 PHYs using any ID read from a MMD marked as present in the "Devices in package" registers 5 and 6. However, this is incorrect. 45.2 says:
"The definition of the term package is vendor specific and could be
a chip, module, or other similar entity."
so a package could be more or less than the whole PHY - a PHY could be made up of several modules instantiated onto a single chip such as the Marvell 88x3310, or some of the MMDs could be disabled according to chip configuration, such as the Broadcom 84881.
In the case of Broadcom 84881, the "Devices in package" registers contain 0xc000009b, meaning that there is a PHYXS present in the package, but all registers in MMD 4 return 0xffff. This leads to our matching code incorrectly binding this PHY to one of our generic PHY drivers.
This patch changes the way we determine whether to attempt to match a MMD identifier, or use it to request a module - if the identifier is all-ones, then we skip over it. When reading the identifiers, we initialise phydev->c45_ids.device_ids to all-ones, only reading the device ID if the "Devices in package" registers indicates we should.
This avoids the generic drivers incorrectly matching on a PHY ID of 0xffffffff.
--- drivers/net/phy/phy_device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/phy/phy_device.c +6 -3
@@ -488,7 +488,7 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)if (phydev->is_c45) {for (i =1 ; i < num_ids; i++) { -if (!(phydev->c45_ids.devices_in_package & (1 << i))) +if (phydev->c45_ids.device_ids[i] ==0xffffffff )continue ; if ((phydrv->phy_id & phydrv->phy_id_mask) ==
@@ -632,7 +632,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,int i;for (i =1 ; i < num_ids; i++) { -if (!(c45_ids->devices_in_package & (1 << i))) +if (c45_ids->device_ids[i] ==0xffffffff )continue ; ret = phy_request_driver_module(dev,
@@ -812,10 +812,13 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,*/ struct phy_device *get_phy_device (struct mii_bus *bus,int addr,bool is_c45) { -struct phy_c45_device_ids c45_ids = {0 }; +struct phy_c45_device_ids c45_ids;u32 phy_id =0 ;int r; + c45_ids.devices_in_package =0 ; +memset (c45_ids.device_ids,0xff ,sizeof (c45_ids.device_ids)); + r =get_phy_id (bus, addr, &phy_id, is_c45, &c45_ids);if (r)return ERR_PTR (r);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 310/350 firmware_loader: Fix labels with comma for builtin firmware
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
[ Upstream commit 553671b7685972ca671da5f71cf6414b54376e13 ]
Some firmware images contain a comma, such as:EXTRA_FIRMWARE "brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt" as Broadcom firmware simply tags the device tree compatible string at the end of the firmware parameter file. And the compatible string contains a comma.
This doesn't play well with gas:
drivers/base/firmware_loader/builtin/brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt.gen.S: Assembler messages:drivers/base/firmware_loader/builtin/brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt.gen.S:4: Error: bad instruction _fw_brcm_brcmfmac4334_sdio_samsung,gt_s7710_txt_bin:' drivers/base/firmware_loader/builtin/brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt.gen.S:9: Error: bad instruction _fw_brcm_brcmfmac4334_sdio_samsung,gt_s7710_txt_name:' drivers/base/firmware_loader/builtin/brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt.gen.S:15: Error: can't resolve .rodata' {.rodata section} - _fw_brcm_brcmfmac4334_sdio_samsung' {*UND* section} make[6]: *** [../scripts/Makefile.build:357: drivers/base/firmware_loader/builtin/brcm/brcmfmac4334-sdio.samsung,gt-s7710.txt.gen.o] Error 1
We need to get rid of the comma from the labels used by the assembly stub generator.
Replacing a comma using GNU Make subst requires a helper variable.
--- drivers/base/firmware_loader/builtin/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/firmware_loader/builtin/Makefile +2 -1
@@ -8,7 +8,8 @@ fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE))) FWNAME = $(patsubst $(obj)/%.gen.S,%,$@) -FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME)))) +comma := , +FWSTR = $(subst $(comma),_,$(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))) ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long) ASM_ALIGN = $(if $(CONFIG_64BIT),3,2) PROGBITS = $(if $(CONFIG_ARM),%,@)progbits
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 311/350 ASoC: Intel: bytcr_rt5640: Update quirk for Acer Switch 10 SW5-012 2-in-1
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 0bb887709eb16bdc4b5baddd8337abf3de72917f ]
When the Acer Switch 10 SW5-012 quirk was added we did not have jack-detection support yet; and the builtin microphone selection of the original quirk is wrong too.
Fix the microphone-input quirk and add jack-detection info so that the internal-microphone and headphone/set jack on the Switch 10 work properly.
--- sound/soc/intel/boards/bytcr_rt5640.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/soc/intel/boards/bytcr_rt5640.c +6 -4
@@ -405,10 +405,12 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), }, - .driver_data = (void *)(BYT_RT5640_IN1_MAP | -BYT_RT5640_MCLK_EN | -BYT_RT5640_SSP0_AIF1 ), - + .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | +BYT_RT5640_JD_SRC_JD2_IN4N | +BYT_RT5640_OVCD_TH_2000UA | +BYT_RT5640_OVCD_SF_0P75 | +BYT_RT5640_SSP0_AIF1 | + BYT_RT5640_MCLK_EN), }, { .matches = {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 312/350 x86/insn: Add some Intel instructions to the opcode map
In reply to Sasha LevinFrom: Adrian Hunter <[email protected]>
[ Upstream commit b980be189c9badba50634671e2303e92bf28e35a ]
Add to the opcode map the following instructions:
cldemote
tpause
umonitor
umwait
movdiri
movdir64b
enqcmd
enqcmds
encls
enclu
enclv
pconfig
wbnoinvd
For information about the instructions, refer Intel SDM May 2019 (325462-070US) and Intel Architecture Instruction Set Extensions May 2019 (319433-037).
The instruction decoding can be tested using the perf tools' "x86 instruction decoder - new instructions" test as folllows:
$ perf test -v "new " 2>&1 | grep -i cldemote Decoded ok: 0f 1c 00 cldemote (%eax) Decoded ok: 0f 1c 05 78 56 34 12 cldemote 0x12345678 Decoded ok: 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%eax,%ecx,8) Decoded ok: 0f 1c 00 cldemote (%rax) Decoded ok: 41 0f 1c 00 cldemote (%r8) Decoded ok: 0f 1c 04 25 78 56 34 12 cldemote 0x12345678 Decoded ok: 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%rax,%rcx,8) Decoded ok: 41 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%r8,%rcx,8) $ perf test -v "new " 2>&1 | grep -i tpause Decoded ok: 66 0f ae f3 tpause %ebx Decoded ok: 66 0f ae f3 tpause %ebx Decoded ok: 66 41 0f ae f0 tpause %r8d $ perf test -v "new " 2>&1 | grep -i umonitor Decoded ok: 67 f3 0f ae f0 umonitor %ax Decoded ok: f3 0f ae f0 umonitor %eax Decoded ok: 67 f3 0f ae f0 umonitor %eax Decoded ok: f3 0f ae f0 umonitor %rax Decoded ok: 67 f3 41 0f ae f0 umonitor %r8d $ perf test -v "new " 2>&1 | grep -i umwait Decoded ok: f2 0f ae f0 umwait %eax Decoded ok: f2 0f ae f0 umwait %eax Decoded ok: f2 41 0f ae f0 umwait %r8d $ perf test -v "new " 2>&1 | grep -i movdiri Decoded ok: 0f 38 f9 03 movdiri %eax,(%ebx) Decoded ok: 0f 38 f9 88 78 56 34 12 movdiri %ecx,0x12345678(%eax) Decoded ok: 48 0f 38 f9 03 movdiri %rax,(%rbx) Decoded ok: 48 0f 38 f9 88 78 56 34 12 movdiri %rcx,0x12345678(%rax) $ perf test -v "new " 2>&1 | grep -i movdir64b Decoded ok: 66 0f 38 f8 18 movdir64b (%eax),%ebx Decoded ok: 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%eax),%ecx Decoded ok: 67 66 0f 38 f8 1c movdir64b (%si),%bx Decoded ok: 67 66 0f 38 f8 8c 34 12 movdir64b 0x1234(%si),%cx Decoded ok: 66 0f 38 f8 18 movdir64b (%rax),%rbx Decoded ok: 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%rax),%rcx Decoded ok: 67 66 0f 38 f8 18 movdir64b (%eax),%ebx Decoded ok: 67 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%eax),%ecx $ perf test -v "new " 2>&1 | grep -i enqcmd Decoded ok: f2 0f 38 f8 18 enqcmd (%eax),%ebx Decoded ok: f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%eax),%ecx Decoded ok: 67 f2 0f 38 f8 1c enqcmd (%si),%bx Decoded ok: 67 f2 0f 38 f8 8c 34 12 enqcmd 0x1234(%si),%cx Decoded ok: f3 0f 38 f8 18 enqcmds (%eax),%ebx Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx Decoded ok: 67 f3 0f 38 f8 1c enqcmds (%si),%bx Decoded ok: 67 f3 0f 38 f8 8c 34 12 enqcmds 0x1234(%si),%cx Decoded ok: f2 0f 38 f8 18 enqcmd (%rax),%rbx Decoded ok: f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%rax),%rcx Decoded ok: 67 f2 0f 38 f8 18 enqcmd (%eax),%ebx Decoded ok: 67 f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%eax),%ecx Decoded ok: f3 0f 38 f8 18 enqcmds (%rax),%rbx Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%rax),%rcx Decoded ok: 67 f3 0f 38 f8 18 enqcmds (%eax),%ebx Decoded ok: 67 f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx $ perf test -v "new " 2>&1 | grep -i enqcmds Decoded ok: f3 0f 38 f8 18 enqcmds (%eax),%ebx Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx Decoded ok: 67 f3 0f 38 f8 1c enqcmds (%si),%bx Decoded ok: 67 f3 0f 38 f8 8c 34 12 enqcmds 0x1234(%si),%cx Decoded ok: f3 0f 38 f8 18 enqcmds (%rax),%rbx Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%rax),%rcx Decoded ok: 67 f3 0f 38 f8 18 enqcmds (%eax),%ebx Decoded ok: 67 f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx $ perf test -v "new " 2>&1 | grep -i encls Decoded ok: 0f 01 cf encls Decoded ok: 0f 01 cf encls $ perf test -v "new " 2>&1 | grep -i enclu Decoded ok: 0f 01 d7 enclu Decoded ok: 0f 01 d7 enclu $ perf test -v "new " 2>&1 | grep -i enclv Decoded ok: 0f 01 c0 enclv Decoded ok: 0f 01 c0 enclv $ perf test -v "new " 2>&1 | grep -i pconfig Decoded ok: 0f 01 c5 pconfig Decoded ok: 0f 01 c5 pconfig $ perf test -v "new " 2>&1 | grep -i wbnoinvd Decoded ok: f3 0f 09 wbnoinvd Decoded ok: f3 0f 09 wbnoinvd
--- arch/x86/lib/x86-opcode-map.txt | 18 ++++++++++++------ tools/arch/x86/lib/x86-opcode-map.txt | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-)
arch/x86/lib/x86-opcode-map.txt +12 -6
@@ -333,7 +333,7 @@ AVXcode: 1 06: CLTS 07: SYSRET (o64) 08: INVD -09: WBINVD +09: WBINVD | WBNOINVD (F3) 0a: 0b: UD2 (1B) 0c:
@@ -364,7 +364,7 @@ AVXcode: 1 # a ModR/M byte. 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv -1c: +1c: Grp20 (1A),(1C) 1d: 1e: 1f: NOP Ev
@@ -792,6 +792,8 @@ f3: Grp17 (1A) f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v) +f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3) +f9: MOVDIRI My,Gy EndTable Table: 3-byte opcode 2 (0x0f 0x3a)
@@ -943,9 +945,9 @@ GrpTable: Grp6 EndTable GrpTable: Grp7 -0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) -1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) -2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) +0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B) +1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B) +2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B) 3: LIDT Ms 4: SMSW Mw/Rv 5: rdpkru (110),(11B) | wrpkru (111),(11B)
@@ -1020,7 +1022,7 @@ GrpTable: Grp15 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B) 4: XSAVE | ptwrite Ey (F3),(11B) 5: XRSTOR | lfence (11B) -6: XSAVEOPT | clwb (66) | mfence (11B) +6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B) 7: clflush | clflushopt (66) | sfence (11B) EndTable
@@ -1051,6 +1053,10 @@ GrpTable: Grp19 6: vscatterpf1qps/d Wx (66),(ev) EndTable +GrpTable: Grp20 +0: cldemote Mb +EndTable + # AMD's Prefetch Group GrpTable: GrpP 0: PREFETCH
tools/arch/x86/lib/x86-opcode-map.txt +12 -6
@@ -333,7 +333,7 @@ AVXcode: 1 06: CLTS 07: SYSRET (o64) 08: INVD -09: WBINVD +09: WBINVD | WBNOINVD (F3) 0a: 0b: UD2 (1B) 0c:
@@ -364,7 +364,7 @@ AVXcode: 1 # a ModR/M byte. 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv -1c: +1c: Grp20 (1A),(1C) 1d: 1e: 1f: NOP Ev
@@ -792,6 +792,8 @@ f3: Grp17 (1A) f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v) +f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3) +f9: MOVDIRI My,Gy EndTable Table: 3-byte opcode 2 (0x0f 0x3a)
@@ -943,9 +945,9 @@ GrpTable: Grp6 EndTable GrpTable: Grp7 -0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) -1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) -2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) +0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B) +1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B) +2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B) 3: LIDT Ms 4: SMSW Mw/Rv 5: rdpkru (110),(11B) | wrpkru (111),(11B)
@@ -1020,7 +1022,7 @@ GrpTable: Grp15 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B) 4: XSAVE | ptwrite Ey (F3),(11B) 5: XRSTOR | lfence (11B) -6: XSAVEOPT | clwb (66) | mfence (11B) +6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B) 7: clflush | clflushopt (66) | sfence (11B) EndTable
@@ -1051,6 +1053,10 @@ GrpTable: Grp19 6: vscatterpf1qps/d Wx (66),(ev) EndTable +GrpTable: Grp20 +0: cldemote Mb +EndTable + # AMD's Prefetch Group GrpTable: GrpP 0: PREFETCH
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 313/350 net-af_xdp: Use correct number of channels from ethtool
In reply to Sasha LevinFrom: Luigi Rizzo <[email protected]>
[ Upstream commit 3de88c9113f88c04abda339f1aa629397bf89e02 ]
Drivers use different fields to report the number of channels, so take the maximum of all data channels (rx, tx, combined) when determining the size of the xsk map. The current code used only 'combined' which was set to 0 in some drivers e.g. mlx4.
Tested: compiled and run xdpsock -q 3 -r -S on mlx4
--- tools/lib/bpf/xsk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/lib/bpf/xsk.c +8 -3
@@ -344,13 +344,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) goto out; } -if (err || channels.max_combined ==0 ) +if (err) {/* If the device says it has no channels, then all traffic * is sent to a single stream, so max queues = 1. */ ret =1 ; -else - ret = channels.max_combined; + }else { +/* Take the max of rx, tx, combined. Drivers return +* the number of channels in different ways. +*/ + ret =max (channels.max_rx, channels.max_tx); + ret =max (ret, (int )channels.max_combined); + } out:close (fd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 314/350 brcmfmac: remove monitor interface when detaching
In reply to Sasha LevinFrom: Rafał Miłecki <[email protected]>
[ Upstream commit 4f61563da075bc8faefddfd5f8fc0cc14c49650a ]
This fixes a minor WARNING in the cfg80211:
[ 130.658034] ------------[ cut here ]------------ [ 130.662805] WARNING: CPU: 1 PID: 610 at net/wireless/core.c:954 wiphy_unregister+0xb4/0x198 [cfg80211]
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +5 -0
@@ -1350,6 +1350,11 @@ void brcmf_detach(struct device *dev)brcmf_fweh_detach (drvr);brcmf_proto_detach (drvr); +if (drvr->mon_if) { +brcmf_net_detach (drvr->mon_if->ndev, false); + drvr->mon_if =NULL ; + } +/* make sure primary interface removed last */ for (i =BRCMF_MAX_IFS -1 ; i >-1 ; i--) {if (drvr->iflist[i])
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 315/350 perf session: Fix decompression of PERF_RECORD_COMPRESSED records
In reply to Sasha LevinFrom: Alexey Budankov <[email protected]>
[ Upstream commit bb1835a3b86c73aa534ef6430ad40223728dfbc0 ]
Avoid termination of trace loading in case the last record in the decompressed buffer partly resides in the following mmaped PERF_RECORD_COMPRESSED record.
In this case NULL value returned by fetch_mmaped_event() means to proceed to the next mmaped record then decompress it and load compressed events.
The issue can be reproduced like this:
$ perf record -z -- some_long_running_workload $ perf report --stdio -vv decomp (B): 44519 to 163000 decomp (B): 48119 to 174800 decomp (B): 65527 to 131072 fetch_mmaped_event: head=0x1ffe0 event->header_size=0x28, mmap_size=0x20000: fuzzed perf.data? Error: failed to process sample ...
Testing:
71: Zstd perf.data compression/decompression : Ok
$ tools/perf/perf report -vv --stdio decomp (B): 59593 to 262160 decomp (B): 4438 to 16512 decomp (B): 285 to 880 Looking at the vmlinux_path (8 entries long) Using vmlinux for symbols decomp (B): 57474 to 261248 prefetch_event: head=0x3fc78 event->header_size=0x28, mmap_size=0x3fc80: fuzzed or compressed perf.data? decomp (B): 25 to 32 decomp (B): 52 to 120 ...
--- tools/perf/util/session.c | 44 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-)
tools/perf/util/session.c +27 -17
@@ -1954,8 +1954,8 @@ static int __perf_session__process_pipe_events(struct perf_session *session) }static union perf_event * -fetch_mmaped_event (struct perf_session *session, -u64 head,size_t mmap_size,char *buf) +prefetch_event (char *buf,u64 head,size_t mmap_size, +bool needs_swap,union perf_event *error) {union perf_event *event;
@@ -1967,20 +1967,32 @@ fetch_mmaped_event(struct perf_session *session,return NULL ; event = (union perf_event *)(buf + head); +if (needs_swap) +perf_event_header__bswap (&event->header); -if (session->header.needs_swap) +if (head + event->header.size <= mmap_size) +return event; + +/* We're not fetching the event so swap back again */ +if (needs_swap)perf_event_header__bswap (&event->header); -if (head + event->header.size > mmap_size) { -/* We're not fetching the event so swap back again */ -if (session->header.needs_swap) -perf_event_header__bswap (&event->header); -pr_debug ("%s: head=%#" PRIx64" event->header_size=%#x, mmap_size=%#zx: fuzzed perf.data?\n" , - __func__, head, event->header.size, mmap_size); -return ERR_PTR (-EINVAL ); - } +pr_debug ("%s: head=%#" PRIx64" event->header_size=%#x, mmap_size=%#zx:" +" fuzzed or compressed perf.data?\n" ,__func__, head, event->header.size, mmap_size); -return event; +return error; +} + +static union perf_event * +fetch_mmaped_event (u64 head,size_t mmap_size,char *buf,bool needs_swap) +{ +return prefetch_event (buf, head, mmap_size, needs_swap,ERR_PTR (-EINVAL )); +} + +static union perf_event * +fetch_decomp_event (u64 head,size_t mmap_size,char *buf,bool needs_swap) +{ +return prefetch_event (buf, head, mmap_size, needs_swap,NULL ); }static int __perf_session__process_decomp_events (struct perf_session *session)
@@ -1993,10 +2005,8 @@ static int __perf_session__process_decomp_events(struct perf_session *session)return 0 ;while (decomp->head < decomp->size && !session_done ()) { -union perf_event *event =fetch_mmaped_event (session, decomp->head, decomp->size, decomp->data); - -if (IS_ERR (event)) -return PTR_ERR (event); +union perf_event *event =fetch_decomp_event (decomp->head, decomp->size, decomp->data, + session->header.needs_swap);if (!event)break ;
@@ -2096,7 +2106,7 @@ reader__process_events(struct reader *rd, struct perf_session *session, } more: - event =fetch_mmaped_event (session, head, mmap_size, buf); + event =fetch_mmaped_event (head, mmap_size, buf, session->header.needs_swap);if (IS_ERR (event))return PTR_ERR (event);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 316/350 int128: move __uint128_t compiler test to Kconfig
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit c12d3362a74bf0cd9e1d488918d40607b62a3104 ]
In order to use 128-bit integer arithmetic in C code, the architecture needs to have declared support for it by setting ARCH_SUPPORTS_INT128, and it requires a version of the toolchain that supports this at build time. This is why all existing tests for ARCH_SUPPORTS_INT128 also test whether __SIZEOF_INT128__ is defined, since this is only the case for compilers that can support 128-bit integers.
Let's fold this additional test into the Kconfig declaration of ARCH_SUPPORTS_INT128 so that we can also use the symbol in Makefiles, e.g., to decide whether a certain object needs to be included in the first place.
--- arch/arm64/Kconfig | 2 +- arch/riscv/Kconfig | 2 +- arch/x86/Kconfig | 2 +- crypto/ecc.c | 2 +- init/Kconfig | 4 ++++ lib/ubsan.c | 2 +- lib/ubsan.h | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -67,7 +67,7 @@ config ARM64 select ARCH_USE_QUEUED_SPINLOCKS select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_SUPPORTS_ATOMIC_RMW - select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && (GCC_VERSION >= 50000 || CC_IS_CLANG) select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
arch/riscv/Kconfig +1 -1
@@ -164,7 +164,7 @@ config ARCH_RV32I config ARCH_RV64I bool "RV64I" select 64BIT - select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000 select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FTRACE_MCOUNT_RECORD
arch/x86/Kconfig +1 -1
@@ -24,7 +24,7 @@ config X86_64 depends on 64BIT # Options that are inherently 64-bit kernel only: select ARCH_HAS_GIGANTIC_PAGE - select ARCH_SUPPORTS_INT128 + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_SOFT_DIRTY select MODULES_USE_ELF_RELA
crypto/ecc.c +1 -1
@@ -336,7 +336,7 @@ static u64 vli_usub(u64 *result, const u64 *left, u64 right,static uint128_t mul_64_64 (u64 left,u64 right) {uint128_t result; -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )unsigned __int128 m = (unsigned __int128 )left * right; result.m_low = m;
init/Kconfig +4 -0
@@ -785,6 +785,10 @@ config ARCH_SUPPORTS_NUMA_BALANCING config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH bool +config CC_HAS_INT128 + def_bool y + depends on !$(cc-option,-D__SIZEOF_INT128__=0) + # # For architectures that know their GCC __int128 support is sound #
lib/ubsan.c +1 -1
@@ -119,7 +119,7 @@ static void val_to_string(char *str, size_t size, struct type_descriptor *type, {if (type_is_int (type)) {if (type_bit_width (type) ==128 ) { -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )u_max val =get_unsigned_val (type, value); scnprintf(str, size, "0x%08x%08x%08x%08x",
lib/ubsan.h +1 -1
@@ -78,7 +78,7 @@ struct invalid_value_data {struct type_descriptor *type; }; -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )typedef __int128 s_max ;typedef unsigned __int128 u_max ;#else
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.4 316/350] int128: move __uint128_t compiler test to Kconfig
Quoted 17 lines · Sasha Levin
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
c12d3362a74bf0cd9e1d488918d40607b62a3104]In order to use 128-bit integer arithmetic in C code, the architecture needs to have declared support for it by setting
ARCH_SUPPORTS_INT128, and it requires a version of the toolchain that supports this at build time. This is why all existing tests forARCH_SUPPORTS_INT128also test whether__SIZEOF_INT128__is defined, since this is only the case for compilers that can support 128-bit integers.Let's fold this additional test into the
Kconfigdeclaration ofARCH_SUPPORTS_INT128so that we can also use the symbol in Makefiles, e.g., to decide whether a certain object needs to be included in the first place.
Quoted 4 lines
Cc Masahiro Yamada <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Signed-off-by Herbert Xu <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This does not fix a bug so no need to put it in -stable
Quoted 106 lines
--- arch/arm64/Kconfig | 2 +- arch/riscv/Kconfig | 2 +- arch/x86/Kconfig | 2 +- crypto/ecc.c | 2 +- init/Kconfig | 4 ++++ lib/ubsan.c | 2 +- lib/ubsan.h | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-)arch/arm64/Kconfig +1
-1@@ -67,7 +67,7 @@ config ARM64 select ARCH_USE_QUEUED_SPINLOCKS select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_SUPPORTS_ATOMIC_RMW - select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && (GCC_VERSION >= 50000 || CC_IS_CLANG) select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUTarch/riscv/Kconfig +1
-1@@ -164,7 +164,7 @@ config ARCH_RV32I config ARCH_RV64I bool "RV64I" select 64BIT - select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000 select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FTRACE_MCOUNT_RECORDarch/x86/Kconfig +1
-1@@ -24,7 +24,7 @@ config X86_64 depends on 64BIT # Options that are inherently 64-bit kernel only: select ARCH_HAS_GIGANTIC_PAGE - select ARCH_SUPPORTS_INT128 + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_SOFT_DIRTY select MODULES_USE_ELF_RELAcrypto/ecc.c +1
-1@@ -336,7 +336,7 @@ static u64 vli_usub(u64 *result, const u64 *left, u64 right,static uint128_t mul_64_64 (u64 left,u64 right) {uint128_t result; -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )unsigned __int128 m = (unsigned __int128 )left * right; result.m_low = m;init/Kconfig +4
-0@@ -785,6 +785,10 @@ config ARCH_SUPPORTS_NUMA_BALANCING config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH bool +config CC_HAS_INT128 + def_bool y + depends on !$(cc-option,-D__SIZEOF_INT128__=0) + # # For architectures that know their GCC __int128 support is sound #lib/ubsan.c +1
-1@@ -119,7 +119,7 @@ static void val_to_string(char *str, size_t size, struct type_descriptor *type, {if (type_is_int (type)) {if (type_bit_width (type) ==128 ) { -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )u_max val =get_unsigned_val (type, value); scnprintf(str, size, "0x%08x%08x%08x%08x",lib/ubsan.h +1
-2@@ -78,7 +78,7 @@ struct invalid_value_data {struct type_descriptor *type; }; -#if defined(CONFIG_ARCH_SUPPORTS_INT128 ) && defined(__SIZEOF_INT128__) +#if defined(CONFIG_ARCH_SUPPORTS_INT128 )typedef __int128 s_max ;typedef unsigned __int128 u_max ;#else --2.20.1
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.4 316/350] int128: move __uint128_t compiler test to Kconfig
Quoted 18 lines · Ard Biesheuvel
Quoted 17 lines · Sasha Levin
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
c12d3362a74bf0cd9e1d488918d40607b62a3104]In order to use 128-bit integer arithmetic in C code, the architecture needs to have declared support for it by setting
ARCH_SUPPORTS_INT128, and it requires a version of the toolchain that supports this at build time. This is why all existing tests forARCH_SUPPORTS_INT128also test whether__SIZEOF_INT128__is defined, since this is only the case for compilers that can support 128-bit integers.Let's fold this additional test into the
Kconfigdeclaration ofARCH_SUPPORTS_INT128so that we can also use the symbol in Makefiles, e.g., to decide whether a certain object needs to be included in the first place.
Quoted 6 lines
Quoted 4 lines
Cc Masahiro Yamada <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Signed-off-by Herbert Xu <[email protected]>Signed-off-by Sasha Levin <[email protected]>This does not fix a bug so no need to put it in -stable
Dropped, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 317/350 s390/crypto: Fix unsigned variable compared with zero
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 0398d4ab1677f7d8cd43aac2aa29a93dfcf9e2e3 ]
s390_crypto_shash_parmsize() return type is int, it should not be stored in a unsigned variable, which compared with zero.
--- arch/s390/crypto/sha_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/s390/crypto/sha_common.c +5 -2
@@ -74,14 +74,17 @@ int s390_sha_final(struct shash_desc *desc, u8 *out)struct s390_sha_ctx *ctx =shash_desc_ctx (desc);unsigned int bsize =crypto_shash_blocksize (desc->tfm);u64 bits; -unsigned int n, mbl_offset; +unsigned int n; +int mbl_offset; n = ctx->count % bsize; bits = ctx->count *8 ; - mbl_offset =s390_crypto_shash_parmsize (ctx->func) /sizeof (u32); + mbl_offset =s390_crypto_shash_parmsize (ctx->func);if (mbl_offset <0 )return -EINVAL ; + mbl_offset = mbl_offset /sizeof (u32); +/* set total msg bit length (mbl) in CPACF parmblock */ switch (ctx->func) {case CPACF_KLMD_SHA_1 :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 318/350 s390/kasan: support memcpy_real with TRACE_IRQFLAGS
In reply to Sasha LevinFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 13f9bae579c6bd051e58f326913dd09af1291208 ]
Currently if the kernel is built with CONFIG_TRACE_IRQFLAGS and KASAN and used as crash kernel it crashes itself due to trace_hardirqs_off/trace_hardirqs_on being called with DAT off. This happens because trace_hardirqs_off/trace_hardirqs_on are instrumented and kasan code tries to perform access to shadow memory to validate memory accesses. Kasan shadow memory is populated with vmemmap, so all accesses require DAT on.
memcpy_real could be called with DAT on or off (with kasan enabled DAT is set even before early code is executed).
Make sure that trace_hardirqs_off/trace_hardirqs_on are called with DAT on and only actual __memcpy_real is called with DAT off.
Also annotate __memcpy_real and _memcpy_real with __no_sanitize_address to avoid further problems due to switching DAT off.
--- arch/s390/mm/maccess.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/s390/mm/maccess.c +8 -4
@@ -70,7 +70,7 @@ void notrace s390_kernel_write(void *dst, const void *src, size_t size)spin_unlock_irqrestore (&s390_kernel_write_lock, flags); } -static int __memcpy_real (void *dest,void *src,size_t count) +static int __no_sanitize_address __memcpy_real(void *dest, void *src, size_t count) { register unsigned long _dest asm("2") = (unsigned long) dest; register unsigned long _len1 asm("3") = (unsigned long) count;
@@ -91,19 +91,23 @@ static int __memcpy_real(void *dest, void *src, size_t count)return rc; } -static unsigned long _memcpy_real (unsigned long dest,unsigned long src, -unsigned long count) +static unsigned long __no_sanitize_address _memcpy_real (unsigned long dest, +unsigned long src, +unsigned long count) {int irqs_disabled, rc;unsigned long flags;if (!count)return 0 ; - flags =__arch_local_irq_stnsm (0xf8UL ); + flags =arch_local_irq_save (); irqs_disabled =arch_irqs_disabled_flags (flags);if (!irqs_disabled)trace_hardirqs_off (); +__arch_local_irq_stnsm (0xf8 );// disable DAT rc =__memcpy_real ((void *) dest, (void *) src, (size_t ) count); +if (flags &PSW_MASK_DAT ) +__arch_local_irq_stosm (0x04 );// enable DAT if (!irqs_disabled)trace_hardirqs_on ();__arch_local_irq_ssm (flags);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 319/350 bnxt_en: Improve RX buffer error handling.
In reply to Sasha LevinFrom: Michael Chan <[email protected]>
[ Upstream commit 19b3751ffa713d04290effb26fe01009010f2206 ]
When hardware reports RX buffer errors, the latest 57500 chips do not require reset. The packet is discarded by the hardware and the ring will continue to operate.
Also, add an rx_buf_errors counter for this type of error. It can help the user to identify if the aggregation ring is too small.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -1767,8 +1767,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, rc = -EIO ;if (rx_err &RX_CMPL_ERRORS_BUFFER_ERROR_MASK ) { -netdev_warn (bp->dev,"RX buffer error %x\n" , rx_err); -bnxt_sched_reset (bp, rxr); + bnapi->cp_ring.rx_buf_errors++; +if (!(bp->flags &BNXT_FLAG_CHIP_P5 )) { +netdev_warn (bp->dev,"RX buffer error %x\n" , + rx_err); +bnxt_sched_reset (bp, rxr); + } } goto next_rx_no_len; }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -927,6 +927,7 @@ struct bnxt_cp_ring_info {dma_addr_t hw_stats_map;u32 hw_stats_ctx_id;u64 rx_l4_csum_errors; +u64 rx_buf_errors;u64 missed_irqs;struct bnxt_ring_struct cp_ring_struct;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -0
@@ -173,6 +173,7 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {static const char *const bnxt_ring_sw_stats_str[] = {"rx_l4_csum_errors" , +"rx_buf_errors" ,"missed_irqs" , };
@@ -552,6 +553,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,for (k =0 ; k < stat_fields; j++, k++) buf[j] =le64_to_cpu (hw_stats[k]); buf[j++] = cpr->rx_l4_csum_errors; + buf[j++] = cpr->rx_buf_errors; buf[j++] = cpr->missed_irqs; bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 320/350 iwlwifi: check kasprintf() return value
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 5974fbb5e10b018fdbe3c3b81cb4cc54e1105ab9 ]
kasprintf() can fail, we should check the return value.
--- drivers/net/wireless/intel/iwlwifi/dvm/led.c | 3 +++ drivers/net/wireless/intel/iwlwifi/mvm/led.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/net/wireless/intel/iwlwifi/dvm/led.c +3 -0
@@ -171,6 +171,9 @@ void iwl_leds_init(struct iwl_priv *priv) priv->led.name =kasprintf (GFP_KERNEL ,"%s-led" ,wiphy_name (priv->hw->wiphy)); +if (!priv->led.name) +return ; + priv->led.brightness_set = iwl_led_brightness_set; priv->led.blink_set = iwl_led_blink_set; priv->led.max_brightness =1 ;
drivers/net/wireless/intel/iwlwifi/mvm/led.c +3 -0
@@ -129,6 +129,9 @@ int iwl_mvm_leds_init(struct iwl_mvm *mvm) mvm->led.name =kasprintf (GFP_KERNEL ,"%s-led" ,wiphy_name (mvm->hw->wiphy)); +if (!mvm->led.name) +return -ENOMEM ; + mvm->led.brightness_set = iwl_led_brightness_set; mvm->led.max_brightness =1 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 321/350 fbtft: Make sure string is NULL terminated
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 21f585480deb4bcf0d92b08879c35d066dfee030 ]
New GCC warns about inappropriate use of strncpy():
drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_framebuffer_alloc’:drivers/staging/fbtft/fbtft-core.c:665:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
665 | strncpy(info->fix.id, dev->driver->name, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Later on the copy is being used with the assumption to be NULL terminated. Make sure string is NULL terminated by switching to snprintf().
--- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-core.c +1 -1
@@ -666,7 +666,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbdefio->deferred_io = fbtft_deferred_io;fb_deferred_io_init (info); -strncpy (info->fix.id, dev->driver->name,16 ); +snprintf (info->fix.id,sizeof (info->fix.id),"%s" , dev->driver->name); info->fix.type =FB_TYPE_PACKED_PIXELS ; info->fix.visual =FB_VISUAL_TRUECOLOR ; info->fix.xpanstep =0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 322/350 ASoC: soc-pcm: check symmetry before hw_params
In reply to Sasha LevinFrom: Shengjiu Wang <[email protected]>
[ Upstream commit 5cca59516de5df9de6bdecb328dd55fb5bcccb41 ]
This reverts commit 957ce0c6b8a1f (ASoC: soc-pcm: check symmetry after hw_params).
That commit cause soc_pcm_params_symmetry can't take effect. cpu_dai->rate, cpu_dai->channels and cpu_dai->sample_bits are updated in the middle of soc_pcm_hw_params, so move soc_pcm_params_symmetry to the end of soc_pcm_hw_params is not a good solution, for judgement of symmetry in the function is always true.
FIXME:
According to the comments of that commit, I think the case described in the commit should disable symmetric_rates in Back-End, rather than changing the position of soc_pcm_params_symmetry.
--- sound/soc/soc-pcm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/soc-pcm.c +5 -3
@@ -877,6 +877,11 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,int i, ret =0 ;mutex_lock_nested (&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + + ret =soc_pcm_params_symmetry (substream, params); +if (ret) + goto out; +if (rtd->dai_link->ops->hw_params) { ret = rtd->dai_link->ops->hw_params (substream, params);if (ret <0 ) {
@@ -958,9 +963,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } component =NULL ; - ret =soc_pcm_params_symmetry (substream, params); -if (ret) - goto component_err; out:mutex_unlock (&rtd->card->pcm_mutex);return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 323/350 net: ethernet: ti: ale: clean ale tbl on init and intf restart
In reply to Sasha LevinFrom: Grygorii Strashko <[email protected]>
[ Upstream commit 7fe579dfb90fcdf0c7722f33c772d5f0d1bc7cb6 ]
Clean CPSW ALE on init and intf restart (up/down) to avoid reading obsolete or garbage entries from ALE table.
--- drivers/net/ethernet/ti/cpsw_ale.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/ti/cpsw_ale.c +2 -0
@@ -779,6 +779,7 @@ void cpsw_ale_start(struct cpsw_ale *ale)void cpsw_ale_stop (struct cpsw_ale *ale) {del_timer_sync (&ale->timer); +cpsw_ale_control_set (ale,0 ,ALE_CLEAR ,1 );cpsw_ale_control_set (ale,0 ,ALE_ENABLE ,0 ); }
@@ -862,6 +863,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS ; } +cpsw_ale_control_set (ale,0 ,ALE_CLEAR ,1 );return ale; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 324/350 mt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit e8b970c8e367e85fab9b8ac4f36080e5d653c38e ]
Fix possible out-of-bound access of status rates array in mt7615_fill_txs/mt7603_fill_txs routines
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +3 -1
@@ -1032,8 +1032,10 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,if (idx && (cur_rate->idx != info->status.rates[i].idx || cur_rate->flags != info->status.rates[i].flags)) { i++; -if (i ==ARRAY_SIZE (info->status.rates)) +if (i ==ARRAY_SIZE (info->status.rates)) { + i--;break ; + } info->status.rates[i] = *cur_rate; info->status.rates[i].count =0 ;
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -1
@@ -914,8 +914,10 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,if (idx && (cur_rate->idx != info->status.rates[i].idx || cur_rate->flags != info->status.rates[i].flags)) { i++; -if (i ==ARRAY_SIZE (info->status.rates)) +if (i ==ARRAY_SIZE (info->status.rates)) { + i--;break ; + } info->status.rates[i] = *cur_rate; info->status.rates[i].count =0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 325/350 s390/cpumf: Adjust registration of s390 PMU device drivers
In reply to Sasha LevinFrom: Thomas Richter <[email protected]>
[ Upstream commit 6a82e23f45fe0aa821e7a935e39d0acb20c275c0 ]
Linux-next commit titled "perf/core: Optimize perf_init_event()" changed the semantics of PMU device driver registration. It was done to speed up the lookup/handling of PMU device driver specific events. It also enforces that only one PMU device driver will be registered of type PERF_EVENT_RAW.
This change added these line in function perf_pmu_register():
...
+ ret = idr_alloc(&pmu_idr, pmu, max, 0, GFP_KERNEL);
+ if (ret < 0)
goto free_pdc;
+
+ WARN_ON(type >= 0 && ret != type);
The warn_on generates a message. We have 3 PMU device drivers, each registered as type PERF_TYPE_RAW.
The cf_diag device driver (arch/s390/kernel/perf_cpumf_cf_diag.c) always hits the WARN_ON because it is the second PMU device driver (after sampling device driver arch/s390/kernel/perf_cpumf_sf.c) which is registered as type 4 (PERF_TYPE_RAW).
So when the sampling device driver is registered, ret has value 4. When cf_diag device driver is registered with type 4, ret has value of 5 and WARN_ON fires.
Adjust the PMU device drivers for s390 to support the new semantics required by perf_pmu_register().
--- arch/s390/kernel/perf_cpum_cf.c | 21 ++++++++++----------- arch/s390/kernel/perf_cpum_cf_diag.c | 10 +++++----- 2 files changed, 15 insertions(+), 16 deletions(-)
arch/s390/kernel/perf_cpum_cf.c +10 -11
@@ -199,7 +199,7 @@ static const int cpumf_generic_events_user[] = { [PERF_COUNT_HW_BUS_CYCLES] = -1, }; -static int __hw_perf_event_init (struct perf_event *event) +static int __hw_perf_event_init (struct perf_event *event,unsigned int type) {struct perf_event_attr *attr = &event->attr;struct hw_perf_event *hwc = &event->hw;
@@ -207,7 +207,7 @@ static int __hw_perf_event_init(struct perf_event *event)int err =0 ;u64 ev; -switch (attr->type) { +switch (type) {case PERF_TYPE_RAW :/* Raw events are used to access counters directly, * hence do not permit excludes */
@@ -294,17 +294,16 @@ static int __hw_perf_event_init(struct perf_event *event)static int cpumf_pmu_event_init (struct perf_event *event) { +unsigned int type = event->attr.type;int err; -switch (event->attr.type) { -case PERF_TYPE_HARDWARE : -case PERF_TYPE_HW_CACHE : -case PERF_TYPE_RAW : - err =__hw_perf_event_init (event); -break ; -default : +if (type ==PERF_TYPE_HARDWARE || type ==PERF_TYPE_RAW ) + err =__hw_perf_event_init (event, type); +else if (event->pmu->type == type) +/* Registered as unknown PMU */ + err =__hw_perf_event_init (event,PERF_TYPE_RAW ); +else return -ENOENT ; - }if (unlikely (err) && event->destroy) event->destroy (event);
@@ -553,7 +552,7 @@ static int __init cpumf_pmu_init(void)return -ENODEV ; cpumf_pmu.attr_groups =cpumf_cf_event_group (); - rc =perf_pmu_register (&cpumf_pmu,"cpum_cf" ,PERF_TYPE_RAW ); + rc =perf_pmu_register (&cpumf_pmu,"cpum_cf" ,-1 );if (rc)pr_err ("Registering the cpum_cf PMU failed with rc=%i\n" , rc);return rc;
arch/s390/kernel/perf_cpum_cf_diag.c +5 -5
@@ -243,13 +243,13 @@ static int cf_diag_event_init(struct perf_event *event)int err = -ENOENT ;debug_sprintf_event (cf_diag_dbg,5 , -"%s event %p cpu %d config %#llx " +"%s event %p cpu %d config %#llx type:%u " "sample_type %#llx cf_diag_events %d\n" , __func__, - event, event->cpu, attr->config, attr->sample_type, -atomic_read (&cf_diag_events)); + event, event->cpu, attr->config, event->pmu->type, + attr->sample_type,atomic_read (&cf_diag_events));if (event->attr.config !=PERF_EVENT_CPUM_CF_DIAG || - event->attr.type !=PERF_TYPE_RAW ) + event->attr.type != event->pmu->type) goto out;/* Raw events are used to access counters directly,
@@ -693,7 +693,7 @@ static int __init cf_diag_init(void) }debug_register_view (cf_diag_dbg, &debug_sprintf_view); - rc =perf_pmu_register (&cf_diag,"cpum_cf_diag" ,PERF_TYPE_RAW ); + rc =perf_pmu_register (&cf_diag,"cpum_cf_diag" ,-1 );if (rc) {debug_unregister_view (cf_diag_dbg, &debug_sprintf_view);debug_unregister (cf_diag_dbg);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 326/350 bpf: Switch bpf_map ref counter to atomic64_t so bpf_map_inc() never fails
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 1e0bd5a091e5d9e0f1d5b0e6329b87bb1792f784 ]
92117d8443bc ("bpf: fix refcnt overflow") turned refcounting of bpf_map into potentially failing operation, when refcount reaches BPF_MAX_REFCNT limit (32k). Due to using 32-bit counter, it's possible in practice to overflow refcounter and make it wrap around to 0, causing erroneous map free, while there are still references to it, causing use-after-free problems.
But having a failing refcounting operations are problematic in some cases. One example is mmap() interface. After establishing initial memory-mapping, user is allowed to arbitrarily map/remap/unmap parts of mapped memory, arbitrarily splitting it into multiple non-contiguous regions. All this happening without any control from the users of mmap subsystem. Rather mmap subsystem sends notifications to original creator of memory mapping through open/close callbacks, which are optionally specified during initial memory mapping creation. These callbacks are used to maintain accurate refcount for bpf_map (see next patch in this series). The problem is that open() callback is not supposed to fail, because memory-mapped resource is set up and properly referenced. This is posing a problem for using memory-mapping with BPF maps.
One solution to this is to maintain separate refcount for just memory-mappings and do single bpf_map_inc/bpf_map_put when it goes from/to zero, respectively. There are similar use cases in current work on tcp-bpf, necessitating extra counter as well. This seems like a rather unfortunate and ugly solution that doesn't scale well to various new use cases.
Another approach to solve this is to use non-failing refcount_t type, which uses 32-bit counter internally, but, once reaching overflow state at UINT_MAX, stays there. This utlimately causes memory leak, but prevents use after free.
But given refcounting is not the most performance-critical operation with BPF maps (it's not used from running BPF program code), we can also just switch to 64-bit counter that can't overflow in practice, potentially disadvantaging 32-bit platforms a tiny bit. This simplifies semantics and allows above described scenarios to not worry about failing refcount increment operation.
In terms of struct bpf_map size, we are still good and use the same amount of space:
BEFORE (3 cache lines, 8 bytes of padding at the end):
struct bpf_map {
const struct bpf_map_ops * ops __attribute__((__aligned__(64))); /* 0 8 */
struct bpf_map * inner_map_meta; /* 8 8 */
void * security; /* 16 8 */
enum bpf_map_type map_type; /* 24 4 */
u32 key_size; /* 28 4 */
u32 value_size; /* 32 4 */
u32 max_entries; /* 36 4 */
u32 map_flags; /* 40 4 */
int spin_lock_off; /* 44 4 */
u32 id; /* 48 4 */
int numa_node; /* 52 4 */
u32 btf_key_type_id; /* 56 4 */
u32 btf_value_type_id; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct btf * btf; /* 64 8 */
struct bpf_map_memory memory; /* 72 16 */
bool unpriv_array; /* 88 1 */
bool frozen; /* 89 1 */
/* XXX 38 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
atomic_t refcnt __attribute__((__aligned__(64))); /* 128 4 */
atomic_t usercnt; /* 132 4 */
struct work_struct work; /* 136 32 */
char name[16]; /* 168 16 */
/* size: 192, cachelines: 3, members: 21 */
/* sum members: 146, holes: 1, sum holes: 38 */
/* padding: 8 */
/* forced alignments: 2, forced holes: 1, sum forced holes: 38 */
} __attribute__((__aligned__(64)));
AFTER (same 3 cache lines, no extra padding now):
struct bpf_map {
const struct bpf_map_ops * ops __attribute__((__aligned__(64))); /* 0 8 */
struct bpf_map * inner_map_meta; /* 8 8 */
void * security; /* 16 8 */
enum bpf_map_type map_type; /* 24 4 */
u32 key_size; /* 28 4 */
u32 value_size; /* 32 4 */
u32 max_entries; /* 36 4 */
u32 map_flags; /* 40 4 */
int spin_lock_off; /* 44 4 */
u32 id; /* 48 4 */
int numa_node; /* 52 4 */
u32 btf_key_type_id; /* 56 4 */
u32 btf_value_type_id; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct btf * btf; /* 64 8 */
struct bpf_map_memory memory; /* 72 16 */
bool unpriv_array; /* 88 1 */
bool frozen; /* 89 1 */
/* XXX 38 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
atomic64_t refcnt __attribute__((__aligned__(64))); /* 128 8 */
atomic64_t usercnt; /* 136 8 */
struct work_struct work; /* 144 32 */
char name[16]; /* 176 16 */
/* size: 192, cachelines: 3, members: 21 */
/* sum members: 154, holes: 1, sum holes: 38 */
/* forced alignments: 2, forced holes: 1, sum forced holes: 38 */
} __attribute__((__aligned__(64)));
This patch, while modifying all users of bpf_map_inc, also cleans up its interface to match bpf_map_put with separate operations for bpf_map_inc and bpf_map_inc_with_uref (to match bpf_map_put and bpf_map_put_with_uref, respectively). Also, given there are no users of bpf_map_inc_not_zero specifying uref=true, remove uref flag and default to uref=false internally.
--- .../net/ethernet/netronome/nfp/bpf/offload.c | 4 +- include/linux/bpf.h | 10 ++-- kernel/bpf/inode.c | 2 +- kernel/bpf/map_in_map.c | 2 +- kernel/bpf/syscall.c | 51 ++++++++----------- kernel/bpf/verifier.c | 6 +-- kernel/bpf/xskmap.c | 6 +-- net/core/bpf_sk_storage.c | 2 +- 8 files changed, 34 insertions(+), 49 deletions(-)
drivers/net/ethernet/netronome/nfp/bpf/offload.c +1 -3
@@ -46,9 +46,7 @@ nfp_map_ptr_record(struct nfp_app_bpf *bpf, struct nfp_prog *nfp_prog,/* Grab a single ref to the map for our record. The prog destroy ndo * happens after free_used_maps(). */ - map =bpf_map_inc (map, false); -if (IS_ERR (map)) -return PTR_ERR (map); +bpf_map_inc (map); record =kmalloc (sizeof (*record),GFP_KERNEL );if (!record) {
include/linux/bpf.h +5 -5
@@ -99,8 +99,8 @@ struct bpf_map {/* The 3rd and 4th cacheline with misc members to avoid false sharing * particularly with refcounting. */ -atomic_t refcnt____cacheline_aligned ; -atomic_t usercnt; +atomic64_t refcnt____cacheline_aligned ; +atomic64_t usercnt;struct work_struct work;char name[BPF_OBJ_NAME_LEN ]; };
@@ -649,9 +649,9 @@ void bpf_map_free_id(struct bpf_map *map, bool do_idr_lock);struct bpf_map *bpf_map_get_with_uref (u32 ufd);struct bpf_map *__bpf_map_get (struct fd f); -struct bpf_map *__must_check bpf_map_inc (struct bpf_map *map,bool uref); -struct bpf_map *__must_check bpf_map_inc_not_zero (struct bpf_map *map, -bool uref); +void bpf_map_inc (struct bpf_map *map); +void bpf_map_inc_with_uref (struct bpf_map *map); +struct bpf_map *__must_check bpf_map_inc_not_zero (struct bpf_map *map);void bpf_map_put_with_uref (struct bpf_map *map);void bpf_map_put (struct bpf_map *map);int bpf_map_charge_memlock (struct bpf_map *map,u32 pages);
kernel/bpf/inode.c +1 -1
@@ -34,7 +34,7 @@ static void *bpf_any_get(void *raw, enum bpf_type type) raw =bpf_prog_inc (raw);break ;case BPF_TYPE_MAP : - raw =bpf_map_inc (raw, true); +bpf_map_inc_with_uref (raw);break ;default :WARN_ON_ONCE (1 );
kernel/bpf/map_in_map.c +1 -1
@@ -98,7 +98,7 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map,return inner_map;if (bpf_map_meta_equal (map->inner_map_meta, inner_map)) - inner_map =bpf_map_inc (inner_map, false); +bpf_map_inc (inner_map);else inner_map =ERR_PTR (-EINVAL );
kernel/bpf/syscall.c +22 -29
109 lines not on this page · raw message
kernel/bpf/verifier.c +1 -5
@@ -8008,11 +8008,7 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)* will be used by the valid program until it's unloaded * and all maps are released in free_used_maps() */ - map =bpf_map_inc (map, false); -if (IS_ERR (map)) { -fdput (f); -return PTR_ERR (map); - } +bpf_map_inc (map); aux->map_index = env->used_map_cnt; env->used_maps[env->used_map_cnt++] = map;
kernel/bpf/xskmap.c +2 -4
@@ -18,10 +18,8 @@ struct xsk_map {int xsk_map_inc (struct xsk_map *map) { -struct bpf_map *m = &map->map; - - m =bpf_map_inc (m, false); -return PTR_ERR_OR_ZERO (m); +bpf_map_inc (&map->map); +return 0 ; }void xsk_map_put (struct xsk_map *map)
net/core/bpf_sk_storage.c +1 -1
@@ -798,7 +798,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)* Try to grab map refcnt to make sure that it's still * alive and prevent concurrent removal. */ - map =bpf_map_inc_not_zero (&smap->map, false); + map =bpf_map_inc_not_zero (&smap->map);if (IS_ERR (map))continue ;
Signature · 1 line
2.20.1
Re: [oss-drivers] [PATCH AUTOSEL 5.4 326/350] bpf: Switch bpf_map ref counter to atomic64_t so bpf_map_inc() never fails
Quoted 9 lines · Sasha Levin
From: Andrii Nakryiko <[email protected]>
[ Upstream commit
1e0bd5a091e5d9e0f1d5b0e6329b87bb1792f784]
92117d8443bc("bpf: fix refcnt overflow") turned refcounting ofbpf_mapinto potentially failing operation, when refcount reachesBPF_MAX_REFCNTlimit (32k). Due to using 32-bit counter, it's possible in practice to overflow refcounter and make it wrap around to 0, causing erroneous map free, while there are still references to it, causing use-after-free problems.
I don't think this is a bug fix, the second sentence here is written in a quite confusing way, but there is no bug.
Could you drop? I don't think it's worth the backporting pain since it changes bpf_map_inc().
Daniel Borkmann
maintainerRe: [oss-drivers] [PATCH AUTOSEL 5.4 326/350] bpf: Switch bpf_map ref counter to atomic64_t so bpf_map_inc() never fails
Quoted 11 lines · Jakub Kicinski
Quoted 9 lines · Sasha Levin
From: Andrii Nakryiko <[email protected]>
[ Upstream commit
1e0bd5a091e5d9e0f1d5b0e6329b87bb1792f784]
92117d8443bc("bpf: fix refcnt overflow") turned refcounting ofbpf_mapinto potentially failing operation, when refcount reachesBPF_MAX_REFCNTlimit (32k). Due to using 32-bit counter, it's possible in practice to overflow refcounter and make it wrap around to 0, causing erroneous map free, while there are still references to it, causing use-after-free problems.
Quoted 5 lines
I don't think this is a bug fix, the second sentence here is written in a quite confusing way, but there is no bug.
Could you drop? I don't think it's worth the backporting pain since it changes
bpf_map_inc().
Agree, this is not a bug fix and should not go to stable. (Also agree that the changelog is super confusing here and should have been done differently to avoid exactly where we are here. I think I pointed that out in the original patch, but seems this slipped through the cracks :/)
Thanks,
Daniel
Sasha Levin
maintainerRe: [oss-drivers] [PATCH AUTOSEL 5.4 326/350] bpf: Switch bpf_map ref counter to atomic64_t so bpf_map_inc() never fails
Quoted 15 lines · Daniel Borkmann
Quoted 14 lines · Jakub Kicinski
Quoted 9 lines · Sasha Levin
From: Andrii Nakryiko <[email protected]>
[ Upstream commit
1e0bd5a091e5d9e0f1d5b0e6329b87bb1792f784]
92117d8443bc("bpf: fix refcnt overflow") turned refcounting ofbpf_mapinto potentially failing operation, when refcount reachesBPF_MAX_REFCNTlimit (32k). Due to using 32-bit counter, it's possible in practice to overflow refcounter and make it wrap around to 0, causing erroneous map free, while there are still references to it, causing use-after-free problems.I don't think this is a bug fix, the second sentence here is written in a quite confusing way, but there is no bug.
Quoted 7 lines
Quoted 2 lines
Could you drop? I don't think it's worth the backporting pain since it changes
bpf_map_inc().Agree, this is not a bug fix and should not go to stable. (Also agree that the changelog is super confusing here and should have been done differently to avoid exactly where we are here. I think I pointed that out in the original patch, but seems this slipped through the cracks :/)
Sure, dropped, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 327/350 libbpf: Fix call relocation offset calculation bug
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit a0d7da26ce86a25e97ae191cb90574ada6daea98 ]
When relocating subprogram call, libbpf doesn't take into account relo->text_off, which comes from symbol's value. This generally works fine for subprograms implemented as static functions, but breaks for global functions.
Taking a simplified test_pkt_access.c as an example:
__attribute__ ((noinline))
static int test_pkt_access_subprog1(volatile struct __sk_buff *skb)
{
return skb->len * 2;
}__attribute__ ((noinline))
static int test_pkt_access_subprog2(int val, volatile struct __sk_buff *skb)
{
return skb->len + val;
}SEC("classifier/test_pkt_access")
int test_pkt_access(struct __sk_buff *skb)
{
if (test_pkt_access_subprog1(skb) != skb->len * 2)
return TC_ACT_SHOT;
if (test_pkt_access_subprog2(2, skb) != skb->len + 2)
return TC_ACT_SHOT;
return TC_ACT_UNSPEC;
}When compiled, we get two relocations, pointing to '.text' symbol. .text has st_value set to 0 (it points to the beginning of .text section):
0000000000000008 000000050000000a R_BPF_64_32 0000000000000000 .text 0000000000000040 000000050000000a R_BPF_64_32 0000000000000000 .text
test_pkt_access_subprog1 and test_pkt_access_subprog2 offsets (targets of two calls) are encoded within call instruction's imm32 part as -1 and 2, respectively:
0000000000000000 test_pkt_access_subprog1:
0: 61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
1: 64 00 00 00 01 00 00 00 w0 <<= 1
2: 95 00 00 00 00 00 00 00 exit0000000000000018 test_pkt_access_subprog2:
3: 61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
4: 04 00 00 00 02 00 00 00 w0 += 2
5: 95 00 00 00 00 00 00 00 exit0000000000000000 test_pkt_access:
0: bf 16 00 00 00 00 00 00 r6 = r1
===> 1: 85 10 00 00 ff ff ff ff call -1
2: bc 01 00 00 00 00 00 00 w1 = w0
3: b4 00 00 00 02 00 00 00 w0 = 2
4: 61 62 00 00 00 00 00 00 r2 = *(u32 *)(r6 + 0)
5: 64 02 00 00 01 00 00 00 w2 <<= 1
6: 5e 21 08 00 00 00 00 00 if w1 != w2 goto +8 <LBB0_3>
7: bf 61 00 00 00 00 00 00 r1 = r6
===> 8: 85 10 00 00 02 00 00 00 call 2
9: bc 01 00 00 00 00 00 00 w1 = w0
10: 61 62 00 00 00 00 00 00 r2 = *(u32 *)(r6 + 0)
11: 04 02 00 00 02 00 00 00 w2 += 2
12: b4 00 00 00 ff ff ff ff w0 = -1
13: 1e 21 01 00 00 00 00 00 if w1 == w2 goto +1 <LBB0_3>
14: b4 00 00 00 02 00 00 00 w0 = 2
0000000000000078 LBB0_3:
15: 95 00 00 00 00 00 00 00 exitNow, if we compile example with global functions, the setup changes. Relocations are now against specifically test_pkt_access_subprog1 and test_pkt_access_subprog2 symbols, with test_pkt_access_subprog2 pointing 24 bytes into its respective section (.text), i.e., 3 instructions in:
0000000000000008 000000070000000a R_BPF_64_32 0000000000000000 test_pkt_access_subprog1 0000000000000048 000000080000000a R_BPF_64_32 0000000000000018 test_pkt_access_subprog2
Calls instructions now encode offsets relative to function symbols and are both set ot -1:
0000000000000000 test_pkt_access_subprog1:
0: 61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
1: 64 00 00 00 01 00 00 00 w0 <<= 1
2: 95 00 00 00 00 00 00 00 exit0000000000000018 test_pkt_access_subprog2:
3: 61 20 00 00 00 00 00 00 r0 = *(u32 *)(r2 + 0)
4: 0c 10 00 00 00 00 00 00 w0 += w1
5: 95 00 00 00 00 00 00 00 exit0000000000000000 test_pkt_access:
0: bf 16 00 00 00 00 00 00 r6 = r1
===> 1: 85 10 00 00 ff ff ff ff call -1
2: bc 01 00 00 00 00 00 00 w1 = w0
3: b4 00 00 00 02 00 00 00 w0 = 2
4: 61 62 00 00 00 00 00 00 r2 = *(u32 *)(r6 + 0)
5: 64 02 00 00 01 00 00 00 w2 <<= 1
6: 5e 21 09 00 00 00 00 00 if w1 != w2 goto +9 <LBB2_3>
7: b4 01 00 00 02 00 00 00 w1 = 2
8: bf 62 00 00 00 00 00 00 r2 = r6
===> 9: 85 10 00 00 ff ff ff ff call -1
10: bc 01 00 00 00 00 00 00 w1 = w0
11: 61 62 00 00 00 00 00 00 r2 = *(u32 *)(r6 + 0)
12: 04 02 00 00 02 00 00 00 w2 += 2
13: b4 00 00 00 ff ff ff ff w0 = -1
14: 1e 21 01 00 00 00 00 00 if w1 == w2 goto +1 <LBB2_3>
15: b4 00 00 00 02 00 00 00 w0 = 2
0000000000000080 LBB2_3:
16: 95 00 00 00 00 00 00 00 exitThus the right formula to calculate target call offset after relocation should take into account relocation's target symbol value (offset within section), call instruction's imm32 offset, and (subtracting, to get relative instruction offset) instruction index of call instruction itself. All that is shifted by number of instructions in main program, given all sub-programs are copied over after main program.
Convert few selftests relying on bpf-to-bpf calls to use global functions instead of static ones.
--- tools/lib/bpf/libbpf.c | 8 ++++++-- tools/testing/selftests/bpf/progs/test_btf_haskv.c | 4 ++-- tools/testing/selftests/bpf/progs/test_btf_newkv.c | 4 ++-- tools/testing/selftests/bpf/progs/test_btf_nokv.c | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-)
tools/lib/bpf/libbpf.c +6 -2
@@ -1791,9 +1791,13 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,pr_warning ("incorrect bpf_call opcode\n" );return -LIBBPF_ERRNO__RELOC ; } +if (sym.st_value %8 ) { +pr_warn ("bad call relo offset: %lu\n" , sym.st_value); +return -LIBBPF_ERRNO__RELOC ; + } prog->reloc_desc[i].type =RELO_CALL ; prog->reloc_desc[i].insn_idx = insn_idx; - prog->reloc_desc[i].text_off = sym.st_value; + prog->reloc_desc[i].text_off = sym.st_value /8 ; obj->has_pseudo_calls = true;continue ; }
@@ -3239,7 +3243,7 @@ bpf_program__reloc_text(struct bpf_program *prog, struct bpf_object *obj, prog->section_name); } insn = &prog->insns[relo->insn_idx]; - insn->imm += prog->main_prog_cnt - relo->insn_idx; + insn->imm += relo->text_off + prog->main_prog_cnt - relo->insn_idx;return 0 ; }
tools/testing/selftests/bpf/progs/test_btf_haskv.c +2 -2
@@ -25,7 +25,7 @@ struct dummy_tracepoint_args { }; __attribute__((noinline)) -static int test_long_fname_2 (struct dummy_tracepoint_args *arg) +int test_long_fname_2 (struct dummy_tracepoint_args *arg) {struct ipv_counts *counts;int key =0 ;
@@ -43,7 +43,7 @@ static int test_long_fname_2(struct dummy_tracepoint_args *arg) } __attribute__((noinline)) -static int test_long_fname_1 (struct dummy_tracepoint_args *arg) +int test_long_fname_1 (struct dummy_tracepoint_args *arg) {return test_long_fname_2 (arg); }
tools/testing/selftests/bpf/progs/test_btf_newkv.c +2 -2
@@ -33,7 +33,7 @@ struct dummy_tracepoint_args { }; __attribute__((noinline)) -static int test_long_fname_2 (struct dummy_tracepoint_args *arg) +int test_long_fname_2 (struct dummy_tracepoint_args *arg) {struct ipv_counts *counts;int key =0 ;
@@ -56,7 +56,7 @@ static int test_long_fname_2(struct dummy_tracepoint_args *arg) } __attribute__((noinline)) -static int test_long_fname_1 (struct dummy_tracepoint_args *arg) +int test_long_fname_1 (struct dummy_tracepoint_args *arg) {return test_long_fname_2 (arg); }
tools/testing/selftests/bpf/progs/test_btf_nokv.c +2 -2
@@ -23,7 +23,7 @@ struct dummy_tracepoint_args { }; __attribute__((noinline)) -static int test_long_fname_2 (struct dummy_tracepoint_args *arg) +int test_long_fname_2 (struct dummy_tracepoint_args *arg) {struct ipv_counts *counts;int key =0 ;
@@ -41,7 +41,7 @@ static int test_long_fname_2(struct dummy_tracepoint_args *arg) } __attribute__((noinline)) -static int test_long_fname_1 (struct dummy_tracepoint_args *arg) +int test_long_fname_1 (struct dummy_tracepoint_args *arg) {return test_long_fname_2 (arg); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 328/350 debugfs: Fix !DEBUG_FS debugfs_create_automount
In reply to Sasha LevinFrom: Kusanagi Kouichi <[email protected]>
[ Upstream commit 4250b047039d324e0ff65267c8beb5bad5052a86 ]
If DEBUG_FS=n, compile fails with the following error:
kernel/trace/trace.c: In function 'tracing_init_dentry':kernel/trace/trace.c:8658:9: error: passing argument 3 of 'debugfs_create_automount' from incompatible pointer type [-Werror=incompatible-pointer-types]
8658 | trace_automount, NULL);
| ^~~~~~~~~~~~~~~
| |
| struct vfsmount * (*)(struct dentry *, void *)
In file included from kernel/trace/trace.c:24:
./include/linux/debugfs.h:206:25: note: expected 'struct vfsmount * (*)(void *)' but argument is of type 'struct vfsmount * (*)(struct dentry *, void *)'
206 | struct vfsmount *(*f)(void *),
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~--- include/linux/debugfs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/debugfs.h +3 -2
@@ -54,6 +54,8 @@ static const struct file_operations __fops = { \ .llseek = no_llseek, \ } +typedef struct vfsmount *(*debugfs_automount_t )(struct dentry *,void *); +#if defined(CONFIG_DEBUG_FS )struct dentry *debugfs_lookup (const char *name,struct dentry *parent);
@@ -75,7 +77,6 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);struct dentry *debugfs_create_symlink (const char *name,struct dentry *parent,const char *dest); -typedef struct vfsmount *(*debugfs_automount_t )(struct dentry *,void *); struct dentry *debugfs_create_automount(const char *name, struct dentry *parent, debugfs_automount_t f,
@@ -203,7 +204,7 @@ static inline struct dentry *debugfs_create_symlink(const char *name,static inline struct dentry *debugfs_create_automount (const char *name,struct dentry *parent, -struct vfsmount *(*f)(void *), +debugfs_automount_t f,void *data) {return ERR_PTR (-ENODEV );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.4 328/350] debugfs: Fix !DEBUG_FS debugfs_create_automount
Quoted 17 lines · Sasha Levin
From: Kusanagi Kouichi <[email protected]>
[ Upstream commit
4250b047039d324e0ff65267c8beb5bad5052a86]If DEBUG_FS=n, compile fails with the following error:
kernel/trace/trace.c: In function 'tracing_init_dentry':kernel/trace/trace.c:8658:9: error: passing argument 3 of 'debugfs_create_automount' from incompatible pointer type [-Werror=incompatible-pointer-types]8658 | trace_automount, NULL); | ^~~~~~~~~~~~~~~ | | | struct vfsmount * (*)(struct dentry *, void *) In file included from kernel/trace/trace.c:24: ./include/linux/debugfs.h:206:25: note: expected 'struct vfsmount * (*)(void *)' but argument is of type 'struct vfsmount * (*)(struct dentry *, void *)' 206 | struct vfsmount *(*f)(void *), | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Quoted 7 lines
Signed-off-by Kusanagi Kouichi <[email protected]>Link https://lore.kernel.org/r/20191121102021787.MLMY.25002.ppp.dion.ne.jp@dmta0003.auone-net.jp open hereSigned-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- include/linux/debugfs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Not needed here either, this is a 5.5-rc1 only issue.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 329/350 crypto: sun4i-ss - Fix 64-bit size_t warnings
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
[ Upstream commit d6e9da21ee8246b5e556b3b153401ab045adb986 ]
If you try to compile this driver on a 64-bit platform then you will get warnings because it mixes size_t with unsigned int which only works on 32-bit.
This patch fixes all of the warnings.
--- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +14 -8
@@ -72,7 +72,8 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) oi =0 ; oo =0 ; do { - todo = min3(rx_cnt, ileft, (mi.length - oi) / 4); + todo = min(rx_cnt, ileft); + todo = min_t(size_t, todo, (mi.length - oi) / 4); if (todo) { ileft -= todo; writesl(ss->base + SS_RXFIFO, mi.addr + oi, todo);
@@ -87,7 +88,8 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) rx_cnt =SS_RXFIFO_SPACES (spaces); tx_cnt =SS_TXFIFO_SPACES (spaces); - todo =min3 (tx_cnt, oleft, (mo.length - oo) /4 ); + todo =min (tx_cnt, oleft); + todo =min_t (size_t, todo, (mo.length - oo) /4 );if (todo) { oleft -= todo;readsl (ss->base +SS_TXFIFO , mo.addr + oo, todo);
@@ -239,7 +241,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)* todo is the number of consecutive 4byte word that we * can read from current SG */ - todo =min3 (rx_cnt, ileft /4 , (mi.length - oi) /4 ); + todo =min (rx_cnt, ileft /4 ); + todo =min_t (size_t, todo, (mi.length - oi) /4 );if (todo && !ob) {writesl (ss->base +SS_RXFIFO , mi.addr + oi, todo);
@@ -253,8 +256,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)* we need to be able to write all buf in one * pass, so it is why we min() with rx_cnt */ - todo =min3 (rx_cnt *4 - ob, ileft, - mi.length - oi); + todo =min (rx_cnt *4 - ob, ileft); + todo =min_t (size_t, todo, mi.length - oi);memcpy (buf + ob, mi.addr + oi, todo); ileft -= todo; oi += todo;
@@ -274,7 +277,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) spaces =readl (ss->base +SS_FCSR ); rx_cnt =SS_RXFIFO_SPACES (spaces); tx_cnt =SS_TXFIFO_SPACES (spaces); -dev_dbg (ss->dev,"%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n" , +dev_dbg (ss->dev, +"%x %u/%zu %u/%u cnt=%u %u/%zu %u/%u cnt=%u %u\n" , mode, oi, mi.length, ileft, areq->cryptlen, rx_cnt, oo, mo.length, oleft, areq->cryptlen, tx_cnt, ob);
@@ -282,7 +286,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)if (!tx_cnt)continue ;/* todo in 4bytes word */ - todo =min3 (tx_cnt, oleft /4 , (mo.length - oo) /4 ); + todo =min (tx_cnt, oleft /4 ); + todo =min_t (size_t, todo, (mo.length - oo) /4 );if (todo) {readsl (ss->base +SS_TXFIFO , mo.addr + oo, todo); oleft -= todo *4 ;
@@ -308,7 +313,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)* no more than remaining buffer * no need to test against oleft */ - todo =min (mo.length - oo, obl - obo); + todo =min_t (size_t, + mo.length - oo, obl - obo);memcpy (mo.addr + oo, bufo + obo, todo); oleft -= todo; obo += todo;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 330/350 EDAC/ghes: Do not warn when incrementing refcount on 0
In reply to Sasha LevinFrom: Robert Richter <[email protected]>
[ Upstream commit 16214bd9e43a31683a7073664b000029bba00354 ]
The following warning from the refcount framework is seen during ghes initialization:
EDAC MC0: Giving out device to module ghes_edac.c controller ghes_edac: DEV ghes (INTERRUPT)
------------[ cut here ]------------ refcount_t: increment on 0; use-after-free. WARNING: CPU: 36 PID: 1 at lib/refcount.c:156 refcount_inc_checked [...] Call trace: refcount_inc_checked ghes_edac_register ghes_probe ...
It warns if the refcount is incremented from zero. This warning is reasonable as a kernel object is typically created with a refcount of one and freed once the refcount is zero. Afterwards the object would be "used-after-free".
For GHES, the refcount is initialized with zero, and that is why this message is seen when initializing the first instance. However, whenever the refcount is zero, the device will be allocated and registered. Since the ghes_reg_mutex protects the refcount and serializes allocation and freeing of ghes devices, a use-after-free cannot happen here.
Instead of using refcount_inc() for the first instance, use refcount_set(). This can be used here because the refcount is zero at this point and can not change due to its protection by the mutex.
--- drivers/edac/ghes_edac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/ghes_edac.c +2 -2
@@ -572,8 +572,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) ghes_pvt = pvt;spin_unlock_irqrestore (&ghes_lock, flags); -/* only increment on success */ -refcount_inc (&ghes_refcount); +/* only set on success */ +refcount_set (&ghes_refcount,1 ); unlock:mutex_unlock (&ghes_reg_mutex);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 331/350 crypto: sun4i-ss - Fix 64-bit size_t warnings on sun4i-ss-hash.c
In reply to Sasha LevinFrom: Corentin Labbe <[email protected]>
[ Upstream commit a7126603d46fe8f01aeedf589e071c6aaa6c6c39 ]
If you try to compile this driver on a 64-bit platform then you will get warnings because it mixes size_t with unsigned int which only works on 32-bit.
This patch fixes all of the warnings on sun4i-ss-hash.c.
--- drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +6 -6
@@ -272,8 +272,8 @@ static int sun4i_hash(struct ahash_request *areq)*/ while (op->len <64 && i < end) {/* how many bytes we can read from current SG */ - in_r =min3 (mi.length - in_i, end - i, -64 - op->len); + in_r =min (end - i,64 - op->len); + in_r =min_t (size_t, mi.length - in_i, in_r);memcpy (op->buf + op->len, mi.addr + in_i, in_r); op->len += in_r; i += in_r;
@@ -293,8 +293,8 @@ static int sun4i_hash(struct ahash_request *areq) }if (mi.length - in_i >3 && i < end) {/* how many bytes we can read from current SG */ - in_r =min3 (mi.length - in_i, areq->nbytes - i, - ((mi.length - in_i) /4 ) *4 ); + in_r =min_t (size_t, mi.length - in_i, areq->nbytes - i); + in_r =min_t (size_t, ((mi.length - in_i) /4 ) *4 , in_r);/* how many bytes we can write in the device*/ todo =min3 ((u32)(end - i) /4 , rx_cnt, (u32 )in_r /4 );writesl (ss->base +SS_RXFIFO , mi.addr + in_i, todo);
@@ -320,8 +320,8 @@ static int sun4i_hash(struct ahash_request *areq)if ((areq->nbytes - i) <64 ) {while (i < areq->nbytes && in_i < mi.length && op->len <64 ) {/* how many bytes we can read from current SG */ - in_r =min3 (mi.length - in_i, areq->nbytes - i, -64 - op->len); + in_r =min (areq->nbytes - i,64 - op->len); + in_r =min_t (size_t, mi.length - in_i, in_r);memcpy (op->buf + op->len, mi.addr + in_i, in_r); op->len += in_r; i += in_r;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 332/350 mac80211: consider QoS Null frames for STA_NULLFUNC_ACKED
In reply to Sasha LevinFrom: Thomas Pedersen <[email protected]>
[ Upstream commit 08a5bdde3812993cb8eb7aa9124703df0de28e4b ]
Commit 7b6ddeaf27ec ("mac80211: use QoS NDP for AP probing") let STAs send QoS Null frames as PS triggers if the AP was a QoS STA. However, the mac80211 PS stack relies on an interface flag IEEE80211_STA_NULLFUNC_ACKED for determining trigger frame ACK, which was not being set for acked non-QoS Null frames. The effect is an inability to trigger hardware sleep via IEEE80211_CONF_PS since the QoS Null frame was seemingly never acked.
This bug only applies to drivers which set bothIEEE80211_HW_REPORTS_TX_ACK_STATUS andIEEE80211_HW_PS_NULLFUNC_STACK.
Detect the acked QoS Null frame to restore STA power save.
--- net/mac80211/status.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/status.c +2 -1
@@ -1030,7 +1030,8 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,I802_DEBUG_INC (local->dot11FailedCount); } -if (ieee80211_is_nullfunc (fc) &&ieee80211_has_pm (fc) && +if ((ieee80211_is_nullfunc (fc) ||ieee80211_is_qos_nullfunc (fc)) && +ieee80211_has_pm (fc) &&ieee80211_hw_check (&local->hw,REPORTS_TX_ACK_STATUS ) && !(info->flags &IEEE80211_TX_CTL_INJECTED ) && local->ps_sdata && !(local->scanning)) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 333/350 crypto: vmx - Avoid weird build failures
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
[ Upstream commit 4ee812f6143d78d8ba1399671d78c8d78bf2817c ]
In the vmx crypto Makefile we assign to a variable called TARGET and pass that to the aesp8-ppc.pl and ghashp8-ppc.pl scripts.
The variable is meant to describe what flavour of powerpc we're building for, eg. either 32 or 64-bit, and big or little endian.
Unfortunately TARGET is a fairly common name for a make variable, and if it happens that TARGET is specified as a command line parameter to make, the value specified on the command line will override our value.
In particular this can happen if the kernel Makefile is driven by an external Makefile that uses TARGET for something.
This leads to weird build failures, eg:
nonsense at /build/linux/drivers/crypto/vmx/ghashp8-ppc.pl line 45. /linux/drivers/crypto/vmx/Makefile:20: recipe for target 'drivers/crypto/vmx/ghashp8-ppc.S' failed
Which shows that we passed an empty value for $(TARGET) to the perl script, confirmed with make V=1:
perl /linux/drivers/crypto/vmx/ghashp8-ppc.pl > drivers/crypto/vmx/ghashp8-ppc.S
We can avoid this confusion by using override, to tell make that we don't want anything to override our variable, even a value specified on the command line. We can also use a less common name, given the script calls it "flavour", let's use that.
--- drivers/crypto/vmx/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/vmx/Makefile +3 -3
@@ -3,13 +3,13 @@ obj-$(CONFIG_CRYPTO_DEV_VMX_ENCRYPT) += vmx-crypto.o vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes_xts.o ghash.o ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) -TARGET := linux-ppc64le +override flavour := linux-ppc64le else -TARGET := linux-ppc64 +override flavour := linux-ppc64 endif quiet_cmd_perl = PERL $@ - cmd_perl = $(PERL) $(<) $(TARGET) > $(@) + cmd_perl = $(PERL) $(<) $(flavour) > $(@) targets += aesp8-ppc.S ghashp8-ppc.S
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 334/350 libtraceevent: Fix memory leakage in copy_filter_type
In reply to Sasha LevinFrom: Hewenliang <[email protected]>
[ Upstream commit 10992af6bf46a2048ad964985a5b77464e5563b1 ]
It is necessary to free the memory that we have allocated when error occurs.
--- tools/lib/traceevent/parse-filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/lib/traceevent/parse-filter.c +7 -2
@@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,if (strcmp (str,"TRUE" ) ==0 ||strcmp (str,"FALSE" ) ==0 ) {/* Add trivial event */ arg =allocate_arg (); -if (arg ==NULL ) +if (arg ==NULL ) { +free (str);return -1 ; + } arg->type =TEP_FILTER_ARG_BOOLEAN ;if (strcmp (str,"TRUE" ) ==0 )
@@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter, arg->boolean.value =0 ; filter_type =add_filter_type (filter, event->id); -if (filter_type ==NULL ) +if (filter_type ==NULL ) { +free (str); +free_arg (arg);return -1 ; + } filter_type->filter = arg;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 335/350 perf parse: Fix potential memory leak when handling tracepoint errors
In reply to Sasha LevinFrom: Ian Rogers <[email protected]>
[ Upstream commit 4584f084aa9d8033d5911935837dbee7b082d0e9 ]
An error may be in place when tracepoint_error is called, use parse_events__handle_error to avoid a memory leak and to capture the first and last error. Error detected by LLVM's libFuzzer using the following event:
$ perf stat -e 'msr/event/,f:e'
event syntax error: 'msr/event/,f:e'
\___ can't access trace eventsError: No permissions to read /sys/kernel/debug/tracing/events/f/e Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing/'
Initial error:
event syntax error: 'msr/event/,f:e'
\___ no value assigned for term
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
--- tools/perf/util/parse-events.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/util/parse-events.c +5 -4
@@ -480,6 +480,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,static void tracepoint_error (struct parse_events_error *e,int err,const char *sys,const char *name) { +const char *str;char help[BUFSIZ ];if (!e)
@@ -493,18 +494,18 @@ static void tracepoint_error(struct parse_events_error *e, int err,switch (err) {case EACCES : - e->str =strdup ("can't access trace events" ); + str ="can't access trace events" ;break ;case ENOENT : - e->str =strdup ("unknown tracepoint" ); + str ="unknown tracepoint" ;break ;default : - e->str =strdup ("failed to add tracepoint" ); + str ="failed to add tracepoint" ;break ; }tracing_path__strerror_open_tp (err, help,sizeof (help), sys, name); - e->help =strdup (help); +parse_events__handle_error (e,0 ,strdup (str),strdup (help)); } static int add_tracepoint(struct list_head *list, int *idx,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 336/350 mips: fix build when "48 bits virtual memory" is enabled
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
[ Upstream commit 3ed6751bb8fa89c3014399bb0414348499ee202a ]
With CONFIG_MIPS_VA_BITS_48=y the build fails miserably:
CC arch/mips/kernel/asm-offsets.s
In file included from arch/mips/include/asm/pgtable.h:644,
from include/linux/mm.h:99,
from arch/mips/kernel/asm-offsets.c:15:include/asm-generic/pgtable.h:16:2: error: #error CONFIG_PGTABLE_LEVELS is not consistent with __PAGETABLE_{P4D,PUD,PMD}_FOLDED
#error CONFIG_PGTABLE_LEVELS is not consistent with __PAGETABLE_{P4D,PUD,PMD}_FOLDED
^~~~~include/asm-generic/pgtable.h:390:28: error: unknown type name 'p4d_t'; did you mean 'pmd_t'?
static inline int p4d_same(p4d_t p4d_a, p4d_t p4d_b)
^~~~~
pmd_t[ ... more such errors ... ]
scripts/Makefile.build:99: recipe for target 'arch/mips/kernel/asm-offsets.s' failed make[2]: *** [arch/mips/kernel/asm-offsets.s] Error 1
This happens because when CONFIG_MIPS_VA_BITS_48 enables 4th level of the page tables, but neither pgtable-nop4d.h nor 5level-fixup.h are included to cope with the 5th level.
Replace #ifdef conditions around includes of the pgtable-nop{m,u}d.h with explicit CONFIG_PGTABLE_LEVELS and add include of 5level-fixup.h for the case when CONFIG_PGTABLE_LEVELS==4
--- arch/mips/include/asm/pgtable-64.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/mips/include/asm/pgtable-64.h +7 -2
@@ -18,10 +18,12 @@#include <asm/fixmap.h> #define __ARCH_USE_5LEVEL_HACK -#if defined(CONFIG_PAGE_SIZE_64KB ) && !defined(CONFIG_MIPS_VA_BITS_48 ) +#if CONFIG_PGTABLE_LEVELS ==2 #include <asm-generic/pgtable-nopmd.h> -#elif !(defined(CONFIG_PAGE_SIZE_4KB ) && defined(CONFIG_MIPS_VA_BITS_48 )) +#elif CONFIG_PGTABLE_LEVELS ==3 #include <asm-generic/pgtable-nopud.h> +#else +#include <asm-generic/5level-fixup.h> #endif /*
@@ -216,6 +218,9 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)return pgd_val (pgd); } +#define pgd_phys (pgd) virt_to_phys((void *)pgd_val(pgd)) +#define pgd_page (pgd) (pfn_to_page(pgd_phys(pgd) >> PAGE_SHIFT)) +static inline pud_t *pud_offset (pgd_t *pgd,unsigned long address) {return (pud_t *)pgd_page_vaddr (*pgd) +pud_index (address);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 337/350 drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2
In reply to Sasha LevinFrom: Sam Bobroff <[email protected]>
[ Upstream commit 3d0e3ce52ce3eb4b9de3caf9c38dbb5a4d3e13c3 ]
The INTERRUPT_CNTL2 register expects a valid DMA address, but is currently set with a GPU MC address. This can cause problems on systems that detect the resulting DMA read from an invalid address (found on a Power8 guest).
Instead, use the DMA address of the dummy page because it will always be safe.
--- drivers/gpu/drm/amd/amdgpu/si_ih.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/si_ih.c +2 -1
@@ -64,7 +64,8 @@ static int si_ih_irq_init(struct amdgpu_device *adev)u32 interrupt_cntl, ih_cntl, ih_rb_cntl;si_ih_disable_interrupts (adev); -WREG32 (INTERRUPT_CNTL2 , adev->irq.ih.gpu_addr >>8 ); +/* set dummy read address to dummy page address */ +WREG32 (INTERRUPT_CNTL2 , adev->dummy_page_addr >>8 ); interrupt_cntl =RREG32 (INTERRUPT_CNTL ); interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE ; interrupt_cntl &= ~IH_REQ_NONSNOOP_EN ;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx