hwmon: (da9052) Synchronize access with mfd
Subsystems (50)
Sasha Levin
maintainerPATCH 171/606 staging: kpc2000: fix error return code in kp2000_pcie_probe()
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
commit b17884ccf29e127b16bba6aea1438c851c9f5af1 upstream.
Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Also removed var 'rv' since we can use 'err' instead.
--- drivers/staging/kpc2000/kpc2000/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +4 -5
@@ -298,7 +298,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, {int err =0 ;struct kp2000_device *pcard; -int rv;unsigned long reg_bar_phys_addr;unsigned long reg_bar_phys_len;unsigned long dma_bar_phys_addr;
@@ -445,11 +444,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,if (err <0 ) goto err_release_dma; - rv =request_irq (pcard->pdev->irq, kp2000_irq_handler,IRQF_SHARED , - pcard->name, pcard); -if (rv) { + err =request_irq (pcard->pdev->irq, kp2000_irq_handler,IRQF_SHARED , + pcard->name, pcard); +if (err) {dev_err (&pcard->pdev->dev, -"%s: failed to request_irq: %d\n" , __func__, rv); +"%s: failed to request_irq: %d\n" , __func__, err); goto err_disable_msi; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 172/606 staging: greybus: Fix uninitialized scalar variable
In reply to Sasha LevinFrom: Oscar Carter <[email protected]>
commit 34625c1931f8204c234c532b446b9f53c69f4b68 upstream.
In the "gb_tty_set_termios" function the "newline" variable is declared but not initialized. So the "flow_control" member is not initialized and the OR / AND operations with itself results in an undefined value in this member.
The purpose of the code is to set the flow control type, so remove the OR / AND self operator and set the value directly.
Addresses-Coverity-ID: 1374016 ("Uninitialized scalar variable")
--- drivers/staging/greybus/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/uart.c +2 -2
@@ -537,9 +537,9 @@ static void gb_tty_set_termios(struct tty_struct *tty, }if (C_CRTSCTS (tty) &&C_BAUD (tty) !=B0 ) - newline.flow_control |=GB_SERIAL_AUTO_RTSCTS_EN ; + newline.flow_control =GB_SERIAL_AUTO_RTSCTS_EN ;else - newline.flow_control &= ~GB_SERIAL_AUTO_RTSCTS_EN ; + newline.flow_control =0 ;if (memcmp (&gb_tty->line_coding, &newline,sizeof (newline))) {memcpy (&gb_tty->line_coding, &newline,sizeof (newline));
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 173/606 iio: adc: stm32-adc: fix device used to request dma
In reply to Sasha LevinFrom: Fabrice Gasnier <[email protected]>
commit 52cd91c27f3908b88e8b25aed4a4d20660abcc45 upstream.
DMA channel request should use device struct from platform device struct. Currently it's using iio device struct. But at this stage when probing, device struct isn't yet registered (e.g. device_register is done in iio_device_register). Since commit 71723a96b8b1 ("dmaengine: Create symlinks between DMA channels and slaves"), a warning message is printed as the links in sysfs can't be created, due to device isn't yet registered:
- Cannot create DMA slave symlink
- Cannot create DMA dma:rx symlink
Fix this by using device struct from platform device to request dma chan.
--- drivers/iio/adc/stm32-adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/adc/stm32-adc.c +4 -4
@@ -1812,18 +1812,18 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev)return 0 ; } -static int stm32_adc_dma_request (struct iio_dev *indio_dev) +static int stm32_adc_dma_request (struct device *dev,struct iio_dev *indio_dev) {struct stm32_adc *adc =iio_priv (indio_dev);struct dma_slave_config config;int ret; - adc->dma_chan =dma_request_chan (&indio_dev->dev,"rx" ); + adc->dma_chan =dma_request_chan (dev,"rx" );if (IS_ERR (adc->dma_chan)) { ret =PTR_ERR (adc->dma_chan);if (ret != -ENODEV ) {if (ret != -EPROBE_DEFER ) -dev_err (&indio_dev->dev, +dev_err (dev,"DMA channel request failed with %d\n" , ret);return ret;
@@ -1930,7 +1930,7 @@ static int stm32_adc_probe(struct platform_device *pdev)if (ret <0 )return ret; - ret =stm32_adc_dma_request (indio_dev); + ret =stm32_adc_dma_request (dev, indio_dev);if (ret <0 )return ret;
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 174/606 iio: adc: stm32-dfsdm: fix device used to request dma
In reply to Sasha LevinFrom: Fabrice Gasnier <[email protected]>
commit b455d06e6fb3c035711e8aab1ca18082ccb15d87 upstream.
DMA channel request should use device struct from platform device struct. Currently it's using iio device struct. But at this stage when probing, device struct isn't yet registered (e.g. device_register is done in iio_device_register). Since commit 71723a96b8b1 ("dmaengine: Create symlinks between DMA channels and slaves"), a warning message is printed as the links in sysfs can't be created, due to device isn't yet registered:
- Cannot create DMA slave symlink
- Cannot create DMA dma:rx symlink
Fix this by using device struct from platform device to request dma chan.
--- drivers/iio/adc/stm32-dfsdm-adc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/iio/adc/stm32-dfsdm-adc.c +11 -10
@@ -62,7 +62,7 @@ enum sd_converter_type {struct stm32_dfsdm_dev_data {int type; -int (*init)(struct iio_dev *indio_dev); +int (*init)(struct device *dev,struct iio_dev *indio_dev);unsigned int num_channels;const struct regmap_config *regmap_cfg; };
@@ -1365,11 +1365,12 @@ static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev) } } -static int stm32_dfsdm_dma_request (struct iio_dev *indio_dev) +static int stm32_dfsdm_dma_request (struct device *dev, +struct iio_dev *indio_dev) {struct stm32_dfsdm_adc *adc =iio_priv (indio_dev); - adc->dma_chan =dma_request_chan (&indio_dev->dev,"rx" ); + adc->dma_chan =dma_request_chan (dev,"rx" );if (IS_ERR (adc->dma_chan)) {int ret =PTR_ERR (adc->dma_chan);
@@ -1425,7 +1426,7 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, &adc->dfsdm->ch_list[ch->channel]); } -static int stm32_dfsdm_audio_init (struct iio_dev *indio_dev) +static int stm32_dfsdm_audio_init (struct device *dev,struct iio_dev *indio_dev) {struct iio_chan_spec *ch;struct stm32_dfsdm_adc *adc =iio_priv (indio_dev);
@@ -1452,10 +1453,10 @@ static int stm32_dfsdm_audio_init(struct iio_dev *indio_dev) indio_dev->num_channels =1 ; indio_dev->channels = ch; -return stm32_dfsdm_dma_request (indio_dev); +return stm32_dfsdm_dma_request (dev, indio_dev); } -static int stm32_dfsdm_adc_init (struct iio_dev *indio_dev) +static int stm32_dfsdm_adc_init (struct device *dev,struct iio_dev *indio_dev) {struct iio_chan_spec *ch;struct stm32_dfsdm_adc *adc =iio_priv (indio_dev);
@@ -1499,17 +1500,17 @@ static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev)init_completion (&adc->completion);/* Optionally request DMA */ - ret =stm32_dfsdm_dma_request (indio_dev); + ret =stm32_dfsdm_dma_request (dev, indio_dev);if (ret) {if (ret != -ENODEV ) {if (ret != -EPROBE_DEFER ) -dev_err (&indio_dev->dev, +dev_err (dev,"DMA channel request failed with %d\n" , ret);return ret; } -dev_dbg (&indio_dev->dev,"No DMA support\n" ); +dev_dbg (dev,"No DMA support\n" );return 0 ; }
@@ -1622,7 +1623,7 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) adc->dfsdm->fl_list[adc->fl_id].sync_mode = val; adc->dev_data = dev_data; - ret = dev_data->init (iio); + ret = dev_data->init (dev, iio);if (ret <0 )return ret;
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 175/606 iio: sca3000: Remove an erroneous 'get_device()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
commit 928edefbc18cd8433f7df235c6e09a9306e7d580 upstream.
This looks really unusual to have a 'get_device()' hidden in a 'dev_err()' call.
Remove it.
While at it add a missing \n at the end of the message.
--- drivers/iio/accel/sca3000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/sca3000.c +1 -1
@@ -980,7 +980,7 @@ static int sca3000_read_data(struct sca3000_state *st, st->tx[0 ] =SCA3000_READ_REG (reg_address_high); ret =spi_sync_transfer (st->us, xfer,ARRAY_SIZE (xfer));if (ret) { -dev_err (get_device (&st->us->dev),"problem reading register" ); +dev_err (&st->us->dev,"problem reading register\n" );return ret; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 176/606 iio: dac: vf610: Fix an error handling path in 'vf610_dac_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
commit aad4742fbf0a560c25827adb58695a4497ffc204 upstream.
A call to 'vf610_dac_exit()' is missing in an error handling path.
--- drivers/iio/dac/vf610_dac.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/dac/vf610_dac.c +1 -0
@@ -223,6 +223,7 @@ static int vf610_dac_probe(struct platform_device *pdev)return 0 ; error_iio_device_register: +vf610_dac_exit (info);clk_disable_unprepare (info->clk);return ret;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 177/606 iio: adc: ti-ads8344: Fix channel selection
In reply to Sasha LevinFrom: Gregory CLEMENT <[email protected]>
commit bcfa1e253d2e329e1ebab5c89f3c73f6dd17606c upstream.
During initial submission the selection of the channel was done using the scan_index member of the iio_chan_spec structure. It was an abuse because this member is supposed to be used with a buffer so it was removed.
However there was still the need to be able to known how to select a channel, the correct member to store this information is address.
Thanks to this it is possible to select any other channel than the channel 0.
--- drivers/iio/adc/ti-ads8344.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/ti-ads8344.c +5 -3
@@ -32,16 +32,17 @@ struct ads8344 {u8 rx_buf[3 ]; }; -#define ADS8344_VOLTAGE_CHANNEL (chan, si) \ +#define ADS8344_VOLTAGE_CHANNEL (chan, addr) \ { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .channel = chan, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .address = addr, \ } -#define ADS8344_VOLTAGE_CHANNEL_DIFF (chan1, chan2, si) \ +#define ADS8344_VOLTAGE_CHANNEL_DIFF (chan1, chan2, addr) \ { \ .type = IIO_VOLTAGE, \ .indexed = 1, \
@@ -50,6 +51,7 @@ struct ads8344 { .differential = 1, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .address = addr, \ }static const struct iio_chan_spec ads8344_channels[] = {
@@ -105,7 +107,7 @@ static int ads8344_read_raw(struct iio_dev *iio,switch (mask) {case IIO_CHAN_INFO_RAW :mutex_lock (&adc->lock); - *value =ads8344_adc_conversion (adc, channel->scan_index, + *value =ads8344_adc_conversion (adc, channel->address, channel->differential);mutex_unlock (&adc->lock);if (*value <0 )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 178/606 driver core: Fix SYNC_STATE_ONLY device link implementation
In reply to Sasha LevinFrom: Saravana Kannan <[email protected]>
commit 21c27f06587d2c18150d27ca2382a509ec55c482 upstream.
When SYNC_STATE_ONLY support was added in commit 05ef983e0d65 ("driver
core: Add device link support for SYNC_STATE_ONLY flag"), device_link_add() incorrectly skipped adding the new SYNC_STATE_ONLY device link to the supplier's and consumer's "device link" list.
This causes multiple issues:
- The device link is lost forever from driver core if the caller didn't keep track of it (caller typically isn't expected to). This is a memory leak.
- The device link is also never visible to any other code path after device_link_add() returns.
If we fix the "device link" list handling, that exposes a bunch of issues.
1. The device link "status" state management code rightfully doesn't handle the case where a DL_FLAG_MANAGED device link exists between a supplier and consumer, but the consumer manages to probe successfully before the supplier. The addition of DL_FLAG_SYNC_STATE_ONLY links break this assumption. This causes device_links_driver_bound() to throw a warning when this happens.
Since DL_FLAG_SYNC_STATE_ONLY device links are mainly used for creating proxy device links for child device dependencies and aren't useful once the consumer device probes successfully, this patch just deletes DL_FLAG_SYNC_STATE_ONLY device links once its consumer device probes. This way, we avoid the warning, free up some memory and avoid complicating the device links "status" state management code.
2. Creating a DL_FLAG_STATELESS device link between two devices that already have a DL_FLAG_SYNC_STATE_ONLY device link will result in the DL_FLAG_STATELESS flag not getting set correctly. This patch also fixes this.
Lastly, this patch also fixes minor whitespace issues.
--- drivers/base/core.c | 61 +++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 22 deletions(-)
drivers/base/core.c +39 -22
@@ -360,13 +360,12 @@ struct device_link *device_link_add(struct device *consumer,if (flags &DL_FLAG_STATELESS ) {kref_get (&link->kref); + link->flags |=DL_FLAG_STATELESS ;if (link->flags &DL_FLAG_SYNC_STATE_ONLY && - !(link->flags &DL_FLAG_STATELESS )) { - link->flags |=DL_FLAG_STATELESS ; + !(link->flags &DL_FLAG_STATELESS )) goto reorder; - }else { +else goto out; - } }/*
@@ -433,12 +432,16 @@ struct device_link *device_link_add(struct device *consumer, flags & DL_FLAG_PM_RUNTIME)pm_runtime_resume (supplier); +list_add_tail_rcu (&link->s_node, &supplier->links.consumers); +list_add_tail_rcu (&link->c_node, &consumer->links.suppliers); +if (flags &DL_FLAG_SYNC_STATE_ONLY ) {dev_dbg (consumer,"Linked as a sync state only consumer to %s\n" ,dev_name (supplier)); goto out; } + reorder:/* * Move the consumer and all of the devices depending on it to the end
@@ -449,12 +452,9 @@ struct device_link *device_link_add(struct device *consumer,*/ device_reorder_to_tail (consumer,NULL ); -list_add_tail_rcu (&link->s_node, &supplier->links.consumers); -list_add_tail_rcu (&link->c_node, &consumer->links.suppliers); -dev_dbg (consumer,"Linked as a consumer to %s\n" ,dev_name (supplier)); - out: +out:device_pm_unlock ();device_links_write_unlock ();
@@ -829,6 +829,13 @@ static void __device_links_supplier_defer_sync(struct device *sup)list_add_tail (&sup->links.defer_sync, &deferred_sync); } +static void device_link_drop_managed (struct device_link *link) +{ + link->flags &= ~DL_FLAG_MANAGED ; +WRITE_ONCE (link->status,DL_STATE_NONE ); +kref_put (&link->kref, __device_link_del); +} +/** * device_links_driver_bound - Update device links after probing its driver. * @dev: Device to update the links for.
@@ -842,7 +849,7 @@ static void __device_links_supplier_defer_sync(struct device *sup)*/ void device_links_driver_bound (struct device *dev) { -struct device_link *link; +struct device_link *link, *ln;LIST_HEAD (sync_list);/*
@@ -882,18 +889,35 @@ void device_links_driver_bound(struct device *dev)else __device_links_queue_sync_state (dev, &sync_list); -list_for_each_entry (link, &dev->links.suppliers, c_node) { +list_for_each_entry_safe (link, ln, &dev->links.suppliers, c_node) { +struct device *supplier; +if (!(link->flags &DL_FLAG_MANAGED ))continue ; -WARN_ON (link->status !=DL_STATE_CONSUMER_PROBE ); -WRITE_ONCE (link->status,DL_STATE_ACTIVE ); + supplier = link->supplier; +if (link->flags &DL_FLAG_SYNC_STATE_ONLY ) { +/* +* When DL_FLAG_SYNC_STATE_ONLY is set, it means no +* other DL_MANAGED_LINK_FLAGS have been set. So, it's +* save to drop the managed link completely. +*/ +device_link_drop_managed (link); + }else { +WARN_ON (link->status !=DL_STATE_CONSUMER_PROBE ); +WRITE_ONCE (link->status,DL_STATE_ACTIVE ); + } +/* +* This needs to be done even for the deleted +* DL_FLAG_SYNC_STATE_ONLY device link in case it was the last +* device link that was preventing the supplier from getting a +* sync_state() call. +*/ if (defer_sync_state_count) -__device_links_supplier_defer_sync (link->supplier); +__device_links_supplier_defer_sync (supplier);else -__device_links_queue_sync_state (link->supplier, - &sync_list); +__device_links_queue_sync_state (supplier, &sync_list); } dev->links.status =DL_DEV_DRIVER_BOUND ;
@@ -903,13 +927,6 @@ void device_links_driver_bound(struct device *dev)device_links_flush_sync_list (&sync_list, dev); } -static void device_link_drop_managed (struct device_link *link) -{ - link->flags &= ~DL_FLAG_MANAGED ; -WRITE_ONCE (link->status,DL_STATE_NONE ); -kref_put (&link->kref, __device_link_del); -} -/** * __device_links_no_driver - Update links of a device without a driver. * @dev: Device without a drvier.
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 179/606 driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links
In reply to Sasha LevinFrom: Saravana Kannan <[email protected]>
commit 44e960490ddf868fc9135151c4a658936e771dc2 upstream.
Commit 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link implementation") didn't completely fix STATELESS + SYNC_STATE_ONLY handling.
What looks like an optimization in that commit is actually a bug that causes an if condition to always take the else path. This prevents reordering of devices in the dpm_list when a DL_FLAG_STATELESS device link is create on top of an existing DL_FLAG_SYNC_STATE_ONLY device link.
--- drivers/base/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/base/core.c +5 -3
@@ -360,12 +360,14 @@ struct device_link *device_link_add(struct device *consumer,if (flags &DL_FLAG_STATELESS ) {kref_get (&link->kref); - link->flags |=DL_FLAG_STATELESS ;if (link->flags &DL_FLAG_SYNC_STATE_ONLY && - !(link->flags &DL_FLAG_STATELESS )) + !(link->flags &DL_FLAG_STATELESS )) { + link->flags |=DL_FLAG_STATELESS ; goto reorder; -else + }else { + link->flags |=DL_FLAG_STATELESS ; goto out; + } }/*
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 180/606 misc: rtsx: Add short delay after exit from ASPM
In reply to Sasha LevinFrom: Klaus Doth <[email protected]>
commit 7a839dbab1be59f5ed3b3b046de29e166784c9b4 upstream.
DMA transfers to and from the SD card stall for 10 seconds and run into timeout on RTS5260 card readers after ASPM was enabled.
Adding a short msleep after disabling ASPM fixes the issue on several Dell Precision 7530/7540 systems I tested.
This function is only called when waking up after the chip went into power-save after not transferring data for a few seconds. The added msleep does therefore not change anything in data transfer speed or induce any excessive waiting while data transfers are running, or the chip is sleeping. Only the transition from sleep to active is affected.
--- drivers/misc/cardreader/rtsx_pcr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/cardreader/rtsx_pcr.c +3 -0
@@ -142,6 +142,9 @@ static void rtsx_comm_pm_full_on(struct rtsx_pcr *pcr)rtsx_disable_aspm (pcr); +/* Fixes DMA transfer timout issue after disabling ASPM on RTS5260 */ +msleep (1 ); +if (option->ltr_enabled)rtsx_set_ltr_latency (pcr, option->ltr_active_latency);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 181/606 tty: serial: add missing spin_lock_init for SiFive serial console
In reply to Sasha LevinFrom: Sagar Shrikant Kadam <[email protected]>
commit 17b4efdf4e4867079012a48ca10d965fe9d68822 upstream.
An uninitialised spin lock for sifive serial console raises a bad magic spin_lock error as reported and discussed here [1]. Initialising the spin lock resolves the issue.
The fix is tested on HiFive Unleashed A00 board with Linux 5.7-rc4 and OpenSBI v0.7
[1] https://lore.kernel.org/linux-riscv/[email protected]
--- drivers/tty/serial/sifive.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/sifive.c +1 -0
@@ -840,6 +840,7 @@ console_initcall(sifive_console_init);static void __ssp_add_console_port (struct sifive_serial_port *ssp) { +spin_lock_init (&ssp->port.lock); sifive_serial_console_ports[ssp->port.line] = ssp; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 182/606 mei: release me_cl object reference
In reply to Sasha LevinFrom: Alexander Usyskin <[email protected]>
commit fc9c03ce30f79b71807961bfcb42be191af79873 upstream.
Allow me_cl object to be freed by releasing the reference that was acquired by one of the search functions:__mei_me_cl_by_uuid_id() or __mei_me_cl_by_uuid()
--- drivers/misc/mei/client.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/mei/client.c +2 -0
@@ -266,6 +266,7 @@ void mei_me_cl_rm_by_uuid(struct mei_device *dev, const uuid_le *uuid)down_write (&dev->me_clients_rwsem); me_cl =__mei_me_cl_by_uuid (dev, uuid);__mei_me_cl_del (dev, me_cl); +mei_me_cl_put (me_cl);up_write (&dev->me_clients_rwsem); }
@@ -287,6 +288,7 @@ void mei_me_cl_rm_by_uuid_id(struct mei_device *dev, const uuid_le *uuid, u8 id)down_write (&dev->me_clients_rwsem); me_cl =__mei_me_cl_by_uuid_id (dev, uuid, id);__mei_me_cl_del (dev, me_cl); +mei_me_cl_put (me_cl);up_write (&dev->me_clients_rwsem); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 183/606 ipack: tpci200: fix error return code in tpci200_register()
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
commit 133317479f0324f6faaf797c4f5f3e9b1b36ce35 upstream.
Fix to return negative error code -ENOMEM from the ioremap() error handling case instead of 0, as done elsewhere in this function.
--- drivers/ipack/carriers/tpci200.c | 1 + 1 file changed, 1 insertion(+)
drivers/ipack/carriers/tpci200.c +1 -0
@@ -306,6 +306,7 @@ static int tpci200_register(struct tpci200_board *tpci200)"(bn 0x%X, sn 0x%X) failed to map driver user space!" , tpci200->info->pdev->bus->number, tpci200->info->pdev->devfn); + res = -ENOMEM ; goto out_release_mem8_space; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 184/606 s390/pci: Fix s390_mmio_read/write with MIO
In reply to Sasha LevinFrom: Niklas Schnelle <[email protected]>
commit f058599e22d59e594e5aae1dc10560568d8f4a8b upstream.
The s390_mmio_read/write syscalls are currently broken when running with MIO.
The new pcistb_mio/pcstg_mio/pcilg_mio instructions are executed similiarly to normal load/store instructions and do address translation in the current address space. That means inside the kernel they are aware of mappings into kernel address space while outside the kernel they use user space mappings (usually created through mmap'ing a PCI device file).
Now when existing user space applications use the s390_pci_mmio_write and s390_pci_mmio_read syscalls, they pass I/O addresses that are mapped into user space so as to be usable with the new instructions without needing a syscall. Accessing these addresses with the old instructions as done currently leads to a kernel panic.
Also, for such a user space mapping there may not exist an equivalent kernel space mapping which means we can't just use the new instructions in kernel space.
Instead of replicating user mappings in the kernel which then might collide with other mappings, we can conceptually execute the new instructions as if executed by the user space application using the secondary address space. This even allows us to directly store to the user pointer without the need for copy_to/from_user().
--- arch/s390/include/asm/pci_io.h | 10 +- arch/s390/pci/pci_mmio.c | 213 ++++++++++++++++++++++++++++++++- 2 files changed, 219 insertions(+), 4 deletions(-)
arch/s390/include/asm/pci_io.h +8 -2
@@ -8,6 +8,10 @@#include <linux/slab.h> #include <asm/pci_insn.h> +/* I/O size constraints */ +#define ZPCI_MAX_READ_SIZE 8 +#define ZPCI_MAX_WRITE_SIZE 128 +/* I/O Map */ #define ZPCI_IOMAP_SHIFT 48#define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000UL
@@ -140,7 +144,8 @@ static inline int zpci_memcpy_fromio(void *dst,while (n >0 ) { size =zpci_get_max_write_size ((u64 __force ) src, - (u64 ) dst, n,8 ); + (u64 ) dst, n, +ZPCI_MAX_READ_SIZE ); rc =zpci_read_single (dst, src, size);if (rc)break ;
@@ -161,7 +166,8 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst,while (n >0 ) { size =zpci_get_max_write_size ((u64 __force ) dst, - (u64 ) src, n,128 ); + (u64 ) src, n, +ZPCI_MAX_WRITE_SIZE );if (size >8 )/* main path */ rc =zpci_write_block (dst, src, size);else
arch/s390/pci/pci_mmio.c +211 -2
248 lines not on this page · raw message
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 185/606 s390/kaslr: add support for R_390_JMP_SLOT relocation type
In reply to Sasha LevinFrom: Gerald Schaefer <[email protected]>
commit 4c1cbcbd6c56c79de2c07159be4f55386bb0bef2 upstream.
With certain kernel configurations, the R_390_JMP_SLOT relocation type might be generated, which is not expected by the KASLR relocation code, and the kernel stops with the message "Unknown relocation type".
This was found with a zfcpdump kernel config, where CONFIG_MODULES=n and CONFIG_VFIO=n. In that case, symbol_get() is used on undefined __weak symbols in virt/kvm/vfio.c, which results in the generation of R_390_JMP_SLOT relocation types.
Fix this by handling R_390_JMP_SLOT similar to R_390_GLOB_DAT.
--- arch/s390/kernel/machine_kexec_reloc.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kernel/machine_kexec_reloc.c +1 -0
@@ -28,6 +28,7 @@ int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,break ;case R_390_64 :/* Direct 64 bit. */ case R_390_GLOB_DAT : +case R_390_JMP_SLOT : *(u64 *)loc = val;break ;case R_390_PC16 :/* PC relative 16 bit. */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 186/606 device-dax: don't leak kernel memory to user space after unloading kmem
In reply to Sasha LevinFrom: David Hildenbrand <[email protected]>
commit 60858c00e5f018eda711a3aa84cf62214ef62d61 upstream.
Assume we have kmem configured and loaded:
[root@localhost ~]# cat /proc/iomem
...
140000000-33fffffff : Persistent Memory$
140000000-1481fffff : namespace0.0
150000000-33fffffff : dax0.0
150000000-33fffffff : System RAMAssume we try to unload kmem. This force-unloading will work, even if memory cannot get removed from the system.
[root@localhost ~]# rmmod kmem
[ 86.380228] removing memory fails, because memory [0x0000000150000000-0x0000000157ffffff] is onlined ... [ 86.431225] kmem dax0.0: DAX region [mem 0x150000000-0x33fffffff] cannot be hotremoved until the next reboot
Now, we can reconfigure the namespace:
[root@localhost ~]# ndctl create-namespace --force --reconfig=namespace0.0 --mode=devdax [ 131.409351] nd_pmem namespace0.0: could not reserve region [mem 0x140000000-0x33fffffff]dax [ 131.410147] nd_pmem: probe of namespace0.0 failed with error -16namespace0.0 --mode=devdax ...
This fails as expected due to the busy memory resource, and the memory cannot be used. However, the dax0.0 device is removed, and along its name.
The name of the memory resource now points at freed memory (name of the device):
[root@localhost ~]# cat /proc/iomem
...
140000000-33fffffff : Persistent Memory
140000000-1481fffff : namespace0.0
150000000-33fffffff : �_�^7_��/_��wR��WQ���^��� ...
150000000-33fffffff : System RAMWe have to make sure to duplicate the string. While at it, remove the superfluous setting of the name and fixup a stale comment.
--- drivers/dax/kmem.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/dax/kmem.c +11 -3
@@ -22,6 +22,7 @@ int dev_dax_kmem_probe(struct device *dev)resource_size_t kmem_size;resource_size_t kmem_end;struct resource *new_res; +const char *new_res_name;int numa_node;int rc;
@@ -48,11 +49,16 @@ int dev_dax_kmem_probe(struct device *dev) kmem_size &= ~(memory_block_size_bytes () -1 ); kmem_end = kmem_start + kmem_size; -/* Region is permanently reserved. Hot-remove not yet implemented. */ - new_res =request_mem_region (kmem_start, kmem_size,dev_name (dev)); + new_res_name =kstrdup (dev_name (dev),GFP_KERNEL ); +if (!new_res_name) +return -ENOMEM ; + +/* Region is permanently reserved if hotremove fails. */ + new_res =request_mem_region (kmem_start, kmem_size, new_res_name);if (!new_res) {dev_warn (dev,"could not reserve region [%pa-%pa]\n" , &kmem_start, &kmem_end); +kfree (new_res_name);return -EBUSY ; }
@@ -63,12 +69,12 @@ int dev_dax_kmem_probe(struct device *dev)* unknown to us that will break add_memory() below. */ new_res->flags =IORESOURCE_SYSTEM_RAM ; - new_res->name =dev_name (dev); rc =add_memory (numa_node, new_res->start,resource_size (new_res));if (rc) {release_resource (new_res);kfree (new_res); +kfree (new_res_name);return rc; } dev_dax->dax_kmem_res = new_res;
@@ -83,6 +89,7 @@ static int dev_dax_kmem_remove(struct device *dev)struct resource *res = dev_dax->dax_kmem_res;resource_size_t kmem_start = res->start;resource_size_t kmem_size =resource_size (res); +const char *res_name = res->name;int rc;/*
@@ -102,6 +109,7 @@ static int dev_dax_kmem_remove(struct device *dev)/* Release and free dax resources */ release_resource (res);kfree (res); +kfree (res_name); dev_dax->dax_kmem_res =NULL ;return 0 ;
Signature · 4 lines
2.25.1 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Sasha Levin
maintainerPATCH 187/606 rapidio: fix an error in get_user_pages_fast() error handling
In reply to Sasha LevinFrom: John Hubbard <[email protected]>
commit ffca476a0a8d26de767cc41d62b8ca7f540ecfdd upstream.
In the case of get_user_pages_fast() returning fewer pages than requested, rio_dma_transfer() does not quite do the right thing. It attempts to release all the pages that were requested, rather than just the pages that were pinned.
Fix the error handling so that only the pages that were successfully pinned are released.
--- drivers/rapidio/devices/rio_mport_cdev.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/rapidio/devices/rio_mport_cdev.c +5 -0
@@ -877,6 +877,11 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,rmcd_error ("pinned %ld out of %ld pages" , pinned, nr_pages); ret = -EFAULT ; +/* +* Set nr_pages up to mean "how many pages to unpin, in +* the error handler: +*/ + nr_pages = pinned; goto err_pg; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 188/606 kasan: disable branch tracing for core runtime
In reply to Sasha LevinFrom: Marco Elver <[email protected]>
commit 33cd65e73abd693c00c4156cf23677c453b41b3b upstream.
During early boot, while KASAN is not yet initialized, it is possible to enter reporting code-path and end up in kasan_report().
While uninitialized, the branch there prevents generating any reports, however, under certain circumstances when branches are being traced (TRACE_BRANCH_PROFILING), we may recurse deep enough to cause kernel reboots without warning.
To prevent similar issues in future, we should disable branch tracing for the core runtime.
--- mm/kasan/Makefile | 8 ++++---- mm/kasan/generic.c | 1 - mm/kasan/tags.c | 1 - 3 files changed, 4 insertions(+), 6 deletions(-)
mm/kasan/Makefile +4 -4
@@ -14,10 +14,10 @@ CFLAGS_REMOVE_tags.o = $(CC_FLAGS_FTRACE) # Function splitter causes unnecessary splits in __asan_load1/__asan_store1 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533 -CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) +CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING obj-$(CONFIG_KASAN) := common.o init.o report.o obj-$(CONFIG_KASAN_GENERIC) += generic.o generic_report.o quarantine.o
mm/kasan/generic.c +0 -1
@@ -15,7 +15,6 @@*/ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#define DISABLE_BRANCH_PROFILING #include <linux/export.h> #include <linux/interrupt.h>
mm/kasan/tags.c +0 -1
@@ -12,7 +12,6 @@*/ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#define DISABLE_BRANCH_PROFILING #include <linux/export.h> #include <linux/interrupt.h>
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 189/606 sh: include linux/time_types.h for sockios
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
commit fc94cf2092c7c1267fa2deb8388d624f50eba808 upstream.
Using the socket ioctls on arch/sh (and only there) causes build time problems when __kernel_old_timeval/__kernel_old_timespec are not already visible to the compiler.
Add an explict include line for the header that defines these structures.
--- arch/sh/include/uapi/asm/sockios.h | 2 ++ 1 file changed, 2 insertions(+)
arch/sh/include/uapi/asm/sockios.h +2 -0
@@ -2,6 +2,8 @@#ifndef __ASM_SH_SOCKIOS_H#define __ASM_SH_SOCKIOS_H +#include <linux/time_types.h> +/* Socket-level I/O control calls. */ #define FIOGETOWN _IOR('f', 123, int)#define FIOSETOWN _IOW('f', 124, int)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 190/606 sparc32: use PUD rather than PGD to get PMD in srmmu_nocache_init()
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
commit c2bc26f7ca1ff1165bb6669a7a4cccc20ffd2ced upstream.
The kbuild test robot reported the following warning:
arch/sparc/mm/srmmu.c: In function 'srmmu_nocache_init': arch/sparc/mm/srmmu.c:300:9: error: variable 'pud' set but not used [-Werror=unused-but-set-variable] 300 | pud_t *pud;
This warning is caused by misprint in the page table traversal in srmmu_nocache_init() function which accessed a PMD entry using PGD rather than PUD.
Since sparc32 has only 3 page table levels, the PGD and PUD are essentially the same and usage of __nocache_fix() removed the type checking.
Use PUD for the consistency and to silence the compiler warning.
--- arch/sparc/mm/srmmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/mm/srmmu.c +1 -1
@@ -333,7 +333,7 @@ static void __init srmmu_nocache_init(void) pgd =pgd_offset_k (vaddr); p4d =p4d_offset (__nocache_fix (pgd), vaddr); pud =pud_offset (__nocache_fix (p4d), vaddr); - pmd =pmd_offset (__nocache_fix (pgd), vaddr); + pmd =pmd_offset (__nocache_fix (pud), vaddr); pte =pte_offset_kernel (__nocache_fix (pmd), vaddr); pteval = ((paddr >>4 ) |SRMMU_ET_PTE |SRMMU_PRIV );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 191/606 sparc32: fix page table traversal in srmmu_nocache_init()
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
commit 0cfc8a8d70dcd51db783e8e87917e02149c71458 upstream.
The srmmu_nocache_init() uses __nocache_fix() macro to add an offset to page table entry to access srmmu_nocache_pool.
But since sparc32 has only three actual page table levels, pgd, p4d and pud are essentially the same thing and pgd_offset() and p4d_offset() are no-ops, the __nocache_fix() should be done only at PUD level.
Remove __nocache_fix() for p4d_offset() and pud_offset() and keep it only for PUD and lower levels.
--- arch/sparc/mm/srmmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sparc/mm/srmmu.c +2 -2
@@ -331,8 +331,8 @@ static void __init srmmu_nocache_init(void)while (vaddr < srmmu_nocache_end) { pgd =pgd_offset_k (vaddr); - p4d =p4d_offset (__nocache_fix (pgd), vaddr); - pud =pud_offset (__nocache_fix (p4d), vaddr); + p4d =p4d_offset (pgd, vaddr); + pud =pud_offset (p4d, vaddr); pmd =pmd_offset (__nocache_fix (pud), vaddr); pte =pte_offset_kernel (__nocache_fix (pmd), vaddr);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 192/606 z3fold: fix use-after-free when freeing handles
In reply to Sasha LevinFrom: Uladzislau Rezki <[email protected]>
commit d8f117abb380ba968b5e3ef2042d901c02872a4c upstream.
free_handle() for a foreign handle may race with inter-page compaction, what can lead to memory corruption.
To avoid that, take write lock not read lock in free_handle to be synchronized with __release_z3fold_page().
For example KASAN can detect it:
==================================================================
BUG: KASAN: use-after-free in LZ4_decompress_safe+0x2c4/0x3b8
Read of size 1 at addr ffffffc976695ca3 by task GoogleApiHandle/4121
CPU: 0 PID: 4121 Comm: GoogleApiHandle Tainted: P S OE 4.19.81-perf+ #162
Hardware name: Sony Mobile Communications. PDX-203(KONA) (DT)
Call trace:
LZ4_decompress_safe+0x2c4/0x3b8
lz4_decompress_crypto+0x3c/0x70
crypto_decompress+0x58/0x70
zcomp_decompress+0xd4/0x120
...Apart from that, initialize zhdr->mapped_count in init_z3fold_page() and remove "newpage" variable because it is not used anywhere.
--- mm/z3fold.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
mm/z3fold.c +6 -5
@@ -318,16 +318,16 @@ static inline void free_handle(unsigned long handle) slots =handle_to_slots (handle);write_lock (&slots->lock); *(unsigned long *)handle =0 ; -write_unlock (&slots->lock); -if (zhdr->slots == slots) +if (zhdr->slots == slots) { +write_unlock (&slots->lock);return ;/* simple case, nothing else to do */ + }/* we are freeing a foreign handle if we are here */ zhdr->foreign_handles--; is_free = true; -read_lock (&slots->lock);if (!test_bit (HANDLES_ORPHANED , &slots->pool)) { -read_unlock (&slots->lock); +write_unlock (&slots->lock);return ; }for (i =0 ; i <=BUDDY_MASK ; i++) {
@@ -336,7 +336,7 @@ static inline void free_handle(unsigned long handle)break ; } } -read_unlock (&slots->lock); +write_unlock (&slots->lock);if (is_free) {struct z3fold_pool *pool =slots_to_pool (slots);
@@ -422,6 +422,7 @@ static struct z3fold_header *init_z3fold_page(struct page *page, bool headless, zhdr->start_middle =0 ; zhdr->cpu =-1 ; zhdr->foreign_handles =0 ; + zhdr->mapped_count =0 ; zhdr->slots = slots; zhdr->pool = pool;INIT_LIST_HEAD (&zhdr->buddy);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 193/606 iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
commit 115c215a7e5753ddf982c8760ce7904dd3fbb8ae upstream.
We need to release a lock if st_lsm6dsx_check_odr() fails, we can't return directly.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +5 -2
@@ -544,8 +544,10 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev, ref_sensor =iio_priv (hw->iio_devs[ST_LSM6DSX_ID_ACC ]); odr =st_lsm6dsx_check_odr (ref_sensor, val, &odr_val); -if (odr <0 ) -return odr; +if (odr <0 ) { + err = odr; + goto release; + } sensor->ext_info.slv_odr = val; sensor->odr = odr;
@@ -557,6 +559,7 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,break ; } +release:iio_device_release_direct_mode (iio_dev);return err;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 194/606 rxrpc: Fix the excessive initial retransmission timeout
In reply to Sasha LevinFrom: David Howells <[email protected]>
commit c410bf01933e5e09d142c66c3df9ad470a7eec13 upstream.
rxrpc currently uses a fixed 4s retransmission timeout until the RTT is sufficiently sampled. This can cause problems with some fileservers with calls to the cache manager in the afs filesystem being dropped from the fileserver because a packet goes missing and the retransmission timeout is greater than the call expiry timeout.
Fix this by:
(1) Copying the RTT/RTO calculation code from Linux's TCP implementation and altering it to fit rxrpc.
(2) Altering the various users of the RTT to make use of the new SRTT value.
(3) Replacing the use of rxrpc_resend_timeout to use the calculated RTO value instead (which is needed in jiffies), along with a backoff.
Notes:
(1) rxrpc provides RTT samples by matching the serial numbers on outgoing DATA packets that have the RXRPC_REQUEST_ACK set and PING ACK packets against the reference serial number in incoming REQUESTED ACK and PING-RESPONSE ACK packets.
(2) Each packet that is transmitted on an rxrpc connection gets a new per-connection serial number, even for retransmissions, so an ACK can be cross-referenced to a specific trigger packet. This allows RTT information to be drawn from retransmitted DATA packets also.
(3) rxrpc maintains the RTT/RTO state on the rxrpc_peer record rather than on an rxrpc_call because many RPC calls won't live long enough to generate more than one sample.
(4) The calculated SRTT value is in units of 8ths of a microsecond rather than nanoseconds.
The (S)RTT and RTO values are displayed in /proc/net/rxrpc/peers.
--- fs/afs/fs_probe.c | 18 +--- fs/afs/vl_probe.c | 18 +--- include/net/af_rxrpc.h | 2 +- include/trace/events/rxrpc.h | 17 ++- net/rxrpc/Makefile | 1 + net/rxrpc/ar-internal.h | 25 +++-- net/rxrpc/call_accept.c | 2 +- net/rxrpc/call_event.c | 22 ++-- net/rxrpc/input.c | 6 +- net/rxrpc/misc.c | 5 - net/rxrpc/output.c | 9 +- net/rxrpc/peer_event.c | 46 --------- net/rxrpc/peer_object.c | 12 ++- net/rxrpc/proc.c | 8 +- net/rxrpc/rtt.c | 195 +++++++++++++++++++++++++++++++++++ net/rxrpc/sendmsg.c | 26 ++--- net/rxrpc/sysctl.c | 9 -- 17 files changed, 266 insertions(+), 155 deletions(-) create mode 100644 net/rxrpc/rtt.c
fs/afs/fs_probe.c +5 -13
@@ -32,9 +32,8 @@ void afs_fileserver_probe_result(struct afs_call *call)struct afs_server *server = call->server;unsigned int server_index = call->server_index;unsigned int index = call->addr_ix; -unsigned int rtt =UINT_MAX ; +unsigned int rtt_us;bool have_result = false; -u64 _rtt;int ret = call->error;_enter ("%pU,%u" , &server->uuid, index);
@@ -93,15 +92,9 @@ void afs_fileserver_probe_result(struct afs_call *call) } } -/* Get the RTT and scale it to fit into a 32-bit value that represents -* over a minute of time so that we can access it with one instruction -* on a 32-bit system. -*/ - _rtt =rxrpc_kernel_get_rtt (call->net->socket, call->rxcall); - _rtt /=64 ; - rtt = (_rtt >UINT_MAX ) ?UINT_MAX : _rtt; -if (rtt < server->probe.rtt) { - server->probe.rtt = rtt; + rtt_us =rxrpc_kernel_get_srtt (call->net->socket, call->rxcall); +if (rtt_us < server->probe.rtt) { + server->probe.rtt = rtt_us; alist->preferred = index; have_result = true; }
@@ -113,8 +106,7 @@ void afs_fileserver_probe_result(struct afs_call *call)spin_unlock (&server->probe_lock);_debug ("probe [%u][%u] %pISpc rtt=%u ret=%d" , - server_index, index, &alist->addrs[index].transport, - (unsigned int )rtt, ret); + server_index, index, &alist->addrs[index].transport, rtt_us, ret); have_result |=afs_fs_probe_done (server);if (have_result) {
fs/afs/vl_probe.c +5 -13
@@ -31,10 +31,9 @@ void afs_vlserver_probe_result(struct afs_call *call)struct afs_addr_list *alist = call->alist;struct afs_vlserver *server = call->vlserver;unsigned int server_index = call->server_index; +unsigned int rtt_us =0 ;unsigned int index = call->addr_ix; -unsigned int rtt =UINT_MAX ;bool have_result = false; -u64 _rtt;int ret = call->error;_enter ("%s,%u,%u,%d,%d" , server->name, server_index, index, ret, call->abort_code);
@@ -93,15 +92,9 @@ void afs_vlserver_probe_result(struct afs_call *call) } } -/* Get the RTT and scale it to fit into a 32-bit value that represents -* over a minute of time so that we can access it with one instruction -* on a 32-bit system. -*/ - _rtt =rxrpc_kernel_get_rtt (call->net->socket, call->rxcall); - _rtt /=64 ; - rtt = (_rtt >UINT_MAX ) ?UINT_MAX : _rtt; -if (rtt < server->probe.rtt) { - server->probe.rtt = rtt; + rtt_us =rxrpc_kernel_get_srtt (call->net->socket, call->rxcall); +if (rtt_us < server->probe.rtt) { + server->probe.rtt = rtt_us; alist->preferred = index; have_result = true; }
@@ -113,8 +106,7 @@ void afs_vlserver_probe_result(struct afs_call *call)spin_unlock (&server->probe_lock);_debug ("probe [%u][%u] %pISpc rtt=%u ret=%d" , - server_index, index, &alist->addrs[index].transport, - (unsigned int )rtt, ret); + server_index, index, &alist->addrs[index].transport, rtt_us, ret); have_result |=afs_vl_probe_done (server);if (have_result) {
include/net/af_rxrpc.h +1 -1
@@ -59,7 +59,7 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,void rxrpc_kernel_end_call (struct socket *,struct rxrpc_call *);void rxrpc_kernel_get_peer (struct socket *,struct rxrpc_call *,struct sockaddr_rxrpc *); -u64 rxrpc_kernel_get_rtt (struct socket *,struct rxrpc_call *); +u32 rxrpc_kernel_get_srtt (struct socket *,struct rxrpc_call *);int rxrpc_kernel_charge_accept (struct socket *,rxrpc_notify_rx_t ,rxrpc_user_attach_call_t ,unsigned long ,gfp_t ,unsigned int );
include/trace/events/rxrpc.h +7 -10
@@ -1112,18 +1112,17 @@ TRACE_EVENT(rxrpc_rtt_tx, TRACE_EVENT(rxrpc_rtt_rx, TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why, rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial, - s64 rtt, u8 nr, s64 avg), + u32 rtt, u32 rto), - TP_ARGS(call, why, send_serial, resp_serial, rtt, nr, avg), + TP_ARGS(call, why, send_serial, resp_serial, rtt, rto), TP_STRUCT__entry( __field(unsigned int, call ) __field(enum rxrpc_rtt_rx_trace, why ) - __field(u8, nr ) __field(rxrpc_serial_t, send_serial ) __field(rxrpc_serial_t, resp_serial ) - __field(s64, rtt ) - __field(u64, avg ) + __field(u32, rtt ) + __field(u32, rto ) ), TP_fast_assign(
@@ -1132,18 +1131,16 @@ TRACE_EVENT(rxrpc_rtt_rx, __entry->send_serial = send_serial; __entry->resp_serial = resp_serial; __entry->rtt = rtt; - __entry->nr = nr; - __entry->avg = avg; + __entry->rto = rto; ), -TP_printk ("c=%08x %s sr=%08x rr=%08x rtt=%lld nr=%u avg=%lld" , +TP_printk ("c=%08x %s sr=%08x rr=%08x rtt=%u rto=%u" , __entry->call,__print_symbolic (__entry->why, rxrpc_rtt_rx_traces), __entry->send_serial, __entry->resp_serial, __entry->rtt, - __entry->nr, - __entry->avg) + __entry->rto) ); TRACE_EVENT(rxrpc_timer,
net/rxrpc/Makefile +1 -0
@@ -25,6 +25,7 @@ rxrpc-y := \ peer_event.o \ peer_object.o \ recvmsg.o \ + rtt.o \ security.o \ sendmsg.o \ skbuff.o \
net/rxrpc/ar-internal.h +17 -8
@@ -7,6 +7,7 @@#include <linux/atomic.h> #include <linux/seqlock.h> +#include <linux/win_minmax.h> #include <net/net_namespace.h> #include <net/netns/generic.h> #include <net/sock.h>
@@ -311,11 +312,14 @@ struct rxrpc_peer {#define RXRPC_RTT_CACHE_SIZE 32spinlock_t rtt_input_lock;/* RTT lock for input routine */ ktime_t rtt_last_req;/* Time of last RTT request */ -u64 rtt;/* Current RTT estimate (in nS) */ -u64 rtt_sum;/* Sum of cache contents */ -u64 rtt_cache[RXRPC_RTT_CACHE_SIZE ];/* Determined RTT cache */ -u8 rtt_cursor;/* next entry at which to insert */ -u8 rtt_usage;/* amount of cache actually used */ +unsigned int rtt_count;/* Number of samples we've got */ + +u32 srtt_us;/* smoothed round trip time << 3 in usecs */ +u32 mdev_us;/* medium deviation */ +u32 mdev_max_us;/* maximal mdev for the last rtt period */ +u32 rttvar_us;/* smoothed mdev_max */ +u32 rto_j;/* Retransmission timeout in jiffies */ +u8 backoff;/* Backoff timeout */ u8 cong_cwnd;/* Congestion window size */ };
@@ -1041,7 +1045,6 @@ extern unsigned long rxrpc_idle_ack_delay;extern unsigned int rxrpc_rx_window_size;extern unsigned int rxrpc_rx_mtu;extern unsigned int rxrpc_rx_jumbo_max; -extern unsigned long rxrpc_resend_timeout;extern const s8 rxrpc_ack_priority[];
@@ -1069,8 +1072,6 @@ void rxrpc_send_keepalive(struct rxrpc_peer *);* peer_event.c */ void rxrpc_error_report (struct sock *); -void rxrpc_peer_add_rtt (struct rxrpc_call *,enum rxrpc_rtt_rx_trace , -rxrpc_serial_t ,rxrpc_serial_t ,ktime_t ,ktime_t );void rxrpc_peer_keepalive_worker (struct work_struct *);/*
@@ -1102,6 +1103,14 @@ extern const struct seq_operations rxrpc_peer_seq_ops;void rxrpc_notify_socket (struct rxrpc_call *);int rxrpc_recvmsg (struct socket *,struct msghdr *,size_t ,int ); +/* +* rtt.c +*/ +void rxrpc_peer_add_rtt (struct rxrpc_call *,enum rxrpc_rtt_rx_trace , +rxrpc_serial_t ,rxrpc_serial_t ,ktime_t ,ktime_t ); +unsigned long rxrpc_get_rto_backoff (struct rxrpc_peer *,bool ); +void rxrpc_peer_init_rtt (struct rxrpc_peer *); +/* * rxkad.c */
net/rxrpc/call_accept.c +1 -1
@@ -248,7 +248,7 @@ static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)struct rxrpc_skb_priv *sp =rxrpc_skb (skb);ktime_t now = skb->tstamp; -if (call->peer->rtt_usage <3 || +if (call->peer->rtt_count <3 ||ktime_before (ktime_add_ms (call->peer->rtt_last_req,1000 ), now)) rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial, true, true,
net/rxrpc/call_event.c +8 -14
@@ -111,8 +111,8 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, }else {unsigned long now = jiffies, ack_at; -if (call->peer->rtt_usage >0 ) - ack_at =nsecs_to_jiffies (call->peer->rtt); +if (call->peer->srtt_us !=0 ) + ack_at =usecs_to_jiffies (call->peer->srtt_us >>3 );else ack_at = expiry;
@@ -157,24 +157,18 @@ static void rxrpc_congestion_timeout(struct rxrpc_call *call)static void rxrpc_resend (struct rxrpc_call *call,unsigned long now_j) {struct sk_buff *skb; -unsigned long resend_at; +unsigned long resend_at, rto_j;rxrpc_seq_t cursor, seq, top; -ktime_t now, max_age, oldest, ack_ts, timeout, min_timeo; +ktime_t now, max_age, oldest, ack_ts;int ix;u8 annotation, anno_type, retrans =0 , unacked =0 ;_enter ("{%d,%d}" , call->tx_hard_ack, call->tx_top); -if (call->peer->rtt_usage >1 ) - timeout =ns_to_ktime (call->peer->rtt *3 /2 ); -else - timeout =ms_to_ktime (rxrpc_resend_timeout); - min_timeo =ns_to_ktime ((1000000000 /HZ ) *4 ); -if (ktime_before (timeout, min_timeo)) - timeout = min_timeo; + rto_j = call->peer->rto_j; now =ktime_get_real (); - max_age =ktime_sub (now, timeout); + max_age =ktime_sub (now,jiffies_to_usecs (rto_j));spin_lock_bh (&call->lock);
@@ -219,7 +213,7 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j) } resend_at =nsecs_to_jiffies (ktime_to_ns (ktime_sub (now, oldest))); - resend_at += jiffies + rxrpc_resend_timeout; + resend_at += jiffies + rto_j;WRITE_ONCE (call->resend_at, resend_at);if (unacked)
@@ -234,7 +228,7 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j) rxrpc_timer_set_for_resend);spin_unlock_bh (&call->lock); ack_ts =ktime_sub (now, call->acks_latest_ts); -if (ktime_to_ns (ack_ts) < call->peer->rtt) +if (ktime_to_us (ack_ts) < (call->peer->srtt_us >>3 )) goto out;rxrpc_propose_ACK (call,RXRPC_ACK_PING ,0 , true, false, rxrpc_propose_ack_ping_for_lost_ack);
net/rxrpc/input.c +3 -3
@@ -91,11 +91,11 @@ static void rxrpc_congestion_management(struct rxrpc_call *call,/* We analyse the number of packets that get ACK'd per RTT * period and increase the window if we managed to fill it. */ -if (call->peer->rtt_usage ==0 ) +if (call->peer->rtt_count ==0 ) goto out;if (ktime_before (skb->tstamp, -ktime_add_ns (call->cong_tstamp, - call->peer->rtt))) +ktime_add_us (call->cong_tstamp, + call->peer->srtt_us >>3 ))) goto out_no_clear_ca; change = rxrpc_cong_rtt_window_end; call->cong_tstamp = skb->tstamp;
net/rxrpc/misc.c +0 -5
@@ -63,11 +63,6 @@ unsigned int rxrpc_rx_mtu = 5692;*/ unsigned int rxrpc_rx_jumbo_max =4 ; -/* -* Time till packet resend (in milliseconds). -*/ -unsigned long rxrpc_resend_timeout =4 *HZ ; -const s8 rxrpc_ack_priority[] = { [0 ] =0 , [RXRPC_ACK_DELAY ] =1 ,
net/rxrpc/output.c +3 -6
@@ -369,7 +369,7 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb, (test_and_clear_bit (RXRPC_CALL_EV_ACK_LOST , &call->events) || retrans || call->cong_mode ==RXRPC_CALL_SLOW_START || - (call->peer->rtt_usage <3 && sp->hdr.seq &1 ) || + (call->peer->rtt_count <3 && sp->hdr.seq &1 ) ||ktime_before (ktime_add_ms (call->peer->rtt_last_req,1000 ), ktime_get_real()))) whdr.flags |= RXRPC_REQUEST_ACK;
@@ -423,13 +423,10 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,if (whdr.flags &RXRPC_REQUEST_ACK ) { call->peer->rtt_last_req = skb->tstamp;trace_rxrpc_rtt_tx (call, rxrpc_rtt_tx_data, serial); -if (call->peer->rtt_usage >1 ) { +if (call->peer->rtt_count >1 ) {unsigned long nowj = jiffies, ack_lost_at; - ack_lost_at =nsecs_to_jiffies (2 * call->peer->rtt); -if (ack_lost_at <1 ) - ack_lost_at =1 ; - + ack_lost_at =rxrpc_get_rto_backoff (call->peer, retrans); ack_lost_at += nowj;WRITE_ONCE (call->ack_lost_at, ack_lost_at); rxrpc_reduce_call_timer(call, ack_lost_at, nowj,
net/rxrpc/peer_event.c +0 -46
52 lines not on this page · raw message
net/rxrpc/peer_object.c +7 -5
@@ -225,6 +225,8 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp)spin_lock_init (&peer->rtt_input_lock); peer->debug_id =atomic_inc_return (&rxrpc_debug_id); +rxrpc_peer_init_rtt (peer); +if (RXRPC_TX_SMSS >2190 ) peer->cong_cwnd =2 ;else if (RXRPC_TX_SMSS >1095 )
@@ -497,14 +499,14 @@ void rxrpc_kernel_get_peer(struct socket *sock, struct rxrpc_call *call,EXPORT_SYMBOL (rxrpc_kernel_get_peer);/** -* rxrpc_kernel_get_rtt - Get a call's peer RTT +* rxrpc_kernel_get_srtt - Get a call's peer smoothed RTT * @sock: The socket on which the call is in progress. * @call: The call to query * -* Get the call's peer RTT. +* Get the call's peer smoothed RTT. */ -u64 rxrpc_kernel_get_rtt (struct socket *sock,struct rxrpc_call *call) +u32 rxrpc_kernel_get_srtt (struct socket *sock,struct rxrpc_call *call) { -return call->peer->rtt; +return call->peer->srtt_us >>3 ; } -EXPORT_SYMBOL (rxrpc_kernel_get_rtt); +EXPORT_SYMBOL (rxrpc_kernel_get_srtt);
net/rxrpc/proc.c +4 -4
@@ -222,7 +222,7 @@ static int rxrpc_peer_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"Proto Local " " Remote " -" Use CW MTU LastUse RTT Rc\n" +" Use CW MTU LastUse RTT RTO\n" );return 0 ; }
@@ -236,15 +236,15 @@ static int rxrpc_peer_seq_show(struct seq_file *seq, void *v) now =ktime_get_seconds ();seq_printf (seq,"UDP %-47.47s %-47.47s %3u" -" %3u %5u %6llus %12llu %2u\n" , +" %3u %5u %6llus %8u %8u\n" , lbuff, rbuff,atomic_read (&peer->usage), peer->cong_cwnd, peer->mtu, now - peer->last_tx_at, - peer->rtt, - peer->rtt_cursor); + peer->srtt_us >>3 , +jiffies_to_usecs (peer->rto_j));return 0 ; }
net/rxrpc/rtt.c new file +195 -0
195 lines not on this page · raw message
net/rxrpc/sendmsg.c +9 -17
@@ -66,15 +66,14 @@ static int rxrpc_wait_for_tx_window_waitall(struct rxrpc_sock *rx, struct rxrpc_call *call) {rxrpc_seq_t tx_start, tx_win; -signed long rtt2, timeout; -u64 rtt; +signed long rtt, timeout; - rtt =READ_ONCE (call->peer->rtt); - rtt2 =nsecs_to_jiffies64 (rtt) *2 ; -if (rtt2 <2 ) - rtt2 =2 ; + rtt =READ_ONCE (call->peer->srtt_us) >>3 ; + rtt =usecs_to_jiffies (rtt) *2 ; +if (rtt <2 ) + rtt =2 ; - timeout = rtt2; + timeout = rtt; tx_start =READ_ONCE (call->tx_hard_ack);for (;;) {
@@ -92,7 +91,7 @@ static int rxrpc_wait_for_tx_window_waitall(struct rxrpc_sock *rx,return -EINTR ;if (tx_win != tx_start) { - timeout = rtt2; + timeout = rtt; tx_start = tx_win; }
@@ -271,16 +270,9 @@ static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,_debug ("need instant resend %d" , ret);rxrpc_instant_resend (call, ix); }else { -unsigned long now = jiffies, resend_at; +unsigned long now = jiffies; +unsigned long resend_at = now + call->peer->rto_j; -if (call->peer->rtt_usage >1 ) - resend_at =nsecs_to_jiffies (call->peer->rtt *3 /2 ); -else - resend_at = rxrpc_resend_timeout; -if (resend_at <1 ) - resend_at =1 ; - - resend_at += now;WRITE_ONCE (call->resend_at, resend_at);rxrpc_reduce_call_timer (call, resend_at, now, rxrpc_timer_set_for_send);
net/rxrpc/sysctl.c +0 -9
@@ -71,15 +71,6 @@ static struct ctl_table rxrpc_sysctl_table[] = { .extra1 = (void *)&one_jiffy, .extra2 = (void *)&max_jiffies, }, - { - .procname = "resend_timeout", - .data = &rxrpc_resend_timeout, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = proc_doulongvec_ms_jiffies_minmax, - .extra1 = (void *)&one_jiffy, - .extra2 = (void *)&max_jiffies, - },/* Non-time values */ {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 195/606 rxrpc: Fix a memory leak in rxkad_verify_response()
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
commit f45d01f4f30b53c3a0a1c6c1c154acb7ff74ab9f upstream.
A ticket was not released after a call of the function "rxkad_decrypt_ticket" failed. Thus replace the jump target "temporary_error_free_resp" by "temporary_error_free_ticket".
--- net/rxrpc/rxkad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/rxrpc/rxkad.c +1 -2
@@ -1148,7 +1148,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, ret =rxkad_decrypt_ticket (conn, skb, ticket, ticket_len, &session_key, &expiry, _abort_code);if (ret <0 ) - goto temporary_error_free_resp; + goto temporary_error_free_ticket;/* use the session key from inside the ticket to decrypt the * response */
@@ -1230,7 +1230,6 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, temporary_error_free_ticket:kfree (ticket); -temporary_error_free_resp:kfree (response); temporary_error:/* Ignore the response packet if we got a temporary error such as
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 196/606 tpm: check event log version before reading final events
In reply to Sasha LevinFrom: Loïc Yhuel <[email protected]>
commit b4f1874c62168159fdb419ced4afc77c1b51c475 upstream.
This fixes the boot issues since 5.3 on several Dell models when the TPM is enabled. Depending on the exact grub binary, booting the kernel would freeze early, or just report an error parsing the final events log.
We get an event log in the SHA-1 format, which doesn't have a tcg_efi_specid_event_head in the first event, and there is a final events table which doesn't match the crypto agile format. __calc_tpm2_event_size reads bad "count" and "efispecid->num_algs", and either fails, or loops long enough for the machine to be appear frozen.
So we now only parse the final events table, which is per the spec always supposed to be in the crypto agile format, when we got a event log in this format.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1779611
--- drivers/firmware/efi/libstub/tpm.c | 5 +++-- drivers/firmware/efi/tpm.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/firmware/efi/libstub/tpm.c +3 -2
@@ -54,7 +54,7 @@ void efi_retrieve_tpm2_eventlog(void)efi_status_t status;efi_physical_addr_t log_location =0 , log_last_entry =0 ;struct linux_efi_tpm_eventlog *log_tbl =NULL ; -struct efi_tcg2_final_events_table *final_events_table; +struct efi_tcg2_final_events_table *final_events_table =NULL ;unsigned long first_entry_addr, last_entry_addr;size_t log_size, last_entry_size;efi_bool_t truncated;
@@ -127,7 +127,8 @@ void efi_retrieve_tpm2_eventlog(void)* Figure out whether any events have already been logged to the * final events structure, and if so how much space they take up */ - final_events_table =get_efi_config_table (LINUX_EFI_TPM_FINAL_LOG_GUID ); +if (version ==EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 ) + final_events_table =get_efi_config_table (LINUX_EFI_TPM_FINAL_LOG_GUID );if (final_events_table && final_events_table->nr_events) {struct tcg_pcr_event2_head *header;int offset;
drivers/firmware/efi/tpm.c +4 -1
@@ -62,8 +62,11 @@ int __init efi_tpm_eventlog_init(void) tbl_size =sizeof (*log_tbl) + log_tbl->size;memblock_reserve (efi.tpm_log, tbl_size); -if (efi.tpm_final_log ==EFI_INVALID_TABLE_ADDR ) +if (efi.tpm_final_log ==EFI_INVALID_TABLE_ADDR || + log_tbl->version !=EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 ) { +pr_warn (FW_BUG "TPM Final Events table missing or invalid\n" ); goto out; + } final_tbl =early_memremap (efi.tpm_final_log,sizeof (*final_tbl));
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 197/606 s390/kexec_file: fix initrd location for kdump kernel
In reply to Sasha LevinFrom: Philipp Rudo <[email protected]>
commit 70b690547d5ea1a3d135a4cc39cd1e08246d0c3a upstream.
initrd_start must not point at the location the initrd is loaded into the crashkernel memory but at the location it will be after the crashkernel memory is swapped with the memory at 0.
--- arch/s390/kernel/machine_kexec_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/machine_kexec_file.c +1 -1
@@ -151,7 +151,7 @@ static int kexec_file_add_initrd(struct kimage *image, buf.mem += crashk_res.start; buf.memsz = buf.bufsz; - data->parm->initrd_start = buf.mem; + data->parm->initrd_start = data->memsz; data->parm->initrd_size = buf.memsz; data->memsz += buf.memsz;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 198/606 flow_dissector: Drop BPF flow dissector prog ref on netns cleanup
In reply to Sasha LevinFrom: Jakub Sitnicki <[email protected]>
commit 5cf65922bb15279402e1e19b5ee8c51d618fa51f upstream.
When attaching a flow dissector program to a network namespace with bpf(BPF_PROG_ATTACH, ...) we grab a reference to bpf_prog.
If netns gets destroyed while a flow dissector is still attached, and there are no other references to the prog, we leak the reference and the program remains loaded.
Leak can be reproduced by running flow dissector tests from selftests/bpf:
# bpftool prog list
# ./test_flow_dissector.sh
...
selftests: test_flow_dissector [PASS]
# bpftool prog list
4: flow_dissector name _dissect tag e314084d332a5338 gpl
loaded_at 2020-05-20T18:50:53+0200 uid 0
xlated 552B jited 355B memlock 4096B map_ids 3,4
btf_id 4
#Fix it by detaching the flow dissector program when netns is going away.
--- net/core/flow_dissector.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
net/core/flow_dissector.c +21 -5
@@ -160,12 +160,10 @@ int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,return ret; } -int skb_flow_dissector_bpf_prog_detach (const union bpf_attr *attr) +static int flow_dissector_bpf_prog_detach (struct net *net) {struct bpf_prog *attached; -struct net *net; - net = current->nsproxy->net_ns;mutex_lock (&flow_dissector_mutex); attached =rcu_dereference_protected (net->flow_dissector_prog,lockdep_is_held (&flow_dissector_mutex));
@@ -179,6 +177,24 @@ int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)return 0 ; } +int skb_flow_dissector_bpf_prog_detach (const union bpf_attr *attr) +{ +return flow_dissector_bpf_prog_detach (current->nsproxy->net_ns); +} + +static void __net_exit flow_dissector_pernet_pre_exit(struct net *net) +{ +/* We're not racing with attach/detach because there are no +* references to netns left when pre_exit gets called. +*/ +if (rcu_access_pointer (net->flow_dissector_prog)) +flow_dissector_bpf_prog_detach (net); +} + +static struct pernet_operations flow_dissector_pernet_ops__net_initdata = { + .pre_exit = flow_dissector_pernet_pre_exit, +}; +/** * __skb_flow_get_ports - extract the upper layer ports and return them * @skb: sk_buff to extract the ports from
@@ -1838,7 +1854,7 @@ static int __init init_default_flow_dissectors(void)skb_flow_dissector_init (&flow_keys_basic_dissector, flow_keys_basic_dissector_keys,ARRAY_SIZE (flow_keys_basic_dissector_keys)); -return 0 ; -} +return register_pernet_subsys (&flow_dissector_pernet_ops); +}core_initcall (init_default_flow_dissectors);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 199/606 x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
commit 187b96db5ca79423618dfa29a05c438c34f9e1f0 upstream.
Normally, show_trace_log_lvl() scans the stack, looking for text addresses to print. In parallel, it unwinds the stack with unwind_next_frame(). If the stack address matches the pointer returned by unwind_get_return_address_ptr() for the current frame, the text address is printed normally without a question mark. Otherwise it's considered a breadcrumb (potentially from a previous call path) and it's printed with a question mark to indicate that the address is unreliable and typically can be ignored.
Since the following commit:
f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tasks")
... for inactive tasks, show_trace_log_lvl() prints *only* unreliable addresses (prepended with '?').
That happens because, for the first frame of an inactive task, unwind_get_return_address_ptr() returns the wrong return address
pointer: one word *below* the task stack pointer. show_trace_log_lvl() starts scanning at the stack pointer itself, so it never finds the first 'reliable' address, causing only guesses to being printed.
The first frame of an inactive task isn't a normal stack frame. It's actually just an instance of 'struct inactive_task_frame' which is left behind by __switch_to_asm(). Now that this inactive frame is actually exposed to callers, fix unwind_get_return_address_ptr() to interpret it properly.
--- arch/x86/kernel/unwind_orc.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/unwind_orc.c +7 -0
@@ -314,12 +314,19 @@ EXPORT_SYMBOL_GPL(unwind_get_return_address);unsigned long *unwind_get_return_address_ptr (struct unwind_state *state) { +struct task_struct *task = state->task; +if (unwind_done (state))return NULL ;if (state->regs)return &state->regs->ip; +if (task != current && state->sp == task->thread.sp) { +struct inactive_task_frame *frame = (void *)task->thread.sp; +return &frame->ret_addr; + } +if (state->sp)return (unsigned long *)state->sp -1 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 200/606 rxrpc: Trace discarded ACKs
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit d1f129470e6cb79b8b97fecd12689f6eb49e27fe ]
Add a tracepoint to track received ACKs that are discarded due to being outside of the Tx window.
--- include/trace/events/rxrpc.h | 35 +++++++++++++++++++++++++++++++++++ net/rxrpc/input.c | 12 ++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-)
include/trace/events/rxrpc.h +35 -0
@@ -1541,6 +1541,41 @@ TRACE_EVENT(rxrpc_notify_socket, __entry->serial) ); +TRACE_EVENT (rxrpc_rx_discard_ack, + TP_PROTO(unsigned int debug_id, rxrpc_serial_t serial, + rxrpc_seq_t first_soft_ack, rxrpc_seq_t call_ackr_first, + rxrpc_seq_t prev_pkt, rxrpc_seq_t call_ackr_prev), + +TP_ARGS (debug_id, serial, first_soft_ack, call_ackr_first, + prev_pkt, call_ackr_prev), + +TP_STRUCT__entry ( + __field(unsigned int, debug_id ) + __field(rxrpc_serial_t, serial ) + __field(rxrpc_seq_t, first_soft_ack) + __field(rxrpc_seq_t, call_ackr_first) + __field(rxrpc_seq_t, prev_pkt) +__field (rxrpc_seq_t, call_ackr_prev) + ), + +TP_fast_assign ( + __entry->debug_id = debug_id; + __entry->serial = serial; + __entry->first_soft_ack = first_soft_ack; + __entry->call_ackr_first = call_ackr_first; + __entry->prev_pkt = prev_pkt; + __entry->call_ackr_prev = call_ackr_prev; + ), + +TP_printk ("c=%08x r=%08x %08x<%08x %08x<%08x" , + __entry->debug_id, + __entry->serial, + __entry->first_soft_ack, + __entry->call_ackr_first, + __entry->prev_pkt, + __entry->call_ackr_prev) + ); +#endif /* _TRACE_RXRPC_H */ /* This part must be outside protection */
net/rxrpc/input.c +10 -2
@@ -866,8 +866,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)/* Discard any out-of-order or duplicate ACKs (outside lock). */ if (before (first_soft_ack, call->ackr_first_seq) || -before (prev_pkt, call->ackr_prev_seq)) +before (prev_pkt, call->ackr_prev_seq)) { +trace_rxrpc_rx_discard_ack (call->debug_id, sp->hdr.serial, + first_soft_ack, call->ackr_first_seq, + prev_pkt, call->ackr_prev_seq);return ; + } buf.info.rxMTU =0 ; ioffset = offset + nr_acks +3 ;
@@ -879,8 +883,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)/* Discard any out-of-order or duplicate ACKs (inside lock). */ if (before (first_soft_ack, call->ackr_first_seq) || -before (prev_pkt, call->ackr_prev_seq)) +before (prev_pkt, call->ackr_prev_seq)) { +trace_rxrpc_rx_discard_ack (call->debug_id, sp->hdr.serial, + first_soft_ack, call->ackr_first_seq, + prev_pkt, call->ackr_prev_seq); goto out; + } call->acks_latest_ts = skb->tstamp; call->ackr_first_seq = first_soft_ack;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 201/606 rxrpc: Fix ack discard
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 441fdee1eaf050ef0040bde0d7af075c1c6a6d8b ]
The Rx protocol has a "previousPacket" field in it that is not handled in the same way by all protocol implementations. Sometimes it contains the serial number of the last DATA packet received, sometimes the sequence number of the last DATA packet received and sometimes the highest sequence number so far received.
AF_RXRPC is using this to weed out ACKs that are out of date (it's possible for ACK packets to get reordered on the wire), but this does not work with OpenAFS which will just stick the sequence number of the last packet seen into previousPacket.
The issue being seen is that big AFS FS.StoreData RPC (eg. of ~256MiB) are timing out when partly sent. A trace was captured, with an additional tracepoint to show ACKs being discarded in rxrpc_input_ack(). Here's an excerpt showing the problem.
52873.203230: rxrpc_tx_data: c=000004ae DATA ed1a3584:00000002 0002449c q=00024499 fl=09
A DATA packet with sequence number 00024499 has been transmitted (the "q=" field).
...
52873.243296: rxrpc_rx_ack: c=000004ae 00012a2b DLY r=00024499 f=00024497 p=00024496 n=0 52873.243376: rxrpc_rx_ack: c=000004ae 00012a2c IDL r=0002449b f=00024499 p=00024498 n=0 52873.243383: rxrpc_rx_ack: c=000004ae 00012a2d OOS r=0002449d f=00024499 p=0002449a n=2
The Out-Of-Sequence ACK indicates that the server didn't see DATA sequence number 00024499, but did see seq 0002449a (previousPacket, shown as "p=", skipped the number, but firstPacket, "f=", which shows the bottom of the window is set at that point).
52873.252663: rxrpc_retransmit: c=000004ae q=24499 a=02 xp=14581537
52873.252664: rxrpc_tx_data: c=000004ae DATA ed1a3584:00000002 000244bc q=00024499 fl=0b *RETRANS*
The packet has been retransmitted. Retransmission recurs until the peer says it got the packet.
52873.271013: rxrpc_rx_ack: c=000004ae 00012a31 OOS r=000244a1 f=00024499 p=0002449e n=6
More OOS ACKs indicate that the other packets that are already in the transmission pipeline are being received. The specific-ACK list is up to 6 ACKs and NAKs.
...
52873.284792: rxrpc_rx_ack: c=000004ae 00012a49 OOS r=000244b9 f=00024499 p=000244b6 n=30 52873.284802: rxrpc_retransmit: c=000004ae q=24499 a=0a xp=63505500
52873.284804: rxrpc_tx_data: c=000004ae DATA ed1a3584:00000002 000244c2 q=00024499 fl=0b *RETRANS* 52873.287468: rxrpc_rx_ack: c=000004ae 00012a4a OOS r=000244ba f=00024499 p=000244b7 n=31 52873.287478: rxrpc_rx_ack: c=000004ae 00012a4b OOS r=000244bb f=00024499 p=000244b8 n=32
At this point, the server's receive window is full (n=32) with presumably 1 NAK'd packet and 31 ACK'd packets. We can't transmit any more packets.
52873.287488: rxrpc_retransmit: c=000004ae q=24499 a=0a xp=61327980
52873.287489: rxrpc_tx_data: c=000004ae DATA ed1a3584:00000002 000244c3 q=00024499 fl=0b *RETRANS* 52873.293850: rxrpc_rx_ack: c=000004ae 00012a4c DLY r=000244bc f=000244a0 p=00024499 n=25
And now we've received an ACK indicating that a DATA retransmission was received. 7 packets have been processed (the occupied part of the window moved, as indicated by f= and n=).
52873.293853: rxrpc_rx_discard_ack: c=000004ae r=00012a4c 000244a0<00024499 00024499<000244b8
However, the DLY ACK gets discarded because its previousPacket has gone backwards (from p=000244b8, in the ACK at 52873.287478 to p=00024499 in the ACK at 52873.293850).
We then end up in a continuous cycle of retransmit/discard. kafs fails to update its window because it's discarding the ACKs and can't transmit an extra packet that would clear the issue because the window is full. OpenAFS doesn't change the previousPacket value in the ACKs because no new DATA packets are received with a different previousPacket number.
Fix this by altering the discard check to only discard an ACK based on previousPacket if there was no advance in the firstPacket. This allows us to transmit a new packet which will cause previousPacket to advance in the next ACK.
The check, however, needs to allow for the possibility that previousPacket may actually have had the serial number placed in it instead - in which case it will go outside the window and we should ignore it.
--- net/rxrpc/input.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
net/rxrpc/input.c +26 -4
@@ -802,6 +802,30 @@ static void rxrpc_input_soft_acks(struct rxrpc_call *call, u8 *acks, } } +/* +* Return true if the ACK is valid - ie. it doesn't appear to have regressed +* with respect to the ack state conveyed by preceding ACKs. +*/ +static bool rxrpc_is_ack_valid (struct rxrpc_call *call, +rxrpc_seq_t first_pkt,rxrpc_seq_t prev_pkt) +{ +rxrpc_seq_t base =READ_ONCE (call->ackr_first_seq); + +if (after (first_pkt, base)) +return true;/* The window advanced */ + +if (before (first_pkt, base)) +return false;/* firstPacket regressed */ + +if (after_eq (prev_pkt, call->ackr_prev_seq)) +return true;/* previousPacket hasn't regressed. */ + +/* Some rx implementations put a serial number in previousPacket. */ +if (after_eq (prev_pkt, base + call->tx_winsize)) +return false; +return true; +} +/* * Process an ACK packet. *
@@ -865,8 +889,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb) }/* Discard any out-of-order or duplicate ACKs (outside lock). */ -if (before (first_soft_ack, call->ackr_first_seq) || -before (prev_pkt, call->ackr_prev_seq)) { +if (!rxrpc_is_ack_valid (call, first_soft_ack, prev_pkt)) {trace_rxrpc_rx_discard_ack (call->debug_id, sp->hdr.serial, first_soft_ack, call->ackr_first_seq, prev_pkt, call->ackr_prev_seq);
@@ -882,8 +905,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)spin_lock (&call->input_lock);/* Discard any out-of-order or duplicate ACKs (inside lock). */ -if (before (first_soft_ack, call->ackr_first_seq) || -before (prev_pkt, call->ackr_prev_seq)) { +if (!rxrpc_is_ack_valid (call, first_soft_ack, prev_pkt)) {trace_rxrpc_rx_discard_ack (call->debug_id, sp->hdr.serial, first_soft_ack, call->ackr_first_seq, prev_pkt, call->ackr_prev_seq);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 202/606 bpf: Prevent mmap()'ing read-only maps as writable
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit dfeb376dd4cb2c5004aeb625e2475f58a5ff2ea7 ]
As discussed in [0], it's dangerous to allow mapping BPF map, that's meant to be frozen and is read-only on BPF program side, because that allows user-space to actually store a writable view to the page even after it is frozen. This is exacerbated by BPF verifier making a strong assumption that contents of such frozen map will remain unchanged. To prevent this, disallow mapping BPF_F_RDONLY_PROG mmap()'able BPF maps as writable, ever.
[0] https://lore.kernel.org/bpf/CAEf4BzYGWYhXdp6BJ7_=9OQPJxQpgug080MMjdSB72i9R+5c6g@mail.gmail.com/
--- kernel/bpf/syscall.c | 17 ++++++++++++++--- tools/testing/selftests/bpf/prog_tests/mmap.c | 13 ++++++++++++- tools/testing/selftests/bpf/progs/test_mmap.c | 8 ++++++++ 3 files changed, 34 insertions(+), 4 deletions(-)
kernel/bpf/syscall.c +14 -3
@@ -629,9 +629,20 @@ static int bpf_map_mmap(struct file *filp, struct vm_area_struct *vma)mutex_lock (&map->freeze_mutex); -if ((vma->vm_flags &VM_WRITE ) && map->frozen) { - err = -EPERM ; - goto out; +if (vma->vm_flags &VM_WRITE ) { +if (map->frozen) { + err = -EPERM ; + goto out; + } +/* map is meant to be read-only, so do not allow mapping as +* writable, because it's possible to leak a writable page +* reference and allows user-space to still modify it after +* freezing, while verifier will assume contents do not change +*/ +if (map->map_flags &BPF_F_RDONLY_PROG ) { + err = -EACCES ; + goto out; + } }/* set default open/close callbacks */
tools/testing/selftests/bpf/prog_tests/mmap.c +12 -1
@@ -19,7 +19,7 @@ void test_mmap(void)const size_t map_sz =roundup_page (sizeof (struct map_data ));const int zero =0 , one =1 , two =2 , far =1500 ;const long page_size =sysconf (_SC_PAGE_SIZE); -int err, duration =0 , i, data_map_fd; +int err, duration =0 , i, data_map_fd, rdmap_fd;struct bpf_map *data_map, *bss_map;void *bss_mmaped =NULL , *map_mmaped =NULL , *tmp1, *tmp2;struct test_mmap__bss *bss_data;
@@ -36,6 +36,17 @@ void test_mmap(void) data_map = skel->maps.data_map; data_map_fd =bpf_map__fd (data_map); + rdmap_fd =bpf_map__fd (skel->maps.rdonly_map); + tmp1 =mmap (NULL ,4096 ,PROT_READ |PROT_WRITE ,MAP_SHARED , rdmap_fd,0 ); +if (CHECK (tmp1 !=MAP_FAILED ,"rdonly_write_mmap" ,"unexpected success\n" )) { +munmap (tmp1,4096 ); + goto cleanup; + } +/* now double-check if it's mmap()'able at all */ + tmp1 =mmap (NULL ,4096 ,PROT_READ ,MAP_SHARED , rdmap_fd,0 ); +if (CHECK (tmp1 ==MAP_FAILED ,"rdonly_read_mmap" ,"failed: %d\n" , errno)) + goto cleanup; + bss_mmaped =mmap (NULL , bss_sz,PROT_READ |PROT_WRITE ,MAP_SHARED ,bpf_map__fd (bss_map),0 ); if (CHECK(bss_mmaped == MAP_FAILED, "bss_mmap",
tools/testing/selftests/bpf/progs/test_mmap.c +8 -0
@@ -7,6 +7,14 @@ char _license[] SEC("license") = "GPL"; +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 4096); + __uint(map_flags, BPF_F_MMAPABLE | BPF_F_RDONLY_PROG); + __type(key, __u32); + __type(value, char); +} rdonly_map SEC(".maps"); +struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries, 512 * 4); /* at least 4 pages of data */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 203/606 sched/fair: Reorder enqueue/dequeue_task_fair path
In reply to Sasha LevinFrom: Vincent Guittot <[email protected]>
[ Upstream commit 6d4d22468dae3d8757af9f8b81b848a76ef4409d ]
The walk through the cgroup hierarchy during the enqueue/dequeue of a task is split in 2 distinct parts for throttled cfs_rq without any added value but making code less readable.
Change the code ordering such that everything related to a cfs_rq (throttled or not) will be done in the same loop.
In addition, the same steps ordering is used when updating a cfs_rq:
- update_load_avg
- update_cfs_group
- update *h_nr_running
This reordering enables the use of h_nr_running in PELT algorithm.
No functional and performance changes are expected and have been noticed during tests.
--- kernel/sched/fair.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
kernel/sched/fair.c +20 -22
@@ -5276,32 +5276,31 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq =cfs_rq_of (se);enqueue_entity (cfs_rq, se, flags); -/* -* end evaluation on encountering a throttled cfs_rq -* -* note: in the case of encountering a throttled cfs_rq we will -* post the final h_nr_running increment below. -*/ -if (cfs_rq_throttled (cfs_rq)) -break ; cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running += idle_h_nr_running; +/* end evaluation on encountering a throttled cfs_rq */ +if (cfs_rq_throttled (cfs_rq)) + goto enqueue_throttle; + flags =ENQUEUE_WAKEUP ; }for_each_sched_entity (se) { cfs_rq =cfs_rq_of (se); - cfs_rq->h_nr_running++; - cfs_rq->idle_h_nr_running += idle_h_nr_running; +/* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled (cfs_rq)) -break ; + goto enqueue_throttle;update_load_avg (cfs_rq, se,UPDATE_TG );update_cfs_group (se); + + cfs_rq->h_nr_running++; + cfs_rq->idle_h_nr_running += idle_h_nr_running; } +enqueue_throttle:if (!se) {add_nr_running (rq,1 );/*
@@ -5362,17 +5361,13 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq =cfs_rq_of (se);dequeue_entity (cfs_rq, se, flags); -/* -* end evaluation on encountering a throttled cfs_rq -* -* note: in the case of encountering a throttled cfs_rq we will -* post the final h_nr_running decrement below. -*/ -if (cfs_rq_throttled (cfs_rq)) -break ; cfs_rq->h_nr_running--; cfs_rq->idle_h_nr_running -= idle_h_nr_running; +/* end evaluation on encountering a throttled cfs_rq */ +if (cfs_rq_throttled (cfs_rq)) + goto dequeue_throttle; +/* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) {/* Avoid re-evaluating load for this entity: */
@@ -5390,16 +5385,19 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)for_each_sched_entity (se) { cfs_rq =cfs_rq_of (se); - cfs_rq->h_nr_running--; - cfs_rq->idle_h_nr_running -= idle_h_nr_running; +/* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled (cfs_rq)) -break ; + goto dequeue_throttle;update_load_avg (cfs_rq, se,UPDATE_TG );update_cfs_group (se); + + cfs_rq->h_nr_running--; + cfs_rq->idle_h_nr_running -= idle_h_nr_running; } +dequeue_throttle:if (!se)sub_nr_running (rq,1 );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 204/606 sched/fair: Fix reordering of enqueue/dequeue_task_fair()
In reply to Sasha LevinFrom: Vincent Guittot <[email protected]>
[ Upstream commit 5ab297bab984310267734dfbcc8104566658ebef ]
Even when a cgroup is throttled, the group se of a child cgroup can still be enqueued and its gse->on_rq stays true. When a task is enqueued on such child, we still have to update the load_avg and increase h_nr_running of the throttled cfs. Nevertheless, the 1st for_each_sched_entity() loop is skipped because of gse->on_rq == true and the 2nd loop because the cfs is throttled whereas we have to update both load_avg with the old h_nr_running and increase h_nr_running in such case.
The same sequence can happen during dequeue when se moves to parent before breaking in the 1st loop.
Note that the update of load_avg will effectively happen only once in order to sync up to the throttled time. Next call for updating load_avg will stop early because the clock stays unchanged.
--- kernel/sched/fair.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
kernel/sched/fair.c +9 -8
@@ -5289,15 +5289,15 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)for_each_sched_entity (se) { cfs_rq =cfs_rq_of (se); -/* end evaluation on encountering a throttled cfs_rq */ -if (cfs_rq_throttled (cfs_rq)) - goto enqueue_throttle; -update_load_avg (cfs_rq, se,UPDATE_TG );update_cfs_group (se); cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running += idle_h_nr_running; + +/* end evaluation on encountering a throttled cfs_rq */ +if (cfs_rq_throttled (cfs_rq)) + goto enqueue_throttle; } enqueue_throttle:
@@ -5386,15 +5386,16 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)for_each_sched_entity (se) { cfs_rq =cfs_rq_of (se); -/* end evaluation on encountering a throttled cfs_rq */ -if (cfs_rq_throttled (cfs_rq)) - goto dequeue_throttle; -update_load_avg (cfs_rq, se,UPDATE_TG );update_cfs_group (se); cfs_rq->h_nr_running--; cfs_rq->idle_h_nr_running -= idle_h_nr_running; + +/* end evaluation on encountering a throttled cfs_rq */ +if (cfs_rq_throttled (cfs_rq)) + goto dequeue_throttle; + } dequeue_throttle:
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 205/606 sched/fair: Fix enqueue_task_fair() warning some more
In reply to Sasha LevinFrom: Phil Auld <[email protected]>
[ Upstream commit b34cb07dde7c2346dec73d053ce926aeaa087303 ]
sched/fair: Fix enqueue_task_fair warning some more
The recent patch, fe61468b2cb (sched/fair: Fix enqueue_task_fair warning) did not fully resolve the issues with the rq->tmp_alone_branch != &rq->leaf_cfs_rq_list warning in enqueue_task_fair. There is a case where the first for_each_sched_entity loop exits due to on_rq, having incompletely updated the list. In this case the second for_each_sched_entity loop can further modify se. The later code to fix up the list management fails to do what is needed because se does not point to the sched_entity which broke out of the first loop. The list is not fixed up because the throttled parent was already added back to the list by a task enqueue in a parallel child hierarchy.
Address this by calling list_add_leaf_cfs_rq if there are throttled parents while doing the second for_each_sched_entity loop.
--- kernel/sched/fair.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/sched/fair.c +7 -0
@@ -5298,6 +5298,13 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)/* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled (cfs_rq)) goto enqueue_throttle; + +/* +* One parent has been throttled and cfs_rq removed from the +* list. Add it back to not break the leaf list. +*/ +if (throttled_hierarchy (cfs_rq)) +list_add_leaf_cfs_rq (cfs_rq); } enqueue_throttle:
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 206/606 Linux 5.6.15
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 5 PATCHLEVEL = 6 -SUBLEVEL = 14 +SUBLEVEL = 15 EXTRAVERSION = NAME = Kleptomaniac Octopus
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 207/606 ax25: fix setsockopt(SO_BINDTODEVICE)
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 687775cec056b38a4c8f3291e0dd7a9145f7b667 ]
syzbot was able to trigger this trace [1], probably by using a zero optlen.
While we are at it, cap optlen to IFNAMSIZ - 1 instead of IFNAMSIZ.
[1]
BUG: KMSAN: uninit-value in strnlen+0xf9/0x170 lib/string.c:569 CPU: 0 PID: 8807 Comm: syz-executor483 Not tainted 5.7.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1c9/0x220 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215 strnlen+0xf9/0x170 lib/string.c:569 dev_name_hash net/core/dev.c:207 [inline] netdev_name_node_lookup net/core/dev.c:277 [inline] __dev_get_by_name+0x75/0x2b0 net/core/dev.c:778 ax25_setsockopt+0xfa3/0x1170 net/ax25/af_ax25.c:654 __compat_sys_setsockopt+0x4ed/0x910 net/compat.c:403 __do_compat_sys_setsockopt net/compat.c:413 [inline] __se_compat_sys_setsockopt+0xdd/0x100 net/compat.c:410 __ia32_compat_sys_setsockopt+0x62/0x80 net/compat.c:410 do_syscall_32_irqs_on arch/x86/entry/common.c:339 [inline] do_fast_syscall_32+0x3bf/0x6d0 arch/x86/entry/common.c:398 entry_SYSENTER_compat+0x68/0x77 arch/x86/entry/entry_64_compat.S:139 RIP: 0023:0xf7f57dd9 Code: 90 e8 0b 00 00 00 f3 90 0f ae e8 eb f9 8d 74 26 00 89 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000ffae8c1c EFLAGS: 00000217 ORIG_RAX: 000000000000016e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000101 RDX: 0000000000000019 RSI: 0000000020000000 RDI: 0000000000000004 RBP: 0000000000000012 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
Local variable ----devname@ax25_setsockopt created at:
ax25_setsockopt+0xe6/0x1170 net/ax25/af_ax25.c:536 ax25_setsockopt+0xe6/0x1170 net/ax25/af_ax25.c:536
--- net/ax25/af_ax25.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ax25/af_ax25.c +4 -2
@@ -635,8 +635,10 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,break ;case SO_BINDTODEVICE : -if (optlen >IFNAMSIZ ) - optlen =IFNAMSIZ ; +if (optlen >IFNAMSIZ -1 ) + optlen =IFNAMSIZ -1 ; + +memset (devname,0 ,sizeof (devname));if (copy_from_user (devname, optval, optlen)) { res = -EFAULT ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 208/606 dpaa_eth: fix usage as DSA master, try 3
In reply to Sasha LevinFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 5d14c304bfc14b4fd052dc83d5224376b48f52f0 ]
The dpaa-eth driver probes on compatible string for the MAC node, and the fman/mac.c driver allocates a dpaa-ethernet platform device that triggers the probing of the dpaa-eth net device driver.
All of this is fine, but the problem is that the struct device of the dpaa_eth net_device is 2 parents away from the MAC which can be referenced via of_node. So of_find_net_device_by_node can't find it, and DSA switches won't be able to probe on top of FMan ports.
It would be a bit silly to modify a core function (of_find_net_device_by_node) to look for dev->parent->parent->of_node just for one driver. We're just 1 step away from implementing full recursion.
Actually there have already been at least 2 previous attempts to make this work:
- Commit a1a50c8e4c24 ("fsl/man: Inherit parent device and of_node")
- One or more of the patches in "[v3,0/6] adapt DPAA drivers for DSA":
https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/
(I couldn't really figure out which one was supposed to solve the problem and how).
Point being, it looks like this is still pretty much a problem today. On T1040, the /sys/class/net/eth0 symlink currently points to
../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/dpaa-ethernet.0/net/eth0
which pretty much illustrates the problem. The closest of_node we've got is the "fsl,fman-memac" at /soc@ffe000000/fman@400000/ethernet@e6000, which is what we'd like to be able to reference from DSA as host port.
For of_find_net_device_by_node to find the eth0 port, we would need the parent of the eth0 net_device to not be the "dpaa-ethernet" platform device, but to point 1 level higher, aka the "fsl,fman-memac" node directly. The new sysfs path would look like this:
../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/net/eth0
And this is exactly what SET_NETDEV_DEV does. It sets the parent of the net_device. The new parent has an of_node associated with it, and of_dev_node_match already checks for the of_node of the device or of its parent.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +1 -1
@@ -2902,7 +2902,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) }/* Do this here, so we can be verbose early */ -SET_NETDEV_DEV (net_dev, dev); +SET_NETDEV_DEV (net_dev, dev->parent);dev_set_drvdata (dev, net_dev); priv =netdev_priv (net_dev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 209/606 ethtool: count header size in reply size estimate
In reply to Sasha LevinFrom: Michal Kubecek <[email protected]>
[ Upstream commit 7c87e32d2e380228ada79d20ac5b7674718ef097 ]
As ethnl_request_ops::reply_size handlers do not include common header size into calculated/estimated reply size, it needs to be added in ethnl_default_doit() and ethnl_default_notify() before allocating the message. On the other hand, strset_reply_size() should not add common header size.
--- net/ethtool/netlink.c | 4 ++-- net/ethtool/strset.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
net/ethtool/netlink.c +2 -2
@@ -334,7 +334,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info) ret = ops->reply_size (req_info, reply_data);if (ret <0 ) goto err_cleanup; - reply_len = ret; + reply_len = ret +ethnl_reply_header_size (); ret = -ENOMEM ; rskb =ethnl_reply_init (reply_len, req_info->dev, ops->reply_cmd, ops->hdr_attr, info, &reply_payload);
@@ -573,7 +573,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, ret = ops->reply_size (req_info, reply_data);if (ret <0 ) goto err_cleanup; - reply_len = ret; + reply_len = ret +ethnl_reply_header_size (); ret = -ENOMEM ; skb =genlmsg_new (reply_len,GFP_KERNEL );if (!skb)
net/ethtool/strset.c +0 -1
@@ -309,7 +309,6 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,int len =0 ;int ret; - len +=ethnl_reply_header_size ();for (i =0 ; i <ETH_SS_COUNT ; i++) {const struct strset_info *set_info = &data->sets[i];
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 210/606 felix: Fix initialization of ioremap resources
In reply to Sasha LevinFrom: Claudiu Manoil <[email protected]>
[ Upstream commit b4024c9e5c57902155d3b5e7de482e245f492bff ]
The caller of devm_ioremap_resource(), either accidentally or by wrong assumption, is writing back derived resource data to global static resource initialization tables that should have been constant. Meaning that after it computes the final physical start address it saves the address for no reason in the static tables. This doesn't affect the first driver probing after reboot, but it breaks consecutive driver reloads (i.e. driver unbind & bind) because the initialization tables no longer have the correct initial values. So the next probe() will map the device registers to wrong physical addresses, causing ARM SError async exceptions.
This patch fixes all of the above.
--- drivers/net/dsa/ocelot/felix.c | 23 +++++++++++------------ drivers/net/dsa/ocelot/felix.h | 6 +++--- drivers/net/dsa/ocelot/felix_vsc9959.c | 22 ++++++++++------------ 3 files changed, 24 insertions(+), 27 deletions(-)
drivers/net/dsa/ocelot/felix.c +11 -12
@@ -385,6 +385,7 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)struct ocelot *ocelot = &felix->ocelot;phy_interface_t *port_phy_modes;resource_size_t switch_base; +struct resource res;int port, i, err; ocelot->num_phys_ports = num_phys_ports;
@@ -416,17 +417,16 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)for (i =0 ; i <TARGET_MAX ; i++) {struct regmap *target; -struct resource *res;if (!felix->info->target_io_res[i].name)continue ; - res = &felix->info->target_io_res[i]; - res->flags =IORESOURCE_MEM ; - res->start += switch_base; - res->end += switch_base; +memcpy (&res, &felix->info->target_io_res[i],sizeof (res)); + res.flags =IORESOURCE_MEM ; + res.start += switch_base; + res.end += switch_base; - target =ocelot_regmap_init (ocelot, res); + target =ocelot_regmap_init (ocelot, &res);if (IS_ERR (target)) {dev_err (ocelot->dev,"Failed to map device memory space\n" );
@@ -447,7 +447,6 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)for (port =0 ; port < num_phys_ports; port++) {struct ocelot_port *ocelot_port;void __iomem *port_regs; -struct resource *res; ocelot_port = devm_kzalloc(ocelot->dev, sizeof(struct ocelot_port),
@@ -459,12 +458,12 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)return -ENOMEM ; } - res = &felix->info->port_io_res[port]; - res->flags =IORESOURCE_MEM ; - res->start += switch_base; - res->end += switch_base; +memcpy (&res, &felix->info->port_io_res[port],sizeof (res)); + res.flags =IORESOURCE_MEM ; + res.start += switch_base; + res.end += switch_base; - port_regs =devm_ioremap_resource (ocelot->dev, res); + port_regs =devm_ioremap_resource (ocelot->dev, &res);if (IS_ERR (port_regs)) {dev_err (ocelot->dev,"failed to map registers for port %d\n" , port);
drivers/net/dsa/ocelot/felix.h +3 -3
@@ -8,9 +8,9 @@/* Platform-specific information */ struct felix_info { -struct resource *target_io_res; -struct resource *port_io_res; -struct resource *imdio_res; +const struct resource *target_io_res; +const struct resource *port_io_res; +const struct resource *imdio_res;const struct reg_field *regfields;const u32 *const *map;const struct ocelot_ops *ops;
drivers/net/dsa/ocelot/felix_vsc9959.c +10 -12
@@ -328,10 +328,8 @@ static const u32 *vsc9959_regmap[] = { [GCB] = vsc9959_gcb_regmap, }; -/* Addresses are relative to the PCI device's base address and -* will be fixed up at ioremap time. -*/ -static struct resource vsc9959_target_io_res[] = { +/* Addresses are relative to the PCI device's base address */ +static const struct resource vsc9959_target_io_res[] = { [ANA ] = { .start =0x0280000 , .end =0x028ffff ,
@@ -374,7 +372,7 @@ static struct resource vsc9959_target_io_res[] = { }, }; -static struct resource vsc9959_port_io_res[] = { +static const struct resource vsc9959_port_io_res[] = { { .start =0x0100000 , .end =0x010ffff ,
@@ -410,7 +408,7 @@ static struct resource vsc9959_port_io_res[] = {/* Port MAC 0 Internal MDIO bus through which the SerDes acting as an * SGMII/QSGMII MAC PCS can be found. */ -static struct resource vsc9959_imdio_res = { +static const struct resource vsc9959_imdio_res = { .start =0x8030 , .end =0x8040 , .name ="imdio" ,
@@ -984,7 +982,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)struct device *dev = ocelot->dev;resource_size_t imdio_base;void __iomem *imdio_regs; -struct resource *res; +struct resource res;struct enetc_hw *hw;struct mii_bus *bus;int port;
@@ -1001,12 +999,12 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) imdio_base =pci_resource_start (felix->pdev, felix->info->imdio_pci_bar); - res = felix->info->imdio_res; - res->flags =IORESOURCE_MEM ; - res->start += imdio_base; - res->end += imdio_base; +memcpy (&res, felix->info->imdio_res,sizeof (res)); + res.flags =IORESOURCE_MEM ; + res.start += imdio_base; + res.end += imdio_base; - imdio_regs =devm_ioremap_resource (dev, res); + imdio_regs =devm_ioremap_resource (dev, &res);if (IS_ERR (imdio_regs)) {dev_err (dev,"failed to map internal MDIO registers\n" );return PTR_ERR (imdio_regs);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 211/606 net: don't return invalid table id error when we fall back to PF_UNSPEC
In reply to Sasha LevinFrom: Sabrina Dubroca <[email protected]>
[ Upstream commit 41b4bd986f86331efc599b9a3f5fb86ad92e9af9 ]
In case we can't find a ->dumpit callback for the requested (family,type) pair, we fall back to (PF_UNSPEC,type). In effect, we're in the same situation as if userspace had requested a PF_UNSPEC dump. For RTM_GETROUTE, that handler is rtnl_dump_all, which calls all the registered RTM_GETROUTE handlers.
The requested table id may or may not exist for all of those families. commit ae677bbb4441 ("net: Don't return invalid table id error when dumping all families") fixed the problem when userspace explicitly requests a PF_UNSPEC dump, but missed the fallback case.
For example, when we pass ipv6.disable=1 to a kernel with CONFIG_IP_MROUTE=y and CONFIG_IP_MROUTE_MULTIPLE_TABLES=y, the (PF_INET6, RTM_GETROUTE) handler isn't registered, so we end up in rtnl_dump_all, and listing IPv6 routes will unexpectedly print:
# ip -6 r Error: ipv4: MR table does not exist. Dump terminated
commit ae677bbb4441 introduced the dump_all_families variable, which gets set when userspace requests a PF_UNSPEC dump. However, we can't simply set the family to PF_UNSPEC in rtnetlink_rcv_msg in the fallback case to get dump_all_families == true, because some messages types (for example RTM_GETRULE and RTM_GETNEIGH) only register the PF_UNSPEC handler and use the family to filter in the kernel what is dumped to userspace. We would then export more entries, that userspace would have to filter. iproute does that, but other programs may not.
Instead, this patch removes dump_all_families and updates the RTM_GETROUTE handlers to check if the family that is being dumped is their own. When it's not, which covers both the intentional PF_UNSPEC dumps (as dump_all_families did) and the fallback case, ignore the missing table id error.
--- include/net/ip_fib.h | 1 - net/ipv4/fib_frontend.c | 3 +-- net/ipv4/ipmr.c | 2 +- net/ipv6/ip6_fib.c | 2 +- net/ipv6/ip6mr.c | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-)
include/net/ip_fib.h +0 -1
@@ -257,7 +257,6 @@ struct fib_dump_filter {u32 table_id;/* filter_set is an optimization that an entry is set */ bool filter_set; -bool dump_all_families;bool dump_routes;bool dump_exceptions;unsigned char protocol;
net/ipv4/fib_frontend.c +1 -2
@@ -918,7 +918,6 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,else filter->dump_exceptions = false; - filter->dump_all_families = (rtm->rtm_family ==AF_UNSPEC ); filter->flags = rtm->rtm_flags; filter->protocol = rtm->rtm_protocol; filter->rt_type = rtm->rtm_type;
@@ -990,7 +989,7 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)if (filter.table_id) { tb =fib_get_table (net, filter.table_id);if (!tb) { -if (filter.dump_all_families) +if (rtnl_msg_family (cb->nlh) !=PF_INET )return skb->len;NL_SET_ERR_MSG (cb->extack,"ipv4: FIB table does not exist" );
net/ipv4/ipmr.c +1 -1
@@ -2611,7 +2611,7 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) mrt =ipmr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) { -if (filter.dump_all_families) +if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IPMR )return skb->len;NL_SET_ERR_MSG (cb->extack,"ipv4: MR table does not exist" );
net/ipv6/ip6_fib.c +1 -1
@@ -664,7 +664,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)if (arg.filter.table_id) { tb =fib6_get_table (net, arg.filter.table_id);if (!tb) { -if (arg.filter.dump_all_families) +if (rtnl_msg_family (cb->nlh) !=PF_INET6 ) goto out;NL_SET_ERR_MSG_MOD (cb->extack,"FIB table does not exist" );
net/ipv6/ip6mr.c +1 -1
@@ -2501,7 +2501,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) mrt =ip6mr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) { -if (filter.dump_all_families) +if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IP6MR )return skb->len;NL_SET_ERR_MSG_MOD (cb->extack,"MR table does not exist" );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 212/606 net: dsa: mt7530: fix roaming from DSA user ports
In reply to Sasha LevinFrom: DENG Qingfang <[email protected]>
[ Upstream commit 5e5502e012b8129e11be616acb0f9c34bc8f8adb ]
When a client moves from a DSA user port to a software port in a bridge, it cannot reach any other clients that connected to the DSA user ports. That is because SA learning on the CPU port is disabled, so the switch ignores the client's frames from the CPU port and still thinks it is at the user port.
Fix it by enabling SA learning on the CPU port.
To prevent the switch from learning from flooding frames from the CPU port, set skb->offload_fwd_mark to 1 for unicast and broadcast frames, and let the switch flood them instead of trapping to the CPU port. Multicast frames still need to be trapped to the CPU port for snooping, so set the SA_DIS bit of the MTK tag to 1 when transmitting those frames to disable SA learning.
--- drivers/net/dsa/mt7530.c | 9 ++------- drivers/net/dsa/mt7530.h | 1 + net/dsa/tag_mtk.c | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-)
drivers/net/dsa/mt7530.c +2 -7
@@ -639,11 +639,8 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,mt7530_write (priv,MT7530_PVC_P (port),PORT_SPEC_TAG ); -/* Disable auto learning on the cpu port */ -mt7530_set (priv,MT7530_PSC_P (port),SA_DIS ); - -/* Unknown unicast frame fordwarding to the cpu port */ -mt7530_set (priv,MT7530_MFC ,UNU_FFP (BIT (port))); +/* Unknown multicast frame forwarding to the cpu port */ +mt7530_rmw (priv,MT7530_MFC ,UNM_FFP_MASK ,UNM_FFP (BIT (port)));/* Set CPU port number */ if (priv->id ==ID_MT7621 )
@@ -1247,8 +1244,6 @@ mt7530_setup(struct dsa_switch *ds)/* Enable and reset MIB counters */ mt7530_mib_reset (ds); -mt7530_clear (priv,MT7530_MFC ,UNU_FFP_MASK ); -for (i =0 ; i <MT7530_NUM_PORTS ; i++) {/* Disable forwarding by default on all ports */ mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
drivers/net/dsa/mt7530.h +1 -0
@@ -31,6 +31,7 @@ enum {#define MT7530_MFC 0x10#define BC_FFP (x) (((x) & 0xff) << 24)#define UNM_FFP (x) (((x) & 0xff) << 16) +#define UNM_FFP_MASK UNM_FFP(~0)#define UNU_FFP (x) (((x) & 0xff) << 8)#define UNU_FFP_MASK UNU_FFP(~0)#define CPU_EN BIT(7)
net/dsa/tag_mtk.c +15 -0
@@ -15,6 +15,7 @@#define MTK_HDR_XMIT_TAGGED_TPID_8100 1#define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0)#define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) +#define MTK_HDR_XMIT_SA_DIS BIT(6)static struct sk_buff *mtk_tag_xmit (struct sk_buff *skb,struct net_device *dev)
@@ -22,6 +23,9 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,struct dsa_port *dp =dsa_slave_to_port (dev);u8 *mtk_tag;bool is_vlan_skb = true; +unsigned char *dest =eth_hdr (skb)->h_dest; +bool is_multicast_skb =is_multicast_ether_addr (dest) && + !is_broadcast_ether_addr (dest);/* Build the special tag after the MAC Source Address. If VLAN header * is present, it's required that VLAN header and special tag is
@@ -47,6 +51,10 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,MTK_HDR_XMIT_UNTAGGED ; mtk_tag[1 ] = (1 << dp->index) &MTK_HDR_XMIT_DP_BIT_MASK ; +/* Disable SA learning for multicast frames */ +if (unlikely (is_multicast_skb)) + mtk_tag[1 ] |=MTK_HDR_XMIT_SA_DIS ; +/* Tag control information is kept for 802.1Q */ if (!is_vlan_skb) { mtk_tag[2 ] =0 ;
@@ -61,6 +69,9 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, {int port;__be16 *phdr, hdr; +unsigned char *dest =eth_hdr (skb)->h_dest; +bool is_multicast_skb =is_multicast_ether_addr (dest) && + !is_broadcast_ether_addr (dest);if (unlikely (!pskb_may_pull (skb,MTK_HDR_LEN )))return NULL ;
@@ -86,6 +97,10 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,if (!skb->dev)return NULL ; +/* Only unicast or broadcast frames are offloaded */ +if (likely (!is_multicast_skb)) + skb->offload_fwd_mark =1 ; +return skb; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 213/606 net: ethernet: ti: cpsw: fix ASSERT_RTNL() warning during suspend
In reply to Sasha LevinFrom: Grygorii Strashko <[email protected]>
[ Upstream commit 4c64b83d03f4aafcdf710caad994cbc855802e74 ]
vlan_for_each() are required to be called with rtnl_lock taken, otherwise ASSERT_RTNL() warning will be triggered - which happens now during System resume from suspend:
cpsw_suspend()
|- cpsw_ndo_stop()
|- __hw_addr_ref_unsync_dev()
|- cpsw_purge_all_mc()
|- vlan_for_each()
|- ASSERT_RTNL();Hence, fix it by surrounding cpsw_ndo_stop() by rtnl_lock/unlock() calls.
--- drivers/net/ethernet/ti/cpsw.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/ti/cpsw.c +4 -0
@@ -1752,11 +1752,15 @@ static int cpsw_suspend(struct device *dev)struct cpsw_common *cpsw =dev_get_drvdata (dev);int i; +rtnl_lock (); +for (i =0 ; i < cpsw->data.slaves; i++)if (cpsw->slaves[i].ndev)if (netif_running (cpsw->slaves[i].ndev))cpsw_ndo_stop (cpsw->slaves[i].ndev); +rtnl_unlock (); +/* Select sleep pin state */ pinctrl_pm_select_sleep_state (dev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 214/606 __netif_receive_skb_core: pass skb by reference
In reply to Sasha LevinFrom: Boris Sukholitko <[email protected]>
[ Upstream commit c0bbbdc32febd4f034ecbf3ea17865785b2c0652 ]
__netif_receive_skb_core may change the skb pointer passed into it (e.g. in rx_handler). The original skb may be freed as a result of this operation.
The callers of __netif_receive_skb_core may further process original skb by using pt_prev pointer returned by __netif_receive_skb_core thus leading to unpleasant effects.
The solution is to pass skb by reference into __netif_receive_skb_core.
v2: Added Fixes tag and comment regarding ppt_prev and skb invariant.
--- net/core/dev.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/core/dev.c +15 -5
@@ -4988,11 +4988,12 @@ static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,return 0 ; } -static int __netif_receive_skb_core (struct sk_buff *skb,bool pfmemalloc, +static int __netif_receive_skb_core (struct sk_buff **pskb,bool pfmemalloc,struct packet_type **ppt_prev) {struct packet_type *ptype, *pt_prev;rx_handler_func_t *rx_handler; +struct sk_buff *skb = *pskb;struct net_device *orig_dev;bool deliver_exact = false;int ret =NET_RX_DROP ;
@@ -5023,8 +5024,10 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc, ret2 =do_xdp_generic (rcu_dereference (skb->dev->xdp_prog), skb);preempt_enable (); -if (ret2 !=XDP_PASS ) -return NET_RX_DROP ; +if (ret2 !=XDP_PASS ) { + ret =NET_RX_DROP ; + goto out; + }skb_reset_mac_len (skb); }
@@ -5174,6 +5177,13 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc, } out: +/* The invariant here is that if *ppt_prev is not NULL +* then skb should also be non-NULL. +* +* Apparently *ppt_prev assignment above holds this invariant due to +* skb dereferencing near it. +*/ + *pskb = skb;return ret; }
@@ -5183,7 +5193,7 @@ static int __netif_receive_skb_one_core(struct sk_buff *skb, bool pfmemalloc)struct packet_type *pt_prev =NULL ;int ret; - ret =__netif_receive_skb_core (skb, pfmemalloc, &pt_prev); + ret =__netif_receive_skb_core (&skb, pfmemalloc, &pt_prev);if (pt_prev) ret =INDIRECT_CALL_INET (pt_prev->func, ipv6_rcv, ip_rcv, skb, skb->dev, pt_prev, orig_dev);
@@ -5261,7 +5271,7 @@ static void __netif_receive_skb_list_core(struct list_head *head, bool pfmemallostruct packet_type *pt_prev =NULL ;skb_list_del_init (skb); -__netif_receive_skb_core (skb, pfmemalloc, &pt_prev); +__netif_receive_skb_core (&skb, pfmemalloc, &pt_prev);if (!pt_prev)continue ;if (pt_curr != pt_prev || od_curr != orig_dev) {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 215/606 net: inet_csk: Fix so_reuseport bind-address cache in tb->fast*
In reply to Sasha LevinFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit 88d7fcfa3b1fe670f0412b95be785aafca63352b ]
The commit 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk") added a bind-address cache in tb->fast*. The tb->fast* caches the address of a sk which has successfully been binded with SO_REUSEPORT ON. The idea is to avoid the expensive conflict search in inet_csk_bind_conflict().
There is an issue with wildcard matching where sk_reuseport_match() should have returned false but it is currently returning true. It ends up hiding bind conflict. For example,
bind("[::1]:443"); /* without SO_REUSEPORT. Succeed. */bind("[::2]:443"); /* with SO_REUSEPORT. Succeed. */bind("[::]:443"); /* with SO_REUSEPORT. Still Succeed where it shouldn't */
The last bind("[::]:443") with SO_REUSEPORT on should have failed because it should have a conflict with the very first bind("[::1]:443") which has SO_REUSEPORT off. However, the address "[::2]" is cached in tb->fast* in the second bind. In the last bind, the sk_reuseport_match() returns true because the binding sk's wildcard addr "[::]" matches with the "[::2]" cached in tb->fast*.
The correct bind conflict is reported by removing the second bind such that tb->fast* cache is not involved and forces the bind("[::]:443") to go through the inet_csk_bind_conflict():
bind("[::1]:443"); /* without SO_REUSEPORT. Succeed. */bind("[::]:443"); /* with SO_REUSEPORT. -EADDRINUSE */
The expected behavior for sk_reuseport_match() is, it should only allow the "cached" tb->fast* address to be used as a wildcard match but not the address of the binding sk. To do that, the current "bool match_wildcard" arg is split into
"bool match_sk1_wildcard" and "bool match_sk2_wildcard".
This change only affects the sk_reuseport_match() which is only used by inet_csk (e.g. TCP).
The other use cases are calling inet_rcv_saddr_equal() and this patch makes it pass the same "match_wildcard" arg twice to the "ipv[46]_rcv_saddr_equal(..., match_wildcard, match_wildcard)".
--- net/ipv4/inet_connection_sock.c | 43 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-)
net/ipv4/inet_connection_sock.c +24 -19
@@ -24,17 +24,19 @@#include <net/addrconf.h> #if IS_ENABLED (CONFIG_IPV6 ) -/* match_wildcard == true: IPV6_ADDR_ANY equals to any IPv6 addresses if IPv6 -* only, and any IPv4 addresses if not IPv6 only -* match_wildcard == false: addresses must be exactly the same, i.e. -* IPV6_ADDR_ANY only equals to IPV6_ADDR_ANY, -* and 0.0.0.0 equals to 0.0.0.0 only +/* match_sk*_wildcard == true: IPV6_ADDR_ANY equals to any IPv6 addresses +* if IPv6 only, and any IPv4 addresses +* if not IPv6 only +* match_sk*_wildcard == false: addresses must be exactly the same, i.e. +* IPV6_ADDR_ANY only equals to IPV6_ADDR_ANY, +* and 0.0.0.0 equals to 0.0.0.0 only */ static bool ipv6_rcv_saddr_equal (const struct in6_addr *sk1_rcv_saddr6,const struct in6_addr *sk2_rcv_saddr6,__be32 sk1_rcv_saddr,__be32 sk2_rcv_saddr,bool sk1_ipv6only,bool sk2_ipv6only, -bool match_wildcard) +bool match_sk1_wildcard, +bool match_sk2_wildcard) {int addr_type =ipv6_addr_type (sk1_rcv_saddr6);int addr_type2 = sk2_rcv_saddr6 ?ipv6_addr_type (sk2_rcv_saddr6) :IPV6_ADDR_MAPPED ;
@@ -44,8 +46,8 @@ static bool ipv6_rcv_saddr_equal(const struct in6_addr *sk1_rcv_saddr6,if (!sk2_ipv6only) {if (sk1_rcv_saddr == sk2_rcv_saddr)return true; -if (!sk1_rcv_saddr || !sk2_rcv_saddr) -return match_wildcard; +return (match_sk1_wildcard && !sk1_rcv_saddr) || + (match_sk2_wildcard && !sk2_rcv_saddr); }return false; }
@@ -53,11 +55,11 @@ static bool ipv6_rcv_saddr_equal(const struct in6_addr *sk1_rcv_saddr6,if (addr_type ==IPV6_ADDR_ANY && addr_type2 ==IPV6_ADDR_ANY )return true; -if (addr_type2 ==IPV6_ADDR_ANY && match_wildcard && +if (addr_type2 ==IPV6_ADDR_ANY && match_sk2_wildcard && !(sk2_ipv6only && addr_type ==IPV6_ADDR_MAPPED ))return true; -if (addr_type ==IPV6_ADDR_ANY && match_wildcard && +if (addr_type ==IPV6_ADDR_ANY && match_sk1_wildcard && !(sk1_ipv6only && addr_type2 ==IPV6_ADDR_MAPPED ))return true;
@@ -69,18 +71,19 @@ static bool ipv6_rcv_saddr_equal(const struct in6_addr *sk1_rcv_saddr6, }#endif -/* match_wildcard == true: 0.0.0.0 equals to any IPv4 addresses -* match_wildcard == false: addresses must be exactly the same, i.e. -* 0.0.0.0 only equals to 0.0.0.0 +/* match_sk*_wildcard == true: 0.0.0.0 equals to any IPv4 addresses +* match_sk*_wildcard == false: addresses must be exactly the same, i.e. +* 0.0.0.0 only equals to 0.0.0.0 */ static bool ipv4_rcv_saddr_equal (__be32 sk1_rcv_saddr,__be32 sk2_rcv_saddr, -bool sk2_ipv6only,bool match_wildcard) +bool sk2_ipv6only,bool match_sk1_wildcard, +bool match_sk2_wildcard) {if (!sk2_ipv6only) {if (sk1_rcv_saddr == sk2_rcv_saddr)return true; -if (!sk1_rcv_saddr || !sk2_rcv_saddr) -return match_wildcard; +return (match_sk1_wildcard && !sk1_rcv_saddr) || + (match_sk2_wildcard && !sk2_rcv_saddr); }return false; }
@@ -96,10 +99,12 @@ bool inet_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2, sk2->sk_rcv_saddr,ipv6_only_sock (sk),ipv6_only_sock (sk2), + match_wildcard, match_wildcard);#endif return ipv4_rcv_saddr_equal (sk->sk_rcv_saddr, sk2->sk_rcv_saddr, -ipv6_only_sock (sk2), match_wildcard); +ipv6_only_sock (sk2), match_wildcard, + match_wildcard); }EXPORT_SYMBOL (inet_rcv_saddr_equal);
@@ -273,10 +278,10 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb, tb->fast_rcv_saddr, sk->sk_rcv_saddr, tb->fast_ipv6_only, - ipv6_only_sock(sk), true); + ipv6_only_sock(sk), true, false);#endif return ipv4_rcv_saddr_equal (tb->fast_rcv_saddr, sk->sk_rcv_saddr, -ipv6_only_sock (sk), true); +ipv6_only_sock (sk), true, false); }/* Obtain a reference to a local port for the given sock,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 216/606 net: ipip: fix wrong address family in init error path
In reply to Sasha LevinFrom: Vadim Fedorenko <[email protected]>
[ Upstream commit 57ebc8f08504f176eb0f25b3e0fde517dec61a4f ]
In case of error with MPLS support the code is misusing AF_INET instead of AF_MPLS.
--- net/ipv4/ipip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ipip.c +1 -1
@@ -698,7 +698,7 @@ static int __init ipip_init(void) rtnl_link_failed:#if IS_ENABLED (CONFIG_MPLS ) -xfrm4_tunnel_deregister (&mplsip_handler,AF_INET ); +xfrm4_tunnel_deregister (&mplsip_handler,AF_MPLS ); xfrm_tunnel_mplsip_failed:#endif
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 217/606 net/mlx5: Add command entry handling completion
In reply to Sasha LevinFrom: Moshe Shemesh <[email protected]>
[ Upstream commit 17d00e839d3b592da9659c1977d45f85b77f986a ]
When FW response to commands is very slow and all command entries in use are waiting for completion we can have a race where commands can get timeout before they get out of the queue and handled. Timeout completion on uninitialized command will cause releasing command's buffers before accessing it for initialization and then we will get NULL pointer exception while trying access it. It may also cause releasing buffers of another command since we may have timeout completion before even allocating entry index for this command.
Add entry handling completion to avoid this race.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 14 ++++++++++++++ include/linux/mlx5/driver.h | 1 + 2 files changed, 15 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +14 -0
@@ -861,6 +861,7 @@ static void cmd_work_handler(struct work_struct *work)int alloc_ret;int cmd_mode; +complete (&ent->handling); sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem;down (sem);if (!ent->page_queue) {
@@ -978,6 +979,11 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)struct mlx5_cmd *cmd = &dev->cmd;int err; +if (!wait_for_completion_timeout (&ent->handling, timeout) && +cancel_work_sync (&ent->work)) { + ent->ret = -ECANCELED ; + goto out_err; + }if (cmd->mode ==CMD_MODE_POLLING || ent->polling) {wait_for_completion (&ent->done); }else if (!wait_for_completion_timeout (&ent->done, timeout)) {
@@ -985,12 +991,17 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)mlx5_cmd_comp_handler (dev,1UL << ent->idx, true); } +out_err: err = ent->ret;if (err == -ETIMEDOUT ) {mlx5_core_warn (dev,"%s(0x%x) timeout. Will cause a leak of a command resource\n" ,mlx5_command_str (msg_to_opcode (ent->in)),msg_to_opcode (ent->in)); + }else if (err == -ECANCELED ) { +mlx5_core_warn (dev,"%s(0x%x) canceled on out of queue timeout.\n" , +mlx5_command_str (msg_to_opcode (ent->in)), +msg_to_opcode (ent->in)); }mlx5_core_dbg (dev,"err %d, delivery status %s(%d)\n" , err,deliv_status_to_str (ent->status), ent->status);
@@ -1026,6 +1037,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, ent->token = token; ent->polling = force_polling; +init_completion (&ent->handling);if (!callback)init_completion (&ent->done);
@@ -1045,6 +1057,8 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, err =wait_func (dev, ent);if (err == -ETIMEDOUT ) goto out; +if (err == -ECANCELED ) + goto out_free; ds = ent->ts2 - ent->ts1; op =MLX5_GET (mbox_in, in->first.data, opcode);
include/linux/mlx5/driver.h +1 -0
@@ -761,6 +761,7 @@ struct mlx5_cmd_work_ent {struct delayed_work cb_timeout_work;void *context;int idx; +struct completion handling;struct completion done;struct mlx5_cmd *cmd;struct work_struct work;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 218/606 net: mvpp2: fix RX hashing for non-10G ports
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 3138a07ce219acde4c0d7ea0b6d54ba64153328b ]
When rxhash is enabled on any ethernet port except the first in each CP block, traffic flow is prevented. The analysis is below:
I've been investigating this afternoon, and what I've found, comparing a kernel without 895586d5dc32 and with 895586d5dc32 applied is:
- The table programmed into the hardware via mvpp22_rss_fill_table() appears to be identical with or without the commit.
- When rxhash is enabled on eth2, mvpp2_rss_port_c2_enable() reports that c2.attr[0] and c2.attr[2] are written back containing:
- with 895586d5dc32, failing: 00200000 40000000
- without 895586d5dc32, working: 04000000 40000000
- When disabling rxhash, c2.attr[0] and c2.attr[2] are written back as:
04000000 00000000
The second value represents the MVPP22_CLS_C2_ATTR2_RSS_EN bit, the first value is the queue number, which comprises two fields. The high 5 bits are 24:29 and the low three are 21:23 inclusive. This comes from:
c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) |
MVPP22_CLS_C2_ATTR0_QLOW(ql);So, the working case gives eth2 a queue id of 4.0, or 32 as per port->first_rxq, and the non-working case a queue id of 0.1, or 1. The allocation of queue IDs seems to be in mvpp2_port_probe():
if (priv->hw_version == MVPP21)
port->first_rxq = port->id * port->nrxqs;
else
port->first_rxq = port->id * priv->max_port_rxqs;Where:
if (priv->hw_version == MVPP21)
priv->max_port_rxqs = 8;
else
priv->max_port_rxqs = 32;Making the port 0 (eth0 / eth1) have port->first_rxq = 0, and port 1 (eth2) be 32. It seems the idea is that the first 32 queues belong to port 0, the second 32 queues belong to port 1, etc.
mvpp2_rss_port_c2_enable() gets the queue number from it's parameter, 'ctx', which comes from mvpp22_rss_ctx(port, 0). This returns port->rss_ctx[0].
mvpp22_rss_context_create() is responsible for allocating that, which it does by looking for an unallocated priv->rss_tables[] pointer. This table is shared amongst all ports on the CP silicon.
When we write the tables in mvpp22_rss_fill_table(), the RSS table entry is defined by:
u32 sel = MVPP22_RSS_INDEX_TABLE(rss_ctx) |
MVPP22_RSS_INDEX_TABLE_ENTRY(i);where rss_ctx is the context ID (queue number) and i is the index in the table.
If we look at what is written:
- The first table to be written has "sel" values of 00000000..0000001f, containing values 0..3. This appears to be for eth1. This is table 0, RX queue number 0.
- The second table has "sel" values of 00000100..0000011f, and appears to be for eth2. These contain values 0x20..0x23. This is table 1, RX queue number 0.
- The third table has "sel" values of 00000200..0000021f, and appears to be for eth3. These contain values 0x40..0x43. This is table 2, RX queue number 0.
How do queue numbers translate to the RSS table? There is another table - the RXQ2RSS table, indexed by the MVPP22_RSS_INDEX_QUEUE field of MVPP22_RSS_INDEX and accessed through the MVPP22_RXQ2RSS_TABLE register. Before 895586d5dc32, it was:
mvpp2_write(priv, MVPP22_RSS_INDEX,
MVPP22_RSS_INDEX_QUEUE(port->first_rxq));
mvpp2_write(priv, MVPP22_RXQ2RSS_TABLE,
MVPP22_RSS_TABLE_POINTER(port->id));and after:
mvpp2_write(priv, MVPP22_RSS_INDEX, MVPP22_RSS_INDEX_QUEUE(ctx));
mvpp2_write(priv, MVPP22_RXQ2RSS_TABLE, MVPP22_RSS_TABLE_POINTER(ctx));Before the commit, for eth2, that would've contained '32' for the index and '1' for the table pointer - mapping queue 32 to table 1. Remember that this is queue-high.queue-low of 4.0.
After the commit, we appear to map queue 1 to table 1. That again looks fine on the face of it.
Section 9.3.1 of the A8040 manual seems indicate the reason that the queue number is separated. queue-low seems to always come from the classifier, whereas queue-high can be from the ingress physical port number or the classifier depending on the MVPP2_CLS_SWFWD_PCTRL_REG.
We set the port bit in MVPP2_CLS_SWFWD_PCTRL_REG, meaning that queue-high comes from the MVPP2_CLS_SWFWD_P2HQ_REG() register... and this seems to be where our bug comes from.
mvpp2_cls_oversize_rxq_set() sets this up as:
mvpp2_write(port->priv, MVPP2_CLS_SWFWD_P2HQ_REG(port->id),
(port->first_rxq >> MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS));
val = mvpp2_read(port->priv, MVPP2_CLS_SWFWD_PCTRL_REG);
val |= MVPP2_CLS_SWFWD_PCTRL_MASK(port->id);
mvpp2_write(port->priv, MVPP2_CLS_SWFWD_PCTRL_REG, val);Setting the MVPP2_CLS_SWFWD_PCTRL_MASK bit means that the queue-high for eth2 is _always_ 4, so only queues 32 through 39 inclusive are available to eth2. Yet, we're trying to tell the classifier to set queue-high, which will be ignored, to zero. Hence, the queue-high field (MVPP22_CLS_C2_ATTR0_QHIGH()) from the classifier will be ignored.
This means we end up directing traffic from eth2 not to queue 1, but to queue 33, and then we tell it to look up queue 33 in the RSS table. However, RSS table has not been programmed for queue 33, and so it ends up (presumably) dropping the packets.
It seems that mvpp22_rss_context_create() doesn't take account of the fact that the upper 5 bits of the queue ID can't actually be changed due to the settings in mvpp2_cls_oversize_rxq_set(), _or_ it seems that mvpp2_cls_oversize_rxq_set() has been missed in this commit. Either way, these two functions mutually disagree with what queue number should be used.
Looking deeper into what mvpp2_cls_oversize_rxq_set() and the MTU validation is doing, it seems that MVPP2_CLS_SWFWD_P2HQ_REG() is used for over-sized packets attempting to egress through this port. With the classifier having had RSS enabled and directing eth2 traffic to queue 1, we may still have packets appearing on queue 32 for this port.
However, the only way we may end up with over-sized packets attempting to egress through eth2 - is if the A8040 forwards frames between its ports. From what I can see, we don't support that feature, and the kernel restricts the egress packet size to the MTU. In any case, if we were to attempt to transmit an oversized packet, we have no support in the kernel to deal with that appearing in the port's receive queue.
So, this patch attempts to solve the issue by clearing the MVPP2_CLS_SWFWD_PCTRL_MASK() bit, allowing MVPP22_CLS_C2_ATTR0_QHIGH() from the classifier to define the queue-high field of the queue number.
My testing seems to confirm my findings above - clearing this bit means that if I enable rxhash on eth2, the interface can then pass traffic, as we are now directing traffic to RX queue 1 rather than queue 33. Traffic still seems to work with rxhash off as well.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +1 -1
@@ -1070,7 +1070,7 @@ void mvpp2_cls_oversize_rxq_set(struct mvpp2_port *port) (port->first_rxq >> MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS)); val =mvpp2_read (port->priv,MVPP2_CLS_SWFWD_PCTRL_REG ); - val |=MVPP2_CLS_SWFWD_PCTRL_MASK (port->id); + val &= ~MVPP2_CLS_SWFWD_PCTRL_MASK (port->id);mvpp2_write (port->priv,MVPP2_CLS_SWFWD_PCTRL_REG , val); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 219/606 net: nlmsg_cancel() if put fails for nhmsg
In reply to Sasha LevinFrom: Stephen Worley <[email protected]>
[ Upstream commit d69100b8eee27c2d60ee52df76e0b80a8d492d34 ]
Fixes data remnant seen when we fail to reserve space for a nexthop group during a larger dump.
If we fail the reservation, we goto nla_put_failure and cancel the message.
Reproduce with the following iproute2 commands:
=====================
ip link add dummy1 type dummy
ip link add dummy2 type dummy
ip link add dummy3 type dummy
ip link add dummy4 type dummy
ip link add dummy5 type dummy
ip link add dummy6 type dummy
ip link add dummy7 type dummy
ip link add dummy8 type dummy
ip link add dummy9 type dummy
ip link add dummy10 type dummy
ip link add dummy11 type dummy
ip link add dummy12 type dummy
ip link add dummy13 type dummy
ip link add dummy14 type dummy
ip link add dummy15 type dummy
ip link add dummy16 type dummy
ip link add dummy17 type dummy
ip link add dummy18 type dummy
ip link add dummy19 type dummy
ip link add dummy20 type dummy
ip link add dummy21 type dummy
ip link add dummy22 type dummy
ip link add dummy23 type dummy
ip link add dummy24 type dummy
ip link add dummy25 type dummy
ip link add dummy26 type dummy
ip link add dummy27 type dummy
ip link add dummy28 type dummy
ip link add dummy29 type dummy
ip link add dummy30 type dummy
ip link add dummy31 type dummy
ip link add dummy32 type dummy
ip link set dummy1 up
ip link set dummy2 up
ip link set dummy3 up
ip link set dummy4 up
ip link set dummy5 up
ip link set dummy6 up
ip link set dummy7 up
ip link set dummy8 up
ip link set dummy9 up
ip link set dummy10 up
ip link set dummy11 up
ip link set dummy12 up
ip link set dummy13 up
ip link set dummy14 up
ip link set dummy15 up
ip link set dummy16 up
ip link set dummy17 up
ip link set dummy18 up
ip link set dummy19 up
ip link set dummy20 up
ip link set dummy21 up
ip link set dummy22 up
ip link set dummy23 up
ip link set dummy24 up
ip link set dummy25 up
ip link set dummy26 up
ip link set dummy27 up
ip link set dummy28 up
ip link set dummy29 up
ip link set dummy30 up
ip link set dummy31 up
ip link set dummy32 up
ip link set dummy33 up
ip link set dummy34 up
ip link set vrf-red up
ip link set vrf-blue up
ip link set dummyVRFred up
ip link set dummyVRFblue up
ip ro add 1.1.1.1/32 dev dummy1
ip ro add 1.1.1.2/32 dev dummy2
ip ro add 1.1.1.3/32 dev dummy3
ip ro add 1.1.1.4/32 dev dummy4
ip ro add 1.1.1.5/32 dev dummy5
ip ro add 1.1.1.6/32 dev dummy6
ip ro add 1.1.1.7/32 dev dummy7
ip ro add 1.1.1.8/32 dev dummy8
ip ro add 1.1.1.9/32 dev dummy9
ip ro add 1.1.1.10/32 dev dummy10 ip ro add 1.1.1.11/32 dev dummy11 ip ro add 1.1.1.12/32 dev dummy12 ip ro add 1.1.1.13/32 dev dummy13 ip ro add 1.1.1.14/32 dev dummy14 ip ro add 1.1.1.15/32 dev dummy15 ip ro add 1.1.1.16/32 dev dummy16 ip ro add 1.1.1.17/32 dev dummy17 ip ro add 1.1.1.18/32 dev dummy18 ip ro add 1.1.1.19/32 dev dummy19 ip ro add 1.1.1.20/32 dev dummy20 ip ro add 1.1.1.21/32 dev dummy21 ip ro add 1.1.1.22/32 dev dummy22 ip ro add 1.1.1.23/32 dev dummy23 ip ro add 1.1.1.24/32 dev dummy24 ip ro add 1.1.1.25/32 dev dummy25 ip ro add 1.1.1.26/32 dev dummy26 ip ro add 1.1.1.27/32 dev dummy27 ip ro add 1.1.1.28/32 dev dummy28 ip ro add 1.1.1.29/32 dev dummy29 ip ro add 1.1.1.30/32 dev dummy30 ip ro add 1.1.1.31/32 dev dummy31 ip ro add 1.1.1.32/32 dev dummy32
ip next add id 1 via 1.1.1.1 dev dummy1 ip next add id 2 via 1.1.1.2 dev dummy2 ip next add id 3 via 1.1.1.3 dev dummy3 ip next add id 4 via 1.1.1.4 dev dummy4 ip next add id 5 via 1.1.1.5 dev dummy5 ip next add id 6 via 1.1.1.6 dev dummy6 ip next add id 7 via 1.1.1.7 dev dummy7 ip next add id 8 via 1.1.1.8 dev dummy8 ip next add id 9 via 1.1.1.9 dev dummy9 ip next add id 10 via 1.1.1.10 dev dummy10 ip next add id 11 via 1.1.1.11 dev dummy11 ip next add id 12 via 1.1.1.12 dev dummy12 ip next add id 13 via 1.1.1.13 dev dummy13 ip next add id 14 via 1.1.1.14 dev dummy14 ip next add id 15 via 1.1.1.15 dev dummy15 ip next add id 16 via 1.1.1.16 dev dummy16 ip next add id 17 via 1.1.1.17 dev dummy17 ip next add id 18 via 1.1.1.18 dev dummy18 ip next add id 19 via 1.1.1.19 dev dummy19 ip next add id 20 via 1.1.1.20 dev dummy20 ip next add id 21 via 1.1.1.21 dev dummy21 ip next add id 22 via 1.1.1.22 dev dummy22 ip next add id 23 via 1.1.1.23 dev dummy23 ip next add id 24 via 1.1.1.24 dev dummy24 ip next add id 25 via 1.1.1.25 dev dummy25 ip next add id 26 via 1.1.1.26 dev dummy26 ip next add id 27 via 1.1.1.27 dev dummy27 ip next add id 28 via 1.1.1.28 dev dummy28 ip next add id 29 via 1.1.1.29 dev dummy29 ip next add id 30 via 1.1.1.30 dev dummy30 ip next add id 31 via 1.1.1.31 dev dummy31 ip next add id 32 via 1.1.1.32 dev dummy32
i=100
while [ $i -le 200 ]
do
ip next add id $i group 1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19
echo $i ((i++))
done
ip next add id 999 group 1/2/3/4/5/6
ip next ls
========================
--- net/ipv4/nexthop.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/nexthop.c +1 -0
@@ -276,6 +276,7 @@ static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,return 0 ; nla_put_failure: +nlmsg_cancel (skb, nlh);return -EMSGSIZE ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 220/606 net: qrtr: Fix passing invalid reference to qrtr_local_enqueue()
In reply to Sasha LevinFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit d28ea1fbbf437054ef339afec241019f2c4e2bb6 ]
Once the traversal of the list is completed with list_for_each_entry(), the iterator (node) will point to an invalid object. So passing this to qrtr_local_enqueue() which is outside of the iterator block is erroneous eventhough the object is not used.
So fix this by passing NULL to qrtr_local_enqueue().
--- net/qrtr/qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/qrtr/qrtr.c +1 -1
@@ -855,7 +855,7 @@ static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb, }mutex_unlock (&qrtr_node_lock); -qrtr_local_enqueue (node, skb, type, from, to); +qrtr_local_enqueue (NULL , skb, type, from, to);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 221/606 net: revert "net: get rid of an signed integer overflow in ip_idents_reserve()"
In reply to Sasha LevinFrom: Yuqi Jin <[email protected]>
[ Upstream commit a6211caa634da39d861a47437ffcda8b38ef421b ]
Commit adb03115f459 ("net: get rid of an signed integer overflow in ip_idents_reserve()") used atomic_cmpxchg to replace "atomic_add_return" inside the function "ip_idents_reserve". The reason was to avoid UBSAN warning.
However, this change has caused performance degrade and in GCC-8, fno-strict-overflow is now mapped to -fwrapv -fwrapv-pointer
and signed integer overflow is now undefined by default at all
optimization levels[1]. Moreover, it was a bug in UBSAN vs -fwrapv /-fno-strict-overflow, so Let's revert it safely.
[1] https://gcc.gnu.org/gcc-8/changes.html
--- net/ipv4/route.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/ipv4/route.c +6 -8
@@ -491,18 +491,16 @@ u32 ip_idents_reserve(u32 hash, int segs)atomic_t *p_id = ip_idents + hash %IP_IDENTS_SZ ;u32 old =READ_ONCE (*p_tstamp);u32 now = (u32 )jiffies; -u32 new, delta =0 ; +u32 delta =0 ;if (old != now &&cmpxchg (p_tstamp, old, now) == old) delta =prandom_u32_max (now - old); -/* Do not use atomic_add_return() as it makes UBSAN unhappy */ -do { - old = (u32 )atomic_read (p_id); - new = old + delta + segs; - }while (atomic_cmpxchg (p_id, old, new) != old); - -return new - segs; +/* If UBSAN reports an error there, please make sure your compiler +* supports -fno-strict-overflow before reporting it that was a bug +* in UBSAN, and it has been fixed in GCC-8. +*/ +return atomic_add_return (segs + delta, p_id) - segs; }EXPORT_SYMBOL (ip_idents_reserve);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 222/606 net sched: fix reporting the first-time use timestamp
In reply to Sasha LevinFrom: Roman Mashak <[email protected]>
[ Upstream commit b15e62631c5f19fea9895f7632dae9c1b27fe0cd ]
When a new action is installed, firstuse field of 'tcf_t' is explicitly set to 0. Value of zero means "new action, not yet used"; as a packet hits the action, 'firstuse' is stamped with the current jiffies value.
tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.
--- include/net/act_api.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/act_api.h +2 -1
@@ -69,7 +69,8 @@ static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) { dtm->install =jiffies_to_clock_t (jiffies - stm->install); dtm->lastuse =jiffies_to_clock_t (jiffies - stm->lastuse); - dtm->firstuse =jiffies_to_clock_t (jiffies - stm->firstuse); + dtm->firstuse = stm->firstuse ? +jiffies_to_clock_t (jiffies - stm->firstuse) :0 ; dtm->expires =jiffies_to_clock_t (stm->expires); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 223/606 net/tls: fix race condition causing kernel panic
In reply to Sasha LevinFrom: Vinay Kumar Yadav <[email protected]>
[ Upstream commit 0cada33241d9de205522e3858b18e506ca5cce2c ]
tls_sw_recvmsg() and tls_decrypt_done() can be run concurrently. // tls_sw_recvmsg()
if (atomic_read(&ctx->decrypt_pending)) crypto_wait_req(-EINPROGRESS, &ctx->async_wait); else reinit_completion(&ctx->async_wait.completion);
//tls_decrypt_done()
pending = atomic_dec_return(&ctx->decrypt_pending);
if (!pending && READ_ONCE(ctx->async_notify)) complete(&ctx->async_wait.completion);
Consider the scenario tls_decrypt_done() is about to run complete()
if (!pending && READ_ONCE(ctx->async_notify))
and tls_sw_recvmsg() reads decrypt_pending == 0, does reinit_completion(), then tls_decrypt_done() runs complete(). This sequence of execution results in wrong completion. Consequently, for next decrypt request, it will not wait for completion, eventually on connection close, crypto resources freed, there is no way to handle pending decrypt response.
This race condition can be avoided by having atomic_read() mutually exclusive with atomic_dec_return(),complete().Intoduced spin lock to ensure the mutual exclution.
Addressed similar problem in tx direction.
v1->v2:
- More readable commit message.
- Corrected the lock to fix new race scenario.
- Removed barrier which is not needed now.
--- include/net/tls.h | 4 ++++ net/tls/tls_sw.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-)
include/net/tls.h +4 -0
@@ -135,6 +135,8 @@ struct tls_sw_context_tx {struct tls_rec *open_rec;struct list_head tx_list;atomic_t encrypt_pending; +/* protect crypto_wait with encrypt_pending */ +spinlock_t encrypt_compl_lock;int async_notify; u8 async_capable:1;
@@ -155,6 +157,8 @@ struct tls_sw_context_rx { u8 async_capable:1; u8 decrypted:1;atomic_t decrypt_pending; +/* protect crypto_wait with decrypt_pending*/ +spinlock_t decrypt_compl_lock;bool async_notify; };
net/tls/tls_sw.c +27 -6
@@ -206,10 +206,12 @@ static void tls_decrypt_done(struct crypto_async_request *req, int err)kfree (aead_req); +spin_lock_bh (&ctx->decrypt_compl_lock); pending =atomic_dec_return (&ctx->decrypt_pending); -if (!pending &&READ_ONCE (ctx->async_notify)) +if (!pending && ctx->async_notify)complete (&ctx->async_wait.completion); +spin_unlock_bh (&ctx->decrypt_compl_lock); } static int tls_do_decryption(struct sock *sk,
@@ -467,10 +469,12 @@ static void tls_encrypt_done(struct crypto_async_request *req, int err) ready = true; } +spin_lock_bh (&ctx->encrypt_compl_lock); pending =atomic_dec_return (&ctx->encrypt_pending); -if (!pending &&READ_ONCE (ctx->async_notify)) +if (!pending && ctx->async_notify)complete (&ctx->async_wait.completion); +spin_unlock_bh (&ctx->encrypt_compl_lock);if (!ready)return ;
@@ -926,6 +930,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)int num_zc =0 ;int orig_size;int ret =0 ; +int pending;if (msg->msg_flags & ~(MSG_MORE |MSG_DONTWAIT |MSG_NOSIGNAL ))return -EOPNOTSUPP ;
@@ -1092,13 +1097,19 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) goto send_end; }else if (num_zc) {/* Wait for pending encryptions to get completed */ -smp_store_mb (ctx->async_notify, true); +spin_lock_bh (&ctx->encrypt_compl_lock); + ctx->async_notify = true; -if (atomic_read (&ctx->encrypt_pending)) + pending =atomic_read (&ctx->encrypt_pending); +spin_unlock_bh (&ctx->encrypt_compl_lock); +if (pending)crypto_wait_req (-EINPROGRESS , &ctx->async_wait);else reinit_completion (&ctx->async_wait.completion); +/* There can be no concurrent accesses, since we have no +* pending encrypt operations +*/ WRITE_ONCE (ctx->async_notify, false);if (ctx->async_wait.err) {
@@ -1729,6 +1740,7 @@ int tls_sw_recvmsg(struct sock *sk,bool is_kvec =iov_iter_is_kvec (&msg->msg_iter);bool is_peek = flags &MSG_PEEK ;int num_async =0 ; +int pending; flags |= nonblock;
@@ -1891,8 +1903,11 @@ int tls_sw_recvmsg(struct sock *sk, recv_end:if (num_async) {/* Wait for all previously submitted records to be decrypted */ -smp_store_mb (ctx->async_notify, true); -if (atomic_read (&ctx->decrypt_pending)) { +spin_lock_bh (&ctx->decrypt_compl_lock); + ctx->async_notify = true; + pending =atomic_read (&ctx->decrypt_pending); +spin_unlock_bh (&ctx->decrypt_compl_lock); +if (pending) { err =crypto_wait_req (-EINPROGRESS , &ctx->async_wait);if (err) {/* one of async decrypt failed */
@@ -1904,6 +1919,10 @@ int tls_sw_recvmsg(struct sock *sk, }else {reinit_completion (&ctx->async_wait.completion); } + +/* There can be no concurrent accesses, since we have no +* pending decrypt operations +*/ WRITE_ONCE (ctx->async_notify, false);/* Drain records from the rx_list & copy if required */
@@ -2290,6 +2309,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)if (tx) {crypto_init_wait (&sw_ctx_tx->async_wait); +spin_lock_init (&sw_ctx_tx->encrypt_compl_lock); crypto_info = &ctx->crypto_send.info; cctx = &ctx->tx; aead = &sw_ctx_tx->aead_send;
@@ -2298,6 +2318,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) sw_ctx_tx->tx_work.sk = sk; }else {crypto_init_wait (&sw_ctx_rx->async_wait); +spin_lock_init (&sw_ctx_rx->decrypt_compl_lock); crypto_info = &ctx->crypto_recv.info; cctx = &ctx->rx;skb_queue_head_init (&sw_ctx_rx->rx_list);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 224/606 nexthop: Fix attribute checking for groups
In reply to Sasha LevinFrom: David Ahern <[email protected]>
[ Upstream commit 84be69b869a5a496a6cfde9b3c29509207a1f1fa ]
For nexthop groups, attributes after NHA_GROUP_TYPE are invalid, but nh_check_attr_group starts checking at NHA_GROUP. The group type defaults to multipath and the NHA_GROUP_TYPE is currently optional so this has slipped through so far. Fix the attribute checking to handle support of new group types.
--- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/nexthop.c +1 -1
@@ -434,7 +434,7 @@ static int nh_check_attr_group(struct net *net, struct nlattr *tb[],if (!valid_group_nh (nh, len, extack))return -EINVAL ; } -for (i =NHA_GROUP +1 ; i < __NHA_MAX; ++i) { +for (i =NHA_GROUP_TYPE +1 ; i < __NHA_MAX; ++i) {if (!tb[i])continue ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 225/606 r8152: support additional Microsoft Surface Ethernet Adapter variant
In reply to Sasha LevinFrom: Marc Payne <[email protected]>
[ Upstream commit c27a204383616efba5a4194075e90819961ff66a ]
Device id 0927 is the RTL8153B-based component of the 'Surface USB-C to Ethernet and USB Adapter' and may be used as a component of other devices in future. Tested and working with the r8152 driver.
Update the cdc_ether blacklist due to the RTL8153 'network jam on suspend' issue which this device will cause (personally confirmed).
--- drivers/net/usb/cdc_ether.c | 11 +++++++++-- drivers/net/usb/r8152.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/usb/cdc_ether.c +9 -2
@@ -815,14 +815,21 @@ static const struct usb_device_id products[] = { .driver_info = 0, }, -/* Microsoft Surface 3 dock (based on Realtek RTL8153) */ +/* Microsoft Surface Ethernet Adapter (based on Realtek RTL8153) */ {USB_DEVICE_AND_INTERFACE_INFO (MICROSOFT_VENDOR_ID ,0x07c6 ,USB_CLASS_COMM , USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), .driver_info =0 , }, - /* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ +/* Microsoft Surface Ethernet Adapter (based on Realtek RTL8153B) */ +{ +USB_DEVICE_AND_INTERFACE_INFO (MICROSOFT_VENDOR_ID ,0x0927 ,USB_CLASS_COMM , +USB_CDC_SUBCLASS_ETHERNET ,USB_CDC_PROTO_NONE ), + .driver_info = 0, +}, + +/* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ {USB_DEVICE_AND_INTERFACE_INFO (TPLINK_VENDOR_ID ,0x0601 ,USB_CLASS_COMM , USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
drivers/net/usb/r8152.c +1 -0
@@ -6901,6 +6901,7 @@ static const struct usb_device_id rtl8152_table[] = { {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, + {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)}, {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)},
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 226/606 sctp: Don't add the shutdown timer if its already been added
In reply to Sasha LevinFrom: Neil Horman <[email protected]>
[ Upstream commit 20a785aa52c82246055a089e55df9dac47d67da1 ]
This BUG halt was reported a while back, but the patch somehow got missed:
PID: 2879 TASK: c16adaa0 CPU: 1 COMMAND: "sctpn"
#0 [f418dd28] crash_kexec at c04a7d8c
#1 [f418dd7c] oops_end at c0863e02
#2 [f418dd90] do_invalid_op at c040aaca
#3 [f418de28] error_code (via invalid_op) at c08631a5
EAX: f34baac0 EBX: 00000090 ECX: f418deb0 EDX: f5542950 EBP: 00000000
DS: 007b ESI: f34ba800 ES: 007b EDI: f418dea0 GS: 00e0
CS: 0060 EIP: c046fa5e ERR: ffffffff EFLAGS: 00010286
#4 [f418de5c] add_timer at c046fa5e
#5 [f418de68] sctp_do_sm at f8db8c77 [sctp]
#6 [f418df30] sctp_primitive_SHUTDOWN at f8dcc1b5 [sctp]
#7 [f418df48] inet_shutdown at c080baf9
#8 [f418df5c] sys_shutdown at c079eedf
#9 [f418df70] sys_socketcall at c079fe88
EAX: ffffffda EBX: 0000000d ECX: bfceea90 EDX: 0937af98
DS: 007b ESI: 0000000c ES: 007b EDI: b7150ae4
SS: 007b ESP: bfceea7c EBP: bfceeaa8 GS: 0033
CS: 0073 EIP: b775c424 ERR: 00000066 EFLAGS: 00000282It appears that the side effect that starts the shutdown timer was processed multiple times, which can happen as multiple paths can trigger it. This of course leads to the BUG halt in add_timer getting called.
Fix seems pretty straightforward, just check before the timer is added if its already been started. If it has mod the timer instead to min(current expiration, new expiration)
Its been tested but not confirmed to fix the problem, as the issue has only occured in production environments where test kernels are enjoined from being installed. It appears to be a sane fix to me though. Also, recentely, Jere found a reproducer posted on list to confirm that this resolves the issues
--- net/sctp/sm_sideeffect.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/sctp/sm_sideeffect.c +11 -3
@@ -1523,9 +1523,17 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type, timeout = asoc->timeouts[cmd->obj.to];BUG_ON (!timeout); - timer->expires = jiffies + timeout; -sctp_association_hold (asoc); -add_timer (timer); +/* +* SCTP has a hard time with timer starts. Because we process +* timer starts as side effects, it can be hard to tell if we +* have already started a timer or not, which leads to BUG +* halts when we call add_timer. So here, instead of just starting +* a timer, if the timer is already started, and just mod +* the timer with the shorter of the two expiration times +*/ +if (!timer_pending (timer)) +sctp_association_hold (asoc); +timer_reduce (timer, jiffies + timeout);break ;case SCTP_CMD_TIMER_RESTART :
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 227/606 sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed
In reply to Sasha LevinFrom: Jere Leppänen <[email protected]>
[ Upstream commit d3e8e4c11870413789f029a71e72ae6e971fe678 ]
Commit bdf6fa52f01b ("sctp: handle association restarts when the socket is closed.") starts shutdown when an association is restarted, if in SHUTDOWN-PENDING state and the socket is closed. However, the rationale stated in that commit applies also when in SHUTDOWN-SENT state - we don't want to move an association to ESTABLISHED state when the socket has been closed, because that results in an association that is unreachable from user space.
The problem scenario:
1. Client crashes and/or restarts.
2. Server (using one-to-one socket) calls close(). SHUTDOWN is lost.
3. Client reconnects using the same addresses and ports.
4. Server's association is restarted. The association and the socket move to ESTABLISHED state, even though the server process has closed its descriptor.
Also, after step 4 when the server process exits, some resources are leaked in an attempt to release the underlying inet sock structure in ESTABLISHED state:
IPv4: Attempt to release TCP socket in state 1 00000000377288c7
Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if an association is restarted in SHUTDOWN-SENT state and the socket is closed, then start shutdown and don't move the association or the socket to ESTABLISHED state.
--- net/sctp/sm_statefuns.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/sctp/sm_statefuns.c +5 -4
@@ -1856,12 +1856,13 @@ static enum sctp_disposition sctp_sf_do_dupcook_a(/* Update the content of current association. */ sctp_add_cmd_sf (commands,SCTP_CMD_UPDATE_ASSOC ,SCTP_ASOC (new_asoc));sctp_add_cmd_sf (commands,SCTP_CMD_EVENT_ULP ,SCTP_ULPEVENT (ev)); -if (sctp_state (asoc,SHUTDOWN_PENDING ) && +if ((sctp_state (asoc,SHUTDOWN_PENDING ) || +sctp_state (asoc,SHUTDOWN_SENT )) && (sctp_sstate (asoc->base.sk,CLOSING ) ||sock_flag (asoc->base.sk,SOCK_DEAD ))) { -/* if were currently in SHUTDOWN_PENDING, but the socket -* has been closed by user, don't transition to ESTABLISHED. -* Instead trigger SHUTDOWN bundled with COOKIE_ACK. +/* If the socket has been closed by user, don't +* transition to ESTABLISHED. Instead trigger SHUTDOWN +* bundled with COOKIE_ACK. */ sctp_add_cmd_sf (commands,SCTP_CMD_REPLY ,SCTP_CHUNK (repl)); return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 228/606 tipc: block BH before using dst_cache
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1378817486d6860f6a927f573491afe65287abf1 ]
dst_cache_get() documents it must be used with BH disabled.
sysbot reported :
BUG: using smp_processor_id() in preemptible [00000000] code: /21697 caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68 CPU: 0 PID: 21697 Comm: Not tainted 5.7.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x188/0x20d lib/dump_stack.c:118 check_preemption_disabled lib/smp_processor_id.c:47 [inline] debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57 dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68 tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164 tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244 tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526 tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331 __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995 tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline] genl_family_rcv_msg net/netlink/genetlink.c:718 [inline] genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469 genl_rcv+0x24/0x40 net/netlink/genetlink.c:746 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline] netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:672 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362 ___sys_sendmsg+0x100/0x170 net/socket.c:2416 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295 entry_SYSCALL_64_after_hwframe+0x49/0xb3 RIP: 0033:0x45ca29
--- net/tipc/udp_media.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -1
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb, struct udp_bearer *ub, struct udp_media_addr *src, struct udp_media_addr *dst, struct dst_cache *cache) { - struct dst_entry *ndst = dst_cache_get(cache); + struct dst_entry *ndst;int ttl, err =0 ; +local_bh_disable (); + ndst =dst_cache_get (cache);if (dst->proto ==htons (ETH_P_IP )) {struct rtable *rt = (struct rtable *)ndst;
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb, src->port, dst->port, false);#endif } +local_bh_enable ();return err; tx_error: +local_bh_enable ();kfree_skb (skb);return err; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 229/606 net/mlx5e: kTLS, Destroy key object after destroying the TIS
In reply to Sasha LevinFrom: Tariq Toukan <[email protected]>
[ Upstream commit 16736e11f43b80a38f98f6add54fab3b8c297df3 ]
The TLS TIS object contains the dek/key ID.
By destroying the key first, the TIS would contain an invalid non-existing key ID.
Reverse the destroy order, this also acheives the desired assymetry between the destroy and the create flows.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c +1 -1
@@ -69,8 +69,8 @@ static void mlx5e_ktls_del(struct net_device *netdev,struct mlx5e_ktls_offload_context_tx *tx_priv =mlx5e_get_ktls_tx_priv_ctx (tls_ctx); -mlx5_ktls_destroy_key (priv->mdev, tx_priv->key_id);mlx5e_destroy_tis (priv->mdev, tx_priv->tisn); +mlx5_ktls_destroy_key (priv->mdev, tx_priv->key_id);kvfree (tx_priv); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 230/606 net/mlx5e: Fix inner tirs handling
In reply to Sasha LevinFrom: Roi Dayan <[email protected]>
[ Upstream commit a16b8e0dcf7043bee46174bed0553cc9e36b63a5 ]
In the cited commit inner_tirs argument was added to create and destroy inner tirs, and no indication was added to mlx5e_modify_tirs_hash() function. In order to have a consistent handling, use inner_indir_tir[0].tirn in tirs destroy/modify function as an indication to whether inner tirs are created.
Inner tirs are not created for representors and before this commit, a call to mlx5e_modify_tirs_hash() was sending HW commands to modify non-existent inner tirs.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 12 +++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -1104,7 +1104,7 @@ void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq);int mlx5e_create_indirect_rqt (struct mlx5e_priv *priv);int mlx5e_create_indirect_tirs (struct mlx5e_priv *priv,bool inner_ttc); -void mlx5e_destroy_indirect_tirs (struct mlx5e_priv *priv,bool inner_ttc); +void mlx5e_destroy_indirect_tirs (struct mlx5e_priv *priv);int mlx5e_create_direct_rqts (struct mlx5e_priv *priv,struct mlx5e_tir *tirs);void mlx5e_destroy_direct_rqts (struct mlx5e_priv *priv,struct mlx5e_tir *tirs);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +7 -5
@@ -2747,7 +2747,8 @@ void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in, int inlen)mlx5_core_modify_tir (mdev, priv->indir_tir[tt].tirn, in, inlen); } -if (!mlx5e_tunnel_inner_ft_supported (priv->mdev)) +/* Verify inner tirs resources allocated */ +if (!priv->inner_indir_tir[0 ].tirn)return ;for (tt =0 ; tt <MLX5E_NUM_INDIR_TIRS ; tt++) {
@@ -3394,14 +3395,15 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)return err; } -void mlx5e_destroy_indirect_tirs (struct mlx5e_priv *priv,bool inner_ttc) +void mlx5e_destroy_indirect_tirs (struct mlx5e_priv *priv) {int i;for (i =0 ; i <MLX5E_NUM_INDIR_TIRS ; i++)mlx5e_destroy_tir (priv->mdev, &priv->indir_tir[i]); -if (!inner_ttc || !mlx5e_tunnel_inner_ft_supported (priv->mdev)) +/* Verify inner tirs resources allocated */ +if (!priv->inner_indir_tir[0 ].tirn)return ;for (i =0 ; i <MLX5E_NUM_INDIR_TIRS ; i++)
@@ -5107,7 +5109,7 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) err_destroy_direct_tirs:mlx5e_destroy_direct_tirs (priv, priv->direct_tir); err_destroy_indirect_tirs: -mlx5e_destroy_indirect_tirs (priv, true); +mlx5e_destroy_indirect_tirs (priv); err_destroy_direct_rqts:mlx5e_destroy_direct_rqts (priv, priv->direct_tir); err_destroy_indirect_rqts:
@@ -5126,7 +5128,7 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)mlx5e_destroy_direct_tirs (priv, priv->xsk_tir);mlx5e_destroy_direct_rqts (priv, priv->xsk_tir);mlx5e_destroy_direct_tirs (priv, priv->direct_tir); -mlx5e_destroy_indirect_tirs (priv, true); +mlx5e_destroy_indirect_tirs (priv);mlx5e_destroy_direct_rqts (priv, priv->direct_tir);mlx5e_destroy_rqt (priv, &priv->indir_rqt);mlx5e_close_drop_rq (&priv->drop_rq);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -1667,7 +1667,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) err_destroy_direct_tirs:mlx5e_destroy_direct_tirs (priv, priv->direct_tir); err_destroy_indirect_tirs: -mlx5e_destroy_indirect_tirs (priv, false); +mlx5e_destroy_indirect_tirs (priv); err_destroy_direct_rqts:mlx5e_destroy_direct_rqts (priv, priv->direct_tir); err_destroy_indirect_rqts:
@@ -1684,7 +1684,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)mlx5_del_flow_rules (rpriv->vport_rx_rule);mlx5e_destroy_ttc_table (priv, &priv->fs.ttc);mlx5e_destroy_direct_tirs (priv, priv->direct_tir); -mlx5e_destroy_indirect_tirs (priv, false); +mlx5e_destroy_indirect_tirs (priv);mlx5e_destroy_direct_rqts (priv, priv->direct_tir);mlx5e_destroy_rqt (priv, &priv->indir_rqt);mlx5e_close_drop_rq (&priv->drop_rq);
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -2
@@ -396,7 +396,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) err_destroy_direct_tirs:mlx5e_destroy_direct_tirs (priv, priv->direct_tir); err_destroy_indirect_tirs: -mlx5e_destroy_indirect_tirs (priv, true); +mlx5e_destroy_indirect_tirs (priv); err_destroy_direct_rqts:mlx5e_destroy_direct_rqts (priv, priv->direct_tir); err_destroy_indirect_rqts:
@@ -412,7 +412,7 @@ static void mlx5i_cleanup_rx(struct mlx5e_priv *priv) {mlx5i_destroy_flow_steering (priv);mlx5e_destroy_direct_tirs (priv, priv->direct_tir); -mlx5e_destroy_indirect_tirs (priv, true); +mlx5e_destroy_indirect_tirs (priv);mlx5e_destroy_direct_rqts (priv, priv->direct_tir);mlx5e_destroy_rqt (priv, &priv->indir_rqt);mlx5e_close_drop_rq (&priv->drop_rq);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 231/606 net/mlx5: Fix memory leak in mlx5_events_init
In reply to Sasha LevinFrom: Moshe Shemesh <[email protected]>
[ Upstream commit df14ad1eccb04a4a28c90389214dbacab085b244 ]
Fix memory leak in mlx5_events_init(), in casecreate_single_thread_workqueue() fails, events
struct should be freed.
--- drivers/net/ethernet/mellanox/mlx5/core/events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/events.c +3 -1
@@ -346,8 +346,10 @@ int mlx5_events_init(struct mlx5_core_dev *dev) events->dev = dev; dev->priv.events = events; events->wq =create_singlethread_workqueue ("mlx5_events" ); -if (!events->wq) +if (!events->wq) { +kfree (events);return -ENOMEM ; + }INIT_WORK (&events->pcie_core_work, mlx5_pcie_event);return 0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 232/606 net/mlx5e: Update netdev txq on completions during closure
In reply to Sasha LevinFrom: Moshe Shemesh <[email protected]>
[ Upstream commit 5e911e2c06bd8c17df29147a5e2d4b17fafda024 ]
On sq closure when we free its descriptors, we should also update netdev txq on completions which would not arrive. Otherwise if we reopen sqs and attach them back, for example on fw fatal recovery flow, we may get tx timeout.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +6 -3
@@ -538,10 +538,9 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)void mlx5e_free_txqsq_descs (struct mlx5e_txqsq *sq) {struct mlx5e_tx_wqe_info *wi; +u32 dma_fifo_cc, nbytes =0 ; +u16 ci, sqcc, npkts =0 ;struct sk_buff *skb; -u32 dma_fifo_cc; -u16 sqcc; -u16 ci;int i; sqcc = sq->cc;
@@ -566,11 +565,15 @@ void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq) }dev_kfree_skb_any (skb); + npkts++; + nbytes += wi->num_bytes; sqcc += wi->num_wqebbs; } sq->dma_fifo_cc = dma_fifo_cc; sq->cc = sqcc; + +netdev_tx_completed_queue (sq->txq, npkts, nbytes); }#ifdef CONFIG_MLX5_CORE_IPOIB
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 233/606 net/mlx5: Fix error flow in case of function_setup failure
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit 4f7400d5cbaef676e00cdffb0565bf731c6bb09e ]
Currently, if an error occurred during mlx5_function_setup(), we keep dev->state as DEVICE_STATE_UP.
Fixing it by adding a goto label.
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -1
@@ -1179,7 +1179,7 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool boot) err =mlx5_function_setup (dev, boot);if (err) - goto out; + goto err_function;if (boot) { err =mlx5_init_once (dev);
@@ -1225,6 +1225,7 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)mlx5_cleanup_once (dev); function_teardown:mlx5_function_teardown (dev, boot); +err_function: dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ;mutex_unlock (&dev->intf_state_mutex);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 234/606 wireguard: noise: read preshared key while taking lock
In reply to Sasha LevinFrom: "Jason A. Donenfeld" <[email protected]>
[ Upstream commit bc67d371256f5c47d824e2eec51e46c8d62d022e ]
Prior we read the preshared key after dropping the handshake lock, which isn't an actual crypto issue if it races, but it's still not quite correct. So copy that part of the state into a temporary like we do with the rest of the handshake state variables. Then we can release the lock, operate on the temporary, and zero it out at the end of the function. In performance tests, the impact of this was entirely unnoticable, probably because those bytes are coming from the same cacheline as other things that are being copied out in the same manner.
--- drivers/net/wireguard/noise.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireguard/noise.c +5 -1
@@ -715,6 +715,7 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src,u8 e[NOISE_PUBLIC_KEY_LEN ];u8 ephemeral_private[NOISE_PUBLIC_KEY_LEN ];u8 static_private[NOISE_PUBLIC_KEY_LEN ]; +u8 preshared_key[NOISE_SYMMETRIC_KEY_LEN ];down_read (&wg->static_identity.lock);
@@ -733,6 +734,8 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src,memcpy (chaining_key, handshake->chaining_key,NOISE_HASH_LEN );memcpy (ephemeral_private, handshake->ephemeral_private,NOISE_PUBLIC_KEY_LEN ); +memcpy (preshared_key, handshake->preshared_key, +NOISE_SYMMETRIC_KEY_LEN );up_read (&handshake->lock);if (state !=HANDSHAKE_CREATED_INITIATION )
@@ -750,7 +753,7 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src, goto fail;/* psk */ -mix_psk (chaining_key, hash, key, handshake->preshared_key); +mix_psk (chaining_key, hash, key, preshared_key);/* {} */ if (!message_decrypt(NULL, src->encrypted_nothing,
@@ -783,6 +786,7 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src,memzero_explicit (chaining_key,NOISE_HASH_LEN );memzero_explicit (ephemeral_private,NOISE_PUBLIC_KEY_LEN );memzero_explicit (static_private,NOISE_PUBLIC_KEY_LEN ); +memzero_explicit (preshared_key,NOISE_SYMMETRIC_KEY_LEN );up_read (&wg->static_identity.lock);return ret_peer; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 235/606 wireguard: queueing: preserve flow hash across packet scrubbing
In reply to Sasha LevinFrom: "Jason A. Donenfeld" <[email protected]>
[ Upstream commit c78a0b4a78839d572d8a80f6a62221c0d7843135 ]
It's important that we clear most header fields during encapsulation and decapsulation, because the packet is substantially changed, and we don't want any info leak or logic bug due to an accidental correlation. But, for encapsulation, it's wrong to clear skb->hash, since it's used by fq_codel and flow dissection in general. Without it, classification does not proceed as usual. This change might make it easier to estimate the number of innerflows by examining clustering of out of order packets, but this shouldn't open up anything that can't already be inferred otherwise (e.g. syn packet size inference), and fq_codel can be disabled anyway.
Furthermore, it might be the case that the hash isn't used or queried at all until after wireguard transmits the encrypted UDP packet, which means skb->hash might still be zero at this point, and thus no hash taken over the inner packet data. In order to address this situation, we force a calculation of skb->hash before encrypting packet data.
Of course this means that fq_codel might transmit packets slightly more out of order than usual. Toke did some testing on beefy machines with high quantities of parallel flows and found that increasing the reply-attack counter to 8192 takes care of the most pathological cases pretty well.
--- drivers/net/wireguard/messages.h | 2 +- drivers/net/wireguard/queueing.h | 10 +++++++++- drivers/net/wireguard/receive.c | 2 +- drivers/net/wireguard/send.c | 7 ++++++- 4 files changed, 17 insertions(+), 4 deletions(-)
drivers/net/wireguard/messages.h +1 -1
@@ -32,7 +32,7 @@ enum cookie_values { };enum counter_values { -COUNTER_BITS_TOTAL =2048 , +COUNTER_BITS_TOTAL =8192 ,COUNTER_REDUNDANT_BITS =BITS_PER_LONG ,COUNTER_WINDOW_SIZE =COUNTER_BITS_TOTAL -COUNTER_REDUNDANT_BITS };
drivers/net/wireguard/queueing.h +9 -1
@@ -87,12 +87,20 @@ static inline bool wg_check_packet_protocol(struct sk_buff *skb)return real_protocol && skb->protocol == real_protocol; } -static inline void wg_reset_packet (struct sk_buff *skb) +static inline void wg_reset_packet (struct sk_buff *skb,bool encapsulating) { +u8 l4_hash = skb->l4_hash; +u8 sw_hash = skb->sw_hash; +u32 hash = skb->hash;skb_scrub_packet (skb, true);memset (&skb->headers_start,0 , offsetof(struct sk_buff , headers_end) - offsetof(struct sk_buff , headers_start)); +if (encapsulating) { + skb->l4_hash = l4_hash; + skb->sw_hash = sw_hash; + skb->hash = hash; + } skb->queue_mapping =0 ; skb->nohdr =0 ; skb->peeked =0 ;
drivers/net/wireguard/receive.c +1 -1
@@ -485,7 +485,7 @@ int wg_packet_rx_poll(struct napi_struct *napi, int budget)if (unlikely (wg_socket_endpoint_from_skb (&endpoint, skb))) goto next; -wg_reset_packet (skb); +wg_reset_packet (skb, false);wg_packet_consume_data_done (peer, skb, &endpoint); free = false;
drivers/net/wireguard/send.c +6 -1
@@ -170,6 +170,11 @@ static bool encrypt_packet(struct sk_buff *skb, struct noise_keypair *keypair)struct sk_buff *trailer;int num_frags; +/* Force hash calculation before encryption so that flow analysis is +* consistent over the inner packet. +*/ +skb_get_hash (skb); +/* Calculate lengths. */ padding_len =calculate_skb_padding (skb); trailer_len = padding_len +noise_encrypted_len (0 );
@@ -298,7 +303,7 @@ void wg_packet_encrypt_worker(struct work_struct *work) skb_list_walk_safe(first, skb, next) {if (likely (encrypt_packet (skb,PACKET_CB (first)->keypair))) { -wg_reset_packet (skb); +wg_reset_packet (skb, true); }else { state =PACKET_STATE_DEAD ;break ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 236/606 wireguard: noise: separate receive counter from send counter
In reply to Sasha LevinFrom: "Jason A. Donenfeld" <[email protected]>
[ Upstream commit a9e90d9931f3a474f04bab782ccd9d77904941e9 ]
In "wireguard: queueing: preserve flow hash across packet scrubbing", we were required to slightly increase the size of the receive replay counter to something still fairly small, but an increase nonetheless. It turns out that we can recoup some of the additional memory overhead by splitting up the prior union type into two distinct types. Before, we used the same "noise_counter" union for both sending and receiving, with sending just using a simple atomic64_t, while receiving used the full replay counter checker. This meant that most of the memory being allocated for the sending counter was being wasted. Since the old "noise_counter" type increased in size in the prior commit, now is a good time to split up that union type into a distinct "noise_replay_ counter" for receiving and a boring atomic64_t for sending, each using neither more nor less memory than required.
Also, since sometimes the replay counter is accessed without necessitating additional accesses to the bitmap, we can reduce cache misses by hoisting the always-necessary lock above the bitmap in the struct layout. We also change a "noise_replay_counter" stack allocation to kmalloc in a -DDEBUG selftest so that KASAN doesn't trigger a stack frame warning.
All and all, removing a bit of abstraction in this commit makes the code simpler and smaller, in addition to the motivating memory usage recuperation. For example, passing around raw "noise_symmetric_key" structs is something that really only makes sense within noise.c, in the one place where the sending and receiving keys can safely be thought of as the same type of object; subsequent to that, it's important that we uniformly access these through keypair->{sending,receiving}, where their distinct roles are always made explicit. So this patch allows us to draw that distinction clearly as well.
--- drivers/net/wireguard/noise.c | 16 +++------ drivers/net/wireguard/noise.h | 14 ++++---- drivers/net/wireguard/receive.c | 42 ++++++++++++------------ drivers/net/wireguard/selftest/counter.c | 17 +++++++--- drivers/net/wireguard/send.c | 12 +++---- 5 files changed, 48 insertions(+), 53 deletions(-)
drivers/net/wireguard/noise.c +4 -12
@@ -104,6 +104,7 @@ static struct noise_keypair *keypair_create(struct wg_peer *peer)if (unlikely (!keypair))return NULL ; +spin_lock_init (&keypair->receiving_counter.lock); keypair->internal_id =atomic64_inc_return (&keypair_counter); keypair->entry.type =INDEX_HASHTABLE_KEYPAIR ; keypair->entry.peer = peer;
@@ -358,25 +359,16 @@ static void kdf(u8 *first_dst, u8 *second_dst, u8 *third_dst, const u8 *data,memzero_explicit (output,BLAKE2S_HASH_SIZE +1 ); } -static void symmetric_key_init (struct noise_symmetric_key *key) -{ -spin_lock_init (&key->counter.receive.lock); -atomic64_set (&key->counter.counter,0 ); -memset (key->counter.receive.backtrack,0 , -sizeof (key->counter.receive.backtrack)); - key->birthdate =ktime_get_coarse_boottime_ns (); - key->is_valid = true; -} -static void derive_keys (struct noise_symmetric_key *first_dst,struct noise_symmetric_key *second_dst,const u8 chaining_key[NOISE_HASH_LEN ]) { +u64 birthdate =ktime_get_coarse_boottime_ns ();kdf (first_dst->key, second_dst->key,NULL ,NULL ,NOISE_SYMMETRIC_KEY_LEN ,NOISE_SYMMETRIC_KEY_LEN ,0 ,0 , chaining_key); -symmetric_key_init (first_dst); -symmetric_key_init (second_dst); + first_dst->birthdate = second_dst->birthdate = birthdate; + first_dst->is_valid = second_dst->is_valid = true; } static bool __must_check mix_dh(u8 chaining_key[NOISE_HASH_LEN],
drivers/net/wireguard/noise.h +6 -8
@@ -15,18 +15,14 @@#include <linux/mutex.h> #include <linux/kref.h> -union noise_counter { -struct { -u64 counter; -unsigned long backtrack[COUNTER_BITS_TOTAL /BITS_PER_LONG ]; -spinlock_t lock; - } receive; -atomic64_t counter; +struct noise_replay_counter { +u64 counter; +spinlock_t lock; +unsigned long backtrack[COUNTER_BITS_TOTAL /BITS_PER_LONG ]; };struct noise_symmetric_key {u8 key[NOISE_SYMMETRIC_KEY_LEN ]; -union noise_counter counter;u64 birthdate;bool is_valid; };
@@ -34,7 +30,9 @@ struct noise_symmetric_key {struct noise_keypair {struct index_hashtable_entry entry;struct noise_symmetric_key sending; +atomic64_t sending_counter;struct noise_symmetric_key receiving; +struct noise_replay_counter receiving_counter;__le32 remote_index;bool i_am_the_initiator;struct kref refcount;
drivers/net/wireguard/receive.c +21 -21
109 lines not on this page · raw message
drivers/net/wireguard/selftest/counter.c +12 -5
@@ -6,18 +6,24 @@ #ifdef DEBUG bool __init wg_packet_counter_selftest(void) { + struct noise_replay_counter *counter; unsigned int test_num = 0, i; - union noise_counter counter; bool success = true; -#define T_INIT do { \ - memset(&counter, 0, sizeof(union noise_counter)); \ - spin_lock_init(&counter.receive.lock); \ + counter = kmalloc(sizeof(*counter), GFP_KERNEL); + if (unlikely(!counter)) { + pr_err("nonce counter self-test malloc: FAIL\n"); + return false; + } + +#define T_INIT do { \ + memset(counter, 0, sizeof(*counter)); \ + spin_lock_init(&counter->lock); \ } while (0) #define T_LIM (COUNTER_WINDOW_SIZE + 1) #define T(n, v) do { \ ++test_num; \ - if (counter_validate(&counter, n) != (v)) { \ + if (counter_validate(counter, n) != (v)) { \ pr_err("nonce counter self-test %u: FAIL\n", \ test_num); \ success = false; \
@@ -99,6 +105,7 @@ bool __init wg_packet_counter_selftest(void)if (success)pr_info ("nonce counter self-tests: pass\n" ); +kfree (counter); return success; }#endif
drivers/net/wireguard/send.c +5 -7
@@ -129,7 +129,7 @@ static void keep_key_fresh(struct wg_peer *peer)rcu_read_lock_bh (); keypair =rcu_dereference_bh (peer->keypairs.current_keypair); if (likely(keypair && READ_ONCE(keypair->sending.is_valid)) && - (unlikely(atomic64_read(&keypair->sending.counter.counter) > + (unlikely(atomic64_read(&keypair->sending_counter) > REKEY_AFTER_MESSAGES) || (keypair->i_am_the_initiator && unlikely(wg_birthdate_has_expired(keypair->sending.birthdate,
@@ -353,7 +353,6 @@ void wg_packet_purge_staged_packets(struct wg_peer *peer)void wg_packet_send_staged_packets (struct wg_peer *peer) { -struct noise_symmetric_key *key;struct noise_keypair *keypair;struct sk_buff_head packets;struct sk_buff *skb;
@@ -373,10 +372,9 @@ void wg_packet_send_staged_packets(struct wg_peer *peer)rcu_read_unlock_bh ();if (unlikely (!keypair)) goto out_nokey; - key = &keypair->sending; -if (unlikely (!READ_ONCE (key->is_valid))) +if (unlikely (!READ_ONCE (keypair->sending.is_valid))) goto out_nokey; -if (unlikely (wg_birthdate_has_expired (key->birthdate, +if (unlikely (wg_birthdate_has_expired (keypair->sending.birthdate,REJECT_AFTER_TIME ))) goto out_invalid;
@@ -391,7 +389,7 @@ void wg_packet_send_staged_packets(struct wg_peer *peer)*/ PACKET_CB (skb)->ds =ip_tunnel_ecn_encap (0 ,ip_hdr (skb), skb);PACKET_CB (skb)->nonce = -atomic64_inc_return (&key->counter.counter) -1 ; +atomic64_inc_return (&keypair->sending_counter) -1 ;if (unlikely (PACKET_CB (skb)->nonce >=REJECT_AFTER_MESSAGES )) goto out_invalid; }
@@ -403,7 +401,7 @@ void wg_packet_send_staged_packets(struct wg_peer *peer)return ; out_invalid: -WRITE_ONCE (key->is_valid, false); +WRITE_ONCE (keypair->sending.is_valid, false); out_nokey:wg_noise_keypair_put (keypair, false);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 237/606 r8169: fix OCP access on RTL8117
In reply to Sasha LevinFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 561535b0f23961ced071b82575d5e83e6351a814 ]
According to r8168 vendor driver DASHv3 chips like RTL8168fp/RTL8117 need a special addressing for OCP access.
Fix is compile-tested only due to missing test hardware.
--- drivers/net/ethernet/realtek/r8169_main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +15 -2
@@ -1044,6 +1044,13 @@ static u16 rtl_ephy_read(struct rtl8169_private *tp, int reg_addr) RTL_R32(tp, EPHYAR) & EPHYAR_DATA_MASK : ~0; } +static void r8168fp_adjust_ocp_cmd (struct rtl8169_private *tp,u32 *cmd,int type) +{ +/* based on RTL8168FP_OOBMAC_BASE in vendor driver */ +if (tp->mac_version ==RTL_GIGA_MAC_VER_52 && type ==ERIAR_OOB ) + *cmd |=0x7f0 <<18 ; +} +DECLARE_RTL_COND (rtl_eriar_cond) {return RTL_R32 (tp,ERIAR ) &ERIAR_FLAG ;
@@ -1052,9 +1059,12 @@ DECLARE_RTL_COND(rtl_eriar_cond)static void _rtl_eri_write (struct rtl8169_private *tp,int addr,u32 mask,u32 val,int type) { +u32 cmd =ERIAR_WRITE_CMD | type | mask | addr; +BUG_ON ((addr &3 ) || (mask ==0 ));RTL_W32 (tp,ERIDR , val); -RTL_W32 (tp,ERIAR ,ERIAR_WRITE_CMD | type | mask | addr); +r8168fp_adjust_ocp_cmd (tp, &cmd, type); +RTL_W32 (tp,ERIAR , cmd);rtl_udelay_loop_wait_low (tp, &rtl_eriar_cond,100 ,100 ); }
@@ -1067,7 +1077,10 @@ static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,static u32 _rtl_eri_read (struct rtl8169_private *tp,int addr,int type) { -RTL_W32 (tp,ERIAR ,ERIAR_READ_CMD | type |ERIAR_MASK_1111 | addr); +u32 cmd =ERIAR_READ_CMD | type |ERIAR_MASK_1111 | addr; + +r8168fp_adjust_ocp_cmd (tp, &cmd, type); +RTL_W32 (tp,ERIAR , cmd);return rtl_udelay_loop_wait_high (tp, &rtl_eriar_cond,100 ,100 ) ?RTL_R32 (tp,ERIDR ) : ~0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 238/606 net/mlx5: Fix a race when moving command interface to events mode
In reply to Sasha LevinFrom: Eran Ben Elisha <[email protected]>
[ Upstream commit d43b7007dbd1195a5b6b83213e49b1516aaf6f5e ]
After driver creates (via FW command) an EQ for commands, the driver will be informed on new commands completion by EQE. However, due to a race in driver's internal command mode metadata update, some new commands will still be miss-handled by driver as if we are in polling mode. Such commands can get two non forced completion, leading to already freed command entry access.
CREATE_EQ command, that maps EQ to the command queue must be posted to the command queue while it is empty and no other command should be posted.
Add SW mechanism that once the CREATE_EQ command is about to be executed, all other commands will return error without being sent to the FW. Allow sending other commands only after successfully changing the driver's internal command mode metadata.
We can safely return error to all other commands while creating the command EQ, as all other commands might be sent from the user/application during driver load. Application can rerun them later after driver's load was finished.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 35 ++++++++++++++++--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 ++ include/linux/mlx5/driver.h | 6 ++++ 3 files changed, 40 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +31 -4
@@ -848,6 +848,14 @@ static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg);static void mlx5_free_cmd_msg (struct mlx5_core_dev *dev,struct mlx5_cmd_msg *msg); +static bool opcode_allowed (struct mlx5_cmd *cmd,u16 opcode) +{ +if (cmd->allowed_opcode ==CMD_ALLOWED_OPCODE_ALL ) +return true; + +return cmd->allowed_opcode == opcode; +} +static void cmd_work_handler (struct work_struct *work) { struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
@@ -914,7 +922,8 @@ static void cmd_work_handler(struct work_struct *work)/* Skip sending command to fw if internal error */ if (pci_channel_offline (dev->pdev) || - dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR ) { + dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR || + !opcode_allowed (&dev->cmd, ent->op)) {u8 status =0 ;u32 drv_synd;
@@ -1405,6 +1414,22 @@ static void create_debugfs_files(struct mlx5_core_dev *dev)mlx5_cmdif_debugfs_init (dev); } +void mlx5_cmd_allowed_opcode (struct mlx5_core_dev *dev,u16 opcode) +{ +struct mlx5_cmd *cmd = &dev->cmd; +int i; + +for (i =0 ; i < cmd->max_reg_cmds; i++) +down (&cmd->sem); +down (&cmd->pages_sem); + + cmd->allowed_opcode = opcode; + +up (&cmd->pages_sem); +for (i =0 ; i < cmd->max_reg_cmds; i++) +up (&cmd->sem); +} +static void mlx5_cmd_change_mod (struct mlx5_core_dev *dev,int mode) {struct mlx5_cmd *cmd = &dev->cmd;
@@ -1681,12 +1706,13 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,int err;u8 status =0 ;u32 drv_synd; +u16 opcode;u8 token; + opcode =MLX5_GET (mbox_in, in, opcode);if (pci_channel_offline (dev->pdev) || - dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR ) { -u16 opcode =MLX5_GET (mbox_in, in, opcode); - + dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR || + !opcode_allowed (&dev->cmd, opcode)) { err =mlx5_internal_err_ret_value (dev, opcode, &drv_synd, &status);MLX5_SET (mbox_out, out, status, status);MLX5_SET (mbox_out, out, syndrome, drv_synd);
@@ -1988,6 +2014,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)mlx5_core_dbg (dev,"descriptor at dma 0x%llx\n" , (unsigned long long )(cmd->dma)); cmd->mode =CMD_MODE_POLLING ; + cmd->allowed_opcode =CMD_ALLOWED_OPCODE_ALL ;create_msg_cache (dev);
drivers/net/ethernet/mellanox/mlx5/core/eq.c +3 -0
@@ -611,11 +611,13 @@ static int create_async_eqs(struct mlx5_core_dev *dev) .nent = MLX5_NUM_CMD_EQE, .mask[0] = 1ull << MLX5_EVENT_TYPE_CMD, }; +mlx5_cmd_allowed_opcode (dev,MLX5_CMD_OP_CREATE_EQ ); err =setup_async_eq (dev, &table->cmd_eq, ¶m,"cmd" );if (err) goto err1;mlx5_cmd_use_events (dev); +mlx5_cmd_allowed_opcode (dev,CMD_ALLOWED_OPCODE_ALL ); param = (struct mlx5_eq_param ) { .irq_index =0 ,
@@ -645,6 +647,7 @@ static int create_async_eqs(struct mlx5_core_dev *dev)mlx5_cmd_use_polling (dev);cleanup_async_eq (dev, &table->cmd_eq,"cmd" ); err1: +mlx5_cmd_allowed_opcode (dev,CMD_ALLOWED_OPCODE_ALL );mlx5_eq_notifier_unregister (dev, &table->cq_err_nb);return err; }
include/linux/mlx5/driver.h +6 -0
@@ -301,6 +301,7 @@ struct mlx5_cmd {struct semaphore sem;struct semaphore pages_sem;int mode; +u16 allowed_opcode;struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS ];struct dma_pool *pool;struct mlx5_cmd_debug dbg;
@@ -893,10 +894,15 @@ mlx5_frag_buf_get_idx_last_contig_stride(struct mlx5_frag_buf_ctrl *fbc, u32 ix)return min_t (u32, last_frag_stride_idx - fbc->strides_offset, fbc->sz_m1); } +enum { +CMD_ALLOWED_OPCODE_ALL , +}; +int mlx5_cmd_init (struct mlx5_core_dev *dev);void mlx5_cmd_cleanup (struct mlx5_core_dev *dev);void mlx5_cmd_use_events (struct mlx5_core_dev *dev);void mlx5_cmd_use_polling (struct mlx5_core_dev *dev); +void mlx5_cmd_allowed_opcode (struct mlx5_core_dev *dev,u16 opcode);struct mlx5_async_ctx {struct mlx5_core_dev *dev;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 239/606 net/mlx5: Fix cleaning unmanaged flow tables
In reply to Sasha LevinFrom: Roi Dayan <[email protected]>
[ Upstream commit aee37f3d940ca732df71c3df49347bccaafc0b24 ]
Unmanaged flow tables doesn't have a parent and tree_put_node() assume there is always a parent if cleaning is needed. fix that.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +6 -5
@@ -323,14 +323,13 @@ static void tree_put_node(struct fs_node *node, bool locked)if (node->del_hw_func) node->del_hw_func (node);if (parent_node) { -/* Only root namespace doesn't have parent and we just -* need to free its node. -*/ down_write_ref_node (parent_node, locked);list_del_init (&node->list);if (node->del_sw_func) node->del_sw_func (node);up_write_ref_node (parent_node, locked); + }else if (node->del_sw_func) { + node->del_sw_func (node); }else {kfree (node); }
@@ -447,8 +446,10 @@ static void del_sw_flow_table(struct fs_node *node)fs_get_obj (ft, node);rhltable_destroy (&ft->fgs_hash); -fs_get_obj (prio, ft->node.parent); - prio->num_ft--; +if (ft->node.parent) { +fs_get_obj (prio, ft->node.parent); + prio->num_ft--; + }kfree (ft); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 240/606 Revert "virtio-balloon: Revert "virtio-balloon: Switch back to OOM handler for VIRTIO_BALLOON_F_DEFLATE_ON_OOM""
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
This reverts commit 37681282be8e89ae8baf26753bf489837d74e08e which is commit 835a6a649d0dd1b1f46759eb60fff2f63ed253a7 upstream.
Jiri and David agree that it is not needed in the 5.6.y tree, so revert it.
--- drivers/virtio/virtio_balloon.c | 107 +++++++++++++------------------- 1 file changed, 44 insertions(+), 63 deletions(-)
drivers/virtio/virtio_balloon.c +44 -63
@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/module.h> #include <linux/balloon_compaction.h> +#include <linux/oom.h> #include <linux/wait.h> #include <linux/mm.h> #include <linux/mount.h>
@@ -27,7 +28,9 @@*/ #define VIRTIO_BALLOON_PAGES_PER_PAGE (unsigned)(PAGE_SIZE >> VIRTIO_BALLOON_PFN_SHIFT)#define VIRTIO_BALLOON_ARRAY_PFNS_MAX 256 -#define VIRTBALLOON_OOM_NOTIFY_PRIORITY 80 +/* Maximum number of (4k) pages to deflate on OOM notifications. */ +#define VIRTIO_BALLOON_OOM_NR_PAGES 256 +#define VIRTIO_BALLOON_OOM_NOTIFY_PRIORITY 80#define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ __GFP_NOMEMALLOC)
@@ -112,8 +115,11 @@ struct virtio_balloon {/* Memory statistics */ struct virtio_balloon_stat stats[VIRTIO_BALLOON_S_NR ]; -/* To register a shrinker to shrink memory upon memory pressure */ +/* Shrinker to return free pages - VIRTIO_BALLOON_F_FREE_PAGE_HINT */ struct shrinker shrinker; + +/* OOM notifier to deflate on OOM - VIRTIO_BALLOON_F_DEFLATE_ON_OOM */ +struct notifier_block oom_nb; };static struct virtio_device_id id_table[] = {
@@ -788,50 +794,13 @@ static unsigned long shrink_free_pages(struct virtio_balloon *vb,return blocks_freed *VIRTIO_BALLOON_HINT_BLOCK_PAGES ; } -static unsigned long leak_balloon_pages (struct virtio_balloon *vb, -unsigned long pages_to_free) -{ -return leak_balloon (vb, pages_to_free *VIRTIO_BALLOON_PAGES_PER_PAGE ) / -VIRTIO_BALLOON_PAGES_PER_PAGE ; -} - -static unsigned long shrink_balloon_pages (struct virtio_balloon *vb, -unsigned long pages_to_free) -{ -unsigned long pages_freed =0 ; - -/* -* One invocation of leak_balloon can deflate at most -* VIRTIO_BALLOON_ARRAY_PFNS_MAX balloon pages, so we call it -* multiple times to deflate pages till reaching pages_to_free. -*/ -while (vb->num_pages && pages_freed < pages_to_free) - pages_freed +=leak_balloon_pages (vb, - pages_to_free - pages_freed); - -update_balloon_size (vb); - -return pages_freed; -} -static unsigned long virtio_balloon_shrinker_scan (struct shrinker *shrinker,struct shrink_control *sc) { -unsigned long pages_to_free, pages_freed =0 ;struct virtio_balloon *vb =container_of (shrinker, struct virtio_balloon, shrinker); - pages_to_free = sc->nr_to_scan; - -if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT )) - pages_freed =shrink_free_pages (vb, pages_to_free); - -if (pages_freed >= pages_to_free) -return pages_freed; - - pages_freed +=shrink_balloon_pages (vb, pages_to_free - pages_freed); - -return pages_freed; +return shrink_free_pages (vb, sc->nr_to_scan); } static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker,
@@ -839,26 +808,22 @@ static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker, {struct virtio_balloon *vb =container_of (shrinker, struct virtio_balloon, shrinker); -unsigned long count; - - count = vb->num_pages /VIRTIO_BALLOON_PAGES_PER_PAGE ; - count += vb->num_free_page_blocks *VIRTIO_BALLOON_HINT_BLOCK_PAGES ; -return count; +return vb->num_free_page_blocks *VIRTIO_BALLOON_HINT_BLOCK_PAGES ; } -static void virtio_balloon_unregister_shrinker (struct virtio_balloon *vb) +static int virtio_balloon_oom_notify (struct notifier_block *nb, +unsigned long dummy,void *parm) { -unregister_shrinker (&vb->shrinker); -} +struct virtio_balloon *vb =container_of (nb, + struct virtio_balloon, oom_nb); +unsigned long *freed = parm; -static int virtio_balloon_register_shrinker (struct virtio_balloon *vb) -{ - vb->shrinker.scan_objects = virtio_balloon_shrinker_scan; - vb->shrinker.count_objects = virtio_balloon_shrinker_count; - vb->shrinker.seeks =DEFAULT_SEEKS ; + *freed +=leak_balloon (vb,VIRTIO_BALLOON_OOM_NR_PAGES ) / +VIRTIO_BALLOON_PAGES_PER_PAGE ; +update_balloon_size (vb); -return register_shrinker (&vb->shrinker); +return NOTIFY_OK ; }static int virtballoon_probe (struct virtio_device *vdev)
@@ -935,22 +900,35 @@ static int virtballoon_probe(struct virtio_device *vdev) virtio_cwrite(vb->vdev, struct virtio_balloon_config, poison_val, &poison_val); } - } -/* -* We continue to use VIRTIO_BALLOON_F_DEFLATE_ON_OOM to decide if a -* shrinker needs to be registered to relieve memory pressure. -*/ -if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM )) { - err =virtio_balloon_register_shrinker (vb); + +/* +* We're allowed to reuse any free pages, even if they are +* still to be processed by the host. +*/ + vb->shrinker.scan_objects = virtio_balloon_shrinker_scan; + vb->shrinker.count_objects = virtio_balloon_shrinker_count; + vb->shrinker.seeks =DEFAULT_SEEKS ; + err =register_shrinker (&vb->shrinker);if (err) goto out_del_balloon_wq; } +if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM )) { + vb->oom_nb.notifier_call = virtio_balloon_oom_notify; + vb->oom_nb.priority =VIRTIO_BALLOON_OOM_NOTIFY_PRIORITY ; + err =register_oom_notifier (&vb->oom_nb); +if (err <0 ) + goto out_unregister_shrinker; + } +virtio_device_ready (vdev);if (towards_target (vb))virtballoon_changed (vdev);return 0 ; +out_unregister_shrinker: +if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT )) +unregister_shrinker (&vb->shrinker); out_del_balloon_wq:if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT ))destroy_workqueue (vb->balloon_wq);
@@ -989,8 +967,11 @@ static void virtballoon_remove(struct virtio_device *vdev) {struct virtio_balloon *vb = vdev->priv; -if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM )) -virtio_balloon_unregister_shrinker (vb); +if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM )) +unregister_oom_notifier (&vb->oom_nb); +if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT )) +unregister_shrinker (&vb->shrinker); +spin_lock_irq (&vb->stop_update_lock); vb->stop_update = true;spin_unlock_irq (&vb->stop_update_lock);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 241/606 net/mlx5: Avoid processing commands before cmdif is ready
In reply to Sasha LevinFrom: Eran Ben Elisha <[email protected]>
commit f7936ddd35d8b849daf0372770c7c9dbe7910fca upstream.
When driver is reloading during recovery flow, it can't get new commands till command interface is up again. Otherwise we may get to null pointer trying to access non initialized command structures.
Add cmdif state to avoid processing commands while cmdif is not ready.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 10 ++++++++++ drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 ++++ include/linux/mlx5/driver.h | 9 +++++++++ 3 files changed, 23 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +10 -0
@@ -923,6 +923,7 @@ static void cmd_work_handler(struct work_struct *work)/* Skip sending command to fw if internal error */ if (pci_channel_offline (dev->pdev) || dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR || + cmd->state !=MLX5_CMDIF_STATE_UP || !opcode_allowed (&dev->cmd, ent->op)) {u8 status =0 ;u32 drv_synd;
@@ -1712,6 +1713,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, opcode =MLX5_GET (mbox_in, in, opcode);if (pci_channel_offline (dev->pdev) || dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR || + dev->cmd.state !=MLX5_CMDIF_STATE_UP || !opcode_allowed (&dev->cmd, opcode)) { err =mlx5_internal_err_ret_value (dev, opcode, &drv_synd, &status);MLX5_SET (mbox_out, out, status, status);
@@ -1977,6 +1979,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev) goto err_free_page; } + cmd->state =MLX5_CMDIF_STATE_DOWN ; cmd->checksum_disabled =1 ; cmd->max_reg_cmds = (1 << cmd->log_sz) -1 ; cmd->bitmask = (1UL << cmd->max_reg_cmds) -1 ;
@@ -2054,3 +2057,10 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)dma_pool_destroy (cmd->pool); }EXPORT_SYMBOL (mlx5_cmd_cleanup); + +void mlx5_cmd_set_state (struct mlx5_core_dev *dev, +enum mlx5_cmdif_state cmdif_state) +{ + dev->cmd.state = cmdif_state; +} +EXPORT_SYMBOL (mlx5_cmd_set_state);
drivers/net/ethernet/mellanox/mlx5/core/main.c +4 -0
@@ -962,6 +962,8 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) goto err_cmd_cleanup; } +mlx5_cmd_set_state (dev,MLX5_CMDIF_STATE_UP ); + err =mlx5_core_enable_hca (dev,0 );if (err) {mlx5_core_err (dev,"enable hca failed\n" );
@@ -1023,6 +1025,7 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) err_disable_hca:mlx5_core_disable_hca (dev,0 ); err_cmd_cleanup: +mlx5_cmd_set_state (dev,MLX5_CMDIF_STATE_DOWN );mlx5_cmd_cleanup (dev);return err;
@@ -1040,6 +1043,7 @@ static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot) }mlx5_reclaim_startup_pages (dev);mlx5_core_disable_hca (dev,0 ); +mlx5_cmd_set_state (dev,MLX5_CMDIF_STATE_DOWN );mlx5_cmd_cleanup (dev);return 0 ;
include/linux/mlx5/driver.h +9 -0
@@ -230,6 +230,12 @@ struct mlx5_bfreg_info {u32 num_dyn_bfregs; }; +enum mlx5_cmdif_state { +MLX5_CMDIF_STATE_UNINITIALIZED , +MLX5_CMDIF_STATE_UP , +MLX5_CMDIF_STATE_DOWN , +}; +struct mlx5_cmd_first {__be32 data[4 ]; };
@@ -275,6 +281,7 @@ struct mlx5_cmd_stats {struct mlx5_cmd {struct mlx5_nb nb; +enum mlx5_cmdif_state state;void *cmd_alloc_buf;dma_addr_t alloc_dma;int alloc_size;
@@ -900,6 +907,8 @@ enum {int mlx5_cmd_init (struct mlx5_core_dev *dev);void mlx5_cmd_cleanup (struct mlx5_core_dev *dev); +void mlx5_cmd_set_state (struct mlx5_core_dev *dev, +enum mlx5_cmdif_state cmdif_state);void mlx5_cmd_use_events (struct mlx5_core_dev *dev);void mlx5_cmd_use_polling (struct mlx5_core_dev *dev);void mlx5_cmd_allowed_opcode (struct mlx5_core_dev *dev,u16 opcode);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 242/606 net/mlx5: Annotate mutex destroy for root ns
In reply to Sasha LevinFrom: Roi Dayan <[email protected]>
commit 9ca415399dae133b00273a4283ef31d003a6818d upstream.
Invoke mutex_destroy() to catch any errors.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +6 -0
@@ -416,6 +416,12 @@ static void del_sw_ns(struct fs_node *node)static void del_sw_prio (struct fs_node *node) { +struct mlx5_flow_root_namespace *root_ns; +struct mlx5_flow_namespace *ns; + +fs_get_obj (ns, node); + root_ns = container_of(ns, struct mlx5_flow_root_namespace, ns); +mutex_destroy (&root_ns->chain_lock);kfree (node); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 243/606 net/tls: fix encryption error checking
In reply to Sasha LevinFrom: Vadim Fedorenko <[email protected]>
commit a7bff11f6f9afa87c25711db8050c9b5324db0e2 upstream.
bpf_exec_tx_verdict() can return negative value for copied variable. In that case this value will be pushed back to caller and the real error code will be lost. Fix it using signed type and checking for positive value.
--- net/tls/tls_sw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/tls/tls_sw.c +6 -5
@@ -784,7 +784,7 @@ static int tls_push_record(struct sock *sk, int flags,static int bpf_exec_tx_verdict (struct sk_msg *msg,struct sock *sk,bool full_record,u8 record_type, -size_t *copied,int flags) +ssize_t *copied,int flags) {struct tls_context *tls_ctx =tls_get_ctx (sk);struct tls_sw_context_tx *ctx =tls_sw_ctx_tx (tls_ctx);
@@ -920,7 +920,8 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)unsigned char record_type =TLS_RECORD_TYPE_DATA ;bool is_kvec =iov_iter_is_kvec (&msg->msg_iter);bool eor = !(msg->msg_flags &MSG_MORE ); -size_t try_to_copy, copied =0 ; +size_t try_to_copy; +ssize_t copied =0 ;struct sk_msg *msg_pl, *msg_en;struct tls_rec *rec;int required_size;
@@ -1129,7 +1130,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)release_sock (sk);mutex_unlock (&tls_ctx->tx_lock); -return copied ? copied : ret; +return copied >0 ? copied : ret; } static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
@@ -1143,7 +1144,7 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page,struct sk_msg *msg_pl;struct tls_rec *rec;int num_async =0 ; -size_t copied =0 ; +ssize_t copied =0 ;bool full_record;int record_room;int ret =0 ;
@@ -1245,7 +1246,7 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page, } sendpage_end: ret =sk_stream_error (sk, flags, ret); -return copied ? copied : ret; +return copied >0 ? copied : ret; } int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 244/606 net/tls: free record only on encryption error
In reply to Sasha LevinFrom: Vadim Fedorenko <[email protected]>
commit 635d9398178659d8ddba79dd061f9451cec0b4d1 upstream.
We cannot free record on any transient error because it leads to losing previos data. Check socket error to know whether record must be freed or not.
--- net/tls/tls_sw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/tls/tls_sw.c +4 -2
@@ -800,9 +800,10 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk, psock =sk_psock_get (sk);if (!psock || !policy) { err =tls_push_record (sk, flags, record_type); -if (err && err != -EINPROGRESS ) { +if (err && sk->sk_err ==EBADMSG ) { *copied -=sk_msg_free (sk, msg);tls_free_open_rec (sk); + err = -sk->sk_err; }if (psock)sk_psock_put (sk, psock);
@@ -828,9 +829,10 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk,switch (psock->eval) {case __SK_PASS: err =tls_push_record (sk, flags, record_type); -if (err && err != -EINPROGRESS ) { +if (err && sk->sk_err ==EBADMSG ) { *copied -=sk_msg_free (sk, msg);tls_free_open_rec (sk); + err = -sk->sk_err; goto out_err; }break ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 245/606 net: sun: fix missing release regions in cas_init_one().
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
commit 5a730153984dd13f82ffae93d7170d76eba204e9 upstream.
In cas_init_one(), "pdev" is requested by "pci_request_regions", but it was not released after a call of the function “pci_write_config_byte” failed. Thus replace the jump target “err_write_cacheline” by "err_out_free_res".
--- drivers/net/ethernet/sun/cassini.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/sun/cassini.c +1 -2
@@ -4971,7 +4971,7 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) cas_cacheline_size)) {dev_err (&pdev->dev,"Could not set PCI cache " "line size\n" ); - goto err_write_cacheline; + goto err_out_free_res; } }#endif
@@ -5144,7 +5144,6 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_free_res:pci_release_regions (pdev); -err_write_cacheline:/* Try to restore it in case the error occurred after we * set it. */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 246/606 net/mlx4_core: fix a memory leak bug.
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
commit febfd9d3c7f74063e8e630b15413ca91b567f963 upstream.
In function mlx4_opreq_action(), pointer "mailbox" is not released, when mlx4_cmd_box() return and error, causing a memory leak bug. Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can free this pointer.
--- drivers/net/ethernet/mellanox/mlx4/fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/fw.c +1 -1
@@ -2734,7 +2734,7 @@ void mlx4_opreq_action(struct work_struct *work)if (err) {mlx4_err (dev,"Failed to retrieve required operation: %d\n" , err); -return ; + goto out; }MLX4_GET (modifier, outbox,GET_OP_REQ_MODIFIER_OFFSET );MLX4_GET (token, outbox,GET_OP_REQ_TOKEN_OFFSET );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 247/606 net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe()
In reply to Sasha LevinFrom: Tang Bin <[email protected]>
commit a7654211d0ffeaa8eb0545ea00f8445242cbce05 upstream.
In the function devm_platform_ioremap_resource(), if get resource failed, the return value is ERR_PTR() not NULL. Thus it must be replaced by IS_ERR(), or else it may result in crashes if a critical error path is encountered.
--- drivers/net/ethernet/sgi/ioc3-eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +4 -4
@@ -865,14 +865,14 @@ static int ioc3eth_probe(struct platform_device *pdev) ip =netdev_priv (dev); ip->dma_dev = pdev->dev.parent; ip->regs =devm_platform_ioremap_resource (pdev,0 ); -if (!ip->regs) { - err = -ENOMEM ; +if (IS_ERR (ip->regs)) { + err =PTR_ERR (ip->regs); goto out_free; } ip->ssram =devm_platform_ioremap_resource (pdev,1 ); -if (!ip->ssram) { - err = -ENOMEM ; +if (IS_ERR (ip->ssram)) { + err =PTR_ERR (ip->ssram); goto out_free; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 248/606 mlxsw: spectrum: Fix use-after-free of split/unsplit/type_set in case reload fails
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
commit 4340f42f207eacb81e7a6b6bb1e3b6afad9a2e26 upstream.
In case of reload fail, the mlxsw_sp->ports contains a pointer to a freed memory (either by reload_down() or reload_up() error path). Fix this by initializing the pointer to NULL and checking it before dereferencing in split/unsplit/type_set callpaths.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 14 ++++++++++++-- drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +12 -2
@@ -4043,6 +4043,7 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)mlxsw_sp_port_remove (mlxsw_sp, i);mlxsw_sp_cpu_port_remove (mlxsw_sp);kfree (mlxsw_sp->ports); + mlxsw_sp->ports =NULL ; }static int mlxsw_sp_ports_create (struct mlxsw_sp *mlxsw_sp)
@@ -4079,6 +4080,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)mlxsw_sp_cpu_port_remove (mlxsw_sp); err_cpu_port_create:kfree (mlxsw_sp->ports); + mlxsw_sp->ports =NULL ;return err; }
@@ -4200,6 +4202,14 @@ static int mlxsw_sp_local_ports_offset(struct mlxsw_core *mlxsw_core,return mlxsw_core_res_get (mlxsw_core, local_ports_in_x_res_id); } +static struct mlxsw_sp_port * +mlxsw_sp_port_get_by_local_port (struct mlxsw_sp *mlxsw_sp,u8 local_port) +{ +if (mlxsw_sp->ports && mlxsw_sp->ports[local_port]) +return mlxsw_sp->ports[local_port]; +return NULL ; +} +static int mlxsw_sp_port_split (struct mlxsw_core *mlxsw_core,u8 local_port,unsigned int count,struct netlink_ext_ack *extack)
@@ -4213,7 +4223,7 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,int i;int err; - mlxsw_sp_port = mlxsw_sp->ports[local_port]; + mlxsw_sp_port =mlxsw_sp_port_get_by_local_port (mlxsw_sp, local_port);if (!mlxsw_sp_port) {dev_err (mlxsw_sp->bus_info->dev,"Port number \"%d\" does not exist\n" , local_port);
@@ -4308,7 +4318,7 @@ static int mlxsw_sp_port_unsplit(struct mlxsw_core *mlxsw_core, u8 local_port,int offset;int i; - mlxsw_sp_port = mlxsw_sp->ports[local_port]; + mlxsw_sp_port =mlxsw_sp_port_get_by_local_port (mlxsw_sp, local_port);if (!mlxsw_sp_port) {dev_err (mlxsw_sp->bus_info->dev,"Port number \"%d\" does not exist\n" , local_port);
drivers/net/ethernet/mellanox/mlxsw/switchx2.c +8 -0
@@ -1259,6 +1259,7 @@ static void mlxsw_sx_ports_remove(struct mlxsw_sx *mlxsw_sx)if (mlxsw_sx_port_created (mlxsw_sx, i))mlxsw_sx_port_remove (mlxsw_sx, i);kfree (mlxsw_sx->ports); + mlxsw_sx->ports =NULL ; }static int mlxsw_sx_ports_create (struct mlxsw_sx *mlxsw_sx)
@@ -1293,6 +1294,7 @@ static int mlxsw_sx_ports_create(struct mlxsw_sx *mlxsw_sx)if (mlxsw_sx_port_created (mlxsw_sx, i))mlxsw_sx_port_remove (mlxsw_sx, i);kfree (mlxsw_sx->ports); + mlxsw_sx->ports =NULL ;return err; }
@@ -1376,6 +1378,12 @@ static int mlxsw_sx_port_type_set(struct mlxsw_core *mlxsw_core, u8 local_port,u8 module, width;int err; +if (!mlxsw_sx->ports || !mlxsw_sx->ports[local_port]) { +dev_err (mlxsw_sx->bus_info->dev,"Port number \"%d\" does not exist\n" , + local_port); +return -EINVAL ; + } +if (new_type ==DEVLINK_PORT_TYPE_AUTO )return -EOPNOTSUPP ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 249/606 net: mscc: ocelot: fix address ageing time (again)
In reply to Sasha LevinFrom: Vladimir Oltean <[email protected]>
commit bf655ba212dfd10d1c86afeee3f3372dbd731d46 upstream.
ocelot_set_ageing_time has 2 callers:
- felix_set_ageing_time: from drivers/net/dsa/ocelot/felix.c
- ocelot_port_attr_ageing_set: from drivers/net/ethernet/mscc/ocelot.c
The issue described in the fixed commit below actually happened for the felix_set_ageing_time code path only, since ocelot_port_attr_ageing_set was already dividing by 1000. So to make both paths symmetrical (and to fix addresses getting aged way too fast on Ocelot), stop dividing by 1000 at caller side altogether.
--- drivers/net/ethernet/mscc/ocelot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mscc/ocelot.c +1 -1
@@ -1460,7 +1460,7 @@ static void ocelot_port_attr_ageing_set(struct ocelot *ocelot, int port, unsigned long ageing_clock_t) {unsigned long ageing_jiffies =clock_t_to_jiffies (ageing_clock_t); -u32 ageing_time =jiffies_to_msecs (ageing_jiffies) /1000 ; +u32 ageing_time =jiffies_to_msecs (ageing_jiffies);ocelot_set_ageing_time (ocelot, ageing_time); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 250/606 arm64: dts: qcom: db820c: fix audio configuration
In reply to Sasha LevinFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 7710f80ecd9c74544a22557ab581cf603e713f51 ]
After patch f864edff110d ("ASoC: qdsp6: q6routing: remove default routing") and 9b60441692d9 ("ASoC: qdsp6: q6asm-dai: only enable dais from device tree") asm dais and routing needs to be properly specified at device tree level.
This patch fixes this.
--- arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 19 ++++++++++++++++++- arch/arm64/boot/dts/qcom/msm8996.dtsi | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi +18 -1
@@ -908,10 +908,27 @@ &sdhc2 { status = "okay"; }; +&q6asmdai { + dai@0 { + reg = <0>; + }; + + dai@1 { + reg = <1>; + }; + + dai@2 { + reg = <2>; + }; +}; + &sound { compatible = "qcom,apq8096-sndcard"; model = "DB820c"; - audio-routing = "RX_BIAS", "MCLK"; + audio-routing = "RX_BIAS", "MCLK", + "MM_DL1", "MultiMedia1 Playback", + "MM_DL2", "MultiMedia2 Playback", + "MultiMedia3 Capture", "MM_UL3"; mm1-dai-link { link-name = "MultiMedia1";
arch/arm64/boot/dts/qcom/msm8996.dtsi +2 -0
@@ -2053,6 +2053,8 @@ q6asm: q6asm { reg = <APR_SVC_ASM>; q6asmdai: dais { compatible = "qcom,q6asm-dais"; + #address-cells = <1>; + #size-cells = <0>; #sound-dai-cells = <1>; iommus = <&lpass_q6_smmu 1>; };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 251/606 ARM: dts: rockchip: fix phy nodename for rk3228-evb
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit 287e0d538fcec2f6e8eb1e565bf0749f3b90186d ]
A test with the command below gives for example this error:
arch/arm/boot/dts/rk3228-evb.dt.yaml: phy@0:
'#phy-cells' is a required property
The phy nodename is normally used by a phy-handle. This node is however compatible with "ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22" which is just been added to 'ethernet-phy.yaml'. So change nodename to 'ethernet-phy' for which '#phy-cells' is not a required property
make ARCH=arm dtbs_check DT_SCHEMA_FILES=~/.local/lib/python3.5/site-packages/dtschema/schemas/ phy/phy-provider.yaml
--- arch/arm/boot/dts/rk3228-evb.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/rk3228-evb.dts +1 -1
@@ -46,7 +46,7 @@ mdio { #address-cells = <1>; #size-cells = <0>; - phy: phy@0 { + phy: ethernet-phy@0 { compatible = "ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22"; reg = <0>; clocks = <&cru SCLK_MAC_PHY>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 252/606 ARM: dts: rockchip: fix phy nodename for rk3229-xms6
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit 621c8d0c233e260232278a4cfd3380caa3c1da29 ]
A test with the command below gives for example this error:
arch/arm/boot/dts/rk3229-xms6.dt.yaml: phy@0:
'#phy-cells' is a required property
The phy nodename is normally used by a phy-handle. This node is however compatible with "ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22" which is just been added to 'ethernet-phy.yaml'. So change nodename to 'ethernet-phy' for which '#phy-cells' is not a required property
make ARCH=arm dtbs_check DT_SCHEMA_FILES=~/.local/lib/python3.5/site-packages/dtschema/schemas/ phy/phy-provider.yaml
--- arch/arm/boot/dts/rk3229-xms6.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/rk3229-xms6.dts +1 -1
@@ -150,7 +150,7 @@ mdio { #address-cells = <1>; #size-cells = <0>; - phy: phy@0 { + phy: ethernet-phy@0 { compatible = "ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22"; reg = <0>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 253/606 arm64: dts: rockchip: fix status for &gmac2phy in rk3328-evb.dts
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit c617ed88502d0b05149e7f32f3b3fd8a0663f7e2 ]
The status was removed of the '&gmac2phy' node with the apply of a patch long time ago, so fix status for '&gmac2phy' in 'rk3328-evb.dts'.
--- arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3328-evb.dts +1 -1
@@ -86,7 +86,7 @@ &gmac2phy { assigned-clock-rate = <50000000>; assigned-clocks = <&cru SCLK_MAC2PHY>; assigned-clock-parents = <&cru SCLK_MAC2PHY_SRC>; - + status = "okay"; }; &i2c1 {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 254/606 arm64: dts: rockchip: swap interrupts interrupt-names rk3399 gpu node
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit c604fd810bda667bdc20b2c041917baa7803e0fb ]
Dts files with Rockchip rk3399 'gpu' nodes were manually verified. In order to automate this process arm,mali-midgard.txt has been converted to yaml. In the new setup dtbs_check with arm,mali-midgard.yaml expects interrupts and interrupt-names values in the same order. Fix this for rk3399.
make ARCH=arm64 dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/gpu/ arm,mali-midgard.yaml
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +4 -4
@@ -1890,10 +1890,10 @@ edp_in_vopl: endpoint@1 { gpu: gpu@ff9a0000 { compatible = "rockchip,rk3399-mali", "arm,mali-t860"; reg = <0x0 0xff9a0000 0x0 0x10000>; - interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH 0>, - <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH 0>; - interrupt-names = "gpu", "job", "mmu"; + interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "job", "mmu", "gpu"; clocks = <&cru ACLK_GPU>; #cooling-cells = <2>; power-domains = <&power RK3399_PD_GPU>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 255/606 ARM: dts: rockchip: swap clock-names of gpu nodes
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit b14f3898d2c25a9b47a61fb879d0b1f3af92c59b ]
Dts files with Rockchip 'gpu' nodes were manually verified. In order to automate this process arm,mali-utgard.txt has been converted to yaml. In the new setup dtbs_check with arm,mali-utgard.yaml expects clock-names values
in the same order, so fix that.
--- arch/arm/boot/dts/rk3036.dtsi | 2 +- arch/arm/boot/dts/rk322x.dtsi | 2 +- arch/arm/boot/dts/rk3xxx.dtsi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/rk3036.dtsi +1 -1
@@ -128,7 +128,7 @@ gpu: gpu@10090000 { assigned-clocks = <&cru SCLK_GPU>; assigned-clock-rates = <100000000>; clocks = <&cru SCLK_GPU>, <&cru SCLK_GPU>; - clock-names = "core", "bus"; + clock-names = "bus", "core"; resets = <&cru SRST_GPU>; status = "disabled"; };
arch/arm/boot/dts/rk322x.dtsi +1 -1
@@ -561,7 +561,7 @@ gpu: gpu@20000000 { "pp1", "ppmmu1"; clocks = <&cru ACLK_GPU>, <&cru ACLK_GPU>; - clock-names = "core", "bus"; + clock-names = "bus", "core"; resets = <&cru SRST_GPU_A>; status = "disabled"; };
arch/arm/boot/dts/rk3xxx.dtsi +1 -1
@@ -84,7 +84,7 @@ gpu: gpu@10090000 { compatible = "arm,mali-400"; reg = <0x10090000 0x10000>; clocks = <&cru ACLK_GPU>, <&cru ACLK_GPU>; - clock-names = "core", "bus"; + clock-names = "bus", "core"; assigned-clocks = <&cru ACLK_GPU>; assigned-clock-rates = <100000000>; resets = <&cru SRST_GPU>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 256/606 ARM: dts: rockchip: fix pinctrl sub nodename for spi in rk322x.dtsi
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit 855bdca1781c79eb661f89c8944c4a719ce720e8 ]
A test with the command below gives these errors:
arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-0:
'#address-cells' is a required property arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-1:
'#address-cells' is a required property arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-0:
'#address-cells' is a required property arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-1:
'#address-cells' is a required property
The $nodename pattern for spi nodes is "^spi(@.*|-[0-9a-f])*$". To prevent warnings rename 'spi-0' and 'spi-1' pinctrl sub nodenames to 'spi0' and 'spi1' in 'rk322x.dtsi'.
make ARCH=arm dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/spi-controller.yaml
--- arch/arm/boot/dts/rk322x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/rk322x.dtsi +2 -2
@@ -1033,7 +1033,7 @@ i2c3_xfer: i2c3-xfer { }; }; - spi-0 { + spi0 { spi0_clk: spi0-clk { rockchip,pins = <0 RK_PB1 2 &pcfg_pull_up>; };
@@ -1051,7 +1051,7 @@ spi0_cs1: spi0-cs1 { }; }; - spi-1 { + spi1 { spi1_clk: spi1-clk { rockchip,pins = <0 RK_PC7 2 &pcfg_pull_up>; };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 257/606 gpio: tegra: mask GPIO IRQs during IRQ shutdown
In reply to Sasha LevinFrom: Stephen Warren <[email protected]>
[ Upstream commit 0cf253eed5d2bdf7bb3152457b38f39b012955f7 ]
The driver currently leaves GPIO IRQs unmasked even when the GPIO IRQ client has released the GPIO IRQ. This allows the HW to raise IRQs, and SW to process them, after shutdown. Fix this by masking the IRQ when it's shut down. This is usually taken care of by the irqchip core, but since this driver has a custom irq_shutdown implementation, it must do this explicitly itself.
--- drivers/gpio/gpio-tegra.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-tegra.c +1 -0
@@ -368,6 +368,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d)struct tegra_gpio_info *tgi = bank->tgi;unsigned int gpio = d->hwirq; +tegra_gpio_irq_mask (d);gpiochip_unlock_as_irq (&tgi->gc, gpio); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 258/606 ALSA: usb-audio: add mapping for ASRock TRX40 Creator
In reply to Sasha LevinFrom: Andrew Oakley <[email protected]>
[ Upstream commit da7a8f1a8fc3e14c6dcc52b4098bddb8f20390be ]
This is another TRX40 based motherboard with ALC1220-VB USB-audio that requires a static mapping table.
This motherboard also has a PCI device which advertises no codecs. The PCI ID is 1022:1487 and PCI SSID is 1022:d102. As this is using the AMD vendor ID, don't blacklist for now in case other boards have a working audio device with the same ssid.
alsa-info.sh report for this board:
http://alsa-project.org/db/?f=0a742f89066527497b77ce16bca486daccf8a70c
--- sound/usb/mixer_maps.c | 5 +++++ sound/usb/quirks-table.h | 1 + 2 files changed, 6 insertions(+)
sound/usb/mixer_maps.c +5 -0
@@ -549,6 +549,11 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .map = trx40_mobo_map, .connector_map = trx40_mobo_connector_map, }, + {/* Asrock TRX40 Creator */ + .id = USB_ID(0x26ce, 0x0a01), + .map = trx40_mobo_map, + .connector_map = trx40_mobo_connector_map, + }, { 0 } /* terminator */ };
sound/usb/quirks-table.h +1 -0
@@ -3647,6 +3647,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),ALC1220_VB_DESKTOP (0x0414 ,0xa002 ),/* Gigabyte TRX40 Aorus Pro WiFi */ ALC1220_VB_DESKTOP (0x0db0 ,0x0d64 ),/* MSI TRX40 Creator */ ALC1220_VB_DESKTOP (0x0db0 ,0x543d ),/* MSI TRX40 */ +ALC1220_VB_DESKTOP (0x26ce ,0x0a01 ),/* Asrock TRX40 Creator */ #undef ALC1220_VB_DESKTOP #undef USB_DEVICE_VENDOR_SPEC
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 259/606 ARM: dts: omap4-droid4: Fix flakey wlan by disabling internal pull for gpio
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 30fa60c678eaa27b8f2a531920d77f7184658f73 ]
The wlan on droid4 is flakey on some devices, and experiments have shown this gets fixed if we disable the internal pull for wlan gpio interrupt line.
The symptoms are that the wlan connection is very slow and almost useless with lots of wlcore firmware reboot warnings in the dmesg.
In addition to configuring the wlan gpio pulls, let's also configure the rest of the wlan sd pins. We have not configured those eariler as we're booting using kexec.
--- .../boot/dts/motorola-mapphone-common.dtsi | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/arm/boot/dts/motorola-mapphone-common.dtsi +33 -0
@@ -367,6 +367,8 @@ &mmc2 { }; &mmc3 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc3_pins>; vmmc-supply = <&wl12xx_vmmc>; /* uart2_tx.sdmmc3_dat1 pad as wakeirq */ interrupts-extended = <&wakeupgen GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH
@@ -472,6 +474,37 @@ OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0) >; }; + /* + * Android uses PIN_OFF_INPUT_PULLDOWN | PIN_INPUT_PULLUP | MUX_MODE3 + * for gpio_100, but the internal pull makes wlan flakey on some + * devices. Off mode value should be tested if we have off mode working + * later on. + */ + mmc3_pins: pinmux_mmc3_pins { + pinctrl-single,pins = < + /* 0x4a10008e gpmc_wait2.gpio_100 d23 */ + OMAP4_IOPAD(0x08e, PIN_INPUT | MUX_MODE3) + + /* 0x4a100102 abe_mcbsp1_dx.sdmmc3_dat2 ab25 */ + OMAP4_IOPAD(0x102, PIN_INPUT_PULLUP | MUX_MODE1) + + /* 0x4a100104 abe_mcbsp1_fsx.sdmmc3_dat3 ac27 */ + OMAP4_IOPAD(0x104, PIN_INPUT_PULLUP | MUX_MODE1) + + /* 0x4a100118 uart2_cts.sdmmc3_clk ab26 */ + OMAP4_IOPAD(0x118, PIN_INPUT | MUX_MODE1) + + /* 0x4a10011a uart2_rts.sdmmc3_cmd ab27 */ + OMAP4_IOPAD(0x11a, PIN_INPUT_PULLUP | MUX_MODE1) + + /* 0x4a10011c uart2_rx.sdmmc3_dat0 aa25 */ + OMAP4_IOPAD(0x11c, PIN_INPUT_PULLUP | MUX_MODE1) + + /* 0x4a10011e uart2_tx.sdmmc3_dat1 aa26 */ + OMAP4_IOPAD(0x11e, PIN_INPUT_PULLUP | MUX_MODE1) + >; + }; + /* gpmc_ncs0.gpio_50 */ poweroff_gpio: pinmux_poweroff_pins { pinctrl-single,pins = <
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 260/606 ARM: dts: omap4-droid4: Fix occasional lost wakeirq for uart1
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 738b150ecefbffb6e55cfa8a3b66a844f777d8fb ]
Looks like using the UART CTS pin does not always trigger for a wake-up when the SoC is idle.
This is probably because the modem first uses gpio_149 to signal the SoC that data will be sent, and the CTS will only get used later when the data transfer is starting.
Let's fix the issue by configuring the gpio_149 pad as the wakeirq for UART. We have gpio_149 managed by the USB PHY for powering up the right USB mode, and after that, the gpio gets recycled as the modem wake-up pin. If needeed, the USB PHY can also later on be configured to use gpio_149 pad as the wakeirq as a shared irq.
Let's also configure the missing properties for uart-has-rtscts and current-speed for the modem port while at it. We already configure the hardware flow control pins with uart1_pins pinctrl setting.
--- arch/arm/boot/dts/motorola-mapphone-common.dtsi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/boot/dts/motorola-mapphone-common.dtsi +7 -3
@@ -723,14 +723,18 @@ &timer9 { }; /* - * As uart1 is wired to mdm6600 with rts and cts, we can use the cts pin for - * uart1 wakeirq. + * The uart1 port is wired to mdm6600 with rts and cts. The modem uses gpio_149 + * for wake-up events for both the USB PHY and the UART. We can use gpio_149 + * pad as the shared wakeirq for the UART rather than the RX or CTS pad as we + * have gpio_149 trigger before the UART transfer starts. */ &uart1 { pinctrl-names = "default"; pinctrl-0 = <&uart1_pins>; interrupts-extended = <&wakeupgen GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH - &omap4_pmx_core 0xfc>; + &omap4_pmx_core 0x110>; + uart-has-rtscts; + current-speed = <115200>; }; &uart3 {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 261/606 net: microchip: encx24j600: add missed kthread_stop
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit ff8ce319e9c25e920d994cc35236f0bb32dfc8f3 ]
This driver calls kthread_run() in probe, but forgets to call kthread_stop() in probe failure and remove.
Add the missed kthread_stop() to fix it.
--- drivers/net/ethernet/microchip/encx24j600.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/encx24j600.c +4 -1
@@ -1070,7 +1070,7 @@ static int encx24j600_spi_probe(struct spi_device *spi)if (unlikely (ret)) {netif_err (priv, probe, ndev,"Error %d initializing card encx24j600 card\n" , ret); - goto out_free; + goto out_stop; } eidled =encx24j600_read_reg (priv,EIDLED );
@@ -1088,6 +1088,8 @@ static int encx24j600_spi_probe(struct spi_device *spi) out_unregister:unregister_netdev (priv->ndev); +out_stop: +kthread_stop (priv->kworker_task); out_free:free_netdev (ndev);
@@ -1100,6 +1102,7 @@ static int encx24j600_spi_remove(struct spi_device *spi)struct encx24j600_priv *priv =dev_get_drvdata (&spi->dev);unregister_netdev (priv->ndev); +kthread_stop (priv->kworker_task);free_netdev (priv->ndev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 262/606 kselftests: dmabuf-heaps: Fix confused return value on expected error testing
In reply to Sasha LevinFrom: John Stultz <[email protected]>
[ Upstream commit 4bb9d46d47b105a774f9dca642f5271375bca4b2 ]
When I added the expected error testing, I forgot I need to set the return to zero when we successfully see an error.
Without this change we only end up testing a single heap before the test quits.
--- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1 -0
@@ -351,6 +351,7 @@ static int test_alloc_errors(char *heap_name) }printf ("Expected error checking passed\n" ); + ret =0 ; out:if (dmabuf_fd >=0 )close (dmabuf_fd);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 263/606 gfs2: move privileged user check to gfs2_quota_lock_check
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit 4ed0c30811cb4d30ef89850b787a53a84d5d2bcb ]
Before this patch, function gfs2_quota_lock checked if it was called from a privileged user, and if so, it bypassed the quota check:
superuser can operate outside the quotas.
That's the wrong place for the check because the lock/unlock functions are separate from the lock_check function, and you can do lock and unlock without actually checking the quotas.
This patch moves the check to gfs2_quota_lock_check.
--- fs/gfs2/quota.c | 3 +-- fs/gfs2/quota.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/quota.c +1 -2
@@ -1040,8 +1040,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)u32 x;int error =0 ; -if (capable (CAP_SYS_RESOURCE ) || - sdp->sd_args.ar_quota !=GFS2_QUOTA_ON ) +if (sdp->sd_args.ar_quota !=GFS2_QUOTA_ON )return 0 ; error =gfs2_quota_hold (ip, uid, gid);
fs/gfs2/quota.h +2 -1
@@ -44,7 +44,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,int ret; ap->allowed =UINT_MAX ;/* Assume we are permitted a whole lot */ -if (sdp->sd_args.ar_quota ==GFS2_QUOTA_OFF ) +if (capable (CAP_SYS_RESOURCE ) || + sdp->sd_args.ar_quota ==GFS2_QUOTA_OFF )return 0 ; ret =gfs2_quota_lock (ip,NO_UID_QUOTA_CHANGE ,NO_GID_QUOTA_CHANGE );if (ret)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 264/606 gfs2: Grab glock reference sooner in gfs2_add_revoke
In reply to Sasha LevinFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit f4e2f5e1a527ce58fc9f85145b03704779a3123e ]
This patch rearranges gfs2_add_revoke so that the extra glock reference is added earlier on in the function to avoid races in which the glock is freed before the new reference is taken.
--- fs/gfs2/log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/log.c +3 -3
@@ -603,13 +603,13 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)struct buffer_head *bh = bd->bd_bh;struct gfs2_glock *gl = bd->bd_gl; + sdp->sd_log_num_revoke++; +if (atomic_inc_return (&gl->gl_revokes) ==1 ) +gfs2_glock_hold (gl); bh->b_private =NULL ; bd->bd_blkno = bh->b_blocknr;gfs2_remove_from_ail (bd);/* drops ref on bh */ bd->bd_bh =NULL ; - sdp->sd_log_num_revoke++; -if (atomic_inc_return (&gl->gl_revokes) ==1 ) -gfs2_glock_hold (gl);set_bit (GLF_LFLUSH , &gl->gl_flags);list_add (&bd->bd_list, &sdp->sd_log_revokes); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 265/606 drm/amdgpu: drop unnecessary cancel_delayed_work_sync on PG ungate
In reply to Sasha LevinFrom: Evan Quan <[email protected]>
[ Upstream commit 1fe48ec08d9f2e26d893a6c05bd6c99a3490f9ef ]
As this is already properly handled in amdgpu_gfx_off_ctrl(). In fact, this unnecessary cancel_delayed_work_sync may leave a small time window for race condition and is dangerous.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 +----- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 12 +++--------- 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -5
@@ -4241,11 +4241,7 @@ static int gfx_v10_0_set_powergating_state(void *handle,switch (adev->asic_type) {case CHIP_NAVI10 :case CHIP_NAVI14 : -if (!enable) { -amdgpu_gfx_off_ctrl (adev, false); -cancel_delayed_work_sync (&adev->gfx.gfx_off_delay_work); - }else -amdgpu_gfx_off_ctrl (adev, true); +amdgpu_gfx_off_ctrl (adev, enable);break ;default :break ;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -9
@@ -4734,10 +4734,9 @@ static int gfx_v9_0_set_powergating_state(void *handle,switch (adev->asic_type) {case CHIP_RAVEN :case CHIP_RENOIR : -if (!enable) { +if (!enable)amdgpu_gfx_off_ctrl (adev, false); -cancel_delayed_work_sync (&adev->gfx.gfx_off_delay_work); - } +if (adev->pg_flags &AMD_PG_SUPPORT_RLC_SMU_HS ) {gfx_v9_0_enable_sck_slow_down_on_power_up (adev, true);gfx_v9_0_enable_sck_slow_down_on_power_down (adev, true);
@@ -4761,12 +4760,7 @@ static int gfx_v9_0_set_powergating_state(void *handle,amdgpu_gfx_off_ctrl (adev, true);break ;case CHIP_VEGA12 : -if (!enable) { -amdgpu_gfx_off_ctrl (adev, false); -cancel_delayed_work_sync (&adev->gfx.gfx_off_delay_work); - }else { -amdgpu_gfx_off_ctrl (adev, true); - } +amdgpu_gfx_off_ctrl (adev, enable);break ;default :break ;
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 266/606 drm/amd/powerplay: perform PG ungate prior to CG ungate
In reply to Sasha LevinFrom: Evan Quan <[email protected]>
[ Upstream commit f4fcfa4282c1a1bf51475ebb0ffda623eebf1191 ]
Since gfxoff should be disabled first before trying to access those GC registers.
--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 6 +++--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +3 -3
@@ -319,12 +319,12 @@ static void pp_dpm_en_umd_pstate(struct pp_hwmgr *hwmgr,if (*level & profile_mode_mask) { hwmgr->saved_dpm_level = hwmgr->dpm_level; hwmgr->en_umd_pstate = true; -amdgpu_device_ip_set_clockgating_state (hwmgr->adev, -AMD_IP_BLOCK_TYPE_GFX , -AMD_CG_STATE_UNGATE );amdgpu_device_ip_set_powergating_state (hwmgr->adev,AMD_IP_BLOCK_TYPE_GFX ,AMD_PG_STATE_UNGATE ); +amdgpu_device_ip_set_clockgating_state (hwmgr->adev, +AMD_IP_BLOCK_TYPE_GFX , +AMD_CG_STATE_UNGATE ); } }else {/* exit umd pstate, restore level, enable gfx cg*/
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +3 -3
@@ -1675,12 +1675,12 @@ static int smu_enable_umd_pstate(void *handle,if (*level & profile_mode_mask) { smu_dpm_ctx->saved_dpm_level = smu_dpm_ctx->dpm_level; smu_dpm_ctx->enable_umd_pstate = true; -amdgpu_device_ip_set_clockgating_state (smu->adev, -AMD_IP_BLOCK_TYPE_GFX , -AMD_CG_STATE_UNGATE );amdgpu_device_ip_set_powergating_state (smu->adev,AMD_IP_BLOCK_TYPE_GFX ,AMD_PG_STATE_UNGATE ); +amdgpu_device_ip_set_clockgating_state (smu->adev, +AMD_IP_BLOCK_TYPE_GFX , +AMD_CG_STATE_UNGATE ); } }else {/* exit umd pstate, restore level, enable gfx cg*/
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 267/606 drm/amdgpu: Use GEM obj reference for KFD BOs
In reply to Sasha LevinFrom: Felix Kuehling <[email protected]>
[ Upstream commit 39b3128d7ffd44e400e581e6f49e88cb42bef9a1 ]
Releasing the AMDGPU BO ref directly leads to problems when BOs were exported as DMA bufs. Releasing the GEM reference makes sure that the AMDGPU/TTM BO is not freed too early.
Also take a GEM reference when importing BOs from DMABufs to keep references to imported BOs balances properly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -2
@@ -1304,7 +1304,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( }/* Free the BO*/ -amdgpu_bo_unref (&mem->bo); +drm_gem_object_put_unlocked (&mem->bo->tbo.base);mutex_destroy (&mem->lock);kfree (mem);
@@ -1647,7 +1647,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, ALLOC_MEM_FLAGS_VRAM : ALLOC_MEM_FLAGS_GTT) |ALLOC_MEM_FLAGS_WRITABLE |ALLOC_MEM_FLAGS_EXECUTABLE ; - (*mem)->bo =amdgpu_bo_ref (bo); +drm_gem_object_get (&bo->tbo.base); + (*mem)->bo = bo; (*mem)->va = va; (*mem)->domain = (bo->preferred_domains &AMDGPU_GEM_DOMAIN_VRAM ) ?AMDGPU_GEM_DOMAIN_VRAM :AMDGPU_GEM_DOMAIN_GTT ;
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 268/606 cachefiles: Fix race between read_waiter and read_copier involving op->to_do
In reply to Sasha LevinFrom: Lei Xue <[email protected]>
[ Upstream commit 7bb0c5338436dae953622470d52689265867f032 ]
There is a potential race in fscache operation enqueuing for reading and copying multiple pages from cachefiles to netfs. The problem can be seen easily on a heavy loaded system (for example many processes reading files continually on an NFS share covered by fscache triggered this problem within a few minutes).
The race is due to cachefiles_read_waiter() adding the op to the monitor to_do list and then then drop the object->work_lock spinlock before completing fscache_enqueue_operation(). Once the lock is dropped, cachefiles_read_copier() grabs the op, completes processing it, and makes it through fscache_retrieval_complete() which sets the op->state to the final state of FSCACHE_OP_ST_COMPLETE(4). When cachefiles_read_waiter() finally gets through the remainder of fscache_enqueue_operation() it sees the invalid state, and hits the ASSERTCMP and the following oops is seen:
[ 2259.612361] FS-Cache: [ 2259.614785] FS-Cache: Assertion failed [ 2259.618639] FS-Cache: 4 == 5 is false [ 2259.622456] ------------[ cut here ]------------ [ 2259.627190] kernel BUG at fs/fscache/operation.c:70! ... [ 2259.791675] RIP: 0010:[<ffffffffc061b4cf>] [<ffffffffc061b4cf>] fscache_enqueue_operation+0xff/0x170 [fscache] [ 2259.802059] RSP: 0000:ffffa0263d543be0 EFLAGS: 00010046 [ 2259.807521] RAX: 0000000000000019 RBX: ffffa01a4d390480 RCX: 0000000000000006 [ 2259.814847] RDX: 0000000000000000 RSI: 0000000000000046 RDI: ffffa0263d553890 [ 2259.822176] RBP: ffffa0263d543be8 R08: 0000000000000000 R09: ffffa0263c2d8708 [ 2259.829502] R10: 0000000000001e7f R11: 0000000000000000 R12: ffffa01a4d390480 [ 2259.844483] R13: ffff9fa9546c5920 R14: ffffa0263d543c80 R15: ffffa0293ff9bf10 [ 2259.859554] FS: 00007f4b6efbd700(0000) GS:ffffa0263d540000(0000) knlGS:0000000000000000 [ 2259.875571] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2259.889117] CR2: 00007f49e1624ff0 CR3: 0000012b38b38000 CR4: 00000000007607e0 [ 2259.904015] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 2259.918764] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 2259.933449] PKRU: 55555554 [ 2259.943654] Call Trace: [ 2259.953592] <IRQ> [ 2259.955577] [<ffffffffc03a7c12>] cachefiles_read_waiter+0x92/0xf0 [cachefiles] [ 2259.978039] [<ffffffffa34d3942>] __wake_up_common+0x82/0x120 [ 2259.991392] [<ffffffffa34d3a63>] __wake_up_common_lock+0x83/0xc0 [ 2260.004930] [<ffffffffa34d3510>] ? task_rq_unlock+0x20/0x20 [ 2260.017863] [<ffffffffa34d3ab3>] __wake_up+0x13/0x20 [ 2260.030230] [<ffffffffa34c72a0>] __wake_up_bit+0x50/0x70 [ 2260.042535] [<ffffffffa35bdcdb>] unlock_page+0x2b/0x30 [ 2260.054495] [<ffffffffa35bdd09>] page_endio+0x29/0x90 [ 2260.066184] [<ffffffffa368fc81>] mpage_end_io+0x51/0x80
CPU1cachefiles_read_waiter()
20 static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
21 int sync, void *_key)
22 {
...
61 spin_lock(&object->work_lock); 62 list_add_tail(&monitor->op_link, &op->to_do); 63 spin_unlock(&object->work_lock);
<begin race window>
64
65 fscache_enqueue_retrieval(op);
182 static inline void fscache_enqueue_retrieval(struct fscache_retrieval *op) 183 {
184 fscache_enqueue_operation(&op->op);
185 }
58 void fscache_enqueue_operation(struct fscache_operation *op) 59 {
60 struct fscache_cookie *cookie = op->object->cookie;
61
62 _enter("{OBJ%x OP%x,%u}",
63 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
64
65 ASSERT(list_empty(&op->pend_link)); 66 ASSERT(op->processor != NULL); 67 ASSERT(fscache_object_is_available(op->object)); 68 ASSERTCMP(atomic_read(&op->usage), >, 0);
<end race window>
CPU2cachefiles_read_copier()
168 while (!list_empty(&op->to_do)) {
...
202 fscache_end_io(op, monitor->netfs_page, error); 203 put_page(monitor->netfs_page); 204 fscache_retrieval_complete(op, 1);
CPU1
58 void fscache_enqueue_operation(struct fscache_operation *op) 59 {
...
69 ASSERTIFCMP(op->state != FSCACHE_OP_ST_IN_PROGRESS,
70 op->state, ==, FSCACHE_OP_ST_CANCELLED);
--- fs/cachefiles/rdwr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cachefiles/rdwr.c +1 -1
@@ -60,9 +60,9 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode, object = container_of(op->op.object, struct cachefiles_object, fscache);spin_lock (&object->work_lock);list_add_tail (&monitor->op_link, &op->to_do); +fscache_enqueue_retrieval (op);spin_unlock (&object->work_lock); -fscache_enqueue_retrieval (op);fscache_put_retrieval (op);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 269/606 usb: dwc3: pci: Enable extcon driver for Intel Merrifield
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 066c09593454e89bc605ffdff1c9810061f9b1e1 ]
Intel Merrifield provides a DR support via PMIC which has its own extcon driver.
Add a property string to link to that driver.
--- drivers/usb/dwc3/dwc3-pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/dwc3/dwc3-pci.c +1 -0
@@ -114,6 +114,7 @@ static const struct property_entry dwc3_pci_intel_properties[] = {static const struct property_entry dwc3_pci_mrfld_properties[] = {PROPERTY_ENTRY_STRING ("dr_mode" ,"otg" ), +PROPERTY_ENTRY_STRING ("linux,extcon-name" ,"mrfld_bcove_pwrsrc" ),PROPERTY_ENTRY_BOOL ("linux,sysdev_is_parent" ), {} };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 270/606 usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit f058764d19000d98aef72010468db1f69faf9fa0 ]
A call to 'regulator_get()' is hidden in 'twl6030_usb_ldo_init()'. A corresponding put must be performed in the error handling path, as already done in the remove function.
While at it, also move a 'free_irq()' call in the error handling path in order to be consistent.
--- drivers/usb/phy/phy-twl6030-usb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/phy/phy-twl6030-usb.c +9 -3
@@ -377,7 +377,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)if (status <0 ) {dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , twl->irq1, status); -return status; + goto err_put_regulator; } status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
@@ -386,8 +386,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)if (status <0 ) {dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , twl->irq2, status); -free_irq (twl->irq1, twl); -return status; + goto err_free_irq1; } twl->asleep =0 ;
@@ -396,6 +395,13 @@ static int twl6030_usb_probe(struct platform_device *pdev)dev_info (&pdev->dev,"Initialized TWL6030 USB module\n" );return 0 ; + +err_free_irq1: +free_irq (twl->irq1, twl); +err_put_regulator: +regulator_put (twl->usb3v3); + +return status; }static int twl6030_usb_remove (struct platform_device *pdev)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 271/606 usb: gadget: legacy: fix redundant initialization warnings
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit d13cce757954fa663c69845611957396843ed87a ]
Fix the following cppcheck warnings:
drivers/usb/gadget/legacy/inode.c:1364:8: style: Redundant initialization for 'value'. The initialized value is overwritten$
value = -EOPNOTSUPP;
^
drivers/usb/gadget/legacy/inode.c:1331:15: note: value is initialized
int value = -EOPNOTSUPP;
^
drivers/usb/gadget/legacy/inode.c:1364:8: note: value is overwritten
value = -EOPNOTSUPP;
^
drivers/usb/gadget/legacy/inode.c:1817:8: style: Redundant initialization for 'value'. The initialized value is overwritten$
value = -EINVAL;
^
drivers/usb/gadget/legacy/inode.c:1787:18: note: value is initialized
ssize_t value = len, length = len;
^
drivers/usb/gadget/legacy/inode.c:1817:8: note: value is overwritten
value = -EINVAL;
^--- drivers/usb/gadget/legacy/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/legacy/inode.c +1 -2
@@ -1361,7 +1361,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) req->buf = dev->rbuf; req->context =NULL ; - value = -EOPNOTSUPP ;switch (ctrl->bRequest) {case USB_REQ_GET_DESCRIPTOR :
@@ -1784,7 +1783,7 @@ static ssize_t dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) { struct dev_data *dev = fd->private_data; -ssize_t value = len, length = len; +ssize_t value, length = len;unsigned total;u32 tag;char *kbuf;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 272/606 net: freescale: select CONFIG_FIXED_PHY where needed
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 99352c79af3e5f2e4724abf37fa5a2a3299b1c81 ]
I ran into a randconfig build failure with CONFIG_FIXED_PHY=m and CONFIG_GIANFAR=y:
x86_64-linux-ld: drivers/net/ethernet/freescale/gianfar.o:(.rodata+0x418): undefined reference to `fixed_phy_change_carrier'
It seems the same thing can happen with dpaa and ucc_geth, so change all three to do an explicit 'select FIXED_PHY'.
The fixed-phy driver actually has an alternative stub function that theoretically allows building network drivers when fixed-phy is disabled, but I don't see how that would help here, as the drivers presumably would not work then.
--- drivers/net/ethernet/freescale/Kconfig | 2 ++ drivers/net/ethernet/freescale/dpaa/Kconfig | 1 + 2 files changed, 3 insertions(+)
drivers/net/ethernet/freescale/Kconfig +2 -0
@@ -77,6 +77,7 @@ config UCC_GETH depends on QUICC_ENGINE && PPC32 select FSL_PQ_MDIO select PHYLIB + select FIXED_PHY ---help--- This driver supports the Gigabit Ethernet mode of the QUICC Engine, which is available on some Freescale SOCs.
@@ -90,6 +91,7 @@ config GIANFAR depends on HAS_DMA select FSL_PQ_MDIO select PHYLIB + select FIXED_PHY select CRC32 ---help--- This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
drivers/net/ethernet/freescale/dpaa/Kconfig +1 -0
@@ -3,6 +3,7 @@ menuconfig FSL_DPAA_ETH tristate "DPAA Ethernet" depends on FSL_DPAA && FSL_FMAN select PHYLIB + select FIXED_PHY select FSL_FMAN_MAC ---help--- Data Path Acceleration Architecture Ethernet driver,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 273/606 drm/amd/amdgpu: Update update_config() logic
In reply to Sasha LevinFrom: "Leo (Hanghong) Ma" <[email protected]>
[ Upstream commit 650e723cecf2738dee828564396f3239829aba83 ]
[Why]
For MST case: when update_config is called to disable a stream, this clears the settings for all the streams on that link. We should only clear the settings for the stream that was disabled.
[How]
Clear the settings after the call to remove display is called.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c +5 -5
@@ -316,15 +316,15 @@ static void update_config(void *handle, struct cp_psp_stream_config *config)struct mod_hdcp_display *display = &hdcp_work[link_index].display;struct mod_hdcp_link *link = &hdcp_work[link_index].link; -memset (display,0 ,sizeof (*display)); -memset (link,0 ,sizeof (*link)); - - display->index = aconnector->base.index; -if (config->dpms_off) {hdcp_remove_display (hdcp_work, link_index, aconnector);return ; } + +memset (display,0 ,sizeof (*display)); +memset (link,0 ,sizeof (*link)); + + display->index = aconnector->base.index; display->state =MOD_HDCP_DISPLAY_ACTIVE ;if (aconnector->dc_sink !=NULL )
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 274/606 IB/i40iw: Remove bogus call to netdev_master_upper_dev_get()
In reply to Sasha LevinFrom: "Denis V. Lunev" <[email protected]>
[ Upstream commit 856ec7f64688387b100b7083cdf480ce3ac41227 ]
Local variable netdev is not used in these calls.
It should be noted, that this change is required to work in bonded mode. Otherwise we would get the following assert:
"RTNL: assertion failed at net/core/dev.c (5665)"
With the calltrace as follows:
dump_stack+0x19/0x1b netdev_master_upper_dev_get+0x61/0x70 i40iw_addr_resolve_neigh+0x1e8/0x220 i40iw_make_cm_node+0x296/0x700 ? i40iw_find_listener.isra.10+0xcc/0x110 i40iw_receive_ilq+0x3d4/0x810 i40iw_puda_poll_completion+0x341/0x420 i40iw_process_ceq+0xa5/0x280 i40iw_ceq_dpc+0x1e/0x40 tasklet_action+0x83/0x140 __do_softirq+0x125/0x2bb call_softirq+0x1c/0x30 do_softirq+0x65/0xa0 irq_exit+0x105/0x110 do_IRQ+0x56/0xf0 common_interrupt+0x16a/0x16a ? cpuidle_enter_state+0x57/0xd0 cpuidle_idle_call+0xde/0x230 arch_cpu_idle+0xe/0xc0 cpu_startup_entry+0x14a/0x1e0 start_secondary+0x1f7/0x270 start_cpu+0x5/0x14
--- drivers/infiniband/hw/i40iw/i40iw_cm.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_cm.c +0 -8
@@ -1987,7 +1987,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,struct rtable *rt;struct neighbour *neigh;int rc = arpindex; -struct net_device *netdev = iwdev->netdev;__be32 dst_ipaddr =htonl (dst_ip);__be32 src_ipaddr =htonl (src_ip);
@@ -1997,9 +1996,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,return rc; } -if (netif_is_bond_slave (netdev)) - netdev =netdev_master_upper_dev_get (netdev); - neigh =dst_neigh_lookup (&rt->dst, &dst_ipaddr);rcu_read_lock ();
@@ -2065,7 +2061,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev, {struct neighbour *neigh;int rc = arpindex; -struct net_device *netdev = iwdev->netdev;struct dst_entry *dst;struct sockaddr_in6 dst_addr;struct sockaddr_in6 src_addr;
@@ -2086,9 +2081,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev,return rc; } -if (netif_is_bond_slave (netdev)) - netdev =netdev_master_upper_dev_get (netdev); - neigh =dst_neigh_lookup (dst, dst_addr.sin6_addr.in6_u.u6_addr32);rcu_read_lock ();
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 275/606 riscv: Fix unmet direct dependencies built based on SOC_VIRT
In reply to Sasha LevinFrom: Kefeng Wang <[email protected]>
[ Upstream commit ab7fbad0c7d7a4f9b320a059a171a92a34b6d409 ]
Fix unmet direct dependencies Warning and fix Kconfig indent.
WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON
Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y] Selected by [y]:
- SOC_VIRT [=y]
WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON_POWEROFF
Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y] Selected by [y]:
- SOC_VIRT [=y]
WARNING: unmet direct dependencies detected for RTC_DRV_GOLDFISH
Depends on [n]: RTC_CLASS [=n] && OF [=y] && HAS_IOMEM [=y] && (GOLDFISH [=y] || COMPILE_TEST [=n]) Selected by [y]:
- SOC_VIRT [=y]
--- arch/riscv/Kconfig.socs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
arch/riscv/Kconfig.socs +9 -8
@@ -11,13 +11,14 @@ config SOC_SIFIVE This enables support for SiFive SoC platform hardware. config SOC_VIRT - bool "QEMU Virt Machine" - select POWER_RESET_SYSCON - select POWER_RESET_SYSCON_POWEROFF - select GOLDFISH - select RTC_DRV_GOLDFISH - select SIFIVE_PLIC - help - This enables support for QEMU Virt Machine. + bool "QEMU Virt Machine" + select POWER_RESET + select POWER_RESET_SYSCON + select POWER_RESET_SYSCON_POWEROFF + select GOLDFISH + select RTC_DRV_GOLDFISH if RTC_CLASS + select SIFIVE_PLIC + help + This enables support for QEMU Virt Machine. endmenu
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 276/606 riscv: stacktrace: Fix undefined reference to `walk_stackframe'
In reply to Sasha LevinFrom: Kefeng Wang <[email protected]>
[ Upstream commit 0502bee37cdef755d63eee60236562e5605e2480 ]
Drop static declaration to fix following build error if FRAME_POINTER disabled,
riscv64-linux-ld: arch/riscv/kernel/perf_callchain.o: in function `.L0':
perf_callchain.c:(.text+0x2b8): undefined reference to `walk_stackframe'
--- arch/riscv/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/stacktrace.c +1 -1
@@ -63,7 +63,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,#else /* !CONFIG_FRAME_POINTER */ -static void notrace walk_stackframe(struct task_struct *task, +void notrace walk_stackframe(struct task_struct *task,struct pt_regs *regs,bool (*fn)(unsigned long ,void *),void *arg) {unsigned long sp, pc;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 277/606 riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if NOMMU
In reply to Sasha LevinFrom: Kefeng Wang <[email protected]>
[ Upstream commit fa8174aa225fe3d53b37552e5066e6f0301dbabd ]
Some drivers use PAGE_SHARED, pgprot_writecombine()/pgprot_device(), add the defination to fix build error if NOMMU.
--- arch/riscv/include/asm/mmio.h | 2 ++ arch/riscv/include/asm/pgtable.h | 1 + 2 files changed, 3 insertions(+)
arch/riscv/include/asm/mmio.h +2 -0
@@ -16,6 +16,8 @@#ifndef CONFIG_MMU #define pgprot_noncached (x) (x) +#define pgprot_writecombine (x) (x) +#define pgprot_device (x) (x)#endif /* CONFIG_MMU */ /* Generic IO read/write. These perform native-endian accesses. */
arch/riscv/include/asm/pgtable.h +1 -0
@@ -460,6 +460,7 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,#else /* CONFIG_MMU */ +#define PAGE_SHARED __pgprot(0)#define PAGE_KERNEL __pgprot(0)#define swapper_pg_dir NULL#define VMALLOC_START 0
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 278/606 clk: ti: am33xx: fix RTC clock parent
In reply to Sasha LevinFrom: Tero Kristo <[email protected]>
[ Upstream commit dc6dbd51009fc412729c307161f442c0a08618f4 ]
Right now, trying to use RTC purely with the ti-sysc / clkctrl framework fails to enable the RTC module properly. Based on experimentation, this appears to be because RTC is sourced from the clkdiv32k optional clock. TRM is not very clear on this topic, but fix the RTC to use the proper source clock nevertheless.
--- drivers/clk/ti/clk-33xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/ti/clk-33xx.c +1 -1
@@ -212,7 +212,7 @@ static const struct omap_clkctrl_reg_data am3_mpu_clkctrl_regs[] __initconst = { };static const struct omap_clkctrl_reg_data am3_l4_rtc_clkctrl_regs[]__initconst = { - {AM3_L4_RTC_RTC_CLKCTRL ,NULL ,CLKF_SW_SUP ,"clk_32768_ck" }, + {AM3_L4_RTC_RTC_CLKCTRL ,NULL ,CLKF_SW_SUP ,"clk-24mhz-clkctrl:0000:0" }, {0 }, };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 279/606 csky: Fixup msa highest 3 bits mask
In reply to Sasha LevinFrom: Liu Yibin <[email protected]>
[ Upstream commit 165f2d2858013253042809df082b8df7e34e86d7 ]
Just as comment mentioned, the msa format:
cr<30/31, 15> MSA register format:
31 - 29 | 28 - 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
BA Reserved SH WA B SO SEC C D V
So we should shift 29 bits not 28 bits for mask
--- arch/csky/abiv1/inc/abi/entry.h | 4 ++-- arch/csky/abiv2/inc/abi/entry.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/csky/abiv1/inc/abi/entry.h +2 -2
@@ -167,8 +167,8 @@* BA Reserved C D V */ cprcr r6, cpcr30 - lsri r6, 28 - lsli r6, 28 + lsri r6, 29 + lsli r6, 29 addi r6, 0xe cpwcr r6, cpcr30
arch/csky/abiv2/inc/abi/entry.h +2 -2
@@ -225,8 +225,8 @@*/ mfcr r6, cr<30, 15> /* Get MSA0 */ 2: - lsri r6, 28 - lsli r6, 28 + lsri r6, 29 + lsli r6, 29 addi r6, 0x1ce mtcr r6, cr<30, 15> /* Set MSA0 */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 280/606 csky: Fixup perf callchain unwind
In reply to Sasha LevinFrom: Mao Han <[email protected]>
[ Upstream commit 229a0ddee1108a3f82a873e6cbbe35c92c540444 ]
[ 5221.974084] Unable to handle kernel paging request at virtual address 0xfffff000, pc: 0x8002c18e [ 5221.985929] Oops: 00000000 [ 5221.989488] [ 5221.989488] CURRENT PROCESS: [ 5221.989488] [ 5221.992877] COMM=callchain_test PID=11962 [ 5221.995213] TEXT=00008000-000087e0 DATA=00009f1c-0000a018 BSS=0000a018-0000b000 [ 5221.999037] USER-STACK=7fc18e20 KERNEL-STACK=be204680 [ 5221.999037] [ 5222.003292] PC: 0x8002c18e (perf_callchain_kernel+0x3e/0xd4) [ 5222.007957] LR: 0x8002c198 (perf_callchain_kernel+0x48/0xd4) [ 5222.074873] Call Trace: [ 5222.074873] [<800a248e>] get_perf_callchain+0x20a/0x29c [ 5222.074873] [<8009d964>] perf_callchain+0x64/0x80 [ 5222.074873] [<8009dc1c>] perf_prepare_sample+0x29c/0x4b8 [ 5222.074873] [<8009de6e>] perf_event_output_forward+0x36/0x98 [ 5222.074873] [<800497e0>] search_exception_tables+0x20/0x44 [ 5222.074873] [<8002cbb6>] do_page_fault+0x92/0x378 [ 5222.074873] [<80098608>] __perf_event_overflow+0x54/0xdc [ 5222.074873] [<80098778>] perf_swevent_hrtimer+0xe8/0x164 [ 5222.074873] [<8002ddd0>] update_mmu_cache+0x0/0xd8 [ 5222.074873] [<8002c014>] user_backtrace+0x58/0xc4 [ 5222.074873] [<8002c0b4>] perf_callchain_user+0x34/0xd0 [ 5222.074873] [<800a2442>] get_perf_callchain+0x1be/0x29c [ 5222.074873] [<8009d964>] perf_callchain+0x64/0x80 [ 5222.074873] [<8009d834>] perf_output_sample+0x78c/0x858 [ 5222.074873] [<8009dc1c>] perf_prepare_sample+0x29c/0x4b8 [ 5222.074873] [<8009de94>] perf_event_output_forward+0x5c/0x98 [ 5222.097846] [ 5222.097846] [<800a0300>] perf_event_exit_task+0x58/0x43c [ 5222.097846] [<8006c874>] hrtimer_interrupt+0x104/0x2ec [ 5222.097846] [<800a0300>] perf_event_exit_task+0x58/0x43c [ 5222.097846] [<80437bb6>] dw_apb_clockevent_irq+0x2a/0x4c [ 5222.097846] [<8006c770>] hrtimer_interrupt+0x0/0x2ec [ 5222.097846] [<8005f2e4>] __handle_irq_event_percpu+0xac/0x19c [ 5222.097846] [<80437bb6>] dw_apb_clockevent_irq+0x2a/0x4c [ 5222.097846] [<8005f408>] handle_irq_event_percpu+0x34/0x88 [ 5222.097846] [<8005f480>] handle_irq_event+0x24/0x64 [ 5222.097846] [<8006218c>] handle_level_irq+0x68/0xdc [ 5222.097846] [<8005ec76>] __handle_domain_irq+0x56/0xa8 [ 5222.097846] [<80450e90>] ck_irq_handler+0xac/0xe4 [ 5222.097846] [<80029012>] csky_do_IRQ+0x12/0x24 [ 5222.097846] [<8002a3a0>] csky_irq+0x70/0x80 [ 5222.097846] [<800ca612>] alloc_set_pte+0xd2/0x238 [ 5222.097846] [<8002ddd0>] update_mmu_cache+0x0/0xd8 [ 5222.097846] [<800a0340>] perf_event_exit_task+0x98/0x43c
The original fp check doesn't base on the real kernal stack region. Invalid fp address may cause kernel panic.
--- arch/csky/kernel/perf_callchain.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/csky/kernel/perf_callchain.c +7 -2
@@ -12,12 +12,17 @@ struct stackframe {static int unwind_frame_kernel (struct stackframe *frame) { -if (kstack_end ((void *)frame->fp)) +unsigned long low = (unsigned long )task_stack_page (current); +unsigned long high = low +THREAD_SIZE ; + +if (unlikely (frame->fp < low || frame->fp > high))return -EPERM ; -if (frame->fp &0x3 || frame->fp <TASK_SIZE ) + +if (kstack_end ((void *)frame->fp) || frame->fp &0x3 )return -EPERM ; *frame = *(struct stackframe *)frame->fp; +if (__kernel_text_address (frame->lr)) {int graph =0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 281/606 csky: Fixup remove duplicate irq_disable
In reply to Sasha LevinFrom: Liu Yibin <[email protected]>
[ Upstream commit 6633a5aa8eb6bda70eb3a9837efd28a67ccc6e0a ]
Interrupt has been disabled in __schedule() with local_irq_disable() and enabled in finish_task_switch->finish_lock_switch() with local_irq_enabled(), So needn't to disable irq here.
--- arch/csky/kernel/entry.S | 2 -- 1 file changed, 2 deletions(-)
arch/csky/kernel/entry.S +0 -2
@@ -318,8 +318,6 @@ ENTRY(__switch_to) mfcr a2, psr /* Save PSR value */ stw a2, (a3, THREAD_SR) /* Save PSR in task struct */ - bclri a2, 6 /* Disable interrupts */ - mtcr a2, psr SAVE_SWITCH_STACK
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 282/606 drm/meson: pm resume add return errno branch
In reply to Sasha LevinFrom: Bernard Zhao <[email protected]>
[ Upstream commit c54a8f1f329197d83d941ad84c4aa38bf282cbbd ]
pm_resump api did not handle drm_mode_config_helper_resume error. This change add handle to return drm_mode_config_helper_resume`s error number. This code logic is aligned with api pm_suspend. After this change, the code maybe a bit readable.
--- drivers/gpu/drm/meson/meson_drv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +1 -3
@@ -412,9 +412,7 @@ static int __maybe_unused meson_drv_pm_resume(struct device *dev)if (priv->afbcd.ops) priv->afbcd.ops->init (priv); -drm_mode_config_helper_resume (priv->drm); - -return 0 ; +return drm_mode_config_helper_resume (priv->drm); }static int compare_of (struct device *dev,void *data)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 283/606 hwmon: (nct7904) Fix incorrect range of temperature limit registers
In reply to Sasha LevinFrom: Amy Shih <[email protected]>
[ Upstream commit 7b2fd270af27edaf02acb41a7babe805a9441914 ]
The format of temperature limitation registers are 8-bit 2's complement and the range is -128~127.
Converts the reading value to signed char to fix the incorrect range of temperature limitation registers.
--- drivers/hwmon/nct7904.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/nct7904.c +3 -1
@@ -356,6 +356,7 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,struct nct7904_data *data =dev_get_drvdata (dev);int ret, temp;unsigned int reg1, reg2, reg3; +s8 temps;switch (attr) {case hwmon_temp_input:
@@ -461,7 +462,8 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,if (ret <0 )return ret; - *val = ret *1000 ; + temps = ret; + *val = temps *1000 ;return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 284/606 riscv: pgtable: Fix __kernel_map_pages build error if NOMMU
In reply to Sasha LevinFrom: Kefeng Wang <[email protected]>
[ Upstream commit 9a6630aef93394ac54494c7e273e9bc026509375 ]
riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
page_alloc.c:(.text+0xd34): undefined reference to `__kernel_map_pages'
riscv64-none-linux-gnu-ld: page_alloc.c:(.text+0x104a): undefined reference to `__kernel_map_pages'
riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function `__pageblock_pfn_to_page':
page_alloc.c:(.text+0x145e): undefined reference to `__kernel_map_pages'
--- arch/riscv/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/include/asm/pgtable.h +2 -0
@@ -467,6 +467,8 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,#define TASK_SIZE 0xffffffffUL +static inline void __kernel_map_pages (struct page *page,int numpages,int enable) {} +#endif /* !CONFIG_MMU */ #define kern_addr_valid (addr) (1)/* FIXME */
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 285/606 cifs: Fix null pointer check in cifs_read
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit 9bd21d4b1a767c3abebec203342f3820dcb84662 ]
Coverity scan noted a redundant null check
Coverity-id: 728517
--- fs/cifs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/file.c +1 -1
@@ -4060,7 +4060,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)* than it negotiated since it will refuse the read * then. */ -if ((tcon->ses) && !(tcon->ses->capabilities & +if (!(tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)) { current_read_size =min_t (uint, current_read_size, CIFSMaxBufSize);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 286/606 csky: Fixup raw_copy_from_user()
In reply to Sasha LevinFrom: Al Viro <[email protected]>
[ Upstream commit 51bb38cb78363fdad1f89e87357b7bc73e39ba88 ]
If raw_copy_from_user(to, from, N) returns K, callers expect the first N - K bytes starting at to to have been replaced with the contents of corresponding area starting at from and the last K bytes of destination *left* *unmodified*.
What arch/sky/lib/usercopy.c is doing is broken - it can lead to e.g. data corruption on write(2).
raw_copy_to_user() is inaccurate about return value, which is a bug, but consequences are less drastic than for raw_copy_from_user(). And just what are those access_ok() doing in there? I mean, look into linux/uaccess.h; that's where we do that check (as well as zero tail on failure in the callers that need zeroing).
AFAICS, all of that shouldn't be hard to fix; something like a patch below might make a useful starting point.
I would suggest moving these macros into usercopy.c (they are never used anywhere else) and possibly expanding them there; if you leave them alive, please at least rename __copy_user_zeroing(). Again, it must not zero anything on failed read.
Said that, I'm not sure we won't be better off simply turning usercopy.c into usercopy.S - all that is left there is a couple of functions, each consisting only of inline asm.
Guo Ren reply:
Yes, raw_copy_from_user is wrong, it's no need zeroing code.
unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)
{
unsigned long res = n;
might_fault();
if (likely(access_ok(from, n))) {
kasan_check_write(to, n);
res = raw_copy_from_user(to, from, n);
}
if (unlikely(res))
memset(to + (n - res), 0, res);
return res;
}EXPORT_SYMBOL(_copy_from_user);
You are right and access_ok() should be removed.
but, how about:
do {
...
"2: stw %3, (%1, 0) \n" \
+ " subi %0, 4 \n" \
"9: stw %4, (%1, 4) \n" \
+ " subi %0, 4 \n" \
"10: stw %5, (%1, 8) \n" \
+ " subi %0, 4 \n" \
"11: stw %6, (%1, 12) \n" \
+ " subi %0, 4 \n" \
" addi %2, 16 \n" \
" addi %1, 16 \n" \Don't expand __ex_table
AI Viro reply:
Hey, I've no idea about the instruction scheduling on csky - if that doesn't slow the things down, all the better. It's just that copy_to_user() and friends are on fairly hot codepaths, and in quite a few situations they will dominate the speed of e.g. read(2). So I tried to keep the fast path unchanged. Up to the architecture maintainers, obviously. Which would be you...
As for the fixups size increase (__ex_table size is unchanged)... You have each of those macros expanded exactly once.
So the size is not a serious argument, IMO - useless complexity would be, if it is, in fact, useless; the size... not really, especially since those extra subi will at least offset it.
Again, up to you - asm optimizations of (essentially) memcpy()-style loops are tricky and can depend upon the fairly subtle details of architecture. So even on something I know reasonably well I would resort to direct experiments if I can't pass the buck to architecture maintainers.
It *is* worth optimizing - this is where read() from a file that is already in page cache spends most of the time, etc.
Guo Ren reply:
Thx, after fixup some typo “sub %0, 4”, apply the patch.
TODO:
- user copy/from codes are still need optimizing.
--- arch/csky/include/asm/uaccess.h | 49 +++++++++++++++++---------------- arch/csky/lib/usercopy.c | 8 ++---- 2 files changed, 28 insertions(+), 29 deletions(-)
arch/csky/include/asm/uaccess.h +26 -23
@@ -254,7 +254,7 @@ do { \extern int __get_user_bad (void ); -#define __copy_user (to, from, n) \ +#define ___copy_to_user (to, from, n) \ do { \ int w0, w1, w2, w3; \ asm volatile( \
@@ -289,31 +289,34 @@ do { \ " subi %0, 4 \n" \ " br 3b \n" \ "5: cmpnei %0, 0 \n" /* 1B */ \ - " bf 8f \n" \ + " bf 13f \n" \ " ldb %3, (%2, 0) \n" \ "6: stb %3, (%1, 0) \n" \ " addi %2, 1 \n" \ " addi %1, 1 \n" \ " subi %0, 1 \n" \ " br 5b \n" \ - "7: br 8f \n" \ + "7: subi %0, 4 \n" \ + "8: subi %0, 4 \n" \ + "12: subi %0, 4 \n" \ + " br 13f \n" \ ".section __ex_table, \"a\" \n" \ ".align 2 \n" \ - ".long 2b, 7b \n" \ - ".long 9b, 7b \n" \ - ".long 10b, 7b \n" \ + ".long 2b, 13f \n" \ + ".long 4b, 13f \n" \ + ".long 6b, 13f \n" \ + ".long 9b, 12b \n" \ + ".long 10b, 8b \n" \ ".long 11b, 7b \n" \ - ".long 4b, 7b \n" \ - ".long 6b, 7b \n" \ ".previous \n" \ - "8: \n" \ + "13: \n" \ : "=r"(n), "=r"(to), "=r"(from), "=r"(w0), \ "=r"(w1), "=r"(w2), "=r"(w3) \ : "0"(n), "1"(to), "2"(from) \ : "memory"); \ } while (0) -#define __copy_user_zeroing (to, from, n) \ +#define ___copy_from_user (to, from, n) \ do { \ int tmp; \ int nsave; \
@@ -356,22 +359,22 @@ do { \" addi %1, 1 \n" \" subi %0, 1 \n" \" br 5b \n" \ -"8: mov %3, %0 \n" \ -" movi %4, 0 \n" \ -"9: stb %4, (%1, 0) \n" \ -" addi %1, 1 \n" \ -" subi %3, 1 \n" \ -" cmpnei %3, 0 \n" \ -" bt 9b \n" \ -" br 7f \n" \ +"8: stw %3, (%1, 0) \n" \ +" subi %0, 4 \n" \ +" bf 7f \n" \ +"9: subi %0, 8 \n" \ +" bf 7f \n" \ +"13: stw %3, (%1, 8) \n" \ +" subi %0, 12 \n" \ +" bf 7f \n" \".section __ex_table, \"a\" \n" \".align 2 \n" \ -".long 2b, 8b \n" \ +".long 2b, 7f \n" \ +".long 4b, 7f \n" \ +".long 6b, 7f \n" \".long 10b, 8b \n" \ -".long 11b, 8b \n" \ -".long 12b, 8b \n" \ -".long 4b, 8b \n" \ -".long 6b, 8b \n" \ +".long 11b, 9b \n" \ +".long 12b,13b \n" \".previous \n" \"7: \n" \ : "=r"(n), "=r"(to), "=r"(from), "=r"(nsave), \
arch/csky/lib/usercopy.c +2 -6
@@ -7,10 +7,7 @@unsigned long raw_copy_from_user (void *to,const void *from,unsigned long n) { -if (access_ok (from, n)) -__copy_user_zeroing (to, from, n); -else -memset (to,0 , n); +___copy_from_user (to, from, n);return n; }EXPORT_SYMBOL (raw_copy_from_user);
@@ -18,8 +15,7 @@ EXPORT_SYMBOL(raw_copy_from_user);unsigned long raw_copy_to_user (void *to,const void *from,unsigned long n) { -if (access_ok (to, n)) -__copy_user (to, from, n); +___copy_to_user (to, from, n);return n; }EXPORT_SYMBOL (raw_copy_to_user);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 287/606 samples: bpf: Fix build error
In reply to Sasha LevinFrom: Matteo Croce <[email protected]>
[ Upstream commit 23ad04669f81f958e9a4121b0266228d2eb3c357 ]
GCC 10 is very strict about symbol clash, and lwt_len_hist_user contains a symbol which clashes with libbpf:
/usr/bin/ld: samples/bpf/lwt_len_hist_user.o:(.bss+0x0): multiple definition of `bpf_log_buf'; samples/bpf/bpf_load.o:(.bss+0x8c0): first defined here
collect2: error: ld returned 1 exit status
bpf_log_buf here seems to be a leftover, so removing it.
--- samples/bpf/lwt_len_hist_user.c | 2 -- 1 file changed, 2 deletions(-)
samples/bpf/lwt_len_hist_user.c +0 -2
@@ -15,8 +15,6 @@#define MAX_INDEX 64#define MAX_STARS 38 -char bpf_log_buf[BPF_LOG_BUF_SIZE ]; -static void stars (char *str,long val,long max,int width) {int i;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 288/606 drivers: net: hamradio: Fix suspicious RCU usage warning in bpqether.c
In reply to Sasha LevinFrom: Madhuparna Bhowmik <[email protected]>
[ Upstream commit 95f59bf88bb75281cc626e283ecefdd5d5641427 ]
This patch fixes the following warning:
=============================
WARNING: suspicious RCU usage
5.7.0-rc5-next-20200514-syzkaller #0 Not tainted
-----------------------------drivers/net/hamradio/bpqether.c:149 RCU-list traversed in non-reader section!!
Since rtnl lock is held, pass this cond in list_for_each_entry_rcu().
--- drivers/net/hamradio/bpqether.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/hamradio/bpqether.c +2 -1
@@ -127,7 +127,8 @@ static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev) {struct bpqdev *bpq; -list_for_each_entry_rcu (bpq, &bpq_devices, bpq_list) { +list_for_each_entry_rcu (bpq, &bpq_devices, bpq_list, +lockdep_rtnl_is_held ()) {if (bpq->ethdev == dev)return bpq->axdev; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 289/606 Input: usbtouchscreen - add support for BonXeon TP
In reply to Sasha LevinFrom: James Hilliard <[email protected]>
[ Upstream commit e3b4f94ef52ae1592cbe199bd38dbdc0d58b2217 ]
Based on available information this uses the singletouch irtouch protocol. This is tested and confirmed to be fully functional on the BonXeon TP hardware I have.
--- drivers/input/touchscreen/usbtouchscreen.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/touchscreen/usbtouchscreen.c +1 -0
@@ -182,6 +182,7 @@ static const struct usb_device_id usbtouch_devices[] = {#endif #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH + {USB_DEVICE(0x255e, 0x0001), .driver_info = DEVTYPE_IRTOUCH}, {USB_DEVICE(0x595a, 0x0001), .driver_info = DEVTYPE_IRTOUCH}, {USB_DEVICE(0x6615, 0x0001), .driver_info = DEVTYPE_IRTOUCH}, {USB_DEVICE(0x6615, 0x0012), .driver_info = DEVTYPE_IRTOUCH_HIRES},
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 290/606 Input: evdev - call input_flush_device() on release(), not flush()
In reply to Sasha LevinFrom: Brendan Shanks <[email protected]>
[ Upstream commit 09264098ff153f60866039d60b31d39b66f55a31 ]
input_flush_device() should only be called once the struct file is being released and no open descriptors remain, but evdev_flush() was calling it whenever a file descriptor was closed.
This caused uploaded force-feedback effects to be erased when a process did a dup()/close() on the event FD, called system(), etc.
Call input_flush_device() from evdev_release() instead.
--- drivers/input/evdev.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/input/evdev.c +4 -15
@@ -326,20 +326,6 @@ static int evdev_fasync(int fd, struct file *file, int on)return fasync_helper (fd, file, on, &client->fasync); } -static int evdev_flush (struct file *file,fl_owner_t id) -{ -struct evdev_client *client = file->private_data; -struct evdev *evdev = client->evdev; - -mutex_lock (&evdev->mutex); - -if (evdev->exist && !client->revoked) -input_flush_device (&evdev->handle, file); - -mutex_unlock (&evdev->mutex); -return 0 ; -} -static void evdev_free (struct device *dev) { struct evdev *evdev = container_of(dev, struct evdev, dev);
@@ -453,6 +439,10 @@ static int evdev_release(struct inode *inode, struct file *file)unsigned int i;mutex_lock (&evdev->mutex); + +if (evdev->exist && !client->revoked) +input_flush_device (&evdev->handle, file); +evdev_ungrab (evdev, client);mutex_unlock (&evdev->mutex);
@@ -1310,7 +1300,6 @@ static const struct file_operations evdev_fops = { .compat_ioctl = evdev_ioctl_compat, #endif .fasync = evdev_fasync, - .flush = evdev_flush, .llseek = no_llseek, };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 291/606 Input: xpad - add custom init packet for Xbox One S controllers
In reply to Sasha LevinFrom: Łukasz Patron <[email protected]>
[ Upstream commit 764f7f911bf72450c51eb74cbb262ad9933741d8 ]
Sending [ 0x05, 0x20, 0x00, 0x0f, 0x06 ] packet for Xbox One S controllers fixes an issue where controller is stuck in Bluetooth mode and not sending any inputs.
--- drivers/input/joystick/xpad.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/input/joystick/xpad.c +12 -0
@@ -458,6 +458,16 @@ static const u8 xboxone_fw2015_init[] = { 0x05, 0x20, 0x00, 0x01, 0x00 }; +/* +* This packet is required for Xbox One S (0x045e:0x02ea) +* and Xbox One Elite Series 2 (0x045e:0x0b00) pads to +* initialize the controller that was previously used in +* Bluetooth mode. +*/ +static const u8 xboxone_s_init[] = { +0x05 ,0x20 ,0x00 ,0x0f ,0x06 +}; +/* * This packet is required for the Titanfall 2 Xbox One pads * (0x0e6f:0x0165) to finish initialization and for Hori pads
@@ -516,6 +526,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {XBOXONE_INIT_PKT (0x0e6f ,0x0165 , xboxone_hori_init),XBOXONE_INIT_PKT (0x0f0d ,0x0067 , xboxone_hori_init),XBOXONE_INIT_PKT (0x0000 ,0x0000 , xboxone_fw2015_init), +XBOXONE_INIT_PKT (0x045e ,0x02ea , xboxone_s_init), +XBOXONE_INIT_PKT (0x045e ,0x0b00 , xboxone_s_init),XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_init1),XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_init2), XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 292/606 Input: dlink-dir685-touchkeys - fix a typo in driver name
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 38347374ae3f1ec4df56dd688bd603a64e79a0ed ]
According to the file name and Kconfig, a 'k' is missing in this driver name. It should be "dlink-dir685-touchkeys".
--- drivers/input/keyboard/dlink-dir685-touchkeys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/dlink-dir685-touchkeys.c +1 -1
@@ -143,7 +143,7 @@ MODULE_DEVICE_TABLE(of, dir685_tk_of_match);static struct i2c_driver dir685_tk_i2c_driver = { .driver = { - .name ="dlin-dir685-touchkeys" , + .name ="dlink-dir685-touchkeys" , .of_match_table =of_match_ptr (dir685_tk_of_match), }, .probe = dir685_tk_probe,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 293/606 gpio: mvebu: Fix probing for chips without PWM
In reply to Sasha LevinFrom: Sascha Hauer <[email protected]>
[ Upstream commit 19c26d90ff4ca08ef2a2fef23cc9c13cfbfd891e ]
The PWM iomem resource is optional and its presence indicates whether the GPIO chip has a PWM or not, which is why mvebu_pwm_probe() returned successfully when the PWM resource was not present. With f51b18d92b66 the driver switched to devm_platform_ioremap_resource_byname() and its error return is propagated to the caller, so now a missing PWM resource leads to a probe error in the driver.
To fix this explicitly test for the presence of the PWM resource and return successfully when it's not there. Do this check before the check for the clock is done (which GPIO chips without a PWM do not have). Also move the existing comment why the PWM resource is optional up to the actual check.
--- drivers/gpio/gpio-mvebu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpio/gpio-mvebu.c +9 -6
@@ -782,6 +782,15 @@ static int mvebu_pwm_probe(struct platform_device *pdev, "marvell,armada-370-gpio"))return 0 ; +/* +* There are only two sets of PWM configuration registers for +* all the GPIO lines on those SoCs which this driver reserves +* for the first two GPIO chips. So if the resource is missing +* we can't treat it as an error. +*/ +if (!platform_get_resource_byname (pdev,IORESOURCE_MEM ,"pwm" )) +return 0 ; +if (IS_ERR (mvchip->clk))return PTR_ERR (mvchip->clk);
@@ -804,12 +813,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev, mvchip->mvpwm = mvpwm; mvpwm->mvchip = mvchip; -/* -* There are only two sets of PWM configuration registers for -* all the GPIO lines on those SoCs which this driver reserves -* for the first two GPIO chips. So if the resource is missing -* we can't treat it as an error. -*/ mvpwm->membase =devm_platform_ioremap_resource_byname (pdev,"pwm" );if (IS_ERR (mvpwm->membase))return PTR_ERR (mvpwm->membase);
Signature · 1 line
2.25.1
libgpiod users - implementations.
Hello,
because of the email address, and from what I read in the content of emails, this is mostly (or probably all) about development?
Is there some "user activity" too? I am interested in using libgpiod for reading senors etc.
thanks,
Ron
Sasha Levin
maintainerPATCH 294/606 Input: i8042 - add ThinkPad S230u to i8042 reset list
In reply to Sasha LevinFrom: Kevin Locke <[email protected]>
[ Upstream commit 2712c91a54a1058d55c284152b4d93c979b67be6 ]
On the Lenovo ThinkPad Twist S230u (3347-4HU) with BIOS version "GDETC1WW (1.81 ) 06/27/2019", the keyboard, Synaptics TouchPad, and TrackPoint either do not function or stop functioning a few minutes after boot. This problem has been noted before, perhaps only occurring with BIOS 1.57 and later.[1][2][3][4][5]
Odds of a BIOS fix appear to be low: 1.57 was released over 6 years ago and although the [BIOS changelog] notes "Fixed an issue of UEFI touchpad/trackpoint/keyboard/touchscreen" in 1.58, it appears to be insufficient.
Setting i8042.reset=1 or adding 33474HU to the reset list avoids the issue on my system from either warm or cold boot.
[1]: https://bugs.launchpad.net/bugs/1210748
[2]: https://bbs.archlinux.org/viewtopic.php?pid=1360425
[3]: https://forums.linuxmint.com/viewtopic.php?f=46&t=41200
[4]: https://forums.linuxmint.com/viewtopic.php?f=49&t=157115
[5]: https://forums.lenovo.com/topic/findpost/27/1337119
[BIOS changelog]: https://download.lenovo.com/pccbbs/mobiles/gduj33uc.txt
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -662,6 +662,13 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"), }, }, + { + /* Lenovo ThinkPad Twist S230u */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"), + }, + }, { } };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 295/606 Input: synaptics-rmi4 - really fix attn_data use-after-free
In reply to Sasha LevinFrom: Evan Green <[email protected]>
[ Upstream commit d5a5e5b5fa7b86c05bf073acc0ba98fa280174ec ]
Fix a use-after-free noticed by running with KASAN enabled. If rmi_irq_fn() is run twice in a row, then rmi_f11_attention() (among others) will end up reading from drvdata->attn_data.data, which was freed and left dangling in rmi_irq_fn().
Commit 55edde9fff1a ("Input: synaptics-rmi4 - prevent UAF reported by KASAN") correctly identified and analyzed this bug. However the attempted fix only NULLed out a local variable, missing the fact that drvdata->attn_data is a struct, not a pointer.
NULL out the correct pointer in the driver data to prevent the attention functions from copying from it.
--- drivers/input/rmi4/rmi_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/rmi4/rmi_driver.c +1 -1
@@ -205,7 +205,7 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id)if (count) {kfree (attn_data.data); - attn_data.data =NULL ; + drvdata->attn_data.data =NULL ; }if (!kfifo_is_empty (&drvdata->attn_fifo))
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 296/606 Input: synaptics-rmi4 - fix error return code in rmi_driver_probe()
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
[ Upstream commit 5caab2da63207d6d631007f592f5219459e3454d ]
Fix to return a negative error code from the input_register_device() error handling case instead of 0, as done elsewhere in this function.
--- drivers/input/rmi4/rmi_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/input/rmi4/rmi_driver.c +2 -1
@@ -1210,7 +1210,8 @@ static int rmi_driver_probe(struct device *dev)if (data->input) {rmi_driver_set_input_name (rmi_dev, data->input);if (!rmi_dev->xport->input) { -if (input_register_device (data->input)) { + retval =input_register_device (data->input); +if (retval) {dev_err (dev,"%s: Failed to register input device.\n" , __func__); goto err_destroy_functions;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 297/606 ARM: 8970/1: decompressor: increase tag size
In reply to Sasha LevinFrom: Łukasz Stelmach <[email protected]>
[ Upstream commit 2c962369d72f286659e6446919f88d69b943cb4d ]
The size field of the tag header structure is supposed to be set to the size of a tag structure including the header.
--- arch/arm/boot/compressed/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/compressed/vmlinux.lds.S +1 -1
@@ -43,7 +43,7 @@ SECTIONS } .table : ALIGN(4) { _table_start = .; - LONG(ZIMAGE_MAGIC(2)) + LONG(ZIMAGE_MAGIC(4)) LONG(ZIMAGE_MAGIC(0x5a534c4b)) LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) LONG(ZIMAGE_MAGIC(_kernel_bss_size))
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 298/606 ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 747ffc2fcf969eff9309d7f2d1d61cb8b9e1bb40 ]
Consolidate the user access assembly code to asm/uaccess-asm.h. This moves the csdb, check_uaccess, uaccess_mask_range_ptr, uaccess_enable, uaccess_disable, uaccess_save, uaccess_restore macros, and creates two new ones for exception entry and exit - uaccess_entry and uaccess_exit.
This makes the uaccess_save and uaccess_restore macros private to asm/uaccess-asm.h.
--- arch/arm/include/asm/assembler.h | 75 +------------------- arch/arm/include/asm/uaccess-asm.h | 106 +++++++++++++++++++++++++++++ arch/arm/kernel/entry-armv.S | 11 +-- arch/arm/kernel/entry-header.S | 9 +-- 4 files changed, 112 insertions(+), 89 deletions(-) create mode 100644 arch/arm/include/asm/uaccess-asm.h
arch/arm/include/asm/assembler.h +1 -74
@@ -18,11 +18,11 @@#endif #include <asm/ptrace.h> -#include <asm/domain.h> #include <asm/opcodes-virt.h> #include <asm/asm-offsets.h> #include <asm/page.h> #include <asm/thread_info.h> +#include <asm/uaccess-asm.h> #define IOMEM (x) (x)
@@ -446,79 +446,6 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) .size \name , . - \name .endm - .macro csdb -#ifdef CONFIG_THUMB2_KERNEL - .inst.w 0xf3af8014 -#else - .inst 0xe320f014 -#endif - .endm - - .macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req -#ifndef CONFIG_CPU_USE_DOMAINS - adds \tmp, \addr, #\size - 1 - sbcscc \tmp, \tmp, \limit - bcs \bad -#ifdef CONFIG_CPU_SPECTRE - movcs \addr, #0 - csdb -#endif -#endif - .endm - - .macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req -#ifdef CONFIG_CPU_SPECTRE - sub \tmp, \limit, #1 - subs \tmp, \tmp, \addr @ tmp = limit - 1 - addr - addhs \tmp, \tmp, #1 @ if (tmp >= 0) { - subshs \tmp, \tmp, \size @ tmp = limit - (addr + size) } - movlo \addr, #0 @ if (tmp < 0) addr = NULL - csdb -#endif - .endm - - .macro uaccess_disable, tmp, isb=1 -#ifdef CONFIG_CPU_SW_DOMAIN_PAN - /* - * Whenever we re-enter userspace, the domains should always be - * set appropriately. - */ - mov \tmp, #DACR_UACCESS_DISABLE - mcr p15, 0, \tmp, c3, c0, 0 @ Set domain register - .if \isb - instr_sync - .endif -#endif - .endm - - .macro uaccess_enable, tmp, isb=1 -#ifdef CONFIG_CPU_SW_DOMAIN_PAN - /* - * Whenever we re-enter userspace, the domains should always be - * set appropriately. - */ - mov \tmp, #DACR_UACCESS_ENABLE - mcr p15, 0, \tmp, c3, c0, 0 - .if \isb - instr_sync - .endif -#endif - .endm - - .macro uaccess_save, tmp -#ifdef CONFIG_CPU_SW_DOMAIN_PAN - mrc p15, 0, \tmp, c3, c0, 0 - str \tmp, [sp, #SVC_DACR] -#endif - .endm - - .macro uaccess_restore -#ifdef CONFIG_CPU_SW_DOMAIN_PAN - ldr r0, [sp, #SVC_DACR] - mcr p15, 0, r0, c3, c0, 0 -#endif - .endm - .irp c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo .macro ret\c, reg #if __LINUX_ARM_ARCH__ < 6
arch/arm/include/asm/uaccess-asm.h new file +106 -0
106 lines not on this page · raw message
arch/arm/kernel/entry-armv.S +2 -9
@@ -27,6 +27,7 @@ #include <asm/unistd.h> #include <asm/tls.h> #include <asm/system_info.h> +#include <asm/uaccess-asm.h> #include "entry-header.S" #include <asm/entry-macro-multi.S>
@@ -179,15 +180,7 @@ ENDPROC(__und_invalid) stmia r7, {r2 - r6} get_thread_info tsk - ldr r0, [tsk, #TI_ADDR_LIMIT] - mov r1, #TASK_SIZE - str r1, [tsk, #TI_ADDR_LIMIT] - str r0, [sp, #SVC_ADDR_LIMIT] - - uaccess_save r0 - .if \uaccess - uaccess_disable r0 - .endif + uaccess_entry tsk, r0, r1, r2, \uaccess .if \trace #ifdef CONFIG_TRACE_IRQFLAGS
arch/arm/kernel/entry-header.S +3 -6
@@ -6,6 +6,7 @@ #include <asm/asm-offsets.h> #include <asm/errno.h> #include <asm/thread_info.h> +#include <asm/uaccess-asm.h> #include <asm/v7m.h> @ Bad Abort numbers
@@ -217,9 +218,7 @@ blne trace_hardirqs_off #endif .endif - ldr r1, [sp, #SVC_ADDR_LIMIT] - uaccess_restore - str r1, [tsk, #TI_ADDR_LIMIT] + uaccess_exit tsk, r0, r1 #ifndef CONFIG_THUMB2_KERNEL @ ARM mode SVC restore
@@ -263,9 +262,7 @@ @ on the stack remains correct). @ .macro svc_exit_via_fiq - ldr r1, [sp, #SVC_ADDR_LIMIT] - uaccess_restore - str r1, [tsk, #TI_ADDR_LIMIT] + uaccess_exit tsk, r0, r1 #ifndef CONFIG_THUMB2_KERNEL @ ARM mode restore mov r0, sp
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 299/606 ARM: uaccess: integrate uaccess_save and uaccess_restore
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 8ede890b0bcebe8c760aacfe20e934d98c3dc6aa ]
Integrate uaccess_save / uaccess_restore macros into the new uaccess_entry / uaccess_exit macros respectively.
--- arch/arm/include/asm/uaccess-asm.h | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
arch/arm/include/asm/uaccess-asm.h +13 -17
@@ -67,30 +67,23 @@#endif .endm - .macro uaccess_save, tmp#ifdef CONFIG_CPU_SW_DOMAIN_PAN - mrc p15, 0, \tmp, c3, c0, 0 - str \tmp, [sp, #SVC_DACR] -#endif - .endm - - .macro uaccess_restore -#ifdef CONFIG_CPU_SW_DOMAIN_PAN - ldr r0, [sp, #SVC_DACR] - mcr p15, 0, r0, c3, c0, 0 +#define DACR(x...) x +#else +#define DACR(x...)#endif - .endm/* * Save the address limit on entry to a privileged exception and * if using PAN, save and disable usermode access. */ .macro uaccess_entry, tsk, tmp0, tmp1, tmp2, disable - ldr \tmp0, [\tsk, #TI_ADDR_LIMIT] - mov \tmp1, #TASK_SIZE - str \tmp1, [\tsk, #TI_ADDR_LIMIT] - str \tmp0, [sp, #SVC_ADDR_LIMIT] - uaccess_save \tmp0 + ldr \tmp1, [\tsk, #TI_ADDR_LIMIT] + mov \tmp2, #TASK_SIZE + str \tmp2, [\tsk, #TI_ADDR_LIMIT] + DACR( mrc p15, 0, \tmp0, c3, c0, 0) + DACR( str \tmp0, [sp, #SVC_DACR]) + str \tmp1, [sp, #SVC_ADDR_LIMIT] .if \disable uaccess_disable \tmp0 .endif
@@ -99,8 +92,11 @@/* Restore the user access state previously saved by uaccess_entry */ .macro uaccess_exit, tsk, tmp0, tmp1 ldr \tmp1, [sp, #SVC_ADDR_LIMIT] - uaccess_restore + DACR( ldr \tmp0, [sp, #SVC_DACR]) str \tmp1, [\tsk, #TI_ADDR_LIMIT] + DACR( mcr p15, 0, \tmp0, c3, c0, 0) .endm +#undef DACR + #endif /* __ASM_UACCESS_ASM_H__ */
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 300/606 ARM: uaccess: fix DACR mismatch with nested exceptions
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 71f8af1110101facfad68989ff91f88f8e2c3e22 ]
Tomas Paukrt reports that his SAM9X60 based system (ARM926, ARMv5TJ) fails to fix up alignment faults, eventually resulting in a kernel oops.
The problem occurs when using CONFIG_CPU_USE_DOMAINS with commit e6978e4bf181 ("ARM: save and reset the address limit when entering an exception"). This is because the address limit is set back to TASK_SIZE on exception entry, and, although it is restored on exception exit, the domain register is not.
Hence, this sequence can occur:
interrupt
pt_regs->addr_limit = addr_limit // USER_DS
addr_limit = USER_DS
alignment exception
__probe_kernel_read()
old_fs = get_fs() // USER_DS
set_fs(KERNEL_DS)
addr_limit = KERNEL_DS
dacr.kernel = DOMAIN_MANAGER
interrupt
pt_regs->addr_limit = addr_limit // KERNEL_DS
addr_limit = USER_DS
alignment exception
__probe_kernel_read()
old_fs = get_fs() // USER_DS
set_fs(KERNEL_DS)
addr_limit = KERNEL_DS
dacr.kernel = DOMAIN_MANAGER
...
set_fs(old_fs)
addr_limit = USER_DS
dacr.kernel = DOMAIN_CLIENT
...
addr_limit = pt_regs->addr_limit // KERNEL_DS
interrupt returnsAt this point, addr_limit is correctly restored to KERNEL_DS for __probe_kernel_read() to continue execution, but dacr.kernel is not, it has been reset by the set_fs(old_fs) to DOMAIN_CLIENT.
This would not have happened prior to the mentioned commit, because addr_limit would remain KERNEL_DS, so get_fs() would have returned KERNEL_DS, and so would correctly nest.
This commit fixes the problem by also saving the DACR on exception entry if either CONFIG_CPU_SW_DOMAIN_PAN or CONFIG_CPU_USE_DOMAINS are enabled, and resetting the DACR appropriately on exception entry to match addr_limit and PAN settings.
--- arch/arm/include/asm/uaccess-asm.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
arch/arm/include/asm/uaccess-asm.h +20 -5
@@ -67,15 +67,21 @@#endif .endm -#ifdef CONFIG_CPU_SW_DOMAIN_PAN +#if defined(CONFIG_CPU_SW_DOMAIN_PAN ) || defined(CONFIG_CPU_USE_DOMAINS ) #define DACR(x...) x#else #define DACR(x...)#endif /* -* Save the address limit on entry to a privileged exception and -* if using PAN, save and disable usermode access. +* Save the address limit on entry to a privileged exception. +* +* If we are using the DACR for kernel access by the user accessors +* (CONFIG_CPU_USE_DOMAINS=y), always reset the DACR kernel domain +* back to client mode, whether or not \disable is set. +* +* If we are using SW PAN, set the DACR user domain to no access +* if \disable is set. */ .macro uaccess_entry, tsk, tmp0, tmp1, tmp2, disable ldr \tmp1, [\tsk, #TI_ADDR_LIMIT]
@@ -84,8 +90,17 @@ DACR( mrc p15, 0, \tmp0, c3, c0, 0) DACR( str \tmp0, [sp, #SVC_DACR]) str \tmp1, [sp, #SVC_ADDR_LIMIT] - .if \disable - uaccess_disable \tmp0 + .if \disable && IS_ENABLED(CONFIG_CPU_SW_DOMAIN_PAN) + /* kernel=client, user=no access */ + mov \tmp2, #DACR_UACCESS_DISABLE + mcr p15, 0, \tmp2, c3, c0, 0 + instr_sync + .elseif IS_ENABLED(CONFIG_CPU_USE_DOMAINS) + /* kernel=client */ + bic \tmp2, \tmp0, #domain_mask(DOMAIN_KERNEL) + orr \tmp2, \tmp2, #domain_val(DOMAIN_KERNEL, DOMAIN_CLIENT) + mcr p15, 0, \tmp2, c3, c0, 0 + instr_sync .endif .endm
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 301/606 gpio: exar: Fix bad handling for ida_simple_get error path
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 333830aa149a87cabeb5d30fbcf12eecc8040d2c ]
The commit 7ecced0934e5 ("gpio: exar: add a check for the return value of ida_simple_get fails") added a goto jump to the common error handler for ida_simple_get() error, but this is wrong in two ways:
it doesn't set the proper return code and, more badly, it invokes ida_simple_remove() with a negative index that shall lead to a kernel panic via BUG_ON().
This patch addresses those two issues.
--- drivers/gpio/gpio-exar.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpio/gpio-exar.c +5 -2
@@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)mutex_init (&exar_gpio->lock); index =ida_simple_get (&ida_index,0 ,0 ,GFP_KERNEL ); -if (index <0 ) - goto err_destroy; +if (index <0 ) { + ret = index; + goto err_mutex_destroy; + }sprintf (exar_gpio->name,"exar_gpio%d" , index); exar_gpio->gpio_chip.label = exar_gpio->name;
@@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev) err_destroy:ida_simple_remove (&ida_index, index); +err_mutex_destroy:mutex_destroy (&exar_gpio->lock);return ret; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 302/606 arm64: dts: mt8173: fix vcodec-enc clock
In reply to Sasha LevinFrom: Hsin-Yi Wang <[email protected]>
[ Upstream commit 3b1f6c5e4dfaf767f6f2f120cd93b347b5a9f1aa ]
Fix the assigned-clock-parents to higher frequency clock to avoid h264 encode timeout:
[ 134.763465] mtk_vpu 10020000.vpu: vpu ipi 4 ack time out ! [ 134.769008] [MTK_VCODEC][ERROR][18]: vpu_enc_send_msg() vpu_ipi_send msg_id c002 len 32 fail -5 [ 134.777707] [MTK_VCODEC][ERROR][18]: vpu_enc_encode() AP_IPIMSG_ENC_ENCODE 0 fail
venc_sel is the clock used by h264 encoder, and venclt_sel is the clock used by vp8 encoder. Assign venc_sel to vcodecpll_ck and venclt_sel to vcodecpll_370p5.
vcodecpll 1482000000
vcodecpll_ck 494000000
venc_sel 494000000
...
vcodecpll_370p5 370500000
venclt_sel 370500000--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +2 -2
@@ -1401,8 +1401,8 @@ vcodec_enc: vcodec@18002000 { "venc_lt_sel"; assigned-clocks = <&topckgen CLK_TOP_VENC_SEL>, <&topckgen CLK_TOP_VENC_LT_SEL>; - assigned-clock-parents = <&topckgen CLK_TOP_VENCPLL_D2>, - <&topckgen CLK_TOP_UNIVPLL1_D2>; + assigned-clock-parents = <&topckgen CLK_TOP_VCODECPLL>, + <&topckgen CLK_TOP_VCODECPLL_370P5>; }; jpegdec: jpegdec@18004000 {
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 303/606 soc: mediatek: cmdq: return send msg error code
In reply to Sasha LevinFrom: Dennis YC Hsieh <[email protected]>
[ Upstream commit 34c4e4072603ff5c174df73b973896abb76cbb51 ]
Return error code to client if send message fail,
so that client has chance to error handling.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +3 -1
@@ -351,7 +351,9 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb,spin_unlock_irqrestore (&client->lock, flags); } -mbox_send_message (client->chan, pkt); + err =mbox_send_message (client->chan, pkt); +if (err <0 ) +return err;/* We can send next packet immediately, so just call txdone. */ mbox_client_txdone (client->chan,0 );
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 304/606 gpu/drm: ingenic: Fix bogus crtc_atomic_check callback
In reply to Sasha LevinFrom: Paul Cercueil <[email protected]>
[ Upstream commit a53bcc19876498bdd3b4ef796c787295dcc498b4 ]
The code was comparing the SoC's maximum height with the mode's width, and vice-versa. D'oh.
--- drivers/gpu/drm/ingenic/ingenic-drm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm.c +2 -2
@@ -328,8 +328,8 @@ static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,if (!drm_atomic_crtc_needs_modeset (state))return 0 ; -if (state->mode.hdisplay > priv->soc_info->max_height || - state->mode.vdisplay > priv->soc_info->max_width) +if (state->mode.hdisplay > priv->soc_info->max_width || + state->mode.vdisplay > priv->soc_info->max_height)return -EINVAL ; rate = clk_round_rate(priv->pix_clk,
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 305/606 gpu/drm: Ingenic: Fix opaque pointer casted to wrong type
In reply to Sasha LevinFrom: Paul Cercueil <[email protected]>
[ Upstream commit abf56fadf0e208abfb13ad1ac0094416058da0ad ]
The opaque pointer passed to the IRQ handler is a pointer to the drm_device, not a pointer to our ingenic_drm structure.
It still worked, because our ingenic_drm structure contains the drm_device as its first field, so the pointer received had the same value, but this was not semantically correct.
--- drivers/gpu/drm/ingenic/ingenic-drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ingenic/ingenic-drm.c +1 -1
@@ -474,7 +474,7 @@ static int ingenic_drm_encoder_atomic_check(struct drm_encoder *encoder,static irqreturn_t ingenic_drm_irq_handler (int irq,void *arg) { -struct ingenic_drm *priv = arg; +struct ingenic_drm *priv =drm_device_get_priv (arg);unsigned int state;regmap_read (priv->map,JZ_REG_LCD_STATE , &state);
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 306/606 IB/qib: Call kobject_put() when kobject_init_and_add() fails
In reply to Sasha LevinFrom: Kaike Wan <[email protected]>
[ Upstream commit a35cd6447effd5c239b564c80fa109d05ff3d114 ]
When kobject_init_and_add() returns an error in the function qib_create_port_files(), the function kobject_put() is not called for the corresponding kobject, which potentially leads to memory leak.
This patch fixes the issue by calling kobject_put() even if kobject_init_and_add() fails. In addition, the ppd->diagc_kobj is released along with other kobjects when the sysfs is unregistered.
--- drivers/infiniband/hw/qib/qib_sysfs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/infiniband/hw/qib/qib_sysfs.c +5 -4
@@ -760,7 +760,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,qib_dev_err (dd,"Skipping linkcontrol sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail; + goto bail_link; }kobject_uevent (&ppd->pport_kobj,KOBJ_ADD );
@@ -770,7 +770,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,qib_dev_err (dd,"Skipping sl2vl sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_link; + goto bail_sl; }kobject_uevent (&ppd->sl2vl_kobj,KOBJ_ADD );
@@ -780,7 +780,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,qib_dev_err (dd,"Skipping diag_counters sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_sl; + goto bail_diagc; }kobject_uevent (&ppd->diagc_kobj,KOBJ_ADD );
@@ -793,7 +793,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,qib_dev_err (dd,"Skipping Congestion Control sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_diagc; + goto bail_cc; }kobject_uevent (&ppd->pport_cc_kobj,KOBJ_ADD );
@@ -854,6 +854,7 @@ void qib_verbs_unregister_sysfs(struct qib_devdata *dd) &cc_table_bin_attr);kobject_put (&ppd->pport_cc_kobj); } +kobject_put (&ppd->diagc_kobj);kobject_put (&ppd->sl2vl_kobj);kobject_put (&ppd->pport_kobj); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 307/606 ARM: dts/imx6q-bx50v3: Set display interface clock parents
In reply to Sasha LevinFrom: Robert Beckett <[email protected]>
[ Upstream commit 665e7c73a7724a393b4ec92d1ae1e029925ef2b7 ]
Avoid LDB and IPU DI clocks both using the same parent. LDB requires pasthrough clock to avoid breaking timing while IPU DI does not.
Force IPU DI clocks to use IMX6QDL_CLK_PLL2_PFD0_352M as parent and LDB to use IMX6QDL_CLK_PLL5_VIDEO_DIV.
This fixes an issue where attempting atomic modeset while using HDMI and display port at the same time causes LDB clock programming to destroy the programming of HDMI that was done during the same modeset.
[Use IMX6QDL_CLK_PLL2_PFD0_352M instead of IMX6QDL_CLK_PLL2_PFD2_396M
originally chosen by Robert Beckett to avoid affecting eMMC clock by DRM atomic updates]
[Squash Robert's and Ian's commits for bisectability, update patch
description and add stable tag]
--- arch/arm/boot/dts/imx6q-b450v3.dts | 7 ------- arch/arm/boot/dts/imx6q-b650v3.dts | 7 ------- arch/arm/boot/dts/imx6q-b850v3.dts | 11 ----------- arch/arm/boot/dts/imx6q-bx50v3.dtsi | 15 +++++++++++++++ 4 files changed, 15 insertions(+), 25 deletions(-)
arch/arm/boot/dts/imx6q-b450v3.dts +0 -7
@@ -65,13 +65,6 @@ panel_in_lvds0: endpoint { }; }; -&clks { - assigned-clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>, - <&clks IMX6QDL_CLK_LDB_DI1_SEL>; - assigned-clock-parents = <&clks IMX6QDL_CLK_PLL3_USB_OTG>, - <&clks IMX6QDL_CLK_PLL3_USB_OTG>; -}; - &ldb { status = "okay";
arch/arm/boot/dts/imx6q-b650v3.dts +0 -7
@@ -65,13 +65,6 @@ panel_in_lvds0: endpoint { }; }; -&clks { - assigned-clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>, - <&clks IMX6QDL_CLK_LDB_DI1_SEL>; - assigned-clock-parents = <&clks IMX6QDL_CLK_PLL3_USB_OTG>, - <&clks IMX6QDL_CLK_PLL3_USB_OTG>; -}; - &ldb { status = "okay";
arch/arm/boot/dts/imx6q-b850v3.dts +0 -11
@@ -53,17 +53,6 @@ chosen { }; }; -&clks { - assigned-clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>, - <&clks IMX6QDL_CLK_LDB_DI1_SEL>, - <&clks IMX6QDL_CLK_IPU1_DI0_PRE_SEL>, - <&clks IMX6QDL_CLK_IPU2_DI0_PRE_SEL>; - assigned-clock-parents = <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>, - <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>, - <&clks IMX6QDL_CLK_PLL2_PFD2_396M>, - <&clks IMX6QDL_CLK_PLL2_PFD2_396M>; -}; - &ldb { fsl,dual-channel; status = "okay";
arch/arm/boot/dts/imx6q-bx50v3.dtsi +15 -0
@@ -377,3 +377,18 @@ pci_root: root@0,0 { #interrupt-cells = <1>; }; }; + +&clks { + assigned-clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>, + <&clks IMX6QDL_CLK_LDB_DI1_SEL>, + <&clks IMX6QDL_CLK_IPU1_DI0_PRE_SEL>, + <&clks IMX6QDL_CLK_IPU1_DI1_PRE_SEL>, + <&clks IMX6QDL_CLK_IPU2_DI0_PRE_SEL>, + <&clks IMX6QDL_CLK_IPU2_DI1_PRE_SEL>; + assigned-clock-parents = <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>, + <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>, + <&clks IMX6QDL_CLK_PLL2_PFD0_352M>, + <&clks IMX6QDL_CLK_PLL2_PFD0_352M>, + <&clks IMX6QDL_CLK_PLL2_PFD0_352M>, + <&clks IMX6QDL_CLK_PLL2_PFD0_352M>; +};
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 308/606 ARM: dts: bcm2835-rpi-zero-w: Fix led polarity
In reply to Sasha LevinFrom: Vincent Stehlé <[email protected]>
[ Upstream commit 58bb90ab415562eededb932455046924e65df342 ]
The status "ACT" led on the Raspberry Pi Zero W is on when GPIO 47 is low.
This has been verified on a board and somewhat confirmed by both the GPIO name ("STATUS_LED_N") and the reduced schematics [1].
--- arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/bcm2835-rpi-zero-w.dts +1 -1
@@ -24,7 +24,7 @@ chosen { leds { act { - gpios = <&gpio 47 GPIO_ACTIVE_HIGH>; + gpios = <&gpio 47 GPIO_ACTIVE_LOW>; }; };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 309/606 ARM: dts: bcm: HR2: Fix PPI interrupt types
In reply to Sasha LevinFrom: Hamish Martin <[email protected]>
[ Upstream commit be0ec060b54f0481fb95d59086c1484a949c903c ]
These error messages are output when booting on a BCM HR2 system:
GIC: PPI11 is secure or misconfigured
GIC: PPI13 is secure or misconfigured
Per ARM documentation these interrupts are triggered on a rising edge. See ARM Cortex A-9 MPCore Technical Reference Manual, Revision r4p1, Section 3.3.8 Interrupt Configuration Registers.
The same issue was resolved for NSP systems in commit 5f1aa51c7a1e ("ARM: dts: NSP: Fix PPI interrupt types").
--- arch/arm/boot/dts/bcm-hr2.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/bcm-hr2.dtsi +3 -3
@@ -75,7 +75,7 @@ a9pll: arm_clk@0 { timer@20200 { compatible = "arm,cortex-a9-global-timer"; reg = <0x20200 0x100>; - interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>; clocks = <&periph_clk>; };
@@ -83,7 +83,7 @@ twd-timer@20600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x20600 0x20>; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | - IRQ_TYPE_LEVEL_HIGH)>; + IRQ_TYPE_EDGE_RISING)>; clocks = <&periph_clk>; };
@@ -91,7 +91,7 @@ twd-watchdog@20620 { compatible = "arm,cortex-a9-twd-wdt"; reg = <0x20620 0x20>; interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | - IRQ_TYPE_LEVEL_HIGH)>; + IRQ_TYPE_EDGE_RISING)>; clocks = <&periph_clk>; };
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 310/606 ARM: dts: mmp3: Use the MMP3 compatible string for /clocks
In reply to Sasha LevinFrom: Lubomir Rintel <[email protected]>
[ Upstream commit ec7d12faf81de983efce8ff23f41c5d1bff14c41 ]
Clocks are in fact slightly different on MMP3. In particular, PLL2 is fixed to a different frequency, there's an extra PLL3, and the GPU clocks are configured differently.
--- arch/arm/boot/dts/mmp3.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/mmp3.dtsi +1 -1
@@ -531,7 +531,7 @@ l2: l2-cache-controller@d0020000 { }; soc_clocks: clocks@d4050000 { - compatible = "marvell,mmp2-clock"; + compatible = "marvell,mmp3-clock"; reg = <0xd4050000 0x1000>, <0xd4282800 0x400>, <0xd4015000 0x1000>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 311/606 ARM: dts: mmp3-dell-ariel: Fix the SPI devices
In reply to Sasha LevinFrom: Lubomir Rintel <[email protected]>
[ Upstream commit 233cbffaa0b9ca874731efee67a11f005da1f87c ]
I've managed to get about everything wrong while digging these out of OEM's board file.
Correct the bus numbers, the exact model of the NOR flash, polarity of the chip selects and align the SPI frequency with the data sheet.
Tested that it works now, with a slight fix to the PXA SSP driver.
--- arch/arm/boot/dts/mmp3-dell-ariel.dts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/boot/dts/mmp3-dell-ariel.dts +6 -6
@@ -98,19 +98,19 @@ &twsi4 { status = "okay"; }; -&ssp3 { +&ssp1 { status = "okay"; - cs-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 46 GPIO_ACTIVE_LOW>; firmware-flash@0 { - compatible = "st,m25p80", "jedec,spi-nor"; + compatible = "winbond,w25q32", "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <40000000>; + spi-max-frequency = <104000000>; m25p,fast-read; }; }; -&ssp4 { - cs-gpios = <&gpio 56 GPIO_ACTIVE_HIGH>; +&ssp2 { + cs-gpios = <&gpio 56 GPIO_ACTIVE_LOW>; status = "okay"; };
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 312/606 ARM: dts: mmp3: Drop usb-nop-xceiv from HSIC phy
In reply to Sasha LevinFrom: Lubomir Rintel <[email protected]>
[ Upstream commit 24cf6eef79a7e85cfd2ef9dea52f769c9192fc6e ]
"usb-nop-xceiv" is good enough if we don't lose the configuration done by the firmware, but we'd really prefer a real driver.
Unfortunately, the PHY core is odd in that when the node is compatible with "usb-nop-xceiv", it ignores the other compatible strings. Let's just remove it.
--- arch/arm/boot/dts/mmp3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/boot/dts/mmp3.dtsi +2 -4
@@ -202,8 +202,7 @@ usb_otg0: usb-otg@d4208000 { }; hsic_phy0: hsic-phy@f0001800 { - compatible = "marvell,mmp3-hsic-phy", - "usb-nop-xceiv"; + compatible = "marvell,mmp3-hsic-phy"; reg = <0xf0001800 0x40>; #phy-cells = <0>; status = "disabled";
@@ -224,8 +223,7 @@ hsic0: hsic@f0001000 { }; hsic_phy1: hsic-phy@f0002800 { - compatible = "marvell,mmp3-hsic-phy", - "usb-nop-xceiv"; + compatible = "marvell,mmp3-hsic-phy"; reg = <0xf0002800 0x40>; #phy-cells = <0>; status = "disabled";
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 313/606 RDMA/mlx5: Fix NULL pointer dereference in destroy_prefetch_work
In reply to Sasha LevinFrom: Maor Gottlieb <[email protected]>
[ Upstream commit 189277f3814c36133f4ff0352f4b5194a38486b6 ]
q_deferred_work isn't initialized when creating an explicit ODP memory region. This can lead to a NULL pointer dereference when user performs asynchronous prefetch MR. Fix it by initializing q_deferred_work for explicit ODP.
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI CPU: 4 PID: 6074 Comm: kworker/u16:6 Not tainted 5.7.0-rc1-for-upstream-perf-2020-04-17_07-03-39-64 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: events_unbound mlx5_ib_prefetch_mr_work [mlx5_ib] RIP: 0010:__wake_up_common+0x49/0x120 Code: 04 89 54 24 0c 89 4c 24 08 74 0a 41 f6 01 04 0f 85 8e 00 00 00 48 8b 47 08 48 83 e8 18 4c 8d 67 08 48 8d 50 18 49 39 d4 74 66 <48> 8b 70 18 31 db 4c 8d 7e e8 eb 17 49 8b 47 18 48 8d 50 e8 49 8d RSP: 0000:ffffc9000097bd88 EFLAGS: 00010082 RAX: ffffffffffffffe8 RBX: ffff888454cd9f90 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffff888454cd9f90 RBP: ffffc9000097bdd0 R08: 0000000000000000 R09: ffffc9000097bdd0 R10: 0000000000000000 R11: 0000000000000001 R12: ffff888454cd9f98 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000003 FS: 0000000000000000(0000) GS:ffff88846fd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000044c19e002 CR4: 0000000000760ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __wake_up_common_lock+0x7a/0xc0 destroy_prefetch_work+0x5a/0x60 [mlx5_ib] mlx5_ib_prefetch_mr_work+0x64/0x80 [mlx5_ib] process_one_work+0x15b/0x360 worker_thread+0x49/0x3d0 kthread+0xf5/0x130 ? rescuer_thread+0x310/0x310 ? kthread_bind+0x10/0x10 ret_from_fork+0x1f/0x30
--- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/mr.c +1 -0
@@ -1319,6 +1319,7 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,if (is_odp_mr (mr)) {to_ib_umem_odp (mr->umem)->private = mr; +init_waitqueue_head (&mr->q_deferred_work);atomic_set (&mr->num_deferred_work,0 ); err = xa_err(xa_store(&dev->odp_mkeys, mlx5_base_mkey(mr->mmkey.key), &mr->mmkey,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 314/606 mmc: block: Fix use-after-free issue for rpmb
In reply to Sasha LevinFrom: Peng Hao <[email protected]>
[ Upstream commit 202500d21654874aa03243e91f96de153ec61860 ]
The data structure member “rpmb->md” was passed to a call of the function “mmc_blk_put” after a call of the function “put_device”. Reorder these function calls to keep the data accesses consistent.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -2475,8 +2475,8 @@ static int mmc_rpmb_chrdev_release(struct inode *inode, struct file *filp)struct mmc_rpmb_data *rpmb =container_of (inode->i_cdev, struct mmc_rpmb_data, chrdev); -put_device (&rpmb->dev);mmc_blk_put (rpmb->md); +put_device (&rpmb->dev);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 315/606 gpio: pxa: Fix return value of pxa_gpio_probe()
In reply to Sasha LevinFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 558ab2e8155e5f42ca0a6407957cd4173dc166cc ]
When call function devm_platform_ioremap_resource(), we should use IS_ERR() to check the return value and return PTR_ERR() if failed.
--- drivers/gpio/gpio-pxa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pxa.c +2 -2
@@ -663,8 +663,8 @@ static int pxa_gpio_probe(struct platform_device *pdev) pchip->irq1 = irq1; gpio_reg_base =devm_platform_ioremap_resource (pdev,0 ); -if (!gpio_reg_base) -return -EINVAL ; +if (IS_ERR (gpio_reg_base)) +return PTR_ERR (gpio_reg_base); clk =clk_get (&pdev->dev,NULL );if (IS_ERR (clk)) {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 316/606 gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe()
In reply to Sasha LevinFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 98f7d1b15e87c84488b30ecc4ec753b0690b9dbf ]
Propagate the error code returned by devm_platform_ioremap_resource() out of probe() instead of overwriting it.
--- drivers/gpio/gpio-bcm-kona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-bcm-kona.c +1 -1
@@ -625,7 +625,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) kona_gpio->reg_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (kona_gpio->reg_base)) { - ret = -ENXIO ; + ret =PTR_ERR (kona_gpio->reg_base); goto err_irq_domain; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 317/606 RDMA/pvrdma: Fix missing pci disable in pvrdma_pci_probe()
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
[ Upstream commit db857e6ae548f0f4f4a0f63fffeeedf3cca21f9d ]
In function pvrdma_pci_probe(), pdev was not disabled in one error path. Thus replace the jump target “err_free_device” by "err_disable_pdev".
--- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +1 -1
@@ -829,7 +829,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, !(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {dev_err (&pdev->dev,"PCI BAR region not MMIO\n" ); ret = -ENOMEM ; - goto err_free_device; + goto err_disable_pdev; } ret =pci_request_regions (pdev,DRV_NAME );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 318/606 ALSA: hwdep: fix a left shifting 1 by 31 UB bug
In reply to Sasha LevinFrom: Changming Liu <[email protected]>
[ Upstream commit fb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e ]
The "info.index" variable can be 31 in "1 << info.index". This might trigger an undefined behavior since 1 is signed.
Fix this by casting 1 to 1u just to be sure "1u << 31" is defined.
--- sound/core/hwdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/hwdep.c +2 -2
@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,if (info.index >=32 )return -EINVAL ;/* check whether the dsp was already loaded */ -if (hw->dsp_loaded & (1 << info.index)) +if (hw->dsp_loaded & (1u << info.index))return -EBUSY ; err = hw->ops.dsp_load (hw, &info);if (err <0 )return err; - hw->dsp_loaded |= (1 << info.index); + hw->dsp_loaded |= (1u << info.index);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 319/606 ALSA: hda/realtek - Add a model for Thinkpad T570 without DAC workaround
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 399c01aa49e548c82d40f8161915a5941dd3c60e ]
We fixed the regression of the speaker volume for some Thinkpad models (e.g. T570) by the commit 54947cd64c1b ("ALSA: hda/realtek - Fix speaker output regression on Thinkpad T570"). Essentially it fixes the DAC / pin pairing by a static table. It was confirmed and merged to stable kernel later.
Now, interestingly, we got another regression report for the very same model (T570) about the similar problem, and the commit above was the culprit. That is, by some reason, there are devices that prefer the DAC1, and another device DAC2!
Unfortunately those have the same ID and we have no idea what can differentiate, in this patch, a new fixup model "tpt470-dock-fix" is provided, so that users with such a machine can apply it manually. When model=tpt470-dock-fix option is passed to snd-hda-intel module, it avoids the fixed DAC pairing and the DAC1 is assigned to the speaker like the earlier versions.
--- sound/pci/hda/patch_realtek.c | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
sound/pci/hda/patch_realtek.c +26 -10
@@ -5484,18 +5484,9 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec, { 0x19, 0x21a11010 }, /* dock mic */ { } }; -/* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise -* the speaker output becomes too low by some reason on Thinkpads with -* ALC298 codec -*/ -static const hda_nid_t preferred_pairs[] = { -0x14 ,0x03 ,0x17 ,0x02 ,0x21 ,0x02 , -0 - };struct alc_spec *spec = codec->spec;if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { - spec->gen.preferred_dacs = preferred_pairs; spec->parse_flags =HDA_PINCFG_NO_HP_FIXUP ;snd_hda_apply_pincfgs (codec, pincfgs); }else if (action ==HDA_FIXUP_ACT_INIT ) {
@@ -5508,6 +5499,23 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec, } } +static void alc_fixup_tpt470_dacs (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +/* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise +* the speaker output becomes too low by some reason on Thinkpads with +* ALC298 codec +*/ +static const hda_nid_t preferred_pairs[] = { +0x14 ,0x03 ,0x17 ,0x02 ,0x21 ,0x02 , +0 + }; +struct alc_spec *spec = codec->spec; + +if (action ==HDA_FIXUP_ACT_PRE_PROBE ) + spec->gen.preferred_dacs = preferred_pairs; +} +static void alc_shutup_dell_xps13 (struct hda_codec *codec) {struct alc_spec *spec = codec->spec;
@@ -6063,6 +6071,7 @@ enum {ALC700_FIXUP_INTEL_REFERENCE ,ALC274_FIXUP_DELL_BIND_DACS ,ALC274_FIXUP_DELL_AIO_LINEOUT_VERB , +ALC298_FIXUP_TPT470_DOCK_FIX ,ALC298_FIXUP_TPT470_DOCK ,ALC255_FIXUP_DUMMY_LINEOUT_VERB , ALC255_FIXUP_DELL_HEADSET_MIC,
@@ -6994,12 +7003,18 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC274_FIXUP_DELL_BIND_DACS }, - [ALC298_FIXUP_TPT470_DOCK] = { + [ALC298_FIXUP_TPT470_DOCK_FIX] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_tpt470_dock, .chained = true, .chain_id =ALC293_FIXUP_LENOVO_SPK_NOISE }, + [ALC298_FIXUP_TPT470_DOCK] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc_fixup_tpt470_dacs, + .chained = true, + .chain_id =ALC298_FIXUP_TPT470_DOCK_FIX + }, [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl []) {
@@ -7638,6 +7653,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"}, {.id = ALC292_FIXUP_TPT440, .name = "tpt440"}, {.id = ALC292_FIXUP_TPT460, .name = "tpt460"}, + {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"}, {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"}, {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"}, {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 320/606 ALSA: usb-audio: mixer: volume quirk for ESS Technology Asus USB DAC
In reply to Sasha LevinFrom: Chris Chiu <[email protected]>
[ Upstream commit 4020d1ccbe55bdf67b31d718d2400506eaf4b43f ]
The Asus USB DAC is a USB type-C audio dongle for connecting to the headset and headphone. The volume minimum value -23040 which is 0xa600 in hexadecimal with the resolution value 1 indicates this should be endianness issue caused by the firmware bug. Add a volume quirk to fix the volume control problem.
Also fixes this warning:
Warning! Unlikely big volume range (=23040), cval->res is probably wrong.
[5] FU [Headset Capture Volume] ch = 1, val = -23040/0/1 Warning! Unlikely big volume range (=23040), cval->res is probably wrong.
[7] FU [Headset Playback Volume] ch = 1, val = -23040/0/1
--- sound/usb/mixer.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/usb/mixer.c +8 -0
@@ -1171,6 +1171,14 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, cval->res =384 ; }break ; +case USB_ID (0x0495 ,0x3042 ):/* ESS Technology Asus USB DAC */ +if ((strstr (kctl->id.name,"Playback Volume" ) !=NULL ) || +strstr (kctl->id.name,"Capture Volume" ) !=NULL ) { + cval->min >>=8 ; + cval->max =0 ; + cval->res =1 ; + } +break ; } }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 321/606 exec: Always set cap_ambient in cap_bprm_set_creds
In reply to Sasha LevinFrom: "Eric W. Biederman" <[email protected]>
[ Upstream commit a4ae32c71fe90794127b32d26d7ad795813b502e ]
An invariant of cap_bprm_set_creds is that every field in the new cred structure that cap_bprm_set_creds might set, needs to be set every time to ensure the fields does not get a stale value.
The field cap_ambient is not set every time cap_bprm_set_creds is called, which means that if there is a suid or sgid script with an interpreter that has neither the suid nor the sgid bits set the interpreter should be able to accept ambient credentials. Unfortuantely because cap_ambient is not reset to it's original value the interpreter can not accept ambient credentials.
Given that the ambient capability set is expected to be controlled by the caller, I don't think this is particularly serious. But it is definitely worth fixing so the code works correctly.
I have tested to verify my reading of the code is correct and the interpreter of a sgid can receive ambient capabilities with this change and cannot receive ambient capabilities without this change.
--- security/commoncap.c | 1 + 1 file changed, 1 insertion(+)
security/commoncap.c +1 -0
@@ -812,6 +812,7 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)int ret;kuid_t root_uid; + new->cap_ambient = old->cap_ambient;if (WARN_ON (!cap_ambient_invariant_ok (old)))return -EPERM ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 322/606 clk: qcom: gcc: Fix parent for gpll0_out_even
In reply to Sasha LevinFrom: Vinod Koul <[email protected]>
[ Upstream commit a76f274182f054481182c81cd62bb8794a5450a6 ]
Documentation says that gpll0 is parent of gpll0_out_even, somehow driver coded that as bi_tcxo, so fix it
--- drivers/clk/qcom/gcc-sm8150.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8150.c +1 -2
@@ -75,8 +75,7 @@ static struct clk_alpha_pll_postdiv gpll0_out_even = { .clkr.hw.init = &(struct clk_init_data){ .name ="gpll0_out_even" , .parent_data = &(const struct clk_parent_data ){ - .fw_name ="bi_tcxo" , - .name ="bi_tcxo" , + .hw = &gpll0.clkr.hw, }, .num_parents =1 , .ops = &clk_trion_pll_postdiv_ops,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 323/606 ALSA: usb-audio: Quirks for Gigabyte TRX40 Aorus Master onboard audio
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 7f5ad9c9003425175f46c94df380e8c9e558cfb5 ]
Gigabyte TRX40 Aorus Master is equipped with two USB-audio devices, a Realtek ALC1220-VB codec (USB ID 0414:a001) and an ESS SABRE9218 DAC (USB ID 0414:a000). The latter serves solely for the headphone output on the front panel while the former serves for the rest I/Os (mostly for the I/Os in the rear panel but also including the front mic).
Both chips do work more or less with the unmodified USB-audio driver, but there are a few glitches. The ALC1220-VB returns an error for an inquiry to some jacks, as already seen on other TRX40-based mobos. However this machine has a slightly incompatible configuration, hence the existing mapping cannot be used as is.
Meanwhile the ESS chip seems working without any quirk. But since both audio devices don't provide any specific names, both cards appear as "USB-Audio", and it's quite confusing for users.
This patch is an attempt to overcome those issues:
- The specific mapping table for ALC1220-VB is provided, reducing the non-working nodes and renaming the badly chosen controls. The connector map isn't needed here unlike other TRX40 quirks.
- For both USB IDs (0414:a000 and 0414:a001), provide specific card name strings, so that user-space can identify more easily; and more importantly, UCM profile can be applied to each.
--- sound/usb/mixer_maps.c | 19 +++++++++++++++++++ sound/usb/quirks-table.h | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
sound/usb/mixer_maps.c +19 -0
@@ -397,6 +397,21 @@ static const struct usbmix_connector_map trx40_mobo_connector_map[] = { {} }; +/* Rear panel + front mic on Gigabyte TRX40 Aorus Master with ALC1220-VB */ +static const struct usbmix_name_map aorus_master_alc1220vb_map[] = { + {17 ,NULL },/* OT, IEC958?, disabled */ + {19 ,NULL ,12 },/* FU, Input Gain Pad - broken response, disabled */ + {16 ,"Line Out" },/* OT */ + {22 ,"Line Out Playback" },/* FU */ + {7 ,"Line" },/* IT */ + {19 ,"Line Capture" },/* FU */ + {8 ,"Mic" },/* IT */ + {20 ,"Mic Capture" },/* FU */ + {9 ,"Front Mic" },/* IT */ + {21 ,"Front Mic Capture" },/* FU */ + {} +}; +/* * Control map entries */
@@ -526,6 +541,10 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .id = USB_ID(0x1b1c, 0x0a42), .map = corsair_virtuoso_map, }, + {/* Gigabyte TRX40 Aorus Master (rear panel + front mic) */ + .id = USB_ID(0x0414, 0xa001), + .map = aorus_master_alc1220vb_map, + }, {/* Gigabyte TRX40 Aorus Pro WiFi */ .id = USB_ID(0x0414, 0xa002), .map = trx40_mobo_map,
sound/usb/quirks-table.h +25 -0
@@ -3650,4 +3650,29 @@ ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */#undef ALC1220_VB_DESKTOP +/* Two entries for Gigabyte TRX40 Aorus Master: +* TRX40 Aorus Master has two USB-audio devices, one for the front headphone +* with ESS SABRE9218 DAC chip, while another for the rest I/O (the rear +* panel and the front mic) with Realtek ALC1220-VB. +* Here we provide two distinct names for making UCM profiles easier. +*/ +{ + USB_DEVICE(0x0414, 0xa000), + .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + .vendor_name ="Gigabyte" , + .product_name ="Aorus Master Front Headphone" , + .profile_name ="Gigabyte-Aorus-Master-Front-Headphone" , + .ifnum =QUIRK_NO_INTERFACE + } +}, +{ + USB_DEVICE(0x0414, 0xa001), + .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + .vendor_name ="Gigabyte" , + .product_name ="Aorus Master Main Audio" , + .profile_name ="Gigabyte-Aorus-Master-Main-Audio" , + .ifnum =QUIRK_NO_INTERFACE + } +}, + #undef USB_DEVICE_VENDOR_SPEC
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 324/606 ALSA: hda/realtek - Add new codec supported for ALC287
In reply to Sasha LevinFrom: Kailang Yang <[email protected]>
[ Upstream commit 630e36126e420e1756378b3427b42711ce0b9ddd ]
Enable new codec supported for ALC287.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -384,6 +384,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)case 0x10ec0282 :case 0x10ec0283 :case 0x10ec0286 : +case 0x10ec0287 :case 0x10ec0288 :case 0x10ec0285 :case 0x10ec0298 :
@@ -8292,6 +8293,7 @@ static int patch_alc269(struct hda_codec *codec)case 0x10ec0215 :case 0x10ec0245 :case 0x10ec0285 : +case 0x10ec0287 :case 0x10ec0289 : spec->codec_variant =ALC269_TYPE_ALC215 ; spec->shutup = alc225_shutup;
@@ -9570,6 +9572,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {HDA_CODEC_ENTRY (0x10ec0284 ,"ALC284" , patch_alc269),HDA_CODEC_ENTRY (0x10ec0285 ,"ALC285" , patch_alc269),HDA_CODEC_ENTRY (0x10ec0286 ,"ALC286" , patch_alc269), +HDA_CODEC_ENTRY (0x10ec0287 ,"ALC287" , patch_alc269),HDA_CODEC_ENTRY (0x10ec0288 ,"ALC288" , patch_alc269),HDA_CODEC_ENTRY (0x10ec0289 ,"ALC289" , patch_alc269), HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
Signature · 1 line
2.25.1