From patchwork Thu Nov 21 11:52:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11256137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DB87138C for ; Thu, 21 Nov 2019 12:01:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E0F42089F for ; Thu, 21 Nov 2019 12:01:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="U5WWZU7y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726593AbfKUMBr (ORCPT ); Thu, 21 Nov 2019 07:01:47 -0500 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:63153 "EHLO ste-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbfKUMBr (ORCPT ); Thu, 21 Nov 2019 07:01:47 -0500 X-Greylist: delayed 541 seconds by postgrey-1.27 at vger.kernel.org; Thu, 21 Nov 2019 07:01:46 EST Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id D24673F59D; Thu, 21 Nov 2019 12:52:43 +0100 (CET) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=U5WWZU7y; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (1024-bit key) header.d=shipmail.org Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NZRwLHAXHBD9; Thu, 21 Nov 2019 12:52:42 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 744D83F59F; Thu, 21 Nov 2019 12:52:41 +0100 (CET) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id C2466360051; Thu, 21 Nov 2019 12:52:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1574337160; bh=rADTjlZLWos97SHytV5j8Qmd2jVz1bQ6E4e0jEU56Fo=; h=From:To:Cc:Subject:Date:From; b=U5WWZU7yZFP/JrCuk/AtbxMN6B9ivocYHZ/udxnZhFc7X1XSmxuGehtLeC2/cvi3X 0c9AgQQeUD4Tltxt/Uk1RLjgIsjtHdjRFB9KrF+rs74iru9ftV3Yfs49QmQiGs8VPp 9K6ehIXqq70mcvEKDgwOkc69Hj93V8qtStmebvhA= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, pv-drivers@vmware.com Cc: Thomas Hellstrom , "James E.J. Bottomley" , "Martin K. Petersen" , Vishal Bhakta , Jim Gill Subject: [PATCH 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Date: Thu, 21 Nov 2019 12:52:03 +0100 Message-Id: <20191121115204.53060-1-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Thomas Hellstrom With swiotlb, the first byte of the sense buffer may in some cases be uninitialized since we use DMA_FROM_DEVICE, and the device incorrectly doesn't clear it. In those cases, clear it after DMA unmapping. Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Suggested-by: Vishal Bhakta Signed-off-by: Thomas Hellstrom Acked-by: Jim Gill Please enter the commit message for your changes. Lines starting --- drivers/scsi/vmw_pvscsi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 70008816c91f..8a09d184a320 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -402,6 +402,17 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, return 0; } +/* + * The device incorrectly doesn't clear the first byte of the sense + * buffer in some cases. We have to do it ourselves. + * Otherwise we run into trouble when SWIOTLB is forced. + */ +static void pvscsi_patch_sense(struct scsi_cmnd *cmd) +{ + if (cmd->sense_buffer) + cmd->sense_buffer[0] = 0; +} + static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, struct pvscsi_ctx *ctx) { @@ -544,6 +555,8 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, cmd = ctx->cmd; abort_cmp = ctx->abort_cmp; pvscsi_unmap_buffers(adapter, ctx); + if (sdstat != SAM_STAT_CHECK_CONDITION) + pvscsi_patch_sense(cmd); pvscsi_release_context(adapter, ctx); if (abort_cmp) { /* @@ -873,6 +886,7 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter) scmd_printk(KERN_ERR, cmd, "Forced reset on cmd %p\n", cmd); pvscsi_unmap_buffers(adapter, ctx); + pvscsi_patch_sense(cmd); pvscsi_release_context(adapter, ctx); cmd->result = (DID_RESET << 16); cmd->scsi_done(cmd); From patchwork Thu Nov 21 11:52:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11256139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC7F514E5 for ; Thu, 21 Nov 2019 12:01:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CB38208A1 for ; Thu, 21 Nov 2019 12:01:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="DhQtwEVk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbfKUMBs (ORCPT ); Thu, 21 Nov 2019 07:01:48 -0500 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:61503 "EHLO ste-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfKUMBr (ORCPT ); Thu, 21 Nov 2019 07:01:47 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 173E53F5A2; Thu, 21 Nov 2019 12:52:43 +0100 (CET) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=DhQtwEVk; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (1024-bit key) header.d=shipmail.org Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5QL1eylg0w_I; Thu, 21 Nov 2019 12:52:42 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 6611E3F59D; Thu, 21 Nov 2019 12:52:41 +0100 (CET) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id DFFD13601A3; Thu, 21 Nov 2019 12:52:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1574337160; bh=GgpXsnJVZPKyPe+h+0gIt+VQkmGTuW5nmRdMrtnMCT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DhQtwEVknumPNenH6P8RzVcvRF39BpRQFFa59wO9swleFk3W+XhR0GqFSLUA7zvvP GGTeCmX3cbDSVDGuZd11NrWNJLaNpuOAtUFKqydn2H4bEEiHpxF4j8zvsA04ORBiYt qHAElm5tKUqVNMazxruCP8mFnCmf1RFSLXHybl5o= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, pv-drivers@vmware.com Cc: Thomas Hellstrom , "James E.J. Bottomley" , "Martin K. Petersen" , Jim Gill Subject: [PATCH 2/2] scsi: vmw_pvscsi: Silence dma mapping errors Date: Thu, 21 Nov 2019 12:52:04 +0100 Message-Id: <20191121115204.53060-2-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191121115204.53060-1-thomas_os@shipmail.org> References: <20191121115204.53060-1-thomas_os@shipmail.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Thomas Hellstrom These errors typically occur with swiotlb when the swiotlb buffer is full. But they are transient and would typically unnecessarily worry a user. Instead of errors, print debug messages. Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Signed-off-by: Thomas Hellstrom Acked-by: Jim Gill --- drivers/scsi/vmw_pvscsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 8a09d184a320..c3f010df641e 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -365,7 +365,7 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, int segs = scsi_dma_map(cmd); if (segs == -ENOMEM) { - scmd_printk(KERN_ERR, cmd, + scmd_printk(KERN_DEBUG, cmd, "vmw_pvscsi: Failed to map cmd sglist for DMA.\n"); return -ENOMEM; } else if (segs > 1) { @@ -392,7 +392,7 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, ctx->dataPA = dma_map_single(&adapter->dev->dev, sg, bufflen, cmd->sc_data_direction); if (dma_mapping_error(&adapter->dev->dev, ctx->dataPA)) { - scmd_printk(KERN_ERR, cmd, + scmd_printk(KERN_DEBUG, cmd, "vmw_pvscsi: Failed to map direct data buffer for DMA.\n"); return -ENOMEM; } @@ -725,7 +725,7 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); if (dma_mapping_error(&adapter->dev->dev, ctx->sensePA)) { - scmd_printk(KERN_ERR, cmd, + scmd_printk(KERN_DEBUG, cmd, "vmw_pvscsi: Failed to map sense buffer for DMA.\n"); ctx->sensePA = 0; return -ENOMEM;