Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright(c) 2015, 2016 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * This file is provided under a dual BSD/GPLv2 license.  When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  - Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *    notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  - Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *    notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *    the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *    distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *  - Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *    contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *    from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <linux/bitmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include "hfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #include "sdma.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define LINK_UP_DELAY  500  /* in microseconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static void set_mgmt_allowed(struct hfi1_pportdata *ppd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u32 frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (ppd->neighbor_type == NEIGHBOR_TYPE_HFI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		ppd->mgmt_allowed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		read_8051_config(dd, REMOTE_LNI_INFO, GENERAL_CONFIG, &frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		ppd->mgmt_allowed = (frame >> MGMT_ALLOWED_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		& MGMT_ALLOWED_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * Our neighbor has indicated that we are allowed to act as a fabric
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * manager, so place the full management partition key in the second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * (0-based) pkey array position. Note that we should already have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * the limited management partition key in array element 1, and also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * that the port is not yet up when add_full_mgmt_pkey() is invoked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static void add_full_mgmt_pkey(struct hfi1_pportdata *ppd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	/* Sanity check - ppd->pkeys[2] should be 0, or already initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			    __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	ppd->pkeys[2] = FULL_MGMT_P_KEY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	(void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	hfi1_event_pkey_change(ppd->dd, ppd->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * format_hwmsg - format a single hwerror message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * @msg message buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * @msgl length of message buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * @hwmsg message to add to message buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static void format_hwmsg(char *msg, size_t msgl, const char *hwmsg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	strlcat(msg, "[", msgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	strlcat(msg, hwmsg, msgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	strlcat(msg, "]", msgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * hfi1_format_hwerrors - format hardware error messages for display
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @hwerrs hardware errors bit vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * @hwerrmsgs hardware error descriptions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * @nhwerrmsgs number of hwerrmsgs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * @msg message buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * @msgl message buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void hfi1_format_hwerrors(u64 hwerrs, const struct hfi1_hwerror_msgs *hwerrmsgs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			  size_t nhwerrmsgs, char *msg, size_t msgl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	for (i = 0; i < nhwerrmsgs; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (hwerrs & hwerrmsgs[i].mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			format_hwmsg(msg, msgl, hwerrmsgs[i].msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static void signal_ib_event(struct hfi1_pportdata *ppd, enum ib_event_type ev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct ib_event event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * Only call ib_dispatch_event() if the IB device has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 * registered.  HFI1_INITED is set iff the driver has successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 * registered with the IB core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (!(dd->flags & HFI1_INITTED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	event.device = &dd->verbs_dev.rdi.ibdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	event.element.port_num = ppd->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	event.event = ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	ib_dispatch_event(&event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * handle_linkup_change - finish linkup/down state changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * @dd: valid device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * @linkup: link state information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * Handle a linkup or link down notification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * The HW needs time to finish its link up state change. Give it that chance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * This is called outside an interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) void handle_linkup_change(struct hfi1_devdata *dd, u32 linkup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct hfi1_pportdata *ppd = &dd->pport[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	enum ib_event_type ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (!(ppd->linkup ^ !!linkup))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		return;	/* no change, nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	if (linkup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		 * Quick linkup and all link up on the simulator does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		 * trigger or implement:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		 *	- VerifyCap interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		 *	- VerifyCap frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		 * But rather moves directly to LinkUp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		 * Do the work of the VerifyCap interrupt handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		 * handle_verify_cap(), but do not try moving the state to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		 * LinkUp as we are already there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		 * NOTE: This uses this device's vAU, vCU, and vl15_init for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		 * the remote values.  Both sides must be using the values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		if (quick_linkup || dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			set_up_vau(dd, dd->vau);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			set_up_vl15(dd, dd->vl15_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			assign_remote_cm_au_table(dd, dd->vcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		ppd->neighbor_guid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		ppd->neighbor_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				 DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		ppd->neighbor_port_number =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		ppd->neighbor_fm_security =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 				 DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		dd_dev_info(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			    "Neighbor Guid %llx, Type %d, Port Num %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			    ppd->neighbor_guid, ppd->neighbor_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			    ppd->neighbor_port_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		/* HW needs LINK_UP_DELAY to settle, give it that chance */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		udelay(LINK_UP_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		 * 'MgmtAllowed' information, which is exchanged during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		 * LNI, is available at this point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		set_mgmt_allowed(ppd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		if (ppd->mgmt_allowed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			add_full_mgmt_pkey(ppd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		/* physical link went up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		ppd->linkup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		ppd->offline_disabled_reason =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		/* link widths are not available until the link is fully up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		get_linkup_link_widths(ppd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		/* physical link went down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		ppd->linkup = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		/* clear HW details of the previous connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		ppd->actual_vls_operational = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		reset_link_credits(dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		/* freeze after a link down to guarantee a clean egress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		start_freeze_handling(ppd, FREEZE_SELF | FREEZE_LINK_DOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		ev = IB_EVENT_PORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		hfi1_set_uevent_bits(ppd, _HFI1_EVENT_LINKDOWN_BIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		/* if we are down, the neighbor is down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		ppd->neighbor_normal = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		/* notify IB of the link change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		signal_ib_event(ppd, ev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * Handle receive or urgent interrupts for user contexts.  This means a user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * process was waiting for a packet to arrive, and didn't want to poll.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void handle_user_interrupt(struct hfi1_ctxtdata *rcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	struct hfi1_devdata *dd = rcd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	spin_lock_irqsave(&dd->uctxt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	if (bitmap_empty(rcd->in_use_ctxts, HFI1_MAX_SHARED_CTXTS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (test_and_clear_bit(HFI1_CTXT_WAITING_RCV, &rcd->event_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		wake_up_interruptible(&rcd->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		hfi1_rcvctrl(dd, HFI1_RCVCTRL_INTRAVAIL_DIS, rcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	} else if (test_and_clear_bit(HFI1_CTXT_WAITING_URG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 							&rcd->event_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		rcd->urgent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		wake_up_interruptible(&rcd->wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	spin_unlock_irqrestore(&dd->uctxt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }