From patchwork Mon Mar 4 13:52:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Taranov X-Patchwork-Id: 209557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1444856dyc; Mon, 4 Mar 2024 06:11:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXenrOqeZ/0qbNYw6wR7Cz26gkN33ldpzBRQS/+oez6V6AclvSb+YesTB6l7CCQ8FEPzZ2IAcoS/DYekYDu+QOpiO8o3Q== X-Google-Smtp-Source: AGHT+IFx01Gc6dZO+V1AZ3LdDi1t4wmLAXTG1bFJya+uyHitzqRYZsPB5AOd1fRLYXXyDhYBpaTS X-Received: by 2002:a05:6a21:3a85:b0:1a1:4806:d7a5 with SMTP id zv5-20020a056a213a8500b001a14806d7a5mr4162358pzb.38.1709561510958; Mon, 04 Mar 2024 06:11:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709561510; cv=pass; d=google.com; s=arc-20160816; b=v7HY9SN8jLClAh9KbWkVQj7v/S3sribhynMmF687rM/MQEqoC2ulMjP9TYwi2PYUks f8mCfE4qg7JBrky47rH3tdykoLtQzdFTeT4vWze03xSPXqaJ4fIO6wlgKmGh5KuCgSIz kND1Rg3h0FA4i0cVVBUmu0PeHFLDY00WXC7aIOl4b+nSVZw4khfcD5aW+iPKg1lo4tRa Rn8WZix4EoTICwZ1Pw5fVTlFdVOcRqJQ6lA2GJDUMyhSZP2qHupfMDdwqCyUb1YWvMP4 SF+NNccM+6N8hw8Or3UpRORxSqk/mt0N6xDpWLzb9NjagHaCMipGibAoaFP7FC0yusqJ FDEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=KEd2yZoIBVvL18aDItKvfvTSbUPB7RV44kXga7k9ang=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=Qy/+6usbZ8lMV9zSgKPHQmeFYLas1bM19VCa79xtRTJKZLhnKkZMaTf/uUacT2Cpe9 KFN9UqeXc9gr4XJ5QDoOf8i5IqHJfZaiVCuJvvb8WwhyL4/h6FpL2QBZdoq9vt3/tEDq //O3+qAwP7Q3k3WTqlc0FQPihtrjeFXkl55VKJ4tSHDkBpJPkv3irEJCd3E3qLj3d0fO 1fJjEkfBm2uRx9/MW7PL6SHBWW8Vu7rltuGd74yK9m90NTeTjpRQBnc+4GQ7VZUHrMA7 S8z9ZIGD347vzFn7yLxXSkCW7XAFgqIbPEjXbrrp0K1MoW/J3qI3T3YGm2T7CU/eQusy rMSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=m7HWS9FK; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-90682-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90682-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z19-20020a62d113000000b006e05b7bfcffsi8182957pfg.52.2024.03.04.06.11.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 06:11:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90682-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=m7HWS9FK; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-90682-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90682-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 40096B2379F for ; Mon, 4 Mar 2024 13:53:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C2D13FB1E; Mon, 4 Mar 2024 13:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="m7HWS9FK" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D1603E468; Mon, 4 Mar 2024 13:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560374; cv=none; b=B8UyPBKXrWvVtxaYut08Zk6mXnmW6d4jlLtFqv06HGFlPNpwPGSBZ9F5np7/5M9dBcPkMw2AYvSqZpwXFvuoCCRgRqlF8//FmNptFvW2VqDOi6jYpr6sYSSO6pepItHnvcEqbhUaZ6p2YREYpXzHykLwvhl2Xz7gQCS7anB85ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560374; c=relaxed/simple; bh=Tj7WsO02oBY3rpOVtVkrmLamQ8bHlbEb+mt75vTTGAA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=AhVTqWNZ8MgjTNed0jtqHhQ3PTM5IMx5B3U1fT2uIpq6/s5BVaUOwc2Ehz+SqrPpFqe8TRYuVHjjGwoHqkNXsOdp2i9Qy/uwL6wZc4VY1ckyHeoQNBV+J6Nz5u2DYk+CDkNraH1qXm0f7W+Bphy5itFYNx9K5NgnC2Cofdo8kns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=m7HWS9FK; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 3050420B74C1; Mon, 4 Mar 2024 05:52:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3050420B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709560367; bh=KEd2yZoIBVvL18aDItKvfvTSbUPB7RV44kXga7k9ang=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7HWS9FKynD9hCTJb8HUvOydOjlW7R61XvzXbL3qC2Fp0G3EtiEA4XULAIUhamUB3 rR9dFVAZVtsI89TlNepYowrsTV7CCr4F1LVdGNid7u8LwgnMV1rfobPaT2s+nUHNMv nDI5hLOb1f63vnGnbmerWmfQL3DQDrO64Mm8UCWs= From: Konstantin Taranov To: kotaranov@microsoft.com, sharmaajay@microsoft.com, longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH rdma-next v3 1/2] RDMA/mana_ib: Fix bug in creation of dma regions Date: Mon, 4 Mar 2024 05:52:40 -0800 Message-Id: <1709560361-26393-2-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1709560361-26393-1-git-send-email-kotaranov@linux.microsoft.com> References: <1709560361-26393-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792605171372313064 X-GMAIL-MSGID: 1792605171372313064 From: Konstantin Taranov Use ib_umem_dma_offset() helper to calculate correct dma offset. Fixes: 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter") Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 29dd2438d..dd570832d 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -348,7 +348,7 @@ int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, sizeof(struct gdma_create_dma_region_resp)); create_req->length = umem->length; - create_req->offset_in_page = umem->address & (page_sz - 1); + create_req->offset_in_page = ib_umem_dma_offset(umem, page_sz); create_req->gdma_page_type = order_base_2(page_sz) - PAGE_SHIFT; create_req->page_count = num_pages_total; From patchwork Mon Mar 4 13:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Taranov X-Patchwork-Id: 209551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1432241dyc; Mon, 4 Mar 2024 05:53:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPYvS/J9ZgkBwLi4g1fGYiijRrAm4/GMUAPsoYZbYRq802zRGjGac4ZDHWSr4h/UmCWMeh+tFFwG8LvgRfpN8gum/+zw== X-Google-Smtp-Source: AGHT+IGmNVRspRPbzXwDBmQqxvh4qERYjwaW91bIwSDBbWpGZnpbCKxikRh8y6TcBdP5OKgLsx66 X-Received: by 2002:a05:6402:3d5:b0:567:6c78:52a1 with SMTP id t21-20020a05640203d500b005676c7852a1mr773143edw.32.1709560427312; Mon, 04 Mar 2024 05:53:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709560427; cv=pass; d=google.com; s=arc-20160816; b=RvkrCU5VOIntvtYyEINPdPPL8UMOtHk/LszAYDO60AAhjDOvPFHvZbwOtecQlE3ux5 QRJgbsa+89382vz6hnwap3REozdgww+445MwfJ6f/zQx0ylORvNkmiW3d08HjYcR7UpO XVao7nCcoq213ptoBrtdRIFYHnIgRn8ZpokL7ixqpHKhBvtRqhIkEDR8XQHiWh7XNtcu +ESvgeFbjH2GQ0hGvEXEPFfM2Opi0dV1Jw88FJT582aQvLrvEFJWJjxrIwobwzNsrZNq 5XCtUuwqeQIj+QjAoBZF9Z3nRhjF7C/hiqOBT/z88gxPM3ql2lCU5+N2ivbmflg7T4i9 WC3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=+dCuIYfG/o2f47s0DE9P3zkA2qtsXwx3O4UUpJpY3S8=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=BbHqiE9lN6b+7vrC6DC6PGr8A4fyP1r5zjEy9rOnh6VYbDI3+AZ57ZF8TDq07oJ2Ju Q+dfwjPIKgx/xwAF1fOlqjyWgtZYoEhk112hzi5TIMQokDC6sEA8g45qAJwpv8TMDl3K OUxcp/Z5HW+dmAzqe4ySxarDQKavfzXW4MlLxFxBdOUtG2nhalc/SzeL3MdZpx02rtT1 8Pczh+MNtz75rmEMdOGu6ZejNC+BTx6bUOpUh624DiAaHNVaqosJVzxAltiRuR/EmE6t +dyyk2RVfCI+wyZUQTyMObGuX9aR7ReLxiaI1MLNDkZS1I+9jG14s7GAi93we7gWXD4L 7RDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EJEMSQPz; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-90683-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90683-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id eb6-20020a0564020d0600b00566392490dbsi3916953edb.175.2024.03.04.05.53.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 05:53:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90683-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EJEMSQPz; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-90683-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90683-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 BDBD41F25BBA for ; Mon, 4 Mar 2024 13:53:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4012D405FF; Mon, 4 Mar 2024 13:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="EJEMSQPz" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D0F43D97F; Mon, 4 Mar 2024 13:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560375; cv=none; b=bI0l0ITjKT7jpt4F7FV43FZ1GitrR3ZRhHmsZ7tOtNhlNrMC7qY4YzwYtnHO50u3Y3zch+yD2h3SfM5lHVg8mOVbYGvZ3euHAEBpx4RC6M3hAgRqG351WEIWt7HvvAYYUA4Qm7mDrXTCsjQi+XB9u5IpDVrwRM76IuHcSnG0PIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560375; c=relaxed/simple; bh=edteOrSYt2EcmTZCgyDU0iHxaX79E5A2rQMj7jh+MKM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=llMDb3XXbSnuaqCcavFNigbOO9B3rafHGOeMNv5sy4oV+yZM24qYdjuuIuD7FoLQXd8hBadWA7hVdf8Ix5WP8qiXTSBzmol+NHe3vInQquA6GT0zXT/cPbCFY02rcfd6iAo5n+hZ1CKAmn4n0RDljGLH6SY99bI/y3sRpHTGkH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=EJEMSQPz; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 481E420B74C2; Mon, 4 Mar 2024 05:52:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 481E420B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709560367; bh=+dCuIYfG/o2f47s0DE9P3zkA2qtsXwx3O4UUpJpY3S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJEMSQPz1Zcc37w95kqnfAZTP8HoKqUDh3F5z4vVlRchUFKrVxhNQai+Yffx5FWyM 3zBcoQZ1Rdz8gs39d7QKOZq/J8nucGhay5HU+Rpv1IWfHOEA4qRaUwVMF9qQJOxs6Z QKAZNvOddyujnZ1EvUS8f/a2j0WItcY6MnpkYRC4= From: Konstantin Taranov To: kotaranov@microsoft.com, sharmaajay@microsoft.com, longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH rdma-next v3 2/2] RDMA/mana_ib: Use virtual address in dma regions for MRs Date: Mon, 4 Mar 2024 05:52:41 -0800 Message-Id: <1709560361-26393-3-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1709560361-26393-1-git-send-email-kotaranov@linux.microsoft.com> References: <1709560361-26393-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792604034756278397 X-GMAIL-MSGID: 1792604034756278397 From: Konstantin Taranov Introduce mana_ib_create_dma_region() to create dma regions with iova for MRs. It allows creating MRs with any page offset. Previously, only page-aligned addresses worked. For dma regions that must have a zero dma offset (e.g., for queues), mana_ib_create_zero_offset_dma_region() is added. To get the zero offset, ib_umem_find_best_pgoff() is used with zero pgoff_bitmask. Fixes: 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter") Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/cq.c | 4 +-- drivers/infiniband/hw/mana/main.c | 40 +++++++++++++++++++++------- drivers/infiniband/hw/mana/mana_ib.h | 7 +++-- drivers/infiniband/hw/mana/mr.c | 4 +-- drivers/infiniband/hw/mana/qp.c | 6 ++--- drivers/infiniband/hw/mana/wq.c | 4 +-- 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c index 83d20c3f0..4a71e678d 100644 --- a/drivers/infiniband/hw/mana/cq.c +++ b/drivers/infiniband/hw/mana/cq.c @@ -48,7 +48,7 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, return err; } - err = mana_ib_gd_create_dma_region(mdev, cq->umem, &cq->gdma_region); + err = mana_ib_create_zero_offset_dma_region(mdev, cq->umem, &cq->gdma_region); if (err) { ibdev_dbg(ibdev, "Failed to create dma region for create cq, %d\n", @@ -57,7 +57,7 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, } ibdev_dbg(ibdev, - "mana_ib_gd_create_dma_region ret %d gdma_region 0x%llx\n", + "create_dma_region ret %d gdma_region 0x%llx\n", err, cq->gdma_region); /* diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index dd570832d..71e33feee 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -301,8 +301,8 @@ mana_ib_gd_add_dma_region(struct mana_ib_dev *dev, struct gdma_context *gc, return 0; } -int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, - mana_handle_t *gdma_region) +static int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, + mana_handle_t *gdma_region, unsigned long page_sz) { struct gdma_dma_region_add_pages_req *add_req = NULL; size_t num_pages_processed = 0, num_pages_to_handle; @@ -314,7 +314,6 @@ int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, size_t max_pgs_create_cmd; struct gdma_context *gc; size_t num_pages_total; - unsigned long page_sz; unsigned int tail = 0; u64 *page_addr_list; void *request_buf; @@ -323,12 +322,6 @@ int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, gc = mdev_to_gc(dev); hwc = gc->hwc.driver_data; - /* Hardware requires dma region to align to chosen page size */ - page_sz = ib_umem_find_best_pgsz(umem, PAGE_SZ_BM, 0); - if (!page_sz) { - ibdev_dbg(&dev->ib_dev, "failed to find page size.\n"); - return -ENOMEM; - } num_pages_total = ib_umem_num_dma_blocks(umem, page_sz); max_pgs_create_cmd = @@ -414,6 +407,35 @@ int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, return err; } +int mana_ib_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, + mana_handle_t *gdma_region, u64 virt) +{ + unsigned long page_sz; + + page_sz = ib_umem_find_best_pgsz(umem, PAGE_SZ_BM, virt); + if (!page_sz) { + ibdev_dbg(&dev->ib_dev, "Failed to find page size.\n"); + return -EINVAL; + } + + return mana_ib_gd_create_dma_region(dev, umem, gdma_region, page_sz); +} + +int mana_ib_create_zero_offset_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, + mana_handle_t *gdma_region) +{ + unsigned long page_sz; + + /* Hardware requires dma region to align to chosen page size */ + page_sz = ib_umem_find_best_pgoff(umem, PAGE_SZ_BM, 0); + if (!page_sz) { + ibdev_dbg(&dev->ib_dev, "Failed to find page size.\n"); + return -EINVAL; + } + + return mana_ib_gd_create_dma_region(dev, umem, gdma_region, page_sz); +} + int mana_ib_gd_destroy_dma_region(struct mana_ib_dev *dev, u64 gdma_region) { struct gdma_context *gc = mdev_to_gc(dev); diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index 6a03ae645..f83390eeb 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -160,8 +160,11 @@ static inline struct net_device *mana_ib_get_netdev(struct ib_device *ibdev, u32 int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq); -int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, - mana_handle_t *gdma_region); +int mana_ib_create_zero_offset_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, + mana_handle_t *gdma_region); + +int mana_ib_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, + mana_handle_t *gdma_region, u64 virt); int mana_ib_gd_destroy_dma_region(struct mana_ib_dev *dev, mana_handle_t gdma_region); diff --git a/drivers/infiniband/hw/mana/mr.c b/drivers/infiniband/hw/mana/mr.c index ee4d4f834..b70b13484 100644 --- a/drivers/infiniband/hw/mana/mr.c +++ b/drivers/infiniband/hw/mana/mr.c @@ -127,7 +127,7 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length, goto err_free; } - err = mana_ib_gd_create_dma_region(dev, mr->umem, &dma_region_handle); + err = mana_ib_create_dma_region(dev, mr->umem, &dma_region_handle, iova); if (err) { ibdev_dbg(ibdev, "Failed create dma region for user-mr, %d\n", err); @@ -135,7 +135,7 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length, } ibdev_dbg(ibdev, - "mana_ib_gd_create_dma_region ret %d gdma_region %llx\n", err, + "create_dma_region ret %d gdma_region %llx\n", err, dma_region_handle); mr_params.pd_handle = pd->pd_handle; diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c index 5d4c05dcd..6e7627745 100644 --- a/drivers/infiniband/hw/mana/qp.c +++ b/drivers/infiniband/hw/mana/qp.c @@ -357,8 +357,8 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, } qp->sq_umem = umem; - err = mana_ib_gd_create_dma_region(mdev, qp->sq_umem, - &qp->sq_gdma_region); + err = mana_ib_create_zero_offset_dma_region(mdev, qp->sq_umem, + &qp->sq_gdma_region); if (err) { ibdev_dbg(&mdev->ib_dev, "Failed to create dma region for create qp-raw, %d\n", @@ -367,7 +367,7 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, } ibdev_dbg(&mdev->ib_dev, - "mana_ib_gd_create_dma_region ret %d gdma_region 0x%llx\n", + "create_dma_region ret %d gdma_region 0x%llx\n", err, qp->sq_gdma_region); /* Create a WQ on the same port handle used by the Ethernet */ diff --git a/drivers/infiniband/hw/mana/wq.c b/drivers/infiniband/hw/mana/wq.c index 372d36151..7c9c69962 100644 --- a/drivers/infiniband/hw/mana/wq.c +++ b/drivers/infiniband/hw/mana/wq.c @@ -46,7 +46,7 @@ struct ib_wq *mana_ib_create_wq(struct ib_pd *pd, wq->wq_buf_size = ucmd.wq_buf_size; wq->rx_object = INVALID_MANA_HANDLE; - err = mana_ib_gd_create_dma_region(mdev, wq->umem, &wq->gdma_region); + err = mana_ib_create_zero_offset_dma_region(mdev, wq->umem, &wq->gdma_region); if (err) { ibdev_dbg(&mdev->ib_dev, "Failed to create dma region for create wq, %d\n", @@ -55,7 +55,7 @@ struct ib_wq *mana_ib_create_wq(struct ib_pd *pd, } ibdev_dbg(&mdev->ib_dev, - "mana_ib_gd_create_dma_region ret %d gdma_region 0x%llx\n", + "create_dma_region ret %d gdma_region 0x%llx\n", err, wq->gdma_region); /* WQ ID is returned at wq_create time, doesn't know the value yet */