diff --git a/common.sh b/common.sh index bb37c35b35..36f5f253d2 100644 --- a/common.sh +++ b/common.sh @@ -25,8 +25,11 @@ compile_uboot() { - local ubootdir="$1" - + if [[ $USE_OVERLAYFS == yes ]]; then + local ubootdir=$(overlayfs_wrapper "wrap" "$SOURCES/$BOOTSOURCEDIR" "u-boot_${LINUXFAMILY}_${BRANCH}") + else + local ubootdir="$SOURCES/$BOOTSOURCEDIR" + fi cd "$ubootdir" [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "u-boot" "$BOOTDIR-$BRANCH" "$BOARD" "$BOOTDIR-$BRANCH" @@ -38,6 +41,11 @@ compile_uboot() local version=$(grab_version "$ubootdir") display_alert "Compiling uboot" "$version" "info" + # if requires specific toolchain, check if default is suitable + if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" ; then + # try to find suitable in $SRC/toolchains, exit if not found + find_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" "UBOOT_TOOLCHAIN" + fi display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} ${UBOOT_COMPILER}gcc -dumpversion)" "info" eval CCACHE_BASEDIR="$(pwd)" ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} \ @@ -67,10 +75,11 @@ compile_uboot() # create .deb package local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH} - mkdir -p $DEST/debs/$uboot_name/usr/lib/{u-boot,$uboot_name} $DEST/debs/$uboot_name/DEBIAN + rm -rf $uboot_name + mkdir -p $uboot_name/usr/lib/{u-boot,$uboot_name} $uboot_name/DEBIAN # set up postinstall script - cat <<-EOF > $DEST/debs/$uboot_name/DEBIAN/postinst + cat <<-EOF > $uboot_name/DEBIAN/postinst #!/bin/bash source /usr/lib/u-boot/platform_install.sh [[ \$DEVICE == /dev/null ]] && exit 0 @@ -81,17 +90,17 @@ compile_uboot() sync exit 0 EOF - chmod 755 $DEST/debs/$uboot_name/DEBIAN/postinst + chmod 755 $uboot_name/DEBIAN/postinst # declare -f on non-defined function does not do anything - cat <<-EOF > $DEST/debs/$uboot_name/usr/lib/u-boot/platform_install.sh + cat <<-EOF > $uboot_name/usr/lib/u-boot/platform_install.sh DIR=/usr/lib/$uboot_name $(declare -f write_uboot_platform) $(declare -f setup_write_uboot_platform) EOF # set up control file - cat <<-END > $DEST/debs/$uboot_name/DEBIAN/control + cat <<-END > $uboot_name/DEBIAN/control Package: linux-u-boot-${BOARD}-${BRANCH} Version: $REVISION Architecture: $ARCH @@ -108,25 +117,25 @@ compile_uboot() # copy files to build directory for f in $UBOOT_FILES; do [[ ! -f $f ]] && exit_with_error "U-boot file not found" "$(basename $f)" - cp $f $DEST/debs/$uboot_name/usr/lib/$uboot_name + cp $f $uboot_name/usr/lib/$uboot_name done - cd $DEST/debs - display_alert "Building deb" "$uboot_name.deb" "info" + display_alert "Building deb" "${uboot_name}.deb" "info" eval 'dpkg -b $uboot_name 2>&1' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} rm -rf $uboot_name - local filesize=$(wc -c $DEST/debs/$uboot_name.deb | cut -f 1 -d ' ') + [[ ! -f ${uboot_name}.deb || $(stat -c '%s' "${uboot_name}.deb") -lt 5000 ]] && exit_with_error "Building u-boot failed" - if [[ $filesize -lt 50000 ]]; then - rm $DEST/debs/$uboot_name.deb - exit_with_error "Building u-boot failed, check configuration" - fi + mv ${uboot_name}.deb $DEST/debs/ } compile_kernel() { - local kerneldir="$1" + if [[ $USE_OVERLAYFS == yes ]]; then + local kerneldir=$(overlayfs_wrapper "wrap" "$SOURCES/$LINUXSOURCEDIR" "kernel_${LINUXFAMILY}_${BRANCH}") + else + local kerneldir="$SOURCES/$LINUXSOURCEDIR" + fi cd "$kerneldir" # this is a patch that Ubuntu Trusty compiler works @@ -145,6 +154,11 @@ compile_kernel() local version=$(grab_version "$kerneldir") display_alert "Compiling $BRANCH kernel" "$version" "info" + # if requires specific toolchain, check if default is suitable + if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain "$KERNEL" "$KERNEL_NEEDS_GCC" ; then + # try to find suitable in $SRC/toolchains, exit if not found + find_toolchain "KERNEL" "$KERNEL_NEEDS_GCC" "KERNEL_TOOLCHAIN" + fi display_alert "Compiler version" "${KERNEL_COMPILER}gcc $(eval ${KERNEL_TOOLCHAIN:+env PATH=$KERNEL_TOOLCHAIN:$PATH} ${KERNEL_COMPILER}gcc -dumpversion)" "info" # use proven config @@ -425,10 +439,11 @@ userpatch_create() for i in {3..1..1}; do echo -n "$i." && sleep 1; done } -# overlayfs_wrapper +# overlayfs_wrapper # # : wrap|cleanup # : path to source directory +# : suffix for merged directory to help locating it in /tmp # return value: new directory # # Assumptions/notes: @@ -440,16 +455,13 @@ userpatch_create() # overlayfs_wrapper() { - if [[ $USE_OVERLAYFS != yes && -n $2 ]]; then - echo "$2" - return - fi local operation="$1" if [[ $operation == wrap ]]; then local srcdir="$2" + local description="$3" local tempdir=$(mktemp -d) local workdir=$(mktemp -d) - local mergeddir=$(mktemp -d) + local mergeddir=$(mktemp -d --suffix="_$description") mount -t overlay overlay -o lowerdir="$srcdir",upperdir="$tempdir",workdir="$workdir" "$mergeddir" # this is executed in a subshell, so use temp files to pass extra data outside echo "$tempdir" >> /tmp/.overlayfs_wrapper_cleanup diff --git a/config/boards/pine64.conf b/config/boards/pine64.conf index 2c2542e1b4..1f5127c7d0 100644 --- a/config/boards/pine64.conf +++ b/config/boards/pine64.conf @@ -3,7 +3,7 @@ BOARD_NAME="Pine64" KERNEL_TARGET="default,dev" LINUXFAMILY=pine64 BOOTCONFIG=pine64_plus_defconfig -MODULES="sunxi_codec sunxi_i2s sunxi_sndcodec 8723bs" +MODULES="sunxi_codec sunxi_i2s sunxi_sndcodec 8723bs gt9xxf_ts" MODULES_NEXT="" CLI_TARGET="jessie,xenial:default,dev" DESKTOP_TARGET="" diff --git a/config/bootenv/pine64-default.txt b/config/bootenv/pine64-default.txt index a73d7caa7f..5ba1cc5f1d 100644 --- a/config/bootenv/pine64-default.txt +++ b/config/bootenv/pine64-default.txt @@ -1,3 +1,5 @@ verbosity=1 console=both disp_mode=720p60 +camera_type=none +pine64_lcd=off diff --git a/config/bootscripts/boot-pine64-default.cmd b/config/bootscripts/boot-pine64-default.cmd index d76f7178cc..0c5685430d 100644 --- a/config/bootscripts/boot-pine64-default.cmd +++ b/config/bootscripts/boot-pine64-default.cmd @@ -11,6 +11,8 @@ setenv console "both" setenv disp_mem_reserves "off" setenv disp_mode "720p60" setenv rootfstype "ext4" +setenv camera_type "none" +setenv pine64_lcd "off" if ext4load mmc 0 ${load_addr} /boot/armbianEnv.txt || fatload mmc 0 ${load_addr} armbianEnv.txt || ext4load mmc 0 ${load_addr} armbianEnv.txt; then env import -t ${load_addr} ${filesize} @@ -46,8 +48,22 @@ fi fdt addr ${fdt_addr} fdt resize -fdt set /soc@01c00000/disp@01000000 screen0_output_mode ${fdt_disp_mode} -#fdt set /soc@01c00000/disp@01000000 screen1_output_mode ${fdt_disp_mode} +if test ${pine64_lcd} = 1 || test ${pine64_lcd} = on; then + fdt set /soc@01c00000/disp@01000000 screen0_output_type "<0x00000001>" + fdt set /soc@01c00000/disp@01000000 screen0_output_mode "<0x00000004>" + fdt set /soc@01c00000/disp@01000000 screen1_output_mode ${fdt_disp_mode} + + fdt set /soc@01c00000/lcd0@01c0c000 lcd_used "<0x00000001>" + + fdt set /soc@01c00000/boot_disp output_type "<0x00000001>" + fdt set /soc@01c00000/boot_disp output_mode "<0x00000004>" + + fdt set /soc@01c00000/ctp status "okay" + fdt set /soc@01c00000/ctp ctp_used "<0x00000001>" + fdt set /soc@01c00000/ctp ctp_name "gt911_DB2" +else + fdt set /soc@01c00000/disp@01000000 screen0_output_mode ${fdt_disp_mode} +fi # DVI compatibility if test ${disp_dvi_compat} = 1 || test ${disp_dvi_compat} = on; then @@ -59,6 +75,21 @@ if test "${disp_mem_reserves}" = "off"; then # TODO: Remove reserved memory from DT or disable devices? fi +# default, only set status +if test "${camera_type}" = "s5k4ec"; then + fdt set /soc@01c00000/vfe@0/ status "okay" + fdt set /soc@01c00000/vfe@0/dev@0/ status "okay" +fi + +# change name, i2c address and vdd voltage +if test "${camera_type}" = "ov5640"; then + fdt set /soc@01c00000/vfe@0/dev@0/ csi0_dev0_mname "ov5640" + fdt set /soc@01c00000/vfe@0/dev@0/ csi0_dev0_twi_addr "<0x00000078>" + fdt set /soc@01c00000/vfe@0/dev@0/ csi0_dev0_iovdd_vol "<0x001b7740>" + fdt set /soc@01c00000/vfe@0/ status "okay" + fdt set /soc@01c00000/vfe@0/dev@0/ status "okay" +fi + booti ${kernel_addr} ${initrd_addr} ${fdt_addr} # Recompile with: diff --git a/config/kernel/linux-marvell-default.config b/config/kernel/linux-marvell-default.config index 7b5f9f9343..3e318562e6 100644 --- a/config/kernel/linux-marvell-default.config +++ b/config/kernel/linux-marvell-default.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.10.102 Kernel Configuration +# Linux/arm 3.10.104 Kernel Configuration # CONFIG_ARM=y CONFIG_MIGHT_HAVE_PCI=y @@ -570,7 +570,7 @@ CONFIG_NET=y CONFIG_PACKET=y # CONFIG_PACKET_DIAG is not set CONFIG_UNIX=y -CONFIG_UNIX_DIAG=y +CONFIG_UNIX_DIAG=m CONFIG_XFRM=y CONFIG_XFRM_ALGO=y # CONFIG_XFRM_USER is not set @@ -580,19 +580,29 @@ CONFIG_XFRM_ALGO=y CONFIG_NET_KEY=y # CONFIG_NET_KEY_MIGRATE is not set CONFIG_INET=y -# CONFIG_IP_MULTICAST is not set -# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +# CONFIG_IP_FIB_TRIE_STATS is not set +# CONFIG_IP_MULTIPLE_TABLES is not set +# CONFIG_IP_ROUTE_MULTIPATH is not set +# CONFIG_IP_ROUTE_VERBOSE is not set CONFIG_IP_ROUTE_CLASSID=y CONFIG_IP_PNP=y CONFIG_IP_PNP_DHCP=y CONFIG_IP_PNP_BOOTP=y CONFIG_IP_PNP_RARP=y -# CONFIG_NET_IPIP is not set -# CONFIG_NET_IPGRE_DEMUX is not set +CONFIG_NET_IPIP=m +CONFIG_NET_IPGRE_DEMUX=m CONFIG_NET_IP_TUNNEL=y +CONFIG_NET_IPGRE=m +# CONFIG_NET_IPGRE_BROADCAST is not set +CONFIG_IP_MROUTE=y +# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set +# CONFIG_IP_PIMSM_V1 is not set +# CONFIG_IP_PIMSM_V2 is not set # CONFIG_ARPD is not set # CONFIG_SYN_COOKIES is not set -# CONFIG_NET_IPVTI is not set +CONFIG_NET_IPVTI=m # CONFIG_INET_AH is not set # CONFIG_INET_ESP is not set # CONFIG_INET_IPCOMP is not set @@ -690,6 +700,7 @@ CONFIG_NETFILTER_XTABLES=m # CONFIG_NETFILTER_XT_MARK=m CONFIG_NETFILTER_XT_CONNMARK=m +# CONFIG_NETFILTER_XT_SET is not set # # Xtables targets @@ -739,6 +750,7 @@ CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m CONFIG_NETFILTER_XT_MATCH_HELPER=m CONFIG_NETFILTER_XT_MATCH_HL=m CONFIG_NETFILTER_XT_MATCH_IPRANGE=m +# CONFIG_NETFILTER_XT_MATCH_IPVS is not set CONFIG_NETFILTER_XT_MATCH_LENGTH=m CONFIG_NETFILTER_XT_MATCH_LIMIT=m CONFIG_NETFILTER_XT_MATCH_MAC=m @@ -762,8 +774,57 @@ CONFIG_NETFILTER_XT_MATCH_STRING=m CONFIG_NETFILTER_XT_MATCH_TCPMSS=m CONFIG_NETFILTER_XT_MATCH_TIME=m CONFIG_NETFILTER_XT_MATCH_U32=m -# CONFIG_IP_SET is not set -# CONFIG_IP_VS is not set +CONFIG_IP_SET=m +CONFIG_IP_SET_MAX=256 +CONFIG_IP_SET_BITMAP_IP=m +CONFIG_IP_SET_BITMAP_IPMAC=m +CONFIG_IP_SET_BITMAP_PORT=m +CONFIG_IP_SET_HASH_IP=m +CONFIG_IP_SET_HASH_IPPORT=m +CONFIG_IP_SET_HASH_IPPORTIP=m +CONFIG_IP_SET_HASH_IPPORTNET=m +CONFIG_IP_SET_HASH_NET=m +CONFIG_IP_SET_HASH_NETPORT=m +CONFIG_IP_SET_HASH_NETIFACE=m +CONFIG_IP_SET_LIST_SET=m +CONFIG_IP_VS=m +# CONFIG_IP_VS_IPV6 is not set +# CONFIG_IP_VS_DEBUG is not set +CONFIG_IP_VS_TAB_BITS=12 + +# +# IPVS transport protocol load balancing support +# +# CONFIG_IP_VS_PROTO_TCP is not set +# CONFIG_IP_VS_PROTO_UDP is not set +# CONFIG_IP_VS_PROTO_AH_ESP is not set +# CONFIG_IP_VS_PROTO_ESP is not set +# CONFIG_IP_VS_PROTO_AH is not set +# CONFIG_IP_VS_PROTO_SCTP is not set + +# +# IPVS scheduler +# +# CONFIG_IP_VS_RR is not set +# CONFIG_IP_VS_WRR is not set +# CONFIG_IP_VS_LC is not set +# CONFIG_IP_VS_WLC is not set +# CONFIG_IP_VS_LBLC is not set +# CONFIG_IP_VS_LBLCR is not set +# CONFIG_IP_VS_DH is not set +# CONFIG_IP_VS_SH is not set +# CONFIG_IP_VS_SED is not set +# CONFIG_IP_VS_NQ is not set + +# +# IPVS SH scheduler +# +CONFIG_IP_VS_SH_TAB_BITS=8 + +# +# IPVS application helper +# +# CONFIG_IP_VS_NFCT is not set # # IP: Netfilter Configuration @@ -792,7 +853,7 @@ CONFIG_IP_NF_TARGET_CLUSTERIP=m CONFIG_IP_NF_TARGET_ECN=m CONFIG_IP_NF_TARGET_TTL=m CONFIG_IP_NF_RAW=m -# CONFIG_IP_NF_SECURITY is not set +CONFIG_IP_NF_SECURITY=m CONFIG_IP_NF_ARPTABLES=m CONFIG_IP_NF_ARPFILTER=m CONFIG_IP_NF_ARP_MANGLE=m @@ -817,17 +878,42 @@ CONFIG_IP6_NF_FILTER=m CONFIG_IP6_NF_TARGET_REJECT=m CONFIG_IP6_NF_MANGLE=m CONFIG_IP6_NF_RAW=m -# CONFIG_IP6_NF_SECURITY is not set +CONFIG_IP6_NF_SECURITY=m CONFIG_NF_NAT_IPV6=m CONFIG_IP6_NF_TARGET_MASQUERADE=m CONFIG_IP6_NF_TARGET_NPT=m -# CONFIG_BRIDGE_NF_EBTABLES is not set +CONFIG_BRIDGE_NF_EBTABLES=m +CONFIG_BRIDGE_EBT_BROUTE=m +CONFIG_BRIDGE_EBT_T_FILTER=m +CONFIG_BRIDGE_EBT_T_NAT=m +CONFIG_BRIDGE_EBT_802_3=m +CONFIG_BRIDGE_EBT_AMONG=m +CONFIG_BRIDGE_EBT_ARP=m +CONFIG_BRIDGE_EBT_IP=m +CONFIG_BRIDGE_EBT_IP6=m +CONFIG_BRIDGE_EBT_LIMIT=m +CONFIG_BRIDGE_EBT_MARK=m +CONFIG_BRIDGE_EBT_PKTTYPE=m +CONFIG_BRIDGE_EBT_STP=m +CONFIG_BRIDGE_EBT_VLAN=m +CONFIG_BRIDGE_EBT_ARPREPLY=m +CONFIG_BRIDGE_EBT_DNAT=m +CONFIG_BRIDGE_EBT_MARK_T=m +CONFIG_BRIDGE_EBT_REDIRECT=m +CONFIG_BRIDGE_EBT_SNAT=m +CONFIG_BRIDGE_EBT_LOG=m +CONFIG_BRIDGE_EBT_ULOG=m +CONFIG_BRIDGE_EBT_NFLOG=m # CONFIG_IP_DCCP is not set # CONFIG_IP_SCTP is not set # CONFIG_RDS is not set # CONFIG_TIPC is not set # CONFIG_ATM is not set -# CONFIG_L2TP is not set +CONFIG_L2TP=m +# CONFIG_L2TP_DEBUGFS is not set +CONFIG_L2TP_V3=y +CONFIG_L2TP_IP=m +CONFIG_L2TP_ETH=m CONFIG_STP=y CONFIG_BRIDGE=y CONFIG_BRIDGE_IGMP_SNOOPING=y @@ -845,7 +931,51 @@ CONFIG_LLC=y # CONFIG_LAPB is not set # CONFIG_PHONET is not set # CONFIG_IEEE802154 is not set -# CONFIG_NET_SCHED is not set +CONFIG_NET_SCHED=y + +# +# Queueing/Scheduling +# +CONFIG_NET_SCH_CBQ=m +CONFIG_NET_SCH_HTB=m +CONFIG_NET_SCH_HFSC=m +CONFIG_NET_SCH_PRIO=m +CONFIG_NET_SCH_MULTIQ=m +CONFIG_NET_SCH_RED=m +CONFIG_NET_SCH_SFB=m +CONFIG_NET_SCH_SFQ=m +CONFIG_NET_SCH_TEQL=m +CONFIG_NET_SCH_TBF=m +CONFIG_NET_SCH_GRED=m +CONFIG_NET_SCH_DSMARK=m +CONFIG_NET_SCH_NETEM=m +CONFIG_NET_SCH_DRR=m +CONFIG_NET_SCH_MQPRIO=m +CONFIG_NET_SCH_CHOKE=m +CONFIG_NET_SCH_QFQ=m +CONFIG_NET_SCH_CODEL=m +CONFIG_NET_SCH_FQ_CODEL=m +CONFIG_NET_SCH_PLUG=m + +# +# Classification +# +CONFIG_NET_CLS=y +CONFIG_NET_CLS_BASIC=m +CONFIG_NET_CLS_TCINDEX=m +CONFIG_NET_CLS_ROUTE4=m +CONFIG_NET_CLS_FW=m +CONFIG_NET_CLS_U32=m +# CONFIG_CLS_U32_PERF is not set +# CONFIG_CLS_U32_MARK is not set +CONFIG_NET_CLS_RSVP=m +CONFIG_NET_CLS_RSVP6=m +CONFIG_NET_CLS_FLOW=m +CONFIG_NET_CLS_CGROUP=m +# CONFIG_NET_EMATCH is not set +# CONFIG_NET_CLS_ACT is not set +# CONFIG_NET_CLS_IND is not set +CONFIG_NET_SCH_FIFO=y # CONFIG_DCB is not set CONFIG_DNS_RESOLVER=y # CONFIG_BATMAN_ADV is not set @@ -1421,8 +1551,13 @@ CONFIG_BONDING=y # CONFIG_DUMMY is not set # CONFIG_EQUALIZER is not set # CONFIG_NET_FC is not set -# CONFIG_MII is not set -# CONFIG_NET_TEAM is not set +CONFIG_MII=m +CONFIG_NET_TEAM=m +# CONFIG_NET_TEAM_MODE_BROADCAST is not set +# CONFIG_NET_TEAM_MODE_ROUNDROBIN is not set +# CONFIG_NET_TEAM_MODE_RANDOM is not set +# CONFIG_NET_TEAM_MODE_ACTIVEBACKUP is not set +# CONFIG_NET_TEAM_MODE_LOADBALANCE is not set CONFIG_MACVLAN=y CONFIG_MACVTAP=y CONFIG_VXLAN=y @@ -1859,8 +1994,19 @@ CONFIG_MARVELL_PHY=y # CONFIG_MDIO_BUS_MUX_GPIO is not set # CONFIG_MDIO_BUS_MUX_MMIOREG is not set # CONFIG_MICREL_KS8995MA is not set -# CONFIG_PPP is not set +CONFIG_PPP=m +CONFIG_PPP_BSDCOMP=m +CONFIG_PPP_DEFLATE=m +CONFIG_PPP_FILTER=y +CONFIG_PPP_MPPE=m +CONFIG_PPP_MULTILINK=y +CONFIG_PPPOE=m +CONFIG_PPTP=m +CONFIG_PPPOL2TP=m +# CONFIG_PPP_ASYNC is not set +# CONFIG_PPP_SYNC_TTY is not set # CONFIG_SLIP is not set +CONFIG_SLHC=m # # USB Network Adapters diff --git a/config/kernel/linux-marvell-next.config b/config/kernel/linux-marvell-next.config index f11f654d90..21877a8b01 100644 --- a/config/kernel/linux-marvell-next.config +++ b/config/kernel/linux-marvell-next.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.7.3 Kernel Configuration +# Linux/arm 4.8.6 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y @@ -63,6 +63,8 @@ CONFIG_HARDIRQS_SW_RESEND=y CONFIG_GENERIC_IRQ_CHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_IRQ_DOMAIN_DEBUG=y CONFIG_IRQ_FORCED_THREADING=y @@ -222,6 +224,8 @@ CONFIG_HAVE_PERF_REGS=y CONFIG_HAVE_PERF_USER_STACK_DUMP=y CONFIG_HAVE_ARCH_JUMP_LABEL=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_HAVE_GCC_PLUGINS=y +# CONFIG_GCC_PLUGINS is not set CONFIG_HAVE_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR is not set CONFIG_CC_STACKPROTECTOR_NONE=y @@ -308,7 +312,6 @@ CONFIG_FREEZER=y # CONFIG_MMU=y CONFIG_ARCH_MULTIPLATFORM=y -# CONFIG_ARCH_CLPS711X is not set # CONFIG_ARCH_GEMINI is not set # CONFIG_ARCH_EBSA110 is not set # CONFIG_ARCH_EP93XX is not set @@ -456,6 +459,11 @@ CONFIG_ARM_ERRATA_720789=y # CONFIG_ARM_ERRATA_775420 is not set # CONFIG_ARM_ERRATA_798181 is not set # CONFIG_ARM_ERRATA_773022 is not set +# CONFIG_ARM_ERRATA_818325_852422 is not set +# CONFIG_ARM_ERRATA_821420 is not set +# CONFIG_ARM_ERRATA_825619 is not set +# CONFIG_ARM_ERRATA_852421 is not set +# CONFIG_ARM_ERRATA_852423 is not set # # Bus support @@ -464,7 +472,8 @@ CONFIG_PCI=y # CONFIG_PCI_DOMAINS_GENERIC is not set CONFIG_PCI_SYSCALL=y # CONFIG_PCIEPORTBUS is not set -# CONFIG_PCI_MSI is not set +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y # CONFIG_PCI_DEBUG is not set # CONFIG_PCI_REALLOC_ENABLE_AUTO is not set # CONFIG_PCI_STUB is not set @@ -695,7 +704,7 @@ CONFIG_XFRM_USER=y # CONFIG_XFRM_SUB_POLICY is not set # CONFIG_XFRM_MIGRATE is not set # CONFIG_XFRM_STATISTICS is not set -CONFIG_XFRM_IPCOMP=y +CONFIG_XFRM_IPCOMP=m CONFIG_NET_KEY=y # CONFIG_NET_KEY_MIGRATE is not set CONFIG_INET=y @@ -720,18 +729,18 @@ CONFIG_IP_MROUTE_MULTIPLE_TABLES=y CONFIG_IP_PIMSM_V1=y CONFIG_IP_PIMSM_V2=y CONFIG_SYN_COOKIES=y -# CONFIG_NET_IPVTI is not set +CONFIG_NET_IPVTI=m CONFIG_NET_UDP_TUNNEL=y -# CONFIG_NET_FOU is not set +CONFIG_NET_FOU=m # CONFIG_NET_FOU_IP_TUNNELS is not set -CONFIG_INET_AH=y -CONFIG_INET_ESP=y -CONFIG_INET_IPCOMP=y -CONFIG_INET_XFRM_TUNNEL=y +CONFIG_INET_AH=m +CONFIG_INET_ESP=m +CONFIG_INET_IPCOMP=m +CONFIG_INET_XFRM_TUNNEL=m CONFIG_INET_TUNNEL=y -CONFIG_INET_XFRM_MODE_TRANSPORT=y -CONFIG_INET_XFRM_MODE_TUNNEL=y -CONFIG_INET_XFRM_MODE_BEET=y +CONFIG_INET_XFRM_MODE_TRANSPORT=m +CONFIG_INET_XFRM_MODE_TUNNEL=m +CONFIG_INET_XFRM_MODE_BEET=m CONFIG_INET_DIAG=m CONFIG_INET_TCP_DIAG=m CONFIG_INET_UDP_DIAG=m @@ -744,13 +753,14 @@ CONFIG_TCP_CONG_HTCP=y CONFIG_TCP_CONG_HSTCP=y CONFIG_TCP_CONG_HYBLA=y CONFIG_TCP_CONG_VEGAS=y +CONFIG_TCP_CONG_NV=y CONFIG_TCP_CONG_SCALABLE=y CONFIG_TCP_CONG_LP=y CONFIG_TCP_CONG_VENO=y CONFIG_TCP_CONG_YEAH=y CONFIG_TCP_CONG_ILLINOIS=y -# CONFIG_TCP_CONG_DCTCP is not set -# CONFIG_TCP_CONG_CDG is not set +CONFIG_TCP_CONG_DCTCP=y +CONFIG_TCP_CONG_CDG=y # CONFIG_DEFAULT_BIC is not set CONFIG_DEFAULT_CUBIC=y # CONFIG_DEFAULT_HTCP is not set @@ -758,6 +768,8 @@ CONFIG_DEFAULT_CUBIC=y # CONFIG_DEFAULT_VEGAS is not set # CONFIG_DEFAULT_VENO is not set # CONFIG_DEFAULT_WESTWOOD is not set +# CONFIG_DEFAULT_DCTCP is not set +# CONFIG_DEFAULT_CDG is not set # CONFIG_DEFAULT_RENO is not set CONFIG_DEFAULT_TCP_CONG="cubic" CONFIG_TCP_MD5SIG=y @@ -776,13 +788,13 @@ CONFIG_INET6_XFRM_MODE_TRANSPORT=m CONFIG_INET6_XFRM_MODE_TUNNEL=m CONFIG_INET6_XFRM_MODE_BEET=m CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m -# CONFIG_IPV6_VTI is not set +CONFIG_IPV6_VTI=m CONFIG_IPV6_SIT=m CONFIG_IPV6_SIT_6RD=y CONFIG_IPV6_NDISC_NODETYPE=y CONFIG_IPV6_TUNNEL=m -# CONFIG_IPV6_GRE is not set -# CONFIG_IPV6_FOU is not set +CONFIG_IPV6_GRE=m +CONFIG_IPV6_FOU=m # CONFIG_IPV6_FOU_TUNNEL is not set CONFIG_IPV6_MULTIPLE_TABLES=y CONFIG_IPV6_SUBTREES=y @@ -1247,6 +1259,7 @@ CONFIG_NET_CLS_FLOW=m CONFIG_NET_CLS_CGROUP=y # CONFIG_NET_CLS_BPF is not set # CONFIG_NET_CLS_FLOWER is not set +CONFIG_NET_CLS_MATCHALL=y CONFIG_NET_EMATCH=y CONFIG_NET_EMATCH_STACK=32 CONFIG_NET_EMATCH_CMP=m @@ -1286,6 +1299,7 @@ CONFIG_NET_MPLS_GSO=m CONFIG_HSR=m CONFIG_NET_SWITCHDEV=y # CONFIG_NET_L3_MASTER_DEV is not set +# CONFIG_NET_NCSI is not set CONFIG_RPS=y CONFIG_RFS_ACCEL=y CONFIG_XPS=y @@ -1518,6 +1532,7 @@ CONFIG_MTD_NAND_PXA3xx=y # CONFIG_MTD_NAND_PLATFORM is not set # CONFIG_MTD_NAND_ORION is not set # CONFIG_MTD_NAND_HISI504 is not set +# CONFIG_MTD_NAND_MTK is not set # CONFIG_MTD_ONENAND is not set # @@ -1528,6 +1543,7 @@ CONFIG_MTD_NAND_PXA3xx=y CONFIG_MTD_SPI_NOR=y # CONFIG_MTD_MT81xx_NOR is not set CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +# CONFIG_SPI_CADENCE_QUADSPI is not set # CONFIG_MTD_UBI is not set CONFIG_DTC=y CONFIG_OF=y @@ -1585,7 +1601,6 @@ CONFIG_BLK_DEV_NVME=m # CONFIG_ISL29003 is not set # CONFIG_ISL29020 is not set # CONFIG_SENSORS_TSL2550 is not set -# CONFIG_SENSORS_BH1780 is not set # CONFIG_SENSORS_BH1770 is not set # CONFIG_SENSORS_APDS990X is not set # CONFIG_HMC6352 is not set @@ -1654,8 +1669,7 @@ CONFIG_EEPROM_AT24=y # # CONFIG_ECHO is not set # CONFIG_CXL_BASE is not set -# CONFIG_CXL_KERNEL_API is not set -# CONFIG_CXL_EEH is not set +# CONFIG_CXL_AFU_DRIVER_OPS is not set CONFIG_HAVE_IDE=y # CONFIG_IDE is not set @@ -1878,7 +1892,12 @@ CONFIG_BONDING=y # CONFIG_EQUALIZER is not set CONFIG_NET_FC=y CONFIG_IFB=m -# CONFIG_NET_TEAM is not set +CONFIG_NET_TEAM=m +CONFIG_NET_TEAM_MODE_BROADCAST=m +CONFIG_NET_TEAM_MODE_ROUNDROBIN=m +CONFIG_NET_TEAM_MODE_RANDOM=m +CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=m +CONFIG_NET_TEAM_MODE_LOADBALANCE=m CONFIG_MACVLAN=y CONFIG_MACVTAP=y CONFIG_IPVLAN=y @@ -1909,15 +1928,14 @@ CONFIG_ATM_DUMMY=m # # CAIF transport drivers # -# CONFIG_VHOST_NET is not set -# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set # # Distributed Switch Architecture drivers # # CONFIG_NET_DSA_MV88E6060 is not set -CONFIG_NET_DSA_MV88E6XXX=m # CONFIG_NET_DSA_BCM_SF2 is not set +# CONFIG_B53 is not set +CONFIG_NET_DSA_MV88E6XXX=m CONFIG_ETHERNET=y CONFIG_NET_VENDOR_3COM=y # CONFIG_VORTEX is not set @@ -1984,6 +2002,7 @@ CONFIG_NET_VENDOR_FARADAY=y # CONFIG_FTGMAC100 is not set CONFIG_NET_VENDOR_HISILICON=y # CONFIG_HIX5HD2_GMAC is not set +# CONFIG_HISI_FEMAC is not set # CONFIG_HIP04_ETH is not set # CONFIG_HNS is not set # CONFIG_HNS_DSAF is not set @@ -1998,7 +2017,10 @@ CONFIG_NET_VENDOR_INTEL=y # CONFIG_IGBVF is not set # CONFIG_IXGB is not set # CONFIG_IXGBE is not set +# CONFIG_IXGBEVF is not set # CONFIG_I40E is not set +# CONFIG_I40EVF is not set +# CONFIG_FM10K is not set CONFIG_NET_VENDOR_I825XX=y # CONFIG_JME is not set CONFIG_NET_VENDOR_MARVELL=y @@ -2030,6 +2052,7 @@ CONFIG_NET_VENDOR_NATSEMI=y # CONFIG_NATSEMI is not set # CONFIG_NS83820 is not set CONFIG_NET_VENDOR_NETRONOME=y +# CONFIG_NFP_NETVF is not set CONFIG_NET_VENDOR_8390=y # CONFIG_AX88796 is not set # CONFIG_NE2K_PCI is not set @@ -2095,6 +2118,7 @@ CONFIG_NET_VENDOR_WIZNET=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_PHYLIB=y +CONFIG_SWPHY=y # # MII PHY device drivers @@ -2127,9 +2151,23 @@ CONFIG_FIXED_PHY=y # CONFIG_MDIO_BUS_MUX_GPIO is not set # CONFIG_MDIO_BUS_MUX_MMIOREG is not set # CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_MDIO_HISI_FEMAC is not set # CONFIG_MICREL_KS8995MA is not set -# CONFIG_PPP is not set +CONFIG_PPP=m +CONFIG_PPP_BSDCOMP=m +CONFIG_PPP_DEFLATE=m +CONFIG_PPP_FILTER=y +CONFIG_PPP_MPPE=m +CONFIG_PPP_MULTILINK=y +# CONFIG_PPPOATM is not set +CONFIG_PPPOE=m +CONFIG_PPTP=m +CONFIG_PPPOL2TP=m +# CONFIG_PPP_ASYNC is not set +# CONFIG_PPP_SYNC_TTY is not set # CONFIG_SLIP is not set +CONFIG_SLHC=m CONFIG_USB_NET_DRIVERS=y # CONFIG_USB_CATC is not set # CONFIG_USB_KAWETH is not set @@ -2410,7 +2448,6 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_ALTERA_UART is not set # CONFIG_SERIAL_IFX6X60 is not set # CONFIG_SERIAL_XILINX_PS_UART is not set -# CONFIG_SERIAL_MPS2_UART is not set # CONFIG_SERIAL_ARC is not set # CONFIG_SERIAL_RP2 is not set # CONFIG_SERIAL_FSL_LPUART is not set @@ -2570,11 +2607,10 @@ CONFIG_PINCTRL_ARMADA_38X=y CONFIG_PINCTRL_ARMADA_39X=y CONFIG_PINCTRL_ARMADA_XP=y CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y -CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y -CONFIG_ARCH_REQUIRE_GPIOLIB=y CONFIG_GPIOLIB=y CONFIG_GPIO_DEVRES=y CONFIG_OF_GPIO=y +CONFIG_GPIOLIB_IRQCHIP=y # CONFIG_DEBUG_GPIO is not set CONFIG_GPIO_SYSFS=y @@ -2670,6 +2706,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_F71805F is not set # CONFIG_SENSORS_F71882FG is not set # CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_FTSTEUTATES is not set # CONFIG_SENSORS_GL518SM is not set # CONFIG_SENSORS_GL520SM is not set # CONFIG_SENSORS_G760A is not set @@ -2728,6 +2765,7 @@ CONFIG_SENSORS_MAX31790=m # CONFIG_PMBUS is not set # CONFIG_SENSORS_SHT15 is not set # CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set # CONFIG_SENSORS_SHTC1 is not set # CONFIG_SENSORS_SIS5595 is not set # CONFIG_SENSORS_DME1737 is not set @@ -2748,6 +2786,7 @@ CONFIG_SENSORS_MAX31790=m # CONFIG_SENSORS_AMC6821 is not set # CONFIG_SENSORS_INA209 is not set # CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set # CONFIG_SENSORS_TC74 is not set # CONFIG_SENSORS_THMC50 is not set # CONFIG_SENSORS_TMP102 is not set @@ -3124,6 +3163,7 @@ CONFIG_SND_KIRKWOOD_SOC=y # Allwinner SoC Audio support # # CONFIG_SND_SUN4I_CODEC is not set +# CONFIG_SND_SUN4I_I2S is not set # CONFIG_SND_SUN4I_SPDIF is not set # CONFIG_SND_SOC_XTFPGA_I2S is not set CONFIG_SND_SOC_I2C_AND_SPI=y @@ -3133,13 +3173,16 @@ CONFIG_SND_SOC_I2C_AND_SPI=y # # CONFIG_SND_SOC_AC97_CODEC is not set # CONFIG_SND_SOC_ADAU1701 is not set +# CONFIG_SND_SOC_ADAU7002 is not set # CONFIG_SND_SOC_AK4104 is not set # CONFIG_SND_SOC_AK4554 is not set # CONFIG_SND_SOC_AK4613 is not set # CONFIG_SND_SOC_AK4642 is not set # CONFIG_SND_SOC_AK5386 is not set # CONFIG_SND_SOC_ALC5623 is not set +# CONFIG_SND_SOC_BT_SCO is not set # CONFIG_SND_SOC_CS35L32 is not set +# CONFIG_SND_SOC_CS35L33 is not set CONFIG_SND_SOC_CS42L51=y CONFIG_SND_SOC_CS42L51_I2C=y # CONFIG_SND_SOC_CS42L52 is not set @@ -3151,9 +3194,12 @@ CONFIG_SND_SOC_CS42L51_I2C=y # CONFIG_SND_SOC_CS4271_SPI is not set # CONFIG_SND_SOC_CS42XX8_I2C is not set # CONFIG_SND_SOC_CS4349 is not set +# CONFIG_SND_SOC_CS53L30 is not set # CONFIG_SND_SOC_ES8328 is not set # CONFIG_SND_SOC_GTM601 is not set # CONFIG_SND_SOC_INNO_RK3036 is not set +# CONFIG_SND_SOC_MAX98504 is not set +# CONFIG_SND_SOC_MAX9860 is not set # CONFIG_SND_SOC_PCM1681 is not set # CONFIG_SND_SOC_PCM179X_I2C is not set # CONFIG_SND_SOC_PCM179X_SPI is not set @@ -3203,7 +3249,9 @@ CONFIG_SND_SOC_WM8960=m # CONFIG_SND_SOC_WM8962 is not set # CONFIG_SND_SOC_WM8974 is not set # CONFIG_SND_SOC_WM8978 is not set +# CONFIG_SND_SOC_WM8985 is not set # CONFIG_SND_SOC_TPA6130A2 is not set +CONFIG_SND_SIMPLE_CARD_UTILS=y CONFIG_SND_SIMPLE_CARD=y # CONFIG_SOUND_PRIME is not set @@ -3251,6 +3299,7 @@ CONFIG_HID_CMEDIA=m # CONFIG_HID_TWINHAN is not set # CONFIG_HID_KENSINGTON is not set # CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LED is not set # CONFIG_HID_LENOVO is not set # CONFIG_HID_LOGITECH is not set # CONFIG_HID_MAGICMOUSE is not set @@ -3285,6 +3334,7 @@ CONFIG_HID_CMEDIA=m # CONFIG_HID_ZEROPLUS is not set # CONFIG_HID_ZYDACRON is not set # CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_ALPS is not set # # USB HID support @@ -3401,7 +3451,6 @@ CONFIG_USB_STORAGE=y # CONFIG_USB_RIO500 is not set # CONFIG_USB_LEGOTOWER is not set # CONFIG_USB_LCD is not set -# CONFIG_USB_LED is not set # CONFIG_USB_CYPRESS_CY7C63 is not set # CONFIG_USB_CYTHERM is not set # CONFIG_USB_IDMOUSE is not set @@ -3430,7 +3479,6 @@ CONFIG_USB_ATM=m # # CONFIG_USB_PHY is not set # CONFIG_NOP_USB_XCEIV is not set -# CONFIG_AM335X_PHY_USB is not set # CONFIG_USB_GPIO_VBUS is not set # CONFIG_USB_ISP1301 is not set # CONFIG_USB_ULPI is not set @@ -3516,6 +3564,7 @@ CONFIG_LEDS_IS31FL32XX=m CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_TIMER=y # CONFIG_LEDS_TRIGGER_ONESHOT is not set +CONFIG_LEDS_TRIGGER_DISK=y # CONFIG_LEDS_TRIGGER_MTD is not set CONFIG_LEDS_TRIGGER_HEARTBEAT=y # CONFIG_LEDS_TRIGGER_BACKLIGHT is not set @@ -3589,6 +3638,7 @@ CONFIG_RTC_DRV_DS1302=m # CONFIG_RTC_DRV_DS1343 is not set # CONFIG_RTC_DRV_DS1347 is not set # CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6916 is not set # CONFIG_RTC_DRV_R9701 is not set # CONFIG_RTC_DRV_RX4581 is not set CONFIG_RTC_DRV_RX6110=m @@ -3712,6 +3762,7 @@ CONFIG_LNET_MAX_PAYLOAD=1048576 # CONFIG_WILC1000_SDIO is not set # CONFIG_WILC1000_SPI is not set # CONFIG_MOST is not set +# CONFIG_KS7010 is not set # CONFIG_GOLDFISH is not set # CONFIG_CHROME_PLATFORMS is not set CONFIG_CLKDEV_LOOKUP=y @@ -3731,7 +3782,6 @@ CONFIG_CLK_QORIQ=y # CONFIG_COMMON_CLK_NXP is not set # CONFIG_COMMON_CLK_PXA is not set # CONFIG_COMMON_CLK_PIC32 is not set -# CONFIG_COMMON_CLK_OXNAS is not set CONFIG_MVEBU_CLK_COMMON=y CONFIG_MVEBU_CLK_CPU=y CONFIG_MVEBU_CLK_COREDIV=y @@ -3741,6 +3791,7 @@ CONFIG_ARMADA_38X_CLK=y CONFIG_ARMADA_39X_CLK=y CONFIG_ARMADA_XP_CLK=y CONFIG_DOVE_CLK=y +# CONFIG_SUNXI_CCU is not set # # Hardware Spinlock drivers @@ -3775,6 +3826,10 @@ CONFIG_ORION_TIMER=y # # SOC (System On Chip) specific Drivers # + +# +# Broadcom SoC drivers +# # CONFIG_SOC_BRCMSTB is not set # CONFIG_SUNXI_SRAM is not set # CONFIG_SOC_TI is not set @@ -3838,6 +3893,7 @@ CONFIG_HAVE_ARM_SMCCC=y # File systems # CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_FS_IOMAP=y # CONFIG_EXT2_FS is not set CONFIG_EXT3_FS=y CONFIG_EXT3_FS_POSIX_ACL=y @@ -3885,9 +3941,10 @@ CONFIG_F2FS_FS_POSIX_ACL=y # CONFIG_F2FS_FAULT_INJECTION is not set CONFIG_FS_POSIX_ACL=y CONFIG_EXPORTFS=y +# CONFIG_EXPORTFS_BLOCK_OPS is not set CONFIG_FILE_LOCKING=y CONFIG_MANDATORY_FILE_LOCKING=y -CONFIG_FS_ENCRYPTION=m +CONFIG_FS_ENCRYPTION=y CONFIG_FSNOTIFY=y CONFIG_DNOTIFY=y CONFIG_INOTIFY_USER=y @@ -3997,6 +4054,7 @@ CONFIG_NFSD_V3_ACL=y CONFIG_NFSD_V4=y # CONFIG_NFSD_BLOCKLAYOUT is not set # CONFIG_NFSD_SCSILAYOUT is not set +# CONFIG_NFSD_FLEXFILELAYOUT is not set # CONFIG_NFSD_FAULT_INJECTION is not set CONFIG_GRACE_PERIOD=y CONFIG_LOCKD=y @@ -4257,6 +4315,9 @@ CONFIG_ENCRYPTED_KEYS=y # CONFIG_SECURITY_DMESG_RESTRICT is not set # CONFIG_SECURITY is not set # CONFIG_SECURITYFS is not set +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +CONFIG_HAVE_ARCH_HARDENED_USERCOPY=y +# CONFIG_HARDENED_USERCOPY is not set CONFIG_DEFAULT_SECURITY_DAC=y CONFIG_DEFAULT_SECURITY="" CONFIG_XOR_BLOCKS=y @@ -4278,7 +4339,11 @@ CONFIG_CRYPTO_RNG2=y CONFIG_CRYPTO_RNG_DEFAULT=y CONFIG_CRYPTO_AKCIPHER2=y CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_KPP=y CONFIG_CRYPTO_RSA=y +CONFIG_CRYPTO_DH=y +CONFIG_CRYPTO_ECDH=y CONFIG_CRYPTO_MANAGER=y CONFIG_CRYPTO_MANAGER2=y CONFIG_CRYPTO_USER=m @@ -4340,6 +4405,7 @@ CONFIG_CRYPTO_RMD320=m CONFIG_CRYPTO_SHA1=y CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_SHA512=m +CONFIG_CRYPTO_SHA3=y # CONFIG_CRYPTO_TGR192 is not set CONFIG_CRYPTO_WP512=m @@ -4485,3 +4551,5 @@ CONFIG_OID_REGISTRY=y CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_VIRTUALIZATION=y +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set diff --git a/config/kernel/linux-odroidc1-default.config b/config/kernel/linux-odroidc1-default.config index 436b3097ca..1ced5f2f32 100644 --- a/config/kernel/linux-odroidc1-default.config +++ b/config/kernel/linux-odroidc1-default.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.10.103 Kernel Configuration +# Linux/arm 3.10.104 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -4684,6 +4684,7 @@ CONFIG_BACKPORT_USB_NET_DRIVERS=y CONFIG_BACKPORT_USB_USBNET=m CONFIG_BACKPORT_USB_NET_CDCETHER=m CONFIG_BACKPORT_USB_NET_CDC_NCM=m +CONFIG_BACKPORT_USB_NET_HUAWEI_CDC_NCM=m CONFIG_BACKPORT_USB_NET_CDC_MBIM=m CONFIG_BACKPORT_USB_NET_RNDIS_HOST=m CONFIG_BACKPORT_USB_NET_QMI_WWAN=m diff --git a/config/kernel/linux-pine64-default.config b/config/kernel/linux-pine64-default.config index 34d4d88384..16f930fedc 100644 --- a/config/kernel/linux-pine64-default.config +++ b/config/kernel/linux-pine64-default.config @@ -1395,9 +1395,9 @@ CONFIG_RTL8189FS=m # CONFIG_INPUT=y CONFIG_INPUT_FF_MEMLESS=m -# CONFIG_INPUT_POLLDEV is not set +CONFIG_INPUT_POLLDEV=m # CONFIG_INPUT_SPARSEKMAP is not set -# CONFIG_INPUT_MATRIXKMAP is not set +CONFIG_INPUT_MATRIXKMAP=m # # Userland interfaces @@ -1411,7 +1411,7 @@ CONFIG_INPUT_EVDEV=y # CONFIG_INPUT_EVBUG is not set # CONFIG_INPUT_KEYRESET is not set # CONFIG_INPUT_KEYCOMBO is not set -CONFIG_INPUT_SW_DEVICE=m +CONFIG_INPUT_SW_DEVICE=y # # Input Device Drivers @@ -1423,11 +1423,11 @@ CONFIG_KEYBOARD_ATKBD=y # CONFIG_KEYBOARD_QT1070 is not set # CONFIG_KEYBOARD_QT2160 is not set # CONFIG_KEYBOARD_LKKBD is not set -# CONFIG_KEYBOARD_GPIO is not set -# CONFIG_KEYBOARD_GPIO_POLLED is not set +CONFIG_KEYBOARD_GPIO=m +CONFIG_KEYBOARD_GPIO_POLLED=m # CONFIG_KEYBOARD_TCA6416 is not set # CONFIG_KEYBOARD_TCA8418 is not set -# CONFIG_KEYBOARD_MATRIX is not set +CONFIG_KEYBOARD_MATRIX=m CONFIG_KEYBOARD_LM8323=m # CONFIG_KEYBOARD_LM8333 is not set # CONFIG_KEYBOARD_MAX7359 is not set @@ -1469,7 +1469,78 @@ CONFIG_INPUT_JOYSTICK=y # CONFIG_JOYSTICK_XPAD is not set # CONFIG_JOYSTICK_WALKERA0701 is not set # CONFIG_INPUT_TABLET is not set -# CONFIG_INPUT_TOUCHSCREEN is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_ADS7846=m +CONFIG_TOUCHSCREEN_AD7877=m +CONFIG_TOUCHSCREEN_AD7879=m +CONFIG_TOUCHSCREEN_AD7879_I2C=m +CONFIG_TOUCHSCREEN_AD7879_SPI=m +CONFIG_TOUCHSCREEN_ATMEL_MXT=m +CONFIG_TOUCHSCREEN_AUO_PIXCIR=m +CONFIG_TOUCHSCREEN_BU21013=m +CONFIG_TOUCHSCREEN_CY8CTMG110=m +CONFIG_TOUCHSCREEN_CYTTSP_CORE=m +CONFIG_TOUCHSCREEN_CYTTSP_I2C=m +CONFIG_TOUCHSCREEN_CYTTSP_SPI=m +CONFIG_TOUCHSCREEN_DYNAPRO=m +CONFIG_TOUCHSCREEN_HAMPSHIRE=m +CONFIG_TOUCHSCREEN_EETI=m +CONFIG_TOUCHSCREEN_EGALAX=m +CONFIG_TOUCHSCREEN_FUJITSU=m +CONFIG_TOUCHSCREEN_ILI210X=m +CONFIG_TOUCHSCREEN_GUNZE=m +CONFIG_TOUCHSCREEN_ELO=m +CONFIG_TOUCHSCREEN_WACOM_W8001=m +CONFIG_TOUCHSCREEN_WACOM_I2C=m +CONFIG_TOUCHSCREEN_MAX11801=m +CONFIG_TOUCHSCREEN_MCS5000=m +CONFIG_TOUCHSCREEN_MMS114=m +CONFIG_TOUCHSCREEN_MTOUCH=m +CONFIG_TOUCHSCREEN_INEXIO=m +CONFIG_TOUCHSCREEN_MK712=m +CONFIG_TOUCHSCREEN_PENMOUNT=m +CONFIG_TOUCHSCREEN_EDT_FT5X06=m +CONFIG_TOUCHSCREEN_TOUCHRIGHT=m +CONFIG_TOUCHSCREEN_TOUCHWIN=m +CONFIG_TOUCHSCREEN_PIXCIR=m +CONFIG_TOUCHSCREEN_USB_COMPOSITE=m +CONFIG_TOUCHSCREEN_USB_EGALAX=y +CONFIG_TOUCHSCREEN_USB_PANJIT=y +CONFIG_TOUCHSCREEN_USB_3M=y +CONFIG_TOUCHSCREEN_USB_ITM=y +CONFIG_TOUCHSCREEN_USB_ETURBO=y +CONFIG_TOUCHSCREEN_USB_GUNZE=y +CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y +CONFIG_TOUCHSCREEN_USB_IRTOUCH=y +CONFIG_TOUCHSCREEN_USB_IDEALTEK=y +CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y +CONFIG_TOUCHSCREEN_USB_GOTOP=y +CONFIG_TOUCHSCREEN_USB_JASTEC=y +CONFIG_TOUCHSCREEN_USB_ELO=y +CONFIG_TOUCHSCREEN_USB_E2I=y +CONFIG_TOUCHSCREEN_USB_ZYTRONIC=y +CONFIG_TOUCHSCREEN_USB_ETT_TC45USB=y +CONFIG_TOUCHSCREEN_USB_NEXIO=y +CONFIG_TOUCHSCREEN_USB_EASYTOUCH=y +CONFIG_TOUCHSCREEN_TOUCHIT213=m +CONFIG_TOUCHSCREEN_TSC_SERIO=m +CONFIG_TOUCHSCREEN_TSC2005=m +CONFIG_TOUCHSCREEN_TSC2007=m +CONFIG_TOUCHSCREEN_W90X900=m +CONFIG_TOUCHSCREEN_ST1232=m +CONFIG_TOUCHSCREEN_TPS6507X=m +CONFIG_TOUCHSCREEN_GT82X=m +CONFIG_TOUCHSCREEN_SUN6I_TS=m +CONFIG_TOUCHSCREEN_FT5X_TS=m +CONFIG_TOUCHSCREEN_GT9XX_TS=m +CONFIG_TOUCHSCREEN_GT9XXF_TS=m +CONFIG_TOUCHSCREEN_GSLX680=m +CONFIG_TOUCHSCREEN_GSLX680NEW=m +CONFIG_TOUCHSCREEN_GT9XXNEW_TS=m +CONFIG_TOUCHSCREEN_AW5X06_TS=m +CONFIG_TOUCHSCREEN_GT818_TS=m +CONFIG_TOUCHSCREEN_TU_TS=m +CONFIG_TOUCHSCREEN_ICN83XX_TS=m CONFIG_INPUT_MISC=y # CONFIG_INPUT_AD714X is not set # CONFIG_INPUT_BMA150 is not set @@ -2338,29 +2409,29 @@ CONFIG_SND_SOC_I2C_AND_SPI=y # HID support # CONFIG_HID=y -# CONFIG_HID_BATTERY_STRENGTH is not set -# CONFIG_HIDRAW is not set -# CONFIG_UHID is not set +CONFIG_HID_BATTERY_STRENGTH=y +CONFIG_HIDRAW=y +CONFIG_UHID=m CONFIG_HID_GENERIC=y # # Special HID drivers # -CONFIG_HID_A4TECH=y +CONFIG_HID_A4TECH=m # CONFIG_HID_ACRUX is not set -CONFIG_HID_APPLE=y +CONFIG_HID_APPLE=m # CONFIG_HID_APPLEIR is not set # CONFIG_HID_AUREAL is not set -CONFIG_HID_BELKIN=y -CONFIG_HID_CHERRY=y -CONFIG_HID_CHICONY=y +CONFIG_HID_BELKIN=m +CONFIG_HID_CHERRY=m +CONFIG_HID_CHICONY=m # CONFIG_HID_PRODIKEYS is not set -CONFIG_HID_CYPRESS=y +CONFIG_HID_CYPRESS=m CONFIG_HID_DRAGONRISE=m CONFIG_DRAGONRISE_FF=y # CONFIG_HID_EMS_FF is not set # CONFIG_HID_ELECOM is not set -CONFIG_HID_EZKEY=y +CONFIG_HID_EZKEY=m # CONFIG_HID_HOLTEK is not set # CONFIG_HID_KEYTOUCH is not set # CONFIG_HID_KYE is not set @@ -2369,19 +2440,19 @@ CONFIG_HID_EZKEY=y # CONFIG_HID_GYRATION is not set # CONFIG_HID_ICADE is not set # CONFIG_HID_TWINHAN is not set -CONFIG_HID_KENSINGTON=y +CONFIG_HID_KENSINGTON=m # CONFIG_HID_LCPOWER is not set # CONFIG_HID_LENOVO_TPKBD is not set -CONFIG_HID_LOGITECH=y -# CONFIG_HID_LOGITECH_DJ is not set +CONFIG_HID_LOGITECH=m +CONFIG_HID_LOGITECH_DJ=m # CONFIG_LOGITECH_FF is not set # CONFIG_LOGIRUMBLEPAD2_FF is not set # CONFIG_LOGIG940_FF is not set # CONFIG_LOGIWHEELS_FF is not set # CONFIG_HID_MAGICMOUSE is not set -CONFIG_HID_MICROSOFT=y +CONFIG_HID_MICROSOFT=m CONFIG_HID_MONTEREY=y -# CONFIG_HID_MULTITOUCH is not set +CONFIG_HID_MULTITOUCH=m # CONFIG_HID_NTRIG is not set # CONFIG_HID_ORTEK is not set # CONFIG_HID_PANTHERLORD is not set diff --git a/config/kernel/linux-sunxi-dev.config b/config/kernel/linux-sunxi-dev.config index 5d56455c6f..f830c1b18d 100644 --- a/config/kernel/linux-sunxi-dev.config +++ b/config/kernel/linux-sunxi-dev.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.8.0 Kernel Configuration +# Linux/arm 4.9.0 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y @@ -71,6 +71,7 @@ CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_IRQ_DOMAIN_DEBUG=y CONFIG_IRQ_FORCED_THREADING=y CONFIG_SPARSE_IRQ=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_ARCH_HAS_TICK_BROADCAST=y @@ -254,6 +255,7 @@ CONFIG_CLONE_BACKWARDS=y CONFIG_OLD_SIGSUSPEND3=y CONFIG_OLD_SIGACTION=y # CONFIG_CPU_NO_EFFICIENT_FFS is not set +# CONFIG_HAVE_ARCH_VMAP_STACK is not set # # GCOV-based kernel profiling @@ -425,6 +427,7 @@ CONFIG_ARM_THUMB=y # CONFIG_ARM_THUMBEE is not set CONFIG_ARM_VIRT_EXT=y CONFIG_SWP_EMULATE=y +# CONFIG_CPU_BIG_ENDIAN is not set # CONFIG_CPU_ICACHE_DISABLE is not set # CONFIG_CPU_BPREDICT_DISABLE is not set CONFIG_KUSER_HELPERS=y @@ -433,6 +436,7 @@ CONFIG_OUTER_CACHE=y CONFIG_OUTER_CACHE_SYNC=y CONFIG_MIGHT_HAVE_CACHE_L2X0=y CONFIG_CACHE_L2X0=y +# CONFIG_CACHE_L2X0_PMU is not set # CONFIG_PL310_ERRATA_588369 is not set # CONFIG_PL310_ERRATA_727915 is not set # CONFIG_PL310_ERRATA_753970 is not set @@ -441,6 +445,7 @@ CONFIG_ARM_L1_CACHE_SHIFT_6=y CONFIG_ARM_L1_CACHE_SHIFT=6 CONFIG_ARM_DMA_MEM_BUFFERABLE=y CONFIG_ARM_HEAVY_MB=y +CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y CONFIG_DEBUG_RODATA=y CONFIG_DEBUG_ALIGN_RODATA=y CONFIG_MULTI_IRQ_HANDLER=y @@ -639,6 +644,9 @@ CONFIG_BINFMT_ELF=y CONFIG_ELFCORE=y CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y CONFIG_BINFMT_SCRIPT=y +CONFIG_BINFMT_FLAT=y +CONFIG_BINFMT_ZFLAT=y +CONFIG_BINFMT_SHARED_FLAT=y # CONFIG_HAVE_AOUT is not set CONFIG_BINFMT_MISC=m CONFIG_COREDUMP=y @@ -730,7 +738,7 @@ CONFIG_TCP_CONG_HTCP=y CONFIG_TCP_CONG_HSTCP=y CONFIG_TCP_CONG_HYBLA=y CONFIG_TCP_CONG_VEGAS=y -CONFIG_TCP_CONG_NV=m +CONFIG_TCP_CONG_NV=y CONFIG_TCP_CONG_SCALABLE=y CONFIG_TCP_CONG_LP=y CONFIG_TCP_CONG_VENO=y @@ -738,6 +746,7 @@ CONFIG_TCP_CONG_YEAH=y CONFIG_TCP_CONG_ILLINOIS=y # CONFIG_TCP_CONG_DCTCP is not set # CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set # CONFIG_DEFAULT_BIC is not set CONFIG_DEFAULT_CUBIC=y # CONFIG_DEFAULT_HTCP is not set @@ -837,9 +846,10 @@ CONFIG_NF_TABLES_INET=m CONFIG_NF_TABLES_NETDEV=m CONFIG_NFT_EXTHDR=m CONFIG_NFT_META=m +# CONFIG_NFT_NUMGEN is not set CONFIG_NFT_CT=m -CONFIG_NFT_RBTREE=m -CONFIG_NFT_HASH=m +CONFIG_NFT_SET_RBTREE=m +CONFIG_NFT_SET_HASH=m CONFIG_NFT_COUNTER=m CONFIG_NFT_LOG=m CONFIG_NFT_LIMIT=m @@ -847,9 +857,11 @@ CONFIG_NFT_MASQ=m CONFIG_NFT_REDIR=m CONFIG_NFT_NAT=m CONFIG_NFT_QUEUE=m +CONFIG_NFT_QUOTA=m CONFIG_NFT_REJECT=m CONFIG_NFT_REJECT_INET=m CONFIG_NFT_COMPAT=m +CONFIG_NFT_HASH=m # CONFIG_NF_DUP_NETDEV is not set # CONFIG_NFT_DUP_NETDEV is not set # CONFIG_NFT_FWD_NETDEV is not set @@ -1005,7 +1017,6 @@ CONFIG_IP_VS_PE_SIP=m # CONFIG_NF_DEFRAG_IPV4=m CONFIG_NF_CONNTRACK_IPV4=m -# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set CONFIG_NF_TABLES_IPV4=m CONFIG_NFT_CHAIN_ROUTE_IPV4=m CONFIG_NFT_REJECT_IPV4=m @@ -1256,12 +1267,20 @@ CONFIG_NET_ACT_CSUM=m CONFIG_NET_ACT_VLAN=m CONFIG_NET_ACT_BPF=m CONFIG_NET_ACT_CONNMARK=m +CONFIG_NET_ACT_SKBMOD=m # CONFIG_NET_ACT_IFE is not set +CONFIG_NET_ACT_TUNNEL_KEY=m CONFIG_NET_CLS_IND=y CONFIG_NET_SCH_FIFO=y CONFIG_DCB=y CONFIG_DNS_RESOLVER=y -# CONFIG_BATMAN_ADV is not set +CONFIG_BATMAN_ADV=m +CONFIG_BATMAN_ADV_BATMAN_V=y +CONFIG_BATMAN_ADV_BLA=y +CONFIG_BATMAN_ADV_DAT=y +CONFIG_BATMAN_ADV_NC=y +CONFIG_BATMAN_ADV_MCAST=y +# CONFIG_BATMAN_ADV_DEBUGFS is not set CONFIG_OPENVSWITCH=m CONFIG_OPENVSWITCH_GRE=m CONFIG_OPENVSWITCH_VXLAN=m @@ -1336,7 +1355,7 @@ CONFIG_CAN_CC770_PLATFORM=m # CONFIG_CAN_IFI_CANFD is not set CONFIG_CAN_M_CAN=m CONFIG_CAN_RCAR=m -# CONFIG_CAN_RCAR_CANFD is not set +CONFIG_CAN_RCAR_CANFD=m CONFIG_CAN_SJA1000=m CONFIG_CAN_SJA1000_ISA=m CONFIG_CAN_SJA1000_PLATFORM=m @@ -1432,6 +1451,7 @@ CONFIG_BT_HCIUART_LL=y # CONFIG_BT_HCIUART_BCM is not set # CONFIG_BT_HCIUART_QCA is not set # CONFIG_BT_HCIUART_AG6XX is not set +# CONFIG_BT_HCIUART_MRVL is not set CONFIG_BT_HCIBCM203X=m CONFIG_BT_HCIBPA10X=m CONFIG_BT_HCIBFUSB=m @@ -1440,9 +1460,12 @@ CONFIG_BT_MRVL=m CONFIG_BT_MRVL_SDIO=m CONFIG_BT_ATH3K=m CONFIG_AF_RXRPC=m +# CONFIG_AF_RXRPC_IPV6 is not set +# CONFIG_AF_RXRPC_INJECT_LOSS is not set # CONFIG_AF_RXRPC_DEBUG is not set # CONFIG_RXKAD is not set CONFIG_AF_KCM=m +CONFIG_STREAM_PARSER=m CONFIG_FIB_RULES=y CONFIG_WIRELESS=y CONFIG_WIRELESS_EXT=y @@ -1514,6 +1537,7 @@ CONFIG_ALLOW_DEV_COREDUMP=y CONFIG_DEV_COREDUMP=y # CONFIG_DEBUG_DRIVER is not set # CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set # CONFIG_SYS_HYPERVISOR is not set # CONFIG_GENERIC_CPU_DEVICES is not set CONFIG_REGMAP=y @@ -1551,9 +1575,9 @@ CONFIG_SUNXI_RSB=y CONFIG_MTD=y # CONFIG_MTD_TESTS is not set # CONFIG_MTD_REDBOOT_PARTS is not set -CONFIG_MTD_CMDLINE_PARTS=m +CONFIG_MTD_CMDLINE_PARTS=y # CONFIG_MTD_AFS_PARTS is not set -CONFIG_MTD_OF_PARTS=m +CONFIG_MTD_OF_PARTS=y # CONFIG_MTD_AR7_PARTS is not set # @@ -1617,15 +1641,15 @@ CONFIG_MTD_NAND=y # CONFIG_MTD_NAND_ECC_BCH is not set # CONFIG_MTD_SM_COMMON is not set # CONFIG_MTD_NAND_DENALI_DT is not set -CONFIG_MTD_NAND_GPIO=m +CONFIG_MTD_NAND_GPIO=y # CONFIG_MTD_NAND_OMAP_BCH_BUILD is not set CONFIG_MTD_NAND_IDS=y # CONFIG_MTD_NAND_DISKONCHIP is not set # CONFIG_MTD_NAND_DOCG4 is not set # CONFIG_MTD_NAND_NANDSIM is not set # CONFIG_MTD_NAND_BRCMNAND is not set -CONFIG_MTD_NAND_PLATFORM=m -CONFIG_MTD_NAND_SUNXI=m +CONFIG_MTD_NAND_PLATFORM=y +CONFIG_MTD_NAND_SUNXI=y # CONFIG_MTD_NAND_HISI504 is not set # CONFIG_MTD_NAND_MTK is not set # CONFIG_MTD_ONENAND is not set @@ -1636,7 +1660,7 @@ CONFIG_MTD_NAND_SUNXI=m # CONFIG_MTD_LPDDR is not set # CONFIG_MTD_LPDDR2_NVM is not set # CONFIG_MTD_SPI_NOR is not set -CONFIG_MTD_UBI=m +CONFIG_MTD_UBI=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_MTD_UBI_BEB_LIMIT=20 # CONFIG_MTD_UBI_FASTMAP is not set @@ -1652,7 +1676,6 @@ CONFIG_OF_ADDRESS=y CONFIG_OF_IRQ=y CONFIG_OF_NET=y CONFIG_OF_MDIO=y -CONFIG_OF_MTD=y CONFIG_OF_RESERVED_MEM=y CONFIG_OF_RESOLVE=y CONFIG_OF_OVERLAY=y @@ -1680,7 +1703,11 @@ CONFIG_BLK_DEV_RAM_SIZE=4096 # CONFIG_ATA_OVER_ETH is not set # CONFIG_MG_DISK is not set CONFIG_BLK_DEV_RBD=m -# CONFIG_NVME_TARGET is not set +CONFIG_NVME_CORE=m +# CONFIG_BLK_DEV_NVME_SCSI is not set +CONFIG_NVME_FABRICS=m +CONFIG_NVME_TARGET=m +CONFIG_NVME_TARGET_LOOP=m # # Misc devices @@ -1693,16 +1720,12 @@ CONFIG_BLK_DEV_RBD=m # CONFIG_APDS9802ALS is not set # CONFIG_ISL29003 is not set # CONFIG_ISL29020 is not set -CONFIG_SENSORS_TSL2550=m -# CONFIG_SENSORS_BH1780 is not set +# CONFIG_SENSORS_TSL2550 is not set # CONFIG_SENSORS_BH1770 is not set # CONFIG_SENSORS_APDS990X is not set # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set # CONFIG_TI_DAC7512 is not set -CONFIG_BMP085=m -CONFIG_BMP085_I2C=m -# CONFIG_BMP085_SPI is not set # CONFIG_USB_SWITCH_FSA9480 is not set # CONFIG_LATTICE_ECP3_CONFIG is not set # CONFIG_SRAM is not set @@ -1903,7 +1926,6 @@ CONFIG_IFB=m # CONFIG_NET_TEAM is not set CONFIG_MACVLAN=m CONFIG_MACVTAP=m -CONFIG_IPVLAN=m CONFIG_VXLAN=m # CONFIG_GENEVE is not set # CONFIG_GTP is not set @@ -1928,16 +1950,18 @@ CONFIG_ATM_DRIVERS=y # # CONFIG_NET_DSA_MV88E6060 is not set # CONFIG_NET_DSA_BCM_SF2 is not set -CONFIG_B53=y -CONFIG_B53_SPI_DRIVER=y -CONFIG_B53_MDIO_DRIVER=y -CONFIG_B53_MMAP_DRIVER=y -CONFIG_B53_SRAB_DRIVER=y +CONFIG_B53=m +CONFIG_B53_SPI_DRIVER=m +CONFIG_B53_MDIO_DRIVER=m +CONFIG_B53_MMAP_DRIVER=m +CONFIG_B53_SRAB_DRIVER=m # CONFIG_NET_DSA_MV88E6XXX is not set +# CONFIG_NET_DSA_QCA8K is not set CONFIG_ETHERNET=y CONFIG_NET_VENDOR_ALLWINNER=y CONFIG_SUN4I_EMAC=y # CONFIG_ALTERA_TSE is not set +CONFIG_NET_VENDOR_AMAZON=y # CONFIG_NET_VENDOR_ARC is not set # CONFIG_NET_VENDOR_AURORA is not set # CONFIG_NET_CADENCE is not set @@ -1968,6 +1992,7 @@ CONFIG_NET_VENDOR_NETRONOME=y # CONFIG_ETHOC is not set CONFIG_NET_VENDOR_QUALCOMM=y # CONFIG_QCA7000 is not set +# CONFIG_QCOM_EMAC is not set CONFIG_NET_VENDOR_RENESAS=y CONFIG_NET_VENDOR_ROCKER=y # CONFIG_NET_VENDOR_SAMSUNG is not set @@ -1977,6 +2002,7 @@ CONFIG_NET_VENDOR_STMICRO=y CONFIG_STMMAC_ETH=y CONFIG_STMMAC_PLATFORM=y CONFIG_DWMAC_GENERIC=y +# CONFIG_DWMAC_STM32 is not set CONFIG_DWMAC_SUNXI=y CONFIG_NET_VENDOR_SYNOPSYS=y CONFIG_SYNOPSYS_DWC_ETH_QOS=m @@ -1984,47 +2010,48 @@ CONFIG_SYNOPSYS_DWC_ETH_QOS=m # CONFIG_NET_VENDOR_WIZNET is not set CONFIG_PHYLIB=y CONFIG_SWPHY=y -CONFIG_SWCONFIG=y -CONFIG_SWCONFIG_LEDS=y + +# +# MDIO bus device drivers +# +# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_BUS_MUX_GPIO is not set +# CONFIG_MDIO_BUS_MUX_MMIOREG is not set +# CONFIG_MDIO_HISI_FEMAC is not set +CONFIG_MDIO_SUN4I=y # # MII PHY device drivers # +CONFIG_AMD_PHY=m CONFIG_AQUANTIA_PHY=m CONFIG_AT803X_PHY=m -CONFIG_AMD_PHY=m -CONFIG_MARVELL_PHY=m -CONFIG_DAVICOM_PHY=m -CONFIG_QSEMI_PHY=m -CONFIG_LXT_PHY=m -CONFIG_CICADA_PHY=m -CONFIG_VITESSE_PHY=m -CONFIG_TERANETICS_PHY=m -CONFIG_SMSC_PHY=m -CONFIG_BCM_NET_PHYLIB=m -CONFIG_BROADCOM_PHY=m # CONFIG_BCM7XXX_PHY is not set CONFIG_BCM87XX_PHY=m -CONFIG_ICPLUS_PHY=m -CONFIG_REALTEK_PHY=m -CONFIG_NATIONAL_PHY=m -CONFIG_STE10XP=m -CONFIG_LSI_ET1011C_PHY=m -CONFIG_MICREL_PHY=m +CONFIG_BCM_NET_PHYLIB=m +CONFIG_BROADCOM_PHY=m +CONFIG_CICADA_PHY=m +CONFIG_DAVICOM_PHY=m CONFIG_DP83848_PHY=m # CONFIG_DP83867_PHY is not set -CONFIG_MICROCHIP_PHY=m CONFIG_FIXED_PHY=y -# CONFIG_MDIO_BITBANG is not set -CONFIG_MDIO_SUN4I=y -# CONFIG_MDIO_BUS_MUX_GPIO is not set -# CONFIG_MDIO_BUS_MUX_MMIOREG is not set -# CONFIG_MDIO_BCM_UNIMAC is not set +CONFIG_ICPLUS_PHY=m # CONFIG_INTEL_XWAY_PHY is not set -# CONFIG_MDIO_HISI_FEMAC is not set -# CONFIG_MDIO_XGENE is not set -CONFIG_B53_PHY_DRIVER=y -CONFIG_B53_PHY_FIXUP=y +CONFIG_LSI_ET1011C_PHY=m +CONFIG_LXT_PHY=m +CONFIG_MARVELL_PHY=m +CONFIG_MICREL_PHY=m +CONFIG_MICROCHIP_PHY=m +# CONFIG_MICROSEMI_PHY is not set +CONFIG_NATIONAL_PHY=m +CONFIG_QSEMI_PHY=m +CONFIG_REALTEK_PHY=m +CONFIG_SMSC_PHY=m +CONFIG_STE10XP=m +CONFIG_TERANETICS_PHY=m +CONFIG_VITESSE_PHY=m +# CONFIG_XILINX_GMII2RGMII is not set # CONFIG_MICREL_KS8995MA is not set # CONFIG_PLIP is not set CONFIG_PPP=m @@ -2235,6 +2262,7 @@ CONFIG_INPUT_EVDEV=m # Input Device Drivers # CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ADC is not set # CONFIG_KEYBOARD_ADP5588 is not set # CONFIG_KEYBOARD_ADP5589 is not set CONFIG_KEYBOARD_ATKBD=y @@ -2260,19 +2288,19 @@ CONFIG_KEYBOARD_SUN4I_LRADC=m # CONFIG_KEYBOARD_OMAP4 is not set # CONFIG_KEYBOARD_XTKBD is not set # CONFIG_KEYBOARD_CAP11XX is not set -CONFIG_KEYBOARD_BCM=m +# CONFIG_KEYBOARD_BCM is not set CONFIG_INPUT_MOUSE=y -CONFIG_MOUSE_PS2=y -CONFIG_MOUSE_PS2_ALPS=y -CONFIG_MOUSE_PS2_BYD=y +CONFIG_MOUSE_PS2=m +# CONFIG_MOUSE_PS2_ALPS is not set +# CONFIG_MOUSE_PS2_BYD is not set CONFIG_MOUSE_PS2_LOGIPS2PP=y -CONFIG_MOUSE_PS2_SYNAPTICS=y -CONFIG_MOUSE_PS2_CYPRESS=y -CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_SYNAPTICS is not set +# CONFIG_MOUSE_PS2_CYPRESS is not set +# CONFIG_MOUSE_PS2_TRACKPOINT is not set # CONFIG_MOUSE_PS2_ELANTECH is not set # CONFIG_MOUSE_PS2_SENTELIC is not set # CONFIG_MOUSE_PS2_TOUCHKIT is not set -CONFIG_MOUSE_PS2_FOCALTECH=y +# CONFIG_MOUSE_PS2_FOCALTECH is not set CONFIG_MOUSE_SERIAL=m # CONFIG_MOUSE_APPLETOUCH is not set # CONFIG_MOUSE_BCM5974 is not set @@ -2302,11 +2330,11 @@ CONFIG_TOUCHSCREEN_CHIPONE_ICN8318=m # CONFIG_TOUCHSCREEN_EETI is not set # CONFIG_TOUCHSCREEN_EGALAX is not set # CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set -# CONFIG_TOUCHSCREEN_FT6236 is not set # CONFIG_TOUCHSCREEN_FUJITSU is not set CONFIG_TOUCHSCREEN_GOODIX=m # CONFIG_TOUCHSCREEN_ILI210X is not set # CONFIG_TOUCHSCREEN_GUNZE is not set +# CONFIG_TOUCHSCREEN_EKTF2127 is not set # CONFIG_TOUCHSCREEN_ELAN is not set # CONFIG_TOUCHSCREEN_ELO is not set # CONFIG_TOUCHSCREEN_WACOM_W8001 is not set @@ -2316,14 +2344,13 @@ CONFIG_TOUCHSCREEN_GOODIX=m # CONFIG_TOUCHSCREEN_MMS114 is not set # CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set # CONFIG_TOUCHSCREEN_MTOUCH is not set -CONFIG_TOUCHSCREEN_IMX6UL_TSC=m +# CONFIG_TOUCHSCREEN_IMX6UL_TSC is not set # CONFIG_TOUCHSCREEN_INEXIO is not set # CONFIG_TOUCHSCREEN_MK712 is not set # CONFIG_TOUCHSCREEN_PENMOUNT is not set # CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set # CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set # CONFIG_TOUCHSCREEN_TOUCHWIN is not set -# CONFIG_TOUCHSCREEN_UCB1400 is not set # CONFIG_TOUCHSCREEN_PIXCIR is not set # CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set # CONFIG_TOUCHSCREEN_WM97XX is not set @@ -2340,7 +2367,7 @@ CONFIG_TOUCHSCREEN_IMX6UL_TSC=m CONFIG_TOUCHSCREEN_SUN4I=m # CONFIG_TOUCHSCREEN_SUR40 is not set # CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set -CONFIG_TOUCHSCREEN_SX8654=m +# CONFIG_TOUCHSCREEN_SX8654 is not set # CONFIG_TOUCHSCREEN_TPS6507X is not set # CONFIG_TOUCHSCREEN_ZFORCE is not set # CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set @@ -2354,6 +2381,7 @@ CONFIG_INPUT_MISC=y # CONFIG_INPUT_GP2A is not set # CONFIG_INPUT_GPIO_BEEPER is not set # CONFIG_INPUT_GPIO_TILT_POLLED is not set +# CONFIG_INPUT_GPIO_DECODER is not set # CONFIG_INPUT_ATI_REMOTE2 is not set # CONFIG_INPUT_KEYSPAN_REMOTE is not set # CONFIG_INPUT_KXTJ9 is not set @@ -2366,7 +2394,6 @@ CONFIG_INPUT_AXP20X_PEK=y # CONFIG_INPUT_PCF8574 is not set # CONFIG_INPUT_PWM_BEEPER is not set # CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set -# CONFIG_INPUT_DA9063_ONKEY is not set # CONFIG_INPUT_ADXL34X is not set # CONFIG_INPUT_IMS_PCU is not set # CONFIG_INPUT_CMA3000 is not set @@ -2449,7 +2476,6 @@ CONFIG_SERIAL_CORE_CONSOLE=y CONFIG_SERIAL_CONEXANT_DIGICOLOR=m # CONFIG_SERIAL_ST_ASC is not set CONFIG_SERIAL_STM32=m -CONFIG_SERIAL_MCTRL_GPIO=y # CONFIG_TTY_PRINTK is not set # CONFIG_PRINTER is not set # CONFIG_PPDEV is not set @@ -2482,7 +2508,7 @@ CONFIG_I2C_MUX_PINCTRL=m CONFIG_I2C_MUX_REG=m CONFIG_I2C_DEMUX_PINCTRL=m CONFIG_I2C_HELPER_AUTO=y -CONFIG_I2C_ALGOBIT=m +CONFIG_I2C_ALGOBIT=y # # I2C Hardware Bus support @@ -2596,6 +2622,7 @@ CONFIG_PINCTRL_SUNXI=y CONFIG_PINCTRL_SUN4I_A10=y CONFIG_PINCTRL_SUN5I_A10S=y CONFIG_PINCTRL_SUN5I_A13=y +CONFIG_PINCTRL_GR8=y CONFIG_PINCTRL_SUN6I_A31=y CONFIG_PINCTRL_SUN6I_A31S=y CONFIG_PINCTRL_SUN6I_A31_R=y @@ -2621,10 +2648,12 @@ CONFIG_GPIO_SYSFS=y # # CONFIG_GPIO_74XX_MMIO is not set CONFIG_GPIO_ALTERA=m +CONFIG_GPIO_AXP209=y # CONFIG_GPIO_DWAPB is not set # CONFIG_GPIO_EM is not set # CONFIG_GPIO_GENERIC_PLATFORM is not set # CONFIG_GPIO_GRGPIO is not set +# CONFIG_GPIO_MOCKUP is not set # CONFIG_GPIO_MPC8XXX is not set CONFIG_GPIO_SYSCON=m # CONFIG_GPIO_XILINX is not set @@ -2642,11 +2671,12 @@ CONFIG_GPIO_SYSCON=m CONFIG_GPIO_PCF857X=m # CONFIG_GPIO_SX150X is not set # CONFIG_GPIO_TPIC2810 is not set +# CONFIG_GPIO_TS4900 is not set # # MFD GPIO expanders # -# CONFIG_GPIO_UCB1400 is not set +# CONFIG_HTC_EGPIO is not set # # SPI GPIO expanders @@ -2692,6 +2722,19 @@ CONFIG_W1_SLAVE_DS2433=m # CONFIG_W1_SLAVE_DS2781 is not set # CONFIG_W1_SLAVE_DS28E04 is not set # CONFIG_W1_SLAVE_BQ27000 is not set +CONFIG_POWER_AVS=y +CONFIG_POWER_RESET=y +# CONFIG_POWER_RESET_BRCMKONA is not set +# CONFIG_POWER_RESET_BRCMSTB is not set +# CONFIG_POWER_RESET_GPIO is not set +# CONFIG_POWER_RESET_GPIO_RESTART is not set +# CONFIG_POWER_RESET_LTC2952 is not set +# CONFIG_POWER_RESET_RESTART is not set +CONFIG_POWER_RESET_VERSATILE=y +CONFIG_POWER_RESET_SYSCON=y +CONFIG_POWER_RESET_SYSCON_POWEROFF=y +CONFIG_REBOOT_MODE=y +CONFIG_SYSCON_REBOOT_MODE=y CONFIG_POWER_SUPPLY=y # CONFIG_POWER_SUPPLY_DEBUG is not set # CONFIG_PDA_POWER is not set @@ -2702,7 +2745,6 @@ CONFIG_POWER_SUPPLY=y # CONFIG_BATTERY_DS2782 is not set # CONFIG_BATTERY_SBS is not set # CONFIG_BATTERY_BQ27XXX is not set -# CONFIG_BATTERY_DA9150 is not set CONFIG_AXP288_CHARGER=m CONFIG_AXP288_FUEL_GAUGE=m # CONFIG_BATTERY_MAX17040 is not set @@ -2718,22 +2760,9 @@ CONFIG_AXP288_FUEL_GAUGE=m # CONFIG_CHARGER_BQ24735 is not set # CONFIG_CHARGER_BQ25890 is not set # CONFIG_CHARGER_SMB347 is not set -CONFIG_BATTERY_GAUGE_LTC2941=m -CONFIG_BATTERY_RT5033=m +# CONFIG_BATTERY_GAUGE_LTC2941 is not set # CONFIG_CHARGER_RT9455 is not set CONFIG_AXP20X_POWER=y -CONFIG_POWER_RESET=y -# CONFIG_POWER_RESET_BRCMKONA is not set -# CONFIG_POWER_RESET_BRCMSTB is not set -# CONFIG_POWER_RESET_GPIO is not set -# CONFIG_POWER_RESET_GPIO_RESTART is not set -# CONFIG_POWER_RESET_LTC2952 is not set -# CONFIG_POWER_RESET_RESTART is not set -CONFIG_POWER_RESET_VERSATILE=y -# CONFIG_POWER_RESET_SYSCON is not set -CONFIG_POWER_RESET_SYSCON_POWEROFF=y -# CONFIG_SYSCON_REBOOT_MODE is not set -CONFIG_POWER_AVS=y CONFIG_HWMON=y CONFIG_HWMON_VID=m # CONFIG_HWMON_DEBUG_CHIP is not set @@ -2764,7 +2793,7 @@ CONFIG_SENSORS_DS1621=m CONFIG_SENSORS_F71805F=m CONFIG_SENSORS_F71882FG=m CONFIG_SENSORS_F75375S=m -# CONFIG_SENSORS_FTSTEUTATES is not set +CONFIG_SENSORS_FTSTEUTATES=m CONFIG_SENSORS_GL518SM=m CONFIG_SENSORS_GL520SM=m CONFIG_SENSORS_G760A=m @@ -2880,12 +2909,12 @@ CONFIG_CPU_THERMAL=y CONFIG_CLOCK_THERMAL=y # CONFIG_DEVFREQ_THERMAL is not set # CONFIG_THERMAL_EMULATION is not set -# CONFIG_IMX_THERMAL is not set +# CONFIG_QORIQ_THERMAL is not set # # ACPI INT340X thermal drivers # -# CONFIG_GENERIC_ADC_THERMAL is not set +CONFIG_GENERIC_ADC_THERMAL=m CONFIG_WATCHDOG=y CONFIG_WATCHDOG_CORE=y # CONFIG_WATCHDOG_NOWAYOUT is not set @@ -2895,7 +2924,6 @@ CONFIG_WATCHDOG_CORE=y # Watchdog Device Drivers # # CONFIG_SOFT_WATCHDOG is not set -CONFIG_DA9062_WATCHDOG=m CONFIG_GPIO_WATCHDOG=m # CONFIG_XILINX_WATCHDOG is not set # CONFIG_ZIIRAVE_WATCHDOG is not set @@ -2909,6 +2937,11 @@ CONFIG_SUNXI_WATCHDOG=y # USB-based Watchdog Cards # # CONFIG_USBPCWATCHDOG is not set + +# +# Watchdog Pretimeout Governors +# +# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set CONFIG_SSB_POSSIBLE=y # @@ -2945,6 +2978,7 @@ CONFIG_MFD_CORE=y # CONFIG_MFD_ATMEL_FLEXCOM is not set # CONFIG_MFD_ATMEL_HLCDC is not set # CONFIG_MFD_BCM590XX is not set +# CONFIG_MFD_AC100 is not set CONFIG_MFD_AXP20X=y CONFIG_MFD_AXP20X_I2C=y CONFIG_MFD_AXP20X_RSB=y @@ -2954,14 +2988,14 @@ CONFIG_MFD_AXP20X_RSB=y # CONFIG_MFD_DA9052_SPI is not set # CONFIG_MFD_DA9052_I2C is not set # CONFIG_MFD_DA9055 is not set -CONFIG_MFD_DA9062=m +# CONFIG_MFD_DA9062 is not set # CONFIG_MFD_DA9063 is not set -CONFIG_MFD_DA9150=m +# CONFIG_MFD_DA9150 is not set # CONFIG_MFD_DLN2 is not set +# CONFIG_MFD_EXYNOS_LPASS is not set # CONFIG_MFD_MC13XXX_SPI is not set # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_MFD_HI6421_PMIC is not set -# CONFIG_HTC_EGPIO is not set # CONFIG_HTC_PASIC3 is not set # CONFIG_HTC_I2CPLD is not set # CONFIG_INTEL_SOC_PMIC is not set @@ -2978,15 +3012,15 @@ CONFIG_MFD_DA9150=m # CONFIG_MFD_MAX8925 is not set # CONFIG_MFD_MAX8997 is not set # CONFIG_MFD_MAX8998 is not set -CONFIG_MFD_MT6397=m +# CONFIG_MFD_MT6397 is not set # CONFIG_MFD_MENF21BMC is not set # CONFIG_EZX_PCAP is not set # CONFIG_MFD_VIPERBOARD is not set # CONFIG_MFD_RETU is not set # CONFIG_MFD_PCF50633 is not set -CONFIG_UCB1400_CORE=m +# CONFIG_UCB1400_CORE is not set # CONFIG_MFD_PM8921_CORE is not set -CONFIG_MFD_RT5033=m +# CONFIG_MFD_RT5033 is not set # CONFIG_MFD_RTSX_USB is not set # CONFIG_MFD_RC5T583 is not set # CONFIG_MFD_RK808 is not set @@ -2994,7 +3028,7 @@ CONFIG_MFD_RT5033=m # CONFIG_MFD_SEC_CORE is not set # CONFIG_MFD_SI476X_CORE is not set # CONFIG_MFD_SM501 is not set -CONFIG_MFD_SKY81452=m +# CONFIG_MFD_SKY81452 is not set # CONFIG_MFD_SMSC is not set # CONFIG_ABX500_CORE is not set # CONFIG_MFD_STMPE is not set @@ -3010,6 +3044,7 @@ CONFIG_MFD_SYSCON=y # CONFIG_MFD_TPS65086 is not set # CONFIG_MFD_TPS65090 is not set # CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TI_LP873X is not set # CONFIG_MFD_TPS65218 is not set # CONFIG_MFD_TPS6586X is not set # CONFIG_MFD_TPS65910 is not set @@ -3039,9 +3074,8 @@ CONFIG_REGULATOR_VIRTUAL_CONSUMER=y # CONFIG_REGULATOR_USERSPACE_CONSUMER is not set # CONFIG_REGULATOR_ACT8865 is not set # CONFIG_REGULATOR_AD5398 is not set -CONFIG_REGULATOR_ANATOP=m +# CONFIG_REGULATOR_ANATOP is not set CONFIG_REGULATOR_AXP20X=y -CONFIG_REGULATOR_DA9062=m # CONFIG_REGULATOR_DA9210 is not set # CONFIG_REGULATOR_DA9211 is not set # CONFIG_REGULATOR_FAN53555 is not set @@ -3053,21 +3087,18 @@ CONFIG_REGULATOR_GPIO=y # CONFIG_REGULATOR_LP872X is not set # CONFIG_REGULATOR_LP8755 is not set # CONFIG_REGULATOR_LTC3589 is not set +# CONFIG_REGULATOR_LTC3676 is not set # CONFIG_REGULATOR_MAX1586 is not set # CONFIG_REGULATOR_MAX8649 is not set # CONFIG_REGULATOR_MAX8660 is not set # CONFIG_REGULATOR_MAX8952 is not set # CONFIG_REGULATOR_MAX8973 is not set -CONFIG_REGULATOR_MT6311=m -# CONFIG_REGULATOR_MT6323 is not set -CONFIG_REGULATOR_MT6397=m +# CONFIG_REGULATOR_MT6311 is not set # CONFIG_REGULATOR_PFUZE100 is not set # CONFIG_REGULATOR_PV88060 is not set # CONFIG_REGULATOR_PV88080 is not set # CONFIG_REGULATOR_PV88090 is not set CONFIG_REGULATOR_PWM=m -CONFIG_REGULATOR_RT5033=m -CONFIG_REGULATOR_SKY81452=m # CONFIG_REGULATOR_TPS51632 is not set # CONFIG_REGULATOR_TPS62360 is not set # CONFIG_REGULATOR_TPS65023 is not set @@ -3236,6 +3267,7 @@ CONFIG_VIDEO_TM6000_DVB=m # CONFIG_DVB_USB=m # CONFIG_DVB_USB_DEBUG is not set +CONFIG_DVB_USB_DIB3000MC=m CONFIG_DVB_USB_A800=m CONFIG_DVB_USB_DIBUSB_MB=m CONFIG_DVB_USB_DIBUSB_MB_FAULTY=y @@ -3351,14 +3383,14 @@ CONFIG_SMS_SIANO_DEBUGFS=y CONFIG_VIDEO_V4L2_TPG=m # -# Media ancillary drivers (tuners, sensors, i2c, frontends) +# Media ancillary drivers (tuners, sensors, i2c, spi, frontends) # # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set CONFIG_MEDIA_ATTACH=y CONFIG_VIDEO_IR_I2C=m # -# Encoders, decoders, sensors and other helper chips +# I2C Encoders, decoders, sensors and other helper chips # # @@ -3399,6 +3431,7 @@ CONFIG_VIDEO_BT856=m CONFIG_VIDEO_BT866=m CONFIG_VIDEO_KS0127=m CONFIG_VIDEO_ML86V7667=m +# CONFIG_VIDEO_AD5820 is not set CONFIG_VIDEO_SAA7110=m CONFIG_VIDEO_SAA711X=m CONFIG_VIDEO_TC358743=m @@ -3440,6 +3473,7 @@ CONFIG_VIDEO_THS8200=m # CONFIG_VIDEO_OV9650 is not set # CONFIG_VIDEO_VS6624 is not set # CONFIG_VIDEO_MT9M032 is not set +# CONFIG_VIDEO_MT9M111 is not set # CONFIG_VIDEO_MT9P031 is not set # CONFIG_VIDEO_MT9T001 is not set # CONFIG_VIDEO_MT9V011 is not set @@ -3482,6 +3516,11 @@ CONFIG_VIDEO_M52790=m # # Sensors used on soc_camera driver # + +# +# SPI helper chips +# +# CONFIG_VIDEO_GS1662 is not set CONFIG_MEDIA_TUNER=y # @@ -3684,11 +3723,59 @@ CONFIG_DVB_DUMMY_FE=m # Graphics support # # CONFIG_IMX_IPUV3_CORE is not set -# CONFIG_DRM is not set +CONFIG_DRM=y +# CONFIG_DRM_DP_AUX_CHARDEV is not set +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_FBDEV_EMULATION=y +# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set +CONFIG_DRM_GEM_CMA_HELPER=y +CONFIG_DRM_KMS_CMA_HELPER=y + +# +# I2C encoder or helper chips +# +# CONFIG_DRM_I2C_CH7006 is not set +# CONFIG_DRM_I2C_SIL164 is not set +# CONFIG_DRM_I2C_NXP_TDA998X is not set +# CONFIG_DRM_HDLCD is not set +# CONFIG_DRM_MALI_DISPLAY is not set # # ACP (Audio CoProcessor) Configuration # +# CONFIG_DRM_VGEM is not set +# CONFIG_DRM_EXYNOS is not set +# CONFIG_DRM_UDL is not set +# CONFIG_DRM_ARMADA is not set +CONFIG_DRM_SUN4I=m +# CONFIG_DRM_OMAP is not set +# CONFIG_DRM_TILCDC is not set +# CONFIG_DRM_FSL_DCU is not set +CONFIG_DRM_PANEL=y + +# +# Display Panels +# +# CONFIG_DRM_PANEL_SIMPLE is not set +# CONFIG_DRM_PANEL_SAMSUNG_LD9040 is not set +# CONFIG_DRM_PANEL_LG_LG4573 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0 is not set +CONFIG_DRM_BRIDGE=y + +# +# Display Interface Bridges +# +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +# CONFIG_DRM_DUMB_VGA_DAC is not set +# CONFIG_DRM_NXP_PTN3460 is not set +# CONFIG_DRM_PARADE_PS8622 is not set +# CONFIG_DRM_SII902X is not set +# CONFIG_DRM_TOSHIBA_TC358767 is not set +# CONFIG_DRM_I2C_ADV7511 is not set +# CONFIG_DRM_STI is not set +# CONFIG_DRM_ARCPGU is not set +# CONFIG_DRM_LEGACY is not set # # Frame buffer Devices @@ -3703,11 +3790,11 @@ CONFIG_FB_CFB_FILLRECT=y CONFIG_FB_CFB_COPYAREA=y CONFIG_FB_CFB_IMAGEBLIT=y # CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set -CONFIG_FB_SYS_FILLRECT=m -CONFIG_FB_SYS_COPYAREA=m -CONFIG_FB_SYS_IMAGEBLIT=m +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_IMAGEBLIT=y # CONFIG_FB_FOREIGN_ENDIAN is not set -CONFIG_FB_SYS_FOPS=m +CONFIG_FB_SYS_FOPS=y CONFIG_FB_DEFERRED_IO=y # CONFIG_FB_SVGALIB is not set # CONFIG_FB_MACMODES is not set @@ -3747,17 +3834,17 @@ CONFIG_LCD_CLASS_DEVICE=m CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_GENERIC=m # CONFIG_BACKLIGHT_PWM is not set -CONFIG_BACKLIGHT_PM8941_WLED=m +# CONFIG_BACKLIGHT_PM8941_WLED is not set # CONFIG_BACKLIGHT_ADP8860 is not set # CONFIG_BACKLIGHT_ADP8870 is not set # CONFIG_BACKLIGHT_LM3630A is not set # CONFIG_BACKLIGHT_LM3639 is not set # CONFIG_BACKLIGHT_LP855X is not set -CONFIG_BACKLIGHT_SKY81452=m # CONFIG_BACKLIGHT_GPIO is not set # CONFIG_BACKLIGHT_LV5207LP is not set # CONFIG_BACKLIGHT_BD6107 is not set # CONFIG_VGASTATE is not set +CONFIG_VIDEOMODE_HELPERS=y CONFIG_HDMI=y # @@ -3765,7 +3852,7 @@ CONFIG_HDMI=y # CONFIG_DUMMY_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE=y -# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y # CONFIG_LOGO is not set CONFIG_SOUND=m @@ -3810,8 +3897,8 @@ CONFIG_SND_DRIVERS=y # HD-Audio # CONFIG_SND_HDA_PREALLOC_SIZE=64 -CONFIG_SND_ARM=y -CONFIG_SND_SPI=y +# CONFIG_SND_ARM is not set +# CONFIG_SND_SPI is not set CONFIG_SND_USB=y CONFIG_SND_USB_AUDIO=m CONFIG_SND_USB_UA101=m @@ -3893,13 +3980,12 @@ CONFIG_SND_SOC_I2C_AND_SPI=m # CONFIG_SND_SOC_PCM3168A_SPI is not set # CONFIG_SND_SOC_PCM512x_I2C is not set # CONFIG_SND_SOC_PCM512x_SPI is not set -CONFIG_SND_SOC_RL6231=m -CONFIG_SND_SOC_RT5616=m +# CONFIG_SND_SOC_RT5616 is not set # CONFIG_SND_SOC_RT5631 is not set # CONFIG_SND_SOC_RT5677_SPI is not set # CONFIG_SND_SOC_SGTL5000 is not set # CONFIG_SND_SOC_SIRF_AUDIO_CODEC is not set -# CONFIG_SND_SOC_SPDIF is not set +CONFIG_SND_SOC_SPDIF=m # CONFIG_SND_SOC_SSM2602_SPI is not set # CONFIG_SND_SOC_SSM2602_I2C is not set # CONFIG_SND_SOC_SSM4567 is not set @@ -3936,8 +4022,11 @@ CONFIG_SND_SOC_RT5616=m # CONFIG_SND_SOC_WM8974 is not set # CONFIG_SND_SOC_WM8978 is not set # CONFIG_SND_SOC_WM8985 is not set +# CONFIG_SND_SOC_NAU8810 is not set # CONFIG_SND_SOC_TPA6130A2 is not set -# CONFIG_SND_SIMPLE_CARD is not set +CONFIG_SND_SIMPLE_CARD_UTILS=m +CONFIG_SND_SIMPLE_CARD=m +# CONFIG_SND_SIMPLE_SCU_CARD is not set # CONFIG_SOUND_PRIME is not set CONFIG_AC97_BUS=m @@ -4042,7 +4131,7 @@ CONFIG_ZEROPLUS_FF=y CONFIG_HID_ZYDACRON=m CONFIG_HID_SENSOR_HUB=m CONFIG_HID_SENSOR_CUSTOM_SENSOR=m -# CONFIG_HID_ALPS is not set +CONFIG_HID_ALPS=m # # USB HID support @@ -4071,7 +4160,7 @@ CONFIG_USB_OTG=y # CONFIG_USB_OTG_WHITELIST is not set # CONFIG_USB_OTG_BLACKLIST_HUB is not set # CONFIG_USB_OTG_FSM is not set -CONFIG_USB_ULPI_BUS=m +CONFIG_USB_LEDS_TRIGGER_USBPORT=y CONFIG_USB_MON=m # CONFIG_USB_WUSB_CBAF is not set @@ -4092,7 +4181,6 @@ CONFIG_USB_EHCI_HCD_PLATFORM=y # CONFIG_USB_MAX3421_HCD is not set CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_HCD_PLATFORM=y -# CONFIG_USB_U132_HCD is not set # CONFIG_USB_SL811_HCD is not set # CONFIG_USB_R8A66597_HCD is not set # CONFIG_USB_HCD_BCMA is not set @@ -4138,6 +4226,8 @@ CONFIG_USB_UAS=m # CONFIG_USB_MICROTEK is not set CONFIG_USBIP_CORE=m CONFIG_USBIP_VHCI_HCD=m +CONFIG_USBIP_VHCI_HC_PORTS=8 +CONFIG_USBIP_VHCI_NR_HCS=1 CONFIG_USBIP_HOST=m CONFIG_USBIP_VUDC=m # CONFIG_USBIP_DEBUG is not set @@ -4158,12 +4248,7 @@ CONFIG_USB_MUSB_SUNXI=y # CONFIG_USB_DWC3 is not set # CONFIG_USB_DWC2 is not set # CONFIG_USB_CHIPIDEA is not set -CONFIG_USB_ISP1760=m -CONFIG_USB_ISP1760_HCD=y -CONFIG_USB_ISP1761_UDC=y -# CONFIG_USB_ISP1760_HOST_ROLE is not set -# CONFIG_USB_ISP1760_GADGET_ROLE is not set -CONFIG_USB_ISP1760_DUAL_ROLE=y +# CONFIG_USB_ISP1760 is not set # # USB port drivers @@ -4249,7 +4334,7 @@ CONFIG_USB_SERIAL_DEBUG=m # CONFIG_USB_CYPRESS_CY7C63 is not set # CONFIG_USB_CYTHERM is not set # CONFIG_USB_IDMOUSE is not set -CONFIG_USB_FTDI_ELAN=m +# CONFIG_USB_FTDI_ELAN is not set # CONFIG_USB_APPLEDISPLAY is not set # CONFIG_USB_SISUSBVGA is not set # CONFIG_USB_LD is not set @@ -4261,6 +4346,7 @@ CONFIG_USB_FTDI_ELAN=m # CONFIG_USB_YUREX is not set CONFIG_USB_EZUSB_FX2=m # CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set # CONFIG_USB_LINK_LAYER_TEST is not set CONFIG_USB_CHAOSKEY=m # CONFIG_USB_ATM is not set @@ -4303,6 +4389,7 @@ CONFIG_USB_U_SERIAL=m CONFIG_USB_U_ETHER=m CONFIG_USB_F_SERIAL=m CONFIG_USB_F_OBEX=m +CONFIG_USB_F_NCM=m CONFIG_USB_F_ECM=m CONFIG_USB_F_EEM=m CONFIG_USB_F_SUBSET=m @@ -4319,7 +4406,7 @@ CONFIG_GADGET_UAC1=y CONFIG_USB_ETH=m CONFIG_USB_ETH_RNDIS=y CONFIG_USB_ETH_EEM=y -# CONFIG_USB_G_NCM is not set +CONFIG_USB_G_NCM=m CONFIG_USB_GADGETFS=m # CONFIG_USB_FUNCTIONFS is not set CONFIG_USB_MASS_STORAGE=m @@ -4336,6 +4423,7 @@ CONFIG_USB_G_HID=m # CONFIG_USB_G_DBGP is not set CONFIG_USB_G_WEBCAM=m # CONFIG_USB_LED_TRIG is not set +CONFIG_USB_ULPI_BUS=m # CONFIG_UWB is not set CONFIG_MMC=y # CONFIG_MMC_DEBUG is not set @@ -4361,7 +4449,7 @@ CONFIG_MMC_SDHCI=m CONFIG_MMC_USHC=m # CONFIG_MMC_USDHI6ROL0 is not set CONFIG_MMC_SUNXI=y -CONFIG_MMC_MTK=m +# CONFIG_MMC_MTK is not set # CONFIG_MEMSTICK is not set CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y @@ -4394,6 +4482,7 @@ CONFIG_LEDS_REGULATOR=m # CONFIG_LEDS_TLC591XX is not set # CONFIG_LEDS_LM355x is not set # CONFIG_LEDS_KTD2692 is not set +# CONFIG_LEDS_IS31FL319X is not set # CONFIG_LEDS_IS31FL32XX is not set # @@ -4436,7 +4525,7 @@ CONFIG_RTC_SYSTOHC_DEVICE="rtc0" # # RTC interfaces # -# CONFIG_RTC_INTF_SYSFS is not set +CONFIG_RTC_INTF_SYSFS=y # CONFIG_RTC_INTF_PROC is not set CONFIG_RTC_INTF_DEV=y # CONFIG_RTC_INTF_DEV_UIE_EMUL is not set @@ -4445,10 +4534,11 @@ CONFIG_RTC_INTF_DEV=y # # I2C RTC drivers # -CONFIG_RTC_DRV_ABB5ZES3=m -CONFIG_RTC_DRV_ABX80X=m +# CONFIG_RTC_DRV_ABB5ZES3 is not set +# CONFIG_RTC_DRV_ABX80X is not set CONFIG_RTC_DRV_DS1307=m CONFIG_RTC_DRV_DS1307_HWMON=y +# CONFIG_RTC_DRV_DS1307_CENTURY is not set # CONFIG_RTC_DRV_DS1374 is not set # CONFIG_RTC_DRV_DS1672 is not set # CONFIG_RTC_DRV_HYM8563 is not set @@ -4456,7 +4546,6 @@ CONFIG_RTC_DRV_DS1307_HWMON=y # CONFIG_RTC_DRV_RS5C372 is not set # CONFIG_RTC_DRV_ISL1208 is not set # CONFIG_RTC_DRV_ISL12022 is not set -# CONFIG_RTC_DRV_ISL12057 is not set # CONFIG_RTC_DRV_X1205 is not set # CONFIG_RTC_DRV_PCF8523 is not set # CONFIG_RTC_DRV_PCF85063 is not set @@ -4506,17 +4595,9 @@ CONFIG_RTC_I2C_AND_SPI=y # CONFIG_RTC_DRV_DS1286 is not set # CONFIG_RTC_DRV_DS1511 is not set # CONFIG_RTC_DRV_DS1553 is not set -CONFIG_RTC_DRV_DS1685_FAMILY=m -CONFIG_RTC_DRV_DS1685=y -# CONFIG_RTC_DRV_DS1689 is not set -# CONFIG_RTC_DRV_DS17285 is not set -# CONFIG_RTC_DRV_DS17485 is not set -# CONFIG_RTC_DRV_DS17885 is not set -# CONFIG_RTC_DS1685_PROC_REGS is not set -# CONFIG_RTC_DS1685_SYSFS_REGS is not set +# CONFIG_RTC_DRV_DS1685_FAMILY is not set # CONFIG_RTC_DRV_DS1742 is not set # CONFIG_RTC_DRV_DS2404 is not set -CONFIG_RTC_DRV_DA9063=m # CONFIG_RTC_DRV_STK17TA8 is not set # CONFIG_RTC_DRV_M48T86 is not set # CONFIG_RTC_DRV_M48T35 is not set @@ -4525,7 +4606,7 @@ CONFIG_RTC_DRV_DA9063=m # CONFIG_RTC_DRV_BQ4802 is not set # CONFIG_RTC_DRV_RP5C01 is not set # CONFIG_RTC_DRV_V3020 is not set -CONFIG_RTC_DRV_ZYNQMP=m +# CONFIG_RTC_DRV_ZYNQMP is not set # # on-CPU RTC drivers @@ -4533,7 +4614,6 @@ CONFIG_RTC_DRV_ZYNQMP=m CONFIG_RTC_DRV_SUN6I=y CONFIG_RTC_DRV_SUNXI=y # CONFIG_RTC_DRV_SNVS is not set -# CONFIG_RTC_DRV_MT6397 is not set # # HID Sensor RTC drivers @@ -4590,7 +4670,6 @@ CONFIG_STAGING=y CONFIG_R8712U=m CONFIG_R8188EU=m CONFIG_88EU_AP_MODE=y -# CONFIG_R8723AU is not set # CONFIG_VT6656 is not set # @@ -4686,6 +4765,7 @@ CONFIG_USB_PULSE8_CEC=m # # CONFIG_STAGING_BOARD is not set # CONFIG_LTE_GDM724X is not set +# CONFIG_MTD_SPINAND_MT29F is not set # CONFIG_LNET is not set # CONFIG_GS_FPGABOOT is not set # CONFIG_COMMON_CLK_XLNX_CLKWZRD is not set @@ -4735,6 +4815,7 @@ CONFIG_HDM_DIM2=m CONFIG_HDM_I2C=m CONFIG_HDM_USB=m # CONFIG_KS7010 is not set +# CONFIG_GREYBUS is not set # CONFIG_GOLDFISH is not set # CONFIG_CHROME_PLATFORMS is not set CONFIG_CLKDEV_LOOKUP=y @@ -4760,12 +4841,16 @@ CONFIG_SUNXI_CCU_DIV=y CONFIG_SUNXI_CCU_FRAC=y CONFIG_SUNXI_CCU_GATE=y CONFIG_SUNXI_CCU_MUX=y +CONFIG_SUNXI_CCU_MULT=y CONFIG_SUNXI_CCU_PHASE=y CONFIG_SUNXI_CCU_NK=y CONFIG_SUNXI_CCU_NKM=y CONFIG_SUNXI_CCU_NKMP=y CONFIG_SUNXI_CCU_NM=y CONFIG_SUNXI_CCU_MP=y +CONFIG_SUN6I_A31_CCU=y +CONFIG_SUN8I_A23_CCU=y +CONFIG_SUN8I_A33_CCU=y CONFIG_SUN8I_H3_CCU=y # @@ -4846,8 +4931,9 @@ CONFIG_EXTCON=y CONFIG_EXTCON_AXP288=y CONFIG_EXTCON_GPIO=m # CONFIG_EXTCON_MAX3355 is not set -CONFIG_EXTCON_RT8973A=m -CONFIG_EXTCON_SM5502=m +# CONFIG_EXTCON_QCOM_SPMI_MISC is not set +# CONFIG_EXTCON_RT8973A is not set +# CONFIG_EXTCON_SM5502 is not set CONFIG_EXTCON_USB_GPIO=m # CONFIG_MEMORY is not set CONFIG_IIO=m @@ -4863,10 +4949,13 @@ CONFIG_IIO=m # CONFIG_BMA180 is not set # CONFIG_BMA220 is not set # CONFIG_BMC150_ACCEL is not set +# CONFIG_DMARD06 is not set +# CONFIG_DMARD09 is not set # CONFIG_HID_SENSOR_ACCEL_3D is not set # CONFIG_IIO_ST_ACCEL_3AXIS is not set # CONFIG_KXSD9 is not set # CONFIG_KXCJK1013 is not set +# CONFIG_MC3230 is not set # CONFIG_MMA7455_I2C is not set # CONFIG_MMA7455_SPI is not set # CONFIG_MMA7660 is not set @@ -4876,6 +4965,7 @@ CONFIG_IIO=m # CONFIG_MXC4005 is not set # CONFIG_MXC6255 is not set # CONFIG_STK8312 is not set +# CONFIG_STK8BA50 is not set # # Analog to digital converters @@ -4891,9 +4981,9 @@ CONFIG_IIO=m # CONFIG_AD799X is not set CONFIG_AXP288_ADC=m # CONFIG_CC10001_ADC is not set -# CONFIG_DA9150_GPADC is not set # CONFIG_HI8435 is not set # CONFIG_INA2XX_ADC is not set +# CONFIG_LTC2485 is not set # CONFIG_MAX1027 is not set # CONFIG_MAX1363 is not set # CONFIG_MCP320X is not set @@ -4901,7 +4991,9 @@ CONFIG_AXP288_ADC=m # CONFIG_NAU7802 is not set # CONFIG_TI_ADC081C is not set # CONFIG_TI_ADC0832 is not set +# CONFIG_TI_ADC12138 is not set # CONFIG_TI_ADC128S052 is not set +# CONFIG_TI_ADC161S626 is not set # CONFIG_TI_ADS1015 is not set # CONFIG_TI_ADS8688 is not set # CONFIG_VF610_ADC is not set @@ -4947,6 +5039,7 @@ CONFIG_AXP288_ADC=m # CONFIG_AD5764 is not set # CONFIG_AD5791 is not set # CONFIG_AD7303 is not set +# CONFIG_AD8801 is not set # CONFIG_M62332 is not set # CONFIG_MAX517 is not set # CONFIG_MAX5821 is not set @@ -5040,6 +5133,7 @@ CONFIG_AXP288_ADC=m # CONFIG_MAX44000 is not set # CONFIG_OPT3001 is not set # CONFIG_PA12203001 is not set +# CONFIG_SI1145 is not set # CONFIG_STK3310 is not set # CONFIG_TCS3414 is not set # CONFIG_TCS3472 is not set @@ -5052,6 +5146,7 @@ CONFIG_AXP288_ADC=m # # Magnetometer sensors # +# CONFIG_AK8974 is not set # CONFIG_AK8975 is not set # CONFIG_AK09911 is not set # CONFIG_BMC150_MAGN_I2C is not set @@ -5081,6 +5176,7 @@ CONFIG_AXP288_ADC=m # # Pressure sensors # +# CONFIG_BMP280 is not set # CONFIG_HID_SENSOR_PRESS is not set # CONFIG_HP03 is not set # CONFIG_MPL115_I2C is not set @@ -5091,6 +5187,7 @@ CONFIG_AXP288_ADC=m # CONFIG_IIO_ST_PRESS is not set # CONFIG_T5403 is not set # CONFIG_HP206C is not set +# CONFIG_ZPA2326 is not set # # Lightning sensors @@ -5106,6 +5203,7 @@ CONFIG_AXP288_ADC=m # # Temperature sensors # +# CONFIG_MAXIM_THERMOCOUPLE is not set # CONFIG_MLX90614 is not set # CONFIG_TMP006 is not set # CONFIG_TSYS01 is not set @@ -5121,7 +5219,16 @@ CONFIG_ARM_GIC_MAX_NR=1 # CONFIG_IPACK_BUS is not set CONFIG_ARCH_HAS_RESET_CONTROLLER=y CONFIG_RESET_CONTROLLER=y +# CONFIG_RESET_ATH79 is not set +# CONFIG_RESET_BERLIN is not set +# CONFIG_RESET_LPC18XX is not set +# CONFIG_RESET_MESON is not set +# CONFIG_RESET_PISTACHIO is not set +# CONFIG_RESET_SOCFPGA is not set +# CONFIG_RESET_STM32 is not set +CONFIG_RESET_SUNXI=y # CONFIG_TI_SYSCON_RESET is not set +# CONFIG_RESET_ZYNQ is not set # CONFIG_FMC is not set # @@ -5311,11 +5418,11 @@ CONFIG_JFFS2_ZLIB=y # CONFIG_JFFS2_LZO is not set CONFIG_JFFS2_RTIME=y # CONFIG_JFFS2_RUBIN is not set -CONFIG_UBIFS_FS=m +CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS_ADVANCED_COMPR=y CONFIG_UBIFS_FS_LZO=y CONFIG_UBIFS_FS_ZLIB=y -CONFIG_UBIFS_ATIME_SUPPORT=y +# CONFIG_UBIFS_ATIME_SUPPORT is not set # CONFIG_LOGFS is not set # CONFIG_CRAMFS is not set CONFIG_SQUASHFS=m @@ -5575,6 +5682,7 @@ CONFIG_FUNCTION_TRACER=y CONFIG_FUNCTION_GRAPH_TRACER=y # CONFIG_IRQSOFF_TRACER is not set # CONFIG_SCHED_TRACER is not set +# CONFIG_HWLAT_TRACER is not set # CONFIG_FTRACE_SYSCALLS is not set # CONFIG_TRACER_SNAPSHOT is not set CONFIG_BRANCH_PROFILE_NONE=y @@ -5624,6 +5732,7 @@ CONFIG_TEST_HEXDUMP=m # CONFIG_SAMPLES is not set CONFIG_HAVE_ARCH_KGDB=y # CONFIG_KGDB is not set +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set # CONFIG_UBSAN is not set CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y # CONFIG_STRICT_DEVMEM is not set @@ -5662,7 +5771,7 @@ CONFIG_KEYS=y # CONFIG_PERSISTENT_KEYRINGS is not set # CONFIG_BIG_KEYS is not set CONFIG_ENCRYPTED_KEYS=y -CONFIG_KEY_DH_OPERATIONS=y +# CONFIG_KEY_DH_OPERATIONS is not set # CONFIG_SECURITY_DMESG_RESTRICT is not set # CONFIG_SECURITY is not set # CONFIG_SECURITYFS is not set @@ -5907,12 +6016,11 @@ CONFIG_DQL=y CONFIG_GLOB=y # CONFIG_GLOB_SELFTEST is not set CONFIG_NLATTR=y -CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y CONFIG_CLZ_TAB=y # CONFIG_CORDIC is not set # CONFIG_DDR is not set # CONFIG_IRQ_POLL is not set -CONFIG_MPILIB=y +CONFIG_MPILIB=m CONFIG_LIBFDT=y CONFIG_OID_REGISTRY=y CONFIG_FONT_SUPPORT=y @@ -5922,6 +6030,7 @@ CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_SBITMAP=y CONFIG_VIRTUALIZATION=y # CONFIG_VHOST_NET is not set # CONFIG_VHOST_SCSI is not set diff --git a/config/kernel/linux-sunxi-next.config b/config/kernel/linux-sunxi-next.config index 2732d82b30..31d31d2aa6 100644 --- a/config/kernel/linux-sunxi-next.config +++ b/config/kernel/linux-sunxi-next.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.8.1 Kernel Configuration +# Linux/arm 4.8.6 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y @@ -54,8 +54,11 @@ CONFIG_POSIX_MQUEUE_SYSCTL=y CONFIG_CROSS_MEMORY_ATTACH=y CONFIG_FHANDLE=y CONFIG_USELIB=y -# CONFIG_AUDIT is not set +CONFIG_AUDIT=y CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_AUDITSYSCALL=y +CONFIG_AUDIT_WATCH=y +CONFIG_AUDIT_TREE=y # # IRQ subsystem @@ -208,7 +211,8 @@ CONFIG_SLUB_CPU_PARTIAL=y CONFIG_TRACEPOINTS=y CONFIG_HAVE_OPROFILE=y # CONFIG_KPROBES is not set -# CONFIG_JUMP_LABEL is not set +CONFIG_JUMP_LABEL=y +# CONFIG_STATIC_KEYS_SELFTEST is not set # CONFIG_UPROBES is not set # CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y @@ -560,10 +564,7 @@ CONFIG_ATAGS=y # CONFIG_DEPRECATED_PARAM_STRUCT is not set CONFIG_ZBOOT_ROM_TEXT=0 CONFIG_ZBOOT_ROM_BSS=0 -CONFIG_ARM_APPENDED_DTB=y -CONFIG_ARM_ATAG_DTB_COMPAT=y -CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y -# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set +# CONFIG_ARM_APPENDED_DTB is not set CONFIG_CMDLINE="" # CONFIG_KEXEC is not set # CONFIG_CRASH_DUMP is not set @@ -603,7 +604,7 @@ CONFIG_CPUFREQ_DT_PLATDEV=y CONFIG_ARM_BIG_LITTLE_CPUFREQ=m CONFIG_ARM_DT_BL_CPUFREQ=m # CONFIG_ARM_KIRKWOOD_CPUFREQ is not set -CONFIG_QORIQ_CPUFREQ=m +# CONFIG_QORIQ_CPUFREQ is not set # # CPU Idle @@ -763,12 +764,12 @@ CONFIG_INET6_XFRM_MODE_TRANSPORT=m CONFIG_INET6_XFRM_MODE_TUNNEL=m CONFIG_INET6_XFRM_MODE_BEET=m CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m -# CONFIG_IPV6_VTI is not set +CONFIG_IPV6_VTI=m CONFIG_IPV6_SIT=m CONFIG_IPV6_SIT_6RD=y CONFIG_IPV6_NDISC_NODETYPE=y CONFIG_IPV6_TUNNEL=m -# CONFIG_IPV6_GRE is not set +CONFIG_IPV6_GRE=m # CONFIG_IPV6_FOU is not set # CONFIG_IPV6_FOU_TUNNEL is not set CONFIG_IPV6_MULTIPLE_TABLES=y @@ -865,6 +866,7 @@ CONFIG_NETFILTER_XT_SET=m # # Xtables targets # +# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m CONFIG_NETFILTER_XT_TARGET_CONNMARK=m @@ -1134,12 +1136,7 @@ CONFIG_RDS_TCP=m # CONFIG_RDS_DEBUG is not set CONFIG_TIPC=m CONFIG_TIPC_MEDIA_UDP=y -CONFIG_ATM=m -CONFIG_ATM_CLIP=m -CONFIG_ATM_CLIP_NO_ICMP=y -# CONFIG_ATM_LANE is not set -CONFIG_ATM_BR2684=m -CONFIG_ATM_BR2684_IPFILTER=y +# CONFIG_ATM is not set CONFIG_L2TP=m # CONFIG_L2TP_DEBUGFS is not set CONFIG_L2TP_V3=y @@ -1193,7 +1190,6 @@ CONFIG_NET_SCHED=y CONFIG_NET_SCH_CBQ=y CONFIG_NET_SCH_HTB=y CONFIG_NET_SCH_HFSC=m -# CONFIG_NET_SCH_ATM is not set CONFIG_NET_SCH_PRIO=m CONFIG_NET_SCH_MULTIQ=m CONFIG_NET_SCH_RED=m @@ -1204,17 +1200,17 @@ CONFIG_NET_SCH_TBF=m CONFIG_NET_SCH_GRED=m CONFIG_NET_SCH_DSMARK=m CONFIG_NET_SCH_NETEM=m -# CONFIG_NET_SCH_DRR is not set +CONFIG_NET_SCH_DRR=m CONFIG_NET_SCH_MQPRIO=m -# CONFIG_NET_SCH_CHOKE is not set +CONFIG_NET_SCH_CHOKE=m CONFIG_NET_SCH_QFQ=m CONFIG_NET_SCH_CODEL=m CONFIG_NET_SCH_FQ_CODEL=m -# CONFIG_NET_SCH_FQ is not set -# CONFIG_NET_SCH_HHF is not set -# CONFIG_NET_SCH_PIE is not set +CONFIG_NET_SCH_FQ=m +CONFIG_NET_SCH_HHF=m +CONFIG_NET_SCH_PIE=m CONFIG_NET_SCH_INGRESS=m -# CONFIG_NET_SCH_PLUG is not set +CONFIG_NET_SCH_PLUG=m # # Classification @@ -1227,13 +1223,13 @@ CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m CONFIG_CLS_U32_PERF=y CONFIG_CLS_U32_MARK=y -# CONFIG_NET_CLS_RSVP is not set -# CONFIG_NET_CLS_RSVP6 is not set +CONFIG_NET_CLS_RSVP=m +CONFIG_NET_CLS_RSVP6=m CONFIG_NET_CLS_FLOW=m -# CONFIG_NET_CLS_CGROUP is not set -# CONFIG_NET_CLS_BPF is not set -# CONFIG_NET_CLS_FLOWER is not set -# CONFIG_NET_CLS_MATCHALL is not set +CONFIG_NET_CLS_CGROUP=m +CONFIG_NET_CLS_BPF=m +CONFIG_NET_CLS_FLOWER=m +CONFIG_NET_CLS_MATCHALL=m CONFIG_NET_EMATCH=y CONFIG_NET_EMATCH_STACK=32 CONFIG_NET_EMATCH_CMP=m @@ -1242,13 +1238,14 @@ CONFIG_NET_EMATCH_U32=m CONFIG_NET_EMATCH_META=m CONFIG_NET_EMATCH_TEXT=m CONFIG_NET_EMATCH_CANID=m -# CONFIG_NET_EMATCH_IPSET is not set +CONFIG_NET_EMATCH_IPSET=m CONFIG_NET_CLS_ACT=y CONFIG_NET_ACT_POLICE=m -# CONFIG_NET_ACT_GACT is not set +CONFIG_NET_ACT_GACT=m +# CONFIG_GACT_PROB is not set CONFIG_NET_ACT_MIRRED=m CONFIG_NET_ACT_IPT=m -# CONFIG_NET_ACT_NAT is not set +CONFIG_NET_ACT_NAT=m # CONFIG_NET_ACT_PEDIT is not set # CONFIG_NET_ACT_SIMP is not set CONFIG_NET_ACT_SKBEDIT=m @@ -1256,7 +1253,9 @@ CONFIG_NET_ACT_CSUM=m CONFIG_NET_ACT_VLAN=m CONFIG_NET_ACT_BPF=m CONFIG_NET_ACT_CONNMARK=m -# CONFIG_NET_ACT_IFE is not set +CONFIG_NET_ACT_IFE=m +# CONFIG_NET_IFE_SKBMARK is not set +# CONFIG_NET_IFE_SKBPRIO is not set CONFIG_NET_CLS_IND=y CONFIG_NET_SCH_FIFO=y CONFIG_DCB=y @@ -1288,7 +1287,7 @@ CONFIG_CGROUP_NET_PRIO=y CONFIG_CGROUP_NET_CLASSID=y CONFIG_NET_RX_BUSY_POLL=y CONFIG_BQL=y -# CONFIG_BPF_JIT is not set +CONFIG_BPF_JIT=y CONFIG_NET_FLOW_LIMIT=y # @@ -1329,24 +1328,19 @@ CONFIG_CAN_VCAN=m CONFIG_CAN_SLCAN=m CONFIG_CAN_DEV=m CONFIG_CAN_CALC_BITTIMING=y -# CONFIG_CAN_LEDS is not set -CONFIG_CAN_FLEXCAN=m -CONFIG_CAN_GRCAN=m +CONFIG_CAN_LEDS=y +# CONFIG_CAN_FLEXCAN is not set +# CONFIG_CAN_GRCAN is not set CONFIG_CAN_SUN4I=m -CONFIG_CAN_TI_HECC=m -CONFIG_CAN_C_CAN=m -CONFIG_CAN_C_CAN_PLATFORM=m -CONFIG_CAN_CC770=m -CONFIG_CAN_CC770_ISA=m -CONFIG_CAN_CC770_PLATFORM=m +# CONFIG_CAN_TI_HECC is not set +# CONFIG_CAN_C_CAN is not set +# CONFIG_CAN_CC770 is not set # CONFIG_CAN_IFI_CANFD is not set -CONFIG_CAN_M_CAN=m -CONFIG_CAN_RCAR=m -CONFIG_CAN_RCAR_CANFD=m -CONFIG_CAN_SJA1000=m -CONFIG_CAN_SJA1000_ISA=m -CONFIG_CAN_SJA1000_PLATFORM=m -CONFIG_CAN_SOFTING=m +# CONFIG_CAN_M_CAN is not set +# CONFIG_CAN_RCAR is not set +# CONFIG_CAN_RCAR_CANFD is not set +# CONFIG_CAN_SJA1000 is not set +# CONFIG_CAN_SOFTING is not set # # CAN SPI interfaces @@ -1413,7 +1407,7 @@ CONFIG_BT_BNEP_PROTO_FILTER=y CONFIG_BT_HIDP=m CONFIG_BT_HS=y CONFIG_BT_LE=y -# CONFIG_BT_6LOWPAN is not set +CONFIG_BT_6LOWPAN=m CONFIG_BT_LEDS=y # CONFIG_BT_SELFTEST is not set CONFIG_BT_DEBUGFS=y @@ -1457,7 +1451,7 @@ CONFIG_WEXT_PROC=y CONFIG_WEXT_PRIV=y CONFIG_CFG80211=m # CONFIG_NL80211_TESTMODE is not set -CONFIG_CFG80211_DEVELOPER_WARNINGS=y +# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set # CONFIG_CFG80211_CERTIFICATION_ONUS is not set CONFIG_CFG80211_DEFAULT_PS=y # CONFIG_CFG80211_DEBUGFS is not set @@ -1667,7 +1661,7 @@ CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y CONFIG_PARPORT=m # CONFIG_PARPORT_PC is not set # CONFIG_PARPORT_GSC is not set -CONFIG_PARPORT_AX88796=m +# CONFIG_PARPORT_AX88796 is not set # CONFIG_PARPORT_1284 is not set CONFIG_PARPORT_NOT_PC=y CONFIG_BLK_DEV=y @@ -1679,7 +1673,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 CONFIG_BLK_DEV_CRYPTOLOOP=m # CONFIG_BLK_DEV_DRBD is not set CONFIG_BLK_DEV_NBD=m -CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM=m CONFIG_BLK_DEV_RAM_COUNT=4 CONFIG_BLK_DEV_RAM_SIZE=4096 # CONFIG_CDROM_PKTCDVD is not set @@ -1924,9 +1918,6 @@ CONFIG_TUN=m # CONFIG_TUN_VNET_CROSS_LE is not set CONFIG_VETH=m # CONFIG_NLMON is not set -CONFIG_ATM_DRIVERS=y -# CONFIG_ATM_DUMMY is not set -# CONFIG_ATM_TCP is not set # # CAIF transport drivers @@ -1937,11 +1928,6 @@ CONFIG_ATM_DRIVERS=y # # CONFIG_NET_DSA_MV88E6060 is not set # CONFIG_NET_DSA_BCM_SF2 is not set -CONFIG_B53=m -CONFIG_B53_SPI_DRIVER=m -CONFIG_B53_MDIO_DRIVER=m -CONFIG_B53_MMAP_DRIVER=m -CONFIG_B53_SRAB_DRIVER=m # CONFIG_NET_DSA_MV88E6XXX is not set CONFIG_ETHERNET=y CONFIG_NET_VENDOR_ALLWINNER=y @@ -1954,17 +1940,9 @@ CONFIG_SUN4I_EMAC=y # CONFIG_NET_VENDOR_CIRRUS is not set # CONFIG_DM9000 is not set # CONFIG_DNET is not set -CONFIG_NET_VENDOR_EZCHIP=y -# CONFIG_EZCHIP_NPS_MANAGEMENT_ENET is not set +# CONFIG_NET_VENDOR_EZCHIP is not set # CONFIG_NET_VENDOR_FARADAY is not set -CONFIG_NET_VENDOR_HISILICON=y -# CONFIG_HIX5HD2_GMAC is not set -# CONFIG_HISI_FEMAC is not set -CONFIG_HIP04_ETH=m -CONFIG_HNS_MDIO=m -# CONFIG_HNS is not set -# CONFIG_HNS_DSAF is not set -# CONFIG_HNS_ENET is not set +# CONFIG_NET_VENDOR_HISILICON is not set # CONFIG_NET_VENDOR_INTEL is not set # CONFIG_NET_VENDOR_MARVELL is not set # CONFIG_NET_VENDOR_MICREL is not set @@ -1973,12 +1951,11 @@ CONFIG_ENC28J60=m CONFIG_ENC28J60_WRITEVERIFY=y # CONFIG_ENCX24J600 is not set # CONFIG_NET_VENDOR_NATSEMI is not set -CONFIG_NET_VENDOR_NETRONOME=y +# CONFIG_NET_VENDOR_NETRONOME is not set # CONFIG_ETHOC is not set -CONFIG_NET_VENDOR_QUALCOMM=y -# CONFIG_QCA7000 is not set -CONFIG_NET_VENDOR_RENESAS=y -CONFIG_NET_VENDOR_ROCKER=y +# CONFIG_NET_VENDOR_QUALCOMM is not set +# CONFIG_NET_VENDOR_RENESAS is not set +# CONFIG_NET_VENDOR_ROCKER is not set # CONFIG_NET_VENDOR_SAMSUNG is not set # CONFIG_NET_VENDOR_SEEQ is not set # CONFIG_NET_VENDOR_SMSC is not set @@ -1993,31 +1970,33 @@ CONFIG_SYNOPSYS_DWC_ETH_QOS=m # CONFIG_NET_VENDOR_WIZNET is not set CONFIG_PHYLIB=y CONFIG_SWPHY=y +CONFIG_SWCONFIG=y +CONFIG_SWCONFIG_LEDS=y # # MII PHY device drivers # -CONFIG_AQUANTIA_PHY=m -CONFIG_AT803X_PHY=m -CONFIG_AMD_PHY=m +# CONFIG_AQUANTIA_PHY is not set +# CONFIG_AT803X_PHY is not set +# CONFIG_AMD_PHY is not set CONFIG_MARVELL_PHY=m -CONFIG_DAVICOM_PHY=m -CONFIG_QSEMI_PHY=m -CONFIG_LXT_PHY=m -CONFIG_CICADA_PHY=m -CONFIG_VITESSE_PHY=m -CONFIG_TERANETICS_PHY=m -CONFIG_SMSC_PHY=m +# CONFIG_DAVICOM_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_SMSC_PHY is not set CONFIG_BCM_NET_PHYLIB=m CONFIG_BROADCOM_PHY=m # CONFIG_BCM7XXX_PHY is not set CONFIG_BCM87XX_PHY=m -CONFIG_ICPLUS_PHY=m +# CONFIG_ICPLUS_PHY is not set CONFIG_REALTEK_PHY=m -CONFIG_NATIONAL_PHY=m -CONFIG_STE10XP=m -CONFIG_LSI_ET1011C_PHY=m -CONFIG_MICREL_PHY=m +# CONFIG_NATIONAL_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_MICREL_PHY is not set CONFIG_DP83848_PHY=m # CONFIG_DP83867_PHY is not set CONFIG_MICROCHIP_PHY=m @@ -2029,6 +2008,12 @@ CONFIG_MDIO_SUN4I=y # CONFIG_MDIO_BCM_UNIMAC is not set # CONFIG_INTEL_XWAY_PHY is not set # CONFIG_MDIO_HISI_FEMAC is not set +CONFIG_B53=y +CONFIG_B53_SPI_DRIVER=y +CONFIG_B53_PHY_DRIVER=y +CONFIG_B53_MMAP_DRIVER=y +CONFIG_B53_SRAB_DRIVER=y +CONFIG_B53_PHY_FIXUP=y # CONFIG_MICREL_KS8995MA is not set # CONFIG_PLIP is not set CONFIG_PPP=m @@ -2037,7 +2022,6 @@ CONFIG_PPP_DEFLATE=m CONFIG_PPP_FILTER=y CONFIG_PPP_MPPE=m # CONFIG_PPP_MULTILINK is not set -# CONFIG_PPPOATM is not set CONFIG_PPPOE=m CONFIG_PPTP=m CONFIG_PPPOL2TP=m @@ -2194,19 +2178,13 @@ CONFIG_RTLWIFI_USB=m # CONFIG_RTLWIFI_DEBUG is not set CONFIG_RTL8192C_COMMON=m # CONFIG_RTL8XXXU is not set -CONFIG_WLAN_VENDOR_RSI=y -# CONFIG_RSI_91X is not set -CONFIG_WLAN_VENDOR_ST=y -# CONFIG_CW1200 is not set -CONFIG_WLAN_VENDOR_TI=y -# CONFIG_WL1251 is not set -# CONFIG_WL12XX is not set -# CONFIG_WL18XX is not set -# CONFIG_WLCORE is not set +# CONFIG_WLAN_VENDOR_RSI is not set +# CONFIG_WLAN_VENDOR_ST is not set +# CONFIG_WLAN_VENDOR_TI is not set CONFIG_WLAN_VENDOR_ZYDAS=y # CONFIG_USB_ZD1201 is not set # CONFIG_ZD1211RW is not set -CONFIG_MAC80211_HWSIM=m +# CONFIG_MAC80211_HWSIM is not set CONFIG_USB_NET_RNDIS_WLAN=m # @@ -2448,7 +2426,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_XILINX_PS_UART is not set # CONFIG_SERIAL_ARC is not set # CONFIG_SERIAL_FSL_LPUART is not set -CONFIG_SERIAL_CONEXANT_DIGICOLOR=m +# CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set # CONFIG_SERIAL_ST_ASC is not set CONFIG_SERIAL_STM32=m # CONFIG_TTY_PRINTK is not set @@ -2494,9 +2472,9 @@ CONFIG_I2C_ALGOBIT=y # # CONFIG_I2C_CBUS_GPIO is not set # CONFIG_I2C_DESIGNWARE_PLATFORM is not set -CONFIG_I2C_EMEV2=m -# CONFIG_I2C_GPIO is not set -CONFIG_I2C_MV64XXX=y +# CONFIG_I2C_EMEV2 is not set +CONFIG_I2C_GPIO=m +# CONFIG_I2C_MV64XXX is not set # CONFIG_I2C_OCORES is not set # CONFIG_I2C_PCA_PLATFORM is not set # CONFIG_I2C_PXA_PCI is not set @@ -2518,7 +2496,7 @@ CONFIG_I2C_SUN6I_P2WI=m # # Other I2C/SMBus bus drivers # -CONFIG_I2C_STUB=m +# CONFIG_I2C_STUB is not set CONFIG_I2C_SLAVE=y CONFIG_I2C_SLAVE_EEPROM=m # CONFIG_I2C_DEBUG_CORE is not set @@ -2621,7 +2599,7 @@ CONFIG_GPIO_SYSFS=y # Memory mapped GPIO drivers # # CONFIG_GPIO_74XX_MMIO is not set -CONFIG_GPIO_ALTERA=m +# CONFIG_GPIO_ALTERA is not set # CONFIG_GPIO_DWAPB is not set # CONFIG_GPIO_EM is not set # CONFIG_GPIO_GENERIC_PLATFORM is not set @@ -2719,7 +2697,7 @@ CONFIG_AXP288_FUEL_GAUGE=m # CONFIG_CHARGER_SMB347 is not set # CONFIG_BATTERY_GAUGE_LTC2941 is not set # CONFIG_CHARGER_RT9455 is not set -CONFIG_AXP20X_POWER=y +CONFIG_AXP20X_POWER=m CONFIG_POWER_RESET=y # CONFIG_POWER_RESET_BRCMKONA is not set # CONFIG_POWER_RESET_BRCMSTB is not set @@ -2815,10 +2793,10 @@ CONFIG_SENSORS_LM95245=m CONFIG_SENSORS_PC87360=m CONFIG_SENSORS_PC87427=m CONFIG_SENSORS_NTC_THERMISTOR=m -CONFIG_SENSORS_NCT6683=m -CONFIG_SENSORS_NCT6775=m -CONFIG_SENSORS_NCT7802=m -CONFIG_SENSORS_NCT7904=m +# CONFIG_SENSORS_NCT6683 is not set +# CONFIG_SENSORS_NCT6775 is not set +# CONFIG_SENSORS_NCT7802 is not set +# CONFIG_SENSORS_NCT7904 is not set CONFIG_SENSORS_PCF8591=m # CONFIG_PMBUS is not set CONFIG_SENSORS_PWM_FAN=m @@ -2826,16 +2804,16 @@ CONFIG_SENSORS_SHT15=m CONFIG_SENSORS_SHT21=m CONFIG_SENSORS_SHT3x=m CONFIG_SENSORS_SHTC1=m -CONFIG_SENSORS_DME1737=m -CONFIG_SENSORS_EMC1403=m -CONFIG_SENSORS_EMC2103=m -CONFIG_SENSORS_EMC6W201=m -CONFIG_SENSORS_SMSC47M1=m -CONFIG_SENSORS_SMSC47M192=m -CONFIG_SENSORS_SMSC47B397=m -CONFIG_SENSORS_SCH56XX_COMMON=m -CONFIG_SENSORS_SCH5627=m -CONFIG_SENSORS_SCH5636=m +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_EMC1403 is not set +# CONFIG_SENSORS_EMC2103 is not set +# CONFIG_SENSORS_EMC6W201 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +# CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_SCH5627 is not set +# CONFIG_SENSORS_SCH5636 is not set CONFIG_SENSORS_SMM665=m CONFIG_SENSORS_ADC128D818=m CONFIG_SENSORS_ADS1015=m @@ -2851,17 +2829,16 @@ CONFIG_SENSORS_TMP102=m CONFIG_SENSORS_TMP103=m CONFIG_SENSORS_TMP401=m CONFIG_SENSORS_TMP421=m -CONFIG_SENSORS_VT1211=m -CONFIG_SENSORS_W83781D=m -CONFIG_SENSORS_W83791D=m -CONFIG_SENSORS_W83792D=m -CONFIG_SENSORS_W83793=m -CONFIG_SENSORS_W83795=m -# CONFIG_SENSORS_W83795_FANCTRL is not set -CONFIG_SENSORS_W83L785TS=m -CONFIG_SENSORS_W83L786NG=m -CONFIG_SENSORS_W83627HF=m -CONFIG_SENSORS_W83627EHF=m +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83795 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set CONFIG_THERMAL=m CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_OF=y @@ -3128,7 +3105,7 @@ CONFIG_RC_DEVICES=y # CONFIG_IR_IGUANA is not set # CONFIG_IR_TTUSBIR is not set # CONFIG_RC_LOOPBACK is not set -# CONFIG_IR_GPIO_CIR is not set +CONFIG_IR_GPIO_CIR=m CONFIG_IR_SUNXI=m CONFIG_MEDIA_USB_SUPPORT=y @@ -3254,7 +3231,7 @@ CONFIG_DVB_USB_DTV5100=m CONFIG_DVB_USB_FRIIO=m CONFIG_DVB_USB_AZ6027=m CONFIG_DVB_USB_TECHNISAT_USB2=m -CONFIG_DVB_USB_V2=y +CONFIG_DVB_USB_V2=m CONFIG_DVB_USB_AF9015=m CONFIG_DVB_USB_AF9035=m CONFIG_DVB_USB_ANYSEE=m @@ -3298,8 +3275,7 @@ CONFIG_VIDEO_VIVID=m # CONFIG_VIDEO_VIVID_CEC is not set CONFIG_VIDEO_VIVID_MAX_DEVS=64 CONFIG_VIDEO_VIM2M=m -CONFIG_DVB_PLATFORM_DRIVERS=y -CONFIG_DVB_C8SECTPFE=m +# CONFIG_DVB_PLATFORM_DRIVERS is not set # # Supported MMC/SDIO adapters @@ -3340,7 +3316,7 @@ CONFIG_CYPRESS_FIRMWARE=m CONFIG_DVB_B2C2_FLEXCOP=m CONFIG_SMS_SIANO_MDTV=m CONFIG_SMS_SIANO_RC=y -CONFIG_SMS_SIANO_DEBUGFS=y +# CONFIG_SMS_SIANO_DEBUGFS is not set CONFIG_VIDEO_V4L2_TPG=m # @@ -3682,7 +3658,7 @@ CONFIG_DRM=y CONFIG_DRM_KMS_HELPER=y CONFIG_DRM_KMS_FB_HELPER=y CONFIG_DRM_FBDEV_EMULATION=y -# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set +CONFIG_DRM_LOAD_EDID_FIRMWARE=y CONFIG_DRM_GEM_CMA_HELPER=y CONFIG_DRM_KMS_CMA_HELPER=y @@ -3825,7 +3801,7 @@ CONFIG_SND_PCM_TIMER=y # CONFIG_SND_DYNAMIC_MINORS is not set CONFIG_SND_SUPPORT_OLD_API=y CONFIG_SND_PROC_FS=y -CONFIG_SND_VERBOSE_PROCFS=y +# CONFIG_SND_VERBOSE_PROCFS is not set # CONFIG_SND_VERBOSE_PRINTK is not set # CONFIG_SND_DEBUG is not set CONFIG_SND_VMASTER=y @@ -4296,7 +4272,6 @@ CONFIG_USB_EZUSB_FX2=m # CONFIG_USB_HSIC_USB3503 is not set # CONFIG_USB_LINK_LAYER_TEST is not set CONFIG_USB_CHAOSKEY=m -# CONFIG_USB_ATM is not set # # USB Physical Layer drivers @@ -5175,7 +5150,7 @@ CONFIG_ARM_PMU=y CONFIG_NVMEM=m CONFIG_NVMEM_SUNXI_SID=m CONFIG_STM=m -CONFIG_STM_DUMMY=m +# CONFIG_STM_DUMMY is not set CONFIG_STM_SOURCE_CONSOLE=m # CONFIG_STM_SOURCE_HEARTBEAT is not set # CONFIG_INTEL_TH is not set @@ -5241,7 +5216,7 @@ CONFIG_F2FS_FS_XATTR=y CONFIG_F2FS_FS_POSIX_ACL=y # CONFIG_F2FS_FS_SECURITY is not set # CONFIG_F2FS_CHECK_FS is not set -# CONFIG_F2FS_FS_ENCRYPTION is not set +CONFIG_F2FS_FS_ENCRYPTION=y # CONFIG_F2FS_IO_TRACE is not set # CONFIG_F2FS_FAULT_INJECTION is not set CONFIG_FS_POSIX_ACL=y @@ -5889,9 +5864,10 @@ CONFIG_CRC32_SLICEBY8=y # CONFIG_CRC32_SLICEBY4 is not set # CONFIG_CRC32_SARWATE is not set # CONFIG_CRC32_BIT is not set -CONFIG_CRC7=m +CONFIG_CRC7=y CONFIG_LIBCRC32C=y -CONFIG_CRC8=m +CONFIG_CRC8=y +CONFIG_AUDIT_GENERIC=y # CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set # CONFIG_RANDOM32_SELFTEST is not set CONFIG_842_COMPRESS=m @@ -5934,7 +5910,7 @@ CONFIG_GLOB=y CONFIG_NLATTR=y CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y CONFIG_CLZ_TAB=y -# CONFIG_CORDIC is not set +CONFIG_CORDIC=y # CONFIG_DDR is not set # CONFIG_IRQ_POLL is not set CONFIG_MPILIB=m diff --git a/config/sources/marvell.conf b/config/sources/marvell.conf index 7633d5cb99..a38db860d3 100644 --- a/config/sources/marvell.conf +++ b/config/sources/marvell.conf @@ -23,7 +23,7 @@ case $BRANCH in dev) KERNELSOURCE='https://github.com/SolidRun/linux-stable' - KERNELBRANCH='branch:linux-4.4.y-clearfog' + KERNELBRANCH='branch:linux-4.4.y-marvell' KERNELDIR='linux-armada-modern' ;; esac diff --git a/configuration.sh b/configuration.sh index 7d1cb6e929..c4393ec7e0 100644 --- a/configuration.sh +++ b/configuration.sh @@ -150,7 +150,8 @@ case $RELEASE in ;; xenial) PACKAGE_LIST_RELEASE="man-db wget nano libpam-systemd software-properties-common libnss-myhostname f2fs-tools iperf3 paprefs" - PACKAGE_LIST_DESKTOP="$PACKAGE_LIST_DESKTOP libreoffice-writer libreoffice-style-tango libreoffice-gtk thunderbird firefox gnome-icon-theme-full tango-icon-theme policykit-1" + PACKAGE_LIST_DESKTOP="$PACKAGE_LIST_DESKTOP libreoffice-writer libreoffice-style-tango libreoffice-gtk thunderbird firefox gnome-icon-theme-full tango-icon-theme \ + policykit-1 language-selector-gnome" ;; esac diff --git a/debootstrap-ng.sh b/debootstrap-ng.sh index 99ee8aea29..3dd1f9b630 100644 --- a/debootstrap-ng.sh +++ b/debootstrap-ng.sh @@ -498,8 +498,8 @@ sign_and_compress() display_alert "Done building" "$DEST/images/${version}.img" "info" else display_alert "Signing and compressing" "Please wait!" "info" - # stage: generate sha256sum - sha256sum -b ${version}.img > sha256sum + # stage: generate sha256sum.sha + sha256sum -b ${version}.img > sha256sum.sha # stage: sign with PGP if [[ -n $GPG_PASS ]]; then echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --batch --yes ${version}.img @@ -508,17 +508,17 @@ sign_and_compress() if [[ $SEVENZIP == yes ]]; then local filename=$DEST/images/${version}.7z if [[ $BUILD_ALL == yes ]]; then - nice -n 19 bash -c "7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $filename ${version}.img armbian.txt *.asc sha256sum >/dev/null 2>&1 \ + nice -n 19 bash -c "7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $filename ${version}.img armbian.txt *.asc sha256sum.sha >/dev/null 2>&1 \ ; [[ -n '$SEND_TO_SERVER' ]] && rsync -arP $filename -e 'ssh -p 22' $SEND_TO_SERVER" else - 7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $filename ${version}.img armbian.txt *.asc sha256sum >/dev/null 2>&1 + 7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $filename ${version}.img armbian.txt *.asc sha256sum.sha >/dev/null 2>&1 [[ -n $SEND_TO_SERVER ]] && rsync -arP $filename -e 'ssh -p 22' $SEND_TO_SERVER fi else local filename=$DEST/images/${version}.zip - zip -FSq $filename ${version}.img armbian.txt *.asc sha256sum + zip -FSq $filename ${version}.img armbian.txt *.asc sha256sum.sha fi - rm -f ${version}.img *.asc armbian.txt sha256sum + rm -f ${version}.img *.asc armbian.txt sha256sum.sha if [[ $BUILD_ALL == yes ]]; then cd .. && rmdir "${TEMP_DIR}" else diff --git a/extras/firmware.sh b/extras/firmware.sh index d92b229160..f6d6a2fe75 100644 --- a/extras/firmware.sh +++ b/extras/firmware.sh @@ -23,7 +23,7 @@ build_firmware() cp -R $SRC/lib/bin/firmware-overlay/* $SOURCES/$plugin_dir/lib/firmware # cleanup what's not needed for sure - rm -rf $SOURCES/$plugin_dir/lib/firmware/{amdgpu,amd-ucode,radeon,nvidia,matrox} + rm -rf $SOURCES/$plugin_dir/lib/firmware/{amdgpu,amd-ucode,radeon,nvidia,matrox,.git} cd $SOURCES/$plugin_dir # set up control file diff --git a/main.sh b/main.sh index 7d22689b9a..694274bff6 100644 --- a/main.sh +++ b/main.sh @@ -47,8 +47,8 @@ date +"%d_%m_%Y-%H_%M_%S" > $DEST/debug/timestamp (cd $DEST/debug && find . -name '*.tgz' -atime +7 -delete) > /dev/null # compile.sh version checking -ver1=$(awk -F"=" '/^# VERSION/ {print $2}' <"$SRC/compile.sh") -ver2=$(awk -F"=" '/^# VERSION/ {print $2}' <"$SRC/lib/compile.sh" 2>/dev/null) || ver2=0 +ver1=$(awk -F"=" '/^# VERSION/ {print $2}' <$SRC/compile.sh ) +ver2=$(awk -F"=" '/^# VERSION/ {print $2}' <$SRC/lib/compile.sh 2>/dev/null) || ver2=0 if [[ -z $ver1 || $ver1 -lt $ver2 ]]; then display_alert "File $0 is outdated. Please overwrite it with an updated version from" "$SRC/lib" "wrn" echo -e "Press \e[0;33m\x1B[0m to abort compilation, \e[0;33m\x1B[0m to ignore and continue" @@ -200,24 +200,12 @@ done # Compile u-boot if packed .deb does not exist if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then - # if requires specific toolchain, check if default is suitable - if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" ; then - # try to find suitable in $SRC/toolchains, exit if not found - find_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" "UBOOT_TOOLCHAIN" - fi - - compile_uboot $(overlayfs_wrapper "wrap" "$SOURCES/$BOOTSOURCEDIR") + compile_uboot fi # Compile kernel if packed .deb does not exist if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then - # if requires specific toolchain, check if default is suitable - if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain "$KERNEL" "$KERNEL_NEEDS_GCC" ; then - # try to find suitable in $SRC/toolchains, exit if not found - find_toolchain "KERNEL" "$KERNEL_NEEDS_GCC" "KERNEL_TOOLCHAIN" - fi - - compile_kernel $(overlayfs_wrapper "wrap" "$SOURCES/$LINUXSOURCEDIR") + compile_kernel fi overlayfs_wrapper "cleanup" diff --git a/makeboarddeb.sh b/makeboarddeb.sh index 421f371e74..37ba48f720 100644 --- a/makeboarddeb.sh +++ b/makeboarddeb.sh @@ -25,6 +25,7 @@ create_board_package() # Replaces: base-files is needed to replace /etc/update-motd.d/ files on Xenial # Replaces: unattended-upgrades may be needed to replace /etc/apt/apt.conf.d/50unattended-upgrades # (distributions provide good defaults, so this is not needed currently) + # Depends: linux-base is needed for "linux-version" command in initrd cleanup script cat <<-EOF > $destination/DEBIAN/control Package: linux-${RELEASE}-root-${DEB_BRANCH}${BOARD} Version: $REVISION @@ -33,7 +34,7 @@ create_board_package() Installed-Size: 1 Section: kernel Priority: optional - Depends: bash + Depends: bash, linux-base Provides: armbian-bsp Conflicts: armbian-bsp Replaces: base-files, mpv @@ -233,6 +234,14 @@ create_board_package() # setting window title for remote sessions install -m 755 $SRC/lib/scripts/ssh-title.sh $destination/etc/profile.d/ssh-title.sh + # install copy of boot script & environment file + mkdir -p $destination/usr/share/armbian/ + local bootscript_src=${BOOTSCRIPT%%:*} + local bootscript_dst=${BOOTSCRIPT##*:} + cp $SRC/lib/config/bootscripts/$bootscript_src $destination/usr/share/armbian/$bootscript_dst + [[ -n $BOOTENV_FILE && -f $SRC/lib/config/bootenv/$BOOTENV_FILE ]] && \ + cp $SRC/lib/config/bootenv/$BOOTENV_FILE $destination/usr/share/armbian/armbianEnv.txt + # h3disp for sun8i/3.4.x if [[ $LINUXFAMILY == sun8i && $BRANCH == default ]]; then install -m 755 $SRC/lib/scripts/h3disp $destination/usr/bin diff --git a/patch/kernel/marvell-dev/patch-4.4.15-16.patch b/patch/kernel/marvell-dev/patch-4.4.15-16.patch deleted file mode 100644 index cb9c03a1c8..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.15-16.patch +++ /dev/null @@ -1,5699 +0,0 @@ -diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 -index 6708c5e264aa..33e96f740639 100644 ---- a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 -+++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 -@@ -1,4 +1,4 @@ --What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw -+What /sys/bus/iio/devices/iio:deviceX/in_proximity_input - Date: March 2014 - KernelVersion: 3.15 - Contact: Matt Ranostay -diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt -index 8638f61c8c9d..37eca00796ee 100644 ---- a/Documentation/scsi/scsi_eh.txt -+++ b/Documentation/scsi/scsi_eh.txt -@@ -263,19 +263,23 @@ scmd->allowed. - - 3. scmd recovered - ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd -- - shost->host_failed-- - - clear scmd->eh_eflags - - scsi_setup_cmd_retry() - - move from local eh_work_q to local eh_done_q - LOCKING: none -+ CONCURRENCY: at most one thread per separate eh_work_q to -+ keep queue manipulation lockless - - 4. EH completes - ACTION: scsi_eh_flush_done_q() retries scmds or notifies upper -- layer of failure. -+ layer of failure. May be called concurrently but must have -+ a no more than one thread per separate eh_work_q to -+ manipulate the queue locklessly - - scmd is removed from eh_done_q and scmd->eh_entry is cleared - - if retry is necessary, scmd is requeued using - scsi_queue_insert() - - otherwise, scsi_finish_command() is invoked for scmd -+ - zero shost->host_failed - LOCKING: queue or finish function performs appropriate locking - - -diff --git a/Makefile b/Makefile -index 979088079338..da7621cadc8e 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 15 -+SUBLEVEL = 16 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig -index 6312f607932f..2d785f5a3041 100644 ---- a/arch/arc/Kconfig -+++ b/arch/arc/Kconfig -@@ -387,7 +387,7 @@ config ARC_HAS_LLSC - - config ARC_STAR_9000923308 - bool "Workaround for llock/scond livelock" -- default y -+ default n - depends on ISA_ARCV2 && SMP && ARC_HAS_LLSC - - config ARC_HAS_SWAPE -diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c -index e1b87444ea9a..05131805aa33 100644 ---- a/arch/arc/kernel/setup.c -+++ b/arch/arc/kernel/setup.c -@@ -332,10 +332,6 @@ static void arc_chk_core_config(void) - pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n"); - else if (!cpu->extn.fpu_dp && fpu_enabled) - panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n"); -- -- if (is_isa_arcv2() && IS_ENABLED(CONFIG_SMP) && cpu->isa.atomic && -- !IS_ENABLED(CONFIG_ARC_STAR_9000923308)) -- panic("llock/scond livelock workaround missing\n"); - } - - /* -diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi -index 8450944b28e6..22f7a13e20b4 100644 ---- a/arch/arm/boot/dts/armada-385-linksys.dtsi -+++ b/arch/arm/boot/dts/armada-385-linksys.dtsi -@@ -58,8 +58,8 @@ - soc { - ranges = ; -+ MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000 -+ MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>; - - internal-regs { - -diff --git a/arch/arm/boot/dts/sun5i-r8-chip.dts b/arch/arm/boot/dts/sun5i-r8-chip.dts -index 530ab28e9ca2..d21f50ba3172 100644 ---- a/arch/arm/boot/dts/sun5i-r8-chip.dts -+++ b/arch/arm/boot/dts/sun5i-r8-chip.dts -@@ -52,7 +52,7 @@ - - / { - model = "NextThing C.H.I.P."; -- compatible = "nextthing,chip", "allwinner,sun5i-r8"; -+ compatible = "nextthing,chip", "allwinner,sun5i-r8", "allwinner,sun5i-a13"; - - aliases { - i2c0 = &i2c0; -diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h -index aeddd28b3595..92fd2c8a9af0 100644 ---- a/arch/arm/include/asm/pgtable-2level.h -+++ b/arch/arm/include/asm/pgtable-2level.h -@@ -193,6 +193,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) - - #define pmd_large(pmd) (pmd_val(pmd) & 2) - #define pmd_bad(pmd) (pmd_val(pmd) & 2) -+#define pmd_present(pmd) (pmd_val(pmd)) - - #define copy_pmd(pmdpd,pmdps) \ - do { \ -diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h -index a745a2a53853..fd929b5ded9e 100644 ---- a/arch/arm/include/asm/pgtable-3level.h -+++ b/arch/arm/include/asm/pgtable-3level.h -@@ -212,6 +212,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) - : !!(pmd_val(pmd) & (val))) - #define pmd_isclear(pmd, val) (!(pmd_val(pmd) & (val))) - -+#define pmd_present(pmd) (pmd_isset((pmd), L_PMD_SECT_VALID)) - #define pmd_young(pmd) (pmd_isset((pmd), PMD_SECT_AF)) - #define pte_special(pte) (pte_isset((pte), L_PTE_SPECIAL)) - static inline pte_t pte_mkspecial(pte_t pte) -@@ -257,10 +258,10 @@ PMD_BIT_FUNC(mkyoung, |= PMD_SECT_AF); - #define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))) - #define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) - --/* represent a notpresent pmd by zero, this is used by pmdp_invalidate */ -+/* represent a notpresent pmd by faulting entry, this is used by pmdp_invalidate */ - static inline pmd_t pmd_mknotpresent(pmd_t pmd) - { -- return __pmd(0); -+ return __pmd(pmd_val(pmd) & ~L_PMD_SECT_VALID); - } - - static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) -diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h -index 348caabb7625..d62204060cbe 100644 ---- a/arch/arm/include/asm/pgtable.h -+++ b/arch/arm/include/asm/pgtable.h -@@ -182,7 +182,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; - #define pgd_offset_k(addr) pgd_offset(&init_mm, addr) - - #define pmd_none(pmd) (!pmd_val(pmd)) --#define pmd_present(pmd) (pmd_val(pmd)) - - static inline pte_t *pmd_page_vaddr(pmd_t pmd) - { -diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c -index acaf7056efa5..e08d02667c81 100644 ---- a/arch/arm/mach-imx/mach-imx6ul.c -+++ b/arch/arm/mach-imx/mach-imx6ul.c -@@ -46,7 +46,7 @@ static int ksz8081_phy_fixup(struct phy_device *dev) - static void __init imx6ul_enet_phy_init(void) - { - if (IS_BUILTIN(CONFIG_PHYLIB)) -- phy_register_fixup_for_uid(PHY_ID_KSZ8081, 0xffffffff, -+ phy_register_fixup_for_uid(PHY_ID_KSZ8081, MICREL_PHY_ID_MASK, - ksz8081_phy_fixup); - } - -diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h -index e9e5467e0bf4..a307eb6e7fa8 100644 ---- a/arch/arm64/include/asm/ptrace.h -+++ b/arch/arm64/include/asm/ptrace.h -@@ -58,6 +58,7 @@ - #define COMPAT_PSR_Z_BIT 0x40000000 - #define COMPAT_PSR_N_BIT 0x80000000 - #define COMPAT_PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */ -+#define COMPAT_PSR_GE_MASK 0x000f0000 - - #ifdef CONFIG_CPU_BIG_ENDIAN - #define COMPAT_PSR_ENDSTATE COMPAT_PSR_E_BIT -@@ -151,35 +152,9 @@ static inline unsigned long regs_return_value(struct pt_regs *regs) - return regs->regs[0]; - } - --/* -- * Are the current registers suitable for user mode? (used to maintain -- * security in signal handlers) -- */ --static inline int valid_user_regs(struct user_pt_regs *regs) --{ -- if (user_mode(regs) && (regs->pstate & PSR_I_BIT) == 0) { -- regs->pstate &= ~(PSR_F_BIT | PSR_A_BIT); -- -- /* The T bit is reserved for AArch64 */ -- if (!(regs->pstate & PSR_MODE32_BIT)) -- regs->pstate &= ~COMPAT_PSR_T_BIT; -- -- return 1; -- } -- -- /* -- * Force PSR to something logical... -- */ -- regs->pstate &= PSR_f | PSR_s | (PSR_x & ~PSR_A_BIT) | \ -- COMPAT_PSR_T_BIT | PSR_MODE32_BIT; -- -- if (!(regs->pstate & PSR_MODE32_BIT)) { -- regs->pstate &= ~COMPAT_PSR_T_BIT; -- regs->pstate |= PSR_MODE_EL0t; -- } -- -- return 0; --} -+/* We must avoid circular header include via sched.h */ -+struct task_struct; -+int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task); - - #define instruction_pointer(regs) ((unsigned long)(regs)->pc) - -diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c -index ff7f13239515..fc779ec6f051 100644 ---- a/arch/arm64/kernel/ptrace.c -+++ b/arch/arm64/kernel/ptrace.c -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - #include -@@ -500,7 +501,7 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset, - if (ret) - return ret; - -- if (!valid_user_regs(&newregs)) -+ if (!valid_user_regs(&newregs, target)) - return -EINVAL; - - task_pt_regs(target)->user_regs = newregs; -@@ -770,7 +771,7 @@ static int compat_gpr_set(struct task_struct *target, - - } - -- if (valid_user_regs(&newregs.user_regs)) -+ if (valid_user_regs(&newregs.user_regs, target)) - *task_pt_regs(target) = newregs; - else - ret = -EINVAL; -@@ -1272,3 +1273,79 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs) - if (test_thread_flag(TIF_SYSCALL_TRACE)) - tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); - } -+ -+/* -+ * Bits which are always architecturally RES0 per ARM DDI 0487A.h -+ * Userspace cannot use these until they have an architectural meaning. -+ * We also reserve IL for the kernel; SS is handled dynamically. -+ */ -+#define SPSR_EL1_AARCH64_RES0_BITS \ -+ (GENMASK_ULL(63,32) | GENMASK_ULL(27, 22) | GENMASK_ULL(20, 10) | \ -+ GENMASK_ULL(5, 5)) -+#define SPSR_EL1_AARCH32_RES0_BITS \ -+ (GENMASK_ULL(63,32) | GENMASK_ULL(24, 22) | GENMASK_ULL(20,20)) -+ -+static int valid_compat_regs(struct user_pt_regs *regs) -+{ -+ regs->pstate &= ~SPSR_EL1_AARCH32_RES0_BITS; -+ -+ if (!system_supports_mixed_endian_el0()) { -+ if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) -+ regs->pstate |= COMPAT_PSR_E_BIT; -+ else -+ regs->pstate &= ~COMPAT_PSR_E_BIT; -+ } -+ -+ if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) && -+ (regs->pstate & COMPAT_PSR_A_BIT) == 0 && -+ (regs->pstate & COMPAT_PSR_I_BIT) == 0 && -+ (regs->pstate & COMPAT_PSR_F_BIT) == 0) { -+ return 1; -+ } -+ -+ /* -+ * Force PSR to a valid 32-bit EL0t, preserving the same bits as -+ * arch/arm. -+ */ -+ regs->pstate &= COMPAT_PSR_N_BIT | COMPAT_PSR_Z_BIT | -+ COMPAT_PSR_C_BIT | COMPAT_PSR_V_BIT | -+ COMPAT_PSR_Q_BIT | COMPAT_PSR_IT_MASK | -+ COMPAT_PSR_GE_MASK | COMPAT_PSR_E_BIT | -+ COMPAT_PSR_T_BIT; -+ regs->pstate |= PSR_MODE32_BIT; -+ -+ return 0; -+} -+ -+static int valid_native_regs(struct user_pt_regs *regs) -+{ -+ regs->pstate &= ~SPSR_EL1_AARCH64_RES0_BITS; -+ -+ if (user_mode(regs) && !(regs->pstate & PSR_MODE32_BIT) && -+ (regs->pstate & PSR_D_BIT) == 0 && -+ (regs->pstate & PSR_A_BIT) == 0 && -+ (regs->pstate & PSR_I_BIT) == 0 && -+ (regs->pstate & PSR_F_BIT) == 0) { -+ return 1; -+ } -+ -+ /* Force PSR to a valid 64-bit EL0t */ -+ regs->pstate &= PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT; -+ -+ return 0; -+} -+ -+/* -+ * Are the current registers suitable for user mode? (used to maintain -+ * security in signal handlers) -+ */ -+int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task) -+{ -+ if (!test_tsk_thread_flag(task, TIF_SINGLESTEP)) -+ regs->pstate &= ~DBG_SPSR_SS; -+ -+ if (is_compat_thread(task_thread_info(task))) -+ return valid_compat_regs(regs); -+ else -+ return valid_native_regs(regs); -+} -diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c -index e18c48cb6db1..a8eafdbc7cb8 100644 ---- a/arch/arm64/kernel/signal.c -+++ b/arch/arm64/kernel/signal.c -@@ -115,7 +115,7 @@ static int restore_sigframe(struct pt_regs *regs, - */ - regs->syscallno = ~0UL; - -- err |= !valid_user_regs(®s->user_regs); -+ err |= !valid_user_regs(®s->user_regs, current); - - if (err == 0) { - struct fpsimd_context *fpsimd_ctx = -@@ -307,7 +307,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) - /* - * Check that the resulting registers are actually sane. - */ -- ret |= !valid_user_regs(®s->user_regs); -+ ret |= !valid_user_regs(®s->user_regs, current); - - /* - * Fast forward the stepping logic so we step into the signal -diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c -index 71ef6dc89ae5..107335637390 100644 ---- a/arch/arm64/kernel/signal32.c -+++ b/arch/arm64/kernel/signal32.c -@@ -356,7 +356,7 @@ static int compat_restore_sigframe(struct pt_regs *regs, - */ - regs->syscallno = ~0UL; - -- err |= !valid_user_regs(®s->user_regs); -+ err |= !valid_user_regs(®s->user_regs, current); - - aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace; - if (err == 0) -diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h -index 4e956b3e16f5..dd7cee795709 100644 ---- a/arch/mips/include/asm/kvm_host.h -+++ b/arch/mips/include/asm/kvm_host.h -@@ -372,6 +372,7 @@ struct kvm_mips_tlb { - #define KVM_MIPS_GUEST_TLB_SIZE 64 - struct kvm_vcpu_arch { - void *host_ebase, *guest_ebase; -+ int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu); - unsigned long host_stack; - unsigned long host_gp; - -diff --git a/arch/mips/kvm/interrupt.h b/arch/mips/kvm/interrupt.h -index 4ab4bdfad703..2143884709e4 100644 ---- a/arch/mips/kvm/interrupt.h -+++ b/arch/mips/kvm/interrupt.h -@@ -28,6 +28,7 @@ - #define MIPS_EXC_MAX 12 - /* XXXSL More to follow */ - -+extern char __kvm_mips_vcpu_run_end[]; - extern char mips32_exception[], mips32_exceptionEnd[]; - extern char mips32_GuestException[], mips32_GuestExceptionEnd[]; - -diff --git a/arch/mips/kvm/locore.S b/arch/mips/kvm/locore.S -index 7e2210846b8b..77706433651b 100644 ---- a/arch/mips/kvm/locore.S -+++ b/arch/mips/kvm/locore.S -@@ -227,6 +227,7 @@ FEXPORT(__kvm_mips_load_k0k1) - - /* Jump to guest */ - eret -+EXPORT(__kvm_mips_vcpu_run_end) - - VECTOR(MIPSX(exception), unknown) - /* Find out what mode we came from and jump to the proper handler. */ -diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c -index 2683d04fdda5..e86b7499921a 100644 ---- a/arch/mips/kvm/mips.c -+++ b/arch/mips/kvm/mips.c -@@ -314,6 +314,15 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) - memcpy(gebase + offset, mips32_GuestException, - mips32_GuestExceptionEnd - mips32_GuestException); - -+#ifdef MODULE -+ offset += mips32_GuestExceptionEnd - mips32_GuestException; -+ memcpy(gebase + offset, (char *)__kvm_mips_vcpu_run, -+ __kvm_mips_vcpu_run_end - (char *)__kvm_mips_vcpu_run); -+ vcpu->arch.vcpu_run = gebase + offset; -+#else -+ vcpu->arch.vcpu_run = __kvm_mips_vcpu_run; -+#endif -+ - /* Invalidate the icache for these ranges */ - local_flush_icache_range((unsigned long)gebase, - (unsigned long)gebase + ALIGN(size, PAGE_SIZE)); -@@ -403,7 +412,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) - /* Disable hardware page table walking while in guest */ - htw_stop(); - -- r = __kvm_mips_vcpu_run(run, vcpu); -+ r = vcpu->arch.vcpu_run(run, vcpu); - - /* Re-enable HTW before enabling interrupts */ - htw_start(); -diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c -index 646bf4d222c1..cf788d7d7e56 100644 ---- a/arch/powerpc/kernel/process.c -+++ b/arch/powerpc/kernel/process.c -@@ -1239,6 +1239,16 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp) - current->thread.regs = regs - 1; - } - -+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM -+ /* -+ * Clear any transactional state, we're exec()ing. The cause is -+ * not important as there will never be a recheckpoint so it's not -+ * user visible. -+ */ -+ if (MSR_TM_SUSPENDED(mfmsr())) -+ tm_reclaim_current(0); -+#endif -+ - memset(regs->gpr, 0, sizeof(regs->gpr)); - regs->ctr = 0; - regs->link = 0; -diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c -index e52b82b71d79..b7e86e00048f 100644 ---- a/arch/powerpc/kernel/prom_init.c -+++ b/arch/powerpc/kernel/prom_init.c -@@ -718,7 +718,7 @@ unsigned char ibm_architecture_vec[] = { - * must match by the macro below. Update the definition if - * the structure layout changes. - */ --#define IBM_ARCH_VEC_NRCORES_OFFSET 125 -+#define IBM_ARCH_VEC_NRCORES_OFFSET 133 - W(NR_CPUS), /* number of cores supported */ - 0, - 0, -diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c -index bd98ce2be17b..3e8865b187de 100644 ---- a/arch/powerpc/platforms/pseries/iommu.c -+++ b/arch/powerpc/platforms/pseries/iommu.c -@@ -912,7 +912,8 @@ machine_arch_initcall(pseries, find_existing_ddw_windows); - static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, - struct ddw_query_response *query) - { -- struct eeh_dev *edev; -+ struct device_node *dn; -+ struct pci_dn *pdn; - u32 cfg_addr; - u64 buid; - int ret; -@@ -923,11 +924,10 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, - * Retrieve them from the pci device, not the node with the - * dma-window property - */ -- edev = pci_dev_to_eeh_dev(dev); -- cfg_addr = edev->config_addr; -- if (edev->pe_config_addr) -- cfg_addr = edev->pe_config_addr; -- buid = edev->phb->buid; -+ dn = pci_device_to_OF_node(dev); -+ pdn = PCI_DN(dn); -+ buid = pdn->phb->buid; -+ cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8)); - - ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query, - cfg_addr, BUID_HI(buid), BUID_LO(buid)); -@@ -941,7 +941,8 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, - struct ddw_create_response *create, int page_shift, - int window_shift) - { -- struct eeh_dev *edev; -+ struct device_node *dn; -+ struct pci_dn *pdn; - u32 cfg_addr; - u64 buid; - int ret; -@@ -952,11 +953,10 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, - * Retrieve them from the pci device, not the node with the - * dma-window property - */ -- edev = pci_dev_to_eeh_dev(dev); -- cfg_addr = edev->config_addr; -- if (edev->pe_config_addr) -- cfg_addr = edev->pe_config_addr; -- buid = edev->phb->buid; -+ dn = pci_device_to_OF_node(dev); -+ pdn = PCI_DN(dn); -+ buid = pdn->phb->buid; -+ cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8)); - - do { - /* extra outputs are LIOBN and dma-addr (hi, lo) */ -diff --git a/arch/s390/include/asm/fpu/api.h b/arch/s390/include/asm/fpu/api.h -index 5e04f3cbd320..8ae236b0f80b 100644 ---- a/arch/s390/include/asm/fpu/api.h -+++ b/arch/s390/include/asm/fpu/api.h -@@ -22,7 +22,7 @@ static inline int test_fp_ctl(u32 fpc) - " la %0,0\n" - "1:\n" - EX_TABLE(0b,1b) -- : "=d" (rc), "=d" (orig_fpc) -+ : "=d" (rc), "=&d" (orig_fpc) - : "d" (fpc), "0" (-EINVAL)); - return rc; - } -diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile -index 2ee62dba0373..c0cc2a6be0bf 100644 ---- a/arch/x86/boot/Makefile -+++ b/arch/x86/boot/Makefile -@@ -162,6 +162,9 @@ isoimage: $(obj)/bzImage - for i in lib lib64 share end ; do \ - if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \ - cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \ -+ if [ -f /usr/$$i/syslinux/ldlinux.c32 ]; then \ -+ cp /usr/$$i/syslinux/ldlinux.c32 $(obj)/isoimage ; \ -+ fi ; \ - break ; \ - fi ; \ - if [ $$i = end ] ; then exit 1 ; fi ; \ -diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c -index 29fa475ec518..c986d0b3bc35 100644 ---- a/arch/x86/kernel/amd_nb.c -+++ b/arch/x86/kernel/amd_nb.c -@@ -71,8 +71,8 @@ int amd_cache_northbridges(void) - while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL) - i++; - -- if (i == 0) -- return 0; -+ if (!i) -+ return -ENODEV; - - nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL); - if (!nb) -diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c -index 078de2e86b7a..5f82cd59f0e5 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel.c -+++ b/arch/x86/kernel/cpu/perf_event_intel.c -@@ -3601,7 +3601,7 @@ __init int intel_pmu_init(void) - c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1; - } - c->idxmsk64 &= -- ~(~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed)); -+ ~(~0ULL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed)); - c->weight = hweight64(c->idxmsk64); - } - } -diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c -index 1deffe6cc873..023c442c33bb 100644 ---- a/arch/x86/kernel/kprobes/core.c -+++ b/arch/x86/kernel/kprobes/core.c -@@ -959,7 +959,19 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) - * normal page fault. - */ - regs->ip = (unsigned long)cur->addr; -+ /* -+ * Trap flag (TF) has been set here because this fault -+ * happened where the single stepping will be done. -+ * So clear it by resetting the current kprobe: -+ */ -+ regs->flags &= ~X86_EFLAGS_TF; -+ -+ /* -+ * If the TF flag was set before the kprobe hit, -+ * don't touch it: -+ */ - regs->flags |= kcb->kprobe_old_flags; -+ - if (kcb->kprobe_status == KPROBE_REENTER) - restore_previous_kprobe(kcb); - else -diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c -index f314e9b9660b..41e7943004fe 100644 ---- a/arch/x86/kvm/vmx.c -+++ b/arch/x86/kvm/vmx.c -@@ -6579,7 +6579,13 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu, - - /* Checks for #GP/#SS exceptions. */ - exn = false; -- if (is_protmode(vcpu)) { -+ if (is_long_mode(vcpu)) { -+ /* Long mode: #GP(0)/#SS(0) if the memory address is in a -+ * non-canonical form. This is the only check on the memory -+ * destination for long mode! -+ */ -+ exn = is_noncanonical_address(*ret); -+ } else if (is_protmode(vcpu)) { - /* Protected mode: apply checks for segment validity in the - * following order: - * - segment type check (#GP(0) may be thrown) -@@ -6596,17 +6602,10 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu, - * execute-only code segment - */ - exn = ((s.type & 0xa) == 8); -- } -- if (exn) { -- kvm_queue_exception_e(vcpu, GP_VECTOR, 0); -- return 1; -- } -- if (is_long_mode(vcpu)) { -- /* Long mode: #GP(0)/#SS(0) if the memory address is in a -- * non-canonical form. This is an only check for long mode. -- */ -- exn = is_noncanonical_address(*ret); -- } else if (is_protmode(vcpu)) { -+ if (exn) { -+ kvm_queue_exception_e(vcpu, GP_VECTOR, 0); -+ return 1; -+ } - /* Protected mode: #GP(0)/#SS(0) if the segment is unusable. - */ - exn = (s.unusable != 0); -diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c -index 961acc788f44..91a9e6af2ec4 100644 ---- a/drivers/ata/libata-eh.c -+++ b/drivers/ata/libata-eh.c -@@ -606,7 +606,7 @@ void ata_scsi_error(struct Scsi_Host *host) - ata_scsi_port_error_handler(host, ap); - - /* finish or retry handled scmd's and clean up */ -- WARN_ON(host->host_failed || !list_empty(&eh_work_q)); -+ WARN_ON(!list_empty(&eh_work_q)); - - DPRINTK("EXIT\n"); - } -diff --git a/drivers/base/module.c b/drivers/base/module.c -index db930d3ee312..2a215780eda2 100644 ---- a/drivers/base/module.c -+++ b/drivers/base/module.c -@@ -24,10 +24,12 @@ static char *make_driver_name(struct device_driver *drv) - - static void module_create_drivers_dir(struct module_kobject *mk) - { -- if (!mk || mk->drivers_dir) -- return; -+ static DEFINE_MUTEX(drivers_dir_mutex); - -- mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj); -+ mutex_lock(&drivers_dir_mutex); -+ if (mk && !mk->drivers_dir) -+ mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj); -+ mutex_unlock(&drivers_dir_mutex); - } - - void module_add_driver(struct module *mod, struct device_driver *drv) -diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c -index e3536da05c88..a084a4751fa9 100644 ---- a/drivers/char/ipmi/ipmi_msghandler.c -+++ b/drivers/char/ipmi/ipmi_msghandler.c -@@ -3819,6 +3819,7 @@ static void handle_new_recv_msgs(ipmi_smi_t intf) - while (!list_empty(&intf->waiting_rcv_msgs)) { - smi_msg = list_entry(intf->waiting_rcv_msgs.next, - struct ipmi_smi_msg, link); -+ list_del(&smi_msg->link); - if (!run_to_completion) - spin_unlock_irqrestore(&intf->waiting_rcv_msgs_lock, - flags); -@@ -3828,11 +3829,14 @@ static void handle_new_recv_msgs(ipmi_smi_t intf) - if (rv > 0) { - /* - * To preserve message order, quit if we -- * can't handle a message. -+ * can't handle a message. Add the message -+ * back at the head, this is safe because this -+ * tasklet is the only thing that pulls the -+ * messages. - */ -+ list_add(&smi_msg->link, &intf->waiting_rcv_msgs); - break; - } else { -- list_del(&smi_msg->link); - if (rv == 0) - /* Message handled */ - ipmi_free_smi_msg(smi_msg); -diff --git a/drivers/crypto/qat/qat_common/Makefile b/drivers/crypto/qat/qat_common/Makefile -index 9e9e196c6d51..45b5adaafa6f 100644 ---- a/drivers/crypto/qat/qat_common/Makefile -+++ b/drivers/crypto/qat/qat_common/Makefile -@@ -2,6 +2,7 @@ $(obj)/qat_rsapubkey-asn1.o: $(obj)/qat_rsapubkey-asn1.c \ - $(obj)/qat_rsapubkey-asn1.h - $(obj)/qat_rsaprivkey-asn1.o: $(obj)/qat_rsaprivkey-asn1.c \ - $(obj)/qat_rsaprivkey-asn1.h -+$(obj)/qat_asym_algs.o: $(obj)/qat_rsapubkey-asn1.h $(obj)/qat_rsaprivkey-asn1.h - - clean-files += qat_rsapubkey-asn1.c qat_rsapubkey-asn1.h - clean-files += qat_rsaprivkey-asn1.c qat_rsapvivkey-asn1.h -diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c -index 37649221f81c..ca64b174f8a3 100644 ---- a/drivers/edac/sb_edac.c -+++ b/drivers/edac/sb_edac.c -@@ -218,8 +218,11 @@ static const u32 rir_offset[MAX_RIR_RANGES][MAX_RIR_WAY] = { - { 0x1a0, 0x1a4, 0x1a8, 0x1ac, 0x1b0, 0x1b4, 0x1b8, 0x1bc }, - }; - --#define RIR_RNK_TGT(reg) GET_BITFIELD(reg, 16, 19) --#define RIR_OFFSET(reg) GET_BITFIELD(reg, 2, 14) -+#define RIR_RNK_TGT(type, reg) (((type) == BROADWELL) ? \ -+ GET_BITFIELD(reg, 20, 23) : GET_BITFIELD(reg, 16, 19)) -+ -+#define RIR_OFFSET(type, reg) (((type) == HASWELL || (type) == BROADWELL) ? \ -+ GET_BITFIELD(reg, 2, 15) : GET_BITFIELD(reg, 2, 14)) - - /* Device 16, functions 2-7 */ - -@@ -1175,14 +1178,14 @@ static void get_memory_layout(const struct mem_ctl_info *mci) - pci_read_config_dword(pvt->pci_tad[i], - rir_offset[j][k], - ®); -- tmp_mb = RIR_OFFSET(reg) << 6; -+ tmp_mb = RIR_OFFSET(pvt->info.type, reg) << 6; - - gb = div_u64_rem(tmp_mb, 1024, &mb); - edac_dbg(0, "CH#%d RIR#%d INTL#%d, offset %u.%03u GB (0x%016Lx), tgt: %d, reg=0x%08x\n", - i, j, k, - gb, (mb*1000)/1024, - ((u64)tmp_mb) << 20L, -- (u32)RIR_RNK_TGT(reg), -+ (u32)RIR_RNK_TGT(pvt->info.type, reg), - reg); - } - } -@@ -1512,7 +1515,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci, - pci_read_config_dword(pvt->pci_tad[ch_add + base_ch], - rir_offset[n_rir][idx], - ®); -- *rank = RIR_RNK_TGT(reg); -+ *rank = RIR_RNK_TGT(pvt->info.type, reg); - - edac_dbg(0, "RIR#%d: channel address 0x%08Lx < 0x%08Lx, RIR interleave %d, index %d\n", - n_rir, -diff --git a/drivers/gpio/gpiolib-legacy.c b/drivers/gpio/gpiolib-legacy.c -index 3a5c7011ad3b..8b830996fe02 100644 ---- a/drivers/gpio/gpiolib-legacy.c -+++ b/drivers/gpio/gpiolib-legacy.c -@@ -28,6 +28,10 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) - if (!desc && gpio_is_valid(gpio)) - return -EPROBE_DEFER; - -+ err = gpiod_request(desc, label); -+ if (err) -+ return err; -+ - if (flags & GPIOF_OPEN_DRAIN) - set_bit(FLAG_OPEN_DRAIN, &desc->flags); - -@@ -37,10 +41,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) - if (flags & GPIOF_ACTIVE_LOW) - set_bit(FLAG_ACTIVE_LOW, &desc->flags); - -- err = gpiod_request(desc, label); -- if (err) -- return err; -- - if (flags & GPIOF_DIR_IN) - err = gpiod_direction_input(desc); - else -diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c -index 4e4c3083ae56..06d345b087f8 100644 ---- a/drivers/gpio/gpiolib.c -+++ b/drivers/gpio/gpiolib.c -@@ -927,14 +927,6 @@ static int __gpiod_request(struct gpio_desc *desc, const char *label) - spin_lock_irqsave(&gpio_lock, flags); - } - done: -- if (status < 0) { -- /* Clear flags that might have been set by the caller before -- * requesting the GPIO. -- */ -- clear_bit(FLAG_ACTIVE_LOW, &desc->flags); -- clear_bit(FLAG_OPEN_DRAIN, &desc->flags); -- clear_bit(FLAG_OPEN_SOURCE, &desc->flags); -- } - spin_unlock_irqrestore(&gpio_lock, flags); - return status; - } -@@ -2062,28 +2054,13 @@ struct gpio_desc *__must_check gpiod_get_optional(struct device *dev, - } - EXPORT_SYMBOL_GPL(gpiod_get_optional); - --/** -- * gpiod_parse_flags - helper function to parse GPIO lookup flags -- * @desc: gpio to be setup -- * @lflags: gpio_lookup_flags - returned from of_find_gpio() or -- * of_get_gpio_hog() -- * -- * Set the GPIO descriptor flags based on the given GPIO lookup flags. -- */ --static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags) --{ -- if (lflags & GPIO_ACTIVE_LOW) -- set_bit(FLAG_ACTIVE_LOW, &desc->flags); -- if (lflags & GPIO_OPEN_DRAIN) -- set_bit(FLAG_OPEN_DRAIN, &desc->flags); -- if (lflags & GPIO_OPEN_SOURCE) -- set_bit(FLAG_OPEN_SOURCE, &desc->flags); --} - - /** - * gpiod_configure_flags - helper function to configure a given GPIO - * @desc: gpio whose value will be assigned - * @con_id: function within the GPIO consumer -+ * @lflags: gpio_lookup_flags - returned from of_find_gpio() or -+ * of_get_gpio_hog() - * @dflags: gpiod_flags - optional GPIO initialization flags - * - * Return 0 on success, -ENOENT if no GPIO has been assigned to the -@@ -2091,10 +2068,17 @@ static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags) - * occurred while trying to acquire the GPIO. - */ - static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, -- enum gpiod_flags dflags) -+ unsigned long lflags, enum gpiod_flags dflags) - { - int status; - -+ if (lflags & GPIO_ACTIVE_LOW) -+ set_bit(FLAG_ACTIVE_LOW, &desc->flags); -+ if (lflags & GPIO_OPEN_DRAIN) -+ set_bit(FLAG_OPEN_DRAIN, &desc->flags); -+ if (lflags & GPIO_OPEN_SOURCE) -+ set_bit(FLAG_OPEN_SOURCE, &desc->flags); -+ - /* No particular flag request, return here... */ - if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) { - pr_debug("no flags found for %s\n", con_id); -@@ -2161,13 +2145,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, - return desc; - } - -- gpiod_parse_flags(desc, lookupflags); -- - status = gpiod_request(desc, con_id); - if (status < 0) - return ERR_PTR(status); - -- status = gpiod_configure_flags(desc, con_id, flags); -+ status = gpiod_configure_flags(desc, con_id, lookupflags, flags); - if (status < 0) { - dev_dbg(dev, "setup of GPIO %s failed\n", con_id); - gpiod_put(desc); -@@ -2223,6 +2205,10 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, - if (IS_ERR(desc)) - return desc; - -+ ret = gpiod_request(desc, NULL); -+ if (ret) -+ return ERR_PTR(ret); -+ - if (active_low) - set_bit(FLAG_ACTIVE_LOW, &desc->flags); - -@@ -2233,10 +2219,6 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, - set_bit(FLAG_OPEN_SOURCE, &desc->flags); - } - -- ret = gpiod_request(desc, NULL); -- if (ret) -- return ERR_PTR(ret); -- - return desc; - } - EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod); -@@ -2289,8 +2271,6 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, - chip = gpiod_to_chip(desc); - hwnum = gpio_chip_hwgpio(desc); - -- gpiod_parse_flags(desc, lflags); -- - local_desc = gpiochip_request_own_desc(chip, hwnum, name); - if (IS_ERR(local_desc)) { - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n", -@@ -2298,7 +2278,7 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, - return PTR_ERR(local_desc); - } - -- status = gpiod_configure_flags(desc, name, dflags); -+ status = gpiod_configure_flags(desc, name, lflags, dflags); - if (status < 0) { - pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n", - name, chip->label, hwnum); -diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -index 946300764609..b57fffc2d4af 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -@@ -5463,7 +5463,7 @@ static int gfx_v7_0_eop_irq(struct amdgpu_device *adev, - case 2: - for (i = 0; i < adev->gfx.num_compute_rings; i++) { - ring = &adev->gfx.compute_ring[i]; -- if ((ring->me == me_id) & (ring->pipe == pipe_id)) -+ if ((ring->me == me_id) && (ring->pipe == pipe_id)) - amdgpu_fence_process(ring); - } - break; -diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c -index 9be007081b72..eb1da83c9902 100644 ---- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c -+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c -@@ -242,13 +242,19 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn, - pqm_uninit(&p->pqm); - - /* Iterate over all process device data structure and check -- * if we should reset all wavefronts */ -- list_for_each_entry(pdd, &p->per_device_data, per_device_list) -+ * if we should delete debug managers and reset all wavefronts -+ */ -+ list_for_each_entry(pdd, &p->per_device_data, per_device_list) { -+ if ((pdd->dev->dbgmgr) && -+ (pdd->dev->dbgmgr->pasid == p->pasid)) -+ kfd_dbgmgr_destroy(pdd->dev->dbgmgr); -+ - if (pdd->reset_wavefronts) { - pr_warn("amdkfd: Resetting all wave fronts\n"); - dbgdev_wave_reset_wavefronts(pdd->dev, p); - pdd->reset_wavefronts = false; - } -+ } - - mutex_unlock(&p->mutex); - -@@ -404,42 +410,52 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid) - - idx = srcu_read_lock(&kfd_processes_srcu); - -+ /* -+ * Look for the process that matches the pasid. If there is no such -+ * process, we either released it in amdkfd's own notifier, or there -+ * is a bug. Unfortunately, there is no way to tell... -+ */ - hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes) -- if (p->pasid == pasid) -- break; -+ if (p->pasid == pasid) { - -- srcu_read_unlock(&kfd_processes_srcu, idx); -+ srcu_read_unlock(&kfd_processes_srcu, idx); - -- BUG_ON(p->pasid != pasid); -+ pr_debug("Unbinding process %d from IOMMU\n", pasid); - -- mutex_lock(&p->mutex); -+ mutex_lock(&p->mutex); - -- if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid)) -- kfd_dbgmgr_destroy(dev->dbgmgr); -+ if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid)) -+ kfd_dbgmgr_destroy(dev->dbgmgr); - -- pqm_uninit(&p->pqm); -+ pqm_uninit(&p->pqm); - -- pdd = kfd_get_process_device_data(dev, p); -+ pdd = kfd_get_process_device_data(dev, p); - -- if (!pdd) { -- mutex_unlock(&p->mutex); -- return; -- } -+ if (!pdd) { -+ mutex_unlock(&p->mutex); -+ return; -+ } - -- if (pdd->reset_wavefronts) { -- dbgdev_wave_reset_wavefronts(pdd->dev, p); -- pdd->reset_wavefronts = false; -- } -+ if (pdd->reset_wavefronts) { -+ dbgdev_wave_reset_wavefronts(pdd->dev, p); -+ pdd->reset_wavefronts = false; -+ } - -- /* -- * Just mark pdd as unbound, because we still need it to call -- * amd_iommu_unbind_pasid() in when the process exits. -- * We don't call amd_iommu_unbind_pasid() here -- * because the IOMMU called us. -- */ -- pdd->bound = false; -+ /* -+ * Just mark pdd as unbound, because we still need it -+ * to call amd_iommu_unbind_pasid() in when the -+ * process exits. -+ * We don't call amd_iommu_unbind_pasid() here -+ * because the IOMMU called us. -+ */ -+ pdd->bound = false; - -- mutex_unlock(&p->mutex); -+ mutex_unlock(&p->mutex); -+ -+ return; -+ } -+ -+ srcu_read_unlock(&kfd_processes_srcu, idx); - } - - struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p) -diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -index d0299aed517e..59d1269626b1 100644 ---- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -@@ -335,6 +335,8 @@ atmel_hlcdc_plane_update_pos_and_size(struct atmel_hlcdc_plane *plane, - - atmel_hlcdc_layer_update_cfg(&plane->layer, 13, 0xffffffff, - factor_reg); -+ } else { -+ atmel_hlcdc_layer_update_cfg(&plane->layer, 13, 0xffffffff, 0); - } - } - -diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c -index aed2e3f8a1a2..6253775b8d9c 100644 ---- a/drivers/gpu/drm/drm_atomic.c -+++ b/drivers/gpu/drm/drm_atomic.c -@@ -367,6 +367,8 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state, - drm_property_unreference_blob(state->mode_blob); - state->mode_blob = NULL; - -+ memset(&state->mode, 0, sizeof(state->mode)); -+ - if (blob) { - if (blob->length != sizeof(struct drm_mode_modeinfo) || - drm_mode_convert_umode(&state->mode, -@@ -379,7 +381,6 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state, - DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n", - state->mode.name, state); - } else { -- memset(&state->mode, 0, sizeof(state->mode)); - state->enable = false; - DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n", - state); -diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c -index a02238c85e18..dc84003f694e 100644 ---- a/drivers/gpu/drm/drm_crtc.c -+++ b/drivers/gpu/drm/drm_crtc.c -@@ -2682,8 +2682,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, - goto out; - } - -- drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); -- - /* - * Check whether the primary plane supports the fb pixel format. - * Drivers not implementing the universal planes API use a -diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c -index d268bf18a662..2485fb652716 100644 ---- a/drivers/gpu/drm/drm_dp_mst_topology.c -+++ b/drivers/gpu/drm/drm_dp_mst_topology.c -@@ -2874,11 +2874,9 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) - drm_dp_port_teardown_pdt(port, port->pdt); - - if (!port->input && port->vcpi.vcpi > 0) { -- if (mgr->mst_state) { -- drm_dp_mst_reset_vcpi_slots(mgr, port); -- drm_dp_update_payload_part1(mgr); -- drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi); -- } -+ drm_dp_mst_reset_vcpi_slots(mgr, port); -+ drm_dp_update_payload_part1(mgr); -+ drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi); - } - - kref_put(&port->kref, drm_dp_free_mst_port); -diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c -index cd74a0953f42..39e30abddf08 100644 ---- a/drivers/gpu/drm/drm_modes.c -+++ b/drivers/gpu/drm/drm_modes.c -@@ -1487,6 +1487,8 @@ int drm_mode_convert_umode(struct drm_display_mode *out, - if (out->status != MODE_OK) - goto out; - -+ drm_mode_set_crtcinfo(out, CRTC_INTERLACE_HALVE_V); -+ - ret = 0; - - out: -diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c -index f7df54a8ee2b..c0a96f1ee18e 100644 ---- a/drivers/gpu/drm/i915/i915_gem_shrinker.c -+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c -@@ -39,7 +39,7 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task) - if (!mutex_is_locked(mutex)) - return false; - --#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES) -+#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER) - return mutex->owner == task; - #else - /* Since UP may be pre-empted, we cannot assume that we own the lock */ -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h -index 7e461dca564c..9ed9f6dde86f 100644 ---- a/drivers/gpu/drm/i915/i915_reg.h -+++ b/drivers/gpu/drm/i915/i915_reg.h -@@ -7357,6 +7357,8 @@ enum skl_disp_power_wells { - #define TRANS_CLK_SEL_DISABLED (0x0<<29) - #define TRANS_CLK_SEL_PORT(x) (((x)+1)<<29) - -+#define CDCLK_FREQ 0x46200 -+ - #define TRANSA_MSA_MISC 0x60410 - #define TRANSB_MSA_MISC 0x61410 - #define TRANSC_MSA_MISC 0x62410 -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c -index afa81691163d..c41bc42b6fa7 100644 ---- a/drivers/gpu/drm/i915/intel_display.c -+++ b/drivers/gpu/drm/i915/intel_display.c -@@ -8228,12 +8228,14 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) - { - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_encoder *encoder; -+ int i; - u32 val, final; - bool has_lvds = false; - bool has_cpu_edp = false; - bool has_panel = false; - bool has_ck505 = false; - bool can_ssc = false; -+ bool using_ssc_source = false; - - /* We need to take the global config into account */ - for_each_intel_encoder(dev, encoder) { -@@ -8260,8 +8262,22 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) - can_ssc = true; - } - -- DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d\n", -- has_panel, has_lvds, has_ck505); -+ /* Check if any DPLLs are using the SSC source */ -+ for (i = 0; i < dev_priv->num_shared_dpll; i++) { -+ u32 temp = I915_READ(PCH_DPLL(i)); -+ -+ if (!(temp & DPLL_VCO_ENABLE)) -+ continue; -+ -+ if ((temp & PLL_REF_INPUT_MASK) == -+ PLLB_REF_INPUT_SPREADSPECTRUMIN) { -+ using_ssc_source = true; -+ break; -+ } -+ } -+ -+ DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d using_ssc_source %d\n", -+ has_panel, has_lvds, has_ck505, using_ssc_source); - - /* Ironlake: try to setup display ref clock before DPLL - * enabling. This is only under driver's control after -@@ -8298,9 +8314,9 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) - final |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; - } else - final |= DREF_CPU_SOURCE_OUTPUT_DISABLE; -- } else { -- final |= DREF_SSC_SOURCE_DISABLE; -- final |= DREF_CPU_SOURCE_OUTPUT_DISABLE; -+ } else if (using_ssc_source) { -+ final |= DREF_SSC_SOURCE_ENABLE; -+ final |= DREF_SSC1_ENABLE; - } - - if (final == val) -@@ -8346,7 +8362,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) - POSTING_READ(PCH_DREF_CONTROL); - udelay(200); - } else { -- DRM_DEBUG_KMS("Disabling SSC entirely\n"); -+ DRM_DEBUG_KMS("Disabling CPU source output\n"); - - val &= ~DREF_CPU_SOURCE_OUTPUT_MASK; - -@@ -8357,16 +8373,20 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) - POSTING_READ(PCH_DREF_CONTROL); - udelay(200); - -- /* Turn off the SSC source */ -- val &= ~DREF_SSC_SOURCE_MASK; -- val |= DREF_SSC_SOURCE_DISABLE; -+ if (!using_ssc_source) { -+ DRM_DEBUG_KMS("Disabling SSC source\n"); - -- /* Turn off SSC1 */ -- val &= ~DREF_SSC1_ENABLE; -+ /* Turn off the SSC source */ -+ val &= ~DREF_SSC_SOURCE_MASK; -+ val |= DREF_SSC_SOURCE_DISABLE; - -- I915_WRITE(PCH_DREF_CONTROL, val); -- POSTING_READ(PCH_DREF_CONTROL); -- udelay(200); -+ /* Turn off SSC1 */ -+ val &= ~DREF_SSC1_ENABLE; -+ -+ I915_WRITE(PCH_DREF_CONTROL, val); -+ POSTING_READ(PCH_DREF_CONTROL); -+ udelay(200); -+ } - } - - BUG_ON(val != final); -@@ -9669,6 +9689,8 @@ static void broadwell_set_cdclk(struct drm_device *dev, int cdclk) - sandybridge_pcode_write(dev_priv, HSW_PCODE_DE_WRITE_FREQ_REQ, data); - mutex_unlock(&dev_priv->rps.hw_lock); - -+ I915_WRITE(CDCLK_FREQ, DIV_ROUND_CLOSEST(cdclk, 1000) - 1); -+ - intel_update_cdclk(dev); - - WARN(cdclk != dev_priv->cdclk_freq, -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c -index e55a82a99e7f..8e1d6d74c203 100644 ---- a/drivers/gpu/drm/i915/intel_dp.c -+++ b/drivers/gpu/drm/i915/intel_dp.c -@@ -3628,8 +3628,7 @@ static bool - intel_dp_reset_link_train(struct intel_dp *intel_dp, uint32_t *DP, - uint8_t dp_train_pat) - { -- if (!intel_dp->train_set_valid) -- memset(intel_dp->train_set, 0, sizeof(intel_dp->train_set)); -+ memset(intel_dp->train_set, 0, sizeof(intel_dp->train_set)); - intel_dp_set_signal_levels(intel_dp, DP); - return intel_dp_set_link_train(intel_dp, DP, dp_train_pat); - } -@@ -3746,22 +3745,6 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp) - break; - } - -- /* -- * if we used previously trained voltage and pre-emphasis values -- * and we don't get clock recovery, reset link training values -- */ -- if (intel_dp->train_set_valid) { -- DRM_DEBUG_KMS("clock recovery not ok, reset"); -- /* clear the flag as we are not reusing train set */ -- intel_dp->train_set_valid = false; -- if (!intel_dp_reset_link_train(intel_dp, &DP, -- DP_TRAINING_PATTERN_1 | -- DP_LINK_SCRAMBLING_DISABLE)) { -- DRM_ERROR("failed to enable link training\n"); -- return; -- } -- continue; -- } - - /* Check to see if we've tried the max voltage */ - for (i = 0; i < intel_dp->lane_count; i++) -@@ -3854,7 +3837,6 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp) - /* Make sure clock is still ok */ - if (!drm_dp_clock_recovery_ok(link_status, - intel_dp->lane_count)) { -- intel_dp->train_set_valid = false; - intel_dp_link_training_clock_recovery(intel_dp); - intel_dp_set_link_train(intel_dp, &DP, - training_pattern | -@@ -3871,7 +3853,6 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp) - - /* Try 5 times, then try clock recovery if that fails */ - if (tries > 5) { -- intel_dp->train_set_valid = false; - intel_dp_link_training_clock_recovery(intel_dp); - intel_dp_set_link_train(intel_dp, &DP, - training_pattern | -@@ -3893,10 +3874,8 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp) - - intel_dp->DP = DP; - -- if (channel_eq) { -- intel_dp->train_set_valid = true; -+ if (channel_eq) - DRM_DEBUG_KMS("Channel EQ done. DP Training successful\n"); -- } - } - - void intel_dp_stop_link_train(struct intel_dp *intel_dp) -@@ -5079,13 +5058,15 @@ static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp) - - void intel_dp_encoder_reset(struct drm_encoder *encoder) - { -- struct intel_dp *intel_dp; -+ struct drm_i915_private *dev_priv = to_i915(encoder->dev); -+ struct intel_dp *intel_dp = enc_to_intel_dp(encoder); -+ -+ if (!HAS_DDI(dev_priv)) -+ intel_dp->DP = I915_READ(intel_dp->output_reg); - - if (to_intel_encoder(encoder)->type != INTEL_OUTPUT_EDP) - return; - -- intel_dp = enc_to_intel_dp(encoder); -- - pps_lock(intel_dp); - - /* -@@ -5157,9 +5138,6 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) - intel_display_power_get(dev_priv, power_domain); - - if (long_hpd) { -- /* indicate that we need to restart link training */ -- intel_dp->train_set_valid = false; -- - if (!intel_digital_port_connected(dev_priv, intel_dig_port)) - goto mst_fail; - -diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h -index f34a219ec5c4..c5f11e0c5d5b 100644 ---- a/drivers/gpu/drm/i915/intel_drv.h -+++ b/drivers/gpu/drm/i915/intel_drv.h -@@ -783,7 +783,6 @@ struct intel_dp { - bool has_aux_irq, - int send_bytes, - uint32_t aux_clock_divider); -- bool train_set_valid; - - /* Displayport compliance testing */ - unsigned long compliance_test_type; -diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c -index c99d3fe12881..e5bb40e58020 100644 ---- a/drivers/gpu/drm/mgag200/mgag200_mode.c -+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c -@@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock) - } - } - -- fvv = pllreffreq * testn / testm; -+ fvv = pllreffreq * (n + 1) / (m + 1); - fvv = (fvv - 800000) / 50000; - - if (fvv > 15) -@@ -214,6 +214,14 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock) - WREG_DAC(MGA1064_PIX_PLLC_M, m); - WREG_DAC(MGA1064_PIX_PLLC_N, n); - WREG_DAC(MGA1064_PIX_PLLC_P, p); -+ -+ if (mdev->unique_rev_id >= 0x04) { -+ WREG_DAC(0x1a, 0x09); -+ msleep(20); -+ WREG_DAC(0x1a, 0x01); -+ -+ } -+ - return 0; - } - -diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c -index 59f27e774acb..e40a1b07a014 100644 ---- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c -@@ -557,6 +557,8 @@ nouveau_fbcon_init(struct drm_device *dev) - if (ret) - goto fini; - -+ if (fbcon->helper.fbdev) -+ fbcon->helper.fbdev->pixmap.buf_align = 4; - return 0; - - fini: -diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c -index 789dc2993b0d..8f715feadf56 100644 ---- a/drivers/gpu/drm/nouveau/nv04_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c -@@ -82,7 +82,6 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - uint32_t fg; - uint32_t bg; - uint32_t dsize; -- uint32_t width; - uint32_t *data = (uint32_t *)image->data; - int ret; - -@@ -93,9 +92,6 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - if (ret) - return ret; - -- width = ALIGN(image->width, 8); -- dsize = ALIGN(width * image->height, 32) >> 5; -- - if (info->fix.visual == FB_VISUAL_TRUECOLOR || - info->fix.visual == FB_VISUAL_DIRECTCOLOR) { - fg = ((uint32_t *) info->pseudo_palette)[image->fg_color]; -@@ -111,10 +107,11 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - ((image->dx + image->width) & 0xffff)); - OUT_RING(chan, bg); - OUT_RING(chan, fg); -- OUT_RING(chan, (image->height << 16) | width); -+ OUT_RING(chan, (image->height << 16) | image->width); - OUT_RING(chan, (image->height << 16) | image->width); - OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); - -+ dsize = ALIGN(image->width * image->height, 32) >> 5; - while (dsize) { - int iter_len = dsize > 128 ? 128 : dsize; - -diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c -index e05499d6ed83..a4e259a00430 100644 ---- a/drivers/gpu/drm/nouveau/nv50_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c -@@ -95,7 +95,7 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - struct nouveau_fbdev *nfbdev = info->par; - struct nouveau_drm *drm = nouveau_drm(nfbdev->dev); - struct nouveau_channel *chan = drm->channel; -- uint32_t width, dwords, *data = (uint32_t *)image->data; -+ uint32_t dwords, *data = (uint32_t *)image->data; - uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel)); - uint32_t *palette = info->pseudo_palette; - int ret; -@@ -107,9 +107,6 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - if (ret) - return ret; - -- width = ALIGN(image->width, 32); -- dwords = (width * image->height) >> 5; -- - BEGIN_NV04(chan, NvSub2D, 0x0814, 2); - if (info->fix.visual == FB_VISUAL_TRUECOLOR || - info->fix.visual == FB_VISUAL_DIRECTCOLOR) { -@@ -128,6 +125,7 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - OUT_RING(chan, 0); - OUT_RING(chan, image->dy); - -+ dwords = ALIGN(image->width * image->height, 32) >> 5; - while (dwords) { - int push = dwords > 2047 ? 2047 : dwords; - -diff --git a/drivers/gpu/drm/nouveau/nvc0_fbcon.c b/drivers/gpu/drm/nouveau/nvc0_fbcon.c -index c97395b4a312..f28315e865a5 100644 ---- a/drivers/gpu/drm/nouveau/nvc0_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nvc0_fbcon.c -@@ -95,7 +95,7 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - struct nouveau_fbdev *nfbdev = info->par; - struct nouveau_drm *drm = nouveau_drm(nfbdev->dev); - struct nouveau_channel *chan = drm->channel; -- uint32_t width, dwords, *data = (uint32_t *)image->data; -+ uint32_t dwords, *data = (uint32_t *)image->data; - uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel)); - uint32_t *palette = info->pseudo_palette; - int ret; -@@ -107,9 +107,6 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - if (ret) - return ret; - -- width = ALIGN(image->width, 32); -- dwords = (width * image->height) >> 5; -- - BEGIN_NVC0(chan, NvSub2D, 0x0814, 2); - if (info->fix.visual == FB_VISUAL_TRUECOLOR || - info->fix.visual == FB_VISUAL_DIRECTCOLOR) { -@@ -128,6 +125,7 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - OUT_RING (chan, 0); - OUT_RING (chan, image->dy); - -+ dwords = ALIGN(image->width * image->height, 32) >> 5; - while (dwords) { - int push = dwords > 2047 ? 2047 : dwords; - -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c -index b4b41b135643..2aaf0dd19a55 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c -@@ -40,8 +40,8 @@ static int - gf119_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern) - { - struct nvkm_device *device = outp->base.disp->engine.subdev.device; -- const u32 loff = gf119_sor_loff(outp); -- nvkm_mask(device, 0x61c110 + loff, 0x0f0f0f0f, 0x01010101 * pattern); -+ const u32 soff = gf119_sor_soff(outp); -+ nvkm_mask(device, 0x61c110 + soff, 0x0f0f0f0f, 0x01010101 * pattern); - return 0; - } - -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c -index 36655a74c538..eeeea1c2ca23 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c -@@ -874,22 +874,41 @@ gf100_gr_trap_gpc_rop(struct gf100_gr *gr, int gpc) - } - - static const struct nvkm_enum gf100_mp_warp_error[] = { -- { 0x00, "NO_ERROR" }, -- { 0x01, "STACK_MISMATCH" }, -+ { 0x01, "STACK_ERROR" }, -+ { 0x02, "API_STACK_ERROR" }, -+ { 0x03, "RET_EMPTY_STACK_ERROR" }, -+ { 0x04, "PC_WRAP" }, - { 0x05, "MISALIGNED_PC" }, -- { 0x08, "MISALIGNED_GPR" }, -- { 0x09, "INVALID_OPCODE" }, -- { 0x0d, "GPR_OUT_OF_BOUNDS" }, -- { 0x0e, "MEM_OUT_OF_BOUNDS" }, -- { 0x0f, "UNALIGNED_MEM_ACCESS" }, -+ { 0x06, "PC_OVERFLOW" }, -+ { 0x07, "MISALIGNED_IMMC_ADDR" }, -+ { 0x08, "MISALIGNED_REG" }, -+ { 0x09, "ILLEGAL_INSTR_ENCODING" }, -+ { 0x0a, "ILLEGAL_SPH_INSTR_COMBO" }, -+ { 0x0b, "ILLEGAL_INSTR_PARAM" }, -+ { 0x0c, "INVALID_CONST_ADDR" }, -+ { 0x0d, "OOR_REG" }, -+ { 0x0e, "OOR_ADDR" }, -+ { 0x0f, "MISALIGNED_ADDR" }, - { 0x10, "INVALID_ADDR_SPACE" }, -- { 0x11, "INVALID_PARAM" }, -+ { 0x11, "ILLEGAL_INSTR_PARAM2" }, -+ { 0x12, "INVALID_CONST_ADDR_LDC" }, -+ { 0x13, "GEOMETRY_SM_ERROR" }, -+ { 0x14, "DIVERGENT" }, -+ { 0x15, "WARP_EXIT" }, - {} - }; - - static const struct nvkm_bitfield gf100_mp_global_error[] = { -+ { 0x00000001, "SM_TO_SM_FAULT" }, -+ { 0x00000002, "L1_ERROR" }, - { 0x00000004, "MULTIPLE_WARP_ERRORS" }, -- { 0x00000008, "OUT_OF_STACK_SPACE" }, -+ { 0x00000008, "PHYSICAL_STACK_OVERFLOW" }, -+ { 0x00000010, "BPT_INT" }, -+ { 0x00000020, "BPT_PAUSE" }, -+ { 0x00000040, "SINGLE_STEP_COMPLETE" }, -+ { 0x20000000, "ECC_SEC_ERROR" }, -+ { 0x40000000, "ECC_DED_ERROR" }, -+ { 0x80000000, "TIMEOUT" }, - {} - }; - -diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c -index c566993a2ec3..e2dd5d19c32c 100644 ---- a/drivers/gpu/drm/radeon/radeon_device.c -+++ b/drivers/gpu/drm/radeon/radeon_device.c -@@ -630,6 +630,23 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) - /* - * GPU helpers function. - */ -+ -+/** -+ * radeon_device_is_virtual - check if we are running is a virtual environment -+ * -+ * Check if the asic has been passed through to a VM (all asics). -+ * Used at driver startup. -+ * Returns true if virtual or false if not. -+ */ -+static bool radeon_device_is_virtual(void) -+{ -+#ifdef CONFIG_X86 -+ return boot_cpu_has(X86_FEATURE_HYPERVISOR); -+#else -+ return false; -+#endif -+} -+ - /** - * radeon_card_posted - check if the hw has already been initialized - * -@@ -643,6 +660,10 @@ bool radeon_card_posted(struct radeon_device *rdev) - { - uint32_t reg; - -+ /* for pass through, always force asic_init */ -+ if (radeon_device_is_virtual()) -+ return false; -+ - /* required for EFI mode on macbook2,1 which uses an r5xx asic */ - if (efi_enabled(EFI_BOOT) && - (rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) && -diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c -index 745e996d2dbc..4ae8b56b1847 100644 ---- a/drivers/gpu/drm/ttm/ttm_bo.c -+++ b/drivers/gpu/drm/ttm/ttm_bo.c -@@ -1004,9 +1004,9 @@ out_unlock: - return ret; - } - --static bool ttm_bo_mem_compat(struct ttm_placement *placement, -- struct ttm_mem_reg *mem, -- uint32_t *new_flags) -+bool ttm_bo_mem_compat(struct ttm_placement *placement, -+ struct ttm_mem_reg *mem, -+ uint32_t *new_flags) - { - int i; - -@@ -1038,6 +1038,7 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement, - - return false; - } -+EXPORT_SYMBOL(ttm_bo_mem_compat); - - int ttm_bo_validate(struct ttm_buffer_object *bo, - struct ttm_placement *placement, -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c -index 299925a1f6c6..eadc981ee79a 100644 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c -@@ -49,6 +49,7 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv, - { - struct ttm_buffer_object *bo = &buf->base; - int ret; -+ uint32_t new_flags; - - ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible); - if (unlikely(ret != 0)) -@@ -60,7 +61,12 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv, - if (unlikely(ret != 0)) - goto err; - -- ret = ttm_bo_validate(bo, placement, interruptible, false); -+ if (buf->pin_count > 0) -+ ret = ttm_bo_mem_compat(placement, &bo->mem, -+ &new_flags) == true ? 0 : -EINVAL; -+ else -+ ret = ttm_bo_validate(bo, placement, interruptible, false); -+ - if (!ret) - vmw_bo_pin_reserved(buf, true); - -@@ -91,6 +97,7 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv, - { - struct ttm_buffer_object *bo = &buf->base; - int ret; -+ uint32_t new_flags; - - ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible); - if (unlikely(ret != 0)) -@@ -102,6 +109,12 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv, - if (unlikely(ret != 0)) - goto err; - -+ if (buf->pin_count > 0) { -+ ret = ttm_bo_mem_compat(&vmw_vram_gmr_placement, &bo->mem, -+ &new_flags) == true ? 0 : -EINVAL; -+ goto out_unreserve; -+ } -+ - ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible, - false); - if (likely(ret == 0) || ret == -ERESTARTSYS) -@@ -161,6 +174,7 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv, - struct ttm_placement placement; - struct ttm_place place; - int ret = 0; -+ uint32_t new_flags; - - place = vmw_vram_placement.placement[0]; - place.lpfn = bo->num_pages; -@@ -185,10 +199,15 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv, - */ - if (bo->mem.mem_type == TTM_PL_VRAM && - bo->mem.start < bo->num_pages && -- bo->mem.start > 0) -+ bo->mem.start > 0 && -+ buf->pin_count == 0) - (void) ttm_bo_validate(bo, &vmw_sys_placement, false, false); - -- ret = ttm_bo_validate(bo, &placement, interruptible, false); -+ if (buf->pin_count > 0) -+ ret = ttm_bo_mem_compat(&placement, &bo->mem, -+ &new_flags) == true ? 0 : -EINVAL; -+ else -+ ret = ttm_bo_validate(bo, &placement, interruptible, false); - - /* For some reason we didn't end up at the start of vram */ - WARN_ON(ret == 0 && bo->offset != 0); -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c -index 24fb348a44e1..f3f31f995878 100644 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c -@@ -227,6 +227,7 @@ static int vmw_force_iommu; - static int vmw_restrict_iommu; - static int vmw_force_coherent; - static int vmw_restrict_dma_mask; -+static int vmw_assume_16bpp; - - static int vmw_probe(struct pci_dev *, const struct pci_device_id *); - static void vmw_master_init(struct vmw_master *); -@@ -243,6 +244,8 @@ MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages"); - module_param_named(force_coherent, vmw_force_coherent, int, 0600); - MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU"); - module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600); -+MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes"); -+module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600); - - - static void vmw_print_capabilities(uint32_t capabilities) -@@ -652,6 +655,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) - dev_priv->vram_start = pci_resource_start(dev->pdev, 1); - dev_priv->mmio_start = pci_resource_start(dev->pdev, 2); - -+ dev_priv->assume_16bpp = !!vmw_assume_16bpp; -+ - dev_priv->enable_fb = enable_fbdev; - - vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2); -@@ -698,6 +703,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) - vmw_read(dev_priv, - SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB); - -+ /* -+ * Workaround for low memory 2D VMs to compensate for the -+ * allocation taken by fbdev -+ */ -+ if (!(dev_priv->capabilities & SVGA_CAP_3D)) -+ mem_size *= 2; -+ - dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE; - dev_priv->prim_bb_mem = - vmw_read(dev_priv, -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h -index 469cdd520615..2e94fe27b3f6 100644 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h -@@ -387,6 +387,7 @@ struct vmw_private { - spinlock_t hw_lock; - spinlock_t cap_lock; - bool has_dx; -+ bool assume_16bpp; - - /* - * VGA registers. -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c -index 679a4cb98ee3..d2d93959b119 100644 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c -@@ -517,28 +517,6 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info) - - par->set_fb = &vfb->base; - -- if (!par->bo_ptr) { -- /* -- * Pin before mapping. Since we don't know in what placement -- * to pin, call into KMS to do it for us. -- */ -- ret = vfb->pin(vfb); -- if (ret) { -- DRM_ERROR("Could not pin the fbdev framebuffer.\n"); -- return ret; -- } -- -- ret = ttm_bo_kmap(&par->vmw_bo->base, 0, -- par->vmw_bo->base.num_pages, &par->map); -- if (ret) { -- vfb->unpin(vfb); -- DRM_ERROR("Could not map the fbdev framebuffer.\n"); -- return ret; -- } -- -- par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite); -- } -- - return 0; - } - -@@ -601,6 +579,31 @@ static int vmw_fb_set_par(struct fb_info *info) - if (ret) - goto out_unlock; - -+ if (!par->bo_ptr) { -+ struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(set.fb); -+ -+ /* -+ * Pin before mapping. Since we don't know in what placement -+ * to pin, call into KMS to do it for us. -+ */ -+ ret = vfb->pin(vfb); -+ if (ret) { -+ DRM_ERROR("Could not pin the fbdev framebuffer.\n"); -+ goto out_unlock; -+ } -+ -+ ret = ttm_bo_kmap(&par->vmw_bo->base, 0, -+ par->vmw_bo->base.num_pages, &par->map); -+ if (ret) { -+ vfb->unpin(vfb); -+ DRM_ERROR("Could not map the fbdev framebuffer.\n"); -+ goto out_unlock; -+ } -+ -+ par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite); -+ } -+ -+ - vmw_fb_dirty_mark(par, par->fb_x, par->fb_y, - par->set_fb->width, par->set_fb->height); - -diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c -index 7c2e118a77b0..060e5c6f4446 100644 ---- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c -+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c -@@ -1538,14 +1538,10 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) - }; - int i; -- u32 assumed_bpp = 2; -+ u32 assumed_bpp = 4; - -- /* -- * If using screen objects, then assume 32-bpp because that's what the -- * SVGA device is assuming -- */ -- if (dev_priv->active_display_unit == vmw_du_screen_object) -- assumed_bpp = 4; -+ if (dev_priv->assume_16bpp) -+ assumed_bpp = 2; - - if (dev_priv->active_display_unit == vmw_du_screen_target) { - max_width = min(max_width, dev_priv->stdu_max_width); -diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c -index aad8c162a825..0cd4f7216239 100644 ---- a/drivers/hid/hid-elo.c -+++ b/drivers/hid/hid-elo.c -@@ -261,7 +261,7 @@ static void elo_remove(struct hid_device *hdev) - struct elo_priv *priv = hid_get_drvdata(hdev); - - hid_hw_stop(hdev); -- flush_workqueue(wq); -+ cancel_delayed_work_sync(&priv->work); - kfree(priv); - } - -diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c -index c5ec4f915594..f62a9d6601cc 100644 ---- a/drivers/hid/hid-multitouch.c -+++ b/drivers/hid/hid-multitouch.c -@@ -61,6 +61,7 @@ MODULE_LICENSE("GPL"); - #define MT_QUIRK_ALWAYS_VALID (1 << 4) - #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) - #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) -+#define MT_QUIRK_CONFIDENCE (1 << 7) - #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) - #define MT_QUIRK_NO_AREA (1 << 9) - #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) -@@ -78,6 +79,7 @@ struct mt_slot { - __s32 contactid; /* the device ContactID assigned to this slot */ - bool touch_state; /* is the touch valid? */ - bool inrange_state; /* is the finger in proximity of the sensor? */ -+ bool confidence_state; /* is the touch made by a finger? */ - }; - - struct mt_class { -@@ -502,6 +504,9 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, - mt_store_field(usage, td, hi); - return 1; - case HID_DG_CONFIDENCE: -+ if (cls->name == MT_CLS_WIN_8 && -+ field->application == HID_DG_TOUCHPAD) -+ cls->quirks |= MT_QUIRK_CONFIDENCE; - mt_store_field(usage, td, hi); - return 1; - case HID_DG_TIPSWITCH: -@@ -614,6 +619,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) - return; - - if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { -+ int active; - int slotnum = mt_compute_slot(td, input); - struct mt_slot *s = &td->curdata; - struct input_mt *mt = input->mt; -@@ -628,10 +634,14 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) - return; - } - -+ if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE)) -+ s->confidence_state = 1; -+ active = (s->touch_state || s->inrange_state) && -+ s->confidence_state; -+ - input_mt_slot(input, slotnum); -- input_mt_report_slot_state(input, MT_TOOL_FINGER, -- s->touch_state || s->inrange_state); -- if (s->touch_state || s->inrange_state) { -+ input_mt_report_slot_state(input, MT_TOOL_FINGER, active); -+ if (active) { - /* this finger is in proximity of the sensor */ - int wide = (s->w > s->h); - /* divided by two to match visual scale of touch */ -@@ -696,6 +706,8 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, - td->curdata.touch_state = value; - break; - case HID_DG_CONFIDENCE: -+ if (quirks & MT_QUIRK_CONFIDENCE) -+ td->curdata.confidence_state = value; - if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) - td->curvalid = value; - break; -diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c -index 2f1ddca6f2e0..700145b15088 100644 ---- a/drivers/hid/usbhid/hiddev.c -+++ b/drivers/hid/usbhid/hiddev.c -@@ -516,13 +516,13 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, - goto inval; - } else if (uref->usage_index >= field->report_count) - goto inval; -- -- else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) && -- (uref_multi->num_values > HID_MAX_MULTI_USAGES || -- uref->usage_index + uref_multi->num_values > field->report_count)) -- goto inval; - } - -+ if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) && -+ (uref_multi->num_values > HID_MAX_MULTI_USAGES || -+ uref->usage_index + uref_multi->num_values > field->report_count)) -+ goto inval; -+ - switch (cmd) { - case HIDIOCGUSAGE: - uref->value = field->value[uref->usage_index]; -diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c -index c43318d3416e..a9356a3dea92 100644 ---- a/drivers/hwmon/dell-smm-hwmon.c -+++ b/drivers/hwmon/dell-smm-hwmon.c -@@ -66,11 +66,13 @@ - - static DEFINE_MUTEX(i8k_mutex); - static char bios_version[4]; -+static char bios_machineid[16]; - static struct device *i8k_hwmon_dev; - static u32 i8k_hwmon_flags; - static uint i8k_fan_mult = I8K_FAN_MULT; - static uint i8k_pwm_mult; - static uint i8k_fan_max = I8K_FAN_HIGH; -+static bool disallow_fan_type_call; - - #define I8K_HWMON_HAVE_TEMP1 (1 << 0) - #define I8K_HWMON_HAVE_TEMP2 (1 << 1) -@@ -94,13 +96,13 @@ module_param(ignore_dmi, bool, 0); - MODULE_PARM_DESC(ignore_dmi, "Continue probing hardware even if DMI data does not match"); - - #if IS_ENABLED(CONFIG_I8K) --static bool restricted; -+static bool restricted = true; - module_param(restricted, bool, 0); --MODULE_PARM_DESC(restricted, "Allow fan control if SYS_ADMIN capability set"); -+MODULE_PARM_DESC(restricted, "Restrict fan control and serial number to CAP_SYS_ADMIN (default: 1)"); - - static bool power_status; - module_param(power_status, bool, 0600); --MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); -+MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k (default: 0)"); - #endif - - static uint fan_mult; -@@ -235,14 +237,28 @@ static int i8k_get_fan_speed(int fan) - /* - * Read the fan type. - */ --static int i8k_get_fan_type(int fan) -+static int _i8k_get_fan_type(int fan) - { - struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; - -+ if (disallow_fan_type_call) -+ return -EINVAL; -+ - regs.ebx = fan & 0xff; - return i8k_smm(®s) ? : regs.eax & 0xff; - } - -+static int i8k_get_fan_type(int fan) -+{ -+ /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */ -+ static int types[2] = { INT_MIN, INT_MIN }; -+ -+ if (types[fan] == INT_MIN) -+ types[fan] = _i8k_get_fan_type(fan); -+ -+ return types[fan]; -+} -+ - /* - * Read the fan nominal rpm for specific fan speed. - */ -@@ -392,9 +408,11 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) - break; - - case I8K_MACHINE_ID: -- memset(buff, 0, 16); -- strlcpy(buff, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), -- sizeof(buff)); -+ if (restricted && !capable(CAP_SYS_ADMIN)) -+ return -EPERM; -+ -+ memset(buff, 0, sizeof(buff)); -+ strlcpy(buff, bios_machineid, sizeof(buff)); - break; - - case I8K_FN_STATUS: -@@ -511,7 +529,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset) - seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n", - I8K_PROC_FMT, - bios_version, -- i8k_get_dmi_data(DMI_PRODUCT_SERIAL), -+ (restricted && !capable(CAP_SYS_ADMIN)) ? "-1" : bios_machineid, - cpu_temp, - left_fan, right_fan, left_speed, right_speed, - ac_power, fn_key); -@@ -718,6 +736,9 @@ static struct attribute *i8k_attrs[] = { - static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, - int index) - { -+ if (disallow_fan_type_call && -+ (index == 9 || index == 12)) -+ return 0; - if (index >= 0 && index <= 1 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) - return 0; -@@ -767,13 +788,17 @@ static int __init i8k_init_hwmon(void) - if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4; - -- /* First fan attributes, if fan type is OK */ -- err = i8k_get_fan_type(0); -+ /* First fan attributes, if fan status or type is OK */ -+ err = i8k_get_fan_status(0); -+ if (err < 0) -+ err = i8k_get_fan_type(0); - if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1; - -- /* Second fan attributes, if fan type is OK */ -- err = i8k_get_fan_type(1); -+ /* Second fan attributes, if fan status or type is OK */ -+ err = i8k_get_fan_status(1); -+ if (err < 0) -+ err = i8k_get_fan_type(1); - if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2; - -@@ -929,12 +954,14 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { - - MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); - --static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { -+/* -+ * On some machines once I8K_SMM_GET_FAN_TYPE is issued then CPU fan speed -+ * randomly going up and down due to bug in Dell SMM or BIOS. Here is blacklist -+ * of affected Dell machines for which we disallow I8K_SMM_GET_FAN_TYPE call. -+ * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=100121 -+ */ -+static struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initdata = { - { -- /* -- * CPU fan speed going up and down on Dell Studio XPS 8000 -- * for unknown reasons. -- */ - .ident = "Dell Studio XPS 8000", - .matches = { - DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -@@ -942,16 +969,19 @@ static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { - }, - }, - { -- /* -- * CPU fan speed going up and down on Dell Studio XPS 8100 -- * for unknown reasons. -- */ - .ident = "Dell Studio XPS 8100", - .matches = { - DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8100"), - }, - }, -+ { -+ .ident = "Dell Inspiron 580", -+ .matches = { -+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Inspiron 580 "), -+ }, -+ }, - { } - }; - -@@ -966,8 +996,7 @@ static int __init i8k_probe(void) - /* - * Get DMI information - */ -- if (!dmi_check_system(i8k_dmi_table) || -- dmi_check_system(i8k_blacklist_dmi_table)) { -+ if (!dmi_check_system(i8k_dmi_table)) { - if (!ignore_dmi && !force) - return -ENODEV; - -@@ -978,8 +1007,13 @@ static int __init i8k_probe(void) - i8k_get_dmi_data(DMI_BIOS_VERSION)); - } - -+ if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) -+ disallow_fan_type_call = true; -+ - strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), - sizeof(bios_version)); -+ strlcpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), -+ sizeof(bios_machineid)); - - /* - * Get SMM Dell signature -diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c -index 923f56598d4b..3a9f106787d2 100644 ---- a/drivers/iio/accel/kxsd9.c -+++ b/drivers/iio/accel/kxsd9.c -@@ -81,7 +81,7 @@ static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro) - - mutex_lock(&st->buf_lock); - ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); -- if (ret) -+ if (ret < 0) - goto error_ret; - st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C); - st->tx[1] = (ret & ~KXSD9_FS_MASK) | i; -@@ -163,7 +163,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, - break; - case IIO_CHAN_INFO_SCALE: - ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); -- if (ret) -+ if (ret < 0) - goto error_ret; - *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; - ret = IIO_VAL_INT_PLUS_MICRO; -diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c -index 21e19b60e2b9..2123f0ac2e2a 100644 ---- a/drivers/iio/adc/ad7266.c -+++ b/drivers/iio/adc/ad7266.c -@@ -396,8 +396,8 @@ static int ad7266_probe(struct spi_device *spi) - - st = iio_priv(indio_dev); - -- st->reg = devm_regulator_get(&spi->dev, "vref"); -- if (!IS_ERR_OR_NULL(st->reg)) { -+ st->reg = devm_regulator_get_optional(&spi->dev, "vref"); -+ if (!IS_ERR(st->reg)) { - ret = regulator_enable(st->reg); - if (ret) - return ret; -@@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_device *spi) - - st->vref_mv = ret / 1000; - } else { -+ /* Any other error indicates that the regulator does exist */ -+ if (PTR_ERR(st->reg) != -ENODEV) -+ return PTR_ERR(st->reg); - /* Use internal reference */ - st->vref_mv = 2500; - } -diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c -index a7f61e881a49..dc5e7e70f951 100644 ---- a/drivers/iio/humidity/hdc100x.c -+++ b/drivers/iio/humidity/hdc100x.c -@@ -55,7 +55,7 @@ static const struct { - }, - { /* IIO_HUMIDITYRELATIVE channel */ - .shift = 8, -- .mask = 2, -+ .mask = 3, - }, - }; - -@@ -164,14 +164,14 @@ static int hdc100x_get_measurement(struct hdc100x_data *data, - dev_err(&client->dev, "cannot read high byte measurement"); - return ret; - } -- val = ret << 6; -+ val = ret << 8; - - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(&client->dev, "cannot read low byte measurement"); - return ret; - } -- val |= ret >> 2; -+ val |= ret; - - return val; - } -@@ -211,18 +211,18 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev, - return IIO_VAL_INT_PLUS_MICRO; - case IIO_CHAN_INFO_SCALE: - if (chan->type == IIO_TEMP) { -- *val = 165; -- *val2 = 65536 >> 2; -+ *val = 165000; -+ *val2 = 65536; - return IIO_VAL_FRACTIONAL; - } else { -- *val = 0; -- *val2 = 10000; -- return IIO_VAL_INT_PLUS_MICRO; -+ *val = 100; -+ *val2 = 65536; -+ return IIO_VAL_FRACTIONAL; - } - break; - case IIO_CHAN_INFO_OFFSET: -- *val = -3971; -- *val2 = 879096; -+ *val = -15887; -+ *val2 = 515151; - return IIO_VAL_INT_PLUS_MICRO; - default: - return -EINVAL; -diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c -index ae2806aafb72..0c52dfe64977 100644 ---- a/drivers/iio/industrialio-trigger.c -+++ b/drivers/iio/industrialio-trigger.c -@@ -210,22 +210,35 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig, - - /* Prevent the module from being removed whilst attached to a trigger */ - __module_get(pf->indio_dev->info->driver_module); -+ -+ /* Get irq number */ - pf->irq = iio_trigger_get_irq(trig); -+ if (pf->irq < 0) -+ goto out_put_module; -+ -+ /* Request irq */ - ret = request_threaded_irq(pf->irq, pf->h, pf->thread, - pf->type, pf->name, - pf); -- if (ret < 0) { -- module_put(pf->indio_dev->info->driver_module); -- return ret; -- } -+ if (ret < 0) -+ goto out_put_irq; - -+ /* Enable trigger in driver */ - if (trig->ops && trig->ops->set_trigger_state && notinuse) { - ret = trig->ops->set_trigger_state(trig, true); - if (ret < 0) -- module_put(pf->indio_dev->info->driver_module); -+ goto out_free_irq; - } - - return ret; -+ -+out_free_irq: -+ free_irq(pf->irq, pf); -+out_put_irq: -+ iio_trigger_put_irq(trig, pf->irq); -+out_put_module: -+ module_put(pf->indio_dev->info->driver_module); -+ return ret; - } - - static int iio_trigger_detach_poll_func(struct iio_trigger *trig, -diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c -index f6a07dc32ae4..4a6d9670e4cd 100644 ---- a/drivers/iio/light/apds9960.c -+++ b/drivers/iio/light/apds9960.c -@@ -1005,6 +1005,7 @@ static int apds9960_probe(struct i2c_client *client, - - iio_device_attach_buffer(indio_dev, buffer); - -+ indio_dev->dev.parent = &client->dev; - indio_dev->info = &apds9960_info; - indio_dev->name = APDS9960_DRV_NAME; - indio_dev->channels = apds9960_channels; -diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c -index b39a2fb0671c..5056bd68573f 100644 ---- a/drivers/iio/pressure/st_pressure_core.c -+++ b/drivers/iio/pressure/st_pressure_core.c -@@ -28,15 +28,21 @@ - #include - #include "st_pressure.h" - -+#define MCELSIUS_PER_CELSIUS 1000 -+ -+/* Default pressure sensitivity */ - #define ST_PRESS_LSB_PER_MBAR 4096UL - #define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \ - ST_PRESS_LSB_PER_MBAR) -+ -+/* Default temperature sensitivity */ - #define ST_PRESS_LSB_PER_CELSIUS 480UL --#define ST_PRESS_CELSIUS_NANO_SCALE (1000000000UL / \ -- ST_PRESS_LSB_PER_CELSIUS) -+#define ST_PRESS_MILLI_CELSIUS_OFFSET 42500UL -+ - #define ST_PRESS_NUMBER_DATA_CHANNELS 1 - - /* FULLSCALE */ -+#define ST_PRESS_FS_AVL_1100MB 1100 - #define ST_PRESS_FS_AVL_1260MB 1260 - - #define ST_PRESS_1_OUT_XL_ADDR 0x28 -@@ -54,18 +60,20 @@ - #define ST_PRESS_LPS331AP_PW_MASK 0x80 - #define ST_PRESS_LPS331AP_FS_ADDR 0x23 - #define ST_PRESS_LPS331AP_FS_MASK 0x30 --#define ST_PRESS_LPS331AP_FS_AVL_1260_VAL 0x00 --#define ST_PRESS_LPS331AP_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE --#define ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE - #define ST_PRESS_LPS331AP_BDU_ADDR 0x20 - #define ST_PRESS_LPS331AP_BDU_MASK 0x04 - #define ST_PRESS_LPS331AP_DRDY_IRQ_ADDR 0x22 - #define ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK 0x04 - #define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20 - #define ST_PRESS_LPS331AP_MULTIREAD_BIT true --#define ST_PRESS_LPS331AP_TEMP_OFFSET 42500 - - /* CUSTOM VALUES FOR LPS001WP SENSOR */ -+ -+/* LPS001WP pressure resolution */ -+#define ST_PRESS_LPS001WP_LSB_PER_MBAR 16UL -+/* LPS001WP temperature resolution */ -+#define ST_PRESS_LPS001WP_LSB_PER_CELSIUS 64UL -+ - #define ST_PRESS_LPS001WP_WAI_EXP 0xba - #define ST_PRESS_LPS001WP_ODR_ADDR 0x20 - #define ST_PRESS_LPS001WP_ODR_MASK 0x30 -@@ -74,6 +82,8 @@ - #define ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL 0x03 - #define ST_PRESS_LPS001WP_PW_ADDR 0x20 - #define ST_PRESS_LPS001WP_PW_MASK 0x40 -+#define ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN \ -+ (100000000UL / ST_PRESS_LPS001WP_LSB_PER_MBAR) - #define ST_PRESS_LPS001WP_BDU_ADDR 0x20 - #define ST_PRESS_LPS001WP_BDU_MASK 0x04 - #define ST_PRESS_LPS001WP_MULTIREAD_BIT true -@@ -90,18 +100,12 @@ - #define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04 - #define ST_PRESS_LPS25H_PW_ADDR 0x20 - #define ST_PRESS_LPS25H_PW_MASK 0x80 --#define ST_PRESS_LPS25H_FS_ADDR 0x00 --#define ST_PRESS_LPS25H_FS_MASK 0x00 --#define ST_PRESS_LPS25H_FS_AVL_1260_VAL 0x00 --#define ST_PRESS_LPS25H_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE --#define ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE - #define ST_PRESS_LPS25H_BDU_ADDR 0x20 - #define ST_PRESS_LPS25H_BDU_MASK 0x04 - #define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23 - #define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01 - #define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10 - #define ST_PRESS_LPS25H_MULTIREAD_BIT true --#define ST_PRESS_LPS25H_TEMP_OFFSET 42500 - #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28 - #define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b - -@@ -153,7 +157,9 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { - .storagebits = 16, - .endianness = IIO_LE, - }, -- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), -+ .info_mask_separate = -+ BIT(IIO_CHAN_INFO_RAW) | -+ BIT(IIO_CHAN_INFO_SCALE), - .modified = 0, - }, - { -@@ -169,7 +175,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { - }, - .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | -- BIT(IIO_CHAN_INFO_OFFSET), -+ BIT(IIO_CHAN_INFO_SCALE), - .modified = 0, - }, - IIO_CHAN_SOFT_TIMESTAMP(1) -@@ -204,11 +210,14 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { - .addr = ST_PRESS_LPS331AP_FS_ADDR, - .mask = ST_PRESS_LPS331AP_FS_MASK, - .fs_avl = { -+ /* -+ * Pressure and temperature sensitivity values -+ * as defined in table 3 of LPS331AP datasheet. -+ */ - [0] = { - .num = ST_PRESS_FS_AVL_1260MB, -- .value = ST_PRESS_LPS331AP_FS_AVL_1260_VAL, -- .gain = ST_PRESS_LPS331AP_FS_AVL_1260_GAIN, -- .gain2 = ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN, -+ .gain = ST_PRESS_KPASCAL_NANO_SCALE, -+ .gain2 = ST_PRESS_LSB_PER_CELSIUS, - }, - }, - }, -@@ -248,7 +257,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { - .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, - }, - .fs = { -- .addr = 0, -+ .fs_avl = { -+ /* -+ * Pressure and temperature resolution values -+ * as defined in table 3 of LPS001WP datasheet. -+ */ -+ [0] = { -+ .num = ST_PRESS_FS_AVL_1100MB, -+ .gain = ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN, -+ .gain2 = ST_PRESS_LPS001WP_LSB_PER_CELSIUS, -+ }, -+ }, - }, - .bdu = { - .addr = ST_PRESS_LPS001WP_BDU_ADDR, -@@ -285,14 +304,15 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { - .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, - }, - .fs = { -- .addr = ST_PRESS_LPS25H_FS_ADDR, -- .mask = ST_PRESS_LPS25H_FS_MASK, - .fs_avl = { -+ /* -+ * Pressure and temperature sensitivity values -+ * as defined in table 3 of LPS25H datasheet. -+ */ - [0] = { - .num = ST_PRESS_FS_AVL_1260MB, -- .value = ST_PRESS_LPS25H_FS_AVL_1260_VAL, -- .gain = ST_PRESS_LPS25H_FS_AVL_1260_GAIN, -- .gain2 = ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN, -+ .gain = ST_PRESS_KPASCAL_NANO_SCALE, -+ .gain2 = ST_PRESS_LSB_PER_CELSIUS, - }, - }, - }, -@@ -346,26 +366,26 @@ static int st_press_read_raw(struct iio_dev *indio_dev, - - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: -- *val = 0; -- - switch (ch->type) { - case IIO_PRESSURE: -+ *val = 0; - *val2 = press_data->current_fullscale->gain; -- break; -+ return IIO_VAL_INT_PLUS_NANO; - case IIO_TEMP: -+ *val = MCELSIUS_PER_CELSIUS; - *val2 = press_data->current_fullscale->gain2; -- break; -+ return IIO_VAL_FRACTIONAL; - default: - err = -EINVAL; - goto read_error; - } - -- return IIO_VAL_INT_PLUS_NANO; - case IIO_CHAN_INFO_OFFSET: - switch (ch->type) { - case IIO_TEMP: -- *val = 425; -- *val2 = 10; -+ *val = ST_PRESS_MILLI_CELSIUS_OFFSET * -+ press_data->current_fullscale->gain2; -+ *val2 = MCELSIUS_PER_CELSIUS; - break; - default: - err = -EINVAL; -diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c -index f4d29d5dbd5f..e2f926cdcad2 100644 ---- a/drivers/iio/proximity/as3935.c -+++ b/drivers/iio/proximity/as3935.c -@@ -64,6 +64,7 @@ struct as3935_state { - struct delayed_work work; - - u32 tune_cap; -+ u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */ - u8 buf[2] ____cacheline_aligned; - }; - -@@ -72,7 +73,8 @@ static const struct iio_chan_spec as3935_channels[] = { - .type = IIO_PROXIMITY, - .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | -- BIT(IIO_CHAN_INFO_PROCESSED), -+ BIT(IIO_CHAN_INFO_PROCESSED) | -+ BIT(IIO_CHAN_INFO_SCALE), - .scan_index = 0, - .scan_type = { - .sign = 'u', -@@ -181,7 +183,12 @@ static int as3935_read_raw(struct iio_dev *indio_dev, - /* storm out of range */ - if (*val == AS3935_DATA_MASK) - return -EINVAL; -- *val *= 1000; -+ -+ if (m == IIO_CHAN_INFO_PROCESSED) -+ *val *= 1000; -+ break; -+ case IIO_CHAN_INFO_SCALE: -+ *val = 1000; - break; - default: - return -EINVAL; -@@ -206,10 +213,10 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) - ret = as3935_read(st, AS3935_DATA, &val); - if (ret) - goto err_read; -- val &= AS3935_DATA_MASK; -- val *= 1000; - -- iio_push_to_buffers_with_timestamp(indio_dev, &val, pf->timestamp); -+ st->buffer[0] = val & AS3935_DATA_MASK; -+ iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, -+ pf->timestamp); - err_read: - iio_trigger_notify_done(indio_dev->trig); - -diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c -index d6d2b3582910..4d8e7f18a9af 100644 ---- a/drivers/infiniband/core/cm.c -+++ b/drivers/infiniband/core/cm.c -@@ -3430,14 +3430,14 @@ static int cm_establish(struct ib_cm_id *cm_id) - work->cm_event.event = IB_CM_USER_ESTABLISHED; - - /* Check if the device started its remove_one */ -- spin_lock_irq(&cm.lock); -+ spin_lock_irqsave(&cm.lock, flags); - if (!cm_dev->going_down) { - queue_delayed_work(cm.wq, &work->work, 0); - } else { - kfree(work); - ret = -ENODEV; - } -- spin_unlock_irq(&cm.lock); -+ spin_unlock_irqrestore(&cm.lock, flags); - - out: - return ret; -diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c -index 86af71351d9a..06da56bda201 100644 ---- a/drivers/infiniband/hw/mlx4/ah.c -+++ b/drivers/infiniband/hw/mlx4/ah.c -@@ -47,6 +47,7 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr, - - ah->av.ib.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24)); - ah->av.ib.g_slid = ah_attr->src_path_bits; -+ ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28); - if (ah_attr->ah_flags & IB_AH_GRH) { - ah->av.ib.g_slid |= 0x80; - ah->av.ib.gid_index = ah_attr->grh.sgid_index; -@@ -64,7 +65,6 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr, - !(1 << ah->av.ib.stat_rate & dev->caps.stat_rate_support)) - --ah->av.ib.stat_rate; - } -- ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28); - - return &ah->ibah; - } -diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c -index bf4959f4225b..94f1bf772ec9 100644 ---- a/drivers/iommu/amd_iommu_init.c -+++ b/drivers/iommu/amd_iommu_init.c -@@ -1363,13 +1363,23 @@ static int __init amd_iommu_init_pci(void) - break; - } - -+ /* -+ * Order is important here to make sure any unity map requirements are -+ * fulfilled. The unity mappings are created and written to the device -+ * table during the amd_iommu_init_api() call. -+ * -+ * After that we call init_device_table_dma() to make sure any -+ * uninitialized DTE will block DMA, and in the end we flush the caches -+ * of all IOMMUs to make sure the changes to the device table are -+ * active. -+ */ -+ ret = amd_iommu_init_api(); -+ - init_device_table_dma(); - - for_each_iommu(iommu) - iommu_flush_all_caches(iommu); - -- ret = amd_iommu_init_api(); -- - if (!ret) - print_iommu_info(); - -diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c -index 4e5118a4cd30..8487987458a1 100644 ---- a/drivers/iommu/arm-smmu-v3.c -+++ b/drivers/iommu/arm-smmu-v3.c -@@ -1919,6 +1919,7 @@ static struct iommu_ops arm_smmu_ops = { - .detach_dev = arm_smmu_detach_dev, - .map = arm_smmu_map, - .unmap = arm_smmu_unmap, -+ .map_sg = default_iommu_map_sg, - .iova_to_phys = arm_smmu_iova_to_phys, - .add_device = arm_smmu_add_device, - .remove_device = arm_smmu_remove_device, -diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c -index a2e1b7f14df2..6763a4dfed94 100644 ---- a/drivers/iommu/intel-iommu.c -+++ b/drivers/iommu/intel-iommu.c -@@ -3169,11 +3169,6 @@ static int __init init_dmars(void) - } - } - -- iommu_flush_write_buffer(iommu); -- iommu_set_root_entry(iommu); -- iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL); -- iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); -- - if (!ecap_pass_through(iommu->ecap)) - hw_pass_through = 0; - #ifdef CONFIG_INTEL_IOMMU_SVM -@@ -3182,6 +3177,18 @@ static int __init init_dmars(void) - #endif - } - -+ /* -+ * Now that qi is enabled on all iommus, set the root entry and flush -+ * caches. This is required on some Intel X58 chipsets, otherwise the -+ * flush_context function will loop forever and the boot hangs. -+ */ -+ for_each_active_iommu(iommu, drhd) { -+ iommu_flush_write_buffer(iommu); -+ iommu_set_root_entry(iommu); -+ iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL); -+ iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); -+ } -+ - if (iommu_pass_through) - iommu_identity_mapping |= IDENTMAP_ALL; - -diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c -index 2764f43607c1..0e7d16fe84d4 100644 ---- a/drivers/media/usb/uvc/uvc_v4l2.c -+++ b/drivers/media/usb/uvc/uvc_v4l2.c -@@ -1388,47 +1388,44 @@ static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp, - static long uvc_v4l2_compat_ioctl32(struct file *file, - unsigned int cmd, unsigned long arg) - { -+ struct uvc_fh *handle = file->private_data; - union { - struct uvc_xu_control_mapping xmap; - struct uvc_xu_control_query xqry; - } karg; - void __user *up = compat_ptr(arg); -- mm_segment_t old_fs; - long ret; - - switch (cmd) { - case UVCIOC_CTRL_MAP32: -- cmd = UVCIOC_CTRL_MAP; - ret = uvc_v4l2_get_xu_mapping(&karg.xmap, up); -+ if (ret) -+ return ret; -+ ret = uvc_ioctl_ctrl_map(handle->chain, &karg.xmap); -+ if (ret) -+ return ret; -+ ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up); -+ if (ret) -+ return ret; -+ - break; - - case UVCIOC_CTRL_QUERY32: -- cmd = UVCIOC_CTRL_QUERY; - ret = uvc_v4l2_get_xu_query(&karg.xqry, up); -+ if (ret) -+ return ret; -+ ret = uvc_xu_ctrl_query(handle->chain, &karg.xqry); -+ if (ret) -+ return ret; -+ ret = uvc_v4l2_put_xu_query(&karg.xqry, up); -+ if (ret) -+ return ret; - break; - - default: - return -ENOIOCTLCMD; - } - -- old_fs = get_fs(); -- set_fs(KERNEL_DS); -- ret = video_ioctl2(file, cmd, (unsigned long)&karg); -- set_fs(old_fs); -- -- if (ret < 0) -- return ret; -- -- switch (cmd) { -- case UVCIOC_CTRL_MAP: -- ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up); -- break; -- -- case UVCIOC_CTRL_QUERY: -- ret = uvc_v4l2_put_xu_query(&karg.xqry, up); -- break; -- } -- - return ret; - } - #endif -diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c -index 6515dfc2b805..55cba89dbdb8 100644 ---- a/drivers/memory/omap-gpmc.c -+++ b/drivers/memory/omap-gpmc.c -@@ -394,7 +394,7 @@ static void gpmc_cs_bool_timings(int cs, const struct gpmc_bool_timings *p) - gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, - GPMC_CONFIG4_OEEXTRADELAY, p->oe_extra_delay); - gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, -- GPMC_CONFIG4_OEEXTRADELAY, p->we_extra_delay); -+ GPMC_CONFIG4_WEEXTRADELAY, p->we_extra_delay); - gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, - GPMC_CONFIG6_CYCLE2CYCLESAMECSEN, - p->cycle2cyclesamecsen); -diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c -index 96fddb016bf1..4dd0391d2942 100644 ---- a/drivers/mtd/ubi/eba.c -+++ b/drivers/mtd/ubi/eba.c -@@ -575,6 +575,7 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, - int err, idx = vol_id2idx(ubi, vol_id), new_pnum, data_size, tries = 0; - struct ubi_volume *vol = ubi->volumes[idx]; - struct ubi_vid_hdr *vid_hdr; -+ uint32_t crc; - - vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); - if (!vid_hdr) -@@ -599,14 +600,8 @@ retry: - goto out_put; - } - -- vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); -- err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr); -- if (err) { -- up_read(&ubi->fm_eba_sem); -- goto write_error; -- } -+ ubi_assert(vid_hdr->vol_type == UBI_VID_DYNAMIC); - -- data_size = offset + len; - mutex_lock(&ubi->buf_mutex); - memset(ubi->peb_buf + offset, 0xFF, len); - -@@ -621,6 +616,19 @@ retry: - - memcpy(ubi->peb_buf + offset, buf, len); - -+ data_size = offset + len; -+ crc = crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size); -+ vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); -+ vid_hdr->copy_flag = 1; -+ vid_hdr->data_size = cpu_to_be32(data_size); -+ vid_hdr->data_crc = cpu_to_be32(crc); -+ err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr); -+ if (err) { -+ mutex_unlock(&ubi->buf_mutex); -+ up_read(&ubi->fm_eba_sem); -+ goto write_error; -+ } -+ - err = ubi_io_write_data(ubi, ubi->peb_buf, new_pnum, 0, data_size); - if (err) { - mutex_unlock(&ubi->buf_mutex); -diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c -index 8c2bb77db049..a790d5f90b83 100644 ---- a/drivers/net/usb/cdc_ncm.c -+++ b/drivers/net/usb/cdc_ncm.c -@@ -809,6 +809,13 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ - if (cdc_ncm_init(dev)) - goto error2; - -+ /* Some firmwares need a pause here or they will silently fail -+ * to set up the interface properly. This value was decided -+ * empirically on a Sierra Wireless MC7455 running 02.08.02.00 -+ * firmware. -+ */ -+ usleep_range(10000, 20000); -+ - /* configure data interface */ - temp = usb_set_interface(dev->udev, iface_no, data_altsetting); - if (temp) { -diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c -index c00a7daaa4bc..0cd95120bc78 100644 ---- a/drivers/net/wireless/mac80211_hwsim.c -+++ b/drivers/net/wireless/mac80211_hwsim.c -@@ -2723,6 +2723,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, - if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || - !info->attrs[HWSIM_ATTR_FLAGS] || - !info->attrs[HWSIM_ATTR_COOKIE] || -+ !info->attrs[HWSIM_ATTR_SIGNAL] || - !info->attrs[HWSIM_ATTR_TX_INFO]) - goto out; - -diff --git a/drivers/of/irq.c b/drivers/of/irq.c -index 72a2c1969646..28da6242eb84 100644 ---- a/drivers/of/irq.c -+++ b/drivers/of/irq.c -@@ -386,13 +386,13 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) - EXPORT_SYMBOL_GPL(of_irq_to_resource); - - /** -- * of_irq_get - Decode a node's IRQ and return it as a Linux irq number -+ * of_irq_get - Decode a node's IRQ and return it as a Linux IRQ number - * @dev: pointer to device tree node -- * @index: zero-based index of the irq -- * -- * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain -- * is not yet created. -+ * @index: zero-based index of the IRQ - * -+ * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or -+ * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case -+ * of any other failure. - */ - int of_irq_get(struct device_node *dev, int index) - { -@@ -413,12 +413,13 @@ int of_irq_get(struct device_node *dev, int index) - EXPORT_SYMBOL_GPL(of_irq_get); - - /** -- * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number -+ * of_irq_get_byname - Decode a node's IRQ and return it as a Linux IRQ number - * @dev: pointer to device tree node -- * @name: irq name -+ * @name: IRQ name - * -- * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain -- * is not yet created, or error code in case of any other failure. -+ * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or -+ * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case -+ * of any other failure. - */ - int of_irq_get_byname(struct device_node *dev, const char *name) - { -diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c -index d4c285688ce9..3ddc85e6efd6 100644 ---- a/drivers/scsi/53c700.c -+++ b/drivers/scsi/53c700.c -@@ -1122,7 +1122,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, - } else { - struct scsi_cmnd *SCp; - -- SCp = scsi_host_find_tag(SDp->host, SCSI_NO_TAG); -+ SCp = SDp->current_cmnd; - if(unlikely(SCp == NULL)) { - sdev_printk(KERN_ERR, SDp, - "no saved request for untagged cmd\n"); -@@ -1826,7 +1826,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) - slot->tag, slot); - } else { - slot->tag = SCSI_NO_TAG; -- /* must populate current_cmnd for scsi_host_find_tag to work */ -+ /* save current command for reselection */ - SCp->device->current_cmnd = SCp; - } - /* sanity check: some of the commands generated by the mid-layer -diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c -index 984ddcb4786d..1b9c049bd5c5 100644 ---- a/drivers/scsi/scsi_error.c -+++ b/drivers/scsi/scsi_error.c -@@ -1127,7 +1127,6 @@ static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn) - */ - void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) - { -- scmd->device->host->host_failed--; - scmd->eh_eflags = 0; - list_move_tail(&scmd->eh_entry, done_q); - } -@@ -2226,6 +2225,9 @@ int scsi_error_handler(void *data) - else - scsi_unjam_host(shost); - -+ /* All scmds have been handled */ -+ shost->host_failed = 0; -+ - /* - * Note - if the above fails completely, the action is to take - * individual devices offline and flush the queue of any -diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c -index 02e930c55570..e4839ee4ca61 100644 ---- a/drivers/staging/iio/accel/sca3000_core.c -+++ b/drivers/staging/iio/accel/sca3000_core.c -@@ -595,7 +595,7 @@ static ssize_t sca3000_read_frequency(struct device *dev, - goto error_ret_mut; - ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL); - mutex_unlock(&st->lock); -- if (ret) -+ if (ret < 0) - goto error_ret; - val = ret; - if (base_freq > 0) -diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c -index 6ceac4f2d4b2..5b4b47ed948b 100644 ---- a/drivers/thermal/cpu_cooling.c -+++ b/drivers/thermal/cpu_cooling.c -@@ -857,14 +857,6 @@ __cpufreq_cooling_register(struct device_node *np, - goto free_power_table; - } - -- snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", -- cpufreq_dev->id); -- -- cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, -- &cpufreq_cooling_ops); -- if (IS_ERR(cool_dev)) -- goto remove_idr; -- - /* Fill freq-table in descending order of frequencies */ - for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) { - freq = find_next_max(table, freq); -@@ -877,6 +869,14 @@ __cpufreq_cooling_register(struct device_node *np, - pr_debug("%s: freq:%u KHz\n", __func__, freq); - } - -+ snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", -+ cpufreq_dev->id); -+ -+ cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, -+ &cpufreq_cooling_ops); -+ if (IS_ERR(cool_dev)) -+ goto remove_idr; -+ - cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; - cpufreq_dev->cool_dev = cool_dev; - -diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c -index 6f0336fff501..41987a55a538 100644 ---- a/drivers/tty/vt/keyboard.c -+++ b/drivers/tty/vt/keyboard.c -@@ -366,34 +366,22 @@ static void to_utf8(struct vc_data *vc, uint c) - - static void do_compute_shiftstate(void) - { -- unsigned int i, j, k, sym, val; -+ unsigned int k, sym, val; - - shift_state = 0; - memset(shift_down, 0, sizeof(shift_down)); - -- for (i = 0; i < ARRAY_SIZE(key_down); i++) { -- -- if (!key_down[i]) -+ for_each_set_bit(k, key_down, min(NR_KEYS, KEY_CNT)) { -+ sym = U(key_maps[0][k]); -+ if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK) - continue; - -- k = i * BITS_PER_LONG; -- -- for (j = 0; j < BITS_PER_LONG; j++, k++) { -- -- if (!test_bit(k, key_down)) -- continue; -+ val = KVAL(sym); -+ if (val == KVAL(K_CAPSSHIFT)) -+ val = KVAL(K_SHIFT); - -- sym = U(key_maps[0][k]); -- if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK) -- continue; -- -- val = KVAL(sym); -- if (val == KVAL(K_CAPSSHIFT)) -- val = KVAL(K_SHIFT); -- -- shift_down[val]++; -- shift_state |= (1 << val); -- } -+ shift_down[val]++; -+ shift_state |= BIT(val); - } - } - -diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c -index cf20282f79f0..136ebaaa9cc0 100644 ---- a/drivers/tty/vt/vt.c -+++ b/drivers/tty/vt/vt.c -@@ -750,6 +750,7 @@ static void visual_init(struct vc_data *vc, int num, int init) - vc->vc_complement_mask = 0; - vc->vc_can_do_color = 0; - vc->vc_panic_force_write = false; -+ vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; - vc->vc_sw->con_init(vc, init); - if (!vc->vc_complement_mask) - vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; -diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c -index 61d538aa2346..4f4f06a5889f 100644 ---- a/drivers/usb/common/usb-otg-fsm.c -+++ b/drivers/usb/common/usb-otg-fsm.c -@@ -21,6 +21,7 @@ - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -+#include - #include - #include - #include -@@ -365,3 +366,4 @@ int otg_statemachine(struct otg_fsm *fsm) - return state_changed; - } - EXPORT_SYMBOL_GPL(otg_statemachine); -+MODULE_LICENSE("GPL"); -diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h -index a66d3cb62b65..a738a68d2292 100644 ---- a/drivers/usb/dwc2/core.h -+++ b/drivers/usb/dwc2/core.h -@@ -44,6 +44,17 @@ - #include - #include "hw.h" - -+#ifdef CONFIG_MIPS -+/* -+ * There are some MIPS machines that can run in either big-endian -+ * or little-endian mode and that use the dwc2 register without -+ * a byteswap in both ways. -+ * Unlike other architectures, MIPS apparently does not require a -+ * barrier before the __raw_writel() to synchronize with DMA but does -+ * require the barrier after the __raw_writel() to serialize a set of -+ * writes. This set of operations was added specifically for MIPS and -+ * should only be used there. -+ */ - static inline u32 dwc2_readl(const void __iomem *addr) - { - u32 value = __raw_readl(addr); -@@ -70,6 +81,22 @@ static inline void dwc2_writel(u32 value, void __iomem *addr) - pr_info("INFO:: wrote %08x to %p\n", value, addr); - #endif - } -+#else -+/* Normal architectures just use readl/write */ -+static inline u32 dwc2_readl(const void __iomem *addr) -+{ -+ return readl(addr); -+} -+ -+static inline void dwc2_writel(u32 value, void __iomem *addr) -+{ -+ writel(value, addr); -+ -+#ifdef DWC2_LOG_WRITES -+ pr_info("info:: wrote %08x to %p\n", value, addr); -+#endif -+} -+#endif - - /* Maximum number of Endpoints/HostChannels */ - #define MAX_EPS_CHANNELS 16 -diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c -index 7d3e5d0e9aa4..8ab6238c9299 100644 ---- a/drivers/virtio/virtio_balloon.c -+++ b/drivers/virtio/virtio_balloon.c -@@ -73,7 +73,7 @@ struct virtio_balloon { - - /* The array of pfns we tell the Host about. */ - unsigned int num_pfns; -- u32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX]; -+ __virtio32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX]; - - /* Memory statistics */ - int need_stats_update; -@@ -125,14 +125,16 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) - wait_event(vb->acked, virtqueue_get_buf(vq, &len)); - } - --static void set_page_pfns(u32 pfns[], struct page *page) -+static void set_page_pfns(struct virtio_balloon *vb, -+ __virtio32 pfns[], struct page *page) - { - unsigned int i; - - /* Set balloon pfns pointing at this page. - * Note that the first pfn points at start of the page. */ - for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++) -- pfns[i] = page_to_balloon_pfn(page) + i; -+ pfns[i] = cpu_to_virtio32(vb->vdev, -+ page_to_balloon_pfn(page) + i); - } - - static void fill_balloon(struct virtio_balloon *vb, size_t num) -@@ -155,7 +157,7 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num) - msleep(200); - break; - } -- set_page_pfns(vb->pfns + vb->num_pfns, page); -+ set_page_pfns(vb, vb->pfns + vb->num_pfns, page); - vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) -@@ -171,10 +173,12 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num) - static void release_pages_balloon(struct virtio_balloon *vb) - { - unsigned int i; -+ struct page *page; - - /* Find pfns pointing at start of each page, get pages and free them. */ - for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) { -- struct page *page = balloon_pfn_to_page(vb->pfns[i]); -+ page = balloon_pfn_to_page(virtio32_to_cpu(vb->vdev, -+ vb->pfns[i])); - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - adjust_managed_page_count(page, 1); -@@ -197,7 +201,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) - page = balloon_page_dequeue(vb_dev_info); - if (!page) - break; -- set_page_pfns(vb->pfns + vb->num_pfns, page); -+ set_page_pfns(vb, vb->pfns + vb->num_pfns, page); - vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE; - } - -@@ -465,13 +469,13 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info, - __count_vm_event(BALLOON_MIGRATE); - spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags); - vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE; -- set_page_pfns(vb->pfns, newpage); -+ set_page_pfns(vb, vb->pfns, newpage); - tell_host(vb, vb->inflate_vq); - - /* balloon's page migration 2nd step -- deflate "page" */ - balloon_page_delete(page); - vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE; -- set_page_pfns(vb->pfns, page); -+ set_page_pfns(vb, vb->pfns, page); - tell_host(vb, vb->deflate_vq); - - mutex_unlock(&vb->balloon_lock); -diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c -index 364bc44610c1..cfab1d24e4bc 100644 ---- a/drivers/xen/balloon.c -+++ b/drivers/xen/balloon.c -@@ -152,8 +152,6 @@ static DECLARE_WAIT_QUEUE_HEAD(balloon_wq); - static void balloon_process(struct work_struct *work); - static DECLARE_DELAYED_WORK(balloon_worker, balloon_process); - --static void release_memory_resource(struct resource *resource); -- - /* When ballooning out (allocating memory to return to Xen) we don't really - want the kernel to try too hard since that can trigger the oom killer. */ - #define GFP_BALLOON \ -@@ -249,6 +247,19 @@ static enum bp_state update_schedule(enum bp_state state) - } - - #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG -+static void release_memory_resource(struct resource *resource) -+{ -+ if (!resource) -+ return; -+ -+ /* -+ * No need to reset region to identity mapped since we now -+ * know that no I/O can be in this region -+ */ -+ release_resource(resource); -+ kfree(resource); -+} -+ - static struct resource *additional_memory_resource(phys_addr_t size) - { - struct resource *res; -@@ -287,19 +298,6 @@ static struct resource *additional_memory_resource(phys_addr_t size) - return res; - } - --static void release_memory_resource(struct resource *resource) --{ -- if (!resource) -- return; -- -- /* -- * No need to reset region to identity mapped since we now -- * know that no I/O can be in this region -- */ -- release_resource(resource); -- kfree(resource); --} -- - static enum bp_state reserve_additional_memory(void) - { - long credit; -diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c -index 70fa438000af..611f9c11da85 100644 ---- a/drivers/xen/xen-acpi-processor.c -+++ b/drivers/xen/xen-acpi-processor.c -@@ -423,36 +423,7 @@ upload: - - return 0; - } --static int __init check_prereq(void) --{ -- struct cpuinfo_x86 *c = &cpu_data(0); -- -- if (!xen_initial_domain()) -- return -ENODEV; -- -- if (!acpi_gbl_FADT.smi_command) -- return -ENODEV; -- -- if (c->x86_vendor == X86_VENDOR_INTEL) { -- if (!cpu_has(c, X86_FEATURE_EST)) -- return -ENODEV; - -- return 0; -- } -- if (c->x86_vendor == X86_VENDOR_AMD) { -- /* Copied from powernow-k8.h, can't include ../cpufreq/powernow -- * as we get compile warnings for the static functions. -- */ --#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 --#define USE_HW_PSTATE 0x00000080 -- u32 eax, ebx, ecx, edx; -- cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); -- if ((edx & USE_HW_PSTATE) != USE_HW_PSTATE) -- return -ENODEV; -- return 0; -- } -- return -ENODEV; --} - /* acpi_perf_data is a pointer to percpu data. */ - static struct acpi_processor_performance __percpu *acpi_perf_data; - -@@ -509,10 +480,10 @@ struct notifier_block xen_acpi_processor_resume_nb = { - static int __init xen_acpi_processor_init(void) - { - unsigned int i; -- int rc = check_prereq(); -+ int rc; - -- if (rc) -- return rc; -+ if (!xen_initial_domain()) -+ return -ENODEV; - - nr_acpi_bits = get_max_acpi_id() + 1; - acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL); -diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c -index 5b8e235c4b6d..0f2b7c622ce3 100644 ---- a/fs/btrfs/ctree.c -+++ b/fs/btrfs/ctree.c -@@ -1551,6 +1551,7 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans, - trans->transid, root->fs_info->generation); - - if (!should_cow_block(trans, root, buf)) { -+ trans->dirty = true; - *cow_ret = buf; - return 0; - } -@@ -2773,8 +2774,10 @@ again: - * then we don't want to set the path blocking, - * so we test it here - */ -- if (!should_cow_block(trans, root, b)) -+ if (!should_cow_block(trans, root, b)) { -+ trans->dirty = true; - goto cow_done; -+ } - - /* - * must have write locks on this node and the -diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c -index 2368cac1115a..47cdc6f3390b 100644 ---- a/fs/btrfs/extent-tree.c -+++ b/fs/btrfs/extent-tree.c -@@ -7856,7 +7856,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, - set_extent_dirty(&trans->transaction->dirty_pages, buf->start, - buf->start + buf->len - 1, GFP_NOFS); - } -- trans->blocks_used++; -+ trans->dirty = true; - /* this returns a buffer locked for blocking */ - return buf; - } -diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c -index fe609b81dd1b..5d34a062ca4f 100644 ---- a/fs/btrfs/super.c -+++ b/fs/btrfs/super.c -@@ -239,7 +239,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, - trans->aborted = errno; - /* Nothing used. The other threads that have joined this - * transaction may be able to continue. */ -- if (!trans->blocks_used && list_empty(&trans->new_bgs)) { -+ if (!trans->dirty && list_empty(&trans->new_bgs)) { - const char *errstr; - - errstr = btrfs_decode_error(errno); -diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h -index 64c8221b6165..1e872923ec2c 100644 ---- a/fs/btrfs/transaction.h -+++ b/fs/btrfs/transaction.h -@@ -110,7 +110,6 @@ struct btrfs_trans_handle { - u64 chunk_bytes_reserved; - unsigned long use_count; - unsigned long blocks_reserved; -- unsigned long blocks_used; - unsigned long delayed_ref_updates; - struct btrfs_transaction *transaction; - struct btrfs_block_rsv *block_rsv; -@@ -121,6 +120,7 @@ struct btrfs_trans_handle { - bool can_flush_pending_bgs; - bool reloc_reserved; - bool sync; -+ bool dirty; - unsigned int type; - /* - * this root is only needed to validate that the root passed to -diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c -index 5a53ac6b1e02..02b071bf3732 100644 ---- a/fs/cifs/cifs_unicode.c -+++ b/fs/cifs/cifs_unicode.c -@@ -101,6 +101,12 @@ convert_sfm_char(const __u16 src_char, char *target) - case SFM_SLASH: - *target = '\\'; - break; -+ case SFM_SPACE: -+ *target = ' '; -+ break; -+ case SFM_PERIOD: -+ *target = '.'; -+ break; - default: - return false; - } -@@ -404,7 +410,7 @@ static __le16 convert_to_sfu_char(char src_char) - return dest_char; - } - --static __le16 convert_to_sfm_char(char src_char) -+static __le16 convert_to_sfm_char(char src_char, bool end_of_string) - { - __le16 dest_char; - -@@ -427,6 +433,18 @@ static __le16 convert_to_sfm_char(char src_char) - case '|': - dest_char = cpu_to_le16(SFM_PIPE); - break; -+ case '.': -+ if (end_of_string) -+ dest_char = cpu_to_le16(SFM_PERIOD); -+ else -+ dest_char = 0; -+ break; -+ case ' ': -+ if (end_of_string) -+ dest_char = cpu_to_le16(SFM_SPACE); -+ else -+ dest_char = 0; -+ break; - default: - dest_char = 0; - } -@@ -469,9 +487,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen, - /* see if we must remap this char */ - if (map_chars == SFU_MAP_UNI_RSVD) - dst_char = convert_to_sfu_char(src_char); -- else if (map_chars == SFM_MAP_UNI_RSVD) -- dst_char = convert_to_sfm_char(src_char); -- else -+ else if (map_chars == SFM_MAP_UNI_RSVD) { -+ bool end_of_string; -+ -+ if (i == srclen - 1) -+ end_of_string = true; -+ else -+ end_of_string = false; -+ -+ dst_char = convert_to_sfm_char(src_char, end_of_string); -+ } else - dst_char = 0; - /* - * FIXME: We can not handle remapping backslash (UNI_SLASH) -diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h -index bdc52cb9a676..479bc0a941f3 100644 ---- a/fs/cifs/cifs_unicode.h -+++ b/fs/cifs/cifs_unicode.h -@@ -64,6 +64,8 @@ - #define SFM_LESSTHAN ((__u16) 0xF023) - #define SFM_PIPE ((__u16) 0xF027) - #define SFM_SLASH ((__u16) 0xF026) -+#define SFM_PERIOD ((__u16) 0xF028) -+#define SFM_SPACE ((__u16) 0xF029) - - /* - * Mapping mechanism to use when one of the seven reserved characters is -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c -index 3c194ff0d2f0..5481a6eb9a95 100644 ---- a/fs/cifs/connect.c -+++ b/fs/cifs/connect.c -@@ -425,7 +425,9 @@ cifs_echo_request(struct work_struct *work) - * server->ops->need_neg() == true. Also, no need to ping if - * we got a response recently. - */ -- if (!server->ops->need_neg || server->ops->need_neg(server) || -+ -+ if (server->tcpStatus == CifsNeedReconnect || -+ server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || - (server->ops->can_echo && !server->ops->can_echo(server)) || - time_before(jiffies, server->lstrp + SMB_ECHO_INTERVAL - HZ)) - goto requeue_echo; -diff --git a/fs/cifs/ntlmssp.h b/fs/cifs/ntlmssp.h -index 848249fa120f..3079b38f0afb 100644 ---- a/fs/cifs/ntlmssp.h -+++ b/fs/cifs/ntlmssp.h -@@ -133,6 +133,6 @@ typedef struct _AUTHENTICATE_MESSAGE { - - int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses); - void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses); --int build_ntlmssp_auth_blob(unsigned char *pbuffer, u16 *buflen, -+int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen, - struct cifs_ses *ses, - const struct nls_table *nls_cp); -diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c -index af0ec2d5ad0e..e88ffe1da045 100644 ---- a/fs/cifs/sess.c -+++ b/fs/cifs/sess.c -@@ -364,19 +364,43 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, - sec_blob->DomainName.MaximumLength = 0; - } - --/* We do not malloc the blob, it is passed in pbuffer, because its -- maximum possible size is fixed and small, making this approach cleaner. -- This function returns the length of the data in the blob */ --int build_ntlmssp_auth_blob(unsigned char *pbuffer, -+static int size_of_ntlmssp_blob(struct cifs_ses *ses) -+{ -+ int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len -+ - CIFS_SESS_KEY_SIZE + CIFS_CPHTXT_SIZE + 2; -+ -+ if (ses->domainName) -+ sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); -+ else -+ sz += 2; -+ -+ if (ses->user_name) -+ sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); -+ else -+ sz += 2; -+ -+ return sz; -+} -+ -+int build_ntlmssp_auth_blob(unsigned char **pbuffer, - u16 *buflen, - struct cifs_ses *ses, - const struct nls_table *nls_cp) - { - int rc; -- AUTHENTICATE_MESSAGE *sec_blob = (AUTHENTICATE_MESSAGE *)pbuffer; -+ AUTHENTICATE_MESSAGE *sec_blob; - __u32 flags; - unsigned char *tmp; - -+ rc = setup_ntlmv2_rsp(ses, nls_cp); -+ if (rc) { -+ cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc); -+ *buflen = 0; -+ goto setup_ntlmv2_ret; -+ } -+ *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); -+ sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer; -+ - memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); - sec_blob->MessageType = NtLmAuthenticate; - -@@ -391,7 +415,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - flags |= NTLMSSP_NEGOTIATE_KEY_XCH; - } - -- tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE); -+ tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); - sec_blob->NegotiateFlags = cpu_to_le32(flags); - - sec_blob->LmChallengeResponse.BufferOffset = -@@ -399,13 +423,9 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - sec_blob->LmChallengeResponse.Length = 0; - sec_blob->LmChallengeResponse.MaximumLength = 0; - -- sec_blob->NtChallengeResponse.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->NtChallengeResponse.BufferOffset = -+ cpu_to_le32(tmp - *pbuffer); - if (ses->user_name != NULL) { -- rc = setup_ntlmv2_rsp(ses, nls_cp); -- if (rc) { -- cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc); -- goto setup_ntlmv2_ret; -- } - memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, - ses->auth_key.len - CIFS_SESS_KEY_SIZE); - tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; -@@ -423,7 +443,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - } - - if (ses->domainName == NULL) { -- sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->DomainName.Length = 0; - sec_blob->DomainName.MaximumLength = 0; - tmp += 2; -@@ -432,14 +452,14 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, - CIFS_MAX_USERNAME_LEN, nls_cp); - len *= 2; /* unicode is 2 bytes each */ -- sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->DomainName.Length = cpu_to_le16(len); - sec_blob->DomainName.MaximumLength = cpu_to_le16(len); - tmp += len; - } - - if (ses->user_name == NULL) { -- sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->UserName.Length = 0; - sec_blob->UserName.MaximumLength = 0; - tmp += 2; -@@ -448,13 +468,13 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, - CIFS_MAX_USERNAME_LEN, nls_cp); - len *= 2; /* unicode is 2 bytes each */ -- sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->UserName.Length = cpu_to_le16(len); - sec_blob->UserName.MaximumLength = cpu_to_le16(len); - tmp += len; - } - -- sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->WorkstationName.Length = 0; - sec_blob->WorkstationName.MaximumLength = 0; - tmp += 2; -@@ -463,19 +483,19 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, - (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) - && !calc_seckey(ses)) { - memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); -- sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); - sec_blob->SessionKey.MaximumLength = - cpu_to_le16(CIFS_CPHTXT_SIZE); - tmp += CIFS_CPHTXT_SIZE; - } else { -- sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer); -+ sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); - sec_blob->SessionKey.Length = 0; - sec_blob->SessionKey.MaximumLength = 0; - } - -+ *buflen = tmp - *pbuffer; - setup_ntlmv2_ret: -- *buflen = tmp - pbuffer; - return rc; - } - -@@ -1266,7 +1286,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data) - struct cifs_ses *ses = sess_data->ses; - __u16 bytes_remaining; - char *bcc_ptr; -- char *ntlmsspblob = NULL; -+ unsigned char *ntlmsspblob = NULL; - u16 blob_len; - - cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n"); -@@ -1279,19 +1299,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data) - /* Build security blob before we assemble the request */ - pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; - smb_buf = (struct smb_hdr *)pSMB; -- /* -- * 5 is an empirical value, large enough to hold -- * authenticate message plus max 10 of av paris, -- * domain, user, workstation names, flags, etc. -- */ -- ntlmsspblob = kzalloc(5*sizeof(struct _AUTHENTICATE_MESSAGE), -- GFP_KERNEL); -- if (!ntlmsspblob) { -- rc = -ENOMEM; -- goto out; -- } -- -- rc = build_ntlmssp_auth_blob(ntlmsspblob, -+ rc = build_ntlmssp_auth_blob(&ntlmsspblob, - &blob_len, ses, sess_data->nls_cp); - if (rc) - goto out_free_ntlmsspblob; -diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c -index 82c5f57382b2..0b6dc1942bdc 100644 ---- a/fs/cifs/smb2pdu.c -+++ b/fs/cifs/smb2pdu.c -@@ -591,7 +591,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, - u16 blob_length = 0; - struct key *spnego_key = NULL; - char *security_blob = NULL; -- char *ntlmssp_blob = NULL; -+ unsigned char *ntlmssp_blob = NULL; - bool use_spnego = false; /* else use raw ntlmssp */ - - cifs_dbg(FYI, "Session Setup\n"); -@@ -716,13 +716,7 @@ ssetup_ntlmssp_authenticate: - iov[1].iov_len = blob_length; - } else if (phase == NtLmAuthenticate) { - req->hdr.SessionId = ses->Suid; -- ntlmssp_blob = kzalloc(sizeof(struct _NEGOTIATE_MESSAGE) + 500, -- GFP_KERNEL); -- if (ntlmssp_blob == NULL) { -- rc = -ENOMEM; -- goto ssetup_exit; -- } -- rc = build_ntlmssp_auth_blob(ntlmssp_blob, &blob_length, ses, -+ rc = build_ntlmssp_auth_blob(&ntlmssp_blob, &blob_length, ses, - nls_cp); - if (rc) { - cifs_dbg(FYI, "build_ntlmssp_auth_blob failed %d\n", -@@ -1820,6 +1814,33 @@ SMB2_echo(struct TCP_Server_Info *server) - - cifs_dbg(FYI, "In echo request\n"); - -+ if (server->tcpStatus == CifsNeedNegotiate) { -+ struct list_head *tmp, *tmp2; -+ struct cifs_ses *ses; -+ struct cifs_tcon *tcon; -+ -+ cifs_dbg(FYI, "Need negotiate, reconnecting tcons\n"); -+ spin_lock(&cifs_tcp_ses_lock); -+ list_for_each(tmp, &server->smb_ses_list) { -+ ses = list_entry(tmp, struct cifs_ses, smb_ses_list); -+ list_for_each(tmp2, &ses->tcon_list) { -+ tcon = list_entry(tmp2, struct cifs_tcon, -+ tcon_list); -+ /* add check for persistent handle reconnect */ -+ if (tcon && tcon->need_reconnect) { -+ spin_unlock(&cifs_tcp_ses_lock); -+ rc = smb2_reconnect(SMB2_ECHO, tcon); -+ spin_lock(&cifs_tcp_ses_lock); -+ } -+ } -+ } -+ spin_unlock(&cifs_tcp_ses_lock); -+ } -+ -+ /* if no session, renegotiate failed above */ -+ if (server->tcpStatus == CifsNeedNegotiate) -+ return -EIO; -+ - rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req); - if (rc) - return rc; -diff --git a/fs/namespace.c b/fs/namespace.c -index 0570729c87fd..33064fcbfff9 100644 ---- a/fs/namespace.c -+++ b/fs/namespace.c -@@ -2401,8 +2401,10 @@ static int do_new_mount(struct path *path, const char *fstype, int flags, - mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV; - } - if (type->fs_flags & FS_USERNS_VISIBLE) { -- if (!fs_fully_visible(type, &mnt_flags)) -+ if (!fs_fully_visible(type, &mnt_flags)) { -+ put_filesystem(type); - return -EPERM; -+ } - } - } - -@@ -3236,6 +3238,10 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags) - if (mnt->mnt.mnt_sb->s_iflags & SB_I_NOEXEC) - mnt_flags &= ~(MNT_LOCK_NOSUID | MNT_LOCK_NOEXEC); - -+ /* Don't miss readonly hidden in the superblock flags */ -+ if (mnt->mnt.mnt_sb->s_flags & MS_RDONLY) -+ mnt_flags |= MNT_LOCK_READONLY; -+ - /* Verify the mount flags are equal to or more permissive - * than the proposed new mount. - */ -@@ -3262,7 +3268,7 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags) - list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { - struct inode *inode = child->mnt_mountpoint->d_inode; - /* Only worry about locked mounts */ -- if (!(mnt_flags & MNT_LOCKED)) -+ if (!(child->mnt.mnt_flags & MNT_LOCKED)) - continue; - /* Is the directory permanetly empty? */ - if (!is_empty_dir_inode(inode)) -diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c -index 5fc2162afb67..46cfed63d229 100644 ---- a/fs/nfs/dir.c -+++ b/fs/nfs/dir.c -@@ -1531,9 +1531,9 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, - err = PTR_ERR(inode); - trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); - put_nfs_open_context(ctx); -+ d_drop(dentry); - switch (err) { - case -ENOENT: -- d_drop(dentry); - d_add(dentry, NULL); - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); - break; -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c -index 98a44157353a..fc215ab4dcd5 100644 ---- a/fs/nfs/nfs4proc.c -+++ b/fs/nfs/nfs4proc.c -@@ -2854,12 +2854,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) - call_close |= is_wronly; - else if (is_wronly) - calldata->arg.fmode |= FMODE_WRITE; -+ if (calldata->arg.fmode != (FMODE_READ|FMODE_WRITE)) -+ call_close |= is_rdwr; - } else if (is_rdwr) - calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; - -- if (calldata->arg.fmode == 0) -- call_close |= is_rdwr; -- - if (!nfs4_valid_open_stateid(state)) - call_close = 0; - spin_unlock(&state->owner->so_lock); -diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c -index 1580ea6fd64d..d08cd88155c7 100644 ---- a/fs/nfsd/nfs2acl.c -+++ b/fs/nfsd/nfs2acl.c -@@ -104,22 +104,21 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp, - goto out; - - inode = d_inode(fh->fh_dentry); -- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { -- error = -EOPNOTSUPP; -- goto out_errno; -- } - - error = fh_want_write(fh); - if (error) - goto out_errno; - -- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); -+ fh_lock(fh); -+ -+ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access); - if (error) -- goto out_drop_write; -- error = inode->i_op->set_acl(inode, argp->acl_default, -- ACL_TYPE_DEFAULT); -+ goto out_drop_lock; -+ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default); - if (error) -- goto out_drop_write; -+ goto out_drop_lock; -+ -+ fh_unlock(fh); - - fh_drop_write(fh); - -@@ -131,7 +130,8 @@ out: - posix_acl_release(argp->acl_access); - posix_acl_release(argp->acl_default); - return nfserr; --out_drop_write: -+out_drop_lock: -+ fh_unlock(fh); - fh_drop_write(fh); - out_errno: - nfserr = nfserrno(error); -diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c -index 01df4cd7c753..0c890347cde3 100644 ---- a/fs/nfsd/nfs3acl.c -+++ b/fs/nfsd/nfs3acl.c -@@ -95,22 +95,20 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp, - goto out; - - inode = d_inode(fh->fh_dentry); -- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { -- error = -EOPNOTSUPP; -- goto out_errno; -- } - - error = fh_want_write(fh); - if (error) - goto out_errno; - -- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); -+ fh_lock(fh); -+ -+ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access); - if (error) -- goto out_drop_write; -- error = inode->i_op->set_acl(inode, argp->acl_default, -- ACL_TYPE_DEFAULT); -+ goto out_drop_lock; -+ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default); - --out_drop_write: -+out_drop_lock: -+ fh_unlock(fh); - fh_drop_write(fh); - out_errno: - nfserr = nfserrno(error); -diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c -index 6adabd6049b7..71292a0d6f09 100644 ---- a/fs/nfsd/nfs4acl.c -+++ b/fs/nfsd/nfs4acl.c -@@ -770,9 +770,6 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, - dentry = fhp->fh_dentry; - inode = d_inode(dentry); - -- if (!inode->i_op->set_acl || !IS_POSIXACL(inode)) -- return nfserr_attrnotsupp; -- - if (S_ISDIR(inode->i_mode)) - flags = NFS4_ACL_DIR; - -@@ -782,16 +779,19 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, - if (host_error < 0) - goto out_nfserr; - -- host_error = inode->i_op->set_acl(inode, pacl, ACL_TYPE_ACCESS); -+ fh_lock(fhp); -+ -+ host_error = set_posix_acl(inode, ACL_TYPE_ACCESS, pacl); - if (host_error < 0) -- goto out_release; -+ goto out_drop_lock; - - if (S_ISDIR(inode->i_mode)) { -- host_error = inode->i_op->set_acl(inode, dpacl, -- ACL_TYPE_DEFAULT); -+ host_error = set_posix_acl(inode, ACL_TYPE_DEFAULT, dpacl); - } - --out_release: -+out_drop_lock: -+ fh_unlock(fhp); -+ - posix_acl_release(pacl); - posix_acl_release(dpacl); - out_nfserr: -diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c -index e7f50c4081d6..15bdc2d48cfe 100644 ---- a/fs/nfsd/nfs4callback.c -+++ b/fs/nfsd/nfs4callback.c -@@ -710,22 +710,6 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc - } - } - --static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args) --{ -- struct rpc_xprt *xprt; -- -- if (args->protocol != XPRT_TRANSPORT_BC_TCP) -- return rpc_create(args); -- -- xprt = args->bc_xprt->xpt_bc_xprt; -- if (xprt) { -- xprt_get(xprt); -- return rpc_create_xprt(args, xprt); -- } -- -- return rpc_create(args); --} -- - static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) - { - int maxtime = max_cb_time(clp->net); -@@ -768,7 +752,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c - args.authflavor = ses->se_cb_sec.flavor; - } - /* Create RPC client */ -- client = create_backchannel_client(&args); -+ client = rpc_create(&args); - if (IS_ERR(client)) { - dprintk("NFSD: couldn't create callback client: %ld\n", - PTR_ERR(client)); -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c -index 6b800b5b8fed..ed2f64ca49de 100644 ---- a/fs/nfsd/nfs4state.c -+++ b/fs/nfsd/nfs4state.c -@@ -3452,6 +3452,10 @@ init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, - struct nfs4_openowner *oo = open->op_openowner; - struct nfs4_ol_stateid *retstp = NULL; - -+ /* We are moving these outside of the spinlocks to avoid the warnings */ -+ mutex_init(&stp->st_mutex); -+ mutex_lock(&stp->st_mutex); -+ - spin_lock(&oo->oo_owner.so_client->cl_lock); - spin_lock(&fp->fi_lock); - -@@ -3467,13 +3471,17 @@ init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, - stp->st_access_bmap = 0; - stp->st_deny_bmap = 0; - stp->st_openstp = NULL; -- init_rwsem(&stp->st_rwsem); - list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); - list_add(&stp->st_perfile, &fp->fi_stateids); - - out_unlock: - spin_unlock(&fp->fi_lock); - spin_unlock(&oo->oo_owner.so_client->cl_lock); -+ if (retstp) { -+ mutex_lock(&retstp->st_mutex); -+ /* Not that we need to, just for neatness */ -+ mutex_unlock(&stp->st_mutex); -+ } - return retstp; - } - -@@ -4300,32 +4308,34 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf - */ - if (stp) { - /* Stateid was found, this is an OPEN upgrade */ -- down_read(&stp->st_rwsem); -+ mutex_lock(&stp->st_mutex); - status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); - if (status) { -- up_read(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - goto out; - } - } else { - stp = open->op_stp; - open->op_stp = NULL; -+ /* -+ * init_open_stateid() either returns a locked stateid -+ * it found, or initializes and locks the new one we passed in -+ */ - swapstp = init_open_stateid(stp, fp, open); - if (swapstp) { - nfs4_put_stid(&stp->st_stid); - stp = swapstp; -- down_read(&stp->st_rwsem); - status = nfs4_upgrade_open(rqstp, fp, current_fh, - stp, open); - if (status) { -- up_read(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - goto out; - } - goto upgrade_out; - } -- down_read(&stp->st_rwsem); - status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); - if (status) { -- up_read(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - release_open_stateid(stp); - goto out; - } -@@ -4337,7 +4347,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf - } - upgrade_out: - nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); -- up_read(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - - if (nfsd4_has_session(&resp->cstate)) { - if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { -@@ -4950,12 +4960,12 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ - * revoked delegations are kept only for free_stateid. - */ - return nfserr_bad_stateid; -- down_write(&stp->st_rwsem); -+ mutex_lock(&stp->st_mutex); - status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); - if (status == nfs_ok) - status = nfs4_check_fh(current_fh, &stp->st_stid); - if (status != nfs_ok) -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - return status; - } - -@@ -5003,7 +5013,7 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs - return status; - oo = openowner(stp->st_stateowner); - if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) { -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - nfs4_put_stid(&stp->st_stid); - return nfserr_bad_stateid; - } -@@ -5035,12 +5045,12 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - oo = openowner(stp->st_stateowner); - status = nfserr_bad_stateid; - if (oo->oo_flags & NFS4_OO_CONFIRMED) { -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - goto put_stateid; - } - oo->oo_flags |= NFS4_OO_CONFIRMED; - nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n", - __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid)); - -@@ -5116,7 +5126,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, - nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); - status = nfs_ok; - put_stateid: -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - nfs4_put_stid(&stp->st_stid); - out: - nfsd4_bump_seqid(cstate, status); -@@ -5169,7 +5179,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - if (status) - goto out; - nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - - nfsd4_close_open_stateid(stp); - -@@ -5395,7 +5405,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, - stp->st_access_bmap = 0; - stp->st_deny_bmap = open_stp->st_deny_bmap; - stp->st_openstp = open_stp; -- init_rwsem(&stp->st_rwsem); -+ mutex_init(&stp->st_mutex); - list_add(&stp->st_locks, &open_stp->st_locks); - list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); - spin_lock(&fp->fi_lock); -@@ -5564,7 +5574,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - &open_stp, nn); - if (status) - goto out; -- up_write(&open_stp->st_rwsem); -+ mutex_unlock(&open_stp->st_mutex); - open_sop = openowner(open_stp->st_stateowner); - status = nfserr_bad_stateid; - if (!same_clid(&open_sop->oo_owner.so_client->cl_clientid, -@@ -5573,7 +5583,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - status = lookup_or_create_lock_state(cstate, open_stp, lock, - &lock_stp, &new); - if (status == nfs_ok) -- down_write(&lock_stp->st_rwsem); -+ mutex_lock(&lock_stp->st_mutex); - } else { - status = nfs4_preprocess_seqid_op(cstate, - lock->lk_old_lock_seqid, -@@ -5677,7 +5687,7 @@ out: - seqid_mutating_err(ntohl(status))) - lock_sop->lo_owner.so_seqid++; - -- up_write(&lock_stp->st_rwsem); -+ mutex_unlock(&lock_stp->st_mutex); - - /* - * If this is a new, never-before-used stateid, and we are -@@ -5847,7 +5857,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - fput: - fput(filp); - put_stateid: -- up_write(&stp->st_rwsem); -+ mutex_unlock(&stp->st_mutex); - nfs4_put_stid(&stp->st_stid); - out: - nfsd4_bump_seqid(cstate, status); -diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h -index 77fdf4de91ba..77860b75da9d 100644 ---- a/fs/nfsd/state.h -+++ b/fs/nfsd/state.h -@@ -535,7 +535,7 @@ struct nfs4_ol_stateid { - unsigned char st_access_bmap; - unsigned char st_deny_bmap; - struct nfs4_ol_stateid *st_openstp; -- struct rw_semaphore st_rwsem; -+ struct mutex st_mutex; - }; - - static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s) -diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c -index a2b1d7ce3e1a..ba5ef733951f 100644 ---- a/fs/overlayfs/dir.c -+++ b/fs/overlayfs/dir.c -@@ -511,6 +511,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) - struct dentry *upper; - struct dentry *opaquedir = NULL; - int err; -+ int flags = 0; - - if (WARN_ON(!workdir)) - return -EROFS; -@@ -540,46 +541,39 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) - if (err) - goto out_dput; - -- whiteout = ovl_whiteout(workdir, dentry); -- err = PTR_ERR(whiteout); -- if (IS_ERR(whiteout)) -+ upper = lookup_one_len(dentry->d_name.name, upperdir, -+ dentry->d_name.len); -+ err = PTR_ERR(upper); -+ if (IS_ERR(upper)) - goto out_unlock; - -- upper = ovl_dentry_upper(dentry); -- if (!upper) { -- upper = lookup_one_len(dentry->d_name.name, upperdir, -- dentry->d_name.len); -- err = PTR_ERR(upper); -- if (IS_ERR(upper)) -- goto kill_whiteout; -- -- err = ovl_do_rename(wdir, whiteout, udir, upper, 0); -- dput(upper); -- if (err) -- goto kill_whiteout; -- } else { -- int flags = 0; -+ err = -ESTALE; -+ if ((opaquedir && upper != opaquedir) || -+ (!opaquedir && ovl_dentry_upper(dentry) && -+ upper != ovl_dentry_upper(dentry))) { -+ goto out_dput_upper; -+ } - -- if (opaquedir) -- upper = opaquedir; -- err = -ESTALE; -- if (upper->d_parent != upperdir) -- goto kill_whiteout; -+ whiteout = ovl_whiteout(workdir, dentry); -+ err = PTR_ERR(whiteout); -+ if (IS_ERR(whiteout)) -+ goto out_dput_upper; - -- if (is_dir) -- flags |= RENAME_EXCHANGE; -+ if (d_is_dir(upper)) -+ flags = RENAME_EXCHANGE; - -- err = ovl_do_rename(wdir, whiteout, udir, upper, flags); -- if (err) -- goto kill_whiteout; -+ err = ovl_do_rename(wdir, whiteout, udir, upper, flags); -+ if (err) -+ goto kill_whiteout; -+ if (flags) -+ ovl_cleanup(wdir, upper); - -- if (is_dir) -- ovl_cleanup(wdir, upper); -- } - ovl_dentry_version_inc(dentry->d_parent); - out_d_drop: - d_drop(dentry); - dput(whiteout); -+out_dput_upper: -+ dput(upper); - out_unlock: - unlock_rename(workdir, upperdir); - out_dput: -@@ -596,21 +590,25 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir) - { - struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); - struct inode *dir = upperdir->d_inode; -- struct dentry *upper = ovl_dentry_upper(dentry); -+ struct dentry *upper; - int err; - - mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); -+ upper = lookup_one_len(dentry->d_name.name, upperdir, -+ dentry->d_name.len); -+ err = PTR_ERR(upper); -+ if (IS_ERR(upper)) -+ goto out_unlock; -+ - err = -ESTALE; -- if (upper->d_parent == upperdir) { -- /* Don't let d_delete() think it can reset d_inode */ -- dget(upper); -+ if (upper == ovl_dentry_upper(dentry)) { - if (is_dir) - err = vfs_rmdir(dir, upper); - else - err = vfs_unlink(dir, upper, NULL); -- dput(upper); - ovl_dentry_version_inc(dentry->d_parent); - } -+ dput(upper); - - /* - * Keeping this dentry hashed would mean having to release -@@ -620,6 +618,7 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir) - */ - if (!err) - d_drop(dentry); -+out_unlock: - mutex_unlock(&dir->i_mutex); - - return err; -@@ -840,29 +839,39 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, - - trap = lock_rename(new_upperdir, old_upperdir); - -- olddentry = ovl_dentry_upper(old); -- newdentry = ovl_dentry_upper(new); -- if (newdentry) { -+ -+ olddentry = lookup_one_len(old->d_name.name, old_upperdir, -+ old->d_name.len); -+ err = PTR_ERR(olddentry); -+ if (IS_ERR(olddentry)) -+ goto out_unlock; -+ -+ err = -ESTALE; -+ if (olddentry != ovl_dentry_upper(old)) -+ goto out_dput_old; -+ -+ newdentry = lookup_one_len(new->d_name.name, new_upperdir, -+ new->d_name.len); -+ err = PTR_ERR(newdentry); -+ if (IS_ERR(newdentry)) -+ goto out_dput_old; -+ -+ err = -ESTALE; -+ if (ovl_dentry_upper(new)) { - if (opaquedir) { -- newdentry = opaquedir; -- opaquedir = NULL; -+ if (newdentry != opaquedir) -+ goto out_dput; - } else { -- dget(newdentry); -+ if (newdentry != ovl_dentry_upper(new)) -+ goto out_dput; - } - } else { - new_create = true; -- newdentry = lookup_one_len(new->d_name.name, new_upperdir, -- new->d_name.len); -- err = PTR_ERR(newdentry); -- if (IS_ERR(newdentry)) -- goto out_unlock; -+ if (!d_is_negative(newdentry) && -+ (!new_opaque || !ovl_is_whiteout(newdentry))) -+ goto out_dput; - } - -- err = -ESTALE; -- if (olddentry->d_parent != old_upperdir) -- goto out_dput; -- if (newdentry->d_parent != new_upperdir) -- goto out_dput; - if (olddentry == trap) - goto out_dput; - if (newdentry == trap) -@@ -925,6 +934,8 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, - - out_dput: - dput(newdentry); -+out_dput_old: -+ dput(olddentry); - out_unlock: - unlock_rename(new_upperdir, old_upperdir); - out_revert_creds: -diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c -index 05ac9a95e881..0597820f5d9d 100644 ---- a/fs/overlayfs/inode.c -+++ b/fs/overlayfs/inode.c -@@ -412,12 +412,11 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, - if (!inode) - return NULL; - -- mode &= S_IFMT; -- - inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_flags |= S_NOATIME | S_NOCMTIME; - -+ mode &= S_IFMT; - switch (mode) { - case S_IFDIR: - inode->i_private = oe; -diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h -index e17154aeaae4..735e1d49b301 100644 ---- a/fs/overlayfs/overlayfs.h -+++ b/fs/overlayfs/overlayfs.h -@@ -181,6 +181,7 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to) - { - to->i_uid = from->i_uid; - to->i_gid = from->i_gid; -+ to->i_mode = from->i_mode; - } - - /* dir.c */ -diff --git a/fs/posix_acl.c b/fs/posix_acl.c -index 4adde1e2cbec..34bd1bd354e6 100644 ---- a/fs/posix_acl.c -+++ b/fs/posix_acl.c -@@ -788,6 +788,28 @@ posix_acl_xattr_get(const struct xattr_handler *handler, - return error; - } - -+int -+set_posix_acl(struct inode *inode, int type, struct posix_acl *acl) -+{ -+ if (!IS_POSIXACL(inode)) -+ return -EOPNOTSUPP; -+ if (!inode->i_op->set_acl) -+ return -EOPNOTSUPP; -+ -+ if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) -+ return acl ? -EACCES : 0; -+ if (!inode_owner_or_capable(inode)) -+ return -EPERM; -+ -+ if (acl) { -+ int ret = posix_acl_valid(acl); -+ if (ret) -+ return ret; -+ } -+ return inode->i_op->set_acl(inode, acl, type); -+} -+EXPORT_SYMBOL(set_posix_acl); -+ - static int - posix_acl_xattr_set(const struct xattr_handler *handler, - struct dentry *dentry, const char *name, -@@ -799,30 +821,13 @@ posix_acl_xattr_set(const struct xattr_handler *handler, - - if (strcmp(name, "") != 0) - return -EINVAL; -- if (!IS_POSIXACL(inode)) -- return -EOPNOTSUPP; -- if (!inode->i_op->set_acl) -- return -EOPNOTSUPP; -- -- if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) -- return value ? -EACCES : 0; -- if (!inode_owner_or_capable(inode)) -- return -EPERM; - - if (value) { - acl = posix_acl_from_xattr(&init_user_ns, value, size); - if (IS_ERR(acl)) - return PTR_ERR(acl); -- -- if (acl) { -- ret = posix_acl_valid(acl); -- if (ret) -- goto out; -- } - } -- -- ret = inode->i_op->set_acl(inode, acl, handler->flags); --out: -+ ret = set_posix_acl(inode, handler->flags, acl); - posix_acl_release(acl); - return ret; - } -diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c -index 0edc12856147..b895af7d8d80 100644 ---- a/fs/ubifs/file.c -+++ b/fs/ubifs/file.c -@@ -52,6 +52,7 @@ - #include "ubifs.h" - #include - #include -+#include - - static int read_block(struct inode *inode, void *addr, unsigned int block, - struct ubifs_data_node *dn) -@@ -1452,6 +1453,26 @@ static int ubifs_set_page_dirty(struct page *page) - return ret; - } - -+#ifdef CONFIG_MIGRATION -+static int ubifs_migrate_page(struct address_space *mapping, -+ struct page *newpage, struct page *page, enum migrate_mode mode) -+{ -+ int rc; -+ -+ rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); -+ if (rc != MIGRATEPAGE_SUCCESS) -+ return rc; -+ -+ if (PagePrivate(page)) { -+ ClearPagePrivate(page); -+ SetPagePrivate(newpage); -+ } -+ -+ migrate_page_copy(newpage, page); -+ return MIGRATEPAGE_SUCCESS; -+} -+#endif -+ - static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags) - { - /* -@@ -1591,6 +1612,9 @@ const struct address_space_operations ubifs_file_address_operations = { - .write_end = ubifs_write_end, - .invalidatepage = ubifs_invalidatepage, - .set_page_dirty = ubifs_set_page_dirty, -+#ifdef CONFIG_MIGRATION -+ .migratepage = ubifs_migrate_page, -+#endif - .releasepage = ubifs_releasepage, - }; - -diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h -index 7d633f19e38a..1885fc44b1bc 100644 ---- a/include/asm-generic/qspinlock.h -+++ b/include/asm-generic/qspinlock.h -@@ -21,37 +21,33 @@ - #include - - /** -+ * queued_spin_unlock_wait - wait until the _current_ lock holder releases the lock -+ * @lock : Pointer to queued spinlock structure -+ * -+ * There is a very slight possibility of live-lock if the lockers keep coming -+ * and the waiter is just unfortunate enough to not see any unlock state. -+ */ -+#ifndef queued_spin_unlock_wait -+extern void queued_spin_unlock_wait(struct qspinlock *lock); -+#endif -+ -+/** - * queued_spin_is_locked - is the spinlock locked? - * @lock: Pointer to queued spinlock structure - * Return: 1 if it is locked, 0 otherwise - */ -+#ifndef queued_spin_is_locked - static __always_inline int queued_spin_is_locked(struct qspinlock *lock) - { - /* -- * queued_spin_lock_slowpath() can ACQUIRE the lock before -- * issuing the unordered store that sets _Q_LOCKED_VAL. -- * -- * See both smp_cond_acquire() sites for more detail. -- * -- * This however means that in code like: -- * -- * spin_lock(A) spin_lock(B) -- * spin_unlock_wait(B) spin_is_locked(A) -- * do_something() do_something() -- * -- * Both CPUs can end up running do_something() because the store -- * setting _Q_LOCKED_VAL will pass through the loads in -- * spin_unlock_wait() and/or spin_is_locked(). -+ * See queued_spin_unlock_wait(). - * -- * Avoid this by issuing a full memory barrier between the spin_lock() -- * and the loads in spin_unlock_wait() and spin_is_locked(). -- * -- * Note that regular mutual exclusion doesn't care about this -- * delayed store. -+ * Any !0 state indicates it is locked, even if _Q_LOCKED_VAL -+ * isn't immediately observable. - */ -- smp_mb(); -- return atomic_read(&lock->val) & _Q_LOCKED_MASK; -+ return atomic_read(&lock->val); - } -+#endif - - /** - * queued_spin_value_unlocked - is the spinlock structure unlocked? -@@ -121,21 +117,6 @@ static __always_inline void queued_spin_unlock(struct qspinlock *lock) - } - #endif - --/** -- * queued_spin_unlock_wait - wait until current lock holder releases the lock -- * @lock : Pointer to queued spinlock structure -- * -- * There is a very slight possibility of live-lock if the lockers keep coming -- * and the waiter is just unfortunate enough to not see any unlock state. -- */ --static inline void queued_spin_unlock_wait(struct qspinlock *lock) --{ -- /* See queued_spin_is_locked() */ -- smp_mb(); -- while (atomic_read(&lock->val) & _Q_LOCKED_MASK) -- cpu_relax(); --} -- - #ifndef virt_spin_lock - static __always_inline bool virt_spin_lock(struct qspinlock *lock) - { -diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h -index c768ddfbe53c..b7bfa513e6ed 100644 ---- a/include/drm/ttm/ttm_bo_api.h -+++ b/include/drm/ttm/ttm_bo_api.h -@@ -316,6 +316,20 @@ ttm_bo_reference(struct ttm_buffer_object *bo) - */ - extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy, - bool interruptible, bool no_wait); -+ -+/** -+ * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo -+ * -+ * @placement: Return immediately if buffer is busy. -+ * @mem: The struct ttm_mem_reg indicating the region where the bo resides -+ * @new_flags: Describes compatible placement found -+ * -+ * Returns true if the placement is compatible -+ */ -+extern bool ttm_bo_mem_compat(struct ttm_placement *placement, -+ struct ttm_mem_reg *mem, -+ uint32_t *new_flags); -+ - /** - * ttm_bo_validate - * -diff --git a/include/linux/dcache.h b/include/linux/dcache.h -index d81746d3b2da..8d7151eb6ceb 100644 ---- a/include/linux/dcache.h -+++ b/include/linux/dcache.h -@@ -603,5 +603,17 @@ static inline struct inode *vfs_select_inode(struct dentry *dentry, - return inode; - } - -+/** -+ * d_real_inode - Return the real inode -+ * @dentry: The dentry to query -+ * -+ * If dentry is on an union/overlay, then return the underlying, real inode. -+ * Otherwise return d_inode(). -+ */ -+static inline struct inode *d_real_inode(struct dentry *dentry) -+{ -+ return d_backing_inode(d_real(dentry)); -+} -+ - - #endif /* __LINUX_DCACHE_H */ -diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h -index 0536524bb9eb..68904469fba1 100644 ---- a/include/linux/jump_label.h -+++ b/include/linux/jump_label.h -@@ -117,13 +117,18 @@ struct module; - - #include - -+#ifdef HAVE_JUMP_LABEL -+ - static inline int static_key_count(struct static_key *key) - { -- return atomic_read(&key->enabled); -+ /* -+ * -1 means the first static_key_slow_inc() is in progress. -+ * static_key_enabled() must return true, so return 1 here. -+ */ -+ int n = atomic_read(&key->enabled); -+ return n >= 0 ? n : 1; - } - --#ifdef HAVE_JUMP_LABEL -- - #define JUMP_TYPE_FALSE 0UL - #define JUMP_TYPE_TRUE 1UL - #define JUMP_TYPE_MASK 1UL -@@ -162,6 +167,11 @@ extern void jump_label_apply_nops(struct module *mod); - - #else /* !HAVE_JUMP_LABEL */ - -+static inline int static_key_count(struct static_key *key) -+{ -+ return atomic_read(&key->enabled); -+} -+ - static __always_inline void jump_label_init(void) - { - static_key_initialized = true; -diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h -index 1716f9395010..d443d9ab0236 100644 ---- a/include/linux/skbuff.h -+++ b/include/linux/skbuff.h -@@ -982,6 +982,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4) - } - - void __skb_get_hash(struct sk_buff *skb); -+u32 __skb_get_hash_symmetric(struct sk_buff *skb); - u32 skb_get_poff(const struct sk_buff *skb); - u32 __skb_get_poff(const struct sk_buff *skb, void *data, - const struct flow_keys *keys, int hlen); -@@ -2773,6 +2774,25 @@ static inline void skb_postpush_rcsum(struct sk_buff *skb, - } - - /** -+ * skb_push_rcsum - push skb and update receive checksum -+ * @skb: buffer to update -+ * @len: length of data pulled -+ * -+ * This function performs an skb_push on the packet and updates -+ * the CHECKSUM_COMPLETE checksum. It should be used on -+ * receive path processing instead of skb_push unless you know -+ * that the checksum difference is zero (e.g., a valid IP header) -+ * or you are setting ip_summed to CHECKSUM_NONE. -+ */ -+static inline unsigned char *skb_push_rcsum(struct sk_buff *skb, -+ unsigned int len) -+{ -+ skb_push(skb, len); -+ skb_postpush_rcsum(skb, skb->data, len); -+ return skb->data; -+} -+ -+/** - * pskb_trim_rcsum - trim received skb and update checksum - * @skb: buffer to trim - * @len: new length -diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h -index 131032f15cc1..9b6027c51736 100644 ---- a/include/linux/sunrpc/clnt.h -+++ b/include/linux/sunrpc/clnt.h -@@ -135,8 +135,6 @@ struct rpc_create_args { - #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) - - struct rpc_clnt *rpc_create(struct rpc_create_args *args); --struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, -- struct rpc_xprt *xprt); - struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, - const struct rpc_program *, u32); - void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt); -diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h -index 966889a20ea3..e479033bd782 100644 ---- a/include/linux/usb/ehci_def.h -+++ b/include/linux/usb/ehci_def.h -@@ -180,11 +180,11 @@ struct ehci_regs { - * PORTSCx - */ - /* HOSTPC: offset 0x84 */ -- u32 hostpc[1]; /* HOSTPC extension */ -+ u32 hostpc[0]; /* HOSTPC extension */ - #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ - #define HOSTPC_PSPD (3<<25) /* Port speed detection */ - -- u32 reserved5[16]; -+ u32 reserved5[17]; - - /* USBMODE_EX: offset 0xc8 */ - u32 usbmode_ex; /* USB Device mode extension */ -diff --git a/kernel/jump_label.c b/kernel/jump_label.c -index 05254eeb4b4e..4b353e0be121 100644 ---- a/kernel/jump_label.c -+++ b/kernel/jump_label.c -@@ -58,13 +58,36 @@ static void jump_label_update(struct static_key *key); - - void static_key_slow_inc(struct static_key *key) - { -+ int v, v1; -+ - STATIC_KEY_CHECK_USE(); -- if (atomic_inc_not_zero(&key->enabled)) -- return; -+ -+ /* -+ * Careful if we get concurrent static_key_slow_inc() calls; -+ * later calls must wait for the first one to _finish_ the -+ * jump_label_update() process. At the same time, however, -+ * the jump_label_update() call below wants to see -+ * static_key_enabled(&key) for jumps to be updated properly. -+ * -+ * So give a special meaning to negative key->enabled: it sends -+ * static_key_slow_inc() down the slow path, and it is non-zero -+ * so it counts as "enabled" in jump_label_update(). Note that -+ * atomic_inc_unless_negative() checks >= 0, so roll our own. -+ */ -+ for (v = atomic_read(&key->enabled); v > 0; v = v1) { -+ v1 = atomic_cmpxchg(&key->enabled, v, v + 1); -+ if (likely(v1 == v)) -+ return; -+ } - - jump_label_lock(); -- if (atomic_inc_return(&key->enabled) == 1) -+ if (atomic_read(&key->enabled) == 0) { -+ atomic_set(&key->enabled, -1); - jump_label_update(key); -+ atomic_set(&key->enabled, 1); -+ } else { -+ atomic_inc(&key->enabled); -+ } - jump_label_unlock(); - } - EXPORT_SYMBOL_GPL(static_key_slow_inc); -@@ -72,6 +95,13 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc); - static void __static_key_slow_dec(struct static_key *key, - unsigned long rate_limit, struct delayed_work *work) - { -+ /* -+ * The negative count check is valid even when a negative -+ * key->enabled is in use by static_key_slow_inc(); a -+ * __static_key_slow_dec() before the first static_key_slow_inc() -+ * returns is unbalanced, because all other static_key_slow_inc() -+ * instances block while the update is in progress. -+ */ - if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex)) { - WARN(atomic_read(&key->enabled) < 0, - "jump label: negative count!\n"); -diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c -index 0551c219c40e..89350f924c85 100644 ---- a/kernel/locking/mutex.c -+++ b/kernel/locking/mutex.c -@@ -486,9 +486,6 @@ __ww_mutex_lock_check_stamp(struct mutex *lock, struct ww_acquire_ctx *ctx) - if (!hold_ctx) - return 0; - -- if (unlikely(ctx == hold_ctx)) -- return -EALREADY; -- - if (ctx->stamp - hold_ctx->stamp <= LONG_MAX && - (ctx->stamp != hold_ctx->stamp || ctx > hold_ctx)) { - #ifdef CONFIG_DEBUG_MUTEXES -@@ -514,6 +511,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, - unsigned long flags; - int ret; - -+ if (use_ww_ctx) { -+ struct ww_mutex *ww = container_of(lock, struct ww_mutex, base); -+ if (unlikely(ww_ctx == READ_ONCE(ww->ctx))) -+ return -EALREADY; -+ } -+ - preempt_disable(); - mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip); - -diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c -index 87e9ce6a63c5..8173bc7fec92 100644 ---- a/kernel/locking/qspinlock.c -+++ b/kernel/locking/qspinlock.c -@@ -255,6 +255,66 @@ static __always_inline void __pv_wait_head(struct qspinlock *lock, - #define queued_spin_lock_slowpath native_queued_spin_lock_slowpath - #endif - -+/* -+ * queued_spin_lock_slowpath() can (load-)ACQUIRE the lock before -+ * issuing an _unordered_ store to set _Q_LOCKED_VAL. -+ * -+ * This means that the store can be delayed, but no later than the -+ * store-release from the unlock. This means that simply observing -+ * _Q_LOCKED_VAL is not sufficient to determine if the lock is acquired. -+ * -+ * There are two paths that can issue the unordered store: -+ * -+ * (1) clear_pending_set_locked(): *,1,0 -> *,0,1 -+ * -+ * (2) set_locked(): t,0,0 -> t,0,1 ; t != 0 -+ * atomic_cmpxchg_relaxed(): t,0,0 -> 0,0,1 -+ * -+ * However, in both cases we have other !0 state we've set before to queue -+ * ourseves: -+ * -+ * For (1) we have the atomic_cmpxchg_acquire() that set _Q_PENDING_VAL, our -+ * load is constrained by that ACQUIRE to not pass before that, and thus must -+ * observe the store. -+ * -+ * For (2) we have a more intersting scenario. We enqueue ourselves using -+ * xchg_tail(), which ends up being a RELEASE. This in itself is not -+ * sufficient, however that is followed by an smp_cond_acquire() on the same -+ * word, giving a RELEASE->ACQUIRE ordering. This again constrains our load and -+ * guarantees we must observe that store. -+ * -+ * Therefore both cases have other !0 state that is observable before the -+ * unordered locked byte store comes through. This means we can use that to -+ * wait for the lock store, and then wait for an unlock. -+ */ -+#ifndef queued_spin_unlock_wait -+void queued_spin_unlock_wait(struct qspinlock *lock) -+{ -+ u32 val; -+ -+ for (;;) { -+ val = atomic_read(&lock->val); -+ -+ if (!val) /* not locked, we're done */ -+ goto done; -+ -+ if (val & _Q_LOCKED_MASK) /* locked, go wait for unlock */ -+ break; -+ -+ /* not locked, but pending, wait until we observe the lock */ -+ cpu_relax(); -+ } -+ -+ /* any unlock is good */ -+ while (atomic_read(&lock->val) & _Q_LOCKED_MASK) -+ cpu_relax(); -+ -+done: -+ smp_rmb(); /* CTRL + RMB -> ACQUIRE */ -+} -+EXPORT_SYMBOL(queued_spin_unlock_wait); -+#endif -+ - #endif /* _GEN_PV_LOCK_SLOWPATH */ - - /** -diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index cfdc0e61066c..51c615279b23 100644 ---- a/kernel/sched/fair.c -+++ b/kernel/sched/fair.c -@@ -2682,6 +2682,23 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq, int force) {} - - static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq); - -+/* -+ * Unsigned subtract and clamp on underflow. -+ * -+ * Explicitly do a load-store to ensure the intermediate value never hits -+ * memory. This allows lockless observations without ever seeing the negative -+ * values. -+ */ -+#define sub_positive(_ptr, _val) do { \ -+ typeof(_ptr) ptr = (_ptr); \ -+ typeof(*ptr) val = (_val); \ -+ typeof(*ptr) res, var = READ_ONCE(*ptr); \ -+ res = var - val; \ -+ if (res > var) \ -+ res = 0; \ -+ WRITE_ONCE(*ptr, res); \ -+} while (0) -+ - /* Group cfs_rq's load_avg is used for task_h_load and update_cfs_share */ - static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) - { -@@ -2690,15 +2707,15 @@ static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) - - if (atomic_long_read(&cfs_rq->removed_load_avg)) { - s64 r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0); -- sa->load_avg = max_t(long, sa->load_avg - r, 0); -- sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0); -+ sub_positive(&sa->load_avg, r); -+ sub_positive(&sa->load_sum, r * LOAD_AVG_MAX); - removed = 1; - } - - if (atomic_long_read(&cfs_rq->removed_util_avg)) { - long r = atomic_long_xchg(&cfs_rq->removed_util_avg, 0); -- sa->util_avg = max_t(long, sa->util_avg - r, 0); -- sa->util_sum = max_t(s32, sa->util_sum - r * LOAD_AVG_MAX, 0); -+ sub_positive(&sa->util_avg, r); -+ sub_positive(&sa->util_sum, r * LOAD_AVG_MAX); - } - - decayed = __update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa, -@@ -2764,10 +2781,10 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s - &se->avg, se->on_rq * scale_load_down(se->load.weight), - cfs_rq->curr == se, NULL); - -- cfs_rq->avg.load_avg = max_t(long, cfs_rq->avg.load_avg - se->avg.load_avg, 0); -- cfs_rq->avg.load_sum = max_t(s64, cfs_rq->avg.load_sum - se->avg.load_sum, 0); -- cfs_rq->avg.util_avg = max_t(long, cfs_rq->avg.util_avg - se->avg.util_avg, 0); -- cfs_rq->avg.util_sum = max_t(s32, cfs_rq->avg.util_sum - se->avg.util_sum, 0); -+ sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); -+ sub_positive(&cfs_rq->avg.load_sum, se->avg.load_sum); -+ sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); -+ sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); - } - - /* Add the load generated by se into cfs_rq's load average */ -diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c -index f96f0383f6c6..ad1d6164e946 100644 ---- a/kernel/trace/trace_printk.c -+++ b/kernel/trace/trace_printk.c -@@ -36,6 +36,10 @@ struct trace_bprintk_fmt { - static inline struct trace_bprintk_fmt *lookup_format(const char *fmt) - { - struct trace_bprintk_fmt *pos; -+ -+ if (!fmt) -+ return ERR_PTR(-EINVAL); -+ - list_for_each_entry(pos, &trace_bprintk_fmt_list, list) { - if (!strcmp(pos->fmt, fmt)) - return pos; -@@ -57,7 +61,8 @@ void hold_module_trace_bprintk_format(const char **start, const char **end) - for (iter = start; iter < end; iter++) { - struct trace_bprintk_fmt *tb_fmt = lookup_format(*iter); - if (tb_fmt) { -- *iter = tb_fmt->fmt; -+ if (!IS_ERR(tb_fmt)) -+ *iter = tb_fmt->fmt; - continue; - } - -diff --git a/mm/migrate.c b/mm/migrate.c -index bbeb0b71fcf4..72c09dea6526 100644 ---- a/mm/migrate.c -+++ b/mm/migrate.c -@@ -429,6 +429,7 @@ int migrate_page_move_mapping(struct address_space *mapping, - - return MIGRATEPAGE_SUCCESS; - } -+EXPORT_SYMBOL(migrate_page_move_mapping); - - /* - * The expected number of remaining references is the same as that -@@ -579,6 +580,7 @@ void migrate_page_copy(struct page *newpage, struct page *page) - if (PageWriteback(newpage)) - end_page_writeback(newpage); - } -+EXPORT_SYMBOL(migrate_page_copy); - - /************************************************************ - * Migration functions -diff --git a/mm/page-writeback.c b/mm/page-writeback.c -index e40c9364582d..fd51ebfc423f 100644 ---- a/mm/page-writeback.c -+++ b/mm/page-writeback.c -@@ -359,8 +359,9 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc) - struct dirty_throttle_control *gdtc = mdtc_gdtc(dtc); - unsigned long bytes = vm_dirty_bytes; - unsigned long bg_bytes = dirty_background_bytes; -- unsigned long ratio = vm_dirty_ratio; -- unsigned long bg_ratio = dirty_background_ratio; -+ /* convert ratios to per-PAGE_SIZE for higher precision */ -+ unsigned long ratio = (vm_dirty_ratio * PAGE_SIZE) / 100; -+ unsigned long bg_ratio = (dirty_background_ratio * PAGE_SIZE) / 100; - unsigned long thresh; - unsigned long bg_thresh; - struct task_struct *tsk; -@@ -372,26 +373,28 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc) - /* - * The byte settings can't be applied directly to memcg - * domains. Convert them to ratios by scaling against -- * globally available memory. -+ * globally available memory. As the ratios are in -+ * per-PAGE_SIZE, they can be obtained by dividing bytes by -+ * number of pages. - */ - if (bytes) -- ratio = min(DIV_ROUND_UP(bytes, PAGE_SIZE) * 100 / -- global_avail, 100UL); -+ ratio = min(DIV_ROUND_UP(bytes, global_avail), -+ PAGE_SIZE); - if (bg_bytes) -- bg_ratio = min(DIV_ROUND_UP(bg_bytes, PAGE_SIZE) * 100 / -- global_avail, 100UL); -+ bg_ratio = min(DIV_ROUND_UP(bg_bytes, global_avail), -+ PAGE_SIZE); - bytes = bg_bytes = 0; - } - - if (bytes) - thresh = DIV_ROUND_UP(bytes, PAGE_SIZE); - else -- thresh = (ratio * available_memory) / 100; -+ thresh = (ratio * available_memory) / PAGE_SIZE; - - if (bg_bytes) - bg_thresh = DIV_ROUND_UP(bg_bytes, PAGE_SIZE); - else -- bg_thresh = (bg_ratio * available_memory) / 100; -+ bg_thresh = (bg_ratio * available_memory) / PAGE_SIZE; - - if (bg_thresh >= thresh) - bg_thresh = thresh / 2; -diff --git a/mm/percpu.c b/mm/percpu.c -index 8a943b97a053..1f376bce413c 100644 ---- a/mm/percpu.c -+++ b/mm/percpu.c -@@ -110,7 +110,7 @@ struct pcpu_chunk { - int map_used; /* # of map entries used before the sentry */ - int map_alloc; /* # of map entries allocated */ - int *map; /* allocation map */ -- struct work_struct map_extend_work;/* async ->map[] extension */ -+ struct list_head map_extend_list;/* on pcpu_map_extend_chunks */ - - void *data; /* chunk data */ - int first_free; /* no free below this */ -@@ -160,10 +160,13 @@ static struct pcpu_chunk *pcpu_reserved_chunk; - static int pcpu_reserved_chunk_limit; - - static DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */ --static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop */ -+static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext */ - - static struct list_head *pcpu_slot __read_mostly; /* chunk list slots */ - -+/* chunks which need their map areas extended, protected by pcpu_lock */ -+static LIST_HEAD(pcpu_map_extend_chunks); -+ - /* - * The number of empty populated pages, protected by pcpu_lock. The - * reserved chunk doesn't contribute to the count. -@@ -397,13 +400,19 @@ static int pcpu_need_to_extend(struct pcpu_chunk *chunk, bool is_atomic) - { - int margin, new_alloc; - -+ lockdep_assert_held(&pcpu_lock); -+ - if (is_atomic) { - margin = 3; - - if (chunk->map_alloc < -- chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW && -- pcpu_async_enabled) -- schedule_work(&chunk->map_extend_work); -+ chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW) { -+ if (list_empty(&chunk->map_extend_list)) { -+ list_add_tail(&chunk->map_extend_list, -+ &pcpu_map_extend_chunks); -+ pcpu_schedule_balance_work(); -+ } -+ } - } else { - margin = PCPU_ATOMIC_MAP_MARGIN_HIGH; - } -@@ -437,6 +446,8 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) - size_t old_size = 0, new_size = new_alloc * sizeof(new[0]); - unsigned long flags; - -+ lockdep_assert_held(&pcpu_alloc_mutex); -+ - new = pcpu_mem_zalloc(new_size); - if (!new) - return -ENOMEM; -@@ -469,20 +480,6 @@ out_unlock: - return 0; - } - --static void pcpu_map_extend_workfn(struct work_struct *work) --{ -- struct pcpu_chunk *chunk = container_of(work, struct pcpu_chunk, -- map_extend_work); -- int new_alloc; -- -- spin_lock_irq(&pcpu_lock); -- new_alloc = pcpu_need_to_extend(chunk, false); -- spin_unlock_irq(&pcpu_lock); -- -- if (new_alloc) -- pcpu_extend_area_map(chunk, new_alloc); --} -- - /** - * pcpu_fit_in_area - try to fit the requested allocation in a candidate area - * @chunk: chunk the candidate area belongs to -@@ -742,7 +739,7 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) - chunk->map_used = 1; - - INIT_LIST_HEAD(&chunk->list); -- INIT_WORK(&chunk->map_extend_work, pcpu_map_extend_workfn); -+ INIT_LIST_HEAD(&chunk->map_extend_list); - chunk->free_size = pcpu_unit_size; - chunk->contig_hint = pcpu_unit_size; - -@@ -897,6 +894,9 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, - return NULL; - } - -+ if (!is_atomic) -+ mutex_lock(&pcpu_alloc_mutex); -+ - spin_lock_irqsave(&pcpu_lock, flags); - - /* serve reserved allocations from the reserved chunk if available */ -@@ -969,12 +969,9 @@ restart: - if (is_atomic) - goto fail; - -- mutex_lock(&pcpu_alloc_mutex); -- - if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) { - chunk = pcpu_create_chunk(); - if (!chunk) { -- mutex_unlock(&pcpu_alloc_mutex); - err = "failed to allocate new chunk"; - goto fail; - } -@@ -985,7 +982,6 @@ restart: - spin_lock_irqsave(&pcpu_lock, flags); - } - -- mutex_unlock(&pcpu_alloc_mutex); - goto restart; - - area_found: -@@ -995,8 +991,6 @@ area_found: - if (!is_atomic) { - int page_start, page_end, rs, re; - -- mutex_lock(&pcpu_alloc_mutex); -- - page_start = PFN_DOWN(off); - page_end = PFN_UP(off + size); - -@@ -1007,7 +1001,6 @@ area_found: - - spin_lock_irqsave(&pcpu_lock, flags); - if (ret) { -- mutex_unlock(&pcpu_alloc_mutex); - pcpu_free_area(chunk, off, &occ_pages); - err = "failed to populate"; - goto fail_unlock; -@@ -1047,6 +1040,8 @@ fail: - /* see the flag handling in pcpu_blance_workfn() */ - pcpu_atomic_alloc_failed = true; - pcpu_schedule_balance_work(); -+ } else { -+ mutex_unlock(&pcpu_alloc_mutex); - } - return NULL; - } -@@ -1131,6 +1126,7 @@ static void pcpu_balance_workfn(struct work_struct *work) - if (chunk == list_first_entry(free_head, struct pcpu_chunk, list)) - continue; - -+ list_del_init(&chunk->map_extend_list); - list_move(&chunk->list, &to_free); - } - -@@ -1148,6 +1144,25 @@ static void pcpu_balance_workfn(struct work_struct *work) - pcpu_destroy_chunk(chunk); - } - -+ /* service chunks which requested async area map extension */ -+ do { -+ int new_alloc = 0; -+ -+ spin_lock_irq(&pcpu_lock); -+ -+ chunk = list_first_entry_or_null(&pcpu_map_extend_chunks, -+ struct pcpu_chunk, map_extend_list); -+ if (chunk) { -+ list_del_init(&chunk->map_extend_list); -+ new_alloc = pcpu_need_to_extend(chunk, false); -+ } -+ -+ spin_unlock_irq(&pcpu_lock); -+ -+ if (new_alloc) -+ pcpu_extend_area_map(chunk, new_alloc); -+ } while (chunk); -+ - /* - * Ensure there are certain number of free populated pages for - * atomic allocs. Fill up from the most packed so that atomic -@@ -1646,7 +1661,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, - */ - schunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0); - INIT_LIST_HEAD(&schunk->list); -- INIT_WORK(&schunk->map_extend_work, pcpu_map_extend_workfn); -+ INIT_LIST_HEAD(&schunk->map_extend_list); - schunk->base_addr = base_addr; - schunk->map = smap; - schunk->map_alloc = ARRAY_SIZE(smap); -@@ -1675,7 +1690,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, - if (dyn_size) { - dchunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0); - INIT_LIST_HEAD(&dchunk->list); -- INIT_WORK(&dchunk->map_extend_work, pcpu_map_extend_workfn); -+ INIT_LIST_HEAD(&dchunk->map_extend_list); - dchunk->base_addr = base_addr; - dchunk->map = dmap; - dchunk->map_alloc = ARRAY_SIZE(dmap); -diff --git a/mm/shmem.c b/mm/shmem.c -index ea5a70cfc1d8..1b11ccc0a3b7 100644 ---- a/mm/shmem.c -+++ b/mm/shmem.c -@@ -2153,9 +2153,11 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, - NULL); - if (error) { - /* Remove the !PageUptodate pages we added */ -- shmem_undo_range(inode, -- (loff_t)start << PAGE_CACHE_SHIFT, -- (loff_t)index << PAGE_CACHE_SHIFT, true); -+ if (index > start) { -+ shmem_undo_range(inode, -+ (loff_t)start << PAGE_CACHE_SHIFT, -+ ((loff_t)index << PAGE_CACHE_SHIFT) - 1, true); -+ } - goto undone; - } - -diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c -index 12e700332010..4ab6ead3d8ee 100644 ---- a/net/core/flow_dissector.c -+++ b/net/core/flow_dissector.c -@@ -662,6 +662,23 @@ void make_flow_keys_digest(struct flow_keys_digest *digest, - } - EXPORT_SYMBOL(make_flow_keys_digest); - -+static struct flow_dissector flow_keys_dissector_symmetric __read_mostly; -+ -+u32 __skb_get_hash_symmetric(struct sk_buff *skb) -+{ -+ struct flow_keys keys; -+ -+ __flow_hash_secret_init(); -+ -+ memset(&keys, 0, sizeof(keys)); -+ __skb_flow_dissect(skb, &flow_keys_dissector_symmetric, &keys, -+ NULL, 0, 0, 0, -+ FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL); -+ -+ return __flow_hash_from_keys(&keys, hashrnd); -+} -+EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric); -+ - /** - * __skb_get_hash: calculate a flow hash - * @skb: sk_buff to calculate flow hash from -@@ -874,6 +891,29 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = { - }, - }; - -+static const struct flow_dissector_key flow_keys_dissector_symmetric_keys[] = { -+ { -+ .key_id = FLOW_DISSECTOR_KEY_CONTROL, -+ .offset = offsetof(struct flow_keys, control), -+ }, -+ { -+ .key_id = FLOW_DISSECTOR_KEY_BASIC, -+ .offset = offsetof(struct flow_keys, basic), -+ }, -+ { -+ .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS, -+ .offset = offsetof(struct flow_keys, addrs.v4addrs), -+ }, -+ { -+ .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS, -+ .offset = offsetof(struct flow_keys, addrs.v6addrs), -+ }, -+ { -+ .key_id = FLOW_DISSECTOR_KEY_PORTS, -+ .offset = offsetof(struct flow_keys, ports), -+ }, -+}; -+ - static const struct flow_dissector_key flow_keys_buf_dissector_keys[] = { - { - .key_id = FLOW_DISSECTOR_KEY_CONTROL, -@@ -895,6 +935,9 @@ static int __init init_default_flow_dissectors(void) - skb_flow_dissector_init(&flow_keys_dissector, - flow_keys_dissector_keys, - ARRAY_SIZE(flow_keys_dissector_keys)); -+ skb_flow_dissector_init(&flow_keys_dissector_symmetric, -+ flow_keys_dissector_symmetric_keys, -+ ARRAY_SIZE(flow_keys_dissector_symmetric_keys)); - skb_flow_dissector_init(&flow_keys_buf_dissector, - flow_keys_buf_dissector_keys, - ARRAY_SIZE(flow_keys_buf_dissector_keys)); -diff --git a/net/core/skbuff.c b/net/core/skbuff.c -index 9835d9a8a7a4..4968b5ddea69 100644 ---- a/net/core/skbuff.c -+++ b/net/core/skbuff.c -@@ -2948,24 +2948,6 @@ int skb_append_pagefrags(struct sk_buff *skb, struct page *page, - EXPORT_SYMBOL_GPL(skb_append_pagefrags); - - /** -- * skb_push_rcsum - push skb and update receive checksum -- * @skb: buffer to update -- * @len: length of data pulled -- * -- * This function performs an skb_push on the packet and updates -- * the CHECKSUM_COMPLETE checksum. It should be used on -- * receive path processing instead of skb_push unless you know -- * that the checksum difference is zero (e.g., a valid IP header) -- * or you are setting ip_summed to CHECKSUM_NONE. -- */ --static unsigned char *skb_push_rcsum(struct sk_buff *skb, unsigned len) --{ -- skb_push(skb, len); -- skb_postpush_rcsum(skb, skb->data, len); -- return skb->data; --} -- --/** - * skb_pull_rcsum - pull skb and update receive checksum - * @skb: buffer to update - * @len: length of data pulled -diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c -index 0c7e276c230e..34cf46d74554 100644 ---- a/net/ipv6/ip6_fib.c -+++ b/net/ipv6/ip6_fib.c -@@ -179,6 +179,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt) - } - } - -+ free_percpu(non_pcpu_rt->rt6i_pcpu); - non_pcpu_rt->rt6i_pcpu = NULL; - } - -diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c -index 6f85b6ab8e51..f7bb6829b415 100644 ---- a/net/mac80211/mesh.c -+++ b/net/mac80211/mesh.c -@@ -151,19 +151,26 @@ u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata) - void mesh_sta_cleanup(struct sta_info *sta) - { - struct ieee80211_sub_if_data *sdata = sta->sdata; -- u32 changed; -+ u32 changed = 0; - - /* - * maybe userspace handles peer allocation and peering, but in either - * case the beacon is still generated by the kernel and we might need - * an update. - */ -- changed = mesh_accept_plinks_update(sdata); -+ if (sdata->u.mesh.user_mpm && -+ sta->mesh->plink_state == NL80211_PLINK_ESTAB) -+ changed |= mesh_plink_dec_estab_count(sdata); -+ changed |= mesh_accept_plinks_update(sdata); - if (!sdata->u.mesh.user_mpm) { - changed |= mesh_plink_deactivate(sta); - del_timer_sync(&sta->mesh->plink_timer); - } - -+ /* make sure no readers can access nexthop sta from here on */ -+ mesh_path_flush_by_nexthop(sta); -+ synchronize_net(); -+ - if (changed) - ieee80211_mbss_info_change_notify(sdata, changed); - } -diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h -index 2cafb21b422f..15b0150283b6 100644 ---- a/net/mac80211/sta_info.h -+++ b/net/mac80211/sta_info.h -@@ -269,7 +269,7 @@ struct ieee80211_fast_tx { - u8 sa_offs, da_offs, pn_offs; - u8 band; - u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV + -- sizeof(rfc1042_header)]; -+ sizeof(rfc1042_header)] __aligned(2); - - struct rcu_head rcu_head; - }; -diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c -index 9cc7b512b472..a86f26d05bc2 100644 ---- a/net/packet/af_packet.c -+++ b/net/packet/af_packet.c -@@ -1341,7 +1341,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f, - struct sk_buff *skb, - unsigned int num) - { -- return reciprocal_scale(skb_get_hash(skb), num); -+ return reciprocal_scale(__skb_get_hash_symmetric(skb), num); - } - - static unsigned int fanout_demux_lb(struct packet_fanout *f, -diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c -index 32fcdecdb9e2..e384d6aefa3a 100644 ---- a/net/sched/act_mirred.c -+++ b/net/sched/act_mirred.c -@@ -170,7 +170,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, - - if (!(at & AT_EGRESS)) { - if (m->tcfm_ok_push) -- skb_push(skb2, skb->mac_len); -+ skb_push_rcsum(skb2, skb->mac_len); - } - - /* mirror is always swallowed */ -diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c -index 23608eb0ded2..7a93922457ff 100644 ---- a/net/sunrpc/clnt.c -+++ b/net/sunrpc/clnt.c -@@ -442,7 +442,7 @@ out_no_rpciod: - return ERR_PTR(err); - } - --struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, -+static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, - struct rpc_xprt *xprt) - { - struct rpc_clnt *clnt = NULL; -@@ -474,7 +474,6 @@ struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, - - return clnt; - } --EXPORT_SYMBOL_GPL(rpc_create_xprt); - - /** - * rpc_create - create an RPC client and transport with one call -@@ -500,6 +499,15 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) - }; - char servername[48]; - -+ if (args->bc_xprt) { -+ WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP); -+ xprt = args->bc_xprt->xpt_bc_xprt; -+ if (xprt) { -+ xprt_get(xprt); -+ return rpc_create_xprt(args, xprt); -+ } -+ } -+ - if (args->flags & RPC_CLNT_CREATE_INFINITE_SLOTS) - xprtargs.flags |= XPRT_CREATE_INFINITE_SLOTS; - if (args->flags & RPC_CLNT_CREATE_NO_IDLE_TIMEOUT) -diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c -index 898a53a562b8..6579fd6e7459 100644 ---- a/net/unix/af_unix.c -+++ b/net/unix/af_unix.c -@@ -315,7 +315,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i) - &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { - struct dentry *dentry = unix_sk(s)->path.dentry; - -- if (dentry && d_backing_inode(dentry) == i) { -+ if (dentry && d_real_inode(dentry) == i) { - sock_hold(s); - goto found; - } -@@ -911,7 +911,7 @@ static struct sock *unix_find_other(struct net *net, - err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path); - if (err) - goto fail; -- inode = d_backing_inode(path.dentry); -+ inode = d_real_inode(path.dentry); - err = inode_permission(inode, MAY_WRITE); - if (err) - goto put_fail; -@@ -1048,7 +1048,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - goto out_up; - } - addr->hash = UNIX_HASH_SIZE; -- hash = d_backing_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); -+ hash = d_real_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); - spin_lock(&unix_table_lock); - u->path = u_path; - list = &unix_socket_table[hash]; -diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c -index 5b96206e9aab..9f5cdd49ff0b 100644 ---- a/scripts/mod/file2alias.c -+++ b/scripts/mod/file2alias.c -@@ -695,7 +695,7 @@ static int do_of_entry (const char *filename, void *symval, char *alias) - len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*", - (*type)[0] ? *type : "*"); - -- if (compatible[0]) -+ if ((*compatible)[0]) - sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "", - *compatible); - -diff --git a/security/keys/key.c b/security/keys/key.c -index ab7997ded725..534808915371 100644 ---- a/security/keys/key.c -+++ b/security/keys/key.c -@@ -578,7 +578,7 @@ int key_reject_and_link(struct key *key, - - mutex_unlock(&key_construction_mutex); - -- if (keyring) -+ if (keyring && link_ret == 0) - __key_link_end(keyring, &key->index_key, edit); - - /* wake up anyone waiting for a key to be constructed */ -diff --git a/sound/core/control.c b/sound/core/control.c -index a85d45595d02..b4fe9b002512 100644 ---- a/sound/core/control.c -+++ b/sound/core/control.c -@@ -160,6 +160,8 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask, - - if (snd_BUG_ON(!card || !id)) - return; -+ if (card->shutdown) -+ return; - read_lock(&card->ctl_files_rwlock); - #if IS_ENABLED(CONFIG_SND_MIXER_OSS) - card->mixer_oss_change_count++; -diff --git a/sound/core/pcm.c b/sound/core/pcm.c -index 308c9ecf73db..8e980aa678d0 100644 ---- a/sound/core/pcm.c -+++ b/sound/core/pcm.c -@@ -849,6 +849,14 @@ int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, - } - EXPORT_SYMBOL(snd_pcm_new_internal); - -+static void free_chmap(struct snd_pcm_str *pstr) -+{ -+ if (pstr->chmap_kctl) { -+ snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl); -+ pstr->chmap_kctl = NULL; -+ } -+} -+ - static void snd_pcm_free_stream(struct snd_pcm_str * pstr) - { - struct snd_pcm_substream *substream, *substream_next; -@@ -871,6 +879,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) - kfree(setup); - } - #endif -+ free_chmap(pstr); - if (pstr->substream_count) - put_device(&pstr->dev); - } -@@ -1135,10 +1144,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) - for (cidx = 0; cidx < 2; cidx++) { - if (!pcm->internal) - snd_unregister_device(&pcm->streams[cidx].dev); -- if (pcm->streams[cidx].chmap_kctl) { -- snd_ctl_remove(pcm->card, pcm->streams[cidx].chmap_kctl); -- pcm->streams[cidx].chmap_kctl = NULL; -- } -+ free_chmap(&pcm->streams[cidx]); - } - mutex_unlock(&pcm->open_mutex); - mutex_unlock(®ister_mutex); -diff --git a/sound/core/timer.c b/sound/core/timer.c -index b982d1b089bd..7c6155f5865b 100644 ---- a/sound/core/timer.c -+++ b/sound/core/timer.c -@@ -1961,6 +1961,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, - - qhead = tu->qhead++; - tu->qhead %= tu->queue_size; -+ tu->qused--; - spin_unlock_irq(&tu->qlock); - - if (tu->tread) { -@@ -1974,7 +1975,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, - } - - spin_lock_irq(&tu->qlock); -- tu->qused--; - if (err < 0) - goto _error; - result += unit; -diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c -index a9f7a75702d2..67628616506e 100644 ---- a/sound/drivers/dummy.c -+++ b/sound/drivers/dummy.c -@@ -420,6 +420,7 @@ static int dummy_hrtimer_stop(struct snd_pcm_substream *substream) - - static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) - { -+ hrtimer_cancel(&dpcm->timer); - tasklet_kill(&dpcm->tasklet); - } - -diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c -index 4667c3232b7f..74177189063c 100644 ---- a/sound/pci/au88x0/au88x0_core.c -+++ b/sound/pci/au88x0/au88x0_core.c -@@ -1444,9 +1444,8 @@ static int vortex_wtdma_bufshift(vortex_t * vortex, int wtdma) - int page, p, pp, delta, i; - - page = -- (hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)) & -- WT_SUBBUF_MASK) -- >> WT_SUBBUF_SHIFT; -+ (hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)) -+ >> WT_SUBBUF_SHIFT) & WT_SUBBUF_MASK; - if (dma->nr_periods >= 4) - delta = (page - dma->period_real) & 3; - else { -diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c -index 1cb85aeb0cea..286f5e3686a3 100644 ---- a/sound/pci/echoaudio/echoaudio.c -+++ b/sound/pci/echoaudio/echoaudio.c -@@ -2200,11 +2200,11 @@ static int snd_echo_resume(struct device *dev) - u32 pipe_alloc_mask; - int err; - -- commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); -+ commpage_bak = kmalloc(sizeof(*commpage), GFP_KERNEL); - if (commpage_bak == NULL) - return -ENOMEM; - commpage = chip->comm_page; -- memcpy(commpage_bak, commpage, sizeof(struct comm_page)); -+ memcpy(commpage_bak, commpage, sizeof(*commpage)); - - err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); - if (err < 0) { -diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c -index 367dbf0d285e..dc2fa576d60d 100644 ---- a/sound/pci/hda/hda_generic.c -+++ b/sound/pci/hda/hda_generic.c -@@ -3994,6 +3994,8 @@ static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid, - - for (n = 0; n < spec->paths.used; n++) { - path = snd_array_elem(&spec->paths, n); -+ if (!path->depth) -+ continue; - if (path->path[0] == nid || - path->path[path->depth - 1] == nid) { - bool pin_old = path->pin_enabled; -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index 1475440b70aa..8218cace8fea 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -361,9 +361,10 @@ enum { - #define IS_SKL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d70) - #define IS_KBL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa171) - #define IS_KBL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d71) -+#define IS_KBL_H(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa2f0) - #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) - #define IS_SKL_PLUS(pci) (IS_SKL(pci) || IS_SKL_LP(pci) || IS_BXT(pci)) || \ -- IS_KBL(pci) || IS_KBL_LP(pci) -+ IS_KBL(pci) || IS_KBL_LP(pci) || IS_KBL_H(pci) - - static char *driver_short_names[] = { - [AZX_DRIVER_ICH] = "HDA Intel", -@@ -1255,8 +1256,10 @@ 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) { -@@ -2213,6 +2216,9 @@ static const struct pci_device_id azx_ids[] = { - /* Kabylake-LP */ - { PCI_DEVICE(0x8086, 0x9d71), - .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_SKYLAKE }, -+ /* Kabylake-H */ -+ { PCI_DEVICE(0x8086, 0xa2f0), -+ .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_SKYLAKE }, - /* Broxton-P(Apollolake) */ - { PCI_DEVICE(0x8086, 0x5a98), - .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_BROXTON }, -@@ -2286,6 +2292,8 @@ static const struct pci_device_id azx_ids[] = { - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0x157a), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, -+ { PCI_DEVICE(0x1002, 0x15b3), -+ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0x793b), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0x7919), -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 0fe18ede3e85..abcb5a6a1cd9 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -5650,6 +5650,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK), - SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK), - SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE), -+ SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460), -+ SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460), -+ SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460), - SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), - SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), - SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), -@@ -5735,7 +5738,6 @@ static const struct hda_model_fixup alc269_fixup_models[] = { - {} - }; - #define ALC225_STANDARD_PINS \ -- {0x12, 0xb7a60130}, \ - {0x21, 0x04211020} - - #define ALC256_STANDARD_PINS \ -@@ -5760,10 +5762,24 @@ static const struct hda_model_fixup alc269_fixup_models[] = { - static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC225_STANDARD_PINS, -+ {0x12, 0xb7a60130}, - {0x14, 0x901701a0}), - SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC225_STANDARD_PINS, -+ {0x12, 0xb7a60130}, - {0x14, 0x901701b0}), -+ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, -+ ALC225_STANDARD_PINS, -+ {0x12, 0xb7a60150}, -+ {0x14, 0x901701a0}), -+ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, -+ ALC225_STANDARD_PINS, -+ {0x12, 0xb7a60150}, -+ {0x14, 0x901701b0}), -+ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, -+ ALC225_STANDARD_PINS, -+ {0x12, 0xb7a60130}, -+ {0x1b, 0x90170110}), - SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, - {0x14, 0x90170110}, - {0x21, 0x02211020}), -@@ -5832,6 +5848,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - {0x14, 0x90170120}, - {0x21, 0x02211030}), - SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, -+ {0x12, 0x90a60170}, -+ {0x14, 0x90170120}, -+ {0x21, 0x02211030}), -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC256_STANDARD_PINS), - SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, - {0x12, 0x90a60130}, -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index fefbf2d148ef..510df220d1b5 100644 ---- a/virt/kvm/kvm_main.c -+++ b/virt/kvm/kvm_main.c -@@ -2861,7 +2861,7 @@ static long kvm_vm_ioctl(struct file *filp, - if (copy_from_user(&routing, argp, sizeof(routing))) - goto out; - r = -EINVAL; -- if (routing.nr >= KVM_MAX_IRQ_ROUTES) -+ if (routing.nr > KVM_MAX_IRQ_ROUTES) - goto out; - if (routing.flags) - goto out; diff --git a/patch/kernel/marvell-dev/patch-4.4.16-17.patch b/patch/kernel/marvell-dev/patch-4.4.16-17.patch deleted file mode 100644 index c0fb1a6e94..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.16-17.patch +++ /dev/null @@ -1,2074 +0,0 @@ -diff --git a/Makefile b/Makefile -index da7621cadc8e..76d34f763a41 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 16 -+SUBLEVEL = 17 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arc/Makefile b/arch/arc/Makefile -index aeb19021099e..209d8451e23d 100644 ---- a/arch/arc/Makefile -+++ b/arch/arc/Makefile -@@ -48,8 +48,6 @@ endif - - endif - --cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables -- - # By default gcc 4.8 generates dwarf4 which kernel unwinder can't grok - ifeq ($(atleast_gcc48),y) - cflags-$(CONFIG_ARC_DW2_UNWIND) += -gdwarf-2 -diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c -index 001de4ce711e..11b50959f20e 100644 ---- a/arch/arc/kernel/stacktrace.c -+++ b/arch/arc/kernel/stacktrace.c -@@ -142,7 +142,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, - * prelogue is setup (callee regs saved and then fp set and not other - * way around - */ -- pr_warn("CONFIG_ARC_DW2_UNWIND needs to be enabled\n"); -+ pr_warn_once("CONFIG_ARC_DW2_UNWIND needs to be enabled\n"); - return 0; - - #endif -diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h -index 7a6bed5c08bc..baad72e4c100 100644 ---- a/arch/x86/include/asm/pvclock.h -+++ b/arch/x86/include/asm/pvclock.h -@@ -76,6 +76,8 @@ unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, - u8 ret_flags; - - version = src->version; -+ /* Make the latest version visible */ -+ smp_rmb(); - - offset = pvclock_get_nsec_offset(src); - ret = src->system_time + offset; -diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c -index 7abb2b88572e..1e7de3cefc9c 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel_ds.c -+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c -@@ -1110,6 +1110,13 @@ get_next_pebs_record_by_bit(void *base, void *top, int bit) - void *at; - u64 pebs_status; - -+ /* -+ * fmt0 does not have a status bitfield (does not use -+ * perf_record_nhm format) -+ */ -+ if (x86_pmu.intel_cap.pebs_format < 1) -+ return base; -+ - if (base == NULL) - return NULL; - -@@ -1195,7 +1202,7 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs) - if (!event->attr.precise_ip) - return; - -- n = (top - at) / x86_pmu.pebs_record_size; -+ n = top - at; - if (n <= 0) - return; - -diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c -index db9a675e751b..9fdf1d330727 100644 ---- a/arch/x86/kernel/early-quirks.c -+++ b/arch/x86/kernel/early-quirks.c -@@ -11,7 +11,11 @@ - - #include - #include -+#include -+#include - #include -+#include -+#include - #include - #include - #include -@@ -21,6 +25,9 @@ - #include - #include - #include -+#include -+ -+#define dev_err(msg) pr_err("pci 0000:%02x:%02x.%d: %s", bus, slot, func, msg) - - static void __init fix_hypertransport_config(int num, int slot, int func) - { -@@ -76,6 +83,13 @@ static void __init nvidia_bugs(int num, int slot, int func) - #ifdef CONFIG_ACPI - #ifdef CONFIG_X86_IO_APIC - /* -+ * Only applies to Nvidia root ports (bus 0) and not to -+ * Nvidia graphics cards with PCI ports on secondary buses. -+ */ -+ if (num) -+ return; -+ -+ /* - * All timer overrides on Nvidia are - * wrong unless HPET is enabled. - * Unfortunately that's not true on many Asus boards. -@@ -589,6 +603,61 @@ static void __init force_disable_hpet(int num, int slot, int func) - #endif - } - -+#define BCM4331_MMIO_SIZE 16384 -+#define BCM4331_PM_CAP 0x40 -+#define bcma_aread32(reg) ioread32(mmio + 1 * BCMA_CORE_SIZE + reg) -+#define bcma_awrite32(reg, val) iowrite32(val, mmio + 1 * BCMA_CORE_SIZE + reg) -+ -+static void __init apple_airport_reset(int bus, int slot, int func) -+{ -+ void __iomem *mmio; -+ u16 pmcsr; -+ u64 addr; -+ int i; -+ -+ if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) -+ return; -+ -+ /* Card may have been put into PCI_D3hot by grub quirk */ -+ pmcsr = read_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL); -+ -+ if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) { -+ pmcsr &= ~PCI_PM_CTRL_STATE_MASK; -+ write_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL, pmcsr); -+ mdelay(10); -+ -+ pmcsr = read_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL); -+ if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) { -+ dev_err("Cannot power up Apple AirPort card\n"); -+ return; -+ } -+ } -+ -+ addr = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0); -+ addr |= (u64)read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_1) << 32; -+ addr &= PCI_BASE_ADDRESS_MEM_MASK; -+ -+ mmio = early_ioremap(addr, BCM4331_MMIO_SIZE); -+ if (!mmio) { -+ dev_err("Cannot iomap Apple AirPort card\n"); -+ return; -+ } -+ -+ pr_info("Resetting Apple AirPort card (left enabled by EFI)\n"); -+ -+ for (i = 0; bcma_aread32(BCMA_RESET_ST) && i < 30; i++) -+ udelay(10); -+ -+ bcma_awrite32(BCMA_RESET_CTL, BCMA_RESET_CTL_RESET); -+ bcma_aread32(BCMA_RESET_CTL); -+ udelay(1); -+ -+ bcma_awrite32(BCMA_RESET_CTL, 0); -+ bcma_aread32(BCMA_RESET_CTL); -+ udelay(10); -+ -+ early_iounmap(mmio, BCM4331_MMIO_SIZE); -+} - - #define QFLAG_APPLY_ONCE 0x1 - #define QFLAG_APPLIED 0x2 -@@ -602,12 +671,6 @@ struct chipset { - void (*f)(int num, int slot, int func); - }; - --/* -- * Only works for devices on the root bus. If you add any devices -- * not on bus 0 readd another loop level in early_quirks(). But -- * be careful because at least the Nvidia quirk here relies on -- * only matching on bus 0. -- */ - static struct chipset early_qrk[] __initdata = { - { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, - PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, nvidia_bugs }, -@@ -637,9 +700,13 @@ static struct chipset early_qrk[] __initdata = { - */ - { PCI_VENDOR_ID_INTEL, 0x0f00, - PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet}, -+ { PCI_VENDOR_ID_BROADCOM, 0x4331, -+ PCI_CLASS_NETWORK_OTHER, PCI_ANY_ID, 0, apple_airport_reset}, - {} - }; - -+static void __init early_pci_scan_bus(int bus); -+ - /** - * check_dev_quirk - apply early quirks to a given PCI device - * @num: bus number -@@ -648,7 +715,7 @@ static struct chipset early_qrk[] __initdata = { - * - * Check the vendor & device ID against the early quirks table. - * -- * If the device is single function, let early_quirks() know so we don't -+ * If the device is single function, let early_pci_scan_bus() know so we don't - * poke at this device again. - */ - static int __init check_dev_quirk(int num, int slot, int func) -@@ -657,6 +724,7 @@ static int __init check_dev_quirk(int num, int slot, int func) - u16 vendor; - u16 device; - u8 type; -+ u8 sec; - int i; - - class = read_pci_config_16(num, slot, func, PCI_CLASS_DEVICE); -@@ -684,25 +752,36 @@ static int __init check_dev_quirk(int num, int slot, int func) - - type = read_pci_config_byte(num, slot, func, - PCI_HEADER_TYPE); -+ -+ if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) { -+ sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS); -+ if (sec > num) -+ early_pci_scan_bus(sec); -+ } -+ - if (!(type & 0x80)) - return -1; - - return 0; - } - --void __init early_quirks(void) -+static void __init early_pci_scan_bus(int bus) - { - int slot, func; - -- if (!early_pci_allowed()) -- return; -- - /* Poor man's PCI discovery */ -- /* Only scan the root bus */ - for (slot = 0; slot < 32; slot++) - for (func = 0; func < 8; func++) { - /* Only probe function 0 on single fn devices */ -- if (check_dev_quirk(0, slot, func)) -+ if (check_dev_quirk(bus, slot, func)) - break; - } - } -+ -+void __init early_quirks(void) -+{ -+ if (!early_pci_allowed()) -+ return; -+ -+ early_pci_scan_bus(0); -+} -diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c -index 2f355d229a58..bf0ce75735b0 100644 ---- a/arch/x86/kernel/pvclock.c -+++ b/arch/x86/kernel/pvclock.c -@@ -66,6 +66,8 @@ u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src) - - do { - version = __pvclock_read_cycles(src, &ret, &flags); -+ /* Make sure that the version double-check is last. */ -+ smp_rmb(); - } while ((src->version & 1) || version != src->version); - - return flags & valid_flags; -@@ -80,6 +82,8 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) - - do { - version = __pvclock_read_cycles(src, &ret, &flags); -+ /* Make sure that the version double-check is last. */ -+ smp_rmb(); - } while ((src->version & 1) || version != src->version); - - if (unlikely((flags & PVCLOCK_GUEST_STOPPED) != 0)) { -diff --git a/block/ioprio.c b/block/ioprio.c -index cc7800e9eb44..01b8116298a1 100644 ---- a/block/ioprio.c -+++ b/block/ioprio.c -@@ -150,8 +150,10 @@ static int get_task_ioprio(struct task_struct *p) - if (ret) - goto out; - ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM); -+ task_lock(p); - if (p->io_context) - ret = p->io_context->ioprio; -+ task_unlock(p); - out: - return ret; - } -diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c -index b79cb10e289e..bd370c98f77d 100644 ---- a/drivers/ata/libata-core.c -+++ b/drivers/ata/libata-core.c -@@ -4138,6 +4138,12 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { - */ - { "ST380013AS", "3.20", ATA_HORKAGE_MAX_SEC_1024 }, - -+ /* -+ * Device times out with higher max sects. -+ * https://bugzilla.kernel.org/show_bug.cgi?id=121671 -+ */ -+ { "LITEON CX1-JB256-HP", NULL, ATA_HORKAGE_MAX_SEC_1024 }, -+ - /* Devices we expect to fail diagnostics */ - - /* Devices where NCQ should be avoided */ -diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h -index 38f156745d53..71df8f2afc6c 100644 ---- a/drivers/bcma/bcma_private.h -+++ b/drivers/bcma/bcma_private.h -@@ -8,8 +8,6 @@ - #include - #include - --#define BCMA_CORE_SIZE 0x1000 -- - #define bcma_err(bus, fmt, ...) \ - pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__) - #define bcma_warn(bus, fmt, ...) \ -diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c -index 2685644826a0..33c20c6b45af 100644 ---- a/drivers/clk/rockchip/clk-mmc-phase.c -+++ b/drivers/clk/rockchip/clk-mmc-phase.c -@@ -153,6 +153,7 @@ struct clk *rockchip_clk_register_mmc(const char *name, - return NULL; - - init.name = name; -+ init.flags = 0; - init.num_parents = num_parents; - init.parent_names = parent_names; - init.ops = &rockchip_mmc_clk_ops; -diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c -index 02f9aa4ebe05..e44a1bfb0250 100644 ---- a/drivers/dma/at_xdmac.c -+++ b/drivers/dma/at_xdmac.c -@@ -242,7 +242,7 @@ struct at_xdmac_lld { - u32 mbr_dus; /* Destination Microblock Stride Register */ - }; - -- -+/* 64-bit alignment needed to update CNDA and CUBC registers in an atomic way. */ - struct at_xdmac_desc { - struct at_xdmac_lld lld; - enum dma_transfer_direction direction; -@@ -253,7 +253,7 @@ struct at_xdmac_desc { - unsigned int xfer_size; - struct list_head descs_list; - struct list_head xfer_node; --}; -+} __aligned(sizeof(u64)); - - static inline void __iomem *at_xdmac_chan_reg_base(struct at_xdmac *atxdmac, unsigned int chan_nb) - { -@@ -1388,6 +1388,7 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, - u32 cur_nda, check_nda, cur_ubc, mask, value; - u8 dwidth = 0; - unsigned long flags; -+ bool initd; - - ret = dma_cookie_status(chan, cookie, txstate); - if (ret == DMA_COMPLETE) -@@ -1412,7 +1413,16 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, - residue = desc->xfer_size; - /* - * Flush FIFO: only relevant when the transfer is source peripheral -- * synchronized. -+ * synchronized. Flush is needed before reading CUBC because data in -+ * the FIFO are not reported by CUBC. Reporting a residue of the -+ * transfer length while we have data in FIFO can cause issue. -+ * Usecase: atmel USART has a timeout which means I have received -+ * characters but there is no more character received for a while. On -+ * timeout, it requests the residue. If the data are in the DMA FIFO, -+ * we will return a residue of the transfer length. It means no data -+ * received. If an application is waiting for these data, it will hang -+ * since we won't have another USART timeout without receiving new -+ * data. - */ - mask = AT_XDMAC_CC_TYPE | AT_XDMAC_CC_DSYNC; - value = AT_XDMAC_CC_TYPE_PER_TRAN | AT_XDMAC_CC_DSYNC_PER2MEM; -@@ -1423,34 +1433,43 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, - } - - /* -- * When processing the residue, we need to read two registers but we -- * can't do it in an atomic way. AT_XDMAC_CNDA is used to find where -- * we stand in the descriptor list and AT_XDMAC_CUBC is used -- * to know how many data are remaining for the current descriptor. -- * Since the dma channel is not paused to not loose data, between the -- * AT_XDMAC_CNDA and AT_XDMAC_CUBC read, we may have change of -- * descriptor. -- * For that reason, after reading AT_XDMAC_CUBC, we check if we are -- * still using the same descriptor by reading a second time -- * AT_XDMAC_CNDA. If AT_XDMAC_CNDA has changed, it means we have to -- * read again AT_XDMAC_CUBC. -+ * The easiest way to compute the residue should be to pause the DMA -+ * but doing this can lead to miss some data as some devices don't -+ * have FIFO. -+ * We need to read several registers because: -+ * - DMA is running therefore a descriptor change is possible while -+ * reading these registers -+ * - When the block transfer is done, the value of the CUBC register -+ * is set to its initial value until the fetch of the next descriptor. -+ * This value will corrupt the residue calculation so we have to skip -+ * it. -+ * -+ * INITD -------- ------------ -+ * |____________________| -+ * _______________________ _______________ -+ * NDA @desc2 \/ @desc3 -+ * _______________________/\_______________ -+ * __________ ___________ _______________ -+ * CUBC 0 \/ MAX desc1 \/ MAX desc2 -+ * __________/\___________/\_______________ -+ * -+ * Since descriptors are aligned on 64 bits, we can assume that -+ * the update of NDA and CUBC is atomic. - * Memory barriers are used to ensure the read order of the registers. -- * A max number of retries is set because unlikely it can never ends if -- * we are transferring a lot of data with small buffers. -+ * A max number of retries is set because unlikely it could never ends. - */ -- cur_nda = at_xdmac_chan_read(atchan, AT_XDMAC_CNDA) & 0xfffffffc; -- rmb(); -- cur_ubc = at_xdmac_chan_read(atchan, AT_XDMAC_CUBC); - for (retry = 0; retry < AT_XDMAC_RESIDUE_MAX_RETRIES; retry++) { -- rmb(); - check_nda = at_xdmac_chan_read(atchan, AT_XDMAC_CNDA) & 0xfffffffc; -- -- if (likely(cur_nda == check_nda)) -- break; -- -- cur_nda = check_nda; -+ rmb(); -+ initd = !!(at_xdmac_chan_read(atchan, AT_XDMAC_CC) & AT_XDMAC_CC_INITD); - rmb(); - cur_ubc = at_xdmac_chan_read(atchan, AT_XDMAC_CUBC); -+ rmb(); -+ cur_nda = at_xdmac_chan_read(atchan, AT_XDMAC_CNDA) & 0xfffffffc; -+ rmb(); -+ -+ if ((check_nda == cur_nda) && initd) -+ break; - } - - if (unlikely(retry >= AT_XDMAC_RESIDUE_MAX_RETRIES)) { -@@ -1459,6 +1478,19 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, - } - - /* -+ * Flush FIFO: only relevant when the transfer is source peripheral -+ * synchronized. Another flush is needed here because CUBC is updated -+ * when the controller sends the data write command. It can lead to -+ * report data that are not written in the memory or the device. The -+ * FIFO flush ensures that data are really written. -+ */ -+ if ((desc->lld.mbr_cfg & mask) == value) { -+ at_xdmac_write(atxdmac, AT_XDMAC_GSWF, atchan->mask); -+ while (!(at_xdmac_chan_read(atchan, AT_XDMAC_CIS) & AT_XDMAC_CIS_FIS)) -+ cpu_relax(); -+ } -+ -+ /* - * Remove size of all microblocks already transferred and the current - * one. Then add the remaining size to transfer of the current - * microblock. -diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c -index 165d3001c301..c6ec5c62b7a9 100644 ---- a/drivers/hwtracing/intel_th/core.c -+++ b/drivers/hwtracing/intel_th/core.c -@@ -419,6 +419,38 @@ static struct intel_th_subdevice { - }, - }; - -+#ifdef CONFIG_MODULES -+static void __intel_th_request_hub_module(struct work_struct *work) -+{ -+ struct intel_th *th = container_of(work, struct intel_th, -+ request_module_work); -+ -+ request_module("intel_th_%s", th->hub->name); -+} -+ -+static int intel_th_request_hub_module(struct intel_th *th) -+{ -+ INIT_WORK(&th->request_module_work, __intel_th_request_hub_module); -+ schedule_work(&th->request_module_work); -+ -+ return 0; -+} -+ -+static void intel_th_request_hub_module_flush(struct intel_th *th) -+{ -+ flush_work(&th->request_module_work); -+} -+#else -+static inline int intel_th_request_hub_module(struct intel_th *th) -+{ -+ return -EINVAL; -+} -+ -+static inline void intel_th_request_hub_module_flush(struct intel_th *th) -+{ -+} -+#endif /* CONFIG_MODULES */ -+ - static int intel_th_populate(struct intel_th *th, struct resource *devres, - unsigned int ndevres, int irq) - { -@@ -488,7 +520,7 @@ static int intel_th_populate(struct intel_th *th, struct resource *devres, - /* need switch driver to be loaded to enumerate the rest */ - if (subdev->type == INTEL_TH_SWITCH && !req) { - th->hub = thdev; -- err = request_module("intel_th_%s", subdev->name); -+ err = intel_th_request_hub_module(th); - if (!err) - req++; - } -@@ -603,6 +635,7 @@ void intel_th_free(struct intel_th *th) - { - int i; - -+ intel_th_request_hub_module_flush(th); - for (i = 0; i < TH_SUBDEVICE_MAX; i++) - if (th->thdev[i] != th->hub) - intel_th_device_remove(th->thdev[i]); -diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h -index 57fd72b20fae..d03a6cd1c65d 100644 ---- a/drivers/hwtracing/intel_th/intel_th.h -+++ b/drivers/hwtracing/intel_th/intel_th.h -@@ -197,6 +197,9 @@ struct intel_th { - - int id; - int major; -+#ifdef CONFIG_MODULES -+ struct work_struct request_module_work; -+#endif /* CONFIG_MODULES */ - #ifdef CONFIG_INTEL_TH_DEBUG - struct dentry *dbg; - #endif -diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c -index 641e87936064..d57a2f75dccf 100644 ---- a/drivers/hwtracing/intel_th/pci.c -+++ b/drivers/hwtracing/intel_th/pci.c -@@ -67,6 +67,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = { - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa126), - .driver_data = (kernel_ulong_t)0, - }, -+ { -+ /* Kaby Lake PCH-H */ -+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6), -+ .driver_data = (kernel_ulong_t)0, -+ }, - { 0 }, - }; - -diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c -index 5fbd5bd0878f..49fc2c7e560a 100644 ---- a/drivers/i2c/muxes/i2c-mux-reg.c -+++ b/drivers/i2c/muxes/i2c-mux-reg.c -@@ -150,7 +150,7 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, - mux->data.idle_in_use = true; - - /* map address from "reg" if exists */ -- if (of_address_to_resource(np, 0, &res)) { -+ if (of_address_to_resource(np, 0, &res) == 0) { - mux->data.reg_size = resource_size(&res); - mux->data.reg = devm_ioremap_resource(&pdev->dev, &res); - if (IS_ERR(mux->data.reg)) -diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c -index fd4100d56d8c..2b2f9d66c2c7 100644 ---- a/drivers/input/joystick/xpad.c -+++ b/drivers/input/joystick/xpad.c -@@ -1200,22 +1200,15 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id - int ep_irq_in_idx; - int i, error; - -+ if (intf->cur_altsetting->desc.bNumEndpoints != 2) -+ return -ENODEV; -+ - for (i = 0; xpad_device[i].idVendor; i++) { - if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && - (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) - break; - } - -- if (xpad_device[i].xtype == XTYPE_XBOXONE && -- intf->cur_altsetting->desc.bInterfaceNumber != 0) { -- /* -- * The Xbox One controller lists three interfaces all with the -- * same interface class, subclass and protocol. Differentiate by -- * interface number. -- */ -- return -ENODEV; -- } -- - xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); - if (!xpad) - return -ENOMEM; -@@ -1246,6 +1239,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id - if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { - if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) - xpad->xtype = XTYPE_XBOX360W; -+ else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) -+ xpad->xtype = XTYPE_XBOXONE; - else - xpad->xtype = XTYPE_XBOX360; - } else { -@@ -1260,6 +1255,17 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id - xpad->mapping |= MAP_STICKS_TO_NULL; - } - -+ if (xpad->xtype == XTYPE_XBOXONE && -+ intf->cur_altsetting->desc.bInterfaceNumber != 0) { -+ /* -+ * The Xbox One controller lists three interfaces all with the -+ * same interface class, subclass and protocol. Differentiate by -+ * interface number. -+ */ -+ error = -ENODEV; -+ goto err_free_in_urb; -+ } -+ - error = xpad_init_output(intf, xpad); - if (error) - goto err_free_in_urb; -diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c -index 78f93cf68840..be5b399da5d3 100644 ---- a/drivers/input/mouse/elantech.c -+++ b/drivers/input/mouse/elantech.c -@@ -1568,13 +1568,7 @@ static int elantech_set_properties(struct elantech_data *etd) - case 5: - etd->hw_version = 3; - break; -- case 6: -- case 7: -- case 8: -- case 9: -- case 10: -- case 13: -- case 14: -+ case 6 ... 14: - etd->hw_version = 4; - break; - default: -diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c -index a3f0f5a47490..0f586780ceb4 100644 ---- a/drivers/input/mouse/vmmouse.c -+++ b/drivers/input/mouse/vmmouse.c -@@ -355,18 +355,11 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) - return -ENXIO; - } - -- if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) { -- psmouse_dbg(psmouse, "VMMouse port in use.\n"); -- return -EBUSY; -- } -- - /* Check if the device is present */ - response = ~VMMOUSE_PROTO_MAGIC; - VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2); -- if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) { -- release_region(VMMOUSE_PROTO_PORT, 4); -+ if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) - return -ENXIO; -- } - - if (set_properties) { - psmouse->vendor = VMMOUSE_VENDOR; -@@ -374,8 +367,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) - psmouse->model = version; - } - -- release_region(VMMOUSE_PROTO_PORT, 4); -- - return 0; - } - -@@ -394,7 +385,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse) - psmouse_reset(psmouse); - input_unregister_device(priv->abs_dev); - kfree(priv); -- release_region(VMMOUSE_PROTO_PORT, 4); - } - - /** -@@ -438,15 +428,10 @@ int vmmouse_init(struct psmouse *psmouse) - struct input_dev *rel_dev = psmouse->dev, *abs_dev; - int error; - -- if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) { -- psmouse_dbg(psmouse, "VMMouse port in use.\n"); -- return -EBUSY; -- } -- - psmouse_reset(psmouse); - error = vmmouse_enable(psmouse); - if (error) -- goto release_region; -+ return error; - - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - abs_dev = input_allocate_device(); -@@ -502,8 +487,5 @@ init_fail: - kfree(priv); - psmouse->private = NULL; - --release_region: -- release_region(VMMOUSE_PROTO_PORT, 4); -- - return error; - } -diff --git a/drivers/input/touchscreen/tsc2004.c b/drivers/input/touchscreen/tsc2004.c -index 7295c198aa08..6fe55d598fac 100644 ---- a/drivers/input/touchscreen/tsc2004.c -+++ b/drivers/input/touchscreen/tsc2004.c -@@ -22,6 +22,11 @@ - #include - #include "tsc200x-core.h" - -+static const struct input_id tsc2004_input_id = { -+ .bustype = BUS_I2C, -+ .product = 2004, -+}; -+ - static int tsc2004_cmd(struct device *dev, u8 cmd) - { - u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; -@@ -42,7 +47,7 @@ static int tsc2004_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) - - { -- return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C, -+ return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id, - devm_regmap_init_i2c(i2c, &tsc200x_regmap_config), - tsc2004_cmd); - } -diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c -index b9f593dfd2ef..f2c5f0e47f77 100644 ---- a/drivers/input/touchscreen/tsc2005.c -+++ b/drivers/input/touchscreen/tsc2005.c -@@ -24,6 +24,11 @@ - #include - #include "tsc200x-core.h" - -+static const struct input_id tsc2005_input_id = { -+ .bustype = BUS_SPI, -+ .product = 2005, -+}; -+ - static int tsc2005_cmd(struct device *dev, u8 cmd) - { - u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; -@@ -62,7 +67,7 @@ static int tsc2005_probe(struct spi_device *spi) - if (error) - return error; - -- return tsc200x_probe(&spi->dev, spi->irq, BUS_SPI, -+ return tsc200x_probe(&spi->dev, spi->irq, &tsc2005_input_id, - devm_regmap_init_spi(spi, &tsc200x_regmap_config), - tsc2005_cmd); - } -diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c -index 15240c1ee850..dfa7f1c4f545 100644 ---- a/drivers/input/touchscreen/tsc200x-core.c -+++ b/drivers/input/touchscreen/tsc200x-core.c -@@ -450,7 +450,7 @@ static void tsc200x_close(struct input_dev *input) - mutex_unlock(&ts->mutex); - } - --int tsc200x_probe(struct device *dev, int irq, __u16 bustype, -+int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, - struct regmap *regmap, - int (*tsc200x_cmd)(struct device *dev, u8 cmd)) - { -@@ -547,9 +547,18 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype, - snprintf(ts->phys, sizeof(ts->phys), - "%s/input-ts", dev_name(dev)); - -- input_dev->name = "TSC200X touchscreen"; -+ if (tsc_id->product == 2004) { -+ input_dev->name = "TSC200X touchscreen"; -+ } else { -+ input_dev->name = devm_kasprintf(dev, GFP_KERNEL, -+ "TSC%04d touchscreen", -+ tsc_id->product); -+ if (!input_dev->name) -+ return -ENOMEM; -+ } -+ - input_dev->phys = ts->phys; -- input_dev->id.bustype = bustype; -+ input_dev->id = *tsc_id; - input_dev->dev.parent = dev; - input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -diff --git a/drivers/input/touchscreen/tsc200x-core.h b/drivers/input/touchscreen/tsc200x-core.h -index 7a482d102614..49a63a3c6840 100644 ---- a/drivers/input/touchscreen/tsc200x-core.h -+++ b/drivers/input/touchscreen/tsc200x-core.h -@@ -70,7 +70,7 @@ - extern const struct regmap_config tsc200x_regmap_config; - extern const struct dev_pm_ops tsc200x_pm_ops; - --int tsc200x_probe(struct device *dev, int irq, __u16 bustype, -+int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, - struct regmap *regmap, - int (*tsc200x_cmd)(struct device *dev, u8 cmd)); - int tsc200x_remove(struct device *dev); -diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c -index 2792ca397dd0..3ed0ce1e4dcb 100644 ---- a/drivers/input/touchscreen/wacom_w8001.c -+++ b/drivers/input/touchscreen/wacom_w8001.c -@@ -27,7 +27,7 @@ MODULE_AUTHOR("Jaya Kumar "); - MODULE_DESCRIPTION(DRIVER_DESC); - MODULE_LICENSE("GPL"); - --#define W8001_MAX_LENGTH 11 -+#define W8001_MAX_LENGTH 13 - #define W8001_LEAD_MASK 0x80 - #define W8001_LEAD_BYTE 0x80 - #define W8001_TAB_MASK 0x40 -diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c -index 565a59310747..34b35ebd60ac 100644 ---- a/drivers/media/usb/airspy/airspy.c -+++ b/drivers/media/usb/airspy/airspy.c -@@ -1073,7 +1073,7 @@ static int airspy_probe(struct usb_interface *intf, - if (ret) { - dev_err(s->dev, "Failed to register as video device (%d)\n", - ret); -- goto err_unregister_v4l2_dev; -+ goto err_free_controls; - } - dev_info(s->dev, "Registered as %s\n", - video_device_node_name(&s->vdev)); -@@ -1082,7 +1082,6 @@ static int airspy_probe(struct usb_interface *intf, - - err_free_controls: - v4l2_ctrl_handler_free(&s->hdl); --err_unregister_v4l2_dev: - v4l2_device_unregister(&s->v4l2_dev); - err_free_mem: - kfree(s); -diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c -index c641c202fe7e..64950035613b 100644 ---- a/drivers/mmc/card/block.c -+++ b/drivers/mmc/card/block.c -@@ -1767,8 +1767,8 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq, - - packed_cmd_hdr = packed->cmd_hdr; - memset(packed_cmd_hdr, 0, sizeof(packed->cmd_hdr)); -- packed_cmd_hdr[0] = (packed->nr_entries << 16) | -- (PACKED_CMD_WR << 8) | PACKED_CMD_VER; -+ packed_cmd_hdr[0] = cpu_to_le32((packed->nr_entries << 16) | -+ (PACKED_CMD_WR << 8) | PACKED_CMD_VER); - hdr_blocks = mmc_large_sector(card) ? 8 : 1; - - /* -@@ -1782,14 +1782,14 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq, - ((brq->data.blocks * brq->data.blksz) >= - card->ext_csd.data_tag_unit_size); - /* Argument of CMD23 */ -- packed_cmd_hdr[(i * 2)] = -+ packed_cmd_hdr[(i * 2)] = cpu_to_le32( - (do_rel_wr ? MMC_CMD23_ARG_REL_WR : 0) | - (do_data_tag ? MMC_CMD23_ARG_TAG_REQ : 0) | -- blk_rq_sectors(prq); -+ blk_rq_sectors(prq)); - /* Argument of CMD18 or CMD25 */ -- packed_cmd_hdr[((i * 2)) + 1] = -+ packed_cmd_hdr[((i * 2)) + 1] = cpu_to_le32( - mmc_card_blockaddr(card) ? -- blk_rq_pos(prq) : blk_rq_pos(prq) << 9; -+ blk_rq_pos(prq) : blk_rq_pos(prq) << 9); - packed->blocks += blk_rq_sectors(prq); - i++; - } -diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c -index 8b3275d7792a..8f5e93cb7975 100644 ---- a/drivers/net/can/at91_can.c -+++ b/drivers/net/can/at91_can.c -@@ -712,9 +712,10 @@ static int at91_poll_rx(struct net_device *dev, int quota) - - /* upper group completed, look again in lower */ - if (priv->rx_next > get_mb_rx_low_last(priv) && -- quota > 0 && mb > get_mb_rx_last(priv)) { -+ mb > get_mb_rx_last(priv)) { - priv->rx_next = get_mb_rx_first(priv); -- goto again; -+ if (quota > 0) -+ goto again; - } - - return received; -diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c -index f91b094288da..e3dccd3200d5 100644 ---- a/drivers/net/can/c_can/c_can.c -+++ b/drivers/net/can/c_can/c_can.c -@@ -332,9 +332,23 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface, - - priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl); - -- for (i = 0; i < frame->can_dlc; i += 2) { -- priv->write_reg(priv, C_CAN_IFACE(DATA1_REG, iface) + i / 2, -- frame->data[i] | (frame->data[i + 1] << 8)); -+ if (priv->type == BOSCH_D_CAN) { -+ u32 data = 0, dreg = C_CAN_IFACE(DATA1_REG, iface); -+ -+ for (i = 0; i < frame->can_dlc; i += 4, dreg += 2) { -+ data = (u32)frame->data[i]; -+ data |= (u32)frame->data[i + 1] << 8; -+ data |= (u32)frame->data[i + 2] << 16; -+ data |= (u32)frame->data[i + 3] << 24; -+ priv->write_reg32(priv, dreg, data); -+ } -+ } else { -+ for (i = 0; i < frame->can_dlc; i += 2) { -+ priv->write_reg(priv, -+ C_CAN_IFACE(DATA1_REG, iface) + i / 2, -+ frame->data[i] | -+ (frame->data[i + 1] << 8)); -+ } - } - } - -@@ -402,10 +416,20 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl) - } else { - int i, dreg = C_CAN_IFACE(DATA1_REG, iface); - -- for (i = 0; i < frame->can_dlc; i += 2, dreg ++) { -- data = priv->read_reg(priv, dreg); -- frame->data[i] = data; -- frame->data[i + 1] = data >> 8; -+ if (priv->type == BOSCH_D_CAN) { -+ for (i = 0; i < frame->can_dlc; i += 4, dreg += 2) { -+ data = priv->read_reg32(priv, dreg); -+ frame->data[i] = data; -+ frame->data[i + 1] = data >> 8; -+ frame->data[i + 2] = data >> 16; -+ frame->data[i + 3] = data >> 24; -+ } -+ } else { -+ for (i = 0; i < frame->can_dlc; i += 2, dreg++) { -+ data = priv->read_reg(priv, dreg); -+ frame->data[i] = data; -+ frame->data[i + 1] = data >> 8; -+ } - } - } - -diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c -index 910c12e2638e..ad535a854e5c 100644 ---- a/drivers/net/can/dev.c -+++ b/drivers/net/can/dev.c -@@ -798,6 +798,9 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[]) - * - control mode with CAN_CTRLMODE_FD set - */ - -+ if (!data) -+ return 0; -+ - if (data[IFLA_CAN_CTRLMODE]) { - struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]); - -@@ -1008,6 +1011,11 @@ static int can_newlink(struct net *src_net, struct net_device *dev, - return -EOPNOTSUPP; - } - -+static void can_dellink(struct net_device *dev, struct list_head *head) -+{ -+ return; -+} -+ - static struct rtnl_link_ops can_link_ops __read_mostly = { - .kind = "can", - .maxtype = IFLA_CAN_MAX, -@@ -1016,6 +1024,7 @@ static struct rtnl_link_ops can_link_ops __read_mostly = { - .validate = can_validate, - .newlink = can_newlink, - .changelink = can_changelink, -+ .dellink = can_dellink, - .get_size = can_get_size, - .fill_info = can_fill_info, - .get_xstats_size = can_get_xstats_size, -diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c -index 1029aa7889b5..398ec45aadef 100644 ---- a/drivers/pinctrl/freescale/pinctrl-imx.c -+++ b/drivers/pinctrl/freescale/pinctrl-imx.c -@@ -207,9 +207,9 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, - pin_reg = &info->pin_regs[pin_id]; - - if (pin_reg->mux_reg == -1) { -- dev_err(ipctl->dev, "Pin(%s) does not support mux function\n", -+ dev_dbg(ipctl->dev, "Pin(%s) does not support mux function\n", - info->pins[pin_id].name); -- return -EINVAL; -+ continue; - } - - if (info->flags & SHARE_MUX_CONF_REG) { -diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c -index 23b6b8c29a99..73d8d47ea465 100644 ---- a/drivers/pinctrl/pinctrl-single.c -+++ b/drivers/pinctrl/pinctrl-single.c -@@ -1576,6 +1576,9 @@ static inline void pcs_irq_set(struct pcs_soc_data *pcs_soc, - else - mask &= ~soc_mask; - pcs->write(mask, pcswi->reg); -+ -+ /* flush posted write */ -+ mask = pcs->read(pcswi->reg); - raw_spin_unlock(&pcs->lock); - } - -diff --git a/drivers/platform/chrome/cros_ec_dev.c b/drivers/platform/chrome/cros_ec_dev.c -index d45cd254ed1c..2b331d5b9e79 100644 ---- a/drivers/platform/chrome/cros_ec_dev.c -+++ b/drivers/platform/chrome/cros_ec_dev.c -@@ -147,13 +147,19 @@ static long ec_device_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg) - goto exit; - } - -+ if (u_cmd.outsize != s_cmd->outsize || -+ u_cmd.insize != s_cmd->insize) { -+ ret = -EINVAL; -+ goto exit; -+ } -+ - s_cmd->command += ec->cmd_offset; - ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd); - /* Only copy data to userland if data was received. */ - if (ret < 0) - goto exit; - -- if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + u_cmd.insize)) -+ if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + s_cmd->insize)) - ret = -EFAULT; - exit: - kfree(s_cmd); -diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c -index 456987c88baa..b13cd074c52a 100644 ---- a/drivers/power/power_supply_core.c -+++ b/drivers/power/power_supply_core.c -@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd, - - WARN_ON(tzd == NULL); - psy = tzd->devdata; -- ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); -+ ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); -+ if (ret) -+ return ret; - - /* Convert tenths of degree Celsius to milli degree Celsius. */ -- if (!ret) -- *temp = val.intval * 100; -+ *temp = val.intval * 100; - - return ret; - } -@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd, - int ret; - - psy = tcd->devdata; -- ret = psy->desc->get_property(psy, -- POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); -- if (!ret) -- *state = val.intval; -+ ret = power_supply_get_property(psy, -+ POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); -+ if (ret) -+ return ret; -+ -+ *state = val.intval; - - return ret; - } -@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd, - int ret; - - psy = tcd->devdata; -- ret = psy->desc->get_property(psy, -- POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); -- if (!ret) -- *state = val.intval; -+ ret = power_supply_get_property(psy, -+ POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); -+ if (ret) -+ return ret; -+ -+ *state = val.intval; - - return ret; - } -diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c -index 38a8bbe74810..83797d89c30f 100644 ---- a/drivers/pps/clients/pps_parport.c -+++ b/drivers/pps/clients/pps_parport.c -@@ -195,7 +195,7 @@ static void parport_detach(struct parport *port) - struct pps_client_pp *device; - - /* FIXME: oooh, this is ugly! */ -- if (strcmp(pardev->name, KBUILD_MODNAME)) -+ if (!pardev || strcmp(pardev->name, KBUILD_MODNAME)) - /* not our port */ - return; - -diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c -index 8f1b091e1732..12b2cb7769f9 100644 ---- a/drivers/s390/net/qeth_l2_main.c -+++ b/drivers/s390/net/qeth_l2_main.c -@@ -1051,6 +1051,7 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) - qeth_l2_set_offline(cgdev); - - if (card->dev) { -+ netif_napi_del(&card->napi); - unregister_netdev(card->dev); - card->dev = NULL; - } -diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c -index 543960e96b42..50cec6b13d27 100644 ---- a/drivers/s390/net/qeth_l3_main.c -+++ b/drivers/s390/net/qeth_l3_main.c -@@ -3246,6 +3246,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) - qeth_l3_set_offline(cgdev); - - if (card->dev) { -+ netif_napi_del(&card->napi); - unregister_netdev(card->dev); - card->dev = NULL; - } -diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c -index 43ac62623bf2..7a58128a0000 100644 ---- a/drivers/scsi/ipr.c -+++ b/drivers/scsi/ipr.c -@@ -10095,6 +10095,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev, - ioa_cfg->intr_flag = IPR_USE_MSI; - else { - ioa_cfg->intr_flag = IPR_USE_LSI; -+ ioa_cfg->clear_isr = 1; - ioa_cfg->nvectors = 1; - dev_info(&pdev->dev, "Cannot enable MSI.\n"); - } -diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c -index 93cbefa75b26..11cdb172cfaf 100644 ---- a/drivers/scsi/scsi_devinfo.c -+++ b/drivers/scsi/scsi_devinfo.c -@@ -426,7 +426,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, - * here, and we don't know what device it is - * trying to work with, leave it as-is. - */ -- vmax = 8; /* max length of vendor */ -+ vmax = sizeof(devinfo->vendor); - vskip = vendor; - while (vmax > 0 && *vskip == ' ') { - vmax--; -@@ -436,7 +436,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, - while (vmax > 0 && vskip[vmax - 1] == ' ') - --vmax; - -- mmax = 16; /* max length of model */ -+ mmax = sizeof(devinfo->model); - mskip = model; - while (mmax > 0 && *mskip == ' ') { - mmax--; -@@ -452,10 +452,12 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, - * Behave like the older version of get_device_flags. - */ - if (memcmp(devinfo->vendor, vskip, vmax) || -- devinfo->vendor[vmax]) -+ (vmax < sizeof(devinfo->vendor) && -+ devinfo->vendor[vmax])) - continue; - if (memcmp(devinfo->model, mskip, mmax) || -- devinfo->model[mmax]) -+ (mmax < sizeof(devinfo->model) && -+ devinfo->model[mmax])) - continue; - return devinfo; - } else { -diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c -index fbb0a4d74e91..39d7c7c70112 100644 ---- a/drivers/spi/spi-sun4i.c -+++ b/drivers/spi/spi-sun4i.c -@@ -170,13 +170,17 @@ static int sun4i_spi_transfer_one(struct spi_master *master, - { - struct sun4i_spi *sspi = spi_master_get_devdata(master); - unsigned int mclk_rate, div, timeout; -+ unsigned int start, end, tx_time; - unsigned int tx_len = 0; - int ret = 0; - u32 reg; - - /* We don't support transfer larger than the FIFO */ - if (tfr->len > SUN4I_FIFO_DEPTH) -- return -EINVAL; -+ return -EMSGSIZE; -+ -+ if (tfr->tx_buf && tfr->len >= SUN4I_FIFO_DEPTH) -+ return -EMSGSIZE; - - reinit_completion(&sspi->done); - sspi->tx_buf = tfr->tx_buf; -@@ -269,8 +273,12 @@ static int sun4i_spi_transfer_one(struct spi_master *master, - sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len)); - sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len)); - -- /* Fill the TX FIFO */ -- sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH); -+ /* -+ * Fill the TX FIFO -+ * Filling the FIFO fully causes timeout for some reason -+ * at least on spi2 on A10s -+ */ -+ sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH - 1); - - /* Enable the interrupts */ - sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC); -@@ -279,9 +287,16 @@ static int sun4i_spi_transfer_one(struct spi_master *master, - reg = sun4i_spi_read(sspi, SUN4I_CTL_REG); - sun4i_spi_write(sspi, SUN4I_CTL_REG, reg | SUN4I_CTL_XCH); - -+ tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U); -+ start = jiffies; - timeout = wait_for_completion_timeout(&sspi->done, -- msecs_to_jiffies(1000)); -+ msecs_to_jiffies(tx_time)); -+ end = jiffies; - if (!timeout) { -+ dev_warn(&master->dev, -+ "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", -+ dev_name(&spi->dev), tfr->len, tfr->speed_hz, -+ jiffies_to_msecs(end - start), tx_time); - ret = -ETIMEDOUT; - goto out; - } -diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c -index ac48f59705a8..e77add01b0e9 100644 ---- a/drivers/spi/spi-sun6i.c -+++ b/drivers/spi/spi-sun6i.c -@@ -160,6 +160,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master, - { - struct sun6i_spi *sspi = spi_master_get_devdata(master); - unsigned int mclk_rate, div, timeout; -+ unsigned int start, end, tx_time; - unsigned int tx_len = 0; - int ret = 0; - u32 reg; -@@ -269,9 +270,16 @@ static int sun6i_spi_transfer_one(struct spi_master *master, - reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG); - sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg | SUN6I_TFR_CTL_XCH); - -+ tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U); -+ start = jiffies; - timeout = wait_for_completion_timeout(&sspi->done, -- msecs_to_jiffies(1000)); -+ msecs_to_jiffies(tx_time)); -+ end = jiffies; - if (!timeout) { -+ dev_warn(&master->dev, -+ "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", -+ dev_name(&spi->dev), tfr->len, tfr->speed_hz, -+ jiffies_to_msecs(end - start), tx_time); - ret = -ETIMEDOUT; - goto out; - } -diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c -index d029bbe9eb36..641fed609911 100644 ---- a/drivers/usb/host/ohci-q.c -+++ b/drivers/usb/host/ohci-q.c -@@ -183,7 +183,6 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) - { - int branch; - -- ed->state = ED_OPER; - ed->ed_prev = NULL; - ed->ed_next = NULL; - ed->hwNextED = 0; -@@ -259,6 +258,8 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) - /* the HC may not see the schedule updates yet, but if it does - * then they'll be properly ordered. - */ -+ -+ ed->state = ED_OPER; - return 0; - } - -diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c -index 9c234209d8b5..47a4177b16d2 100644 ---- a/drivers/xen/xen-pciback/conf_space.c -+++ b/drivers/xen/xen-pciback/conf_space.c -@@ -183,8 +183,7 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size, - field_start = OFFSET(cfg_entry); - field_end = OFFSET(cfg_entry) + field->size; - -- if ((req_start >= field_start && req_start < field_end) -- || (req_end > field_start && req_end <= field_end)) { -+ if (req_end > field_start && field_end > req_start) { - err = conf_space_read(dev, cfg_entry, field_start, - &tmp_val); - if (err) -@@ -230,8 +229,7 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value) - field_start = OFFSET(cfg_entry); - field_end = OFFSET(cfg_entry) + field->size; - -- if ((req_start >= field_start && req_start < field_end) -- || (req_end > field_start && req_end <= field_end)) { -+ if (req_end > field_start && field_end > req_start) { - tmp_val = 0; - - err = xen_pcibk_config_read(dev, field_start, -diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c -index 9433e46518c8..531e76474983 100644 ---- a/drivers/xen/xenbus/xenbus_dev_frontend.c -+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c -@@ -316,11 +316,18 @@ static int xenbus_write_transaction(unsigned msg_type, - rc = -ENOMEM; - goto out; - } -+ } else { -+ list_for_each_entry(trans, &u->transactions, list) -+ if (trans->handle.id == u->u.msg.tx_id) -+ break; -+ if (&trans->list == &u->transactions) -+ return -ESRCH; - } - - reply = xenbus_dev_request_and_reply(&u->u.msg); - if (IS_ERR(reply)) { -- kfree(trans); -+ if (msg_type == XS_TRANSACTION_START) -+ kfree(trans); - rc = PTR_ERR(reply); - goto out; - } -@@ -333,12 +340,7 @@ static int xenbus_write_transaction(unsigned msg_type, - list_add(&trans->list, &u->transactions); - } - } else if (u->u.msg.type == XS_TRANSACTION_END) { -- list_for_each_entry(trans, &u->transactions, list) -- if (trans->handle.id == u->u.msg.tx_id) -- break; -- BUG_ON(&trans->list == &u->transactions); - list_del(&trans->list); -- - kfree(trans); - } - -diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c -index ba804f3d8278..ce65591b4168 100644 ---- a/drivers/xen/xenbus/xenbus_xs.c -+++ b/drivers/xen/xenbus/xenbus_xs.c -@@ -250,9 +250,6 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg) - - mutex_unlock(&xs_state.request_mutex); - -- if (IS_ERR(ret)) -- return ret; -- - if ((msg->type == XS_TRANSACTION_END) || - ((req_msg.type == XS_TRANSACTION_START) && - (msg->type == XS_ERROR))) -diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c -index 7bf835f85bc8..12ceaf52dae6 100644 ---- a/fs/9p/vfs_file.c -+++ b/fs/9p/vfs_file.c -@@ -74,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) - v9fs_proto_dotu(v9ses)); - fid = file->private_data; - if (!fid) { -- fid = v9fs_fid_clone(file->f_path.dentry); -+ fid = v9fs_fid_clone(file_dentry(file)); - if (IS_ERR(fid)) - return PTR_ERR(fid); - -@@ -100,7 +100,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) - * because we want write after unlink usecase - * to work. - */ -- fid = v9fs_writeback_fid(file->f_path.dentry); -+ fid = v9fs_writeback_fid(file_dentry(file)); - if (IS_ERR(fid)) { - err = PTR_ERR(fid); - mutex_unlock(&v9inode->v_mutex); -@@ -516,7 +516,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma) - * because we want write after unlink usecase - * to work. - */ -- fid = v9fs_writeback_fid(filp->f_path.dentry); -+ fid = v9fs_writeback_fid(file_dentry(filp)); - if (IS_ERR(fid)) { - retval = PTR_ERR(fid); - mutex_unlock(&v9inode->v_mutex); -diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c -index feef8a9c4de7..11309683d65f 100644 ---- a/fs/ecryptfs/file.c -+++ b/fs/ecryptfs/file.c -@@ -170,6 +170,19 @@ out: - return rc; - } - -+static int ecryptfs_mmap(struct file *file, struct vm_area_struct *vma) -+{ -+ struct file *lower_file = ecryptfs_file_to_lower(file); -+ /* -+ * Don't allow mmap on top of file systems that don't support it -+ * natively. If FILESYSTEM_MAX_STACK_DEPTH > 2 or ecryptfs -+ * allows recursive mounting, this will need to be extended. -+ */ -+ if (!lower_file->f_op->mmap) -+ return -ENODEV; -+ return generic_file_mmap(file, vma); -+} -+ - /** - * ecryptfs_open - * @inode: inode speciying file to open -@@ -364,7 +377,7 @@ const struct file_operations ecryptfs_main_fops = { - #ifdef CONFIG_COMPAT - .compat_ioctl = ecryptfs_compat_ioctl, - #endif -- .mmap = generic_file_mmap, -+ .mmap = ecryptfs_mmap, - .open = ecryptfs_open, - .flush = ecryptfs_flush, - .release = ecryptfs_release, -diff --git a/fs/ecryptfs/kthread.c b/fs/ecryptfs/kthread.c -index e818f5ac7a26..866bb18efefe 100644 ---- a/fs/ecryptfs/kthread.c -+++ b/fs/ecryptfs/kthread.c -@@ -25,7 +25,6 @@ - #include - #include - #include --#include - #include "ecryptfs_kernel.h" - - struct ecryptfs_open_req { -@@ -148,7 +147,7 @@ int ecryptfs_privileged_open(struct file **lower_file, - flags |= IS_RDONLY(d_inode(lower_dentry)) ? O_RDONLY : O_RDWR; - (*lower_file) = dentry_open(&req.path, flags, cred); - if (!IS_ERR(*lower_file)) -- goto have_file; -+ goto out; - if ((flags & O_ACCMODE) == O_RDONLY) { - rc = PTR_ERR((*lower_file)); - goto out; -@@ -166,16 +165,8 @@ int ecryptfs_privileged_open(struct file **lower_file, - mutex_unlock(&ecryptfs_kthread_ctl.mux); - wake_up(&ecryptfs_kthread_ctl.wait); - wait_for_completion(&req.done); -- if (IS_ERR(*lower_file)) { -+ if (IS_ERR(*lower_file)) - rc = PTR_ERR(*lower_file); -- goto out; -- } --have_file: -- if ((*lower_file)->f_op->mmap == NULL) { -- fput(*lower_file); -- *lower_file = NULL; -- rc = -EMEDIUMTYPE; -- } - out: - return rc; - } -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 3578b25fccfd..62880586ed85 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -469,6 +469,10 @@ static int __ext4_ext_check(const char *function, unsigned int line, - error_msg = "invalid extent entries"; - goto corrupted; - } -+ if (unlikely(depth > 32)) { -+ error_msg = "too large eh_depth"; -+ goto corrupted; -+ } - /* Verify checksum on non-root extent tree nodes */ - if (ext_depth(inode) != depth && - !ext4_extent_block_csum_verify(inode, eh)) { -diff --git a/fs/inode.c b/fs/inode.c -index 1be5f9003eb3..b0edef500590 100644 ---- a/fs/inode.c -+++ b/fs/inode.c -@@ -1733,8 +1733,8 @@ static int __remove_privs(struct dentry *dentry, int kill) - */ - int file_remove_privs(struct file *file) - { -- struct dentry *dentry = file->f_path.dentry; -- struct inode *inode = d_inode(dentry); -+ struct dentry *dentry = file_dentry(file); -+ struct inode *inode = file_inode(file); - int kill; - int error = 0; - -@@ -1742,7 +1742,7 @@ int file_remove_privs(struct file *file) - if (IS_NOSEC(inode)) - return 0; - -- kill = file_needs_remove_privs(file); -+ kill = dentry_needs_remove_privs(dentry); - if (kill < 0) - return kill; - if (kill) -diff --git a/fs/locks.c b/fs/locks.c -index 6333263b7bc8..8eddae23e10b 100644 ---- a/fs/locks.c -+++ b/fs/locks.c -@@ -1602,7 +1602,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr - { - struct file_lock *fl, *my_fl = NULL, *lease; - struct dentry *dentry = filp->f_path.dentry; -- struct inode *inode = dentry->d_inode; -+ struct inode *inode = file_inode(filp); - struct file_lock_context *ctx; - bool is_deleg = (*flp)->fl_flags & FL_DELEG; - int error; -diff --git a/fs/namespace.c b/fs/namespace.c -index 33064fcbfff9..5be02a0635be 100644 ---- a/fs/namespace.c -+++ b/fs/namespace.c -@@ -1562,6 +1562,7 @@ void __detach_mounts(struct dentry *dentry) - goto out_unlock; - - lock_mount_hash(); -+ event++; - while (!hlist_empty(&mp->m_list)) { - mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list); - if (mnt->mnt.mnt_flags & MNT_UMOUNT) { -diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c -index 69bd801afb53..37e49cb2ac4c 100644 ---- a/fs/nilfs2/the_nilfs.c -+++ b/fs/nilfs2/the_nilfs.c -@@ -443,7 +443,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp) - if (!sbp || le16_to_cpu(sbp->s_magic) != NILFS_SUPER_MAGIC) - return 0; - bytes = le16_to_cpu(sbp->s_bytes); -- if (bytes > BLOCK_SIZE) -+ if (bytes < sumoff + 4 || bytes > BLOCK_SIZE) - return 0; - crc = crc32_le(le32_to_cpu(sbp->s_crc_seed), (unsigned char *)sbp, - sumoff); -diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c -index 0597820f5d9d..4f729ffff75d 100644 ---- a/fs/overlayfs/inode.c -+++ b/fs/overlayfs/inode.c -@@ -63,6 +63,9 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) - if (!err) { - upperdentry = ovl_dentry_upper(dentry); - -+ if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) -+ attr->ia_valid &= ~ATTR_MODE; -+ - mutex_lock(&upperdentry->d_inode->i_mutex); - err = notify_change(upperdentry, attr, NULL); - if (!err) -diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h -index c4bd0e2c173c..ef2e8c97e183 100644 ---- a/include/asm-generic/vmlinux.lds.h -+++ b/include/asm-generic/vmlinux.lds.h -@@ -531,15 +531,19 @@ - - #define INIT_TEXT \ - *(.init.text) \ -+ *(.text.startup) \ - MEM_DISCARD(init.text) - - #define EXIT_DATA \ - *(.exit.data) \ -+ *(.fini_array) \ -+ *(.dtors) \ - MEM_DISCARD(exit.data) \ - MEM_DISCARD(exit.rodata) - - #define EXIT_TEXT \ - *(.exit.text) \ -+ *(.text.exit) \ - MEM_DISCARD(exit.text) - - #define EXIT_CALL \ -diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h -index 3feb1b2d75d8..14cd6f77e284 100644 ---- a/include/linux/bcma/bcma.h -+++ b/include/linux/bcma/bcma.h -@@ -156,6 +156,7 @@ struct bcma_host_ops { - #define BCMA_CORE_DEFAULT 0xFFF - - #define BCMA_MAX_NR_CORES 16 -+#define BCMA_CORE_SIZE 0x1000 - - /* Chip IDs of PCIe devices */ - #define BCMA_CHIP_ID_BCM4313 0x4313 -diff --git a/kernel/cgroup.c b/kernel/cgroup.c -index 1c9d701f7a72..a3424f28aaf4 100644 ---- a/kernel/cgroup.c -+++ b/kernel/cgroup.c -@@ -4793,6 +4793,7 @@ static void init_and_link_css(struct cgroup_subsys_state *css, - memset(css, 0, sizeof(*css)); - css->cgroup = cgrp; - css->ss = ss; -+ css->id = -1; - INIT_LIST_HEAD(&css->sibling); - INIT_LIST_HEAD(&css->children); - css->serial_nr = css_serial_nr_next++; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 6c0cdb5a73f8..67d1e1597d9c 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -4951,14 +4951,16 @@ void show_state_filter(unsigned long state_filter) - /* - * reset the NMI-timeout, listing all files on a slow - * console might take a lot of time: -+ * Also, reset softlockup watchdogs on all CPUs, because -+ * another CPU might be blocked waiting for us to process -+ * an IPI. - */ - touch_nmi_watchdog(); -+ touch_all_softlockup_watchdogs(); - if (!state_filter || (p->state & state_filter)) - sched_show_task(p); - } - -- touch_all_softlockup_watchdogs(); -- - #ifdef CONFIG_SCHED_DEBUG - sysrq_sched_debug_show(); - #endif -diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 51c615279b23..b8b516c37bf1 100644 ---- a/kernel/sched/fair.c -+++ b/kernel/sched/fair.c -@@ -687,8 +687,6 @@ void init_entity_runnable_average(struct sched_entity *se) - /* when this task enqueue'ed, it will contribute to its cfs_rq's load_avg */ - } - --static inline unsigned long cfs_rq_runnable_load_avg(struct cfs_rq *cfs_rq); --static inline unsigned long cfs_rq_load_avg(struct cfs_rq *cfs_rq); - #else - void init_entity_runnable_average(struct sched_entity *se) - { -@@ -4594,19 +4592,24 @@ static long effective_load(struct task_group *tg, int cpu, long wl, long wg) - return wl; - - for_each_sched_entity(se) { -- long w, W; -+ struct cfs_rq *cfs_rq = se->my_q; -+ long W, w = cfs_rq_load_avg(cfs_rq); - -- tg = se->my_q->tg; -+ tg = cfs_rq->tg; - - /* - * W = @wg + \Sum rw_j - */ -- W = wg + calc_tg_weight(tg, se->my_q); -+ W = wg + atomic_long_read(&tg->load_avg); -+ -+ /* Ensure \Sum rw_j >= rw_i */ -+ W -= cfs_rq->tg_load_avg_contrib; -+ W += w; - - /* - * w = rw_i + @wl - */ -- w = cfs_rq_load_avg(se->my_q) + wl; -+ w += wl; - - /* - * wl = S * s'_i; see (2) -diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c -index f5e86d282d52..80016b329d94 100644 ---- a/kernel/time/posix-cpu-timers.c -+++ b/kernel/time/posix-cpu-timers.c -@@ -808,6 +808,7 @@ static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp) - timer->it.cpu.expires = 0; - sample_to_timespec(timer->it_clock, timer->it.cpu.expires, - &itp->it_value); -+ return; - } else { - cpu_timer_sample_group(timer->it_clock, p, &now); - unlock_task_sighand(p, &flags); -diff --git a/mm/compaction.c b/mm/compaction.c -index 7881e072dc33..dba02dec7195 100644 ---- a/mm/compaction.c -+++ b/mm/compaction.c -@@ -475,25 +475,23 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, - - /* Found a free page, break it into order-0 pages */ - isolated = split_free_page(page); -+ if (!isolated) -+ break; -+ - total_isolated += isolated; -+ cc->nr_freepages += isolated; - for (i = 0; i < isolated; i++) { - list_add(&page->lru, freelist); - page++; - } -- -- /* If a page was split, advance to the end of it */ -- if (isolated) { -- cc->nr_freepages += isolated; -- if (!strict && -- cc->nr_migratepages <= cc->nr_freepages) { -- blockpfn += isolated; -- break; -- } -- -- blockpfn += isolated - 1; -- cursor += isolated - 1; -- continue; -+ if (!strict && cc->nr_migratepages <= cc->nr_freepages) { -+ blockpfn += isolated; -+ break; - } -+ /* Advance to the end of split page */ -+ blockpfn += isolated - 1; -+ cursor += isolated - 1; -+ continue; - - isolate_fail: - if (strict) -@@ -503,6 +501,9 @@ isolate_fail: - - } - -+ if (locked) -+ spin_unlock_irqrestore(&cc->zone->lock, flags); -+ - /* - * There is a tiny chance that we have read bogus compound_order(), - * so be careful to not go outside of the pageblock. -@@ -524,9 +525,6 @@ isolate_fail: - if (strict && blockpfn < end_pfn) - total_isolated = 0; - -- if (locked) -- spin_unlock_irqrestore(&cc->zone->lock, flags); -- - /* Update the pageblock-skip if the whole pageblock was scanned */ - if (blockpfn == end_pfn) - update_pageblock_skip(cc, valid_page, total_isolated, false); -@@ -966,7 +964,6 @@ static void isolate_freepages(struct compact_control *cc) - block_end_pfn = block_start_pfn, - block_start_pfn -= pageblock_nr_pages, - isolate_start_pfn = block_start_pfn) { -- - /* - * This can iterate a massively long zone without finding any - * suitable migration targets, so periodically check if we need -@@ -990,32 +987,30 @@ static void isolate_freepages(struct compact_control *cc) - continue; - - /* Found a block suitable for isolating free pages from. */ -- isolate_freepages_block(cc, &isolate_start_pfn, -- block_end_pfn, freelist, false); -+ isolate_freepages_block(cc, &isolate_start_pfn, block_end_pfn, -+ freelist, false); - - /* -- * If we isolated enough freepages, or aborted due to async -- * compaction being contended, terminate the loop. -- * Remember where the free scanner should restart next time, -- * which is where isolate_freepages_block() left off. -- * But if it scanned the whole pageblock, isolate_start_pfn -- * now points at block_end_pfn, which is the start of the next -- * pageblock. -- * In that case we will however want to restart at the start -- * of the previous pageblock. -+ * If we isolated enough freepages, or aborted due to lock -+ * contention, terminate. - */ - if ((cc->nr_freepages >= cc->nr_migratepages) - || cc->contended) { -- if (isolate_start_pfn >= block_end_pfn) -+ if (isolate_start_pfn >= block_end_pfn) { -+ /* -+ * Restart at previous pageblock if more -+ * freepages can be isolated next time. -+ */ - isolate_start_pfn = - block_start_pfn - pageblock_nr_pages; -+ } - break; -- } else { -+ } else if (isolate_start_pfn < block_end_pfn) { - /* -- * isolate_freepages_block() should not terminate -- * prematurely unless contended, or isolated enough -+ * If isolation failed early, do not continue -+ * needlessly. - */ -- VM_BUG_ON(isolate_start_pfn < block_end_pfn); -+ break; - } - } - -diff --git a/mm/internal.h b/mm/internal.h -index 38e24b89e4c4..6979b2bd3227 100644 ---- a/mm/internal.h -+++ b/mm/internal.h -@@ -22,7 +22,8 @@ - */ - #define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\ - __GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\ -- __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC) -+ __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\ -+ __GFP_ATOMIC) - - /* The GFP flags allowed during early boot */ - #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_FS)) -diff --git a/mm/page_alloc.c b/mm/page_alloc.c -index 99c1738684ec..2bcdfbf8c36d 100644 ---- a/mm/page_alloc.c -+++ b/mm/page_alloc.c -@@ -275,7 +275,9 @@ static inline void reset_deferred_meminit(pg_data_t *pgdat) - /* Returns true if the struct page for the pfn is uninitialised */ - static inline bool __meminit early_page_uninitialised(unsigned long pfn) - { -- if (pfn >= NODE_DATA(early_pfn_to_nid(pfn))->first_deferred_pfn) -+ int nid = early_pfn_to_nid(pfn); -+ -+ if (node_online(nid) && pfn >= NODE_DATA(nid)->first_deferred_pfn) - return true; - - return false; -@@ -1057,7 +1059,7 @@ int __meminit early_pfn_to_nid(unsigned long pfn) - spin_lock(&early_pfn_lock); - nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache); - if (nid < 0) -- nid = 0; -+ nid = first_online_node; - spin_unlock(&early_pfn_lock); - - return nid; -diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c -index 7d8f581d9f1f..ddc3573894b0 100644 ---- a/net/ceph/osdmap.c -+++ b/net/ceph/osdmap.c -@@ -1192,6 +1192,115 @@ struct ceph_osdmap *ceph_osdmap_decode(void **p, void *end) - } - - /* -+ * Encoding order is (new_up_client, new_state, new_weight). Need to -+ * apply in the (new_weight, new_state, new_up_client) order, because -+ * an incremental map may look like e.g. -+ * -+ * new_up_client: { osd=6, addr=... } # set osd_state and addr -+ * new_state: { osd=6, xorstate=EXISTS } # clear osd_state -+ */ -+static int decode_new_up_state_weight(void **p, void *end, -+ struct ceph_osdmap *map) -+{ -+ void *new_up_client; -+ void *new_state; -+ void *new_weight_end; -+ u32 len; -+ -+ new_up_client = *p; -+ ceph_decode_32_safe(p, end, len, e_inval); -+ len *= sizeof(u32) + sizeof(struct ceph_entity_addr); -+ ceph_decode_need(p, end, len, e_inval); -+ *p += len; -+ -+ new_state = *p; -+ ceph_decode_32_safe(p, end, len, e_inval); -+ len *= sizeof(u32) + sizeof(u8); -+ ceph_decode_need(p, end, len, e_inval); -+ *p += len; -+ -+ /* new_weight */ -+ ceph_decode_32_safe(p, end, len, e_inval); -+ while (len--) { -+ s32 osd; -+ u32 w; -+ -+ ceph_decode_need(p, end, 2*sizeof(u32), e_inval); -+ osd = ceph_decode_32(p); -+ w = ceph_decode_32(p); -+ BUG_ON(osd >= map->max_osd); -+ pr_info("osd%d weight 0x%x %s\n", osd, w, -+ w == CEPH_OSD_IN ? "(in)" : -+ (w == CEPH_OSD_OUT ? "(out)" : "")); -+ map->osd_weight[osd] = w; -+ -+ /* -+ * If we are marking in, set the EXISTS, and clear the -+ * AUTOOUT and NEW bits. -+ */ -+ if (w) { -+ map->osd_state[osd] |= CEPH_OSD_EXISTS; -+ map->osd_state[osd] &= ~(CEPH_OSD_AUTOOUT | -+ CEPH_OSD_NEW); -+ } -+ } -+ new_weight_end = *p; -+ -+ /* new_state (up/down) */ -+ *p = new_state; -+ len = ceph_decode_32(p); -+ while (len--) { -+ s32 osd; -+ u8 xorstate; -+ int ret; -+ -+ osd = ceph_decode_32(p); -+ xorstate = ceph_decode_8(p); -+ if (xorstate == 0) -+ xorstate = CEPH_OSD_UP; -+ BUG_ON(osd >= map->max_osd); -+ if ((map->osd_state[osd] & CEPH_OSD_UP) && -+ (xorstate & CEPH_OSD_UP)) -+ pr_info("osd%d down\n", osd); -+ if ((map->osd_state[osd] & CEPH_OSD_EXISTS) && -+ (xorstate & CEPH_OSD_EXISTS)) { -+ pr_info("osd%d does not exist\n", osd); -+ map->osd_weight[osd] = CEPH_OSD_IN; -+ ret = set_primary_affinity(map, osd, -+ CEPH_OSD_DEFAULT_PRIMARY_AFFINITY); -+ if (ret) -+ return ret; -+ memset(map->osd_addr + osd, 0, sizeof(*map->osd_addr)); -+ map->osd_state[osd] = 0; -+ } else { -+ map->osd_state[osd] ^= xorstate; -+ } -+ } -+ -+ /* new_up_client */ -+ *p = new_up_client; -+ len = ceph_decode_32(p); -+ while (len--) { -+ s32 osd; -+ struct ceph_entity_addr addr; -+ -+ osd = ceph_decode_32(p); -+ ceph_decode_copy(p, &addr, sizeof(addr)); -+ ceph_decode_addr(&addr); -+ BUG_ON(osd >= map->max_osd); -+ pr_info("osd%d up\n", osd); -+ map->osd_state[osd] |= CEPH_OSD_EXISTS | CEPH_OSD_UP; -+ map->osd_addr[osd] = addr; -+ } -+ -+ *p = new_weight_end; -+ return 0; -+ -+e_inval: -+ return -EINVAL; -+} -+ -+/* - * decode and apply an incremental map update. - */ - struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, -@@ -1290,49 +1399,10 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, - __remove_pg_pool(&map->pg_pools, pi); - } - -- /* new_up */ -- ceph_decode_32_safe(p, end, len, e_inval); -- while (len--) { -- u32 osd; -- struct ceph_entity_addr addr; -- ceph_decode_32_safe(p, end, osd, e_inval); -- ceph_decode_copy_safe(p, end, &addr, sizeof(addr), e_inval); -- ceph_decode_addr(&addr); -- pr_info("osd%d up\n", osd); -- BUG_ON(osd >= map->max_osd); -- map->osd_state[osd] |= CEPH_OSD_UP | CEPH_OSD_EXISTS; -- map->osd_addr[osd] = addr; -- } -- -- /* new_state */ -- ceph_decode_32_safe(p, end, len, e_inval); -- while (len--) { -- u32 osd; -- u8 xorstate; -- ceph_decode_32_safe(p, end, osd, e_inval); -- xorstate = **(u8 **)p; -- (*p)++; /* clean flag */ -- if (xorstate == 0) -- xorstate = CEPH_OSD_UP; -- if (xorstate & CEPH_OSD_UP) -- pr_info("osd%d down\n", osd); -- if (osd < map->max_osd) -- map->osd_state[osd] ^= xorstate; -- } -- -- /* new_weight */ -- ceph_decode_32_safe(p, end, len, e_inval); -- while (len--) { -- u32 osd, off; -- ceph_decode_need(p, end, sizeof(u32)*2, e_inval); -- osd = ceph_decode_32(p); -- off = ceph_decode_32(p); -- pr_info("osd%d weight 0x%x %s\n", osd, off, -- off == CEPH_OSD_IN ? "(in)" : -- (off == CEPH_OSD_OUT ? "(out)" : "")); -- if (osd < map->max_osd) -- map->osd_weight[osd] = off; -- } -+ /* new_up_client, new_state, new_weight */ -+ err = decode_new_up_state_weight(p, end, map); -+ if (err) -+ goto bad; - - /* new_pg_temp */ - err = decode_new_pg_temp(p, end, map); -diff --git a/net/rds/tcp.c b/net/rds/tcp.c -index 9d6ddbacd875..18e50a8fc05f 100644 ---- a/net/rds/tcp.c -+++ b/net/rds/tcp.c -@@ -421,7 +421,7 @@ static int rds_tcp_init(void) - - ret = rds_tcp_recv_init(); - if (ret) -- goto out_slab; -+ goto out_pernet; - - ret = rds_trans_register(&rds_tcp_transport); - if (ret) -@@ -433,8 +433,9 @@ static int rds_tcp_init(void) - - out_recv: - rds_tcp_recv_exit(); --out_slab: -+out_pernet: - unregister_pernet_subsys(&rds_tcp_net_ops); -+out_slab: - kmem_cache_destroy(rds_tcp_conn_slab); - out: - return ret; -diff --git a/sound/core/timer.c b/sound/core/timer.c -index 7c6155f5865b..637d034bb084 100644 ---- a/sound/core/timer.c -+++ b/sound/core/timer.c -@@ -1247,6 +1247,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, - tu->tstamp = *tstamp; - if ((tu->filter & (1 << event)) == 0 || !tu->tread) - return; -+ memset(&r1, 0, sizeof(r1)); - r1.event = event; - r1.tstamp = *tstamp; - r1.val = resolution; -@@ -1281,6 +1282,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, - } - if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && - tu->last_resolution != resolution) { -+ memset(&r1, 0, sizeof(r1)); - r1.event = SNDRV_TIMER_EVENT_RESOLUTION; - r1.tstamp = tstamp; - r1.val = resolution; -@@ -1746,6 +1748,7 @@ static int snd_timer_user_params(struct file *file, - if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { - if (tu->tread) { - struct snd_timer_tread tread; -+ memset(&tread, 0, sizeof(tread)); - tread.event = SNDRV_TIMER_EVENT_EARLY; - tread.tstamp.tv_sec = 0; - tread.tstamp.tv_nsec = 0; diff --git a/patch/kernel/marvell-dev/patch-4.4.17-18.patch b/patch/kernel/marvell-dev/patch-4.4.17-18.patch deleted file mode 100644 index 4306189dc0..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.17-18.patch +++ /dev/null @@ -1,2072 +0,0 @@ -diff --git a/Documentation/x86/pat.txt b/Documentation/x86/pat.txt -index 54944c71b819..2a4ee6302122 100644 ---- a/Documentation/x86/pat.txt -+++ b/Documentation/x86/pat.txt -@@ -196,3 +196,35 @@ Another, more verbose way of getting PAT related debug messages is with - "debugpat" boot parameter. With this parameter, various debug messages are - printed to dmesg log. - -+PAT Initialization -+------------------ -+ -+The following table describes how PAT is initialized under various -+configurations. The PAT MSR must be updated by Linux in order to support WC -+and WT attributes. Otherwise, the PAT MSR has the value programmed in it -+by the firmware. Note, Xen enables WC attribute in the PAT MSR for guests. -+ -+ MTRR PAT Call Sequence PAT State PAT MSR -+ ========================================================= -+ E E MTRR -> PAT init Enabled OS -+ E D MTRR -> PAT init Disabled - -+ D E MTRR -> PAT disable Disabled BIOS -+ D D MTRR -> PAT disable Disabled - -+ - np/E PAT -> PAT disable Disabled BIOS -+ - np/D PAT -> PAT disable Disabled - -+ E !P/E MTRR -> PAT init Disabled BIOS -+ D !P/E MTRR -> PAT disable Disabled BIOS -+ !M !P/E MTRR stub -> PAT disable Disabled BIOS -+ -+ Legend -+ ------------------------------------------------ -+ E Feature enabled in CPU -+ D Feature disabled/unsupported in CPU -+ np "nopat" boot option specified -+ !P CONFIG_X86_PAT option unset -+ !M CONFIG_MTRR option unset -+ Enabled PAT state set to enabled -+ Disabled PAT state set to disabled -+ OS PAT initializes PAT MSR with OS setting -+ BIOS PAT keeps PAT MSR with BIOS setting -+ -diff --git a/Makefile b/Makefile -index 76d34f763a41..eaedea88a8a7 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 17 -+SUBLEVEL = 18 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c -index 087acb569b63..5f221acd21ae 100644 ---- a/arch/arm/kernel/sys_oabi-compat.c -+++ b/arch/arm/kernel/sys_oabi-compat.c -@@ -279,8 +279,12 @@ asmlinkage long sys_oabi_epoll_wait(int epfd, - mm_segment_t fs; - long ret, err, i; - -- if (maxevents <= 0 || maxevents > (INT_MAX/sizeof(struct epoll_event))) -+ if (maxevents <= 0 || -+ maxevents > (INT_MAX/sizeof(*kbuf)) || -+ maxevents > (INT_MAX/sizeof(*events))) - return -EINVAL; -+ if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents)) -+ return -EFAULT; - kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL); - if (!kbuf) - return -ENOMEM; -@@ -317,6 +321,8 @@ asmlinkage long sys_oabi_semtimedop(int semid, - - if (nsops < 1 || nsops > SEMOPM) - return -EINVAL; -+ if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops)) -+ return -EFAULT; - sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL); - if (!sops) - return -ENOMEM; -diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S -index 5a69eb48d0a8..ee93d5fe61d7 100644 ---- a/arch/mips/kernel/scall64-n32.S -+++ b/arch/mips/kernel/scall64-n32.S -@@ -344,7 +344,7 @@ EXPORT(sysn32_call_table) - PTR sys_ni_syscall /* available, was setaltroot */ - PTR sys_add_key - PTR sys_request_key -- PTR sys_keyctl /* 6245 */ -+ PTR compat_sys_keyctl /* 6245 */ - PTR sys_set_thread_area - PTR sys_inotify_init - PTR sys_inotify_add_watch -diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S -index e4b6d7c97822..b77052ec6fb2 100644 ---- a/arch/mips/kernel/scall64-o32.S -+++ b/arch/mips/kernel/scall64-o32.S -@@ -500,7 +500,7 @@ EXPORT(sys32_call_table) - PTR sys_ni_syscall /* available, was setaltroot */ - PTR sys_add_key /* 4280 */ - PTR sys_request_key -- PTR sys_keyctl -+ PTR compat_sys_keyctl - PTR sys_set_thread_area - PTR sys_inotify_init - PTR sys_inotify_add_watch /* 4285 */ -diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c -index b1f0a90f933b..42570d8fb265 100644 ---- a/arch/s390/kernel/ipl.c -+++ b/arch/s390/kernel/ipl.c -@@ -2070,13 +2070,6 @@ void s390_reset_system(void (*fn_pre)(void), - S390_lowcore.program_new_psw.addr = - PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; - -- /* -- * Clear subchannel ID and number to signal new kernel that no CCW or -- * SCSI IPL has been done (for kexec and kdump) -- */ -- S390_lowcore.subchannel_id = 0; -- S390_lowcore.subchannel_nr = 0; -- - /* Store status at absolute zero */ - store_status(); - -diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl -index f17705e1332c..e62f4401e792 100644 ---- a/arch/x86/entry/syscalls/syscall_32.tbl -+++ b/arch/x86/entry/syscalls/syscall_32.tbl -@@ -294,7 +294,7 @@ - # 285 sys_setaltroot - 286 i386 add_key sys_add_key - 287 i386 request_key sys_request_key --288 i386 keyctl sys_keyctl -+288 i386 keyctl sys_keyctl compat_sys_keyctl - 289 i386 ioprio_set sys_ioprio_set - 290 i386 ioprio_get sys_ioprio_get - 291 i386 inotify_init sys_inotify_init -diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h -index b94f6f64e23d..dbff1456d215 100644 ---- a/arch/x86/include/asm/mtrr.h -+++ b/arch/x86/include/asm/mtrr.h -@@ -24,6 +24,7 @@ - #define _ASM_X86_MTRR_H - - #include -+#include - - - /* -@@ -83,9 +84,12 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn) - static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) - { - } -+static inline void mtrr_bp_init(void) -+{ -+ pat_disable("MTRRs disabled, skipping PAT initialization too."); -+} - - #define mtrr_ap_init() do {} while (0) --#define mtrr_bp_init() do {} while (0) - #define set_mtrr_aps_delayed_init() do {} while (0) - #define mtrr_aps_init() do {} while (0) - #define mtrr_bp_restore() do {} while (0) -diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h -index ca6c228d5e62..0b1ff4c1c14e 100644 ---- a/arch/x86/include/asm/pat.h -+++ b/arch/x86/include/asm/pat.h -@@ -5,8 +5,8 @@ - #include - - bool pat_enabled(void); -+void pat_disable(const char *reason); - extern void pat_init(void); --void pat_init_cache_modes(u64); - - extern int reserve_memtype(u64 start, u64 end, - enum page_cache_mode req_pcm, enum page_cache_mode *ret_pcm); -diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c -index 3b533cf37c74..b5624fafa44a 100644 ---- a/arch/x86/kernel/cpu/mtrr/generic.c -+++ b/arch/x86/kernel/cpu/mtrr/generic.c -@@ -444,11 +444,24 @@ static void __init print_mtrr_state(void) - pr_debug("TOM2: %016llx aka %lldM\n", mtrr_tom2, mtrr_tom2>>20); - } - -+/* PAT setup for BP. We need to go through sync steps here */ -+void __init mtrr_bp_pat_init(void) -+{ -+ unsigned long flags; -+ -+ local_irq_save(flags); -+ prepare_set(); -+ -+ pat_init(); -+ -+ post_set(); -+ local_irq_restore(flags); -+} -+ - /* Grab all of the MTRR state for this CPU into *state */ - bool __init get_mtrr_state(void) - { - struct mtrr_var_range *vrs; -- unsigned long flags; - unsigned lo, dummy; - unsigned int i; - -@@ -481,15 +494,6 @@ bool __init get_mtrr_state(void) - - mtrr_state_set = 1; - -- /* PAT setup for BP. We need to go through sync steps here */ -- local_irq_save(flags); -- prepare_set(); -- -- pat_init(); -- -- post_set(); -- local_irq_restore(flags); -- - return !!(mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED); - } - -diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c -index f891b4750f04..fa77ac8291f0 100644 ---- a/arch/x86/kernel/cpu/mtrr/main.c -+++ b/arch/x86/kernel/cpu/mtrr/main.c -@@ -752,6 +752,9 @@ void __init mtrr_bp_init(void) - /* BIOS may override */ - __mtrr_enabled = get_mtrr_state(); - -+ if (mtrr_enabled()) -+ mtrr_bp_pat_init(); -+ - if (mtrr_cleanup(phys_addr)) { - changed_by_mtrr_cleanup = 1; - mtrr_if->set_all(); -@@ -759,8 +762,16 @@ void __init mtrr_bp_init(void) - } - } - -- if (!mtrr_enabled()) -+ if (!mtrr_enabled()) { - pr_info("MTRR: Disabled\n"); -+ -+ /* -+ * PAT initialization relies on MTRR's rendezvous handler. -+ * Skip PAT init until the handler can initialize both -+ * features independently. -+ */ -+ pat_disable("MTRRs disabled, skipping PAT initialization too."); -+ } - } - - void mtrr_ap_init(void) -diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h -index 951884dcc433..6c7ced07d16d 100644 ---- a/arch/x86/kernel/cpu/mtrr/mtrr.h -+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h -@@ -52,6 +52,7 @@ void set_mtrr_prepare_save(struct set_mtrr_context *ctxt); - void fill_mtrr_var_range(unsigned int index, - u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi); - bool get_mtrr_state(void); -+void mtrr_bp_pat_init(void); - - extern void set_mtrr_ops(const struct mtrr_ops *ops); - -diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c -index 844b06d67df4..307f60ecfc6d 100644 ---- a/arch/x86/mm/mmap.c -+++ b/arch/x86/mm/mmap.c -@@ -94,18 +94,6 @@ static unsigned long mmap_base(unsigned long rnd) - } - - /* -- * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64 -- * does, but not when emulating X86_32 -- */ --static unsigned long mmap_legacy_base(unsigned long rnd) --{ -- if (mmap_is_ia32()) -- return TASK_UNMAPPED_BASE; -- else -- return TASK_UNMAPPED_BASE + rnd; --} -- --/* - * This function, called very early during the creation of a new - * process VM image, sets up which VM layout function to use: - */ -@@ -116,7 +104,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) - if (current->flags & PF_RANDOMIZE) - random_factor = arch_mmap_rnd(); - -- mm->mmap_legacy_base = mmap_legacy_base(random_factor); -+ mm->mmap_legacy_base = TASK_UNMAPPED_BASE + random_factor; - - if (mmap_is_legacy()) { - mm->mmap_base = mm->mmap_legacy_base; -diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c -index 188e3e07eeeb..6ad687d104ca 100644 ---- a/arch/x86/mm/pat.c -+++ b/arch/x86/mm/pat.c -@@ -39,11 +39,22 @@ - static bool boot_cpu_done; - - static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT); -+static void init_cache_modes(void); - --static inline void pat_disable(const char *reason) -+void pat_disable(const char *reason) - { -+ if (!__pat_enabled) -+ return; -+ -+ if (boot_cpu_done) { -+ WARN_ONCE(1, "x86/PAT: PAT cannot be disabled after initialization\n"); -+ return; -+ } -+ - __pat_enabled = 0; - pr_info("x86/PAT: %s\n", reason); -+ -+ init_cache_modes(); - } - - static int __init nopat(char *str) -@@ -180,7 +191,7 @@ static enum page_cache_mode pat_get_cache_mode(unsigned pat_val, char *msg) - * configuration. - * Using lower indices is preferred, so we start with highest index. - */ --void pat_init_cache_modes(u64 pat) -+static void __init_cache_modes(u64 pat) - { - enum page_cache_mode cache; - char pat_msg[33]; -@@ -201,14 +212,11 @@ static void pat_bsp_init(u64 pat) - { - u64 tmp_pat; - -- if (!cpu_has_pat) { -+ if (!boot_cpu_has(X86_FEATURE_PAT)) { - pat_disable("PAT not supported by CPU."); - return; - } - -- if (!pat_enabled()) -- goto done; -- - rdmsrl(MSR_IA32_CR_PAT, tmp_pat); - if (!tmp_pat) { - pat_disable("PAT MSR is 0, disabled."); -@@ -217,16 +225,12 @@ static void pat_bsp_init(u64 pat) - - wrmsrl(MSR_IA32_CR_PAT, pat); - --done: -- pat_init_cache_modes(pat); -+ __init_cache_modes(pat); - } - - static void pat_ap_init(u64 pat) - { -- if (!pat_enabled()) -- return; -- -- if (!cpu_has_pat) { -+ if (!boot_cpu_has(X86_FEATURE_PAT)) { - /* - * If this happens we are on a secondary CPU, but switched to - * PAT on the boot CPU. We have no way to undo PAT. -@@ -237,18 +241,32 @@ static void pat_ap_init(u64 pat) - wrmsrl(MSR_IA32_CR_PAT, pat); - } - --void pat_init(void) -+static void init_cache_modes(void) - { -- u64 pat; -- struct cpuinfo_x86 *c = &boot_cpu_data; -+ u64 pat = 0; -+ static int init_cm_done; - -- if (!pat_enabled()) { -+ if (init_cm_done) -+ return; -+ -+ if (boot_cpu_has(X86_FEATURE_PAT)) { -+ /* -+ * CPU supports PAT. Set PAT table to be consistent with -+ * PAT MSR. This case supports "nopat" boot option, and -+ * virtual machine environments which support PAT without -+ * MTRRs. In specific, Xen has unique setup to PAT MSR. -+ * -+ * If PAT MSR returns 0, it is considered invalid and emulates -+ * as No PAT. -+ */ -+ rdmsrl(MSR_IA32_CR_PAT, pat); -+ } -+ -+ if (!pat) { - /* - * No PAT. Emulate the PAT table that corresponds to the two -- * cache bits, PWT (Write Through) and PCD (Cache Disable). This -- * setup is the same as the BIOS default setup when the system -- * has PAT but the "nopat" boot option has been specified. This -- * emulated PAT table is used when MSR_IA32_CR_PAT returns 0. -+ * cache bits, PWT (Write Through) and PCD (Cache Disable). -+ * This setup is also the same as the BIOS default setup. - * - * PTE encoding: - * -@@ -265,10 +283,36 @@ void pat_init(void) - */ - pat = PAT(0, WB) | PAT(1, WT) | PAT(2, UC_MINUS) | PAT(3, UC) | - PAT(4, WB) | PAT(5, WT) | PAT(6, UC_MINUS) | PAT(7, UC); -+ } -+ -+ __init_cache_modes(pat); -+ -+ init_cm_done = 1; -+} -+ -+/** -+ * pat_init - Initialize PAT MSR and PAT table -+ * -+ * This function initializes PAT MSR and PAT table with an OS-defined value -+ * to enable additional cache attributes, WC and WT. -+ * -+ * This function must be called on all CPUs using the specific sequence of -+ * operations defined in Intel SDM. mtrr_rendezvous_handler() provides this -+ * procedure for PAT. -+ */ -+void pat_init(void) -+{ -+ u64 pat; -+ struct cpuinfo_x86 *c = &boot_cpu_data; -+ -+ if (!pat_enabled()) { -+ init_cache_modes(); -+ return; -+ } - -- } else if ((c->x86_vendor == X86_VENDOR_INTEL) && -- (((c->x86 == 0x6) && (c->x86_model <= 0xd)) || -- ((c->x86 == 0xf) && (c->x86_model <= 0x6)))) { -+ if ((c->x86_vendor == X86_VENDOR_INTEL) && -+ (((c->x86 == 0x6) && (c->x86_model <= 0xd)) || -+ ((c->x86 == 0xf) && (c->x86_model <= 0x6)))) { - /* - * PAT support with the lower four entries. Intel Pentium 2, - * 3, M, and 4 are affected by PAT errata, which makes the -@@ -733,25 +777,6 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, - if (file->f_flags & O_DSYNC) - pcm = _PAGE_CACHE_MODE_UC_MINUS; - --#ifdef CONFIG_X86_32 -- /* -- * On the PPro and successors, the MTRRs are used to set -- * memory types for physical addresses outside main memory, -- * so blindly setting UC or PWT on those pages is wrong. -- * For Pentiums and earlier, the surround logic should disable -- * caching for the high addresses through the KEN pin, but -- * we maintain the tradition of paranoia in this code. -- */ -- if (!pat_enabled() && -- !(boot_cpu_has(X86_FEATURE_MTRR) || -- boot_cpu_has(X86_FEATURE_K6_MTRR) || -- boot_cpu_has(X86_FEATURE_CYRIX_ARR) || -- boot_cpu_has(X86_FEATURE_CENTAUR_MCR)) && -- (pfn << PAGE_SHIFT) >= __pa(high_memory)) { -- pcm = _PAGE_CACHE_MODE_UC; -- } --#endif -- - *vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) | - cachemode2protval(pcm)); - return 1; -diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c -index beab8c706ac9..ffa41591bff9 100644 ---- a/arch/x86/xen/enlighten.c -+++ b/arch/x86/xen/enlighten.c -@@ -74,7 +74,6 @@ - #include - #include - #include --#include - #include - - #ifdef CONFIG_ACPI -@@ -1519,7 +1518,6 @@ asmlinkage __visible void __init xen_start_kernel(void) - { - struct physdev_set_iopl set_iopl; - unsigned long initrd_start = 0; -- u64 pat; - int rc; - - if (!xen_start_info) -@@ -1627,13 +1625,6 @@ asmlinkage __visible void __init xen_start_kernel(void) - xen_start_info->nr_pages); - xen_reserve_special_pages(); - -- /* -- * Modify the cache mode translation tables to match Xen's PAT -- * configuration. -- */ -- rdmsrl(MSR_IA32_CR_PAT, pat); -- pat_init_cache_modes(pat); -- - /* keep using Xen gdt for now; no urgent need to change it */ - - #ifdef CONFIG_X86_32 -diff --git a/block/genhd.c b/block/genhd.c -index e5cafa51567c..d2a1d43bf9fa 100644 ---- a/block/genhd.c -+++ b/block/genhd.c -@@ -831,6 +831,7 @@ static void disk_seqf_stop(struct seq_file *seqf, void *v) - if (iter) { - class_dev_iter_exit(iter); - kfree(iter); -+ seqf->private = NULL; - } - } - -diff --git a/crypto/gcm.c b/crypto/gcm.c -index bec329b3de8d..d9ea5f9c0574 100644 ---- a/crypto/gcm.c -+++ b/crypto/gcm.c -@@ -639,7 +639,9 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl, - - ghash_alg = crypto_find_alg(ghash_name, &crypto_ahash_type, - CRYPTO_ALG_TYPE_HASH, -- CRYPTO_ALG_TYPE_AHASH_MASK); -+ CRYPTO_ALG_TYPE_AHASH_MASK | -+ crypto_requires_sync(algt->type, -+ algt->mask)); - if (IS_ERR(ghash_alg)) - return PTR_ERR(ghash_alg); - -diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c -index ea5815c5e128..bc769c448d4a 100644 ---- a/crypto/scatterwalk.c -+++ b/crypto/scatterwalk.c -@@ -72,7 +72,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out, - - void scatterwalk_done(struct scatter_walk *walk, int out, int more) - { -- if (!(scatterwalk_pagelen(walk) & (PAGE_SIZE - 1)) || !more) -+ if (!more || walk->offset >= walk->sg->offset + walk->sg->length || -+ !(walk->offset & (PAGE_SIZE - 1))) - scatterwalk_pagedone(walk, out, more); - } - EXPORT_SYMBOL_GPL(scatterwalk_done); -diff --git a/drivers/char/random.c b/drivers/char/random.c -index d0da5d852d41..0227b0465b40 100644 ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -722,15 +722,18 @@ retry: - } - } - --static void credit_entropy_bits_safe(struct entropy_store *r, int nbits) -+static int credit_entropy_bits_safe(struct entropy_store *r, int nbits) - { - const int nbits_max = (int)(~0U >> (ENTROPY_SHIFT + 1)); - -+ if (nbits < 0) -+ return -EINVAL; -+ - /* Cap the value to avoid overflows */ - nbits = min(nbits, nbits_max); -- nbits = max(nbits, -nbits_max); - - credit_entropy_bits(r, nbits); -+ return 0; - } - - /********************************************************************* -@@ -1542,8 +1545,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) - return -EPERM; - if (get_user(ent_count, p)) - return -EFAULT; -- credit_entropy_bits_safe(&input_pool, ent_count); -- return 0; -+ return credit_entropy_bits_safe(&input_pool, ent_count); - case RNDADDENTROPY: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; -@@ -1557,8 +1559,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) - size); - if (retval < 0) - return retval; -- credit_entropy_bits_safe(&input_pool, ent_count); -- return 0; -+ return credit_entropy_bits_safe(&input_pool, ent_count); - case RNDZAPENTCNT: - case RNDCLEARPOOL: - /* -diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c -index 62284e45d531..eb434881ddbc 100644 ---- a/drivers/gpu/drm/i915/intel_pm.c -+++ b/drivers/gpu/drm/i915/intel_pm.c -@@ -1789,16 +1789,20 @@ static uint32_t ilk_compute_cur_wm(const struct intel_crtc_state *cstate, - const struct intel_plane_state *pstate, - uint32_t mem_value) - { -- int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0; -+ /* -+ * We treat the cursor plane as always-on for the purposes of watermark -+ * calculation. Until we have two-stage watermark programming merged, -+ * this is necessary to avoid flickering. -+ */ -+ int cpp = 4; -+ int width = pstate->visible ? pstate->base.crtc_w : 64; - -- if (!cstate->base.active || !pstate->visible) -+ if (!cstate->base.active) - return 0; - - return ilk_wm_method2(ilk_pipe_pixel_rate(cstate), - cstate->base.adjusted_mode.crtc_htotal, -- drm_rect_width(&pstate->dst), -- bpp, -- mem_value); -+ width, cpp, mem_value); - } - - /* Only for WM_LP. */ -diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c -index 774cd2210566..21febbb0d84e 100644 ---- a/drivers/hid/hid-sony.c -+++ b/drivers/hid/hid-sony.c -@@ -1418,8 +1418,10 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev) - } - - ret = hid_hw_output_report(hdev, buf, 1); -- if (ret < 0) -- hid_err(hdev, "can't set operational mode: step 3\n"); -+ if (ret < 0) { -+ hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); -+ ret = 0; -+ } - - out: - kfree(buf); -diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c -index 27fa0cb09538..85f39cc3e276 100644 ---- a/drivers/i2c/busses/i2c-i801.c -+++ b/drivers/i2c/busses/i2c-i801.c -@@ -244,6 +244,13 @@ struct i801_priv { - struct platform_device *mux_pdev; - #endif - struct platform_device *tco_pdev; -+ -+ /* -+ * If set to true the host controller registers are reserved for -+ * ACPI AML use. Protected by acpi_lock. -+ */ -+ bool acpi_reserved; -+ struct mutex acpi_lock; - }; - - #define FEATURE_SMBUS_PEC (1 << 0) -@@ -714,9 +721,15 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, - { - int hwpec; - int block = 0; -- int ret, xact = 0; -+ int ret = 0, xact = 0; - struct i801_priv *priv = i2c_get_adapdata(adap); - -+ mutex_lock(&priv->acpi_lock); -+ if (priv->acpi_reserved) { -+ mutex_unlock(&priv->acpi_lock); -+ return -EBUSY; -+ } -+ - hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) - && size != I2C_SMBUS_QUICK - && size != I2C_SMBUS_I2C_BLOCK_DATA; -@@ -773,7 +786,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, - default: - dev_err(&priv->pci_dev->dev, "Unsupported transaction %d\n", - size); -- return -EOPNOTSUPP; -+ ret = -EOPNOTSUPP; -+ goto out; - } - - if (hwpec) /* enable/disable hardware PEC */ -@@ -796,11 +810,11 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, - ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); - - if (block) -- return ret; -+ goto out; - if (ret) -- return ret; -+ goto out; - if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) -- return 0; -+ goto out; - - switch (xact & 0x7f) { - case I801_BYTE: /* Result put in SMBHSTDAT0 */ -@@ -812,7 +826,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, - (inb_p(SMBHSTDAT1(priv)) << 8); - break; - } -- return 0; -+ -+out: -+ mutex_unlock(&priv->acpi_lock); -+ return ret; - } - - -@@ -1249,6 +1266,72 @@ static void i801_add_tco(struct i801_priv *priv) - priv->tco_pdev = pdev; - } - -+#ifdef CONFIG_ACPI -+static acpi_status -+i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, -+ u64 *value, void *handler_context, void *region_context) -+{ -+ struct i801_priv *priv = handler_context; -+ struct pci_dev *pdev = priv->pci_dev; -+ acpi_status status; -+ -+ /* -+ * Once BIOS AML code touches the OpRegion we warn and inhibit any -+ * further access from the driver itself. This device is now owned -+ * by the system firmware. -+ */ -+ mutex_lock(&priv->acpi_lock); -+ -+ if (!priv->acpi_reserved) { -+ priv->acpi_reserved = true; -+ -+ dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n"); -+ dev_warn(&pdev->dev, "Driver SMBus register access inhibited\n"); -+ } -+ -+ if ((function & ACPI_IO_MASK) == ACPI_READ) -+ status = acpi_os_read_port(address, (u32 *)value, bits); -+ else -+ status = acpi_os_write_port(address, (u32)*value, bits); -+ -+ mutex_unlock(&priv->acpi_lock); -+ -+ return status; -+} -+ -+static int i801_acpi_probe(struct i801_priv *priv) -+{ -+ struct acpi_device *adev; -+ acpi_status status; -+ -+ adev = ACPI_COMPANION(&priv->pci_dev->dev); -+ if (adev) { -+ status = acpi_install_address_space_handler(adev->handle, -+ ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler, -+ NULL, priv); -+ if (ACPI_SUCCESS(status)) -+ return 0; -+ } -+ -+ return acpi_check_resource_conflict(&priv->pci_dev->resource[SMBBAR]); -+} -+ -+static void i801_acpi_remove(struct i801_priv *priv) -+{ -+ struct acpi_device *adev; -+ -+ adev = ACPI_COMPANION(&priv->pci_dev->dev); -+ if (!adev) -+ return; -+ -+ acpi_remove_address_space_handler(adev->handle, -+ ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler); -+} -+#else -+static inline int i801_acpi_probe(struct i801_priv *priv) { return 0; } -+static inline void i801_acpi_remove(struct i801_priv *priv) { } -+#endif -+ - static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) - { - unsigned char temp; -@@ -1266,6 +1349,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) - priv->adapter.dev.parent = &dev->dev; - ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&dev->dev)); - priv->adapter.retries = 3; -+ mutex_init(&priv->acpi_lock); - - priv->pci_dev = dev; - switch (dev->device) { -@@ -1328,10 +1412,8 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) - return -ENODEV; - } - -- err = acpi_check_resource_conflict(&dev->resource[SMBBAR]); -- if (err) { -+ if (i801_acpi_probe(priv)) - return -ENODEV; -- } - - err = pcim_iomap_regions(dev, 1 << SMBBAR, - dev_driver_string(&dev->dev)); -@@ -1340,6 +1422,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) - "Failed to request SMBus region 0x%lx-0x%Lx\n", - priv->smba, - (unsigned long long)pci_resource_end(dev, SMBBAR)); -+ i801_acpi_remove(priv); - return err; - } - -@@ -1404,6 +1487,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) - err = i2c_add_adapter(&priv->adapter); - if (err) { - dev_err(&dev->dev, "Failed to add SMBus adapter\n"); -+ i801_acpi_remove(priv); - return err; - } - -@@ -1422,6 +1506,7 @@ static void i801_remove(struct pci_dev *dev) - - i801_del_mux(priv); - i2c_del_adapter(&priv->adapter); -+ i801_acpi_remove(priv); - pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); - - platform_device_unregister(priv->tco_pdev); -diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c -index db760e84119f..b8df0f5e8c25 100644 ---- a/drivers/net/bonding/bond_netlink.c -+++ b/drivers/net/bonding/bond_netlink.c -@@ -446,7 +446,11 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev, - if (err < 0) - return err; - -- return register_netdevice(bond_dev); -+ err = register_netdevice(bond_dev); -+ -+ netif_carrier_off(bond_dev); -+ -+ return err; - } - - static size_t bond_get_size(const struct net_device *bond_dev) -diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c -index 28f7610b03fe..c32f5d32f811 100644 ---- a/drivers/net/ethernet/broadcom/bgmac.c -+++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -219,7 +219,7 @@ err_dma: - dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb), - DMA_TO_DEVICE); - -- while (i > 0) { -+ while (i-- > 0) { - int index = (ring->end + i) % BGMAC_TX_RING_SLOTS; - struct bgmac_slot_info *slot = &ring->slots[index]; - u32 ctl1 = le32_to_cpu(ring->cpu_base[index].ctl1); -diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c -index 3dd548ab8df1..40365cb1abe6 100644 ---- a/drivers/net/ethernet/qlogic/qed/qed_spq.c -+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c -@@ -794,13 +794,12 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn, - * in a bitmap and increasing the chain consumer only - * for the first successive completed entries. - */ -- bitmap_set(p_spq->p_comp_bitmap, pos, SPQ_RING_SIZE); -+ __set_bit(pos, p_spq->p_comp_bitmap); - - while (test_bit(p_spq->comp_bitmap_idx, - p_spq->p_comp_bitmap)) { -- bitmap_clear(p_spq->p_comp_bitmap, -- p_spq->comp_bitmap_idx, -- SPQ_RING_SIZE); -+ __clear_bit(p_spq->comp_bitmap_idx, -+ p_spq->p_comp_bitmap); - p_spq->comp_bitmap_idx++; - qed_chain_return_produced(&p_spq->chain); - } -diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c -index a790d5f90b83..e0e94b855bbe 100644 ---- a/drivers/net/usb/cdc_ncm.c -+++ b/drivers/net/usb/cdc_ncm.c -@@ -952,8 +952,6 @@ EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting); - - static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf) - { -- int ret; -- - /* MBIM backwards compatible function? */ - if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM) - return -ENODEV; -@@ -962,16 +960,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf) - * Additionally, generic NCM devices are assumed to accept arbitrarily - * placed NDP. - */ -- ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0); -- -- /* -- * We should get an event when network connection is "connected" or -- * "disconnected". Set network connection in "disconnected" state -- * (carrier is OFF) during attach, so the IP network stack does not -- * start IPv6 negotiation and more. -- */ -- usbnet_link_change(dev, 0, 0); -- return ret; -+ return cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0); - } - - static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max) -@@ -1554,7 +1543,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) - - static const struct driver_info cdc_ncm_info = { - .description = "CDC NCM", -- .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET, -+ .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET -+ | FLAG_LINK_INTR, - .bind = cdc_ncm_bind, - .unbind = cdc_ncm_unbind, - .manage_power = usbnet_manage_power, -@@ -1567,7 +1557,7 @@ static const struct driver_info cdc_ncm_info = { - static const struct driver_info wwan_info = { - .description = "Mobile Broadband Network Device", - .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET -- | FLAG_WWAN, -+ | FLAG_LINK_INTR | FLAG_WWAN, - .bind = cdc_ncm_bind, - .unbind = cdc_ncm_unbind, - .manage_power = usbnet_manage_power, -@@ -1580,7 +1570,7 @@ static const struct driver_info wwan_info = { - static const struct driver_info wwan_noarp_info = { - .description = "Mobile Broadband Network Device (NO ARP)", - .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET -- | FLAG_WWAN | FLAG_NOARP, -+ | FLAG_LINK_INTR | FLAG_WWAN | FLAG_NOARP, - .bind = cdc_ncm_bind, - .unbind = cdc_ncm_unbind, - .manage_power = usbnet_manage_power, -diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c -index 943c1cb9566c..d28e3ab9479c 100644 ---- a/drivers/pnp/quirks.c -+++ b/drivers/pnp/quirks.c -@@ -342,7 +342,9 @@ static void quirk_amd_mmconfig_area(struct pnp_dev *dev) - /* Device IDs of parts that have 32KB MCH space */ - static const unsigned int mch_quirk_devices[] = { - 0x0154, /* Ivy Bridge */ -+ 0x0a04, /* Haswell-ULT */ - 0x0c00, /* Haswell */ -+ 0x1604, /* Broadwell */ - }; - - static struct pci_dev *get_intel_host(void) -diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c -index f7ae898833dd..7232d43e2207 100644 ---- a/drivers/scsi/scsi_sysfs.c -+++ b/drivers/scsi/scsi_sysfs.c -@@ -1058,11 +1058,12 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) - } - - error = scsi_dh_add_device(sdev); -- if (error) { -+ if (error) -+ /* -+ * device_handler is optional, so any error can be ignored -+ */ - sdev_printk(KERN_INFO, sdev, - "failed to add device handler: %d\n", error); -- return error; -- } - - device_enable_async_suspend(&sdev->sdev_dev); - error = device_add(&sdev->sdev_dev); -diff --git a/drivers/staging/rdma/ipath/ipath_file_ops.c b/drivers/staging/rdma/ipath/ipath_file_ops.c -index 13c3cd11ab92..05d30f433b19 100644 ---- a/drivers/staging/rdma/ipath/ipath_file_ops.c -+++ b/drivers/staging/rdma/ipath/ipath_file_ops.c -@@ -45,6 +45,8 @@ - #include - #include - -+#include -+ - #include "ipath_kernel.h" - #include "ipath_common.h" - #include "ipath_user_sdma.h" -@@ -2243,6 +2245,9 @@ static ssize_t ipath_write(struct file *fp, const char __user *data, - ssize_t ret = 0; - void *dest; - -+ if (WARN_ON_ONCE(!ib_safe_file_access(fp))) -+ return -EACCES; -+ - if (count < sizeof(cmd.type)) { - ret = -EINVAL; - goto bail; -diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c -index 7865228f664f..807d80145686 100644 ---- a/drivers/tty/pty.c -+++ b/drivers/tty/pty.c -@@ -679,14 +679,14 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) - /* this is called once with whichever end is closed last */ - static void pty_unix98_shutdown(struct tty_struct *tty) - { -- struct inode *ptmx_inode; -+ struct pts_fs_info *fsi; - - if (tty->driver->subtype == PTY_TYPE_MASTER) -- ptmx_inode = tty->driver_data; -+ fsi = tty->driver_data; - else -- ptmx_inode = tty->link->driver_data; -- devpts_kill_index(ptmx_inode, tty->index); -- devpts_del_ref(ptmx_inode); -+ fsi = tty->link->driver_data; -+ devpts_kill_index(fsi, tty->index); -+ devpts_put_ref(fsi); - } - - static const struct tty_operations ptm_unix98_ops = { -@@ -738,6 +738,7 @@ static const struct tty_operations pty_unix98_ops = { - - static int ptmx_open(struct inode *inode, struct file *filp) - { -+ struct pts_fs_info *fsi; - struct tty_struct *tty; - struct inode *slave_inode; - int retval; -@@ -752,47 +753,41 @@ static int ptmx_open(struct inode *inode, struct file *filp) - if (retval) - return retval; - -+ fsi = devpts_get_ref(inode, filp); -+ retval = -ENODEV; -+ if (!fsi) -+ goto out_free_file; -+ - /* find a device that is not in use. */ - mutex_lock(&devpts_mutex); -- index = devpts_new_index(inode); -- if (index < 0) { -- retval = index; -- mutex_unlock(&devpts_mutex); -- goto err_file; -- } -- -+ index = devpts_new_index(fsi); - mutex_unlock(&devpts_mutex); - -- mutex_lock(&tty_mutex); -- tty = tty_init_dev(ptm_driver, index); -+ retval = index; -+ if (index < 0) -+ goto out_put_ref; - -- if (IS_ERR(tty)) { -- retval = PTR_ERR(tty); -- goto out; -- } - -+ mutex_lock(&tty_mutex); -+ tty = tty_init_dev(ptm_driver, index); - /* The tty returned here is locked so we can safely - drop the mutex */ - mutex_unlock(&tty_mutex); - -- set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ -- tty->driver_data = inode; -+ retval = PTR_ERR(tty); -+ if (IS_ERR(tty)) -+ goto out; - - /* -- * In the case where all references to ptmx inode are dropped and we -- * still have /dev/tty opened pointing to the master/slave pair (ptmx -- * is closed/released before /dev/tty), we must make sure that the inode -- * is still valid when we call the final pty_unix98_shutdown, thus we -- * hold an additional reference to the ptmx inode. For the same /dev/tty -- * last close case, we also need to make sure the super_block isn't -- * destroyed (devpts instance unmounted), before /dev/tty is closed and -- * on its release devpts_kill_index is called. -+ * From here on out, the tty is "live", and the index and -+ * fsi will be killed/put by the tty_release() - */ -- devpts_add_ref(inode); -+ set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ -+ tty->driver_data = fsi; - - tty_add_file(tty, filp); - -- slave_inode = devpts_pty_new(inode, -+ slave_inode = devpts_pty_new(fsi, - MKDEV(UNIX98_PTY_SLAVE_MAJOR, index), index, - tty->link); - if (IS_ERR(slave_inode)) { -@@ -811,12 +806,14 @@ static int ptmx_open(struct inode *inode, struct file *filp) - return 0; - err_release: - tty_unlock(tty); -+ // This will also put-ref the fsi - tty_release(inode, filp); - return retval; - out: -- mutex_unlock(&tty_mutex); -- devpts_kill_index(inode, index); --err_file: -+ devpts_kill_index(fsi, index); -+out_put_ref: -+ devpts_put_ref(fsi); -+out_free_file: - tty_free_file(filp); - return retval; - } -diff --git a/fs/dcache.c b/fs/dcache.c -index 108d7d810be3..71b6056ad35d 100644 ---- a/fs/dcache.c -+++ b/fs/dcache.c -@@ -578,7 +578,6 @@ static struct dentry *dentry_kill(struct dentry *dentry) - - failed: - spin_unlock(&dentry->d_lock); -- cpu_relax(); - return dentry; /* try again with same dentry */ - } - -@@ -752,6 +751,8 @@ void dput(struct dentry *dentry) - return; - - repeat: -+ might_sleep(); -+ - rcu_read_lock(); - if (likely(fast_dput(dentry))) { - rcu_read_unlock(); -@@ -783,8 +784,10 @@ repeat: - - kill_it: - dentry = dentry_kill(dentry); -- if (dentry) -+ if (dentry) { -+ cond_resched(); - goto repeat; -+ } - } - EXPORT_SYMBOL(dput); - -diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c -index 706de324f2a6..c82edb049117 100644 ---- a/fs/devpts/inode.c -+++ b/fs/devpts/inode.c -@@ -128,6 +128,7 @@ static const match_table_t tokens = { - struct pts_fs_info { - struct ida allocated_ptys; - struct pts_mount_opts mount_opts; -+ struct super_block *sb; - struct dentry *ptmx_dentry; - }; - -@@ -358,7 +359,7 @@ static const struct super_operations devpts_sops = { - .show_options = devpts_show_options, - }; - --static void *new_pts_fs_info(void) -+static void *new_pts_fs_info(struct super_block *sb) - { - struct pts_fs_info *fsi; - -@@ -369,6 +370,7 @@ static void *new_pts_fs_info(void) - ida_init(&fsi->allocated_ptys); - fsi->mount_opts.mode = DEVPTS_DEFAULT_MODE; - fsi->mount_opts.ptmxmode = DEVPTS_DEFAULT_PTMX_MODE; -+ fsi->sb = sb; - - return fsi; - } -@@ -384,7 +386,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent) - s->s_op = &devpts_sops; - s->s_time_gran = 1; - -- s->s_fs_info = new_pts_fs_info(); -+ s->s_fs_info = new_pts_fs_info(s); - if (!s->s_fs_info) - goto fail; - -@@ -524,17 +526,14 @@ static struct file_system_type devpts_fs_type = { - * to the System V naming convention - */ - --int devpts_new_index(struct inode *ptmx_inode) -+int devpts_new_index(struct pts_fs_info *fsi) - { -- struct super_block *sb = pts_sb_from_inode(ptmx_inode); -- struct pts_fs_info *fsi; - int index; - int ida_ret; - -- if (!sb) -+ if (!fsi) - return -ENODEV; - -- fsi = DEVPTS_SB(sb); - retry: - if (!ida_pre_get(&fsi->allocated_ptys, GFP_KERNEL)) - return -ENOMEM; -@@ -564,11 +563,8 @@ retry: - return index; - } - --void devpts_kill_index(struct inode *ptmx_inode, int idx) -+void devpts_kill_index(struct pts_fs_info *fsi, int idx) - { -- struct super_block *sb = pts_sb_from_inode(ptmx_inode); -- struct pts_fs_info *fsi = DEVPTS_SB(sb); -- - mutex_lock(&allocated_ptys_lock); - ida_remove(&fsi->allocated_ptys, idx); - pty_count--; -@@ -578,21 +574,25 @@ void devpts_kill_index(struct inode *ptmx_inode, int idx) - /* - * pty code needs to hold extra references in case of last /dev/tty close - */ -- --void devpts_add_ref(struct inode *ptmx_inode) -+struct pts_fs_info *devpts_get_ref(struct inode *ptmx_inode, struct file *file) - { -- struct super_block *sb = pts_sb_from_inode(ptmx_inode); -+ struct super_block *sb; -+ struct pts_fs_info *fsi; -+ -+ sb = pts_sb_from_inode(ptmx_inode); -+ if (!sb) -+ return NULL; -+ fsi = DEVPTS_SB(sb); -+ if (!fsi) -+ return NULL; - - atomic_inc(&sb->s_active); -- ihold(ptmx_inode); -+ return fsi; - } - --void devpts_del_ref(struct inode *ptmx_inode) -+void devpts_put_ref(struct pts_fs_info *fsi) - { -- struct super_block *sb = pts_sb_from_inode(ptmx_inode); -- -- iput(ptmx_inode); -- deactivate_super(sb); -+ deactivate_super(fsi->sb); - } - - /** -@@ -604,22 +604,21 @@ void devpts_del_ref(struct inode *ptmx_inode) - * - * The created inode is returned. Remove it from /dev/pts/ by devpts_pty_kill. - */ --struct inode *devpts_pty_new(struct inode *ptmx_inode, dev_t device, int index, -+struct inode *devpts_pty_new(struct pts_fs_info *fsi, dev_t device, int index, - void *priv) - { - struct dentry *dentry; -- struct super_block *sb = pts_sb_from_inode(ptmx_inode); -+ struct super_block *sb; - struct inode *inode; - struct dentry *root; -- struct pts_fs_info *fsi; - struct pts_mount_opts *opts; - char s[12]; - -- if (!sb) -+ if (!fsi) - return ERR_PTR(-ENODEV); - -+ sb = fsi->sb; - root = sb->s_root; -- fsi = DEVPTS_SB(sb); - opts = &fsi->mount_opts; - - inode = new_inode(sb); -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index fe1f50fe764f..f97110461c19 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -208,6 +208,9 @@ static int ext4_init_block_bitmap(struct super_block *sb, - memset(bh->b_data, 0, sb->s_blocksize); - - bit_max = ext4_num_base_meta_clusters(sb, block_group); -+ if ((bit_max >> 3) >= bh->b_size) -+ return -EFSCORRUPTED; -+ - for (bit = 0; bit < bit_max; bit++) - ext4_set_bit(bit, bh->b_data); - -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 62880586ed85..8eac7d586997 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -376,9 +376,13 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext) - ext4_fsblk_t block = ext4_ext_pblock(ext); - int len = ext4_ext_get_actual_len(ext); - ext4_lblk_t lblock = le32_to_cpu(ext->ee_block); -- ext4_lblk_t last = lblock + len - 1; - -- if (len == 0 || lblock > last) -+ /* -+ * We allow neither: -+ * - zero length -+ * - overflow/wrap-around -+ */ -+ if (lblock + len <= lblock) - return 0; - return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len); - } -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index e31d762eedce..9a5ad0f0d3ed 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -205,9 +205,9 @@ void ext4_evict_inode(struct inode *inode) - * Note that directories do not have this problem because they - * don't use page cache. - */ -- if (ext4_should_journal_data(inode) && -- (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) && -- inode->i_ino != EXT4_JOURNAL_INO) { -+ if (inode->i_ino != EXT4_JOURNAL_INO && -+ ext4_should_journal_data(inode) && -+ (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) { - journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; - tid_t commit_tid = EXT4_I(inode)->i_datasync_tid; - -@@ -2589,13 +2589,36 @@ retry: - done = true; - } - } -- ext4_journal_stop(handle); -+ /* -+ * Caution: If the handle is synchronous, -+ * ext4_journal_stop() can wait for transaction commit -+ * to finish which may depend on writeback of pages to -+ * complete or on page lock to be released. In that -+ * case, we have to wait until after after we have -+ * submitted all the IO, released page locks we hold, -+ * and dropped io_end reference (for extent conversion -+ * to be able to complete) before stopping the handle. -+ */ -+ if (!ext4_handle_valid(handle) || handle->h_sync == 0) { -+ ext4_journal_stop(handle); -+ handle = NULL; -+ } - /* Submit prepared bio */ - ext4_io_submit(&mpd.io_submit); - /* Unlock pages we didn't use */ - mpage_release_unused_pages(&mpd, give_up_on_write); -- /* Drop our io_end reference we got from init */ -- ext4_put_io_end(mpd.io_submit.io_end); -+ /* -+ * Drop our io_end reference we got from init. We have -+ * to be careful and use deferred io_end finishing if -+ * we are still holding the transaction as we can -+ * release the last reference to io_end which may end -+ * up doing unwritten extent conversion. -+ */ -+ if (handle) { -+ ext4_put_io_end_defer(mpd.io_submit.io_end); -+ ext4_journal_stop(handle); -+ } else -+ ext4_put_io_end(mpd.io_submit.io_end); - - if (ret == -ENOSPC && sbi->s_journal) { - /* -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index cf734170daa9..c4dcac8a018d 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -2932,7 +2932,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, - ext4_error(sb, "Allocating blocks %llu-%llu which overlap " - "fs metadata", block, block+len); - /* File system mounted not to panic on error -- * Fix the bitmap and repeat the block allocation -+ * Fix the bitmap and return EFSCORRUPTED - * We leak some of the blocks here. - */ - ext4_lock_group(sb, ac->ac_b_ex.fe_group); -@@ -2941,7 +2941,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, - ext4_unlock_group(sb, ac->ac_b_ex.fe_group); - err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); - if (!err) -- err = -EAGAIN; -+ err = -EFSCORRUPTED; - goto out_err; - } - -@@ -4506,18 +4506,7 @@ repeat: - } - if (likely(ac->ac_status == AC_STATUS_FOUND)) { - *errp = ext4_mb_mark_diskspace_used(ac, handle, reserv_clstrs); -- if (*errp == -EAGAIN) { -- /* -- * drop the reference that we took -- * in ext4_mb_use_best_found -- */ -- ext4_mb_release_context(ac); -- ac->ac_b_ex.fe_group = 0; -- ac->ac_b_ex.fe_start = 0; -- ac->ac_b_ex.fe_len = 0; -- ac->ac_status = AC_STATUS_CONTINUE; -- goto repeat; -- } else if (*errp) { -+ if (*errp) { - ext4_discard_allocated_blocks(ac); - goto errout; - } else { -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index 852c26806af2..c542ebcf7a92 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -2240,6 +2240,16 @@ static void ext4_orphan_cleanup(struct super_block *sb, - while (es->s_last_orphan) { - struct inode *inode; - -+ /* -+ * We may have encountered an error during cleanup; if -+ * so, skip the rest. -+ */ -+ if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { -+ jbd_debug(1, "Skipping orphan recovery on fs with errors.\n"); -+ es->s_last_orphan = 0; -+ break; -+ } -+ - inode = ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan)); - if (IS_ERR(inode)) { - es->s_last_orphan = 0; -@@ -3372,6 +3382,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) - goto failed_mount; - } - -+ if (le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) > (blocksize / 4)) { -+ ext4_msg(sb, KERN_ERR, -+ "Number of reserved GDT blocks insanely large: %d", -+ le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks)); -+ goto failed_mount; -+ } -+ - if (sbi->s_mount_opt & EXT4_MOUNT_DAX) { - if (blocksize != PAGE_SIZE) { - ext4_msg(sb, KERN_ERR, -diff --git a/fs/fuse/file.c b/fs/fuse/file.c -index c2e340d6ec6e..d58d4c0af0ce 100644 ---- a/fs/fuse/file.c -+++ b/fs/fuse/file.c -@@ -417,6 +417,15 @@ static int fuse_flush(struct file *file, fl_owner_t id) - fuse_sync_writes(inode); - mutex_unlock(&inode->i_mutex); - -+ if (test_bit(AS_ENOSPC, &file->f_mapping->flags) && -+ test_and_clear_bit(AS_ENOSPC, &file->f_mapping->flags)) -+ err = -ENOSPC; -+ if (test_bit(AS_EIO, &file->f_mapping->flags) && -+ test_and_clear_bit(AS_EIO, &file->f_mapping->flags)) -+ err = -EIO; -+ if (err) -+ return err; -+ - req = fuse_get_req_nofail_nopages(fc, file); - memset(&inarg, 0, sizeof(inarg)); - inarg.fh = ff->fh; -@@ -462,6 +471,21 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, - goto out; - - fuse_sync_writes(inode); -+ -+ /* -+ * Due to implementation of fuse writeback -+ * filemap_write_and_wait_range() does not catch errors. -+ * We have to do this directly after fuse_sync_writes() -+ */ -+ if (test_bit(AS_ENOSPC, &file->f_mapping->flags) && -+ test_and_clear_bit(AS_ENOSPC, &file->f_mapping->flags)) -+ err = -ENOSPC; -+ if (test_bit(AS_EIO, &file->f_mapping->flags) && -+ test_and_clear_bit(AS_EIO, &file->f_mapping->flags)) -+ err = -EIO; -+ if (err) -+ goto out; -+ - err = sync_inode_metadata(inode, 1); - if (err) - goto out; -diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c -index 2913db2a5b99..0d5e8e59b390 100644 ---- a/fs/fuse/inode.c -+++ b/fs/fuse/inode.c -@@ -926,7 +926,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) - arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | - FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | - FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | -- FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | -+ FUSE_FLOCK_LOCKS | FUSE_HAS_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | - FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | - FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT; - req->in.h.opcode = FUSE_INIT; -diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h -index e0ee0b3000b2..358a4db72a27 100644 ---- a/include/linux/devpts_fs.h -+++ b/include/linux/devpts_fs.h -@@ -15,38 +15,24 @@ - - #include - -+struct pts_fs_info; -+ - #ifdef CONFIG_UNIX98_PTYS - --int devpts_new_index(struct inode *ptmx_inode); --void devpts_kill_index(struct inode *ptmx_inode, int idx); --void devpts_add_ref(struct inode *ptmx_inode); --void devpts_del_ref(struct inode *ptmx_inode); -+/* Look up a pts fs info and get a ref to it */ -+struct pts_fs_info *devpts_get_ref(struct inode *, struct file *); -+void devpts_put_ref(struct pts_fs_info *); -+ -+int devpts_new_index(struct pts_fs_info *); -+void devpts_kill_index(struct pts_fs_info *, int); -+ - /* mknod in devpts */ --struct inode *devpts_pty_new(struct inode *ptmx_inode, dev_t device, int index, -- void *priv); -+struct inode *devpts_pty_new(struct pts_fs_info *, dev_t, int, void *); - /* get private structure */ - void *devpts_get_priv(struct inode *pts_inode); - /* unlink */ - void devpts_pty_kill(struct inode *inode); - --#else -- --/* Dummy stubs in the no-pty case */ --static inline int devpts_new_index(struct inode *ptmx_inode) { return -EINVAL; } --static inline void devpts_kill_index(struct inode *ptmx_inode, int idx) { } --static inline void devpts_add_ref(struct inode *ptmx_inode) { } --static inline void devpts_del_ref(struct inode *ptmx_inode) { } --static inline struct inode *devpts_pty_new(struct inode *ptmx_inode, -- dev_t device, int index, void *priv) --{ -- return ERR_PTR(-EINVAL); --} --static inline void *devpts_get_priv(struct inode *pts_inode) --{ -- return NULL; --} --static inline void devpts_pty_kill(struct inode *inode) { } -- - #endif - - -diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h -index cd0e2413c358..435fd8426b8a 100644 ---- a/include/linux/memcontrol.h -+++ b/include/linux/memcontrol.h -@@ -174,6 +174,11 @@ struct mem_cgroup_thresholds { - struct mem_cgroup_threshold_ary *spare; - }; - -+struct mem_cgroup_id { -+ int id; -+ atomic_t ref; -+}; -+ - /* - * The memory controller data structure. The memory controller controls both - * page cache and RSS per cgroup. We would eventually like to provide -@@ -183,6 +188,9 @@ struct mem_cgroup_thresholds { - struct mem_cgroup { - struct cgroup_subsys_state css; - -+ /* Private memcg ID. Used to ID objects that outlive the cgroup */ -+ struct mem_cgroup_id id; -+ - /* Accounted resources */ - struct page_counter memory; - struct page_counter memsw; -diff --git a/ipc/msg.c b/ipc/msg.c -index 1471db9a7e61..c6521c205cb4 100644 ---- a/ipc/msg.c -+++ b/ipc/msg.c -@@ -680,7 +680,7 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext, - rcu_read_lock(); - ipc_lock_object(&msq->q_perm); - -- ipc_rcu_putref(msq, ipc_rcu_free); -+ ipc_rcu_putref(msq, msg_rcu_free); - /* raced with RMID? */ - if (!ipc_valid_object(&msq->q_perm)) { - err = -EIDRM; -diff --git a/ipc/sem.c b/ipc/sem.c -index b471e5a3863d..20d07008ad5e 100644 ---- a/ipc/sem.c -+++ b/ipc/sem.c -@@ -442,7 +442,7 @@ static inline struct sem_array *sem_obtain_object_check(struct ipc_namespace *ns - static inline void sem_lock_and_putref(struct sem_array *sma) - { - sem_lock(sma, NULL, -1); -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - } - - static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) -@@ -1385,7 +1385,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, - rcu_read_unlock(); - sem_io = ipc_alloc(sizeof(ushort)*nsems); - if (sem_io == NULL) { -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - return -ENOMEM; - } - -@@ -1419,20 +1419,20 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, - if (nsems > SEMMSL_FAST) { - sem_io = ipc_alloc(sizeof(ushort)*nsems); - if (sem_io == NULL) { -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - return -ENOMEM; - } - } - - if (copy_from_user(sem_io, p, nsems*sizeof(ushort))) { -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - err = -EFAULT; - goto out_free; - } - - for (i = 0; i < nsems; i++) { - if (sem_io[i] > SEMVMX) { -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - err = -ERANGE; - goto out_free; - } -@@ -1722,7 +1722,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid) - /* step 2: allocate new undo structure */ - new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL); - if (!new) { -- ipc_rcu_putref(sma, ipc_rcu_free); -+ ipc_rcu_putref(sma, sem_rcu_free); - return ERR_PTR(-ENOMEM); - } - -diff --git a/mm/memcontrol.c b/mm/memcontrol.c -index 67648e6b2ac8..6b90d184e9c0 100644 ---- a/mm/memcontrol.c -+++ b/mm/memcontrol.c -@@ -272,21 +272,7 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) - - static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) - { -- return memcg->css.id; --} -- --/* -- * A helper function to get mem_cgroup from ID. must be called under -- * rcu_read_lock(). The caller is responsible for calling -- * css_tryget_online() if the mem_cgroup is used for charging. (dropping -- * refcnt from swap can be called against removed memcg.) -- */ --static inline struct mem_cgroup *mem_cgroup_from_id(unsigned short id) --{ -- struct cgroup_subsys_state *css; -- -- css = css_from_id(id, &memory_cgrp_subsys); -- return mem_cgroup_from_css(css); -+ return memcg->id.id; - } - - /* Writing them here to avoid exposing memcg's inner layout */ -@@ -4124,6 +4110,88 @@ static struct cftype mem_cgroup_legacy_files[] = { - { }, /* terminate */ - }; - -+/* -+ * Private memory cgroup IDR -+ * -+ * Swap-out records and page cache shadow entries need to store memcg -+ * references in constrained space, so we maintain an ID space that is -+ * limited to 16 bit (MEM_CGROUP_ID_MAX), limiting the total number of -+ * memory-controlled cgroups to 64k. -+ * -+ * However, there usually are many references to the oflline CSS after -+ * the cgroup has been destroyed, such as page cache or reclaimable -+ * slab objects, that don't need to hang on to the ID. We want to keep -+ * those dead CSS from occupying IDs, or we might quickly exhaust the -+ * relatively small ID space and prevent the creation of new cgroups -+ * even when there are much fewer than 64k cgroups - possibly none. -+ * -+ * Maintain a private 16-bit ID space for memcg, and allow the ID to -+ * be freed and recycled when it's no longer needed, which is usually -+ * when the CSS is offlined. -+ * -+ * The only exception to that are records of swapped out tmpfs/shmem -+ * pages that need to be attributed to live ancestors on swapin. But -+ * those references are manageable from userspace. -+ */ -+ -+static DEFINE_IDR(mem_cgroup_idr); -+ -+static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n) -+{ -+ atomic_add(n, &memcg->id.ref); -+} -+ -+static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) -+{ -+ while (!atomic_inc_not_zero(&memcg->id.ref)) { -+ /* -+ * The root cgroup cannot be destroyed, so it's refcount must -+ * always be >= 1. -+ */ -+ if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { -+ VM_BUG_ON(1); -+ break; -+ } -+ memcg = parent_mem_cgroup(memcg); -+ if (!memcg) -+ memcg = root_mem_cgroup; -+ } -+ return memcg; -+} -+ -+static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) -+{ -+ if (atomic_sub_and_test(n, &memcg->id.ref)) { -+ idr_remove(&mem_cgroup_idr, memcg->id.id); -+ memcg->id.id = 0; -+ -+ /* Memcg ID pins CSS */ -+ css_put(&memcg->css); -+ } -+} -+ -+static inline void mem_cgroup_id_get(struct mem_cgroup *memcg) -+{ -+ mem_cgroup_id_get_many(memcg, 1); -+} -+ -+static inline void mem_cgroup_id_put(struct mem_cgroup *memcg) -+{ -+ mem_cgroup_id_put_many(memcg, 1); -+} -+ -+/** -+ * mem_cgroup_from_id - look up a memcg from a memcg id -+ * @id: the memcg id to look up -+ * -+ * Caller must hold rcu_read_lock(). -+ */ -+struct mem_cgroup *mem_cgroup_from_id(unsigned short id) -+{ -+ WARN_ON_ONCE(!rcu_read_lock_held()); -+ return idr_find(&mem_cgroup_idr, id); -+} -+ - static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) - { - struct mem_cgroup_per_node *pn; -@@ -4178,6 +4246,12 @@ static struct mem_cgroup *mem_cgroup_alloc(void) - if (memcg_wb_domain_init(memcg, GFP_KERNEL)) - goto out_free_stat; - -+ memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL, -+ 1, MEM_CGROUP_ID_MAX, -+ GFP_KERNEL); -+ if (memcg->id.id < 0) -+ goto out_free_stat; -+ - return memcg; - - out_free_stat: -@@ -4263,9 +4337,11 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) - #ifdef CONFIG_CGROUP_WRITEBACK - INIT_LIST_HEAD(&memcg->cgwb_list); - #endif -+ idr_replace(&mem_cgroup_idr, memcg, memcg->id.id); - return &memcg->css; - - free_out: -+ idr_remove(&mem_cgroup_idr, memcg->id.id); - __mem_cgroup_free(memcg); - return ERR_PTR(error); - } -@@ -4277,8 +4353,9 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) - struct mem_cgroup *parent = mem_cgroup_from_css(css->parent); - int ret; - -- if (css->id > MEM_CGROUP_ID_MAX) -- return -ENOSPC; -+ /* Online state pins memcg ID, memcg ID pins CSS */ -+ mem_cgroup_id_get(mem_cgroup_from_css(css)); -+ css_get(css); - - if (!parent) - return 0; -@@ -4352,6 +4429,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) - memcg_deactivate_kmem(memcg); - - wb_memcg_offline(memcg); -+ -+ mem_cgroup_id_put(memcg); - } - - static void mem_cgroup_css_released(struct cgroup_subsys_state *css) -@@ -4785,6 +4864,8 @@ static void __mem_cgroup_clear_mc(void) - if (!mem_cgroup_is_root(mc.from)) - page_counter_uncharge(&mc.from->memsw, mc.moved_swap); - -+ mem_cgroup_id_put_many(mc.from, mc.moved_swap); -+ - /* - * we charged both to->memory and to->memsw, so we - * should uncharge to->memory. -@@ -4792,9 +4873,9 @@ static void __mem_cgroup_clear_mc(void) - if (!mem_cgroup_is_root(mc.to)) - page_counter_uncharge(&mc.to->memory, mc.moved_swap); - -- css_put_many(&mc.from->css, mc.moved_swap); -+ mem_cgroup_id_get_many(mc.to, mc.moved_swap); -+ css_put_many(&mc.to->css, mc.moved_swap); - -- /* we've already done css_get(mc.to) */ - mc.moved_swap = 0; - } - memcg_oom_recover(from); -@@ -5670,7 +5751,7 @@ subsys_initcall(mem_cgroup_init); - */ - void mem_cgroup_swapout(struct page *page, swp_entry_t entry) - { -- struct mem_cgroup *memcg; -+ struct mem_cgroup *memcg, *swap_memcg; - unsigned short oldid; - - VM_BUG_ON_PAGE(PageLRU(page), page); -@@ -5685,15 +5766,27 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) - if (!memcg) - return; - -- oldid = swap_cgroup_record(entry, mem_cgroup_id(memcg)); -+ /* -+ * In case the memcg owning these pages has been offlined and doesn't -+ * have an ID allocated to it anymore, charge the closest online -+ * ancestor for the swap instead and transfer the memory+swap charge. -+ */ -+ swap_memcg = mem_cgroup_id_get_online(memcg); -+ oldid = swap_cgroup_record(entry, mem_cgroup_id(swap_memcg)); - VM_BUG_ON_PAGE(oldid, page); -- mem_cgroup_swap_statistics(memcg, true); -+ mem_cgroup_swap_statistics(swap_memcg, true); - - page->mem_cgroup = NULL; - - if (!mem_cgroup_is_root(memcg)) - page_counter_uncharge(&memcg->memory, 1); - -+ if (memcg != swap_memcg) { -+ if (!mem_cgroup_is_root(swap_memcg)) -+ page_counter_charge(&swap_memcg->memsw, 1); -+ page_counter_uncharge(&memcg->memsw, 1); -+ } -+ - /* - * Interrupts should be disabled here because the caller holds the - * mapping->tree_lock lock which is taken with interrupts-off. It is -@@ -5703,6 +5796,9 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) - VM_BUG_ON(!irqs_disabled()); - mem_cgroup_charge_statistics(memcg, page, -1); - memcg_check_events(memcg, page); -+ -+ if (!mem_cgroup_is_root(memcg)) -+ css_put(&memcg->css); - } - - /** -@@ -5726,7 +5822,7 @@ void mem_cgroup_uncharge_swap(swp_entry_t entry) - if (!mem_cgroup_is_root(memcg)) - page_counter_uncharge(&memcg->memsw, 1); - mem_cgroup_swap_statistics(memcg, false); -- css_put(&memcg->css); -+ mem_cgroup_id_put(memcg); - } - rcu_read_unlock(); - } -diff --git a/mm/slab_common.c b/mm/slab_common.c -index 3c6a86b4ec25..bec2fce9fafc 100644 ---- a/mm/slab_common.c -+++ b/mm/slab_common.c -@@ -521,8 +521,8 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg, - goto out_unlock; - - cgroup_name(css->cgroup, memcg_name_buf, sizeof(memcg_name_buf)); -- cache_name = kasprintf(GFP_KERNEL, "%s(%d:%s)", root_cache->name, -- css->id, memcg_name_buf); -+ cache_name = kasprintf(GFP_KERNEL, "%s(%llu:%s)", root_cache->name, -+ css->serial_nr, memcg_name_buf); - if (!cache_name) - goto out_unlock; - -diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c -index 2b68418c7198..ffe95d954007 100644 ---- a/net/ipv4/fib_semantics.c -+++ b/net/ipv4/fib_semantics.c -@@ -479,6 +479,9 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, - if (!rtnh_ok(rtnh, remaining)) - return -EINVAL; - -+ if (rtnh->rtnh_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) -+ return -EINVAL; -+ - nexthop_nh->nh_flags = - (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; - nexthop_nh->nh_oif = rtnh->rtnh_ifindex; -@@ -1003,6 +1006,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg) - if (fib_props[cfg->fc_type].scope > cfg->fc_scope) - goto err_inval; - -+ if (cfg->fc_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) -+ goto err_inval; -+ - #ifdef CONFIG_IP_ROUTE_MULTIPATH - if (cfg->fc_mp) { - nhs = fib_count_nexthops(cfg->fc_mp, cfg->fc_mp_len); -diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c -index d4c51158470f..12b98e257c5f 100644 ---- a/net/ipv4/tcp_input.c -+++ b/net/ipv4/tcp_input.c -@@ -89,7 +89,7 @@ int sysctl_tcp_adv_win_scale __read_mostly = 1; - EXPORT_SYMBOL(sysctl_tcp_adv_win_scale); - - /* rfc5961 challenge ack rate limiting */ --int sysctl_tcp_challenge_ack_limit = 100; -+int sysctl_tcp_challenge_ack_limit = 1000; - - int sysctl_tcp_stdurg __read_mostly; - int sysctl_tcp_rfc1337 __read_mostly; -@@ -3390,6 +3390,23 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 - return flag; - } - -+static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, -+ u32 *last_oow_ack_time) -+{ -+ if (*last_oow_ack_time) { -+ s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time); -+ -+ if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) { -+ NET_INC_STATS_BH(net, mib_idx); -+ return true; /* rate-limited: don't send yet! */ -+ } -+ } -+ -+ *last_oow_ack_time = tcp_time_stamp; -+ -+ return false; /* not rate-limited: go ahead, send dupack now! */ -+} -+ - /* Return true if we're currently rate-limiting out-of-window ACKs and - * thus shouldn't send a dupack right now. We rate-limit dupacks in - * response to out-of-window SYNs or ACKs to mitigate ACK loops or DoS -@@ -3403,21 +3420,9 @@ bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb, - /* Data packets without SYNs are not likely part of an ACK loop. */ - if ((TCP_SKB_CB(skb)->seq != TCP_SKB_CB(skb)->end_seq) && - !tcp_hdr(skb)->syn) -- goto not_rate_limited; -- -- if (*last_oow_ack_time) { -- s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time); -- -- if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) { -- NET_INC_STATS_BH(net, mib_idx); -- return true; /* rate-limited: don't send yet! */ -- } -- } -- -- *last_oow_ack_time = tcp_time_stamp; -+ return false; - --not_rate_limited: -- return false; /* not rate-limited: go ahead, send dupack now! */ -+ return __tcp_oow_rate_limited(net, mib_idx, last_oow_ack_time); - } - - /* RFC 5961 7 [ACK Throttling] */ -@@ -3427,21 +3432,26 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb) - static u32 challenge_timestamp; - static unsigned int challenge_count; - struct tcp_sock *tp = tcp_sk(sk); -- u32 now; -+ u32 count, now; - - /* First check our per-socket dupack rate limit. */ -- if (tcp_oow_rate_limited(sock_net(sk), skb, -- LINUX_MIB_TCPACKSKIPPEDCHALLENGE, -- &tp->last_oow_ack_time)) -+ if (__tcp_oow_rate_limited(sock_net(sk), -+ LINUX_MIB_TCPACKSKIPPEDCHALLENGE, -+ &tp->last_oow_ack_time)) - return; - -- /* Then check the check host-wide RFC 5961 rate limit. */ -+ /* Then check host-wide RFC 5961 rate limit. */ - now = jiffies / HZ; - if (now != challenge_timestamp) { -+ u32 half = (sysctl_tcp_challenge_ack_limit + 1) >> 1; -+ - challenge_timestamp = now; -- challenge_count = 0; -+ WRITE_ONCE(challenge_count, half + -+ prandom_u32_max(sysctl_tcp_challenge_ack_limit)); - } -- if (++challenge_count <= sysctl_tcp_challenge_ack_limit) { -+ count = READ_ONCE(challenge_count); -+ if (count > 0) { -+ WRITE_ONCE(challenge_count, count - 1); - NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK); - tcp_send_ack(sk); - } -diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c -index 7c9883ab56e5..660c967ba84a 100644 ---- a/net/ipv4/tcp_output.c -+++ b/net/ipv4/tcp_output.c -@@ -239,7 +239,8 @@ void tcp_select_initial_window(int __space, __u32 mss, - /* Set window scaling on max possible window - * See RFC1323 for an explanation of the limit to 14 - */ -- space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max); -+ space = max_t(u32, space, sysctl_tcp_rmem[2]); -+ space = max_t(u32, space, sysctl_rmem_max); - space = min_t(u32, space, *window_clamp); - while (space > 65535 && (*rcv_wscale) < 14) { - space >>= 1; -diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c -index 923abd6b3064..8d2f7c9b491d 100644 ---- a/net/irda/af_irda.c -+++ b/net/irda/af_irda.c -@@ -1024,8 +1024,11 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, - } - - /* Check if we have opened a local TSAP */ -- if (!self->tsap) -- irda_open_tsap(self, LSAP_ANY, addr->sir_name); -+ if (!self->tsap) { -+ err = irda_open_tsap(self, LSAP_ANY, addr->sir_name); -+ if (err) -+ goto out; -+ } - - /* Move to connecting socket, start sending Connect Requests */ - sock->state = SS_CONNECTING; -diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c -index ad4fa49ad1db..9068369f8a1b 100644 ---- a/security/apparmor/apparmorfs.c -+++ b/security/apparmor/apparmorfs.c -@@ -331,6 +331,7 @@ static int aa_fs_seq_hash_show(struct seq_file *seq, void *v) - seq_printf(seq, "%.2x", profile->hash[i]); - seq_puts(seq, "\n"); - } -+ aa_put_profile(profile); - - return 0; - } diff --git a/patch/kernel/marvell-dev/patch-4.4.18-19.patch b/patch/kernel/marvell-dev/patch-4.4.18-19.patch deleted file mode 100644 index 552c978a9c..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.18-19.patch +++ /dev/null @@ -1,5823 +0,0 @@ -diff --git a/Documentation/module-signing.txt b/Documentation/module-signing.txt -index a78bf1ffa68c..39b7f612c418 100644 ---- a/Documentation/module-signing.txt -+++ b/Documentation/module-signing.txt -@@ -271,3 +271,9 @@ Since the private key is used to sign modules, viruses and malware could use - the private key to sign modules and compromise the operating system. The - private key must be either destroyed or moved to a secure location and not kept - in the root node of the kernel source tree. -+ -+If you use the same private key to sign modules for multiple kernel -+configurations, you must ensure that the module version information is -+sufficient to prevent loading a module into a different kernel. Either -+set CONFIG_MODVERSIONS=y or ensure that each configuration has a different -+kernel release string by changing EXTRAVERSION or CONFIG_LOCALVERSION. -diff --git a/Makefile b/Makefile -index eaedea88a8a7..695c64ec160c 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 18 -+SUBLEVEL = 19 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h -index 57af2f05ae84..3cab04255ae0 100644 ---- a/arch/arc/include/asm/pgtable.h -+++ b/arch/arc/include/asm/pgtable.h -@@ -110,7 +110,7 @@ - #define ___DEF (_PAGE_PRESENT | _PAGE_CACHEABLE) - - /* Set of bits not changed in pte_modify */ --#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) -+#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL) - - /* More Abbrevaited helpers */ - #define PAGE_U_NONE __pgprot(___DEF) -diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts b/arch/arm/boot/dts/sun4i-a10-a1000.dts -index 97570cb7f2fc..1d23527d4ecf 100644 ---- a/arch/arm/boot/dts/sun4i-a10-a1000.dts -+++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts -@@ -84,6 +84,7 @@ - regulator-name = "emac-3v3"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ startup-delay-us = <20000>; - enable-active-high; - gpio = <&pio 7 15 GPIO_ACTIVE_HIGH>; - }; -diff --git a/arch/arm/boot/dts/sun4i-a10-hackberry.dts b/arch/arm/boot/dts/sun4i-a10-hackberry.dts -index 2b17c5199151..6de83a6187d0 100644 ---- a/arch/arm/boot/dts/sun4i-a10-hackberry.dts -+++ b/arch/arm/boot/dts/sun4i-a10-hackberry.dts -@@ -66,6 +66,7 @@ - regulator-name = "emac-3v3"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ startup-delay-us = <20000>; - enable-active-high; - gpio = <&pio 7 19 GPIO_ACTIVE_HIGH>; - }; -diff --git a/arch/arm/boot/dts/sun4i-a10-jesurun-q5.dts b/arch/arm/boot/dts/sun4i-a10-jesurun-q5.dts -index 7afc7a64eef1..e28f080b1fd5 100644 ---- a/arch/arm/boot/dts/sun4i-a10-jesurun-q5.dts -+++ b/arch/arm/boot/dts/sun4i-a10-jesurun-q5.dts -@@ -80,6 +80,7 @@ - regulator-name = "emac-3v3"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ startup-delay-us = <20000>; - enable-active-high; - gpio = <&pio 7 19 GPIO_ACTIVE_HIGH>; /* PH19 */ - }; -diff --git a/arch/arm/boot/dts/sun5i-a10s-wobo-i5.dts b/arch/arm/boot/dts/sun5i-a10s-wobo-i5.dts -index 9fea918f949e..39731a78f087 100644 ---- a/arch/arm/boot/dts/sun5i-a10s-wobo-i5.dts -+++ b/arch/arm/boot/dts/sun5i-a10s-wobo-i5.dts -@@ -79,6 +79,7 @@ - regulator-name = "emac-3v3"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ startup-delay-us = <20000>; - enable-active-high; - gpio = <&pio 0 2 GPIO_ACTIVE_HIGH>; - }; -diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi -index cc093a482aa4..8fe39e1b680e 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi -+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi -@@ -517,7 +517,7 @@ - #address-cells = <0>; - - reg = <0x0 0xffb71000 0x0 0x1000>, -- <0x0 0xffb72000 0x0 0x1000>, -+ <0x0 0xffb72000 0x0 0x2000>, - <0x0 0xffb74000 0x0 0x2000>, - <0x0 0xffb76000 0x0 0x2000>; - interrupts = - #include - #include -+#include - #include - #include - -@@ -93,7 +94,13 @@ - disable_step_tsk x19, x20 // exceptions when scheduling. - .else - add x21, sp, #S_FRAME_SIZE -- .endif -+ get_thread_info tsk -+ /* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */ -+ ldr x20, [tsk, #TI_ADDR_LIMIT] -+ str x20, [sp, #S_ORIG_ADDR_LIMIT] -+ mov x20, #TASK_SIZE_64 -+ str x20, [tsk, #TI_ADDR_LIMIT] -+ .endif /* \el == 0 */ - mrs x22, elr_el1 - mrs x23, spsr_el1 - stp lr, x21, [sp, #S_LR] -@@ -117,6 +124,12 @@ - .endm - - .macro kernel_exit, el -+ .if \el != 0 -+ /* Restore the task's original addr_limit. */ -+ ldr x20, [sp, #S_ORIG_ADDR_LIMIT] -+ str x20, [tsk, #TI_ADDR_LIMIT] -+ .endif -+ - ldp x21, x22, [sp, #S_PC] // load ELR, SPSR - .if \el == 0 - ct_user_enter -diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c -index b1adc51b2c2e..f3c3d8fee5ba 100644 ---- a/arch/arm64/kernel/smp.c -+++ b/arch/arm64/kernel/smp.c -@@ -188,7 +188,6 @@ asmlinkage void secondary_start_kernel(void) - set_cpu_online(cpu, true); - complete(&cpu_running); - -- local_dbg_enable(); - local_irq_enable(); - local_async_enable(); - -@@ -334,8 +333,8 @@ void __init smp_cpus_done(unsigned int max_cpus) - - void __init smp_prepare_boot_cpu(void) - { -- cpuinfo_store_boot_cpu(); - set_my_cpu_offset(per_cpu_offset(smp_processor_id())); -+ cpuinfo_store_boot_cpu(); - } - - static u64 __init of_get_cpu_mpidr(struct device_node *dn) -diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c -index 116ad654dd59..653735a8c58a 100644 ---- a/arch/arm64/mm/mmu.c -+++ b/arch/arm64/mm/mmu.c -@@ -652,9 +652,9 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) - /* - * Check whether the physical FDT address is set and meets the minimum - * alignment requirement. Since we are relying on MIN_FDT_ALIGN to be -- * at least 8 bytes so that we can always access the size field of the -- * FDT header after mapping the first chunk, double check here if that -- * is indeed the case. -+ * at least 8 bytes so that we can always access the magic and size -+ * fields of the FDT header after mapping the first chunk, double check -+ * here if that is indeed the case. - */ - BUILD_BUG_ON(MIN_FDT_ALIGN < 8); - if (!dt_phys || dt_phys % MIN_FDT_ALIGN) -@@ -682,7 +682,7 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) - create_mapping(round_down(dt_phys, SWAPPER_BLOCK_SIZE), dt_virt_base, - SWAPPER_BLOCK_SIZE, prot); - -- if (fdt_check_header(dt_virt) != 0) -+ if (fdt_magic(dt_virt) != FDT_MAGIC) - return NULL; - - size = fdt_totalsize(dt_virt); -diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S -index b8f04b3f2786..1f6bb29ca53b 100644 ---- a/arch/arm64/mm/proc.S -+++ b/arch/arm64/mm/proc.S -@@ -156,6 +156,8 @@ ENTRY(__cpu_setup) - msr cpacr_el1, x0 // Enable FP/ASIMD - mov x0, #1 << 12 // Reset mdscr_el1 and disable - msr mdscr_el1, x0 // access to the DCC from EL0 -+ isb // Unmask debug exceptions now, -+ enable_dbg // since this is per-cpu - reset_pmuserenr_el0 x0 // Disable PMU access from EL0 - /* - * Memory region attributes for LPAE: -diff --git a/arch/metag/include/asm/cmpxchg_lnkget.h b/arch/metag/include/asm/cmpxchg_lnkget.h -index 0154e2807ebb..2369ad394876 100644 ---- a/arch/metag/include/asm/cmpxchg_lnkget.h -+++ b/arch/metag/include/asm/cmpxchg_lnkget.h -@@ -73,7 +73,7 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old, - " DCACHE [%2], %0\n" - #endif - "2:\n" -- : "=&d" (temp), "=&da" (retval) -+ : "=&d" (temp), "=&d" (retval) - : "da" (m), "bd" (old), "da" (new) - : "cc" - ); -diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c -index 1f910563fdf6..d76275da54cb 100644 ---- a/arch/mips/kernel/csrc-r4k.c -+++ b/arch/mips/kernel/csrc-r4k.c -@@ -23,7 +23,7 @@ static struct clocksource clocksource_mips = { - .flags = CLOCK_SOURCE_IS_CONTINUOUS, - }; - --static u64 notrace r4k_read_sched_clock(void) -+static u64 __maybe_unused notrace r4k_read_sched_clock(void) - { - return read_c0_count(); - } -@@ -82,7 +82,9 @@ int __init init_r4k_clocksource(void) - - clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); - -+#ifndef CONFIG_CPU_FREQ - sched_clock_register(r4k_read_sched_clock, 32, mips_hpt_frequency); -+#endif - - return 0; - } -diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c -index dc10c77b7500..d6476d11212e 100644 ---- a/arch/mips/kvm/emulate.c -+++ b/arch/mips/kvm/emulate.c -@@ -1629,8 +1629,14 @@ enum emulation_result kvm_mips_emulate_cache(uint32_t inst, uint32_t *opc, - - preempt_disable(); - if (KVM_GUEST_KSEGX(va) == KVM_GUEST_KSEG0) { -- if (kvm_mips_host_tlb_lookup(vcpu, va) < 0) -- kvm_mips_handle_kseg0_tlb_fault(va, vcpu); -+ if (kvm_mips_host_tlb_lookup(vcpu, va) < 0 && -+ kvm_mips_handle_kseg0_tlb_fault(va, vcpu)) { -+ kvm_err("%s: handling mapped kseg0 tlb fault for %lx, vcpu: %p, ASID: %#lx\n", -+ __func__, va, vcpu, read_c0_entryhi()); -+ er = EMULATE_FAIL; -+ preempt_enable(); -+ goto done; -+ } - } else if ((KVM_GUEST_KSEGX(va) < KVM_GUEST_KSEG0) || - KVM_GUEST_KSEGX(va) == KVM_GUEST_KSEG23) { - int index; -@@ -1665,14 +1671,19 @@ enum emulation_result kvm_mips_emulate_cache(uint32_t inst, uint32_t *opc, - run, vcpu); - preempt_enable(); - goto dont_update_pc; -- } else { -- /* -- * We fault an entry from the guest tlb to the -- * shadow host TLB -- */ -- kvm_mips_handle_mapped_seg_tlb_fault(vcpu, tlb, -- NULL, -- NULL); -+ } -+ /* -+ * We fault an entry from the guest tlb to the -+ * shadow host TLB -+ */ -+ if (kvm_mips_handle_mapped_seg_tlb_fault(vcpu, tlb, -+ NULL, NULL)) { -+ kvm_err("%s: handling mapped seg tlb fault for %lx, index: %u, vcpu: %p, ASID: %#lx\n", -+ __func__, va, index, vcpu, -+ read_c0_entryhi()); -+ er = EMULATE_FAIL; -+ preempt_enable(); -+ goto done; - } - } - } else { -@@ -2633,8 +2644,13 @@ enum emulation_result kvm_mips_handle_tlbmiss(unsigned long cause, - * OK we have a Guest TLB entry, now inject it into the - * shadow host TLB - */ -- kvm_mips_handle_mapped_seg_tlb_fault(vcpu, tlb, NULL, -- NULL); -+ if (kvm_mips_handle_mapped_seg_tlb_fault(vcpu, tlb, -+ NULL, NULL)) { -+ kvm_err("%s: handling mapped seg tlb fault for %lx, index: %u, vcpu: %p, ASID: %#lx\n", -+ __func__, va, index, vcpu, -+ read_c0_entryhi()); -+ er = EMULATE_FAIL; -+ } - } - } - -diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c -index aed0ac2a4972..7a7ed9ca01bb 100644 ---- a/arch/mips/kvm/tlb.c -+++ b/arch/mips/kvm/tlb.c -@@ -276,7 +276,7 @@ int kvm_mips_handle_kseg0_tlb_fault(unsigned long badvaddr, - } - - gfn = (KVM_GUEST_CPHYSADDR(badvaddr) >> PAGE_SHIFT); -- if (gfn >= kvm->arch.guest_pmap_npages) { -+ if ((gfn | 1) >= kvm->arch.guest_pmap_npages) { - kvm_err("%s: Invalid gfn: %#llx, BadVaddr: %#lx\n", __func__, - gfn, badvaddr); - kvm_mips_dump_host_tlbs(); -@@ -361,25 +361,39 @@ int kvm_mips_handle_mapped_seg_tlb_fault(struct kvm_vcpu *vcpu, - unsigned long entryhi = 0, entrylo0 = 0, entrylo1 = 0; - struct kvm *kvm = vcpu->kvm; - pfn_t pfn0, pfn1; -- -- if ((tlb->tlb_hi & VPN2_MASK) == 0) { -- pfn0 = 0; -- pfn1 = 0; -- } else { -- if (kvm_mips_map_page(kvm, mips3_tlbpfn_to_paddr(tlb->tlb_lo0) -- >> PAGE_SHIFT) < 0) -- return -1; -- -- if (kvm_mips_map_page(kvm, mips3_tlbpfn_to_paddr(tlb->tlb_lo1) -- >> PAGE_SHIFT) < 0) -- return -1; -- -- pfn0 = kvm->arch.guest_pmap[mips3_tlbpfn_to_paddr(tlb->tlb_lo0) -- >> PAGE_SHIFT]; -- pfn1 = kvm->arch.guest_pmap[mips3_tlbpfn_to_paddr(tlb->tlb_lo1) -- >> PAGE_SHIFT]; -+ gfn_t gfn0, gfn1; -+ long tlb_lo[2]; -+ -+ tlb_lo[0] = tlb->tlb_lo0; -+ tlb_lo[1] = tlb->tlb_lo1; -+ -+ /* -+ * The commpage address must not be mapped to anything else if the guest -+ * TLB contains entries nearby, or commpage accesses will break. -+ */ -+ if (!((tlb->tlb_hi ^ KVM_GUEST_COMMPAGE_ADDR) & -+ VPN2_MASK & (PAGE_MASK << 1))) -+ tlb_lo[(KVM_GUEST_COMMPAGE_ADDR >> PAGE_SHIFT) & 1] = 0; -+ -+ gfn0 = mips3_tlbpfn_to_paddr(tlb_lo[0]) >> PAGE_SHIFT; -+ gfn1 = mips3_tlbpfn_to_paddr(tlb_lo[1]) >> PAGE_SHIFT; -+ if (gfn0 >= kvm->arch.guest_pmap_npages || -+ gfn1 >= kvm->arch.guest_pmap_npages) { -+ kvm_err("%s: Invalid gfn: [%#llx, %#llx], EHi: %#lx\n", -+ __func__, gfn0, gfn1, tlb->tlb_hi); -+ kvm_mips_dump_guest_tlbs(vcpu); -+ return -1; - } - -+ if (kvm_mips_map_page(kvm, gfn0) < 0) -+ return -1; -+ -+ if (kvm_mips_map_page(kvm, gfn1) < 0) -+ return -1; -+ -+ pfn0 = kvm->arch.guest_pmap[gfn0]; -+ pfn1 = kvm->arch.guest_pmap[gfn1]; -+ - if (hpa0) - *hpa0 = pfn0 << PAGE_SHIFT; - -@@ -391,9 +405,9 @@ int kvm_mips_handle_mapped_seg_tlb_fault(struct kvm_vcpu *vcpu, - kvm_mips_get_kernel_asid(vcpu) : - kvm_mips_get_user_asid(vcpu)); - entrylo0 = mips3_paddr_to_tlbpfn(pfn0 << PAGE_SHIFT) | (0x3 << 3) | -- (tlb->tlb_lo0 & MIPS3_PG_D) | (tlb->tlb_lo0 & MIPS3_PG_V); -+ (tlb_lo[0] & MIPS3_PG_D) | (tlb_lo[0] & MIPS3_PG_V); - entrylo1 = mips3_paddr_to_tlbpfn(pfn1 << PAGE_SHIFT) | (0x3 << 3) | -- (tlb->tlb_lo1 & MIPS3_PG_D) | (tlb->tlb_lo1 & MIPS3_PG_V); -+ (tlb_lo[1] & MIPS3_PG_D) | (tlb_lo[1] & MIPS3_PG_V); - - kvm_debug("@ %#lx tlb_lo0: 0x%08lx tlb_lo1: 0x%08lx\n", vcpu->arch.pc, - tlb->tlb_lo0, tlb->tlb_lo1); -@@ -794,10 +808,16 @@ uint32_t kvm_get_inst(uint32_t *opc, struct kvm_vcpu *vcpu) - local_irq_restore(flags); - return KVM_INVALID_INST; - } -- kvm_mips_handle_mapped_seg_tlb_fault(vcpu, -- &vcpu->arch. -- guest_tlb[index], -- NULL, NULL); -+ if (kvm_mips_handle_mapped_seg_tlb_fault(vcpu, -+ &vcpu->arch.guest_tlb[index], -+ NULL, NULL)) { -+ kvm_err("%s: handling mapped seg tlb fault failed for %p, index: %u, vcpu: %p, ASID: %#lx\n", -+ __func__, opc, index, vcpu, -+ read_c0_entryhi()); -+ kvm_mips_dump_guest_tlbs(vcpu); -+ local_irq_restore(flags); -+ return KVM_INVALID_INST; -+ } - inst = *(opc); - } - local_irq_restore(flags); -diff --git a/arch/mips/loongson64/loongson-3/hpet.c b/arch/mips/loongson64/loongson-3/hpet.c -index a2631a52ca99..444802e78554 100644 ---- a/arch/mips/loongson64/loongson-3/hpet.c -+++ b/arch/mips/loongson64/loongson-3/hpet.c -@@ -13,8 +13,8 @@ - #define SMBUS_PCI_REG64 0x64 - #define SMBUS_PCI_REGB4 0xb4 - --#define HPET_MIN_CYCLES 64 --#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1)) -+#define HPET_MIN_CYCLES 16 -+#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES * 12) - - static DEFINE_SPINLOCK(hpet_lock); - DEFINE_PER_CPU(struct clock_event_device, hpet_clockevent_device); -@@ -157,14 +157,14 @@ static int hpet_tick_resume(struct clock_event_device *evt) - static int hpet_next_event(unsigned long delta, - struct clock_event_device *evt) - { -- unsigned int cnt; -- int res; -+ u32 cnt; -+ s32 res; - - cnt = hpet_read(HPET_COUNTER); -- cnt += delta; -+ cnt += (u32) delta; - hpet_write(HPET_T0_CMP, cnt); - -- res = (int)(cnt - hpet_read(HPET_COUNTER)); -+ res = (s32)(cnt - hpet_read(HPET_COUNTER)); - - return res < HPET_MIN_CYCLES ? -ETIME : 0; - } -@@ -230,7 +230,7 @@ void __init setup_hpet_timer(void) - - cd = &per_cpu(hpet_clockevent_device, cpu); - cd->name = "hpet"; -- cd->rating = 320; -+ cd->rating = 100; - cd->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; - cd->set_state_shutdown = hpet_set_state_shutdown; - cd->set_state_periodic = hpet_set_state_periodic; -diff --git a/arch/mips/mm/uasm-mips.c b/arch/mips/mm/uasm-mips.c -index b4a837893562..5abe51cad899 100644 ---- a/arch/mips/mm/uasm-mips.c -+++ b/arch/mips/mm/uasm-mips.c -@@ -65,7 +65,7 @@ static struct insn insn_table[] = { - #ifndef CONFIG_CPU_MIPSR6 - { insn_cache, M(cache_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, - #else -- { insn_cache, M6(cache_op, 0, 0, 0, cache6_op), RS | RT | SIMM9 }, -+ { insn_cache, M6(spec3_op, 0, 0, 0, cache6_op), RS | RT | SIMM9 }, - #endif - { insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, - { insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD }, -diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S -index 463af88c95a2..974f73df00bb 100644 ---- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S -+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S -@@ -655,112 +655,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) - - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM - BEGIN_FTR_SECTION -- b skip_tm --END_FTR_SECTION_IFCLR(CPU_FTR_TM) -- -- /* Turn on TM/FP/VSX/VMX so we can restore them. */ -- mfmsr r5 -- li r6, MSR_TM >> 32 -- sldi r6, r6, 32 -- or r5, r5, r6 -- ori r5, r5, MSR_FP -- oris r5, r5, (MSR_VEC | MSR_VSX)@h -- mtmsrd r5 -- -- /* -- * The user may change these outside of a transaction, so they must -- * always be context switched. -- */ -- ld r5, VCPU_TFHAR(r4) -- ld r6, VCPU_TFIAR(r4) -- ld r7, VCPU_TEXASR(r4) -- mtspr SPRN_TFHAR, r5 -- mtspr SPRN_TFIAR, r6 -- mtspr SPRN_TEXASR, r7 -- -- ld r5, VCPU_MSR(r4) -- rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 -- beq skip_tm /* TM not active in guest */ -- -- /* Make sure the failure summary is set, otherwise we'll program check -- * when we trechkpt. It's possible that this might have been not set -- * on a kvmppc_set_one_reg() call but we shouldn't let this crash the -- * host. -- */ -- oris r7, r7, (TEXASR_FS)@h -- mtspr SPRN_TEXASR, r7 -- -- /* -- * We need to load up the checkpointed state for the guest. -- * We need to do this early as it will blow away any GPRs, VSRs and -- * some SPRs. -- */ -- -- mr r31, r4 -- addi r3, r31, VCPU_FPRS_TM -- bl load_fp_state -- addi r3, r31, VCPU_VRS_TM -- bl load_vr_state -- mr r4, r31 -- lwz r7, VCPU_VRSAVE_TM(r4) -- mtspr SPRN_VRSAVE, r7 -- -- ld r5, VCPU_LR_TM(r4) -- lwz r6, VCPU_CR_TM(r4) -- ld r7, VCPU_CTR_TM(r4) -- ld r8, VCPU_AMR_TM(r4) -- ld r9, VCPU_TAR_TM(r4) -- mtlr r5 -- mtcr r6 -- mtctr r7 -- mtspr SPRN_AMR, r8 -- mtspr SPRN_TAR, r9 -- -- /* -- * Load up PPR and DSCR values but don't put them in the actual SPRs -- * till the last moment to avoid running with userspace PPR and DSCR for -- * too long. -- */ -- ld r29, VCPU_DSCR_TM(r4) -- ld r30, VCPU_PPR_TM(r4) -- -- std r2, PACATMSCRATCH(r13) /* Save TOC */ -- -- /* Clear the MSR RI since r1, r13 are all going to be foobar. */ -- li r5, 0 -- mtmsrd r5, 1 -- -- /* Load GPRs r0-r28 */ -- reg = 0 -- .rept 29 -- ld reg, VCPU_GPRS_TM(reg)(r31) -- reg = reg + 1 -- .endr -- -- mtspr SPRN_DSCR, r29 -- mtspr SPRN_PPR, r30 -- -- /* Load final GPRs */ -- ld 29, VCPU_GPRS_TM(29)(r31) -- ld 30, VCPU_GPRS_TM(30)(r31) -- ld 31, VCPU_GPRS_TM(31)(r31) -- -- /* TM checkpointed state is now setup. All GPRs are now volatile. */ -- TRECHKPT -- -- /* Now let's get back the state we need. */ -- HMT_MEDIUM -- GET_PACA(r13) -- ld r29, HSTATE_DSCR(r13) -- mtspr SPRN_DSCR, r29 -- ld r4, HSTATE_KVM_VCPU(r13) -- ld r1, HSTATE_HOST_R1(r13) -- ld r2, PACATMSCRATCH(r13) -- -- /* Set the MSR RI since we have our registers back. */ -- li r5, MSR_RI -- mtmsrd r5, 1 --skip_tm: -+ bl kvmppc_restore_tm -+END_FTR_SECTION_IFSET(CPU_FTR_TM) - #endif - - /* Load guest PMU registers */ -@@ -841,12 +737,6 @@ BEGIN_FTR_SECTION - /* Skip next section on POWER7 */ - b 8f - END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) -- /* Turn on TM so we can access TFHAR/TFIAR/TEXASR */ -- mfmsr r8 -- li r0, 1 -- rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG -- mtmsrd r8 -- - /* Load up POWER8-specific registers */ - ld r5, VCPU_IAMR(r4) - lwz r6, VCPU_PSPB(r4) -@@ -1436,106 +1326,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) - - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM - BEGIN_FTR_SECTION -- b 2f --END_FTR_SECTION_IFCLR(CPU_FTR_TM) -- /* Turn on TM. */ -- mfmsr r8 -- li r0, 1 -- rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG -- mtmsrd r8 -- -- ld r5, VCPU_MSR(r9) -- rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 -- beq 1f /* TM not active in guest. */ -- -- li r3, TM_CAUSE_KVM_RESCHED -- -- /* Clear the MSR RI since r1, r13 are all going to be foobar. */ -- li r5, 0 -- mtmsrd r5, 1 -- -- /* All GPRs are volatile at this point. */ -- TRECLAIM(R3) -- -- /* Temporarily store r13 and r9 so we have some regs to play with */ -- SET_SCRATCH0(r13) -- GET_PACA(r13) -- std r9, PACATMSCRATCH(r13) -- ld r9, HSTATE_KVM_VCPU(r13) -- -- /* Get a few more GPRs free. */ -- std r29, VCPU_GPRS_TM(29)(r9) -- std r30, VCPU_GPRS_TM(30)(r9) -- std r31, VCPU_GPRS_TM(31)(r9) -- -- /* Save away PPR and DSCR soon so don't run with user values. */ -- mfspr r31, SPRN_PPR -- HMT_MEDIUM -- mfspr r30, SPRN_DSCR -- ld r29, HSTATE_DSCR(r13) -- mtspr SPRN_DSCR, r29 -- -- /* Save all but r9, r13 & r29-r31 */ -- reg = 0 -- .rept 29 -- .if (reg != 9) && (reg != 13) -- std reg, VCPU_GPRS_TM(reg)(r9) -- .endif -- reg = reg + 1 -- .endr -- /* ... now save r13 */ -- GET_SCRATCH0(r4) -- std r4, VCPU_GPRS_TM(13)(r9) -- /* ... and save r9 */ -- ld r4, PACATMSCRATCH(r13) -- std r4, VCPU_GPRS_TM(9)(r9) -- -- /* Reload stack pointer and TOC. */ -- ld r1, HSTATE_HOST_R1(r13) -- ld r2, PACATOC(r13) -- -- /* Set MSR RI now we have r1 and r13 back. */ -- li r5, MSR_RI -- mtmsrd r5, 1 -- -- /* Save away checkpinted SPRs. */ -- std r31, VCPU_PPR_TM(r9) -- std r30, VCPU_DSCR_TM(r9) -- mflr r5 -- mfcr r6 -- mfctr r7 -- mfspr r8, SPRN_AMR -- mfspr r10, SPRN_TAR -- std r5, VCPU_LR_TM(r9) -- stw r6, VCPU_CR_TM(r9) -- std r7, VCPU_CTR_TM(r9) -- std r8, VCPU_AMR_TM(r9) -- std r10, VCPU_TAR_TM(r9) -- -- /* Restore r12 as trap number. */ -- lwz r12, VCPU_TRAP(r9) -- -- /* Save FP/VSX. */ -- addi r3, r9, VCPU_FPRS_TM -- bl store_fp_state -- addi r3, r9, VCPU_VRS_TM -- bl store_vr_state -- mfspr r6, SPRN_VRSAVE -- stw r6, VCPU_VRSAVE_TM(r9) --1: -- /* -- * We need to save these SPRs after the treclaim so that the software -- * error code is recorded correctly in the TEXASR. Also the user may -- * change these outside of a transaction, so they must always be -- * context switched. -- */ -- mfspr r5, SPRN_TFHAR -- mfspr r6, SPRN_TFIAR -- mfspr r7, SPRN_TEXASR -- std r5, VCPU_TFHAR(r9) -- std r6, VCPU_TFIAR(r9) -- std r7, VCPU_TEXASR(r9) --2: -+ bl kvmppc_save_tm -+END_FTR_SECTION_IFSET(CPU_FTR_TM) - #endif - - /* Increment yield count if they have a VPA */ -@@ -2245,6 +2037,13 @@ _GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */ - /* save FP state */ - bl kvmppc_save_fp - -+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM -+BEGIN_FTR_SECTION -+ ld r9, HSTATE_KVM_VCPU(r13) -+ bl kvmppc_save_tm -+END_FTR_SECTION_IFSET(CPU_FTR_TM) -+#endif -+ - /* - * Set DEC to the smaller of DEC and HDEC, so that we wake - * no later than the end of our timeslice (HDEC interrupts -@@ -2321,6 +2120,12 @@ kvm_end_cede: - bl kvmhv_accumulate_time - #endif - -+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM -+BEGIN_FTR_SECTION -+ bl kvmppc_restore_tm -+END_FTR_SECTION_IFSET(CPU_FTR_TM) -+#endif -+ - /* load up FP state */ - bl kvmppc_load_fp - -@@ -2629,6 +2434,239 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) - mr r4,r31 - blr - -+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM -+/* -+ * Save transactional state and TM-related registers. -+ * Called with r9 pointing to the vcpu struct. -+ * This can modify all checkpointed registers, but -+ * restores r1, r2 and r9 (vcpu pointer) before exit. -+ */ -+kvmppc_save_tm: -+ mflr r0 -+ std r0, PPC_LR_STKOFF(r1) -+ -+ /* Turn on TM. */ -+ mfmsr r8 -+ li r0, 1 -+ rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG -+ mtmsrd r8 -+ -+ ld r5, VCPU_MSR(r9) -+ rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 -+ beq 1f /* TM not active in guest. */ -+ -+ std r1, HSTATE_HOST_R1(r13) -+ li r3, TM_CAUSE_KVM_RESCHED -+ -+ /* Clear the MSR RI since r1, r13 are all going to be foobar. */ -+ li r5, 0 -+ mtmsrd r5, 1 -+ -+ /* All GPRs are volatile at this point. */ -+ TRECLAIM(R3) -+ -+ /* Temporarily store r13 and r9 so we have some regs to play with */ -+ SET_SCRATCH0(r13) -+ GET_PACA(r13) -+ std r9, PACATMSCRATCH(r13) -+ ld r9, HSTATE_KVM_VCPU(r13) -+ -+ /* Get a few more GPRs free. */ -+ std r29, VCPU_GPRS_TM(29)(r9) -+ std r30, VCPU_GPRS_TM(30)(r9) -+ std r31, VCPU_GPRS_TM(31)(r9) -+ -+ /* Save away PPR and DSCR soon so don't run with user values. */ -+ mfspr r31, SPRN_PPR -+ HMT_MEDIUM -+ mfspr r30, SPRN_DSCR -+ ld r29, HSTATE_DSCR(r13) -+ mtspr SPRN_DSCR, r29 -+ -+ /* Save all but r9, r13 & r29-r31 */ -+ reg = 0 -+ .rept 29 -+ .if (reg != 9) && (reg != 13) -+ std reg, VCPU_GPRS_TM(reg)(r9) -+ .endif -+ reg = reg + 1 -+ .endr -+ /* ... now save r13 */ -+ GET_SCRATCH0(r4) -+ std r4, VCPU_GPRS_TM(13)(r9) -+ /* ... and save r9 */ -+ ld r4, PACATMSCRATCH(r13) -+ std r4, VCPU_GPRS_TM(9)(r9) -+ -+ /* Reload stack pointer and TOC. */ -+ ld r1, HSTATE_HOST_R1(r13) -+ ld r2, PACATOC(r13) -+ -+ /* Set MSR RI now we have r1 and r13 back. */ -+ li r5, MSR_RI -+ mtmsrd r5, 1 -+ -+ /* Save away checkpinted SPRs. */ -+ std r31, VCPU_PPR_TM(r9) -+ std r30, VCPU_DSCR_TM(r9) -+ mflr r5 -+ mfcr r6 -+ mfctr r7 -+ mfspr r8, SPRN_AMR -+ mfspr r10, SPRN_TAR -+ std r5, VCPU_LR_TM(r9) -+ stw r6, VCPU_CR_TM(r9) -+ std r7, VCPU_CTR_TM(r9) -+ std r8, VCPU_AMR_TM(r9) -+ std r10, VCPU_TAR_TM(r9) -+ -+ /* Restore r12 as trap number. */ -+ lwz r12, VCPU_TRAP(r9) -+ -+ /* Save FP/VSX. */ -+ addi r3, r9, VCPU_FPRS_TM -+ bl store_fp_state -+ addi r3, r9, VCPU_VRS_TM -+ bl store_vr_state -+ mfspr r6, SPRN_VRSAVE -+ stw r6, VCPU_VRSAVE_TM(r9) -+1: -+ /* -+ * We need to save these SPRs after the treclaim so that the software -+ * error code is recorded correctly in the TEXASR. Also the user may -+ * change these outside of a transaction, so they must always be -+ * context switched. -+ */ -+ mfspr r5, SPRN_TFHAR -+ mfspr r6, SPRN_TFIAR -+ mfspr r7, SPRN_TEXASR -+ std r5, VCPU_TFHAR(r9) -+ std r6, VCPU_TFIAR(r9) -+ std r7, VCPU_TEXASR(r9) -+ -+ ld r0, PPC_LR_STKOFF(r1) -+ mtlr r0 -+ blr -+ -+/* -+ * Restore transactional state and TM-related registers. -+ * Called with r4 pointing to the vcpu struct. -+ * This potentially modifies all checkpointed registers. -+ * It restores r1, r2, r4 from the PACA. -+ */ -+kvmppc_restore_tm: -+ mflr r0 -+ std r0, PPC_LR_STKOFF(r1) -+ -+ /* Turn on TM/FP/VSX/VMX so we can restore them. */ -+ mfmsr r5 -+ li r6, MSR_TM >> 32 -+ sldi r6, r6, 32 -+ or r5, r5, r6 -+ ori r5, r5, MSR_FP -+ oris r5, r5, (MSR_VEC | MSR_VSX)@h -+ mtmsrd r5 -+ -+ /* -+ * The user may change these outside of a transaction, so they must -+ * always be context switched. -+ */ -+ ld r5, VCPU_TFHAR(r4) -+ ld r6, VCPU_TFIAR(r4) -+ ld r7, VCPU_TEXASR(r4) -+ mtspr SPRN_TFHAR, r5 -+ mtspr SPRN_TFIAR, r6 -+ mtspr SPRN_TEXASR, r7 -+ -+ ld r5, VCPU_MSR(r4) -+ rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 -+ beqlr /* TM not active in guest */ -+ std r1, HSTATE_HOST_R1(r13) -+ -+ /* Make sure the failure summary is set, otherwise we'll program check -+ * when we trechkpt. It's possible that this might have been not set -+ * on a kvmppc_set_one_reg() call but we shouldn't let this crash the -+ * host. -+ */ -+ oris r7, r7, (TEXASR_FS)@h -+ mtspr SPRN_TEXASR, r7 -+ -+ /* -+ * We need to load up the checkpointed state for the guest. -+ * We need to do this early as it will blow away any GPRs, VSRs and -+ * some SPRs. -+ */ -+ -+ mr r31, r4 -+ addi r3, r31, VCPU_FPRS_TM -+ bl load_fp_state -+ addi r3, r31, VCPU_VRS_TM -+ bl load_vr_state -+ mr r4, r31 -+ lwz r7, VCPU_VRSAVE_TM(r4) -+ mtspr SPRN_VRSAVE, r7 -+ -+ ld r5, VCPU_LR_TM(r4) -+ lwz r6, VCPU_CR_TM(r4) -+ ld r7, VCPU_CTR_TM(r4) -+ ld r8, VCPU_AMR_TM(r4) -+ ld r9, VCPU_TAR_TM(r4) -+ mtlr r5 -+ mtcr r6 -+ mtctr r7 -+ mtspr SPRN_AMR, r8 -+ mtspr SPRN_TAR, r9 -+ -+ /* -+ * Load up PPR and DSCR values but don't put them in the actual SPRs -+ * till the last moment to avoid running with userspace PPR and DSCR for -+ * too long. -+ */ -+ ld r29, VCPU_DSCR_TM(r4) -+ ld r30, VCPU_PPR_TM(r4) -+ -+ std r2, PACATMSCRATCH(r13) /* Save TOC */ -+ -+ /* Clear the MSR RI since r1, r13 are all going to be foobar. */ -+ li r5, 0 -+ mtmsrd r5, 1 -+ -+ /* Load GPRs r0-r28 */ -+ reg = 0 -+ .rept 29 -+ ld reg, VCPU_GPRS_TM(reg)(r31) -+ reg = reg + 1 -+ .endr -+ -+ mtspr SPRN_DSCR, r29 -+ mtspr SPRN_PPR, r30 -+ -+ /* Load final GPRs */ -+ ld 29, VCPU_GPRS_TM(29)(r31) -+ ld 30, VCPU_GPRS_TM(30)(r31) -+ ld 31, VCPU_GPRS_TM(31)(r31) -+ -+ /* TM checkpointed state is now setup. All GPRs are now volatile. */ -+ TRECHKPT -+ -+ /* Now let's get back the state we need. */ -+ HMT_MEDIUM -+ GET_PACA(r13) -+ ld r29, HSTATE_DSCR(r13) -+ mtspr SPRN_DSCR, r29 -+ ld r4, HSTATE_KVM_VCPU(r13) -+ ld r1, HSTATE_HOST_R1(r13) -+ ld r2, PACATMSCRATCH(r13) -+ -+ /* Set the MSR RI since we have our registers back. */ -+ li r5, MSR_RI -+ mtmsrd r5, 1 -+ -+ ld r0, PPC_LR_STKOFF(r1) -+ mtlr r0 -+ blr -+#endif -+ - /* - * We come here if we get any exception or interrupt while we are - * executing host real mode code while in guest MMU context. -diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c -index c146f3c262c3..0149ac59c273 100644 ---- a/arch/x86/kvm/mtrr.c -+++ b/arch/x86/kvm/mtrr.c -@@ -539,6 +539,7 @@ static void mtrr_lookup_var_start(struct mtrr_iter *iter) - - iter->fixed = false; - iter->start_max = iter->start; -+ iter->range = NULL; - iter->range = list_prepare_entry(iter->range, &mtrr_state->head, node); - - __mtrr_lookup_var_next(iter); -diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c -index 41e7943004fe..4589b6feeb7b 100644 ---- a/arch/x86/kvm/vmx.c -+++ b/arch/x86/kvm/vmx.c -@@ -8124,6 +8124,7 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) - if ((vectoring_info & VECTORING_INFO_VALID_MASK) && - (exit_reason != EXIT_REASON_EXCEPTION_NMI && - exit_reason != EXIT_REASON_EPT_VIOLATION && -+ exit_reason != EXIT_REASON_PML_FULL && - exit_reason != EXIT_REASON_TASK_SWITCH)) { - vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; - vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_DELIVERY_EV; -@@ -8736,6 +8737,22 @@ static void vmx_load_vmcs01(struct kvm_vcpu *vcpu) - put_cpu(); - } - -+/* -+ * Ensure that the current vmcs of the logical processor is the -+ * vmcs01 of the vcpu before calling free_nested(). -+ */ -+static void vmx_free_vcpu_nested(struct kvm_vcpu *vcpu) -+{ -+ struct vcpu_vmx *vmx = to_vmx(vcpu); -+ int r; -+ -+ r = vcpu_load(vcpu); -+ BUG_ON(r); -+ vmx_load_vmcs01(vcpu); -+ free_nested(vmx); -+ vcpu_put(vcpu); -+} -+ - static void vmx_free_vcpu(struct kvm_vcpu *vcpu) - { - struct vcpu_vmx *vmx = to_vmx(vcpu); -@@ -8744,8 +8761,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu) - vmx_destroy_pml_buffer(vmx); - free_vpid(vmx->vpid); - leave_guest_mode(vcpu); -- vmx_load_vmcs01(vcpu); -- free_nested(vmx); -+ vmx_free_vcpu_nested(vcpu); - free_loaded_vmcs(vmx->loaded_vmcs); - kfree(vmx->guest_msrs); - kvm_vcpu_uninit(vcpu); -diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c -index 8b93e634af84..ae97f24a4371 100644 ---- a/arch/x86/pci/intel_mid_pci.c -+++ b/arch/x86/pci/intel_mid_pci.c -@@ -37,6 +37,7 @@ - - /* Quirks for the listed devices */ - #define PCI_DEVICE_ID_INTEL_MRFL_MMC 0x1190 -+#define PCI_DEVICE_ID_INTEL_MRFL_HSU 0x1191 - - /* Fixed BAR fields */ - #define PCIE_VNDR_CAP_ID_FIXED_BAR 0x00 /* Fixed BAR (TBD) */ -@@ -225,13 +226,20 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) - /* Special treatment for IRQ0 */ - if (dev->irq == 0) { - /* -+ * Skip HS UART common registers device since it has -+ * IRQ0 assigned and not used by the kernel. -+ */ -+ if (dev->device == PCI_DEVICE_ID_INTEL_MRFL_HSU) -+ return -EBUSY; -+ /* - * TNG has IRQ0 assigned to eMMC controller. But there - * are also other devices with bogus PCI configuration - * that have IRQ0 assigned. This check ensures that -- * eMMC gets it. -+ * eMMC gets it. The rest of devices still could be -+ * enabled without interrupt line being allocated. - */ - if (dev->device != PCI_DEVICE_ID_INTEL_MRFL_MMC) -- return -EBUSY; -+ return 0; - } - break; - default: -diff --git a/block/bio.c b/block/bio.c -index d4d144363250..46e2cc1d4016 100644 ---- a/block/bio.c -+++ b/block/bio.c -@@ -584,6 +584,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) - bio->bi_rw = bio_src->bi_rw; - bio->bi_iter = bio_src->bi_iter; - bio->bi_io_vec = bio_src->bi_io_vec; -+ -+ bio_clone_blkcg_association(bio, bio_src); - } - EXPORT_SYMBOL(__bio_clone_fast); - -@@ -689,6 +691,8 @@ integrity_clone: - } - } - -+ bio_clone_blkcg_association(bio, bio_src); -+ - return bio; - } - EXPORT_SYMBOL(bio_clone_bioset); -@@ -2014,6 +2018,17 @@ void bio_disassociate_task(struct bio *bio) - } - } - -+/** -+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio -+ * @dst: destination bio -+ * @src: source bio -+ */ -+void bio_clone_blkcg_association(struct bio *dst, struct bio *src) -+{ -+ if (src->bi_css) -+ WARN_ON(bio_associate_blkcg(dst, src->bi_css)); -+} -+ - #endif /* CONFIG_BLK_CGROUP */ - - static void __init biovec_init_slabs(void) -diff --git a/block/genhd.c b/block/genhd.c -index d2a1d43bf9fa..a5bed6bc869d 100644 ---- a/block/genhd.c -+++ b/block/genhd.c -@@ -612,7 +612,7 @@ void add_disk(struct gendisk *disk) - - /* Register BDI before referencing it from bdev */ - bdi = &disk->queue->backing_dev_info; -- bdi_register_dev(bdi, disk_devt(disk)); -+ bdi_register_owner(bdi, disk_to_dev(disk)); - - blk_register_region(disk_devt(disk), disk->minors, NULL, - exact_match, exact_lock, disk); -diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c -index b420fb46669d..43f20328f830 100644 ---- a/drivers/acpi/ec.c -+++ b/drivers/acpi/ec.c -@@ -101,6 +101,7 @@ enum ec_command { - #define ACPI_EC_UDELAY_POLL 550 /* Wait 1ms for EC transaction polling */ - #define ACPI_EC_CLEAR_MAX 100 /* Maximum number of events to query - * when trying to clear the EC */ -+#define ACPI_EC_MAX_QUERIES 16 /* Maximum number of parallel queries */ - - enum { - EC_FLAGS_QUERY_PENDING, /* Query is pending */ -@@ -121,6 +122,10 @@ static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; - module_param(ec_delay, uint, 0644); - MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes"); - -+static unsigned int ec_max_queries __read_mostly = ACPI_EC_MAX_QUERIES; -+module_param(ec_max_queries, uint, 0644); -+MODULE_PARM_DESC(ec_max_queries, "Maximum parallel _Qxx evaluations"); -+ - static bool ec_busy_polling __read_mostly; - module_param(ec_busy_polling, bool, 0644); - MODULE_PARM_DESC(ec_busy_polling, "Use busy polling to advance EC transaction"); -@@ -174,6 +179,7 @@ static void acpi_ec_event_processor(struct work_struct *work); - - struct acpi_ec *boot_ec, *first_ec; - EXPORT_SYMBOL(first_ec); -+static struct workqueue_struct *ec_query_wq; - - static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */ - static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ -@@ -1097,7 +1103,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data) - * work queue execution. - */ - ec_dbg_evt("Query(0x%02x) scheduled", value); -- if (!schedule_work(&q->work)) { -+ if (!queue_work(ec_query_wq, &q->work)) { - ec_dbg_evt("Query(0x%02x) overlapped", value); - result = -EBUSY; - } -@@ -1657,15 +1663,41 @@ static struct acpi_driver acpi_ec_driver = { - }, - }; - -+static inline int acpi_ec_query_init(void) -+{ -+ if (!ec_query_wq) { -+ ec_query_wq = alloc_workqueue("kec_query", 0, -+ ec_max_queries); -+ if (!ec_query_wq) -+ return -ENODEV; -+ } -+ return 0; -+} -+ -+static inline void acpi_ec_query_exit(void) -+{ -+ if (ec_query_wq) { -+ destroy_workqueue(ec_query_wq); -+ ec_query_wq = NULL; -+ } -+} -+ - int __init acpi_ec_init(void) - { -- int result = 0; -+ int result; - -+ /* register workqueue for _Qxx evaluations */ -+ result = acpi_ec_query_init(); -+ if (result) -+ goto err_exit; - /* Now register the driver for the EC */ - result = acpi_bus_register_driver(&acpi_ec_driver); -- if (result < 0) -- return -ENODEV; -+ if (result) -+ goto err_exit; - -+err_exit: -+ if (result) -+ acpi_ec_query_exit(); - return result; - } - -@@ -1675,5 +1707,6 @@ static void __exit acpi_ec_exit(void) - { - - acpi_bus_unregister_driver(&acpi_ec_driver); -+ acpi_ec_query_exit(); - } - #endif /* 0 */ -diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c -index 4a414a5a3165..b9065506a847 100644 ---- a/drivers/bluetooth/hci_intel.c -+++ b/drivers/bluetooth/hci_intel.c -@@ -1234,8 +1234,7 @@ static int intel_probe(struct platform_device *pdev) - - idev->pdev = pdev; - -- idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset", -- GPIOD_OUT_LOW); -+ idev->reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(idev->reset)) { - dev_err(&pdev->dev, "Unable to retrieve gpio\n"); - return PTR_ERR(idev->reset); -@@ -1247,8 +1246,7 @@ static int intel_probe(struct platform_device *pdev) - - dev_err(&pdev->dev, "No IRQ, falling back to gpio-irq\n"); - -- host_wake = devm_gpiod_get_optional(&pdev->dev, "host-wake", -- GPIOD_IN); -+ host_wake = devm_gpiod_get(&pdev->dev, "host-wake", GPIOD_IN); - if (IS_ERR(host_wake)) { - dev_err(&pdev->dev, "Unable to retrieve IRQ\n"); - goto no_irq; -diff --git a/drivers/char/random.c b/drivers/char/random.c -index 0227b0465b40..491a4dce13fe 100644 ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -948,6 +948,7 @@ void add_interrupt_randomness(int irq, int irq_flags) - /* award one bit for the contents of the fast pool */ - credit_entropy_bits(r, credit + 1); - } -+EXPORT_SYMBOL_GPL(add_interrupt_randomness); - - #ifdef CONFIG_BLOCK - void add_disk_randomness(struct gendisk *disk) -@@ -1460,12 +1461,16 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) - static ssize_t - urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) - { -+ static int maxwarn = 10; - int ret; - -- if (unlikely(nonblocking_pool.initialized == 0)) -- printk_once(KERN_NOTICE "random: %s urandom read " -- "with %d bits of entropy available\n", -- current->comm, nonblocking_pool.entropy_total); -+ if (unlikely(nonblocking_pool.initialized == 0) && -+ maxwarn > 0) { -+ maxwarn--; -+ printk(KERN_NOTICE "random: %s: uninitialized urandom read " -+ "(%zd bytes read, %d bits of entropy available)\n", -+ current->comm, nbytes, nonblocking_pool.entropy_total); -+ } - - nbytes = min_t(size_t, nbytes, INT_MAX >> (ENTROPY_SHIFT + 3)); - ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); -@@ -1847,12 +1852,18 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, - { - struct entropy_store *poolp = &input_pool; - -- /* Suspend writing if we're above the trickle threshold. -- * We'll be woken up again once below random_write_wakeup_thresh, -- * or when the calling thread is about to terminate. -- */ -- wait_event_interruptible(random_write_wait, kthread_should_stop() || -+ if (unlikely(nonblocking_pool.initialized == 0)) -+ poolp = &nonblocking_pool; -+ else { -+ /* Suspend writing if we're above the trickle -+ * threshold. We'll be woken up again once below -+ * random_write_wakeup_thresh, or when the calling -+ * thread is about to terminate. -+ */ -+ wait_event_interruptible(random_write_wait, -+ kthread_should_stop() || - ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); -+ } - mix_pool_bytes(poolp, buffer, count); - credit_entropy_bits(poolp, entropy); - } -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c -index f53b02a6bc05..6e80e4298274 100644 ---- a/drivers/cpufreq/intel_pstate.c -+++ b/drivers/cpufreq/intel_pstate.c -@@ -662,7 +662,7 @@ static int core_get_max_pstate(void) - if (err) - goto skip_tar; - -- tdp_msr = MSR_CONFIG_TDP_NOMINAL + tdp_ctrl; -+ tdp_msr = MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl & 0x3); - err = rdmsrl_safe(tdp_msr, &tdp_ratio); - if (err) - goto skip_tar; -diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c -index 58aed67b7eba..3c8f19f5ac81 100644 ---- a/drivers/edac/edac_mc_sysfs.c -+++ b/drivers/edac/edac_mc_sysfs.c -@@ -313,7 +313,6 @@ static struct device_type csrow_attr_type = { - * possible dynamic channel DIMM Label attribute files - * - */ -- - DEVICE_CHANNEL(ch0_dimm_label, S_IRUGO | S_IWUSR, - channel_dimm_label_show, channel_dimm_label_store, 0); - DEVICE_CHANNEL(ch1_dimm_label, S_IRUGO | S_IWUSR, -@@ -326,6 +325,10 @@ DEVICE_CHANNEL(ch4_dimm_label, S_IRUGO | S_IWUSR, - channel_dimm_label_show, channel_dimm_label_store, 4); - DEVICE_CHANNEL(ch5_dimm_label, S_IRUGO | S_IWUSR, - channel_dimm_label_show, channel_dimm_label_store, 5); -+DEVICE_CHANNEL(ch6_dimm_label, S_IRUGO | S_IWUSR, -+ channel_dimm_label_show, channel_dimm_label_store, 6); -+DEVICE_CHANNEL(ch7_dimm_label, S_IRUGO | S_IWUSR, -+ channel_dimm_label_show, channel_dimm_label_store, 7); - - /* Total possible dynamic DIMM Label attribute file table */ - static struct attribute *dynamic_csrow_dimm_attr[] = { -@@ -335,6 +338,8 @@ static struct attribute *dynamic_csrow_dimm_attr[] = { - &dev_attr_legacy_ch3_dimm_label.attr.attr, - &dev_attr_legacy_ch4_dimm_label.attr.attr, - &dev_attr_legacy_ch5_dimm_label.attr.attr, -+ &dev_attr_legacy_ch6_dimm_label.attr.attr, -+ &dev_attr_legacy_ch7_dimm_label.attr.attr, - NULL - }; - -@@ -351,6 +356,10 @@ DEVICE_CHANNEL(ch4_ce_count, S_IRUGO, - channel_ce_count_show, NULL, 4); - DEVICE_CHANNEL(ch5_ce_count, S_IRUGO, - channel_ce_count_show, NULL, 5); -+DEVICE_CHANNEL(ch6_ce_count, S_IRUGO, -+ channel_ce_count_show, NULL, 6); -+DEVICE_CHANNEL(ch7_ce_count, S_IRUGO, -+ channel_ce_count_show, NULL, 7); - - /* Total possible dynamic ce_count attribute file table */ - static struct attribute *dynamic_csrow_ce_count_attr[] = { -@@ -360,6 +369,8 @@ static struct attribute *dynamic_csrow_ce_count_attr[] = { - &dev_attr_legacy_ch3_ce_count.attr.attr, - &dev_attr_legacy_ch4_ce_count.attr.attr, - &dev_attr_legacy_ch5_ce_count.attr.attr, -+ &dev_attr_legacy_ch6_ce_count.attr.attr, -+ &dev_attr_legacy_ch7_ce_count.attr.attr, - NULL - }; - -@@ -371,9 +382,16 @@ static umode_t csrow_dev_is_visible(struct kobject *kobj, - - if (idx >= csrow->nr_channels) - return 0; -+ -+ if (idx >= ARRAY_SIZE(dynamic_csrow_ce_count_attr) - 1) { -+ WARN_ONCE(1, "idx: %d\n", idx); -+ return 0; -+ } -+ - /* Only expose populated DIMMs */ - if (!csrow->channels[idx]->dimm->nr_pages) - return 0; -+ - return attr->mode; - } - -diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c -index 70097472b02c..c50e930d97d3 100644 ---- a/drivers/gpio/gpio-intel-mid.c -+++ b/drivers/gpio/gpio-intel-mid.c -@@ -17,7 +17,6 @@ - * Moorestown platform Langwell chip. - * Medfield platform Penwell chip. - * Clovertrail platform Cloverview chip. -- * Merrifield platform Tangier chip. - */ - - #include -@@ -64,10 +63,6 @@ enum GPIO_REG { - /* intel_mid gpio driver data */ - struct intel_mid_gpio_ddata { - u16 ngpio; /* number of gpio pins */ -- u32 gplr_offset; /* offset of first GPLR register from base */ -- u32 flis_base; /* base address of FLIS registers */ -- u32 flis_len; /* length of FLIS registers */ -- u32 (*get_flis_offset)(int gpio); - u32 chip_irq_type; /* chip interrupt type */ - }; - -@@ -257,15 +252,6 @@ static const struct intel_mid_gpio_ddata gpio_cloverview_core = { - .chip_irq_type = INTEL_MID_IRQ_TYPE_EDGE, - }; - --static const struct intel_mid_gpio_ddata gpio_tangier = { -- .ngpio = 192, -- .gplr_offset = 4, -- .flis_base = 0xff0c0000, -- .flis_len = 0x8000, -- .get_flis_offset = NULL, -- .chip_irq_type = INTEL_MID_IRQ_TYPE_EDGE, --}; -- - static const struct pci_device_id intel_gpio_ids[] = { - { - /* Lincroft */ -@@ -292,11 +278,6 @@ static const struct pci_device_id intel_gpio_ids[] = { - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x08f7), - .driver_data = (kernel_ulong_t)&gpio_cloverview_core, - }, -- { -- /* Tangier */ -- PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1199), -- .driver_data = (kernel_ulong_t)&gpio_tangier, -- }, - { 0 } - }; - MODULE_DEVICE_TABLE(pci, intel_gpio_ids); -diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c -index 2d4892cc70fb..c844d7eccb6c 100644 ---- a/drivers/gpio/gpio-pca953x.c -+++ b/drivers/gpio/gpio-pca953x.c -@@ -86,7 +86,7 @@ MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids); - #define MAX_BANK 5 - #define BANK_SZ 8 - --#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ) -+#define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ) - - struct pca953x_chip { - unsigned gpio_start; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -index 9416e0f5c1db..0aaa457a1710 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -@@ -566,28 +566,19 @@ int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev) - le16_to_cpu(firmware_info->info.usReferenceClock); - ppll->reference_div = 0; - -- if (crev < 2) -- ppll->pll_out_min = -- le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); -- else -- ppll->pll_out_min = -- le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); -+ ppll->pll_out_min = -+ le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); - ppll->pll_out_max = - le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); - -- if (crev >= 4) { -- ppll->lcd_pll_out_min = -- le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; -- if (ppll->lcd_pll_out_min == 0) -- ppll->lcd_pll_out_min = ppll->pll_out_min; -- ppll->lcd_pll_out_max = -- le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; -- if (ppll->lcd_pll_out_max == 0) -- ppll->lcd_pll_out_max = ppll->pll_out_max; -- } else { -+ ppll->lcd_pll_out_min = -+ le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; -+ if (ppll->lcd_pll_out_min == 0) - ppll->lcd_pll_out_min = ppll->pll_out_min; -+ ppll->lcd_pll_out_max = -+ le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; -+ if (ppll->lcd_pll_out_max == 0) - ppll->lcd_pll_out_max = ppll->pll_out_max; -- } - - if (ppll->pll_out_min == 0) - ppll->pll_out_min = 64800; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c -index 5a8fbadbd27b..29adbbe225c4 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c -@@ -10,6 +10,7 @@ - #include - #include - #include -+#include - - #include "amdgpu_acpi.h" - -@@ -256,6 +257,10 @@ static int amdgpu_atpx_set_discrete_state(struct amdgpu_atpx *atpx, u8 state) - if (!info) - return -EIO; - kfree(info); -+ -+ /* 200ms delay is required after off */ -+ if (state == 0) -+ msleep(200); - } - return 0; - } -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -index 7ef2c13921b4..930083336968 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -@@ -1690,7 +1690,6 @@ amdgpu_connector_add(struct amdgpu_device *adev, - DRM_MODE_SCALE_NONE); - /* no HPD on analog connectors */ - amdgpu_connector->hpd.hpd = AMDGPU_HPD_NONE; -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; - connector->interlace_allowed = true; - connector->doublescan_allowed = true; - break; -@@ -1893,8 +1892,10 @@ amdgpu_connector_add(struct amdgpu_device *adev, - } - - if (amdgpu_connector->hpd.hpd == AMDGPU_HPD_NONE) { -- if (i2c_bus->valid) -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; -+ if (i2c_bus->valid) { -+ connector->polled = DRM_CONNECTOR_POLL_CONNECT | -+ DRM_CONNECTOR_POLL_DISCONNECT; -+ } - } else - connector->polled = DRM_CONNECTOR_POLL_HPD; - -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -index c961fe093e12..16302f7d59f6 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -@@ -1793,7 +1793,23 @@ int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon) - } - - drm_kms_helper_poll_enable(dev); -+ -+ /* -+ * Most of the connector probing functions try to acquire runtime pm -+ * refs to ensure that the GPU is powered on when connector polling is -+ * performed. Since we're calling this from a runtime PM callback, -+ * trying to acquire rpm refs will cause us to deadlock. -+ * -+ * Since we're guaranteed to be holding the rpm lock, it's safe to -+ * temporarily disable the rpm helpers so this doesn't deadlock us. -+ */ -+#ifdef CONFIG_PM -+ dev->dev->power.disable_depth++; -+#endif - drm_helper_hpd_irq_event(dev); -+#ifdef CONFIG_PM -+ dev->dev->power.disable_depth--; -+#endif - - if (fbcon) { - amdgpu_fbdev_set_suspend(adev, 0); -diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -index 1cd6de575305..542517d4e584 100644 ---- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -+++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -@@ -98,6 +98,7 @@ amdgpu_atombios_encoder_set_backlight_level(struct amdgpu_encoder *amdgpu_encode - case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: - case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: - case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: -+ case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3: - if (dig->backlight_level == 0) - amdgpu_atombios_encoder_setup_dig_transmitter(encoder, - ATOM_TRANSMITTER_ACTION_LCD_BLOFF, 0, 0); -diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -index ea87033bfaf6..df17fababbd6 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -@@ -167,6 +167,7 @@ static int gmc_v7_0_init_microcode(struct amdgpu_device *adev) - break; - case CHIP_KAVERI: - case CHIP_KABINI: -+ case CHIP_MULLINS: - return 0; - default: BUG(); - } -diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c -index 6743ff7dccfa..7f4a6c550319 100644 ---- a/drivers/gpu/drm/drm_cache.c -+++ b/drivers/gpu/drm/drm_cache.c -@@ -136,6 +136,7 @@ drm_clflush_virt_range(void *addr, unsigned long length) - mb(); - for (; addr < end; addr += size) - clflushopt(addr); -+ clflushopt(end - 1); /* force serialisation */ - mb(); - return; - } -diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c -index d5d2c03fd136..8c9ac021608f 100644 ---- a/drivers/gpu/drm/drm_edid.c -+++ b/drivers/gpu/drm/drm_edid.c -@@ -73,6 +73,8 @@ - #define EDID_QUIRK_FORCE_8BPC (1 << 8) - /* Force 12bpc */ - #define EDID_QUIRK_FORCE_12BPC (1 << 9) -+/* Force 6bpc */ -+#define EDID_QUIRK_FORCE_6BPC (1 << 10) - - struct detailed_mode_closure { - struct drm_connector *connector; -@@ -99,6 +101,9 @@ static struct edid_quirk { - /* Unknown Acer */ - { "ACR", 2423, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, - -+ /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ -+ { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, -+ - /* Belinea 10 15 55 */ - { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, - { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, -@@ -3820,6 +3825,9 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) - - drm_add_display_info(edid, &connector->display_info, connector); - -+ if (quirks & EDID_QUIRK_FORCE_6BPC) -+ connector->display_info.bpc = 6; -+ - if (quirks & EDID_QUIRK_FORCE_8BPC) - connector->display_info.bpc = 8; - -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c -index c41bc42b6fa7..3292495ee10f 100644 ---- a/drivers/gpu/drm/i915/intel_display.c -+++ b/drivers/gpu/drm/i915/intel_display.c -@@ -11952,21 +11952,11 @@ connected_sink_compute_bpp(struct intel_connector *connector, - pipe_config->pipe_bpp = connector->base.display_info.bpc*3; - } - -- /* Clamp bpp to default limit on screens without EDID 1.4 */ -- if (connector->base.display_info.bpc == 0) { -- int type = connector->base.connector_type; -- int clamp_bpp = 24; -- -- /* Fall back to 18 bpp when DP sink capability is unknown. */ -- if (type == DRM_MODE_CONNECTOR_DisplayPort || -- type == DRM_MODE_CONNECTOR_eDP) -- clamp_bpp = 18; -- -- if (bpp > clamp_bpp) { -- DRM_DEBUG_KMS("clamping display bpp (was %d) to default limit of %d\n", -- bpp, clamp_bpp); -- pipe_config->pipe_bpp = clamp_bpp; -- } -+ /* Clamp bpp to 8 on screens without EDID 1.4 */ -+ if (connector->base.display_info.bpc == 0 && bpp > 24) { -+ DRM_DEBUG_KMS("clamping display bpp (was %d) to default limit of 24\n", -+ bpp); -+ pipe_config->pipe_bpp = 24; - } - } - -diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c -index 6dc13c02c28e..e362a30776fa 100644 ---- a/drivers/gpu/drm/i915/intel_opregion.c -+++ b/drivers/gpu/drm/i915/intel_opregion.c -@@ -682,7 +682,7 @@ static void intel_didl_outputs(struct drm_device *dev) - } - - if (!acpi_video_bus) { -- DRM_ERROR("No ACPI video bus found\n"); -+ DRM_DEBUG_KMS("No ACPI video bus found\n"); - return; - } - -diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c -index eb434881ddbc..1e851e037c29 100644 ---- a/drivers/gpu/drm/i915/intel_pm.c -+++ b/drivers/gpu/drm/i915/intel_pm.c -@@ -4526,7 +4526,8 @@ void gen6_rps_idle(struct drm_i915_private *dev_priv) - else - gen6_set_rps(dev_priv->dev, dev_priv->rps.idle_freq); - dev_priv->rps.last_adj = 0; -- I915_WRITE(GEN6_PMINTRMSK, 0xffffffff); -+ I915_WRITE(GEN6_PMINTRMSK, -+ gen6_sanitize_rps_pm_mask(dev_priv, ~0)); - } - mutex_unlock(&dev_priv->rps.hw_lock); - -diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c -index 1d3ee5179ab8..d236fc7c425b 100644 ---- a/drivers/gpu/drm/nouveau/nouveau_drm.c -+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c -@@ -308,7 +308,16 @@ static int nouveau_drm_probe(struct pci_dev *pdev, - bool boot = false; - int ret; - -- /* remove conflicting drivers (vesafb, efifb etc) */ -+ /* We need to check that the chipset is supported before booting -+ * fbdev off the hardware, as there's no way to put it back. -+ */ -+ ret = nvkm_device_pci_new(pdev, NULL, "error", true, false, 0, &device); -+ if (ret) -+ return ret; -+ -+ nvkm_device_del(&device); -+ -+ /* Remove conflicting drivers (vesafb, efifb etc). */ - aper = alloc_apertures(3); - if (!aper) - return -ENOMEM; -diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c -index 8f715feadf56..f90568327468 100644 ---- a/drivers/gpu/drm/nouveau/nv04_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c -@@ -107,11 +107,11 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - ((image->dx + image->width) & 0xffff)); - OUT_RING(chan, bg); - OUT_RING(chan, fg); -- OUT_RING(chan, (image->height << 16) | image->width); -+ OUT_RING(chan, (image->height << 16) | ALIGN(image->width, 8)); - OUT_RING(chan, (image->height << 16) | image->width); - OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); - -- dsize = ALIGN(image->width * image->height, 32) >> 5; -+ dsize = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; - while (dsize) { - int iter_len = dsize > 128 ? 128 : dsize; - -diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c -index a4e259a00430..c8e096533f60 100644 ---- a/drivers/gpu/drm/nouveau/nv50_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c -@@ -125,7 +125,7 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - OUT_RING(chan, 0); - OUT_RING(chan, image->dy); - -- dwords = ALIGN(image->width * image->height, 32) >> 5; -+ dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; - while (dwords) { - int push = dwords > 2047 ? 2047 : dwords; - -diff --git a/drivers/gpu/drm/nouveau/nvc0_fbcon.c b/drivers/gpu/drm/nouveau/nvc0_fbcon.c -index f28315e865a5..22d32578dafd 100644 ---- a/drivers/gpu/drm/nouveau/nvc0_fbcon.c -+++ b/drivers/gpu/drm/nouveau/nvc0_fbcon.c -@@ -125,7 +125,7 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) - OUT_RING (chan, 0); - OUT_RING (chan, image->dy); - -- dwords = ALIGN(image->width * image->height, 32) >> 5; -+ dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; - while (dwords) { - int push = dwords > 2047 ? 2047 : dwords; - -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv30.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv30.c -index 69de8c6259fe..f1e15a4d4f64 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv30.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv30.c -@@ -76,8 +76,8 @@ nv30_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch, - nvkm_wo32(chan->inst, i, 0x00040004); - for (i = 0x1f18; i <= 0x3088 ; i += 16) { - nvkm_wo32(chan->inst, i + 0, 0x10700ff9); -- nvkm_wo32(chan->inst, i + 1, 0x0436086c); -- nvkm_wo32(chan->inst, i + 2, 0x000c001b); -+ nvkm_wo32(chan->inst, i + 4, 0x0436086c); -+ nvkm_wo32(chan->inst, i + 8, 0x000c001b); - } - for (i = 0x30b8; i < 0x30c8; i += 4) - nvkm_wo32(chan->inst, i, 0x0000ffff); -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv34.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv34.c -index 2207dac23981..300f5ed5de0b 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv34.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv34.c -@@ -75,8 +75,8 @@ nv34_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch, - nvkm_wo32(chan->inst, i, 0x00040004); - for (i = 0x15ac; i <= 0x271c ; i += 16) { - nvkm_wo32(chan->inst, i + 0, 0x10700ff9); -- nvkm_wo32(chan->inst, i + 1, 0x0436086c); -- nvkm_wo32(chan->inst, i + 2, 0x000c001b); -+ nvkm_wo32(chan->inst, i + 4, 0x0436086c); -+ nvkm_wo32(chan->inst, i + 8, 0x000c001b); - } - for (i = 0x274c; i < 0x275c; i += 4) - nvkm_wo32(chan->inst, i, 0x0000ffff); -diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c -index 0b04b9282f56..d4ac8c837314 100644 ---- a/drivers/gpu/drm/radeon/atombios_encoders.c -+++ b/drivers/gpu/drm/radeon/atombios_encoders.c -@@ -120,6 +120,7 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level) - case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: - case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: - case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: -+ case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3: - if (dig->backlight_level == 0) - atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_LCD_BLOFF, 0, 0); - else { -diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c -index de9a2ffcf5f7..0c5b3eeff82d 100644 ---- a/drivers/gpu/drm/radeon/radeon_atombios.c -+++ b/drivers/gpu/drm/radeon/radeon_atombios.c -@@ -1155,7 +1155,7 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) - le16_to_cpu(firmware_info->info.usReferenceClock); - p1pll->reference_div = 0; - -- if (crev < 2) -+ if ((frev < 2) && (crev < 2)) - p1pll->pll_out_min = - le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); - else -@@ -1164,7 +1164,7 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) - p1pll->pll_out_max = - le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); - -- if (crev >= 4) { -+ if (((frev < 2) && (crev >= 4)) || (frev >= 2)) { - p1pll->lcd_pll_out_min = - le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; - if (p1pll->lcd_pll_out_min == 0) -diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c -index c4b4f298a283..69ce95571136 100644 ---- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c -+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c -@@ -10,6 +10,7 @@ - #include - #include - #include -+#include - - #include "radeon_acpi.h" - -@@ -255,6 +256,10 @@ static int radeon_atpx_set_discrete_state(struct radeon_atpx *atpx, u8 state) - if (!info) - return -EIO; - kfree(info); -+ -+ /* 200ms delay is required after off */ -+ if (state == 0) -+ msleep(200); - } - return 0; - } -diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c -index 9cfc1c3e1965..30f00748ed37 100644 ---- a/drivers/gpu/drm/radeon/radeon_connectors.c -+++ b/drivers/gpu/drm/radeon/radeon_connectors.c -@@ -2058,7 +2058,6 @@ radeon_add_atom_connector(struct drm_device *dev, - RADEON_OUTPUT_CSC_BYPASS); - /* no HPD on analog connectors */ - radeon_connector->hpd.hpd = RADEON_HPD_NONE; -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; - connector->interlace_allowed = true; - connector->doublescan_allowed = true; - break; -@@ -2308,8 +2307,10 @@ radeon_add_atom_connector(struct drm_device *dev, - } - - if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { -- if (i2c_bus->valid) -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; -+ if (i2c_bus->valid) { -+ connector->polled = DRM_CONNECTOR_POLL_CONNECT | -+ DRM_CONNECTOR_POLL_DISCONNECT; -+ } - } else - connector->polled = DRM_CONNECTOR_POLL_HPD; - -@@ -2385,7 +2386,6 @@ radeon_add_legacy_connector(struct drm_device *dev, - 1); - /* no HPD on analog connectors */ - radeon_connector->hpd.hpd = RADEON_HPD_NONE; -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; - connector->interlace_allowed = true; - connector->doublescan_allowed = true; - break; -@@ -2470,10 +2470,13 @@ radeon_add_legacy_connector(struct drm_device *dev, - } - - if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { -- if (i2c_bus->valid) -- connector->polled = DRM_CONNECTOR_POLL_CONNECT; -+ if (i2c_bus->valid) { -+ connector->polled = DRM_CONNECTOR_POLL_CONNECT | -+ DRM_CONNECTOR_POLL_DISCONNECT; -+ } - } else - connector->polled = DRM_CONNECTOR_POLL_HPD; -+ - connector->display_info.subpixel_order = subpixel_order; - drm_connector_register(connector); - } -diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c -index e094c572b86e..1a2032c2c1fb 100644 ---- a/drivers/hid/uhid.c -+++ b/drivers/hid/uhid.c -@@ -51,10 +51,26 @@ struct uhid_device { - u32 report_id; - u32 report_type; - struct uhid_event report_buf; -+ struct work_struct worker; - }; - - static struct miscdevice uhid_misc; - -+static void uhid_device_add_worker(struct work_struct *work) -+{ -+ struct uhid_device *uhid = container_of(work, struct uhid_device, worker); -+ int ret; -+ -+ ret = hid_add_device(uhid->hid); -+ if (ret) { -+ hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret); -+ -+ hid_destroy_device(uhid->hid); -+ uhid->hid = NULL; -+ uhid->running = false; -+ } -+} -+ - static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev) - { - __u8 newhead; -@@ -498,18 +514,14 @@ static int uhid_dev_create2(struct uhid_device *uhid, - uhid->hid = hid; - uhid->running = true; - -- ret = hid_add_device(hid); -- if (ret) { -- hid_err(hid, "Cannot register HID device\n"); -- goto err_hid; -- } -+ /* Adding of a HID device is done through a worker, to allow HID drivers -+ * which use feature requests during .probe to work, without they would -+ * be blocked on devlock, which is held by uhid_char_write. -+ */ -+ schedule_work(&uhid->worker); - - return 0; - --err_hid: -- hid_destroy_device(hid); -- uhid->hid = NULL; -- uhid->running = false; - err_free: - kfree(uhid->rd_data); - uhid->rd_data = NULL; -@@ -550,6 +562,8 @@ static int uhid_dev_destroy(struct uhid_device *uhid) - uhid->running = false; - wake_up_interruptible(&uhid->report_wait); - -+ cancel_work_sync(&uhid->worker); -+ - hid_destroy_device(uhid->hid); - kfree(uhid->rd_data); - -@@ -612,6 +626,7 @@ static int uhid_char_open(struct inode *inode, struct file *file) - init_waitqueue_head(&uhid->waitq); - init_waitqueue_head(&uhid->report_wait); - uhid->running = false; -+ INIT_WORK(&uhid->worker, uhid_device_add_worker); - - file->private_data = uhid; - nonseekable_open(inode, file); -diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c -index f19b6f7a467a..9b5440f6b3b4 100644 ---- a/drivers/hv/vmbus_drv.c -+++ b/drivers/hv/vmbus_drv.c -@@ -41,6 +41,7 @@ - #include - #include - #include -+#include - #include "hyperv_vmbus.h" - - static struct acpi_device *hv_acpi_dev; -@@ -826,6 +827,8 @@ static void vmbus_isr(void) - else - tasklet_schedule(&msg_dpc); - } -+ -+ add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR, 0); - } - - -diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c -index 8eff62738877..e253598d764c 100644 ---- a/drivers/i2c/busses/i2c-efm32.c -+++ b/drivers/i2c/busses/i2c-efm32.c -@@ -433,7 +433,7 @@ static int efm32_i2c_probe(struct platform_device *pdev) - ret = request_irq(ddata->irq, efm32_i2c_irq, 0, DRIVER_NAME, ddata); - if (ret < 0) { - dev_err(&pdev->dev, "failed to request irq (%d)\n", ret); -- return ret; -+ goto err_disable_clk; - } - - ret = i2c_add_adapter(&ddata->adapter); -diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c -index 5fb089e91353..fb43a242847b 100644 ---- a/drivers/infiniband/core/iwpm_util.c -+++ b/drivers/infiniband/core/iwpm_util.c -@@ -634,6 +634,7 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 nl_client, int iwpm_pid) - if (!(ibnl_put_msg(skb, &nlh, 0, 0, nl_client, - RDMA_NL_IWPM_MAPINFO, NLM_F_MULTI))) { - pr_warn("%s Unable to put NLMSG_DONE\n", __func__); -+ dev_kfree_skb(skb); - return -ENOMEM; - } - nlh->nlmsg_type = NLMSG_DONE; -diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c -index a95a32ba596e..d3b7ecd106f7 100644 ---- a/drivers/infiniband/core/sa_query.c -+++ b/drivers/infiniband/core/sa_query.c -@@ -534,7 +534,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query, gfp_t gfp_mask) - data = ibnl_put_msg(skb, &nlh, query->seq, 0, RDMA_NL_LS, - RDMA_NL_LS_OP_RESOLVE, NLM_F_REQUEST); - if (!data) { -- kfree_skb(skb); -+ nlmsg_free(skb); - return -EMSGSIZE; - } - -diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c -index 870e56b6b25f..05179f47bbde 100644 ---- a/drivers/infiniband/hw/mlx4/mad.c -+++ b/drivers/infiniband/hw/mlx4/mad.c -@@ -526,7 +526,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, - tun_tx_ix = (++tun_qp->tx_ix_head) & (MLX4_NUM_TUNNEL_BUFS - 1); - spin_unlock(&tun_qp->tx_lock); - if (ret) -- goto out; -+ goto end; - - tun_mad = (struct mlx4_rcv_tunnel_mad *) (tun_qp->tx_ring[tun_tx_ix].buf.addr); - if (tun_qp->tx_ring[tun_tx_ix].ah) -@@ -595,9 +595,15 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, - wr.wr.send_flags = IB_SEND_SIGNALED; - - ret = ib_post_send(src_qp, &wr.wr, &bad_wr); --out: -- if (ret) -- ib_destroy_ah(ah); -+ if (!ret) -+ return 0; -+ out: -+ spin_lock(&tun_qp->tx_lock); -+ tun_qp->tx_ix_tail++; -+ spin_unlock(&tun_qp->tx_lock); -+ tun_qp->tx_ring[tun_tx_ix].ah = NULL; -+end: -+ ib_destroy_ah(ah); - return ret; - } - -@@ -1278,9 +1284,15 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port, - - - ret = ib_post_send(send_qp, &wr.wr, &bad_wr); -+ if (!ret) -+ return 0; -+ -+ spin_lock(&sqp->tx_lock); -+ sqp->tx_ix_tail++; -+ spin_unlock(&sqp->tx_lock); -+ sqp->tx_ring[wire_tx_ix].ah = NULL; - out: -- if (ret) -- ib_destroy_ah(ah); -+ ib_destroy_ah(ah); - return ret; - } - -diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c -index 13eaaf45288f..ea1e2ddaddf5 100644 ---- a/drivers/infiniband/hw/mlx4/qp.c -+++ b/drivers/infiniband/hw/mlx4/qp.c -@@ -357,7 +357,7 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags) - sizeof (struct mlx4_wqe_raddr_seg); - case MLX4_IB_QPT_RC: - return sizeof (struct mlx4_wqe_ctrl_seg) + -- sizeof (struct mlx4_wqe_atomic_seg) + -+ sizeof (struct mlx4_wqe_masked_atomic_seg) + - sizeof (struct mlx4_wqe_raddr_seg); - case MLX4_IB_QPT_SMI: - case MLX4_IB_QPT_GSI: -@@ -1162,8 +1162,10 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd, - { - err = create_qp_common(to_mdev(pd->device), pd, init_attr, - udata, 0, &qp, gfp); -- if (err) -+ if (err) { -+ kfree(qp); - return ERR_PTR(err); -+ } - - qp->ibqp.qp_num = qp->mqp.qpn; - qp->xrcdn = xrcdn; -diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c -index 92ddae101ecc..8184267c7901 100644 ---- a/drivers/infiniband/hw/mlx5/cq.c -+++ b/drivers/infiniband/hw/mlx5/cq.c -@@ -763,7 +763,8 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, - if (attr->flags) - return ERR_PTR(-EINVAL); - -- if (entries < 0) -+ if (entries < 0 || -+ (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))) - return ERR_PTR(-EINVAL); - - entries = roundup_pow_of_two(entries + 1); -@@ -1094,11 +1095,16 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) - return -ENOSYS; - } - -- if (entries < 1) -+ if (entries < 1 || -+ entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) { -+ mlx5_ib_warn(dev, "wrong entries number %d, max %d\n", -+ entries, -+ 1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)); - return -EINVAL; -+ } - - entries = roundup_pow_of_two(entries + 1); -- if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1) -+ if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1) - return -EINVAL; - - if (entries == ibcq->cqe + 1) -diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c -index fd17443aeacd..bfc940ff9c8a 100644 ---- a/drivers/infiniband/hw/mlx5/main.c -+++ b/drivers/infiniband/hw/mlx5/main.c -@@ -962,14 +962,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context, - break; - - case MLX5_DEV_EVENT_PORT_DOWN: -+ case MLX5_DEV_EVENT_PORT_INITIALIZED: - ibev.event = IB_EVENT_PORT_ERR; - port = (u8)param; - break; - -- case MLX5_DEV_EVENT_PORT_INITIALIZED: -- /* not used by ULPs */ -- return; -- - case MLX5_DEV_EVENT_LID_CHANGE: - ibev.event = IB_EVENT_LID_CHANGE; - port = (u8)param; -diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c -index 307bdbca8938..cfcfbb6b84d7 100644 ---- a/drivers/infiniband/hw/mlx5/qp.c -+++ b/drivers/infiniband/hw/mlx5/qp.c -@@ -226,6 +226,8 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap, - qp->rq.max_gs = 0; - qp->rq.wqe_cnt = 0; - qp->rq.wqe_shift = 0; -+ cap->max_recv_wr = 0; -+ cap->max_recv_sge = 0; - } else { - if (ucmd) { - qp->rq.wqe_cnt = ucmd->rq_wqe_count; -@@ -2525,10 +2527,11 @@ static u8 get_fence(u8 fence, struct ib_send_wr *wr) - return MLX5_FENCE_MODE_SMALL_AND_FENCE; - else - return fence; -- -- } else { -- return 0; -+ } else if (unlikely(wr->send_flags & IB_SEND_FENCE)) { -+ return MLX5_FENCE_MODE_FENCE; - } -+ -+ return 0; - } - - static int begin_wqe(struct mlx5_ib_qp *qp, void **seg, -@@ -3092,17 +3095,19 @@ int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr - qp_attr->cap.max_recv_sge = qp->rq.max_gs; - - if (!ibqp->uobject) { -- qp_attr->cap.max_send_wr = qp->sq.wqe_cnt; -+ qp_attr->cap.max_send_wr = qp->sq.max_post; - qp_attr->cap.max_send_sge = qp->sq.max_gs; -+ qp_init_attr->qp_context = ibqp->qp_context; - } else { - qp_attr->cap.max_send_wr = 0; - qp_attr->cap.max_send_sge = 0; - } - -- /* We don't support inline sends for kernel QPs (yet), and we -- * don't know what userspace's value should be. -- */ -- qp_attr->cap.max_inline_data = 0; -+ qp_init_attr->qp_type = ibqp->qp_type; -+ qp_init_attr->recv_cq = ibqp->recv_cq; -+ qp_init_attr->send_cq = ibqp->send_cq; -+ qp_init_attr->srq = ibqp->srq; -+ qp_attr->cap.max_inline_data = qp->max_inline_data; - - qp_init_attr->cap = qp_attr->cap; - -diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c -index 7d3281866ffc..942dffca6a9d 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib_main.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c -@@ -1131,7 +1131,9 @@ struct ipoib_neigh *ipoib_neigh_get(struct net_device *dev, u8 *daddr) - neigh = NULL; - goto out_unlock; - } -- neigh->alive = jiffies; -+ -+ if (likely(skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE)) -+ neigh->alive = jiffies; - goto out_unlock; - } - } -diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c -index 2f589857a039..d15b33813021 100644 ---- a/drivers/input/mouse/elan_i2c_core.c -+++ b/drivers/input/mouse/elan_i2c_core.c -@@ -4,7 +4,8 @@ - * Copyright (c) 2013 ELAN Microelectronics Corp. - * - * Author: 林政維 (Duson Lin) -- * Version: 1.6.0 -+ * Author: KT Liao -+ * Version: 1.6.2 - * - * Based on cyapa driver: - * copyright (c) 2011-2012 Cypress Semiconductor, Inc. -@@ -40,7 +41,7 @@ - #include "elan_i2c.h" - - #define DRIVER_NAME "elan_i2c" --#define ELAN_DRIVER_VERSION "1.6.1" -+#define ELAN_DRIVER_VERSION "1.6.2" - #define ELAN_VENDOR_ID 0x04f3 - #define ETP_MAX_PRESSURE 255 - #define ETP_FWIDTH_REDUCE 90 -@@ -199,9 +200,41 @@ static int elan_sleep(struct elan_tp_data *data) - return error; - } - -+static int elan_query_product(struct elan_tp_data *data) -+{ -+ int error; -+ -+ error = data->ops->get_product_id(data->client, &data->product_id); -+ if (error) -+ return error; -+ -+ error = data->ops->get_sm_version(data->client, &data->ic_type, -+ &data->sm_version); -+ if (error) -+ return error; -+ -+ return 0; -+} -+ -+static int elan_check_ASUS_special_fw(struct elan_tp_data *data) -+{ -+ if (data->ic_type != 0x0E) -+ return false; -+ -+ switch (data->product_id) { -+ case 0x05 ... 0x07: -+ case 0x09: -+ case 0x13: -+ return true; -+ default: -+ return false; -+ } -+} -+ - static int __elan_initialize(struct elan_tp_data *data) - { - struct i2c_client *client = data->client; -+ bool woken_up = false; - int error; - - error = data->ops->initialize(client); -@@ -210,6 +243,27 @@ static int __elan_initialize(struct elan_tp_data *data) - return error; - } - -+ error = elan_query_product(data); -+ if (error) -+ return error; -+ -+ /* -+ * Some ASUS devices were shipped with firmware that requires -+ * touchpads to be woken up first, before attempting to switch -+ * them into absolute reporting mode. -+ */ -+ if (elan_check_ASUS_special_fw(data)) { -+ error = data->ops->sleep_control(client, false); -+ if (error) { -+ dev_err(&client->dev, -+ "failed to wake device up: %d\n", error); -+ return error; -+ } -+ -+ msleep(200); -+ woken_up = true; -+ } -+ - data->mode |= ETP_ENABLE_ABS; - error = data->ops->set_mode(client, data->mode); - if (error) { -@@ -218,11 +272,13 @@ static int __elan_initialize(struct elan_tp_data *data) - return error; - } - -- error = data->ops->sleep_control(client, false); -- if (error) { -- dev_err(&client->dev, -- "failed to wake device up: %d\n", error); -- return error; -+ if (!woken_up) { -+ error = data->ops->sleep_control(client, false); -+ if (error) { -+ dev_err(&client->dev, -+ "failed to wake device up: %d\n", error); -+ return error; -+ } - } - - return 0; -@@ -248,10 +304,6 @@ static int elan_query_device_info(struct elan_tp_data *data) - { - int error; - -- error = data->ops->get_product_id(data->client, &data->product_id); -- if (error) -- return error; -- - error = data->ops->get_version(data->client, false, &data->fw_version); - if (error) - return error; -@@ -261,11 +313,6 @@ static int elan_query_device_info(struct elan_tp_data *data) - if (error) - return error; - -- error = data->ops->get_sm_version(data->client, &data->ic_type, -- &data->sm_version); -- if (error) -- return error; -- - error = data->ops->get_version(data->client, true, &data->iap_version); - if (error) - return error; -diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c -index d214f22ed305..45b466e3bbe8 100644 ---- a/drivers/input/touchscreen/sur40.c -+++ b/drivers/input/touchscreen/sur40.c -@@ -126,7 +126,7 @@ struct sur40_image_header { - #define VIDEO_PACKET_SIZE 16384 - - /* polling interval (ms) */ --#define POLL_INTERVAL 4 -+#define POLL_INTERVAL 1 - - /* maximum number of contacts FIXME: this is a guess? */ - #define MAX_CONTACTS 64 -@@ -441,7 +441,7 @@ static void sur40_process_video(struct sur40_state *sur40) - - /* return error if streaming was stopped in the meantime */ - if (sur40->sequence == -1) -- goto err_poll; -+ return; - - /* mark as finished */ - v4l2_get_timestamp(&new_buf->vb.timestamp); -@@ -730,6 +730,7 @@ static int sur40_start_streaming(struct vb2_queue *vq, unsigned int count) - static void sur40_stop_streaming(struct vb2_queue *vq) - { - struct sur40_state *sur40 = vb2_get_drv_priv(vq); -+ vb2_wait_for_all_buffers(vq); - sur40->sequence = -1; - - /* Release all active buffers */ -diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c -index b9319b76a8a1..0397985a2601 100644 ---- a/drivers/iommu/amd_iommu.c -+++ b/drivers/iommu/amd_iommu.c -@@ -352,9 +352,11 @@ static void init_iommu_group(struct device *dev) - if (!domain) - goto out; - -- dma_domain = to_pdomain(domain)->priv; -+ if (to_pdomain(domain)->flags == PD_DMA_OPS_MASK) { -+ dma_domain = to_pdomain(domain)->priv; -+ init_unity_mappings_for_device(dev, dma_domain); -+ } - -- init_unity_mappings_for_device(dev, dma_domain); - out: - iommu_group_put(group); - } -@@ -2322,8 +2324,15 @@ static void update_device_table(struct protection_domain *domain) - { - struct iommu_dev_data *dev_data; - -- list_for_each_entry(dev_data, &domain->dev_list, list) -+ list_for_each_entry(dev_data, &domain->dev_list, list) { - set_dte_entry(dev_data->devid, domain, dev_data->ats.enabled); -+ -+ if (dev_data->devid == dev_data->alias) -+ continue; -+ -+ /* There is an alias, update device table entry for it */ -+ set_dte_entry(dev_data->alias, domain, dev_data->ats.enabled); -+ } - } - - static void update_domain(struct protection_domain *domain) -@@ -2970,9 +2979,7 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type) - static void amd_iommu_domain_free(struct iommu_domain *dom) - { - struct protection_domain *domain; -- -- if (!dom) -- return; -+ struct dma_ops_domain *dma_dom; - - domain = to_pdomain(dom); - -@@ -2981,13 +2988,24 @@ static void amd_iommu_domain_free(struct iommu_domain *dom) - - BUG_ON(domain->dev_cnt != 0); - -- if (domain->mode != PAGE_MODE_NONE) -- free_pagetable(domain); -+ if (!dom) -+ return; -+ -+ switch (dom->type) { -+ case IOMMU_DOMAIN_DMA: -+ dma_dom = domain->priv; -+ dma_ops_domain_free(dma_dom); -+ break; -+ default: -+ if (domain->mode != PAGE_MODE_NONE) -+ free_pagetable(domain); - -- if (domain->flags & PD_IOMMUV2_MASK) -- free_gcr3_table(domain); -+ if (domain->flags & PD_IOMMUV2_MASK) -+ free_gcr3_table(domain); - -- protection_domain_free(domain); -+ protection_domain_free(domain); -+ break; -+ } - } - - static void amd_iommu_detach_device(struct iommu_domain *dom, -diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c -index 97c41b8ab5d9..29a31eb9ace3 100644 ---- a/drivers/iommu/exynos-iommu.c -+++ b/drivers/iommu/exynos-iommu.c -@@ -647,6 +647,7 @@ static struct platform_driver exynos_sysmmu_driver __refdata = { - .name = "exynos-sysmmu", - .of_match_table = sysmmu_of_match, - .pm = &sysmmu_pm_ops, -+ .suppress_bind_attrs = true, - } - }; - -diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c -index 6763a4dfed94..24d81308a1a6 100644 ---- a/drivers/iommu/intel-iommu.c -+++ b/drivers/iommu/intel-iommu.c -@@ -2032,7 +2032,7 @@ out_unlock: - spin_unlock(&iommu->lock); - spin_unlock_irqrestore(&device_domain_lock, flags); - -- return 0; -+ return ret; - } - - struct domain_context_mapping_data { -diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c -index 09e2afcafd2d..cd0a93df4cb7 100644 ---- a/drivers/md/dm-flakey.c -+++ b/drivers/md/dm-flakey.c -@@ -289,10 +289,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) - pb->bio_submitted = true; - - /* -- * Map reads as normal. -+ * Map reads as normal only if corrupt_bio_byte set. - */ -- if (bio_data_dir(bio) == READ) -- goto map_bio; -+ if (bio_data_dir(bio) == READ) { -+ /* If flags were specified, only corrupt those that match. */ -+ if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && -+ all_corrupt_bio_flags_match(bio, fc)) -+ goto map_bio; -+ else -+ return -EIO; -+ } - - /* - * Drop writes? -@@ -330,12 +336,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) - - /* - * Corrupt successful READs while in down state. -- * If flags were specified, only corrupt those that match. - */ -- if (fc->corrupt_bio_byte && !error && pb->bio_submitted && -- (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && -- all_corrupt_bio_flags_match(bio, fc)) -- corrupt_bio_data(bio, fc); -+ if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { -+ if (fc->corrupt_bio_byte) -+ corrupt_bio_data(bio, fc); -+ else -+ return -EIO; -+ } - - return error; - } -diff --git a/drivers/md/dm.c b/drivers/md/dm.c -index c338aebb4ccd..a42729ebf272 100644 ---- a/drivers/md/dm.c -+++ b/drivers/md/dm.c -@@ -3078,7 +3078,8 @@ static void unlock_fs(struct mapped_device *md) - * Caller must hold md->suspend_lock - */ - static int __dm_suspend(struct mapped_device *md, struct dm_table *map, -- unsigned suspend_flags, int interruptible) -+ unsigned suspend_flags, int interruptible, -+ int dmf_suspended_flag) - { - bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG; - bool noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG; -@@ -3145,6 +3146,8 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map, - * to finish. - */ - r = dm_wait_for_completion(md, interruptible); -+ if (!r) -+ set_bit(dmf_suspended_flag, &md->flags); - - if (noflush) - clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags); -@@ -3206,12 +3209,10 @@ retry: - - map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); - -- r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE); -+ r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED); - if (r) - goto out_unlock; - -- set_bit(DMF_SUSPENDED, &md->flags); -- - dm_table_postsuspend_targets(map); - - out_unlock: -@@ -3305,9 +3306,8 @@ static void __dm_internal_suspend(struct mapped_device *md, unsigned suspend_fla - * would require changing .presuspend to return an error -- avoid this - * until there is a need for more elaborate variants of internal suspend. - */ -- (void) __dm_suspend(md, map, suspend_flags, TASK_UNINTERRUPTIBLE); -- -- set_bit(DMF_SUSPENDED_INTERNALLY, &md->flags); -+ (void) __dm_suspend(md, map, suspend_flags, TASK_UNINTERRUPTIBLE, -+ DMF_SUSPENDED_INTERNALLY); - - dm_table_postsuspend_targets(map); - } -diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c -index 1100e98a7b1d..7df7fb3738a0 100644 ---- a/drivers/media/dvb-core/dvb_ringbuffer.c -+++ b/drivers/media/dvb-core/dvb_ringbuffer.c -@@ -55,7 +55,13 @@ void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len) - - int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf) - { -- return (rbuf->pread==rbuf->pwrite); -+ /* smp_load_acquire() to load write pointer on reader side -+ * this pairs with smp_store_release() in dvb_ringbuffer_write(), -+ * dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset() -+ * -+ * for memory barriers also see Documentation/circular-buffers.txt -+ */ -+ return (rbuf->pread == smp_load_acquire(&rbuf->pwrite)); - } - - -@@ -64,7 +70,12 @@ ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf) - { - ssize_t free; - -- free = rbuf->pread - rbuf->pwrite; -+ /* ACCESS_ONCE() to load read pointer on writer side -+ * this pairs with smp_store_release() in dvb_ringbuffer_read(), -+ * dvb_ringbuffer_read_user(), dvb_ringbuffer_flush(), -+ * or dvb_ringbuffer_reset() -+ */ -+ free = ACCESS_ONCE(rbuf->pread) - rbuf->pwrite; - if (free <= 0) - free += rbuf->size; - return free-1; -@@ -76,7 +87,11 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf) - { - ssize_t avail; - -- avail = rbuf->pwrite - rbuf->pread; -+ /* smp_load_acquire() to load write pointer on reader side -+ * this pairs with smp_store_release() in dvb_ringbuffer_write(), -+ * dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset() -+ */ -+ avail = smp_load_acquire(&rbuf->pwrite) - rbuf->pread; - if (avail < 0) - avail += rbuf->size; - return avail; -@@ -86,14 +101,25 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf) - - void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf) - { -- rbuf->pread = rbuf->pwrite; -+ /* dvb_ringbuffer_flush() counts as read operation -+ * smp_load_acquire() to load write pointer -+ * smp_store_release() to update read pointer, this ensures that the -+ * correct pointer is visible for subsequent dvb_ringbuffer_free() -+ * calls on other cpu cores -+ */ -+ smp_store_release(&rbuf->pread, smp_load_acquire(&rbuf->pwrite)); - rbuf->error = 0; - } - EXPORT_SYMBOL(dvb_ringbuffer_flush); - - void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf) - { -- rbuf->pread = rbuf->pwrite = 0; -+ /* dvb_ringbuffer_reset() counts as read and write operation -+ * smp_store_release() to update read pointer -+ */ -+ smp_store_release(&rbuf->pread, 0); -+ /* smp_store_release() to update write pointer */ -+ smp_store_release(&rbuf->pwrite, 0); - rbuf->error = 0; - } - -@@ -119,12 +145,17 @@ ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer *rbuf, u8 __user *buf, si - return -EFAULT; - buf += split; - todo -= split; -- rbuf->pread = 0; -+ /* smp_store_release() for read pointer update to ensure -+ * that buf is not overwritten until read is complete, -+ * this pairs with ACCESS_ONCE() in dvb_ringbuffer_free() -+ */ -+ smp_store_release(&rbuf->pread, 0); - } - if (copy_to_user(buf, rbuf->data+rbuf->pread, todo)) - return -EFAULT; - -- rbuf->pread = (rbuf->pread + todo) % rbuf->size; -+ /* smp_store_release() to update read pointer, see above */ -+ smp_store_release(&rbuf->pread, (rbuf->pread + todo) % rbuf->size); - - return len; - } -@@ -139,11 +170,16 @@ void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len) - memcpy(buf, rbuf->data+rbuf->pread, split); - buf += split; - todo -= split; -- rbuf->pread = 0; -+ /* smp_store_release() for read pointer update to ensure -+ * that buf is not overwritten until read is complete, -+ * this pairs with ACCESS_ONCE() in dvb_ringbuffer_free() -+ */ -+ smp_store_release(&rbuf->pread, 0); - } - memcpy(buf, rbuf->data+rbuf->pread, todo); - -- rbuf->pread = (rbuf->pread + todo) % rbuf->size; -+ /* smp_store_release() to update read pointer, see above */ -+ smp_store_release(&rbuf->pread, (rbuf->pread + todo) % rbuf->size); - } - - -@@ -158,10 +194,16 @@ ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, size_t - memcpy(rbuf->data+rbuf->pwrite, buf, split); - buf += split; - todo -= split; -- rbuf->pwrite = 0; -+ /* smp_store_release() for write pointer update to ensure that -+ * written data is visible on other cpu cores before the pointer -+ * update, this pairs with smp_load_acquire() in -+ * dvb_ringbuffer_empty() or dvb_ringbuffer_avail() -+ */ -+ smp_store_release(&rbuf->pwrite, 0); - } - memcpy(rbuf->data+rbuf->pwrite, buf, todo); -- rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size; -+ /* smp_store_release() for write pointer update, see above */ -+ smp_store_release(&rbuf->pwrite, (rbuf->pwrite + todo) % rbuf->size); - - return len; - } -@@ -181,12 +223,18 @@ ssize_t dvb_ringbuffer_write_user(struct dvb_ringbuffer *rbuf, - return len - todo; - buf += split; - todo -= split; -- rbuf->pwrite = 0; -+ /* smp_store_release() for write pointer update to ensure that -+ * written data is visible on other cpu cores before the pointer -+ * update, this pairs with smp_load_acquire() in -+ * dvb_ringbuffer_empty() or dvb_ringbuffer_avail() -+ */ -+ smp_store_release(&rbuf->pwrite, 0); - } - status = copy_from_user(rbuf->data+rbuf->pwrite, buf, todo); - if (status) - return len - todo; -- rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size; -+ /* smp_store_release() for write pointer update, see above */ -+ smp_store_release(&rbuf->pwrite, (rbuf->pwrite + todo) % rbuf->size); - - return len; - } -diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c -index 3ffe2ecfd5ef..c8946f98ced4 100644 ---- a/drivers/media/platform/s5p-mfc/s5p_mfc.c -+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c -@@ -1029,6 +1029,11 @@ static int match_child(struct device *dev, void *data) - return !strcmp(dev_name(dev), (char *)data); - } - -+static void s5p_mfc_memdev_release(struct device *dev) -+{ -+ dma_release_declared_memory(dev); -+} -+ - static void *mfc_get_drv_data(struct platform_device *pdev); - - static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) -@@ -1041,6 +1046,9 @@ static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) - mfc_err("Not enough memory\n"); - return -ENOMEM; - } -+ -+ dev_set_name(dev->mem_dev_l, "%s", "s5p-mfc-l"); -+ dev->mem_dev_l->release = s5p_mfc_memdev_release; - device_initialize(dev->mem_dev_l); - of_property_read_u32_array(dev->plat_dev->dev.of_node, - "samsung,mfc-l", mem_info, 2); -@@ -1058,6 +1066,9 @@ static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) - mfc_err("Not enough memory\n"); - return -ENOMEM; - } -+ -+ dev_set_name(dev->mem_dev_r, "%s", "s5p-mfc-r"); -+ dev->mem_dev_r->release = s5p_mfc_memdev_release; - device_initialize(dev->mem_dev_r); - of_property_read_u32_array(dev->plat_dev->dev.of_node, - "samsung,mfc-r", mem_info, 2); -diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c -index 84fa6e9b59a1..67314c034cdb 100644 ---- a/drivers/media/rc/ir-rc5-decoder.c -+++ b/drivers/media/rc/ir-rc5-decoder.c -@@ -29,7 +29,7 @@ - #define RC5_BIT_START (1 * RC5_UNIT) - #define RC5_BIT_END (1 * RC5_UNIT) - #define RC5X_SPACE (4 * RC5_UNIT) --#define RC5_TRAILER (10 * RC5_UNIT) /* In reality, approx 100 */ -+#define RC5_TRAILER (6 * RC5_UNIT) /* In reality, approx 100 */ - - enum rc5_state { - STATE_INACTIVE, -diff --git a/drivers/media/usb/usbtv/usbtv-audio.c b/drivers/media/usb/usbtv/usbtv-audio.c -index 78c12d22dfbb..5dab02432e82 100644 ---- a/drivers/media/usb/usbtv/usbtv-audio.c -+++ b/drivers/media/usb/usbtv/usbtv-audio.c -@@ -278,6 +278,9 @@ static void snd_usbtv_trigger(struct work_struct *work) - { - struct usbtv *chip = container_of(work, struct usbtv, snd_trigger); - -+ if (!chip->snd) -+ return; -+ - if (atomic_read(&chip->snd_stream)) - usbtv_audio_start(chip); - else -@@ -378,6 +381,8 @@ err: - - void usbtv_audio_free(struct usbtv *usbtv) - { -+ cancel_work_sync(&usbtv->snd_trigger); -+ - if (usbtv->snd && usbtv->udev) { - snd_card_free(usbtv->snd); - usbtv->snd = NULL; -diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c -index 11f39791ec33..47f37683893a 100644 ---- a/drivers/media/v4l2-core/videobuf2-core.c -+++ b/drivers/media/v4l2-core/videobuf2-core.c -@@ -1505,7 +1505,7 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, - void *pb, int nonblocking) - { - unsigned long flags; -- int ret; -+ int ret = 0; - - /* - * Wait for at least one buffer to become available on the done_list. -@@ -1521,10 +1521,12 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, - spin_lock_irqsave(&q->done_lock, flags); - *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); - /* -- * Only remove the buffer from done_list if v4l2_buffer can handle all -- * the planes. -+ * Only remove the buffer from done_list if all planes can be -+ * handled. Some cases such as V4L2 file I/O and DVB have pb -+ * == NULL; skip the check then as there's nothing to verify. - */ -- ret = call_bufop(q, verify_planes_array, *vb, pb); -+ if (pb) -+ ret = call_bufop(q, verify_planes_array, *vb, pb); - if (!ret) - list_del(&(*vb)->done_entry); - spin_unlock_irqrestore(&q->done_lock, flags); -diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c -index 502984c724ff..6c441be8f893 100644 ---- a/drivers/media/v4l2-core/videobuf2-v4l2.c -+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c -@@ -67,6 +67,11 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer - return 0; - } - -+static int __verify_planes_array_core(struct vb2_buffer *vb, const void *pb) -+{ -+ return __verify_planes_array(vb, pb); -+} -+ - /** - * __verify_length() - Verify that the bytesused value for each plane fits in - * the plane length and that the data offset doesn't exceed the bytesused value. -@@ -432,6 +437,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, - } - - static const struct vb2_buf_ops v4l2_buf_ops = { -+ .verify_planes_array = __verify_planes_array_core, - .fill_user_buffer = __fill_v4l2_buffer, - .fill_vb2_buffer = __fill_vb2_buffer, - .set_timestamp = __set_timestamp, -diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c -index 207a3bd68559..a867cc91657e 100644 ---- a/drivers/mfd/qcom_rpm.c -+++ b/drivers/mfd/qcom_rpm.c -@@ -34,7 +34,13 @@ struct qcom_rpm_resource { - struct qcom_rpm_data { - u32 version; - const struct qcom_rpm_resource *resource_table; -- unsigned n_resources; -+ unsigned int n_resources; -+ unsigned int req_ctx_off; -+ unsigned int req_sel_off; -+ unsigned int ack_ctx_off; -+ unsigned int ack_sel_off; -+ unsigned int req_sel_size; -+ unsigned int ack_sel_size; - }; - - struct qcom_rpm { -@@ -61,11 +67,7 @@ struct qcom_rpm { - - #define RPM_REQUEST_TIMEOUT (5 * HZ) - --#define RPM_REQUEST_CONTEXT 3 --#define RPM_REQ_SELECT 11 --#define RPM_ACK_CONTEXT 15 --#define RPM_ACK_SELECTOR 23 --#define RPM_SELECT_SIZE 7 -+#define RPM_MAX_SEL_SIZE 7 - - #define RPM_NOTIFICATION BIT(30) - #define RPM_REJECTED BIT(31) -@@ -157,6 +159,12 @@ static const struct qcom_rpm_data apq8064_template = { - .version = 3, - .resource_table = apq8064_rpm_resource_table, - .n_resources = ARRAY_SIZE(apq8064_rpm_resource_table), -+ .req_ctx_off = 3, -+ .req_sel_off = 11, -+ .ack_ctx_off = 15, -+ .ack_sel_off = 23, -+ .req_sel_size = 4, -+ .ack_sel_size = 7, - }; - - static const struct qcom_rpm_resource msm8660_rpm_resource_table[] = { -@@ -240,6 +248,12 @@ static const struct qcom_rpm_data msm8660_template = { - .version = 2, - .resource_table = msm8660_rpm_resource_table, - .n_resources = ARRAY_SIZE(msm8660_rpm_resource_table), -+ .req_ctx_off = 3, -+ .req_sel_off = 11, -+ .ack_ctx_off = 19, -+ .ack_sel_off = 27, -+ .req_sel_size = 7, -+ .ack_sel_size = 7, - }; - - static const struct qcom_rpm_resource msm8960_rpm_resource_table[] = { -@@ -322,6 +336,12 @@ static const struct qcom_rpm_data msm8960_template = { - .version = 3, - .resource_table = msm8960_rpm_resource_table, - .n_resources = ARRAY_SIZE(msm8960_rpm_resource_table), -+ .req_ctx_off = 3, -+ .req_sel_off = 11, -+ .ack_ctx_off = 15, -+ .ack_sel_off = 23, -+ .req_sel_size = 4, -+ .ack_sel_size = 7, - }; - - static const struct qcom_rpm_resource ipq806x_rpm_resource_table[] = { -@@ -362,6 +382,12 @@ static const struct qcom_rpm_data ipq806x_template = { - .version = 3, - .resource_table = ipq806x_rpm_resource_table, - .n_resources = ARRAY_SIZE(ipq806x_rpm_resource_table), -+ .req_ctx_off = 3, -+ .req_sel_off = 11, -+ .ack_ctx_off = 15, -+ .ack_sel_off = 23, -+ .req_sel_size = 4, -+ .ack_sel_size = 7, - }; - - static const struct of_device_id qcom_rpm_of_match[] = { -@@ -380,7 +406,7 @@ int qcom_rpm_write(struct qcom_rpm *rpm, - { - const struct qcom_rpm_resource *res; - const struct qcom_rpm_data *data = rpm->data; -- u32 sel_mask[RPM_SELECT_SIZE] = { 0 }; -+ u32 sel_mask[RPM_MAX_SEL_SIZE] = { 0 }; - int left; - int ret = 0; - int i; -@@ -398,12 +424,12 @@ int qcom_rpm_write(struct qcom_rpm *rpm, - writel_relaxed(buf[i], RPM_REQ_REG(rpm, res->target_id + i)); - - bitmap_set((unsigned long *)sel_mask, res->select_id, 1); -- for (i = 0; i < ARRAY_SIZE(sel_mask); i++) { -+ for (i = 0; i < rpm->data->req_sel_size; i++) { - writel_relaxed(sel_mask[i], -- RPM_CTRL_REG(rpm, RPM_REQ_SELECT + i)); -+ RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i)); - } - -- writel_relaxed(BIT(state), RPM_CTRL_REG(rpm, RPM_REQUEST_CONTEXT)); -+ writel_relaxed(BIT(state), RPM_CTRL_REG(rpm, rpm->data->req_ctx_off)); - - reinit_completion(&rpm->ack); - regmap_write(rpm->ipc_regmap, rpm->ipc_offset, BIT(rpm->ipc_bit)); -@@ -426,10 +452,11 @@ static irqreturn_t qcom_rpm_ack_interrupt(int irq, void *dev) - u32 ack; - int i; - -- ack = readl_relaxed(RPM_CTRL_REG(rpm, RPM_ACK_CONTEXT)); -- for (i = 0; i < RPM_SELECT_SIZE; i++) -- writel_relaxed(0, RPM_CTRL_REG(rpm, RPM_ACK_SELECTOR + i)); -- writel(0, RPM_CTRL_REG(rpm, RPM_ACK_CONTEXT)); -+ ack = readl_relaxed(RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); -+ for (i = 0; i < rpm->data->ack_sel_size; i++) -+ writel_relaxed(0, -+ RPM_CTRL_REG(rpm, rpm->data->ack_sel_off + i)); -+ writel(0, RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); - - if (ack & RPM_NOTIFICATION) { - dev_warn(rpm->dev, "ignoring notification!\n"); -diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c -index ce7b2cab5762..54ab48827258 100644 ---- a/drivers/mtd/nand/nand_base.c -+++ b/drivers/mtd/nand/nand_base.c -@@ -2586,7 +2586,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, - int cached = writelen > bytes && page != blockmask; - uint8_t *wbuf = buf; - int use_bufpoi; -- int part_pagewr = (column || writelen < (mtd->writesize - 1)); -+ int part_pagewr = (column || writelen < mtd->writesize); - - if (part_pagewr) - use_bufpoi = 1; -diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c -index 22fd19c0c5d3..27de0463226e 100644 ---- a/drivers/mtd/ubi/build.c -+++ b/drivers/mtd/ubi/build.c -@@ -869,7 +869,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - for (i = 0; i < UBI_MAX_DEVICES; i++) { - ubi = ubi_devices[i]; - if (ubi && mtd->index == ubi->mtd->index) { -- ubi_err(ubi, "mtd%d is already attached to ubi%d", -+ pr_err("ubi: mtd%d is already attached to ubi%d", - mtd->index, i); - return -EEXIST; - } -@@ -884,7 +884,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - * no sense to attach emulated MTD devices, so we prohibit this. - */ - if (mtd->type == MTD_UBIVOLUME) { -- ubi_err(ubi, "refuse attaching mtd%d - it is already emulated on top of UBI", -+ pr_err("ubi: refuse attaching mtd%d - it is already emulated on top of UBI", - mtd->index); - return -EINVAL; - } -@@ -895,7 +895,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - if (!ubi_devices[ubi_num]) - break; - if (ubi_num == UBI_MAX_DEVICES) { -- ubi_err(ubi, "only %d UBI devices may be created", -+ pr_err("ubi: only %d UBI devices may be created", - UBI_MAX_DEVICES); - return -ENFILE; - } -@@ -905,7 +905,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - - /* Make sure ubi_num is not busy */ - if (ubi_devices[ubi_num]) { -- ubi_err(ubi, "already exists"); -+ pr_err("ubi: ubi%i already exists", ubi_num); - return -EEXIST; - } - } -@@ -987,6 +987,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - goto out_detach; - } - -+ /* Make device "available" before it becomes accessible via sysfs */ -+ ubi_devices[ubi_num] = ubi; -+ - err = uif_init(ubi, &ref); - if (err) - goto out_detach; -@@ -1031,7 +1034,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, - wake_up_process(ubi->bgt_thread); - spin_unlock(&ubi->wl_lock); - -- ubi_devices[ubi_num] = ubi; - ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); - return ubi_num; - -@@ -1042,6 +1044,7 @@ out_uif: - ubi_assert(ref); - uif_close(ubi); - out_detach: -+ ubi_devices[ubi_num] = NULL; - ubi_wl_close(ubi); - ubi_free_internal_volumes(ubi); - vfree(ubi->vtbl); -diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c -index 1ae17bb9b889..3ea4c022cbb9 100644 ---- a/drivers/mtd/ubi/vmt.c -+++ b/drivers/mtd/ubi/vmt.c -@@ -488,13 +488,6 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) - spin_unlock(&ubi->volumes_lock); - } - -- /* Change volume table record */ -- vtbl_rec = ubi->vtbl[vol_id]; -- vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs); -- err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); -- if (err) -- goto out_acc; -- - if (pebs < 0) { - for (i = 0; i < -pebs; i++) { - err = ubi_eba_unmap_leb(ubi, vol, reserved_pebs + i); -@@ -512,6 +505,24 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) - spin_unlock(&ubi->volumes_lock); - } - -+ /* -+ * When we shrink a volume we have to flush all pending (erase) work. -+ * Otherwise it can happen that upon next attach UBI finds a LEB with -+ * lnum > highest_lnum and refuses to attach. -+ */ -+ if (pebs < 0) { -+ err = ubi_wl_flush(ubi, vol_id, UBI_ALL); -+ if (err) -+ goto out_acc; -+ } -+ -+ /* Change volume table record */ -+ vtbl_rec = ubi->vtbl[vol_id]; -+ vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs); -+ err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); -+ if (err) -+ goto out_acc; -+ - vol->reserved_pebs = reserved_pebs; - if (vol->vol_type == UBI_DYNAMIC_VOLUME) { - vol->used_ebs = reserved_pebs; -diff --git a/drivers/of/base.c b/drivers/of/base.c -index 017dd94f16ea..942461f36616 100644 ---- a/drivers/of/base.c -+++ b/drivers/of/base.c -@@ -112,6 +112,7 @@ static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj, - return memory_read_from_buffer(buf, count, &offset, pp->value, pp->length); - } - -+/* always return newly allocated name, caller must free after use */ - static const char *safe_name(struct kobject *kobj, const char *orig_name) - { - const char *name = orig_name; -@@ -126,9 +127,12 @@ static const char *safe_name(struct kobject *kobj, const char *orig_name) - name = kasprintf(GFP_KERNEL, "%s#%i", orig_name, ++i); - } - -- if (name != orig_name) -+ if (name == orig_name) { -+ name = kstrdup(orig_name, GFP_KERNEL); -+ } else { - pr_warn("device-tree: Duplicate name in %s, renamed to \"%s\"\n", - kobject_name(kobj), name); -+ } - return name; - } - -@@ -159,6 +163,7 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp) - int __of_attach_node_sysfs(struct device_node *np) - { - const char *name; -+ struct kobject *parent; - struct property *pp; - int rc; - -@@ -171,15 +176,16 @@ int __of_attach_node_sysfs(struct device_node *np) - np->kobj.kset = of_kset; - if (!np->parent) { - /* Nodes without parents are new top level trees */ -- rc = kobject_add(&np->kobj, NULL, "%s", -- safe_name(&of_kset->kobj, "base")); -+ name = safe_name(&of_kset->kobj, "base"); -+ parent = NULL; - } else { - name = safe_name(&np->parent->kobj, kbasename(np->full_name)); -- if (!name || !name[0]) -- return -EINVAL; -- -- rc = kobject_add(&np->kobj, &np->parent->kobj, "%s", name); -+ parent = &np->parent->kobj; - } -+ if (!name) -+ return -ENOMEM; -+ rc = kobject_add(&np->kobj, parent, "%s", name); -+ kfree(name); - if (rc) - return rc; - -@@ -1753,6 +1759,12 @@ int __of_remove_property(struct device_node *np, struct property *prop) - return 0; - } - -+void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop) -+{ -+ sysfs_remove_bin_file(&np->kobj, &prop->attr); -+ kfree(prop->attr.attr.name); -+} -+ - void __of_remove_property_sysfs(struct device_node *np, struct property *prop) - { - if (!IS_ENABLED(CONFIG_SYSFS)) -@@ -1760,7 +1772,7 @@ void __of_remove_property_sysfs(struct device_node *np, struct property *prop) - - /* at early boot, bail here and defer setup to of_init() */ - if (of_kset && of_node_is_attached(np)) -- sysfs_remove_bin_file(&np->kobj, &prop->attr); -+ __of_sysfs_remove_bin_file(np, prop); - } - - /** -@@ -1830,7 +1842,7 @@ void __of_update_property_sysfs(struct device_node *np, struct property *newprop - return; - - if (oldprop) -- sysfs_remove_bin_file(&np->kobj, &oldprop->attr); -+ __of_sysfs_remove_bin_file(np, oldprop); - __of_add_property_sysfs(np, newprop); - } - -diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c -index 53826b84e0ec..2d72ddcf534f 100644 ---- a/drivers/of/dynamic.c -+++ b/drivers/of/dynamic.c -@@ -55,7 +55,7 @@ void __of_detach_node_sysfs(struct device_node *np) - /* only remove properties if on sysfs */ - if (of_node_is_attached(np)) { - for_each_property_of_node(np, pp) -- sysfs_remove_bin_file(&np->kobj, &pp->attr); -+ __of_sysfs_remove_bin_file(np, pp); - kobject_del(&np->kobj); - } - -diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h -index 8e882e706cd8..46ddbee22ce3 100644 ---- a/drivers/of/of_private.h -+++ b/drivers/of/of_private.h -@@ -81,6 +81,9 @@ extern int __of_attach_node_sysfs(struct device_node *np); - extern void __of_detach_node(struct device_node *np); - extern void __of_detach_node_sysfs(struct device_node *np); - -+extern void __of_sysfs_remove_bin_file(struct device_node *np, -+ struct property *prop); -+ - /* iterators for transactions, used for overlays */ - /* forward iterator */ - #define for_each_transaction_entry(_oft, _te) \ -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index 7e327309cf69..3c4752a288e2 100644 ---- a/drivers/pci/quirks.c -+++ b/drivers/pci/quirks.c -@@ -3115,13 +3115,15 @@ static void quirk_no_bus_reset(struct pci_dev *dev) - } - - /* -- * Atheros AR93xx chips do not behave after a bus reset. The device will -- * throw a Link Down error on AER-capable systems and regardless of AER, -- * config space of the device is never accessible again and typically -- * causes the system to hang or reset when access is attempted. -+ * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. -+ * The device will throw a Link Down error on AER-capable systems and -+ * regardless of AER, config space of the device is never accessible again -+ * and typically causes the system to hang or reset when access is attempted. - * http://www.spinics.net/lists/linux-pci/msg34797.html - */ - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0030, quirk_no_bus_reset); -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset); -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset); - - static void quirk_no_pm_reset(struct pci_dev *dev) - { -diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c -index 84936bae6e5e..4e377599d266 100644 ---- a/drivers/pinctrl/intel/pinctrl-cherryview.c -+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c -@@ -160,7 +160,6 @@ struct chv_pin_context { - * @pctldev: Pointer to the pin controller device - * @chip: GPIO chip in this pin controller - * @regs: MMIO registers -- * @lock: Lock to serialize register accesses - * @intr_lines: Stores mapping between 16 HW interrupt wires and GPIO - * offset (in GPIO number space) - * @community: Community this pinctrl instance represents -@@ -174,7 +173,6 @@ struct chv_pinctrl { - struct pinctrl_dev *pctldev; - struct gpio_chip chip; - void __iomem *regs; -- raw_spinlock_t lock; - unsigned intr_lines[16]; - const struct chv_community *community; - u32 saved_intmask; -@@ -659,6 +657,17 @@ static const struct chv_community *chv_communities[] = { - &southeast_community, - }; - -+/* -+ * Lock to serialize register accesses -+ * -+ * Due to a silicon issue, a shared lock must be used to prevent -+ * concurrent accesses across the 4 GPIO controllers. -+ * -+ * See Intel Atom Z8000 Processor Series Specification Update (Rev. 005), -+ * errata #CHT34, for further information. -+ */ -+static DEFINE_RAW_SPINLOCK(chv_lock); -+ - static void __iomem *chv_padreg(struct chv_pinctrl *pctrl, unsigned offset, - unsigned reg) - { -@@ -720,13 +729,13 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, - u32 ctrl0, ctrl1; - bool locked; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - ctrl0 = readl(chv_padreg(pctrl, offset, CHV_PADCTRL0)); - ctrl1 = readl(chv_padreg(pctrl, offset, CHV_PADCTRL1)); - locked = chv_pad_locked(pctrl, offset); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - if (ctrl0 & CHV_PADCTRL0_GPIOEN) { - seq_puts(s, "GPIO "); -@@ -789,14 +798,14 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned function, - - grp = &pctrl->community->groups[group]; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - /* Check first that the pad is not locked */ - for (i = 0; i < grp->npins; i++) { - if (chv_pad_locked(pctrl, grp->pins[i])) { - dev_warn(pctrl->dev, "unable to set mode for locked pin %u\n", - grp->pins[i]); -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - return -EBUSY; - } - } -@@ -839,7 +848,7 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned function, - pin, altfunc->mode, altfunc->invert_oe ? "" : "not "); - } - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - return 0; - } -@@ -853,13 +862,13 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev, - void __iomem *reg; - u32 value; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - if (chv_pad_locked(pctrl, offset)) { - value = readl(chv_padreg(pctrl, offset, CHV_PADCTRL0)); - if (!(value & CHV_PADCTRL0_GPIOEN)) { - /* Locked so cannot enable */ -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - return -EBUSY; - } - } else { -@@ -899,7 +908,7 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev, - chv_writel(value, reg); - } - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - return 0; - } -@@ -913,13 +922,13 @@ static void chv_gpio_disable_free(struct pinctrl_dev *pctldev, - void __iomem *reg; - u32 value; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - reg = chv_padreg(pctrl, offset, CHV_PADCTRL0); - value = readl(reg) & ~CHV_PADCTRL0_GPIOEN; - chv_writel(value, reg); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - } - - static int chv_gpio_set_direction(struct pinctrl_dev *pctldev, -@@ -931,7 +940,7 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev, - unsigned long flags; - u32 ctrl0; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - ctrl0 = readl(reg) & ~CHV_PADCTRL0_GPIOCFG_MASK; - if (input) -@@ -940,7 +949,7 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev, - ctrl0 |= CHV_PADCTRL0_GPIOCFG_GPO << CHV_PADCTRL0_GPIOCFG_SHIFT; - chv_writel(ctrl0, reg); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - return 0; - } -@@ -965,10 +974,10 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned pin, - u16 arg = 0; - u32 term; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - ctrl0 = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); - ctrl1 = readl(chv_padreg(pctrl, pin, CHV_PADCTRL1)); -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - term = (ctrl0 & CHV_PADCTRL0_TERM_MASK) >> CHV_PADCTRL0_TERM_SHIFT; - -@@ -1042,7 +1051,7 @@ static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned pin, - unsigned long flags; - u32 ctrl0, pull; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - ctrl0 = readl(reg); - - switch (param) { -@@ -1065,7 +1074,7 @@ static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned pin, - pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; - break; - default: -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - return -EINVAL; - } - -@@ -1083,7 +1092,7 @@ static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned pin, - pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; - break; - default: -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - return -EINVAL; - } - -@@ -1091,12 +1100,12 @@ static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned pin, - break; - - default: -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - return -EINVAL; - } - - chv_writel(ctrl0, reg); -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - return 0; - } -@@ -1162,9 +1171,9 @@ static int chv_gpio_get(struct gpio_chip *chip, unsigned offset) - unsigned long flags; - u32 ctrl0, cfg; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - ctrl0 = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - cfg = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; - cfg >>= CHV_PADCTRL0_GPIOCFG_SHIFT; -@@ -1182,7 +1191,7 @@ static void chv_gpio_set(struct gpio_chip *chip, unsigned offset, int value) - void __iomem *reg; - u32 ctrl0; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - reg = chv_padreg(pctrl, pin, CHV_PADCTRL0); - ctrl0 = readl(reg); -@@ -1194,7 +1203,7 @@ static void chv_gpio_set(struct gpio_chip *chip, unsigned offset, int value) - - chv_writel(ctrl0, reg); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - } - - static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned offset) -@@ -1204,9 +1213,9 @@ static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned offset) - u32 ctrl0, direction; - unsigned long flags; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - ctrl0 = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - direction = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; - direction >>= CHV_PADCTRL0_GPIOCFG_SHIFT; -@@ -1244,14 +1253,14 @@ static void chv_gpio_irq_ack(struct irq_data *d) - int pin = chv_gpio_offset_to_pin(pctrl, irqd_to_hwirq(d)); - u32 intr_line; - -- raw_spin_lock(&pctrl->lock); -+ raw_spin_lock(&chv_lock); - - intr_line = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); - intr_line &= CHV_PADCTRL0_INTSEL_MASK; - intr_line >>= CHV_PADCTRL0_INTSEL_SHIFT; - chv_writel(BIT(intr_line), pctrl->regs + CHV_INTSTAT); - -- raw_spin_unlock(&pctrl->lock); -+ raw_spin_unlock(&chv_lock); - } - - static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) -@@ -1262,7 +1271,7 @@ static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) - u32 value, intr_line; - unsigned long flags; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - intr_line = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); - intr_line &= CHV_PADCTRL0_INTSEL_MASK; -@@ -1275,7 +1284,7 @@ static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) - value |= BIT(intr_line); - chv_writel(value, pctrl->regs + CHV_INTMASK); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - } - - static void chv_gpio_irq_mask(struct irq_data *d) -@@ -1309,7 +1318,7 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d) - unsigned long flags; - u32 intsel, value; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - intsel = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0)); - intsel &= CHV_PADCTRL0_INTSEL_MASK; - intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; -@@ -1324,7 +1333,7 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d) - irq_set_handler_locked(d, handler); - pctrl->intr_lines[intsel] = offset; - } -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - } - - chv_gpio_irq_unmask(d); -@@ -1340,7 +1349,7 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned type) - unsigned long flags; - u32 value; - -- raw_spin_lock_irqsave(&pctrl->lock, flags); -+ raw_spin_lock_irqsave(&chv_lock, flags); - - /* - * Pins which can be used as shared interrupt are configured in -@@ -1389,7 +1398,7 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned type) - else if (type & IRQ_TYPE_LEVEL_MASK) - irq_set_handler_locked(d, handle_level_irq); - -- raw_spin_unlock_irqrestore(&pctrl->lock, flags); -+ raw_spin_unlock_irqrestore(&chv_lock, flags); - - return 0; - } -@@ -1501,7 +1510,6 @@ static int chv_pinctrl_probe(struct platform_device *pdev) - if (i == ARRAY_SIZE(chv_communities)) - return -ENODEV; - -- raw_spin_lock_init(&pctrl->lock); - pctrl->dev = &pdev->dev; - - #ifdef CONFIG_PM_SLEEP -diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c -index fb4dd7b3ee71..af2046c87806 100644 ---- a/drivers/platform/x86/hp-wmi.c -+++ b/drivers/platform/x86/hp-wmi.c -@@ -723,6 +723,11 @@ static int __init hp_wmi_rfkill_setup(struct platform_device *device) - if (err) - return err; - -+ err = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, &wireless, -+ sizeof(wireless), 0); -+ if (err) -+ return err; -+ - if (wireless & 0x1) { - wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev, - RFKILL_TYPE_WLAN, -@@ -910,7 +915,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) - gps_rfkill = NULL; - rfkill2_count = 0; - -- if (hp_wmi_bios_2009_later() || hp_wmi_rfkill_setup(device)) -+ if (hp_wmi_rfkill_setup(device)) - hp_wmi_rfkill2_setup(device); - - err = device_create_file(&device->dev, &dev_attr_display); -diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c -index 9e03d158f411..4f7ce0097191 100644 ---- a/drivers/remoteproc/remoteproc_core.c -+++ b/drivers/remoteproc/remoteproc_core.c -@@ -1239,11 +1239,6 @@ int rproc_add(struct rproc *rproc) - if (ret < 0) - return ret; - -- /* expose to rproc_get_by_phandle users */ -- mutex_lock(&rproc_list_mutex); -- list_add(&rproc->node, &rproc_list); -- mutex_unlock(&rproc_list_mutex); -- - dev_info(dev, "%s is available\n", rproc->name); - - dev_info(dev, "Note: remoteproc is still under development and considered experimental.\n"); -@@ -1251,8 +1246,16 @@ int rproc_add(struct rproc *rproc) - - /* create debugfs entries */ - rproc_create_debug_dir(rproc); -+ ret = rproc_add_virtio_devices(rproc); -+ if (ret < 0) -+ return ret; - -- return rproc_add_virtio_devices(rproc); -+ /* expose to rproc_get_by_phandle users */ -+ mutex_lock(&rproc_list_mutex); -+ list_add(&rproc->node, &rproc_list); -+ mutex_unlock(&rproc_list_mutex); -+ -+ return 0; - } - EXPORT_SYMBOL(rproc_add); - -diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c -index ffb860d18701..f92528822f06 100644 ---- a/drivers/rtc/rtc-s3c.c -+++ b/drivers/rtc/rtc-s3c.c -@@ -149,12 +149,14 @@ static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq) - if (!is_power_of_2(freq)) - return -EINVAL; - -+ s3c_rtc_enable_clk(info); - spin_lock_irq(&info->pie_lock); - - if (info->data->set_freq) - info->data->set_freq(info, freq); - - spin_unlock_irq(&info->pie_lock); -+ s3c_rtc_disable_clk(info); - - return 0; - } -diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c -index b2afad5a5682..2a34eb5f6161 100644 ---- a/drivers/s390/cio/cmf.c -+++ b/drivers/s390/cio/cmf.c -@@ -753,6 +753,17 @@ static void reset_cmb(struct ccw_device *cdev) - cmf_generic_reset(cdev); - } - -+static int cmf_enabled(struct ccw_device *cdev) -+{ -+ int enabled; -+ -+ spin_lock_irq(cdev->ccwlock); -+ enabled = !!cdev->private->cmb; -+ spin_unlock_irq(cdev->ccwlock); -+ -+ return enabled; -+} -+ - static struct attribute_group cmf_attr_group; - - static struct cmb_operations cmbops_basic = { -@@ -1153,13 +1164,8 @@ static ssize_t cmb_enable_show(struct device *dev, - char *buf) - { - struct ccw_device *cdev = to_ccwdev(dev); -- int enabled; - -- spin_lock_irq(cdev->ccwlock); -- enabled = !!cdev->private->cmb; -- spin_unlock_irq(cdev->ccwlock); -- -- return sprintf(buf, "%d\n", enabled); -+ return sprintf(buf, "%d\n", cmf_enabled(cdev)); - } - - static ssize_t cmb_enable_store(struct device *dev, -@@ -1199,15 +1205,20 @@ int ccw_set_cmf(struct ccw_device *cdev, int enable) - * @cdev: The ccw device to be enabled - * - * Returns %0 for success or a negative error value. -- * -+ * Note: If this is called on a device for which channel measurement is already -+ * enabled a reset of the measurement data is triggered. - * Context: - * non-atomic - */ - int enable_cmf(struct ccw_device *cdev) - { -- int ret; -+ int ret = 0; - - device_lock(&cdev->dev); -+ if (cmf_enabled(cdev)) { -+ cmbops->reset(cdev); -+ goto out_unlock; -+ } - get_device(&cdev->dev); - ret = cmbops->alloc(cdev); - if (ret) -@@ -1226,7 +1237,7 @@ int enable_cmf(struct ccw_device *cdev) - out: - if (ret) - put_device(&cdev->dev); -- -+out_unlock: - device_unlock(&cdev->dev); - return ret; - } -diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c -index 4679ed4444a7..9e165bc05ee1 100644 ---- a/drivers/scsi/lpfc/lpfc_scsi.c -+++ b/drivers/scsi/lpfc/lpfc_scsi.c -@@ -3859,7 +3859,7 @@ int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba, - uint32_t tag; - uint16_t hwq; - -- if (shost_use_blk_mq(cmnd->device->host)) { -+ if (cmnd && shost_use_blk_mq(cmnd->device->host)) { - tag = blk_mq_unique_tag(cmnd->request); - hwq = blk_mq_unique_tag_to_hwq(tag); - -diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c -index 73c8ea0b1360..3cac73e4c3e4 100644 ---- a/drivers/spi/spi-pxa2xx.c -+++ b/drivers/spi/spi-pxa2xx.c -@@ -548,7 +548,14 @@ static void reset_sccr1(struct driver_data *drv_data) - u32 sccr1_reg; - - sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1) & ~drv_data->int_cr1; -- sccr1_reg &= ~SSCR1_RFT; -+ switch (drv_data->ssp_type) { -+ case QUARK_X1000_SSP: -+ sccr1_reg &= ~QUARK_X1000_SSCR1_RFT; -+ break; -+ default: -+ sccr1_reg &= ~SSCR1_RFT; -+ break; -+ } - sccr1_reg |= chip->threshold; - pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg); - } -diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c -index 72204fbf2bb1..bd810c109277 100644 ---- a/drivers/target/iscsi/iscsi_target.c -+++ b/drivers/target/iscsi/iscsi_target.c -@@ -492,7 +492,8 @@ static void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) - bool scsi_cmd = (cmd->iscsi_opcode == ISCSI_OP_SCSI_CMD); - - spin_lock_bh(&conn->cmd_lock); -- if (!list_empty(&cmd->i_conn_node)) -+ if (!list_empty(&cmd->i_conn_node) && -+ !(cmd->se_cmd.transport_state & CMD_T_FABRIC_STOP)) - list_del_init(&cmd->i_conn_node); - spin_unlock_bh(&conn->cmd_lock); - -@@ -4194,6 +4195,7 @@ transport_err: - - static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) - { -+ LIST_HEAD(tmp_list); - struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL; - struct iscsi_session *sess = conn->sess; - /* -@@ -4202,18 +4204,26 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) - * has been reset -> returned sleeping pre-handler state. - */ - spin_lock_bh(&conn->cmd_lock); -- list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_conn_node) { -+ list_splice_init(&conn->conn_cmd_list, &tmp_list); - -+ list_for_each_entry(cmd, &tmp_list, i_conn_node) { -+ struct se_cmd *se_cmd = &cmd->se_cmd; -+ -+ if (se_cmd->se_tfo != NULL) { -+ spin_lock(&se_cmd->t_state_lock); -+ se_cmd->transport_state |= CMD_T_FABRIC_STOP; -+ spin_unlock(&se_cmd->t_state_lock); -+ } -+ } -+ spin_unlock_bh(&conn->cmd_lock); -+ -+ list_for_each_entry_safe(cmd, cmd_tmp, &tmp_list, i_conn_node) { - list_del_init(&cmd->i_conn_node); -- spin_unlock_bh(&conn->cmd_lock); - - iscsit_increment_maxcmdsn(cmd, sess); -- - iscsit_free_cmd(cmd, true); - -- spin_lock_bh(&conn->cmd_lock); - } -- spin_unlock_bh(&conn->cmd_lock); - } - - static void iscsit_stop_timers_for_cmds( -diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c -index 96e78c823d13..316f66172335 100644 ---- a/drivers/target/iscsi/iscsi_target_login.c -+++ b/drivers/target/iscsi/iscsi_target_login.c -@@ -1357,8 +1357,9 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) - } - login->zero_tsih = zero_tsih; - -- conn->sess->se_sess->sup_prot_ops = -- conn->conn_transport->iscsit_get_sup_prot_ops(conn); -+ if (conn->sess) -+ conn->sess->se_sess->sup_prot_ops = -+ conn->conn_transport->iscsit_get_sup_prot_ops(conn); - - tpg = conn->tpg; - if (!tpg) { -diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c -index 3436a83568ea..dcd5ed26eb18 100644 ---- a/drivers/target/target_core_device.c -+++ b/drivers/target/target_core_device.c -@@ -832,13 +832,15 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) - * in ATA and we need to set TPE=1 - */ - bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, -- struct request_queue *q, int block_size) -+ struct request_queue *q) - { -+ int block_size = queue_logical_block_size(q); -+ - if (!blk_queue_discard(q)) - return false; - -- attrib->max_unmap_lba_count = (q->limits.max_discard_sectors << 9) / -- block_size; -+ attrib->max_unmap_lba_count = -+ q->limits.max_discard_sectors >> (ilog2(block_size) - 9); - /* - * Currently hardcoded to 1 in Linux/SCSI code.. - */ -diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c -index 75f0f08b2a34..79291869bce6 100644 ---- a/drivers/target/target_core_file.c -+++ b/drivers/target/target_core_file.c -@@ -161,8 +161,7 @@ static int fd_configure_device(struct se_device *dev) - dev_size, div_u64(dev_size, fd_dev->fd_block_size), - fd_dev->fd_block_size); - -- if (target_configure_unmap_from_queue(&dev->dev_attrib, q, -- fd_dev->fd_block_size)) -+ if (target_configure_unmap_from_queue(&dev->dev_attrib, q)) - pr_debug("IFILE: BLOCK Discard support available," - " disabled by default\n"); - /* -diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c -index 2c53dcefff3e..4620c1dcdbc7 100644 ---- a/drivers/target/target_core_iblock.c -+++ b/drivers/target/target_core_iblock.c -@@ -121,8 +121,7 @@ static int iblock_configure_device(struct se_device *dev) - dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q); - dev->dev_attrib.hw_queue_depth = q->nr_requests; - -- if (target_configure_unmap_from_queue(&dev->dev_attrib, q, -- dev->dev_attrib.hw_block_size)) -+ if (target_configure_unmap_from_queue(&dev->dev_attrib, q)) - pr_debug("IBLOCK: BLOCK Discard support available," - " disabled by default\n"); - -diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h -index dae0750c2032..253a91bff943 100644 ---- a/drivers/target/target_core_internal.h -+++ b/drivers/target/target_core_internal.h -@@ -148,6 +148,7 @@ sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size); - void target_qf_do_work(struct work_struct *work); - bool target_check_wce(struct se_device *dev); - bool target_check_fua(struct se_device *dev); -+void __target_execute_cmd(struct se_cmd *, bool); - - /* target_core_stat.c */ - void target_stat_setup_dev_default_groups(struct se_device *); -diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c -index 98698d875742..c220bb8dfa9d 100644 ---- a/drivers/target/target_core_sbc.c -+++ b/drivers/target/target_core_sbc.c -@@ -594,7 +594,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes - cmd->transport_state |= CMD_T_ACTIVE|CMD_T_BUSY|CMD_T_SENT; - spin_unlock_irq(&cmd->t_state_lock); - -- __target_execute_cmd(cmd); -+ __target_execute_cmd(cmd, false); - - kfree(buf); - return ret; -diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c -index d151bc3d6971..7bc3778a1ac9 100644 ---- a/drivers/target/target_core_transport.c -+++ b/drivers/target/target_core_transport.c -@@ -1270,23 +1270,6 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) - - trace_target_sequencer_start(cmd); - -- /* -- * Check for an existing UNIT ATTENTION condition -- */ -- ret = target_scsi3_ua_check(cmd); -- if (ret) -- return ret; -- -- ret = target_alua_state_check(cmd); -- if (ret) -- return ret; -- -- ret = target_check_reservation(cmd); -- if (ret) { -- cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; -- return ret; -- } -- - ret = dev->transport->parse_cdb(cmd); - if (ret == TCM_UNSUPPORTED_SCSI_OPCODE) - pr_warn_ratelimited("%s/%s: Unsupported SCSI Opcode 0x%02x, sending CHECK_CONDITION.\n", -@@ -1749,20 +1732,45 @@ queue_full: - } - EXPORT_SYMBOL(transport_generic_request_failure); - --void __target_execute_cmd(struct se_cmd *cmd) -+void __target_execute_cmd(struct se_cmd *cmd, bool do_checks) - { - sense_reason_t ret; - -- if (cmd->execute_cmd) { -- ret = cmd->execute_cmd(cmd); -- if (ret) { -- spin_lock_irq(&cmd->t_state_lock); -- cmd->transport_state &= ~(CMD_T_BUSY|CMD_T_SENT); -- spin_unlock_irq(&cmd->t_state_lock); -+ if (!cmd->execute_cmd) { -+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; -+ goto err; -+ } -+ if (do_checks) { -+ /* -+ * Check for an existing UNIT ATTENTION condition after -+ * target_handle_task_attr() has done SAM task attr -+ * checking, and possibly have already defered execution -+ * out to target_restart_delayed_cmds() context. -+ */ -+ ret = target_scsi3_ua_check(cmd); -+ if (ret) -+ goto err; -+ -+ ret = target_alua_state_check(cmd); -+ if (ret) -+ goto err; - -- transport_generic_request_failure(cmd, ret); -+ ret = target_check_reservation(cmd); -+ if (ret) { -+ cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; -+ goto err; - } - } -+ -+ ret = cmd->execute_cmd(cmd); -+ if (!ret) -+ return; -+err: -+ spin_lock_irq(&cmd->t_state_lock); -+ cmd->transport_state &= ~(CMD_T_BUSY|CMD_T_SENT); -+ spin_unlock_irq(&cmd->t_state_lock); -+ -+ transport_generic_request_failure(cmd, ret); - } - - static int target_write_prot_action(struct se_cmd *cmd) -@@ -1807,6 +1815,8 @@ static bool target_handle_task_attr(struct se_cmd *cmd) - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) - return false; - -+ cmd->se_cmd_flags |= SCF_TASK_ATTR_SET; -+ - /* - * Check for the existence of HEAD_OF_QUEUE, and if true return 1 - * to allow the passed struct se_cmd list of tasks to the front of the list. -@@ -1887,7 +1897,7 @@ void target_execute_cmd(struct se_cmd *cmd) - return; - } - -- __target_execute_cmd(cmd); -+ __target_execute_cmd(cmd, true); - } - EXPORT_SYMBOL(target_execute_cmd); - -@@ -1911,7 +1921,7 @@ static void target_restart_delayed_cmds(struct se_device *dev) - list_del(&cmd->se_delayed_node); - spin_unlock(&dev->delayed_cmd_lock); - -- __target_execute_cmd(cmd); -+ __target_execute_cmd(cmd, true); - - if (cmd->sam_task_attr == TCM_ORDERED_TAG) - break; -@@ -1929,6 +1939,9 @@ static void transport_complete_task_attr(struct se_cmd *cmd) - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) - return; - -+ if (!(cmd->se_cmd_flags & SCF_TASK_ATTR_SET)) -+ goto restart; -+ - if (cmd->sam_task_attr == TCM_SIMPLE_TAG) { - atomic_dec_mb(&dev->simple_cmds); - dev->dev_cur_ordered_id++; -@@ -1945,7 +1958,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) - pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED\n", - dev->dev_cur_ordered_id); - } -- -+restart: - target_restart_delayed_cmds(dev); - } - -@@ -2533,15 +2546,10 @@ static void target_release_cmd_kref(struct kref *kref) - bool fabric_stop; - - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); -- if (list_empty(&se_cmd->se_cmd_list)) { -- spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); -- target_free_cmd_mem(se_cmd); -- se_cmd->se_tfo->release_cmd(se_cmd); -- return; -- } - - spin_lock(&se_cmd->t_state_lock); -- fabric_stop = (se_cmd->transport_state & CMD_T_FABRIC_STOP); -+ fabric_stop = (se_cmd->transport_state & CMD_T_FABRIC_STOP) && -+ (se_cmd->transport_state & CMD_T_ABORTED); - spin_unlock(&se_cmd->t_state_lock); - - if (se_cmd->cmd_wait_set || fabric_stop) { -diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c -index 7bbadd176c74..7b5462eb8388 100644 ---- a/drivers/tty/serial/atmel_serial.c -+++ b/drivers/tty/serial/atmel_serial.c -@@ -485,19 +485,21 @@ static void atmel_start_tx(struct uart_port *port) - { - struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); - -- if (atmel_use_pdc_tx(port)) { -- if (atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN) -- /* The transmitter is already running. Yes, we -- really need this.*/ -- return; -+ if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR) -+ & ATMEL_PDC_TXTEN)) -+ /* The transmitter is already running. Yes, we -+ really need this.*/ -+ return; - -+ if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) - if ((port->rs485.flags & SER_RS485_ENABLED) && - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) - atmel_stop_rx(port); - -+ if (atmel_use_pdc_tx(port)) - /* re-enable PDC transmit */ - atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); -- } -+ - /* Enable interrupts */ - atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); - } -diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c -index dcde955475dc..e1de4944e0ce 100644 ---- a/drivers/tty/serial/msm_serial.c -+++ b/drivers/tty/serial/msm_serial.c -@@ -726,7 +726,7 @@ static void msm_handle_tx(struct uart_port *port) - return; - } - -- pio_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); -+ pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); - dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); - - dma_min = 1; /* Always DMA */ -diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c -index 8320173af846..237ef5573c18 100644 ---- a/drivers/tty/serial/samsung.c -+++ b/drivers/tty/serial/samsung.c -@@ -1676,7 +1676,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, - return -ENODEV; - - if (port->mapbase != 0) -- return 0; -+ return -EINVAL; - - /* setup info for port */ - port->dev = &platdev->dev; -@@ -1730,22 +1730,25 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, - ourport->dma = devm_kzalloc(port->dev, - sizeof(*ourport->dma), - GFP_KERNEL); -- if (!ourport->dma) -- return -ENOMEM; -+ if (!ourport->dma) { -+ ret = -ENOMEM; -+ goto err; -+ } - } - - ourport->clk = clk_get(&platdev->dev, "uart"); - if (IS_ERR(ourport->clk)) { - pr_err("%s: Controller clock not found\n", - dev_name(&platdev->dev)); -- return PTR_ERR(ourport->clk); -+ ret = PTR_ERR(ourport->clk); -+ goto err; - } - - ret = clk_prepare_enable(ourport->clk); - if (ret) { - pr_err("uart: clock failed to prepare+enable: %d\n", ret); - clk_put(ourport->clk); -- return ret; -+ goto err; - } - - /* Keep all interrupts masked and cleared */ -@@ -1761,7 +1764,12 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, - - /* reset the fifos (and setup the uart) */ - s3c24xx_serial_resetport(port, cfg); -+ - return 0; -+ -+err: -+ port->mapbase = 0; -+ return ret; - } - - /* Device driver serial port probe */ -diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c -index 38ae877c46e3..3ffb01ff6549 100644 ---- a/drivers/usb/core/devio.c -+++ b/drivers/usb/core/devio.c -@@ -1203,10 +1203,11 @@ static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) - - static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) - { -- struct usbdevfs_connectinfo ci = { -- .devnum = ps->dev->devnum, -- .slow = ps->dev->speed == USB_SPEED_LOW -- }; -+ struct usbdevfs_connectinfo ci; -+ -+ memset(&ci, 0, sizeof(ci)); -+ ci.devnum = ps->dev->devnum; -+ ci.slow = ps->dev->speed == USB_SPEED_LOW; - - if (copy_to_user(arg, &ci, sizeof(ci))) - return -EFAULT; -diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c -index 944a6dca0fcb..d2e50a27140c 100644 ---- a/drivers/usb/core/quirks.c -+++ b/drivers/usb/core/quirks.c -@@ -128,6 +128,9 @@ static const struct usb_device_id usb_quirk_list[] = { - { USB_DEVICE(0x04f3, 0x016f), .driver_info = - USB_QUIRK_DEVICE_QUALIFIER }, - -+ { USB_DEVICE(0x04f3, 0x0381), .driver_info = -+ USB_QUIRK_NO_LPM }, -+ - { USB_DEVICE(0x04f3, 0x21b8), .driver_info = - USB_QUIRK_DEVICE_QUALIFIER }, - -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c -index 69ffe6e8d77f..70900e6ca9bc 100644 ---- a/drivers/usb/dwc3/gadget.c -+++ b/drivers/usb/dwc3/gadget.c -@@ -1965,6 +1965,10 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, - return 1; - } - -+ if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) -+ if ((event->status & DEPEVT_STATUS_IOC) && -+ (trb->ctrl & DWC3_TRB_CTRL_IOC)) -+ return 0; - return 1; - } - -diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c -index 97ef75af9632..803c503a2e3d 100644 ---- a/drivers/usb/gadget/function/f_fs.c -+++ b/drivers/usb/gadget/function/f_fs.c -@@ -2740,6 +2740,7 @@ static int _ffs_func_bind(struct usb_configuration *c, - func->ffs->ss_descs_count; - - int fs_len, hs_len, ss_len, ret, i; -+ struct ffs_ep *eps_ptr; - - /* Make it a single chunk, less management later on */ - vla_group(d); -@@ -2788,12 +2789,9 @@ static int _ffs_func_bind(struct usb_configuration *c, - ffs->raw_descs_length); - - memset(vla_ptr(vlabuf, d, inums), 0xff, d_inums__sz); -- for (ret = ffs->eps_count; ret; --ret) { -- struct ffs_ep *ptr; -- -- ptr = vla_ptr(vlabuf, d, eps); -- ptr[ret].num = -1; -- } -+ eps_ptr = vla_ptr(vlabuf, d, eps); -+ for (i = 0; i < ffs->eps_count; i++) -+ eps_ptr[i].num = -1; - - /* Save pointers - * d_eps == vlabuf, func->eps used to kfree vlabuf later -diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c -index 044ca79d3cb5..12628dd36e55 100644 ---- a/drivers/usb/gadget/function/f_uac2.c -+++ b/drivers/usb/gadget/function/f_uac2.c -@@ -1291,6 +1291,7 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr) - - if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { - struct cntrl_cur_lay3 c; -+ memset(&c, 0, sizeof(struct cntrl_cur_lay3)); - - if (entity_id == USB_IN_CLK_ID) - c.dCUR = p_srate; -diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c -index f1893e08e51a..db565f620f82 100644 ---- a/drivers/usb/renesas_usbhs/fifo.c -+++ b/drivers/usb/renesas_usbhs/fifo.c -@@ -808,20 +808,27 @@ static void xfer_work(struct work_struct *work) - { - struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work); - struct usbhs_pipe *pipe = pkt->pipe; -- struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe); -+ struct usbhs_fifo *fifo; - struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); - struct dma_async_tx_descriptor *desc; -- struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt); -+ struct dma_chan *chan; - struct device *dev = usbhs_priv_to_dev(priv); - enum dma_transfer_direction dir; -+ unsigned long flags; - -+ usbhs_lock(priv, flags); -+ fifo = usbhs_pipe_to_fifo(pipe); -+ if (!fifo) -+ goto xfer_work_end; -+ -+ chan = usbhsf_dma_chan_get(fifo, pkt); - dir = usbhs_pipe_is_dir_in(pipe) ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; - - desc = dmaengine_prep_slave_single(chan, pkt->dma + pkt->actual, - pkt->trans, dir, - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - if (!desc) -- return; -+ goto xfer_work_end; - - desc->callback = usbhsf_dma_complete; - desc->callback_param = pipe; -@@ -829,7 +836,7 @@ static void xfer_work(struct work_struct *work) - pkt->cookie = dmaengine_submit(desc); - if (pkt->cookie < 0) { - dev_err(dev, "Failed to submit dma descriptor\n"); -- return; -+ goto xfer_work_end; - } - - dev_dbg(dev, " %s %d (%d/ %d)\n", -@@ -840,6 +847,9 @@ static void xfer_work(struct work_struct *work) - usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans); - dma_async_issue_pending(chan); - usbhs_pipe_enable(pipe); -+ -+xfer_work_end: -+ usbhs_unlock(priv, flags); - } - - /* -diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c -index fa14198daf77..5a3abf56d56b 100644 ---- a/drivers/usb/renesas_usbhs/mod_gadget.c -+++ b/drivers/usb/renesas_usbhs/mod_gadget.c -@@ -586,6 +586,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep, - struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); - struct usbhs_pipe *pipe; - int ret = -EIO; -+ unsigned long flags; -+ -+ usbhs_lock(priv, flags); - - /* - * if it already have pipe, -@@ -594,7 +597,8 @@ static int usbhsg_ep_enable(struct usb_ep *ep, - if (uep->pipe) { - usbhs_pipe_clear(uep->pipe); - usbhs_pipe_sequence_data0(uep->pipe); -- return 0; -+ ret = 0; -+ goto usbhsg_ep_enable_end; - } - - pipe = usbhs_pipe_malloc(priv, -@@ -622,6 +626,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep, - ret = 0; - } - -+usbhsg_ep_enable_end: -+ usbhs_unlock(priv, flags); -+ - return ret; - } - -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c -index d96d423d00e6..8e07536c233a 100644 ---- a/drivers/usb/serial/option.c -+++ b/drivers/usb/serial/option.c -@@ -273,6 +273,7 @@ static void option_instat_callback(struct urb *urb); - #define TELIT_PRODUCT_LE922_USBCFG5 0x1045 - #define TELIT_PRODUCT_LE920 0x1200 - #define TELIT_PRODUCT_LE910 0x1201 -+#define TELIT_PRODUCT_LE910_USBCFG4 0x1206 - - /* ZTE PRODUCTS */ - #define ZTE_VENDOR_ID 0x19d2 -@@ -1198,6 +1199,8 @@ static const struct usb_device_id option_ids[] = { - .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), - .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4), -+ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), - .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ -diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c -index 8ab6238c9299..56f7e2521202 100644 ---- a/drivers/virtio/virtio_balloon.c -+++ b/drivers/virtio/virtio_balloon.c -@@ -196,6 +196,8 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) - num = min(num, ARRAY_SIZE(vb->pfns)); - - mutex_lock(&vb->balloon_lock); -+ /* We can't release more pages than taken */ -+ num = min(num, (size_t)vb->num_pages); - for (vb->num_pfns = 0; vb->num_pfns < num; - vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) { - page = balloon_page_dequeue(vb_dev_info); -diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c -index 0e2f43bccf1f..0c427d6a12d1 100644 ---- a/drivers/w1/masters/omap_hdq.c -+++ b/drivers/w1/masters/omap_hdq.c -@@ -390,8 +390,6 @@ static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val) - goto out; - } - -- hdq_data->hdq_irqstatus = 0; -- - if (!(hdq_data->hdq_irqstatus & OMAP_HDQ_INT_STATUS_RXCOMPLETE)) { - hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, - OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO, -diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c -index 9abe18763a7f..257bbdcb5df6 100644 ---- a/fs/btrfs/extent_io.c -+++ b/fs/btrfs/extent_io.c -@@ -2786,12 +2786,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask) - btrfs_bio->csum = NULL; - btrfs_bio->csum_allocated = NULL; - btrfs_bio->end_io = NULL; -- --#ifdef CONFIG_BLK_CGROUP -- /* FIXME, put this into bio_clone_bioset */ -- if (bio->bi_css) -- bio_associate_blkcg(new, bio->bi_css); --#endif - } - return new; - } -diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h -index 3182273a3407..1418daa03d95 100644 ---- a/fs/cifs/cifs_fs_sb.h -+++ b/fs/cifs/cifs_fs_sb.h -@@ -46,6 +46,9 @@ - #define CIFS_MOUNT_CIFS_BACKUPUID 0x200000 /* backup intent bit for a user */ - #define CIFS_MOUNT_CIFS_BACKUPGID 0x400000 /* backup intent bit for a group */ - #define CIFS_MOUNT_MAP_SFM_CHR 0x800000 /* SFM/MAC mapping for illegal chars */ -+#define CIFS_MOUNT_USE_PREFIX_PATH 0x1000000 /* make subpath with unaccessible -+ * root mountable -+ */ - - struct cifs_sb_info { - struct rb_root tlink_tree; -@@ -67,5 +70,6 @@ struct cifs_sb_info { - struct backing_dev_info bdi; - struct delayed_work prune_tlinks; - struct rcu_head rcu; -+ char *prepath; - }; - #endif /* _CIFS_FS_SB_H */ -diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c -index e682b36a210f..4acbc390a7d6 100644 ---- a/fs/cifs/cifsencrypt.c -+++ b/fs/cifs/cifsencrypt.c -@@ -731,24 +731,26 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) - - memcpy(ses->auth_key.response + baselen, tiblob, tilen); - -+ mutex_lock(&ses->server->srv_mutex); -+ - rc = crypto_hmacmd5_alloc(ses->server); - if (rc) { - cifs_dbg(VFS, "could not crypto alloc hmacmd5 rc %d\n", rc); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - /* calculate ntlmv2_hash */ - rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp); - if (rc) { - cifs_dbg(VFS, "could not get v2 hash rc %d\n", rc); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - /* calculate first part of the client response (CR1) */ - rc = CalcNTLMv2_response(ses, ntlmv2_hash); - if (rc) { - cifs_dbg(VFS, "Could not calculate CR1 rc: %d\n", rc); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - /* now calculate the session key for NTLMv2 */ -@@ -757,13 +759,13 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) - if (rc) { - cifs_dbg(VFS, "%s: Could not set NTLMV2 Hash as a key\n", - __func__); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); - if (rc) { - cifs_dbg(VFS, "%s: Could not init hmacmd5\n", __func__); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, -@@ -771,7 +773,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) - CIFS_HMAC_MD5_HASH_SIZE); - if (rc) { - cifs_dbg(VFS, "%s: Could not update with response\n", __func__); -- goto setup_ntlmv2_rsp_ret; -+ goto unlock; - } - - rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, -@@ -779,6 +781,8 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) - if (rc) - cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __func__); - -+unlock: -+ mutex_unlock(&ses->server->srv_mutex); - setup_ntlmv2_rsp_ret: - kfree(tiblob); - -diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c -index cbc0f4bca0c0..450578097fb7 100644 ---- a/fs/cifs/cifsfs.c -+++ b/fs/cifs/cifsfs.c -@@ -686,6 +686,14 @@ cifs_do_mount(struct file_system_type *fs_type, - goto out_cifs_sb; - } - -+ if (volume_info->prepath) { -+ cifs_sb->prepath = kstrdup(volume_info->prepath, GFP_KERNEL); -+ if (cifs_sb->prepath == NULL) { -+ root = ERR_PTR(-ENOMEM); -+ goto out_cifs_sb; -+ } -+ } -+ - cifs_setup_cifs_sb(volume_info, cifs_sb); - - rc = cifs_mount(cifs_sb, volume_info); -@@ -724,7 +732,11 @@ cifs_do_mount(struct file_system_type *fs_type, - sb->s_flags |= MS_ACTIVE; - } - -- root = cifs_get_root(volume_info, sb); -+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) -+ root = dget(sb->s_root); -+ else -+ root = cifs_get_root(volume_info, sb); -+ - if (IS_ERR(root)) - goto out_super; - -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c -index 5481a6eb9a95..61c3a5ab8637 100644 ---- a/fs/cifs/connect.c -+++ b/fs/cifs/connect.c -@@ -3517,6 +3517,44 @@ cifs_get_volume_info(char *mount_data, const char *devname) - return volume_info; - } - -+static int -+cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, -+ unsigned int xid, -+ struct cifs_tcon *tcon, -+ struct cifs_sb_info *cifs_sb, -+ char *full_path) -+{ -+ int rc; -+ char *s; -+ char sep, tmp; -+ -+ sep = CIFS_DIR_SEP(cifs_sb); -+ s = full_path; -+ -+ rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); -+ while (rc == 0) { -+ /* skip separators */ -+ while (*s == sep) -+ s++; -+ if (!*s) -+ break; -+ /* next separator */ -+ while (*s && *s != sep) -+ s++; -+ -+ /* -+ * temporarily null-terminate the path at the end of -+ * the current component -+ */ -+ tmp = *s; -+ *s = 0; -+ rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, -+ full_path); -+ *s = tmp; -+ } -+ return rc; -+} -+ - int - cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) - { -@@ -3654,6 +3692,16 @@ remote_path_check: - kfree(full_path); - goto mount_fail_check; - } -+ -+ rc = cifs_are_all_path_components_accessible(server, -+ xid, tcon, cifs_sb, -+ full_path); -+ if (rc != 0) { -+ cifs_dbg(VFS, "cannot query dirs between root and final path, " -+ "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); -+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; -+ rc = 0; -+ } - kfree(full_path); - } - -@@ -3923,6 +3971,7 @@ cifs_umount(struct cifs_sb_info *cifs_sb) - - bdi_destroy(&cifs_sb->bdi); - kfree(cifs_sb->mountdata); -+ kfree(cifs_sb->prepath); - call_rcu(&cifs_sb->rcu, delayed_free); - } - -diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c -index c3eb998a99bd..26a3b389a265 100644 ---- a/fs/cifs/dir.c -+++ b/fs/cifs/dir.c -@@ -84,6 +84,7 @@ build_path_from_dentry(struct dentry *direntry) - struct dentry *temp; - int namelen; - int dfsplen; -+ int pplen = 0; - char *full_path; - char dirsep; - struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); -@@ -95,8 +96,12 @@ build_path_from_dentry(struct dentry *direntry) - dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); - else - dfsplen = 0; -+ -+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) -+ pplen = cifs_sb->prepath ? strlen(cifs_sb->prepath) + 1 : 0; -+ - cifs_bp_rename_retry: -- namelen = dfsplen; -+ namelen = dfsplen + pplen; - seq = read_seqbegin(&rename_lock); - rcu_read_lock(); - for (temp = direntry; !IS_ROOT(temp);) { -@@ -137,7 +142,7 @@ cifs_bp_rename_retry: - } - } - rcu_read_unlock(); -- if (namelen != dfsplen || read_seqretry(&rename_lock, seq)) { -+ if (namelen != dfsplen + pplen || read_seqretry(&rename_lock, seq)) { - cifs_dbg(FYI, "did not end path lookup where expected. namelen=%ddfsplen=%d\n", - namelen, dfsplen); - /* presumably this is only possible if racing with a rename -@@ -153,6 +158,17 @@ cifs_bp_rename_retry: - those safely to '/' if any are found in the middle of the prepath */ - /* BB test paths to Windows with '/' in the midst of prepath */ - -+ if (pplen) { -+ int i; -+ -+ cifs_dbg(FYI, "using cifs_sb prepath <%s>\n", cifs_sb->prepath); -+ memcpy(full_path+dfsplen+1, cifs_sb->prepath, pplen-1); -+ full_path[dfsplen] = '\\'; -+ for (i = 0; i < pplen-1; i++) -+ if (full_path[dfsplen+1+i] == '/') -+ full_path[dfsplen+1+i] = CIFS_DIR_SEP(cifs_sb); -+ } -+ - if (dfsplen) { - strncpy(full_path, tcon->treeName, dfsplen); - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { -@@ -229,6 +245,13 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, - goto cifs_create_get_file_info; - } - -+ if (S_ISDIR(newinode->i_mode)) { -+ CIFSSMBClose(xid, tcon, fid->netfid); -+ iput(newinode); -+ rc = -EISDIR; -+ goto out; -+ } -+ - if (!S_ISREG(newinode->i_mode)) { - /* - * The server may allow us to open things like -@@ -399,10 +422,14 @@ cifs_create_set_dentry: - if (rc != 0) { - cifs_dbg(FYI, "Create worked, get_inode_info failed rc = %d\n", - rc); -- if (server->ops->close) -- server->ops->close(xid, tcon, fid); -- goto out; -+ goto out_err; - } -+ -+ if (S_ISDIR(newinode->i_mode)) { -+ rc = -EISDIR; -+ goto out_err; -+ } -+ - d_drop(direntry); - d_add(direntry, newinode); - -@@ -410,6 +437,13 @@ out: - kfree(buf); - kfree(full_path); - return rc; -+ -+out_err: -+ if (server->ops->close) -+ server->ops->close(xid, tcon, fid); -+ if (newinode) -+ iput(newinode); -+ goto out; - } - - int -diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c -index a329f5ba35aa..9cdeb0293267 100644 ---- a/fs/cifs/inode.c -+++ b/fs/cifs/inode.c -@@ -982,10 +982,26 @@ struct inode *cifs_root_iget(struct super_block *sb) - struct inode *inode = NULL; - long rc; - struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); -+ char *path = NULL; -+ int len; -+ -+ if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) -+ && cifs_sb->prepath) { -+ len = strlen(cifs_sb->prepath); -+ path = kzalloc(len + 2 /* leading sep + null */, GFP_KERNEL); -+ if (path == NULL) -+ return ERR_PTR(-ENOMEM); -+ path[0] = '/'; -+ memcpy(path+1, cifs_sb->prepath, len); -+ } else { -+ path = kstrdup("", GFP_KERNEL); -+ if (path == NULL) -+ return ERR_PTR(-ENOMEM); -+ } - - xid = get_xid(); - if (tcon->unix_ext) { -- rc = cifs_get_inode_info_unix(&inode, "", sb, xid); -+ rc = cifs_get_inode_info_unix(&inode, path, sb, xid); - /* some servers mistakenly claim POSIX support */ - if (rc != -EOPNOTSUPP) - goto iget_no_retry; -@@ -993,7 +1009,8 @@ struct inode *cifs_root_iget(struct super_block *sb) - tcon->unix_ext = false; - } - -- rc = cifs_get_inode_info(&inode, "", NULL, sb, xid, NULL); -+ convert_delimiter(path, CIFS_DIR_SEP(cifs_sb)); -+ rc = cifs_get_inode_info(&inode, path, NULL, sb, xid, NULL); - - iget_no_retry: - if (!inode) { -@@ -1022,6 +1039,7 @@ iget_no_retry: - } - - out: -+ kfree(path); - /* can not call macro free_xid here since in a void func - * TODO: This is no longer true - */ -diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c -index 53ccdde6ff18..dd8543caa56e 100644 ---- a/fs/cifs/smb2ops.c -+++ b/fs/cifs/smb2ops.c -@@ -1039,6 +1039,9 @@ smb2_new_lease_key(struct cifs_fid *fid) - get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE); - } - -+#define SMB2_SYMLINK_STRUCT_SIZE \ -+ (sizeof(struct smb2_err_rsp) - 1 + sizeof(struct smb2_symlink_err_rsp)) -+ - static int - smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, - const char *full_path, char **target_path, -@@ -1051,7 +1054,10 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, - struct cifs_fid fid; - struct smb2_err_rsp *err_buf = NULL; - struct smb2_symlink_err_rsp *symlink; -- unsigned int sub_len, sub_offset; -+ unsigned int sub_len; -+ unsigned int sub_offset; -+ unsigned int print_len; -+ unsigned int print_offset; - - cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path); - -@@ -1072,11 +1078,33 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, - kfree(utf16_path); - return -ENOENT; - } -+ -+ if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) || -+ get_rfc1002_length(err_buf) + 4 < SMB2_SYMLINK_STRUCT_SIZE) { -+ kfree(utf16_path); -+ return -ENOENT; -+ } -+ - /* open must fail on symlink - reset rc */ - rc = 0; - symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData; - sub_len = le16_to_cpu(symlink->SubstituteNameLength); - sub_offset = le16_to_cpu(symlink->SubstituteNameOffset); -+ print_len = le16_to_cpu(symlink->PrintNameLength); -+ print_offset = le16_to_cpu(symlink->PrintNameOffset); -+ -+ if (get_rfc1002_length(err_buf) + 4 < -+ SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) { -+ kfree(utf16_path); -+ return -ENOENT; -+ } -+ -+ if (get_rfc1002_length(err_buf) + 4 < -+ SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) { -+ kfree(utf16_path); -+ return -ENOENT; -+ } -+ - *target_path = cifs_strndup_from_utf16( - (char *)symlink->PathBuffer + sub_offset, - sub_len, true, cifs_sb->local_nls); -diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c -index 36345fefa3ff..2d964ce45606 100644 ---- a/fs/jbd2/commit.c -+++ b/fs/jbd2/commit.c -@@ -124,7 +124,7 @@ static int journal_submit_commit_record(journal_t *journal, - struct commit_header *tmp; - struct buffer_head *bh; - int ret; -- struct timespec now = current_kernel_time(); -+ struct timespec64 now = current_kernel_time64(); - - *cbh = NULL; - -diff --git a/fs/nfs/write.c b/fs/nfs/write.c -index 7b9316406930..7a9b6e347249 100644 ---- a/fs/nfs/write.c -+++ b/fs/nfs/write.c -@@ -1261,6 +1261,9 @@ int nfs_updatepage(struct file *file, struct page *page, - dprintk("NFS: nfs_updatepage(%pD2 %d@%lld)\n", - file, count, (long long)(page_file_offset(page) + offset)); - -+ if (!count) -+ goto out; -+ - if (nfs_can_extend_write(file, page, inode)) { - count = max(count + offset, nfs_page_length(page)); - offset = 0; -@@ -1271,7 +1274,7 @@ int nfs_updatepage(struct file *file, struct page *page, - nfs_set_pageerror(page); - else - __set_page_dirty_nobuffers(page); -- -+out: - dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n", - status, (long long)i_size_read(inode)); - return status; -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c -index ed2f64ca49de..f7ea624780a7 100644 ---- a/fs/nfsd/nfs4state.c -+++ b/fs/nfsd/nfs4state.c -@@ -4882,6 +4882,32 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - return nfs_ok; - } - -+static __be32 -+nfsd4_free_lock_stateid(stateid_t *stateid, struct nfs4_stid *s) -+{ -+ struct nfs4_ol_stateid *stp = openlockstateid(s); -+ __be32 ret; -+ -+ mutex_lock(&stp->st_mutex); -+ -+ ret = check_stateid_generation(stateid, &s->sc_stateid, 1); -+ if (ret) -+ goto out; -+ -+ ret = nfserr_locks_held; -+ if (check_for_locks(stp->st_stid.sc_file, -+ lockowner(stp->st_stateowner))) -+ goto out; -+ -+ release_lock_stateid(stp); -+ ret = nfs_ok; -+ -+out: -+ mutex_unlock(&stp->st_mutex); -+ nfs4_put_stid(s); -+ return ret; -+} -+ - __be32 - nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - struct nfsd4_free_stateid *free_stateid) -@@ -4889,7 +4915,6 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - stateid_t *stateid = &free_stateid->fr_stateid; - struct nfs4_stid *s; - struct nfs4_delegation *dp; -- struct nfs4_ol_stateid *stp; - struct nfs4_client *cl = cstate->session->se_client; - __be32 ret = nfserr_bad_stateid; - -@@ -4908,18 +4933,9 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - ret = nfserr_locks_held; - break; - case NFS4_LOCK_STID: -- ret = check_stateid_generation(stateid, &s->sc_stateid, 1); -- if (ret) -- break; -- stp = openlockstateid(s); -- ret = nfserr_locks_held; -- if (check_for_locks(stp->st_stid.sc_file, -- lockowner(stp->st_stateowner))) -- break; -- WARN_ON(!unhash_lock_stateid(stp)); -+ atomic_inc(&s->sc_count); - spin_unlock(&cl->cl_lock); -- nfs4_put_stid(s); -- ret = nfs_ok; -+ ret = nfsd4_free_lock_stateid(stateid, s); - goto out; - case NFS4_REVOKED_DELEG_STID: - dp = delegstateid(s); -@@ -5486,7 +5502,7 @@ static __be32 - lookup_or_create_lock_state(struct nfsd4_compound_state *cstate, - struct nfs4_ol_stateid *ost, - struct nfsd4_lock *lock, -- struct nfs4_ol_stateid **lst, bool *new) -+ struct nfs4_ol_stateid **plst, bool *new) - { - __be32 status; - struct nfs4_file *fi = ost->st_stid.sc_file; -@@ -5494,7 +5510,9 @@ lookup_or_create_lock_state(struct nfsd4_compound_state *cstate, - struct nfs4_client *cl = oo->oo_owner.so_client; - struct inode *inode = d_inode(cstate->current_fh.fh_dentry); - struct nfs4_lockowner *lo; -+ struct nfs4_ol_stateid *lst; - unsigned int strhashval; -+ bool hashed; - - lo = find_lockowner_str(cl, &lock->lk_new_owner); - if (!lo) { -@@ -5510,12 +5528,27 @@ lookup_or_create_lock_state(struct nfsd4_compound_state *cstate, - goto out; - } - -- *lst = find_or_create_lock_stateid(lo, fi, inode, ost, new); -- if (*lst == NULL) { -+retry: -+ lst = find_or_create_lock_stateid(lo, fi, inode, ost, new); -+ if (lst == NULL) { - status = nfserr_jukebox; - goto out; - } -+ -+ mutex_lock(&lst->st_mutex); -+ -+ /* See if it's still hashed to avoid race with FREE_STATEID */ -+ spin_lock(&cl->cl_lock); -+ hashed = !list_empty(&lst->st_perfile); -+ spin_unlock(&cl->cl_lock); -+ -+ if (!hashed) { -+ mutex_unlock(&lst->st_mutex); -+ nfs4_put_stid(&lst->st_stid); -+ goto retry; -+ } - status = nfs_ok; -+ *plst = lst; - out: - nfs4_put_stateowner(&lo->lo_owner); - return status; -@@ -5582,8 +5615,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - goto out; - status = lookup_or_create_lock_state(cstate, open_stp, lock, - &lock_stp, &new); -- if (status == nfs_ok) -- mutex_lock(&lock_stp->st_mutex); - } else { - status = nfs4_preprocess_seqid_op(cstate, - lock->lk_old_lock_seqid, -diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c -index a1acc6004a91..70a7bbe199d0 100644 ---- a/fs/overlayfs/super.c -+++ b/fs/overlayfs/super.c -@@ -376,7 +376,8 @@ static struct ovl_entry *ovl_alloc_entry(unsigned int numlower) - static bool ovl_dentry_remote(struct dentry *dentry) - { - return dentry->d_flags & -- (DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE); -+ (DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE | -+ DCACHE_OP_REAL); - } - - static bool ovl_dentry_weird(struct dentry *dentry) -diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h -index 1b4d69f68c33..140c29635069 100644 ---- a/include/linux/backing-dev-defs.h -+++ b/include/linux/backing-dev-defs.h -@@ -163,6 +163,7 @@ struct backing_dev_info { - wait_queue_head_t wb_waitq; - - struct device *dev; -+ struct device *owner; - - struct timer_list laptop_mode_wb_timer; - -diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h -index c82794f20110..89d3de3e096b 100644 ---- a/include/linux/backing-dev.h -+++ b/include/linux/backing-dev.h -@@ -24,6 +24,7 @@ __printf(3, 4) - int bdi_register(struct backing_dev_info *bdi, struct device *parent, - const char *fmt, ...); - int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); -+int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner); - void bdi_unregister(struct backing_dev_info *bdi); - - int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); -diff --git a/include/linux/bio.h b/include/linux/bio.h -index fbe47bc700bd..42e4e3cbb001 100644 ---- a/include/linux/bio.h -+++ b/include/linux/bio.h -@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx); - int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css); - int bio_associate_current(struct bio *bio); - void bio_disassociate_task(struct bio *bio); -+void bio_clone_blkcg_association(struct bio *dst, struct bio *src); - #else /* CONFIG_BLK_CGROUP */ - static inline int bio_associate_blkcg(struct bio *bio, - struct cgroup_subsys_state *blkcg_css) { return 0; } - static inline int bio_associate_current(struct bio *bio) { return -ENOENT; } - static inline void bio_disassociate_task(struct bio *bio) { } -+static inline void bio_clone_blkcg_association(struct bio *dst, -+ struct bio *src) { } - #endif /* CONFIG_BLK_CGROUP */ - - #ifdef CONFIG_HIGHMEM -diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h -index f079fb1a31f7..a8786d27ab81 100644 ---- a/include/linux/mlx5/qp.h -+++ b/include/linux/mlx5/qp.h -@@ -160,6 +160,7 @@ enum { - enum { - MLX5_FENCE_MODE_NONE = 0 << 5, - MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5, -+ MLX5_FENCE_MODE_FENCE = 2 << 5, - MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5, - MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5, - }; -@@ -534,9 +535,9 @@ struct mlx5_destroy_qp_mbox_out { - struct mlx5_modify_qp_mbox_in { - struct mlx5_inbox_hdr hdr; - __be32 qpn; -- u8 rsvd1[4]; -- __be32 optparam; - u8 rsvd0[4]; -+ __be32 optparam; -+ u8 rsvd1[4]; - struct mlx5_qp_context ctx; - }; - -diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h -index 28ee5c2e6bcd..711322a8ee35 100644 ---- a/include/target/target_core_backend.h -+++ b/include/target/target_core_backend.h -@@ -96,6 +96,6 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, - bool target_sense_desc_format(struct se_device *dev); - sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); - bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, -- struct request_queue *q, int block_size); -+ struct request_queue *q); - - #endif /* TARGET_CORE_BACKEND_H */ -diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h -index 689f4d207122..59081c73b296 100644 ---- a/include/target/target_core_base.h -+++ b/include/target/target_core_base.h -@@ -139,6 +139,7 @@ enum se_cmd_flags_table { - SCF_COMPARE_AND_WRITE_POST = 0x00100000, - SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC = 0x00200000, - SCF_ACK_KREF = 0x00400000, -+ SCF_TASK_ATTR_SET = 0x01000000, - }; - - /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ -diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h -index 7fb2557a760e..ce9ea736f1d7 100644 ---- a/include/target/target_core_fabric.h -+++ b/include/target/target_core_fabric.h -@@ -163,7 +163,6 @@ int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); - void core_tmr_release_req(struct se_tmr_req *); - int transport_generic_handle_tmr(struct se_cmd *); - void transport_generic_request_failure(struct se_cmd *, sense_reason_t); --void __target_execute_cmd(struct se_cmd *); - int transport_lookup_tmr_lun(struct se_cmd *, u64); - void core_allocate_nexus_loss_ua(struct se_node_acl *acl); - -diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h -index 003dca933803..5664ca07c9c7 100644 ---- a/include/trace/events/sunrpc.h -+++ b/include/trace/events/sunrpc.h -@@ -529,20 +529,27 @@ TRACE_EVENT(svc_xprt_do_enqueue, - - TP_STRUCT__entry( - __field(struct svc_xprt *, xprt) -- __field_struct(struct sockaddr_storage, ss) - __field(int, pid) - __field(unsigned long, flags) -+ __dynamic_array(unsigned char, addr, xprt != NULL ? -+ xprt->xpt_remotelen : 0) - ), - - TP_fast_assign( - __entry->xprt = xprt; -- xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss)); - __entry->pid = rqst? rqst->rq_task->pid : 0; -- __entry->flags = xprt ? xprt->xpt_flags : 0; -+ if (xprt) { -+ memcpy(__get_dynamic_array(addr), -+ &xprt->xpt_remote, -+ xprt->xpt_remotelen); -+ __entry->flags = xprt->xpt_flags; -+ } else -+ __entry->flags = 0; - ), - - TP_printk("xprt=0x%p addr=%pIScp pid=%d flags=%s", __entry->xprt, -- (struct sockaddr *)&__entry->ss, -+ __get_dynamic_array_len(addr) != 0 ? -+ (struct sockaddr *)__get_dynamic_array(addr) : NULL, - __entry->pid, show_svc_xprt_flags(__entry->flags)) - ); - -@@ -553,18 +560,25 @@ TRACE_EVENT(svc_xprt_dequeue, - - TP_STRUCT__entry( - __field(struct svc_xprt *, xprt) -- __field_struct(struct sockaddr_storage, ss) - __field(unsigned long, flags) -+ __dynamic_array(unsigned char, addr, xprt != NULL ? -+ xprt->xpt_remotelen : 0) - ), - - TP_fast_assign( -- __entry->xprt = xprt, -- xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss)); -- __entry->flags = xprt ? xprt->xpt_flags : 0; -+ __entry->xprt = xprt; -+ if (xprt) { -+ memcpy(__get_dynamic_array(addr), -+ &xprt->xpt_remote, -+ xprt->xpt_remotelen); -+ __entry->flags = xprt->xpt_flags; -+ } else -+ __entry->flags = 0; - ), - - TP_printk("xprt=0x%p addr=%pIScp flags=%s", __entry->xprt, -- (struct sockaddr *)&__entry->ss, -+ __get_dynamic_array_len(addr) != 0 ? -+ (struct sockaddr *)__get_dynamic_array(addr) : NULL, - show_svc_xprt_flags(__entry->flags)) - ); - -@@ -592,19 +606,26 @@ TRACE_EVENT(svc_handle_xprt, - TP_STRUCT__entry( - __field(struct svc_xprt *, xprt) - __field(int, len) -- __field_struct(struct sockaddr_storage, ss) - __field(unsigned long, flags) -+ __dynamic_array(unsigned char, addr, xprt != NULL ? -+ xprt->xpt_remotelen : 0) - ), - - TP_fast_assign( - __entry->xprt = xprt; -- xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss)); - __entry->len = len; -- __entry->flags = xprt ? xprt->xpt_flags : 0; -+ if (xprt) { -+ memcpy(__get_dynamic_array(addr), -+ &xprt->xpt_remote, -+ xprt->xpt_remotelen); -+ __entry->flags = xprt->xpt_flags; -+ } else -+ __entry->flags = 0; - ), - - TP_printk("xprt=0x%p addr=%pIScp len=%d flags=%s", __entry->xprt, -- (struct sockaddr *)&__entry->ss, -+ __get_dynamic_array_len(addr) != 0 ? -+ (struct sockaddr *)__get_dynamic_array(addr) : NULL, - __entry->len, show_svc_xprt_flags(__entry->flags)) - ); - #endif /* _TRACE_SUNRPC_H */ -diff --git a/kernel/auditsc.c b/kernel/auditsc.c -index b86cc04959de..48f45987dc6c 100644 ---- a/kernel/auditsc.c -+++ b/kernel/auditsc.c -@@ -73,6 +73,7 @@ - #include - #include - #include -+#include - #include - - #include "audit.h" -@@ -82,7 +83,8 @@ - #define AUDITSC_SUCCESS 1 - #define AUDITSC_FAILURE 2 - --/* no execve audit message should be longer than this (userspace limits) */ -+/* no execve audit message should be longer than this (userspace limits), -+ * see the note near the top of audit_log_execve_info() about this value */ - #define MAX_EXECVE_AUDIT_LEN 7500 - - /* max length to print of cmdline/proctitle value during audit */ -@@ -988,184 +990,178 @@ static int audit_log_pid_context(struct audit_context *context, pid_t pid, - return rc; - } - --/* -- * to_send and len_sent accounting are very loose estimates. We aren't -- * really worried about a hard cap to MAX_EXECVE_AUDIT_LEN so much as being -- * within about 500 bytes (next page boundary) -- * -- * why snprintf? an int is up to 12 digits long. if we just assumed when -- * logging that a[%d]= was going to be 16 characters long we would be wasting -- * space in every audit message. In one 7500 byte message we can log up to -- * about 1000 min size arguments. That comes down to about 50% waste of space -- * if we didn't do the snprintf to find out how long arg_num_len was. -- */ --static int audit_log_single_execve_arg(struct audit_context *context, -- struct audit_buffer **ab, -- int arg_num, -- size_t *len_sent, -- const char __user *p, -- char *buf) -+static void audit_log_execve_info(struct audit_context *context, -+ struct audit_buffer **ab) - { -- char arg_num_len_buf[12]; -- const char __user *tmp_p = p; -- /* how many digits are in arg_num? 5 is the length of ' a=""' */ -- size_t arg_num_len = snprintf(arg_num_len_buf, 12, "%d", arg_num) + 5; -- size_t len, len_left, to_send; -- size_t max_execve_audit_len = MAX_EXECVE_AUDIT_LEN; -- unsigned int i, has_cntl = 0, too_long = 0; -- int ret; -- -- /* strnlen_user includes the null we don't want to send */ -- len_left = len = strnlen_user(p, MAX_ARG_STRLEN) - 1; -- -- /* -- * We just created this mm, if we can't find the strings -- * we just copied into it something is _very_ wrong. Similar -- * for strings that are too long, we should not have created -- * any. -- */ -- if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) { -- send_sig(SIGKILL, current, 0); -- return -1; -+ long len_max; -+ long len_rem; -+ long len_full; -+ long len_buf; -+ long len_abuf; -+ long len_tmp; -+ bool require_data; -+ bool encode; -+ unsigned int iter; -+ unsigned int arg; -+ char *buf_head; -+ char *buf; -+ const char __user *p = (const char __user *)current->mm->arg_start; -+ -+ /* NOTE: this buffer needs to be large enough to hold all the non-arg -+ * data we put in the audit record for this argument (see the -+ * code below) ... at this point in time 96 is plenty */ -+ char abuf[96]; -+ -+ /* NOTE: we set MAX_EXECVE_AUDIT_LEN to a rather arbitrary limit, the -+ * current value of 7500 is not as important as the fact that it -+ * is less than 8k, a setting of 7500 gives us plenty of wiggle -+ * room if we go over a little bit in the logging below */ -+ WARN_ON_ONCE(MAX_EXECVE_AUDIT_LEN > 7500); -+ len_max = MAX_EXECVE_AUDIT_LEN; -+ -+ /* scratch buffer to hold the userspace args */ -+ buf_head = kmalloc(MAX_EXECVE_AUDIT_LEN + 1, GFP_KERNEL); -+ if (!buf_head) { -+ audit_panic("out of memory for argv string"); -+ return; - } -+ buf = buf_head; - -- /* walk the whole argument looking for non-ascii chars */ -+ audit_log_format(*ab, "argc=%d", context->execve.argc); -+ -+ len_rem = len_max; -+ len_buf = 0; -+ len_full = 0; -+ require_data = true; -+ encode = false; -+ iter = 0; -+ arg = 0; - do { -- if (len_left > MAX_EXECVE_AUDIT_LEN) -- to_send = MAX_EXECVE_AUDIT_LEN; -- else -- to_send = len_left; -- ret = copy_from_user(buf, tmp_p, to_send); -- /* -- * There is no reason for this copy to be short. We just -- * copied them here, and the mm hasn't been exposed to user- -- * space yet. -- */ -- if (ret) { -- WARN_ON(1); -- send_sig(SIGKILL, current, 0); -- return -1; -- } -- buf[to_send] = '\0'; -- has_cntl = audit_string_contains_control(buf, to_send); -- if (has_cntl) { -- /* -- * hex messages get logged as 2 bytes, so we can only -- * send half as much in each message -- */ -- max_execve_audit_len = MAX_EXECVE_AUDIT_LEN / 2; -- break; -- } -- len_left -= to_send; -- tmp_p += to_send; -- } while (len_left > 0); -- -- len_left = len; -- -- if (len > max_execve_audit_len) -- too_long = 1; -- -- /* rewalk the argument actually logging the message */ -- for (i = 0; len_left > 0; i++) { -- int room_left; -- -- if (len_left > max_execve_audit_len) -- to_send = max_execve_audit_len; -- else -- to_send = len_left; -- -- /* do we have space left to send this argument in this ab? */ -- room_left = MAX_EXECVE_AUDIT_LEN - arg_num_len - *len_sent; -- if (has_cntl) -- room_left -= (to_send * 2); -- else -- room_left -= to_send; -- if (room_left < 0) { -- *len_sent = 0; -- audit_log_end(*ab); -- *ab = audit_log_start(context, GFP_KERNEL, AUDIT_EXECVE); -- if (!*ab) -- return 0; -- } -+ /* NOTE: we don't ever want to trust this value for anything -+ * serious, but the audit record format insists we -+ * provide an argument length for really long arguments, -+ * e.g. > MAX_EXECVE_AUDIT_LEN, so we have no choice but -+ * to use strncpy_from_user() to obtain this value for -+ * recording in the log, although we don't use it -+ * anywhere here to avoid a double-fetch problem */ -+ if (len_full == 0) -+ len_full = strnlen_user(p, MAX_ARG_STRLEN) - 1; -+ -+ /* read more data from userspace */ -+ if (require_data) { -+ /* can we make more room in the buffer? */ -+ if (buf != buf_head) { -+ memmove(buf_head, buf, len_buf); -+ buf = buf_head; -+ } -+ -+ /* fetch as much as we can of the argument */ -+ len_tmp = strncpy_from_user(&buf_head[len_buf], p, -+ len_max - len_buf); -+ if (len_tmp == -EFAULT) { -+ /* unable to copy from userspace */ -+ send_sig(SIGKILL, current, 0); -+ goto out; -+ } else if (len_tmp == (len_max - len_buf)) { -+ /* buffer is not large enough */ -+ require_data = true; -+ /* NOTE: if we are going to span multiple -+ * buffers force the encoding so we stand -+ * a chance at a sane len_full value and -+ * consistent record encoding */ -+ encode = true; -+ len_full = len_full * 2; -+ p += len_tmp; -+ } else { -+ require_data = false; -+ if (!encode) -+ encode = audit_string_contains_control( -+ buf, len_tmp); -+ /* try to use a trusted value for len_full */ -+ if (len_full < len_max) -+ len_full = (encode ? -+ len_tmp * 2 : len_tmp); -+ p += len_tmp + 1; -+ } -+ len_buf += len_tmp; -+ buf_head[len_buf] = '\0'; - -- /* -- * first record needs to say how long the original string was -- * so we can be sure nothing was lost. -- */ -- if ((i == 0) && (too_long)) -- audit_log_format(*ab, " a%d_len=%zu", arg_num, -- has_cntl ? 2*len : len); -- -- /* -- * normally arguments are small enough to fit and we already -- * filled buf above when we checked for control characters -- * so don't bother with another copy_from_user -- */ -- if (len >= max_execve_audit_len) -- ret = copy_from_user(buf, p, to_send); -- else -- ret = 0; -- if (ret) { -- WARN_ON(1); -- send_sig(SIGKILL, current, 0); -- return -1; -+ /* length of the buffer in the audit record? */ -+ len_abuf = (encode ? len_buf * 2 : len_buf + 2); - } -- buf[to_send] = '\0'; -- -- /* actually log it */ -- audit_log_format(*ab, " a%d", arg_num); -- if (too_long) -- audit_log_format(*ab, "[%d]", i); -- audit_log_format(*ab, "="); -- if (has_cntl) -- audit_log_n_hex(*ab, buf, to_send); -- else -- audit_log_string(*ab, buf); -- -- p += to_send; -- len_left -= to_send; -- *len_sent += arg_num_len; -- if (has_cntl) -- *len_sent += to_send * 2; -- else -- *len_sent += to_send; -- } -- /* include the null we didn't log */ -- return len + 1; --} - --static void audit_log_execve_info(struct audit_context *context, -- struct audit_buffer **ab) --{ -- int i, len; -- size_t len_sent = 0; -- const char __user *p; -- char *buf; -+ /* write as much as we can to the audit log */ -+ if (len_buf > 0) { -+ /* NOTE: some magic numbers here - basically if we -+ * can't fit a reasonable amount of data into the -+ * existing audit buffer, flush it and start with -+ * a new buffer */ -+ if ((sizeof(abuf) + 8) > len_rem) { -+ len_rem = len_max; -+ audit_log_end(*ab); -+ *ab = audit_log_start(context, -+ GFP_KERNEL, AUDIT_EXECVE); -+ if (!*ab) -+ goto out; -+ } - -- p = (const char __user *)current->mm->arg_start; -+ /* create the non-arg portion of the arg record */ -+ len_tmp = 0; -+ if (require_data || (iter > 0) || -+ ((len_abuf + sizeof(abuf)) > len_rem)) { -+ if (iter == 0) { -+ len_tmp += snprintf(&abuf[len_tmp], -+ sizeof(abuf) - len_tmp, -+ " a%d_len=%lu", -+ arg, len_full); -+ } -+ len_tmp += snprintf(&abuf[len_tmp], -+ sizeof(abuf) - len_tmp, -+ " a%d[%d]=", arg, iter++); -+ } else -+ len_tmp += snprintf(&abuf[len_tmp], -+ sizeof(abuf) - len_tmp, -+ " a%d=", arg); -+ WARN_ON(len_tmp >= sizeof(abuf)); -+ abuf[sizeof(abuf) - 1] = '\0'; -+ -+ /* log the arg in the audit record */ -+ audit_log_format(*ab, "%s", abuf); -+ len_rem -= len_tmp; -+ len_tmp = len_buf; -+ if (encode) { -+ if (len_abuf > len_rem) -+ len_tmp = len_rem / 2; /* encoding */ -+ audit_log_n_hex(*ab, buf, len_tmp); -+ len_rem -= len_tmp * 2; -+ len_abuf -= len_tmp * 2; -+ } else { -+ if (len_abuf > len_rem) -+ len_tmp = len_rem - 2; /* quotes */ -+ audit_log_n_string(*ab, buf, len_tmp); -+ len_rem -= len_tmp + 2; -+ /* don't subtract the "2" because we still need -+ * to add quotes to the remaining string */ -+ len_abuf -= len_tmp; -+ } -+ len_buf -= len_tmp; -+ buf += len_tmp; -+ } - -- audit_log_format(*ab, "argc=%d", context->execve.argc); -+ /* ready to move to the next argument? */ -+ if ((len_buf == 0) && !require_data) { -+ arg++; -+ iter = 0; -+ len_full = 0; -+ require_data = true; -+ encode = false; -+ } -+ } while (arg < context->execve.argc); - -- /* -- * we need some kernel buffer to hold the userspace args. Just -- * allocate one big one rather than allocating one of the right size -- * for every single argument inside audit_log_single_execve_arg() -- * should be <8k allocation so should be pretty safe. -- */ -- buf = kmalloc(MAX_EXECVE_AUDIT_LEN + 1, GFP_KERNEL); -- if (!buf) { -- audit_panic("out of memory for argv string"); -- return; -- } -+ /* NOTE: the caller handles the final audit_log_end() call */ - -- for (i = 0; i < context->execve.argc; i++) { -- len = audit_log_single_execve_arg(context, ab, i, -- &len_sent, p, buf); -- if (len <= 0) -- break; -- p += len; -- } -- kfree(buf); -+out: -+ kfree(buf_head); - } - - static void show_special(struct audit_context *context, int *call_panic) -diff --git a/kernel/module.c b/kernel/module.c -index 0e5c71195f18..b14a4f31221f 100644 ---- a/kernel/module.c -+++ b/kernel/module.c -@@ -2606,13 +2606,18 @@ static inline void kmemleak_load_module(const struct module *mod, - #endif - - #ifdef CONFIG_MODULE_SIG --static int module_sig_check(struct load_info *info) -+static int module_sig_check(struct load_info *info, int flags) - { - int err = -ENOKEY; - const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; - const void *mod = info->hdr; - -- if (info->len > markerlen && -+ /* -+ * Require flags == 0, as a module with version information -+ * removed is no longer the module that was signed -+ */ -+ if (flags == 0 && -+ info->len > markerlen && - memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) { - /* We truncate the module to discard the signature */ - info->len -= markerlen; -@@ -2631,7 +2636,7 @@ static int module_sig_check(struct load_info *info) - return err; - } - #else /* !CONFIG_MODULE_SIG */ --static int module_sig_check(struct load_info *info) -+static int module_sig_check(struct load_info *info, int flags) - { - return 0; - } -@@ -3444,7 +3449,7 @@ static int load_module(struct load_info *info, const char __user *uargs, - long err; - char *after_dashes; - -- err = module_sig_check(info); -+ err = module_sig_check(info, flags); - if (err) - goto free_copy; - -diff --git a/mm/backing-dev.c b/mm/backing-dev.c -index cbe6f0b96f29..9ef80bf441b3 100644 ---- a/mm/backing-dev.c -+++ b/mm/backing-dev.c -@@ -825,6 +825,20 @@ int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev) - } - EXPORT_SYMBOL(bdi_register_dev); - -+int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner) -+{ -+ int rc; -+ -+ rc = bdi_register(bdi, NULL, "%u:%u", MAJOR(owner->devt), -+ MINOR(owner->devt)); -+ if (rc) -+ return rc; -+ bdi->owner = owner; -+ get_device(owner); -+ return 0; -+} -+EXPORT_SYMBOL(bdi_register_owner); -+ - /* - * Remove bdi from bdi_list, and ensure that it is no longer visible - */ -@@ -849,6 +863,11 @@ void bdi_unregister(struct backing_dev_info *bdi) - device_unregister(bdi->dev); - bdi->dev = NULL; - } -+ -+ if (bdi->owner) { -+ put_device(bdi->owner); -+ bdi->owner = NULL; -+ } - } - - void bdi_exit(struct backing_dev_info *bdi) -diff --git a/mm/hugetlb.c b/mm/hugetlb.c -index ef6963b577fd..0c31f184daf8 100644 ---- a/mm/hugetlb.c -+++ b/mm/hugetlb.c -@@ -2170,6 +2170,10 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count, - * and reducing the surplus. - */ - spin_unlock(&hugetlb_lock); -+ -+ /* yield cpu to avoid soft lockup */ -+ cond_resched(); -+ - if (hstate_is_gigantic(h)) - ret = alloc_fresh_gigantic_page(h, nodes_allowed); - else -diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c -index 1bb551527044..d9bbbded49ef 100644 ---- a/net/bluetooth/l2cap_sock.c -+++ b/net/bluetooth/l2cap_sock.c -@@ -927,7 +927,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, - break; - } - -- if (get_user(opt, (u32 __user *) optval)) { -+ if (get_user(opt, (u16 __user *) optval)) { - err = -EFAULT; - break; - } -diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c -index 28cddc85b700..bfa2b6d5b5cf 100644 ---- a/net/netlabel/netlabel_kapi.c -+++ b/net/netlabel/netlabel_kapi.c -@@ -824,7 +824,11 @@ socket_setattr_return: - */ - void netlbl_sock_delattr(struct sock *sk) - { -- cipso_v4_sock_delattr(sk); -+ switch (sk->sk_family) { -+ case AF_INET: -+ cipso_v4_sock_delattr(sk); -+ break; -+ } - } - - /** -@@ -987,7 +991,11 @@ req_setattr_return: - */ - void netlbl_req_delattr(struct request_sock *req) - { -- cipso_v4_req_delattr(req); -+ switch (req->rsk_ops->family) { -+ case AF_INET: -+ cipso_v4_req_delattr(req); -+ break; -+ } - } - - /** -diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c -index e167592793a7..42396a74405d 100644 ---- a/scripts/recordmcount.c -+++ b/scripts/recordmcount.c -@@ -33,10 +33,17 @@ - #include - #include - -+/* -+ * glibc synced up and added the metag number but didn't add the relocations. -+ * Work around this in a crude manner for now. -+ */ - #ifndef EM_METAG --/* Remove this when these make it to the standard system elf.h. */ - #define EM_METAG 174 -+#endif -+#ifndef R_METAG_ADDR32 - #define R_METAG_ADDR32 2 -+#endif -+#ifndef R_METAG_NONE - #define R_METAG_NONE 3 - #endif - -diff --git a/sound/hda/array.c b/sound/hda/array.c -index 516795baa7db..5dfa610e4471 100644 ---- a/sound/hda/array.c -+++ b/sound/hda/array.c -@@ -21,13 +21,15 @@ void *snd_array_new(struct snd_array *array) - return NULL; - if (array->used >= array->alloced) { - int num = array->alloced + array->alloc_align; -+ int oldsize = array->alloced * array->elem_size; - int size = (num + 1) * array->elem_size; - void *nlist; - if (snd_BUG_ON(num >= 4096)) - return NULL; -- nlist = krealloc(array->list, size, GFP_KERNEL | __GFP_ZERO); -+ nlist = krealloc(array->list, size, GFP_KERNEL); - if (!nlist) - return NULL; -+ memset(nlist + oldsize, 0, size - oldsize); - array->list = nlist; - array->alloced = num; - } -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index 8218cace8fea..e769e5764cba 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -2288,6 +2288,8 @@ static const struct pci_device_id azx_ids[] = { - { PCI_DEVICE(0x1022, 0x780d), - .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB }, - /* ATI HDMI */ -+ { PCI_DEVICE(0x1002, 0x0002), -+ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0x1308), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0x157a), -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index abcb5a6a1cd9..f25479ba3981 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -4674,6 +4674,22 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec, - } - } - -+static void alc298_fixup_speaker_volume(struct hda_codec *codec, -+ const struct hda_fixup *fix, int action) -+{ -+ if (action == HDA_FIXUP_ACT_PRE_PROBE) { -+ /* The speaker is routed to the Node 0x06 by a mistake, as a result -+ we can't adjust the speaker's volume since this node does not has -+ Amp-out capability. we change the speaker's route to: -+ Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 ( -+ Pin Complex), since Node 0x02 has Amp-out caps, we can adjust -+ speaker's volume now. */ -+ -+ hda_nid_t conn1[1] = { 0x0c }; -+ snd_hda_override_conn_list(codec, 0x17, 1, conn1); -+ } -+} -+ - /* Hook to update amp GPIO4 for automute */ - static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec, - struct hda_jack_callback *jack) -@@ -4823,6 +4839,7 @@ enum { - ALC280_FIXUP_HP_HEADSET_MIC, - ALC221_FIXUP_HP_FRONT_MIC, - ALC292_FIXUP_TPT460, -+ ALC298_FIXUP_SPK_VOLUME, - }; - - static const struct hda_fixup alc269_fixups[] = { -@@ -5478,6 +5495,12 @@ static const struct hda_fixup alc269_fixups[] = { - .chained = true, - .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE, - }, -+ [ALC298_FIXUP_SPK_VOLUME] = { -+ .type = HDA_FIXUP_FUNC, -+ .v.func = alc298_fixup_speaker_volume, -+ .chained = true, -+ .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, -+ }, - }; - - static const struct snd_pci_quirk alc269_fixup_tbl[] = { -@@ -5524,6 +5547,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), - SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), - SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), -+ SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), - SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), -@@ -5799,6 +5823,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - {0x1b, 0x01014020}, - {0x21, 0x0221103f}), - SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, -+ {0x14, 0x90170130}, -+ {0x1b, 0x02011020}, -+ {0x21, 0x0221103f}), -+ SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - {0x14, 0x90170150}, - {0x1b, 0x02011020}, - {0x21, 0x0221105f}), -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index 510df220d1b5..336ed267c407 100644 ---- a/virt/kvm/kvm_main.c -+++ b/virt/kvm/kvm_main.c -@@ -142,6 +142,7 @@ int vcpu_load(struct kvm_vcpu *vcpu) - put_cpu(); - return 0; - } -+EXPORT_SYMBOL_GPL(vcpu_load); - - void vcpu_put(struct kvm_vcpu *vcpu) - { -@@ -151,6 +152,7 @@ void vcpu_put(struct kvm_vcpu *vcpu) - preempt_enable(); - mutex_unlock(&vcpu->mutex); - } -+EXPORT_SYMBOL_GPL(vcpu_put); - - static void ack_flush(void *_completed) - { diff --git a/patch/kernel/marvell-dev/patch-4.4.19-20.patch b/patch/kernel/marvell-dev/patch-4.4.19-20.patch deleted file mode 100644 index f1c008e6e2..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.19-20.patch +++ /dev/null @@ -1,3676 +0,0 @@ -diff --git a/Makefile b/Makefile -index 695c64ec160c..b74d60081a16 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 19 -+SUBLEVEL = 20 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arc/Makefile b/arch/arc/Makefile -index 209d8451e23d..c05ea2b54276 100644 ---- a/arch/arc/Makefile -+++ b/arch/arc/Makefile -@@ -18,6 +18,20 @@ cflags-y += -fno-common -pipe -fno-builtin -D__linux__ - cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7 - cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs - -+is_700 = $(shell $(CC) -dM -E - < /dev/null | grep -q "ARC700" && echo 1 || echo 0) -+ -+ifdef CONFIG_ISA_ARCOMPACT -+ifeq ($(is_700), 0) -+ $(error Toolchain not configured for ARCompact builds) -+endif -+endif -+ -+ifdef CONFIG_ISA_ARCV2 -+ifeq ($(is_700), 1) -+ $(error Toolchain not configured for ARCv2 builds) -+endif -+endif -+ - ifdef CONFIG_ARC_CURR_IN_REG - # For a global register defintion, make sure it gets passed to every file - # We had a customer reported bug where some code built in kernel was NOT using -diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h -index 7fac7d85ed6a..2c30a016cf15 100644 ---- a/arch/arc/include/asm/arcregs.h -+++ b/arch/arc/include/asm/arcregs.h -@@ -374,12 +374,6 @@ static inline int is_isa_arcompact(void) - return IS_ENABLED(CONFIG_ISA_ARCOMPACT); - } - --#if defined(CONFIG_ISA_ARCOMPACT) && !defined(_CPU_DEFAULT_A7) --#error "Toolchain not configured for ARCompact builds" --#elif defined(CONFIG_ISA_ARCV2) && !defined(_CPU_DEFAULT_HS) --#error "Toolchain not configured for ARCv2 builds" --#endif -- - #endif /* __ASEMBLY__ */ - - #endif /* _ASM_ARC_ARCREGS_H */ -diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h -index ad7860c5ce15..51597f344a62 100644 ---- a/arch/arc/include/asm/entry.h -+++ b/arch/arc/include/asm/entry.h -@@ -142,7 +142,7 @@ - - #ifdef CONFIG_ARC_CURR_IN_REG - ; Retrieve orig r25 and save it with rest of callee_regs -- ld.as r12, [r12, PT_user_r25] -+ ld r12, [r12, PT_user_r25] - PUSH r12 - #else - PUSH r25 -@@ -198,7 +198,7 @@ - - ; SP is back to start of pt_regs - #ifdef CONFIG_ARC_CURR_IN_REG -- st.as r12, [sp, PT_user_r25] -+ st r12, [sp, PT_user_r25] - #endif - .endm - -diff --git a/arch/arc/include/asm/irqflags-compact.h b/arch/arc/include/asm/irqflags-compact.h -index c1d36458bfb7..4c6eed80cd8b 100644 ---- a/arch/arc/include/asm/irqflags-compact.h -+++ b/arch/arc/include/asm/irqflags-compact.h -@@ -188,10 +188,10 @@ static inline int arch_irqs_disabled(void) - .endm - - .macro IRQ_ENABLE scratch -+ TRACE_ASM_IRQ_ENABLE - lr \scratch, [status32] - or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK) - flag \scratch -- TRACE_ASM_IRQ_ENABLE - .endm - - #endif /* __ASSEMBLY__ */ -diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c -index ff7ff6cbb811..aaf1e2d1d900 100644 ---- a/arch/arc/mm/cache.c -+++ b/arch/arc/mm/cache.c -@@ -914,6 +914,15 @@ void arc_cache_init(void) - - printk(arc_cache_mumbojumbo(0, str, sizeof(str))); - -+ /* -+ * Only master CPU needs to execute rest of function: -+ * - Assume SMP so all cores will have same cache config so -+ * any geomtry checks will be same for all -+ * - IOC setup / dma callbacks only need to be setup once -+ */ -+ if (cpu) -+ return; -+ - if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { - struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; - -diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi -index 8fe39e1b680e..e0ee2b00d573 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi -+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi -@@ -262,6 +262,8 @@ - #io-channel-cells = <1>; - clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; - clock-names = "saradc", "apb_pclk"; -+ resets = <&cru SRST_SARADC>; -+ reset-names = "saradc-apb"; - status = "disabled"; - }; - -diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h -index bc6492b9a924..44dd892a4bbe 100644 ---- a/arch/arm64/include/asm/elf.h -+++ b/arch/arm64/include/asm/elf.h -@@ -136,6 +136,7 @@ typedef struct user_fpsimd_state elf_fpregset_t; - - #define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT); - -+/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ - #define ARCH_DLINFO \ - do { \ - NEW_AUX_ENT(AT_SYSINFO_EHDR, \ -diff --git a/arch/arm64/include/uapi/asm/auxvec.h b/arch/arm64/include/uapi/asm/auxvec.h -index 22d6d8885854..4cf0c17787a8 100644 ---- a/arch/arm64/include/uapi/asm/auxvec.h -+++ b/arch/arm64/include/uapi/asm/auxvec.h -@@ -19,4 +19,6 @@ - /* vDSO location */ - #define AT_SYSINFO_EHDR 33 - -+#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */ -+ - #endif -diff --git a/arch/parisc/include/uapi/asm/errno.h b/arch/parisc/include/uapi/asm/errno.h -index c0ae62520d15..274d5bc6ecce 100644 ---- a/arch/parisc/include/uapi/asm/errno.h -+++ b/arch/parisc/include/uapi/asm/errno.h -@@ -97,10 +97,10 @@ - #define ENOTCONN 235 /* Transport endpoint is not connected */ - #define ESHUTDOWN 236 /* Cannot send after transport endpoint shutdown */ - #define ETOOMANYREFS 237 /* Too many references: cannot splice */ --#define EREFUSED ECONNREFUSED /* for HP's NFS apparently */ - #define ETIMEDOUT 238 /* Connection timed out */ - #define ECONNREFUSED 239 /* Connection refused */ --#define EREMOTERELEASE 240 /* Remote peer released connection */ -+#define EREFUSED ECONNREFUSED /* for HP's NFS apparently */ -+#define EREMOTERELEASE 240 /* Remote peer released connection */ - #define EHOSTDOWN 241 /* Host is down */ - #define EHOSTUNREACH 242 /* No route to host */ - -diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c -index b34e8a54f7db..98949b0df00a 100644 ---- a/arch/powerpc/kernel/eeh.c -+++ b/arch/powerpc/kernel/eeh.c -@@ -677,7 +677,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function) - /* Check if the request is finished successfully */ - if (active_flag) { - rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); -- if (rc <= 0) -+ if (rc < 0) - return rc; - - if (rc & active_flag) -diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S -index 1dd5bd8a8c59..133055311dce 100644 ---- a/arch/um/include/asm/common.lds.S -+++ b/arch/um/include/asm/common.lds.S -@@ -81,7 +81,7 @@ - .altinstr_replacement : { *(.altinstr_replacement) } - /* .exit.text is discard at runtime, not link time, to deal with references - from .altinstructions and .eh_frame */ -- .exit.text : { *(.exit.text) } -+ .exit.text : { EXIT_TEXT } - .exit.data : { *(.exit.data) } - - .preinit_array : { -diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h -index 6df2029405a3..3142218e546f 100644 ---- a/arch/x86/include/asm/tlbflush.h -+++ b/arch/x86/include/asm/tlbflush.h -@@ -86,7 +86,14 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask) - - static inline void __native_flush_tlb(void) - { -+ /* -+ * If current->mm == NULL then we borrow a mm which may change during a -+ * task switch and therefore we must not be preempted while we write CR3 -+ * back: -+ */ -+ preempt_disable(); - native_write_cr3(native_read_cr3()); -+ preempt_enable(); - } - - static inline void __native_flush_tlb_global_irq_disabled(void) -diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c -index bf4db6eaec8f..c6aace2bbe08 100644 ---- a/arch/x86/kernel/uprobes.c -+++ b/arch/x86/kernel/uprobes.c -@@ -357,20 +357,22 @@ static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn) - *cursor &= 0xfe; - } - /* -- * Similar treatment for VEX3 prefix. -- * TODO: add XOP/EVEX treatment when insn decoder supports them -+ * Similar treatment for VEX3/EVEX prefix. -+ * TODO: add XOP treatment when insn decoder supports them - */ -- if (insn->vex_prefix.nbytes == 3) { -+ if (insn->vex_prefix.nbytes >= 3) { - /* - * vex2: c5 rvvvvLpp (has no b bit) - * vex3/xop: c4/8f rxbmmmmm wvvvvLpp - * evex: 62 rxbR00mm wvvvv1pp zllBVaaa -- * (evex will need setting of both b and x since -- * in non-sib encoding evex.x is 4th bit of MODRM.rm) -- * Setting VEX3.b (setting because it has inverted meaning): -+ * Setting VEX3.b (setting because it has inverted meaning). -+ * Setting EVEX.x since (in non-SIB encoding) EVEX.x -+ * is the 4th bit of MODRM.rm, and needs the same treatment. -+ * For VEX3-encoded insns, VEX3.x value has no effect in -+ * non-SIB encoding, the change is superfluous but harmless. - */ - cursor = auprobe->insn + insn_offset_vex_prefix(insn) + 1; -- *cursor |= 0x20; -+ *cursor |= 0x60; - } - - /* -@@ -415,12 +417,10 @@ static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn) - - reg = MODRM_REG(insn); /* Fetch modrm.reg */ - reg2 = 0xff; /* Fetch vex.vvvv */ -- if (insn->vex_prefix.nbytes == 2) -- reg2 = insn->vex_prefix.bytes[1]; -- else if (insn->vex_prefix.nbytes == 3) -+ if (insn->vex_prefix.nbytes) - reg2 = insn->vex_prefix.bytes[2]; - /* -- * TODO: add XOP, EXEV vvvv reading. -+ * TODO: add XOP vvvv reading. - * - * vex.vvvv field is in bits 6-3, bits are inverted. - * But in 32-bit mode, high-order bit may be ignored. -diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c -index 6730f965b379..0afd1981e350 100644 ---- a/drivers/acpi/cppc_acpi.c -+++ b/drivers/acpi/cppc_acpi.c -@@ -216,8 +216,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data) - continue; - - cpc_ptr = per_cpu(cpc_desc_ptr, i); -- if (!cpc_ptr) -- continue; -+ if (!cpc_ptr) { -+ retval = -EFAULT; -+ goto err_ret; -+ } - - pdomain = &(cpc_ptr->domain_info); - cpumask_set_cpu(i, pr->shared_cpu_map); -@@ -239,8 +241,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data) - continue; - - match_cpc_ptr = per_cpu(cpc_desc_ptr, j); -- if (!match_cpc_ptr) -- continue; -+ if (!match_cpc_ptr) { -+ retval = -EFAULT; -+ goto err_ret; -+ } - - match_pdomain = &(match_cpc_ptr->domain_info); - if (match_pdomain->domain != pdomain->domain) -@@ -270,8 +274,10 @@ int acpi_get_psd_map(struct cpudata **all_cpu_data) - continue; - - match_cpc_ptr = per_cpu(cpc_desc_ptr, j); -- if (!match_cpc_ptr) -- continue; -+ if (!match_cpc_ptr) { -+ retval = -EFAULT; -+ goto err_ret; -+ } - - match_pdomain = &(match_cpc_ptr->domain_info); - if (match_pdomain->domain != pdomain->domain) -@@ -502,9 +508,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) - /* Store CPU Logical ID */ - cpc_ptr->cpu_id = pr->id; - -- /* Plug it into this CPUs CPC descriptor. */ -- per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr; -- - /* Parse PSD data for this CPU */ - ret = acpi_get_psd(cpc_ptr, handle); - if (ret) -@@ -517,6 +520,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) - goto out_free; - } - -+ /* Plug PSD data into this CPUs CPC descriptor. */ -+ per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr; -+ - /* Everything looks okay */ - pr_debug("Parsed CPC struct for CPU: %d\n", pr->id); - -diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c -index 11d8209e6e5d..5230e8449d30 100644 ---- a/drivers/acpi/nfit.c -+++ b/drivers/acpi/nfit.c -@@ -1072,11 +1072,12 @@ static u32 read_blk_stat(struct nfit_blk *nfit_blk, unsigned int bw) - { - struct nfit_blk_mmio *mmio = &nfit_blk->mmio[DCR]; - u64 offset = nfit_blk->stat_offset + mmio->size * bw; -+ const u32 STATUS_MASK = 0x80000037; - - if (mmio->num_lines) - offset = to_interleave_offset(offset, mmio); - -- return readl(mmio->addr.base + offset); -+ return readl(mmio->addr.base + offset) & STATUS_MASK; - } - - static void write_blk_ctl(struct nfit_blk *nfit_blk, unsigned int bw, -diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c -index 72b6e9ef0ae9..d176e0ece470 100644 ---- a/drivers/acpi/numa.c -+++ b/drivers/acpi/numa.c -@@ -327,10 +327,18 @@ int __init acpi_numa_init(void) - - /* SRAT: Static Resource Affinity Table */ - if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { -- acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY, -- acpi_parse_x2apic_affinity, 0); -- acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, -- acpi_parse_processor_affinity, 0); -+ struct acpi_subtable_proc srat_proc[2]; -+ -+ memset(srat_proc, 0, sizeof(srat_proc)); -+ srat_proc[0].id = ACPI_SRAT_TYPE_CPU_AFFINITY; -+ srat_proc[0].handler = acpi_parse_processor_affinity; -+ srat_proc[1].id = ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY; -+ srat_proc[1].handler = acpi_parse_x2apic_affinity; -+ -+ acpi_table_parse_entries_array(ACPI_SIG_SRAT, -+ sizeof(struct acpi_table_srat), -+ srat_proc, ARRAY_SIZE(srat_proc), 0); -+ - cnt = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, - acpi_parse_memory_affinity, - NR_NODE_MEMBLKS); -diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c -index 78d5f02a073b..dcb3d6245ca5 100644 ---- a/drivers/acpi/scan.c -+++ b/drivers/acpi/scan.c -@@ -1958,7 +1958,7 @@ int __init acpi_scan_init(void) - - static struct acpi_probe_entry *ape; - static int acpi_probe_count; --static DEFINE_SPINLOCK(acpi_probe_lock); -+static DEFINE_MUTEX(acpi_probe_mutex); - - static int __init acpi_match_madt(struct acpi_subtable_header *header, - const unsigned long end) -@@ -1977,7 +1977,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) - if (acpi_disabled) - return 0; - -- spin_lock(&acpi_probe_lock); -+ mutex_lock(&acpi_probe_mutex); - for (ape = ap_head; nr; ape++, nr--) { - if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) { - acpi_probe_count = 0; -@@ -1990,7 +1990,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) - count++; - } - } -- spin_unlock(&acpi_probe_lock); -+ mutex_unlock(&acpi_probe_mutex); - - return count; - } -diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c -index 0243d375c6fd..4b3a9e27f1b6 100644 ---- a/drivers/acpi/sysfs.c -+++ b/drivers/acpi/sysfs.c -@@ -555,23 +555,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device, - static int get_status(u32 index, acpi_event_status *status, - acpi_handle *handle) - { -- int result = 0; -+ int result; - - if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS) -- goto end; -+ return -EINVAL; - - if (index < num_gpes) { - result = acpi_get_gpe_device(index, handle); - if (result) { - ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, - "Invalid GPE 0x%x", index)); -- goto end; -+ return result; - } - result = acpi_get_gpe_status(*handle, index, status); - } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) - result = acpi_get_event_status(index - num_gpes, status); - --end: - return result; - } - -diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c -index ea8189f4b021..6dc597126b79 100644 ---- a/drivers/crypto/caam/caamalg.c -+++ b/drivers/crypto/caam/caamalg.c -@@ -441,6 +441,9 @@ static int aead_set_sh_desc(struct crypto_aead *aead) - OP_ALG_AAI_CTR_MOD128); - const bool is_rfc3686 = alg->caam.rfc3686; - -+ if (!ctx->authsize) -+ return 0; -+ - /* NULL encryption / decryption */ - if (!ctx->enckeylen) - return aead_null_set_sh_desc(aead); -@@ -614,7 +617,7 @@ skip_enc: - keys_fit_inline = true; - - /* aead_givencrypt shared descriptor */ -- desc = ctx->sh_desc_givenc; -+ desc = ctx->sh_desc_enc; - - /* Note: Context registers are saved. */ - init_sh_desc_key_aead(desc, ctx, keys_fit_inline, is_rfc3686); -@@ -645,13 +648,13 @@ copy_iv: - append_operation(desc, ctx->class2_alg_type | - OP_ALG_AS_INITFINAL | OP_ALG_ENCRYPT); - -- /* ivsize + cryptlen = seqoutlen - authsize */ -- append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); -- - /* Read and write assoclen bytes */ - append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); - append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); - -+ /* ivsize + cryptlen = seqoutlen - authsize */ -+ append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); -+ - /* Skip assoc data */ - append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); - -@@ -697,7 +700,7 @@ copy_iv: - ctx->sh_desc_enc_dma = dma_map_single(jrdev, desc, - desc_bytes(desc), - DMA_TO_DEVICE); -- if (dma_mapping_error(jrdev, ctx->sh_desc_givenc_dma)) { -+ if (dma_mapping_error(jrdev, ctx->sh_desc_enc_dma)) { - dev_err(jrdev, "unable to map shared descriptor\n"); - return -ENOMEM; - } -diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c -index 49106ea42887..99d5e11db194 100644 ---- a/drivers/crypto/caam/caamhash.c -+++ b/drivers/crypto/caam/caamhash.c -@@ -1873,6 +1873,7 @@ caam_hash_alloc(struct caam_hash_template *template, - template->name); - snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s", - template->driver_name); -+ t_alg->ahash_alg.setkey = NULL; - } - alg->cra_module = THIS_MODULE; - alg->cra_init = caam_hash_cra_init; -diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c -index 0794f1cc0018..42f0f229f7f7 100644 ---- a/drivers/crypto/nx/nx.c -+++ b/drivers/crypto/nx/nx.c -@@ -392,7 +392,7 @@ static void nx_of_update_msc(struct device *dev, - ((bytes_so_far + sizeof(struct msc_triplet)) <= lenp) && - i < msc->triplets; - i++) { -- if (msc->fc > NX_MAX_FC || msc->mode > NX_MAX_MODE) { -+ if (msc->fc >= NX_MAX_FC || msc->mode >= NX_MAX_MODE) { - dev_err(dev, "unknown function code/mode " - "combo: %d/%d (ignored)\n", msc->fc, - msc->mode); -diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c -index 59e4c3af15ed..367b6661ee04 100644 ---- a/drivers/crypto/qat/qat_common/qat_algs.c -+++ b/drivers/crypto/qat/qat_common/qat_algs.c -@@ -1262,8 +1262,8 @@ static struct crypto_alg qat_algs[] = { { - .setkey = qat_alg_ablkcipher_xts_setkey, - .decrypt = qat_alg_ablkcipher_decrypt, - .encrypt = qat_alg_ablkcipher_encrypt, -- .min_keysize = AES_MIN_KEY_SIZE, -- .max_keysize = AES_MAX_KEY_SIZE, -+ .min_keysize = 2 * AES_MIN_KEY_SIZE, -+ .max_keysize = 2 * AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - }, - }, -diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c -index f1bcc2a163b3..b1bc945f008f 100644 ---- a/drivers/dma/sh/usb-dmac.c -+++ b/drivers/dma/sh/usb-dmac.c -@@ -600,27 +600,30 @@ static irqreturn_t usb_dmac_isr_channel(int irq, void *dev) - { - struct usb_dmac_chan *chan = dev; - irqreturn_t ret = IRQ_NONE; -- u32 mask = USB_DMACHCR_TE; -- u32 check_bits = USB_DMACHCR_TE | USB_DMACHCR_SP; -+ u32 mask = 0; - u32 chcr; -+ bool xfer_end = false; - - spin_lock(&chan->vc.lock); - - chcr = usb_dmac_chan_read(chan, USB_DMACHCR); -- if (chcr & check_bits) -- mask |= USB_DMACHCR_DE | check_bits; -+ if (chcr & (USB_DMACHCR_TE | USB_DMACHCR_SP)) { -+ mask |= USB_DMACHCR_DE | USB_DMACHCR_TE | USB_DMACHCR_SP; -+ if (chcr & USB_DMACHCR_DE) -+ xfer_end = true; -+ ret |= IRQ_HANDLED; -+ } - if (chcr & USB_DMACHCR_NULL) { - /* An interruption of TE will happen after we set FTE */ - mask |= USB_DMACHCR_NULL; - chcr |= USB_DMACHCR_FTE; - ret |= IRQ_HANDLED; - } -- usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); -+ if (mask) -+ usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); - -- if (chcr & check_bits) { -+ if (xfer_end) - usb_dmac_isr_transfer_end(chan); -- ret |= IRQ_HANDLED; -- } - - spin_unlock(&chan->vc.lock); - -diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c -index 1b2c2187b347..dc68394da682 100644 ---- a/drivers/edac/edac_mc.c -+++ b/drivers/edac/edac_mc.c -@@ -966,7 +966,7 @@ static void edac_inc_ue_error(struct mem_ctl_info *mci, - mci->ue_mc += count; - - if (!enable_per_layer_report) { -- mci->ce_noinfo_count += count; -+ mci->ue_noinfo_count += count; - return; - } - -diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig -index b18bea08ff25..469dc378adeb 100644 ---- a/drivers/gpio/Kconfig -+++ b/drivers/gpio/Kconfig -@@ -50,6 +50,7 @@ config GPIO_DEVRES - config OF_GPIO - def_bool y - depends on OF -+ depends on HAS_IOMEM - - config GPIO_ACPI - def_bool y -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -index 053fc2f465df..ff5566c69f7d 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -@@ -710,9 +710,9 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev); - void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); - int amdgpu_gart_init(struct amdgpu_device *adev); - void amdgpu_gart_fini(struct amdgpu_device *adev); --void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, -+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, - int pages); --int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, -+int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, - int pages, struct page **pagelist, - dma_addr_t *dma_addr, uint32_t flags); - -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -index 0aaa457a1710..51a9942cdb40 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c -@@ -331,6 +331,19 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device * - (le16_to_cpu(path->usConnObjectId) & - OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; - -+ /* Skip TV/CV support */ -+ if ((le16_to_cpu(path->usDeviceTag) == -+ ATOM_DEVICE_TV1_SUPPORT) || -+ (le16_to_cpu(path->usDeviceTag) == -+ ATOM_DEVICE_CV_SUPPORT)) -+ continue; -+ -+ if (con_obj_id >= ARRAY_SIZE(object_connector_convert)) { -+ DRM_ERROR("invalid con_obj_id %d for device tag 0x%04x\n", -+ con_obj_id, le16_to_cpu(path->usDeviceTag)); -+ continue; -+ } -+ - connector_type = - object_connector_convert[con_obj_id]; - connector_object_id = con_obj_id; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c -index 7312d729d300..22a613a95bf0 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c -@@ -221,7 +221,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev) - * Unbinds the requested pages from the gart page table and - * replaces them with the dummy page (all asics). - */ --void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, -+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, - int pages) - { - unsigned t; -@@ -269,7 +269,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, - * (all asics). - * Returns 0 for success, -EINVAL for failure. - */ --int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, -+int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, - int pages, struct page **pagelist, dma_addr_t *dma_addr, - uint32_t flags) - { -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c -index 9e25edafa721..c77a1ebfc632 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c -@@ -288,7 +288,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev) - int amdgpu_ib_ring_tests(struct amdgpu_device *adev) - { - unsigned i; -- int r; -+ int r, ret = 0; - - for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { - struct amdgpu_ring *ring = adev->rings[i]; -@@ -309,10 +309,11 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) - } else { - /* still not good, but we can live with it */ - DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r); -+ ret = r; - } - } - } -- return 0; -+ return ret; - } - - /* -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -index 1cbb16e15307..475c38fe9245 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -@@ -233,8 +233,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, - - adev = amdgpu_get_adev(bo->bdev); - ring = adev->mman.buffer_funcs_ring; -- old_start = old_mem->start << PAGE_SHIFT; -- new_start = new_mem->start << PAGE_SHIFT; -+ old_start = (u64)old_mem->start << PAGE_SHIFT; -+ new_start = (u64)new_mem->start << PAGE_SHIFT; - - switch (old_mem->mem_type) { - case TTM_PL_VRAM: -diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c -index 5f712ceddf08..c568293cb6c1 100644 ---- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c -+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c -@@ -52,6 +52,7 @@ static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev); - static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev); - static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev); - static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev); -+static int cik_sdma_soft_reset(void *handle); - - MODULE_FIRMWARE("radeon/bonaire_sdma.bin"); - MODULE_FIRMWARE("radeon/bonaire_sdma1.bin"); -@@ -1030,6 +1031,8 @@ static int cik_sdma_resume(void *handle) - { - struct amdgpu_device *adev = (struct amdgpu_device *)handle; - -+ cik_sdma_soft_reset(handle); -+ - return cik_sdma_hw_init(adev); - } - -diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c -index 86c7500454b4..b37fe0df743e 100644 ---- a/drivers/gpu/drm/i915/i915_gem_gtt.c -+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c -@@ -2747,6 +2747,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev) - struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; - - ppgtt->base.cleanup(&ppgtt->base); -+ kfree(ppgtt); - } - - if (drm_mm_initialized(&vm->mm)) { -diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c -index 17ae2eb26ce2..d5c06f2764f4 100644 ---- a/drivers/hwmon/iio_hwmon.c -+++ b/drivers/hwmon/iio_hwmon.c -@@ -109,24 +109,24 @@ static int iio_hwmon_probe(struct platform_device *pdev) - - switch (type) { - case IIO_VOLTAGE: -- a->dev_attr.attr.name = kasprintf(GFP_KERNEL, -- "in%d_input", -- in_i++); -+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, -+ "in%d_input", -+ in_i++); - break; - case IIO_TEMP: -- a->dev_attr.attr.name = kasprintf(GFP_KERNEL, -- "temp%d_input", -- temp_i++); -+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, -+ "temp%d_input", -+ temp_i++); - break; - case IIO_CURRENT: -- a->dev_attr.attr.name = kasprintf(GFP_KERNEL, -- "curr%d_input", -- curr_i++); -+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, -+ "curr%d_input", -+ curr_i++); - break; - case IIO_HUMIDITYRELATIVE: -- a->dev_attr.attr.name = kasprintf(GFP_KERNEL, -- "humidity%d_input", -- humidity_i++); -+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, -+ "humidity%d_input", -+ humidity_i++); - break; - default: - ret = -EINVAL; -diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c -index a0d95ff682ae..2d5ff86398d0 100644 ---- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c -+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c -@@ -215,7 +215,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[], - msg->outsize = request_len; - msg->insize = response_len; - -- result = cros_ec_cmd_xfer(bus->ec, msg); -+ result = cros_ec_cmd_xfer_status(bus->ec, msg); - if (result < 0) { - dev_err(dev, "Error transferring EC i2c message %d\n", result); - goto exit; -diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c -index 0f6f63b20263..7afd226a3321 100644 ---- a/drivers/iio/industrialio-buffer.c -+++ b/drivers/iio/industrialio-buffer.c -@@ -107,6 +107,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, - { - struct iio_dev *indio_dev = filp->private_data; - struct iio_buffer *rb = indio_dev->buffer; -+ DEFINE_WAIT_FUNC(wait, woken_wake_function); - size_t datum_size; - size_t to_wait; - int ret; -@@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, - else - to_wait = min_t(size_t, n / datum_size, rb->watermark); - -+ add_wait_queue(&rb->pollq, &wait); - do { -- ret = wait_event_interruptible(rb->pollq, -- iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)); -- if (ret) -- return ret; -+ if (!indio_dev->info) { -+ ret = -ENODEV; -+ break; -+ } - -- if (!indio_dev->info) -- return -ENODEV; -+ if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) { -+ if (signal_pending(current)) { -+ ret = -ERESTARTSYS; -+ break; -+ } -+ -+ wait_woken(&wait, TASK_INTERRUPTIBLE, -+ MAX_SCHEDULE_TIMEOUT); -+ continue; -+ } - - ret = rb->access->read_first_n(rb, n, buf); - if (ret == 0 && (filp->f_flags & O_NONBLOCK)) - ret = -EAGAIN; - } while (ret == 0); -+ remove_wait_queue(&rb->pollq, &wait); - - return ret; - } -diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c -index acc5394afb03..29485bc4221c 100644 ---- a/drivers/input/keyboard/tegra-kbc.c -+++ b/drivers/input/keyboard/tegra-kbc.c -@@ -376,7 +376,7 @@ static int tegra_kbc_start(struct tegra_kbc *kbc) - /* Reset the KBC controller to clear all previous status.*/ - reset_control_assert(kbc->rst); - udelay(100); -- reset_control_assert(kbc->rst); -+ reset_control_deassert(kbc->rst); - udelay(100); - - tegra_kbc_config_pins(kbc); -diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c -index 454195709a82..405252a884dd 100644 ---- a/drivers/input/serio/i8042.c -+++ b/drivers/input/serio/i8042.c -@@ -1277,6 +1277,7 @@ static int __init i8042_create_kbd_port(void) - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->close = i8042_port_close; -+ serio->ps2_cmd_mutex = &i8042_mutex; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); -@@ -1304,6 +1305,7 @@ static int __init i8042_create_aux_port(int idx) - serio->write = i8042_aux_write; - serio->start = i8042_start; - serio->stop = i8042_stop; -+ serio->ps2_cmd_mutex = &i8042_mutex; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - if (idx < 0) { -@@ -1373,21 +1375,6 @@ static void i8042_unregister_ports(void) - } - } - --/* -- * Checks whether port belongs to i8042 controller. -- */ --bool i8042_check_port_owner(const struct serio *port) --{ -- int i; -- -- for (i = 0; i < I8042_NUM_PORTS; i++) -- if (i8042_ports[i].serio == port) -- return true; -- -- return false; --} --EXPORT_SYMBOL(i8042_check_port_owner); -- - static void i8042_free_irqs(void) - { - if (i8042_aux_irq_registered) -diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c -index 316f2c897101..83e9c663aa67 100644 ---- a/drivers/input/serio/libps2.c -+++ b/drivers/input/serio/libps2.c -@@ -56,19 +56,17 @@ EXPORT_SYMBOL(ps2_sendbyte); - - void ps2_begin_command(struct ps2dev *ps2dev) - { -- mutex_lock(&ps2dev->cmd_mutex); -+ struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex; - -- if (i8042_check_port_owner(ps2dev->serio)) -- i8042_lock_chip(); -+ mutex_lock(m); - } - EXPORT_SYMBOL(ps2_begin_command); - - void ps2_end_command(struct ps2dev *ps2dev) - { -- if (i8042_check_port_owner(ps2dev->serio)) -- i8042_unlock_chip(); -+ struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex; - -- mutex_unlock(&ps2dev->cmd_mutex); -+ mutex_unlock(m); - } - EXPORT_SYMBOL(ps2_end_command); - -diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c -index 8487987458a1..00df3832faab 100644 ---- a/drivers/iommu/arm-smmu-v3.c -+++ b/drivers/iommu/arm-smmu-v3.c -@@ -870,7 +870,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu) - * We may have concurrent producers, so we need to be careful - * not to touch any of the shadow cmdq state. - */ -- queue_read(cmd, Q_ENT(q, idx), q->ent_dwords); -+ queue_read(cmd, Q_ENT(q, cons), q->ent_dwords); - dev_err(smmu->dev, "skipping command in error state:\n"); - for (i = 0; i < ARRAY_SIZE(cmd); ++i) - dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]); -@@ -881,7 +881,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu) - return; - } - -- queue_write(cmd, Q_ENT(q, idx), q->ent_dwords); -+ queue_write(Q_ENT(q, cons), cmd, q->ent_dwords); - } - - static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, -@@ -1025,6 +1025,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, - case STRTAB_STE_0_CFG_S2_TRANS: - ste_live = true; - break; -+ case STRTAB_STE_0_CFG_ABORT: -+ if (disable_bypass) -+ break; - default: - BUG(); /* STE corruption */ - } -diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c -index 58f2fe687a24..347a3c17f73a 100644 ---- a/drivers/iommu/dma-iommu.c -+++ b/drivers/iommu/dma-iommu.c -@@ -68,7 +68,8 @@ void iommu_put_dma_cookie(struct iommu_domain *domain) - if (!iovad) - return; - -- put_iova_domain(iovad); -+ if (iovad->granule) -+ put_iova_domain(iovad); - kfree(iovad); - domain->iova_cookie = NULL; - } -diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig -index 1dee533634c9..2e6d2fff1096 100644 ---- a/drivers/mmc/host/Kconfig -+++ b/drivers/mmc/host/Kconfig -@@ -97,6 +97,7 @@ config MMC_RICOH_MMC - config MMC_SDHCI_ACPI - tristate "SDHCI support for ACPI enumerated SDHCI controllers" - depends on MMC_SDHCI && ACPI -+ select IOSF_MBI if X86 - help - This selects support for ACPI enumerated SDHCI controllers, - identified by ACPI Compatibility ID PNP0D40 or specific -diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c -index 8aea3fa6938b..5a05bf400ca8 100644 ---- a/drivers/mmc/host/sdhci-acpi.c -+++ b/drivers/mmc/host/sdhci-acpi.c -@@ -41,6 +41,11 @@ - #include - #include - -+#ifdef CONFIG_X86 -+#include -+#include -+#endif -+ - #include "sdhci.h" - - enum { -@@ -146,6 +151,75 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = { - .ops = &sdhci_acpi_ops_int, - }; - -+#ifdef CONFIG_X86 -+ -+static bool sdhci_acpi_byt(void) -+{ -+ static const struct x86_cpu_id byt[] = { -+ { X86_VENDOR_INTEL, 6, 0x37 }, -+ {} -+ }; -+ -+ return x86_match_cpu(byt); -+} -+ -+#define BYT_IOSF_SCCEP 0x63 -+#define BYT_IOSF_OCP_NETCTRL0 0x1078 -+#define BYT_IOSF_OCP_TIMEOUT_BASE GENMASK(10, 8) -+ -+static void sdhci_acpi_byt_setting(struct device *dev) -+{ -+ u32 val = 0; -+ -+ if (!sdhci_acpi_byt()) -+ return; -+ -+ if (iosf_mbi_read(BYT_IOSF_SCCEP, 0x06, BYT_IOSF_OCP_NETCTRL0, -+ &val)) { -+ dev_err(dev, "%s read error\n", __func__); -+ return; -+ } -+ -+ if (!(val & BYT_IOSF_OCP_TIMEOUT_BASE)) -+ return; -+ -+ val &= ~BYT_IOSF_OCP_TIMEOUT_BASE; -+ -+ if (iosf_mbi_write(BYT_IOSF_SCCEP, 0x07, BYT_IOSF_OCP_NETCTRL0, -+ val)) { -+ dev_err(dev, "%s write error\n", __func__); -+ return; -+ } -+ -+ dev_dbg(dev, "%s completed\n", __func__); -+} -+ -+static bool sdhci_acpi_byt_defer(struct device *dev) -+{ -+ if (!sdhci_acpi_byt()) -+ return false; -+ -+ if (!iosf_mbi_available()) -+ return true; -+ -+ sdhci_acpi_byt_setting(dev); -+ -+ return false; -+} -+ -+#else -+ -+static inline void sdhci_acpi_byt_setting(struct device *dev) -+{ -+} -+ -+static inline bool sdhci_acpi_byt_defer(struct device *dev) -+{ -+ return false; -+} -+ -+#endif -+ - static int bxt_get_cd(struct mmc_host *mmc) - { - int gpio_cd = mmc_gpio_get_cd(mmc); -@@ -337,6 +411,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev) - if (acpi_bus_get_status(device) || !device->status.present) - return -ENODEV; - -+ if (sdhci_acpi_byt_defer(dev)) -+ return -EPROBE_DEFER; -+ - hid = acpi_device_hid(device); - uid = device->pnp.unique_id; - -@@ -460,6 +537,8 @@ static int sdhci_acpi_resume(struct device *dev) - { - struct sdhci_acpi_host *c = dev_get_drvdata(dev); - -+ sdhci_acpi_byt_setting(&c->pdev->dev); -+ - return sdhci_resume_host(c->host); - } - -@@ -483,6 +562,8 @@ static int sdhci_acpi_runtime_resume(struct device *dev) - { - struct sdhci_acpi_host *c = dev_get_drvdata(dev); - -+ sdhci_acpi_byt_setting(&c->pdev->dev); -+ - return sdhci_runtime_resume_host(c->host); - } - -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index 0c67b57be83c..289a5df0d44a 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -2672,10 +2672,10 @@ static int nvme_dev_add(struct nvme_dev *dev) - return 0; - } - --static int nvme_dev_map(struct nvme_dev *dev) -+static int nvme_pci_enable(struct nvme_dev *dev) - { - u64 cap; -- int bars, result = -ENOMEM; -+ int result = -ENOMEM; - struct pci_dev *pdev = to_pci_dev(dev->dev); - - if (pci_enable_device_mem(pdev)) -@@ -2683,24 +2683,14 @@ static int nvme_dev_map(struct nvme_dev *dev) - - dev->entry[0].vector = pdev->irq; - pci_set_master(pdev); -- bars = pci_select_bars(pdev, IORESOURCE_MEM); -- if (!bars) -- goto disable_pci; -- -- if (pci_request_selected_regions(pdev, bars, "nvme")) -- goto disable_pci; - - if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) && - dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32))) - goto disable; - -- dev->bar = ioremap(pci_resource_start(pdev, 0), 8192); -- if (!dev->bar) -- goto disable; -- - if (readl(&dev->bar->csts) == -1) { - result = -ENODEV; -- goto unmap; -+ goto disable; - } - - /* -@@ -2710,7 +2700,7 @@ static int nvme_dev_map(struct nvme_dev *dev) - if (!pdev->irq) { - result = pci_enable_msix(pdev, dev->entry, 1); - if (result < 0) -- goto unmap; -+ goto disable; - } - - cap = lo_hi_readq(&dev->bar->cap); -@@ -2734,18 +2724,21 @@ static int nvme_dev_map(struct nvme_dev *dev) - - return 0; - -- unmap: -- iounmap(dev->bar); -- dev->bar = NULL; - disable: - pci_release_regions(pdev); -- disable_pci: -- pci_disable_device(pdev); -+ - return result; - } - - static void nvme_dev_unmap(struct nvme_dev *dev) - { -+ if (dev->bar) -+ iounmap(dev->bar); -+ pci_release_regions(to_pci_dev(dev->dev)); -+} -+ -+static void nvme_pci_disable(struct nvme_dev *dev) -+{ - struct pci_dev *pdev = to_pci_dev(dev->dev); - - if (pdev->msi_enabled) -@@ -2753,12 +2746,6 @@ static void nvme_dev_unmap(struct nvme_dev *dev) - else if (pdev->msix_enabled) - pci_disable_msix(pdev); - -- if (dev->bar) { -- iounmap(dev->bar); -- dev->bar = NULL; -- pci_release_regions(pdev); -- } -- - if (pci_is_enabled(pdev)) - pci_disable_device(pdev); - } -@@ -2962,7 +2949,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev) - - nvme_dev_list_remove(dev); - -- if (dev->bar) { -+ if (pci_is_enabled(to_pci_dev(dev->dev))) { - nvme_freeze_queues(dev); - csts = readl(&dev->bar->csts); - } -@@ -2976,7 +2963,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev) - nvme_shutdown_ctrl(dev); - nvme_disable_queue(dev, 0); - } -- nvme_dev_unmap(dev); -+ nvme_pci_disable(dev); - - for (i = dev->queue_count - 1; i >= 0; i--) - nvme_clear_queue(dev->queues[i]); -@@ -3136,7 +3123,7 @@ static void nvme_probe_work(struct work_struct *work) - bool start_thread = false; - int result; - -- result = nvme_dev_map(dev); -+ result = nvme_pci_enable(dev); - if (result) - goto out; - -@@ -3292,6 +3279,27 @@ static ssize_t nvme_sysfs_reset(struct device *dev, - } - static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset); - -+static int nvme_dev_map(struct nvme_dev *dev) -+{ -+ int bars; -+ struct pci_dev *pdev = to_pci_dev(dev->dev); -+ -+ bars = pci_select_bars(pdev, IORESOURCE_MEM); -+ if (!bars) -+ return -ENODEV; -+ if (pci_request_selected_regions(pdev, bars, "nvme")) -+ return -ENODEV; -+ -+ dev->bar = ioremap(pci_resource_start(pdev, 0), 8192); -+ if (!dev->bar) -+ goto release; -+ -+ return 0; -+release: -+ pci_release_regions(pdev); -+ return -ENODEV; -+} -+ - static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) - { - int node, result = -ENOMEM; -@@ -3317,6 +3325,11 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) - INIT_WORK(&dev->reset_work, nvme_reset_work); - dev->dev = get_device(&pdev->dev); - pci_set_drvdata(pdev, dev); -+ -+ result = nvme_dev_map(dev); -+ if (result) -+ goto free; -+ - result = nvme_set_instance(dev); - if (result) - goto put_pci; -@@ -3355,6 +3368,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) - nvme_release_instance(dev); - put_pci: - put_device(dev->dev); -+ nvme_dev_unmap(dev); - free: - kfree(dev->queues); - kfree(dev->entry); -@@ -3398,6 +3412,7 @@ static void nvme_remove(struct pci_dev *pdev) - nvme_free_queues(dev, 0); - nvme_release_cmb(dev); - nvme_release_prp_pools(dev); -+ nvme_dev_unmap(dev); - kref_put(&dev->kref, nvme_free_dev); - } - -diff --git a/drivers/of/base.c b/drivers/of/base.c -index 942461f36616..31341290cd91 100644 ---- a/drivers/of/base.c -+++ b/drivers/of/base.c -@@ -2253,20 +2253,13 @@ struct device_node *of_graph_get_endpoint_by_regs( - const struct device_node *parent, int port_reg, int reg) - { - struct of_endpoint endpoint; -- struct device_node *node, *prev_node = NULL; -- -- while (1) { -- node = of_graph_get_next_endpoint(parent, prev_node); -- of_node_put(prev_node); -- if (!node) -- break; -+ struct device_node *node = NULL; - -+ for_each_endpoint_of_node(parent, node) { - of_graph_parse_endpoint(node, &endpoint); - if (((port_reg == -1) || (endpoint.port == port_reg)) && - ((reg == -1) || (endpoint.id == reg))) - return node; -- -- prev_node = node; - } - - return NULL; -diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c -index 7eaa4c87fec7..10a6a8e5db88 100644 ---- a/drivers/pci/msi.c -+++ b/drivers/pci/msi.c -@@ -1278,6 +1278,8 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode, - if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) - pci_msi_domain_update_chip_ops(info); - -+ info->flags |= MSI_FLAG_ACTIVATE_EARLY; -+ - domain = msi_create_irq_domain(fwnode, info, parent); - if (!domain) - return NULL; -diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c -index eead54cd01b2..d7508704c992 100644 ---- a/drivers/pci/pci-sysfs.c -+++ b/drivers/pci/pci-sysfs.c -@@ -1372,10 +1372,10 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) - if (!sysfs_initialized) - return -EACCES; - -- if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) -- retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); -- else -+ if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) - retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); -+ else -+ retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); - if (retval) - goto err; - -@@ -1427,10 +1427,10 @@ err_rom_file: - err_resource_files: - pci_remove_resource_files(pdev); - err_config_file: -- if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) -- sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); -- else -+ if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) - sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); -+ else -+ sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); - err: - return retval; - } -@@ -1464,10 +1464,10 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) - - pci_remove_capabilities_sysfs(pdev); - -- if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) -- sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); -- else -+ if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) - sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); -+ else -+ sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); - - pci_remove_resource_files(pdev); - -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index 3c4752a288e2..42774bc39786 100644 ---- a/drivers/pci/quirks.c -+++ b/drivers/pci/quirks.c -@@ -287,6 +287,18 @@ static void quirk_citrine(struct pci_dev *dev) - } - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine); - -+/* -+ * This chip can cause bus lockups if config addresses above 0x600 -+ * are read or written. -+ */ -+static void quirk_nfp6000(struct pci_dev *dev) -+{ -+ dev->cfg_size = 0x600; -+} -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP4000, quirk_nfp6000); -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000, quirk_nfp6000); -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000_VF, quirk_nfp6000); -+ - /* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */ - static void quirk_extend_bar_to_page(struct pci_dev *dev) - { -diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c -index 3318f1d6193c..7340ff78839a 100644 ---- a/drivers/pinctrl/pinctrl-amd.c -+++ b/drivers/pinctrl/pinctrl-amd.c -@@ -48,17 +48,6 @@ static int amd_gpio_direction_input(struct gpio_chip *gc, unsigned offset) - - spin_lock_irqsave(&gpio_dev->lock, flags); - pin_reg = readl(gpio_dev->base + offset * 4); -- /* -- * Suppose BIOS or Bootloader sets specific debounce for the -- * GPIO. if not, set debounce to be 2.75ms and remove glitch. -- */ -- if ((pin_reg & DB_TMR_OUT_MASK) == 0) { -- pin_reg |= 0xf; -- pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF); -- pin_reg |= DB_TYPE_REMOVE_GLITCH << DB_CNTRL_OFF; -- pin_reg &= ~BIT(DB_TMR_LARGE_OFF); -- } -- - pin_reg &= ~BIT(OUTPUT_ENABLE_OFF); - writel(pin_reg, gpio_dev->base + offset * 4); - spin_unlock_irqrestore(&gpio_dev->lock, flags); -@@ -331,15 +320,6 @@ static void amd_gpio_irq_enable(struct irq_data *d) - - spin_lock_irqsave(&gpio_dev->lock, flags); - pin_reg = readl(gpio_dev->base + (d->hwirq)*4); -- /* -- Suppose BIOS or Bootloader sets specific debounce for the -- GPIO. if not, set debounce to be 2.75ms. -- */ -- if ((pin_reg & DB_TMR_OUT_MASK) == 0) { -- pin_reg |= 0xf; -- pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF); -- pin_reg &= ~BIT(DB_TMR_LARGE_OFF); -- } - pin_reg |= BIT(INTERRUPT_ENABLE_OFF); - pin_reg |= BIT(INTERRUPT_MASK_OFF); - writel(pin_reg, gpio_dev->base + (d->hwirq)*4); -diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c -index 990308ca384f..92430f781eb7 100644 ---- a/drivers/platform/chrome/cros_ec_proto.c -+++ b/drivers/platform/chrome/cros_ec_proto.c -@@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, - return ret; - } - EXPORT_SYMBOL(cros_ec_cmd_xfer); -+ -+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, -+ struct cros_ec_command *msg) -+{ -+ int ret; -+ -+ ret = cros_ec_cmd_xfer(ec_dev, msg); -+ if (ret < 0) { -+ dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret); -+ } else if (msg->result != EC_RES_SUCCESS) { -+ dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result); -+ return -EPROTO; -+ } -+ -+ return ret; -+} -+EXPORT_SYMBOL(cros_ec_cmd_xfer_status); -diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c -index 4abfbdb285ec..84c13dffa3a8 100644 ---- a/drivers/s390/block/dasd.c -+++ b/drivers/s390/block/dasd.c -@@ -1584,9 +1584,18 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, - unsigned long long now; - int expires; - -+ cqr = (struct dasd_ccw_req *) intparm; - if (IS_ERR(irb)) { - switch (PTR_ERR(irb)) { - case -EIO: -+ if (cqr && cqr->status == DASD_CQR_CLEAR_PENDING) { -+ device = (struct dasd_device *) cqr->startdev; -+ cqr->status = DASD_CQR_CLEARED; -+ dasd_device_clear_timer(device); -+ wake_up(&dasd_flush_wq); -+ dasd_schedule_device_bh(device); -+ return; -+ } - break; - case -ETIMEDOUT: - DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " -@@ -1602,7 +1611,6 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, - } - - now = get_tod_clock(); -- cqr = (struct dasd_ccw_req *) intparm; - /* check for conditions that should be handled immediately */ - if (!cqr || - !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && -diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c -index 54195a117f72..f78cc943d230 100644 ---- a/drivers/scsi/aacraid/commctrl.c -+++ b/drivers/scsi/aacraid/commctrl.c -@@ -63,7 +63,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) - struct fib *fibptr; - struct hw_fib * hw_fib = (struct hw_fib *)0; - dma_addr_t hw_fib_pa = (dma_addr_t)0LL; -- unsigned size; -+ unsigned int size, osize; - int retval; - - if (dev->in_reset) { -@@ -87,7 +87,8 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) - * will not overrun the buffer when we copy the memory. Return - * an error if we would. - */ -- size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr); -+ osize = size = le16_to_cpu(kfib->header.Size) + -+ sizeof(struct aac_fibhdr); - if (size < le16_to_cpu(kfib->header.SenderSize)) - size = le16_to_cpu(kfib->header.SenderSize); - if (size > dev->max_fib_size) { -@@ -118,6 +119,14 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) - goto cleanup; - } - -+ /* Sanity check the second copy */ -+ if ((osize != le16_to_cpu(kfib->header.Size) + -+ sizeof(struct aac_fibhdr)) -+ || (size < le16_to_cpu(kfib->header.SenderSize))) { -+ retval = -EINVAL; -+ goto cleanup; -+ } -+ - if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) { - aac_adapter_interrupt(dev); - /* -diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c -index 00ce3e269a43..e994ff944091 100644 ---- a/drivers/scsi/megaraid/megaraid_sas_base.c -+++ b/drivers/scsi/megaraid/megaraid_sas_base.c -@@ -4669,7 +4669,7 @@ static int megasas_init_fw(struct megasas_instance *instance) - /* Find first memory bar */ - bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); - instance->bar = find_first_bit(&bar_list, sizeof(unsigned long)); -- if (pci_request_selected_regions(instance->pdev, instance->bar, -+ if (pci_request_selected_regions(instance->pdev, 1<bar, - "megasas: LSI")) { - dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n"); - return -EBUSY; -@@ -4960,7 +4960,7 @@ fail_ready_state: - iounmap(instance->reg_set); - - fail_ioremap: -- pci_release_selected_regions(instance->pdev, instance->bar); -+ pci_release_selected_regions(instance->pdev, 1<bar); - - return -EINVAL; - } -@@ -4981,7 +4981,7 @@ static void megasas_release_mfi(struct megasas_instance *instance) - - iounmap(instance->reg_set); - -- pci_release_selected_regions(instance->pdev, instance->bar); -+ pci_release_selected_regions(instance->pdev, 1<bar); - } - - /** -diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c -index 8d630a552b07..4f391e747be2 100644 ---- a/drivers/scsi/megaraid/megaraid_sas_fusion.c -+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c -@@ -2437,7 +2437,7 @@ megasas_release_fusion(struct megasas_instance *instance) - - iounmap(instance->reg_set); - -- pci_release_selected_regions(instance->pdev, instance->bar); -+ pci_release_selected_regions(instance->pdev, 1<bar); - } - - /** -diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c -index 11393ebf1a68..356233f86064 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_base.c -+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c -@@ -2155,6 +2155,17 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) - } else - ioc->msix96_vector = 0; - -+ if (ioc->is_warpdrive) { -+ ioc->reply_post_host_index[0] = (resource_size_t __iomem *) -+ &ioc->chip->ReplyPostHostIndex; -+ -+ for (i = 1; i < ioc->cpu_msix_table_sz; i++) -+ ioc->reply_post_host_index[i] = -+ (resource_size_t __iomem *) -+ ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1) -+ * 4))); -+ } -+ - list_for_each_entry(reply_q, &ioc->reply_queue_list, list) - pr_info(MPT3SAS_FMT "%s: IRQ %d\n", - reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" : -@@ -5201,17 +5212,6 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) - if (r) - goto out_free_resources; - -- if (ioc->is_warpdrive) { -- ioc->reply_post_host_index[0] = (resource_size_t __iomem *) -- &ioc->chip->ReplyPostHostIndex; -- -- for (i = 1; i < ioc->cpu_msix_table_sz; i++) -- ioc->reply_post_host_index[i] = -- (resource_size_t __iomem *) -- ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1) -- * 4))); -- } -- - pci_set_drvdata(ioc->pdev, ioc->shost); - r = _base_get_ioc_facts(ioc, CAN_SLEEP); - if (r) -diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c -index 4ab186669f0c..ec5b9a23494d 100644 ---- a/drivers/staging/comedi/drivers/comedi_test.c -+++ b/drivers/staging/comedi/drivers/comedi_test.c -@@ -56,11 +56,6 @@ - - #define N_CHANS 8 - --enum waveform_state_bits { -- WAVEFORM_AI_RUNNING, -- WAVEFORM_AO_RUNNING --}; -- - /* Data unique to this driver */ - struct waveform_private { - struct timer_list ai_timer; /* timer for AI commands */ -@@ -68,7 +63,6 @@ struct waveform_private { - unsigned int wf_amplitude; /* waveform amplitude in microvolts */ - unsigned int wf_period; /* waveform period in microseconds */ - unsigned int wf_current; /* current time in waveform period */ -- unsigned long state_bits; - unsigned int ai_scan_period; /* AI scan period in usec */ - unsigned int ai_convert_period; /* AI conversion period in usec */ - struct timer_list ao_timer; /* timer for AO commands */ -@@ -191,10 +185,6 @@ static void waveform_ai_timer(unsigned long arg) - unsigned int nsamples; - unsigned int time_increment; - -- /* check command is still active */ -- if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits)) -- return; -- - now = ktime_to_us(ktime_get()); - nsamples = comedi_nsamples_left(s, UINT_MAX); - -@@ -386,11 +376,6 @@ static int waveform_ai_cmd(struct comedi_device *dev, - */ - devpriv->ai_timer.expires = - jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1; -- -- /* mark command as active */ -- smp_mb__before_atomic(); -- set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); -- smp_mb__after_atomic(); - add_timer(&devpriv->ai_timer); - return 0; - } -@@ -400,11 +385,12 @@ static int waveform_ai_cancel(struct comedi_device *dev, - { - struct waveform_private *devpriv = dev->private; - -- /* mark command as no longer active */ -- clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); -- smp_mb__after_atomic(); -- /* cannot call del_timer_sync() as may be called from timer routine */ -- del_timer(&devpriv->ai_timer); -+ if (in_softirq()) { -+ /* Assume we were called from the timer routine itself. */ -+ del_timer(&devpriv->ai_timer); -+ } else { -+ del_timer_sync(&devpriv->ai_timer); -+ } - return 0; - } - -@@ -436,10 +422,6 @@ static void waveform_ao_timer(unsigned long arg) - u64 scans_since; - unsigned int scans_avail = 0; - -- /* check command is still active */ -- if (!test_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits)) -- return; -- - /* determine number of scan periods since last time */ - now = ktime_to_us(ktime_get()); - scans_since = now - devpriv->ao_last_scan_time; -@@ -518,11 +500,6 @@ static int waveform_ao_inttrig_start(struct comedi_device *dev, - devpriv->ao_last_scan_time = ktime_to_us(ktime_get()); - devpriv->ao_timer.expires = - jiffies + usecs_to_jiffies(devpriv->ao_scan_period); -- -- /* mark command as active */ -- smp_mb__before_atomic(); -- set_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits); -- smp_mb__after_atomic(); - add_timer(&devpriv->ao_timer); - - return 1; -@@ -608,11 +585,12 @@ static int waveform_ao_cancel(struct comedi_device *dev, - struct waveform_private *devpriv = dev->private; - - s->async->inttrig = NULL; -- /* mark command as no longer active */ -- clear_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits); -- smp_mb__after_atomic(); -- /* cannot call del_timer_sync() as may be called from timer routine */ -- del_timer(&devpriv->ao_timer); -+ if (in_softirq()) { -+ /* Assume we were called from the timer routine itself. */ -+ del_timer(&devpriv->ao_timer); -+ } else { -+ del_timer_sync(&devpriv->ao_timer); -+ } - return 0; - } - -diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c -index 57ab6680e3ae..e5fee6e0fb47 100644 ---- a/drivers/staging/comedi/drivers/daqboard2000.c -+++ b/drivers/staging/comedi/drivers/daqboard2000.c -@@ -636,7 +636,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev, - const struct daq200_boardtype *board; - int i; - -- if (pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH) -+ if (pcidev->subsystem_vendor != PCI_VENDOR_ID_IOTECH) - return NULL; - - for (i = 0; i < ARRAY_SIZE(boardtypes); i++) { -diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c -index 27fbf1a81097..35ab4a9ef95d 100644 ---- a/drivers/staging/comedi/drivers/ni_mio_common.c -+++ b/drivers/staging/comedi/drivers/ni_mio_common.c -@@ -2823,7 +2823,15 @@ static int ni_ao_inttrig(struct comedi_device *dev, - int i; - static const int timeout = 1000; - -- if (trig_num != cmd->start_arg) -+ /* -+ * Require trig_num == cmd->start_arg when cmd->start_src == TRIG_INT. -+ * For backwards compatibility, also allow trig_num == 0 when -+ * cmd->start_src != TRIG_INT (i.e. when cmd->start_src == TRIG_EXT); -+ * in that case, the internal trigger is being used as a pre-trigger -+ * before the external trigger. -+ */ -+ if (!(trig_num == cmd->start_arg || -+ (trig_num == 0 && cmd->start_src != TRIG_INT))) - return -EINVAL; - - /* Null trig at beginning prevent ao start trigger from executing more than -@@ -5346,7 +5354,7 @@ static int ni_E_init(struct comedi_device *dev, - s->maxdata = (devpriv->is_m_series) ? 0xffffffff - : 0x00ffffff; - s->insn_read = ni_tio_insn_read; -- s->insn_write = ni_tio_insn_read; -+ s->insn_write = ni_tio_insn_write; - s->insn_config = ni_tio_insn_config; - #ifdef PCIDMA - if (dev->irq && devpriv->mite) { -diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c -index 391a1225b0ba..ca367b05e440 100644 ---- a/drivers/usb/chipidea/udc.c -+++ b/drivers/usb/chipidea/udc.c -@@ -1585,8 +1585,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) - { - struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); - -- /* Data+ pullup controlled by OTG state machine in OTG fsm mode */ -- if (ci_otg_is_fsm_mode(ci)) -+ /* -+ * Data+ pullup controlled by OTG state machine in OTG fsm mode; -+ * and don't touch Data+ in host mode for dual role config. -+ */ -+ if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST) - return 0; - - pm_runtime_get_sync(&ci->gadget.dev); -diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c -index d37fdcc3143c..7f374369e539 100644 ---- a/drivers/usb/class/cdc-acm.c -+++ b/drivers/usb/class/cdc-acm.c -@@ -1336,7 +1336,6 @@ made_compressed_probe: - spin_lock_init(&acm->write_lock); - spin_lock_init(&acm->read_lock); - mutex_init(&acm->mutex); -- acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); - acm->is_int_ep = usb_endpoint_xfer_int(epread); - if (acm->is_int_ep) - acm->bInterval = epread->bInterval; -@@ -1376,14 +1375,14 @@ made_compressed_probe: - urb->transfer_dma = rb->dma; - if (acm->is_int_ep) { - usb_fill_int_urb(urb, acm->dev, -- acm->rx_endpoint, -+ usb_rcvintpipe(usb_dev, epread->bEndpointAddress), - rb->base, - acm->readsize, - acm_read_bulk_callback, rb, - acm->bInterval); - } else { - usb_fill_bulk_urb(urb, acm->dev, -- acm->rx_endpoint, -+ usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress), - rb->base, - acm->readsize, - acm_read_bulk_callback, rb); -diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h -index ccfaba9ab4e4..b30ac5fcde68 100644 ---- a/drivers/usb/class/cdc-acm.h -+++ b/drivers/usb/class/cdc-acm.h -@@ -95,7 +95,6 @@ struct acm { - struct urb *read_urbs[ACM_NR]; - struct acm_rb read_buffers[ACM_NR]; - int rx_buflimit; -- int rx_endpoint; - spinlock_t read_lock; - int write_used; /* number of non-empty write buffers */ - int transmitting; -diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c -index 673d53038ed2..a00bfb93acc3 100644 ---- a/drivers/usb/common/common.c -+++ b/drivers/usb/common/common.c -@@ -50,6 +50,7 @@ static const char *const speed_names[] = { - [USB_SPEED_HIGH] = "high-speed", - [USB_SPEED_WIRELESS] = "wireless", - [USB_SPEED_SUPER] = "super-speed", -+ [USB_SPEED_SUPER_PLUS] = "super-speed-plus", - }; - - const char *usb_speed_string(enum usb_device_speed speed) -diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c -index 5050760f5e17..80c8d90d8b75 100644 ---- a/drivers/usb/core/config.c -+++ b/drivers/usb/core/config.c -@@ -142,6 +142,31 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno, - } - } - -+static const unsigned short low_speed_maxpacket_maxes[4] = { -+ [USB_ENDPOINT_XFER_CONTROL] = 8, -+ [USB_ENDPOINT_XFER_ISOC] = 0, -+ [USB_ENDPOINT_XFER_BULK] = 0, -+ [USB_ENDPOINT_XFER_INT] = 8, -+}; -+static const unsigned short full_speed_maxpacket_maxes[4] = { -+ [USB_ENDPOINT_XFER_CONTROL] = 64, -+ [USB_ENDPOINT_XFER_ISOC] = 1023, -+ [USB_ENDPOINT_XFER_BULK] = 64, -+ [USB_ENDPOINT_XFER_INT] = 64, -+}; -+static const unsigned short high_speed_maxpacket_maxes[4] = { -+ [USB_ENDPOINT_XFER_CONTROL] = 64, -+ [USB_ENDPOINT_XFER_ISOC] = 1024, -+ [USB_ENDPOINT_XFER_BULK] = 512, -+ [USB_ENDPOINT_XFER_INT] = 1024, -+}; -+static const unsigned short super_speed_maxpacket_maxes[4] = { -+ [USB_ENDPOINT_XFER_CONTROL] = 512, -+ [USB_ENDPOINT_XFER_ISOC] = 1024, -+ [USB_ENDPOINT_XFER_BULK] = 1024, -+ [USB_ENDPOINT_XFER_INT] = 1024, -+}; -+ - static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - int asnum, struct usb_host_interface *ifp, int num_ep, - unsigned char *buffer, int size) -@@ -150,6 +175,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - struct usb_endpoint_descriptor *d; - struct usb_host_endpoint *endpoint; - int n, i, j, retval; -+ unsigned int maxp; -+ const unsigned short *maxpacket_maxes; - - d = (struct usb_endpoint_descriptor *) buffer; - buffer += d->bLength; -@@ -191,6 +218,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - if (usb_endpoint_xfer_int(d)) { - i = 1; - switch (to_usb_device(ddev)->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - case USB_SPEED_HIGH: - /* Many device manufacturers are using full-speed -@@ -256,6 +284,42 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - endpoint->desc.wMaxPacketSize = cpu_to_le16(8); - } - -+ /* Validate the wMaxPacketSize field */ -+ maxp = usb_endpoint_maxp(&endpoint->desc); -+ -+ /* Find the highest legal maxpacket size for this endpoint */ -+ i = 0; /* additional transactions per microframe */ -+ switch (to_usb_device(ddev)->speed) { -+ case USB_SPEED_LOW: -+ maxpacket_maxes = low_speed_maxpacket_maxes; -+ break; -+ case USB_SPEED_FULL: -+ maxpacket_maxes = full_speed_maxpacket_maxes; -+ break; -+ case USB_SPEED_HIGH: -+ /* Bits 12..11 are allowed only for HS periodic endpoints */ -+ if (usb_endpoint_xfer_int(d) || usb_endpoint_xfer_isoc(d)) { -+ i = maxp & (BIT(12) | BIT(11)); -+ maxp &= ~i; -+ } -+ /* fallthrough */ -+ default: -+ maxpacket_maxes = high_speed_maxpacket_maxes; -+ break; -+ case USB_SPEED_SUPER: -+ case USB_SPEED_SUPER_PLUS: -+ maxpacket_maxes = super_speed_maxpacket_maxes; -+ break; -+ } -+ j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)]; -+ -+ if (maxp > j) { -+ dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n", -+ cfgno, inum, asnum, d->bEndpointAddress, maxp, j); -+ maxp = j; -+ endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp); -+ } -+ - /* - * Some buggy high speed devices have bulk endpoints using - * maxpacket sizes other than 512. High speed HCDs may not -@@ -263,9 +327,6 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - */ - if (to_usb_device(ddev)->speed == USB_SPEED_HIGH - && usb_endpoint_xfer_bulk(d)) { -- unsigned maxp; -- -- maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff; - if (maxp != 512) - dev_warn(ddev, "config %d interface %d altsetting %d " - "bulk endpoint 0x%X has invalid maxpacket %d\n", -@@ -274,7 +335,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - } - - /* Parse a possible SuperSpeed endpoint companion descriptor */ -- if (to_usb_device(ddev)->speed == USB_SPEED_SUPER) -+ if (to_usb_device(ddev)->speed >= USB_SPEED_SUPER) - usb_parse_ss_endpoint_companion(ddev, cfgno, - inum, asnum, endpoint, buffer, size); - -diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c -index 2a3bbdf7eb94..332ed277a06c 100644 ---- a/drivers/usb/core/devices.c -+++ b/drivers/usb/core/devices.c -@@ -221,7 +221,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, - break; - case USB_ENDPOINT_XFER_INT: - type = "Int."; -- if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER) -+ if (speed == USB_SPEED_HIGH || speed >= USB_SPEED_SUPER) - interval = 1 << (desc->bInterval - 1); - else - interval = desc->bInterval; -@@ -230,7 +230,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, - return start; - } - interval *= (speed == USB_SPEED_HIGH || -- speed == USB_SPEED_SUPER) ? 125 : 1000; -+ speed >= USB_SPEED_SUPER) ? 125 : 1000; - if (interval % 1000) - unit = 'u'; - else { -@@ -322,7 +322,7 @@ static char *usb_dump_config_descriptor(char *start, char *end, - - if (start > end) - return start; -- if (speed == USB_SPEED_SUPER) -+ if (speed >= USB_SPEED_SUPER) - mul = 8; - else - mul = 2; -@@ -534,6 +534,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, - speed = "480"; break; - case USB_SPEED_SUPER: - speed = "5000"; break; -+ case USB_SPEED_SUPER_PLUS: -+ speed = "10000"; break; - default: - speed = "??"; - } -@@ -553,7 +555,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, - - /* super/high speed reserves 80%, full/low reserves 90% */ - if (usbdev->speed == USB_SPEED_HIGH || -- usbdev->speed == USB_SPEED_SUPER) -+ usbdev->speed >= USB_SPEED_SUPER) - max = 800; - else - max = FRAME_TIME_MAX_USECS_ALLOC; -diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c -index 3ffb01ff6549..f5c92d904ded 100644 ---- a/drivers/usb/core/devio.c -+++ b/drivers/usb/core/devio.c -@@ -1530,11 +1530,17 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb - as->urb->start_frame = uurb->start_frame; - as->urb->number_of_packets = number_of_packets; - as->urb->stream_id = stream_id; -- if (uurb->type == USBDEVFS_URB_TYPE_ISO || -- ps->dev->speed == USB_SPEED_HIGH) -- as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); -- else -- as->urb->interval = ep->desc.bInterval; -+ -+ if (ep->desc.bInterval) { -+ if (uurb->type == USBDEVFS_URB_TYPE_ISO || -+ ps->dev->speed == USB_SPEED_HIGH || -+ ps->dev->speed >= USB_SPEED_SUPER) -+ as->urb->interval = 1 << -+ min(15, ep->desc.bInterval - 1); -+ else -+ as->urb->interval = ep->desc.bInterval; -+ } -+ - as->urb->context = as; - as->urb->complete = async_completed; - for (totlen = u = 0; u < number_of_packets; u++) { -diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c -index b8b580e5ae6e..40378487e023 100644 ---- a/drivers/usb/core/hcd-pci.c -+++ b/drivers/usb/core/hcd-pci.c -@@ -206,7 +206,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) - * The xHCI driver has its own irq management - * make sure irq setup is not touched for xhci in generic hcd code - */ -- if ((driver->flags & HCD_MASK) != HCD_USB3) { -+ if ((driver->flags & HCD_MASK) < HCD_USB3) { - if (!dev->irq) { - dev_err(&dev->dev, - "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", -diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c -index 1c102d60cd9f..f44ce09367bc 100644 ---- a/drivers/usb/core/hcd.c -+++ b/drivers/usb/core/hcd.c -@@ -1078,7 +1078,7 @@ static int register_root_hub(struct usb_hcd *hcd) - retval = usb_get_bos_descriptor(usb_dev); - if (!retval) { - usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev); -- } else if (usb_dev->speed == USB_SPEED_SUPER) { -+ } else if (usb_dev->speed >= USB_SPEED_SUPER) { - mutex_unlock(&usb_bus_list_lock); - dev_dbg(parent_dev, "can't read %s bos descriptor %d\n", - dev_name(&usb_dev->dev), retval); -@@ -2112,7 +2112,7 @@ int usb_alloc_streams(struct usb_interface *interface, - hcd = bus_to_hcd(dev->bus); - if (!hcd->driver->alloc_streams || !hcd->driver->free_streams) - return -EINVAL; -- if (dev->speed != USB_SPEED_SUPER) -+ if (dev->speed < USB_SPEED_SUPER) - return -EINVAL; - if (dev->state < USB_STATE_CONFIGURED) - return -ENODEV; -@@ -2160,7 +2160,7 @@ int usb_free_streams(struct usb_interface *interface, - - dev = interface_to_usbdev(interface); - hcd = bus_to_hcd(dev->bus); -- if (dev->speed != USB_SPEED_SUPER) -+ if (dev->speed < USB_SPEED_SUPER) - return -EINVAL; - - /* Double-free is not allowed */ -diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c -index 84df093639ac..bcc1e1b729ad 100644 ---- a/drivers/usb/core/hub.c -+++ b/drivers/usb/core/hub.c -@@ -298,7 +298,7 @@ static void usb_set_lpm_parameters(struct usb_device *udev) - unsigned int hub_u1_del; - unsigned int hub_u2_del; - -- if (!udev->lpm_capable || udev->speed != USB_SPEED_SUPER) -+ if (!udev->lpm_capable || udev->speed < USB_SPEED_SUPER) - return; - - hub = usb_hub_to_struct_hub(udev->parent); -@@ -1036,14 +1036,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) - - /* Continue a partial initialization */ - if (type == HUB_INIT2 || type == HUB_INIT3) { -- device_lock(hub->intfdev); -+ device_lock(&hdev->dev); - - /* Was the hub disconnected while we were waiting? */ -- if (hub->disconnected) { -- device_unlock(hub->intfdev); -- kref_put(&hub->kref, hub_release); -- return; -- } -+ if (hub->disconnected) -+ goto disconnected; - if (type == HUB_INIT2) - goto init2; - goto init3; -@@ -1246,7 +1243,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) - queue_delayed_work(system_power_efficient_wq, - &hub->init_work, - msecs_to_jiffies(delay)); -- device_unlock(hub->intfdev); -+ device_unlock(&hdev->dev); - return; /* Continues at init3: below */ - } else { - msleep(delay); -@@ -1265,12 +1262,12 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) - /* Scan all ports that need attention */ - kick_hub_wq(hub); - -- /* Allow autosuspend if it was suppressed */ -- if (type <= HUB_INIT3) -+ if (type == HUB_INIT2 || type == HUB_INIT3) { -+ /* Allow autosuspend if it was suppressed */ -+ disconnected: - usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); -- -- if (type == HUB_INIT2 || type == HUB_INIT3) -- device_unlock(hub->intfdev); -+ device_unlock(&hdev->dev); -+ } - - kref_put(&hub->kref, hub_release); - } -@@ -1299,8 +1296,6 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) - struct usb_device *hdev = hub->hdev; - int i; - -- cancel_delayed_work_sync(&hub->init_work); -- - /* hub_wq and related activity won't re-trigger */ - hub->quiescing = 1; - -@@ -2645,7 +2640,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub) - */ - static bool use_new_scheme(struct usb_device *udev, int retry) - { -- if (udev->speed == USB_SPEED_SUPER) -+ if (udev->speed >= USB_SPEED_SUPER) - return false; - - return USE_NEW_SCHEME(retry); -@@ -3985,7 +3980,7 @@ int usb_disable_lpm(struct usb_device *udev) - struct usb_hcd *hcd; - - if (!udev || !udev->parent || -- udev->speed != USB_SPEED_SUPER || -+ udev->speed < USB_SPEED_SUPER || - !udev->lpm_capable || - udev->state < USB_STATE_DEFAULT) - return 0; -@@ -4042,7 +4037,7 @@ void usb_enable_lpm(struct usb_device *udev) - struct usb_hcd *hcd; - - if (!udev || !udev->parent || -- udev->speed != USB_SPEED_SUPER || -+ udev->speed < USB_SPEED_SUPER || - !udev->lpm_capable || - udev->state < USB_STATE_DEFAULT) - return; -@@ -4308,7 +4303,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - - retval = -ENODEV; - -- if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) { -+ /* Don't allow speed changes at reset, except usb 3.0 to faster */ -+ if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed && -+ !(oldspeed == USB_SPEED_SUPER && udev->speed > oldspeed)) { - dev_dbg(&udev->dev, "device reset changed speed!\n"); - goto fail; - } -@@ -4320,6 +4317,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - * reported as 0xff in the device descriptor). WUSB1.0[4.8.1]. - */ - switch (udev->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - case USB_SPEED_WIRELESS: /* fixed at 512 */ - udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); -@@ -4346,7 +4344,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - else - speed = usb_speed_string(udev->speed); - -- if (udev->speed != USB_SPEED_SUPER) -+ if (udev->speed < USB_SPEED_SUPER) - dev_info(&udev->dev, - "%s %s USB device number %d using %s\n", - (udev->config) ? "reset" : "new", speed, -@@ -4476,11 +4474,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - devnum, retval); - goto fail; - } -- if (udev->speed == USB_SPEED_SUPER) { -+ if (udev->speed >= USB_SPEED_SUPER) { - devnum = udev->devnum; - dev_info(&udev->dev, -- "%s SuperSpeed USB device number %d using %s\n", -+ "%s SuperSpeed%s USB device number %d using %s\n", - (udev->config) ? "reset" : "new", -+ (udev->speed == USB_SPEED_SUPER_PLUS) ? "Plus" : "", - devnum, udev->bus->controller->driver->name); - } - -@@ -4519,7 +4518,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - * got from those devices show they aren't superspeed devices. Warm - * reset the port attached by the devices can fix them. - */ -- if ((udev->speed == USB_SPEED_SUPER) && -+ if ((udev->speed >= USB_SPEED_SUPER) && - (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) { - dev_err(&udev->dev, "got a wrong device descriptor, " - "warm reset device\n"); -@@ -4530,7 +4529,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, - } - - if (udev->descriptor.bMaxPacketSize0 == 0xff || -- udev->speed == USB_SPEED_SUPER) -+ udev->speed >= USB_SPEED_SUPER) - i = 512; - else - i = udev->descriptor.bMaxPacketSize0; -@@ -4740,7 +4739,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, - udev->level = hdev->level + 1; - udev->wusb = hub_is_wusb(hub); - -- /* Only USB 3.0 devices are connected to SuperSpeed hubs. */ -+ /* Devices connected to SuperSpeed hubs are USB 3.0 or later */ - if (hub_is_superspeed(hub->hdev)) - udev->speed = USB_SPEED_SUPER; - else -diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c -index 3d274778caaf..c601e25b609f 100644 ---- a/drivers/usb/core/urb.c -+++ b/drivers/usb/core/urb.c -@@ -401,7 +401,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) - /* SuperSpeed isoc endpoints have up to 16 bursts of up to - * 3 packets each - */ -- if (dev->speed == USB_SPEED_SUPER) { -+ if (dev->speed >= USB_SPEED_SUPER) { - int burst = 1 + ep->ss_ep_comp.bMaxBurst; - int mult = USB_SS_MULT(ep->ss_ep_comp.bmAttributes); - max *= burst; -@@ -499,6 +499,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) - } - /* too big? */ - switch (dev->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: /* units are 125us */ - /* Handle up to 2^(16-1) microframes */ - if (urb->interval > (1 << 15)) -diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h -index 05b5e17abf92..53318126ed91 100644 ---- a/drivers/usb/core/usb.h -+++ b/drivers/usb/core/usb.h -@@ -45,7 +45,7 @@ static inline unsigned usb_get_max_power(struct usb_device *udev, - struct usb_host_config *c) - { - /* SuperSpeed power is in 8 mA units; others are in 2 mA units */ -- unsigned mul = (udev->speed == USB_SPEED_SUPER ? 8 : 2); -+ unsigned mul = (udev->speed >= USB_SPEED_SUPER ? 8 : 2); - - return c->desc.bMaxPower * mul; - } -diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c -index 009d83048c8c..3d731d1b5c60 100644 ---- a/drivers/usb/dwc3/dwc3-pci.c -+++ b/drivers/usb/dwc3/dwc3-pci.c -@@ -36,6 +36,7 @@ - #define PCI_DEVICE_ID_INTEL_SPTH 0xa130 - #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa - #define PCI_DEVICE_ID_INTEL_APL 0x5aaa -+#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 - - static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; - static const struct acpi_gpio_params cs_gpios = { 1, 0, false }; -@@ -214,6 +215,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTH), }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, -+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, - { } /* Terminating Entry */ - }; -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c -index 70900e6ca9bc..fb79dca9484b 100644 ---- a/drivers/usb/dwc3/gadget.c -+++ b/drivers/usb/dwc3/gadget.c -@@ -1892,14 +1892,6 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, - s_pkt = 1; - } - -- /* -- * We assume here we will always receive the entire data block -- * which we should receive. Meaning, if we program RX to -- * receive 4K but we receive only 2K, we assume that's all we -- * should receive and we simply bounce the request back to the -- * gadget driver for further processing. -- */ -- req->request.actual += req->request.length - count; - if (s_pkt) - return 1; - if ((event->status & DEPEVT_STATUS_LST) && -@@ -1919,6 +1911,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, - struct dwc3_trb *trb; - unsigned int slot; - unsigned int i; -+ int count = 0; - int ret; - - do { -@@ -1935,6 +1928,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, - slot++; - slot %= DWC3_TRB_NUM; - trb = &dep->trb_pool[slot]; -+ count += trb->size & DWC3_TRB_SIZE_MASK; -+ - - ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb, - event, status); -@@ -1942,6 +1937,14 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, - break; - } while (++i < req->request.num_mapped_sgs); - -+ /* -+ * We assume here we will always receive the entire data block -+ * which we should receive. Meaning, if we program RX to -+ * receive 4K but we receive only 2K, we assume that's all we -+ * should receive and we simply bounce the request back to the -+ * gadget driver for further processing. -+ */ -+ req->request.actual += req->request.length - count; - dwc3_gadget_giveback(dep, req, status); - - if (ret) -diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c -index 55386619a0f1..e57f48f9528f 100644 ---- a/drivers/usb/gadget/legacy/inode.c -+++ b/drivers/usb/gadget/legacy/inode.c -@@ -541,7 +541,7 @@ static ssize_t ep_aio(struct kiocb *iocb, - */ - spin_lock_irq(&epdata->dev->lock); - value = -ENODEV; -- if (unlikely(epdata->ep)) -+ if (unlikely(epdata->ep == NULL)) - goto fail; - - req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC); -diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c -index 5fb6f8b4f0b4..c73689b72f95 100644 ---- a/drivers/usb/gadget/udc/fsl_qe_udc.c -+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c -@@ -2053,7 +2053,7 @@ static void setup_received_handle(struct qe_udc *udc, - struct qe_ep *ep; - - if (wValue != 0 || wLength != 0 -- || pipe > USB_MAX_ENDPOINTS) -+ || pipe >= USB_MAX_ENDPOINTS) - break; - ep = &udc->eps[pipe]; - -diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c -index 48c92bf78bd0..f7661d9750fd 100644 ---- a/drivers/usb/host/ehci-hcd.c -+++ b/drivers/usb/host/ehci-hcd.c -@@ -332,11 +332,11 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) - int port = HCS_N_PORTS(ehci->hcs_params); - - while (port--) { -- ehci_writel(ehci, PORT_RWC_BITS, -- &ehci->regs->port_status[port]); - spin_unlock_irq(&ehci->lock); - ehci_port_power(ehci, port, false); - spin_lock_irq(&ehci->lock); -+ ehci_writel(ehci, PORT_RWC_BITS, -+ &ehci->regs->port_status[port]); - } - } - -diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c -index f980c239eded..1da876605e4d 100644 ---- a/drivers/usb/host/xhci-hub.c -+++ b/drivers/usb/host/xhci-hub.c -@@ -377,6 +377,9 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) - - ret = 0; - virt_dev = xhci->devs[slot_id]; -+ if (!virt_dev) -+ return -ENODEV; -+ - cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO); - if (!cmd) { - xhci_dbg(xhci, "Couldn't allocate command structure.\n"); -diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c -index d8dbd7e5194b..8ea2c05beca2 100644 ---- a/drivers/usb/host/xhci-mem.c -+++ b/drivers/usb/host/xhci-mem.c -@@ -1072,7 +1072,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, - struct usb_device *top_dev; - struct usb_hcd *hcd; - -- if (udev->speed == USB_SPEED_SUPER) -+ if (udev->speed >= USB_SPEED_SUPER) - hcd = xhci->shared_hcd; - else - hcd = xhci->main_hcd; -@@ -1107,6 +1107,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud - /* 3) Only the control endpoint is valid - one endpoint context */ - slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); - switch (udev->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); - max_packets = MAX_PACKET(512); -@@ -1294,6 +1295,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, - } - /* Fall through - SS and HS isoc/int have same decoding */ - -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - if (usb_endpoint_xfer_int(&ep->desc) || - usb_endpoint_xfer_isoc(&ep->desc)) { -@@ -1334,7 +1336,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, - static u32 xhci_get_endpoint_mult(struct usb_device *udev, - struct usb_host_endpoint *ep) - { -- if (udev->speed != USB_SPEED_SUPER || -+ if (udev->speed < USB_SPEED_SUPER || - !usb_endpoint_xfer_isoc(&ep->desc)) - return 0; - return ep->ss_ep_comp.bmAttributes; -@@ -1384,7 +1386,7 @@ static u32 xhci_get_max_esit_payload(struct usb_device *udev, - usb_endpoint_xfer_bulk(&ep->desc)) - return 0; - -- if (udev->speed == USB_SPEED_SUPER) -+ if (udev->speed >= USB_SPEED_SUPER) - return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); - - max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); -@@ -1455,6 +1457,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, - max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); - max_burst = 0; - switch (udev->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - /* dig out max burst from ep companion desc */ - max_burst = ep->ss_ep_comp.bMaxBurst; -diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c -index de644e56aa3b..963867c2c1d5 100644 ---- a/drivers/usb/host/xhci-pci.c -+++ b/drivers/usb/host/xhci-pci.c -@@ -311,11 +311,12 @@ static void xhci_pci_remove(struct pci_dev *dev) - usb_remove_hcd(xhci->shared_hcd); - usb_put_hcd(xhci->shared_hcd); - } -- usb_hcd_pci_remove(dev); - - /* Workaround for spurious wakeups at shutdown with HSW */ - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(dev, PCI_D3hot); -+ -+ usb_hcd_pci_remove(dev); - } - - #ifdef CONFIG_PM -diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c -index 34cd23724bed..1f37b89e7267 100644 ---- a/drivers/usb/host/xhci-ring.c -+++ b/drivers/usb/host/xhci-ring.c -@@ -1331,12 +1331,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, - - cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); - -- if (cmd->command_trb != xhci->cmd_ring->dequeue) { -- xhci_err(xhci, -- "Command completion event does not match command\n"); -- return; -- } -- - del_timer(&xhci->cmd_timer); - - trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); -@@ -1348,6 +1342,13 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, - xhci_handle_stopped_cmd_ring(xhci, cmd); - return; - } -+ -+ if (cmd->command_trb != xhci->cmd_ring->dequeue) { -+ xhci_err(xhci, -+ "Command completion event does not match command\n"); -+ return; -+ } -+ - /* - * Host aborted the command ring, check if the current command was - * supposed to be aborted, otherwise continue normally. -@@ -3575,7 +3576,7 @@ static unsigned int xhci_get_burst_count(struct xhci_hcd *xhci, - { - unsigned int max_burst; - -- if (xhci->hci_version < 0x100 || udev->speed != USB_SPEED_SUPER) -+ if (xhci->hci_version < 0x100 || udev->speed < USB_SPEED_SUPER) - return 0; - - max_burst = urb->ep->ss_ep_comp.bMaxBurst; -@@ -3601,6 +3602,7 @@ static unsigned int xhci_get_last_burst_packet_count(struct xhci_hcd *xhci, - return 0; - - switch (udev->speed) { -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - /* bMaxBurst is zero based: 0 means 1 packet per burst */ - max_burst = urb->ep->ss_ep_comp.bMaxBurst; -diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c -index 6fe0174da226..adc169d2fd76 100644 ---- a/drivers/usb/host/xhci.c -+++ b/drivers/usb/host/xhci.c -@@ -2073,6 +2073,7 @@ static unsigned int xhci_get_block_size(struct usb_device *udev) - case USB_SPEED_HIGH: - return HS_BLOCK; - case USB_SPEED_SUPER: -+ case USB_SPEED_SUPER_PLUS: - return SS_BLOCK; - case USB_SPEED_UNKNOWN: - case USB_SPEED_WIRELESS: -@@ -2198,7 +2199,7 @@ static int xhci_check_bw_table(struct xhci_hcd *xhci, - unsigned int packets_remaining = 0; - unsigned int i; - -- if (virt_dev->udev->speed == USB_SPEED_SUPER) -+ if (virt_dev->udev->speed >= USB_SPEED_SUPER) - return xhci_check_ss_bw(xhci, virt_dev); - - if (virt_dev->udev->speed == USB_SPEED_HIGH) { -@@ -2399,7 +2400,7 @@ void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci, - if (xhci_is_async_ep(ep_bw->type)) - return; - -- if (udev->speed == USB_SPEED_SUPER) { -+ if (udev->speed >= USB_SPEED_SUPER) { - if (xhci_is_sync_in_ep(ep_bw->type)) - xhci->devs[udev->slot_id]->bw_table->ss_bw_in -= - xhci_get_ss_bw_consumed(ep_bw); -@@ -2437,6 +2438,7 @@ void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci, - interval_bw->overhead[HS_OVERHEAD_TYPE] -= 1; - break; - case USB_SPEED_SUPER: -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_UNKNOWN: - case USB_SPEED_WIRELESS: - /* Should never happen because only LS/FS/HS endpoints will get -@@ -2496,6 +2498,7 @@ static void xhci_add_ep_to_interval_table(struct xhci_hcd *xhci, - interval_bw->overhead[HS_OVERHEAD_TYPE] += 1; - break; - case USB_SPEED_SUPER: -+ case USB_SPEED_SUPER_PLUS: - case USB_SPEED_UNKNOWN: - case USB_SPEED_WIRELESS: - /* Should never happen because only LS/FS/HS endpoints will get -diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c -index 1a812eafe670..1624b09d9748 100644 ---- a/drivers/usb/misc/usbtest.c -+++ b/drivers/usb/misc/usbtest.c -@@ -558,7 +558,6 @@ static void sg_timeout(unsigned long _req) - { - struct usb_sg_request *req = (struct usb_sg_request *) _req; - -- req->status = -ETIMEDOUT; - usb_sg_cancel(req); - } - -@@ -589,8 +588,10 @@ static int perform_sglist( - mod_timer(&sg_timer, jiffies + - msecs_to_jiffies(SIMPLE_IO_TIMEOUT)); - usb_sg_wait(req); -- del_timer_sync(&sg_timer); -- retval = req->status; -+ if (!del_timer_sync(&sg_timer)) -+ retval = -ETIMEDOUT; -+ else -+ retval = req->status; - - /* FIXME check resulting data pattern */ - -diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c -index db565f620f82..36e5b5c530bd 100644 ---- a/drivers/usb/renesas_usbhs/fifo.c -+++ b/drivers/usb/renesas_usbhs/fifo.c -@@ -869,7 +869,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) - - /* use PIO if packet is less than pio_dma_border or pipe is DCP */ - if ((len < usbhs_get_dparam(priv, pio_dma_border)) || -- usbhs_pipe_is_dcp(pipe)) -+ usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC)) - goto usbhsf_pio_prepare_push; - - /* check data length if this driver don't use USB-DMAC */ -@@ -974,7 +974,7 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt, - - /* use PIO if packet is less than pio_dma_border or pipe is DCP */ - if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) || -- usbhs_pipe_is_dcp(pipe)) -+ usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC)) - goto usbhsf_pio_prepare_pop; - - fifo = usbhsf_get_dma_fifo(priv, pkt); -diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c -index 5a3abf56d56b..efc4fae123a4 100644 ---- a/drivers/usb/renesas_usbhs/mod_gadget.c -+++ b/drivers/usb/renesas_usbhs/mod_gadget.c -@@ -618,10 +618,13 @@ static int usbhsg_ep_enable(struct usb_ep *ep, - * use dmaengine if possible. - * It will use pio handler if impossible. - */ -- if (usb_endpoint_dir_in(desc)) -+ if (usb_endpoint_dir_in(desc)) { - pipe->handler = &usbhs_fifo_dma_push_handler; -- else -+ } else { - pipe->handler = &usbhs_fifo_dma_pop_handler; -+ usbhs_xxxsts_clear(priv, BRDYSTS, -+ usbhs_pipe_number(pipe)); -+ } - - ret = 0; - } -@@ -1072,7 +1075,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) - - gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); - dev_info(dev, "%stransceiver found\n", -- gpriv->transceiver ? "" : "no "); -+ !IS_ERR(gpriv->transceiver) ? "" : "no "); - - /* - * CAUTION -diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c -index b61f12160d37..8c48c9d83d48 100644 ---- a/drivers/usb/serial/ftdi_sio.c -+++ b/drivers/usb/serial/ftdi_sio.c -@@ -648,6 +648,8 @@ static const struct usb_device_id id_table_combined[] = { - { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) }, - { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) }, - { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) }, -+ { USB_DEVICE(FTDI_VID, FTDI_PALMSENS_PID) }, -+ { USB_DEVICE(FTDI_VID, FTDI_IVIUM_XSTAT_PID) }, - { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, - { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, - { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, -@@ -1008,6 +1010,7 @@ static const struct usb_device_id id_table_combined[] = { - { USB_DEVICE(ICPDAS_VID, ICPDAS_I7560U_PID) }, - { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) }, - { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) }, -+ { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) }, - { } /* Terminating entry */ - }; - -diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h -index c5d6c1e73e8e..f87a938cf005 100644 ---- a/drivers/usb/serial/ftdi_sio_ids.h -+++ b/drivers/usb/serial/ftdi_sio_ids.h -@@ -406,6 +406,12 @@ - #define FTDI_4N_GALAXY_DE_3_PID 0xF3C2 - - /* -+ * Ivium Technologies product IDs -+ */ -+#define FTDI_PALMSENS_PID 0xf440 -+#define FTDI_IVIUM_XSTAT_PID 0xf441 -+ -+/* - * Linx Technologies product ids - */ - #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ -@@ -673,6 +679,12 @@ - #define INTREPID_NEOVI_PID 0x0701 - - /* -+ * WICED USB UART -+ */ -+#define WICED_VID 0x0A5C -+#define WICED_USB20706V2_PID 0x6422 -+ -+/* - * Definitions for ID TECH (www.idt-net.com) devices - */ - #define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */ -diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c -index 06c7dbc1c802..63db004af21f 100644 ---- a/drivers/usb/serial/mos7720.c -+++ b/drivers/usb/serial/mos7720.c -@@ -1252,7 +1252,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, - - if (urb->transfer_buffer == NULL) { - urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, -- GFP_KERNEL); -+ GFP_ATOMIC); - if (!urb->transfer_buffer) - goto exit; - } -diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c -index 8ac9b55f05af..7f3ddd7ba2ce 100644 ---- a/drivers/usb/serial/mos7840.c -+++ b/drivers/usb/serial/mos7840.c -@@ -1340,8 +1340,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, - } - - if (urb->transfer_buffer == NULL) { -- urb->transfer_buffer = -- kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); -+ urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, -+ GFP_ATOMIC); - if (!urb->transfer_buffer) - goto exit; - } -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c -index 8e07536c233a..9894e341c6ac 100644 ---- a/drivers/usb/serial/option.c -+++ b/drivers/usb/serial/option.c -@@ -274,6 +274,12 @@ static void option_instat_callback(struct urb *urb); - #define TELIT_PRODUCT_LE920 0x1200 - #define TELIT_PRODUCT_LE910 0x1201 - #define TELIT_PRODUCT_LE910_USBCFG4 0x1206 -+#define TELIT_PRODUCT_LE920A4_1207 0x1207 -+#define TELIT_PRODUCT_LE920A4_1208 0x1208 -+#define TELIT_PRODUCT_LE920A4_1211 0x1211 -+#define TELIT_PRODUCT_LE920A4_1212 0x1212 -+#define TELIT_PRODUCT_LE920A4_1213 0x1213 -+#define TELIT_PRODUCT_LE920A4_1214 0x1214 - - /* ZTE PRODUCTS */ - #define ZTE_VENDOR_ID 0x19d2 -@@ -519,6 +525,12 @@ static void option_instat_callback(struct urb *urb); - #define VIATELECOM_VENDOR_ID 0x15eb - #define VIATELECOM_PRODUCT_CDS7 0x0001 - -+/* WeTelecom products */ -+#define WETELECOM_VENDOR_ID 0x22de -+#define WETELECOM_PRODUCT_WMD200 0x6801 -+#define WETELECOM_PRODUCT_6802 0x6802 -+#define WETELECOM_PRODUCT_WMD300 0x6803 -+ - struct option_blacklist_info { - /* bitmask of interface numbers blacklisted for send_setup */ - const unsigned long sendsetup; -@@ -628,6 +640,11 @@ static const struct option_blacklist_info telit_le920_blacklist = { - .reserved = BIT(1) | BIT(5), - }; - -+static const struct option_blacklist_info telit_le920a4_blacklist_1 = { -+ .sendsetup = BIT(0), -+ .reserved = BIT(1), -+}; -+ - static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { - .sendsetup = BIT(2), - .reserved = BIT(0) | BIT(1) | BIT(3), -@@ -1203,6 +1220,16 @@ static const struct usb_device_id option_ids[] = { - .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), - .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1207) }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1208), -+ .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1211), -+ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1212), -+ .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 }, -+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) }, -+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214), -+ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), - .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, -@@ -1966,9 +1993,13 @@ static const struct usb_device_id option_ids[] = { - .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, - { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ - { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ -+ { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ - { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ - { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, - { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, -+ { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, -+ { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) }, -+ { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) }, - { } /* Terminating entry */ - }; - MODULE_DEVICE_TABLE(usb, option_ids); -diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c -index 46f1f13b41f1..a0ca291bc07f 100644 ---- a/drivers/usb/serial/usb-serial.c -+++ b/drivers/usb/serial/usb-serial.c -@@ -1432,7 +1432,7 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[] - - rc = usb_register(udriver); - if (rc) -- return rc; -+ goto failed_usb_register; - - for (sd = serial_drivers; *sd; ++sd) { - (*sd)->usb_driver = udriver; -@@ -1450,6 +1450,8 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[] - while (sd-- > serial_drivers) - usb_serial_deregister(*sd); - usb_deregister(udriver); -+failed_usb_register: -+ kfree(udriver); - return rc; - } - EXPORT_SYMBOL_GPL(usb_serial_register_drivers); -diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c -index 3b3ba15558b7..20e9a86d2dcf 100644 ---- a/drivers/vfio/pci/vfio_pci_intrs.c -+++ b/drivers/vfio/pci/vfio_pci_intrs.c -@@ -563,67 +563,80 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_device *vdev, - } - - static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx, -- uint32_t flags, void *data) -+ unsigned int count, uint32_t flags, -+ void *data) - { -- int32_t fd = *(int32_t *)data; -- -- if (!(flags & VFIO_IRQ_SET_DATA_TYPE_MASK)) -- return -EINVAL; -- - /* DATA_NONE/DATA_BOOL enables loopback testing */ - if (flags & VFIO_IRQ_SET_DATA_NONE) { -- if (*ctx) -- eventfd_signal(*ctx, 1); -- return 0; -+ if (*ctx) { -+ if (count) { -+ eventfd_signal(*ctx, 1); -+ } else { -+ eventfd_ctx_put(*ctx); -+ *ctx = NULL; -+ } -+ return 0; -+ } - } else if (flags & VFIO_IRQ_SET_DATA_BOOL) { -- uint8_t trigger = *(uint8_t *)data; -+ uint8_t trigger; -+ -+ if (!count) -+ return -EINVAL; -+ -+ trigger = *(uint8_t *)data; - if (trigger && *ctx) - eventfd_signal(*ctx, 1); -- return 0; -- } - -- /* Handle SET_DATA_EVENTFD */ -- if (fd == -1) { -- if (*ctx) -- eventfd_ctx_put(*ctx); -- *ctx = NULL; - return 0; -- } else if (fd >= 0) { -- struct eventfd_ctx *efdctx; -- efdctx = eventfd_ctx_fdget(fd); -- if (IS_ERR(efdctx)) -- return PTR_ERR(efdctx); -- if (*ctx) -- eventfd_ctx_put(*ctx); -- *ctx = efdctx; -+ } else if (flags & VFIO_IRQ_SET_DATA_EVENTFD) { -+ int32_t fd; -+ -+ if (!count) -+ return -EINVAL; -+ -+ fd = *(int32_t *)data; -+ if (fd == -1) { -+ if (*ctx) -+ eventfd_ctx_put(*ctx); -+ *ctx = NULL; -+ } else if (fd >= 0) { -+ struct eventfd_ctx *efdctx; -+ -+ efdctx = eventfd_ctx_fdget(fd); -+ if (IS_ERR(efdctx)) -+ return PTR_ERR(efdctx); -+ -+ if (*ctx) -+ eventfd_ctx_put(*ctx); -+ -+ *ctx = efdctx; -+ } - return 0; -- } else -- return -EINVAL; -+ } -+ -+ return -EINVAL; - } - - static int vfio_pci_set_err_trigger(struct vfio_pci_device *vdev, - unsigned index, unsigned start, - unsigned count, uint32_t flags, void *data) - { -- if (index != VFIO_PCI_ERR_IRQ_INDEX) -+ if (index != VFIO_PCI_ERR_IRQ_INDEX || start != 0 || count > 1) - return -EINVAL; - -- /* -- * We should sanitize start & count, but that wasn't caught -- * originally, so this IRQ index must forever ignore them :-( -- */ -- -- return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, flags, data); -+ return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, -+ count, flags, data); - } - - static int vfio_pci_set_req_trigger(struct vfio_pci_device *vdev, - unsigned index, unsigned start, - unsigned count, uint32_t flags, void *data) - { -- if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count != 1) -+ if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count > 1) - return -EINVAL; - -- return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, flags, data); -+ return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, -+ count, flags, data); - } - - int vfio_pci_set_irqs_ioctl(struct vfio_pci_device *vdev, uint32_t flags, -diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c -index ee663c458b20..dc2b94142f53 100644 ---- a/drivers/virtio/virtio_ring.c -+++ b/drivers/virtio/virtio_ring.c -@@ -202,6 +202,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, - * host should service the ring ASAP. */ - if (out_sgs) - vq->notify(&vq->vq); -+ if (indirect) -+ kfree(desc); - END_USE(vq); - return -ENOSPC; - } -diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h -index 385b449fd7ed..1391f72c28c3 100644 ---- a/fs/btrfs/ctree.h -+++ b/fs/btrfs/ctree.h -@@ -1770,6 +1770,7 @@ struct btrfs_fs_info { - struct btrfs_workqueue *qgroup_rescan_workers; - struct completion qgroup_rescan_completion; - struct btrfs_work qgroup_rescan_work; -+ bool qgroup_rescan_running; /* protected by qgroup_rescan_lock */ - - /* filesystem state */ - unsigned long fs_state; -diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c -index 41fb43183406..85b207d19aa5 100644 ---- a/fs/btrfs/disk-io.c -+++ b/fs/btrfs/disk-io.c -@@ -2276,6 +2276,7 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info) - fs_info->quota_enabled = 0; - fs_info->pending_quota_state = 0; - fs_info->qgroup_ulist = NULL; -+ fs_info->qgroup_rescan_running = false; - mutex_init(&fs_info->qgroup_rescan_lock); - } - -@@ -3811,7 +3812,7 @@ void close_ctree(struct btrfs_root *root) - smp_mb(); - - /* wait for the qgroup rescan worker to stop */ -- btrfs_qgroup_wait_for_completion(fs_info); -+ btrfs_qgroup_wait_for_completion(fs_info, false); - - /* wait for the uuid_scan task to finish */ - down(&fs_info->uuid_tree_rescan_sem); -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c -index bfcd87ee8ff5..65f30b3b04f9 100644 ---- a/fs/btrfs/ioctl.c -+++ b/fs/btrfs/ioctl.c -@@ -5121,7 +5121,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg) - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - -- return btrfs_qgroup_wait_for_completion(root->fs_info); -+ return btrfs_qgroup_wait_for_completion(root->fs_info, true); - } - - static long _btrfs_ioctl_set_received_subvol(struct file *file, -diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c -index 5279fdae7142..bcc965ed5fa1 100644 ---- a/fs/btrfs/qgroup.c -+++ b/fs/btrfs/qgroup.c -@@ -995,7 +995,7 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, - goto out; - fs_info->quota_enabled = 0; - fs_info->pending_quota_state = 0; -- btrfs_qgroup_wait_for_completion(fs_info); -+ btrfs_qgroup_wait_for_completion(fs_info, false); - spin_lock(&fs_info->qgroup_lock); - quota_root = fs_info->quota_root; - fs_info->quota_root = NULL; -@@ -2283,6 +2283,10 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) - int err = -ENOMEM; - int ret = 0; - -+ mutex_lock(&fs_info->qgroup_rescan_lock); -+ fs_info->qgroup_rescan_running = true; -+ mutex_unlock(&fs_info->qgroup_rescan_lock); -+ - path = btrfs_alloc_path(); - if (!path) - goto out; -@@ -2349,6 +2353,9 @@ out: - } - - done: -+ mutex_lock(&fs_info->qgroup_rescan_lock); -+ fs_info->qgroup_rescan_running = false; -+ mutex_unlock(&fs_info->qgroup_rescan_lock); - complete_all(&fs_info->qgroup_rescan_completion); - } - -@@ -2467,20 +2474,26 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info) - return 0; - } - --int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info) -+int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info, -+ bool interruptible) - { - int running; - int ret = 0; - - mutex_lock(&fs_info->qgroup_rescan_lock); - spin_lock(&fs_info->qgroup_lock); -- running = fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN; -+ running = fs_info->qgroup_rescan_running; - spin_unlock(&fs_info->qgroup_lock); - mutex_unlock(&fs_info->qgroup_rescan_lock); - -- if (running) -+ if (!running) -+ return 0; -+ -+ if (interruptible) - ret = wait_for_completion_interruptible( - &fs_info->qgroup_rescan_completion); -+ else -+ wait_for_completion(&fs_info->qgroup_rescan_completion); - - return ret; - } -diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h -index ecb2c143ef75..3d73e4c9c7df 100644 ---- a/fs/btrfs/qgroup.h -+++ b/fs/btrfs/qgroup.h -@@ -46,7 +46,8 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, - struct btrfs_fs_info *fs_info); - int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); - void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info); --int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info); -+int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info, -+ bool interruptible); - int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, - struct btrfs_fs_info *fs_info, u64 src, u64 dst); - int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, -diff --git a/fs/seq_file.c b/fs/seq_file.c -index e85664b7c7d9..d672e2fec459 100644 ---- a/fs/seq_file.c -+++ b/fs/seq_file.c -@@ -222,8 +222,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) - size -= n; - buf += n; - copied += n; -- if (!m->count) -+ if (!m->count) { -+ m->from = 0; - m->index++; -+ } - if (!size) - goto Done; - } -diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c -index f35523d4fa3a..b803213d1307 100644 ---- a/fs/sysfs/file.c -+++ b/fs/sysfs/file.c -@@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, - * If buf != of->prealloc_buf, we don't know how - * large it is, so cannot safely pass it to ->show - */ -- if (pos || WARN_ON_ONCE(buf != of->prealloc_buf)) -+ if (WARN_ON_ONCE(buf != of->prealloc_buf)) - return 0; - len = ops->show(kobj, of->kn->priv, buf); -+ if (pos) { -+ if (len <= pos) -+ return 0; -+ len -= pos; -+ memmove(buf, buf + pos, len); -+ } - return min(count, len); - } - -diff --git a/include/linux/acpi.h b/include/linux/acpi.h -index 1991aea2ec4c..3672893b275e 100644 ---- a/include/linux/acpi.h -+++ b/include/linux/acpi.h -@@ -920,7 +920,7 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev, - return NULL; - } - --#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \ -+#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \ - static const void * __acpi_table_##name[] \ - __attribute__((unused)) \ - = { (void *) table_id, \ -diff --git a/include/linux/i8042.h b/include/linux/i8042.h -index 0f9bafa17a02..d98780ca9604 100644 ---- a/include/linux/i8042.h -+++ b/include/linux/i8042.h -@@ -62,7 +62,6 @@ struct serio; - void i8042_lock_chip(void); - void i8042_unlock_chip(void); - int i8042_command(unsigned char *param, int command); --bool i8042_check_port_owner(const struct serio *); - int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str, - struct serio *serio)); - int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str, -@@ -83,11 +82,6 @@ static inline int i8042_command(unsigned char *param, int command) - return -ENODEV; - } - --static inline bool i8042_check_port_owner(const struct serio *serio) --{ -- return false; --} -- - static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str, - struct serio *serio)) - { -diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h -index 494682ce4bf3..3ab3cede28ea 100644 ---- a/include/linux/mfd/cros_ec.h -+++ b/include/linux/mfd/cros_ec.h -@@ -224,6 +224,21 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, - struct cros_ec_command *msg); - - /** -+ * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC -+ * -+ * This function is identical to cros_ec_cmd_xfer, except it returns success -+ * status only if both the command was transmitted successfully and the EC -+ * replied with success status. It's not necessary to check msg->result when -+ * using this function. -+ * -+ * @ec_dev: EC device -+ * @msg: Message to write -+ * @return: Num. of bytes transferred on success, <0 on failure -+ */ -+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, -+ struct cros_ec_command *msg); -+ -+/** - * cros_ec_remove - Remove a ChromeOS EC - * - * Call this to deregister a ChromeOS EC, then clean up any private data. -diff --git a/include/linux/msi.h b/include/linux/msi.h -index f71a25e5fd25..f0f43ec45ee7 100644 ---- a/include/linux/msi.h -+++ b/include/linux/msi.h -@@ -254,12 +254,12 @@ enum { - * callbacks. - */ - MSI_FLAG_USE_DEF_CHIP_OPS = (1 << 1), -- /* Build identity map between hwirq and irq */ -- MSI_FLAG_IDENTITY_MAP = (1 << 2), - /* Support multiple PCI MSI interrupts */ -- MSI_FLAG_MULTI_PCI_MSI = (1 << 3), -+ MSI_FLAG_MULTI_PCI_MSI = (1 << 2), - /* Support PCI MSIX interrupts */ -- MSI_FLAG_PCI_MSIX = (1 << 4), -+ MSI_FLAG_PCI_MSIX = (1 << 3), -+ /* Needs early activate, required for PCI */ -+ MSI_FLAG_ACTIVATE_EARLY = (1 << 4), - }; - - int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, -diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h -index d9ba49cedc5d..37f05cb1dfd6 100644 ---- a/include/linux/pci_ids.h -+++ b/include/linux/pci_ids.h -@@ -2495,6 +2495,13 @@ - #define PCI_DEVICE_ID_KORENIX_JETCARDF2 0x1700 - #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff - -+#define PCI_VENDOR_ID_NETRONOME 0x19ee -+#define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200 -+#define PCI_DEVICE_ID_NETRONOME_NFP3240 0x3240 -+#define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000 -+#define PCI_DEVICE_ID_NETRONOME_NFP6000 0x6000 -+#define PCI_DEVICE_ID_NETRONOME_NFP6000_VF 0x6003 -+ - #define PCI_VENDOR_ID_QMI 0x1a32 - - #define PCI_VENDOR_ID_AZWAVE 0x1a3b -diff --git a/include/linux/serio.h b/include/linux/serio.h -index df4ab5de1586..c733cff44e18 100644 ---- a/include/linux/serio.h -+++ b/include/linux/serio.h -@@ -31,7 +31,8 @@ struct serio { - - struct serio_device_id id; - -- spinlock_t lock; /* protects critical sections from port's interrupt handler */ -+ /* Protects critical sections from port's interrupt handler */ -+ spinlock_t lock; - - int (*write)(struct serio *, unsigned char); - int (*open)(struct serio *); -@@ -40,16 +41,29 @@ struct serio { - void (*stop)(struct serio *); - - struct serio *parent; -- struct list_head child_node; /* Entry in parent->children list */ -+ /* Entry in parent->children list */ -+ struct list_head child_node; - struct list_head children; -- unsigned int depth; /* level of nesting in serio hierarchy */ -+ /* Level of nesting in serio hierarchy */ -+ unsigned int depth; - -- struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */ -- struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */ -+ /* -+ * serio->drv is accessed from interrupt handlers; when modifying -+ * caller should acquire serio->drv_mutex and serio->lock. -+ */ -+ struct serio_driver *drv; -+ /* Protects serio->drv so attributes can pin current driver */ -+ struct mutex drv_mutex; - - struct device dev; - - struct list_head node; -+ -+ /* -+ * For use by PS/2 layer when several ports share hardware and -+ * may get indigestion when exposed to concurrent access (i8042). -+ */ -+ struct mutex *ps2_cmd_mutex; - }; - #define to_serio_port(d) container_of(d, struct serio, dev) - -diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h -index 4338eb7b09b3..779a62aafafe 100644 ---- a/include/uapi/linux/usb/ch9.h -+++ b/include/uapi/linux/usb/ch9.h -@@ -954,6 +954,7 @@ enum usb_device_speed { - USB_SPEED_HIGH, /* usb 2.0 */ - USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ - USB_SPEED_SUPER, /* usb 3.0 */ -+ USB_SPEED_SUPER_PLUS, /* usb 3.1 */ - }; - - -diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c -index 6b0c0b74a2a1..4b21779d5163 100644 ---- a/kernel/irq/msi.c -+++ b/kernel/irq/msi.c -@@ -268,7 +268,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - struct msi_domain_ops *ops = info->ops; - msi_alloc_info_t arg; - struct msi_desc *desc; -- int i, ret, virq = -1; -+ int i, ret, virq; - - ret = ops->msi_check(domain, info, dev); - if (ret == 0) -@@ -278,12 +278,8 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - - for_each_msi_entry(desc, dev) { - ops->set_desc(&arg, desc); -- if (info->flags & MSI_FLAG_IDENTITY_MAP) -- virq = (int)ops->get_hwirq(info, &arg); -- else -- virq = -1; - -- virq = __irq_domain_alloc_irqs(domain, virq, desc->nvec_used, -+ virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, - dev_to_node(dev), &arg, false); - if (virq < 0) { - ret = -ENOSPC; -@@ -307,6 +303,17 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - else - dev_dbg(dev, "irq [%d-%d] for MSI\n", - virq, virq + desc->nvec_used - 1); -+ /* -+ * This flag is set by the PCI layer as we need to activate -+ * the MSI entries before the PCI layer enables MSI in the -+ * card. Otherwise the card latches a random msi message. -+ */ -+ if (info->flags & MSI_FLAG_ACTIVATE_EARLY) { -+ struct irq_data *irq_data; -+ -+ irq_data = irq_domain_get_irq_data(domain, desc->irq); -+ irq_domain_activate_irq(irq_data); -+ } - } - - return 0; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 67d1e1597d9c..ea863bc22caf 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -627,7 +627,10 @@ int get_nohz_timer_target(void) - rcu_read_lock(); - for_each_domain(cpu, sd) { - for_each_cpu(i, sched_domain_span(sd)) { -- if (!idle_cpu(i) && is_housekeeping_cpu(cpu)) { -+ if (cpu == i) -+ continue; -+ -+ if (!idle_cpu(i) && is_housekeeping_cpu(i)) { - cpu = i; - goto unlock; - } -diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c -index f74ea89e77a8..a1aecbedf5b1 100644 ---- a/kernel/sched/cputime.c -+++ b/kernel/sched/cputime.c -@@ -600,19 +600,25 @@ static void cputime_adjust(struct task_cputime *curr, - stime = curr->stime; - utime = curr->utime; - -- if (utime == 0) { -- stime = rtime; -+ /* -+ * If either stime or both stime and utime are 0, assume all runtime is -+ * userspace. Once a task gets some ticks, the monotonicy code at -+ * 'update' will ensure things converge to the observed ratio. -+ */ -+ if (stime == 0) { -+ utime = rtime; - goto update; - } - -- if (stime == 0) { -- utime = rtime; -+ if (utime == 0) { -+ stime = rtime; - goto update; - } - - stime = scale_stime((__force u64)stime, (__force u64)rtime, - (__force u64)(stime + utime)); - -+update: - /* - * Make sure stime doesn't go backwards; this preserves monotonicity - * for utime because rtime is monotonic. -@@ -635,7 +641,6 @@ static void cputime_adjust(struct task_cputime *curr, - stime = rtime - utime; - } - --update: - prev->stime = stime; - prev->utime = utime; - out: -diff --git a/mm/hugetlb.c b/mm/hugetlb.c -index 0c31f184daf8..125c7dd55322 100644 ---- a/mm/hugetlb.c -+++ b/mm/hugetlb.c -@@ -4213,7 +4213,6 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) - if (saddr) { - spte = huge_pte_offset(svma->vm_mm, saddr); - if (spte) { -- mm_inc_nr_pmds(mm); - get_page(virt_to_page(spte)); - break; - } -@@ -4228,9 +4227,9 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) - if (pud_none(*pud)) { - pud_populate(mm, pud, - (pmd_t *)((unsigned long)spte & PAGE_MASK)); -+ mm_inc_nr_pmds(mm); - } else { - put_page(virt_to_page(spte)); -- mm_inc_nr_pmds(mm); - } - spin_unlock(ptl); - out: -diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c -index c12f348138ac..19322c047386 100644 ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -865,7 +865,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) - - /* free all potentially still buffered bcast frames */ - local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); -- skb_queue_purge(&sdata->u.ap.ps.bc_buf); -+ ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf); - - mutex_lock(&local->mtx); - ieee80211_vif_copy_chanctx_to_vlans(sdata, true); -diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c -index bdc224d5053a..e1225b395415 100644 ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -365,7 +365,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) - skb = skb_dequeue(&ps->bc_buf); - if (skb) { - purged++; -- dev_kfree_skb(skb); -+ ieee80211_free_txskb(&local->hw, skb); - } - total += skb_queue_len(&ps->bc_buf); - } -@@ -448,7 +448,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) - if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { - ps_dbg(tx->sdata, - "BC TX buffer full - dropping the oldest frame\n"); -- dev_kfree_skb(skb_dequeue(&ps->bc_buf)); -+ ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); - } else - tx->local->total_ps_buffered++; - -@@ -3781,7 +3781,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, - sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); - if (!ieee80211_tx_prepare(sdata, &tx, NULL, skb)) - break; -- dev_kfree_skb_any(skb); -+ ieee80211_free_txskb(hw, skb); - } - - info = IEEE80211_SKB_CB(skb); -diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c -index 799e65b944b9..06095cc8815e 100644 ---- a/net/sunrpc/auth_gss/auth_gss.c -+++ b/net/sunrpc/auth_gss/auth_gss.c -@@ -340,12 +340,14 @@ gss_release_msg(struct gss_upcall_msg *gss_msg) - } - - static struct gss_upcall_msg * --__gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid) -+__gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid, const struct gss_auth *auth) - { - struct gss_upcall_msg *pos; - list_for_each_entry(pos, &pipe->in_downcall, list) { - if (!uid_eq(pos->uid, uid)) - continue; -+ if (auth && pos->auth->service != auth->service) -+ continue; - atomic_inc(&pos->count); - dprintk("RPC: %s found msg %p\n", __func__, pos); - return pos; -@@ -365,7 +367,7 @@ gss_add_msg(struct gss_upcall_msg *gss_msg) - struct gss_upcall_msg *old; - - spin_lock(&pipe->lock); -- old = __gss_find_upcall(pipe, gss_msg->uid); -+ old = __gss_find_upcall(pipe, gss_msg->uid, gss_msg->auth); - if (old == NULL) { - atomic_inc(&gss_msg->count); - list_add(&gss_msg->list, &pipe->in_downcall); -@@ -714,7 +716,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) - err = -ENOENT; - /* Find a matching upcall */ - spin_lock(&pipe->lock); -- gss_msg = __gss_find_upcall(pipe, uid); -+ gss_msg = __gss_find_upcall(pipe, uid, NULL); - if (gss_msg == NULL) { - spin_unlock(&pipe->lock); - goto err_put_ctx; -diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c -index 027c9ef8a263..1ba417207465 100644 ---- a/net/sunrpc/xprtsock.c -+++ b/net/sunrpc/xprtsock.c -@@ -2286,6 +2286,10 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) - /* SYN_SENT! */ - if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO) - xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; -+ break; -+ case -EADDRNOTAVAIL: -+ /* Source port number is unavailable. Try a new one! */ -+ transport->srcport = 0; - } - out: - return ret; -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index e769e5764cba..12f7f6fdae4d 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -944,20 +944,23 @@ static int azx_resume(struct device *dev) - struct snd_card *card = dev_get_drvdata(dev); - struct azx *chip; - struct hda_intel *hda; -+ struct hdac_bus *bus; - - if (!card) - return 0; - - chip = card->private_data; - hda = container_of(chip, struct hda_intel, chip); -+ bus = azx_bus(chip); - if (chip->disabled || hda->init_failed || !chip->running) - return 0; - -- if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL -- && hda->need_i915_power) { -- snd_hdac_display_power(azx_bus(chip), true); -- haswell_set_bclk(hda); -+ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { -+ snd_hdac_display_power(bus, true); -+ if (hda->need_i915_power) -+ haswell_set_bclk(hda); - } -+ - if (chip->msi) - if (pci_enable_msi(pci) < 0) - chip->msi = 0; -@@ -967,6 +970,11 @@ static int azx_resume(struct device *dev) - - hda_intel_init_chip(chip, true); - -+ /* power down again for link-controlled chips */ -+ if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) && -+ !hda->need_i915_power) -+ snd_hdac_display_power(bus, false); -+ - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - - trace_azx_resume(chip); -@@ -1046,6 +1054,7 @@ static int azx_runtime_resume(struct device *dev) - - chip = card->private_data; - hda = container_of(chip, struct hda_intel, chip); -+ bus = azx_bus(chip); - if (chip->disabled || hda->init_failed) - return 0; - -@@ -1053,15 +1062,9 @@ static int azx_runtime_resume(struct device *dev) - return 0; - - if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { -- bus = azx_bus(chip); -- if (hda->need_i915_power) { -- snd_hdac_display_power(bus, true); -+ snd_hdac_display_power(bus, true); -+ if (hda->need_i915_power) - haswell_set_bclk(hda); -- } else { -- /* toggle codec wakeup bit for STATESTS read */ -- snd_hdac_set_codec_wakeup(bus, true); -- snd_hdac_set_codec_wakeup(bus, false); -- } - } - - /* Read STATESTS before controller reset */ -@@ -1081,6 +1084,11 @@ static int azx_runtime_resume(struct device *dev) - azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) & - ~STATESTS_INT_MASK); - -+ /* power down again for link-controlled chips */ -+ if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) && -+ !hda->need_i915_power) -+ snd_hdac_display_power(bus, false); -+ - trace_azx_runtime_resume(chip); - return 0; - } -diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c -index 204cc074adb9..41aa3355e920 100644 ---- a/sound/usb/line6/pcm.c -+++ b/sound/usb/line6/pcm.c -@@ -55,7 +55,6 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol, - err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); - if (err < 0) { - line6pcm->impulse_volume = 0; -- line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); - return err; - } - } else { -@@ -211,7 +210,9 @@ static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction, - spin_lock_irqsave(&pstr->lock, flags); - clear_bit(type, &pstr->running); - if (!pstr->running) { -+ spin_unlock_irqrestore(&pstr->lock, flags); - line6_unlink_audio_urbs(line6pcm, pstr); -+ spin_lock_irqsave(&pstr->lock, flags); - if (direction == SNDRV_PCM_STREAM_CAPTURE) { - line6pcm->prev_fbuf = NULL; - line6pcm->prev_fsize = 0; -diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c -index daf81d169a42..45dd34874f43 100644 ---- a/sound/usb/line6/pod.c -+++ b/sound/usb/line6/pod.c -@@ -244,8 +244,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, - static ssize_t serial_number_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -- struct usb_interface *interface = to_usb_interface(dev); -- struct usb_line6_pod *pod = usb_get_intfdata(interface); -+ struct snd_card *card = dev_to_snd_card(dev); -+ struct usb_line6_pod *pod = card->private_data; - - return sprintf(buf, "%u\n", pod->serial_number); - } -@@ -256,8 +256,8 @@ static ssize_t serial_number_show(struct device *dev, - static ssize_t firmware_version_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -- struct usb_interface *interface = to_usb_interface(dev); -- struct usb_line6_pod *pod = usb_get_intfdata(interface); -+ struct snd_card *card = dev_to_snd_card(dev); -+ struct usb_line6_pod *pod = card->private_data; - - return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, - pod->firmware_version % 100); -@@ -269,8 +269,8 @@ static ssize_t firmware_version_show(struct device *dev, - static ssize_t device_id_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -- struct usb_interface *interface = to_usb_interface(dev); -- struct usb_line6_pod *pod = usb_get_intfdata(interface); -+ struct snd_card *card = dev_to_snd_card(dev); -+ struct usb_line6_pod *pod = card->private_data; - - return sprintf(buf, "%d\n", pod->device_id); - } -diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c -index db11ecf0b74d..a3e1252ce242 100644 ---- a/sound/usb/quirks.c -+++ b/sound/usb/quirks.c -@@ -1129,6 +1129,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) - { - /* devices which do not support reading the sample rate. */ - switch (chip->usb_id) { -+ case USB_ID(0x041E, 0x4080): /* Creative Live Cam VF0610 */ - case USB_ID(0x045E, 0x075D): /* MS Lifecam Cinema */ - case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */ - case USB_ID(0x045E, 0x076E): /* MS Lifecam HD-5001 */ -@@ -1139,6 +1140,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) - case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */ - case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ - case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ -+ case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ - case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ - case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ - case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ -diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c -index b02af064f0f9..c53f78767568 100644 ---- a/tools/perf/arch/x86/util/intel-pt.c -+++ b/tools/perf/arch/x86/util/intel-pt.c -@@ -499,7 +499,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, - struct intel_pt_recording *ptr = - container_of(itr, struct intel_pt_recording, itr); - struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; -- bool have_timing_info; -+ bool have_timing_info, need_immediate = false; - struct perf_evsel *evsel, *intel_pt_evsel = NULL; - const struct cpu_map *cpus = evlist->cpus; - bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; -@@ -653,6 +653,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, - ptr->have_sched_switch = 3; - } else { - opts->record_switch_events = true; -+ need_immediate = true; - if (cpu_wide) - ptr->have_sched_switch = 3; - else -@@ -698,6 +699,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, - tracking_evsel->attr.freq = 0; - tracking_evsel->attr.sample_period = 1; - -+ if (need_immediate) -+ tracking_evsel->immediate = true; -+ - /* In per-cpu case, always need the time of mmap events etc */ - if (!cpu_map__empty(cpus)) { - perf_evsel__set_sample_bit(tracking_evsel, TIME); -diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c -index 51cf8256c6cd..f0d1c8ff8e8a 100644 ---- a/tools/testing/nvdimm/test/nfit.c -+++ b/tools/testing/nvdimm/test/nfit.c -@@ -13,6 +13,7 @@ - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include - #include -+#include - #include - #include - #include -@@ -1246,6 +1247,7 @@ static int nfit_test_probe(struct platform_device *pdev) - if (nfit_test->setup != nfit_test0_setup) - return 0; - -+ flush_work(&acpi_desc->work); - nfit_test->setup_hotplug = 1; - nfit_test->setup(nfit_test); - diff --git a/patch/kernel/marvell-dev/patch-4.4.20-21.patch b/patch/kernel/marvell-dev/patch-4.4.20-21.patch deleted file mode 100644 index 8223cdebb7..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.20-21.patch +++ /dev/null @@ -1,10463 +0,0 @@ -diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt -index 402ab99e409f..6716413c17ba 100644 ---- a/Documentation/filesystems/proc.txt -+++ b/Documentation/filesystems/proc.txt -@@ -346,7 +346,7 @@ address perms offset dev inode pathname - a7cb1000-a7cb2000 ---p 00000000 00:00 0 - a7cb2000-a7eb2000 rw-p 00000000 00:00 0 - a7eb2000-a7eb3000 ---p 00000000 00:00 0 --a7eb3000-a7ed5000 rw-p 00000000 00:00 0 [stack:1001] -+a7eb3000-a7ed5000 rw-p 00000000 00:00 0 - a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 - a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6 - a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6 -@@ -378,7 +378,6 @@ is not associated with a file: - - [heap] = the heap of the program - [stack] = the stack of the main process -- [stack:1001] = the stack of the thread with tid 1001 - [vdso] = the "virtual dynamic shared object", - the kernel system call handler - -@@ -386,10 +385,8 @@ is not associated with a file: - - The /proc/PID/task/TID/maps is a view of the virtual memory from the viewpoint - of the individual tasks of a process. In this file you will see a mapping marked --as [stack] if that task sees it as a stack. This is a key difference from the --content of /proc/PID/maps, where you will see all mappings that are being used --as stack by all of those tasks. Hence, for the example above, the task-level --map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this: -+as [stack] if that task sees it as a stack. Hence, for the example above, the -+task-level map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this: - - 08048000-08049000 r-xp 00000000 03:00 8312 /opt/test - 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test -diff --git a/Makefile b/Makefile -index b74d60081a16..d1cc9e0b7473 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 20 -+SUBLEVEL = 21 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig -index 871f21783866..14cdc6dea493 100644 ---- a/arch/arm64/Kconfig -+++ b/arch/arm64/Kconfig -@@ -391,6 +391,15 @@ config CAVIUM_ERRATUM_22375 - - If unsure, say Y. - -+config CAVIUM_ERRATUM_23144 -+ bool "Cavium erratum 23144: ITS SYNC hang on dual socket system" -+ depends on NUMA -+ default y -+ help -+ ITS SYNC command hang for cross node io and collections/cpu mapping. -+ -+ If unsure, say Y. -+ - config CAVIUM_ERRATUM_23154 - bool "Cavium erratum 23154: Access to ICC_IAR1_EL1 is not sync'ed" - default y -@@ -401,6 +410,17 @@ config CAVIUM_ERRATUM_23154 - - If unsure, say Y. - -+config CAVIUM_ERRATUM_27456 -+ bool "Cavium erratum 27456: Broadcast TLBI instructions may cause icache corruption" -+ default y -+ help -+ On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI -+ instructions may cause the icache to become corrupted if it -+ contains data for a non-current ASID. The fix is to -+ invalidate the icache when changing the mm context. -+ -+ If unsure, say Y. -+ - endmenu - - -diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h -index 2731d3b25ed2..8ec88e5b290f 100644 ---- a/arch/arm64/include/asm/arch_gicv3.h -+++ b/arch/arm64/include/asm/arch_gicv3.h -@@ -103,6 +103,7 @@ static inline u64 gic_read_iar_common(void) - u64 irqstat; - - asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat)); -+ dsb(sy); - return irqstat; - } - -diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h -index 8f271b83f910..8136afc9df0d 100644 ---- a/arch/arm64/include/asm/cpufeature.h -+++ b/arch/arm64/include/asm/cpufeature.h -@@ -30,8 +30,9 @@ - #define ARM64_HAS_LSE_ATOMICS 5 - #define ARM64_WORKAROUND_CAVIUM_23154 6 - #define ARM64_WORKAROUND_834220 7 -+#define ARM64_WORKAROUND_CAVIUM_27456 8 - --#define ARM64_NCAPS 8 -+#define ARM64_NCAPS 9 - - #ifndef __ASSEMBLY__ - -diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h -index 5e6857b6bdc4..2d960f8588b0 100644 ---- a/arch/arm64/include/asm/kvm_arm.h -+++ b/arch/arm64/include/asm/kvm_arm.h -@@ -107,8 +107,6 @@ - #define TCR_EL2_MASK (TCR_EL2_TG0 | TCR_EL2_SH0 | \ - TCR_EL2_ORGN0 | TCR_EL2_IRGN0 | TCR_EL2_T0SZ) - --#define TCR_EL2_FLAGS (TCR_EL2_RES1 | TCR_EL2_PS_40B) -- - /* VTCR_EL2 Registers bits */ - #define VTCR_EL2_RES1 (1 << 31) - #define VTCR_EL2_PS_MASK (7 << 16) -diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c -index feb6b4efa641..a3e846a28b05 100644 ---- a/arch/arm64/kernel/cpu_errata.c -+++ b/arch/arm64/kernel/cpu_errata.c -@@ -100,6 +100,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { - MIDR_RANGE(MIDR_THUNDERX, 0x00, 0x01), - }, - #endif -+#ifdef CONFIG_CAVIUM_ERRATUM_27456 -+ { -+ /* Cavium ThunderX, T88 pass 1.x - 2.1 */ -+ .desc = "Cavium erratum 27456", -+ .capability = ARM64_WORKAROUND_CAVIUM_27456, -+ MIDR_RANGE(MIDR_THUNDERX, 0x00, -+ (1 << MIDR_VARIANT_SHIFT) | 1), -+ }, -+#endif - { - } - }; -diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S -index 178ba2248a98..84c338f017b2 100644 ---- a/arch/arm64/kvm/hyp-init.S -+++ b/arch/arm64/kvm/hyp-init.S -@@ -64,7 +64,7 @@ __do_hyp_init: - mrs x4, tcr_el1 - ldr x5, =TCR_EL2_MASK - and x4, x4, x5 -- ldr x5, =TCR_EL2_FLAGS -+ mov x5, #TCR_EL2_RES1 - orr x4, x4, x5 - - #ifndef CONFIG_ARM64_VA_BITS_48 -@@ -85,15 +85,18 @@ __do_hyp_init: - ldr_l x5, idmap_t0sz - bfi x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH - #endif -- msr tcr_el2, x4 -- -- ldr x4, =VTCR_EL2_FLAGS - /* - * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in -- * VTCR_EL2. -+ * TCR_EL2 and VTCR_EL2. - */ - mrs x5, ID_AA64MMFR0_EL1 - bfi x4, x5, #16, #3 -+ -+ msr tcr_el2, x4 -+ -+ ldr x4, =VTCR_EL2_FLAGS -+ bfi x4, x5, #16, #3 -+ - msr vtcr_el2, x4 - - mrs x4, mair_el1 -diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S -index 1f6bb29ca53b..18201e9e8cc7 100644 ---- a/arch/arm64/mm/proc.S -+++ b/arch/arm64/mm/proc.S -@@ -25,6 +25,8 @@ - #include - #include - #include -+#include -+#include - - #include "proc-macros.S" - -@@ -137,7 +139,17 @@ ENTRY(cpu_do_switch_mm) - bfi x0, x1, #48, #16 // set the ASID - msr ttbr0_el1, x0 // set TTBR0 - isb -+alternative_if_not ARM64_WORKAROUND_CAVIUM_27456 - ret -+ nop -+ nop -+ nop -+alternative_else -+ ic iallu -+ dsb nsh -+ isb -+ ret -+alternative_endif - ENDPROC(cpu_do_switch_mm) - - .section ".text.init", #alloc, #execinstr -diff --git a/arch/metag/include/asm/atomic_lnkget.h b/arch/metag/include/asm/atomic_lnkget.h -index a62581815624..88fa25fae8bd 100644 ---- a/arch/metag/include/asm/atomic_lnkget.h -+++ b/arch/metag/include/asm/atomic_lnkget.h -@@ -61,7 +61,7 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ - " CMPT %0, #HI(0x02000000)\n" \ - " BNZ 1b\n" \ - : "=&d" (temp), "=&da" (result) \ -- : "da" (&v->counter), "bd" (i) \ -+ : "da" (&v->counter), "br" (i) \ - : "cc"); \ - \ - smp_mb(); \ -diff --git a/arch/powerpc/include/asm/icswx.h b/arch/powerpc/include/asm/icswx.h -index 9f8402b35115..27e588f6c72e 100644 ---- a/arch/powerpc/include/asm/icswx.h -+++ b/arch/powerpc/include/asm/icswx.h -@@ -164,6 +164,7 @@ struct coprocessor_request_block { - #define ICSWX_INITIATED (0x8) - #define ICSWX_BUSY (0x4) - #define ICSWX_REJECTED (0x2) -+#define ICSWX_XERS0 (0x1) /* undefined or set from XERSO. */ - - static inline int icswx(__be32 ccw, struct coprocessor_request_block *crb) - { -diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S -index bf8f34a58670..b7019b559ddb 100644 ---- a/arch/powerpc/kernel/tm.S -+++ b/arch/powerpc/kernel/tm.S -@@ -110,17 +110,11 @@ _GLOBAL(tm_reclaim) - std r3, STK_PARAM(R3)(r1) - SAVE_NVGPRS(r1) - -- /* We need to setup MSR for VSX register save instructions. Here we -- * also clear the MSR RI since when we do the treclaim, we won't have a -- * valid kernel pointer for a while. We clear RI here as it avoids -- * adding another mtmsr closer to the treclaim. This makes the region -- * maked as non-recoverable wider than it needs to be but it saves on -- * inserting another mtmsrd later. -- */ -+ /* We need to setup MSR for VSX register save instructions. */ - mfmsr r14 - mr r15, r14 - ori r15, r15, MSR_FP -- li r16, MSR_RI -+ li r16, 0 - ori r16, r16, MSR_EE /* IRQs hard off */ - andc r15, r15, r16 - oris r15, r15, MSR_VEC@h -@@ -176,7 +170,17 @@ dont_backup_fp: - 1: tdeqi r6, 0 - EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0 - -- /* The moment we treclaim, ALL of our GPRs will switch -+ /* Clear MSR RI since we are about to change r1, EE is already off. */ -+ li r4, 0 -+ mtmsrd r4, 1 -+ -+ /* -+ * BE CAREFUL HERE: -+ * At this point we can't take an SLB miss since we have MSR_RI -+ * off. Load only to/from the stack/paca which are in SLB bolted regions -+ * until we turn MSR RI back on. -+ * -+ * The moment we treclaim, ALL of our GPRs will switch - * to user register state. (FPRs, CCR etc. also!) - * Use an sprg and a tm_scratch in the PACA to shuffle. - */ -@@ -197,6 +201,11 @@ dont_backup_fp: - - /* Store the PPR in r11 and reset to decent value */ - std r11, GPR11(r1) /* Temporary stash */ -+ -+ /* Reset MSR RI so we can take SLB faults again */ -+ li r11, MSR_RI -+ mtmsrd r11, 1 -+ - mfspr r11, SPRN_PPR - HMT_MEDIUM - -@@ -397,11 +406,6 @@ restore_gprs: - ld r5, THREAD_TM_DSCR(r3) - ld r6, THREAD_TM_PPR(r3) - -- /* Clear the MSR RI since we are about to change R1. EE is already off -- */ -- li r4, 0 -- mtmsrd r4, 1 -- - REST_GPR(0, r7) /* GPR0 */ - REST_2GPRS(2, r7) /* GPR2-3 */ - REST_GPR(4, r7) /* GPR4 */ -@@ -439,10 +443,33 @@ restore_gprs: - ld r6, _CCR(r7) - mtcr r6 - -- REST_GPR(1, r7) /* GPR1 */ -- REST_GPR(5, r7) /* GPR5-7 */ - REST_GPR(6, r7) -- ld r7, GPR7(r7) -+ -+ /* -+ * Store r1 and r5 on the stack so that we can access them -+ * after we clear MSR RI. -+ */ -+ -+ REST_GPR(5, r7) -+ std r5, -8(r1) -+ ld r5, GPR1(r7) -+ std r5, -16(r1) -+ -+ REST_GPR(7, r7) -+ -+ /* Clear MSR RI since we are about to change r1. EE is already off */ -+ li r5, 0 -+ mtmsrd r5, 1 -+ -+ /* -+ * BE CAREFUL HERE: -+ * At this point we can't take an SLB miss since we have MSR_RI -+ * off. Load only to/from the stack/paca which are in SLB bolted regions -+ * until we turn MSR RI back on. -+ */ -+ -+ ld r5, -8(r1) -+ ld r1, -16(r1) - - /* Commit register state as checkpointed state: */ - TRECHKPT -diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c -index b8045b97f4fb..d750cc0dfe30 100644 ---- a/arch/s390/crypto/prng.c -+++ b/arch/s390/crypto/prng.c -@@ -669,11 +669,13 @@ static const struct file_operations prng_tdes_fops = { - static struct miscdevice prng_sha512_dev = { - .name = "prandom", - .minor = MISC_DYNAMIC_MINOR, -+ .mode = 0644, - .fops = &prng_sha512_fops, - }; - static struct miscdevice prng_tdes_dev = { - .name = "prandom", - .minor = MISC_DYNAMIC_MINOR, -+ .mode = 0644, - .fops = &prng_tdes_fops, - }; - -diff --git a/arch/s390/include/asm/pci_dma.h b/arch/s390/include/asm/pci_dma.h -index 1aac41e83ea1..92df3eb8d14e 100644 ---- a/arch/s390/include/asm/pci_dma.h -+++ b/arch/s390/include/asm/pci_dma.h -@@ -23,6 +23,8 @@ enum zpci_ioat_dtype { - #define ZPCI_IOTA_FS_2G 2 - #define ZPCI_KEY (PAGE_DEFAULT_KEY << 5) - -+#define ZPCI_TABLE_SIZE_RT (1UL << 42) -+ - #define ZPCI_IOTA_STO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_ST) - #define ZPCI_IOTA_RTTO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_RT) - #define ZPCI_IOTA_RSTO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_RS) -diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c -index 19442395f413..f2f6720a3331 100644 ---- a/arch/s390/pci/pci.c -+++ b/arch/s390/pci/pci.c -@@ -701,8 +701,7 @@ static int zpci_restore(struct device *dev) - goto out; - - zpci_map_resources(pdev); -- zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET, -- zdev->start_dma + zdev->iommu_size - 1, -+ zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma, - (u64) zdev->dma_table); - - out: -diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c -index d348f2c09a1e..3a40f718baef 100644 ---- a/arch/s390/pci/pci_dma.c -+++ b/arch/s390/pci/pci_dma.c -@@ -458,7 +458,19 @@ int zpci_dma_init_device(struct zpci_dev *zdev) - goto out_clean; - } - -- zdev->iommu_size = (unsigned long) high_memory - PAGE_OFFSET; -+ /* -+ * Restrict the iommu bitmap size to the minimum of the following: -+ * - main memory size -+ * - 3-level pagetable address limit minus start_dma offset -+ * - DMA address range allowed by the hardware (clp query pci fn) -+ * -+ * Also set zdev->end_dma to the actual end address of the usable -+ * range, instead of the theoretical maximum as reported by hardware. -+ */ -+ zdev->iommu_size = min3((u64) high_memory, -+ ZPCI_TABLE_SIZE_RT - zdev->start_dma, -+ zdev->end_dma - zdev->start_dma + 1); -+ zdev->end_dma = zdev->start_dma + zdev->iommu_size - 1; - zdev->iommu_pages = zdev->iommu_size >> PAGE_SHIFT; - zdev->iommu_bitmap = vzalloc(zdev->iommu_pages / 8); - if (!zdev->iommu_bitmap) { -@@ -466,10 +478,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev) - goto out_reg; - } - -- rc = zpci_register_ioat(zdev, -- 0, -- zdev->start_dma + PAGE_OFFSET, -- zdev->start_dma + zdev->iommu_size - 1, -+ rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma, - (u64) zdev->dma_table); - if (rc) - goto out_reg; -diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c -index 2f69e3b184f6..a3e1f8497f8c 100644 ---- a/arch/x86/kernel/apic/apic.c -+++ b/arch/x86/kernel/apic/apic.c -@@ -1587,6 +1587,9 @@ void __init enable_IR_x2apic(void) - unsigned long flags; - int ret, ir_stat; - -+ if (skip_ioapic_setup) -+ return; -+ - ir_stat = irq_remapping_prepare(); - if (ir_stat < 0 && !x2apic_supported()) - return; -diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c -index 20e242ea1bc4..cfc4a966e2b9 100644 ---- a/arch/x86/kernel/cpu/mshyperv.c -+++ b/arch/x86/kernel/cpu/mshyperv.c -@@ -152,6 +152,11 @@ static struct clocksource hyperv_cs = { - .flags = CLOCK_SOURCE_IS_CONTINUOUS, - }; - -+static unsigned char hv_get_nmi_reason(void) -+{ -+ return 0; -+} -+ - static void __init ms_hyperv_init_platform(void) - { - /* -@@ -191,6 +196,13 @@ static void __init ms_hyperv_init_platform(void) - machine_ops.crash_shutdown = hv_machine_crash_shutdown; - #endif - mark_tsc_unstable("running on Hyper-V"); -+ -+ /* -+ * Generation 2 instances don't support reading the NMI status from -+ * 0x61 port. -+ */ -+ if (efi_enabled(EFI_BOOT)) -+ x86_platform.get_nmi_reason = hv_get_nmi_reason; - } - - const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = { -diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c -index a316ca96f1b6..fc704ed587e8 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c -+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c -@@ -211,6 +211,20 @@ static void __put_rmid(u32 rmid) - list_add_tail(&entry->list, &cqm_rmid_limbo_lru); - } - -+static void cqm_cleanup(void) -+{ -+ int i; -+ -+ if (!cqm_rmid_ptrs) -+ return; -+ -+ for (i = 0; i < cqm_max_rmid; i++) -+ kfree(cqm_rmid_ptrs[i]); -+ -+ kfree(cqm_rmid_ptrs); -+ cqm_rmid_ptrs = NULL; -+} -+ - static int intel_cqm_setup_rmid_cache(void) - { - struct cqm_rmid_entry *entry; -@@ -218,7 +232,7 @@ static int intel_cqm_setup_rmid_cache(void) - int r = 0; - - nr_rmids = cqm_max_rmid + 1; -- cqm_rmid_ptrs = kmalloc(sizeof(struct cqm_rmid_entry *) * -+ cqm_rmid_ptrs = kzalloc(sizeof(struct cqm_rmid_entry *) * - nr_rmids, GFP_KERNEL); - if (!cqm_rmid_ptrs) - return -ENOMEM; -@@ -249,11 +263,9 @@ static int intel_cqm_setup_rmid_cache(void) - mutex_unlock(&cache_mutex); - - return 0; --fail: -- while (r--) -- kfree(cqm_rmid_ptrs[r]); - -- kfree(cqm_rmid_ptrs); -+fail: -+ cqm_cleanup(); - return -ENOMEM; - } - -@@ -281,9 +293,13 @@ static bool __match_event(struct perf_event *a, struct perf_event *b) - - /* - * Events that target same task are placed into the same cache group. -+ * Mark it as a multi event group, so that we update ->count -+ * for every event rather than just the group leader later. - */ -- if (a->hw.target == b->hw.target) -+ if (a->hw.target == b->hw.target) { -+ b->hw.is_group_event = true; - return true; -+ } - - /* - * Are we an inherited event? -@@ -849,6 +865,7 @@ static void intel_cqm_setup_event(struct perf_event *event, - bool conflict = false; - u32 rmid; - -+ event->hw.is_group_event = false; - list_for_each_entry(iter, &cache_groups, hw.cqm_groups_entry) { - rmid = iter->hw.cqm_rmid; - -@@ -940,7 +957,9 @@ static u64 intel_cqm_event_count(struct perf_event *event) - return __perf_event_count(event); - - /* -- * Only the group leader gets to report values. This stops us -+ * Only the group leader gets to report values except in case of -+ * multiple events in the same group, we still need to read the -+ * other events.This stops us - * reporting duplicate values to userspace, and gives us a clear - * rule for which task gets to report the values. - * -@@ -948,7 +967,7 @@ static u64 intel_cqm_event_count(struct perf_event *event) - * specific packages - we forfeit that ability when we create - * task events. - */ -- if (!cqm_group_leader(event)) -+ if (!cqm_group_leader(event) && !event->hw.is_group_event) - return 0; - - /* -@@ -1315,7 +1334,7 @@ static const struct x86_cpu_id intel_cqm_match[] = { - - static int __init intel_cqm_init(void) - { -- char *str, scale[20]; -+ char *str = NULL, scale[20]; - int i, cpu, ret; - - if (!x86_match_cpu(intel_cqm_match)) -@@ -1375,16 +1394,25 @@ static int __init intel_cqm_init(void) - cqm_pick_event_reader(i); - } - -- __perf_cpu_notifier(intel_cqm_cpu_notifier); -- - ret = perf_pmu_register(&intel_cqm_pmu, "intel_cqm", -1); -- if (ret) -+ if (ret) { - pr_err("Intel CQM perf registration failed: %d\n", ret); -- else -- pr_info("Intel CQM monitoring enabled\n"); -+ goto out; -+ } -+ -+ pr_info("Intel CQM monitoring enabled\n"); - -+ /* -+ * Register the hot cpu notifier once we are sure cqm -+ * is enabled to avoid notifier leak. -+ */ -+ __perf_cpu_notifier(intel_cqm_cpu_notifier); - out: - cpu_notifier_register_done(); -+ if (ret) { -+ kfree(str); -+ cqm_cleanup(); -+ } - - return ret; - } -diff --git a/block/blk-core.c b/block/blk-core.c -index f8e64cac981a..4fab5d610805 100644 ---- a/block/blk-core.c -+++ b/block/blk-core.c -@@ -515,7 +515,9 @@ EXPORT_SYMBOL_GPL(blk_queue_bypass_end); - - void blk_set_queue_dying(struct request_queue *q) - { -- queue_flag_set_unlocked(QUEUE_FLAG_DYING, q); -+ spin_lock_irq(q->queue_lock); -+ queue_flag_set(QUEUE_FLAG_DYING, q); -+ spin_unlock_irq(q->queue_lock); - - if (q->mq_ops) - blk_mq_wake_waiters(q); -diff --git a/block/blk-merge.c b/block/blk-merge.c -index b966db8f3556..7225511cf0b4 100644 ---- a/block/blk-merge.c -+++ b/block/blk-merge.c -@@ -92,9 +92,31 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, - bool do_split = true; - struct bio *new = NULL; - const unsigned max_sectors = get_max_io_size(q, bio); -+ unsigned bvecs = 0; - - bio_for_each_segment(bv, bio, iter) { - /* -+ * With arbitrary bio size, the incoming bio may be very -+ * big. We have to split the bio into small bios so that -+ * each holds at most BIO_MAX_PAGES bvecs because -+ * bio_clone() can fail to allocate big bvecs. -+ * -+ * It should have been better to apply the limit per -+ * request queue in which bio_clone() is involved, -+ * instead of globally. The biggest blocker is the -+ * bio_clone() in bio bounce. -+ * -+ * If bio is splitted by this reason, we should have -+ * allowed to continue bios merging, but don't do -+ * that now for making the change simple. -+ * -+ * TODO: deal with bio bounce's bio_clone() gracefully -+ * and convert the global limit into per-queue limit. -+ */ -+ if (bvecs++ >= BIO_MAX_PAGES) -+ goto split; -+ -+ /* - * If the queue doesn't support SG gaps and adding this - * offset would create a gap, disallow it. - */ -diff --git a/block/blk-mq.c b/block/blk-mq.c -index 6d6f8feb48c0..839b1e17481b 100644 ---- a/block/blk-mq.c -+++ b/block/blk-mq.c -@@ -601,8 +601,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx, - * If a request wasn't started before the queue was - * marked dying, kill it here or it'll go unnoticed. - */ -- if (unlikely(blk_queue_dying(rq->q))) -- blk_mq_complete_request(rq, -EIO); -+ if (unlikely(blk_queue_dying(rq->q))) { -+ rq->errors = -EIO; -+ blk_mq_end_request(rq, rq->errors); -+ } - return; - } - if (rq->cmd_flags & REQ_NO_TIMEOUT) -diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c -index 79107597a594..c306b483de60 100644 ---- a/drivers/bluetooth/btusb.c -+++ b/drivers/bluetooth/btusb.c -@@ -2056,12 +2056,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) - return -EINVAL; - } - -- /* At the moment only the hardware variant iBT 3.0 (LnP/SfP) is -- * supported by this firmware loading method. This check has been -- * put in place to ensure correct forward compatibility options -- * when newer hardware variants come along. -+ /* At the moment the iBT 3.0 hardware variants 0x0b (LnP/SfP) -+ * and 0x0c (WsP) are supported by this firmware loading method. -+ * -+ * This check has been put in place to ensure correct forward -+ * compatibility options when newer hardware variants come along. - */ -- if (ver->hw_variant != 0x0b) { -+ if (ver->hw_variant != 0x0b && ver->hw_variant != 0x0c) { - BT_ERR("%s: Unsupported Intel hardware variant (%u)", - hdev->name, ver->hw_variant); - kfree_skb(skb); -diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c -index aa30af5f0f2b..7845a38b6604 100644 ---- a/drivers/char/hw_random/exynos-rng.c -+++ b/drivers/char/hw_random/exynos-rng.c -@@ -118,6 +118,7 @@ static int exynos_rng_probe(struct platform_device *pdev) - { - struct exynos_rng *exynos_rng; - struct resource *res; -+ int ret; - - exynos_rng = devm_kzalloc(&pdev->dev, sizeof(struct exynos_rng), - GFP_KERNEL); -@@ -145,7 +146,13 @@ static int exynos_rng_probe(struct platform_device *pdev) - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_enable(&pdev->dev); - -- return devm_hwrng_register(&pdev->dev, &exynos_rng->rng); -+ ret = devm_hwrng_register(&pdev->dev, &exynos_rng->rng); -+ if (ret) { -+ pm_runtime_dont_use_autosuspend(&pdev->dev); -+ pm_runtime_disable(&pdev->dev); -+ } -+ -+ return ret; - } - - #ifdef CONFIG_PM -diff --git a/drivers/clk/clk-xgene.c b/drivers/clk/clk-xgene.c -index 27c0da29eca3..10224b01b97c 100644 ---- a/drivers/clk/clk-xgene.c -+++ b/drivers/clk/clk-xgene.c -@@ -351,7 +351,8 @@ static int xgene_clk_set_rate(struct clk_hw *hw, unsigned long rate, - /* Set new divider */ - data = xgene_clk_read(pclk->param.divider_reg + - pclk->param.reg_divider_offset); -- data &= ~((1 << pclk->param.reg_divider_width) - 1); -+ data &= ~((1 << pclk->param.reg_divider_width) - 1) -+ << pclk->param.reg_divider_shift; - data |= divider; - xgene_clk_write(data, pclk->param.divider_reg + - pclk->param.reg_divider_offset); -diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c -index 4dbf1db16aca..9cc8abd3d116 100644 ---- a/drivers/cpufreq/cpufreq_userspace.c -+++ b/drivers/cpufreq/cpufreq_userspace.c -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - - static DEFINE_PER_CPU(unsigned int, cpu_is_managed); - static DEFINE_MUTEX(userspace_mutex); -@@ -31,6 +32,7 @@ static DEFINE_MUTEX(userspace_mutex); - static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) - { - int ret = -EINVAL; -+ unsigned int *setspeed = policy->governor_data; - - pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); - -@@ -38,6 +40,8 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) - if (!per_cpu(cpu_is_managed, policy->cpu)) - goto err; - -+ *setspeed = freq; -+ - ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); - err: - mutex_unlock(&userspace_mutex); -@@ -49,19 +53,45 @@ static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) - return sprintf(buf, "%u\n", policy->cur); - } - -+static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy) -+{ -+ unsigned int *setspeed; -+ -+ setspeed = kzalloc(sizeof(*setspeed), GFP_KERNEL); -+ if (!setspeed) -+ return -ENOMEM; -+ -+ policy->governor_data = setspeed; -+ return 0; -+} -+ - static int cpufreq_governor_userspace(struct cpufreq_policy *policy, - unsigned int event) - { -+ unsigned int *setspeed = policy->governor_data; - unsigned int cpu = policy->cpu; - int rc = 0; - -+ if (event == CPUFREQ_GOV_POLICY_INIT) -+ return cpufreq_userspace_policy_init(policy); -+ -+ if (!setspeed) -+ return -EINVAL; -+ - switch (event) { -+ case CPUFREQ_GOV_POLICY_EXIT: -+ mutex_lock(&userspace_mutex); -+ policy->governor_data = NULL; -+ kfree(setspeed); -+ mutex_unlock(&userspace_mutex); -+ break; - case CPUFREQ_GOV_START: - BUG_ON(!policy->cur); - pr_debug("started managing cpu %u\n", cpu); - - mutex_lock(&userspace_mutex); - per_cpu(cpu_is_managed, cpu) = 1; -+ *setspeed = policy->cur; - mutex_unlock(&userspace_mutex); - break; - case CPUFREQ_GOV_STOP: -@@ -69,20 +99,23 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, - - mutex_lock(&userspace_mutex); - per_cpu(cpu_is_managed, cpu) = 0; -+ *setspeed = 0; - mutex_unlock(&userspace_mutex); - break; - case CPUFREQ_GOV_LIMITS: - mutex_lock(&userspace_mutex); -- pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz\n", -- cpu, policy->min, policy->max, -- policy->cur); -+ pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", -+ cpu, policy->min, policy->max, policy->cur, *setspeed); - -- if (policy->max < policy->cur) -+ if (policy->max < *setspeed) - __cpufreq_driver_target(policy, policy->max, - CPUFREQ_RELATION_H); -- else if (policy->min > policy->cur) -+ else if (policy->min > *setspeed) - __cpufreq_driver_target(policy, policy->min, - CPUFREQ_RELATION_L); -+ else -+ __cpufreq_driver_target(policy, *setspeed, -+ CPUFREQ_RELATION_L); - mutex_unlock(&userspace_mutex); - break; - } -diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c -index 6dc597126b79..b3044219772c 100644 ---- a/drivers/crypto/caam/caamalg.c -+++ b/drivers/crypto/caam/caamalg.c -@@ -556,7 +556,10 @@ skip_enc: - - /* Read and write assoclen bytes */ - append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); -- append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); -+ if (alg->caam.geniv) -+ append_math_add_imm_u32(desc, VARSEQOUTLEN, REG3, IMM, ivsize); -+ else -+ append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); - - /* Skip assoc data */ - append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); -@@ -565,6 +568,14 @@ skip_enc: - append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | - KEY_VLF); - -+ if (alg->caam.geniv) { -+ append_seq_load(desc, ivsize, LDST_CLASS_1_CCB | -+ LDST_SRCDST_BYTE_CONTEXT | -+ (ctx1_iv_off << LDST_OFFSET_SHIFT)); -+ append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_CLASS2INFIFO | -+ (ctx1_iv_off << MOVE_OFFSET_SHIFT) | ivsize); -+ } -+ - /* Load Counter into CONTEXT1 reg */ - if (is_rfc3686) - append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM | -@@ -2150,7 +2161,7 @@ static void init_authenc_job(struct aead_request *req, - - init_aead_job(req, edesc, all_contig, encrypt); - -- if (ivsize && (is_rfc3686 || !(alg->caam.geniv && encrypt))) -+ if (ivsize && ((is_rfc3686 && encrypt) || !alg->caam.geniv)) - append_load_as_imm(desc, req->iv, ivsize, - LDST_CLASS_1_CCB | - LDST_SRCDST_BYTE_CONTEXT | -@@ -2537,20 +2548,6 @@ static int aead_decrypt(struct aead_request *req) - return ret; - } - --static int aead_givdecrypt(struct aead_request *req) --{ -- struct crypto_aead *aead = crypto_aead_reqtfm(req); -- unsigned int ivsize = crypto_aead_ivsize(aead); -- -- if (req->cryptlen < ivsize) -- return -EINVAL; -- -- req->cryptlen -= ivsize; -- req->assoclen += ivsize; -- -- return aead_decrypt(req); --} -- - /* - * allocate and map the ablkcipher extended descriptor for ablkcipher - */ -@@ -3210,7 +3207,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = MD5_DIGEST_SIZE, - }, -@@ -3256,7 +3253,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = SHA1_DIGEST_SIZE, - }, -@@ -3302,7 +3299,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = SHA224_DIGEST_SIZE, - }, -@@ -3348,7 +3345,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = SHA256_DIGEST_SIZE, - }, -@@ -3394,7 +3391,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = SHA384_DIGEST_SIZE, - }, -@@ -3440,7 +3437,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = AES_BLOCK_SIZE, - .maxauthsize = SHA512_DIGEST_SIZE, - }, -@@ -3486,7 +3483,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = MD5_DIGEST_SIZE, - }, -@@ -3534,7 +3531,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = SHA1_DIGEST_SIZE, - }, -@@ -3582,7 +3579,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = SHA224_DIGEST_SIZE, - }, -@@ -3630,7 +3627,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = SHA256_DIGEST_SIZE, - }, -@@ -3678,7 +3675,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = SHA384_DIGEST_SIZE, - }, -@@ -3726,7 +3723,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES3_EDE_BLOCK_SIZE, - .maxauthsize = SHA512_DIGEST_SIZE, - }, -@@ -3772,7 +3769,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = MD5_DIGEST_SIZE, - }, -@@ -3818,7 +3815,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = SHA1_DIGEST_SIZE, - }, -@@ -3864,7 +3861,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = SHA224_DIGEST_SIZE, - }, -@@ -3910,7 +3907,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = SHA256_DIGEST_SIZE, - }, -@@ -3956,7 +3953,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = SHA384_DIGEST_SIZE, - }, -@@ -4002,7 +3999,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = DES_BLOCK_SIZE, - .maxauthsize = SHA512_DIGEST_SIZE, - }, -@@ -4051,7 +4048,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = MD5_DIGEST_SIZE, - }, -@@ -4102,7 +4099,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = SHA1_DIGEST_SIZE, - }, -@@ -4153,7 +4150,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = SHA224_DIGEST_SIZE, - }, -@@ -4204,7 +4201,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = SHA256_DIGEST_SIZE, - }, -@@ -4255,7 +4252,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = SHA384_DIGEST_SIZE, - }, -@@ -4306,7 +4303,7 @@ static struct caam_aead_alg driver_aeads[] = { - .setkey = aead_setkey, - .setauthsize = aead_setauthsize, - .encrypt = aead_encrypt, -- .decrypt = aead_givdecrypt, -+ .decrypt = aead_decrypt, - .ivsize = CTR_RFC3686_IV_SIZE, - .maxauthsize = SHA512_DIGEST_SIZE, - }, -diff --git a/drivers/crypto/nx/nx-842-powernv.c b/drivers/crypto/nx/nx-842-powernv.c -index 9ef51fafdbff..6e105e87b8ff 100644 ---- a/drivers/crypto/nx/nx-842-powernv.c -+++ b/drivers/crypto/nx/nx-842-powernv.c -@@ -442,6 +442,14 @@ static int nx842_powernv_function(const unsigned char *in, unsigned int inlen, - (unsigned int)ccw, - (unsigned int)be32_to_cpu(crb->ccw)); - -+ /* -+ * NX842 coprocessor sets 3rd bit in CR register with XER[S0]. -+ * XER[S0] is the integer summary overflow bit which is nothing -+ * to do NX. Since this bit can be set with other return values, -+ * mask this bit. -+ */ -+ ret &= ~ICSWX_XERS0; -+ - switch (ret) { - case ICSWX_INITIATED: - ret = wait_for_csb(wmem, csb); -@@ -454,10 +462,6 @@ static int nx842_powernv_function(const unsigned char *in, unsigned int inlen, - pr_err_ratelimited("ICSWX rejected\n"); - ret = -EPROTO; - break; -- default: -- pr_err_ratelimited("Invalid ICSWX return code %x\n", ret); -- ret = -EPROTO; -- break; - } - - if (!ret) -diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c -index f3801b983f42..3f8bb9a40df1 100644 ---- a/drivers/crypto/vmx/aes_cbc.c -+++ b/drivers/crypto/vmx/aes_cbc.c -@@ -191,7 +191,7 @@ struct crypto_alg p8_aes_cbc_alg = { - .cra_init = p8_aes_cbc_init, - .cra_exit = p8_aes_cbc_exit, - .cra_blkcipher = { -- .ivsize = 0, -+ .ivsize = AES_BLOCK_SIZE, - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = p8_aes_cbc_setkey, -diff --git a/drivers/crypto/vmx/aes_ctr.c b/drivers/crypto/vmx/aes_ctr.c -index 404a1b69a3ab..72f138985e18 100644 ---- a/drivers/crypto/vmx/aes_ctr.c -+++ b/drivers/crypto/vmx/aes_ctr.c -@@ -175,7 +175,7 @@ struct crypto_alg p8_aes_ctr_alg = { - .cra_init = p8_aes_ctr_init, - .cra_exit = p8_aes_ctr_exit, - .cra_blkcipher = { -- .ivsize = 0, -+ .ivsize = AES_BLOCK_SIZE, - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = p8_aes_ctr_setkey, -diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl -index b9997335f193..b18e67d0e065 100644 ---- a/drivers/crypto/vmx/ppc-xlate.pl -+++ b/drivers/crypto/vmx/ppc-xlate.pl -@@ -139,6 +139,26 @@ my $vmr = sub { - " vor $vx,$vy,$vy"; - }; - -+# Some ABIs specify vrsave, special-purpose register #256, as reserved -+# for system use. -+my $no_vrsave = ($flavour =~ /linux-ppc64le/); -+my $mtspr = sub { -+ my ($f,$idx,$ra) = @_; -+ if ($idx == 256 && $no_vrsave) { -+ " or $ra,$ra,$ra"; -+ } else { -+ " mtspr $idx,$ra"; -+ } -+}; -+my $mfspr = sub { -+ my ($f,$rd,$idx) = @_; -+ if ($idx == 256 && $no_vrsave) { -+ " li $rd,-1"; -+ } else { -+ " mfspr $rd,$idx"; -+ } -+}; -+ - # PowerISA 2.06 stuff - sub vsxmem_op { - my ($f, $vrt, $ra, $rb, $op) = @_; -diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_dp.c b/drivers/gpu/drm/amd/amdgpu/atombios_dp.c -index 92b6acadfc52..21aacc1f45c1 100644 ---- a/drivers/gpu/drm/amd/amdgpu/atombios_dp.c -+++ b/drivers/gpu/drm/amd/amdgpu/atombios_dp.c -@@ -243,7 +243,7 @@ static void amdgpu_atombios_dp_get_adjust_train(const u8 link_status[DP_LINK_STA - - /* convert bits per color to bits per pixel */ - /* get bpc from the EDID */ --static int amdgpu_atombios_dp_convert_bpc_to_bpp(int bpc) -+static unsigned amdgpu_atombios_dp_convert_bpc_to_bpp(int bpc) - { - if (bpc == 0) - return 24; -@@ -251,64 +251,32 @@ static int amdgpu_atombios_dp_convert_bpc_to_bpp(int bpc) - return bpc * 3; - } - --/* get the max pix clock supported by the link rate and lane num */ --static int amdgpu_atombios_dp_get_max_dp_pix_clock(int link_rate, -- int lane_num, -- int bpp) --{ -- return (link_rate * lane_num * 8) / bpp; --} -- - /***** amdgpu specific DP functions *****/ - --/* First get the min lane# when low rate is used according to pixel clock -- * (prefer low rate), second check max lane# supported by DP panel, -- * if the max lane# < low rate lane# then use max lane# instead. -- */ --static int amdgpu_atombios_dp_get_dp_lane_number(struct drm_connector *connector, -+static int amdgpu_atombios_dp_get_dp_link_config(struct drm_connector *connector, - const u8 dpcd[DP_DPCD_SIZE], -- int pix_clock) --{ -- int bpp = amdgpu_atombios_dp_convert_bpc_to_bpp(amdgpu_connector_get_monitor_bpc(connector)); -- int max_link_rate = drm_dp_max_link_rate(dpcd); -- int max_lane_num = drm_dp_max_lane_count(dpcd); -- int lane_num; -- int max_dp_pix_clock; -- -- for (lane_num = 1; lane_num < max_lane_num; lane_num <<= 1) { -- max_dp_pix_clock = amdgpu_atombios_dp_get_max_dp_pix_clock(max_link_rate, lane_num, bpp); -- if (pix_clock <= max_dp_pix_clock) -- break; -- } -- -- return lane_num; --} -- --static int amdgpu_atombios_dp_get_dp_link_clock(struct drm_connector *connector, -- const u8 dpcd[DP_DPCD_SIZE], -- int pix_clock) -+ unsigned pix_clock, -+ unsigned *dp_lanes, unsigned *dp_rate) - { -- int bpp = amdgpu_atombios_dp_convert_bpc_to_bpp(amdgpu_connector_get_monitor_bpc(connector)); -- int lane_num, max_pix_clock; -- -- if (amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector) == -- ENCODER_OBJECT_ID_NUTMEG) -- return 270000; -- -- lane_num = amdgpu_atombios_dp_get_dp_lane_number(connector, dpcd, pix_clock); -- max_pix_clock = amdgpu_atombios_dp_get_max_dp_pix_clock(162000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 162000; -- max_pix_clock = amdgpu_atombios_dp_get_max_dp_pix_clock(270000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 270000; -- if (amdgpu_connector_is_dp12_capable(connector)) { -- max_pix_clock = amdgpu_atombios_dp_get_max_dp_pix_clock(540000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 540000; -+ unsigned bpp = -+ amdgpu_atombios_dp_convert_bpc_to_bpp(amdgpu_connector_get_monitor_bpc(connector)); -+ static const unsigned link_rates[3] = { 162000, 270000, 540000 }; -+ unsigned max_link_rate = drm_dp_max_link_rate(dpcd); -+ unsigned max_lane_num = drm_dp_max_lane_count(dpcd); -+ unsigned lane_num, i, max_pix_clock; -+ -+ for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) { -+ for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) { -+ max_pix_clock = (lane_num * link_rates[i] * 8) / bpp; -+ if (max_pix_clock >= pix_clock) { -+ *dp_lanes = lane_num; -+ *dp_rate = link_rates[i]; -+ return 0; -+ } -+ } - } - -- return drm_dp_max_link_rate(dpcd); -+ return -EINVAL; - } - - static u8 amdgpu_atombios_dp_encoder_service(struct amdgpu_device *adev, -@@ -422,6 +390,7 @@ void amdgpu_atombios_dp_set_link_config(struct drm_connector *connector, - { - struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); - struct amdgpu_connector_atom_dig *dig_connector; -+ int ret; - - if (!amdgpu_connector->con_priv) - return; -@@ -429,10 +398,14 @@ void amdgpu_atombios_dp_set_link_config(struct drm_connector *connector, - - if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || - (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) { -- dig_connector->dp_clock = -- amdgpu_atombios_dp_get_dp_link_clock(connector, dig_connector->dpcd, mode->clock); -- dig_connector->dp_lane_count = -- amdgpu_atombios_dp_get_dp_lane_number(connector, dig_connector->dpcd, mode->clock); -+ ret = amdgpu_atombios_dp_get_dp_link_config(connector, dig_connector->dpcd, -+ mode->clock, -+ &dig_connector->dp_lane_count, -+ &dig_connector->dp_clock); -+ if (ret) { -+ dig_connector->dp_clock = 0; -+ dig_connector->dp_lane_count = 0; -+ } - } - } - -@@ -441,14 +414,17 @@ int amdgpu_atombios_dp_mode_valid_helper(struct drm_connector *connector, - { - struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); - struct amdgpu_connector_atom_dig *dig_connector; -- int dp_clock; -+ unsigned dp_lanes, dp_clock; -+ int ret; - - if (!amdgpu_connector->con_priv) - return MODE_CLOCK_HIGH; - dig_connector = amdgpu_connector->con_priv; - -- dp_clock = -- amdgpu_atombios_dp_get_dp_link_clock(connector, dig_connector->dpcd, mode->clock); -+ ret = amdgpu_atombios_dp_get_dp_link_config(connector, dig_connector->dpcd, -+ mode->clock, &dp_lanes, &dp_clock); -+ if (ret) -+ return MODE_CLOCK_HIGH; - - if ((dp_clock == 540000) && - (!amdgpu_connector_is_dp12_capable(connector))) -diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c -index 8035d4d6a4f5..653917a3bcc2 100644 ---- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c -+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c -@@ -1955,10 +1955,8 @@ static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate) - } - } else { /*pi->caps_vce_pg*/ - cz_update_vce_dpm(adev); -- cz_enable_vce_dpm(adev, true); -+ cz_enable_vce_dpm(adev, !gate); - } -- -- return; - } - - const struct amd_ip_funcs cz_dpm_ip_funcs = { -diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c -index e5aec45bf985..1ac29d703c12 100644 ---- a/drivers/gpu/drm/drm_atomic_helper.c -+++ b/drivers/gpu/drm/drm_atomic_helper.c -@@ -108,7 +108,6 @@ steal_encoder(struct drm_atomic_state *state, - struct drm_crtc_state *crtc_state; - struct drm_connector *connector; - struct drm_connector_state *connector_state; -- int ret; - - /* - * We can only steal an encoder coming from a connector, which means we -@@ -139,9 +138,6 @@ steal_encoder(struct drm_atomic_state *state, - if (IS_ERR(connector_state)) - return PTR_ERR(connector_state); - -- ret = drm_atomic_set_crtc_for_connector(connector_state, NULL); -- if (ret) -- return ret; - connector_state->best_encoder = NULL; - } - -diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c -index dc84003f694e..5e4bb4837bae 100644 ---- a/drivers/gpu/drm/drm_crtc.c -+++ b/drivers/gpu/drm/drm_crtc.c -@@ -5231,6 +5231,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, - unsigned long flags; - int ret = -EINVAL; - -+ if (!drm_core_check_feature(dev, DRIVER_MODESET)) -+ return -EINVAL; -+ - if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || - page_flip->reserved != 0) - return -EINVAL; -diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c -index c7de454e8e88..b205224f1a44 100644 ---- a/drivers/gpu/drm/drm_gem.c -+++ b/drivers/gpu/drm/drm_gem.c -@@ -338,27 +338,32 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, - spin_unlock(&file_priv->table_lock); - idr_preload_end(); - mutex_unlock(&dev->object_name_lock); -- if (ret < 0) { -- drm_gem_object_handle_unreference_unlocked(obj); -- return ret; -- } -+ if (ret < 0) -+ goto err_unref; -+ - *handlep = ret; - - ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp); -- if (ret) { -- drm_gem_handle_delete(file_priv, *handlep); -- return ret; -- } -+ if (ret) -+ goto err_remove; - - if (dev->driver->gem_open_object) { - ret = dev->driver->gem_open_object(obj, file_priv); -- if (ret) { -- drm_gem_handle_delete(file_priv, *handlep); -- return ret; -- } -+ if (ret) -+ goto err_revoke; - } - - return 0; -+ -+err_revoke: -+ drm_vma_node_revoke(&obj->vma_node, file_priv->filp); -+err_remove: -+ spin_lock(&file_priv->table_lock); -+ idr_remove(&file_priv->object_idr, *handlep); -+ spin_unlock(&file_priv->table_lock); -+err_unref: -+ drm_gem_object_handle_unreference_unlocked(obj); -+ return ret; - } - - /** -diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h -index d3ce4da6a6ad..d400d6773bbb 100644 ---- a/drivers/gpu/drm/i915/i915_drv.h -+++ b/drivers/gpu/drm/i915/i915_drv.h -@@ -3313,6 +3313,9 @@ static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter) - } - extern void intel_i2c_reset(struct drm_device *dev); - -+/* intel_bios.c */ -+bool intel_bios_is_port_present(struct drm_i915_private *dev_priv, enum port port); -+ - /* intel_opregion.c */ - #ifdef CONFIG_ACPI - extern int intel_opregion_setup(struct drm_device *dev); -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h -index 9ed9f6dde86f..cace154bbdc0 100644 ---- a/drivers/gpu/drm/i915/i915_reg.h -+++ b/drivers/gpu/drm/i915/i915_reg.h -@@ -3240,19 +3240,20 @@ enum skl_disp_power_wells { - - #define PORT_HOTPLUG_STAT (dev_priv->info.display_mmio_offset + 0x61114) - /* -- * HDMI/DP bits are gen4+ -+ * HDMI/DP bits are g4x+ - * - * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused. - * Please check the detailed lore in the commit message for for experimental - * evidence. - */ --#define PORTD_HOTPLUG_LIVE_STATUS_G4X (1 << 29) -+/* Bspec says GM45 should match G4X/VLV/CHV, but reality disagrees */ -+#define PORTD_HOTPLUG_LIVE_STATUS_GM45 (1 << 29) -+#define PORTC_HOTPLUG_LIVE_STATUS_GM45 (1 << 28) -+#define PORTB_HOTPLUG_LIVE_STATUS_GM45 (1 << 27) -+/* G4X/VLV/CHV DP/HDMI bits again match Bspec */ -+#define PORTD_HOTPLUG_LIVE_STATUS_G4X (1 << 27) - #define PORTC_HOTPLUG_LIVE_STATUS_G4X (1 << 28) --#define PORTB_HOTPLUG_LIVE_STATUS_G4X (1 << 27) --/* VLV DP/HDMI bits again match Bspec */ --#define PORTD_HOTPLUG_LIVE_STATUS_VLV (1 << 27) --#define PORTC_HOTPLUG_LIVE_STATUS_VLV (1 << 28) --#define PORTB_HOTPLUG_LIVE_STATUS_VLV (1 << 29) -+#define PORTB_HOTPLUG_LIVE_STATUS_G4X (1 << 29) - #define PORTD_HOTPLUG_INT_STATUS (3 << 21) - #define PORTD_HOTPLUG_INT_LONG_PULSE (2 << 21) - #define PORTD_HOTPLUG_INT_SHORT_PULSE (1 << 21) -diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c -index ce82f9c7df24..d14bdc537587 100644 ---- a/drivers/gpu/drm/i915/intel_bios.c -+++ b/drivers/gpu/drm/i915/intel_bios.c -@@ -1351,3 +1351,42 @@ intel_parse_bios(struct drm_device *dev) - - return 0; - } -+ -+/** -+ * intel_bios_is_port_present - is the specified digital port present -+ * @dev_priv: i915 device instance -+ * @port: port to check -+ * -+ * Return true if the device in %port is present. -+ */ -+bool intel_bios_is_port_present(struct drm_i915_private *dev_priv, enum port port) -+{ -+ static const struct { -+ u16 dp, hdmi; -+ } port_mapping[] = { -+ [PORT_B] = { DVO_PORT_DPB, DVO_PORT_HDMIB, }, -+ [PORT_C] = { DVO_PORT_DPC, DVO_PORT_HDMIC, }, -+ [PORT_D] = { DVO_PORT_DPD, DVO_PORT_HDMID, }, -+ [PORT_E] = { DVO_PORT_DPE, DVO_PORT_HDMIE, }, -+ }; -+ int i; -+ -+ /* FIXME maybe deal with port A as well? */ -+ if (WARN_ON(port == PORT_A) || port >= ARRAY_SIZE(port_mapping)) -+ return false; -+ -+ if (!dev_priv->vbt.child_dev_num) -+ return false; -+ -+ for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { -+ const union child_device_config *p_child = -+ &dev_priv->vbt.child_dev[i]; -+ if ((p_child->common.dvo_port == port_mapping[port].dp || -+ p_child->common.dvo_port == port_mapping[port].hdmi) && -+ (p_child->common.device_type & (DEVICE_TYPE_TMDS_DVI_SIGNALING | -+ DEVICE_TYPE_DISPLAYPORT_OUTPUT))) -+ return true; -+ } -+ -+ return false; -+} -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c -index 3292495ee10f..a3254c3bcc7c 100644 ---- a/drivers/gpu/drm/i915/intel_display.c -+++ b/drivers/gpu/drm/i915/intel_display.c -@@ -14160,6 +14160,8 @@ static void intel_setup_outputs(struct drm_device *dev) - if (I915_READ(PCH_DP_D) & DP_DETECTED) - intel_dp_init(dev, PCH_DP_D, PORT_D); - } else if (IS_VALLEYVIEW(dev)) { -+ bool has_edp, has_port; -+ - /* - * The DP_DETECTED bit is the latched state of the DDC - * SDA pin at boot. However since eDP doesn't require DDC -@@ -14168,27 +14170,37 @@ static void intel_setup_outputs(struct drm_device *dev) - * Thus we can't rely on the DP_DETECTED bit alone to detect - * eDP ports. Consult the VBT as well as DP_DETECTED to - * detect eDP ports. -+ * -+ * Sadly the straps seem to be missing sometimes even for HDMI -+ * ports (eg. on Voyo V3 - CHT x7-Z8700), so check both strap -+ * and VBT for the presence of the port. Additionally we can't -+ * trust the port type the VBT declares as we've seen at least -+ * HDMI ports that the VBT claim are DP or eDP. - */ -- if (I915_READ(VLV_HDMIB) & SDVO_DETECTED && -- !intel_dp_is_edp(dev, PORT_B)) -+ has_edp = intel_dp_is_edp(dev, PORT_B); -+ has_port = intel_bios_is_port_present(dev_priv, PORT_B); -+ if (I915_READ(VLV_DP_B) & DP_DETECTED || has_port) -+ has_edp &= intel_dp_init(dev, VLV_DP_B, PORT_B); -+ if ((I915_READ(VLV_HDMIB) & SDVO_DETECTED || has_port) && !has_edp) - intel_hdmi_init(dev, VLV_HDMIB, PORT_B); -- if (I915_READ(VLV_DP_B) & DP_DETECTED || -- intel_dp_is_edp(dev, PORT_B)) -- intel_dp_init(dev, VLV_DP_B, PORT_B); - -- if (I915_READ(VLV_HDMIC) & SDVO_DETECTED && -- !intel_dp_is_edp(dev, PORT_C)) -+ has_edp = intel_dp_is_edp(dev, PORT_C); -+ has_port = intel_bios_is_port_present(dev_priv, PORT_C); -+ if (I915_READ(VLV_DP_C) & DP_DETECTED || has_port) -+ has_edp &= intel_dp_init(dev, VLV_DP_C, PORT_C); -+ if ((I915_READ(VLV_HDMIC) & SDVO_DETECTED || has_port) && !has_edp) - intel_hdmi_init(dev, VLV_HDMIC, PORT_C); -- if (I915_READ(VLV_DP_C) & DP_DETECTED || -- intel_dp_is_edp(dev, PORT_C)) -- intel_dp_init(dev, VLV_DP_C, PORT_C); - - if (IS_CHERRYVIEW(dev)) { -- /* eDP not supported on port D, so don't check VBT */ -- if (I915_READ(CHV_HDMID) & SDVO_DETECTED) -- intel_hdmi_init(dev, CHV_HDMID, PORT_D); -- if (I915_READ(CHV_DP_D) & DP_DETECTED) -+ /* -+ * eDP not supported on port D, -+ * so no need to worry about it -+ */ -+ has_port = intel_bios_is_port_present(dev_priv, PORT_D); -+ if (I915_READ(CHV_DP_D) & DP_DETECTED || has_port) - intel_dp_init(dev, CHV_DP_D, PORT_D); -+ if (I915_READ(CHV_HDMID) & SDVO_DETECTED || has_port) -+ intel_hdmi_init(dev, CHV_HDMID, PORT_D); - } - - intel_dsi_init(dev); -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c -index 8e1d6d74c203..ebbd23407a80 100644 ---- a/drivers/gpu/drm/i915/intel_dp.c -+++ b/drivers/gpu/drm/i915/intel_dp.c -@@ -4592,20 +4592,20 @@ static bool g4x_digital_port_connected(struct drm_i915_private *dev_priv, - return I915_READ(PORT_HOTPLUG_STAT) & bit; - } - --static bool vlv_digital_port_connected(struct drm_i915_private *dev_priv, -- struct intel_digital_port *port) -+static bool gm45_digital_port_connected(struct drm_i915_private *dev_priv, -+ struct intel_digital_port *port) - { - u32 bit; - - switch (port->port) { - case PORT_B: -- bit = PORTB_HOTPLUG_LIVE_STATUS_VLV; -+ bit = PORTB_HOTPLUG_LIVE_STATUS_GM45; - break; - case PORT_C: -- bit = PORTC_HOTPLUG_LIVE_STATUS_VLV; -+ bit = PORTC_HOTPLUG_LIVE_STATUS_GM45; - break; - case PORT_D: -- bit = PORTD_HOTPLUG_LIVE_STATUS_VLV; -+ bit = PORTD_HOTPLUG_LIVE_STATUS_GM45; - break; - default: - MISSING_CASE(port->port); -@@ -4657,8 +4657,8 @@ bool intel_digital_port_connected(struct drm_i915_private *dev_priv, - return cpt_digital_port_connected(dev_priv, port); - else if (IS_BROXTON(dev_priv)) - return bxt_digital_port_connected(dev_priv, port); -- else if (IS_VALLEYVIEW(dev_priv)) -- return vlv_digital_port_connected(dev_priv, port); -+ else if (IS_GM45(dev_priv)) -+ return gm45_digital_port_connected(dev_priv, port); - else - return g4x_digital_port_connected(dev_priv, port); - } -@@ -6113,8 +6113,9 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, - return true; - } - --void --intel_dp_init(struct drm_device *dev, int output_reg, enum port port) -+bool intel_dp_init(struct drm_device *dev, -+ int output_reg, -+ enum port port) - { - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_digital_port *intel_dig_port; -@@ -6124,7 +6125,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) - - intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); - if (!intel_dig_port) -- return; -+ return false; - - intel_connector = intel_connector_alloc(); - if (!intel_connector) -@@ -6179,15 +6180,14 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) - if (!intel_dp_init_connector(intel_dig_port, intel_connector)) - goto err_init_connector; - -- return; -+ return true; - - err_init_connector: - drm_encoder_cleanup(encoder); - kfree(intel_connector); - err_connector_alloc: - kfree(intel_dig_port); -- -- return; -+ return false; - } - - void intel_dp_mst_suspend(struct drm_device *dev) -diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h -index c5f11e0c5d5b..67f72a7ee7cb 100644 ---- a/drivers/gpu/drm/i915/intel_drv.h -+++ b/drivers/gpu/drm/i915/intel_drv.h -@@ -1195,7 +1195,7 @@ void intel_csr_ucode_fini(struct drm_device *dev); - void assert_csr_loaded(struct drm_i915_private *dev_priv); - - /* intel_dp.c */ --void intel_dp_init(struct drm_device *dev, int output_reg, enum port port); -+bool intel_dp_init(struct drm_device *dev, int output_reg, enum port port); - bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port, - struct intel_connector *intel_connector); - void intel_dp_set_link_params(struct intel_dp *intel_dp, -diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c -index 4b8ed9f2dabc..dff69fef47e0 100644 ---- a/drivers/gpu/drm/i915/intel_hdmi.c -+++ b/drivers/gpu/drm/i915/intel_hdmi.c -@@ -2030,6 +2030,9 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, - enum port port = intel_dig_port->port; - uint8_t alternate_ddc_pin; - -+ DRM_DEBUG_KMS("Adding HDMI connector on port %c\n", -+ port_name(port)); -+ - drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, - DRM_MODE_CONNECTOR_HDMIA); - drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); -diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c -index 6d7cd3fe21e7..1847f83b1e33 100644 ---- a/drivers/gpu/drm/msm/msm_gem_submit.c -+++ b/drivers/gpu/drm/msm/msm_gem_submit.c -@@ -55,6 +55,14 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev, - return submit; - } - -+static inline unsigned long __must_check -+copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) -+{ -+ if (access_ok(VERIFY_READ, from, n)) -+ return __copy_from_user_inatomic(to, from, n); -+ return -EFAULT; -+} -+ - static int submit_lookup_objects(struct msm_gem_submit *submit, - struct drm_msm_gem_submit *args, struct drm_file *file) - { -@@ -62,6 +70,7 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, - int ret = 0; - - spin_lock(&file->table_lock); -+ pagefault_disable(); - - for (i = 0; i < args->nr_bos; i++) { - struct drm_msm_gem_submit_bo submit_bo; -@@ -70,10 +79,15 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, - void __user *userptr = - to_user_ptr(args->bos + (i * sizeof(submit_bo))); - -- ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); -- if (ret) { -- ret = -EFAULT; -- goto out_unlock; -+ ret = copy_from_user_inatomic(&submit_bo, userptr, sizeof(submit_bo)); -+ if (unlikely(ret)) { -+ pagefault_enable(); -+ spin_unlock(&file->table_lock); -+ ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); -+ if (ret) -+ goto out; -+ spin_lock(&file->table_lock); -+ pagefault_disable(); - } - - if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { -@@ -113,9 +127,12 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, - } - - out_unlock: -- submit->nr_bos = i; -+ pagefault_enable(); - spin_unlock(&file->table_lock); - -+out: -+ submit->nr_bos = i; -+ - return ret; - } - -diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c -index bd73b4069069..44ee72e04df9 100644 ---- a/drivers/gpu/drm/radeon/atombios_dp.c -+++ b/drivers/gpu/drm/radeon/atombios_dp.c -@@ -302,77 +302,31 @@ static int convert_bpc_to_bpp(int bpc) - return bpc * 3; - } - --/* get the max pix clock supported by the link rate and lane num */ --static int dp_get_max_dp_pix_clock(int link_rate, -- int lane_num, -- int bpp) --{ -- return (link_rate * lane_num * 8) / bpp; --} -- - /***** radeon specific DP functions *****/ - --int radeon_dp_get_max_link_rate(struct drm_connector *connector, -- const u8 dpcd[DP_DPCD_SIZE]) --{ -- int max_link_rate; -- -- if (radeon_connector_is_dp12_capable(connector)) -- max_link_rate = min(drm_dp_max_link_rate(dpcd), 540000); -- else -- max_link_rate = min(drm_dp_max_link_rate(dpcd), 270000); -- -- return max_link_rate; --} -- --/* First get the min lane# when low rate is used according to pixel clock -- * (prefer low rate), second check max lane# supported by DP panel, -- * if the max lane# < low rate lane# then use max lane# instead. -- */ --static int radeon_dp_get_dp_lane_number(struct drm_connector *connector, -- const u8 dpcd[DP_DPCD_SIZE], -- int pix_clock) --{ -- int bpp = convert_bpc_to_bpp(radeon_get_monitor_bpc(connector)); -- int max_link_rate = radeon_dp_get_max_link_rate(connector, dpcd); -- int max_lane_num = drm_dp_max_lane_count(dpcd); -- int lane_num; -- int max_dp_pix_clock; -- -- for (lane_num = 1; lane_num < max_lane_num; lane_num <<= 1) { -- max_dp_pix_clock = dp_get_max_dp_pix_clock(max_link_rate, lane_num, bpp); -- if (pix_clock <= max_dp_pix_clock) -- break; -- } -- -- return lane_num; --} -- --static int radeon_dp_get_dp_link_clock(struct drm_connector *connector, -- const u8 dpcd[DP_DPCD_SIZE], -- int pix_clock) -+int radeon_dp_get_dp_link_config(struct drm_connector *connector, -+ const u8 dpcd[DP_DPCD_SIZE], -+ unsigned pix_clock, -+ unsigned *dp_lanes, unsigned *dp_rate) - { - int bpp = convert_bpc_to_bpp(radeon_get_monitor_bpc(connector)); -- int lane_num, max_pix_clock; -- -- if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) == -- ENCODER_OBJECT_ID_NUTMEG) -- return 270000; -- -- lane_num = radeon_dp_get_dp_lane_number(connector, dpcd, pix_clock); -- max_pix_clock = dp_get_max_dp_pix_clock(162000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 162000; -- max_pix_clock = dp_get_max_dp_pix_clock(270000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 270000; -- if (radeon_connector_is_dp12_capable(connector)) { -- max_pix_clock = dp_get_max_dp_pix_clock(540000, lane_num, bpp); -- if (pix_clock <= max_pix_clock) -- return 540000; -+ static const unsigned link_rates[3] = { 162000, 270000, 540000 }; -+ unsigned max_link_rate = drm_dp_max_link_rate(dpcd); -+ unsigned max_lane_num = drm_dp_max_lane_count(dpcd); -+ unsigned lane_num, i, max_pix_clock; -+ -+ for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) { -+ for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) { -+ max_pix_clock = (lane_num * link_rates[i] * 8) / bpp; -+ if (max_pix_clock >= pix_clock) { -+ *dp_lanes = lane_num; -+ *dp_rate = link_rates[i]; -+ return 0; -+ } -+ } - } - -- return radeon_dp_get_max_link_rate(connector, dpcd); -+ return -EINVAL; - } - - static u8 radeon_dp_encoder_service(struct radeon_device *rdev, -@@ -491,6 +445,7 @@ void radeon_dp_set_link_config(struct drm_connector *connector, - { - struct radeon_connector *radeon_connector = to_radeon_connector(connector); - struct radeon_connector_atom_dig *dig_connector; -+ int ret; - - if (!radeon_connector->con_priv) - return; -@@ -498,10 +453,14 @@ void radeon_dp_set_link_config(struct drm_connector *connector, - - if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || - (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) { -- dig_connector->dp_clock = -- radeon_dp_get_dp_link_clock(connector, dig_connector->dpcd, mode->clock); -- dig_connector->dp_lane_count = -- radeon_dp_get_dp_lane_number(connector, dig_connector->dpcd, mode->clock); -+ ret = radeon_dp_get_dp_link_config(connector, dig_connector->dpcd, -+ mode->clock, -+ &dig_connector->dp_lane_count, -+ &dig_connector->dp_clock); -+ if (ret) { -+ dig_connector->dp_clock = 0; -+ dig_connector->dp_lane_count = 0; -+ } - } - } - -@@ -510,7 +469,8 @@ int radeon_dp_mode_valid_helper(struct drm_connector *connector, - { - struct radeon_connector *radeon_connector = to_radeon_connector(connector); - struct radeon_connector_atom_dig *dig_connector; -- int dp_clock; -+ unsigned dp_clock, dp_lanes; -+ int ret; - - if ((mode->clock > 340000) && - (!radeon_connector_is_dp12_capable(connector))) -@@ -520,8 +480,12 @@ int radeon_dp_mode_valid_helper(struct drm_connector *connector, - return MODE_CLOCK_HIGH; - dig_connector = radeon_connector->con_priv; - -- dp_clock = -- radeon_dp_get_dp_link_clock(connector, dig_connector->dpcd, mode->clock); -+ ret = radeon_dp_get_dp_link_config(connector, dig_connector->dpcd, -+ mode->clock, -+ &dp_lanes, -+ &dp_clock); -+ if (ret) -+ return MODE_CLOCK_HIGH; - - if ((dp_clock == 540000) && - (!radeon_connector_is_dp12_capable(connector))) -diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c -index 744f5c49c664..6dd39bdedb97 100644 ---- a/drivers/gpu/drm/radeon/radeon_dp_mst.c -+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c -@@ -525,11 +525,9 @@ static bool radeon_mst_mode_fixup(struct drm_encoder *encoder, - drm_mode_set_crtcinfo(adjusted_mode, 0); - { - struct radeon_connector_atom_dig *dig_connector; -- - dig_connector = mst_enc->connector->con_priv; - dig_connector->dp_lane_count = drm_dp_max_lane_count(dig_connector->dpcd); -- dig_connector->dp_clock = radeon_dp_get_max_link_rate(&mst_enc->connector->base, -- dig_connector->dpcd); -+ dig_connector->dp_clock = drm_dp_max_link_rate(dig_connector->dpcd); - DRM_DEBUG_KMS("dig clock %p %d %d\n", dig_connector, - dig_connector->dp_lane_count, dig_connector->dp_clock); - } -diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h -index bba112628b47..7a0666ac4e23 100644 ---- a/drivers/gpu/drm/radeon/radeon_mode.h -+++ b/drivers/gpu/drm/radeon/radeon_mode.h -@@ -757,8 +757,10 @@ extern u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector); - extern bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector); - extern int radeon_dp_get_panel_mode(struct drm_encoder *encoder, - struct drm_connector *connector); --int radeon_dp_get_max_link_rate(struct drm_connector *connector, -- const u8 *dpcd); -+extern int radeon_dp_get_dp_link_config(struct drm_connector *connector, -+ const u8 *dpcd, -+ unsigned pix_clock, -+ unsigned *dp_lanes, unsigned *dp_rate); - extern void radeon_dp_set_rx_power_state(struct drm_connector *connector, - u8 power_state); - extern void radeon_dp_aux_init(struct radeon_connector *radeon_connector); -diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c -index f342aad79cc6..35310336dd0a 100644 ---- a/drivers/gpu/drm/radeon/radeon_ttm.c -+++ b/drivers/gpu/drm/radeon/radeon_ttm.c -@@ -263,8 +263,8 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, - - rdev = radeon_get_rdev(bo->bdev); - ridx = radeon_copy_ring_index(rdev); -- old_start = old_mem->start << PAGE_SHIFT; -- new_start = new_mem->start << PAGE_SHIFT; -+ old_start = (u64)old_mem->start << PAGE_SHIFT; -+ new_start = (u64)new_mem->start << PAGE_SHIFT; - - switch (old_mem->mem_type) { - case TTM_PL_VRAM: -diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c -index ec791e169f8f..936960202cf4 100644 ---- a/drivers/hid/hid-core.c -+++ b/drivers/hid/hid-core.c -@@ -1251,6 +1251,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, - /* Ignore report if ErrorRollOver */ - if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && - value[n] >= min && value[n] <= max && -+ value[n] - min < field->maxusage && - field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) - goto exit; - } -@@ -1263,11 +1264,13 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, - } - - if (field->value[n] >= min && field->value[n] <= max -+ && field->value[n] - min < field->maxusage - && field->usage[field->value[n] - min].hid - && search(value, field->value[n], count)) - hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); - - if (value[n] >= min && value[n] <= max -+ && value[n] - min < field->maxusage - && field->usage[value[n] - min].hid - && search(field->value, value[n], count)) - hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); -diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c -index 9098f13f2f44..1ef37c727572 100644 ---- a/drivers/hv/channel.c -+++ b/drivers/hv/channel.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - - #include "hyperv_vmbus.h" - -@@ -496,8 +497,21 @@ static void reset_channel_cb(void *arg) - static int vmbus_close_internal(struct vmbus_channel *channel) - { - struct vmbus_channel_close_channel *msg; -+ struct tasklet_struct *tasklet; - int ret; - -+ /* -+ * process_chn_event(), running in the tasklet, can race -+ * with vmbus_close_internal() in the case of SMP guest, e.g., when -+ * the former is accessing channel->inbound.ring_buffer, the latter -+ * could be freeing the ring_buffer pages. -+ * -+ * To resolve the race, we can serialize them by disabling the -+ * tasklet when the latter is running here. -+ */ -+ tasklet = hv_context.event_dpc[channel->target_cpu]; -+ tasklet_disable(tasklet); -+ - channel->state = CHANNEL_OPEN_STATE; - channel->sc_creation_callback = NULL; - /* Stop callback and cancel the timer asap */ -@@ -525,7 +539,7 @@ static int vmbus_close_internal(struct vmbus_channel *channel) - * If we failed to post the close msg, - * it is perhaps better to leak memory. - */ -- return ret; -+ goto out; - } - - /* Tear down the gpadl for the channel's ring buffer */ -@@ -538,7 +552,7 @@ static int vmbus_close_internal(struct vmbus_channel *channel) - * If we failed to teardown gpadl, - * it is perhaps better to leak memory. - */ -- return ret; -+ goto out; - } - } - -@@ -549,12 +563,9 @@ static int vmbus_close_internal(struct vmbus_channel *channel) - free_pages((unsigned long)channel->ringbuffer_pages, - get_order(channel->ringbuffer_pagecount * PAGE_SIZE)); - -- /* -- * If the channel has been rescinded; process device removal. -- */ -- if (channel->rescind) -- hv_process_channel_removal(channel, -- channel->offermsg.child_relid); -+out: -+ tasklet_enable(tasklet); -+ - return ret; - } - -diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c -index 652afd11a9ef..37238dffd947 100644 ---- a/drivers/hv/channel_mgmt.c -+++ b/drivers/hv/channel_mgmt.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - - #include "hyperv_vmbus.h" -@@ -191,6 +192,8 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid) - if (channel == NULL) - return; - -+ BUG_ON(!channel->rescind); -+ - if (channel->target_cpu != get_cpu()) { - put_cpu(); - smp_call_function_single(channel->target_cpu, -@@ -230,9 +233,7 @@ void vmbus_free_channels(void) - - list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list, - listentry) { -- /* if we don't set rescind to true, vmbus_close_internal() -- * won't invoke hv_process_channel_removal(). -- */ -+ /* hv_process_channel_removal() needs this */ - channel->rescind = true; - - vmbus_device_unregister(channel->device_obj); -@@ -459,6 +460,17 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui - cpumask_of_node(primary->numa_node)); - - cur_cpu = -1; -+ -+ /* -+ * Normally Hyper-V host doesn't create more subchannels than there -+ * are VCPUs on the node but it is possible when not all present VCPUs -+ * on the node are initialized by guest. Clear the alloced_cpus_in_node -+ * to start over. -+ */ -+ if (cpumask_equal(&primary->alloced_cpus_in_node, -+ cpumask_of_node(primary->numa_node))) -+ cpumask_clear(&primary->alloced_cpus_in_node); -+ - while (true) { - cur_cpu = cpumask_next(cur_cpu, &available_mask); - if (cur_cpu >= nr_cpu_ids) { -@@ -488,6 +500,40 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui - channel->target_vp = hv_context.vp_index[cur_cpu]; - } - -+static void vmbus_wait_for_unload(void) -+{ -+ int cpu = smp_processor_id(); -+ void *page_addr = hv_context.synic_message_page[cpu]; -+ struct hv_message *msg = (struct hv_message *)page_addr + -+ VMBUS_MESSAGE_SINT; -+ struct vmbus_channel_message_header *hdr; -+ bool unloaded = false; -+ -+ while (1) { -+ if (msg->header.message_type == HVMSG_NONE) { -+ mdelay(10); -+ continue; -+ } -+ -+ hdr = (struct vmbus_channel_message_header *)msg->u.payload; -+ if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE) -+ unloaded = true; -+ -+ msg->header.message_type = HVMSG_NONE; -+ /* -+ * header.message_type needs to be written before we do -+ * wrmsrl() below. -+ */ -+ mb(); -+ -+ if (msg->header.message_flags.msg_pending) -+ wrmsrl(HV_X64_MSR_EOM, 0); -+ -+ if (unloaded) -+ break; -+ } -+} -+ - /* - * vmbus_unload_response - Handler for the unload response. - */ -@@ -513,7 +559,14 @@ void vmbus_initiate_unload(void) - hdr.msgtype = CHANNELMSG_UNLOAD; - vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header)); - -- wait_for_completion(&vmbus_connection.unload_event); -+ /* -+ * vmbus_initiate_unload() is also called on crash and the crash can be -+ * happening in an interrupt context, where scheduling is impossible. -+ */ -+ if (!in_interrupt()) -+ wait_for_completion(&vmbus_connection.unload_event); -+ else -+ vmbus_wait_for_unload(); - } - - /* -diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c -index 6341be8739ae..63194a9a7189 100644 ---- a/drivers/hv/hv.c -+++ b/drivers/hv/hv.c -@@ -293,8 +293,14 @@ void hv_cleanup(void) - * Cleanup the TSC page based CS. - */ - if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) { -- clocksource_change_rating(&hyperv_cs_tsc, 10); -- clocksource_unregister(&hyperv_cs_tsc); -+ /* -+ * Crash can happen in an interrupt context and unregistering -+ * a clocksource is impossible and redundant in this case. -+ */ -+ if (!oops_in_progress) { -+ clocksource_change_rating(&hyperv_cs_tsc, 10); -+ clocksource_unregister(&hyperv_cs_tsc); -+ } - - hypercall_msr.as_uint64 = 0; - wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64); -diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c -index db4b887b889d..c37a71e13de0 100644 ---- a/drivers/hv/hv_fcopy.c -+++ b/drivers/hv/hv_fcopy.c -@@ -51,7 +51,6 @@ static struct { - struct hv_fcopy_hdr *fcopy_msg; /* current message */ - struct vmbus_channel *recv_channel; /* chn we got the request */ - u64 recv_req_id; /* request ID. */ -- void *fcopy_context; /* for the channel callback */ - } fcopy_transaction; - - static void fcopy_respond_to_host(int error); -@@ -67,6 +66,13 @@ static struct hvutil_transport *hvt; - */ - static int dm_reg_value; - -+static void fcopy_poll_wrapper(void *channel) -+{ -+ /* Transaction is finished, reset the state here to avoid races. */ -+ fcopy_transaction.state = HVUTIL_READY; -+ hv_fcopy_onchannelcallback(channel); -+} -+ - static void fcopy_timeout_func(struct work_struct *dummy) - { - /* -@@ -74,13 +80,7 @@ static void fcopy_timeout_func(struct work_struct *dummy) - * process the pending transaction. - */ - fcopy_respond_to_host(HV_E_FAIL); -- -- /* Transaction is finished, reset the state. */ -- if (fcopy_transaction.state > HVUTIL_READY) -- fcopy_transaction.state = HVUTIL_READY; -- -- hv_poll_channel(fcopy_transaction.fcopy_context, -- hv_fcopy_onchannelcallback); -+ hv_poll_channel(fcopy_transaction.recv_channel, fcopy_poll_wrapper); - } - - static int fcopy_handle_handshake(u32 version) -@@ -108,9 +108,7 @@ static int fcopy_handle_handshake(u32 version) - return -EINVAL; - } - pr_debug("FCP: userspace daemon ver. %d registered\n", version); -- fcopy_transaction.state = HVUTIL_READY; -- hv_poll_channel(fcopy_transaction.fcopy_context, -- hv_fcopy_onchannelcallback); -+ hv_poll_channel(fcopy_transaction.recv_channel, fcopy_poll_wrapper); - return 0; - } - -@@ -227,15 +225,8 @@ void hv_fcopy_onchannelcallback(void *context) - int util_fw_version; - int fcopy_srv_version; - -- if (fcopy_transaction.state > HVUTIL_READY) { -- /* -- * We will defer processing this callback once -- * the current transaction is complete. -- */ -- fcopy_transaction.fcopy_context = context; -+ if (fcopy_transaction.state > HVUTIL_READY) - return; -- } -- fcopy_transaction.fcopy_context = NULL; - - vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, - &requestid); -@@ -275,7 +266,8 @@ void hv_fcopy_onchannelcallback(void *context) - * Send the information to the user-level daemon. - */ - schedule_work(&fcopy_send_work); -- schedule_delayed_work(&fcopy_timeout_work, 5*HZ); -+ schedule_delayed_work(&fcopy_timeout_work, -+ HV_UTIL_TIMEOUT * HZ); - return; - } - icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; -@@ -304,9 +296,8 @@ static int fcopy_on_msg(void *msg, int len) - if (cancel_delayed_work_sync(&fcopy_timeout_work)) { - fcopy_transaction.state = HVUTIL_USERSPACE_RECV; - fcopy_respond_to_host(*val); -- fcopy_transaction.state = HVUTIL_READY; -- hv_poll_channel(fcopy_transaction.fcopy_context, -- hv_fcopy_onchannelcallback); -+ hv_poll_channel(fcopy_transaction.recv_channel, -+ fcopy_poll_wrapper); - } - - return 0; -diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c -index 74c38a9f34a6..2a3420c4ca59 100644 ---- a/drivers/hv/hv_kvp.c -+++ b/drivers/hv/hv_kvp.c -@@ -66,7 +66,6 @@ static struct { - struct hv_kvp_msg *kvp_msg; /* current message */ - struct vmbus_channel *recv_channel; /* chn we got the request */ - u64 recv_req_id; /* request ID. */ -- void *kvp_context; /* for the channel callback */ - } kvp_transaction; - - /* -@@ -94,6 +93,13 @@ static struct hvutil_transport *hvt; - */ - #define HV_DRV_VERSION "3.1" - -+static void kvp_poll_wrapper(void *channel) -+{ -+ /* Transaction is finished, reset the state here to avoid races. */ -+ kvp_transaction.state = HVUTIL_READY; -+ hv_kvp_onchannelcallback(channel); -+} -+ - static void - kvp_register(int reg_value) - { -@@ -121,12 +127,7 @@ static void kvp_timeout_func(struct work_struct *dummy) - */ - kvp_respond_to_host(NULL, HV_E_FAIL); - -- /* Transaction is finished, reset the state. */ -- if (kvp_transaction.state > HVUTIL_READY) -- kvp_transaction.state = HVUTIL_READY; -- -- hv_poll_channel(kvp_transaction.kvp_context, -- hv_kvp_onchannelcallback); -+ hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper); - } - - static int kvp_handle_handshake(struct hv_kvp_msg *msg) -@@ -218,9 +219,7 @@ static int kvp_on_msg(void *msg, int len) - */ - if (cancel_delayed_work_sync(&kvp_timeout_work)) { - kvp_respond_to_host(message, error); -- kvp_transaction.state = HVUTIL_READY; -- hv_poll_channel(kvp_transaction.kvp_context, -- hv_kvp_onchannelcallback); -+ hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper); - } - - return 0; -@@ -596,15 +595,8 @@ void hv_kvp_onchannelcallback(void *context) - int util_fw_version; - int kvp_srv_version; - -- if (kvp_transaction.state > HVUTIL_READY) { -- /* -- * We will defer processing this callback once -- * the current transaction is complete. -- */ -- kvp_transaction.kvp_context = context; -+ if (kvp_transaction.state > HVUTIL_READY) - return; -- } -- kvp_transaction.kvp_context = NULL; - - vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen, - &requestid); -@@ -668,7 +660,8 @@ void hv_kvp_onchannelcallback(void *context) - * user-mode not responding. - */ - schedule_work(&kvp_sendkey_work); -- schedule_delayed_work(&kvp_timeout_work, 5*HZ); -+ schedule_delayed_work(&kvp_timeout_work, -+ HV_UTIL_TIMEOUT * HZ); - - return; - -diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c -index 815405f2e777..81882d4848bd 100644 ---- a/drivers/hv/hv_snapshot.c -+++ b/drivers/hv/hv_snapshot.c -@@ -53,7 +53,6 @@ static struct { - struct vmbus_channel *recv_channel; /* chn we got the request */ - u64 recv_req_id; /* request ID. */ - struct hv_vss_msg *msg; /* current message */ -- void *vss_context; /* for the channel callback */ - } vss_transaction; - - -@@ -74,6 +73,13 @@ static void vss_timeout_func(struct work_struct *dummy); - static DECLARE_DELAYED_WORK(vss_timeout_work, vss_timeout_func); - static DECLARE_WORK(vss_send_op_work, vss_send_op); - -+static void vss_poll_wrapper(void *channel) -+{ -+ /* Transaction is finished, reset the state here to avoid races. */ -+ vss_transaction.state = HVUTIL_READY; -+ hv_vss_onchannelcallback(channel); -+} -+ - /* - * Callback when data is received from user mode. - */ -@@ -86,12 +92,7 @@ static void vss_timeout_func(struct work_struct *dummy) - pr_warn("VSS: timeout waiting for daemon to reply\n"); - vss_respond_to_host(HV_E_FAIL); - -- /* Transaction is finished, reset the state. */ -- if (vss_transaction.state > HVUTIL_READY) -- vss_transaction.state = HVUTIL_READY; -- -- hv_poll_channel(vss_transaction.vss_context, -- hv_vss_onchannelcallback); -+ hv_poll_channel(vss_transaction.recv_channel, vss_poll_wrapper); - } - - static int vss_handle_handshake(struct hv_vss_msg *vss_msg) -@@ -138,9 +139,8 @@ static int vss_on_msg(void *msg, int len) - if (cancel_delayed_work_sync(&vss_timeout_work)) { - vss_respond_to_host(vss_msg->error); - /* Transaction is finished, reset the state. */ -- vss_transaction.state = HVUTIL_READY; -- hv_poll_channel(vss_transaction.vss_context, -- hv_vss_onchannelcallback); -+ hv_poll_channel(vss_transaction.recv_channel, -+ vss_poll_wrapper); - } - } else { - /* This is a spurious call! */ -@@ -238,15 +238,8 @@ void hv_vss_onchannelcallback(void *context) - struct icmsg_hdr *icmsghdrp; - struct icmsg_negotiate *negop = NULL; - -- if (vss_transaction.state > HVUTIL_READY) { -- /* -- * We will defer processing this callback once -- * the current transaction is complete. -- */ -- vss_transaction.vss_context = context; -+ if (vss_transaction.state > HVUTIL_READY) - return; -- } -- vss_transaction.vss_context = NULL; - - vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, - &requestid); -@@ -338,6 +331,11 @@ static void vss_on_reset(void) - int - hv_vss_init(struct hv_util_service *srv) - { -+ if (vmbus_proto_version < VERSION_WIN8_1) { -+ pr_warn("Integration service 'Backup (volume snapshot)'" -+ " not supported on this host version.\n"); -+ return -ENOTSUPP; -+ } - recv_buffer = srv->recv_buffer; - - /* -diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c -index 6a9d80a5332d..1505ee6e6605 100644 ---- a/drivers/hv/hv_utils_transport.c -+++ b/drivers/hv/hv_utils_transport.c -@@ -204,9 +204,12 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len) - goto out_unlock; - } - hvt->outmsg = kzalloc(len, GFP_KERNEL); -- memcpy(hvt->outmsg, msg, len); -- hvt->outmsg_len = len; -- wake_up_interruptible(&hvt->outmsg_q); -+ if (hvt->outmsg) { -+ memcpy(hvt->outmsg, msg, len); -+ hvt->outmsg_len = len; -+ wake_up_interruptible(&hvt->outmsg_q); -+ } else -+ ret = -ENOMEM; - out_unlock: - mutex_unlock(&hvt->outmsg_lock); - return ret; -diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h -index 3782636562a1..12156db2e88e 100644 ---- a/drivers/hv/hyperv_vmbus.h -+++ b/drivers/hv/hyperv_vmbus.h -@@ -31,6 +31,11 @@ - #include - - /* -+ * Timeout for services such as KVP and fcopy. -+ */ -+#define HV_UTIL_TIMEOUT 30 -+ -+/* - * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent - * is set by CPUID(HVCPUID_VERSION_FEATURES). - */ -@@ -759,11 +764,7 @@ static inline void hv_poll_channel(struct vmbus_channel *channel, - if (!channel) - return; - -- if (channel->target_cpu != smp_processor_id()) -- smp_call_function_single(channel->target_cpu, -- cb, channel, true); -- else -- cb(channel); -+ smp_call_function_single(channel->target_cpu, cb, channel, true); - } - - enum hvutil_device_state { -diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c -index 9b5440f6b3b4..509ed9731630 100644 ---- a/drivers/hv/vmbus_drv.c -+++ b/drivers/hv/vmbus_drv.c -@@ -105,6 +105,7 @@ static struct notifier_block hyperv_panic_block = { - }; - - struct resource *hyperv_mmio; -+DEFINE_SEMAPHORE(hyperv_mmio_lock); - - static int vmbus_exists(void) - { -@@ -603,23 +604,11 @@ static int vmbus_remove(struct device *child_device) - { - struct hv_driver *drv; - struct hv_device *dev = device_to_hv_device(child_device); -- u32 relid = dev->channel->offermsg.child_relid; - - if (child_device->driver) { - drv = drv_to_hv_drv(child_device->driver); - if (drv->remove) - drv->remove(dev); -- else { -- hv_process_channel_removal(dev->channel, relid); -- pr_err("remove not set for driver %s\n", -- dev_name(child_device)); -- } -- } else { -- /* -- * We don't have a driver for this device; deal with the -- * rescind message by removing the channel. -- */ -- hv_process_channel_removal(dev->channel, relid); - } - - return 0; -@@ -654,7 +643,10 @@ static void vmbus_shutdown(struct device *child_device) - static void vmbus_device_release(struct device *device) - { - struct hv_device *hv_dev = device_to_hv_device(device); -+ struct vmbus_channel *channel = hv_dev->channel; - -+ hv_process_channel_removal(channel, -+ channel->offermsg.child_relid); - kfree(hv_dev); - - } -@@ -870,7 +862,7 @@ static int vmbus_bus_init(int irq) - on_each_cpu(hv_synic_init, NULL, 1); - ret = vmbus_connect(); - if (ret) -- goto err_alloc; -+ goto err_connect; - - if (vmbus_proto_version > VERSION_WIN7) - cpu_hotplug_disable(); -@@ -888,6 +880,8 @@ static int vmbus_bus_init(int irq) - - return 0; - -+err_connect: -+ on_each_cpu(hv_synic_cleanup, NULL, 1); - err_alloc: - hv_synic_free(); - hv_remove_vmbus_irq(); -@@ -1147,7 +1141,10 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, - resource_size_t range_min, range_max, start, local_min, local_max; - const char *dev_n = dev_name(&device_obj->device); - u32 fb_end = screen_info.lfb_base + (screen_info.lfb_size << 1); -- int i; -+ int i, retval; -+ -+ retval = -ENXIO; -+ down(&hyperv_mmio_lock); - - for (iter = hyperv_mmio; iter; iter = iter->sibling) { - if ((iter->start >= max) || (iter->end <= min)) -@@ -1184,13 +1181,17 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, - for (; start + size - 1 <= local_max; start += align) { - *new = request_mem_region_exclusive(start, size, - dev_n); -- if (*new) -- return 0; -+ if (*new) { -+ retval = 0; -+ goto exit; -+ } - } - } - } - -- return -ENXIO; -+exit: -+ up(&hyperv_mmio_lock); -+ return retval; - } - EXPORT_SYMBOL_GPL(vmbus_allocate_mmio); - -diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c -index 146eed70bdf4..ba947df5a8c7 100644 ---- a/drivers/idle/intel_idle.c -+++ b/drivers/idle/intel_idle.c -@@ -716,6 +716,26 @@ static struct cpuidle_state avn_cstates[] = { - { - .enter = NULL } - }; -+static struct cpuidle_state knl_cstates[] = { -+ { -+ .name = "C1-KNL", -+ .desc = "MWAIT 0x00", -+ .flags = MWAIT2flg(0x00), -+ .exit_latency = 1, -+ .target_residency = 2, -+ .enter = &intel_idle, -+ .enter_freeze = intel_idle_freeze }, -+ { -+ .name = "C6-KNL", -+ .desc = "MWAIT 0x10", -+ .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, -+ .exit_latency = 120, -+ .target_residency = 500, -+ .enter = &intel_idle, -+ .enter_freeze = intel_idle_freeze }, -+ { -+ .enter = NULL } -+}; - - /** - * intel_idle -@@ -890,6 +910,10 @@ static const struct idle_cpu idle_cpu_avn = { - .disable_promotion_to_c1e = true, - }; - -+static const struct idle_cpu idle_cpu_knl = { -+ .state_table = knl_cstates, -+}; -+ - #define ICPU(model, cpu) \ - { X86_VENDOR_INTEL, 6, model, X86_FEATURE_MWAIT, (unsigned long)&cpu } - -@@ -921,6 +945,7 @@ static const struct x86_cpu_id intel_idle_ids[] __initconst = { - ICPU(0x56, idle_cpu_bdw), - ICPU(0x4e, idle_cpu_skl), - ICPU(0x5e, idle_cpu_skl), -+ ICPU(0x57, idle_cpu_knl), - {} - }; - MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids); -diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c -index 5ea0c14070d1..fa9c42ff1fb0 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c -@@ -245,8 +245,6 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) - skb_reset_mac_header(skb); - skb_pull(skb, IPOIB_ENCAP_LEN); - -- skb->truesize = SKB_TRUESIZE(skb->len); -- - ++dev->stats.rx_packets; - dev->stats.rx_bytes += skb->len; - -diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c -index 2b2f9d66c2c7..aff42d5e2296 100644 ---- a/drivers/input/joystick/xpad.c -+++ b/drivers/input/joystick/xpad.c -@@ -317,6 +317,19 @@ static struct usb_device_id xpad_table[] = { - - MODULE_DEVICE_TABLE(usb, xpad_table); - -+struct xpad_output_packet { -+ u8 data[XPAD_PKT_LEN]; -+ u8 len; -+ bool pending; -+}; -+ -+#define XPAD_OUT_CMD_IDX 0 -+#define XPAD_OUT_FF_IDX 1 -+#define XPAD_OUT_LED_IDX (1 + IS_ENABLED(CONFIG_JOYSTICK_XPAD_FF)) -+#define XPAD_NUM_OUT_PACKETS (1 + \ -+ IS_ENABLED(CONFIG_JOYSTICK_XPAD_FF) + \ -+ IS_ENABLED(CONFIG_JOYSTICK_XPAD_LEDS)) -+ - struct usb_xpad { - struct input_dev *dev; /* input device interface */ - struct usb_device *udev; /* usb device */ -@@ -329,9 +342,13 @@ struct usb_xpad { - dma_addr_t idata_dma; - - struct urb *irq_out; /* urb for interrupt out report */ -+ bool irq_out_active; /* we must not use an active URB */ - unsigned char *odata; /* output data */ - dma_addr_t odata_dma; -- struct mutex odata_mutex; -+ spinlock_t odata_lock; -+ -+ struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS]; -+ int last_out_packet; - - #if defined(CONFIG_JOYSTICK_XPAD_LEDS) - struct xpad_led *led; -@@ -678,18 +695,71 @@ exit: - __func__, retval); - } - -+/* Callers must hold xpad->odata_lock spinlock */ -+static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad) -+{ -+ struct xpad_output_packet *pkt, *packet = NULL; -+ int i; -+ -+ for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) { -+ if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) -+ xpad->last_out_packet = 0; -+ -+ pkt = &xpad->out_packets[xpad->last_out_packet]; -+ if (pkt->pending) { -+ dev_dbg(&xpad->intf->dev, -+ "%s - found pending output packet %d\n", -+ __func__, xpad->last_out_packet); -+ packet = pkt; -+ break; -+ } -+ } -+ -+ if (packet) { -+ memcpy(xpad->odata, packet->data, packet->len); -+ xpad->irq_out->transfer_buffer_length = packet->len; -+ packet->pending = false; -+ return true; -+ } -+ -+ return false; -+} -+ -+/* Callers must hold xpad->odata_lock spinlock */ -+static int xpad_try_sending_next_out_packet(struct usb_xpad *xpad) -+{ -+ int error; -+ -+ if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { -+ error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); -+ if (error) { -+ dev_err(&xpad->intf->dev, -+ "%s - usb_submit_urb failed with result %d\n", -+ __func__, error); -+ return -EIO; -+ } -+ -+ xpad->irq_out_active = true; -+ } -+ -+ return 0; -+} -+ - static void xpad_irq_out(struct urb *urb) - { - struct usb_xpad *xpad = urb->context; - struct device *dev = &xpad->intf->dev; -- int retval, status; -+ int status = urb->status; -+ int error; -+ unsigned long flags; - -- status = urb->status; -+ spin_lock_irqsave(&xpad->odata_lock, flags); - - switch (status) { - case 0: - /* success */ -- return; -+ xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); -+ break; - - case -ECONNRESET: - case -ENOENT: -@@ -697,19 +767,26 @@ static void xpad_irq_out(struct urb *urb) - /* this urb is terminated, clean up */ - dev_dbg(dev, "%s - urb shutting down with status: %d\n", - __func__, status); -- return; -+ xpad->irq_out_active = false; -+ break; - - default: - dev_dbg(dev, "%s - nonzero urb status received: %d\n", - __func__, status); -- goto exit; -+ break; - } - --exit: -- retval = usb_submit_urb(urb, GFP_ATOMIC); -- if (retval) -- dev_err(dev, "%s - usb_submit_urb failed with result %d\n", -- __func__, retval); -+ if (xpad->irq_out_active) { -+ error = usb_submit_urb(urb, GFP_ATOMIC); -+ if (error) { -+ dev_err(dev, -+ "%s - usb_submit_urb failed with result %d\n", -+ __func__, error); -+ xpad->irq_out_active = false; -+ } -+ } -+ -+ spin_unlock_irqrestore(&xpad->odata_lock, flags); - } - - static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) -@@ -728,7 +805,7 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) - goto fail1; - } - -- mutex_init(&xpad->odata_mutex); -+ spin_lock_init(&xpad->odata_lock); - - xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); - if (!xpad->irq_out) { -@@ -770,27 +847,57 @@ static void xpad_deinit_output(struct usb_xpad *xpad) - - static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) - { -+ struct xpad_output_packet *packet = -+ &xpad->out_packets[XPAD_OUT_CMD_IDX]; -+ unsigned long flags; - int retval; - -- mutex_lock(&xpad->odata_mutex); -+ spin_lock_irqsave(&xpad->odata_lock, flags); -+ -+ packet->data[0] = 0x08; -+ packet->data[1] = 0x00; -+ packet->data[2] = 0x0F; -+ packet->data[3] = 0xC0; -+ packet->data[4] = 0x00; -+ packet->data[5] = 0x00; -+ packet->data[6] = 0x00; -+ packet->data[7] = 0x00; -+ packet->data[8] = 0x00; -+ packet->data[9] = 0x00; -+ packet->data[10] = 0x00; -+ packet->data[11] = 0x00; -+ packet->len = 12; -+ packet->pending = true; -+ -+ /* Reset the sequence so we send out presence first */ -+ xpad->last_out_packet = -1; -+ retval = xpad_try_sending_next_out_packet(xpad); -+ -+ spin_unlock_irqrestore(&xpad->odata_lock, flags); - -- xpad->odata[0] = 0x08; -- xpad->odata[1] = 0x00; -- xpad->odata[2] = 0x0F; -- xpad->odata[3] = 0xC0; -- xpad->odata[4] = 0x00; -- xpad->odata[5] = 0x00; -- xpad->odata[6] = 0x00; -- xpad->odata[7] = 0x00; -- xpad->odata[8] = 0x00; -- xpad->odata[9] = 0x00; -- xpad->odata[10] = 0x00; -- xpad->odata[11] = 0x00; -- xpad->irq_out->transfer_buffer_length = 12; -+ return retval; -+} - -- retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL); -+static int xpad_start_xbox_one(struct usb_xpad *xpad) -+{ -+ struct xpad_output_packet *packet = -+ &xpad->out_packets[XPAD_OUT_CMD_IDX]; -+ unsigned long flags; -+ int retval; -+ -+ spin_lock_irqsave(&xpad->odata_lock, flags); -+ -+ /* Xbox one controller needs to be initialized. */ -+ packet->data[0] = 0x05; -+ packet->data[1] = 0x20; -+ packet->len = 2; -+ packet->pending = true; - -- mutex_unlock(&xpad->odata_mutex); -+ /* Reset the sequence so we send out start packet first */ -+ xpad->last_out_packet = -1; -+ retval = xpad_try_sending_next_out_packet(xpad); -+ -+ spin_unlock_irqrestore(&xpad->odata_lock, flags); - - return retval; - } -@@ -799,8 +906,11 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) - static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) - { - struct usb_xpad *xpad = input_get_drvdata(dev); -+ struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; - __u16 strong; - __u16 weak; -+ int retval; -+ unsigned long flags; - - if (effect->type != FF_RUMBLE) - return 0; -@@ -808,69 +918,80 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect - strong = effect->u.rumble.strong_magnitude; - weak = effect->u.rumble.weak_magnitude; - -+ spin_lock_irqsave(&xpad->odata_lock, flags); -+ - switch (xpad->xtype) { - case XTYPE_XBOX: -- xpad->odata[0] = 0x00; -- xpad->odata[1] = 0x06; -- xpad->odata[2] = 0x00; -- xpad->odata[3] = strong / 256; /* left actuator */ -- xpad->odata[4] = 0x00; -- xpad->odata[5] = weak / 256; /* right actuator */ -- xpad->irq_out->transfer_buffer_length = 6; -+ packet->data[0] = 0x00; -+ packet->data[1] = 0x06; -+ packet->data[2] = 0x00; -+ packet->data[3] = strong / 256; /* left actuator */ -+ packet->data[4] = 0x00; -+ packet->data[5] = weak / 256; /* right actuator */ -+ packet->len = 6; -+ packet->pending = true; - break; - - case XTYPE_XBOX360: -- xpad->odata[0] = 0x00; -- xpad->odata[1] = 0x08; -- xpad->odata[2] = 0x00; -- xpad->odata[3] = strong / 256; /* left actuator? */ -- xpad->odata[4] = weak / 256; /* right actuator? */ -- xpad->odata[5] = 0x00; -- xpad->odata[6] = 0x00; -- xpad->odata[7] = 0x00; -- xpad->irq_out->transfer_buffer_length = 8; -+ packet->data[0] = 0x00; -+ packet->data[1] = 0x08; -+ packet->data[2] = 0x00; -+ packet->data[3] = strong / 256; /* left actuator? */ -+ packet->data[4] = weak / 256; /* right actuator? */ -+ packet->data[5] = 0x00; -+ packet->data[6] = 0x00; -+ packet->data[7] = 0x00; -+ packet->len = 8; -+ packet->pending = true; - break; - - case XTYPE_XBOX360W: -- xpad->odata[0] = 0x00; -- xpad->odata[1] = 0x01; -- xpad->odata[2] = 0x0F; -- xpad->odata[3] = 0xC0; -- xpad->odata[4] = 0x00; -- xpad->odata[5] = strong / 256; -- xpad->odata[6] = weak / 256; -- xpad->odata[7] = 0x00; -- xpad->odata[8] = 0x00; -- xpad->odata[9] = 0x00; -- xpad->odata[10] = 0x00; -- xpad->odata[11] = 0x00; -- xpad->irq_out->transfer_buffer_length = 12; -+ packet->data[0] = 0x00; -+ packet->data[1] = 0x01; -+ packet->data[2] = 0x0F; -+ packet->data[3] = 0xC0; -+ packet->data[4] = 0x00; -+ packet->data[5] = strong / 256; -+ packet->data[6] = weak / 256; -+ packet->data[7] = 0x00; -+ packet->data[8] = 0x00; -+ packet->data[9] = 0x00; -+ packet->data[10] = 0x00; -+ packet->data[11] = 0x00; -+ packet->len = 12; -+ packet->pending = true; - break; - - case XTYPE_XBOXONE: -- xpad->odata[0] = 0x09; /* activate rumble */ -- xpad->odata[1] = 0x08; -- xpad->odata[2] = 0x00; -- xpad->odata[3] = 0x08; /* continuous effect */ -- xpad->odata[4] = 0x00; /* simple rumble mode */ -- xpad->odata[5] = 0x03; /* L and R actuator only */ -- xpad->odata[6] = 0x00; /* TODO: LT actuator */ -- xpad->odata[7] = 0x00; /* TODO: RT actuator */ -- xpad->odata[8] = strong / 256; /* left actuator */ -- xpad->odata[9] = weak / 256; /* right actuator */ -- xpad->odata[10] = 0x80; /* length of pulse */ -- xpad->odata[11] = 0x00; /* stop period of pulse */ -- xpad->irq_out->transfer_buffer_length = 12; -+ packet->data[0] = 0x09; /* activate rumble */ -+ packet->data[1] = 0x08; -+ packet->data[2] = 0x00; -+ packet->data[3] = 0x08; /* continuous effect */ -+ packet->data[4] = 0x00; /* simple rumble mode */ -+ packet->data[5] = 0x03; /* L and R actuator only */ -+ packet->data[6] = 0x00; /* TODO: LT actuator */ -+ packet->data[7] = 0x00; /* TODO: RT actuator */ -+ packet->data[8] = strong / 256; /* left actuator */ -+ packet->data[9] = weak / 256; /* right actuator */ -+ packet->data[10] = 0x80; /* length of pulse */ -+ packet->data[11] = 0x00; /* stop period of pulse */ -+ packet->len = 12; -+ packet->pending = true; - break; - - default: - dev_dbg(&xpad->dev->dev, - "%s - rumble command sent to unsupported xpad type: %d\n", - __func__, xpad->xtype); -- return -EINVAL; -+ retval = -EINVAL; -+ goto out; - } - -- return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); -+ retval = xpad_try_sending_next_out_packet(xpad); -+ -+out: -+ spin_unlock_irqrestore(&xpad->odata_lock, flags); -+ return retval; - } - - static int xpad_init_ff(struct usb_xpad *xpad) -@@ -921,36 +1042,44 @@ struct xpad_led { - */ - static void xpad_send_led_command(struct usb_xpad *xpad, int command) - { -+ struct xpad_output_packet *packet = -+ &xpad->out_packets[XPAD_OUT_LED_IDX]; -+ unsigned long flags; -+ - command %= 16; - -- mutex_lock(&xpad->odata_mutex); -+ spin_lock_irqsave(&xpad->odata_lock, flags); - - switch (xpad->xtype) { - case XTYPE_XBOX360: -- xpad->odata[0] = 0x01; -- xpad->odata[1] = 0x03; -- xpad->odata[2] = command; -- xpad->irq_out->transfer_buffer_length = 3; -+ packet->data[0] = 0x01; -+ packet->data[1] = 0x03; -+ packet->data[2] = command; -+ packet->len = 3; -+ packet->pending = true; - break; -+ - case XTYPE_XBOX360W: -- xpad->odata[0] = 0x00; -- xpad->odata[1] = 0x00; -- xpad->odata[2] = 0x08; -- xpad->odata[3] = 0x40 + command; -- xpad->odata[4] = 0x00; -- xpad->odata[5] = 0x00; -- xpad->odata[6] = 0x00; -- xpad->odata[7] = 0x00; -- xpad->odata[8] = 0x00; -- xpad->odata[9] = 0x00; -- xpad->odata[10] = 0x00; -- xpad->odata[11] = 0x00; -- xpad->irq_out->transfer_buffer_length = 12; -+ packet->data[0] = 0x00; -+ packet->data[1] = 0x00; -+ packet->data[2] = 0x08; -+ packet->data[3] = 0x40 + command; -+ packet->data[4] = 0x00; -+ packet->data[5] = 0x00; -+ packet->data[6] = 0x00; -+ packet->data[7] = 0x00; -+ packet->data[8] = 0x00; -+ packet->data[9] = 0x00; -+ packet->data[10] = 0x00; -+ packet->data[11] = 0x00; -+ packet->len = 12; -+ packet->pending = true; - break; - } - -- usb_submit_urb(xpad->irq_out, GFP_KERNEL); -- mutex_unlock(&xpad->odata_mutex); -+ xpad_try_sending_next_out_packet(xpad); -+ -+ spin_unlock_irqrestore(&xpad->odata_lock, flags); - } - - /* -@@ -1048,13 +1177,8 @@ static int xpad_open(struct input_dev *dev) - if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) - return -EIO; - -- if (xpad->xtype == XTYPE_XBOXONE) { -- /* Xbox one controller needs to be initialized. */ -- xpad->odata[0] = 0x05; -- xpad->odata[1] = 0x20; -- xpad->irq_out->transfer_buffer_length = 2; -- return usb_submit_urb(xpad->irq_out, GFP_KERNEL); -- } -+ if (xpad->xtype == XTYPE_XBOXONE) -+ return xpad_start_xbox_one(xpad); - - return 0; - } -diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c -index a159529f9d53..c5f1757ac61d 100644 ---- a/drivers/irqchip/irq-gic-v3-its.c -+++ b/drivers/irqchip/irq-gic-v3-its.c -@@ -41,6 +41,7 @@ - - #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING (1ULL << 0) - #define ITS_FLAGS_WORKAROUND_CAVIUM_22375 (1ULL << 1) -+#define ITS_FLAGS_WORKAROUND_CAVIUM_23144 (1ULL << 2) - - #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0) - -@@ -71,6 +72,7 @@ struct its_node { - struct list_head its_device_list; - u64 flags; - u32 ite_size; -+ int numa_node; - }; - - #define ITS_ITT_ALIGN SZ_256 -@@ -600,11 +602,23 @@ static void its_unmask_irq(struct irq_data *d) - static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val, - bool force) - { -- unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask); -+ unsigned int cpu; -+ const struct cpumask *cpu_mask = cpu_online_mask; - struct its_device *its_dev = irq_data_get_irq_chip_data(d); - struct its_collection *target_col; - u32 id = its_get_event_id(d); - -+ /* lpi cannot be routed to a redistributor that is on a foreign node */ -+ if (its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) { -+ if (its_dev->its->numa_node >= 0) { -+ cpu_mask = cpumask_of_node(its_dev->its->numa_node); -+ if (!cpumask_intersects(mask_val, cpu_mask)) -+ return -EINVAL; -+ } -+ } -+ -+ cpu = cpumask_any_and(mask_val, cpu_mask); -+ - if (cpu >= nr_cpu_ids) - return -EINVAL; - -@@ -1081,6 +1095,16 @@ static void its_cpu_init_collection(void) - list_for_each_entry(its, &its_nodes, entry) { - u64 target; - -+ /* avoid cross node collections and its mapping */ -+ if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) { -+ struct device_node *cpu_node; -+ -+ cpu_node = of_get_cpu_node(cpu, NULL); -+ if (its->numa_node != NUMA_NO_NODE && -+ its->numa_node != of_node_to_nid(cpu_node)) -+ continue; -+ } -+ - /* - * We now have to bind each collection to its target - * redistributor. -@@ -1308,9 +1332,14 @@ static void its_irq_domain_activate(struct irq_domain *domain, - { - struct its_device *its_dev = irq_data_get_irq_chip_data(d); - u32 event = its_get_event_id(d); -+ const struct cpumask *cpu_mask = cpu_online_mask; -+ -+ /* get the cpu_mask of local node */ -+ if (its_dev->its->numa_node >= 0) -+ cpu_mask = cpumask_of_node(its_dev->its->numa_node); - - /* Bind the LPI to the first possible CPU */ -- its_dev->event_map.col_map[event] = cpumask_first(cpu_online_mask); -+ its_dev->event_map.col_map[event] = cpumask_first(cpu_mask); - - /* Map the GIC IRQ and event to the device */ - its_send_mapvi(its_dev, d->hwirq, event); -@@ -1400,6 +1429,13 @@ static void __maybe_unused its_enable_quirk_cavium_22375(void *data) - its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_22375; - } - -+static void __maybe_unused its_enable_quirk_cavium_23144(void *data) -+{ -+ struct its_node *its = data; -+ -+ its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_23144; -+} -+ - static const struct gic_quirk its_quirks[] = { - #ifdef CONFIG_CAVIUM_ERRATUM_22375 - { -@@ -1409,6 +1445,14 @@ static const struct gic_quirk its_quirks[] = { - .init = its_enable_quirk_cavium_22375, - }, - #endif -+#ifdef CONFIG_CAVIUM_ERRATUM_23144 -+ { -+ .desc = "ITS: Cavium erratum 23144", -+ .iidr = 0xa100034c, /* ThunderX pass 1.x */ -+ .mask = 0xffff0fff, -+ .init = its_enable_quirk_cavium_23144, -+ }, -+#endif - { - } - }; -@@ -1470,6 +1514,7 @@ static int its_probe(struct device_node *node, struct irq_domain *parent) - its->base = its_base; - its->phys_base = res.start; - its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1; -+ its->numa_node = of_node_to_nid(node); - - its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL); - if (!its->cmd_base) { -diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c -index a54b339951a3..2a96ff6923f0 100644 ---- a/drivers/lightnvm/gennvm.c -+++ b/drivers/lightnvm/gennvm.c -@@ -89,6 +89,7 @@ static int gennvm_block_bb(struct ppa_addr ppa, int nr_blocks, u8 *blks, - - list_move_tail(&blk->list, &lun->bb_list); - lun->vlun.nr_bad_blocks++; -+ lun->vlun.nr_free_blocks--; - } - - return 0; -@@ -345,7 +346,7 @@ static void gennvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) - static int gennvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) - { - if (!dev->ops->submit_io) -- return 0; -+ return -ENODEV; - - /* Convert address space */ - gennvm_generic_to_addr_mode(dev, rqd); -diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c -index 134e4faba482..a9859489acf6 100644 ---- a/drivers/lightnvm/rrpc.c -+++ b/drivers/lightnvm/rrpc.c -@@ -287,6 +287,8 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk) - } - - page = mempool_alloc(rrpc->page_pool, GFP_NOIO); -+ if (!page) -+ return -ENOMEM; - - while ((slot = find_first_zero_bit(rblk->invalid_pages, - nr_pgs_per_blk)) < nr_pgs_per_blk) { -@@ -427,7 +429,7 @@ static void rrpc_lun_gc(struct work_struct *work) - if (nr_blocks_need < rrpc->nr_luns) - nr_blocks_need = rrpc->nr_luns; - -- spin_lock(&lun->lock); -+ spin_lock(&rlun->lock); - while (nr_blocks_need > lun->nr_free_blocks && - !list_empty(&rlun->prio_list)) { - struct rrpc_block *rblock = block_prio_find_max(rlun); -@@ -436,16 +438,16 @@ static void rrpc_lun_gc(struct work_struct *work) - if (!rblock->nr_invalid_pages) - break; - -+ gcb = mempool_alloc(rrpc->gcb_pool, GFP_ATOMIC); -+ if (!gcb) -+ break; -+ - list_del_init(&rblock->prio); - - BUG_ON(!block_is_full(rrpc, rblock)); - - pr_debug("rrpc: selected block '%lu' for GC\n", block->id); - -- gcb = mempool_alloc(rrpc->gcb_pool, GFP_ATOMIC); -- if (!gcb) -- break; -- - gcb->rrpc = rrpc; - gcb->rblk = rblock; - INIT_WORK(&gcb->ws_gc, rrpc_block_gc); -@@ -454,7 +456,7 @@ static void rrpc_lun_gc(struct work_struct *work) - - nr_blocks_need--; - } -- spin_unlock(&lun->lock); -+ spin_unlock(&rlun->lock); - - /* TODO: Hint that request queue can be started again */ - } -@@ -650,11 +652,12 @@ static int rrpc_end_io(struct nvm_rq *rqd, int error) - if (bio_data_dir(rqd->bio) == WRITE) - rrpc_end_io_write(rrpc, rrqd, laddr, npages); - -+ bio_put(rqd->bio); -+ - if (rrqd->flags & NVM_IOTYPE_GC) - return 0; - - rrpc_unlock_rq(rrpc, rqd); -- bio_put(rqd->bio); - - if (npages > 1) - nvm_dev_dma_free(rrpc->dev, rqd->ppa_list, rqd->dma_ppa_list); -@@ -841,6 +844,13 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, - err = nvm_submit_io(rrpc->dev, rqd); - if (err) { - pr_err("rrpc: I/O submission failed: %d\n", err); -+ bio_put(bio); -+ if (!(flags & NVM_IOTYPE_GC)) { -+ rrpc_unlock_rq(rrpc, rqd); -+ if (rqd->nr_pages > 1) -+ nvm_dev_dma_free(rrpc->dev, -+ rqd->ppa_list, rqd->dma_ppa_list); -+ } - return NVM_IO_ERR; - } - -diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index a296425a7270..3d5c0ba13181 100644 ---- a/drivers/md/bcache/super.c -+++ b/drivers/md/bcache/super.c -@@ -1818,7 +1818,7 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca) - free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; - - if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || -- !init_fifo(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || -+ !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || - !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || - !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || - !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || -diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig -index 292c9479bb75..310e4b8beae8 100644 ---- a/drivers/media/dvb-frontends/Kconfig -+++ b/drivers/media/dvb-frontends/Kconfig -@@ -264,7 +264,7 @@ config DVB_MB86A16 - config DVB_TDA10071 - tristate "NXP TDA10071" - depends on DVB_CORE && I2C -- select REGMAP -+ select REGMAP_I2C - default m if !MEDIA_SUBDRV_AUTOSELECT - help - Say Y when you want to support this frontend. -diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c -index d11fd6ac2df0..5cefca95734e 100644 ---- a/drivers/media/usb/uvc/uvc_driver.c -+++ b/drivers/media/usb/uvc/uvc_driver.c -@@ -148,6 +148,26 @@ static struct uvc_format_desc uvc_fmts[] = { - .guid = UVC_GUID_FORMAT_H264, - .fcc = V4L2_PIX_FMT_H264, - }, -+ { -+ .name = "Greyscale 8 L/R (Y8I)", -+ .guid = UVC_GUID_FORMAT_Y8I, -+ .fcc = V4L2_PIX_FMT_Y8I, -+ }, -+ { -+ .name = "Greyscale 12 L/R (Y12I)", -+ .guid = UVC_GUID_FORMAT_Y12I, -+ .fcc = V4L2_PIX_FMT_Y12I, -+ }, -+ { -+ .name = "Depth data 16-bit (Z16)", -+ .guid = UVC_GUID_FORMAT_Z16, -+ .fcc = V4L2_PIX_FMT_Z16, -+ }, -+ { -+ .name = "Bayer 10-bit (SRGGB10P)", -+ .guid = UVC_GUID_FORMAT_RW10, -+ .fcc = V4L2_PIX_FMT_SRGGB10P, -+ }, - }; - - /* ------------------------------------------------------------------------ -diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h -index f0f2391e1b43..7e4d3eea371b 100644 ---- a/drivers/media/usb/uvc/uvcvideo.h -+++ b/drivers/media/usb/uvc/uvcvideo.h -@@ -119,6 +119,18 @@ - #define UVC_GUID_FORMAT_H264 \ - { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \ - 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} -+#define UVC_GUID_FORMAT_Y8I \ -+ { 'Y', '8', 'I', ' ', 0x00, 0x00, 0x10, 0x00, \ -+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} -+#define UVC_GUID_FORMAT_Y12I \ -+ { 'Y', '1', '2', 'I', 0x00, 0x00, 0x10, 0x00, \ -+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} -+#define UVC_GUID_FORMAT_Z16 \ -+ { 'Z', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ -+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} -+#define UVC_GUID_FORMAT_RW10 \ -+ { 'R', 'W', '1', '0', 0x00, 0x00, 0x10, 0x00, \ -+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} - - /* ------------------------------------------------------------------------ - * Driver specific constants. -diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile -index 6982f603fadc..ab6f392d3504 100644 ---- a/drivers/misc/cxl/Makefile -+++ b/drivers/misc/cxl/Makefile -@@ -1,4 +1,4 @@ --ccflags-y := -Werror -Wno-unused-const-variable -+ccflags-y := -Werror $(call cc-disable-warning, unused-const-variable) - - cxl-y += main.o file.o irq.o fault.o native.o - cxl-y += context.o sysfs.o debugfs.o pci.o trace.o -diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c -index 103baf0e0c5b..ea3eeb7011e1 100644 ---- a/drivers/misc/cxl/api.c -+++ b/drivers/misc/cxl/api.c -@@ -25,7 +25,6 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) - - afu = cxl_pci_to_afu(dev); - -- get_device(&afu->dev); - ctx = cxl_context_alloc(); - if (IS_ERR(ctx)) { - rc = PTR_ERR(ctx); -@@ -61,7 +60,6 @@ err_mapping: - err_ctx: - kfree(ctx); - err_dev: -- put_device(&afu->dev); - return ERR_PTR(rc); - } - EXPORT_SYMBOL_GPL(cxl_dev_context_init); -@@ -87,8 +85,6 @@ int cxl_release_context(struct cxl_context *ctx) - if (ctx->status >= STARTED) - return -EBUSY; - -- put_device(&ctx->afu->dev); -- - cxl_context_free(ctx); - - return 0; -@@ -176,7 +172,7 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, - - if (task) { - ctx->pid = get_task_pid(task, PIDTYPE_PID); -- get_pid(ctx->pid); -+ ctx->glpid = get_task_pid(task->group_leader, PIDTYPE_PID); - kernel = false; - } - -diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c -index 2faa1270d085..262b88eac414 100644 ---- a/drivers/misc/cxl/context.c -+++ b/drivers/misc/cxl/context.c -@@ -42,7 +42,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, - spin_lock_init(&ctx->sste_lock); - ctx->afu = afu; - ctx->master = master; -- ctx->pid = NULL; /* Set in start work ioctl */ -+ ctx->pid = ctx->glpid = NULL; /* Set in start work ioctl */ - mutex_init(&ctx->mapping_lock); - ctx->mapping = mapping; - -@@ -97,6 +97,12 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, - ctx->pe = i; - ctx->elem = &ctx->afu->spa[i]; - ctx->pe_inserted = false; -+ -+ /* -+ * take a ref on the afu so that it stays alive at-least till -+ * this context is reclaimed inside reclaim_ctx. -+ */ -+ cxl_afu_get(afu); - return 0; - } - -@@ -211,7 +217,11 @@ int __detach_context(struct cxl_context *ctx) - WARN_ON(cxl_detach_process(ctx) && - cxl_adapter_link_ok(ctx->afu->adapter)); - flush_work(&ctx->fault_work); /* Only needed for dedicated process */ -+ -+ /* release the reference to the group leader and mm handling pid */ - put_pid(ctx->pid); -+ put_pid(ctx->glpid); -+ - cxl_ctx_put(); - return 0; - } -@@ -278,6 +288,9 @@ static void reclaim_ctx(struct rcu_head *rcu) - if (ctx->irq_bitmap) - kfree(ctx->irq_bitmap); - -+ /* Drop ref to the afu device taken during cxl_context_init */ -+ cxl_afu_put(ctx->afu); -+ - kfree(ctx); - } - -diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h -index 0cfb9c129f27..a521bc72cec2 100644 ---- a/drivers/misc/cxl/cxl.h -+++ b/drivers/misc/cxl/cxl.h -@@ -403,6 +403,18 @@ struct cxl_afu { - bool enabled; - }; - -+/* AFU refcount management */ -+static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) -+{ -+ -+ return (get_device(&afu->dev) == NULL) ? NULL : afu; -+} -+ -+static inline void cxl_afu_put(struct cxl_afu *afu) -+{ -+ put_device(&afu->dev); -+} -+ - - struct cxl_irq_name { - struct list_head list; -@@ -433,6 +445,9 @@ struct cxl_context { - unsigned int sst_size, sst_lru; - - wait_queue_head_t wq; -+ /* pid of the group leader associated with the pid */ -+ struct pid *glpid; -+ /* use mm context associated with this pid for ds faults */ - struct pid *pid; - spinlock_t lock; /* Protects pending_irq_mask, pending_fault and fault_addr */ - /* Only used in PR mode */ -diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c -index 25a5418c55cb..81c3f75b7330 100644 ---- a/drivers/misc/cxl/fault.c -+++ b/drivers/misc/cxl/fault.c -@@ -166,13 +166,92 @@ static void cxl_handle_page_fault(struct cxl_context *ctx, - cxl_ack_irq(ctx, CXL_PSL_TFC_An_R, 0); - } - -+/* -+ * Returns the mm_struct corresponding to the context ctx via ctx->pid -+ * In case the task has exited we use the task group leader accessible -+ * via ctx->glpid to find the next task in the thread group that has a -+ * valid mm_struct associated with it. If a task with valid mm_struct -+ * is found the ctx->pid is updated to use the task struct for subsequent -+ * translations. In case no valid mm_struct is found in the task group to -+ * service the fault a NULL is returned. -+ */ -+static struct mm_struct *get_mem_context(struct cxl_context *ctx) -+{ -+ struct task_struct *task = NULL; -+ struct mm_struct *mm = NULL; -+ struct pid *old_pid = ctx->pid; -+ -+ if (old_pid == NULL) { -+ pr_warn("%s: Invalid context for pe=%d\n", -+ __func__, ctx->pe); -+ return NULL; -+ } -+ -+ task = get_pid_task(old_pid, PIDTYPE_PID); -+ -+ /* -+ * pid_alive may look racy but this saves us from costly -+ * get_task_mm when the task is a zombie. In worst case -+ * we may think a task is alive, which is about to die -+ * but get_task_mm will return NULL. -+ */ -+ if (task != NULL && pid_alive(task)) -+ mm = get_task_mm(task); -+ -+ /* release the task struct that was taken earlier */ -+ if (task) -+ put_task_struct(task); -+ else -+ pr_devel("%s: Context owning pid=%i for pe=%i dead\n", -+ __func__, pid_nr(old_pid), ctx->pe); -+ -+ /* -+ * If we couldn't find the mm context then use the group -+ * leader to iterate over the task group and find a task -+ * that gives us mm_struct. -+ */ -+ if (unlikely(mm == NULL && ctx->glpid != NULL)) { -+ -+ rcu_read_lock(); -+ task = pid_task(ctx->glpid, PIDTYPE_PID); -+ if (task) -+ do { -+ mm = get_task_mm(task); -+ if (mm) { -+ ctx->pid = get_task_pid(task, -+ PIDTYPE_PID); -+ break; -+ } -+ task = next_thread(task); -+ } while (task && !thread_group_leader(task)); -+ rcu_read_unlock(); -+ -+ /* check if we switched pid */ -+ if (ctx->pid != old_pid) { -+ if (mm) -+ pr_devel("%s:pe=%i switch pid %i->%i\n", -+ __func__, ctx->pe, pid_nr(old_pid), -+ pid_nr(ctx->pid)); -+ else -+ pr_devel("%s:Cannot find mm for pid=%i\n", -+ __func__, pid_nr(old_pid)); -+ -+ /* drop the reference to older pid */ -+ put_pid(old_pid); -+ } -+ } -+ -+ return mm; -+} -+ -+ -+ - void cxl_handle_fault(struct work_struct *fault_work) - { - struct cxl_context *ctx = - container_of(fault_work, struct cxl_context, fault_work); - u64 dsisr = ctx->dsisr; - u64 dar = ctx->dar; -- struct task_struct *task = NULL; - struct mm_struct *mm = NULL; - - if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr || -@@ -195,17 +274,17 @@ void cxl_handle_fault(struct work_struct *fault_work) - "DSISR: %#llx DAR: %#llx\n", ctx->pe, dsisr, dar); - - if (!ctx->kernel) { -- if (!(task = get_pid_task(ctx->pid, PIDTYPE_PID))) { -- pr_devel("cxl_handle_fault unable to get task %i\n", -- pid_nr(ctx->pid)); -+ -+ mm = get_mem_context(ctx); -+ /* indicates all the thread in task group have exited */ -+ if (mm == NULL) { -+ pr_devel("%s: unable to get mm for pe=%d pid=%i\n", -+ __func__, ctx->pe, pid_nr(ctx->pid)); - cxl_ack_ae(ctx); - return; -- } -- if (!(mm = get_task_mm(task))) { -- pr_devel("cxl_handle_fault unable to get mm %i\n", -- pid_nr(ctx->pid)); -- cxl_ack_ae(ctx); -- goto out; -+ } else { -+ pr_devel("Handling page fault for pe=%d pid=%i\n", -+ ctx->pe, pid_nr(ctx->pid)); - } - } - -@@ -218,33 +297,22 @@ void cxl_handle_fault(struct work_struct *fault_work) - - if (mm) - mmput(mm); --out: -- if (task) -- put_task_struct(task); - } - - static void cxl_prefault_one(struct cxl_context *ctx, u64 ea) - { -- int rc; -- struct task_struct *task; - struct mm_struct *mm; - -- if (!(task = get_pid_task(ctx->pid, PIDTYPE_PID))) { -- pr_devel("cxl_prefault_one unable to get task %i\n", -- pid_nr(ctx->pid)); -- return; -- } -- if (!(mm = get_task_mm(task))) { -+ mm = get_mem_context(ctx); -+ if (mm == NULL) { - pr_devel("cxl_prefault_one unable to get mm %i\n", - pid_nr(ctx->pid)); -- put_task_struct(task); - return; - } - -- rc = cxl_fault_segment(ctx, mm, ea); -+ cxl_fault_segment(ctx, mm, ea); - - mmput(mm); -- put_task_struct(task); - } - - static u64 next_segment(u64 ea, u64 vsid) -@@ -263,18 +331,13 @@ static void cxl_prefault_vma(struct cxl_context *ctx) - struct copro_slb slb; - struct vm_area_struct *vma; - int rc; -- struct task_struct *task; - struct mm_struct *mm; - -- if (!(task = get_pid_task(ctx->pid, PIDTYPE_PID))) { -- pr_devel("cxl_prefault_vma unable to get task %i\n", -- pid_nr(ctx->pid)); -- return; -- } -- if (!(mm = get_task_mm(task))) { -+ mm = get_mem_context(ctx); -+ if (mm == NULL) { - pr_devel("cxl_prefault_vm unable to get mm %i\n", - pid_nr(ctx->pid)); -- goto out1; -+ return; - } - - down_read(&mm->mmap_sem); -@@ -295,8 +358,6 @@ static void cxl_prefault_vma(struct cxl_context *ctx) - up_read(&mm->mmap_sem); - - mmput(mm); --out1: -- put_task_struct(task); - } - - void cxl_prefault(struct cxl_context *ctx, u64 wed) -diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c -index 7ccd2998be92..783337d22f36 100644 ---- a/drivers/misc/cxl/file.c -+++ b/drivers/misc/cxl/file.c -@@ -67,7 +67,13 @@ static int __afu_open(struct inode *inode, struct file *file, bool master) - spin_unlock(&adapter->afu_list_lock); - goto err_put_adapter; - } -- get_device(&afu->dev); -+ -+ /* -+ * taking a ref to the afu so that it doesn't go away -+ * for rest of the function. This ref is released before -+ * we return. -+ */ -+ cxl_afu_get(afu); - spin_unlock(&adapter->afu_list_lock); - - if (!afu->current_mode) -@@ -90,13 +96,12 @@ static int __afu_open(struct inode *inode, struct file *file, bool master) - file->private_data = ctx; - cxl_ctx_get(); - -- /* Our ref on the AFU will now hold the adapter */ -- put_device(&adapter->dev); -- -- return 0; -+ /* indicate success */ -+ rc = 0; - - err_put_afu: -- put_device(&afu->dev); -+ /* release the ref taken earlier */ -+ cxl_afu_put(afu); - err_put_adapter: - put_device(&adapter->dev); - return rc; -@@ -131,8 +136,6 @@ int afu_release(struct inode *inode, struct file *file) - mutex_unlock(&ctx->mapping_lock); - } - -- put_device(&ctx->afu->dev); -- - /* - * At this this point all bottom halfs have finished and we should be - * getting no more IRQs from the hardware for this context. Once it's -@@ -198,8 +201,12 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, - * where a process (master, some daemon, etc) has opened the chardev on - * behalf of another process, so the AFU's mm gets bound to the process - * that performs this ioctl and not the process that opened the file. -+ * Also we grab the PID of the group leader so that if the task that -+ * has performed the attach operation exits the mm context of the -+ * process is still accessible. - */ -- ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID)); -+ ctx->pid = get_task_pid(current, PIDTYPE_PID); -+ ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); - - trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); - -diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c -index be2c8e248e2e..0c6c17a1c59e 100644 ---- a/drivers/misc/cxl/pci.c -+++ b/drivers/misc/cxl/pci.c -@@ -138,6 +138,7 @@ static const struct pci_device_id cxl_pci_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0477), }, - { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x044b), }, - { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x04cf), }, -+ { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0601), }, - { PCI_DEVICE_CLASS(0x120000, ~0), }, - - { } -diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c -index 1a802af827ed..552a34dc4f82 100644 ---- a/drivers/mmc/host/sdhci.c -+++ b/drivers/mmc/host/sdhci.c -@@ -492,7 +492,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, - host->align_buffer, host->align_buffer_sz, direction); - if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr)) - goto fail; -- BUG_ON(host->align_addr & host->align_mask); -+ BUG_ON(host->align_addr & SDHCI_ADMA2_MASK); - - host->sg_count = sdhci_pre_dma_transfer(host, data); - if (host->sg_count < 0) -@@ -514,8 +514,8 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, - * the (up to three) bytes that screw up the - * alignment. - */ -- offset = (host->align_sz - (addr & host->align_mask)) & -- host->align_mask; -+ offset = (SDHCI_ADMA2_ALIGN - (addr & SDHCI_ADMA2_MASK)) & -+ SDHCI_ADMA2_MASK; - if (offset) { - if (data->flags & MMC_DATA_WRITE) { - buffer = sdhci_kmap_atomic(sg, &flags); -@@ -529,8 +529,8 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, - - BUG_ON(offset > 65536); - -- align += host->align_sz; -- align_addr += host->align_sz; -+ align += SDHCI_ADMA2_ALIGN; -+ align_addr += SDHCI_ADMA2_ALIGN; - - desc += host->desc_sz; - -@@ -611,7 +611,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, - /* Do a quick scan of the SG list for any unaligned mappings */ - has_unaligned = false; - for_each_sg(data->sg, sg, host->sg_count, i) -- if (sg_dma_address(sg) & host->align_mask) { -+ if (sg_dma_address(sg) & SDHCI_ADMA2_MASK) { - has_unaligned = true; - break; - } -@@ -623,15 +623,15 @@ static void sdhci_adma_table_post(struct sdhci_host *host, - align = host->align_buffer; - - for_each_sg(data->sg, sg, host->sg_count, i) { -- if (sg_dma_address(sg) & host->align_mask) { -- size = host->align_sz - -- (sg_dma_address(sg) & host->align_mask); -+ if (sg_dma_address(sg) & SDHCI_ADMA2_MASK) { -+ size = SDHCI_ADMA2_ALIGN - -+ (sg_dma_address(sg) & SDHCI_ADMA2_MASK); - - buffer = sdhci_kmap_atomic(sg, &flags); - memcpy(buffer, align, size); - sdhci_kunmap_atomic(buffer, &flags); - -- align += host->align_sz; -+ align += SDHCI_ADMA2_ALIGN; - } - } - } -@@ -1315,7 +1315,9 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode, - pwr = SDHCI_POWER_330; - break; - default: -- BUG(); -+ WARN(1, "%s: Invalid vdd %#x\n", -+ mmc_hostname(host->mmc), vdd); -+ break; - } - } - -@@ -2983,24 +2985,17 @@ int sdhci_add_host(struct sdhci_host *host) - if (host->flags & SDHCI_USE_64_BIT_DMA) { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * - SDHCI_ADMA2_64_DESC_SZ; -- host->align_buffer_sz = SDHCI_MAX_SEGS * -- SDHCI_ADMA2_64_ALIGN; - host->desc_sz = SDHCI_ADMA2_64_DESC_SZ; -- host->align_sz = SDHCI_ADMA2_64_ALIGN; -- host->align_mask = SDHCI_ADMA2_64_ALIGN - 1; - } else { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * - SDHCI_ADMA2_32_DESC_SZ; -- host->align_buffer_sz = SDHCI_MAX_SEGS * -- SDHCI_ADMA2_32_ALIGN; - host->desc_sz = SDHCI_ADMA2_32_DESC_SZ; -- host->align_sz = SDHCI_ADMA2_32_ALIGN; -- host->align_mask = SDHCI_ADMA2_32_ALIGN - 1; - } - host->adma_table = dma_alloc_coherent(mmc_dev(mmc), - host->adma_table_sz, - &host->adma_addr, - GFP_KERNEL); -+ host->align_buffer_sz = SDHCI_MAX_SEGS * SDHCI_ADMA2_ALIGN; - host->align_buffer = kmalloc(host->align_buffer_sz, GFP_KERNEL); - if (!host->adma_table || !host->align_buffer) { - if (host->adma_table) -@@ -3014,7 +3009,7 @@ int sdhci_add_host(struct sdhci_host *host) - host->flags &= ~SDHCI_USE_ADMA; - host->adma_table = NULL; - host->align_buffer = NULL; -- } else if (host->adma_addr & host->align_mask) { -+ } else if (host->adma_addr & (SDHCI_ADMA2_DESC_ALIGN - 1)) { - pr_warn("%s: unable to allocate aligned ADMA descriptor\n", - mmc_hostname(mmc)); - host->flags &= ~SDHCI_USE_ADMA; -diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h -index 9c331ac5ad6b..0115e9907bf8 100644 ---- a/drivers/mmc/host/sdhci.h -+++ b/drivers/mmc/host/sdhci.h -@@ -272,22 +272,27 @@ - /* ADMA2 32-bit DMA descriptor size */ - #define SDHCI_ADMA2_32_DESC_SZ 8 - --/* ADMA2 32-bit DMA alignment */ --#define SDHCI_ADMA2_32_ALIGN 4 -- - /* ADMA2 32-bit descriptor */ - struct sdhci_adma2_32_desc { - __le16 cmd; - __le16 len; - __le32 addr; --} __packed __aligned(SDHCI_ADMA2_32_ALIGN); -+} __packed __aligned(4); -+ -+/* ADMA2 data alignment */ -+#define SDHCI_ADMA2_ALIGN 4 -+#define SDHCI_ADMA2_MASK (SDHCI_ADMA2_ALIGN - 1) -+ -+/* -+ * ADMA2 descriptor alignment. Some controllers (e.g. Intel) require 8 byte -+ * alignment for the descriptor table even in 32-bit DMA mode. Memory -+ * allocation is at least 8 byte aligned anyway, so just stipulate 8 always. -+ */ -+#define SDHCI_ADMA2_DESC_ALIGN 8 - - /* ADMA2 64-bit DMA descriptor size */ - #define SDHCI_ADMA2_64_DESC_SZ 12 - --/* ADMA2 64-bit DMA alignment */ --#define SDHCI_ADMA2_64_ALIGN 8 -- - /* - * ADMA2 64-bit descriptor. Note 12-byte descriptor can't always be 8-byte - * aligned. -@@ -483,8 +488,6 @@ struct sdhci_host { - dma_addr_t align_addr; /* Mapped bounce buffer */ - - unsigned int desc_sz; /* ADMA descriptor size */ -- unsigned int align_sz; /* ADMA alignment */ -- unsigned int align_mask; /* ADMA alignment mask */ - - struct tasklet_struct finish_tasklet; /* Tasklet structures */ - -diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c -index b89504405b72..7445da218bd9 100644 ---- a/drivers/net/ethernet/cavium/liquidio/lio_main.c -+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c -@@ -2526,7 +2526,7 @@ static void handle_timestamp(struct octeon_device *oct, - - octeon_swap_8B_data(&resp->timestamp, 1); - -- if (unlikely((skb_shinfo(skb)->tx_flags | SKBTX_IN_PROGRESS) != 0)) { -+ if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS) != 0)) { - struct skb_shared_hwtstamps ts; - u64 ns = resp->timestamp; - -diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h -index 39ca6744a4e6..22471d283a95 100644 ---- a/drivers/net/ethernet/cavium/thunder/nic.h -+++ b/drivers/net/ethernet/cavium/thunder/nic.h -@@ -116,6 +116,15 @@ - #define NIC_PF_INTR_ID_MBOX0 8 - #define NIC_PF_INTR_ID_MBOX1 9 - -+/* Minimum FIFO level before all packets for the CQ are dropped -+ * -+ * This value ensures that once a packet has been "accepted" -+ * for reception it will not get dropped due to non-availability -+ * of CQ descriptor. An errata in HW mandates this value to be -+ * atleast 0x100. -+ */ -+#define NICPF_CQM_MIN_DROP_LEVEL 0x100 -+ - /* Global timer for CQ timer thresh interrupts - * Calculated for SCLK of 700Mhz - * value written should be a 1/16th of what is expected -diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c -index 5f24d11cb16a..16baaafed26c 100644 ---- a/drivers/net/ethernet/cavium/thunder/nic_main.c -+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c -@@ -309,6 +309,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) - static void nic_init_hw(struct nicpf *nic) - { - int i; -+ u64 cqm_cfg; - - /* Enable NIC HW block */ - nic_reg_write(nic, NIC_PF_CFG, 0x3); -@@ -345,6 +346,11 @@ static void nic_init_hw(struct nicpf *nic) - /* Enable VLAN ethertype matching and stripping */ - nic_reg_write(nic, NIC_PF_RX_ETYPE_0_7, - (2 << 19) | (ETYPE_ALG_VLAN_STRIP << 16) | ETH_P_8021Q); -+ -+ /* Check if HW expected value is higher (could be in future chips) */ -+ cqm_cfg = nic_reg_read(nic, NIC_PF_CQM_CFG); -+ if (cqm_cfg < NICPF_CQM_MIN_DROP_LEVEL) -+ nic_reg_write(nic, NIC_PF_CQM_CFG, NICPF_CQM_MIN_DROP_LEVEL); - } - - /* Channel parse index configuration */ -diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h -index dd536be20193..afb10e326b4f 100644 ---- a/drivers/net/ethernet/cavium/thunder/nic_reg.h -+++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h -@@ -21,7 +21,7 @@ - #define NIC_PF_TCP_TIMER (0x0060) - #define NIC_PF_BP_CFG (0x0080) - #define NIC_PF_RRM_CFG (0x0088) --#define NIC_PF_CQM_CF (0x00A0) -+#define NIC_PF_CQM_CFG (0x00A0) - #define NIC_PF_CNM_CF (0x00A8) - #define NIC_PF_CNM_STATUS (0x00B0) - #define NIC_PF_CQ_AVG_CFG (0x00C0) -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c -index dde8dc720cd3..b7093b9cd1e8 100644 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c -@@ -566,8 +566,7 @@ static inline void nicvf_set_rxhash(struct net_device *netdev, - - static void nicvf_rcv_pkt_handler(struct net_device *netdev, - struct napi_struct *napi, -- struct cmp_queue *cq, -- struct cqe_rx_t *cqe_rx, int cqe_type) -+ struct cqe_rx_t *cqe_rx) - { - struct sk_buff *skb; - struct nicvf *nic = netdev_priv(netdev); -@@ -583,7 +582,7 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev, - } - - /* Check for errors */ -- err = nicvf_check_cqe_rx_errs(nic, cq, cqe_rx); -+ err = nicvf_check_cqe_rx_errs(nic, cqe_rx); - if (err && !cqe_rx->rb_cnt) - return; - -@@ -674,8 +673,7 @@ loop: - cq_idx, cq_desc->cqe_type); - switch (cq_desc->cqe_type) { - case CQE_TYPE_RX: -- nicvf_rcv_pkt_handler(netdev, napi, cq, -- cq_desc, CQE_TYPE_RX); -+ nicvf_rcv_pkt_handler(netdev, napi, cq_desc); - work_done++; - break; - case CQE_TYPE_SEND: -@@ -1117,7 +1115,6 @@ int nicvf_stop(struct net_device *netdev) - - /* Clear multiqset info */ - nic->pnicvf = nic; -- nic->sqs_count = 0; - - return 0; - } -@@ -1346,6 +1343,9 @@ void nicvf_update_stats(struct nicvf *nic) - drv_stats->tx_frames_ok = stats->tx_ucast_frames_ok + - stats->tx_bcast_frames_ok + - stats->tx_mcast_frames_ok; -+ drv_stats->rx_frames_ok = stats->rx_ucast_frames + -+ stats->rx_bcast_frames + -+ stats->rx_mcast_frames; - drv_stats->rx_drops = stats->rx_drop_red + - stats->rx_drop_overrun; - drv_stats->tx_drops = stats->tx_drops; -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c -index d1c217eaf417..912ee28ab58b 100644 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c -@@ -1414,16 +1414,12 @@ void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx) - } - - /* Check for errors in the receive cmp.queue entry */ --int nicvf_check_cqe_rx_errs(struct nicvf *nic, -- struct cmp_queue *cq, struct cqe_rx_t *cqe_rx) -+int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx) - { - struct nicvf_hw_stats *stats = &nic->hw_stats; -- struct nicvf_drv_stats *drv_stats = &nic->drv_stats; - -- if (!cqe_rx->err_level && !cqe_rx->err_opcode) { -- drv_stats->rx_frames_ok++; -+ if (!cqe_rx->err_level && !cqe_rx->err_opcode) - return 0; -- } - - if (netif_msg_rx_err(nic)) - netdev_err(nic->netdev, -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h -index 033e8306e91c..5652c612e20b 100644 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h -@@ -344,8 +344,7 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, - /* Stats */ - void nicvf_update_rq_stats(struct nicvf *nic, int rq_idx); - void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx); --int nicvf_check_cqe_rx_errs(struct nicvf *nic, -- struct cmp_queue *cq, struct cqe_rx_t *cqe_rx); -+int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx); - int nicvf_check_cqe_tx_errs(struct nicvf *nic, - struct cmp_queue *cq, struct cqe_send_t *cqe_tx); - #endif /* NICVF_QUEUES_H */ -diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c -index 9df26c2263bc..42718cc7d4e8 100644 ---- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c -+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c -@@ -549,7 +549,9 @@ static int bgx_xaui_check_link(struct lmac *lmac) - } - - /* Clear rcvflt bit (latching high) and read it back */ -- bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT); -+ if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) -+ bgx_reg_modify(bgx, lmacid, -+ BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT); - if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { - dev_err(&bgx->pdev->dev, "Receive fault, retry training\n"); - if (bgx->use_training) { -@@ -568,13 +570,6 @@ static int bgx_xaui_check_link(struct lmac *lmac) - return -1; - } - -- /* Wait for MAC RX to be ready */ -- if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_RX_CTL, -- SMU_RX_CTL_STATUS, true)) { -- dev_err(&bgx->pdev->dev, "SMU RX link not okay\n"); -- return -1; -- } -- - /* Wait for BGX RX to be idle */ - if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) { - dev_err(&bgx->pdev->dev, "SMU RX not idle\n"); -@@ -587,29 +582,30 @@ static int bgx_xaui_check_link(struct lmac *lmac) - return -1; - } - -- if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { -- dev_err(&bgx->pdev->dev, "Receive fault\n"); -- return -1; -- } -- -- /* Receive link is latching low. Force it high and verify it */ -- bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS1, SPU_STATUS1_RCV_LNK); -- if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_STATUS1, -- SPU_STATUS1_RCV_LNK, false)) { -- dev_err(&bgx->pdev->dev, "SPU receive link down\n"); -- return -1; -- } -- -+ /* Clear receive packet disable */ - cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL); - cfg &= ~SPU_MISC_CTL_RX_DIS; - bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg); -- return 0; -+ -+ /* Check for MAC RX faults */ -+ cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_CTL); -+ /* 0 - Link is okay, 1 - Local fault, 2 - Remote fault */ -+ cfg &= SMU_RX_CTL_STATUS; -+ if (!cfg) -+ return 0; -+ -+ /* Rx local/remote fault seen. -+ * Do lmac reinit to see if condition recovers -+ */ -+ bgx_lmac_xaui_init(bgx, lmacid, bgx->lmac_type); -+ -+ return -1; - } - - static void bgx_poll_for_link(struct work_struct *work) - { - struct lmac *lmac; -- u64 link; -+ u64 spu_link, smu_link; - - lmac = container_of(work, struct lmac, dwork.work); - -@@ -619,8 +615,11 @@ static void bgx_poll_for_link(struct work_struct *work) - bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1, - SPU_STATUS1_RCV_LNK, false); - -- link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); -- if (link & SPU_STATUS1_RCV_LNK) { -+ spu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); -+ smu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SMUX_RX_CTL); -+ -+ if ((spu_link & SPU_STATUS1_RCV_LNK) && -+ !(smu_link & SMU_RX_CTL_STATUS)) { - lmac->link_up = 1; - if (lmac->bgx->lmac_type == BGX_MODE_XLAUI) - lmac->last_speed = 40000; -@@ -634,9 +633,15 @@ static void bgx_poll_for_link(struct work_struct *work) - } - - if (lmac->last_link != lmac->link_up) { -+ if (lmac->link_up) { -+ if (bgx_xaui_check_link(lmac)) { -+ /* Errors, clear link_up state */ -+ lmac->link_up = 0; -+ lmac->last_speed = SPEED_UNKNOWN; -+ lmac->last_duplex = DUPLEX_UNKNOWN; -+ } -+ } - lmac->last_link = lmac->link_up; -- if (lmac->link_up) -- bgx_xaui_check_link(lmac); - } - - queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2); -@@ -708,7 +713,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) - static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) - { - struct lmac *lmac; -- u64 cmrx_cfg; -+ u64 cfg; - - lmac = &bgx->lmac[lmacid]; - if (lmac->check_link) { -@@ -717,9 +722,33 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) - destroy_workqueue(lmac->check_link); - } - -- cmrx_cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); -- cmrx_cfg &= ~(1 << 15); -- bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cmrx_cfg); -+ /* Disable packet reception */ -+ cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); -+ cfg &= ~CMR_PKT_RX_EN; -+ bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); -+ -+ /* Give chance for Rx/Tx FIFO to get drained */ -+ bgx_poll_reg(bgx, lmacid, BGX_CMRX_RX_FIFO_LEN, (u64)0x1FFF, true); -+ bgx_poll_reg(bgx, lmacid, BGX_CMRX_TX_FIFO_LEN, (u64)0x3FFF, true); -+ -+ /* Disable packet transmission */ -+ cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); -+ cfg &= ~CMR_PKT_TX_EN; -+ bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); -+ -+ /* Disable serdes lanes */ -+ if (!lmac->is_sgmii) -+ bgx_reg_modify(bgx, lmacid, -+ BGX_SPUX_CONTROL1, SPU_CTL_LOW_POWER); -+ else -+ bgx_reg_modify(bgx, lmacid, -+ BGX_GMP_PCS_MRX_CTL, PCS_MRX_CTL_PWR_DN); -+ -+ /* Disable LMAC */ -+ cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); -+ cfg &= ~CMR_EN; -+ bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); -+ - bgx_flush_dmac_addrs(bgx, lmacid); - - if ((bgx->lmac_type != BGX_MODE_XFI) && -diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h -index 149e179363a1..42010d2e5ddf 100644 ---- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h -+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h -@@ -41,6 +41,7 @@ - #define BGX_CMRX_RX_STAT10 0xC0 - #define BGX_CMRX_RX_BP_DROP 0xC8 - #define BGX_CMRX_RX_DMAC_CTL 0x0E8 -+#define BGX_CMRX_RX_FIFO_LEN 0x108 - #define BGX_CMR_RX_DMACX_CAM 0x200 - #define RX_DMACX_CAM_EN BIT_ULL(48) - #define RX_DMACX_CAM_LMACID(x) (x << 49) -@@ -50,6 +51,7 @@ - #define BGX_CMR_CHAN_MSK_AND 0x450 - #define BGX_CMR_BIST_STATUS 0x460 - #define BGX_CMR_RX_LMACS 0x468 -+#define BGX_CMRX_TX_FIFO_LEN 0x518 - #define BGX_CMRX_TX_STAT0 0x600 - #define BGX_CMRX_TX_STAT1 0x608 - #define BGX_CMRX_TX_STAT2 0x610 -diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h -index 69707108d23c..98fe5a2cd6e3 100644 ---- a/drivers/net/ethernet/intel/e1000/e1000.h -+++ b/drivers/net/ethernet/intel/e1000/e1000.h -@@ -213,8 +213,11 @@ struct e1000_rx_ring { - }; - - #define E1000_DESC_UNUSED(R) \ -- ((((R)->next_to_clean > (R)->next_to_use) \ -- ? 0 : (R)->count) + (R)->next_to_clean - (R)->next_to_use - 1) -+({ \ -+ unsigned int clean = smp_load_acquire(&(R)->next_to_clean); \ -+ unsigned int use = READ_ONCE((R)->next_to_use); \ -+ (clean > use ? 0 : (R)->count) + clean - use - 1; \ -+}) - - #define E1000_RX_DESC_EXT(R, i) \ - (&(((union e1000_rx_desc_extended *)((R).desc))[i])) -diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c -index fd7be860c201..068023595d84 100644 ---- a/drivers/net/ethernet/intel/e1000/e1000_main.c -+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c -@@ -3876,7 +3876,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, - eop_desc = E1000_TX_DESC(*tx_ring, eop); - } - -- tx_ring->next_to_clean = i; -+ /* Synchronize with E1000_DESC_UNUSED called from e1000_xmit_frame, -+ * which will reuse the cleaned buffers. -+ */ -+ smp_store_release(&tx_ring->next_to_clean, i); - - netdev_completed_queue(netdev, pkts_compl, bytes_compl); - -diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c -index 0a854a47d31a..80ec587d510e 100644 ---- a/drivers/net/ethernet/intel/e1000e/netdev.c -+++ b/drivers/net/ethernet/intel/e1000e/netdev.c -@@ -1959,8 +1959,10 @@ static irqreturn_t e1000_intr_msix_rx(int __always_unused irq, void *data) - * previous interrupt. - */ - if (rx_ring->set_itr) { -- writel(1000000000 / (rx_ring->itr_val * 256), -- rx_ring->itr_register); -+ u32 itr = rx_ring->itr_val ? -+ 1000000000 / (rx_ring->itr_val * 256) : 0; -+ -+ writel(itr, rx_ring->itr_register); - rx_ring->set_itr = 0; - } - -diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h -index 14440200499b..48809e5d3f79 100644 ---- a/drivers/net/ethernet/intel/fm10k/fm10k.h -+++ b/drivers/net/ethernet/intel/fm10k/fm10k.h -@@ -33,7 +33,7 @@ - #include "fm10k_pf.h" - #include "fm10k_vf.h" - --#define FM10K_MAX_JUMBO_FRAME_SIZE 15358 /* Maximum supported size 15K */ -+#define FM10K_MAX_JUMBO_FRAME_SIZE 15342 /* Maximum supported size 15K */ - - #define MAX_QUEUES FM10K_MAX_QUEUES_PF - -diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c -index e76a44cf330c..09281558bfbc 100644 ---- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c -+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c -@@ -1428,6 +1428,10 @@ static int fm10k_poll(struct napi_struct *napi, int budget) - fm10k_for_each_ring(ring, q_vector->tx) - clean_complete &= fm10k_clean_tx_irq(q_vector, ring); - -+ /* Handle case where we are called by netpoll with a budget of 0 */ -+ if (budget <= 0) -+ return budget; -+ - /* attempt to distribute budget to each queue fairly, but don't - * allow the budget to go below 1 because we'll exit polling - */ -@@ -1966,8 +1970,10 @@ int fm10k_init_queueing_scheme(struct fm10k_intfc *interface) - - /* Allocate memory for queues */ - err = fm10k_alloc_q_vectors(interface); -- if (err) -+ if (err) { -+ fm10k_reset_msix_capability(interface); - return err; -+ } - - /* Map rings to devices, and map devices to physical queues */ - fm10k_assign_rings(interface); -diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c -index 74be792f3f1b..7f3fb51bc37b 100644 ---- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c -+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c -@@ -159,13 +159,30 @@ static void fm10k_reinit(struct fm10k_intfc *interface) - - fm10k_mbx_free_irq(interface); - -+ /* free interrupts */ -+ fm10k_clear_queueing_scheme(interface); -+ - /* delay any future reset requests */ - interface->last_reset = jiffies + (10 * HZ); - - /* reset and initialize the hardware so it is in a known state */ -- err = hw->mac.ops.reset_hw(hw) ? : hw->mac.ops.init_hw(hw); -- if (err) -+ err = hw->mac.ops.reset_hw(hw); -+ if (err) { -+ dev_err(&interface->pdev->dev, "reset_hw failed: %d\n", err); -+ goto reinit_err; -+ } -+ -+ err = hw->mac.ops.init_hw(hw); -+ if (err) { - dev_err(&interface->pdev->dev, "init_hw failed: %d\n", err); -+ goto reinit_err; -+ } -+ -+ err = fm10k_init_queueing_scheme(interface); -+ if (err) { -+ dev_err(&interface->pdev->dev, "init_queueing_scheme failed: %d\n", err); -+ goto reinit_err; -+ } - - /* reassociate interrupts */ - fm10k_mbx_request_irq(interface); -@@ -193,6 +210,10 @@ static void fm10k_reinit(struct fm10k_intfc *interface) - - fm10k_iov_resume(interface->pdev); - -+reinit_err: -+ if (err) -+ netif_device_detach(netdev); -+ - rtnl_unlock(); - - clear_bit(__FM10K_RESETTING, &interface->state); -@@ -1101,6 +1122,10 @@ void fm10k_mbx_free_irq(struct fm10k_intfc *interface) - struct fm10k_hw *hw = &interface->hw; - int itr_reg; - -+ /* no mailbox IRQ to free if MSI-X is not enabled */ -+ if (!interface->msix_entries) -+ return; -+ - /* disconnect the mailbox */ - hw->mbx.ops.disconnect(hw, &hw->mbx); - -@@ -1423,10 +1448,15 @@ int fm10k_mbx_request_irq(struct fm10k_intfc *interface) - err = fm10k_mbx_request_irq_pf(interface); - else - err = fm10k_mbx_request_irq_vf(interface); -+ if (err) -+ return err; - - /* connect mailbox */ -- if (!err) -- err = hw->mbx.ops.connect(hw, &hw->mbx); -+ err = hw->mbx.ops.connect(hw, &hw->mbx); -+ -+ /* if the mailbox failed to connect, then free IRQ */ -+ if (err) -+ fm10k_mbx_free_irq(interface); - - return err; - } -@@ -1684,7 +1714,13 @@ static int fm10k_sw_init(struct fm10k_intfc *interface, - interface->last_reset = jiffies + (10 * HZ); - - /* reset and initialize the hardware so it is in a known state */ -- err = hw->mac.ops.reset_hw(hw) ? : hw->mac.ops.init_hw(hw); -+ err = hw->mac.ops.reset_hw(hw); -+ if (err) { -+ dev_err(&pdev->dev, "reset_hw failed: %d\n", err); -+ return err; -+ } -+ -+ err = hw->mac.ops.init_hw(hw); - if (err) { - dev_err(&pdev->dev, "init_hw failed: %d\n", err); - return err; -@@ -2071,8 +2107,10 @@ static int fm10k_resume(struct pci_dev *pdev) - - /* reset hardware to known state */ - err = hw->mac.ops.init_hw(&interface->hw); -- if (err) -+ if (err) { -+ dev_err(&pdev->dev, "init_hw failed: %d\n", err); - return err; -+ } - - /* reset statistics starting values */ - hw->mac.ops.rebind_hw_stats(hw, &interface->stats); -@@ -2185,6 +2223,9 @@ static pci_ers_result_t fm10k_io_error_detected(struct pci_dev *pdev, - if (netif_running(netdev)) - fm10k_close(netdev); - -+ /* free interrupts */ -+ fm10k_clear_queueing_scheme(interface); -+ - fm10k_mbx_free_irq(interface); - - pci_disable_device(pdev); -@@ -2248,11 +2289,21 @@ static void fm10k_io_resume(struct pci_dev *pdev) - int err = 0; - - /* reset hardware to known state */ -- hw->mac.ops.init_hw(&interface->hw); -+ err = hw->mac.ops.init_hw(&interface->hw); -+ if (err) { -+ dev_err(&pdev->dev, "init_hw failed: %d\n", err); -+ return; -+ } - - /* reset statistics starting values */ - hw->mac.ops.rebind_hw_stats(hw, &interface->stats); - -+ err = fm10k_init_queueing_scheme(interface); -+ if (err) { -+ dev_err(&interface->pdev->dev, "init_queueing_scheme failed: %d\n", err); -+ return; -+ } -+ - /* reassociate interrupts */ - fm10k_mbx_request_irq(interface); - -diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_type.h b/drivers/net/ethernet/intel/fm10k/fm10k_type.h -index 318a212f0a78..35afd711d144 100644 ---- a/drivers/net/ethernet/intel/fm10k/fm10k_type.h -+++ b/drivers/net/ethernet/intel/fm10k/fm10k_type.h -@@ -77,6 +77,7 @@ struct fm10k_hw; - #define FM10K_PCIE_SRIOV_CTRL_VFARI 0x10 - - #define FM10K_ERR_PARAM -2 -+#define FM10K_ERR_NO_RESOURCES -3 - #define FM10K_ERR_REQUESTS_PENDING -4 - #define FM10K_ERR_RESET_REQUESTED -5 - #define FM10K_ERR_DMA_PENDING -6 -diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_vf.c b/drivers/net/ethernet/intel/fm10k/fm10k_vf.c -index 36c8b0aa08fd..d512575c33f3 100644 ---- a/drivers/net/ethernet/intel/fm10k/fm10k_vf.c -+++ b/drivers/net/ethernet/intel/fm10k/fm10k_vf.c -@@ -103,7 +103,14 @@ static s32 fm10k_init_hw_vf(struct fm10k_hw *hw) - s32 err; - u16 i; - -- /* assume we always have at least 1 queue */ -+ /* verify we have at least 1 queue */ -+ if (!~fm10k_read_reg(hw, FM10K_TXQCTL(0)) || -+ !~fm10k_read_reg(hw, FM10K_RXQCTL(0))) { -+ err = FM10K_ERR_NO_RESOURCES; -+ goto reset_max_queues; -+ } -+ -+ /* determine how many queues we have */ - for (i = 1; tqdloc0 && (i < FM10K_MAX_QUEUES_POOL); i++) { - /* verify the Descriptor cache offsets are increasing */ - tqdloc = ~fm10k_read_reg(hw, FM10K_TQDLOC(i)); -@@ -119,7 +126,7 @@ static s32 fm10k_init_hw_vf(struct fm10k_hw *hw) - /* shut down queues we own and reset DMA configuration */ - err = fm10k_disable_queues_generic(hw, i); - if (err) -- return err; -+ goto reset_max_queues; - - /* record maximum queue count */ - hw->mac.max_queues = i; -@@ -129,6 +136,11 @@ static s32 fm10k_init_hw_vf(struct fm10k_hw *hw) - FM10K_TXQCTL_VID_MASK) >> FM10K_TXQCTL_VID_SHIFT; - - return 0; -+ -+reset_max_queues: -+ hw->mac.max_queues = 0; -+ -+ return err; - } - - /* This structure defines the attibutes to be parsed below */ -diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h -index 4dd3e26129b4..7e258a83ccab 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e.h -+++ b/drivers/net/ethernet/intel/i40e/i40e.h -@@ -767,6 +767,8 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid); - int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid); - struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, u8 *macaddr, - bool is_vf, bool is_netdev); -+int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, u8 *macaddr, -+ bool is_vf, bool is_netdev); - bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi); - struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, u8 *macaddr, - bool is_vf, bool is_netdev); -diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -index 3f385ffe420f..488a50d59dca 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -@@ -2164,8 +2164,7 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc) - case TCP_V4_FLOW: - switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - case 0: -- hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); -- break; -+ return -EINVAL; - case (RXH_L4_B_0_1 | RXH_L4_B_2_3): - hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); - break; -@@ -2176,8 +2175,7 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc) - case TCP_V6_FLOW: - switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - case 0: -- hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); -- break; -+ return -EINVAL; - case (RXH_L4_B_0_1 | RXH_L4_B_2_3): - hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); - break; -@@ -2188,9 +2186,7 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc) - case UDP_V4_FLOW: - switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - case 0: -- hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | -- BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); -- break; -+ return -EINVAL; - case (RXH_L4_B_0_1 | RXH_L4_B_2_3): - hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | - BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); -@@ -2202,9 +2198,7 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc) - case UDP_V6_FLOW: - switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - case 0: -- hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | -- BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); -- break; -+ return -EINVAL; - case (RXH_L4_B_0_1 | RXH_L4_B_2_3): - hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | - BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index 4a9873ec28c7..2215bebe208e 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c -@@ -1317,6 +1317,42 @@ struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, u8 *macaddr, - } - - /** -+ * i40e_del_mac_all_vlan - Remove a MAC filter from all VLANS -+ * @vsi: the VSI to be searched -+ * @macaddr: the mac address to be removed -+ * @is_vf: true if it is a VF -+ * @is_netdev: true if it is a netdev -+ * -+ * Removes a given MAC address from a VSI, regardless of VLAN -+ * -+ * Returns 0 for success, or error -+ **/ -+int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, u8 *macaddr, -+ bool is_vf, bool is_netdev) -+{ -+ struct i40e_mac_filter *f = NULL; -+ int changed = 0; -+ -+ WARN(!spin_is_locked(&vsi->mac_filter_list_lock), -+ "Missing mac_filter_list_lock\n"); -+ list_for_each_entry(f, &vsi->mac_filter_list, list) { -+ if ((ether_addr_equal(macaddr, f->macaddr)) && -+ (is_vf == f->is_vf) && -+ (is_netdev == f->is_netdev)) { -+ f->counter--; -+ f->changed = true; -+ changed = 1; -+ } -+ } -+ if (changed) { -+ vsi->flags |= I40E_VSI_FLAG_FILTER_CHANGED; -+ vsi->back->flags |= I40E_FLAG_FILTER_SYNC; -+ return 0; -+ } -+ return -ENOENT; -+} -+ -+/** - * i40e_rm_default_mac_filter - Remove the default MAC filter set by NVM - * @vsi: the PF Main VSI - inappropriate for any other VSI - * @macaddr: the MAC address -@@ -1547,9 +1583,11 @@ static int i40e_set_mac(struct net_device *netdev, void *p) - spin_unlock_bh(&vsi->mac_filter_list_lock); - } - -- i40e_sync_vsi_filters(vsi, false); - ether_addr_copy(netdev->dev_addr, addr->sa_data); -- -+ /* schedule our worker thread which will take care of -+ * applying the new filter changes -+ */ -+ i40e_service_event_schedule(vsi->back); - return 0; - } - -@@ -1935,11 +1973,13 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl) - - /* Now process 'del_list' outside the lock */ - if (!list_empty(&tmp_del_list)) { -+ int del_list_size; -+ - filter_list_len = pf->hw.aq.asq_buf_size / - sizeof(struct i40e_aqc_remove_macvlan_element_data); -- del_list = kcalloc(filter_list_len, -- sizeof(struct i40e_aqc_remove_macvlan_element_data), -- GFP_KERNEL); -+ del_list_size = filter_list_len * -+ sizeof(struct i40e_aqc_remove_macvlan_element_data); -+ del_list = kzalloc(del_list_size, GFP_KERNEL); - if (!del_list) { - i40e_cleanup_add_list(&tmp_add_list); - -@@ -1971,7 +2011,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl) - NULL); - aq_err = pf->hw.aq.asq_last_status; - num_del = 0; -- memset(del_list, 0, sizeof(*del_list)); -+ memset(del_list, 0, del_list_size); - - if (ret && aq_err != I40E_AQ_RC_ENOENT) - dev_err(&pf->pdev->dev, -@@ -2004,13 +2044,14 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl) - } - - if (!list_empty(&tmp_add_list)) { -+ int add_list_size; - - /* do all the adds now */ - filter_list_len = pf->hw.aq.asq_buf_size / - sizeof(struct i40e_aqc_add_macvlan_element_data), -- add_list = kcalloc(filter_list_len, -- sizeof(struct i40e_aqc_add_macvlan_element_data), -- GFP_KERNEL); -+ add_list_size = filter_list_len * -+ sizeof(struct i40e_aqc_add_macvlan_element_data); -+ add_list = kzalloc(add_list_size, GFP_KERNEL); - if (!add_list) { - /* Purge element from temporary lists */ - i40e_cleanup_add_list(&tmp_add_list); -@@ -2048,7 +2089,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl) - - if (ret) - break; -- memset(add_list, 0, sizeof(*add_list)); -+ memset(add_list, 0, add_list_size); - } - /* Entries from tmp_add_list were cloned from MAC - * filter list, hence clean those cloned entries -@@ -2112,12 +2153,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl) - */ - if (pf->cur_promisc != cur_promisc) { - pf->cur_promisc = cur_promisc; -- if (grab_rtnl) -- i40e_do_reset_safe(pf, -- BIT(__I40E_PF_RESET_REQUESTED)); -- else -- i40e_do_reset(pf, -- BIT(__I40E_PF_RESET_REQUESTED)); -+ set_bit(__I40E_PF_RESET_REQUESTED, &pf->state); - } - } else { - ret = i40e_aq_set_vsi_unicast_promiscuous( -@@ -2377,16 +2413,13 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid) - } - } - -- /* Make sure to release before sync_vsi_filter because that -- * function will lock/unlock as necessary -- */ - spin_unlock_bh(&vsi->mac_filter_list_lock); - -- if (test_bit(__I40E_DOWN, &vsi->back->state) || -- test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) -- return 0; -- -- return i40e_sync_vsi_filters(vsi, false); -+ /* schedule our worker thread which will take care of -+ * applying the new filter changes -+ */ -+ i40e_service_event_schedule(vsi->back); -+ return 0; - } - - /** -@@ -2459,16 +2492,13 @@ int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid) - } - } - -- /* Make sure to release before sync_vsi_filter because that -- * function with lock/unlock as necessary -- */ - spin_unlock_bh(&vsi->mac_filter_list_lock); - -- if (test_bit(__I40E_DOWN, &vsi->back->state) || -- test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) -- return 0; -- -- return i40e_sync_vsi_filters(vsi, false); -+ /* schedule our worker thread which will take care of -+ * applying the new filter changes -+ */ -+ i40e_service_event_schedule(vsi->back); -+ return 0; - } - - /** -@@ -2711,6 +2741,11 @@ static void i40e_config_xps_tx_ring(struct i40e_ring *ring) - netif_set_xps_queue(ring->netdev, mask, ring->queue_index); - free_cpumask_var(mask); - } -+ -+ /* schedule our worker thread which will take care of -+ * applying the new filter changes -+ */ -+ i40e_service_event_schedule(vsi->back); - } - - /** -@@ -6685,6 +6720,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) - struct i40e_hw *hw = &pf->hw; - u8 set_fc_aq_fail = 0; - i40e_status ret; -+ u32 val; - u32 v; - - /* Now we wait for GRST to settle out. -@@ -6823,6 +6859,20 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) - } - } - -+ /* Reconfigure hardware for allowing smaller MSS in the case -+ * of TSO, so that we avoid the MDD being fired and causing -+ * a reset in the case of small MSS+TSO. -+ */ -+#define I40E_REG_MSS 0x000E64DC -+#define I40E_REG_MSS_MIN_MASK 0x3FF0000 -+#define I40E_64BYTE_MSS 0x400000 -+ val = rd32(hw, I40E_REG_MSS); -+ if ((val & I40E_REG_MSS_MIN_MASK) > I40E_64BYTE_MSS) { -+ val &= ~I40E_REG_MSS_MIN_MASK; -+ val |= I40E_64BYTE_MSS; -+ wr32(hw, I40E_REG_MSS, val); -+ } -+ - if (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 33)) || - (pf->hw.aq.fw_maj_ver < 4)) { - msleep(75); -@@ -10183,6 +10233,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - u16 link_status; - int err; - u32 len; -+ u32 val; - u32 i; - u8 set_fc_aq_fail; - -@@ -10493,6 +10544,17 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - i40e_stat_str(&pf->hw, err), - i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); - -+ /* Reconfigure hardware for allowing smaller MSS in the case -+ * of TSO, so that we avoid the MDD being fired and causing -+ * a reset in the case of small MSS+TSO. -+ */ -+ val = rd32(hw, I40E_REG_MSS); -+ if ((val & I40E_REG_MSS_MIN_MASK) > I40E_64BYTE_MSS) { -+ val &= ~I40E_REG_MSS_MIN_MASK; -+ val |= I40E_64BYTE_MSS; -+ wr32(hw, I40E_REG_MSS, val); -+ } -+ - if (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 33)) || - (pf->hw.aq.fw_maj_ver < 4)) { - msleep(75); -diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -index 635b3ac17877..26c55bba4bf3 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -@@ -235,6 +235,9 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi, - "Filter deleted for PCTYPE %d loc = %d\n", - fd_data->pctype, fd_data->fd_id); - } -+ if (err) -+ kfree(raw_packet); -+ - return err ? -EOPNOTSUPP : 0; - } - -@@ -312,6 +315,9 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, - fd_data->pctype, fd_data->fd_id); - } - -+ if (err) -+ kfree(raw_packet); -+ - return err ? -EOPNOTSUPP : 0; - } - -@@ -387,6 +393,9 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, - } - } - -+ if (err) -+ kfree(raw_packet); -+ - return err ? -EOPNOTSUPP : 0; - } - -@@ -526,11 +535,7 @@ static void i40e_unmap_and_free_tx_resource(struct i40e_ring *ring, - struct i40e_tx_buffer *tx_buffer) - { - if (tx_buffer->skb) { -- if (tx_buffer->tx_flags & I40E_TX_FLAGS_FD_SB) -- kfree(tx_buffer->raw_buf); -- else -- dev_kfree_skb_any(tx_buffer->skb); -- -+ dev_kfree_skb_any(tx_buffer->skb); - if (dma_unmap_len(tx_buffer, len)) - dma_unmap_single(ring->dev, - dma_unmap_addr(tx_buffer, dma), -@@ -542,6 +547,10 @@ static void i40e_unmap_and_free_tx_resource(struct i40e_ring *ring, - dma_unmap_len(tx_buffer, len), - DMA_TO_DEVICE); - } -+ -+ if (tx_buffer->tx_flags & I40E_TX_FLAGS_FD_SB) -+ kfree(tx_buffer->raw_buf); -+ - tx_buffer->next_to_watch = NULL; - tx_buffer->skb = NULL; - dma_unmap_len_set(tx_buffer, len, 0); -@@ -1416,31 +1425,12 @@ checksum_fail: - } - - /** -- * i40e_rx_hash - returns the hash value from the Rx descriptor -- * @ring: descriptor ring -- * @rx_desc: specific descriptor -- **/ --static inline u32 i40e_rx_hash(struct i40e_ring *ring, -- union i40e_rx_desc *rx_desc) --{ -- const __le64 rss_mask = -- cpu_to_le64((u64)I40E_RX_DESC_FLTSTAT_RSS_HASH << -- I40E_RX_DESC_STATUS_FLTSTAT_SHIFT); -- -- if ((ring->netdev->features & NETIF_F_RXHASH) && -- (rx_desc->wb.qword1.status_error_len & rss_mask) == rss_mask) -- return le32_to_cpu(rx_desc->wb.qword0.hi_dword.rss); -- else -- return 0; --} -- --/** -- * i40e_ptype_to_hash - get a hash type -+ * i40e_ptype_to_htype - get a hash type - * @ptype: the ptype value from the descriptor - * - * Returns a hash type to be used by skb_set_hash - **/ --static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype) -+static inline enum pkt_hash_types i40e_ptype_to_htype(u8 ptype) - { - struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(ptype); - -@@ -1458,6 +1448,30 @@ static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype) - } - - /** -+ * i40e_rx_hash - set the hash value in the skb -+ * @ring: descriptor ring -+ * @rx_desc: specific descriptor -+ **/ -+static inline void i40e_rx_hash(struct i40e_ring *ring, -+ union i40e_rx_desc *rx_desc, -+ struct sk_buff *skb, -+ u8 rx_ptype) -+{ -+ u32 hash; -+ const __le64 rss_mask = -+ cpu_to_le64((u64)I40E_RX_DESC_FLTSTAT_RSS_HASH << -+ I40E_RX_DESC_STATUS_FLTSTAT_SHIFT); -+ -+ if (ring->netdev->features & NETIF_F_RXHASH) -+ return; -+ -+ if ((rx_desc->wb.qword1.status_error_len & rss_mask) == rss_mask) { -+ hash = le32_to_cpu(rx_desc->wb.qword0.hi_dword.rss); -+ skb_set_hash(skb, hash, i40e_ptype_to_htype(rx_ptype)); -+ } -+} -+ -+/** - * i40e_clean_rx_irq_ps - Reclaim resources after receive; packet split - * @rx_ring: rx ring to clean - * @budget: how many cleans we're allowed -@@ -1606,8 +1620,8 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring *rx_ring, int budget) - continue; - } - -- skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc), -- i40e_ptype_to_hash(rx_ptype)); -+ i40e_rx_hash(rx_ring, rx_desc, skb, rx_ptype); -+ - if (unlikely(rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK)) { - i40e_ptp_rx_hwtstamp(vsi->back, skb, (rx_status & - I40E_RXD_QW1_STATUS_TSYNINDX_MASK) >> -@@ -1736,8 +1750,7 @@ static int i40e_clean_rx_irq_1buf(struct i40e_ring *rx_ring, int budget) - continue; - } - -- skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc), -- i40e_ptype_to_hash(rx_ptype)); -+ i40e_rx_hash(rx_ring, rx_desc, skb, rx_ptype); - if (unlikely(rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK)) { - i40e_ptp_rx_hwtstamp(vsi->back, skb, (rx_status & - I40E_RXD_QW1_STATUS_TSYNINDX_MASK) >> -diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c -index 44462b40f2d7..e116d9a99b8e 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c -@@ -549,12 +549,15 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type) - i40e_vsi_add_pvid(vsi, vf->port_vlan_id); - - spin_lock_bh(&vsi->mac_filter_list_lock); -- f = i40e_add_filter(vsi, vf->default_lan_addr.addr, -- vf->port_vlan_id ? vf->port_vlan_id : -1, -- true, false); -- if (!f) -- dev_info(&pf->pdev->dev, -- "Could not allocate VF MAC addr\n"); -+ if (is_valid_ether_addr(vf->default_lan_addr.addr)) { -+ f = i40e_add_filter(vsi, vf->default_lan_addr.addr, -+ vf->port_vlan_id ? vf->port_vlan_id : -1, -+ true, false); -+ if (!f) -+ dev_info(&pf->pdev->dev, -+ "Could not add MAC filter %pM for VF %d\n", -+ vf->default_lan_addr.addr, vf->vf_id); -+ } - f = i40e_add_filter(vsi, brdcast, - vf->port_vlan_id ? vf->port_vlan_id : -1, - true, false); -@@ -1680,8 +1683,12 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) - spin_lock_bh(&vsi->mac_filter_list_lock); - /* delete addresses from the list */ - for (i = 0; i < al->num_elements; i++) -- i40e_del_filter(vsi, al->list[i].addr, -- I40E_VLAN_ANY, true, false); -+ if (i40e_del_mac_all_vlan(vsi, al->list[i].addr, true, false)) { -+ ret = I40E_ERR_INVALID_MAC_ADDR; -+ spin_unlock_bh(&vsi->mac_filter_list_lock); -+ goto error_param; -+ } -+ - spin_unlock_bh(&vsi->mac_filter_list_lock); - - /* program the updated filter list */ -diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c -index 47e9a90d6b10..39db70a597ed 100644 ---- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c -+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c -@@ -51,11 +51,7 @@ static void i40e_unmap_and_free_tx_resource(struct i40e_ring *ring, - struct i40e_tx_buffer *tx_buffer) - { - if (tx_buffer->skb) { -- if (tx_buffer->tx_flags & I40E_TX_FLAGS_FD_SB) -- kfree(tx_buffer->raw_buf); -- else -- dev_kfree_skb_any(tx_buffer->skb); -- -+ dev_kfree_skb_any(tx_buffer->skb); - if (dma_unmap_len(tx_buffer, len)) - dma_unmap_single(ring->dev, - dma_unmap_addr(tx_buffer, dma), -@@ -67,6 +63,10 @@ static void i40e_unmap_and_free_tx_resource(struct i40e_ring *ring, - dma_unmap_len(tx_buffer, len), - DMA_TO_DEVICE); - } -+ -+ if (tx_buffer->tx_flags & I40E_TX_FLAGS_FD_SB) -+ kfree(tx_buffer->raw_buf); -+ - tx_buffer->next_to_watch = NULL; - tx_buffer->skb = NULL; - dma_unmap_len_set(tx_buffer, len, 0); -@@ -245,16 +245,6 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget) - tx_ring->q_vector->tx.total_bytes += total_bytes; - tx_ring->q_vector->tx.total_packets += total_packets; - -- /* check to see if there are any non-cache aligned descriptors -- * waiting to be written back, and kick the hardware to force -- * them to be written back in case of napi polling -- */ -- if (budget && -- !((i & WB_STRIDE) == WB_STRIDE) && -- !test_bit(__I40E_DOWN, &tx_ring->vsi->state) && -- (I40E_DESC_UNUSED(tx_ring) != tx_ring->count)) -- tx_ring->arm_wb = true; -- - netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev, - tx_ring->queue_index), - total_packets, total_bytes); -@@ -889,31 +879,12 @@ checksum_fail: - } - - /** -- * i40e_rx_hash - returns the hash value from the Rx descriptor -- * @ring: descriptor ring -- * @rx_desc: specific descriptor -- **/ --static inline u32 i40e_rx_hash(struct i40e_ring *ring, -- union i40e_rx_desc *rx_desc) --{ -- const __le64 rss_mask = -- cpu_to_le64((u64)I40E_RX_DESC_FLTSTAT_RSS_HASH << -- I40E_RX_DESC_STATUS_FLTSTAT_SHIFT); -- -- if ((ring->netdev->features & NETIF_F_RXHASH) && -- (rx_desc->wb.qword1.status_error_len & rss_mask) == rss_mask) -- return le32_to_cpu(rx_desc->wb.qword0.hi_dword.rss); -- else -- return 0; --} -- --/** -- * i40e_ptype_to_hash - get a hash type -+ * i40e_ptype_to_htype - get a hash type - * @ptype: the ptype value from the descriptor - * - * Returns a hash type to be used by skb_set_hash - **/ --static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype) -+static inline enum pkt_hash_types i40e_ptype_to_htype(u8 ptype) - { - struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(ptype); - -@@ -931,6 +902,30 @@ static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype) - } - - /** -+ * i40e_rx_hash - set the hash value in the skb -+ * @ring: descriptor ring -+ * @rx_desc: specific descriptor -+ **/ -+static inline void i40e_rx_hash(struct i40e_ring *ring, -+ union i40e_rx_desc *rx_desc, -+ struct sk_buff *skb, -+ u8 rx_ptype) -+{ -+ u32 hash; -+ const __le64 rss_mask = -+ cpu_to_le64((u64)I40E_RX_DESC_FLTSTAT_RSS_HASH << -+ I40E_RX_DESC_STATUS_FLTSTAT_SHIFT); -+ -+ if (ring->netdev->features & NETIF_F_RXHASH) -+ return; -+ -+ if ((rx_desc->wb.qword1.status_error_len & rss_mask) == rss_mask) { -+ hash = le32_to_cpu(rx_desc->wb.qword0.hi_dword.rss); -+ skb_set_hash(skb, hash, i40e_ptype_to_htype(rx_ptype)); -+ } -+} -+ -+/** - * i40e_clean_rx_irq_ps - Reclaim resources after receive; packet split - * @rx_ring: rx ring to clean - * @budget: how many cleans we're allowed -@@ -1071,8 +1066,8 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring *rx_ring, int budget) - continue; - } - -- skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc), -- i40e_ptype_to_hash(rx_ptype)); -+ i40e_rx_hash(rx_ring, rx_desc, skb, rx_ptype); -+ - /* probably a little skewed due to removing CRC */ - total_rx_bytes += skb->len; - total_rx_packets++; -@@ -1189,8 +1184,7 @@ static int i40e_clean_rx_irq_1buf(struct i40e_ring *rx_ring, int budget) - continue; - } - -- skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc), -- i40e_ptype_to_hash(rx_ptype)); -+ i40e_rx_hash(rx_ring, rx_desc, skb, rx_ptype); - /* probably a little skewed due to removing CRC */ - total_rx_bytes += skb->len; - total_rx_packets++; -@@ -1770,6 +1764,9 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, - u32 td_tag = 0; - dma_addr_t dma; - u16 gso_segs; -+ u16 desc_count = 0; -+ bool tail_bump = true; -+ bool do_rs = false; - - if (tx_flags & I40E_TX_FLAGS_HW_VLAN) { - td_cmd |= I40E_TX_DESC_CMD_IL2TAG1; -@@ -1810,6 +1807,8 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, - - tx_desc++; - i++; -+ desc_count++; -+ - if (i == tx_ring->count) { - tx_desc = I40E_TX_DESC(tx_ring, 0); - i = 0; -@@ -1829,6 +1828,8 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, - - tx_desc++; - i++; -+ desc_count++; -+ - if (i == tx_ring->count) { - tx_desc = I40E_TX_DESC(tx_ring, 0); - i = 0; -@@ -1843,35 +1844,7 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, - tx_bi = &tx_ring->tx_bi[i]; - } - -- /* Place RS bit on last descriptor of any packet that spans across the -- * 4th descriptor (WB_STRIDE aka 0x3) in a 64B cacheline. -- */ - #define WB_STRIDE 0x3 -- if (((i & WB_STRIDE) != WB_STRIDE) && -- (first <= &tx_ring->tx_bi[i]) && -- (first >= &tx_ring->tx_bi[i & ~WB_STRIDE])) { -- tx_desc->cmd_type_offset_bsz = -- build_ctob(td_cmd, td_offset, size, td_tag) | -- cpu_to_le64((u64)I40E_TX_DESC_CMD_EOP << -- I40E_TXD_QW1_CMD_SHIFT); -- } else { -- tx_desc->cmd_type_offset_bsz = -- build_ctob(td_cmd, td_offset, size, td_tag) | -- cpu_to_le64((u64)I40E_TXD_CMD << -- I40E_TXD_QW1_CMD_SHIFT); -- } -- -- netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev, -- tx_ring->queue_index), -- first->bytecount); -- -- /* Force memory writes to complete before letting h/w -- * know there are new descriptors to fetch. (Only -- * applicable for weak-ordered memory model archs, -- * such as IA-64). -- */ -- wmb(); -- - /* set next_to_watch value indicating a packet is present */ - first->next_to_watch = tx_desc; - -@@ -1881,15 +1854,78 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, - - tx_ring->next_to_use = i; - -+ netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev, -+ tx_ring->queue_index), -+ first->bytecount); - i40evf_maybe_stop_tx(tx_ring, DESC_NEEDED); -+ -+ /* Algorithm to optimize tail and RS bit setting: -+ * if xmit_more is supported -+ * if xmit_more is true -+ * do not update tail and do not mark RS bit. -+ * if xmit_more is false and last xmit_more was false -+ * if every packet spanned less than 4 desc -+ * then set RS bit on 4th packet and update tail -+ * on every packet -+ * else -+ * update tail and set RS bit on every packet. -+ * if xmit_more is false and last_xmit_more was true -+ * update tail and set RS bit. -+ * else (kernel < 3.18) -+ * if every packet spanned less than 4 desc -+ * then set RS bit on 4th packet and update tail -+ * on every packet -+ * else -+ * set RS bit on EOP for every packet and update tail -+ * -+ * Optimization: wmb to be issued only in case of tail update. -+ * Also optimize the Descriptor WB path for RS bit with the same -+ * algorithm. -+ * -+ * Note: If there are less than 4 packets -+ * pending and interrupts were disabled the service task will -+ * trigger a force WB. -+ */ -+ if (skb->xmit_more && -+ !netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev, -+ tx_ring->queue_index))) { -+ tx_ring->flags |= I40E_TXR_FLAGS_LAST_XMIT_MORE_SET; -+ tail_bump = false; -+ } else if (!skb->xmit_more && -+ !netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev, -+ tx_ring->queue_index)) && -+ (!(tx_ring->flags & I40E_TXR_FLAGS_LAST_XMIT_MORE_SET)) && -+ (tx_ring->packet_stride < WB_STRIDE) && -+ (desc_count < WB_STRIDE)) { -+ tx_ring->packet_stride++; -+ } else { -+ tx_ring->packet_stride = 0; -+ tx_ring->flags &= ~I40E_TXR_FLAGS_LAST_XMIT_MORE_SET; -+ do_rs = true; -+ } -+ if (do_rs) -+ tx_ring->packet_stride = 0; -+ -+ tx_desc->cmd_type_offset_bsz = -+ build_ctob(td_cmd, td_offset, size, td_tag) | -+ cpu_to_le64((u64)(do_rs ? I40E_TXD_CMD : -+ I40E_TX_DESC_CMD_EOP) << -+ I40E_TXD_QW1_CMD_SHIFT); -+ - /* notify HW of packet */ -- if (!skb->xmit_more || -- netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev, -- tx_ring->queue_index))) -- writel(i, tx_ring->tail); -- else -+ if (!tail_bump) - prefetchw(tx_desc + 1); - -+ if (tail_bump) { -+ /* Force memory writes to complete before letting h/w -+ * know there are new descriptors to fetch. (Only -+ * applicable for weak-ordered memory model archs, -+ * such as IA-64). -+ */ -+ wmb(); -+ writel(i, tx_ring->tail); -+ } -+ - return; - - dma_error: -diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h -index ebc1bf77f036..998976844e4e 100644 ---- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h -+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h -@@ -267,6 +267,8 @@ struct i40e_ring { - - bool ring_active; /* is ring online or not */ - bool arm_wb; /* do something to arm write back */ -+ u8 packet_stride; -+#define I40E_TXR_FLAGS_LAST_XMIT_MORE_SET BIT(2) - - u16 flags; - #define I40E_TXR_FLAGS_WB_ON_ITR BIT(0) -diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c -index 4790437a50ac..2ac62efc36f7 100644 ---- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c -+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c -@@ -477,54 +477,30 @@ static int i40evf_set_rss_hash_opt(struct i40evf_adapter *adapter, - - switch (nfc->flow_type) { - case TCP_V4_FLOW: -- switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { -- case 0: -- hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); -- break; -- case (RXH_L4_B_0_1 | RXH_L4_B_2_3): -+ if (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) - hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); -- break; -- default: -+ else - return -EINVAL; -- } - break; - case TCP_V6_FLOW: -- switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { -- case 0: -- hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); -- break; -- case (RXH_L4_B_0_1 | RXH_L4_B_2_3): -+ if (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) - hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); -- break; -- default: -+ else - return -EINVAL; -- } - break; - case UDP_V4_FLOW: -- switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { -- case 0: -- hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | -- BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); -- break; -- case (RXH_L4_B_0_1 | RXH_L4_B_2_3): -+ if (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | - BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); -- break; -- default: -+ } else { - return -EINVAL; - } - break; - case UDP_V6_FLOW: -- switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { -- case 0: -- hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | -- BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); -- break; -- case (RXH_L4_B_0_1 | RXH_L4_B_2_3): -+ if (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { - hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | - BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); -- break; -- default: -+ } else { - return -EINVAL; - } - break; -diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c -index 99d2cffae0cd..5f03ab3dfa19 100644 ---- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c -+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c -@@ -1864,6 +1864,9 @@ void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter) - { - int i; - -+ if (!adapter->tx_rings) -+ return; -+ - for (i = 0; i < adapter->num_active_queues; i++) - if (adapter->tx_rings[i]->desc) - i40evf_free_tx_resources(adapter->tx_rings[i]); -@@ -1932,6 +1935,9 @@ void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) - { - int i; - -+ if (!adapter->rx_rings) -+ return; -+ - for (i = 0; i < adapter->num_active_queues; i++) - if (adapter->rx_rings[i]->desc) - i40evf_free_rx_resources(adapter->rx_rings[i]); -diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c -index 32e620e1eb5c..5de3f52fd31f 100644 ---- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c -+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c -@@ -391,6 +391,7 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter) - struct i40e_virtchnl_ether_addr_list *veal; - int len, i = 0, count = 0; - struct i40evf_mac_filter *f; -+ bool more = false; - - if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { - /* bail because we already have a command pending */ -@@ -415,7 +416,9 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter) - count = (I40EVF_MAX_AQ_BUF_SIZE - - sizeof(struct i40e_virtchnl_ether_addr_list)) / - sizeof(struct i40e_virtchnl_ether_addr); -- len = I40EVF_MAX_AQ_BUF_SIZE; -+ len = sizeof(struct i40e_virtchnl_ether_addr_list) + -+ (count * sizeof(struct i40e_virtchnl_ether_addr)); -+ more = true; - } - - veal = kzalloc(len, GFP_ATOMIC); -@@ -431,7 +434,8 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter) - f->add = false; - } - } -- adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER; -+ if (!more) -+ adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER; - i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS, - (u8 *)veal, len); - kfree(veal); -@@ -450,6 +454,7 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter) - struct i40e_virtchnl_ether_addr_list *veal; - struct i40evf_mac_filter *f, *ftmp; - int len, i = 0, count = 0; -+ bool more = false; - - if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { - /* bail because we already have a command pending */ -@@ -474,7 +479,9 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter) - count = (I40EVF_MAX_AQ_BUF_SIZE - - sizeof(struct i40e_virtchnl_ether_addr_list)) / - sizeof(struct i40e_virtchnl_ether_addr); -- len = I40EVF_MAX_AQ_BUF_SIZE; -+ len = sizeof(struct i40e_virtchnl_ether_addr_list) + -+ (count * sizeof(struct i40e_virtchnl_ether_addr)); -+ more = true; - } - veal = kzalloc(len, GFP_ATOMIC); - if (!veal) -@@ -490,7 +497,8 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter) - kfree(f); - } - } -- adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER; -+ if (!more) -+ adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER; - i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS, - (u8 *)veal, len); - kfree(veal); -@@ -509,6 +517,7 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter) - struct i40e_virtchnl_vlan_filter_list *vvfl; - int len, i = 0, count = 0; - struct i40evf_vlan_filter *f; -+ bool more = false; - - if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { - /* bail because we already have a command pending */ -@@ -534,7 +543,9 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter) - count = (I40EVF_MAX_AQ_BUF_SIZE - - sizeof(struct i40e_virtchnl_vlan_filter_list)) / - sizeof(u16); -- len = I40EVF_MAX_AQ_BUF_SIZE; -+ len = sizeof(struct i40e_virtchnl_vlan_filter_list) + -+ (count * sizeof(u16)); -+ more = true; - } - vvfl = kzalloc(len, GFP_ATOMIC); - if (!vvfl) -@@ -549,7 +560,8 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter) - f->add = false; - } - } -- adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER; -+ if (!more) -+ adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER; - i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len); - kfree(vvfl); - } -@@ -567,6 +579,7 @@ void i40evf_del_vlans(struct i40evf_adapter *adapter) - struct i40e_virtchnl_vlan_filter_list *vvfl; - struct i40evf_vlan_filter *f, *ftmp; - int len, i = 0, count = 0; -+ bool more = false; - - if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { - /* bail because we already have a command pending */ -@@ -592,7 +605,9 @@ void i40evf_del_vlans(struct i40evf_adapter *adapter) - count = (I40EVF_MAX_AQ_BUF_SIZE - - sizeof(struct i40e_virtchnl_vlan_filter_list)) / - sizeof(u16); -- len = I40EVF_MAX_AQ_BUF_SIZE; -+ len = sizeof(struct i40e_virtchnl_vlan_filter_list) + -+ (count * sizeof(u16)); -+ more = true; - } - vvfl = kzalloc(len, GFP_ATOMIC); - if (!vvfl) -@@ -608,7 +623,8 @@ void i40evf_del_vlans(struct i40evf_adapter *adapter) - kfree(f); - } - } -- adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER; -+ if (!more) -+ adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER; - i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len); - kfree(vvfl); - } -diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c -index 7a73510e547c..97bf0c3d5c69 100644 ---- a/drivers/net/ethernet/intel/igb/e1000_82575.c -+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c -@@ -294,6 +294,7 @@ static s32 igb_init_phy_params_82575(struct e1000_hw *hw) - case I210_I_PHY_ID: - phy->type = e1000_phy_i210; - phy->ops.check_polarity = igb_check_polarity_m88; -+ phy->ops.get_cfg_done = igb_get_cfg_done_i210; - phy->ops.get_phy_info = igb_get_phy_info_m88; - phy->ops.get_cable_length = igb_get_cable_length_m88_gen2; - phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82580; -diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c -index 65d931669f81..29f59c76878a 100644 ---- a/drivers/net/ethernet/intel/igb/e1000_i210.c -+++ b/drivers/net/ethernet/intel/igb/e1000_i210.c -@@ -900,3 +900,30 @@ s32 igb_pll_workaround_i210(struct e1000_hw *hw) - wr32(E1000_MDICNFG, mdicnfg); - return ret_val; - } -+ -+/** -+ * igb_get_cfg_done_i210 - Read config done bit -+ * @hw: pointer to the HW structure -+ * -+ * Read the management control register for the config done bit for -+ * completion status. NOTE: silicon which is EEPROM-less will fail trying -+ * to read the config done bit, so an error is *ONLY* logged and returns -+ * 0. If we were to return with error, EEPROM-less silicon -+ * would not be able to be reset or change link. -+ **/ -+s32 igb_get_cfg_done_i210(struct e1000_hw *hw) -+{ -+ s32 timeout = PHY_CFG_TIMEOUT; -+ u32 mask = E1000_NVM_CFG_DONE_PORT_0; -+ -+ while (timeout) { -+ if (rd32(E1000_EEMNGCTL_I210) & mask) -+ break; -+ usleep_range(1000, 2000); -+ timeout--; -+ } -+ if (!timeout) -+ hw_dbg("MNG configuration cycle has not completed.\n"); -+ -+ return 0; -+} -diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h -index 3442b6357d01..eaa68a50cb3b 100644 ---- a/drivers/net/ethernet/intel/igb/e1000_i210.h -+++ b/drivers/net/ethernet/intel/igb/e1000_i210.h -@@ -34,6 +34,7 @@ s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data); - s32 igb_init_nvm_params_i210(struct e1000_hw *hw); - bool igb_get_flash_presence_i210(struct e1000_hw *hw); - s32 igb_pll_workaround_i210(struct e1000_hw *hw); -+s32 igb_get_cfg_done_i210(struct e1000_hw *hw); - - #define E1000_STM_OPCODE 0xDB00 - #define E1000_EEPROM_FLASH_SIZE_WORD 0x11 -diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h -index 4af2870e49f8..0fdcd4d1b982 100644 ---- a/drivers/net/ethernet/intel/igb/e1000_regs.h -+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h -@@ -66,6 +66,7 @@ - #define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ - #define E1000_PBS 0x01008 /* Packet Buffer Size */ - #define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ -+#define E1000_EEMNGCTL_I210 0x12030 /* MNG EEprom Control */ - #define E1000_EEARBC_I210 0x12024 /* EEPROM Auto Read Bus Control */ - #define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */ - #define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */ -diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h -index 1a2f1cc44b28..e3cb93bdb21a 100644 ---- a/drivers/net/ethernet/intel/igb/igb.h -+++ b/drivers/net/ethernet/intel/igb/igb.h -@@ -389,6 +389,8 @@ struct igb_adapter { - u16 link_speed; - u16 link_duplex; - -+ u8 __iomem *io_addr; /* Mainly for iounmap use */ -+ - struct work_struct reset_task; - struct work_struct watchdog_task; - bool fc_autoneg; -diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c -index ea7b09887245..fa3b4cbea23b 100644 ---- a/drivers/net/ethernet/intel/igb/igb_main.c -+++ b/drivers/net/ethernet/intel/igb/igb_main.c -@@ -2294,9 +2294,11 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); - - err = -EIO; -- hw->hw_addr = pci_iomap(pdev, 0, 0); -- if (!hw->hw_addr) -+ adapter->io_addr = pci_iomap(pdev, 0, 0); -+ if (!adapter->io_addr) - goto err_ioremap; -+ /* hw->hw_addr can be altered, we'll use adapter->io_addr for unmap */ -+ hw->hw_addr = adapter->io_addr; - - netdev->netdev_ops = &igb_netdev_ops; - igb_set_ethtool_ops(netdev); -@@ -2656,7 +2658,7 @@ err_sw_init: - #ifdef CONFIG_PCI_IOV - igb_disable_sriov(pdev); - #endif -- pci_iounmap(pdev, hw->hw_addr); -+ pci_iounmap(pdev, adapter->io_addr); - err_ioremap: - free_netdev(netdev); - err_alloc_etherdev: -@@ -2823,7 +2825,7 @@ static void igb_remove(struct pci_dev *pdev) - - igb_clear_interrupt_scheme(adapter); - -- pci_iounmap(pdev, hw->hw_addr); -+ pci_iounmap(pdev, adapter->io_addr); - if (hw->flash_address) - iounmap(hw->flash_address); - pci_release_selected_regions(pdev, -@@ -2856,6 +2858,13 @@ static void igb_probe_vfs(struct igb_adapter *adapter) - if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) - return; - -+ /* Of the below we really only want the effect of getting -+ * IGB_FLAG_HAS_MSIX set (if available), without which -+ * igb_enable_sriov() has no effect. -+ */ -+ igb_set_interrupt_capability(adapter, true); -+ igb_reset_interrupt_capability(adapter); -+ - pci_sriov_set_totalvfs(pdev, 7); - igb_enable_sriov(pdev, max_vfs); - -diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -index aed8d029b23d..cd9b284bc83b 100644 ---- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -@@ -2786,7 +2786,8 @@ int ixgbe_poll(struct napi_struct *napi, int budget) - ixgbe_for_each_ring(ring, q_vector->tx) - clean_complete &= !!ixgbe_clean_tx_irq(q_vector, ring); - -- if (!ixgbe_qv_lock_napi(q_vector)) -+ /* Exit if we are called by netpoll or busy polling is active */ -+ if ((budget <= 0) || !ixgbe_qv_lock_napi(q_vector)) - return budget; - - /* attempt to distribute budget to each queue fairly, but don't allow -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -index 2e022e900939..7cc9df717323 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -@@ -399,6 +399,9 @@ static int mlx5e_get_coalesce(struct net_device *netdev, - { - struct mlx5e_priv *priv = netdev_priv(netdev); - -+ if (!MLX5_CAP_GEN(priv->mdev, cq_moderation)) -+ return -ENOTSUPP; -+ - coal->rx_coalesce_usecs = priv->params.rx_cq_moderation_usec; - coal->rx_max_coalesced_frames = priv->params.rx_cq_moderation_pkts; - coal->tx_coalesce_usecs = priv->params.tx_cq_moderation_usec; -@@ -416,11 +419,18 @@ static int mlx5e_set_coalesce(struct net_device *netdev, - int tc; - int i; - -+ if (!MLX5_CAP_GEN(mdev, cq_moderation)) -+ return -ENOTSUPP; -+ -+ mutex_lock(&priv->state_lock); - priv->params.tx_cq_moderation_usec = coal->tx_coalesce_usecs; - priv->params.tx_cq_moderation_pkts = coal->tx_max_coalesced_frames; - priv->params.rx_cq_moderation_usec = coal->rx_coalesce_usecs; - priv->params.rx_cq_moderation_pkts = coal->rx_max_coalesced_frames; - -+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) -+ goto out; -+ - for (i = 0; i < priv->params.num_channels; ++i) { - c = priv->channel[i]; - -@@ -436,6 +446,8 @@ static int mlx5e_set_coalesce(struct net_device *netdev, - coal->rx_max_coalesced_frames); - } - -+out: -+ mutex_unlock(&priv->state_lock); - return 0; - } - -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -index cbd17e25beeb..90e876ecc720 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -@@ -863,12 +863,10 @@ static int mlx5e_open_cq(struct mlx5e_channel *c, - if (err) - goto err_destroy_cq; - -- err = mlx5_core_modify_cq_moderation(mdev, &cq->mcq, -- moderation_usecs, -- moderation_frames); -- if (err) -- goto err_destroy_cq; -- -+ if (MLX5_CAP_GEN(mdev, cq_moderation)) -+ mlx5_core_modify_cq_moderation(mdev, &cq->mcq, -+ moderation_usecs, -+ moderation_frames); - return 0; - - err_destroy_cq: -@@ -1963,6 +1961,8 @@ static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev) - } - if (!MLX5_CAP_ETH(mdev, self_lb_en_modifiable)) - mlx5_core_warn(mdev, "Self loop back prevention is not supported\n"); -+ if (!MLX5_CAP_GEN(mdev, cq_moderation)) -+ mlx5_core_warn(mdev, "CQ modiration is not supported\n"); - - return 0; - } -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index 289a5df0d44a..c851bc53831c 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -2725,7 +2725,7 @@ static int nvme_pci_enable(struct nvme_dev *dev) - return 0; - - disable: -- pci_release_regions(pdev); -+ pci_disable_device(pdev); - - return result; - } -diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c -index f9dfc8b6407a..7225ac6b3df5 100644 ---- a/drivers/pwm/pwm-fsl-ftm.c -+++ b/drivers/pwm/pwm-fsl-ftm.c -@@ -80,7 +80,6 @@ struct fsl_pwm_chip { - - struct mutex lock; - -- unsigned int use_count; - unsigned int cnt_select; - unsigned int clk_ps; - -@@ -300,9 +299,6 @@ static int fsl_counter_clock_enable(struct fsl_pwm_chip *fpc) - { - int ret; - -- if (fpc->use_count++ != 0) -- return 0; -- - /* select counter clock source */ - regmap_update_bits(fpc->regmap, FTM_SC, FTM_SC_CLK_MASK, - FTM_SC_CLK(fpc->cnt_select)); -@@ -334,25 +330,6 @@ static int fsl_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) - return ret; - } - --static void fsl_counter_clock_disable(struct fsl_pwm_chip *fpc) --{ -- /* -- * already disabled, do nothing -- */ -- if (fpc->use_count == 0) -- return; -- -- /* there are still users, so can't disable yet */ -- if (--fpc->use_count > 0) -- return; -- -- /* no users left, disable PWM counter clock */ -- regmap_update_bits(fpc->regmap, FTM_SC, FTM_SC_CLK_MASK, 0); -- -- clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_CNTEN]); -- clk_disable_unprepare(fpc->clk[fpc->cnt_select]); --} -- - static void fsl_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) - { - struct fsl_pwm_chip *fpc = to_fsl_chip(chip); -@@ -362,7 +339,8 @@ static void fsl_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) - regmap_update_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm), - BIT(pwm->hwpwm)); - -- fsl_counter_clock_disable(fpc); -+ clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_CNTEN]); -+ clk_disable_unprepare(fpc->clk[fpc->cnt_select]); - - regmap_read(fpc->regmap, FTM_OUTMASK, &val); - if ((val & 0xFF) == 0xFF) -@@ -492,17 +470,24 @@ static int fsl_pwm_remove(struct platform_device *pdev) - static int fsl_pwm_suspend(struct device *dev) - { - struct fsl_pwm_chip *fpc = dev_get_drvdata(dev); -- u32 val; -+ int i; - - regcache_cache_only(fpc->regmap, true); - regcache_mark_dirty(fpc->regmap); - -- /* read from cache */ -- regmap_read(fpc->regmap, FTM_OUTMASK, &val); -- if ((val & 0xFF) != 0xFF) { -+ for (i = 0; i < fpc->chip.npwm; i++) { -+ struct pwm_device *pwm = &fpc->chip.pwms[i]; -+ -+ if (!test_bit(PWMF_REQUESTED, &pwm->flags)) -+ continue; -+ -+ clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]); -+ -+ if (!pwm_is_enabled(pwm)) -+ continue; -+ - clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_CNTEN]); - clk_disable_unprepare(fpc->clk[fpc->cnt_select]); -- clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]); - } - - return 0; -@@ -511,12 +496,19 @@ static int fsl_pwm_suspend(struct device *dev) - static int fsl_pwm_resume(struct device *dev) - { - struct fsl_pwm_chip *fpc = dev_get_drvdata(dev); -- u32 val; -+ int i; -+ -+ for (i = 0; i < fpc->chip.npwm; i++) { -+ struct pwm_device *pwm = &fpc->chip.pwms[i]; -+ -+ if (!test_bit(PWMF_REQUESTED, &pwm->flags)) -+ continue; - -- /* read from cache */ -- regmap_read(fpc->regmap, FTM_OUTMASK, &val); -- if ((val & 0xFF) != 0xFF) { - clk_prepare_enable(fpc->clk[FSL_PWM_CLK_SYS]); -+ -+ if (!pwm_is_enabled(pwm)) -+ continue; -+ - clk_prepare_enable(fpc->clk[fpc->cnt_select]); - clk_prepare_enable(fpc->clk[FSL_PWM_CLK_CNTEN]); - } -diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c -index 9fde60ce8e7b..6e203a65effb 100644 ---- a/drivers/pwm/pwm-lpc32xx.c -+++ b/drivers/pwm/pwm-lpc32xx.c -@@ -24,9 +24,7 @@ struct lpc32xx_pwm_chip { - void __iomem *base; - }; - --#define PWM_ENABLE (1 << 31) --#define PWM_RELOADV(x) (((x) & 0xFF) << 8) --#define PWM_DUTY(x) ((x) & 0xFF) -+#define PWM_ENABLE BIT(31) - - #define to_lpc32xx_pwm_chip(_chip) \ - container_of(_chip, struct lpc32xx_pwm_chip, chip) -@@ -38,40 +36,27 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, - unsigned long long c; - int period_cycles, duty_cycles; - u32 val; -- -- c = clk_get_rate(lpc32xx->clk) / 256; -- c = c * period_ns; -- do_div(c, NSEC_PER_SEC); -- -- /* Handle high and low extremes */ -- if (c == 0) -- c = 1; -- if (c > 255) -- c = 0; /* 0 set division by 256 */ -- period_cycles = c; -- -- /* The duty-cycle value is as follows: -- * -- * DUTY-CYCLE HIGH LEVEL -- * 1 99.9% -- * 25 90.0% -- * 128 50.0% -- * 220 10.0% -- * 255 0.1% -- * 0 0.0% -- * -- * In other words, the register value is duty-cycle % 256 with -- * duty-cycle in the range 1-256. -- */ -- c = 256 * duty_ns; -- do_div(c, period_ns); -- if (c > 255) -- c = 255; -- duty_cycles = 256 - c; -+ c = clk_get_rate(lpc32xx->clk); -+ -+ /* The highest acceptable divisor is 256, which is represented by 0 */ -+ period_cycles = div64_u64(c * period_ns, -+ (unsigned long long)NSEC_PER_SEC * 256); -+ if (!period_cycles) -+ period_cycles = 1; -+ if (period_cycles > 255) -+ period_cycles = 0; -+ -+ /* Compute 256 x #duty/period value and care for corner cases */ -+ duty_cycles = div64_u64((unsigned long long)(period_ns - duty_ns) * 256, -+ period_ns); -+ if (!duty_cycles) -+ duty_cycles = 1; -+ if (duty_cycles > 255) -+ duty_cycles = 255; - - val = readl(lpc32xx->base + (pwm->hwpwm << 2)); - val &= ~0xFFFF; -- val |= PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles); -+ val |= (period_cycles << 8) | duty_cycles; - writel(val, lpc32xx->base + (pwm->hwpwm << 2)); - - return 0; -@@ -134,7 +119,7 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev) - - lpc32xx->chip.dev = &pdev->dev; - lpc32xx->chip.ops = &lpc32xx_pwm_ops; -- lpc32xx->chip.npwm = 2; -+ lpc32xx->chip.npwm = 1; - lpc32xx->chip.base = -1; - - ret = pwmchip_add(&lpc32xx->chip); -diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c -index 63cd5e68c864..3a6d0290c54c 100644 ---- a/drivers/regulator/anatop-regulator.c -+++ b/drivers/regulator/anatop-regulator.c -@@ -296,7 +296,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) - if (!sreg->sel && !strcmp(sreg->name, "vddpu")) - sreg->sel = 22; - -- if (!sreg->sel) { -+ if (!sreg->bypass && !sreg->sel) { - dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n"); - return -EINVAL; - } -diff --git a/drivers/s390/char/sclp_ctl.c b/drivers/s390/char/sclp_ctl.c -index 648cb86afd42..ea607a4a1bdd 100644 ---- a/drivers/s390/char/sclp_ctl.c -+++ b/drivers/s390/char/sclp_ctl.c -@@ -56,6 +56,7 @@ static int sclp_ctl_ioctl_sccb(void __user *user_area) - { - struct sclp_ctl_sccb ctl_sccb; - struct sccb_header *sccb; -+ unsigned long copied; - int rc; - - if (copy_from_user(&ctl_sccb, user_area, sizeof(ctl_sccb))) -@@ -65,14 +66,15 @@ static int sclp_ctl_ioctl_sccb(void __user *user_area) - sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); - if (!sccb) - return -ENOMEM; -- if (copy_from_user(sccb, u64_to_uptr(ctl_sccb.sccb), sizeof(*sccb))) { -+ copied = PAGE_SIZE - -+ copy_from_user(sccb, u64_to_uptr(ctl_sccb.sccb), PAGE_SIZE); -+ if (offsetof(struct sccb_header, length) + -+ sizeof(sccb->length) > copied || sccb->length > copied) { - rc = -EFAULT; - goto out_free; - } -- if (sccb->length > PAGE_SIZE || sccb->length < 8) -- return -EINVAL; -- if (copy_from_user(sccb, u64_to_uptr(ctl_sccb.sccb), sccb->length)) { -- rc = -EFAULT; -+ if (sccb->length < 8) { -+ rc = -EINVAL; - goto out_free; - } - rc = sclp_sync_request(ctl_sccb.cmdw, sccb); -diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c -index c692dfebd0ba..50597f9522fe 100644 ---- a/drivers/s390/cio/chp.c -+++ b/drivers/s390/cio/chp.c -@@ -139,11 +139,11 @@ static ssize_t chp_measurement_chars_read(struct file *filp, - - device = container_of(kobj, struct device, kobj); - chp = to_channelpath(device); -- if (!chp->cmg_chars) -+ if (chp->cmg == -1) - return 0; - -- return memory_read_from_buffer(buf, count, &off, -- chp->cmg_chars, sizeof(struct cmg_chars)); -+ return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars, -+ sizeof(chp->cmg_chars)); - } - - static struct bin_attribute chp_measurement_chars_attr = { -@@ -416,7 +416,8 @@ static void chp_release(struct device *dev) - * chp_update_desc - update channel-path description - * @chp - channel-path - * -- * Update the channel-path description of the specified channel-path. -+ * Update the channel-path description of the specified channel-path -+ * including channel measurement related information. - * Return zero on success, non-zero otherwise. - */ - int chp_update_desc(struct channel_path *chp) -@@ -428,8 +429,10 @@ int chp_update_desc(struct channel_path *chp) - return rc; - - rc = chsc_determine_fmt1_channel_path_desc(chp->chpid, &chp->desc_fmt1); -+ if (rc) -+ return rc; - -- return rc; -+ return chsc_get_channel_measurement_chars(chp); - } - - /** -@@ -466,14 +469,6 @@ int chp_new(struct chp_id chpid) - ret = -ENODEV; - goto out_free; - } -- /* Get channel-measurement characteristics. */ -- if (css_chsc_characteristics.scmc && css_chsc_characteristics.secm) { -- ret = chsc_get_channel_measurement_chars(chp); -- if (ret) -- goto out_free; -- } else { -- chp->cmg = -1; -- } - dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id); - - /* make it known to the system */ -diff --git a/drivers/s390/cio/chp.h b/drivers/s390/cio/chp.h -index 4efd5b867cc3..af0232290dc4 100644 ---- a/drivers/s390/cio/chp.h -+++ b/drivers/s390/cio/chp.h -@@ -48,7 +48,7 @@ struct channel_path { - /* Channel-measurement related stuff: */ - int cmg; - int shared; -- void *cmg_chars; -+ struct cmg_chars cmg_chars; - }; - - /* Return channel_path struct for given chpid. */ -diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c -index a831d18596a5..c424c0c7367e 100644 ---- a/drivers/s390/cio/chsc.c -+++ b/drivers/s390/cio/chsc.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - - #include -@@ -224,8 +225,9 @@ out_unreg: - - void chsc_chp_offline(struct chp_id chpid) - { -- char dbf_txt[15]; -+ struct channel_path *chp = chpid_to_chp(chpid); - struct chp_link link; -+ char dbf_txt[15]; - - sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); - CIO_TRACE_EVENT(2, dbf_txt); -@@ -236,6 +238,11 @@ void chsc_chp_offline(struct chp_id chpid) - link.chpid = chpid; - /* Wait until previous actions have settled. */ - css_wait_for_slow_path(); -+ -+ mutex_lock(&chp->lock); -+ chp_update_desc(chp); -+ mutex_unlock(&chp->lock); -+ - for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link); - } - -@@ -690,8 +697,9 @@ static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow) - - void chsc_chp_online(struct chp_id chpid) - { -- char dbf_txt[15]; -+ struct channel_path *chp = chpid_to_chp(chpid); - struct chp_link link; -+ char dbf_txt[15]; - - sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); - CIO_TRACE_EVENT(2, dbf_txt); -@@ -701,6 +709,11 @@ void chsc_chp_online(struct chp_id chpid) - link.chpid = chpid; - /* Wait until previous actions have settled. */ - css_wait_for_slow_path(); -+ -+ mutex_lock(&chp->lock); -+ chp_update_desc(chp); -+ mutex_unlock(&chp->lock); -+ - for_each_subchannel_staged(__s390_process_res_acc, NULL, - &link); - css_schedule_reprobe(); -@@ -967,22 +980,19 @@ static void - chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, - struct cmg_chars *chars) - { -- struct cmg_chars *cmg_chars; - int i, mask; - -- cmg_chars = chp->cmg_chars; - for (i = 0; i < NR_MEASUREMENT_CHARS; i++) { - mask = 0x80 >> (i + 3); - if (cmcv & mask) -- cmg_chars->values[i] = chars->values[i]; -+ chp->cmg_chars.values[i] = chars->values[i]; - else -- cmg_chars->values[i] = 0; -+ chp->cmg_chars.values[i] = 0; - } - } - - int chsc_get_channel_measurement_chars(struct channel_path *chp) - { -- struct cmg_chars *cmg_chars; - int ccode, ret; - - struct { -@@ -1006,10 +1016,11 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) - u32 data[NR_MEASUREMENT_CHARS]; - } __attribute__ ((packed)) *scmc_area; - -- chp->cmg_chars = NULL; -- cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL); -- if (!cmg_chars) -- return -ENOMEM; -+ chp->shared = -1; -+ chp->cmg = -1; -+ -+ if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm) -+ return 0; - - spin_lock_irq(&chsc_page_lock); - memset(chsc_page, 0, PAGE_SIZE); -@@ -1031,25 +1042,19 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) - scmc_area->response.code); - goto out; - } -- if (scmc_area->not_valid) { -- chp->cmg = -1; -- chp->shared = -1; -+ if (scmc_area->not_valid) - goto out; -- } -+ - chp->cmg = scmc_area->cmg; - chp->shared = scmc_area->shared; - if (chp->cmg != 2 && chp->cmg != 3) { - /* No cmg-dependent data. */ - goto out; - } -- chp->cmg_chars = cmg_chars; - chsc_initialize_cmg_chars(chp, scmc_area->cmcv, - (struct cmg_chars *) &scmc_area->data); - out: - spin_unlock_irq(&chsc_page_lock); -- if (!chp->cmg_chars) -- kfree(cmg_chars); -- - return ret; - } - -diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c -index 12b2cb7769f9..df036b872b05 100644 ---- a/drivers/s390/net/qeth_l2_main.c -+++ b/drivers/s390/net/qeth_l2_main.c -@@ -1127,6 +1127,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) - qeth_l2_request_initial_mac(card); - SET_NETDEV_DEV(card->dev, &card->gdev->dev); - netif_napi_add(card->dev, &card->napi, qeth_l2_poll, QETH_NAPI_WEIGHT); -+ netif_carrier_off(card->dev); - return register_netdev(card->dev); - } - -diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c -index 50cec6b13d27..cc4d3c3d8cc5 100644 ---- a/drivers/s390/net/qeth_l3_main.c -+++ b/drivers/s390/net/qeth_l3_main.c -@@ -3220,6 +3220,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) - - SET_NETDEV_DEV(card->dev, &card->gdev->dev); - netif_napi_add(card->dev, &card->napi, qeth_l3_poll, QETH_NAPI_WEIGHT); -+ netif_carrier_off(card->dev); - return register_netdev(card->dev); - } - -diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c -index 333db5953607..41f9a00e4f74 100644 ---- a/drivers/scsi/arcmsr/arcmsr_hba.c -+++ b/drivers/scsi/arcmsr/arcmsr_hba.c -@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb) - if (!arcmsr_hbaB_wait_msgint_ready(acb)) { - printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ - miscellaneous data' timeout \n", acb->host->host_no); -- return false; -+ goto err_free_dma; - } - count = 8; - while (count){ -@@ -2694,19 +2694,23 @@ static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb) - acb->firm_model, - acb->firm_version); - -- acb->signature = readl(®->message_rwbuffer[1]); -+ acb->signature = readl(®->message_rwbuffer[0]); - /*firm_signature,1,00-03*/ -- acb->firm_request_len = readl(®->message_rwbuffer[2]); -+ acb->firm_request_len = readl(®->message_rwbuffer[1]); - /*firm_request_len,1,04-07*/ -- acb->firm_numbers_queue = readl(®->message_rwbuffer[3]); -+ acb->firm_numbers_queue = readl(®->message_rwbuffer[2]); - /*firm_numbers_queue,2,08-11*/ -- acb->firm_sdram_size = readl(®->message_rwbuffer[4]); -+ acb->firm_sdram_size = readl(®->message_rwbuffer[3]); - /*firm_sdram_size,3,12-15*/ -- acb->firm_hd_channels = readl(®->message_rwbuffer[5]); -+ acb->firm_hd_channels = readl(®->message_rwbuffer[4]); - /*firm_ide_channels,4,16-19*/ - acb->firm_cfg_version = readl(®->message_rwbuffer[25]); /*firm_cfg_version,25,100-103*/ - /*firm_ide_channels,4,16-19*/ - return true; -+err_free_dma: -+ dma_free_coherent(&acb->pdev->dev, acb->roundup_ccbsize, -+ acb->dma_coherent2, acb->dma_coherent_handle2); -+ return false; - } - - static bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB) -@@ -2880,15 +2884,15 @@ static bool arcmsr_hbaD_get_config(struct AdapterControlBlock *acb) - iop_device_map++; - count--; - } -- acb->signature = readl(®->msgcode_rwbuffer[1]); -+ acb->signature = readl(®->msgcode_rwbuffer[0]); - /*firm_signature,1,00-03*/ -- acb->firm_request_len = readl(®->msgcode_rwbuffer[2]); -+ acb->firm_request_len = readl(®->msgcode_rwbuffer[1]); - /*firm_request_len,1,04-07*/ -- acb->firm_numbers_queue = readl(®->msgcode_rwbuffer[3]); -+ acb->firm_numbers_queue = readl(®->msgcode_rwbuffer[2]); - /*firm_numbers_queue,2,08-11*/ -- acb->firm_sdram_size = readl(®->msgcode_rwbuffer[4]); -+ acb->firm_sdram_size = readl(®->msgcode_rwbuffer[3]); - /*firm_sdram_size,3,12-15*/ -- acb->firm_hd_channels = readl(®->msgcode_rwbuffer[5]); -+ acb->firm_hd_channels = readl(®->msgcode_rwbuffer[4]); - /*firm_hd_channels,4,16-19*/ - acb->firm_cfg_version = readl(®->msgcode_rwbuffer[25]); - pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", -diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c -index fa09d4be2b53..2b456ca69d5c 100644 ---- a/drivers/scsi/constants.c -+++ b/drivers/scsi/constants.c -@@ -1181,8 +1181,9 @@ static const char * const snstext[] = { - - /* Get sense key string or NULL if not available */ - const char * --scsi_sense_key_string(unsigned char key) { -- if (key <= 0xE) -+scsi_sense_key_string(unsigned char key) -+{ -+ if (key < ARRAY_SIZE(snstext)) - return snstext[key]; - return NULL; - } -diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h -index c11cd193f896..5ada9268a450 100644 ---- a/drivers/scsi/cxlflash/common.h -+++ b/drivers/scsi/cxlflash/common.h -@@ -165,6 +165,8 @@ struct afu { - struct sisl_host_map __iomem *host_map; /* MC host map */ - struct sisl_ctrl_map __iomem *ctrl_map; /* MC control map */ - -+ struct kref mapcount; -+ - ctx_hndl_t ctx_hndl; /* master's context handle */ - u64 *hrrq_start; - u64 *hrrq_end; -diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c -index 1e5bf0ca81da..c86847c68448 100644 ---- a/drivers/scsi/cxlflash/main.c -+++ b/drivers/scsi/cxlflash/main.c -@@ -289,7 +289,7 @@ static void context_reset(struct afu_cmd *cmd) - atomic64_set(&afu->room, room); - if (room) - goto write_rrin; -- udelay(nretry); -+ udelay(1 << nretry); - } while (nretry++ < MC_ROOM_RETRY_CNT); - - pr_err("%s: no cmd_room to send reset\n", __func__); -@@ -303,7 +303,7 @@ write_rrin: - if (rrin != 0x1) - break; - /* Double delay each time */ -- udelay(2 << nretry); -+ udelay(1 << nretry); - } while (nretry++ < MC_ROOM_RETRY_CNT); - } - -@@ -338,7 +338,7 @@ retry: - atomic64_set(&afu->room, room); - if (room) - goto write_ioarrin; -- udelay(nretry); -+ udelay(1 << nretry); - } while (nretry++ < MC_ROOM_RETRY_CNT); - - dev_err(dev, "%s: no cmd_room to send 0x%X\n", -@@ -352,7 +352,7 @@ retry: - * afu->room. - */ - if (nretry++ < MC_ROOM_RETRY_CNT) { -- udelay(nretry); -+ udelay(1 << nretry); - goto retry; - } - -@@ -368,6 +368,7 @@ out: - - no_room: - afu->read_room = true; -+ kref_get(&cfg->afu->mapcount); - schedule_work(&cfg->work_q); - rc = SCSI_MLQUEUE_HOST_BUSY; - goto out; -@@ -473,6 +474,16 @@ out: - return rc; - } - -+static void afu_unmap(struct kref *ref) -+{ -+ struct afu *afu = container_of(ref, struct afu, mapcount); -+ -+ if (likely(afu->afu_map)) { -+ cxl_psa_unmap((void __iomem *)afu->afu_map); -+ afu->afu_map = NULL; -+ } -+} -+ - /** - * cxlflash_driver_info() - information handler for this host driver - * @host: SCSI host associated with device. -@@ -503,6 +514,7 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) - ulong lock_flags; - short lflag = 0; - int rc = 0; -+ int kref_got = 0; - - dev_dbg_ratelimited(dev, "%s: (scp=%p) %d/%d/%d/%llu " - "cdb=(%08X-%08X-%08X-%08X)\n", -@@ -547,6 +559,9 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) - goto out; - } - -+ kref_get(&cfg->afu->mapcount); -+ kref_got = 1; -+ - cmd->rcb.ctx_id = afu->ctx_hndl; - cmd->rcb.port_sel = port_sel; - cmd->rcb.lun_id = lun_to_lunid(scp->device->lun); -@@ -587,6 +602,8 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) - } - - out: -+ if (kref_got) -+ kref_put(&afu->mapcount, afu_unmap); - pr_devel("%s: returning rc=%d\n", __func__, rc); - return rc; - } -@@ -632,20 +649,36 @@ static void free_mem(struct cxlflash_cfg *cfg) - * @cfg: Internal structure associated with the host. - * - * Safe to call with AFU in a partially allocated/initialized state. -+ * -+ * Cleans up all state associated with the command queue, and unmaps -+ * the MMIO space. -+ * -+ * - complete() will take care of commands we initiated (they'll be checked -+ * in as part of the cleanup that occurs after the completion) -+ * -+ * - cmd_checkin() will take care of entries that we did not initiate and that -+ * have not (and will not) complete because they are sitting on a [now stale] -+ * hardware queue - */ - static void stop_afu(struct cxlflash_cfg *cfg) - { - int i; - struct afu *afu = cfg->afu; -+ struct afu_cmd *cmd; - - if (likely(afu)) { -- for (i = 0; i < CXLFLASH_NUM_CMDS; i++) -- complete(&afu->cmd[i].cevent); -+ for (i = 0; i < CXLFLASH_NUM_CMDS; i++) { -+ cmd = &afu->cmd[i]; -+ complete(&cmd->cevent); -+ if (!atomic_read(&cmd->free)) -+ cmd_checkin(cmd); -+ } - - if (likely(afu->afu_map)) { - cxl_psa_unmap((void __iomem *)afu->afu_map); - afu->afu_map = NULL; - } -+ kref_put(&afu->mapcount, afu_unmap); - } - } - -@@ -731,8 +764,8 @@ static void cxlflash_remove(struct pci_dev *pdev) - scsi_remove_host(cfg->host); - /* fall through */ - case INIT_STATE_AFU: -- term_afu(cfg); - cancel_work_sync(&cfg->work_q); -+ term_afu(cfg); - case INIT_STATE_PCI: - pci_release_regions(cfg->dev); - pci_disable_device(pdev); -@@ -1108,7 +1141,7 @@ static const struct asyc_intr_info ainfo[] = { - {SISL_ASTATUS_FC1_OTHER, "other error", 1, CLR_FC_ERROR | LINK_RESET}, - {SISL_ASTATUS_FC1_LOGO, "target initiated LOGO", 1, 0}, - {SISL_ASTATUS_FC1_CRC_T, "CRC threshold exceeded", 1, LINK_RESET}, -- {SISL_ASTATUS_FC1_LOGI_R, "login timed out, retrying", 1, 0}, -+ {SISL_ASTATUS_FC1_LOGI_R, "login timed out, retrying", 1, LINK_RESET}, - {SISL_ASTATUS_FC1_LOGI_F, "login failed", 1, CLR_FC_ERROR}, - {SISL_ASTATUS_FC1_LOGI_S, "login succeeded", 1, SCAN_HOST}, - {SISL_ASTATUS_FC1_LINK_DN, "link down", 1, 0}, -@@ -1316,6 +1349,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) - __func__, port); - cfg->lr_state = LINK_RESET_REQUIRED; - cfg->lr_port = port; -+ kref_get(&cfg->afu->mapcount); - schedule_work(&cfg->work_q); - } - -@@ -1336,6 +1370,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) - - if (info->action & SCAN_HOST) { - atomic_inc(&cfg->scan_host_needed); -+ kref_get(&cfg->afu->mapcount); - schedule_work(&cfg->work_q); - } - } -@@ -1731,6 +1766,7 @@ static int init_afu(struct cxlflash_cfg *cfg) - rc = -ENOMEM; - goto err1; - } -+ kref_init(&afu->mapcount); - - /* No byte reverse on reading afu_version or string will be backwards */ - reg = readq(&afu->afu_map->global.regs.afu_version); -@@ -1765,8 +1801,7 @@ out: - return rc; - - err2: -- cxl_psa_unmap((void __iomem *)afu->afu_map); -- afu->afu_map = NULL; -+ kref_put(&afu->mapcount, afu_unmap); - err1: - term_mc(cfg, UNDO_START); - goto out; -@@ -2114,6 +2149,16 @@ static ssize_t lun_mode_store(struct device *dev, - rc = kstrtouint(buf, 10, &lun_mode); - if (!rc && (lun_mode < 5) && (lun_mode != afu->internal_lun)) { - afu->internal_lun = lun_mode; -+ -+ /* -+ * When configured for internal LUN, there is only one channel, -+ * channel number 0, else there will be 2 (default). -+ */ -+ if (afu->internal_lun) -+ shost->max_channel = 0; -+ else -+ shost->max_channel = NUM_FC_PORTS - 1; -+ - afu_reset(cfg); - scsi_scan_host(cfg->host); - } -@@ -2274,6 +2319,7 @@ static struct scsi_host_template driver_template = { - * Device dependent values - */ - static struct dev_dependent_vals dev_corsa_vals = { CXLFLASH_MAX_SECTORS }; -+static struct dev_dependent_vals dev_flash_gt_vals = { CXLFLASH_MAX_SECTORS }; - - /* - * PCI device binding table -@@ -2281,6 +2327,8 @@ static struct dev_dependent_vals dev_corsa_vals = { CXLFLASH_MAX_SECTORS }; - static struct pci_device_id cxlflash_pci_table[] = { - {PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CORSA, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&dev_corsa_vals}, -+ {PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_FLASH_GT, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&dev_flash_gt_vals}, - {} - }; - -@@ -2339,6 +2387,7 @@ static void cxlflash_worker_thread(struct work_struct *work) - - if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0) - scsi_scan_host(cfg->host); -+ kref_put(&afu->mapcount, afu_unmap); - } - - /** -diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h -index 60324566c14f..3d2d606fafb3 100644 ---- a/drivers/scsi/cxlflash/main.h -+++ b/drivers/scsi/cxlflash/main.h -@@ -24,8 +24,8 @@ - #define CXLFLASH_ADAPTER_NAME "IBM POWER CXL Flash Adapter" - #define CXLFLASH_DRIVER_DATE "(August 13, 2015)" - --#define PCI_DEVICE_ID_IBM_CORSA 0x04F0 --#define CXLFLASH_SUBS_DEV_ID 0x04F0 -+#define PCI_DEVICE_ID_IBM_CORSA 0x04F0 -+#define PCI_DEVICE_ID_IBM_FLASH_GT 0x0600 - - /* Since there is only one target, make it 0 */ - #define CXLFLASH_TARGET 0 -diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c -index cac2e6a50efd..babe7ccc1777 100644 ---- a/drivers/scsi/cxlflash/superpipe.c -+++ b/drivers/scsi/cxlflash/superpipe.c -@@ -1380,7 +1380,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev, - } - - ctxid = cxl_process_element(ctx); -- if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) { -+ if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) { - dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); - rc = -EPERM; - goto err2; -@@ -1508,7 +1508,7 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi) - } - - ctxid = cxl_process_element(ctx); -- if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) { -+ if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) { - dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); - rc = -EPERM; - goto err1; -@@ -1590,6 +1590,13 @@ err1: - * place at the same time and the failure was due to CXL services being - * unable to keep up. - * -+ * As this routine is called on ioctl context, it holds the ioctl r/w -+ * semaphore that is used to drain ioctls in recovery scenarios. The -+ * implementation to achieve the pacing described above (a local mutex) -+ * requires that the ioctl r/w semaphore be dropped and reacquired to -+ * avoid a 3-way deadlock when multiple process recoveries operate in -+ * parallel. -+ * - * Because a user can detect an error condition before the kernel, it is - * quite possible for this routine to act as the kernel's EEH detection - * source (MMIO read of mbox_r). Because of this, there is a window of -@@ -1617,9 +1624,17 @@ static int cxlflash_afu_recover(struct scsi_device *sdev, - int rc = 0; - - atomic_inc(&cfg->recovery_threads); -+ up_read(&cfg->ioctl_rwsem); - rc = mutex_lock_interruptible(mutex); -+ down_read(&cfg->ioctl_rwsem); - if (rc) - goto out; -+ rc = check_state(cfg); -+ if (rc) { -+ dev_err(dev, "%s: Failed state! rc=%d\n", __func__, rc); -+ rc = -ENODEV; -+ goto out; -+ } - - dev_dbg(dev, "%s: reason 0x%016llX rctxid=%016llX\n", - __func__, recover->reason, rctxid); -diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c -index a53f583e2d7b..50f8e9300770 100644 ---- a/drivers/scsi/cxlflash/vlun.c -+++ b/drivers/scsi/cxlflash/vlun.c -@@ -1008,6 +1008,8 @@ int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg) - virt->last_lba = last_lba; - virt->rsrc_handle = rsrc_handle; - -+ if (lli->port_sel == BOTH_PORTS) -+ virt->hdr.return_flags |= DK_CXLFLASH_ALL_PORTS_ACTIVE; - out: - if (likely(ctxi)) - put_context(ctxi); -diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h -index b0e6fe46448d..80d3c740a8a8 100644 ---- a/drivers/scsi/lpfc/lpfc_crtn.h -+++ b/drivers/scsi/lpfc/lpfc_crtn.h -@@ -72,6 +72,7 @@ void lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *); - void lpfc_retry_pport_discovery(struct lpfc_hba *); - void lpfc_release_rpi(struct lpfc_hba *, struct lpfc_vport *, uint16_t); - -+void lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *); - void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); - void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *); - void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); -diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c -index b6fa257ea3e0..59ced8864b2f 100644 ---- a/drivers/scsi/lpfc/lpfc_els.c -+++ b/drivers/scsi/lpfc/lpfc_els.c -@@ -455,9 +455,9 @@ int - lpfc_issue_reg_vfi(struct lpfc_vport *vport) - { - struct lpfc_hba *phba = vport->phba; -- LPFC_MBOXQ_t *mboxq; -+ LPFC_MBOXQ_t *mboxq = NULL; - struct lpfc_nodelist *ndlp; -- struct lpfc_dmabuf *dmabuf; -+ struct lpfc_dmabuf *dmabuf = NULL; - int rc = 0; - - /* move forward in case of SLI4 FC port loopback test and pt2pt mode */ -@@ -471,25 +471,33 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport) - } - } - -- dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); -- if (!dmabuf) { -+ mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -+ if (!mboxq) { - rc = -ENOMEM; - goto fail; - } -- dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); -- if (!dmabuf->virt) { -- rc = -ENOMEM; -- goto fail_free_dmabuf; -- } - -- mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -- if (!mboxq) { -- rc = -ENOMEM; -- goto fail_free_coherent; -+ /* Supply CSP's only if we are fabric connect or pt-to-pt connect */ -+ if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) { -+ dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); -+ if (!dmabuf) { -+ rc = -ENOMEM; -+ goto fail; -+ } -+ dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); -+ if (!dmabuf->virt) { -+ rc = -ENOMEM; -+ goto fail; -+ } -+ memcpy(dmabuf->virt, &phba->fc_fabparam, -+ sizeof(struct serv_parm)); - } -+ - vport->port_state = LPFC_FABRIC_CFG_LINK; -- memcpy(dmabuf->virt, &phba->fc_fabparam, sizeof(vport->fc_sparam)); -- lpfc_reg_vfi(mboxq, vport, dmabuf->phys); -+ if (dmabuf) -+ lpfc_reg_vfi(mboxq, vport, dmabuf->phys); -+ else -+ lpfc_reg_vfi(mboxq, vport, 0); - - mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi; - mboxq->vport = vport; -@@ -497,17 +505,19 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport) - rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) { - rc = -ENXIO; -- goto fail_free_mbox; -+ goto fail; - } - return 0; - --fail_free_mbox: -- mempool_free(mboxq, phba->mbox_mem_pool); --fail_free_coherent: -- lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); --fail_free_dmabuf: -- kfree(dmabuf); - fail: -+ if (mboxq) -+ mempool_free(mboxq, phba->mbox_mem_pool); -+ if (dmabuf) { -+ if (dmabuf->virt) -+ lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); -+ kfree(dmabuf); -+ } -+ - lpfc_vport_set_state(vport, FC_VPORT_FAILED); - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "0289 Issue Register VFI failed: Err %d\n", rc); -@@ -711,9 +721,10 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - * For FC we need to do some special processing because of the SLI - * Port's default settings of the Common Service Parameters. - */ -- if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) { -+ if ((phba->sli_rev == LPFC_SLI_REV4) && -+ (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)) { - /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ -- if ((phba->sli_rev == LPFC_SLI_REV4) && fabric_param_changed) -+ if (fabric_param_changed) - lpfc_unregister_fcf_prep(phba); - - /* This should just update the VFI CSPs*/ -@@ -824,13 +835,21 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - - spin_lock_irq(shost->host_lock); - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); -+ vport->fc_flag |= FC_PT2PT; - spin_unlock_irq(shost->host_lock); - -- phba->fc_edtov = FF_DEF_EDTOV; -- phba->fc_ratov = FF_DEF_RATOV; -+ /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ -+ if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) { -+ lpfc_unregister_fcf_prep(phba); -+ -+ spin_lock_irq(shost->host_lock); -+ vport->fc_flag &= ~FC_VFI_REGISTERED; -+ spin_unlock_irq(shost->host_lock); -+ phba->fc_topology_changed = 0; -+ } -+ - rc = memcmp(&vport->fc_portname, &sp->portName, - sizeof(vport->fc_portname)); -- memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); - - if (rc >= 0) { - /* This side will initiate the PLOGI */ -@@ -839,38 +858,14 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - spin_unlock_irq(shost->host_lock); - - /* -- * N_Port ID cannot be 0, set our to LocalID the other -- * side will be RemoteID. -+ * N_Port ID cannot be 0, set our Id to LocalID -+ * the other side will be RemoteID. - */ - - /* not equal */ - if (rc) - vport->fc_myDID = PT2PT_LocalID; - -- mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -- if (!mbox) -- goto fail; -- -- lpfc_config_link(phba, mbox); -- -- mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -- mbox->vport = vport; -- rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -- if (rc == MBX_NOT_FINISHED) { -- mempool_free(mbox, phba->mbox_mem_pool); -- goto fail; -- } -- -- /* -- * For SLI4, the VFI/VPI are registered AFTER the -- * Nport with the higher WWPN sends the PLOGI with -- * an assigned NPortId. -- */ -- -- /* not equal */ -- if ((phba->sli_rev == LPFC_SLI_REV4) && rc) -- lpfc_issue_reg_vfi(vport); -- - /* Decrement ndlp reference count indicating that ndlp can be - * safely released when other references to it are done. - */ -@@ -912,29 +907,20 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - /* If we are pt2pt with another NPort, force NPIV off! */ - phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; - -- spin_lock_irq(shost->host_lock); -- vport->fc_flag |= FC_PT2PT; -- spin_unlock_irq(shost->host_lock); -- /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ -- if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) { -- lpfc_unregister_fcf_prep(phba); -+ mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -+ if (!mbox) -+ goto fail; - -- /* The FC_VFI_REGISTERED flag will get clear in the cmpl -- * handler for unreg_vfi, but if we don't force the -- * FC_VFI_REGISTERED flag then the reg_vfi mailbox could be -- * built with the update bit set instead of just the vp bit to -- * change the Nport ID. We need to have the vp set and the -- * Upd cleared on topology changes. -- */ -- spin_lock_irq(shost->host_lock); -- vport->fc_flag &= ~FC_VFI_REGISTERED; -- spin_unlock_irq(shost->host_lock); -- phba->fc_topology_changed = 0; -- lpfc_issue_reg_vfi(vport); -+ lpfc_config_link(phba, mbox); -+ -+ mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; -+ mbox->vport = vport; -+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -+ if (rc == MBX_NOT_FINISHED) { -+ mempool_free(mbox, phba->mbox_mem_pool); -+ goto fail; - } - -- /* Start discovery - this should just do CLEAR_LA */ -- lpfc_disc_start(vport); - return 0; - fail: - return -ENXIO; -@@ -1157,6 +1143,7 @@ flogifail: - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DISCOVERY; - spin_unlock_irq(&phba->hbalock); -+ - lpfc_nlp_put(ndlp); - - if (!lpfc_error_lost_link(irsp)) { -@@ -3792,14 +3779,17 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, - lpfc_nlp_set_state(vport, ndlp, - NLP_STE_REG_LOGIN_ISSUE); - } -+ -+ ndlp->nlp_flag |= NLP_REG_LOGIN_SEND; - if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) - != MBX_NOT_FINISHED) - goto out; -- else -- /* Decrement the ndlp reference count we -- * set for this failed mailbox command. -- */ -- lpfc_nlp_put(ndlp); -+ -+ /* Decrement the ndlp reference count we -+ * set for this failed mailbox command. -+ */ -+ lpfc_nlp_put(ndlp); -+ ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; - - /* ELS rsp: Cannot issue reg_login for */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, -@@ -3856,6 +3846,7 @@ out: - * the routine lpfc_els_free_iocb. - */ - cmdiocb->context1 = NULL; -+ - } - - lpfc_els_free_iocb(phba, cmdiocb); -@@ -3898,6 +3889,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, - IOCB_t *oldcmd; - struct lpfc_iocbq *elsiocb; - uint8_t *pcmd; -+ struct serv_parm *sp; - uint16_t cmdsize; - int rc; - ELS_PKT *els_pkt_ptr; -@@ -3927,6 +3919,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, - "Issue ACC: did:x%x flg:x%x", - ndlp->nlp_DID, ndlp->nlp_flag, 0); - break; -+ case ELS_CMD_FLOGI: - case ELS_CMD_PLOGI: - cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); - elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, -@@ -3944,10 +3937,34 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, - - *((uint32_t *) (pcmd)) = ELS_CMD_ACC; - pcmd += sizeof(uint32_t); -- memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); -+ sp = (struct serv_parm *)pcmd; -+ -+ if (flag == ELS_CMD_FLOGI) { -+ /* Copy the received service parameters back */ -+ memcpy(sp, &phba->fc_fabparam, -+ sizeof(struct serv_parm)); -+ -+ /* Clear the F_Port bit */ -+ sp->cmn.fPort = 0; -+ -+ /* Mark all class service parameters as invalid */ -+ sp->cls1.classValid = 0; -+ sp->cls2.classValid = 0; -+ sp->cls3.classValid = 0; -+ sp->cls4.classValid = 0; -+ -+ /* Copy our worldwide names */ -+ memcpy(&sp->portName, &vport->fc_sparam.portName, -+ sizeof(struct lpfc_name)); -+ memcpy(&sp->nodeName, &vport->fc_sparam.nodeName, -+ sizeof(struct lpfc_name)); -+ } else { -+ memcpy(pcmd, &vport->fc_sparam, -+ sizeof(struct serv_parm)); -+ } - - lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, -- "Issue ACC PLOGI: did:x%x flg:x%x", -+ "Issue ACC FLOGI/PLOGI: did:x%x flg:x%x", - ndlp->nlp_DID, ndlp->nlp_flag, 0); - break; - case ELS_CMD_PRLO: -@@ -4681,28 +4698,25 @@ lpfc_rdp_res_speed(struct fc_rdp_port_speed_desc *desc, struct lpfc_hba *phba) - - desc->tag = cpu_to_be32(RDP_PORT_SPEED_DESC_TAG); - -- switch (phba->sli4_hba.link_state.speed) { -- case LPFC_FC_LA_SPEED_1G: -+ switch (phba->fc_linkspeed) { -+ case LPFC_LINK_SPEED_1GHZ: - rdp_speed = RDP_PS_1GB; - break; -- case LPFC_FC_LA_SPEED_2G: -+ case LPFC_LINK_SPEED_2GHZ: - rdp_speed = RDP_PS_2GB; - break; -- case LPFC_FC_LA_SPEED_4G: -+ case LPFC_LINK_SPEED_4GHZ: - rdp_speed = RDP_PS_4GB; - break; -- case LPFC_FC_LA_SPEED_8G: -+ case LPFC_LINK_SPEED_8GHZ: - rdp_speed = RDP_PS_8GB; - break; -- case LPFC_FC_LA_SPEED_10G: -+ case LPFC_LINK_SPEED_10GHZ: - rdp_speed = RDP_PS_10GB; - break; -- case LPFC_FC_LA_SPEED_16G: -+ case LPFC_LINK_SPEED_16GHZ: - rdp_speed = RDP_PS_16GB; - break; -- case LPFC_FC_LA_SPEED_32G: -- rdp_speed = RDP_PS_32GB; -- break; - default: - rdp_speed = RDP_PS_UNKNOWN; - break; -@@ -5739,7 +5753,6 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, - IOCB_t *icmd = &cmdiocb->iocb; - struct serv_parm *sp; - LPFC_MBOXQ_t *mbox; -- struct ls_rjt stat; - uint32_t cmd, did; - int rc; - uint32_t fc_flag = 0; -@@ -5765,135 +5778,92 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, - return 1; - } - -- if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1))) { -- /* For a FLOGI we accept, then if our portname is greater -- * then the remote portname we initiate Nport login. -- */ -+ (void) lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1); - -- rc = memcmp(&vport->fc_portname, &sp->portName, -- sizeof(struct lpfc_name)); - -- if (!rc) { -- if (phba->sli_rev < LPFC_SLI_REV4) { -- mbox = mempool_alloc(phba->mbox_mem_pool, -- GFP_KERNEL); -- if (!mbox) -- return 1; -- lpfc_linkdown(phba); -- lpfc_init_link(phba, mbox, -- phba->cfg_topology, -- phba->cfg_link_speed); -- mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; -- mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -- mbox->vport = vport; -- rc = lpfc_sli_issue_mbox(phba, mbox, -- MBX_NOWAIT); -- lpfc_set_loopback_flag(phba); -- if (rc == MBX_NOT_FINISHED) -- mempool_free(mbox, phba->mbox_mem_pool); -- return 1; -- } else { -- /* abort the flogi coming back to ourselves -- * due to external loopback on the port. -- */ -- lpfc_els_abort_flogi(phba); -- return 0; -- } -- } else if (rc > 0) { /* greater than */ -- spin_lock_irq(shost->host_lock); -- vport->fc_flag |= FC_PT2PT_PLOGI; -- spin_unlock_irq(shost->host_lock); -+ /* -+ * If our portname is greater than the remote portname, -+ * then we initiate Nport login. -+ */ - -- /* If we have the high WWPN we can assign our own -- * myDID; otherwise, we have to WAIT for a PLOGI -- * from the remote NPort to find out what it -- * will be. -- */ -- vport->fc_myDID = PT2PT_LocalID; -- } else -- vport->fc_myDID = PT2PT_RemoteID; -+ rc = memcmp(&vport->fc_portname, &sp->portName, -+ sizeof(struct lpfc_name)); - -- /* -- * The vport state should go to LPFC_FLOGI only -- * AFTER we issue a FLOGI, not receive one. -+ if (!rc) { -+ if (phba->sli_rev < LPFC_SLI_REV4) { -+ mbox = mempool_alloc(phba->mbox_mem_pool, -+ GFP_KERNEL); -+ if (!mbox) -+ return 1; -+ lpfc_linkdown(phba); -+ lpfc_init_link(phba, mbox, -+ phba->cfg_topology, -+ phba->cfg_link_speed); -+ mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; -+ mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -+ mbox->vport = vport; -+ rc = lpfc_sli_issue_mbox(phba, mbox, -+ MBX_NOWAIT); -+ lpfc_set_loopback_flag(phba); -+ if (rc == MBX_NOT_FINISHED) -+ mempool_free(mbox, phba->mbox_mem_pool); -+ return 1; -+ } -+ -+ /* abort the flogi coming back to ourselves -+ * due to external loopback on the port. - */ -+ lpfc_els_abort_flogi(phba); -+ return 0; -+ -+ } else if (rc > 0) { /* greater than */ - spin_lock_irq(shost->host_lock); -- fc_flag = vport->fc_flag; -- port_state = vport->port_state; -- vport->fc_flag |= FC_PT2PT; -- vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); -+ vport->fc_flag |= FC_PT2PT_PLOGI; - spin_unlock_irq(shost->host_lock); -- lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, -- "3311 Rcv Flogi PS x%x new PS x%x " -- "fc_flag x%x new fc_flag x%x\n", -- port_state, vport->port_state, -- fc_flag, vport->fc_flag); - -- /* -- * We temporarily set fc_myDID to make it look like we are -- * a Fabric. This is done just so we end up with the right -- * did / sid on the FLOGI ACC rsp. -+ /* If we have the high WWPN we can assign our own -+ * myDID; otherwise, we have to WAIT for a PLOGI -+ * from the remote NPort to find out what it -+ * will be. - */ -- did = vport->fc_myDID; -- vport->fc_myDID = Fabric_DID; -- -+ vport->fc_myDID = PT2PT_LocalID; - } else { -- /* Reject this request because invalid parameters */ -- stat.un.b.lsRjtRsvd0 = 0; -- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; -- stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; -- stat.un.b.vendorUnique = 0; -- -- /* -- * We temporarily set fc_myDID to make it look like we are -- * a Fabric. This is done just so we end up with the right -- * did / sid on the FLOGI LS_RJT rsp. -- */ -- did = vport->fc_myDID; -- vport->fc_myDID = Fabric_DID; -- -- lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, -- NULL); -+ vport->fc_myDID = PT2PT_RemoteID; -+ } - -- /* Now lets put fc_myDID back to what its supposed to be */ -- vport->fc_myDID = did; -+ /* -+ * The vport state should go to LPFC_FLOGI only -+ * AFTER we issue a FLOGI, not receive one. -+ */ -+ spin_lock_irq(shost->host_lock); -+ fc_flag = vport->fc_flag; -+ port_state = vport->port_state; -+ vport->fc_flag |= FC_PT2PT; -+ vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); -+ spin_unlock_irq(shost->host_lock); -+ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, -+ "3311 Rcv Flogi PS x%x new PS x%x " -+ "fc_flag x%x new fc_flag x%x\n", -+ port_state, vport->port_state, -+ fc_flag, vport->fc_flag); - -- return 1; -- } -+ /* -+ * We temporarily set fc_myDID to make it look like we are -+ * a Fabric. This is done just so we end up with the right -+ * did / sid on the FLOGI ACC rsp. -+ */ -+ did = vport->fc_myDID; -+ vport->fc_myDID = Fabric_DID; - -- /* send our FLOGI first */ -- if (vport->port_state < LPFC_FLOGI) { -- vport->fc_myDID = 0; -- lpfc_initial_flogi(vport); -- vport->fc_myDID = Fabric_DID; -- } -+ memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); - - /* Send back ACC */ -- lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL); -+ lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, cmdiocb, ndlp, NULL); - - /* Now lets put fc_myDID back to what its supposed to be */ - vport->fc_myDID = did; - -- if (!(vport->fc_flag & FC_PT2PT_PLOGI)) { -- -- mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -- if (!mbox) -- goto fail; -- -- lpfc_config_link(phba, mbox); -- -- mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -- mbox->vport = vport; -- rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -- if (rc == MBX_NOT_FINISHED) { -- mempool_free(mbox, phba->mbox_mem_pool); -- goto fail; -- } -- } -- - return 0; --fail: -- return 1; - } - - /** -@@ -7345,7 +7315,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, - - /* reject till our FLOGI completes */ - if ((vport->port_state < LPFC_FABRIC_CFG_LINK) && -- (cmd != ELS_CMD_FLOGI)) { -+ (cmd != ELS_CMD_FLOGI)) { - rjt_err = LSRJT_UNABLE_TPC; - rjt_exp = LSEXP_NOTHING_MORE; - goto lsrjt; -@@ -7381,6 +7351,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, - rjt_exp = LSEXP_NOTHING_MORE; - break; - } -+ - if (vport->port_state < LPFC_DISC_AUTH) { - if (!(phba->pport->fc_flag & FC_PT2PT) || - (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { -diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c -index bfc2442dd74a..d3668aa555d5 100644 ---- a/drivers/scsi/lpfc/lpfc_hbadisc.c -+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c -@@ -1083,7 +1083,7 @@ out: - } - - --static void -+void - lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) - { - struct lpfc_vport *vport = pmb->vport; -@@ -1113,8 +1113,10 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) - /* Start discovery by sending a FLOGI. port_state is identically - * LPFC_FLOGI while waiting for FLOGI cmpl - */ -- if (vport->port_state != LPFC_FLOGI || vport->fc_flag & FC_PT2PT_PLOGI) -+ if (vport->port_state != LPFC_FLOGI) - lpfc_initial_flogi(vport); -+ else if (vport->fc_flag & FC_PT2PT) -+ lpfc_disc_start(vport); - return; - - out: -@@ -2963,8 +2965,10 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) - - out_free_mem: - mempool_free(mboxq, phba->mbox_mem_pool); -- lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); -- kfree(dmabuf); -+ if (dmabuf) { -+ lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); -+ kfree(dmabuf); -+ } - return; - } - -@@ -3448,10 +3452,10 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) - spin_lock_irq(shost->host_lock); - ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; - spin_unlock_irq(shost->host_lock); -- } else -- /* Good status, call state machine */ -- lpfc_disc_state_machine(vport, ndlp, pmb, -- NLP_EVT_CMPL_REG_LOGIN); -+ } -+ -+ /* Call state machine */ -+ lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN); - - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); -diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c -index b0d92b84bcdc..c14ab6c3ae40 100644 ---- a/drivers/scsi/lpfc/lpfc_init.c -+++ b/drivers/scsi/lpfc/lpfc_init.c -@@ -8834,9 +8834,12 @@ found: - * already mapped to this phys_id. - */ - if (cpup->irq != LPFC_VECTOR_MAP_EMPTY) { -- chann[saved_chann] = -- cpup->channel_id; -- saved_chann++; -+ if (saved_chann <= -+ LPFC_FCP_IO_CHAN_MAX) { -+ chann[saved_chann] = -+ cpup->channel_id; -+ saved_chann++; -+ } - goto out; - } - -diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c -index f87f90e9b7df..1e34b5408a29 100644 ---- a/drivers/scsi/lpfc/lpfc_mbox.c -+++ b/drivers/scsi/lpfc/lpfc_mbox.c -@@ -2145,10 +2145,12 @@ lpfc_reg_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport, dma_addr_t phys) - reg_vfi->wwn[1] = cpu_to_le32(reg_vfi->wwn[1]); - reg_vfi->e_d_tov = phba->fc_edtov; - reg_vfi->r_a_tov = phba->fc_ratov; -- reg_vfi->bde.addrHigh = putPaddrHigh(phys); -- reg_vfi->bde.addrLow = putPaddrLow(phys); -- reg_vfi->bde.tus.f.bdeSize = sizeof(vport->fc_sparam); -- reg_vfi->bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; -+ if (phys) { -+ reg_vfi->bde.addrHigh = putPaddrHigh(phys); -+ reg_vfi->bde.addrLow = putPaddrLow(phys); -+ reg_vfi->bde.tus.f.bdeSize = sizeof(vport->fc_sparam); -+ reg_vfi->bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; -+ } - bf_set(lpfc_reg_vfi_nport_id, reg_vfi, vport->fc_myDID); - - /* Only FC supports upd bit */ -diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c -index ed9a2c80c4aa..193733e8c823 100644 ---- a/drivers/scsi/lpfc/lpfc_nportdisc.c -+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c -@@ -280,38 +280,12 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - uint32_t *lp; - IOCB_t *icmd; - struct serv_parm *sp; -+ uint32_t ed_tov; - LPFC_MBOXQ_t *mbox; - struct ls_rjt stat; - int rc; - - memset(&stat, 0, sizeof (struct ls_rjt)); -- if (vport->port_state <= LPFC_FDISC) { -- /* Before responding to PLOGI, check for pt2pt mode. -- * If we are pt2pt, with an outstanding FLOGI, abort -- * the FLOGI and resend it first. -- */ -- if (vport->fc_flag & FC_PT2PT) { -- lpfc_els_abort_flogi(phba); -- if (!(vport->fc_flag & FC_PT2PT_PLOGI)) { -- /* If the other side is supposed to initiate -- * the PLOGI anyway, just ACC it now and -- * move on with discovery. -- */ -- phba->fc_edtov = FF_DEF_EDTOV; -- phba->fc_ratov = FF_DEF_RATOV; -- /* Start discovery - this should just do -- CLEAR_LA */ -- lpfc_disc_start(vport); -- } else -- lpfc_initial_flogi(vport); -- } else { -- stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; -- stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; -- lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, -- ndlp, NULL); -- return 0; -- } -- } - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; - lp = (uint32_t *) pcmd->virt; - sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); -@@ -404,30 +378,46 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, - /* Check for Nport to NPort pt2pt protocol */ - if ((vport->fc_flag & FC_PT2PT) && - !(vport->fc_flag & FC_PT2PT_PLOGI)) { -- - /* rcv'ed PLOGI decides what our NPortId will be */ - vport->fc_myDID = icmd->un.rcvels.parmRo; -- mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -- if (mbox == NULL) -- goto out; -- lpfc_config_link(phba, mbox); -- mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -- mbox->vport = vport; -- rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -- if (rc == MBX_NOT_FINISHED) { -- mempool_free(mbox, phba->mbox_mem_pool); -- goto out; -+ -+ ed_tov = be32_to_cpu(sp->cmn.e_d_tov); -+ if (sp->cmn.edtovResolution) { -+ /* E_D_TOV ticks are in nanoseconds */ -+ ed_tov = (phba->fc_edtov + 999999) / 1000000; - } -+ - /* -- * For SLI4, the VFI/VPI are registered AFTER the -- * Nport with the higher WWPN sends us a PLOGI with -- * our assigned NPortId. -+ * For pt-to-pt, use the larger EDTOV -+ * RATOV = 2 * EDTOV - */ -+ if (ed_tov > phba->fc_edtov) -+ phba->fc_edtov = ed_tov; -+ phba->fc_ratov = (2 * phba->fc_edtov) / 1000; -+ -+ memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); -+ -+ /* Issue config_link / reg_vfi to account for updated TOV's */ -+ - if (phba->sli_rev == LPFC_SLI_REV4) - lpfc_issue_reg_vfi(vport); -+ else { -+ mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -+ if (mbox == NULL) -+ goto out; -+ lpfc_config_link(phba, mbox); -+ mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -+ mbox->vport = vport; -+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -+ if (rc == MBX_NOT_FINISHED) { -+ mempool_free(mbox, phba->mbox_mem_pool); -+ goto out; -+ } -+ } - - lpfc_can_disctmo(vport); - } -+ - mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!mbox) - goto out; -@@ -1038,7 +1028,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, - uint32_t *lp; - IOCB_t *irsp; - struct serv_parm *sp; -+ uint32_t ed_tov; - LPFC_MBOXQ_t *mbox; -+ int rc; - - cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; -@@ -1094,18 +1086,63 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, - ndlp->nlp_maxframe = - ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb; - -+ if ((vport->fc_flag & FC_PT2PT) && -+ (vport->fc_flag & FC_PT2PT_PLOGI)) { -+ ed_tov = be32_to_cpu(sp->cmn.e_d_tov); -+ if (sp->cmn.edtovResolution) { -+ /* E_D_TOV ticks are in nanoseconds */ -+ ed_tov = (phba->fc_edtov + 999999) / 1000000; -+ } -+ -+ /* -+ * Use the larger EDTOV -+ * RATOV = 2 * EDTOV for pt-to-pt -+ */ -+ if (ed_tov > phba->fc_edtov) -+ phba->fc_edtov = ed_tov; -+ phba->fc_ratov = (2 * phba->fc_edtov) / 1000; -+ -+ memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); -+ -+ /* Issue config_link / reg_vfi to account for updated TOV's */ -+ if (phba->sli_rev == LPFC_SLI_REV4) { -+ lpfc_issue_reg_vfi(vport); -+ } else { -+ mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -+ if (!mbox) { -+ lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, -+ "0133 PLOGI: no memory " -+ "for config_link " -+ "Data: x%x x%x x%x x%x\n", -+ ndlp->nlp_DID, ndlp->nlp_state, -+ ndlp->nlp_flag, ndlp->nlp_rpi); -+ goto out; -+ } -+ -+ lpfc_config_link(phba, mbox); -+ -+ mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; -+ mbox->vport = vport; -+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); -+ if (rc == MBX_NOT_FINISHED) { -+ mempool_free(mbox, phba->mbox_mem_pool); -+ goto out; -+ } -+ } -+ } -+ -+ lpfc_unreg_rpi(vport, ndlp); -+ - mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!mbox) { - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, -- "0133 PLOGI: no memory for reg_login " -- "Data: x%x x%x x%x x%x\n", -- ndlp->nlp_DID, ndlp->nlp_state, -- ndlp->nlp_flag, ndlp->nlp_rpi); -+ "0018 PLOGI: no memory for reg_login " -+ "Data: x%x x%x x%x x%x\n", -+ ndlp->nlp_DID, ndlp->nlp_state, -+ ndlp->nlp_flag, ndlp->nlp_rpi); - goto out; - } - -- lpfc_unreg_rpi(vport, ndlp); -- - if (lpfc_reg_rpi(phba, vport->vpi, irsp->un.elsreq64.remoteID, - (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) { - switch (ndlp->nlp_DID) { -@@ -2299,6 +2336,9 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport, - if (vport->phba->sli_rev < LPFC_SLI_REV4) - ndlp->nlp_rpi = mb->un.varWords[0]; - ndlp->nlp_flag |= NLP_RPI_REGISTERED; -+ if (ndlp->nlp_flag & NLP_LOGO_ACC) { -+ lpfc_unreg_rpi(vport, ndlp); -+ } - } else { - if (ndlp->nlp_flag & NLP_NODEV_REMOVE) { - lpfc_drop_node(vport, ndlp); -diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c -index 9e165bc05ee1..bae36cc3740b 100644 ---- a/drivers/scsi/lpfc/lpfc_scsi.c -+++ b/drivers/scsi/lpfc/lpfc_scsi.c -@@ -3908,9 +3908,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, - uint32_t logit = LOG_FCP; - - /* Sanity check on return of outstanding command */ -- if (!(lpfc_cmd->pCmd)) -- return; - cmd = lpfc_cmd->pCmd; -+ if (!cmd) -+ return; - shost = cmd->device->host; - - lpfc_cmd->result = (pIocbOut->iocb.un.ulpWord[4] & IOERR_PARAM_MASK); -diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c -index f9585cdd8933..92dfd6a5178c 100644 ---- a/drivers/scsi/lpfc/lpfc_sli.c -+++ b/drivers/scsi/lpfc/lpfc_sli.c -@@ -14842,10 +14842,12 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) - struct lpfc_dmabuf *h_buf; - struct hbq_dmabuf *seq_dmabuf = NULL; - struct hbq_dmabuf *temp_dmabuf = NULL; -+ uint8_t found = 0; - - INIT_LIST_HEAD(&dmabuf->dbuf.list); - dmabuf->time_stamp = jiffies; - new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; -+ - /* Use the hdr_buf to find the sequence that this frame belongs to */ - list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { - temp_hdr = (struct fc_frame_header *)h_buf->virt; -@@ -14885,7 +14887,8 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) - return seq_dmabuf; - } - /* find the correct place in the sequence to insert this frame */ -- list_for_each_entry_reverse(d_buf, &seq_dmabuf->dbuf.list, list) { -+ d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); -+ while (!found) { - temp_dmabuf = container_of(d_buf, struct hbq_dmabuf, dbuf); - temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; - /* -@@ -14895,9 +14898,17 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) - if (be16_to_cpu(new_hdr->fh_seq_cnt) > - be16_to_cpu(temp_hdr->fh_seq_cnt)) { - list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); -- return seq_dmabuf; -+ found = 1; -+ break; - } -+ -+ if (&d_buf->list == &seq_dmabuf->dbuf.list) -+ break; -+ d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); - } -+ -+ if (found) -+ return seq_dmabuf; - return NULL; - } - -@@ -16173,7 +16184,7 @@ fail_fcf_read: - } - - /** -- * lpfc_check_next_fcf_pri -+ * lpfc_check_next_fcf_pri_level - * phba pointer to the lpfc_hba struct for this port. - * This routine is called from the lpfc_sli4_fcf_rr_next_index_get - * routine when the rr_bmask is empty. The FCF indecies are put into the -@@ -16329,8 +16340,12 @@ next_priority: - - if (next_fcf_index < LPFC_SLI4_FCF_TBL_INDX_MAX && - phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & -- LPFC_FCF_FLOGI_FAILED) -+ LPFC_FCF_FLOGI_FAILED) { -+ if (list_is_singular(&phba->fcf.fcf_pri_list)) -+ return LPFC_FCOE_FCF_NEXT_NONE; -+ - goto next_priority; -+ } - - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2845 Get next roundrobin failover FCF (x%x)\n", -diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h -index c0f7c8ce54aa..ef4ff03242ea 100644 ---- a/drivers/scsi/megaraid/megaraid_sas.h -+++ b/drivers/scsi/megaraid/megaraid_sas.h -@@ -1083,6 +1083,8 @@ struct megasas_ctrl_info { - - #define VD_EXT_DEBUG 0 - -+#define SCAN_PD_CHANNEL 0x1 -+#define SCAN_VD_CHANNEL 0x2 - - enum MR_SCSI_CMD_TYPE { - READ_WRITE_LDIO = 0, -diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c -index e994ff944091..3f8d357b1bac 100644 ---- a/drivers/scsi/megaraid/megaraid_sas_base.c -+++ b/drivers/scsi/megaraid/megaraid_sas_base.c -@@ -735,6 +735,7 @@ megasas_fire_cmd_skinny(struct megasas_instance *instance, - &(regs)->inbound_high_queue_port); - writel((lower_32_bits(frame_phys_addr) | (frame_count<<1))|1, - &(regs)->inbound_low_queue_port); -+ mmiowb(); - spin_unlock_irqrestore(&instance->hba_lock, flags); - } - -@@ -5476,7 +5477,6 @@ static int megasas_probe_one(struct pci_dev *pdev, - spin_lock_init(&instance->hba_lock); - spin_lock_init(&instance->completion_lock); - -- mutex_init(&instance->aen_mutex); - mutex_init(&instance->reset_mutex); - - /* -@@ -6443,10 +6443,10 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) - } - spin_unlock_irqrestore(&instance->hba_lock, flags); - -- mutex_lock(&instance->aen_mutex); -+ mutex_lock(&instance->reset_mutex); - error = megasas_register_aen(instance, aen.seq_num, - aen.class_locale_word); -- mutex_unlock(&instance->aen_mutex); -+ mutex_unlock(&instance->reset_mutex); - return error; - } - -@@ -6477,9 +6477,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) - int i; - int error = 0; - compat_uptr_t ptr; -- unsigned long local_raw_ptr; - u32 local_sense_off; - u32 local_sense_len; -+ u32 user_sense_off; - - if (clear_user(ioc, sizeof(*ioc))) - return -EFAULT; -@@ -6497,17 +6497,16 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) - * sense_len is not null, so prepare the 64bit value under - * the same condition. - */ -- if (get_user(local_raw_ptr, ioc->frame.raw) || -- get_user(local_sense_off, &ioc->sense_off) || -- get_user(local_sense_len, &ioc->sense_len)) -+ if (get_user(local_sense_off, &ioc->sense_off) || -+ get_user(local_sense_len, &ioc->sense_len) || -+ get_user(user_sense_off, &cioc->sense_off)) - return -EFAULT; - -- - if (local_sense_len) { - void __user **sense_ioc_ptr = -- (void __user **)((u8*)local_raw_ptr + local_sense_off); -+ (void __user **)((u8 *)((unsigned long)&ioc->frame.raw) + local_sense_off); - compat_uptr_t *sense_cioc_ptr = -- (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off); -+ (compat_uptr_t *)(((unsigned long)&cioc->frame.raw) + user_sense_off); - if (get_user(ptr, sense_cioc_ptr) || - put_user(compat_ptr(ptr), sense_ioc_ptr)) - return -EFAULT; -@@ -6648,6 +6647,7 @@ megasas_aen_polling(struct work_struct *work) - int i, j, doscan = 0; - u32 seq_num, wait_time = MEGASAS_RESET_WAIT_TIME; - int error; -+ u8 dcmd_ret = 0; - - if (!instance) { - printk(KERN_ERR "invalid instance!\n"); -@@ -6660,16 +6660,7 @@ megasas_aen_polling(struct work_struct *work) - wait_time = MEGASAS_ROUTINE_WAIT_TIME_VF; - - /* Don't run the event workqueue thread if OCR is running */ -- for (i = 0; i < wait_time; i++) { -- if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) -- break; -- if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { -- dev_notice(&instance->pdev->dev, "%s waiting for " -- "controller reset to finish for scsi%d\n", -- __func__, instance->host->host_no); -- } -- msleep(1000); -- } -+ mutex_lock(&instance->reset_mutex); - - instance->ev = NULL; - host = instance->host; -@@ -6677,212 +6668,127 @@ megasas_aen_polling(struct work_struct *work) - megasas_decode_evt(instance); - - switch (le32_to_cpu(instance->evt_detail->code)) { -- case MR_EVT_PD_INSERTED: -- if (megasas_get_pd_list(instance) == 0) { -- for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) { -- for (j = 0; -- j < MEGASAS_MAX_DEV_PER_CHANNEL; -- j++) { -- -- pd_index = -- (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -- -- sdev1 = scsi_device_lookup(host, i, j, 0); -- -- if (instance->pd_list[pd_index].driveState -- == MR_PD_STATE_SYSTEM) { -- if (!sdev1) -- scsi_add_device(host, i, j, 0); -- -- if (sdev1) -- scsi_device_put(sdev1); -- } -- } -- } -- } -- doscan = 0; -- break; - -+ case MR_EVT_PD_INSERTED: - case MR_EVT_PD_REMOVED: -- if (megasas_get_pd_list(instance) == 0) { -- for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) { -- for (j = 0; -- j < MEGASAS_MAX_DEV_PER_CHANNEL; -- j++) { -- -- pd_index = -- (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -- -- sdev1 = scsi_device_lookup(host, i, j, 0); -- -- if (instance->pd_list[pd_index].driveState -- == MR_PD_STATE_SYSTEM) { -- if (sdev1) -- scsi_device_put(sdev1); -- } else { -- if (sdev1) { -- scsi_remove_device(sdev1); -- scsi_device_put(sdev1); -- } -- } -- } -- } -- } -- doscan = 0; -+ dcmd_ret = megasas_get_pd_list(instance); -+ if (dcmd_ret == 0) -+ doscan = SCAN_PD_CHANNEL; - break; - - case MR_EVT_LD_OFFLINE: - case MR_EVT_CFG_CLEARED: - case MR_EVT_LD_DELETED: -- if (!instance->requestorId || -- megasas_get_ld_vf_affiliation(instance, 0)) { -- if (megasas_ld_list_query(instance, -- MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) -- megasas_get_ld_list(instance); -- for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) { -- for (j = 0; -- j < MEGASAS_MAX_DEV_PER_CHANNEL; -- j++) { -- -- ld_index = -- (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -- -- sdev1 = scsi_device_lookup(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -- -- if (instance->ld_ids[ld_index] -- != 0xff) { -- if (sdev1) -- scsi_device_put(sdev1); -- } else { -- if (sdev1) { -- scsi_remove_device(sdev1); -- scsi_device_put(sdev1); -- } -- } -- } -- } -- doscan = 0; -- } -- break; - case MR_EVT_LD_CREATED: - if (!instance->requestorId || -- megasas_get_ld_vf_affiliation(instance, 0)) { -- if (megasas_ld_list_query(instance, -- MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) -- megasas_get_ld_list(instance); -- for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) { -- for (j = 0; -- j < MEGASAS_MAX_DEV_PER_CHANNEL; -- j++) { -- ld_index = -- (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -- -- sdev1 = scsi_device_lookup(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -- -- if (instance->ld_ids[ld_index] -- != 0xff) { -- if (!sdev1) -- scsi_add_device(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -- } -- if (sdev1) -- scsi_device_put(sdev1); -- } -- } -- doscan = 0; -- } -+ (instance->requestorId && megasas_get_ld_vf_affiliation(instance, 0))) -+ dcmd_ret = megasas_ld_list_query(instance, MR_LD_QUERY_TYPE_EXPOSED_TO_HOST); -+ -+ if (dcmd_ret == 0) -+ doscan = SCAN_VD_CHANNEL; -+ - break; -+ - case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED: - case MR_EVT_FOREIGN_CFG_IMPORTED: - case MR_EVT_LD_STATE_CHANGE: -- doscan = 1; -+ dcmd_ret = megasas_get_pd_list(instance); -+ -+ if (dcmd_ret != 0) -+ break; -+ -+ if (!instance->requestorId || -+ (instance->requestorId && megasas_get_ld_vf_affiliation(instance, 0))) -+ dcmd_ret = megasas_ld_list_query(instance, MR_LD_QUERY_TYPE_EXPOSED_TO_HOST); -+ -+ if (dcmd_ret != 0) -+ break; -+ -+ doscan = SCAN_VD_CHANNEL | SCAN_PD_CHANNEL; -+ dev_info(&instance->pdev->dev, "scanning for scsi%d...\n", -+ instance->host->host_no); - break; -+ - case MR_EVT_CTRL_PROP_CHANGED: -- megasas_get_ctrl_info(instance); -- break; -+ dcmd_ret = megasas_get_ctrl_info(instance); -+ break; - default: - doscan = 0; - break; - } - } else { - dev_err(&instance->pdev->dev, "invalid evt_detail!\n"); -+ mutex_unlock(&instance->reset_mutex); - kfree(ev); - return; - } - -- if (doscan) { -- dev_info(&instance->pdev->dev, "scanning for scsi%d...\n", -- instance->host->host_no); -- if (megasas_get_pd_list(instance) == 0) { -- for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) { -- for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) { -- pd_index = i*MEGASAS_MAX_DEV_PER_CHANNEL + j; -- sdev1 = scsi_device_lookup(host, i, j, 0); -- if (instance->pd_list[pd_index].driveState == -- MR_PD_STATE_SYSTEM) { -- if (!sdev1) { -- scsi_add_device(host, i, j, 0); -- } -- if (sdev1) -- scsi_device_put(sdev1); -- } else { -- if (sdev1) { -- scsi_remove_device(sdev1); -- scsi_device_put(sdev1); -- } -+ mutex_unlock(&instance->reset_mutex); -+ -+ if (doscan & SCAN_PD_CHANNEL) { -+ for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) { -+ for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) { -+ pd_index = i*MEGASAS_MAX_DEV_PER_CHANNEL + j; -+ sdev1 = scsi_device_lookup(host, i, j, 0); -+ if (instance->pd_list[pd_index].driveState == -+ MR_PD_STATE_SYSTEM) { -+ if (!sdev1) -+ scsi_add_device(host, i, j, 0); -+ else -+ scsi_device_put(sdev1); -+ } else { -+ if (sdev1) { -+ scsi_remove_device(sdev1); -+ scsi_device_put(sdev1); - } - } - } - } -+ } - -- if (!instance->requestorId || -- megasas_get_ld_vf_affiliation(instance, 0)) { -- if (megasas_ld_list_query(instance, -- MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) -- megasas_get_ld_list(instance); -- for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) { -- for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; -- j++) { -- ld_index = -- (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -- -- sdev1 = scsi_device_lookup(host, -- MEGASAS_MAX_PD_CHANNELS + i, j, 0); -- if (instance->ld_ids[ld_index] -- != 0xff) { -- if (!sdev1) -- scsi_add_device(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -- else -- scsi_device_put(sdev1); -- } else { -- if (sdev1) { -- scsi_remove_device(sdev1); -- scsi_device_put(sdev1); -- } -+ if (doscan & SCAN_VD_CHANNEL) { -+ for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) { -+ for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) { -+ ld_index = (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j; -+ sdev1 = scsi_device_lookup(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -+ if (instance->ld_ids[ld_index] != 0xff) { -+ if (!sdev1) -+ scsi_add_device(host, MEGASAS_MAX_PD_CHANNELS + i, j, 0); -+ else -+ scsi_device_put(sdev1); -+ } else { -+ if (sdev1) { -+ scsi_remove_device(sdev1); -+ scsi_device_put(sdev1); - } - } - } - } - } - -- if (instance->aen_cmd != NULL) { -- kfree(ev); -- return ; -- } -- -- seq_num = le32_to_cpu(instance->evt_detail->seq_num) + 1; -+ if (dcmd_ret == 0) -+ seq_num = le32_to_cpu(instance->evt_detail->seq_num) + 1; -+ else -+ seq_num = instance->last_seq_num; - - /* Register AEN with FW for latest sequence number plus 1 */ - class_locale.members.reserved = 0; - class_locale.members.locale = MR_EVT_LOCALE_ALL; - class_locale.members.class = MR_EVT_CLASS_DEBUG; -- mutex_lock(&instance->aen_mutex); -+ -+ if (instance->aen_cmd != NULL) { -+ kfree(ev); -+ return; -+ } -+ -+ mutex_lock(&instance->reset_mutex); - error = megasas_register_aen(instance, seq_num, - class_locale.word); -- mutex_unlock(&instance->aen_mutex); -- - if (error) -- dev_err(&instance->pdev->dev, "register aen failed error %x\n", error); -+ dev_err(&instance->pdev->dev, -+ "register aen failed error %x\n", error); - -+ mutex_unlock(&instance->reset_mutex); - kfree(ev); - } - -diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c -index 4f391e747be2..021b994fdae8 100644 ---- a/drivers/scsi/megaraid/megaraid_sas_fusion.c -+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c -@@ -201,6 +201,7 @@ megasas_fire_cmd_fusion(struct megasas_instance *instance, - &instance->reg_set->inbound_low_queue_port); - writel(le32_to_cpu(req_desc->u.high), - &instance->reg_set->inbound_high_queue_port); -+ mmiowb(); - spin_unlock_irqrestore(&instance->hba_lock, flags); - #endif - } -diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c -index 356233f86064..5b2c37f1e908 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_base.c -+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c -@@ -2020,8 +2020,10 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc) - _base_free_irq(ioc); - _base_disable_msix(ioc); - -- if (ioc->msix96_vector) -+ if (ioc->msix96_vector) { - kfree(ioc->replyPostRegisterIndex); -+ ioc->replyPostRegisterIndex = NULL; -+ } - - if (ioc->chip_phys) { - iounmap(ioc->chip); -@@ -2240,6 +2242,12 @@ mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc, u32 phys_addr) - return ioc->reply + (phys_addr - (u32)ioc->reply_dma); - } - -+static inline u8 -+_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc) -+{ -+ return ioc->cpu_msix_table[raw_smp_processor_id()]; -+} -+ - /** - * mpt3sas_base_get_smid - obtain a free smid from internal queue - * @ioc: per adapter object -@@ -2300,6 +2308,7 @@ mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx, - request->scmd = scmd; - request->cb_idx = cb_idx; - smid = request->smid; -+ request->msix_io = _base_get_msix_index(ioc); - list_del(&request->tracker_list); - spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); - return smid; -@@ -2422,12 +2431,6 @@ _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock) - } - #endif - --static inline u8 --_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc) --{ -- return ioc->cpu_msix_table[raw_smp_processor_id()]; --} -- - /** - * mpt3sas_base_put_smid_scsi_io - send SCSI_IO request to firmware - * @ioc: per adapter object -@@ -2481,18 +2484,19 @@ mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid, - * mpt3sas_base_put_smid_hi_priority - send Task Managment request to firmware - * @ioc: per adapter object - * @smid: system request message index -- * -+ * @msix_task: msix_task will be same as msix of IO incase of task abort else 0. - * Return nothing. - */ - void --mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid) -+mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid, -+ u16 msix_task) - { - Mpi2RequestDescriptorUnion_t descriptor; - u64 *request = (u64 *)&descriptor; - - descriptor.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; -- descriptor.HighPriority.MSIxIndex = 0; -+ descriptor.HighPriority.MSIxIndex = msix_task; - descriptor.HighPriority.SMID = cpu_to_le16(smid); - descriptor.HighPriority.LMID = 0; - descriptor.HighPriority.Reserved1 = 0; -diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h -index 5ad271efbd45..92648a5ea2d2 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_base.h -+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h -@@ -643,6 +643,7 @@ struct chain_tracker { - * @cb_idx: callback index - * @direct_io: To indicate whether I/O is direct (WARPDRIVE) - * @tracker_list: list of free request (ioc->free_list) -+ * @msix_io: IO's msix - */ - struct scsiio_tracker { - u16 smid; -@@ -651,6 +652,7 @@ struct scsiio_tracker { - u8 direct_io; - struct list_head chain_list; - struct list_head tracker_list; -+ u16 msix_io; - }; - - /** -@@ -1213,7 +1215,8 @@ void mpt3sas_base_put_smid_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, - u16 handle); - void mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid, - u16 handle); --void mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid); -+void mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, -+ u16 smid, u16 msix_task); - void mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid); - void mpt3sas_base_initialize_callback_handler(void); - u8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func); -diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c -index d8366b056b70..4ccde5a05b70 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c -+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c -@@ -817,7 +817,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, - tm_request->DevHandle)); - ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, - data_in_dma, data_in_sz); -- mpt3sas_base_put_smid_hi_priority(ioc, smid); -+ mpt3sas_base_put_smid_hi_priority(ioc, smid, 0); - break; - } - case MPI2_FUNCTION_SMP_PASSTHROUGH: -diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c -index 9ab77b06434d..6180f7970bbf 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c -+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c -@@ -2193,6 +2193,7 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, - unsigned long timeleft; - struct scsiio_tracker *scsi_lookup = NULL; - int rc; -+ u16 msix_task = 0; - - if (m_type == TM_MUTEX_ON) - mutex_lock(&ioc->tm_cmds.mutex); -@@ -2256,7 +2257,12 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, - int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); - mpt3sas_scsih_set_tm_flag(ioc, handle); - init_completion(&ioc->tm_cmds.done); -- mpt3sas_base_put_smid_hi_priority(ioc, smid); -+ if ((type == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) && -+ (scsi_lookup->msix_io < ioc->reply_queue_count)) -+ msix_task = scsi_lookup->msix_io; -+ else -+ msix_task = 0; -+ mpt3sas_base_put_smid_hi_priority(ioc, smid, msix_task); - timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); - if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", -@@ -3151,7 +3157,7 @@ _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) - mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; - mpi_request->DevHandle = cpu_to_le16(handle); - mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; -- mpt3sas_base_put_smid_hi_priority(ioc, smid); -+ mpt3sas_base_put_smid_hi_priority(ioc, smid, 0); - mpt3sas_trigger_master(ioc, MASTER_TRIGGER_DEVICE_REMOVAL); - - out: -@@ -3332,7 +3338,7 @@ _scsih_tm_tr_volume_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) - mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; - mpi_request->DevHandle = cpu_to_le16(handle); - mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; -- mpt3sas_base_put_smid_hi_priority(ioc, smid); -+ mpt3sas_base_put_smid_hi_priority(ioc, smid, 0); - } - - /** -diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c -index 75514a15bea0..f57d96984ae4 100644 ---- a/drivers/scsi/qla2xxx/qla_target.c -+++ b/drivers/scsi/qla2xxx/qla_target.c -@@ -1578,7 +1578,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd) - qlt_send_notify_ack(vha, &mcmd->orig_iocb.imm_ntfy, - 0, 0, 0, 0, 0, 0); - else { -- if (mcmd->se_cmd.se_tmr_req->function == TMR_ABORT_TASK) -+ if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX) - qlt_24xx_send_abts_resp(vha, &mcmd->orig_iocb.abts, - mcmd->fc_tm_rsp, false); - else -diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h -index 9096d311e45d..c2d9b793759d 100644 ---- a/drivers/staging/lustre/lustre/llite/llite_internal.h -+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h -@@ -631,8 +631,6 @@ struct ll_file_data { - - struct lov_stripe_md; - --extern spinlock_t inode_lock; -- - extern struct dentry *llite_root; - extern struct kset *llite_kset; - -diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c -index 29cfc57d496e..e4110d6de0b5 100644 ---- a/drivers/vhost/scsi.c -+++ b/drivers/vhost/scsi.c -@@ -88,7 +88,7 @@ struct vhost_scsi_cmd { - struct scatterlist *tvc_prot_sgl; - struct page **tvc_upages; - /* Pointer to response header iovec */ -- struct iovec *tvc_resp_iov; -+ struct iovec tvc_resp_iov; - /* Pointer to vhost_scsi for our device */ - struct vhost_scsi *tvc_vhost; - /* Pointer to vhost_virtqueue for the cmd */ -@@ -557,7 +557,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) - memcpy(v_rsp.sense, cmd->tvc_sense_buf, - se_cmd->scsi_sense_length); - -- iov_iter_init(&iov_iter, READ, cmd->tvc_resp_iov, -+ iov_iter_init(&iov_iter, READ, &cmd->tvc_resp_iov, - cmd->tvc_in_iovs, sizeof(v_rsp)); - ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); - if (likely(ret == sizeof(v_rsp))) { -@@ -1054,7 +1054,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) - } - cmd->tvc_vhost = vs; - cmd->tvc_vq = vq; -- cmd->tvc_resp_iov = &vq->iov[out]; -+ cmd->tvc_resp_iov = vq->iov[out]; - cmd->tvc_in_iovs = in; - - pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", -diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c -index 5e5db3687e34..353f4bae658c 100644 ---- a/fs/btrfs/file.c -+++ b/fs/btrfs/file.c -@@ -1526,27 +1526,24 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, - - reserve_bytes = num_pages << PAGE_CACHE_SHIFT; - -- if (BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | -- BTRFS_INODE_PREALLOC)) { -- ret = check_can_nocow(inode, pos, &write_bytes); -- if (ret < 0) -- break; -- if (ret > 0) { -- /* -- * For nodata cow case, no need to reserve -- * data space. -- */ -- only_release_metadata = true; -- /* -- * our prealloc extent may be smaller than -- * write_bytes, so scale down. -- */ -- num_pages = DIV_ROUND_UP(write_bytes + offset, -- PAGE_CACHE_SIZE); -- reserve_bytes = num_pages << PAGE_CACHE_SHIFT; -- goto reserve_metadata; -- } -+ if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | -+ BTRFS_INODE_PREALLOC)) && -+ check_can_nocow(inode, pos, &write_bytes) > 0) { -+ /* -+ * For nodata cow case, no need to reserve -+ * data space. -+ */ -+ only_release_metadata = true; -+ /* -+ * our prealloc extent may be smaller than -+ * write_bytes, so scale down. -+ */ -+ num_pages = DIV_ROUND_UP(write_bytes + offset, -+ PAGE_CACHE_SIZE); -+ reserve_bytes = num_pages << PAGE_CACHE_SHIFT; -+ goto reserve_metadata; - } -+ - ret = btrfs_check_data_free_space(inode, pos, write_bytes); - if (ret < 0) - break; -diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c -index 11309683d65f..27794b137b24 100644 ---- a/fs/ecryptfs/file.c -+++ b/fs/ecryptfs/file.c -@@ -112,7 +112,6 @@ static int ecryptfs_readdir(struct file *file, struct dir_context *ctx) - .sb = inode->i_sb, - }; - lower_file = ecryptfs_file_to_lower(file); -- lower_file->f_pos = ctx->pos; - rc = iterate_dir(lower_file, &buf.ctx); - ctx->pos = buf.ctx.pos; - if (rc < 0) -@@ -236,14 +235,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file) - } - ecryptfs_set_file_lower( - file, ecryptfs_inode_to_private(inode)->lower_file); -- if (d_is_dir(ecryptfs_dentry)) { -- ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); -- mutex_lock(&crypt_stat->cs_mutex); -- crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); -- mutex_unlock(&crypt_stat->cs_mutex); -- rc = 0; -- goto out; -- } - rc = read_or_initialize_metadata(ecryptfs_dentry); - if (rc) - goto out_put; -@@ -260,6 +251,45 @@ out: - return rc; - } - -+/** -+ * ecryptfs_dir_open -+ * @inode: inode speciying file to open -+ * @file: Structure to return filled in -+ * -+ * Opens the file specified by inode. -+ * -+ * Returns zero on success; non-zero otherwise -+ */ -+static int ecryptfs_dir_open(struct inode *inode, struct file *file) -+{ -+ struct dentry *ecryptfs_dentry = file->f_path.dentry; -+ /* Private value of ecryptfs_dentry allocated in -+ * ecryptfs_lookup() */ -+ struct ecryptfs_file_info *file_info; -+ struct file *lower_file; -+ -+ /* Released in ecryptfs_release or end of function if failure */ -+ file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL); -+ ecryptfs_set_file_private(file, file_info); -+ if (unlikely(!file_info)) { -+ ecryptfs_printk(KERN_ERR, -+ "Error attempting to allocate memory\n"); -+ return -ENOMEM; -+ } -+ lower_file = dentry_open(ecryptfs_dentry_to_lower_path(ecryptfs_dentry), -+ file->f_flags, current_cred()); -+ if (IS_ERR(lower_file)) { -+ printk(KERN_ERR "%s: Error attempting to initialize " -+ "the lower file for the dentry with name " -+ "[%pd]; rc = [%ld]\n", __func__, -+ ecryptfs_dentry, PTR_ERR(lower_file)); -+ kmem_cache_free(ecryptfs_file_info_cache, file_info); -+ return PTR_ERR(lower_file); -+ } -+ ecryptfs_set_file_lower(file, lower_file); -+ return 0; -+} -+ - static int ecryptfs_flush(struct file *file, fl_owner_t td) - { - struct file *lower_file = ecryptfs_file_to_lower(file); -@@ -280,6 +310,19 @@ static int ecryptfs_release(struct inode *inode, struct file *file) - return 0; - } - -+static int ecryptfs_dir_release(struct inode *inode, struct file *file) -+{ -+ fput(ecryptfs_file_to_lower(file)); -+ kmem_cache_free(ecryptfs_file_info_cache, -+ ecryptfs_file_to_private(file)); -+ return 0; -+} -+ -+static loff_t ecryptfs_dir_llseek(struct file *file, loff_t offset, int whence) -+{ -+ return vfs_llseek(ecryptfs_file_to_lower(file), offset, whence); -+} -+ - static int - ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync) - { -@@ -359,20 +402,16 @@ const struct file_operations ecryptfs_dir_fops = { - #ifdef CONFIG_COMPAT - .compat_ioctl = ecryptfs_compat_ioctl, - #endif -- .open = ecryptfs_open, -- .flush = ecryptfs_flush, -- .release = ecryptfs_release, -+ .open = ecryptfs_dir_open, -+ .release = ecryptfs_dir_release, - .fsync = ecryptfs_fsync, -- .fasync = ecryptfs_fasync, -- .splice_read = generic_file_splice_read, -- .llseek = default_llseek, -+ .llseek = ecryptfs_dir_llseek, - }; - - const struct file_operations ecryptfs_main_fops = { - .llseek = generic_file_llseek, - .read_iter = ecryptfs_read_update_atime, - .write_iter = generic_file_write_iter, -- .iterate = ecryptfs_readdir, - .unlocked_ioctl = ecryptfs_unlocked_ioctl, - #ifdef CONFIG_COMPAT - .compat_ioctl = ecryptfs_compat_ioctl, -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 9a5ad0f0d3ed..28702932a908 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -51,25 +51,31 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw, - struct ext4_inode_info *ei) - { - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); -- __u16 csum_lo; -- __u16 csum_hi = 0; - __u32 csum; -+ __u16 dummy_csum = 0; -+ int offset = offsetof(struct ext4_inode, i_checksum_lo); -+ unsigned int csum_size = sizeof(dummy_csum); - -- csum_lo = le16_to_cpu(raw->i_checksum_lo); -- raw->i_checksum_lo = 0; -- if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE && -- EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) { -- csum_hi = le16_to_cpu(raw->i_checksum_hi); -- raw->i_checksum_hi = 0; -- } -+ csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw, offset); -+ csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, csum_size); -+ offset += csum_size; -+ csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset, -+ EXT4_GOOD_OLD_INODE_SIZE - offset); - -- csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw, -- EXT4_INODE_SIZE(inode->i_sb)); -- -- raw->i_checksum_lo = cpu_to_le16(csum_lo); -- if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE && -- EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) -- raw->i_checksum_hi = cpu_to_le16(csum_hi); -+ if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { -+ offset = offsetof(struct ext4_inode, i_checksum_hi); -+ csum = ext4_chksum(sbi, csum, (__u8 *)raw + -+ EXT4_GOOD_OLD_INODE_SIZE, -+ offset - EXT4_GOOD_OLD_INODE_SIZE); -+ if (EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) { -+ csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, -+ csum_size); -+ offset += csum_size; -+ csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset, -+ EXT4_INODE_SIZE(inode->i_sb) - -+ offset); -+ } -+ } - - return csum; - } -@@ -5186,8 +5192,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) - sbi->s_want_extra_isize, - iloc, handle); - if (ret) { -- ext4_set_inode_state(inode, -- EXT4_STATE_NO_EXPAND); - if (mnt_count != - le16_to_cpu(sbi->s_es->s_mnt_count)) { - ext4_warning(inode->i_sb, -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index 91bf36f22dbf..38eb0c8e43b9 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -420,15 +420,14 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent, - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); - struct ext4_inode_info *ei = EXT4_I(inode); - __u32 csum; -- __le32 save_csum; - int size; -+ __u32 dummy_csum = 0; -+ int offset = offsetof(struct dx_tail, dt_checksum); - - size = count_offset + (count * sizeof(struct dx_entry)); -- save_csum = t->dt_checksum; -- t->dt_checksum = 0; - csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size); -- csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail)); -- t->dt_checksum = save_csum; -+ csum = ext4_chksum(sbi, csum, (__u8 *)t, offset); -+ csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum)); - - return cpu_to_le32(csum); - } -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index c542ebcf7a92..5bab28caa9d4 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -2030,23 +2030,25 @@ failed: - static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, - struct ext4_group_desc *gdp) - { -- int offset; -+ int offset = offsetof(struct ext4_group_desc, bg_checksum); - __u16 crc = 0; - __le32 le_group = cpu_to_le32(block_group); - struct ext4_sb_info *sbi = EXT4_SB(sb); - - if (ext4_has_metadata_csum(sbi->s_sb)) { - /* Use new metadata_csum algorithm */ -- __le16 save_csum; - __u32 csum32; -+ __u16 dummy_csum = 0; - -- save_csum = gdp->bg_checksum; -- gdp->bg_checksum = 0; - csum32 = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&le_group, - sizeof(le_group)); -- csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp, -- sbi->s_desc_size); -- gdp->bg_checksum = save_csum; -+ csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp, offset); -+ csum32 = ext4_chksum(sbi, csum32, (__u8 *)&dummy_csum, -+ sizeof(dummy_csum)); -+ offset += sizeof(dummy_csum); -+ if (offset < sbi->s_desc_size) -+ csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp + offset, -+ sbi->s_desc_size - offset); - - crc = csum32 & 0xFFFF; - goto out; -@@ -2056,8 +2058,6 @@ static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, - if (!ext4_has_feature_gdt_csum(sb)) - return 0; - -- offset = offsetof(struct ext4_group_desc, bg_checksum); -- - crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid)); - crc = crc16(crc, (__u8 *)&le_group, sizeof(le_group)); - crc = crc16(crc, (__u8 *)gdp, offset); -@@ -2093,6 +2093,7 @@ void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group, - - /* Called at mount-time, super-block is locked */ - static int ext4_check_descriptors(struct super_block *sb, -+ ext4_fsblk_t sb_block, - ext4_group_t *first_not_zeroed) - { - struct ext4_sb_info *sbi = EXT4_SB(sb); -@@ -2123,6 +2124,11 @@ static int ext4_check_descriptors(struct super_block *sb, - grp = i; - - block_bitmap = ext4_block_bitmap(sb, gdp); -+ if (block_bitmap == sb_block) { -+ ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " -+ "Block bitmap for group %u overlaps " -+ "superblock", i); -+ } - if (block_bitmap < first_block || block_bitmap > last_block) { - ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " - "Block bitmap for group %u not in group " -@@ -2130,6 +2136,11 @@ static int ext4_check_descriptors(struct super_block *sb, - return 0; - } - inode_bitmap = ext4_inode_bitmap(sb, gdp); -+ if (inode_bitmap == sb_block) { -+ ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " -+ "Inode bitmap for group %u overlaps " -+ "superblock", i); -+ } - if (inode_bitmap < first_block || inode_bitmap > last_block) { - ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " - "Inode bitmap for group %u not in group " -@@ -2137,6 +2148,11 @@ static int ext4_check_descriptors(struct super_block *sb, - return 0; - } - inode_table = ext4_inode_table(sb, gdp); -+ if (inode_table == sb_block) { -+ ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " -+ "Inode table for group %u overlaps " -+ "superblock", i); -+ } - if (inode_table < first_block || - inode_table + sbi->s_itb_per_group - 1 > last_block) { - ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " -@@ -3640,7 +3656,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) - goto failed_mount2; - } - } -- if (!ext4_check_descriptors(sb, &first_not_zeroed)) { -+ if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { - ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); - ret = -EFSCORRUPTED; - goto failed_mount2; -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 6b6b3e751f8c..263002f0389d 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -123,17 +123,18 @@ static __le32 ext4_xattr_block_csum(struct inode *inode, - { - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); - __u32 csum; -- __le32 save_csum; - __le64 dsk_block_nr = cpu_to_le64(block_nr); -+ __u32 dummy_csum = 0; -+ int offset = offsetof(struct ext4_xattr_header, h_checksum); - -- save_csum = hdr->h_checksum; -- hdr->h_checksum = 0; - csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&dsk_block_nr, - sizeof(dsk_block_nr)); -- csum = ext4_chksum(sbi, csum, (__u8 *)hdr, -- EXT4_BLOCK_SIZE(inode->i_sb)); -+ csum = ext4_chksum(sbi, csum, (__u8 *)hdr, offset); -+ csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum)); -+ offset += sizeof(dummy_csum); -+ csum = ext4_chksum(sbi, csum, (__u8 *)hdr + offset, -+ EXT4_BLOCK_SIZE(inode->i_sb) - offset); - -- hdr->h_checksum = save_csum; - return cpu_to_le32(csum); - } - -@@ -1264,15 +1265,19 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - size_t min_offs, free; - int total_ino; - void *base, *start, *end; -- int extra_isize = 0, error = 0, tried_min_extra_isize = 0; -+ int error = 0, tried_min_extra_isize = 0; - int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize); -+ int isize_diff; /* How much do we need to grow i_extra_isize */ - - down_write(&EXT4_I(inode)->xattr_sem); -+ /* -+ * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty -+ */ -+ ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); - retry: -- if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { -- up_write(&EXT4_I(inode)->xattr_sem); -- return 0; -- } -+ isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize; -+ if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) -+ goto out; - - header = IHDR(inode, raw_inode); - entry = IFIRST(header); -@@ -1289,7 +1294,7 @@ retry: - total_ino = sizeof(struct ext4_xattr_ibody_header); - - free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); -- if (free >= new_extra_isize) { -+ if (free >= isize_diff) { - entry = IFIRST(header); - ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - - new_extra_isize, (void *)raw_inode + -@@ -1297,8 +1302,7 @@ retry: - (void *)header, total_ino, - inode->i_sb->s_blocksize); - EXT4_I(inode)->i_extra_isize = new_extra_isize; -- error = 0; -- goto cleanup; -+ goto out; - } - - /* -@@ -1321,7 +1325,7 @@ retry: - end = bh->b_data + bh->b_size; - min_offs = end - base; - free = ext4_xattr_free_space(first, &min_offs, base, NULL); -- if (free < new_extra_isize) { -+ if (free < isize_diff) { - if (!tried_min_extra_isize && s_min_extra_isize) { - tried_min_extra_isize++; - new_extra_isize = s_min_extra_isize; -@@ -1335,7 +1339,7 @@ retry: - free = inode->i_sb->s_blocksize; - } - -- while (new_extra_isize > 0) { -+ while (isize_diff > 0) { - size_t offs, size, entry_size; - struct ext4_xattr_entry *small_entry = NULL; - struct ext4_xattr_info i = { -@@ -1366,7 +1370,7 @@ retry: - EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + - EXT4_XATTR_LEN(last->e_name_len); - if (total_size <= free && total_size < min_total_size) { -- if (total_size < new_extra_isize) { -+ if (total_size < isize_diff) { - small_entry = last; - } else { - entry = last; -@@ -1421,22 +1425,22 @@ retry: - error = ext4_xattr_ibody_set(handle, inode, &i, is); - if (error) - goto cleanup; -+ total_ino -= entry_size; - - entry = IFIRST(header); -- if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) -- shift_bytes = new_extra_isize; -+ if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) -+ shift_bytes = isize_diff; - else -- shift_bytes = entry_size + size; -+ shift_bytes = entry_size + EXT4_XATTR_SIZE(size); - /* Adjust the offsets and shift the remaining entries ahead */ -- ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - -- shift_bytes, (void *)raw_inode + -- EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes, -- (void *)header, total_ino - entry_size, -- inode->i_sb->s_blocksize); -+ ext4_xattr_shift_entries(entry, -shift_bytes, -+ (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + -+ EXT4_I(inode)->i_extra_isize + shift_bytes, -+ (void *)header, total_ino, inode->i_sb->s_blocksize); - -- extra_isize += shift_bytes; -- new_extra_isize -= shift_bytes; -- EXT4_I(inode)->i_extra_isize = extra_isize; -+ isize_diff -= shift_bytes; -+ EXT4_I(inode)->i_extra_isize += shift_bytes; -+ header = IHDR(inode, raw_inode); - - i.name = b_entry_name; - i.value = buffer; -@@ -1458,6 +1462,8 @@ retry: - kfree(bs); - } - brelse(bh); -+out: -+ ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); - up_write(&EXT4_I(inode)->xattr_sem); - return 0; - -@@ -1469,6 +1475,10 @@ cleanup: - kfree(is); - kfree(bs); - brelse(bh); -+ /* -+ * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode -+ * size expansion failed. -+ */ - up_write(&EXT4_I(inode)->xattr_sem); - return error; - } -diff --git a/fs/namei.c b/fs/namei.c -index 209ca7737cb2..0b0acba72a71 100644 ---- a/fs/namei.c -+++ b/fs/namei.c -@@ -887,6 +887,7 @@ static inline int may_follow_link(struct nameidata *nd) - { - const struct inode *inode; - const struct inode *parent; -+ kuid_t puid; - - if (!sysctl_protected_symlinks) - return 0; -@@ -902,7 +903,8 @@ static inline int may_follow_link(struct nameidata *nd) - return 0; - - /* Allowed if parent directory and link owner match. */ -- if (uid_eq(parent->i_uid, inode->i_uid)) -+ puid = parent->i_uid; -+ if (uid_valid(puid) && uid_eq(puid, inode->i_uid)) - return 0; - - if (nd->flags & LOOKUP_RCU) -diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c -index eff6319d5037..9e52609cd683 100644 ---- a/fs/overlayfs/copy_up.c -+++ b/fs/overlayfs/copy_up.c -@@ -48,6 +48,8 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) - } - - for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { -+ if (ovl_is_private_xattr(name)) -+ continue; - retry: - size = vfs_getxattr(old, name, value, value_size); - if (size == -ERANGE) -diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c -index 4f729ffff75d..220b04f04523 100644 ---- a/fs/overlayfs/inode.c -+++ b/fs/overlayfs/inode.c -@@ -219,7 +219,7 @@ static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz) - } - - --static bool ovl_is_private_xattr(const char *name) -+bool ovl_is_private_xattr(const char *name) - { - return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0; - } -@@ -277,7 +277,8 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) - struct path realpath; - enum ovl_path_type type = ovl_path_real(dentry, &realpath); - ssize_t res; -- int off; -+ size_t len; -+ char *s; - - res = vfs_listxattr(realpath.dentry, list, size); - if (res <= 0 || size == 0) -@@ -287,17 +288,19 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) - return res; - - /* filter out private xattrs */ -- for (off = 0; off < res;) { -- char *s = list + off; -- size_t slen = strlen(s) + 1; -+ for (s = list, len = res; len;) { -+ size_t slen = strnlen(s, len) + 1; - -- BUG_ON(off + slen > res); -+ /* underlying fs providing us with an broken xattr list? */ -+ if (WARN_ON(slen > len)) -+ return -EIO; - -+ len -= slen; - if (ovl_is_private_xattr(s)) { - res -= slen; -- memmove(s, s + slen, res - off); -+ memmove(s, s + slen, len); - } else { -- off += slen; -+ s += slen; - } - } - -diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h -index 735e1d49b301..c319d5eaabcf 100644 ---- a/fs/overlayfs/overlayfs.h -+++ b/fs/overlayfs/overlayfs.h -@@ -174,6 +174,7 @@ ssize_t ovl_getxattr(struct dentry *dentry, const char *name, - ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); - int ovl_removexattr(struct dentry *dentry, const char *name); - struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags); -+bool ovl_is_private_xattr(const char *name); - - struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, - struct ovl_entry *oe); -diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c -index 70a7bbe199d0..d70208c0de84 100644 ---- a/fs/overlayfs/super.c -+++ b/fs/overlayfs/super.c -@@ -763,6 +763,10 @@ retry: - struct kstat stat = { - .mode = S_IFDIR | 0, - }; -+ struct iattr attr = { -+ .ia_valid = ATTR_MODE, -+ .ia_mode = stat.mode, -+ }; - - if (work->d_inode) { - err = -EEXIST; -@@ -778,6 +782,21 @@ retry: - err = ovl_create_real(dir, work, &stat, NULL, NULL, true); - if (err) - goto out_dput; -+ -+ err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT); -+ if (err && err != -ENODATA && err != -EOPNOTSUPP) -+ goto out_dput; -+ -+ err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS); -+ if (err && err != -ENODATA && err != -EOPNOTSUPP) -+ goto out_dput; -+ -+ /* Clear any inherited mode bits */ -+ inode_lock(work->d_inode); -+ err = notify_change(work, &attr, NULL); -+ inode_unlock(work->d_inode); -+ if (err) -+ goto out_dput; - } - out_unlock: - mutex_unlock(&dir->i_mutex); -diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c -index f6478301db00..d598b9c809c1 100644 ---- a/fs/proc/task_mmu.c -+++ b/fs/proc/task_mmu.c -@@ -248,23 +248,29 @@ static int do_maps_open(struct inode *inode, struct file *file, - sizeof(struct proc_maps_private)); - } - --static pid_t pid_of_stack(struct proc_maps_private *priv, -- struct vm_area_struct *vma, bool is_pid) -+/* -+ * Indicate if the VMA is a stack for the given task; for -+ * /proc/PID/maps that is the stack of the main task. -+ */ -+static int is_stack(struct proc_maps_private *priv, -+ struct vm_area_struct *vma, int is_pid) - { -- struct inode *inode = priv->inode; -- struct task_struct *task; -- pid_t ret = 0; -+ int stack = 0; -+ -+ if (is_pid) { -+ stack = vma->vm_start <= vma->vm_mm->start_stack && -+ vma->vm_end >= vma->vm_mm->start_stack; -+ } else { -+ struct inode *inode = priv->inode; -+ struct task_struct *task; - -- rcu_read_lock(); -- task = pid_task(proc_pid(inode), PIDTYPE_PID); -- if (task) { -- task = task_of_stack(task, vma, is_pid); -+ rcu_read_lock(); -+ task = pid_task(proc_pid(inode), PIDTYPE_PID); - if (task) -- ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info); -+ stack = vma_is_stack_for_task(vma, task); -+ rcu_read_unlock(); - } -- rcu_read_unlock(); -- -- return ret; -+ return stack; - } - - static void -@@ -324,8 +330,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) - - name = arch_vma_name(vma); - if (!name) { -- pid_t tid; -- - if (!mm) { - name = "[vdso]"; - goto done; -@@ -337,21 +341,8 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) - goto done; - } - -- tid = pid_of_stack(priv, vma, is_pid); -- if (tid != 0) { -- /* -- * Thread stack in /proc/PID/task/TID/maps or -- * the main process stack. -- */ -- if (!is_pid || (vma->vm_start <= mm->start_stack && -- vma->vm_end >= mm->start_stack)) { -- name = "[stack]"; -- } else { -- /* Thread stack in /proc/PID/maps */ -- seq_pad(m, ' '); -- seq_printf(m, "[stack:%d]", tid); -- } -- } -+ if (is_stack(priv, vma, is_pid)) -+ name = "[stack]"; - } - - done: -@@ -1566,19 +1557,8 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) - seq_file_path(m, file, "\n\t= "); - } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { - seq_puts(m, " heap"); -- } else { -- pid_t tid = pid_of_stack(proc_priv, vma, is_pid); -- if (tid != 0) { -- /* -- * Thread stack in /proc/PID/task/TID/maps or -- * the main process stack. -- */ -- if (!is_pid || (vma->vm_start <= mm->start_stack && -- vma->vm_end >= mm->start_stack)) -- seq_puts(m, " stack"); -- else -- seq_printf(m, " stack:%d", tid); -- } -+ } else if (is_stack(proc_priv, vma, is_pid)) { -+ seq_puts(m, " stack"); - } - - if (is_vm_hugetlb_page(vma)) -diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c -index e0d64c92e4f6..faacb0c0d857 100644 ---- a/fs/proc/task_nommu.c -+++ b/fs/proc/task_nommu.c -@@ -123,23 +123,26 @@ unsigned long task_statm(struct mm_struct *mm, - return size; - } - --static pid_t pid_of_stack(struct proc_maps_private *priv, -- struct vm_area_struct *vma, bool is_pid) -+static int is_stack(struct proc_maps_private *priv, -+ struct vm_area_struct *vma, int is_pid) - { -- struct inode *inode = priv->inode; -- struct task_struct *task; -- pid_t ret = 0; -- -- rcu_read_lock(); -- task = pid_task(proc_pid(inode), PIDTYPE_PID); -- if (task) { -- task = task_of_stack(task, vma, is_pid); -+ struct mm_struct *mm = vma->vm_mm; -+ int stack = 0; -+ -+ if (is_pid) { -+ stack = vma->vm_start <= mm->start_stack && -+ vma->vm_end >= mm->start_stack; -+ } else { -+ struct inode *inode = priv->inode; -+ struct task_struct *task; -+ -+ rcu_read_lock(); -+ task = pid_task(proc_pid(inode), PIDTYPE_PID); - if (task) -- ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info); -+ stack = vma_is_stack_for_task(vma, task); -+ rcu_read_unlock(); - } -- rcu_read_unlock(); -- -- return ret; -+ return stack; - } - - /* -@@ -181,21 +184,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, - if (file) { - seq_pad(m, ' '); - seq_file_path(m, file, ""); -- } else if (mm) { -- pid_t tid = pid_of_stack(priv, vma, is_pid); -- -- if (tid != 0) { -- seq_pad(m, ' '); -- /* -- * Thread stack in /proc/PID/task/TID/maps or -- * the main process stack. -- */ -- if (!is_pid || (vma->vm_start <= mm->start_stack && -- vma->vm_end >= mm->start_stack)) -- seq_printf(m, "[stack]"); -- else -- seq_printf(m, "[stack:%d]", tid); -- } -+ } else if (mm && is_stack(priv, vma, is_pid)) { -+ seq_pad(m, ' '); -+ seq_printf(m, "[stack]"); - } - - seq_putc(m, '\n'); -diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c -index b45345d701e7..51157da3f76e 100644 ---- a/fs/ubifs/tnc_commit.c -+++ b/fs/ubifs/tnc_commit.c -@@ -370,7 +370,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) - - p = c->gap_lebs; - do { -- ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs); -+ ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs); - written = layout_leb_in_gaps(c, p); - if (written < 0) { - err = written; -diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c -index 8a53eaa349f4..7088be6afb3c 100644 ---- a/fs/xfs/libxfs/xfs_sb.c -+++ b/fs/xfs/libxfs/xfs_sb.c -@@ -581,7 +581,8 @@ xfs_sb_verify( - * Only check the in progress field for the primary superblock as - * mkfs.xfs doesn't clear it from secondary superblocks. - */ -- return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR, -+ return xfs_mount_validate_sb(mp, &sb, -+ bp->b_maps[0].bm_bn == XFS_SB_DADDR, - check_version); - } - -diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h -index 17c445612e01..2cdc723d750f 100644 ---- a/include/drm/i915_pciids.h -+++ b/include/drm/i915_pciids.h -@@ -277,7 +277,9 @@ - INTEL_VGA_DEVICE(0x191D, info) /* WKS GT2 */ - - #define INTEL_SKL_GT3_IDS(info) \ -+ INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \ - INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \ -+ INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \ - INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \ - INTEL_VGA_DEVICE(0x192A, info) /* SRV GT3 */ \ - -@@ -289,6 +291,8 @@ - #define INTEL_BXT_IDS(info) \ - INTEL_VGA_DEVICE(0x0A84, info), \ - INTEL_VGA_DEVICE(0x1A84, info), \ -- INTEL_VGA_DEVICE(0x5A84, info) -+ INTEL_VGA_DEVICE(0x1A85, info), \ -+ INTEL_VGA_DEVICE(0x5A84, info), /* APL HD Graphics 505 */ \ -+ INTEL_VGA_DEVICE(0x5A85, info) /* APL HD Graphics 500 */ - - #endif /* _I915_PCIIDS_H */ -diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h -index 168755791ec8..fe14382f9664 100644 ---- a/include/linux/blkdev.h -+++ b/include/linux/blkdev.h -@@ -890,7 +890,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq) - { - struct request_queue *q = rq->q; - -- if (unlikely(rq->cmd_type == REQ_TYPE_BLOCK_PC)) -+ if (unlikely(rq->cmd_type != REQ_TYPE_FS)) - return q->limits.max_hw_sectors; - - if (!q->limits.chunk_sectors || (rq->cmd_flags & REQ_DISCARD)) -diff --git a/include/linux/capability.h b/include/linux/capability.h -index af9f0b9e80e6..5f8249d378a2 100644 ---- a/include/linux/capability.h -+++ b/include/linux/capability.h -@@ -214,6 +214,7 @@ extern bool has_ns_capability_noaudit(struct task_struct *t, - struct user_namespace *ns, int cap); - extern bool capable(int cap); - extern bool ns_capable(struct user_namespace *ns, int cap); -+extern bool ns_capable_noaudit(struct user_namespace *ns, int cap); - #else - static inline bool has_capability(struct task_struct *t, int cap) - { -@@ -241,6 +242,10 @@ static inline bool ns_capable(struct user_namespace *ns, int cap) - { - return true; - } -+static inline bool ns_capable_noaudit(struct user_namespace *ns, int cap) -+{ -+ return true; -+} - #endif /* CONFIG_MULTIUSER */ - extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap); - extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap); -diff --git a/include/linux/fs.h b/include/linux/fs.h -index ab3d8d9bb3ef..0166582c4d78 100644 ---- a/include/linux/fs.h -+++ b/include/linux/fs.h -@@ -710,6 +710,31 @@ enum inode_i_mutex_lock_class - I_MUTEX_PARENT2, - }; - -+static inline void inode_lock(struct inode *inode) -+{ -+ mutex_lock(&inode->i_mutex); -+} -+ -+static inline void inode_unlock(struct inode *inode) -+{ -+ mutex_unlock(&inode->i_mutex); -+} -+ -+static inline int inode_trylock(struct inode *inode) -+{ -+ return mutex_trylock(&inode->i_mutex); -+} -+ -+static inline int inode_is_locked(struct inode *inode) -+{ -+ return mutex_is_locked(&inode->i_mutex); -+} -+ -+static inline void inode_lock_nested(struct inode *inode, unsigned subclass) -+{ -+ mutex_lock_nested(&inode->i_mutex, subclass); -+} -+ - void lock_two_nondirectories(struct inode *, struct inode*); - void unlock_two_nondirectories(struct inode *, struct inode*); - -@@ -3029,8 +3054,8 @@ static inline bool dir_emit_dots(struct file *file, struct dir_context *ctx) - } - static inline bool dir_relax(struct inode *inode) - { -- mutex_unlock(&inode->i_mutex); -- mutex_lock(&inode->i_mutex); -+ inode_unlock(inode); -+ inode_lock(inode); - return !IS_DEADDIR(inode); - } - -diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h -index 034117b3be5f..f09648d14694 100644 ---- a/include/linux/lightnvm.h -+++ b/include/linux/lightnvm.h -@@ -58,8 +58,9 @@ enum { - /* Block Types */ - NVM_BLK_T_FREE = 0x0, - NVM_BLK_T_BAD = 0x1, -- NVM_BLK_T_DEV = 0x2, -- NVM_BLK_T_HOST = 0x4, -+ NVM_BLK_T_GRWN_BAD = 0x2, -+ NVM_BLK_T_DEV = 0x4, -+ NVM_BLK_T_HOST = 0x8, - }; - - struct nvm_id_group { -diff --git a/include/linux/mm.h b/include/linux/mm.h -index f24df9c0b9df..8a761248d01e 100644 ---- a/include/linux/mm.h -+++ b/include/linux/mm.h -@@ -1311,8 +1311,7 @@ static inline int stack_guard_page_end(struct vm_area_struct *vma, - !vma_growsup(vma->vm_next, addr); - } - --extern struct task_struct *task_of_stack(struct task_struct *task, -- struct vm_area_struct *vma, bool in_group); -+int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t); - - extern unsigned long move_page_tables(struct vm_area_struct *vma, - unsigned long old_addr, struct vm_area_struct *new_vma, -diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h -index f9828a48f16a..6cdd50f7f52d 100644 ---- a/include/linux/perf_event.h -+++ b/include/linux/perf_event.h -@@ -121,6 +121,7 @@ struct hw_perf_event { - struct { /* intel_cqm */ - int cqm_state; - u32 cqm_rmid; -+ int is_group_event; - struct list_head cqm_events_entry; - struct list_head cqm_groups_entry; - struct list_head cqm_group_entry; -diff --git a/include/linux/time.h b/include/linux/time.h -index beebe3a02d43..297f09f23896 100644 ---- a/include/linux/time.h -+++ b/include/linux/time.h -@@ -125,6 +125,32 @@ static inline bool timeval_valid(const struct timeval *tv) - - extern struct timespec timespec_trunc(struct timespec t, unsigned gran); - -+/* -+ * Validates if a timespec/timeval used to inject a time offset is valid. -+ * Offsets can be postive or negative. The value of the timeval/timespec -+ * is the sum of its fields, but *NOTE*: the field tv_usec/tv_nsec must -+ * always be non-negative. -+ */ -+static inline bool timeval_inject_offset_valid(const struct timeval *tv) -+{ -+ /* We don't check the tv_sec as it can be positive or negative */ -+ -+ /* Can't have more microseconds then a second */ -+ if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC) -+ return false; -+ return true; -+} -+ -+static inline bool timespec_inject_offset_valid(const struct timespec *ts) -+{ -+ /* We don't check the tv_sec as it can be positive or negative */ -+ -+ /* Can't have more nanoseconds then a second */ -+ if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC) -+ return false; -+ return true; -+} -+ - #define CURRENT_TIME (current_kernel_time()) - #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) - -diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h -index e4c0a35d6417..e347b24ef9fb 100644 ---- a/include/uapi/linux/hyperv.h -+++ b/include/uapi/linux/hyperv.h -@@ -313,6 +313,7 @@ enum hv_kvp_exchg_pool { - #define HV_INVALIDARG 0x80070057 - #define HV_GUID_NOTFOUND 0x80041002 - #define HV_ERROR_ALREADY_EXISTS 0x80070050 -+#define HV_ERROR_DISK_FULL 0x80070070 - - #define ADDR_FAMILY_NONE 0x00 - #define ADDR_FAMILY_IPV4 0x01 -diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h -index a0e87d16b726..421d27413731 100644 ---- a/include/uapi/linux/videodev2.h -+++ b/include/uapi/linux/videodev2.h -@@ -621,6 +621,9 @@ struct v4l2_pix_format { - #define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */ - #define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */ - #define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */ -+#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */ -+#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */ -+#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */ - - /* SDR formats - used only for Software Defined Radio devices */ - #define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ -diff --git a/include/uapi/scsi/cxlflash_ioctl.h b/include/uapi/scsi/cxlflash_ioctl.h -index 831351b2e660..2302f3ce5f86 100644 ---- a/include/uapi/scsi/cxlflash_ioctl.h -+++ b/include/uapi/scsi/cxlflash_ioctl.h -@@ -31,6 +31,16 @@ struct dk_cxlflash_hdr { - }; - - /* -+ * Return flag definitions available to all ioctls -+ * -+ * Similar to the input flags, these are grown from the bottom-up with the -+ * intention that ioctl-specific return flag definitions would grow from the -+ * top-down, allowing the two sets to co-exist. While not required/enforced -+ * at this time, this provides future flexibility. -+ */ -+#define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL -+ -+/* - * Notes: - * ----- - * The 'context_id' field of all ioctl structures contains the context -diff --git a/kernel/capability.c b/kernel/capability.c -index 45432b54d5c6..00411c82dac5 100644 ---- a/kernel/capability.c -+++ b/kernel/capability.c -@@ -361,6 +361,24 @@ bool has_capability_noaudit(struct task_struct *t, int cap) - return has_ns_capability_noaudit(t, &init_user_ns, cap); - } - -+static bool ns_capable_common(struct user_namespace *ns, int cap, bool audit) -+{ -+ int capable; -+ -+ if (unlikely(!cap_valid(cap))) { -+ pr_crit("capable() called with invalid cap=%u\n", cap); -+ BUG(); -+ } -+ -+ capable = audit ? security_capable(current_cred(), ns, cap) : -+ security_capable_noaudit(current_cred(), ns, cap); -+ if (capable == 0) { -+ current->flags |= PF_SUPERPRIV; -+ return true; -+ } -+ return false; -+} -+ - /** - * ns_capable - Determine if the current task has a superior capability in effect - * @ns: The usernamespace we want the capability in -@@ -374,19 +392,27 @@ bool has_capability_noaudit(struct task_struct *t, int cap) - */ - bool ns_capable(struct user_namespace *ns, int cap) - { -- if (unlikely(!cap_valid(cap))) { -- pr_crit("capable() called with invalid cap=%u\n", cap); -- BUG(); -- } -- -- if (security_capable(current_cred(), ns, cap) == 0) { -- current->flags |= PF_SUPERPRIV; -- return true; -- } -- return false; -+ return ns_capable_common(ns, cap, true); - } - EXPORT_SYMBOL(ns_capable); - -+/** -+ * ns_capable_noaudit - Determine if the current task has a superior capability -+ * (unaudited) in effect -+ * @ns: The usernamespace we want the capability in -+ * @cap: The capability to be tested for -+ * -+ * Return true if the current task has the given superior capability currently -+ * available for use, false if not. -+ * -+ * This sets PF_SUPERPRIV on the task if the capability is available on the -+ * assumption that it's about to be used. -+ */ -+bool ns_capable_noaudit(struct user_namespace *ns, int cap) -+{ -+ return ns_capable_common(ns, cap, false); -+} -+EXPORT_SYMBOL(ns_capable_noaudit); - - /** - * capable - Determine if the current task has a superior capability in effect -diff --git a/kernel/cred.c b/kernel/cred.c -index 71179a09c1d6..ff8606f77d90 100644 ---- a/kernel/cred.c -+++ b/kernel/cred.c -@@ -689,6 +689,8 @@ EXPORT_SYMBOL(set_security_override_from_ctx); - */ - int set_create_files_as(struct cred *new, struct inode *inode) - { -+ if (!uid_valid(inode->i_uid) || !gid_valid(inode->i_gid)) -+ return -EINVAL; - new->fsuid = inode->i_uid; - new->fsgid = inode->i_gid; - return security_kernel_create_files_as(new, inode); -diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c -index 7dad84913abf..da0c09ff6112 100644 ---- a/kernel/events/uprobes.c -+++ b/kernel/events/uprobes.c -@@ -171,8 +171,10 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, - mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); - err = -EAGAIN; - ptep = page_check_address(page, mm, addr, &ptl, 0); -- if (!ptep) -+ if (!ptep) { -+ mem_cgroup_cancel_charge(kpage, memcg); - goto unlock; -+ } - - get_page(kpage); - page_add_new_anon_rmap(kpage, vma, addr); -@@ -199,7 +201,6 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, - - err = 0; - unlock: -- mem_cgroup_cancel_charge(kpage, memcg); - mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); - unlock_page(page); - return err; -diff --git a/kernel/fork.c b/kernel/fork.c -index 1155eac61687..c485cb156772 100644 ---- a/kernel/fork.c -+++ b/kernel/fork.c -@@ -1369,7 +1369,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, - p->real_start_time = ktime_get_boot_ns(); - p->io_context = NULL; - p->audit_context = NULL; -- threadgroup_change_begin(current); - cgroup_fork(p); - #ifdef CONFIG_NUMA - p->mempolicy = mpol_dup(p->mempolicy); -@@ -1521,6 +1520,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, - INIT_LIST_HEAD(&p->thread_group); - p->task_works = NULL; - -+ threadgroup_change_begin(current); - /* - * Ensure that the cgroup subsystem policies allow the new process to be - * forked. It should be noted the the new process's css_set can be changed -@@ -1621,6 +1621,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, - bad_fork_cancel_cgroup: - cgroup_cancel_fork(p, cgrp_ss_priv); - bad_fork_free_pid: -+ threadgroup_change_end(current); - if (pid != &init_struct_pid) - free_pid(pid); - bad_fork_cleanup_io: -@@ -1651,7 +1652,6 @@ bad_fork_cleanup_policy: - mpol_put(p->mempolicy); - bad_fork_cleanup_threadgroup_lock: - #endif -- threadgroup_change_end(current); - delayacct_tsk_free(p); - bad_fork_cleanup_count: - atomic_dec(&p->cred->user->processes); -diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index b8b516c37bf1..8f258f437ac2 100644 ---- a/kernel/sched/fair.c -+++ b/kernel/sched/fair.c -@@ -1191,8 +1191,6 @@ static void task_numa_assign(struct task_numa_env *env, - { - if (env->best_task) - put_task_struct(env->best_task); -- if (p) -- get_task_struct(p); - - env->best_task = p; - env->best_imp = imp; -@@ -1260,20 +1258,30 @@ static void task_numa_compare(struct task_numa_env *env, - long imp = env->p->numa_group ? groupimp : taskimp; - long moveimp = imp; - int dist = env->dist; -+ bool assigned = false; - - rcu_read_lock(); - - raw_spin_lock_irq(&dst_rq->lock); - cur = dst_rq->curr; - /* -- * No need to move the exiting task, and this ensures that ->curr -- * wasn't reaped and thus get_task_struct() in task_numa_assign() -- * is safe under RCU read lock. -- * Note that rcu_read_lock() itself can't protect from the final -- * put_task_struct() after the last schedule(). -+ * No need to move the exiting task or idle task. - */ - if ((cur->flags & PF_EXITING) || is_idle_task(cur)) - cur = NULL; -+ else { -+ /* -+ * The task_struct must be protected here to protect the -+ * p->numa_faults access in the task_weight since the -+ * numa_faults could already be freed in the following path: -+ * finish_task_switch() -+ * --> put_task_struct() -+ * --> __put_task_struct() -+ * --> task_numa_free() -+ */ -+ get_task_struct(cur); -+ } -+ - raw_spin_unlock_irq(&dst_rq->lock); - - /* -@@ -1357,6 +1365,7 @@ balance: - */ - if (!load_too_imbalanced(src_load, dst_load, env)) { - imp = moveimp - 1; -+ put_task_struct(cur); - cur = NULL; - goto assign; - } -@@ -1382,9 +1391,16 @@ balance: - env->dst_cpu = select_idle_sibling(env->p, env->dst_cpu); - - assign: -+ assigned = true; - task_numa_assign(env, cur, imp); - unlock: - rcu_read_unlock(); -+ /* -+ * The dst_rq->curr isn't assigned. The protection for task_struct is -+ * finished. -+ */ -+ if (cur && !assigned) -+ put_task_struct(cur); - } - - static void task_numa_find_cpu(struct task_numa_env *env, -diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c -index 1347882d131e..b98810d2f3b4 100644 ---- a/kernel/time/clocksource.c -+++ b/kernel/time/clocksource.c -@@ -323,13 +323,42 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs) - /* cs is a watchdog. */ - if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) - cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; -+ } -+ spin_unlock_irqrestore(&watchdog_lock, flags); -+} -+ -+static void clocksource_select_watchdog(bool fallback) -+{ -+ struct clocksource *cs, *old_wd; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&watchdog_lock, flags); -+ /* save current watchdog */ -+ old_wd = watchdog; -+ if (fallback) -+ watchdog = NULL; -+ -+ list_for_each_entry(cs, &clocksource_list, list) { -+ /* cs is a clocksource to be watched. */ -+ if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) -+ continue; -+ -+ /* Skip current if we were requested for a fallback. */ -+ if (fallback && cs == old_wd) -+ continue; -+ - /* Pick the best watchdog. */ -- if (!watchdog || cs->rating > watchdog->rating) { -+ if (!watchdog || cs->rating > watchdog->rating) - watchdog = cs; -- /* Reset watchdog cycles */ -- clocksource_reset_watchdog(); -- } - } -+ /* If we failed to find a fallback restore the old one. */ -+ if (!watchdog) -+ watchdog = old_wd; -+ -+ /* If we changed the watchdog we need to reset cycles. */ -+ if (watchdog != old_wd) -+ clocksource_reset_watchdog(); -+ - /* Check if the watchdog timer needs to be started. */ - clocksource_start_watchdog(); - spin_unlock_irqrestore(&watchdog_lock, flags); -@@ -404,6 +433,7 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs) - cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; - } - -+static void clocksource_select_watchdog(bool fallback) { } - static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } - static inline void clocksource_resume_watchdog(void) { } - static inline int __clocksource_watchdog_kthread(void) { return 0; } -@@ -736,6 +766,7 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) - clocksource_enqueue(cs); - clocksource_enqueue_watchdog(cs); - clocksource_select(); -+ clocksource_select_watchdog(false); - mutex_unlock(&clocksource_mutex); - return 0; - } -@@ -758,6 +789,7 @@ void clocksource_change_rating(struct clocksource *cs, int rating) - mutex_lock(&clocksource_mutex); - __clocksource_change_rating(cs, rating); - clocksource_select(); -+ clocksource_select_watchdog(false); - mutex_unlock(&clocksource_mutex); - } - EXPORT_SYMBOL(clocksource_change_rating); -@@ -767,12 +799,12 @@ EXPORT_SYMBOL(clocksource_change_rating); - */ - static int clocksource_unbind(struct clocksource *cs) - { -- /* -- * I really can't convince myself to support this on hardware -- * designed by lobotomized monkeys. -- */ -- if (clocksource_is_watchdog(cs)) -- return -EBUSY; -+ if (clocksource_is_watchdog(cs)) { -+ /* Select and try to install a replacement watchdog. */ -+ clocksource_select_watchdog(true); -+ if (clocksource_is_watchdog(cs)) -+ return -EBUSY; -+ } - - if (cs == curr_clocksource) { - /* Select and try to install a replacement clock source */ -diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c -index fa909f9fd559..17f7bcff1e02 100644 ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -94,6 +94,9 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) = - }; - - static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = { -+ /* Make sure we catch unsupported clockids */ -+ [0 ... MAX_CLOCKS - 1] = HRTIMER_MAX_CLOCK_BASES, -+ - [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME, - [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC, - [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME, -@@ -102,7 +105,9 @@ static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = { - - static inline int hrtimer_clockid_to_base(clockid_t clock_id) - { -- return hrtimer_clock_to_base_table[clock_id]; -+ int base = hrtimer_clock_to_base_table[clock_id]; -+ BUG_ON(base == HRTIMER_MAX_CLOCK_BASES); -+ return base; - } - - /* -diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c -index 149cc8086aea..ab861771e37f 100644 ---- a/kernel/time/ntp.c -+++ b/kernel/time/ntp.c -@@ -674,8 +674,24 @@ int ntp_validate_timex(struct timex *txc) - return -EINVAL; - } - -- if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) -- return -EPERM; -+ if (txc->modes & ADJ_SETOFFSET) { -+ /* In order to inject time, you gotta be super-user! */ -+ if (!capable(CAP_SYS_TIME)) -+ return -EPERM; -+ -+ if (txc->modes & ADJ_NANO) { -+ struct timespec ts; -+ -+ ts.tv_sec = txc->time.tv_sec; -+ ts.tv_nsec = txc->time.tv_usec; -+ if (!timespec_inject_offset_valid(&ts)) -+ return -EINVAL; -+ -+ } else { -+ if (!timeval_inject_offset_valid(&txc->time)) -+ return -EINVAL; -+ } -+ } - - /* - * Check for potential multiplication overflows that can -diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c -index 99188ee5d9d0..4ff237dbc006 100644 ---- a/kernel/time/timekeeping.c -+++ b/kernel/time/timekeeping.c -@@ -383,7 +383,10 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) - do { - seq = raw_read_seqcount_latch(&tkf->seq); - tkr = tkf->base + (seq & 0x01); -- now = ktime_to_ns(tkr->base) + timekeeping_get_ns(tkr); -+ now = ktime_to_ns(tkr->base); -+ -+ now += clocksource_delta(tkr->read(tkr->clock), -+ tkr->cycle_last, tkr->mask); - } while (read_seqcount_retry(&tkf->seq, seq)); - - return now; -@@ -958,7 +961,7 @@ int timekeeping_inject_offset(struct timespec *ts) - struct timespec64 ts64, tmp; - int ret = 0; - -- if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) -+ if (!timespec_inject_offset_valid(ts)) - return -EINVAL; - - ts64 = timespec_to_timespec64(*ts); -diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c -index f6bd65236712..107310a6f36f 100644 ---- a/kernel/time/timekeeping_debug.c -+++ b/kernel/time/timekeeping_debug.c -@@ -23,7 +23,9 @@ - - #include "timekeeping_internal.h" - --static unsigned int sleep_time_bin[32] = {0}; -+#define NUM_BINS 32 -+ -+static unsigned int sleep_time_bin[NUM_BINS] = {0}; - - static int tk_debug_show_sleep_time(struct seq_file *s, void *data) - { -@@ -69,6 +71,9 @@ late_initcall(tk_debug_sleep_time_init); - - void tk_debug_account_sleep_time(struct timespec64 *t) - { -- sleep_time_bin[fls(t->tv_sec)]++; -+ /* Cap bin index so we don't overflow the array */ -+ int bin = min(fls(t->tv_sec), NUM_BINS-1); -+ -+ sleep_time_bin[bin]++; - } - -diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c -index 2b3f46c049d4..554522934c44 100644 ---- a/lib/asn1_decoder.c -+++ b/lib/asn1_decoder.c -@@ -74,7 +74,7 @@ next_tag: - - /* Extract a tag from the data */ - tag = data[dp++]; -- if (tag == 0) { -+ if (tag == ASN1_EOC) { - /* It appears to be an EOC. */ - if (data[dp++] != 0) - goto invalid_eoc; -@@ -96,10 +96,8 @@ next_tag: - - /* Extract the length */ - len = data[dp++]; -- if (len <= 0x7f) { -- dp += len; -- goto next_tag; -- } -+ if (len <= 0x7f) -+ goto check_length; - - if (unlikely(len == ASN1_INDEFINITE_LENGTH)) { - /* Indefinite length */ -@@ -110,14 +108,18 @@ next_tag: - } - - n = len - 0x80; -- if (unlikely(n > sizeof(size_t) - 1)) -+ if (unlikely(n > sizeof(len) - 1)) - goto length_too_long; - if (unlikely(n > datalen - dp)) - goto data_overrun_error; -- for (len = 0; n > 0; n--) { -+ len = 0; -+ for (; n > 0; n--) { - len <<= 8; - len |= data[dp++]; - } -+check_length: -+ if (len > datalen - dp) -+ goto data_overrun_error; - dp += len; - goto next_tag; - -diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c -index e00ff00e861c..e37dbf53e226 100644 ---- a/lib/mpi/mpicoder.c -+++ b/lib/mpi/mpicoder.c -@@ -367,7 +367,9 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes, - buf_len = sgl->length; - p2 = sg_virt(sgl); - -- for (i = a->nlimbs - 1; i >= 0; i--) { -+ for (i = a->nlimbs - 1 - lzeros / BYTES_PER_MPI_LIMB, -+ lzeros %= BYTES_PER_MPI_LIMB; -+ i >= 0; i--) { - alimb = a->d[i]; - p = (u8 *)&alimb2; - #if BYTES_PER_MPI_LIMB == 4 -@@ -388,17 +390,12 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes, - #error please implement for this limb size. - #endif - if (lzeros > 0) { -- if (lzeros >= sizeof(alimb)) { -- p -= sizeof(alimb); -- continue; -- } else { -- mpi_limb_t *limb1 = (void *)p - sizeof(alimb); -- mpi_limb_t *limb2 = (void *)p - sizeof(alimb) -- + lzeros; -- *limb1 = *limb2; -- p -= lzeros; -- y = lzeros; -- } -+ mpi_limb_t *limb1 = (void *)p - sizeof(alimb); -+ mpi_limb_t *limb2 = (void *)p - sizeof(alimb) -+ + lzeros; -+ *limb1 = *limb2; -+ p -= lzeros; -+ y = lzeros; - lzeros -= sizeof(alimb); - } - -diff --git a/mm/util.c b/mm/util.c -index 9af1c12b310c..d5259b62f8d7 100644 ---- a/mm/util.c -+++ b/mm/util.c -@@ -199,36 +199,11 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma, - } - - /* Check if the vma is being used as a stack by this task */ --static int vm_is_stack_for_task(struct task_struct *t, -- struct vm_area_struct *vma) -+int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t) - { - return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t)); - } - --/* -- * Check if the vma is being used as a stack. -- * If is_group is non-zero, check in the entire thread group or else -- * just check in the current task. Returns the task_struct of the task -- * that the vma is stack for. Must be called under rcu_read_lock(). -- */ --struct task_struct *task_of_stack(struct task_struct *task, -- struct vm_area_struct *vma, bool in_group) --{ -- if (vm_is_stack_for_task(task, vma)) -- return task; -- -- if (in_group) { -- struct task_struct *t; -- -- for_each_thread(task, t) { -- if (vm_is_stack_for_task(t, vma)) -- return t; -- } -- } -- -- return NULL; --} -- - #if defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT) - void arch_pick_mmap_layout(struct mm_struct *mm) - { -diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c -index 44e1632370dd..0b1ea5abcc04 100644 ---- a/net/ipv4/udp.c -+++ b/net/ipv4/udp.c -@@ -1275,6 +1275,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, - int peeked, off = 0; - int err; - int is_udplite = IS_UDPLITE(sk); -+ bool checksum_valid = false; - bool slow; - - if (flags & MSG_ERRQUEUE) -@@ -1300,11 +1301,12 @@ try_again: - */ - - if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { -- if (udp_lib_checksum_complete(skb)) -+ checksum_valid = !udp_lib_checksum_complete(skb); -+ if (!checksum_valid) - goto csum_copy_err; - } - -- if (skb_csum_unnecessary(skb)) -+ if (checksum_valid || skb_csum_unnecessary(skb)) - err = skb_copy_datagram_msg(skb, sizeof(struct udphdr), - msg, copied); - else { -diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c -index 275af43306f9..e6092bd72ee2 100644 ---- a/net/ipv6/udp.c -+++ b/net/ipv6/udp.c -@@ -402,6 +402,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, - int peeked, off = 0; - int err; - int is_udplite = IS_UDPLITE(sk); -+ bool checksum_valid = false; - int is_udp4; - bool slow; - -@@ -433,11 +434,12 @@ try_again: - */ - - if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { -- if (udp_lib_checksum_complete(skb)) -+ checksum_valid = !udp_lib_checksum_complete(skb); -+ if (!checksum_valid) - goto csum_copy_err; - } - -- if (skb_csum_unnecessary(skb)) -+ if (checksum_valid || skb_csum_unnecessary(skb)) - err = skb_copy_datagram_msg(skb, sizeof(struct udphdr), - msg, copied); - else { -diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c -index 25391fb25516..2fc6ca9d1286 100644 ---- a/net/netfilter/x_tables.c -+++ b/net/netfilter/x_tables.c -@@ -897,6 +897,12 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) - struct xt_table_info *info = NULL; - size_t sz = sizeof(*info) + size; - -+ if (sz < sizeof(*info)) -+ return NULL; -+ -+ if (sz < sizeof(*info)) -+ return NULL; -+ - /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ - if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages) - return NULL; -diff --git a/net/rds/recv.c b/net/rds/recv.c -index a00462b0d01d..0514af3ab378 100644 ---- a/net/rds/recv.c -+++ b/net/rds/recv.c -@@ -545,5 +545,7 @@ void rds_inc_info_copy(struct rds_incoming *inc, - minfo.fport = inc->i_hdr.h_dport; - } - -+ minfo.flags = 0; -+ - rds_info_copy(iter, &minfo, sizeof(minfo)); - } -diff --git a/net/sysctl_net.c b/net/sysctl_net.c -index ed98c1fc3de1..46a71c701e7c 100644 ---- a/net/sysctl_net.c -+++ b/net/sysctl_net.c -@@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head, - kgid_t root_gid = make_kgid(net->user_ns, 0); - - /* Allow network administrator to have same access as root. */ -- if (ns_capable(net->user_ns, CAP_NET_ADMIN) || -+ if (ns_capable_noaudit(net->user_ns, CAP_NET_ADMIN) || - uid_eq(root_uid, current_euid())) { - int mode = (table->mode >> 6) & 7; - return (mode << 6) | (mode << 3) | mode; -diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c -index 2ed732bfe94b..a0c90572d0e5 100644 ---- a/net/tipc/netlink_compat.c -+++ b/net/tipc/netlink_compat.c -@@ -574,7 +574,8 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg, - - link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]); - link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP])); -- strcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME])); -+ nla_strlcpy(link_info.str, link[TIPC_NLA_LINK_NAME], -+ TIPC_MAX_LINK_NAME); - - return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO, - &link_info, sizeof(link_info)); -diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c -index 69ee2eeef968..f9ff73a8d815 100644 ---- a/net/tipc/subscr.c -+++ b/net/tipc/subscr.c -@@ -296,7 +296,8 @@ static void tipc_subscrb_rcv_cb(struct net *net, int conid, - if (tipc_subscrp_create(net, (struct tipc_subscr *)buf, subscrb, &sub)) - return tipc_conn_terminate(tn->topsrv, subscrb->conid); - -- tipc_nametbl_subscribe(sub); -+ if (sub) -+ tipc_nametbl_subscribe(sub); - } - - /* Handle one request to establish a new subscriber */ -diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c -index 795437b10082..b450a27588c8 100644 ---- a/sound/core/rawmidi.c -+++ b/sound/core/rawmidi.c -@@ -1633,11 +1633,13 @@ static int snd_rawmidi_dev_register(struct snd_device *device) - return -EBUSY; - } - list_add_tail(&rmidi->list, &snd_rawmidi_devices); -+ mutex_unlock(®ister_mutex); - err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, - rmidi->card, rmidi->device, - &snd_rawmidi_f_ops, rmidi, &rmidi->dev); - if (err < 0) { - rmidi_err(rmidi, "unable to register\n"); -+ mutex_lock(®ister_mutex); - list_del(&rmidi->list); - mutex_unlock(®ister_mutex); - return err; -@@ -1645,6 +1647,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) - if (rmidi->ops && rmidi->ops->dev_register && - (err = rmidi->ops->dev_register(rmidi)) < 0) { - snd_unregister_device(&rmidi->dev); -+ mutex_lock(®ister_mutex); - list_del(&rmidi->list); - mutex_unlock(®ister_mutex); - return err; -@@ -1677,7 +1680,6 @@ static int snd_rawmidi_dev_register(struct snd_device *device) - } - } - #endif /* CONFIG_SND_OSSEMUL */ -- mutex_unlock(®ister_mutex); - sprintf(name, "midi%d", rmidi->device); - entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); - if (entry) { -diff --git a/sound/core/timer.c b/sound/core/timer.c -index 637d034bb084..ae4ea2e2e7fe 100644 ---- a/sound/core/timer.c -+++ b/sound/core/timer.c -@@ -296,8 +296,21 @@ int snd_timer_open(struct snd_timer_instance **ti, - get_device(&timer->card->card_dev); - timeri->slave_class = tid->dev_sclass; - timeri->slave_id = slave_id; -- if (list_empty(&timer->open_list_head) && timer->hw.open) -- timer->hw.open(timer); -+ -+ if (list_empty(&timer->open_list_head) && timer->hw.open) { -+ int err = timer->hw.open(timer); -+ if (err) { -+ kfree(timeri->owner); -+ kfree(timeri); -+ -+ if (timer->card) -+ put_device(&timer->card->card_dev); -+ module_put(timer->module); -+ mutex_unlock(®ister_mutex); -+ return err; -+ } -+ } -+ - list_add_tail(&timeri->open_list, &timer->open_list_head); - snd_timer_check_master(timeri); - mutex_unlock(®ister_mutex); -@@ -837,6 +850,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, - timer->tmr_subdevice = tid->subdevice; - if (id) - strlcpy(timer->id, id, sizeof(timer->id)); -+ timer->sticks = 1; - INIT_LIST_HEAD(&timer->device_list); - INIT_LIST_HEAD(&timer->open_list_head); - INIT_LIST_HEAD(&timer->active_list_head); -@@ -1967,6 +1981,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, - tu->qused--; - spin_unlock_irq(&tu->qlock); - -+ mutex_lock(&tu->ioctl_lock); - if (tu->tread) { - if (copy_to_user(buffer, &tu->tqueue[qhead], - sizeof(struct snd_timer_tread))) -@@ -1976,6 +1991,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, - sizeof(struct snd_timer_read))) - err = -EFAULT; - } -+ mutex_unlock(&tu->ioctl_lock); - - spin_lock_irq(&tu->qlock); - if (err < 0) -diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h -index c7cb7deafe48..2c316a9bc7f6 100644 ---- a/sound/firewire/fireworks/fireworks.h -+++ b/sound/firewire/fireworks/fireworks.h -@@ -106,7 +106,6 @@ struct snd_efw { - u8 *resp_buf; - u8 *pull_ptr; - u8 *push_ptr; -- unsigned int resp_queues; - }; - - int snd_efw_transaction_cmd(struct fw_unit *unit, -diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c -index 33df8655fe81..2e1d9a23920c 100644 ---- a/sound/firewire/fireworks/fireworks_hwdep.c -+++ b/sound/firewire/fireworks/fireworks_hwdep.c -@@ -25,6 +25,7 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, - { - unsigned int length, till_end, type; - struct snd_efw_transaction *t; -+ u8 *pull_ptr; - long count = 0; - - if (remained < sizeof(type) + sizeof(struct snd_efw_transaction)) -@@ -38,8 +39,17 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, - buf += sizeof(type); - - /* write into buffer as many responses as possible */ -- while (efw->resp_queues > 0) { -- t = (struct snd_efw_transaction *)(efw->pull_ptr); -+ spin_lock_irq(&efw->lock); -+ -+ /* -+ * When another task reaches here during this task's access to user -+ * space, it picks up current position in buffer and can read the same -+ * series of responses. -+ */ -+ pull_ptr = efw->pull_ptr; -+ -+ while (efw->push_ptr != pull_ptr) { -+ t = (struct snd_efw_transaction *)(pull_ptr); - length = be32_to_cpu(t->length) * sizeof(__be32); - - /* confirm enough space for this response */ -@@ -49,26 +59,39 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, - /* copy from ring buffer to user buffer */ - while (length > 0) { - till_end = snd_efw_resp_buf_size - -- (unsigned int)(efw->pull_ptr - efw->resp_buf); -+ (unsigned int)(pull_ptr - efw->resp_buf); - till_end = min_t(unsigned int, length, till_end); - -- if (copy_to_user(buf, efw->pull_ptr, till_end)) -+ spin_unlock_irq(&efw->lock); -+ -+ if (copy_to_user(buf, pull_ptr, till_end)) - return -EFAULT; - -- efw->pull_ptr += till_end; -- if (efw->pull_ptr >= efw->resp_buf + -- snd_efw_resp_buf_size) -- efw->pull_ptr -= snd_efw_resp_buf_size; -+ spin_lock_irq(&efw->lock); -+ -+ pull_ptr += till_end; -+ if (pull_ptr >= efw->resp_buf + snd_efw_resp_buf_size) -+ pull_ptr -= snd_efw_resp_buf_size; - - length -= till_end; - buf += till_end; - count += till_end; - remained -= till_end; - } -- -- efw->resp_queues--; - } - -+ /* -+ * All of tasks can read from the buffer nearly simultaneously, but the -+ * last position for each task is different depending on the length of -+ * given buffer. Here, for simplicity, a position of buffer is set by -+ * the latest task. It's better for a listening application to allow one -+ * thread to read from the buffer. Unless, each task can read different -+ * sequence of responses depending on variation of buffer length. -+ */ -+ efw->pull_ptr = pull_ptr; -+ -+ spin_unlock_irq(&efw->lock); -+ - return count; - } - -@@ -76,14 +99,17 @@ static long - hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count, - loff_t *offset) - { -- union snd_firewire_event event; -+ union snd_firewire_event event = { -+ .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS, -+ }; - -- memset(&event, 0, sizeof(event)); -+ spin_lock_irq(&efw->lock); - -- event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; - event.lock_status.status = (efw->dev_lock_count > 0); - efw->dev_lock_changed = false; - -+ spin_unlock_irq(&efw->lock); -+ - count = min_t(long, count, sizeof(event.lock_status)); - - if (copy_to_user(buf, &event, count)) -@@ -98,10 +124,15 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, - { - struct snd_efw *efw = hwdep->private_data; - DEFINE_WAIT(wait); -+ bool dev_lock_changed; -+ bool queued; - - spin_lock_irq(&efw->lock); - -- while ((!efw->dev_lock_changed) && (efw->resp_queues == 0)) { -+ dev_lock_changed = efw->dev_lock_changed; -+ queued = efw->push_ptr != efw->pull_ptr; -+ -+ while (!dev_lock_changed && !queued) { - prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE); - spin_unlock_irq(&efw->lock); - schedule(); -@@ -109,15 +140,17 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, - if (signal_pending(current)) - return -ERESTARTSYS; - spin_lock_irq(&efw->lock); -+ dev_lock_changed = efw->dev_lock_changed; -+ queued = efw->push_ptr != efw->pull_ptr; - } - -- if (efw->dev_lock_changed) -+ spin_unlock_irq(&efw->lock); -+ -+ if (dev_lock_changed) - count = hwdep_read_locked(efw, buf, count, offset); -- else if (efw->resp_queues > 0) -+ else if (queued) - count = hwdep_read_resp_buf(efw, buf, count, offset); - -- spin_unlock_irq(&efw->lock); -- - return count; - } - -@@ -160,7 +193,7 @@ hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) - poll_wait(file, &efw->hwdep_wait, wait); - - spin_lock_irq(&efw->lock); -- if (efw->dev_lock_changed || (efw->resp_queues > 0)) -+ if (efw->dev_lock_changed || efw->pull_ptr != efw->push_ptr) - events = POLLIN | POLLRDNORM; - else - events = 0; -diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c -index 0639dcb13f7d..beb0a0ffee57 100644 ---- a/sound/firewire/fireworks/fireworks_proc.c -+++ b/sound/firewire/fireworks/fireworks_proc.c -@@ -188,8 +188,8 @@ proc_read_queues_state(struct snd_info_entry *entry, - else - consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr); - -- snd_iprintf(buffer, "%d %d/%d\n", -- efw->resp_queues, consumed, snd_efw_resp_buf_size); -+ snd_iprintf(buffer, "%d/%d\n", -+ consumed, snd_efw_resp_buf_size); - } - - static void -diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c -index f550808d1784..36a08ba51ec7 100644 ---- a/sound/firewire/fireworks/fireworks_transaction.c -+++ b/sound/firewire/fireworks/fireworks_transaction.c -@@ -121,11 +121,11 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) - size_t capacity, till_end; - struct snd_efw_transaction *t; - -- spin_lock_irq(&efw->lock); -- - t = (struct snd_efw_transaction *)data; - length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length); - -+ spin_lock_irq(&efw->lock); -+ - if (efw->push_ptr < efw->pull_ptr) - capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); - else -@@ -155,7 +155,6 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) - } - - /* for hwdep */ -- efw->resp_queues++; - wake_up(&efw->hwdep_wait); - - *rcode = RCODE_COMPLETE; -diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c -index 131267c3a042..106406cbfaa3 100644 ---- a/sound/firewire/tascam/tascam-hwdep.c -+++ b/sound/firewire/tascam/tascam-hwdep.c -@@ -16,31 +16,14 @@ - - #include "tascam.h" - --static long hwdep_read_locked(struct snd_tscm *tscm, char __user *buf, -- long count) --{ -- union snd_firewire_event event; -- -- memset(&event, 0, sizeof(event)); -- -- event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; -- event.lock_status.status = (tscm->dev_lock_count > 0); -- tscm->dev_lock_changed = false; -- -- count = min_t(long, count, sizeof(event.lock_status)); -- -- if (copy_to_user(buf, &event, count)) -- return -EFAULT; -- -- return count; --} -- - static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, - loff_t *offset) - { - struct snd_tscm *tscm = hwdep->private_data; - DEFINE_WAIT(wait); -- union snd_firewire_event event; -+ union snd_firewire_event event = { -+ .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS, -+ }; - - spin_lock_irq(&tscm->lock); - -@@ -54,10 +37,16 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, - spin_lock_irq(&tscm->lock); - } - -- memset(&event, 0, sizeof(event)); -- count = hwdep_read_locked(tscm, buf, count); -+ event.lock_status.status = (tscm->dev_lock_count > 0); -+ tscm->dev_lock_changed = false; -+ - spin_unlock_irq(&tscm->lock); - -+ count = min_t(long, count, sizeof(event.lock_status)); -+ -+ if (copy_to_user(buf, &event, count)) -+ return -EFAULT; -+ - return count; - } - -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index 12f7f6fdae4d..d4671973d889 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -2366,6 +2366,10 @@ static const struct pci_device_id azx_ids[] = { - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0xaae8), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, -+ { PCI_DEVICE(0x1002, 0xaae0), -+ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, -+ { PCI_DEVICE(0x1002, 0xaaf0), -+ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - /* VIA VT8251/VT8237A */ - { PCI_DEVICE(0x1106, 0x3288), - .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA }, -diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c -index f7bcd8dbac14..a8045b8a2a18 100644 ---- a/sound/pci/hda/patch_hdmi.c -+++ b/sound/pci/hda/patch_hdmi.c -@@ -51,8 +51,10 @@ MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); - #define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808) - #define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809) - #define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a) -+#define is_kabylake(codec) ((codec)->core.vendor_id == 0x8086280b) - #define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ -- || is_skylake(codec) || is_broxton(codec)) -+ || is_skylake(codec) || is_broxton(codec) \ -+ || is_kabylake(codec)) - - #define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882) - #define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883) -@@ -3584,6 +3586,7 @@ HDA_CODEC_ENTRY(0x80862807, "Haswell HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x80862808, "Broadwell HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x80862809, "Skylake HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x8086280a, "Broxton HDMI", patch_generic_hdmi), -+HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_generic_hdmi), - HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_generic_hdmi), -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index f25479ba3981..eaee626ab185 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -4840,6 +4840,7 @@ enum { - ALC221_FIXUP_HP_FRONT_MIC, - ALC292_FIXUP_TPT460, - ALC298_FIXUP_SPK_VOLUME, -+ ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, - }; - - static const struct hda_fixup alc269_fixups[] = { -@@ -5501,6 +5502,15 @@ static const struct hda_fixup alc269_fixups[] = { - .chained = true, - .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, - }, -+ [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = { -+ .type = HDA_FIXUP_PINS, -+ .v.pins = (const struct hda_pintbl[]) { -+ { 0x1b, 0x90170151 }, -+ { } -+ }, -+ .chained = true, -+ .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE -+ }, - }; - - static const struct snd_pci_quirk alc269_fixup_tbl[] = { -@@ -5545,6 +5555,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), - SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), - SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), -+ SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), - SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), - SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), - SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), -@@ -5879,6 +5890,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - {0x12, 0x90a60170}, - {0x14, 0x90170120}, - {0x21, 0x02211030}), -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, -+ {0x12, 0x90a60180}, -+ {0x14, 0x90170120}, -+ {0x21, 0x02211030}), - SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC256_STANDARD_PINS), - SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, -diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c -index ba8def5665c4..6726143c7fc5 100644 ---- a/sound/soc/atmel/atmel_ssc_dai.c -+++ b/sound/soc/atmel/atmel_ssc_dai.c -@@ -298,8 +298,9 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream, - clk_enable(ssc_p->ssc->clk); - ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk); - -- /* Reset the SSC to keep it at a clean status */ -- ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); -+ /* Reset the SSC unless initialized to keep it in a clean state */ -+ if (!ssc_p->initialized) -+ ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - dir = 0; -diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c -index a3e1252ce242..3039e907f1f8 100644 ---- a/sound/usb/quirks.c -+++ b/sound/usb/quirks.c -@@ -1142,6 +1142,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) - case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ - case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ - case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ -+ case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ - case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ - case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ - case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */ -diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c -index 5480e4e424eb..f1d742682317 100644 ---- a/tools/hv/hv_fcopy_daemon.c -+++ b/tools/hv/hv_fcopy_daemon.c -@@ -37,12 +37,14 @@ - - static int target_fd; - static char target_fname[W_MAX_PATH]; -+static unsigned long long filesize; - - static int hv_start_fcopy(struct hv_start_fcopy *smsg) - { - int error = HV_E_FAIL; - char *q, *p; - -+ filesize = 0; - p = (char *)smsg->path_name; - snprintf(target_fname, sizeof(target_fname), "%s/%s", - (char *)smsg->path_name, (char *)smsg->file_name); -@@ -98,14 +100,26 @@ done: - static int hv_copy_data(struct hv_do_fcopy *cpmsg) - { - ssize_t bytes_written; -+ int ret = 0; - - bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size, - cpmsg->offset); - -- if (bytes_written != cpmsg->size) -- return HV_E_FAIL; -+ filesize += cpmsg->size; -+ if (bytes_written != cpmsg->size) { -+ switch (errno) { -+ case ENOSPC: -+ ret = HV_ERROR_DISK_FULL; -+ break; -+ default: -+ ret = HV_E_FAIL; -+ break; -+ } -+ syslog(LOG_ERR, "pwrite failed to write %llu bytes: %ld (%s)", -+ filesize, (long)bytes_written, strerror(errno)); -+ } - -- return 0; -+ return ret; - } - - static int hv_copy_finished(void) diff --git a/patch/kernel/marvell-dev/patch-4.4.21-22.patch b/patch/kernel/marvell-dev/patch-4.4.21-22.patch deleted file mode 100644 index 8381b8de08..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.21-22.patch +++ /dev/null @@ -1,3663 +0,0 @@ -diff --git a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt -index a9a5fe19ff2a..ec9d65682702 100644 ---- a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt -+++ b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt -@@ -12,6 +12,11 @@ Required properties: - - vref-supply: The regulator supply ADC reference voltage. - - #io-channel-cells: Should be 1, see ../iio-bindings.txt - -+Optional properties: -+- resets: Must contain an entry for each entry in reset-names if need support -+ this option. See ../reset/reset.txt for details. -+- reset-names: Must include the name "saradc-apb". -+ - Example: - saradc: saradc@2006c000 { - compatible = "rockchip,saradc"; -@@ -19,6 +24,8 @@ Example: - interrupts = ; - clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; - clock-names = "saradc", "apb_pclk"; -+ resets = <&cru SRST_SARADC>; -+ reset-names = "saradc-apb"; - #io-channel-cells = <1>; - vref-supply = <&vcc18>; - }; -diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c -index aaeafa18d99b..c99a75968c01 100644 ---- a/Documentation/mic/mpssd/mpssd.c -+++ b/Documentation/mic/mpssd/mpssd.c -@@ -1538,9 +1538,9 @@ set_cmdline(struct mic_info *mic) - - len = snprintf(buffer, PATH_MAX, - "clocksource=tsc highres=off nohz=off "); -- len += snprintf(buffer + len, PATH_MAX, -+ len += snprintf(buffer + len, PATH_MAX - len, - "cpufreq_on;corec6_off;pc3_off;pc6_off "); -- len += snprintf(buffer + len, PATH_MAX, -+ len += snprintf(buffer + len, PATH_MAX - len, - "ifcfg=static;address,172.31.%d.1;netmask,255.255.255.0", - mic->id + 1); - -diff --git a/Makefile b/Makefile -index d1cc9e0b7473..a6512f4eec9f 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 21 -+SUBLEVEL = 22 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h -index 9b0d40093c9a..c0ddbbf73400 100644 ---- a/arch/alpha/include/asm/uaccess.h -+++ b/arch/alpha/include/asm/uaccess.h -@@ -371,14 +371,6 @@ __copy_tofrom_user_nocheck(void *to, const void *from, long len) - return __cu_len; - } - --extern inline long --__copy_tofrom_user(void *to, const void *from, long len, const void __user *validate) --{ -- if (__access_ok((unsigned long)validate, len, get_fs())) -- len = __copy_tofrom_user_nocheck(to, from, len); -- return len; --} -- - #define __copy_to_user(to, from, n) \ - ({ \ - __chk_user_ptr(to); \ -@@ -393,17 +385,22 @@ __copy_tofrom_user(void *to, const void *from, long len, const void __user *vali - #define __copy_to_user_inatomic __copy_to_user - #define __copy_from_user_inatomic __copy_from_user - -- - extern inline long - copy_to_user(void __user *to, const void *from, long n) - { -- return __copy_tofrom_user((__force void *)to, from, n, to); -+ if (likely(__access_ok((unsigned long)to, n, get_fs()))) -+ n = __copy_tofrom_user_nocheck((__force void *)to, from, n); -+ return n; - } - - extern inline long - copy_from_user(void *to, const void __user *from, long n) - { -- return __copy_tofrom_user(to, (__force void *)from, n, from); -+ if (likely(__access_ok((unsigned long)from, n, get_fs()))) -+ n = __copy_tofrom_user_nocheck(to, (__force void *)from, n); -+ else -+ memset(to, 0, n); -+ return n; - } - - extern void __do_clear_user(void); -diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h -index 3cab04255ae0..e5fec320f158 100644 ---- a/arch/arc/include/asm/pgtable.h -+++ b/arch/arc/include/asm/pgtable.h -@@ -277,8 +277,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) - - #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) - #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) --#define pfn_pte(pfn, prot) (__pte(((pte_t)(pfn) << PAGE_SHIFT) | \ -- pgprot_val(prot))) -+#define pfn_pte(pfn, prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) - #define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) - - /* -diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h -index d1da6032b715..d4d8df706efa 100644 ---- a/arch/arc/include/asm/uaccess.h -+++ b/arch/arc/include/asm/uaccess.h -@@ -83,7 +83,10 @@ - "2: ;nop\n" \ - " .section .fixup, \"ax\"\n" \ - " .align 4\n" \ -- "3: mov %0, %3\n" \ -+ "3: # return -EFAULT\n" \ -+ " mov %0, %3\n" \ -+ " # zero out dst ptr\n" \ -+ " mov %1, 0\n" \ - " j 2b\n" \ - " .previous\n" \ - " .section __ex_table, \"a\"\n" \ -@@ -101,7 +104,11 @@ - "2: ;nop\n" \ - " .section .fixup, \"ax\"\n" \ - " .align 4\n" \ -- "3: mov %0, %3\n" \ -+ "3: # return -EFAULT\n" \ -+ " mov %0, %3\n" \ -+ " # zero out dst ptr\n" \ -+ " mov %1, 0\n" \ -+ " mov %R1, 0\n" \ - " j 2b\n" \ - " .previous\n" \ - " .section __ex_table, \"a\"\n" \ -diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi -index 2b6cc8bf3c5c..e6af41c4bbc1 100644 ---- a/arch/arm/boot/dts/imx6qdl.dtsi -+++ b/arch/arm/boot/dts/imx6qdl.dtsi -@@ -221,7 +221,7 @@ - clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>, - <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>, - <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>, -- <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>, -+ <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>, - <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>; - clock-names = "core", "rxtx0", - "rxtx1", "rxtx2", -diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts -index bfa5edde179c..2c1e7f09205f 100644 ---- a/arch/arm/boot/dts/kirkwood-ib62x0.dts -+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts -@@ -113,7 +113,7 @@ - - partition@e0000 { - label = "u-boot environment"; -- reg = <0xe0000 0x100000>; -+ reg = <0xe0000 0x20000>; - }; - - partition@100000 { -diff --git a/arch/arm/boot/dts/omap3-overo-base.dtsi b/arch/arm/boot/dts/omap3-overo-base.dtsi -index a29ad16cc9bb..64c5af30c1d0 100644 ---- a/arch/arm/boot/dts/omap3-overo-base.dtsi -+++ b/arch/arm/boot/dts/omap3-overo-base.dtsi -@@ -223,7 +223,9 @@ - }; - - &gpmc { -- ranges = <0 0 0x00000000 0x20000000>; -+ ranges = <0 0 0x30000000 0x1000000>, /* CS0 */ -+ <4 0 0x2b000000 0x1000000>, /* CS4 */ -+ <5 0 0x2c000000 0x1000000>; /* CS5 */ - - nand@0,0 { - linux,mtd-name= "micron,mt29c4g96maz"; -diff --git a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi -index 17b82f82638a..64047788216b 100644 ---- a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi -+++ b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi -@@ -55,8 +55,6 @@ - #include "omap-gpmc-smsc9221.dtsi" - - &gpmc { -- ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */ -- - ethernet@gpmc { - reg = <5 0 0xff>; - interrupt-parent = <&gpio6>; -diff --git a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi -index 9e24b6a1d07b..1b304e2f1bd2 100644 ---- a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi -+++ b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi -@@ -27,8 +27,6 @@ - #include "omap-gpmc-smsc9221.dtsi" - - &gpmc { -- ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */ -- - ethernet@gpmc { - reg = <5 0 0xff>; - interrupt-parent = <&gpio6>; -diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi -index 334109e14613..82e98ee3023a 100644 ---- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi -+++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi -@@ -15,9 +15,6 @@ - #include "omap-gpmc-smsc9221.dtsi" - - &gpmc { -- ranges = <4 0 0x2b000000 0x1000000>, /* CS4 */ -- <5 0 0x2c000000 0x1000000>; /* CS5 */ -- - smsc1: ethernet@gpmc { - reg = <5 0 0xff>; - interrupt-parent = <&gpio6>; -diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi -index 81f81214cdf9..bbf95375cf99 100644 ---- a/arch/arm/boot/dts/stih407-family.dtsi -+++ b/arch/arm/boot/dts/stih407-family.dtsi -@@ -497,8 +497,9 @@ - interrupt-names = "mmcirq"; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_mmc0>; -- clock-names = "mmc"; -- clocks = <&clk_s_c0_flexgen CLK_MMC_0>; -+ clock-names = "mmc", "icn"; -+ clocks = <&clk_s_c0_flexgen CLK_MMC_0>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_HVA>; - bus-width = <8>; - non-removable; - }; -@@ -512,8 +513,9 @@ - interrupt-names = "mmcirq"; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_sd1>; -- clock-names = "mmc"; -- clocks = <&clk_s_c0_flexgen CLK_MMC_1>; -+ clock-names = "mmc", "icn"; -+ clocks = <&clk_s_c0_flexgen CLK_MMC_1>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_HVA>; - resets = <&softreset STIH407_MMC1_SOFTRESET>; - bus-width = <4>; - }; -diff --git a/arch/arm/boot/dts/stih410.dtsi b/arch/arm/boot/dts/stih410.dtsi -index 18ed1ad10d32..40318869c733 100644 ---- a/arch/arm/boot/dts/stih410.dtsi -+++ b/arch/arm/boot/dts/stih410.dtsi -@@ -41,7 +41,8 @@ - compatible = "st,st-ohci-300x"; - reg = <0x9a03c00 0x100>; - interrupts = ; -- clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; -+ clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; - resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, - <&softreset STIH407_USB2_PORT0_SOFTRESET>; - reset-names = "power", "softreset"; -@@ -57,7 +58,8 @@ - interrupts = ; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usb0>; -- clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; -+ clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; - resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, - <&softreset STIH407_USB2_PORT0_SOFTRESET>; - reset-names = "power", "softreset"; -@@ -71,7 +73,8 @@ - compatible = "st,st-ohci-300x"; - reg = <0x9a83c00 0x100>; - interrupts = ; -- clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; -+ clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; - resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, - <&softreset STIH407_USB2_PORT1_SOFTRESET>; - reset-names = "power", "softreset"; -@@ -87,7 +90,8 @@ - interrupts = ; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usb1>; -- clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; -+ clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, -+ <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; - resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, - <&softreset STIH407_USB2_PORT1_SOFTRESET>; - reset-names = "power", "softreset"; -diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c -index e06fd299de08..d7bef2144760 100644 ---- a/arch/arm/kvm/arm.c -+++ b/arch/arm/kvm/arm.c -@@ -155,8 +155,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm) - { - int i; - -- kvm_free_stage2_pgd(kvm); -- - for (i = 0; i < KVM_MAX_VCPUS; ++i) { - if (kvm->vcpus[i]) { - kvm_arch_vcpu_free(kvm->vcpus[i]); -diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c -index 12d727fae0a7..11b6595c2672 100644 ---- a/arch/arm/kvm/mmu.c -+++ b/arch/arm/kvm/mmu.c -@@ -1852,6 +1852,7 @@ void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots) - - void kvm_arch_flush_shadow_all(struct kvm *kvm) - { -+ kvm_free_stage2_pgd(kvm); - } - - void kvm_arch_flush_shadow_memslot(struct kvm *kvm, -diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c -index 4470376af5f8..a19d20f23e71 100644 ---- a/arch/arm/mach-imx/pm-imx6.c -+++ b/arch/arm/mach-imx/pm-imx6.c -@@ -295,7 +295,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode) - val &= ~BM_CLPCR_SBYOS; - if (cpu_is_imx6sl()) - val |= BM_CLPCR_BYPASS_PMIC_READY; -- if (cpu_is_imx6sl() || cpu_is_imx6sx()) -+ if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) - val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; - else - val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS; -@@ -310,7 +310,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode) - val |= 0x3 << BP_CLPCR_STBY_COUNT; - val |= BM_CLPCR_VSTBY; - val |= BM_CLPCR_SBYOS; -- if (cpu_is_imx6sl()) -+ if (cpu_is_imx6sl() || cpu_is_imx6sx()) - val |= BM_CLPCR_BYPASS_PMIC_READY; - if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) - val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; -diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c -index 907a452b78ea..b31ad596be79 100644 ---- a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c -+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c -@@ -1474,6 +1474,7 @@ static void omap_hwmod_am43xx_rst(void) - { - RSTCTRL(am33xx_pruss_hwmod, AM43XX_RM_PER_RSTCTRL_OFFSET); - RSTCTRL(am33xx_gfx_hwmod, AM43XX_RM_GFX_RSTCTRL_OFFSET); -+ RSTST(am33xx_pruss_hwmod, AM43XX_RM_PER_RSTST_OFFSET); - RSTST(am33xx_gfx_hwmod, AM43XX_RM_GFX_RSTST_OFFSET); - } - -diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c -index aff78d5198d2..131f8967589b 100644 ---- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c -+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c -@@ -723,8 +723,20 @@ static struct omap_hwmod omap3xxx_dss_dispc_hwmod = { - * display serial interface controller - */ - -+static struct omap_hwmod_class_sysconfig omap3xxx_dsi_sysc = { -+ .rev_offs = 0x0000, -+ .sysc_offs = 0x0010, -+ .syss_offs = 0x0014, -+ .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY | -+ SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE | -+ SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS), -+ .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), -+ .sysc_fields = &omap_hwmod_sysc_type1, -+}; -+ - static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = { - .name = "dsi", -+ .sysc = &omap3xxx_dsi_sysc, - }; - - static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = { -diff --git a/arch/arm/mach-omap2/prcm43xx.h b/arch/arm/mach-omap2/prcm43xx.h -index 7c34c44eb0ae..babb5db5a3a4 100644 ---- a/arch/arm/mach-omap2/prcm43xx.h -+++ b/arch/arm/mach-omap2/prcm43xx.h -@@ -39,6 +39,7 @@ - - /* RM RSTST offsets */ - #define AM43XX_RM_GFX_RSTST_OFFSET 0x0014 -+#define AM43XX_RM_PER_RSTST_OFFSET 0x0014 - #define AM43XX_RM_WKUP_RSTST_OFFSET 0x0014 - - /* CM instances */ -diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h -index c85e96d174a5..499e8de33a00 100644 ---- a/arch/arm64/include/asm/spinlock.h -+++ b/arch/arm64/include/asm/spinlock.h -@@ -312,4 +312,14 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) - #define arch_read_relax(lock) cpu_relax() - #define arch_write_relax(lock) cpu_relax() - -+/* -+ * Accesses appearing in program order before a spin_lock() operation -+ * can be reordered with accesses inside the critical section, by virtue -+ * of arch_spin_lock being constructed using acquire semantics. -+ * -+ * In cases where this is problematic (e.g. try_to_wake_up), an -+ * smp_mb__before_spinlock() can restore the required ordering. -+ */ -+#define smp_mb__before_spinlock() smp_mb() -+ - #endif /* __ASM_SPINLOCK_H */ -diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h -index 68cf638faf48..b1ec1fa06463 100644 ---- a/arch/avr32/include/asm/uaccess.h -+++ b/arch/avr32/include/asm/uaccess.h -@@ -74,7 +74,7 @@ extern __kernel_size_t __copy_user(void *to, const void *from, - - extern __kernel_size_t copy_to_user(void __user *to, const void *from, - __kernel_size_t n); --extern __kernel_size_t copy_from_user(void *to, const void __user *from, -+extern __kernel_size_t ___copy_from_user(void *to, const void __user *from, - __kernel_size_t n); - - static inline __kernel_size_t __copy_to_user(void __user *to, const void *from, -@@ -88,6 +88,15 @@ static inline __kernel_size_t __copy_from_user(void *to, - { - return __copy_user(to, (const void __force *)from, n); - } -+static inline __kernel_size_t copy_from_user(void *to, -+ const void __user *from, -+ __kernel_size_t n) -+{ -+ size_t res = ___copy_from_user(to, from, n); -+ if (unlikely(res)) -+ memset(to + (n - res), 0, res); -+ return res; -+} - - #define __copy_to_user_inatomic __copy_to_user - #define __copy_from_user_inatomic __copy_from_user -diff --git a/arch/avr32/kernel/avr32_ksyms.c b/arch/avr32/kernel/avr32_ksyms.c -index d93ead02daed..7c6cf14f0985 100644 ---- a/arch/avr32/kernel/avr32_ksyms.c -+++ b/arch/avr32/kernel/avr32_ksyms.c -@@ -36,7 +36,7 @@ EXPORT_SYMBOL(copy_page); - /* - * Userspace access stuff. - */ --EXPORT_SYMBOL(copy_from_user); -+EXPORT_SYMBOL(___copy_from_user); - EXPORT_SYMBOL(copy_to_user); - EXPORT_SYMBOL(__copy_user); - EXPORT_SYMBOL(strncpy_from_user); -diff --git a/arch/avr32/lib/copy_user.S b/arch/avr32/lib/copy_user.S -index ea59c04b07de..075373471da1 100644 ---- a/arch/avr32/lib/copy_user.S -+++ b/arch/avr32/lib/copy_user.S -@@ -23,13 +23,13 @@ - */ - .text - .align 1 -- .global copy_from_user -- .type copy_from_user, @function --copy_from_user: -+ .global ___copy_from_user -+ .type ___copy_from_user, @function -+___copy_from_user: - branch_if_kernel r8, __copy_user - ret_if_privileged r8, r11, r10, r10 - rjmp __copy_user -- .size copy_from_user, . - copy_from_user -+ .size ___copy_from_user, . - ___copy_from_user - - .global copy_to_user - .type copy_to_user, @function -diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h -index 90612a7f2cf3..8cd0184ea9ef 100644 ---- a/arch/blackfin/include/asm/uaccess.h -+++ b/arch/blackfin/include/asm/uaccess.h -@@ -177,11 +177,12 @@ static inline int bad_user_access_length(void) - static inline unsigned long __must_check - copy_from_user(void *to, const void __user *from, unsigned long n) - { -- if (access_ok(VERIFY_READ, from, n)) -+ if (likely(access_ok(VERIFY_READ, from, n))) { - memcpy(to, (const void __force *)from, n); -- else -- return n; -- return 0; -+ return 0; -+ } -+ memset(to, 0, n); -+ return n; - } - - static inline unsigned long __must_check -diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h -index e3530d0f13ee..56c7d5750abd 100644 ---- a/arch/cris/include/asm/uaccess.h -+++ b/arch/cris/include/asm/uaccess.h -@@ -194,30 +194,6 @@ extern unsigned long __copy_user(void __user *to, const void *from, unsigned lon - extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n); - extern unsigned long __do_clear_user(void __user *to, unsigned long n); - --static inline unsigned long --__generic_copy_to_user(void __user *to, const void *from, unsigned long n) --{ -- if (access_ok(VERIFY_WRITE, to, n)) -- return __copy_user(to, from, n); -- return n; --} -- --static inline unsigned long --__generic_copy_from_user(void *to, const void __user *from, unsigned long n) --{ -- if (access_ok(VERIFY_READ, from, n)) -- return __copy_user_zeroing(to, from, n); -- return n; --} -- --static inline unsigned long --__generic_clear_user(void __user *to, unsigned long n) --{ -- if (access_ok(VERIFY_WRITE, to, n)) -- return __do_clear_user(to, n); -- return n; --} -- - static inline long - __strncpy_from_user(char *dst, const char __user *src, long count) - { -@@ -282,7 +258,7 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n) - else if (n == 24) - __asm_copy_from_user_24(to, from, ret); - else -- ret = __generic_copy_from_user(to, from, n); -+ ret = __copy_user_zeroing(to, from, n); - - return ret; - } -@@ -333,7 +309,7 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n) - else if (n == 24) - __asm_copy_to_user_24(to, from, ret); - else -- ret = __generic_copy_to_user(to, from, n); -+ ret = __copy_user(to, from, n); - - return ret; - } -@@ -366,26 +342,43 @@ __constant_clear_user(void __user *to, unsigned long n) - else if (n == 24) - __asm_clear_24(to, ret); - else -- ret = __generic_clear_user(to, n); -+ ret = __do_clear_user(to, n); - - return ret; - } - - --#define clear_user(to, n) \ -- (__builtin_constant_p(n) ? \ -- __constant_clear_user(to, n) : \ -- __generic_clear_user(to, n)) -+static inline size_t clear_user(void __user *to, size_t n) -+{ -+ if (unlikely(!access_ok(VERIFY_WRITE, to, n))) -+ return n; -+ if (__builtin_constant_p(n)) -+ return __constant_clear_user(to, n); -+ else -+ return __do_clear_user(to, n); -+} - --#define copy_from_user(to, from, n) \ -- (__builtin_constant_p(n) ? \ -- __constant_copy_from_user(to, from, n) : \ -- __generic_copy_from_user(to, from, n)) -+static inline size_t copy_from_user(void *to, const void __user *from, size_t n) -+{ -+ if (unlikely(!access_ok(VERIFY_READ, from, n))) { -+ memset(to, 0, n); -+ return n; -+ } -+ if (__builtin_constant_p(n)) -+ return __constant_copy_from_user(to, from, n); -+ else -+ return __copy_user_zeroing(to, from, n); -+} - --#define copy_to_user(to, from, n) \ -- (__builtin_constant_p(n) ? \ -- __constant_copy_to_user(to, from, n) : \ -- __generic_copy_to_user(to, from, n)) -+static inline size_t copy_to_user(void __user *to, const void *from, size_t n) -+{ -+ if (unlikely(!access_ok(VERIFY_WRITE, to, n))) -+ return n; -+ if (__builtin_constant_p(n)) -+ return __constant_copy_to_user(to, from, n); -+ else -+ return __copy_user(to, from, n); -+} - - /* We let the __ versions of copy_from/to_user inline, because they're often - * used in fast paths and have only a small space overhead. -diff --git a/arch/frv/include/asm/uaccess.h b/arch/frv/include/asm/uaccess.h -index 3ac9a59d65d4..87d9e34c5df8 100644 ---- a/arch/frv/include/asm/uaccess.h -+++ b/arch/frv/include/asm/uaccess.h -@@ -263,19 +263,25 @@ do { \ - extern long __memset_user(void *dst, unsigned long count); - extern long __memcpy_user(void *dst, const void *src, unsigned long count); - --#define clear_user(dst,count) __memset_user(____force(dst), (count)) -+#define __clear_user(dst,count) __memset_user(____force(dst), (count)) - #define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), ____force(from), (n)) - #define __copy_to_user_inatomic(to, from, n) __memcpy_user(____force(to), (from), (n)) - - #else - --#define clear_user(dst,count) (memset(____force(dst), 0, (count)), 0) -+#define __clear_user(dst,count) (memset(____force(dst), 0, (count)), 0) - #define __copy_from_user_inatomic(to, from, n) (memcpy((to), ____force(from), (n)), 0) - #define __copy_to_user_inatomic(to, from, n) (memcpy(____force(to), (from), (n)), 0) - - #endif - --#define __clear_user clear_user -+static inline unsigned long __must_check -+clear_user(void __user *to, unsigned long n) -+{ -+ if (likely(__access_ok(to, n))) -+ n = __clear_user(to, n); -+ return n; -+} - - static inline unsigned long __must_check - __copy_to_user(void __user *to, const void *from, unsigned long n) -diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h -index f000a382bc7f..f61cfb28e9f2 100644 ---- a/arch/hexagon/include/asm/uaccess.h -+++ b/arch/hexagon/include/asm/uaccess.h -@@ -103,7 +103,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, - { - long res = __strnlen_user(src, n); - -- /* return from strnlen can't be zero -- that would be rubbish. */ -+ if (unlikely(!res)) -+ return -EFAULT; - - if (res > n) { - copy_from_user(dst, src, n); -diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h -index 4f3fb6ccbf21..40c2027a2bf4 100644 ---- a/arch/ia64/include/asm/uaccess.h -+++ b/arch/ia64/include/asm/uaccess.h -@@ -263,17 +263,15 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) - __cu_len; \ - }) - --#define copy_from_user(to, from, n) \ --({ \ -- void *__cu_to = (to); \ -- const void __user *__cu_from = (from); \ -- long __cu_len = (n); \ -- \ -- __chk_user_ptr(__cu_from); \ -- if (__access_ok(__cu_from, __cu_len, get_fs())) \ -- __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ -- __cu_len; \ --}) -+static inline unsigned long -+copy_from_user(void *to, const void __user *from, unsigned long n) -+{ -+ if (likely(__access_ok(from, n, get_fs()))) -+ n = __copy_user((__force void __user *) to, from, n); -+ else -+ memset(to, 0, n); -+ return n; -+} - - #define __copy_in_user(to, from, size) __copy_user((to), (from), (size)) - -diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h -index cac7014daef3..6f8982157a75 100644 ---- a/arch/m32r/include/asm/uaccess.h -+++ b/arch/m32r/include/asm/uaccess.h -@@ -219,7 +219,7 @@ extern int fixup_exception(struct pt_regs *regs); - #define __get_user_nocheck(x, ptr, size) \ - ({ \ - long __gu_err = 0; \ -- unsigned long __gu_val; \ -+ unsigned long __gu_val = 0; \ - might_fault(); \ - __get_user_size(__gu_val, (ptr), (size), __gu_err); \ - (x) = (__force __typeof__(*(ptr)))__gu_val; \ -diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h -index 8282cbce7e39..273e61225c27 100644 ---- a/arch/metag/include/asm/uaccess.h -+++ b/arch/metag/include/asm/uaccess.h -@@ -204,8 +204,9 @@ extern unsigned long __must_check __copy_user_zeroing(void *to, - static inline unsigned long - copy_from_user(void *to, const void __user *from, unsigned long n) - { -- if (access_ok(VERIFY_READ, from, n)) -+ if (likely(access_ok(VERIFY_READ, from, n))) - return __copy_user_zeroing(to, from, n); -+ memset(to, 0, n); - return n; - } - -diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h -index 331b0d35f89c..826676778094 100644 ---- a/arch/microblaze/include/asm/uaccess.h -+++ b/arch/microblaze/include/asm/uaccess.h -@@ -227,7 +227,7 @@ extern long __user_bad(void); - - #define __get_user(x, ptr) \ - ({ \ -- unsigned long __gu_val; \ -+ unsigned long __gu_val = 0; \ - /*unsigned long __gu_ptr = (unsigned long)(ptr);*/ \ - long __gu_err; \ - switch (sizeof(*(ptr))) { \ -@@ -373,10 +373,13 @@ extern long __user_bad(void); - static inline long copy_from_user(void *to, - const void __user *from, unsigned long n) - { -+ unsigned long res = n; - might_fault(); -- if (access_ok(VERIFY_READ, from, n)) -- return __copy_from_user(to, from, n); -- return n; -+ if (likely(access_ok(VERIFY_READ, from, n))) -+ res = __copy_from_user(to, from, n); -+ if (unlikely(res)) -+ memset(to + (n - res), 0, res); -+ return res; - } - - #define __copy_to_user(to, from, n) \ -diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h -index 095ecafe6bd3..c74c32ccc647 100644 ---- a/arch/mips/include/asm/uaccess.h -+++ b/arch/mips/include/asm/uaccess.h -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - - /* -@@ -1170,6 +1171,8 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n); - __cu_len = __invoke_copy_from_user(__cu_to, \ - __cu_from, \ - __cu_len); \ -+ } else { \ -+ memset(__cu_to, 0, __cu_len); \ - } \ - } \ - __cu_len; \ -diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c -index 7a7ed9ca01bb..eff71c75dc27 100644 ---- a/arch/mips/kvm/tlb.c -+++ b/arch/mips/kvm/tlb.c -@@ -152,7 +152,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn) - srcu_idx = srcu_read_lock(&kvm->srcu); - pfn = kvm_mips_gfn_to_pfn(kvm, gfn); - -- if (kvm_mips_is_error_pfn(pfn)) { -+ if (is_error_noslot_pfn(pfn)) { - kvm_err("Couldn't get pfn for gfn %#" PRIx64 "!\n", gfn); - err = -EFAULT; - goto out; -diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h -index 537278746a15..4af43d9ba495 100644 ---- a/arch/mn10300/include/asm/uaccess.h -+++ b/arch/mn10300/include/asm/uaccess.h -@@ -181,6 +181,7 @@ struct __large_struct { unsigned long buf[100]; }; - "2:\n" \ - " .section .fixup,\"ax\"\n" \ - "3:\n\t" \ -+ " mov 0,%1\n" \ - " mov %3,%0\n" \ - " jmp 2b\n" \ - " .previous\n" \ -diff --git a/arch/mn10300/lib/usercopy.c b/arch/mn10300/lib/usercopy.c -index 7826e6c364e7..ce8899e5e171 100644 ---- a/arch/mn10300/lib/usercopy.c -+++ b/arch/mn10300/lib/usercopy.c -@@ -9,7 +9,7 @@ - * as published by the Free Software Foundation; either version - * 2 of the Licence, or (at your option) any later version. - */ --#include -+#include - - unsigned long - __generic_copy_to_user(void *to, const void *from, unsigned long n) -@@ -24,6 +24,8 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n) - { - if (access_ok(VERIFY_READ, from, n)) - __copy_user_zeroing(to, from, n); -+ else -+ memset(to, 0, n); - return n; - } - -diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h -index caa51ff85a3c..0ab82324c817 100644 ---- a/arch/nios2/include/asm/uaccess.h -+++ b/arch/nios2/include/asm/uaccess.h -@@ -102,9 +102,12 @@ extern long __copy_to_user(void __user *to, const void *from, unsigned long n); - static inline long copy_from_user(void *to, const void __user *from, - unsigned long n) - { -- if (!access_ok(VERIFY_READ, from, n)) -- return n; -- return __copy_from_user(to, from, n); -+ unsigned long res = n; -+ if (access_ok(VERIFY_READ, from, n)) -+ res = __copy_from_user(to, from, n); -+ if (unlikely(res)) -+ memset(to + (n - res), 0, res); -+ return res; - } - - static inline long copy_to_user(void __user *to, const void *from, -@@ -139,7 +142,7 @@ extern long strnlen_user(const char __user *s, long n); - - #define __get_user_unknown(val, size, ptr, err) do { \ - err = 0; \ -- if (copy_from_user(&(val), ptr, size)) { \ -+ if (__copy_from_user(&(val), ptr, size)) { \ - err = -EFAULT; \ - } \ - } while (0) -@@ -166,7 +169,7 @@ do { \ - ({ \ - long __gu_err = -EFAULT; \ - const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ -- unsigned long __gu_val; \ -+ unsigned long __gu_val = 0; \ - __get_user_common(__gu_val, sizeof(*(ptr)), __gu_ptr, __gu_err);\ - (x) = (__force __typeof__(x))__gu_val; \ - __gu_err; \ -diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h -index a6bd07ca3d6c..5cc6b4f1b795 100644 ---- a/arch/openrisc/include/asm/uaccess.h -+++ b/arch/openrisc/include/asm/uaccess.h -@@ -273,28 +273,20 @@ __copy_tofrom_user(void *to, const void *from, unsigned long size); - static inline unsigned long - copy_from_user(void *to, const void *from, unsigned long n) - { -- unsigned long over; -- -- if (access_ok(VERIFY_READ, from, n)) -- return __copy_tofrom_user(to, from, n); -- if ((unsigned long)from < TASK_SIZE) { -- over = (unsigned long)from + n - TASK_SIZE; -- return __copy_tofrom_user(to, from, n - over) + over; -- } -- return n; -+ unsigned long res = n; -+ -+ if (likely(access_ok(VERIFY_READ, from, n))) -+ res = __copy_tofrom_user(to, from, n); -+ if (unlikely(res)) -+ memset(to + (n - res), 0, res); -+ return res; - } - - static inline unsigned long - copy_to_user(void *to, const void *from, unsigned long n) - { -- unsigned long over; -- -- if (access_ok(VERIFY_WRITE, to, n)) -- return __copy_tofrom_user(to, from, n); -- if ((unsigned long)to < TASK_SIZE) { -- over = (unsigned long)to + n - TASK_SIZE; -- return __copy_tofrom_user(to, from, n - over) + over; -- } -+ if (likely(access_ok(VERIFY_WRITE, to, n))) -+ n = __copy_tofrom_user(to, from, n); - return n; - } - -@@ -303,13 +295,8 @@ extern unsigned long __clear_user(void *addr, unsigned long size); - static inline __must_check unsigned long - clear_user(void *addr, unsigned long size) - { -- -- if (access_ok(VERIFY_WRITE, addr, size)) -- return __clear_user(addr, size); -- if ((unsigned long)addr < TASK_SIZE) { -- unsigned long over = (unsigned long)addr + size - TASK_SIZE; -- return __clear_user(addr, size - over) + over; -- } -+ if (likely(access_ok(VERIFY_WRITE, addr, size))) -+ size = __clear_user(addr, size); - return size; - } - -diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h -index 1960b87c1c8b..4ad51465890b 100644 ---- a/arch/parisc/include/asm/uaccess.h -+++ b/arch/parisc/include/asm/uaccess.h -@@ -10,6 +10,7 @@ - #include - - #include -+#include - - #define VERIFY_READ 0 - #define VERIFY_WRITE 1 -@@ -245,13 +246,14 @@ static inline unsigned long __must_check copy_from_user(void *to, - unsigned long n) - { - int sz = __compiletime_object_size(to); -- int ret = -EFAULT; -+ unsigned long ret = n; - - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) - ret = __copy_from_user(to, from, n); - else - copy_from_user_overflow(); -- -+ if (unlikely(ret)) -+ memset(to + (n - ret), 0, ret); - return ret; - } - -diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h -index 2a8ebae0936b..a5ffe0207c16 100644 ---- a/arch/powerpc/include/asm/uaccess.h -+++ b/arch/powerpc/include/asm/uaccess.h -@@ -323,30 +323,17 @@ extern unsigned long __copy_tofrom_user(void __user *to, - static inline unsigned long copy_from_user(void *to, - const void __user *from, unsigned long n) - { -- unsigned long over; -- -- if (access_ok(VERIFY_READ, from, n)) -+ if (likely(access_ok(VERIFY_READ, from, n))) - return __copy_tofrom_user((__force void __user *)to, from, n); -- if ((unsigned long)from < TASK_SIZE) { -- over = (unsigned long)from + n - TASK_SIZE; -- return __copy_tofrom_user((__force void __user *)to, from, -- n - over) + over; -- } -+ memset(to, 0, n); - return n; - } - - static inline unsigned long copy_to_user(void __user *to, - const void *from, unsigned long n) - { -- unsigned long over; -- - if (access_ok(VERIFY_WRITE, to, n)) - return __copy_tofrom_user(to, (__force void __user *)from, n); -- if ((unsigned long)to < TASK_SIZE) { -- over = (unsigned long)to + n - TASK_SIZE; -- return __copy_tofrom_user(to, (__force void __user *)from, -- n - over) + over; -- } - return n; - } - -@@ -437,10 +424,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long size) - might_fault(); - if (likely(access_ok(VERIFY_WRITE, addr, size))) - return __clear_user(addr, size); -- if ((unsigned long)addr < TASK_SIZE) { -- unsigned long over = (unsigned long)addr + size - TASK_SIZE; -- return __clear_user(addr, size - over) + over; -- } - return size; - } - -diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S -index a94f155db78e..edba294620db 100644 ---- a/arch/powerpc/kernel/entry_64.S -+++ b/arch/powerpc/kernel/entry_64.S -@@ -334,13 +334,13 @@ syscall_exit_work: - tabort_syscall: - /* Firstly we need to enable TM in the kernel */ - mfmsr r10 -- li r13, 1 -- rldimi r10, r13, MSR_TM_LG, 63-MSR_TM_LG -+ li r9, 1 -+ rldimi r10, r9, MSR_TM_LG, 63-MSR_TM_LG - mtmsrd r10, 0 - - /* tabort, this dooms the transaction, nothing else */ -- li r13, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT) -- TABORT(R13) -+ li r9, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT) -+ TABORT(R9) - - /* - * Return directly to userspace. We have corrupted user register state, -@@ -348,8 +348,8 @@ tabort_syscall: - * resume after the tbegin of the aborted transaction with the - * checkpointed register state. - */ -- li r13, MSR_RI -- andc r10, r10, r13 -+ li r9, MSR_RI -+ andc r10, r10, r9 - mtmsrd r10, 1 - mtspr SPRN_SRR0, r11 - mtspr SPRN_SRR1, r12 -diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S -index 736d18b3cefd..4c48b487698c 100644 ---- a/arch/powerpc/mm/slb_low.S -+++ b/arch/powerpc/mm/slb_low.S -@@ -113,7 +113,12 @@ BEGIN_FTR_SECTION - END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) - b slb_finish_load_1T - --0: -+0: /* -+ * For userspace addresses, make sure this is region 0. -+ */ -+ cmpdi r9, 0 -+ bne 8f -+ - /* when using slices, we extract the psize off the slice bitmaps - * and then we need to get the sllp encoding off the mmu_psize_defs - * array. -diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c -index 2ee96431f736..4c827826c05e 100644 ---- a/arch/powerpc/platforms/powernv/opal-dump.c -+++ b/arch/powerpc/platforms/powernv/opal-dump.c -@@ -370,6 +370,7 @@ static irqreturn_t process_dump(int irq, void *data) - uint32_t dump_id, dump_size, dump_type; - struct dump_obj *dump; - char name[22]; -+ struct kobject *kobj; - - rc = dump_read_info(&dump_id, &dump_size, &dump_type); - if (rc != OPAL_SUCCESS) -@@ -381,8 +382,12 @@ static irqreturn_t process_dump(int irq, void *data) - * that gracefully and not create two conflicting - * entries. - */ -- if (kset_find_obj(dump_kset, name)) -+ kobj = kset_find_obj(dump_kset, name); -+ if (kobj) { -+ /* Drop reference added by kset_find_obj() */ -+ kobject_put(kobj); - return 0; -+ } - - dump = create_dump_obj(dump_id, dump_size, dump_type); - if (!dump) -diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c -index 37f959bf392e..f2344cbd2f46 100644 ---- a/arch/powerpc/platforms/powernv/opal-elog.c -+++ b/arch/powerpc/platforms/powernv/opal-elog.c -@@ -247,6 +247,7 @@ static irqreturn_t elog_event(int irq, void *data) - uint64_t elog_type; - int rc; - char name[2+16+1]; -+ struct kobject *kobj; - - rc = opal_get_elog_size(&id, &size, &type); - if (rc != OPAL_SUCCESS) { -@@ -269,8 +270,12 @@ static irqreturn_t elog_event(int irq, void *data) - * that gracefully and not create two conflicting - * entries. - */ -- if (kset_find_obj(elog_kset, name)) -+ kobj = kset_find_obj(elog_kset, name); -+ if (kobj) { -+ /* Drop reference added by kset_find_obj() */ -+ kobject_put(kobj); - return IRQ_HANDLED; -+ } - - create_elog_obj(log_id, elog_size, elog_type); - -diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h -index 9dd4cc47ddc7..5c7381c5ad7f 100644 ---- a/arch/s390/include/asm/uaccess.h -+++ b/arch/s390/include/asm/uaccess.h -@@ -215,28 +215,28 @@ int __put_user_bad(void) __attribute__((noreturn)); - __chk_user_ptr(ptr); \ - switch (sizeof(*(ptr))) { \ - case 1: { \ -- unsigned char __x; \ -+ unsigned char __x = 0; \ - __gu_err = __get_user_fn(&__x, ptr, \ - sizeof(*(ptr))); \ - (x) = *(__force __typeof__(*(ptr)) *) &__x; \ - break; \ - }; \ - case 2: { \ -- unsigned short __x; \ -+ unsigned short __x = 0; \ - __gu_err = __get_user_fn(&__x, ptr, \ - sizeof(*(ptr))); \ - (x) = *(__force __typeof__(*(ptr)) *) &__x; \ - break; \ - }; \ - case 4: { \ -- unsigned int __x; \ -+ unsigned int __x = 0; \ - __gu_err = __get_user_fn(&__x, ptr, \ - sizeof(*(ptr))); \ - (x) = *(__force __typeof__(*(ptr)) *) &__x; \ - break; \ - }; \ - case 8: { \ -- unsigned long long __x; \ -+ unsigned long long __x = 0; \ - __gu_err = __get_user_fn(&__x, ptr, \ - sizeof(*(ptr))); \ - (x) = *(__force __typeof__(*(ptr)) *) &__x; \ -diff --git a/arch/score/include/asm/uaccess.h b/arch/score/include/asm/uaccess.h -index 20a3591225cc..01aec8ccde83 100644 ---- a/arch/score/include/asm/uaccess.h -+++ b/arch/score/include/asm/uaccess.h -@@ -163,7 +163,7 @@ do { \ - __get_user_asm(val, "lw", ptr); \ - break; \ - case 8: \ -- if ((copy_from_user((void *)&val, ptr, 8)) == 0) \ -+ if (__copy_from_user((void *)&val, ptr, 8) == 0) \ - __gu_err = 0; \ - else \ - __gu_err = -EFAULT; \ -@@ -188,6 +188,8 @@ do { \ - \ - if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \ - __get_user_common((x), size, __gu_ptr); \ -+ else \ -+ (x) = 0; \ - \ - __gu_err; \ - }) -@@ -201,6 +203,7 @@ do { \ - "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3:li %0, %4\n" \ -+ "li %1, 0\n" \ - "j 2b\n" \ - ".previous\n" \ - ".section __ex_table,\"a\"\n" \ -@@ -298,35 +301,34 @@ extern int __copy_tofrom_user(void *to, const void *from, unsigned long len); - static inline unsigned long - copy_from_user(void *to, const void *from, unsigned long len) - { -- unsigned long over; -+ unsigned long res = len; - -- if (access_ok(VERIFY_READ, from, len)) -- return __copy_tofrom_user(to, from, len); -+ if (likely(access_ok(VERIFY_READ, from, len))) -+ res = __copy_tofrom_user(to, from, len); - -- if ((unsigned long)from < TASK_SIZE) { -- over = (unsigned long)from + len - TASK_SIZE; -- return __copy_tofrom_user(to, from, len - over) + over; -- } -- return len; -+ if (unlikely(res)) -+ memset(to + (len - res), 0, res); -+ -+ return res; - } - - static inline unsigned long - copy_to_user(void *to, const void *from, unsigned long len) - { -- unsigned long over; -- -- if (access_ok(VERIFY_WRITE, to, len)) -- return __copy_tofrom_user(to, from, len); -+ if (likely(access_ok(VERIFY_WRITE, to, len))) -+ len = __copy_tofrom_user(to, from, len); - -- if ((unsigned long)to < TASK_SIZE) { -- over = (unsigned long)to + len - TASK_SIZE; -- return __copy_tofrom_user(to, from, len - over) + over; -- } - return len; - } - --#define __copy_from_user(to, from, len) \ -- __copy_tofrom_user((to), (from), (len)) -+static inline unsigned long -+__copy_from_user(void *to, const void *from, unsigned long len) -+{ -+ unsigned long left = __copy_tofrom_user(to, from, len); -+ if (unlikely(left)) -+ memset(to + (len - left), 0, left); -+ return left; -+} - - #define __copy_to_user(to, from, len) \ - __copy_tofrom_user((to), (from), (len)) -@@ -340,17 +342,17 @@ __copy_to_user_inatomic(void *to, const void *from, unsigned long len) - static inline unsigned long - __copy_from_user_inatomic(void *to, const void *from, unsigned long len) - { -- return __copy_from_user(to, from, len); -+ return __copy_tofrom_user(to, from, len); - } - --#define __copy_in_user(to, from, len) __copy_from_user(to, from, len) -+#define __copy_in_user(to, from, len) __copy_tofrom_user(to, from, len) - - static inline unsigned long - copy_in_user(void *to, const void *from, unsigned long len) - { - if (access_ok(VERIFY_READ, from, len) && - access_ok(VERFITY_WRITE, to, len)) -- return copy_from_user(to, from, len); -+ return __copy_tofrom_user(to, from, len); - } - - /* -diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h -index a49635c51266..92ade79ac427 100644 ---- a/arch/sh/include/asm/uaccess.h -+++ b/arch/sh/include/asm/uaccess.h -@@ -151,7 +151,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n) - __kernel_size_t __copy_size = (__kernel_size_t) n; - - if (__copy_size && __access_ok(__copy_from, __copy_size)) -- return __copy_user(to, from, __copy_size); -+ __copy_size = __copy_user(to, from, __copy_size); -+ -+ if (unlikely(__copy_size)) -+ memset(to + (n - __copy_size), 0, __copy_size); - - return __copy_size; - } -diff --git a/arch/sh/include/asm/uaccess_64.h b/arch/sh/include/asm/uaccess_64.h -index c01376c76b86..ca5073dd4596 100644 ---- a/arch/sh/include/asm/uaccess_64.h -+++ b/arch/sh/include/asm/uaccess_64.h -@@ -24,6 +24,7 @@ - #define __get_user_size(x,ptr,size,retval) \ - do { \ - retval = 0; \ -+ x = 0; \ - switch (size) { \ - case 1: \ - retval = __get_user_asm_b((void *)&x, \ -diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h -index 64ee103dc29d..dfb542c7cc71 100644 ---- a/arch/sparc/include/asm/uaccess_32.h -+++ b/arch/sparc/include/asm/uaccess_32.h -@@ -328,8 +328,10 @@ static inline unsigned long copy_from_user(void *to, const void __user *from, un - { - if (n && __access_ok((unsigned long) from, n)) - return __copy_user((__force void __user *) to, from, n); -- else -+ else { -+ memset(to, 0, n); - return n; -+ } - } - - static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n) -diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config -index 4e2ecfa23c15..4b429df40d7a 100644 ---- a/arch/x86/configs/tiny.config -+++ b/arch/x86/configs/tiny.config -@@ -1 +1,3 @@ - CONFIG_NOHIGHMEM=y -+# CONFIG_HIGHMEM4G is not set -+# CONFIG_HIGHMEM64G is not set -diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h -index 09b1b0ab94b7..d42252ce9b4d 100644 ---- a/arch/x86/include/asm/uaccess.h -+++ b/arch/x86/include/asm/uaccess.h -@@ -394,7 +394,11 @@ do { \ - #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ - asm volatile("1: mov"itype" %1,%"rtype"0\n" \ - "2:\n" \ -- _ASM_EXTABLE_EX(1b, 2b) \ -+ ".section .fixup,\"ax\"\n" \ -+ "3:xor"itype" %"rtype"0,%"rtype"0\n" \ -+ " jmp 2b\n" \ -+ ".previous\n" \ -+ _ASM_EXTABLE_EX(1b, 3b) \ - : ltype(x) : "m" (__m(addr))) - - #define __put_user_nocheck(x, ptr, size) \ -diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c -index a8816b325162..6cb5834062a3 100644 ---- a/arch/x86/kernel/cpu/amd.c -+++ b/arch/x86/kernel/cpu/amd.c -@@ -656,6 +656,17 @@ static void init_amd_gh(struct cpuinfo_x86 *c) - set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); - } - -+#define MSR_AMD64_DE_CFG 0xC0011029 -+ -+static void init_amd_ln(struct cpuinfo_x86 *c) -+{ -+ /* -+ * Apply erratum 665 fix unconditionally so machines without a BIOS -+ * fix work. -+ */ -+ msr_set_bit(MSR_AMD64_DE_CFG, 31); -+} -+ - static void init_amd_bd(struct cpuinfo_x86 *c) - { - u64 value; -@@ -713,6 +724,7 @@ static void init_amd(struct cpuinfo_x86 *c) - case 6: init_amd_k7(c); break; - case 0xf: init_amd_k8(c); break; - case 0x10: init_amd_gh(c); break; -+ case 0x12: init_amd_ln(c); break; - case 0x15: init_amd_bd(c); break; - } - -diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c -index c2130aef3f9d..f534a0e3af53 100644 ---- a/arch/x86/kernel/paravirt.c -+++ b/arch/x86/kernel/paravirt.c -@@ -55,12 +55,12 @@ asm (".pushsection .entry.text, \"ax\"\n" - ".popsection"); - - /* identity function, which can be inlined */ --u32 _paravirt_ident_32(u32 x) -+u32 notrace _paravirt_ident_32(u32 x) - { - return x; - } - --u64 _paravirt_ident_64(u64 x) -+u64 notrace _paravirt_ident_64(u64 x) - { - return x; - } -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index be222666b1c2..d7cb9577fa31 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -2735,7 +2735,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) - } - - kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); -- vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD; - } - - void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) -diff --git a/crypto/cryptd.c b/crypto/cryptd.c -index c81861b1350b..e7aa904cb20b 100644 ---- a/crypto/cryptd.c -+++ b/crypto/cryptd.c -@@ -594,9 +594,14 @@ static int cryptd_hash_export(struct ahash_request *req, void *out) - - static int cryptd_hash_import(struct ahash_request *req, const void *in) - { -- struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req); -+ struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); -+ struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm); -+ struct shash_desc *desc = cryptd_shash_desc(req); -+ -+ desc->tfm = ctx->child; -+ desc->flags = req->base.flags; - -- return crypto_shash_import(&rctx->desc, in); -+ return crypto_shash_import(desc, in); - } - - static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, -diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c -index 7082c7268845..0f54cb7ddcbb 100644 ---- a/drivers/bus/arm-ccn.c -+++ b/drivers/bus/arm-ccn.c -@@ -187,6 +187,7 @@ struct arm_ccn { - struct arm_ccn_component *xp; - - struct arm_ccn_dt dt; -+ int mn_id; - }; - - -@@ -326,6 +327,7 @@ struct arm_ccn_pmu_event { - static ssize_t arm_ccn_pmu_event_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -+ struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); - struct arm_ccn_pmu_event *event = container_of(attr, - struct arm_ccn_pmu_event, attr); - ssize_t res; -@@ -352,6 +354,9 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev, - res += snprintf(buf + res, PAGE_SIZE - res, - ",cmp_l=?,cmp_h=?,mask=?"); - break; -+ case CCN_TYPE_MN: -+ res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); -+ break; - default: - res += snprintf(buf + res, PAGE_SIZE - res, ",node=?"); - break; -@@ -381,9 +386,9 @@ static umode_t arm_ccn_pmu_events_is_visible(struct kobject *kobj, - } - - static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = { -- CCN_EVENT_MN(eobarrier, "dir=0,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE), -- CCN_EVENT_MN(ecbarrier, "dir=0,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE), -- CCN_EVENT_MN(dvmop, "dir=0,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE), -+ CCN_EVENT_MN(eobarrier, "dir=1,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE), -+ CCN_EVENT_MN(ecbarrier, "dir=1,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE), -+ CCN_EVENT_MN(dvmop, "dir=1,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE), - CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY), - CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY), - CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY), -@@ -757,6 +762,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) - - /* Validate node/xp vs topology */ - switch (type) { -+ case CCN_TYPE_MN: -+ if (node_xp != ccn->mn_id) { -+ dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp); -+ return -EINVAL; -+ } -+ break; - case CCN_TYPE_XP: - if (node_xp >= ccn->num_xps) { - dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp); -@@ -884,6 +895,10 @@ static void arm_ccn_pmu_xp_dt_config(struct perf_event *event, int enable) - struct arm_ccn_component *xp; - u32 val, dt_cfg; - -+ /* Nothing to do for cycle counter */ -+ if (hw->idx == CCN_IDX_PMU_CYCLE_COUNTER) -+ return; -+ - if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP) - xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)]; - else -@@ -986,7 +1001,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event) - - /* Comparison values */ - writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp)); -- writel((cmp_l >> 32) & 0xefffffff, -+ writel((cmp_l >> 32) & 0x7fffffff, - source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4); - writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp)); - writel((cmp_h >> 32) & 0x0fffffff, -@@ -994,7 +1009,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event) - - /* Mask */ - writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp)); -- writel((mask_l >> 32) & 0xefffffff, -+ writel((mask_l >> 32) & 0x7fffffff, - source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4); - writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp)); - writel((mask_h >> 32) & 0x0fffffff, -@@ -1368,6 +1383,8 @@ static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region, - - switch (type) { - case CCN_TYPE_MN: -+ ccn->mn_id = id; -+ return 0; - case CCN_TYPE_DT: - return 0; - case CCN_TYPE_XP: -diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c -index 6f3719d73390..e84877a2cacc 100644 ---- a/drivers/clocksource/sun4i_timer.c -+++ b/drivers/clocksource/sun4i_timer.c -@@ -123,12 +123,16 @@ static struct clock_event_device sun4i_clockevent = { - .set_next_event = sun4i_clkevt_next_event, - }; - -+static void sun4i_timer_clear_interrupt(void) -+{ -+ writel(TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_ST_REG); -+} - - static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) - { - struct clock_event_device *evt = (struct clock_event_device *)dev_id; - -- writel(0x1, timer_base + TIMER_IRQ_ST_REG); -+ sun4i_timer_clear_interrupt(); - evt->event_handler(evt); - - return IRQ_HANDLED; -@@ -193,6 +197,9 @@ static void __init sun4i_timer_init(struct device_node *node) - /* Make sure timer is stopped before playing with interrupts */ - sun4i_clkevt_time_stop(0); - -+ /* clear timer0 interrupt */ -+ sun4i_timer_clear_interrupt(); -+ - sun4i_clockevent.cpumask = cpu_possible_mask; - sun4i_clockevent.irq = irq; - -diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -index 59d1269626b1..e231176cb66b 100644 ---- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c -@@ -316,19 +316,19 @@ atmel_hlcdc_plane_update_pos_and_size(struct atmel_hlcdc_plane *plane, - u32 *coeff_tab = heo_upscaling_ycoef; - u32 max_memsize; - -- if (state->crtc_w < state->src_w) -+ if (state->crtc_h < state->src_h) - coeff_tab = heo_downscaling_ycoef; - for (i = 0; i < ARRAY_SIZE(heo_upscaling_ycoef); i++) - atmel_hlcdc_layer_update_cfg(&plane->layer, - 33 + i, - 0xffffffff, - coeff_tab[i]); -- factor = ((8 * 256 * state->src_w) - (256 * 4)) / -- state->crtc_w; -+ factor = ((8 * 256 * state->src_h) - (256 * 4)) / -+ state->crtc_h; - factor++; -- max_memsize = ((factor * state->crtc_w) + (256 * 4)) / -+ max_memsize = ((factor * state->crtc_h) + (256 * 4)) / - 2048; -- if (max_memsize > state->src_w) -+ if (max_memsize > state->src_h) - factor--; - factor_reg |= (factor << 16) | 0x80000000; - } -diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c -index 57676f8d7ecf..a6289752be16 100644 ---- a/drivers/gpu/drm/drm_ioc32.c -+++ b/drivers/gpu/drm/drm_ioc32.c -@@ -1015,6 +1015,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, - return 0; - } - -+#if defined(CONFIG_X86) || defined(CONFIG_IA64) - typedef struct drm_mode_fb_cmd232 { - u32 fb_id; - u32 width; -@@ -1071,6 +1072,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd, - - return 0; - } -+#endif - - static drm_ioctl_compat_t *drm_compat_ioctls[] = { - [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version, -@@ -1104,7 +1106,9 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = { - [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw, - #endif - [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank, -+#if defined(CONFIG_X86) || defined(CONFIG_IA64) - [DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2, -+#endif - }; - - /** -diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c -index 17cea400ae32..d3de377dc857 100644 ---- a/drivers/gpu/drm/gma500/cdv_intel_dp.c -+++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c -@@ -220,7 +220,7 @@ i2c_dp_aux_prepare_bus(struct i2c_adapter *adapter) - * FIXME: This is the old dp aux helper, gma500 is the last driver that needs to - * be ported over to the new helper code in drm_dp_helper.c like i915 or radeon. - */ --static int __deprecated -+static int - i2c_dp_aux_add_bus(struct i2c_adapter *adapter) - { - int error; -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c -index a3254c3bcc7c..909d1d71d130 100644 ---- a/drivers/gpu/drm/i915/intel_display.c -+++ b/drivers/gpu/drm/i915/intel_display.c -@@ -2950,13 +2950,13 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier, - } - } - --unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane, -- struct drm_i915_gem_object *obj, -- unsigned int plane) -+u32 intel_plane_obj_offset(struct intel_plane *intel_plane, -+ struct drm_i915_gem_object *obj, -+ unsigned int plane) - { - const struct i915_ggtt_view *view = &i915_ggtt_view_normal; - struct i915_vma *vma; -- unsigned char *offset; -+ u64 offset; - - if (intel_rotation_90_or_270(intel_plane->base.state->rotation)) - view = &i915_ggtt_view_rotated; -@@ -2966,14 +2966,16 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane, - view->type)) - return -1; - -- offset = (unsigned char *)vma->node.start; -+ offset = vma->node.start; - - if (plane == 1) { - offset += vma->ggtt_view.rotation_info.uv_start_page * - PAGE_SIZE; - } - -- return (unsigned long)offset; -+ WARN_ON(upper_32_bits(offset)); -+ -+ return lower_32_bits(offset); - } - - static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id) -@@ -3099,7 +3101,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc, - u32 tile_height, plane_offset, plane_size; - unsigned int rotation; - int x_offset, y_offset; -- unsigned long surf_addr; -+ u32 surf_addr; - struct intel_crtc_state *crtc_state = intel_crtc->config; - struct intel_plane_state *plane_state; - int src_x = 0, src_y = 0, src_w = 0, src_h = 0; -diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h -index 67f72a7ee7cb..41442e619595 100644 ---- a/drivers/gpu/drm/i915/intel_drv.h -+++ b/drivers/gpu/drm/i915/intel_drv.h -@@ -1177,9 +1177,9 @@ void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file); - int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); - int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state); - --unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane, -- struct drm_i915_gem_object *obj, -- unsigned int plane); -+u32 intel_plane_obj_offset(struct intel_plane *intel_plane, -+ struct drm_i915_gem_object *obj, -+ unsigned int plane); - - u32 skl_plane_ctl_format(uint32_t pixel_format); - u32 skl_plane_ctl_tiling(uint64_t fb_modifier); -diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c -index 56dc132e8e20..2cc6aa072f4c 100644 ---- a/drivers/gpu/drm/i915/intel_sprite.c -+++ b/drivers/gpu/drm/i915/intel_sprite.c -@@ -195,7 +195,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, - int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); - const struct drm_intel_sprite_colorkey *key = - &to_intel_plane_state(drm_plane->state)->ckey; -- unsigned long surf_addr; -+ u32 surf_addr; - u32 tile_height, plane_offset, plane_size; - unsigned int rotation; - int x_offset, y_offset; -diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c -index 291c61a41c9a..fa24d5196615 100644 ---- a/drivers/iio/accel/bmc150-accel-core.c -+++ b/drivers/iio/accel/bmc150-accel-core.c -@@ -68,6 +68,9 @@ - #define BMC150_ACCEL_REG_PMU_BW 0x10 - #define BMC150_ACCEL_DEF_BW 125 - -+#define BMC150_ACCEL_REG_RESET 0x14 -+#define BMC150_ACCEL_RESET_VAL 0xB6 -+ - #define BMC150_ACCEL_REG_INT_MAP_0 0x19 - #define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2) - -@@ -1487,6 +1490,14 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) - int ret, i; - unsigned int val; - -+ /* -+ * Reset chip to get it in a known good state. A delay of 1.8ms after -+ * reset is required according to the data sheets of supported chips. -+ */ -+ regmap_write(data->regmap, BMC150_ACCEL_REG_RESET, -+ BMC150_ACCEL_RESET_VAL); -+ usleep_range(1800, 2500); -+ - ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); - if (ret < 0) { - dev_err(data->dev, -diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c -index 3a9f106787d2..9d72d4bcf5e9 100644 ---- a/drivers/iio/accel/kxsd9.c -+++ b/drivers/iio/accel/kxsd9.c -@@ -160,11 +160,13 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, - if (ret < 0) - goto error_ret; - *val = ret; -+ ret = IIO_VAL_INT; - break; - case IIO_CHAN_INFO_SCALE: - ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); - if (ret < 0) - goto error_ret; -+ *val = 0; - *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; - ret = IIO_VAL_INT_PLUS_MICRO; - break; -diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig -index 1e7aded53117..bda6bbe4479c 100644 ---- a/drivers/iio/adc/Kconfig -+++ b/drivers/iio/adc/Kconfig -@@ -306,6 +306,7 @@ config QCOM_SPMI_VADC - config ROCKCHIP_SARADC - tristate "Rockchip SARADC driver" - depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) -+ depends on RESET_CONTROLLER - help - Say yes here to build support for the SARADC found in SoCs from - Rockchip. -diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c -index 01d71588d752..ba82de25a797 100644 ---- a/drivers/iio/adc/ad799x.c -+++ b/drivers/iio/adc/ad799x.c -@@ -533,6 +533,7 @@ static struct attribute_group ad799x_event_attrs_group = { - static const struct iio_info ad7991_info = { - .read_raw = &ad799x_read_raw, - .driver_module = THIS_MODULE, -+ .update_scan_mode = ad799x_update_scan_mode, - }; - - static const struct iio_info ad7993_4_7_8_noirq_info = { -diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c -index 7b40925dd4ff..93986f0590ef 100644 ---- a/drivers/iio/adc/at91_adc.c -+++ b/drivers/iio/adc/at91_adc.c -@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private) - st->ts_bufferedmeasure = false; - input_report_key(st->ts_input, BTN_TOUCH, 0); - input_sync(st->ts_input); -- } else if (status & AT91_ADC_EOC(3)) { -- /* Conversion finished */ -+ } else if (status & AT91_ADC_EOC(3) && st->ts_input) { -+ /* Conversion finished and we've a touchscreen */ - if (st->ts_bufferedmeasure) { - /* - * Last measurement is always discarded, since it can -diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c -index 9c311c1e1ac7..dffff64b5989 100644 ---- a/drivers/iio/adc/rockchip_saradc.c -+++ b/drivers/iio/adc/rockchip_saradc.c -@@ -21,6 +21,8 @@ - #include - #include - #include -+#include -+#include - #include - #include - -@@ -53,6 +55,7 @@ struct rockchip_saradc { - struct clk *clk; - struct completion completion; - struct regulator *vref; -+ struct reset_control *reset; - const struct rockchip_saradc_data *data; - u16 last_val; - }; -@@ -171,6 +174,16 @@ static const struct of_device_id rockchip_saradc_match[] = { - }; - MODULE_DEVICE_TABLE(of, rockchip_saradc_match); - -+/** -+ * Reset SARADC Controller. -+ */ -+static void rockchip_saradc_reset_controller(struct reset_control *reset) -+{ -+ reset_control_assert(reset); -+ usleep_range(10, 20); -+ reset_control_deassert(reset); -+} -+ - static int rockchip_saradc_probe(struct platform_device *pdev) - { - struct rockchip_saradc *info = NULL; -@@ -199,6 +212,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev) - if (IS_ERR(info->regs)) - return PTR_ERR(info->regs); - -+ /* -+ * The reset should be an optional property, as it should work -+ * with old devicetrees as well -+ */ -+ info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb"); -+ if (IS_ERR(info->reset)) { -+ ret = PTR_ERR(info->reset); -+ if (ret != -ENOENT) -+ return ret; -+ -+ dev_dbg(&pdev->dev, "no reset control found\n"); -+ info->reset = NULL; -+ } -+ - init_completion(&info->completion); - - irq = platform_get_irq(pdev, 0); -@@ -233,6 +260,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev) - return PTR_ERR(info->vref); - } - -+ if (info->reset) -+ rockchip_saradc_reset_controller(info->reset); -+ - /* - * Use a default value for the converter clock. - * This may become user-configurable in the future. -diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c -index c1e05532d437..0470fc843d4e 100644 ---- a/drivers/iio/adc/ti_am335x_adc.c -+++ b/drivers/iio/adc/ti_am335x_adc.c -@@ -32,6 +32,7 @@ - - struct tiadc_device { - struct ti_tscadc_dev *mfd_tscadc; -+ struct mutex fifo1_lock; /* to protect fifo access */ - int channels; - u8 channel_line[8]; - u8 channel_step[8]; -@@ -360,6 +361,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, - int *val, int *val2, long mask) - { - struct tiadc_device *adc_dev = iio_priv(indio_dev); -+ int ret = IIO_VAL_INT; - int i, map_val; - unsigned int fifo1count, read, stepid; - bool found = false; -@@ -373,13 +375,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, - if (!step_en) - return -EINVAL; - -+ mutex_lock(&adc_dev->fifo1_lock); - fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); - while (fifo1count--) - tiadc_readl(adc_dev, REG_FIFO1); - - am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); - -- timeout = jiffies + usecs_to_jiffies -+ timeout = jiffies + msecs_to_jiffies - (IDLE_TIMEOUT * adc_dev->channels); - /* Wait for Fifo threshold interrupt */ - while (1) { -@@ -389,7 +392,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, - - if (time_after(jiffies, timeout)) { - am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); -- return -EAGAIN; -+ ret = -EAGAIN; -+ goto err_unlock; - } - } - map_val = adc_dev->channel_step[chan->scan_index]; -@@ -415,8 +419,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, - am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); - - if (found == false) -- return -EBUSY; -- return IIO_VAL_INT; -+ ret = -EBUSY; -+ -+err_unlock: -+ mutex_unlock(&adc_dev->fifo1_lock); -+ return ret; - } - - static const struct iio_info tiadc_info = { -@@ -485,6 +492,7 @@ static int tiadc_probe(struct platform_device *pdev) - - tiadc_step_config(indio_dev); - tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); -+ mutex_init(&adc_dev->fifo1_lock); - - err = tiadc_channel_init(indio_dev, adc_dev->channels); - if (err < 0) -diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c -index e81f434760f4..dc33c1dd5191 100644 ---- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c -+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c -@@ -56,8 +56,8 @@ static struct { - {HID_USAGE_SENSOR_ALS, 0, 1, 0}, - {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, - -- {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0}, -- {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0}, -+ {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0}, -+ {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000}, - }; - - static int pow_10(unsigned power) -diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c -index 7afd226a3321..32bb036069eb 100644 ---- a/drivers/iio/industrialio-buffer.c -+++ b/drivers/iio/industrialio-buffer.c -@@ -110,7 +110,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, - DEFINE_WAIT_FUNC(wait, woken_wake_function); - size_t datum_size; - size_t to_wait; -- int ret; -+ int ret = 0; - - if (!indio_dev->info) - return -ENODEV; -@@ -153,7 +153,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, - ret = rb->access->read_first_n(rb, n, buf); - if (ret == 0 && (filp->f_flags & O_NONBLOCK)) - ret = -EAGAIN; -- } while (ret == 0); -+ } while (ret == 0); - remove_wait_queue(&rb->pollq, &wait); - - return ret; -diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c -index 159ede61f793..7ede941e9301 100644 ---- a/drivers/iio/industrialio-core.c -+++ b/drivers/iio/industrialio-core.c -@@ -447,9 +447,8 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) - return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); - case IIO_VAL_FRACTIONAL: - tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); -- vals[1] = do_div(tmp, 1000000000LL); -- vals[0] = tmp; -- return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); -+ vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]); -+ return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1])); - case IIO_VAL_FRACTIONAL_LOG2: - tmp = (s64)vals[0] * 1000000000LL >> vals[1]; - vals[1] = do_div(tmp, 1000000000LL); -diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c -index e2f926cdcad2..a0aedda7dfd7 100644 ---- a/drivers/iio/proximity/as3935.c -+++ b/drivers/iio/proximity/as3935.c -@@ -392,7 +392,7 @@ static int as3935_probe(struct spi_device *spi) - return ret; - } - -- ret = iio_triggered_buffer_setup(indio_dev, NULL, -+ ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, - &as3935_trigger_handler, NULL); - - if (ret) { -diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h -index 94bbd8c155fc..a2d19d136099 100644 ---- a/drivers/infiniband/core/uverbs.h -+++ b/drivers/infiniband/core/uverbs.h -@@ -116,6 +116,7 @@ struct ib_uverbs_event_file { - struct ib_uverbs_file { - struct kref ref; - struct mutex mutex; -+ struct mutex cleanup_mutex; /* protect cleanup */ - struct ib_uverbs_device *device; - struct ib_ucontext *ucontext; - struct ib_event_handler event_handler; -diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c -index 24f3ca2c4ad7..d625c82d6c82 100644 ---- a/drivers/infiniband/core/uverbs_main.c -+++ b/drivers/infiniband/core/uverbs_main.c -@@ -922,6 +922,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) - file->async_file = NULL; - kref_init(&file->ref); - mutex_init(&file->mutex); -+ mutex_init(&file->cleanup_mutex); - - filp->private_data = file; - kobject_get(&dev->kobj); -@@ -947,18 +948,20 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp) - { - struct ib_uverbs_file *file = filp->private_data; - struct ib_uverbs_device *dev = file->device; -- struct ib_ucontext *ucontext = NULL; -+ -+ mutex_lock(&file->cleanup_mutex); -+ if (file->ucontext) { -+ ib_uverbs_cleanup_ucontext(file, file->ucontext); -+ file->ucontext = NULL; -+ } -+ mutex_unlock(&file->cleanup_mutex); - - mutex_lock(&file->device->lists_mutex); -- ucontext = file->ucontext; -- file->ucontext = NULL; - if (!file->is_closed) { - list_del(&file->list); - file->is_closed = 1; - } - mutex_unlock(&file->device->lists_mutex); -- if (ucontext) -- ib_uverbs_cleanup_ucontext(file, ucontext); - - if (file->async_file) - kref_put(&file->async_file->ref, ib_uverbs_release_event_file); -@@ -1172,22 +1175,30 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev, - mutex_lock(&uverbs_dev->lists_mutex); - while (!list_empty(&uverbs_dev->uverbs_file_list)) { - struct ib_ucontext *ucontext; -- - file = list_first_entry(&uverbs_dev->uverbs_file_list, - struct ib_uverbs_file, list); - file->is_closed = 1; -- ucontext = file->ucontext; - list_del(&file->list); -- file->ucontext = NULL; - kref_get(&file->ref); - mutex_unlock(&uverbs_dev->lists_mutex); -- /* We must release the mutex before going ahead and calling -- * disassociate_ucontext. disassociate_ucontext might end up -- * indirectly calling uverbs_close, for example due to freeing -- * the resources (e.g mmput). -- */ -+ - ib_uverbs_event_handler(&file->event_handler, &event); -+ -+ mutex_lock(&file->cleanup_mutex); -+ ucontext = file->ucontext; -+ file->ucontext = NULL; -+ mutex_unlock(&file->cleanup_mutex); -+ -+ /* At this point ib_uverbs_close cannot be running -+ * ib_uverbs_cleanup_ucontext -+ */ - if (ucontext) { -+ /* We must release the mutex before going ahead and -+ * calling disassociate_ucontext. disassociate_ucontext -+ * might end up indirectly calling uverbs_close, -+ * for example due to freeing the resources -+ * (e.g mmput). -+ */ - ib_dev->disassociate_ucontext(ucontext); - ib_uverbs_cleanup_ucontext(file, ucontext); - } -diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c -index 8a0c7f288198..981c3959da59 100644 ---- a/drivers/irqchip/irq-atmel-aic.c -+++ b/drivers/irqchip/irq-atmel-aic.c -@@ -176,6 +176,7 @@ static int aic_irq_domain_xlate(struct irq_domain *d, - { - struct irq_domain_chip_generic *dgc = d->gc; - struct irq_chip_generic *gc; -+ unsigned long flags; - unsigned smr; - int idx; - int ret; -@@ -194,12 +195,12 @@ static int aic_irq_domain_xlate(struct irq_domain *d, - - gc = dgc->gc[idx]; - -- irq_gc_lock(gc); -+ irq_gc_lock_irqsave(gc, flags); - smr = irq_reg_readl(gc, AT91_AIC_SMR(*out_hwirq)); - ret = aic_common_set_priority(intspec[2], &smr); - if (!ret) - irq_reg_writel(gc, smr, AT91_AIC_SMR(*out_hwirq)); -- irq_gc_unlock(gc); -+ irq_gc_unlock_irqrestore(gc, flags); - - return ret; - } -diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c -index 62bb840c613f..7dee71bde350 100644 ---- a/drivers/irqchip/irq-atmel-aic5.c -+++ b/drivers/irqchip/irq-atmel-aic5.c -@@ -258,6 +258,7 @@ static int aic5_irq_domain_xlate(struct irq_domain *d, - unsigned int *out_type) - { - struct irq_chip_generic *bgc = irq_get_domain_generic_chip(d, 0); -+ unsigned long flags; - unsigned smr; - int ret; - -@@ -269,13 +270,13 @@ static int aic5_irq_domain_xlate(struct irq_domain *d, - if (ret) - return ret; - -- irq_gc_lock(bgc); -+ irq_gc_lock_irqsave(bgc, flags); - irq_reg_writel(bgc, *out_hwirq, AT91_AIC5_SSR); - smr = irq_reg_readl(bgc, AT91_AIC5_SMR); - ret = aic_common_set_priority(intspec[2], &smr); - if (!ret) - irq_reg_writel(bgc, intspec[2] | smr, AT91_AIC5_SMR); -- irq_gc_unlock(bgc); -+ irq_gc_unlock_irqrestore(bgc, flags); - - return ret; - } -diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c -index a9859489acf6..596347f345db 100644 ---- a/drivers/lightnvm/rrpc.c -+++ b/drivers/lightnvm/rrpc.c -@@ -287,8 +287,10 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk) - } - - page = mempool_alloc(rrpc->page_pool, GFP_NOIO); -- if (!page) -+ if (!page) { -+ bio_put(bio); - return -ENOMEM; -+ } - - while ((slot = find_first_zero_bit(rblk->invalid_pages, - nr_pgs_per_blk)) < nr_pgs_per_blk) { -diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c -index 3147c8d09ea8..51eda7235e32 100644 ---- a/drivers/md/dm-crypt.c -+++ b/drivers/md/dm-crypt.c -@@ -1920,6 +1920,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio) - return DM_MAPIO_REMAPPED; - } - -+ /* -+ * Check if bio is too large, split as needed. -+ */ -+ if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) && -+ bio_data_dir(bio) == WRITE) -+ dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT)); -+ - io = dm_per_bio_data(bio, cc->per_bio_data_size); - crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector)); - io->ctx.req = (struct ablkcipher_request *)(io + 1); -diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c -index cd0a93df4cb7..8e9e928dafba 100644 ---- a/drivers/md/dm-flakey.c -+++ b/drivers/md/dm-flakey.c -@@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) - pb->bio_submitted = true; - - /* -- * Map reads as normal only if corrupt_bio_byte set. -+ * Error reads if neither corrupt_bio_byte or drop_writes are set. -+ * Otherwise, flakey_end_io() will decide if the reads should be modified. - */ - if (bio_data_dir(bio) == READ) { -- /* If flags were specified, only corrupt those that match. */ -- if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && -- all_corrupt_bio_flags_match(bio, fc)) -- goto map_bio; -- else -+ if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags)) - return -EIO; -+ goto map_bio; - } - - /* -@@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) - struct flakey_c *fc = ti->private; - struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); - -- /* -- * Corrupt successful READs while in down state. -- */ - if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { -- if (fc->corrupt_bio_byte) -+ if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && -+ all_corrupt_bio_flags_match(bio, fc)) { -+ /* -+ * Corrupt successful matching READs while in down state. -+ */ - corrupt_bio_data(bio, fc); -- else -+ -+ } else if (!test_bit(DROP_WRITES, &fc->flags)) { -+ /* -+ * Error read during the down_interval if drop_writes -+ * wasn't configured. -+ */ - return -EIO; -+ } - } - - return error; -diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c -index 624589d51c2c..d8956b4a7b09 100644 ---- a/drivers/md/dm-log-writes.c -+++ b/drivers/md/dm-log-writes.c -@@ -258,12 +258,12 @@ static int log_one_block(struct log_writes_c *lc, - goto out; - sector++; - -+ atomic_inc(&lc->io_blocks); - bio = bio_alloc(GFP_KERNEL, block->vec_cnt); - if (!bio) { - DMERR("Couldn't alloc log bio"); - goto error; - } -- atomic_inc(&lc->io_blocks); - bio->bi_iter.bi_size = 0; - bio->bi_iter.bi_sector = sector; - bio->bi_bdev = lc->logdev->bdev; -@@ -456,9 +456,9 @@ static int log_writes_ctr(struct dm_target *ti, unsigned int argc, char **argv) - goto bad; - } - -- ret = -EINVAL; - lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write"); -- if (!lc->log_kthread) { -+ if (IS_ERR(lc->log_kthread)) { -+ ret = PTR_ERR(lc->log_kthread); - ti->error = "Couldn't alloc kthread"; - dm_put_device(ti, lc->dev); - dm_put_device(ti, lc->logdev); -diff --git a/drivers/md/md.c b/drivers/md/md.c -index c57fdf847b47..c1c7d4fb4b77 100644 ---- a/drivers/md/md.c -+++ b/drivers/md/md.c -@@ -7572,16 +7572,12 @@ EXPORT_SYMBOL(unregister_md_cluster_operations); - - int md_setup_cluster(struct mddev *mddev, int nodes) - { -- int err; -- -- err = request_module("md-cluster"); -- if (err) { -- pr_err("md-cluster module not found.\n"); -- return -ENOENT; -- } -- -+ if (!md_cluster_ops) -+ request_module("md-cluster"); - spin_lock(&pers_lock); -+ /* ensure module won't be unloaded */ - if (!md_cluster_ops || !try_module_get(md_cluster_mod)) { -+ pr_err("can't find md-cluster module or get it's reference.\n"); - spin_unlock(&pers_lock); - return -ENOENT; - } -diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c -index 7e1d13b68b06..81bdeeb05a4d 100644 ---- a/drivers/mmc/host/dw_mmc-pltfm.c -+++ b/drivers/mmc/host/dw_mmc-pltfm.c -@@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev, - - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - /* Get registers' physical base address */ -- host->phy_regs = (void *)(regs->start); -+ host->phy_regs = regs->start; - host->regs = devm_ioremap_resource(&pdev->dev, regs); - if (IS_ERR(host->regs)) - return PTR_ERR(host->regs); -diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c -index 7a6cedbe48a8..fb204ee6ff89 100644 ---- a/drivers/mmc/host/dw_mmc.c -+++ b/drivers/mmc/host/dw_mmc.c -@@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host, - int ret = 0; - - /* Set external dma config: burst size, burst width */ -- cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); -+ cfg.dst_addr = host->phy_regs + fifo_offset; - cfg.src_addr = cfg.dst_addr; - cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; -diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h -index afb10e326b4f..fab35a593898 100644 ---- a/drivers/net/ethernet/cavium/thunder/nic_reg.h -+++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h -@@ -170,7 +170,6 @@ - #define NIC_QSET_SQ_0_7_DOOR (0x010838) - #define NIC_QSET_SQ_0_7_STATUS (0x010840) - #define NIC_QSET_SQ_0_7_DEBUG (0x010848) --#define NIC_QSET_SQ_0_7_CNM_CHG (0x010860) - #define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900) - - #define NIC_QSET_RBDR_0_1_CFG (0x010C00) -diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c -index a12b2e38cf61..ff1d777f3ed9 100644 ---- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c -+++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c -@@ -380,7 +380,10 @@ static void nicvf_get_regs(struct net_device *dev, - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q); - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q); - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q); -- p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_CNM_CHG, q); -+ /* Padding, was NIC_QSET_SQ_0_7_CNM_CHG, which -+ * produces bus errors when read -+ */ -+ p[i++] = 0; - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q); - reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3); - p[i++] = nicvf_queue_reg_read(nic, reg_offset, q); -diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c -index d184e682e636..8c5d2cf9c979 100644 ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -1550,13 +1550,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw, - struct ath_common *common = ath9k_hw_common(sc->sc_ah); - int ret = 0; - -- if (old_state == IEEE80211_STA_AUTH && -- new_state == IEEE80211_STA_ASSOC) { -+ if (old_state == IEEE80211_STA_NOTEXIST && -+ new_state == IEEE80211_STA_NONE) { - ret = ath9k_sta_add(hw, vif, sta); - ath_dbg(common, CONFIG, - "Add station: %pM\n", sta->addr); -- } else if (old_state == IEEE80211_STA_ASSOC && -- new_state == IEEE80211_STA_AUTH) { -+ } else if (old_state == IEEE80211_STA_NONE && -+ new_state == IEEE80211_STA_NOTEXIST) { - ret = ath9k_sta_remove(hw, vif, sta); - ath_dbg(common, CONFIG, - "Remove station: %pM\n", sta->addr); -diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c -index b3235fd2950c..271cca63e9bd 100644 ---- a/drivers/pinctrl/pinctrl-at91-pio4.c -+++ b/drivers/pinctrl/pinctrl-at91-pio4.c -@@ -1002,7 +1002,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) - atmel_pioctrl->irqs[i] = res->start; - irq_set_chained_handler(res->start, atmel_gpio_irq_handler); - irq_set_handler_data(res->start, atmel_pioctrl); -- dev_dbg(dev, "bank %i: hwirq=%u\n", i, res->start); -+ dev_dbg(dev, "bank %i: irq=%pr\n", i, res); - } - - atmel_pioctrl->irq_domain = irq_domain_add_linear(dev->of_node, -diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c -index 6b1a47f8c096..98a459b1c095 100644 ---- a/drivers/pinctrl/pinctrl-pistachio.c -+++ b/drivers/pinctrl/pinctrl-pistachio.c -@@ -809,17 +809,17 @@ static const struct pistachio_pin_group pistachio_groups[] = { - PADS_FUNCTION_SELECT2, 12, 0x3), - MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, - PADS_FUNCTION_SELECT2, 14, 0x3), -- MFIO_MUX_PIN_GROUP(84, SYS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, -+ MFIO_MUX_PIN_GROUP(84, AUDIO_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, - PADS_FUNCTION_SELECT2, 16, 0x3), -- MFIO_MUX_PIN_GROUP(85, WIFI_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, -+ MFIO_MUX_PIN_GROUP(85, RPU_V_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, - PADS_FUNCTION_SELECT2, 18, 0x3), -- MFIO_MUX_PIN_GROUP(86, BT_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, -+ MFIO_MUX_PIN_GROUP(86, RPU_L_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, - PADS_FUNCTION_SELECT2, 20, 0x3), -- MFIO_MUX_PIN_GROUP(87, RPU_V_PLL_LOCK, DREQ2, SOCIF_DEBUG, -+ MFIO_MUX_PIN_GROUP(87, SYS_PLL_LOCK, DREQ2, SOCIF_DEBUG, - PADS_FUNCTION_SELECT2, 22, 0x3), -- MFIO_MUX_PIN_GROUP(88, RPU_L_PLL_LOCK, DREQ3, SOCIF_DEBUG, -+ MFIO_MUX_PIN_GROUP(88, WIFI_PLL_LOCK, DREQ3, SOCIF_DEBUG, - PADS_FUNCTION_SELECT2, 24, 0x3), -- MFIO_MUX_PIN_GROUP(89, AUDIO_PLL_LOCK, DREQ4, DREQ5, -+ MFIO_MUX_PIN_GROUP(89, BT_PLL_LOCK, DREQ4, DREQ5, - PADS_FUNCTION_SELECT2, 26, 0x3), - PIN_GROUP(TCK, "tck"), - PIN_GROUP(TRSTN, "trstn"), -diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c -index 55083d278bb1..51fbf85301be 100644 ---- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c -+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c -@@ -485,12 +485,12 @@ static const struct sunxi_desc_pin sun8i_a23_pins[] = { - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), - SUNXI_FUNCTION(0x0, "gpio_in"), - SUNXI_FUNCTION(0x1, "gpio_out"), -- SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ -+ SUNXI_FUNCTION(0x2, "uart1"), /* RTS */ - SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */ - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), - SUNXI_FUNCTION(0x0, "gpio_in"), - SUNXI_FUNCTION(0x1, "gpio_out"), -- SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ -+ SUNXI_FUNCTION(0x2, "uart1"), /* CTS */ - SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */ - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), - SUNXI_FUNCTION(0x0, "gpio_in"), -diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c -index 8b381d69df86..584cdedea7a4 100644 ---- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c -+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c -@@ -407,12 +407,12 @@ static const struct sunxi_desc_pin sun8i_a33_pins[] = { - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), - SUNXI_FUNCTION(0x0, "gpio_in"), - SUNXI_FUNCTION(0x1, "gpio_out"), -- SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ -+ SUNXI_FUNCTION(0x2, "uart1"), /* RTS */ - SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */ - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), - SUNXI_FUNCTION(0x0, "gpio_in"), - SUNXI_FUNCTION(0x1, "gpio_out"), -- SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ -+ SUNXI_FUNCTION(0x2, "uart1"), /* CTS */ - SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */ - SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), - SUNXI_FUNCTION(0x0, "gpio_in"), -diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c -index b04b05a0904e..65bce1eecaf8 100644 ---- a/drivers/soc/qcom/spm.c -+++ b/drivers/soc/qcom/spm.c -@@ -288,7 +288,7 @@ static struct spm_driver_data *spm_get_drv(struct platform_device *pdev, - struct spm_driver_data *drv = NULL; - struct device_node *cpu_node, *saw_node; - int cpu; -- bool found; -+ bool found = 0; - - for_each_possible_cpu(cpu) { - cpu_node = of_cpu_device_node_get(cpu); -diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c -index ed489880e62b..83b3988eb6b2 100644 ---- a/drivers/tty/serial/8250/8250_mid.c -+++ b/drivers/tty/serial/8250/8250_mid.c -@@ -149,6 +149,9 @@ static void mid8250_set_termios(struct uart_port *p, - unsigned long w = BIT(24) - 1; - unsigned long mul, div; - -+ /* Gracefully handle the B0 case: fall back to B9600 */ -+ fuart = fuart ? fuart : 9600 * 16; -+ - if (mid->board->freq < fuart) { - /* Find prescaler value that satisfies Fuart < Fref */ - if (mid->board->freq > baud) -diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c -index c1d4a8fa9be8..029de3f99752 100644 ---- a/drivers/tty/serial/8250/8250_pci.c -+++ b/drivers/tty/serial/8250/8250_pci.c -@@ -1952,6 +1952,43 @@ pci_wch_ch38x_setup(struct serial_private *priv, - #define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954 - #define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958 - -+#define PCI_VENDOR_ID_ACCESIO 0x494f -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB 0x1051 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S 0x1053 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB 0x105C -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S 0x105E -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB 0x1091 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2 0x1093 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB 0x1099 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4 0x109B -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB 0x10D1 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM 0x10D3 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB 0x10DA -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM 0x10DC -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1 0x1108 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2 0x1110 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2 0x1111 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4 0x1118 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4 0x1119 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S 0x1152 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S 0x115A -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2 0x1190 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2 0x1191 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4 0x1198 -+#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4 0x1199 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM 0x11D0 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4 0x105A -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4 0x105B -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8 0x106A -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8 0x106B -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4 0x1098 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8 0x10A9 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM 0x10D9 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM 0x10E9 -+#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM 0x11D8 -+ -+ -+ - /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ - #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 - #define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588 -@@ -5120,6 +5157,108 @@ static struct pci_device_id serial_pci_tbl[] = { - 0, - 0, pbn_pericom_PI7C9X7958 }, - /* -+ * ACCES I/O Products quad -+ */ -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7954 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM, -+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, -+ pbn_pericom_PI7C9X7958 }, -+ /* - * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) - */ - { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560, -diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c -index ca367b05e440..68fc5fce4cc5 100644 ---- a/drivers/usb/chipidea/udc.c -+++ b/drivers/usb/chipidea/udc.c -@@ -939,6 +939,15 @@ static int isr_setup_status_phase(struct ci_hdrc *ci) - int retval; - struct ci_hw_ep *hwep; - -+ /* -+ * Unexpected USB controller behavior, caused by bad signal integrity -+ * or ground reference problems, can lead to isr_setup_status_phase -+ * being called with ci->status equal to NULL. -+ * If this situation occurs, you should review your USB hardware design. -+ */ -+ if (WARN_ON_ONCE(!ci->status)) -+ return -EPIPE; -+ - hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in; - ci->status->context = ci; - ci->status->complete = isr_setup_status_complete; -diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c -index 80c8d90d8b75..ff44cfa26af8 100644 ---- a/drivers/usb/core/config.c -+++ b/drivers/usb/core/config.c -@@ -211,8 +211,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - memcpy(&endpoint->desc, d, n); - INIT_LIST_HEAD(&endpoint->urb_list); - -- /* Fix up bInterval values outside the legal range. Use 32 ms if no -- * proper value can be guessed. */ -+ /* -+ * Fix up bInterval values outside the legal range. -+ * Use 10 or 8 ms if no proper value can be guessed. -+ */ - i = 0; /* i = min, j = max, n = default */ - j = 255; - if (usb_endpoint_xfer_int(d)) { -@@ -221,13 +223,15 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - case USB_SPEED_SUPER_PLUS: - case USB_SPEED_SUPER: - case USB_SPEED_HIGH: -- /* Many device manufacturers are using full-speed -+ /* -+ * Many device manufacturers are using full-speed - * bInterval values in high-speed interrupt endpoint -- * descriptors. Try to fix those and fall back to a -- * 32 ms default value otherwise. */ -+ * descriptors. Try to fix those and fall back to an -+ * 8-ms default value otherwise. -+ */ - n = fls(d->bInterval*8); - if (n == 0) -- n = 9; /* 32 ms = 2^(9-1) uframes */ -+ n = 7; /* 8 ms = 2^(7-1) uframes */ - j = 16; - - /* -@@ -242,10 +246,12 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - } - break; - default: /* USB_SPEED_FULL or _LOW */ -- /* For low-speed, 10 ms is the official minimum. -+ /* -+ * For low-speed, 10 ms is the official minimum. - * But some "overclocked" devices might want faster -- * polling so we'll allow it. */ -- n = 32; -+ * polling so we'll allow it. -+ */ -+ n = 10; - break; - } - } else if (usb_endpoint_xfer_isoc(d)) { -@@ -253,10 +259,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, - j = 16; - switch (to_usb_device(ddev)->speed) { - case USB_SPEED_HIGH: -- n = 9; /* 32 ms = 2^(9-1) uframes */ -+ n = 7; /* 8 ms = 2^(7-1) uframes */ - break; - default: /* USB_SPEED_FULL */ -- n = 6; /* 32 ms = 2^(6-1) frames */ -+ n = 4; /* 8 ms = 2^(4-1) frames */ - break; - } - } -diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c -index 1f37b89e7267..62a5c8d5e028 100644 ---- a/drivers/usb/host/xhci-ring.c -+++ b/drivers/usb/host/xhci-ring.c -@@ -846,6 +846,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) - spin_lock_irqsave(&xhci->lock, flags); - - ep->stop_cmds_pending--; -+ if (xhci->xhc_state & XHCI_STATE_REMOVING) { -+ spin_unlock_irqrestore(&xhci->lock, flags); -+ return; -+ } - if (xhci->xhc_state & XHCI_STATE_DYING) { - xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - "Stop EP timer ran, but another timer marked " -@@ -899,7 +903,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) - spin_unlock_irqrestore(&xhci->lock, flags); - xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - "Calling usb_hc_died()"); -- usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); -+ usb_hc_died(xhci_to_hcd(xhci)); - xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - "xHCI host controller is dead."); - } -diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c -index d4be5d594896..28965ef4f824 100644 ---- a/drivers/usb/renesas_usbhs/mod.c -+++ b/drivers/usb/renesas_usbhs/mod.c -@@ -282,9 +282,16 @@ static irqreturn_t usbhs_interrupt(int irq, void *data) - if (usbhs_mod_is_host(priv)) - usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); - -- usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); -+ /* -+ * The driver should not clear the xxxSTS after the line of -+ * "call irq callback functions" because each "if" statement is -+ * possible to call the callback function for avoiding any side effects. -+ */ -+ if (irq_state.intsts0 & BRDY) -+ usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); - usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); -- usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); -+ if (irq_state.intsts0 & BEMP) -+ usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); - - /* - * call irq callback functions -diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c -index a204782ae530..e98b6e57b703 100644 ---- a/drivers/usb/serial/usb-serial-simple.c -+++ b/drivers/usb/serial/usb-serial-simple.c -@@ -54,7 +54,8 @@ DEVICE(funsoft, FUNSOFT_IDS); - /* Infineon Flashloader driver */ - #define FLASHLOADER_IDS() \ - { USB_DEVICE_INTERFACE_CLASS(0x058b, 0x0041, USB_CLASS_CDC_DATA) }, \ -- { USB_DEVICE(0x8087, 0x0716) } -+ { USB_DEVICE(0x8087, 0x0716) }, \ -+ { USB_DEVICE(0x8087, 0x0801) } - DEVICE(flashloader, FLASHLOADER_IDS); - - /* Google Serial USB SubClass */ -diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c -index 0e044d7ee721..1415f6d58633 100644 ---- a/fs/btrfs/tree-log.c -+++ b/fs/btrfs/tree-log.c -@@ -2850,6 +2850,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, - - if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { - blk_finish_plug(&plug); -+ list_del_init(&root_log_ctx.list); - mutex_unlock(&log_root_tree->log_mutex); - ret = root_log_ctx.log_ret; - goto out; -diff --git a/fs/ext4/crypto_policy.c b/fs/ext4/crypto_policy.c -index ad050698143f..8a9feb341f31 100644 ---- a/fs/ext4/crypto_policy.c -+++ b/fs/ext4/crypto_policy.c -@@ -102,6 +102,9 @@ static int ext4_create_encryption_context_from_policy( - int ext4_process_policy(const struct ext4_encryption_policy *policy, - struct inode *inode) - { -+ if (!inode_owner_or_capable(inode)) -+ return -EACCES; -+ - if (policy->version != 0) - return -EINVAL; - -diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c -index 5e872fd40e5e..1fb12f9c97a6 100644 ---- a/fs/ext4/ioctl.c -+++ b/fs/ext4/ioctl.c -@@ -629,7 +629,13 @@ resizefs_out: - goto encryption_policy_out; - } - -+ err = mnt_want_write_file(filp); -+ if (err) -+ goto encryption_policy_out; -+ - err = ext4_process_policy(&policy, inode); -+ -+ mnt_drop_write_file(filp); - encryption_policy_out: - return err; - #else -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index c4dcac8a018d..3c7f0c44cfb3 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -815,7 +815,7 @@ static void mb_regenerate_buddy(struct ext4_buddy *e4b) - * for this page; do not hold this lock when calling this routine! - */ - --static int ext4_mb_init_cache(struct page *page, char *incore) -+static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp) - { - ext4_group_t ngroups; - int blocksize; -@@ -848,7 +848,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore) - /* allocate buffer_heads to read bitmaps */ - if (groups_per_page > 1) { - i = sizeof(struct buffer_head *) * groups_per_page; -- bh = kzalloc(i, GFP_NOFS); -+ bh = kzalloc(i, gfp); - if (bh == NULL) { - err = -ENOMEM; - goto out; -@@ -983,7 +983,7 @@ out: - * are on the same page e4b->bd_buddy_page is NULL and return value is 0. - */ - static int ext4_mb_get_buddy_page_lock(struct super_block *sb, -- ext4_group_t group, struct ext4_buddy *e4b) -+ ext4_group_t group, struct ext4_buddy *e4b, gfp_t gfp) - { - struct inode *inode = EXT4_SB(sb)->s_buddy_cache; - int block, pnum, poff; -@@ -1002,7 +1002,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb, - block = group * 2; - pnum = block / blocks_per_page; - poff = block % blocks_per_page; -- page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); -+ page = find_or_create_page(inode->i_mapping, pnum, gfp); - if (!page) - return -ENOMEM; - BUG_ON(page->mapping != inode->i_mapping); -@@ -1016,7 +1016,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb, - - block++; - pnum = block / blocks_per_page; -- page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); -+ page = find_or_create_page(inode->i_mapping, pnum, gfp); - if (!page) - return -ENOMEM; - BUG_ON(page->mapping != inode->i_mapping); -@@ -1042,7 +1042,7 @@ static void ext4_mb_put_buddy_page_lock(struct ext4_buddy *e4b) - * calling this routine! - */ - static noinline_for_stack --int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) -+int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp) - { - - struct ext4_group_info *this_grp; -@@ -1062,7 +1062,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) - * The call to ext4_mb_get_buddy_page_lock will mark the - * page accessed. - */ -- ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b); -+ ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b, gfp); - if (ret || !EXT4_MB_GRP_NEED_INIT(this_grp)) { - /* - * somebody initialized the group -@@ -1072,7 +1072,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) - } - - page = e4b.bd_bitmap_page; -- ret = ext4_mb_init_cache(page, NULL); -+ ret = ext4_mb_init_cache(page, NULL, gfp); - if (ret) - goto err; - if (!PageUptodate(page)) { -@@ -1091,7 +1091,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) - } - /* init buddy cache */ - page = e4b.bd_buddy_page; -- ret = ext4_mb_init_cache(page, e4b.bd_bitmap); -+ ret = ext4_mb_init_cache(page, e4b.bd_bitmap, gfp); - if (ret) - goto err; - if (!PageUptodate(page)) { -@@ -1109,8 +1109,8 @@ err: - * calling this routine! - */ - static noinline_for_stack int --ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, -- struct ext4_buddy *e4b) -+ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group, -+ struct ext4_buddy *e4b, gfp_t gfp) - { - int blocks_per_page; - int block; -@@ -1140,7 +1140,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - * we need full data about the group - * to make a good selection - */ -- ret = ext4_mb_init_group(sb, group); -+ ret = ext4_mb_init_group(sb, group, gfp); - if (ret) - return ret; - } -@@ -1168,11 +1168,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - * wait for it to initialize. - */ - page_cache_release(page); -- page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); -+ page = find_or_create_page(inode->i_mapping, pnum, gfp); - if (page) { - BUG_ON(page->mapping != inode->i_mapping); - if (!PageUptodate(page)) { -- ret = ext4_mb_init_cache(page, NULL); -+ ret = ext4_mb_init_cache(page, NULL, gfp); - if (ret) { - unlock_page(page); - goto err; -@@ -1204,11 +1204,12 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - if (page == NULL || !PageUptodate(page)) { - if (page) - page_cache_release(page); -- page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); -+ page = find_or_create_page(inode->i_mapping, pnum, gfp); - if (page) { - BUG_ON(page->mapping != inode->i_mapping); - if (!PageUptodate(page)) { -- ret = ext4_mb_init_cache(page, e4b->bd_bitmap); -+ ret = ext4_mb_init_cache(page, e4b->bd_bitmap, -+ gfp); - if (ret) { - unlock_page(page); - goto err; -@@ -1247,6 +1248,12 @@ err: - return ret; - } - -+static int ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, -+ struct ext4_buddy *e4b) -+{ -+ return ext4_mb_load_buddy_gfp(sb, group, e4b, GFP_NOFS); -+} -+ - static void ext4_mb_unload_buddy(struct ext4_buddy *e4b) - { - if (e4b->bd_bitmap_page) -@@ -2047,7 +2054,7 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, - - /* We only do this if the grp has never been initialized */ - if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { -- int ret = ext4_mb_init_group(ac->ac_sb, group); -+ int ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS); - if (ret) - return ret; - } -@@ -4808,7 +4815,9 @@ do_more: - #endif - trace_ext4_mballoc_free(sb, inode, block_group, bit, count_clusters); - -- err = ext4_mb_load_buddy(sb, block_group, &e4b); -+ /* __GFP_NOFAIL: retry infinitely, ignore TIF_MEMDIE and memcg limit. */ -+ err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b, -+ GFP_NOFS|__GFP_NOFAIL); - if (err) - goto error_return; - -@@ -5210,7 +5219,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) - grp = ext4_get_group_info(sb, group); - /* We only do this if the grp has never been initialized */ - if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { -- ret = ext4_mb_init_group(sb, group); -+ ret = ext4_mb_init_group(sb, group, GFP_NOFS); - if (ret) - break; - } -diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c -index d4a96af513c2..e504f548b64e 100644 ---- a/fs/f2fs/crypto_policy.c -+++ b/fs/f2fs/crypto_policy.c -@@ -89,6 +89,9 @@ static int f2fs_create_encryption_context_from_policy( - int f2fs_process_policy(const struct f2fs_encryption_policy *policy, - struct inode *inode) - { -+ if (!inode_owner_or_capable(inode)) -+ return -EACCES; -+ - if (policy->version != 0) - return -EINVAL; - -diff --git a/fs/fuse/file.c b/fs/fuse/file.c -index d58d4c0af0ce..682e79965c16 100644 ---- a/fs/fuse/file.c -+++ b/fs/fuse/file.c -@@ -540,13 +540,13 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos, - req->out.args[0].size = count; - } - --static void fuse_release_user_pages(struct fuse_req *req, int write) -+static void fuse_release_user_pages(struct fuse_req *req, bool should_dirty) - { - unsigned i; - - for (i = 0; i < req->num_pages; i++) { - struct page *page = req->pages[i]; -- if (write) -+ if (should_dirty) - set_page_dirty_lock(page); - put_page(page); - } -@@ -1331,6 +1331,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, - loff_t *ppos, int flags) - { - int write = flags & FUSE_DIO_WRITE; -+ bool should_dirty = !write && iter_is_iovec(iter); - int cuse = flags & FUSE_DIO_CUSE; - struct file *file = io->file; - struct inode *inode = file->f_mapping->host; -@@ -1375,7 +1376,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, - nres = fuse_send_read(req, io, pos, nbytes, owner); - - if (!io->async) -- fuse_release_user_pages(req, !write); -+ fuse_release_user_pages(req, should_dirty); - if (req->out.h.error) { - if (!res) - res = req->out.h.error; -diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c -index 7247252ee9b1..6e9a912d394c 100644 ---- a/fs/kernfs/file.c -+++ b/fs/kernfs/file.c -@@ -833,21 +833,35 @@ repeat: - mutex_lock(&kernfs_mutex); - - list_for_each_entry(info, &kernfs_root(kn)->supers, node) { -+ struct kernfs_node *parent; - struct inode *inode; -- struct dentry *dentry; - -+ /* -+ * We want fsnotify_modify() on @kn but as the -+ * modifications aren't originating from userland don't -+ * have the matching @file available. Look up the inodes -+ * and generate the events manually. -+ */ - inode = ilookup(info->sb, kn->ino); - if (!inode) - continue; - -- dentry = d_find_any_alias(inode); -- if (dentry) { -- fsnotify_parent(NULL, dentry, FS_MODIFY); -- fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, -- NULL, 0); -- dput(dentry); -+ parent = kernfs_get_parent(kn); -+ if (parent) { -+ struct inode *p_inode; -+ -+ p_inode = ilookup(info->sb, parent->ino); -+ if (p_inode) { -+ fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, -+ inode, FSNOTIFY_EVENT_INODE, kn->name, 0); -+ iput(p_inode); -+ } -+ -+ kernfs_put(parent); - } - -+ fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, -+ kn->name, 0); - iput(inode); - } - -diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c -index a7f2e6e33305..52a28311e2a4 100644 ---- a/fs/nfs/callback.c -+++ b/fs/nfs/callback.c -@@ -275,6 +275,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, - err_socks: - svc_rpcb_cleanup(serv, net); - err_bind: -+ nn->cb_users[minorversion]--; - dprintk("NFS: Couldn't create callback socket: err = %d; " - "net = %p\n", ret, net); - return ret; -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c -index fc215ab4dcd5..3c69299c01ab 100644 ---- a/fs/nfs/nfs4proc.c -+++ b/fs/nfs/nfs4proc.c -@@ -7424,12 +7424,20 @@ static int _nfs4_proc_create_session(struct nfs_client *clp, - status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); - trace_nfs4_create_session(clp, status); - -+ switch (status) { -+ case -NFS4ERR_STALE_CLIENTID: -+ case -NFS4ERR_DELAY: -+ case -ETIMEDOUT: -+ case -EACCES: -+ case -EAGAIN: -+ goto out; -+ }; -+ -+ clp->cl_seqid++; - if (!status) { - /* Verify the session's negotiated channel_attrs values */ - status = nfs4_verify_channel_attrs(&args, &res); - /* Increment the clientid slot sequence id */ -- if (clp->cl_seqid == res.seqid) -- clp->cl_seqid++; - if (status) - goto out; - nfs4_update_session(session, &res); -diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c -index bec0384499f7..5cd3568eea06 100644 ---- a/fs/nfs/pnfs.c -+++ b/fs/nfs/pnfs.c -@@ -365,6 +365,9 @@ pnfs_layout_need_return(struct pnfs_layout_hdr *lo, - static bool - pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo) - { -+ /* Serialise LAYOUTGET/LAYOUTRETURN */ -+ if (atomic_read(&lo->plh_outstanding) != 0) -+ return false; - if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) - return false; - lo->plh_return_iomode = 0; -@@ -1530,6 +1533,7 @@ pnfs_update_layout(struct inode *ino, - goto out; - - lookup_again: -+ nfs4_client_recover_expired_lease(clp); - first = false; - spin_lock(&ino->i_lock); - lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c -index f7ea624780a7..55638110cb06 100644 ---- a/fs/nfsd/nfs4state.c -+++ b/fs/nfsd/nfs4state.c -@@ -1200,27 +1200,6 @@ free_ol_stateid_reaplist(struct list_head *reaplist) - } - } - --static void release_lockowner(struct nfs4_lockowner *lo) --{ -- struct nfs4_client *clp = lo->lo_owner.so_client; -- struct nfs4_ol_stateid *stp; -- struct list_head reaplist; -- -- INIT_LIST_HEAD(&reaplist); -- -- spin_lock(&clp->cl_lock); -- unhash_lockowner_locked(lo); -- while (!list_empty(&lo->lo_owner.so_stateids)) { -- stp = list_first_entry(&lo->lo_owner.so_stateids, -- struct nfs4_ol_stateid, st_perstateowner); -- WARN_ON(!unhash_lock_stateid(stp)); -- put_ol_stateid_locked(stp, &reaplist); -- } -- spin_unlock(&clp->cl_lock); -- free_ol_stateid_reaplist(&reaplist); -- nfs4_put_stateowner(&lo->lo_owner); --} -- - static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp, - struct list_head *reaplist) - { -@@ -5952,6 +5931,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, - __be32 status; - struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); - struct nfs4_client *clp; -+ LIST_HEAD (reaplist); - - dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", - clid->cl_boot, clid->cl_id); -@@ -5982,9 +5962,23 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, - nfs4_get_stateowner(sop); - break; - } -+ if (!lo) { -+ spin_unlock(&clp->cl_lock); -+ return status; -+ } -+ -+ unhash_lockowner_locked(lo); -+ while (!list_empty(&lo->lo_owner.so_stateids)) { -+ stp = list_first_entry(&lo->lo_owner.so_stateids, -+ struct nfs4_ol_stateid, -+ st_perstateowner); -+ WARN_ON(!unhash_lock_stateid(stp)); -+ put_ol_stateid_locked(stp, &reaplist); -+ } - spin_unlock(&clp->cl_lock); -- if (lo) -- release_lockowner(lo); -+ free_ol_stateid_reaplist(&reaplist); -+ nfs4_put_stateowner(&lo->lo_owner); -+ - return status; - } - -diff --git a/fs/proc/base.c b/fs/proc/base.c -index e8bbf6cdb437..d2b8c754f627 100644 ---- a/fs/proc/base.c -+++ b/fs/proc/base.c -@@ -1545,18 +1545,13 @@ static const struct file_operations proc_pid_set_comm_operations = { - static int proc_exe_link(struct dentry *dentry, struct path *exe_path) - { - struct task_struct *task; -- struct mm_struct *mm; - struct file *exe_file; - - task = get_proc_task(d_inode(dentry)); - if (!task) - return -ENOENT; -- mm = get_task_mm(task); -+ exe_file = get_task_exe_file(task); - put_task_struct(task); -- if (!mm) -- return -ENOENT; -- exe_file = get_mm_exe_file(mm); -- mmput(mm); - if (exe_file) { - *exe_path = exe_file->f_path; - path_get(&exe_file->f_path); -diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h -index 1bfa602958f2..32901d11f8c4 100644 ---- a/include/asm-generic/uaccess.h -+++ b/include/asm-generic/uaccess.h -@@ -230,14 +230,18 @@ extern int __put_user_bad(void) __attribute__((noreturn)); - might_fault(); \ - access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \ - __get_user((x), (__typeof__(*(ptr)) *)__p) : \ -- -EFAULT; \ -+ ((x) = (__typeof__(*(ptr)))0,-EFAULT); \ - }) - - #ifndef __get_user_fn - static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) - { -- size = __copy_from_user(x, ptr, size); -- return size ? -EFAULT : size; -+ size_t n = __copy_from_user(x, ptr, size); -+ if (unlikely(n)) { -+ memset(x + (size - n), 0, n); -+ return -EFAULT; -+ } -+ return 0; - } - - #define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k) -@@ -257,11 +261,13 @@ extern int __get_user_bad(void) __attribute__((noreturn)); - static inline long copy_from_user(void *to, - const void __user * from, unsigned long n) - { -+ unsigned long res = n; - might_fault(); -- if (access_ok(VERIFY_READ, from, n)) -- return __copy_from_user(to, from, n); -- else -- return n; -+ if (likely(access_ok(VERIFY_READ, from, n))) -+ res = __copy_from_user(to, from, n); -+ if (unlikely(res)) -+ memset(to + (n - res), 0, res); -+ return res; - } - - static inline long copy_to_user(void __user *to, -diff --git a/include/linux/irq.h b/include/linux/irq.h -index 3c1c96786248..f7cade00c525 100644 ---- a/include/linux/irq.h -+++ b/include/linux/irq.h -@@ -916,6 +916,16 @@ static inline void irq_gc_lock(struct irq_chip_generic *gc) { } - static inline void irq_gc_unlock(struct irq_chip_generic *gc) { } - #endif - -+/* -+ * The irqsave variants are for usage in non interrupt code. Do not use -+ * them in irq_chip callbacks. Use irq_gc_lock() instead. -+ */ -+#define irq_gc_lock_irqsave(gc, flags) \ -+ raw_spin_lock_irqsave(&(gc)->lock, flags) -+ -+#define irq_gc_unlock_irqrestore(gc, flags) \ -+ raw_spin_unlock_irqrestore(&(gc)->lock, flags) -+ - static inline void irq_reg_writel(struct irq_chip_generic *gc, - u32 val, int reg_offset) - { -diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h -index 1fd50dcfe47c..175c82699e9d 100644 ---- a/include/linux/mfd/ti_am335x_tscadc.h -+++ b/include/linux/mfd/ti_am335x_tscadc.h -@@ -138,16 +138,16 @@ - /* - * time in us for processing a single channel, calculated as follows: - * -- * num cycles = open delay + (sample delay + conv time) * averaging -+ * max num cycles = open delay + (sample delay + conv time) * averaging - * -- * num cycles: 152 + (1 + 13) * 16 = 376 -+ * max num cycles: 262143 + (255 + 13) * 16 = 266431 - * - * clock frequency: 26MHz / 8 = 3.25MHz - * clock period: 1 / 3.25MHz = 308ns - * -- * processing time: 376 * 308ns = 116us -+ * max processing time: 266431 * 308ns = 83ms(approx) - */ --#define IDLE_TIMEOUT 116 /* microsec */ -+#define IDLE_TIMEOUT 83 /* milliseconds */ - - #define TSCADC_CELLS 2 - -diff --git a/include/linux/mm.h b/include/linux/mm.h -index 8a761248d01e..cfebb742ee18 100644 ---- a/include/linux/mm.h -+++ b/include/linux/mm.h -@@ -1898,6 +1898,7 @@ extern void mm_drop_all_locks(struct mm_struct *mm); - - extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); - extern struct file *get_mm_exe_file(struct mm_struct *mm); -+extern struct file *get_task_exe_file(struct task_struct *task); - - extern int may_expand_vm(struct mm_struct *mm, unsigned long npages); - extern struct vm_area_struct *_install_special_mapping(struct mm_struct *mm, -diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h -index f67b2ec18e6d..7776afb0ffa5 100644 ---- a/include/linux/mmc/dw_mmc.h -+++ b/include/linux/mmc/dw_mmc.h -@@ -172,7 +172,7 @@ struct dw_mci { - /* For edmac */ - struct dw_mci_dma_slave *dms; - /* Registers's physical base address */ -- void *phy_regs; -+ resource_size_t phy_regs; - - u32 cmd_status; - u32 data_status; -diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h -index 04c068e55353..b97d6823ef3c 100644 ---- a/include/linux/netdevice.h -+++ b/include/linux/netdevice.h -@@ -511,7 +511,6 @@ static inline void napi_enable(struct napi_struct *n) - clear_bit(NAPI_STATE_NPSVC, &n->state); - } - --#ifdef CONFIG_SMP - /** - * napi_synchronize - wait until NAPI is not running - * @n: napi context -@@ -522,12 +521,12 @@ static inline void napi_enable(struct napi_struct *n) - */ - static inline void napi_synchronize(const struct napi_struct *n) - { -- while (test_bit(NAPI_STATE_SCHED, &n->state)) -- msleep(1); -+ if (IS_ENABLED(CONFIG_SMP)) -+ while (test_bit(NAPI_STATE_SCHED, &n->state)) -+ msleep(1); -+ else -+ barrier(); - } --#else --# define napi_synchronize(n) barrier() --#endif - - enum netdev_queue_state_t { - __QUEUE_STATE_DRV_XOFF, -diff --git a/include/linux/uio.h b/include/linux/uio.h -index 8b01e1c3c614..5f9c59da978b 100644 ---- a/include/linux/uio.h -+++ b/include/linux/uio.h -@@ -76,7 +76,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page, - struct iov_iter *i, unsigned long offset, size_t bytes); - void iov_iter_advance(struct iov_iter *i, size_t bytes); - int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes); --int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes); -+#define iov_iter_fault_in_multipages_readable iov_iter_fault_in_readable - size_t iov_iter_single_seg_count(const struct iov_iter *i); - size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, - struct iov_iter *i); -diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c -index 656c7e93ac0d..939945a5649c 100644 ---- a/kernel/audit_watch.c -+++ b/kernel/audit_watch.c -@@ -19,6 +19,7 @@ - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -+#include - #include - #include - #include -@@ -544,10 +545,11 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark) - unsigned long ino; - dev_t dev; - -- rcu_read_lock(); -- exe_file = rcu_dereference(tsk->mm->exe_file); -+ exe_file = get_task_exe_file(tsk); -+ if (!exe_file) -+ return 0; - ino = exe_file->f_inode->i_ino; - dev = exe_file->f_inode->i_sb->s_dev; -- rcu_read_unlock(); -+ fput(exe_file); - return audit_mark_compare(mark, ino, dev); - } -diff --git a/kernel/configs/tiny.config b/kernel/configs/tiny.config -index c2de56ab0fce..7fa0c4ae6394 100644 ---- a/kernel/configs/tiny.config -+++ b/kernel/configs/tiny.config -@@ -1,4 +1,12 @@ -+# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set - CONFIG_CC_OPTIMIZE_FOR_SIZE=y -+# CONFIG_KERNEL_GZIP is not set -+# CONFIG_KERNEL_BZIP2 is not set -+# CONFIG_KERNEL_LZMA is not set - CONFIG_KERNEL_XZ=y -+# CONFIG_KERNEL_LZO is not set -+# CONFIG_KERNEL_LZ4 is not set - CONFIG_OPTIMIZE_INLINING=y -+# CONFIG_SLAB is not set -+# CONFIG_SLUB is not set - CONFIG_SLOB=y -diff --git a/kernel/cpuset.c b/kernel/cpuset.c -index 11eaf14b52c2..e120bd983ad0 100644 ---- a/kernel/cpuset.c -+++ b/kernel/cpuset.c -@@ -2074,6 +2074,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css) - mutex_unlock(&cpuset_mutex); - } - -+/* -+ * Make sure the new task conform to the current state of its parent, -+ * which could have been changed by cpuset just after it inherits the -+ * state from the parent and before it sits on the cgroup's task list. -+ */ -+void cpuset_fork(struct task_struct *task) -+{ -+ if (task_css_is_root(task, cpuset_cgrp_id)) -+ return; -+ -+ set_cpus_allowed_ptr(task, ¤t->cpus_allowed); -+ task->mems_allowed = current->mems_allowed; -+} -+ - struct cgroup_subsys cpuset_cgrp_subsys = { - .css_alloc = cpuset_css_alloc, - .css_online = cpuset_css_online, -@@ -2084,6 +2098,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = { - .attach = cpuset_attach, - .post_attach = cpuset_post_attach, - .bind = cpuset_bind, -+ .fork = cpuset_fork, - .legacy_cftypes = files, - .early_init = 1, - }; -diff --git a/kernel/fork.c b/kernel/fork.c -index c485cb156772..8860d1f50d24 100644 ---- a/kernel/fork.c -+++ b/kernel/fork.c -@@ -764,6 +764,29 @@ struct file *get_mm_exe_file(struct mm_struct *mm) - EXPORT_SYMBOL(get_mm_exe_file); - - /** -+ * get_task_exe_file - acquire a reference to the task's executable file -+ * -+ * Returns %NULL if task's mm (if any) has no associated executable file or -+ * this is a kernel thread with borrowed mm (see the comment above get_task_mm). -+ * User must release file via fput(). -+ */ -+struct file *get_task_exe_file(struct task_struct *task) -+{ -+ struct file *exe_file = NULL; -+ struct mm_struct *mm; -+ -+ task_lock(task); -+ mm = task->mm; -+ if (mm) { -+ if (!(task->flags & PF_KTHREAD)) -+ exe_file = get_mm_exe_file(mm); -+ } -+ task_unlock(task); -+ return exe_file; -+} -+EXPORT_SYMBOL(get_task_exe_file); -+ -+/** - * get_task_mm - acquire a reference to the task's mm - * - * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning -diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c -index 4b21779d5163..cd6009006510 100644 ---- a/kernel/irq/msi.c -+++ b/kernel/irq/msi.c -@@ -298,6 +298,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - ops->msi_finish(&arg, 0); - - for_each_msi_entry(desc, dev) { -+ virq = desc->irq; - if (desc->nvec_used == 1) - dev_dbg(dev, "irq %d for MSI\n", virq); - else -diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c -index b70ada0028d2..6030efd4a188 100644 ---- a/kernel/kexec_file.c -+++ b/kernel/kexec_file.c -@@ -934,7 +934,10 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min, - return 0; - out: - vfree(pi->sechdrs); -+ pi->sechdrs = NULL; -+ - vfree(pi->purgatory_buf); -+ pi->purgatory_buf = NULL; - return ret; - } - -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index ea863bc22caf..20253dbc8610 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -1945,6 +1945,28 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) - success = 1; /* we're going to change ->state */ - cpu = task_cpu(p); - -+ /* -+ * Ensure we load p->on_rq _after_ p->state, otherwise it would -+ * be possible to, falsely, observe p->on_rq == 0 and get stuck -+ * in smp_cond_load_acquire() below. -+ * -+ * sched_ttwu_pending() try_to_wake_up() -+ * [S] p->on_rq = 1; [L] P->state -+ * UNLOCK rq->lock -----. -+ * \ -+ * +--- RMB -+ * schedule() / -+ * LOCK rq->lock -----' -+ * UNLOCK rq->lock -+ * -+ * [task p] -+ * [S] p->state = UNINTERRUPTIBLE [L] p->on_rq -+ * -+ * Pairs with the UNLOCK+LOCK on rq->lock from the -+ * last wakeup of our task and the schedule that got our task -+ * current. -+ */ -+ smp_rmb(); - if (p->on_rq && ttwu_remote(p, wake_flags)) - goto stat; - -diff --git a/lib/iov_iter.c b/lib/iov_iter.c -index 75232ad0a5e7..daca582a8ed0 100644 ---- a/lib/iov_iter.c -+++ b/lib/iov_iter.c -@@ -298,33 +298,13 @@ done: - } - - /* -- * Fault in the first iovec of the given iov_iter, to a maximum length -- * of bytes. Returns 0 on success, or non-zero if the memory could not be -- * accessed (ie. because it is an invalid address). -- * -- * writev-intensive code may want this to prefault several iovecs -- that -- * would be possible (callers must not rely on the fact that _only_ the -- * first iovec will be faulted with the current implementation). -- */ --int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes) --{ -- if (!(i->type & (ITER_BVEC|ITER_KVEC))) { -- char __user *buf = i->iov->iov_base + i->iov_offset; -- bytes = min(bytes, i->iov->iov_len - i->iov_offset); -- return fault_in_pages_readable(buf, bytes); -- } -- return 0; --} --EXPORT_SYMBOL(iov_iter_fault_in_readable); -- --/* - * Fault in one or more iovecs of the given iov_iter, to a maximum length of - * bytes. For each iovec, fault in each page that constitutes the iovec. - * - * Return 0 on success, or non-zero if the memory could not be accessed (i.e. - * because it is an invalid address). - */ --int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes) -+int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes) - { - size_t skip = i->iov_offset; - const struct iovec *iov; -@@ -341,7 +321,7 @@ int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes) - } - return 0; - } --EXPORT_SYMBOL(iov_iter_fault_in_multipages_readable); -+EXPORT_SYMBOL(iov_iter_fault_in_readable); - - void iov_iter_init(struct iov_iter *i, int direction, - const struct iovec *iov, unsigned long nr_segs, -diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c -index e8d3da0817d3..036b39eb1220 100644 ---- a/net/ipv6/addrconf.c -+++ b/net/ipv6/addrconf.c -@@ -1898,6 +1898,7 @@ errdad: - spin_unlock_bh(&ifp->lock); - - addrconf_mod_dad_work(ifp, 0); -+ in6_ifa_put(ifp); - } - - /* Join to solicited addr multicast group. -@@ -3609,6 +3610,7 @@ static void addrconf_dad_work(struct work_struct *w) - addrconf_dad_begin(ifp); - goto out; - } else if (action == DAD_ABORT) { -+ in6_ifa_hold(ifp); - addrconf_dad_stop(ifp, 1); - goto out; - } -diff --git a/net/tipc/link.c b/net/tipc/link.c -index 91aea071ab27..72268eac4ec7 100644 ---- a/net/tipc/link.c -+++ b/net/tipc/link.c -@@ -1262,6 +1262,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, - /* fall thru' */ - - case ACTIVATE_MSG: -+ skb_linearize(skb); -+ hdr = buf_msg(skb); - - /* Complete own link name with peer's interface name */ - if_name = strrchr(l->name, ':') + 1; -diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c -index c07612bab95c..f51c8bdbea1c 100644 ---- a/net/tipc/name_distr.c -+++ b/net/tipc/name_distr.c -@@ -397,6 +397,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq) - - spin_lock_bh(&tn->nametbl_lock); - for (skb = skb_dequeue(inputq); skb; skb = skb_dequeue(inputq)) { -+ skb_linearize(skb); - msg = buf_msg(skb); - mtype = msg_type(msg); - item = (struct distr_item *)msg_data(msg); -diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c -index 70c03271b798..6af78c6276b4 100644 ---- a/net/tipc/udp_media.c -+++ b/net/tipc/udp_media.c -@@ -48,7 +48,6 @@ - #include - #include "core.h" - #include "bearer.h" --#include "msg.h" - - /* IANA assigned UDP port */ - #define UDP_PORT_DEFAULT 6118 -@@ -224,10 +223,6 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb) - { - struct udp_bearer *ub; - struct tipc_bearer *b; -- int usr = msg_user(buf_msg(skb)); -- -- if ((usr == LINK_PROTOCOL) || (usr == NAME_DISTRIBUTOR)) -- skb_linearize(skb); - - ub = rcu_dereference_sk_user_data(sk); - if (!ub) { -diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c -index c753211cb83f..b50ee5d622e1 100644 ---- a/net/wireless/wext-core.c -+++ b/net/wireless/wext-core.c -@@ -955,29 +955,8 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, - return private(dev, iwr, cmd, info, handler); - } - /* Old driver API : call driver ioctl handler */ -- if (dev->netdev_ops->ndo_do_ioctl) { --#ifdef CONFIG_COMPAT -- if (info->flags & IW_REQUEST_FLAG_COMPAT) { -- int ret = 0; -- struct iwreq iwr_lcl; -- struct compat_iw_point *iwp_compat = (void *) &iwr->u.data; -- -- memcpy(&iwr_lcl, iwr, sizeof(struct iwreq)); -- iwr_lcl.u.data.pointer = compat_ptr(iwp_compat->pointer); -- iwr_lcl.u.data.length = iwp_compat->length; -- iwr_lcl.u.data.flags = iwp_compat->flags; -- -- ret = dev->netdev_ops->ndo_do_ioctl(dev, (void *) &iwr_lcl, cmd); -- -- iwp_compat->pointer = ptr_to_compat(iwr_lcl.u.data.pointer); -- iwp_compat->length = iwr_lcl.u.data.length; -- iwp_compat->flags = iwr_lcl.u.data.flags; -- -- return ret; -- } else --#endif -- return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); -- } -+ if (dev->netdev_ops->ndo_do_ioctl) -+ return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); - return -EOPNOTSUPP; - } - diff --git a/patch/kernel/marvell-dev/patch-4.4.22-23.patch b/patch/kernel/marvell-dev/patch-4.4.22-23.patch deleted file mode 100644 index 5ea7450adf..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.22-23.patch +++ /dev/null @@ -1,2907 +0,0 @@ -diff --git a/Makefile b/Makefile -index a6512f4eec9f..95421b688f23 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 22 -+SUBLEVEL = 23 - EXTRAVERSION = - NAME = Blurry Fish Butt - -@@ -128,6 +128,10 @@ _all: - # Cancel implicit rules on top Makefile - $(CURDIR)/Makefile Makefile: ; - -+ifneq ($(words $(subst :, ,$(CURDIR))), 1) -+ $(error main directory cannot contain spaces nor colons) -+endif -+ - ifneq ($(KBUILD_OUTPUT),) - # Invoke a second make in the output directory, passing relevant variables - # check that the output directory actually exists -@@ -495,6 +499,12 @@ ifeq ($(KBUILD_EXTMOD),) - endif - endif - endif -+# install and module_install need also be processed one by one -+ifneq ($(filter install,$(MAKECMDGOALS)),) -+ ifneq ($(filter modules_install,$(MAKECMDGOALS)),) -+ mixed-targets := 1 -+ endif -+endif - - ifeq ($(mixed-targets),1) - # =========================================================================== -@@ -606,11 +616,16 @@ ARCH_CFLAGS := - include arch/$(SRCARCH)/Makefile - - KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) -+KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) - - ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE --KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) -+KBUILD_CFLAGS += -Os - else -+ifdef CONFIG_PROFILE_ALL_BRANCHES - KBUILD_CFLAGS += -O2 -+else -+KBUILD_CFLAGS += -O2 -+endif - endif - - # Tell gcc to never replace conditional load with a non-conditional one -@@ -1260,7 +1275,7 @@ help: - @echo ' firmware_install- Install all firmware to INSTALL_FW_PATH' - @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' - @echo ' dir/ - Build all files in dir and below' -- @echo ' dir/file.[oisS] - Build specified target only' -+ @echo ' dir/file.[ois] - Build specified target only' - @echo ' dir/file.lst - Build specified mixed source/assembly target only' - @echo ' (requires a recent binutils and recent build (System.map))' - @echo ' dir/file.ko - Build module including final link' -@@ -1500,11 +1515,11 @@ image_name: - # Clear a bunch of variables before executing the submake - tools/: FORCE - $(Q)mkdir -p $(objtree)/tools -- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(O) subdir=tools -C $(src)/tools/ -+ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ - - tools/%: FORCE - $(Q)mkdir -p $(objtree)/tools -- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(O) subdir=tools -C $(src)/tools/ $* -+ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* - - # Single targets - # --------------------------------------------------------------------------- -diff --git a/arch/arm/crypto/aes-ce-glue.c b/arch/arm/crypto/aes-ce-glue.c -index b445a5d56f43..593da7ffb449 100644 ---- a/arch/arm/crypto/aes-ce-glue.c -+++ b/arch/arm/crypto/aes-ce-glue.c -@@ -279,7 +279,7 @@ static int ctr_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - err = blkcipher_walk_done(desc, &walk, - walk.nbytes % AES_BLOCK_SIZE); - } -- if (nbytes) { -+ if (walk.nbytes % AES_BLOCK_SIZE) { - u8 *tdst = walk.dst.virt.addr + blocks * AES_BLOCK_SIZE; - u8 *tsrc = walk.src.virt.addr + blocks * AES_BLOCK_SIZE; - u8 __aligned(8) tail[AES_BLOCK_SIZE]; -diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c -index f6d02e4cbcda..5c87dff5d46e 100644 ---- a/arch/arm/mach-pxa/idp.c -+++ b/arch/arm/mach-pxa/idp.c -@@ -83,7 +83,8 @@ static struct resource smc91x_resources[] = { - }; - - static struct smc91x_platdata smc91x_platdata = { -- .flags = SMC91X_USE_32BIT | SMC91X_USE_DMA | SMC91X_NOWAIT, -+ .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | -+ SMC91X_USE_DMA | SMC91X_NOWAIT, - }; - - static struct platform_device smc91x_device = { -diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c -index 13b1d4586d7d..9001312710f7 100644 ---- a/arch/arm/mach-pxa/xcep.c -+++ b/arch/arm/mach-pxa/xcep.c -@@ -120,7 +120,8 @@ static struct resource smc91x_resources[] = { - }; - - static struct smc91x_platdata xcep_smc91x_info = { -- .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT | SMC91X_USE_DMA, -+ .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | -+ SMC91X_NOWAIT | SMC91X_USE_DMA, - }; - - static struct platform_device smc91x_device = { -diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c -index 44575edc44b1..cf0a7c2359f0 100644 ---- a/arch/arm/mach-realview/core.c -+++ b/arch/arm/mach-realview/core.c -@@ -95,7 +95,8 @@ static struct smsc911x_platform_config smsc911x_config = { - }; - - static struct smc91x_platdata smc91x_platdata = { -- .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, -+ .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | -+ SMC91X_NOWAIT, - }; - - static struct platform_device realview_eth_device = { -diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c -index 1525d7b5f1b7..88149f85bc49 100644 ---- a/arch/arm/mach-sa1100/pleb.c -+++ b/arch/arm/mach-sa1100/pleb.c -@@ -45,7 +45,7 @@ static struct resource smc91x_resources[] = { - }; - - static struct smc91x_platdata smc91x_platdata = { -- .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, -+ .flags = SMC91X_USE_16BIT | SMC91X_USE_8BIT | SMC91X_NOWAIT, - }; - - static struct platform_device smc91x_device = { -diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c -index 05d9e16c0dfd..6a51dfccfe71 100644 ---- a/arch/arm64/crypto/aes-glue.c -+++ b/arch/arm64/crypto/aes-glue.c -@@ -211,7 +211,7 @@ static int ctr_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - err = blkcipher_walk_done(desc, &walk, - walk.nbytes % AES_BLOCK_SIZE); - } -- if (nbytes) { -+ if (walk.nbytes % AES_BLOCK_SIZE) { - u8 *tdst = walk.dst.virt.addr + blocks * AES_BLOCK_SIZE; - u8 *tsrc = walk.src.virt.addr + blocks * AES_BLOCK_SIZE; - u8 __aligned(8) tail[AES_BLOCK_SIZE]; -diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c -index c6db52ba3a06..10c57771822d 100644 ---- a/arch/blackfin/mach-bf561/boards/cm_bf561.c -+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c -@@ -146,7 +146,8 @@ static struct platform_device hitachi_fb_device = { - #include - - static struct smc91x_platdata smc91x_info = { -- .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, -+ .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | -+ SMC91X_NOWAIT, - .leda = RPC_LED_100_10, - .ledb = RPC_LED_TX_RX, - }; -diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c -index 2de71e8c104b..93c22468cc14 100644 ---- a/arch/blackfin/mach-bf561/boards/ezkit.c -+++ b/arch/blackfin/mach-bf561/boards/ezkit.c -@@ -134,7 +134,8 @@ static struct platform_device net2272_bfin_device = { - #include - - static struct smc91x_platdata smc91x_info = { -- .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, -+ .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | -+ SMC91X_NOWAIT, - .leda = RPC_LED_100_10, - .ledb = RPC_LED_TX_RX, - }; -diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug -index f0e314ceb8ba..7f975b20b20c 100644 ---- a/arch/mips/Kconfig.debug -+++ b/arch/mips/Kconfig.debug -@@ -113,42 +113,6 @@ config SPINLOCK_TEST - help - Add several files to the debugfs to test spinlock speed. - --if CPU_MIPSR6 -- --choice -- prompt "Compact branch policy" -- default MIPS_COMPACT_BRANCHES_OPTIMAL -- --config MIPS_COMPACT_BRANCHES_NEVER -- bool "Never (force delay slot branches)" -- help -- Pass the -mcompact-branches=never flag to the compiler in order to -- force it to always emit branches with delay slots, and make no use -- of the compact branch instructions introduced by MIPSr6. This is -- useful if you suspect there may be an issue with compact branches in -- either the compiler or the CPU. -- --config MIPS_COMPACT_BRANCHES_OPTIMAL -- bool "Optimal (use where beneficial)" -- help -- Pass the -mcompact-branches=optimal flag to the compiler in order for -- it to make use of compact branch instructions where it deems them -- beneficial, and use branches with delay slots elsewhere. This is the -- default compiler behaviour, and should be used unless you have a -- reason to choose otherwise. -- --config MIPS_COMPACT_BRANCHES_ALWAYS -- bool "Always (force compact branches)" -- help -- Pass the -mcompact-branches=always flag to the compiler in order to -- force it to always emit compact branches, making no use of branch -- instructions with delay slots. This can result in more compact code -- which may be beneficial in some scenarios. -- --endchoice -- --endif # CPU_MIPSR6 -- - config SCACHE_DEBUGFS - bool "L2 cache debugfs entries" - depends on DEBUG_FS -diff --git a/arch/mips/Makefile b/arch/mips/Makefile -index 3f70ba54ae21..252e347958f3 100644 ---- a/arch/mips/Makefile -+++ b/arch/mips/Makefile -@@ -204,10 +204,6 @@ toolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$( - cflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA - endif - --cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_NEVER) += -mcompact-branches=never --cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_OPTIMAL) += -mcompact-branches=optimal --cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_ALWAYS) += -mcompact-branches=always -- - # - # Firmware support - # -diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h -index e689b894353c..8dedee1def83 100644 ---- a/arch/mips/include/asm/asmmacro.h -+++ b/arch/mips/include/asm/asmmacro.h -@@ -135,6 +135,7 @@ - ldc1 $f28, THREAD_FPR28(\thread) - ldc1 $f30, THREAD_FPR30(\thread) - ctc1 \tmp, fcr31 -+ .set pop - .endm - - .macro fpu_restore_16odd thread -diff --git a/arch/mips/include/asm/mach-paravirt/kernel-entry-init.h b/arch/mips/include/asm/mach-paravirt/kernel-entry-init.h -index 2f82bfa3a773..c9f5769dfc8f 100644 ---- a/arch/mips/include/asm/mach-paravirt/kernel-entry-init.h -+++ b/arch/mips/include/asm/mach-paravirt/kernel-entry-init.h -@@ -11,11 +11,13 @@ - #define CP0_EBASE $15, 1 - - .macro kernel_entry_setup -+#ifdef CONFIG_SMP - mfc0 t0, CP0_EBASE - andi t0, t0, 0x3ff # CPUNum - beqz t0, 1f - # CPUs other than zero goto smp_bootstrap - j smp_bootstrap -+#endif /* CONFIG_SMP */ - - 1: - .endm -diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c -index 4674a74a08b5..af27334d6809 100644 ---- a/arch/mips/kernel/mips-r2-to-r6-emul.c -+++ b/arch/mips/kernel/mips-r2-to-r6-emul.c -@@ -1164,7 +1164,9 @@ fpu_emul: - regs->regs[31] = r31; - regs->cp0_epc = epc; - if (!used_math()) { /* First time FPU user. */ -+ preempt_disable(); - err = init_fpu(); -+ preempt_enable(); - set_used_math(); - } - lose_fpu(1); /* Save FPU state for the emulator. */ -diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c -index 89847bee2b53..44a6f25e902e 100644 ---- a/arch/mips/kernel/process.c -+++ b/arch/mips/kernel/process.c -@@ -593,14 +593,14 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) - return -EOPNOTSUPP; - - /* Avoid inadvertently triggering emulation */ -- if ((value & PR_FP_MODE_FR) && cpu_has_fpu && -- !(current_cpu_data.fpu_id & MIPS_FPIR_F64)) -+ if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu && -+ !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64)) - return -EOPNOTSUPP; -- if ((value & PR_FP_MODE_FRE) && cpu_has_fpu && !cpu_has_fre) -+ if ((value & PR_FP_MODE_FRE) && raw_cpu_has_fpu && !cpu_has_fre) - return -EOPNOTSUPP; - - /* FR = 0 not supported in MIPS R6 */ -- if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6) -+ if (!(value & PR_FP_MODE_FR) && raw_cpu_has_fpu && cpu_has_mips_r6) - return -EOPNOTSUPP; - - /* Proceed with the mode switch */ -diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c -index 2b521e07b860..7fef02a9eb85 100644 ---- a/arch/mips/kernel/smp.c -+++ b/arch/mips/kernel/smp.c -@@ -174,6 +174,9 @@ asmlinkage void start_secondary(void) - cpumask_set_cpu(cpu, &cpu_coherent_mask); - notify_cpu_starting(cpu); - -+ cpumask_set_cpu(cpu, &cpu_callin_map); -+ synchronise_count_slave(cpu); -+ - set_cpu_online(cpu, true); - - set_cpu_sibling_map(cpu); -@@ -181,10 +184,6 @@ asmlinkage void start_secondary(void) - - calculate_cpu_foreign_map(); - -- cpumask_set_cpu(cpu, &cpu_callin_map); -- -- synchronise_count_slave(cpu); -- - /* - * irq will be enabled in ->smp_finish(), enabling it too early - * is dangerous. -diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c -index 975e99759bab..5649a9e429e0 100644 ---- a/arch/mips/kernel/vdso.c -+++ b/arch/mips/kernel/vdso.c -@@ -39,16 +39,16 @@ static struct vm_special_mapping vdso_vvar_mapping = { - static void __init init_vdso_image(struct mips_vdso_image *image) - { - unsigned long num_pages, i; -+ unsigned long data_pfn; - - BUG_ON(!PAGE_ALIGNED(image->data)); - BUG_ON(!PAGE_ALIGNED(image->size)); - - num_pages = image->size / PAGE_SIZE; - -- for (i = 0; i < num_pages; i++) { -- image->mapping.pages[i] = -- virt_to_page(image->data + (i * PAGE_SIZE)); -- } -+ data_pfn = __phys_to_pfn(__pa_symbol(image->data)); -+ for (i = 0; i < num_pages; i++) -+ image->mapping.pages[i] = pfn_to_page(data_pfn + i); - } - - static int __init init_vdso(void) -diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c -index 8cc1622b2ee0..dca7bc87dad9 100644 ---- a/crypto/blkcipher.c -+++ b/crypto/blkcipher.c -@@ -234,6 +234,8 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc, - return blkcipher_walk_done(desc, walk, -EINVAL); - } - -+ bsize = min(walk->walk_blocksize, n); -+ - walk->flags &= ~(BLKCIPHER_WALK_SLOW | BLKCIPHER_WALK_COPY | - BLKCIPHER_WALK_DIFF); - if (!scatterwalk_aligned(&walk->in, walk->alignmask) || -@@ -246,7 +248,6 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc, - } - } - -- bsize = min(walk->walk_blocksize, n); - n = scatterwalk_clamp(&walk->in, n); - n = scatterwalk_clamp(&walk->out, n); - -diff --git a/crypto/echainiv.c b/crypto/echainiv.c -index b96a84560b67..343a74e96e2a 100644 ---- a/crypto/echainiv.c -+++ b/crypto/echainiv.c -@@ -1,8 +1,8 @@ - /* - * echainiv: Encrypted Chain IV Generator - * -- * This generator generates an IV based on a sequence number by xoring it -- * with a salt and then encrypting it with the same key as used to encrypt -+ * This generator generates an IV based on a sequence number by multiplying -+ * it with a salt and then encrypting it with the same key as used to encrypt - * the plain text. This algorithm requires that the block size be equal - * to the IV size. It is mainly useful for CBC. - * -@@ -23,81 +23,17 @@ - #include - #include - #include --#include - #include --#include --#include -+#include - #include - --#define MAX_IV_SIZE 16 -- --static DEFINE_PER_CPU(u32 [MAX_IV_SIZE / sizeof(u32)], echainiv_iv); -- --/* We don't care if we get preempted and read/write IVs from the next CPU. */ --static void echainiv_read_iv(u8 *dst, unsigned size) --{ -- u32 *a = (u32 *)dst; -- u32 __percpu *b = echainiv_iv; -- -- for (; size >= 4; size -= 4) { -- *a++ = this_cpu_read(*b); -- b++; -- } --} -- --static void echainiv_write_iv(const u8 *src, unsigned size) --{ -- const u32 *a = (const u32 *)src; -- u32 __percpu *b = echainiv_iv; -- -- for (; size >= 4; size -= 4) { -- this_cpu_write(*b, *a); -- a++; -- b++; -- } --} -- --static void echainiv_encrypt_complete2(struct aead_request *req, int err) --{ -- struct aead_request *subreq = aead_request_ctx(req); -- struct crypto_aead *geniv; -- unsigned int ivsize; -- -- if (err == -EINPROGRESS) -- return; -- -- if (err) -- goto out; -- -- geniv = crypto_aead_reqtfm(req); -- ivsize = crypto_aead_ivsize(geniv); -- -- echainiv_write_iv(subreq->iv, ivsize); -- -- if (req->iv != subreq->iv) -- memcpy(req->iv, subreq->iv, ivsize); -- --out: -- if (req->iv != subreq->iv) -- kzfree(subreq->iv); --} -- --static void echainiv_encrypt_complete(struct crypto_async_request *base, -- int err) --{ -- struct aead_request *req = base->data; -- -- echainiv_encrypt_complete2(req, err); -- aead_request_complete(req, err); --} -- - static int echainiv_encrypt(struct aead_request *req) - { - struct crypto_aead *geniv = crypto_aead_reqtfm(req); - struct aead_geniv_ctx *ctx = crypto_aead_ctx(geniv); - struct aead_request *subreq = aead_request_ctx(req); -- crypto_completion_t compl; -- void *data; -+ __be64 nseqno; -+ u64 seqno; - u8 *info; - unsigned int ivsize = crypto_aead_ivsize(geniv); - int err; -@@ -107,8 +43,6 @@ static int echainiv_encrypt(struct aead_request *req) - - aead_request_set_tfm(subreq, ctx->child); - -- compl = echainiv_encrypt_complete; -- data = req; - info = req->iv; - - if (req->src != req->dst) { -@@ -123,29 +57,30 @@ static int echainiv_encrypt(struct aead_request *req) - return err; - } - -- if (unlikely(!IS_ALIGNED((unsigned long)info, -- crypto_aead_alignmask(geniv) + 1))) { -- info = kmalloc(ivsize, req->base.flags & -- CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL: -- GFP_ATOMIC); -- if (!info) -- return -ENOMEM; -- -- memcpy(info, req->iv, ivsize); -- } -- -- aead_request_set_callback(subreq, req->base.flags, compl, data); -+ aead_request_set_callback(subreq, req->base.flags, -+ req->base.complete, req->base.data); - aead_request_set_crypt(subreq, req->dst, req->dst, - req->cryptlen, info); - aead_request_set_ad(subreq, req->assoclen); - -- crypto_xor(info, ctx->salt, ivsize); -+ memcpy(&nseqno, info + ivsize - 8, 8); -+ seqno = be64_to_cpu(nseqno); -+ memset(info, 0, ivsize); -+ - scatterwalk_map_and_copy(info, req->dst, req->assoclen, ivsize, 1); -- echainiv_read_iv(info, ivsize); - -- err = crypto_aead_encrypt(subreq); -- echainiv_encrypt_complete2(req, err); -- return err; -+ do { -+ u64 a; -+ -+ memcpy(&a, ctx->salt + ivsize - 8, 8); -+ -+ a |= 1; -+ a *= seqno; -+ -+ memcpy(info + ivsize - 8, &a, 8); -+ } while ((ivsize -= 8)); -+ -+ return crypto_aead_encrypt(subreq); - } - - static int echainiv_decrypt(struct aead_request *req) -@@ -192,8 +127,7 @@ static int echainiv_aead_create(struct crypto_template *tmpl, - alg = crypto_spawn_aead_alg(spawn); - - err = -EINVAL; -- if (inst->alg.ivsize & (sizeof(u32) - 1) || -- inst->alg.ivsize > MAX_IV_SIZE) -+ if (inst->alg.ivsize & (sizeof(u64) - 1) || !inst->alg.ivsize) - goto free_inst; - - inst->alg.encrypt = echainiv_encrypt; -@@ -202,7 +136,6 @@ static int echainiv_aead_create(struct crypto_template *tmpl, - inst->alg.init = aead_init_geniv; - inst->alg.exit = aead_exit_geniv; - -- inst->alg.base.cra_alignmask |= __alignof__(u32) - 1; - inst->alg.base.cra_ctxsize = sizeof(struct aead_geniv_ctx); - inst->alg.base.cra_ctxsize += inst->alg.ivsize; - -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c -index 4bef72a9d106..3fda594700e0 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c -@@ -59,9 +59,11 @@ static void - nv40_perfctr_next(struct nvkm_pm *pm, struct nvkm_perfdom *dom) - { - struct nvkm_device *device = pm->engine.subdev.device; -- if (pm->sequence != pm->sequence) { -+ struct nv40_pm *nv40pm = container_of(pm, struct nv40_pm, base); -+ -+ if (nv40pm->sequence != pm->sequence) { - nvkm_wr32(device, 0x400084, 0x00000020); -- pm->sequence = pm->sequence; -+ nv40pm->sequence = pm->sequence; - } - } - -diff --git a/drivers/gpu/drm/qxl/qxl_draw.c b/drivers/gpu/drm/qxl/qxl_draw.c -index 56e1d633875e..6e6c76080d6a 100644 ---- a/drivers/gpu/drm/qxl/qxl_draw.c -+++ b/drivers/gpu/drm/qxl/qxl_draw.c -@@ -136,6 +136,8 @@ static int qxl_palette_create_1bit(struct qxl_bo *palette_bo, - * correctly globaly, since that would require - * tracking all of our palettes. */ - ret = qxl_bo_kmap(palette_bo, (void **)&pal); -+ if (ret) -+ return ret; - pal->num_ents = 2; - pal->unique = unique++; - if (visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR) { -diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c -index 76e699f9ed97..eef3aa6007f1 100644 ---- a/drivers/i2c/busses/i2c-eg20t.c -+++ b/drivers/i2c/busses/i2c-eg20t.c -@@ -773,13 +773,6 @@ static int pch_i2c_probe(struct pci_dev *pdev, - /* Set the number of I2C channel instance */ - adap_info->ch_num = id->driver_data; - -- ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED, -- KBUILD_MODNAME, adap_info); -- if (ret) { -- pch_pci_err(pdev, "request_irq FAILED\n"); -- goto err_request_irq; -- } -- - for (i = 0; i < adap_info->ch_num; i++) { - pch_adap = &adap_info->pch_data[i].pch_adapter; - adap_info->pch_i2c_suspended = false; -@@ -796,6 +789,17 @@ static int pch_i2c_probe(struct pci_dev *pdev, - adap_info->pch_data[i].pch_base_address = base_addr + 0x100 * i; - - pch_adap->dev.parent = &pdev->dev; -+ } -+ -+ ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED, -+ KBUILD_MODNAME, adap_info); -+ if (ret) { -+ pch_pci_err(pdev, "request_irq FAILED\n"); -+ goto err_request_irq; -+ } -+ -+ for (i = 0; i < adap_info->ch_num; i++) { -+ pch_adap = &adap_info->pch_data[i].pch_adapter; - - pch_i2c_init(&adap_info->pch_data[i]); - -diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c -index fdcbdab808e9..33b11563cde7 100644 ---- a/drivers/i2c/busses/i2c-qup.c -+++ b/drivers/i2c/busses/i2c-qup.c -@@ -727,7 +727,8 @@ static int qup_i2c_pm_resume_runtime(struct device *device) - #ifdef CONFIG_PM_SLEEP - static int qup_i2c_suspend(struct device *device) - { -- qup_i2c_pm_suspend_runtime(device); -+ if (!pm_runtime_suspended(device)) -+ return qup_i2c_pm_suspend_runtime(device); - return 0; - } - -diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c -index 7ede941e9301..131b434af994 100644 ---- a/drivers/iio/industrialio-core.c -+++ b/drivers/iio/industrialio-core.c -@@ -433,16 +433,15 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) - scale_db = true; - case IIO_VAL_INT_PLUS_MICRO: - if (vals[1] < 0) -- return sprintf(buf, "-%ld.%06u%s\n", abs(vals[0]), -- -vals[1], -- scale_db ? " dB" : ""); -+ return sprintf(buf, "-%d.%06u%s\n", abs(vals[0]), -+ -vals[1], scale_db ? " dB" : ""); - else - return sprintf(buf, "%d.%06u%s\n", vals[0], vals[1], - scale_db ? " dB" : ""); - case IIO_VAL_INT_PLUS_NANO: - if (vals[1] < 0) -- return sprintf(buf, "-%ld.%09u\n", abs(vals[0]), -- -vals[1]); -+ return sprintf(buf, "-%d.%09u\n", abs(vals[0]), -+ -vals[1]); - else - return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); - case IIO_VAL_FRACTIONAL: -diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c -index 3821c4786662..565bb2c140ed 100644 ---- a/drivers/iommu/dmar.c -+++ b/drivers/iommu/dmar.c -@@ -1858,10 +1858,11 @@ static int dmar_hp_remove_drhd(struct acpi_dmar_header *header, void *arg) - /* - * All PCI devices managed by this unit should have been destroyed. - */ -- if (!dmaru->include_all && dmaru->devices && dmaru->devices_cnt) -+ if (!dmaru->include_all && dmaru->devices && dmaru->devices_cnt) { - for_each_active_dev_scope(dmaru->devices, - dmaru->devices_cnt, i, dev) - return -EBUSY; -+ } - - ret = dmar_ir_hotplug(dmaru, false); - if (ret == 0) -diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c -index 24d81308a1a6..b7f852d824a3 100644 ---- a/drivers/iommu/intel-iommu.c -+++ b/drivers/iommu/intel-iommu.c -@@ -4182,10 +4182,11 @@ int dmar_check_one_atsr(struct acpi_dmar_header *hdr, void *arg) - if (!atsru) - return 0; - -- if (!atsru->include_all && atsru->devices && atsru->devices_cnt) -+ if (!atsru->include_all && atsru->devices && atsru->devices_cnt) { - for_each_active_dev_scope(atsru->devices, atsru->devices_cnt, - i, dev) - return -EBUSY; -+ } - - return 0; - } -diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c -index f0480d687f17..ba780c45f645 100644 ---- a/drivers/media/platform/am437x/am437x-vpfe.c -+++ b/drivers/media/platform/am437x/am437x-vpfe.c -@@ -1706,7 +1706,7 @@ static int vpfe_get_app_input_index(struct vpfe_device *vpfe, - sdinfo = &cfg->sub_devs[i]; - client = v4l2_get_subdevdata(sdinfo->sd); - if (client->addr == curr_client->addr && -- client->adapter->nr == client->adapter->nr) { -+ client->adapter->nr == curr_client->adapter->nr) { - if (vpfe->current_input >= 1) - return -1; - *app_input_index = j + vpfe->current_input; -diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c -index 744ca5cacc9b..f9fa3fad728e 100644 ---- a/drivers/mtd/maps/pmcmsp-flash.c -+++ b/drivers/mtd/maps/pmcmsp-flash.c -@@ -75,15 +75,15 @@ static int __init init_msp_flash(void) - - printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt); - -- msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL); -+ msp_flash = kcalloc(fcnt, sizeof(*msp_flash), GFP_KERNEL); - if (!msp_flash) - return -ENOMEM; - -- msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL); -+ msp_parts = kcalloc(fcnt, sizeof(*msp_parts), GFP_KERNEL); - if (!msp_parts) - goto free_msp_flash; - -- msp_maps = kcalloc(fcnt, sizeof(struct mtd_info), GFP_KERNEL); -+ msp_maps = kcalloc(fcnt, sizeof(*msp_maps), GFP_KERNEL); - if (!msp_maps) - goto free_msp_parts; - -diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c -index 142fc3d79463..784c6e1a0391 100644 ---- a/drivers/mtd/maps/sa1100-flash.c -+++ b/drivers/mtd/maps/sa1100-flash.c -@@ -230,8 +230,10 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev, - - info->mtd = mtd_concat_create(cdev, info->num_subdev, - plat->name); -- if (info->mtd == NULL) -+ if (info->mtd == NULL) { - ret = -ENXIO; -+ goto err; -+ } - } - info->mtd->dev.parent = &pdev->dev; - -diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c -index b3d70a7a5262..5dca77e0ffed 100644 ---- a/drivers/net/bonding/bond_main.c -+++ b/drivers/net/bonding/bond_main.c -@@ -1317,9 +1317,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) - slave_dev->name); - } - -- /* already enslaved */ -- if (slave_dev->flags & IFF_SLAVE) { -- netdev_dbg(bond_dev, "Error: Device was already enslaved\n"); -+ /* already in-use? */ -+ if (netdev_is_rx_handler_busy(slave_dev)) { -+ netdev_err(bond_dev, -+ "Error: Device is in use and cannot be enslaved\n"); - return -EBUSY; - } - -diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c -index 41c0fc9f3b14..16f7cadda5c3 100644 ---- a/drivers/net/can/flexcan.c -+++ b/drivers/net/can/flexcan.c -@@ -1268,11 +1268,10 @@ static int __maybe_unused flexcan_suspend(struct device *device) - struct flexcan_priv *priv = netdev_priv(dev); - int err; - -- err = flexcan_chip_disable(priv); -- if (err) -- return err; -- - if (netif_running(dev)) { -+ err = flexcan_chip_disable(priv); -+ if (err) -+ return err; - netif_stop_queue(dev); - netif_device_detach(dev); - } -@@ -1285,13 +1284,17 @@ static int __maybe_unused flexcan_resume(struct device *device) - { - struct net_device *dev = dev_get_drvdata(device); - struct flexcan_priv *priv = netdev_priv(dev); -+ int err; - - priv->can.state = CAN_STATE_ERROR_ACTIVE; - if (netif_running(dev)) { - netif_device_attach(dev); - netif_start_queue(dev); -+ err = flexcan_chip_enable(priv); -+ if (err) -+ return err; - } -- return flexcan_chip_enable(priv); -+ return 0; - } - - static SIMPLE_DEV_PM_OPS(flexcan_pm_ops, flexcan_suspend, flexcan_resume); -diff --git a/drivers/net/dsa/bcm_sf2.h b/drivers/net/dsa/bcm_sf2.h -index 6bba1c98d764..c7994e372284 100644 ---- a/drivers/net/dsa/bcm_sf2.h -+++ b/drivers/net/dsa/bcm_sf2.h -@@ -187,8 +187,8 @@ static inline void name##_writeq(struct bcm_sf2_priv *priv, u64 val, \ - static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \ - u32 mask) \ - { \ -- intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ - priv->irq##which##_mask &= ~(mask); \ -+ intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ - } \ - static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \ - u32 mask) \ -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c -index 037fc4cdf5af..cc199063612a 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c -@@ -143,13 +143,14 @@ static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx) - return cmd->cmd_buf + (idx << cmd->log_stride); - } - --static u8 xor8_buf(void *buf, int len) -+static u8 xor8_buf(void *buf, size_t offset, int len) - { - u8 *ptr = buf; - u8 sum = 0; - int i; -+ int end = len + offset; - -- for (i = 0; i < len; i++) -+ for (i = offset; i < end; i++) - sum ^= ptr[i]; - - return sum; -@@ -157,41 +158,49 @@ static u8 xor8_buf(void *buf, int len) - - static int verify_block_sig(struct mlx5_cmd_prot_block *block) - { -- if (xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 1) != 0xff) -+ size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); -+ int xor_len = sizeof(*block) - sizeof(block->data) - 1; -+ -+ if (xor8_buf(block, rsvd0_off, xor_len) != 0xff) - return -EINVAL; - -- if (xor8_buf(block, sizeof(*block)) != 0xff) -+ if (xor8_buf(block, 0, sizeof(*block)) != 0xff) - return -EINVAL; - - return 0; - } - --static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, -- int csum) -+static void calc_block_sig(struct mlx5_cmd_prot_block *block) - { -- block->token = token; -- if (csum) { -- block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - -- sizeof(block->data) - 2); -- block->sig = ~xor8_buf(block, sizeof(*block) - 1); -- } -+ int ctrl_xor_len = sizeof(*block) - sizeof(block->data) - 2; -+ size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); -+ -+ block->ctrl_sig = ~xor8_buf(block, rsvd0_off, ctrl_xor_len); -+ block->sig = ~xor8_buf(block, 0, sizeof(*block) - 1); - } - --static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) -+static void calc_chain_sig(struct mlx5_cmd_msg *msg) - { - struct mlx5_cmd_mailbox *next = msg->next; -- -- while (next) { -- calc_block_sig(next->buf, token, csum); -+ int size = msg->len; -+ int blen = size - min_t(int, sizeof(msg->first.data), size); -+ int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) -+ / MLX5_CMD_DATA_BLOCK_SIZE; -+ int i = 0; -+ -+ for (i = 0; i < n && next; i++) { -+ calc_block_sig(next->buf); - next = next->next; - } - } - - static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) - { -- ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); -- calc_chain_sig(ent->in, ent->token, csum); -- calc_chain_sig(ent->out, ent->token, csum); -+ ent->lay->sig = ~xor8_buf(ent->lay, 0, sizeof(*ent->lay)); -+ if (csum) { -+ calc_chain_sig(ent->in); -+ calc_chain_sig(ent->out); -+ } - } - - static void poll_timeout(struct mlx5_cmd_work_ent *ent) -@@ -222,12 +231,17 @@ static int verify_signature(struct mlx5_cmd_work_ent *ent) - struct mlx5_cmd_mailbox *next = ent->out->next; - int err; - u8 sig; -+ int size = ent->out->len; -+ int blen = size - min_t(int, sizeof(ent->out->first.data), size); -+ int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) -+ / MLX5_CMD_DATA_BLOCK_SIZE; -+ int i = 0; - -- sig = xor8_buf(ent->lay, sizeof(*ent->lay)); -+ sig = xor8_buf(ent->lay, 0, sizeof(*ent->lay)); - if (sig != 0xff) - return -EINVAL; - -- while (next) { -+ for (i = 0; i < n && next; i++) { - err = verify_block_sig(next->buf); - if (err) - return err; -@@ -641,7 +655,6 @@ static void cmd_work_handler(struct work_struct *work) - spin_unlock_irqrestore(&cmd->alloc_lock, flags); - } - -- ent->token = alloc_token(cmd); - cmd->ent_arr[ent->idx] = ent; - lay = get_inst(cmd, ent->idx); - ent->lay = lay; -@@ -755,7 +768,8 @@ static u8 *get_status_ptr(struct mlx5_outbox_hdr *out) - static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, - struct mlx5_cmd_msg *out, void *uout, int uout_size, - mlx5_cmd_cbk_t callback, -- void *context, int page_queue, u8 *status) -+ void *context, int page_queue, u8 *status, -+ u8 token) - { - struct mlx5_cmd *cmd = &dev->cmd; - struct mlx5_cmd_work_ent *ent; -@@ -772,6 +786,8 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, - if (IS_ERR(ent)) - return PTR_ERR(ent); - -+ ent->token = token; -+ - if (!callback) - init_completion(&ent->done); - -@@ -844,7 +860,8 @@ static const struct file_operations fops = { - .write = dbg_write, - }; - --static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) -+static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size, -+ u8 token) - { - struct mlx5_cmd_prot_block *block; - struct mlx5_cmd_mailbox *next; -@@ -870,6 +887,7 @@ static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) - memcpy(block->data, from, copy); - from += copy; - size -= copy; -+ block->token = token; - next = next->next; - } - -@@ -939,7 +957,8 @@ static void free_cmd_box(struct mlx5_core_dev *dev, - } - - static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, -- gfp_t flags, int size) -+ gfp_t flags, int size, -+ u8 token) - { - struct mlx5_cmd_mailbox *tmp, *head = NULL; - struct mlx5_cmd_prot_block *block; -@@ -968,6 +987,7 @@ static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, - tmp->next = head; - block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); - block->block_num = cpu_to_be32(n - i - 1); -+ block->token = token; - head = tmp; - } - msg->next = head; -@@ -1351,7 +1371,7 @@ static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size, - } - - if (IS_ERR(msg)) -- msg = mlx5_alloc_cmd_msg(dev, gfp, in_size); -+ msg = mlx5_alloc_cmd_msg(dev, gfp, in_size, 0); - - return msg; - } -@@ -1376,6 +1396,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, - int err; - u8 status = 0; - u32 drv_synd; -+ u8 token; - - if (pci_channel_offline(dev->pdev) || - dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { -@@ -1394,20 +1415,22 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, - return err; - } - -- err = mlx5_copy_to_msg(inb, in, in_size); -+ token = alloc_token(&dev->cmd); -+ -+ err = mlx5_copy_to_msg(inb, in, in_size, token); - if (err) { - mlx5_core_warn(dev, "err %d\n", err); - goto out_in; - } - -- outb = mlx5_alloc_cmd_msg(dev, gfp, out_size); -+ outb = mlx5_alloc_cmd_msg(dev, gfp, out_size, token); - if (IS_ERR(outb)) { - err = PTR_ERR(outb); - goto out_in; - } - - err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context, -- pages_queue, &status); -+ pages_queue, &status, token); - if (err) - goto out_out; - -@@ -1475,7 +1498,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev) - INIT_LIST_HEAD(&cmd->cache.med.head); - - for (i = 0; i < NUM_LONG_LISTS; i++) { -- msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE); -+ msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE, 0); - if (IS_ERR(msg)) { - err = PTR_ERR(msg); - goto ex_err; -@@ -1485,7 +1508,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev) - } - - for (i = 0; i < NUM_MED_LISTS; i++) { -- msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE); -+ msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE, 0); - if (IS_ERR(msg)) { - err = PTR_ERR(msg); - goto ex_err; -diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c -index 0e2fc1a844ab..8c44cf6ff7a2 100644 ---- a/drivers/net/ethernet/smsc/smc91x.c -+++ b/drivers/net/ethernet/smsc/smc91x.c -@@ -2269,6 +2269,13 @@ static int smc_drv_probe(struct platform_device *pdev) - if (pd) { - memcpy(&lp->cfg, pd, sizeof(lp->cfg)); - lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); -+ -+ if (!SMC_8BIT(lp) && !SMC_16BIT(lp)) { -+ dev_err(&pdev->dev, -+ "at least one of 8-bit or 16-bit access support is required.\n"); -+ ret = -ENXIO; -+ goto out_free_netdev; -+ } - } - - #if IS_BUILTIN(CONFIG_OF) -diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h -index a3c129e1e40a..29df0465daf4 100644 ---- a/drivers/net/ethernet/smsc/smc91x.h -+++ b/drivers/net/ethernet/smsc/smc91x.h -@@ -37,6 +37,27 @@ - #include - - /* -+ * Any 16-bit access is performed with two 8-bit accesses if the hardware -+ * can't do it directly. Most registers are 16-bit so those are mandatory. -+ */ -+#define SMC_outw_b(x, a, r) \ -+ do { \ -+ unsigned int __val16 = (x); \ -+ unsigned int __reg = (r); \ -+ SMC_outb(__val16, a, __reg); \ -+ SMC_outb(__val16 >> 8, a, __reg + (1 << SMC_IO_SHIFT)); \ -+ } while (0) -+ -+#define SMC_inw_b(a, r) \ -+ ({ \ -+ unsigned int __val16; \ -+ unsigned int __reg = r; \ -+ __val16 = SMC_inb(a, __reg); \ -+ __val16 |= SMC_inb(a, __reg + (1 << SMC_IO_SHIFT)) << 8; \ -+ __val16; \ -+ }) -+ -+/* - * Define your architecture specific bus configuration parameters here. - */ - -@@ -55,10 +76,30 @@ - #define SMC_IO_SHIFT (lp->io_shift) - - #define SMC_inb(a, r) readb((a) + (r)) --#define SMC_inw(a, r) readw((a) + (r)) -+#define SMC_inw(a, r) \ -+ ({ \ -+ unsigned int __smc_r = r; \ -+ SMC_16BIT(lp) ? readw((a) + __smc_r) : \ -+ SMC_8BIT(lp) ? SMC_inw_b(a, __smc_r) : \ -+ ({ BUG(); 0; }); \ -+ }) -+ - #define SMC_inl(a, r) readl((a) + (r)) - #define SMC_outb(v, a, r) writeb(v, (a) + (r)) -+#define SMC_outw(v, a, r) \ -+ do { \ -+ unsigned int __v = v, __smc_r = r; \ -+ if (SMC_16BIT(lp)) \ -+ __SMC_outw(__v, a, __smc_r); \ -+ else if (SMC_8BIT(lp)) \ -+ SMC_outw_b(__v, a, __smc_r); \ -+ else \ -+ BUG(); \ -+ } while (0) -+ - #define SMC_outl(v, a, r) writel(v, (a) + (r)) -+#define SMC_insb(a, r, p, l) readsb((a) + (r), p, l) -+#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, l) - #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) - #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) - #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) -@@ -66,7 +107,7 @@ - #define SMC_IRQ_FLAGS (-1) /* from resource */ - - /* We actually can't write halfwords properly if not word aligned */ --static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) -+static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg) - { - if ((machine_is_mainstone() || machine_is_stargate2() || - machine_is_pxa_idp()) && reg & 2) { -@@ -405,24 +446,8 @@ smc_pxa_dma_insw(void __iomem *ioaddr, struct smc_local *lp, int reg, int dma, - - #if ! SMC_CAN_USE_16BIT - --/* -- * Any 16-bit access is performed with two 8-bit accesses if the hardware -- * can't do it directly. Most registers are 16-bit so those are mandatory. -- */ --#define SMC_outw(x, ioaddr, reg) \ -- do { \ -- unsigned int __val16 = (x); \ -- SMC_outb( __val16, ioaddr, reg ); \ -- SMC_outb( __val16 >> 8, ioaddr, reg + (1 << SMC_IO_SHIFT));\ -- } while (0) --#define SMC_inw(ioaddr, reg) \ -- ({ \ -- unsigned int __val16; \ -- __val16 = SMC_inb( ioaddr, reg ); \ -- __val16 |= SMC_inb( ioaddr, reg + (1 << SMC_IO_SHIFT)) << 8; \ -- __val16; \ -- }) -- -+#define SMC_outw(x, ioaddr, reg) SMC_outw_b(x, ioaddr, reg) -+#define SMC_inw(ioaddr, reg) SMC_inw_b(ioaddr, reg) - #define SMC_insw(a, r, p, l) BUG() - #define SMC_outsw(a, r, p, l) BUG() - -diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c -index 47cd306dbb3c..bba0ca786aaa 100644 ---- a/drivers/net/phy/phy.c -+++ b/drivers/net/phy/phy.c -@@ -640,8 +640,10 @@ phy_err: - int phy_start_interrupts(struct phy_device *phydev) - { - atomic_set(&phydev->irq_disable, 0); -- if (request_irq(phydev->irq, phy_interrupt, 0, "phy_interrupt", -- phydev) < 0) { -+ if (request_irq(phydev->irq, phy_interrupt, -+ IRQF_SHARED, -+ "phy_interrupt", -+ phydev) < 0) { - pr_warn("%s: Can't get IRQ %d (PHY)\n", - phydev->bus->name, phydev->irq); - phydev->irq = PHY_POLL; -diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c -index 1bdeacf7b257..bc70ce62bc03 100644 ---- a/drivers/net/wireless/ath/ath9k/init.c -+++ b/drivers/net/wireless/ath/ath9k/init.c -@@ -869,8 +869,8 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) - hw->wiphy->interface_modes |= - BIT(NL80211_IFTYPE_P2P_DEVICE); - -- hw->wiphy->iface_combinations = if_comb; -- hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); -+ hw->wiphy->iface_combinations = if_comb; -+ hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); - } - - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; -diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c -index 93bdf684babe..ae047ab7a4df 100644 ---- a/drivers/net/wireless/iwlegacy/3945.c -+++ b/drivers/net/wireless/iwlegacy/3945.c -@@ -1019,12 +1019,13 @@ il3945_hw_txq_ctx_free(struct il_priv *il) - int txq_id; - - /* Tx queues */ -- if (il->txq) -+ if (il->txq) { - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == IL39_CMD_QUEUE_NUM) - il_cmd_queue_free(il); - else - il_tx_queue_free(il, txq_id); -+ } - - /* free tx queue structure */ - il_free_txq_mem(il); -diff --git a/drivers/net/wireless/iwlwifi/dvm/calib.c b/drivers/net/wireless/iwlwifi/dvm/calib.c -index 20e6aa910700..c148085742a0 100644 ---- a/drivers/net/wireless/iwlwifi/dvm/calib.c -+++ b/drivers/net/wireless/iwlwifi/dvm/calib.c -@@ -901,7 +901,7 @@ static void iwlagn_gain_computation(struct iwl_priv *priv, - /* bound gain by 2 bits value max, 3rd bit is sign */ - data->delta_gain_code[i] = - min(abs(delta_g), -- (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); -+ (s32) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); - - if (delta_g < 0) - /* -diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c -index 9c65f134d447..da7a75f82489 100644 ---- a/drivers/power/max17042_battery.c -+++ b/drivers/power/max17042_battery.c -@@ -457,13 +457,16 @@ static inline void max17042_write_model_data(struct max17042_chip *chip, - } - - static inline void max17042_read_model_data(struct max17042_chip *chip, -- u8 addr, u32 *data, int size) -+ u8 addr, u16 *data, int size) - { - struct regmap *map = chip->regmap; - int i; -+ u32 tmp; - -- for (i = 0; i < size; i++) -- regmap_read(map, addr + i, &data[i]); -+ for (i = 0; i < size; i++) { -+ regmap_read(map, addr + i, &tmp); -+ data[i] = (u16)tmp; -+ } - } - - static inline int max17042_model_data_compare(struct max17042_chip *chip, -@@ -486,7 +489,7 @@ static int max17042_init_model(struct max17042_chip *chip) - { - int ret; - int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl); -- u32 *temp_data; -+ u16 *temp_data; - - temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL); - if (!temp_data) -@@ -501,7 +504,7 @@ static int max17042_init_model(struct max17042_chip *chip) - ret = max17042_model_data_compare( - chip, - chip->pdata->config_data->cell_char_tbl, -- (u16 *)temp_data, -+ temp_data, - table_size); - - max10742_lock_model(chip); -@@ -514,7 +517,7 @@ static int max17042_verify_model_lock(struct max17042_chip *chip) - { - int i; - int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl); -- u32 *temp_data; -+ u16 *temp_data; - int ret = 0; - - temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL); -diff --git a/drivers/power/reset/hisi-reboot.c b/drivers/power/reset/hisi-reboot.c -index 9ab7f562a83b..f69387e12c1e 100644 ---- a/drivers/power/reset/hisi-reboot.c -+++ b/drivers/power/reset/hisi-reboot.c -@@ -53,13 +53,16 @@ static int hisi_reboot_probe(struct platform_device *pdev) - - if (of_property_read_u32(np, "reboot-offset", &reboot_offset) < 0) { - pr_err("failed to find reboot-offset property\n"); -+ iounmap(base); - return -EINVAL; - } - - err = register_restart_handler(&hisi_restart_nb); -- if (err) -+ if (err) { - dev_err(&pdev->dev, "cannot register restart handler (err=%d)\n", - err); -+ iounmap(base); -+ } - - return err; - } -diff --git a/drivers/power/tps65217_charger.c b/drivers/power/tps65217_charger.c -index d9f56730c735..040a40b4b173 100644 ---- a/drivers/power/tps65217_charger.c -+++ b/drivers/power/tps65217_charger.c -@@ -205,6 +205,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) - if (!charger) - return -ENOMEM; - -+ platform_set_drvdata(pdev, charger); - charger->tps = tps; - charger->dev = &pdev->dev; - -diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c -index d24ca5f281b4..7831bc6b51dd 100644 ---- a/drivers/pwm/core.c -+++ b/drivers/pwm/core.c -@@ -889,7 +889,7 @@ EXPORT_SYMBOL_GPL(devm_pwm_put); - */ - bool pwm_can_sleep(struct pwm_device *pwm) - { -- return pwm->chip->can_sleep; -+ return true; - } - EXPORT_SYMBOL_GPL(pwm_can_sleep); - -diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c -index 3f8d357b1bac..278e10cd771f 100644 ---- a/drivers/scsi/megaraid/megaraid_sas_base.c -+++ b/drivers/scsi/megaraid/megaraid_sas_base.c -@@ -5941,11 +5941,11 @@ static void megasas_detach_one(struct pci_dev *pdev) - if (fusion->ld_drv_map[i]) - free_pages((ulong)fusion->ld_drv_map[i], - fusion->drv_map_pages); -- if (fusion->pd_seq_sync) -- dma_free_coherent(&instance->pdev->dev, -- pd_seq_map_sz, -- fusion->pd_seq_sync[i], -- fusion->pd_seq_phys[i]); -+ if (fusion->pd_seq_sync[i]) -+ dma_free_coherent(&instance->pdev->dev, -+ pd_seq_map_sz, -+ fusion->pd_seq_sync[i], -+ fusion->pd_seq_phys[i]); - } - free_pages((ulong)instance->ctrl_context, - instance->ctrl_context_pages); -diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c -index bb40f3728742..20314ff08be0 100644 ---- a/drivers/staging/iio/adc/ad7192.c -+++ b/drivers/staging/iio/adc/ad7192.c -@@ -236,7 +236,7 @@ static int ad7192_setup(struct ad7192_state *st, - st->mclk = pdata->ext_clk_hz; - else - st->mclk = AD7192_INT_FREQ_MHZ; -- break; -+ break; - default: - ret = -EINVAL; - goto out; -diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h -index c37149b929be..502d3892d8a4 100644 ---- a/fs/autofs4/autofs_i.h -+++ b/fs/autofs4/autofs_i.h -@@ -79,9 +79,13 @@ struct autofs_info { - }; - - #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ --#define AUTOFS_INF_NO_RCU (1<<1) /* the dentry is being considered -+#define AUTOFS_INF_WANT_EXPIRE (1<<1) /* the dentry is being considered - * for expiry, so RCU_walk is -- * not permitted -+ * not permitted. If it progresses to -+ * actual expiry attempt, the flag is -+ * not cleared when EXPIRING is set - -+ * in that case it gets cleared only -+ * when it comes to clearing EXPIRING. - */ - #define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */ - -diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c -index 1cebc3c52fa5..7a5a598a2d94 100644 ---- a/fs/autofs4/expire.c -+++ b/fs/autofs4/expire.c -@@ -315,19 +315,17 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, - if (ino->flags & AUTOFS_INF_PENDING) - goto out; - if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { -- ino->flags |= AUTOFS_INF_NO_RCU; -+ ino->flags |= AUTOFS_INF_WANT_EXPIRE; - spin_unlock(&sbi->fs_lock); - synchronize_rcu(); - spin_lock(&sbi->fs_lock); - if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { - ino->flags |= AUTOFS_INF_EXPIRING; -- smp_mb(); -- ino->flags &= ~AUTOFS_INF_NO_RCU; - init_completion(&ino->expire_complete); - spin_unlock(&sbi->fs_lock); - return root; - } -- ino->flags &= ~AUTOFS_INF_NO_RCU; -+ ino->flags &= ~AUTOFS_INF_WANT_EXPIRE; - } - out: - spin_unlock(&sbi->fs_lock); -@@ -417,6 +415,7 @@ static struct dentry *should_expire(struct dentry *dentry, - } - return NULL; - } -+ - /* - * Find an eligible tree to time-out - * A tree is eligible if :- -@@ -432,6 +431,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, - struct dentry *root = sb->s_root; - struct dentry *dentry; - struct dentry *expired; -+ struct dentry *found; - struct autofs_info *ino; - - if (!root) -@@ -442,48 +442,54 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, - - dentry = NULL; - while ((dentry = get_next_positive_subdir(dentry, root))) { -+ int flags = how; -+ - spin_lock(&sbi->fs_lock); - ino = autofs4_dentry_ino(dentry); -- if (ino->flags & AUTOFS_INF_NO_RCU) -- expired = NULL; -- else -- expired = should_expire(dentry, mnt, timeout, how); -- if (!expired) { -+ if (ino->flags & AUTOFS_INF_WANT_EXPIRE) { - spin_unlock(&sbi->fs_lock); - continue; - } -+ spin_unlock(&sbi->fs_lock); -+ -+ expired = should_expire(dentry, mnt, timeout, flags); -+ if (!expired) -+ continue; -+ -+ spin_lock(&sbi->fs_lock); - ino = autofs4_dentry_ino(expired); -- ino->flags |= AUTOFS_INF_NO_RCU; -+ ino->flags |= AUTOFS_INF_WANT_EXPIRE; - spin_unlock(&sbi->fs_lock); - synchronize_rcu(); -- spin_lock(&sbi->fs_lock); -- if (should_expire(expired, mnt, timeout, how)) { -- if (expired != dentry) -- dput(dentry); -- goto found; -- } - -- ino->flags &= ~AUTOFS_INF_NO_RCU; -+ /* Make sure a reference is not taken on found if -+ * things have changed. -+ */ -+ flags &= ~AUTOFS_EXP_LEAVES; -+ found = should_expire(expired, mnt, timeout, how); -+ if (!found || found != expired) -+ /* Something has changed, continue */ -+ goto next; -+ - if (expired != dentry) -- dput(expired); -+ dput(dentry); -+ -+ spin_lock(&sbi->fs_lock); -+ goto found; -+next: -+ spin_lock(&sbi->fs_lock); -+ ino->flags &= ~AUTOFS_INF_WANT_EXPIRE; - spin_unlock(&sbi->fs_lock); -+ if (expired != dentry) -+ dput(expired); - } - return NULL; - - found: - DPRINTK("returning %p %pd", expired, expired); - ino->flags |= AUTOFS_INF_EXPIRING; -- smp_mb(); -- ino->flags &= ~AUTOFS_INF_NO_RCU; - init_completion(&ino->expire_complete); - spin_unlock(&sbi->fs_lock); -- spin_lock(&sbi->lookup_lock); -- spin_lock(&expired->d_parent->d_lock); -- spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); -- list_move(&expired->d_parent->d_subdirs, &expired->d_child); -- spin_unlock(&expired->d_lock); -- spin_unlock(&expired->d_parent->d_lock); -- spin_unlock(&sbi->lookup_lock); - return expired; - } - -@@ -492,15 +498,27 @@ int autofs4_expire_wait(struct dentry *dentry, int rcu_walk) - struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); - struct autofs_info *ino = autofs4_dentry_ino(dentry); - int status; -+ int state; - - /* Block on any pending expire */ -- if (!(ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU))) -+ if (!(ino->flags & AUTOFS_INF_WANT_EXPIRE)) - return 0; - if (rcu_walk) - return -ECHILD; - -+retry: - spin_lock(&sbi->fs_lock); -- if (ino->flags & AUTOFS_INF_EXPIRING) { -+ state = ino->flags & (AUTOFS_INF_WANT_EXPIRE | AUTOFS_INF_EXPIRING); -+ if (state == AUTOFS_INF_WANT_EXPIRE) { -+ spin_unlock(&sbi->fs_lock); -+ /* -+ * Possibly being selected for expire, wait until -+ * it's selected or not. -+ */ -+ schedule_timeout_uninterruptible(HZ/10); -+ goto retry; -+ } -+ if (state & AUTOFS_INF_EXPIRING) { - spin_unlock(&sbi->fs_lock); - - DPRINTK("waiting for expire %p name=%pd", dentry, dentry); -@@ -551,7 +569,7 @@ int autofs4_expire_run(struct super_block *sb, - ino = autofs4_dentry_ino(dentry); - /* avoid rapid-fire expire attempts if expiry fails */ - ino->last_used = now; -- ino->flags &= ~AUTOFS_INF_EXPIRING; -+ ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE); - complete_all(&ino->expire_complete); - spin_unlock(&sbi->fs_lock); - -@@ -579,7 +597,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, - spin_lock(&sbi->fs_lock); - /* avoid rapid-fire expire attempts if expiry fails */ - ino->last_used = now; -- ino->flags &= ~AUTOFS_INF_EXPIRING; -+ ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE); - complete_all(&ino->expire_complete); - spin_unlock(&sbi->fs_lock); - dput(dentry); -diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c -index c6d7d3dbd52a..7a54c6a867c8 100644 ---- a/fs/autofs4/root.c -+++ b/fs/autofs4/root.c -@@ -455,7 +455,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) - * a mount-trap. - */ - struct inode *inode; -- if (ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU)) -+ if (ino->flags & AUTOFS_INF_WANT_EXPIRE) - return 0; - if (d_mountpoint(dentry)) - return 0; -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c -index 65f30b3b04f9..a7e18dbadf74 100644 ---- a/fs/btrfs/ioctl.c -+++ b/fs/btrfs/ioctl.c -@@ -1619,6 +1619,9 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file, - int namelen; - int ret = 0; - -+ if (!S_ISDIR(file_inode(file)->i_mode)) -+ return -ENOTDIR; -+ - ret = mnt_want_write_file(file); - if (ret) - goto out; -@@ -1676,6 +1679,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file, - struct btrfs_ioctl_vol_args *vol_args; - int ret; - -+ if (!S_ISDIR(file_inode(file)->i_mode)) -+ return -ENOTDIR; -+ - vol_args = memdup_user(arg, sizeof(*vol_args)); - if (IS_ERR(vol_args)) - return PTR_ERR(vol_args); -@@ -1699,6 +1705,9 @@ static noinline int btrfs_ioctl_snap_create_v2(struct file *file, - bool readonly = false; - struct btrfs_qgroup_inherit *inherit = NULL; - -+ if (!S_ISDIR(file_inode(file)->i_mode)) -+ return -ENOTDIR; -+ - vol_args = memdup_user(arg, sizeof(*vol_args)); - if (IS_ERR(vol_args)) - return PTR_ERR(vol_args); -@@ -2345,6 +2354,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, - int ret; - int err = 0; - -+ if (!S_ISDIR(dir->i_mode)) -+ return -ENOTDIR; -+ - vol_args = memdup_user(arg, sizeof(*vol_args)); - if (IS_ERR(vol_args)) - return PTR_ERR(vol_args); -diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c -index 5a7b3229b956..f34d6f5a5aca 100644 ---- a/fs/hostfs/hostfs_kern.c -+++ b/fs/hostfs/hostfs_kern.c -@@ -959,10 +959,11 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) - - if (S_ISLNK(root_inode->i_mode)) { - char *name = follow_link(host_root_path); -- if (IS_ERR(name)) -+ if (IS_ERR(name)) { - err = PTR_ERR(name); -- else -- err = read_name(root_inode, name); -+ goto out_put; -+ } -+ err = read_name(root_inode, name); - kfree(name); - if (err) - goto out_put; -diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c -index d2f97ecca6a5..e0e5f7c3c99f 100644 ---- a/fs/notify/fanotify/fanotify.c -+++ b/fs/notify/fanotify/fanotify.c -@@ -67,18 +67,7 @@ static int fanotify_get_response(struct fsnotify_group *group, - - pr_debug("%s: group=%p event=%p\n", __func__, group, event); - -- wait_event(group->fanotify_data.access_waitq, event->response || -- atomic_read(&group->fanotify_data.bypass_perm)); -- -- if (!event->response) { /* bypass_perm set */ -- /* -- * Event was canceled because group is being destroyed. Remove -- * it from group's event list because we are responsible for -- * freeing the permission event. -- */ -- fsnotify_remove_event(group, &event->fae.fse); -- return 0; -- } -+ wait_event(group->fanotify_data.access_waitq, event->response); - - /* userspace responded, convert to something usable */ - switch (event->response) { -diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c -index 8e8e6bcd1d43..a64313868d3a 100644 ---- a/fs/notify/fanotify/fanotify_user.c -+++ b/fs/notify/fanotify/fanotify_user.c -@@ -358,16 +358,20 @@ static int fanotify_release(struct inode *ignored, struct file *file) - - #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS - struct fanotify_perm_event_info *event, *next; -+ struct fsnotify_event *fsn_event; - - /* -- * There may be still new events arriving in the notification queue -- * but since userspace cannot use fanotify fd anymore, no event can -- * enter or leave access_list by now. -+ * Stop new events from arriving in the notification queue. since -+ * userspace cannot use fanotify fd anymore, no event can enter or -+ * leave access_list by now either. - */ -- spin_lock(&group->fanotify_data.access_lock); -- -- atomic_inc(&group->fanotify_data.bypass_perm); -+ fsnotify_group_stop_queueing(group); - -+ /* -+ * Process all permission events on access_list and notification queue -+ * and simulate reply from userspace. -+ */ -+ spin_lock(&group->fanotify_data.access_lock); - list_for_each_entry_safe(event, next, &group->fanotify_data.access_list, - fae.fse.list) { - pr_debug("%s: found group=%p event=%p\n", __func__, group, -@@ -379,12 +383,21 @@ static int fanotify_release(struct inode *ignored, struct file *file) - spin_unlock(&group->fanotify_data.access_lock); - - /* -- * Since bypass_perm is set, newly queued events will not wait for -- * access response. Wake up the already sleeping ones now. -- * synchronize_srcu() in fsnotify_destroy_group() will wait for all -- * processes sleeping in fanotify_handle_event() waiting for access -- * response and thus also for all permission events to be freed. -+ * Destroy all non-permission events. For permission events just -+ * dequeue them and set the response. They will be freed once the -+ * response is consumed and fanotify_get_response() returns. - */ -+ mutex_lock(&group->notification_mutex); -+ while (!fsnotify_notify_queue_is_empty(group)) { -+ fsn_event = fsnotify_remove_first_event(group); -+ if (!(fsn_event->mask & FAN_ALL_PERM_EVENTS)) -+ fsnotify_destroy_event(group, fsn_event); -+ else -+ FANOTIFY_PE(fsn_event)->response = FAN_ALLOW; -+ } -+ mutex_unlock(&group->notification_mutex); -+ -+ /* Response for all permission events it set, wakeup waiters */ - wake_up(&group->fanotify_data.access_waitq); - #endif - -@@ -755,7 +768,6 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) - spin_lock_init(&group->fanotify_data.access_lock); - init_waitqueue_head(&group->fanotify_data.access_waitq); - INIT_LIST_HEAD(&group->fanotify_data.access_list); -- atomic_set(&group->fanotify_data.bypass_perm, 0); - #endif - switch (flags & FAN_ALL_CLASS_BITS) { - case FAN_CLASS_NOTIF: -diff --git a/fs/notify/group.c b/fs/notify/group.c -index d16b62cb2854..18eb30c6bd8f 100644 ---- a/fs/notify/group.c -+++ b/fs/notify/group.c -@@ -40,6 +40,17 @@ static void fsnotify_final_destroy_group(struct fsnotify_group *group) - } - - /* -+ * Stop queueing new events for this group. Once this function returns -+ * fsnotify_add_event() will not add any new events to the group's queue. -+ */ -+void fsnotify_group_stop_queueing(struct fsnotify_group *group) -+{ -+ mutex_lock(&group->notification_mutex); -+ group->shutdown = true; -+ mutex_unlock(&group->notification_mutex); -+} -+ -+/* - * Trying to get rid of a group. Remove all marks, flush all events and release - * the group reference. - * Note that another thread calling fsnotify_clear_marks_by_group() may still -@@ -47,6 +58,14 @@ static void fsnotify_final_destroy_group(struct fsnotify_group *group) - */ - void fsnotify_destroy_group(struct fsnotify_group *group) - { -+ /* -+ * Stop queueing new events. The code below is careful enough to not -+ * require this but fanotify needs to stop queuing events even before -+ * fsnotify_destroy_group() is called and this makes the other callers -+ * of fsnotify_destroy_group() to see the same behavior. -+ */ -+ fsnotify_group_stop_queueing(group); -+ - /* clear all inode marks for this group */ - fsnotify_clear_marks_by_group(group); - -diff --git a/fs/notify/notification.c b/fs/notify/notification.c -index a95d8e037aeb..e455e83ceeeb 100644 ---- a/fs/notify/notification.c -+++ b/fs/notify/notification.c -@@ -82,7 +82,8 @@ void fsnotify_destroy_event(struct fsnotify_group *group, - * Add an event to the group notification queue. The group can later pull this - * event off the queue to deal with. The function returns 0 if the event was - * added to the queue, 1 if the event was merged with some other queued event, -- * 2 if the queue of events has overflown. -+ * 2 if the event was not queued - either the queue of events has overflown -+ * or the group is shutting down. - */ - int fsnotify_add_event(struct fsnotify_group *group, - struct fsnotify_event *event, -@@ -96,6 +97,11 @@ int fsnotify_add_event(struct fsnotify_group *group, - - mutex_lock(&group->notification_mutex); - -+ if (group->shutdown) { -+ mutex_unlock(&group->notification_mutex); -+ return 2; -+ } -+ - if (group->q_len >= group->max_events) { - ret = 2; - /* Queue overflow event only if it isn't already queued */ -@@ -126,21 +132,6 @@ queue: - } - - /* -- * Remove @event from group's notification queue. It is the responsibility of -- * the caller to destroy the event. -- */ --void fsnotify_remove_event(struct fsnotify_group *group, -- struct fsnotify_event *event) --{ -- mutex_lock(&group->notification_mutex); -- if (!list_empty(&event->list)) { -- list_del_init(&event->list); -- group->q_len--; -- } -- mutex_unlock(&group->notification_mutex); --} -- --/* - * Remove and return the first event from the notification list. It is the - * responsibility of the caller to destroy the obtained event - */ -diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c -index f90931335c6b..2e11658676eb 100644 ---- a/fs/ocfs2/dlm/dlmconvert.c -+++ b/fs/ocfs2/dlm/dlmconvert.c -@@ -262,7 +262,6 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, - struct dlm_lock *lock, int flags, int type) - { - enum dlm_status status; -- u8 old_owner = res->owner; - - mlog(0, "type=%d, convert_type=%d, busy=%d\n", lock->ml.type, - lock->ml.convert_type, res->state & DLM_LOCK_RES_IN_PROGRESS); -@@ -329,7 +328,6 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, - - spin_lock(&res->spinlock); - res->state &= ~DLM_LOCK_RES_IN_PROGRESS; -- lock->convert_pending = 0; - /* if it failed, move it back to granted queue. - * if master returns DLM_NORMAL and then down before sending ast, - * it may have already been moved to granted queue, reset to -@@ -338,12 +336,14 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, - if (status != DLM_NOTQUEUED) - dlm_error(status); - dlm_revert_pending_convert(res, lock); -- } else if ((res->state & DLM_LOCK_RES_RECOVERING) || -- (old_owner != res->owner)) { -- mlog(0, "res %.*s is in recovering or has been recovered.\n", -- res->lockname.len, res->lockname.name); -+ } else if (!lock->convert_pending) { -+ mlog(0, "%s: res %.*s, owner died and lock has been moved back " -+ "to granted list, retry convert.\n", -+ dlm->name, res->lockname.len, res->lockname.name); - status = DLM_RECOVERING; - } -+ -+ lock->convert_pending = 0; - bail: - spin_unlock(&res->spinlock); - -diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c -index 77d30cbd944d..56dd3957cc91 100644 ---- a/fs/ocfs2/file.c -+++ b/fs/ocfs2/file.c -@@ -1536,7 +1536,8 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, - u64 start, u64 len) - { - int ret = 0; -- u64 tmpend, end = start + len; -+ u64 tmpend = 0; -+ u64 end = start + len; - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - unsigned int csize = osb->s_clustersize; - handle_t *handle; -@@ -1568,18 +1569,31 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, - } - - /* -- * We want to get the byte offset of the end of the 1st cluster. -+ * If start is on a cluster boundary and end is somewhere in another -+ * cluster, we have not COWed the cluster starting at start, unless -+ * end is also within the same cluster. So, in this case, we skip this -+ * first call to ocfs2_zero_range_for_truncate() truncate and move on -+ * to the next one. - */ -- tmpend = (u64)osb->s_clustersize + (start & ~(osb->s_clustersize - 1)); -- if (tmpend > end) -- tmpend = end; -+ if ((start & (csize - 1)) != 0) { -+ /* -+ * We want to get the byte offset of the end of the 1st -+ * cluster. -+ */ -+ tmpend = (u64)osb->s_clustersize + -+ (start & ~(osb->s_clustersize - 1)); -+ if (tmpend > end) -+ tmpend = end; - -- trace_ocfs2_zero_partial_clusters_range1((unsigned long long)start, -- (unsigned long long)tmpend); -+ trace_ocfs2_zero_partial_clusters_range1( -+ (unsigned long long)start, -+ (unsigned long long)tmpend); - -- ret = ocfs2_zero_range_for_truncate(inode, handle, start, tmpend); -- if (ret) -- mlog_errno(ret); -+ ret = ocfs2_zero_range_for_truncate(inode, handle, start, -+ tmpend); -+ if (ret) -+ mlog_errno(ret); -+ } - - if (tmpend < end) { - /* -diff --git a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c -index b751eea32e20..5db6f45b3fed 100644 ---- a/fs/reiserfs/ibalance.c -+++ b/fs/reiserfs/ibalance.c -@@ -1153,8 +1153,9 @@ int balance_internal(struct tree_balance *tb, - insert_ptr); - } - -- memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE); - insert_ptr[0] = new_insert_ptr; -+ if (new_insert_ptr) -+ memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE); - - return order; - } -diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c -index 39090fc56f09..eb1b8c8acfcb 100644 ---- a/fs/xfs/xfs_buf.c -+++ b/fs/xfs/xfs_buf.c -@@ -1535,7 +1535,7 @@ xfs_wait_buftarg( - * ensure here that all reference counts have been dropped before we - * start walking the LRU list. - */ -- drain_workqueue(btp->bt_mount->m_buf_workqueue); -+ flush_workqueue(btp->bt_mount->m_buf_workqueue); - - /* loop until there is nothing left on the lru list. */ - while (list_lru_count(&btp->bt_lru)) { -diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h -index 533c4408529a..850d8822e8ff 100644 ---- a/include/linux/fsnotify_backend.h -+++ b/include/linux/fsnotify_backend.h -@@ -148,6 +148,7 @@ struct fsnotify_group { - #define FS_PRIO_1 1 /* fanotify content based access control */ - #define FS_PRIO_2 2 /* fanotify pre-content access */ - unsigned int priority; -+ bool shutdown; /* group is being shut down, don't queue more events */ - - /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ - struct mutex mark_mutex; /* protect marks_list */ -@@ -179,7 +180,6 @@ struct fsnotify_group { - spinlock_t access_lock; - struct list_head access_list; - wait_queue_head_t access_waitq; -- atomic_t bypass_perm; - #endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ - int f_flags; - unsigned int max_marks; -@@ -308,6 +308,8 @@ extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *op - extern void fsnotify_get_group(struct fsnotify_group *group); - /* drop reference on a group from fsnotify_alloc_group */ - extern void fsnotify_put_group(struct fsnotify_group *group); -+/* group destruction begins, stop queuing new events */ -+extern void fsnotify_group_stop_queueing(struct fsnotify_group *group); - /* destroy group */ - extern void fsnotify_destroy_group(struct fsnotify_group *group); - /* fasync handler function */ -@@ -320,8 +322,6 @@ extern int fsnotify_add_event(struct fsnotify_group *group, - struct fsnotify_event *event, - int (*merge)(struct list_head *, - struct fsnotify_event *)); --/* Remove passed event from groups notification queue */ --extern void fsnotify_remove_event(struct fsnotify_group *group, struct fsnotify_event *event); - /* true if the group notification queue is empty */ - extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); - /* return, but do not dequeue the first event on the notification queue */ -diff --git a/include/linux/kernel.h b/include/linux/kernel.h -index 924853d33a13..e571e592e53a 100644 ---- a/include/linux/kernel.h -+++ b/include/linux/kernel.h -@@ -202,26 +202,26 @@ extern int _cond_resched(void); - - /** - * abs - return absolute value of an argument -- * @x: the value. If it is unsigned type, it is converted to signed type first -- * (s64, long or int depending on its size). -+ * @x: the value. If it is unsigned type, it is converted to signed type first. -+ * char is treated as if it was signed (regardless of whether it really is) -+ * but the macro's return type is preserved as char. - * -- * Return: an absolute value of x. If x is 64-bit, macro's return type is s64, -- * otherwise it is signed long. -+ * Return: an absolute value of x. - */ --#define abs(x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ -- s64 __x = (x); \ -- (__x < 0) ? -__x : __x; \ -- }), ({ \ -- long ret; \ -- if (sizeof(x) == sizeof(long)) { \ -- long __x = (x); \ -- ret = (__x < 0) ? -__x : __x; \ -- } else { \ -- int __x = (x); \ -- ret = (__x < 0) ? -__x : __x; \ -- } \ -- ret; \ -- })) -+#define abs(x) __abs_choose_expr(x, long long, \ -+ __abs_choose_expr(x, long, \ -+ __abs_choose_expr(x, int, \ -+ __abs_choose_expr(x, short, \ -+ __abs_choose_expr(x, char, \ -+ __builtin_choose_expr( \ -+ __builtin_types_compatible_p(typeof(x), char), \ -+ (char)({ signed char __x = (x); __x<0?-__x:__x; }), \ -+ ((void)0))))))) -+ -+#define __abs_choose_expr(x, type, other) __builtin_choose_expr( \ -+ __builtin_types_compatible_p(typeof(x), signed type) || \ -+ __builtin_types_compatible_p(typeof(x), unsigned type), \ -+ ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other) - - /** - * reciprocal_scale - "scale" a value into range [0, ep_ro) -diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h -index b97d6823ef3c..4e9c75226f07 100644 ---- a/include/linux/netdevice.h -+++ b/include/linux/netdevice.h -@@ -3036,6 +3036,7 @@ static inline void napi_free_frags(struct napi_struct *napi) - napi->skb = NULL; - } - -+bool netdev_is_rx_handler_busy(struct net_device *dev); - int netdev_rx_handler_register(struct net_device *dev, - rx_handler_func_t *rx_handler, - void *rx_handler_data); -diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h -index 26eabf5ec718..fbfadba81c5a 100644 ---- a/include/linux/pagemap.h -+++ b/include/linux/pagemap.h -@@ -601,56 +601,56 @@ static inline int fault_in_pages_readable(const char __user *uaddr, int size) - */ - static inline int fault_in_multipages_writeable(char __user *uaddr, int size) - { -- int ret = 0; - char __user *end = uaddr + size - 1; - - if (unlikely(size == 0)) -- return ret; -+ return 0; - -+ if (unlikely(uaddr > end)) -+ return -EFAULT; - /* - * Writing zeroes into userspace here is OK, because we know that if - * the zero gets there, we'll be overwriting it. - */ -- while (uaddr <= end) { -- ret = __put_user(0, uaddr); -- if (ret != 0) -- return ret; -+ do { -+ if (unlikely(__put_user(0, uaddr) != 0)) -+ return -EFAULT; - uaddr += PAGE_SIZE; -- } -+ } while (uaddr <= end); - - /* Check whether the range spilled into the next page. */ - if (((unsigned long)uaddr & PAGE_MASK) == - ((unsigned long)end & PAGE_MASK)) -- ret = __put_user(0, end); -+ return __put_user(0, end); - -- return ret; -+ return 0; - } - - static inline int fault_in_multipages_readable(const char __user *uaddr, - int size) - { - volatile char c; -- int ret = 0; - const char __user *end = uaddr + size - 1; - - if (unlikely(size == 0)) -- return ret; -+ return 0; - -- while (uaddr <= end) { -- ret = __get_user(c, uaddr); -- if (ret != 0) -- return ret; -+ if (unlikely(uaddr > end)) -+ return -EFAULT; -+ -+ do { -+ if (unlikely(__get_user(c, uaddr) != 0)) -+ return -EFAULT; - uaddr += PAGE_SIZE; -- } -+ } while (uaddr <= end); - - /* Check whether the range spilled into the next page. */ - if (((unsigned long)uaddr & PAGE_MASK) == - ((unsigned long)end & PAGE_MASK)) { -- ret = __get_user(c, end); -- (void)c; -+ return __get_user(c, end); - } - -- return ret; -+ return 0; - } - - int add_to_page_cache_locked(struct page *page, struct address_space *mapping, -diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h -index 76199b75d584..e302c447e057 100644 ---- a/include/linux/smc91x.h -+++ b/include/linux/smc91x.h -@@ -1,6 +1,16 @@ - #ifndef __SMC91X_H__ - #define __SMC91X_H__ - -+/* -+ * These bits define which access sizes a platform can support, rather -+ * than the maximal access size. So, if your platform can do 16-bit -+ * and 32-bit accesses to the SMC91x device, but not 8-bit, set both -+ * SMC91X_USE_16BIT and SMC91X_USE_32BIT. -+ * -+ * The SMC91x driver requires at least one of SMC91X_USE_8BIT or -+ * SMC91X_USE_16BIT to be supported - just setting SMC91X_USE_32BIT is -+ * an invalid configuration. -+ */ - #define SMC91X_USE_8BIT (1 << 0) - #define SMC91X_USE_16BIT (1 << 1) - #define SMC91X_USE_32BIT (1 << 2) -diff --git a/include/net/af_unix.h b/include/net/af_unix.h -index 9b4c418bebd8..fd60eccb59a6 100644 ---- a/include/net/af_unix.h -+++ b/include/net/af_unix.h -@@ -52,7 +52,7 @@ struct unix_sock { - struct sock sk; - struct unix_address *addr; - struct path path; -- struct mutex readlock; -+ struct mutex iolock, bindlock; - struct sock *peer; - struct list_head link; - atomic_long_t inflight; -diff --git a/include/net/tcp.h b/include/net/tcp.h -index 414d822bc1db..9c3ab544d3a8 100644 ---- a/include/net/tcp.h -+++ b/include/net/tcp.h -@@ -1510,6 +1510,8 @@ static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unli - { - if (sk->sk_send_head == skb_unlinked) - sk->sk_send_head = NULL; -+ if (tcp_sk(sk)->highest_sack == skb_unlinked) -+ tcp_sk(sk)->highest_sack = NULL; - } - - static inline void tcp_init_send_head(struct sock *sk) -diff --git a/kernel/cpuset.c b/kernel/cpuset.c -index e120bd983ad0..b9279a2844d8 100644 ---- a/kernel/cpuset.c -+++ b/kernel/cpuset.c -@@ -2079,7 +2079,7 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css) - * which could have been changed by cpuset just after it inherits the - * state from the parent and before it sits on the cgroup's task list. - */ --void cpuset_fork(struct task_struct *task) -+void cpuset_fork(struct task_struct *task, void *priv) - { - if (task_css_is_root(task, cpuset_cgrp_id)) - return; -diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c -index b7dd5718836e..3124cebaec31 100644 ---- a/kernel/power/hibernate.c -+++ b/kernel/power/hibernate.c -@@ -299,12 +299,12 @@ static int create_image(int platform_mode) - save_processor_state(); - trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true); - error = swsusp_arch_suspend(); -+ /* Restore control flow magically appears here */ -+ restore_processor_state(); - trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false); - if (error) - printk(KERN_ERR "PM: Error %d creating hibernation image\n", - error); -- /* Restore control flow magically appears here */ -- restore_processor_state(); - if (!in_suspend) - events_check_enabled = false; - -diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c -index 3a970604308f..f155c62f1f2c 100644 ---- a/kernel/power/snapshot.c -+++ b/kernel/power/snapshot.c -@@ -765,9 +765,9 @@ static bool memory_bm_pfn_present(struct memory_bitmap *bm, unsigned long pfn) - */ - static bool rtree_next_node(struct memory_bitmap *bm) - { -- bm->cur.node = list_entry(bm->cur.node->list.next, -- struct rtree_node, list); -- if (&bm->cur.node->list != &bm->cur.zone->leaves) { -+ if (!list_is_last(&bm->cur.node->list, &bm->cur.zone->leaves)) { -+ bm->cur.node = list_entry(bm->cur.node->list.next, -+ struct rtree_node, list); - bm->cur.node_pfn += BM_BITS_PER_BLOCK; - bm->cur.node_bit = 0; - touch_softlockup_watchdog(); -@@ -775,9 +775,9 @@ static bool rtree_next_node(struct memory_bitmap *bm) - } - - /* No more nodes, goto next zone */ -- bm->cur.zone = list_entry(bm->cur.zone->list.next, -+ if (!list_is_last(&bm->cur.zone->list, &bm->zones)) { -+ bm->cur.zone = list_entry(bm->cur.zone->list.next, - struct mem_zone_bm_rtree, list); -- if (&bm->cur.zone->list != &bm->zones) { - bm->cur.node = list_entry(bm->cur.zone->leaves.next, - struct rtree_node, list); - bm->cur.node_pfn = 0; -diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile -index 9b1044e936a6..05ea5167e6bb 100644 ---- a/kernel/trace/Makefile -+++ b/kernel/trace/Makefile -@@ -1,4 +1,8 @@ - -+# We are fully aware of the dangers of __builtin_return_address() -+FRAME_CFLAGS := $(call cc-disable-warning,frame-address) -+KBUILD_CFLAGS += $(FRAME_CFLAGS) -+ - # Do not instrument the tracer itself: - - ifdef CONFIG_FUNCTION_TRACER -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c -index 8305cbb2d5a2..059233abcfcf 100644 ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -4727,19 +4727,20 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, - struct trace_iterator *iter = filp->private_data; - ssize_t sret; - -- /* return any leftover data */ -- sret = trace_seq_to_user(&iter->seq, ubuf, cnt); -- if (sret != -EBUSY) -- return sret; -- -- trace_seq_init(&iter->seq); -- - /* - * Avoid more than one consumer on a single file descriptor - * This is just a matter of traces coherency, the ring buffer itself - * is protected. - */ - mutex_lock(&iter->mutex); -+ -+ /* return any leftover data */ -+ sret = trace_seq_to_user(&iter->seq, ubuf, cnt); -+ if (sret != -EBUSY) -+ goto out; -+ -+ trace_seq_init(&iter->seq); -+ - if (iter->trace->read) { - sret = iter->trace->read(iter, filp, ubuf, cnt, ppos); - if (sret) -@@ -5766,9 +5767,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, - return -EBUSY; - #endif - -- if (splice_grow_spd(pipe, &spd)) -- return -ENOMEM; -- - if (*ppos & (PAGE_SIZE - 1)) - return -EINVAL; - -@@ -5778,6 +5776,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, - len &= PAGE_MASK; - } - -+ if (splice_grow_spd(pipe, &spd)) -+ return -ENOMEM; -+ - again: - trace_access_lock(iter->cpu_file); - entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); -@@ -5835,19 +5836,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, - /* did we read anything? */ - if (!spd.nr_pages) { - if (ret) -- return ret; -+ goto out; - -+ ret = -EAGAIN; - if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) -- return -EAGAIN; -+ goto out; - - ret = wait_on_pipe(iter, true); - if (ret) -- return ret; -+ goto out; - - goto again; - } - - ret = splice_to_pipe(pipe, &spd); -+out: - splice_shrink_spd(&spd); - - return ret; -diff --git a/mm/vmscan.c b/mm/vmscan.c -index 0c114e2b01d3..0838e9f02b11 100644 ---- a/mm/vmscan.c -+++ b/mm/vmscan.c -@@ -2159,23 +2159,6 @@ out: - } - } - --#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH --static void init_tlb_ubc(void) --{ -- /* -- * This deliberately does not clear the cpumask as it's expensive -- * and unnecessary. If there happens to be data in there then the -- * first SWAP_CLUSTER_MAX pages will send an unnecessary IPI and -- * then will be cleared. -- */ -- current->tlb_ubc.flush_required = false; --} --#else --static inline void init_tlb_ubc(void) --{ --} --#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */ -- - /* - * This is a basic per-zone page freer. Used by both kswapd and direct reclaim. - */ -@@ -2210,8 +2193,6 @@ static void shrink_lruvec(struct lruvec *lruvec, int swappiness, - scan_adjusted = (global_reclaim(sc) && !current_is_kswapd() && - sc->priority == DEF_PRIORITY); - -- init_tlb_ubc(); -- - blk_start_plug(&plug); - while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || - nr[LRU_INACTIVE_FILE]) { -diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c -index 7173a685309a..9542e84a9455 100644 ---- a/net/bridge/br_multicast.c -+++ b/net/bridge/br_multicast.c -@@ -1113,7 +1113,7 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br, - } else { - err = br_ip6_multicast_add_group(br, port, - &grec->grec_mca, vid); -- if (!err) -+ if (err) - break; - } - } -diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c -index f6c3b2137eea..59ce1fcc220c 100644 ---- a/net/caif/cfpkt_skbuff.c -+++ b/net/caif/cfpkt_skbuff.c -@@ -286,7 +286,7 @@ int cfpkt_setlen(struct cfpkt *pkt, u16 len) - else - skb_trim(skb, len); - -- return cfpkt_getlen(pkt); -+ return cfpkt_getlen(pkt); - } - - /* Need to expand SKB */ -diff --git a/net/core/dev.c b/net/core/dev.c -index 9efbdb3ff78a..de4ed2b5a221 100644 ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -3722,6 +3722,22 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb, - } - - /** -+ * netdev_is_rx_handler_busy - check if receive handler is registered -+ * @dev: device to check -+ * -+ * Check if a receive handler is already registered for a given device. -+ * Return true if there one. -+ * -+ * The caller must hold the rtnl_mutex. -+ */ -+bool netdev_is_rx_handler_busy(struct net_device *dev) -+{ -+ ASSERT_RTNL(); -+ return dev && rtnl_dereference(dev->rx_handler); -+} -+EXPORT_SYMBOL_GPL(netdev_is_rx_handler_busy); -+ -+/** - * netdev_rx_handler_register - register receive handler - * @dev: device to register a handler for - * @rx_handler: receive handler to register -diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c -index 744e5936c10d..e5a3ff210fec 100644 ---- a/net/ipv4/fib_trie.c -+++ b/net/ipv4/fib_trie.c -@@ -2453,9 +2453,7 @@ struct fib_route_iter { - static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter, - loff_t pos) - { -- struct fib_table *tb = iter->main_tb; - struct key_vector *l, **tp = &iter->tnode; -- struct trie *t; - t_key key; - - /* use cache location of next-to-find key */ -@@ -2463,8 +2461,6 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter, - pos -= iter->pos; - key = iter->key; - } else { -- t = (struct trie *)tb->tb_data; -- iter->tnode = t->kv; - iter->pos = 0; - key = 0; - } -@@ -2505,12 +2501,12 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos) - return NULL; - - iter->main_tb = tb; -+ t = (struct trie *)tb->tb_data; -+ iter->tnode = t->kv; - - if (*pos != 0) - return fib_route_get_idx(iter, *pos); - -- t = (struct trie *)tb->tb_data; -- iter->tnode = t->kv; - iter->pos = 0; - iter->key = 0; - -diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c -index 4d8f0b698777..65036891e080 100644 ---- a/net/ipv4/ip_vti.c -+++ b/net/ipv4/ip_vti.c -@@ -540,6 +540,33 @@ static struct rtnl_link_ops vti_link_ops __read_mostly = { - .get_link_net = ip_tunnel_get_link_net, - }; - -+static bool is_vti_tunnel(const struct net_device *dev) -+{ -+ return dev->netdev_ops == &vti_netdev_ops; -+} -+ -+static int vti_device_event(struct notifier_block *unused, -+ unsigned long event, void *ptr) -+{ -+ struct net_device *dev = netdev_notifier_info_to_dev(ptr); -+ struct ip_tunnel *tunnel = netdev_priv(dev); -+ -+ if (!is_vti_tunnel(dev)) -+ return NOTIFY_DONE; -+ -+ switch (event) { -+ case NETDEV_DOWN: -+ if (!net_eq(tunnel->net, dev_net(dev))) -+ xfrm_garbage_collect(tunnel->net); -+ break; -+ } -+ return NOTIFY_DONE; -+} -+ -+static struct notifier_block vti_notifier_block __read_mostly = { -+ .notifier_call = vti_device_event, -+}; -+ - static int __init vti_init(void) - { - const char *msg; -@@ -547,6 +574,8 @@ static int __init vti_init(void) - - pr_info("IPv4 over IPsec tunneling driver\n"); - -+ register_netdevice_notifier(&vti_notifier_block); -+ - msg = "tunnel device"; - err = register_pernet_device(&vti_net_ops); - if (err < 0) -@@ -579,6 +608,7 @@ xfrm_proto_ah_failed: - xfrm_proto_esp_failed: - unregister_pernet_device(&vti_net_ops); - pernet_dev_failed: -+ unregister_netdevice_notifier(&vti_notifier_block); - pr_err("vti init: failed to register %s\n", msg); - return err; - } -@@ -590,6 +620,7 @@ static void __exit vti_fini(void) - xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH); - xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP); - unregister_pernet_device(&vti_net_ops); -+ unregister_netdevice_notifier(&vti_notifier_block); - } - - module_init(vti_init); -diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c -index 048418b049d8..b5853cac3269 100644 ---- a/net/ipv4/tcp_ipv4.c -+++ b/net/ipv4/tcp_ipv4.c -@@ -808,8 +808,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, - u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : - tcp_sk(sk)->snd_nxt; - -+ /* RFC 7323 2.3 -+ * The window field (SEG.WND) of every outgoing segment, with the -+ * exception of segments, MUST be right-shifted by -+ * Rcv.Wind.Shift bits: -+ */ - tcp_v4_send_ack(sock_net(sk), skb, seq, -- tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, -+ tcp_rsk(req)->rcv_nxt, -+ req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, - tcp_time_stamp, - req->ts_recent, - 0, -diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c -index 3e6a472e6b88..92ab5bc91592 100644 ---- a/net/ipv4/tcp_yeah.c -+++ b/net/ipv4/tcp_yeah.c -@@ -75,7 +75,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked) - if (!tcp_is_cwnd_limited(sk)) - return; - -- if (tp->snd_cwnd <= tp->snd_ssthresh) -+ if (tcp_in_slow_start(tp)) - tcp_slow_start(tp, acked); - - else if (!yeah->doing_reno_now) { -diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c -index 263a5164a6f5..3e55447b63a4 100644 ---- a/net/ipv6/ping.c -+++ b/net/ipv6/ping.c -@@ -150,8 +150,10 @@ int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) - rt = (struct rt6_info *) dst; - - np = inet6_sk(sk); -- if (!np) -- return -EBADF; -+ if (!np) { -+ err = -EBADF; -+ goto dst_err_out; -+ } - - if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) - fl6.flowi6_oif = np->mcast_oif; -@@ -186,6 +188,9 @@ int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) - } - release_sock(sk); - -+dst_err_out: -+ dst_release(dst); -+ - if (err) - return err; - -diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c -index 1a1cd3938fd0..2d81e2f33ef2 100644 ---- a/net/ipv6/tcp_ipv6.c -+++ b/net/ipv6/tcp_ipv6.c -@@ -932,9 +932,15 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, - /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV - * sk->sk_state == TCP_SYN_RECV -> for Fast Open. - */ -+ /* RFC 7323 2.3 -+ * The window field (SEG.WND) of every outgoing segment, with the -+ * exception of segments, MUST be right-shifted by -+ * Rcv.Wind.Shift bits: -+ */ - tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ? - tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, -- tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, -+ tcp_rsk(req)->rcv_nxt, -+ req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, - tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, - tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), - 0, 0); -diff --git a/net/irda/iriap.c b/net/irda/iriap.c -index 4a7ae32afa09..1138eaf5c682 100644 ---- a/net/irda/iriap.c -+++ b/net/irda/iriap.c -@@ -185,8 +185,12 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv, - - self->magic = IAS_MAGIC; - self->mode = mode; -- if (mode == IAS_CLIENT) -- iriap_register_lsap(self, slsap_sel, mode); -+ if (mode == IAS_CLIENT) { -+ if (iriap_register_lsap(self, slsap_sel, mode)) { -+ kfree(self); -+ return NULL; -+ } -+ } - - self->confirm = callback; - self->priv = priv; -diff --git a/net/tipc/socket.c b/net/tipc/socket.c -index 9b713e0ce00d..b26b7a127773 100644 ---- a/net/tipc/socket.c -+++ b/net/tipc/socket.c -@@ -2111,7 +2111,8 @@ restart: - TIPC_CONN_MSG, SHORT_H_SIZE, - 0, dnode, onode, dport, oport, - TIPC_CONN_SHUTDOWN); -- tipc_node_xmit_skb(net, skb, dnode, tsk->portid); -+ if (skb) -+ tipc_node_xmit_skb(net, skb, dnode, tsk->portid); - } - tsk->connected = 0; - sock->state = SS_DISCONNECTING; -diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c -index 6579fd6e7459..824cc1e160bc 100644 ---- a/net/unix/af_unix.c -+++ b/net/unix/af_unix.c -@@ -661,11 +661,11 @@ static int unix_set_peek_off(struct sock *sk, int val) - { - struct unix_sock *u = unix_sk(sk); - -- if (mutex_lock_interruptible(&u->readlock)) -+ if (mutex_lock_interruptible(&u->iolock)) - return -EINTR; - - sk->sk_peek_off = val; -- mutex_unlock(&u->readlock); -+ mutex_unlock(&u->iolock); - - return 0; - } -@@ -778,7 +778,8 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern) - spin_lock_init(&u->lock); - atomic_long_set(&u->inflight, 0); - INIT_LIST_HEAD(&u->link); -- mutex_init(&u->readlock); /* single task reading lock */ -+ mutex_init(&u->iolock); /* single task reading lock */ -+ mutex_init(&u->bindlock); /* single task binding lock */ - init_waitqueue_head(&u->peer_wait); - init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay); - unix_insert_socket(unix_sockets_unbound(sk), sk); -@@ -847,7 +848,7 @@ static int unix_autobind(struct socket *sock) - int err; - unsigned int retries = 0; - -- err = mutex_lock_interruptible(&u->readlock); -+ err = mutex_lock_interruptible(&u->bindlock); - if (err) - return err; - -@@ -894,7 +895,7 @@ retry: - spin_unlock(&unix_table_lock); - err = 0; - --out: mutex_unlock(&u->readlock); -+out: mutex_unlock(&u->bindlock); - return err; - } - -@@ -953,20 +954,32 @@ fail: - return NULL; - } - --static int unix_mknod(struct dentry *dentry, struct path *path, umode_t mode, -- struct path *res) -+static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) - { -- int err; -+ struct dentry *dentry; -+ struct path path; -+ int err = 0; -+ /* -+ * Get the parent directory, calculate the hash for last -+ * component. -+ */ -+ dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); -+ err = PTR_ERR(dentry); -+ if (IS_ERR(dentry)) -+ return err; - -- err = security_path_mknod(path, dentry, mode, 0); -+ /* -+ * All right, let's create it. -+ */ -+ err = security_path_mknod(&path, dentry, mode, 0); - if (!err) { -- err = vfs_mknod(d_inode(path->dentry), dentry, mode, 0); -+ err = vfs_mknod(d_inode(path.dentry), dentry, mode, 0); - if (!err) { -- res->mnt = mntget(path->mnt); -+ res->mnt = mntget(path.mnt); - res->dentry = dget(dentry); - } - } -- -+ done_path_create(&path, dentry); - return err; - } - -@@ -977,12 +990,10 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - struct unix_sock *u = unix_sk(sk); - struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; - char *sun_path = sunaddr->sun_path; -- int err, name_err; -+ int err; - unsigned int hash; - struct unix_address *addr; - struct hlist_head *list; -- struct path path; -- struct dentry *dentry; - - err = -EINVAL; - if (sunaddr->sun_family != AF_UNIX) -@@ -998,34 +1009,14 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - goto out; - addr_len = err; - -- name_err = 0; -- dentry = NULL; -- if (sun_path[0]) { -- /* Get the parent directory, calculate the hash for last -- * component. -- */ -- dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); -- -- if (IS_ERR(dentry)) { -- /* delay report until after 'already bound' check */ -- name_err = PTR_ERR(dentry); -- dentry = NULL; -- } -- } -- -- err = mutex_lock_interruptible(&u->readlock); -+ err = mutex_lock_interruptible(&u->bindlock); - if (err) -- goto out_path; -+ goto out; - - err = -EINVAL; - if (u->addr) - goto out_up; - -- if (name_err) { -- err = name_err == -EEXIST ? -EADDRINUSE : name_err; -- goto out_up; -- } -- - err = -ENOMEM; - addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL); - if (!addr) -@@ -1036,11 +1027,11 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - addr->hash = hash ^ sk->sk_type; - atomic_set(&addr->refcnt, 1); - -- if (dentry) { -- struct path u_path; -+ if (sun_path[0]) { -+ struct path path; - umode_t mode = S_IFSOCK | - (SOCK_INODE(sock)->i_mode & ~current_umask()); -- err = unix_mknod(dentry, &path, mode, &u_path); -+ err = unix_mknod(sun_path, mode, &path); - if (err) { - if (err == -EEXIST) - err = -EADDRINUSE; -@@ -1048,9 +1039,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - goto out_up; - } - addr->hash = UNIX_HASH_SIZE; -- hash = d_real_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); -+ hash = d_real_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); - spin_lock(&unix_table_lock); -- u->path = u_path; -+ u->path = path; - list = &unix_socket_table[hash]; - } else { - spin_lock(&unix_table_lock); -@@ -1072,11 +1063,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) - out_unlock: - spin_unlock(&unix_table_lock); - out_up: -- mutex_unlock(&u->readlock); --out_path: -- if (dentry) -- done_path_create(&path, dentry); -- -+ mutex_unlock(&u->bindlock); - out: - return err; - } -@@ -1971,17 +1958,17 @@ static ssize_t unix_stream_sendpage(struct socket *socket, struct page *page, - if (false) { - alloc_skb: - unix_state_unlock(other); -- mutex_unlock(&unix_sk(other)->readlock); -+ mutex_unlock(&unix_sk(other)->iolock); - newskb = sock_alloc_send_pskb(sk, 0, 0, flags & MSG_DONTWAIT, - &err, 0); - if (!newskb) - goto err; - } - -- /* we must acquire readlock as we modify already present -+ /* we must acquire iolock as we modify already present - * skbs in the sk_receive_queue and mess with skb->len - */ -- err = mutex_lock_interruptible(&unix_sk(other)->readlock); -+ err = mutex_lock_interruptible(&unix_sk(other)->iolock); - if (err) { - err = flags & MSG_DONTWAIT ? -EAGAIN : -ERESTARTSYS; - goto err; -@@ -2048,7 +2035,7 @@ alloc_skb: - } - - unix_state_unlock(other); -- mutex_unlock(&unix_sk(other)->readlock); -+ mutex_unlock(&unix_sk(other)->iolock); - - other->sk_data_ready(other); - scm_destroy(&scm); -@@ -2057,7 +2044,7 @@ alloc_skb: - err_state_unlock: - unix_state_unlock(other); - err_unlock: -- mutex_unlock(&unix_sk(other)->readlock); -+ mutex_unlock(&unix_sk(other)->iolock); - err: - kfree_skb(newskb); - if (send_sigpipe && !(flags & MSG_NOSIGNAL)) -@@ -2122,7 +2109,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, - if (flags&MSG_OOB) - goto out; - -- err = mutex_lock_interruptible(&u->readlock); -+ err = mutex_lock_interruptible(&u->iolock); - if (unlikely(err)) { - /* recvmsg() in non blocking mode is supposed to return -EAGAIN - * sk_rcvtimeo is not honored by mutex_lock_interruptible() -@@ -2198,7 +2185,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, - out_free: - skb_free_datagram(sk, skb); - out_unlock: -- mutex_unlock(&u->readlock); -+ mutex_unlock(&u->iolock); - out: - return err; - } -@@ -2293,7 +2280,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) - /* Lock the socket to prevent queue disordering - * while sleeps in memcpy_tomsg - */ -- mutex_lock(&u->readlock); -+ mutex_lock(&u->iolock); - - if (flags & MSG_PEEK) - skip = sk_peek_offset(sk, flags); -@@ -2334,7 +2321,7 @@ again: - break; - } - -- mutex_unlock(&u->readlock); -+ mutex_unlock(&u->iolock); - - timeo = unix_stream_data_wait(sk, timeo, last, - last_len); -@@ -2345,7 +2332,7 @@ again: - goto out; - } - -- mutex_lock(&u->readlock); -+ mutex_lock(&u->iolock); - continue; - unlock: - unix_state_unlock(sk); -@@ -2448,7 +2435,7 @@ unlock: - } - } while (size); - -- mutex_unlock(&u->readlock); -+ mutex_unlock(&u->iolock); - if (state->msg) - scm_recv(sock, state->msg, &scm, flags); - else -@@ -2489,9 +2476,9 @@ static ssize_t skb_unix_socket_splice(struct sock *sk, - int ret; - struct unix_sock *u = unix_sk(sk); - -- mutex_unlock(&u->readlock); -+ mutex_unlock(&u->iolock); - ret = splice_to_pipe(pipe, spd); -- mutex_lock(&u->readlock); -+ mutex_lock(&u->iolock); - - return ret; - } -diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c -index 5d89f13a98db..bf65f31bd55e 100644 ---- a/net/wireless/nl80211.c -+++ b/net/wireless/nl80211.c -@@ -6628,7 +6628,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) - - params.n_counter_offsets_presp = len / sizeof(u16); - if (rdev->wiphy.max_num_csa_counters && -- (params.n_counter_offsets_beacon > -+ (params.n_counter_offsets_presp > - rdev->wiphy.max_num_csa_counters)) - return -EINVAL; - diff --git a/patch/kernel/marvell-dev/patch-4.4.23-24.patch b/patch/kernel/marvell-dev/patch-4.4.23-24.patch deleted file mode 100644 index f3a7dba266..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.23-24.patch +++ /dev/null @@ -1,2457 +0,0 @@ -diff --git a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt -index d00bfd8624a5..e0381c28773d 100644 ---- a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt -+++ b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt -@@ -81,9 +81,9 @@ pm8916: - l14, l15, l16, l17, l18 - - pm8941: -- s1, s2, s3, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, -- l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2, lvs3, -- mvs1, mvs2 -+ s1, s2, s3, s4, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, -+ l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2, lvs3, -+ 5vs1, 5vs2 - - The content of each sub-node is defined by the standard binding for regulators - - see regulator.txt - with additional custom properties described below: -diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt -index 4976389e432d..dd15a699ee1c 100644 ---- a/Documentation/pinctrl.txt -+++ b/Documentation/pinctrl.txt -@@ -831,7 +831,7 @@ separate memory range only intended for GPIO driving, and the register - range dealing with pin config and pin multiplexing get placed into a - different memory range and a separate section of the data sheet. - --A flag "strict" in struct pinctrl_desc is available to check and deny -+A flag "strict" in struct pinmux_ops is available to check and deny - simultaneous access to the same pin from GPIO and pin multiplexing - consumers on hardware of this type. The pinctrl driver should set this flag - accordingly. -diff --git a/Makefile b/Makefile -index 95421b688f23..cdbc185c3539 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 23 -+SUBLEVEL = 24 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S -index 06e983f59980..856913705169 100644 ---- a/arch/arm/boot/compressed/head.S -+++ b/arch/arm/boot/compressed/head.S -@@ -776,7 +776,7 @@ __armv7_mmu_cache_on: - orrne r0, r0, #1 @ MMU enabled - movne r1, #0xfffffffd @ domain 0 = client - bic r6, r6, #1 << 31 @ 32-bit translation system -- bic r6, r6, #3 << 0 @ use only ttbr0 -+ bic r6, r6, #(7 << 0) | (1 << 4) @ use only ttbr0 - mcrne p15, 0, r3, c2, c0, 0 @ load page table pointer - mcrne p15, 0, r1, c3, c0, 0 @ load domain access control - mcrne p15, 0, r6, c2, c0, 2 @ load ttb control -diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi -index d910d3a6c41c..84bdba480d5a 100644 ---- a/arch/arm/boot/dts/sun5i-a13.dtsi -+++ b/arch/arm/boot/dts/sun5i-a13.dtsi -@@ -83,7 +83,7 @@ - trips { - cpu_alert0: cpu_alert0 { - /* milliCelsius */ -- temperature = <850000>; -+ temperature = <85000>; - hysteresis = <2000>; - type = "passive"; - }; -diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c -index 3d224941b541..a3a9ad4dc3c6 100644 ---- a/arch/arm/common/sa1111.c -+++ b/arch/arm/common/sa1111.c -@@ -869,9 +869,9 @@ struct sa1111_save_data { - - #ifdef CONFIG_PM - --static int sa1111_suspend(struct platform_device *dev, pm_message_t state) -+static int sa1111_suspend_noirq(struct device *dev) - { -- struct sa1111 *sachip = platform_get_drvdata(dev); -+ struct sa1111 *sachip = dev_get_drvdata(dev); - struct sa1111_save_data *save; - unsigned long flags; - unsigned int val; -@@ -934,9 +934,9 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) - * restored by their respective drivers, and must be called - * via LDM after this function. - */ --static int sa1111_resume(struct platform_device *dev) -+static int sa1111_resume_noirq(struct device *dev) - { -- struct sa1111 *sachip = platform_get_drvdata(dev); -+ struct sa1111 *sachip = dev_get_drvdata(dev); - struct sa1111_save_data *save; - unsigned long flags, id; - void __iomem *base; -@@ -952,7 +952,7 @@ static int sa1111_resume(struct platform_device *dev) - id = sa1111_readl(sachip->base + SA1111_SKID); - if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { - __sa1111_remove(sachip); -- platform_set_drvdata(dev, NULL); -+ dev_set_drvdata(dev, NULL); - kfree(save); - return 0; - } -@@ -1003,8 +1003,8 @@ static int sa1111_resume(struct platform_device *dev) - } - - #else --#define sa1111_suspend NULL --#define sa1111_resume NULL -+#define sa1111_suspend_noirq NULL -+#define sa1111_resume_noirq NULL - #endif - - static int sa1111_probe(struct platform_device *pdev) -@@ -1038,6 +1038,11 @@ static int sa1111_remove(struct platform_device *pdev) - return 0; - } - -+static struct dev_pm_ops sa1111_pm_ops = { -+ .suspend_noirq = sa1111_suspend_noirq, -+ .resume_noirq = sa1111_resume_noirq, -+}; -+ - /* - * Not sure if this should be on the system bus or not yet. - * We really want some way to register a system device at -@@ -1050,10 +1055,9 @@ static int sa1111_remove(struct platform_device *pdev) - static struct platform_driver sa1111_device_driver = { - .probe = sa1111_probe, - .remove = sa1111_remove, -- .suspend = sa1111_suspend, -- .resume = sa1111_resume, - .driver = { - .name = "sa1111", -+ .pm = &sa1111_pm_ops, - }, - }; - -diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h -index ccb3aa64640d..b91a2d17a521 100644 ---- a/arch/arm/include/asm/dma-mapping.h -+++ b/arch/arm/include/asm/dma-mapping.h -@@ -119,7 +119,7 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) - /* The ARM override for dma_max_pfn() */ - static inline unsigned long dma_max_pfn(struct device *dev) - { -- return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask); -+ return dma_to_pfn(dev, *dev->dma_mask); - } - #define dma_max_pfn(dev) dma_max_pfn(dev) - -diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c -index 65addcbf5b30..b3b950fc8ea0 100644 ---- a/arch/arm/kernel/devtree.c -+++ b/arch/arm/kernel/devtree.c -@@ -87,6 +87,8 @@ void __init arm_dt_init_cpu_maps(void) - return; - - for_each_child_of_node(cpus, cpu) { -+ const __be32 *cell; -+ int prop_bytes; - u32 hwid; - - if (of_node_cmp(cpu->type, "cpu")) -@@ -98,7 +100,8 @@ void __init arm_dt_init_cpu_maps(void) - * properties is considered invalid to build the - * cpu_logical_map. - */ -- if (of_property_read_u32(cpu, "reg", &hwid)) { -+ cell = of_get_property(cpu, "reg", &prop_bytes); -+ if (!cell || prop_bytes < sizeof(*cell)) { - pr_debug(" * %s missing reg property\n", - cpu->full_name); - of_node_put(cpu); -@@ -106,10 +109,15 @@ void __init arm_dt_init_cpu_maps(void) - } - - /* -- * 8 MSBs must be set to 0 in the DT since the reg property -+ * Bits n:24 must be set to 0 in the DT since the reg property - * defines the MPIDR[23:0]. - */ -- if (hwid & ~MPIDR_HWID_BITMASK) { -+ do { -+ hwid = be32_to_cpu(*cell++); -+ prop_bytes -= sizeof(*cell); -+ } while (!hwid && prop_bytes > 0); -+ -+ if (prop_bytes || (hwid & ~MPIDR_HWID_BITMASK)) { - of_node_put(cpu); - return; - } -diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c -index cbf53bb9c814..0db46895c82a 100644 ---- a/arch/arm/mach-sa1100/clock.c -+++ b/arch/arm/mach-sa1100/clock.c -@@ -125,6 +125,8 @@ static unsigned long clk_36864_get_rate(struct clk *clk) - } - - static struct clkops clk_36864_ops = { -+ .enable = clk_cpu_enable, -+ .disable = clk_cpu_disable, - .get_rate = clk_36864_get_rate, - }; - -@@ -140,9 +142,8 @@ static struct clk_lookup sa11xx_clkregs[] = { - CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864), - }; - --static int __init sa11xx_clk_init(void) -+int __init sa11xx_clk_init(void) - { - clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); - return 0; - } --core_initcall(sa11xx_clk_init); -diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c -index 345e63f4eb71..3e09beddb6e8 100644 ---- a/arch/arm/mach-sa1100/generic.c -+++ b/arch/arm/mach-sa1100/generic.c -@@ -34,6 +34,7 @@ - - #include - #include -+#include - - #include "generic.h" - #include -@@ -95,6 +96,8 @@ static void sa1100_power_off(void) - - void sa11x0_restart(enum reboot_mode mode, const char *cmd) - { -+ clear_reset_status(RESET_STATUS_ALL); -+ - if (mode == REBOOT_SOFT) { - /* Jump into ROM at address 0 */ - soft_restart(0); -@@ -388,6 +391,7 @@ void __init sa1100_init_irq(void) - sa11x0_init_irq_nodt(IRQ_GPIO0_SC, irq_resource.start); - - sa1100_init_gpio(); -+ sa11xx_clk_init(); - } - - /* -diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h -index 0d92e119b36b..68199b603ff7 100644 ---- a/arch/arm/mach-sa1100/generic.h -+++ b/arch/arm/mach-sa1100/generic.h -@@ -44,3 +44,5 @@ int sa11x0_pm_init(void); - #else - static inline int sa11x0_pm_init(void) { return 0; } - #endif -+ -+int sa11xx_clk_init(void); -diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c -index 62437b57813e..73e3adbc1330 100644 ---- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c -+++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c -@@ -41,39 +41,26 @@ - - #define REGULATOR_IRQ_MASK BIT(2) /* IRQ2, active low */ - --static void __iomem *irqc; -- --static const u8 da9063_mask_regs[] = { -- DA9063_REG_IRQ_MASK_A, -- DA9063_REG_IRQ_MASK_B, -- DA9063_REG_IRQ_MASK_C, -- DA9063_REG_IRQ_MASK_D, --}; -- --/* DA9210 System Control and Event Registers */ -+/* start of DA9210 System Control and Event Registers */ - #define DA9210_REG_MASK_A 0x54 --#define DA9210_REG_MASK_B 0x55 -- --static const u8 da9210_mask_regs[] = { -- DA9210_REG_MASK_A, -- DA9210_REG_MASK_B, --}; -- --static void da9xxx_mask_irqs(struct i2c_client *client, const u8 regs[], -- unsigned int nregs) --{ -- unsigned int i; - -- dev_info(&client->dev, "Masking %s interrupt sources\n", client->name); -+static void __iomem *irqc; - -- for (i = 0; i < nregs; i++) { -- int error = i2c_smbus_write_byte_data(client, regs[i], ~0); -- if (error) { -- dev_err(&client->dev, "i2c error %d\n", error); -- return; -- } -- } --} -+/* first byte sets the memory pointer, following are consecutive reg values */ -+static u8 da9063_irq_clr[] = { DA9063_REG_IRQ_MASK_A, 0xff, 0xff, 0xff, 0xff }; -+static u8 da9210_irq_clr[] = { DA9210_REG_MASK_A, 0xff, 0xff }; -+ -+static struct i2c_msg da9xxx_msgs[2] = { -+ { -+ .addr = 0x58, -+ .len = ARRAY_SIZE(da9063_irq_clr), -+ .buf = da9063_irq_clr, -+ }, { -+ .addr = 0x68, -+ .len = ARRAY_SIZE(da9210_irq_clr), -+ .buf = da9210_irq_clr, -+ }, -+}; - - static int regulator_quirk_notify(struct notifier_block *nb, - unsigned long action, void *data) -@@ -93,12 +80,15 @@ static int regulator_quirk_notify(struct notifier_block *nb, - client = to_i2c_client(dev); - dev_dbg(dev, "Detected %s\n", client->name); - -- if ((client->addr == 0x58 && !strcmp(client->name, "da9063"))) -- da9xxx_mask_irqs(client, da9063_mask_regs, -- ARRAY_SIZE(da9063_mask_regs)); -- else if (client->addr == 0x68 && !strcmp(client->name, "da9210")) -- da9xxx_mask_irqs(client, da9210_mask_regs, -- ARRAY_SIZE(da9210_mask_regs)); -+ if ((client->addr == 0x58 && !strcmp(client->name, "da9063")) || -+ (client->addr == 0x68 && !strcmp(client->name, "da9210"))) { -+ int ret; -+ -+ dev_info(&client->dev, "clearing da9063/da9210 interrupts\n"); -+ ret = i2c_transfer(client->adapter, da9xxx_msgs, ARRAY_SIZE(da9xxx_msgs)); -+ if (ret != ARRAY_SIZE(da9xxx_msgs)) -+ dev_err(&client->dev, "i2c error %d\n", ret); -+ } - - mon = ioread32(irqc + IRQC_MONITOR); - if (mon & REGULATOR_IRQ_MASK) -diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c -index e51f27ac13fd..c8875b64be90 100644 ---- a/arch/arm64/kernel/debug-monitors.c -+++ b/arch/arm64/kernel/debug-monitors.c -@@ -422,8 +422,10 @@ int kernel_active_single_step(void) - /* ptrace API */ - void user_enable_single_step(struct task_struct *task) - { -- set_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); -- set_regs_spsr_ss(task_pt_regs(task)); -+ struct thread_info *ti = task_thread_info(task); -+ -+ if (!test_and_set_ti_thread_flag(ti, TIF_SINGLESTEP)) -+ set_regs_spsr_ss(task_pt_regs(task)); - } - - void user_disable_single_step(struct task_struct *task) -diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c -index 4f61378c3453..456128174b17 100644 ---- a/arch/avr32/mach-at32ap/pio.c -+++ b/arch/avr32/mach-at32ap/pio.c -@@ -435,7 +435,7 @@ void __init at32_init_pio(struct platform_device *pdev) - struct resource *regs; - struct pio_device *pio; - -- if (pdev->id > MAX_NR_PIO_DEVICES) { -+ if (pdev->id >= MAX_NR_PIO_DEVICES) { - dev_err(&pdev->dev, "only %d PIO devices supported\n", - MAX_NR_PIO_DEVICES); - return; -diff --git a/arch/mips/include/asm/uprobes.h b/arch/mips/include/asm/uprobes.h -index 34c325c674c4..70a4a2f173ff 100644 ---- a/arch/mips/include/asm/uprobes.h -+++ b/arch/mips/include/asm/uprobes.h -@@ -36,7 +36,6 @@ struct arch_uprobe { - unsigned long resume_epc; - u32 insn[2]; - u32 ixol[2]; -- union mips_instruction orig_inst[MAX_UINSN_BYTES / 4]; - }; - - struct arch_uprobe_task { -diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c -index 8452d933a645..4e7b89f2e244 100644 ---- a/arch/mips/kernel/uprobes.c -+++ b/arch/mips/kernel/uprobes.c -@@ -157,7 +157,6 @@ bool is_trap_insn(uprobe_opcode_t *insn) - int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs) - { - struct uprobe_task *utask = current->utask; -- union mips_instruction insn; - - /* - * Now find the EPC where to resume after the breakpoint has been -@@ -168,10 +167,10 @@ int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs) - unsigned long epc; - - epc = regs->cp0_epc; -- __compute_return_epc_for_insn(regs, insn); -+ __compute_return_epc_for_insn(regs, -+ (union mips_instruction) aup->insn[0]); - aup->resume_epc = regs->cp0_epc; - } -- - utask->autask.saved_trap_nr = current->thread.trap_nr; - current->thread.trap_nr = UPROBE_TRAP_NR; - regs->cp0_epc = current->utask->xol_vaddr; -@@ -257,7 +256,7 @@ unsigned long arch_uretprobe_hijack_return_addr( - ra = regs->regs[31]; - - /* Replace the return address with the trampoline address */ -- regs->regs[31] = ra; -+ regs->regs[31] = trampoline_vaddr; - - return ra; - } -@@ -280,24 +279,6 @@ int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, - return uprobe_write_opcode(mm, vaddr, UPROBE_SWBP_INSN); - } - --/** -- * set_orig_insn - Restore the original instruction. -- * @mm: the probed process address space. -- * @auprobe: arch specific probepoint information. -- * @vaddr: the virtual address to insert the opcode. -- * -- * For mm @mm, restore the original opcode (opcode) at @vaddr. -- * Return 0 (success) or a negative errno. -- * -- * This overrides the weak version in kernel/events/uprobes.c. -- */ --int set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, -- unsigned long vaddr) --{ -- return uprobe_write_opcode(mm, vaddr, -- *(uprobe_opcode_t *)&auprobe->orig_inst[0].word); --} -- - void __weak arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, - void *src, unsigned long len) - { -diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c -index 4740c82fb97a..36b09b2ea972 100644 ---- a/arch/mips/mti-malta/malta-setup.c -+++ b/arch/mips/mti-malta/malta-setup.c -@@ -39,6 +39,9 @@ - #include - #endif - -+#define ROCIT_CONFIG_GEN0 0x1f403000 -+#define ROCIT_CONFIG_GEN0_PCI_IOCU BIT(7) -+ - extern void malta_be_init(void); - extern int malta_be_handler(struct pt_regs *regs, int is_fixup); - -@@ -107,6 +110,8 @@ static void __init fd_activate(void) - static int __init plat_enable_iocoherency(void) - { - int supported = 0; -+ u32 cfg; -+ - if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) { - if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) { - BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN; -@@ -129,7 +134,8 @@ static int __init plat_enable_iocoherency(void) - } else if (mips_cm_numiocu() != 0) { - /* Nothing special needs to be done to enable coherency */ - pr_info("CMP IOCU detected\n"); -- if ((*(unsigned int *)0xbf403000 & 0x81) != 0x81) { -+ cfg = __raw_readl((u32 *)CKSEG1ADDR(ROCIT_CONFIG_GEN0)); -+ if (!(cfg & ROCIT_CONFIG_GEN0_PCI_IOCU)) { - pr_crit("IOCU OPERATION DISABLED BY SWITCH - DEFAULTING TO SW IO COHERENCY\n"); - return 0; - } -diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c -index b7e86e00048f..7b89e7b305e6 100644 ---- a/arch/powerpc/kernel/prom_init.c -+++ b/arch/powerpc/kernel/prom_init.c -@@ -694,7 +694,7 @@ unsigned char ibm_architecture_vec[] = { - OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */ - - /* option vector 5: PAPR/OF options */ -- VECTOR_LENGTH(18), /* length */ -+ VECTOR_LENGTH(21), /* length */ - 0, /* don't ignore, don't halt */ - OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) | - OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) | -@@ -725,8 +725,11 @@ unsigned char ibm_architecture_vec[] = { - 0, - 0, - OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) | -- OV5_FEAT(OV5_PFO_HW_842), -- OV5_FEAT(OV5_SUB_PROCESSORS), -+ OV5_FEAT(OV5_PFO_HW_842), /* Byte 17 */ -+ 0, /* Byte 18 */ -+ 0, /* Byte 19 */ -+ 0, /* Byte 20 */ -+ OV5_FEAT(OV5_SUB_PROCESSORS), /* Byte 21 */ - - /* option vector 6: IBM PAPR hints */ - VECTOR_LENGTH(3), /* length */ -diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h -index c505d77e4d06..e9d54a06736f 100644 ---- a/arch/tile/include/asm/elf.h -+++ b/arch/tile/include/asm/elf.h -@@ -129,6 +129,7 @@ extern int dump_task_regs(struct task_struct *, elf_gregset_t *); - struct linux_binprm; - extern int arch_setup_additional_pages(struct linux_binprm *bprm, - int executable_stack); -+/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ - #define ARCH_DLINFO \ - do { \ - NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \ -diff --git a/arch/tile/include/uapi/asm/auxvec.h b/arch/tile/include/uapi/asm/auxvec.h -index c93e92709f14..f497123ed980 100644 ---- a/arch/tile/include/uapi/asm/auxvec.h -+++ b/arch/tile/include/uapi/asm/auxvec.h -@@ -18,4 +18,6 @@ - /* The vDSO location. */ - #define AT_SYSINFO_EHDR 33 - -+#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */ -+ - #endif /* _ASM_TILE_AUXVEC_H */ -diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h -index 3142218e546f..6433e28dc9c8 100644 ---- a/arch/x86/include/asm/tlbflush.h -+++ b/arch/x86/include/asm/tlbflush.h -@@ -32,7 +32,7 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate); - /* Initialize cr4 shadow for this CPU. */ - static inline void cr4_init_shadow(void) - { -- this_cpu_write(cpu_tlbstate.cr4, __read_cr4()); -+ this_cpu_write(cpu_tlbstate.cr4, __read_cr4_safe()); - } - - /* Set in this cpu's CR4. */ -diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c -index c2b7522cbf35..2b49b113d65d 100644 ---- a/arch/x86/kernel/cpu/common.c -+++ b/arch/x86/kernel/cpu/common.c -@@ -737,21 +737,20 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) - identify_cpu_without_cpuid(c); - - /* cyrix could have cpuid enabled via c_identify()*/ -- if (!have_cpuid_p()) -- return; -+ if (have_cpuid_p()) { -+ cpu_detect(c); -+ get_cpu_vendor(c); -+ get_cpu_cap(c); - -- cpu_detect(c); -- get_cpu_vendor(c); -- get_cpu_cap(c); -- -- if (this_cpu->c_early_init) -- this_cpu->c_early_init(c); -+ if (this_cpu->c_early_init) -+ this_cpu->c_early_init(c); - -- c->cpu_index = 0; -- filter_cpuid_features(c, false); -+ c->cpu_index = 0; -+ filter_cpuid_features(c, false); - -- if (this_cpu->c_bsp_init) -- this_cpu->c_bsp_init(c); -+ if (this_cpu->c_bsp_init) -+ this_cpu->c_bsp_init(c); -+ } - - setup_force_cpu_cap(X86_FEATURE_ALWAYS); - fpu__init_system(c); -diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c -index 4589b6feeb7b..268df707b5ce 100644 ---- a/arch/x86/kvm/vmx.c -+++ b/arch/x86/kvm/vmx.c -@@ -408,6 +408,7 @@ struct nested_vmx { - struct list_head vmcs02_pool; - int vmcs02_num; - u64 vmcs01_tsc_offset; -+ bool change_vmcs01_virtual_x2apic_mode; - /* L2 must run next, and mustn't decide to exit to L1. */ - bool nested_run_pending; - /* -@@ -8184,6 +8185,12 @@ static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set) - { - u32 sec_exec_control; - -+ /* Postpone execution until vmcs01 is the current VMCS. */ -+ if (is_guest_mode(vcpu)) { -+ to_vmx(vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true; -+ return; -+ } -+ - /* - * There is not point to enable virtualize x2apic without enable - * apicv -@@ -10483,6 +10490,12 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, - /* Update TSC_OFFSET if TSC was changed while L2 ran */ - vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); - -+ if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { -+ vmx->nested.change_vmcs01_virtual_x2apic_mode = false; -+ vmx_set_virtual_x2apic_mode(vcpu, -+ vcpu->arch.apic_base & X2APIC_ENABLE); -+ } -+ - /* This is needed for same reason as it was needed in prepare_vmcs02 */ - vmx->host_rsp = 0; - -diff --git a/block/blk-mq.c b/block/blk-mq.c -index 839b1e17481b..c3e461ec40e4 100644 ---- a/block/blk-mq.c -+++ b/block/blk-mq.c -@@ -780,7 +780,7 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) - switch (ret) { - case BLK_MQ_RQ_QUEUE_OK: - queued++; -- continue; -+ break; - case BLK_MQ_RQ_QUEUE_BUSY: - list_add(&rq->queuelist, &rq_list); - __blk_mq_requeue_request(rq); -diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c -index 5f97468df8ff..b2e50d8007fe 100644 ---- a/drivers/acpi/acpica/hwxface.c -+++ b/drivers/acpi/acpica/hwxface.c -@@ -504,11 +504,20 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) - * Evaluate the \_Sx namespace object containing the register values - * for this state - */ -- info->relative_pathname = -- ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); -+ info->relative_pathname = ACPI_CAST_PTR(char, -+ acpi_gbl_sleep_state_names -+ [sleep_state]); -+ - status = acpi_ns_evaluate(info); - if (ACPI_FAILURE(status)) { -- goto cleanup; -+ if (status == AE_NOT_FOUND) { -+ -+ /* The _Sx states are optional, ignore NOT_FOUND */ -+ -+ goto final_cleanup; -+ } -+ -+ goto warning_cleanup; - } - - /* Must have a return object */ -@@ -517,7 +526,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) - ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", - info->relative_pathname)); - status = AE_AML_NO_RETURN_VALUE; -- goto cleanup; -+ goto warning_cleanup; - } - - /* Return object must be of type Package */ -@@ -526,7 +535,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) - ACPI_ERROR((AE_INFO, - "Sleep State return object is not a Package")); - status = AE_AML_OPERAND_TYPE; -- goto cleanup1; -+ goto return_value_cleanup; - } - - /* -@@ -570,16 +579,17 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) - break; - } - --cleanup1: -+return_value_cleanup: - acpi_ut_remove_reference(info->return_object); - --cleanup: -+warning_cleanup: - if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "While evaluating Sleep State [%s]", - info->relative_pathname)); - } - -+final_cleanup: - ACPI_FREE(info); - return_ACPI_STATUS(status); - } -diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c -index 8a1432e8bb80..01d4be2c354b 100644 ---- a/drivers/char/hw_random/omap-rng.c -+++ b/drivers/char/hw_random/omap-rng.c -@@ -384,7 +384,12 @@ static int omap_rng_probe(struct platform_device *pdev) - } - - pm_runtime_enable(&pdev->dev); -- pm_runtime_get_sync(&pdev->dev); -+ ret = pm_runtime_get_sync(&pdev->dev); -+ if (ret) { -+ dev_err(&pdev->dev, "Failed to runtime_get device: %d\n", ret); -+ pm_runtime_put_noidle(&pdev->dev); -+ goto err_ioremap; -+ } - - ret = (dev->of_node) ? of_get_omap_rng_device_details(priv, pdev) : - get_omap_rng_device_details(priv); -@@ -435,8 +440,15 @@ static int __maybe_unused omap_rng_suspend(struct device *dev) - static int __maybe_unused omap_rng_resume(struct device *dev) - { - struct omap_rng_dev *priv = dev_get_drvdata(dev); -+ int ret; -+ -+ ret = pm_runtime_get_sync(dev); -+ if (ret) { -+ dev_err(dev, "Failed to runtime_get device: %d\n", ret); -+ pm_runtime_put_noidle(dev); -+ return ret; -+ } - -- pm_runtime_get_sync(dev); - priv->pdata->init(priv); - - return 0; -diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c -index c12130485fc1..678af51fb29e 100644 ---- a/drivers/char/tpm/tpm2-cmd.c -+++ b/drivers/char/tpm/tpm2-cmd.c -@@ -657,7 +657,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, - - rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), desc); - if (!rc) -- *value = cmd.params.get_tpm_pt_out.value; -+ *value = be32_to_cpu(cmd.params.get_tpm_pt_out.value); - - return rc; - } -diff --git a/drivers/clk/clk-xgene.c b/drivers/clk/clk-xgene.c -index 10224b01b97c..b134a8b15e2c 100644 ---- a/drivers/clk/clk-xgene.c -+++ b/drivers/clk/clk-xgene.c -@@ -351,8 +351,8 @@ static int xgene_clk_set_rate(struct clk_hw *hw, unsigned long rate, - /* Set new divider */ - data = xgene_clk_read(pclk->param.divider_reg + - pclk->param.reg_divider_offset); -- data &= ~((1 << pclk->param.reg_divider_width) - 1) -- << pclk->param.reg_divider_shift; -+ data &= ~(((1 << pclk->param.reg_divider_width) - 1) -+ << pclk->param.reg_divider_shift); - data |= divider; - xgene_clk_write(data, pclk->param.divider_reg + - pclk->param.reg_divider_offset); -diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c -index e44a1bfb0250..9d05d7dbcfa9 100644 ---- a/drivers/dma/at_xdmac.c -+++ b/drivers/dma/at_xdmac.c -@@ -1183,8 +1183,8 @@ static struct at_xdmac_desc *at_xdmac_memset_create_desc(struct dma_chan *chan, - desc->lld.mbr_cfg = chan_cc; - - dev_dbg(chan2dev(chan), -- "%s: lld: mbr_da=%pad, mbr_ds=%pad, mbr_ubc=0x%08x, mbr_cfg=0x%08x\n", -- __func__, &desc->lld.mbr_da, &desc->lld.mbr_ds, desc->lld.mbr_ubc, -+ "%s: lld: mbr_da=%pad, mbr_ds=0x%08x, mbr_ubc=0x%08x, mbr_cfg=0x%08x\n", -+ __func__, &desc->lld.mbr_da, desc->lld.mbr_ds, desc->lld.mbr_ubc, - desc->lld.mbr_cfg); - - return desc; -@@ -2055,7 +2055,7 @@ err_dma_unregister: - err_clk_disable: - clk_disable_unprepare(atxdmac->clk); - err_free_irq: -- free_irq(atxdmac->irq, atxdmac->dma.dev); -+ free_irq(atxdmac->irq, atxdmac); - return ret; - } - -@@ -2071,7 +2071,7 @@ static int at_xdmac_remove(struct platform_device *pdev) - - synchronize_irq(atxdmac->irq); - -- free_irq(atxdmac->irq, atxdmac->dma.dev); -+ free_irq(atxdmac->irq, atxdmac); - - for (i = 0; i < atxdmac->dma.chancnt; i++) { - struct at_xdmac_chan *atchan = &atxdmac->chan[i]; -diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c -index 990fa9023e22..3b6bce0518ab 100644 ---- a/drivers/gpio/gpio-sa1100.c -+++ b/drivers/gpio/gpio-sa1100.c -@@ -155,7 +155,7 @@ static int sa1100_gpio_irqdomain_map(struct irq_domain *d, - { - irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, - handle_edge_irq); -- irq_set_noprobe(irq); -+ irq_set_probe(irq); - - return 0; - } -diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c -index bfcc6408a772..b7f4b826febe 100644 ---- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c -+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c -@@ -36,7 +36,10 @@ nv04_fifo_dma_object_dtor(struct nvkm_fifo_chan *base, int cookie) - { - struct nv04_fifo_chan *chan = nv04_fifo_chan(base); - struct nvkm_instmem *imem = chan->fifo->base.engine.subdev.device->imem; -+ -+ mutex_lock(&chan->fifo->base.engine.subdev.mutex); - nvkm_ramht_remove(imem->ramht, cookie); -+ mutex_unlock(&chan->fifo->base.engine.subdev.mutex); - } - - static int -diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c -index caa73de584a5..3aaa07dafc00 100644 ---- a/drivers/gpu/drm/radeon/si_dpm.c -+++ b/drivers/gpu/drm/radeon/si_dpm.c -@@ -3015,6 +3015,12 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, - if (rdev->pdev->device == 0x6811 && - rdev->pdev->revision == 0x81) - max_mclk = 120000; -+ /* limit sclk/mclk on Jet parts for stability */ -+ if (rdev->pdev->device == 0x6665 && -+ rdev->pdev->revision == 0xc3) { -+ max_sclk = 75000; -+ max_mclk = 80000; -+ } - - if (rps->vce_active) { - rps->evclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].evclk; -diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c -index 827c03703128..a7f886961830 100644 ---- a/drivers/hwmon/adt7411.c -+++ b/drivers/hwmon/adt7411.c -@@ -30,6 +30,7 @@ - - #define ADT7411_REG_CFG1 0x18 - #define ADT7411_CFG1_START_MONITOR (1 << 0) -+#define ADT7411_CFG1_RESERVED_BIT3 (1 << 3) - - #define ADT7411_REG_CFG2 0x19 - #define ADT7411_CFG2_DISABLE_AVG (1 << 5) -@@ -296,8 +297,10 @@ static int adt7411_probe(struct i2c_client *client, - mutex_init(&data->device_lock); - mutex_init(&data->update_lock); - -+ /* According to the datasheet, we must only write 1 to bit 3 */ - ret = adt7411_modify_bit(client, ADT7411_REG_CFG1, -- ADT7411_CFG1_START_MONITOR, 1); -+ ADT7411_CFG1_RESERVED_BIT3 -+ | ADT7411_CFG1_START_MONITOR, 1); - if (ret < 0) - return ret; - -diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c -index bb6685fb08c6..6aa648cb5381 100644 ---- a/drivers/infiniband/core/multicast.c -+++ b/drivers/infiniband/core/multicast.c -@@ -106,7 +106,6 @@ struct mcast_group { - atomic_t refcount; - enum mcast_group_state state; - struct ib_sa_query *query; -- int query_id; - u16 pkey_index; - u8 leave_state; - int retries; -@@ -339,11 +338,7 @@ static int send_join(struct mcast_group *group, struct mcast_member *member) - member->multicast.comp_mask, - 3000, GFP_KERNEL, join_handler, group, - &group->query); -- if (ret >= 0) { -- group->query_id = ret; -- ret = 0; -- } -- return ret; -+ return (ret > 0) ? 0 : ret; - } - - static int send_leave(struct mcast_group *group, u8 leave_state) -@@ -363,11 +358,7 @@ static int send_leave(struct mcast_group *group, u8 leave_state) - IB_SA_MCMEMBER_REC_JOIN_STATE, - 3000, GFP_KERNEL, leave_handler, - group, &group->query); -- if (ret >= 0) { -- group->query_id = ret; -- ret = 0; -- } -- return ret; -+ return (ret > 0) ? 0 : ret; - } - - static void join_group(struct mcast_group *group, struct mcast_member *member, -diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c -index 05179f47bbde..d862b9b7910e 100644 ---- a/drivers/infiniband/hw/mlx4/mad.c -+++ b/drivers/infiniband/hw/mlx4/mad.c -@@ -1080,6 +1080,27 @@ void handle_port_mgmt_change_event(struct work_struct *work) - - /* Generate GUID changed event */ - if (changed_attr & MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK) { -+ if (mlx4_is_master(dev->dev)) { -+ union ib_gid gid; -+ int err = 0; -+ -+ if (!eqe->event.port_mgmt_change.params.port_info.gid_prefix) -+ err = __mlx4_ib_query_gid(&dev->ib_dev, port, 0, &gid, 1); -+ else -+ gid.global.subnet_prefix = -+ eqe->event.port_mgmt_change.params.port_info.gid_prefix; -+ if (err) { -+ pr_warn("Could not change QP1 subnet prefix for port %d: query_gid error (%d)\n", -+ port, err); -+ } else { -+ pr_debug("Changing QP1 subnet prefix for port %d. old=0x%llx. new=0x%llx\n", -+ port, -+ (u64)atomic64_read(&dev->sriov.demux[port - 1].subnet_prefix), -+ be64_to_cpu(gid.global.subnet_prefix)); -+ atomic64_set(&dev->sriov.demux[port - 1].subnet_prefix, -+ be64_to_cpu(gid.global.subnet_prefix)); -+ } -+ } - mlx4_ib_dispatch_event(dev, port, IB_EVENT_GID_CHANGE); - /*if master, notify all slaves*/ - if (mlx4_is_master(dev->dev)) -@@ -2154,6 +2175,8 @@ int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev) - if (err) - goto demux_err; - dev->sriov.demux[i].guid_cache[0] = gid.global.interface_id; -+ atomic64_set(&dev->sriov.demux[i].subnet_prefix, -+ be64_to_cpu(gid.global.subnet_prefix)); - err = alloc_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1, - &dev->sriov.sqps[i]); - if (err) -diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c -index 99451d887266..36ec8aa048aa 100644 ---- a/drivers/infiniband/hw/mlx4/mcg.c -+++ b/drivers/infiniband/hw/mlx4/mcg.c -@@ -489,7 +489,7 @@ static u8 get_leave_state(struct mcast_group *group) - if (!group->members[i]) - leave_state |= (1 << i); - -- return leave_state & (group->rec.scope_join_state & 7); -+ return leave_state & (group->rec.scope_join_state & 0xf); - } - - static int join_group(struct mcast_group *group, int slave, u8 join_mask) -@@ -564,8 +564,8 @@ static void mlx4_ib_mcg_timeout_handler(struct work_struct *work) - } else - mcg_warn_group(group, "DRIVER BUG\n"); - } else if (group->state == MCAST_LEAVE_SENT) { -- if (group->rec.scope_join_state & 7) -- group->rec.scope_join_state &= 0xf8; -+ if (group->rec.scope_join_state & 0xf) -+ group->rec.scope_join_state &= 0xf0; - group->state = MCAST_IDLE; - mutex_unlock(&group->lock); - if (release_group(group, 1)) -@@ -605,7 +605,7 @@ static int handle_leave_req(struct mcast_group *group, u8 leave_mask, - static int handle_join_req(struct mcast_group *group, u8 join_mask, - struct mcast_req *req) - { -- u8 group_join_state = group->rec.scope_join_state & 7; -+ u8 group_join_state = group->rec.scope_join_state & 0xf; - int ref = 0; - u16 status; - struct ib_sa_mcmember_data *sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; -@@ -690,8 +690,8 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work) - u8 cur_join_state; - - resp_join_state = ((struct ib_sa_mcmember_data *) -- group->response_sa_mad.data)->scope_join_state & 7; -- cur_join_state = group->rec.scope_join_state & 7; -+ group->response_sa_mad.data)->scope_join_state & 0xf; -+ cur_join_state = group->rec.scope_join_state & 0xf; - - if (method == IB_MGMT_METHOD_GET_RESP) { - /* successfull join */ -@@ -710,7 +710,7 @@ process_requests: - req = list_first_entry(&group->pending_list, struct mcast_req, - group_list); - sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; -- req_join_state = sa_data->scope_join_state & 0x7; -+ req_join_state = sa_data->scope_join_state & 0xf; - - /* For a leave request, we will immediately answer the VF, and - * update our internal counters. The actual leave will be sent -diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h -index 1caa11edac03..78f29e91653a 100644 ---- a/drivers/infiniband/hw/mlx4/mlx4_ib.h -+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h -@@ -441,7 +441,7 @@ struct mlx4_ib_demux_ctx { - struct workqueue_struct *wq; - struct workqueue_struct *ud_wq; - spinlock_t ud_lock; -- __be64 subnet_prefix; -+ atomic64_t subnet_prefix; - __be64 guid_cache[128]; - struct mlx4_ib_dev *dev; - /* the following lock protects both mcg_table and mcg_mgid0_list */ -diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c -index ea1e2ddaddf5..f350f2d61c15 100644 ---- a/drivers/infiniband/hw/mlx4/qp.c -+++ b/drivers/infiniband/hw/mlx4/qp.c -@@ -2331,24 +2331,27 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr, - sqp->ud_header.grh.flow_label = - ah->av.ib.sl_tclass_flowlabel & cpu_to_be32(0xfffff); - sqp->ud_header.grh.hop_limit = ah->av.ib.hop_limit; -- if (is_eth) -+ if (is_eth) { - memcpy(sqp->ud_header.grh.source_gid.raw, sgid.raw, 16); -- else { -- if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) { -- /* When multi-function is enabled, the ib_core gid -- * indexes don't necessarily match the hw ones, so -- * we must use our own cache */ -- sqp->ud_header.grh.source_gid.global.subnet_prefix = -- to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. -- subnet_prefix; -- sqp->ud_header.grh.source_gid.global.interface_id = -- to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. -- guid_cache[ah->av.ib.gid_index]; -- } else -- ib_get_cached_gid(ib_dev, -- be32_to_cpu(ah->av.ib.port_pd) >> 24, -- ah->av.ib.gid_index, -- &sqp->ud_header.grh.source_gid, NULL); -+ } else { -+ if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) { -+ /* When multi-function is enabled, the ib_core gid -+ * indexes don't necessarily match the hw ones, so -+ * we must use our own cache -+ */ -+ sqp->ud_header.grh.source_gid.global.subnet_prefix = -+ cpu_to_be64(atomic64_read(&(to_mdev(ib_dev)->sriov. -+ demux[sqp->qp.port - 1]. -+ subnet_prefix))); -+ sqp->ud_header.grh.source_gid.global.interface_id = -+ to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. -+ guid_cache[ah->av.ib.gid_index]; -+ } else { -+ ib_get_cached_gid(ib_dev, -+ be32_to_cpu(ah->av.ib.port_pd) >> 24, -+ ah->av.ib.gid_index, -+ &sqp->ud_header.grh.source_gid, NULL); -+ } - } - memcpy(sqp->ud_header.grh.destination_gid.raw, - ah->av.ib.dgid, 16); -diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h -index 3ede10309754..69a151ae8261 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib.h -+++ b/drivers/infiniband/ulp/ipoib/ipoib.h -@@ -472,6 +472,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, - struct ipoib_ah *address, u32 qpn); - void ipoib_reap_ah(struct work_struct *work); - -+struct ipoib_path *__path_find(struct net_device *dev, void *gid); - void ipoib_mark_paths_invalid(struct net_device *dev); - void ipoib_flush_paths(struct net_device *dev); - struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); -diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c -index 3ae9726efb98..8ca75af0e6d1 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c -@@ -1299,6 +1299,8 @@ void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) - } - } - -+#define QPN_AND_OPTIONS_OFFSET 4 -+ - static void ipoib_cm_tx_start(struct work_struct *work) - { - struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, -@@ -1307,6 +1309,7 @@ static void ipoib_cm_tx_start(struct work_struct *work) - struct ipoib_neigh *neigh; - struct ipoib_cm_tx *p; - unsigned long flags; -+ struct ipoib_path *path; - int ret; - - struct ib_sa_path_rec pathrec; -@@ -1319,7 +1322,19 @@ static void ipoib_cm_tx_start(struct work_struct *work) - p = list_entry(priv->cm.start_list.next, typeof(*p), list); - list_del_init(&p->list); - neigh = p->neigh; -+ - qpn = IPOIB_QPN(neigh->daddr); -+ /* -+ * As long as the search is with these 2 locks, -+ * path existence indicates its validity. -+ */ -+ path = __path_find(dev, neigh->daddr + QPN_AND_OPTIONS_OFFSET); -+ if (!path) { -+ pr_info("%s ignore not valid path %pI6\n", -+ __func__, -+ neigh->daddr + QPN_AND_OPTIONS_OFFSET); -+ goto free_neigh; -+ } - memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); - - spin_unlock_irqrestore(&priv->lock, flags); -@@ -1331,6 +1346,7 @@ static void ipoib_cm_tx_start(struct work_struct *work) - spin_lock_irqsave(&priv->lock, flags); - - if (ret) { -+free_neigh: - neigh = p->neigh; - if (neigh) { - neigh->cm = NULL; -diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c -index fa9c42ff1fb0..85de078fb0ce 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c -@@ -1028,8 +1028,17 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, - } - - if (level == IPOIB_FLUSH_LIGHT) { -+ int oper_up; - ipoib_mark_paths_invalid(dev); -+ /* Set IPoIB operation as down to prevent races between: -+ * the flush flow which leaves MCG and on the fly joins -+ * which can happen during that time. mcast restart task -+ * should deal with join requests we missed. -+ */ -+ oper_up = test_and_clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); - ipoib_mcast_dev_flush(dev); -+ if (oper_up) -+ set_bit(IPOIB_FLAG_OPER_UP, &priv->flags); - ipoib_flush_ah(dev); - } - -diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c -index 942dffca6a9d..5f7681b975d0 100644 ---- a/drivers/infiniband/ulp/ipoib/ipoib_main.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c -@@ -481,7 +481,7 @@ int ipoib_set_mode(struct net_device *dev, const char *buf) - return -EINVAL; - } - --static struct ipoib_path *__path_find(struct net_device *dev, void *gid) -+struct ipoib_path *__path_find(struct net_device *dev, void *gid) - { - struct ipoib_dev_priv *priv = netdev_priv(dev); - struct rb_node *n = priv->path_tree.rb_node; -diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c -index 2fc499a2207e..44aa57edf207 100644 ---- a/drivers/irqchip/irq-gic-v3.c -+++ b/drivers/irqchip/irq-gic-v3.c -@@ -544,7 +544,7 @@ static struct notifier_block gic_cpu_notifier = { - static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, - unsigned long cluster_id) - { -- int cpu = *base_cpu; -+ int next_cpu, cpu = *base_cpu; - unsigned long mpidr = cpu_logical_map(cpu); - u16 tlist = 0; - -@@ -558,9 +558,10 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, - - tlist |= 1 << (mpidr & 0xf); - -- cpu = cpumask_next(cpu, mask); -- if (cpu >= nr_cpu_ids) -+ next_cpu = cpumask_next(cpu, mask); -+ if (next_cpu >= nr_cpu_ids) - goto out; -+ cpu = next_cpu; - - mpidr = cpu_logical_map(cpu); - -diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c -index d8956b4a7b09..c8b513ee117c 100644 ---- a/drivers/md/dm-log-writes.c -+++ b/drivers/md/dm-log-writes.c -@@ -259,7 +259,7 @@ static int log_one_block(struct log_writes_c *lc, - sector++; - - atomic_inc(&lc->io_blocks); -- bio = bio_alloc(GFP_KERNEL, block->vec_cnt); -+ bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt, BIO_MAX_PAGES)); - if (!bio) { - DMERR("Couldn't alloc log bio"); - goto error; -@@ -280,7 +280,7 @@ static int log_one_block(struct log_writes_c *lc, - if (ret != block->vecs[i].bv_len) { - atomic_inc(&lc->io_blocks); - submit_bio(WRITE, bio); -- bio = bio_alloc(GFP_KERNEL, block->vec_cnt - i); -+ bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt - i, BIO_MAX_PAGES)); - if (!bio) { - DMERR("Couldn't alloc log bio"); - goto error; -diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c -index a19b5c8b56ff..1a9e1e556706 100644 ---- a/drivers/media/usb/em28xx/em28xx-i2c.c -+++ b/drivers/media/usb/em28xx/em28xx-i2c.c -@@ -507,9 +507,8 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, - if (dev->disconnected) - return -ENODEV; - -- rc = rt_mutex_trylock(&dev->i2c_bus_lock); -- if (rc < 0) -- return rc; -+ if (!rt_mutex_trylock(&dev->i2c_bus_lock)) -+ return -EAGAIN; - - /* Switch I2C bus if needed */ - if (bus != dev->cur_i2c_bus && -diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c -index f23df4a9d8c5..52b88e9e656b 100644 ---- a/drivers/media/usb/gspca/cpia1.c -+++ b/drivers/media/usb/gspca/cpia1.c -@@ -1624,7 +1624,7 @@ static int sd_start(struct gspca_dev *gspca_dev) - - static void sd_stopN(struct gspca_dev *gspca_dev) - { -- struct sd *sd = (struct sd *) gspca_dev; -+ struct sd *sd __maybe_unused = (struct sd *) gspca_dev; - - command_pause(gspca_dev); - -diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c -index 39c96bb4c985..0712b1bc90b4 100644 ---- a/drivers/media/usb/gspca/konica.c -+++ b/drivers/media/usb/gspca/konica.c -@@ -243,7 +243,7 @@ static int sd_start(struct gspca_dev *gspca_dev) - - static void sd_stopN(struct gspca_dev *gspca_dev) - { -- struct sd *sd = (struct sd *) gspca_dev; -+ struct sd *sd __maybe_unused = (struct sd *) gspca_dev; - - konica_stream_off(gspca_dev); - #if IS_ENABLED(CONFIG_INPUT) -diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c -index e2cc4e5a0ccb..bb52fc1fe598 100644 ---- a/drivers/media/usb/gspca/t613.c -+++ b/drivers/media/usb/gspca/t613.c -@@ -837,7 +837,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, - u8 *data, /* isoc packet */ - int len) /* iso packet length */ - { -- struct sd *sd = (struct sd *) gspca_dev; -+ struct sd *sd __maybe_unused = (struct sd *) gspca_dev; - int pkt_type; - - if (data[0] == 0x5a) { -diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c -index 28a057fae0a1..72bbb12fb938 100644 ---- a/drivers/mmc/host/pxamci.c -+++ b/drivers/mmc/host/pxamci.c -@@ -798,14 +798,16 @@ static int pxamci_probe(struct platform_device *pdev) - gpio_direction_output(gpio_power, - host->pdata->gpio_power_invert); - } -- if (gpio_is_valid(gpio_ro)) -+ if (gpio_is_valid(gpio_ro)) { - ret = mmc_gpio_request_ro(mmc, gpio_ro); -- if (ret) { -- dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", gpio_ro); -- goto out; -- } else { -- mmc->caps2 |= host->pdata->gpio_card_ro_invert ? -- 0 : MMC_CAP2_RO_ACTIVE_HIGH; -+ if (ret) { -+ dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", -+ gpio_ro); -+ goto out; -+ } else { -+ mmc->caps2 |= host->pdata->gpio_card_ro_invert ? -+ 0 : MMC_CAP2_RO_ACTIVE_HIGH; -+ } - } - - if (gpio_is_valid(gpio_cd)) -diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c -index c72313d66cf6..bc054a5ed7f8 100644 ---- a/drivers/mtd/nand/davinci_nand.c -+++ b/drivers/mtd/nand/davinci_nand.c -@@ -241,6 +241,9 @@ static void nand_davinci_hwctl_4bit(struct mtd_info *mtd, int mode) - unsigned long flags; - u32 val; - -+ /* Reset ECC hardware */ -+ davinci_nand_readl(info, NAND_4BIT_ECC1_OFFSET); -+ - spin_lock_irqsave(&davinci_nand_lock, flags); - - /* Start 4-bit ECC calculation for read/write */ -diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c -index ad535a854e5c..eab132778e67 100644 ---- a/drivers/net/can/dev.c -+++ b/drivers/net/can/dev.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -471,9 +472,8 @@ EXPORT_SYMBOL_GPL(can_free_echo_skb); - /* - * CAN device restart for bus-off recovery - */ --static void can_restart(unsigned long data) -+static void can_restart(struct net_device *dev) - { -- struct net_device *dev = (struct net_device *)data; - struct can_priv *priv = netdev_priv(dev); - struct net_device_stats *stats = &dev->stats; - struct sk_buff *skb; -@@ -513,6 +513,14 @@ restart: - netdev_err(dev, "Error %d during restart", err); - } - -+static void can_restart_work(struct work_struct *work) -+{ -+ struct delayed_work *dwork = to_delayed_work(work); -+ struct can_priv *priv = container_of(dwork, struct can_priv, restart_work); -+ -+ can_restart(priv->dev); -+} -+ - int can_restart_now(struct net_device *dev) - { - struct can_priv *priv = netdev_priv(dev); -@@ -526,8 +534,8 @@ int can_restart_now(struct net_device *dev) - if (priv->state != CAN_STATE_BUS_OFF) - return -EBUSY; - -- /* Runs as soon as possible in the timer context */ -- mod_timer(&priv->restart_timer, jiffies); -+ cancel_delayed_work_sync(&priv->restart_work); -+ can_restart(dev); - - return 0; - } -@@ -548,8 +556,8 @@ void can_bus_off(struct net_device *dev) - netif_carrier_off(dev); - - if (priv->restart_ms) -- mod_timer(&priv->restart_timer, -- jiffies + (priv->restart_ms * HZ) / 1000); -+ schedule_delayed_work(&priv->restart_work, -+ msecs_to_jiffies(priv->restart_ms)); - } - EXPORT_SYMBOL_GPL(can_bus_off); - -@@ -658,6 +666,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max) - return NULL; - - priv = netdev_priv(dev); -+ priv->dev = dev; - - if (echo_skb_max) { - priv->echo_skb_max = echo_skb_max; -@@ -667,7 +676,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max) - - priv->state = CAN_STATE_STOPPED; - -- init_timer(&priv->restart_timer); -+ INIT_DELAYED_WORK(&priv->restart_work, can_restart_work); - - return dev; - } -@@ -748,8 +757,6 @@ int open_candev(struct net_device *dev) - if (!netif_carrier_ok(dev)) - netif_carrier_on(dev); - -- setup_timer(&priv->restart_timer, can_restart, (unsigned long)dev); -- - return 0; - } - EXPORT_SYMBOL_GPL(open_candev); -@@ -764,7 +771,7 @@ void close_candev(struct net_device *dev) - { - struct can_priv *priv = netdev_priv(dev); - -- del_timer_sync(&priv->restart_timer); -+ cancel_delayed_work_sync(&priv->restart_work); - can_flush_echo_skb(dev); - } - EXPORT_SYMBOL_GPL(close_candev); -diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c -index 2d74c6e4d7b6..1cf715c72683 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_common.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c -@@ -302,13 +302,15 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc, - void *buffer, u16 buf_len) - { - struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc; -- u16 len = le16_to_cpu(aq_desc->datalen); -+ u16 len; - u8 *buf = (u8 *)buffer; - u16 i = 0; - - if ((!(mask & hw->debug_mask)) || (desc == NULL)) - return; - -+ len = le16_to_cpu(aq_desc->datalen); -+ - i40e_debug(hw, mask, - "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n", - le16_to_cpu(aq_desc->opcode), -diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c -index 8b4561e8ce1a..ef493271c712 100644 ---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c -+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c -@@ -4176,7 +4176,7 @@ static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, - if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && !AR_SREV_9531(ah)) - ar9003_hw_internal_regulator_apply(ah); - ar9003_hw_apply_tuning_caps(ah); -- ar9003_hw_apply_minccapwr_thresh(ah, chan); -+ ar9003_hw_apply_minccapwr_thresh(ah, is2ghz); - ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz); - ar9003_hw_thermometer_apply(ah); - ar9003_hw_thermo_cal_apply(ah); -diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c -index 410a6645d316..59cef6c69fe8 100644 ---- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c -+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c -@@ -726,8 +726,10 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev, - return -ENOMEM; - err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr, - glom_skb); -- if (err) -+ if (err) { -+ brcmu_pkt_buf_free_skb(glom_skb); - goto done; -+ } - - skb_queue_walk(pktq, skb) { - memcpy(skb->data, glom_skb->data, skb->len); -diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c -index 796f5f9d5d5a..b7df576bb84d 100644 ---- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c -+++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c -@@ -1079,8 +1079,10 @@ bool dma_rxfill(struct dma_pub *pub) - - pa = dma_map_single(di->dmadev, p->data, di->rxbufsize, - DMA_FROM_DEVICE); -- if (dma_mapping_error(di->dmadev, pa)) -+ if (dma_mapping_error(di->dmadev, pa)) { -+ brcmu_pkt_buf_free_skb(p); - return false; -+ } - - /* save the free packet pointer */ - di->rxp[rxout] = p; -diff --git a/drivers/net/wireless/brcm80211/brcmsmac/stf.c b/drivers/net/wireless/brcm80211/brcmsmac/stf.c -index dd9162722495..0ab865de1491 100644 ---- a/drivers/net/wireless/brcm80211/brcmsmac/stf.c -+++ b/drivers/net/wireless/brcm80211/brcmsmac/stf.c -@@ -87,7 +87,7 @@ void - brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc, u16 *ss_algo_channel, - u16 chanspec) - { -- struct tx_power power; -+ struct tx_power power = { }; - u8 siso_mcs_id, cdd_mcs_id, stbc_mcs_id; - - /* Clear previous settings */ -diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c -index 610c442c7ab2..9584f950fd2f 100644 ---- a/drivers/net/wireless/iwlwifi/mvm/fw.c -+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c -@@ -935,7 +935,8 @@ int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 conf_id) - } - - mvm->fw_dbg_conf = conf_id; -- return ret; -+ -+ return 0; - } - - static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) -diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c -index f96ab2f4b90e..ce12717e656a 100644 ---- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c -+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c -@@ -3992,8 +3992,8 @@ static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx, - if (idx != 0) - return -ENOENT; - -- if (fw_has_capa(&mvm->fw->ucode_capa, -- IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) -+ if (!fw_has_capa(&mvm->fw->ucode_capa, -+ IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) - return -ENOENT; - - mutex_lock(&mvm->mutex); -@@ -4039,8 +4039,8 @@ static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw, - struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); - struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); - -- if (fw_has_capa(&mvm->fw->ucode_capa, -- IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) -+ if (!fw_has_capa(&mvm->fw->ucode_capa, -+ IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) - return; - - /* if beacon filtering isn't on mac80211 does it anyway */ -diff --git a/drivers/net/wireless/iwlwifi/mvm/sf.c b/drivers/net/wireless/iwlwifi/mvm/sf.c -index b0f59fdd287c..d7d72adb6343 100644 ---- a/drivers/net/wireless/iwlwifi/mvm/sf.c -+++ b/drivers/net/wireless/iwlwifi/mvm/sf.c -@@ -215,7 +215,7 @@ static int iwl_mvm_sf_config(struct iwl_mvm *mvm, u8 sta_id, - enum iwl_sf_state new_state) - { - struct iwl_sf_cfg_cmd sf_cmd = { -- .state = cpu_to_le32(SF_FULL_ON), -+ .state = cpu_to_le32(new_state), - }; - struct ieee80211_sta *sta; - int ret = 0; -diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c -index a8c8a4a7420b..8dfe6b2bc703 100644 ---- a/drivers/net/wireless/iwlwifi/pcie/tx.c -+++ b/drivers/net/wireless/iwlwifi/pcie/tx.c -@@ -1508,9 +1508,9 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, - - /* start the TFD with the scratchbuf */ - scratch_size = min_t(int, copy_size, IWL_HCMD_SCRATCHBUF_SIZE); -- memcpy(&txq->scratchbufs[q->write_ptr], &out_cmd->hdr, scratch_size); -+ memcpy(&txq->scratchbufs[idx], &out_cmd->hdr, scratch_size); - iwl_pcie_txq_build_tfd(trans, txq, -- iwl_pcie_get_scratchbuf_dma(txq, q->write_ptr), -+ iwl_pcie_get_scratchbuf_dma(txq, idx), - scratch_size, true); - - /* map first command fragment, if any remains */ -diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c -index ccb07a1b153d..23e53780728b 100644 ---- a/drivers/nfc/fdp/fdp.c -+++ b/drivers/nfc/fdp/fdp.c -@@ -352,7 +352,7 @@ static int fdp_nci_patch_otp(struct nci_dev *ndev) - { - struct fdp_nci_info *info = nci_get_drvdata(ndev); - struct device *dev = &info->phy->i2c_dev->dev; -- u8 conn_id; -+ int conn_id; - int r = 0; - - if (info->otp_version >= info->otp_patch_version) -@@ -423,7 +423,7 @@ static int fdp_nci_patch_ram(struct nci_dev *ndev) - { - struct fdp_nci_info *info = nci_get_drvdata(ndev); - struct device *dev = &info->phy->i2c_dev->dev; -- u8 conn_id; -+ int conn_id; - int r = 0; - - if (info->ram_version >= info->ram_patch_version) -diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c -index be3755c973e9..8af1f900ea65 100644 ---- a/drivers/perf/arm_pmu.c -+++ b/drivers/perf/arm_pmu.c -@@ -815,6 +815,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) - if (i > 0 && spi != using_spi) { - pr_err("PPI/SPI IRQ type mismatch for %s!\n", - dn->name); -+ of_node_put(dn); - kfree(irqs); - return -EINVAL; - } -diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c -index 589872cc8adb..a19c29c79b0a 100644 ---- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c -+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c -@@ -73,6 +73,12 @@ static void uniphier_pctl_pin_dbg_show(struct pinctrl_dev *pctldev, - case UNIPHIER_PIN_PULL_DOWN: - pull_dir = "DOWN"; - break; -+ case UNIPHIER_PIN_PULL_UP_FIXED: -+ pull_dir = "UP(FIXED)"; -+ break; -+ case UNIPHIER_PIN_PULL_DOWN_FIXED: -+ pull_dir = "DOWN(FIXED)"; -+ break; - case UNIPHIER_PIN_PULL_NONE: - pull_dir = "NONE"; - break; -diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c -index 6fa0c7d13290..4bda998afdef 100644 ---- a/drivers/regulator/qcom_smd-regulator.c -+++ b/drivers/regulator/qcom_smd-regulator.c -@@ -166,29 +166,30 @@ static const struct regulator_desc pm8x41_hfsmps = { - static const struct regulator_desc pm8841_ftsmps = { - .linear_ranges = (struct regulator_linear_range[]) { - REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), -- REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), -+ REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000), - }, - .n_linear_ranges = 2, -- .n_voltages = 340, -+ .n_voltages = 262, - .ops = &rpm_smps_ldo_ops, - }; - - static const struct regulator_desc pm8941_boost = { - .linear_ranges = (struct regulator_linear_range[]) { -- REGULATOR_LINEAR_RANGE(4000000, 0, 15, 100000), -+ REGULATOR_LINEAR_RANGE(4000000, 0, 30, 50000), - }, - .n_linear_ranges = 1, -- .n_voltages = 16, -+ .n_voltages = 31, - .ops = &rpm_smps_ldo_ops, - }; - - static const struct regulator_desc pm8941_pldo = { - .linear_ranges = (struct regulator_linear_range[]) { -- REGULATOR_LINEAR_RANGE( 750000, 0, 30, 25000), -- REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), -+ REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500), -+ REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000), -+ REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000), - }, -- .n_linear_ranges = 2, -- .n_voltages = 100, -+ .n_linear_ranges = 3, -+ .n_voltages = 164, - .ops = &rpm_smps_ldo_ops, - }; - -diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c -index 88a5dc88badc..fee6457e3111 100644 ---- a/drivers/regulator/qcom_spmi-regulator.c -+++ b/drivers/regulator/qcom_spmi-regulator.c -@@ -1050,6 +1050,8 @@ static struct regulator_ops spmi_vs_ops = { - .set_pull_down = spmi_regulator_common_set_pull_down, - .set_soft_start = spmi_regulator_common_set_soft_start, - .set_over_current_protection = spmi_regulator_vs_ocp, -+ .set_mode = spmi_regulator_common_set_mode, -+ .get_mode = spmi_regulator_common_get_mode, - }; - - static struct regulator_ops spmi_boost_ops = { -@@ -1440,6 +1442,7 @@ static const struct spmi_regulator_data pm8941_regulators[] = { - { "s1", 0x1400, "vdd_s1", }, - { "s2", 0x1700, "vdd_s2", }, - { "s3", 0x1a00, "vdd_s3", }, -+ { "s4", 0xa000, }, - { "l1", 0x4000, "vdd_l1_l3", }, - { "l2", 0x4100, "vdd_l2_lvs_1_2_3", }, - { "l3", 0x4200, "vdd_l1_l3", }, -@@ -1467,8 +1470,8 @@ static const struct spmi_regulator_data pm8941_regulators[] = { - { "lvs1", 0x8000, "vdd_l2_lvs_1_2_3", }, - { "lvs2", 0x8100, "vdd_l2_lvs_1_2_3", }, - { "lvs3", 0x8200, "vdd_l2_lvs_1_2_3", }, -- { "mvs1", 0x8300, "vin_5vs", }, -- { "mvs2", 0x8400, "vin_5vs", }, -+ { "5vs1", 0x8300, "vin_5vs", "ocp-5vs1", }, -+ { "5vs2", 0x8400, "vin_5vs", "ocp-5vs2", }, - { } - }; - -diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c -index 67669a9e73c1..f3a33312a9a6 100644 ---- a/drivers/scsi/fnic/fnic_fcs.c -+++ b/drivers/scsi/fnic/fnic_fcs.c -@@ -954,8 +954,8 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq) - skb_put(skb, len); - pa = pci_map_single(fnic->pdev, skb->data, len, PCI_DMA_FROMDEVICE); - -- r = pci_dma_mapping_error(fnic->pdev, pa); -- if (r) { -+ if (pci_dma_mapping_error(fnic->pdev, pa)) { -+ r = -ENOMEM; - printk(KERN_ERR "PCI mapping failed with error %d\n", r); - goto free_skb; - } -@@ -1093,8 +1093,8 @@ static int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp) - - pa = pci_map_single(fnic->pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE); - -- ret = pci_dma_mapping_error(fnic->pdev, pa); -- if (ret) { -+ if (pci_dma_mapping_error(fnic->pdev, pa)) { -+ ret = -ENOMEM; - printk(KERN_ERR "DMA map failed with error %d\n", ret); - goto free_skb_on_err; - } -diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c -index a7934ab00b96..d22de4c8c399 100644 ---- a/drivers/spi/spi-sh-msiof.c -+++ b/drivers/spi/spi-sh-msiof.c -@@ -263,6 +263,9 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p, - - for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) { - brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div); -+ /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */ -+ if (sh_msiof_spi_div_table[k].div == 1 && brps > 2) -+ continue; - if (brps <= 32) /* max of brdv is 32 */ - break; - } -diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c -index b1e45161eefc..18c2b6daf588 100644 ---- a/drivers/staging/fbtft/fbtft-core.c -+++ b/drivers/staging/fbtft/fbtft-core.c -@@ -392,11 +392,11 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned start_line, - - if (unlikely(timeit)) { - ts_end = ktime_get(); -- if (ktime_to_ns(par->update_time)) -+ if (!ktime_to_ns(par->update_time)) - par->update_time = ts_start; - -- par->update_time = ts_start; - fps = ktime_us_delta(ts_start, par->update_time); -+ par->update_time = ts_start; - fps = fps ? 1000000 / fps : 0; - - throughput = ktime_us_delta(ts_end, ts_start); -diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c -index 7a11a8263171..deaddb950c20 100644 ---- a/drivers/usb/class/usbtmc.c -+++ b/drivers/usb/class/usbtmc.c -@@ -121,6 +121,7 @@ static void usbtmc_delete(struct kref *kref) - struct usbtmc_device_data *data = to_usbtmc_data(kref); - - usb_put_dev(data->usb_dev); -+ kfree(data); - } - - static int usbtmc_open(struct inode *inode, struct file *filp) -@@ -1104,7 +1105,7 @@ static int usbtmc_probe(struct usb_interface *intf, - - dev_dbg(&intf->dev, "%s called\n", __func__); - -- data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); -+ data = kmalloc(sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - -diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c -index c73689b72f95..b38a33584d4a 100644 ---- a/drivers/usb/gadget/udc/fsl_qe_udc.c -+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c -@@ -1878,11 +1878,8 @@ static int qe_get_frame(struct usb_gadget *gadget) - - tmp = in_be16(&udc->usb_param->frame_n); - if (tmp & 0x8000) -- tmp = tmp & 0x07ff; -- else -- tmp = -EINVAL; -- -- return (int)tmp; -+ return tmp & 0x07ff; -+ return -EINVAL; - } - - static int fsl_qe_start(struct usb_gadget *gadget, -diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c -index 7771be3ac178..4dd531ac5a7f 100644 ---- a/drivers/usb/misc/legousbtower.c -+++ b/drivers/usb/misc/legousbtower.c -@@ -898,24 +898,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device - dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; - dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; - -- /* we can register the device now, as it is ready */ -- usb_set_intfdata (interface, dev); -- -- retval = usb_register_dev (interface, &tower_class); -- -- if (retval) { -- /* something prevented us from registering this driver */ -- dev_err(idev, "Not able to get a minor for this device.\n"); -- usb_set_intfdata (interface, NULL); -- goto error; -- } -- dev->minor = interface->minor; -- -- /* let the user know what node this device is now attached to */ -- dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " -- "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), -- USB_MAJOR, dev->minor); -- - /* get the firmware version and log it */ - result = usb_control_msg (udev, - usb_rcvctrlpipe(udev, 0), -@@ -936,6 +918,23 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device - get_version_reply.minor, - le16_to_cpu(get_version_reply.build_no)); - -+ /* we can register the device now, as it is ready */ -+ usb_set_intfdata (interface, dev); -+ -+ retval = usb_register_dev (interface, &tower_class); -+ -+ if (retval) { -+ /* something prevented us from registering this driver */ -+ dev_err(idev, "Not able to get a minor for this device.\n"); -+ usb_set_intfdata (interface, NULL); -+ goto error; -+ } -+ dev->minor = interface->minor; -+ -+ /* let the user know what node this device is now attached to */ -+ dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " -+ "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), -+ USB_MAJOR, dev->minor); - - exit: - return retval; -diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c -index 59a63a0b7985..e0a083f6ab68 100644 ---- a/drivers/usb/musb/musb_host.c -+++ b/drivers/usb/musb/musb_host.c -@@ -661,7 +661,7 @@ static int musb_tx_dma_set_mode_mentor(struct dma_controller *dma, - csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAMODE); - csr |= MUSB_TXCSR_DMAENAB; /* against programmer's guide */ - } -- channel->desired_mode = mode; -+ channel->desired_mode = *mode; - musb_writew(epio, MUSB_TXCSR, csr); - - return 0; -@@ -2008,10 +2008,8 @@ void musb_host_rx(struct musb *musb, u8 epnum) - qh->offset, - urb->transfer_buffer_length); - -- done = musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, -- urb, xfer_len, -- iso_err); -- if (done) -+ if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb, -+ xfer_len, iso_err)) - goto finish; - else - dev_err(musb->controller, "error: rx_dma failed\n"); -diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c -index a2b43a6e7fa7..6eccded3bc33 100644 ---- a/drivers/usb/serial/cp210x.c -+++ b/drivers/usb/serial/cp210x.c -@@ -117,6 +117,7 @@ static const struct usb_device_id id_table[] = { - { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */ - { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */ - { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */ -+ { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */ - { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ - { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ - { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ -@@ -784,7 +785,7 @@ static void cp210x_set_termios(struct tty_struct *tty, - } else { - modem_ctl[0] &= ~0x7B; - modem_ctl[0] |= 0x01; -- modem_ctl[1] |= 0x40; -+ modem_ctl[1] = 0x40; - dev_dbg(dev, "%s - flow control = NONE\n", __func__); - } - -diff --git a/fs/aio.c b/fs/aio.c -index 155f84253f33..fe4f49212b99 100644 ---- a/fs/aio.c -+++ b/fs/aio.c -@@ -239,7 +239,12 @@ static struct dentry *aio_mount(struct file_system_type *fs_type, - static const struct dentry_operations ops = { - .d_dname = simple_dname, - }; -- return mount_pseudo(fs_type, "aio:", NULL, &ops, AIO_RING_MAGIC); -+ struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, &ops, -+ AIO_RING_MAGIC); -+ -+ if (!IS_ERR(root)) -+ root->d_sb->s_iflags |= SB_I_NOEXEC; -+ return root; - } - - /* aio_setup -diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c -index 498dcfa2dcdb..d98536c8abfc 100644 ---- a/fs/ceph/inode.c -+++ b/fs/ceph/inode.c -@@ -1358,15 +1358,20 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn, - - if (!ctl->page || pgoff != page_index(ctl->page)) { - ceph_readdir_cache_release(ctl); -- ctl->page = grab_cache_page(&dir->i_data, pgoff); -+ if (idx == 0) -+ ctl->page = grab_cache_page(&dir->i_data, pgoff); -+ else -+ ctl->page = find_lock_page(&dir->i_data, pgoff); - if (!ctl->page) { - ctl->index = -1; -- return -ENOMEM; -+ return idx == 0 ? -ENOMEM : 0; - } - /* reading/filling the cache are serialized by - * i_mutex, no need to use page lock */ - unlock_page(ctl->page); - ctl->dentries = kmap(ctl->page); -+ if (idx == 0) -+ memset(ctl->dentries, 0, PAGE_CACHE_SIZE); - } - - if (req->r_dir_release_cnt == atomic64_read(&ci->i_release_count) && -diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c -index 646cdac73488..e2e857affbf2 100644 ---- a/fs/nfs/callback_xdr.c -+++ b/fs/nfs/callback_xdr.c -@@ -912,7 +912,7 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r - if (hdr_arg.minorversion == 0) { - cps.clp = nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident); - if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) -- return rpc_drop_reply; -+ goto out_invalidcred; - } - - cps.minorversion = hdr_arg.minorversion; -@@ -940,6 +940,10 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r - nfs_put_client(cps.clp); - dprintk("%s: done, status = %u\n", __func__, ntohl(status)); - return rpc_success; -+ -+out_invalidcred: -+ pr_warn_ratelimited("NFS: NFSv4 callback contains invalid cred\n"); -+ return rpc_autherr_badcred; - } - - /* -diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c -index 02ec07973bc4..fd8da630fd22 100644 ---- a/fs/nfs/filelayout/filelayout.c -+++ b/fs/nfs/filelayout/filelayout.c -@@ -374,8 +374,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task, - return -EAGAIN; - } - -- if (data->verf.committed == NFS_UNSTABLE) -- pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); -+ pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); - - return 0; - } -diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c -index 2a2e2d8ddee5..54313322ee5b 100644 ---- a/fs/nfs/flexfilelayout/flexfilelayout.c -+++ b/fs/nfs/flexfilelayout/flexfilelayout.c -@@ -1414,8 +1414,7 @@ static int ff_layout_commit_done_cb(struct rpc_task *task, - return -EAGAIN; - } - -- if (data->verf.committed == NFS_UNSTABLE -- && ff_layout_need_layoutcommit(data->lseg)) -+ if (ff_layout_need_layoutcommit(data->lseg)) - pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); - - return 0; -diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c -index d8c439d813ce..ac6c78fe19cf 100644 ---- a/fs/pstore/inode.c -+++ b/fs/pstore/inode.c -@@ -178,7 +178,6 @@ static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence) - } - - static const struct file_operations pstore_file_operations = { -- .owner = THIS_MODULE, - .open = pstore_file_open, - .read = pstore_file_read, - .llseek = pstore_file_llseek, -diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h -index 5261751f6bd4..5f5270941ba0 100644 ---- a/include/linux/can/dev.h -+++ b/include/linux/can/dev.h -@@ -32,6 +32,7 @@ enum can_mode { - * CAN common private data - */ - struct can_priv { -+ struct net_device *dev; - struct can_device_stats can_stats; - - struct can_bittiming bittiming, data_bittiming; -@@ -47,7 +48,7 @@ struct can_priv { - u32 ctrlmode_static; /* static enabled options for driver/hardware */ - - int restart_ms; -- struct timer_list restart_timer; -+ struct delayed_work restart_work; - - int (*do_set_bittiming)(struct net_device *dev); - int (*do_set_data_bittiming)(struct net_device *dev); -diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h -index 9bb77d3ed6e0..c2256d746543 100644 ---- a/include/linux/nvmem-consumer.h -+++ b/include/linux/nvmem-consumer.h -@@ -74,7 +74,7 @@ static inline void nvmem_cell_put(struct nvmem_cell *cell) - { - } - --static inline char *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) -+static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) - { - return ERR_PTR(-ENOSYS); - } -diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h -index fa7bc29925c9..ef17db6caaed 100644 ---- a/include/linux/sysctl.h -+++ b/include/linux/sysctl.h -@@ -41,6 +41,8 @@ extern int proc_dostring(struct ctl_table *, int, - void __user *, size_t *, loff_t *); - extern int proc_dointvec(struct ctl_table *, int, - void __user *, size_t *, loff_t *); -+extern int proc_douintvec(struct ctl_table *, int, -+ void __user *, size_t *, loff_t *); - extern int proc_dointvec_minmax(struct ctl_table *, int, - void __user *, size_t *, loff_t *); - extern int proc_dointvec_jiffies(struct ctl_table *, int, -diff --git a/kernel/cpuset.c b/kernel/cpuset.c -index b9279a2844d8..b271353d5202 100644 ---- a/kernel/cpuset.c -+++ b/kernel/cpuset.c -@@ -324,8 +324,7 @@ static struct file_system_type cpuset_fs_type = { - /* - * Return in pmask the portion of a cpusets's cpus_allowed that - * are online. If none are online, walk up the cpuset hierarchy -- * until we find one that does have some online cpus. The top -- * cpuset always has some cpus online. -+ * until we find one that does have some online cpus. - * - * One way or another, we guarantee to return some non-empty subset - * of cpu_online_mask. -@@ -334,8 +333,20 @@ static struct file_system_type cpuset_fs_type = { - */ - static void guarantee_online_cpus(struct cpuset *cs, struct cpumask *pmask) - { -- while (!cpumask_intersects(cs->effective_cpus, cpu_online_mask)) -+ while (!cpumask_intersects(cs->effective_cpus, cpu_online_mask)) { - cs = parent_cs(cs); -+ if (unlikely(!cs)) { -+ /* -+ * The top cpuset doesn't have any online cpu as a -+ * consequence of a race between cpuset_hotplug_work -+ * and cpu hotplug notifier. But we know the top -+ * cpuset's effective_cpus is on its way to to be -+ * identical to cpu_online_mask. -+ */ -+ cpumask_copy(pmask, cpu_online_mask); -+ return; -+ } -+ } - cpumask_and(pmask, cs->effective_cpus, cpu_online_mask); - } - -diff --git a/kernel/events/core.c b/kernel/events/core.c -index 12ecd4f0329f..bc6371b0e4fb 100644 ---- a/kernel/events/core.c -+++ b/kernel/events/core.c -@@ -1539,12 +1539,33 @@ static int __init perf_workqueue_init(void) - - core_initcall(perf_workqueue_init); - --static inline int pmu_filter_match(struct perf_event *event) -+static inline int __pmu_filter_match(struct perf_event *event) - { - struct pmu *pmu = event->pmu; - return pmu->filter_match ? pmu->filter_match(event) : 1; - } - -+/* -+ * Check whether we should attempt to schedule an event group based on -+ * PMU-specific filtering. An event group can consist of HW and SW events, -+ * potentially with a SW leader, so we must check all the filters, to -+ * determine whether a group is schedulable: -+ */ -+static inline int pmu_filter_match(struct perf_event *event) -+{ -+ struct perf_event *child; -+ -+ if (!__pmu_filter_match(event)) -+ return 0; -+ -+ list_for_each_entry(child, &event->sibling_list, group_entry) { -+ if (!__pmu_filter_match(child)) -+ return 0; -+ } -+ -+ return 1; -+} -+ - static inline int - event_filter_match(struct perf_event *event) - { -diff --git a/kernel/fork.c b/kernel/fork.c -index 8860d1f50d24..7161ebe67cbb 100644 ---- a/kernel/fork.c -+++ b/kernel/fork.c -@@ -901,14 +901,12 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) - deactivate_mm(tsk, mm); - - /* -- * If we're exiting normally, clear a user-space tid field if -- * requested. We leave this alone when dying by signal, to leave -- * the value intact in a core dump, and to save the unnecessary -- * trouble, say, a killed vfork parent shouldn't touch this mm. -- * Userland only wants this done for a sys_exit. -+ * Signal userspace if we're not exiting with a core dump -+ * because we want to leave the value intact for debugging -+ * purposes. - */ - if (tsk->clear_child_tid) { -- if (!(tsk->flags & PF_SIGNALED) && -+ if (!(tsk->signal->flags & SIGNAL_GROUP_COREDUMP) && - atomic_read(&mm->mm_users) > 1) { - /* - * We don't check the error code - if userspace has -diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c -index 276762f3a460..d5760c42f042 100644 ---- a/kernel/printk/braille.c -+++ b/kernel/printk/braille.c -@@ -9,10 +9,10 @@ - - char *_braille_console_setup(char **str, char **brl_options) - { -- if (!memcmp(*str, "brl,", 4)) { -+ if (!strncmp(*str, "brl,", 4)) { - *brl_options = ""; - *str += 4; -- } else if (!memcmp(str, "brl=", 4)) { -+ } else if (!strncmp(*str, "brl=", 4)) { - *brl_options = *str + 4; - *str = strchr(*brl_options, ','); - if (!*str) -diff --git a/kernel/sysctl.c b/kernel/sysctl.c -index 2781141a89f9..999e025bf68e 100644 ---- a/kernel/sysctl.c -+++ b/kernel/sysctl.c -@@ -2051,6 +2051,21 @@ static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, - return 0; - } - -+static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, -+ int *valp, -+ int write, void *data) -+{ -+ if (write) { -+ if (*negp) -+ return -EINVAL; -+ *valp = *lvalp; -+ } else { -+ unsigned int val = *valp; -+ *lvalp = (unsigned long)val; -+ } -+ return 0; -+} -+ - static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; - - static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, -@@ -2178,8 +2193,27 @@ static int do_proc_dointvec(struct ctl_table *table, int write, - int proc_dointvec(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) - { -- return do_proc_dointvec(table,write,buffer,lenp,ppos, -- NULL,NULL); -+ return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); -+} -+ -+/** -+ * proc_douintvec - read a vector of unsigned integers -+ * @table: the sysctl table -+ * @write: %TRUE if this is a write to the sysctl file -+ * @buffer: the user buffer -+ * @lenp: the size of the user buffer -+ * @ppos: file position -+ * -+ * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer -+ * values from/to the user buffer, treated as an ASCII string. -+ * -+ * Returns 0 on success. -+ */ -+int proc_douintvec(struct ctl_table *table, int write, -+ void __user *buffer, size_t *lenp, loff_t *ppos) -+{ -+ return do_proc_dointvec(table, write, buffer, lenp, ppos, -+ do_proc_douintvec_conv, NULL); - } - - /* -@@ -2792,6 +2826,12 @@ int proc_dointvec(struct ctl_table *table, int write, - return -ENOSYS; - } - -+int proc_douintvec(struct ctl_table *table, int write, -+ void __user *buffer, size_t *lenp, loff_t *ppos) -+{ -+ return -ENOSYS; -+} -+ - int proc_dointvec_minmax(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) - { -@@ -2837,6 +2877,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, - * exception granted :-) - */ - EXPORT_SYMBOL(proc_dointvec); -+EXPORT_SYMBOL(proc_douintvec); - EXPORT_SYMBOL(proc_dointvec_jiffies); - EXPORT_SYMBOL(proc_dointvec_minmax); - EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); -diff --git a/mm/ksm.c b/mm/ksm.c -index b5cd647daa52..2f028e6d0831 100644 ---- a/mm/ksm.c -+++ b/mm/ksm.c -@@ -283,7 +283,8 @@ static inline struct rmap_item *alloc_rmap_item(void) - { - struct rmap_item *rmap_item; - -- rmap_item = kmem_cache_zalloc(rmap_item_cache, GFP_KERNEL); -+ rmap_item = kmem_cache_zalloc(rmap_item_cache, GFP_KERNEL | -+ __GFP_NORETRY | __GFP_NOWARN); - if (rmap_item) - ksm_rmap_items++; - return rmap_item; -diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c -index 17851d3aaf22..6282f021ddfb 100644 ---- a/net/batman-adv/originator.c -+++ b/net/batman-adv/originator.c -@@ -197,18 +197,12 @@ static void batadv_neigh_node_release(struct batadv_neigh_node *neigh_node) - { - struct hlist_node *node_tmp; - struct batadv_neigh_ifinfo *neigh_ifinfo; -- struct batadv_algo_ops *bao; -- -- bao = neigh_node->orig_node->bat_priv->bat_algo_ops; - - hlist_for_each_entry_safe(neigh_ifinfo, node_tmp, - &neigh_node->ifinfo_list, list) { - batadv_neigh_ifinfo_free_ref(neigh_ifinfo); - } - -- if (bao->bat_neigh_free) -- bao->bat_neigh_free(neigh_node); -- - batadv_hardif_free_ref(neigh_node->if_incoming); - - kfree_rcu(neigh_node, rcu); -diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h -index d260efd70499..cbd347c2e4a5 100644 ---- a/net/batman-adv/types.h -+++ b/net/batman-adv/types.h -@@ -1136,8 +1136,6 @@ struct batadv_forw_packet { - * @bat_neigh_is_equiv_or_better: check if neigh1 is equally good or better - * than neigh2 for their respective outgoing interface from the metric - * prospective -- * @bat_neigh_free: free the resources allocated by the routing algorithm for a -- * neigh_node object - * @bat_orig_print: print the originator table (optional) - * @bat_orig_free: free the resources allocated by the routing algorithm for an - * orig_node object -@@ -1165,7 +1163,6 @@ struct batadv_algo_ops { - struct batadv_hard_iface *if_outgoing1, - struct batadv_neigh_node *neigh2, - struct batadv_hard_iface *if_outgoing2); -- void (*bat_neigh_free)(struct batadv_neigh_node *neigh); - /* orig_node handling API */ - void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq, - struct batadv_hard_iface *hard_iface); -diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c -index 803001a45aa1..1b07578bedf3 100644 ---- a/net/netfilter/ipvs/ip_vs_sync.c -+++ b/net/netfilter/ipvs/ip_vs_sync.c -@@ -1545,7 +1545,8 @@ error: - /* - * Set up receiving multicast socket over UDP - */ --static struct socket *make_receive_sock(struct netns_ipvs *ipvs, int id) -+static struct socket *make_receive_sock(struct netns_ipvs *ipvs, int id, -+ int ifindex) - { - /* multicast addr */ - union ipvs_sockaddr mcast_addr; -@@ -1566,6 +1567,7 @@ static struct socket *make_receive_sock(struct netns_ipvs *ipvs, int id) - set_sock_size(sock->sk, 0, result); - - get_mcast_sockaddr(&mcast_addr, &salen, &ipvs->bcfg, id); -+ sock->sk->sk_bound_dev_if = ifindex; - result = sock->ops->bind(sock, (struct sockaddr *)&mcast_addr, salen); - if (result < 0) { - pr_err("Error binding to the multicast addr\n"); -@@ -1868,7 +1870,7 @@ int start_sync_thread(struct netns_ipvs *ipvs, struct ipvs_sync_daemon_cfg *c, - if (state == IP_VS_STATE_MASTER) - sock = make_send_sock(ipvs, id); - else -- sock = make_receive_sock(ipvs, id); -+ sock = make_receive_sock(ipvs, id, dev->ifindex); - if (IS_ERR(sock)) { - result = PTR_ERR(sock); - goto outtinfo; -diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c -index cc9852897395..c5b0cb4f4056 100644 ---- a/net/sunrpc/svc.c -+++ b/net/sunrpc/svc.c -@@ -1188,11 +1188,17 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) - *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp); - - /* Encode reply */ -- if (test_bit(RQ_DROPME, &rqstp->rq_flags)) { -+ if (*statp == rpc_drop_reply || -+ test_bit(RQ_DROPME, &rqstp->rq_flags)) { - if (procp->pc_release) - procp->pc_release(rqstp, NULL, rqstp->rq_resp); - goto dropit; - } -+ if (*statp == rpc_autherr_badcred) { -+ if (procp->pc_release) -+ procp->pc_release(rqstp, NULL, rqstp->rq_resp); -+ goto err_bad_auth; -+ } - if (*statp == rpc_success && - (xdr = procp->pc_encode) && - !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) { -diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c -index 600af5878e75..36cd715986bc 100644 ---- a/sound/pci/hda/patch_conexant.c -+++ b/sound/pci/hda/patch_conexant.c -@@ -261,6 +261,7 @@ enum { - CXT_FIXUP_HP_530, - CXT_FIXUP_CAP_MIX_AMP_5047, - CXT_FIXUP_MUTE_LED_EAPD, -+ CXT_FIXUP_HP_SPECTRE, - }; - - /* for hda_fixup_thinkpad_acpi() */ -@@ -765,6 +766,14 @@ static const struct hda_fixup cxt_fixups[] = { - .type = HDA_FIXUP_FUNC, - .v.func = cxt_fixup_mute_led_eapd, - }, -+ [CXT_FIXUP_HP_SPECTRE] = { -+ .type = HDA_FIXUP_PINS, -+ .v.pins = (const struct hda_pintbl[]) { -+ /* enable NID 0x1d for the speaker on top */ -+ { 0x1d, 0x91170111 }, -+ { } -+ } -+ }, - }; - - static const struct snd_pci_quirk cxt5045_fixups[] = { -@@ -814,6 +823,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { - SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), - SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC), - SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC), -+ SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE), - SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), - SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO), - SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index eaee626ab185..b1fa50aed888 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -5790,6 +5790,13 @@ static const struct hda_model_fixup alc269_fixup_models[] = { - {0x14, 0x90170110}, \ - {0x15, 0x0221401f} - -+#define ALC295_STANDARD_PINS \ -+ {0x12, 0xb7a60130}, \ -+ {0x14, 0x90170110}, \ -+ {0x17, 0x21014020}, \ -+ {0x18, 0x21a19030}, \ -+ {0x21, 0x04211020} -+ - #define ALC298_STANDARD_PINS \ - {0x12, 0x90a60130}, \ - {0x21, 0x03211020} -@@ -5830,6 +5837,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - {0x14, 0x90170120}, - {0x21, 0x02211030}), - SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, -+ {0x14, 0x90170110}, -+ {0x1b, 0x02011020}, -+ {0x21, 0x0221101f}), -+ SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - {0x14, 0x90170130}, - {0x1b, 0x01014020}, - {0x21, 0x0221103f}), -@@ -5895,6 +5906,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - {0x14, 0x90170120}, - {0x21, 0x02211030}), - SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, -+ {0x12, 0xb7a60130}, -+ {0x14, 0x90170110}, -+ {0x21, 0x02211020}), -+ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC256_STANDARD_PINS), - SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, - {0x12, 0x90a60130}, -@@ -6005,6 +6020,8 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { - SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC292_STANDARD_PINS, - {0x13, 0x90a60140}), -+ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, -+ ALC295_STANDARD_PINS), - SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC298_STANDARD_PINS, - {0x17, 0x90170110}), -diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c -index caa69c4598a6..b4844f78266f 100644 ---- a/sound/soc/intel/skylake/skl.c -+++ b/sound/soc/intel/skylake/skl.c -@@ -464,8 +464,10 @@ static int skl_probe(struct pci_dev *pci, - - skl->nhlt = skl_nhlt_init(bus->dev); - -- if (skl->nhlt == NULL) -+ if (skl->nhlt == NULL) { -+ err = -ENODEV; - goto out_free; -+ } - - pci_set_drvdata(skl->pci, ebus); - -diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c -index b837265ac3e9..8d0d45d330e7 100644 ---- a/sound/soc/omap/omap-mcpdm.c -+++ b/sound/soc/omap/omap-mcpdm.c -@@ -390,8 +390,8 @@ static int omap_mcpdm_probe(struct snd_soc_dai *dai) - pm_runtime_get_sync(mcpdm->dev); - omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); - -- ret = devm_request_irq(mcpdm->dev, mcpdm->irq, omap_mcpdm_irq_handler, -- 0, "McPDM", (void *)mcpdm); -+ ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", -+ (void *)mcpdm); - - pm_runtime_put_sync(mcpdm->dev); - -@@ -416,6 +416,7 @@ static int omap_mcpdm_remove(struct snd_soc_dai *dai) - { - struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); - -+ free_irq(mcpdm->irq, (void *)mcpdm); - pm_runtime_disable(mcpdm->dev); - - return 0; -diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c -index 86e698d07e20..499b8819d4c6 100644 ---- a/tools/vm/slabinfo.c -+++ b/tools/vm/slabinfo.c -@@ -510,10 +510,11 @@ static void slab_stats(struct slabinfo *s) - s->alloc_node_mismatch, (s->alloc_node_mismatch * 100) / total); - } - -- if (s->cmpxchg_double_fail || s->cmpxchg_double_cpu_fail) -+ if (s->cmpxchg_double_fail || s->cmpxchg_double_cpu_fail) { - printf("\nCmpxchg_double Looping\n------------------------\n"); - printf("Locked Cmpxchg Double redos %lu\nUnlocked Cmpxchg Double redos %lu\n", - s->cmpxchg_double_fail, s->cmpxchg_double_cpu_fail); -+ } - } - - static void report(struct slabinfo *s) diff --git a/patch/kernel/marvell-dev/patch-4.4.24-25.patch b/patch/kernel/marvell-dev/patch-4.4.24-25.patch deleted file mode 100644 index 106495e9e1..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.24-25.patch +++ /dev/null @@ -1,1130 +0,0 @@ -diff --git a/Makefile b/Makefile -index cdbc185c3539..578a82554923 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 24 -+SUBLEVEL = 25 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi -index a4c1762b53ea..e00d50ef678f 100644 ---- a/arch/arm/boot/dts/qcom-apq8064.dtsi -+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - #include - / { - model = "Qualcomm APQ8064"; -@@ -354,22 +355,50 @@ - - compatible = "qcom,pm8921-gpio"; - reg = <0x150>; -- interrupts = <192 1>, <193 1>, <194 1>, -- <195 1>, <196 1>, <197 1>, -- <198 1>, <199 1>, <200 1>, -- <201 1>, <202 1>, <203 1>, -- <204 1>, <205 1>, <206 1>, -- <207 1>, <208 1>, <209 1>, -- <210 1>, <211 1>, <212 1>, -- <213 1>, <214 1>, <215 1>, -- <216 1>, <217 1>, <218 1>, -- <219 1>, <220 1>, <221 1>, -- <222 1>, <223 1>, <224 1>, -- <225 1>, <226 1>, <227 1>, -- <228 1>, <229 1>, <230 1>, -- <231 1>, <232 1>, <233 1>, -- <234 1>, <235 1>; -- -+ interrupts = <192 IRQ_TYPE_NONE>, -+ <193 IRQ_TYPE_NONE>, -+ <194 IRQ_TYPE_NONE>, -+ <195 IRQ_TYPE_NONE>, -+ <196 IRQ_TYPE_NONE>, -+ <197 IRQ_TYPE_NONE>, -+ <198 IRQ_TYPE_NONE>, -+ <199 IRQ_TYPE_NONE>, -+ <200 IRQ_TYPE_NONE>, -+ <201 IRQ_TYPE_NONE>, -+ <202 IRQ_TYPE_NONE>, -+ <203 IRQ_TYPE_NONE>, -+ <204 IRQ_TYPE_NONE>, -+ <205 IRQ_TYPE_NONE>, -+ <206 IRQ_TYPE_NONE>, -+ <207 IRQ_TYPE_NONE>, -+ <208 IRQ_TYPE_NONE>, -+ <209 IRQ_TYPE_NONE>, -+ <210 IRQ_TYPE_NONE>, -+ <211 IRQ_TYPE_NONE>, -+ <212 IRQ_TYPE_NONE>, -+ <213 IRQ_TYPE_NONE>, -+ <214 IRQ_TYPE_NONE>, -+ <215 IRQ_TYPE_NONE>, -+ <216 IRQ_TYPE_NONE>, -+ <217 IRQ_TYPE_NONE>, -+ <218 IRQ_TYPE_NONE>, -+ <219 IRQ_TYPE_NONE>, -+ <220 IRQ_TYPE_NONE>, -+ <221 IRQ_TYPE_NONE>, -+ <222 IRQ_TYPE_NONE>, -+ <223 IRQ_TYPE_NONE>, -+ <224 IRQ_TYPE_NONE>, -+ <225 IRQ_TYPE_NONE>, -+ <226 IRQ_TYPE_NONE>, -+ <227 IRQ_TYPE_NONE>, -+ <228 IRQ_TYPE_NONE>, -+ <229 IRQ_TYPE_NONE>, -+ <230 IRQ_TYPE_NONE>, -+ <231 IRQ_TYPE_NONE>, -+ <232 IRQ_TYPE_NONE>, -+ <233 IRQ_TYPE_NONE>, -+ <234 IRQ_TYPE_NONE>, -+ <235 IRQ_TYPE_NONE>; - gpio-controller; - #gpio-cells = <2>; - -@@ -381,9 +410,18 @@ - gpio-controller; - #gpio-cells = <2>; - interrupts = -- <128 1>, <129 1>, <130 1>, <131 1>, -- <132 1>, <133 1>, <134 1>, <135 1>, -- <136 1>, <137 1>, <138 1>, <139 1>; -+ <128 IRQ_TYPE_NONE>, -+ <129 IRQ_TYPE_NONE>, -+ <130 IRQ_TYPE_NONE>, -+ <131 IRQ_TYPE_NONE>, -+ <132 IRQ_TYPE_NONE>, -+ <133 IRQ_TYPE_NONE>, -+ <134 IRQ_TYPE_NONE>, -+ <135 IRQ_TYPE_NONE>, -+ <136 IRQ_TYPE_NONE>, -+ <137 IRQ_TYPE_NONE>, -+ <138 IRQ_TYPE_NONE>, -+ <139 IRQ_TYPE_NONE>; - }; - - rtc@11d { -diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c -index d6476d11212e..3251b206e55a 100644 ---- a/arch/mips/kvm/emulate.c -+++ b/arch/mips/kvm/emulate.c -@@ -807,6 +807,47 @@ enum emulation_result kvm_mips_emul_tlbr(struct kvm_vcpu *vcpu) - return EMULATE_FAIL; - } - -+/** -+ * kvm_mips_invalidate_guest_tlb() - Indicates a change in guest MMU map. -+ * @vcpu: VCPU with changed mappings. -+ * @tlb: TLB entry being removed. -+ * -+ * This is called to indicate a single change in guest MMU mappings, so that we -+ * can arrange TLB flushes on this and other CPUs. -+ */ -+static void kvm_mips_invalidate_guest_tlb(struct kvm_vcpu *vcpu, -+ struct kvm_mips_tlb *tlb) -+{ -+ int cpu, i; -+ bool user; -+ -+ /* No need to flush for entries which are already invalid */ -+ if (!((tlb->tlb_lo[0] | tlb->tlb_lo[1]) & ENTRYLO_V)) -+ return; -+ /* User address space doesn't need flushing for KSeg2/3 changes */ -+ user = tlb->tlb_hi < KVM_GUEST_KSEG0; -+ -+ preempt_disable(); -+ -+ /* -+ * Probe the shadow host TLB for the entry being overwritten, if one -+ * matches, invalidate it -+ */ -+ kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); -+ -+ /* Invalidate the whole ASID on other CPUs */ -+ cpu = smp_processor_id(); -+ for_each_possible_cpu(i) { -+ if (i == cpu) -+ continue; -+ if (user) -+ vcpu->arch.guest_user_asid[i] = 0; -+ vcpu->arch.guest_kernel_asid[i] = 0; -+ } -+ -+ preempt_enable(); -+} -+ - /* Write Guest TLB Entry @ Index */ - enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu) - { -@@ -826,11 +867,8 @@ enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu) - } - - tlb = &vcpu->arch.guest_tlb[index]; -- /* -- * Probe the shadow host TLB for the entry being overwritten, if one -- * matches, invalidate it -- */ -- kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); -+ -+ kvm_mips_invalidate_guest_tlb(vcpu, tlb); - - tlb->tlb_mask = kvm_read_c0_guest_pagemask(cop0); - tlb->tlb_hi = kvm_read_c0_guest_entryhi(cop0); -@@ -859,11 +897,7 @@ enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu) - - tlb = &vcpu->arch.guest_tlb[index]; - -- /* -- * Probe the shadow host TLB for the entry being overwritten, if one -- * matches, invalidate it -- */ -- kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi); -+ kvm_mips_invalidate_guest_tlb(vcpu, tlb); - - tlb->tlb_mask = kvm_read_c0_guest_pagemask(cop0); - tlb->tlb_hi = kvm_read_c0_guest_entryhi(cop0); -@@ -982,6 +1016,7 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, - int32_t rt, rd, copz, sel, co_bit, op; - uint32_t pc = vcpu->arch.pc; - unsigned long curr_pc; -+ int cpu, i; - - /* - * Update PC and hold onto current PC in case there is -@@ -1089,8 +1124,16 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, - vcpu->arch.gprs[rt] - & ASID_MASK); - -+ preempt_disable(); - /* Blow away the shadow host TLBs */ - kvm_mips_flush_host_tlb(1); -+ cpu = smp_processor_id(); -+ for_each_possible_cpu(i) -+ if (i != cpu) { -+ vcpu->arch.guest_user_asid[i] = 0; -+ vcpu->arch.guest_kernel_asid[i] = 0; -+ } -+ preempt_enable(); - } - kvm_write_c0_guest_entryhi(cop0, - vcpu->arch.gprs[rt]); -diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h -index 070fa8552051..627d129d7fcb 100644 ---- a/arch/powerpc/include/asm/reg.h -+++ b/arch/powerpc/include/asm/reg.h -@@ -708,6 +708,7 @@ - #define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */ - #define SPRN_MMCR1 798 - #define SPRN_MMCR2 785 -+#define SPRN_UMMCR2 769 - #define SPRN_MMCRA 0x312 - #define MMCRA_SDSYNC 0x80000000UL /* SDAR synced with SIAR */ - #define MMCRA_SDAR_DCACHE_MISS 0x40000000UL -diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c -index 2afdb9c0937d..729f8faa95c5 100644 ---- a/arch/powerpc/kvm/book3s_emulate.c -+++ b/arch/powerpc/kvm/book3s_emulate.c -@@ -498,6 +498,7 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) - case SPRN_MMCR0: - case SPRN_MMCR1: - case SPRN_MMCR2: -+ case SPRN_UMMCR2: - #endif - break; - unprivileged: -@@ -640,6 +641,7 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val - case SPRN_MMCR0: - case SPRN_MMCR1: - case SPRN_MMCR2: -+ case SPRN_UMMCR2: - case SPRN_TIR: - #endif - *spr_val = 0; -diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c -index fd5875179e5c..6d63cd67b09b 100644 ---- a/arch/powerpc/kvm/booke.c -+++ b/arch/powerpc/kvm/booke.c -@@ -2033,7 +2033,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, - if (type == KVMPPC_DEBUG_NONE) - continue; - -- if (type & !(KVMPPC_DEBUG_WATCH_READ | -+ if (type & ~(KVMPPC_DEBUG_WATCH_READ | - KVMPPC_DEBUG_WATCH_WRITE | - KVMPPC_DEBUG_BREAKPOINT)) - return -EINVAL; -diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c -index df6b4eeac0bd..0988e204f1e3 100644 ---- a/arch/x86/kernel/apic/vector.c -+++ b/arch/x86/kernel/apic/vector.c -@@ -659,11 +659,28 @@ void irq_complete_move(struct irq_cfg *cfg) - */ - void irq_force_complete_move(struct irq_desc *desc) - { -- struct irq_data *irqdata = irq_desc_get_irq_data(desc); -- struct apic_chip_data *data = apic_chip_data(irqdata); -- struct irq_cfg *cfg = data ? &data->cfg : NULL; -+ struct irq_data *irqdata; -+ struct apic_chip_data *data; -+ struct irq_cfg *cfg; - unsigned int cpu; - -+ /* -+ * The function is called for all descriptors regardless of which -+ * irqdomain they belong to. For example if an IRQ is provided by -+ * an irq_chip as part of a GPIO driver, the chip data for that -+ * descriptor is specific to the irq_chip in question. -+ * -+ * Check first that the chip_data is what we expect -+ * (apic_chip_data) before touching it any further. -+ */ -+ irqdata = irq_domain_get_irq_data(x86_vector_domain, -+ irq_desc_get_irq(desc)); -+ if (!irqdata) -+ return; -+ -+ data = apic_chip_data(irqdata); -+ cfg = data ? &data->cfg : NULL; -+ - if (!cfg) - return; - -diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c -index 569c1e4f96fe..38b3ead7222d 100644 ---- a/arch/x86/kernel/e820.c -+++ b/arch/x86/kernel/e820.c -@@ -347,7 +347,7 @@ int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, - * continue building up new bios map based on this - * information - */ -- if (current_type != last_type || current_type == E820_PRAM) { -+ if (current_type != last_type) { - if (last_type != 0) { - new_bios[new_bios_entry].size = - change_point[chgidx]->addr - last_addr; -@@ -753,7 +753,7 @@ u64 __init early_reserve_e820(u64 size, u64 align) - /* - * Find the highest page frame number we have available - */ --static unsigned long __init e820_end_pfn(unsigned long limit_pfn) -+static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) - { - int i; - unsigned long last_pfn = 0; -@@ -764,11 +764,7 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn) - unsigned long start_pfn; - unsigned long end_pfn; - -- /* -- * Persistent memory is accounted as ram for purposes of -- * establishing max_pfn and mem_map. -- */ -- if (ei->type != E820_RAM && ei->type != E820_PRAM) -+ if (ei->type != type) - continue; - - start_pfn = ei->addr >> PAGE_SHIFT; -@@ -793,12 +789,12 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn) - } - unsigned long __init e820_end_of_ram_pfn(void) - { -- return e820_end_pfn(MAX_ARCH_PFN); -+ return e820_end_pfn(MAX_ARCH_PFN, E820_RAM); - } - - unsigned long __init e820_end_of_low_ram_pfn(void) - { -- return e820_end_pfn(1UL << (32-PAGE_SHIFT)); -+ return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_RAM); - } - - static void early_panic(char *msg) -diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c -index 558f50edebca..479a409ddac8 100644 ---- a/arch/x86/kernel/ptrace.c -+++ b/arch/x86/kernel/ptrace.c -@@ -188,8 +188,8 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs) - return sp; - - prev_esp = (u32 *)(context); -- if (prev_esp) -- return (unsigned long)prev_esp; -+ if (*prev_esp) -+ return (unsigned long)*prev_esp; - - return (unsigned long)regs; - } -diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c -index de0337ebd658..4f3137d9a35e 100644 ---- a/drivers/char/tpm/tpm-dev.c -+++ b/drivers/char/tpm/tpm-dev.c -@@ -139,7 +139,7 @@ static ssize_t tpm_write(struct file *file, const char __user *buf, - - /* atomic tpm command send and result receive */ - out_size = tpm_transmit(priv->chip, priv->data_buffer, -- sizeof(priv->data_buffer)); -+ sizeof(priv->data_buffer), 0); - if (out_size < 0) { - mutex_unlock(&priv->buffer_mutex); - return out_size; -diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c -index c50637db3a8a..17abe52e6365 100644 ---- a/drivers/char/tpm/tpm-interface.c -+++ b/drivers/char/tpm/tpm-interface.c -@@ -328,8 +328,8 @@ EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); - /* - * Internal kernel interface to transmit TPM commands - */ --ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, -- size_t bufsiz) -+ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, -+ unsigned int flags) - { - ssize_t rc; - u32 count, ordinal; -@@ -348,7 +348,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, - return -E2BIG; - } - -- mutex_lock(&chip->tpm_mutex); -+ if (!(flags & TPM_TRANSMIT_UNLOCKED)) -+ mutex_lock(&chip->tpm_mutex); - - rc = chip->ops->send(chip, (u8 *) buf, count); - if (rc < 0) { -@@ -391,20 +392,21 @@ out_recv: - dev_err(chip->pdev, - "tpm_transmit: tpm_recv: error %zd\n", rc); - out: -- mutex_unlock(&chip->tpm_mutex); -+ if (!(flags & TPM_TRANSMIT_UNLOCKED)) -+ mutex_unlock(&chip->tpm_mutex); - return rc; - } - - #define TPM_DIGEST_SIZE 20 - #define TPM_RET_CODE_IDX 6 - --ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, -- int len, const char *desc) -+ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd, -+ int len, unsigned int flags, const char *desc) - { -- struct tpm_output_header *header; -+ const struct tpm_output_header *header; - int err; - -- len = tpm_transmit(chip, (u8 *) cmd, len); -+ len = tpm_transmit(chip, (const u8 *)cmd, len, flags); - if (len < 0) - return len; - else if (len < TPM_HEADER_SIZE) -@@ -452,7 +454,8 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, cap_t *cap, - tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); - tpm_cmd.params.getcap_in.subcap = subcap_id; - } -- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, desc); -+ rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, -+ desc); - if (!rc) - *cap = tpm_cmd.params.getcap_out.cap; - return rc; -@@ -468,7 +471,7 @@ void tpm_gen_interrupt(struct tpm_chip *chip) - tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); - tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; - -- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, - "attempting to determine the timeouts"); - } - EXPORT_SYMBOL_GPL(tpm_gen_interrupt); -@@ -489,7 +492,7 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) - start_cmd.header.in = tpm_startup_header; - - start_cmd.params.startup_in.startup_type = startup_type; -- return tpm_transmit_cmd(chip, &start_cmd, TPM_INTERNAL_RESULT_SIZE, -+ return tpm_transmit_cmd(chip, &start_cmd, TPM_INTERNAL_RESULT_SIZE, 0, - "attempting to start the TPM"); - } - -@@ -505,7 +508,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) - tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; - tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); - tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; -- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, NULL); -+ rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, -+ NULL); - - if (rc == TPM_ERR_INVALID_POSTINIT) { - /* The TPM is not started, we are the first to talk to it. -@@ -519,7 +523,7 @@ int tpm_get_timeouts(struct tpm_chip *chip) - tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); - tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; - rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, -- NULL); -+ 0, NULL); - } - if (rc) { - dev_err(chip->pdev, -@@ -580,7 +584,7 @@ duration: - tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); - tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION; - -- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0, - "attempting to determine the durations"); - if (rc) - return rc; -@@ -636,7 +640,7 @@ static int tpm_continue_selftest(struct tpm_chip *chip) - struct tpm_cmd_t cmd; - - cmd.header.in = continue_selftest_header; -- rc = tpm_transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, 0, - "continue selftest"); - return rc; - } -@@ -656,7 +660,7 @@ int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) - - cmd.header.in = pcrread_header; - cmd.params.pcrread_in.pcr_idx = cpu_to_be32(pcr_idx); -- rc = tpm_transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, 0, - "attempting to read a pcr value"); - - if (rc == 0) -@@ -754,7 +758,7 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) - cmd.header.in = pcrextend_header; - cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(pcr_idx); - memcpy(cmd.params.pcrextend_in.hash, hash, TPM_DIGEST_SIZE); -- rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, 0, - "attempting extend a PCR value"); - - tpm_chip_put(chip); -@@ -793,7 +797,7 @@ int tpm_do_selftest(struct tpm_chip *chip) - /* Attempt to read a PCR value */ - cmd.header.in = pcrread_header; - cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0); -- rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE); -+ rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE, 0); - /* Some buggy TPMs will not respond to tpm_tis_ready() for - * around 300ms while the self test is ongoing, keep trying - * until the self test duration expires. */ -@@ -834,7 +838,7 @@ int tpm_send(u32 chip_num, void *cmd, size_t buflen) - if (chip == NULL) - return -ENODEV; - -- rc = tpm_transmit_cmd(chip, cmd, buflen, "attempting tpm_cmd"); -+ rc = tpm_transmit_cmd(chip, cmd, buflen, 0, "attempting tpm_cmd"); - - tpm_chip_put(chip); - return rc; -@@ -936,14 +940,15 @@ int tpm_pm_suspend(struct device *dev) - cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(tpm_suspend_pcr); - memcpy(cmd.params.pcrextend_in.hash, dummy_hash, - TPM_DIGEST_SIZE); -- rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, -+ rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, 0, - "extending dummy pcr before suspend"); - } - - /* now do the actual savestate */ - for (try = 0; try < TPM_RETRY; try++) { - cmd.header.in = savestate_header; -- rc = tpm_transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL); -+ rc = tpm_transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, 0, -+ NULL); - - /* - * If the TPM indicates that it is too busy to respond to -@@ -1027,8 +1032,8 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max) - tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes); - - err = tpm_transmit_cmd(chip, &tpm_cmd, -- TPM_GETRANDOM_RESULT_SIZE + num_bytes, -- "attempting get random"); -+ TPM_GETRANDOM_RESULT_SIZE + num_bytes, -+ 0, "attempting get random"); - if (err) - break; - -diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c -index ee66fd4673f3..f880856aa75e 100644 ---- a/drivers/char/tpm/tpm-sysfs.c -+++ b/drivers/char/tpm/tpm-sysfs.c -@@ -39,7 +39,7 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, - struct tpm_chip *chip = dev_get_drvdata(dev); - - tpm_cmd.header.in = tpm_readpubek_header; -- err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, -+ err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, 0, - "attempting to read the PUBEK"); - if (err) - goto out; -diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h -index a4257a32964f..2216861f89f1 100644 ---- a/drivers/char/tpm/tpm.h -+++ b/drivers/char/tpm/tpm.h -@@ -498,11 +498,15 @@ extern struct class *tpm_class; - extern dev_t tpm_devt; - extern const struct file_operations tpm_fops; - -+enum tpm_transmit_flags { -+ TPM_TRANSMIT_UNLOCKED = BIT(0), -+}; -+ -+ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, -+ unsigned int flags); -+ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd, int len, -+ unsigned int flags, const char *desc); - ssize_t tpm_getcap(struct device *, __be32, cap_t *, const char *); --ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, -- size_t bufsiz); --ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len, -- const char *desc); - extern int tpm_get_timeouts(struct tpm_chip *); - extern void tpm_gen_interrupt(struct tpm_chip *); - extern int tpm_do_selftest(struct tpm_chip *); -diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c -index 678af51fb29e..cb7e4f6b70ba 100644 ---- a/drivers/char/tpm/tpm2-cmd.c -+++ b/drivers/char/tpm/tpm2-cmd.c -@@ -264,7 +264,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) - sizeof(cmd.params.pcrread_in.pcr_select)); - cmd.params.pcrread_in.pcr_select[pcr_idx >> 3] = 1 << (pcr_idx & 0x7); - -- rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), -+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, - "attempting to read a pcr value"); - if (rc == 0) { - buf = cmd.params.pcrread_out.digest; -@@ -312,7 +312,7 @@ int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash) - cmd.params.pcrextend_in.hash_alg = cpu_to_be16(TPM2_ALG_SHA1); - memcpy(cmd.params.pcrextend_in.digest, hash, TPM_DIGEST_SIZE); - -- rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), -+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, - "attempting extend a PCR value"); - - return rc; -@@ -358,7 +358,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max) - cmd.header.in = tpm2_getrandom_header; - cmd.params.getrandom_in.size = cpu_to_be16(num_bytes); - -- err = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), -+ err = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, - "attempting get random"); - if (err) - break; -@@ -416,12 +416,12 @@ static void tpm2_buf_append_auth(struct tpm_buf *buf, u32 session_handle, - } - - /** -- * tpm2_seal_trusted() - seal a trusted key -- * @chip_num: A specific chip number for the request or TPM_ANY_NUM -- * @options: authentication values and other options -+ * tpm2_seal_trusted() - seal the payload of a trusted key -+ * @chip_num: TPM chip to use - * @payload: the key data in clear and encrypted form -+ * @options: authentication values and other options - * -- * Returns < 0 on error and 0 on success. -+ * Return: < 0 on error and 0 on success. - */ - int tpm2_seal_trusted(struct tpm_chip *chip, - struct trusted_key_payload *payload, -@@ -472,7 +472,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip, - goto out; - } - -- rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "sealing data"); -+ rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, "sealing data"); - if (rc) - goto out; - -@@ -494,10 +494,18 @@ out: - return rc; - } - --static int tpm2_load(struct tpm_chip *chip, -- struct trusted_key_payload *payload, -- struct trusted_key_options *options, -- u32 *blob_handle) -+/** -+ * tpm2_load_cmd() - execute a TPM2_Load command -+ * @chip_num: TPM chip to use -+ * @payload: the key data in clear and encrypted form -+ * @options: authentication values and other options -+ * -+ * Return: same as with tpm_transmit_cmd -+ */ -+static int tpm2_load_cmd(struct tpm_chip *chip, -+ struct trusted_key_payload *payload, -+ struct trusted_key_options *options, -+ u32 *blob_handle, unsigned int flags) - { - struct tpm_buf buf; - unsigned int private_len; -@@ -532,7 +540,7 @@ static int tpm2_load(struct tpm_chip *chip, - goto out; - } - -- rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "loading blob"); -+ rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, "loading blob"); - if (!rc) - *blob_handle = be32_to_cpup( - (__be32 *) &buf.data[TPM_HEADER_SIZE]); -@@ -546,7 +554,16 @@ out: - return rc; - } - --static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) -+/** -+ * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command -+ * @chip_num: TPM chip to use -+ * @payload: the key data in clear and encrypted form -+ * @options: authentication values and other options -+ * -+ * Return: same as with tpm_transmit_cmd -+ */ -+static void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle, -+ unsigned int flags) - { - struct tpm_buf buf; - int rc; -@@ -560,7 +577,8 @@ static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) - - tpm_buf_append_u32(&buf, handle); - -- rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "flushing context"); -+ rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, -+ "flushing context"); - if (rc) - dev_warn(chip->pdev, "0x%08x was not flushed, rc=%d\n", handle, - rc); -@@ -568,10 +586,18 @@ static void tpm2_flush_context(struct tpm_chip *chip, u32 handle) - tpm_buf_destroy(&buf); - } - --static int tpm2_unseal(struct tpm_chip *chip, -- struct trusted_key_payload *payload, -- struct trusted_key_options *options, -- u32 blob_handle) -+/** -+ * tpm2_unseal_cmd() - execute a TPM2_Unload command -+ * @chip_num: TPM chip to use -+ * @payload: the key data in clear and encrypted form -+ * @options: authentication values and other options -+ * -+ * Return: same as with tpm_transmit_cmd -+ */ -+static int tpm2_unseal_cmd(struct tpm_chip *chip, -+ struct trusted_key_payload *payload, -+ struct trusted_key_options *options, -+ u32 blob_handle, unsigned int flags) - { - struct tpm_buf buf; - u16 data_len; -@@ -589,7 +615,7 @@ static int tpm2_unseal(struct tpm_chip *chip, - options->blobauth /* hmac */, - TPM_DIGEST_SIZE); - -- rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "unsealing"); -+ rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, "unsealing"); - if (rc > 0) - rc = -EPERM; - -@@ -608,12 +634,12 @@ static int tpm2_unseal(struct tpm_chip *chip, - } - - /** -- * tpm_unseal_trusted() - unseal a trusted key -- * @chip_num: A specific chip number for the request or TPM_ANY_NUM -- * @options: authentication values and other options -+ * tpm_unseal_trusted() - unseal the payload of a trusted key -+ * @chip_num: TPM chip to use - * @payload: the key data in clear and encrypted form -+ * @options: authentication values and other options - * -- * Returns < 0 on error and 0 on success. -+ * Return: < 0 on error and 0 on success. - */ - int tpm2_unseal_trusted(struct tpm_chip *chip, - struct trusted_key_payload *payload, -@@ -622,14 +648,17 @@ int tpm2_unseal_trusted(struct tpm_chip *chip, - u32 blob_handle; - int rc; - -- rc = tpm2_load(chip, payload, options, &blob_handle); -+ mutex_lock(&chip->tpm_mutex); -+ rc = tpm2_load_cmd(chip, payload, options, &blob_handle, -+ TPM_TRANSMIT_UNLOCKED); - if (rc) -- return rc; -- -- rc = tpm2_unseal(chip, payload, options, blob_handle); -- -- tpm2_flush_context(chip, blob_handle); -+ goto out; - -+ rc = tpm2_unseal_cmd(chip, payload, options, blob_handle, -+ TPM_TRANSMIT_UNLOCKED); -+ tpm2_flush_context_cmd(chip, blob_handle, TPM_TRANSMIT_UNLOCKED); -+out: -+ mutex_unlock(&chip->tpm_mutex); - return rc; - } - -@@ -655,7 +684,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, - cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(property_id); - cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); - -- rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), desc); -+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, desc); - if (!rc) - *value = be32_to_cpu(cmd.params.get_tpm_pt_out.value); - -@@ -689,7 +718,7 @@ int tpm2_startup(struct tpm_chip *chip, u16 startup_type) - cmd.header.in = tpm2_startup_header; - - cmd.params.startup_in.startup_type = cpu_to_be16(startup_type); -- return tpm_transmit_cmd(chip, &cmd, sizeof(cmd), -+ return tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, - "attempting to start the TPM"); - } - EXPORT_SYMBOL_GPL(tpm2_startup); -@@ -718,7 +747,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type) - cmd.header.in = tpm2_shutdown_header; - cmd.params.startup_in.startup_type = cpu_to_be16(shutdown_type); - -- rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), "stopping the TPM"); -+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, "stopping the TPM"); - - /* In places where shutdown command is sent there's no much we can do - * except print the error code on a system failure. -@@ -784,7 +813,7 @@ static int tpm2_start_selftest(struct tpm_chip *chip, bool full) - cmd.header.in = tpm2_selftest_header; - cmd.params.selftest_in.full_test = full; - -- rc = tpm_transmit_cmd(chip, &cmd, TPM2_SELF_TEST_IN_SIZE, -+ rc = tpm_transmit_cmd(chip, &cmd, TPM2_SELF_TEST_IN_SIZE, 0, - "continue selftest"); - - /* At least some prototype chips seem to give RC_TESTING error -@@ -836,7 +865,7 @@ int tpm2_do_selftest(struct tpm_chip *chip) - cmd.params.pcrread_in.pcr_select[1] = 0x00; - cmd.params.pcrread_in.pcr_select[2] = 0x00; - -- rc = tpm_transmit_cmd(chip, (u8 *) &cmd, sizeof(cmd), NULL); -+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), 0, NULL); - if (rc < 0) - break; - -@@ -885,7 +914,7 @@ int tpm2_probe(struct tpm_chip *chip) - cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100); - cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); - -- rc = tpm_transmit(chip, (const char *) &cmd, sizeof(cmd)); -+ rc = tpm_transmit(chip, (const u8 *)&cmd, sizeof(cmd), 0); - if (rc < 0) - return rc; - else if (rc < TPM_HEADER_SIZE) -diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c -index 61e64293b765..2b21398c3adc 100644 ---- a/drivers/char/tpm/tpm_crb.c -+++ b/drivers/char/tpm/tpm_crb.c -@@ -149,6 +149,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) - struct crb_priv *priv = chip->vendor.priv; - int rc = 0; - -+ /* Zero the cancel register so that the next command will not get -+ * canceled. -+ */ -+ iowrite32(0, &priv->cca->cancel); -+ - if (len > le32_to_cpu(ioread32(&priv->cca->cmd_size))) { - dev_err(&chip->dev, - "invalid command count value %x %zx\n", -@@ -182,8 +187,6 @@ static void crb_cancel(struct tpm_chip *chip) - - if ((priv->flags & CRB_FL_ACPI_START) && crb_do_acpi_start(chip)) - dev_err(&chip->dev, "ACPI Start failed\n"); -- -- iowrite32(0, &priv->cca->cancel); - } - - static bool crb_req_canceled(struct tpm_chip *chip, u8 status) -diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c -index e342565e8715..1855b9ee807f 100644 ---- a/drivers/cpuidle/cpuidle-arm.c -+++ b/drivers/cpuidle/cpuidle-arm.c -@@ -135,6 +135,7 @@ static int __init arm_idle_init(void) - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - pr_err("Failed to allocate cpuidle device\n"); -+ ret = -ENOMEM; - goto out_fail; - } - dev->cpu = cpu; -diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig -index 4d92df6ef9fe..7398262a2fab 100644 ---- a/drivers/mfd/Kconfig -+++ b/drivers/mfd/Kconfig -@@ -1460,6 +1460,7 @@ config MFD_WM8350 - config MFD_WM8350_I2C - bool "Wolfson Microelectronics WM8350 with I2C" - select MFD_WM8350 -+ select REGMAP_I2C - depends on I2C=y - help - The WM8350 is an integrated audio and power management -diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c -index 06c205868573..c216c3a55793 100644 ---- a/drivers/mfd/atmel-hlcdc.c -+++ b/drivers/mfd/atmel-hlcdc.c -@@ -50,8 +50,9 @@ static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg, - if (reg <= ATMEL_HLCDC_DIS) { - u32 status; - -- readl_poll_timeout(hregmap->regs + ATMEL_HLCDC_SR, status, -- !(status & ATMEL_HLCDC_SIP), 1, 100); -+ readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR, -+ status, !(status & ATMEL_HLCDC_SIP), -+ 1, 100); - } - - writel(val, hregmap->regs + reg); -diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c -index dbd907d7170e..691dab791f7a 100644 ---- a/drivers/mfd/rtsx_usb.c -+++ b/drivers/mfd/rtsx_usb.c -@@ -46,9 +46,6 @@ static void rtsx_usb_sg_timed_out(unsigned long data) - - dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__); - usb_sg_cancel(&ucr->current_sg); -- -- /* we know the cancellation is caused by time-out */ -- ucr->current_sg.status = -ETIMEDOUT; - } - - static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, -@@ -67,12 +64,15 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, - ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout); - add_timer(&ucr->sg_timer); - usb_sg_wait(&ucr->current_sg); -- del_timer_sync(&ucr->sg_timer); -+ if (!del_timer_sync(&ucr->sg_timer)) -+ ret = -ETIMEDOUT; -+ else -+ ret = ucr->current_sg.status; - - if (act_len) - *act_len = ucr->current_sg.bytes; - -- return ucr->current_sg.status; -+ return ret; - } - - int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe, -diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h -index d409ceb2231e..c118a7ec94d6 100644 ---- a/include/linux/mfd/88pm80x.h -+++ b/include/linux/mfd/88pm80x.h -@@ -350,7 +350,7 @@ static inline int pm80x_dev_suspend(struct device *dev) - int irq = platform_get_irq(pdev, 0); - - if (device_may_wakeup(dev)) -- set_bit((1 << irq), &chip->wu_flag); -+ set_bit(irq, &chip->wu_flag); - - return 0; - } -@@ -362,7 +362,7 @@ static inline int pm80x_dev_resume(struct device *dev) - int irq = platform_get_irq(pdev, 0); - - if (device_may_wakeup(dev)) -- clear_bit((1 << irq), &chip->wu_flag); -+ clear_bit(irq, &chip->wu_flag); - - return 0; - } -diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c -index 4ff237dbc006..445601c580d6 100644 ---- a/kernel/time/timekeeping.c -+++ b/kernel/time/timekeeping.c -@@ -298,17 +298,34 @@ u32 (*arch_gettimeoffset)(void) = default_arch_gettimeoffset; - static inline u32 arch_gettimeoffset(void) { return 0; } - #endif - -+static inline s64 timekeeping_delta_to_ns(struct tk_read_base *tkr, -+ cycle_t delta) -+{ -+ s64 nsec; -+ -+ nsec = delta * tkr->mult + tkr->xtime_nsec; -+ nsec >>= tkr->shift; -+ -+ /* If arch requires, add in get_arch_timeoffset() */ -+ return nsec + arch_gettimeoffset(); -+} -+ - static inline s64 timekeeping_get_ns(struct tk_read_base *tkr) - { - cycle_t delta; -- s64 nsec; - - delta = timekeeping_get_delta(tkr); -+ return timekeeping_delta_to_ns(tkr, delta); -+} - -- nsec = (delta * tkr->mult + tkr->xtime_nsec) >> tkr->shift; -+static inline s64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, -+ cycle_t cycles) -+{ -+ cycle_t delta; - -- /* If arch requires, add in get_arch_timeoffset() */ -- return nsec + arch_gettimeoffset(); -+ /* calculate the delta since the last update_wall_time */ -+ delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); -+ return timekeeping_delta_to_ns(tkr, delta); - } - - /** -@@ -385,8 +402,11 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) - tkr = tkf->base + (seq & 0x01); - now = ktime_to_ns(tkr->base); - -- now += clocksource_delta(tkr->read(tkr->clock), -- tkr->cycle_last, tkr->mask); -+ now += timekeeping_delta_to_ns(tkr, -+ clocksource_delta( -+ tkr->read(tkr->clock), -+ tkr->cycle_last, -+ tkr->mask)); - } while (read_seqcount_retry(&tkf->seq, seq)); - - return now; -diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c -index 1d950fbb2aec..2d1fe34781fa 100644 ---- a/security/integrity/ima/ima_api.c -+++ b/security/integrity/ima/ima_api.c -@@ -202,7 +202,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, - } hash; - - if (xattr_value) -- *xattr_len = ima_read_xattr(file->f_path.dentry, xattr_value); -+ *xattr_len = ima_read_xattr(file_dentry(file), xattr_value); - - if (!(iint->flags & IMA_COLLECTED)) { - u64 i_version = file_inode(file)->i_version; -diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c -index 1873b5536f80..ed5a9c110b3a 100644 ---- a/security/integrity/ima/ima_appraise.c -+++ b/security/integrity/ima/ima_appraise.c -@@ -189,7 +189,7 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, - { - static const char op[] = "appraise_data"; - char *cause = "unknown"; -- struct dentry *dentry = file->f_path.dentry; -+ struct dentry *dentry = file_dentry(file); - struct inode *inode = d_backing_inode(dentry); - enum integrity_status status = INTEGRITY_UNKNOWN; - int rc = xattr_len, hash_start = 0; -@@ -289,7 +289,7 @@ out: - */ - void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) - { -- struct dentry *dentry = file->f_path.dentry; -+ struct dentry *dentry = file_dentry(file); - int rc = 0; - - /* do not collect and update hash for digital signatures */ -diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c -index 36470af7eda7..92b819e4f729 100644 ---- a/sound/pci/ali5451/ali5451.c -+++ b/sound/pci/ali5451/ali5451.c -@@ -1408,6 +1408,7 @@ snd_ali_playback_pointer(struct snd_pcm_substream *substream) - spin_unlock(&codec->reg_lock); - dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso); - -+ cso %= runtime->buffer_size; - return cso; - } - -@@ -1428,6 +1429,7 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream) - cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); - spin_unlock(&codec->reg_lock); - -+ cso %= runtime->buffer_size; - return cso; - } - -diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c -index 81b7da8e56d3..183311cb849e 100644 ---- a/sound/usb/line6/driver.c -+++ b/sound/usb/line6/driver.c -@@ -29,7 +29,7 @@ - /* - This is Line 6's MIDI manufacturer ID. - */ --const unsigned char line6_midi_id[] = { -+const unsigned char line6_midi_id[3] = { - 0x00, 0x01, 0x0c - }; - EXPORT_SYMBOL_GPL(line6_midi_id); -diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c -index f6c3bf79af9a..04991b009132 100644 ---- a/sound/usb/mixer_quirks.c -+++ b/sound/usb/mixer_quirks.c -@@ -1831,6 +1831,7 @@ void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer, - } - - static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer, -+ struct usb_mixer_elem_info *cval, - struct snd_kcontrol *kctl) - { - /* Approximation using 10 ranges based on output measurement on hw v1.2. -@@ -1848,10 +1849,19 @@ static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer, - 41, 50, TLV_DB_MINMAX_ITEM(-441, 0), - ); - -- usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk\n"); -- kctl->tlv.p = scale; -- kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; -- kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; -+ if (cval->min == 0 && cval->max == 50) { -+ usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk (0-50 variant)\n"); -+ kctl->tlv.p = scale; -+ kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; -+ kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; -+ -+ } else if (cval->min == 0 && cval->max <= 1000) { -+ /* Some other clearly broken DragonFly variant. -+ * At least a 0..53 variant (hw v1.0) exists. -+ */ -+ usb_audio_info(mixer->chip, "ignoring too narrow dB range on a DragonFly device"); -+ kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; -+ } - } - - void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, -@@ -1860,8 +1870,8 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, - { - switch (mixer->chip->usb_id) { - case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ -- if (unitid == 7 && cval->min == 0 && cval->max == 50) -- snd_dragonfly_quirk_db_scale(mixer, kctl); -+ if (unitid == 7 && cval->control == UAC_FU_VOLUME) -+ snd_dragonfly_quirk_db_scale(mixer, cval, kctl); - break; - } - } diff --git a/patch/kernel/marvell-dev/patch-4.4.25-26.patch b/patch/kernel/marvell-dev/patch-4.4.25-26.patch deleted file mode 100644 index f09375b063..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.25-26.patch +++ /dev/null @@ -1,153 +0,0 @@ -diff --git a/Makefile b/Makefile -index 578a82554923..a127b9ef9ebc 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 25 -+SUBLEVEL = 26 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile -index 0a291cdfaf77..efa6073ffa7e 100644 ---- a/arch/x86/boot/compressed/Makefile -+++ b/arch/x86/boot/compressed/Makefile -@@ -22,7 +22,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ - vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 - - KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 --KBUILD_CFLAGS += -fno-strict-aliasing -fPIC -+KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC) - KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING - cflags-$(CONFIG_X86_32) := -march=i386 - cflags-$(CONFIG_X86_64) := -mcmodel=small -@@ -35,6 +35,18 @@ KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ - GCOV_PROFILE := n - - LDFLAGS := -m elf_$(UTS_MACHINE) -+ifeq ($(CONFIG_RELOCATABLE),y) -+# If kernel is relocatable, build compressed kernel as PIE. -+ifeq ($(CONFIG_X86_32),y) -+LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker) -+else -+# To build 64-bit compressed kernel as PIE, we disable relocation -+# overflow check to avoid relocation overflow error with a new linker -+# command-line option, -z noreloc-overflow. -+LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ -+ && echo "-z noreloc-overflow -pie --no-dynamic-linker") -+endif -+endif - LDFLAGS_vmlinux := -T - - hostprogs-y := mkpiggy -diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S -index 8ef964ddc18e..0256064da8da 100644 ---- a/arch/x86/boot/compressed/head_32.S -+++ b/arch/x86/boot/compressed/head_32.S -@@ -31,6 +31,34 @@ - #include - #include - -+/* -+ * The 32-bit x86 assembler in binutils 2.26 will generate R_386_GOT32X -+ * relocation to get the symbol address in PIC. When the compressed x86 -+ * kernel isn't built as PIC, the linker optimizes R_386_GOT32X -+ * relocations to their fixed symbol addresses. However, when the -+ * compressed x86 kernel is loaded at a different address, it leads -+ * to the following load failure: -+ * -+ * Failed to allocate space for phdrs -+ * -+ * during the decompression stage. -+ * -+ * If the compressed x86 kernel is relocatable at run-time, it should be -+ * compiled with -fPIE, instead of -fPIC, if possible and should be built as -+ * Position Independent Executable (PIE) so that linker won't optimize -+ * R_386_GOT32X relocation to its fixed symbol address. Older -+ * linkers generate R_386_32 relocations against locally defined symbols, -+ * _bss, _ebss, _got and _egot, in PIE. It isn't wrong, just less -+ * optimal than R_386_RELATIVE. But the x86 kernel fails to properly handle -+ * R_386_32 relocations when relocating the kernel. To generate -+ * R_386_RELATIVE relocations, we mark _bss, _ebss, _got and _egot as -+ * hidden: -+ */ -+ .hidden _bss -+ .hidden _ebss -+ .hidden _got -+ .hidden _egot -+ - __HEAD - ENTRY(startup_32) - #ifdef CONFIG_EFI_STUB -diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S -index b0c0d16ef58d..86558a199139 100644 ---- a/arch/x86/boot/compressed/head_64.S -+++ b/arch/x86/boot/compressed/head_64.S -@@ -33,6 +33,14 @@ - #include - #include - -+/* -+ * Locally defined symbols should be marked hidden: -+ */ -+ .hidden _bss -+ .hidden _ebss -+ .hidden _got -+ .hidden _egot -+ - __HEAD - .code32 - ENTRY(startup_32) -diff --git a/include/linux/mm.h b/include/linux/mm.h -index cfebb742ee18..f0ffa01c90d9 100644 ---- a/include/linux/mm.h -+++ b/include/linux/mm.h -@@ -2112,6 +2112,7 @@ static inline struct page *follow_page(struct vm_area_struct *vma, - #define FOLL_MIGRATION 0x400 /* wait for page to replace migration entry */ - #define FOLL_TRIED 0x800 /* a retry, previous pass started an IO */ - #define FOLL_MLOCK 0x1000 /* lock present pages */ -+#define FOLL_COW 0x4000 /* internal GUP flag */ - - typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr, - void *data); -diff --git a/mm/gup.c b/mm/gup.c -index deafa2c91b36..4b0b7e7d1136 100644 ---- a/mm/gup.c -+++ b/mm/gup.c -@@ -58,6 +58,16 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, - return -EEXIST; - } - -+/* -+ * FOLL_FORCE can write to even unwritable pte's, but only -+ * after we've gone through a COW cycle and they are dirty. -+ */ -+static inline bool can_follow_write_pte(pte_t pte, unsigned int flags) -+{ -+ return pte_write(pte) || -+ ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte)); -+} -+ - static struct page *follow_page_pte(struct vm_area_struct *vma, - unsigned long address, pmd_t *pmd, unsigned int flags) - { -@@ -92,7 +102,7 @@ retry: - } - if ((flags & FOLL_NUMA) && pte_protnone(pte)) - goto no_page; -- if ((flags & FOLL_WRITE) && !pte_write(pte)) { -+ if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) { - pte_unmap_unlock(ptep, ptl); - return NULL; - } -@@ -352,7 +362,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, - * reCOWed by userspace write). - */ - if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE)) -- *flags &= ~FOLL_WRITE; -+ *flags |= FOLL_COW; - return 0; - } - diff --git a/patch/kernel/marvell-dev/patch-4.4.26-27.patch b/patch/kernel/marvell-dev/patch-4.4.26-27.patch deleted file mode 100644 index 3789594335..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.26-27.patch +++ /dev/null @@ -1,995 +0,0 @@ -diff --git a/Makefile b/Makefile -index a127b9ef9ebc..b6ee4ce561f8 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 26 -+SUBLEVEL = 27 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c -index 1f9093e901da..3ad307ee6029 100644 ---- a/block/cfq-iosched.c -+++ b/block/cfq-iosched.c -@@ -3003,7 +3003,6 @@ static struct request *cfq_check_fifo(struct cfq_queue *cfqq) - if (time_before(jiffies, rq->fifo_time)) - rq = NULL; - -- cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); - return rq; - } - -@@ -3377,6 +3376,9 @@ static bool cfq_may_dispatch(struct cfq_data *cfqd, struct cfq_queue *cfqq) - { - unsigned int max_dispatch; - -+ if (cfq_cfqq_must_dispatch(cfqq)) -+ return true; -+ - /* - * Drain async requests before we start sync IO - */ -@@ -3468,15 +3470,20 @@ static bool cfq_dispatch_request(struct cfq_data *cfqd, struct cfq_queue *cfqq) - - BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list)); - -+ rq = cfq_check_fifo(cfqq); -+ if (rq) -+ cfq_mark_cfqq_must_dispatch(cfqq); -+ - if (!cfq_may_dispatch(cfqd, cfqq)) - return false; - - /* - * follow expired path, else get first next available - */ -- rq = cfq_check_fifo(cfqq); - if (!rq) - rq = cfqq->next_rq; -+ else -+ cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); - - /* - * insert request into driver dispatch list -@@ -3944,7 +3951,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq, - * if the new request is sync, but the currently running queue is - * not, let the sync request have priority. - */ -- if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq)) -+ if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq) && !cfq_cfqq_must_dispatch(cfqq)) - return true; - - if (new_cfqq->cfqg != cfqq->cfqg) -diff --git a/crypto/async_tx/async_pq.c b/crypto/async_tx/async_pq.c -index c0748bbd4c08..84f8d4d8b6bc 100644 ---- a/crypto/async_tx/async_pq.c -+++ b/crypto/async_tx/async_pq.c -@@ -368,8 +368,6 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks, - - dma_set_unmap(tx, unmap); - async_tx_submit(chan, tx, submit); -- -- return tx; - } else { - struct page *p_src = P(blocks, disks); - struct page *q_src = Q(blocks, disks); -@@ -424,9 +422,11 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks, - submit->cb_param = cb_param_orig; - submit->flags = flags_orig; - async_tx_sync_epilog(submit); -- -- return NULL; -+ tx = NULL; - } -+ dmaengine_unmap_put(unmap); -+ -+ return tx; - } - EXPORT_SYMBOL_GPL(async_syndrome_val); - -diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c -index bac70995e064..12ad3e3a84e3 100644 ---- a/crypto/ghash-generic.c -+++ b/crypto/ghash-generic.c -@@ -14,24 +14,13 @@ - - #include - #include -+#include - #include - #include - #include - #include - #include - --#define GHASH_BLOCK_SIZE 16 --#define GHASH_DIGEST_SIZE 16 -- --struct ghash_ctx { -- struct gf128mul_4k *gf128; --}; -- --struct ghash_desc_ctx { -- u8 buffer[GHASH_BLOCK_SIZE]; -- u32 bytes; --}; -- - static int ghash_init(struct shash_desc *desc) - { - struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); -diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c -index d95c5971c225..a00f7b79202b 100644 ---- a/drivers/base/dma-mapping.c -+++ b/drivers/base/dma-mapping.c -@@ -335,7 +335,7 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags) - return; - } - -- unmap_kernel_range((unsigned long)cpu_addr, size); -+ unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size)); - vunmap(cpu_addr); - } - #endif -diff --git a/drivers/crypto/vmx/ghash.c b/drivers/crypto/vmx/ghash.c -index 2183a2e77641..9cb3a0b715e2 100644 ---- a/drivers/crypto/vmx/ghash.c -+++ b/drivers/crypto/vmx/ghash.c -@@ -26,16 +26,13 @@ - #include - #include - #include -+#include - #include - #include - #include - - #define IN_INTERRUPT in_interrupt() - --#define GHASH_BLOCK_SIZE (16) --#define GHASH_DIGEST_SIZE (16) --#define GHASH_KEY_LEN (16) -- - void gcm_init_p8(u128 htable[16], const u64 Xi[2]); - void gcm_gmult_p8(u64 Xi[2], const u128 htable[16]); - void gcm_ghash_p8(u64 Xi[2], const u128 htable[16], -@@ -55,16 +52,11 @@ struct p8_ghash_desc_ctx { - - static int p8_ghash_init_tfm(struct crypto_tfm *tfm) - { -- const char *alg; -+ const char *alg = "ghash-generic"; - struct crypto_shash *fallback; - struct crypto_shash *shash_tfm = __crypto_shash_cast(tfm); - struct p8_ghash_ctx *ctx = crypto_tfm_ctx(tfm); - -- if (!(alg = crypto_tfm_alg_name(tfm))) { -- printk(KERN_ERR "Failed to get algorithm name.\n"); -- return -ENOENT; -- } -- - fallback = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK); - if (IS_ERR(fallback)) { - printk(KERN_ERR -@@ -78,10 +70,18 @@ static int p8_ghash_init_tfm(struct crypto_tfm *tfm) - crypto_shash_set_flags(fallback, - crypto_shash_get_flags((struct crypto_shash - *) tfm)); -- ctx->fallback = fallback; - -- shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx) -- + crypto_shash_descsize(fallback); -+ /* Check if the descsize defined in the algorithm is still enough. */ -+ if (shash_tfm->descsize < sizeof(struct p8_ghash_desc_ctx) -+ + crypto_shash_descsize(fallback)) { -+ printk(KERN_ERR -+ "Desc size of the fallback implementation (%s) does not match the expected value: %lu vs %u\n", -+ alg, -+ shash_tfm->descsize - sizeof(struct p8_ghash_desc_ctx), -+ crypto_shash_descsize(fallback)); -+ return -EINVAL; -+ } -+ ctx->fallback = fallback; - - return 0; - } -@@ -113,7 +113,7 @@ static int p8_ghash_setkey(struct crypto_shash *tfm, const u8 *key, - { - struct p8_ghash_ctx *ctx = crypto_tfm_ctx(crypto_shash_tfm(tfm)); - -- if (keylen != GHASH_KEY_LEN) -+ if (keylen != GHASH_BLOCK_SIZE) - return -EINVAL; - - preempt_disable(); -@@ -215,7 +215,8 @@ struct shash_alg p8_ghash_alg = { - .update = p8_ghash_update, - .final = p8_ghash_final, - .setkey = p8_ghash_setkey, -- .descsize = sizeof(struct p8_ghash_desc_ctx), -+ .descsize = sizeof(struct p8_ghash_desc_ctx) -+ + sizeof(struct ghash_desc_ctx), - .base = { - .cra_name = "ghash", - .cra_driver_name = "p8_ghash", -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index 2215bebe208e..979cc024bca7 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c -@@ -10853,6 +10853,12 @@ static pci_ers_result_t i40e_pci_error_detected(struct pci_dev *pdev, - - dev_info(&pdev->dev, "%s: error %d\n", __func__, error); - -+ if (!pf) { -+ dev_info(&pdev->dev, -+ "Cannot recover - error happened during device probe\n"); -+ return PCI_ERS_RESULT_DISCONNECT; -+ } -+ - /* shutdown all operations */ - if (!test_bit(__I40E_SUSPENDED, &pf->state)) { - rtnl_lock(); -diff --git a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c -index deb5f78dcacc..71493d2af912 100644 ---- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c -+++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c -@@ -2408,7 +2408,7 @@ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si) - WL_BSS_INFO_MAX); - if (err) { - brcmf_err("Failed to get bss info (%d)\n", err); -- return; -+ goto out_kfree; - } - si->filled |= BIT(NL80211_STA_INFO_BSS_PARAM); - si->bss_param.beacon_interval = le16_to_cpu(buf->bss_le.beacon_period); -@@ -2420,6 +2420,9 @@ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si) - si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; - if (capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) - si->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; -+ -+out_kfree: -+ kfree(buf); - } - - static s32 -diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c -index 41f9a00e4f74..8db9f3a5844d 100644 ---- a/drivers/scsi/arcmsr/arcmsr_hba.c -+++ b/drivers/scsi/arcmsr/arcmsr_hba.c -@@ -2297,15 +2297,23 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, - } - case ARCMSR_MESSAGE_WRITE_WQBUFFER: { - unsigned char *ver_addr; -- int32_t user_len, cnt2end; -+ uint32_t user_len; -+ int32_t cnt2end; - uint8_t *pQbuffer, *ptmpuserbuffer; -+ -+ user_len = pcmdmessagefld->cmdmessage.Length; -+ if (user_len > ARCMSR_API_DATA_BUFLEN) { -+ retvalue = ARCMSR_MESSAGE_FAIL; -+ goto message_out; -+ } -+ - ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC); - if (!ver_addr) { - retvalue = ARCMSR_MESSAGE_FAIL; - goto message_out; - } - ptmpuserbuffer = ver_addr; -- user_len = pcmdmessagefld->cmdmessage.Length; -+ - memcpy(ptmpuserbuffer, - pcmdmessagefld->messagedatabuffer, user_len); - spin_lock_irqsave(&acb->wqbuffer_lock, flags); -diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c -index 6aa317c303e2..1f9f9e5af207 100644 ---- a/drivers/scsi/ibmvscsi/ibmvfc.c -+++ b/drivers/scsi/ibmvscsi/ibmvfc.c -@@ -717,7 +717,6 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) - spin_lock_irqsave(vhost->host->host_lock, flags); - vhost->state = IBMVFC_NO_CRQ; - vhost->logged_in = 0; -- ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_NONE); - - /* Clean out the queue */ - memset(crq->msgs, 0, PAGE_SIZE); -diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c -index a5d319e4aae6..8435c3f204c1 100644 ---- a/drivers/tty/serial/8250/8250_dw.c -+++ b/drivers/tty/serial/8250/8250_dw.c -@@ -440,7 +440,7 @@ static int dw8250_probe(struct platform_device *pdev) - } - - data->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); -- if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER) { -+ if (IS_ERR(data->pclk) && PTR_ERR(data->pclk) == -EPROBE_DEFER) { - err = -EPROBE_DEFER; - goto err_clk; - } -diff --git a/fs/attr.c b/fs/attr.c -index 6530ced19697..d62f674a605f 100644 ---- a/fs/attr.c -+++ b/fs/attr.c -@@ -202,6 +202,21 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de - return -EPERM; - } - -+ /* -+ * If utimes(2) and friends are called with times == NULL (or both -+ * times are UTIME_NOW), then we need to check for write permission -+ */ -+ if (ia_valid & ATTR_TOUCH) { -+ if (IS_IMMUTABLE(inode)) -+ return -EPERM; -+ -+ if (!inode_owner_or_capable(inode)) { -+ error = inode_permission(inode, MAY_WRITE); -+ if (error) -+ return error; -+ } -+ } -+ - if ((ia_valid & ATTR_MODE)) { - umode_t amode = attr->ia_mode; - /* Flag setting protected by i_mutex */ -diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c -index c473c42d7d6c..bae05c5c75ba 100644 ---- a/fs/btrfs/compression.c -+++ b/fs/btrfs/compression.c -@@ -694,7 +694,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, - ret = btrfs_map_bio(root, READ, comp_bio, - mirror_num, 0); - if (ret) { -- bio->bi_error = ret; -+ comp_bio->bi_error = ret; - bio_endio(comp_bio); - } - -@@ -723,7 +723,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, - - ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); - if (ret) { -- bio->bi_error = ret; -+ comp_bio->bi_error = ret; - bio_endio(comp_bio); - } - -diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c -index 3a37bd3f9637..9d7a4a714907 100644 ---- a/fs/dlm/lowcomms.c -+++ b/fs/dlm/lowcomms.c -@@ -1607,16 +1607,12 @@ void dlm_lowcomms_stop(void) - mutex_lock(&connections_lock); - dlm_allow_conn = 0; - foreach_conn(stop_conn); -+ clean_writequeues(); -+ foreach_conn(free_conn); - mutex_unlock(&connections_lock); - - work_stop(); - -- mutex_lock(&connections_lock); -- clean_writequeues(); -- -- foreach_conn(free_conn); -- -- mutex_unlock(&connections_lock); - kmem_cache_destroy(con_cache); - } - -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 8eac7d586997..9da42ace762a 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -5738,6 +5738,9 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) - up_write(&EXT4_I(inode)->i_data_sem); - goto out_stop; - } -+ } else { -+ ext4_ext_drop_refs(path); -+ kfree(path); - } - - ret = ext4_es_remove_extent(inode, offset_lblk, -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 28702932a908..c71d2941a45b 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -3645,7 +3645,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset, - } - - /* -- * ext4_punch_hole: punches a hole in a file by releaseing the blocks -+ * ext4_punch_hole: punches a hole in a file by releasing the blocks - * associated with the given offset and length - * - * @inode: File inode -@@ -3674,7 +3674,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) - * Write out all dirty pages to avoid race conditions - * Then release them. - */ -- if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { -+ if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { - ret = filemap_write_and_wait_range(mapping, offset, - offset + length - 1); - if (ret) -@@ -4549,14 +4549,14 @@ static int ext4_do_update_inode(handle_t *handle, - * Fix up interoperability with old kernels. Otherwise, old inodes get - * re-used with the upper 16 bits of the uid/gid intact - */ -- if (!ei->i_dtime) { -+ if (ei->i_dtime && list_empty(&ei->i_orphan)) { -+ raw_inode->i_uid_high = 0; -+ raw_inode->i_gid_high = 0; -+ } else { - raw_inode->i_uid_high = - cpu_to_le16(high_16_bits(i_uid)); - raw_inode->i_gid_high = - cpu_to_le16(high_16_bits(i_gid)); -- } else { -- raw_inode->i_uid_high = 0; -- raw_inode->i_gid_high = 0; - } - } else { - raw_inode->i_uid_low = cpu_to_le16(fs_high2lowuid(i_uid)); -diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c -index 796ff0eafd3c..7861d801b048 100644 ---- a/fs/ext4/move_extent.c -+++ b/fs/ext4/move_extent.c -@@ -598,6 +598,13 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk, - return -EOPNOTSUPP; - } - -+ if (ext4_encrypted_inode(orig_inode) || -+ ext4_encrypted_inode(donor_inode)) { -+ ext4_msg(orig_inode->i_sb, KERN_ERR, -+ "Online defrag not supported for encrypted files"); -+ return -EOPNOTSUPP; -+ } -+ - /* Protect orig and donor inodes against a truncate */ - lock_two_nondirectories(orig_inode, donor_inode); - -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index 38eb0c8e43b9..573b4cbb0cb9 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -2017,33 +2017,31 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname, - frame->entries = entries; - frame->at = entries; - frame->bh = bh; -- bh = bh2; - - retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh); - if (retval) - goto out_frames; -- retval = ext4_handle_dirty_dirent_node(handle, dir, bh); -+ retval = ext4_handle_dirty_dirent_node(handle, dir, bh2); - if (retval) - goto out_frames; - -- de = do_split(handle,dir, &bh, frame, &fname->hinfo); -+ de = do_split(handle,dir, &bh2, frame, &fname->hinfo); - if (IS_ERR(de)) { - retval = PTR_ERR(de); - goto out_frames; - } -- dx_release(frames); - -- retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh); -- brelse(bh); -- return retval; -+ retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2); - out_frames: - /* - * Even if the block split failed, we have to properly write - * out all the changes we did so far. Otherwise we can end up - * with corrupted filesystem. - */ -- ext4_mark_inode_dirty(handle, dir); -+ if (retval) -+ ext4_mark_inode_dirty(handle, dir); - dx_release(frames); -+ brelse(bh2); - return retval; - } - -diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c -index 5e2e08712d3b..4b5f2c4e69c8 100644 ---- a/fs/fuse/dir.c -+++ b/fs/fuse/dir.c -@@ -1697,14 +1697,46 @@ error: - static int fuse_setattr(struct dentry *entry, struct iattr *attr) - { - struct inode *inode = d_inode(entry); -+ struct file *file = (attr->ia_valid & ATTR_FILE) ? attr->ia_file : NULL; -+ int ret; - - if (!fuse_allow_current_process(get_fuse_conn(inode))) - return -EACCES; - -- if (attr->ia_valid & ATTR_FILE) -- return fuse_do_setattr(inode, attr, attr->ia_file); -- else -- return fuse_do_setattr(inode, attr, NULL); -+ if (attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) { -+ int kill; -+ -+ attr->ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | -+ ATTR_MODE); -+ /* -+ * ia_mode calculation may have used stale i_mode. Refresh and -+ * recalculate. -+ */ -+ ret = fuse_do_getattr(inode, NULL, file); -+ if (ret) -+ return ret; -+ -+ attr->ia_mode = inode->i_mode; -+ kill = should_remove_suid(entry); -+ if (kill & ATTR_KILL_SUID) { -+ attr->ia_valid |= ATTR_MODE; -+ attr->ia_mode &= ~S_ISUID; -+ } -+ if (kill & ATTR_KILL_SGID) { -+ attr->ia_valid |= ATTR_MODE; -+ attr->ia_mode &= ~S_ISGID; -+ } -+ } -+ if (!attr->ia_valid) -+ return 0; -+ -+ ret = fuse_do_setattr(inode, attr, file); -+ if (!ret) { -+ /* Directory mode changed, may need to revalidate access */ -+ if (d_is_dir(entry) && (attr->ia_valid & ATTR_MODE)) -+ fuse_invalidate_entry_cache(entry); -+ } -+ return ret; - } - - static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry, -@@ -1797,6 +1829,23 @@ static ssize_t fuse_getxattr(struct dentry *entry, const char *name, - return ret; - } - -+static int fuse_verify_xattr_list(char *list, size_t size) -+{ -+ size_t origsize = size; -+ -+ while (size) { -+ size_t thislen = strnlen(list, size); -+ -+ if (!thislen || thislen == size) -+ return -EIO; -+ -+ size -= thislen + 1; -+ list += thislen + 1; -+ } -+ -+ return origsize; -+} -+ - static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) - { - struct inode *inode = d_inode(entry); -@@ -1832,6 +1881,8 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) - ret = fuse_simple_request(fc, &args); - if (!ret && !size) - ret = outarg.size; -+ if (ret > 0 && size) -+ ret = fuse_verify_xattr_list(list, ret); - if (ret == -ENOSYS) { - fc->no_listxattr = 1; - ret = -EOPNOTSUPP; -diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c -index 96a1bcf33db4..8f5ccdf81c25 100644 ---- a/fs/reiserfs/file.c -+++ b/fs/reiserfs/file.c -@@ -260,10 +260,10 @@ const struct file_operations reiserfs_file_operations = { - - const struct inode_operations reiserfs_file_inode_operations = { - .setattr = reiserfs_setattr, -- .setxattr = reiserfs_setxattr, -- .getxattr = reiserfs_getxattr, -+ .setxattr = generic_setxattr, -+ .getxattr = generic_getxattr, - .listxattr = reiserfs_listxattr, -- .removexattr = reiserfs_removexattr, -+ .removexattr = generic_removexattr, - .permission = reiserfs_permission, - .get_acl = reiserfs_get_acl, - .set_acl = reiserfs_set_acl, -diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c -index 47f96988fdd4..3ebc70167e41 100644 ---- a/fs/reiserfs/namei.c -+++ b/fs/reiserfs/namei.c -@@ -1649,10 +1649,10 @@ const struct inode_operations reiserfs_dir_inode_operations = { - .mknod = reiserfs_mknod, - .rename = reiserfs_rename, - .setattr = reiserfs_setattr, -- .setxattr = reiserfs_setxattr, -- .getxattr = reiserfs_getxattr, -+ .setxattr = generic_setxattr, -+ .getxattr = generic_getxattr, - .listxattr = reiserfs_listxattr, -- .removexattr = reiserfs_removexattr, -+ .removexattr = generic_removexattr, - .permission = reiserfs_permission, - .get_acl = reiserfs_get_acl, - .set_acl = reiserfs_set_acl, -@@ -1667,10 +1667,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = { - .follow_link = page_follow_link_light, - .put_link = page_put_link, - .setattr = reiserfs_setattr, -- .setxattr = reiserfs_setxattr, -- .getxattr = reiserfs_getxattr, -+ .setxattr = generic_setxattr, -+ .getxattr = generic_getxattr, - .listxattr = reiserfs_listxattr, -- .removexattr = reiserfs_removexattr, -+ .removexattr = generic_removexattr, - .permission = reiserfs_permission, - }; - -@@ -1679,10 +1679,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = { - */ - const struct inode_operations reiserfs_special_inode_operations = { - .setattr = reiserfs_setattr, -- .setxattr = reiserfs_setxattr, -- .getxattr = reiserfs_getxattr, -+ .setxattr = generic_setxattr, -+ .getxattr = generic_getxattr, - .listxattr = reiserfs_listxattr, -- .removexattr = reiserfs_removexattr, -+ .removexattr = generic_removexattr, - .permission = reiserfs_permission, - .get_acl = reiserfs_get_acl, - .set_acl = reiserfs_set_acl, -diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c -index 4a62fe8cc3bf..f9f3be50081a 100644 ---- a/fs/reiserfs/super.c -+++ b/fs/reiserfs/super.c -@@ -190,7 +190,15 @@ static int remove_save_link_only(struct super_block *s, - static int reiserfs_quota_on_mount(struct super_block *, int); - #endif - --/* look for uncompleted unlinks and truncates and complete them */ -+/* -+ * Look for uncompleted unlinks and truncates and complete them -+ * -+ * Called with superblock write locked. If quotas are enabled, we have to -+ * release/retake lest we call dquot_quota_on_mount(), proceed to -+ * schedule_on_each_cpu() in invalidate_bdev() and deadlock waiting for the per -+ * cpu worklets to complete flush_async_commits() that in turn wait for the -+ * superblock write lock. -+ */ - static int finish_unfinished(struct super_block *s) - { - INITIALIZE_PATH(path); -@@ -237,7 +245,9 @@ static int finish_unfinished(struct super_block *s) - quota_enabled[i] = 0; - continue; - } -+ reiserfs_write_unlock(s); - ret = reiserfs_quota_on_mount(s, i); -+ reiserfs_write_lock(s); - if (ret < 0) - reiserfs_warning(s, "reiserfs-2500", - "cannot turn on journaled " -diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c -index 66b26fdfff8d..a8dbc93e45eb 100644 ---- a/fs/reiserfs/xattr.c -+++ b/fs/reiserfs/xattr.c -@@ -763,60 +763,6 @@ find_xattr_handler_prefix(const struct xattr_handler **handlers, - return xah; - } - -- --/* -- * Inode operation getxattr() -- */ --ssize_t --reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, -- size_t size) --{ -- const struct xattr_handler *handler; -- -- handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); -- -- if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) -- return -EOPNOTSUPP; -- -- return handler->get(handler, dentry, name, buffer, size); --} -- --/* -- * Inode operation setxattr() -- * -- * d_inode(dentry)->i_mutex down -- */ --int --reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, -- size_t size, int flags) --{ -- const struct xattr_handler *handler; -- -- handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); -- -- if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) -- return -EOPNOTSUPP; -- -- return handler->set(handler, dentry, name, value, size, flags); --} -- --/* -- * Inode operation removexattr() -- * -- * d_inode(dentry)->i_mutex down -- */ --int reiserfs_removexattr(struct dentry *dentry, const char *name) --{ -- const struct xattr_handler *handler; -- -- handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); -- -- if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) -- return -EOPNOTSUPP; -- -- return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE); --} -- - struct listxattr_buf { - struct dir_context ctx; - size_t size; -diff --git a/fs/reiserfs/xattr.h b/fs/reiserfs/xattr.h -index 15dde6262c00..613ff5aef94e 100644 ---- a/fs/reiserfs/xattr.h -+++ b/fs/reiserfs/xattr.h -@@ -2,6 +2,7 @@ - #include - #include - #include -+#include - - struct inode; - struct dentry; -@@ -18,12 +19,7 @@ int reiserfs_permission(struct inode *inode, int mask); - - #ifdef CONFIG_REISERFS_FS_XATTR - #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) --ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name, -- void *buffer, size_t size); --int reiserfs_setxattr(struct dentry *dentry, const char *name, -- const void *value, size_t size, int flags); - ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); --int reiserfs_removexattr(struct dentry *dentry, const char *name); - - int reiserfs_xattr_get(struct inode *, const char *, void *, size_t); - int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); -@@ -92,10 +88,7 @@ static inline void reiserfs_init_xattr_rwsem(struct inode *inode) - - #else - --#define reiserfs_getxattr NULL --#define reiserfs_setxattr NULL - #define reiserfs_listxattr NULL --#define reiserfs_removexattr NULL - - static inline void reiserfs_init_xattr_rwsem(struct inode *inode) - { -diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c -index ac659af431ae..60de069225ba 100644 ---- a/fs/reiserfs/xattr_security.c -+++ b/fs/reiserfs/xattr_security.c -@@ -12,26 +12,24 @@ static int - security_get(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, void *buffer, size_t size) - { -- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) -- return -EINVAL; -- - if (IS_PRIVATE(d_inode(dentry))) - return -EPERM; - -- return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); -+ return reiserfs_xattr_get(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size); - } - - static int - security_set(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, const void *buffer, size_t size, int flags) - { -- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) -- return -EINVAL; -- - if (IS_PRIVATE(d_inode(dentry))) - return -EPERM; - -- return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); -+ return reiserfs_xattr_set(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size, flags); - } - - static size_t security_list(const struct xattr_handler *handler, -diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c -index a338adf1b8b4..ebba1ebf28ad 100644 ---- a/fs/reiserfs/xattr_trusted.c -+++ b/fs/reiserfs/xattr_trusted.c -@@ -11,26 +11,24 @@ static int - trusted_get(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, void *buffer, size_t size) - { -- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) -- return -EINVAL; -- - if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) - return -EPERM; - -- return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); -+ return reiserfs_xattr_get(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size); - } - - static int - trusted_set(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, const void *buffer, size_t size, int flags) - { -- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) -- return -EINVAL; -- - if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) - return -EPERM; - -- return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); -+ return reiserfs_xattr_set(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size, flags); - } - - static size_t trusted_list(const struct xattr_handler *handler, -diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c -index 39c9667191c5..6ac8a8c8bd9c 100644 ---- a/fs/reiserfs/xattr_user.c -+++ b/fs/reiserfs/xattr_user.c -@@ -10,24 +10,22 @@ static int - user_get(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, void *buffer, size_t size) - { -- -- if (strlen(name) < sizeof(XATTR_USER_PREFIX)) -- return -EINVAL; - if (!reiserfs_xattrs_user(dentry->d_sb)) - return -EOPNOTSUPP; -- return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); -+ return reiserfs_xattr_get(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size); - } - - static int - user_set(const struct xattr_handler *handler, struct dentry *dentry, - const char *name, const void *buffer, size_t size, int flags) - { -- if (strlen(name) < sizeof(XATTR_USER_PREFIX)) -- return -EINVAL; -- - if (!reiserfs_xattrs_user(dentry->d_sb)) - return -EOPNOTSUPP; -- return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); -+ return reiserfs_xattr_set(d_inode(dentry), -+ xattr_full_name(handler, name), -+ buffer, size, flags); - } - - static size_t user_list(const struct xattr_handler *handler, -diff --git a/fs/utimes.c b/fs/utimes.c -index aa138d64560a..cb771c30d102 100644 ---- a/fs/utimes.c -+++ b/fs/utimes.c -@@ -87,20 +87,7 @@ static int utimes_common(struct path *path, struct timespec *times) - */ - newattrs.ia_valid |= ATTR_TIMES_SET; - } else { -- /* -- * If times is NULL (or both times are UTIME_NOW), -- * then we need to check permissions, because -- * inode_change_ok() won't do it. -- */ -- error = -EACCES; -- if (IS_IMMUTABLE(inode)) -- goto mnt_drop_write_and_out; -- -- if (!inode_owner_or_capable(inode)) { -- error = inode_permission(inode, MAY_WRITE); -- if (error) -- goto mnt_drop_write_and_out; -- } -+ newattrs.ia_valid |= ATTR_TOUCH; - } - retry_deleg: - mutex_lock(&inode->i_mutex); -@@ -112,7 +99,6 @@ retry_deleg: - goto retry_deleg; - } - --mnt_drop_write_and_out: - mnt_drop_write(path->mnt); - out: - return error; -diff --git a/include/crypto/ghash.h b/include/crypto/ghash.h -new file mode 100644 -index 000000000000..2a61c9bbab8f ---- /dev/null -+++ b/include/crypto/ghash.h -@@ -0,0 +1,23 @@ -+/* -+ * Common values for GHASH algorithms -+ */ -+ -+#ifndef __CRYPTO_GHASH_H__ -+#define __CRYPTO_GHASH_H__ -+ -+#include -+#include -+ -+#define GHASH_BLOCK_SIZE 16 -+#define GHASH_DIGEST_SIZE 16 -+ -+struct ghash_ctx { -+ struct gf128mul_4k *gf128; -+}; -+ -+struct ghash_desc_ctx { -+ u8 buffer[GHASH_BLOCK_SIZE]; -+ u32 bytes; -+}; -+ -+#endif -diff --git a/include/linux/fs.h b/include/linux/fs.h -index 0166582c4d78..e1a123760dbf 100644 ---- a/include/linux/fs.h -+++ b/include/linux/fs.h -@@ -226,6 +226,7 @@ typedef void (dax_iodone_t)(struct buffer_head *bh_map, int uptodate); - #define ATTR_KILL_PRIV (1 << 14) - #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ - #define ATTR_TIMES_SET (1 << 16) -+#define ATTR_TOUCH (1 << 17) - - /* - * Whiteout is represented by a char device. The following constants define the -diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c -index adb32fefd693..b1e6b8f34a6a 100644 ---- a/sound/soc/intel/atom/sst/sst_pvt.c -+++ b/sound/soc/intel/atom/sst/sst_pvt.c -@@ -279,17 +279,15 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst, - - if (response) { - ret = sst_wait_timeout(sst, block); -- if (ret < 0) { -+ if (ret < 0) - goto out; -- } else if(block->data) { -- if (!data) -- goto out; -- *data = kzalloc(block->size, GFP_KERNEL); -- if (!(*data)) { -+ -+ if (data && block->data) { -+ *data = kmemdup(block->data, block->size, GFP_KERNEL); -+ if (!*data) { - ret = -ENOMEM; - goto out; -- } else -- memcpy(data, (void *) block->data, block->size); -+ } - } - } - out: diff --git a/patch/kernel/marvell-dev/patch-4.4.27-28.patch b/patch/kernel/marvell-dev/patch-4.4.27-28.patch deleted file mode 100644 index a653d5d9e3..0000000000 --- a/patch/kernel/marvell-dev/patch-4.4.27-28.patch +++ /dev/null @@ -1,4828 +0,0 @@ -diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt -index 0e4102ae1a61..c360f80c3473 100644 ---- a/Documentation/kernel-parameters.txt -+++ b/Documentation/kernel-parameters.txt -@@ -1371,7 +1371,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted. - i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX - controllers - i8042.notimeout [HW] Ignore timeout condition signalled by controller -- i8042.reset [HW] Reset the controller during init and cleanup -+ i8042.reset [HW] Reset the controller during init, cleanup and -+ suspend-to-ram transitions, only during s2r -+ transitions, or never reset -+ Format: { 1 | Y | y | 0 | N | n } -+ 1, Y, y: always reset controller -+ 0, N, n: don't ever reset controller -+ Default: only on s2r transitions on x86; most other -+ architectures force reset to be always executed - i8042.unlock [HW] Unlock (ignore) the keylock - i8042.kbdreset [HW] Reset device connected to KBD port - -diff --git a/Makefile b/Makefile -index b6ee4ce561f8..391294301aaf 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 27 -+SUBLEVEL = 28 - EXTRAVERSION = - NAME = Blurry Fish Butt - -diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c -index 004b7f0bc76c..257b8699efde 100644 ---- a/arch/arc/kernel/signal.c -+++ b/arch/arc/kernel/signal.c -@@ -107,13 +107,13 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) - struct user_regs_struct uregs; - - err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); -- if (!err) -- set_current_blocked(&set); -- - err |= __copy_from_user(&uregs.scratch, - &(sf->uc.uc_mcontext.regs.scratch), - sizeof(sf->uc.uc_mcontext.regs.scratch)); -+ if (err) -+ return err; - -+ set_current_blocked(&set); - regs->bta = uregs.scratch.bta; - regs->lp_start = uregs.scratch.lp_start; - regs->lp_end = uregs.scratch.lp_end; -@@ -138,7 +138,7 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) - regs->r0 = uregs.scratch.r0; - regs->sp = uregs.scratch.sp; - -- return err; -+ return 0; - } - - static inline int is_do_ss_needed(unsigned int magic) -diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h -index 0a456bef8c79..8a336852eeba 100644 ---- a/arch/arm64/include/asm/percpu.h -+++ b/arch/arm64/include/asm/percpu.h -@@ -44,48 +44,44 @@ static inline unsigned long __percpu_##op(void *ptr, \ - \ - switch (size) { \ - case 1: \ -- do { \ -- asm ("//__per_cpu_" #op "_1\n" \ -- "ldxrb %w[ret], %[ptr]\n" \ -+ asm ("//__per_cpu_" #op "_1\n" \ -+ "1: ldxrb %w[ret], %[ptr]\n" \ - #asm_op " %w[ret], %w[ret], %w[val]\n" \ -- "stxrb %w[loop], %w[ret], %[ptr]\n" \ -- : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -- [ptr] "+Q"(*(u8 *)ptr) \ -- : [val] "Ir" (val)); \ -- } while (loop); \ -+ " stxrb %w[loop], %w[ret], %[ptr]\n" \ -+ " cbnz %w[loop], 1b" \ -+ : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -+ [ptr] "+Q"(*(u8 *)ptr) \ -+ : [val] "Ir" (val)); \ - break; \ - case 2: \ -- do { \ -- asm ("//__per_cpu_" #op "_2\n" \ -- "ldxrh %w[ret], %[ptr]\n" \ -+ asm ("//__per_cpu_" #op "_2\n" \ -+ "1: ldxrh %w[ret], %[ptr]\n" \ - #asm_op " %w[ret], %w[ret], %w[val]\n" \ -- "stxrh %w[loop], %w[ret], %[ptr]\n" \ -- : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -- [ptr] "+Q"(*(u16 *)ptr) \ -- : [val] "Ir" (val)); \ -- } while (loop); \ -+ " stxrh %w[loop], %w[ret], %[ptr]\n" \ -+ " cbnz %w[loop], 1b" \ -+ : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -+ [ptr] "+Q"(*(u16 *)ptr) \ -+ : [val] "Ir" (val)); \ - break; \ - case 4: \ -- do { \ -- asm ("//__per_cpu_" #op "_4\n" \ -- "ldxr %w[ret], %[ptr]\n" \ -+ asm ("//__per_cpu_" #op "_4\n" \ -+ "1: ldxr %w[ret], %[ptr]\n" \ - #asm_op " %w[ret], %w[ret], %w[val]\n" \ -- "stxr %w[loop], %w[ret], %[ptr]\n" \ -- : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -- [ptr] "+Q"(*(u32 *)ptr) \ -- : [val] "Ir" (val)); \ -- } while (loop); \ -+ " stxr %w[loop], %w[ret], %[ptr]\n" \ -+ " cbnz %w[loop], 1b" \ -+ : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -+ [ptr] "+Q"(*(u32 *)ptr) \ -+ : [val] "Ir" (val)); \ - break; \ - case 8: \ -- do { \ -- asm ("//__per_cpu_" #op "_8\n" \ -- "ldxr %[ret], %[ptr]\n" \ -+ asm ("//__per_cpu_" #op "_8\n" \ -+ "1: ldxr %[ret], %[ptr]\n" \ - #asm_op " %[ret], %[ret], %[val]\n" \ -- "stxr %w[loop], %[ret], %[ptr]\n" \ -- : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -- [ptr] "+Q"(*(u64 *)ptr) \ -- : [val] "Ir" (val)); \ -- } while (loop); \ -+ " stxr %w[loop], %[ret], %[ptr]\n" \ -+ " cbnz %w[loop], 1b" \ -+ : [loop] "=&r" (loop), [ret] "=&r" (ret), \ -+ [ptr] "+Q"(*(u64 *)ptr) \ -+ : [val] "Ir" (val)); \ - break; \ - default: \ - BUILD_BUG(); \ -@@ -150,44 +146,40 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val, - - switch (size) { - case 1: -- do { -- asm ("//__percpu_xchg_1\n" -- "ldxrb %w[ret], %[ptr]\n" -- "stxrb %w[loop], %w[val], %[ptr]\n" -- : [loop] "=&r"(loop), [ret] "=&r"(ret), -- [ptr] "+Q"(*(u8 *)ptr) -- : [val] "r" (val)); -- } while (loop); -+ asm ("//__percpu_xchg_1\n" -+ "1: ldxrb %w[ret], %[ptr]\n" -+ " stxrb %w[loop], %w[val], %[ptr]\n" -+ " cbnz %w[loop], 1b" -+ : [loop] "=&r"(loop), [ret] "=&r"(ret), -+ [ptr] "+Q"(*(u8 *)ptr) -+ : [val] "r" (val)); - break; - case 2: -- do { -- asm ("//__percpu_xchg_2\n" -- "ldxrh %w[ret], %[ptr]\n" -- "stxrh %w[loop], %w[val], %[ptr]\n" -- : [loop] "=&r"(loop), [ret] "=&r"(ret), -- [ptr] "+Q"(*(u16 *)ptr) -- : [val] "r" (val)); -- } while (loop); -+ asm ("//__percpu_xchg_2\n" -+ "1: ldxrh %w[ret], %[ptr]\n" -+ " stxrh %w[loop], %w[val], %[ptr]\n" -+ " cbnz %w[loop], 1b" -+ : [loop] "=&r"(loop), [ret] "=&r"(ret), -+ [ptr] "+Q"(*(u16 *)ptr) -+ : [val] "r" (val)); - break; - case 4: -- do { -- asm ("//__percpu_xchg_4\n" -- "ldxr %w[ret], %[ptr]\n" -- "stxr %w[loop], %w[val], %[ptr]\n" -- : [loop] "=&r"(loop), [ret] "=&r"(ret), -- [ptr] "+Q"(*(u32 *)ptr) -- : [val] "r" (val)); -- } while (loop); -+ asm ("//__percpu_xchg_4\n" -+ "1: ldxr %w[ret], %[ptr]\n" -+ " stxr %w[loop], %w[val], %[ptr]\n" -+ " cbnz %w[loop], 1b" -+ : [loop] "=&r"(loop), [ret] "=&r"(ret), -+ [ptr] "+Q"(*(u32 *)ptr) -+ : [val] "r" (val)); - break; - case 8: -- do { -- asm ("//__percpu_xchg_8\n" -- "ldxr %[ret], %[ptr]\n" -- "stxr %w[loop], %[val], %[ptr]\n" -- : [loop] "=&r"(loop), [ret] "=&r"(ret), -- [ptr] "+Q"(*(u64 *)ptr) -- : [val] "r" (val)); -- } while (loop); -+ asm ("//__percpu_xchg_8\n" -+ "1: ldxr %[ret], %[ptr]\n" -+ " stxr %w[loop], %[val], %[ptr]\n" -+ " cbnz %w[loop], 1b" -+ : [loop] "=&r"(loop), [ret] "=&r"(ret), -+ [ptr] "+Q"(*(u64 *)ptr) -+ : [val] "r" (val)); - break; - default: - BUILD_BUG(); -diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S -index b685257926f0..20ceb5edf7b8 100644 ---- a/arch/arm64/kernel/head.S -+++ b/arch/arm64/kernel/head.S -@@ -518,8 +518,9 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems - b.lt 4f // Skip if no PMU present - mrs x0, pmcr_el0 // Disable debug access traps - ubfx x0, x0, #11, #5 // to EL2 and allow access to -- msr mdcr_el2, x0 // all PMU counters from EL1 - 4: -+ csel x0, xzr, x0, lt // all PMU counters from EL1 -+ msr mdcr_el2, x0 // (if they exist) - - /* Stage-2 translation */ - msr vttbr_el2, xzr -diff --git a/arch/metag/include/asm/atomic.h b/arch/metag/include/asm/atomic.h -index 470e365f04ea..8ff0a70865f6 100644 ---- a/arch/metag/include/asm/atomic.h -+++ b/arch/metag/include/asm/atomic.h -@@ -39,11 +39,10 @@ - #define atomic_dec(v) atomic_sub(1, (v)) - - #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) -+#define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) - - #endif - --#define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) -- - #include - - #endif /* __ASM_METAG_ATOMIC_H */ -diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h -index f6fc6aac5496..b6578611dddb 100644 ---- a/arch/mips/include/asm/ptrace.h -+++ b/arch/mips/include/asm/ptrace.h -@@ -152,7 +152,7 @@ static inline int is_syscall_success(struct pt_regs *regs) - - static inline long regs_return_value(struct pt_regs *regs) - { -- if (is_syscall_success(regs)) -+ if (is_syscall_success(regs) || !user_mode(regs)) - return regs->regs[2]; - else - return -regs->regs[2]; -diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile -index 090393aa0f20..6c7d78546eee 100644 ---- a/arch/mips/vdso/Makefile -+++ b/arch/mips/vdso/Makefile -@@ -75,7 +75,7 @@ obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) - $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) - $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) - --$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(native-abi) -+$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) - - $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE - $(call if_changed,vdsold) -diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h -index 291cee28ccb6..c2c43f714684 100644 ---- a/arch/parisc/include/asm/pgtable.h -+++ b/arch/parisc/include/asm/pgtable.h -@@ -83,10 +83,10 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr) - printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, (unsigned long)pgd_val(e)) - - /* This is the size of the initially mapped kernel memory */ --#ifdef CONFIG_64BIT --#define KERNEL_INITIAL_ORDER 25 /* 1<<25 = 32MB */ -+#if defined(CONFIG_64BIT) -+#define KERNEL_INITIAL_ORDER 26 /* 1<<26 = 64MB */ - #else --#define KERNEL_INITIAL_ORDER 24 /* 1<<24 = 16MB */ -+#define KERNEL_INITIAL_ORDER 25 /* 1<<25 = 32MB */ - #endif - #define KERNEL_INITIAL_SIZE (1 << KERNEL_INITIAL_ORDER) - -diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c -index f7ea626e29c9..81d6f6391944 100644 ---- a/arch/parisc/kernel/setup.c -+++ b/arch/parisc/kernel/setup.c -@@ -38,6 +38,7 @@ - #include - - #include -+#include - #include - #include - #include /* for pa7300lc_init() proto */ -@@ -140,6 +141,13 @@ void __init setup_arch(char **cmdline_p) - #endif - printk(KERN_CONT ".\n"); - -+ /* -+ * Check if initial kernel page mappings are sufficient. -+ * panic early if not, else we may access kernel functions -+ * and variables which can't be reached. -+ */ -+ if (__pa((unsigned long) &_end) >= KERNEL_INITIAL_SIZE) -+ panic("KERNEL_INITIAL_ORDER too small!"); - - pdc_console_init(); - -diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S -index 308f29081d46..60771df10fde 100644 ---- a/arch/parisc/kernel/vmlinux.lds.S -+++ b/arch/parisc/kernel/vmlinux.lds.S -@@ -88,8 +88,9 @@ SECTIONS - /* Start of data section */ - _sdata = .; - -- RO_DATA_SECTION(8) -- -+ /* Architecturally we need to keep __gp below 0x1000000 and thus -+ * in front of RO_DATA_SECTION() which stores lots of tracepoint -+ * and ftrace symbols. */ - #ifdef CONFIG_64BIT - . = ALIGN(16); - /* Linkage tables */ -@@ -104,6 +105,8 @@ SECTIONS - } - #endif - -+ RO_DATA_SECTION(8) -+ - /* unwind info */ - .PARISC.unwind : { - __start___unwind = .; -diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S -index 2f01c4a0d8a0..7612eeb31da1 100644 ---- a/arch/powerpc/kernel/vdso64/datapage.S -+++ b/arch/powerpc/kernel/vdso64/datapage.S -@@ -59,7 +59,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) - bl V_LOCAL_FUNC(__get_datapage) - mtlr r12 - addi r3,r3,CFG_SYSCALL_MAP64 -- cmpli cr0,r4,0 -+ cmpldi cr0,r4,0 - crclr cr0*4+so - beqlr - li r0,__NR_syscalls -diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S -index a76b4af37ef2..382021324883 100644 ---- a/arch/powerpc/kernel/vdso64/gettimeofday.S -+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S -@@ -145,7 +145,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) - bne cr0,99f - - li r3,0 -- cmpli cr0,r4,0 -+ cmpldi cr0,r4,0 - crclr cr0*4+so - beqlr - lis r5,CLOCK_REALTIME_RES@h -diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S -index f09899e35991..7b22624f332c 100644 ---- a/arch/powerpc/lib/copyuser_64.S -+++ b/arch/powerpc/lib/copyuser_64.S -@@ -359,6 +359,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD) - addi r3,r3,8 - 171: - 177: -+179: - addi r3,r3,8 - 370: - 372: -@@ -373,7 +374,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD) - 173: - 174: - 175: --179: - 181: - 184: - 186: -diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c -index 6527882ce05e..ddfd2740a1b5 100644 ---- a/arch/powerpc/mm/copro_fault.c -+++ b/arch/powerpc/mm/copro_fault.c -@@ -106,6 +106,8 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb) - switch (REGION_ID(ea)) { - case USER_REGION_ID: - pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); -+ if (mm == NULL) -+ return 1; - psize = get_slice_psize(mm, ea); - ssize = user_segment_size(ea); - vsid = get_vsid(mm->context.id, ea, ssize); -diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c -index 2ba602591a20..ba0cae69a396 100644 ---- a/arch/powerpc/platforms/powernv/eeh-powernv.c -+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c -@@ -1163,7 +1163,7 @@ static void pnv_eeh_get_and_dump_hub_diag(struct pci_controller *hose) - return; - } - -- switch (data->type) { -+ switch (be16_to_cpu(data->type)) { - case OPAL_P7IOC_DIAG_TYPE_RGC: - pr_info("P7IOC diag-data for RGC\n\n"); - pnv_eeh_dump_hub_diag_common(data); -@@ -1395,7 +1395,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe) - - /* Try best to clear it */ - opal_pci_eeh_freeze_clear(phb->opal_id, -- frozen_pe_no, -+ be64_to_cpu(frozen_pe_no), - OPAL_EEH_ACTION_CLEAR_FREEZE_ALL); - ret = EEH_NEXT_ERR_NONE; - } else if ((*pe)->state & EEH_PE_ISOLATED || -diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c -index ad8c3f4a5e0b..dd5e0f3b1b5d 100644 ---- a/arch/powerpc/platforms/powernv/pci.c -+++ b/arch/powerpc/platforms/powernv/pci.c -@@ -197,8 +197,8 @@ static void pnv_pci_dump_p7ioc_diag_data(struct pci_controller *hose, - be64_to_cpu(data->dma1ErrorLog1)); - - for (i = 0; i < OPAL_P7IOC_NUM_PEST_REGS; i++) { -- if ((data->pestA[i] >> 63) == 0 && -- (data->pestB[i] >> 63) == 0) -+ if ((be64_to_cpu(data->pestA[i]) >> 63) == 0 && -+ (be64_to_cpu(data->pestB[i]) >> 63) == 0) - continue; - - pr_info("PE[%3d] A/B: %016llx %016llx\n", -diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c -index b7a67e3d2201..3ae43282460e 100644 ---- a/arch/powerpc/platforms/pseries/lpar.c -+++ b/arch/powerpc/platforms/pseries/lpar.c -@@ -406,7 +406,7 @@ static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot, - unsigned long *vpn, int count, - int psize, int ssize) - { -- unsigned long param[8]; -+ unsigned long param[PLPAR_HCALL9_BUFSIZE]; - int i = 0, pix = 0, rc; - unsigned long flags = 0; - int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); -@@ -523,7 +523,7 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local) - unsigned long flags = 0; - struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); - int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); -- unsigned long param[9]; -+ unsigned long param[PLPAR_HCALL9_BUFSIZE]; - unsigned long hash, index, shift, hidx, slot; - real_pte_t pte; - int psize, ssize; -diff --git a/arch/s390/include/asm/tlbflush.h b/arch/s390/include/asm/tlbflush.h -index a2e6ef32e054..0a2031618f7f 100644 ---- a/arch/s390/include/asm/tlbflush.h -+++ b/arch/s390/include/asm/tlbflush.h -@@ -81,7 +81,8 @@ static inline void __tlb_flush_full(struct mm_struct *mm) - } - - /* -- * Flush TLB entries for a specific ASCE on all CPUs. -+ * Flush TLB entries for a specific ASCE on all CPUs. Should never be used -+ * when more than one asce (e.g. gmap) ran on this mm. - */ - static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce) - { -diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c -index 471a370a527b..8345ae1f117d 100644 ---- a/arch/s390/mm/pgtable.c -+++ b/arch/s390/mm/pgtable.c -@@ -166,7 +166,7 @@ EXPORT_SYMBOL_GPL(gmap_alloc); - static void gmap_flush_tlb(struct gmap *gmap) - { - if (MACHINE_HAS_IDTE) -- __tlb_flush_asce(gmap->mm, gmap->asce); -+ __tlb_flush_idte(gmap->asce); - else - __tlb_flush_global(); - } -@@ -205,7 +205,7 @@ void gmap_free(struct gmap *gmap) - - /* Flush tlb. */ - if (MACHINE_HAS_IDTE) -- __tlb_flush_asce(gmap->mm, gmap->asce); -+ __tlb_flush_idte(gmap->asce); - else - __tlb_flush_global(); - -diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c -index 38b3ead7222d..52a2526c3fbe 100644 ---- a/arch/x86/kernel/e820.c -+++ b/arch/x86/kernel/e820.c -@@ -347,7 +347,7 @@ int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, - * continue building up new bios map based on this - * information - */ -- if (current_type != last_type) { -+ if (current_type != last_type || current_type == E820_PRAM) { - if (last_type != 0) { - new_bios[new_bios_entry].size = - change_point[chgidx]->addr - last_addr; -diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c -index 88d0a92d3f94..3aab53f8cad2 100644 ---- a/arch/x86/kvm/ioapic.c -+++ b/arch/x86/kvm/ioapic.c -@@ -580,7 +580,7 @@ static void kvm_ioapic_reset(struct kvm_ioapic *ioapic) - ioapic->irr = 0; - ioapic->irr_delivered = 0; - ioapic->id = 0; -- memset(ioapic->irq_eoi, 0x00, IOAPIC_NUM_PINS); -+ memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi)); - rtc_irq_eoi_tracking_reset(ioapic); - } - -diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c -index 5a37188b559f..9d359e05fad7 100644 ---- a/block/blk-cgroup.c -+++ b/block/blk-cgroup.c -@@ -1331,10 +1331,8 @@ int blkcg_policy_register(struct blkcg_policy *pol) - struct blkcg_policy_data *cpd; - - cpd = pol->cpd_alloc_fn(GFP_KERNEL); -- if (!cpd) { -- mutex_unlock(&blkcg_pol_mutex); -+ if (!cpd) - goto err_free_cpds; -- } - - blkcg->cpd[pol->plid] = cpd; - cpd->blkcg = blkcg; -diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c -index 758acabf2d81..8f3056cd0399 100644 ---- a/crypto/asymmetric_keys/pkcs7_parser.c -+++ b/crypto/asymmetric_keys/pkcs7_parser.c -@@ -547,9 +547,7 @@ int pkcs7_sig_note_set_of_authattrs(void *context, size_t hdrlen, - struct pkcs7_signed_info *sinfo = ctx->sinfo; - - if (!test_bit(sinfo_has_content_type, &sinfo->aa_set) || -- !test_bit(sinfo_has_message_digest, &sinfo->aa_set) || -- (ctx->msg->data_type == OID_msIndirectData && -- !test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))) { -+ !test_bit(sinfo_has_message_digest, &sinfo->aa_set)) { - pr_warn("Missing required AuthAttr\n"); - return -EBADMSG; - } -diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c -index 5230e8449d30..c097f477c74c 100644 ---- a/drivers/acpi/nfit.c -+++ b/drivers/acpi/nfit.c -@@ -1806,6 +1806,9 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) - - dev_dbg(dev, "%s: event: %d\n", __func__, event); - -+ if (event != NFIT_NOTIFY_UPDATE) -+ return; -+ - device_lock(dev); - if (!dev->driver) { - /* dev->driver may be null if we're being removed */ -diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h -index 3d549a383659..13d6ec1ff055 100644 ---- a/drivers/acpi/nfit.h -+++ b/drivers/acpi/nfit.h -@@ -45,6 +45,10 @@ enum { - ND_BLK_DCR_LATCH = 2, - }; - -+enum nfit_root_notifiers { -+ NFIT_NOTIFY_UPDATE = 0x80, -+}; -+ - struct nfit_spa { - struct acpi_nfit_system_address *spa; - struct list_head list; -diff --git a/drivers/base/platform.c b/drivers/base/platform.c -index 176b59f5bc47..ba66330cea67 100644 ---- a/drivers/base/platform.c -+++ b/drivers/base/platform.c -@@ -96,7 +96,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) - int ret; - - ret = of_irq_get(dev->dev.of_node, num); -- if (ret >= 0 || ret == -EPROBE_DEFER) -+ if (ret > 0 || ret == -EPROBE_DEFER) - return ret; - } - -@@ -154,7 +154,7 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name) - int ret; - - ret = of_irq_get_byname(dev->dev.of_node, name); -- if (ret >= 0 || ret == -EPROBE_DEFER) -+ if (ret > 0 || ret == -EPROBE_DEFER) - return ret; - } - -diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c -index c1935081d34a..aab64205d866 100644 ---- a/drivers/clk/imx/clk-imx6q.c -+++ b/drivers/clk/imx/clk-imx6q.c -@@ -550,6 +550,24 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - if (IS_ENABLED(CONFIG_PCI_IMX6)) - clk_set_parent(clk[IMX6QDL_CLK_LVDS1_SEL], clk[IMX6QDL_CLK_SATA_REF_100M]); - -+ /* -+ * Initialize the GPU clock muxes, so that the maximum specified clock -+ * rates for the respective SoC are not exceeded. -+ */ -+ if (clk_on_imx6dl()) { -+ clk_set_parent(clk[IMX6QDL_CLK_GPU3D_CORE_SEL], -+ clk[IMX6QDL_CLK_PLL2_PFD1_594M]); -+ clk_set_parent(clk[IMX6QDL_CLK_GPU2D_CORE_SEL], -+ clk[IMX6QDL_CLK_PLL2_PFD1_594M]); -+ } else if (clk_on_imx6q()) { -+ clk_set_parent(clk[IMX6QDL_CLK_GPU3D_CORE_SEL], -+ clk[IMX6QDL_CLK_MMDC_CH0_AXI]); -+ clk_set_parent(clk[IMX6QDL_CLK_GPU3D_SHADER_SEL], -+ clk[IMX6QDL_CLK_PLL2_PFD1_594M]); -+ clk_set_parent(clk[IMX6QDL_CLK_GPU2D_CORE_SEL], -+ clk[IMX6QDL_CLK_PLL3_USB_OTG]); -+ } -+ - imx_register_uart_clocks(uart_clks); - } - CLK_OF_DECLARE(imx6q, "fsl,imx6q-ccm", imx6q_clocks_init); -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c -index 6e80e4298274..7ff8b15a3422 100644 ---- a/drivers/cpufreq/intel_pstate.c -+++ b/drivers/cpufreq/intel_pstate.c -@@ -285,14 +285,14 @@ static void intel_pstate_hwp_set(void) - int min, hw_min, max, hw_max, cpu, range, adj_range; - u64 value, cap; - -- rdmsrl(MSR_HWP_CAPABILITIES, cap); -- hw_min = HWP_LOWEST_PERF(cap); -- hw_max = HWP_HIGHEST_PERF(cap); -- range = hw_max - hw_min; -- - get_online_cpus(); - - for_each_online_cpu(cpu) { -+ rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap); -+ hw_min = HWP_LOWEST_PERF(cap); -+ hw_max = HWP_HIGHEST_PERF(cap); -+ range = hw_max - hw_min; -+ - rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); - adj_range = limits->min_perf_pct * range / 100; - min = hw_min + adj_range; -diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c -index 48ef368347ab..9e02cb6afb0b 100644 ---- a/drivers/gpio/gpio-mpc8xxx.c -+++ b/drivers/gpio/gpio-mpc8xxx.c -@@ -329,7 +329,7 @@ static int mpc8xxx_gpio_irq_map(struct irq_domain *h, unsigned int irq, - irq_hw_number_t hwirq) - { - irq_set_chip_data(irq, h->host_data); -- irq_set_chip_and_handler(irq, &mpc8xxx_irq_chip, handle_level_irq); -+ irq_set_chip_and_handler(irq, &mpc8xxx_irq_chip, handle_edge_irq); - - return 0; - } -diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c -index be5b399da5d3..43482ae1e049 100644 ---- a/drivers/input/mouse/elantech.c -+++ b/drivers/input/mouse/elantech.c -@@ -1163,6 +1163,13 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = { - DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"), - }, - }, -+ { -+ /* Fujitsu H760 also has a middle button */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H760"), -+ }, -+ }, - #endif - { } - }; -@@ -1507,10 +1514,10 @@ static const struct dmi_system_id elantech_dmi_force_crc_enabled[] = { - }, - }, - { -- /* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ -+ /* Fujitsu H760 does not work with crc_enabled == 0 */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), -- DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E554"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H760"), - }, - }, - { -@@ -1521,6 +1528,20 @@ static const struct dmi_system_id elantech_dmi_force_crc_enabled[] = { - }, - }, - { -+ /* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E554"), -+ }, -+ }, -+ { -+ /* Fujitsu LIFEBOOK E556 does not work with crc_enabled == 0 */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E556"), -+ }, -+ }, -+ { - /* Fujitsu LIFEBOOK U745 does not work with crc_enabled == 0 */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), -diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h -index a5eed2ade53d..34da81c006b6 100644 ---- a/drivers/input/serio/i8042-io.h -+++ b/drivers/input/serio/i8042-io.h -@@ -81,7 +81,7 @@ static inline int i8042_platform_init(void) - return -EBUSY; - #endif - -- i8042_reset = 1; -+ i8042_reset = I8042_RESET_ALWAYS; - return 0; - } - -diff --git a/drivers/input/serio/i8042-ip22io.h b/drivers/input/serio/i8042-ip22io.h -index ee1ad27d6ed0..08a1c10a1448 100644 ---- a/drivers/input/serio/i8042-ip22io.h -+++ b/drivers/input/serio/i8042-ip22io.h -@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void) - return -EBUSY; - #endif - -- i8042_reset = 1; -+ i8042_reset = I8042_RESET_ALWAYS; - - return 0; - } -diff --git a/drivers/input/serio/i8042-ppcio.h b/drivers/input/serio/i8042-ppcio.h -index f708c75d16f1..1aabea43329e 100644 ---- a/drivers/input/serio/i8042-ppcio.h -+++ b/drivers/input/serio/i8042-ppcio.h -@@ -44,7 +44,7 @@ static inline void i8042_write_command(int val) - - static inline int i8042_platform_init(void) - { -- i8042_reset = 1; -+ i8042_reset = I8042_RESET_ALWAYS; - return 0; - } - -diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h -index afcd1c1a05b2..6231d63860ee 100644 ---- a/drivers/input/serio/i8042-sparcio.h -+++ b/drivers/input/serio/i8042-sparcio.h -@@ -130,7 +130,7 @@ static int __init i8042_platform_init(void) - } - } - -- i8042_reset = 1; -+ i8042_reset = I8042_RESET_ALWAYS; - - return 0; - } -diff --git a/drivers/input/serio/i8042-unicore32io.h b/drivers/input/serio/i8042-unicore32io.h -index 73f5cc124a36..455747552f85 100644 ---- a/drivers/input/serio/i8042-unicore32io.h -+++ b/drivers/input/serio/i8042-unicore32io.h -@@ -61,7 +61,7 @@ static inline int i8042_platform_init(void) - if (!request_mem_region(I8042_REGION_START, I8042_REGION_SIZE, "i8042")) - return -EBUSY; - -- i8042_reset = 1; -+ i8042_reset = I8042_RESET_ALWAYS; - return 0; - } - -diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h -index 68f5f4a0f1e7..f4bfb4b2d50a 100644 ---- a/drivers/input/serio/i8042-x86ia64io.h -+++ b/drivers/input/serio/i8042-x86ia64io.h -@@ -510,6 +510,90 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { - { } - }; - -+/* -+ * On some Asus laptops, just running self tests cause problems. -+ */ -+static const struct dmi_system_id i8042_dmi_noselftest_table[] = { -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "A455LD"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "K401LB"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "K501LB"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "K501LX"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "R409L"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "V502LX"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X302LA"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X450LD"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X455LAB"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X455LDB"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "X455LF"), -+ }, -+ }, -+ { -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_PRODUCT_NAME, "Z450LA"), -+ }, -+ }, -+ { } -+}; - static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = { - { - /* MSI Wind U-100 */ -@@ -1072,12 +1156,18 @@ static int __init i8042_platform_init(void) - return retval; - - #if defined(__ia64__) -- i8042_reset = true; -+ i8042_reset = I8042_RESET_ALWAYS; - #endif - - #ifdef CONFIG_X86 -- if (dmi_check_system(i8042_dmi_reset_table)) -- i8042_reset = true; -+ /* Honor module parameter when value is not default */ -+ if (i8042_reset == I8042_RESET_DEFAULT) { -+ if (dmi_check_system(i8042_dmi_reset_table)) -+ i8042_reset = I8042_RESET_ALWAYS; -+ -+ if (dmi_check_system(i8042_dmi_noselftest_table)) -+ i8042_reset = I8042_RESET_NEVER; -+ } - - if (dmi_check_system(i8042_dmi_noloop_table)) - i8042_noloop = true; -diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c -index 405252a884dd..89abfdb539ac 100644 ---- a/drivers/input/serio/i8042.c -+++ b/drivers/input/serio/i8042.c -@@ -48,9 +48,39 @@ static bool i8042_unlock; - module_param_named(unlock, i8042_unlock, bool, 0); - MODULE_PARM_DESC(unlock, "Ignore keyboard lock."); - --static bool i8042_reset; --module_param_named(reset, i8042_reset, bool, 0); --MODULE_PARM_DESC(reset, "Reset controller during init and cleanup."); -+enum i8042_controller_reset_mode { -+ I8042_RESET_NEVER, -+ I8042_RESET_ALWAYS, -+ I8042_RESET_ON_S2RAM, -+#define I8042_RESET_DEFAULT I8042_RESET_ON_S2RAM -+}; -+static enum i8042_controller_reset_mode i8042_reset = I8042_RESET_DEFAULT; -+static int i8042_set_reset(const char *val, const struct kernel_param *kp) -+{ -+ enum i8042_controller_reset_mode *arg = kp->arg; -+ int error; -+ bool reset; -+ -+ if (val) { -+ error = kstrtobool(val, &reset); -+ if (error) -+ return error; -+ } else { -+ reset = true; -+ } -+ -+ *arg = reset ? I8042_RESET_ALWAYS : I8042_RESET_NEVER; -+ return 0; -+} -+ -+static const struct kernel_param_ops param_ops_reset_param = { -+ .flags = KERNEL_PARAM_OPS_FL_NOARG, -+ .set = i8042_set_reset, -+}; -+#define param_check_reset_param(name, p) \ -+ __param_check(name, p, enum i8042_controller_reset_mode) -+module_param_named(reset, i8042_reset, reset_param, 0); -+MODULE_PARM_DESC(reset, "Reset controller on resume, cleanup or both"); - - static bool i8042_direct; - module_param_named(direct, i8042_direct, bool, 0); -@@ -1019,7 +1049,7 @@ static int i8042_controller_init(void) - * Reset the controller and reset CRT to the original value set by BIOS. - */ - --static void i8042_controller_reset(bool force_reset) -+static void i8042_controller_reset(bool s2r_wants_reset) - { - i8042_flush(); - -@@ -1044,8 +1074,10 @@ static void i8042_controller_reset(bool force_reset) - * Reset the controller if requested. - */ - -- if (i8042_reset || force_reset) -+ if (i8042_reset == I8042_RESET_ALWAYS || -+ (i8042_reset == I8042_RESET_ON_S2RAM && s2r_wants_reset)) { - i8042_controller_selftest(); -+ } - - /* - * Restore the original control register setting. -@@ -1110,7 +1142,7 @@ static void i8042_dritek_enable(void) - * before suspending. - */ - --static int i8042_controller_resume(bool force_reset) -+static int i8042_controller_resume(bool s2r_wants_reset) - { - int error; - -@@ -1118,7 +1150,8 @@ static int i8042_controller_resume(bool force_reset) - if (error) - return error; - -- if (i8042_reset || force_reset) { -+ if (i8042_reset == I8042_RESET_ALWAYS || -+ (i8042_reset == I8042_RESET_ON_S2RAM && s2r_wants_reset)) { - error = i8042_controller_selftest(); - if (error) - return error; -@@ -1195,7 +1228,7 @@ static int i8042_pm_resume_noirq(struct device *dev) - - static int i8042_pm_resume(struct device *dev) - { -- bool force_reset; -+ bool want_reset; - int i; - - for (i = 0; i < I8042_NUM_PORTS; i++) { -@@ -1218,9 +1251,9 @@ static int i8042_pm_resume(struct device *dev) - * off control to the platform firmware, otherwise we can simply restore - * the mode. - */ -- force_reset = pm_resume_via_firmware(); -+ want_reset = pm_resume_via_firmware(); - -- return i8042_controller_resume(force_reset); -+ return i8042_controller_resume(want_reset); - } - - static int i8042_pm_thaw(struct device *dev) -@@ -1482,7 +1515,7 @@ static int __init i8042_probe(struct platform_device *dev) - - i8042_platform_device = dev; - -- if (i8042_reset) { -+ if (i8042_reset == I8042_RESET_ALWAYS) { - error = i8042_controller_selftest(); - if (error) - return error; -diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c -index 44aa57edf207..e33c729b9f48 100644 ---- a/drivers/irqchip/irq-gic-v3.c -+++ b/drivers/irqchip/irq-gic-v3.c -@@ -142,7 +142,7 @@ static void gic_enable_redist(bool enable) - return; /* No PM support in this redistributor */ - } - -- while (count--) { -+ while (--count) { - val = readl_relaxed(rbase + GICR_WAKER); - if (enable ^ (val & GICR_WAKER_ChildrenAsleep)) - break; -diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c -index 51eda7235e32..5cac11d7a876 100644 ---- a/drivers/md/dm-crypt.c -+++ b/drivers/md/dm-crypt.c -@@ -112,8 +112,7 @@ struct iv_tcw_private { - * and encrypts / decrypts at the same time. - */ - enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, -- DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD, -- DM_CRYPT_EXIT_THREAD}; -+ DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD }; - - /* - * The fields in here must be read only after initialization. -@@ -1204,18 +1203,20 @@ continue_locked: - if (!RB_EMPTY_ROOT(&cc->write_tree)) - goto pop_from_list; - -- if (unlikely(test_bit(DM_CRYPT_EXIT_THREAD, &cc->flags))) { -- spin_unlock_irq(&cc->write_thread_wait.lock); -- break; -- } -- -- __set_current_state(TASK_INTERRUPTIBLE); -+ set_current_state(TASK_INTERRUPTIBLE); - __add_wait_queue(&cc->write_thread_wait, &wait); - - spin_unlock_irq(&cc->write_thread_wait.lock); - -+ if (unlikely(kthread_should_stop())) { -+ set_task_state(current, TASK_RUNNING); -+ remove_wait_queue(&cc->write_thread_wait, &wait); -+ break; -+ } -+ - schedule(); - -+ set_task_state(current, TASK_RUNNING); - spin_lock_irq(&cc->write_thread_wait.lock); - __remove_wait_queue(&cc->write_thread_wait, &wait); - goto continue_locked; -@@ -1530,13 +1531,8 @@ static void crypt_dtr(struct dm_target *ti) - if (!cc) - return; - -- if (cc->write_thread) { -- spin_lock_irq(&cc->write_thread_wait.lock); -- set_bit(DM_CRYPT_EXIT_THREAD, &cc->flags); -- wake_up_locked(&cc->write_thread_wait); -- spin_unlock_irq(&cc->write_thread_wait.lock); -+ if (cc->write_thread) - kthread_stop(cc->write_thread); -- } - - if (cc->io_queue) - destroy_workqueue(cc->io_queue); -diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c -index cfa29f574c2a..5b2ef966012b 100644 ---- a/drivers/md/dm-mpath.c -+++ b/drivers/md/dm-mpath.c -@@ -1220,10 +1220,10 @@ static void activate_path(struct work_struct *work) - { - struct pgpath *pgpath = - container_of(work, struct pgpath, activate_path.work); -+ struct request_queue *q = bdev_get_queue(pgpath->path.dev->bdev); - -- if (pgpath->is_active) -- scsi_dh_activate(bdev_get_queue(pgpath->path.dev->bdev), -- pg_init_done, pgpath); -+ if (pgpath->is_active && !blk_queue_dying(q)) -+ scsi_dh_activate(q, pg_init_done, pgpath); - else - pg_init_done(pgpath, SCSI_DH_DEV_OFFLINED); - } -diff --git a/drivers/md/dm.c b/drivers/md/dm.c -index a42729ebf272..84aa8b1d0480 100644 ---- a/drivers/md/dm.c -+++ b/drivers/md/dm.c -@@ -2869,6 +2869,7 @@ EXPORT_SYMBOL_GPL(dm_device_name); - - static void __dm_destroy(struct mapped_device *md, bool wait) - { -+ struct request_queue *q = dm_get_md_queue(md); - struct dm_table *map; - int srcu_idx; - -@@ -2879,6 +2880,10 @@ static void __dm_destroy(struct mapped_device *md, bool wait) - set_bit(DMF_FREEING, &md->flags); - spin_unlock(&_minor_lock); - -+ spin_lock_irq(q->queue_lock); -+ queue_flag_set(QUEUE_FLAG_DYING, q); -+ spin_unlock_irq(q->queue_lock); -+ - if (dm_request_based(md) && md->kworker_task) - flush_kthread_worker(&md->kworker); - -@@ -3245,10 +3250,11 @@ static int __dm_resume(struct mapped_device *md, struct dm_table *map) - - int dm_resume(struct mapped_device *md) - { -- int r = -EINVAL; -+ int r; - struct dm_table *map = NULL; - - retry: -+ r = -EINVAL; - mutex_lock_nested(&md->suspend_lock, SINGLE_DEPTH_NESTING); - - if (!dm_suspended_md(md)) -@@ -3272,8 +3278,6 @@ retry: - goto out; - - clear_bit(DMF_SUSPENDED, &md->flags); -- -- r = 0; - out: - mutex_unlock(&md->suspend_lock); - -diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c -index cfc005ee11d8..7fc72de2434c 100644 ---- a/drivers/media/dvb-frontends/mb86a20s.c -+++ b/drivers/media/dvb-frontends/mb86a20s.c -@@ -71,25 +71,27 @@ static struct regdata mb86a20s_init1[] = { - }; - - static struct regdata mb86a20s_init2[] = { -- { 0x28, 0x22 }, { 0x29, 0x00 }, { 0x2a, 0x1f }, { 0x2b, 0xf0 }, -+ { 0x50, 0xd1 }, { 0x51, 0x22 }, -+ { 0x39, 0x01 }, -+ { 0x71, 0x00 }, - { 0x3b, 0x21 }, -- { 0x3c, 0x38 }, -+ { 0x3c, 0x3a }, - { 0x01, 0x0d }, -- { 0x04, 0x08 }, { 0x05, 0x03 }, -+ { 0x04, 0x08 }, { 0x05, 0x05 }, - { 0x04, 0x0e }, { 0x05, 0x00 }, -- { 0x04, 0x0f }, { 0x05, 0x37 }, -- { 0x04, 0x0b }, { 0x05, 0x78 }, -+ { 0x04, 0x0f }, { 0x05, 0x14 }, -+ { 0x04, 0x0b }, { 0x05, 0x8c }, - { 0x04, 0x00 }, { 0x05, 0x00 }, -- { 0x04, 0x01 }, { 0x05, 0x1e }, -- { 0x04, 0x02 }, { 0x05, 0x07 }, -- { 0x04, 0x03 }, { 0x05, 0xd0 }, -+ { 0x04, 0x01 }, { 0x05, 0x07 }, -+ { 0x04, 0x02 }, { 0x05, 0x0f }, -+ { 0x04, 0x03 }, { 0x05, 0xa0 }, - { 0x04, 0x09 }, { 0x05, 0x00 }, - { 0x04, 0x0a }, { 0x05, 0xff }, -- { 0x04, 0x27 }, { 0x05, 0x00 }, -+ { 0x04, 0x27 }, { 0x05, 0x64 }, - { 0x04, 0x28 }, { 0x05, 0x00 }, -- { 0x04, 0x1e }, { 0x05, 0x00 }, -- { 0x04, 0x29 }, { 0x05, 0x64 }, -- { 0x04, 0x32 }, { 0x05, 0x02 }, -+ { 0x04, 0x1e }, { 0x05, 0xff }, -+ { 0x04, 0x29 }, { 0x05, 0x0a }, -+ { 0x04, 0x32 }, { 0x05, 0x0a }, - { 0x04, 0x14 }, { 0x05, 0x02 }, - { 0x04, 0x04 }, { 0x05, 0x00 }, - { 0x04, 0x05 }, { 0x05, 0x22 }, -@@ -97,8 +99,6 @@ static struct regdata mb86a20s_init2[] = { - { 0x04, 0x07 }, { 0x05, 0xd8 }, - { 0x04, 0x12 }, { 0x05, 0x00 }, - { 0x04, 0x13 }, { 0x05, 0xff }, -- { 0x04, 0x15 }, { 0x05, 0x4e }, -- { 0x04, 0x16 }, { 0x05, 0x20 }, - - /* - * On this demod, when the bit count reaches the count below, -@@ -152,42 +152,36 @@ static struct regdata mb86a20s_init2[] = { - { 0x50, 0x51 }, { 0x51, 0x04 }, /* MER symbol 4 */ - { 0x45, 0x04 }, /* CN symbol 4 */ - { 0x48, 0x04 }, /* CN manual mode */ -- -+ { 0x50, 0xd5 }, { 0x51, 0x01 }, - { 0x50, 0xd6 }, { 0x51, 0x1f }, - { 0x50, 0xd2 }, { 0x51, 0x03 }, -- { 0x50, 0xd7 }, { 0x51, 0xbf }, -- { 0x28, 0x74 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0xff }, -- { 0x28, 0x46 }, { 0x29, 0x00 }, { 0x2a, 0x1a }, { 0x2b, 0x0c }, -- -- { 0x04, 0x40 }, { 0x05, 0x00 }, -- { 0x28, 0x00 }, { 0x2b, 0x08 }, -- { 0x28, 0x05 }, { 0x2b, 0x00 }, -+ { 0x50, 0xd7 }, { 0x51, 0x3f }, - { 0x1c, 0x01 }, -- { 0x28, 0x06 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x1f }, -- { 0x28, 0x07 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x18 }, -- { 0x28, 0x08 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x12 }, -- { 0x28, 0x09 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x30 }, -- { 0x28, 0x0a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x37 }, -- { 0x28, 0x0b }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x02 }, -- { 0x28, 0x0c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x09 }, -- { 0x28, 0x0d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x06 }, -- { 0x28, 0x0e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x7b }, -- { 0x28, 0x0f }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x76 }, -- { 0x28, 0x10 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x7d }, -- { 0x28, 0x11 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x08 }, -- { 0x28, 0x12 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0b }, -- { 0x28, 0x13 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x00 }, -- { 0x28, 0x14 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xf2 }, -- { 0x28, 0x15 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xf3 }, -- { 0x28, 0x16 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x05 }, -- { 0x28, 0x17 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x16 }, -- { 0x28, 0x18 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0f }, -- { 0x28, 0x19 }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xef }, -- { 0x28, 0x1a }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xd8 }, -- { 0x28, 0x1b }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xf1 }, -- { 0x28, 0x1c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x3d }, -- { 0x28, 0x1d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x94 }, -- { 0x28, 0x1e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0xba }, -+ { 0x28, 0x06 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x03 }, -+ { 0x28, 0x07 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0d }, -+ { 0x28, 0x08 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x02 }, -+ { 0x28, 0x09 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x01 }, -+ { 0x28, 0x0a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x21 }, -+ { 0x28, 0x0b }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x29 }, -+ { 0x28, 0x0c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x16 }, -+ { 0x28, 0x0d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x31 }, -+ { 0x28, 0x0e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0e }, -+ { 0x28, 0x0f }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x4e }, -+ { 0x28, 0x10 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x46 }, -+ { 0x28, 0x11 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0f }, -+ { 0x28, 0x12 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x56 }, -+ { 0x28, 0x13 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x35 }, -+ { 0x28, 0x14 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xbe }, -+ { 0x28, 0x15 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0x84 }, -+ { 0x28, 0x16 }, { 0x29, 0x00 }, { 0x2a, 0x03 }, { 0x2b, 0xee }, -+ { 0x28, 0x17 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x98 }, -+ { 0x28, 0x18 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x9f }, -+ { 0x28, 0x19 }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xb2 }, -+ { 0x28, 0x1a }, { 0x29, 0x00 }, { 0x2a, 0x06 }, { 0x2b, 0xc2 }, -+ { 0x28, 0x1b }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0x4a }, -+ { 0x28, 0x1c }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xbc }, -+ { 0x28, 0x1d }, { 0x29, 0x00 }, { 0x2a, 0x04 }, { 0x2b, 0xba }, -+ { 0x28, 0x1e }, { 0x29, 0x00 }, { 0x2a, 0x06 }, { 0x2b, 0x14 }, - { 0x50, 0x1e }, { 0x51, 0x5d }, - { 0x50, 0x22 }, { 0x51, 0x00 }, - { 0x50, 0x23 }, { 0x51, 0xc8 }, -@@ -196,9 +190,7 @@ static struct regdata mb86a20s_init2[] = { - { 0x50, 0x26 }, { 0x51, 0x00 }, - { 0x50, 0x27 }, { 0x51, 0xc3 }, - { 0x50, 0x39 }, { 0x51, 0x02 }, -- { 0xec, 0x0f }, -- { 0xeb, 0x1f }, -- { 0x28, 0x6a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x00 }, -+ { 0x50, 0xd5 }, { 0x51, 0x01 }, - { 0xd0, 0x00 }, - }; - -@@ -317,7 +309,11 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, enum fe_status *status) - if (val >= 7) - *status |= FE_HAS_SYNC; - -- if (val >= 8) /* Maybe 9? */ -+ /* -+ * Actually, on state S8, it starts receiving TS, but the TS -+ * output is only on normal state after the transition to S9. -+ */ -+ if (val >= 9) - *status |= FE_HAS_LOCK; - - dev_dbg(&state->i2c->dev, "%s: Status = 0x%02x (state = %d)\n", -@@ -2067,6 +2063,11 @@ static void mb86a20s_release(struct dvb_frontend *fe) - kfree(state); - } - -+static int mb86a20s_get_frontend_algo(struct dvb_frontend *fe) -+{ -+ return DVBFE_ALGO_HW; -+} -+ - static struct dvb_frontend_ops mb86a20s_ops; - - struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, -@@ -2140,6 +2141,7 @@ static struct dvb_frontend_ops mb86a20s_ops = { - .read_status = mb86a20s_read_status_and_stats, - .read_signal_strength = mb86a20s_read_signal_strength_from_cache, - .tune = mb86a20s_tune, -+ .get_frontend_algo = mb86a20s_get_frontend_algo, - }; - - MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware"); -diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c -index 491913778bcc..2f52d66b4dae 100644 ---- a/drivers/media/usb/cx231xx/cx231xx-avcore.c -+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c -@@ -1264,7 +1264,10 @@ int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, - dev->board.agc_analog_digital_select_gpio, - analog_or_digital); - -- return status; -+ if (status < 0) -+ return status; -+ -+ return 0; - } - - int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3) -diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c -index 4a117a58c39a..8389c162bc89 100644 ---- a/drivers/media/usb/cx231xx/cx231xx-cards.c -+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c -@@ -486,7 +486,7 @@ struct cx231xx_board cx231xx_boards[] = { - .output_mode = OUT_MODE_VIP11, - .demod_xfer_mode = 0, - .ctl_pin_status_mask = 0xFFFFFFC4, -- .agc_analog_digital_select_gpio = 0x00, /* According with PV cxPolaris.inf file */ -+ .agc_analog_digital_select_gpio = 0x1c, - .tuner_sif_gpio = -1, - .tuner_scl_gpio = -1, - .tuner_sda_gpio = -1, -diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c -index a2fd49b6be83..19b0293312a0 100644 ---- a/drivers/media/usb/cx231xx/cx231xx-core.c -+++ b/drivers/media/usb/cx231xx/cx231xx-core.c -@@ -712,6 +712,7 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) - break; - case CX231XX_BOARD_CNXT_RDE_253S: - case CX231XX_BOARD_CNXT_RDU_253S: -+ case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: - errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); - break; - case CX231XX_BOARD_HAUPPAUGE_EXETER: -@@ -738,7 +739,7 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) - case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: - case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: - case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: -- errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); -+ errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); - break; - default: - break; -diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c -index 1105db2355d2..83bfb1659abe 100644 ---- a/drivers/memstick/host/rtsx_usb_ms.c -+++ b/drivers/memstick/host/rtsx_usb_ms.c -@@ -524,6 +524,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) - int rc; - - if (!host->req) { -+ pm_runtime_get_sync(ms_dev(host)); - do { - rc = memstick_next_req(msh, &host->req); - dev_dbg(ms_dev(host), "next req %d\n", rc); -@@ -544,6 +545,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) - host->req->error); - } - } while (!rc); -+ pm_runtime_put(ms_dev(host)); - } - - } -@@ -570,6 +572,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, - dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n", - __func__, param, value); - -+ pm_runtime_get_sync(ms_dev(host)); - mutex_lock(&ucr->dev_mutex); - - err = rtsx_usb_card_exclusive_check(ucr, RTSX_USB_MS_CARD); -@@ -635,6 +638,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, - } - out: - mutex_unlock(&ucr->dev_mutex); -+ pm_runtime_put(ms_dev(host)); - - /* power-on delay */ - if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) -@@ -681,6 +685,7 @@ static int rtsx_usb_detect_ms_card(void *__host) - int err; - - for (;;) { -+ pm_runtime_get_sync(ms_dev(host)); - mutex_lock(&ucr->dev_mutex); - - /* Check pending MS card changes */ -@@ -703,6 +708,7 @@ static int rtsx_usb_detect_ms_card(void *__host) - } - - poll_again: -+ pm_runtime_put(ms_dev(host)); - if (host->eject) - break; - -diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h -index a8a68acd3267..4e8069866c85 100644 ---- a/drivers/misc/mei/hw-me-regs.h -+++ b/drivers/misc/mei/hw-me-regs.h -@@ -66,6 +66,9 @@ - #ifndef _MEI_HW_MEI_REGS_H_ - #define _MEI_HW_MEI_REGS_H_ - -+#define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */ -+#define MEI_DEV_ID_KBP_2 0xA2BB /* Kaby Point 2 */ -+ - /* - * MEI device IDs - */ -diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c -index 27678d8154e0..0af3d7d30419 100644 ---- a/drivers/misc/mei/pci-me.c -+++ b/drivers/misc/mei/pci-me.c -@@ -87,6 +87,9 @@ static const struct pci_device_id mei_me_pci_tbl[] = { - {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, mei_me_pch8_cfg)}, - {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, mei_me_pch8_cfg)}, - -+ {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, mei_me_pch8_cfg)}, -+ {MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, mei_me_pch8_cfg)}, -+ - /* required last entry */ - {0, } - }; -diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c -index 64950035613b..f2b733275a0a 100644 ---- a/drivers/mmc/card/block.c -+++ b/drivers/mmc/card/block.c -@@ -1755,7 +1755,7 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq, - struct mmc_blk_data *md = mq->data; - struct mmc_packed *packed = mqrq->packed; - bool do_rel_wr, do_data_tag; -- u32 *packed_cmd_hdr; -+ __le32 *packed_cmd_hdr; - u8 hdr_blocks; - u8 i = 1; - -@@ -2279,7 +2279,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, - set_capacity(md->disk, size); - - if (mmc_host_cmd23(card->host)) { -- if (mmc_card_mmc(card) || -+ if ((mmc_card_mmc(card) && -+ card->csd.mmca_vsn >= CSD_SPEC_VER_3) || - (mmc_card_sd(card) && - card->scr.cmds & SD_SCR_CMD23_SUPPORT)) - md->flags |= MMC_BLK_CMD23; -diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h -index 36cddab57d77..cf30b3712cb2 100644 ---- a/drivers/mmc/card/queue.h -+++ b/drivers/mmc/card/queue.h -@@ -25,7 +25,7 @@ enum mmc_packed_type { - - struct mmc_packed { - struct list_head list; -- u32 cmd_hdr[1024]; -+ __le32 cmd_hdr[1024]; - unsigned int blocks; - u8 nr_entries; - u8 retries; -diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c -index 6c71fc9f76c7..da9f71b8deb0 100644 ---- a/drivers/mmc/host/rtsx_usb_sdmmc.c -+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c -@@ -1138,11 +1138,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) - dev_dbg(sdmmc_dev(host), "%s\n", __func__); - mutex_lock(&ucr->dev_mutex); - -- if (rtsx_usb_card_exclusive_check(ucr, RTSX_USB_SD_CARD)) { -- mutex_unlock(&ucr->dev_mutex); -- return; -- } -- - sd_set_power_mode(host, ios->power_mode); - sd_set_bus_width(host, ios->bus_width); - sd_set_timing(host, ios->timing, &host->ddr_mode); -@@ -1314,6 +1309,7 @@ static void rtsx_usb_update_led(struct work_struct *work) - container_of(work, struct rtsx_usb_sdmmc, led_work); - struct rtsx_ucr *ucr = host->ucr; - -+ pm_runtime_get_sync(sdmmc_dev(host)); - mutex_lock(&ucr->dev_mutex); - - if (host->led.brightness == LED_OFF) -@@ -1322,6 +1318,7 @@ static void rtsx_usb_update_led(struct work_struct *work) - rtsx_usb_turn_on_led(ucr); - - mutex_unlock(&ucr->dev_mutex); -+ pm_runtime_put(sdmmc_dev(host)); - } - #endif - -diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c -index 552a34dc4f82..64a428984afe 100644 ---- a/drivers/mmc/host/sdhci.c -+++ b/drivers/mmc/host/sdhci.c -@@ -675,7 +675,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) - * host->clock is in Hz. target_timeout is in us. - * Hence, us = 1000000 * cycles / Hz. Round up. - */ -- val = 1000000 * data->timeout_clks; -+ val = 1000000ULL * data->timeout_clks; - if (do_div(val, host->clock)) - target_timeout++; - target_timeout += val; -diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c -index 56065632a5b8..75286588b823 100644 ---- a/drivers/mtd/ubi/wl.c -+++ b/drivers/mtd/ubi/wl.c -@@ -643,7 +643,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, - int shutdown) - { - int err, scrubbing = 0, torture = 0, protect = 0, erroneous = 0; -- int vol_id = -1, lnum = -1; -+ int erase = 0, keep = 0, vol_id = -1, lnum = -1; - #ifdef CONFIG_MTD_UBI_FASTMAP - int anchor = wrk->anchor; - #endif -@@ -777,6 +777,16 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, - e1->pnum); - scrubbing = 1; - goto out_not_moved; -+ } else if (ubi->fast_attach && err == UBI_IO_BAD_HDR_EBADMSG) { -+ /* -+ * While a full scan would detect interrupted erasures -+ * at attach time we can face them here when attached from -+ * Fastmap. -+ */ -+ dbg_wl("PEB %d has ECC errors, maybe from an interrupted erasure", -+ e1->pnum); -+ erase = 1; -+ goto out_not_moved; - } - - ubi_err(ubi, "error %d while reading VID header from PEB %d", -@@ -810,6 +820,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, - * Target PEB had bit-flips or write error - torture it. - */ - torture = 1; -+ keep = 1; - goto out_not_moved; - } - -@@ -895,7 +906,7 @@ out_not_moved: - ubi->erroneous_peb_count += 1; - } else if (scrubbing) - wl_tree_add(e1, &ubi->scrub); -- else -+ else if (keep) - wl_tree_add(e1, &ubi->used); - ubi_assert(!ubi->move_to_put); - ubi->move_from = ubi->move_to = NULL; -@@ -907,6 +918,12 @@ out_not_moved: - if (err) - goto out_ro; - -+ if (erase) { -+ err = do_sync_erase(ubi, e1, vol_id, lnum, 1); -+ if (err) -+ goto out_ro; -+ } -+ - mutex_unlock(&ubi->move_mutex); - return 0; - -diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c -index 2e611dc5f162..1c8123816745 100644 ---- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c -+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c -@@ -14819,6 +14819,10 @@ static int bnx2x_get_fc_npiv(struct net_device *dev, - } - - offset = SHMEM2_RD(bp, fc_npiv_nvram_tbl_addr[BP_PORT(bp)]); -+ if (!offset) { -+ DP(BNX2X_MSG_MCP, "No FC-NPIV in NVRAM\n"); -+ goto out; -+ } - DP(BNX2X_MSG_MCP, "Offset of FC-NPIV in NVRAM: %08x\n", offset); - - /* Read the table contents from nvram */ -diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -index 67e9633ea9c7..232191417b93 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -@@ -2282,7 +2282,7 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac) - struct mlx4_en_dev *mdev = en_priv->mdev; - u64 mac_u64 = mlx4_mac_to_u64(mac); - -- if (!is_valid_ether_addr(mac)) -+ if (is_multicast_ether_addr(mac)) - return -EINVAL; - - return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64); -diff --git a/drivers/net/wireless/realtek/rtlwifi/regd.c b/drivers/net/wireless/realtek/rtlwifi/regd.c -index 5be34118e0af..f67e7e5b13e1 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/regd.c -+++ b/drivers/net/wireless/realtek/rtlwifi/regd.c -@@ -345,9 +345,9 @@ static const struct ieee80211_regdomain *_rtl_regdomain_select( - return &rtl_regdom_no_midband; - case COUNTRY_CODE_IC: - return &rtl_regdom_11; -- case COUNTRY_CODE_ETSI: - case COUNTRY_CODE_TELEC_NETGEAR: - return &rtl_regdom_60_64; -+ case COUNTRY_CODE_ETSI: - case COUNTRY_CODE_SPAIN: - case COUNTRY_CODE_FRANCE: - case COUNTRY_CODE_ISRAEL: -@@ -406,6 +406,8 @@ static u8 channel_plan_to_country_code(u8 channelplan) - return COUNTRY_CODE_WORLD_WIDE_13; - case 0x22: - return COUNTRY_CODE_IC; -+ case 0x25: -+ return COUNTRY_CODE_ETSI; - case 0x32: - return COUNTRY_CODE_TELEC_NETGEAR; - case 0x41: -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index 42774bc39786..254192b5dad1 100644 ---- a/drivers/pci/quirks.c -+++ b/drivers/pci/quirks.c -@@ -3136,6 +3136,7 @@ static void quirk_no_bus_reset(struct pci_dev *dev) - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0030, quirk_no_bus_reset); - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset); - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset); -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset); - - static void quirk_no_pm_reset(struct pci_dev *dev) - { -diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c -index fb991ec76423..696116ebdf50 100644 ---- a/drivers/regulator/tps65910-regulator.c -+++ b/drivers/regulator/tps65910-regulator.c -@@ -1111,6 +1111,12 @@ static int tps65910_probe(struct platform_device *pdev) - pmic->num_regulators = ARRAY_SIZE(tps65910_regs); - pmic->ext_sleep_control = tps65910_ext_sleep_control; - info = tps65910_regs; -+ /* Work around silicon erratum SWCZ010: output programmed -+ * voltage level can go higher than expected or crash -+ * Workaround: use no synchronization of DCDC clocks -+ */ -+ tps65910_reg_clear_bits(pmic->mfd, TPS65910_DCDCCTRL, -+ DCDCCTRL_DCDCCKSYNC_MASK); - break; - case TPS65911: - pmic->get_ctrl_reg = &tps65911_get_ctrl_register; -diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c -index 5d7fbe4e907e..581001989937 100644 ---- a/drivers/s390/scsi/zfcp_dbf.c -+++ b/drivers/s390/scsi/zfcp_dbf.c -@@ -3,7 +3,7 @@ - * - * Debug traces for zfcp. - * -- * Copyright IBM Corp. 2002, 2013 -+ * Copyright IBM Corp. 2002, 2016 - */ - - #define KMSG_COMPONENT "zfcp" -@@ -65,7 +65,7 @@ void zfcp_dbf_pl_write(struct zfcp_dbf *dbf, void *data, u16 length, char *area, - * @tag: tag indicating which kind of unsolicited status has been received - * @req: request for which a response was received - */ --void zfcp_dbf_hba_fsf_res(char *tag, struct zfcp_fsf_req *req) -+void zfcp_dbf_hba_fsf_res(char *tag, int level, struct zfcp_fsf_req *req) - { - struct zfcp_dbf *dbf = req->adapter->dbf; - struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix; -@@ -85,6 +85,8 @@ void zfcp_dbf_hba_fsf_res(char *tag, struct zfcp_fsf_req *req) - rec->u.res.req_issued = req->issued; - rec->u.res.prot_status = q_pref->prot_status; - rec->u.res.fsf_status = q_head->fsf_status; -+ rec->u.res.port_handle = q_head->port_handle; -+ rec->u.res.lun_handle = q_head->lun_handle; - - memcpy(rec->u.res.prot_status_qual, &q_pref->prot_status_qual, - FSF_PROT_STATUS_QUAL_SIZE); -@@ -97,7 +99,7 @@ void zfcp_dbf_hba_fsf_res(char *tag, struct zfcp_fsf_req *req) - rec->pl_len, "fsf_res", req->req_id); - } - -- debug_event(dbf->hba, 1, rec, sizeof(*rec)); -+ debug_event(dbf->hba, level, rec, sizeof(*rec)); - spin_unlock_irqrestore(&dbf->hba_lock, flags); - } - -@@ -241,7 +243,8 @@ static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec, - if (sdev) { - rec->lun_status = atomic_read(&sdev_to_zfcp(sdev)->status); - rec->lun = zfcp_scsi_dev_lun(sdev); -- } -+ } else -+ rec->lun = ZFCP_DBF_INVALID_LUN; - } - - /** -@@ -320,13 +323,48 @@ void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp) - spin_unlock_irqrestore(&dbf->rec_lock, flags); - } - -+/** -+ * zfcp_dbf_rec_run_wka - trace wka port event with info like running recovery -+ * @tag: identifier for event -+ * @wka_port: well known address port -+ * @req_id: request ID to correlate with potential HBA trace record -+ */ -+void zfcp_dbf_rec_run_wka(char *tag, struct zfcp_fc_wka_port *wka_port, -+ u64 req_id) -+{ -+ struct zfcp_dbf *dbf = wka_port->adapter->dbf; -+ struct zfcp_dbf_rec *rec = &dbf->rec_buf; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&dbf->rec_lock, flags); -+ memset(rec, 0, sizeof(*rec)); -+ -+ rec->id = ZFCP_DBF_REC_RUN; -+ memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); -+ rec->port_status = wka_port->status; -+ rec->d_id = wka_port->d_id; -+ rec->lun = ZFCP_DBF_INVALID_LUN; -+ -+ rec->u.run.fsf_req_id = req_id; -+ rec->u.run.rec_status = ~0; -+ rec->u.run.rec_step = ~0; -+ rec->u.run.rec_action = ~0; -+ rec->u.run.rec_count = ~0; -+ -+ debug_event(dbf->rec, 1, rec, sizeof(*rec)); -+ spin_unlock_irqrestore(&dbf->rec_lock, flags); -+} -+ - static inline --void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, -- u64 req_id, u32 d_id) -+void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, -+ char *paytag, struct scatterlist *sg, u8 id, u16 len, -+ u64 req_id, u32 d_id, u16 cap_len) - { - struct zfcp_dbf_san *rec = &dbf->san_buf; - u16 rec_len; - unsigned long flags; -+ struct zfcp_dbf_pay *payload = &dbf->pay_buf; -+ u16 pay_sum = 0; - - spin_lock_irqsave(&dbf->san_lock, flags); - memset(rec, 0, sizeof(*rec)); -@@ -334,10 +372,41 @@ void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, - rec->id = id; - rec->fsf_req_id = req_id; - rec->d_id = d_id; -- rec_len = min(len, (u16)ZFCP_DBF_SAN_MAX_PAYLOAD); -- memcpy(rec->payload, data, rec_len); - memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); -+ rec->pl_len = len; /* full length even if we cap pay below */ -+ if (!sg) -+ goto out; -+ rec_len = min_t(unsigned int, sg->length, ZFCP_DBF_SAN_MAX_PAYLOAD); -+ memcpy(rec->payload, sg_virt(sg), rec_len); /* part of 1st sg entry */ -+ if (len <= rec_len) -+ goto out; /* skip pay record if full content in rec->payload */ -+ -+ /* if (len > rec_len): -+ * dump data up to cap_len ignoring small duplicate in rec->payload -+ */ -+ spin_lock(&dbf->pay_lock); -+ memset(payload, 0, sizeof(*payload)); -+ memcpy(payload->area, paytag, ZFCP_DBF_TAG_LEN); -+ payload->fsf_req_id = req_id; -+ payload->counter = 0; -+ for (; sg && pay_sum < cap_len; sg = sg_next(sg)) { -+ u16 pay_len, offset = 0; -+ -+ while (offset < sg->length && pay_sum < cap_len) { -+ pay_len = min((u16)ZFCP_DBF_PAY_MAX_REC, -+ (u16)(sg->length - offset)); -+ /* cap_len <= pay_sum < cap_len+ZFCP_DBF_PAY_MAX_REC */ -+ memcpy(payload->data, sg_virt(sg) + offset, pay_len); -+ debug_event(dbf->pay, 1, payload, -+ zfcp_dbf_plen(pay_len)); -+ payload->counter++; -+ offset += pay_len; -+ pay_sum += pay_len; -+ } -+ } -+ spin_unlock(&dbf->pay_lock); - -+out: - debug_event(dbf->san, 1, rec, sizeof(*rec)); - spin_unlock_irqrestore(&dbf->san_lock, flags); - } -@@ -354,9 +423,62 @@ void zfcp_dbf_san_req(char *tag, struct zfcp_fsf_req *fsf, u32 d_id) - struct zfcp_fsf_ct_els *ct_els = fsf->data; - u16 length; - -- length = (u16)(ct_els->req->length + FC_CT_HDR_LEN); -- zfcp_dbf_san(tag, dbf, sg_virt(ct_els->req), ZFCP_DBF_SAN_REQ, length, -- fsf->req_id, d_id); -+ length = (u16)zfcp_qdio_real_bytes(ct_els->req); -+ zfcp_dbf_san(tag, dbf, "san_req", ct_els->req, ZFCP_DBF_SAN_REQ, -+ length, fsf->req_id, d_id, length); -+} -+ -+static u16 zfcp_dbf_san_res_cap_len_if_gpn_ft(char *tag, -+ struct zfcp_fsf_req *fsf, -+ u16 len) -+{ -+ struct zfcp_fsf_ct_els *ct_els = fsf->data; -+ struct fc_ct_hdr *reqh = sg_virt(ct_els->req); -+ struct fc_ns_gid_ft *reqn = (struct fc_ns_gid_ft *)(reqh + 1); -+ struct scatterlist *resp_entry = ct_els->resp; -+ struct fc_gpn_ft_resp *acc; -+ int max_entries, x, last = 0; -+ -+ if (!(memcmp(tag, "fsscth2", 7) == 0 -+ && ct_els->d_id == FC_FID_DIR_SERV -+ && reqh->ct_rev == FC_CT_REV -+ && reqh->ct_in_id[0] == 0 -+ && reqh->ct_in_id[1] == 0 -+ && reqh->ct_in_id[2] == 0 -+ && reqh->ct_fs_type == FC_FST_DIR -+ && reqh->ct_fs_subtype == FC_NS_SUBTYPE -+ && reqh->ct_options == 0 -+ && reqh->_ct_resvd1 == 0 -+ && reqh->ct_cmd == FC_NS_GPN_FT -+ /* reqh->ct_mr_size can vary so do not match but read below */ -+ && reqh->_ct_resvd2 == 0 -+ && reqh->ct_reason == 0 -+ && reqh->ct_explan == 0 -+ && reqh->ct_vendor == 0 -+ && reqn->fn_resvd == 0 -+ && reqn->fn_domain_id_scope == 0 -+ && reqn->fn_area_id_scope == 0 -+ && reqn->fn_fc4_type == FC_TYPE_FCP)) -+ return len; /* not GPN_FT response so do not cap */ -+ -+ acc = sg_virt(resp_entry); -+ max_entries = (reqh->ct_mr_size * 4 / sizeof(struct fc_gpn_ft_resp)) -+ + 1 /* zfcp_fc_scan_ports: bytes correct, entries off-by-one -+ * to account for header as 1st pseudo "entry" */; -+ -+ /* the basic CT_IU preamble is the same size as one entry in the GPN_FT -+ * response, allowing us to skip special handling for it - just skip it -+ */ -+ for (x = 1; x < max_entries && !last; x++) { -+ if (x % (ZFCP_FC_GPN_FT_ENT_PAGE + 1)) -+ acc++; -+ else -+ acc = sg_virt(++resp_entry); -+ -+ last = acc->fp_flags & FC_NS_FID_LAST; -+ } -+ len = min(len, (u16)(x * sizeof(struct fc_gpn_ft_resp))); -+ return len; /* cap after last entry */ - } - - /** -@@ -370,9 +492,10 @@ void zfcp_dbf_san_res(char *tag, struct zfcp_fsf_req *fsf) - struct zfcp_fsf_ct_els *ct_els = fsf->data; - u16 length; - -- length = (u16)(ct_els->resp->length + FC_CT_HDR_LEN); -- zfcp_dbf_san(tag, dbf, sg_virt(ct_els->resp), ZFCP_DBF_SAN_RES, length, -- fsf->req_id, 0); -+ length = (u16)zfcp_qdio_real_bytes(ct_els->resp); -+ zfcp_dbf_san(tag, dbf, "san_res", ct_els->resp, ZFCP_DBF_SAN_RES, -+ length, fsf->req_id, ct_els->d_id, -+ zfcp_dbf_san_res_cap_len_if_gpn_ft(tag, fsf, length)); - } - - /** -@@ -386,11 +509,13 @@ void zfcp_dbf_san_in_els(char *tag, struct zfcp_fsf_req *fsf) - struct fsf_status_read_buffer *srb = - (struct fsf_status_read_buffer *) fsf->data; - u16 length; -+ struct scatterlist sg; - - length = (u16)(srb->length - - offsetof(struct fsf_status_read_buffer, payload)); -- zfcp_dbf_san(tag, dbf, srb->payload.data, ZFCP_DBF_SAN_ELS, length, -- fsf->req_id, ntoh24(srb->d_id)); -+ sg_init_one(&sg, srb->payload.data, length); -+ zfcp_dbf_san(tag, dbf, "san_els", &sg, ZFCP_DBF_SAN_ELS, length, -+ fsf->req_id, ntoh24(srb->d_id), length); - } - - /** -@@ -399,7 +524,8 @@ void zfcp_dbf_san_in_els(char *tag, struct zfcp_fsf_req *fsf) - * @sc: pointer to struct scsi_cmnd - * @fsf: pointer to struct zfcp_fsf_req - */ --void zfcp_dbf_scsi(char *tag, struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf) -+void zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *sc, -+ struct zfcp_fsf_req *fsf) - { - struct zfcp_adapter *adapter = - (struct zfcp_adapter *) sc->device->host->hostdata[0]; -@@ -442,7 +568,7 @@ void zfcp_dbf_scsi(char *tag, struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf) - } - } - -- debug_event(dbf->scsi, 1, rec, sizeof(*rec)); -+ debug_event(dbf->scsi, level, rec, sizeof(*rec)); - spin_unlock_irqrestore(&dbf->scsi_lock, flags); - } - -diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h -index 0be3d48681ae..36d07584271d 100644 ---- a/drivers/s390/scsi/zfcp_dbf.h -+++ b/drivers/s390/scsi/zfcp_dbf.h -@@ -2,7 +2,7 @@ - * zfcp device driver - * debug feature declarations - * -- * Copyright IBM Corp. 2008, 2010 -+ * Copyright IBM Corp. 2008, 2015 - */ - - #ifndef ZFCP_DBF_H -@@ -17,6 +17,11 @@ - - #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull - -+enum zfcp_dbf_pseudo_erp_act_type { -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD = 0xff, -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL = 0xfe, -+}; -+ - /** - * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action - * @ready: number of ready recovery actions -@@ -110,6 +115,7 @@ struct zfcp_dbf_san { - u32 d_id; - #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32) - char payload[ZFCP_DBF_SAN_MAX_PAYLOAD]; -+ u16 pl_len; - } __packed; - - /** -@@ -126,6 +132,8 @@ struct zfcp_dbf_hba_res { - u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE]; - u32 fsf_status; - u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; -+ u32 port_handle; -+ u32 lun_handle; - } __packed; - - /** -@@ -279,7 +287,7 @@ static inline - void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req) - { - if (debug_level_enabled(req->adapter->dbf->hba, level)) -- zfcp_dbf_hba_fsf_res(tag, req); -+ zfcp_dbf_hba_fsf_res(tag, level, req); - } - - /** -@@ -318,7 +326,7 @@ void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd, - scmd->device->host->hostdata[0]; - - if (debug_level_enabled(adapter->dbf->scsi, level)) -- zfcp_dbf_scsi(tag, scmd, req); -+ zfcp_dbf_scsi(tag, level, scmd, req); - } - - /** -diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c -index 3fb410977014..a59d678125bd 100644 ---- a/drivers/s390/scsi/zfcp_erp.c -+++ b/drivers/s390/scsi/zfcp_erp.c -@@ -3,7 +3,7 @@ - * - * Error Recovery Procedures (ERP). - * -- * Copyright IBM Corp. 2002, 2010 -+ * Copyright IBM Corp. 2002, 2015 - */ - - #define KMSG_COMPONENT "zfcp" -@@ -1217,8 +1217,14 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) - break; - - case ZFCP_ERP_ACTION_REOPEN_PORT: -- if (result == ZFCP_ERP_SUCCEEDED) -- zfcp_scsi_schedule_rport_register(port); -+ /* This switch case might also happen after a forced reopen -+ * was successfully done and thus overwritten with a new -+ * non-forced reopen at `ersfs_2'. In this case, we must not -+ * do the clean-up of the non-forced version. -+ */ -+ if (act->step != ZFCP_ERP_STEP_UNINITIALIZED) -+ if (result == ZFCP_ERP_SUCCEEDED) -+ zfcp_scsi_schedule_rport_register(port); - /* fall through */ - case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: - put_device(&port->dev); -diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h -index 5b500652572b..c8fed9fa1cca 100644 ---- a/drivers/s390/scsi/zfcp_ext.h -+++ b/drivers/s390/scsi/zfcp_ext.h -@@ -3,7 +3,7 @@ - * - * External function declarations. - * -- * Copyright IBM Corp. 2002, 2010 -+ * Copyright IBM Corp. 2002, 2015 - */ - - #ifndef ZFCP_EXT_H -@@ -35,8 +35,9 @@ extern void zfcp_dbf_adapter_unregister(struct zfcp_adapter *); - extern void zfcp_dbf_rec_trig(char *, struct zfcp_adapter *, - struct zfcp_port *, struct scsi_device *, u8, u8); - extern void zfcp_dbf_rec_run(char *, struct zfcp_erp_action *); -+extern void zfcp_dbf_rec_run_wka(char *, struct zfcp_fc_wka_port *, u64); - extern void zfcp_dbf_hba_fsf_uss(char *, struct zfcp_fsf_req *); --extern void zfcp_dbf_hba_fsf_res(char *, struct zfcp_fsf_req *); -+extern void zfcp_dbf_hba_fsf_res(char *, int, struct zfcp_fsf_req *); - extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *); - extern void zfcp_dbf_hba_berr(struct zfcp_dbf *, struct zfcp_fsf_req *); - extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **); -@@ -44,7 +45,8 @@ extern void zfcp_dbf_hba_basic(char *, struct zfcp_adapter *); - extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32); - extern void zfcp_dbf_san_res(char *, struct zfcp_fsf_req *); - extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *); --extern void zfcp_dbf_scsi(char *, struct scsi_cmnd *, struct zfcp_fsf_req *); -+extern void zfcp_dbf_scsi(char *, int, struct scsi_cmnd *, -+ struct zfcp_fsf_req *); - - /* zfcp_erp.c */ - extern void zfcp_erp_set_adapter_status(struct zfcp_adapter *, u32); -diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c -index 522a633c866a..75f820ca17b7 100644 ---- a/drivers/s390/scsi/zfcp_fsf.c -+++ b/drivers/s390/scsi/zfcp_fsf.c -@@ -3,7 +3,7 @@ - * - * Implementation of FSF commands. - * -- * Copyright IBM Corp. 2002, 2013 -+ * Copyright IBM Corp. 2002, 2015 - */ - - #define KMSG_COMPONENT "zfcp" -@@ -508,7 +508,10 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req) - fc_host_port_type(shost) = FC_PORTTYPE_PTP; - break; - case FSF_TOPO_FABRIC: -- fc_host_port_type(shost) = FC_PORTTYPE_NPORT; -+ if (bottom->connection_features & FSF_FEATURE_NPIV_MODE) -+ fc_host_port_type(shost) = FC_PORTTYPE_NPIV; -+ else -+ fc_host_port_type(shost) = FC_PORTTYPE_NPORT; - break; - case FSF_TOPO_AL: - fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; -@@ -613,7 +616,6 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req) - - if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) { - fc_host_permanent_port_name(shost) = bottom->wwpn; -- fc_host_port_type(shost) = FC_PORTTYPE_NPIV; - } else - fc_host_permanent_port_name(shost) = fc_host_port_name(shost); - fc_host_maxframe_size(shost) = bottom->maximum_frame_size; -@@ -982,8 +984,12 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, - if (zfcp_adapter_multi_buffer_active(adapter)) { - if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req)) - return -EIO; -+ qtcb->bottom.support.req_buf_length = -+ zfcp_qdio_real_bytes(sg_req); - if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_resp)) - return -EIO; -+ qtcb->bottom.support.resp_buf_length = -+ zfcp_qdio_real_bytes(sg_resp); - - zfcp_qdio_set_data_div(qdio, &req->qdio_req, - zfcp_qdio_sbale_count(sg_req)); -@@ -1073,6 +1079,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port, - - req->handler = zfcp_fsf_send_ct_handler; - req->qtcb->header.port_handle = wka_port->handle; -+ ct->d_id = wka_port->d_id; - req->data = ct; - - zfcp_dbf_san_req("fssct_1", req, wka_port->d_id); -@@ -1169,6 +1176,7 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id, - - hton24(req->qtcb->bottom.support.d_id, d_id); - req->handler = zfcp_fsf_send_els_handler; -+ els->d_id = d_id; - req->data = els; - - zfcp_dbf_san_req("fssels1", req, d_id); -@@ -1575,7 +1583,7 @@ out: - int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) - { - struct zfcp_qdio *qdio = wka_port->adapter->qdio; -- struct zfcp_fsf_req *req; -+ struct zfcp_fsf_req *req = NULL; - int retval = -EIO; - - spin_lock_irq(&qdio->req_q_lock); -@@ -1604,6 +1612,8 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) - zfcp_fsf_req_free(req); - out: - spin_unlock_irq(&qdio->req_q_lock); -+ if (req && !IS_ERR(req)) -+ zfcp_dbf_rec_run_wka("fsowp_1", wka_port, req->req_id); - return retval; - } - -@@ -1628,7 +1638,7 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req) - int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) - { - struct zfcp_qdio *qdio = wka_port->adapter->qdio; -- struct zfcp_fsf_req *req; -+ struct zfcp_fsf_req *req = NULL; - int retval = -EIO; - - spin_lock_irq(&qdio->req_q_lock); -@@ -1657,6 +1667,8 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) - zfcp_fsf_req_free(req); - out: - spin_unlock_irq(&qdio->req_q_lock); -+ if (req && !IS_ERR(req)) -+ zfcp_dbf_rec_run_wka("fscwp_1", wka_port, req->req_id); - return retval; - } - -diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h -index 57ae3ae1046d..be1c04b334c5 100644 ---- a/drivers/s390/scsi/zfcp_fsf.h -+++ b/drivers/s390/scsi/zfcp_fsf.h -@@ -3,7 +3,7 @@ - * - * Interface to the FSF support functions. - * -- * Copyright IBM Corp. 2002, 2010 -+ * Copyright IBM Corp. 2002, 2015 - */ - - #ifndef FSF_H -@@ -436,6 +436,7 @@ struct zfcp_blk_drv_data { - * @handler_data: data passed to handler function - * @port: Optional pointer to port for zfcp internal ELS (only test link ADISC) - * @status: used to pass error status to calling function -+ * @d_id: Destination ID of either open WKA port for CT or of D_ID for ELS - */ - struct zfcp_fsf_ct_els { - struct scatterlist *req; -@@ -444,6 +445,7 @@ struct zfcp_fsf_ct_els { - void *handler_data; - struct zfcp_port *port; - int status; -+ u32 d_id; - }; - - #endif /* FSF_H */ -diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c -index b3c6ff49103b..9069f98a1817 100644 ---- a/drivers/s390/scsi/zfcp_scsi.c -+++ b/drivers/s390/scsi/zfcp_scsi.c -@@ -3,7 +3,7 @@ - * - * Interface to Linux SCSI midlayer. - * -- * Copyright IBM Corp. 2002, 2013 -+ * Copyright IBM Corp. 2002, 2015 - */ - - #define KMSG_COMPONENT "zfcp" -@@ -556,6 +556,9 @@ static void zfcp_scsi_rport_register(struct zfcp_port *port) - ids.port_id = port->d_id; - ids.roles = FC_RPORT_ROLE_FCP_TARGET; - -+ zfcp_dbf_rec_trig("scpaddy", port->adapter, port, NULL, -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD, -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD); - rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids); - if (!rport) { - dev_err(&port->adapter->ccw_device->dev, -@@ -577,6 +580,9 @@ static void zfcp_scsi_rport_block(struct zfcp_port *port) - struct fc_rport *rport = port->rport; - - if (rport) { -+ zfcp_dbf_rec_trig("scpdely", port->adapter, port, NULL, -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL, -+ ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL); - fc_remote_port_delete(rport); - port->rport = NULL; - } -diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c -index a3860367b568..e9ce74afd13f 100644 ---- a/drivers/scsi/hpsa.c -+++ b/drivers/scsi/hpsa.c -@@ -3930,6 +3930,70 @@ static int hpsa_set_local_logical_count(struct ctlr_info *h, - return rc; - } - -+static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) -+{ -+ struct bmic_identify_physical_device *id_phys; -+ bool is_spare = false; -+ int rc; -+ -+ id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL); -+ if (!id_phys) -+ return false; -+ -+ rc = hpsa_bmic_id_physical_device(h, -+ lunaddrbytes, -+ GET_BMIC_DRIVE_NUMBER(lunaddrbytes), -+ id_phys, sizeof(*id_phys)); -+ if (rc == 0) -+ is_spare = (id_phys->more_flags >> 6) & 0x01; -+ -+ kfree(id_phys); -+ return is_spare; -+} -+ -+#define RPL_DEV_FLAG_NON_DISK 0x1 -+#define RPL_DEV_FLAG_UNCONFIG_DISK_REPORTING_SUPPORTED 0x2 -+#define RPL_DEV_FLAG_UNCONFIG_DISK 0x4 -+ -+#define BMIC_DEVICE_TYPE_ENCLOSURE 6 -+ -+static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, -+ struct ext_report_lun_entry *rle) -+{ -+ u8 device_flags; -+ u8 device_type; -+ -+ if (!MASKED_DEVICE(lunaddrbytes)) -+ return false; -+ -+ device_flags = rle->device_flags; -+ device_type = rle->device_type; -+ -+ if (device_flags & RPL_DEV_FLAG_NON_DISK) { -+ if (device_type == BMIC_DEVICE_TYPE_ENCLOSURE) -+ return false; -+ return true; -+ } -+ -+ if (!(device_flags & RPL_DEV_FLAG_UNCONFIG_DISK_REPORTING_SUPPORTED)) -+ return false; -+ -+ if (device_flags & RPL_DEV_FLAG_UNCONFIG_DISK) -+ return false; -+ -+ /* -+ * Spares may be spun down, we do not want to -+ * do an Inquiry to a RAID set spare drive as -+ * that would have them spun up, that is a -+ * performance hit because I/O to the RAID device -+ * stops while the spin up occurs which can take -+ * over 50 seconds. -+ */ -+ if (hpsa_is_disk_spare(h, lunaddrbytes)) -+ return true; -+ -+ return false; -+} - - static void hpsa_update_scsi_devices(struct ctlr_info *h) - { -@@ -4023,6 +4087,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) - u8 *lunaddrbytes, is_OBDR = 0; - int rc = 0; - int phys_dev_index = i - (raid_ctlr_position == 0); -+ bool skip_device = false; - - physical_device = i < nphysicals + (raid_ctlr_position == 0); - -@@ -4030,10 +4095,15 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) - lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, - i, nphysicals, nlogicals, physdev_list, logdev_list); - -- /* skip masked non-disk devices */ -- if (MASKED_DEVICE(lunaddrbytes) && physical_device && -- (physdev_list->LUN[phys_dev_index].device_flags & 0x01)) -- continue; -+ /* -+ * Skip over some devices such as a spare. -+ */ -+ if (!tmpdevice->external && physical_device) { -+ skip_device = hpsa_skip_device(h, lunaddrbytes, -+ &physdev_list->LUN[phys_dev_index]); -+ if (skip_device) -+ continue; -+ } - - /* Get device type, vendor, model, device id */ - rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, -diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c -index f0cfaacbfabd..692445bcca6f 100644 ---- a/drivers/scsi/scsi_scan.c -+++ b/drivers/scsi/scsi_scan.c -@@ -1459,12 +1459,12 @@ retry: - out_err: - kfree(lun_data); - out: -- scsi_device_put(sdev); - if (scsi_device_created(sdev)) - /* - * the sdev we used didn't appear in the report luns scan - */ - __scsi_remove_device(sdev); -+ scsi_device_put(sdev); - return ret; - } - -diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c -index 0d7c6e86f149..6ee50742f6a5 100644 ---- a/drivers/scsi/sd.c -+++ b/drivers/scsi/sd.c -@@ -2879,10 +2879,10 @@ static int sd_revalidate_disk(struct gendisk *disk) - if (sdkp->opt_xfer_blocks && - sdkp->opt_xfer_blocks <= dev_max && - sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && -- sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE) -- rw_max = q->limits.io_opt = -- sdkp->opt_xfer_blocks * sdp->sector_size; -- else -+ logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_CACHE_SIZE) { -+ q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); -+ rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); -+ } else - rw_max = BLK_DEF_MAX_SECTORS; - - /* Combine with controller limits */ -diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h -index 654630bb7d0e..765a6f1ac1b7 100644 ---- a/drivers/scsi/sd.h -+++ b/drivers/scsi/sd.h -@@ -151,6 +151,11 @@ static inline sector_t logical_to_sectors(struct scsi_device *sdev, sector_t blo - return blocks << (ilog2(sdev->sector_size) - 9); - } - -+static inline unsigned int logical_to_bytes(struct scsi_device *sdev, sector_t blocks) -+{ -+ return blocks * sdev->sector_size; -+} -+ - /* - * A DIF-capable target device can be formatted with different - * protection schemes. Currently 0 through 3 are defined: -diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c -index 7bc3778a1ac9..2a67af4e2e13 100644 ---- a/drivers/target/target_core_transport.c -+++ b/drivers/target/target_core_transport.c -@@ -1680,6 +1680,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, - case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED: - case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED: - case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED: -+ case TCM_COPY_TARGET_DEVICE_NOT_REACHABLE: - break; - case TCM_OUT_OF_RESOURCES: - sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; -@@ -2509,8 +2510,10 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref) - * fabric acknowledgement that requires two target_put_sess_cmd() - * invocations before se_cmd descriptor release. - */ -- if (ack_kref) -+ if (ack_kref) { - kref_get(&se_cmd->cmd_kref); -+ se_cmd->se_cmd_flags |= SCF_ACK_KREF; -+ } - - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); - if (se_sess->sess_tearing_down) { -@@ -2833,6 +2836,12 @@ static const struct sense_info sense_info_table[] = { - .ascq = 0x03, /* LOGICAL BLOCK REFERENCE TAG CHECK FAILED */ - .add_sector_info = true, - }, -+ [TCM_COPY_TARGET_DEVICE_NOT_REACHABLE] = { -+ .key = COPY_ABORTED, -+ .asc = 0x0d, -+ .ascq = 0x02, /* COPY TARGET DEVICE NOT REACHABLE */ -+ -+ }, - [TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE] = { - /* - * Returning ILLEGAL REQUEST would cause immediate IO errors on -diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c -index 47fe94ee10b8..153a6f255b6d 100644 ---- a/drivers/target/target_core_xcopy.c -+++ b/drivers/target/target_core_xcopy.c -@@ -104,7 +104,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op - } - mutex_unlock(&g_device_mutex); - -- pr_err("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n"); -+ pr_debug_ratelimited("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n"); - return -EINVAL; - } - -@@ -185,7 +185,7 @@ static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op - - static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd, - struct xcopy_op *xop, unsigned char *p, -- unsigned short tdll) -+ unsigned short tdll, sense_reason_t *sense_ret) - { - struct se_device *local_dev = se_cmd->se_dev; - unsigned char *desc = p; -@@ -193,6 +193,8 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd, - unsigned short start = 0; - bool src = true; - -+ *sense_ret = TCM_INVALID_PARAMETER_LIST; -+ - if (offset != 0) { - pr_err("XCOPY target descriptor list length is not" - " multiple of %d\n", XCOPY_TARGET_DESC_LEN); -@@ -243,9 +245,16 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd, - rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, true); - else - rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, false); -- -- if (rc < 0) -+ /* -+ * If a matching IEEE NAA 0x83 descriptor for the requested device -+ * is not located on this node, return COPY_ABORTED with ASQ/ASQC -+ * 0x0d/0x02 - COPY_TARGET_DEVICE_NOT_REACHABLE to request the -+ * initiator to fall back to normal copy method. -+ */ -+ if (rc < 0) { -+ *sense_ret = TCM_COPY_TARGET_DEVICE_NOT_REACHABLE; - goto out; -+ } - - pr_debug("XCOPY TGT desc: Source dev: %p NAA IEEE WWN: 0x%16phN\n", - xop->src_dev, &xop->src_tid_wwn[0]); -@@ -653,6 +662,7 @@ static int target_xcopy_read_source( - rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0], - remote_port, true); - if (rc < 0) { -+ ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status; - transport_generic_free_cmd(se_cmd, 0); - return rc; - } -@@ -664,6 +674,7 @@ static int target_xcopy_read_source( - - rc = target_xcopy_issue_pt_cmd(xpt_cmd); - if (rc < 0) { -+ ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status; - transport_generic_free_cmd(se_cmd, 0); - return rc; - } -@@ -714,6 +725,7 @@ static int target_xcopy_write_destination( - remote_port, false); - if (rc < 0) { - struct se_cmd *src_cmd = &xop->src_pt_cmd->se_cmd; -+ ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status; - /* - * If the failure happened before the t_mem_list hand-off in - * target_xcopy_setup_pt_cmd(), Reset memory + clear flag so that -@@ -729,6 +741,7 @@ static int target_xcopy_write_destination( - - rc = target_xcopy_issue_pt_cmd(xpt_cmd); - if (rc < 0) { -+ ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status; - se_cmd->se_cmd_flags &= ~SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC; - transport_generic_free_cmd(se_cmd, 0); - return rc; -@@ -815,9 +828,14 @@ static void target_xcopy_do_work(struct work_struct *work) - out: - xcopy_pt_undepend_remotedev(xop); - kfree(xop); -- -- pr_warn("target_xcopy_do_work: Setting X-COPY CHECK_CONDITION -> sending response\n"); -- ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION; -+ /* -+ * Don't override an error scsi status if it has already been set -+ */ -+ if (ec_cmd->scsi_status == SAM_STAT_GOOD) { -+ pr_warn_ratelimited("target_xcopy_do_work: rc: %d, Setting X-COPY" -+ " CHECK_CONDITION -> sending response\n", rc); -+ ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION; -+ } - target_complete_cmd(ec_cmd, SAM_STAT_CHECK_CONDITION); - } - -@@ -875,7 +893,7 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) - " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, - tdll, sdll, inline_dl); - -- rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll); -+ rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll, &ret); - if (rc <= 0) - goto out; - -diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c -index 95d293b7445a..dc2fcda54d53 100644 ---- a/drivers/video/fbdev/efifb.c -+++ b/drivers/video/fbdev/efifb.c -@@ -52,9 +52,9 @@ static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green, - return 1; - - if (regno < 16) { -- red >>= 8; -- green >>= 8; -- blue >>= 8; -+ red >>= 16 - info->var.red.length; -+ green >>= 16 - info->var.green.length; -+ blue >>= 16 - info->var.blue.length; - ((u32 *)(info->pseudo_palette))[regno] = - (red << info->var.red.offset) | - (green << info->var.green.offset) | -diff --git a/fs/ceph/file.c b/fs/ceph/file.c -index 3c68e6aee2f0..c8222bfe1e56 100644 ---- a/fs/ceph/file.c -+++ b/fs/ceph/file.c -@@ -929,7 +929,8 @@ again: - statret = __ceph_do_getattr(inode, page, - CEPH_STAT_CAP_INLINE_DATA, !!page); - if (statret < 0) { -- __free_page(page); -+ if (page) -+ __free_page(page); - if (statret == -ENODATA) { - BUG_ON(retry_op != READ_INLINE); - goto again; -diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c -index 50b268483302..0a3544fb50f9 100644 ---- a/fs/cifs/cifs_debug.c -+++ b/fs/cifs/cifs_debug.c -@@ -152,6 +152,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) - list_for_each(tmp1, &cifs_tcp_ses_list) { - server = list_entry(tmp1, struct TCP_Server_Info, - tcp_ses_list); -+ seq_printf(m, "\nNumber of credits: %d", server->credits); - i++; - list_for_each(tmp2, &server->smb_ses_list) { - ses = list_entry(tmp2, struct cifs_ses, -@@ -255,7 +256,6 @@ static const struct file_operations cifs_debug_data_proc_fops = { - static ssize_t cifs_stats_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) - { -- char c; - bool bv; - int rc; - struct list_head *tmp1, *tmp2, *tmp3; -@@ -263,11 +263,8 @@ static ssize_t cifs_stats_proc_write(struct file *file, - struct cifs_ses *ses; - struct cifs_tcon *tcon; - -- rc = get_user(c, buffer); -- if (rc) -- return rc; -- -- if (strtobool(&c, &bv) == 0) { -+ rc = kstrtobool_from_user(buffer, count, &bv); -+ if (rc == 0) { - #ifdef CONFIG_CIFS_STATS2 - atomic_set(&totBufAllocCount, 0); - atomic_set(&totSmBufAllocCount, 0); -@@ -290,6 +287,8 @@ static ssize_t cifs_stats_proc_write(struct file *file, - } - } - spin_unlock(&cifs_tcp_ses_lock); -+ } else { -+ return rc; - } - - return count; -@@ -433,17 +432,17 @@ static int cifsFYI_proc_open(struct inode *inode, struct file *file) - static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) - { -- char c; -+ char c[2] = { '\0' }; - bool bv; - int rc; - -- rc = get_user(c, buffer); -+ rc = get_user(c[0], buffer); - if (rc) - return rc; -- if (strtobool(&c, &bv) == 0) -+ if (strtobool(c, &bv) == 0) - cifsFYI = bv; -- else if ((c > '1') && (c <= '9')) -- cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ -+ else if ((c[0] > '1') && (c[0] <= '9')) -+ cifsFYI = (int) (c[0] - '0'); /* see cifs_debug.h for meanings */ - - return count; - } -@@ -471,20 +470,12 @@ static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file) - static ssize_t cifs_linux_ext_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) - { -- char c; -- bool bv; - int rc; - -- rc = get_user(c, buffer); -+ rc = kstrtobool_from_user(buffer, count, &linuxExtEnabled); - if (rc) - return rc; - -- rc = strtobool(&c, &bv); -- if (rc) -- return rc; -- -- linuxExtEnabled = bv; -- - return count; - } - -@@ -511,20 +502,12 @@ static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file) - static ssize_t cifs_lookup_cache_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) - { -- char c; -- bool bv; - int rc; - -- rc = get_user(c, buffer); -+ rc = kstrtobool_from_user(buffer, count, &lookupCacheEnabled); - if (rc) - return rc; - -- rc = strtobool(&c, &bv); -- if (rc) -- return rc; -- -- lookupCacheEnabled = bv; -- - return count; - } - -@@ -551,20 +534,12 @@ static int traceSMB_proc_open(struct inode *inode, struct file *file) - static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) - { -- char c; -- bool bv; - int rc; - -- rc = get_user(c, buffer); -+ rc = kstrtobool_from_user(buffer, count, &traceSMB); - if (rc) - return rc; - -- rc = strtobool(&c, &bv); -- if (rc) -- return rc; -- -- traceSMB = bv; -- - return count; - } - -@@ -622,7 +597,6 @@ static ssize_t cifs_security_flags_proc_write(struct file *file, - int rc; - unsigned int flags; - char flags_string[12]; -- char c; - bool bv; - - if ((count < 1) || (count > 11)) -@@ -635,11 +609,10 @@ static ssize_t cifs_security_flags_proc_write(struct file *file, - - if (count < 3) { - /* single char or single char followed by null */ -- c = flags_string[0]; -- if (strtobool(&c, &bv) == 0) { -+ if (strtobool(flags_string, &bv) == 0) { - global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF; - return count; -- } else if (!isdigit(c)) { -+ } else if (!isdigit(flags_string[0])) { - cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", - flags_string); - return -EINVAL; -diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h -index 66cf0f9fff89..c611ca2339d7 100644 ---- a/fs/cifs/cifs_debug.h -+++ b/fs/cifs/cifs_debug.h -@@ -25,7 +25,7 @@ - void cifs_dump_mem(char *label, void *data, int length); - void cifs_dump_detail(void *); - void cifs_dump_mids(struct TCP_Server_Info *); --extern int traceSMB; /* flag which enables the function below */ -+extern bool traceSMB; /* flag which enables the function below */ - void dump_smb(void *, int); - #define CIFS_INFO 0x01 - #define CIFS_RC 0x02 -diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c -index 450578097fb7..4f4fc9ff3636 100644 ---- a/fs/cifs/cifsfs.c -+++ b/fs/cifs/cifsfs.c -@@ -54,10 +54,10 @@ - #endif - - int cifsFYI = 0; --int traceSMB = 0; -+bool traceSMB; - bool enable_oplocks = true; --unsigned int linuxExtEnabled = 1; --unsigned int lookupCacheEnabled = 1; -+bool linuxExtEnabled = true; -+bool lookupCacheEnabled = true; - unsigned int global_secflags = CIFSSEC_DEF; - /* unsigned int ntlmv2_support = 0; */ - unsigned int sign_CIFS_PDUs = 1; -@@ -268,7 +268,7 @@ cifs_alloc_inode(struct super_block *sb) - cifs_inode->createtime = 0; - cifs_inode->epoch = 0; - #ifdef CONFIG_CIFS_SMB2 -- get_random_bytes(cifs_inode->lease_key, SMB2_LEASE_KEY_SIZE); -+ generate_random_uuid(cifs_inode->lease_key); - #endif - /* - * Can not set i_flags here - they get immediately overwritten to zero -@@ -1210,7 +1210,6 @@ init_cifs(void) - GlobalTotalActiveXid = 0; - GlobalMaxActiveXid = 0; - spin_lock_init(&cifs_tcp_ses_lock); -- spin_lock_init(&cifs_file_list_lock); - spin_lock_init(&GlobalMid_Lock); - - if (cifs_max_pending < 2) { -diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h -index 2b510c537a0d..c669a1471395 100644 ---- a/fs/cifs/cifsglob.h -+++ b/fs/cifs/cifsglob.h -@@ -827,6 +827,7 @@ struct cifs_tcon { - struct list_head tcon_list; - int tc_count; - struct list_head openFileList; -+ spinlock_t open_file_lock; /* protects list above */ - struct cifs_ses *ses; /* pointer to session associated with */ - char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ - char *nativeFileSystem; -@@ -883,7 +884,7 @@ struct cifs_tcon { - #endif /* CONFIG_CIFS_STATS2 */ - __u64 bytes_read; - __u64 bytes_written; -- spinlock_t stat_lock; -+ spinlock_t stat_lock; /* protects the two fields above */ - #endif /* CONFIG_CIFS_STATS */ - FILE_SYSTEM_DEVICE_INFO fsDevInfo; - FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */ -@@ -1034,8 +1035,10 @@ struct cifs_fid_locks { - }; - - struct cifsFileInfo { -+ /* following two lists are protected by tcon->open_file_lock */ - struct list_head tlist; /* pointer to next fid owned by tcon */ - struct list_head flist; /* next fid (file instance) for this inode */ -+ /* lock list below protected by cifsi->lock_sem */ - struct cifs_fid_locks *llist; /* brlocks held by this fid */ - kuid_t uid; /* allows finding which FileInfo structure */ - __u32 pid; /* process id who opened file */ -@@ -1043,11 +1046,12 @@ struct cifsFileInfo { - /* BB add lock scope info here if needed */ ; - /* lock scope id (0 if none) */ - struct dentry *dentry; -- unsigned int f_flags; - struct tcon_link *tlink; -+ unsigned int f_flags; - bool invalidHandle:1; /* file closed via session abend */ - bool oplock_break_cancelled:1; -- int count; /* refcount protected by cifs_file_list_lock */ -+ int count; -+ spinlock_t file_info_lock; /* protects four flag/count fields above */ - struct mutex fh_mutex; /* prevents reopen race after dead ses*/ - struct cifs_search_info srch_inf; - struct work_struct oplock_break; /* work for oplock breaks */ -@@ -1114,7 +1118,7 @@ struct cifs_writedata { - - /* - * Take a reference on the file private data. Must be called with -- * cifs_file_list_lock held. -+ * cfile->file_info_lock held. - */ - static inline void - cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file) -@@ -1508,8 +1512,10 @@ require use of the stronger protocol */ - * GlobalMid_Lock protects: - * list operations on pending_mid_q and oplockQ - * updates to XID counters, multiplex id and SMB sequence numbers -- * cifs_file_list_lock protects: -- * list operations on tcp and SMB session lists and tCon lists -+ * tcp_ses_lock protects: -+ * list operations on tcp and SMB session lists -+ * tcon->open_file_lock protects the list of open files hanging off the tcon -+ * cfile->file_info_lock protects counters and fields in cifs file struct - * f_owner.lock protects certain per file struct operations - * mapping->page_lock protects certain per page operations - * -@@ -1541,18 +1547,12 @@ GLOBAL_EXTERN struct list_head cifs_tcp_ses_list; - * tcp session, and the list of tcon's per smb session. It also protects - * the reference counters for the server, smb session, and tcon. Finally, - * changes to the tcon->tidStatus should be done while holding this lock. -+ * generally the locks should be taken in order tcp_ses_lock before -+ * tcon->open_file_lock and that before file->file_info_lock since the -+ * structure order is cifs_socket-->cifs_ses-->cifs_tcon-->cifs_file - */ - GLOBAL_EXTERN spinlock_t cifs_tcp_ses_lock; - --/* -- * This lock protects the cifs_file->llist and cifs_file->flist -- * list operations, and updates to some flags (cifs_file->invalidHandle) -- * It will be moved to either use the tcon->stat_lock or equivalent later. -- * If cifs_tcp_ses_lock and the lock below are both needed to be held, then -- * the cifs_tcp_ses_lock must be grabbed first and released last. -- */ --GLOBAL_EXTERN spinlock_t cifs_file_list_lock; -- - #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */ - /* Outstanding dir notify requests */ - GLOBAL_EXTERN struct list_head GlobalDnotifyReqList; -@@ -1588,11 +1588,11 @@ GLOBAL_EXTERN atomic_t midCount; - - /* Misc globals */ - GLOBAL_EXTERN bool enable_oplocks; /* enable or disable oplocks */ --GLOBAL_EXTERN unsigned int lookupCacheEnabled; -+GLOBAL_EXTERN bool lookupCacheEnabled; - GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent - with more secure ntlmssp2 challenge/resp */ - GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */ --GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/ -+GLOBAL_EXTERN bool linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/ - GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */ - GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */ - GLOBAL_EXTERN unsigned int cifs_min_small; /* min size of small buf pool */ -diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c -index 76fcb50295a3..b1104ed8f54c 100644 ---- a/fs/cifs/cifssmb.c -+++ b/fs/cifs/cifssmb.c -@@ -98,13 +98,13 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon) - struct list_head *tmp1; - - /* list all files open on tree connection and mark them invalid */ -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - list_for_each_safe(tmp, tmp1, &tcon->openFileList) { - open_file = list_entry(tmp, struct cifsFileInfo, tlist); - open_file->invalidHandle = true; - open_file->oplock_break_cancelled = true; - } -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - /* - * BB Add call to invalidate_inodes(sb) for all superblocks mounted - * to this tcon. -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c -index 61c3a5ab8637..812a8cb07c63 100644 ---- a/fs/cifs/connect.c -+++ b/fs/cifs/connect.c -@@ -2200,7 +2200,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) - memcpy(&tcp_ses->dstaddr, &volume_info->dstaddr, - sizeof(tcp_ses->dstaddr)); - #ifdef CONFIG_CIFS_SMB2 -- get_random_bytes(tcp_ses->client_guid, SMB2_CLIENT_GUID_SIZE); -+ generate_random_uuid(tcp_ses->client_guid); - #endif - /* - * at this point we are the only ones with the pointer -@@ -3693,14 +3693,16 @@ remote_path_check: - goto mount_fail_check; - } - -- rc = cifs_are_all_path_components_accessible(server, -+ if (rc != -EREMOTE) { -+ rc = cifs_are_all_path_components_accessible(server, - xid, tcon, cifs_sb, - full_path); -- if (rc != 0) { -- cifs_dbg(VFS, "cannot query dirs between root and final path, " -- "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); -- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; -- rc = 0; -+ if (rc != 0) { -+ cifs_dbg(VFS, "cannot query dirs between root and final path, " -+ "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); -+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; -+ rc = 0; -+ } - } - kfree(full_path); - } -diff --git a/fs/cifs/file.c b/fs/cifs/file.c -index 0068e82217c3..72f270d4bd17 100644 ---- a/fs/cifs/file.c -+++ b/fs/cifs/file.c -@@ -305,6 +305,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, - cfile->tlink = cifs_get_tlink(tlink); - INIT_WORK(&cfile->oplock_break, cifs_oplock_break); - mutex_init(&cfile->fh_mutex); -+ spin_lock_init(&cfile->file_info_lock); - - cifs_sb_active(inode->i_sb); - -@@ -317,7 +318,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, - oplock = 0; - } - -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - if (fid->pending_open->oplock != CIFS_OPLOCK_NO_CHANGE && oplock) - oplock = fid->pending_open->oplock; - list_del(&fid->pending_open->olist); -@@ -326,12 +327,13 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, - server->ops->set_fid(cfile, fid, oplock); - - list_add(&cfile->tlist, &tcon->openFileList); -+ - /* if readable file instance put first in list*/ - if (file->f_mode & FMODE_READ) - list_add(&cfile->flist, &cinode->openFileList); - else - list_add_tail(&cfile->flist, &cinode->openFileList); -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - - if (fid->purge_cache) - cifs_zap_mapping(inode); -@@ -343,16 +345,16 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, - struct cifsFileInfo * - cifsFileInfo_get(struct cifsFileInfo *cifs_file) - { -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&cifs_file->file_info_lock); - cifsFileInfo_get_locked(cifs_file); -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cifs_file->file_info_lock); - return cifs_file; - } - - /* - * Release a reference on the file private data. This may involve closing - * the filehandle out on the server. Must be called without holding -- * cifs_file_list_lock. -+ * tcon->open_file_lock and cifs_file->file_info_lock. - */ - void cifsFileInfo_put(struct cifsFileInfo *cifs_file) - { -@@ -367,11 +369,15 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file) - struct cifs_pending_open open; - bool oplock_break_cancelled; - -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); -+ -+ spin_lock(&cifs_file->file_info_lock); - if (--cifs_file->count > 0) { -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cifs_file->file_info_lock); -+ spin_unlock(&tcon->open_file_lock); - return; - } -+ spin_unlock(&cifs_file->file_info_lock); - - if (server->ops->get_lease_key) - server->ops->get_lease_key(inode, &fid); -@@ -395,7 +401,8 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file) - set_bit(CIFS_INO_INVALID_MAPPING, &cifsi->flags); - cifs_set_oplock_level(cifsi, 0); - } -- spin_unlock(&cifs_file_list_lock); -+ -+ spin_unlock(&tcon->open_file_lock); - - oplock_break_cancelled = cancel_work_sync(&cifs_file->oplock_break); - -@@ -772,10 +779,10 @@ int cifs_closedir(struct inode *inode, struct file *file) - server = tcon->ses->server; - - cifs_dbg(FYI, "Freeing private data in close dir\n"); -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&cfile->file_info_lock); - if (server->ops->dir_needs_close(cfile)) { - cfile->invalidHandle = true; -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cfile->file_info_lock); - if (server->ops->close_dir) - rc = server->ops->close_dir(xid, tcon, &cfile->fid); - else -@@ -784,7 +791,7 @@ int cifs_closedir(struct inode *inode, struct file *file) - /* not much we can do if it fails anyway, ignore rc */ - rc = 0; - } else -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cfile->file_info_lock); - - buf = cfile->srch_inf.ntwrk_buf_start; - if (buf) { -@@ -1720,12 +1727,13 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, - { - struct cifsFileInfo *open_file = NULL; - struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); -+ struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); - - /* only filter by fsuid on multiuser mounts */ - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) - fsuid_only = false; - -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - /* we could simply get the first_list_entry since write-only entries - are always at the end of the list but since the first entry might - have a close pending, we go through the whole list */ -@@ -1736,8 +1744,8 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, - if (!open_file->invalidHandle) { - /* found a good file */ - /* lock it so it will not be closed on us */ -- cifsFileInfo_get_locked(open_file); -- spin_unlock(&cifs_file_list_lock); -+ cifsFileInfo_get(open_file); -+ spin_unlock(&tcon->open_file_lock); - return open_file; - } /* else might as well continue, and look for - another, or simply have the caller reopen it -@@ -1745,7 +1753,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, - } else /* write only file */ - break; /* write only files are last so must be done */ - } -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - return NULL; - } - -@@ -1754,6 +1762,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, - { - struct cifsFileInfo *open_file, *inv_file = NULL; - struct cifs_sb_info *cifs_sb; -+ struct cifs_tcon *tcon; - bool any_available = false; - int rc; - unsigned int refind = 0; -@@ -1769,15 +1778,16 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, - } - - cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); -+ tcon = cifs_sb_master_tcon(cifs_sb); - - /* only filter by fsuid on multiuser mounts */ - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) - fsuid_only = false; - -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - refind_writable: - if (refind > MAX_REOPEN_ATT) { -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - return NULL; - } - list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { -@@ -1788,8 +1798,8 @@ refind_writable: - if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { - if (!open_file->invalidHandle) { - /* found a good writable file */ -- cifsFileInfo_get_locked(open_file); -- spin_unlock(&cifs_file_list_lock); -+ cifsFileInfo_get(open_file); -+ spin_unlock(&tcon->open_file_lock); - return open_file; - } else { - if (!inv_file) -@@ -1805,24 +1815,24 @@ refind_writable: - - if (inv_file) { - any_available = false; -- cifsFileInfo_get_locked(inv_file); -+ cifsFileInfo_get(inv_file); - } - -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - - if (inv_file) { - rc = cifs_reopen_file(inv_file, false); - if (!rc) - return inv_file; - else { -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - list_move_tail(&inv_file->flist, - &cifs_inode->openFileList); -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - cifsFileInfo_put(inv_file); -- spin_lock(&cifs_file_list_lock); - ++refind; - inv_file = NULL; -+ spin_lock(&tcon->open_file_lock); - goto refind_writable; - } - } -@@ -3632,15 +3642,17 @@ static int cifs_readpage(struct file *file, struct page *page) - static int is_inode_writable(struct cifsInodeInfo *cifs_inode) - { - struct cifsFileInfo *open_file; -+ struct cifs_tcon *tcon = -+ cifs_sb_master_tcon(CIFS_SB(cifs_inode->vfs_inode.i_sb)); - -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { - if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - return 1; - } - } -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - return 0; - } - -diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c -index 8442b8b8e0be..2396ab099849 100644 ---- a/fs/cifs/misc.c -+++ b/fs/cifs/misc.c -@@ -120,6 +120,7 @@ tconInfoAlloc(void) - ++ret_buf->tc_count; - INIT_LIST_HEAD(&ret_buf->openFileList); - INIT_LIST_HEAD(&ret_buf->tcon_list); -+ spin_lock_init(&ret_buf->open_file_lock); - #ifdef CONFIG_CIFS_STATS - spin_lock_init(&ret_buf->stat_lock); - #endif -@@ -465,7 +466,7 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv) - continue; - - cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks); -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - list_for_each(tmp2, &tcon->openFileList) { - netfile = list_entry(tmp2, struct cifsFileInfo, - tlist); -@@ -495,11 +496,11 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv) - &netfile->oplock_break); - netfile->oplock_break_cancelled = false; - -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - return true; - } -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - cifs_dbg(FYI, "No matching file for oplock break\n"); - return true; -@@ -613,9 +614,9 @@ backup_cred(struct cifs_sb_info *cifs_sb) - void - cifs_del_pending_open(struct cifs_pending_open *open) - { -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tlink_tcon(open->tlink)->open_file_lock); - list_del(&open->olist); -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tlink_tcon(open->tlink)->open_file_lock); - } - - void -@@ -635,7 +636,7 @@ void - cifs_add_pending_open(struct cifs_fid *fid, struct tcon_link *tlink, - struct cifs_pending_open *open) - { -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tlink_tcon(tlink)->open_file_lock); - cifs_add_pending_open_locked(fid, tlink, open); -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tlink_tcon(open->tlink)->open_file_lock); - } -diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c -index b30a4a6d98a0..833e5844a2db 100644 ---- a/fs/cifs/readdir.c -+++ b/fs/cifs/readdir.c -@@ -594,14 +594,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos, - is_dir_changed(file)) || (index_to_find < first_entry_in_buffer)) { - /* close and restart search */ - cifs_dbg(FYI, "search backing up - close and restart search\n"); -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&cfile->file_info_lock); - if (server->ops->dir_needs_close(cfile)) { - cfile->invalidHandle = true; -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cfile->file_info_lock); - if (server->ops->close_dir) - server->ops->close_dir(xid, tcon, &cfile->fid); - } else -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&cfile->file_info_lock); - if (cfile->srch_inf.ntwrk_buf_start) { - cifs_dbg(FYI, "freeing SMB ff cache buf on search rewind\n"); - if (cfile->srch_inf.smallBuf) -diff --git a/fs/cifs/smb2glob.h b/fs/cifs/smb2glob.h -index 0ffa18094335..238759c146ba 100644 ---- a/fs/cifs/smb2glob.h -+++ b/fs/cifs/smb2glob.h -@@ -61,4 +61,14 @@ - /* Maximum buffer size value we can send with 1 credit */ - #define SMB2_MAX_BUFFER_SIZE 65536 - -+/* -+ * Maximum number of credits to keep available. -+ * This value is chosen somewhat arbitrarily. The Windows client -+ * defaults to 128 credits, the Windows server allows clients up to -+ * 512 credits, and the NetApp server does not limit clients at all. -+ * Choose a high enough value such that the client shouldn't limit -+ * performance. -+ */ -+#define SMB2_MAX_CREDITS_AVAILABLE 32000 -+ - #endif /* _SMB2_GLOB_H */ -diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c -index 4f0231e685a9..1238cd3552f9 100644 ---- a/fs/cifs/smb2inode.c -+++ b/fs/cifs/smb2inode.c -@@ -266,9 +266,15 @@ smb2_set_file_info(struct inode *inode, const char *full_path, - struct tcon_link *tlink; - int rc; - -+ if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) && -+ (buf->LastWriteTime == 0) && (buf->ChangeTime) && -+ (buf->Attributes == 0)) -+ return 0; /* would be a no op, no sense sending this */ -+ - tlink = cifs_sb_tlink(cifs_sb); - if (IS_ERR(tlink)) - return PTR_ERR(tlink); -+ - rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path, - FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf, - SMB2_OP_SET_INFO); -diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c -index 1c5907019045..e5bc85e49be7 100644 ---- a/fs/cifs/smb2misc.c -+++ b/fs/cifs/smb2misc.c -@@ -525,19 +525,19 @@ smb2_is_valid_lease_break(char *buffer) - list_for_each(tmp1, &server->smb_ses_list) { - ses = list_entry(tmp1, struct cifs_ses, smb_ses_list); - -- spin_lock(&cifs_file_list_lock); - list_for_each(tmp2, &ses->tcon_list) { - tcon = list_entry(tmp2, struct cifs_tcon, - tcon_list); -+ spin_lock(&tcon->open_file_lock); - cifs_stats_inc( - &tcon->stats.cifs_stats.num_oplock_brks); - if (smb2_tcon_has_lease(tcon, rsp, lw)) { -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - return true; - } -+ spin_unlock(&tcon->open_file_lock); - } -- spin_unlock(&cifs_file_list_lock); - } - } - spin_unlock(&cifs_tcp_ses_lock); -@@ -579,7 +579,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) - tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); - - cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks); -- spin_lock(&cifs_file_list_lock); -+ spin_lock(&tcon->open_file_lock); - list_for_each(tmp2, &tcon->openFileList) { - cfile = list_entry(tmp2, struct cifsFileInfo, - tlist); -@@ -591,7 +591,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) - - cifs_dbg(FYI, "file id match, oplock break\n"); - cinode = CIFS_I(d_inode(cfile->dentry)); -- -+ spin_lock(&cfile->file_info_lock); - if (!CIFS_CACHE_WRITE(cinode) && - rsp->OplockLevel == SMB2_OPLOCK_LEVEL_NONE) - cfile->oplock_break_cancelled = true; -@@ -613,14 +613,14 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) - clear_bit( - CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2, - &cinode->flags); -- -+ spin_unlock(&cfile->file_info_lock); - queue_work(cifsiod_wq, &cfile->oplock_break); - -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - return true; - } -- spin_unlock(&cifs_file_list_lock); -+ spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - cifs_dbg(FYI, "No matching file for oplock break\n"); - return true; -diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c -index dd8543caa56e..be34b4860675 100644 ---- a/fs/cifs/smb2ops.c -+++ b/fs/cifs/smb2ops.c -@@ -282,7 +282,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) - cifs_dbg(FYI, "Link Speed %lld\n", - le64_to_cpu(out_buf->LinkSpeed)); - } -- -+ kfree(out_buf); - return rc; - } - #endif /* STATS2 */ -@@ -536,6 +536,7 @@ smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) - server->ops->set_oplock_level(cinode, oplock, fid->epoch, - &fid->purge_cache); - cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); -+ memcpy(cfile->fid.create_guid, fid->create_guid, 16); - } - - static void -@@ -694,6 +695,7 @@ smb2_clone_range(const unsigned int xid, - - cchunk_out: - kfree(pcchunk); -+ kfree(retbuf); - return rc; - } - -@@ -818,7 +820,6 @@ smb2_duplicate_extents(const unsigned int xid, - { - int rc; - unsigned int ret_data_len; -- char *retbuf = NULL; - struct duplicate_extents_to_file dup_ext_buf; - struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink); - -@@ -844,7 +845,7 @@ smb2_duplicate_extents(const unsigned int xid, - FSCTL_DUPLICATE_EXTENTS_TO_FILE, - true /* is_fsctl */, (char *)&dup_ext_buf, - sizeof(struct duplicate_extents_to_file), -- (char **)&retbuf, -+ NULL, - &ret_data_len); - - if (ret_data_len > 0) -@@ -867,7 +868,6 @@ smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon, - struct cifsFileInfo *cfile) - { - struct fsctl_set_integrity_information_req integr_info; -- char *retbuf = NULL; - unsigned int ret_data_len; - - integr_info.ChecksumAlgorithm = cpu_to_le16(CHECKSUM_TYPE_UNCHANGED); -@@ -879,7 +879,7 @@ smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon, - FSCTL_SET_INTEGRITY_INFORMATION, - true /* is_fsctl */, (char *)&integr_info, - sizeof(struct fsctl_set_integrity_information_req), -- (char **)&retbuf, -+ NULL, - &ret_data_len); - - } -@@ -1036,7 +1036,7 @@ smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid) - static void - smb2_new_lease_key(struct cifs_fid *fid) - { -- get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE); -+ generate_random_uuid(fid->lease_key); - } - - #define SMB2_SYMLINK_STRUCT_SIZE \ -diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c -index 0b6dc1942bdc..0dbbdf5e4aee 100644 ---- a/fs/cifs/smb2pdu.c -+++ b/fs/cifs/smb2pdu.c -@@ -103,7 +103,21 @@ smb2_hdr_assemble(struct smb2_hdr *hdr, __le16 smb2_cmd /* command */ , - hdr->ProtocolId[3] = 'B'; - hdr->StructureSize = cpu_to_le16(64); - hdr->Command = smb2_cmd; -- hdr->CreditRequest = cpu_to_le16(2); /* BB make this dynamic */ -+ if (tcon && tcon->ses && tcon->ses->server) { -+ struct TCP_Server_Info *server = tcon->ses->server; -+ -+ spin_lock(&server->req_lock); -+ /* Request up to 2 credits but don't go over the limit. */ -+ if (server->credits >= SMB2_MAX_CREDITS_AVAILABLE) -+ hdr->CreditRequest = cpu_to_le16(0); -+ else -+ hdr->CreditRequest = cpu_to_le16( -+ min_t(int, SMB2_MAX_CREDITS_AVAILABLE - -+ server->credits, 2)); -+ spin_unlock(&server->req_lock); -+ } else { -+ hdr->CreditRequest = cpu_to_le16(2); -+ } - hdr->ProcessId = cpu_to_le32((__u16)current->tgid); - - if (!tcon) -@@ -593,6 +607,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, - char *security_blob = NULL; - unsigned char *ntlmssp_blob = NULL; - bool use_spnego = false; /* else use raw ntlmssp */ -+ u64 previous_session = ses->Suid; - - cifs_dbg(FYI, "Session Setup\n"); - -@@ -630,6 +645,10 @@ ssetup_ntlmssp_authenticate: - return rc; - - req->hdr.SessionId = 0; /* First session, not a reauthenticate */ -+ -+ /* if reconnect, we need to send previous sess id, otherwise it is 0 */ -+ req->PreviousSessionId = previous_session; -+ - req->Flags = 0; /* MBZ */ - /* to enable echos and oplocks */ - req->hdr.CreditRequest = cpu_to_le16(3); -@@ -1167,7 +1186,7 @@ create_durable_v2_buf(struct cifs_fid *pfid) - - buf->dcontext.Timeout = 0; /* Should this be configurable by workload */ - buf->dcontext.Flags = cpu_to_le32(SMB2_DHANDLE_FLAG_PERSISTENT); -- get_random_bytes(buf->dcontext.CreateGuid, 16); -+ generate_random_uuid(buf->dcontext.CreateGuid); - memcpy(pfid->create_guid, buf->dcontext.CreateGuid, 16); - - /* SMB2_CREATE_DURABLE_HANDLE_REQUEST is "DH2Q" */ -@@ -2059,6 +2078,7 @@ smb2_async_readv(struct cifs_readdata *rdata) - if (rdata->credits) { - buf->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, - SMB2_MAX_BUFFER_SIZE)); -+ buf->CreditRequest = buf->CreditCharge; - spin_lock(&server->req_lock); - server->credits += rdata->credits - - le16_to_cpu(buf->CreditCharge); -@@ -2245,6 +2265,7 @@ smb2_async_writev(struct cifs_writedata *wdata, - if (wdata->credits) { - req->hdr.CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes, - SMB2_MAX_BUFFER_SIZE)); -+ req->hdr.CreditRequest = req->hdr.CreditCharge; - spin_lock(&server->req_lock); - server->credits += wdata->credits - - le16_to_cpu(req->hdr.CreditCharge); -diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h -index 4af52780ec35..b8f553b32dda 100644 ---- a/fs/cifs/smb2pdu.h -+++ b/fs/cifs/smb2pdu.h -@@ -276,7 +276,7 @@ struct smb2_sess_setup_req { - __le32 Channel; - __le16 SecurityBufferOffset; - __le16 SecurityBufferLength; -- __le64 PreviousSessionId; -+ __u64 PreviousSessionId; - __u8 Buffer[1]; /* variable length GSS security buffer */ - } __packed; - -diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c -index 1420a3c614af..5d09ea585840 100644 ---- a/fs/ext4/sysfs.c -+++ b/fs/ext4/sysfs.c -@@ -223,14 +223,18 @@ static struct attribute *ext4_attrs[] = { - EXT4_ATTR_FEATURE(lazy_itable_init); - EXT4_ATTR_FEATURE(batched_discard); - EXT4_ATTR_FEATURE(meta_bg_resize); -+#ifdef CONFIG_EXT4_FS_ENCRYPTION - EXT4_ATTR_FEATURE(encryption); -+#endif - EXT4_ATTR_FEATURE(metadata_csum_seed); - - static struct attribute *ext4_feat_attrs[] = { - ATTR_LIST(lazy_itable_init), - ATTR_LIST(batched_discard), - ATTR_LIST(meta_bg_resize), -+#ifdef CONFIG_EXT4_FS_ENCRYPTION - ATTR_LIST(encryption), -+#endif - ATTR_LIST(metadata_csum_seed), - NULL, - }; -diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c -index d67a16f2a45d..350f67fb5b9c 100644 ---- a/fs/isofs/inode.c -+++ b/fs/isofs/inode.c -@@ -690,6 +690,11 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) - pri_bh = NULL; - - root_found: -+ /* We don't support read-write mounts */ -+ if (!(s->s_flags & MS_RDONLY)) { -+ error = -EACCES; -+ goto out_freebh; -+ } - - if (joliet_level && (pri == NULL || !opt.rock)) { - /* This is the case of Joliet with the norock mount flag. -@@ -1503,9 +1508,6 @@ struct inode *__isofs_iget(struct super_block *sb, - static struct dentry *isofs_mount(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data) - { -- /* We don't support read-write mounts */ -- if (!(flags & MS_RDONLY)) -- return ERR_PTR(-EACCES); - return mount_bdev(fs_type, flags, dev_name, data, isofs_fill_super); - } - -diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c -index ca181e81c765..fa1b8e0dcacf 100644 ---- a/fs/jbd2/transaction.c -+++ b/fs/jbd2/transaction.c -@@ -1156,6 +1156,7 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) - JBUFFER_TRACE(jh, "file as BJ_Reserved"); - spin_lock(&journal->j_list_lock); - __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved); -+ spin_unlock(&journal->j_list_lock); - } else if (jh->b_transaction == journal->j_committing_transaction) { - /* first access by this transaction */ - jh->b_modified = 0; -@@ -1163,8 +1164,8 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) - JBUFFER_TRACE(jh, "set next transaction"); - spin_lock(&journal->j_list_lock); - jh->b_next_transaction = transaction; -+ spin_unlock(&journal->j_list_lock); - } -- spin_unlock(&journal->j_list_lock); - jbd_unlock_bh_state(bh); - - /* -diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c -index 5166adcfc0fb..7af5eeabc80e 100644 ---- a/fs/nfs/delegation.c -+++ b/fs/nfs/delegation.c -@@ -41,6 +41,17 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) - set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); - } - -+static bool -+nfs4_is_valid_delegation(const struct nfs_delegation *delegation, -+ fmode_t flags) -+{ -+ if (delegation != NULL && (delegation->type & flags) == flags && -+ !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && -+ !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) -+ return true; -+ return false; -+} -+ - static int - nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) - { -@@ -50,8 +61,7 @@ nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) - flags &= FMODE_READ|FMODE_WRITE; - rcu_read_lock(); - delegation = rcu_dereference(NFS_I(inode)->delegation); -- if (delegation != NULL && (delegation->type & flags) == flags && -- !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { -+ if (nfs4_is_valid_delegation(delegation, flags)) { - if (mark) - nfs_mark_delegation_referenced(delegation); - ret = 1; -@@ -892,7 +902,7 @@ bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode, - flags &= FMODE_READ|FMODE_WRITE; - rcu_read_lock(); - delegation = rcu_dereference(nfsi->delegation); -- ret = (delegation != NULL && (delegation->type & flags) == flags); -+ ret = nfs4_is_valid_delegation(delegation, flags); - if (ret) { - nfs4_stateid_copy(dst, &delegation->stateid); - nfs_mark_delegation_referenced(delegation); -diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c -index 6b1ce9825430..7f1a0fb8c493 100644 ---- a/fs/nfs/nfs42proc.c -+++ b/fs/nfs/nfs42proc.c -@@ -269,6 +269,7 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server, - task = rpc_run_task(&task_setup); - if (IS_ERR(task)) - return PTR_ERR(task); -+ rpc_put_task(task); - return 0; - } - -diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c -index d854693a15b0..82dc3035ea45 100644 ---- a/fs/nfs/nfs4state.c -+++ b/fs/nfs/nfs4state.c -@@ -1493,6 +1493,9 @@ restart: - __func__, status); - case -ENOENT: - case -ENOMEM: -+ case -EACCES: -+ case -EROFS: -+ case -EIO: - case -ESTALE: - /* Open state on this file cannot be recovered */ - nfs4_state_mark_recovery_failed(state, status); -diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c -index 9e52609cd683..ea0dd9ee138d 100644 ---- a/fs/overlayfs/copy_up.c -+++ b/fs/overlayfs/copy_up.c -@@ -25,6 +25,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) - ssize_t list_size, size, value_size = 0; - char *buf, *name, *value = NULL; - int uninitialized_var(error); -+ size_t slen; - - if (!old->d_inode->i_op->getxattr || - !new->d_inode->i_op->getxattr) -@@ -47,7 +48,16 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) - goto out; - } - -- for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { -+ for (name = buf; list_size; name += slen) { -+ slen = strnlen(name, list_size) + 1; -+ -+ /* underlying fs providing us with an broken xattr list? */ -+ if (WARN_ON(slen > list_size)) { -+ error = -EIO; -+ break; -+ } -+ list_size -= slen; -+ - if (ovl_is_private_xattr(name)) - continue; - retry: -diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c -index ba5ef733951f..327177df03a5 100644 ---- a/fs/overlayfs/dir.c -+++ b/fs/overlayfs/dir.c -@@ -12,6 +12,7 @@ - #include - #include - #include -+#include - #include "overlayfs.h" - - void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) -@@ -35,8 +36,10 @@ struct dentry *ovl_lookup_temp(struct dentry *workdir, struct dentry *dentry) - { - struct dentry *temp; - char name[20]; -+ static atomic_t temp_id = ATOMIC_INIT(0); - -- snprintf(name, sizeof(name), "#%lx", (unsigned long) dentry); -+ /* counter is allowed to wrap, since temp dentries are ephemeral */ -+ snprintf(name, sizeof(name), "#%x", atomic_inc_return(&temp_id)); - - temp = lookup_one_len(name, workdir, strlen(name)); - if (!IS_ERR(temp) && temp->d_inode) { -diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c -index 319c3a60cfa5..905caba36529 100644 ---- a/fs/pstore/ram.c -+++ b/fs/pstore/ram.c -@@ -375,13 +375,14 @@ static void ramoops_free_przs(struct ramoops_context *cxt) - { - int i; - -- cxt->max_dump_cnt = 0; - if (!cxt->przs) - return; - -- for (i = 0; !IS_ERR_OR_NULL(cxt->przs[i]); i++) -+ for (i = 0; i < cxt->max_dump_cnt; i++) - persistent_ram_free(cxt->przs[i]); -+ - kfree(cxt->przs); -+ cxt->max_dump_cnt = 0; - } - - static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, -@@ -406,7 +407,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, - GFP_KERNEL); - if (!cxt->przs) { - dev_err(dev, "failed to initialize a prz array for dumps\n"); -- goto fail_prz; -+ goto fail_mem; - } - - for (i = 0; i < cxt->max_dump_cnt; i++) { -@@ -417,6 +418,11 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, - err = PTR_ERR(cxt->przs[i]); - dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n", - cxt->record_size, (unsigned long long)*paddr, err); -+ -+ while (i > 0) { -+ i--; -+ persistent_ram_free(cxt->przs[i]); -+ } - goto fail_prz; - } - *paddr += cxt->record_size; -@@ -424,7 +430,9 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, - - return 0; - fail_prz: -- ramoops_free_przs(cxt); -+ kfree(cxt->przs); -+fail_mem: -+ cxt->max_dump_cnt = 0; - return err; - } - -@@ -583,7 +591,6 @@ static int ramoops_remove(struct platform_device *pdev) - struct ramoops_context *cxt = &oops_cxt; - - pstore_unregister(&cxt->pstore); -- cxt->max_dump_cnt = 0; - - kfree(cxt->pstore.buf); - cxt->pstore.bufsize = 0; -diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c -index 76c3f80efdfa..364d2dffe5a6 100644 ---- a/fs/pstore/ram_core.c -+++ b/fs/pstore/ram_core.c -@@ -47,43 +47,10 @@ static inline size_t buffer_start(struct persistent_ram_zone *prz) - return atomic_read(&prz->buffer->start); - } - --/* increase and wrap the start pointer, returning the old value */ --static size_t buffer_start_add_atomic(struct persistent_ram_zone *prz, size_t a) --{ -- int old; -- int new; -- -- do { -- old = atomic_read(&prz->buffer->start); -- new = old + a; -- while (unlikely(new >= prz->buffer_size)) -- new -= prz->buffer_size; -- } while (atomic_cmpxchg(&prz->buffer->start, old, new) != old); -- -- return old; --} -- --/* increase the size counter until it hits the max size */ --static void buffer_size_add_atomic(struct persistent_ram_zone *prz, size_t a) --{ -- size_t old; -- size_t new; -- -- if (atomic_read(&prz->buffer->size) == prz->buffer_size) -- return; -- -- do { -- old = atomic_read(&prz->buffer->size); -- new = old + a; -- if (new > prz->buffer_size) -- new = prz->buffer_size; -- } while (atomic_cmpxchg(&prz->buffer->size, old, new) != old); --} -- - static DEFINE_RAW_SPINLOCK(buffer_lock); - - /* increase and wrap the start pointer, returning the old value */ --static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t a) -+static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a) - { - int old; - int new; -@@ -103,7 +70,7 @@ static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t a) - } - - /* increase the size counter until it hits the max size */ --static void buffer_size_add_locked(struct persistent_ram_zone *prz, size_t a) -+static void buffer_size_add(struct persistent_ram_zone *prz, size_t a) - { - size_t old; - size_t new; -@@ -124,9 +91,6 @@ exit: - raw_spin_unlock_irqrestore(&buffer_lock, flags); - } - --static size_t (*buffer_start_add)(struct persistent_ram_zone *, size_t) = buffer_start_add_atomic; --static void (*buffer_size_add)(struct persistent_ram_zone *, size_t) = buffer_size_add_atomic; -- - static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz, - uint8_t *data, size_t len, uint8_t *ecc) - { -@@ -299,7 +263,7 @@ static void notrace persistent_ram_update(struct persistent_ram_zone *prz, - const void *s, unsigned int start, unsigned int count) - { - struct persistent_ram_buffer *buffer = prz->buffer; -- memcpy(buffer->data + start, s, count); -+ memcpy_toio(buffer->data + start, s, count); - persistent_ram_update_ecc(prz, start, count); - } - -@@ -322,8 +286,8 @@ void persistent_ram_save_old(struct persistent_ram_zone *prz) - } - - prz->old_log_size = size; -- memcpy(prz->old_log, &buffer->data[start], size - start); -- memcpy(prz->old_log + size - start, &buffer->data[0], start); -+ memcpy_fromio(prz->old_log, &buffer->data[start], size - start); -+ memcpy_fromio(prz->old_log + size - start, &buffer->data[0], start); - } - - int notrace persistent_ram_write(struct persistent_ram_zone *prz, -@@ -426,9 +390,6 @@ static void *persistent_ram_iomap(phys_addr_t start, size_t size, - return NULL; - } - -- buffer_start_add = buffer_start_add_locked; -- buffer_size_add = buffer_size_add_locked; -- - if (memtype) - va = ioremap(start, size); - else -diff --git a/fs/super.c b/fs/super.c -index f5f4b328f860..d4d2591b77c8 100644 ---- a/fs/super.c -+++ b/fs/super.c -@@ -1326,8 +1326,8 @@ int freeze_super(struct super_block *sb) - } - } - /* -- * This is just for debugging purposes so that fs can warn if it -- * sees write activity when frozen is set to SB_FREEZE_COMPLETE. -+ * For debugging purposes so that fs can warn if it sees write activity -+ * when frozen is set to SB_FREEZE_COMPLETE, and for thaw_super(). - */ - sb->s_writers.frozen = SB_FREEZE_COMPLETE; - up_write(&sb->s_umount); -@@ -1346,7 +1346,7 @@ int thaw_super(struct super_block *sb) - int error; - - down_write(&sb->s_umount); -- if (sb->s_writers.frozen == SB_UNFROZEN) { -+ if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) { - up_write(&sb->s_umount); - return -EINVAL; - } -diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c -index e8b01b721e99..b5bf23b34241 100644 ---- a/fs/ubifs/xattr.c -+++ b/fs/ubifs/xattr.c -@@ -173,6 +173,7 @@ out_cancel: - host_ui->xattr_cnt -= 1; - host_ui->xattr_size -= CALC_DENT_SIZE(nm->len); - host_ui->xattr_size -= CALC_XATTR_BYTES(size); -+ host_ui->xattr_names -= nm->len; - mutex_unlock(&host_ui->ui_mutex); - out_free: - make_bad_inode(inode); -@@ -533,6 +534,7 @@ out_cancel: - host_ui->xattr_cnt += 1; - host_ui->xattr_size += CALC_DENT_SIZE(nm->len); - host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); -+ host_ui->xattr_names += nm->len; - mutex_unlock(&host_ui->ui_mutex); - ubifs_release_budget(c, &req); - make_bad_inode(inode); -diff --git a/include/linux/devfreq-event.h b/include/linux/devfreq-event.h -index 0a83a1e648b0..4db00b02ca3f 100644 ---- a/include/linux/devfreq-event.h -+++ b/include/linux/devfreq-event.h -@@ -148,11 +148,6 @@ static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev) - return -EINVAL; - } - --static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev) --{ -- return ERR_PTR(-EINVAL); --} -- - static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle( - struct device *dev, int index) - { -diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h -index e98425058f20..54048f336a1f 100644 ---- a/include/linux/irqchip/arm-gic-v3.h -+++ b/include/linux/irqchip/arm-gic-v3.h -@@ -218,7 +218,7 @@ - #define GITS_BASER_TYPE_SHIFT (56) - #define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7) - #define GITS_BASER_ENTRY_SIZE_SHIFT (48) --#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0xff) + 1) -+#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0x1f) + 1) - #define GITS_BASER_NonShareable (0UL << 10) - #define GITS_BASER_InnerShareable (1UL << 10) - #define GITS_BASER_OuterShareable (2UL << 10) -diff --git a/include/linux/kernel.h b/include/linux/kernel.h -index e571e592e53a..50220cab738c 100644 ---- a/include/linux/kernel.h -+++ b/include/linux/kernel.h -@@ -356,6 +356,7 @@ int __must_check kstrtou16(const char *s, unsigned int base, u16 *res); - int __must_check kstrtos16(const char *s, unsigned int base, s16 *res); - int __must_check kstrtou8(const char *s, unsigned int base, u8 *res); - int __must_check kstrtos8(const char *s, unsigned int base, s8 *res); -+int __must_check kstrtobool(const char *s, bool *res); - - int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res); - int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res); -@@ -367,6 +368,7 @@ int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigne - int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res); - int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res); - int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res); -+int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool *res); - - static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res) - { -diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h -index f09648d14694..782d4e814e21 100644 ---- a/include/linux/lightnvm.h -+++ b/include/linux/lightnvm.h -@@ -1,6 +1,8 @@ - #ifndef NVM_H - #define NVM_H - -+#include -+ - enum { - NVM_IO_OK = 0, - NVM_IO_REQUEUE = 1, -@@ -11,10 +13,71 @@ enum { - NVM_IOTYPE_GC = 1, - }; - -+#define NVM_BLK_BITS (16) -+#define NVM_PG_BITS (16) -+#define NVM_SEC_BITS (8) -+#define NVM_PL_BITS (8) -+#define NVM_LUN_BITS (8) -+#define NVM_CH_BITS (8) -+ -+struct ppa_addr { -+ /* Generic structure for all addresses */ -+ union { -+ struct { -+ u64 blk : NVM_BLK_BITS; -+ u64 pg : NVM_PG_BITS; -+ u64 sec : NVM_SEC_BITS; -+ u64 pl : NVM_PL_BITS; -+ u64 lun : NVM_LUN_BITS; -+ u64 ch : NVM_CH_BITS; -+ } g; -+ -+ u64 ppa; -+ }; -+}; -+ -+struct nvm_rq; -+struct nvm_id; -+struct nvm_dev; -+ -+typedef int (nvm_l2p_update_fn)(u64, u32, __le64 *, void *); -+typedef int (nvm_bb_update_fn)(struct ppa_addr, int, u8 *, void *); -+typedef int (nvm_id_fn)(struct nvm_dev *, struct nvm_id *); -+typedef int (nvm_get_l2p_tbl_fn)(struct nvm_dev *, u64, u32, -+ nvm_l2p_update_fn *, void *); -+typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr, int, -+ nvm_bb_update_fn *, void *); -+typedef int (nvm_op_set_bb_fn)(struct nvm_dev *, struct nvm_rq *, int); -+typedef int (nvm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); -+typedef int (nvm_erase_blk_fn)(struct nvm_dev *, struct nvm_rq *); -+typedef void *(nvm_create_dma_pool_fn)(struct nvm_dev *, char *); -+typedef void (nvm_destroy_dma_pool_fn)(void *); -+typedef void *(nvm_dev_dma_alloc_fn)(struct nvm_dev *, void *, gfp_t, -+ dma_addr_t *); -+typedef void (nvm_dev_dma_free_fn)(void *, void*, dma_addr_t); -+ -+struct nvm_dev_ops { -+ nvm_id_fn *identity; -+ nvm_get_l2p_tbl_fn *get_l2p_tbl; -+ nvm_op_bb_tbl_fn *get_bb_tbl; -+ nvm_op_set_bb_fn *set_bb_tbl; -+ -+ nvm_submit_io_fn *submit_io; -+ nvm_erase_blk_fn *erase_block; -+ -+ nvm_create_dma_pool_fn *create_dma_pool; -+ nvm_destroy_dma_pool_fn *destroy_dma_pool; -+ nvm_dev_dma_alloc_fn *dev_dma_alloc; -+ nvm_dev_dma_free_fn *dev_dma_free; -+ -+ unsigned int max_phys_sect; -+}; -+ -+ -+ - #ifdef CONFIG_NVM - - #include --#include - #include - #include - -@@ -126,29 +189,6 @@ struct nvm_tgt_instance { - #define NVM_VERSION_MINOR 0 - #define NVM_VERSION_PATCH 0 - --#define NVM_BLK_BITS (16) --#define NVM_PG_BITS (16) --#define NVM_SEC_BITS (8) --#define NVM_PL_BITS (8) --#define NVM_LUN_BITS (8) --#define NVM_CH_BITS (8) -- --struct ppa_addr { -- /* Generic structure for all addresses */ -- union { -- struct { -- u64 blk : NVM_BLK_BITS; -- u64 pg : NVM_PG_BITS; -- u64 sec : NVM_SEC_BITS; -- u64 pl : NVM_PL_BITS; -- u64 lun : NVM_LUN_BITS; -- u64 ch : NVM_CH_BITS; -- } g; -- -- u64 ppa; -- }; --}; -- - struct nvm_rq { - struct nvm_tgt_instance *ins; - struct nvm_dev *dev; -@@ -182,39 +222,6 @@ static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata) - - struct nvm_block; - --typedef int (nvm_l2p_update_fn)(u64, u32, __le64 *, void *); --typedef int (nvm_bb_update_fn)(struct ppa_addr, int, u8 *, void *); --typedef int (nvm_id_fn)(struct nvm_dev *, struct nvm_id *); --typedef int (nvm_get_l2p_tbl_fn)(struct nvm_dev *, u64, u32, -- nvm_l2p_update_fn *, void *); --typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr, int, -- nvm_bb_update_fn *, void *); --typedef int (nvm_op_set_bb_fn)(struct nvm_dev *, struct nvm_rq *, int); --typedef int (nvm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); --typedef int (nvm_erase_blk_fn)(struct nvm_dev *, struct nvm_rq *); --typedef void *(nvm_create_dma_pool_fn)(struct nvm_dev *, char *); --typedef void (nvm_destroy_dma_pool_fn)(void *); --typedef void *(nvm_dev_dma_alloc_fn)(struct nvm_dev *, void *, gfp_t, -- dma_addr_t *); --typedef void (nvm_dev_dma_free_fn)(void *, void*, dma_addr_t); -- --struct nvm_dev_ops { -- nvm_id_fn *identity; -- nvm_get_l2p_tbl_fn *get_l2p_tbl; -- nvm_op_bb_tbl_fn *get_bb_tbl; -- nvm_op_set_bb_fn *set_bb_tbl; -- -- nvm_submit_io_fn *submit_io; -- nvm_erase_blk_fn *erase_block; -- -- nvm_create_dma_pool_fn *create_dma_pool; -- nvm_destroy_dma_pool_fn *destroy_dma_pool; -- nvm_dev_dma_alloc_fn *dev_dma_alloc; -- nvm_dev_dma_free_fn *dev_dma_free; -- -- unsigned int max_phys_sect; --}; -- - struct nvm_lun { - int id; - -diff --git a/include/linux/sem.h b/include/linux/sem.h -index 976ce3a19f1b..d0efd6e6c20a 100644 ---- a/include/linux/sem.h -+++ b/include/linux/sem.h -@@ -21,6 +21,7 @@ struct sem_array { - struct list_head list_id; /* undo requests on this array */ - int sem_nsems; /* no. of semaphores in array */ - int complex_count; /* pending complex operations */ -+ bool complex_mode; /* no parallel simple ops */ - }; - - #ifdef CONFIG_SYSVIPC -diff --git a/include/linux/string.h b/include/linux/string.h -index 9ef7795e65e4..aa30789b0f65 100644 ---- a/include/linux/string.h -+++ b/include/linux/string.h -@@ -127,7 +127,11 @@ extern char **argv_split(gfp_t gfp, const char *str, int *argcp); - extern void argv_free(char **argv); - - extern bool sysfs_streq(const char *s1, const char *s2); --extern int strtobool(const char *s, bool *res); -+extern int kstrtobool(const char *s, bool *res); -+static inline int strtobool(const char *s, bool *res) -+{ -+ return kstrtobool(s, res); -+} - - #ifdef CONFIG_BINARY_PRINTF - int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); -diff --git a/include/linux/swap.h b/include/linux/swap.h -index 7ba7dccaf0e7..d8ca2eaa3a8b 100644 ---- a/include/linux/swap.h -+++ b/include/linux/swap.h -@@ -266,6 +266,7 @@ static inline void workingset_node_pages_inc(struct radix_tree_node *node) - - static inline void workingset_node_pages_dec(struct radix_tree_node *node) - { -+ VM_WARN_ON_ONCE(!workingset_node_pages(node)); - node->count--; - } - -@@ -281,6 +282,7 @@ static inline void workingset_node_shadows_inc(struct radix_tree_node *node) - - static inline void workingset_node_shadows_dec(struct radix_tree_node *node) - { -+ VM_WARN_ON_ONCE(!workingset_node_shadows(node)); - node->count -= 1U << RADIX_TREE_COUNT_SHIFT; - } - -diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h -index 59081c73b296..6afc6f388edf 100644 ---- a/include/target/target_core_base.h -+++ b/include/target/target_core_base.h -@@ -180,6 +180,7 @@ enum tcm_sense_reason_table { - TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED = R(0x15), - TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = R(0x16), - TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = R(0x17), -+ TCM_COPY_TARGET_DEVICE_NOT_REACHABLE = R(0x18), - #undef R - }; - -diff --git a/ipc/sem.c b/ipc/sem.c -index 20d07008ad5e..9862c3d1c26d 100644 ---- a/ipc/sem.c -+++ b/ipc/sem.c -@@ -155,14 +155,21 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it); - - /* - * Locking: -+ * a) global sem_lock() for read/write - * sem_undo.id_next, - * sem_array.complex_count, -- * sem_array.pending{_alter,_cont}, -- * sem_array.sem_undo: global sem_lock() for read/write -- * sem_undo.proc_next: only "current" is allowed to read/write that field. -+ * sem_array.complex_mode -+ * sem_array.pending{_alter,_const}, -+ * sem_array.sem_undo - * -+ * b) global or semaphore sem_lock() for read/write: - * sem_array.sem_base[i].pending_{const,alter}: -- * global or semaphore sem_lock() for read/write -+ * sem_array.complex_mode (for read) -+ * -+ * c) special: -+ * sem_undo_list.list_proc: -+ * * undo_list->lock for write -+ * * rcu for read - */ - - #define sc_semmsl sem_ctls[0] -@@ -263,24 +270,25 @@ static void sem_rcu_free(struct rcu_head *head) - #define ipc_smp_acquire__after_spin_is_unlocked() smp_rmb() - - /* -- * Wait until all currently ongoing simple ops have completed. -+ * Enter the mode suitable for non-simple operations: - * Caller must own sem_perm.lock. -- * New simple ops cannot start, because simple ops first check -- * that sem_perm.lock is free. -- * that a) sem_perm.lock is free and b) complex_count is 0. - */ --static void sem_wait_array(struct sem_array *sma) -+static void complexmode_enter(struct sem_array *sma) - { - int i; - struct sem *sem; - -- if (sma->complex_count) { -- /* The thread that increased sma->complex_count waited on -- * all sem->lock locks. Thus we don't need to wait again. -- */ -+ if (sma->complex_mode) { -+ /* We are already in complex_mode. Nothing to do */ - return; - } - -+ /* We need a full barrier after seting complex_mode: -+ * The write to complex_mode must be visible -+ * before we read the first sem->lock spinlock state. -+ */ -+ smp_store_mb(sma->complex_mode, true); -+ - for (i = 0; i < sma->sem_nsems; i++) { - sem = sma->sem_base + i; - spin_unlock_wait(&sem->lock); -@@ -289,6 +297,28 @@ static void sem_wait_array(struct sem_array *sma) - } - - /* -+ * Try to leave the mode that disallows simple operations: -+ * Caller must own sem_perm.lock. -+ */ -+static void complexmode_tryleave(struct sem_array *sma) -+{ -+ if (sma->complex_count) { -+ /* Complex ops are sleeping. -+ * We must stay in complex mode -+ */ -+ return; -+ } -+ /* -+ * Immediately after setting complex_mode to false, -+ * a simple op can start. Thus: all memory writes -+ * performed by the current operation must be visible -+ * before we set complex_mode to false. -+ */ -+ smp_store_release(&sma->complex_mode, false); -+} -+ -+#define SEM_GLOBAL_LOCK (-1) -+/* - * If the request contains only one semaphore operation, and there are - * no complex transactions pending, lock only the semaphore involved. - * Otherwise, lock the entire semaphore array, since we either have -@@ -304,56 +334,42 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops, - /* Complex operation - acquire a full lock */ - ipc_lock_object(&sma->sem_perm); - -- /* And wait until all simple ops that are processed -- * right now have dropped their locks. -- */ -- sem_wait_array(sma); -- return -1; -+ /* Prevent parallel simple ops */ -+ complexmode_enter(sma); -+ return SEM_GLOBAL_LOCK; - } - - /* - * Only one semaphore affected - try to optimize locking. -- * The rules are: -- * - optimized locking is possible if no complex operation -- * is either enqueued or processed right now. -- * - The test for enqueued complex ops is simple: -- * sma->complex_count != 0 -- * - Testing for complex ops that are processed right now is -- * a bit more difficult. Complex ops acquire the full lock -- * and first wait that the running simple ops have completed. -- * (see above) -- * Thus: If we own a simple lock and the global lock is free -- * and complex_count is now 0, then it will stay 0 and -- * thus just locking sem->lock is sufficient. -+ * Optimized locking is possible if no complex operation -+ * is either enqueued or processed right now. -+ * -+ * Both facts are tracked by complex_mode. - */ - sem = sma->sem_base + sops->sem_num; - -- if (sma->complex_count == 0) { -+ /* -+ * Initial check for complex_mode. Just an optimization, -+ * no locking, no memory barrier. -+ */ -+ if (!sma->complex_mode) { - /* - * It appears that no complex operation is around. - * Acquire the per-semaphore lock. - */ - spin_lock(&sem->lock); - -- /* Then check that the global lock is free */ -- if (!spin_is_locked(&sma->sem_perm.lock)) { -- /* -- * We need a memory barrier with acquire semantics, -- * otherwise we can race with another thread that does: -- * complex_count++; -- * spin_unlock(sem_perm.lock); -- */ -- ipc_smp_acquire__after_spin_is_unlocked(); -+ /* -+ * See 51d7d5205d33 -+ * ("powerpc: Add smp_mb() to arch_spin_is_locked()"): -+ * A full barrier is required: the write of sem->lock -+ * must be visible before the read is executed -+ */ -+ smp_mb(); - -- /* -- * Now repeat the test of complex_count: -- * It can't change anymore until we drop sem->lock. -- * Thus: if is now 0, then it will stay 0. -- */ -- if (sma->complex_count == 0) { -- /* fast path successful! */ -- return sops->sem_num; -- } -+ if (!smp_load_acquire(&sma->complex_mode)) { -+ /* fast path successful! */ -+ return sops->sem_num; - } - spin_unlock(&sem->lock); - } -@@ -373,15 +389,16 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops, - /* Not a false alarm, thus complete the sequence for a - * full lock. - */ -- sem_wait_array(sma); -- return -1; -+ complexmode_enter(sma); -+ return SEM_GLOBAL_LOCK; - } - } - - static inline void sem_unlock(struct sem_array *sma, int locknum) - { -- if (locknum == -1) { -+ if (locknum == SEM_GLOBAL_LOCK) { - unmerge_queues(sma); -+ complexmode_tryleave(sma); - ipc_unlock_object(&sma->sem_perm); - } else { - struct sem *sem = sma->sem_base + locknum; -@@ -533,6 +550,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) - } - - sma->complex_count = 0; -+ sma->complex_mode = true; /* dropped by sem_unlock below */ - INIT_LIST_HEAD(&sma->pending_alter); - INIT_LIST_HEAD(&sma->pending_const); - INIT_LIST_HEAD(&sma->list_id); -@@ -2186,10 +2204,10 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it) - /* - * The proc interface isn't aware of sem_lock(), it calls - * ipc_lock_object() directly (in sysvipc_find_ipc). -- * In order to stay compatible with sem_lock(), we must wait until -- * all simple semop() calls have left their critical regions. -+ * In order to stay compatible with sem_lock(), we must -+ * enter / leave complex_mode. - */ -- sem_wait_array(sma); -+ complexmode_enter(sma); - - sem_otime = get_semotime(sma); - -@@ -2206,6 +2224,8 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it) - sem_otime, - sma->sem_ctime); - -+ complexmode_tryleave(sma); -+ - return 0; - } - #endif -diff --git a/lib/kstrtox.c b/lib/kstrtox.c -index 94be244e8441..d8a5cf66c316 100644 ---- a/lib/kstrtox.c -+++ b/lib/kstrtox.c -@@ -321,6 +321,70 @@ int kstrtos8(const char *s, unsigned int base, s8 *res) - } - EXPORT_SYMBOL(kstrtos8); - -+/** -+ * kstrtobool - convert common user inputs into boolean values -+ * @s: input string -+ * @res: result -+ * -+ * This routine returns 0 iff the first character is one of 'Yy1Nn0', or -+ * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value -+ * pointed to by res is updated upon finding a match. -+ */ -+int kstrtobool(const char *s, bool *res) -+{ -+ if (!s) -+ return -EINVAL; -+ -+ switch (s[0]) { -+ case 'y': -+ case 'Y': -+ case '1': -+ *res = true; -+ return 0; -+ case 'n': -+ case 'N': -+ case '0': -+ *res = false; -+ return 0; -+ case 'o': -+ case 'O': -+ switch (s[1]) { -+ case 'n': -+ case 'N': -+ *res = true; -+ return 0; -+ case 'f': -+ case 'F': -+ *res = false; -+ return 0; -+ default: -+ break; -+ } -+ default: -+ break; -+ } -+ -+ return -EINVAL; -+} -+EXPORT_SYMBOL(kstrtobool); -+ -+/* -+ * Since "base" would be a nonsense argument, this open-codes the -+ * _from_user helper instead of using the helper macro below. -+ */ -+int kstrtobool_from_user(const char __user *s, size_t count, bool *res) -+{ -+ /* Longest string needed to differentiate, newline, terminator */ -+ char buf[4]; -+ -+ count = min(count, sizeof(buf) - 1); -+ if (copy_from_user(buf, s, count)) -+ return -EFAULT; -+ buf[count] = '\0'; -+ return kstrtobool(buf, res); -+} -+EXPORT_SYMBOL(kstrtobool_from_user); -+ - #define kstrto_from_user(f, g, type) \ - int f(const char __user *s, size_t count, unsigned int base, type *res) \ - { \ -diff --git a/lib/string.c b/lib/string.c -index 0323c0d5629a..1a90db9bc6e1 100644 ---- a/lib/string.c -+++ b/lib/string.c -@@ -630,35 +630,6 @@ bool sysfs_streq(const char *s1, const char *s2) - } - EXPORT_SYMBOL(sysfs_streq); - --/** -- * strtobool - convert common user inputs into boolean values -- * @s: input string -- * @res: result -- * -- * This routine returns 0 iff the first character is one of 'Yy1Nn0'. -- * Otherwise it will return -EINVAL. Value pointed to by res is -- * updated upon finding a match. -- */ --int strtobool(const char *s, bool *res) --{ -- switch (s[0]) { -- case 'y': -- case 'Y': -- case '1': -- *res = true; -- break; -- case 'n': -- case 'N': -- case '0': -- *res = false; -- break; -- default: -- return -EINVAL; -- } -- return 0; --} --EXPORT_SYMBOL(strtobool); -- - #ifndef __HAVE_ARCH_MEMSET - /** - * memset - Fill a region of memory with the given value -diff --git a/mm/filemap.c b/mm/filemap.c -index 1bb007624b53..c588d1222b2a 100644 ---- a/mm/filemap.c -+++ b/mm/filemap.c -@@ -109,6 +109,48 @@ - * ->tasklist_lock (memory_failure, collect_procs_ao) - */ - -+static int page_cache_tree_insert(struct address_space *mapping, -+ struct page *page, void **shadowp) -+{ -+ struct radix_tree_node *node; -+ void **slot; -+ int error; -+ -+ error = __radix_tree_create(&mapping->page_tree, page->index, -+ &node, &slot); -+ if (error) -+ return error; -+ if (*slot) { -+ void *p; -+ -+ p = radix_tree_deref_slot_protected(slot, &mapping->tree_lock); -+ if (!radix_tree_exceptional_entry(p)) -+ return -EEXIST; -+ if (shadowp) -+ *shadowp = p; -+ mapping->nrshadows--; -+ if (node) -+ workingset_node_shadows_dec(node); -+ } -+ radix_tree_replace_slot(slot, page); -+ mapping->nrpages++; -+ if (node) { -+ workingset_node_pages_inc(node); -+ /* -+ * Don't track node that contains actual pages. -+ * -+ * Avoid acquiring the list_lru lock if already -+ * untracked. The list_empty() test is safe as -+ * node->private_list is protected by -+ * mapping->tree_lock. -+ */ -+ if (!list_empty(&node->private_list)) -+ list_lru_del(&workingset_shadow_nodes, -+ &node->private_list); -+ } -+ return 0; -+} -+ - static void page_cache_tree_delete(struct address_space *mapping, - struct page *page, void *shadow) - { -@@ -122,6 +164,14 @@ static void page_cache_tree_delete(struct address_space *mapping, - - __radix_tree_lookup(&mapping->page_tree, page->index, &node, &slot); - -+ if (!node) { -+ /* -+ * We need a node to properly account shadow -+ * entries. Don't plant any without. XXX -+ */ -+ shadow = NULL; -+ } -+ - if (shadow) { - mapping->nrshadows++; - /* -@@ -538,9 +588,8 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) - memcg = mem_cgroup_begin_page_stat(old); - spin_lock_irqsave(&mapping->tree_lock, flags); - __delete_from_page_cache(old, NULL, memcg); -- error = radix_tree_insert(&mapping->page_tree, offset, new); -+ error = page_cache_tree_insert(mapping, new, NULL); - BUG_ON(error); -- mapping->nrpages++; - - /* - * hugetlb pages do not participate in page cache accounting. -@@ -562,48 +611,6 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) - } - EXPORT_SYMBOL_GPL(replace_page_cache_page); - --static int page_cache_tree_insert(struct address_space *mapping, -- struct page *page, void **shadowp) --{ -- struct radix_tree_node *node; -- void **slot; -- int error; -- -- error = __radix_tree_create(&mapping->page_tree, page->index, -- &node, &slot); -- if (error) -- return error; -- if (*slot) { -- void *p; -- -- p = radix_tree_deref_slot_protected(slot, &mapping->tree_lock); -- if (!radix_tree_exceptional_entry(p)) -- return -EEXIST; -- if (shadowp) -- *shadowp = p; -- mapping->nrshadows--; -- if (node) -- workingset_node_shadows_dec(node); -- } -- radix_tree_replace_slot(slot, page); -- mapping->nrpages++; -- if (node) { -- workingset_node_pages_inc(node); -- /* -- * Don't track node that contains actual pages. -- * -- * Avoid acquiring the list_lru lock if already -- * untracked. The list_empty() test is safe as -- * node->private_list is protected by -- * mapping->tree_lock. -- */ -- if (!list_empty(&node->private_list)) -- list_lru_del(&workingset_shadow_nodes, -- &node->private_list); -- } -- return 0; --} -- - static int __add_to_page_cache_locked(struct page *page, - struct address_space *mapping, - pgoff_t offset, gfp_t gfp_mask, -diff --git a/mm/workingset.c b/mm/workingset.c -index aa017133744b..df66f426fdcf 100644 ---- a/mm/workingset.c -+++ b/mm/workingset.c -@@ -341,21 +341,19 @@ static enum lru_status shadow_lru_isolate(struct list_head *item, - * no pages, so we expect to be able to remove them all and - * delete and free the empty node afterwards. - */ -- -- BUG_ON(!node->count); -- BUG_ON(node->count & RADIX_TREE_COUNT_MASK); -+ BUG_ON(!workingset_node_shadows(node)); -+ BUG_ON(workingset_node_pages(node)); - - for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) { - if (node->slots[i]) { - BUG_ON(!radix_tree_exceptional_entry(node->slots[i])); - node->slots[i] = NULL; -- BUG_ON(node->count < (1U << RADIX_TREE_COUNT_SHIFT)); -- node->count -= 1U << RADIX_TREE_COUNT_SHIFT; -+ workingset_node_shadows_dec(node); - BUG_ON(!mapping->nrshadows); - mapping->nrshadows--; - } - } -- BUG_ON(node->count); -+ BUG_ON(workingset_node_shadows(node)); - inc_zone_state(page_zone(virt_to_page(node)), WORKINGSET_NODERECLAIM); - if (!__radix_tree_delete_node(&mapping->page_tree, node)) - BUG(); -diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c -index 1ba417207465..27b6f55fa43a 100644 ---- a/net/sunrpc/xprtsock.c -+++ b/net/sunrpc/xprtsock.c -@@ -474,7 +474,16 @@ static int xs_nospace(struct rpc_task *task) - spin_unlock_bh(&xprt->transport_lock); - - /* Race breaker in case memory is freed before above code is called */ -- sk->sk_write_space(sk); -+ if (ret == -EAGAIN) { -+ struct socket_wq *wq; -+ -+ rcu_read_lock(); -+ wq = rcu_dereference(sk->sk_wq); -+ set_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags); -+ rcu_read_unlock(); -+ -+ sk->sk_write_space(sk); -+ } - return ret; - } - -diff --git a/sound/pci/hda/dell_wmi_helper.c b/sound/pci/hda/dell_wmi_helper.c -index 9c22f95838ef..19d41da79f93 100644 ---- a/sound/pci/hda/dell_wmi_helper.c -+++ b/sound/pci/hda/dell_wmi_helper.c -@@ -49,7 +49,7 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec, - removefunc = true; - if (dell_led_set_func(DELL_LED_MICMUTE, false) >= 0) { - dell_led_value = 0; -- if (spec->gen.num_adc_nids > 1) -+ if (spec->gen.num_adc_nids > 1 && !spec->gen.dyn_adc_switch) - codec_dbg(codec, "Skipping micmute LED control due to several ADCs"); - else { - dell_old_cap_hook = spec->gen.cap_sync_hook; -diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c -index 0a4ad5feb82e..12826ac0381f 100644 ---- a/sound/pci/hda/thinkpad_helper.c -+++ b/sound/pci/hda/thinkpad_helper.c -@@ -75,7 +75,7 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec, - removefunc = false; - } - if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { -- if (spec->num_adc_nids > 1) -+ if (spec->num_adc_nids > 1 && !spec->dyn_adc_switch) - codec_dbg(codec, - "Skipping micmute LED control due to several ADCs"); - else { -diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -index 9409d014b46c..71df7acf8643 100644 ---- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -@@ -89,6 +89,7 @@ struct intel_pt_decoder { - bool pge; - bool have_tma; - bool have_cyc; -+ bool fixup_last_mtc; - uint64_t pos; - uint64_t last_ip; - uint64_t ip; -@@ -584,10 +585,31 @@ struct intel_pt_calc_cyc_to_tsc_info { - uint64_t tsc_timestamp; - uint64_t timestamp; - bool have_tma; -+ bool fixup_last_mtc; - bool from_mtc; - double cbr_cyc_to_tsc; - }; - -+/* -+ * MTC provides a 8-bit slice of CTC but the TMA packet only provides the lower -+ * 16 bits of CTC. If mtc_shift > 8 then some of the MTC bits are not in the CTC -+ * provided by the TMA packet. Fix-up the last_mtc calculated from the TMA -+ * packet by copying the missing bits from the current MTC assuming the least -+ * difference between the two, and that the current MTC comes after last_mtc. -+ */ -+static void intel_pt_fixup_last_mtc(uint32_t mtc, int mtc_shift, -+ uint32_t *last_mtc) -+{ -+ uint32_t first_missing_bit = 1U << (16 - mtc_shift); -+ uint32_t mask = ~(first_missing_bit - 1); -+ -+ *last_mtc |= mtc & mask; -+ if (*last_mtc >= mtc) { -+ *last_mtc -= first_missing_bit; -+ *last_mtc &= 0xff; -+ } -+} -+ - static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) - { - struct intel_pt_decoder *decoder = pkt_info->decoder; -@@ -617,6 +639,11 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) - return 0; - - mtc = pkt_info->packet.payload; -+ if (decoder->mtc_shift > 8 && data->fixup_last_mtc) { -+ data->fixup_last_mtc = false; -+ intel_pt_fixup_last_mtc(mtc, decoder->mtc_shift, -+ &data->last_mtc); -+ } - if (mtc > data->last_mtc) - mtc_delta = mtc - data->last_mtc; - else -@@ -685,6 +712,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) - - data->ctc_delta = 0; - data->have_tma = true; -+ data->fixup_last_mtc = true; - - return 0; - -@@ -751,6 +779,7 @@ static void intel_pt_calc_cyc_to_tsc(struct intel_pt_decoder *decoder, - .tsc_timestamp = decoder->tsc_timestamp, - .timestamp = decoder->timestamp, - .have_tma = decoder->have_tma, -+ .fixup_last_mtc = decoder->fixup_last_mtc, - .from_mtc = from_mtc, - .cbr_cyc_to_tsc = 0, - }; -@@ -1241,6 +1270,7 @@ static void intel_pt_calc_tma(struct intel_pt_decoder *decoder) - } - decoder->ctc_delta = 0; - decoder->have_tma = true; -+ decoder->fixup_last_mtc = true; - intel_pt_log("CTC timestamp " x64_fmt " last MTC %#x CTC rem %#x\n", - decoder->ctc_timestamp, decoder->last_mtc, ctc_rem); - } -@@ -1255,6 +1285,12 @@ static void intel_pt_calc_mtc_timestamp(struct intel_pt_decoder *decoder) - - mtc = decoder->packet.payload; - -+ if (decoder->mtc_shift > 8 && decoder->fixup_last_mtc) { -+ decoder->fixup_last_mtc = false; -+ intel_pt_fixup_last_mtc(mtc, decoder->mtc_shift, -+ &decoder->last_mtc); -+ } -+ - if (mtc > decoder->last_mtc) - mtc_delta = mtc - decoder->last_mtc; - else -@@ -1323,6 +1359,8 @@ static void intel_pt_calc_cyc_timestamp(struct intel_pt_decoder *decoder) - timestamp, decoder->timestamp); - else - decoder->timestamp = timestamp; -+ -+ decoder->timestamp_insn_cnt = 0; - } - - /* Walk PSB+ packets when already in sync. */ -diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c -index 9227c2f076c3..89927b5beebf 100644 ---- a/tools/perf/util/intel-pt.c -+++ b/tools/perf/util/intel-pt.c -@@ -238,7 +238,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) - } - - queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; -- -+next: - buffer = auxtrace_buffer__next(queue, buffer); - if (!buffer) { - if (old_buffer) -@@ -261,9 +261,6 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) - intel_pt_do_fix_overlap(ptq->pt, old_buffer, buffer)) - return -ENOMEM; - -- if (old_buffer) -- auxtrace_buffer__drop_data(old_buffer); -- - if (buffer->use_data) { - b->len = buffer->use_size; - b->buf = buffer->use_data; -@@ -273,6 +270,16 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) - } - b->ref_timestamp = buffer->reference; - -+ /* -+ * If in snapshot mode and the buffer has no usable data, get next -+ * buffer and again check overlap against old_buffer. -+ */ -+ if (ptq->pt->snapshot_mode && !b->len) -+ goto next; -+ -+ if (old_buffer) -+ auxtrace_buffer__drop_data(old_buffer); -+ - if (!old_buffer || ptq->pt->sampling_mode || (ptq->pt->snapshot_mode && - !buffer->consecutive)) { - b->consecutive = false; diff --git a/patch/kernel/marvell-dev/patch-4.4.28-29.patch b/patch/kernel/marvell-dev/patch-4.4.28-29.patch new file mode 100644 index 0000000000..0bcb39c5ba --- /dev/null +++ b/patch/kernel/marvell-dev/patch-4.4.28-29.patch @@ -0,0 +1,2368 @@ +diff --git a/Documentation/x86/exception-tables.txt b/Documentation/x86/exception-tables.txt +index 32901aa36f0a..e396bcd8d830 100644 +--- a/Documentation/x86/exception-tables.txt ++++ b/Documentation/x86/exception-tables.txt +@@ -290,3 +290,38 @@ Due to the way that the exception table is built and needs to be ordered, + only use exceptions for code in the .text section. Any other section + will cause the exception table to not be sorted correctly, and the + exceptions will fail. ++ ++Things changed when 64-bit support was added to x86 Linux. Rather than ++double the size of the exception table by expanding the two entries ++from 32-bits to 64 bits, a clever trick was used to store addresses ++as relative offsets from the table itself. The assembly code changed ++from: ++ .long 1b,3b ++to: ++ .long (from) - . ++ .long (to) - . ++ ++and the C-code that uses these values converts back to absolute addresses ++like this: ++ ++ ex_insn_addr(const struct exception_table_entry *x) ++ { ++ return (unsigned long)&x->insn + x->insn; ++ } ++ ++In v4.6 the exception table entry was expanded with a new field "handler". ++This is also 32-bits wide and contains a third relative function ++pointer which points to one of: ++ ++1) int ex_handler_default(const struct exception_table_entry *fixup) ++ This is legacy case that just jumps to the fixup code ++2) int ex_handler_fault(const struct exception_table_entry *fixup) ++ This case provides the fault number of the trap that occurred at ++ entry->insn. It is used to distinguish page faults from machine ++ check. ++3) int ex_handler_ext(const struct exception_table_entry *fixup) ++ This case is used for uaccess_err ... we need to set a flag ++ in the task structure. Before the handler functions existed this ++ case was handled by adding a large offset to the fixup to tag ++ it as special. ++More functions can easily be added. +diff --git a/Makefile b/Makefile +index 391294301aaf..19d7d9f68e35 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 28 ++SUBLEVEL = 29 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/crypto/ghash-ce-glue.c b/arch/arm/crypto/ghash-ce-glue.c +index 03a39fe29246..9d9ba9acdddc 100644 +--- a/arch/arm/crypto/ghash-ce-glue.c ++++ b/arch/arm/crypto/ghash-ce-glue.c +@@ -226,6 +226,27 @@ static int ghash_async_digest(struct ahash_request *req) + } + } + ++static int ghash_async_import(struct ahash_request *req, const void *in) ++{ ++ struct ahash_request *cryptd_req = ahash_request_ctx(req); ++ struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); ++ struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm); ++ struct shash_desc *desc = cryptd_shash_desc(cryptd_req); ++ ++ desc->tfm = cryptd_ahash_child(ctx->cryptd_tfm); ++ desc->flags = req->base.flags; ++ ++ return crypto_shash_import(desc, in); ++} ++ ++static int ghash_async_export(struct ahash_request *req, void *out) ++{ ++ struct ahash_request *cryptd_req = ahash_request_ctx(req); ++ struct shash_desc *desc = cryptd_shash_desc(cryptd_req); ++ ++ return crypto_shash_export(desc, out); ++} ++ + static int ghash_async_setkey(struct crypto_ahash *tfm, const u8 *key, + unsigned int keylen) + { +@@ -274,7 +295,10 @@ static struct ahash_alg ghash_async_alg = { + .final = ghash_async_final, + .setkey = ghash_async_setkey, + .digest = ghash_async_digest, ++ .import = ghash_async_import, ++ .export = ghash_async_export, + .halg.digestsize = GHASH_DIGEST_SIZE, ++ .halg.statesize = sizeof(struct ghash_desc_ctx), + .halg.base = { + .cra_name = "ghash", + .cra_driver_name = "ghash-ce", +diff --git a/arch/arm/mach-pxa/pxa_cplds_irqs.c b/arch/arm/mach-pxa/pxa_cplds_irqs.c +index 2385052b0ce1..e362f865fcd2 100644 +--- a/arch/arm/mach-pxa/pxa_cplds_irqs.c ++++ b/arch/arm/mach-pxa/pxa_cplds_irqs.c +@@ -41,30 +41,35 @@ static irqreturn_t cplds_irq_handler(int in_irq, void *d) + unsigned long pending; + unsigned int bit; + +- pending = readl(fpga->base + FPGA_IRQ_SET_CLR) & fpga->irq_mask; +- for_each_set_bit(bit, &pending, CPLDS_NB_IRQ) +- generic_handle_irq(irq_find_mapping(fpga->irqdomain, bit)); ++ do { ++ pending = readl(fpga->base + FPGA_IRQ_SET_CLR) & fpga->irq_mask; ++ for_each_set_bit(bit, &pending, CPLDS_NB_IRQ) { ++ generic_handle_irq(irq_find_mapping(fpga->irqdomain, ++ bit)); ++ } ++ } while (pending); + + return IRQ_HANDLED; + } + +-static void cplds_irq_mask_ack(struct irq_data *d) ++static void cplds_irq_mask(struct irq_data *d) + { + struct cplds *fpga = irq_data_get_irq_chip_data(d); + unsigned int cplds_irq = irqd_to_hwirq(d); +- unsigned int set, bit = BIT(cplds_irq); ++ unsigned int bit = BIT(cplds_irq); + + fpga->irq_mask &= ~bit; + writel(fpga->irq_mask, fpga->base + FPGA_IRQ_MASK_EN); +- set = readl(fpga->base + FPGA_IRQ_SET_CLR); +- writel(set & ~bit, fpga->base + FPGA_IRQ_SET_CLR); + } + + static void cplds_irq_unmask(struct irq_data *d) + { + struct cplds *fpga = irq_data_get_irq_chip_data(d); + unsigned int cplds_irq = irqd_to_hwirq(d); +- unsigned int bit = BIT(cplds_irq); ++ unsigned int set, bit = BIT(cplds_irq); ++ ++ set = readl(fpga->base + FPGA_IRQ_SET_CLR); ++ writel(set & ~bit, fpga->base + FPGA_IRQ_SET_CLR); + + fpga->irq_mask |= bit; + writel(fpga->irq_mask, fpga->base + FPGA_IRQ_MASK_EN); +@@ -72,7 +77,8 @@ static void cplds_irq_unmask(struct irq_data *d) + + static struct irq_chip cplds_irq_chip = { + .name = "pxa_cplds", +- .irq_mask_ack = cplds_irq_mask_ack, ++ .irq_ack = cplds_irq_mask, ++ .irq_mask = cplds_irq_mask, + .irq_unmask = cplds_irq_unmask, + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, + }; +diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c +index 247a0dc012f1..c07bfb52275e 100644 +--- a/arch/powerpc/kernel/eeh_driver.c ++++ b/arch/powerpc/kernel/eeh_driver.c +@@ -909,6 +909,14 @@ static void eeh_handle_special_event(void) + /* Notify all devices to be down */ + eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); + bus = eeh_pe_bus_get(phb_pe); ++ if (!bus) { ++ pr_err("%s: Cannot find PCI bus for " ++ "PHB#%d-PE#%x\n", ++ __func__, ++ pe->phb->global_number, ++ pe->addr); ++ break; ++ } + eeh_pe_dev_traverse(pe, + eeh_report_failure, NULL); + pcibios_remove_pci_devices(bus); +diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c +index 32e26526f7e4..1eb698f653b4 100644 +--- a/arch/powerpc/kernel/nvram_64.c ++++ b/arch/powerpc/kernel/nvram_64.c +@@ -969,7 +969,7 @@ int __init nvram_remove_partition(const char *name, int sig, + + /* Make partition a free partition */ + part->header.signature = NVRAM_SIG_FREE; +- strncpy(part->header.name, "wwwwwwwwwwww", 12); ++ memset(part->header.name, 'w', 12); + part->header.checksum = nvram_checksum(&part->header); + rc = nvram_write_header(part); + if (rc <= 0) { +@@ -987,8 +987,8 @@ int __init nvram_remove_partition(const char *name, int sig, + } + if (prev) { + prev->header.length += part->header.length; +- prev->header.checksum = nvram_checksum(&part->header); +- rc = nvram_write_header(part); ++ prev->header.checksum = nvram_checksum(&prev->header); ++ rc = nvram_write_header(prev); + if (rc <= 0) { + printk(KERN_ERR "nvram_remove_partition: nvram_write failed (%d)\n", rc); + return rc; +diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c +index ba0cae69a396..92736851c795 100644 +--- a/arch/powerpc/platforms/powernv/eeh-powernv.c ++++ b/arch/powerpc/platforms/powernv/eeh-powernv.c +@@ -956,6 +956,11 @@ static int pnv_eeh_reset(struct eeh_pe *pe, int option) + } + + bus = eeh_pe_bus_get(pe); ++ if (!bus) { ++ pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n", ++ __func__, pe->phb->global_number, pe->addr); ++ return -EIO; ++ } + if (pci_is_root_bus(bus) || + pci_is_root_bus(bus->parent)) + ret = pnv_eeh_root_reset(hose, option); +diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h +index 189679aba703..f5063b6659eb 100644 +--- a/arch/x86/include/asm/asm.h ++++ b/arch/x86/include/asm/asm.h +@@ -44,19 +44,22 @@ + + /* Exception table entry */ + #ifdef __ASSEMBLY__ +-# define _ASM_EXTABLE(from,to) \ ++# define _ASM_EXTABLE_HANDLE(from, to, handler) \ + .pushsection "__ex_table","a" ; \ +- .balign 8 ; \ ++ .balign 4 ; \ + .long (from) - . ; \ + .long (to) - . ; \ ++ .long (handler) - . ; \ + .popsection + +-# define _ASM_EXTABLE_EX(from,to) \ +- .pushsection "__ex_table","a" ; \ +- .balign 8 ; \ +- .long (from) - . ; \ +- .long (to) - . + 0x7ffffff0 ; \ +- .popsection ++# define _ASM_EXTABLE(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) ++ ++# define _ASM_EXTABLE_FAULT(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) ++ ++# define _ASM_EXTABLE_EX(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) + + # define _ASM_NOKPROBE(entry) \ + .pushsection "_kprobe_blacklist","aw" ; \ +@@ -89,19 +92,24 @@ + .endm + + #else +-# define _ASM_EXTABLE(from,to) \ ++# define _EXPAND_EXTABLE_HANDLE(x) #x ++# define _ASM_EXTABLE_HANDLE(from, to, handler) \ + " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 8\n" \ ++ " .balign 4\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ ++ " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \ + " .popsection\n" + +-# define _ASM_EXTABLE_EX(from,to) \ +- " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 8\n" \ +- " .long (" #from ") - .\n" \ +- " .long (" #to ") - . + 0x7ffffff0\n" \ +- " .popsection\n" ++# define _ASM_EXTABLE(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) ++ ++# define _ASM_EXTABLE_FAULT(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) ++ ++# define _ASM_EXTABLE_EX(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) ++ + /* For C file, we already have NOKPROBE_SYMBOL macro */ + #endif + +diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h +index d42252ce9b4d..3794c7331cfc 100644 +--- a/arch/x86/include/asm/uaccess.h ++++ b/arch/x86/include/asm/uaccess.h +@@ -90,12 +90,11 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + likely(!__range_not_ok(addr, size, user_addr_max())) + + /* +- * The exception table consists of pairs of addresses relative to the +- * exception table enty itself: the first is the address of an +- * instruction that is allowed to fault, and the second is the address +- * at which the program should continue. No registers are modified, +- * so it is entirely up to the continuation code to figure out what to +- * do. ++ * The exception table consists of triples of addresses relative to the ++ * exception table entry itself. The first address is of an instruction ++ * that is allowed to fault, the second is the target at which the program ++ * should continue. The third is a handler function to deal with the fault ++ * caused by the instruction in the first field. + * + * All the routines below use bits of fixup code that are out of line + * with the main instruction path. This means when everything is well, +@@ -104,13 +103,14 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + */ + + struct exception_table_entry { +- int insn, fixup; ++ int insn, fixup, handler; + }; + /* This is not the generic standard exception_table_entry format */ + #define ARCH_HAS_SORT_EXTABLE + #define ARCH_HAS_SEARCH_EXTABLE + +-extern int fixup_exception(struct pt_regs *regs); ++extern int fixup_exception(struct pt_regs *regs, int trapnr); ++extern bool ex_has_fault_handler(unsigned long ip); + extern int early_fixup_exception(unsigned long *ip); + + /* +diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c +index 9fdf1d330727..a257d6077d1b 100644 +--- a/arch/x86/kernel/early-quirks.c ++++ b/arch/x86/kernel/early-quirks.c +@@ -331,12 +331,11 @@ static u32 __init i85x_stolen_base(int num, int slot, int func, size_t stolen_si + + static u32 __init i865_stolen_base(int num, int slot, int func, size_t stolen_size) + { +- /* +- * FIXME is the graphics stolen memory region +- * always at TOUD? Ie. is it always the last +- * one to be allocated by the BIOS? +- */ +- return read_pci_config_16(0, 0, 0, I865_TOUD) << 16; ++ u16 toud = 0; ++ ++ toud = read_pci_config_16(0, 0, 0, I865_TOUD); ++ ++ return (phys_addr_t)(toud << 16) + i845_tseg_size(); + } + + static size_t __init i830_stolen_size(int num, int slot, int func) +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c +index 023c442c33bb..e1d1f6cbaf11 100644 +--- a/arch/x86/kernel/kprobes/core.c ++++ b/arch/x86/kernel/kprobes/core.c +@@ -1000,7 +1000,7 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) + * In case the user-specified fault handler returned + * zero, try to fix up. + */ +- if (fixup_exception(regs)) ++ if (fixup_exception(regs, trapnr)) + return 1; + + /* +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c +index 679302c312f8..5621f882645e 100644 +--- a/arch/x86/kernel/traps.c ++++ b/arch/x86/kernel/traps.c +@@ -199,7 +199,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, + } + + if (!user_mode(regs)) { +- if (!fixup_exception(regs)) { ++ if (!fixup_exception(regs, trapnr)) { + tsk->thread.error_code = error_code; + tsk->thread.trap_nr = trapnr; + die(str, regs, error_code); +@@ -453,7 +453,7 @@ do_general_protection(struct pt_regs *regs, long error_code) + + tsk = current; + if (!user_mode(regs)) { +- if (fixup_exception(regs)) ++ if (fixup_exception(regs, X86_TRAP_GP)) + return; + + tsk->thread.error_code = error_code; +@@ -699,7 +699,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) + conditional_sti(regs); + + if (!user_mode(regs)) { +- if (!fixup_exception(regs)) { ++ if (!fixup_exception(regs, trapnr)) { + task->thread.error_code = error_code; + task->thread.trap_nr = trapnr; + die(str, regs, error_code); +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c +index 903ec1e9c326..9dd7e4b7fcde 100644 +--- a/arch/x86/mm/extable.c ++++ b/arch/x86/mm/extable.c +@@ -3,6 +3,9 @@ + #include + #include + ++typedef bool (*ex_handler_t)(const struct exception_table_entry *, ++ struct pt_regs *, int); ++ + static inline unsigned long + ex_insn_addr(const struct exception_table_entry *x) + { +@@ -13,11 +16,56 @@ ex_fixup_addr(const struct exception_table_entry *x) + { + return (unsigned long)&x->fixup + x->fixup; + } ++static inline ex_handler_t ++ex_fixup_handler(const struct exception_table_entry *x) ++{ ++ return (ex_handler_t)((unsigned long)&x->handler + x->handler); ++} + +-int fixup_exception(struct pt_regs *regs) ++bool ex_handler_default(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) + { +- const struct exception_table_entry *fixup; +- unsigned long new_ip; ++ regs->ip = ex_fixup_addr(fixup); ++ return true; ++} ++EXPORT_SYMBOL(ex_handler_default); ++ ++bool ex_handler_fault(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) ++{ ++ regs->ip = ex_fixup_addr(fixup); ++ regs->ax = trapnr; ++ return true; ++} ++EXPORT_SYMBOL_GPL(ex_handler_fault); ++ ++bool ex_handler_ext(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) ++{ ++ /* Special hack for uaccess_err */ ++ current_thread_info()->uaccess_err = 1; ++ regs->ip = ex_fixup_addr(fixup); ++ return true; ++} ++EXPORT_SYMBOL(ex_handler_ext); ++ ++bool ex_has_fault_handler(unsigned long ip) ++{ ++ const struct exception_table_entry *e; ++ ex_handler_t handler; ++ ++ e = search_exception_tables(ip); ++ if (!e) ++ return false; ++ handler = ex_fixup_handler(e); ++ ++ return handler == ex_handler_fault; ++} ++ ++int fixup_exception(struct pt_regs *regs, int trapnr) ++{ ++ const struct exception_table_entry *e; ++ ex_handler_t handler; + + #ifdef CONFIG_PNPBIOS + if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) { +@@ -33,42 +81,34 @@ int fixup_exception(struct pt_regs *regs) + } + #endif + +- fixup = search_exception_tables(regs->ip); +- if (fixup) { +- new_ip = ex_fixup_addr(fixup); +- +- if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { +- /* Special hack for uaccess_err */ +- current_thread_info()->uaccess_err = 1; +- new_ip -= 0x7ffffff0; +- } +- regs->ip = new_ip; +- return 1; +- } ++ e = search_exception_tables(regs->ip); ++ if (!e) ++ return 0; + +- return 0; ++ handler = ex_fixup_handler(e); ++ return handler(e, regs, trapnr); + } + + /* Restricted version used during very early boot */ + int __init early_fixup_exception(unsigned long *ip) + { +- const struct exception_table_entry *fixup; ++ const struct exception_table_entry *e; + unsigned long new_ip; ++ ex_handler_t handler; + +- fixup = search_exception_tables(*ip); +- if (fixup) { +- new_ip = ex_fixup_addr(fixup); ++ e = search_exception_tables(*ip); ++ if (!e) ++ return 0; + +- if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { +- /* uaccess handling not supported during early boot */ +- return 0; +- } ++ new_ip = ex_fixup_addr(e); ++ handler = ex_fixup_handler(e); + +- *ip = new_ip; +- return 1; +- } ++ /* special handling not supported during early boot */ ++ if (handler != ex_handler_default) ++ return 0; + +- return 0; ++ *ip = new_ip; ++ return 1; + } + + /* +@@ -133,6 +173,8 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup += i; + i += 4; ++ p->handler += i; ++ i += 4; + } + + sort(start, finish - start, sizeof(struct exception_table_entry), +@@ -145,6 +187,8 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup -= i; + i += 4; ++ p->handler -= i; ++ i += 4; + } + } + +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c +index e830c71a1323..03898aea6e0f 100644 +--- a/arch/x86/mm/fault.c ++++ b/arch/x86/mm/fault.c +@@ -663,7 +663,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, + int sig; + + /* Are we prepared to handle this kernel fault? */ +- if (fixup_exception(regs)) { ++ if (fixup_exception(regs, X86_TRAP_PF)) { + /* + * Any interrupt that takes a fault gets the fixup. This makes + * the below recursive fault logic only apply to a faults from +diff --git a/crypto/gcm.c b/crypto/gcm.c +index d9ea5f9c0574..1238b3c5a321 100644 +--- a/crypto/gcm.c ++++ b/crypto/gcm.c +@@ -117,7 +117,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, + struct crypto_ablkcipher *ctr = ctx->ctr; + struct { + be128 hash; +- u8 iv[8]; ++ u8 iv[16]; + + struct crypto_gcm_setkey_result result; + +diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c +index 01d4be2c354b..f5c26a5f6875 100644 +--- a/drivers/char/hw_random/omap-rng.c ++++ b/drivers/char/hw_random/omap-rng.c +@@ -385,7 +385,7 @@ static int omap_rng_probe(struct platform_device *pdev) + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); +- if (ret) { ++ if (ret < 0) { + dev_err(&pdev->dev, "Failed to runtime_get device: %d\n", ret); + pm_runtime_put_noidle(&pdev->dev); + goto err_ioremap; +@@ -443,7 +443,7 @@ static int __maybe_unused omap_rng_resume(struct device *dev) + int ret; + + ret = pm_runtime_get_sync(dev); +- if (ret) { ++ if (ret < 0) { + dev_err(dev, "Failed to runtime_get device: %d\n", ret); + pm_runtime_put_noidle(dev); + return ret; +diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c +index bbf206e3da0d..ac9582de64a5 100644 +--- a/drivers/clk/clk-divider.c ++++ b/drivers/clk/clk-divider.c +@@ -354,7 +354,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, + + /* if read only, just return current value */ + if (divider->flags & CLK_DIVIDER_READ_ONLY) { +- bestdiv = readl(divider->reg) >> divider->shift; ++ bestdiv = clk_readl(divider->reg) >> divider->shift; + bestdiv &= div_mask(divider->width); + bestdiv = _get_div(divider->table, bestdiv, divider->flags, + divider->width); +diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c +index 7bc1c4527ae4..8b77abb6bc22 100644 +--- a/drivers/clk/clk-qoriq.c ++++ b/drivers/clk/clk-qoriq.c +@@ -766,7 +766,11 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx) + if (!hwc) + return NULL; + +- hwc->reg = cg->regs + 0x20 * idx; ++ if (cg->info.flags & CG_VER3) ++ hwc->reg = cg->regs + 0x70000 + 0x20 * idx; ++ else ++ hwc->reg = cg->regs + 0x20 * idx; ++ + hwc->info = cg->info.cmux_groups[cg->info.cmux_to_group[idx]]; + + /* +diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c +index b0978d3b83e2..d302ed3b8225 100644 +--- a/drivers/clk/imx/clk-imx35.c ++++ b/drivers/clk/imx/clk-imx35.c +@@ -115,7 +115,7 @@ static void __init _mx35_clocks_init(void) + } + + clk[ckih] = imx_clk_fixed("ckih", 24000000); +- clk[ckil] = imx_clk_fixed("ckih", 32768); ++ clk[ckil] = imx_clk_fixed("ckil", 32768); + clk[mpll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "mpll", "ckih", base + MX35_CCM_MPCTL); + clk[ppll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "ppll", "ckih", base + MX35_CCM_PPCTL); + +diff --git a/drivers/dma/ipu/ipu_irq.c b/drivers/dma/ipu/ipu_irq.c +index 2bf37e68ad0f..dd184b50e5b4 100644 +--- a/drivers/dma/ipu/ipu_irq.c ++++ b/drivers/dma/ipu/ipu_irq.c +@@ -286,22 +286,21 @@ static void ipu_irq_handler(struct irq_desc *desc) + raw_spin_unlock(&bank_lock); + while ((line = ffs(status))) { + struct ipu_irq_map *map; +- unsigned int irq = NO_IRQ; ++ unsigned int irq; + + line--; + status &= ~(1UL << line); + + raw_spin_lock(&bank_lock); + map = src2map(32 * i + line); +- if (map) +- irq = map->irq; +- raw_spin_unlock(&bank_lock); +- + if (!map) { ++ raw_spin_unlock(&bank_lock); + pr_err("IPU: Interrupt on unmapped source %u bank %d\n", + line, i); + continue; + } ++ irq = map->irq; ++ raw_spin_unlock(&bank_lock); + generic_handle_irq(irq); + } + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +index fe36caf1b7d7..14f57d9915e3 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +@@ -113,24 +113,26 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev, + printk("\n"); + } + ++ + u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev) + { + struct drm_device *dev = adev->ddev; + struct drm_crtc *crtc; + struct amdgpu_crtc *amdgpu_crtc; +- u32 line_time_us, vblank_lines; ++ u32 vblank_in_pixels; + u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ + + if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + amdgpu_crtc = to_amdgpu_crtc(crtc); + if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { +- line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) / +- amdgpu_crtc->hw_mode.clock; +- vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end - ++ vblank_in_pixels = ++ amdgpu_crtc->hw_mode.crtc_htotal * ++ (amdgpu_crtc->hw_mode.crtc_vblank_end - + amdgpu_crtc->hw_mode.crtc_vdisplay + +- (amdgpu_crtc->v_border * 2); +- vblank_time_us = vblank_lines * line_time_us; ++ (amdgpu_crtc->v_border * 2)); ++ ++ vblank_time_us = vblank_in_pixels * 1000 / amdgpu_crtc->hw_mode.clock; + break; + } + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +index 4488e82f87b0..a5c824078472 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +@@ -227,7 +227,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file + type = AMD_IP_BLOCK_TYPE_UVD; + ring_mask = adev->uvd.ring.ready ? 1 : 0; + ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; +- ib_size_alignment = 8; ++ ib_size_alignment = 16; + break; + case AMDGPU_HW_IP_VCE: + type = AMD_IP_BLOCK_TYPE_VCE; +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +index 4dcc8fba5792..5b261adb4b69 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +@@ -419,16 +419,6 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } +- + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + idx = 0; +@@ -452,6 +442,19 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) + continue; + } + ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ tmp = RREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx]); ++ tmp = REG_SET_FIELD(tmp, DC_HPD_INT_CONTROL, DC_HPD_INT_EN, 0); ++ WREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx], tmp); ++ continue; ++ } ++ + tmp = RREG32(mmDC_HPD_CONTROL + hpd_offsets[idx]); + tmp = REG_SET_FIELD(tmp, DC_HPD_CONTROL, DC_HPD_EN, 1); + WREG32(mmDC_HPD_CONTROL + hpd_offsets[idx], tmp); +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +index 8f1e51128b33..c161eeda417b 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +@@ -409,16 +409,6 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } +- + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + idx = 0; +@@ -442,6 +432,19 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) + continue; + } + ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ tmp = RREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx]); ++ tmp = REG_SET_FIELD(tmp, DC_HPD_INT_CONTROL, DC_HPD_INT_EN, 0); ++ WREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx], tmp); ++ continue; ++ } ++ + tmp = RREG32(mmDC_HPD_CONTROL + hpd_offsets[idx]); + tmp = REG_SET_FIELD(tmp, DC_HPD_CONTROL, DC_HPD_EN, 1); + WREG32(mmDC_HPD_CONTROL + hpd_offsets[idx], tmp); +@@ -3030,6 +3033,7 @@ static int dce_v11_0_sw_fini(void *handle) + + dce_v11_0_afmt_fini(adev); + ++ drm_mode_config_cleanup(adev->ddev); + adev->mode_info.mode_config_initialized = false; + + return 0; +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +index 42d954dc436d..9b4dcf76ce6c 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +@@ -392,15 +392,6 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + WREG32(mmDC_HPD1_CONTROL, tmp); +@@ -423,6 +414,45 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) + default: + break; + } ++ ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ u32 dc_hpd_int_cntl_reg, dc_hpd_int_cntl; ++ ++ switch (amdgpu_connector->hpd.hpd) { ++ case AMDGPU_HPD_1: ++ dc_hpd_int_cntl_reg = mmDC_HPD1_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_2: ++ dc_hpd_int_cntl_reg = mmDC_HPD2_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_3: ++ dc_hpd_int_cntl_reg = mmDC_HPD3_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_4: ++ dc_hpd_int_cntl_reg = mmDC_HPD4_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_5: ++ dc_hpd_int_cntl_reg = mmDC_HPD5_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_6: ++ dc_hpd_int_cntl_reg = mmDC_HPD6_INT_CONTROL; ++ break; ++ default: ++ continue; ++ } ++ ++ dc_hpd_int_cntl = RREG32(dc_hpd_int_cntl_reg); ++ dc_hpd_int_cntl &= ~DC_HPD1_INT_CONTROL__DC_HPD1_INT_EN_MASK; ++ WREG32(dc_hpd_int_cntl_reg, dc_hpd_int_cntl); ++ continue; ++ } ++ + dce_v8_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); + amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); + } +diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c +index 9f935f55d74c..968b31f39884 100644 +--- a/drivers/gpu/drm/drm_prime.c ++++ b/drivers/gpu/drm/drm_prime.c +@@ -339,14 +339,17 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { + * using the PRIME helpers. + */ + struct dma_buf *drm_gem_prime_export(struct drm_device *dev, +- struct drm_gem_object *obj, int flags) ++ struct drm_gem_object *obj, ++ int flags) + { +- DEFINE_DMA_BUF_EXPORT_INFO(exp_info); +- +- exp_info.ops = &drm_gem_prime_dmabuf_ops; +- exp_info.size = obj->size; +- exp_info.flags = flags; +- exp_info.priv = obj; ++ struct dma_buf_export_info exp_info = { ++ .exp_name = KBUILD_MODNAME, /* white lie for debug */ ++ .owner = dev->driver->fops->owner, ++ .ops = &drm_gem_prime_dmabuf_ops, ++ .size = obj->size, ++ .flags = flags, ++ .priv = obj, ++ }; + + if (dev->driver->gem_prime_res_obj) + exp_info.resv = dev->driver->gem_prime_res_obj(obj); +diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h +index d400d6773bbb..fb9f647bb5cd 100644 +--- a/drivers/gpu/drm/i915/i915_drv.h ++++ b/drivers/gpu/drm/i915/i915_drv.h +@@ -2150,21 +2150,19 @@ struct drm_i915_gem_object { + /** Record of address bit 17 of each page at last unbind. */ + unsigned long *bit_17; + +- union { +- /** for phy allocated objects */ +- struct drm_dma_handle *phys_handle; +- +- struct i915_gem_userptr { +- uintptr_t ptr; +- unsigned read_only :1; +- unsigned workers :4; ++ struct i915_gem_userptr { ++ uintptr_t ptr; ++ unsigned read_only :1; ++ unsigned workers :4; + #define I915_GEM_USERPTR_MAX_WORKERS 15 + +- struct i915_mm_struct *mm; +- struct i915_mmu_object *mmu_object; +- struct work_struct *work; +- } userptr; +- }; ++ struct i915_mm_struct *mm; ++ struct i915_mmu_object *mmu_object; ++ struct work_struct *work; ++ } userptr; ++ ++ /** for phys allocated objects */ ++ struct drm_dma_handle *phys_handle; + }; + #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base) + +diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c +index 87e919a06b27..5d2323a40c25 100644 +--- a/drivers/gpu/drm/i915/i915_gem_stolen.c ++++ b/drivers/gpu/drm/i915/i915_gem_stolen.c +@@ -108,17 +108,28 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) + pci_read_config_dword(dev->pdev, 0x5c, &base); + base &= ~((1<<20) - 1); + } else if (IS_I865G(dev)) { ++ u32 tseg_size = 0; + u16 toud = 0; ++ u8 tmp; ++ ++ pci_bus_read_config_byte(dev->pdev->bus, PCI_DEVFN(0, 0), ++ I845_ESMRAMC, &tmp); ++ ++ if (tmp & TSEG_ENABLE) { ++ switch (tmp & I845_TSEG_SIZE_MASK) { ++ case I845_TSEG_SIZE_512K: ++ tseg_size = KB(512); ++ break; ++ case I845_TSEG_SIZE_1M: ++ tseg_size = MB(1); ++ break; ++ } ++ } + +- /* +- * FIXME is the graphics stolen memory region +- * always at TOUD? Ie. is it always the last +- * one to be allocated by the BIOS? +- */ + pci_bus_read_config_word(dev->pdev->bus, PCI_DEVFN(0, 0), + I865_TOUD, &toud); + +- base = toud << 16; ++ base = (toud << 16) + tseg_size; + } else if (IS_I85X(dev)) { + u32 tseg_size = 0; + u32 tom; +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c +index ebbd23407a80..0f8367da0663 100644 +--- a/drivers/gpu/drm/i915/intel_dp.c ++++ b/drivers/gpu/drm/i915/intel_dp.c +@@ -4648,7 +4648,7 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, + * + * Return %true if @port is connected, %false otherwise. + */ +-bool intel_digital_port_connected(struct drm_i915_private *dev_priv, ++static bool intel_digital_port_connected(struct drm_i915_private *dev_priv, + struct intel_digital_port *port) + { + if (HAS_PCH_IBX(dev_priv)) +diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h +index 41442e619595..722aa159cd28 100644 +--- a/drivers/gpu/drm/i915/intel_drv.h ++++ b/drivers/gpu/drm/i915/intel_drv.h +@@ -1231,8 +1231,6 @@ void intel_edp_drrs_disable(struct intel_dp *intel_dp); + void intel_edp_drrs_invalidate(struct drm_device *dev, + unsigned frontbuffer_bits); + void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits); +-bool intel_digital_port_connected(struct drm_i915_private *dev_priv, +- struct intel_digital_port *port); + void hsw_dp_set_ddi_pll_sel(struct intel_crtc_state *pipe_config); + + /* intel_dp_mst.c */ +diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c +index dff69fef47e0..3b92cad8bef2 100644 +--- a/drivers/gpu/drm/i915/intel_hdmi.c ++++ b/drivers/gpu/drm/i915/intel_hdmi.c +@@ -1331,19 +1331,18 @@ intel_hdmi_unset_edid(struct drm_connector *connector) + } + + static bool +-intel_hdmi_set_edid(struct drm_connector *connector, bool force) ++intel_hdmi_set_edid(struct drm_connector *connector) + { + struct drm_i915_private *dev_priv = to_i915(connector->dev); + struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); +- struct edid *edid = NULL; ++ struct edid *edid; + bool connected = false; + + intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); + +- if (force) +- edid = drm_get_edid(connector, +- intel_gmbus_get_adapter(dev_priv, +- intel_hdmi->ddc_bus)); ++ edid = drm_get_edid(connector, ++ intel_gmbus_get_adapter(dev_priv, ++ intel_hdmi->ddc_bus)); + + intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS); + +@@ -1371,37 +1370,16 @@ static enum drm_connector_status + intel_hdmi_detect(struct drm_connector *connector, bool force) + { + enum drm_connector_status status; +- struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); + struct drm_i915_private *dev_priv = to_i915(connector->dev); +- bool live_status = false; +- unsigned int try; + + DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", + connector->base.id, connector->name); + + intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); + +- for (try = 0; !live_status && try < 9; try++) { +- if (try) +- msleep(10); +- live_status = intel_digital_port_connected(dev_priv, +- hdmi_to_dig_port(intel_hdmi)); +- } +- +- if (!live_status) { +- DRM_DEBUG_KMS("HDMI live status down\n"); +- /* +- * Live status register is not reliable on all intel platforms. +- * So consider live_status only for certain platforms, for +- * others, read EDID to determine presence of sink. +- */ +- if (INTEL_INFO(dev_priv)->gen < 7 || IS_IVYBRIDGE(dev_priv)) +- live_status = true; +- } +- + intel_hdmi_unset_edid(connector); + +- if (intel_hdmi_set_edid(connector, live_status)) { ++ if (intel_hdmi_set_edid(connector)) { + struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); + + hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; +@@ -1427,7 +1405,7 @@ intel_hdmi_force(struct drm_connector *connector) + if (connector->status != connector_status_connected) + return; + +- intel_hdmi_set_edid(connector, true); ++ intel_hdmi_set_edid(connector); + hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; + } + +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c +index 1e851e037c29..3f802163f7d4 100644 +--- a/drivers/gpu/drm/i915/intel_pm.c ++++ b/drivers/gpu/drm/i915/intel_pm.c +@@ -2097,32 +2097,34 @@ static void intel_read_wm_latency(struct drm_device *dev, uint16_t wm[8]) + GEN9_MEM_LATENCY_LEVEL_MASK; + + /* ++ * If a level n (n > 1) has a 0us latency, all levels m (m >= n) ++ * need to be disabled. We make sure to sanitize the values out ++ * of the punit to satisfy this requirement. ++ */ ++ for (level = 1; level <= max_level; level++) { ++ if (wm[level] == 0) { ++ for (i = level + 1; i <= max_level; i++) ++ wm[i] = 0; ++ break; ++ } ++ } ++ ++ /* + * WaWmMemoryReadLatency:skl + * + * punit doesn't take into account the read latency so we need +- * to add 2us to the various latency levels we retrieve from +- * the punit. +- * - W0 is a bit special in that it's the only level that +- * can't be disabled if we want to have display working, so +- * we always add 2us there. +- * - For levels >=1, punit returns 0us latency when they are +- * disabled, so we respect that and don't add 2us then +- * +- * Additionally, if a level n (n > 1) has a 0us latency, all +- * levels m (m >= n) need to be disabled. We make sure to +- * sanitize the values out of the punit to satisfy this +- * requirement. ++ * to add 2us to the various latency levels we retrieve from the ++ * punit when level 0 response data us 0us. + */ +- wm[0] += 2; +- for (level = 1; level <= max_level; level++) +- if (wm[level] != 0) ++ if (wm[0] == 0) { ++ wm[0] += 2; ++ for (level = 1; level <= max_level; level++) { ++ if (wm[level] == 0) ++ break; + wm[level] += 2; +- else { +- for (i = level + 1; i <= max_level; i++) +- wm[i] = 0; +- +- break; + } ++ } ++ + } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { + uint64_t sskpd = I915_READ64(MCH_SSKPD); + +diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c +index fa2154493cf1..470af4aa4a6a 100644 +--- a/drivers/gpu/drm/radeon/r600_dpm.c ++++ b/drivers/gpu/drm/radeon/r600_dpm.c +@@ -156,19 +156,20 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev) + struct drm_device *dev = rdev->ddev; + struct drm_crtc *crtc; + struct radeon_crtc *radeon_crtc; +- u32 line_time_us, vblank_lines; ++ u32 vblank_in_pixels; + u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ + + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + radeon_crtc = to_radeon_crtc(crtc); + if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { +- line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / +- radeon_crtc->hw_mode.clock; +- vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - +- radeon_crtc->hw_mode.crtc_vdisplay + +- (radeon_crtc->v_border * 2); +- vblank_time_us = vblank_lines * line_time_us; ++ vblank_in_pixels = ++ radeon_crtc->hw_mode.crtc_htotal * ++ (radeon_crtc->hw_mode.crtc_vblank_end - ++ radeon_crtc->hw_mode.crtc_vdisplay + ++ (radeon_crtc->v_border * 2)); ++ ++ vblank_time_us = vblank_in_pixels * 1000 / radeon_crtc->hw_mode.clock; + break; + } + } +diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c +index e2dd5d19c32c..4aa2cbe4c85f 100644 +--- a/drivers/gpu/drm/radeon/radeon_device.c ++++ b/drivers/gpu/drm/radeon/radeon_device.c +@@ -660,8 +660,9 @@ bool radeon_card_posted(struct radeon_device *rdev) + { + uint32_t reg; + +- /* for pass through, always force asic_init */ +- if (radeon_device_is_virtual()) ++ /* for pass through, always force asic_init for CI */ ++ if (rdev->family >= CHIP_BONAIRE && ++ radeon_device_is_virtual()) + return false; + + /* required for EFI mode on macbook2,1 which uses an r5xx asic */ +diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c +index 3aaa07dafc00..472e0771832e 100644 +--- a/drivers/gpu/drm/radeon/si_dpm.c ++++ b/drivers/gpu/drm/radeon/si_dpm.c +@@ -4112,7 +4112,7 @@ static int si_populate_smc_voltage_tables(struct radeon_device *rdev, + &rdev->pm.dpm.dyn_state.phase_shedding_limits_table)) { + si_populate_smc_voltage_table(rdev, &si_pi->vddc_phase_shed_table, table); + +- table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] = ++ table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] = + cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low); + + si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_phase_shedding_delay, +diff --git a/drivers/gpu/drm/radeon/sislands_smc.h b/drivers/gpu/drm/radeon/sislands_smc.h +index 3c779838d9ab..966e3a556011 100644 +--- a/drivers/gpu/drm/radeon/sislands_smc.h ++++ b/drivers/gpu/drm/radeon/sislands_smc.h +@@ -194,6 +194,7 @@ typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE; + #define SISLANDS_SMC_VOLTAGEMASK_VDDC 0 + #define SISLANDS_SMC_VOLTAGEMASK_MVDD 1 + #define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2 ++#define SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING 3 + #define SISLANDS_SMC_VOLTAGEMASK_MAX 4 + + struct SISLANDS_SMC_VOLTAGEMASKTABLE +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +index 4948c1529836..ecf15cf0c3fd 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +@@ -3830,14 +3830,14 @@ static void *vmw_execbuf_cmdbuf(struct vmw_private *dev_priv, + int ret; + + *header = NULL; +- if (!dev_priv->cman || kernel_commands) +- return kernel_commands; +- + if (command_size > SVGA_CB_MAX_SIZE) { + DRM_ERROR("Command buffer is too large.\n"); + return ERR_PTR(-EINVAL); + } + ++ if (!dev_priv->cman || kernel_commands) ++ return kernel_commands; ++ + /* If possible, add a little space for fencing. */ + cmdbuf_size = command_size + 512; + cmdbuf_size = min_t(size_t, cmdbuf_size, SVGA_CB_MAX_SIZE); +diff --git a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c +index 71493d2af912..70a6985334d5 100644 +--- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c +@@ -4102,7 +4102,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, + (u8 *)&settings->beacon.head[ie_offset], + settings->beacon.head_len - ie_offset, + WLAN_EID_SSID); +- if (!ssid_ie) ++ if (!ssid_ie || ssid_ie->len > IEEE80211_MAX_SSID_LEN) + return -EINVAL; + + memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len); +diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c +index 3cda1f956f0b..6378dfd3b4e8 100644 +--- a/drivers/net/wireless/mwifiex/join.c ++++ b/drivers/net/wireless/mwifiex/join.c +@@ -661,9 +661,8 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, + priv->assoc_rsp_size = min(le16_to_cpu(resp->size) - S_DS_GEN, + sizeof(priv->assoc_rsp_buf)); + +- memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); +- + assoc_rsp->a_id = cpu_to_le16(aid); ++ memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); + + if (status_code) { + priv->adapter->dbg.num_cmd_assoc_failure++; +diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c +index 1fea2c7ef97f..6fc31bdc639b 100644 +--- a/drivers/power/bq24257_charger.c ++++ b/drivers/power/bq24257_charger.c +@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client, + return ret; + } + ++ ret = bq24257_power_supply_init(bq); ++ if (ret < 0) { ++ dev_err(dev, "Failed to register power supply\n"); ++ return ret; ++ } ++ + ret = devm_request_threaded_irq(dev, client->irq, NULL, + bq24257_irq_handler_thread, + IRQF_TRIGGER_FALLING | +@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client, + return ret; + } + +- ret = bq24257_power_supply_init(bq); +- if (ret < 0) { +- dev_err(dev, "Failed to register power supply\n"); +- return ret; +- } +- + ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group); + if (ret < 0) { + dev_err(dev, "Can't create sysfs entries\n"); +diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c +index 7c511add5aa7..bae98521c808 100644 +--- a/drivers/s390/char/con3270.c ++++ b/drivers/s390/char/con3270.c +@@ -124,7 +124,12 @@ con3270_create_status(struct con3270 *cp) + static void + con3270_update_string(struct con3270 *cp, struct string *s, int nr) + { +- if (s->len >= cp->view.cols - 5) ++ if (s->len < 4) { ++ /* This indicates a bug, but printing a warning would ++ * cause a deadlock. */ ++ return; ++ } ++ if (s->string[s->len - 4] != TO_RA) + return; + raw3270_buffer_address(cp->view.dev, s->string + s->len - 3, + cp->view.cols * (nr + 1)); +@@ -461,11 +466,11 @@ con3270_cline_end(struct con3270 *cp) + cp->cline->len + 4 : cp->view.cols; + s = con3270_alloc_string(cp, size); + memcpy(s->string, cp->cline->string, cp->cline->len); +- if (s->len < cp->view.cols - 5) { ++ if (cp->cline->len < cp->view.cols - 5) { + s->string[s->len - 4] = TO_RA; + s->string[s->len - 1] = 0; + } else { +- while (--size > cp->cline->len) ++ while (--size >= cp->cline->len) + s->string[size] = cp->view.ascebc[' ']; + } + /* Replace cline with allocated line s and reset cline. */ +diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c +index c424c0c7367e..1e16331891a9 100644 +--- a/drivers/s390/cio/chsc.c ++++ b/drivers/s390/cio/chsc.c +@@ -95,12 +95,13 @@ struct chsc_ssd_area { + int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) + { + struct chsc_ssd_area *ssd_area; ++ unsigned long flags; + int ccode; + int ret; + int i; + int mask; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + ssd_area = chsc_page; + ssd_area->request.length = 0x0010; +@@ -144,7 +145,7 @@ int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) + ssd->fla[i] = ssd_area->fla[i]; + } + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -832,9 +833,10 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable) + u32 fmt : 4; + u32 : 16; + } __attribute__ ((packed)) *secm_area; ++ unsigned long flags; + int ret, ccode; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + secm_area = chsc_page; + secm_area->request.length = 0x0050; +@@ -864,7 +866,7 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable) + CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n", + secm_area->response.code); + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -993,6 +995,7 @@ chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, + + int chsc_get_channel_measurement_chars(struct channel_path *chp) + { ++ unsigned long flags; + int ccode, ret; + + struct { +@@ -1022,7 +1025,7 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) + if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm) + return 0; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + scmc_area = chsc_page; + scmc_area->request.length = 0x0010; +@@ -1054,7 +1057,7 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) + chsc_initialize_cmg_chars(chp, scmc_area->cmcv, + (struct cmg_chars *) &scmc_area->data); + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -1135,6 +1138,7 @@ struct css_chsc_char css_chsc_characteristics; + int __init + chsc_determine_css_characteristics(void) + { ++ unsigned long flags; + int result; + struct { + struct chsc_header request; +@@ -1147,7 +1151,7 @@ chsc_determine_css_characteristics(void) + u32 chsc_char[508]; + } __attribute__ ((packed)) *scsc_area; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + scsc_area = chsc_page; + scsc_area->request.length = 0x0010; +@@ -1169,7 +1173,7 @@ chsc_determine_css_characteristics(void) + CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n", + scsc_area->response.code); + exit: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return result; + } + +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c +index 6180f7970bbf..0969cea1089a 100644 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c +@@ -4510,7 +4510,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) + le16_to_cpu(mpi_reply->DevHandle)); + mpt3sas_trigger_scsi(ioc, data.skey, data.asc, data.ascq); + +- if (!(ioc->logging_level & MPT_DEBUG_REPLY) && ++ if ((ioc->logging_level & MPT_DEBUG_REPLY) && + ((scmd->sense_buffer[2] == UNIT_ATTENTION) || + (scmd->sense_buffer[2] == MEDIUM_ERROR) || + (scmd->sense_buffer[2] == HARDWARE_ERROR))) +diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c +index 39412c9097c6..a3965cac1b34 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -753,7 +753,6 @@ static int dspi_remove(struct platform_device *pdev) + /* Disconnect from the SPI framework */ + clk_disable_unprepare(dspi->clk); + spi_unregister_master(dspi->master); +- spi_master_put(dspi->master); + + return 0; + } +diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c +index 9b7026e7d55b..45d0a87f55d2 100644 +--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c ++++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c +@@ -718,13 +718,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) + u8 res = _SUCCESS; + + +- ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); ++ ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + +- paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); ++ paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); + if (paddbareq_parm == NULL) { + kfree(ph2c); + res = _FAIL; +diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c +index 915facbf552e..e1134a4d97f3 100644 +--- a/drivers/uio/uio_dmem_genirq.c ++++ b/drivers/uio/uio_dmem_genirq.c +@@ -229,7 +229,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev) + ++uiomem; + } + +- priv->dmem_region_start = i; ++ priv->dmem_region_start = uiomem - &uioinfo->mem[0]; + priv->num_dmem_regions = pdata->num_dynamic_regions; + + for (i = 0; i < pdata->num_dynamic_regions; ++i) { +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c +index 531e76474983..0e0eb10f82a0 100644 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c +@@ -316,7 +316,7 @@ static int xenbus_write_transaction(unsigned msg_type, + rc = -ENOMEM; + goto out; + } +- } else { ++ } else if (msg_type == XS_TRANSACTION_END) { + list_for_each_entry(trans, &u->transactions, list) + if (trans->handle.id == u->u.msg.tx_id) + break; +diff --git a/fs/9p/acl.c b/fs/9p/acl.c +index a7e28890f5ef..929b618da43b 100644 +--- a/fs/9p/acl.c ++++ b/fs/9p/acl.c +@@ -282,32 +282,26 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler, + switch (handler->flags) { + case ACL_TYPE_ACCESS: + if (acl) { +- umode_t mode = inode->i_mode; +- retval = posix_acl_equiv_mode(acl, &mode); +- if (retval < 0) ++ struct iattr iattr; ++ ++ retval = posix_acl_update_mode(inode, &iattr.ia_mode, &acl); ++ if (retval) + goto err_out; +- else { +- struct iattr iattr; +- if (retval == 0) { +- /* +- * ACL can be represented +- * by the mode bits. So don't +- * update ACL. +- */ +- acl = NULL; +- value = NULL; +- size = 0; +- } +- /* Updte the mode bits */ +- iattr.ia_mode = ((mode & S_IALLUGO) | +- (inode->i_mode & ~S_IALLUGO)); +- iattr.ia_valid = ATTR_MODE; +- /* FIXME should we update ctime ? +- * What is the following setxattr update the +- * mode ? ++ if (!acl) { ++ /* ++ * ACL can be represented ++ * by the mode bits. So don't ++ * update ACL. + */ +- v9fs_vfs_setattr_dotl(dentry, &iattr); ++ value = NULL; ++ size = 0; + } ++ iattr.ia_valid = ATTR_MODE; ++ /* FIXME should we update ctime ? ++ * What is the following setxattr update the ++ * mode ? ++ */ ++ v9fs_vfs_setattr_dotl(dentry, &iattr); + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c +index 9a0124a95851..fb3e64d37cb4 100644 +--- a/fs/btrfs/acl.c ++++ b/fs/btrfs/acl.c +@@ -83,11 +83,9 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans, + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- ret = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (ret < 0) ++ ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (ret) + return ret; +- if (ret == 0) +- acl = NULL; + } + ret = 0; + break; +diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c +index 8f84646f10e9..4d8caeb94a11 100644 +--- a/fs/ceph/acl.c ++++ b/fs/ceph/acl.c +@@ -94,11 +94,9 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- ret = posix_acl_equiv_mode(acl, &new_mode); +- if (ret < 0) ++ ret = posix_acl_update_mode(inode, &new_mode, &acl); ++ if (ret) + goto out; +- if (ret == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c +index 27695e6f4e46..d6aeb84e90b6 100644 +--- a/fs/ext2/acl.c ++++ b/fs/ext2/acl.c +@@ -193,15 +193,11 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- inode->i_ctime = CURRENT_TIME_SEC; +- mark_inode_dirty(inode); +- if (error == 0) +- acl = NULL; +- } ++ inode->i_ctime = CURRENT_TIME_SEC; ++ mark_inode_dirty(inode); + } + break; + +diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c +index 69b1e73026a5..c3fe1e323951 100644 +--- a/fs/ext4/acl.c ++++ b/fs/ext4/acl.c +@@ -196,15 +196,11 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type, + case ACL_TYPE_ACCESS: + name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- inode->i_ctime = ext4_current_time(inode); +- ext4_mark_inode_dirty(handle, inode); +- if (error == 0) +- acl = NULL; +- } ++ inode->i_ctime = ext4_current_time(inode); ++ ext4_mark_inode_dirty(handle, inode); + } + break; + +diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c +index c8f25f7241f0..e9a8d676c6bc 100644 +--- a/fs/f2fs/acl.c ++++ b/fs/f2fs/acl.c +@@ -214,12 +214,10 @@ static int __f2fs_set_acl(struct inode *inode, int type, + case ACL_TYPE_ACCESS: + name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; + set_acl_inode(fi, inode->i_mode); +- if (error == 0) +- acl = NULL; + } + break; + +diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c +index 1be3b061c05c..ff0ac96a8e7b 100644 +--- a/fs/gfs2/acl.c ++++ b/fs/gfs2/acl.c +@@ -79,17 +79,11 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + if (type == ACL_TYPE_ACCESS) { + umode_t mode = inode->i_mode; + +- error = posix_acl_equiv_mode(acl, &mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- +- if (error == 0) +- acl = NULL; +- +- if (mode != inode->i_mode) { +- inode->i_mode = mode; ++ if (mode != inode->i_mode) + mark_inode_dirty(inode); +- } + } + + if (acl) { +diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c +index df0c9af68d05..71b3087b7e32 100644 +--- a/fs/hfsplus/posix_acl.c ++++ b/fs/hfsplus/posix_acl.c +@@ -68,8 +68,8 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, + case ACL_TYPE_ACCESS: + xattr_name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- err = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (err < 0) ++ err = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (err) + return err; + } + err = 0; +diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c +index 2f7a3c090489..f9f86f87d32b 100644 +--- a/fs/jffs2/acl.c ++++ b/fs/jffs2/acl.c +@@ -235,9 +235,10 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + xprefix = JFFS2_XPREFIX_ACL_ACCESS; + if (acl) { +- umode_t mode = inode->i_mode; +- rc = posix_acl_equiv_mode(acl, &mode); +- if (rc < 0) ++ umode_t mode; ++ ++ rc = posix_acl_update_mode(inode, &mode, &acl); ++ if (rc) + return rc; + if (inode->i_mode != mode) { + struct iattr attr; +@@ -249,8 +250,6 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + if (rc < 0) + return rc; + } +- if (rc == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c +index 0c8ca830b113..9fad9f4fe883 100644 +--- a/fs/jfs/acl.c ++++ b/fs/jfs/acl.c +@@ -84,13 +84,11 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type, + case ACL_TYPE_ACCESS: + ea_name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- rc = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (rc < 0) ++ rc = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (rc) + return rc; + inode->i_ctime = CURRENT_TIME; + mark_inode_dirty(inode); +- if (rc == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c +index 2162434728c0..164307b99405 100644 +--- a/fs/ocfs2/acl.c ++++ b/fs/ocfs2/acl.c +@@ -241,13 +241,11 @@ int ocfs2_set_acl(handle_t *handle, + case ACL_TYPE_ACCESS: + name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- umode_t mode = inode->i_mode; +- ret = posix_acl_equiv_mode(acl, &mode); +- if (ret < 0) +- return ret; ++ umode_t mode; + +- if (ret == 0) +- acl = NULL; ++ ret = posix_acl_update_mode(inode, &mode, &acl); ++ if (ret) ++ return ret; + + ret = ocfs2_acl_set_mode(inode, di_bh, + handle, mode); +diff --git a/fs/posix_acl.c b/fs/posix_acl.c +index 34bd1bd354e6..a60d3cc5b55d 100644 +--- a/fs/posix_acl.c ++++ b/fs/posix_acl.c +@@ -592,6 +592,37 @@ no_mem: + } + EXPORT_SYMBOL_GPL(posix_acl_create); + ++/** ++ * posix_acl_update_mode - update mode in set_acl ++ * ++ * Update the file mode when setting an ACL: compute the new file permission ++ * bits based on the ACL. In addition, if the ACL is equivalent to the new ++ * file mode, set *acl to NULL to indicate that no ACL should be set. ++ * ++ * As with chmod, clear the setgit bit if the caller is not in the owning group ++ * or capable of CAP_FSETID (see inode_change_ok). ++ * ++ * Called from set_acl inode operations. ++ */ ++int posix_acl_update_mode(struct inode *inode, umode_t *mode_p, ++ struct posix_acl **acl) ++{ ++ umode_t mode = inode->i_mode; ++ int error; ++ ++ error = posix_acl_equiv_mode(*acl, &mode); ++ if (error < 0) ++ return error; ++ if (error == 0) ++ *acl = NULL; ++ if (!in_group_p(inode->i_gid) && ++ !capable_wrt_inode_uidgid(inode, CAP_FSETID)) ++ mode &= ~S_ISGID; ++ *mode_p = mode; ++ return 0; ++} ++EXPORT_SYMBOL(posix_acl_update_mode); ++ + /* + * Fix up the uids and gids in posix acl extended attributes in place. + */ +diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c +index 4b34b9dc03dd..9b1824f35501 100644 +--- a/fs/reiserfs/xattr_acl.c ++++ b/fs/reiserfs/xattr_acl.c +@@ -246,13 +246,9 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- if (error == 0) +- acl = NULL; +- } + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c +index 6bb470fbb8e8..c5101a3295d8 100644 +--- a/fs/xfs/xfs_acl.c ++++ b/fs/xfs/xfs_acl.c +@@ -288,16 +288,11 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) + return error; + + if (type == ACL_TYPE_ACCESS) { +- umode_t mode = inode->i_mode; +- error = posix_acl_equiv_mode(acl, &mode); +- +- if (error <= 0) { +- acl = NULL; +- +- if (error < 0) +- return error; +- } ++ umode_t mode; + ++ error = posix_acl_update_mode(inode, &mode, &acl); ++ if (error) ++ return error; + error = xfs_set_mode(inode, mode); + if (error) + return error; +diff --git a/include/drm/drmP.h b/include/drm/drmP.h +index 0a271ca1f7c7..a31976c860f6 100644 +--- a/include/drm/drmP.h ++++ b/include/drm/drmP.h +@@ -1029,7 +1029,8 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files, + #endif + + extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, +- struct drm_gem_object *obj, int flags); ++ struct drm_gem_object *obj, ++ int flags); + extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle, uint32_t flags, + int *prime_fd); +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index 4e9c75226f07..12b4d54a8ffa 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1986,8 +1986,8 @@ struct napi_gro_cb { + /* This is non-zero if the packet may be of the same flow. */ + u8 same_flow:1; + +- /* Used in udp_gro_receive */ +- u8 udp_mark:1; ++ /* Used in tunnel GRO receive */ ++ u8 encap_mark:1; + + /* GRO checksum is valid */ + u8 csum_valid:1; +diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h +index 3e96a6a76103..d1a8ad7e5ae4 100644 +--- a/include/linux/posix_acl.h ++++ b/include/linux/posix_acl.h +@@ -95,6 +95,7 @@ extern int set_posix_acl(struct inode *, int, struct posix_acl *); + extern int posix_acl_chmod(struct inode *, umode_t); + extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **, + struct posix_acl **); ++extern int posix_acl_update_mode(struct inode *, umode_t *, struct posix_acl **); + + extern int simple_set_acl(struct inode *, struct posix_acl *, int); + extern int simple_acl_create(struct inode *, struct inode *); +diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h +index af40bc586a1b..86a7bdd61d1a 100644 +--- a/include/net/ip_tunnels.h ++++ b/include/net/ip_tunnels.h +@@ -283,6 +283,22 @@ struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md, + struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum, + int gso_type_mask); + ++static inline int iptunnel_pull_offloads(struct sk_buff *skb) ++{ ++ if (skb_is_gso(skb)) { ++ int err; ++ ++ err = skb_unclone(skb, GFP_ATOMIC); ++ if (unlikely(err)) ++ return err; ++ skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >> ++ NETIF_F_GSO_SHIFT); ++ } ++ ++ skb->encapsulation = 0; ++ return 0; ++} ++ + static inline void iptunnel_xmit_stats(int err, + struct net_device_stats *err_stats, + struct pcpu_sw_netstats __percpu *stats) +diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c +index abd286afbd27..a4775f3451b9 100644 +--- a/kernel/irq/generic-chip.c ++++ b/kernel/irq/generic-chip.c +@@ -411,8 +411,29 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq, + } + EXPORT_SYMBOL_GPL(irq_map_generic_chip); + ++static void irq_unmap_generic_chip(struct irq_domain *d, unsigned int virq) ++{ ++ struct irq_data *data = irq_domain_get_irq_data(d, virq); ++ struct irq_domain_chip_generic *dgc = d->gc; ++ unsigned int hw_irq = data->hwirq; ++ struct irq_chip_generic *gc; ++ int irq_idx; ++ ++ gc = irq_get_domain_generic_chip(d, hw_irq); ++ if (!gc) ++ return; ++ ++ irq_idx = hw_irq % dgc->irqs_per_chip; ++ ++ clear_bit(irq_idx, &gc->installed); ++ irq_domain_set_info(d, virq, hw_irq, &no_irq_chip, NULL, NULL, NULL, ++ NULL); ++ ++} ++ + struct irq_domain_ops irq_generic_chip_ops = { + .map = irq_map_generic_chip, ++ .unmap = irq_unmap_generic_chip, + .xlate = irq_domain_xlate_onetwocell, + }; + EXPORT_SYMBOL_GPL(irq_generic_chip_ops); +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index 125c7dd55322..4434cdd4cd9a 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -1416,12 +1416,13 @@ static void dissolve_free_huge_page(struct page *page) + { + spin_lock(&hugetlb_lock); + if (PageHuge(page) && !page_count(page)) { +- struct hstate *h = page_hstate(page); +- int nid = page_to_nid(page); +- list_del(&page->lru); ++ struct page *head = compound_head(page); ++ struct hstate *h = page_hstate(head); ++ int nid = page_to_nid(head); ++ list_del(&head->lru); + h->free_huge_pages--; + h->free_huge_pages_node[nid]--; +- update_and_free_page(h, page); ++ update_and_free_page(h, head); + } + spin_unlock(&hugetlb_lock); + } +@@ -1429,7 +1430,8 @@ static void dissolve_free_huge_page(struct page *page) + /* + * Dissolve free hugepages in a given pfn range. Used by memory hotplug to + * make specified memory blocks removable from the system. +- * Note that start_pfn should aligned with (minimum) hugepage size. ++ * Note that this will dissolve a free gigantic hugepage completely, if any ++ * part of it lies within the given range. + */ + void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) + { +@@ -1438,7 +1440,6 @@ void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) + if (!hugepages_supported()) + return; + +- VM_BUG_ON(!IS_ALIGNED(start_pfn, 1 << minimum_order)); + for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) + dissolve_free_huge_page(pfn_to_page(pfn)); + } +diff --git a/net/core/dev.c b/net/core/dev.c +index de4ed2b5a221..0989fea88c44 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4239,7 +4239,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff + NAPI_GRO_CB(skb)->same_flow = 0; + NAPI_GRO_CB(skb)->flush = 0; + NAPI_GRO_CB(skb)->free = 0; +- NAPI_GRO_CB(skb)->udp_mark = 0; ++ NAPI_GRO_CB(skb)->encap_mark = 0; + NAPI_GRO_CB(skb)->gro_remcsum_start = 0; + + /* Setup for GRO checksum validation */ +diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c +index 5c5db6636704..1a5c1ca3ad3c 100644 +--- a/net/ipv4/af_inet.c ++++ b/net/ipv4/af_inet.c +@@ -1383,6 +1383,19 @@ out: + return pp; + } + ++static struct sk_buff **ipip_gro_receive(struct sk_buff **head, ++ struct sk_buff *skb) ++{ ++ if (NAPI_GRO_CB(skb)->encap_mark) { ++ NAPI_GRO_CB(skb)->flush = 1; ++ return NULL; ++ } ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ ++ return inet_gro_receive(head, skb); ++} ++ + int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) + { + if (sk->sk_family == AF_INET) +@@ -1425,6 +1438,13 @@ out_unlock: + return err; + } + ++static int ipip_gro_complete(struct sk_buff *skb, int nhoff) ++{ ++ skb->encapsulation = 1; ++ skb_shinfo(skb)->gso_type |= SKB_GSO_IPIP; ++ return inet_gro_complete(skb, nhoff); ++} ++ + int inet_ctl_sock_create(struct sock **sk, unsigned short family, + unsigned short type, unsigned char protocol, + struct net *net) +@@ -1652,8 +1672,8 @@ static struct packet_offload ip_packet_offload __read_mostly = { + static const struct net_offload ipip_offload = { + .callbacks = { + .gso_segment = inet_gso_segment, +- .gro_receive = inet_gro_receive, +- .gro_complete = inet_gro_complete, ++ .gro_receive = ipip_gro_receive, ++ .gro_complete = ipip_gro_complete, + }, + }; + +diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c +index bd903fe0f750..08d7de55e57e 100644 +--- a/net/ipv4/fou.c ++++ b/net/ipv4/fou.c +@@ -48,7 +48,7 @@ static inline struct fou *fou_from_sock(struct sock *sk) + return sk->sk_user_data; + } + +-static void fou_recv_pull(struct sk_buff *skb, size_t len) ++static int fou_recv_pull(struct sk_buff *skb, size_t len) + { + struct iphdr *iph = ip_hdr(skb); + +@@ -59,6 +59,7 @@ static void fou_recv_pull(struct sk_buff *skb, size_t len) + __skb_pull(skb, len); + skb_postpull_rcsum(skb, udp_hdr(skb), len); + skb_reset_transport_header(skb); ++ return iptunnel_pull_offloads(skb); + } + + static int fou_udp_recv(struct sock *sk, struct sk_buff *skb) +@@ -68,9 +69,14 @@ static int fou_udp_recv(struct sock *sk, struct sk_buff *skb) + if (!fou) + return 1; + +- fou_recv_pull(skb, sizeof(struct udphdr)); ++ if (fou_recv_pull(skb, sizeof(struct udphdr))) ++ goto drop; + + return -fou->protocol; ++ ++drop: ++ kfree_skb(skb); ++ return 0; + } + + static struct guehdr *gue_remcsum(struct sk_buff *skb, struct guehdr *guehdr, +@@ -170,6 +176,9 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) + __skb_pull(skb, sizeof(struct udphdr) + hdrlen); + skb_reset_transport_header(skb); + ++ if (iptunnel_pull_offloads(skb)) ++ goto drop; ++ + return -guehdr->proto_ctype; + + drop: +diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c +index 5a8ee3282550..e603004c1af8 100644 +--- a/net/ipv4/gre_offload.c ++++ b/net/ipv4/gre_offload.c +@@ -128,6 +128,11 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head, + struct packet_offload *ptype; + __be16 type; + ++ if (NAPI_GRO_CB(skb)->encap_mark) ++ goto out; ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ + off = skb_gro_offset(skb); + hlen = off + sizeof(*greh); + greh = skb_gro_header_fast(skb, off); +diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c +index 6cb9009c3d96..dbda0565781c 100644 +--- a/net/ipv4/ip_tunnel_core.c ++++ b/net/ipv4/ip_tunnel_core.c +@@ -116,7 +116,8 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto) + skb->vlan_tci = 0; + skb_set_queue_mapping(skb, 0); + skb->pkt_type = PACKET_HOST; +- return 0; ++ ++ return iptunnel_pull_offloads(skb); + } + EXPORT_SYMBOL_GPL(iptunnel_pull_header); + +diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c +index f9386160cbee..0e36e56dfd22 100644 +--- a/net/ipv4/udp_offload.c ++++ b/net/ipv4/udp_offload.c +@@ -299,14 +299,14 @@ struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb, + unsigned int off = skb_gro_offset(skb); + int flush = 1; + +- if (NAPI_GRO_CB(skb)->udp_mark || ++ if (NAPI_GRO_CB(skb)->encap_mark || + (skb->ip_summed != CHECKSUM_PARTIAL && + NAPI_GRO_CB(skb)->csum_cnt == 0 && + !NAPI_GRO_CB(skb)->csum_valid)) + goto out; + +- /* mark that this skb passed once through the udp gro layer */ +- NAPI_GRO_CB(skb)->udp_mark = 1; ++ /* mark that this skb passed once through the tunnel gro layer */ ++ NAPI_GRO_CB(skb)->encap_mark = 1; + + rcu_read_lock(); + uo_priv = rcu_dereference(udp_offload_base); +diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c +index eeca943f12dc..82e9f3076028 100644 +--- a/net/ipv6/ip6_offload.c ++++ b/net/ipv6/ip6_offload.c +@@ -258,6 +258,19 @@ out: + return pp; + } + ++static struct sk_buff **sit_gro_receive(struct sk_buff **head, ++ struct sk_buff *skb) ++{ ++ if (NAPI_GRO_CB(skb)->encap_mark) { ++ NAPI_GRO_CB(skb)->flush = 1; ++ return NULL; ++ } ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ ++ return ipv6_gro_receive(head, skb); ++} ++ + static int ipv6_gro_complete(struct sk_buff *skb, int nhoff) + { + const struct net_offload *ops; +@@ -302,7 +315,7 @@ static struct packet_offload ipv6_packet_offload __read_mostly = { + static const struct net_offload sit_offload = { + .callbacks = { + .gso_segment = ipv6_gso_segment, +- .gro_receive = ipv6_gro_receive, ++ .gro_receive = sit_gro_receive, + .gro_complete = sit_gro_complete, + }, + }; +diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c +index ba3d2f3d66d2..3da2b16356eb 100644 +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -681,14 +681,15 @@ static int ipip6_rcv(struct sk_buff *skb) + skb->mac_header = skb->network_header; + skb_reset_network_header(skb); + IPCB(skb)->flags = 0; +- skb->protocol = htons(ETH_P_IPV6); ++ skb->dev = tunnel->dev; + + if (packet_is_spoofed(skb, iph, tunnel)) { + tunnel->dev->stats.rx_errors++; + goto out; + } + +- __skb_tunnel_rx(skb, tunnel->dev, tunnel->net); ++ if (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6))) ++ goto out; + + err = IP_ECN_decapsulate(iph, skb); + if (unlikely(err)) { +diff --git a/scripts/sortextable.c b/scripts/sortextable.c +index c2423d913b46..7b29fb14f870 100644 +--- a/scripts/sortextable.c ++++ b/scripts/sortextable.c +@@ -209,6 +209,35 @@ static int compare_relative_table(const void *a, const void *b) + return 0; + } + ++static void x86_sort_relative_table(char *extab_image, int image_size) ++{ ++ int i; ++ ++ i = 0; ++ while (i < image_size) { ++ uint32_t *loc = (uint32_t *)(extab_image + i); ++ ++ w(r(loc) + i, loc); ++ w(r(loc + 1) + i + 4, loc + 1); ++ w(r(loc + 2) + i + 8, loc + 2); ++ ++ i += sizeof(uint32_t) * 3; ++ } ++ ++ qsort(extab_image, image_size / 12, 12, compare_relative_table); ++ ++ i = 0; ++ while (i < image_size) { ++ uint32_t *loc = (uint32_t *)(extab_image + i); ++ ++ w(r(loc) - i, loc); ++ w(r(loc + 1) - (i + 4), loc + 1); ++ w(r(loc + 2) - (i + 8), loc + 2); ++ ++ i += sizeof(uint32_t) * 3; ++ } ++} ++ + static void sort_relative_table(char *extab_image, int image_size) + { + int i; +@@ -281,6 +310,9 @@ do_file(char const *const fname) + break; + case EM_386: + case EM_X86_64: ++ custom_sort = x86_sort_relative_table; ++ break; ++ + case EM_S390: + custom_sort = sort_relative_table; + break; +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c +index afb70a5d4fd3..b8a256dfed7e 100644 +--- a/sound/soc/soc-dapm.c ++++ b/sound/soc/soc-dapm.c +@@ -823,6 +823,7 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, + case snd_soc_dapm_switch: + case snd_soc_dapm_mixer: + case snd_soc_dapm_pga: ++ case snd_soc_dapm_out_drv: + wname_in_long_name = true; + kcname_in_long_name = true; + break; +@@ -3015,6 +3016,9 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, + } + mutex_unlock(&card->dapm_mutex); + ++ if (ret) ++ return ret; ++ + if (invert) + ucontrol->value.integer.value[0] = max - val; + else +@@ -3166,7 +3170,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + if (e->shift_l != e->shift_r) { + if (item[1] > e->items) + return -EINVAL; +- val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_l; ++ val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r; + mask |= e->mask << e->shift_r; + } + +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c +index 6963ba20991c..70396d3f6472 100644 +--- a/sound/soc/soc-topology.c ++++ b/sound/soc/soc-topology.c +@@ -1484,6 +1484,7 @@ widget: + if (widget == NULL) { + dev_err(tplg->dev, "ASoC: failed to create widget %s controls\n", + w->name); ++ ret = -ENOMEM; + goto hdr_err; + } + +diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c +index 3900386a3629..d802938644b5 100644 +--- a/tools/perf/ui/browsers/hists.c ++++ b/tools/perf/ui/browsers/hists.c +@@ -684,7 +684,6 @@ static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) + ret = scnprintf(hpp->buf, hpp->size, fmt, len, percent); + ui_browser__printf(arg->b, "%s", hpp->buf); + +- advance_hpp(hpp, ret); + return ret; + } + +diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c +index 4a3a72cb5805..6ce624cb7001 100644 +--- a/tools/perf/util/stat.c ++++ b/tools/perf/util/stat.c +@@ -311,6 +311,16 @@ int perf_stat_process_counter(struct perf_stat_config *config, + + aggr->val = aggr->ena = aggr->run = 0; + ++ /* ++ * We calculate counter's data every interval, ++ * and the display code shows ps->res_stats ++ * avg value. We need to zero the stats for ++ * interval mode, otherwise overall avg running ++ * averages will be shown for each interval. ++ */ ++ if (config->interval) ++ init_stats(ps->res_stats); ++ + if (counter->per_pkg) + zero_per_pkg(counter); + +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c +index 475d88d0a1c9..27ae382feb2d 100644 +--- a/tools/perf/util/symbol-elf.c ++++ b/tools/perf/util/symbol-elf.c +@@ -1091,9 +1091,8 @@ new_symbol: + * For misannotated, zeroed, ASM function sizes. + */ + if (nr > 0) { +- if (!symbol_conf.allow_aliases) +- symbols__fixup_duplicate(&dso->symbols[map->type]); + symbols__fixup_end(&dso->symbols[map->type]); ++ symbols__fixup_duplicate(&dso->symbols[map->type]); + if (kmap) { + /* + * We need to fixup this here too because we create new +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c +index cd08027a6d2c..520a32a12f8a 100644 +--- a/tools/perf/util/symbol.c ++++ b/tools/perf/util/symbol.c +@@ -151,6 +151,9 @@ void symbols__fixup_duplicate(struct rb_root *symbols) + struct rb_node *nd; + struct symbol *curr, *next; + ++ if (symbol_conf.allow_aliases) ++ return; ++ + nd = rb_first(symbols); + + while (nd) { +@@ -1275,8 +1278,8 @@ int dso__load_kallsyms(struct dso *dso, const char *filename, + if (kallsyms__delta(map, filename, &delta)) + return -1; + +- symbols__fixup_duplicate(&dso->symbols[map->type]); + symbols__fixup_end(&dso->symbols[map->type]); ++ symbols__fixup_duplicate(&dso->symbols[map->type]); + + if (dso->kernel == DSO_TYPE_GUEST_KERNEL) + dso->symtab_type = DSO_BINARY_TYPE__GUEST_KALLSYMS; diff --git a/patch/kernel/marvell-dev/patch-4.4.29-30.patch b/patch/kernel/marvell-dev/patch-4.4.29-30.patch new file mode 100644 index 0000000000..e19a680b98 --- /dev/null +++ b/patch/kernel/marvell-dev/patch-4.4.29-30.patch @@ -0,0 +1,434 @@ +diff --git a/Documentation/x86/exception-tables.txt b/Documentation/x86/exception-tables.txt +index e396bcd8d830..32901aa36f0a 100644 +--- a/Documentation/x86/exception-tables.txt ++++ b/Documentation/x86/exception-tables.txt +@@ -290,38 +290,3 @@ Due to the way that the exception table is built and needs to be ordered, + only use exceptions for code in the .text section. Any other section + will cause the exception table to not be sorted correctly, and the + exceptions will fail. +- +-Things changed when 64-bit support was added to x86 Linux. Rather than +-double the size of the exception table by expanding the two entries +-from 32-bits to 64 bits, a clever trick was used to store addresses +-as relative offsets from the table itself. The assembly code changed +-from: +- .long 1b,3b +-to: +- .long (from) - . +- .long (to) - . +- +-and the C-code that uses these values converts back to absolute addresses +-like this: +- +- ex_insn_addr(const struct exception_table_entry *x) +- { +- return (unsigned long)&x->insn + x->insn; +- } +- +-In v4.6 the exception table entry was expanded with a new field "handler". +-This is also 32-bits wide and contains a third relative function +-pointer which points to one of: +- +-1) int ex_handler_default(const struct exception_table_entry *fixup) +- This is legacy case that just jumps to the fixup code +-2) int ex_handler_fault(const struct exception_table_entry *fixup) +- This case provides the fault number of the trap that occurred at +- entry->insn. It is used to distinguish page faults from machine +- check. +-3) int ex_handler_ext(const struct exception_table_entry *fixup) +- This case is used for uaccess_err ... we need to set a flag +- in the task structure. Before the handler functions existed this +- case was handled by adding a large offset to the fixup to tag +- it as special. +-More functions can easily be added. +diff --git a/Makefile b/Makefile +index 19d7d9f68e35..98239d56924c 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 29 ++SUBLEVEL = 30 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h +index f5063b6659eb..189679aba703 100644 +--- a/arch/x86/include/asm/asm.h ++++ b/arch/x86/include/asm/asm.h +@@ -44,22 +44,19 @@ + + /* Exception table entry */ + #ifdef __ASSEMBLY__ +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \ ++# define _ASM_EXTABLE(from,to) \ + .pushsection "__ex_table","a" ; \ +- .balign 4 ; \ ++ .balign 8 ; \ + .long (from) - . ; \ + .long (to) - . ; \ +- .long (handler) - . ; \ + .popsection + +-# define _ASM_EXTABLE(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) +- +-# define _ASM_EXTABLE_FAULT(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) +- +-# define _ASM_EXTABLE_EX(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) ++# define _ASM_EXTABLE_EX(from,to) \ ++ .pushsection "__ex_table","a" ; \ ++ .balign 8 ; \ ++ .long (from) - . ; \ ++ .long (to) - . + 0x7ffffff0 ; \ ++ .popsection + + # define _ASM_NOKPROBE(entry) \ + .pushsection "_kprobe_blacklist","aw" ; \ +@@ -92,24 +89,19 @@ + .endm + + #else +-# define _EXPAND_EXTABLE_HANDLE(x) #x +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \ ++# define _ASM_EXTABLE(from,to) \ + " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 4\n" \ ++ " .balign 8\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ +- " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \ + " .popsection\n" + +-# define _ASM_EXTABLE(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) +- +-# define _ASM_EXTABLE_FAULT(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) +- +-# define _ASM_EXTABLE_EX(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) +- ++# define _ASM_EXTABLE_EX(from,to) \ ++ " .pushsection \"__ex_table\",\"a\"\n" \ ++ " .balign 8\n" \ ++ " .long (" #from ") - .\n" \ ++ " .long (" #to ") - . + 0x7ffffff0\n" \ ++ " .popsection\n" + /* For C file, we already have NOKPROBE_SYMBOL macro */ + #endif + +diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h +index 3794c7331cfc..09b1b0ab94b7 100644 +--- a/arch/x86/include/asm/uaccess.h ++++ b/arch/x86/include/asm/uaccess.h +@@ -90,11 +90,12 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + likely(!__range_not_ok(addr, size, user_addr_max())) + + /* +- * The exception table consists of triples of addresses relative to the +- * exception table entry itself. The first address is of an instruction +- * that is allowed to fault, the second is the target at which the program +- * should continue. The third is a handler function to deal with the fault +- * caused by the instruction in the first field. ++ * The exception table consists of pairs of addresses relative to the ++ * exception table enty itself: the first is the address of an ++ * instruction that is allowed to fault, and the second is the address ++ * at which the program should continue. No registers are modified, ++ * so it is entirely up to the continuation code to figure out what to ++ * do. + * + * All the routines below use bits of fixup code that are out of line + * with the main instruction path. This means when everything is well, +@@ -103,14 +104,13 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + */ + + struct exception_table_entry { +- int insn, fixup, handler; ++ int insn, fixup; + }; + /* This is not the generic standard exception_table_entry format */ + #define ARCH_HAS_SORT_EXTABLE + #define ARCH_HAS_SEARCH_EXTABLE + +-extern int fixup_exception(struct pt_regs *regs, int trapnr); +-extern bool ex_has_fault_handler(unsigned long ip); ++extern int fixup_exception(struct pt_regs *regs); + extern int early_fixup_exception(unsigned long *ip); + + /* +@@ -394,11 +394,7 @@ do { \ + #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ + asm volatile("1: mov"itype" %1,%"rtype"0\n" \ + "2:\n" \ +- ".section .fixup,\"ax\"\n" \ +- "3:xor"itype" %"rtype"0,%"rtype"0\n" \ +- " jmp 2b\n" \ +- ".previous\n" \ +- _ASM_EXTABLE_EX(1b, 3b) \ ++ _ASM_EXTABLE_EX(1b, 2b) \ + : ltype(x) : "m" (__m(addr))) + + #define __put_user_nocheck(x, ptr, size) \ +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c +index e1d1f6cbaf11..023c442c33bb 100644 +--- a/arch/x86/kernel/kprobes/core.c ++++ b/arch/x86/kernel/kprobes/core.c +@@ -1000,7 +1000,7 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) + * In case the user-specified fault handler returned + * zero, try to fix up. + */ +- if (fixup_exception(regs, trapnr)) ++ if (fixup_exception(regs)) + return 1; + + /* +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c +index 5621f882645e..679302c312f8 100644 +--- a/arch/x86/kernel/traps.c ++++ b/arch/x86/kernel/traps.c +@@ -199,7 +199,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, + } + + if (!user_mode(regs)) { +- if (!fixup_exception(regs, trapnr)) { ++ if (!fixup_exception(regs)) { + tsk->thread.error_code = error_code; + tsk->thread.trap_nr = trapnr; + die(str, regs, error_code); +@@ -453,7 +453,7 @@ do_general_protection(struct pt_regs *regs, long error_code) + + tsk = current; + if (!user_mode(regs)) { +- if (fixup_exception(regs, X86_TRAP_GP)) ++ if (fixup_exception(regs)) + return; + + tsk->thread.error_code = error_code; +@@ -699,7 +699,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) + conditional_sti(regs); + + if (!user_mode(regs)) { +- if (!fixup_exception(regs, trapnr)) { ++ if (!fixup_exception(regs)) { + task->thread.error_code = error_code; + task->thread.trap_nr = trapnr; + die(str, regs, error_code); +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c +index 9dd7e4b7fcde..903ec1e9c326 100644 +--- a/arch/x86/mm/extable.c ++++ b/arch/x86/mm/extable.c +@@ -3,9 +3,6 @@ + #include + #include + +-typedef bool (*ex_handler_t)(const struct exception_table_entry *, +- struct pt_regs *, int); +- + static inline unsigned long + ex_insn_addr(const struct exception_table_entry *x) + { +@@ -16,56 +13,11 @@ ex_fixup_addr(const struct exception_table_entry *x) + { + return (unsigned long)&x->fixup + x->fixup; + } +-static inline ex_handler_t +-ex_fixup_handler(const struct exception_table_entry *x) +-{ +- return (ex_handler_t)((unsigned long)&x->handler + x->handler); +-} +- +-bool ex_handler_default(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- regs->ip = ex_fixup_addr(fixup); +- return true; +-} +-EXPORT_SYMBOL(ex_handler_default); +- +-bool ex_handler_fault(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- regs->ip = ex_fixup_addr(fixup); +- regs->ax = trapnr; +- return true; +-} +-EXPORT_SYMBOL_GPL(ex_handler_fault); +- +-bool ex_handler_ext(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- /* Special hack for uaccess_err */ +- current_thread_info()->uaccess_err = 1; +- regs->ip = ex_fixup_addr(fixup); +- return true; +-} +-EXPORT_SYMBOL(ex_handler_ext); +- +-bool ex_has_fault_handler(unsigned long ip) +-{ +- const struct exception_table_entry *e; +- ex_handler_t handler; +- +- e = search_exception_tables(ip); +- if (!e) +- return false; +- handler = ex_fixup_handler(e); +- +- return handler == ex_handler_fault; +-} + +-int fixup_exception(struct pt_regs *regs, int trapnr) ++int fixup_exception(struct pt_regs *regs) + { +- const struct exception_table_entry *e; +- ex_handler_t handler; ++ const struct exception_table_entry *fixup; ++ unsigned long new_ip; + + #ifdef CONFIG_PNPBIOS + if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) { +@@ -81,34 +33,42 @@ int fixup_exception(struct pt_regs *regs, int trapnr) + } + #endif + +- e = search_exception_tables(regs->ip); +- if (!e) +- return 0; ++ fixup = search_exception_tables(regs->ip); ++ if (fixup) { ++ new_ip = ex_fixup_addr(fixup); ++ ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { ++ /* Special hack for uaccess_err */ ++ current_thread_info()->uaccess_err = 1; ++ new_ip -= 0x7ffffff0; ++ } ++ regs->ip = new_ip; ++ return 1; ++ } + +- handler = ex_fixup_handler(e); +- return handler(e, regs, trapnr); ++ return 0; + } + + /* Restricted version used during very early boot */ + int __init early_fixup_exception(unsigned long *ip) + { +- const struct exception_table_entry *e; ++ const struct exception_table_entry *fixup; + unsigned long new_ip; +- ex_handler_t handler; + +- e = search_exception_tables(*ip); +- if (!e) +- return 0; ++ fixup = search_exception_tables(*ip); ++ if (fixup) { ++ new_ip = ex_fixup_addr(fixup); + +- new_ip = ex_fixup_addr(e); +- handler = ex_fixup_handler(e); ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { ++ /* uaccess handling not supported during early boot */ ++ return 0; ++ } + +- /* special handling not supported during early boot */ +- if (handler != ex_handler_default) +- return 0; ++ *ip = new_ip; ++ return 1; ++ } + +- *ip = new_ip; +- return 1; ++ return 0; + } + + /* +@@ -173,8 +133,6 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup += i; + i += 4; +- p->handler += i; +- i += 4; + } + + sort(start, finish - start, sizeof(struct exception_table_entry), +@@ -187,8 +145,6 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup -= i; + i += 4; +- p->handler -= i; +- i += 4; + } + } + +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c +index 03898aea6e0f..e830c71a1323 100644 +--- a/arch/x86/mm/fault.c ++++ b/arch/x86/mm/fault.c +@@ -663,7 +663,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, + int sig; + + /* Are we prepared to handle this kernel fault? */ +- if (fixup_exception(regs, X86_TRAP_PF)) { ++ if (fixup_exception(regs)) { + /* + * Any interrupt that takes a fault gets the fixup. This makes + * the below recursive fault logic only apply to a faults from +diff --git a/scripts/sortextable.c b/scripts/sortextable.c +index 7b29fb14f870..c2423d913b46 100644 +--- a/scripts/sortextable.c ++++ b/scripts/sortextable.c +@@ -209,35 +209,6 @@ static int compare_relative_table(const void *a, const void *b) + return 0; + } + +-static void x86_sort_relative_table(char *extab_image, int image_size) +-{ +- int i; +- +- i = 0; +- while (i < image_size) { +- uint32_t *loc = (uint32_t *)(extab_image + i); +- +- w(r(loc) + i, loc); +- w(r(loc + 1) + i + 4, loc + 1); +- w(r(loc + 2) + i + 8, loc + 2); +- +- i += sizeof(uint32_t) * 3; +- } +- +- qsort(extab_image, image_size / 12, 12, compare_relative_table); +- +- i = 0; +- while (i < image_size) { +- uint32_t *loc = (uint32_t *)(extab_image + i); +- +- w(r(loc) - i, loc); +- w(r(loc + 1) - (i + 4), loc + 1); +- w(r(loc + 2) - (i + 8), loc + 2); +- +- i += sizeof(uint32_t) * 3; +- } +-} +- + static void sort_relative_table(char *extab_image, int image_size) + { + int i; +@@ -310,9 +281,6 @@ do_file(char const *const fname) + break; + case EM_386: + case EM_X86_64: +- custom_sort = x86_sort_relative_table; +- break; +- + case EM_S390: + custom_sort = sort_relative_table; + break; diff --git a/patch/kernel/pine64-default/add_gt911_DB2_profile_to_gt9xxf_ts_driver.patch b/patch/kernel/pine64-default/add_gt911_DB2_profile_to_gt9xxf_ts_driver.patch new file mode 100644 index 0000000000..9593a2ca77 --- /dev/null +++ b/patch/kernel/pine64-default/add_gt911_DB2_profile_to_gt9xxf_ts_driver.patch @@ -0,0 +1,39 @@ +From 832757c73ba9b69d0ee2d2753cca228f0d831386 Mon Sep 17 00:00:00 2001 +From: Martin Bergstrand +Date: Mon, 24 Oct 2016 17:00:54 -0500 +Subject: [PATCH] Use Correct I2C Touchscreen Driver + +--- + drivers/input/touchscreen/gt9xxf/gt9xxf.c | 5 +++++ + drivers/input/touchscreen/gt9xxf/gt9xxf.h | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/drivers/input/touchscreen/gt9xxf/gt9xxf.c b/drivers/input/touchscreen/gt9xxf/gt9xxf.c +index 83f2358..95b13f4 100755 +--- a/drivers/input/touchscreen/gt9xxf/gt9xxf.c ++++ b/drivers/input/touchscreen/gt9xxf/gt9xxf.c +@@ -1454,6 +1454,11 @@ static s32 gtp_init_panel(struct goodix_ts_data *ts) + GTP_INFO("gt9xx:index = %d\n",index); + + } ++ if (!strcmp(config_info.name,"gt911_DB2")){ ++ index = 4; ++ GTP_INFO("gt9xx:index = %d\n",index); ++ ++ } + } + #endif + +diff --git a/drivers/input/touchscreen/gt9xxf/gt9xxf.h b/drivers/input/touchscreen/gt9xxf/gt9xxf.h +index 3db7c68..dd2a729 100755 +--- a/drivers/input/touchscreen/gt9xxf/gt9xxf.h ++++ b/drivers/input/touchscreen/gt9xxf/gt9xxf.h +@@ -156,7 +156,7 @@ extern void gtp_io_init(int ms); + + // TODO: define your config for Sensor_ID == 4 here, if needed + #define CTP_CFG_GROUP5 {\ +- } ++ 0x42,0x00,0x04,0x58,0x02,0x0A,0x0D,0x00,0x01,0x08,0x28,0x08,0x5A,0x46,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x87,0x28,0x0A,0x41,0x43,0xB5,0x06,0x00,0x00,0x00,0x42,0x02,0x11,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x5A,0x94,0xC5,0x02,0x08,0x00,0x00,0x04,0x98,0x35,0x00,0x8A,0x3B,0x00,0x7C,0x43,0x00,0x72,0x4B,0x00,0x67,0x55,0x00,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x12,0x10,0x0E,0x0C,0x0A,0x08,0x06,0x04,0x02,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x24,0x22,0x21,0x20,0x1F,0x1E,0x1D,0x0C,0x0A,0x08,0x06,0x04,0x02,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x01} + + // TODO: define your config for Sensor_ID == 5 here, if needed + #define CTP_CFG_GROUP6 {\ diff --git a/patch/kernel/pine64-default/disp2-fb-force-soft-cursor.patch b/patch/kernel/pine64-default/disp2-fb-force-soft-cursor.patch new file mode 100644 index 0000000000..aa4f382142 --- /dev/null +++ b/patch/kernel/pine64-default/disp2-fb-force-soft-cursor.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/video/sunxi/disp2/disp/dev_fb.c b/drivers/video/sunxi/disp2/disp/dev_fb.c +index cc297aa..b57fa0c 100755 +--- a/drivers/video/sunxi/disp2/disp/dev_fb.c ++++ b/drivers/video/sunxi/disp2/disp/dev_fb.c +@@ -682,7 +682,7 @@ static int sunxi_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) + { + __inf("sunxi_fb_cursor\n"); + +- return 0; ++ return -EINVAL; /* just to force soft_cursor() call */ + } + + s32 drv_disp_vsync_event(u32 sel) diff --git a/patch/kernel/sun8i-default/disp2-fb-force-soft-cursor.patch b/patch/kernel/sun8i-default/disp2-fb-force-soft-cursor.patch new file mode 100644 index 0000000000..aa4f382142 --- /dev/null +++ b/patch/kernel/sun8i-default/disp2-fb-force-soft-cursor.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/video/sunxi/disp2/disp/dev_fb.c b/drivers/video/sunxi/disp2/disp/dev_fb.c +index cc297aa..b57fa0c 100755 +--- a/drivers/video/sunxi/disp2/disp/dev_fb.c ++++ b/drivers/video/sunxi/disp2/disp/dev_fb.c +@@ -682,7 +682,7 @@ static int sunxi_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) + { + __inf("sunxi_fb_cursor\n"); + +- return 0; ++ return -EINVAL; /* just to force soft_cursor() call */ + } + + s32 drv_disp_vsync_event(u32 sel) diff --git a/patch/kernel/sunxi-dev/a20-gmac-txfifo.patch b/patch/kernel/sunxi-dev/a20-gmac-txfifo.patch deleted file mode 100644 index 6705a92487..0000000000 --- a/patch/kernel/sunxi-dev/a20-gmac-txfifo.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi -index e02eb72..470edde 100644 ---- a/arch/arm/boot/dts/sun7i-a20.dtsi -+++ b/arch/arm/boot/dts/sun7i-a20.dtsi -@@ -1385,6 +1385,7 @@ - clock-names = "stmmaceth", "allwinner_gmac_tx"; - snps,pbl = <2>; - snps,fixed-burst; -+ tx-fifo-depth = <16384>; - snps,force_sf_dma_mode; - status = "disabled"; - #address-cells = <1>; diff --git a/patch/kernel/sunxi-dev/add-H27UBG8T2BTR-nand.patch b/patch/kernel/sunxi-dev/add-H27UBG8T2BTR-nand.patch new file mode 100644 index 0000000000..a3b72c64eb --- /dev/null +++ b/patch/kernel/sunxi-dev/add-H27UBG8T2BTR-nand.patch @@ -0,0 +1,15 @@ +diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c +index 2af9869..f561b36 100644 +--- a/drivers/mtd/nand/nand_ids.c ++++ b/drivers/mtd/nand/nand_ids.c +@@ -48,6 +48,10 @@ struct nand_flash_dev nand_flash_ids[] = { + {"SDTNRGAMA 64G 3.3V 8-bit", + { .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x50} }, + SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, ++ {"H27UBG8T2BTR-BC 32G 3.3V 8-bit", ++ { .id = {0xad, 0xd7, 0x94, 0xda, 0x74, 0xc3} }, ++ SZ_8K, SZ_4K, SZ_2M, NAND_NEED_SCRAMBLING, 6, 640, ++ NAND_ECC_INFO(40, SZ_1K), 0 }, + {"H27UCG8T2ATR-BC 64G 3.3V 8-bit", + { .id = {0xad, 0xde, 0x94, 0xda, 0x74, 0xc4} }, + SZ_8K, SZ_8K, SZ_2M, NAND_NEED_SCRAMBLING, 6, 640, diff --git a/patch/kernel/sunxi-dev/add-nand-pins-to-a20-dtsi.patch b/patch/kernel/sunxi-dev/add-nand-pins-to-a20-dtsi.patch new file mode 100644 index 0000000000..103b7b1158 --- /dev/null +++ b/patch/kernel/sunxi-dev/add-nand-pins-to-a20-dtsi.patch @@ -0,0 +1,63 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi +index bd0c476..5791e43 100644 +--- a/arch/arm/boot/dts/sun7i-a20.dtsi ++++ b/arch/arm/boot/dts/sun7i-a20.dtsi +@@ -1389,6 +1389,58 @@ + allwinner,drive = ; + allwinner,pull = ; + }; ++ ++ nand_pins_a: nand_base0@0 { ++ allwinner,pins = "PC0", "PC1", "PC2", ++ "PC5", "PC8", "PC9", "PC10", ++ "PC11", "PC12", "PC13", "PC14", ++ "PC15", "PC16"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_cs0_pins_a: nand_cs@0 { ++ allwinner,pins = "PC4"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_cs1_pins_a: nand_cs@1 { ++ allwinner,pins = "PC3"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_cs2_pins_a: nand_cs@2 { ++ allwinner,pins = "PC17"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_cs3_pins_a: nand_cs@3 { ++ allwinner,pins = "PC18"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_rb0_pins_a: nand_rb@0 { ++ allwinner,pins = "PC6"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ ++ nand_rb1_pins_a: nand_rb@1 { ++ allwinner,pins = "PC7"; ++ allwinner,function = "nand0"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; + }; + + timer@01c20c00 { diff --git a/patch/kernel/sunxi-dev/add-nand-to-a20-micro-migrate.patch.disabled b/patch/kernel/sunxi-dev/add-nand-to-a20-micro-migrate.patch.disabled new file mode 100644 index 0000000000..029e5e986d --- /dev/null +++ b/patch/kernel/sunxi-dev/add-nand-to-a20-micro-migrate.patch.disabled @@ -0,0 +1,23 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +index 7e3006f..de809ec 100644 +--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts ++++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +@@ -213,6 +213,18 @@ + status = "okay"; + }; + ++&nfc { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&nand_pins_a>, <&nand_cs0_pins_a>, <&nand_rb0_pins_a>; ++ status = "okay"; ++ ++ nand@0 { ++ reg = <0>; ++ allwinner,rb = <0>; ++ nand-ecc-mode = "hw"; ++ }; ++}; ++ + &ohci0 { + status = "okay"; + }; diff --git a/patch/kernel/sunxi-dev/add-nand-to-a20-micro.patch b/patch/kernel/sunxi-dev/add-nand-to-a20-micro.patch new file mode 100644 index 0000000000..edf6b77f46 --- /dev/null +++ b/patch/kernel/sunxi-dev/add-nand-to-a20-micro.patch @@ -0,0 +1,60 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +index 7e3006f..7e44d19 100644 +--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts ++++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +@@ -213,6 +213,55 @@ + status = "okay"; + }; + ++&nfc { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&nand_pins_a>, <&nand_cs0_pins_a>, <&nand_rb0_pins_a>; ++ status = "okay"; ++ ++ nand@0 { ++ reg = <0>; ++ allwinner,rb = <0>; ++ nand-ecc-mode = "hw"; ++ nand-on-flash-bbt; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <2>; ++ #size-cells = <2>; ++ ++ partition@0 { ++ label = "SPL"; ++ reg = <0x0 0x0 0x0 0x400000>; ++ }; ++ ++ partition@400000 { ++ label = "SPL.backup"; ++ reg = <0x0 0x400000 0x0 0x400000>; ++ }; ++ ++ partition@800000 { ++ label = "U-Boot"; ++ reg = <0x0 0x800000 0x0 0x400000>; ++ }; ++ ++ partition@c00000 { ++ label = "U-Boot.backup"; ++ reg = <0x0 0xc00000 0x0 0x400000>; ++ }; ++ ++ partition@1000000 { ++ label = "env"; ++ reg = <0x0 0x1000000 0x0 0x400000>; ++ }; ++ ++ partition@1400000 { ++ label = "rootfs"; ++ reg = <0x0 0x1400000 0x0 0xff000000>; ++ }; ++ }; ++ }; ++}; ++ + &ohci0 { + status = "okay"; + }; diff --git a/patch/kernel/sunxi-dev/add-nand-to-cubietruck-migrate.patch.disabled b/patch/kernel/sunxi-dev/add-nand-to-cubietruck-migrate.patch.disabled new file mode 100644 index 0000000000..c9d9817f29 --- /dev/null +++ b/patch/kernel/sunxi-dev/add-nand-to-cubietruck-migrate.patch.disabled @@ -0,0 +1,23 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts +index 83f39b0..283a446 100644 +--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts ++++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts +@@ -210,6 +210,18 @@ + allwinner,pull = ; + }; + ++&nfc { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&nand_pins_a>, <&nand_cs0_pins_a>, <&nand_rb0_pins_a>; ++ status = "okay"; ++ ++ nand@0 { ++ reg = <0>; ++ allwinner,rb = <0>; ++ nand-ecc-mode = "hw"; ++ }; ++}; ++ + &ohci0 { + status = "okay"; + }; diff --git a/patch/kernel/sunxi-dev/add-nand-to-cubietruck.patch b/patch/kernel/sunxi-dev/add-nand-to-cubietruck.patch new file mode 100644 index 0000000000..db7caf9055 --- /dev/null +++ b/patch/kernel/sunxi-dev/add-nand-to-cubietruck.patch @@ -0,0 +1,61 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts +index 83f39b0..dc1d42b 100644 +--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts ++++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts +@@ -210,6 +210,56 @@ + allwinner,pull = ; + }; + ++&nfc { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&nand_pins_a>, <&nand_cs0_pins_a>, <&nand_rb0_pins_a>; ++ status = "okay"; ++ ++ nand@0 { ++ reg = <0>; ++ allwinner,rb = <0>; ++ nand-ecc-mode = "hw"; ++ nand-on-flash-bbt; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <2>; ++ #size-cells = <2>; ++ ++ partition@0 { ++ label = "SPL"; ++ reg = <0x0 0x0 0x0 0x400000>; ++ }; ++ ++ partition@400000 { ++ label = "SPL.backup"; ++ reg = <0x0 0x400000 0x0 0x400000>; ++ }; ++ ++ partition@800000 { ++ label = "U-Boot"; ++ reg = <0x0 0x800000 0x0 0x400000>; ++ }; ++ ++ partition@c00000 { ++ label = "U-Boot.backup"; ++ reg = <0x0 0xc00000 0x0 0x400000>; ++ }; ++ ++ partition@1000000 { ++ label = "env"; ++ reg = <0x0 0x1000000 0x0 0x400000>; ++ read-only; ++ }; ++ ++ partition@1400000 { ++ label = "rootfs"; ++ reg = <0x0 0x1400000 0x01 0xff000000>; ++ }; ++ }; ++ }; ++}; ++ + &ohci0 { + status = "okay"; + }; diff --git a/patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled b/patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled new file mode 100644 index 0000000000..dfb6fd998b --- /dev/null +++ b/patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled @@ -0,0 +1,35 @@ +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c +index 77533f7..8b3b184 100644 +--- a/drivers/mtd/nand/nand_base.c ++++ b/drivers/mtd/nand/nand_base.c +@@ -532,11 +532,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt) + { + struct nand_chip *chip = mtd_to_nand(mtd); + +- if (!chip->bbt) +- return chip->block_bad(mtd, ofs); +- +- /* Return info from the table */ +- return nand_isbad_bbt(mtd, ofs, allowbbt); ++ return 0; + } + + /** +@@ -3030,16 +3026,7 @@ static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) + int chipnr = (int)(offs >> chip->chip_shift); + int ret; + +- /* Select the NAND device */ +- nand_get_device(mtd, FL_READING); +- chip->select_chip(mtd, chipnr); +- +- ret = nand_block_checkbad(mtd, offs, 0); +- +- chip->select_chip(mtd, -1); +- nand_release_device(mtd); +- +- return ret; ++ return 0; + } + + /** diff --git a/patch/kernel/sunxi-dev/stmmac-coe-and-bugged-jumbo.patch b/patch/kernel/sunxi-dev/stmmac-coe-and-bugged-jumbo.patch deleted file mode 100644 index 914edbf8e3..0000000000 --- a/patch/kernel/sunxi-dev/stmmac-coe-and-bugged-jumbo.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c -index adff463..e227f3f 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c -+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c -@@ -143,7 +143,9 @@ static int sun7i_gmac_probe(struct platform_device *pdev) - /* platform data specifying hardware features and callbacks. - * hardware features were copied from Allwinner drivers. */ - plat_dat->tx_coe = 1; -+ plat_dat->rx_coe = 2; - plat_dat->has_gmac = true; -+ plat_dat->bugged_jumbo = 1; - plat_dat->bsp_priv = gmac; - plat_dat->init = sun7i_gmac_init; - plat_dat->exit = sun7i_gmac_exit; diff --git a/patch/kernel/sunxi-next/add-codec-to-bananapro-dts.patch b/patch/kernel/sunxi-next/add-codec-to-bananapro-dts.patch new file mode 100644 index 0000000000..38500f96c8 --- /dev/null +++ b/patch/kernel/sunxi-next/add-codec-to-bananapro-dts.patch @@ -0,0 +1,15 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-bananapro.dts b/arch/arm/boot/dts/sun7i-a20-bananapro.dts +index 18fcc87..f1a3356 100644 +--- a/arch/arm/boot/dts/sun7i-a20-bananapro.dts ++++ b/arch/arm/boot/dts/sun7i-a20-bananapro.dts +@@ -104,6 +104,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; diff --git a/patch/kernel/sunxi-next/b53_switch.kernel_4.5+.patch b/patch/kernel/sunxi-next/b53_switch.kernel_4.5+.patch new file mode 100644 index 0000000000..c535570b19 --- /dev/null +++ b/patch/kernel/sunxi-next/b53_switch.kernel_4.5+.patch @@ -0,0 +1,5541 @@ +diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig +old mode 100644 +new mode 100755 +index 16adbc4..1af38f6 +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -12,6 +12,16 @@ menuconfig PHYLIB + + if PHYLIB + ++config SWCONFIG ++ tristate "Switch configuration API" ++ ---help--- ++ Switch configuration API using netlink. This allows ++ you to configure the VLAN features of certain switches. ++ ++config SWCONFIG_LEDS ++ bool "Switch LED trigger support" ++ depends on (SWCONFIG && LEDS_TRIGGERS) ++ + comment "MII PHY device drivers" + + config AT803X_PHY +@@ -214,6 +224,8 @@ config MDIO_BCM_UNIMAC + + endif # PHYLIB + ++source "drivers/net/phy/b53/Kconfig" ++ + config MICREL_KS8995MA + tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch" + depends on SPI +diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile +old mode 100644 +new mode 100755 +index 501ea76..79cd3b6 +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -17,6 +17,8 @@ obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o + obj-$(CONFIG_ICPLUS_PHY) += icplus.o + obj-$(CONFIG_REALTEK_PHY) += realtek.o + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o ++ obj-$(CONFIG_SWCONFIG) += swconfig.o ++ obj-$(CONFIG_B53) += b53/ + obj-$(CONFIG_FIXED_PHY) += fixed_phy.o + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o + obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o +diff --git a/drivers/net/phy/b53/Kconfig b/drivers/net/phy/b53/Kconfig +new file mode 100755 +index 0000000..67e053e +--- /dev/null ++++ b/drivers/net/phy/b53/Kconfig +@@ -0,0 +1,37 @@ ++menuconfig B53 ++ tristate "Broadcom bcm53xx managed switch support" ++ depends on SWCONFIG ++ help ++ This driver adds support for Broadcom managed switch chips. It supports ++ BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX ++ integrated switches. ++ ++config B53_SPI_DRIVER ++ tristate "B53 SPI connected switch driver" ++ depends on B53 && SPI ++ help ++ Select to enable support for registering switches configured through SPI. ++ ++config B53_PHY_DRIVER ++ tristate "B53 MDIO connected switch driver" ++ depends on B53 ++ select B53_PHY_FIXUP ++ help ++ Select to enable support for registering switches configured through MDIO. ++ ++config B53_MMAP_DRIVER ++ tristate "B53 MMAP connected switch driver" ++ depends on B53 ++ help ++ Select to enable support for memory-mapped switches like the BCM63XX ++ integrated switches. ++ ++config B53_SRAB_DRIVER ++ tristate "B53 SRAB connected switch driver" ++ depends on B53 ++ help ++ Select to enable support for memory-mapped Switch Register Access ++ Bridge Registers (SRAB) like it is found on the BCM53010 ++ ++config B53_PHY_FIXUP ++ bool +diff --git a/drivers/net/phy/b53/Makefile b/drivers/net/phy/b53/Makefile +new file mode 100755 +index 0000000..7cc39c7 +--- /dev/null ++++ b/drivers/net/phy/b53/Makefile +@@ -0,0 +1,10 @@ ++obj-$(CONFIG_B53) += b53_common.o ++ ++obj-$(CONFIG_B53_PHY_FIXUP) += b53_phy_fixup.o ++ ++obj-$(CONFIG_B53_MMAP_DRIVER) += b53_mmap.o ++obj-$(CONFIG_B53_SRAB_DRIVER) += b53_srab.o ++obj-$(CONFIG_B53_PHY_DRIVER) += b53_mdio.o ++obj-$(CONFIG_B53_SPI_DRIVER) += b53_spi.o ++ ++ccflags-y += -Werror +diff --git a/drivers/net/phy/b53/b53_common.c b/drivers/net/phy/b53/b53_common.c +new file mode 100755 +index 0000000..ac7c10c +--- /dev/null ++++ b/drivers/net/phy/b53/b53_common.c +@@ -0,0 +1,1457 @@ ++/* ++ * B53 switch driver main logic ++ * ++ * Copyright (C) 2011-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "b53_regs.h" ++#include "b53_priv.h" ++ ++/* buffer size needed for displaying all MIBs with max'd values */ ++#define B53_BUF_SIZE 1188 ++ ++struct b53_mib_desc { ++ u8 size; ++ u8 offset; ++ const char *name; ++}; ++ ++ ++/* BCM5365 MIB counters */ ++static const struct b53_mib_desc b53_mibs_65[] = { ++ { 8, 0x00, "TxOctets" }, ++ { 4, 0x08, "TxDropPkts" }, ++ { 4, 0x10, "TxBroadcastPkts" }, ++ { 4, 0x14, "TxMulticastPkts" }, ++ { 4, 0x18, "TxUnicastPkts" }, ++ { 4, 0x1c, "TxCollisions" }, ++ { 4, 0x20, "TxSingleCollision" }, ++ { 4, 0x24, "TxMultipleCollision" }, ++ { 4, 0x28, "TxDeferredTransmit" }, ++ { 4, 0x2c, "TxLateCollision" }, ++ { 4, 0x30, "TxExcessiveCollision" }, ++ { 4, 0x38, "TxPausePkts" }, ++ { 8, 0x44, "RxOctets" }, ++ { 4, 0x4c, "RxUndersizePkts" }, ++ { 4, 0x50, "RxPausePkts" }, ++ { 4, 0x54, "Pkts64Octets" }, ++ { 4, 0x58, "Pkts65to127Octets" }, ++ { 4, 0x5c, "Pkts128to255Octets" }, ++ { 4, 0x60, "Pkts256to511Octets" }, ++ { 4, 0x64, "Pkts512to1023Octets" }, ++ { 4, 0x68, "Pkts1024to1522Octets" }, ++ { 4, 0x6c, "RxOversizePkts" }, ++ { 4, 0x70, "RxJabbers" }, ++ { 4, 0x74, "RxAlignmentErrors" }, ++ { 4, 0x78, "RxFCSErrors" }, ++ { 8, 0x7c, "RxGoodOctets" }, ++ { 4, 0x84, "RxDropPkts" }, ++ { 4, 0x88, "RxUnicastPkts" }, ++ { 4, 0x8c, "RxMulticastPkts" }, ++ { 4, 0x90, "RxBroadcastPkts" }, ++ { 4, 0x94, "RxSAChanges" }, ++ { 4, 0x98, "RxFragments" }, ++ { }, ++}; ++ ++/* BCM63xx MIB counters */ ++static const struct b53_mib_desc b53_mibs_63xx[] = { ++ { 8, 0x00, "TxOctets" }, ++ { 4, 0x08, "TxDropPkts" }, ++ { 4, 0x0c, "TxQoSPkts" }, ++ { 4, 0x10, "TxBroadcastPkts" }, ++ { 4, 0x14, "TxMulticastPkts" }, ++ { 4, 0x18, "TxUnicastPkts" }, ++ { 4, 0x1c, "TxCollisions" }, ++ { 4, 0x20, "TxSingleCollision" }, ++ { 4, 0x24, "TxMultipleCollision" }, ++ { 4, 0x28, "TxDeferredTransmit" }, ++ { 4, 0x2c, "TxLateCollision" }, ++ { 4, 0x30, "TxExcessiveCollision" }, ++ { 4, 0x38, "TxPausePkts" }, ++ { 8, 0x3c, "TxQoSOctets" }, ++ { 8, 0x44, "RxOctets" }, ++ { 4, 0x4c, "RxUndersizePkts" }, ++ { 4, 0x50, "RxPausePkts" }, ++ { 4, 0x54, "Pkts64Octets" }, ++ { 4, 0x58, "Pkts65to127Octets" }, ++ { 4, 0x5c, "Pkts128to255Octets" }, ++ { 4, 0x60, "Pkts256to511Octets" }, ++ { 4, 0x64, "Pkts512to1023Octets" }, ++ { 4, 0x68, "Pkts1024to1522Octets" }, ++ { 4, 0x6c, "RxOversizePkts" }, ++ { 4, 0x70, "RxJabbers" }, ++ { 4, 0x74, "RxAlignmentErrors" }, ++ { 4, 0x78, "RxFCSErrors" }, ++ { 8, 0x7c, "RxGoodOctets" }, ++ { 4, 0x84, "RxDropPkts" }, ++ { 4, 0x88, "RxUnicastPkts" }, ++ { 4, 0x8c, "RxMulticastPkts" }, ++ { 4, 0x90, "RxBroadcastPkts" }, ++ { 4, 0x94, "RxSAChanges" }, ++ { 4, 0x98, "RxFragments" }, ++ { 4, 0xa0, "RxSymbolErrors" }, ++ { 4, 0xa4, "RxQoSPkts" }, ++ { 8, 0xa8, "RxQoSOctets" }, ++ { 4, 0xb0, "Pkts1523to2047Octets" }, ++ { 4, 0xb4, "Pkts2048to4095Octets" }, ++ { 4, 0xb8, "Pkts4096to8191Octets" }, ++ { 4, 0xbc, "Pkts8192to9728Octets" }, ++ { 4, 0xc0, "RxDiscarded" }, ++ { } ++}; ++ ++/* MIB counters */ ++static const struct b53_mib_desc b53_mibs[] = { ++ { 8, 0x00, "TxOctets" }, ++ { 4, 0x08, "TxDropPkts" }, ++ { 4, 0x10, "TxBroadcastPkts" }, ++ { 4, 0x14, "TxMulticastPkts" }, ++ { 4, 0x18, "TxUnicastPkts" }, ++ { 4, 0x1c, "TxCollisions" }, ++ { 4, 0x20, "TxSingleCollision" }, ++ { 4, 0x24, "TxMultipleCollision" }, ++ { 4, 0x28, "TxDeferredTransmit" }, ++ { 4, 0x2c, "TxLateCollision" }, ++ { 4, 0x30, "TxExcessiveCollision" }, ++ { 4, 0x38, "TxPausePkts" }, ++ { 8, 0x50, "RxOctets" }, ++ { 4, 0x58, "RxUndersizePkts" }, ++ { 4, 0x5c, "RxPausePkts" }, ++ { 4, 0x60, "Pkts64Octets" }, ++ { 4, 0x64, "Pkts65to127Octets" }, ++ { 4, 0x68, "Pkts128to255Octets" }, ++ { 4, 0x6c, "Pkts256to511Octets" }, ++ { 4, 0x70, "Pkts512to1023Octets" }, ++ { 4, 0x74, "Pkts1024to1522Octets" }, ++ { 4, 0x78, "RxOversizePkts" }, ++ { 4, 0x7c, "RxJabbers" }, ++ { 4, 0x80, "RxAlignmentErrors" }, ++ { 4, 0x84, "RxFCSErrors" }, ++ { 8, 0x88, "RxGoodOctets" }, ++ { 4, 0x90, "RxDropPkts" }, ++ { 4, 0x94, "RxUnicastPkts" }, ++ { 4, 0x98, "RxMulticastPkts" }, ++ { 4, 0x9c, "RxBroadcastPkts" }, ++ { 4, 0xa0, "RxSAChanges" }, ++ { 4, 0xa4, "RxFragments" }, ++ { 4, 0xa8, "RxJumboPkts" }, ++ { 4, 0xac, "RxSymbolErrors" }, ++ { 4, 0xc0, "RxDiscarded" }, ++ { } ++}; ++ ++static int b53_do_vlan_op(struct b53_device *dev, u8 op) ++{ ++ unsigned int i; ++ ++ b53_write8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], VTA_START_CMD | op); ++ ++ for (i = 0; i < 10; i++) { ++ u8 vta; ++ ++ b53_read8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], &vta); ++ if (!(vta & VTA_START_CMD)) ++ return 0; ++ ++ usleep_range(100, 200); ++ } ++ ++ return -EIO; ++} ++ ++static void b53_set_vlan_entry(struct b53_device *dev, u16 vid, u16 members, ++ u16 untag) ++{ ++ if (is5325(dev)) { ++ u32 entry = 0; ++ ++ if (members) { ++ entry = ((untag & VA_UNTAG_MASK_25) << VA_UNTAG_S_25) | ++ members; ++ if (dev->core_rev >= 3) ++ entry |= VA_VALID_25_R4 | vid << VA_VID_HIGH_S; ++ else ++ entry |= VA_VALID_25; ++ } ++ ++ b53_write32(dev, B53_VLAN_PAGE, B53_VLAN_WRITE_25, entry); ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, vid | ++ VTA_RW_STATE_WR | VTA_RW_OP_EN); ++ } else if (is5365(dev)) { ++ u16 entry = 0; ++ ++ if (members) ++ entry = ((untag & VA_UNTAG_MASK_65) << VA_UNTAG_S_65) | ++ members | VA_VALID_65; ++ ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_WRITE_65, entry); ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_65, vid | ++ VTA_RW_STATE_WR | VTA_RW_OP_EN); ++ } else { ++ b53_write16(dev, B53_ARLIO_PAGE, dev->vta_regs[1], vid); ++ b53_write32(dev, B53_ARLIO_PAGE, dev->vta_regs[2], ++ (untag << VTE_UNTAG_S) | members); ++ ++ b53_do_vlan_op(dev, VTA_CMD_WRITE); ++ } ++} ++ ++void b53_set_forwarding(struct b53_device *dev, int enable) ++{ ++ u8 mgmt; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt); ++ ++ if (enable) ++ mgmt |= SM_SW_FWD_EN; ++ else ++ mgmt &= ~SM_SW_FWD_EN; ++ ++ b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt); ++} ++ ++static void b53_enable_vlan(struct b53_device *dev, int enable) ++{ ++ u8 mgmt, vc0, vc1, vc4 = 0, vc5; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt); ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL0, &vc0); ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL1, &vc1); ++ ++ if (is5325(dev) || is5365(dev)) { ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4_25, &vc4); ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5_25, &vc5); ++ } else if (is63xx(dev)) { ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4_63XX, &vc4); ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5_63XX, &vc5); ++ } else { ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4, &vc4); ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5, &vc5); ++ } ++ ++ mgmt &= ~SM_SW_FWD_MODE; ++ ++ if (enable) { ++ vc0 |= VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID; ++ vc1 |= VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN; ++ vc4 &= ~VC4_ING_VID_CHECK_MASK; ++ vc4 |= VC4_ING_VID_VIO_DROP << VC4_ING_VID_CHECK_S; ++ vc5 |= VC5_DROP_VTABLE_MISS; ++ ++ if (is5325(dev)) ++ vc0 &= ~VC0_RESERVED_1; ++ ++ if (is5325(dev) || is5365(dev)) ++ vc1 |= VC1_RX_MCST_TAG_EN; ++ ++ if (!is5325(dev) && !is5365(dev)) { ++ if (dev->allow_vid_4095) ++ vc5 |= VC5_VID_FFF_EN; ++ else ++ vc5 &= ~VC5_VID_FFF_EN; ++ } ++ } else { ++ vc0 &= ~(VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID); ++ vc1 &= ~(VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN); ++ vc4 &= ~VC4_ING_VID_CHECK_MASK; ++ vc5 &= ~VC5_DROP_VTABLE_MISS; ++ ++ if (is5325(dev) || is5365(dev)) ++ vc4 |= VC4_ING_VID_VIO_FWD << VC4_ING_VID_CHECK_S; ++ else ++ vc4 |= VC4_ING_VID_VIO_TO_IMP << VC4_ING_VID_CHECK_S; ++ ++ if (is5325(dev) || is5365(dev)) ++ vc1 &= ~VC1_RX_MCST_TAG_EN; ++ ++ if (!is5325(dev) && !is5365(dev)) ++ vc5 &= ~VC5_VID_FFF_EN; ++ } ++ ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL0, vc0); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL1, vc1); ++ ++ if (is5325(dev) || is5365(dev)) { ++ /* enable the high 8 bit vid check on 5325 */ ++ if (is5325(dev) && enable) ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL3, ++ VC3_HIGH_8BIT_EN); ++ else ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL3, 0); ++ ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4_25, vc4); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5_25, vc5); ++ } else if (is63xx(dev)) { ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_CTRL3_63XX, 0); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4_63XX, vc4); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5_63XX, vc5); ++ } else { ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_CTRL3, 0); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4, vc4); ++ b53_write8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5, vc5); ++ } ++ ++ b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt); ++} ++ ++static int b53_set_jumbo(struct b53_device *dev, int enable, int allow_10_100) ++{ ++ u32 port_mask = 0; ++ u16 max_size = JMS_MIN_SIZE; ++ ++ if (is5325(dev) || is5365(dev)) ++ return -EINVAL; ++ ++ if (enable) { ++ port_mask = dev->enabled_ports; ++ max_size = JMS_MAX_SIZE; ++ if (allow_10_100) ++ port_mask |= JPM_10_100_JUMBO_EN; ++ } ++ ++ b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask); ++ return b53_write16(dev, B53_JUMBO_PAGE, dev->jumbo_size_reg, max_size); ++} ++ ++static int b53_flush_arl(struct b53_device *dev) ++{ ++ unsigned int i; ++ ++ b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_CTRL, ++ FAST_AGE_DONE | FAST_AGE_DYNAMIC | FAST_AGE_STATIC); ++ ++ for (i = 0; i < 10; i++) { ++ u8 fast_age_ctrl; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_FAST_AGE_CTRL, ++ &fast_age_ctrl); ++ ++ if (!(fast_age_ctrl & FAST_AGE_DONE)) ++ return 0; ++ ++ mdelay(1); ++ } ++ ++ pr_warn("time out while flushing ARL\n"); ++ ++ return -EINVAL; ++} ++ ++static void b53_enable_ports(struct b53_device *dev) ++{ ++ unsigned i; ++ ++ b53_for_each_port(dev, i) { ++ u8 port_ctrl; ++ u16 pvlan_mask; ++ ++ /* ++ * prevent leaking packets between wan and lan in unmanaged ++ * mode through port vlans. ++ */ ++ if (dev->enable_vlan || is_cpu_port(dev, i)) ++ pvlan_mask = 0x1ff; ++ else if (is531x5(dev) || is5301x(dev)) ++ /* BCM53115 may use a different port as cpu port */ ++ pvlan_mask = BIT(dev->sw_dev.cpu_port); ++ else ++ pvlan_mask = BIT(B53_CPU_PORT); ++ ++ /* BCM5325 CPU port is at 8 */ ++ if ((is5325(dev) || is5365(dev)) && i == B53_CPU_PORT_25) ++ i = B53_CPU_PORT; ++ ++ if (dev->chip_id == BCM5398_DEVICE_ID && (i == 6 || i == 7)) ++ /* disable unused ports 6 & 7 */ ++ port_ctrl = PORT_CTRL_RX_DISABLE | PORT_CTRL_TX_DISABLE; ++ else if (i == B53_CPU_PORT) ++ port_ctrl = PORT_CTRL_RX_BCST_EN | ++ PORT_CTRL_RX_MCST_EN | ++ PORT_CTRL_RX_UCST_EN; ++ else ++ port_ctrl = 0; ++ ++ b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), ++ pvlan_mask); ++ ++ /* port state is handled by bcm63xx_enet driver */ ++ if (!is63xx(dev) && !(is5301x(dev) && i == 6)) ++ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(i), ++ port_ctrl); ++ } ++} ++ ++static void b53_enable_mib(struct b53_device *dev) ++{ ++ u8 gc; ++ ++ b53_read8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, &gc); ++ ++ gc &= ~(GC_RESET_MIB | GC_MIB_AC_EN); ++ ++ b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc); ++} ++ ++static int b53_apply(struct b53_device *dev) ++{ ++ int i; ++ ++ /* clear all vlan entries */ ++ if (is5325(dev) || is5365(dev)) { ++ for (i = 1; i < dev->sw_dev.vlans; i++) ++ b53_set_vlan_entry(dev, i, 0, 0); ++ } else { ++ b53_do_vlan_op(dev, VTA_CMD_CLEAR); ++ } ++ ++ b53_enable_vlan(dev, dev->enable_vlan); ++ ++ /* fill VLAN table */ ++ if (dev->enable_vlan) { ++ for (i = 0; i < dev->sw_dev.vlans; i++) { ++ struct b53_vlan *vlan = &dev->vlans[i]; ++ ++ if (!vlan->members) ++ continue; ++ ++ b53_set_vlan_entry(dev, i, vlan->members, vlan->untag); ++ } ++ ++ b53_for_each_port(dev, i) ++ b53_write16(dev, B53_VLAN_PAGE, ++ B53_VLAN_PORT_DEF_TAG(i), ++ dev->ports[i].pvid); ++ } else { ++ b53_for_each_port(dev, i) ++ b53_write16(dev, B53_VLAN_PAGE, ++ B53_VLAN_PORT_DEF_TAG(i), 1); ++ ++ } ++ ++ b53_enable_ports(dev); ++ ++ if (!is5325(dev) && !is5365(dev)) ++ b53_set_jumbo(dev, dev->enable_jumbo, 1); ++ ++ return 0; ++} ++ ++static void b53_switch_reset_gpio(struct b53_device *dev) ++{ ++ int gpio = dev->reset_gpio; ++ ++ if (gpio < 0) ++ return; ++ ++ /* ++ * Reset sequence: RESET low(50ms)->high(20ms) ++ */ ++ gpio_set_value(gpio, 0); ++ mdelay(50); ++ ++ gpio_set_value(gpio, 1); ++ mdelay(20); ++ ++ dev->current_page = 0xff; ++} ++ ++static int b53_switch_reset(struct b53_device *dev) ++{ ++ u8 cpu_port = dev->sw_dev.cpu_port; ++ u8 mgmt; ++ ++ b53_switch_reset_gpio(dev); ++ ++ if (is539x(dev)) { ++ b53_write8(dev, B53_CTRL_PAGE, B53_SOFTRESET, 0x83); ++ b53_write8(dev, B53_CTRL_PAGE, B53_SOFTRESET, 0x00); ++ } ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt); ++ ++ if (!(mgmt & SM_SW_FWD_EN)) { ++ mgmt &= ~SM_SW_FWD_MODE; ++ mgmt |= SM_SW_FWD_EN; ++ ++ b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt); ++ b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt); ++ ++ if (!(mgmt & SM_SW_FWD_EN)) { ++ pr_err("Failed to enable switch!\n"); ++ return -EINVAL; ++ } ++ } ++ ++ /* enable all ports */ ++ b53_enable_ports(dev); ++ ++ /* configure MII port if necessary */ ++ if (is5325(dev)) { ++ u8 mii_port_override; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ &mii_port_override); ++ /* reverse mii needs to be enabled */ ++ if (!(mii_port_override & PORT_OVERRIDE_RV_MII_25)) { ++ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ mii_port_override | PORT_OVERRIDE_RV_MII_25); ++ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ &mii_port_override); ++ ++ if (!(mii_port_override & PORT_OVERRIDE_RV_MII_25)) { ++ pr_err("Failed to enable reverse MII mode\n"); ++ return -EINVAL; ++ } ++ } ++ } else if (is531x5(dev) && cpu_port == B53_CPU_PORT) { ++ u8 mii_port_override; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ &mii_port_override); ++ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ mii_port_override | PORT_OVERRIDE_EN | ++ PORT_OVERRIDE_LINK); ++ } else if (is5301x(dev)) { ++ if (cpu_port == 8) { ++ u8 mii_port_override; ++ ++ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ &mii_port_override); ++ mii_port_override |= PORT_OVERRIDE_LINK | ++ PORT_OVERRIDE_RX_FLOW | ++ PORT_OVERRIDE_TX_FLOW | ++ PORT_OVERRIDE_SPEED_2000M | ++ PORT_OVERRIDE_EN; ++ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL, ++ mii_port_override); ++ ++ /* TODO: Ports 5 & 7 require some extra handling */ ++ } else { ++ u8 po_reg = B53_GMII_PORT_OVERRIDE_CTRL(cpu_port); ++ u8 gmii_po; ++ ++ b53_read8(dev, B53_CTRL_PAGE, po_reg, &gmii_po); ++ gmii_po |= GMII_PO_LINK | ++ GMII_PO_RX_FLOW | ++ GMII_PO_TX_FLOW | ++ GMII_PO_EN | ++ GMII_PO_SPEED_2000M; ++ b53_write8(dev, B53_CTRL_PAGE, po_reg, gmii_po); ++ } ++ } ++ ++ b53_enable_mib(dev); ++ ++ return b53_flush_arl(dev); ++} ++ ++/* ++ * Swconfig glue functions ++ */ ++ ++static int b53_global_get_vlan_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ val->value.i = priv->enable_vlan; ++ ++ return 0; ++} ++ ++static int b53_global_set_vlan_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ priv->enable_vlan = val->value.i; ++ ++ return 0; ++} ++ ++static int b53_global_get_jumbo_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ val->value.i = priv->enable_jumbo; ++ ++ return 0; ++} ++ ++static int b53_global_set_jumbo_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ priv->enable_jumbo = val->value.i; ++ ++ return 0; ++} ++ ++static int b53_global_get_4095_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ val->value.i = priv->allow_vid_4095; ++ ++ return 0; ++} ++ ++static int b53_global_set_4095_enable(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ priv->allow_vid_4095 = val->value.i; ++ ++ return 0; ++} ++ ++static int b53_global_get_ports(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ val->len = snprintf(priv->buf, B53_BUF_SIZE, "0x%04x", ++ priv->enabled_ports); ++ val->value.s = priv->buf; ++ ++ return 0; ++} ++ ++static int b53_port_get_pvid(struct switch_dev *dev, int port, int *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ *val = priv->ports[port].pvid; ++ ++ return 0; ++} ++ ++static int b53_port_set_pvid(struct switch_dev *dev, int port, int val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ if (val > 15 && is5325(priv)) ++ return -EINVAL; ++ if (val == 4095 && !priv->allow_vid_4095) ++ return -EINVAL; ++ ++ priv->ports[port].pvid = val; ++ ++ return 0; ++} ++ ++static int b53_vlan_get_ports(struct switch_dev *dev, struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ struct switch_port *port = &val->value.ports[0]; ++ struct b53_vlan *vlan = &priv->vlans[val->port_vlan]; ++ int i; ++ ++ val->len = 0; ++ ++ if (!vlan->members) ++ return 0; ++ ++ for (i = 0; i < dev->ports; i++) { ++ if (!(vlan->members & BIT(i))) ++ continue; ++ ++ ++ if (!(vlan->untag & BIT(i))) ++ port->flags = BIT(SWITCH_PORT_FLAG_TAGGED); ++ else ++ port->flags = 0; ++ ++ port->id = i; ++ val->len++; ++ port++; ++ } ++ ++ return 0; ++} ++ ++static int b53_vlan_set_ports(struct switch_dev *dev, struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ struct switch_port *port; ++ struct b53_vlan *vlan = &priv->vlans[val->port_vlan]; ++ int i; ++ ++ /* only BCM5325 and BCM5365 supports VID 0 */ ++ if (val->port_vlan == 0 && !is5325(priv) && !is5365(priv)) ++ return -EINVAL; ++ ++ /* VLAN 4095 needs special handling */ ++ if (val->port_vlan == 4095 && !priv->allow_vid_4095) ++ return -EINVAL; ++ ++ port = &val->value.ports[0]; ++ vlan->members = 0; ++ vlan->untag = 0; ++ for (i = 0; i < val->len; i++, port++) { ++ vlan->members |= BIT(port->id); ++ ++ if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED))) { ++ vlan->untag |= BIT(port->id); ++ priv->ports[port->id].pvid = val->port_vlan; ++ }; ++ } ++ ++ /* ignore disabled ports */ ++ vlan->members &= priv->enabled_ports; ++ vlan->untag &= priv->enabled_ports; ++ ++ return 0; ++} ++ ++static int b53_port_get_link(struct switch_dev *dev, int port, ++ struct switch_port_link *link) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ if (is_cpu_port(priv, port)) { ++ link->link = 1; ++ link->duplex = 1; ++ link->speed = is5325(priv) || is5365(priv) ? ++ SWITCH_PORT_SPEED_100 : SWITCH_PORT_SPEED_1000; ++ link->aneg = 0; ++ } else if (priv->enabled_ports & BIT(port)) { ++ u32 speed; ++ u16 lnk, duplex; ++ ++ b53_read16(priv, B53_STAT_PAGE, B53_LINK_STAT, &lnk); ++ b53_read16(priv, B53_STAT_PAGE, priv->duplex_reg, &duplex); ++ ++ lnk = (lnk >> port) & 1; ++ duplex = (duplex >> port) & 1; ++ ++ if (is5325(priv) || is5365(priv)) { ++ u16 tmp; ++ ++ b53_read16(priv, B53_STAT_PAGE, B53_SPEED_STAT, &tmp); ++ speed = SPEED_PORT_FE(tmp, port); ++ } else { ++ b53_read32(priv, B53_STAT_PAGE, B53_SPEED_STAT, &speed); ++ speed = SPEED_PORT_GE(speed, port); ++ } ++ ++ link->link = lnk; ++ if (lnk) { ++ link->duplex = duplex; ++ switch (speed) { ++ case SPEED_STAT_10M: ++ link->speed = SWITCH_PORT_SPEED_10; ++ break; ++ case SPEED_STAT_100M: ++ link->speed = SWITCH_PORT_SPEED_100; ++ break; ++ case SPEED_STAT_1000M: ++ link->speed = SWITCH_PORT_SPEED_1000; ++ break; ++ } ++ } ++ ++ link->aneg = 1; ++ } else { ++ link->link = 0; ++ } ++ ++ return 0; ++ ++} ++ ++static int b53_global_reset_switch(struct switch_dev *dev) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ /* reset vlans */ ++ priv->enable_vlan = 0; ++ priv->enable_jumbo = 0; ++ priv->allow_vid_4095 = 0; ++ ++ memset(priv->vlans, 0, sizeof(priv->vlans) * dev->vlans); ++ memset(priv->ports, 0, sizeof(priv->ports) * dev->ports); ++ ++ return b53_switch_reset(priv); ++} ++ ++static int b53_global_apply_config(struct switch_dev *dev) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ ++ /* disable switching */ ++ b53_set_forwarding(priv, 0); ++ ++ b53_apply(priv); ++ ++ /* enable switching */ ++ b53_set_forwarding(priv, 1); ++ ++ return 0; ++} ++ ++ ++static int b53_global_reset_mib(struct switch_dev *dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *priv = sw_to_b53(dev); ++ u8 gc; ++ ++ b53_read8(priv, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, &gc); ++ ++ b53_write8(priv, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc | GC_RESET_MIB); ++ mdelay(1); ++ b53_write8(priv, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc & ~GC_RESET_MIB); ++ mdelay(1); ++ ++ return 0; ++} ++ ++static int b53_port_get_mib(struct switch_dev *sw_dev, ++ const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct b53_device *dev = sw_to_b53(sw_dev); ++ const struct b53_mib_desc *mibs; ++ int port = val->port_vlan; ++ int len = 0; ++ ++ if (!(BIT(port) & dev->enabled_ports)) ++ return -1; ++ ++ if (is5365(dev)) { ++ if (port == 5) ++ port = 8; ++ ++ mibs = b53_mibs_65; ++ } else if (is63xx(dev)) { ++ mibs = b53_mibs_63xx; ++ } else { ++ mibs = b53_mibs; ++ } ++ ++ dev->buf[0] = 0; ++ ++ for (; mibs->size > 0; mibs++) { ++ u64 val; ++ ++ if (mibs->size == 8) { ++ b53_read64(dev, B53_MIB_PAGE(port), mibs->offset, &val); ++ } else { ++ u32 val32; ++ ++ b53_read32(dev, B53_MIB_PAGE(port), mibs->offset, ++ &val32); ++ val = val32; ++ } ++ ++ len += snprintf(dev->buf + len, B53_BUF_SIZE - len, ++ "%-20s: %llu\n", mibs->name, val); ++ } ++ ++ val->len = len; ++ val->value.s = dev->buf; ++ ++ return 0; ++} ++ ++static struct switch_attr b53_global_ops_25[] = { ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "enable_vlan", ++ .description = "Enable VLAN mode", ++ .set = b53_global_set_vlan_enable, ++ .get = b53_global_get_vlan_enable, ++ .max = 1, ++ }, ++ { ++ .type = SWITCH_TYPE_STRING, ++ .name = "ports", ++ .description = "Available ports (as bitmask)", ++ .get = b53_global_get_ports, ++ }, ++}; ++ ++static struct switch_attr b53_global_ops_65[] = { ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "enable_vlan", ++ .description = "Enable VLAN mode", ++ .set = b53_global_set_vlan_enable, ++ .get = b53_global_get_vlan_enable, ++ .max = 1, ++ }, ++ { ++ .type = SWITCH_TYPE_STRING, ++ .name = "ports", ++ .description = "Available ports (as bitmask)", ++ .get = b53_global_get_ports, ++ }, ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "reset_mib", ++ .description = "Reset MIB counters", ++ .set = b53_global_reset_mib, ++ }, ++}; ++ ++static struct switch_attr b53_global_ops[] = { ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "enable_vlan", ++ .description = "Enable VLAN mode", ++ .set = b53_global_set_vlan_enable, ++ .get = b53_global_get_vlan_enable, ++ .max = 1, ++ }, ++ { ++ .type = SWITCH_TYPE_STRING, ++ .name = "ports", ++ .description = "Available Ports (as bitmask)", ++ .get = b53_global_get_ports, ++ }, ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "reset_mib", ++ .description = "Reset MIB counters", ++ .set = b53_global_reset_mib, ++ }, ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "enable_jumbo", ++ .description = "Enable Jumbo Frames", ++ .set = b53_global_set_jumbo_enable, ++ .get = b53_global_get_jumbo_enable, ++ .max = 1, ++ }, ++ { ++ .type = SWITCH_TYPE_INT, ++ .name = "allow_vid_4095", ++ .description = "Allow VID 4095", ++ .set = b53_global_set_4095_enable, ++ .get = b53_global_get_4095_enable, ++ .max = 1, ++ }, ++}; ++ ++static struct switch_attr b53_port_ops[] = { ++ { ++ .type = SWITCH_TYPE_STRING, ++ .name = "mib", ++ .description = "Get port's MIB counters", ++ .get = b53_port_get_mib, ++ }, ++}; ++ ++static struct switch_attr b53_no_ops[] = { ++}; ++ ++static const struct switch_dev_ops b53_switch_ops_25 = { ++ .attr_global = { ++ .attr = b53_global_ops_25, ++ .n_attr = ARRAY_SIZE(b53_global_ops_25), ++ }, ++ .attr_port = { ++ .attr = b53_no_ops, ++ .n_attr = ARRAY_SIZE(b53_no_ops), ++ }, ++ .attr_vlan = { ++ .attr = b53_no_ops, ++ .n_attr = ARRAY_SIZE(b53_no_ops), ++ }, ++ ++ .get_vlan_ports = b53_vlan_get_ports, ++ .set_vlan_ports = b53_vlan_set_ports, ++ .get_port_pvid = b53_port_get_pvid, ++ .set_port_pvid = b53_port_set_pvid, ++ .apply_config = b53_global_apply_config, ++ .reset_switch = b53_global_reset_switch, ++ .get_port_link = b53_port_get_link, ++}; ++ ++static const struct switch_dev_ops b53_switch_ops_65 = { ++ .attr_global = { ++ .attr = b53_global_ops_65, ++ .n_attr = ARRAY_SIZE(b53_global_ops_65), ++ }, ++ .attr_port = { ++ .attr = b53_port_ops, ++ .n_attr = ARRAY_SIZE(b53_port_ops), ++ }, ++ .attr_vlan = { ++ .attr = b53_no_ops, ++ .n_attr = ARRAY_SIZE(b53_no_ops), ++ }, ++ ++ .get_vlan_ports = b53_vlan_get_ports, ++ .set_vlan_ports = b53_vlan_set_ports, ++ .get_port_pvid = b53_port_get_pvid, ++ .set_port_pvid = b53_port_set_pvid, ++ .apply_config = b53_global_apply_config, ++ .reset_switch = b53_global_reset_switch, ++ .get_port_link = b53_port_get_link, ++}; ++ ++static const struct switch_dev_ops b53_switch_ops = { ++ .attr_global = { ++ .attr = b53_global_ops, ++ .n_attr = ARRAY_SIZE(b53_global_ops), ++ }, ++ .attr_port = { ++ .attr = b53_port_ops, ++ .n_attr = ARRAY_SIZE(b53_port_ops), ++ }, ++ .attr_vlan = { ++ .attr = b53_no_ops, ++ .n_attr = ARRAY_SIZE(b53_no_ops), ++ }, ++ ++ .get_vlan_ports = b53_vlan_get_ports, ++ .set_vlan_ports = b53_vlan_set_ports, ++ .get_port_pvid = b53_port_get_pvid, ++ .set_port_pvid = b53_port_set_pvid, ++ .apply_config = b53_global_apply_config, ++ .reset_switch = b53_global_reset_switch, ++ .get_port_link = b53_port_get_link, ++}; ++ ++struct b53_chip_data { ++ u32 chip_id; ++ const char *dev_name; ++ const char *alias; ++ u16 vlans; ++ u16 enabled_ports; ++ u8 cpu_port; ++ u8 vta_regs[3]; ++ u8 duplex_reg; ++ u8 jumbo_pm_reg; ++ u8 jumbo_size_reg; ++ const struct switch_dev_ops *sw_ops; ++}; ++ ++#define B53_VTA_REGS \ ++ { B53_VT_ACCESS, B53_VT_INDEX, B53_VT_ENTRY } ++#define B53_VTA_REGS_9798 \ ++ { B53_VT_ACCESS_9798, B53_VT_INDEX_9798, B53_VT_ENTRY_9798 } ++#define B53_VTA_REGS_63XX \ ++ { B53_VT_ACCESS_63XX, B53_VT_INDEX_63XX, B53_VT_ENTRY_63XX } ++ ++static const struct b53_chip_data b53_switch_chips[] = { ++ { ++ .chip_id = BCM5325_DEVICE_ID, ++ .dev_name = "BCM5325", ++ .alias = "bcm5325", ++ .vlans = 16, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, ++ .duplex_reg = B53_DUPLEX_STAT_FE, ++ .sw_ops = &b53_switch_ops_25, ++ }, ++ { ++ .chip_id = BCM5365_DEVICE_ID, ++ .dev_name = "BCM5365", ++ .alias = "bcm5365", ++ .vlans = 256, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, ++ .duplex_reg = B53_DUPLEX_STAT_FE, ++ .sw_ops = &b53_switch_ops_65, ++ }, ++ { ++ .chip_id = BCM5395_DEVICE_ID, ++ .dev_name = "BCM5395", ++ .alias = "bcm5395", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM5397_DEVICE_ID, ++ .dev_name = "BCM5397", ++ .alias = "bcm5397", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS_9798, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM5398_DEVICE_ID, ++ .dev_name = "BCM5398", ++ .alias = "bcm5398", ++ .vlans = 4096, ++ .enabled_ports = 0x7f, ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS_9798, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53115_DEVICE_ID, ++ .dev_name = "BCM53115", ++ .alias = "bcm53115", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .vta_regs = B53_VTA_REGS, ++ .cpu_port = B53_CPU_PORT, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53125_DEVICE_ID, ++ .dev_name = "BCM53125", ++ .alias = "bcm53125", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53128_DEVICE_ID, ++ .dev_name = "BCM53128", ++ .alias = "bcm53128", ++ .vlans = 4096, ++ .enabled_ports = 0x1ff, ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM63XX_DEVICE_ID, ++ .dev_name = "BCM63xx", ++ .alias = "bcm63xx", ++ .vlans = 4096, ++ .enabled_ports = 0, /* pdata must provide them */ ++ .cpu_port = B53_CPU_PORT, ++ .vta_regs = B53_VTA_REGS_63XX, ++ .duplex_reg = B53_DUPLEX_STAT_63XX, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53010_DEVICE_ID, ++ .dev_name = "BCM53010", ++ .alias = "bcm53011", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */ ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53011_DEVICE_ID, ++ .dev_name = "BCM53011", ++ .alias = "bcm53011", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */ ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53012_DEVICE_ID, ++ .dev_name = "BCM53012", ++ .alias = "bcm53011", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */ ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53018_DEVICE_ID, ++ .dev_name = "BCM53018", ++ .alias = "bcm53018", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */ ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++ { ++ .chip_id = BCM53019_DEVICE_ID, ++ .dev_name = "BCM53019", ++ .alias = "bcm53019", ++ .vlans = 4096, ++ .enabled_ports = 0x1f, ++ .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */ ++ .vta_regs = B53_VTA_REGS, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .sw_ops = &b53_switch_ops, ++ }, ++}; ++ ++static int b53_switch_init(struct b53_device *dev) ++{ ++ struct switch_dev *sw_dev = &dev->sw_dev; ++ unsigned i; ++ int ret; ++ ++ for (i = 0; i < ARRAY_SIZE(b53_switch_chips); i++) { ++ const struct b53_chip_data *chip = &b53_switch_chips[i]; ++ ++ if (chip->chip_id == dev->chip_id) { ++ sw_dev->name = chip->dev_name; ++ if (!sw_dev->alias) ++ sw_dev->alias = chip->alias; ++ if (!dev->enabled_ports) ++ dev->enabled_ports = chip->enabled_ports; ++ dev->duplex_reg = chip->duplex_reg; ++ dev->vta_regs[0] = chip->vta_regs[0]; ++ dev->vta_regs[1] = chip->vta_regs[1]; ++ dev->vta_regs[2] = chip->vta_regs[2]; ++ dev->jumbo_pm_reg = chip->jumbo_pm_reg; ++ sw_dev->ops = chip->sw_ops; ++ sw_dev->cpu_port = chip->cpu_port; ++ sw_dev->vlans = chip->vlans; ++ break; ++ } ++ } ++ ++ if (!sw_dev->name) ++ return -EINVAL; ++ ++ /* check which BCM5325x version we have */ ++ if (is5325(dev)) { ++ u8 vc4; ++ ++ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL4_25, &vc4); ++ ++ /* check reserved bits */ ++ switch (vc4 & 3) { ++ case 1: ++ /* BCM5325E */ ++ break; ++ case 3: ++ /* BCM5325F - do not use port 4 */ ++ dev->enabled_ports &= ~BIT(4); ++ break; ++ default: ++/* On the BCM47XX SoCs this is the supported internal switch.*/ ++#ifndef CONFIG_BCM47XX ++ /* BCM5325M */ ++ return -EINVAL; ++#else ++ break; ++#endif ++ } ++ } else if (dev->chip_id == BCM53115_DEVICE_ID) { ++ u64 strap_value; ++ ++ b53_read48(dev, B53_STAT_PAGE, B53_STRAP_VALUE, &strap_value); ++ /* use second IMP port if GMII is enabled */ ++ if (strap_value & SV_GMII_CTRL_115) ++ sw_dev->cpu_port = 5; ++ } ++ ++ /* cpu port is always last */ ++ sw_dev->ports = sw_dev->cpu_port + 1; ++ dev->enabled_ports |= BIT(sw_dev->cpu_port); ++ ++ dev->ports = devm_kzalloc(dev->dev, ++ sizeof(struct b53_port) * sw_dev->ports, ++ GFP_KERNEL); ++ if (!dev->ports) ++ return -ENOMEM; ++ ++ dev->vlans = devm_kzalloc(dev->dev, ++ sizeof(struct b53_vlan) * sw_dev->vlans, ++ GFP_KERNEL); ++ if (!dev->vlans) ++ return -ENOMEM; ++ ++ dev->buf = devm_kzalloc(dev->dev, B53_BUF_SIZE, GFP_KERNEL); ++ if (!dev->buf) ++ return -ENOMEM; ++ ++ dev->reset_gpio = b53_switch_get_reset_gpio(dev); ++ if (dev->reset_gpio >= 0) { ++ ret = devm_gpio_request_one(dev->dev, dev->reset_gpio, ++ GPIOF_OUT_INIT_HIGH, "robo_reset"); ++ if (ret) ++ return ret; ++ } ++ ++ return b53_switch_reset(dev); ++} ++ ++struct b53_device *b53_switch_alloc(struct device *base, struct b53_io_ops *ops, ++ void *priv) ++{ ++ struct b53_device *dev; ++ ++ dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL); ++ if (!dev) ++ return NULL; ++ ++ dev->dev = base; ++ dev->ops = ops; ++ dev->priv = priv; ++ mutex_init(&dev->reg_mutex); ++ ++ return dev; ++} ++EXPORT_SYMBOL(b53_switch_alloc); ++ ++int b53_switch_detect(struct b53_device *dev) ++{ ++ u32 id32; ++ u16 tmp; ++ u8 id8; ++ int ret; ++ ++ ret = b53_read8(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id8); ++ if (ret) ++ return ret; ++ ++ switch (id8) { ++ case 0: ++ /* ++ * BCM5325 and BCM5365 do not have this register so reads ++ * return 0. But the read operation did succeed, so assume ++ * this is one of them. ++ * ++ * Next check if we can write to the 5325's VTA register; for ++ * 5365 it is read only. ++ */ ++ ++ b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, 0xf); ++ b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, &tmp); ++ ++ if (tmp == 0xf) ++ dev->chip_id = BCM5325_DEVICE_ID; ++ else ++ dev->chip_id = BCM5365_DEVICE_ID; ++ break; ++ case BCM5395_DEVICE_ID: ++ case BCM5397_DEVICE_ID: ++ case BCM5398_DEVICE_ID: ++ dev->chip_id = id8; ++ break; ++ default: ++ ret = b53_read32(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id32); ++ if (ret) ++ return ret; ++ ++ switch (id32) { ++ case BCM53115_DEVICE_ID: ++ case BCM53125_DEVICE_ID: ++ case BCM53128_DEVICE_ID: ++ case BCM53010_DEVICE_ID: ++ case BCM53011_DEVICE_ID: ++ case BCM53012_DEVICE_ID: ++ case BCM53018_DEVICE_ID: ++ case BCM53019_DEVICE_ID: ++ dev->chip_id = id32; ++ break; ++ default: ++ pr_err("unsupported switch detected (BCM53%02x/BCM%x)\n", ++ id8, id32); ++ return -ENODEV; ++ } ++ } ++ ++ if (dev->chip_id == BCM5325_DEVICE_ID) ++ return b53_read8(dev, B53_STAT_PAGE, B53_REV_ID_25, ++ &dev->core_rev); ++ else ++ return b53_read8(dev, B53_MGMT_PAGE, B53_REV_ID, ++ &dev->core_rev); ++} ++EXPORT_SYMBOL(b53_switch_detect); ++ ++int b53_switch_register(struct b53_device *dev) ++{ ++ int ret; ++ ++ if (dev->pdata) { ++ dev->chip_id = dev->pdata->chip_id; ++ dev->enabled_ports = dev->pdata->enabled_ports; ++ dev->sw_dev.alias = dev->pdata->alias; ++ } ++ ++ if (!dev->chip_id && b53_switch_detect(dev)) ++ return -EINVAL; ++ ++ ret = b53_switch_init(dev); ++ if (ret) ++ return ret; ++ ++ pr_info("found switch: %s, rev %i\n", dev->sw_dev.name, dev->core_rev); ++ ++ return register_switch(&dev->sw_dev, NULL); ++} ++EXPORT_SYMBOL(b53_switch_register); ++ ++MODULE_AUTHOR("Jonas Gorski "); ++MODULE_DESCRIPTION("B53 switch library"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff --git a/drivers/net/phy/b53/b53_mdio.c b/drivers/net/phy/b53/b53_mdio.c +new file mode 100755 +index 0000000..3c25f0e +--- /dev/null ++++ b/drivers/net/phy/b53/b53_mdio.c +@@ -0,0 +1,396 @@ ++/* ++ * B53 register access through MII registers ++ * ++ * Copyright (C) 2011-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++ ++#include "b53_priv.h" ++ ++#define B53_PSEUDO_PHY 0x1e /* Register Access Pseudo PHY */ ++ ++/* MII registers */ ++#define REG_MII_PAGE 0x10 /* MII Page register */ ++#define REG_MII_ADDR 0x11 /* MII Address register */ ++#define REG_MII_DATA0 0x18 /* MII Data register 0 */ ++#define REG_MII_DATA1 0x19 /* MII Data register 1 */ ++#define REG_MII_DATA2 0x1a /* MII Data register 2 */ ++#define REG_MII_DATA3 0x1b /* MII Data register 3 */ ++ ++#define REG_MII_PAGE_ENABLE BIT(0) ++#define REG_MII_ADDR_WRITE BIT(0) ++#define REG_MII_ADDR_READ BIT(1) ++ ++static int b53_mdio_op(struct b53_device *dev, u8 page, u8 reg, u16 op) ++{ ++ int i; ++ u16 v; ++ int ret; ++ struct mii_bus *bus = dev->priv; ++ ++ if (dev->current_page != page) { ++ /* set page number */ ++ v = (page << 8) | REG_MII_PAGE_ENABLE; ++ ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_PAGE, v); ++ if (ret) ++ return ret; ++ dev->current_page = page; ++ } ++ ++ /* set register address */ ++ v = (reg << 8) | op; ++ ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_ADDR, v); ++ if (ret) ++ return ret; ++ ++ /* check if operation completed */ ++ for (i = 0; i < 5; ++i) { ++ v = mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_ADDR); ++ if (!(v & (REG_MII_ADDR_WRITE | REG_MII_ADDR_READ))) ++ break; ++ usleep_range(10, 100); ++ } ++ ++ if (WARN_ON(i == 5)) ++ return -EIO; ++ ++ return 0; ++} ++ ++static int b53_mdio_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) ++{ ++ struct mii_bus *bus = dev->priv; ++ int ret; ++ ++ ret = b53_mdio_op(dev, page, reg, REG_MII_ADDR_READ); ++ if (ret) ++ return ret; ++ ++ *val = mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA0) & 0xff; ++ ++ return 0; ++} ++ ++static int b53_mdio_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ++{ ++ struct mii_bus *bus = dev->priv; ++ int ret; ++ ++ ret = b53_mdio_op(dev, page, reg, REG_MII_ADDR_READ); ++ if (ret) ++ return ret; ++ ++ *val = mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA0); ++ ++ return 0; ++} ++ ++static int b53_mdio_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ++{ ++ struct mii_bus *bus = dev->priv; ++ int ret; ++ ++ ret = b53_mdio_op(dev, page, reg, REG_MII_ADDR_READ); ++ if (ret) ++ return ret; ++ ++ *val = mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA0); ++ *val |= mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA1) << 16; ++ ++ return 0; ++} ++ ++static int b53_mdio_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ struct mii_bus *bus = dev->priv; ++ u64 temp = 0; ++ int i; ++ int ret; ++ ++ ret = b53_mdio_op(dev, page, reg, REG_MII_ADDR_READ); ++ if (ret) ++ return ret; ++ ++ for (i = 2; i >= 0; i--) { ++ temp <<= 16; ++ temp |= mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA0 + i); ++ } ++ ++ *val = temp; ++ ++ return 0; ++} ++ ++static int b53_mdio_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ struct mii_bus *bus = dev->priv; ++ u64 temp = 0; ++ int i; ++ int ret; ++ ++ ret = b53_mdio_op(dev, page, reg, REG_MII_ADDR_READ); ++ if (ret) ++ return ret; ++ ++ for (i = 3; i >= 0; i--) { ++ temp <<= 16; ++ temp |= mdiobus_read(bus, B53_PSEUDO_PHY, REG_MII_DATA0 + i); ++ } ++ ++ *val = temp; ++ ++ return 0; ++} ++ ++static int b53_mdio_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) ++{ ++ struct mii_bus *bus = dev->priv; ++ int ret; ++ ++ ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_DATA0, value); ++ if (ret) ++ return ret; ++ ++ return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); ++} ++ ++static int b53_mdio_write16(struct b53_device *dev, u8 page, u8 reg, ++ u16 value) ++{ ++ struct mii_bus *bus = dev->priv; ++ int ret; ++ ++ ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_DATA0, value); ++ if (ret) ++ return ret; ++ ++ return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); ++} ++ ++static int b53_mdio_write32(struct b53_device *dev, u8 page, u8 reg, ++ u32 value) ++{ ++ struct mii_bus *bus = dev->priv; ++ unsigned int i; ++ u32 temp = value; ++ ++ for (i = 0; i < 2; i++) { ++ int ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_DATA0 + i, ++ temp & 0xffff); ++ if (ret) ++ return ret; ++ temp >>= 16; ++ } ++ ++ return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); ++ ++} ++ ++static int b53_mdio_write48(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ struct mii_bus *bus = dev->priv; ++ unsigned i; ++ u64 temp = value; ++ ++ for (i = 0; i < 3; i++) { ++ int ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_DATA0 + i, ++ temp & 0xffff); ++ if (ret) ++ return ret; ++ temp >>= 16; ++ } ++ ++ return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); ++ ++} ++ ++static int b53_mdio_write64(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ struct mii_bus *bus = dev->priv; ++ unsigned i; ++ u64 temp = value; ++ ++ for (i = 0; i < 4; i++) { ++ int ret = mdiobus_write(bus, B53_PSEUDO_PHY, REG_MII_DATA0 + i, ++ temp & 0xffff); ++ if (ret) ++ return ret; ++ temp >>= 16; ++ } ++ ++ return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); ++} ++ ++static struct b53_io_ops b53_mdio_ops = { ++ .read8 = b53_mdio_read8, ++ .read16 = b53_mdio_read16, ++ .read32 = b53_mdio_read32, ++ .read48 = b53_mdio_read48, ++ .read64 = b53_mdio_read64, ++ .write8 = b53_mdio_write8, ++ .write16 = b53_mdio_write16, ++ .write32 = b53_mdio_write32, ++ .write48 = b53_mdio_write48, ++ .write64 = b53_mdio_write64, ++}; ++ ++static int b53_phy_probe(struct phy_device *phydev) ++{ ++ struct b53_device dev; ++ int ret; ++ ++ /* allow the generic phy driver to take over */ ++ if (phydev->mdio.addr != B53_PSEUDO_PHY && phydev->mdio.addr != 0) ++ return -ENODEV; ++ ++ dev.current_page = 0xff; ++ dev.priv = phydev->mdio.bus; ++ dev.ops = &b53_mdio_ops; ++ dev.pdata = NULL; ++ mutex_init(&dev.reg_mutex); ++ ++ ret = b53_switch_detect(&dev); ++ if (ret) ++ return ret; ++ ++ if (is5325(&dev) || is5365(&dev)) ++ phydev->supported = SUPPORTED_100baseT_Full; ++ else ++ phydev->supported = SUPPORTED_1000baseT_Full; ++ ++ phydev->advertising = phydev->supported; ++ ++ return 0; ++} ++ ++static int b53_phy_config_init(struct phy_device *phydev) ++{ ++ struct b53_device *dev; ++ int ret; ++ ++ dev = b53_switch_alloc(&phydev->mdio.dev, &b53_mdio_ops, phydev->mdio.bus); ++ if (!dev) ++ return -ENOMEM; ++ ++ /* we don't use page 0xff, so force a page set */ ++ dev->current_page = 0xff; ++ /* force the ethX as alias */ ++ dev->sw_dev.alias = phydev->attached_dev->name; ++ ++ ret = b53_switch_register(dev); ++ if (ret) { ++ dev_err(dev->dev, "failed to register switch: %i\n", ret); ++ return ret; ++ } ++ ++ phydev->priv = dev; ++ ++ return 0; ++} ++ ++static void b53_phy_remove(struct phy_device *phydev) ++{ ++ struct b53_device *priv = phydev->priv; ++ ++ if (!priv) ++ return; ++ ++ b53_switch_remove(priv); ++ ++ phydev->priv = NULL; ++} ++ ++static int b53_phy_config_aneg(struct phy_device *phydev) ++{ ++ return 0; ++} ++ ++static int b53_phy_read_status(struct phy_device *phydev) ++{ ++ struct b53_device *priv = phydev->priv; ++ ++ if (is5325(priv) || is5365(priv)) ++ phydev->speed = 100; ++ else ++ phydev->speed = 1000; ++ ++ phydev->duplex = DUPLEX_FULL; ++ phydev->link = 1; ++ phydev->state = PHY_RUNNING; ++ ++ netif_carrier_on(phydev->attached_dev); ++ phydev->adjust_link(phydev->attached_dev); ++ ++ return 0; ++} ++ ++static struct phy_driver b53_phy_drivers[] = { ++ { /* BCM5325, BCM539x */ ++ .name = "Broadcom B53 (1)", ++ .phy_id = 0x0143bc00, ++ .phy_id_mask = 0x1ffffc00, ++ .features = 0, ++ .probe = b53_phy_probe, ++ .remove = b53_phy_remove, ++ .config_aneg = b53_phy_config_aneg, ++ .config_init = b53_phy_config_init, ++ .read_status = b53_phy_read_status, ++ }, ++ { /* BCM53125, BCM53128 */ ++ .name = "Broadcom B53 (2)", ++ .phy_id = 0x03625c00, ++ .phy_id_mask = 0x1ffffc00, ++ .features = 0, ++ .probe = b53_phy_probe, ++ .remove = b53_phy_remove, ++ .config_aneg = b53_phy_config_aneg, ++ .config_init = b53_phy_config_init, ++ .read_status = b53_phy_read_status, ++ }, ++ { /* BCM5365 */ ++ .name = "Broadcom B53 (3)", ++ .phy_id = 0x00406000, ++ .phy_id_mask = 0x1ffffc00, ++ .features = 0, ++ .probe = b53_phy_probe, ++ .remove = b53_phy_remove, ++ .config_aneg = b53_phy_config_aneg, ++ .config_init = b53_phy_config_init, ++ .read_status = b53_phy_read_status, ++ } ++}; ++ ++int __init b53_phy_driver_register(void) ++{ ++ return phy_drivers_register(b53_phy_drivers, ++ ARRAY_SIZE(b53_phy_drivers), THIS_MODULE); ++} ++ ++void __exit b53_phy_driver_unregister(void) ++{ ++ phy_drivers_unregister(b53_phy_drivers, ++ ARRAY_SIZE(b53_phy_drivers)); ++} ++ ++module_init(b53_phy_driver_register); ++module_exit(b53_phy_driver_unregister); ++ ++MODULE_DESCRIPTION("B53 MDIO access driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff --git a/drivers/net/phy/b53/b53_mmap.c b/drivers/net/phy/b53/b53_mmap.c +new file mode 100755 +index 0000000..ab1895e +--- /dev/null ++++ b/drivers/net/phy/b53/b53_mmap.c +@@ -0,0 +1,241 @@ ++/* ++ * B53 register access through memory mapped registers ++ * ++ * Copyright (C) 2012-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include "b53_priv.h" ++ ++static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ *val = readb(regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ if (WARN_ON(reg % 2)) ++ return -EINVAL; ++ ++ if (dev->pdata && dev->pdata->big_endian) ++ *val = be16_to_cpu(readw(regs + (page << 8) + reg)); ++ else ++ *val = readw(regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ if (WARN_ON(reg % 4)) ++ return -EINVAL; ++ ++ if (dev->pdata && dev->pdata->big_endian) ++ *val = be16_to_cpu(readl(regs + (page << 8) + reg)); ++ else ++ *val = readl(regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ if (WARN_ON(reg % 2)) ++ return -EINVAL; ++ ++ if (reg % 4) { ++ u16 lo; ++ u32 hi; ++ ++ b53_mmap_read16(dev, page, reg, &lo); ++ b53_mmap_read32(dev, page, reg + 2, &hi); ++ ++ *val = ((u64)hi << 16) | lo; ++ } else { ++ u32 lo; ++ u16 hi; ++ ++ b53_mmap_read32(dev, page, reg, &lo); ++ b53_mmap_read16(dev, page, reg + 4, &hi); ++ ++ *val = ((u64)hi << 32) | lo; ++ } ++ ++ return 0; ++} ++ ++static int b53_mmap_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ u32 hi, lo; ++ ++ if (WARN_ON(reg % 4)) ++ return -EINVAL; ++ ++ b53_mmap_read32(dev, page, reg, &lo); ++ b53_mmap_read32(dev, page, reg + 4, &hi); ++ ++ *val = ((u64)hi << 32) | lo; ++ ++ return 0; ++} ++ ++static int b53_mmap_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ writeb(value, regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg, ++ u16 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ if (WARN_ON(reg % 2)) ++ return -EINVAL; ++ ++ if (dev->pdata && dev->pdata->big_endian) ++ writew(cpu_to_be16((value)), regs + (page << 8) + reg); ++ else ++ writew(value, regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg, ++ u32 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ ++ if (WARN_ON(reg % 4)) ++ return -EINVAL; ++ ++ if (dev->pdata && dev->pdata->big_endian) ++ writel(cpu_to_be32((value)), regs + (page << 8) + reg); ++ else ++ writel(value, regs + (page << 8) + reg); ++ ++ return 0; ++} ++ ++static int b53_mmap_write48(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ if (WARN_ON(reg % 2)) ++ return -EINVAL; ++ ++ if (reg % 4) { ++ u32 hi = (u32)(value >> 16); ++ u16 lo = (u16)value; ++ ++ b53_mmap_write16(dev, page, reg, lo); ++ b53_mmap_write32(dev, page, reg + 2, hi); ++ } else { ++ u16 hi = (u16)(value >> 32); ++ u32 lo = (u32)value; ++ ++ b53_mmap_write32(dev, page, reg, lo); ++ b53_mmap_write16(dev, page, reg + 4, hi); ++ } ++ ++ return 0; ++} ++ ++static int b53_mmap_write64(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ u32 hi, lo; ++ ++ hi = (u32)(value >> 32); ++ lo = (u32)value; ++ ++ if (WARN_ON(reg % 4)) ++ return -EINVAL; ++ ++ b53_mmap_write32(dev, page, reg, lo); ++ b53_mmap_write32(dev, page, reg + 4, hi); ++ ++ return 0; ++} ++ ++static struct b53_io_ops b53_mmap_ops = { ++ .read8 = b53_mmap_read8, ++ .read16 = b53_mmap_read16, ++ .read32 = b53_mmap_read32, ++ .read48 = b53_mmap_read48, ++ .read64 = b53_mmap_read64, ++ .write8 = b53_mmap_write8, ++ .write16 = b53_mmap_write16, ++ .write32 = b53_mmap_write32, ++ .write48 = b53_mmap_write48, ++ .write64 = b53_mmap_write64, ++}; ++ ++static int b53_mmap_probe(struct platform_device *pdev) ++{ ++ struct b53_platform_data *pdata = pdev->dev.platform_data; ++ struct b53_device *dev; ++ ++ if (!pdata) ++ return -EINVAL; ++ ++ dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, pdata->regs); ++ if (!dev) ++ return -ENOMEM; ++ ++ if (pdata) ++ dev->pdata = pdata; ++ ++ platform_set_drvdata(pdev, dev); ++ ++ return b53_switch_register(dev); ++} ++ ++static int b53_mmap_remove(struct platform_device *pdev) ++{ ++ struct b53_device *dev = platform_get_drvdata(pdev); ++ ++ if (dev) ++ b53_switch_remove(dev); ++ ++ return 0; ++} ++ ++static struct platform_driver b53_mmap_driver = { ++ .probe = b53_mmap_probe, ++ .remove = b53_mmap_remove, ++ .driver = { ++ .name = "b53-switch", ++ }, ++}; ++ ++module_platform_driver(b53_mmap_driver); ++MODULE_AUTHOR("Jonas Gorski "); ++MODULE_DESCRIPTION("B53 MMAP access driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff --git a/drivers/net/phy/b53/b53_phy_fixup.c b/drivers/net/phy/b53/b53_phy_fixup.c +new file mode 100755 +index 0000000..72d1373 +--- /dev/null ++++ b/drivers/net/phy/b53/b53_phy_fixup.c +@@ -0,0 +1,55 @@ ++/* ++ * B53 PHY Fixup call ++ * ++ * Copyright (C) 2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++ ++#define B53_PSEUDO_PHY 0x1e /* Register Access Pseudo PHY */ ++ ++#define B53_BRCM_OUI_1 0x0143bc00 ++#define B53_BRCM_OUI_2 0x03625c00 ++#define B53_BRCM_OUI_3 0x00406000 ++ ++static int b53_phy_fixup(struct phy_device *dev) ++{ ++ u32 phy_id; ++ struct mii_bus *bus = dev->mdio.bus; ++ ++ if (dev->mdio.addr != B53_PSEUDO_PHY) ++ return 0; ++ ++ /* read the first port's id */ ++ phy_id = mdiobus_read(bus, 0, 2) << 16; ++ phy_id |= mdiobus_read(bus, 0, 3); ++ ++ if ((phy_id & 0xfffffc00) == B53_BRCM_OUI_1 || ++ (phy_id & 0xfffffc00) == B53_BRCM_OUI_2 || ++ (phy_id & 0xfffffc00) == B53_BRCM_OUI_3) { ++ dev->phy_id = phy_id; ++ } ++ ++ return 0; ++} ++ ++int __init b53_phy_fixup_register(void) ++{ ++ return phy_register_fixup_for_id(PHY_ANY_ID, b53_phy_fixup); ++} ++ ++subsys_initcall(b53_phy_fixup_register); +diff --git a/drivers/net/phy/b53/b53_priv.h b/drivers/net/phy/b53/b53_priv.h +new file mode 100755 +index 0000000..4336fdb +--- /dev/null ++++ b/drivers/net/phy/b53/b53_priv.h +@@ -0,0 +1,324 @@ ++/* ++ * B53 common definitions ++ * ++ * Copyright (C) 2011-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#ifndef __B53_PRIV_H ++#define __B53_PRIV_H ++ ++#include ++#include ++#include ++ ++struct b53_device; ++ ++struct b53_io_ops { ++ int (*read8)(struct b53_device *dev, u8 page, u8 reg, u8 *value); ++ int (*read16)(struct b53_device *dev, u8 page, u8 reg, u16 *value); ++ int (*read32)(struct b53_device *dev, u8 page, u8 reg, u32 *value); ++ int (*read48)(struct b53_device *dev, u8 page, u8 reg, u64 *value); ++ int (*read64)(struct b53_device *dev, u8 page, u8 reg, u64 *value); ++ int (*write8)(struct b53_device *dev, u8 page, u8 reg, u8 value); ++ int (*write16)(struct b53_device *dev, u8 page, u8 reg, u16 value); ++ int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value); ++ int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value); ++ int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value); ++}; ++ ++enum { ++ BCM5325_DEVICE_ID = 0x25, ++ BCM5365_DEVICE_ID = 0x65, ++ BCM5395_DEVICE_ID = 0x95, ++ BCM5397_DEVICE_ID = 0x97, ++ BCM5398_DEVICE_ID = 0x98, ++ BCM53115_DEVICE_ID = 0x53115, ++ BCM53125_DEVICE_ID = 0x53125, ++ BCM53128_DEVICE_ID = 0x53128, ++ BCM63XX_DEVICE_ID = 0x6300, ++ BCM53010_DEVICE_ID = 0x53010, ++ BCM53011_DEVICE_ID = 0x53011, ++ BCM53012_DEVICE_ID = 0x53012, ++ BCM53018_DEVICE_ID = 0x53018, ++ BCM53019_DEVICE_ID = 0x53019, ++}; ++ ++#define B53_N_PORTS 9 ++#define B53_N_PORTS_25 6 ++ ++struct b53_vlan { ++ unsigned int members:B53_N_PORTS; ++ unsigned int untag:B53_N_PORTS; ++}; ++ ++struct b53_port { ++ unsigned int pvid:12; ++}; ++ ++struct b53_device { ++ struct switch_dev sw_dev; ++ struct b53_platform_data *pdata; ++ ++ struct mutex reg_mutex; ++ const struct b53_io_ops *ops; ++ ++ /* chip specific data */ ++ u32 chip_id; ++ u8 core_rev; ++ u8 vta_regs[3]; ++ u8 duplex_reg; ++ u8 jumbo_pm_reg; ++ u8 jumbo_size_reg; ++ int reset_gpio; ++ ++ /* used ports mask */ ++ u16 enabled_ports; ++ ++ /* connect specific data */ ++ u8 current_page; ++ struct device *dev; ++ void *priv; ++ ++ /* run time configuration */ ++ unsigned enable_vlan:1; ++ unsigned enable_jumbo:1; ++ unsigned allow_vid_4095:1; ++ ++ struct b53_port *ports; ++ struct b53_vlan *vlans; ++ ++ char *buf; ++}; ++ ++#define b53_for_each_port(dev, i) \ ++ for (i = 0; i < B53_N_PORTS; i++) \ ++ if (dev->enabled_ports & BIT(i)) ++ ++ ++ ++static inline int is5325(struct b53_device *dev) ++{ ++ return dev->chip_id == BCM5325_DEVICE_ID; ++} ++ ++static inline int is5365(struct b53_device *dev) ++{ ++#ifdef CONFIG_BCM47XX ++ return dev->chip_id == BCM5365_DEVICE_ID; ++#else ++ return 0; ++#endif ++} ++ ++static inline int is5397_98(struct b53_device *dev) ++{ ++ return dev->chip_id == BCM5397_DEVICE_ID || ++ dev->chip_id == BCM5398_DEVICE_ID; ++} ++ ++static inline int is539x(struct b53_device *dev) ++{ ++ return dev->chip_id == BCM5395_DEVICE_ID || ++ dev->chip_id == BCM5397_DEVICE_ID || ++ dev->chip_id == BCM5398_DEVICE_ID; ++} ++ ++static inline int is531x5(struct b53_device *dev) ++{ ++ return dev->chip_id == BCM53115_DEVICE_ID || ++ dev->chip_id == BCM53125_DEVICE_ID || ++ dev->chip_id == BCM53128_DEVICE_ID; ++} ++ ++static inline int is63xx(struct b53_device *dev) ++{ ++#ifdef CONFIG_BCM63XX ++ return dev->chip_id == BCM63XX_DEVICE_ID; ++#else ++ return 0; ++#endif ++} ++ ++static inline int is5301x(struct b53_device *dev) ++{ ++ return dev->chip_id == BCM53010_DEVICE_ID || ++ dev->chip_id == BCM53011_DEVICE_ID || ++ dev->chip_id == BCM53012_DEVICE_ID || ++ dev->chip_id == BCM53018_DEVICE_ID || ++ dev->chip_id == BCM53019_DEVICE_ID; ++} ++ ++#define B53_CPU_PORT_25 5 ++#define B53_CPU_PORT 8 ++ ++static inline int is_cpu_port(struct b53_device *dev, int port) ++{ ++ return dev->sw_dev.cpu_port == port; ++} ++ ++static inline struct b53_device *sw_to_b53(struct switch_dev *sw) ++{ ++ return container_of(sw, struct b53_device, sw_dev); ++} ++ ++struct b53_device *b53_switch_alloc(struct device *base, struct b53_io_ops *ops, ++ void *priv); ++ ++int b53_switch_detect(struct b53_device *dev); ++ ++int b53_switch_register(struct b53_device *dev); ++ ++static inline void b53_switch_remove(struct b53_device *dev) ++{ ++ unregister_switch(&dev->sw_dev); ++} ++ ++static inline int b53_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->read8(dev, page, reg, val); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->read16(dev, page, reg, val); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->read32(dev, page, reg, val); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->read48(dev, page, reg, val); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->read64(dev, page, reg, val); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->write8(dev, page, reg, value); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_write16(struct b53_device *dev, u8 page, u8 reg, ++ u16 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->write16(dev, page, reg, value); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_write32(struct b53_device *dev, u8 page, u8 reg, ++ u32 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->write32(dev, page, reg, value); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_write48(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->write48(dev, page, reg, value); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++static inline int b53_write64(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->reg_mutex); ++ ret = dev->ops->write64(dev, page, reg, value); ++ mutex_unlock(&dev->reg_mutex); ++ ++ return ret; ++} ++ ++#ifdef CONFIG_BCM47XX ++ ++#include ++#include ++static inline int b53_switch_get_reset_gpio(struct b53_device *dev) ++{ ++ enum bcm47xx_board board = bcm47xx_board_get(); ++ ++ switch (board) { ++ case BCM47XX_BOARD_LINKSYS_WRT300NV11: ++ case BCM47XX_BOARD_LINKSYS_WRT310NV1: ++ return 8; ++ default: ++ return bcm47xx_nvram_gpio_pin("robo_reset"); ++ } ++} ++#else ++static inline int b53_switch_get_reset_gpio(struct b53_device *dev) ++{ ++ return -ENOENT; ++} ++#endif ++#endif +diff --git a/drivers/net/phy/b53/b53_regs.h b/drivers/net/phy/b53/b53_regs.h +new file mode 100755 +index 0000000..eef5c81 +--- /dev/null ++++ b/drivers/net/phy/b53/b53_regs.h +@@ -0,0 +1,347 @@ ++/* ++ * B53 register definitions ++ * ++ * Copyright (C) 2004 Broadcom Corporation ++ * Copyright (C) 2011-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#ifndef __B53_REGS_H ++#define __B53_REGS_H ++ ++/* Management Port (SMP) Page offsets */ ++#define B53_CTRL_PAGE 0x00 /* Control */ ++#define B53_STAT_PAGE 0x01 /* Status */ ++#define B53_MGMT_PAGE 0x02 /* Management Mode */ ++#define B53_MIB_AC_PAGE 0x03 /* MIB Autocast */ ++#define B53_ARLCTRL_PAGE 0x04 /* ARL Control */ ++#define B53_ARLIO_PAGE 0x05 /* ARL Access */ ++#define B53_FRAMEBUF_PAGE 0x06 /* Management frame access */ ++#define B53_MEM_ACCESS_PAGE 0x08 /* Memory access */ ++ ++/* PHY Registers */ ++#define B53_PORT_MII_PAGE(i) (0x10 + (i)) /* Port i MII Registers */ ++#define B53_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */ ++#define B53_ALL_PORT_PAGE 0x19 /* All ports MII (broadcast) */ ++ ++/* MIB registers */ ++#define B53_MIB_PAGE(i) (0x20 + (i)) ++ ++/* Quality of Service (QoS) Registers */ ++#define B53_QOS_PAGE 0x30 ++ ++/* Port VLAN Page */ ++#define B53_PVLAN_PAGE 0x31 ++ ++/* VLAN Registers */ ++#define B53_VLAN_PAGE 0x34 ++ ++/* Jumbo Frame Registers */ ++#define B53_JUMBO_PAGE 0x40 ++ ++/* CFP Configuration Registers Page */ ++#define B53_CFP_PAGE 0xa1 ++ ++/************************************************************************* ++ * Control Page registers ++ *************************************************************************/ ++ ++/* Port Control Register (8 bit) */ ++#define B53_PORT_CTRL(i) (0x00 + (i)) ++#define PORT_CTRL_RX_DISABLE BIT(0) ++#define PORT_CTRL_TX_DISABLE BIT(1) ++#define PORT_CTRL_RX_BCST_EN BIT(2) /* Broadcast RX (P8 only) */ ++#define PORT_CTRL_RX_MCST_EN BIT(3) /* Multicast RX (P8 only) */ ++#define PORT_CTRL_RX_UCST_EN BIT(4) /* Unicast RX (P8 only) */ ++#define PORT_CTRL_STP_STATE_S 5 ++#define PORT_CTRL_STP_STATE_MASK (0x3 << PORT_CTRL_STP_STATE_S) ++ ++/* SMP Control Register (8 bit) */ ++#define B53_SMP_CTRL 0x0a ++ ++/* Switch Mode Control Register (8 bit) */ ++#define B53_SWITCH_MODE 0x0b ++#define SM_SW_FWD_MODE BIT(0) /* 1 = Managed Mode */ ++#define SM_SW_FWD_EN BIT(1) /* Forwarding Enable */ ++ ++/* IMP Port state override register (8 bit) */ ++#define B53_PORT_OVERRIDE_CTRL 0x0e ++#define PORT_OVERRIDE_LINK BIT(0) ++#define PORT_OVERRIDE_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */ ++#define PORT_OVERRIDE_SPEED_S 2 ++#define PORT_OVERRIDE_SPEED_10M (0 << PORT_OVERRIDE_SPEED_S) ++#define PORT_OVERRIDE_SPEED_100M (1 << PORT_OVERRIDE_SPEED_S) ++#define PORT_OVERRIDE_SPEED_1000M (2 << PORT_OVERRIDE_SPEED_S) ++#define PORT_OVERRIDE_RV_MII_25 BIT(4) /* BCM5325 only */ ++#define PORT_OVERRIDE_RX_FLOW BIT(4) ++#define PORT_OVERRIDE_TX_FLOW BIT(5) ++#define PORT_OVERRIDE_SPEED_2000M BIT(6) /* BCM5301X only, requires setting 1000M */ ++#define PORT_OVERRIDE_EN BIT(7) /* Use the register contents */ ++ ++/* Power-down mode control */ ++#define B53_PD_MODE_CTRL_25 0x0f ++ ++/* IP Multicast control (8 bit) */ ++#define B53_IP_MULTICAST_CTRL 0x21 ++#define B53_IPMC_FWD_EN BIT(1) ++#define B53_UC_FWD_EN BIT(6) ++#define B53_MC_FWD_EN BIT(7) ++ ++/* (16 bit) */ ++#define B53_UC_FLOOD_MASK 0x32 ++#define B53_MC_FLOOD_MASK 0x34 ++#define B53_IPMC_FLOOD_MASK 0x36 ++ ++/* ++ * Override Ports 0-7 State on devices with xMII interfaces (8 bit) ++ * ++ * For port 8 still use B53_PORT_OVERRIDE_CTRL ++ * Please note that not all ports are available on every hardware, e.g. BCM5301X ++ * don't include overriding port 6, BCM63xx also have some limitations. ++ */ ++#define B53_GMII_PORT_OVERRIDE_CTRL(i) (0x58 + (i)) ++#define GMII_PO_LINK BIT(0) ++#define GMII_PO_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */ ++#define GMII_PO_SPEED_S 2 ++#define GMII_PO_SPEED_10M (0 << GMII_PO_SPEED_S) ++#define GMII_PO_SPEED_100M (1 << GMII_PO_SPEED_S) ++#define GMII_PO_SPEED_1000M (2 << GMII_PO_SPEED_S) ++#define GMII_PO_RX_FLOW BIT(4) ++#define GMII_PO_TX_FLOW BIT(5) ++#define GMII_PO_EN BIT(6) /* Use the register contents */ ++#define GMII_PO_SPEED_2000M BIT(7) /* BCM5301X only, requires setting 1000M */ ++ ++/* Software reset register (8 bit) */ ++#define B53_SOFTRESET 0x79 ++ ++/* Fast Aging Control register (8 bit) */ ++#define B53_FAST_AGE_CTRL 0x88 ++#define FAST_AGE_STATIC BIT(0) ++#define FAST_AGE_DYNAMIC BIT(1) ++#define FAST_AGE_PORT BIT(2) ++#define FAST_AGE_VLAN BIT(3) ++#define FAST_AGE_STP BIT(4) ++#define FAST_AGE_MC BIT(5) ++#define FAST_AGE_DONE BIT(7) ++ ++/************************************************************************* ++ * Status Page registers ++ *************************************************************************/ ++ ++/* Link Status Summary Register (16bit) */ ++#define B53_LINK_STAT 0x00 ++ ++/* Link Status Change Register (16 bit) */ ++#define B53_LINK_STAT_CHANGE 0x02 ++ ++/* Port Speed Summary Register (16 bit for FE, 32 bit for GE) */ ++#define B53_SPEED_STAT 0x04 ++#define SPEED_PORT_FE(reg, port) (((reg) >> (port)) & 1) ++#define SPEED_PORT_GE(reg, port) (((reg) >> 2 * (port)) & 3) ++#define SPEED_STAT_10M 0 ++#define SPEED_STAT_100M 1 ++#define SPEED_STAT_1000M 2 ++ ++/* Duplex Status Summary (16 bit) */ ++#define B53_DUPLEX_STAT_FE 0x06 ++#define B53_DUPLEX_STAT_GE 0x08 ++#define B53_DUPLEX_STAT_63XX 0x0c ++ ++/* Revision ID register for BCM5325 */ ++#define B53_REV_ID_25 0x50 ++ ++/* Strap Value (48 bit) */ ++#define B53_STRAP_VALUE 0x70 ++#define SV_GMII_CTRL_115 BIT(27) ++ ++/************************************************************************* ++ * Management Mode Page Registers ++ *************************************************************************/ ++ ++/* Global Management Config Register (8 bit) */ ++#define B53_GLOBAL_CONFIG 0x00 ++#define GC_RESET_MIB 0x01 ++#define GC_RX_BPDU_EN 0x02 ++#define GC_MIB_AC_HDR_EN 0x10 ++#define GC_MIB_AC_EN 0x20 ++#define GC_FRM_MGMT_PORT_M 0xC0 ++#define GC_FRM_MGMT_PORT_04 0x00 ++#define GC_FRM_MGMT_PORT_MII 0x80 ++ ++/* Broadcom Header control register (8 bit) */ ++#define B53_BRCM_HDR 0x03 ++#define BRCM_HDR_EN BIT(0) /* Enable tagging on IMP port */ ++ ++/* Device ID register (8 or 32 bit) */ ++#define B53_DEVICE_ID 0x30 ++ ++/* Revision ID register (8 bit) */ ++#define B53_REV_ID 0x40 ++ ++/************************************************************************* ++ * ARL Access Page Registers ++ *************************************************************************/ ++ ++/* VLAN Table Access Register (8 bit) */ ++#define B53_VT_ACCESS 0x80 ++#define B53_VT_ACCESS_9798 0x60 /* for BCM5397/BCM5398 */ ++#define B53_VT_ACCESS_63XX 0x60 /* for BCM6328/62/68 */ ++#define VTA_CMD_WRITE 0 ++#define VTA_CMD_READ 1 ++#define VTA_CMD_CLEAR 2 ++#define VTA_START_CMD BIT(7) ++ ++/* VLAN Table Index Register (16 bit) */ ++#define B53_VT_INDEX 0x81 ++#define B53_VT_INDEX_9798 0x61 ++#define B53_VT_INDEX_63XX 0x62 ++ ++/* VLAN Table Entry Register (32 bit) */ ++#define B53_VT_ENTRY 0x83 ++#define B53_VT_ENTRY_9798 0x63 ++#define B53_VT_ENTRY_63XX 0x64 ++#define VTE_MEMBERS 0x1ff ++#define VTE_UNTAG_S 9 ++#define VTE_UNTAG (0x1ff << 9) ++ ++/************************************************************************* ++ * Port VLAN Registers ++ *************************************************************************/ ++ ++/* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */ ++#define B53_PVLAN_PORT_MASK(i) ((i) * 2) ++ ++/************************************************************************* ++ * 802.1Q Page Registers ++ *************************************************************************/ ++ ++/* Global QoS Control (8 bit) */ ++#define B53_QOS_GLOBAL_CTL 0x00 ++ ++/* Enable 802.1Q for individual Ports (16 bit) */ ++#define B53_802_1P_EN 0x04 ++ ++/************************************************************************* ++ * VLAN Page Registers ++ *************************************************************************/ ++ ++/* VLAN Control 0 (8 bit) */ ++#define B53_VLAN_CTRL0 0x00 ++#define VC0_8021PF_CTRL_MASK 0x3 ++#define VC0_8021PF_CTRL_NONE 0x0 ++#define VC0_8021PF_CTRL_CHANGE_PRI 0x1 ++#define VC0_8021PF_CTRL_CHANGE_VID 0x2 ++#define VC0_8021PF_CTRL_CHANGE_BOTH 0x3 ++#define VC0_8021QF_CTRL_MASK 0xc ++#define VC0_8021QF_CTRL_CHANGE_PRI 0x1 ++#define VC0_8021QF_CTRL_CHANGE_VID 0x2 ++#define VC0_8021QF_CTRL_CHANGE_BOTH 0x3 ++#define VC0_RESERVED_1 BIT(1) ++#define VC0_DROP_VID_MISS BIT(4) ++#define VC0_VID_HASH_VID BIT(5) ++#define VC0_VID_CHK_EN BIT(6) /* Use VID,DA or VID,SA */ ++#define VC0_VLAN_EN BIT(7) /* 802.1Q VLAN Enabled */ ++ ++/* VLAN Control 1 (8 bit) */ ++#define B53_VLAN_CTRL1 0x01 ++#define VC1_RX_MCST_TAG_EN BIT(1) ++#define VC1_RX_MCST_FWD_EN BIT(2) ++#define VC1_RX_MCST_UNTAG_EN BIT(3) ++ ++/* VLAN Control 2 (8 bit) */ ++#define B53_VLAN_CTRL2 0x02 ++ ++/* VLAN Control 3 (8 bit when BCM5325, 16 bit else) */ ++#define B53_VLAN_CTRL3 0x03 ++#define B53_VLAN_CTRL3_63XX 0x04 ++#define VC3_MAXSIZE_1532 BIT(6) /* 5325 only */ ++#define VC3_HIGH_8BIT_EN BIT(7) /* 5325 only */ ++ ++/* VLAN Control 4 (8 bit) */ ++#define B53_VLAN_CTRL4 0x05 ++#define B53_VLAN_CTRL4_25 0x04 ++#define B53_VLAN_CTRL4_63XX 0x06 ++#define VC4_ING_VID_CHECK_S 6 ++#define VC4_ING_VID_CHECK_MASK (0x3 << VC4_ING_VID_CHECK_S) ++#define VC4_ING_VID_VIO_FWD 0 /* forward, but do not learn */ ++#define VC4_ING_VID_VIO_DROP 1 /* drop VID violations */ ++#define VC4_NO_ING_VID_CHK 2 /* do not check */ ++#define VC4_ING_VID_VIO_TO_IMP 3 /* redirect to MII port */ ++ ++/* VLAN Control 5 (8 bit) */ ++#define B53_VLAN_CTRL5 0x06 ++#define B53_VLAN_CTRL5_25 0x05 ++#define B53_VLAN_CTRL5_63XX 0x07 ++#define VC5_VID_FFF_EN BIT(2) ++#define VC5_DROP_VTABLE_MISS BIT(3) ++ ++/* VLAN Control 6 (8 bit) */ ++#define B53_VLAN_CTRL6 0x07 ++#define B53_VLAN_CTRL6_63XX 0x08 ++ ++/* VLAN Table Access Register (16 bit) */ ++#define B53_VLAN_TABLE_ACCESS_25 0x06 /* BCM5325E/5350 */ ++#define B53_VLAN_TABLE_ACCESS_65 0x08 /* BCM5365 */ ++#define VTA_VID_LOW_MASK_25 0xf ++#define VTA_VID_LOW_MASK_65 0xff ++#define VTA_VID_HIGH_S_25 4 ++#define VTA_VID_HIGH_S_65 8 ++#define VTA_VID_HIGH_MASK_25 (0xff << VTA_VID_HIGH_S_25E) ++#define VTA_VID_HIGH_MASK_65 (0xf << VTA_VID_HIGH_S_65) ++#define VTA_RW_STATE BIT(12) ++#define VTA_RW_STATE_RD 0 ++#define VTA_RW_STATE_WR BIT(12) ++#define VTA_RW_OP_EN BIT(13) ++ ++/* VLAN Read/Write Registers for (16/32 bit) */ ++#define B53_VLAN_WRITE_25 0x08 ++#define B53_VLAN_WRITE_65 0x0a ++#define B53_VLAN_READ 0x0c ++#define VA_MEMBER_MASK 0x3f ++#define VA_UNTAG_S_25 6 ++#define VA_UNTAG_MASK_25 0x3f ++#define VA_UNTAG_S_65 7 ++#define VA_UNTAG_MASK_65 0x1f ++#define VA_VID_HIGH_S 12 ++#define VA_VID_HIGH_MASK (0xffff << VA_VID_HIGH_S) ++#define VA_VALID_25 BIT(20) ++#define VA_VALID_25_R4 BIT(24) ++#define VA_VALID_65 BIT(14) ++ ++/* VLAN Port Default Tag (16 bit) */ ++#define B53_VLAN_PORT_DEF_TAG(i) (0x10 + 2 * (i)) ++ ++/************************************************************************* ++ * Jumbo Frame Page Registers ++ *************************************************************************/ ++ ++/* Jumbo Enable Port Mask (bit i == port i enabled) (32 bit) */ ++#define B53_JUMBO_PORT_MASK 0x01 ++#define B53_JUMBO_PORT_MASK_63XX 0x04 ++#define JPM_10_100_JUMBO_EN BIT(24) /* GigE always enabled */ ++ ++/* Good Frame Max Size without 802.1Q TAG (16 bit) */ ++#define B53_JUMBO_MAX_SIZE 0x05 ++#define B53_JUMBO_MAX_SIZE_63XX 0x08 ++#define JMS_MIN_SIZE 1518 ++#define JMS_MAX_SIZE 9724 ++ ++/************************************************************************* ++ * CFP Configuration Page Registers ++ *************************************************************************/ ++ ++/* CFP Control Register with ports map (8 bit) */ ++#define B53_CFP_CTRL 0x00 ++ ++#endif /* !__B53_REGS_H */ +diff --git a/drivers/net/phy/b53/b53_spi.c b/drivers/net/phy/b53/b53_spi.c +new file mode 100755 +index 0000000..469a8dd +--- /dev/null ++++ b/drivers/net/phy/b53/b53_spi.c +@@ -0,0 +1,330 @@ ++/* ++ * B53 register access through SPI ++ * ++ * Copyright (C) 2011-2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++ ++#include ++#include ++#include ++#include ++ ++#include "b53_priv.h" ++ ++#define B53_SPI_DATA 0xf0 ++ ++#define B53_SPI_STATUS 0xfe ++#define B53_SPI_CMD_SPIF BIT(7) ++#define B53_SPI_CMD_RACK BIT(5) ++ ++#define B53_SPI_CMD_READ 0x00 ++#define B53_SPI_CMD_WRITE 0x01 ++#define B53_SPI_CMD_NORMAL 0x60 ++#define B53_SPI_CMD_FAST 0x10 ++ ++#define B53_SPI_PAGE_SELECT 0xff ++ ++static inline int b53_spi_read_reg(struct spi_device *spi, u8 reg, u8 *val, ++ unsigned len) ++{ ++ u8 txbuf[2]; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_READ; ++ txbuf[1] = reg; ++ ++ return spi_write_then_read(spi, txbuf, 2, val, len); ++} ++ ++static inline int b53_spi_clear_status(struct spi_device *spi) ++{ ++ unsigned int i; ++ u8 rxbuf; ++ int ret; ++ ++ for (i = 0; i < 10; i++) { ++ ret = b53_spi_read_reg(spi, B53_SPI_STATUS, &rxbuf, 1); ++ if (ret) ++ return ret; ++ ++ if (!(rxbuf & B53_SPI_CMD_SPIF)) ++ break; ++ ++ mdelay(1); ++ } ++ ++ if (i == 10) ++ return -EIO; ++ ++ return 0; ++} ++ ++static inline int b53_spi_set_page(struct spi_device *spi, u8 page) ++{ ++ u8 txbuf[3]; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = B53_SPI_PAGE_SELECT; ++ txbuf[2] = page; ++ ++ return spi_write(spi, txbuf, sizeof(txbuf)); ++} ++ ++static inline int b53_prepare_reg_access(struct spi_device *spi, u8 page) ++{ ++ int ret = b53_spi_clear_status(spi); ++ ++ if (ret) ++ return ret; ++ ++ return b53_spi_set_page(spi, page); ++} ++ ++static int b53_spi_prepare_reg_read(struct spi_device *spi, u8 reg) ++{ ++ u8 rxbuf; ++ int retry_count; ++ int ret; ++ ++ ret = b53_spi_read_reg(spi, reg, &rxbuf, 1); ++ if (ret) ++ return ret; ++ ++ for (retry_count = 0; retry_count < 10; retry_count++) { ++ ret = b53_spi_read_reg(spi, B53_SPI_STATUS, &rxbuf, 1); ++ if (ret) ++ return ret; ++ ++ if (rxbuf & B53_SPI_CMD_RACK) ++ break; ++ ++ mdelay(1); ++ } ++ ++ if (retry_count == 10) ++ return -EIO; ++ ++ return 0; ++} ++ ++static int b53_spi_read(struct b53_device *dev, u8 page, u8 reg, u8 *data, ++ unsigned len) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ ret = b53_spi_prepare_reg_read(spi, reg); ++ if (ret) ++ return ret; ++ ++ return b53_spi_read_reg(spi, B53_SPI_DATA, data, len); ++} ++ ++static int b53_spi_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) ++{ ++ return b53_spi_read(dev, page, reg, val, 1); ++} ++ ++static int b53_spi_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ++{ ++ int ret = b53_spi_read(dev, page, reg, (u8 *)val, 2); ++ ++ if (!ret) ++ *val = le16_to_cpu(*val); ++ ++ return ret; ++} ++ ++static int b53_spi_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ++{ ++ int ret = b53_spi_read(dev, page, reg, (u8 *)val, 4); ++ ++ if (!ret) ++ *val = le32_to_cpu(*val); ++ ++ return ret; ++} ++ ++static int b53_spi_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ int ret; ++ ++ *val = 0; ++ ret = b53_spi_read(dev, page, reg, (u8 *)val, 6); ++ if (!ret) ++ *val = le64_to_cpu(*val); ++ ++ return ret; ++} ++ ++static int b53_spi_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ int ret = b53_spi_read(dev, page, reg, (u8 *)val, 8); ++ ++ if (!ret) ++ *val = le64_to_cpu(*val); ++ ++ return ret; ++} ++ ++static int b53_spi_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ u8 txbuf[3]; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = reg; ++ txbuf[2] = value; ++ ++ return spi_write(spi, txbuf, sizeof(txbuf)); ++} ++ ++static int b53_spi_write16(struct b53_device *dev, u8 page, u8 reg, u16 value) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ u8 txbuf[4]; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = reg; ++ put_unaligned_le16(value, &txbuf[2]); ++ ++ return spi_write(spi, txbuf, sizeof(txbuf)); ++} ++ ++static int b53_spi_write32(struct b53_device *dev, u8 page, u8 reg, u32 value) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ u8 txbuf[6]; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = reg; ++ put_unaligned_le32(value, &txbuf[2]); ++ ++ return spi_write(spi, txbuf, sizeof(txbuf)); ++} ++ ++static int b53_spi_write48(struct b53_device *dev, u8 page, u8 reg, u64 value) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ u8 txbuf[10]; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = reg; ++ put_unaligned_le64(value, &txbuf[2]); ++ ++ return spi_write(spi, txbuf, sizeof(txbuf) - 2); ++} ++ ++static int b53_spi_write64(struct b53_device *dev, u8 page, u8 reg, u64 value) ++{ ++ struct spi_device *spi = dev->priv; ++ int ret; ++ u8 txbuf[10]; ++ ++ ret = b53_prepare_reg_access(spi, page); ++ if (ret) ++ return ret; ++ ++ txbuf[0] = B53_SPI_CMD_NORMAL | B53_SPI_CMD_WRITE; ++ txbuf[1] = reg; ++ put_unaligned_le64(value, &txbuf[2]); ++ ++ return spi_write(spi, txbuf, sizeof(txbuf)); ++} ++ ++static struct b53_io_ops b53_spi_ops = { ++ .read8 = b53_spi_read8, ++ .read16 = b53_spi_read16, ++ .read32 = b53_spi_read32, ++ .read48 = b53_spi_read48, ++ .read64 = b53_spi_read64, ++ .write8 = b53_spi_write8, ++ .write16 = b53_spi_write16, ++ .write32 = b53_spi_write32, ++ .write48 = b53_spi_write48, ++ .write64 = b53_spi_write64, ++}; ++ ++static int b53_spi_probe(struct spi_device *spi) ++{ ++ struct b53_device *dev; ++ int ret; ++ ++ dev = b53_switch_alloc(&spi->dev, &b53_spi_ops, spi); ++ if (!dev) ++ return -ENOMEM; ++ ++ if (spi->dev.platform_data) ++ dev->pdata = spi->dev.platform_data; ++ ++ ret = b53_switch_register(dev); ++ if (ret) ++ return ret; ++ ++ spi_set_drvdata(spi, dev); ++ ++ return 0; ++} ++ ++static int b53_spi_remove(struct spi_device *spi) ++{ ++ struct b53_device *dev = spi_get_drvdata(spi); ++ ++ if (dev) ++ b53_switch_remove(dev); ++ ++ return 0; ++} ++ ++static struct spi_driver b53_spi_driver = { ++ .driver = { ++ .name = "b53-switch", ++ .bus = &spi_bus_type, ++ .owner = THIS_MODULE, ++ }, ++ .probe = b53_spi_probe, ++ .remove = b53_spi_remove, ++}; ++ ++module_spi_driver(b53_spi_driver); ++ ++MODULE_AUTHOR("Jonas Gorski "); ++MODULE_DESCRIPTION("B53 SPI access driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff --git a/drivers/net/phy/b53/b53_srab.c b/drivers/net/phy/b53/b53_srab.c +new file mode 100755 +index 0000000..012daa3 +--- /dev/null ++++ b/drivers/net/phy/b53/b53_srab.c +@@ -0,0 +1,378 @@ ++/* ++ * B53 register access through Switch Register Access Bridge Registers ++ * ++ * Copyright (C) 2013 Hauke Mehrtens ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include "b53_priv.h" ++ ++/* command and status register of the SRAB */ ++#define B53_SRAB_CMDSTAT 0x2c ++#define B53_SRAB_CMDSTAT_RST BIT(2) ++#define B53_SRAB_CMDSTAT_WRITE BIT(1) ++#define B53_SRAB_CMDSTAT_GORDYN BIT(0) ++#define B53_SRAB_CMDSTAT_PAGE 24 ++#define B53_SRAB_CMDSTAT_REG 16 ++ ++/* high order word of write data to switch registe */ ++#define B53_SRAB_WD_H 0x30 ++ ++/* low order word of write data to switch registe */ ++#define B53_SRAB_WD_L 0x34 ++ ++/* high order word of read data from switch register */ ++#define B53_SRAB_RD_H 0x38 ++ ++/* low order word of read data from switch register */ ++#define B53_SRAB_RD_L 0x3c ++ ++/* command and status register of the SRAB */ ++#define B53_SRAB_CTRLS 0x40 ++#define B53_SRAB_CTRLS_RCAREQ BIT(3) ++#define B53_SRAB_CTRLS_RCAGNT BIT(4) ++#define B53_SRAB_CTRLS_SW_INIT_DONE BIT(6) ++ ++/* the register captures interrupt pulses from the switch */ ++#define B53_SRAB_INTR 0x44 ++ ++static int b53_srab_request_grant(struct b53_device *dev) ++{ ++ u8 __iomem *regs = dev->priv; ++ u32 ctrls; ++ int i; ++ ++ ctrls = readl(regs + B53_SRAB_CTRLS); ++ ctrls |= B53_SRAB_CTRLS_RCAREQ; ++ writel(ctrls, regs + B53_SRAB_CTRLS); ++ ++ for (i = 0; i < 20; i++) { ++ ctrls = readl(regs + B53_SRAB_CTRLS); ++ if (ctrls & B53_SRAB_CTRLS_RCAGNT) ++ break; ++ usleep_range(10, 100); ++ } ++ if (WARN_ON(i == 5)) ++ return -EIO; ++ ++ return 0; ++} ++ ++static void b53_srab_release_grant(struct b53_device *dev) ++{ ++ u8 __iomem *regs = dev->priv; ++ u32 ctrls; ++ ++ ctrls = readl(regs + B53_SRAB_CTRLS); ++ ctrls &= ~B53_SRAB_CTRLS_RCAREQ; ++ writel(ctrls, regs + B53_SRAB_CTRLS); ++} ++ ++static int b53_srab_op(struct b53_device *dev, u8 page, u8 reg, u32 op) ++{ ++ int i; ++ u32 cmdstat; ++ u8 __iomem *regs = dev->priv; ++ ++ /* set register address */ ++ cmdstat = (page << B53_SRAB_CMDSTAT_PAGE) | ++ (reg << B53_SRAB_CMDSTAT_REG) | ++ B53_SRAB_CMDSTAT_GORDYN | ++ op; ++ writel(cmdstat, regs + B53_SRAB_CMDSTAT); ++ ++ /* check if operation completed */ ++ for (i = 0; i < 5; ++i) { ++ cmdstat = readl(regs + B53_SRAB_CMDSTAT); ++ if (!(cmdstat & B53_SRAB_CMDSTAT_GORDYN)) ++ break; ++ usleep_range(10, 100); ++ } ++ ++ if (WARN_ON(i == 5)) ++ return -EIO; ++ ++ return 0; ++} ++ ++static int b53_srab_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ ret = b53_srab_op(dev, page, reg, 0); ++ if (ret) ++ goto err; ++ ++ *val = readl(regs + B53_SRAB_RD_L) & 0xff; ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ ret = b53_srab_op(dev, page, reg, 0); ++ if (ret) ++ goto err; ++ ++ *val = readl(regs + B53_SRAB_RD_L) & 0xffff; ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ ret = b53_srab_op(dev, page, reg, 0); ++ if (ret) ++ goto err; ++ ++ *val = readl(regs + B53_SRAB_RD_L); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ ret = b53_srab_op(dev, page, reg, 0); ++ if (ret) ++ goto err; ++ ++ *val = readl(regs + B53_SRAB_RD_L); ++ *val += ((u64)readl(regs + B53_SRAB_RD_H) & 0xffff) << 32; ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ ret = b53_srab_op(dev, page, reg, 0); ++ if (ret) ++ goto err; ++ ++ *val = readl(regs + B53_SRAB_RD_L); ++ *val += (u64)readl(regs + B53_SRAB_RD_H) << 32; ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ writel(value, regs + B53_SRAB_WD_L); ++ ++ ret = b53_srab_op(dev, page, reg, B53_SRAB_CMDSTAT_WRITE); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_write16(struct b53_device *dev, u8 page, u8 reg, ++ u16 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ writel(value, regs + B53_SRAB_WD_L); ++ ++ ret = b53_srab_op(dev, page, reg, B53_SRAB_CMDSTAT_WRITE); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static int b53_srab_write32(struct b53_device *dev, u8 page, u8 reg, ++ u32 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ writel(value, regs + B53_SRAB_WD_L); ++ ++ ret = b53_srab_op(dev, page, reg, B53_SRAB_CMDSTAT_WRITE); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++ ++} ++ ++static int b53_srab_write48(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ writel((u32)value, regs + B53_SRAB_WD_L); ++ writel((u16)(value >> 32), regs + B53_SRAB_WD_H); ++ ++ ret = b53_srab_op(dev, page, reg, B53_SRAB_CMDSTAT_WRITE); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++ ++} ++ ++static int b53_srab_write64(struct b53_device *dev, u8 page, u8 reg, ++ u64 value) ++{ ++ u8 __iomem *regs = dev->priv; ++ int ret = 0; ++ ++ ret = b53_srab_request_grant(dev); ++ if (ret) ++ goto err; ++ ++ writel((u32)value, regs + B53_SRAB_WD_L); ++ writel((u32)(value >> 32), regs + B53_SRAB_WD_H); ++ ++ ret = b53_srab_op(dev, page, reg, B53_SRAB_CMDSTAT_WRITE); ++ ++err: ++ b53_srab_release_grant(dev); ++ ++ return ret; ++} ++ ++static struct b53_io_ops b53_srab_ops = { ++ .read8 = b53_srab_read8, ++ .read16 = b53_srab_read16, ++ .read32 = b53_srab_read32, ++ .read48 = b53_srab_read48, ++ .read64 = b53_srab_read64, ++ .write8 = b53_srab_write8, ++ .write16 = b53_srab_write16, ++ .write32 = b53_srab_write32, ++ .write48 = b53_srab_write48, ++ .write64 = b53_srab_write64, ++}; ++ ++static int b53_srab_probe(struct platform_device *pdev) ++{ ++ struct b53_platform_data *pdata = pdev->dev.platform_data; ++ struct b53_device *dev; ++ ++ if (!pdata) ++ return -EINVAL; ++ ++ dev = b53_switch_alloc(&pdev->dev, &b53_srab_ops, pdata->regs); ++ if (!dev) ++ return -ENOMEM; ++ ++ if (pdata) ++ dev->pdata = pdata; ++ ++ platform_set_drvdata(pdev, dev); ++ ++ return b53_switch_register(dev); ++} ++ ++static int b53_srab_remove(struct platform_device *pdev) ++{ ++ struct b53_device *dev = platform_get_drvdata(pdev); ++ ++ if (dev) ++ b53_switch_remove(dev); ++ ++ return 0; ++} ++ ++static struct platform_driver b53_srab_driver = { ++ .probe = b53_srab_probe, ++ .remove = b53_srab_remove, ++ .driver = { ++ .name = "b53-srab-switch", ++ }, ++}; ++ ++module_platform_driver(b53_srab_driver); ++MODULE_AUTHOR("Hauke Mehrtens "); ++MODULE_DESCRIPTION("B53 Switch Register Access Bridge Registers (SRAB) access driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff --git a/drivers/net/phy/swconfig.c b/drivers/net/phy/swconfig.c +new file mode 100755 +index 0000000..6bb3be1 +--- /dev/null ++++ b/drivers/net/phy/swconfig.c +@@ -0,0 +1,1153 @@ ++/* ++ * swconfig.c: Switch configuration API ++ * ++ * Copyright (C) 2008 Felix Fietkau ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define SWCONFIG_DEVNAME "switch%d" ++ ++#include "swconfig_leds.c" ++ ++MODULE_AUTHOR("Felix Fietkau "); ++MODULE_LICENSE("GPL"); ++ ++static int swdev_id; ++static struct list_head swdevs; ++static DEFINE_SPINLOCK(swdevs_lock); ++struct swconfig_callback; ++ ++struct swconfig_callback { ++ struct sk_buff *msg; ++ struct genlmsghdr *hdr; ++ struct genl_info *info; ++ int cmd; ++ ++ /* callback for filling in the message data */ ++ int (*fill)(struct swconfig_callback *cb, void *arg); ++ ++ /* callback for closing the message before sending it */ ++ int (*close)(struct swconfig_callback *cb, void *arg); ++ ++ struct nlattr *nest[4]; ++ int args[4]; ++}; ++ ++/* defaults */ ++ ++static int ++swconfig_get_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ int ret; ++ if (val->port_vlan >= dev->vlans) ++ return -EINVAL; ++ ++ if (!dev->ops->get_vlan_ports) ++ return -EOPNOTSUPP; ++ ++ ret = dev->ops->get_vlan_ports(dev, val); ++ return ret; ++} ++ ++static int ++swconfig_set_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct switch_port *ports = val->value.ports; ++ const struct switch_dev_ops *ops = dev->ops; ++ int i; ++ ++ if (val->port_vlan >= dev->vlans) ++ return -EINVAL; ++ ++ /* validate ports */ ++ if (val->len > dev->ports) ++ return -EINVAL; ++ ++ if (!ops->set_vlan_ports) ++ return -EOPNOTSUPP; ++ ++ for (i = 0; i < val->len; i++) { ++ if (ports[i].id >= dev->ports) ++ return -EINVAL; ++ ++ if (ops->set_port_pvid && ++ !(ports[i].flags & (1 << SWITCH_PORT_FLAG_TAGGED))) ++ ops->set_port_pvid(dev, ports[i].id, val->port_vlan); ++ } ++ ++ return ops->set_vlan_ports(dev, val); ++} ++ ++static int ++swconfig_set_pvid(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ if (val->port_vlan >= dev->ports) ++ return -EINVAL; ++ ++ if (!dev->ops->set_port_pvid) ++ return -EOPNOTSUPP; ++ ++ return dev->ops->set_port_pvid(dev, val->port_vlan, val->value.i); ++} ++ ++static int ++swconfig_get_pvid(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ if (val->port_vlan >= dev->ports) ++ return -EINVAL; ++ ++ if (!dev->ops->get_port_pvid) ++ return -EOPNOTSUPP; ++ ++ return dev->ops->get_port_pvid(dev, val->port_vlan, &val->value.i); ++} ++ ++static const char * ++swconfig_speed_str(enum switch_port_speed speed) ++{ ++ switch (speed) { ++ case SWITCH_PORT_SPEED_10: ++ return "10baseT"; ++ case SWITCH_PORT_SPEED_100: ++ return "100baseT"; ++ case SWITCH_PORT_SPEED_1000: ++ return "1000baseT"; ++ default: ++ break; ++ } ++ ++ return "unknown"; ++} ++ ++static int ++swconfig_get_link(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ struct switch_port_link link; ++ int len; ++ int ret; ++ ++ if (val->port_vlan >= dev->ports) ++ return -EINVAL; ++ ++ if (!dev->ops->get_port_link) ++ return -EOPNOTSUPP; ++ ++ memset(&link, 0, sizeof(link)); ++ ret = dev->ops->get_port_link(dev, val->port_vlan, &link); ++ if (ret) ++ return ret; ++ ++ memset(dev->buf, 0, sizeof(dev->buf)); ++ ++ if (link.link) ++ len = snprintf(dev->buf, sizeof(dev->buf), ++ "port:%d link:up speed:%s %s-duplex %s%s%s%s%s", ++ val->port_vlan, ++ swconfig_speed_str(link.speed), ++ link.duplex ? "full" : "half", ++ link.tx_flow ? "txflow " : "", ++ link.rx_flow ? "rxflow " : "", ++ link.eee & ADVERTISED_100baseT_Full ? "eee100 " : "", ++ link.eee & ADVERTISED_1000baseT_Full ? "eee1000 " : "", ++ link.aneg ? "auto" : ""); ++ else ++ len = snprintf(dev->buf, sizeof(dev->buf), "port:%d link:down", ++ val->port_vlan); ++ ++ val->value.s = dev->buf; ++ val->len = len; ++ ++ return 0; ++} ++ ++static int ++swconfig_apply_config(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ /* don't complain if not supported by the switch driver */ ++ if (!dev->ops->apply_config) ++ return 0; ++ ++ return dev->ops->apply_config(dev); ++} ++ ++static int ++swconfig_reset_switch(struct switch_dev *dev, const struct switch_attr *attr, ++ struct switch_val *val) ++{ ++ /* don't complain if not supported by the switch driver */ ++ if (!dev->ops->reset_switch) ++ return 0; ++ ++ return dev->ops->reset_switch(dev); ++} ++ ++enum global_defaults { ++ GLOBAL_APPLY, ++ GLOBAL_RESET, ++}; ++ ++enum vlan_defaults { ++ VLAN_PORTS, ++}; ++ ++enum port_defaults { ++ PORT_PVID, ++ PORT_LINK, ++}; ++ ++static struct switch_attr default_global[] = { ++ [GLOBAL_APPLY] = { ++ .type = SWITCH_TYPE_NOVAL, ++ .name = "apply", ++ .description = "Activate changes in the hardware", ++ .set = swconfig_apply_config, ++ }, ++ [GLOBAL_RESET] = { ++ .type = SWITCH_TYPE_NOVAL, ++ .name = "reset", ++ .description = "Reset the switch", ++ .set = swconfig_reset_switch, ++ } ++}; ++ ++static struct switch_attr default_port[] = { ++ [PORT_PVID] = { ++ .type = SWITCH_TYPE_INT, ++ .name = "pvid", ++ .description = "Primary VLAN ID", ++ .set = swconfig_set_pvid, ++ .get = swconfig_get_pvid, ++ }, ++ [PORT_LINK] = { ++ .type = SWITCH_TYPE_STRING, ++ .name = "link", ++ .description = "Get port link information", ++ .set = NULL, ++ .get = swconfig_get_link, ++ } ++}; ++ ++static struct switch_attr default_vlan[] = { ++ [VLAN_PORTS] = { ++ .type = SWITCH_TYPE_PORTS, ++ .name = "ports", ++ .description = "VLAN port mapping", ++ .set = swconfig_set_vlan_ports, ++ .get = swconfig_get_vlan_ports, ++ }, ++}; ++ ++static const struct switch_attr * ++swconfig_find_attr_by_name(const struct switch_attrlist *alist, ++ const char *name) ++{ ++ int i; ++ ++ for (i = 0; i < alist->n_attr; i++) ++ if (strcmp(name, alist->attr[i].name) == 0) ++ return &alist->attr[i]; ++ ++ return NULL; ++} ++ ++static void swconfig_defaults_init(struct switch_dev *dev) ++{ ++ const struct switch_dev_ops *ops = dev->ops; ++ ++ dev->def_global = 0; ++ dev->def_vlan = 0; ++ dev->def_port = 0; ++ ++ if (ops->get_vlan_ports || ops->set_vlan_ports) ++ set_bit(VLAN_PORTS, &dev->def_vlan); ++ ++ if (ops->get_port_pvid || ops->set_port_pvid) ++ set_bit(PORT_PVID, &dev->def_port); ++ ++ if (ops->get_port_link && ++ !swconfig_find_attr_by_name(&ops->attr_port, "link")) ++ set_bit(PORT_LINK, &dev->def_port); ++ ++ /* always present, can be no-op */ ++ set_bit(GLOBAL_APPLY, &dev->def_global); ++ set_bit(GLOBAL_RESET, &dev->def_global); ++} ++ ++ ++static struct genl_family switch_fam = { ++ .id = GENL_ID_GENERATE, ++ .name = "switch", ++ .hdrsize = 0, ++ .version = 1, ++ .maxattr = SWITCH_ATTR_MAX, ++}; ++ ++static const struct nla_policy switch_policy[SWITCH_ATTR_MAX+1] = { ++ [SWITCH_ATTR_ID] = { .type = NLA_U32 }, ++ [SWITCH_ATTR_OP_ID] = { .type = NLA_U32 }, ++ [SWITCH_ATTR_OP_PORT] = { .type = NLA_U32 }, ++ [SWITCH_ATTR_OP_VLAN] = { .type = NLA_U32 }, ++ [SWITCH_ATTR_OP_VALUE_INT] = { .type = NLA_U32 }, ++ [SWITCH_ATTR_OP_VALUE_STR] = { .type = NLA_NUL_STRING }, ++ [SWITCH_ATTR_OP_VALUE_PORTS] = { .type = NLA_NESTED }, ++ [SWITCH_ATTR_TYPE] = { .type = NLA_U32 }, ++}; ++ ++static const struct nla_policy port_policy[SWITCH_PORT_ATTR_MAX+1] = { ++ [SWITCH_PORT_ID] = { .type = NLA_U32 }, ++ [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG }, ++}; ++ ++static inline void ++swconfig_lock(void) ++{ ++ spin_lock(&swdevs_lock); ++} ++ ++static inline void ++swconfig_unlock(void) ++{ ++ spin_unlock(&swdevs_lock); ++} ++ ++static struct switch_dev * ++swconfig_get_dev(struct genl_info *info) ++{ ++ struct switch_dev *dev = NULL; ++ struct switch_dev *p; ++ int id; ++ ++ if (!info->attrs[SWITCH_ATTR_ID]) ++ goto done; ++ ++ id = nla_get_u32(info->attrs[SWITCH_ATTR_ID]); ++ swconfig_lock(); ++ list_for_each_entry(p, &swdevs, dev_list) { ++ if (id != p->id) ++ continue; ++ ++ dev = p; ++ break; ++ } ++ if (dev) ++ mutex_lock(&dev->sw_mutex); ++ else ++ pr_debug("device %d not found\n", id); ++ swconfig_unlock(); ++done: ++ return dev; ++} ++ ++static inline void ++swconfig_put_dev(struct switch_dev *dev) ++{ ++ mutex_unlock(&dev->sw_mutex); ++} ++ ++static int ++swconfig_dump_attr(struct swconfig_callback *cb, void *arg) ++{ ++ struct switch_attr *op = arg; ++ struct genl_info *info = cb->info; ++ struct sk_buff *msg = cb->msg; ++ int id = cb->args[0]; ++ void *hdr; ++ ++ hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam, ++ NLM_F_MULTI, SWITCH_CMD_NEW_ATTR); ++ if (IS_ERR(hdr)) ++ return -1; ++ ++ if (nla_put_u32(msg, SWITCH_ATTR_OP_ID, id)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, SWITCH_ATTR_OP_TYPE, op->type)) ++ goto nla_put_failure; ++ if (nla_put_string(msg, SWITCH_ATTR_OP_NAME, op->name)) ++ goto nla_put_failure; ++ if (op->description) ++ if (nla_put_string(msg, SWITCH_ATTR_OP_DESCRIPTION, ++ op->description)) ++ goto nla_put_failure; ++ ++ genlmsg_end(msg, hdr); ++ return msg->len; ++nla_put_failure: ++ genlmsg_cancel(msg, hdr); ++ return -EMSGSIZE; ++} ++ ++/* spread multipart messages across multiple message buffers */ ++static int ++swconfig_send_multipart(struct swconfig_callback *cb, void *arg) ++{ ++ struct genl_info *info = cb->info; ++ int restart = 0; ++ int err; ++ ++ do { ++ if (!cb->msg) { ++ cb->msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); ++ if (cb->msg == NULL) ++ goto error; ++ } ++ ++ if (!(cb->fill(cb, arg) < 0)) ++ break; ++ ++ /* fill failed, check if this was already the second attempt */ ++ if (restart) ++ goto error; ++ ++ /* try again in a new message, send the current one */ ++ restart = 1; ++ if (cb->close) { ++ if (cb->close(cb, arg) < 0) ++ goto error; ++ } ++ err = genlmsg_reply(cb->msg, info); ++ cb->msg = NULL; ++ if (err < 0) ++ goto error; ++ ++ } while (restart); ++ ++ return 0; ++ ++error: ++ if (cb->msg) ++ nlmsg_free(cb->msg); ++ return -1; ++} ++ ++static int ++swconfig_list_attrs(struct sk_buff *skb, struct genl_info *info) ++{ ++ struct genlmsghdr *hdr = nlmsg_data(info->nlhdr); ++ const struct switch_attrlist *alist; ++ struct switch_dev *dev; ++ struct swconfig_callback cb; ++ int err = -EINVAL; ++ int i; ++ ++ /* defaults */ ++ struct switch_attr *def_list; ++ unsigned long *def_active; ++ int n_def; ++ ++ dev = swconfig_get_dev(info); ++ if (!dev) ++ return -EINVAL; ++ ++ switch (hdr->cmd) { ++ case SWITCH_CMD_LIST_GLOBAL: ++ alist = &dev->ops->attr_global; ++ def_list = default_global; ++ def_active = &dev->def_global; ++ n_def = ARRAY_SIZE(default_global); ++ break; ++ case SWITCH_CMD_LIST_VLAN: ++ alist = &dev->ops->attr_vlan; ++ def_list = default_vlan; ++ def_active = &dev->def_vlan; ++ n_def = ARRAY_SIZE(default_vlan); ++ break; ++ case SWITCH_CMD_LIST_PORT: ++ alist = &dev->ops->attr_port; ++ def_list = default_port; ++ def_active = &dev->def_port; ++ n_def = ARRAY_SIZE(default_port); ++ break; ++ default: ++ WARN_ON(1); ++ goto out; ++ } ++ ++ memset(&cb, 0, sizeof(cb)); ++ cb.info = info; ++ cb.fill = swconfig_dump_attr; ++ for (i = 0; i < alist->n_attr; i++) { ++ if (alist->attr[i].disabled) ++ continue; ++ cb.args[0] = i; ++ err = swconfig_send_multipart(&cb, (void *) &alist->attr[i]); ++ if (err < 0) ++ goto error; ++ } ++ ++ /* defaults */ ++ for (i = 0; i < n_def; i++) { ++ if (!test_bit(i, def_active)) ++ continue; ++ cb.args[0] = SWITCH_ATTR_DEFAULTS_OFFSET + i; ++ err = swconfig_send_multipart(&cb, (void *) &def_list[i]); ++ if (err < 0) ++ goto error; ++ } ++ swconfig_put_dev(dev); ++ ++ if (!cb.msg) ++ return 0; ++ ++ return genlmsg_reply(cb.msg, info); ++ ++error: ++ if (cb.msg) ++ nlmsg_free(cb.msg); ++out: ++ swconfig_put_dev(dev); ++ return err; ++} ++ ++static const struct switch_attr * ++swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info, ++ struct switch_val *val) ++{ ++ struct genlmsghdr *hdr = nlmsg_data(info->nlhdr); ++ const struct switch_attrlist *alist; ++ const struct switch_attr *attr = NULL; ++ int attr_id; ++ ++ /* defaults */ ++ struct switch_attr *def_list; ++ unsigned long *def_active; ++ int n_def; ++ ++ if (!info->attrs[SWITCH_ATTR_OP_ID]) ++ goto done; ++ ++ switch (hdr->cmd) { ++ case SWITCH_CMD_SET_GLOBAL: ++ case SWITCH_CMD_GET_GLOBAL: ++ alist = &dev->ops->attr_global; ++ def_list = default_global; ++ def_active = &dev->def_global; ++ n_def = ARRAY_SIZE(default_global); ++ break; ++ case SWITCH_CMD_SET_VLAN: ++ case SWITCH_CMD_GET_VLAN: ++ alist = &dev->ops->attr_vlan; ++ def_list = default_vlan; ++ def_active = &dev->def_vlan; ++ n_def = ARRAY_SIZE(default_vlan); ++ if (!info->attrs[SWITCH_ATTR_OP_VLAN]) ++ goto done; ++ val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]); ++ if (val->port_vlan >= dev->vlans) ++ goto done; ++ break; ++ case SWITCH_CMD_SET_PORT: ++ case SWITCH_CMD_GET_PORT: ++ alist = &dev->ops->attr_port; ++ def_list = default_port; ++ def_active = &dev->def_port; ++ n_def = ARRAY_SIZE(default_port); ++ if (!info->attrs[SWITCH_ATTR_OP_PORT]) ++ goto done; ++ val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]); ++ if (val->port_vlan >= dev->ports) ++ goto done; ++ break; ++ default: ++ WARN_ON(1); ++ goto done; ++ } ++ ++ if (!alist) ++ goto done; ++ ++ attr_id = nla_get_u32(info->attrs[SWITCH_ATTR_OP_ID]); ++ if (attr_id >= SWITCH_ATTR_DEFAULTS_OFFSET) { ++ attr_id -= SWITCH_ATTR_DEFAULTS_OFFSET; ++ if (attr_id >= n_def) ++ goto done; ++ if (!test_bit(attr_id, def_active)) ++ goto done; ++ attr = &def_list[attr_id]; ++ } else { ++ if (attr_id >= alist->n_attr) ++ goto done; ++ attr = &alist->attr[attr_id]; ++ } ++ ++ if (attr->disabled) ++ attr = NULL; ++ ++done: ++ if (!attr) ++ pr_debug("attribute lookup failed\n"); ++ val->attr = attr; ++ return attr; ++} ++ ++static int ++swconfig_parse_ports(struct sk_buff *msg, struct nlattr *head, ++ struct switch_val *val, int max) ++{ ++ struct nlattr *nla; ++ int rem; ++ ++ val->len = 0; ++ nla_for_each_nested(nla, head, rem) { ++ struct nlattr *tb[SWITCH_PORT_ATTR_MAX+1]; ++ struct switch_port *port = &val->value.ports[val->len]; ++ ++ if (val->len >= max) ++ return -EINVAL; ++ ++ if (nla_parse_nested(tb, SWITCH_PORT_ATTR_MAX, nla, ++ port_policy)) ++ return -EINVAL; ++ ++ if (!tb[SWITCH_PORT_ID]) ++ return -EINVAL; ++ ++ port->id = nla_get_u32(tb[SWITCH_PORT_ID]); ++ if (tb[SWITCH_PORT_FLAG_TAGGED]) ++ port->flags |= (1 << SWITCH_PORT_FLAG_TAGGED); ++ val->len++; ++ } ++ ++ return 0; ++} ++ ++static int ++swconfig_set_attr(struct sk_buff *skb, struct genl_info *info) ++{ ++ const struct switch_attr *attr; ++ struct switch_dev *dev; ++ struct switch_val val; ++ int err = -EINVAL; ++ ++ dev = swconfig_get_dev(info); ++ if (!dev) ++ return -EINVAL; ++ ++ memset(&val, 0, sizeof(val)); ++ attr = swconfig_lookup_attr(dev, info, &val); ++ if (!attr || !attr->set) ++ goto error; ++ ++ val.attr = attr; ++ switch (attr->type) { ++ case SWITCH_TYPE_NOVAL: ++ break; ++ case SWITCH_TYPE_INT: ++ if (!info->attrs[SWITCH_ATTR_OP_VALUE_INT]) ++ goto error; ++ val.value.i = ++ nla_get_u32(info->attrs[SWITCH_ATTR_OP_VALUE_INT]); ++ break; ++ case SWITCH_TYPE_STRING: ++ if (!info->attrs[SWITCH_ATTR_OP_VALUE_STR]) ++ goto error; ++ val.value.s = ++ nla_data(info->attrs[SWITCH_ATTR_OP_VALUE_STR]); ++ break; ++ case SWITCH_TYPE_PORTS: ++ val.value.ports = dev->portbuf; ++ memset(dev->portbuf, 0, ++ sizeof(struct switch_port) * dev->ports); ++ ++ /* TODO: implement multipart? */ ++ if (info->attrs[SWITCH_ATTR_OP_VALUE_PORTS]) { ++ err = swconfig_parse_ports(skb, ++ info->attrs[SWITCH_ATTR_OP_VALUE_PORTS], ++ &val, dev->ports); ++ if (err < 0) ++ goto error; ++ } else { ++ val.len = 0; ++ err = 0; ++ } ++ break; ++ default: ++ goto error; ++ } ++ ++ err = attr->set(dev, attr, &val); ++error: ++ swconfig_put_dev(dev); ++ return err; ++} ++ ++static int ++swconfig_close_portlist(struct swconfig_callback *cb, void *arg) ++{ ++ if (cb->nest[0]) ++ nla_nest_end(cb->msg, cb->nest[0]); ++ return 0; ++} ++ ++static int ++swconfig_send_port(struct swconfig_callback *cb, void *arg) ++{ ++ const struct switch_port *port = arg; ++ struct nlattr *p = NULL; ++ ++ if (!cb->nest[0]) { ++ cb->nest[0] = nla_nest_start(cb->msg, cb->cmd); ++ if (!cb->nest[0]) ++ return -1; ++ } ++ ++ p = nla_nest_start(cb->msg, SWITCH_ATTR_PORT); ++ if (!p) ++ goto error; ++ ++ if (nla_put_u32(cb->msg, SWITCH_PORT_ID, port->id)) ++ goto nla_put_failure; ++ if (port->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) { ++ if (nla_put_flag(cb->msg, SWITCH_PORT_FLAG_TAGGED)) ++ goto nla_put_failure; ++ } ++ ++ nla_nest_end(cb->msg, p); ++ return 0; ++ ++nla_put_failure: ++ nla_nest_cancel(cb->msg, p); ++error: ++ nla_nest_cancel(cb->msg, cb->nest[0]); ++ return -1; ++} ++ ++static int ++swconfig_send_ports(struct sk_buff **msg, struct genl_info *info, int attr, ++ const struct switch_val *val) ++{ ++ struct swconfig_callback cb; ++ int err = 0; ++ int i; ++ ++ if (!val->value.ports) ++ return -EINVAL; ++ ++ memset(&cb, 0, sizeof(cb)); ++ cb.cmd = attr; ++ cb.msg = *msg; ++ cb.info = info; ++ cb.fill = swconfig_send_port; ++ cb.close = swconfig_close_portlist; ++ ++ cb.nest[0] = nla_nest_start(cb.msg, cb.cmd); ++ for (i = 0; i < val->len; i++) { ++ err = swconfig_send_multipart(&cb, &val->value.ports[i]); ++ if (err) ++ goto done; ++ } ++ err = val->len; ++ swconfig_close_portlist(&cb, NULL); ++ *msg = cb.msg; ++ ++done: ++ return err; ++} ++ ++static int ++swconfig_get_attr(struct sk_buff *skb, struct genl_info *info) ++{ ++ struct genlmsghdr *hdr = nlmsg_data(info->nlhdr); ++ const struct switch_attr *attr; ++ struct switch_dev *dev; ++ struct sk_buff *msg = NULL; ++ struct switch_val val; ++ int err = -EINVAL; ++ int cmd = hdr->cmd; ++ ++ dev = swconfig_get_dev(info); ++ if (!dev) ++ return -EINVAL; ++ ++ memset(&val, 0, sizeof(val)); ++ attr = swconfig_lookup_attr(dev, info, &val); ++ if (!attr || !attr->get) ++ goto error; ++ ++ if (attr->type == SWITCH_TYPE_PORTS) { ++ val.value.ports = dev->portbuf; ++ memset(dev->portbuf, 0, ++ sizeof(struct switch_port) * dev->ports); ++ } ++ ++ err = attr->get(dev, attr, &val); ++ if (err) ++ goto error; ++ ++ msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); ++ if (!msg) ++ goto error; ++ ++ hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam, ++ 0, cmd); ++ if (IS_ERR(hdr)) ++ goto nla_put_failure; ++ ++ switch (attr->type) { ++ case SWITCH_TYPE_INT: ++ if (nla_put_u32(msg, SWITCH_ATTR_OP_VALUE_INT, val.value.i)) ++ goto nla_put_failure; ++ break; ++ case SWITCH_TYPE_STRING: ++ if (nla_put_string(msg, SWITCH_ATTR_OP_VALUE_STR, val.value.s)) ++ goto nla_put_failure; ++ break; ++ case SWITCH_TYPE_PORTS: ++ err = swconfig_send_ports(&msg, info, ++ SWITCH_ATTR_OP_VALUE_PORTS, &val); ++ if (err < 0) ++ goto nla_put_failure; ++ break; ++ default: ++ pr_debug("invalid type in attribute\n"); ++ err = -EINVAL; ++ goto error; ++ } ++ genlmsg_end(msg, hdr); ++ err = msg->len; ++ if (err < 0) ++ goto nla_put_failure; ++ ++ swconfig_put_dev(dev); ++ return genlmsg_reply(msg, info); ++ ++nla_put_failure: ++ if (msg) ++ nlmsg_free(msg); ++error: ++ swconfig_put_dev(dev); ++ if (!err) ++ err = -ENOMEM; ++ return err; ++} ++ ++static int ++swconfig_send_switch(struct sk_buff *msg, u32 pid, u32 seq, int flags, ++ const struct switch_dev *dev) ++{ ++ struct nlattr *p = NULL, *m = NULL; ++ void *hdr; ++ int i; ++ ++ hdr = genlmsg_put(msg, pid, seq, &switch_fam, flags, ++ SWITCH_CMD_NEW_ATTR); ++ if (IS_ERR(hdr)) ++ return -1; ++ ++ if (nla_put_u32(msg, SWITCH_ATTR_ID, dev->id)) ++ goto nla_put_failure; ++ if (nla_put_string(msg, SWITCH_ATTR_DEV_NAME, dev->devname)) ++ goto nla_put_failure; ++ if (nla_put_string(msg, SWITCH_ATTR_ALIAS, dev->alias)) ++ goto nla_put_failure; ++ if (nla_put_string(msg, SWITCH_ATTR_NAME, dev->name)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, SWITCH_ATTR_VLANS, dev->vlans)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, SWITCH_ATTR_PORTS, dev->ports)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, SWITCH_ATTR_CPU_PORT, dev->cpu_port)) ++ goto nla_put_failure; ++ ++ m = nla_nest_start(msg, SWITCH_ATTR_PORTMAP); ++ if (!m) ++ goto nla_put_failure; ++ for (i = 0; i < dev->ports; i++) { ++ p = nla_nest_start(msg, SWITCH_ATTR_PORTS); ++ if (!p) ++ continue; ++ if (dev->portmap[i].s) { ++ if (nla_put_string(msg, SWITCH_PORTMAP_SEGMENT, ++ dev->portmap[i].s)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, SWITCH_PORTMAP_VIRT, ++ dev->portmap[i].virt)) ++ goto nla_put_failure; ++ } ++ nla_nest_end(msg, p); ++ } ++ nla_nest_end(msg, m); ++ genlmsg_end(msg, hdr); ++ return msg->len; ++nla_put_failure: ++ genlmsg_cancel(msg, hdr); ++ return -EMSGSIZE; ++} ++ ++static int swconfig_dump_switches(struct sk_buff *skb, ++ struct netlink_callback *cb) ++{ ++ struct switch_dev *dev; ++ int start = cb->args[0]; ++ int idx = 0; ++ ++ swconfig_lock(); ++ list_for_each_entry(dev, &swdevs, dev_list) { ++ if (++idx <= start) ++ continue; ++ if (swconfig_send_switch(skb, NETLINK_CB(cb->skb).portid, ++ cb->nlh->nlmsg_seq, NLM_F_MULTI, ++ dev) < 0) ++ break; ++ } ++ swconfig_unlock(); ++ cb->args[0] = idx; ++ ++ return skb->len; ++} ++ ++static int ++swconfig_done(struct netlink_callback *cb) ++{ ++ return 0; ++} ++ ++static struct genl_ops swconfig_ops[] = { ++ { ++ .cmd = SWITCH_CMD_LIST_GLOBAL, ++ .doit = swconfig_list_attrs, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_LIST_VLAN, ++ .doit = swconfig_list_attrs, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_LIST_PORT, ++ .doit = swconfig_list_attrs, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_GET_GLOBAL, ++ .doit = swconfig_get_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_GET_VLAN, ++ .doit = swconfig_get_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_GET_PORT, ++ .doit = swconfig_get_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_SET_GLOBAL, ++ .doit = swconfig_set_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_SET_VLAN, ++ .doit = swconfig_set_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_SET_PORT, ++ .doit = swconfig_set_attr, ++ .policy = switch_policy, ++ }, ++ { ++ .cmd = SWITCH_CMD_GET_SWITCH, ++ .dumpit = swconfig_dump_switches, ++ .policy = switch_policy, ++ .done = swconfig_done, ++ } ++}; ++ ++#ifdef CONFIG_OF ++void ++of_switch_load_portmap(struct switch_dev *dev) ++{ ++ struct device_node *port; ++ ++ if (!dev->of_node) ++ return; ++ ++ for_each_child_of_node(dev->of_node, port) { ++ const __be32 *prop; ++ const char *segment; ++ int size, phys; ++ ++ if (!of_device_is_compatible(port, "swconfig,port")) ++ continue; ++ ++ if (of_property_read_string(port, "swconfig,segment", &segment)) ++ continue; ++ ++ prop = of_get_property(port, "swconfig,portmap", &size); ++ if (!prop) ++ continue; ++ ++ if (size != (2 * sizeof(*prop))) { ++ pr_err("%s: failed to parse port mapping\n", ++ port->name); ++ continue; ++ } ++ ++ phys = be32_to_cpup(prop++); ++ if ((phys < 0) | (phys >= dev->ports)) { ++ pr_err("%s: physical port index out of range\n", ++ port->name); ++ continue; ++ } ++ ++ dev->portmap[phys].s = kstrdup(segment, GFP_KERNEL); ++ dev->portmap[phys].virt = be32_to_cpup(prop); ++ pr_debug("Found port: %s, physical: %d, virtual: %d\n", ++ segment, phys, dev->portmap[phys].virt); ++ } ++} ++#endif ++ ++int ++register_switch(struct switch_dev *dev, struct net_device *netdev) ++{ ++ struct switch_dev *sdev; ++ const int max_switches = 8 * sizeof(unsigned long); ++ unsigned long in_use = 0; ++ int err; ++ int i; ++ ++ INIT_LIST_HEAD(&dev->dev_list); ++ if (netdev) { ++ dev->netdev = netdev; ++ if (!dev->alias) ++ dev->alias = netdev->name; ++ } ++ BUG_ON(!dev->alias); ++ ++ if (dev->ports > 0) { ++ dev->portbuf = kzalloc(sizeof(struct switch_port) * ++ dev->ports, GFP_KERNEL); ++ if (!dev->portbuf) ++ return -ENOMEM; ++ dev->portmap = kzalloc(sizeof(struct switch_portmap) * ++ dev->ports, GFP_KERNEL); ++ if (!dev->portmap) { ++ kfree(dev->portbuf); ++ return -ENOMEM; ++ } ++ } ++ swconfig_defaults_init(dev); ++ mutex_init(&dev->sw_mutex); ++ swconfig_lock(); ++ dev->id = ++swdev_id; ++ ++ list_for_each_entry(sdev, &swdevs, dev_list) { ++ if (!sscanf(sdev->devname, SWCONFIG_DEVNAME, &i)) ++ continue; ++ if (i < 0 || i > max_switches) ++ continue; ++ ++ set_bit(i, &in_use); ++ } ++ i = find_first_zero_bit(&in_use, max_switches); ++ ++ if (i == max_switches) { ++ swconfig_unlock(); ++ return -ENFILE; ++ } ++ ++#ifdef CONFIG_OF ++ if (dev->ports) ++ of_switch_load_portmap(dev); ++#endif ++ ++ /* fill device name */ ++ snprintf(dev->devname, IFNAMSIZ, SWCONFIG_DEVNAME, i); ++ ++ list_add_tail(&dev->dev_list, &swdevs); ++ swconfig_unlock(); ++ ++ err = swconfig_create_led_trigger(dev); ++ if (err) ++ return err; ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(register_switch); ++ ++void ++unregister_switch(struct switch_dev *dev) ++{ ++ swconfig_destroy_led_trigger(dev); ++ kfree(dev->portbuf); ++ mutex_lock(&dev->sw_mutex); ++ swconfig_lock(); ++ list_del(&dev->dev_list); ++ swconfig_unlock(); ++ mutex_unlock(&dev->sw_mutex); ++} ++EXPORT_SYMBOL_GPL(unregister_switch); ++ ++ ++static int __init ++swconfig_init(void) ++{ ++ int err; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)) ++ int i; ++#endif ++ ++ INIT_LIST_HEAD(&swdevs); ++ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)) ++ err = genl_register_family(&switch_fam); ++ if (err) ++ return err; ++ ++ for (i = 0; i < ARRAY_SIZE(swconfig_ops); i++) { ++ err = genl_register_ops(&switch_fam, &swconfig_ops[i]); ++ if (err) ++ goto unregister; ++ } ++ return 0; ++ ++unregister: ++ genl_unregister_family(&switch_fam); ++ return err; ++#else ++ err = genl_register_family_with_ops(&switch_fam, swconfig_ops); ++ if (err) ++ return err; ++ return 0; ++#endif ++} ++ ++static void __exit ++swconfig_exit(void) ++{ ++ genl_unregister_family(&switch_fam); ++} ++ ++module_init(swconfig_init); ++module_exit(swconfig_exit); ++ +diff --git a/drivers/net/phy/swconfig_leds.c b/drivers/net/phy/swconfig_leds.c +new file mode 100755 +index 0000000..abd7bed +--- /dev/null ++++ b/drivers/net/phy/swconfig_leds.c +@@ -0,0 +1,354 @@ ++/* ++ * swconfig_led.c: LED trigger support for the switch configuration API ++ * ++ * Copyright (C) 2011 Gabor Juhos ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ */ ++ ++#ifdef CONFIG_SWCONFIG_LEDS ++ ++#include ++#include ++#include ++#include ++ ++#define SWCONFIG_LED_TIMER_INTERVAL (HZ / 10) ++#define SWCONFIG_LED_NUM_PORTS 32 ++ ++struct switch_led_trigger { ++ struct led_trigger trig; ++ struct switch_dev *swdev; ++ ++ struct delayed_work sw_led_work; ++ u32 port_mask; ++ u32 port_link; ++ unsigned long port_traffic[SWCONFIG_LED_NUM_PORTS]; ++}; ++ ++struct swconfig_trig_data { ++ struct led_classdev *led_cdev; ++ struct switch_dev *swdev; ++ ++ rwlock_t lock; ++ u32 port_mask; ++ ++ bool prev_link; ++ unsigned long prev_traffic; ++ enum led_brightness prev_brightness; ++}; ++ ++static void ++swconfig_trig_set_brightness(struct swconfig_trig_data *trig_data, ++ enum led_brightness brightness) ++{ ++ led_set_brightness(trig_data->led_cdev, brightness); ++ trig_data->prev_brightness = brightness; ++} ++ ++static void ++swconfig_trig_update_port_mask(struct led_trigger *trigger) ++{ ++ struct list_head *entry; ++ struct switch_led_trigger *sw_trig; ++ u32 port_mask; ++ ++ if (!trigger) ++ return; ++ ++ sw_trig = (void *) trigger; ++ ++ port_mask = 0; ++ read_lock(&trigger->leddev_list_lock); ++ list_for_each(entry, &trigger->led_cdevs) { ++ struct led_classdev *led_cdev; ++ struct swconfig_trig_data *trig_data; ++ ++ led_cdev = list_entry(entry, struct led_classdev, trig_list); ++ trig_data = led_cdev->trigger_data; ++ if (trig_data) { ++ read_lock(&trig_data->lock); ++ port_mask |= trig_data->port_mask; ++ read_unlock(&trig_data->lock); ++ } ++ } ++ read_unlock(&trigger->leddev_list_lock); ++ ++ sw_trig->port_mask = port_mask; ++ ++ if (port_mask) ++ schedule_delayed_work(&sw_trig->sw_led_work, ++ SWCONFIG_LED_TIMER_INTERVAL); ++ else ++ cancel_delayed_work_sync(&sw_trig->sw_led_work); ++} ++ ++static ssize_t ++swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t size) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct swconfig_trig_data *trig_data = led_cdev->trigger_data; ++ unsigned long port_mask; ++ ssize_t ret = -EINVAL; ++ char *after; ++ size_t count; ++ ++ port_mask = simple_strtoul(buf, &after, 16); ++ count = after - buf; ++ ++ if (*after && isspace(*after)) ++ count++; ++ ++ if (count == size) { ++ bool changed; ++ ++ write_lock(&trig_data->lock); ++ ++ changed = (trig_data->port_mask != port_mask); ++ if (changed) { ++ trig_data->port_mask = port_mask; ++ if (port_mask == 0) ++ swconfig_trig_set_brightness(trig_data, LED_OFF); ++ } ++ ++ write_unlock(&trig_data->lock); ++ ++ if (changed) ++ swconfig_trig_update_port_mask(led_cdev->trigger); ++ ++ ret = count; ++ } ++ ++ return ret; ++} ++ ++static ssize_t ++swconfig_trig_port_mask_show(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct swconfig_trig_data *trig_data = led_cdev->trigger_data; ++ ++ read_lock(&trig_data->lock); ++ sprintf(buf, "%#x\n", trig_data->port_mask); ++ read_unlock(&trig_data->lock); ++ ++ return strlen(buf) + 1; ++} ++ ++static DEVICE_ATTR(port_mask, 0644, swconfig_trig_port_mask_show, ++ swconfig_trig_port_mask_store); ++ ++static void ++swconfig_trig_activate(struct led_classdev *led_cdev) ++{ ++ struct switch_led_trigger *sw_trig; ++ struct swconfig_trig_data *trig_data; ++ int err; ++ ++ if (led_cdev->trigger->activate != swconfig_trig_activate) ++ return; ++ ++ trig_data = kzalloc(sizeof(struct swconfig_trig_data), GFP_KERNEL); ++ if (!trig_data) ++ return; ++ ++ sw_trig = (void *) led_cdev->trigger; ++ ++ rwlock_init(&trig_data->lock); ++ trig_data->led_cdev = led_cdev; ++ trig_data->swdev = sw_trig->swdev; ++ led_cdev->trigger_data = trig_data; ++ ++ err = device_create_file(led_cdev->dev, &dev_attr_port_mask); ++ if (err) ++ goto err_free; ++ ++ return; ++ ++err_free: ++ led_cdev->trigger_data = NULL; ++ kfree(trig_data); ++} ++ ++static void ++swconfig_trig_deactivate(struct led_classdev *led_cdev) ++{ ++ struct swconfig_trig_data *trig_data; ++ ++ swconfig_trig_update_port_mask(led_cdev->trigger); ++ ++ trig_data = (void *) led_cdev->trigger_data; ++ if (trig_data) { ++ device_remove_file(led_cdev->dev, &dev_attr_port_mask); ++ kfree(trig_data); ++ } ++} ++ ++static void ++swconfig_trig_led_event(struct switch_led_trigger *sw_trig, ++ struct led_classdev *led_cdev) ++{ ++ struct swconfig_trig_data *trig_data; ++ u32 port_mask; ++ bool link; ++ ++ trig_data = led_cdev->trigger_data; ++ if (!trig_data) ++ return; ++ ++ read_lock(&trig_data->lock); ++ port_mask = trig_data->port_mask; ++ read_unlock(&trig_data->lock); ++ ++ link = !!(sw_trig->port_link & port_mask); ++ if (!link) { ++ if (link != trig_data->prev_link) ++ swconfig_trig_set_brightness(trig_data, LED_OFF); ++ } else { ++ unsigned long traffic; ++ int i; ++ ++ traffic = 0; ++ for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) { ++ if (port_mask & (1 << i)) ++ traffic += sw_trig->port_traffic[i]; ++ } ++ ++ if (trig_data->prev_brightness != LED_FULL) ++ swconfig_trig_set_brightness(trig_data, LED_FULL); ++ else if (traffic != trig_data->prev_traffic) ++ swconfig_trig_set_brightness(trig_data, LED_OFF); ++ ++ trig_data->prev_traffic = traffic; ++ } ++ ++ trig_data->prev_link = link; ++} ++ ++static void ++swconfig_trig_update_leds(struct switch_led_trigger *sw_trig) ++{ ++ struct list_head *entry; ++ struct led_trigger *trigger; ++ ++ trigger = &sw_trig->trig; ++ read_lock(&trigger->leddev_list_lock); ++ list_for_each(entry, &trigger->led_cdevs) { ++ struct led_classdev *led_cdev; ++ ++ led_cdev = list_entry(entry, struct led_classdev, trig_list); ++ swconfig_trig_led_event(sw_trig, led_cdev); ++ } ++ read_unlock(&trigger->leddev_list_lock); ++} ++ ++static void ++swconfig_led_work_func(struct work_struct *work) ++{ ++ struct switch_led_trigger *sw_trig; ++ struct switch_dev *swdev; ++ u32 port_mask; ++ u32 link; ++ int i; ++ ++ sw_trig = container_of(work, struct switch_led_trigger, ++ sw_led_work.work); ++ ++ port_mask = sw_trig->port_mask; ++ swdev = sw_trig->swdev; ++ ++ link = 0; ++ for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) { ++ u32 port_bit; ++ ++ port_bit = BIT(i); ++ if ((port_mask & port_bit) == 0) ++ continue; ++ ++ if (swdev->ops->get_port_link) { ++ struct switch_port_link port_link; ++ ++ memset(&port_link, '\0', sizeof(port_link)); ++ swdev->ops->get_port_link(swdev, i, &port_link); ++ ++ if (port_link.link) ++ link |= port_bit; ++ } ++ ++ if (swdev->ops->get_port_stats) { ++ struct switch_port_stats port_stats; ++ ++ memset(&port_stats, '\0', sizeof(port_stats)); ++ swdev->ops->get_port_stats(swdev, i, &port_stats); ++ sw_trig->port_traffic[i] = port_stats.tx_bytes + ++ port_stats.rx_bytes; ++ } ++ } ++ ++ sw_trig->port_link = link; ++ ++ swconfig_trig_update_leds(sw_trig); ++ ++ schedule_delayed_work(&sw_trig->sw_led_work, ++ SWCONFIG_LED_TIMER_INTERVAL); ++} ++ ++static int ++swconfig_create_led_trigger(struct switch_dev *swdev) ++{ ++ struct switch_led_trigger *sw_trig; ++ int err; ++ ++ if (!swdev->ops->get_port_link) ++ return 0; ++ ++ sw_trig = kzalloc(sizeof(struct switch_led_trigger), GFP_KERNEL); ++ if (!sw_trig) ++ return -ENOMEM; ++ ++ sw_trig->swdev = swdev; ++ sw_trig->trig.name = swdev->devname; ++ sw_trig->trig.activate = swconfig_trig_activate; ++ sw_trig->trig.deactivate = swconfig_trig_deactivate; ++ ++ INIT_DELAYED_WORK(&sw_trig->sw_led_work, swconfig_led_work_func); ++ ++ err = led_trigger_register(&sw_trig->trig); ++ if (err) ++ goto err_free; ++ ++ swdev->led_trigger = sw_trig; ++ ++ return 0; ++ ++err_free: ++ kfree(sw_trig); ++ return err; ++} ++ ++static void ++swconfig_destroy_led_trigger(struct switch_dev *swdev) ++{ ++ struct switch_led_trigger *sw_trig; ++ ++ sw_trig = swdev->led_trigger; ++ if (sw_trig) { ++ cancel_delayed_work_sync(&sw_trig->sw_led_work); ++ led_trigger_unregister(&sw_trig->trig); ++ kfree(sw_trig); ++ } ++} ++ ++#else /* SWCONFIG_LEDS */ ++static inline int ++swconfig_create_led_trigger(struct switch_dev *swdev) { return 0; } ++ ++static inline void ++swconfig_destroy_led_trigger(struct switch_dev *swdev) { } ++#endif /* CONFIG_SWCONFIG_LEDS */ +diff --git a/include/linux/platform_data/b53.h b/include/linux/platform_data/b53.h +new file mode 100755 +index 0000000..7842741 +--- /dev/null ++++ b/include/linux/platform_data/b53.h +@@ -0,0 +1,36 @@ ++/* ++ * B53 platform data ++ * ++ * Copyright (C) 2013 Jonas Gorski ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#ifndef __B53_H ++#define __B53_H ++ ++#include ++ ++struct b53_platform_data { ++ u32 chip_id; ++ u16 enabled_ports; ++ ++ /* allow to specify an ethX alias */ ++ const char *alias; ++ ++ /* only used by MMAP'd driver */ ++ unsigned big_endian:1; ++ void __iomem *regs; ++}; ++ ++#endif +diff --git a/include/linux/switch.h b/include/linux/switch.h +new file mode 100755 +index 0000000..4291364 +--- /dev/null ++++ b/include/linux/switch.h +@@ -0,0 +1,169 @@ ++/* ++ * switch.h: Switch configuration API ++ * ++ * Copyright (C) 2008 Felix Fietkau ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ */ ++#ifndef _LINUX_SWITCH_H ++#define _LINUX_SWITCH_H ++ ++#include ++#include ++ ++struct switch_dev; ++struct switch_op; ++struct switch_val; ++struct switch_attr; ++struct switch_attrlist; ++struct switch_led_trigger; ++ ++int register_switch(struct switch_dev *dev, struct net_device *netdev); ++void unregister_switch(struct switch_dev *dev); ++ ++/** ++ * struct switch_attrlist - attribute list ++ * ++ * @n_attr: number of attributes ++ * @attr: pointer to the attributes array ++ */ ++struct switch_attrlist { ++ int n_attr; ++ const struct switch_attr *attr; ++}; ++ ++enum switch_port_speed { ++ SWITCH_PORT_SPEED_UNKNOWN = 0, ++ SWITCH_PORT_SPEED_10 = 10, ++ SWITCH_PORT_SPEED_100 = 100, ++ SWITCH_PORT_SPEED_1000 = 1000, ++}; ++ ++struct switch_port_link { ++ bool link; ++ bool duplex; ++ bool aneg; ++ bool tx_flow; ++ bool rx_flow; ++ enum switch_port_speed speed; ++ /* in ethtool adv_t format */ ++ u32 eee; ++}; ++ ++struct switch_port_stats { ++ unsigned long tx_bytes; ++ unsigned long rx_bytes; ++}; ++ ++/** ++ * struct switch_dev_ops - switch driver operations ++ * ++ * @attr_global: global switch attribute list ++ * @attr_port: port attribute list ++ * @attr_vlan: vlan attribute list ++ * ++ * Callbacks: ++ * ++ * @get_vlan_ports: read the port list of a VLAN ++ * @set_vlan_ports: set the port list of a VLAN ++ * ++ * @get_port_pvid: get the primary VLAN ID of a port ++ * @set_port_pvid: set the primary VLAN ID of a port ++ * ++ * @apply_config: apply all changed settings to the switch ++ * @reset_switch: resetting the switch ++ */ ++struct switch_dev_ops { ++ struct switch_attrlist attr_global, attr_port, attr_vlan; ++ ++ int (*get_vlan_ports)(struct switch_dev *dev, struct switch_val *val); ++ int (*set_vlan_ports)(struct switch_dev *dev, struct switch_val *val); ++ ++ int (*get_port_pvid)(struct switch_dev *dev, int port, int *val); ++ int (*set_port_pvid)(struct switch_dev *dev, int port, int val); ++ ++ int (*apply_config)(struct switch_dev *dev); ++ int (*reset_switch)(struct switch_dev *dev); ++ ++ int (*get_port_link)(struct switch_dev *dev, int port, ++ struct switch_port_link *link); ++ int (*get_port_stats)(struct switch_dev *dev, int port, ++ struct switch_port_stats *stats); ++}; ++ ++struct switch_dev { ++ struct device_node *of_node; ++ const struct switch_dev_ops *ops; ++ /* will be automatically filled */ ++ char devname[IFNAMSIZ]; ++ ++ const char *name; ++ /* NB: either alias or netdev must be set */ ++ const char *alias; ++ struct net_device *netdev; ++ ++ int ports; ++ int vlans; ++ int cpu_port; ++ ++ /* the following fields are internal for swconfig */ ++ int id; ++ struct list_head dev_list; ++ unsigned long def_global, def_port, def_vlan; ++ ++ struct mutex sw_mutex; ++ struct switch_port *portbuf; ++ struct switch_portmap *portmap; ++ ++ char buf[128]; ++ ++#ifdef CONFIG_SWCONFIG_LEDS ++ struct switch_led_trigger *led_trigger; ++#endif ++}; ++ ++struct switch_port { ++ u32 id; ++ u32 flags; ++}; ++ ++struct switch_portmap { ++ u32 virt; ++ const char *s; ++}; ++ ++struct switch_val { ++ const struct switch_attr *attr; ++ int port_vlan; ++ int len; ++ union { ++ const char *s; ++ u32 i; ++ struct switch_port *ports; ++ } value; ++}; ++ ++struct switch_attr { ++ int disabled; ++ int type; ++ const char *name; ++ const char *description; ++ ++ int (*set)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val); ++ int (*get)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val); ++ ++ /* for driver internal use */ ++ int id; ++ int ofs; ++ int max; ++}; ++ ++#endif /* _LINUX_SWITCH_H */ +diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild +old mode 100644 +new mode 100755 +index 68ceb97..40fa85b +--- a/include/uapi/linux/Kbuild ++++ b/include/uapi/linux/Kbuild +@@ -379,6 +379,7 @@ header-y += stddef.h + header-y += string.h + header-y += suspend_ioctls.h + header-y += swab.h ++header-y += switch.h + header-y += synclink.h + header-y += sysctl.h + header-y += sysinfo.h +diff --git a/include/uapi/linux/switch.h b/include/uapi/linux/switch.h +new file mode 100755 +index 0000000..a59b239 +--- /dev/null ++++ b/include/uapi/linux/switch.h +@@ -0,0 +1,103 @@ ++/* ++ * switch.h: Switch configuration API ++ * ++ * Copyright (C) 2008 Felix Fietkau ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ */ ++ ++#ifndef _UAPI_LINUX_SWITCH_H ++#define _UAPI_LINUX_SWITCH_H ++ ++#include ++#include ++#include ++#include ++#ifndef __KERNEL__ ++#include ++#include ++#include ++#endif ++ ++/* main attributes */ ++enum { ++ SWITCH_ATTR_UNSPEC, ++ /* global */ ++ SWITCH_ATTR_TYPE, ++ /* device */ ++ SWITCH_ATTR_ID, ++ SWITCH_ATTR_DEV_NAME, ++ SWITCH_ATTR_ALIAS, ++ SWITCH_ATTR_NAME, ++ SWITCH_ATTR_VLANS, ++ SWITCH_ATTR_PORTS, ++ SWITCH_ATTR_PORTMAP, ++ SWITCH_ATTR_CPU_PORT, ++ /* attributes */ ++ SWITCH_ATTR_OP_ID, ++ SWITCH_ATTR_OP_TYPE, ++ SWITCH_ATTR_OP_NAME, ++ SWITCH_ATTR_OP_PORT, ++ SWITCH_ATTR_OP_VLAN, ++ SWITCH_ATTR_OP_VALUE_INT, ++ SWITCH_ATTR_OP_VALUE_STR, ++ SWITCH_ATTR_OP_VALUE_PORTS, ++ SWITCH_ATTR_OP_DESCRIPTION, ++ /* port lists */ ++ SWITCH_ATTR_PORT, ++ SWITCH_ATTR_MAX ++}; ++ ++enum { ++ /* port map */ ++ SWITCH_PORTMAP_PORTS, ++ SWITCH_PORTMAP_SEGMENT, ++ SWITCH_PORTMAP_VIRT, ++ SWITCH_PORTMAP_MAX ++}; ++ ++/* commands */ ++enum { ++ SWITCH_CMD_UNSPEC, ++ SWITCH_CMD_GET_SWITCH, ++ SWITCH_CMD_NEW_ATTR, ++ SWITCH_CMD_LIST_GLOBAL, ++ SWITCH_CMD_GET_GLOBAL, ++ SWITCH_CMD_SET_GLOBAL, ++ SWITCH_CMD_LIST_PORT, ++ SWITCH_CMD_GET_PORT, ++ SWITCH_CMD_SET_PORT, ++ SWITCH_CMD_LIST_VLAN, ++ SWITCH_CMD_GET_VLAN, ++ SWITCH_CMD_SET_VLAN ++}; ++ ++/* data types */ ++enum switch_val_type { ++ SWITCH_TYPE_UNSPEC, ++ SWITCH_TYPE_INT, ++ SWITCH_TYPE_STRING, ++ SWITCH_TYPE_PORTS, ++ SWITCH_TYPE_NOVAL, ++}; ++ ++/* port nested attributes */ ++enum { ++ SWITCH_PORT_UNSPEC, ++ SWITCH_PORT_ID, ++ SWITCH_PORT_FLAG_TAGGED, ++ SWITCH_PORT_ATTR_MAX ++}; ++ ++#define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000 ++ ++ ++#endif /* _UAPI_LINUX_SWITCH_H */ diff --git a/patch/kernel/sunxi-next/lime2-add-A20-CAN-support.patch b/patch/kernel/sunxi-next/lime2-add-A20-CAN-support.patch new file mode 100644 index 0000000000..6ff8488feb --- /dev/null +++ b/patch/kernel/sunxi-next/lime2-add-A20-CAN-support.patch @@ -0,0 +1,47 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts +index d5c796c..2f90530 100644 +--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts ++++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts +@@ -278,3 +278,9 @@ + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; + }; ++ ++&can0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&can0_pins_a>; ++ status = "okay"; ++}; +diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi +index bd0c476..8b63dde 100644 +--- a/arch/arm/boot/dts/sun7i-a20.dtsi ++++ b/arch/arm/boot/dts/sun7i-a20.dtsi +@@ -1229,6 +1229,13 @@ + allwinner,pull = ; + }; + ++ can0_pins_a: can0@0 { ++ allwinner,pins = "PH20","PH21"; ++ allwinner,function = "can"; ++ allwinner,drive = ; ++ allwinner,pull = ; ++ }; ++ + ps20_pins_a: ps20@0 { + allwinner,pins = "PI20", "PI21"; + allwinner,function = "ps2"; +@@ -1435,6 +1442,14 @@ + status = "disabled"; + }; + ++ can0: can@01c2bc00 { ++ compatible = "allwinner,sun4i-a10-can"; ++ reg = <0x01c2bc00 0x400>; ++ interrupts = ; ++ clocks = <&apb1_gates 4>; ++ status = "disabled"; ++ }; ++ + ir0: ir@01c21800 { + compatible = "allwinner,sun4i-a10-ir"; + clocks = <&apb0_gates 6>, <&ir0_clk>; diff --git a/patch/kernel/sunxi-next/remove-DSA-b53-driver.patch b/patch/kernel/sunxi-next/remove-DSA-b53-driver.patch new file mode 100644 index 0000000000..b9061cd5e4 --- /dev/null +++ b/patch/kernel/sunxi-next/remove-DSA-b53-driver.patch @@ -0,0 +1,23 @@ +diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig +index 8f45443..8a271ff 100644 +--- a/drivers/net/dsa/Kconfig ++++ b/drivers/net/dsa/Kconfig +@@ -20,8 +20,6 @@ config NET_DSA_BCM_SF2 + This enables support for the Broadcom Starfighter 2 Ethernet + switch chips. + +-source "drivers/net/dsa/b53/Kconfig" +- + source "drivers/net/dsa/mv88e6xxx/Kconfig" + + endmenu +diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile +index ca1e71b..e6ad39b 100644 +--- a/drivers/net/dsa/Makefile ++++ b/drivers/net/dsa/Makefile +@@ -1,5 +1,4 @@ + obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o + obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm_sf2.o + +-obj-y += b53/ + obj-y += mv88e6xxx/ diff --git a/patch/kernel/sunxi-next/revert-lamobo-r1-dts-for-old-b53-driver.patch b/patch/kernel/sunxi-next/revert-lamobo-r1-dts-for-old-b53-driver.patch new file mode 100644 index 0000000000..a7b50b4b4e --- /dev/null +++ b/patch/kernel/sunxi-next/revert-lamobo-r1-dts-for-old-b53-driver.patch @@ -0,0 +1,77 @@ +diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts +index 73c05da..dcaa84f 100644 +--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts ++++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts +@@ -114,68 +114,14 @@ + &gmac { + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii_a>; ++ phy = <&phy1>; + phy-mode = "rgmii"; + phy-supply = <®_gmac_3v3>; + status = "okay"; + +- fixed-link { +- speed = <1000>; +- full-duplex; +- }; +- +- mdio { +- compatible = "snps,dwmac-mdio"; +- #address-cells = <1>; +- #size-cells = <0>; +- +- switch: ethernet-switch@1e { +- compatible = "brcm,bcm53125"; +- reg = <30>; +- #address-cells = <1>; +- #size-cells = <0>; +- +- ports { +- #address-cells = <1>; +- #size-cells = <0>; +- +- port0: port@0 { +- reg = <0>; +- label = "lan2"; +- }; +- +- port1: port@1 { +- reg = <1>; +- label = "lan3"; +- }; +- +- port2: port@2 { +- reg = <2>; +- label = "lan4"; +- }; +- +- port3: port@3 { +- reg = <3>; +- label = "wan"; +- }; +- +- port4: port@4 { +- reg = <4>; +- label = "lan1"; +- }; +- +- port8: port@8 { +- reg = <8>; +- label = "cpu"; +- ethernet = <&gmac>; +- phy-mode = "rgmii"; +- fixed-link { +- speed = <1000>; +- full-duplex; +- }; +- }; +- }; +- }; +- }; ++ phy1: ethernet-phy@1 { ++ reg = <1>; ++ }; + }; + + &i2c0 { diff --git a/patch/kernel/udoo-next/03-patch-4.4.28-29.patch b/patch/kernel/udoo-next/03-patch-4.4.28-29.patch new file mode 100644 index 0000000000..0bcb39c5ba --- /dev/null +++ b/patch/kernel/udoo-next/03-patch-4.4.28-29.patch @@ -0,0 +1,2368 @@ +diff --git a/Documentation/x86/exception-tables.txt b/Documentation/x86/exception-tables.txt +index 32901aa36f0a..e396bcd8d830 100644 +--- a/Documentation/x86/exception-tables.txt ++++ b/Documentation/x86/exception-tables.txt +@@ -290,3 +290,38 @@ Due to the way that the exception table is built and needs to be ordered, + only use exceptions for code in the .text section. Any other section + will cause the exception table to not be sorted correctly, and the + exceptions will fail. ++ ++Things changed when 64-bit support was added to x86 Linux. Rather than ++double the size of the exception table by expanding the two entries ++from 32-bits to 64 bits, a clever trick was used to store addresses ++as relative offsets from the table itself. The assembly code changed ++from: ++ .long 1b,3b ++to: ++ .long (from) - . ++ .long (to) - . ++ ++and the C-code that uses these values converts back to absolute addresses ++like this: ++ ++ ex_insn_addr(const struct exception_table_entry *x) ++ { ++ return (unsigned long)&x->insn + x->insn; ++ } ++ ++In v4.6 the exception table entry was expanded with a new field "handler". ++This is also 32-bits wide and contains a third relative function ++pointer which points to one of: ++ ++1) int ex_handler_default(const struct exception_table_entry *fixup) ++ This is legacy case that just jumps to the fixup code ++2) int ex_handler_fault(const struct exception_table_entry *fixup) ++ This case provides the fault number of the trap that occurred at ++ entry->insn. It is used to distinguish page faults from machine ++ check. ++3) int ex_handler_ext(const struct exception_table_entry *fixup) ++ This case is used for uaccess_err ... we need to set a flag ++ in the task structure. Before the handler functions existed this ++ case was handled by adding a large offset to the fixup to tag ++ it as special. ++More functions can easily be added. +diff --git a/Makefile b/Makefile +index 391294301aaf..19d7d9f68e35 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 28 ++SUBLEVEL = 29 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/crypto/ghash-ce-glue.c b/arch/arm/crypto/ghash-ce-glue.c +index 03a39fe29246..9d9ba9acdddc 100644 +--- a/arch/arm/crypto/ghash-ce-glue.c ++++ b/arch/arm/crypto/ghash-ce-glue.c +@@ -226,6 +226,27 @@ static int ghash_async_digest(struct ahash_request *req) + } + } + ++static int ghash_async_import(struct ahash_request *req, const void *in) ++{ ++ struct ahash_request *cryptd_req = ahash_request_ctx(req); ++ struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); ++ struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm); ++ struct shash_desc *desc = cryptd_shash_desc(cryptd_req); ++ ++ desc->tfm = cryptd_ahash_child(ctx->cryptd_tfm); ++ desc->flags = req->base.flags; ++ ++ return crypto_shash_import(desc, in); ++} ++ ++static int ghash_async_export(struct ahash_request *req, void *out) ++{ ++ struct ahash_request *cryptd_req = ahash_request_ctx(req); ++ struct shash_desc *desc = cryptd_shash_desc(cryptd_req); ++ ++ return crypto_shash_export(desc, out); ++} ++ + static int ghash_async_setkey(struct crypto_ahash *tfm, const u8 *key, + unsigned int keylen) + { +@@ -274,7 +295,10 @@ static struct ahash_alg ghash_async_alg = { + .final = ghash_async_final, + .setkey = ghash_async_setkey, + .digest = ghash_async_digest, ++ .import = ghash_async_import, ++ .export = ghash_async_export, + .halg.digestsize = GHASH_DIGEST_SIZE, ++ .halg.statesize = sizeof(struct ghash_desc_ctx), + .halg.base = { + .cra_name = "ghash", + .cra_driver_name = "ghash-ce", +diff --git a/arch/arm/mach-pxa/pxa_cplds_irqs.c b/arch/arm/mach-pxa/pxa_cplds_irqs.c +index 2385052b0ce1..e362f865fcd2 100644 +--- a/arch/arm/mach-pxa/pxa_cplds_irqs.c ++++ b/arch/arm/mach-pxa/pxa_cplds_irqs.c +@@ -41,30 +41,35 @@ static irqreturn_t cplds_irq_handler(int in_irq, void *d) + unsigned long pending; + unsigned int bit; + +- pending = readl(fpga->base + FPGA_IRQ_SET_CLR) & fpga->irq_mask; +- for_each_set_bit(bit, &pending, CPLDS_NB_IRQ) +- generic_handle_irq(irq_find_mapping(fpga->irqdomain, bit)); ++ do { ++ pending = readl(fpga->base + FPGA_IRQ_SET_CLR) & fpga->irq_mask; ++ for_each_set_bit(bit, &pending, CPLDS_NB_IRQ) { ++ generic_handle_irq(irq_find_mapping(fpga->irqdomain, ++ bit)); ++ } ++ } while (pending); + + return IRQ_HANDLED; + } + +-static void cplds_irq_mask_ack(struct irq_data *d) ++static void cplds_irq_mask(struct irq_data *d) + { + struct cplds *fpga = irq_data_get_irq_chip_data(d); + unsigned int cplds_irq = irqd_to_hwirq(d); +- unsigned int set, bit = BIT(cplds_irq); ++ unsigned int bit = BIT(cplds_irq); + + fpga->irq_mask &= ~bit; + writel(fpga->irq_mask, fpga->base + FPGA_IRQ_MASK_EN); +- set = readl(fpga->base + FPGA_IRQ_SET_CLR); +- writel(set & ~bit, fpga->base + FPGA_IRQ_SET_CLR); + } + + static void cplds_irq_unmask(struct irq_data *d) + { + struct cplds *fpga = irq_data_get_irq_chip_data(d); + unsigned int cplds_irq = irqd_to_hwirq(d); +- unsigned int bit = BIT(cplds_irq); ++ unsigned int set, bit = BIT(cplds_irq); ++ ++ set = readl(fpga->base + FPGA_IRQ_SET_CLR); ++ writel(set & ~bit, fpga->base + FPGA_IRQ_SET_CLR); + + fpga->irq_mask |= bit; + writel(fpga->irq_mask, fpga->base + FPGA_IRQ_MASK_EN); +@@ -72,7 +77,8 @@ static void cplds_irq_unmask(struct irq_data *d) + + static struct irq_chip cplds_irq_chip = { + .name = "pxa_cplds", +- .irq_mask_ack = cplds_irq_mask_ack, ++ .irq_ack = cplds_irq_mask, ++ .irq_mask = cplds_irq_mask, + .irq_unmask = cplds_irq_unmask, + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, + }; +diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c +index 247a0dc012f1..c07bfb52275e 100644 +--- a/arch/powerpc/kernel/eeh_driver.c ++++ b/arch/powerpc/kernel/eeh_driver.c +@@ -909,6 +909,14 @@ static void eeh_handle_special_event(void) + /* Notify all devices to be down */ + eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); + bus = eeh_pe_bus_get(phb_pe); ++ if (!bus) { ++ pr_err("%s: Cannot find PCI bus for " ++ "PHB#%d-PE#%x\n", ++ __func__, ++ pe->phb->global_number, ++ pe->addr); ++ break; ++ } + eeh_pe_dev_traverse(pe, + eeh_report_failure, NULL); + pcibios_remove_pci_devices(bus); +diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c +index 32e26526f7e4..1eb698f653b4 100644 +--- a/arch/powerpc/kernel/nvram_64.c ++++ b/arch/powerpc/kernel/nvram_64.c +@@ -969,7 +969,7 @@ int __init nvram_remove_partition(const char *name, int sig, + + /* Make partition a free partition */ + part->header.signature = NVRAM_SIG_FREE; +- strncpy(part->header.name, "wwwwwwwwwwww", 12); ++ memset(part->header.name, 'w', 12); + part->header.checksum = nvram_checksum(&part->header); + rc = nvram_write_header(part); + if (rc <= 0) { +@@ -987,8 +987,8 @@ int __init nvram_remove_partition(const char *name, int sig, + } + if (prev) { + prev->header.length += part->header.length; +- prev->header.checksum = nvram_checksum(&part->header); +- rc = nvram_write_header(part); ++ prev->header.checksum = nvram_checksum(&prev->header); ++ rc = nvram_write_header(prev); + if (rc <= 0) { + printk(KERN_ERR "nvram_remove_partition: nvram_write failed (%d)\n", rc); + return rc; +diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c +index ba0cae69a396..92736851c795 100644 +--- a/arch/powerpc/platforms/powernv/eeh-powernv.c ++++ b/arch/powerpc/platforms/powernv/eeh-powernv.c +@@ -956,6 +956,11 @@ static int pnv_eeh_reset(struct eeh_pe *pe, int option) + } + + bus = eeh_pe_bus_get(pe); ++ if (!bus) { ++ pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n", ++ __func__, pe->phb->global_number, pe->addr); ++ return -EIO; ++ } + if (pci_is_root_bus(bus) || + pci_is_root_bus(bus->parent)) + ret = pnv_eeh_root_reset(hose, option); +diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h +index 189679aba703..f5063b6659eb 100644 +--- a/arch/x86/include/asm/asm.h ++++ b/arch/x86/include/asm/asm.h +@@ -44,19 +44,22 @@ + + /* Exception table entry */ + #ifdef __ASSEMBLY__ +-# define _ASM_EXTABLE(from,to) \ ++# define _ASM_EXTABLE_HANDLE(from, to, handler) \ + .pushsection "__ex_table","a" ; \ +- .balign 8 ; \ ++ .balign 4 ; \ + .long (from) - . ; \ + .long (to) - . ; \ ++ .long (handler) - . ; \ + .popsection + +-# define _ASM_EXTABLE_EX(from,to) \ +- .pushsection "__ex_table","a" ; \ +- .balign 8 ; \ +- .long (from) - . ; \ +- .long (to) - . + 0x7ffffff0 ; \ +- .popsection ++# define _ASM_EXTABLE(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) ++ ++# define _ASM_EXTABLE_FAULT(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) ++ ++# define _ASM_EXTABLE_EX(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) + + # define _ASM_NOKPROBE(entry) \ + .pushsection "_kprobe_blacklist","aw" ; \ +@@ -89,19 +92,24 @@ + .endm + + #else +-# define _ASM_EXTABLE(from,to) \ ++# define _EXPAND_EXTABLE_HANDLE(x) #x ++# define _ASM_EXTABLE_HANDLE(from, to, handler) \ + " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 8\n" \ ++ " .balign 4\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ ++ " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \ + " .popsection\n" + +-# define _ASM_EXTABLE_EX(from,to) \ +- " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 8\n" \ +- " .long (" #from ") - .\n" \ +- " .long (" #to ") - . + 0x7ffffff0\n" \ +- " .popsection\n" ++# define _ASM_EXTABLE(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) ++ ++# define _ASM_EXTABLE_FAULT(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) ++ ++# define _ASM_EXTABLE_EX(from, to) \ ++ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) ++ + /* For C file, we already have NOKPROBE_SYMBOL macro */ + #endif + +diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h +index d42252ce9b4d..3794c7331cfc 100644 +--- a/arch/x86/include/asm/uaccess.h ++++ b/arch/x86/include/asm/uaccess.h +@@ -90,12 +90,11 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + likely(!__range_not_ok(addr, size, user_addr_max())) + + /* +- * The exception table consists of pairs of addresses relative to the +- * exception table enty itself: the first is the address of an +- * instruction that is allowed to fault, and the second is the address +- * at which the program should continue. No registers are modified, +- * so it is entirely up to the continuation code to figure out what to +- * do. ++ * The exception table consists of triples of addresses relative to the ++ * exception table entry itself. The first address is of an instruction ++ * that is allowed to fault, the second is the target at which the program ++ * should continue. The third is a handler function to deal with the fault ++ * caused by the instruction in the first field. + * + * All the routines below use bits of fixup code that are out of line + * with the main instruction path. This means when everything is well, +@@ -104,13 +103,14 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + */ + + struct exception_table_entry { +- int insn, fixup; ++ int insn, fixup, handler; + }; + /* This is not the generic standard exception_table_entry format */ + #define ARCH_HAS_SORT_EXTABLE + #define ARCH_HAS_SEARCH_EXTABLE + +-extern int fixup_exception(struct pt_regs *regs); ++extern int fixup_exception(struct pt_regs *regs, int trapnr); ++extern bool ex_has_fault_handler(unsigned long ip); + extern int early_fixup_exception(unsigned long *ip); + + /* +diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c +index 9fdf1d330727..a257d6077d1b 100644 +--- a/arch/x86/kernel/early-quirks.c ++++ b/arch/x86/kernel/early-quirks.c +@@ -331,12 +331,11 @@ static u32 __init i85x_stolen_base(int num, int slot, int func, size_t stolen_si + + static u32 __init i865_stolen_base(int num, int slot, int func, size_t stolen_size) + { +- /* +- * FIXME is the graphics stolen memory region +- * always at TOUD? Ie. is it always the last +- * one to be allocated by the BIOS? +- */ +- return read_pci_config_16(0, 0, 0, I865_TOUD) << 16; ++ u16 toud = 0; ++ ++ toud = read_pci_config_16(0, 0, 0, I865_TOUD); ++ ++ return (phys_addr_t)(toud << 16) + i845_tseg_size(); + } + + static size_t __init i830_stolen_size(int num, int slot, int func) +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c +index 023c442c33bb..e1d1f6cbaf11 100644 +--- a/arch/x86/kernel/kprobes/core.c ++++ b/arch/x86/kernel/kprobes/core.c +@@ -1000,7 +1000,7 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) + * In case the user-specified fault handler returned + * zero, try to fix up. + */ +- if (fixup_exception(regs)) ++ if (fixup_exception(regs, trapnr)) + return 1; + + /* +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c +index 679302c312f8..5621f882645e 100644 +--- a/arch/x86/kernel/traps.c ++++ b/arch/x86/kernel/traps.c +@@ -199,7 +199,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, + } + + if (!user_mode(regs)) { +- if (!fixup_exception(regs)) { ++ if (!fixup_exception(regs, trapnr)) { + tsk->thread.error_code = error_code; + tsk->thread.trap_nr = trapnr; + die(str, regs, error_code); +@@ -453,7 +453,7 @@ do_general_protection(struct pt_regs *regs, long error_code) + + tsk = current; + if (!user_mode(regs)) { +- if (fixup_exception(regs)) ++ if (fixup_exception(regs, X86_TRAP_GP)) + return; + + tsk->thread.error_code = error_code; +@@ -699,7 +699,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) + conditional_sti(regs); + + if (!user_mode(regs)) { +- if (!fixup_exception(regs)) { ++ if (!fixup_exception(regs, trapnr)) { + task->thread.error_code = error_code; + task->thread.trap_nr = trapnr; + die(str, regs, error_code); +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c +index 903ec1e9c326..9dd7e4b7fcde 100644 +--- a/arch/x86/mm/extable.c ++++ b/arch/x86/mm/extable.c +@@ -3,6 +3,9 @@ + #include + #include + ++typedef bool (*ex_handler_t)(const struct exception_table_entry *, ++ struct pt_regs *, int); ++ + static inline unsigned long + ex_insn_addr(const struct exception_table_entry *x) + { +@@ -13,11 +16,56 @@ ex_fixup_addr(const struct exception_table_entry *x) + { + return (unsigned long)&x->fixup + x->fixup; + } ++static inline ex_handler_t ++ex_fixup_handler(const struct exception_table_entry *x) ++{ ++ return (ex_handler_t)((unsigned long)&x->handler + x->handler); ++} + +-int fixup_exception(struct pt_regs *regs) ++bool ex_handler_default(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) + { +- const struct exception_table_entry *fixup; +- unsigned long new_ip; ++ regs->ip = ex_fixup_addr(fixup); ++ return true; ++} ++EXPORT_SYMBOL(ex_handler_default); ++ ++bool ex_handler_fault(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) ++{ ++ regs->ip = ex_fixup_addr(fixup); ++ regs->ax = trapnr; ++ return true; ++} ++EXPORT_SYMBOL_GPL(ex_handler_fault); ++ ++bool ex_handler_ext(const struct exception_table_entry *fixup, ++ struct pt_regs *regs, int trapnr) ++{ ++ /* Special hack for uaccess_err */ ++ current_thread_info()->uaccess_err = 1; ++ regs->ip = ex_fixup_addr(fixup); ++ return true; ++} ++EXPORT_SYMBOL(ex_handler_ext); ++ ++bool ex_has_fault_handler(unsigned long ip) ++{ ++ const struct exception_table_entry *e; ++ ex_handler_t handler; ++ ++ e = search_exception_tables(ip); ++ if (!e) ++ return false; ++ handler = ex_fixup_handler(e); ++ ++ return handler == ex_handler_fault; ++} ++ ++int fixup_exception(struct pt_regs *regs, int trapnr) ++{ ++ const struct exception_table_entry *e; ++ ex_handler_t handler; + + #ifdef CONFIG_PNPBIOS + if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) { +@@ -33,42 +81,34 @@ int fixup_exception(struct pt_regs *regs) + } + #endif + +- fixup = search_exception_tables(regs->ip); +- if (fixup) { +- new_ip = ex_fixup_addr(fixup); +- +- if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { +- /* Special hack for uaccess_err */ +- current_thread_info()->uaccess_err = 1; +- new_ip -= 0x7ffffff0; +- } +- regs->ip = new_ip; +- return 1; +- } ++ e = search_exception_tables(regs->ip); ++ if (!e) ++ return 0; + +- return 0; ++ handler = ex_fixup_handler(e); ++ return handler(e, regs, trapnr); + } + + /* Restricted version used during very early boot */ + int __init early_fixup_exception(unsigned long *ip) + { +- const struct exception_table_entry *fixup; ++ const struct exception_table_entry *e; + unsigned long new_ip; ++ ex_handler_t handler; + +- fixup = search_exception_tables(*ip); +- if (fixup) { +- new_ip = ex_fixup_addr(fixup); ++ e = search_exception_tables(*ip); ++ if (!e) ++ return 0; + +- if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { +- /* uaccess handling not supported during early boot */ +- return 0; +- } ++ new_ip = ex_fixup_addr(e); ++ handler = ex_fixup_handler(e); + +- *ip = new_ip; +- return 1; +- } ++ /* special handling not supported during early boot */ ++ if (handler != ex_handler_default) ++ return 0; + +- return 0; ++ *ip = new_ip; ++ return 1; + } + + /* +@@ -133,6 +173,8 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup += i; + i += 4; ++ p->handler += i; ++ i += 4; + } + + sort(start, finish - start, sizeof(struct exception_table_entry), +@@ -145,6 +187,8 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup -= i; + i += 4; ++ p->handler -= i; ++ i += 4; + } + } + +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c +index e830c71a1323..03898aea6e0f 100644 +--- a/arch/x86/mm/fault.c ++++ b/arch/x86/mm/fault.c +@@ -663,7 +663,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, + int sig; + + /* Are we prepared to handle this kernel fault? */ +- if (fixup_exception(regs)) { ++ if (fixup_exception(regs, X86_TRAP_PF)) { + /* + * Any interrupt that takes a fault gets the fixup. This makes + * the below recursive fault logic only apply to a faults from +diff --git a/crypto/gcm.c b/crypto/gcm.c +index d9ea5f9c0574..1238b3c5a321 100644 +--- a/crypto/gcm.c ++++ b/crypto/gcm.c +@@ -117,7 +117,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, + struct crypto_ablkcipher *ctr = ctx->ctr; + struct { + be128 hash; +- u8 iv[8]; ++ u8 iv[16]; + + struct crypto_gcm_setkey_result result; + +diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c +index 01d4be2c354b..f5c26a5f6875 100644 +--- a/drivers/char/hw_random/omap-rng.c ++++ b/drivers/char/hw_random/omap-rng.c +@@ -385,7 +385,7 @@ static int omap_rng_probe(struct platform_device *pdev) + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); +- if (ret) { ++ if (ret < 0) { + dev_err(&pdev->dev, "Failed to runtime_get device: %d\n", ret); + pm_runtime_put_noidle(&pdev->dev); + goto err_ioremap; +@@ -443,7 +443,7 @@ static int __maybe_unused omap_rng_resume(struct device *dev) + int ret; + + ret = pm_runtime_get_sync(dev); +- if (ret) { ++ if (ret < 0) { + dev_err(dev, "Failed to runtime_get device: %d\n", ret); + pm_runtime_put_noidle(dev); + return ret; +diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c +index bbf206e3da0d..ac9582de64a5 100644 +--- a/drivers/clk/clk-divider.c ++++ b/drivers/clk/clk-divider.c +@@ -354,7 +354,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, + + /* if read only, just return current value */ + if (divider->flags & CLK_DIVIDER_READ_ONLY) { +- bestdiv = readl(divider->reg) >> divider->shift; ++ bestdiv = clk_readl(divider->reg) >> divider->shift; + bestdiv &= div_mask(divider->width); + bestdiv = _get_div(divider->table, bestdiv, divider->flags, + divider->width); +diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c +index 7bc1c4527ae4..8b77abb6bc22 100644 +--- a/drivers/clk/clk-qoriq.c ++++ b/drivers/clk/clk-qoriq.c +@@ -766,7 +766,11 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx) + if (!hwc) + return NULL; + +- hwc->reg = cg->regs + 0x20 * idx; ++ if (cg->info.flags & CG_VER3) ++ hwc->reg = cg->regs + 0x70000 + 0x20 * idx; ++ else ++ hwc->reg = cg->regs + 0x20 * idx; ++ + hwc->info = cg->info.cmux_groups[cg->info.cmux_to_group[idx]]; + + /* +diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c +index b0978d3b83e2..d302ed3b8225 100644 +--- a/drivers/clk/imx/clk-imx35.c ++++ b/drivers/clk/imx/clk-imx35.c +@@ -115,7 +115,7 @@ static void __init _mx35_clocks_init(void) + } + + clk[ckih] = imx_clk_fixed("ckih", 24000000); +- clk[ckil] = imx_clk_fixed("ckih", 32768); ++ clk[ckil] = imx_clk_fixed("ckil", 32768); + clk[mpll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "mpll", "ckih", base + MX35_CCM_MPCTL); + clk[ppll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "ppll", "ckih", base + MX35_CCM_PPCTL); + +diff --git a/drivers/dma/ipu/ipu_irq.c b/drivers/dma/ipu/ipu_irq.c +index 2bf37e68ad0f..dd184b50e5b4 100644 +--- a/drivers/dma/ipu/ipu_irq.c ++++ b/drivers/dma/ipu/ipu_irq.c +@@ -286,22 +286,21 @@ static void ipu_irq_handler(struct irq_desc *desc) + raw_spin_unlock(&bank_lock); + while ((line = ffs(status))) { + struct ipu_irq_map *map; +- unsigned int irq = NO_IRQ; ++ unsigned int irq; + + line--; + status &= ~(1UL << line); + + raw_spin_lock(&bank_lock); + map = src2map(32 * i + line); +- if (map) +- irq = map->irq; +- raw_spin_unlock(&bank_lock); +- + if (!map) { ++ raw_spin_unlock(&bank_lock); + pr_err("IPU: Interrupt on unmapped source %u bank %d\n", + line, i); + continue; + } ++ irq = map->irq; ++ raw_spin_unlock(&bank_lock); + generic_handle_irq(irq); + } + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +index fe36caf1b7d7..14f57d9915e3 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +@@ -113,24 +113,26 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev, + printk("\n"); + } + ++ + u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev) + { + struct drm_device *dev = adev->ddev; + struct drm_crtc *crtc; + struct amdgpu_crtc *amdgpu_crtc; +- u32 line_time_us, vblank_lines; ++ u32 vblank_in_pixels; + u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ + + if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + amdgpu_crtc = to_amdgpu_crtc(crtc); + if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { +- line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) / +- amdgpu_crtc->hw_mode.clock; +- vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end - ++ vblank_in_pixels = ++ amdgpu_crtc->hw_mode.crtc_htotal * ++ (amdgpu_crtc->hw_mode.crtc_vblank_end - + amdgpu_crtc->hw_mode.crtc_vdisplay + +- (amdgpu_crtc->v_border * 2); +- vblank_time_us = vblank_lines * line_time_us; ++ (amdgpu_crtc->v_border * 2)); ++ ++ vblank_time_us = vblank_in_pixels * 1000 / amdgpu_crtc->hw_mode.clock; + break; + } + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +index 4488e82f87b0..a5c824078472 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +@@ -227,7 +227,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file + type = AMD_IP_BLOCK_TYPE_UVD; + ring_mask = adev->uvd.ring.ready ? 1 : 0; + ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; +- ib_size_alignment = 8; ++ ib_size_alignment = 16; + break; + case AMDGPU_HW_IP_VCE: + type = AMD_IP_BLOCK_TYPE_VCE; +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +index 4dcc8fba5792..5b261adb4b69 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +@@ -419,16 +419,6 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } +- + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + idx = 0; +@@ -452,6 +442,19 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) + continue; + } + ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ tmp = RREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx]); ++ tmp = REG_SET_FIELD(tmp, DC_HPD_INT_CONTROL, DC_HPD_INT_EN, 0); ++ WREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx], tmp); ++ continue; ++ } ++ + tmp = RREG32(mmDC_HPD_CONTROL + hpd_offsets[idx]); + tmp = REG_SET_FIELD(tmp, DC_HPD_CONTROL, DC_HPD_EN, 1); + WREG32(mmDC_HPD_CONTROL + hpd_offsets[idx], tmp); +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +index 8f1e51128b33..c161eeda417b 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +@@ -409,16 +409,6 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } +- + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + idx = 0; +@@ -442,6 +432,19 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) + continue; + } + ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ tmp = RREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx]); ++ tmp = REG_SET_FIELD(tmp, DC_HPD_INT_CONTROL, DC_HPD_INT_EN, 0); ++ WREG32(mmDC_HPD_INT_CONTROL + hpd_offsets[idx], tmp); ++ continue; ++ } ++ + tmp = RREG32(mmDC_HPD_CONTROL + hpd_offsets[idx]); + tmp = REG_SET_FIELD(tmp, DC_HPD_CONTROL, DC_HPD_EN, 1); + WREG32(mmDC_HPD_CONTROL + hpd_offsets[idx], tmp); +@@ -3030,6 +3033,7 @@ static int dce_v11_0_sw_fini(void *handle) + + dce_v11_0_afmt_fini(adev); + ++ drm_mode_config_cleanup(adev->ddev); + adev->mode_info.mode_config_initialized = false; + + return 0; +diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +index 42d954dc436d..9b4dcf76ce6c 100644 +--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +@@ -392,15 +392,6 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + +- if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || +- connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { +- /* don't try to enable hpd on eDP or LVDS avoid breaking the +- * aux dp channel on imac and help (but not completely fix) +- * https://bugzilla.redhat.com/show_bug.cgi?id=726143 +- * also avoid interrupt storms during dpms. +- */ +- continue; +- } + switch (amdgpu_connector->hpd.hpd) { + case AMDGPU_HPD_1: + WREG32(mmDC_HPD1_CONTROL, tmp); +@@ -423,6 +414,45 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) + default: + break; + } ++ ++ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || ++ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { ++ /* don't try to enable hpd on eDP or LVDS avoid breaking the ++ * aux dp channel on imac and help (but not completely fix) ++ * https://bugzilla.redhat.com/show_bug.cgi?id=726143 ++ * also avoid interrupt storms during dpms. ++ */ ++ u32 dc_hpd_int_cntl_reg, dc_hpd_int_cntl; ++ ++ switch (amdgpu_connector->hpd.hpd) { ++ case AMDGPU_HPD_1: ++ dc_hpd_int_cntl_reg = mmDC_HPD1_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_2: ++ dc_hpd_int_cntl_reg = mmDC_HPD2_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_3: ++ dc_hpd_int_cntl_reg = mmDC_HPD3_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_4: ++ dc_hpd_int_cntl_reg = mmDC_HPD4_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_5: ++ dc_hpd_int_cntl_reg = mmDC_HPD5_INT_CONTROL; ++ break; ++ case AMDGPU_HPD_6: ++ dc_hpd_int_cntl_reg = mmDC_HPD6_INT_CONTROL; ++ break; ++ default: ++ continue; ++ } ++ ++ dc_hpd_int_cntl = RREG32(dc_hpd_int_cntl_reg); ++ dc_hpd_int_cntl &= ~DC_HPD1_INT_CONTROL__DC_HPD1_INT_EN_MASK; ++ WREG32(dc_hpd_int_cntl_reg, dc_hpd_int_cntl); ++ continue; ++ } ++ + dce_v8_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); + amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); + } +diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c +index 9f935f55d74c..968b31f39884 100644 +--- a/drivers/gpu/drm/drm_prime.c ++++ b/drivers/gpu/drm/drm_prime.c +@@ -339,14 +339,17 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { + * using the PRIME helpers. + */ + struct dma_buf *drm_gem_prime_export(struct drm_device *dev, +- struct drm_gem_object *obj, int flags) ++ struct drm_gem_object *obj, ++ int flags) + { +- DEFINE_DMA_BUF_EXPORT_INFO(exp_info); +- +- exp_info.ops = &drm_gem_prime_dmabuf_ops; +- exp_info.size = obj->size; +- exp_info.flags = flags; +- exp_info.priv = obj; ++ struct dma_buf_export_info exp_info = { ++ .exp_name = KBUILD_MODNAME, /* white lie for debug */ ++ .owner = dev->driver->fops->owner, ++ .ops = &drm_gem_prime_dmabuf_ops, ++ .size = obj->size, ++ .flags = flags, ++ .priv = obj, ++ }; + + if (dev->driver->gem_prime_res_obj) + exp_info.resv = dev->driver->gem_prime_res_obj(obj); +diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h +index d400d6773bbb..fb9f647bb5cd 100644 +--- a/drivers/gpu/drm/i915/i915_drv.h ++++ b/drivers/gpu/drm/i915/i915_drv.h +@@ -2150,21 +2150,19 @@ struct drm_i915_gem_object { + /** Record of address bit 17 of each page at last unbind. */ + unsigned long *bit_17; + +- union { +- /** for phy allocated objects */ +- struct drm_dma_handle *phys_handle; +- +- struct i915_gem_userptr { +- uintptr_t ptr; +- unsigned read_only :1; +- unsigned workers :4; ++ struct i915_gem_userptr { ++ uintptr_t ptr; ++ unsigned read_only :1; ++ unsigned workers :4; + #define I915_GEM_USERPTR_MAX_WORKERS 15 + +- struct i915_mm_struct *mm; +- struct i915_mmu_object *mmu_object; +- struct work_struct *work; +- } userptr; +- }; ++ struct i915_mm_struct *mm; ++ struct i915_mmu_object *mmu_object; ++ struct work_struct *work; ++ } userptr; ++ ++ /** for phys allocated objects */ ++ struct drm_dma_handle *phys_handle; + }; + #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base) + +diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c +index 87e919a06b27..5d2323a40c25 100644 +--- a/drivers/gpu/drm/i915/i915_gem_stolen.c ++++ b/drivers/gpu/drm/i915/i915_gem_stolen.c +@@ -108,17 +108,28 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) + pci_read_config_dword(dev->pdev, 0x5c, &base); + base &= ~((1<<20) - 1); + } else if (IS_I865G(dev)) { ++ u32 tseg_size = 0; + u16 toud = 0; ++ u8 tmp; ++ ++ pci_bus_read_config_byte(dev->pdev->bus, PCI_DEVFN(0, 0), ++ I845_ESMRAMC, &tmp); ++ ++ if (tmp & TSEG_ENABLE) { ++ switch (tmp & I845_TSEG_SIZE_MASK) { ++ case I845_TSEG_SIZE_512K: ++ tseg_size = KB(512); ++ break; ++ case I845_TSEG_SIZE_1M: ++ tseg_size = MB(1); ++ break; ++ } ++ } + +- /* +- * FIXME is the graphics stolen memory region +- * always at TOUD? Ie. is it always the last +- * one to be allocated by the BIOS? +- */ + pci_bus_read_config_word(dev->pdev->bus, PCI_DEVFN(0, 0), + I865_TOUD, &toud); + +- base = toud << 16; ++ base = (toud << 16) + tseg_size; + } else if (IS_I85X(dev)) { + u32 tseg_size = 0; + u32 tom; +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c +index ebbd23407a80..0f8367da0663 100644 +--- a/drivers/gpu/drm/i915/intel_dp.c ++++ b/drivers/gpu/drm/i915/intel_dp.c +@@ -4648,7 +4648,7 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, + * + * Return %true if @port is connected, %false otherwise. + */ +-bool intel_digital_port_connected(struct drm_i915_private *dev_priv, ++static bool intel_digital_port_connected(struct drm_i915_private *dev_priv, + struct intel_digital_port *port) + { + if (HAS_PCH_IBX(dev_priv)) +diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h +index 41442e619595..722aa159cd28 100644 +--- a/drivers/gpu/drm/i915/intel_drv.h ++++ b/drivers/gpu/drm/i915/intel_drv.h +@@ -1231,8 +1231,6 @@ void intel_edp_drrs_disable(struct intel_dp *intel_dp); + void intel_edp_drrs_invalidate(struct drm_device *dev, + unsigned frontbuffer_bits); + void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits); +-bool intel_digital_port_connected(struct drm_i915_private *dev_priv, +- struct intel_digital_port *port); + void hsw_dp_set_ddi_pll_sel(struct intel_crtc_state *pipe_config); + + /* intel_dp_mst.c */ +diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c +index dff69fef47e0..3b92cad8bef2 100644 +--- a/drivers/gpu/drm/i915/intel_hdmi.c ++++ b/drivers/gpu/drm/i915/intel_hdmi.c +@@ -1331,19 +1331,18 @@ intel_hdmi_unset_edid(struct drm_connector *connector) + } + + static bool +-intel_hdmi_set_edid(struct drm_connector *connector, bool force) ++intel_hdmi_set_edid(struct drm_connector *connector) + { + struct drm_i915_private *dev_priv = to_i915(connector->dev); + struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); +- struct edid *edid = NULL; ++ struct edid *edid; + bool connected = false; + + intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); + +- if (force) +- edid = drm_get_edid(connector, +- intel_gmbus_get_adapter(dev_priv, +- intel_hdmi->ddc_bus)); ++ edid = drm_get_edid(connector, ++ intel_gmbus_get_adapter(dev_priv, ++ intel_hdmi->ddc_bus)); + + intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS); + +@@ -1371,37 +1370,16 @@ static enum drm_connector_status + intel_hdmi_detect(struct drm_connector *connector, bool force) + { + enum drm_connector_status status; +- struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); + struct drm_i915_private *dev_priv = to_i915(connector->dev); +- bool live_status = false; +- unsigned int try; + + DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", + connector->base.id, connector->name); + + intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); + +- for (try = 0; !live_status && try < 9; try++) { +- if (try) +- msleep(10); +- live_status = intel_digital_port_connected(dev_priv, +- hdmi_to_dig_port(intel_hdmi)); +- } +- +- if (!live_status) { +- DRM_DEBUG_KMS("HDMI live status down\n"); +- /* +- * Live status register is not reliable on all intel platforms. +- * So consider live_status only for certain platforms, for +- * others, read EDID to determine presence of sink. +- */ +- if (INTEL_INFO(dev_priv)->gen < 7 || IS_IVYBRIDGE(dev_priv)) +- live_status = true; +- } +- + intel_hdmi_unset_edid(connector); + +- if (intel_hdmi_set_edid(connector, live_status)) { ++ if (intel_hdmi_set_edid(connector)) { + struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); + + hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; +@@ -1427,7 +1405,7 @@ intel_hdmi_force(struct drm_connector *connector) + if (connector->status != connector_status_connected) + return; + +- intel_hdmi_set_edid(connector, true); ++ intel_hdmi_set_edid(connector); + hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; + } + +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c +index 1e851e037c29..3f802163f7d4 100644 +--- a/drivers/gpu/drm/i915/intel_pm.c ++++ b/drivers/gpu/drm/i915/intel_pm.c +@@ -2097,32 +2097,34 @@ static void intel_read_wm_latency(struct drm_device *dev, uint16_t wm[8]) + GEN9_MEM_LATENCY_LEVEL_MASK; + + /* ++ * If a level n (n > 1) has a 0us latency, all levels m (m >= n) ++ * need to be disabled. We make sure to sanitize the values out ++ * of the punit to satisfy this requirement. ++ */ ++ for (level = 1; level <= max_level; level++) { ++ if (wm[level] == 0) { ++ for (i = level + 1; i <= max_level; i++) ++ wm[i] = 0; ++ break; ++ } ++ } ++ ++ /* + * WaWmMemoryReadLatency:skl + * + * punit doesn't take into account the read latency so we need +- * to add 2us to the various latency levels we retrieve from +- * the punit. +- * - W0 is a bit special in that it's the only level that +- * can't be disabled if we want to have display working, so +- * we always add 2us there. +- * - For levels >=1, punit returns 0us latency when they are +- * disabled, so we respect that and don't add 2us then +- * +- * Additionally, if a level n (n > 1) has a 0us latency, all +- * levels m (m >= n) need to be disabled. We make sure to +- * sanitize the values out of the punit to satisfy this +- * requirement. ++ * to add 2us to the various latency levels we retrieve from the ++ * punit when level 0 response data us 0us. + */ +- wm[0] += 2; +- for (level = 1; level <= max_level; level++) +- if (wm[level] != 0) ++ if (wm[0] == 0) { ++ wm[0] += 2; ++ for (level = 1; level <= max_level; level++) { ++ if (wm[level] == 0) ++ break; + wm[level] += 2; +- else { +- for (i = level + 1; i <= max_level; i++) +- wm[i] = 0; +- +- break; + } ++ } ++ + } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { + uint64_t sskpd = I915_READ64(MCH_SSKPD); + +diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c +index fa2154493cf1..470af4aa4a6a 100644 +--- a/drivers/gpu/drm/radeon/r600_dpm.c ++++ b/drivers/gpu/drm/radeon/r600_dpm.c +@@ -156,19 +156,20 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev) + struct drm_device *dev = rdev->ddev; + struct drm_crtc *crtc; + struct radeon_crtc *radeon_crtc; +- u32 line_time_us, vblank_lines; ++ u32 vblank_in_pixels; + u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ + + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + radeon_crtc = to_radeon_crtc(crtc); + if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { +- line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / +- radeon_crtc->hw_mode.clock; +- vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - +- radeon_crtc->hw_mode.crtc_vdisplay + +- (radeon_crtc->v_border * 2); +- vblank_time_us = vblank_lines * line_time_us; ++ vblank_in_pixels = ++ radeon_crtc->hw_mode.crtc_htotal * ++ (radeon_crtc->hw_mode.crtc_vblank_end - ++ radeon_crtc->hw_mode.crtc_vdisplay + ++ (radeon_crtc->v_border * 2)); ++ ++ vblank_time_us = vblank_in_pixels * 1000 / radeon_crtc->hw_mode.clock; + break; + } + } +diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c +index e2dd5d19c32c..4aa2cbe4c85f 100644 +--- a/drivers/gpu/drm/radeon/radeon_device.c ++++ b/drivers/gpu/drm/radeon/radeon_device.c +@@ -660,8 +660,9 @@ bool radeon_card_posted(struct radeon_device *rdev) + { + uint32_t reg; + +- /* for pass through, always force asic_init */ +- if (radeon_device_is_virtual()) ++ /* for pass through, always force asic_init for CI */ ++ if (rdev->family >= CHIP_BONAIRE && ++ radeon_device_is_virtual()) + return false; + + /* required for EFI mode on macbook2,1 which uses an r5xx asic */ +diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c +index 3aaa07dafc00..472e0771832e 100644 +--- a/drivers/gpu/drm/radeon/si_dpm.c ++++ b/drivers/gpu/drm/radeon/si_dpm.c +@@ -4112,7 +4112,7 @@ static int si_populate_smc_voltage_tables(struct radeon_device *rdev, + &rdev->pm.dpm.dyn_state.phase_shedding_limits_table)) { + si_populate_smc_voltage_table(rdev, &si_pi->vddc_phase_shed_table, table); + +- table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] = ++ table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] = + cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low); + + si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_phase_shedding_delay, +diff --git a/drivers/gpu/drm/radeon/sislands_smc.h b/drivers/gpu/drm/radeon/sislands_smc.h +index 3c779838d9ab..966e3a556011 100644 +--- a/drivers/gpu/drm/radeon/sislands_smc.h ++++ b/drivers/gpu/drm/radeon/sislands_smc.h +@@ -194,6 +194,7 @@ typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE; + #define SISLANDS_SMC_VOLTAGEMASK_VDDC 0 + #define SISLANDS_SMC_VOLTAGEMASK_MVDD 1 + #define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2 ++#define SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING 3 + #define SISLANDS_SMC_VOLTAGEMASK_MAX 4 + + struct SISLANDS_SMC_VOLTAGEMASKTABLE +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +index 4948c1529836..ecf15cf0c3fd 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +@@ -3830,14 +3830,14 @@ static void *vmw_execbuf_cmdbuf(struct vmw_private *dev_priv, + int ret; + + *header = NULL; +- if (!dev_priv->cman || kernel_commands) +- return kernel_commands; +- + if (command_size > SVGA_CB_MAX_SIZE) { + DRM_ERROR("Command buffer is too large.\n"); + return ERR_PTR(-EINVAL); + } + ++ if (!dev_priv->cman || kernel_commands) ++ return kernel_commands; ++ + /* If possible, add a little space for fencing. */ + cmdbuf_size = command_size + 512; + cmdbuf_size = min_t(size_t, cmdbuf_size, SVGA_CB_MAX_SIZE); +diff --git a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c +index 71493d2af912..70a6985334d5 100644 +--- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c +@@ -4102,7 +4102,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, + (u8 *)&settings->beacon.head[ie_offset], + settings->beacon.head_len - ie_offset, + WLAN_EID_SSID); +- if (!ssid_ie) ++ if (!ssid_ie || ssid_ie->len > IEEE80211_MAX_SSID_LEN) + return -EINVAL; + + memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len); +diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c +index 3cda1f956f0b..6378dfd3b4e8 100644 +--- a/drivers/net/wireless/mwifiex/join.c ++++ b/drivers/net/wireless/mwifiex/join.c +@@ -661,9 +661,8 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, + priv->assoc_rsp_size = min(le16_to_cpu(resp->size) - S_DS_GEN, + sizeof(priv->assoc_rsp_buf)); + +- memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); +- + assoc_rsp->a_id = cpu_to_le16(aid); ++ memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); + + if (status_code) { + priv->adapter->dbg.num_cmd_assoc_failure++; +diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c +index 1fea2c7ef97f..6fc31bdc639b 100644 +--- a/drivers/power/bq24257_charger.c ++++ b/drivers/power/bq24257_charger.c +@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client, + return ret; + } + ++ ret = bq24257_power_supply_init(bq); ++ if (ret < 0) { ++ dev_err(dev, "Failed to register power supply\n"); ++ return ret; ++ } ++ + ret = devm_request_threaded_irq(dev, client->irq, NULL, + bq24257_irq_handler_thread, + IRQF_TRIGGER_FALLING | +@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client, + return ret; + } + +- ret = bq24257_power_supply_init(bq); +- if (ret < 0) { +- dev_err(dev, "Failed to register power supply\n"); +- return ret; +- } +- + ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group); + if (ret < 0) { + dev_err(dev, "Can't create sysfs entries\n"); +diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c +index 7c511add5aa7..bae98521c808 100644 +--- a/drivers/s390/char/con3270.c ++++ b/drivers/s390/char/con3270.c +@@ -124,7 +124,12 @@ con3270_create_status(struct con3270 *cp) + static void + con3270_update_string(struct con3270 *cp, struct string *s, int nr) + { +- if (s->len >= cp->view.cols - 5) ++ if (s->len < 4) { ++ /* This indicates a bug, but printing a warning would ++ * cause a deadlock. */ ++ return; ++ } ++ if (s->string[s->len - 4] != TO_RA) + return; + raw3270_buffer_address(cp->view.dev, s->string + s->len - 3, + cp->view.cols * (nr + 1)); +@@ -461,11 +466,11 @@ con3270_cline_end(struct con3270 *cp) + cp->cline->len + 4 : cp->view.cols; + s = con3270_alloc_string(cp, size); + memcpy(s->string, cp->cline->string, cp->cline->len); +- if (s->len < cp->view.cols - 5) { ++ if (cp->cline->len < cp->view.cols - 5) { + s->string[s->len - 4] = TO_RA; + s->string[s->len - 1] = 0; + } else { +- while (--size > cp->cline->len) ++ while (--size >= cp->cline->len) + s->string[size] = cp->view.ascebc[' ']; + } + /* Replace cline with allocated line s and reset cline. */ +diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c +index c424c0c7367e..1e16331891a9 100644 +--- a/drivers/s390/cio/chsc.c ++++ b/drivers/s390/cio/chsc.c +@@ -95,12 +95,13 @@ struct chsc_ssd_area { + int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) + { + struct chsc_ssd_area *ssd_area; ++ unsigned long flags; + int ccode; + int ret; + int i; + int mask; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + ssd_area = chsc_page; + ssd_area->request.length = 0x0010; +@@ -144,7 +145,7 @@ int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) + ssd->fla[i] = ssd_area->fla[i]; + } + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -832,9 +833,10 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable) + u32 fmt : 4; + u32 : 16; + } __attribute__ ((packed)) *secm_area; ++ unsigned long flags; + int ret, ccode; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + secm_area = chsc_page; + secm_area->request.length = 0x0050; +@@ -864,7 +866,7 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable) + CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n", + secm_area->response.code); + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -993,6 +995,7 @@ chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, + + int chsc_get_channel_measurement_chars(struct channel_path *chp) + { ++ unsigned long flags; + int ccode, ret; + + struct { +@@ -1022,7 +1025,7 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) + if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm) + return 0; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + scmc_area = chsc_page; + scmc_area->request.length = 0x0010; +@@ -1054,7 +1057,7 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) + chsc_initialize_cmg_chars(chp, scmc_area->cmcv, + (struct cmg_chars *) &scmc_area->data); + out: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return ret; + } + +@@ -1135,6 +1138,7 @@ struct css_chsc_char css_chsc_characteristics; + int __init + chsc_determine_css_characteristics(void) + { ++ unsigned long flags; + int result; + struct { + struct chsc_header request; +@@ -1147,7 +1151,7 @@ chsc_determine_css_characteristics(void) + u32 chsc_char[508]; + } __attribute__ ((packed)) *scsc_area; + +- spin_lock_irq(&chsc_page_lock); ++ spin_lock_irqsave(&chsc_page_lock, flags); + memset(chsc_page, 0, PAGE_SIZE); + scsc_area = chsc_page; + scsc_area->request.length = 0x0010; +@@ -1169,7 +1173,7 @@ chsc_determine_css_characteristics(void) + CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n", + scsc_area->response.code); + exit: +- spin_unlock_irq(&chsc_page_lock); ++ spin_unlock_irqrestore(&chsc_page_lock, flags); + return result; + } + +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c +index 6180f7970bbf..0969cea1089a 100644 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c +@@ -4510,7 +4510,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) + le16_to_cpu(mpi_reply->DevHandle)); + mpt3sas_trigger_scsi(ioc, data.skey, data.asc, data.ascq); + +- if (!(ioc->logging_level & MPT_DEBUG_REPLY) && ++ if ((ioc->logging_level & MPT_DEBUG_REPLY) && + ((scmd->sense_buffer[2] == UNIT_ATTENTION) || + (scmd->sense_buffer[2] == MEDIUM_ERROR) || + (scmd->sense_buffer[2] == HARDWARE_ERROR))) +diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c +index 39412c9097c6..a3965cac1b34 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -753,7 +753,6 @@ static int dspi_remove(struct platform_device *pdev) + /* Disconnect from the SPI framework */ + clk_disable_unprepare(dspi->clk); + spi_unregister_master(dspi->master); +- spi_master_put(dspi->master); + + return 0; + } +diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c +index 9b7026e7d55b..45d0a87f55d2 100644 +--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c ++++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c +@@ -718,13 +718,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) + u8 res = _SUCCESS; + + +- ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); ++ ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + +- paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); ++ paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); + if (paddbareq_parm == NULL) { + kfree(ph2c); + res = _FAIL; +diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c +index 915facbf552e..e1134a4d97f3 100644 +--- a/drivers/uio/uio_dmem_genirq.c ++++ b/drivers/uio/uio_dmem_genirq.c +@@ -229,7 +229,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev) + ++uiomem; + } + +- priv->dmem_region_start = i; ++ priv->dmem_region_start = uiomem - &uioinfo->mem[0]; + priv->num_dmem_regions = pdata->num_dynamic_regions; + + for (i = 0; i < pdata->num_dynamic_regions; ++i) { +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c +index 531e76474983..0e0eb10f82a0 100644 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c +@@ -316,7 +316,7 @@ static int xenbus_write_transaction(unsigned msg_type, + rc = -ENOMEM; + goto out; + } +- } else { ++ } else if (msg_type == XS_TRANSACTION_END) { + list_for_each_entry(trans, &u->transactions, list) + if (trans->handle.id == u->u.msg.tx_id) + break; +diff --git a/fs/9p/acl.c b/fs/9p/acl.c +index a7e28890f5ef..929b618da43b 100644 +--- a/fs/9p/acl.c ++++ b/fs/9p/acl.c +@@ -282,32 +282,26 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler, + switch (handler->flags) { + case ACL_TYPE_ACCESS: + if (acl) { +- umode_t mode = inode->i_mode; +- retval = posix_acl_equiv_mode(acl, &mode); +- if (retval < 0) ++ struct iattr iattr; ++ ++ retval = posix_acl_update_mode(inode, &iattr.ia_mode, &acl); ++ if (retval) + goto err_out; +- else { +- struct iattr iattr; +- if (retval == 0) { +- /* +- * ACL can be represented +- * by the mode bits. So don't +- * update ACL. +- */ +- acl = NULL; +- value = NULL; +- size = 0; +- } +- /* Updte the mode bits */ +- iattr.ia_mode = ((mode & S_IALLUGO) | +- (inode->i_mode & ~S_IALLUGO)); +- iattr.ia_valid = ATTR_MODE; +- /* FIXME should we update ctime ? +- * What is the following setxattr update the +- * mode ? ++ if (!acl) { ++ /* ++ * ACL can be represented ++ * by the mode bits. So don't ++ * update ACL. + */ +- v9fs_vfs_setattr_dotl(dentry, &iattr); ++ value = NULL; ++ size = 0; + } ++ iattr.ia_valid = ATTR_MODE; ++ /* FIXME should we update ctime ? ++ * What is the following setxattr update the ++ * mode ? ++ */ ++ v9fs_vfs_setattr_dotl(dentry, &iattr); + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c +index 9a0124a95851..fb3e64d37cb4 100644 +--- a/fs/btrfs/acl.c ++++ b/fs/btrfs/acl.c +@@ -83,11 +83,9 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans, + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- ret = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (ret < 0) ++ ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (ret) + return ret; +- if (ret == 0) +- acl = NULL; + } + ret = 0; + break; +diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c +index 8f84646f10e9..4d8caeb94a11 100644 +--- a/fs/ceph/acl.c ++++ b/fs/ceph/acl.c +@@ -94,11 +94,9 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- ret = posix_acl_equiv_mode(acl, &new_mode); +- if (ret < 0) ++ ret = posix_acl_update_mode(inode, &new_mode, &acl); ++ if (ret) + goto out; +- if (ret == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c +index 27695e6f4e46..d6aeb84e90b6 100644 +--- a/fs/ext2/acl.c ++++ b/fs/ext2/acl.c +@@ -193,15 +193,11 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- inode->i_ctime = CURRENT_TIME_SEC; +- mark_inode_dirty(inode); +- if (error == 0) +- acl = NULL; +- } ++ inode->i_ctime = CURRENT_TIME_SEC; ++ mark_inode_dirty(inode); + } + break; + +diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c +index 69b1e73026a5..c3fe1e323951 100644 +--- a/fs/ext4/acl.c ++++ b/fs/ext4/acl.c +@@ -196,15 +196,11 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type, + case ACL_TYPE_ACCESS: + name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- inode->i_ctime = ext4_current_time(inode); +- ext4_mark_inode_dirty(handle, inode); +- if (error == 0) +- acl = NULL; +- } ++ inode->i_ctime = ext4_current_time(inode); ++ ext4_mark_inode_dirty(handle, inode); + } + break; + +diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c +index c8f25f7241f0..e9a8d676c6bc 100644 +--- a/fs/f2fs/acl.c ++++ b/fs/f2fs/acl.c +@@ -214,12 +214,10 @@ static int __f2fs_set_acl(struct inode *inode, int type, + case ACL_TYPE_ACCESS: + name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; + set_acl_inode(fi, inode->i_mode); +- if (error == 0) +- acl = NULL; + } + break; + +diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c +index 1be3b061c05c..ff0ac96a8e7b 100644 +--- a/fs/gfs2/acl.c ++++ b/fs/gfs2/acl.c +@@ -79,17 +79,11 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + if (type == ACL_TYPE_ACCESS) { + umode_t mode = inode->i_mode; + +- error = posix_acl_equiv_mode(acl, &mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- +- if (error == 0) +- acl = NULL; +- +- if (mode != inode->i_mode) { +- inode->i_mode = mode; ++ if (mode != inode->i_mode) + mark_inode_dirty(inode); +- } + } + + if (acl) { +diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c +index df0c9af68d05..71b3087b7e32 100644 +--- a/fs/hfsplus/posix_acl.c ++++ b/fs/hfsplus/posix_acl.c +@@ -68,8 +68,8 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, + case ACL_TYPE_ACCESS: + xattr_name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- err = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (err < 0) ++ err = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (err) + return err; + } + err = 0; +diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c +index 2f7a3c090489..f9f86f87d32b 100644 +--- a/fs/jffs2/acl.c ++++ b/fs/jffs2/acl.c +@@ -235,9 +235,10 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + case ACL_TYPE_ACCESS: + xprefix = JFFS2_XPREFIX_ACL_ACCESS; + if (acl) { +- umode_t mode = inode->i_mode; +- rc = posix_acl_equiv_mode(acl, &mode); +- if (rc < 0) ++ umode_t mode; ++ ++ rc = posix_acl_update_mode(inode, &mode, &acl); ++ if (rc) + return rc; + if (inode->i_mode != mode) { + struct iattr attr; +@@ -249,8 +250,6 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) + if (rc < 0) + return rc; + } +- if (rc == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c +index 0c8ca830b113..9fad9f4fe883 100644 +--- a/fs/jfs/acl.c ++++ b/fs/jfs/acl.c +@@ -84,13 +84,11 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type, + case ACL_TYPE_ACCESS: + ea_name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- rc = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (rc < 0) ++ rc = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (rc) + return rc; + inode->i_ctime = CURRENT_TIME; + mark_inode_dirty(inode); +- if (rc == 0) +- acl = NULL; + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c +index 2162434728c0..164307b99405 100644 +--- a/fs/ocfs2/acl.c ++++ b/fs/ocfs2/acl.c +@@ -241,13 +241,11 @@ int ocfs2_set_acl(handle_t *handle, + case ACL_TYPE_ACCESS: + name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; + if (acl) { +- umode_t mode = inode->i_mode; +- ret = posix_acl_equiv_mode(acl, &mode); +- if (ret < 0) +- return ret; ++ umode_t mode; + +- if (ret == 0) +- acl = NULL; ++ ret = posix_acl_update_mode(inode, &mode, &acl); ++ if (ret) ++ return ret; + + ret = ocfs2_acl_set_mode(inode, di_bh, + handle, mode); +diff --git a/fs/posix_acl.c b/fs/posix_acl.c +index 34bd1bd354e6..a60d3cc5b55d 100644 +--- a/fs/posix_acl.c ++++ b/fs/posix_acl.c +@@ -592,6 +592,37 @@ no_mem: + } + EXPORT_SYMBOL_GPL(posix_acl_create); + ++/** ++ * posix_acl_update_mode - update mode in set_acl ++ * ++ * Update the file mode when setting an ACL: compute the new file permission ++ * bits based on the ACL. In addition, if the ACL is equivalent to the new ++ * file mode, set *acl to NULL to indicate that no ACL should be set. ++ * ++ * As with chmod, clear the setgit bit if the caller is not in the owning group ++ * or capable of CAP_FSETID (see inode_change_ok). ++ * ++ * Called from set_acl inode operations. ++ */ ++int posix_acl_update_mode(struct inode *inode, umode_t *mode_p, ++ struct posix_acl **acl) ++{ ++ umode_t mode = inode->i_mode; ++ int error; ++ ++ error = posix_acl_equiv_mode(*acl, &mode); ++ if (error < 0) ++ return error; ++ if (error == 0) ++ *acl = NULL; ++ if (!in_group_p(inode->i_gid) && ++ !capable_wrt_inode_uidgid(inode, CAP_FSETID)) ++ mode &= ~S_ISGID; ++ *mode_p = mode; ++ return 0; ++} ++EXPORT_SYMBOL(posix_acl_update_mode); ++ + /* + * Fix up the uids and gids in posix acl extended attributes in place. + */ +diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c +index 4b34b9dc03dd..9b1824f35501 100644 +--- a/fs/reiserfs/xattr_acl.c ++++ b/fs/reiserfs/xattr_acl.c +@@ -246,13 +246,9 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + if (acl) { +- error = posix_acl_equiv_mode(acl, &inode->i_mode); +- if (error < 0) ++ error = posix_acl_update_mode(inode, &inode->i_mode, &acl); ++ if (error) + return error; +- else { +- if (error == 0) +- acl = NULL; +- } + } + break; + case ACL_TYPE_DEFAULT: +diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c +index 6bb470fbb8e8..c5101a3295d8 100644 +--- a/fs/xfs/xfs_acl.c ++++ b/fs/xfs/xfs_acl.c +@@ -288,16 +288,11 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) + return error; + + if (type == ACL_TYPE_ACCESS) { +- umode_t mode = inode->i_mode; +- error = posix_acl_equiv_mode(acl, &mode); +- +- if (error <= 0) { +- acl = NULL; +- +- if (error < 0) +- return error; +- } ++ umode_t mode; + ++ error = posix_acl_update_mode(inode, &mode, &acl); ++ if (error) ++ return error; + error = xfs_set_mode(inode, mode); + if (error) + return error; +diff --git a/include/drm/drmP.h b/include/drm/drmP.h +index 0a271ca1f7c7..a31976c860f6 100644 +--- a/include/drm/drmP.h ++++ b/include/drm/drmP.h +@@ -1029,7 +1029,8 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files, + #endif + + extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, +- struct drm_gem_object *obj, int flags); ++ struct drm_gem_object *obj, ++ int flags); + extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle, uint32_t flags, + int *prime_fd); +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index 4e9c75226f07..12b4d54a8ffa 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1986,8 +1986,8 @@ struct napi_gro_cb { + /* This is non-zero if the packet may be of the same flow. */ + u8 same_flow:1; + +- /* Used in udp_gro_receive */ +- u8 udp_mark:1; ++ /* Used in tunnel GRO receive */ ++ u8 encap_mark:1; + + /* GRO checksum is valid */ + u8 csum_valid:1; +diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h +index 3e96a6a76103..d1a8ad7e5ae4 100644 +--- a/include/linux/posix_acl.h ++++ b/include/linux/posix_acl.h +@@ -95,6 +95,7 @@ extern int set_posix_acl(struct inode *, int, struct posix_acl *); + extern int posix_acl_chmod(struct inode *, umode_t); + extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **, + struct posix_acl **); ++extern int posix_acl_update_mode(struct inode *, umode_t *, struct posix_acl **); + + extern int simple_set_acl(struct inode *, struct posix_acl *, int); + extern int simple_acl_create(struct inode *, struct inode *); +diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h +index af40bc586a1b..86a7bdd61d1a 100644 +--- a/include/net/ip_tunnels.h ++++ b/include/net/ip_tunnels.h +@@ -283,6 +283,22 @@ struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md, + struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum, + int gso_type_mask); + ++static inline int iptunnel_pull_offloads(struct sk_buff *skb) ++{ ++ if (skb_is_gso(skb)) { ++ int err; ++ ++ err = skb_unclone(skb, GFP_ATOMIC); ++ if (unlikely(err)) ++ return err; ++ skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >> ++ NETIF_F_GSO_SHIFT); ++ } ++ ++ skb->encapsulation = 0; ++ return 0; ++} ++ + static inline void iptunnel_xmit_stats(int err, + struct net_device_stats *err_stats, + struct pcpu_sw_netstats __percpu *stats) +diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c +index abd286afbd27..a4775f3451b9 100644 +--- a/kernel/irq/generic-chip.c ++++ b/kernel/irq/generic-chip.c +@@ -411,8 +411,29 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq, + } + EXPORT_SYMBOL_GPL(irq_map_generic_chip); + ++static void irq_unmap_generic_chip(struct irq_domain *d, unsigned int virq) ++{ ++ struct irq_data *data = irq_domain_get_irq_data(d, virq); ++ struct irq_domain_chip_generic *dgc = d->gc; ++ unsigned int hw_irq = data->hwirq; ++ struct irq_chip_generic *gc; ++ int irq_idx; ++ ++ gc = irq_get_domain_generic_chip(d, hw_irq); ++ if (!gc) ++ return; ++ ++ irq_idx = hw_irq % dgc->irqs_per_chip; ++ ++ clear_bit(irq_idx, &gc->installed); ++ irq_domain_set_info(d, virq, hw_irq, &no_irq_chip, NULL, NULL, NULL, ++ NULL); ++ ++} ++ + struct irq_domain_ops irq_generic_chip_ops = { + .map = irq_map_generic_chip, ++ .unmap = irq_unmap_generic_chip, + .xlate = irq_domain_xlate_onetwocell, + }; + EXPORT_SYMBOL_GPL(irq_generic_chip_ops); +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index 125c7dd55322..4434cdd4cd9a 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -1416,12 +1416,13 @@ static void dissolve_free_huge_page(struct page *page) + { + spin_lock(&hugetlb_lock); + if (PageHuge(page) && !page_count(page)) { +- struct hstate *h = page_hstate(page); +- int nid = page_to_nid(page); +- list_del(&page->lru); ++ struct page *head = compound_head(page); ++ struct hstate *h = page_hstate(head); ++ int nid = page_to_nid(head); ++ list_del(&head->lru); + h->free_huge_pages--; + h->free_huge_pages_node[nid]--; +- update_and_free_page(h, page); ++ update_and_free_page(h, head); + } + spin_unlock(&hugetlb_lock); + } +@@ -1429,7 +1430,8 @@ static void dissolve_free_huge_page(struct page *page) + /* + * Dissolve free hugepages in a given pfn range. Used by memory hotplug to + * make specified memory blocks removable from the system. +- * Note that start_pfn should aligned with (minimum) hugepage size. ++ * Note that this will dissolve a free gigantic hugepage completely, if any ++ * part of it lies within the given range. + */ + void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) + { +@@ -1438,7 +1440,6 @@ void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) + if (!hugepages_supported()) + return; + +- VM_BUG_ON(!IS_ALIGNED(start_pfn, 1 << minimum_order)); + for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) + dissolve_free_huge_page(pfn_to_page(pfn)); + } +diff --git a/net/core/dev.c b/net/core/dev.c +index de4ed2b5a221..0989fea88c44 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4239,7 +4239,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff + NAPI_GRO_CB(skb)->same_flow = 0; + NAPI_GRO_CB(skb)->flush = 0; + NAPI_GRO_CB(skb)->free = 0; +- NAPI_GRO_CB(skb)->udp_mark = 0; ++ NAPI_GRO_CB(skb)->encap_mark = 0; + NAPI_GRO_CB(skb)->gro_remcsum_start = 0; + + /* Setup for GRO checksum validation */ +diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c +index 5c5db6636704..1a5c1ca3ad3c 100644 +--- a/net/ipv4/af_inet.c ++++ b/net/ipv4/af_inet.c +@@ -1383,6 +1383,19 @@ out: + return pp; + } + ++static struct sk_buff **ipip_gro_receive(struct sk_buff **head, ++ struct sk_buff *skb) ++{ ++ if (NAPI_GRO_CB(skb)->encap_mark) { ++ NAPI_GRO_CB(skb)->flush = 1; ++ return NULL; ++ } ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ ++ return inet_gro_receive(head, skb); ++} ++ + int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) + { + if (sk->sk_family == AF_INET) +@@ -1425,6 +1438,13 @@ out_unlock: + return err; + } + ++static int ipip_gro_complete(struct sk_buff *skb, int nhoff) ++{ ++ skb->encapsulation = 1; ++ skb_shinfo(skb)->gso_type |= SKB_GSO_IPIP; ++ return inet_gro_complete(skb, nhoff); ++} ++ + int inet_ctl_sock_create(struct sock **sk, unsigned short family, + unsigned short type, unsigned char protocol, + struct net *net) +@@ -1652,8 +1672,8 @@ static struct packet_offload ip_packet_offload __read_mostly = { + static const struct net_offload ipip_offload = { + .callbacks = { + .gso_segment = inet_gso_segment, +- .gro_receive = inet_gro_receive, +- .gro_complete = inet_gro_complete, ++ .gro_receive = ipip_gro_receive, ++ .gro_complete = ipip_gro_complete, + }, + }; + +diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c +index bd903fe0f750..08d7de55e57e 100644 +--- a/net/ipv4/fou.c ++++ b/net/ipv4/fou.c +@@ -48,7 +48,7 @@ static inline struct fou *fou_from_sock(struct sock *sk) + return sk->sk_user_data; + } + +-static void fou_recv_pull(struct sk_buff *skb, size_t len) ++static int fou_recv_pull(struct sk_buff *skb, size_t len) + { + struct iphdr *iph = ip_hdr(skb); + +@@ -59,6 +59,7 @@ static void fou_recv_pull(struct sk_buff *skb, size_t len) + __skb_pull(skb, len); + skb_postpull_rcsum(skb, udp_hdr(skb), len); + skb_reset_transport_header(skb); ++ return iptunnel_pull_offloads(skb); + } + + static int fou_udp_recv(struct sock *sk, struct sk_buff *skb) +@@ -68,9 +69,14 @@ static int fou_udp_recv(struct sock *sk, struct sk_buff *skb) + if (!fou) + return 1; + +- fou_recv_pull(skb, sizeof(struct udphdr)); ++ if (fou_recv_pull(skb, sizeof(struct udphdr))) ++ goto drop; + + return -fou->protocol; ++ ++drop: ++ kfree_skb(skb); ++ return 0; + } + + static struct guehdr *gue_remcsum(struct sk_buff *skb, struct guehdr *guehdr, +@@ -170,6 +176,9 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) + __skb_pull(skb, sizeof(struct udphdr) + hdrlen); + skb_reset_transport_header(skb); + ++ if (iptunnel_pull_offloads(skb)) ++ goto drop; ++ + return -guehdr->proto_ctype; + + drop: +diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c +index 5a8ee3282550..e603004c1af8 100644 +--- a/net/ipv4/gre_offload.c ++++ b/net/ipv4/gre_offload.c +@@ -128,6 +128,11 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head, + struct packet_offload *ptype; + __be16 type; + ++ if (NAPI_GRO_CB(skb)->encap_mark) ++ goto out; ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ + off = skb_gro_offset(skb); + hlen = off + sizeof(*greh); + greh = skb_gro_header_fast(skb, off); +diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c +index 6cb9009c3d96..dbda0565781c 100644 +--- a/net/ipv4/ip_tunnel_core.c ++++ b/net/ipv4/ip_tunnel_core.c +@@ -116,7 +116,8 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto) + skb->vlan_tci = 0; + skb_set_queue_mapping(skb, 0); + skb->pkt_type = PACKET_HOST; +- return 0; ++ ++ return iptunnel_pull_offloads(skb); + } + EXPORT_SYMBOL_GPL(iptunnel_pull_header); + +diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c +index f9386160cbee..0e36e56dfd22 100644 +--- a/net/ipv4/udp_offload.c ++++ b/net/ipv4/udp_offload.c +@@ -299,14 +299,14 @@ struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb, + unsigned int off = skb_gro_offset(skb); + int flush = 1; + +- if (NAPI_GRO_CB(skb)->udp_mark || ++ if (NAPI_GRO_CB(skb)->encap_mark || + (skb->ip_summed != CHECKSUM_PARTIAL && + NAPI_GRO_CB(skb)->csum_cnt == 0 && + !NAPI_GRO_CB(skb)->csum_valid)) + goto out; + +- /* mark that this skb passed once through the udp gro layer */ +- NAPI_GRO_CB(skb)->udp_mark = 1; ++ /* mark that this skb passed once through the tunnel gro layer */ ++ NAPI_GRO_CB(skb)->encap_mark = 1; + + rcu_read_lock(); + uo_priv = rcu_dereference(udp_offload_base); +diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c +index eeca943f12dc..82e9f3076028 100644 +--- a/net/ipv6/ip6_offload.c ++++ b/net/ipv6/ip6_offload.c +@@ -258,6 +258,19 @@ out: + return pp; + } + ++static struct sk_buff **sit_gro_receive(struct sk_buff **head, ++ struct sk_buff *skb) ++{ ++ if (NAPI_GRO_CB(skb)->encap_mark) { ++ NAPI_GRO_CB(skb)->flush = 1; ++ return NULL; ++ } ++ ++ NAPI_GRO_CB(skb)->encap_mark = 1; ++ ++ return ipv6_gro_receive(head, skb); ++} ++ + static int ipv6_gro_complete(struct sk_buff *skb, int nhoff) + { + const struct net_offload *ops; +@@ -302,7 +315,7 @@ static struct packet_offload ipv6_packet_offload __read_mostly = { + static const struct net_offload sit_offload = { + .callbacks = { + .gso_segment = ipv6_gso_segment, +- .gro_receive = ipv6_gro_receive, ++ .gro_receive = sit_gro_receive, + .gro_complete = sit_gro_complete, + }, + }; +diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c +index ba3d2f3d66d2..3da2b16356eb 100644 +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -681,14 +681,15 @@ static int ipip6_rcv(struct sk_buff *skb) + skb->mac_header = skb->network_header; + skb_reset_network_header(skb); + IPCB(skb)->flags = 0; +- skb->protocol = htons(ETH_P_IPV6); ++ skb->dev = tunnel->dev; + + if (packet_is_spoofed(skb, iph, tunnel)) { + tunnel->dev->stats.rx_errors++; + goto out; + } + +- __skb_tunnel_rx(skb, tunnel->dev, tunnel->net); ++ if (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6))) ++ goto out; + + err = IP_ECN_decapsulate(iph, skb); + if (unlikely(err)) { +diff --git a/scripts/sortextable.c b/scripts/sortextable.c +index c2423d913b46..7b29fb14f870 100644 +--- a/scripts/sortextable.c ++++ b/scripts/sortextable.c +@@ -209,6 +209,35 @@ static int compare_relative_table(const void *a, const void *b) + return 0; + } + ++static void x86_sort_relative_table(char *extab_image, int image_size) ++{ ++ int i; ++ ++ i = 0; ++ while (i < image_size) { ++ uint32_t *loc = (uint32_t *)(extab_image + i); ++ ++ w(r(loc) + i, loc); ++ w(r(loc + 1) + i + 4, loc + 1); ++ w(r(loc + 2) + i + 8, loc + 2); ++ ++ i += sizeof(uint32_t) * 3; ++ } ++ ++ qsort(extab_image, image_size / 12, 12, compare_relative_table); ++ ++ i = 0; ++ while (i < image_size) { ++ uint32_t *loc = (uint32_t *)(extab_image + i); ++ ++ w(r(loc) - i, loc); ++ w(r(loc + 1) - (i + 4), loc + 1); ++ w(r(loc + 2) - (i + 8), loc + 2); ++ ++ i += sizeof(uint32_t) * 3; ++ } ++} ++ + static void sort_relative_table(char *extab_image, int image_size) + { + int i; +@@ -281,6 +310,9 @@ do_file(char const *const fname) + break; + case EM_386: + case EM_X86_64: ++ custom_sort = x86_sort_relative_table; ++ break; ++ + case EM_S390: + custom_sort = sort_relative_table; + break; +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c +index afb70a5d4fd3..b8a256dfed7e 100644 +--- a/sound/soc/soc-dapm.c ++++ b/sound/soc/soc-dapm.c +@@ -823,6 +823,7 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, + case snd_soc_dapm_switch: + case snd_soc_dapm_mixer: + case snd_soc_dapm_pga: ++ case snd_soc_dapm_out_drv: + wname_in_long_name = true; + kcname_in_long_name = true; + break; +@@ -3015,6 +3016,9 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, + } + mutex_unlock(&card->dapm_mutex); + ++ if (ret) ++ return ret; ++ + if (invert) + ucontrol->value.integer.value[0] = max - val; + else +@@ -3166,7 +3170,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + if (e->shift_l != e->shift_r) { + if (item[1] > e->items) + return -EINVAL; +- val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_l; ++ val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r; + mask |= e->mask << e->shift_r; + } + +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c +index 6963ba20991c..70396d3f6472 100644 +--- a/sound/soc/soc-topology.c ++++ b/sound/soc/soc-topology.c +@@ -1484,6 +1484,7 @@ widget: + if (widget == NULL) { + dev_err(tplg->dev, "ASoC: failed to create widget %s controls\n", + w->name); ++ ret = -ENOMEM; + goto hdr_err; + } + +diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c +index 3900386a3629..d802938644b5 100644 +--- a/tools/perf/ui/browsers/hists.c ++++ b/tools/perf/ui/browsers/hists.c +@@ -684,7 +684,6 @@ static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) + ret = scnprintf(hpp->buf, hpp->size, fmt, len, percent); + ui_browser__printf(arg->b, "%s", hpp->buf); + +- advance_hpp(hpp, ret); + return ret; + } + +diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c +index 4a3a72cb5805..6ce624cb7001 100644 +--- a/tools/perf/util/stat.c ++++ b/tools/perf/util/stat.c +@@ -311,6 +311,16 @@ int perf_stat_process_counter(struct perf_stat_config *config, + + aggr->val = aggr->ena = aggr->run = 0; + ++ /* ++ * We calculate counter's data every interval, ++ * and the display code shows ps->res_stats ++ * avg value. We need to zero the stats for ++ * interval mode, otherwise overall avg running ++ * averages will be shown for each interval. ++ */ ++ if (config->interval) ++ init_stats(ps->res_stats); ++ + if (counter->per_pkg) + zero_per_pkg(counter); + +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c +index 475d88d0a1c9..27ae382feb2d 100644 +--- a/tools/perf/util/symbol-elf.c ++++ b/tools/perf/util/symbol-elf.c +@@ -1091,9 +1091,8 @@ new_symbol: + * For misannotated, zeroed, ASM function sizes. + */ + if (nr > 0) { +- if (!symbol_conf.allow_aliases) +- symbols__fixup_duplicate(&dso->symbols[map->type]); + symbols__fixup_end(&dso->symbols[map->type]); ++ symbols__fixup_duplicate(&dso->symbols[map->type]); + if (kmap) { + /* + * We need to fixup this here too because we create new +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c +index cd08027a6d2c..520a32a12f8a 100644 +--- a/tools/perf/util/symbol.c ++++ b/tools/perf/util/symbol.c +@@ -151,6 +151,9 @@ void symbols__fixup_duplicate(struct rb_root *symbols) + struct rb_node *nd; + struct symbol *curr, *next; + ++ if (symbol_conf.allow_aliases) ++ return; ++ + nd = rb_first(symbols); + + while (nd) { +@@ -1275,8 +1278,8 @@ int dso__load_kallsyms(struct dso *dso, const char *filename, + if (kallsyms__delta(map, filename, &delta)) + return -1; + +- symbols__fixup_duplicate(&dso->symbols[map->type]); + symbols__fixup_end(&dso->symbols[map->type]); ++ symbols__fixup_duplicate(&dso->symbols[map->type]); + + if (dso->kernel == DSO_TYPE_GUEST_KERNEL) + dso->symtab_type = DSO_BINARY_TYPE__GUEST_KALLSYMS; diff --git a/patch/kernel/udoo-next/03-patch-4.4.29-30.patch b/patch/kernel/udoo-next/03-patch-4.4.29-30.patch new file mode 100644 index 0000000000..e19a680b98 --- /dev/null +++ b/patch/kernel/udoo-next/03-patch-4.4.29-30.patch @@ -0,0 +1,434 @@ +diff --git a/Documentation/x86/exception-tables.txt b/Documentation/x86/exception-tables.txt +index e396bcd8d830..32901aa36f0a 100644 +--- a/Documentation/x86/exception-tables.txt ++++ b/Documentation/x86/exception-tables.txt +@@ -290,38 +290,3 @@ Due to the way that the exception table is built and needs to be ordered, + only use exceptions for code in the .text section. Any other section + will cause the exception table to not be sorted correctly, and the + exceptions will fail. +- +-Things changed when 64-bit support was added to x86 Linux. Rather than +-double the size of the exception table by expanding the two entries +-from 32-bits to 64 bits, a clever trick was used to store addresses +-as relative offsets from the table itself. The assembly code changed +-from: +- .long 1b,3b +-to: +- .long (from) - . +- .long (to) - . +- +-and the C-code that uses these values converts back to absolute addresses +-like this: +- +- ex_insn_addr(const struct exception_table_entry *x) +- { +- return (unsigned long)&x->insn + x->insn; +- } +- +-In v4.6 the exception table entry was expanded with a new field "handler". +-This is also 32-bits wide and contains a third relative function +-pointer which points to one of: +- +-1) int ex_handler_default(const struct exception_table_entry *fixup) +- This is legacy case that just jumps to the fixup code +-2) int ex_handler_fault(const struct exception_table_entry *fixup) +- This case provides the fault number of the trap that occurred at +- entry->insn. It is used to distinguish page faults from machine +- check. +-3) int ex_handler_ext(const struct exception_table_entry *fixup) +- This case is used for uaccess_err ... we need to set a flag +- in the task structure. Before the handler functions existed this +- case was handled by adding a large offset to the fixup to tag +- it as special. +-More functions can easily be added. +diff --git a/Makefile b/Makefile +index 19d7d9f68e35..98239d56924c 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 29 ++SUBLEVEL = 30 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h +index f5063b6659eb..189679aba703 100644 +--- a/arch/x86/include/asm/asm.h ++++ b/arch/x86/include/asm/asm.h +@@ -44,22 +44,19 @@ + + /* Exception table entry */ + #ifdef __ASSEMBLY__ +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \ ++# define _ASM_EXTABLE(from,to) \ + .pushsection "__ex_table","a" ; \ +- .balign 4 ; \ ++ .balign 8 ; \ + .long (from) - . ; \ + .long (to) - . ; \ +- .long (handler) - . ; \ + .popsection + +-# define _ASM_EXTABLE(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) +- +-# define _ASM_EXTABLE_FAULT(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) +- +-# define _ASM_EXTABLE_EX(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) ++# define _ASM_EXTABLE_EX(from,to) \ ++ .pushsection "__ex_table","a" ; \ ++ .balign 8 ; \ ++ .long (from) - . ; \ ++ .long (to) - . + 0x7ffffff0 ; \ ++ .popsection + + # define _ASM_NOKPROBE(entry) \ + .pushsection "_kprobe_blacklist","aw" ; \ +@@ -92,24 +89,19 @@ + .endm + + #else +-# define _EXPAND_EXTABLE_HANDLE(x) #x +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \ ++# define _ASM_EXTABLE(from,to) \ + " .pushsection \"__ex_table\",\"a\"\n" \ +- " .balign 4\n" \ ++ " .balign 8\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ +- " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \ + " .popsection\n" + +-# define _ASM_EXTABLE(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) +- +-# define _ASM_EXTABLE_FAULT(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) +- +-# define _ASM_EXTABLE_EX(from, to) \ +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) +- ++# define _ASM_EXTABLE_EX(from,to) \ ++ " .pushsection \"__ex_table\",\"a\"\n" \ ++ " .balign 8\n" \ ++ " .long (" #from ") - .\n" \ ++ " .long (" #to ") - . + 0x7ffffff0\n" \ ++ " .popsection\n" + /* For C file, we already have NOKPROBE_SYMBOL macro */ + #endif + +diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h +index 3794c7331cfc..09b1b0ab94b7 100644 +--- a/arch/x86/include/asm/uaccess.h ++++ b/arch/x86/include/asm/uaccess.h +@@ -90,11 +90,12 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + likely(!__range_not_ok(addr, size, user_addr_max())) + + /* +- * The exception table consists of triples of addresses relative to the +- * exception table entry itself. The first address is of an instruction +- * that is allowed to fault, the second is the target at which the program +- * should continue. The third is a handler function to deal with the fault +- * caused by the instruction in the first field. ++ * The exception table consists of pairs of addresses relative to the ++ * exception table enty itself: the first is the address of an ++ * instruction that is allowed to fault, and the second is the address ++ * at which the program should continue. No registers are modified, ++ * so it is entirely up to the continuation code to figure out what to ++ * do. + * + * All the routines below use bits of fixup code that are out of line + * with the main instruction path. This means when everything is well, +@@ -103,14 +104,13 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un + */ + + struct exception_table_entry { +- int insn, fixup, handler; ++ int insn, fixup; + }; + /* This is not the generic standard exception_table_entry format */ + #define ARCH_HAS_SORT_EXTABLE + #define ARCH_HAS_SEARCH_EXTABLE + +-extern int fixup_exception(struct pt_regs *regs, int trapnr); +-extern bool ex_has_fault_handler(unsigned long ip); ++extern int fixup_exception(struct pt_regs *regs); + extern int early_fixup_exception(unsigned long *ip); + + /* +@@ -394,11 +394,7 @@ do { \ + #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ + asm volatile("1: mov"itype" %1,%"rtype"0\n" \ + "2:\n" \ +- ".section .fixup,\"ax\"\n" \ +- "3:xor"itype" %"rtype"0,%"rtype"0\n" \ +- " jmp 2b\n" \ +- ".previous\n" \ +- _ASM_EXTABLE_EX(1b, 3b) \ ++ _ASM_EXTABLE_EX(1b, 2b) \ + : ltype(x) : "m" (__m(addr))) + + #define __put_user_nocheck(x, ptr, size) \ +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c +index e1d1f6cbaf11..023c442c33bb 100644 +--- a/arch/x86/kernel/kprobes/core.c ++++ b/arch/x86/kernel/kprobes/core.c +@@ -1000,7 +1000,7 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) + * In case the user-specified fault handler returned + * zero, try to fix up. + */ +- if (fixup_exception(regs, trapnr)) ++ if (fixup_exception(regs)) + return 1; + + /* +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c +index 5621f882645e..679302c312f8 100644 +--- a/arch/x86/kernel/traps.c ++++ b/arch/x86/kernel/traps.c +@@ -199,7 +199,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, + } + + if (!user_mode(regs)) { +- if (!fixup_exception(regs, trapnr)) { ++ if (!fixup_exception(regs)) { + tsk->thread.error_code = error_code; + tsk->thread.trap_nr = trapnr; + die(str, regs, error_code); +@@ -453,7 +453,7 @@ do_general_protection(struct pt_regs *regs, long error_code) + + tsk = current; + if (!user_mode(regs)) { +- if (fixup_exception(regs, X86_TRAP_GP)) ++ if (fixup_exception(regs)) + return; + + tsk->thread.error_code = error_code; +@@ -699,7 +699,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) + conditional_sti(regs); + + if (!user_mode(regs)) { +- if (!fixup_exception(regs, trapnr)) { ++ if (!fixup_exception(regs)) { + task->thread.error_code = error_code; + task->thread.trap_nr = trapnr; + die(str, regs, error_code); +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c +index 9dd7e4b7fcde..903ec1e9c326 100644 +--- a/arch/x86/mm/extable.c ++++ b/arch/x86/mm/extable.c +@@ -3,9 +3,6 @@ + #include + #include + +-typedef bool (*ex_handler_t)(const struct exception_table_entry *, +- struct pt_regs *, int); +- + static inline unsigned long + ex_insn_addr(const struct exception_table_entry *x) + { +@@ -16,56 +13,11 @@ ex_fixup_addr(const struct exception_table_entry *x) + { + return (unsigned long)&x->fixup + x->fixup; + } +-static inline ex_handler_t +-ex_fixup_handler(const struct exception_table_entry *x) +-{ +- return (ex_handler_t)((unsigned long)&x->handler + x->handler); +-} +- +-bool ex_handler_default(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- regs->ip = ex_fixup_addr(fixup); +- return true; +-} +-EXPORT_SYMBOL(ex_handler_default); +- +-bool ex_handler_fault(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- regs->ip = ex_fixup_addr(fixup); +- regs->ax = trapnr; +- return true; +-} +-EXPORT_SYMBOL_GPL(ex_handler_fault); +- +-bool ex_handler_ext(const struct exception_table_entry *fixup, +- struct pt_regs *regs, int trapnr) +-{ +- /* Special hack for uaccess_err */ +- current_thread_info()->uaccess_err = 1; +- regs->ip = ex_fixup_addr(fixup); +- return true; +-} +-EXPORT_SYMBOL(ex_handler_ext); +- +-bool ex_has_fault_handler(unsigned long ip) +-{ +- const struct exception_table_entry *e; +- ex_handler_t handler; +- +- e = search_exception_tables(ip); +- if (!e) +- return false; +- handler = ex_fixup_handler(e); +- +- return handler == ex_handler_fault; +-} + +-int fixup_exception(struct pt_regs *regs, int trapnr) ++int fixup_exception(struct pt_regs *regs) + { +- const struct exception_table_entry *e; +- ex_handler_t handler; ++ const struct exception_table_entry *fixup; ++ unsigned long new_ip; + + #ifdef CONFIG_PNPBIOS + if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) { +@@ -81,34 +33,42 @@ int fixup_exception(struct pt_regs *regs, int trapnr) + } + #endif + +- e = search_exception_tables(regs->ip); +- if (!e) +- return 0; ++ fixup = search_exception_tables(regs->ip); ++ if (fixup) { ++ new_ip = ex_fixup_addr(fixup); ++ ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { ++ /* Special hack for uaccess_err */ ++ current_thread_info()->uaccess_err = 1; ++ new_ip -= 0x7ffffff0; ++ } ++ regs->ip = new_ip; ++ return 1; ++ } + +- handler = ex_fixup_handler(e); +- return handler(e, regs, trapnr); ++ return 0; + } + + /* Restricted version used during very early boot */ + int __init early_fixup_exception(unsigned long *ip) + { +- const struct exception_table_entry *e; ++ const struct exception_table_entry *fixup; + unsigned long new_ip; +- ex_handler_t handler; + +- e = search_exception_tables(*ip); +- if (!e) +- return 0; ++ fixup = search_exception_tables(*ip); ++ if (fixup) { ++ new_ip = ex_fixup_addr(fixup); + +- new_ip = ex_fixup_addr(e); +- handler = ex_fixup_handler(e); ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { ++ /* uaccess handling not supported during early boot */ ++ return 0; ++ } + +- /* special handling not supported during early boot */ +- if (handler != ex_handler_default) +- return 0; ++ *ip = new_ip; ++ return 1; ++ } + +- *ip = new_ip; +- return 1; ++ return 0; + } + + /* +@@ -173,8 +133,6 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup += i; + i += 4; +- p->handler += i; +- i += 4; + } + + sort(start, finish - start, sizeof(struct exception_table_entry), +@@ -187,8 +145,6 @@ void sort_extable(struct exception_table_entry *start, + i += 4; + p->fixup -= i; + i += 4; +- p->handler -= i; +- i += 4; + } + } + +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c +index 03898aea6e0f..e830c71a1323 100644 +--- a/arch/x86/mm/fault.c ++++ b/arch/x86/mm/fault.c +@@ -663,7 +663,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, + int sig; + + /* Are we prepared to handle this kernel fault? */ +- if (fixup_exception(regs, X86_TRAP_PF)) { ++ if (fixup_exception(regs)) { + /* + * Any interrupt that takes a fault gets the fixup. This makes + * the below recursive fault logic only apply to a faults from +diff --git a/scripts/sortextable.c b/scripts/sortextable.c +index 7b29fb14f870..c2423d913b46 100644 +--- a/scripts/sortextable.c ++++ b/scripts/sortextable.c +@@ -209,35 +209,6 @@ static int compare_relative_table(const void *a, const void *b) + return 0; + } + +-static void x86_sort_relative_table(char *extab_image, int image_size) +-{ +- int i; +- +- i = 0; +- while (i < image_size) { +- uint32_t *loc = (uint32_t *)(extab_image + i); +- +- w(r(loc) + i, loc); +- w(r(loc + 1) + i + 4, loc + 1); +- w(r(loc + 2) + i + 8, loc + 2); +- +- i += sizeof(uint32_t) * 3; +- } +- +- qsort(extab_image, image_size / 12, 12, compare_relative_table); +- +- i = 0; +- while (i < image_size) { +- uint32_t *loc = (uint32_t *)(extab_image + i); +- +- w(r(loc) - i, loc); +- w(r(loc + 1) - (i + 4), loc + 1); +- w(r(loc + 2) - (i + 8), loc + 2); +- +- i += sizeof(uint32_t) * 3; +- } +-} +- + static void sort_relative_table(char *extab_image, int image_size) + { + int i; +@@ -310,9 +281,6 @@ do_file(char const *const fname) + break; + case EM_386: + case EM_X86_64: +- custom_sort = x86_sort_relative_table; +- break; +- + case EM_S390: + custom_sort = sort_relative_table; + break; diff --git a/patch/u-boot/u-boot-dev/h3-merging_pc_plus_and_opi2e.patch b/patch/u-boot/u-boot-dev/h3-merging_pc_plus_and_opi2e.patch deleted file mode 100644 index d7485f6b26..0000000000 --- a/patch/u-boot/u-boot-dev/h3-merging_pc_plus_and_opi2e.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/configs/orangepi_pc_plus_defconfig b/configs/orangepi_pc_plus_defconfig -old mode 100644 -new mode 100755 -index 8caca59..ba8251b ---- a/configs/orangepi_pc_plus_defconfig -+++ b/configs/orangepi_pc_plus_defconfig -@@ -5,7 +5,7 @@ CONFIG_DRAM_CLK=624 - CONFIG_DRAM_ZQ=3881979 - CONFIG_DRAM_ODT_EN=y - CONFIG_MMC_SUNXI_SLOT_EXTRA=2 --CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-pc-plus" -+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-pc" - # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set - CONFIG_SPL=y - # CONFIG_CMD_IMLS is not set -diff --git a/configs/orangepi_plus2e_defconfig b/configs/orangepi_plus2e_defconfig -old mode 100644 -new mode 100755 -index 579bc70..cd3fd3d ---- a/configs/orangepi_plus2e_defconfig -+++ b/configs/orangepi_plus2e_defconfig -@@ -5,7 +5,7 @@ CONFIG_DRAM_CLK=624 - CONFIG_DRAM_ZQ=3881979 - CONFIG_DRAM_ODT_EN=y - CONFIG_MMC_SUNXI_SLOT_EXTRA=2 --CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-plus2e" -+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-plus" - # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set - CONFIG_SPL=y - CONFIG_SYS_EXTRA_OPTIONS="MACPWR=SUNXI_GPD(6)"