From patchwork Tue Jun 27 15:02:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 106443 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp2504693obb; Tue, 27 Jun 2017 08:06:31 -0700 (PDT) X-Received: by 10.99.120.193 with SMTP id t184mr5695152pgc.35.1498575991409; Tue, 27 Jun 2017 08:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498575991; cv=none; d=google.com; s=arc-20160816; b=AFDZOWBFvKuMmfPe0WJWQMtOdbfP54Yf5l9NcxiAb2umdCN1PUlxmKKN9jEQfOlY/5 PROoVBeSluQyeqOP46XUBfpbLLtbR4JhkBZIs/qUOxMT5+AD6cccKIqIbTmF87OSsyUr orA92jvQ0ynfQ+tTZtYj2+YCy1ojosJKUOrK7lB6lZCsECNVychbqbaVc3UnuJRQccUP 0b+X1+ACPvHbRBQiRjvc54DbVXXZZuUJ4NfSMG00eqQRF8VBTKtC4BQeVAsq7Q4+pZhj n0g3IBXVzI3/XJW/QY5zUqX0M73SHlCgX2SEZf4x2JEYZ4445p5QhWEh8dqbBCz4KpJR O3oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tlCi+0kaEqezpxgXAZuMrxBJe4AyFswWCmf7utUnyzI=; b=RqmDtnkNmcS2lwDrWw/yg3WMEWDYPwPLJaQsm/wi7GVjiQ6fp6roX2xi/L65o6oLAj yb3J1chA8/NLh+lwkkx5uqamDQ3GS59p9WnpKNBdhFpPtV0tbvSXo8ZcmHHhJ8LQDxKt De7TrYf6Unsq4L7XtFSAdhA2Dvy+jz+TU5m1sKtfxTCfbvzYxOHak3hXaRNeujejdZe/ +6Z+yyZti5xlYzWni5YKlL4qhhq1tpIAqSbJLdXjeLHQ7bwWv8ibzWQK5G79/UNfWE7K tbHE7vRmGcN9ee3vQXHk3vJjXN0k69smejSgivJKcqbUUuKX9bFVX53hXTDQZZ6Hlw1U o7Ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si2302499plb.66.2017.06.27.08.06.31; Tue, 27 Jun 2017 08:06:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753245AbdF0PGT (ORCPT + 25 others); Tue, 27 Jun 2017 11:06:19 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:64543 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753262AbdF0PDh (ORCPT ); Tue, 27 Jun 2017 11:03:37 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0LyyIe-1dlsyI1VEO-014Er0; Tue, 27 Jun 2017 17:03:22 +0200 From: Arnd Bergmann To: Stanimir Varbanov , Mauro Carvalho Chehab Cc: Arnd Bergmann , Hans Verkuil , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] [media] venus: don't abuse dma_alloc for non-DMA allocations Date: Tue, 27 Jun 2017 17:02:47 +0200 Message-Id: <20170627150310.719212-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170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mRCtUpwjZ8oug4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In venus_boot(), we pass a pointer to a phys_addr_t into dmam_alloc_coherent, which the compiler warns about: platform/qcom/venus/firmware.c: In function 'venus_boot': platform/qcom/venus/firmware.c:63:49: error: passing argument 3 of 'dmam_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] The returned DMA address is later passed on to a function that takes a phys_addr_t, so it's clearly wrong to use the DMA mapping interface here: the memory may be uncached, or the address may be completely wrong if there is an IOMMU connected to the device. My interpretation is that using dmam_alloc_coherent() had two purposes: a) get a chunk of consecutive memory that may be larger than the limit for kmalloc() b) use the devres infrastructure to simplify the unwinding in the error case. I think ideally we'd use a devres-based version of alloc_pages_exact() here, but since that doesn't exist, let's use devm_get_free_pages() instead. This wastes a little memory as the size gets rounded up to a power of two, but is otherwise harmless. If we want to save memory here, calling devm_free_pages() to release the memory once it is no longer needed is probably better anyway. Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions") Signed-off-by: Arnd Bergmann --- The same problem exists in the drm driver, as of commit 7c65817e6d38 ("drm/msm: gpu: Enable zap shader for A5XX"), and I submitted the same patch for that already. --- drivers/media/platform/qcom/venus/firmware.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 1b1a4f355918..76edb9f60311 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -60,11 +60,13 @@ int venus_boot(struct device *parent, struct device *fw_dev, const char *fwname) mem_size = VENUS_FW_MEM_SIZE; - mem_va = dmam_alloc_coherent(fw_dev, mem_size, &mem_phys, GFP_KERNEL); + mem_va = (void *)devm_get_free_pages(parent, GFP_KERNEL, + get_order(mem_size)); if (!mem_va) { ret = -ENOMEM; goto err_unreg_device; } + mem_phys = virt_to_phys(mem_va); ret = request_firmware(&mdt, fwname, fw_dev); if (ret < 0)