Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1526887yba; Thu, 25 Apr 2019 01:01:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3PPaqg09n4/pXLiLvhV8AcpUZOUi+pna6ttAPenVJvyYqANDLAV/w9ljbnvFcCJKhgxHJ X-Received: by 2002:a63:c54a:: with SMTP id g10mr12057523pgd.71.1556179292106; Thu, 25 Apr 2019 01:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556179292; cv=none; d=google.com; s=arc-20160816; b=Pfg7qBe1uBGu/ekp6Gtmh7zdQE4J844cEjUijaKx+RUhytQpXbzukoYwc6273tHAJX kle/DXlnOmvD/SnBWlZT0ioNxkIIq+tOL0NiBJbSZ6I2aOEz06bZFGiPpDLV1LQf0+T8 mTms4/JXfjEDS49ADF7zhVa4OvUkhTQqdQVVoCJlq0dozcqrl09dqwciD+L2qTzN56p2 9yybbQlc0N3s3i75OGnirDw2Y1Bl14Lvk/BL+AxgKxqeqwq/j4RvTcvH4SGVLwxUUuHe Mlh71emfVEXBLTdwtY4IwY/4VWWFcySEIy+BK8FzfjZg/fJlFuu6k2qEzBFJZsLiZeeM kFMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc; bh=i9yJwlJ+mrD9iQ7meNbA1E2IvzKt1/2mUxjCNbwh5nU=; b=bNgZKUMN0eno2bExrioxixFFn06auo3wxTRSfYd5+i9+JqwujQfz2R0MwmIOwlc995 0CYpPcYG76KrdNgHCj0Bbp24NF+moJiNjjpvGn1EMNCkGQrAKRwP/ra0cfXYAwZ9ZIlB gRZb2Pn5O4lQOPVitoBqct1FRV2Th5AOeskzE0o0CKv50dd9HuO0bMjgiJvj2D+gmZcK F/PNzqCmpJ/nGlB6eUCfNjZdYaLKr6G9vouD+Z3g3a9z/w6HHFUxLs71qWZBr2+n/Q2g jdgOQaBw25rgKE/p3zfYg9Yie1oKMI2mlevSnSQRN5+7SPHwU4VJyjErHVp0fTwKocwN qwHw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si21832549pfd.55.2019.04.25.01.01.16; Thu, 25 Apr 2019 01:01:32 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbfDYCNf (ORCPT + 99 others); Wed, 24 Apr 2019 22:13:35 -0400 Received: from mga02.intel.com ([134.134.136.20]:14114 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727660AbfDYCNf (ORCPT ); Wed, 24 Apr 2019 22:13:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 19:13:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,392,1549958400"; d="scan'208";a="340574172" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by fmsmga006.fm.intel.com with ESMTP; 24 Apr 2019 19:13:31 -0700 Cc: baolu.lu@linux.intel.com, David Woodhouse , Joerg Roedel , ashok.raj@intel.com, jacob.jun.pan@intel.com, alan.cox@intel.com, kevin.tian@intel.com, mika.westerberg@linux.intel.com, pengfei.xu@intel.com, Konrad Rzeszutek Wilk , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 02/10] swiotlb: Factor out slot allocation and free To: Christoph Hellwig References: <20190421011719.14909-1-baolu.lu@linux.intel.com> <20190421011719.14909-3-baolu.lu@linux.intel.com> <20190422164555.GA31181@lst.de> <0c6e5983-312b-0d6b-92f5-64861cd6804d@linux.intel.com> <20190423061232.GB12762@lst.de> <20190424144532.GA21480@lst.de> From: Lu Baolu Message-ID: Date: Thu, 25 Apr 2019 10:07:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190424144532.GA21480@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 4/24/19 10:45 PM, Christoph Hellwig wrote: > On Tue, Apr 23, 2019 at 03:32:16PM +0800, Lu Baolu wrote: >> When we add the bounce buffer between IOVA and physical buffer, the >> bounced buffer must starts from the same offset in a page, otherwise, >> IOMMU can't work here. > > Why? Even with the odd hardware descriptors typical in Intel land that > only allow offsets in the first page, not the following ones, having > a zero offset where we previously had one should be fine. > This is not VT-d specific. It's just how generic IOMMU works. Normally, IOMMU works in paging mode. So if a driver issues DMA with IOVA 0xAAAA0123, IOMMU can remap it with a physical address 0xBBBB0123. But we should never expect IOMMU to remap 0xAAAA0123 with physical address of 0xBBBB0000. That's the reason why I said that IOMMU will not work there. swiotlb System IOVA bounce page Memory .---------. .---------. .---------. | | | | | | | | | | | | buffer_start .---------. .---------.buffer_start .---------. | |----->| | | | | | | |************>| | | | | | swiotlb | | IOMMU Page '---------' '---------' mapping '---------' Boundary | | | | | | | | | | | | | |----------------------------->| | | | IOMMU mapping | | | | | | IOMMU Page .---------. .---------. Boundary | | | | | | | | | |----------------------------->| | | | IOMMU mapping | | | | | | | | | | IOMMU Page .---------. .---------. .---------. Boundary | | | | | | | | | |************>| | | |----->| | swiotlb | | buffer_end '---------' '---------' mapping '---------' | | | | | | | | | | | | '---------' '---------' '---------' This is the whole view of iommu bounce page. I expect the buffer_start returned by swiotlb_tbl_map_single() starts from the same page_offset as the buffer_start in IOVA. Best regards, Lu Baolu