Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2668403rdb; Mon, 5 Feb 2024 13:51:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYTmZvPKJqh6JwyIXrHt9p0seUpKywjVWAKJQlV3CqUAPnOkGLjPc+C7xvU0eGloG6hNzr X-Received: by 2002:a05:6a20:3d05:b0:19e:8866:9e56 with SMTP id y5-20020a056a203d0500b0019e88669e56mr6306588pzi.11.1707169901818; Mon, 05 Feb 2024 13:51:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707169901; cv=pass; d=google.com; s=arc-20160816; b=Yibf856TL0gEqBO7VZdNtfD2lN3/AMqVDop0uxF8Kq5g0xoFykkTM8yjh34mAtZ/5i gwh+bL9NwbGh7Ax3nPVDLvgTB7RT4vGgOJUdiWtsivTITM6CD2h7mDJBpfSJ4Qs+6JN2 19V06iOm+aWrCTL3j5or9+2v7cZwdpxlK/3JjFXgIvQgtxaJnan1bCdXEtibU0SQSAs0 hXGOhGrWuDukjBxDh6geQVZONwT+oCkCZO2eOrAa8ALoK69L1x64JyO1ygxB3vtAarbI rShGcuyF92tBI0hQTusCAKT5ZzoMRav0QtAwPDp2eY2vF8a45YY4+SXfJjOSIXKzSPbj zmUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dJpKJpfoOFFg221gkKrq7FzbeWyIhT5uB2Ecy/dVoZU=; fh=Wdr8XBBekaUhSrgNb7WzENxeNzc8ghCXW+Hko5/bHg8=; b=pp4dcB1R/2g5TvjgnN4TzXrxMsgEYhL2xWETU9PhElivzMJTqSAHNJUmu0Y5/pss+f k3Nqt6t+oRA9Xn7oBXK3YQ0/Ca53dK641vPA4U4x+4raRSIMrIHS4TarCoqpa7BczJnM PWi/U1tLDwjxTHcgv9gTktJcY4EjjgMaWfOR+2rsqtS2RTV9MgOlNFmCaoTBrVxOBdyv 1BPyiXPm4NRWDHAP8KlXGUzrG0o2U/3qoGaaQo6qlrCc9ItxRJ/TB/kaeKjNoIbK1frN DyipOdI+xpNyW0BcPgiDtP+IPoglX2FVl0Zc6j4IzaDc4mdgf/GJngMgRRw5FSTkQupy krZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CIQPBF1D; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWwSqPucDV0d+I3yAAI4KzHBBRZvSygdnG5znL47Oj0Yvc6onBq+UvogkDl0kwtXsFB958Hn2ryV5SfjYZRTXQXBd4uJIjanH7BZZNwPw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x1-20020a631701000000b005d3646ae6f1si504839pgl.4.2024.02.05.13.51.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:51:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CIQPBF1D; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E3B1928C3C6 for ; Mon, 5 Feb 2024 21:38:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D74221292FB; Mon, 5 Feb 2024 20:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CIQPBF1D" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717701292E3 for ; Mon, 5 Feb 2024 20:03:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707163390; cv=none; b=nbu8KGjlltMaxvAwuPb4ws7+HTpov1sMjwcolfIy8JlNImzVjKaJqRFiEaWc73Btnqm8z1GtNg1IRCinx/yGgCIlNBBTGs3L2l7iZuAcfWBI4V9TBJ/6MHLHVIzo7m0n8SlsgJ/jICZe6mBx5WvId1ta6a9ovxbfvnxvWHAlOu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707163390; c=relaxed/simple; bh=/V90lZZSRGXXf05+8SHxHi+6QRtY/DfvuW/SQHQYyIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZP0T75tXUj1FfpspTAditNkWXX5xqfYOhO4NGnt5YfMkXcfQhgteixUFWpQ1OV4YkmAnJpfR2jDEw6qUXOM7GiZcmaM/9fEOGC4VT8hAL2ZgET3uUQpSWGpBlR0vgaUi+Uli3tlNGMh+GLnRc2vdSbYOsYhhZ0J39OMiVYhOrm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CIQPBF1D; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707163387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dJpKJpfoOFFg221gkKrq7FzbeWyIhT5uB2Ecy/dVoZU=; b=CIQPBF1DtkXpWY5I6D/I+NrizGwxwWcfhCDG+WM+viLDT6VO/102ww/DNPmtX70TtUUsyN hlaCqe89r2SXDKaVQhshP0I9Gszcd2gAogDe7c3zeGXxV9u+2xbpkfc4SQdJXJqpuXLOTO wdC9lGQrWnqVPGd44hyAKuVsP1glzxg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-nVCxjYcQNTC-R1a0ywzJvg-1; Mon, 05 Feb 2024 15:03:02 -0500 X-MC-Unique: nVCxjYcQNTC-R1a0ywzJvg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38C93846D6F; Mon, 5 Feb 2024 20:03:01 +0000 (UTC) Received: from rhel-developer-toolbox-latest.redhat.com (unknown [10.2.16.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id E67F55012; Mon, 5 Feb 2024 20:02:59 +0000 (UTC) From: Chris Leech To: Greg Kroah-Hartman , Nilesh Javali Cc: Christoph Hellwig , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, GR-QLogic-Storage-Upstream@marvell.com, Simon Horman Subject: [PATCH v6 4/4] uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion Date: Mon, 5 Feb 2024 12:02:57 -0800 Message-ID: <20240205200257.138376-1-cleech@redhat.com> In-Reply-To: <20240201233400.3394996-5-cleech@redhat.com> References: <20240201233400.3394996-5-cleech@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Conversion of this driver to use UIO_MEM_DMA_COHERENT for dma_alloc_coherent memory instead of UIO_MEM_PHYS. Signed-off-by: Chris Leech --- v6: fixed single char ',' -> ';' typo drivers/uio/uio_dmem_genirq.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c index 5313307c2754a..d5f9384df1255 100644 --- a/drivers/uio/uio_dmem_genirq.c +++ b/drivers/uio/uio_dmem_genirq.c @@ -36,7 +36,6 @@ 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; }; @@ -50,7 +49,6 @@ 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 dmem_region = priv->dmem_region_start; uiomem = &priv->uioinfo->mem[priv->dmem_region_start]; @@ -61,11 +59,8 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode) break; addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size, - (dma_addr_t *)&uiomem->addr, GFP_KERNEL); - if (!addr) { - uiomem->addr = DMEM_MAP_ERROR; - } - priv->dmem_region_vaddr[dmem_region++] = addr; + &uiomem->dma_addr, GFP_KERNEL); + uiomem->addr = addr ? (phys_addr_t) addr : DMEM_MAP_ERROR; ++uiomem; } priv->refcnt++; @@ -80,7 +75,6 @@ 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); @@ -93,13 +87,12 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode) while (!priv->refcnt && uiomem < &priv->uioinfo->mem[MAX_UIO_MAPS]) { if (!uiomem->size) break; - if (priv->dmem_region_vaddr[dmem_region]) { - dma_free_coherent(&priv->pdev->dev, uiomem->size, - priv->dmem_region_vaddr[dmem_region], - uiomem->addr); + if (uiomem->addr) { + dma_free_coherent(uiomem->dma_device, uiomem->size, + (void *) uiomem->addr, + uiomem->dma_addr); } uiomem->addr = DMEM_MAP_ERROR; - ++dmem_region; ++uiomem; } @@ -264,7 +257,8 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev) " dynamic and fixed memory regions.\n"); break; } - uiomem->memtype = UIO_MEM_PHYS; + uiomem->memtype = UIO_MEM_DMA_COHERENT; + uiomem->dma_device = &pdev->dev; uiomem->addr = DMEM_MAP_ERROR; uiomem->size = pdata->dynamic_region_sizes[i]; ++uiomem; -- 2.43.0