linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Jack Morgenstein <jackm@dev.mellanox.co.il>,
	Leon Romanovsky <leon@kernel.org>,
	Doug Ledford <dledford@redhat.com>
Subject: [PATCH 4.4 80/93] IB/mlx4: Use correct subnet-prefix in QP1 mads under SR-IOV
Date: Thu,  6 Oct 2016 10:29:50 +0200	[thread overview]
Message-ID: <20161006074735.295793205@linuxfoundation.org> (raw)
In-Reply-To: <20161006074731.150212126@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

commit 8ec07bf8a8b57d6c58927a16a0a22c0115cf2855 upstream.

When sending QP1 MAD packets which use a GRH, the source GID
(which consists of the 64-bit subnet prefix, and the 64 bit port GUID)
must be included in the packet GRH.

For SR-IOV, a GID cache is used, since the source GID needs to be the
slave's source GID, and not the Hypervisor's GID. This cache also
included a subnet_prefix. Unfortunately, the subnet_prefix field in
the cache was never initialized (to the default subnet prefix 0xfe80::0).
As a result, this field remained all zeroes.  Therefore, when SR-IOV
was active, all QP1 packets which included a GRH had a source GID
subnet prefix of all-zeroes.

However, the subnet-prefix should initially be 0xfe80::0 (the default
subnet prefix). In addition, if OpenSM modifies a port's subnet prefix,
the new subnet prefix must be used in the GRH when sending QP1 packets.
To fix this we now initialize the subnet prefix in the SR-IOV GID cache
to the default subnet prefix. We update the cached value if/when OpenSM
modifies the port's subnet prefix. We take this cached value when sending
QP1 packets when SR-IOV is active.

Note that the value is stored as an atomic64. This eliminates any need
for locking when the subnet prefix is being updated.

Note also that we depend on the FW generating the "port management change"
event for tracking subnet-prefix changes performed by OpenSM. If running
early FW (before 2.9.4630), subnet prefix changes will not be tracked (but
the default subnet prefix still will be stored in the cache; therefore
users who do not modify the subnet prefix will not have a problem).
IF there is a need for such tracking also for early FW, we will add that
capability in a subsequent patch.

Fixes: 1ffeb2eb8be9 ("IB/mlx4: SR-IOV IB context objects and proxy/tunnel SQP support")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/infiniband/hw/mlx4/mad.c     |   23 +++++++++++++++++++++++
 drivers/infiniband/hw/mlx4/mlx4_ib.h |    2 +-
 drivers/infiniband/hw/mlx4/qp.c      |    5 +++--
 3 files changed, 27 insertions(+), 3 deletions(-)

