From patchwork Thu Mar 7 00:04:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10842111 X-Patchwork-Delegate: geert@linux-m68k.org 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 62D391669 for ; Thu, 7 Mar 2019 00:04:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F1E42DF25 for ; Thu, 7 Mar 2019 00:04:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4309B2DF71; Thu, 7 Mar 2019 00:04:49 +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,FREEMAIL_FROM,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 9C1752DF25 for ; Thu, 7 Mar 2019 00:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbfCGAEs (ORCPT ); Wed, 6 Mar 2019 19:04:48 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54150 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfCGAEs (ORCPT ); Wed, 6 Mar 2019 19:04:48 -0500 Received: by mail-wm1-f67.google.com with SMTP id e74so7578744wmg.3; Wed, 06 Mar 2019 16:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RsyiXtrERdpKhf948BNoHs6KFXRsfkG+m5eMNygOTsY=; b=lfV1/MoDOOOHq6MN2NpUiOVb3tS9Qs7ndM8f2zX2zp+ZshSMY4dErTE4V/5crMXpTr c1vIL1Gh4Y88jHAIg0d5qN0uM3oYcV6fxjIsXxtYgjgBkGRnmQrzn7V2G6lBzEHBhTOH ycNkt7izypZL2fq2irKlTLh9AKkbtsqpvZGEHRBUSG3ayzda/LlOTFujADTQMlIh3Ocu DsMfxKm/zin6TwXcStwV/j0iNJn8DlZAqOoZyj6N0ZSkRoleu8pQilp8H94Ntjm0g2Mb 0Nhqtvrv4QfRHiMA7WkIcnpLQibwx64KTV9q+1uAxa87iwzx1LRf84ptDPh4py0S6iK6 n+0A== 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:mime-version :content-transfer-encoding; bh=RsyiXtrERdpKhf948BNoHs6KFXRsfkG+m5eMNygOTsY=; b=PqHcWpVhBkBXMu3dQ5m0ntV6YHKwOKMk7SLRpz8jRa8aijiTmnEyl527Phs/5Ikadn 9KaXN5grTwlB11eaBXhvV1oO9kSuNNkBCD2zAJIMPyhuHz7LlJ0hTVwpr2hglUHcGjtD koECylPaNM8vSd+gsZL3Klz9rwLGLfkv/2EPHt/3bdOGBRi/WUxBc17m4L97WEGd9Ffj sxXb/ouwzmVl4aGSpePZ0h/IIIXQucQejw0ULhNgjPyztIo+5T+Tm+LknOto4nOHdZ2p tfqjj2nsDQNSNBeJErdrXavKio5EO732CPQNyKJAlHoSudIbaxepmY5SdQX1Gwv37zj3 pEaA== X-Gm-Message-State: APjAAAVWuUQRvU+oZccUHU7FYaaeX3ElY0BxDuk46hM2RBTatjYqftai fP7noI2N06qg4xQeSj6BZ+f/h1OQ X-Google-Smtp-Source: APXvYqxQquUdrWyJ/WAJKha1c17+MslNr4y/yfpEN44Oe5nis6OqczmBYSegEnQ54cTT3x035erAYA== X-Received: by 2002:a1c:63d4:: with SMTP id x203mr3992117wmb.128.1551917085535; Wed, 06 Mar 2019 16:04:45 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id a22sm3381642wmj.35.2019.03.06.16.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 16:04:44 -0800 (PST) From: marek.vasut@gmail.com To: linux-ide@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Marek Vasut , Christoph Hellwig , Geert Uytterhoeven , Jens Axboe , Jens Axboe , Keith Busch , Robin Murphy , Sagi Grimberg , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/2] [RFC] ata: ahci: Respect bus DMA constraints Date: Thu, 7 Mar 2019 01:04:39 +0100 Message-Id: <20190307000440.8708-1-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Since commit 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate"), the upstream bus can constraint device DMA range. Respect that constraint and do not change the device DMA masks if they were already set. This is applicable e.g. on systems where the PCIe controller cannot expose the full address space range. Such a system may have a 64bit CPU with DRAM mapped both below and above the 32bit address space, yet the PCIe devices can not perform DMA directly to/from the DRAM range above the 32bit limit. Hence, for such setup to work, all the buffers must exist below the 32bit limit. Signed-off-by: Marek Vasut Cc: Christoph Hellwig Cc: Geert Uytterhoeven Cc: Jens Axboe Cc: Jens Axboe Cc: Keith Busch Cc: Robin Murphy Cc: Sagi Grimberg Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-ide@vger.kernel.org To: linux-nvme@lists.infradead.org --- drivers/ata/ahci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 021ce46e2e57..2acce056dd8c 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -926,6 +926,13 @@ static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac) if (pdev->dma_mask && pdev->dma_mask < DMA_BIT_MASK(32)) return 0; + /* + * The upstream device could have applied DMA constraints already, + * respect those and do not change the DMA masks. + */ + if (pdev->dev.dma_mask && pdev->dev.coherent_dma_mask) + return 0; + if (using_dac && !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); From patchwork Thu Mar 7 00:04:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10842113 X-Patchwork-Delegate: geert@linux-m68k.org 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 D8F6613B5 for ; Thu, 7 Mar 2019 00:05:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C48A22DF98 for ; Thu, 7 Mar 2019 00:05:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B80ED2E0DF; Thu, 7 Mar 2019 00:05:00 +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,FREEMAIL_FROM,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 4CC042DF98 for ; Thu, 7 Mar 2019 00:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfCGAE7 (ORCPT ); Wed, 6 Mar 2019 19:04:59 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36668 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbfCGAE7 (ORCPT ); Wed, 6 Mar 2019 19:04:59 -0500 Received: by mail-wr1-f66.google.com with SMTP id o17so15402700wrw.3; Wed, 06 Mar 2019 16:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JOq4o/gGBKYosn1k7l7U3C9cWiFchEJt6ahMuB7Tvbg=; b=RtoqJlg22b0Q4xrOjXexLh1hsP8j74VkgY5OWB/UHls24EsvGuKAgOCQBlTmgWACIV 1vUaTxjfZEmkjxANiaJgts/7HRd4B4mFISMGD9y56CDQ2q8hWXRO8PiT6uZPzLSCMaX1 UhjXyRCiDfqunXnC0JCcN/xQIGIiASNsZbUAJrBi0CzD7KCO1/TEtkGS/x5DdSKKcoTY XKq7gCAL1AlRngIBj01HsbmOMxlv8+ZbRE57GtKx8hWuPdPa0M2bKcZRyfMP2HIpdxoR h6vXk366gQVrb3wAishuy3EUXHJHWQnSu91m4YGDhCoho6/8Pp6b2RxZaVkU+h1Hhilu s6cQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=JOq4o/gGBKYosn1k7l7U3C9cWiFchEJt6ahMuB7Tvbg=; b=Mk2xMkbtfAUHuCw6KRqGseAi9pMwwVUAM/tV3kIWykwG2OTruOURRZebhMr8Np6KiC lpxqVCKFdskwdT362WwPZ4OdUS/8McDUQG73WIZfK9TQP//Go5Ae+VU03DRN2cdfCxKw xA4S0DwrrWa2KTKQaU2aXlX1tVLksck3mHhtEH0DfMsMYU1QgnMg/lAocsi8YTrxtR4l MtYJfTEaLJT9T0q7xwZ3Tlk2sEiwVe+FBTjRdmxIn0dJsBP9fEEdXtQULxdKDflgfHY2 0CtYZvLdM6yg1vkk8n5VjvBkABwypU2p0NvL9CZNhNwpSC7r7ZAW/+l+2ZFGHNvkWQir U7/A== X-Gm-Message-State: APjAAAXeSnSwWgPBxVeLvZCvSsKYmbItCO94uPDnGkBVtPmB7ZTA14Mg 9XeiEAFM419ZX0bsVtLp0N+JLFmW X-Google-Smtp-Source: APXvYqwMIDUADyD/Qipl8keh4e4um+QfcZHkiUJF2DoDBzXybUfaPKq/R8LrXOuLrB5QgZ3APWNXOA== X-Received: by 2002:a05:6000:1c2:: with SMTP id t2mr4993658wrx.109.1551917097157; Wed, 06 Mar 2019 16:04:57 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id a22sm3381642wmj.35.2019.03.06.16.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 16:04:56 -0800 (PST) From: marek.vasut@gmail.com To: linux-ide@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Marek Vasut , Christoph Hellwig , Geert Uytterhoeven , Jens Axboe , Jens Axboe , Keith Busch , Robin Murphy , Sagi Grimberg , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 2/2] [RFC] nvme-pci: Respect bus DMA constraints Date: Thu, 7 Mar 2019 01:04:40 +0100 Message-Id: <20190307000440.8708-2-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307000440.8708-1-marek.vasut@gmail.com> References: <20190307000440.8708-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Since commit 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate"), the upstream bus can constraint device DMA range. Respect that constraint and do not change the device DMA masks if they were already set. This is applicable e.g. on systems where the PCIe controller cannot expose the full address space range. Such a system may have a 64bit CPU with DRAM mapped both below and above the 32bit address space, yet the PCIe devices can not perform DMA directly to/from the DRAM range above the 32bit limit. Hence, for such setup to work, all the buffers must exist below the 32bit limit. Signed-off-by: Marek Vasut Cc: Christoph Hellwig Cc: Geert Uytterhoeven Cc: Jens Axboe Cc: Jens Axboe Cc: Keith Busch Cc: Robin Murphy Cc: Sagi Grimberg Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-ide@vger.kernel.org To: linux-nvme@lists.infradead.org --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 92bad1c810ac..8ec873fb86b1 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2323,7 +2323,8 @@ static int nvme_pci_enable(struct nvme_dev *dev) pci_set_master(pdev); - if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) && + if (!dev->dev->coherent_dma_mask && + dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) && dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32))) goto disable;