From: Amit Shah Subject: [PATCH 5/8] KVM: PVDMA: Update dma_alloc_coherent to make it paravirt-aware Date: Wed, 7 Nov 2007 16:21:06 +0200 Message-ID: <1194445269469-git-send-email-amit.shah@qumranet.com> References: <1194445269752-git-send-email-amit.shah@qumranet.com> <11944452691714-git-send-email-amit.shah@qumranet.com> <11944452692774-git-send-email-amit.shah@qumranet.com> <11944452694052-git-send-email-amit.shah@qumranet.com> <1194445269859-git-send-email-amit.shah@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Amit Shah To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Return-path: In-Reply-To: <1194445269859-git-send-email-amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> Message-Id: In-Reply-To: References: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Of all the DMA calls, only dma_alloc_coherent might not actually call dma_ops->alloc_coherent. We make sure that gets called if the device that's being worked on is a PV device Signed-off-by: Amit Shah --- arch/x86/kernel/pci-dma_64.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/pci-dma_64.c b/arch/x86/kernel/pci-dma_64.c index aa805b1..d4b1713 100644 --- a/arch/x86/kernel/pci-dma_64.c +++ b/arch/x86/kernel/pci-dma_64.c @@ -11,6 +11,7 @@ #include #include #include +#include int iommu_merge __read_mostly = 1; EXPORT_SYMBOL(iommu_merge); @@ -134,6 +135,18 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, memset(memory, 0, size); if (!mmu) { *dma_handle = virt_to_bus(memory); + if (unlikely(dma_ops->is_pv_device) + && unlikely(dma_ops->is_pv_device(dev, dev->bus_id))) { + void *r; + r = dma_ops->alloc_coherent(dev, size, + dma_handle, + gfp); + if (r == NULL) { + free_pages((unsigned long)memory, + get_order(size)); + memory = NULL; + } + } return memory; } } -- 1.5.3 ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/