Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5139784rwb; Tue, 6 Sep 2022 20:01:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR5aQ3DmIj6lvxuFhCO5js3GbRhnhvZ/IpONE9Tfai7i2s3hfJTHSH9rAN/oS9mgZBLl/OK0 X-Received: by 2002:a17:907:b17:b0:72a:edb8:7529 with SMTP id h23-20020a1709070b1700b0072aedb87529mr840098ejl.749.1662519704179; Tue, 06 Sep 2022 20:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662519704; cv=none; d=google.com; s=arc-20160816; b=ej1REypNR8zkxp9jQDN3GUZzdvCuImqgsZdnzG0O73/vpxo3or7HFH/jZ9P+6OUEMZ EQOXi/9dTl8grruelTfI28r2ehLiMD51saiNOCuFKHoCA99uVy5/gQfuSEGFFOlodrwV yuRaAuj4s3x6ceiTUMvPCwDQbx/c6ST1Dj3itugRYy29S+PbeRw6IXblnv/UeEat4fa2 A9KHn3quTsZ+9kShN6jUcbzeEFEmnYbRE8VxkvzpggZap5i5U89LaLYeF9e4ZK90WqBV 18FdvMDp4B9RSRYMjBrBPoOUSBdCJF/sjjs8uLudYBbArK+xA2koXoJllM6eJjYJxLIE jekg== 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=efArfOyZVUGCI+T53by4TAPMZDP8b/ifJUNoVTVXTsk=; b=t9qJ0O0DqsERpvE0mfkJXykrY2xDOqq4+4ApUhX5ZshKJjmPbqqXTHcuCwr5PBpVV0 lHOojXfxBYKEn4lmmJ72hmFbPuucoJQ2lBCtOz2hZkJsGLyDWxgS+a4aqmRWS9VLm3EA 94a8BiRuRfh8Y8aM8kBpjNNV4EF1miQ1HlrjWkgRlrsUrmtPrfCF2E7cXeLb5HQj2/BR Z6aFnoEBi3BWzuEA087YpQ+cNgB04a8ENXRGc26etMZrt6yYCfSNgUOrzZS1fPIbuqjH H36MngFzMH+rQbCmAteXwiaIeXf0QDHMkpvvVhRGwGwHCgNuTst0UcDoUynvfgd5xUJD PCrQ== 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 en17-20020a056402529100b0043dc00e0740si6978251edb.373.2022.09.06.20.01.18; Tue, 06 Sep 2022 20:01:44 -0700 (PDT) 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 S229907AbiIGCo5 (ORCPT + 99 others); Tue, 6 Sep 2022 22:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiIGCoz (ORCPT ); Tue, 6 Sep 2022 22:44:55 -0400 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 1E1672B25D; Tue, 6 Sep 2022 19:44:53 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="75542771" X-IronPort-AV: E=Sophos;i="5.93,295,1654527600"; d="scan'208";a="75542771" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP; 07 Sep 2022 11:44:51 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 6D6E9E8BFA; Wed, 7 Sep 2022 11:44:50 +0900 (JST) Received: from m3002.s.css.fujitsu.com (msm3.b.css.fujitsu.com [10.128.233.104]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 911F5B4B2E; Wed, 7 Sep 2022 11:44:49 +0900 (JST) Received: from localhost.localdomain (unknown [10.19.3.107]) by m3002.s.css.fujitsu.com (Postfix) with ESMTP id 4A661200B33B; Wed, 7 Sep 2022 11:44:49 +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: [RFC PATCH 4/7] RDMA/rxe: Add page invalidation support Date: Wed, 7 Sep 2022 11:43:02 +0900 Message-Id: <592ea028dff90a324af62623933b6c3c60a1dfde.1662461897.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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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 | 3 ++- drivers/infiniband/sw/rxe/rxe_odp.c | 34 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) 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 358f6b06aa64..924f4acb2816 100644 --- a/drivers/infiniband/sw/rxe/Makefile +++ b/drivers/infiniband/sw/rxe/Makefile @@ -22,4 +22,5 @@ rdma_rxe-y := \ rxe_mcast.o \ rxe_wq.o \ rxe_net.o \ - rxe_hw_counters.o + rxe_hw_counters.o \ + 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..0f702787a66e --- /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 + +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