From patchwork Thu Feb 1 23:33:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Leech X-Patchwork-Id: 19808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp93836dyc; Thu, 1 Feb 2024 15:35:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs6WPhQTjofWwZ0RpV8G2rspwrIrxwGERS7J41b2PY6teWGgCjLyPbLDQsd3mQ1SBXooz9 X-Received: by 2002:a17:906:a8f:b0:a35:b30a:6098 with SMTP id y15-20020a1709060a8f00b00a35b30a6098mr4819812ejf.71.1706830501164; Thu, 01 Feb 2024 15:35:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706830501; cv=pass; d=google.com; s=arc-20160816; b=hLGoNV2+UrJFRQUt9gDne3twnYFwrGKyOBHCGnreVOMj4mOskbln78wOsfM/Ysrhgi wnoSEakGwto3q49zzU5rY6zWDRgwAu/Q1VVqZb8eeZJvj/hEWjCFdtH0fpsbCqEhgfj4 b2KwYSLcOR086/ahTSAQWmr+ashAeDOqmklr9kHglHBv4NTmodP8JQpzGuj9xkRkdTxT EvL7MEHKExOeOQ7RwPTVg5xlYH8wbwSLqTpXdRnklyxmWeWoILK1dC5vBnv16gq7rSuP G8R1fu5UlSe9RwYW5j3p79pfU9Lq2oDnjQIAvA9AFRBH0zBFs1v/wcXnkDe4YXo9FdiR WsmQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=+KNKvB+sVb0oHCzlVCeXjS4dy7AjP6uKhJvKZaZyiAA=; fh=OVeIjqAh3QMbwe0mhAb07ecoMyo1Pn4yZvVNY6yQAgQ=; b=h3MgrzfCk+1oMykGdULCsjazzy+9UtBYP7yf1eCVeqKhHjKnzmKpypX310GUYgKsoq SHp2gkjieopShbnndAn9wIqEFX38h/jExjSSU51eXcxwkIZD+nsZErbqh6/ETr+h+LQf FD5++iaXRoffv7Mqt/RW3nTyGh3cCeja8+uZfwGQsOBjRNjw2F0EpI2+tRxbK7Xxml8Q N/MoGRY6Uml8nfeQXxhcfpgfIBiMAyiefowhGIvF7xWg7ilmeNxCl15yWpiLvIEuM6od QJsPycbkawTy8rlGYj9/+uAxGtQoilIawoe1IDZutu5SaSYSLD748KLD8/bBgnwLS6l2 l5rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Adu1wQi1; 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-48997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48997-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVracBu0ZDqCrczaQT6+ZNZlJieIJmscZM7FgPAbZ9g/OUa2v5O6orJ6DlXImNt8VTKZpdIxxdIVTHRespFmZU9WEppJw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i21-20020a1709064ed500b00a36cb433f70si256856ejv.279.2024.02.01.15.35.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 15:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Adu1wQi1; 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-48997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48997-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9960B1F25CE7 for ; Thu, 1 Feb 2024 23:35:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E072347F58; Thu, 1 Feb 2024 23:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Adu1wQi1" 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 6E35447F4D for ; Thu, 1 Feb 2024 23:34:21 +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=1706830463; cv=none; b=Mh7E3qSYAw890VOE8biHB5nYwnLqiEujNBUonwL/7ugctei5IM+DZcESTa9DvZoALpi5XQ1Q8zDvkBU5wDcCn5cAlqK3BohOQeIg8APBzvtgzf3FyCVPiBaMUicmX9ppOp0iRG348zNpmb/yL82lni4PbtSZDnqjM8+zr2BB48E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706830463; c=relaxed/simple; bh=kw+ki3WM3q8qc2SsVqZ3aaq+zpP97OZDm6P5TkPPdhM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Dl5a5nsiKRDyCGwKSN3emJCpl1K+YyZ9NEPAfZsDFkKT2X8zjU/4l+8IaWDqsOuLx9+B7ai3tlZvUpdKxyeyRRRyYZStF+ilO7z2rmMFjbH5TVF8wtwE7nd3Q28GYPmsN1OSOPTm0bSp2c70BUI1kvRgNgZ4gXOV4FyiKQ7xoUY= 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=Adu1wQi1; 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=1706830460; 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; bh=+KNKvB+sVb0oHCzlVCeXjS4dy7AjP6uKhJvKZaZyiAA=; b=Adu1wQi1CioNWw6FdoKvDmcbWlXfdjUhWN9mghTOBPDFw8akKQfqgjCmdTbnrC4ZdEUx9v sUaZStJTlzc1hjnOS7Nfm7g5gdrpFN6likLEvEgsuVP8g1dsku961TttHhD8bRN46ZTd3o uEMLFBhcY9fIQ3psmsidCpmr3BkdOjs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-_2dxdNjMMFuAFSX8uqEhdw-1; Thu, 01 Feb 2024 18:34:17 -0500 X-MC-Unique: _2dxdNjMMFuAFSX8uqEhdw-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 DD9C428C976B; Thu, 1 Feb 2024 23:34:16 +0000 (UTC) Received: from rhel-developer-toolbox-latest.rmtusor.csb (unknown [10.2.16.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 741AC1BDB1; Thu, 1 Feb 2024 23:34:15 +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 0/4] UIO_MEM_DMA_COHERENT for cnic/bnx2/bnx2x Date: Thu, 1 Feb 2024 15:33:56 -0800 Message-ID: <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 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789741499705998183 X-GMAIL-MSGID: 1789741499705998183 During bnx2i iSCSI testing we ran into page refcounting issues in the uio mmaps exported from cnic to the iscsiuio process, and bisected back to the removal of the __GFP_COMP flag from dma_alloc_coherent calls. The cnic uio interface also has issues running with an iommu enabled, which these changes correct. In order to fix these drivers to be able to mmap dma coherent memory via a uio device, introduce a new uio mmap type backed by dma_mmap_coherent. While I understand some complaints about how these drivers have been structured, I also don't like letting support bitrot when there's a reasonable alternative to re-architecting an existing driver. I believe this to be the most sane way to restore these drivers to functioning properly. There are two other uio drivers which are mmaping dma_alloc_coherent memory as UIO_MEM_PHYS, uio_dmem_genirq and uio_pruss. These drivers are converted in the later patches of this series. v5: - convert uio_pruss and uio_dmem_genirq - added dev_warn and comment about not adding more users - put some PAGE_ALIGNs back in cnic to keep checks in uio_mmap_dma_coherent matched with uio_mmap_physical. - dropped the Fixes trailer v4: - re-introduce the dma_device member to uio_map, it needs to be passed to dma_mmap_coherent somehow - drop patch 3 to focus only on the uio interface, explicit page alignment isn't needed - re-add the v1 mail recipients, this isn't something to be handled through linux-scsi v3 (Nilesh Javali ): - fix warnings reported by kernel test robot and added base commit v2 (Nilesh Javali ): - expose only the dma_addr within uio and cnic. - Cleanup newly added unions comprising virtual_addr and struct device previous threads: v1: https://lore.kernel.org/all/20230929170023.1020032-1-cleech@redhat.com/ attempt at an alternative change: https://lore.kernel.org/all/20231219055514.12324-1-njavali@marvell.com/ v2: https://lore.kernel.org/all/20240103091137.27142-1-njavali@marvell.com/ v3: https://lore.kernel.org/all/20240109121458.26475-1-njavali@marvell.com/ v4: https://lore.kernel.org/all/20240131191732.3247996-1-cleech@redhat.com/ Chris Leech (4): uio: introduce UIO_MEM_DMA_COHERENT type cnic,bnx2,bnx2x: use UIO_MEM_DMA_COHERENT uio_pruss: UIO_MEM_DMA_COHERENT conversion uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion drivers/net/ethernet/broadcom/bnx2.c | 1 + .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 + drivers/net/ethernet/broadcom/cnic.c | 25 ++++++---- drivers/net/ethernet/broadcom/cnic.h | 1 + drivers/net/ethernet/broadcom/cnic_if.h | 1 + drivers/uio/uio.c | 47 +++++++++++++++++++ drivers/uio/uio_dmem_genirq.c | 22 ++++----- drivers/uio/uio_pruss.c | 6 ++- include/linux/uio_driver.h | 8 ++++ 9 files changed, 89 insertions(+), 24 deletions(-) base-commit: 861c0981648f5b64c86fd028ee622096eb7af05a