Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7052957ybi; Thu, 13 Jun 2019 08:47:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEJiiRTsNbLNJb94R/MeLZcw24w4g9y1JnyF2bbG/0mKqaAvmc0qULZhcaUWoAeHL7Ysek X-Received: by 2002:a63:d218:: with SMTP id a24mr24307824pgg.419.1560440822229; Thu, 13 Jun 2019 08:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440822; cv=none; d=google.com; s=arc-20160816; b=U8UrZUhLtzNTkrb14WxYc3TswNoqZG+8nZGK7/KrDCQGobZCeVBvRXu0VY7spdOZCD EeNLfwH/lBPEVcRJnG/a/Zhix3u4UK3h9TthihZSIia8yTZ1jbUSzGpAIRJ5Yma9hN4i EyVTzvm9ERrADA18umscd/asGJ0bLboS8xf8S++9ly5ujlOaacOtUL0VTmv5KfcuWw0D eoRzIf0A8lIzEgRb6L/DzKp90QiWsVtD6UfzM5/wDQ3lTnNukIAZPBGsgDCu7HehIMXd JK7Ft9l52gSQmqIwSOQffvO9qYq4mt+l5hg3shgVrSKGgzS/XTQ5tJI3n7uERoP2lbQo Y9Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wPaWdCIL9H03r8HySQVqow//0jNnHtt/N2MgQJISZ8s=; b=opswMjmgJoj4gkw/HoWMaKtirsau1TkduHfBE4TeIbAgjWI/5HIb4WzaShpuqjno4f 2EY5Z5zRehQQ7RQ+1/t8yseeiaozbKCoZ7TvEvOH1nfcAdDZSQuowWK7Q/cANLn2wZDr HsUzDFjpGiQJqP4F04U2mC12t5s7opvHoHZbW3R1LFqSz04ygF0IeyXsC1X1uwLo535O O0Ng1wjUHMIJvR5ceEcDI9dUL+xb6KU4w8zTmKKWHObzfNooWAnvq4p3wA2V+KzzO6Xo s6lfBkr72LLmciaStom4DpvzNIM6u1djHo9HFO2UNuGmE72oW/epzi2Jen9B/iG4UITe PhIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=avKv6xwb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w185si3698313pfb.170.2019.06.13.08.46.47; Thu, 13 Jun 2019 08:47:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=avKv6xwb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388234AbfFMPou (ORCPT + 99 others); Thu, 13 Jun 2019 11:44:50 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33488 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731816AbfFMJoK (ORCPT ); Thu, 13 Jun 2019 05:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wPaWdCIL9H03r8HySQVqow//0jNnHtt/N2MgQJISZ8s=; b=avKv6xwbjUwP5JnIfmut07FD4E gJPJZ8ZQmWlKJYjAzKHwT0cqU9A36XKIAMssk8gQpq3IhjxldclzNcvSF1zNcI9FEe5J4DrlwynxU BOkf4ZqVPr5yBB+WsSzI5BaGpY9hBxi7Qh2og5bCGOdVDDRSHg1MVKNLMpKkG5YCrQBvTdqcEqdjK BIBwnNK0AKvH4MNtye6T+KQS+ymNK5QfOcLa6VAmU5b2i3i5m5oX14CGYl5bXnH+Ld0nP0t5HEDau tkrt/zZv4j5UrYFMV46EwV5BMV6zPYhoYxnhEc4quUvclTo0SfZwBQ7d4I6wYboawBdk9qACJlW6E gRpSlcmw==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMH8-0001rw-At; Thu, 13 Jun 2019 09:44:06 +0000 From: Christoph Hellwig To: Dan Williams , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/22] device-dax: use the dev_pagemap internal refcount Date: Thu, 13 Jun 2019 11:43:16 +0200 Message-Id: <20190613094326.24093-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The functionality is identical to the one currently open coded in device-dax. Signed-off-by: Christoph Hellwig --- drivers/dax/dax-private.h | 4 --- drivers/dax/device.c | 52 +-------------------------------------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index a45612148ca0..ed04a18a35be 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -51,8 +51,6 @@ struct dax_region { * @target_node: effective numa node if dev_dax memory range is onlined * @dev - device core * @pgmap - pgmap for memmap setup / lifetime (driver owned) - * @ref: pgmap reference count (driver owned) - * @cmp: @ref final put completion (driver owned) */ struct dev_dax { struct dax_region *region; @@ -60,8 +58,6 @@ struct dev_dax { int target_node; struct device dev; struct dev_pagemap pgmap; - struct percpu_ref ref; - struct completion cmp; }; static inline struct dev_dax *to_dev_dax(struct device *dev) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index e23fa1bd8c97..a9d7c90ecf1e 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -14,37 +14,6 @@ #include "dax-private.h" #include "bus.h" -static struct dev_dax *ref_to_dev_dax(struct percpu_ref *ref) -{ - return container_of(ref, struct dev_dax, ref); -} - -static void dev_dax_percpu_release(struct percpu_ref *ref) -{ - struct dev_dax *dev_dax = ref_to_dev_dax(ref); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - complete(&dev_dax->cmp); -} - -static void dev_dax_percpu_exit(void *data) -{ - struct percpu_ref *ref = data; - struct dev_dax *dev_dax = ref_to_dev_dax(ref); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - wait_for_completion(&dev_dax->cmp); - percpu_ref_exit(ref); -} - -static void dev_dax_percpu_kill(struct dev_pagemap *pgmap) -{ - struct dev_dax *dev_dax = container_of(pgmap, struct dev_dax, pgmap); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - percpu_ref_kill(pgmap->ref); -} - static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, const char *func) { @@ -442,10 +411,6 @@ static void dev_dax_kill(void *dev_dax) kill_dev_dax(dev_dax); } -static const struct dev_pagemap_ops dev_dax_pagemap_ops = { - .kill = dev_dax_percpu_kill, -}; - int dev_dax_probe(struct device *dev) { struct dev_dax *dev_dax = to_dev_dax(dev); @@ -463,24 +428,9 @@ int dev_dax_probe(struct device *dev) return -EBUSY; } - init_completion(&dev_dax->cmp); - rc = percpu_ref_init(&dev_dax->ref, dev_dax_percpu_release, 0, - GFP_KERNEL); - if (rc) - return rc; - - rc = devm_add_action_or_reset(dev, dev_dax_percpu_exit, &dev_dax->ref); - if (rc) - return rc; - - dev_dax->pgmap.ref = &dev_dax->ref; - dev_dax->pgmap.ops = &dev_dax_pagemap_ops; addr = devm_memremap_pages(dev, &dev_dax->pgmap); - if (IS_ERR(addr)) { - devm_remove_action(dev, dev_dax_percpu_exit, &dev_dax->ref); - percpu_ref_exit(&dev_dax->ref); + if (IS_ERR(addr)) return PTR_ERR(addr); - } inode = dax_inode(dax_dev); cdev = inode->i_cdev; -- 2.20.1