staging: wimax/i2400m: fix byte-order issue
Subsystems (9)
Sasha Levin
maintainerPATCH 1/10 staging: wimax/i2400m: fix byte-order issue
From: karthik alapati <[email protected]>
[ Upstream commit 0c37baae130df39b19979bba88bde2ee70a33355 ]
fix sparse byte-order warnings by converting host byte-order type to __le16 byte-order types before assigning to hdr.length
--- drivers/net/wimax/i2400m/op-rfkill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wimax/i2400m/op-rfkill.c +1 -1
@@ -101,7 +101,7 @@ int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,if (cmd ==NULL ) goto error_alloc; cmd->hdr.type =cpu_to_le16 (I2400M_MT_CMD_RF_CONTROL ); - cmd->hdr.length =sizeof (cmd->sw_rf); + cmd->hdr.length =cpu_to_le16 (sizeof (cmd->sw_rf)); cmd->hdr.version =cpu_to_le16 (I2400M_L3L4_VERSION ); cmd->sw_rf.hdr.type =cpu_to_le16 (I2400M_TLV_RF_OPERATION ); cmd->sw_rf.hdr.length =cpu_to_le16 (sizeof (cmd->sw_rf.status));
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/10 usb: gadget: uvc: add bInterval checking for HS mode
From: Pawel Laszczak <[email protected]>
[ Upstream commit 26adde04acdff14a1f28d4a5dce46a8513a3038b ]
Patch adds extra checking for bInterval passed by configfs. The 5.6.4 chapter of USB Specification (rev. 2.0) say:
"A high-bandwidth endpoint must specify a period of 1x125 µs (i.e., a bInterval value of 1)."
The issue was observed during testing UVC class on CV. I treat this change as improvement because we can control bInterval by configfs.
--- drivers/usb/gadget/function/f_uvc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_uvc.c +6 -1
@@ -625,7 +625,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc_hs_streaming_ep.wMaxPacketSize =cpu_to_le16 (max_packet_size | ((max_packet_mult -1 ) <<11 )); - uvc_hs_streaming_ep.bInterval = opts->streaming_interval; + +/* A high-bandwidth endpoint must specify a bInterval value of 1 */ +if (max_packet_mult >1 ) + uvc_hs_streaming_ep.bInterval =1 ; +else + uvc_hs_streaming_ep.bInterval = opts->streaming_interval; uvc_ss_streaming_ep.wMaxPacketSize =cpu_to_le16 (max_packet_size); uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/10 PCI: PM: Do not read power state in pci_enable_device_flags()
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 4514d991d99211f225d83b7e640285f29f0755d0 ]
It should not be necessary to update the current_state field of struct pci_dev in pci_enable_device_flags() before calling do_pci_enable_device() for the device, because none of the code between that point and the pci_set_power_state() call in do_pci_enable_device() invoked later depends on it.
Moreover, doing that is actively harmful in some cases. For example, if the given PCI device depends on an ACPI power resource whose _STA method initially returns 0 ("off"), but the config space of the PCI device is accessible and the power state retrieved from the PCI_PM_CTRL register is D0, the current_state field in the struct pci_dev representing that device will get out of sync with the power.state of its ACPI companion object and that will lead to power management issues going forward.
To avoid such issues it is better to leave the current_state value as is until it is changed to PCI_D0 by do_pci_enable_device() as appropriate. However, the power state of the device is not changed to PCI_D0 if it is already enabled when pci_enable_device_flags() gets called for it, so update its current_state in that case, but use pci_update_current_state() covering platform PM too for that.
--- drivers/pci/pci.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/pci/pci.c +3 -13
@@ -1328,20 +1328,10 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)int err;int i, bars =0 ; -/* -* Power state could be unknown at this point, either due to a fresh -* boot or a device removal call. So get the current power state -* so that things like MSI message writing will behave as expected -* (e.g. if the device really is in D0 at enable time). -*/ -if (dev->pm_cap) { -u16 pmcsr; -pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr); - dev->current_state = (pmcsr &PCI_PM_CTRL_STATE_MASK ); - } - -if (atomic_inc_return (&dev->enable_cnt) >1 ) +if (atomic_inc_return (&dev->enable_cnt) >1 ) { +pci_update_current_state (dev, dev->current_state);return 0 ;/* already enabled */ + } bridge =pci_upstream_bridge (dev);if (bridge)
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/10 x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS)
In reply to Sasha LevinFrom: John Millikin <[email protected]>
[ Upstream commit 8abe7fc26ad8f28bfdf78adbed56acd1fa93f82d ]
When cross-compiling with Clang, the $(CLANG_FLAGS)' variable contains additional flags needed to build C and assembly sources for the target platform. Normally this variable is automatically included in $(KBUILD_CFLAGS)' via the top-level Makefile.
The x86 real-mode makefile builds `$(REALMODE_CFLAGS)' from a plain assignment and therefore drops the Clang flags. This causes Clang to not recognize x86-specific assembler directives:
arch/x86/realmode/rm/header.S:36:1: error: unknown directive .type real_mode_header STT_OBJECT ; .size real_mode_header, .-real_mode_header ^
Explicit propagation of $(CLANG_FLAGS)' to $(REALMODE_CFLAGS)', which is inherited by real-mode make rules, fixes cross-compilation with Clang for x86 targets.
Relevant flags:
* --target' sets the target architecture when cross-compiling. This flag must be set for both compilation and assembly (KBUILD_AFLAGS') to support architecture-specific assembler directives.
* -no-integrated-as' tells clang to assemble with GNU Assembler instead of its built-in LLVM assembler. This flag is set by default unless LLVM_IAS=1' is set, because the LLVM assembler can't yet parse certain GNU extensions.
--- arch/x86/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/x86/Makefile +1 -0
@@ -40,6 +40,7 @@ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4)) +REALMODE_CFLAGS += $(CLANG_FLAGS) export REALMODE_CFLAGS # BITS is used as extension for files which are available in a 32 bit
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/10 spi: dln2: Fix reference leak to master
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
[ Upstream commit 9b844b087124c1538d05f40fda8a4fec75af55be ]
Call spi_master_get() holds the reference count to master device, thus we need an additional spi_master_put() call to reduce the reference count, otherwise we will leak a reference to master.
This commit fix it by removing the unnecessary spi_master_get().
--- drivers/spi/spi-dln2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dln2.c +1 -1
@@ -781,7 +781,7 @@ static int dln2_spi_probe(struct platform_device *pdev)static int dln2_spi_remove (struct platform_device *pdev) { -struct spi_master *master =spi_master_get (platform_get_drvdata (pdev)); +struct spi_master *master =platform_get_drvdata (pdev);struct dln2_spi *dln2 =spi_master_get_devdata (master);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 6/10 spi: omap-100k: Fix reference leak to master
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
[ Upstream commit a23faea76d4cf5f75decb574491e66f9ecd707e7 ]
Call spi_master_get() holds the reference count to master device, thus we need an additional spi_master_put() call to reduce the reference count, otherwise we will leak a reference to master.
This commit fix it by removing the unnecessary spi_master_get().
--- drivers/spi/spi-omap-100k.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-omap-100k.c +3 -3
@@ -435,7 +435,7 @@ static int omap1_spi100k_probe(struct platform_device *pdev)static int omap1_spi100k_remove (struct platform_device *pdev) { -struct spi_master *master =spi_master_get (platform_get_drvdata (pdev)); +struct spi_master *master =platform_get_drvdata (pdev);struct omap1_spi100k *spi100k =spi_master_get_devdata (master);pm_runtime_disable (&pdev->dev);
@@ -449,7 +449,7 @@ static int omap1_spi100k_remove(struct platform_device *pdev)#ifdef CONFIG_PM static int omap1_spi100k_runtime_suspend (struct device *dev) { -struct spi_master *master =spi_master_get (dev_get_drvdata (dev)); +struct spi_master *master =dev_get_drvdata (dev);struct omap1_spi100k *spi100k =spi_master_get_devdata (master);clk_disable_unprepare (spi100k->ick);
@@ -460,7 +460,7 @@ static int omap1_spi100k_runtime_suspend(struct device *dev)static int omap1_spi100k_runtime_resume (struct device *dev) { -struct spi_master *master =spi_master_get (dev_get_drvdata (dev)); +struct spi_master *master =dev_get_drvdata (dev);struct omap1_spi100k *spi100k =spi_master_get_devdata (master);int ret;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/10 platform/x86: thinkpad_acpi: Correct thermal sensor allocation
In reply to Sasha LevinFrom: Mark Pearson <[email protected]>
[ Upstream commit 6759e18e5cd8745a5dfc5726e4a3db5281ec1639 ]
On recent Thinkpad platforms it was reported that temp sensor 11 was always incorrectly displaying 66C. It turns out the reason for this is that this location in EC RAM is not a temperature sensor but is the power supply ID (offset 0xC2).
Based on feedback from the Lenovo firmware team the EC RAM version can be determined and for the current version (3) only the 0x78 to 0x7F range is used for temp sensors. I don't have any details for earlier versions so I have left the implementation unaltered there.
Note - in this block only 0x78 and 0x79 are officially designated (CPU & GPU sensors). The use of the other locations in the block will vary from platform to platform; but the existing logic to detect a sensor presence holds.
--- drivers/platform/x86/thinkpad_acpi.c | 31 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +22 -9
@@ -5766,6 +5766,7 @@ enum thermal_access_mode {enum {/* TPACPI_THERMAL_TPEC_* */ TP_EC_THERMAL_TMP0 =0x78 ,/* ACPI EC regs TMP 0..7 */ TP_EC_THERMAL_TMP8 =0xC0 ,/* ACPI EC regs TMP 8..15 */ +TP_EC_FUNCREV =0xEF ,/* ACPI EC Functional revision */ TP_EC_THERMAL_TMP_NA =-128 ,/* ACPI EC sensor not available */ TPACPI_THERMAL_SENSOR_NA =-128000 ,/* Sensor not available */
@@ -5964,7 +5965,7 @@ static const struct attribute_group thermal_temp_input8_group = {static int __init thermal_init (struct ibm_init_struct *iibm) { -u8 t, ta1, ta2; +u8 t, ta1, ta2, ver =0 ;int i;int acpi_tmp7;int res;
@@ -5979,7 +5980,14 @@ static int __init thermal_init(struct ibm_init_struct *iibm)* 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for * non-implemented, thermal sensors return 0x80 when * not available +* The above rule is unfortunately flawed. This has been seen with +* 0xC2 (power supply ID) causing thermal control problems. +* The EC version can be determined by offset 0xEF and at least for +* version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 +* are not thermal registers. */ +if (!acpi_ec_read (TP_EC_FUNCREV , &ver)) +pr_warn ("Thinkpad ACPI EC unable to access EC version\n" ); ta1 = ta2 =0 ;for (i =0 ; i <8 ; i++) {
@@ -5989,11 +5997,13 @@ static int __init thermal_init(struct ibm_init_struct *iibm) ta1 =0 ;break ; } -if (acpi_ec_read (TP_EC_THERMAL_TMP8 + i, &t)) { - ta2 |= t; - }else { - ta1 =0 ; -break ; +if (ver <3 ) { +if (acpi_ec_read (TP_EC_THERMAL_TMP8 + i, &t)) { + ta2 |= t; + }else { + ta1 =0 ; +break ; + } } }if (ta1 ==0 ) {
@@ -6009,9 +6019,12 @@ static int __init thermal_init(struct ibm_init_struct *iibm) thermal_read_mode =TPACPI_THERMAL_NONE ; } }else { - thermal_read_mode = - (ta2 !=0 ) ? -TPACPI_THERMAL_TPEC_16 :TPACPI_THERMAL_TPEC_8 ; +if (ver >=3 ) + thermal_read_mode =TPACPI_THERMAL_TPEC_8 ; +else + thermal_read_mode = + (ta2 !=0 ) ? +TPACPI_THERMAL_TPEC_16 :TPACPI_THERMAL_TPEC_8 ; } }else if (acpi_tmp7) { if (tpacpi_is_ibm() &&
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 8/10 intel_th: Consistency and off-by-one fix
In reply to Sasha LevinFrom: Pavel Machek <[email protected]>
[ Upstream commit 18ffbc47d45a1489b664dd68fb3a7610a6e1dea3 ]
Consistently use "< ... +1" in for loops.
Fix of-by-one in for_each_set_bit().
--- drivers/hwtracing/intel_th/gth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwtracing/intel_th/gth.c +2 -2
@@ -485,7 +485,7 @@ static void intel_th_gth_disable(struct intel_th_device *thdev, output->active = false;for_each_set_bit (master, gth->output[output->port].master, -TH_CONFIGURABLE_MASTERS ) { +TH_CONFIGURABLE_MASTERS +1 ) {gth_master_set (gth, master,-1 ); }spin_unlock (>h->gth_lock);
@@ -597,7 +597,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev, othdev->output.port =-1 ; othdev->output.active = false; gth->output[port].output =NULL ; -for (master =0 ; master <=TH_CONFIGURABLE_MASTERS ; master++) +for (master =0 ; master <TH_CONFIGURABLE_MASTERS +1 ; master++)if (gth->master[master] == port) gth->master[master] =-1 ;spin_unlock (>h->gth_lock);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 9/10 phy: phy-twl4030-usb: Fix possible use-after-free in twl4030_usb_remove()
In reply to Sasha LevinFrom: Yang Yingliang <[email protected]>
[ Upstream commit e1723d8b87b73ab363256e7ca3af3ddb75855680 ]
This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This means that the callback function may still be running after the driver's remove function has finished, which would result in a use-after-free.
Fix by calling cancel_delayed_work_sync(), which ensures that the work is properly cancelled, no longer running, and unable to re-schedule itself.
--- drivers/phy/phy-twl4030-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-twl4030-usb.c +1 -1
@@ -753,7 +753,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)usb_remove_phy (&twl->phy);pm_runtime_get_sync (twl->dev); -cancel_delayed_work (&twl->id_workaround_work); +cancel_delayed_work_sync (&twl->id_workaround_work);device_remove_file (twl->dev, &dev_attr_vbus);/* set transceiver mode to power on defaults */
Signature · 7 lines
2.30.2 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Sasha Levin
maintainerPATCH 10/10 btrfs: convert logic BUG_ON()'s in replace_path to ASSERT()'s
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit 7a9213a93546e7eaef90e6e153af6b8fc7553f10 ]
A few BUG_ON()'s in replace_path are purely to keep us from making logical mistakes, so replace them with ASSERT()'s.
--- fs/btrfs/relocation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/relocation.c +3 -3
@@ -1785,8 +1785,8 @@ int replace_path(struct btrfs_trans_handle *trans,int ret;int slot; -BUG_ON (src->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ); -BUG_ON (dest->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ); +ASSERT (src->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ); +ASSERT (dest->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ); last_snapshot =btrfs_root_last_snapshot (&src->root_item); again:
@@ -1818,7 +1818,7 @@ int replace_path(struct btrfs_trans_handle *trans, parent = eb;while (1 ) { level =btrfs_header_level (parent); -BUG_ON (level < lowest_level); +ASSERT (level >= lowest_level); ret =btrfs_bin_search (parent, &key, level, &slot);if (ret && slot >0 )
Signature · 1 line
2.30.2