Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4032668pxb; Mon, 1 Feb 2021 10:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKgpIm7qYlJsq/KWPl7Or7D3Bev3KEa/P/5CrIe9SJrSNeg8Hr49Ws9CcSgR0Iqy1H7pGa X-Received: by 2002:a17:906:7d09:: with SMTP id u9mr18198288ejo.380.1612204519810; Mon, 01 Feb 2021 10:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612204519; cv=none; d=google.com; s=arc-20160816; b=pPp//5ROlJCY1kwGabsyOJKSx2E7jGCOCaZo8eyEB278nQvglSF0PL/Aj0+aP9s+lL XtBtZSndFun6O8kJYwd9OJMWflJ1E9XUd31gm1z3vFabeH1em91BcXA2NT5c5jY48nAZ DUvdN02UVKp/JdXtYXvGMAhZ9+7A1CMB0790haEMQD1fVaSIMhkZwANzKi5fZxIp9/gq eY888lvrLw5KUcB86dLA8JdtKaqG6tBfV01mYnscpFiT87+438cGDensbR4g+yKHi/wb 5a97BU7/UETE/qLxZNZKPk41TD3javEyYn0ww72JJqSxIoo5gB2MWMcablkg8Aov9cqQ 8z2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=dv/wJr+V9NRV+lolRhI4CVLaEjJrVVBI8C3cibP+WBU=; b=Onag+eyk+pLGDPGB+lR4UNtR5gJdtAVF9rAD8TApBh7uwDml2QXxFuSXdqhBg07Oyf 6XXXOSG0iVAmBW0YTFQ/nLoDCMveHmdkP0sZr9ekp+OeSpLUACusxJiXrjEYMzmrgDHu l4m7TY1hkCXPvF8cFDKHY/aujyGGWcWOHdmE0QsdH+UWznW31dhqGjx9/MfpGMkIeAb9 IKR1SJ+88R+dQpKEfEeBShMNmvlfLB0z0BD3ZbzT33tAnFefqKxr8dwvAQ5JxxWzve9Z 61+hLFGH4UGgPfsL7NVDSpEjc5QjhDdjxk37gZaE5pTeEbYDGXcWbjoUBDJDrDfFDDA9 HH+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Lj3UyKxA; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si1449842eda.322.2021.02.01.10.34.54; Mon, 01 Feb 2021 10:35:19 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Lj3UyKxA; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233037AbhBASd7 (ORCPT + 99 others); Mon, 1 Feb 2021 13:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232832AbhBASbE (ORCPT ); Mon, 1 Feb 2021 13:31:04 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE58EC06174A for ; Mon, 1 Feb 2021 10:30:23 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 18so12049335pgp.22 for ; Mon, 01 Feb 2021 10:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=dv/wJr+V9NRV+lolRhI4CVLaEjJrVVBI8C3cibP+WBU=; b=Lj3UyKxA8lOIDGcPlpqgpnIQ+ae5rtq8GZJ3tw2mo4cgWWi5PDLt0PQL1ceiR7DkDT fsn7U8UN+bqxxlHbLikEDWaglidRgQkkFYiDgTHcsS82JHwwx7gJtiYdyllzS5oNcaWC Eg/jeZpIVEEtoFwS/sAagES8+4KsAUqFWJauvb3OSw+rWHAxuwBZDOO2pzJYGxTwRa3i 6b9k7zhAfI8DOS7uaEO/5PWyeY3tCZ/Y8/padIigVO7e+pLSphaeaBtA4lxv18bUw0Hb T0XuC3AQhuA5yRyaXcr1PL8TRMjE6yZNayj7+MSPQdQWYa+Q1XTmQ8XLb4lcAkkwvub7 l3Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=dv/wJr+V9NRV+lolRhI4CVLaEjJrVVBI8C3cibP+WBU=; b=MId8brGbxbkK6SAZgDDIztX3DniJ1RATQNkvRgeFh/H9cuLaU+u+M49v1uQDVUGU1s pjOIgIWyfVO64G64Y1m/kXKPtu9pwBEBqK/paFRVQMuyht6WQ49UbO2dG9Vfx1U29ReV 4P6xSSP6QNCPcYes/Ecz8cQBt29lkdc0r9tyWUpAwOaBz+Itlckv/b1gipFvHV3m37o6 wywXyzD4C5as38yRFjCLchPXp5X68J0k9MrBrCCmUPdtzXp/qdZNKzsR9pnAdzRlu/1y asoY5X229IrtlBAkQtVr3Z5xVOBjyD9MTpZmTVgt4Co9qZAkIFGUM7cJ+0WbCw259aw8 fWkw== X-Gm-Message-State: AOAM533qIbWEL/9eOeApvAxkwltW6YFkr979rbjbGgz6RNm2Km6ItULJ jOZsCM8eOK+Q3T8YLRlvoL4Ke3zpCQ== Sender: "jxgao via sendgmr" X-Received: from jxgao.kir.corp.google.com ([2620:0:1008:11:695f:7f9e:413c:e3c7]) (user=jxgao job=sendgmr) by 2002:a17:90a:d58a:: with SMTP id v10mr196883pju.9.1612204223378; Mon, 01 Feb 2021 10:30:23 -0800 (PST) Date: Mon, 1 Feb 2021 10:30:15 -0800 In-Reply-To: <20210201183017.3339130-1-jxgao@google.com> Message-Id: <20210201183017.3339130-2-jxgao@google.com> Mime-Version: 1.0 References: <20210201183017.3339130-1-jxgao@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH V2 1/3] Adding page_offset_mask to device_dma_parameters From: Jianxiong Gao To: jxgao@google.com, erdemaktas@google.com, marcorr@google.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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..7960bf516dd7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -291,6 +291,7 @@ struct device_dma_parameters { * sg limitations. */ unsigned int max_segment_size; + unsigned int min_align_mask; unsigned long segment_boundary_mask; }; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 2e49996a8f39..27ec3cab8cbd 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -500,6 +500,23 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) return -EIO; } +static inline unsigned int dma_get_min_align_mask(struct device *dev) +{ + if (dev->dma_parms) + return dev->dma_parms->min_align_mask; + return 0; +} + +static inline int dma_set_min_align_mask(struct device *dev, + unsigned int min_align_mask) +{ + if (dev->dma_parms) { + dev->dma_parms->min_align_mask = min_align_mask; + return 0; + } + return -EIO; +} + static inline int dma_get_cache_alignment(void) { #ifdef ARCH_DMA_MINALIGN -- 2.27.0