All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v14 1/8] ethdev: add Tx preparation
From: Thomas Monjalon @ 2016-12-22 14:24 UTC (permalink / raw)
  To: Tomasz Kulasek; +Cc: dev
In-Reply-To: <1482411919-7620-2-git-send-email-tomaszx.kulasek@intel.com>

Hi Tomasz,

2016-12-22 14:05, Tomasz Kulasek:
> Added API for `rte_eth_tx_prepare`
> 
> uint16_t rte_eth_tx_prepare(uint8_t port_id, uint16_t queue_id,
> 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts)

As discussed earlier and agreed by Konstantin, please mark this API
as experimental.
We could make some changes in 17.05 to improve error description
or add some flags to modify the behaviour.


> int rte_net_intel_cksum_prepare(struct rte_mbuf *m)
> 
>   to prepare pseudo header checksum for TSO and non-TSO tcp/udp packets
>   before hardware tx checksum offload.
>    - for non-TSO tcp/udp packets full pseudo-header checksum is
>      counted and set.
>    - for TSO the IP payload length is not included.
> 
> 
> int
> rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
> 
>   this function uses same logic as rte_net_intel_cksum_prepare, but
>   allows application to choose which offloads should be taken into
>   account, if full preparation is not required.

How the application knows which offload flag should be taken into account?


>  #
> +# Use real NOOP to turn off TX preparation stage
> +#
> +# While the behaviour of ``rte_ethdev_tx_prepare`` may change after turning on
> +# real NOOP, this configuration shouldn't be never enabled globaly, and can be
> +# used in appropriate target configuration file with a following restrictions
> +#
> +CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n

As discussed earlier, it would be easier to not call tx_prepare at all.
However, this option allows an optimization when compiling DPDK for a
known environment without modifying the application.
So it is worth to keep it.

The text explaining the option should be improved.
I suggest this text:

# Turn off Tx preparation stage
#
# Warning: rte_ethdev_tx_prepare() can be safely disabled only if using a
# driver which do not implement any Tx preparation.


> +	uint16_t nb_seg_max;  /**< Max number of segments per whole packet. */
> +	uint16_t nb_mtu_seg_max; /**< Max number of segments per one MTU */

In another mail, you've added this explanation:
* For non-TSO packet, a single transmit packet may span up to "nb_mtu_seg_max" buffers.
* For TSO packet the total number of data descriptors is "nb_seg_max", and each segment within the TSO may span up to "nb_mtu_seg_max".

Maybe you can try to mix these comments to improve the doxygen.

^ permalink raw reply

* [meta-python][PATCH] python-cffi: update to version 1.9.1
From: Derek Straka @ 2016-12-22 14:24 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Derek Straka <derek@asterius.io>
---
 meta-python/recipes-devtools/python/python-cffi.inc               | 8 ++++++--
 .../python/{python-cffi_1.8.3.bb => python-cffi_1.9.1.bb}         | 0
 .../python/{python3-cffi_1.8.3.bb => python3-cffi_1.9.1.bb}       | 0
 3 files changed, 6 insertions(+), 2 deletions(-)
 rename meta-python/recipes-devtools/python/{python-cffi_1.8.3.bb => python-cffi_1.9.1.bb} (100%)
 rename meta-python/recipes-devtools/python/{python3-cffi_1.8.3.bb => python3-cffi_1.9.1.bb} (100%)

diff --git a/meta-python/recipes-devtools/python/python-cffi.inc b/meta-python/recipes-devtools/python/python-cffi.inc
index d24d6ff..12da19f 100644
--- a/meta-python/recipes-devtools/python/python-cffi.inc
+++ b/meta-python/recipes-devtools/python/python-cffi.inc
@@ -3,7 +3,11 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=5677e2fdbf7cdda61d6dd2b57df547bf"
 DEPENDS = "libffi ${PYTHON_PN}-pycparser"
 
-SRC_URI[md5sum] = "c8e877fe0426a99d0cf5872cf2f95b27"
-SRC_URI[sha256sum] = "c321bd46faa7847261b89c0469569530cad5a41976bb6dba8202c0159f476568"
+SRC_URI[md5sum] = "b8fa7ccb87790531db3316ab17aa8244"
+SRC_URI[sha256sum] = "563e0bd53fda03c151573217b3a49b3abad8813de9dd0632e10090f6190fdaf8"
+
+RDEPENDS_${PN}_class-target = " \
+    ${PYTHON_PN}-io \
+"
 
 BBCLASSEXTEND = "native nativesdk"
diff --git a/meta-python/recipes-devtools/python/python-cffi_1.8.3.bb b/meta-python/recipes-devtools/python/python-cffi_1.9.1.bb
similarity index 100%
rename from meta-python/recipes-devtools/python/python-cffi_1.8.3.bb
rename to meta-python/recipes-devtools/python/python-cffi_1.9.1.bb
diff --git a/meta-python/recipes-devtools/python/python3-cffi_1.8.3.bb b/meta-python/recipes-devtools/python/python3-cffi_1.9.1.bb
similarity index 100%
rename from meta-python/recipes-devtools/python/python3-cffi_1.8.3.bb
rename to meta-python/recipes-devtools/python/python3-cffi_1.9.1.bb
-- 
2.7.4



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 6/8] add-to-group: require user to logout for group change
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 add-to-group.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/add-to-group.sh b/add-to-group.sh
index 6fa66e7..1bedd3e 100644
--- a/add-to-group.sh
+++ b/add-to-group.sh
@@ -90,8 +90,10 @@ if [ "$host_upper" -gt "$min_ver_upper" -o "$host_upper" -eq "$min_ver_upper" ];
             fi
 
             echo "Until then you will be required to use sudo when accessing a serial device."
+            echo "Please logout now and log back in so that the group changes are in effect."
             echo
             read -p "Press return to continue" REPLY
+            exit 0
 
         else
             echo "User '$username' is already apart of the 'dialout' group"
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 0/8] keystone: utilize UART boot
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago

For keystone EVMs, there is no MMC interface, so U-Boot cannot be
updated by simply flashing an SD card. U-Boot is updated by using a
another instance of U-Boot to flash the board. Howver, a board may or
may not have U-Boot flashed, and if it is, it is unmanageable to
support all possible versions of U-Boot and the various default
environments.

Therefore these patches automate using UART boot to boot an instance
of the packaged version of U-Boot which is used to flash and configure
the board. In this way, only the packaged version of U-Boot needs to
be supported.

Jacob Stiffler (8):
  setup-uboot-env-keystone.sh: add prompt_feedback function
  setup-uboot-env-keystone.sh: enhance do_expect function
  setup-uboot-env-keystone.sh: add detection of BMC port
  setup-uboot-env-keystone.sh: make updating ubifs an independent option
  setup-uboot-env-keystone.sh: create minicom script to update board
  add-to-group: require user to logout for group change
  setup-package-install: Add screen and lrzsz packages
  setup-uboot-env-keystone: use UART boot to boot latest version of
    U-Boot

 add-to-group.sh             |   2 +
 setup-package-install.sh    |   2 +-
 setup-uboot-env-keystone.sh | 379 ++++++++++++++++++++++++++------------------
 3 files changed, 225 insertions(+), 158 deletions(-)

-- 
1.9.1



^ permalink raw reply

* [tisdk-setup-scripts][PATCH 2/8] setup-uboot-env-keystone.sh: enhance do_expect function
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

