From patchwork Fri Oct 25 22:58:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11213173 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EF261709 for ; Fri, 25 Oct 2019 22:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54C4721D7B for ; Fri, 25 Oct 2019 22:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbfJYW6l (ORCPT ); Fri, 25 Oct 2019 18:58:41 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42492 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725881AbfJYW6l (ORCPT ); Fri, 25 Oct 2019 18:58:41 -0400 Received: by mail-pf1-f195.google.com with SMTP id 21so2579646pfj.9; Fri, 25 Oct 2019 15:58:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=id3Jag4Ah2PkB7BKapHcKYtTL7WashnqZLKEAmMbsoE=; b=MZScq3UdhvrmlDVe5EBsvK0Lvfrl7WM4JQr+TE/GRKfD4gUaIR0owHKfBgG8w33fOt UIdAGLtdrd9FpbMX9u8jtNA4PA2GJhclvMkpkJBjyHSgOH476+AGX81P8e0qns4ZNjU8 pFKFn7vbiu4lmtp/QbrmJagAF4N4P/FbH15/P5DWPH+z+QUjZBEcL6OcFhjkPxvbOe7J ioI9xXQQUfmRDqHVtsSMU9PTkzBxz0ewhrEj1bGlutnRx/w7EfYAP2AEUTlUm0mmzdtG 7KiPBusBFv7V/Gqm9rm34EAUuQzMpyqgUCa4/e7xyu4gKOZOdVPqR/8QrY+Hkigu5RSL trvg== X-Gm-Message-State: APjAAAUrC/VsFr+B1NF61C8kLAqWUQd6TeXMHIJI2M1eM8IrgIq1RIlq 6+0F/YdHNcCZwUUEH/d2+rA= X-Google-Smtp-Source: APXvYqxVNh2jQV3Ol7QSf63nwA0BzgNLtjQm8Jc74eJh4xlOySDdcvTkNaZoexKrf+dv3WMptsoYLQ== X-Received: by 2002:a63:258:: with SMTP id 85mr7097403pgc.352.1572044318650; Fri, 25 Oct 2019 15:58:38 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id o123sm3243983pfg.161.2019.10.25.15.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 15:58:37 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Christoph Hellwig , stable@vger.kernel.org Subject: [PATCH v2 1/4] RDMA/core: Fix ib_dma_max_seg_size() Date: Fri, 25 Oct 2019 15:58:27 -0700 Message-Id: <20191025225830.257535-2-bvanassche@acm.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191025225830.257535-1-bvanassche@acm.org> References: <20191025225830.257535-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org If dev->dma_device->params == NULL then the maximum DMA segment size is 64 KB. See also the dma_get_max_seg_size() implementation. This patch fixes the following kernel warning: DMA-API: infiniband rxe0: mapping sg segment longer than device claims to support [len=126976] [max=65536] WARNING: CPU: 4 PID: 4848 at kernel/dma/debug.c:1220 debug_dma_map_sg+0x3d9/0x450 RIP: 0010:debug_dma_map_sg+0x3d9/0x450 Call Trace: srp_queuecommand+0x626/0x18d0 [ib_srp] scsi_queue_rq+0xd02/0x13e0 [scsi_mod] __blk_mq_try_issue_directly+0x2b3/0x3f0 blk_mq_request_issue_directly+0xac/0xf0 blk_insert_cloned_request+0xdf/0x170 dm_mq_queue_rq+0x43d/0x830 [dm_mod] __blk_mq_try_issue_directly+0x2b3/0x3f0 blk_mq_request_issue_directly+0xac/0xf0 blk_mq_try_issue_list_directly+0xb8/0x170 blk_mq_sched_insert_requests+0x23c/0x3b0 blk_mq_flush_plug_list+0x529/0x730 blk_flush_plug_list+0x21f/0x260 blk_mq_make_request+0x56b/0xf20 generic_make_request+0x196/0x660 submit_bio+0xae/0x290 blkdev_direct_IO+0x822/0x900 generic_file_direct_write+0x110/0x200 __generic_file_write_iter+0x124/0x2a0 blkdev_write_iter+0x168/0x270 aio_write+0x1c4/0x310 io_submit_one+0x971/0x1390 __x64_sys_io_submit+0x12a/0x390 do_syscall_64+0x6f/0x2e0 entry_SYSCALL_64_after_hwframe+0x49/0xbe Cc: Christoph Hellwig Cc: Fixes: 0b5cb3300ae5 ("RDMA/srp: Increase max_segment_size") Signed-off-by: Bart Van Assche --- include/rdma/ib_verbs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index cca9985b4cbc..0626b62ed107 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -4057,9 +4057,7 @@ static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, */ static inline unsigned int ib_dma_max_seg_size(struct ib_device *dev) { - struct device_dma_parameters *p = dev->dma_device->dma_parms; - - return p ? p->max_segment_size : UINT_MAX; + return dma_get_max_seg_size(dev->dma_device); } /** From patchwork Fri Oct 25 22:58:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11213175 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93213139A for ; Fri, 25 Oct 2019 22:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75C4221D7B for ; Fri, 25 Oct 2019 22:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725881AbfJYW6l (ORCPT ); Fri, 25 Oct 2019 18:58:41 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44382 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbfJYW6l (ORCPT ); Fri, 25 Oct 2019 18:58:41 -0400 Received: by mail-pf1-f193.google.com with SMTP id q21so2571882pfn.11 for ; Fri, 25 Oct 2019 15:58:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xiZm8Grr+XQGxlXA+rdrPe0AsMaw87H9ybwMaRghF2A=; b=V04LPsyabgfCUYkYD3zDTGIJ7GvydLkrQHugLDy7OavYDlXwAVLZ8sW29b0Xcda352 Hy8jyeeIVkUxsaBb67Af8YJH9g0N0PnSijqY4KXtw7JiAa4V429TWuopohA4YgKC+MbX kU5/LIBkowqydgSpIqSvN5loHAjJG6ReO+lwkFekdtH8PpIDKSn6IfQhiLMoIo4ZhvoE 9MakD+6k1Bzp7P1RrKBcCcnP3BmFhasf2Qc24yf69GyfCNKZBoHXNiKCxFv3JjqqnR/m KpfxfLbmQpI56V6iaX0SqSZktRLyB8OGV+pKQLZI1r07eJ8oFIWEL6gU+ou1XUnR2adG 2ovA== X-Gm-Message-State: APjAAAVoYkbZrYcerT2Dwgm6jVMk+aCzxPrFyLMsolMm6tYr4FGIgB0Z 0JhTL6co1VFq9m34J60LBjmUOd1S X-Google-Smtp-Source: APXvYqz3Cu64n1dFpqt8SRjoYReWjqvGauv5d7jDrUQ4FyATstzRNA8iLffkSqCvdJOuxOCZNBKA8w== X-Received: by 2002:a17:90a:8002:: with SMTP id b2mr56437pjn.39.1572044320655; Fri, 25 Oct 2019 15:58:40 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id o123sm3243983pfg.161.2019.10.25.15.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 15:58:39 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Christoph Hellwig Subject: [PATCH v2 2/4] rdma_rxe: Increase DMA max_segment_size parameter Date: Fri, 25 Oct 2019 15:58:28 -0700 Message-Id: <20191025225830.257535-3-bvanassche@acm.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191025225830.257535-1-bvanassche@acm.org> References: <20191025225830.257535-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Increase the DMA max_segment_size parameter from 64 KB to 2 GB. Cc: Christoph Hellwig Signed-off-by: Bart Van Assche --- drivers/infiniband/sw/rxe/rxe_verbs.c | 3 +++ drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index fa47bdcc7f54..9dd4bd7aea92 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1175,6 +1175,9 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name) addrconf_addr_eui48((unsigned char *)&dev->node_guid, rxe->ndev->dev_addr); dev->dev.dma_ops = &dma_virt_ops; + dev->dev.dma_parms = &rxe->dma_parms; + rxe->dma_parms = (struct device_dma_parameters) + { .max_segment_size = SZ_2G }; dma_coerce_mask_and_coherent(&dev->dev, dma_get_required_mask(&dev->dev)); diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 5c4b2239129c..95834206c80c 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -384,6 +384,7 @@ struct rxe_port { struct rxe_dev { struct ib_device ib_dev; struct ib_device_attr attr; + struct device_dma_parameters dma_parms; int max_ucontext; int max_inline_data; struct mutex usdev_lock; From patchwork Fri Oct 25 22:58:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11213177 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFAD8139A for ; Fri, 25 Oct 2019 22:58:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5BCB21D81 for ; Fri, 25 Oct 2019 22:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726369AbfJYW6n (ORCPT ); Fri, 25 Oct 2019 18:58:43 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39636 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbfJYW6m (ORCPT ); Fri, 25 Oct 2019 18:58:42 -0400 Received: by mail-pl1-f196.google.com with SMTP id s17so2069121plp.6 for ; Fri, 25 Oct 2019 15:58:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KK2MwTYJxaSyWA184yIdB0YJ/S2GhMiDQz5RLBVTHHE=; b=poJf5S0MRQ46kAdMJu+Bxs98MFEIgtrc2lbrg1ithK1vz6/vTM8wkA/AKeXxgymMPX NebrYE5WzOT7k6dL2GG4boR09QjV3qarXEvfXoSU1kHVN2qj8CJ5J9rBaRW876AXt4Yc 1XHet3O2lluJ+wijEEpuZ6JN7WHNJHd/qTpnKyTlupmLhvmqYBGPAZO6KCqpY37aSPq0 fpVe6sbfSOzgqyFPm7KCqWOM6bjDYmEbTswN+wewb5GHx8Tor2DcvJMbFfp4x7AjwU7r 545ZvRBnpL6ZiHF3jV/c7FYpIsAAMwSua3vIKvUyy1nXGup9zTTJEccawhD87tkVJHfx l+uA== X-Gm-Message-State: APjAAAUVYi6By5AOrYr2/hRZ22ltQJgDBupQs0PGoao4GcyPNI2m4bKu ljMumfzVmPohhBAhixxguYA= X-Google-Smtp-Source: APXvYqw5Z4y8LfkUY3zohGpQmUTg3x7o60kx8aNLGNkRFtxveKUXIPBuqCqk4dS74nDlDPCviVbGIw== X-Received: by 2002:a17:902:7786:: with SMTP id o6mr6567146pll.109.1572044322103; Fri, 25 Oct 2019 15:58:42 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id o123sm3243983pfg.161.2019.10.25.15.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 15:58:41 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Bernard Metzler Subject: [PATCH v2 3/4] siw: Increase DMA max_segment_size parameter Date: Fri, 25 Oct 2019 15:58:29 -0700 Message-Id: <20191025225830.257535-4-bvanassche@acm.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191025225830.257535-1-bvanassche@acm.org> References: <20191025225830.257535-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Increase the DMA max_segment_size parameter from 64 KB to 2 GB. Cc: Christoph Hellwig Cc: Bernard Metzler Signed-off-by: Bart Van Assche --- drivers/infiniband/sw/siw/siw.h | 1 + drivers/infiniband/sw/siw/siw_main.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h index dba4535494ab..1ea3ed249e7b 100644 --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -70,6 +70,7 @@ struct siw_pd { struct siw_device { struct ib_device base_dev; + struct device_dma_parameters dma_parms; struct net_device *netdev; struct siw_dev_cap attrs; diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c index b8fe43074ad6..48e45a852b51 100644 --- a/drivers/infiniband/sw/siw/siw_main.c +++ b/drivers/infiniband/sw/siw/siw_main.c @@ -382,6 +382,9 @@ static struct siw_device *siw_device_create(struct net_device *netdev) base_dev->phys_port_cnt = 1; base_dev->dev.parent = parent; base_dev->dev.dma_ops = &dma_virt_ops; + base_dev->dev.dma_parms = &sdev->dma_parms; + sdev->dma_parms = (struct device_dma_parameters) + { .max_segment_size = SZ_2G }; base_dev->num_comp_vectors = num_possible_cpus(); ib_set_device_ops(base_dev, &siw_device_ops); From patchwork Fri Oct 25 22:58:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11213179 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D85C1515 for ; Fri, 25 Oct 2019 22:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71D7A21D7B for ; Fri, 25 Oct 2019 22:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726330AbfJYW6p (ORCPT ); Fri, 25 Oct 2019 18:58:45 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36006 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbfJYW6p (ORCPT ); Fri, 25 Oct 2019 18:58:45 -0400 Received: by mail-pl1-f193.google.com with SMTP id g9so1467578plp.3 for ; Fri, 25 Oct 2019 15:58:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N5fX6/xTHdCr2cl+KM/9mkyr80CZCAS+fLmex58s/Tw=; b=dUlgKjCU4es1+qhfN+qlTLHaqfg4MepOernbKfn9qhOdhu57mOwKzvqp7xWwv68N2N srwvXzyN+8UqxowyLRFbjz2raEQcPyYVcGaP8oZWQjrGFA18g1ZA4JsOO86Mu5nEIPQE LV73eccKr1lfFQb5+Tro5nNDe+p6JqRhlMGcuQ+2CCgvcWsAPP1Q910s58E9WNPNRNUj XEL0V3CDFDEI6IXVyprfLXyukNQYsMZAkZ+qSs/LmBAo+AScRrLB9d/+CkJkYrffqT9t lvP5sdRAFk9z9k2/iAGQVHjCKUklW0Gv0ehOCZKJj4OPLRpmWA1e9pc7haFQ26WvlENS 9xbw== X-Gm-Message-State: APjAAAUzAEMx4kXK/S9UrUSUM2p1K3PFcs/Bvg/QEIXN3VPMdcdy4TKV Ffeuvq091bBRfSjhrMjOGMM= X-Google-Smtp-Source: APXvYqwTXmk9JYFILFZ4MTkn1hBb6AE6dIkjWrNLfB6+glX4S/7zJ0mxJvS+I9sSlkIep4TGzPCXEg== X-Received: by 2002:a17:902:a98c:: with SMTP id bh12mr6428508plb.289.1572044323566; Fri, 25 Oct 2019 15:58:43 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id o123sm3243983pfg.161.2019.10.25.15.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 15:58:42 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , "Michael J . Ruhl" , Ira Weiny , Adit Ranadive , Shiraz Saleem , Gal Pressman , Selvin Xavier Subject: [PATCH v2 4/4] RDMA/core: Set DMA parameters correctly Date: Fri, 25 Oct 2019 15:58:30 -0700 Message-Id: <20191025225830.257535-5-bvanassche@acm.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191025225830.257535-1-bvanassche@acm.org> References: <20191025225830.257535-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The dma_set_max_seg_size() call in setup_dma_device() does not have any effect since device->dev.dma_parms is NULL. Fix this by initializing device->dev.dma_parms first. Cc: Michael J. Ruhl Cc: Ira Weiny Cc: Adit Ranadive Cc: Shiraz Saleem Cc: Gal Pressman Cc: Selvin Xavier Fixes: d10bcf947a3e ("RDMA/umem: Combine contiguous PAGE_SIZE regions in SGEs") Signed-off-by: Bart Van Assche --- drivers/infiniband/core/device.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index eb35b663a742..a93c23867fb5 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1196,9 +1196,21 @@ static void setup_dma_device(struct ib_device *device) WARN_ON_ONCE(!parent); device->dma_device = parent; } - /* Setup default max segment size for all IB devices */ - dma_set_max_seg_size(device->dma_device, SZ_2G); + if (!device->dev.dma_parms) { + if (parent) { + /* + * The caller did not provide DMA parameters, so + * 'parent' probably represents a PCI device. The PCI + * core sets the maximum segment size to 64 + * KB. Increase this parameter to 2 GB. + */ + device->dev.dma_parms = parent->dma_parms; + dma_set_max_seg_size(device->dma_device, SZ_2G); + } else { + WARN_ON_ONCE(true); + } + } } /*