Hi Tixy,
On 09/01/13 15:25, Jon Medhurst (Tixy) wrote:
Subject: [PATCH] vexpress: Setup IRQ affinity to A7s for TC2 Date: Wed, 9 Jan 2013 14:20:19 +0000 From: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com To: tixy@linaro.orgmailto:tixy@linaro.org tixy@linaro.orgmailto:tixy@linaro.org CC: linaro-dev@linaro.orgmailto:linaro-dev@linaro.org linaro-dev@linaro.orgmailto:linaro-dev@linaro.org, Punit Agrawal Punit.Agrawal@arm.commailto:Punit.Agrawal@arm.com
On TC2, to maximise power savings, it helps to affine the IRQs to the A7s. Now that the cpu to parts mapping is available via /proc/cpuinfo, this patch introduces a script to parse this file and build a mask of particular CPU type and change the IRQ affinity to this mask.
The patch also makes the necessary changes to platform specific init script to call above script and affine the IRQs to the A7s.
Lastly, it changes the makefile to include the new script in the target.
Change-Id: I2fd2840acd4602d9145c7c2f2e839e5dda09ff99 Signed-off-by: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com
Hi Tixy,
I am not quite sure where to send this patch to get it included in Linaro. But you seem to have a few patches in this repo, so maybe you can apply this one.
Yes, I can do that. It looks like it copes OK for devices without any A7's but will give it a test to check that first :-)
I tried to ensure this was the case, but don't have anything other than TC2, so testing on other devices is most appreciated.
We also need to consider how this behaves with the big.LITTLE switcher, I'll have to ask about that.
Let me know if you have any feedback on this as well. I would be happy to incorporate that as long as the intent of the patches carries through.
One question, what happens if I offline all the A7's at run time? Will the system stop responding to interrupts, prevent the last A7 being offlined or migrate the IRQs to the A15s? Guess I can try it out when I test it, but this might not be until tomorrow now.
I just tried this - unplugging all the A7s. The irq affinity got updated to the A15s. So at least this doesn't kill the system.
Let me know if you run into issues.
Thanks, Punit
Tixy
Thanks, Punit
device.mk | 3 ++- init.arm-versatileexpress.rc | 6 ++++++ set_irq_affinity.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 set_irq_affinity.sh
diff --git a/device.mk b/device.mk index 6e6c6dd..9ca73e3 100644 --- a/device.mk +++ b/device.mk @@ -9,7 +9,8 @@ PRODUCT_COPY_FILES += \ device/linaro/vexpress/init.v2p-aarch64.rc:root/init.v2p-aarch64.rc \ device/linaro/vexpress/ueventd.v2p-aarch64.rc:root/ueventd.v2p-aarch64.rc \ device/linaro/vexpress/init.vexpress.sh:system/etc/init.vexpress.sh \
- device/linaro/vexpress/initlogo.rle:root/initlogo.rle
device/linaro/vexpress/initlogo.rle:root/initlogo.rle \
device/linaro/vexpress/set_irq_affinity.sh:root/set_irq_affinity.sh
PRODUCT_CHARACTERISTICS := tablet,nosdcard
diff --git a/init.arm-versatileexpress.rc b/init.arm-versatileexpress.rc index a71e491..d710f36 100644 --- a/init.arm-versatileexpress.rc +++ b/init.arm-versatileexpress.rc @@ -33,6 +33,12 @@ on boot chown system system /sys/class/graphics/fb0/fit_to_screen chown system system /sys/class/graphics/fb1/overlays
+# setup IRQ affinity to the A7s +service setirqaffinity /set_irq_affinity 0xc07
- class main
- user root
- oneshot
- service faketsd /system/bin/faketsd class main user bluetooth
diff --git a/set_irq_affinity.sh b/set_irq_affinity.sh new file mode 100755 index 0000000..4a09d61 --- /dev/null +++ b/set_irq_affinity.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh
+# This script sets the default affinity to the processors with the given part id. +# - part id is in hex (as seen in /proc/cpuinfo)
+function build_mask_from_part_id {
- local IFS
- local mask
- local ref_part_id
- ref_part_id=$1
- IFS=$'\n'
- for line in `cat /proc/cpuinfo`
- do
IFS=':'
set -A tokens $line
if [ "${line#'processor'}" != "$line" ]
then
cpu="${tokens[1]##' '}"
elif [ "${line#'CPU part'}" != "$line" ]
then
part_id="${tokens[1]##' '}"
if [ "$part_id" == "$ref_part_id" ]
then
(( mask |= 1 << $cpu ))
fi
fi
- done
- echo $(printf "%x" $mask)
+}
+ref_part_id=$(echo $1 | tr '[A-Z]' '[a-z]') +mask=$(build_mask_from_part_id $ref_part_id) +[ -z "$mask" ] && exit
+echo $mask > /proc/irq/default_smp_affinity
+for i in `ls /proc/irq` +do
- affinity_file="/proc/irq/$i/smp_affinity"
- [ -e $affinity_file ] && echo $mask > $affinity_file
+done
1.7.9.5
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.