Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/dp/mst: Handle invalid link bandwidth from DPCD gracefully

Don't BUG out if the link reports an invalid (or plain unknown)
bandwidth value, but report the failure and fail gracefully.

Fixes a trivial compiler warning in case the BUG is ever compiled away.

Link: http://lkml.kernel.org/p/1415785566-12758-1-git-send-email-geert@linux-m68k.org
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Chris Wilson and committed by
Dave Airlie
b853fdb3 db883628

+22 -6
+22 -6
drivers/gpu/drm/drm_dp_mst_topology.c
··· 1799 1799 return 0; 1800 1800 } 1801 1801 1802 - static int drm_dp_get_vc_payload_bw(int dp_link_bw, int dp_link_count) 1802 + static bool drm_dp_get_vc_payload_bw(int dp_link_bw, 1803 + int dp_link_count, 1804 + int *out) 1803 1805 { 1804 1806 switch (dp_link_bw) { 1807 + default: 1808 + DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count: %d)\n", 1809 + dp_link_bw, dp_link_count); 1810 + return false; 1811 + 1805 1812 case DP_LINK_BW_1_62: 1806 - return 3 * dp_link_count; 1813 + *out = 3 * dp_link_count; 1814 + break; 1807 1815 case DP_LINK_BW_2_7: 1808 - return 5 * dp_link_count; 1816 + *out = 5 * dp_link_count; 1817 + break; 1809 1818 case DP_LINK_BW_5_4: 1810 - return 10 * dp_link_count; 1819 + *out = 10 * dp_link_count; 1820 + break; 1811 1821 } 1812 - BUG(); 1822 + return true; 1813 1823 } 1814 1824 1815 1825 /** ··· 1851 1841 goto out_unlock; 1852 1842 } 1853 1843 1854 - mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1], mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK); 1844 + if (!drm_dp_get_vc_payload_bw(mgr->dpcd[1], 1845 + mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK, 1846 + &mgr->pbn_div)) { 1847 + ret = -EINVAL; 1848 + goto out_unlock; 1849 + } 1850 + 1855 1851 mgr->total_pbn = 2560; 1856 1852 mgr->total_slots = DIV_ROUND_UP(mgr->total_pbn, mgr->pbn_div); 1857 1853 mgr->avail_slots = mgr->total_slots;