Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808158/?format=api
{ "id": 808158, "url": "http://patchwork.ozlabs.org/api/patches/808158/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/5fc6930c9645c934de2586179ca3f80a055689cb.1504175330.git.robin.murphy@arm.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<5fc6930c9645c934de2586179ca3f80a055689cb.1504175330.git.robin.murphy@arm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/5fc6930c9645c934de2586179ca3f80a055689cb.1504175330.git.robin.murphy@arm.com/", "date": "2017-08-31T10:32:54", "name": "[v2] of: Restrict DMA configuration", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "d7fefc860ddcfefa0cbdc50ca9949ecedae94da7", "submitter": { "id": 65641, "url": "http://patchwork.ozlabs.org/api/people/65641/?format=api", "name": "Robin Murphy", "email": "robin.murphy@arm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/5fc6930c9645c934de2586179ca3f80a055689cb.1504175330.git.robin.murphy@arm.com/mbox/", "series": [ { "id": 787, "url": "http://patchwork.ozlabs.org/api/series/787/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=787", "date": "2017-08-31T10:32:54", "name": "[v2] of: Restrict DMA configuration", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/787/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808158/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808158/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjf0B0t6Zz9s2G\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 31 Aug 2017 20:35:22 +1000 (AEST)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xjf096vsXzDqr5\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 31 Aug 2017 20:35:21 +1000 (AEST)", "from foss.arm.com (foss.arm.com [217.140.101.70])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xjdxX2BkYzDqVg\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tThu, 31 Aug 2017 20:33:03 +1000 (AEST)", "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9FD6F13D5;\n\tThu, 31 Aug 2017 03:33:00 -0700 (PDT)", "from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com\n\t[10.1.210.88])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id\n\t2F8943F58F; Thu, 31 Aug 2017 03:32:59 -0700 (PDT)" ], "From": "Robin Murphy <robin.murphy@arm.com>", "To": "hch@lst.de,\n\trobh+dt@kernel.org", "Subject": "[PATCH v2] of: Restrict DMA configuration", "Date": "Thu, 31 Aug 2017 11:32:54 +0100", "Message-Id": "<5fc6930c9645c934de2586179ca3f80a055689cb.1504175330.git.robin.murphy@arm.com>", "X-Mailer": "git-send-email 2.13.4.dirty", "X-BeenThere": "linuxppc-dev@lists.ozlabs.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>", "Cc": "devicetree@vger.kernel.org, frowand.list@gmail.com,\n\tlinuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, \n\tm.szyprowski@samsung.com", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org", "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>" }, "content": "Moving DMA configuration to happen later at driver probe time had the\nunnoticed side-effect that we now perform DMA configuration for *every*\ndevice represented in DT, rather than only those explicitly created by\nthe of_platform and PCI code.\n\nAs Christoph points out, this is not really the best thing to do. Whilst\nthere may well be other DMA-capable buses that can benefit from having\ntheir children automatically configured after the bridge has probed,\nthere are also plenty of others like USB, MDIO, etc. that definitely do\nnot support DMA and should not be indiscriminately processed.\n\nThe good news is that in most cases the DT \"dma-ranges\" property serves\nas an appropriate indicator - per a strict interpretation of the spec,\nanything lacking a \"dma-ranges\" property should be considered not to\nhave a mapping of DMA address space from its children to its parent,\nthus anything for which of_dma_get_range() does not succeed does not\nneed DMA configuration. Certain bus types have a general expectation of\nDMA capability and carry a well-established precedent that an absent\n\"dma-ranges\" implies the same as the empty property, so we automatically\nopt those in to DMA configuration regardless, to avoid regressing most\nexisting platforms.\n\nFixes: 09515ef5ddad (\"of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices\")\nReported-by: Christoph Hellwig <hch@lst.de>\nSigned-off-by: Robin Murphy <robin.murphy@arm.com>\n---\n\nv2: Updated commit message to be more reasonable\n\n drivers/of/device.c | 48 ++++++++++++++++++++++++++++++++----------------\n 1 file changed, 32 insertions(+), 16 deletions(-)", "diff": "diff --git a/drivers/of/device.c b/drivers/of/device.c\nindex e0a28ea341fe..04c4c952dc57 100644\n--- a/drivers/of/device.c\n+++ b/drivers/of/device.c\n@@ -9,6 +9,9 @@\n #include <linux/module.h>\n #include <linux/mod_devicetable.h>\n #include <linux/slab.h>\n+#include <linux/pci.h>\n+#include <linux/platform_device.h>\n+#include <linux/amba/bus.h>\n \n #include <asm/errno.h>\n #include \"of_private.h\"\n@@ -84,31 +87,28 @@ int of_device_add(struct platform_device *ofdev)\n */\n int of_dma_configure(struct device *dev, struct device_node *np)\n {\n-\tu64 dma_addr, paddr, size;\n+\tu64 dma_addr, paddr, size = 0;\n \tint ret;\n \tbool coherent;\n \tunsigned long offset;\n \tconst struct iommu_ops *iommu;\n \tu64 mask;\n \n-\t/*\n-\t * Set default coherent_dma_mask to 32 bit. Drivers are expected to\n-\t * setup the correct supported mask.\n-\t */\n-\tif (!dev->coherent_dma_mask)\n-\t\tdev->coherent_dma_mask = DMA_BIT_MASK(32);\n-\n-\t/*\n-\t * Set it to coherent_dma_mask by default if the architecture\n-\t * code has not set it.\n-\t */\n-\tif (!dev->dma_mask)\n-\t\tdev->dma_mask = &dev->coherent_dma_mask;\n-\n \tret = of_dma_get_range(np, &dma_addr, &paddr, &size);\n \tif (ret < 0) {\n+\t\t/*\n+\t\t * For legacy reasons, we have to assume some devices need\n+\t\t * DMA configuration regardless of whether \"dma-ranges\" is\n+\t\t * correctly specified or not.\n+\t\t */\n+\t\tif (!dev_is_pci(dev) &&\n+#ifdef CONFIG_ARM_AMBA\n+\t\t dev->bus != &amba_bustype &&\n+#endif\n+\t\t dev->bus != &platform_bus_type)\n+\t\t\treturn ret == -ENODEV ? 0 : ret;\n+\n \t\tdma_addr = offset = 0;\n-\t\tsize = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);\n \t} else {\n \t\toffset = PFN_DOWN(paddr - dma_addr);\n \n@@ -129,6 +129,22 @@ int of_dma_configure(struct device *dev, struct device_node *np)\n \t\tdev_dbg(dev, \"dma_pfn_offset(%#08lx)\\n\", offset);\n \t}\n \n+\t/*\n+\t * Set default coherent_dma_mask to 32 bit. Drivers are expected to\n+\t * setup the correct supported mask.\n+\t */\n+\tif (!dev->coherent_dma_mask)\n+\t\tdev->coherent_dma_mask = DMA_BIT_MASK(32);\n+\t/*\n+\t * Set it to coherent_dma_mask by default if the architecture\n+\t * code has not set it.\n+\t */\n+\tif (!dev->dma_mask)\n+\t\tdev->dma_mask = &dev->coherent_dma_mask;\n+\n+\tif (!size)\n+\t\tsize = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);\n+\n \tdev->dma_pfn_offset = offset;\n \n \t/*\n", "prefixes": [ "v2" ] }