Message ID | 20231011-mlx5_init_fix-v3-1-787ffb9183c6@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp370798vqb; Wed, 11 Oct 2023 00:58:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMG6yZ8dbwyZeS6i/1HFm1j3qkrHpnGVqrvxfg0m+X5XZ1QgA/EvNQ1esz/CmA6cex7t83 X-Received: by 2002:a17:903:22ce:b0:1bb:83ec:832 with SMTP id y14-20020a17090322ce00b001bb83ec0832mr23074986plg.2.1697011112860; Wed, 11 Oct 2023 00:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697011112; cv=none; d=google.com; s=arc-20160816; b=iXPNDHnTnzCIHm5rWSiGSUveDDcGjapY66PpkuwnL06ugFcEaHTvwZPj70o1Y9qe6V aydn9EK++GCXUECc7WsoUKBSkvlav0tmFkN5AWvephGtQom1TExc7kgTCG22eMvSTWY1 YB/bvaWS89UCVSNRqVmzXQbocxfkpLYXJCfq6x6k7qhS45GYKHqdgOdwuF9Swj7Lr7A7 +CJYLLDOeJIkEjyvC6UnztxQeNbxIk36MNOpnXef4i4sGpG8MFJagliOu+PPPbLt2fXl 1mRl6MlC6twmM/qn+SuwcJzoy6UUWKLbg6JxjMgXt6EVKwEBxmwp5X9/+e4UpghIdx7H biBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding:cc:to :message-id:subject:date:from:dkim-signature; bh=+Nh+ttaIlUVnlNuQdKZMcQ5FWauLUpkU6fMAGytoJds=; fh=JZ6mzTVAQleXCudOvUjZb9JQhqB/GJ4MFA5Opzpjf2o=; b=qcO+cHwAgTmZi0nKfxBDREeLxOnDicjAZP3GmZJuUl1gmQasiFW99cF/YcXvAJjWOe Tb8VpCHFBUVZ3Fm0rNjRQ1BwfaAFlq4zmwuSz4joYtYXmJovzQ5G72uOFicq3RFXugfH qGeStSNuqle6SxcNE57jEomnIz7tY1GT8N1zkBVSZCU0hX7eg19lOjdBHHPSV3vhMKTv 8rhIymmJzUP/G8VNURESD7tmNGJz21juR3oMkzFtdWxI1EpJ/1zJOtRxiVx5GZOttr89 ZijxyN+UHQ5sngZE4o6RBq1qMutmuGeebsKR6zweqp1RdjjMzjYZJl2mR3u0xPkqWGf3 7+ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j7DqAfo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f2-20020a170902ce8200b001b845157b69si15009433plg.414.2023.10.11.00.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j7DqAfo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5AE9D801C1AD; Wed, 11 Oct 2023 00:58:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344758AbjJKH6E (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Wed, 11 Oct 2023 03:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbjJKH6C (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Oct 2023 03:58:02 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2873F91; Wed, 11 Oct 2023 00:58:01 -0700 (PDT) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39B7vZnq027168; Wed, 11 Oct 2023 07:57:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : date : subject : content-type : message-id : to : cc : content-transfer-encoding : mime-version; s=pp1; bh=+Nh+ttaIlUVnlNuQdKZMcQ5FWauLUpkU6fMAGytoJds=; b=j7DqAfo0xor59I2htFF3DcLs60Qnewu5gu7tytRoBYhTWRlbJ5Of0iA2mkgefCBMbVGj /qaO/NJUZZ4gDiTNq8TwnP4GeN87hQSScOPNUKxzkha5drEMUKL3MkTb01mM/84S5ygp Dat9fgdHsK0OWfESORHYxa2t6V0w4nPTyed+IFhWhtmGPlr3JPWOQPK5Kpc794Qohn5M kEx9uLjoz5Bf6D46RiVFIun4Q2h6+PufaW/PoST5MTfL7J4o6OE5Gh6kQdFLoXj+HdMC uqQhG1L2DrPCjGfc7SgibEOPtfISz26FwlgFYV07Ud1WYbvd9tYQcZ0V01AJAk5FBryt 3w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tnqs40077-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 07:57:50 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39B7vZYj027159; Wed, 11 Oct 2023 07:57:50 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tnqs4006v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 07:57:49 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39B7XOis024458; Wed, 11 Oct 2023 07:57:48 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tkhnspwqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 07:57:48 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39B7vkYl44565194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Oct 2023 07:57:46 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE93E20043; Wed, 11 Oct 2023 07:57:45 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F5AB20040; Wed, 11 Oct 2023 07:57:45 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 11 Oct 2023 07:57:45 +0000 (GMT) From: Niklas Schnelle <schnelle@linux.ibm.com> Date: Wed, 11 Oct 2023 09:57:38 +0200 Subject: [PATCH net v3] net/mlx5: fix calling mlx5_cmd_init() before DMA mask is set Content-Type: text/plain; charset="utf-8" Message-Id: <20231011-mlx5_init_fix-v3-1-787ffb9183c6@linux.ibm.com> X-B4-Tracking: v=1; b=H4sIAHFVJmUC/3XN0QqDIBQG4FcJr2eoaeWu9h5jROnZOrBsaJNG9 O4Tr0awy/8//N/ZSACPEMi52IiHiAFnl0J1KogZe/cAijZlIpiomBYtnZ6r6tDh0t1xpUbWalD G9pVoSNq8PKQ6e1fiYCG3VI4Yltl/8o/I8+kPFznltNGN1FYqAzW7PNG91xKHqTTzlLUofgV9F EQSFAcrmJZG2/Yo7Pv+BbgqfYf1AAAA To: Saeed Mahameed <saeedm@nvidia.com>, Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>, Matthew Rosato <mjrosato@linux.ibm.com>, Joerg Roedel <joro@8bytes.org>, Robin Murphy <robin.murphy@arm.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shay Drory <shayd@nvidia.com>, Moshe Shemesh <moshe@nvidia.com>, Heiko Carstens <hca@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com> Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Jacob Keller <jacob.e.keller@intel.com>, Niklas Schnelle <schnelle@linux.ibm.com>, Leon Romanovsky <leon@kernel.org> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3636; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=s4vuRbe1ctTn2sX8uQsBeRCDfvcgXhkrwsTDFdyTJEc=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGFLVQotOqvYpbb5vnW8vZjv72Mb9Et7BRWwRXyY/fp/Zz iT999W8jlIWBjEOBlkxRZZFXc5+6wqmmO4J6u+AmcPKBDKEgYtTACby0Izhr0DtVN2L530+rM/a MPeRy23GvMZHH+S8v+v6Ca98vXvP+hkMfyWmPtDIyNzdznbn11vlzVr/jGTlTQUufJFJ+73wxL7 0szwA X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 3JCCzQyui7zKBQUbndel4jsSrX-48M9N X-Proofpoint-GUID: uvKxe_HwHqSYX_Vf6ALqULCM6UY1N_Bh Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-11_05,2023-10-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 clxscore=1011 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310110069 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 00:58:29 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779445124284271557 X-GMAIL-MSGID: 1779445124284271557 |
Series |
[net,v3] net/mlx5: fix calling mlx5_cmd_init() before DMA mask is set
|
|
Commit Message
Niklas Schnelle
Oct. 11, 2023, 7:57 a.m. UTC
Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is called in probe_one() before mlx5_pci_init(). This is a problem because mlx5_pci_init() is where the DMA and coherent mask is set but mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA allocation is done during probe before the correct mask is set. This causes probe to fail initialization of the cmdif SW structs on s390x after that is converted to the common dma-iommu code. This is because on s390x DMA addresses below 4 GiB are reserved on current machines and unlike the old s390x specific DMA API implementation common code enforces DMA masks. Fix this by moving set_dma_caps() out of mlx5_pci_init() and into probe_one() before mlx5_mdev_init(). To match the overall naming scheme rename it to mlx5_dma_init(). Link: https://lore.kernel.org/linux-iommu/cfc9e9128ed5571d2e36421e347301057662a09e.camel@linux.ibm.com/ Fixes: 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and reload routines") Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> --- Note: I ran into this while testing the linked series for converting s390x to use dma-iommu. The existing s390x specific DMA API implementation doesn't respect DMA masks and is thus not affected. --- Changes in v3: - Added R-b's from Leon R and Jacob K - Link to v2: https://lore.kernel.org/r/20230929-mlx5_init_fix-v2-1-51ed2094c9d8@linux.ibm.com --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- base-commit: 94f6f0550c625fab1f373bb86a6669b45e9748b3 change-id: 20230928-mlx5_init_fix-c465b5cda327 Best regards,
Comments
On 11 Oct 09:57, Niklas Schnelle wrote: >Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and >reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is >called in probe_one() before mlx5_pci_init(). This is a problem because >mlx5_pci_init() is where the DMA and coherent mask is set but >mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA >allocation is done during probe before the correct mask is set. This >causes probe to fail initialization of the cmdif SW structs on s390x >after that is converted to the common dma-iommu code. This is because on >s390x DMA addresses below 4 GiB are reserved on current machines and >unlike the old s390x specific DMA API implementation common code >enforces DMA masks. > >Fix this by moving set_dma_caps() out of mlx5_pci_init() and into >probe_one() before mlx5_mdev_init(). To match the overall naming scheme >rename it to mlx5_dma_init(). How about we just call mlx5_pci_init() before mlx5_mdev_init(), instead of breaking it apart ? >
On 11 Oct 11:20, Saeed Mahameed wrote: >On 11 Oct 09:57, Niklas Schnelle wrote: >>Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and >>reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is >>called in probe_one() before mlx5_pci_init(). This is a problem because >>mlx5_pci_init() is where the DMA and coherent mask is set but >>mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA >>allocation is done during probe before the correct mask is set. This >>causes probe to fail initialization of the cmdif SW structs on s390x >>after that is converted to the common dma-iommu code. This is because on >>s390x DMA addresses below 4 GiB are reserved on current machines and >>unlike the old s390x specific DMA API implementation common code >>enforces DMA masks. >> >>Fix this by moving set_dma_caps() out of mlx5_pci_init() and into >>probe_one() before mlx5_mdev_init(). To match the overall naming scheme >>rename it to mlx5_dma_init(). > >How about we just call mlx5_pci_init() before mlx5_mdev_init(), instead of >breaking it apart ? I just posted this RFC patch [1]: I am working in very limited conditions these days, and I don't have strong opinion on which approach to take, Leon, Niklas, please advise. The three possible solutions: 1) mlx5_pci_init() before mlx5_mdev_init(), I don't think enabling pci before initializing cmd dma would be a problem. 2) This patch. 3) Shay's patch from the link below: [1] https://patchwork.kernel.org/project/netdevbpf/patch/20231011184511.19818-1-saeed@kernel.org/ Thanks, Saeed.
On Wed, 2023-10-11 at 11:56 -0700, Saeed Mahameed wrote: > On 11 Oct 11:20, Saeed Mahameed wrote: > > On 11 Oct 09:57, Niklas Schnelle wrote: > > > Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and > > > reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is > > > called in probe_one() before mlx5_pci_init(). This is a problem because > > > mlx5_pci_init() is where the DMA and coherent mask is set but > > > mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA > > > allocation is done during probe before the correct mask is set. This > > > causes probe to fail initialization of the cmdif SW structs on s390x > > > after that is converted to the common dma-iommu code. This is because on > > > s390x DMA addresses below 4 GiB are reserved on current machines and > > > unlike the old s390x specific DMA API implementation common code > > > enforces DMA masks. > > > > > > Fix this by moving set_dma_caps() out of mlx5_pci_init() and into > > > probe_one() before mlx5_mdev_init(). To match the overall naming scheme > > > rename it to mlx5_dma_init(). > > > > How about we just call mlx5_pci_init() before mlx5_mdev_init(), instead of > > breaking it apart ? > > I just posted this RFC patch [1]: This patch works to solve the problem as well. > > I am working in very limited conditions these days, and I don't have strong > opinion on which approach to take, Leon, Niklas, please advise. > > The three possible solutions: > > 1) mlx5_pci_init() before mlx5_mdev_init(), I don't think enabling pci > before initializing cmd dma would be a problem. > > 2) This patch. > > 3) Shay's patch from the link below: > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20231011184511.19818-1-saeed@kernel.org/ > > Thanks, > Saeed. My first gut feeling was option 1) but I'm just as happy with 2) or 3). For me option 2 is the least invasive but not by much. For me the important thing is what Jason also said yesterday. We need to merge something now to unbreak linux-next on s390x and to make sure we don't end up with a broken v6.7-rc1. This is already hampering our CI tests with linux-next. So let's do whatever can be merged the quickest and then feel free to do any refactoring ideas that this discussion might have spawned on top of that. My guess for this criteria would be 2). Thanks, Niklas
On Thu, 2023-10-12 at 12:53 +0200, Niklas Schnelle wrote: > On Wed, 2023-10-11 at 11:56 -0700, Saeed Mahameed wrote: > > On 11 Oct 11:20, Saeed Mahameed wrote: > > > On 11 Oct 09:57, Niklas Schnelle wrote: > > > > Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and > > > > reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is > > > > called in probe_one() before mlx5_pci_init(). This is a problem because > > > > mlx5_pci_init() is where the DMA and coherent mask is set but > > > > mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA > > > > allocation is done during probe before the correct mask is set. This > > > > causes probe to fail initialization of the cmdif SW structs on s390x > > > > after that is converted to the common dma-iommu code. This is because on > > > > s390x DMA addresses below 4 GiB are reserved on current machines and > > > > unlike the old s390x specific DMA API implementation common code > > > > enforces DMA masks. > > > > > > > > Fix this by moving set_dma_caps() out of mlx5_pci_init() and into > > > > probe_one() before mlx5_mdev_init(). To match the overall naming scheme > > > > rename it to mlx5_dma_init(). > > > > > > How about we just call mlx5_pci_init() before mlx5_mdev_init(), instead of > > > breaking it apart ? > > > > I just posted this RFC patch [1]: > > This patch works to solve the problem as well. > > > > > I am working in very limited conditions these days, and I don't have strong > > opinion on which approach to take, Leon, Niklas, please advise. > > > > The three possible solutions: > > > > 1) mlx5_pci_init() before mlx5_mdev_init(), I don't think enabling pci > > before initializing cmd dma would be a problem. > > > > 2) This patch. > > > > 3) Shay's patch from the link below: > > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20231011184511.19818-1-saeed@kernel.org/ > > > > Thanks, > > Saeed. > > My first gut feeling was option 1) but I'm just as happy with 2) or 3). > For me option 2 is the least invasive but not by much. > > For me the important thing is what Jason also said yesterday. We need > to merge something now to unbreak linux-next on s390x and to make sure > we don't end up with a broken v6.7-rc1. This is already hampering our > CI tests with linux-next. So let's do whatever can be merged the > quickest and then feel free to do any refactoring ideas that this > discussion might have spawned on top of that. My guess for this > criteria would be 2). > > Thanks, > Niklas > Looking closer at the patch from Shay I do like that it changes the order in the disable/tear down path too. So since that also fixes a PPC issue I guess that may indeed be the best solution if we can get it merged quickly. I'll comment with my Tested-by there too. Thanks, Niklas
On 12 Oct 13:39, Niklas Schnelle wrote: >On Thu, 2023-10-12 at 12:53 +0200, Niklas Schnelle wrote: >> On Wed, 2023-10-11 at 11:56 -0700, Saeed Mahameed wrote: >> > On 11 Oct 11:20, Saeed Mahameed wrote: >> > > On 11 Oct 09:57, Niklas Schnelle wrote: >> > > > Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and >> > > > reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is >> > > > called in probe_one() before mlx5_pci_init(). This is a problem because >> > > > mlx5_pci_init() is where the DMA and coherent mask is set but >> > > > mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA >> > > > allocation is done during probe before the correct mask is set. This >> > > > causes probe to fail initialization of the cmdif SW structs on s390x >> > > > after that is converted to the common dma-iommu code. This is because on >> > > > s390x DMA addresses below 4 GiB are reserved on current machines and >> > > > unlike the old s390x specific DMA API implementation common code >> > > > enforces DMA masks. >> > > > >> > > > Fix this by moving set_dma_caps() out of mlx5_pci_init() and into >> > > > probe_one() before mlx5_mdev_init(). To match the overall naming scheme >> > > > rename it to mlx5_dma_init(). >> > > >> > > How about we just call mlx5_pci_init() before mlx5_mdev_init(), instead of >> > > breaking it apart ? >> > >> > I just posted this RFC patch [1]: >> >> This patch works to solve the problem as well. >> >> > >> > I am working in very limited conditions these days, and I don't have strong >> > opinion on which approach to take, Leon, Niklas, please advise. >> > >> > The three possible solutions: >> > >> > 1) mlx5_pci_init() before mlx5_mdev_init(), I don't think enabling pci >> > before initializing cmd dma would be a problem. >> > >> > 2) This patch. >> > >> > 3) Shay's patch from the link below: >> > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20231011184511.19818-1-saeed@kernel.org/ >> > >> > Thanks, >> > Saeed. >> >> My first gut feeling was option 1) but I'm just as happy with 2) or 3). >> For me option 2 is the least invasive but not by much. >> >> For me the important thing is what Jason also said yesterday. We need >> to merge something now to unbreak linux-next on s390x and to make sure >> we don't end up with a broken v6.7-rc1. This is already hampering our >> CI tests with linux-next. So let's do whatever can be merged the >> quickest and then feel free to do any refactoring ideas that this >> discussion might have spawned on top of that. My guess for this >> criteria would be 2). >> >> Thanks, >> Niklas >> > >Looking closer at the patch from Shay I do like that it changes the >order in the disable/tear down path too. So since that also fixes a PPC >issue I guess that may indeed be the best solution if we can get it >merged quickly. I'll comment with my Tested-by there too. > Ack, will take Shay's patch then, Will add your Test-by and Reviewed-by. >Thanks, >Niklas
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 15561965d2af..f251d233a16c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -250,7 +250,7 @@ static void mlx5_set_driver_version(struct mlx5_core_dev *dev) mlx5_cmd_exec_in(dev, set_driver_version, in); } -static int set_dma_caps(struct pci_dev *pdev) +static int mlx5_dma_init(struct pci_dev *pdev) { int err; @@ -905,12 +905,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev, pci_set_master(pdev); - err = set_dma_caps(pdev); - if (err) { - mlx5_core_err(dev, "Failed setting DMA capabilities mask, aborting\n"); - goto err_clr_master; - } - if (pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP32) && pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP64) && pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP128)) @@ -1908,9 +1902,15 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto adev_init_err; } + err = mlx5_dma_init(pdev); + if (err) { + mlx5_core_err(dev, "Failed setting DMA capabilities mask, aborting\n"); + goto dma_init_err; + } + err = mlx5_mdev_init(dev, prof_sel); if (err) - goto mdev_init_err; + goto dma_init_err; err = mlx5_pci_init(dev, pdev, id); if (err) { @@ -1942,7 +1942,7 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id) mlx5_pci_close(dev); pci_init_err: mlx5_mdev_uninit(dev); -mdev_init_err: +dma_init_err: mlx5_adev_idx_free(dev->priv.adev_idx); adev_init_err: mlx5_devlink_free(devlink);