--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1080,6 +1080,27 @@ void handle_port_mgmt_change_event(struc
 
 		/* Generate GUID changed event */
 		if (changed_attr & MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK) {
+			if (mlx4_is_master(dev->dev)) {
+				union ib_gid gid;
+				int err = 0;
+
+				if (!eqe->event.port_mgmt_change.params.port_info.gid_prefix)
+					err = __mlx4_ib_query_gid(&dev->ib_dev, port, 0, &gid, 1);
+				else
+					gid.global.subnet_prefix =
+						eqe->event.port_mgmt_change.params.port_info.gid_prefix;
+				if (err) {
+					pr_warn("Could not change QP1 subnet prefix for port %d: query_gid error (%d)\n",
+						port, err);
+				} else {
+					pr_debug("Changing QP1 subnet prefix for port %d. old=0x%llx. new=0x%llx\n",
+						 port,
+						 (u64)atomic64_read(&dev->sriov.demux[port - 1].subnet_prefix),
+						 be64_to_cpu(gid.global.subnet_prefix));
+					atomic64_set(&dev->sriov.demux[port - 1].subnet_prefix,
+						     be64_to_cpu(gid.global.subnet_prefix));
+				}
+			}
 			mlx4_ib_dispatch_event(dev, port, IB_EVENT_GID_CHANGE);
 			/*if master, notify all slaves*/
 			if (mlx4_is_master(dev->dev))
@@ -2154,6 +2175,8 @@ int mlx4_ib_init_sriov(struct mlx4_ib_de
 		if (err)
 			goto demux_err;
 		dev->sriov.demux[i].guid_cache[0] = gid.global.interface_id;
+		atomic64_set(&dev->sriov.demux[i].subnet_prefix,
+			     be64_to_cpu(gid.global.subnet_prefix));
 		err = alloc_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1,
 				      &dev->sriov.sqps[i]);
 		if (err)
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -441,7 +441,7 @@ struct mlx4_ib_demux_ctx {
 	struct workqueue_struct *wq;
 	struct workqueue_struct *ud_wq;
 	spinlock_t ud_lock;
-	__be64 subnet_prefix;
+	atomic64_t subnet_prefix;
 	__be64 guid_cache[128];
 	struct mlx4_ib_dev *dev;
 	/* the following lock protects both mcg_table and mcg_mgid0_list */
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -2340,8 +2340,9 @@ static int build_mlx_header(struct mlx4_
 				 * we must use our own cache
 				 */
 				sqp->ud_header.grh.source_gid.global.subnet_prefix =
-					to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
-							       subnet_prefix;
+					cpu_to_be64(atomic64_read(&(to_mdev(ib_dev)->sriov.
+								    demux[sqp->qp.port - 1].
+								    subnet_prefix)));
 				sqp->ud_header.grh.source_gid.global.interface_id =
 					to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
 						       guid_cache[ah->av.ib.gid_index];

  parent reply	other threads:[~2016-10-06  9:02 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161006085617uscas1p138247ef1e0fc1f67a8925f522d0aed06@uscas1p1.samsung.com>
2016-10-06  8:28 ` [PATCH 4.4 00/93] 4.4.24-stable review Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 01/93] cpuset: handle race between CPU hotplug and cpuset_hotplug_work Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 02/93] mtd: nand: davinci: Reinitialize the HW ECC engine in 4bit hwctl Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 03/93] mm,ksm: fix endless looping in allocating memory when ksm enable Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 04/93] can: dev: fix deadlock reported after bus-off Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 05/93] x86/init: Fix cr4_init_shadow() on CR4-less machines Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 06/93] x86/boot: Initialize FPU and X86_FEATURE_ALWAYS even if we dont have CPUID Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 07/93] drm/nouveau/fifo/nv04: avoid ramht race against cookie insertion Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 08/93] drm/radeon/si/dpm: add workaround for for Jet parts Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 09/93] ARM: 8616/1: dt: Respect property size when parsing CPUs Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 10/93] ARM: 8617/1: dma: fix dma_max_pfn() Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 11/93] usb: musb: Fix DMA desired mode for Mentor DMA engine Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 12/93] usb: musb: fix DMA for host mode Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 13/93] iwlwifi: mvm: fix a few firmware capability checks Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 14/93] perf/core: Fix pmu::filter_match for SW-led groups Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 15/93] i40e: avoid null pointer dereference Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 16/93] pinctrl: uniphier: fix .pin_dbg_show() callback Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 17/93] pinctrl: Flag strict is a field in struct pinmux_ops Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 18/93] drivers/perf: arm_pmu: Fix leak in error path Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 19/93] mmc: pxamci: fix potential oops Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 20/93] tools/vm/slabinfo: fix an unintentional printf Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 21/93] ipvs: fix bind to link-local mcast IPv6 address in backup Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 22/93] nvmem: Declare nvmem_cell_read() consistently Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 23/93] hwmon: (adt7411) set bit 3 in CFG1 register Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 24/93] spi: sh-msiof: Avoid invalid clock generator parameters Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 25/93] iwlwifi: pcie: fix access to scratch buffer Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 26/93] iwlwifi: mvm: dont use ret when not initialised Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 27/93] ceph: fix race during filling readdir cache Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 28/93] usb: gadget: fsl_qe_udc: signedness bug in qe_get_frame() Greg Kroah-Hartman
2016-10-06  8:28   ` [PATCH 4.4 29/93] gpio: sa1100: fix irq probing for ucb1x00 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 30/93] irqchip/gicv3: Silence noisy DEBUG_PER_CPU_MAPS warning Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 31/93] ARM: 8618/1: decompressor: reset ttbcr fields to use TTBR0 on ARMv7 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 32/93] arm64: debug: avoid resetting stepping state machine when TIF_SINGLESTEP Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 33/93] MIPS: uprobes: remove incorrect set_orig_insn Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 34/93] MIPS: fix uretprobe implementation Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 35/93] MIPS: Malta: Fix IOCU disable switch read for MIPS64 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 36/93] MIPS: uprobes: fix use of uninitialised variable Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 37/93] printk: fix parsing of "brl=" option Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 38/93] tpm: fix byte-order for the value read by tpm2_get_tpm_pt Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 39/93] regulator: qcom_spmi: Add support for S4 supply on pm8941 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 40/93] regulator: qcom_spmi: Add support for get_mode/set_mode on switches Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 41/93] regulator: qcom_spmi: Update mvs1/mvs2 switches on pm8941 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 42/93] regulator: qcom_smd: Fix voltage ranges for pm8x41 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 44/93] ARM: sa1100: register clocks early Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 45/93] ARM: sa1100: fix 3.6864MHz clock Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 46/93] ARM: sa1100: clear reset status prior to reboot Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 47/93] ARM: shmobile: fix regulator quirk for Gen2 Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 48/93] ARM: sa1111: fix pcmcia suspend/resume Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 49/93] hwrng: omap - Fix assumption that runtime_get_sync will always succeed Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 50/93] blk-mq: actually hook up defer list when running requests Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 51/93] pstore: drop file opened reference count Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 52/93] tile: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 53/93] iwlmvm: mvm: set correct state in smart-fifo configuration Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 55/93] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 56/93] [media] gspca: avoid unused variable warnings Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 57/93] ath9k: Fix programming of minCCA power threshold Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 58/93] avr32: off by one in at32_init_pio() Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 59/93] fnic: pci_dma_mapping_error() doesnt return an error code Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 60/93] dmaengine: at_xdmac: fix debug string Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 61/93] svc: Avoid garbage replies when pc_func() returns rpc_drop_reply Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 62/93] NFS: Dont drop CB requests with invalid principals Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 63/93] pNFS/files: Fix layoutcommit after a commit to DS Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 64/93] pNFS/flexfiles: " Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 65/93] ASoC: Intel: Skylake: Fix error return code in skl_probe() Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 66/93] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 67/93] brcmsmac: Free packet if dma_mapping_error() fails in dma_rxfill Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 68/93] brcmsmac: Initialize power in brcms_c_stf_ss_algo_channel_get() Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 69/93] powerpc/prom: Fix sub-processor option passed to ibm, client-architecture-support Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 70/93] sysctl: handle error writing UINT_MAX to u32 fields Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 71/93] ASoC: omap-mcpdm: Fix irq resource handling Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 72/93] kernel/fork: fix CLONE_CHILD_CLEARTID regression in nscd Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 73/93] dmaengine: at_xdmac: fix to pass correct device identity to free_irq() Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 75/93] IB/ipoib: Fix memory corruption in ipoib cm mode connect flow Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 76/93] IB/core: Fix use after free in send_leave function Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 77/93] IB/ipoib: Dont allow MC joins during light MC flush Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 78/93] IB/mlx4: Fix incorrect MC join state bit-masking on SR-IOV Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 79/93] IB/mlx4: Fix code indentation in QP1 MAD flow Greg Kroah-Hartman
2016-10-06  8:29   ` Greg Kroah-Hartman [this message]
2016-10-06  8:29   ` [PATCH 4.4 82/93] aio: mark AIO pseudo-fs noexec Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 83/93] clk: xgene: Add missing parenthesis when clearing divider value Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 84/93] dm log writes: fix bug with too large bios Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 85/93] USB: serial: cp210x: fix hardware flow-control disable Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 86/93] usb: misc: legousbtower: Fix NULL pointer deference Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 87/93] Staging: fbtft: Fix bug in fbtft-core Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 88/93] USB: serial: cp210x: Add ID for a Juniper console Greg Kroah-Hartman
2016-10-06  8:29   ` [PATCH 4.4 89/93] Revert "usbtmc: convert to devm_kzalloc" Greg Kroah-Hartman
2016-10-06  8:30   ` [PATCH 4.4 90/93] ALSA: hda - Adding one more ALC255 pin definition for headset problem Greg Kroah-Hartman
2016-10-06  8:30   ` [PATCH 4.4 91/93] ACPICA: acpi_get_sleep_type_data: Reduce warnings Greg Kroah-Hartman
2016-10-06  8:30   ` [PATCH 4.4 92/93] ALSA: hda - Fix headset mic detection problem for several Dell laptops Greg Kroah-Hartman
2016-10-06  8:30   ` [PATCH 4.4 93/93] ALSA: hda - Add the top speaker pin config for HP Spectre x360 Greg Kroah-Hartman
2016-10-06 18:42   ` [PATCH 4.4 00/93] 4.4.24-stable review Guenter Roeck
2016-10-06 19:58   ` Shuah Khan
     [not found]   ` <57f7819c.d4301c0a.965e6.cd11@mx.google.com>
2016-10-07 13:02     ` Greg Kroah-Hartman
2016-10-08  9:53       ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161006074735.295793205@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dledford@redhat.com \
    --cc=jackm@dev.mellanox.co.il \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).