You are not logged in.

#1 2017-09-11 13:34:03

MrKebi
Member
Registered: 2016-04-12
Posts: 33

Macbook Pro 8.2 and AMD GPU suspend

Hello,


I am posting here because I have some troubles with my Macbook Pro 2011 (8.2 model). The AMD card is faulty (known problem for this model), so I disabled it like the wiki documentation show it: https://wiki.archlinux.org/index.php/Ma … 8,3_(2011). Everything is working, I had reduced my battery consommation, I was happy.

But recently, I had some troubles with this AMD card after suspend or hibernation. In fact, I think I observed the electrical reactivation of the card (observed with powertop,  approximatively 5W more after resume in same conditions) after resume. And I don't know how to disable it again. The problem is, my AMD card is faulty so I can detect it with lspci, and so I can't disable it with acpi_call or vgaswitcheroo.


Thanks by advance !

uname -a
Linux MacbookPro-Archlinux 4.12.10-1-macbook #1 SMP PREEMPT Sat Sep 2 18:56:43 EDT 2017 x86_64 GNU/Linux

cat /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet i915.modeset=1 i915.fastboot=1 i915.lvds_channel_mode=2 i915.enable_rc6=1 i915.enable_fbc=1 i915.semaphores=1 pcie_aspm=force resume=/dev/sda2 resume_offset=1019904 video.use_native_backlight=1"
GRUB_CMDLINE_LINUX=""

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable Hidden Menu, and optionally hide the timeout count
#GRUB_HIDDEN_TIMEOUT=5
#GRUB_HIDDEN_TIMEOUT_QUIET=true

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter 
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx" 
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper 
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/path/to/wallpaper"
#GRUB_THEME="/path/to/gfxtheme"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

#GRUB_SAVEDEFAULT="true"

cat /etc/grub.d/00_header 
#! /bin/sh
set -e

# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
grub_lang=`echo $LANG | cut -d . -f 1`

export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"

. "$pkgdatadir/grub-mkconfig_lib"

# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
for i in ${GRUB_PRELOAD_MODULES} ; do
  echo "insmod $i"
done

if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi

if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi

cat << EOF
if [ -s \$prefix/grubenv ]; then
  load_env
fi
EOF
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
    cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
   set default="${GRUB_DEFAULT_BUTTON}"
elif [ "\${next_entry}" ] ; then
   set default="\${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${GRUB_DEFAULT}"
fi
EOF
else
    cat <<EOF
if [ "\${next_entry}" ] ; then
   set default="\${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${GRUB_DEFAULT}"
fi
EOF
fi
cat <<EOF

if [ x"\${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "\${prev_saved_entry}" ]; then
  set saved_entry="\${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "\${boot_once}" ]; then
    saved_entry="\${chosen}"
    save_env saved_entry
  fi
}

