From patchwork Fri Nov 16 05:46:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Hobson-Garcia X-Patchwork-Id: 1753081 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DE5254005F for ; Fri, 16 Nov 2012 05:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751419Ab2KPFrB (ORCPT ); Fri, 16 Nov 2012 00:47:01 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:41777 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402Ab2KPFq7 (ORCPT ); Fri, 16 Nov 2012 00:46:59 -0500 Received: by mail-pa0-f46.google.com with SMTP id hz1so1622226pad.19 for ; Thu, 15 Nov 2012 21:46:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=PMV/2lBbvGVoC42rMev9hCdwfNsa76vxIwRBKUgtPc0=; b=dmLejFQjVmG/YEhJ78wCxeleRnF3NDFunXDK3uTLdMO9+Qei5QfSQW11gU3Wlu9NPf TezU+dmagjjdY9RlDEVLQoBo6KqvKf7mqi4vhoX/uVRU2ZbJ9O2vkUC1JIiX57q+B4ay 7JY5nh/cmybfU032UIrzNVi2d7xyihCPIuR1Ix33M6IJNGbuB9kZSwISuI53bhLr+t5Y 0W3g6QnaqL9T3A0rC/dkpw8n4KfLzXGcDG8XGvBcHi36PtJgIP8O+OCoGfeZklJVCyzq wpxiZqUMWrX62iTuD9DvHR5DQ7yVzSAq0217WivqAFZZ9YVrDGqZnDVbIMAzTZ45XTGO yy0Q== Received: by 10.68.219.164 with SMTP id pp4mr5945447pbc.72.1353044819206; Thu, 15 Nov 2012 21:46:59 -0800 (PST) Received: from localhost.localdomain ([219.106.231.132]) by mx.google.com with ESMTPS id j4sm484425pax.31.2012.11.15.21.46.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 21:46:58 -0800 (PST) From: Damian Hobson-Garcia To: hjk@hansjkoch.de, gregkh@linuxfoundation.org, magnus.damm@gmail.com, horms@verge.net.au Cc: linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, Damian Hobson-Garcia Subject: [PATCH 1/4] drivers: uio_dmem_genirq: Don't mix address spaces for dynamic region vaddr Date: Fri, 16 Nov 2012 14:46:09 +0900 Message-Id: <1353044772-18803-2-git-send-email-dhobsong@igel.co.jp> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1353044772-18803-1-git-send-email-dhobsong@igel.co.jp> References: <1353044772-18803-1-git-send-email-dhobsong@igel.co.jp> X-Gm-Message-State: ALoCoQlYkIl5JB8hG8DQDuWZvwfHJa+2D98naB6aAF9iTG9Tyhpl3sE27JOA1BUr8qJf6gqxE6F/ Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Assigning the virtual address returned from dma_alloc_coherent to the the internal_addr element of uioinfo produces the following sparse errors since internal_addr is a void __iomem * and dma_alloc_coherent returns void *. + drivers/uio/uio_dmem_genirq.c:65:39: sparse: incorrect type in assignment (different address spaces) drivers/uio/uio_dmem_genirq.c:65:39: expected void [noderef] *internal_addr drivers/uio/uio_dmem_genirq.c:65:39: got void *[assigned] addr + drivers/uio/uio_dmem_genirq.c:93:17: sparse: incorrect type in argument 3 (different address spaces) drivers/uio/uio_dmem_genirq.c:93:17: expected void *vaddr drivers/uio/uio_dmem_genirq.c:93:17: got void [noderef] *internal_addr Store the void * in the driver's private data instead. Reported-by: Fengguang Wu Signed-off-by: Damian Hobson-Garcia --- drivers/uio/uio_dmem_genirq.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c index 4d4dd00..d8bbe07 100644 --- a/drivers/uio/uio_dmem_genirq.c +++ b/drivers/uio/uio_dmem_genirq.c @@ -37,6 +37,7 @@ struct uio_dmem_genirq_platdata { struct platform_device *pdev; unsigned int dmem_region_start; unsigned int num_dmem_regions; + void *dmem_region_vaddr[MAX_UIO_MAPS]; struct mutex alloc_lock; unsigned int refcnt; }; @@ -46,6 +47,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode) struct uio_dmem_genirq_platdata *priv = info->priv; struct uio_mem *uiomem; int ret = 0; + int dmem_region = priv->dmem_region_start; uiomem = &priv->uioinfo->mem[priv->dmem_region_start]; @@ -61,8 +63,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode) ret = -ENOMEM; break; } - - uiomem->internal_addr = addr; + priv->dmem_region_vaddr[dmem_region++] = addr; ++uiomem; } priv->refcnt++; @@ -77,6 +78,7 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode) { struct uio_dmem_genirq_platdata *priv = info->priv; struct uio_mem *uiomem; + int dmem_region = priv->dmem_region_start; /* Tell the Runtime PM code that the device has become idle */ pm_runtime_put_sync(&priv->pdev->dev); @@ -91,7 +93,8 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode) break; dma_free_coherent(&priv->pdev->dev, uiomem->size, - uiomem->internal_addr, uiomem->addr); + priv->dmem_region_vaddr[dmem_region++], + uiomem->addr); uiomem->addr = DMA_ERROR_CODE; ++uiomem; }