Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp507768rdb; Thu, 1 Feb 2024 15:38:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnlLLFYowCBnu4aOCpM6G2dD4flqUG2M1EYKXUkhI6PNEj4JvCiFnzSj0ziKM9Zl9ApCzo X-Received: by 2002:a05:6358:1981:b0:178:7ecb:1573 with SMTP id v1-20020a056358198100b001787ecb1573mr5814119rwn.15.1706830721053; Thu, 01 Feb 2024 15:38:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706830721; cv=pass; d=google.com; s=arc-20160816; b=A8hON2O3P5uVLPHj2Mkb0mkcwpdw27+R/3B6PlwsTbrxprhlaZVjZMxj7hkfJ1jIC6 tij58qIm4bxTq5SoUKvNNGv2LtFfEqKym4epCkRSRVdiSd0y7/C12YfzZ3gM4LssxQ45 foYoH80Vt29qWdAeqdukrOQPu73kbpKmkEJhkSBMWHYqDrcA2uWdnk9ZwF+VvcnBopkq irc2vhSKNlEwGGPAsMV081R19LhwJvz0rWS2sEifjn6B8AyCNF/6bO9oyp2/U4oTyosu y6XSaOf4sZWcQrOeumYqLXm+d4sga7EyrnKqdzLxpDfTmZEkCa0AztDfIU2oyzGbu6pN 01eA== 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=kviV4OEyGv0IXC67TnkXo6XXxah3+E8Y2hWZv9VjMFo=; fh=AbxAFoDbdRVBoUaR3z4M1ppTHm+cgUKRhx7Ws/T3v9g=; b=KOfEG0w3FqTQRdvSPrE4vILaT38n0Ajx8Xeaa5BHO+6nb3rH2sBpw0O9U1PPyy1rVS sq0ShsB3+DkH6iTTj8LYScf5TFZAx49VeW8q3E3zf6/07ialtzlrMN5FEgRlN1xHUKS0 T4PpUTMboXYJI9mcXK3vSRxYEIGwFXpdUyPaKlcMNoUGuNcKUONqqdX6agXdX6HX/m8T qzmEiDUr0b183Me6dzNwsjduA7uzfnY1uTqccOhc8WGTx2jP1/akYWfFONScoMl/3JmG OcknOTb+792e8PcVmc9F+Hy/oPCRA/A5lhG2SuHV795OpGkaISBbfeBIL9R6A3Cvmw5O Xj3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="dojqep+/"; 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-49000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49000-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; AJvYcCXMa2Mg9nOcPUjjhGODwUvVDOAfjPhtm51+PEY2G2P3c0bVQvIs2opHUuBQV4Pq+aDgia5yaV9/YRBeu2+2fqU7UmVbT0XMLzvT1XzoMQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t3-20020a634603000000b005c701bcfe09si523020pga.27.2024.02.01.15.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 15:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="dojqep+/"; 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-49000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49000-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5D4E8B25CF1 for ; Thu, 1 Feb 2024 23:35:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80767487AB; Thu, 1 Feb 2024 23:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dojqep+/" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 61EBA482E3 for ; Thu, 1 Feb 2024 23:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706830469; cv=none; b=qPAD5VJnOkysQct3aDjhgcQ/0F7+m7s/A7PEDdjYgTRvVo9Q+szjsu/tRYPQvRtaLYiLU6/Pjj4bMpm4fyhwLP0CqOixfHkIpNrpUckY1KCdaaMEASqUgCl0PirxXucTK3Y/wnlky4rhDP2Eb/iZ8bb1ndnQ8lIm5v+mGi1x/TU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706830469; c=relaxed/simple; bh=J66uGdblJybSdIyISNAiXxVD4U/ZxuF3S6nfLo54RFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzDehh13/JlgovuI5r1vYP4K6j2BLzlxxoPNt/boAuJJDeguDEPY0kPIZ8y/fQP1Mbx95AreMKZGAEELET3EsZtmPg30pHjZu+T8sxsScRzlK5QSAtXO5lsimSkk75+SFU8VafYy/ShHe/uqlj89oNeuFX87dOSMEJybx/SF6WE= 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=dojqep+/; arc=none smtp.client-ip=170.10.133.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=1706830466; 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=kviV4OEyGv0IXC67TnkXo6XXxah3+E8Y2hWZv9VjMFo=; b=dojqep+/fbFDnxWRQVYaQDWK9R2eet3vXO0kyG3W+4ia2yoLdXskiXAlT4xqPe0cYYTROO fFVpEXFHb+d+72FgowKrrqKQdZK72JNMGEq/z1/rzCllQzxqqhSp040wu54jzce4e2Xw3w vsBHom8Imp6VkClF9NvRmJsJHoLvx9s= 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-152-9it-QiwGMCWzk2Dtrm9xXw-1; Thu, 01 Feb 2024 18:34:23 -0500 X-MC-Unique: 9it-QiwGMCWzk2Dtrm9xXw-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 8569E810BB0; Thu, 1 Feb 2024 23:34:22 +0000 (UTC) Received: from rhel-developer-toolbox-latest.rmtusor.csb (unknown [10.2.16.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 552AE111F9; Thu, 1 Feb 2024 23:34:21 +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 Subject: [PATCH v5 4/4] uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion Date: Thu, 1 Feb 2024 15:34:00 -0800 Message-ID: <20240201233400.3394996-5-cleech@redhat.com> In-Reply-To: <20240201233400.3394996-1-cleech@redhat.com> References: <20240201233400.3394996-1-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 --- 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..8634eba0ef2ab 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