From patchwork Fri Jan 11 22:54:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10760775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D82F6C5 for ; Fri, 11 Jan 2019 22:54:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE612A25B for ; Fri, 11 Jan 2019 22:54:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB2B2A287; Fri, 11 Jan 2019 22:54:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B652A25B for ; Fri, 11 Jan 2019 22:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726387AbfAKWyy (ORCPT ); Fri, 11 Jan 2019 17:54:54 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45869 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbfAKWyy (ORCPT ); Fri, 11 Jan 2019 17:54:54 -0500 Received: by mail-pl1-f195.google.com with SMTP id a14so7376460plm.12 for ; Fri, 11 Jan 2019 14:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=mYiqR0xb5DoY083RSC03EBVfuw/quVoV4ynfJVjW+l0=; b=LeWYlJTQHbE56G/g/6CMvNZBSvqRjuNTA4wYqQxtbAKteyzP6Ph8OukKeVYVcrva0g DSJz6btGAXdPCUVF+JjVErcxOJrS+xVnyFb6B50OYGLZ4DTgGLTeKga9x0GGc/qEsMol dg2QZu9J/ojOBYDtab60yDBrlGpDIgTiJ92cM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mYiqR0xb5DoY083RSC03EBVfuw/quVoV4ynfJVjW+l0=; b=SaV5A2+KRcPHjg6mE1FHb4+ve5e+U77xPBwi5RiLgnCSCU6y5ntxfA+sA7ON3QBU8m 9sJ3emTikQdlIdQCHHM3MzkkeYIxkCL3JzNdFDfnN9JPilT5zfgmgWAoaYoOnMdtus+u EI5k4UAi9CzInhmQD05Lc2YOi+sQgdumFsPXFtylOt2vSGZ1spRt0sfJGF9KKEFYSTFa OwDj7J5lRs4m8jwJrQQmW9DBFpN1+3QPBozX1rDcNI4swicFHmkY4NuZMF+RatuVMQ/1 duYKqyjaQW7orkWGd2pXfH73lJwjjsXwwFBw2a8hNXW4zWkIwGQhoDDfP6t5YqFVzMQP gwUw== X-Gm-Message-State: AJcUukdZVXuu6VfvW/7zWwnPPwYUFigLWdkkbPiHPygVWNgeZ0FvY8no hwTZ+1Ks8fDuy50BlXpE/87ucA== X-Google-Smtp-Source: ALg8bN6Y621GvZnpYvOsHoDSnIctWClfEYLPAFdvl+t1nCT1HxqPa5NK9nFeRsrBgHSgEAN9kJH9OA== X-Received: by 2002:a17:902:1102:: with SMTP id d2mr16527532pla.138.1547247293624; Fri, 11 Jan 2019 14:54:53 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id m85sm130301000pfj.171.2019.01.11.14.54.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 14:54:52 -0800 (PST) From: Bjorn Andersson To: Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Douglas Anderson Subject: [PATCH] scsi: ufs: Consider device limitations for dma_mask Date: Fri, 11 Jan 2019 14:54:02 -0800 Message-Id: <20190111225402.6133-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Qualcomm SDM845 the capabilities of the UFS MEM controller states that it's capable of dealing with 64 bit addresses, but DMA addresses are truncated causing IOMMU faults when trying to issue operations. Limit the DMA mask to that of the device, so that DMA allocations is limited to the range supported by the bus and device and not just following what the controller's capabilities states. Signed-off-by: Bjorn Andersson Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson --- drivers/scsi/ufs/ufshcd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9ba7671b84f8..dc0eb59dd46f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8151,11 +8151,14 @@ EXPORT_SYMBOL_GPL(ufshcd_dealloc_host); */ static int ufshcd_set_dma_mask(struct ufs_hba *hba) { - if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) { - if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64))) - return 0; - } - return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32)); + u64 dma_mask = dma_get_mask(hba->dev); + + if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) + dma_mask &= DMA_BIT_MASK(64); + else + dma_mask &= DMA_BIT_MASK(32); + + return dma_set_mask_and_coherent(hba->dev, dma_mask); } /**