function load_video {
EOF
if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
    cat <<EOF
  insmod ${GRUB_VIDEO_BACKEND}
EOF
else
# If all_video.mod isn't available load all modules available
# with versions prior to introduction of all_video.mod
cat <<EOF
  if [ x\$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
EOF
fi
cat <<EOF
}

EOF

if [ x$GRUB_COLOR_NORMAL != x ] && [ x$GRUB_COLOR_HIGHLIGHT != x ] ; then
    cat << EOF
set menu_color_normal=$GRUB_COLOR_NORMAL
set menu_color_highlight=$GRUB_COLOR_HIGHLIGHT

EOF
fi

serial=0;
gfxterm=0;
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
    if [ xserial = "x$x" ]; then
	serial=1;
    fi
    if [ xgfxterm = "x$x" ]; then
	gfxterm=1;
    fi
done

if [ "x$serial" = x1 ]; then
    if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
	grub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"
	GRUB_SERIAL_COMMAND=serial
    fi
    echo "${GRUB_SERIAL_COMMAND}"
fi

if [ "x$gfxterm" = x1 ]; then
    if [ -n "$GRUB_FONT" ] ; then
       # Make the font accessible
       prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
    cat << EOF
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
EOF
    else
	for dir in "${pkgdatadir}" "`echo '//boot/grub' | sed "s,//*,/,g"`" /usr/share/grub ; do
	    for basename in unicode unifont ascii; do
		path="${dir}/${basename}.pf2"
		if is_path_readable_by_grub "${path}" > /dev/null ; then
		    font_path="${path}"
		else
		    continue
		fi
		break 2
	    done
	done
	if [ -n "${font_path}" ] ; then
    cat << EOF
if [ x\$feature_default_font_path = xy ] ; then
   font=unicode
else
EOF
                # Make the font accessible
		prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
    cat << EOF
    font="`make_system_path_relative_to_its_root "${font_path}"`"
fi

if loadfont \$font ; then
EOF
	    else
    cat << EOF
if loadfont unicode ; then
EOF
	    fi
	fi

    cat << EOF
  set gfxmode=${GRUB_GFXMODE}
outb 0x728 1
outb 0x710 2
outb 0x740 2
outb 0x750 0
 load_video
  insmod gfxterm
EOF

# Gettext variables and module
if [ "x${LANG}" != "xC" ] &&  [ "x${LANG}" != "x" ]; then
  cat << EOF
  set locale_dir=\$prefix/locale
  set lang=${grub_lang}
  insmod gettext
EOF
fi

cat <<EOF
fi
EOF
fi

case x${GRUB_TERMINAL_INPUT} in
  x)
    # Just use the native terminal
  ;;
  x*)
    cat << EOF
terminal_input ${GRUB_TERMINAL_INPUT}
EOF
  ;;
esac

case x${GRUB_TERMINAL_OUTPUT} in
  x)
    # Just use the native terminal
  ;;
  x*)
    cat << EOF
terminal_output ${GRUB_TERMINAL_OUTPUT}
EOF
  ;;
esac

if [ "x$gfxterm" = x1 ]; then
    if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
	&& is_path_readable_by_grub "$GRUB_THEME"; then
	gettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2

	prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
	cat << EOF
insmod gfxmenu
EOF
	themedir="`dirname "$GRUB_THEME"`"
	for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
	    if [ -f "$x" ]; then
		cat << EOF
loadfont (\$root)`make_system_path_relative_to_its_root $x`
EOF
	    fi
	done
	if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
	    cat << EOF
insmod jpeg
EOF
	fi
	if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
	    cat << EOF
insmod png
EOF
	fi
	if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
	    cat << EOF
insmod tga
EOF
	fi
	    
	cat << EOF
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
export theme
EOF
    elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
	    && is_path_readable_by_grub "$GRUB_BACKGROUND"; then
	gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
	case "$GRUB_BACKGROUND" in 
	    *.png)         reader=png ;;
	    *.tga)         reader=tga ;;
	    *.jpg|*.jpeg)  reader=jpeg ;;
	    *)             gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
	esac
	prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
	cat << EOF
insmod $reader
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
EOF
    fi
fi

make_timeout ()
{
    if [ "x${3}" != "x" ] ; then
	timeout="${2}"
	style="${3}"
    elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then
	# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
	timeout="${1}"
	if [ "x${2}" != "x0" ] ; then
	    grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
	fi
	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
	    style="hidden"
	    verbose=
	else
	    style="countdown"
	    verbose=" --verbose"
	fi
    else
	# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
	timeout="${2}"
	style="menu"
    fi
    cat << EOF
if [ x\$feature_timeout_style = xy ] ; then
  set timeout_style=${style}
  set timeout=${timeout}
EOF
    if [ "x${style}" = "xmenu" ] ; then
	cat << EOF
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=${timeout}
EOF
    else
	cat << EOF
# Fallback hidden-timeout code in case the timeout_style feature is
# unavailable.
elif sleep${verbose} --interruptible ${timeout} ; then
  set timeout=0
EOF
    fi
    cat << EOF
fi
EOF
}

if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
    cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
