From patchwork Mon May 21 22:05:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10416863 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 074AF60545 for ; Mon, 21 May 2018 22:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E509328A84 for ; Mon, 21 May 2018 22:05:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D96BA28AC1; Mon, 21 May 2018 22:05:24 +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=unavailable 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 8E5F528AB6 for ; Mon, 21 May 2018 22:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753980AbeEUWFW (ORCPT ); Mon, 21 May 2018 18:05:22 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40529 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753972AbeEUWFS (ORCPT ); Mon, 21 May 2018 18:05:18 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so17429546wrc.7; Mon, 21 May 2018 15:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=misuDAYq4KfynsktycJ974YwG+oD3aB1j5Nptb6l+HQ=; b=ofbkf1s6R6b3Edys6ZBqtw6SoJrXXeBEtBEEq9kBgNpS2LeRmiXGaRPI+zEoYBiDqC 8M1/qwfsqE/4Iqj7qhI6r36qPQTJObxHHu5aBbNghtzImf4rNTskBxtnIiyCLXYpRSyj 64JPNB8BTrRyvCpFV4Y+3/GZu+4yrIalAl/3GofLL623AZj6yfEvJzI5g1Xwvj5FI7My 6kiBBdhMP0PNC//ox3rIFBO8g5aAWFS3EPe8/NXwTt1r/C+rJzFoNudZQgyOiLSgmstB YSNIki9opCl0qFvPkYyPiUQtmXzRq0ZqtJkzk53IefVwHsB9GgOCVIY1wbeM942S+87D YCJg== 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=misuDAYq4KfynsktycJ974YwG+oD3aB1j5Nptb6l+HQ=; b=ZulNa/DPvS+svNI/KW8rONyGGd2sx8IjdVlWfwv+HK2AWKrj2SJCLie6H+vvdDYPws vvfZPSp2jCzMufxTE2T4FDm+Q2oBS2DmbOo/ZibUBL1lTeY+DbEJcxuLO2mMql6ndIQ3 HTdss/hgyOkFSi2hDBq1ne4/LTQsUp8aCoh/7eoAleXIG1sxl4qdqN8YgLhyj4uNdlB8 cm6F//CTTPiiN5iKlo+z6IDP80Li15IN36OJhRvK7kjvOwntXbHCnaeytIdhK/MlU2tU 1/1uMJImW3h5TXCKMePWunDrEEz9dPP65ONVyrYLPi2oP558qTR6IYoO70aahchplpZY Lv6Q== X-Gm-Message-State: ALKqPwcxOVoWRF1gxew6ypdPHEhJN9jhRI+WxX5sy3lWZDuuOQX2AfzC dZxCKdu4iRTElHUtlTo3HakV5/j2 X-Google-Smtp-Source: AB8JxZpjt1sOlMcqxNFZT9fPlm0BS9V8elt0dqMwHcQfhAshEY0ve+UR9M2ZL5Moa841U9s3qjDGlw== X-Received: by 2002:adf:e252:: with SMTP id n18-v6mr5968903wri.118.1526940316906; Mon, 21 May 2018 15:05:16 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id 75-v6sm20254971wmw.37.2018.05.21.15.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 15:05:16 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Phil Edworthy , Marek Vasut , Arnd Bergmann , Geert Uytterhoeven , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH][RFC] PCI: rcar: Add bus notifier so we can limit the DMA range Date: Tue, 22 May 2018 00:05:14 +0200 Message-Id: <20180521220514.30256-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Phil Edworthy The PCIe DMA controller on RCar Gen2 and earlier is on 32bit bus, so limit the DMA range to 32bit. Signed-off-by: Phil Edworthy Signed-off-by: Marek Vasut Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org --- NOTE: I'm aware of https://patchwork.kernel.org/patch/9495895/ , but the discussion seems to have gone way off, so I'm sending this as a RFC. Any feedback on how to do this limiting properly would be nice. --- drivers/pci/host/pcie-rcar.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index c3eab0b95290..db2b16f40bc1 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1325,3 +1325,31 @@ static struct platform_driver rcar_pcie_driver = { .probe = rcar_pcie_probe, }; builtin_platform_driver(rcar_pcie_driver); + +static int rcar_pcie_pci_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = data; + + switch (action) { + case BUS_NOTIFY_BOUND_DRIVER: + /* Force the DMA mask to lower 32-bits */ + dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); + break; + default: + return NOTIFY_DONE; + } + + return NOTIFY_OK; +} + +static struct notifier_block device_nb = { + .notifier_call = rcar_pcie_pci_notifier, +}; + +static int __init register_rcar_pcie_pci_notifier(void) +{ + return bus_register_notifier(&pci_bus_type, &device_nb); +} + +arch_initcall(register_rcar_pcie_pci_notifier);