From patchwork Fri Nov 21 16:26:10 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10046 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id DB6B7DDDED for ; Sat, 22 Nov 2008 03:27:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756795AbYKUQ0t (ORCPT ); Fri, 21 Nov 2008 11:26:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756783AbYKUQ0t (ORCPT ); Fri, 21 Nov 2008 11:26:49 -0500 Received: from outbound-sin.frontbridge.com ([207.46.51.80]:3687 "EHLO SG2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756507AbYKUQ0k (ORCPT ); Fri, 21 Nov 2008 11:26:40 -0500 Received: from mail59-sin-R.bigfish.com (10.3.40.3) by SG2EHSOBE005.bigfish.com (10.3.40.25) with Microsoft SMTP Server id 8.1.291.1; Fri, 21 Nov 2008 16:26:38 +0000 Received: from mail59-sin (localhost.localdomain [127.0.0.1]) by mail59-sin-R.bigfish.com (Postfix) with ESMTP id 4ED823B82A2; Fri, 21 Nov 2008 16:26:38 +0000 (UTC) X-BigFish: VPS3(zzzzzzz32i43j66h) X-Spam-TCS-SCL: 5:0 Received: by mail59-sin (MessageSwitch) id 1227284796909279_2123; Fri, 21 Nov 2008 16:26:36 +0000 (UCT) Received: from svlb1extmailp02.amd.com (unknown [139.95.251.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail59-sin.bigfish.com (Postfix) with ESMTP id 5AD56188006D; Fri, 21 Nov 2008 16:26:33 +0000 (UTC) Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id mALGQFBj014068; Fri, 21 Nov 2008 08:26:18 -0800 X-WSS-ID: 0KAOYZP-03-S7Z-01 Received: from SSVLEXBH2.amd.com (ssvlexbh2.amd.com [139.95.53.183]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2031F884944; Fri, 21 Nov 2008 08:26:12 -0800 (PST) Received: from SSVLEXMB1.amd.com ([139.95.53.181]) by SSVLEXBH2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 21 Nov 2008 08:26:18 -0800 Received: from SF30EXMB1.amd.com ([172.20.6.49]) by SSVLEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 21 Nov 2008 08:26:18 -0800 Received: from lemmy.localdomain ([165.204.85.93]) by SF30EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 21 Nov 2008 17:26:10 +0100 Received: by lemmy.localdomain (Postfix, from userid 41430) id 98B6353C44; Fri, 21 Nov 2008 17:26:10 +0100 (CET) From: Joerg Roedel To: Ingo Molnar , Thomas Gleixner CC: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux-foundation.org, Joerg Roedel Subject: [PATCH 10/10] x86: add checks for sync_sg* code Date: Fri, 21 Nov 2008 17:26:10 +0100 Message-ID: <1227284770-19215-11-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 In-Reply-To: <1227284770-19215-1-git-send-email-joerg.roedel@amd.com> References: <1227284770-19215-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 21 Nov 2008 16:26:10.0672 (UTC) FILETIME=[DD2F8700:01C94BF5] MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Impact: detect bugs in sync_sg* usage Signed-off-by: Joerg Roedel --- arch/x86/include/asm/dma-mapping.h | 2 ++ arch/x86/include/asm/dma_debug.h | 20 ++++++++++++++++++++ arch/x86/kernel/pci-dma-debug.c | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index 2b6399d..6a580e9 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h @@ -215,6 +215,7 @@ dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, BUG_ON(!valid_dma_direction(direction)); if (ops->sync_sg_for_cpu) ops->sync_sg_for_cpu(hwdev, sg, nelems, direction); + debug_sync_sg_for_cpu(hwdev, sg, nelems, direction); flush_write_buffers(); } @@ -227,6 +228,7 @@ dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, BUG_ON(!valid_dma_direction(direction)); if (ops->sync_sg_for_device) ops->sync_sg_for_device(hwdev, sg, nelems, direction); + debug_sync_sg_for_device(hwdev, sg, nelems, direction); flush_write_buffers(); } diff --git a/arch/x86/include/asm/dma_debug.h b/arch/x86/include/asm/dma_debug.h index bc4a841..b30d3c9 100644 --- a/arch/x86/include/asm/dma_debug.h +++ b/arch/x86/include/asm/dma_debug.h @@ -86,6 +86,14 @@ void debug_sync_single_range_for_device(struct device *dev, unsigned long offset, size_t size, int direction); +extern +void debug_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, + int nelems, int direction); + +extern +void debug_sync_sg_for_device(struct device *dev, struct scatterlist *sg, + int nelems, int direction); + #else /* CONFIG_DMA_API_DEBUG */ static inline @@ -156,6 +164,18 @@ void debug_sync_single_range_for_device(struct device *dev, { } +static inline +void debug_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, + int nelems, int direction) +{ +} + +static inline +void debug_sync_sg_for_device(struct device *dev, struct scatterlist *sg, + int nelems, int direction) +{ +} + #endif /* CONFIG_DMA_API_DEBUG */ #endif /* __ASM_X86_DMA_DEBUG */ diff --git a/arch/x86/kernel/pci-dma-debug.c b/arch/x86/kernel/pci-dma-debug.c index 92b9491..ac8e1f9 100644 --- a/arch/x86/kernel/pci-dma-debug.c +++ b/arch/x86/kernel/pci-dma-debug.c @@ -439,3 +439,27 @@ void debug_sync_single_range_for_device(struct device *dev, } EXPORT_SYMBOL(debug_sync_single_range_for_device); +void debug_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, + int nelems, int direction) +{ + struct scatterlist *s; + int i; + + for_each_sg(sg, s, nelems, i) + check_sync(dev, s->dma_address, s->dma_length, 0, + direction, true); +} +EXPORT_SYMBOL(debug_sync_sg_for_cpu); + +void debug_sync_sg_for_device(struct device *dev, struct scatterlist *sg, + int nelems, int direction) +{ + struct scatterlist *s; + int i; + + for_each_sg(sg, s, nelems, i) + check_sync(dev, s->dma_address, s->dma_length, 0, + direction, false); +} +EXPORT_SYMBOL(debug_sync_sg_for_device); +