EOF
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_STYLE_BUTTON}"
echo else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
echo fi
else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
fi

if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
    cat <<EOF
cmosclean $GRUB_BUTTON_CMOS_ADDRESS
EOF
fi

# Play an initial tune
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
  echo "play ${GRUB_INIT_TUNE}"
fi

if [ "x${GRUB_BADRAM}" != "x" ] ; then
  echo "badram ${GRUB_BADRAM}"
fi

lspci
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:01.1 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Universal Host Controller #5 (rev 05)
00:1a.7 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b5)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b5)
00:1c.2 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 3 (rev b5)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Universal Host Controller #1 (rev 05)
00:1d.7 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset Family LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port Mobile SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 05)
02:00.0 Ethernet controller: Broadcom Limited NetXtreme BCM57765 Gigabit Ethernet PCIe (rev 10)
02:00.1 SD Host controller: Broadcom Limited BCM57765/57785 SDXC/MMC Card Reader (rev 10)
03:00.0 Network controller: Broadcom Limited BCM4331 802.11a/b/g/n (rev 02)
04:00.0 FireWire (IEEE 1394): LSI Corporation FW643 [TrueFire] PCIe 1394b Controller (rev 08)
05:00.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
06:00.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
06:03.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
06:04.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
06:05.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
06:06.0 PCI bridge: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]
07:00.0 System peripheral: Intel Corporation CV82524 Thunderbolt Controller [Light Ridge 4C 2010]

Last edited by MrKebi (2017-09-11 13:35:25)


Xiaomi Notebook Pro i5-8250u 8Go 256 + 240 Go with optimus-manager : Archlinux/Plasma
Desktop : i7-4770k 12Go RX 580 SSD 120 Go + HDDs 2To : Archlinux/Plasma

Offline

#2 2017-09-13 17:10:18

MrKebi
Member
Registered: 2016-04-12
Posts: 33

Re: Macbook Pro 8.2 and AMD GPU suspend

up please.


Xiaomi Notebook Pro i5-8250u 8Go 256 + 240 Go with optimus-manager : Archlinux/Plasma
Desktop : i7-4770k 12Go RX 580 SSD 120 Go + HDDs 2To : Archlinux/Plasma

Offline

#3 2017-09-13 20:47:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Macbook Pro 8.2 and AMD GPU suspend


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2017-11-02 10:02:48

Xand_69
Member
Registered: 2017-11-02
Posts: 1

Re: Macbook Pro 8.2 and AMD GPU suspend

1. Create disable-ati.c
#include <stdio.h>
#include <sys/io.h>

#define PORT_SWITCH_DISPLAY 0x710
#define PORT_SWITCH_SELECT 0x728
#define PORT_SWITCH_DDC 0x740
#define PORT_DISCRETE_POWER 0x750
static int gmux_switch_to_igd()
{
    outb(1, PORT_SWITCH_SELECT);
    outb(2, PORT_SWITCH_DISPLAY);
    outb(2, PORT_SWITCH_DDC);
    return 0;
}
static void mbp_gpu_power(int state)
{
    outb(state, PORT_DISCRETE_POWER);
}
int main(int argc, char **argv)
{
    if (iopl(3) < 0)
        {
            perror ("No IO permissions");
            return 1;
        }
mbp_gpu_power(0);
gmux_switch_to_igd();
return 0;
}
2. Next, compile it with gcc:

sudo gcc -O2 -o /usr/local/sbin/disable-ati disable-ati.c
3. Create /lib/systemd/system/disable-ati.service
# disable gpu - systemd suspend/resume service
#

[Unit]
Description=disable ATI GPU suspend/resume
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/sbin/disable-ati
ExecStop=/usr/local/sbin/disable-ati

[Install]
WantedBy=sleep.target
4. Enable and start disable-ati.service
profit ...
I have macbookpro 8.3, ati broken too(.

Last edited by Xand_69 (2017-11-02 10:03:36)

Offline

Board footer

Powered by FluxBB