Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1324841ybh; Thu, 16 Jul 2020 09:04:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgtWkAhGLRh9C4ge4RW2AA0Z4MEeRxtxOyewABVVlbOLf0+wO0/A7zVb68Bz8Wkv9pVqEz X-Received: by 2002:a17:906:945:: with SMTP id j5mr4321016ejd.436.1594915495007; Thu, 16 Jul 2020 09:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594915494; cv=none; d=google.com; s=arc-20160816; b=C0jaEnInyCTPK2Xm6wmaLegJ/ol7ISdmcUl2s0nr09haTlgJUWAu8KdyA78d+a5gk2 BZoFuffod6ztbv5C55h6i6fNi/JUwNCy6OoRKlSFXzGFMAht/KR2UepRYrx32zFV5hcF SB3RG2RKfAazoWN5Fkb6LTYWNp+pz7z9sLNxVLEzaEND/c9NG8RyMoIqhBAOOR7GfBr6 bXvd3J8bYEJNL6Sg/LQ3s2jooTIAlR/Ypx5pIlYVtZOIimYB7sR+dXkSVL/B/ZRll58q mhwHe+96Qts0xtaTKJJ6oJnnvPFvWbGAqFpicbn/GqHKk1/QBcWJiFokbDSsy9d9p4IW a8fw== 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=yV3LwwP/SEpzaIEmeMBzbOghkFrbv+sk/VN9onw9N4c=; b=APUzJBQhX8vZeO3ahHrJx7QK9xxrwyr7oJo0b6d9xAZMf95EziG6GlCNglwsxCKWuW ZoCngoJ2zYY1rwYVlLUzujdYW3PxHgEC9gZf6TG8FLgxY3OTEuQaW2fZ26gj3t3PMJVU cdMKuyLDkAKeTeyw2m1lFDqFK3+9YhtgEYXK1NLFh+EIqI4qYE+C27qmbLZy9Zfl8xaY pH57L7uA8KFcZ0SAmJoCplIlwzmI8Vh1Vuj3FPZUwSydFgs1LrtXClKQ/PYnJwVSUJQz d44lRUg5TGYdPFAmiHpfGNjQ6y7KWhXZQTTC1tNsKzaR9iG4DPDJYpo2nczeJtzp5OFw kANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=PmM7BFqw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cy5si3432322edb.554.2020.07.16.09.04.31; Thu, 16 Jul 2020 09:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=PmM7BFqw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729228AbgGPQBB (ORCPT + 99 others); Thu, 16 Jul 2020 12:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbgGPQBA (ORCPT ); Thu, 16 Jul 2020 12:01:00 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE9FC08C5C0 for ; Thu, 16 Jul 2020 09:01:00 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id ga4so7073863ejb.11 for ; Thu, 16 Jul 2020 09:01:00 -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=yV3LwwP/SEpzaIEmeMBzbOghkFrbv+sk/VN9onw9N4c=; b=PmM7BFqw2PSR4FOOXVxXhA2f6W9m437kj4FNos9CDP3AJplZthVDkyvWlsqXdsVzAW IM0jY8Aj2cjRUyQ5//pe2xP0Djmun92aIvQU+RkGKuprB7WpZ6t9y8XW97H8aPkZsSws LauGKXBWtxn+z294PiF58zpqTAMdaJnRkNRZDJaoBHdyv0iIexU9jpq+lDfX70zSDlM/ uuwpQMBzj+gyc/2Gi9ptBI+nur9z9JdfUf8q8QbPcre4pqAcb3Yf2Q8Tt35VJ37cGQ76 IoN3YCs7xA0vUYw1/o3x6BLHfCW/Hf3I81JzZNOwPjM+60sb/ZQZu+tFvmc25pLG3/oe slkQ== 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=yV3LwwP/SEpzaIEmeMBzbOghkFrbv+sk/VN9onw9N4c=; b=axkU+iv44V8HYXPHEWPmljwEUVVo26V1xjRlUkHyPTWkd8hcLMCRptYK1VE8XM4ikB OzAvnHl3kiT60XnhurPew1nXqR/fL+jdWJ8JHyBpMEqFa5F/5JDVAxeFGB09uypbYCPB GaCSWx/egO6yVl4dYNFTE8m2EpZYa6UGuc8LhSW9wnv6Nz0NVE6qH55OH0NW4B1kz7uA c2SrGE5HhHFR8u9fWhcajwgGjBcWnUNvUFoG72cBu7/IRjdh//y1T5Jr4EMzcA8MbdD2 0nySe2Kgp2kVALey4GHRLDbTC4LXef/uVRIEOjOIPgTS5bHSi03qJrL/Xcc6bv67L4jl eirA== X-Gm-Message-State: AOAM533VfpjOhyOzBPApH9tg1Zilc2pN+7nqEfc9TfZvvacvFy1sdJqp gZgp+C6wi7qpvRafb+gsnypLO+fvvXhr/Gqnp8VIGw== X-Received: by 2002:a17:906:6d56:: with SMTP id a22mr4585391ejt.440.1594915258725; Thu, 16 Jul 2020 09:00:58 -0700 (PDT) MIME-Version: 1.0 References: <159457116473.754248.7879464730875147365.stgit@dwillia2-desk3.amr.corp.intel.com> <159457128462.754248.10443613927921016089.stgit@dwillia2-desk3.amr.corp.intel.com> <7ecd1b82-06ab-be49-4b92-ac42caab146c@oracle.com> In-Reply-To: <7ecd1b82-06ab-be49-4b92-ac42caab146c@oracle.com> From: Dan Williams Date: Thu, 16 Jul 2020 09:00:47 -0700 Message-ID: Subject: Re: [PATCH v2 22/22] device-dax: Introduce 'mapping' devices To: Joao Martins Cc: linux-nvdimm , Vishal Verma , Peter Zijlstra , Dave Hansen , Ard Biesheuvel , Linux MM , Linux Kernel Mailing List , Linux ACPI , Christoph Hellwig 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 Thu, Jul 16, 2020 at 6:19 AM Joao Martins wrote: > > On 7/12/20 5:28 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. > > > > Cc: Vishal Verma > > Signed-off-by: Dan Williams > > --- > > drivers/dax/bus.c | 191 +++++++++++++++++++++++++++++++++++++++++++++ > > drivers/dax/dax-private.h | 14 +++ > > 2 files changed, 203 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > > index f342e36c69a1..8b6c4ddc5f42 100644 > > --- a/drivers/dax/bus.c > > +++ b/drivers/dax/bus.c > > @@ -579,6 +579,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) { > ^^^^^^^^^^^^^^^^^^^^^ it's 'mapping->range_id < 0' > > Otherwise 'mapping0' sysfs entries won't work. > Disabled ranges use id -1. Whoops, yes. Needs a unit test.