From patchwork Tue Dec 13 15:10:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ott X-Patchwork-Id: 9472553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7624A6021C for ; Tue, 13 Dec 2016 15:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6901C28554 for ; Tue, 13 Dec 2016 15:11:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DF0A285F4; Tue, 13 Dec 2016 15:11:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9DD628554 for ; Tue, 13 Dec 2016 15:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933775AbcLMPLF (ORCPT ); Tue, 13 Dec 2016 10:11:05 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35131 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933658AbcLMPLC (ORCPT ); Tue, 13 Dec 2016 10:11:02 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBDFA8Du119695 for ; Tue, 13 Dec 2016 10:11:02 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 27akch81fc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Dec 2016 10:11:01 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Dec 2016 15:10:59 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Dec 2016 15:10:56 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0B6912190061; Tue, 13 Dec 2016 15:10:06 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uBDFAtCv13107702; Tue, 13 Dec 2016 15:10:56 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D67634C059; Tue, 13 Dec 2016 14:09:09 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B01954C05A; Tue, 13 Dec 2016 14:09:09 +0000 (GMT) Received: from dyn-9-152-212-47.boeblingen.de.ibm.com (unknown [9.152.212.47]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 13 Dec 2016 14:09:09 +0000 (GMT) Date: Tue, 13 Dec 2016 16:10:55 +0100 (CET) From: Sebastian Ott X-X-Sender: sebott@schleppi To: Doug Ledford , Sean Hefty , Hal Rosenstock cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH resend] IB/core: fix unmap_sg argument In-Reply-To: References: User-Agent: Alpine 2.20 (LFD 67 2015-01-07) Organization: =?ISO-8859-15?Q?=22IBM_Deutschland_Research_&_Development_GmbH_=2F_Vorsitzende_des_Aufsichtsrats=3A_Martina_Koederitz_Gesch=E4ftsf=FChrung=3A_Dirk_Wittkopp_Sitz_der_Gesellschaft=3A_B=F6blingen_=2F_Registergericht?= =?ISO-8859-15?Q?=3A_Amtsgericht_Stuttgart=2C_HRB_243294=22?= MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121315-0020-0000-0000-000002472A4F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121315-0021-0000-0000-00001EA9F45D Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-13_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612130245 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, using dapltest on s390 I ran into the following warning: [ 20.781709] mlx4_core 0000:00:00.0: DMA-API: device driver frees DMA sg list with different entry count [map count=2] [unmap count=1] [ 20.781760] ------------[ cut here ]------------ [ 20.781767] WARNING: CPU: 4 PID: 1063 at lib/dma-debug.c:1141 check_unmap+0x658/0xa08 [ 20.781769] Modules linked in: rdma_ucm ib_ucm ib_uverbs rdma_cm configfs ib_cm iw_cm [...] [ 20.781797] CPU: 4 PID: 1063 Comm: dapltest Tainted: G W 4.9.0-rc7-00039-g43c4f67 #65 [ 20.781799] Hardware name: IBM 2964 N96 704 (LPAR) [ 20.781801] task: 00000000dd8e4008 task.stack: 00000000f1448000 [ 20.781803] Krnl PSW : 0404c00180000000 000000000060af08 (check_unmap+0x658/0xa08) [ 20.781806] R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3 [ 20.781809] Krnl GPRS: 0000000000000002 00000000dd8e4008 0000000000000079 0000000000a1d4f0 [ 20.781811] 000000000060af04 0000000000000000 0000000000000001 0000000000000001 [ 20.781813] 00000000f8e8e880 07000000008f2210 0000000001e47700 00000000f7a11298 [ 20.781814] 00000000f144ba68 00000000008f21f8 000000000060af04 00000000f144b960 [ 20.781822] Krnl Code: 000000000060aef8: c0200022fcc0 larl %r2,a6a878 000000000060aefe: c0e5ffe474dd brasl %r14,2998b8 #000000000060af04: a7f40001 brc 15,60af06 >000000000060af08: c0200022f976 larl %r2,a6a1f4 000000000060af0e: c0e5ffe474d5 brasl %r14,2998b8 000000000060af14: 4120b050 la %r2,80(%r11) 000000000060af18: a7390000 lghi %r3,0 000000000060af1c: c0e5ffde780a brasl %r14,1d9f30 [ 20.781847] Call Trace: [ 20.781848] ([<000000000060af04>] check_unmap+0x654/0xa08) [ 20.781851] [<000000000060b6bc>] debug_dma_unmap_sg+0xf4/0x160 [ 20.781873] [<000003ff82245738>] __ib_umem_release+0x98/0x1a8 [ib_core] [ 20.781881] [<000003ff82245f3e>] ib_umem_release+0x5e/0x1d0 [ib_core] [ 20.781891] [<000003ff80139976>] mlx4_ib_destroy_qp+0x47e/0x550 [mlx4_ib] [ 20.781898] [<000003ff8222ad2e>] ib_destroy_qp+0x116/0x188 [ib_core] [ 20.781902] [<000003ff80052fba>] ib_uverbs_destroy_qp+0xb2/0x1a0 [ib_uverbs] [ 20.781905] [<000003ff8004cada>] ib_uverbs_write+0x20a/0x488 [ib_uverbs] [ 20.781910] [<0000000000352756>] __vfs_write+0x36/0x138 [ 20.781912] [<000000000035348c>] vfs_write+0xbc/0x1a0 [ 20.781914] [<0000000000354a96>] SyS_write+0x66/0xc0 [ 20.781918] [<000000000087d796>] system_call+0xd6/0x270 [ 20.781919] INFO: lockdep is turned off. [ 20.781921] Last Breaking-Event-Address: [ 20.781922] [<000000000060af04>] check_unmap+0x654/0xa08 [ 20.781924] ---[ end trace bd581c43b9bebeea ]--- [ 20.781925] Mapped at: [ 20.781929] [<000000000060b4a6>] debug_dma_map_sg+0x5e/0x180 [ 20.781938] [<000003ff82245d12>] ib_umem_get+0x4ca/0x610 [ib_core] [ 20.781943] [<000003ff80136df2>] create_qp_common.isra.15+0x572/0x1010 [mlx4_ib] [ 20.781949] [<000003ff8013929e>] mlx4_ib_create_qp+0x1de/0x438 [mlx4_ib] [ 20.781953] [<000003ff8004f52c>] create_qp.isra.11+0x44c/0x7f0 [ib_uverbs] The following patch fixes this: ---->8 From ec91646d8c14e2a8dd2b62187084dab32ef8a56b Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Fri, 2 Dec 2016 11:15:05 +0100 Subject: [PATCH] IB/core: fix unmap_sg argument __ib_umem_release calls dma_unmap_sg with a different number of sg_entries than ib_umem_get uses for dma_map_sg. This might cause trouble for implementations that merge sglist entries and results in the following dma debug complaint: DMA-API: device driver frees DMA sg list with different entry count [map count=2] [unmap count=1] Fix it by using the correct value. Signed-off-by: Sebastian Ott --- drivers/infiniband/core/umem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 84b4eff..1e62a5f 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -51,7 +51,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d if (umem->nmap > 0) ib_dma_unmap_sg(dev, umem->sg_head.sgl, - umem->nmap, + umem->npages, DMA_BIDIRECTIONAL); for_each_sg(umem->sg_head.sgl, sg, umem->npages, i) {