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));