scsi: ufs: skip shutdown if hba is not powered
Subsystems (8)
Sasha Levin
maintainerPATCH 1/11 scsi: ufs: skip shutdown if hba is not powered
From: Stanley Chu <[email protected]>
[ Upstream commit f51913eef23f74c3bd07899dc7f1ed6df9e521d8 ]
In some cases, hba may go through shutdown flow without successful initialization and then make system hang.
For example, if ufshcd_change_power_mode() gets error and leads to ufshcd_hba_exit() to release resources of the host, future shutdown flow may hang the system since the host register will be accessed in unpowered state.
To solve this issue, simply add checking to skip shutdown for above kind of situation.
--- drivers/scsi/ufs/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -5371,6 +5371,9 @@ int ufshcd_shutdown(struct ufs_hba *hba) {int ret =0 ; +if (!hba->is_powered) + goto out; +if (ufshcd_is_ufs_dev_poweroff (hba) &&ufshcd_is_link_off (hba)) goto out;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/11 scsi: megaraid: disable device when probe failed after enabled device
From: Xiang Chen <[email protected]>
[ Upstream commit 70054aa39a013fa52eff432f2223b8bd5c0048f8 ]
For pci device, need to disable device when probe failed after enabled device.
--- drivers/scsi/megaraid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/megaraid.c +2 -2
@@ -4219,11 +4219,11 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)*/ if (pdev->subsystem_vendor ==PCI_VENDOR_ID_COMPAQ && pdev->subsystem_device ==0xC000 ) -return -ENODEV ; + goto out_disable_device;/* Now check the magic signature byte */ pci_read_config_word (pdev,PCI_CONF_AMISIG , &magic);if (magic !=HBA_SIGNATURE_471 && magic !=HBA_SIGNATURE ) -return -ENODEV ; + goto out_disable_device;/* Ok it is probably a megaraid */ }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/11 scsi: qla2xxx: Fix unbound sleep in fcport delete path.
In reply to Sasha LevinFrom: Quinn Tran <[email protected]>
[ Upstream commit c3b6a1d397420a0fdd97af2f06abfb78adc370df ]
There are instances, though rare, where a LOGO request cannot be sent out and the thread in free session done can wait indefinitely. Fix this by putting an upper bound to sleep.
--- drivers/scsi/qla2xxx/qla_target.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/qla2xxx/qla_target.c +4 -0
@@ -437,6 +437,7 @@ static void qlt_free_session_done(struct work_struct *work)if (logout_started) {bool traced = false; +u16 cnt =0 ;while (!ACCESS_ONCE (sess->logout_completed)) {if (!traced) {
@@ -446,6 +447,9 @@ static void qlt_free_session_done(struct work_struct *work) traced = true; }msleep (100 ); + cnt++; +if (cnt >200 ) +break ; } ql_dbg(ql_dbg_tgt_mgt, vha, 0xf087,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/11 ARM: OMAP2+: Fix missing reset done flag for am3 and am43
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 8ad8041b98c665b6147e607b749586d6e20ba73a ]
For ti,sysc-omap4 compatible devices with no sysstatus register, we do have reset done status available in the SOFTRESET bit that clears when the reset is done. This is documented for example in am437x TRM for DMTIMER_TIOCP_CFG register. The am335x TRM just says that SOFTRESET bit value 1 means reset is ongoing, but it behaves the same way clearing after reset is done.
With the ti-sysc driver handling this automatically based on no sysstatus register defined, we see warnings if SYSC_HAS_RESET_STATUS is missing in the legacy platform data:
ti-sysc 48042000.target-module: sysc_flags 00000222 != 00000022 ti-sysc 48044000.target-module: sysc_flags 00000222 != 00000022 ti-sysc 48046000.target-module: sysc_flags 00000222 != 00000022
...
Let's fix these warnings by adding SYSC_HAS_RESET_STATUS. Let's also remove the useless parentheses while at it.
If it turns out we do have ti,sysc-omap4 compatible devices without a working SOFTRESET bit we can set up additional quirk handling for it.
--- arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c +2 -1
@@ -1020,7 +1020,8 @@ static struct omap_hwmod_class_sysconfig am33xx_timer_sysc = { .rev_offs = 0x0000, .sysc_offs = 0x0010, .syss_offs = 0x0014, - .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET), + .sysc_flags =SYSC_HAS_SIDLEMODE |SYSC_HAS_SOFTRESET | + SYSC_HAS_RESET_STATUS, .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART | SIDLE_SMART_WKUP), .sysc_fields = &omap_hwmod_sysc_type2,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/11 ARM: dts: am4372: Set memory bandwidth limit for DISPC
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit f90ec6cdf674248dcad85bf9af6e064bf472b841 ]
Set memory bandwidth limit to filter out resolutions above 720p@60Hz to avoid underflow errors due to the bandwidth needs of higher resolutions.
am43xx can not provide enough bandwidth to DISPC to correctly handle 'high' resolutions.
--- arch/arm/boot/dts/am4372.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/am4372.dtsi +2 -0
@@ -1002,6 +1002,8 @@ ti,hwmods = "dss_dispc"; clocks = <&disp_clk>; clock-names = "fck"; + + max-memory-bandwidth = <230000000>; }; rfbi: rfbi@4832a800 {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/11 kvm: vmx: Limit guest PMCs to those supported on the host
In reply to Sasha LevinFrom: Jim Mattson <[email protected]>
[ Upstream commit e1fba49cc1e965a3dacd897367ba1e7b340cf0f4 ]
KVM can only virtualize as many PMCs as the host supports.
Limit the number of generic counters and fixed counters to the number of corresponding counters supported on the host, rather than to INTEL_PMC_MAX_GENERIC and INTEL_PMC_MAX_FIXED, respectively.
Note that INTEL_PMC_MAX_GENERIC is currently 32, which exceeds the 18 contiguous MSR indices reserved by Intel for event selectors. Since the existing code relies on a contiguous range of MSR indices for event selectors, it can't possibly work for more than 18 general purpose counters.
--- arch/x86/kvm/pmu_intel.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/pmu_intel.c +5 -2
@@ -260,6 +260,7 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)static void intel_pmu_refresh (struct kvm_vcpu *vcpu) {struct kvm_pmu *pmu =vcpu_to_pmu (vcpu); +struct x86_pmu_capability x86_pmu;struct kvm_cpuid_entry2 *entry;union cpuid10_eax eax;union cpuid10_edx edx;
@@ -281,8 +282,10 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)if (!pmu->version)return ; +perf_get_x86_pmu_capability (&x86_pmu); + pmu->nr_arch_gp_counters =min_t (int, eax.split.num_counters, -INTEL_PMC_MAX_GENERIC ); + x86_pmu.num_counters_gp); pmu->counter_bitmask[KVM_PMC_GP ] = ((u64 )1 << eax.split.bit_width) -1 ; pmu->available_event_types = ~entry->ebx & ((1ull << eax.split.mask_length) -1 );
@@ -292,7 +295,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) }else { pmu->nr_arch_fixed_counters =min_t (int, edx.split.num_counters_fixed, -INTEL_PMC_MAX_FIXED ); + x86_pmu.num_counters_fixed); pmu->counter_bitmask[KVM_PMC_FIXED ] = ((u64 )1 << edx.split.bit_width_fixed) -1 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/11 nl80211: fix null pointer dereference
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit b501426cf86e70649c983c52f4c823b3c40d72a3 ]
If the interface is not in MESH mode, the command 'iw wlanx mpath del' will cause kernel panic.
The root cause is null pointer access in mpp_flush_by_proxy(), as the pointer 'sdata->u.mesh.mpp_paths' is NULL for non MESH interface.
Unable to handle kernel NULL pointer dereference at virtual address 00000068
[...]
PC is at _raw_spin_lock_bh+0x20/0x5c
LR is at mesh_path_del+0x1c/0x17c [mac80211]
[...]
Process iw (pid: 4537, stack limit = 0xd83e0238)
[...]
[<c021211c>] (_raw_spin_lock_bh) from [<bf8c7648>] (mesh_path_del+0x1c/0x17c [mac80211]) [<bf8c7648>] (mesh_path_del [mac80211]) from [<bf6cdb7c>] (extack_doit+0x20/0x68 [compat]) [<bf6cdb7c>] (extack_doit [compat]) from [<c05c309c>] (genl_rcv_msg+0x274/0x30c) [<c05c309c>] (genl_rcv_msg) from [<c05c25d8>] (netlink_rcv_skb+0x58/0xac) [<c05c25d8>] (netlink_rcv_skb) from [<c05c2e14>] (genl_rcv+0x20/0x34) [<c05c2e14>] (genl_rcv) from [<c05c1f90>] (netlink_unicast+0x11c/0x204) [<c05c1f90>] (netlink_unicast) from [<c05c2420>] (netlink_sendmsg+0x30c/0x370) [<c05c2420>] (netlink_sendmsg) from [<c05886d0>] (sock_sendmsg+0x70/0x84) [<c05886d0>] (sock_sendmsg) from [<c0589f4c>] (___sys_sendmsg.part.3+0x188/0x228) [<c0589f4c>] (___sys_sendmsg.part.3) from [<c058add4>] (__sys_sendmsg+0x4c/0x70) [<c058add4>] (__sys_sendmsg) from [<c0208c80>] (ret_fast_syscall+0x0/0x44)
Code: e2822c02 e2822001 e5832004 f590f000 (e1902f9f) ---[ end trace bbd717600f8f884d ]---
--- net/wireless/nl80211.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/nl80211.c +3 -0
@@ -4779,6 +4779,9 @@ static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)if (!rdev->ops->del_mpath)return -EOPNOTSUPP ; +if (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_MESH_POINT ) +return -EOPNOTSUPP ; +return rdev_del_mpath (rdev, dev, dst); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/11 mips: Loongson: Fix the link time qualifier of 'serial_exit()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 25b69a889b638b0b7e51e2c4fe717a66bec0e566 ]
'exit' functions should be marked as __exit, not __init.
--- arch/mips/loongson64/common/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/loongson64/common/serial.c +1 -1
@@ -110,7 +110,7 @@ static int __init serial_init(void) }module_init (serial_init); -static void __init serial_exit (void ) +static void __exit serial_exit(void) {platform_device_unregister (&uart8250_device); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/11 net: hisilicon: Fix usage of uninitialized variable in function mdio_sc_cfg_reg_write()
In reply to Sasha LevinFrom: Yizhuo <[email protected]>
[ Upstream commit 53de429f4e88f538f7a8ec2b18be8c0cd9b2c8e1 ]
In function mdio_sc_cfg_reg_write(), variable "reg_value" could be uninitialized if regmap_read() fails. However, "reg_value" is used to decide the control flow later in the if statement, which is potentially unsafe.
--- drivers/net/ethernet/hisilicon/hns_mdio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns_mdio.c +5 -1
@@ -156,11 +156,15 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev, {u32 time_cnt;u32 reg_value; +int ret;regmap_write (mdio_dev->subctrl_vbase, cfg_reg, set_val);for (time_cnt =MDIO_TIMEOUT ; time_cnt; time_cnt--) { -regmap_read (mdio_dev->subctrl_vbase, st_reg, ®_value); + ret =regmap_read (mdio_dev->subctrl_vbase, st_reg, ®_value); +if (ret) +return ret; + reg_value &= st_msk;if ((!!check_st) == (!!reg_value))break ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/11 namespace: fix namespace.pl script to support relative paths
In reply to Sasha LevinFrom: Jacob Keller <[email protected]>
[ Upstream commit 82fdd12b95727640c9a8233c09d602e4518e71f7 ]
The namespace.pl script does not work properly if objtree is not set to an absolute path. The do_nm function is run from within the find function, which changes directories.
Because of this, appending objtree, $File::Find::dir, and $source, will return a path which is not valid from the current directory.
This used to work when objtree was set to an absolute path when using "make namespacecheck". It appears to have not worked when calling ./scripts/namespace.pl directly.
This behavior was changed in 7e1c04779efd ("kbuild: Use relative path for $(objtree)", 2014-05-14)
Rather than fixing the Makefile to set objtree to an absolute path, just fix namespace.pl to work when srctree and objtree are relative. Also fix the script to use an absolute path for these by default.
Use the File::Spec module for this purpose. It's been part of perl 5 since 5.005.
The curdir() function is used to get the current directory when the objtree and srctree aren't set in the environment.
rel2abs() is used to convert possibly relative objtree and srctree environment variables to absolute paths.
Finally, the catfile() function is used instead of string appending paths together, since this is more robust when joining paths together.
--- scripts/namespace.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
scripts/namespace.pl +7 -6
@@ -65,13 +65,14 @@ require 5; # at least perl 5 use strict; use File::Find; +use File::Spec; my $nm = ($ENV{'NM'} || "nm") . " -p"; my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; -my $srctree = ""; -my $objtree = ""; -$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); -$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); +my $srctree = File::Spec->curdir(); +my $objtree = File::Spec->curdir(); +$srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); +$objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); if ($#ARGV != -1) { print STDERR "usage: $0 takes no parameters\n";
@@ -229,9 +230,9 @@ sub do_nm } ($source = $basename) =~ s/\.o$//; if (-e "$source.c" || -e "$source.S") { - $source = "$objtree$File::Find::dir/$source"; + $source = File::Spec->catfile($objtree, $File::Find::dir, $source) } else { - $source = "$srctree$File::Find::dir/$source"; + $source = File::Spec->catfile($srctree, $File::Find::dir, $source) } if (! -e "$source.c" && ! -e "$source.S") { # No obvious source, exclude the object if it is conglomerate
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/11 Make filldir[64]() verify the directory entry filename is valid
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
[ Upstream commit 8a23eb804ca4f2be909e372cf5a9e7b30ae476cd ]
This has been discussed several times, and now filesystem people are talking about doing it individually at the filesystem layer, so head that off at the pass and just do it in getdents{64}().
This is partially based on a patch by Jann Horn, but checks for NUL bytes as well, and somewhat simplified.
There's also commentary about how it might be better if invalid names due to filesystem corruption don't cause an immediate failure, but only an error at the end of the readdir(), so that people can still see the filenames that are ok.
There's also been discussion about just how much POSIX strictly speaking requires this since it's about filesystem corruption. It's really more "protect user space from bad behavior" as pointed out by Jann. But since Eric Biederman looked up the POSIX wording, here it is for context:
"From readdir:
The readdir() function shall return a pointer to a structure representing the directory entry at the current position in the directory stream specified by the argument dirp, and position the directory stream at the next entry. It shall return a null pointer upon reaching the end of the directory stream. The structure dirent defined in the <dirent.h> header describes a directory entry.
From definitions:
3.129 Directory Entry (or Link)
An object that associates a filename with a file. Several directory entries can associate names with the same file.
...
3.169 Filename
A name consisting of 1 to {NAME_MAX} bytes used to name a file. The characters composing the name may be selected from the set of all character values excluding the slash character and the null byte. The filenames dot and dot-dot have special meaning. A filename is sometimes referred to as a 'pathname component'."
Note that I didn't bother adding the checks to any legacy interfaces that nobody uses.
Also note that if this ends up being noticeable as a performance regression, we can fix that to do a much more optimized model that checks for both NUL and '/' at the same time one word at a time.
We haven't really tended to optimize 'memchr()', and it only checks for one pattern at a time anyway, and we really _should_ check for NUL too (but see the comment about "soft errors" in the code about why it currently only checks for '/')
See the CONFIG_DCACHE_WORD_ACCESS case of hash_name() for how the name lookup code looks for pathname terminating characters in parallel.
--- fs/readdir.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
fs/readdir.c +40 -0
@@ -50,6 +50,40 @@ int iterate_dir(struct file *file, struct dir_context *ctx) }EXPORT_SYMBOL (iterate_dir); +/* +* POSIX says that a dirent name cannot contain NULL or a '/'. +* +* It's not 100% clear what we should really do in this case. +* The filesystem is clearly corrupted, but returning a hard +* error means that you now don't see any of the other names +* either, so that isn't a perfect alternative. +* +* And if you return an error, what error do you use? Several +* filesystems seem to have decided on EUCLEAN being the error +* code for EFSCORRUPTED, and that may be the error to use. Or +* just EIO, which is perhaps more obvious to users. +* +* In order to see the other file names in the directory, the +* caller might want to make this a "soft" error: skip the +* entry, and return the error at the end instead. +* +* Note that this should likely do a "memchr(name, 0, len)" +* check too, since that would be filesystem corruption as +* well. However, that case can't actually confuse user space, +* which has to do a strlen() on the name anyway to find the +* filename length, and the above "soft error" worry means +* that it's probably better left alone until we have that +* issue clarified. +*/ +static int verify_dirent_name (const char *name,int len) +{ +if (WARN_ON_ONCE (!len)) +return -EIO ; +if (WARN_ON_ONCE (memchr (name,'/' , len))) +return -EIO ; +return 0 ; +} +/* * Traditional linux readdir() handling.. *
@@ -159,6 +193,9 @@ static int filldir(struct dir_context *ctx, const char *name, int namlen,int reclen =ALIGN (offsetof(struct linux_dirent , d_name) + namlen +2 ,sizeof (long )); + buf->error =verify_dirent_name (name, namlen); +if (unlikely (buf->error)) +return buf->error; buf->error = -EINVAL ;/* only used if we fail.. */ if (reclen > buf->count)return -EINVAL ;
@@ -243,6 +280,9 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,int reclen =ALIGN (offsetof(struct linux_dirent64 , d_name) + namlen +1 ,sizeof (u64)); + buf->error =verify_dirent_name (name, namlen); +if (unlikely (buf->error)) +return buf->error; buf->error = -EINVAL ;/* only used if we fail.. */ if (reclen > buf->count)return -EINVAL ;
Signature · 1 line
2.20.1