From nobody Tue Dec 16 19:53:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB6C9E728CC for ; Fri, 29 Sep 2023 17:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233765AbjI2RBo (ORCPT ); Fri, 29 Sep 2023 13:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233675AbjI2RBd (ORCPT ); Fri, 29 Sep 2023 13:01:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D90CB1B0 for ; Fri, 29 Sep 2023 10:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696006845; 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=+oquGKuGwxfFoQE+GbMX8EY8O13dfuQB8zXuBNfC+6k=; b=Kt/iuFqC1I8L9ODVa/7foS9JAYvY+cHYphCQo/xEqdi/wXUDYnBT/FV2YI9ZU2pbopy35g JjpqJi7hqaU0Cgi420SLuTeGkCdZJK8ZnF2v9E1wzzfCx0u8OS20qBGpEKrUIr1m8Hihc4 Uff3c6NVL69F90rDqB0cfeRPpWwcDLo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-drVkHA9PODavbdJcMzCG8Q-1; Fri, 29 Sep 2023 13:00:43 -0400 X-MC-Unique: drVkHA9PODavbdJcMzCG8Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1DE8F8007A4; Fri, 29 Sep 2023 17:00:43 +0000 (UTC) Received: from rhel-developer-toolbox.redhat.com (unknown [10.2.16.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BAF2C15BB8; Fri, 29 Sep 2023 17:00:41 +0000 (UTC) From: Chris Leech To: Greg Kroah-Hartman , Christoph Hellwig , Rasesh Mody , Ariel Elior , Sudarsana Kalluru , Manish Chopra Cc: Nilesh Javali , Manish Rangankar , Jerry Snitselaar , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] uio: introduce UIO_DMA_COHERENT type Date: Fri, 29 Sep 2023 10:00:21 -0700 Message-ID: <20230929170023.1020032-2-cleech@redhat.com> In-Reply-To: <20230929170023.1020032-1-cleech@redhat.com> References: <20230929170023.1020032-1-cleech@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a UIO memtype specificially for sharing dma_alloc_coherent memory with userspace, backed by dma_mmap_coherent. Signed-off-by: Chris Leech --- drivers/uio/uio.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/uio_driver.h | 12 ++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 62082d64ece0..f8f1f7ba6378 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #define UIO_MAX_DEVICES (1U << MINORBITS) =20 @@ -759,6 +760,36 @@ static int uio_mmap_physical(struct vm_area_struct *vm= a) vma->vm_page_prot); } =20 +static int uio_mmap_dma_coherent(struct vm_area_struct *vma) +{ + struct uio_device *idev =3D vma->vm_private_data; + int mi =3D uio_find_mem_index(vma); + struct uio_mem *mem; + int rc; + + if (mi < 0) + return -EINVAL; + mem =3D idev->info->mem + mi; + + if (mem->dma_addr & ~PAGE_MASK) + return -ENODEV; + if (vma->vm_end - vma->vm_start > mem->size) + return -EINVAL; + + /* + * UIO uses offset to index into the maps for a device. + * We need to clear vm_pgoff for dma_mmap_coherent. + */ + vma->vm_pgoff =3D 0; + rc =3D dma_mmap_coherent(mem->dma_device, + vma, + mem->virtual_addr, + mem->dma_addr, + vma->vm_end - vma->vm_start); + vma->vm_pgoff =3D mi; + return rc; +} + static int uio_mmap(struct file *filep, struct vm_area_struct *vma) { struct uio_listener *listener =3D filep->private_data; @@ -806,6 +837,9 @@ static int uio_mmap(struct file *filep, struct vm_area_= struct *vma) case UIO_MEM_VIRTUAL: ret =3D uio_mmap_logical(vma); break; + case UIO_MEM_DMA_COHERENT: + ret =3D uio_mmap_dma_coherent(vma); + break; default: ret =3D -EINVAL; } diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 47c5962b876b..ede58e984658 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -36,11 +36,18 @@ struct uio_map; */ struct uio_mem { const char *name; - phys_addr_t addr; + union { + phys_addr_t addr; + dma_addr_t dma_addr; + }; unsigned long offs; resource_size_t size; int memtype; - void __iomem *internal_addr; + union { + void __iomem *internal_addr; + void *virtual_addr; + }; + struct device *dma_device; struct uio_map *map; }; =20 @@ -158,6 +165,7 @@ extern int __must_check #define UIO_MEM_LOGICAL 2 #define UIO_MEM_VIRTUAL 3 #define UIO_MEM_IOVA 4 +#define UIO_MEM_DMA_COHERENT 5 =20 /* defines for uio_port->porttype */ #define UIO_PORT_NONE 0 --=20 2.41.0 From nobody Tue Dec 16 19:53:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DE6FE728CC for ; Fri, 29 Sep 2023 17:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233776AbjI2RBx (ORCPT ); Fri, 29 Sep 2023 13:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233748AbjI2RBh (ORCPT ); Fri, 29 Sep 2023 13:01:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189A01A7 for ; Fri, 29 Sep 2023 10:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696006851; 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=KJIb8l8HiWQLqwHnb+OGG6jBumxqOciHnOCpUxHqes8=; b=gOZFD3mvA9P8UG+QXusupF2sbj3IwTufgHBbCWGDtxa1fKUSQ0KzDfrfdWc7aYr/wSPZFU 645M8t8Kk7hfTjsoAKC2DC8EQHSrPRWU79kZA30p9MwQ1cukzvMCl9lDzvKGfixj8qMp0i 4QW080Fjrjl5m4lK6I97Dx4reEz4tqU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-373-bhXzHpUdNYKihzMazFXV2A-1; Fri, 29 Sep 2023 13:00:45 -0400 X-MC-Unique: bhXzHpUdNYKihzMazFXV2A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE8E73815F63; Fri, 29 Sep 2023 17:00:44 +0000 (UTC) Received: from rhel-developer-toolbox.redhat.com (unknown [10.2.16.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4506BC15BB8; Fri, 29 Sep 2023 17:00:43 +0000 (UTC) From: Chris Leech To: Greg Kroah-Hartman , Christoph Hellwig , Rasesh Mody , Ariel Elior , Sudarsana Kalluru , Manish Chopra Cc: Nilesh Javali , Manish Rangankar , Jerry Snitselaar , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] cnic,bnx2,bnx2x: page align uio mmap allocations Date: Fri, 29 Sep 2023 10:00:22 -0700 Message-ID: <20230929170023.1020032-3-cleech@redhat.com> In-Reply-To: <20230929170023.1020032-1-cleech@redhat.com> References: <20230929170023.1020032-1-cleech@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Allocations in these drivers that will be mmaped through a uio device should be made in multiples of PAGE_SIZE to avoid exposing additional kernel memory unintentionally. Signed-off-by: Chris Leech Reviewed-by: Jacob Keller --- drivers/net/ethernet/broadcom/bnx2.c | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++++---- drivers/net/ethernet/broadcom/cnic.c | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/br= oadcom/bnx2.c index 0d917a9699c5..84a04eec654a 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -837,6 +837,7 @@ bnx2_alloc_stats_blk(struct net_device *dev) BNX2_SBLK_MSIX_ALIGN_SIZE); bp->status_stats_size =3D status_blk_size + sizeof(struct statistics_block); + bp->status_stats_size =3D PAGE_ALIGN(bp->status_stats_size); status_blk =3D dma_alloc_coherent(&bp->pdev->dev, bp->status_stats_size, &bp->status_blk_mapping, GFP_KERNEL); if (!status_blk) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net= /ethernet/broadcom/bnx2x/bnx2x_main.c index 0d8e61c63c7c..2fcde42a05c1 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -8270,10 +8270,10 @@ void bnx2x_free_mem_cnic(struct bnx2x *bp) =20 if (!CHIP_IS_E1x(bp)) BNX2X_PCI_FREE(bp->cnic_sb.e2_sb, bp->cnic_sb_mapping, - sizeof(struct host_hc_status_block_e2)); + PAGE_ALIGN(sizeof(struct host_hc_status_block_e2))); else BNX2X_PCI_FREE(bp->cnic_sb.e1x_sb, bp->cnic_sb_mapping, - sizeof(struct host_hc_status_block_e1x)); + PAGE_ALIGN(sizeof(struct host_hc_status_block_e1x))); =20 BNX2X_PCI_FREE(bp->t2, bp->t2_mapping, SRC_T2_SZ); } @@ -8316,12 +8316,12 @@ int bnx2x_alloc_mem_cnic(struct bnx2x *bp) if (!CHIP_IS_E1x(bp)) { /* size =3D the status block + ramrod buffers */ bp->cnic_sb.e2_sb =3D BNX2X_PCI_ALLOC(&bp->cnic_sb_mapping, - sizeof(struct host_hc_status_block_e2)); + PAGE_ALIGN(sizeof(struct host_hc_status_block_e2))); if (!bp->cnic_sb.e2_sb) goto alloc_mem_err; } else { bp->cnic_sb.e1x_sb =3D BNX2X_PCI_ALLOC(&bp->cnic_sb_mapping, - sizeof(struct host_hc_status_block_e1x)); + PAGE_ALIGN(sizeof(struct host_hc_status_block_e1x))); if (!bp->cnic_sb.e1x_sb) goto alloc_mem_err; } diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/br= oadcom/cnic.c index 7926aaef8f0c..67ec397bd171 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -1026,13 +1026,14 @@ static int __cnic_alloc_uio_rings(struct cnic_uio_d= ev *udev, int pages) return 0; =20 udev->l2_ring_size =3D pages * CNIC_PAGE_SIZE; + udev->l2_ring_size =3D PAGE_ALIGN(udev->l2_ring_size); udev->l2_ring =3D dma_alloc_coherent(&udev->pdev->dev, udev->l2_ring_size, &udev->l2_ring_map, GFP_KERNEL); if (!udev->l2_ring) return -ENOMEM; =20 udev->l2_buf_size =3D (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; - udev->l2_buf_size =3D CNIC_PAGE_ALIGN(udev->l2_buf_size); + udev->l2_buf_size =3D PAGE_ALIGN(udev->l2_buf_size); udev->l2_buf =3D dma_alloc_coherent(&udev->pdev->dev, udev->l2_buf_size, &udev->l2_buf_map, GFP_KERNEL); if (!udev->l2_buf) { @@ -1108,9 +1109,9 @@ static int cnic_init_uio(struct cnic_dev *dev) uinfo->mem[1].addr =3D (unsigned long) cp->status_blk.gen & CNIC_PAGE_MASK; if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) - uinfo->mem[1].size =3D BNX2_SBLK_MSIX_ALIGN_SIZE * 9; + uinfo->mem[1].size =3D PAGE_ALIGN(BNX2_SBLK_MSIX_ALIGN_SIZE * 9); else - uinfo->mem[1].size =3D BNX2_SBLK_MSIX_ALIGN_SIZE; + uinfo->mem[1].size =3D PAGE_ALIGN(BNX2_SBLK_MSIX_ALIGN_SIZE); =20 uinfo->name =3D "bnx2_cnic"; } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { @@ -1118,7 +1119,7 @@ static int cnic_init_uio(struct cnic_dev *dev) =20 uinfo->mem[1].addr =3D (unsigned long) cp->bnx2x_def_status_blk & CNIC_PAGE_MASK; - uinfo->mem[1].size =3D sizeof(*cp->bnx2x_def_status_blk); + uinfo->mem[1].size =3D PAGE_ALIGN(sizeof(*cp->bnx2x_def_status_blk)); =20 uinfo->name =3D "bnx2x_cnic"; } --=20 2.41.0 From nobody Tue Dec 16 19:53:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A9C0E728CB for ; Fri, 29 Sep 2023 17:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233742AbjI2RBu (ORCPT ); Fri, 29 Sep 2023 13:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233749AbjI2RBh (ORCPT ); Fri, 29 Sep 2023 13:01:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04BC61B7 for ; Fri, 29 Sep 2023 10:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696006852; 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=Oxto29hKqmyufLlB0bzOjhUQy61aqcqEMscXuA0JoFY=; b=evNVYA2BTZ6Ky4Adu8+hX8LoQZM7AzagdWU8+82glsD3mQyheTWm5ZG7pyk0tI+FR3XxpF mp0sd8iCu0pCl/TRRuQlCWveyb1xVa1iIT+RN+NZkgjPdLPvlnps/3Uj2JFA/9ho/SUgCI FGtvtHYE4T3ENpMsKh2aJEN53djzddQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-BZcZciWTNUW3fEUxevJ0rA-1; Fri, 29 Sep 2023 13:00:48 -0400 X-MC-Unique: BZcZciWTNUW3fEUxevJ0rA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B06E481652A; Fri, 29 Sep 2023 17:00:46 +0000 (UTC) Received: from rhel-developer-toolbox.redhat.com (unknown [10.2.16.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00C48C15BB8; Fri, 29 Sep 2023 17:00:44 +0000 (UTC) From: Chris Leech To: Greg Kroah-Hartman , Christoph Hellwig , Rasesh Mody , Ariel Elior , Sudarsana Kalluru , Manish Chopra Cc: Nilesh Javali , Manish Rangankar , Jerry Snitselaar , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] cnic,bnx2,bnx2x: use UIO_MEM_DMA_COHERENT Date: Fri, 29 Sep 2023 10:00:23 -0700 Message-ID: <20230929170023.1020032-4-cleech@redhat.com> In-Reply-To: <20230929170023.1020032-1-cleech@redhat.com> References: <20230929170023.1020032-1-cleech@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Make use of the new UIO_MEM_DMA_COHERENT type to properly handle mmap for dma_alloc_coherent buffers. The cnic l2_ring and l2_buf mmaps have caused page refcount issues since the misuse of the __GFP_COMP flag was removed from their dma_alloc_coherent calls. Fix that by having the uio device use dma_mmap_coherent. The bnx2 and bnx2x status block allocations are also dma_alloc_coherent, and should use dma_mmap_coherent. They didn't allocate multiple pages, but also didn't seem to work correctly with an iommu enabled. Fixes: bb73955c0b1d ("cnic: don't pass bogus GFP_ flags to dma_alloc_cohere= nt") Signed-off-by: Chris Leech Reviewed-by: Jacob Keller --- 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 + 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/br= oadcom/bnx2.c index 84a04eec654a..490f88ad3bd2 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -367,6 +367,7 @@ static void bnx2_setup_cnic_irq_info(struct bnx2 *bp) cp->irq_arr[0].status_blk =3D (void *) ((unsigned long) bnapi->status_blk.msi + (BNX2_SBLK_MSIX_ALIGN_SIZE * sb_id)); + cp->irq_arr[0].status_blk_map =3D bp->status_blk_mapping; cp->irq_arr[0].status_blk_num =3D sb_id; cp->num_irq =3D 1; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net= /ethernet/broadcom/bnx2x/bnx2x_main.c index 2fcde42a05c1..dbaa90b7f889 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -14912,9 +14912,11 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp) else cp->irq_arr[0].status_blk =3D (void *)bp->cnic_sb.e1x_sb; =20 + cp->irq_arr[0].status_blk_map =3D bp->cnic_sb_mapping; cp->irq_arr[0].status_blk_num =3D bnx2x_cnic_fw_sb_id(bp); cp->irq_arr[0].status_blk_num2 =3D bnx2x_cnic_igu_sb_id(bp); cp->irq_arr[1].status_blk =3D bp->def_status_blk; + cp->irq_arr[1].status_blk_map =3D bp->def_status_blk_mapping; cp->irq_arr[1].status_blk_num =3D DEF_SB_ID; cp->irq_arr[1].status_blk_num2 =3D DEF_SB_IGU_ID; =20 diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/br= oadcom/cnic.c index 67ec397bd171..05e28e00e916 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -1106,8 +1106,8 @@ static int cnic_init_uio(struct cnic_dev *dev) if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { uinfo->mem[0].size =3D MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1); - uinfo->mem[1].addr =3D (unsigned long) cp->status_blk.gen & - CNIC_PAGE_MASK; + uinfo->mem[1].dma_addr =3D cp->status_blk_map; + uinfo->mem[1].virtual_addr =3D cp->status_blk.gen; if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) uinfo->mem[1].size =3D PAGE_ALIGN(BNX2_SBLK_MSIX_ALIGN_SIZE * 9); else @@ -1117,22 +1117,27 @@ static int cnic_init_uio(struct cnic_dev *dev) } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { uinfo->mem[0].size =3D pci_resource_len(dev->pcidev, 0); =20 - uinfo->mem[1].addr =3D (unsigned long) cp->bnx2x_def_status_blk & - CNIC_PAGE_MASK; + uinfo->mem[1].dma_addr =3D cp->status_blk_map; + uinfo->mem[1].virtual_addr =3D cp->bnx2x_def_status_blk; uinfo->mem[1].size =3D PAGE_ALIGN(sizeof(*cp->bnx2x_def_status_blk)); =20 uinfo->name =3D "bnx2x_cnic"; } =20 - uinfo->mem[1].memtype =3D UIO_MEM_LOGICAL; + uinfo->mem[1].dma_device =3D &dev->pcidev->dev; + uinfo->mem[1].memtype =3D UIO_MEM_DMA_COHERENT; =20 - uinfo->mem[2].addr =3D (unsigned long) udev->l2_ring; + uinfo->mem[2].dma_addr =3D udev->l2_ring_map; + uinfo->mem[2].virtual_addr =3D udev->l2_ring; uinfo->mem[2].size =3D udev->l2_ring_size; - uinfo->mem[2].memtype =3D UIO_MEM_LOGICAL; + uinfo->mem[2].dma_device =3D &dev->pcidev->dev; + uinfo->mem[2].memtype =3D UIO_MEM_DMA_COHERENT; =20 - uinfo->mem[3].addr =3D (unsigned long) udev->l2_buf; + uinfo->mem[3].dma_addr =3D udev->l2_buf_map; + uinfo->mem[3].virtual_addr =3D udev->l2_buf; uinfo->mem[3].size =3D udev->l2_buf_size; - uinfo->mem[3].memtype =3D UIO_MEM_LOGICAL; + uinfo->mem[3].dma_device =3D &dev->pcidev->dev; + uinfo->mem[3].memtype =3D UIO_MEM_DMA_COHERENT; =20 uinfo->version =3D CNIC_MODULE_VERSION; uinfo->irq =3D UIO_IRQ_CUSTOM; @@ -1314,6 +1319,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) return 0; =20 cp->bnx2x_def_status_blk =3D cp->ethdev->irq_arr[1].status_blk; + cp->status_blk_map =3D cp->ethdev->irq_arr[1].status_blk_map; =20 cp->l2_rx_ring_size =3D 15; =20 @@ -5324,6 +5330,7 @@ static int cnic_start_hw(struct cnic_dev *dev) pci_dev_get(dev->pcidev); cp->func =3D PCI_FUNC(dev->pcidev->devfn); cp->status_blk.gen =3D ethdev->irq_arr[0].status_blk; + cp->status_blk_map =3D ethdev->irq_arr[0].status_blk_map; cp->status_blk_num =3D ethdev->irq_arr[0].status_blk_num; =20 err =3D cp->alloc_resc(dev); diff --git a/drivers/net/ethernet/broadcom/cnic.h b/drivers/net/ethernet/br= oadcom/cnic.h index 4baea81bae7a..fedc84ada937 100644 --- a/drivers/net/ethernet/broadcom/cnic.h +++ b/drivers/net/ethernet/broadcom/cnic.h @@ -260,6 +260,7 @@ struct cnic_local { #define SM_RX_ID 0 #define SM_TX_ID 1 } status_blk; + dma_addr_t status_blk_map; =20 struct host_sp_status_block *bnx2x_def_status_blk; =20 diff --git a/drivers/net/ethernet/broadcom/cnic_if.h b/drivers/net/ethernet= /broadcom/cnic_if.h index 789e5c7e9311..49a11ec80b36 100644 --- a/drivers/net/ethernet/broadcom/cnic_if.h +++ b/drivers/net/ethernet/broadcom/cnic_if.h @@ -190,6 +190,7 @@ struct cnic_ops { struct cnic_irq { unsigned int vector; void *status_blk; + dma_addr_t status_blk_map; u32 status_blk_num; u32 status_blk_num2; u32 irq_flags; --=20 2.41.0