4.14.185-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 155/190 vga_switcheroo: Use device link for HDA controller
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
[ Upstream commit 07f4f97d7b4bf325d9f558c5b58230387e4e57e0 ]
Back in 2013, runtime PM for GPUs with integrated HDA controller was introduced with commits 0d69704ae348 ("gpu/vga_switcheroo: add driver control power feature. (v3)") and 246efa4a072f ("snd/hda: add runtime suspend/resume on optimus support (v4)").
Briefly, the idea was that the HDA controller is forced on and off in unison with the GPU.
The original code is mostly still in place even though it was never a 100% perfect solution: E.g. on access to the HDA controller, the GPU is powered up via vga_switcheroo_runtime_resume_hdmi_audio() but there are no provisions to keep it resumed until access to the HDA controller has ceased: The GPU autosuspends after 5 seconds, rendering the HDA controller inaccessible.
Additionally, a kludge is required when hda_intel.c probes: It has to check whether the GPU is powered down (check_hdmi_disabled()) and defer probing if so.
However in the meantime (in v4.10) the driver core has gained a feature called device links which promises to solve such issues in a clean way:
It allows us to declare a dependency from the HDA controller (consumer) to the GPU (supplier). The PM core then automagically ensures that the GPU is runtime resumed as long as the HDA controller's ->probe hook is executed and whenever the HDA controller is accessed.
By default, the HDA controller has a dependency on its parent, a PCIe Root Port. Adding a device link creates another dependency on its sibling:
PCIe Root Port
^ ^
| |
| |
HDA ===> GPU
The device link is not only used for runtime PM, it also guarantees that on system sleep, the HDA controller suspends before the GPU and resumes after the GPU, and on system shutdown the HDA controller's ->shutdown hook is executed before the one of the GPU. It is a complete solution.
Using this functionality is as simple as calling device_link_add(), which results in a dmesg entry like this:
pci 0000:01:00.1: Linked as a consumer to 0000:01:00.0
The code for the GPU-governed audio power management can thus be removed (except where it's still needed for legacy manual power control).
The device link is added in a PCI quirk rather than in hda_intel.c. It is therefore legal for the GPU to runtime suspend to D3cold even if the HDA controller is not bound to a driver or if CONFIG_SND_HDA_INTEL is not enabled, for accesses to the HDA controller will cause the GPU to wake up regardless if they're occurring outside of hda_intel.c (think config space readout via sysfs).
Contrary to the previous implementation, the HDA controller's power state is now self-governed, rather than GPU-governed, whereas the GPU's power state is no longer fully self-governed. (The HDA controller needs to runtime suspend before the GPU can.)
It is thus crucial that runtime PM is always activated on the HDA controller even if CONFIG_SND_HDA_POWER_SAVE_DEFAULT is set to 0 (which is the default), lest the GPU stays awake. This is achieved by setting the auto_runtime_pm flag on every codec and the AZX_DCAPS_PM_RUNTIME flag on the HDA controller.
A side effect is that power consumption might be reduced if the GPU is in use but the HDA controller is not, because the HDA controller is now allowed to go to D3hot. Before, it was forced to stay in D0 as long as the GPU was in use. (There is no reduction in power consumption on my Nvidia GK107, but there might be on other chips.)
The code paths for legacy manual power control are adjusted such that runtime PM is disabled during power off, thereby preventing the PM core from resuming the HDA controller.
Note that the device link is not only added on vga_switcheroo capable systems, but for *any* GPU with integrated HDA controller. The idea is that the HDA controller streams audio via connectors located on the GPU, so the GPU needs to be on for the HDA controller to do anything useful.
This commit implicitly fixes an unbalanced runtime PM ref upon unbind of hda_intel.c: On ->probe, a runtime PM ref was previously released under the condition "azx_has_pm_runtime(chip) || hda->use_vga_switcheroo", but on ->remove a runtime PM ref was only acquired under the first of those conditions. Thus, binding and unbinding the driver twice on a vga_switcheroo capable system caused the runtime PM refcount to drop below zero. The issue is resolved because the AZX_DCAPS_PM_RUNTIME flag is now always set if use_vga_switcheroo is true.
For more information on device links please refer to:
https://www.kernel.org/doc/html/latest/driver-api/device_link.htmlDocumentation/driver-api/device_link.rst
Tested-by: Mike Lothian <[email protected]> # AMD PowerXpress Tested-by: Denis Lisov <[email protected]> # Nvidia Optimus Tested-by: Peter Wu <[email protected]> # Nvidia Optimus Tested-by: Lukas Wunner <[email protected]> # MacBook Pro
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 - drivers/gpu/drm/nouveau/nouveau_drm.c | 2 - drivers/gpu/drm/radeon/radeon_drv.c | 2 - drivers/gpu/vga/vga_switcheroo.c | 115 ++---------------------- drivers/pci/quirks.c | 39 ++++++++ include/linux/pci_ids.h | 1 + include/linux/vga_switcheroo.h | 6 -- include/sound/hdaudio.h | 3 - sound/pci/hda/hda_intel.c | 35 +++++--- sound/pci/hda/hda_intel.h | 3 - 10 files changed, 72 insertions(+), 136 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
@@ -728,7 +728,6 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_OFF ); ret =amdgpu_device_suspend (drm_dev, false, false);pci_save_state (pdev);
@@ -765,7 +764,6 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) ret =amdgpu_device_resume (drm_dev, false, false);drm_kms_helper_poll_enable (drm_dev); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_ON ); drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ;return 0 ; }
drivers/gpu/drm/nouveau/nouveau_drm.c +0 -2
@@ -754,7 +754,6 @@ nouveau_pmops_runtime_suspend(struct device *dev) }drm_kms_helper_poll_disable (drm_dev); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_OFF );nouveau_switcheroo_optimus_dsm (); ret =nouveau_do_suspend (drm_dev, true);pci_save_state (pdev);
@@ -789,7 +788,6 @@ nouveau_pmops_runtime_resume(struct device *dev)/* do magic */ nvif_mask (&device->object,0x088488 , (1 <<25 ), (1 <<25 )); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_ON ); drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ;/* Monitors may have been connected / disconnected during suspend */
drivers/gpu/drm/radeon/radeon_drv.c +0 -2
@@ -424,7 +424,6 @@ static int radeon_pmops_runtime_suspend(struct device *dev) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_OFF ); ret =radeon_suspend_kms (drm_dev, false, false, false);pci_save_state (pdev);
@@ -461,7 +460,6 @@ static int radeon_pmops_runtime_resume(struct device *dev) ret =radeon_resume_kms (drm_dev, false, false);drm_kms_helper_poll_enable (drm_dev); -vga_switcheroo_set_dynamic_switch (pdev,VGA_SWITCHEROO_ON ); drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ;return 0 ; }
drivers/gpu/vga/vga_switcheroo.c +8 -107
161 lines not on this page · raw message
drivers/pci/quirks.c +39 -0
@@ -27,6 +27,7 @@#include <linux/ktime.h> #include <linux/mm.h> #include <linux/platform_data/x86/apple.h> +#include <linux/pm_runtime.h> #include <asm/dma.h> /* isa_dma_bridge_buggy */ #include "pci.h"
@@ -4952,3 +4953,41 @@ static void quirk_fsl_no_msi(struct pci_dev *pdev) pdev->no_msi =1 ; }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_FREESCALE ,PCI_ANY_ID , quirk_fsl_no_msi); + +/* +* GPUs with integrated HDA controller for streaming audio to attached displays +* need a device link from the HDA controller (consumer) to the GPU (supplier) +* so that the GPU is powered up whenever the HDA controller is accessed. +* The GPU and HDA controller are functions 0 and 1 of the same PCI device. +* The device link stays in place until shutdown (or removal of the PCI device +* if it's hotplugged). Runtime PM is allowed by default on the HDA controller +* to prevent it from permanently keeping the GPU awake. +*/ +static void quirk_gpu_hda (struct pci_dev *hda) +{ +struct pci_dev *gpu; + +if (PCI_FUNC (hda->devfn) !=1 ) +return ; + + gpu =pci_get_domain_bus_and_slot (pci_domain_nr (hda->bus), + hda->bus->number, +PCI_DEVFN (PCI_SLOT (hda->devfn),0 )); +if (!gpu || (gpu->class >>16 ) !=PCI_BASE_CLASS_DISPLAY ) { +pci_dev_put (gpu); +return ; + } + +if (!device_link_add (&hda->dev, &gpu->dev, +DL_FLAG_STATELESS |DL_FLAG_PM_RUNTIME )) +pci_err (hda,"cannot link HDA to GPU %s\n" ,pci_name (gpu)); + +pm_runtime_allow (&hda->dev); +pci_dev_put (gpu); +} +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_MULTIMEDIA_HD_AUDIO ,8 , quirk_gpu_hda); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_AMD ,PCI_ANY_ID , +PCI_CLASS_MULTIMEDIA_HD_AUDIO ,8 , quirk_gpu_hda); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID , +PCI_CLASS_MULTIMEDIA_HD_AUDIO ,8 , quirk_gpu_hda);
include/linux/pci_ids.h +1 -0
@@ -45,6 +45,7 @@#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 +#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480#define PCI_BASE_CLASS_MEMORY 0x05
include/linux/vga_switcheroo.h +0 -6
@@ -168,11 +168,8 @@ int vga_switcheroo_process_delayed_switch(void);bool vga_switcheroo_client_probe_defer (struct pci_dev *pdev);enum vga_switcheroo_state vga_switcheroo_get_client_state (struct pci_dev *dev); -void vga_switcheroo_set_dynamic_switch (struct pci_dev *pdev,enum vga_switcheroo_state dynamic); -int vga_switcheroo_init_domain_pm_ops (struct device *dev,struct dev_pm_domain *domain);void vga_switcheroo_fini_domain_pm_ops (struct device *dev); -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio (struct device *dev,struct dev_pm_domain *domain);#else static inline void vga_switcheroo_unregister_client (struct pci_dev *dev) {}
@@ -192,11 +189,8 @@ static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }static inline bool vga_switcheroo_client_probe_defer (struct pci_dev *pdev) {return false; }static inline enum vga_switcheroo_state vga_switcheroo_get_client_state (struct pci_dev *dev) {return VGA_SWITCHEROO_ON ; } -static inline void vga_switcheroo_set_dynamic_switch (struct pci_dev *pdev,enum vga_switcheroo_state dynamic) {} -static inline int vga_switcheroo_init_domain_pm_ops (struct device *dev,struct dev_pm_domain *domain) {return -EINVAL ; }static inline void vga_switcheroo_fini_domain_pm_ops (struct device *dev) {} -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio (struct device *dev,struct dev_pm_domain *domain) {return -EINVAL ; }#endif #endif /* _LINUX_VGA_SWITCHEROO_H_ */
include/sound/hdaudio.h +0 -3
@@ -228,9 +228,6 @@ struct hdac_io_ops {#define HDA_UNSOL_QUEUE_SIZE 64#define HDA_MAX_CODECS 8/* limit by controller side */ -/* HD Audio class code */ -#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403 -/* * CORB/RIRB *
sound/pci/hda/hda_intel.c +24 -11
@@ -1282,6 +1282,7 @@ static void azx_vs_set_state(struct pci_dev *pci,struct snd_card *card =pci_get_drvdata (pci);struct azx *chip = card->private_data; struct hda_intel *hda = container_of(chip, struct hda_intel, chip); +struct hda_codec *codec;bool disabled;wait_for_completion (&hda->probe_wait);
@@ -1306,8 +1307,12 @@ static void azx_vs_set_state(struct pci_dev *pci,dev_info (chip->card->dev,"%s via vga_switcheroo\n" , disabled ?"Disabling" :"Enabling" );if (disabled) { -pm_runtime_put_sync_suspend (card->dev); -azx_suspend (card->dev); +list_for_each_codec (codec, &chip->bus) { +pm_runtime_suspend (hda_codec_dev (codec)); +pm_runtime_disable (hda_codec_dev (codec)); + } +pm_runtime_suspend (card->dev); +pm_runtime_disable (card->dev);/* when we get suspended by vga_switcheroo we end up in D3cold, * however we have no ACPI handle, so pci/acpi can't put us there, * put ourselves there */
@@ -1318,9 +1323,12 @@ static void azx_vs_set_state(struct pci_dev *pci, "Cannot lock devices!\n"); }else {snd_hda_unlock_devices (&chip->bus); -pm_runtime_get_noresume (card->dev); chip->disabled = false; -azx_resume (card->dev); +pm_runtime_enable (card->dev); +list_for_each_codec (codec, &chip->bus) { +pm_runtime_enable (hda_codec_dev (codec)); +pm_runtime_resume (hda_codec_dev (codec)); + } } } }
@@ -1350,6 +1358,7 @@ static void init_vga_switcheroo(struct azx *chip)dev_info (chip->card->dev,"Handle vga_switcheroo audio client\n" ); hda->use_vga_switcheroo =1 ; + chip->driver_caps |=AZX_DCAPS_PM_RUNTIME ;pci_dev_put (p); } }
@@ -1375,9 +1384,6 @@ static int register_vga_switcheroo(struct azx *chip)return err; hda->vga_switcheroo_registered =1 ; -/* register as an optimus hdmi audio power domain */ -vga_switcheroo_init_domain_pm_optimus_hdmi_audio (chip->card->dev, - &hda->hdmi_pm_domain); return 0; }#else
@@ -1406,10 +1412,8 @@ static int azx_free(struct azx *chip)if (use_vga_switcheroo (hda)) {if (chip->disabled && hda->probe_continued)snd_hda_unlock_devices (&chip->bus); -if (hda->vga_switcheroo_registered) { +if (hda->vga_switcheroo_registered)vga_switcheroo_unregister_client (chip->pci); -vga_switcheroo_fini_domain_pm_ops (chip->card->dev); - } }if (bus->chip_init) {
@@ -2301,6 +2305,7 @@ static int azx_probe_continue(struct azx *chip) struct hda_intel *hda = container_of(chip, struct hda_intel, chip);struct hdac_bus *bus =azx_bus (chip);struct pci_dev *pci = chip->pci; +struct hda_codec *codec;int dev = chip->dev_index;int val;int err;
@@ -2385,6 +2390,14 @@ static int azx_probe_continue(struct azx *chip) chip->running =1 ;azx_add_card_list (chip); +/* +* The discrete GPU cannot power down unless the HDA controller runtime +* suspends, so activate runtime PM on codecs even if power_save == 0. +*/ +if (use_vga_switcheroo (hda)) +list_for_each_codec (codec, &chip->bus) + codec->auto_runtime_pm =1 ; + val = power_save;#ifdef CONFIG_PM if (pm_blacklist) {
@@ -2399,7 +2412,7 @@ static int azx_probe_continue(struct azx *chip) }#endif /* CONFIG_PM */ snd_hda_set_power_save (&chip->bus, val *1000 ); -if (azx_has_pm_runtime (chip) || hda->use_vga_switcheroo) +if (azx_has_pm_runtime (chip))pm_runtime_put_autosuspend (&pci->dev); out_free:
sound/pci/hda/hda_intel.h +0 -3
@@ -40,9 +40,6 @@ struct hda_intel { unsigned int vga_switcheroo_registered:1; unsigned int init_failed:1; /* delayed init failed */ -/* secondary power domain for hdmi audio under vga device */ -struct dev_pm_domain hdmi_pm_domain; - bool need_i915_power:1; /* the hda controller needs i915 power */ };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 156/190 PCI: Generalize multi-function power dependency device links
In reply to Greg Kroah-HartmanFrom: Abhishek Sahu <[email protected]>
[ Upstream commit a17beb1a0882a544523dcb5d0da4801272dfd43a ]
Although not allowed by the PCI specs, some multi-function devices have power dependencies between the functions. For example, function 1 may not work unless function 0 is in the D0 power state.
The existing quirk_gpu_hda() adds a device link to express this dependency for GPU and HDA devices, but it really is not specific to those device types.
Generalize it and rename it to pci_create_device_link() so we can create dependencies between any "consumer" and "producer" functions of a multi-function device, where the consumer is only functional if the producer is in D0. This reorganization should not affect any functionality.
--- drivers/pci/quirks.c | 54 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-)
drivers/pci/quirks.c +34 -20
@@ -4955,35 +4955,49 @@ static void quirk_fsl_no_msi(struct pci_dev *pdev)DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_FREESCALE ,PCI_ANY_ID , quirk_fsl_no_msi);/* -* GPUs with integrated HDA controller for streaming audio to attached displays -* need a device link from the HDA controller (consumer) to the GPU (supplier) -* so that the GPU is powered up whenever the HDA controller is accessed. -* The GPU and HDA controller are functions 0 and 1 of the same PCI device. -* The device link stays in place until shutdown (or removal of the PCI device -* if it's hotplugged). Runtime PM is allowed by default on the HDA controller -* to prevent it from permanently keeping the GPU awake. +* Although not allowed by the spec, some multi-function devices have +* dependencies of one function (consumer) on another (supplier). For the +* consumer to work in D0, the supplier must also be in D0. Create a +* device link from the consumer to the supplier to enforce this +* dependency. Runtime PM is allowed by default on the consumer to prevent +* it from permanently keeping the supplier awake. */ -static void quirk_gpu_hda (struct pci_dev *hda) +static void pci_create_device_link (struct pci_dev *pdev,unsigned int consumer, +unsigned int supplier,unsigned int class, +unsigned int class_shift) { -struct pci_dev *gpu; +struct pci_dev *supplier_pdev; -if (PCI_FUNC (hda->devfn) !=1 ) +if (PCI_FUNC (pdev->devfn) != consumer)return ; - gpu =pci_get_domain_bus_and_slot (pci_domain_nr (hda->bus), - hda->bus->number, -PCI_DEVFN (PCI_SLOT (hda->devfn),0 )); -if (!gpu || (gpu->class >>16 ) !=PCI_BASE_CLASS_DISPLAY ) { -pci_dev_put (gpu); + supplier_pdev =pci_get_domain_bus_and_slot (pci_domain_nr (pdev->bus), + pdev->bus->number, +PCI_DEVFN (PCI_SLOT (pdev->devfn), supplier)); +if (!supplier_pdev || (supplier_pdev->class >> class_shift) != class) { +pci_dev_put (supplier_pdev);return ; } -if (!device_link_add (&hda->dev, &gpu->dev, -DL_FLAG_STATELESS |DL_FLAG_PM_RUNTIME )) -pci_err (hda,"cannot link HDA to GPU %s\n" ,pci_name (gpu)); +if (device_link_add (&pdev->dev, &supplier_pdev->dev, +DL_FLAG_STATELESS |DL_FLAG_PM_RUNTIME )) +pci_info (pdev,"D0 power state depends on %s\n" , +pci_name (supplier_pdev)); +else +pci_err (pdev,"Cannot enforce power dependency on %s\n" , +pci_name (supplier_pdev)); + +pm_runtime_allow (&pdev->dev); +pci_dev_put (supplier_pdev); +} -pm_runtime_allow (&hda->dev); -pci_dev_put (gpu); +/* +* Create device link for GPUs with integrated HDA controller for streaming +* audio to attached displays. +*/ +static void quirk_gpu_hda (struct pci_dev *hda) +{ +pci_create_device_link (hda,1 ,0 ,PCI_BASE_CLASS_DISPLAY ,16 ); }DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID ,PCI_CLASS_MULTIMEDIA_HD_AUDIO ,8 , quirk_gpu_hda);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 157/190 PCI: Add ACS quirk for Intel Root Complex Integrated Endpoints
In reply to Greg Kroah-HartmanFrom: Ashok Raj <[email protected]>
[ Upstream commit 3247bd10a4502a3075ce8e1c3c7d31ef76f193ce ]
All Intel platforms guarantee that all root complex implementations must send transactions up to IOMMU for address translations. Hence for Intel RCiEP devices, we can assume some ACS-type isolation even without an ACS capability.
Quoted 1 line
From the Intel VT-d spec, r3.1, sec 3.16 ("Root-Complex Peer to Peer
Considerations"):
When DMA remapping is enabled, peer-to-peer requests through the Root-Complex must be handled as follows:
- The input address in the request is translated (through first-level, second-level or nested translation) to a host physical address (HPA). The address decoding for peer addresses must be done only on the translated HPA. Hardware implementations are free to further limit peer-to-peer accesses to specific host physical address regions (or to completely disallow peer-forwarding of translated requests).
- Since address translation changes the contents (address field) of the PCI Express Transaction Layer Packet (TLP), for PCI Express peer-to-peer requests with ECRC, the Root-Complex hardware must use the new ECRC (re-computed with the translated address) if it decides to forward the TLP as a peer request.
- Root-ports, and multi-function root-complex integrated endpoints, may support additional peer-to-peer control features by supporting PCI Express Access Control Services (ACS) capability. Refer to ACS capability in PCI Express specifications for details.
Since Linux didn't give special treatment to allow this exception, certain RCiEP MFD devices were grouped in a single IOMMU group. This doesn't permit a single device to be assigned to a guest for instance.
In one vendor system: Device 14.x were grouped in a single IOMMU group.
/sys/kernel/iommu_groups/5/devices/0000:00:14.0
/sys/kernel/iommu_groups/5/devices/0000:00:14.2
/sys/kernel/iommu_groups/5/devices/0000:00:14.3
After this patch:
/sys/kernel/iommu_groups/5/devices/0000:00:14.0 /sys/kernel/iommu_groups/5/devices/0000:00:14.2 /sys/kernel/iommu_groups/6/devices/0000:00:14.3 <<< new group
14.0 and 14.2 are integrated devices, but legacy end points, whereas 14.3 was a PCIe-compliant RCiEP.
00:14.3 Network controller: Intel Corporation Device 9df0 (rev 30)
Capabilities: [40] Express (v2) Root Complex Integrated Endpoint, MSI 00
This permits assigning this device to a guest VM.
--- drivers/pci/quirks.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/pci/quirks.c +15 -0
@@ -4513,6 +4513,20 @@ static int pci_quirk_mf_endpoint_acs(struct pci_dev *dev, u16 acs_flags)return acs_flags ?0 :1 ; } +static int pci_quirk_rciep_acs (struct pci_dev *dev,u16 acs_flags) +{ +/* +* Intel RCiEP's are required to allow p2p only on translated +* addresses. Refer to Intel VT-d specification, r3.1, sec 3.16, +* "Root-Complex Peer to Peer Considerations". +*/ +if (pci_pcie_type (dev) !=PCI_EXP_TYPE_RC_END ) +return -ENOTTY ; + +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); +} +static int pci_quirk_brcm_acs (struct pci_dev *dev,u16 acs_flags) {/*
@@ -4596,6 +4610,7 @@ static const struct pci_dev_acs_enabled {/* I219 */ { PCI_VENDOR_ID_INTEL, 0x15b7, pci_quirk_mf_endpoint_acs }, { PCI_VENDOR_ID_INTEL, 0x15b8, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_rciep_acs },/* QCOM QDF2xxx root ports */ { 0x17cb, 0x400, pci_quirk_qcom_rp_acs }, { 0x17cb, 0x401, pci_quirk_qcom_rp_acs },
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 158/190 PCI: Unify ACS quirk desired vs provided checking
In reply to Greg Kroah-HartmanFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit 7cf2cba43f15c74bac46dc5f0326805d25ef514d ]
Most of the ACS quirks have a similar pattern of:
acs_flags &= ~( <controls provided by this device> ); return acs_flags ? 0 : 1;
Pull this out into a helper function to simplify the quirks slightly. The helper function is also a convenient place for comments about what the list of ACS controls means. No functional change intended.
--- drivers/pci/quirks.c | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 22 deletions(-)
drivers/pci/quirks.c +45 -22
@@ -4236,6 +4236,24 @@ static void quirk_chelsio_T5_disable_root_port_attributes(struct pci_dev *pdev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_CHELSIO ,PCI_ANY_ID , quirk_chelsio_T5_disable_root_port_attributes); +/* +* pci_acs_ctrl_enabled - compare desired ACS controls with those provided +* by a device +* @acs_ctrl_req: Bitmask of desired ACS controls +* @acs_ctrl_ena: Bitmask of ACS controls enabled or provided implicitly by +* the hardware design +* +* Return 1 if all ACS controls in the @acs_ctrl_req bitmask are included +* in @acs_ctrl_ena, i.e., the device provides all the access controls the +* caller desires. Return 0 otherwise. +*/ +static int pci_acs_ctrl_enabled (u16 acs_ctrl_req,u16 acs_ctrl_ena) +{ +if ((acs_ctrl_req & acs_ctrl_ena) == acs_ctrl_req) +return 1 ; +return 0 ; +} +/* * AMD has indicated that the devices below do not support peer-to-peer * in any system where they are found in the southbridge with an AMD
@@ -4279,7 +4297,7 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags)/* Filter out flags not applicable to multifunction */ acs_flags &= (PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_EC |PCI_ACS_DT ); -return acs_flags & ~(PCI_ACS_RR |PCI_ACS_CR ) ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags,PCI_ACS_RR |PCI_ACS_CR );#else return -ENODEV ;#endif
@@ -4317,9 +4335,8 @@ static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)* hardware implements and enables equivalent ACS functionality for * these flags. */ - acs_flags &= ~(PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); - -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); }static int pci_quirk_xgene_acs (struct pci_dev *dev,u16 acs_flags)
@@ -4329,9 +4346,8 @@ static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags)* transactions with others, allowing masking out these bits as if they * were unimplemented in the ACS capability. */ - acs_flags &= ~(PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); - -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); }/*
@@ -4383,17 +4399,16 @@ static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev)return false; } -#define INTEL_PCH_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) -static int pci_quirk_intel_pch_acs (struct pci_dev *dev,u16 acs_flags) {if (!pci_quirk_intel_pch_acs_match (dev))return -ENOTTY ;if (dev->dev_flags &PCI_DEV_FLAGS_ACS_ENABLED_QUIRK ) - acs_flags &= ~(INTEL_PCH_ACS_FLAGS ); +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags,0 ); }/*
@@ -4408,9 +4423,8 @@ static int pci_quirk_intel_pch_acs(struct pci_dev *dev, u16 acs_flags)*/ static int pci_quirk_qcom_rp_acs (struct pci_dev *dev,u16 acs_flags) { - acs_flags &= ~(PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); - -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); }/*
@@ -4493,7 +4507,7 @@ static int pci_quirk_intel_spt_pch_acs(struct pci_dev *dev, u16 acs_flags)pci_read_config_dword (dev, pos +INTEL_SPT_ACS_CTRL , &ctrl); -return acs_flags & ~ctrl ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, ctrl); }static int pci_quirk_mf_endpoint_acs (struct pci_dev *dev,u16 acs_flags)
@@ -4507,10 +4521,9 @@ static int pci_quirk_mf_endpoint_acs(struct pci_dev *dev, u16 acs_flags)* perform peer-to-peer with other functions, allowing us to mask out * these bits as if they were unimplemented in the ACS capability. */ - acs_flags &= ~(PCI_ACS_SV |PCI_ACS_TB |PCI_ACS_RR | -PCI_ACS_CR |PCI_ACS_UF |PCI_ACS_DT ); - -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_TB |PCI_ACS_RR | +PCI_ACS_CR |PCI_ACS_UF |PCI_ACS_DT ); }static int pci_quirk_rciep_acs (struct pci_dev *dev,u16 acs_flags)
@@ -4535,9 +4548,8 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags)* Allow each Root Port to be in a separate IOMMU group by masking * SV/RR/CR/UF bits. */ - acs_flags &= ~(PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); - -return acs_flags ?0 :1 ; +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); } static const struct pci_dev_acs_enabled {
@@ -4636,6 +4648,17 @@ static const struct pci_dev_acs_enabled { { 0 } }; +/* +* pci_dev_specific_acs_enabled - check whether device provides ACS controls +* @dev: PCI device +* @acs_flags: Bitmask of desired ACS controls +* +* Returns: +* -ENOTTY: No quirk applies to this device; we can't tell whether the +* device provides the desired controls +* 0: Device does not provide all the desired controls +* >0: Device provides all the controls in @acs_flags +*/ int pci_dev_specific_acs_enabled (struct pci_dev *dev,u16 acs_flags) {const struct pci_dev_acs_enabled *i;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 159/190 btrfs: fix error handling when submitting direct I/O bio
In reply to Greg Kroah-HartmanFrom: Omar Sandoval <[email protected]>
[ Upstream commit 6d3113a193e3385c72240096fe397618ecab6e43 ]
In btrfs_submit_direct_hook(), if a direct I/O write doesn't span a RAID stripe or chunk, we submit orig_bio without cloning it. In this case, we don't increment pending_bios. Then, if btrfs_submit_dio_bio() fails, we decrement pending_bios to -1, and we never complete orig_bio. Fix it by initializing pending_bios to 1 instead of incrementing later.
Fixing this exposes another bug: we put orig_bio prematurely and then put it again from end_io. Fix it by not putting orig_bio.
After this change, pending_bios is really more of a reference count, but I'll leave that cleanup separate to keep the fix small.
--- fs/btrfs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/inode.c +3 -3
@@ -8707,7 +8707,6 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip)/* bio split */ ASSERT (map_length <=INT_MAX ); -atomic_inc (&dip->pending_bios); do { clone_len = min_t(int, submit_len, map_length);
@@ -8758,7 +8757,8 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip)if (!status)return 0 ; -bio_put (bio); +if (bio != orig_bio) +bio_put (bio); out_err: dip->errors =1 ;/*
@@ -8798,7 +8798,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode, bio->bi_private = dip; dip->orig_bio = bio; dip->dio_bio = dio_bio; -atomic_set (&dip->pending_bios,0 ); +atomic_set (&dip->pending_bios,1 ); io_bio =btrfs_io_bio (bio); io_bio->logical = file_offset;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 160/190 btrfs: fix wrong file range cleanup after an error filling dealloc range
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit e2c8e92d1140754073ad3799eb6620c76bab2078 ]
If an error happens while running dellaloc in COW mode for a range, we can end up calling extent_clear_unlock_delalloc() for a range that goes beyond our range's end offset by 1 byte, which affects 1 extra page. This results in clearing bits and doing page operations (such as a page unlock) outside our target range.
Fix that by calling extent_clear_unlock_delalloc() with an inclusive end offset, instead of an exclusive end offset, at cow_file_range().
--- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +2 -2
@@ -1139,8 +1139,8 @@ static noinline int cow_file_range(struct inode *inode,*/ if (extent_reserved) {extent_clear_unlock_delalloc (inode, start, - start + cur_alloc_size, - start + cur_alloc_size, + start + cur_alloc_size -1 , + start + cur_alloc_size -1 , locked_page, clear_bits, page_ops);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 161/190 blk-mq: move _blk_mq_update_nr_hw_queues synchronize_rcu call
In reply to Greg Kroah-HartmanFrom: Giuliano Procida <[email protected]>
This fixes the
4.14 backport commit 574eb136ec7f315c3ef2ca68fa9b3e16c56baa24 which was
upstream commit f5bbbbe4d63577026f908a809f22f5fd5a90ea1f.
The upstream commit added a call to synchronize_rcu to _blk_mq_update_nr_hw_queues, just after freezing queues.
In the backport this landed just after unfreezeing queues.
This commit moves the call to its intended place.
--- block/blk-mq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/blk-mq.c +4 -4
@@ -2738,6 +2738,10 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,list_for_each_entry (q, &set->tag_list, tag_set_list)blk_mq_freeze_queue (q); +/* +* Sync with blk_mq_queue_tag_busy_iter. +*/ +synchronize_rcu (); set->nr_hw_queues = nr_hw_queues;blk_mq_update_queue_map (set);
@@ -2748,10 +2752,6 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,list_for_each_entry (q, &set->tag_list, tag_set_list)blk_mq_unfreeze_queue (q); -/* -* Sync with blk_mq_queue_tag_busy_iter. -*/ -synchronize_rcu (); }void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 162/190 PCI: Program MPS for RCiEP devices
In reply to Greg Kroah-HartmanFrom: Ashok Raj <[email protected]>
commit aa0ce96d72dd2e1b0dfd0fb868f82876e7790878 upstream.
Root Complex Integrated Endpoints (RCiEPs) do not have an upstream bridge, so pci_configure_mps() previously ignored them, which may result in reduced performance.
Instead, program the Max_Payload_Size of RCiEPs to the maximum supported value (unless it is limited for the PCIE_BUS_PEER2PEER case). This also affects the subsequent programming of Max_Read_Request_Size because Linux programs MRRS based on the MPS value.
--- drivers/pci/probe.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/pci/probe.c +21 -1
@@ -1557,13 +1557,33 @@ static void pci_configure_mps(struct pcistruct pci_dev *bridge =pci_upstream_bridge (dev);int mps, p_mps, rc; -if (!pci_is_pcie (dev) || !bridge || !pci_is_pcie (bridge)) +if (!pci_is_pcie (dev))return ;/* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */ if (dev->is_virtfn)return ; +/* +* For Root Complex Integrated Endpoints, program the maximum +* supported value unless limited by the PCIE_BUS_PEER2PEER case. +*/ +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_END ) { +if (pcie_bus_config ==PCIE_BUS_PEER2PEER ) + mps =128 ; +else + mps =128 << dev->pcie_mpss; + rc =pcie_set_mps (dev, mps); +if (rc) { +pci_warn (dev,"can't set Max Payload Size to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n" , + mps); + } +return ; + } + +if (!bridge || !pci_is_pcie (bridge)) +return ; + mps =pcie_get_mps (dev); p_mps =pcie_get_mps (bridge);
Greg Kroah-Hartman
maintainerPATCH 163/190 e1000e: Disable TSO for buffer overrun workaround
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit f29801030ac67bf98b7a65d3aea67b30769d4f7c upstream.
Commit b10effb92e27 ("e1000e: fix buffer overrun while the I219 is processing DMA transactions") imposes roughly 30% performance penalty.
The commit log states that "Disabling TSO eliminates performance loss for TCP traffic without a noticeable impact on CPU performance", so let's disable TSO by default to regain the loss.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/e1000e/netdev.c +4 -0
@@ -5271,6 +5271,10 @@ static void e1000_watchdog_task(struct w/* oops */ break ; } +if (hw->mac.type == e1000_pch_spt) { + netdev->features &= ~NETIF_F_TSO ; + netdev->features &= ~NETIF_F_TSO6 ; + } }/* enable transmits in the hardware, need to do this
Greg Kroah-Hartman
maintainerPATCH 164/190 e1000e: Relax condition to trigger reset for ME workaround
In reply to Greg Kroah-HartmanFrom: Punit Agrawal <[email protected]>
commit d601afcae2febc49665008e9a79e701248d56c50 upstream.
It's an error if the value of the RX/TX tail descriptor does not match what was written. The error condition is true regardless the duration of the interference from ME. But the driver only performs the reset if E1000_ICH_FWSM_PCIM2PCI_COUNT (2000) iterations of 50us delay have transpired. The extra condition can lead to inconsistency between the state of hardware as expected by the driver.
Fix this by dropping the check for number of delay iterations.
While at it, also make __ew32_prepare() static as it's not used anywhere else.
--- drivers/net/ethernet/intel/e1000e/e1000.h | 1 - drivers/net/ethernet/intel/e1000e/netdev.c | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/e1000e/e1000.h +0 -1
@@ -596,7 +596,6 @@ static inline u32 __er32(struct e1000_hw#define er32 (reg) __er32(hw, E1000_##reg) -s32 __ew32_prepare (struct e1000_hw *hw);void __ew32 (struct e1000_hw *hw,unsigned long reg,u32 val);#define ew32 (reg, val) __ew32(hw, E1000_##reg, (val))
drivers/net/ethernet/intel/e1000e/netdev.c +5 -7
@@ -137,14 +137,12 @@ static const struct e1000_reg_info e1000* has bit 24 set while ME is accessing MAC CSR registers, wait if it is set * and try again a number of times. **/ -s32 __ew32_prepare (struct e1000_hw *hw) +static void __ew32_prepare (struct e1000_hw *hw) {s32 i =E1000_ICH_FWSM_PCIM2PCI_COUNT ;while ((er32 (FWSM ) &E1000_ICH_FWSM_PCIM2PCI ) && --i)udelay (50 ); - -return i; }void __ew32 (struct e1000_hw *hw,unsigned long reg,u32 val)
@@ -625,11 +623,11 @@ static void e1000e_update_rdt_wa(struct {struct e1000_adapter *adapter = rx_ring->adapter;struct e1000_hw *hw = &adapter->hw; -s32 ret_val =__ew32_prepare (hw); +__ew32_prepare (hw);writel (i, rx_ring->tail); -if (unlikely (!ret_val && (i !=readl (rx_ring->tail)))) { +if (unlikely (i !=readl (rx_ring->tail))) {u32 rctl =er32 (RCTL );ew32 (RCTL , rctl & ~E1000_RCTL_EN );
@@ -642,11 +640,11 @@ static void e1000e_update_tdt_wa(struct {struct e1000_adapter *adapter = tx_ring->adapter;struct e1000_hw *hw = &adapter->hw; -s32 ret_val =__ew32_prepare (hw); +__ew32_prepare (hw);writel (i, tx_ring->tail); -if (unlikely (!ret_val && (i !=readl (tx_ring->tail)))) { +if (unlikely (i !=readl (tx_ring->tail))) {u32 tctl =er32 (TCTL );ew32 (TCTL , tctl & ~E1000_TCTL_EN );
Greg Kroah-Hartman
maintainerPATCH 165/190 carl9170: remove P2P_GO support
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit b14fba7ebd04082f7767a11daea7f12f3593de22 upstream.
This patch follows up on a bug-report by Frank Schäfer that discovered P2P GO wasn't working with wpa_supplicant. This patch removes part of the broken P2P GO support but keeps the vif switchover code in place.
--- drivers/net/wireless/ath/carl9170/fw.c | 4 +--- drivers/net/wireless/ath/carl9170/main.c | 21 ++++----------------- 2 files changed, 5 insertions(+), 20 deletions(-)
drivers/net/wireless/ath/carl9170/fw.c +1 -3
@@ -351,9 +351,7 @@ static int carl9170_fw(struct ar9170 *ar ar->hw->wiphy->interface_modes |=BIT (NL80211_IFTYPE_ADHOC );if (SUPP (CARL9170FW_WLANTX_CAB )) { - if_comb_types |= -BIT (NL80211_IFTYPE_AP ) | -BIT (NL80211_IFTYPE_P2P_GO ); + if_comb_types |=BIT (NL80211_IFTYPE_AP );#ifdef CONFIG_MAC80211_MESH if_comb_types |=
drivers/net/wireless/ath/carl9170/main.c +4 -17
@@ -582,11 +582,10 @@ static int carl9170_init_interface(struc ar->disable_offload |= ((vif->type !=NL80211_IFTYPE_STATION ) && (vif->type !=NL80211_IFTYPE_AP )); -/* While the driver supports HW offload in a single -* P2P client configuration, it doesn't support HW -* offload in the favourit, concurrent P2P GO+CLIENT -* configuration. Hence, HW offload will always be -* disabled for P2P. +/* The driver used to have P2P GO+CLIENT support, +* but since this was dropped and we don't know if +* there are any gremlins lurking in the shadows, +* so best we keep HW offload disabled for P2P. */ ar->disable_offload |= vif->p2p;
@@ -639,18 +638,6 @@ static int carl9170_op_add_interface(strif (vif->type ==NL80211_IFTYPE_STATION )break ; -/* P2P GO [master] use-case -* Because the P2P GO station is selected dynamically -* by all participating peers of a WIFI Direct network, -* the driver has be able to change the main interface -* operating mode on the fly. -*/ -if (main_vif->p2p && vif->p2p && - vif->type ==NL80211_IFTYPE_AP ) { - old_main = main_vif; -break ; - } - err = -EBUSY ;rcu_read_unlock ();
Greg Kroah-Hartman
maintainerPATCH 166/190 media: go7007: fix a miss of snd_card_free
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
commit 9453264ef58638ce8976121ac44c07a3ef375983 upstream.
go7007_snd_init() misses a snd_card_free() in an error path. Add the missed call to fix it.
[Salvatore Bonaccorso: Adjust context for backport to versions which do not contain c0decac19da3 ("media: use strscpy() instead of strlcpy()") and ba78170ef153 ("media: go7007: Fix misuse of strscpy")]
--- drivers/media/usb/go7007/snd-go7007.c | 35 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/media/usb/go7007/snd-go7007.c +17 -18
@@ -243,22 +243,18 @@ int go7007_snd_init(struct go7007 *go) gosnd->capturing =0 ; ret =snd_card_new (go->dev, index[dev], id[dev],THIS_MODULE ,0 , &gosnd->card); -if (ret <0 ) { -kfree (gosnd); -return ret; - } +if (ret <0 ) + goto free_snd; + ret =snd_device_new (gosnd->card,SNDRV_DEV_LOWLEVEL , go, &go7007_snd_device_ops); -if (ret <0 ) { -kfree (gosnd); -return ret; - } +if (ret <0 ) + goto free_card; + ret =snd_pcm_new (gosnd->card,"go7007" ,0 ,0 ,1 , &gosnd->pcm); -if (ret <0 ) { -snd_card_free (gosnd->card); -kfree (gosnd); -return ret; - } +if (ret <0 ) + goto free_card; +strlcpy (gosnd->card->driver,"go7007" ,sizeof (gosnd->card->driver));strlcpy (gosnd->card->shortname, go->name,sizeof (gosnd->card->driver)); strlcpy(gosnd->card->longname, gosnd->card->shortname,
@@ -269,11 +265,8 @@ int go7007_snd_init(struct go7007 *go) &go7007_snd_capture_ops); ret =snd_card_register (gosnd->card); -if (ret <0 ) { -snd_card_free (gosnd->card); -kfree (gosnd); -return ret; - } +if (ret <0 ) + goto free_card; gosnd->substream =NULL ; go->snd_context = gosnd;
@@ -281,6 +274,12 @@ int go7007_snd_init(struct go7007 *go) ++dev;return 0 ; + +free_card: +snd_card_free (gosnd->card); +free_snd: +kfree (gosnd); +return ret; }EXPORT_SYMBOL (go7007_snd_init);
Greg Kroah-Hartman
maintainerPATCH 167/190 b43legacy: Fix case where channel status is corrupted
In reply to Greg Kroah-HartmanFrom: Larry Finger <[email protected]>
commit ec4d3e3a054578de34cd0b587ab8a1ac36f629d9 upstream.
This patch fixes commit 75388acd0cd8 ("add mac80211-based driver for legacy BCM43xx devices")
In https://bugzilla.kernel.org/show_bug.cgi?id=207093, a defect in b43legacy is reported. Upon testing, thus problem exists on PPC and X86 platforms, is present in the oldest kernel tested (3.2), and has been present in the driver since it was first added to the kernel.
The problem is a corrupted channel status received from the device. Both the internal card in a PowerBook G4 and the PCMCIA version (Broadcom BCM4306 with PCI ID 14e4:4320) have the problem. Only Rev, 2 (revision 4 of the 802.11 core) of the chip has been tested. No other devices using b43legacy are available for testing.
Various sources of the problem were considered. Buffer overrun and other sources of corruption within the driver were rejected because the faulty channel status is always the same, not a random value. It was concluded that the faulty data is coming from the device, probably due to a firmware bug. As that source is not available, the driver must take appropriate action to recover.
At present, the driver reports the error, and them continues to process the bad packet. This is believed that to be a mistake, and the correct action is to drop the correpted packet.
Reported-and-tested by: F. Erhard <[email protected]>
--- drivers/net/wireless/broadcom/b43legacy/xmit.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/b43legacy/xmit.c +1 -0
@@ -571,6 +571,7 @@ void b43legacy_rx(struct b43legacy_wldevdefault :b43legacywarn (dev->wl,"Unexpected value for chanstat (0x%X)\n" , chanstat); + goto drop; }memcpy (IEEE80211_SKB_RXCB (skb), &status,sizeof (status));
Greg Kroah-Hartman
maintainerPATCH 168/190 b43: Fix connection problem with WPA3
In reply to Greg Kroah-HartmanFrom: Larry Finger <[email protected]>
commit 75d057bda1fbca6ade21378aa45db712e5f7d962 upstream.
Since the driver was first introduced into the kernel, it has only handled the ciphers associated with WEP, WPA, and WPA2. It fails with WPA3 even though mac80211 can handle those additional ciphers in software, b43 did not report that it could handle them. By setting MFP_CAPABLE using ieee80211_set_hw(), the problem is fixed.
With this change, b43 will handle the ciphers it knows in hardware, and let mac80211 handle the others in software. It is not necessary to use the module parameter NOHWCRYPT to turn hardware encryption off. Although this change essentially eliminates that module parameter, I am choosing to keep it for cases where the hardware is broken, and software encryption is required for all ciphers.
--- drivers/net/wireless/broadcom/b43/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/main.c +1 -1
@@ -5596,7 +5596,7 @@ static struct b43_wl *b43_wireless_init(/* fill hw info */ ieee80211_hw_set (hw,RX_INCLUDES_FCS );ieee80211_hw_set (hw,SIGNAL_DBM ); - +ieee80211_hw_set (hw,MFP_CAPABLE ); hw->wiphy->interface_modes =BIT (NL80211_IFTYPE_AP ) | BIT(NL80211_IFTYPE_MESH_POINT) |
Greg Kroah-Hartman
maintainerPATCH 169/190 b43_legacy: Fix connection problem with WPA3
In reply to Greg Kroah-HartmanFrom: Larry Finger <[email protected]>
commit 6a29d134c04a8acebb7a95251acea7ad7abba106 upstream.
Since the driver was first introduced into the kernel, it has only handled the ciphers associated with WEP, WPA, and WPA2. It fails with WPA3 even though mac80211 can handle those additional ciphers in software, b43legacy did not report that it could handle them. By setting MFP_CAPABLE using ieee80211_set_hw(), the problem is fixed.
With this change, b43legacy will handle the ciphers it knows in hardware, and let mac80211 handle the others in software. It is not necessary to use the module parameter NOHWCRYPT to turn hardware encryption off. Although this change essentially eliminates that module parameter, I am choosing to keep it for cases where the hardware is broken, and software encryption is required for all ciphers.
--- drivers/net/wireless/broadcom/b43legacy/main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/b43legacy/main.c +1 -0
@@ -3835,6 +3835,7 @@ static int b43legacy_wireless_init(struc/* fill hw info */ ieee80211_hw_set (hw,RX_INCLUDES_FCS );ieee80211_hw_set (hw,SIGNAL_DBM ); +ieee80211_hw_set (hw,MFP_CAPABLE );/* Allow WPA3 in software */ hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_AP) |
Greg Kroah-Hartman
maintainerPATCH 170/190 media: ov5640: fix use of destroyed mutex
In reply to Greg Kroah-HartmanFrom: Tomi Valkeinen <[email protected]>
commit bfcba38d95a0aed146a958a84a2177af1459eddc upstream.
v4l2_ctrl_handler_free() uses hdl->lock, which in ov5640 driver is set to sensor's own sensor->lock. In ov5640_remove(), the driver destroys the sensor->lock first, and then calls v4l2_ctrl_handler_free(), resulting in the use of the destroyed mutex.
Fix this by calling moving the mutex_destroy() to the end of the cleanup sequence, as there's no need to destroy the mutex as early as possible.
--- drivers/media/i2c/ov5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5640.c +2 -2
@@ -2298,8 +2298,8 @@ static int ov5640_probe(struct i2c_clien free_ctrls:v4l2_ctrl_handler_free (&sensor->ctrls.handler); entity_cleanup: -mutex_destroy (&sensor->lock);media_entity_cleanup (&sensor->sd.entity); +mutex_destroy (&sensor->lock);return ret; }
@@ -2309,9 +2309,9 @@ static int ov5640_remove(struct i2c_cliestruct ov5640_dev *sensor =to_ov5640_dev (sd);v4l2_async_unregister_subdev (&sensor->sd); -mutex_destroy (&sensor->lock);media_entity_cleanup (&sensor->sd.entity);v4l2_ctrl_handler_free (&sensor->ctrls.handler); +mutex_destroy (&sensor->lock);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 171/190 igb: Report speed and duplex as unknown when device is runtime suspended
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 165ae7a8feb53dc47fb041357e4b253bfc927cf9 upstream.
igb device gets runtime suspended when there's no link partner. We can't get correct speed under that state:
$ cat /sys/class/net/enp3s0/speed 1000
In addition to that, an error can also be spotted in dmesg:
[ 385.991957] igb 0000:03:00.0 enp3s0: PCIe link lost
Since device can only be runtime suspended when there's no link partner, we can skip reading register and let the following logic set speed and duplex with correct status.
The more generic approach will be wrap get_link_ksettings() with begin() and complete() callbacks. However, for this particular issue, begin() calls igb_runtime_resume() , which tries to rtnl_lock() while the lock is already hold by upper ethtool layer.
So let's take this approach until the igb_runtime_resume() no longer needs to hold rtnl_lock.
--- drivers/net/ethernet/intel/igb/igb_ethtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/igb_ethtool.c +2 -1
@@ -163,7 +163,8 @@ static int igb_get_link_ksettings(structu32 speed;u32 supported, advertising; - status =rd32 (E1000_STATUS ); + status =pm_runtime_suspended (&adapter->pdev->dev) ? +0 :rd32 (E1000_STATUS );if (hw->phy.media_type == e1000_media_type_copper) { supported = (SUPPORTED_10baseT_Half |
Greg Kroah-Hartman
maintainerPATCH 172/190 power: vexpress: add suppress_bind_attrs to true
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 73174acc9c75960af2daa7dcbdb9781fc0d135cb upstream.
Make sure that the POWER_RESET_VEXPRESS driver won't have bind/unbind attributes available via the sysfs, so lets be explicit here and use ".suppress_bind_attrs = true" to prevent userspace from doing something silly.
--- drivers/power/reset/vexpress-poweroff.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/reset/vexpress-poweroff.c +1 -0
@@ -150,6 +150,7 @@ static struct platform_driver vexpress_r .driver = { .name = "vexpress-reset", .of_match_table = vexpress_reset_of_match, + .suppress_bind_attrs = true, }, };
Greg Kroah-Hartman
maintainerPATCH 173/190 pinctrl: samsung: Save/restore eint_mask over suspend for EINT_TYPE GPIOs
In reply to Greg Kroah-HartmanFrom: Jonathan Bakker <[email protected]>
commit f354157a7d184db430c1a564c506434e33b1bec5 upstream.
Currently, for EINT_TYPE GPIOs, the CON and FLTCON registers are saved and restored over a suspend/resume cycle. However, the EINT_MASK registers are not.
On S5PV210 at the very least, these registers are not retained over suspend, leading to the interrupts remaining masked upon resume and therefore no interrupts being triggered for the device. There should be no effect on any SoCs that do retain these registers as theoretically we would just be re-writing what was already there.
--- drivers/pinctrl/samsung/pinctrl-exynos.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/samsung/pinctrl-exynos.c +9 -0
@@ -266,6 +266,7 @@ struct exynos_eint_gpio_save {u32 eint_con;u32 eint_fltcon0;u32 eint_fltcon1; +u32 eint_mask; };/*
@@ -561,10 +562,13 @@ static void exynos_pinctrl_suspend_bank( + 2 * bank->eint_offset); save->eint_fltcon1 =readl (regs +EXYNOS_GPIO_EFLTCON_OFFSET +2 * bank->eint_offset +4 ); + save->eint_mask =readl (regs + bank->irq_chip->eint_mask + + bank->eint_offset);pr_debug ("%s: save con %#010x\n" , bank->name, save->eint_con);pr_debug ("%s: save fltcon0 %#010x\n" , bank->name, save->eint_fltcon0);pr_debug ("%s: save fltcon1 %#010x\n" , bank->name, save->eint_fltcon1); +pr_debug ("%s: save mask %#010x\n" , bank->name, save->eint_mask); }void exynos_pinctrl_suspend (struct samsung_pinctrl_drv_data *drvdata)
@@ -593,6 +597,9 @@ static void exynos_pinctrl_resume_bank(pr_debug ("%s: fltcon1 %#010x => %#010x\n" , bank->name,readl (regs +EXYNOS_GPIO_EFLTCON_OFFSET +2 * bank->eint_offset +4 ), save->eint_fltcon1); +pr_debug ("%s: mask %#010x => %#010x\n" , bank->name, +readl (regs + bank->irq_chip->eint_mask + + bank->eint_offset), save->eint_mask);writel (save->eint_con, regs +EXYNOS_GPIO_ECON_OFFSET + bank->eint_offset);
@@ -600,6 +607,8 @@ static void exynos_pinctrl_resume_bank( + 2 * bank->eint_offset);writel (save->eint_fltcon1, regs +EXYNOS_GPIO_EFLTCON_OFFSET +2 * bank->eint_offset +4 ); +writel (save->eint_mask, regs + bank->irq_chip->eint_mask + + bank->eint_offset); }void exynos_pinctrl_resume (struct samsung_pinctrl_drv_data *drvdata)
Greg Kroah-Hartman
maintainerPATCH 174/190 sparc32: fix register window handling in genregs32_[gs]et()
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit cf51e129b96847f969bfb8af1ee1516a01a70b39 upstream.
It needs access_process_vm() if the traced process does not share mm with the caller. Solution is similar to what sparc64 does. Note that genregs32_set() is only ever called with pos being 0 or 32 * sizeof(u32) (the latter - as part of PTRACE_SETREGS handling).
--- arch/sparc/kernel/ptrace_32.c | 230 ++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 131 deletions(-)
arch/sparc/kernel/ptrace_32.c +99 -131
@@ -46,82 +46,79 @@ enum sparc_regset { REGSET_FP, }; +static int regwindow32_get (struct task_struct *target, +const struct pt_regs *regs, +u32 *uregs) +{ +unsigned long reg_window = regs->u_regs[UREG_I6 ]; +int size =16 *sizeof (u32); + +if (target == current) { +if (copy_from_user (uregs, (void __user *)reg_window, size)) +return -EFAULT ; + }else { +if (access_process_vm (target, reg_window, uregs, size, +FOLL_FORCE ) != size) +return -EFAULT ; + } +return 0 ; +} + +static int regwindow32_set (struct task_struct *target, +const struct pt_regs *regs, +u32 *uregs) +{ +unsigned long reg_window = regs->u_regs[UREG_I6 ]; +int size =16 *sizeof (u32); + +if (target == current) { +if (copy_to_user ((void __user *)reg_window, uregs, size)) +return -EFAULT ; + }else { +if (access_process_vm (target, reg_window, uregs, size, +FOLL_FORCE |FOLL_WRITE ) != size) +return -EFAULT ; + } +return 0 ; +} +static int genregs32_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf) {const struct pt_regs *regs = target->thread.kregs; -unsigned long __user *reg_window; -unsigned long *k = kbuf; -unsigned long __user *u = ubuf; -unsigned long reg; +u32 uregs[16 ]; +int ret;if (target == current)flush_user_windows (); - pos /=sizeof (reg); - count /=sizeof (reg); + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + regs->u_regs, +0 ,16 *sizeof (u32)); +if (ret || !count) +return ret; -if (kbuf) { -for (; count >0 && pos <16 ; count--) - *k++ = regs->u_regs[pos++]; - - reg_window = (unsigned long __user *) regs->u_regs[UREG_I6 ]; - reg_window -=16 ; -for (; count >0 && pos <32 ; count--) { -if (get_user (*k++, ®_window[pos++])) -return -EFAULT ; - } - }else { -for (; count >0 && pos <16 ; count--) { -if (put_user (regs->u_regs[pos++], u++)) -return -EFAULT ; - } - - reg_window = (unsigned long __user *) regs->u_regs[UREG_I6 ]; - reg_window -=16 ; -for (; count >0 && pos <32 ; count--) { -if (get_user (reg, ®_window[pos++]) || -put_user (reg, u++)) -return -EFAULT ; - } - } -while (count >0 ) { -switch (pos) { -case 32 :/* PSR */ - reg = regs->psr; -break ; -case 33 :/* PC */ - reg = regs->pc; -break ; -case 34 :/* NPC */ - reg = regs->npc; -break ; -case 35 :/* Y */ - reg = regs->y; -break ; -case 36 :/* WIM */ -case 37 :/* TBR */ - reg =0 ; -break ; -default : - goto finish; - } - -if (kbuf) - *k++ = reg; -else if (put_user (reg, u++)) +if (pos <32 *sizeof (u32)) { +if (regwindow32_get (target, regs, uregs))return -EFAULT ; - pos++; - count--; + ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + uregs, +16 *sizeof (u32),32 *sizeof (u32)); +if (ret || !count) +return ret; } -finish: - pos *=sizeof (reg); - count *=sizeof (reg); -return user_regset_copyout_zero (&pos, &count, &kbuf, &ubuf, -38 *sizeof (reg),-1 ); + uregs[0 ] = regs->psr; + uregs[1 ] = regs->pc; + uregs[2 ] = regs->npc; + uregs[3 ] = regs->y; + uregs[4 ] =0 ;/* WIM */ + uregs[5 ] =0 ;/* TBR */ +return user_regset_copyout (&pos, &count, &kbuf, &ubuf, + uregs, +32 *sizeof (u32),38 *sizeof (u32)); } static int genregs32_set(struct task_struct *target,
@@ -130,82 +127,53 @@ static int genregs32_set(struct task_str const void *kbuf, const void __user *ubuf) { struct pt_regs *regs = target->thread.kregs; -unsigned long __user *reg_window; -const unsigned long *k = kbuf; -const unsigned long __user *u = ubuf; -unsigned long reg; +u32 uregs[16 ]; +u32 psr; +int ret;if (target == current)flush_user_windows (); - pos /=sizeof (reg); - count /=sizeof (reg); - -if (kbuf) { -for (; count >0 && pos <16 ; count--) - regs->u_regs[pos++] = *k++; - - reg_window = (unsigned long __user *) regs->u_regs[UREG_I6 ]; - reg_window -=16 ; -for (; count >0 && pos <32 ; count--) { -if (put_user (*k++, ®_window[pos++])) -return -EFAULT ; - } - }else { -for (; count >0 && pos <16 ; count--) { -if (get_user (reg, u++)) -return -EFAULT ; - regs->u_regs[pos++] = reg; - } - - reg_window = (unsigned long __user *) regs->u_regs[UREG_I6 ]; - reg_window -=16 ; -for (; count >0 && pos <32 ; count--) { -if (get_user (reg, u++) || -put_user (reg, ®_window[pos++])) -return -EFAULT ; - } - } -while (count >0 ) { -unsigned long psr; - -if (kbuf) - reg = *k++; -else if (get_user (reg, u++)) -return -EFAULT ; - -switch (pos) { -case 32 :/* PSR */ - psr = regs->psr; - psr &= ~(PSR_ICC |PSR_SYSCALL ); - psr |= (reg & (PSR_ICC |PSR_SYSCALL )); - regs->psr = psr; -break ; -case 33 :/* PC */ - regs->pc = reg; -break ; -case 34 :/* NPC */ - regs->npc = reg; -break ; -case 35 :/* Y */ - regs->y = reg; -break ; -case 36 :/* WIM */ -case 37 :/* TBR */ -break ; -default : - goto finish; - } + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + regs->u_regs, +0 ,16 *sizeof (u32)); +if (ret || !count) +return ret; - pos++; - count--; +if (pos <32 *sizeof (u32)) { +if (regwindow32_get (target, regs, uregs)) +return -EFAULT ; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + uregs, +16 *sizeof (u32),32 *sizeof (u32)); +if (ret) +return ret; +if (regwindow32_set (target, regs, uregs)) +return -EFAULT ; +if (!count) +return 0 ; } -finish: - pos *=sizeof (reg); - count *=sizeof (reg); - + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &psr, +32 *sizeof (u32),33 *sizeof (u32)); +if (ret) +return ret; + regs->psr = (regs->psr & ~(PSR_ICC |PSR_SYSCALL )) | + (psr & (PSR_ICC |PSR_SYSCALL )); +if (!count) +return 0 ; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + ®s->pc, +33 *sizeof (u32),34 *sizeof (u32)); +if (ret || !count) +return ret; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + ®s->y, +34 *sizeof (u32),35 *sizeof (u32)); +if (ret || !count) +return ret;return user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, -38 *sizeof (reg),-1 ); +35 *sizeof (u32),38 *sizeof (u32)); } static int fpregs32_get(struct task_struct *target,
Greg Kroah-Hartman
maintainerPATCH 175/190 sparc64: fix misuses of access_process_vm() in genregs32_[sg]et()
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 142cd25293f6a7ecbdff4fb0af17de6438d46433 upstream.
We do need access_process_vm() to access the target's reg_window. However, access to caller's memory (storing the result in genregs32_get(), fetching the new values in case of genregs32_set()) should be done by normal uaccess primitives.
--- arch/sparc/kernel/ptrace_64.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
arch/sparc/kernel/ptrace_64.c +3 -14
@@ -571,19 +571,13 @@ static int genregs32_get(struct task_strfor (; count >0 && pos <32 ; count--) {if (access_process_vm (target, (unsigned long ) - ®_window[pos], + ®_window[pos++], ®,sizeof (reg),FOLL_FORCE ) !=sizeof (reg))return -EFAULT ; -if (access_process_vm (target, - (unsigned long ) u, - ®,sizeof (reg), -FOLL_FORCE |FOLL_WRITE ) - !=sizeof (reg)) +if (put_user (reg, u++))return -EFAULT ; - pos++; - u++; } } }
@@ -683,12 +677,7 @@ static int genregs32_set(struct task_str } }else {for (; count >0 && pos <32 ; count--) { -if (access_process_vm (target, - (unsigned long ) - u, - ®,sizeof (reg), -FOLL_FORCE ) - !=sizeof (reg)) +if (get_user (reg, u++))return -EFAULT ; if (access_process_vm(target, (unsigned long)
Greg Kroah-Hartman
maintainerPATCH 176/190 dm crypt: avoid truncating the logical block size
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 64611a15ca9da91ff532982429c44686f4593b5f upstream.
queue_limits::logical_block_size got changed from unsigned short to unsigned int, but it was forgotten to update crypt_io_hints() to use the new type. Fix it.
--- drivers/md/dm-crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-crypt.c +1 -1
@@ -3088,7 +3088,7 @@ static void crypt_io_hints(struct dm_tar limits->max_segment_size =PAGE_SIZE ; limits->logical_block_size = - max_t(unsigned short, limits->logical_block_size, cc->sector_size); +max_t (unsigned, limits->logical_block_size, cc->sector_size); limits->physical_block_size =max_t (unsigned, limits->physical_block_size, cc->sector_size); limits->io_min =max_t (unsigned, limits->io_min, cc->sector_size);
Greg Kroah-Hartman
maintainerPATCH 177/190 kernel/cpu_pm: Fix uninitted local in cpu_pm
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
commit b5945214b76a1f22929481724ffd448000ede914 upstream.
cpu_pm_notify() is basically a wrapper of notifier_call_chain(). notifier_call_chain() doesn't initialize *nr_calls to 0 before it starts incrementing it--presumably it's up to the callers to do this.
Unfortunately the callers of cpu_pm_notify() don't init *nr_calls. This potentially means you could get too many or two few calls to CPU_PM_ENTER_FAILED or CPU_CLUSTER_PM_ENTER_FAILED depending on the luck of the stack.
Let's fix this.
--- kernel/cpu_pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cpu_pm.c +2 -2
@@ -89,7 +89,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_noti*/ int cpu_pm_enter (void ) { -int nr_calls; +int nr_calls =0 ;int ret =0 ; ret =cpu_pm_notify (CPU_PM_ENTER ,-1 , &nr_calls);
@@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);*/ int cpu_cluster_pm_enter (void ) { -int nr_calls; +int nr_calls =0 ;int ret =0 ; ret =cpu_pm_notify (CPU_CLUSTER_PM_ENTER ,-1 , &nr_calls);
Greg Kroah-Hartman
maintainerPATCH 178/190 ARM: tegra: Correct PL310 Auxiliary Control Register initialization
In reply to Greg Kroah-HartmanFrom: Dmitry Osipenko <[email protected]>
commit 35509737c8f958944e059d501255a0bf18361ba0 upstream.
The PL310 Auxiliary Control Register shouldn't have the "Full line of zero" optimization bit being set before L2 cache is enabled. The L2X0 driver takes care of enabling the optimization by itself.
This patch fixes a noisy error message on Tegra20 and Tegra30 telling that cache optimization is erroneously enabled without enabling it for the CPU:
L2C-310: enabling full line of zeros but not enabled in Cortex-A9
--- arch/arm/mach-tegra/tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-tegra/tegra.c +2 -2
@@ -108,8 +108,8 @@ static const char * const tegra_dt_board };DT_MACHINE_START (TEGRA_DT ,"NVIDIA Tegra SoC (Flattened Device Tree)" ) - .l2c_aux_val = 0x3c400001, - .l2c_aux_mask = 0xc20fc3fe, + .l2c_aux_val = 0x3c400000, + .l2c_aux_mask = 0xc20fc3ff, .smp = smp_ops(tegra_smp_ops), .map_io = tegra_map_common_io, .init_early = tegra_init_early,
Greg Kroah-Hartman
maintainerPATCH 179/190 drivers/macintosh: Fix memleak in windfarm_pm112 driver
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 93900337b9ac2f4eca427eff6d187be2dc3b5551 upstream.
create_cpu_loop() calls smu_sat_get_sdb_partition() which does kmalloc() and returns the allocated buffer. In fact it's called twice, and neither buffer is freed.
This results in a memory leak as reported by Erhard:
unreferenced object 0xc00000047081f840 (size 32):
comm "kwindfarm", pid 203, jiffies 4294880630 (age 5552.877s)
hex dump (first 32 bytes):
c8 06 02 7f ff 02 ff 01 fb bf 00 41 00 20 00 00 ...........A. ..
00 07 89 37 00 a0 00 00 00 00 00 00 00 00 00 00 ...7............
backtrace:
[<0000000083f0a65c>] .smu_sat_get_sdb_partition+0xc4/0x2d0 [windfarm_smu_sat]
[<000000003010fcb7>] .pm112_wf_notify+0x104c/0x13bc [windfarm_pm112]
[<00000000b958b2dd>] .notifier_call_chain+0xa8/0x180
[<0000000070490868>] .blocking_notifier_call_chain+0x64/0x90
[<00000000131d8149>] .wf_thread_func+0x114/0x1a0
[<000000000d54838d>] .kthread+0x13c/0x190
[<00000000669b72bc>] .ret_from_kernel_thread+0x58/0x64
unreferenced object 0xc0000004737089f0 (size 16):
comm "kwindfarm", pid 203, jiffies 4294880879 (age 5552.050s)
hex dump (first 16 bytes):
c4 04 01 7f 22 11 e0 e6 ff 55 7b 12 ec 11 00 00 ...."....U{.....
backtrace:
[<0000000083f0a65c>] .smu_sat_get_sdb_partition+0xc4/0x2d0 [windfarm_smu_sat]
[<00000000b94ef7e1>] .pm112_wf_notify+0x1294/0x13bc [windfarm_pm112]
[<00000000b958b2dd>] .notifier_call_chain+0xa8/0x180
[<0000000070490868>] .blocking_notifier_call_chain+0x64/0x90
[<00000000131d8149>] .wf_thread_func+0x114/0x1a0
[<000000000d54838d>] .kthread+0x13c/0x190
[<00000000669b72bc>] .ret_from_kernel_thread+0x58/0x64Fix it by rearranging the logic so we deal with each buffer separately, which then makes it easy to free the buffer once we're done with it.
--- drivers/macintosh/windfarm_pm112.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/macintosh/windfarm_pm112.c +13 -8
@@ -133,14 +133,6 @@ static int create_cpu_loop(int cpu)s32 tmax;int fmin; -/* Get PID params from the appropriate SAT */ - hdr =smu_sat_get_sdb_partition (chip,0xC8 + core,NULL ); -if (hdr ==NULL ) { -printk (KERN_WARNING "windfarm: can't get CPU PID fan config\n" ); -return -EINVAL ; - } - piddata = (struct smu_sdbp_cpupiddata *)&hdr[1 ]; -/* Get FVT params to get Tmax; if not found, assume default */ hdr =smu_sat_get_sdb_partition (chip,0xC4 + core,NULL );if (hdr) {
@@ -153,6 +145,16 @@ static int create_cpu_loop(int cpu)if (tmax < cpu_all_tmax) cpu_all_tmax = tmax; +kfree (hdr); + +/* Get PID params from the appropriate SAT */ + hdr =smu_sat_get_sdb_partition (chip,0xC8 + core,NULL ); +if (hdr ==NULL ) { +printk (KERN_WARNING "windfarm: can't get CPU PID fan config\n" ); +return -EINVAL ; + } + piddata = (struct smu_sdbp_cpupiddata *)&hdr[1 ]; +/* * Darwin has a minimum fan speed of 1000 rpm for the 4-way and * 515 for the 2-way. That appears to be overkill, so for now,
@@ -175,6 +177,9 @@ static int create_cpu_loop(int cpu) pid.min = fmin;wf_cpu_pid_init (&cpu_pid[cpu], &pid); + +kfree (hdr); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 180/190 powerpc/64s: Dont let DT CPU features set FSCR_DSCR
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 993e3d96fd08c3ebf7566e43be9b8cd622063e6d upstream.
The device tree CPU features binding includes FSCR bit numbers which Linux is instructed to set by firmware.
Whether that's a good idea or not, in the case of the DSCR the Linux implementation has a hard requirement that the FSCR_DSCR bit not be set by default. We use it to track when a process reads/writes to DSCR, so it must be clear to begin with.
So if firmware tells us to set FSCR_DSCR we must ignore it.
Currently this does not cause a bug in our DSCR handling because the value of FSCR that the device tree CPU features code establishes is only used by swapper. All other tasks use the value hard coded in init_task.thread.fscr.
However we'd like to fix that in a future commit, at which point this will become necessary.
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/kernel/dt_cpu_ftrs.c +8 -0
@@ -385,6 +385,14 @@ static int __init feat_enable_dscr(struc {u64 lpcr; +/* +* Linux relies on FSCR[DSCR] being clear, so that we can take the +* facility unavailable interrupt and track the task's usage of DSCR. +* See facility_unavailable_exception(). +* Clear the bit here so that feat_enable() doesn't set it. +*/ + f->fscr_bit_nr =-1 ; +feat_enable (f); lpcr =mfspr (SPRN_LPCR );
Greg Kroah-Hartman
maintainerPATCH 181/190 powerpc/64s: Save FSCR to init_task.thread.fscr after feature init
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 912c0a7f2b5daa3cbb2bc10f303981e493de73bd upstream.
At boot the FSCR is initialised via one of two paths. On most systems it's set to a hard coded value in __init_FSCR().
On newer skiboot systems we use the device tree CPU features binding, where firmware can tell Linux what bits to set in FSCR (and HFSCR).
In both cases the value that's configured at boot is not propagated into the init_task.thread.fscr value prior to the initial fork of init (pid 1), which means the value is not used by any processes other than swapper (the idle task).
For the __init_FSCR() case this is OK, because the value in init_task.thread.fscr is initialised to something sensible. However it does mean that the value set in __init_FSCR() is not used other than for swapper, which is odd and confusing.
The bigger problem is for the device tree CPU features case it prevents firmware from setting (or clearing) FSCR bits for use by user space. This means all existing kernels can not have features enabled/disabled by firmware if those features require setting/clearing FSCR bits.
We can handle both cases by saving the FSCR value into init_task.thread.fscr after we have initialised it at boot. This fixes the bug for device tree CPU features, and will allow us to simplify the initialisation for the __init_FSCR() case in a future patch.
--- arch/powerpc/kernel/prom.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/powerpc/kernel/prom.c +19 -0
@@ -658,6 +658,23 @@ static void __init early_reserve_mem(voi#endif } +#ifdef CONFIG_PPC64 +static void __init save_fscr_to_task (void ) +{ +/* +* Ensure the init_task (pid 0, aka swapper) uses the value of FSCR we +* have configured via the device tree features or via __init_FSCR(). +* That value will then be propagated to pid 1 (init) and all future +* processes. +*/ +if (early_cpu_has_feature (CPU_FTR_ARCH_207S )) + init_task.thread.fscr =mfspr (SPRN_FSCR ); +} +#else +static inline void save_fscr_to_task (void ) {}; +#endif + +void __init early_init_devtree (void *params) {phys_addr_t limit;
@@ -743,6 +760,8 @@ void __init early_init_devtree(void *parBUG (); } +save_fscr_to_task (); +#if defined(CONFIG_SMP ) && defined(CONFIG_PPC64 )/* We'll later wait for secondaries to check in; there are * NCPUS-1 non-boot CPUs :-)
Greg Kroah-Hartman
maintainerPATCH 182/190 kbuild: force to build vmlinux if CONFIG_MODVERSION=y
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 4b50c8c4eaf06a825d1c005c0b1b4a8307087b83 upstream.
This code does not work as stated in the comment.
$(CONFIG_MODVERSIONS) is always empty because it is expanded before include/config/auto.conf is included. Hence, 'make modules' with CONFIG_MODVERSION=y cannot record the version CRCs.
This has been broken since 2003, commit ("kbuild: Enable modules to be build using the "make dir/" syntax"). [1]
--- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Makefile +8 -5
@@ -542,12 +542,8 @@ KBUILD_MODULES := KBUILD_BUILTIN := 1 # If we have only "make modules", don't compile built-in objects. -# When we're building modules with modversions, we need to consider -# the built-in objects during the descend as well, in order to -# make sure the checksums are up to date before we record them. - ifeq ($(MAKECMDGOALS),modules) - KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) + KBUILD_BUILTIN := endif # If we have "make <whatever> modules", compile modules
@@ -1249,6 +1245,13 @@ ifdef CONFIG_MODULES all: modules +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. +ifdef CONFIG_MODVERSIONS + KBUILD_BUILTIN := 1 +endif + # Build modules # # A module can be listed more than once in obj-m resulting in
Greg Kroah-Hartman
maintainerPATCH 183/190 sunrpc: svcauth_gss_register_pseudoflavor must reject duplicate registrations.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit d47a5dc2888fd1b94adf1553068b8dad76cec96c upstream.
There is no valid case for supporting duplicate pseudoflavor registrations.
Currently the silent acceptance of such registrations is hiding a bug. The rpcsec_gss_krb5 module registers 2 flavours but does not unregister them, so if you load, unload, reload the module, it will happily continue to use the old registration which now has pointers to the memory were the module was originally loaded. This could lead to unexpected results.
So disallow duplicate registrations.
--- net/sunrpc/auth_gss/svcauth_gss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sunrpc/auth_gss/svcauth_gss.c +4 -2
@@ -796,9 +796,11 @@ svcauth_gss_register_pseudoflavor(u32 ps new->h.flavour = &svcauthops_gss; new->pseudoflavor = pseudoflavor; - stat =0 ; test =auth_domain_lookup (name, &new->h); -if (test != &new->h) {/* Duplicate registration */ +if (test != &new->h) { +pr_warn ("svc: duplicate registration of gss pseudo flavour %s.\n" , + name); + stat = -EADDRINUSE ;auth_domain_put (test);kfree (new->h.name); goto out_free_dom;
Greg Kroah-Hartman
maintainerPATCH 184/190 sunrpc: clean up properly in gss_mech_unregister()
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit 24c5efe41c29ee3e55bcf5a1c9f61ca8709622e8 upstream.
gss_mech_register() calls svcauth_gss_register_pseudoflavor() for each flavour, but gss_mech_unregister() does not call auth_domain_put(). This is unbalanced and makes it impossible to reload the module.
Change svcauth_gss_register_pseudoflavor() to return the registered auth_domain, and save it for later release.
--- include/linux/sunrpc/gss_api.h | 1 + include/linux/sunrpc/svcauth_gss.h | 3 ++- net/sunrpc/auth_gss/gss_mech_switch.c | 12 +++++++++--- net/sunrpc/auth_gss/svcauth_gss.c | 12 ++++++------ 4 files changed, 18 insertions(+), 10 deletions(-)
include/linux/sunrpc/gss_api.h +1 -0
@@ -83,6 +83,7 @@ struct pf_desc {u32 service;char *name;char *auth_domain_name; +struct auth_domain *domain;bool datatouch; };
include/linux/sunrpc/svcauth_gss.h +2 -1
@@ -21,7 +21,8 @@ int gss_svc_init(void);void gss_svc_shutdown (void );int gss_svc_init_net (struct net *net);void gss_svc_shutdown_net (struct net *net); -int svcauth_gss_register_pseudoflavor (u32 pseudoflavor,char * name); +struct auth_domain *svcauth_gss_register_pseudoflavor (u32 pseudoflavor, +char *name);u32 svcauth_gss_flavor (struct auth_domain *dom);#endif /* __KERNEL__ */
net/sunrpc/auth_gss/gss_mech_switch.c +9 -3
@@ -61,6 +61,8 @@ gss_mech_free(struct gss_api_mech *gm)for (i =0 ; i < gm->gm_pf_num; i++) { pf = &gm->gm_pfs[i]; +if (pf->domain) +auth_domain_put (pf->domain);kfree (pf->auth_domain_name); pf->auth_domain_name =NULL ; }
@@ -83,6 +85,7 @@ make_auth_domain_name(char *name)static int gss_mech_svc_setup (struct gss_api_mech *gm) { +struct auth_domain *dom;struct pf_desc *pf;int i, status;
@@ -92,10 +95,13 @@ gss_mech_svc_setup(struct gss_api_mech * status = -ENOMEM ;if (pf->auth_domain_name ==NULL ) goto out; - status =svcauth_gss_register_pseudoflavor (pf->pseudoflavor, - pf->auth_domain_name); -if (status) + dom =svcauth_gss_register_pseudoflavor ( + pf->pseudoflavor, pf->auth_domain_name); +if (IS_ERR (dom)) { + status =PTR_ERR (dom); goto out; + } + pf->domain = dom; }return 0 ; out:
net/sunrpc/auth_gss/svcauth_gss.c +6 -6
@@ -779,7 +779,7 @@ u32 svcauth_gss_flavor(struct auth_domaiEXPORT_SYMBOL_GPL (svcauth_gss_flavor); -int +struct auth_domain *svcauth_gss_register_pseudoflavor (u32 pseudoflavor,char * name) {struct gss_domain *new;
@@ -802,17 +802,17 @@ svcauth_gss_register_pseudoflavor(u32 ps name); stat = -EADDRINUSE ;auth_domain_put (test); -kfree (new->h.name); - goto out_free_dom; + goto out_free_name; } -return 0 ; +return test; +out_free_name: +kfree (new->h.name); out_free_dom:kfree (new); out: -return stat; +return ERR_PTR (stat); } -EXPORT_SYMBOL_GPL (svcauth_gss_register_pseudoflavor); static inline int
Greg Kroah-Hartman
maintainerPATCH 185/190 mtd: rawnand: brcmnand: fix hamming oob layout
In reply to Greg Kroah-HartmanFrom: Álvaro Fernández Rojas <[email protected]>
commit 130bbde4809b011faf64f99dddc14b4b01f440c3 upstream.
First 2 bytes are used in large-page nand.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/mtd/nand/brcmnand/brcmnand.c +7 -4
@@ -911,11 +911,14 @@ static int brcmnand_hamming_ooblayout_frif (!section) {/* * Small-page NAND use byte 6 for BBI while large-page -* NAND use byte 0. +* NAND use bytes 0 and 1. */ -if (cfg->page_size >512 ) - oobregion->offset++; - oobregion->length--; +if (cfg->page_size >512 ) { + oobregion->offset +=2 ; + oobregion->length -=2 ; + }else { + oobregion->length--; + } } }
Greg Kroah-Hartman
maintainerPATCH 186/190 mtd: rawnand: pasemi: Fix the probe error path
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit f51466901c07e6930435d30b02a21f0841174f61 upstream.
nand_cleanup() is supposed to be called on error after a successful call to nand_scan() to free all NAND resources.
There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources") which makes this change possible, hence pointing it as the commit to
fix for backporting purposes, even if this commit is not introducing
any bug.
--- drivers/mtd/nand/pasemi_nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/nand/pasemi_nand.c +3 -1
@@ -163,7 +163,7 @@ static int pasemi_nand_probe(struct platif (mtd_device_register (pasemi_nand_mtd,NULL ,0 )) {dev_err (dev,"Unable to register MTD device\n" ); err = -ENODEV ; - goto out_lpc; + goto out_cleanup_nand; } dev_info(dev, "PA Semi NAND flash at %pR, control at I/O %x\n", &res,
@@ -171,6 +171,8 @@ static int pasemi_nand_probe(struct platreturn 0 ; + out_cleanup_nand: +nand_cleanup (chip); out_lpc:release_region (lpcctl,4 ); out_ior:
Greg Kroah-Hartman
maintainerPATCH 187/190 w1: omap-hdq: cleanup to add missing newline for some dev_dbg
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
commit 5e02f3b31704e24537697bce54f8156bdb72b7a6 upstream.
Otherwise it will corrupt the console log during debugging.
--- drivers/w1/masters/omap_hdq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/w1/masters/omap_hdq.c +5 -5
@@ -176,7 +176,7 @@ static int hdq_write_byte(struct hdq_dat/* check irqstatus */ if (!(*status &OMAP_HDQ_INT_STATUS_TXCOMPLETE )) {dev_dbg (hdq_data->dev,"timeout waiting for" -" TXCOMPLETE/RXCOMPLETE, %x" , *status); +" TXCOMPLETE/RXCOMPLETE, %x\n" , *status); ret = -ETIMEDOUT ; goto out; }
@@ -187,7 +187,7 @@ static int hdq_write_byte(struct hdq_dat OMAP_HDQ_FLAG_CLEAR, &tmp_status);if (ret) {dev_dbg (hdq_data->dev,"timeout waiting GO bit" -" return to zero, %x" , tmp_status); +" return to zero, %x\n" , tmp_status); } out:
@@ -203,7 +203,7 @@ static irqreturn_t hdq_isr(int irq, voidspin_lock_irqsave (&hdq_data->hdq_spinlock, irqflags); hdq_data->hdq_irqstatus =hdq_reg_in (hdq_data,OMAP_HDQ_INT_STATUS );spin_unlock_irqrestore (&hdq_data->hdq_spinlock, irqflags); -dev_dbg (hdq_data->dev,"hdq_isr: %x" , hdq_data->hdq_irqstatus); +dev_dbg (hdq_data->dev,"hdq_isr: %x\n" , hdq_data->hdq_irqstatus); if (hdq_data->hdq_irqstatus & (OMAP_HDQ_INT_STATUS_TXCOMPLETE | OMAP_HDQ_INT_STATUS_RXCOMPLETE
@@ -311,7 +311,7 @@ static int omap_hdq_break(struct hdq_dat tmp_status = hdq_data->hdq_irqstatus;/* check irqstatus */ if (!(tmp_status &OMAP_HDQ_INT_STATUS_TIMEOUT )) { -dev_dbg (hdq_data->dev,"timeout waiting for TIMEOUT, %x" , +dev_dbg (hdq_data->dev,"timeout waiting for TIMEOUT, %x\n" , tmp_status); ret = -ETIMEDOUT ; goto out;
@@ -338,7 +338,7 @@ static int omap_hdq_break(struct hdq_dat &tmp_status);if (ret)dev_dbg (hdq_data->dev,"timeout waiting INIT&GO bits" -" return to zero, %x" , tmp_status); +" return to zero, %x\n" , tmp_status); out:mutex_unlock (&hdq_data->hdq_mutex);
Greg Kroah-Hartman
maintainerPATCH 188/190 perf probe: Do not show the skipped events
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit f41ebe9defacddeae96a872a33f0f22ced0bfcef upstream.
When a probe point is expanded to several places (like inlined) and if some of them are skipped because of blacklisted or __init function, those trace_events has no event name. It must be skipped while showing results.
Without this fix, you can see "(null):(null)" on the list,
# ./perf probe request_resource
reserve_setup is out of .text, skip it.
Added new events:
(null):(null) (on request_resource)
probe:request_resource (on request_resource)You can now use it in all perf tools, such as:
perf record -e probe:request_resource -aR sleep 1
#
With this fix, it is ignored:
# ./perf probe request_resource
reserve_setup is out of .text, skip it.
Added new events:
probe:request_resource (on request_resource)You can now use it in all perf tools, such as:
perf record -e probe:request_resource -aR sleep 1
#
--- tools/perf/builtin-probe.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/builtin-probe.c +3 -0
@@ -377,6 +377,9 @@ static int perf_add_probe_events(structfor (k =0 ; k < pev->ntevs; k++) {struct probe_trace_event *tev = &pev->tevs[k]; +/* Skipped events have no event name */ +if (!tev->event) +continue ;/* We use tev's name for showing new events */ show_perf_probe_event(tev->group, tev->event, pev,
Greg Kroah-Hartman
maintainerPATCH 189/190 perf probe: Fix to check blacklist address correctly
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 80526491c2ca6abc028c0f0dbb0707a1f35fb18a upstream.
Fix to check kprobe blacklist address correctly with relocated address by adjusting debuginfo address.
Since the address in the debuginfo is same as objdump, it is different from relocated kernel address with KASLR. Thus, 'perf probe' always misses to catch the blacklisted addresses.
Without this patch, 'perf probe' can not detect the blacklist addresses on a KASLR enabled kernel.
# perf probe kprobe_dispatcher
Failed to write event: Invalid argument
Error: Failed to add events.
#With this patch, it correctly shows the error message.
# perf probe kprobe_dispatcher
kprobe_dispatcher is blacklisted function, skip it.
Probe point 'kprobe_dispatcher' not found.
Error: Failed to add events.
#--- tools/perf/util/probe-event.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
tools/perf/util/probe-event.c +15 -6
@@ -122,7 +122,7 @@ static struct symbol *__find_kernel_funcreturn machine__find_kernel_function (host_machine, addr, mapp); } -static struct ref_reloc_sym *kernel_get_ref_reloc_sym (void ) +static struct ref_reloc_sym *kernel_get_ref_reloc_sym (struct map **pmap) {/* kmap->ref_reloc_sym should be set if host_machine is initialized */ struct kmap *kmap;
@@ -134,6 +134,10 @@ static struct ref_reloc_sym *kernel_get_ kmap =map__kmap (map);if (!kmap)return NULL ; + +if (pmap) + *pmap = map; +return kmap->ref_reloc_sym; }
@@ -145,7 +149,7 @@ static int kernel_get_symbol_address_by_struct map *map;/* ref_reloc_sym is just a label. Need a special fix*/ - reloc_sym =kernel_get_ref_reloc_sym (); + reloc_sym =kernel_get_ref_reloc_sym (NULL );if (reloc_sym &&strcmp (name, reloc_sym->name) ==0 ) *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;else {
@@ -764,6 +768,7 @@ post_process_kernel_probe_trace_events(s int ntevs) {struct ref_reloc_sym *reloc_sym; +struct map *map;char *tmp;int i, skipped =0 ;
@@ -772,7 +777,7 @@ post_process_kernel_probe_trace_events(sreturn post_process_offline_probe_trace_events (tevs, ntevs, symbol_conf.vmlinux_name); - reloc_sym =kernel_get_ref_reloc_sym (); + reloc_sym =kernel_get_ref_reloc_sym (&map);if (!reloc_sym) {pr_warning ("Relocated base symbol is not found!\n" );return -EINVAL ;
@@ -783,9 +788,13 @@ post_process_kernel_probe_trace_events(scontinue ;if (tevs[i].point.retprobe && !kretprobe_offset_is_supported ())continue ; -/* If we found a wrong one, mark it by NULL symbol */ +/* +* If we found a wrong one, mark it by NULL symbol. +* Since addresses in debuginfo is same as objdump, we need +* to convert it to addresses on memory. +*/ if (kprobe_warn_out_range (tevs[i].point.symbol, - tevs[i].point.address)) { +map__objdump_2mem (map, tevs[i].point.address))) { tmp =NULL ; skipped++; }else {
@@ -2887,7 +2896,7 @@ static int find_probe_trace_events_from_/* Note that the symbols in the kmodule are not relocated */ if (!pev->uprobes && !pev->target && (!pp->retprobe ||kretprobe_offset_is_supported ())) { - reloc_sym =kernel_get_ref_reloc_sym (); + reloc_sym =kernel_get_ref_reloc_sym (NULL );if (!reloc_sym) {pr_warning ("Relocated base symbol is not found!\n" ); ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 190/190 perf symbols: Fix debuginfo search for Ubuntu
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 85afd35575a3c1a3a905722dde5ee70b49282e70 upstream.
Reportedly, from 19.10 Ubuntu has begun mixing up the location of some debug symbol files, putting files expected to be in /usr/lib/debug/usr/lib into /usr/lib/debug/lib instead. Fix by adding another dso_binary_type.
Example on Ubuntu 20.04
Before:
$ perf record -e intel_pt//u uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.030 MB perf.data ]
$ perf script --call-trace | head -5
uname 14003 [005] 15321.764958566: cbr: 42 freq: 4219 MHz (156%)
uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4100
uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4df0
uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4e18
uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc5128After:
$ perf script --call-trace | head -5
uname 14003 [005] 15321.764958566: cbr: 42 freq: 4219 MHz (156%)
uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _start
uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start
uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start
uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start--- tools/perf/util/dso.c | 16 ++++++++++++++++ tools/perf/util/dso.h | 1 + tools/perf/util/probe-finder.c | 1 + tools/perf/util/symbol.c | 2 ++ 4 files changed, 20 insertions(+)
tools/perf/util/dso.c +16 -0
@@ -36,6 +36,7 @@ char dso__symtab_origin(const struct dso [DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO] = 'D', [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f', [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u', + [DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO] = 'x', [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO] = 'o', [DSO_BINARY_TYPE__BUILDID_DEBUGINFO] = 'b', [DSO_BINARY_TYPE__SYSTEM_PATH_DSO] = 'd',
@@ -118,6 +119,21 @@ int dso__read_binary_type_filename(constsnprintf (filename + len, size - len,"%s" , dso->long_name);break ; +case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO : +/* +* Ubuntu can mixup /usr/lib with /lib, putting debuginfo in +* /usr/lib/debug/lib when it is expected to be in +* /usr/lib/debug/usr/lib +*/ +if (strlen (dso->long_name) <9 || +strncmp (dso->long_name,"/usr/lib/" ,9 )) { + ret =-1 ; +break ; + } + len =__symbol__join_symfs (filename, size,"/usr/lib/debug" ); +snprintf (filename + len, size - len,"%s" , dso->long_name +4 ); +break ; +case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO : {const char *last_slash;
tools/perf/util/dso.h +1 -0
@@ -25,6 +25,7 @@ enum dso_binary_type {DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO ,DSO_BINARY_TYPE__FEDORA_DEBUGINFO ,DSO_BINARY_TYPE__UBUNTU_DEBUGINFO , +DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO ,DSO_BINARY_TYPE__BUILDID_DEBUGINFO ,DSO_BINARY_TYPE__SYSTEM_PATH_DSO , DSO_BINARY_TYPE__GUEST_KMODULE,
tools/perf/util/probe-finder.c +1 -0
@@ -114,6 +114,7 @@ enum dso_binary_type distro_dwarf_types[DSO_BINARY_TYPE__UBUNTU_DEBUGINFO ,DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO ,DSO_BINARY_TYPE__BUILDID_DEBUGINFO , +DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO , DSO_BINARY_TYPE__NOT_FOUND, };
tools/perf/util/symbol.c +2 -0
@@ -64,6 +64,7 @@ static enum dso_binary_type binary_type_DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ,DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ,DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO , +DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO , DSO_BINARY_TYPE__NOT_FOUND, };
@@ -1412,6 +1413,7 @@ static bool dso__is_compatible_symtab_tycase DSO_BINARY_TYPE__SYSTEM_PATH_DSO :case DSO_BINARY_TYPE__FEDORA_DEBUGINFO :case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO : +case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO :case DSO_BINARY_TYPE__BUILDID_DEBUGINFO :case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO :return !kmod && dso->kernel ==DSO_TYPE_USER ;
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
Build results:
total: 171 pass: 171 fail: 0 Qemu test results: total: 408 pass: 408 fail: 0
Guenter
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.185-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 4.14.185-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.14.y
git commit: e26bcff6a5af4b6e19e350a39e88637307e07eb8
git describe: v4.14.184-191-ge26bcff6a5af
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.184-191-ge26bcff6a5af
No regressions (compared to build v4.14.184)
No fixes (compared to build v4.14.184)
Ran 34182 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- juno-r2-compat
- juno-r2-kasan
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64
- x86-kasan
Test Suites
-----------
* build
* kselftest
* kselftest/drivers
* kselftest/filesystems
* kselftest/net
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-native/drivers
* kselftest-vsyscall-mode-native/filesystems
* kselftest-vsyscall-mode-native/net
* kselftest-vsyscall-mode-none
* kselftest-vsyscall-mode-none/drivers
* kselftest-vsyscall-mode-none/filesystems
* kselftest-vsyscall-mode-none/net
* kvm-unit-tests
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fs-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* network-basic-tests
* perf
* v4l2-compliance
Greetings!
Daniel Díaz
[email protected]
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Jon Hunter
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.185-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v4.14:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
30 tests: 30 pass, 0 failLinux version: 4.14.185-rc1-ge26bcff6a5af
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Cheers
Jon
Signature · 1 line
nvpublic