Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp194101rwj; Thu, 22 Dec 2022 23:24:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9IglL+wLm1oe6BEILaCoG+dQ36xmjXXhJqxImmwNyOspw/LoI6JyKTndLSK/kBdbSk8fY X-Received: by 2002:a17:90a:7187:b0:219:d274:ba39 with SMTP id i7-20020a17090a718700b00219d274ba39mr9517973pjk.27.1671780281031; Thu, 22 Dec 2022 23:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671780281; cv=none; d=google.com; s=arc-20160816; b=LyHOo31K4pQifhDqcoHRzC4MvlcdpUniDxq+sSrraW7sAF7NQqPB/8xMpFzImzgZlO 76BNJnFKH6y4LPMFvQF/bmnlIT+fa5vpDBsE0J/WfL0MmYgp/33SZhIIpQ+eXjoKHW/U h0MCKrFDhp4H5B3aZPhkRK/FeCG1JDqZQ9TmeuHiTkBtW2kPEsB2IaakEjvYu6heCRJV hoMybIErH8nByVup8LJnbxLwlD73UX8JQ9H/DGKCw1ky2rMgYPcXApfBDcDRP2Vf4Fz8 PcS16kdUgcHsTbtgiNXoAq34YYAwooCdHQ0F3U9F6qeseg1y/oWs3XUTXoW62NX04ysr CJlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YZNQe2lZin3NFTTRqMnJaQtJEVrLunwVgALdsf56QGk=; b=g18OdVRqGwiRq2wVv8eJBhL31Ih45eAKsGjqTYZ5NFESQOEfeLSzLWkWX7Z7VMr1JX zPvDFpYnlmkqQ0tsXcLQlPvafPuPVuEwDgwqYf3tekJBXBfmmIRQG1DhQ3TENnEN3TaZ bR0rXn3UFTs03nwnYRTC5ElS7JIjJItdkpvRvPFo40iOkmBJabBFO3Jtbr4QyTD6/Scy Wz5ILbFi83CkpTZirYy9RtUcrqFVKoPfjR62sH2vxVURh4jWwJglIEeqnPDDVg75kFiz cJN9YhnSPDhVQ85M3lE/CtA84T6xB4zRw/THBXmu/v8eSAyPuVOBZrCro9DA1xCuLVq+ Bp1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a17090a648300b0021984d87dd1si2751121pjj.91.2022.12.22.23.24.31; Thu, 22 Dec 2022 23:24:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235825AbiLWGwc (ORCPT + 67 others); Fri, 23 Dec 2022 01:52:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbiLWGwa (ORCPT ); Fri, 23 Dec 2022 01:52:30 -0500 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0BAE24BFB; Thu, 22 Dec 2022 22:52:28 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="89180422" X-IronPort-AV: E=Sophos;i="5.96,267,1665414000"; d="scan'208";a="89180422" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP; 23 Dec 2022 15:52:25 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id DC76CD3EA0; Fri, 23 Dec 2022 15:52:24 +0900 (JST) Received: from m3003.s.css.fujitsu.com (m3003.s.css.fujitsu.com [10.128.233.114]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2FA5914467; Fri, 23 Dec 2022 15:52:24 +0900 (JST) Received: from localhost.localdomain (unknown [10.19.3.107]) by m3003.s.css.fujitsu.com (Postfix) with ESMTP id EDD2C200B2A8; Fri, 23 Dec 2022 15:52:23 +0900 (JST) From: Daisuke Matsuda To: linux-rdma@vger.kernel.org, leonro@nvidia.com, jgg@nvidia.com, zyjzyj2000@gmail.com Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, rpearsonhpe@gmail.com, yangx.jy@fujitsu.com, lizhijian@fujitsu.com, y-goto@fujitsu.com, Daisuke Matsuda Subject: [PATCH for-next v3 4/7] RDMA/rxe: Add page invalidation support Date: Fri, 23 Dec 2022 15:51:55 +0900 Message-Id: <97b0362e256dd3eb022d81c30941edd8fb0caba9.1671772917.git.matsuda-daisuke@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On page invalidation, an MMU notifier callback is invoked to unmap DMA addresses and update the driver page table(umem_odp->dma_list). The callback is registered when an ODP-enabled MR is created. Signed-off-by: Daisuke Matsuda --- drivers/infiniband/sw/rxe/Makefile | 2 ++ drivers/infiniband/sw/rxe/rxe_odp.c | 34 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 drivers/infiniband/sw/rxe/rxe_odp.c diff --git a/drivers/infiniband/sw/rxe/Makefile b/drivers/infiniband/sw/rxe/Makefile index 5395a581f4bb..93134f1d1d0c 100644 --- a/drivers/infiniband/sw/rxe/Makefile +++ b/drivers/infiniband/sw/rxe/Makefile @@ -23,3 +23,5 @@ rdma_rxe-y := \ rxe_task.o \ rxe_net.o \ rxe_hw_counters.o + +rdma_rxe-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += rxe_odp.o diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c new file mode 100644 index 000000000000..0787a9b19646 --- /dev/null +++ b/drivers/infiniband/sw/rxe/rxe_odp.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* + * Copyright (c) 2022 Fujitsu Ltd. All rights reserved. + */ + +#include + +static bool rxe_ib_invalidate_range(struct mmu_interval_notifier *mni, + const struct mmu_notifier_range *range, + unsigned long cur_seq) +{ + struct ib_umem_odp *umem_odp = + container_of(mni, struct ib_umem_odp, notifier); + unsigned long start; + unsigned long end; + + if (!mmu_notifier_range_blockable(range)) + return false; + + mutex_lock(&umem_odp->umem_mutex); + mmu_interval_set_seq(mni, cur_seq); + + start = max_t(u64, ib_umem_start(umem_odp), range->start); + end = min_t(u64, ib_umem_end(umem_odp), range->end); + + ib_umem_odp_unmap_dma_pages(umem_odp, start, end); + + mutex_unlock(&umem_odp->umem_mutex); + return true; +} + +const struct mmu_interval_notifier_ops rxe_mn_ops = { + .invalidate = rxe_ib_invalidate_range, +}; -- 2.31.1