Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4510680ybb; Mon, 23 Mar 2020 23:31:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuakvcVt8lieYp9ybIppjxlnU2LWPFWwpVNKo1jEh0UJ0eJyww/idg9sNONXSHpG5zzfst8 X-Received: by 2002:a9d:a51:: with SMTP id 75mr20255111otg.112.1585031476641; Mon, 23 Mar 2020 23:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585031476; cv=none; d=google.com; s=arc-20160816; b=h11lp/Qy0IG0/ZGycTue4YOBeLyPJQWZWjOaTeOw3I+6IxeSv10HNCXEOiZWPe8nzy DZDTzEhxR97TiMf0oaeJKwHG5Ry/A7FLC42h735z6bWU0k05s2afFt5T6efASU1cGceb 8cY5xkm7nocy6OnuEQev2BZxahcMyb18ja4N0tUniYUlk6uGycFwI0OYmstRoWeTcncE KvdYZ2/gD0yBgHf5M8BTRnAwEvfp0v3CcMIEvGP0TISRCh8J2r3k1W+8IMPeHiDn4PJI Jutvywvy/iQR+bKi6JfrFW67eLQYwMKPpOPCq8wZfx2wP/aNoNOOVIdxKwmFBPYFNDTH W1UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=isGMuaFrKihZ5hvs2wNFT4xLh9qDP0EXsneTBhMwqjI=; b=ZYnMqtFpjnB1YYv65nqmw/fWNl65y+7M66/11XGNpqlMT9fx9JpT2U4c2oPrwbEwoZ rhIAoKaw76QSvzkdndA76kA3Vtbx19hgd30nvWIV3YaxIRAznJ4TUwhMcJNSIXjqTkJD xsdLjHPpph5U2M5zB0V417s2OLXJzZVtNlMuPxMFBwkRhmJiXVjNNHXm5FR5QsFH0MNY GKCdX9YyjjcrKLWSzafWPO45nlLeLnY9Fdr8hb/4Rlb8OBK20TRNMZDXkf5TDIUz3Jox ADO6ZAUfMhaB8BxM+R6zCL2dZFYx7SkV9x1vI1wiyLQ1zTzqhBUKfaLV2wOPcjBAP4P/ ccfA== ARC-Authentication-Results: i=1; mx.google.com; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23si8859478oti.283.2020.03.23.23.31.04; Mon, 23 Mar 2020 23:31:16 -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; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726257AbgCXGac (ORCPT + 99 others); Tue, 24 Mar 2020 02:30:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3216 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbgCXGac (ORCPT ); Tue, 24 Mar 2020 02:30:32 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02O64B86078773; Tue, 24 Mar 2020 02:30:16 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yxw7cxyp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Mar 2020 02:30:16 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02O6R1cx020237; Tue, 24 Mar 2020 06:30:15 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma03dal.us.ibm.com with ESMTP id 2ywaw9bxwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Mar 2020 06:30:15 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02O6UFad53346570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 06:30:15 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1180E112064; Tue, 24 Mar 2020 06:30:15 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DAD05112063; Tue, 24 Mar 2020 06:30:11 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.85.116.254]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 24 Mar 2020 06:30:11 +0000 (GMT) X-Mailer: emacs 27.0.90 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Alexey Kardashevskiy , Christoph Hellwig Cc: iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, Lu Baolu , Greg Kroah-Hartman , Joerg Roedel , Robin Murphy , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device In-Reply-To: References: <20200320141640.366360-1-hch@lst.de> <20200320141640.366360-2-hch@lst.de> <2f31d0dd-aa7e-8b76-c8a1-5759fda5afc9@ozlabs.ru> <20200323083705.GA31245@lst.de> <20200323085059.GA32528@lst.de> <87sghz2ibh.fsf@linux.ibm.com> <20200323172256.GB31269@lst.de> Date: Tue, 24 Mar 2020 12:00:09 +0530 Message-ID: <87pnd22rke.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-23_10:2020-03-23,2020-03-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=18 bulkscore=0 priorityscore=1501 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240027 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexey Kardashevskiy writes: > On 24/03/2020 04:22, Christoph Hellwig wrote: >> On Mon, Mar 23, 2020 at 09:07:38PM +0530, Aneesh Kumar K.V wrote: >>> >>> This is what I was trying, but considering I am new to DMA subsystem, I >>> am not sure I got all the details correct. The idea is to look at the >>> cpu addr and see if that can be used in direct map fashion(is >>> bus_dma_limit the right restriction here?) if not fallback to dynamic >>> IOMMU mapping. >> >> I don't think we can throw all these complications into the dma >> mapping code. At some point I also wonder what the point is, >> especially for scatterlist mappings, where the iommu can coalesce. > > This is for persistent memory which you can DMA to/from but yet it does > not appear in the system as a normal memory and therefore requires > special handling anyway (O_DIRECT or DAX, I do not know the exact > mechanics). All other devices in the system should just run as usual, > i.e. use 1:1 mapping if possible. This is O_DIRECT with a user buffer that is actually mmap from a dax mounted file system. What we really need is something that will falback to iommu_map_page based on dma_addr. ie. Something equivalent to current dma_direct_map_page(), but instead of fallback to swiotlb_map page we should fallback to iommu_map_page(). Something like? dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long attrs) { phys_addr_t phys = page_to_phys(page) + offset; dma_addr_t dma_addr = phys_to_dma(dev, phys); if (unlikely(!dma_capable(dev, dma_addr, size, true))) { return iommu_map(dev, phys, size, dir, attrs); return DMA_MAPPING_ERROR; } .... ... -aneesh