From: "Matthew R. Ochs" Subject: Re: [PATCH v5] cxlflash: Base support for IBM CXL Flash Adapter Date: Tue, 9 Jun 2015 11:01:35 -0500 Message-ID: References: <1433802653-7476-1-git-send-email-mrochs@linux.vnet.ibm.com> <55761DAF.9030203@linux.vnet.ibm.com> <55762437.6060607@linux.vnet.ibm.com> <5576CE22.1060409@linux.vnet.ibm.com> <5576FA38.5010501@linux.vnet.ibm.com> Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Return-path: Received: from e17.ny.us.ibm.com ([129.33.205.207]:41607 "EHLO e17.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933189AbbFIQBv convert rfc822-to-8bit (ORCPT ); Tue, 9 Jun 2015 12:01:51 -0400 Received: from /spool/local by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Jun 2015 12:01:50 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 001DE38C80A5 for ; Tue, 9 Jun 2015 12:01:46 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t59G1k0937748758 for ; Tue, 9 Jun 2015 16:01:46 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t59G1gjb008576 for ; Tue, 9 Jun 2015 12:01:45 -0400 In-Reply-To: <5576FA38.5010501@linux.vnet.ibm.com> Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: "Manoj N. Kumar" , Brian King Cc: linux-scsi@vger.kernel.org, James.Bottomley@HansenPartnership.com, nab@linux-iscsi.org, Christoph Hellwig , Michael Neuling , Ian Munsie Brian/Manoj, See my alternate proposal below. -matt On Jun 9, 2015, at 9:37 AM, Manoj Kumar wrote: > On 6/9/2015 6:29 AM, Brian King wrote: >>> >>> This was the optimization to avoid the MMIO for both threads. The other thread that raced should >>> do the atomic set of afu->room to a positive value. >> >> Let's take the simpler scenario of just one thread. >> >> Let's start with afu->room = 1 >> We call atomic64_dec_if_positive, which results in afu->room going to zero and 0 being returned, >> so we go into the if leg. >> >> If afu->room is zero every time we read it from the adapter and we exhaust our retries, >> we return SCSI_MLQUEUE_HOST_BUSY. However, the next time we enter cxlflash_send_cmd, >> since afu->cmd is now 0, it will no longer get decremented, but the return value will >> be -1, so we'll go down the else if leg. We'll never get into the if leg again to >> re-read afu->room from the AFU. The simplest fix might just be to set afu->room = 1 >> if you ever leave the if leg without having room. > > Good suggestion. Will atomic64_set(&afu->room, 1), if we exhaust retries in both legs. While I agree this will work it seems a bit of a kludge. What if we instead take advantage of our existing work queue and create a new work item that simply MMIO reads and atomically sets afu->room? With this, instead of slamming in a 1 to satisfy our logic such that a subsequent command will MMIO read, we would schedule the new work item and let afu->room be updated with a real value from the card. The only downside I see with this approach is that it has the potential to relax the window of time that we're 'down' (no room) and sending back busy...although that might not be such a bad thing if we were to get into this condition. Thoughts?