Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1204488pxb; Thu, 28 Jan 2021 10:20:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCY1mVoJnRO518GjwPd3BRSjihCerknLaFkgY7iwD2Ckgv8mpEe1zDpLqjAn/ROsx3wWM3 X-Received: by 2002:a17:906:52c1:: with SMTP id w1mr733921ejn.214.1611858047824; Thu, 28 Jan 2021 10:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611858047; cv=none; d=google.com; s=arc-20160816; b=WlBzlcXk3aS3KIF+EjXthRl8RZz8bdbVVQvL4QB4UHb3z9JNcetIQsIBqLdzFst7n4 leglZfA73VUDToTxs6yHD9ujlnHjUrX96gqtNSv58giiHhbIZzauZAtPpcEhYmSQy41w A/GrUWlSlFMVSQV+GnC5yKQ0hpkrPtPYVpZuPOodQhceNa5bBkOrX1vnxIhfGLaqWOjQ vRSg3WJfXkCcJhT4Omf7PnF0xFqxNr2YhKSXOTXyjP0mkHc5kWwhf4rC7Uyi12IkZBL5 5Pm6YaBniY6C8TwB2BgCYCP87FUDJm6DpAKnfb2/xlsYI1L9KTONJlLgKImhYsQyKjfn Guhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=U6gT8aRt6aSVguOpgazmPKMxrVGl+NwXt4KdFl7GEvE=; b=HCRATTIOI7vwag8FVVMCocAiqnwdCJJP5BLYhEHXEOrHLbhnTALcsDWEoOWvPiRw/5 PYU21ZkfYeKf8mN74e5uXJni6yWMay5tkYih55dpONpYAxGN8Xy0LdYM5shqrZBedAnB a6fqz3g1DykwW4Eg07gAsNoqZvLPHu0qa5epXLLOzj1ASuMUkAI0nsh3FOhpMCudEUtC EBGupXbXvYOvhkI/Mlm0JvYggd8H1mfku9HJwPHH4JC92TV+Fewfb3Lao70T1ZqtgaDD 0hNMHOUDtNOYyzp7GKuBPhd5h1ORtqcTE/9utwFHQG4bm8KD8umxsFKbpUjRbkDkKr+P JqUw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si3050171ejw.311.2021.01.28.10.20.23; Thu, 28 Jan 2021 10:20:47 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbhA1STS (ORCPT + 99 others); Thu, 28 Jan 2021 13:19:18 -0500 Received: from verein.lst.de ([213.95.11.211]:58507 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbhA1SQp (ORCPT ); Thu, 28 Jan 2021 13:16:45 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id B320468B02; Thu, 28 Jan 2021 19:15:58 +0100 (CET) Date: Thu, 28 Jan 2021 19:15:57 +0100 From: Christoph Hellwig To: Robin Murphy Cc: Jianxiong Gao , erdemaktas@google.com, marcorr@google.com, hch@lst.de, m.szyprowski@samsung.com, gregkh@linuxfoundation.org, saravanak@google.com, heikki.krogerus@linux.intel.com, rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, dan.j.williams@intel.com, bgolaszewski@baylibre.com, jroedel@suse.de, iommu@lists.linux-foundation.org, konrad.wilk@oracle.com, kbusch@kernel.org, axboe@fb.com, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] Adding page_offset_mask to device_dma_parameters Message-ID: <20210128181557.GA11790@lst.de> References: <20210128003829.1892018-1-jxgao@google.com> <20210128003829.1892018-2-jxgao@google.com> <2863b6d2-47f6-51fa-f60c-ba24904818e9@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2863b6d2-47f6-51fa-f60c-ba24904818e9@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 05:27:25PM +0000, Robin Murphy wrote: > On 2021-01-28 00:38, Jianxiong Gao wrote: >> Some devices rely on the address offset in a page to function >> correctly (NVMe driver as an example). These devices may use >> a different page size than the Linux kernel. The address offset >> has to be preserved upon mapping, and in order to do so, we >> need to record the page_offset_mask first. >> >> Signed-off-by: Jianxiong Gao >> --- >> include/linux/device.h | 1 + >> include/linux/dma-mapping.h | 17 +++++++++++++++++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/include/linux/device.h b/include/linux/device.h >> index 1779f90eeb4c..f44e0659fc66 100644 >> --- a/include/linux/device.h >> +++ b/include/linux/device.h >> @@ -292,6 +292,7 @@ struct device_dma_parameters { >> */ >> unsigned int max_segment_size; >> unsigned long segment_boundary_mask; >> + unsigned int page_offset_mask; > > Could we call this something more like "min_align_mask" (sorry, I can't > think of a name that's actually good and descriptive right now). > Essentially I worry that having "page" in there is going to be too easy to > misinterpret as having anything to do what "page" means almost everywhere > else (even before you throw IOMMU pages into the mix). > > Also note that of all the possible ways to pack two ints and a long, this > one is the worst ;) The block layer uses virt_boundary for the related concept, but that is pretty horrible too.