From patchwork Mon Jan 9 12:03:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 90421 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp46645qgi; Mon, 9 Jan 2017 04:05:28 -0800 (PST) X-Received: by 10.99.219.21 with SMTP id e21mr158336027pgg.136.1483963528476; Mon, 09 Jan 2017 04:05:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p26si2323813pgd.208.2017.01.09.04.05.28; Mon, 09 Jan 2017 04:05:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752749AbdAIMFZ (ORCPT + 4 others); Mon, 9 Jan 2017 07:05:25 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:37685 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752245AbdAIMEQ (ORCPT ); Mon, 9 Jan 2017 07:04:16 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJI003UHHJ1DI30@mailout4.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 09 Jan 2017 12:04:13 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170109120412eucas1p1e17c3c185131409590fac0f109fc2d75~YGOXlxd5r2745027450eucas1p1J; Mon, 9 Jan 2017 12:04:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 30.BB.17477.C3C73785; Mon, 9 Jan 2017 12:04:12 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170109120412eucas1p2d0f898940a61a973bcc8d1645138f0ca~YGOW3ZRwt2787227872eucas1p2L; Mon, 9 Jan 2017 12:04:12 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d000004445-08-58737c3c7211 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7C.EC.06687.E6C73785; Mon, 9 Jan 2017 12:05:02 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJI00KQMHIPLS60@eusync3.samsung.com>; Mon, 09 Jan 2017 12:04:12 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Joerg Roedel , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 2/4] iommu/exynos: Fix warnings from DMA-debug Date: Mon, 09 Jan 2017 13:03:54 +0100 Message-id: <1483963436-29803-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsWy7djPc7o2NcURBr0/VCw2zljParFgv7VF 5+wN7BbnzwOJGef3MVmsPXKX3YHN48nBeUwem1Z1snlMvrGc0aNvyypGj8+b5AJYo7hsUlJz MstSi/TtErgyfh3ZyF6wUqDidtc1pgbGm7xdjJwcEgImEqeO/meGsMUkLtxbz9bFyMUhJLCU UWL/52csIAk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hYBqjq74yT6BkXcBI8MqRpHU0uLc 9NxiQ73ixNzi0rx0veT83E2MwBDeduzn5h2MlzYGH2IU4GBU4uGd4FUUIcSaWFZcmXuIUYKD WUmEd2FFcYQQb0piZVVqUX58UWlOavEhRlOgoyYyS4km5wPjK68k3tDE0NzS0MjYwsLcyEhJ nLfkw5VwIYH0xJLU7NTUgtQimD4mDk6pBkbdhWmu3icWiH4qWCnof+R+ZJfGilV5HZMehq6Z 8juMa9XzLbH+kSr/7/Q3vtkq3fdwsmR1yP99U2LEdBb3MqtkzvyfYJLn9OVgdK+3xE85o1Ur NH7v+qn++eMRL/tahd4mo8nCa05J6yWuvOmeeyjKapGdccd85c/C3xN8vd1dyuLDfbfJ/1Ri Kc5INNRiLipOBADJcg38dwIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170109120412eucas1p2d0f898940a61a973bcc8d1645138f0ca X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170109120412eucas1p2d0f898940a61a973bcc8d1645138f0ca X-RootMTR: 20170109120412eucas1p2d0f898940a61a973bcc8d1645138f0ca References: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Add a simple checks for dma_map_single() return value to make DMA-debug checker happly. Exynos IOMMU on Samsung Exynos SoCs always use device, which has linear DMA mapping ops (dma address is equal to physical memory address), so no failures are returned from dma_map_single(). Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 058ee8425f35..b0d537e6a445 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -744,6 +744,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type) DMA_TO_DEVICE); /* For mapping page table entries we rely on dma == phys */ BUG_ON(handle != virt_to_phys(domain->pgtable)); + if (dma_mapping_error(dma_dev, handle)) + goto err_lv2ent; spin_lock_init(&domain->lock); spin_lock_init(&domain->pgtablelock); @@ -755,6 +757,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type) return &domain->domain; +err_lv2ent: + free_pages((unsigned long)domain->lv2entcnt, 1); err_counter: free_pages((unsigned long)domain->pgtable, 2); err_dma_cookie: @@ -898,6 +902,7 @@ static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain, } if (lv1ent_fault(sent)) { + dma_addr_t handle; sysmmu_pte_t *pent; bool need_flush_flpd_cache = lv1ent_zero(sent); @@ -909,7 +914,12 @@ static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain, update_pte(sent, mk_lv1ent_page(virt_to_phys(pent))); kmemleak_ignore(pent); *pgcounter = NUM_LV2ENTRIES; - dma_map_single(dma_dev, pent, LV2TABLE_SIZE, DMA_TO_DEVICE); + handle = dma_map_single(dma_dev, pent, LV2TABLE_SIZE, + DMA_TO_DEVICE); + if (dma_mapping_error(dma_dev, handle)) { + kmem_cache_free(lv2table_kmem_cache, pent); + return ERR_PTR(-EADDRINUSE); + } /* * If pre-fetched SLPD is a faulty SLPD in zero_l2_table,