From patchwork Fri Dec 24 01:23:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698729 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3E4DC433EF for ; Fri, 24 Dec 2021 01:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245419AbhLXBZG (ORCPT ); Thu, 23 Dec 2021 20:25:06 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25905 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245155AbhLXBZF (ORCPT ); Thu, 23 Dec 2021 20:25:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309105; x=1671845105; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uCi+C9tPaKaYR8lDF/Giqd8tc3Ab1VRUKhQG4JCdYUI=; b=xxSc2qfy0VUbfm50QeGGiK7TGGkb+j5dDE5KRI8oSgYrlm35WFWO6v8M pvqFuevG4gBvFGG1y+uxsBltE5iX8jyzvf20Xy8ezpXnWqpknjZONGckt p8AxUukM929Rxl2k6XHkwJK185tXBYWhYzDIuytPIA/Fc35bhHfT8i9I+ dP8+o9VDVqqJ5aLa2o0QKaxBo9lUQQAeU3yeWJueRs8Ydw89pzTfe1lp5 9+GNxTJiplX3T0AYjJPnqyhXdLaGbQFagamjiMfqfTJIlnSwJA2WX+Woq d802/HOU3B3h11Uxy5FAj99KR/gFMUOZnaskm7Drttw7u8lSKxDMrXCbw Q==; IronPort-SDR: NInssDyEZuda0SohtKiYqIbKSJxtQsHjvBkPXHYsWFoxUXUTXKO7xp3FBVvRpUMc118EK9OnpD 5pRZ3nzPJdjQj6LWKhlWR77WAUsGX3hDXQcAQ1sUQPQfyun2JIH/XjI8NVfdymhPP27SjbuW8l V8vGSULTuB5TtGaWwcx/HE/AotwBx1yJdvcpYRzSn7+RjAnlHcTzmMCZfa2QM/iUDWDySdswSw PvVEUIUxq5G4X7gfGgjeAnhyiQfpBkufGhwkpgFKIPOP7nF9hKwf9w/i+uQiNDJZfsR5hePu9y l4nCeW1Eh+tXlrD103l3wBQJ X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533969" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:04 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:04 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:04 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 1/6] ntb_hw_switchtec: Fix pff ioread to read into mmio_part_cfg_all Date: Thu, 23 Dec 2021 17:23:29 -0800 Message-ID: <20211224012334.89173-2-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jeremy Pallotta Array mmio_part_cfg_all holds the partition configuration of all partitions, with partition number as index. Fix this by reading into mmio_part_cfg_all for pff. Fixes: 0ee28f26f378 ("NTB: switchtec_ntb: Add link management") Signed-off-by: Jeremy Pallotta Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index 4c6eb61a6ac6..6603c77c0a84 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -419,8 +419,8 @@ static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev, enum ntb_width *width) { struct switchtec_dev *stdev = sndev->stdev; - - u32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); + u32 pff = + ioread32(&stdev->mmio_part_cfg_all[partition].vep_pff_inst_id); u32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); if (speed) From patchwork Fri Dec 24 01:23:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698730 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE51C433EF for ; Fri, 24 Dec 2021 01:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350584AbhLXBZI (ORCPT ); Thu, 23 Dec 2021 20:25:08 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25905 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245423AbhLXBZG (ORCPT ); Thu, 23 Dec 2021 20:25:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309106; x=1671845106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2BLqHxCg2vluzkUWaKHLiNKiQukkKyvUGf/eBL4mwj8=; b=O00WXEGGaLK0Bpw+kaBLjTtbf9PwnizugYLfdUy6SYBPeBoBZm2Rm0G6 p88ti7T6mkcRisPK5mqpdcz5GSQuEDeA0+XIG85cw6gJpIePNUctgVWdb kH4IqZloFgxkv3VSObP1DWaBzR1N33dl0VeoqK43pXZO2HlpIe9ISHCEJ waOj5SxjTHL1poH/Pey+ni06QO1plR0C++o+/AgvRyMGzadGX9it5Hyij qUolUKN+mZfTYg3xuc/RcPft7BInt1ehY8yeIrlVOYi22sGFGSncDE/iL q3JnaL84XeBpnv6QqgpDQ7KJPHqOH7fvJ0iLsNHT4qlb8jeYZABDK5r9D w==; IronPort-SDR: tkmUnsOcxxdvBt4adn7HB+XcqbAS1YBFqrVt/Hvn2wi4vKQ4TQJDUHeTTyA8SB4SeH2pSCgBZE VLD6SW53cYsuUCdAOOajwy4heJS4q+gMfH93BXNj8ZrRB/RZOKJuhCVnZRGdVbiE4UAujNIkiL uw/DjOnLag+RyszPjpA1CK/ejOxFTmWhwNKJICDHYmDfg/JuBiVapkhKrM/f2GFZve7BEHWsOs uEwbTx3vup0WWhbUvQRjXYldrru7i+2shXTllw7on5lSx0aXMWsE9nJ1Cebw3ICdnBaEL8HDDF ACTu80ZalhPBb5UAhBp70p/v X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533977" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:05 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:05 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:05 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 2/6] ntb_hw_switchtec: Fix bug with more than 32 partitions Date: Thu, 23 Dec 2021 17:23:30 -0800 Message-ID: <20211224012334.89173-3-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Wesley Sheng Switchtec could support as mush as 48 partitions, but ffs & fls are for 32 bit argument, in case of partition index larger than 31, the current code could not parse the peer partition index correctly. Change to the 64 bit version __ffs64 & fls64 accordingly to fix this bug. Fixes: 3df54c870f52 ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups") Signed-off-by: Wesley Sheng Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index 6603c77c0a84..ec9cb6c81eda 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -840,7 +840,6 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev) u64 tpart_vec; int self; u64 part_map; - int bit; sndev->ntb.pdev = sndev->stdev->pdev; sndev->ntb.topo = NTB_TOPO_SWITCH; @@ -861,29 +860,28 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev) part_map = ioread64(&sndev->mmio_ntb->ep_map); part_map &= ~(1 << sndev->self_partition); - if (!ffs(tpart_vec)) { + if (!tpart_vec) { if (sndev->stdev->partition_count != 2) { dev_err(&sndev->stdev->dev, "ntb target partition not defined\n"); return -ENODEV; } - bit = ffs(part_map); - if (!bit) { + if (!part_map) { dev_err(&sndev->stdev->dev, "peer partition is not NT partition\n"); return -ENODEV; } - sndev->peer_partition = bit - 1; + sndev->peer_partition = __ffs64(part_map); } else { - if (ffs(tpart_vec) != fls(tpart_vec)) { + if (__ffs64(tpart_vec) != (fls64(tpart_vec) - 1)) { dev_err(&sndev->stdev->dev, "ntb driver only supports 1 pair of 1-1 ntb mapping\n"); return -ENODEV; } - sndev->peer_partition = ffs(tpart_vec) - 1; + sndev->peer_partition = __ffs64(tpart_vec); if (!(part_map & (1ULL << sndev->peer_partition))) { dev_err(&sndev->stdev->dev, "ntb target partition is not NT partition\n"); From patchwork Fri Dec 24 01:23:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698731 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26BC7C433F5 for ; Fri, 24 Dec 2021 01:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350615AbhLXBZI (ORCPT ); Thu, 23 Dec 2021 20:25:08 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25905 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245480AbhLXBZH (ORCPT ); Thu, 23 Dec 2021 20:25:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309106; x=1671845106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mOv/6rLMt4SDkUiGk7Ojpht57PKBUSaOXxuqg25I/Y8=; b=Ip2ULqruoiifD3u5O739oWPACbDrykk6E6GEK+0K+2gNM5ejTdDIfdVZ mkIAwjWEA0yUOTJMK3KYTHKilfVPjJDfcF5OVuXNqRYYoAip9tIiiicIx 3zPbA76JSCg8i1K/CyKOu6HZJc0KcIe4WNv2hp0GBC3ydCkz9a80vYctS 5K3JJxSNJhILKBabjqU06N5mYg/pLqSFYzTUc1s5y5dvFPyykhkm61yJl YByhmzyoELas0mrf9QTK89o1afASXl6Spv3lD7fOFLqQWQrb+9KjWBwuy BARBe8HzuQbbYgMj0yitxXlV6bkgf9YamUPtRZwv9OIIbbQQSa9/3arMg Q==; IronPort-SDR: ysZDHzWD+HTWkk4QhHD+2AZiNDoz70cbZgLM00YzXL6zfE0W/Np5w+Fm2Blhg/igh/GXs5YknS vuekBw6nEkAf+H++NZjThqOxibeLCxnzrPFdfumrVUFDJrMNNE9zLMv1boIY0M6WkNwfrzYxqq pcDQGYAoIg0dvt//4Rc5G8+jLlCYk3eTBfFl35xF2zdS3c00IG9T97HfvNPsjxenz2goLPwo7G E8nBCf+M2RpV0yUJ3UQF0+Zo9PTa8aPrI5iDgBQhipXsu1Vc4ogqVQ9CVRhXW0Okpu81JC6WXG FFpf/Ci7ibqyvnJdy0E+9ZC1 X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533979" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:06 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:05 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:05 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 3/6] ntb_hw_switchtec: AND with the part_map for a valid tpart_vec Date: Thu, 23 Dec 2021 17:23:31 -0800 Message-ID: <20211224012334.89173-4-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jeremy Pallotta Some firmware versions return 1 in the target partition vector for undefined partitions. AND with the part_map to give a valid tpart_vec. Signed-off-by: Jeremy Pallotta Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index ec9cb6c81eda..25302a384a7d 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -858,6 +858,7 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev) tpart_vec |= ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_low); part_map = ioread64(&sndev->mmio_ntb->ep_map); + tpart_vec &= part_map; part_map &= ~(1 << sndev->self_partition); if (!tpart_vec) { From patchwork Fri Dec 24 01:23:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698732 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63E7BC433FE for ; Fri, 24 Dec 2021 01:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244989AbhLXBZK (ORCPT ); Thu, 23 Dec 2021 20:25:10 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25922 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350539AbhLXBZH (ORCPT ); Thu, 23 Dec 2021 20:25:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309107; x=1671845107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4sdPVIs9Jjw3pyvV0CLKiGsbnFQZVkRWh8tbvb+iRnc=; b=crbdQUHvWAI8cr+hpwSreG8h/yId1EPcpHzKSC6OpRrOtrRsu3BZxOFc 5Dj/QG1FZVSoQKVXD1vLTDaN5u5mmN4tMLkfENHuhpTmRnc3UVCugjuhP QYklOETNJ/l0Byfb5Ze/nlK2iIChVNgLsBpt/TTYyD++2mZAYXvo67Mqv qAKVeO3rpfr8N68dCXhZlRz0e9Mtud+BrnhAlXszZx9YSJlEo4eDUZdBa UdD5Wm/G00lfR58UXTp+QzZ2Z23fecHH0tJzsiLAb1capPHCBo/egnYUu AIrTeouH1wnghY0tmDKFkq7QbmIWNRJbb8IQmg0F+D/KWsFvXvvBDiNLa w==; IronPort-SDR: FQW/+CiLjkhFTMpKv8M6lhxcIk3BBZYBoUdh49L2V/A8xvkDc7QNRN2+MZVg4/krJI4VQD4ges Md+7wdDfLu/1jAsDtVxfJlt61i3xSJTsHpdUS7oDNUtvEZlk4LQSFdf0iOBOPw56auV7Nd1vy0 B8In17ZvJEdae0gMChY1E5s7sEavTb8T08pVOBLwtRZtQA3QRYp6FNguV88pnaHuBnL5+TPoDu tEefVHptu6wVkQeS5aLul9ftON7iGggF4QVSHLFbt+QvBEy4Buh8ne+H71x/U7iA3a8y25IDON 5axLB/e4mO88C7547szHl8GT X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533980" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:06 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:06 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:06 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 4/6] ntb_hw_switchtec: Update the way of getting VEP instance ID Date: Thu, 23 Dec 2021 17:23:32 -0800 Message-ID: <20211224012334.89173-5-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Gen4 firmware adds DMA VEP and NVMe VEP support in VEP (virtual EP) instance ID register in addtion to management EP. Update the way of getting management VEP instance ID. Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index 25302a384a7d..03839346233d 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -419,8 +419,10 @@ static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev, enum ntb_width *width) { struct switchtec_dev *stdev = sndev->stdev; - u32 pff = - ioread32(&stdev->mmio_part_cfg_all[partition].vep_pff_inst_id); + struct part_cfg_regs __iomem *part_cfg = + &stdev->mmio_part_cfg_all[partition]; + + u32 pff = ioread32(&part_cfg->vep_pff_inst_id) & 0xFF; u32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); if (speed) @@ -1089,7 +1091,7 @@ static int crosslink_enum_partition(struct switchtec_ntb *sndev, { struct part_cfg_regs __iomem *part_cfg = &sndev->stdev->mmio_part_cfg_all[sndev->peer_partition]; - u32 pff = ioread32(&part_cfg->vep_pff_inst_id); + u32 pff = ioread32(&part_cfg->vep_pff_inst_id) & 0xFF; struct pff_csr_regs __iomem *mmio_pff = &sndev->stdev->mmio_pff_csr[pff]; const u64 bar_space = 0x1000000000LL; From patchwork Fri Dec 24 01:23:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698733 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF3BC433F5 for ; Fri, 24 Dec 2021 01:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245155AbhLXBZM (ORCPT ); Thu, 23 Dec 2021 20:25:12 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25932 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350639AbhLXBZJ (ORCPT ); Thu, 23 Dec 2021 20:25:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309108; x=1671845108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YIzE0HtGM6R96JVAkcrysKpawVgajkkhJymCUIKulUI=; b=udiZObvgL1RoQGzQYgNB+AYy9HbtvzmBtXAOn5RaEJ6e8G9Ck4BIk9FK 6Zk4TeAwmmH4S8jiB+1Sx2G4odq4KeOQLjNOKOPUn7xw322O90ATtw9rw K0hvjvz8mxTG9Kil7uG+BwGUEFPmtXVYUyQTQJ/9FLmDrABETd9h2nQ/n ofdgZfA0MrXLnqJNKKZ3VZGVuvWfKomebsrfkKIb+KkTE46xq0VXG2SrK 7/zVrxQRR8eDIYrQxV0thVGrXOp/JZPM8CITYt4GQslMp7zBvV+C9Aghp s2wwG0k+CByLzm+HTlHq4quJVvshJZJsCenbkAUSS2BJybC6JI89uc8xT w==; IronPort-SDR: /qOZHSO6+L+Ze6LNxU3rUbzPVR+YCm43gAOUhb4+Ua65RzkMCdcHFRAXzbVSV99+pnGtTEDy4U pdw0KJkXTGBy+4f2S3VCTUrLuroT/MQMaiK3XZbUGiC1/NJzzUlyGUImz4CxddCzBWycGSQQDY KhHa78G2YasjcjKpAEXF0yL4UPtmPkm2XFmACc4XaBJ9MrPA7K11e5Hjm0eBeU7U9DBMiAXjH8 sdnJXqP3i/Gt0ggc3QZkpEgTwNDr2BLSv3BQMFdWzXI644YjATLXDch9vYghIvOdt97EoaKw8S aBborne7IlXrYupAC7cTDMRa X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533988" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:08 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:07 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:06 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 5/6] ntb_hw_switchtec: Remove code for disabling ID protection Date: Thu, 23 Dec 2021 17:23:33 -0800 Message-ID: <20211224012334.89173-6-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org ID protection is a firmware setting for NT window access control. With it enabled, only the posted requests with requester IDs in the requester ID table will be allowed to access the NT windows. Otherwise all posted requests are allowed. Normally user will configure it statically via the Switchtec config file, and it will take effect when the firmware boots up. The driver can also toggle the ID protection setting dynamically, which will overwrite the static setting in the Switchtec config file as a side effect. Currently, the driver disables the ID protection. However, it's not necessary to disable the ID protection at the driver level as the driver has already configured the proper requester IDs in the requester ID table to allow the corresponding posted requests to hit the NT windows. Remove the code that disables the ID protection to make the static setting prevail. Note: ID protection is not applicable to non-posted requests. Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 3 --- include/linux/switchtec.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index 03839346233d..0e33eef64ec6 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -967,9 +967,6 @@ static int config_req_id_table(struct switchtec_ntb *sndev, if (rc) return rc; - iowrite32(NTB_PART_CTRL_ID_PROT_DIS, - &mmio_ctrl->partition_ctrl); - for (i = 0; i < count; i++) { iowrite32(req_ids[i] << 16 | NTB_CTRL_REQ_ID_EN, &mmio_ctrl->req_id_table[i]); diff --git a/include/linux/switchtec.h b/include/linux/switchtec.h index be24056ac00f..48fabe36509e 100644 --- a/include/linux/switchtec.h +++ b/include/linux/switchtec.h @@ -337,8 +337,6 @@ enum { NTB_CTRL_REQ_ID_EN = 1 << 0, NTB_CTRL_LUT_EN = 1 << 0, - - NTB_PART_CTRL_ID_PROT_DIS = 1 << 0, }; struct ntb_ctrl_regs { From patchwork Fri Dec 24 01:23:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Cao X-Patchwork-Id: 12698734 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C251C433EF for ; Fri, 24 Dec 2021 01:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350708AbhLXBZN (ORCPT ); Thu, 23 Dec 2021 20:25:13 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:25932 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350649AbhLXBZK (ORCPT ); Thu, 23 Dec 2021 20:25:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1640309109; x=1671845109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wu5IURmBwZeW3y4oSE+nzpn5LdHJ/yuuFONebUzH3pY=; b=kjpUkkqfeIxRw4ZGpFji0DdbibsBhi3IlsdiGaB9nEyNdbbUNuumORnU GQXakSkPXxlZH7yhVvahyle1iGWfw5Q/GiItrBv08JZn9Br15f3w1eumS OS8BTiSR1HA8Yd1gqHni8o19lgzw3zkLdXzXby2mSrFGu/PsgTiKlO7zh 7rIBF6XeAB2QllsWjBCRmdB/P4c/uBaN87HpS/bT9urr1yM/TOWL6DcMo iFIqtKXRwQ7AgPZgU3ToCQVlmW63RVe5seo8vyTX9WRyMBup/g3s8e3u+ bX4GIr9iU1a5w8g93Tq4J0NQ53HJvHxaN+eEcre9XkG+5hPIg/beWkuzU Q==; IronPort-SDR: E/zcbyMnMFuwNuUq0taYrhkGjjVLQ1MBCYrKzui2gwba1TRoQbpqMLfXujojIgC3LnNpnZB5Op sPYR8XydPIt5jp+0T5RHCqXhRKqNWcj89xYrOznzk/Z1BkCmkzcaiGl+l1L97DnUKPlScoWA4m O6y5/8XL3k49/okNGo3wx+qVwIpVQ4mqqjsWGc9cUUVEALodqwDZNggSNxuTGOOr/3H0WanmHz BS1RihxjQ5NdC4L2bBJOb/p+7KfCqQUpanhIQts2HvvwZ1QakvbDkFvyHPSo0POJwIK6bLq42D lDvaK3+BqsCn4XXMHIZvWsRz X-IronPort-AV: E=Sophos;i="5.88,231,1635231600"; d="scan'208";a="80533989" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Dec 2021 18:25:08 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 18:25:07 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 23 Dec 2021 18:25:07 -0700 From: Kelvin Cao To: Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , , , CC: Kelvin Cao , , "Jeremy Pallotta" Subject: [PATCH 6/6] ntb_hw_switchtec: Fix a minor issue in config_req_id_table() Date: Thu, 23 Dec 2021 17:23:34 -0800 Message-ID: <20211224012334.89173-7-kelvin.cao@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224012334.89173-1-kelvin.cao@microchip.com> References: <20211224012334.89173-1-kelvin.cao@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The req_id_table_size field is 16-bit wide, use ioread16() to read the value. Signed-off-by: Kelvin Cao --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index 0e33eef64ec6..189faad0d0d5 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -955,7 +955,7 @@ static int config_req_id_table(struct switchtec_ntb *sndev, u32 error; u32 proxy_id; - if (ioread32(&mmio_ctrl->req_id_table_size) < count) { + if (ioread16(&mmio_ctrl->req_id_table_size) < count) { dev_err(&sndev->stdev->dev, "Not enough requester IDs available.\n"); return -EFAULT;