From: Sukadev Bhattiprolu Date: Wed, 8 Nov 2017 02:23:45 +0000 (-0800) Subject: powerpc/vas: Use helper to unpin/close window X-Git-Tag: v4.15-rc1~81^2~35 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=36a288fe9dab9a6b0b50ffdb5c34f04c42cee2ac;p=linux.git powerpc/vas: Use helper to unpin/close window Use a helper to have the hardware unpin and mark a window closed. Signed-off-by: Sukadev Bhattiprolu Signed-off-by: Michael Ellerman --- diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c index 8ab8a8208347..95622a984b05 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -1100,6 +1100,20 @@ static void poll_window_castout(struct vas_window *window) /* stub for now */ } +/* + * Unpin and close a window so no new requests are accepted and the + * hardware can evict this window from cache if necessary. + */ +static void unpin_close_window(struct vas_window *window) +{ + u64 val; + + val = read_hvwc_reg(window, VREG(WINCTL)); + val = SET_FIELD(VAS_WINCTL_PIN, val, 0); + val = SET_FIELD(VAS_WINCTL_OPEN, val, 0); + write_hvwc_reg(window, VREG(WINCTL), val); +} + /* * Close a window. * @@ -1114,8 +1128,6 @@ static void poll_window_castout(struct vas_window *window) */ int vas_win_close(struct vas_window *window) { - u64 val; - if (!window) return 0; @@ -1131,11 +1143,7 @@ int vas_win_close(struct vas_window *window) poll_window_busy_state(window); - /* Unpin window from cache and close it */ - val = read_hvwc_reg(window, VREG(WINCTL)); - val = SET_FIELD(VAS_WINCTL_PIN, val, 0); - val = SET_FIELD(VAS_WINCTL_OPEN, val, 0); - write_hvwc_reg(window, VREG(WINCTL), val); + unpin_close_window(window); poll_window_castout(window);