Forward ported from rpi upstream