* allow writing minicom runscript commands to multiple files

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index fdd131a..356e9c7 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -34,16 +34,26 @@ cwd=`dirname $0`
 . $cwd/common.sh
 
 do_expect() {
-    echo "expect {" >> $3
-    check_status
-    echo "    $1" >> $3
-    check_status
-    echo "    timeout 600 goto end" >> $3
-    echo "}" >> $3
-    check_status
-    echo $2 >> $3
-    check_status
-    echo >> $3
+    local expect_str="$1"
+    local command="$2"
+
+    shift; shift
+
+    while [ $# -gt 0 ]
+    do
+        echo "expect {" >> "$1"
+        check_status
+        echo "    $expect_str" >> "$1"
+        check_status
+        echo "    timeout 600 goto end" >> "$1"
+        echo "}" >> "$1"
+        check_status
+        echo $command >> "$1"
+        check_status
+        echo >> "$1"
+
+        shift
+    done
 }
 
 prompt_feedback() {
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 3/8] setup-uboot-env-keystone.sh: add detection of BMC port
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

* add the ability to auto-detect the BMC port
* The BMC may be used to reboot and configure the bootmode.

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 51 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index 356e9c7..da90629 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -210,7 +210,8 @@ check_for_board() {
                 board_vendor="0403"
                 board_product="6010"
                 num_port="2"
-                uart_port="1"
+                uart_port_idx="1"
+                bmc_port_idx="2"
             fi
         ;;
 
@@ -223,7 +224,8 @@ check_for_board() {
                 board_vendor="10c4"
                 board_product="ea70"
                 num_port="2"
-                uart_port="1"
+                uart_port_idx="1"
+                bmc_port_idx="2"
             fi
         ;;
     esac
@@ -333,6 +335,9 @@ if [ "$minicom" = "y" ]; then
         else
             echo ""
             prompt_feedback "Board could not be detected. Please connect the board to the PC." temp "Press any key to try checking again"
+
+            # Set to default board to allow user to specify the correct ports.
+            board=k2evm
         fi
     done
 
@@ -352,33 +357,51 @@ if [ "$minicom" = "y" ]; then
             echo -n "Detecting connection to board... "
             loopCount=0
             usb_id=`dmesg | grep "idVendor=${board_vendor}" | grep "idProduct=${board_product}" | tail -1 | sed -e 's|.*usb \(.*\):.*|\1|'`
-            port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${uart_port} | tail -1 | grep "attached" |  awk '{ print $NF }'`
-            while [ -z "$port" ] && [ "$loopCount" -ne "10" ]
+            uart_port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${uart_port_idx} | tail -1 | grep "attached" |  awk '{ print $NF }'`
+            bmc_port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${bmc_port_idx} | tail -1 | grep "attached" |  awk '{ print $NF }'`
+            while [ -z "$uart_port" ] && [ "$loopCount" -ne "10" ]
             do
                 #count to 10 and timeout if no connection is found
                 loopCount=$((loopCount+1))
 
                 sleep 1
                 usb_id=`dmesg | grep "idVendor=${board_vendor}" | grep "idProduct=${board_product}" | tail -1 | sed -e 's|.*usb \(.*\):.*|\1|'`
-                port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${uart_port} | tail -1 | grep "attached" |  awk '{ print $NF }'`
+                uart_port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${uart_port_idx} | tail -1 | grep "attached" |  awk '{ print $NF }'`
+                bmc_port=`dmesg | grep "usb $usb_id" | grep "tty" | tail -${num_port} | head -${bmc_port_idx} | tail -1 | grep "attached" |  awk '{ print $NF }'`
             done
 
             #check to see if we actually found a port
-            if [ -n "$port" ]; then
-                echo "${platform} autodetected at /dev/$port"
+            if [ -n "$uart_port" ]; then
+                echo "${platform} (UART) autodetected at /dev/$uart_port"
+                echo
+                prompt_feedback "Please verify that this is correct or manually enter the correct port:" dev_uart_port "/dev/$uart_port"
+
+                echo "${platform} (BMC) autodetected at /dev/$bmc_port"
                 echo
-                prompt_feedback "Please verify that this is correct or manually enter the correct port:" dev_port "/dev/$port"
+                prompt_feedback "Please verify that this is correct or manually enter the correct port:" dev_bmc_port "/dev/$bmc_port"
+
+                if [ ! -e "${dev_uart_port}" ]; then
+                    echo; echo "ERROR: ${dev_uart_port} does not exist!"
+                    dev_uart_port=""
+                fi
+
+                if [ ! -e "${dev_bmc_port}" ]; then
+                    echo; echo "ERROR: ${dev_bmc_port} does not exist!"
+                    dev_bmc_port=""
+                fi
+
+                if [ "$dev_uart_port" = "$dev_bmc_port" ]; then
+                    echo; echo "ERROR: UART and BMC cannot be the same port: $dev_uart_port!"
+                    dev_uart_port=""
+                fi
 
-                if [ ! -e "${dev_port}" ]
-                then
-                    echo "ERROR: ${dev_port} does not exist!"
-                else
+                if [ -n "$dev_uart_port" ] && [ -n "$dev_bmc_port" ]; then
                     break
                 fi
             fi
 
             #if we didn't find a port and reached the timeout limit then ask to reconnect
-            if [ -z "$port" ] && [ "$loopCount" = "10" ]; then
+            if [ -z "$uart_port" ] && [ "$loopCount" = "10" ]; then
                 echo ""
                 echo "Unable to detect which port the board is connected to."
                 echo "Please reconnect your board."
@@ -393,7 +416,7 @@ if [ "$minicom" = "y" ]; then
             fi
         done
 
-        sed -i -e "s|^pu port.*$|pu port             $dev_port|g" ${HOME}/.minirc.dfl
+        sed -i -e "s|^pu port.*$|pu port             $dev_uart_port|g" ${HOME}/.minirc.dfl
     fi
 
     echo
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 4/8] setup-uboot-env-keystone.sh: make updating ubifs an independent option
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index da90629..0ec6e8e 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -170,6 +170,17 @@ copy_to_tftproot "$ubifsimages"
 echo "--------------------------------------------------------------------------------"
 prompt_feedback "Would you like to update U-boot on the board?" ubootupdate y y n
 
+prompt_feedback "Would you like to update the UBI filesystem on the board?" ubifsupdate y y n
+
+if [ "$ubifsupdate" = "y" ]; then
+    echo "Available ubi images in $tftproot:"
+    for file in $tftproot/*-${platform}.ubi; do
+	basefile=`basename $file`
+	echo "    $basefile"
+    done
+    echo
+    prompt_feedback "Which ubi image do you want to boot?" ubifsimage $ubifsimagedefault
+fi
 
 echo "Select secondary boot:"
 echo " 1: NFS"
@@ -187,14 +198,6 @@ if [ "$secondary_boot" -eq "1" ]; then
     echo
     prompt_feedback "Which kernel image do you want to boot from TFTP?" kernelimage $kernelimagedefault
 else
-    echo
-    echo "Available ubi images in $tftproot:"
-    for file in $tftproot/*-${platform}.ubi; do
-	basefile=`basename $file`
-	echo "    $basefile"
-    done
-    echo
-    prompt_feedback "Which ubi image do you want to boot?" ubifsimage $ubifsimagedefault
     kernelimage=zImage
 fi
 
@@ -296,14 +299,17 @@ do_expect "\"$prompt\"" "send \"setenv name_ubi $ubifsimage\"" $cwd/setupBoard.m
 do_expect "\"$prompt\"" "send \"setenv name_kern $kernelimage\"" $cwd/setupBoard.minicom
 do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
 
+if [ "$ubifsupdate" = "y" ]; then
+    do_expect "\"$prompt\"" "send \"run get_ubi_net\"" $cwd/setupBoard.minicom
+    do_expect "\"$prompt\"" "send \"run burn_ubi\"" $cwd/setupBoard.minicom
+fi
+
 if [ "$secondary_boot" -eq "1" ]; then
-	#TFTP and NFS Boot
-	do_expect "\"$prompt\"" "send \"setenv boot net\"" $cwd/setupBoard.minicom
+    #TFTP and NFS Boot
+    do_expect "\"$prompt\"" "send \"setenv boot net\"" $cwd/setupBoard.minicom
 else
-	#SD and NFS Boot
-	do_expect "\"$prompt\"" "send \"run get_ubi_net\"" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send \"run burn_ubi\"" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send \"setenv boot ubi\"" $cwd/setupBoard.minicom
+    #UBI Boot
+    do_expect "\"$prompt\"" "send \"setenv boot ubi\"" $cwd/setupBoard.minicom
 fi
 
 do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 5/8] setup-uboot-env-keystone.sh: create minicom script to update board
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

* Create an additional minicom script to update/flash NAND (ubifs) and
  NOR (uboot) on the board.
* Retain the old setup script so that users may manually pass this to
  minicom to setup the board.

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 100 ++++++++++++++++++++------------------------
 1 file changed, 45 insertions(+), 55 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index 0ec6e8e..2c28430 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -235,13 +235,14 @@ check_for_board() {
 }
 
 echo "timeout 1800" > $cwd/setupBoard.minicom
+echo "timeout 1800" > $cwd/updateBoard.minicom
 echo "verbose on" >> $cwd/setupBoard.minicom
-do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
+echo "verbose on" >> $cwd/updateBoard.minicom
+
+do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 
-# Disable upgrading major U-boot versions
-#if [ "$ubootupdate" != "y" ]; then
-	# If not updating U-Boot, refure to procede if running an old MCSDK version.
-	cat >> $cwd/setupBoard.minicom << __EOF__
+# If U-Boot was not updated, refuse to proceed.
+cat >> $cwd/setupBoard.minicom << __EOF__
 expect {
     "$prompt"
     "# " goto uboot_update_required
@@ -249,76 +250,65 @@ expect {
 }
 send " "
 __EOF__
-#fi
 
 # Reset to the default environment
-do_expect "\"$prompt\"" "send \"env default -f -a\"" $cwd/setupBoard.minicom
+do_expect "\"$prompt\"" "send \"env default -f -a\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+
 do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
 
 # Reset incase any variables are set when u-boot initializes
 do_expect "\"$prompt\"" "send \"reset\"" $cwd/setupBoard.minicom
 do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
 
-# Set vars required to flash u-boot
-do_expect "\"$prompt\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"setenv tftp_root '$tftproot'\"" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"setenv name_uboot $ubootimage\"" $cwd/setupBoard.minicom
-
-if [ "$ubootupdate" = "y" ]; then
-	# Use common "burn_uboot" command
-	do_expect "\"$prompt\"" "send \"if test -n \$burn_uboot_spi; then setenv burn_uboot \$burn_uboot_spi; fi\"" $cwd/setupBoard.minicom
-
-	# Create command to print a known message if u-boot update succeeds
-	update_uboot_success="U-Boot successfully updated"
+# Set up the U-Boot environment
+do_expect "\"$prompt\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv tftp_root '$tftproot'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv name_uboot $ubootimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv nfs_root '$rootpath'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv name_ubi $ubifsimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv name_kern $kernelimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 
-	# Create command to fetch and flash u-boot
-	do_expect "\"$prompt\"" "send \"setenv update_uboot 'if run get_uboot_net burn_uboot; then echo $update_uboot_success; else echo U-boot update failed!; fi'\"" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send \"run update_uboot\"" $cwd/setupBoard.minicom
-
-	do_expect "\"$update_uboot_success\"" "send \"reset\"" $cwd/setupBoard.minicom
-
-	# Reset once to get new u-boot
-	do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
-
-	# Reset environment to the new U-Boot's defaults
-	do_expect "\"$prompt\"" "send \"env default -f -a\"" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
+# Create command to fetch and flash u-boot and ubi
+#
+# TBD: Save minicom output to a log and use these strings to determine the
+#      update status on the host machine.
+#
+update_uboot_status="U-Boot update:"
+update_ubi_status="UBI update:"
 
-	# Reset a second time incase any variables are set when u-boot initializes
-	do_expect "\"$prompt\"" "send \"reset\"" $cwd/setupBoard.minicom
-	do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv update_uboot 'if run get_uboot_net burn_uboot_spi; then echo $update_uboot_status SUCCESS; else echo $update_uboot_status FAILED; fi'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv update_ubi 'if run get_ubi_net burn_ubi; then echo $update_ubi_status SUCCESS; else echo $update_ubi_status FAILED; fi'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 
-	# Reinitialize any variables previously set
-	do_expect "\"$prompt\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send setenv tftp_root '$tftproot'" $cwd/setupBoard.minicom
-	do_expect "\"$prompt\"" "send \"setenv name_uboot $ubootimage\"" $cwd/setupBoard.minicom
+if [ "$secondary_boot" -eq "1" ]; then
+	#TFTP and NFS Boot
+	do_expect "\"$prompt\"" "send \"setenv boot net\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+else
+	#SD and NFS Boot
+	do_expect "\"$prompt\"" "send \"setenv boot ubi\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 fi
 
-do_expect "\"$prompt\"" "send setenv nfs_root '$rootpath'" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"setenv name_ubi $ubifsimage\"" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"setenv name_kern $kernelimage\"" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
+do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 
+if [ "$ubootupdate" = "y" ]; then
+    do_expect "\"$prompt\"" "send \"run update_uboot\"" $cwd/updateBoard.minicom
+fi
 if [ "$ubifsupdate" = "y" ]; then
-    do_expect "\"$prompt\"" "send \"run get_ubi_net\"" $cwd/setupBoard.minicom
-    do_expect "\"$prompt\"" "send \"run burn_ubi\"" $cwd/setupBoard.minicom
+    do_expect "\"$prompt\"" "send \"run update_ubi\"" $cwd/updateBoard.minicom
 fi
 
-if [ "$secondary_boot" -eq "1" ]; then
-    #TFTP and NFS Boot
-    do_expect "\"$prompt\"" "send \"setenv boot net\"" $cwd/setupBoard.minicom
-else
-    #UBI Boot
-    do_expect "\"$prompt\"" "send \"setenv boot ubi\"" $cwd/setupBoard.minicom
-fi
-
-do_expect "\"$prompt\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-do_expect "\"$prompt\"" "send \"boot\"" $cwd/setupBoard.minicom
+do_expect "\"$prompt\"" "send \"boot\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 
 cat >> $cwd/setupBoard.minicom << __EOF__
 goto end
 uboot_update_required:
-send echo; echo "*** U-boot is require to be updated before proceding!"; echo "*** The automatic upgrade of U-boot is currently disabled."; echo "*** Please follow the wiki instructions to manually upgrade U-boot."; echo
+send echo; echo "*** U-boot is require to be updated before proceeding!"; echo "*** The automatic upgrade of this version of U-boot is currently disabled."; echo "*** Please follow the wiki instructions to manually upgrade U-boot."; echo
+end:
+__EOF__
+
+cat >> $cwd/updateBoard.minicom << __EOF__
+goto end
+uboot_update_required:
+send echo; echo "*** U-boot is require to be updated before proceeding!"; echo "*** The automatic upgrade of this version of U-boot is currently disabled."; echo "*** Please follow the wiki instructions to manually upgrade U-boot."; echo
 end:
 __EOF__
 #echo "! killall -s SIGHUP minicom" >> $cwd/setupBoard.minicom
@@ -442,7 +432,7 @@ if [ "$minicom" = "y" ]; then
 
     if [ "$minicomsetup" = "y" ]; then
       cd $cwd
-      sudo minicom -w -S setupBoard.minicom
+      sudo minicom -w -S updateBoard.minicom
       cd -
     fi
 
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 1/8] setup-uboot-env-keystone.sh: add prompt_feedback function
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

The prompt_feedback function abstracts many commonalities when
requesting user feedback.

* Echoing the query string
* providing a default value
* listing valid options
* capturing user input to a specified variable

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 137 +++++++++++++++++++-------------------------
 1 file changed, 60 insertions(+), 77 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index 7335758..fdd131a 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -46,6 +46,50 @@ do_expect() {
     echo >> $3
 }
 
+prompt_feedback() {
+    # Usage: prompt_feedback <prompt> [variable] [default_value] [valid_opt1] [valid_opt2]...
+    local prompt="$1"
+    local var=""
+    local default=""
+
+    local opt_str=""
+
+    local response=""
+    local good_response=""
+
+    shift
+    [ $# -eq 0 ] || var="$1"
+    shift
+    [ $# -eq 0 ] || default="$1"
+    shift
+
+    if [ $# -gt 0 ]
+    then
+        opt_str="($1"
+        shift
+
+        while [ $# -gt 0 ]
+        do
+            opt_str="${opt_str}/$1"
+            shift
+        done
+        opt_str="${opt_str})"
+    fi
+
+    echo "$prompt $opt_str"
+    if [ ! -z "$default" ]
+    then
+        read -p "[ $default ] " response
+    else
+        read response
+    fi
+    echo
+
+    [ ! -z "$response" ] || response="$default"
+
+    [ -z "$var" ] || eval $var=\"$response\"
+}
+
 copy_to_tftproot() {
     files="$1"
     for file in $files
@@ -53,8 +97,7 @@ copy_to_tftproot() {
 	if [ -f $tftproot/$file ]; then
 	    echo
 	    echo "$tftproot/$file already exists. The existing installed file can be renamed and saved under the new name."
-	    echo "(o) overwrite (s) skip copy "
-	    read -p "[o] " exists
+	    prompt_feedback "(o) overwrite (s) skip copy" exists o
 	    case "$exists" in
 	      s) echo "Skipping copy of $file, existing version will be used"
 		 ;;
@@ -84,36 +127,18 @@ platform=`grep PLATFORM= $cwd/../Rules.make | cut -d= -f2`
 # Configure prompt for U-Boot 2016.05
 prompt="=>"
 
-echo "Autodetected the following ip address of your host, correct it if necessary"
-read -p "[ $ipdefault ] " ip
-echo
-
-if [ ! -n "$ip" ]; then
-    ip=$ipdefault
-fi
+prompt_feedback "Autodetected the following ip address of your host, correct it if necessary" ip "$(echo $ipdefault | sed -e 's| .*||')" $ipdefault
 
 if [ -f $cwd/../.tftproot ]; then
     tftproot=`cat $cwd/../.tftproot`
 else
-    echo "Where is your tftp root directory?"
-    read -p "[ /tftpboot ]" tftproot
-
-    if [ ! -n "$tftproot" ]; then
-        tftproot="/tftpboot"
-    fi
-    echo
+    prompt_feedback "Where is your tftp root directory?" tftproot "/tftpboot"
 fi
 
 if [ -f $cwd/../.targetfs ]; then
     rootpath=`cat $cwd/../.targetfs`
 else
-    echo "Where is your target filesystem extracted?"
-    read -p "[ ${HOME}/targetNFS ]" rootpath
-
-    if [ ! -n "$rootpath" ]; then
-        rootpath="${HOME}/targetNFS"
-    fi
-    echo
+    prompt_feedback "Where is your target filesystem extracted?" rootpath "${HOME}/targetNFS"
 fi
 
 
@@ -133,24 +158,13 @@ copy_to_tftproot "$ubifsimages"
 
 
 echo "--------------------------------------------------------------------------------"
-echo "Would you like to update U-boot on the board (y/n)?"
-read -p "[ y ] " ubootupdate
-echo
-
-if [ ! -n "$ubootupdate" ]; then
-    ubootupdate="y"
-fi
+prompt_feedback "Would you like to update U-boot on the board?" ubootupdate y y n
 
 
 echo "Select secondary boot:"
 echo " 1: NFS"
 echo " 2: UBI"
-echo
-read -p "[ 1 ] " secondary_boot
-
-if [ ! -n "$secondary_boot" ]; then
-    secondary_boot="1"
-fi
+prompt_feedback "" secondary_boot 1
 
 
 if [ "$secondary_boot" -eq "1" ]; then
@@ -161,12 +175,7 @@ if [ "$secondary_boot" -eq "1" ]; then
 	echo "    $basefile"
     done
     echo
-    echo "Which kernel image do you want to boot from TFTP?"
-    read -p "[ $kernelimagedefault ] " kernelimage
-
-    if [ ! -n "$kernelimage" ]; then
-	kernelimage=$kernelimagedefault
-    fi
+    prompt_feedback "Which kernel image do you want to boot from TFTP?" kernelimage $kernelimagedefault
 else
     echo
     echo "Available ubi images in $tftproot:"
@@ -175,12 +184,7 @@ else
 	echo "    $basefile"
     done
     echo
-    echo "Which ubi image do you want to boot?"
-    read -p "[ $ubifsimagedefault ] " ubifsimage
-
-    if [ ! -n "$ubifsimage" ]; then
-	ubifsimage=$ubifsimagedefault
-    fi
+    prompt_feedback "Which ubi image do you want to boot?" ubifsimage $ubifsimagedefault
     kernelimage=zImage
 fi
 
@@ -302,13 +306,7 @@ __EOF__
 #echo "! killall -s SIGHUP minicom" >> $cwd/setupBoard.minicom
 
 echo "--------------------------------------------------------------------------------"
-echo "Would you like to create a minicom script with the above parameters (y/n)?"
-read -p "[ y ] " minicom
-echo
-
-if [ ! -n "$minicom" ]; then
-    minicom="y"
-fi
+prompt_feedback "Would you like to create a minicom script with the above parameters?" minicom y y n
 
 if [ "$minicom" = "y" ]; then
 
@@ -324,8 +322,7 @@ if [ "$minicom" = "y" ]; then
             break
         else
             echo ""
-            echo "Board could not be detected. Please connect the board to the PC."
-            read -p "Press any key to try checking again." temp
+            prompt_feedback "Board could not be detected. Please connect the board to the PC." temp "Press any key to try checking again"
         fi
     done
 
@@ -360,22 +357,13 @@ if [ "$minicom" = "y" ]; then
             if [ -n "$port" ]; then
                 echo "${platform} autodetected at /dev/$port"
                 echo
-                echo "Please verify that this is correct or manually enter the correct port:"
-                echo
-                read -p "[/dev/$port] " dev_port
-                echo
+                prompt_feedback "Please verify that this is correct or manually enter the correct port:" dev_port "/dev/$port"
 
-                if [ ! -n "$dev_port" ]
+                if [ ! -e "${dev_port}" ]
                 then
-                    dev_port="/dev/$port"
-                    break
+                    echo "ERROR: ${dev_port} does not exist!"
                 else
-                    if [ ! -e "${dev_port}" ]
-                    then
-                        echo "ERROR: ${dev_port} does not exist!"
-                    else
-                        break
-                    fi
+                    break
                 fi
             fi
 
@@ -384,8 +372,7 @@ if [ "$minicom" = "y" ]; then
                 echo ""
                 echo "Unable to detect which port the board is connected to."
                 echo "Please reconnect your board."
-                echo "Press 'y' to attempt to detect your board again or press 'n' to continue..."
-                read -p "(y/n)" retryBoardDetection
+                prompt_feedback "Press 'y' to attempt to detect your board again or press 'n' to continue..." retryBoardDetection y
             fi
 
             #if they choose not to retry, ask user to reboot manually and exit
@@ -411,12 +398,8 @@ if [ "$minicom" = "y" ]; then
     echo "able to connect to it by executing 'minicom -w' or if you prefer a windows host"
     echo "you can set up Tera Term as explained in the Software Developer's Guide."
     echo "If you connect minicom or Tera Term and power cycle the board Linux will boot."
-    echo
-    read -p "[ y ] " minicomsetup
 
-    if [ ! -n "$minicomsetup" ]; then
-       minicomsetup="y"
-    fi
+    prompt_feedback "" minicomsetup y
 
     if [ "$minicomsetup" = "y" ]; then
       cd $cwd
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 7/8] setup-package-install: Add screen and lrzsz packages
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

* screen is used by these scripts to background processes which
  require a terminal connection (e.g. minicom).
* lrzsz provides an XMODEM implmentation which is used for UART boot.

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-package-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup-package-install.sh b/setup-package-install.sh
index ddddecd..1ef94f9 100644
--- a/setup-package-install.sh
+++ b/setup-package-install.sh
@@ -56,7 +56,7 @@ cwd=`dirname $0`
 
 entry_header
 
-packages_to_install="xinetd tftpd nfs-kernel-server minicom build-essential libncurses5-dev autoconf automake dos2unix"
+packages_to_install="xinetd tftpd nfs-kernel-server minicom build-essential libncurses5-dev autoconf automake dos2unix screen lrzsz"
 
 get_host_type host
 
-- 
1.9.1



^ permalink raw reply related

* [tisdk-setup-scripts][PATCH 8/8] setup-uboot-env-keystone: use UART boot to boot latest version of U-Boot
From: Jacob Stiffler @ 2016-12-22 14:25 UTC (permalink / raw)
  To: meta-arago
In-Reply-To: <1482416729-15556-1-git-send-email-j-stiffler@ti.com>

* Configure keystone boards to boot the packaged version of U-Boot
  over UART
* During the UART boot, configure the U-Boot environment and
  optionally update the U-Boot version flashed to NOR and/or the UBI
  filesystem flashed to NAND.

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 setup-uboot-env-keystone.sh | 67 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 7 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index 2c28430..37fb2c1 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -126,6 +126,29 @@ copy_to_tftproot() {
     done
 }
 
+# Create the BMC scripts. These require no configuration from the user.
+create_bmc_scripts() {
+    ( echo "timeout 300"; echo; ) > $cwd/bmcUartBoot.minicom
+    ( echo "timeout 300"; echo; ) > $cwd/bmcSpiBoot.minicom
+
+    # Allow time for XMODEM transfer to begin
+    echo "! sleep 1" >> $cwd/bmcUartBoot.minicom
+
+    ( echo "send \" \""; echo; ) >> $cwd/bmcUartBoot.minicom
+    ( echo "send \" \""; echo; ) >> $cwd/bmcSpiBoot.minicom
+
+    do_expect "\"BMC>\"" "send \"bootmode #4\"" $cwd/bmcUartBoot.minicom
+    do_expect "\"BMC>\"" "send \"bootmode #2\"" $cwd/bmcSpiBoot.minicom
+
+    do_expect "\"BMC>\"" "send \"reboot\"" $cwd/bmcUartBoot.minicom $cwd/bmcSpiBoot.minicom
+
+    echo "end:" >> $cwd/bmcUartBoot.minicom
+    echo "end:" >> $cwd/bmcSpiBoot.minicom
+
+    # bmcUartboot.minicom will be killed by the updateUboot.minicom script
+    echo "! killall -s SIGHUP minicom" >> $cwd/bmcSpiBoot.minicom
+}
+
 echo
 echo "--------------------------------------------------------------------------------"
 echo "This step will set up the u-boot variables for booting the EVM."
@@ -156,7 +179,10 @@ kernelimage="zImage-""$platform"".bin"
 kernelimagesrc=`ls -1 $cwd/../board-support/prebuilt-images/$kernelimage`
 kernelimagedefault=`basename $kernelimagesrc`
 
-ubootimage="u-boot-spi-${platform}.gph"
+ubootimage="u-boot-${platform}.img"
+ubootimagesrc=`readlink -m $cwd/../board-support/prebuilt-images/$ubootimage`
+
+ubootspiimage="u-boot-spi-${platform}.gph"
 
 ubifsimage="tisdk-server-rootfs-image-${platform}.ubi"
 ubifsimagesrc=`ls -1 $cwd/../filesystem/$ubifsimage`
@@ -263,7 +289,7 @@ do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
 # Set up the U-Boot environment
 do_expect "\"$prompt\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 do_expect "\"$prompt\"" "send \"setenv tftp_root '$tftproot'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
-do_expect "\"$prompt\"" "send \"setenv name_uboot $ubootimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"setenv name_uboot $ubootspiimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 do_expect "\"$prompt\"" "send \"setenv nfs_root '$rootpath'\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 do_expect "\"$prompt\"" "send \"setenv name_ubi $ubifsimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
 do_expect "\"$prompt\"" "send \"setenv name_kern $kernelimage\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
@@ -296,7 +322,8 @@ if [ "$ubifsupdate" = "y" ]; then
     do_expect "\"$prompt\"" "send \"run update_ubi\"" $cwd/updateBoard.minicom
 fi
 
-do_expect "\"$prompt\"" "send \"boot\"" $cwd/setupBoard.minicom $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \" \"" $cwd/updateBoard.minicom
+do_expect "\"$prompt\"" "send \"boot\"" $cwd/setupBoard.minicom
 
 cat >> $cwd/setupBoard.minicom << __EOF__
 goto end
@@ -311,7 +338,7 @@ uboot_update_required:
 send echo; echo "*** U-boot is require to be updated before proceeding!"; echo "*** The automatic upgrade of this version of U-boot is currently disabled."; echo "*** Please follow the wiki instructions to manually upgrade U-boot."; echo
 end:
 __EOF__
-#echo "! killall -s SIGHUP minicom" >> $cwd/setupBoard.minicom
+echo "! killall -s SIGHUP minicom" >> $cwd/updateBoard.minicom
 
 echo "--------------------------------------------------------------------------------"
 prompt_feedback "Would you like to create a minicom script with the above parameters?" minicom y y n
@@ -420,8 +447,9 @@ if [ "$minicom" = "y" ]; then
     echo "Would you like to run the setup script now (y/n)?"
     echo
     echo "Please connect the ethernet cable as described in the Quick Start Guide."
-    echo "Once answering 'y' on the prompt below, you will have 300 seconds to connect"
-    echo "the board and power cycle it before the setup times out"
+    echo "Once answering 'y' on the prompt below, the script will proceed with"
+    echo "automatically booting and configuring the board based on the responses"
+    echo "provided."
     echo
     echo "After successfully executing this script, your EVM will be set up. You will be "
     echo "able to connect to it by executing 'minicom -w' or if you prefer a windows host"
@@ -431,8 +459,33 @@ if [ "$minicom" = "y" ]; then
     prompt_feedback "" minicomsetup y
 
     if [ "$minicomsetup" = "y" ]; then
+      create_bmc_scripts
+
       cd $cwd
-      sudo minicom -w -S updateBoard.minicom
+
+      tmp_fifo="$PWD/uart_boot_fifo"
+
+      rm "$tmp_fifo"
+      mkfifo "$tmp_fifo"
+
+      # stripping U-Boot img header and piping to fifo
+      (dd bs=64 count=1 of=/dev/null; dd bs=512k) < "$ubootimagesrc" > "$tmp_fifo" &
+
+      # Configuring bootmode to UART boot via BMC
+      screen -dmS minicom_${platform}_bmc minicom -D "$dev_bmc_port" -S bmcUartBoot.minicom -C bmcUartBoot.log
+
+      # Transfering uboot.bin using XMODEM protocol
+      sx -kb "$tmp_fifo" < "$dev_uart_port" > "$dev_uart_port"
+
+      # Configure U-Boot environment and optionally flash board
+      minicom -D "$dev_uart_port" -S updateBoard.minicom -C updateBoard.log
+      rm "$tmp_fifo"
+
+      # Configuring bootmode to SPI boot via BMC
+      minicom -D "$dev_bmc_port" -S bmcSpiBoot.minicom -C bmcSpiBoot.log
+
+      # Running terminal to board (UART)
+      minicom -w -D "$dev_uart_port" -C bootBoard.log
       cd -
     fi
 
-- 
1.9.1



^ permalink raw reply related

* Re: [PATCH v14 8/8] testpmd: use Tx preparation in csum engine
From: Thomas Monjalon @ 2016-12-22 14:28 UTC (permalink / raw)
  To: Tomasz Kulasek; +Cc: dev
In-Reply-To: <1482411919-7620-9-git-send-email-tomaszx.kulasek@intel.com>

2016-12-22 14:05, Tomasz Kulasek:
> Since all current drivers supports Tx preparation API, it is used
> in csum forwarding engine by default for all drivers.
[...]
> +/*
> + * Enable Tx preparation path in the "csum" engine.
> + */
> +uint8_t tx_prepare;

It seems this variable is not used.

^ permalink raw reply

* Re: [PATCH 02/12] gfio: Improve IOPS textbox labels
From: Stephen Cameron @ 2016-12-22 14:22 UTC (permalink / raw)
  To: Robert Elliott; +Cc: fio@vger.kernel.org
In-Reply-To: <20161222060853.64104-3-elliott@hpe.com>

On Wed, Dec 21, 2016 at 10:08 PM, Robert Elliott <elliott@hpe.com> wrote:
> From: Robert Elliott <elliott@hpe.com>
>
> Change the three textboxes labeled IOPS to Read IOPS, Write IOPS,
> and Trim IOPS, add Trim to the Blocksize label, and fix Steve's
> last name in the Credits.
[...]
> -               "Stephen Carmeron <stephenmcameron@gmail.com>",
> +               "Stephen Cameron <stephenmcameron@gmail.com>",
[...]

Ha, thanks.

-- steve

^ permalink raw reply

* Re: [PATCH] mm/page_alloc: Wait for oom_lock before retrying.
From: Sergey Senozhatsky @ 2016-12-22 14:30 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: Tetsuo Handa, mhocko, linux-mm, pmladek
In-Reply-To: <20161222140930.GF413@tigerII.localdomain>

On (12/22/16 23:09), Sergey Senozhatsky wrote:
> > "404 The page you're looking for could not be found."
> > 
> > Anonymous access not supported?

https://github.com/sergey-senozhatsky/linux-next-ss/commits/printk-safe-deferred

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply

* [meta-python][PATCH] python-cython: update to version 0.25.2
From: Derek Straka @ 2016-12-22 14:30 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Derek Straka <derek@asterius.io>
---
 meta-python/recipes-devtools/python/python-cython.inc            | 7 +++----
 meta-python/recipes-devtools/python/python-cython_0.24.1.bb      | 6 ------
 meta-python/recipes-devtools/python/python-cython_0.25.2.bb      | 9 +++++++++
 .../{python3-cython_0.24.1.bb => python3-cython_0.25.2.bb}       | 0
 4 files changed, 12 insertions(+), 10 deletions(-)
 delete mode 100644 meta-python/recipes-devtools/python/python-cython_0.24.1.bb
 create mode 100644 meta-python/recipes-devtools/python/python-cython_0.25.2.bb
 rename meta-python/recipes-devtools/python/{python3-cython_0.24.1.bb => python3-cython_0.25.2.bb} (100%)

diff --git a/meta-python/recipes-devtools/python/python-cython.inc b/meta-python/recipes-devtools/python/python-cython.inc
index de8a1a9..1ecdcc9 100644
--- a/meta-python/recipes-devtools/python/python-cython.inc
+++ b/meta-python/recipes-devtools/python/python-cython.inc
@@ -7,14 +7,13 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e23fadd6ceef8c618fc1c65191d846fa"
 PYPI_PACKAGE = "Cython"
 BBCLASSEXTEND = "native"
 
-SRC_URI[md5sum] = "890b494a12951f1d6228c416a5789554"
-SRC_URI[sha256sum] = "84808fda00508757928e1feadcf41c9f78e9a9b7167b6649ab0933b76f75e7b9"
+SRC_URI[md5sum] = "642c81285e1bb833b14ab3f439964086"
+SRC_URI[sha256sum] = "f141d1f9c27a07b5a93f7dc5339472067e2d7140d1c5a9e20112a5665ca60306"
 
 inherit pypi
 
-RDEPENDS_${PN} += "\
+RDEPENDS_${PN}_class-target += "\
     ${PYTHON_PN}-netserver \
     ${PYTHON_PN}-subprocess \
     ${PYTHON_PN}-shell \
 "
-RDEPENDS_${PN}_class-native = ""
diff --git a/meta-python/recipes-devtools/python/python-cython_0.24.1.bb b/meta-python/recipes-devtools/python/python-cython_0.24.1.bb
deleted file mode 100644
index 6be0b1e..0000000
--- a/meta-python/recipes-devtools/python/python-cython_0.24.1.bb
+++ /dev/null
@@ -1,6 +0,0 @@
-inherit setuptools
-require python-cython.inc
-
-RDEPENDS_${PN} += "\
-    python-distribute \
-"
diff --git a/meta-python/recipes-devtools/python/python-cython_0.25.2.bb b/meta-python/recipes-devtools/python/python-cython_0.25.2.bb
new file mode 100644
index 0000000..bdf9490
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python-cython_0.25.2.bb
@@ -0,0 +1,9 @@
+inherit setuptools
+require python-cython.inc
+
+UPSTREAM_CHECK_URI = "https://pypi.python.org/pypi/Cython/"
+UPSTREAM_CHECK_REGEX = "/Cython/(?P<pver>(\d+[\.\-_]*)+)"
+
+RDEPENDS_${PN} += "\
+    python-distribute \
+"
diff --git a/meta-python/recipes-devtools/python/python3-cython_0.24.1.bb b/meta-python/recipes-devtools/python/python3-cython_0.25.2.bb
similarity index 100%
rename from meta-python/recipes-devtools/python/python3-cython_0.24.1.bb
rename to meta-python/recipes-devtools/python/python3-cython_0.25.2.bb
-- 
2.7.4



^ permalink raw reply related

* [xen-4.8-testing test] 103792: trouble: broken/fail/pass
From: osstest service owner @ 2016-12-22 14:30 UTC (permalink / raw)
  To: xen-devel, osstest-admin

flight 103792 xen-4.8-testing real [real]
http://logs.test-lab.xenproject.org/osstest/logs/103792/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-xtf-amd64-amd64-1        3 host-install(3)        broken REGR. vs. 103767

Regressions which are regarded as allowable (not blocking):
 test-armhf-armhf-xl-rtds    15 guest-start/debian.repeat fail REGR. vs. 103767
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-stop            fail like 103767
 test-amd64-amd64-xl-rtds      9 debian-install               fail  like 103767
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-stop             fail like 103767

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-pvh-intel 11 guest-start                  fail  never pass
 test-amd64-amd64-libvirt     12 migrate-support-check        fail   never pass
 test-amd64-amd64-xl-pvh-amd  11 guest-start                  fail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check fail never pass
 test-amd64-i386-libvirt-xsm  12 migrate-support-check        fail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check fail never pass
 test-amd64-amd64-libvirt-vhd 11 migrate-support-check        fail   never pass
 test-amd64-i386-libvirt      12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-arndale  12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-arndale  13 saverestore-support-check    fail   never pass
 test-armhf-armhf-libvirt-xsm 12 migrate-support-check        fail   never pass
 test-armhf-armhf-libvirt-xsm 13 saverestore-support-check    fail   never pass
 test-armhf-armhf-libvirt     12 migrate-support-check        fail   never pass
 test-armhf-armhf-libvirt     13 saverestore-support-check    fail   never pass
 test-armhf-armhf-xl-cubietruck 12 migrate-support-check        fail never pass
 test-armhf-armhf-xl-cubietruck 13 saverestore-support-check    fail never pass
 test-armhf-armhf-xl-xsm      12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-xsm      13 saverestore-support-check    fail   never pass
 test-armhf-armhf-xl-credit2  12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-credit2  13 saverestore-support-check    fail   never pass
 test-amd64-amd64-libvirt-xsm 12 migrate-support-check        fail   never pass
 test-amd64-amd64-qemuu-nested-amd 16 debian-hvm-install/l1/l2  fail never pass
 test-armhf-armhf-xl-multivcpu 12 migrate-support-check        fail  never pass
 test-armhf-armhf-xl-multivcpu 13 saverestore-support-check    fail  never pass
 test-armhf-armhf-libvirt-raw 11 migrate-support-check        fail   never pass
 test-armhf-armhf-libvirt-raw 12 saverestore-support-check    fail   never pass
 test-armhf-armhf-xl-vhd      11 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-vhd      12 saverestore-support-check    fail   never pass
 test-armhf-armhf-xl-rtds     12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl-rtds     13 saverestore-support-check    fail   never pass
 test-armhf-armhf-xl          12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl          13 saverestore-support-check    fail   never pass
 test-armhf-armhf-libvirt-qcow2 11 migrate-support-check        fail never pass
 test-armhf-armhf-libvirt-qcow2 12 saverestore-support-check    fail never pass

version targeted for testing:
 xen                  24ccfc33272be300b306873b75352c0de3deca94
baseline version:
 xen                  b996efb23864f7135db3578a3a2059fe2f3c1a98

Last test of basis   103767  2016-12-20 04:56:08 Z    2 days
Testing same since   103792  2016-12-21 17:10:20 Z    0 days    1 attempts

------------------------------------------------------------
People who touched revisions under test:
  Jan Beulich <jbeulich@suse.com>

jobs:
 build-amd64-xsm                                              pass    
 build-armhf-xsm                                              pass    
 build-i386-xsm                                               pass    
 build-amd64-xtf                                              pass    
 build-amd64                                                  pass    
 build-armhf                                                  pass    
 build-i386                                                   pass    
 build-amd64-libvirt                                          pass    
 build-armhf-libvirt                                          pass    
 build-i386-libvirt                                           pass    
 build-amd64-prev                                             pass    
 build-i386-prev                                              pass    
 build-amd64-pvops                                            pass    
 build-armhf-pvops                                            pass    
 build-i386-pvops                                             pass    
 build-amd64-rumprun                                          pass    
 build-i386-rumprun                                           pass    
 test-xtf-amd64-amd64-1                                       broken  
 test-xtf-amd64-amd64-2                                       pass    
 test-xtf-amd64-amd64-3                                       pass    
 test-xtf-amd64-amd64-4                                       pass    
 test-xtf-amd64-amd64-5                                       pass    
 test-amd64-amd64-xl                                          pass    
 test-armhf-armhf-xl                                          pass    
 test-amd64-i386-xl                                           pass    
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm                pass    
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm                 pass    
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm           pass    
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm            pass    
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm                pass    
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm                 pass    
 test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm        pass    
 test-amd64-i386-xl-qemut-stubdom-debianhvm-amd64-xsm         pass    
 test-amd64-amd64-libvirt-xsm                                 pass    
 test-armhf-armhf-libvirt-xsm                                 pass    
 test-amd64-i386-libvirt-xsm                                  pass    
 test-amd64-amd64-xl-xsm                                      pass    
 test-armhf-armhf-xl-xsm                                      pass    
 test-amd64-i386-xl-xsm                                       pass    
 test-amd64-amd64-qemuu-nested-amd                            fail    
 test-amd64-amd64-xl-pvh-amd                                  fail    
 test-amd64-i386-qemut-rhel6hvm-amd                           pass    
 test-amd64-i386-qemuu-rhel6hvm-amd                           pass    
 test-amd64-amd64-xl-qemut-debianhvm-amd64                    pass    
 test-amd64-i386-xl-qemut-debianhvm-amd64                     pass    
 test-amd64-amd64-xl-qemuu-debianhvm-amd64                    pass    
 test-amd64-i386-xl-qemuu-debianhvm-amd64                     pass    
 test-amd64-i386-freebsd10-amd64                              pass    
 test-amd64-amd64-xl-qemuu-ovmf-amd64                         pass    
 test-amd64-i386-xl-qemuu-ovmf-amd64                          pass    
 test-amd64-amd64-rumprun-amd64                               pass    
 test-amd64-amd64-xl-qemut-win7-amd64                         pass    
 test-amd64-i386-xl-qemut-win7-amd64                          fail    
 test-amd64-amd64-xl-qemuu-win7-amd64                         fail    
 test-amd64-i386-xl-qemuu-win7-amd64                          pass    
 test-armhf-armhf-xl-arndale                                  pass    
 test-amd64-amd64-xl-credit2                                  pass    
 test-armhf-armhf-xl-credit2                                  pass    
 test-armhf-armhf-xl-cubietruck                               pass    
 test-amd64-i386-freebsd10-i386                               pass    
 test-amd64-i386-rumprun-i386                                 pass    
 test-amd64-amd64-qemuu-nested-intel                          pass    
 test-amd64-amd64-xl-pvh-intel                                fail    
 test-amd64-i386-qemut-rhel6hvm-intel                         pass    
 test-amd64-i386-qemuu-rhel6hvm-intel                         pass    
 test-amd64-amd64-libvirt                                     pass    
 test-armhf-armhf-libvirt                                     pass    
 test-amd64-i386-libvirt                                      pass    
 test-amd64-amd64-migrupgrade                                 pass    
 test-amd64-i386-migrupgrade                                  pass    
 test-amd64-amd64-xl-multivcpu                                pass    
 test-armhf-armhf-xl-multivcpu                                pass    
 test-amd64-amd64-pair                                        pass    
 test-amd64-i386-pair                                         pass    
 test-amd64-amd64-libvirt-pair                                pass    
 test-amd64-i386-libvirt-pair                                 pass    
 test-amd64-amd64-amd64-pvgrub                                pass    
 test-amd64-amd64-i386-pvgrub                                 pass    
 test-amd64-amd64-pygrub                                      pass    
 test-armhf-armhf-libvirt-qcow2                               pass    
 test-amd64-amd64-xl-qcow2                                    pass    
 test-armhf-armhf-libvirt-raw                                 pass    
 test-amd64-i386-xl-raw                                       pass    
 test-amd64-amd64-xl-rtds                                     fail    
 test-armhf-armhf-xl-rtds                                     fail    
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1                     pass    
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1                     pass    
 test-amd64-amd64-libvirt-vhd                                 pass    
 test-armhf-armhf-xl-vhd                                      pass    
 test-amd64-amd64-xl-qemut-winxpsp3                           pass    
 test-amd64-i386-xl-qemut-winxpsp3                            pass    
 test-amd64-amd64-xl-qemuu-winxpsp3                           pass    
 test-amd64-i386-xl-qemuu-winxpsp3                            pass    


------------------------------------------------------------
sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
    http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
    http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
    http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
    http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step test-xtf-amd64-amd64-1 host-install(3)

Not pushing.

------------------------------------------------------------
commit 24ccfc33272be300b306873b75352c0de3deca94
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Dec 21 17:41:20 2016 +0100

    x86/HVM: add missing NULL check before using VMFUNC hook
    
    This is CVE-2016-10025 / XSA-203.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 74dcd0ce6f4fadce8093e54f0fc1a45426577e13
    master date: 2016-12-21 16:47:19 +0100

commit 7628c7efb4afca8cb2264bc3ab59830e481b37a8
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Dec 21 17:40:37 2016 +0100

    x86: force EFLAGS.IF on when exiting to PV guests
    
    Guest kernels modifying instructions in the process of being emulated
    for another of their vCPU-s may effect EFLAGS.IF to be cleared upon
    next exiting to guest context, by converting the being emulated
    instruction to CLI (at the right point in time). Prevent any such bad
    effects by always forcing EFLAGS.IF on. And to cover hypothetical other
    similar issues, also force EFLAGS.{IOPL,NT,VM} to zero.
    
    This is CVE-2016-10024 / XSA-202.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 0e47f92b072548800223f9a21ea051a017173915
    master date: 2016-12-21 16:46:13 +0100
(qemu changes not included)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply

* [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
From: cminyard @ 2016-12-22 14:25 UTC (permalink / raw)
  To: qemu-devel
In-Reply-To: <20161219154752.14563.46483.malonedeb@wampee.canonical.com>

** Changed in: qemu
     Assignee: (unassigned) => cminyard (minyard)

** Changed in: qemu
       Status: New => In Progress

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1651167

Title:
  hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?

Status in QEMU:
  In Progress

Bug description:
  I just had a go at compiling qemu trunk with
  llvm trunk. It said:

  hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
  the left hand side of this bitwise operator [-Wlogical-not-
  parentheses]

  Source code is

             IPMI_BT_SET_HBUSY(ib->control_reg,
                                !IPMI_BT_GET_HBUSY(ib->control_reg));

  That use of ! causes trouble. The SET and GET
  macros are defined as:

  #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         (((v & 1) << IPMI_BT_HBUSY_BIT)))

  I can make the compiler shut up by adding extra () in the last
  use of v in the SET macro, like this:

  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         ((((v) & 1) << IPMI_BT_HBUSY_BIT)))

  I think this is standard good practice when using macro parameters
  anyway.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1651167/+subscriptions

^ permalink raw reply

* [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
From: minyard @ 2016-12-22 14:30 UTC (permalink / raw)
  To: Bug 1651167, qemu-devel; +Cc: Corey Minyard
In-Reply-To: <20161219154752.14563.46483.malonedeb@wampee.canonical.com>

From: Corey Minyard <cminyard@mvista.com>

Macro parameters should almost always have () around them when used.
llvm reported an error on this.

Reported in https://bugs.launchpad.net/bugs/1651167

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 hw/ipmi/isa_ipmi_bt.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index f036617..8a97314 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -40,37 +40,37 @@
 #define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
 #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
 #define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
+                                       ((((v) & 1) << IPMI_BT_CLR_WR_BIT)))
 
 #define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
 #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
 #define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
+                                       ((((v) & 1) << IPMI_BT_CLR_RD_BIT)))
 
 #define IPMI_BT_H2B_ATN_MASK       (1 << IPMI_BT_H2B_ATN_BIT)
 #define IPMI_BT_GET_H2B_ATN(d)     (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_H2B_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_H2B_ATN_BIT)))
 
 #define IPMI_BT_B2H_ATN_MASK       (1 << IPMI_BT_B2H_ATN_BIT)
 #define IPMI_BT_GET_B2H_ATN(d)     (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_ATN_BIT)))
 
 #define IPMI_BT_SMS_ATN_MASK       (1 << IPMI_BT_SMS_ATN_BIT)
 #define IPMI_BT_GET_SMS_ATN(d)     (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_SMS_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_SMS_ATN_BIT)))
 
 #define IPMI_BT_HBUSY_MASK         (1 << IPMI_BT_HBUSY_BIT)
 #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
 #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))
+                                       ((((v) & 1) << IPMI_BT_HBUSY_BIT)))
 
 #define IPMI_BT_BBUSY_MASK         (1 << IPMI_BT_BBUSY_BIT)
 #define IPMI_BT_GET_BBUSY(d)       (((d) >> IPMI_BT_BBUSY_BIT) & 0x1)
 #define IPMI_BT_SET_BBUSY(d, v)    (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_BBUSY_BIT)))
+                                       ((((v) & 1) << IPMI_BT_BBUSY_BIT)))
 
 
 /* Mask register */
@@ -80,12 +80,12 @@
 #define IPMI_BT_B2H_IRQ_EN_MASK      (1 << IPMI_BT_B2H_IRQ_EN_BIT)
 #define IPMI_BT_GET_B2H_IRQ_EN(d)    (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
 
 #define IPMI_BT_B2H_IRQ_MASK         (1 << IPMI_BT_B2H_IRQ_BIT)
 #define IPMI_BT_GET_B2H_IRQ(d)       (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_IRQ(d, v)    (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_IRQ_BIT)))
 
 typedef struct IPMIBT {
     IPMIBmc *bmc;
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH] gpgme: add GPGME_STATUS_KEY_CONSIDERED
From: Alexander Kanavin @ 2016-12-22 14:30 UTC (permalink / raw)
  To: Yu, Mingli, openembedded-core
In-Reply-To: <585B397B.6080206@windriver.com>

On 12/22/2016 04:24 AM, Yu, Mingli wrote:
> Thanks Alex!
> Actually I ever tried to upgrade gpgme to 1.8.0 before send out this
> patch, but there comes other ptest failed issues for python-pygpgme
> which not exist on current gpgme 1.6.0 if we simply update gpgme to 1.8.0.
>
> Anyway I prefer to wait for more update for python-pygpgme from
> https://pagure.io/pygpgme/commits/master before we move forward to gpgme
> 1.8.0.

pygpgme upstream hasn't released a new version since 2012; the link 
above is someone's fork to fix the pressing issues, and there's no 
indication they will do more fixing. I suggest you just take the 
necessary patches, add them to pygpgme recipe, and update gpgme recipe 
at the same time. You can also review debian/ubuntu's pygpgme packages 
to see what custom patching they have there.

Alex



^ permalink raw reply

* [Buildroot] [PATCH] ccache: Patch to fix toolchain-wrapper's --sysroot
From: Matt Weber @ 2016-12-22 14:31 UTC (permalink / raw)
  To: buildroot

From: Brandon Maier <brandon.maier@rockwellcollins.com>

ccache doesn't rewrite the --sysroot base_dir from toolchain-wrapper
correctly. Resulting in a large number of cache misses when building
from different base directories.

A fix has already been accepted to the ccache upstream[1], but won't be
released until ccache 3.4. (Was noted as an improvement, so unsure
of the 3.4 release timing)

[1] https://github.com/ccache/ccache/pull/132

Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
---
 ...gument-to-sysroot-option-to-relative-path.patch | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 package/ccache/0001-Convert-argument-to-sysroot-option-to-relative-path.patch

diff --git a/package/ccache/0001-Convert-argument-to-sysroot-option-to-relative-path.patch b/package/ccache/0001-Convert-argument-to-sysroot-option-to-relative-path.patch
new file mode 100644
index 0000000..cb214b0
--- /dev/null
+++ b/package/ccache/0001-Convert-argument-to-sysroot-option-to-relative-path.patch
@@ -0,0 +1,40 @@
+From fe42d6f7b739e8d42811bf46bcccfafa728847a2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Mathias=20De=20Mar=C3=A9?= <mathias.de_mare@nokia.com>
+Date: Mon, 19 Sep 2016 10:38:13 +0200
+Subject: [PATCH] Convert argument to '--sysroot' option to relative path
+
+Previously, only the argument to '--sysroot=' was converted.
+This changeset adds support for '--sysroot'.
+---
+ ccache.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/ccache.c b/ccache.c
+index 8ffadcc..76139b9 100644
+--- a/ccache.c
++++ b/ccache.c
+@@ -2407,6 +2407,21 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
+ 			free(option);
+ 			continue;
+ 		}
++		// Alternate form of specifying sysroot without =
++		if (str_eq(argv[i], "--sysroot")) {
++			if (i == argc-1) {
++				cc_log("Missing argument to %s", argv[i]);
++				stats_update(STATS_ARGS);
++				result = false;
++				goto out;
++			}
++			args_add(stripped_args, argv[i]);
++			char *relpath = make_relative_path(x_strdup(argv[i+1]));
++			args_add(stripped_args, relpath);
++			i++;
++			free(relpath);
++			continue;
++		}
+ 		if (str_startswith(argv[i], "-Wp,")) {
+ 			if (str_eq(argv[i], "-Wp,-P")
+ 			    || strstr(argv[i], ",-P,")
+-- 
+2.8.3
+
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH 2/2] x86/VMX: don't needlessly install VMFUNC emulation hook
From: Jan Beulich @ 2016-12-22 14:31 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel, Kevin Tian, Jun Nakajima
In-Reply-To: <db68f36a-f8d2-492a-387e-8c96fda6fdc4@citrix.com>

>>> On 22.12.16 at 14:47, <andrew.cooper3@citrix.com> wrote:
> On 22/12/16 08:37, Jan Beulich wrote:
>> Instead of checking cpu_has_vmx_vmfunc inside the hook, use it to
>> determine whether to install the hook in the first place.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> I am not so sure about this.
> 
> vmfunc is reachable in the instruction emulator on hardware which 
> doesn't support vmfunc, and there is explicit provision for using vmfunc 
> 0 via hypercall on hardware lacking vmfunc support.
> 
> Given that the #VE part of altp2m is always emulated architecturally, I 
> think there is an argument to be made for also emulating EPTP switching 
> architecturally as well.

I don't understand this argumentation: Without the patch, the
hook function checks !cpu_has_vmx_vmfunc (and fails otherwise);
with the patch the hook isn't being put in place when
!cpu_has_vmx_vmfunc, and failure occurs in hvmemul_vmfunc().
I admit there's the difference in error codes, but we could
certainly make hvmemul_vmfunc() return EXCEPTION when
there's no hook.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply

* Re: [RFC/PATCH] media: Add video bus switch
From: Sebastian Reichel @ 2016-12-22 14:32 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Sakari Ailus, ivo.g.dimitrov.75, pali.rohar, linux-media, galak,
	mchehab, linux-kernel
In-Reply-To: <20161222133938.GA30259@amd>

[-- Attachment #1: Type: text/plain, Size: 2075 bytes --]

Hi Pavel,

On Thu, Dec 22, 2016 at 02:39:38PM +0100, Pavel Machek wrote:
> N900 contains front and back camera, with a switch between the
> two. This adds support for the swich component.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
> 
> --
> 
> I see this needs dts documentation, anything else than needs to be
> done?

Yes. This driver takes care of the switch gpio, but the cameras also
use different bus settings. Currently omap3isp gets the bus-settings
from the link connected to the CCP2 port in DT at probe time (*).

So there are two general problems:

1. Settings must be applied before the streaming starts instead of
at probe time, since the settings may change (based one the selected
camera). That should be fairly easy to implement by just moving the
code to the s_stream callback as far as I can see.

2. omap3isp should try to get the bus settings from using a callback
in the connected driver instead of loading it from DT. Then the
video-bus-switch can load the bus-settings from its downstream links
in DT and propagate the correct ones to omap3isp based on the
selected port. The DT loading part should actually remain in omap3isp
as fallback, in case it does not find a callback in the connected driver.
That way everything is backward compatible and the DT variant is
nice for 1-on-1 scenarios.

Apart from that Sakari told me at ELCE, that the port numbers
should be reversed to match the order of other drivers. That's
obviously very easy to do :)

Regarding the binding document. I actually did write one:
https://git.kernel.org/cgit/linux/kernel/git/sre/linux-n900.git/commit/?h=n900-camera&id=81e74af53fe6d180616b05792f78badc615e871f

So all in all it shouldn't be that hard to implement the remaining
bits.

(*) Actually it does not for CCP2, but there are some old patches
from Sakari adding it for CCP2. It is implemented for parallel port
and CSI in this way.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH v2 07/14] drm/i915: Start moving the cdclk stuff into a distinct state structure
From: Ville Syrjälä @ 2016-12-22 14:33 UTC (permalink / raw)
  To: Ander Conselvan De Oliveira; +Cc: intel-gfx, Rodrigo Vivi
In-Reply-To: <1482416080.4759.61.camel@gmail.com>

On Thu, Dec 22, 2016 at 04:14:40PM +0200, Ander Conselvan De Oliveira wrote:
> On Mon, 2016-12-19 at 19:28 +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Introduce intel_cdclk state which for now will track the cdclk
> > frequency, the vco frequency and the reference frequency (not sure we
> > want the last one, but I put it there anyway). We'll also make the
> > .get_cdclk() function fill out this state structure rather than
> > just returning the current cdclk frequency.
> > 
> > One immediate benefit is that calling .get_cdclk() will no longer
> > clobber state stored under dev_priv unless ex[plicitly told to do
> 
> Typo: ex[plicity
> 
> > so. Previously it clobbered the vco and reference clocks stored
> > there on some platforms.
> > 
> > We'll expand the use of this structure to actually precomputing the
> > state and whatnot later.
> > 
> > v2: Constify intel_cdclk_state_compare()
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> A couple more comments beloew, but either way,
> 
> Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
> 
> > ---
> >  drivers/gpu/drm/i915/i915_debugfs.c     |   2 +-
> >  drivers/gpu/drm/i915/i915_drv.h         |  14 +-
> >  drivers/gpu/drm/i915/intel_audio.c      |   2 +-
> >  drivers/gpu/drm/i915/intel_cdclk.c      | 359 ++++++++++++++++++--------------
> >  drivers/gpu/drm/i915/intel_display.c    |  18 +-
> >  drivers/gpu/drm/i915/intel_dp.c         |   2 +-
> >  drivers/gpu/drm/i915/intel_drv.h        |   3 +
> >  drivers/gpu/drm/i915/intel_fbc.c        |   2 +-
> >  drivers/gpu/drm/i915/intel_panel.c      |   4 +-
> >  drivers/gpu/drm/i915/intel_runtime_pm.c |   5 +-
> >  10 files changed, 240 insertions(+), 171 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> > index 15deb2bc568b..c0171eef8f96 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -1235,7 +1235,7 @@ static int i915_frequency_info(struct seq_file *m, void *unused)
> >  		seq_puts(m, "no P-state info available\n");
> >  	}
> >  
> > -	seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq);
> > +	seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk.hw.cdclk);
> >  	seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
> >  	seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
> >  
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index 393b34fb2d1a..a4f1231ff8ca 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -609,9 +609,11 @@ struct intel_initial_plane_config;
> >  struct intel_crtc;
> >  struct intel_limit;
> >  struct dpll;
> > +struct intel_cdclk_state;
> >  
> >  struct drm_i915_display_funcs {
> > -	int (*get_cdclk)(struct drm_i915_private *dev_priv);
> > +	void (*get_cdclk)(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state);
> >  	int (*get_fifo_size)(struct drm_i915_private *dev_priv, int plane);
> >  	int (*compute_pipe_wm)(struct intel_crtc_state *cstate);
> >  	int (*compute_intermediate_wm)(struct drm_device *dev,
> > @@ -2126,6 +2128,10 @@ struct i915_oa_ops {
> >  	bool (*oa_buffer_is_empty)(struct drm_i915_private *dev_priv);
> >  };
> >  
> > +struct intel_cdclk_state {
> > +	unsigned int cdclk, vco, ref;
> > +};
> > +
> 
> Maybe document the fields while at it.

Yeah. I guess I should start prinkling in some docs to help newcomers.
Usually I only document things that aren't all that obvious (hardware
fails and whanot). It doesn't help that my brain automatically filters
comments out so that I routinely fail to update them even when they
already exist.


> 
> >  struct drm_i915_private {
> >  	struct drm_device drm;
> >  
> > @@ -2229,7 +2235,7 @@ struct drm_i915_private {
> >  
> >  	unsigned int fsb_freq, mem_freq, is_ddr3;
> >  	unsigned int skl_preferred_vco_freq;
> > -	unsigned int cdclk_freq, max_cdclk_freq;
> > +	unsigned int max_cdclk_freq;
> >  
> >  	/*
> >  	 * For reading holding any crtc lock is sufficient,
> > @@ -2243,8 +2249,8 @@ struct drm_i915_private {
> >  	unsigned int czclk_freq;
> >  
> >  	struct {
> > -		unsigned int vco, ref;
> > -	} cdclk_pll;
> > +		struct intel_cdclk_state hw;
> > +	} cdclk;
> >  
> >  	/**
> >  	 * wq - Driver workqueue for GEM.
> > diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
> > index 3bbc96c1767f..a292246995ef 100644
> > --- a/drivers/gpu/drm/i915/intel_audio.c
> > +++ b/drivers/gpu/drm/i915/intel_audio.c
> > @@ -734,7 +734,7 @@ static int i915_audio_component_get_cdclk_freq(struct device *kdev)
> >  	if (WARN_ON_ONCE(!HAS_DDI(dev_priv)))
> >  		return -ENODEV;
> >  
> > -	return dev_priv->cdclk_freq;
> > +	return dev_priv->cdclk.hw.cdclk;
> >  }
> >  
> >  /*
> > diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c
> > index 89be610d0879..13c3b5555473 100644
> > --- a/drivers/gpu/drm/i915/intel_cdclk.c
> > +++ b/drivers/gpu/drm/i915/intel_cdclk.c
> > @@ -23,37 +23,44 @@
> >  
> >  #include "intel_drv.h"
> >  
> > -static int fixed_133mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_133mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 133333;
> > +	cdclk_state->cdclk = 133333;
> >  }
> >  
> > -static int fixed_200mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_200mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 200000;
> > +	cdclk_state->cdclk = 200000;
> >  }
> >  
> > -static int fixed_266mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_266mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 266667;
> > +	cdclk_state->cdclk = 266667;
> >  }
> >  
> > -static int fixed_333mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_333mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 333333;
> > +	cdclk_state->cdclk = 333333;
> >  }
> >  
> > -static int fixed_400mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_400mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 400000;
> > +	cdclk_state->cdclk = 400000;
> >  }
> >  
> > -static int fixed_450mhz_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void fixed_450mhz_get_cdclk(struct drm_i915_private *dev_priv,
> > +				   struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return 450000;
> > +	cdclk_state->cdclk = 450000;
> >  }
> >  
> > -static int i85x_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void i85x_get_cdclk(struct drm_i915_private *dev_priv,
> > +			   struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> >  	u16 hpllcc = 0;
> > @@ -63,8 +70,10 @@ static int i85x_get_cdclk(struct drm_i915_private *dev_priv)
> >  	 * encoding is different :(
> >  	 * FIXME is this the right way to detect 852GM/852GMV?
> >  	 */
> > -	if (pdev->revision == 0x1)
> > -		return 133333;
> > +	if (pdev->revision == 0x1) {
> > +		cdclk_state->cdclk = 133333;
> > +		return;
> > +	}
> >  
> >  	pci_bus_read_config_word(pdev->bus,
> >  				 PCI_DEVFN(0, 3), HPLLCC, &hpllcc);
> > @@ -76,37 +85,43 @@ static int i85x_get_cdclk(struct drm_i915_private *dev_priv)
> >  	case GC_CLOCK_133_200:
> >  	case GC_CLOCK_133_200_2:
> >  	case GC_CLOCK_100_200:
> > -		return 200000;
> > +		cdclk_state->cdclk = 200000;
> > +		break;
> >  	case GC_CLOCK_166_250:
> > -		return 250000;
> > +		cdclk_state->cdclk = 250000;
> > +		break;
> >  	case GC_CLOCK_100_133:
> > -		return 133333;
> > +		cdclk_state->cdclk = 133333;
> > +		break;
> >  	case GC_CLOCK_133_266:
> >  	case GC_CLOCK_133_266_2:
> >  	case GC_CLOCK_166_266:
> > -		return 266667;
> > +		cdclk_state->cdclk = 266667;
> > +		break;
> >  	}
> > -
> > -	/* Shouldn't happen */
> > -	return 0;
> >  }
> >  
> > -static int i915gm_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void i915gm_get_cdclk(struct drm_i915_private *dev_priv,
> > +			     struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> >  	u16 gcfgc = 0;
> >  
> >  	pci_read_config_word(pdev, GCFGC, &gcfgc);
> >  
> > -	if (gcfgc & GC_LOW_FREQUENCY_ENABLE)
> > -		return 133333;
> > +	if (gcfgc & GC_LOW_FREQUENCY_ENABLE) {
> > +		cdclk_state->cdclk = 133333;
> > +		return;
> > +	}
> >  
> >  	switch (gcfgc & GC_DISPLAY_CLOCK_MASK) {
> >  	case GC_DISPLAY_CLOCK_333_MHZ:
> > -		return 333333;
> > +		cdclk_state->cdclk = 333333;
> > +		break;
> >  	default:
> >  	case GC_DISPLAY_CLOCK_190_200_MHZ:
> > -		return 190000;
> > +		cdclk_state->cdclk = 190000;
> > +		break;
> >  	}
> >  }
> >  
> > @@ -178,7 +193,8 @@ static unsigned int intel_hpll_vco(struct drm_i915_private *dev_priv)
> >  	return vco;
> >  }
> >  
> > -static int g33_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void g33_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> >  	static const uint8_t div_3200[] = { 12, 10,  8,  7, 5, 16 };
> > @@ -186,9 +202,11 @@ static int g33_get_cdclk(struct drm_i915_private *dev_priv)
> >  	static const uint8_t div_4800[] = { 20, 14, 12, 10, 8, 24 };
> >  	static const uint8_t div_5333[] = { 20, 16, 12, 12, 8, 28 };
> >  	const uint8_t *div_table;
> > -	unsigned int cdclk_sel, vco = intel_hpll_vco(dev_priv);
> > +	unsigned int cdclk_sel;
> >  	uint16_t tmp = 0;
> >  
> > +	cdclk_state->vco = intel_hpll_vco(dev_priv);
> > +
> >  	pci_read_config_word(pdev, GCFGC, &tmp);
> >  
> >  	cdclk_sel = (tmp >> 4) & 0x7;
> > @@ -196,7 +214,7 @@ static int g33_get_cdclk(struct drm_i915_private *dev_priv)
> >  	if (cdclk_sel >= ARRAY_SIZE(div_3200))
> >  		goto fail;
> >  
> > -	switch (vco) {
> > +	switch (cdclk_state->vco) {
> >  	case 3200000:
> >  		div_table = div_3200;
> >  		break;
> > @@ -213,15 +231,18 @@ static int g33_get_cdclk(struct drm_i915_private *dev_priv)
> >  		goto fail;
> >  	}
> >  
> > -	return DIV_ROUND_CLOSEST(vco, div_table[cdclk_sel]);
> > +	cdclk_state->cdclk = DIV_ROUND_CLOSEST(cdclk_state->vco,
> > +					       div_table[cdclk_sel]);
> > +	return;
> >  
> >  fail:
> >  	DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u kHz, CFGC=0x%08x\n",
> > -		  vco, tmp);
> > -	return 190476;
> > +		  cdclk_state->vco, tmp);
> > +	cdclk_state->cdclk = 190476;
> >  }
> >  
> > -static int pnv_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void pnv_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> >  	u16 gcfgc = 0;
> > @@ -230,32 +251,41 @@ static int pnv_get_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  	switch (gcfgc & GC_DISPLAY_CLOCK_MASK) {
> >  	case GC_DISPLAY_CLOCK_267_MHZ_PNV:
> > -		return 266667;
> > +		cdclk_state->cdclk = 266667;
> > +		break;
> >  	case GC_DISPLAY_CLOCK_333_MHZ_PNV:
> > -		return 333333;
> > +		cdclk_state->cdclk = 333333;
> > +		break;
> >  	case GC_DISPLAY_CLOCK_444_MHZ_PNV:
> > -		return 444444;
> > +		cdclk_state->cdclk = 444444;
> > +		break;
> >  	case GC_DISPLAY_CLOCK_200_MHZ_PNV:
> > -		return 200000;
> > +		cdclk_state->cdclk = 200000;
> > +		break;
> >  	default:
> >  		DRM_ERROR("Unknown pnv display core clock 0x%04x\n", gcfgc);
> >  	case GC_DISPLAY_CLOCK_133_MHZ_PNV:
> > -		return 133333;
> > +		cdclk_state->cdclk = 133333;
> > +		break;
> >  	case GC_DISPLAY_CLOCK_167_MHZ_PNV:
> > -		return 166667;
> > +		cdclk_state->cdclk = 166667;
> > +		break;
> >  	}
> >  }
> >  
> > -static int i965gm_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void i965gm_get_cdclk(struct drm_i915_private *dev_priv,
> > +			     struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> >  	static const uint8_t div_3200[] = { 16, 10,  8 };
> >  	static const uint8_t div_4000[] = { 20, 12, 10 };
> >  	static const uint8_t div_5333[] = { 24, 16, 14 };
> >  	const uint8_t *div_table;
> > -	unsigned int cdclk_sel, vco = intel_hpll_vco(dev_priv);
> > +	unsigned int cdclk_sel;
> >  	uint16_t tmp = 0;
> >  
> > +	cdclk_state->vco = intel_hpll_vco(dev_priv);
> > +
> >  	pci_read_config_word(pdev, GCFGC, &tmp);
> >  
> >  	cdclk_sel = ((tmp >> 8) & 0x1f) - 1;
> > @@ -263,7 +293,7 @@ static int i965gm_get_cdclk(struct drm_i915_private *dev_priv)
> >  	if (cdclk_sel >= ARRAY_SIZE(div_3200))
> >  		goto fail;
> >  
> > -	switch (vco) {
> > +	switch (cdclk_state->vco) {
> >  	case 3200000:
> >  		div_table = div_3200;
> >  		break;
> > @@ -277,53 +307,62 @@ static int i965gm_get_cdclk(struct drm_i915_private *dev_priv)
> >  		goto fail;
> >  	}
> >  
> > -	return DIV_ROUND_CLOSEST(vco, div_table[cdclk_sel]);
> > +	cdclk_state->cdclk = DIV_ROUND_CLOSEST(cdclk_state->vco,
> > +					       div_table[cdclk_sel]);
> > +	return;
> >  
> >  fail:
> >  	DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u kHz, CFGC=0x%04x\n",
> > -		  vco, tmp);
> > -	return 200000;
> > +		  cdclk_state->vco, tmp);
> > +	cdclk_state->cdclk = 200000;
> >  }
> >  
> > -static int gm45_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void gm45_get_cdclk(struct drm_i915_private *dev_priv,
> > +			   struct intel_cdclk_state *cdclk_state)
> >  {
> >  	struct pci_dev *pdev = dev_priv->drm.pdev;
> > -	unsigned int cdclk_sel, vco = intel_hpll_vco(dev_priv);
> > +	unsigned int cdclk_sel;
> >  	uint16_t tmp = 0;
> >  
> > +	cdclk_state->vco = intel_hpll_vco(dev_priv);
> > +
> >  	pci_read_config_word(pdev, GCFGC, &tmp);
> >  
> >  	cdclk_sel = (tmp >> 12) & 0x1;
> >  
> > -	switch (vco) {
> > +	switch (cdclk_state->vco) {
> >  	case 2666667:
> >  	case 4000000:
> >  	case 5333333:
> > -		return cdclk_sel ? 333333 : 222222;
> > +		cdclk_state->cdclk = cdclk_sel ? 333333 : 222222;
> > +		break;
> >  	case 3200000:
> > -		return cdclk_sel ? 320000 : 228571;
> > +		cdclk_state->cdclk = cdclk_sel ? 320000 : 228571;
> > +		break;
> >  	default:
> >  		DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u, CFGC=0x%04x\n",
> > -			  vco, tmp);
> > -		return 222222;
> > +			  cdclk_state->vco, tmp);
> > +		cdclk_state->cdclk = 222222;
> > +		break;
> >  	}
> >  }
> >  
> > -static int hsw_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void hsw_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	uint32_t lcpll = I915_READ(LCPLL_CTL);
> >  	uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK;
> >  
> >  	if (lcpll & LCPLL_CD_SOURCE_FCLK)
> > -		return 800000;
> > +		cdclk_state->cdclk = 800000;
> >  	else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT)
> > -		return 450000;
> > +		cdclk_state->cdclk = 450000;
> >  	else if (freq == LCPLL_CLK_FREQ_450)
> > -		return 450000;
> > +		cdclk_state->cdclk = 450000;
> >  	else if (IS_HSW_ULT(dev_priv))
> > -		return 337500;
> > +		cdclk_state->cdclk = 337500;
> >  	else
> > -		return 540000;
> > +		cdclk_state->cdclk = 540000;
> >  }
> >  
> >  static int vlv_calc_cdclk(struct drm_i915_private *dev_priv,
> > @@ -349,10 +388,13 @@ static int vlv_calc_cdclk(struct drm_i915_private *dev_priv,
> >  		return 200000;
> >  }
> >  
> > -static int vlv_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void vlv_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> > -	return vlv_get_cck_clock_hpll(dev_priv, "cdclk",
> > -				      CCK_DISPLAY_CLOCK_CONTROL);
> > +	cdclk_state->vco = vlv_get_hpll_vco(dev_priv);
> > +	cdclk_state->cdclk = vlv_get_cck_clock(dev_priv, "cdclk",
> > +					       CCK_DISPLAY_CLOCK_CONTROL,
> > +					       cdclk_state->vco);
> >  }
> >  
> >  static void vlv_program_pfi_credits(struct drm_i915_private *dev_priv)
> > @@ -364,7 +406,7 @@ static void vlv_program_pfi_credits(struct drm_i915_private *dev_priv)
> >  	else
> >  		default_credits = PFI_CREDIT(8);
> >  
> > -	if (dev_priv->cdclk_freq >= dev_priv->czclk_freq) {
> > +	if (dev_priv->cdclk.hw.cdclk >= dev_priv->czclk_freq) {
> >  		/* CHV suggested value is 31 or 63 */
> >  		if (IS_CHERRYVIEW(dev_priv))
> >  			credits = PFI_CREDIT_63;
> > @@ -396,8 +438,6 @@ static void vlv_set_cdclk(struct drm_device *dev, int cdclk)
> >  	struct drm_i915_private *dev_priv = to_i915(dev);
> >  	u32 val, cmd;
> >  
> > -	WARN_ON(dev_priv->display.get_cdclk(dev_priv) != dev_priv->cdclk_freq);
> > -
> >  	if (cdclk >= 320000) /* jump to highest voltage for 400MHz too */
> >  		cmd = 2;
> >  	else if (cdclk == 266667)
> > @@ -461,8 +501,6 @@ static void chv_set_cdclk(struct drm_device *dev, int cdclk)
> >  	struct drm_i915_private *dev_priv = to_i915(dev);
> >  	u32 val, cmd;
> >  
> > -	WARN_ON(dev_priv->display.get_cdclk(dev_priv) != dev_priv->cdclk_freq);
> > -
> >  	switch (cdclk) {
> >  	case 333333:
> >  	case 320000:
> > @@ -508,23 +546,24 @@ static int bdw_calc_cdclk(int max_pixclk)
> >  		return 337500;
> >  }
> >  
> > -static int bdw_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void bdw_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	uint32_t lcpll = I915_READ(LCPLL_CTL);
> >  	uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK;
> >  
> >  	if (lcpll & LCPLL_CD_SOURCE_FCLK)
> > -		return 800000;
> > +		cdclk_state->cdclk = 800000;
> >  	else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT)
> > -		return 450000;
> > +		cdclk_state->cdclk = 450000;
> >  	else if (freq == LCPLL_CLK_FREQ_450)
> > -		return 450000;
> > +		cdclk_state->cdclk = 450000;
> >  	else if (freq == LCPLL_CLK_FREQ_54O_BDW)
> > -		return 540000;
> > +		cdclk_state->cdclk = 540000;
> >  	else if (freq == LCPLL_CLK_FREQ_337_5_BDW)
> > -		return 337500;
> > +		cdclk_state->cdclk = 337500;
> >  	else
> > -		return 675000;
> > +		cdclk_state->cdclk = 675000;
> >  }
> >  
> >  static void bdw_set_cdclk(struct drm_device *dev, int cdclk)
> > @@ -601,9 +640,9 @@ static void bdw_set_cdclk(struct drm_device *dev, int cdclk)
> >  
> >  	intel_update_cdclk(dev_priv);
> >  
> > -	WARN(cdclk != dev_priv->cdclk_freq,
> > +	WARN(cdclk != dev_priv->cdclk.hw.cdclk,
> >  	     "cdclk requested %d kHz but got %d kHz\n",
> > -	     cdclk, dev_priv->cdclk_freq);
> > +	     cdclk, dev_priv->cdclk.hw.cdclk);
> >  }
> >  
> >  static int skl_calc_cdclk(int max_pixclk, int vco)
> > @@ -629,12 +668,13 @@ static int skl_calc_cdclk(int max_pixclk, int vco)
> >  	}
> >  }
> >  
> > -static void skl_dpll0_update(struct drm_i915_private *dev_priv)
> > +static void skl_dpll0_update(struct drm_i915_private *dev_priv,
> > +			     struct intel_cdclk_state *cdclk_state)
> >  {
> >  	u32 val;
> >  
> > -	dev_priv->cdclk_pll.ref = 24000;
> > -	dev_priv->cdclk_pll.vco = 0;
> > +	cdclk_state->ref = 24000;
> > +	cdclk_state->vco = 0;
> >  
> >  	val = I915_READ(LCPLL1_CTL);
> >  	if ((val & LCPLL_PLL_ENABLE) == 0)
> > @@ -656,11 +696,11 @@ static void skl_dpll0_update(struct drm_i915_private *dev_priv)
> >  	case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1350, SKL_DPLL0):
> >  	case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620, SKL_DPLL0):
> >  	case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2700, SKL_DPLL0):
> > -		dev_priv->cdclk_pll.vco = 8100000;
> > +		cdclk_state->vco = 8100000;
> >  		break;
> >  	case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080, SKL_DPLL0):
> >  	case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2160, SKL_DPLL0):
> > -		dev_priv->cdclk_pll.vco = 8640000;
> > +		cdclk_state->vco = 8640000;
> >  		break;
> >  	default:
> >  		MISSING_CASE(val & DPLL_CTRL1_LINK_RATE_MASK(SKL_DPLL0));
> 
> This function is a bit funny now, since it sets up the cdclk state based on
> current pll0 programming, instead of looking at an atomic state.

We should probably rename it to somehting more descriptive. skl_get_dpll0()
maybe. Or maybe skl_dpll0_get_config to match the .get_config()
nomenclature used for eg. encoders. Though if we go there then
.get_cdclk() might need to be renamed to .cdclk_get_config or something.

> But so far it
> is only used to read the current cdclk, so there's no harm.
> 
> > @@ -668,46 +708,57 @@ static void skl_dpll0_update(struct drm_i915_private *dev_priv)
> >  	}
> >  }
> >  
> > -static int skl_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void skl_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	u32 cdctl;
> >  
> > -	skl_dpll0_update(dev_priv);
> > +	skl_dpll0_update(dev_priv, cdclk_state);
> > +
> > +	cdclk_state->cdclk = cdclk_state->ref;
> >  
> > -	if (dev_priv->cdclk_pll.vco == 0)
> > -		return dev_priv->cdclk_pll.ref;
> > +	if (cdclk_state->vco == 0)
> > +		return;
> >  
> >  	cdctl = I915_READ(CDCLK_CTL);
> >  
> > -	if (dev_priv->cdclk_pll.vco == 8640000) {
> > +	if (cdclk_state->vco == 8640000) {
> >  		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
> >  		case CDCLK_FREQ_450_432:
> > -			return 432000;
> > +			cdclk_state->cdclk = 432000;
> > +			break;
> >  		case CDCLK_FREQ_337_308:
> > -			return 308571;
> > +			cdclk_state->cdclk = 308571;
> > +			break;
> >  		case CDCLK_FREQ_540:
> > -			return 540000;
> > +			cdclk_state->cdclk = 540000;
> > +			break;
> >  		case CDCLK_FREQ_675_617:
> > -			return 617143;
> > +			cdclk_state->cdclk = 617143;
> > +			break;
> >  		default:
> >  			MISSING_CASE(cdctl & CDCLK_FREQ_SEL_MASK);
> > +			break;
> >  		}
> >  	} else {
> >  		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
> >  		case CDCLK_FREQ_450_432:
> > -			return 450000;
> > +			cdclk_state->cdclk = 450000;
> > +			break;
> >  		case CDCLK_FREQ_337_308:
> > -			return 337500;
> > +			cdclk_state->cdclk = 337500;
> > +			break;
> >  		case CDCLK_FREQ_540:
> > -			return 540000;
> > +			cdclk_state->cdclk = 540000;
> > +			break;
> >  		case CDCLK_FREQ_675_617:
> > -			return 675000;
> > +			cdclk_state->cdclk = 675000;
> > +			break;
> >  		default:
> >  			MISSING_CASE(cdctl & CDCLK_FREQ_SEL_MASK);
> > +			break;
> >  		}
> >  	}
> > -
> > -	return dev_priv->cdclk_pll.ref;
> >  }
> >  
> >  /* convert from kHz to .1 fixpoint MHz with -1MHz offset */
> > @@ -770,7 +821,7 @@ static void skl_dpll0_enable(struct drm_i915_private *dev_priv, int vco)
> >  				    5))
> >  		DRM_ERROR("DPLL0 not locked\n");
> >  
> > -	dev_priv->cdclk_pll.vco = vco;
> > +	dev_priv->cdclk.hw.vco = vco;
> >  
> >  	/* We'll want to keep using the current vco from now on. */
> >  	skl_set_preferred_cdclk_vco(dev_priv, vco);
> > @@ -784,7 +835,7 @@ static void skl_dpll0_disable(struct drm_i915_private *dev_priv)
> >  				   1))
> >  		DRM_ERROR("Couldn't disable DPLL0\n");
> >  
> > -	dev_priv->cdclk_pll.vco = 0;
> > +	dev_priv->cdclk.hw.vco = 0;
> >  }
> >  
> >  static void skl_set_cdclk(struct drm_i915_private *dev_priv,
> > @@ -834,11 +885,11 @@ static void skl_set_cdclk(struct drm_i915_private *dev_priv,
> >  		break;
> >  	}
> >  
> > -	if (dev_priv->cdclk_pll.vco != 0 &&
> > -	    dev_priv->cdclk_pll.vco != vco)
> > +	if (dev_priv->cdclk.hw.vco != 0 &&
> > +	    dev_priv->cdclk.hw.vco != vco)
> >  		skl_dpll0_disable(dev_priv);
> >  
> > -	if (dev_priv->cdclk_pll.vco != vco)
> > +	if (dev_priv->cdclk.hw.vco != vco)
> >  		skl_dpll0_enable(dev_priv, vco);
> >  
> >  	I915_WRITE(CDCLK_CTL, freq_select | skl_cdclk_decimal(cdclk));
> > @@ -866,8 +917,8 @@ static void skl_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  	intel_update_cdclk(dev_priv);
> >  	/* Is PLL enabled and locked ? */
> > -	if (dev_priv->cdclk_pll.vco == 0 ||
> > -	    dev_priv->cdclk_freq == dev_priv->cdclk_pll.ref)
> > +	if (dev_priv->cdclk.hw.vco == 0 ||
> > +	    dev_priv->cdclk.hw.cdclk == dev_priv->cdclk.hw.ref)
> >  		goto sanitize;
> >  
> >  	/* DPLL okay; verify the cdclock
> > @@ -878,7 +929,7 @@ static void skl_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  	 */
> >  	cdctl = I915_READ(CDCLK_CTL);
> >  	expected = (cdctl & CDCLK_FREQ_SEL_MASK) |
> > -		skl_cdclk_decimal(dev_priv->cdclk_freq);
> > +		skl_cdclk_decimal(dev_priv->cdclk.hw.cdclk);
> >  	if (cdctl == expected)
> >  		/* All well; nothing to sanitize */
> >  		return;
> > @@ -887,14 +938,14 @@ static void skl_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  	DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
> >  
> >  	/* force cdclk programming */
> > -	dev_priv->cdclk_freq = 0;
> > +	dev_priv->cdclk.hw.cdclk = 0;
> >  	/* force full PLL disable + enable */
> > -	dev_priv->cdclk_pll.vco = -1;
> > +	dev_priv->cdclk.hw.vco = -1;
> >  }
> >  
> >  void skl_uninit_cdclk(struct drm_i915_private *dev_priv)
> >  {
> > -	skl_set_cdclk(dev_priv, dev_priv->cdclk_pll.ref, 0);
> > +	skl_set_cdclk(dev_priv, dev_priv->cdclk.hw.ref, 0);
> >  }
> >  
> >  void skl_init_cdclk(struct drm_i915_private *dev_priv)
> > @@ -903,14 +954,15 @@ void skl_init_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  	skl_sanitize_cdclk(dev_priv);
> >  
> > -	if (dev_priv->cdclk_freq != 0 && dev_priv->cdclk_pll.vco != 0) {
> > +	if (dev_priv->cdclk.hw.cdclk != 0 &&
> > +	    dev_priv->cdclk.hw.vco != 0) {
> >  		/*
> >  		 * Use the current vco as our initial
> >  		 * guess as to what the preferred vco is.
> >  		 */
> >  		if (dev_priv->skl_preferred_vco_freq == 0)
> >  			skl_set_preferred_cdclk_vco(dev_priv,
> > -						    dev_priv->cdclk_pll.vco);
> > +						    dev_priv->cdclk.hw.vco);
> >  		return;
> >  	}
> >  
> > @@ -950,7 +1002,7 @@ static int bxt_de_pll_vco(struct drm_i915_private *dev_priv, int cdclk)
> >  {
> >  	int ratio;
> >  
> > -	if (cdclk == dev_priv->cdclk_pll.ref)
> > +	if (cdclk == dev_priv->cdclk.hw.ref)
> >  		return 0;
> >  
> >  	switch (cdclk) {
> > @@ -967,14 +1019,14 @@ static int bxt_de_pll_vco(struct drm_i915_private *dev_priv, int cdclk)
> >  		break;
> >  	}
> >  
> > -	return dev_priv->cdclk_pll.ref * ratio;
> > +	return dev_priv->cdclk.hw.ref * ratio;
> >  }
> >  
> >  static int glk_de_pll_vco(struct drm_i915_private *dev_priv, int cdclk)
> >  {
> >  	int ratio;
> >  
> > -	if (cdclk == dev_priv->cdclk_pll.ref)
> > +	if (cdclk == dev_priv->cdclk.hw.ref)
> >  		return 0;
> >  
> >  	switch (cdclk) {
> > @@ -987,15 +1039,16 @@ static int glk_de_pll_vco(struct drm_i915_private *dev_priv, int cdclk)
> >  		break;
> >  	}
> >  
> > -	return dev_priv->cdclk_pll.ref * ratio;
> > +	return dev_priv->cdclk.hw.ref * ratio;
> >  }
> >  
> > -static void bxt_de_pll_update(struct drm_i915_private *dev_priv)
> > +static void bxt_de_pll_update(struct drm_i915_private *dev_priv,
> > +			      struct intel_cdclk_state *cdclk_state)
> >  {
> >  	u32 val;
> >  
> > -	dev_priv->cdclk_pll.ref = 19200;
> > -	dev_priv->cdclk_pll.vco = 0;
> > +	cdclk_state->ref = 19200;
> > +	cdclk_state->vco = 0;
> >  
> >  	val = I915_READ(BXT_DE_PLL_ENABLE);
> >  	if ((val & BXT_DE_PLL_PLL_ENABLE) == 0)
> > @@ -1005,20 +1058,21 @@ static void bxt_de_pll_update(struct drm_i915_private *dev_priv)
> >  		return;
> >  
> >  	val = I915_READ(BXT_DE_PLL_CTL);
> > -	dev_priv->cdclk_pll.vco = (val & BXT_DE_PLL_RATIO_MASK) *
> > -		dev_priv->cdclk_pll.ref;
> > +	cdclk_state->vco = (val & BXT_DE_PLL_RATIO_MASK) * cdclk_state->ref;
> >  }
> >  
> > -static int bxt_get_cdclk(struct drm_i915_private *dev_priv)
> > +static void bxt_get_cdclk(struct drm_i915_private *dev_priv,
> > +			  struct intel_cdclk_state *cdclk_state)
> >  {
> >  	u32 divider;
> > -	int div, vco;
> > +	int div;
> >  
> > -	bxt_de_pll_update(dev_priv);
> > +	bxt_de_pll_update(dev_priv, cdclk_state);
> >  
> > -	vco = dev_priv->cdclk_pll.vco;
> > -	if (vco == 0)
> > -		return dev_priv->cdclk_pll.ref;
> > +	cdclk_state->cdclk = cdclk_state->ref;
> > +
> > +	if (cdclk_state->vco == 0)
> > +		return;
> >  
> >  	divider = I915_READ(CDCLK_CTL) & BXT_CDCLK_CD2X_DIV_SEL_MASK;
> >  
> > @@ -1038,10 +1092,10 @@ static int bxt_get_cdclk(struct drm_i915_private *dev_priv)
> >  		break;
> >  	default:
> >  		MISSING_CASE(divider);
> > -		return dev_priv->cdclk_pll.ref;
> > +		return;
> >  	}
> >  
> > -	return DIV_ROUND_CLOSEST(vco, div);
> > +	cdclk_state->cdclk = DIV_ROUND_CLOSEST(cdclk_state->vco, div);
> >  }
> >  
> >  static void bxt_de_pll_disable(struct drm_i915_private *dev_priv)
> > @@ -1054,12 +1108,12 @@ static void bxt_de_pll_disable(struct drm_i915_private *dev_priv)
> >  				    1))
> >  		DRM_ERROR("timeout waiting for DE PLL unlock\n");
> >  
> > -	dev_priv->cdclk_pll.vco = 0;
> > +	dev_priv->cdclk.hw.vco = 0;
> >  }
> >  
> >  static void bxt_de_pll_enable(struct drm_i915_private *dev_priv, int vco)
> >  {
> > -	int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->cdclk_pll.ref);
> > +	int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->cdclk.hw.ref);
> >  	u32 val;
> >  
> >  	val = I915_READ(BXT_DE_PLL_CTL);
> > @@ -1077,7 +1131,7 @@ static void bxt_de_pll_enable(struct drm_i915_private *dev_priv, int vco)
> >  				    1))
> >  		DRM_ERROR("timeout waiting for DE PLL lock\n");
> >  
> > -	dev_priv->cdclk_pll.vco = vco;
> > +	dev_priv->cdclk.hw.vco = vco;
> >  }
> >  
> >  static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
> > @@ -1105,7 +1159,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
> >  		divider = BXT_CDCLK_CD2X_DIV_SEL_1;
> >  		break;
> >  	default:
> > -		WARN_ON(cdclk != dev_priv->cdclk_pll.ref);
> > +		WARN_ON(cdclk != dev_priv->cdclk.hw.ref);
> >  		WARN_ON(vco != 0);
> >  
> >  		divider = BXT_CDCLK_CD2X_DIV_SEL_1;
> > @@ -1124,11 +1178,11 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
> >  		return;
> >  	}
> >  
> > -	if (dev_priv->cdclk_pll.vco != 0 &&
> > -	    dev_priv->cdclk_pll.vco != vco)
> > +	if (dev_priv->cdclk.hw.vco != 0 &&
> > +	    dev_priv->cdclk.hw.vco != vco)
> >  		bxt_de_pll_disable(dev_priv);
> >  
> > -	if (dev_priv->cdclk_pll.vco != vco)
> > +	if (dev_priv->cdclk.hw.vco != vco)
> >  		bxt_de_pll_enable(dev_priv, vco);
> >  
> >  	val = divider | skl_cdclk_decimal(cdclk);
> > @@ -1165,8 +1219,8 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  	intel_update_cdclk(dev_priv);
> >  
> > -	if (dev_priv->cdclk_pll.vco == 0 ||
> > -	    dev_priv->cdclk_freq == dev_priv->cdclk_pll.ref)
> > +	if (dev_priv->cdclk.hw.vco == 0 ||
> > +	    dev_priv->cdclk.hw.cdclk == dev_priv->cdclk.hw.ref)
> >  		goto sanitize;
> >  
> >  	/* DPLL okay; verify the cdclock
> > @@ -1184,12 +1238,12 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  	cdctl &= ~BXT_CDCLK_CD2X_PIPE_NONE;
> >  
> >  	expected = (cdctl & BXT_CDCLK_CD2X_DIV_SEL_MASK) |
> > -		   skl_cdclk_decimal(dev_priv->cdclk_freq);
> > +		skl_cdclk_decimal(dev_priv->cdclk.hw.cdclk);
> >  	/*
> >  	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
> >  	 * enable otherwise.
> >  	 */
> > -	if (dev_priv->cdclk_freq >= 500000)
> > +	if (dev_priv->cdclk.hw.cdclk >= 500000)
> >  		expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
> >  
> >  	if (cdctl == expected)
> > @@ -1200,10 +1254,10 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
> >  	DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
> >  
> >  	/* force cdclk programming */
> > -	dev_priv->cdclk_freq = 0;
> > +	dev_priv->cdclk.hw.cdclk = 0;
> >  
> >  	/* force full PLL disable + enable */
> > -	dev_priv->cdclk_pll.vco = -1;
> > +	dev_priv->cdclk.hw.vco = -1;
> >  }
> >  
> >  void bxt_init_cdclk(struct drm_i915_private *dev_priv)
> > @@ -1212,7 +1266,8 @@ void bxt_init_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  	bxt_sanitize_cdclk(dev_priv);
> >  
> > -	if (dev_priv->cdclk_freq != 0 && dev_priv->cdclk_pll.vco != 0)
> > +	if (dev_priv->cdclk.hw.cdclk != 0 &&
> > +	    dev_priv->cdclk.hw.vco != 0)
> >  		return;
> >  
> >  	/*
> > @@ -1233,7 +1288,13 @@ void bxt_init_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  void bxt_uninit_cdclk(struct drm_i915_private *dev_priv)
> >  {
> > -	bxt_set_cdclk(dev_priv, dev_priv->cdclk_pll.ref, 0);
> > +	bxt_set_cdclk(dev_priv, dev_priv->cdclk.hw.ref, 0);
> > +}
> > +
> > +bool intel_cdclk_state_compare(const struct intel_cdclk_state *a,
> > +			       const struct intel_cdclk_state *b)
> > +{
> > +	return memcmp(a, b, sizeof(*a)) == 0;
> >  }
> >  
> >  static int bdw_adjust_min_pipe_pixel_rate(struct intel_crtc_state *crtc_state,
> > @@ -1533,7 +1594,7 @@ void intel_update_max_cdclk(struct drm_i915_private *dev_priv)
> >  		dev_priv->max_cdclk_freq = 400000;
> >  	} else {
> >  		/* otherwise assume cdclk is fixed */
> > -		dev_priv->max_cdclk_freq = dev_priv->cdclk_freq;
> > +		dev_priv->max_cdclk_freq = dev_priv->cdclk.hw.cdclk;
> >  	}
> >  
> >  	dev_priv->max_dotclk_freq = intel_compute_max_dotclk(dev_priv);
> > @@ -1547,15 +1608,11 @@ void intel_update_max_cdclk(struct drm_i915_private *dev_priv)
> >  
> >  void intel_update_cdclk(struct drm_i915_private *dev_priv)
> >  {
> > -	dev_priv->cdclk_freq = dev_priv->display.get_cdclk(dev_priv);
> > +	dev_priv->display.get_cdclk(dev_priv, &dev_priv->cdclk.hw);
> >  
> > -	if (INTEL_GEN(dev_priv) >= 9)
> > -		DRM_DEBUG_DRIVER("Current CD clock rate: %d kHz, VCO: %d kHz, ref: %d kHz\n",
> > -				 dev_priv->cdclk_freq, dev_priv->cdclk_pll.vco,
> > -				 dev_priv->cdclk_pll.ref);
> > -	else
> > -		DRM_DEBUG_DRIVER("Current CD clock rate: %d kHz\n",
> > -				 dev_priv->cdclk_freq);
> > +	DRM_DEBUG_DRIVER("Current CD clock rate: %d kHz, VCO: %d kHz, ref: %d kHz\n",
> > +			 dev_priv->cdclk.hw.cdclk, dev_priv->cdclk.hw.vco,
> > +			 dev_priv->cdclk.hw.ref);
> >  
> >  	/*
> >  	 * 9:0 CMBUS [sic] CDCLK frequency (cdfreq):
> > @@ -1565,7 +1622,7 @@ void intel_update_cdclk(struct drm_i915_private *dev_priv)
> >  	 */
> >  	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
> >  		I915_WRITE(GMBUSFREQ_VLV,
> > -			   DIV_ROUND_UP(dev_priv->cdclk_freq, 1000));
> > +			   DIV_ROUND_UP(dev_priv->cdclk.hw.cdclk, 1000));
> >  }
> >  
> >  static int pch_rawclk(struct drm_i915_private *dev_priv)
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 519e5d663c5f..6c38ab299506 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -136,7 +136,7 @@ struct intel_limit {
> >  };
> >  
> >  /* returns HPLL frequency in kHz */
> > -static int valleyview_get_vco(struct drm_i915_private *dev_priv)
> > +int vlv_get_hpll_vco(struct drm_i915_private *dev_priv)
> >  {
> >  	int hpll_freq, vco_freq[] = { 800, 1600, 2000, 2400 };
> >  
> > @@ -172,7 +172,7 @@ int vlv_get_cck_clock_hpll(struct drm_i915_private *dev_priv,
> >  			   const char *name, u32 reg)
> >  {
> >  	if (dev_priv->hpll_freq == 0)
> > -		dev_priv->hpll_freq = valleyview_get_vco(dev_priv);
> > +		dev_priv->hpll_freq = vlv_get_hpll_vco(dev_priv);
> >  
> >  	return vlv_get_cck_clock(dev_priv, name, reg,
> >  				 dev_priv->hpll_freq);
> > @@ -12436,7 +12436,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
> >  	 */
> >  	if (dev_priv->display.modeset_calc_cdclk) {
> >  		if (!intel_state->cdclk_pll_vco)
> > -			intel_state->cdclk_pll_vco = dev_priv->cdclk_pll.vco;
> > +			intel_state->cdclk_pll_vco = dev_priv->cdclk.hw.vco;
> >  		if (!intel_state->cdclk_pll_vco)
> >  			intel_state->cdclk_pll_vco = dev_priv->skl_preferred_vco_freq;
> >  
> > @@ -12456,8 +12456,8 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
> >  		}
> >  
> >  		/* All pipes must be switched off while we change the cdclk. */
> > -		if (intel_state->dev_cdclk != dev_priv->cdclk_freq ||
> > -		    intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco) {
> > +		if (intel_state->dev_cdclk != dev_priv->cdclk.hw.cdclk ||
> > +		    intel_state->cdclk_pll_vco != dev_priv->cdclk.hw.vco) {
> >  			ret = intel_modeset_all_pipes(state);
> >  			if (ret < 0)
> >  				return ret;
> > @@ -12874,8 +12874,8 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
> >  		drm_atomic_helper_update_legacy_modeset_state(state->dev, state);
> >  
> >  		if (dev_priv->display.modeset_commit_cdclk &&
> > -		    (intel_state->dev_cdclk != dev_priv->cdclk_freq ||
> > -		     intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco))
> > +		    (intel_state->dev_cdclk != dev_priv->cdclk.hw.cdclk ||
> > +		     intel_state->cdclk_pll_vco != dev_priv->cdclk.hw.vco))
> >  			dev_priv->display.modeset_commit_cdclk(state);
> >  
> >  		/*
> > @@ -14724,7 +14724,7 @@ void intel_modeset_init_hw(struct drm_device *dev)
> >  
> >  	intel_update_cdclk(dev_priv);
> >  
> > -	dev_priv->atomic_cdclk_freq = dev_priv->cdclk_freq;
> > +	dev_priv->atomic_cdclk_freq = dev_priv->cdclk.hw.cdclk;
> >  
> >  	intel_init_clock_gating(dev_priv);
> >  }
> > @@ -14897,7 +14897,7 @@ int intel_modeset_init(struct drm_device *dev)
> >  
> >  	intel_update_czclk(dev_priv);
> >  	intel_update_cdclk(dev_priv);
> > -	dev_priv->atomic_cdclk_freq = dev_priv->cdclk_freq;
> > +	dev_priv->atomic_cdclk_freq = dev_priv->cdclk.hw.cdclk;
> >  
> >  	intel_shared_dpll_init(dev);
> >  
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index 45ebc9632633..73a708b8d887 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -885,7 +885,7 @@ static uint32_t ilk_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
> >  	 * divide by 2000 and use that
> >  	 */
> >  	if (intel_dig_port->port == PORT_A)
> > -		return DIV_ROUND_CLOSEST(dev_priv->cdclk_freq, 2000);
> > +		return DIV_ROUND_CLOSEST(dev_priv->cdclk.hw.cdclk, 2000);
> >  	else
> >  		return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000);
> >  }
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 8d93b7bda3ff..cc0122282a7b 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -1225,10 +1225,13 @@ void intel_init_cdclk_hooks(struct drm_i915_private *dev_priv);
> >  void intel_update_max_cdclk(struct drm_i915_private *dev_priv);
> >  void intel_update_cdclk(struct drm_i915_private *dev_priv);
> >  void intel_update_rawclk(struct drm_i915_private *dev_priv);
> > +bool intel_cdclk_state_compare(const struct intel_cdclk_state *a,
> > +			       const struct intel_cdclk_state *b);
> >  
> >  /* intel_display.c */
> >  enum transcoder intel_crtc_pch_transcoder(struct intel_crtc *crtc);
> >  void intel_update_rawclk(struct drm_i915_private *dev_priv);
> > +int vlv_get_hpll_vco(struct drm_i915_private *dev_priv);
> >  int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
> >  		      const char *name, u32 reg, int ref_freq);
> >  int vlv_get_cck_clock_hpll(struct drm_i915_private *dev_priv,
> > diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> > index 463056d80f9b..385251e48c74 100644
> > --- a/drivers/gpu/drm/i915/intel_fbc.c
> > +++ b/drivers/gpu/drm/i915/intel_fbc.c
> > @@ -829,7 +829,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)
> >  
> >  	/* WaFbcExceedCdClockThreshold:hsw,bdw */
> >  	if ((IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) &&
> > -	    cache->crtc.hsw_bdw_pixel_rate >= dev_priv->cdclk_freq * 95 / 100) {
> > +	    cache->crtc.hsw_bdw_pixel_rate >= dev_priv->cdclk.hw.cdclk * 95 / 100) {
> >  		fbc->no_fbc_reason = "pixel rate is too big";
> >  		return false;
> >  	}
> > diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> > index 1a6ff26dea20..cb50c527401f 100644
> > --- a/drivers/gpu/drm/i915/intel_panel.c
> > +++ b/drivers/gpu/drm/i915/intel_panel.c
> > @@ -1315,7 +1315,7 @@ static u32 i9xx_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> >  	if (IS_PINEVIEW(dev_priv))
> >  		clock = KHz(dev_priv->rawclk_freq);
> >  	else
> > -		clock = KHz(dev_priv->cdclk_freq);
> > +		clock = KHz(dev_priv->cdclk.hw.cdclk);
> >  
> >  	return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 32);
> >  }
> > @@ -1333,7 +1333,7 @@ static u32 i965_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> >  	if (IS_G4X(dev_priv))
> >  		clock = KHz(dev_priv->rawclk_freq);
> >  	else
> > -		clock = KHz(dev_priv->cdclk_freq);
> > +		clock = KHz(dev_priv->cdclk.hw.cdclk);
> >  
> >  	return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 128);
> >  }
> > diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
> > index 6d5efeb35823..14bbecc8f2ed 100644
> > --- a/drivers/gpu/drm/i915/intel_runtime_pm.c
> > +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
> > @@ -964,9 +964,12 @@ static void gen9_assert_dbuf_enabled(struct drm_i915_private *dev_priv)
> >  static void gen9_dc_off_power_well_enable(struct drm_i915_private *dev_priv,
> >  					  struct i915_power_well *power_well)
> >  {
> > +	struct intel_cdclk_state cdclk_state = {};
> > +
> >  	gen9_set_dc_state(dev_priv, DC_STATE_DISABLE);
> >  
> > -	WARN_ON(dev_priv->cdclk_freq != dev_priv->display.get_cdclk(dev_priv));
> > +	dev_priv->display.get_cdclk(dev_priv, &cdclk_state);
> > +	WARN_ON(!intel_cdclk_state_compare(&dev_priv->cdclk.hw, &cdclk_state));
> >  
> >  	gen9_assert_dbuf_enabled(dev_priv);
> >  

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply

* [PATCH] sign-file: fix build error in sign-file.c with libressl
From: John Crispin @ 2016-12-22 13:38 UTC (permalink / raw)
  To: David Howells, David Woodhouse
  Cc: keyrings, linux-kernel, Felix Fietkau, John Crispin

From: Felix Fietkau <nbd@nbd.name>

The sign-file tool failed to build against libressl. Fix this by extending
the PKCS7 check and thus making sign-file link against libressl without an
error.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 scripts/sign-file.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index 53af6dc..7307fd4 100755
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -41,7 +41,9 @@
  * signing with anything other than SHA1 - so we're stuck with that if such is
  * the case.
  */
-#if OPENSSL_VERSION_NUMBER < 0x10000000L || defined(OPENSSL_NO_CMS)
+#if defined(LIBRESSL_VERSION_NUMBER) || \
+	OPENSSL_VERSION_NUMBER < 0x10000000L || \
+	defined(OPENSSL_NO_CMS)
 #define USE_PKCS7
 #endif
 #ifndef USE_PKCS7
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH v3 13/15] livepatch: change to a per-task consistency model
From: Petr Mladek @ 2016-12-22 14:34 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Jessica Yu, Jiri Kosina, Miroslav Benes, linux-kernel,
	live-patching, Michael Ellerman, Heiko Carstens, x86,
	linuxppc-dev, linux-s390, Vojtech Pavlik, Jiri Slaby,
	Chris J Arges, Andy Lutomirski, Ingo Molnar, Peter Zijlstra
In-Reply-To: <20161221212505.dbxeddu2skmjmwiq@treble>

On Wed 2016-12-21 15:25:05, Josh Poimboeuf wrote:
> On Tue, Dec 20, 2016 at 06:32:46PM +0100, Petr Mladek wrote:
> > On Thu 2016-12-08 12:08:38, Josh Poimboeuf wrote:
> > > Change livepatch to use a basic per-task consistency model.  This is the
> > > foundation which will eventually enable us to patch those ~10% of
> > > security patches which change function or data semantics.  This is the
> > > biggest remaining piece needed to make livepatch more generally useful.
> > > 
> > > [1] https://lkml.kernel.org/r/20141107140458.GA21774@suse.cz
> > > 
> > > --- /dev/null
> > > +++ b/kernel/livepatch/transition.c
> > > +/*
> > > + * Initialize the global target patch state and all tasks to the initial patch
> > > + * state, and initialize all function transition states to true in preparation
> > > + * for patching or unpatching.
> > > + */
> > > +void klp_init_transition(struct klp_patch *patch, int state)
> > > +{
> > > +	struct task_struct *g, *task;
> > > +	unsigned int cpu;
> > > +	struct klp_object *obj;
> > > +	struct klp_func *func;
> > > +	int initial_state = !state;
> > > +
> > > +	WARN_ON_ONCE(klp_target_state != KLP_UNDEFINED);
> > > +
> > > +	klp_transition_patch = patch;
> > > +
> > > +	/*
> > > +	 * Set the global target patch state which tasks will switch to.  This
> > > +	 * has no effect until the TIF_PATCH_PENDING flags get set later.
> > > +	 */
> > > +	klp_target_state = state;
> > > +
> > > +	/*
> > > +	 * If the patch can be applied or reverted immediately, skip the
> > > +	 * per-task transitions.
> > > +	 */
> > > +	if (patch->immediate)
> > > +		return;
> > > +
> > > +	/*
> > > +	 * Initialize all tasks to the initial patch state to prepare them for
> > > +	 * switching to the target state.
> > > +	 */
> > > +	read_lock(&tasklist_lock);
> > > +	for_each_process_thread(g, task) {
> > > +		WARN_ON_ONCE(task->patch_state != KLP_UNDEFINED);
> > > +		task->patch_state = initial_state;
> > > +	}
> > > +	read_unlock(&tasklist_lock);
> > > +
> > > +	/*
> > > +	 * Ditto for the idle "swapper" tasks.
> > > +	 */
> > > +	get_online_cpus();
> > > +	for_each_online_cpu(cpu) {
> > > +		task = idle_task(cpu);
> > > +		WARN_ON_ONCE(task->patch_state != KLP_UNDEFINED);
> > > +		task->patch_state = initial_state;
> > > +	}
> > > +	put_online_cpus();
> > 
> > We allow to add/remove CPUs here. I am afraid that we will also need
> > to add a cpu coming/going handler that will set the task->patch_state
> > the right way. We must not set the klp_target_state until all ftrace
> > handlers are ready.
> 
> What if we instead just change the above to use for_each_possible_cpu()?
> We could do the same in klp_complete_transition().

I like this idea. It seems that there is idle task for each possible
cpu, see idle_threads_init().

IMHO, we should do the same everytime we do anything with the idle
tasks. I mean in klp_start_transition, klp_try_complete_transition()
and also complete_transition().

Then they will be handled like any other processes and we do not need
to think of any special races.


> > > +	/*
> > > +	 * Enforce the order of the task->patch_state initializations and the
> > > +	 * func->transition updates to ensure that, in the enable path,
> > > +	 * klp_ftrace_handler() doesn't see a func in transition with a
> > > +	 * task->patch_state of KLP_UNDEFINED.
> > > +	 */
> > > +	smp_wmb();
> > > +
> > > +	/*
> > > +	 * Set the func transition states so klp_ftrace_handler() will know to
> > > +	 * switch to the transition logic.
> > > +	 *
> > > +	 * When patching, the funcs aren't yet in the func_stack and will be
> > > +	 * made visible to the ftrace handler shortly by the calls to
> > > +	 * klp_patch_object().
> > > +	 *
> > > +	 * When unpatching, the funcs are already in the func_stack and so are
> > > +	 * already visible to the ftrace handler.
> > > +	 */
> > > +	klp_for_each_object(patch, obj)
> > > +		klp_for_each_func(obj, func)
> > > +			func->transition = true;
> > > +}
> > > +
> > > +/*
> > > + * Start the transition to the specified target patch state so tasks can begin
> > > + * switching to it.
> > > + */
> > > +void klp_start_transition(void)
> > > +{
> > > +	struct task_struct *g, *task;
> > > +	unsigned int cpu;
> > > +
> > > +	WARN_ON_ONCE(klp_target_state == KLP_UNDEFINED);
> > > +
> > > +	pr_notice("'%s': %s...\n", klp_transition_patch->mod->name,
> > > +		  klp_target_state == KLP_PATCHED ? "patching" : "unpatching");
> > > +
> > > +	/*
> > > +	 * If the patch can be applied or reverted immediately, skip the
> > > +	 * per-task transitions.
> > > +	 */
> > > +	if (klp_transition_patch->immediate)
> > > +		return;
> > > +
> > > +	/*
> > > +	 * Mark all normal tasks as needing a patch state update.  As they pass
> > > +	 * through the syscall barrier they'll switch over to the target state
> > > +	 * (unless we switch them in klp_try_complete_transition() first).
> > > +	 */
> > > +	read_lock(&tasklist_lock);
> > > +	for_each_process_thread(g, task)
> > > +		set_tsk_thread_flag(task, TIF_PATCH_PENDING);
> > 
> > This is called also from klp_reverse_transition(). We should set it
> > only when the task need migration. Also we should clear it when
> > the task is in the right state already.
> > 
> > It is not only optimization. It actually solves a race between
> > klp_complete_transition() and klp_update_patch_state(), see below.
> 
> I agree about the race, but if I did:
> 
> 	for_each_process_thread(g, task) {
> 		if (task->patch_state != klp_target_state)
> 			set_tsk_thread_flag(task, TIF_PATCH_PENDING);
> 		else
> 			clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
> 	}
> 
> It would still leave a small window where TIF_PATCH_PENDING gets set for
> an already patched task, if klp_update_patch_state() is running at the
> same time.

I see your point. Well, it seems that it is more complicated:

The race would be possible only when this was called from
klp_reverse_transition(). But we need to call there
rcu_synchronize() to prevent races with klp_update_patch_state()
also to prevent prelimitary patch completion.

The result is:

	if (task->patch_state != klp_target_state) {
	    # it means that the task was already migrated before
	    # we reverted klp_target_state. It means that
	    # the TIF flag was already cleared, the related
	    # klp_update_patch_state() already finished (thanks
	    # to rcu_synchronize() and new one will be called
	    # only when we set the flag again
	    # => it is safe to set it

	    # we should also check and warn when the TIF flag
	    # was not clear before we set it here


	else

	    # the task was not migrated before we reverted
	    # klp_target_state. klp_update_patch_state()
	    # could run in parallel but it will do the same
	    # what we do, clear TIF flag and keep the patch_state
	    # as is
	    # => it is safe to clear it


I agree that this is complex like hell. But it also allows use to
check that things work as we expect.

If we always set the flag here and always clear it later, we might
hide a bug.

If we want to make it slightly more straightforward, we might
clear TIF flags in klp_reverse_transaction() before we revert
klp_target_state. The later rcu_synchronize() should make sure
that all migrations are finished and non-will run in parallel.
Then we could set the TIF flag only where needed here.


> > > +	read_unlock(&tasklist_lock);
> > > +
> > > +	/*
> > > +	 * Ditto for the idle "swapper" tasks, though they never cross the
> > > +	 * syscall barrier.  Instead they switch over in cpu_idle_loop().
> > > +	 */
> > > +	get_online_cpus();
> > > +	for_each_online_cpu(cpu)
> > > +		set_tsk_thread_flag(idle_task(cpu), TIF_PATCH_PENDING);
> > > +	put_online_cpus();
> > 
> > Also this stage need to be somehow handled by CPU coming/going
> > handlers.
> 
> Here I think we could automatically switch any offline CPUs' idle tasks.
> And something similar in klp_try_complete_transition().

We still need to make sure to do not race with the cpu_up()/cpu_down()
calls.

I would use here the trick with for_each_possible_cpu() and let
the migration for the stack check.


> > > +}
> > > +
> > > +/*
> > > + * The transition to the target patch state is complete.  Clean up the data
> > > + * structures.
> > > + */
> > > +void klp_complete_transition(void)
> > > +{
> > > +	struct klp_object *obj;
> > > +	struct klp_func *func;
> > > +	struct task_struct *g, *task;
> > > +	unsigned int cpu;
> > > +
> > > +	if (klp_transition_patch->immediate)
> > > +		goto done;
> > > +
> > > +	klp_for_each_object(klp_transition_patch, obj)
> > > +		klp_for_each_func(obj, func)
> > > +			func->transition = false;
> > 
> > We should call rcu_synchronize() here. Otherwise, there
> > might be a race, see below:
> > 
> > CPU1					CPU2
> > 
> > klp_ftrace_handler()
> >   if (unlikely(func->transition))
> > 	// still true
> > 
> > 					klp_complete_transition()
> > 					  func->transition = false;
> > 					  task->patch_state =
> > 					      KLP_UNDEFINED;
> > 
> >      patch_state = current->patch_state;
> > 
> >      WARN_ON(patch_state == KLP_UNDEFINED);
> > 
> > BANG!: We print the warning.
> 
> This shouldn't be possible because klp_try_complete_transition() calls
> rcu_synchronize() before calling klp_complete_transition().  So by the
> time klp_complete_transition() is called, the ftrace handler can no
> longer see the affected func.  See the comment for rcu_synchronize() in
> klp_try_complete_transition().

But rcu_synchronize() in klp_try_complete_transition() will help only
when the patch is being disabled. The ftrace handler will still see
this function and race when the patch is being enabled.

But you are partially right. We need the rcu_synchronize() here
only when the patch is being enabled. It actually matches my comments
in klp_try_complete_transition() where I suggested to call it
only when the patch is being removed.


> > Note that that smp_wmb() is enough in klp_init_transition()
> > but it is not enough here. We need to wait longer once
> > someone might be inside the if (true) code.
> > 
> > > +	read_lock(&tasklist_lock);
> > > +	for_each_process_thread(g, task) {
> > > +		clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
> > > +		task->patch_state = KLP_UNDEFINED;
> > > +	}
> > > +	read_unlock(&tasklist_lock);
> > > +
> > > +	get_online_cpus();
> > > +	for_each_online_cpu(cpu) {
> > > +		task = idle_task(cpu);
> > > +		clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
> > 
> > If TIF_PATCH_PENDING flag is set here it means that
> > klp_update_patch_state() might get triggered and it might
> > put wrong value into task->patch_state.
> > 
> > We must make sure that all task have this cleared before
> > calling this function. This is another reason why
> > klp_init_transition() should set the flag only when
> > transition is needed.
> > 
> > We should only check the state here.
> > 
> > It still might make sense to clear it when it is set wrongly.
> > But the question is if it is really safe to continue. I am
> > afraid that it is not. It would mean that the consistency
> > model is broken and we are in strange state.
> 
> As I mentioned above, with your proposal I think there could still be a
> task with a spurious set TIF_PATCH_PENDING at this point.

I believe that it could not be here if we add that rcu_synchronize()
into klp_reverse_transition().


> Maybe instead we should clear all the TIF_PATCH_PENDING flags before the
> synchronize_rcu() in klp_try_complete_transition().

It might work. But I believe that we do not need this. If we do it,
we might hide a bug.


> > > +		task->patch_state = KLP_UNDEFINED;
> > > +	}
> > > +	put_online_cpus();
> > > +
> > > +done:
> > > +	klp_target_state = KLP_UNDEFINED;
> > > +	klp_transition_patch = NULL;
> > > +}
> > 
> > [...]
> > 
> > > +
> > > +/*
> > > + * Try to switch all remaining tasks to the target patch state by walking the
> > > + * stacks of sleeping tasks and looking for any to-be-patched or
> > > + * to-be-unpatched functions.  If such functions are found, the task can't be
> > > + * switched yet.
> > > + *
> > > + * If any tasks are still stuck in the initial patch state, schedule a retry.
> > > + */
> > > +bool klp_try_complete_transition(void)
> > > +{
> > > +	unsigned int cpu;
> > > +	struct task_struct *g, *task;
> > > +	bool complete = true;
> > > +
> > > +	WARN_ON_ONCE(klp_target_state == KLP_UNDEFINED);
> > > +
> > > +	/*
> > > +	 * If the patch can be applied or reverted immediately, skip the
> > > +	 * per-task transitions.
> > > +	 */
> > > +	if (klp_transition_patch->immediate)
> > > +		goto success;
> > > +
> > > +	/*
> > > +	 * Try to switch the tasks to the target patch state by walking their
> > > +	 * stacks and looking for any to-be-patched or to-be-unpatched
> > > +	 * functions.  If such functions are found on a stack, or if the stack
> > > +	 * is deemed unreliable, the task can't be switched yet.
> > > +	 *
> > > +	 * Usually this will transition most (or all) of the tasks on a system
> > > +	 * unless the patch includes changes to a very common function.
> > > +	 */
> > > +	read_lock(&tasklist_lock);
> > > +	for_each_process_thread(g, task)
> > > +		if (!klp_try_switch_task(task))
> > > +			complete = false;
> > > +	read_unlock(&tasklist_lock);
> > > +
> > > +	/*
> > > +	 * Ditto for the idle "swapper" tasks.
> > > +	 */
> > > +	get_online_cpus();
> > > +	for_each_online_cpu(cpu)
> > > +		if (!klp_try_switch_task(idle_task(cpu)))
> > > +			complete = false;
> > > +	put_online_cpus();
> > > +
> > > +	/*
> > > +	 * Some tasks weren't able to be switched over.  Try again later and/or
> > > +	 * wait for other methods like syscall barrier switching.
> > > +	 */
> > > +	if (!complete)
> > > +		return false;
> > > +
> > > +success:
> > > +
> > > +	/*
> > > +	 * When unpatching, all tasks have transitioned to KLP_UNPATCHED so we
> > > +	 * can now remove the new functions from the func_stack.
> > > +	 */
> > > +	if (klp_target_state == KLP_UNPATCHED)
> > > +		klp_unpatch_objects(klp_transition_patch);
> > > +
> > > +	/*
> > > +	 * Wait for all RCU read-side critical sections to complete.
> > > +	 *
> > > +	 * This has two purposes:
> > > +	 *
> > > +	 * 1) Ensure all existing critical sections in klp_update_patch_state()
> > > +	 *    complete, so task->patch_state won't be unexpectedly updated
> > > +	 *    later.
> > 
> > We should not be here if anyone still might be in klp_update_patch_state().
> 
> Depends on our discussion about conditionally setting TIF_PATCH_PENDING.

Yup.

> > > +	 *
> > > +	 * 2) When unpatching, don't allow any existing instances of
> > > +	 *    klp_ftrace_handler() to access any obsolete funcs before we reset
> > > +	 *    the func transition states to false.  Otherwise the handler may
> > > +	 *    see the deleted "new" func, see that it's not in transition, and
> > > +	 *    wrongly pick the new version of the function.
> > > +	 */
> > 
> > This makes sense but it too me long time to understand. I wonder if
> > this might be better:
> > 
> > 	/*
> > 	 * Make sure that the function is removed from ops->func_stack
> > 	 * before we clear func->transition. Otherwise the handler may
> > 	 * pick the wrong version.
> > 	 */
> 
> Sounds good.
> 
> > And I would call this only when the patch is being removed
> > 
> > 	if (klp_target_state = KLP_UNPATCHED)
> > 		synchronize_rcu();
> 
> Depends on our discussion about conditionally setting TIF_PATCH_PENDING.

And yup.

> > I think that this was the reason to remove WARN_ON_ONCE(!func)
> > in klp_ftrace_handler(). But this is not related. If this was
> > the last entry in the list, we removed the ftrace_handler
> > before removing the last entry. And unregister_ftrace_function()
> > calls rcu_synchronize() to prevent calling the handler later.
> > 
> > 
> > > +	synchronize_rcu();
> > > +
> > > +	pr_notice("'%s': %s complete\n", klp_transition_patch->mod->name,
> > > +		  klp_target_state == KLP_PATCHED ? "patching" : "unpatching");
> > > +
> > > +	/* we're done, now cleanup the data structures */
> > > +	klp_complete_transition();
> > > +
> > > +	return true;
> > > +}
> > > +
> > > +/*
> > > + * This function can be called in the middle of an existing transition to
> > > + * reverse the direction of the target patch state.  This can be done to
> > > + * effectively cancel an existing enable or disable operation if there are any
> > > + * tasks which are stuck in the initial patch state.
> > > + */
> > > +void klp_reverse_transition(void)
> > > +{
> > > +	klp_transition_patch->enabled = !klp_transition_patch->enabled;
> > > +
> > > +	klp_target_state = !klp_target_state;
> > > +
> > > +	/*
> > > +	 * Enforce the order of the write to klp_target_state above and the
> > > +	 * TIF_PATCH_PENDING writes in klp_start_transition() to ensure that
> > > +	 * klp_update_patch_state() doesn't set a wrong task->patch_state.
> > > +	 */
> > > +	smp_wmb();
> > 
> > I would call rcu_synchronize() here to make sure that
> > klp_update_patch_state() calls will not set
> > an outdated task->patch_state.
> > 
> > Note that smp_wmb() is not enough. We do not check TIF_PATCH_PENDING
> > in klp_try_switch_task(). There is a tiny race:
> > 
> > CPU1					CPU2
> > 
> > klp_update_patch_state()
> > 
> > 	if (test_and clear(task, TIF)
> > 	     READ_ONCE(klp_target_state);
> > 
> > 					mutex_lock(klp_lock);
> > 
> > 					klp_reverse_transition()
> > 					  klp_target_state =
> > 					      !klp_target_state;
> > 
> > 					  klp_start_transition()
> > 
> > 					mutex_unlock(klp_lock);
> > 
> > 					 <switch to another process>
> > 
> > 					 klp_transition_work_fn()
> > 					   mutex_lock(klp_lock);
> > 					   klp_try_complete_transition()
> > 					     klp_try_switch_task()
> > 					       if (task->patch_state ==
> > 						   klp_target_state)
> > 						  return true;
> > 
> > 	    task->patch_state = <outdated_value>;
> > 
> > 	 klp_ftrace_handler()
> > 
> > BANG: klp_ftrace_handler() will use wrong implementation according
> >       to the outdated task->patch_state. At the same time,
> >       klp_transition() is not blocked by the task because it thinks
> >       that it has a correct state.
> 
> Good find!

This is important in the puzzle.

> > > +
> > > +	klp_start_transition();
> > > +}
> > > +
> > > diff --git a/samples/livepatch/livepatch-sample.c b/samples/livepatch/livepatch-sample.c
> > > index e34f871..bb61c65 100644
> > > --- a/samples/livepatch/livepatch-sample.c
> > > +++ b/samples/livepatch/livepatch-sample.c
> > > @@ -17,6 +17,8 @@
> > >   * along with this program; if not, see <http://www.gnu.org/licenses/>.
> > >   */
> > >  
> > > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > > +
> > >  #include <linux/module.h>
> > >  #include <linux/kernel.h>
> > >  #include <linux/livepatch.h>
> > > @@ -69,6 +71,11 @@ static int livepatch_init(void)
> > >  {
> > >  	int ret;
> > >  
> > > +	if (!klp_have_reliable_stack() && !patch.immediate) {
> > > +		pr_notice("disabling consistency model!\n");
> > > +		patch.immediate = true;
> > > +	}
> > 
> > I am scared to have this in the sample module. It makes sense
> > to use the consistency model even for immediate patches because
> > it allows to remove them. But this must not be used for patches
> > that really require the consistency model. We should add
> > a big fat warning at least.
> 
> I did this so that the sample module would still work for non-x86_64
> arches, for which there's currently no way to patch kthreads.
> 
> Notice I did add a warning:
> 
>   pr_notice("disabling consistency model!\n");
> 
> Is the warning not fat enough?

The warning does not explain who did it, why, if it is safe, and when
this could be used. I suggest a comment like:

/*
 * WARNING: Use this check only when you know what you do!
 *
 * This sample patch does not change the semantic of the data structures,
 * locks, or return adresses. It is safe to be applied immediately.
 * But we want to test and use the consistency model on supported
 * architectures. It allows to remove the patch module.
 *
 * See Documentation/livepatch/livepatch.txt for more details, please.
 */

Also the message might be more explicit.

 pr_notice("livepatch-sample: The consistency model is not supported on
 this architecture. Using the immediate model that is safe enough.\n");


Alternatively, we might allow more values for patch.immediate, e.g.

enum klp_consistency_model {
     KLP_CM_IMMEDIATE,
     KLP_CM_TASK,
     KLP_CM_TASK_OR_IMMEDIATE,
};

Then we could do the decision on the kernel side.
But I am not sure if this would be widely used and it
it is worth the complication.

Best Regards,
Petr

PS: Merry Christmas and happy new year!

    I am not sure if I will be able to do another deep dive into
    this code until next year.

^ permalink raw reply


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.