staging/rdma/hfi1: set Gen3 half-swing for integrated devices
Subsystems (2)
PATCH v2 1/1 staging/rdma/hfi1: set Gen3 half-swing for integrated devices
From: Dean Luick <[email protected]>
Correctly set half-swing for integrated devices. A0 needs all fields set for CcePcieCtrl. B0 and later only need a few fields set.
---
Changes from V1:
Add comments concerning the very long names.
drivers/staging/rdma/hfi1/chip_registers.h | 16 +++++++ drivers/staging/rdma/hfi1/pcie.c | 77 ++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 4 deletions(-)
drivers/staging/rdma/hfi1/chip_registers.h +16 -0
@@ -51,6 +51,11 @@* */ +/* +* NOTE: The names in this file are very long but they are meant to track the +* hardware specification names. +*/ +#define CORE 0x000000000000#define CCE (CORE + 0x000000000000)#define ASIC (CORE + 0x000000400000)
@@ -549,6 +554,17 @@#define CCE_MSIX_TABLE_UPPER (CCE + 0x000000100008)#define CCE_MSIX_TABLE_UPPER_RESETCSR 0x0000000100000000ull#define CCE_MSIX_VEC_CLR_WITHOUT_INT (CCE + 0x000000110400) +#define CCE_PCIE_CTRL (CCE + 0x0000000000C0) +#define CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_MASK 0x3ull +#define CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_SHIFT 0 +#define CCE_PCIE_CTRL_PCIE_LANE_DELAY_MASK 0xFull +#define CCE_PCIE_CTRL_PCIE_LANE_DELAY_SHIFT 2 +#define CCE_PCIE_CTRL_XMT_MARGIN_OVERWRITE_ENABLE_SHIFT 8 +#define CCE_PCIE_CTRL_XMT_MARGIN_SHIFT 9 +#define CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_MASK 0x1ull +#define CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_SHIFT 12 +#define CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_MASK 0x7ull +#define CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_SHIFT 13#define CCE_REVISION (CCE + 0x000000000000)#define CCE_REVISION2 (CCE + 0x000000000008)#define CCE_REVISION2_HFI_ID_MASK 0x1ull
drivers/staging/rdma/hfi1/pcie.c +73 -4
90 lines not on this page · raw message
Signature · 6 lines
1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Gar... No. Please please get rid of the PC() macro. It makes the code impossible to understand because instead of hitting CTRL-[ you have decode it and then manually type out
:cs find g CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_SHIFT
which is the length of a typical college essay. I meant just put a comment like this:
/*
* In the hardware spec these are prefixed with:
* CCE_PCIE_CTRL_...
* But it is too long to use in code.
*/
#define XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_MASK 0x1ull
Or probably even better:
#define CCE_PCIE_CTRL (CCE + 0x0000000000C0)
#define LANE_BUNDLE_MASK 0x3ull /* CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_MASK */
#define LANE_BUNDLE_SHIFT 0 /* CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_SHIFT */
#define LANE_DELAY_MASK 0xFull /* CCE_PCIE_CTRL_PCIE_LANE_DELAY_MASK */
#define LANE_DELAY_SHIFT 2 /* CCE_PCIE_CTRL_PCIE_LANE_DELAY_SHIFT */
#define MARGIN_OVERWRITE_SHIFT 8 /* CCE_PCIE_CTRL_XMT_MARGIN_OVERWRITE_ENABLE_SHIFT */
#define MARGIN_SHIFT 9 /* CCE_PCIE_CTRL_XMT_MARGIN_SHIFT */
#define MARGIN_G1G2_OVERWRITE_MASK 0x1ull /* CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_MASK */
#define MARGIN_G1G2_OVERWRITE_SHIFT 12 /* CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_SHIFT */
#define MARGIN_G1G2_MASK 0x7ull /* CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_MASK */
#define MARGIN_G1G2_SHIFT 13 /* CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_SHIFT */
Those lines go over the 80 character limit but it's fine.
regards,
dan carpenter
Quoted 30 lines · Dan Carpenter
Gar... No. Please please get rid of the
PC()macro. It makes the code impossible to understand because instead of hitting CTRL-[ you have decode it and then manually type out:cs find g
CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_SHIFTwhich is the length of a typical college essay. I meant just put a comment like this:
/*
* In the hardware spec these are prefixed with:
*CCE_PCIE_CTRL_...
* But it is too long to use in code.
*/
#defineXMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_MASK0x1ullOr probably even better:
#define
CCE_PCIE_CTRL(CCE +0x0000000000C0)
#defineLANE_BUNDLE_MASK0x3ull/*CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_MASK*/
#defineLANE_BUNDLE_SHIFT0 /*CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_SHIFT*/
#defineLANE_DELAY_MASK0xFull/*CCE_PCIE_CTRL_PCIE_LANE_DELAY_MASK*/
#defineLANE_DELAY_SHIFT2 /*CCE_PCIE_CTRL_PCIE_LANE_DELAY_SHIFT*/
#defineMARGIN_OVERWRITE_SHIFT8 /*CCE_PCIE_CTRL_XMT_MARGIN_OVERWRITE_ENABLE_SHIFT*/
#defineMARGIN_SHIFT9 /*CCE_PCIE_CTRL_XMT_MARGIN_SHIFT*/
#defineMARGIN_G1G2_OVERWRITE_MASK0x1ull/*CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_MASK*/
#defineMARGIN_G1G2_OVERWRITE_SHIFT12 /*CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_OVERWRITE_ENABLE_SHIFT*/
#defineMARGIN_G1G2_MASK0x7ull/*CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_MASK*/
#defineMARGIN_G1G2_SHIFT13 /*CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_SHIFT*/
Quoted 1 line
Those lines go over the 80 character limit but it's fine.
My apologies for not understanding what you meant. I took your meaning to be that we had to honor the checkpatch checks so while the PC macro was undesirable it was ok if I just made some comments...
FWIW I don't like the PC macro either. But we have a tool which is generating these names to be identical to the hardware spec. And we really want to preserve those as a reference back to the spec. Creating additional names which are in the code is a bit cumbersome but what if we do something like this:
<auto generated from spec>
...
#define CCE_PCIE_CTRL (CCE + 0x0000000000C0) #define CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_MASK 0x3ull #define CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_SHIFT 0
...
<Defined for use in the code>
#define LANE_BUNDLE_MASK CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_MASK
#define LANE_BUNDLE_SHIFT CCE_PCIE_CTRL_PCIE_LANE_BUNDLE_SHIFT
...
?????
An alternative would be to define some helper functions such as:
static inline u64 extract_xmt_margin_g1g2(u64 reg)
{
return (reg >> CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_SHIFT)
& CCE_PCIE_CTRL_XMT_MARGIN_GEN1_GEN2_MASK;
}...
...
xmt_margin = extract_xmt_margin_g1g2(pcie_ctrl);
...
I prefer the second option as it preserves the register names right in the code. So you can reference the hardware spec without looking anything up in a header file.
I again apologize for misunderstanding your previous meaning.
Ira
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
That's fine. I feel like the first option is better because those long names really are cumbersome. I sometimes cut and paste bugs caused by using really long names because it's hard to spot the differences between two really long names which are 80% the same filler text. (I'm using a static checker so the checker finds the bugs and I have to stare at it for a very long time to spot the characters which are different).
regards,
dan carpenter