| Message ID | 20170922235800.19348-1-wak@google.com (mailing list archive) |
|---|---|
| State | Accepted |
| Commit | 71e24d7731a2903b1ae2bba2b2971c654d9c2aa6 |
| Headers | show |
| Series | powerpc/opal: Fix EBUSY bug in acquiring tokens | expand |
"William A. Kennington III" <wak@google.com> writes: > The current code checks the completion map to look for the first token > that is complete. In some cases, a completion can come in but the token > can still be on lease to the caller processing the completion. If this > completed but unreleased token is the first token found in the bitmap by > another tasks trying to acquire a token, then the __test_and_set_bit > call will fail since the token will still be on lease. The acquisition > will then fail with an EBUSY. > > This patch reorganizes the acquisition code to look at the > opal_async_token_map for an unleased token. If the token has no lease it > must have no outstanding completions so we should never see an EBUSY, > unless we have leased out too many tokens. Since > opal_async_get_token_inrerruptible is protected by a semaphore, we will > practically never see EBUSY anymore. > > Signed-off-by: William A. Kennington III <wak@google.com> > --- > arch/powerpc/platforms/powernv/opal-async.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) I think this is superseeded by Cyrils rework (which he's finally posted): http://patchwork.ozlabs.org/patch/833630/ If not please let us know. cheers
<html><head></head><body dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 4, 2017, at 2:14 AM, Michael Ellerman <<a href="mailto:mpe@ellerman.id.au" class="">mpe@ellerman.id.au</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">"William A. Kennington III" <</span><a href="mailto:wak@google.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">wak@google.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> writes:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">The current code checks the completion map to look for the first token<br class="">that is complete. In some cases, a completion can come in but the token<br class="">can still be on lease to the caller processing the completion. If this<br class="">completed but unreleased token is the first token found in the bitmap by<br class="">another tasks trying to acquire a token, then the __test_and_set_bit<br class="">call will fail since the token will still be on lease. The acquisition<br class="">will then fail with an EBUSY.<br class=""><br class="">This patch reorganizes the acquisition code to look at the<br class="">opal_async_token_map for an unleased token. If the token has no lease it<br class="">must have no outstanding completions so we should never see an EBUSY,<br class="">unless we have leased out too many tokens. Since<br class="">opal_async_get_token_inrerruptible is protected by a semaphore, we will<br class="">practically never see EBUSY anymore.<br class=""><br class="">Signed-off-by: William A. Kennington III <<a href="mailto:wak@google.com" class="">wak@google.com</a>><br class="">---<br class="">arch/powerpc/platforms/powernv/opal-async.c | 6 +++---<br class="">1 file changed, 3 insertions(+), 3 deletions(-)<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I think this is superseeded by Cyrils rework (which he's finally</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">posted):</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> </span><a href="http://patchwork.ozlabs.org/patch/833630/" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://patchwork.ozlabs.org/patch/833630/</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">If not please let us know.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">cheers</span></div></blockquote></div><br class=""><div class="">Yeah, I think Cyril’s rework fixes this. I wasn’t sure how long it would take for master to receive his changes so I figured we could use something in the interim to fix the locking failures. If his changes will be mailed into the next merge window then we should have the issue fixed in master. I understand that rework probably won’t make it into stable kernels? If not then we should probably send this along to stable kernel maintainers.</div><div class=""><br class=""></div><div class="">- William</div></div></body></html>
> On Nov 4, 2017, at 2:14 AM, Michael Ellerman <mpe@ellerman.id.au <mailto:mpe@ellerman.id.au>> wrote: > > "William A. Kennington III" <wak@google.com <mailto:wak@google.com>> writes: > >> The current code checks the completion map to look for the first token >> that is complete. In some cases, a completion can come in but the token >> can still be on lease to the caller processing the completion. If this >> completed but unreleased token is the first token found in the bitmap by >> another tasks trying to acquire a token, then the __test_and_set_bit >> call will fail since the token will still be on lease. The acquisition >> will then fail with an EBUSY. >> >> This patch reorganizes the acquisition code to look at the >> opal_async_token_map for an unleased token. If the token has no lease it >> must have no outstanding completions so we should never see an EBUSY, >> unless we have leased out too many tokens. Since >> opal_async_get_token_inrerruptible is protected by a semaphore, we will >> practically never see EBUSY anymore. >> >> Signed-off-by: William A. Kennington III <wak@google.com <mailto:wak@google.com>> >> --- >> arch/powerpc/platforms/powernv/opal-async.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) > > I think this is superseeded by Cyrils rework (which he's finally > posted): > > http://patchwork.ozlabs.org/patch/833630/ <http://patchwork.ozlabs.org/patch/833630/> > > > If not please let us know. > > cheers Yeah, I think Cyril’s rework fixes this. I wasn’t sure how long it would take for master to receive his changes so I figured we could use something in the interim to fix the locking failures. If his changes will be mailed into the next merge window then we should have the issue fixed in master. I understand that rework probably won’t make it into stable kernels? If not then we should probably send this along to stable kernel maintainers. - William <html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 4, 2017, at 2:14 AM, Michael Ellerman <<a href="mailto:mpe@ellerman.id.au" class="">mpe@ellerman.id.au</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">"William A. Kennington III" <</span><a href="mailto:wak@google.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">wak@google.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> writes:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">The current code checks the completion map to look for the first token<br class="">that is complete. In some cases, a completion can come in but the token<br class="">can still be on lease to the caller processing the completion. If this<br class="">completed but unreleased token is the first token found in the bitmap by<br class="">another tasks trying to acquire a token, then the __test_and_set_bit<br class="">call will fail since the token will still be on lease. The acquisition<br class="">will then fail with an EBUSY.<br class=""><br class="">This patch reorganizes the acquisition code to look at the<br class="">opal_async_token_map for an unleased token. If the token has no lease it<br class="">must have no outstanding completions so we should never see an EBUSY,<br class="">unless we have leased out too many tokens. Since<br class="">opal_async_get_token_inrerruptible is protected by a semaphore, we will<br class="">practically never see EBUSY anymore.<br class=""><br class="">Signed-off-by: William A. Kennington III <<a href="mailto:wak@google.com" class="">wak@google.com</a>><br class="">---<br class="">arch/powerpc/platforms/powernv/opal-async.c | 6 +++---<br class="">1 file changed, 3 insertions(+), 3 deletions(-)<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I think this is superseeded by Cyrils rework (which he's finally</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">posted):</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> </span><a href="http://patchwork.ozlabs.org/patch/833630/" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://patchwork.ozlabs.org/patch/833630/</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">If not please let us know.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">cheers</span></div></blockquote></div><br class=""><div class="">Yeah, I think Cyril’s rework fixes this. I wasn’t sure how long it would take for master to receive his changes so I figured we could use something in the interim to fix the locking failures. If his changes will be mailed into the next merge window then we should have the issue fixed in master. I understand that rework probably won’t make it into stable kernels? If not then we should probably send this along to stable kernel maintainers.</div><div class=""><br class=""></div><div class="">- William</div></div></div></body></html>
William Kennington <wak@google.com> writes: >> On Nov 4, 2017, at 2:14 AM, Michael Ellerman <mpe@ellerman.id.au <mailto:mpe@ellerman.id.au>> wrote: >> >> "William A. Kennington III" <wak@google.com <mailto:wak@google.com>> writes: >> >>> The current code checks the completion map to look for the first token >>> that is complete. In some cases, a completion can come in but the token >>> can still be on lease to the caller processing the completion. If this >>> completed but unreleased token is the first token found in the bitmap by >>> another tasks trying to acquire a token, then the __test_and_set_bit >>> call will fail since the token will still be on lease. The acquisition >>> will then fail with an EBUSY. >>> >>> This patch reorganizes the acquisition code to look at the >>> opal_async_token_map for an unleased token. If the token has no lease it >>> must have no outstanding completions so we should never see an EBUSY, >>> unless we have leased out too many tokens. Since >>> opal_async_get_token_inrerruptible is protected by a semaphore, we will >>> practically never see EBUSY anymore. >>> >>> Signed-off-by: William A. Kennington III <wak@google.com <mailto:wak@google.com>> >>> --- >>> arch/powerpc/platforms/powernv/opal-async.c | 6 +++--- >>> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> I think this is superseeded by Cyrils rework (which he's finally >> posted): >> >> http://patchwork.ozlabs.org/patch/833630/ <http://patchwork.ozlabs.org/patch/833630/> >> >> If not please let us know. > > Yeah, I think Cyril’s rework fixes this. I wasn’t sure how long it > would take for master to receive his changes so I figured we could use > something in the interim to fix the locking failures. If his changes > will be mailed into the next merge window then we should have the > issue fixed in master. I understand that rework probably won’t make it > into stable kernels? If not then we should probably send this along to > stable kernel maintainers. OK. I didn't realise the bug was sufficiently bad to need a backport to stable. To make a backport easier I've merged this patch first, and then Cyril's on top of it (which essentially deletes this patch). I assume you've tested this patch at least somewhat? :) cheers
On Fri, 2017-09-22 at 23:58:00 UTC, "William A. Kennington III" wrote: > The current code checks the completion map to look for the first token > that is complete. In some cases, a completion can come in but the token > can still be on lease to the caller processing the completion. If this > completed but unreleased token is the first token found in the bitmap by > another tasks trying to acquire a token, then the __test_and_set_bit > call will fail since the token will still be on lease. The acquisition > will then fail with an EBUSY. > > This patch reorganizes the acquisition code to look at the > opal_async_token_map for an unleased token. If the token has no lease it > must have no outstanding completions so we should never see an EBUSY, > unless we have leased out too many tokens. Since > opal_async_get_token_inrerruptible is protected by a semaphore, we will > practically never see EBUSY anymore. > > Signed-off-by: William A. Kennington III <wak@google.com> Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/71e24d7731a2903b1ae2bba2b2971c cheers
diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c index cf33769a7b72..45b3feb8aa2f 100644 --- a/arch/powerpc/platforms/powernv/opal-async.c +++ b/arch/powerpc/platforms/powernv/opal-async.c @@ -39,18 +39,18 @@ int __opal_async_get_token(void) int token; spin_lock_irqsave(&opal_async_comp_lock, flags); - token = find_first_bit(opal_async_complete_map, opal_max_async_tokens); + token = find_first_zero_bit(opal_async_token_map, opal_max_async_tokens); if (token >= opal_max_async_tokens) { token = -EBUSY; goto out; } - if (__test_and_set_bit(token, opal_async_token_map)) { + if (!__test_and_clear_bit(token, opal_async_complete_map)) { token = -EBUSY; goto out; } - __clear_bit(token, opal_async_complete_map); + __set_bit(token, opal_async_token_map); out: spin_unlock_irqrestore(&opal_async_comp_lock, flags);
The current code checks the completion map to look for the first token that is complete. In some cases, a completion can come in but the token can still be on lease to the caller processing the completion. If this completed but unreleased token is the first token found in the bitmap by another tasks trying to acquire a token, then the __test_and_set_bit call will fail since the token will still be on lease. The acquisition will then fail with an EBUSY. This patch reorganizes the acquisition code to look at the opal_async_token_map for an unleased token. If the token has no lease it must have no outstanding completions so we should never see an EBUSY, unless we have leased out too many tokens. Since opal_async_get_token_inrerruptible is protected by a semaphore, we will practically never see EBUSY anymore. Signed-off-by: William A. Kennington III <wak@google.com> --- arch/powerpc/platforms/powernv/opal-async.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)