Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp74740ybb; Tue, 24 Mar 2020 16:53:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsMvcDyFGkRfQ7GUvsE5t+t814pOENm8bWVHY88atGzCURtOniz8/pVAb6wJDkVjacD5V5C X-Received: by 2002:aca:5454:: with SMTP id i81mr603811oib.23.1585094000526; Tue, 24 Mar 2020 16:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585094000; cv=none; d=google.com; s=arc-20160816; b=ogZqK3gGPm4himGT0Jf0Kx1lqcqsdFTUPt+4NG1Q7Bd6r2XEw3MNdTNiHmjWhXWugz by6qY5tDAJI++4jxGNWuhsDv9f3I0/arDAGesSPQYZZ5rn1OOYMnmdvegnvMoamGX3yM 9to7lNo0tGeUoK8KW4bKgKSDBQSOY0/O8h5h1F1JH+Y1MQs9F5UlgQa+2Uh4Gc21K8yI X1jnQb1b7g9TEICXQms2oVZADefaPUYtAQA5SDiTuSQBCCIzhmBeUnheBZlllNo9mr5b 2D0rcLpMKZK7J+TcmzrSuOkcO1Q3+a7NpxH/OCyrny3eY1iaoyW3+HTQDO1tFA+Z8t1g +WzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KsuHRbkrRa7b9vqtRFx6ZxGV0C6hEgdYMQeOpNoVJ0E=; b=mWERAv07tq9Vhu1hEVNwYX7QSPh6fA/JX+4wvV8TjOhnMPCxdoMV/PIllFQ30bCW/N UkBIx8np8BSoLRf2C7hwaeRHSdB/9T3cb+Ntlnimd3j+qJMDaJC3BxAxcvLYV/H+n4B5 1ggfZqY6TQIHVAp3swdaoe3g8WzQzkMZBjDASafjHmSBfh5UZEZoPxf2vm27sN1uRiMk a7ZHFqJkPXx0p+wgx2e4MYuH4s7qkhBik9JZEte977FKPiVI/gFNYfiiNB2lQ9u8fCeg mKASENrFRUgj9jp4Xc4CUXxxa3IdDjfh7ttJMH6/YGrpb7u999G4tSnQO5+N8JEi3jeG ixUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=jgx9CVgZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si9914501otn.56.2020.03.24.16.53.07; Tue, 24 Mar 2020 16:53:20 -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=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=jgx9CVgZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbgCXXvl (ORCPT + 99 others); Tue, 24 Mar 2020 19:51:41 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:47055 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbgCXXvl (ORCPT ); Tue, 24 Mar 2020 19:51:41 -0400 Received: by mail-oi1-f193.google.com with SMTP id q204so388970oia.13 for ; Tue, 24 Mar 2020 16:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KsuHRbkrRa7b9vqtRFx6ZxGV0C6hEgdYMQeOpNoVJ0E=; b=jgx9CVgZcBzRzaEGKFLv/1JOTUMrhNkGkLTdNTBN5CFC7PlSIeE0hcCdBrTvaw578G 8YxLzN0nM6iNf3wKE7zw8apBgYHyE5jU7LNswbWwXwWHfUTQJO9vm1PFErePmhUQPlBP Vt6nqyYE7EcDffVVOCJ4DFUufko+Zog9ruk7Gg0dJk5SQBgWGC7BBV5pr1mRIq5755yO YVHd++wVXkAmTw/lET38pgHh8M72HZAwVGgO4Du+2ufb81Jltpo4VrKzt0/QsPNJMRgr 2Tq6BGao3x7tbcGZIExPuDBLWO3boKoqOsO8A/UijwTYnjICttMS266PGrxtNmAjMR3G rsaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KsuHRbkrRa7b9vqtRFx6ZxGV0C6hEgdYMQeOpNoVJ0E=; b=TvpmlHBOUxXz2XHLca/tMq7HTKKtzNvWq9uwA4Zuoh8bhu1fBGCC6LW6EESus8p1xs D0GJ8NxIcOb6aSv1BFA4AW06v+ialhm2Bcr2inlXArHgktFST2Mdj2pitdhap1X6LE4Z ba5uAazQ1Riah6GVY9qBuGg75LukEfTTnFqtzoiYDbvQY3ZeU4MjW8JfTI25tfOj8TZW ERsYbwyAN4vvvtemRU7gdbQJxH0uSDwfUjSCzp68+jbN9NwzopABG2wdHcLcEHmNqooY rfWFnwAFDcGDETYUAz+S0bfJjSHz0JMSElkLq2BKZaz2kWhV8wlNqHbYxzzJ/WjpXoeO 0b8w== X-Gm-Message-State: ANhLgQ3Orxz8UX/JcFvERegHFo4Ttvetyl5vPicHwrEtD1pTE2RdNpME 46pR/H60GthWFi+5aViqh1CiWo96HzfaJSs+0bsV9w== X-Received: by 2002:aca:ef82:: with SMTP id n124mr562802oih.73.1585093900545; Tue, 24 Mar 2020 16:51:40 -0700 (PDT) MIME-Version: 1.0 References: <158500767138.2088294.17131646259803932461.stgit@dwillia2-desk3.amr.corp.intel.com> <158500774067.2088294.1260962550701501447.stgit@dwillia2-desk3.amr.corp.intel.com> <27ba42ac-ec08-fd9c-dee2-53414eb0bc58@oracle.com> In-Reply-To: <27ba42ac-ec08-fd9c-dee2-53414eb0bc58@oracle.com> From: Dan Williams Date: Tue, 24 Mar 2020 16:51:29 -0700 Message-ID: Subject: Re: [PATCH 12/12] device-dax: Introduce 'mapping' devices To: Joao Martins Cc: Linux MM , Dave Hansen , Christoph Hellwig , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 9:28 AM Joao Martins wrote: > > On 3/23/20 11:55 PM, Dan Williams wrote: > > In support of interrogating the physical address layout of a device with > > dis-contiguous ranges, introduce a sysfs directory with 'start', 'end', > > and 'page_offset' attributes. The alternative is trying to parse > > /proc/iomem, and that file will not reflect the extent layout until the > > device is enabled. > > > > Signed-off-by: Dan Williams > > --- > > drivers/dax/bus.c | 190 +++++++++++++++++++++++++++++++++++++++++++++ > > drivers/dax/dax-private.h | 14 +++ > > 2 files changed, 202 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > > index 07aeb8fa9ee8..645449a079bd 100644 > > --- a/drivers/dax/bus.c > > +++ b/drivers/dax/bus.c > > @@ -558,6 +558,167 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id, > > } > > EXPORT_SYMBOL_GPL(alloc_dax_region); > > > > +static void dax_mapping_release(struct device *dev) > > +{ > > + struct dax_mapping *mapping = to_dax_mapping(dev); > > + struct dev_dax *dev_dax = to_dev_dax(dev->parent); > > + > > + ida_free(&dev_dax->ida, mapping->id); > > + kfree(mapping); > > +} > > + > > +static void unregister_dax_mapping(void *data) > > +{ > > + struct device *dev = data; > > + struct dax_mapping *mapping = to_dax_mapping(dev); > > + struct dev_dax *dev_dax = to_dev_dax(dev->parent); > > + struct dax_region *dax_region = dev_dax->region; > > + > > + dev_dbg(dev, "%s\n", __func__); > > + > > + device_lock_assert(dax_region->dev); > > + > > + dev_dax->ranges[mapping->range_id].mapping = NULL; > > + mapping->range_id = -1; > > + > > + device_del(dev); > > + put_device(dev); > > +} > > + > > +static struct dev_dax_range *get_dax_range(struct device *dev) > > +{ > > + struct dax_mapping *mapping = to_dax_mapping(dev); > > + struct dev_dax *dev_dax = to_dev_dax(dev->parent); > > + struct dax_region *dax_region = dev_dax->region; > > + > > + device_lock(dax_region->dev); > > + if (mapping->range_id < 1) { > ^^^^^^^^^^^^^^^^^^^^^ perhaps "mapping->range_id < 0" ? > > AFAICT, invalid/disabled ranges have id to -1. > > Otherwise we can't use mapping0 entry fields. > Yes, a gaping hole in the unit test.