diff for duplicates of <000201d2f103$2f3d2d20$8db78760$@dell.com> diff --git a/a/1.txt b/N1/1.txt index 5236134..cd3bc8b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -2,32 +2,29 @@ From: Logan Gunthorpe > switchtec_ntb checks for a link by looking at the shared memory > window. If the magic number is correct and the otherside indicates > their link is enabled then we take the link to be up. ->=20 +> > Whenever we change our local link status we send a msg to the > otherside to check whether it's up and change their status. ->=20 +> > The current status is maintained in a flag so ntb_is_link_up > can return quickly. ->=20 +> > We utilize switchtec's link status notifier to also check link changes > when the switch notices a port changes state. ->=20 +> > Signed-off-by: Logan Gunthorpe <logang@deltatee.com> > Reviewed-by: Stephen Bates <sbates@raithlin.com> > Reviewed-by: Kurt Schwemmer <kurt.schwemmer@microsemi.com> > --- -> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 = -+++++++++++++++++++++++++++++++++++- +> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 +++++++++++++++++++++++++++++++++++- > 1 file changed, 129 insertions(+), 1 deletion(-) ->=20 -> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c = -b/drivers/ntb/hw/mscc/switchtec_ntb.c +> +> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c b/drivers/ntb/hw/mscc/switchtec_ntb.c > index 0587b2380bcc..8ef84d45bda6 100644 > --- a/drivers/ntb/hw/mscc/switchtec_ntb.c > +++ b/drivers/ntb/hw/mscc/switchtec_ntb.c -> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem = -*mmio) ->=20 +> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem *mmio) +> > struct shared_mw { > u32 magic; > + u32 link_sta; @@ -43,7 +40,7 @@ b/drivers/ntb/hw/mscc/switchtec_ntb.c > + enum ntb_speed link_speed; > + enum ntb_width link_width; > }; ->=20 +> > +static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb) > +{ > + return container_of(ntb, struct switchtec_ntb, ntb); @@ -52,16 +49,14 @@ b/drivers/ntb/hw/mscc/switchtec_ntb.c > static int switchtec_ntb_part_op(struct switchtec_ntb *sndev, > struct ntb_ctrl_regs __iomem *ctl, > u32 op, int wait_status) -> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct = -switchtec_ntb *sndev, +> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct switchtec_ntb *sndev, > return -EIO; > } ->=20 -> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int = -idx, +> +> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int idx, > + u32 val) > +{ -> + if (idx < 0 || idx >=3D ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg)) +> + if (idx < 0 || idx >= ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg)) > + return -EINVAL; > + > + iowrite32(val, &sndev->mmio_self_dbmsg->omsg[idx].msg); @@ -72,29 +67,25 @@ idx, > static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx) > { > return 0; -> @@ -192,22 +213,124 @@ static int = -switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx, +> @@ -192,22 +213,124 @@ static int switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx, > return 0; > } ->=20 -> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb = -*sndev, +> +> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev, > + int partition, > + enum ntb_speed *speed, > + enum ntb_width *width) > +{ -> + struct switchtec_dev *stdev =3D sndev->stdev; +> + struct switchtec_dev *stdev = sndev->stdev; > + -> + u32 pff =3D = -ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); -> + u32 linksta =3D = -ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); +> + u32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); +> + u32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + > + if (speed) -> + *speed =3D (linksta >> 16) & 0xF; +> + *speed = (linksta >> 16) & 0xF; > + > + if (width) -> + *width =3D (linksta >> 20) & 0x3F; +> + *width = (linksta >> 20) & 0x3F; > +} > + > +static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev) @@ -103,8 +94,8 @@ ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + enum ntb_width self_width, peer_width; > + > + if (!sndev->link_is_up) { -> + sndev->link_speed =3D NTB_SPEED_NONE; -> + sndev->link_width =3D NTB_WIDTH_NONE; +> + sndev->link_speed = NTB_SPEED_NONE; +> + sndev->link_width = NTB_WIDTH_NONE; > + return; > + } > + @@ -113,42 +104,39 @@ ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + switchtec_ntb_part_link_speed(sndev, sndev->peer_partition, > + &peer_speed, &peer_width); -Should we only set self_partition? I think each peer should be able to = -set preferred speed, and negotiate down. As written here, the last peer = -to set the speed overrides the setting on the peer, and even that is not = -atomic if they race. +Should we only set self_partition? I think each peer should be able to set preferred speed, and negotiate down. As written here, the last peer to set the speed overrides the setting on the peer, and even that is not atomic if they race. > + -> + sndev->link_speed =3D min(self_speed, peer_speed); -> + sndev->link_width =3D min(self_width, peer_width); +> + sndev->link_speed = min(self_speed, peer_speed); +> + sndev->link_width = min(self_width, peer_width); > +} > + > +enum { -> + LINK_MESSAGE =3D 0, -> + MSG_LINK_UP =3D 1, -> + MSG_LINK_DOWN =3D 2, -> + MSG_CHECK_LINK =3D 3, +> + LINK_MESSAGE = 0, +> + MSG_LINK_UP = 1, +> + MSG_LINK_DOWN = 2, +> + MSG_CHECK_LINK = 3, > +}; > + > +static void switchtec_ntb_check_link(struct switchtec_ntb *sndev) > +{ > + int link_sta; -> + int old =3D sndev->link_is_up; +> + int old = sndev->link_is_up; > + -> + link_sta =3D sndev->self_shared->link_sta; +> + link_sta = sndev->self_shared->link_sta; > + if (link_sta) { -> + u64 peer =3D ioread64(&sndev->peer_shared->magic); +> + u64 peer = ioread64(&sndev->peer_shared->magic); > + -> + if ((peer & 0xFFFFFFFF) =3D=3D SWITCHTEC_NTB_MAGIC) -> + link_sta =3D peer >> 32; +> + if ((peer & 0xFFFFFFFF) == SWITCHTEC_NTB_MAGIC) +> + link_sta = peer >> 32; > + else -> + link_sta =3D 0; +> + link_sta = 0; > + } > + -> + sndev->link_is_up =3D link_sta; +> + sndev->link_is_up = link_sta; > + switchtec_ntb_set_link_speed(sndev); > + -> + if (link_sta !=3D old) { +> + if (link_sta != old) { > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_CHECK_LINK); > + ntb_link_event(&sndev->ntb); > + dev_info(&sndev->stdev->dev, "ntb link %s", @@ -156,10 +144,9 @@ atomic if they race. > + } > +} > + -> +static void switchtec_ntb_link_notification(struct switchtec_dev = -*stdev) +> +static void switchtec_ntb_link_notification(struct switchtec_dev *stdev) > +{ -> + struct switchtec_ntb *sndev =3D stdev->sndev; +> + struct switchtec_ntb *sndev = stdev->sndev; > + > + switchtec_ntb_check_link(sndev); > +} @@ -169,71 +156,70 @@ atomic if they race. > enum ntb_width *width) > { > - return 0; -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + if (speed) -> + *speed =3D sndev->link_speed; +> + *speed = sndev->link_speed; > + if (width) -> + *width =3D sndev->link_width; +> + *width = sndev->link_width; > + > + return sndev->link_is_up; > } ->=20 +> > static int switchtec_ntb_link_enable(struct ntb_dev *ntb, > enum ntb_speed max_speed, > enum ntb_width max_width) > { -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + dev_dbg(&sndev->stdev->dev, "enabling link"); > + -> + sndev->self_shared->link_sta =3D 1; +> + sndev->self_shared->link_sta = 1; > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP); > + > + switchtec_ntb_check_link(sndev); > + > return 0; > } ->=20 +> > static int switchtec_ntb_link_disable(struct ntb_dev *ntb) > { -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + dev_dbg(&sndev->stdev->dev, "disabling link"); > + -> + sndev->self_shared->link_sta =3D 0; +> + sndev->self_shared->link_sta = 0; > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP); > + > + switchtec_ntb_check_link(sndev); > + > return 0; > } ->=20 -> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int = -irq, void *dev) +> +> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev) > dev_dbg(&sndev->stdev->dev, "message: %d %08x\n", i, > (u32)msg); > iowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status); > + -> + if (i =3D=3D LINK_MESSAGE) +> + if (i == LINK_MESSAGE) > + switchtec_ntb_check_link(sndev); > } > } ->=20 +> > @@ -659,6 +785,7 @@ static int switchtec_ntb_add(struct device *dev, > goto deinit_and_exit; ->=20 -> stdev->sndev =3D sndev; -> + stdev->link_notifier =3D switchtec_ntb_link_notification; +> +> stdev->sndev = sndev; +> + stdev->link_notifier = switchtec_ntb_link_notification; > dev_info(dev, "NTB device registered"); ->=20 +> > return 0; > @@ -682,6 +809,7 @@ void switchtec_ntb_remove(struct device *dev, > if (!sndev) > return; ->=20 -> + stdev->link_notifier =3D NULL; -> stdev->sndev =3D NULL; +> +> + stdev->link_notifier = NULL; +> stdev->sndev = NULL; > ntb_unregister_device(&sndev->ntb); > switchtec_ntb_deinit_db_msg_irq(sndev); > -- diff --git a/a/content_digest b/N1/content_digest index 15c96cc..e6fdf84 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -4,9 +4,9 @@ "Subject\0RE: [PATCH 12/16] switchtec_ntb: add link management\0" "Date\0Thu, 29 Jun 2017 14:11:51 -0400\0" "To\0'Logan Gunthorpe' <logang@deltatee.com>" - <linux-ntb@googlegroups.com> - <linux-pci@vger.kernel.org> - " <linux-kernel@vger.kernel.org>\0" + linux-ntb@googlegroups.com + linux-pci@vger.kernel.org + " linux-kernel@vger.kernel.org\0" "Cc\0'Jon Mason' <jdmason@kudzu.us>" 'Dave Jiang' <dave.jiang@intel.com> 'Bjorn Helgaas' <bhelgaas@google.com> @@ -20,32 +20,29 @@ "> switchtec_ntb checks for a link by looking at the shared memory\n" "> window. If the magic number is correct and the otherside indicates\n" "> their link is enabled then we take the link to be up.\n" - ">=20\n" + "> \n" "> Whenever we change our local link status we send a msg to the\n" "> otherside to check whether it's up and change their status.\n" - ">=20\n" + "> \n" "> The current status is maintained in a flag so ntb_is_link_up\n" "> can return quickly.\n" - ">=20\n" + "> \n" "> We utilize switchtec's link status notifier to also check link changes\n" "> when the switch notices a port changes state.\n" - ">=20\n" + "> \n" "> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>\n" "> Reviewed-by: Stephen Bates <sbates@raithlin.com>\n" "> Reviewed-by: Kurt Schwemmer <kurt.schwemmer@microsemi.com>\n" "> ---\n" - "> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 =\n" - "+++++++++++++++++++++++++++++++++++-\n" + "> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 +++++++++++++++++++++++++++++++++++-\n" "> 1 file changed, 129 insertions(+), 1 deletion(-)\n" - ">=20\n" - "> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c =\n" - "b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" + "> \n" + "> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" "> index 0587b2380bcc..8ef84d45bda6 100644\n" "> --- a/drivers/ntb/hw/mscc/switchtec_ntb.c\n" "> +++ b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" - "> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem =\n" - "*mmio)\n" - ">=20\n" + "> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem *mmio)\n" + "> \n" "> struct shared_mw {\n" "> \tu32 magic;\n" "> +\tu32 link_sta;\n" @@ -61,7 +58,7 @@ "> +\tenum ntb_speed link_speed;\n" "> +\tenum ntb_width link_width;\n" "> };\n" - ">=20\n" + "> \n" "> +static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb)\n" "> +{\n" "> +\treturn container_of(ntb, struct switchtec_ntb, ntb);\n" @@ -70,16 +67,14 @@ "> static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,\n" "> \t\t\t\t struct ntb_ctrl_regs __iomem *ctl,\n" "> \t\t\t\t u32 op, int wait_status)\n" - "> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct =\n" - "switchtec_ntb *sndev,\n" + "> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,\n" "> \treturn -EIO;\n" "> }\n" - ">=20\n" - "> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int =\n" - "idx,\n" + "> \n" + "> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int idx,\n" "> +\t\t\t\t u32 val)\n" "> +{\n" - "> +\tif (idx < 0 || idx >=3D ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg))\n" + "> +\tif (idx < 0 || idx >= ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg))\n" "> +\t\treturn -EINVAL;\n" "> +\n" "> +\tiowrite32(val, &sndev->mmio_self_dbmsg->omsg[idx].msg);\n" @@ -90,29 +85,25 @@ "> static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx)\n" "> {\n" "> \treturn 0;\n" - "> @@ -192,22 +213,124 @@ static int =\n" - "switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,\n" + "> @@ -192,22 +213,124 @@ static int switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,\n" "> \treturn 0;\n" "> }\n" - ">=20\n" - "> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb =\n" - "*sndev,\n" + "> \n" + "> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev,\n" "> +\t\t\t\t\t int partition,\n" "> +\t\t\t\t\t enum ntb_speed *speed,\n" "> +\t\t\t\t\t enum ntb_width *width)\n" "> +{\n" - "> +\tstruct switchtec_dev *stdev =3D sndev->stdev;\n" + "> +\tstruct switchtec_dev *stdev = sndev->stdev;\n" "> +\n" - "> +\tu32 pff =3D =\n" - "ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id);\n" - "> +\tu32 linksta =3D =\n" - "ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]);\n" + "> +\tu32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id);\n" + "> +\tu32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]);\n" "> +\n" "> +\tif (speed)\n" - "> +\t\t*speed =3D (linksta >> 16) & 0xF;\n" + "> +\t\t*speed = (linksta >> 16) & 0xF;\n" "> +\n" "> +\tif (width)\n" - "> +\t\t*width =3D (linksta >> 20) & 0x3F;\n" + "> +\t\t*width = (linksta >> 20) & 0x3F;\n" "> +}\n" "> +\n" "> +static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev)\n" @@ -121,8 +112,8 @@ "> +\tenum ntb_width self_width, peer_width;\n" "> +\n" "> +\tif (!sndev->link_is_up) {\n" - "> +\t\tsndev->link_speed =3D NTB_SPEED_NONE;\n" - "> +\t\tsndev->link_width =3D NTB_WIDTH_NONE;\n" + "> +\t\tsndev->link_speed = NTB_SPEED_NONE;\n" + "> +\t\tsndev->link_width = NTB_WIDTH_NONE;\n" "> +\t\treturn;\n" "> +\t}\n" "> +\n" @@ -131,42 +122,39 @@ "> +\tswitchtec_ntb_part_link_speed(sndev, sndev->peer_partition,\n" "> +\t\t\t\t &peer_speed, &peer_width);\n" "\n" - "Should we only set self_partition? I think each peer should be able to =\n" - "set preferred speed, and negotiate down. As written here, the last peer =\n" - "to set the speed overrides the setting on the peer, and even that is not =\n" - "atomic if they race.\n" + "Should we only set self_partition? I think each peer should be able to set preferred speed, and negotiate down. As written here, the last peer to set the speed overrides the setting on the peer, and even that is not atomic if they race.\n" "\n" "> +\n" - "> +\tsndev->link_speed =3D min(self_speed, peer_speed);\n" - "> +\tsndev->link_width =3D min(self_width, peer_width);\n" + "> +\tsndev->link_speed = min(self_speed, peer_speed);\n" + "> +\tsndev->link_width = min(self_width, peer_width);\n" "> +}\n" "> +\n" "> +enum {\n" - "> +\tLINK_MESSAGE =3D 0,\n" - "> +\tMSG_LINK_UP =3D 1,\n" - "> +\tMSG_LINK_DOWN =3D 2,\n" - "> +\tMSG_CHECK_LINK =3D 3,\n" + "> +\tLINK_MESSAGE = 0,\n" + "> +\tMSG_LINK_UP = 1,\n" + "> +\tMSG_LINK_DOWN = 2,\n" + "> +\tMSG_CHECK_LINK = 3,\n" "> +};\n" "> +\n" "> +static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)\n" "> +{\n" "> +\tint link_sta;\n" - "> +\tint old =3D sndev->link_is_up;\n" + "> +\tint old = sndev->link_is_up;\n" "> +\n" - "> +\tlink_sta =3D sndev->self_shared->link_sta;\n" + "> +\tlink_sta = sndev->self_shared->link_sta;\n" "> +\tif (link_sta) {\n" - "> +\t\tu64 peer =3D ioread64(&sndev->peer_shared->magic);\n" + "> +\t\tu64 peer = ioread64(&sndev->peer_shared->magic);\n" "> +\n" - "> +\t\tif ((peer & 0xFFFFFFFF) =3D=3D SWITCHTEC_NTB_MAGIC)\n" - "> +\t\t\tlink_sta =3D peer >> 32;\n" + "> +\t\tif ((peer & 0xFFFFFFFF) == SWITCHTEC_NTB_MAGIC)\n" + "> +\t\t\tlink_sta = peer >> 32;\n" "> +\t\telse\n" - "> +\t\t\tlink_sta =3D 0;\n" + "> +\t\t\tlink_sta = 0;\n" "> +\t}\n" "> +\n" - "> +\tsndev->link_is_up =3D link_sta;\n" + "> +\tsndev->link_is_up = link_sta;\n" "> +\tswitchtec_ntb_set_link_speed(sndev);\n" "> +\n" - "> +\tif (link_sta !=3D old) {\n" + "> +\tif (link_sta != old) {\n" "> +\t\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_CHECK_LINK);\n" "> +\t\tntb_link_event(&sndev->ntb);\n" "> +\t\tdev_info(&sndev->stdev->dev, \"ntb link %s\",\n" @@ -174,10 +162,9 @@ "> +\t}\n" "> +}\n" "> +\n" - "> +static void switchtec_ntb_link_notification(struct switchtec_dev =\n" - "*stdev)\n" + "> +static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)\n" "> +{\n" - "> +\tstruct switchtec_ntb *sndev =3D stdev->sndev;\n" + "> +\tstruct switchtec_ntb *sndev = stdev->sndev;\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +}\n" @@ -187,74 +174,73 @@ "> \t\t\t\t enum ntb_width *width)\n" "> {\n" "> -\treturn 0;\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tif (speed)\n" - "> +\t\t*speed =3D sndev->link_speed;\n" + "> +\t\t*speed = sndev->link_speed;\n" "> +\tif (width)\n" - "> +\t\t*width =3D sndev->link_width;\n" + "> +\t\t*width = sndev->link_width;\n" "> +\n" "> +\treturn sndev->link_is_up;\n" "> }\n" - ">=20\n" + "> \n" "> static int switchtec_ntb_link_enable(struct ntb_dev *ntb,\n" "> \t\t\t\t enum ntb_speed max_speed,\n" "> \t\t\t\t enum ntb_width max_width)\n" "> {\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tdev_dbg(&sndev->stdev->dev, \"enabling link\");\n" "> +\n" - "> +\tsndev->self_shared->link_sta =3D 1;\n" + "> +\tsndev->self_shared->link_sta = 1;\n" "> +\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +\n" "> \treturn 0;\n" "> }\n" - ">=20\n" + "> \n" "> static int switchtec_ntb_link_disable(struct ntb_dev *ntb)\n" "> {\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tdev_dbg(&sndev->stdev->dev, \"disabling link\");\n" "> +\n" - "> +\tsndev->self_shared->link_sta =3D 0;\n" + "> +\tsndev->self_shared->link_sta = 0;\n" "> +\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +\n" "> \treturn 0;\n" "> }\n" - ">=20\n" - "> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int =\n" - "irq, void *dev)\n" + "> \n" + "> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev)\n" "> \t\t\tdev_dbg(&sndev->stdev->dev, \"message: %d %08x\\n\", i,\n" "> \t\t\t\t(u32)msg);\n" "> \t\t\tiowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status);\n" "> +\n" - "> +\t\t\tif (i =3D=3D LINK_MESSAGE)\n" + "> +\t\t\tif (i == LINK_MESSAGE)\n" "> +\t\t\t\tswitchtec_ntb_check_link(sndev);\n" "> \t\t}\n" "> \t}\n" - ">=20\n" + "> \n" "> @@ -659,6 +785,7 @@ static int switchtec_ntb_add(struct device *dev,\n" "> \t\tgoto deinit_and_exit;\n" - ">=20\n" - "> \tstdev->sndev =3D sndev;\n" - "> +\tstdev->link_notifier =3D switchtec_ntb_link_notification;\n" + "> \n" + "> \tstdev->sndev = sndev;\n" + "> +\tstdev->link_notifier = switchtec_ntb_link_notification;\n" "> \tdev_info(dev, \"NTB device registered\");\n" - ">=20\n" + "> \n" "> \treturn 0;\n" "> @@ -682,6 +809,7 @@ void switchtec_ntb_remove(struct device *dev,\n" "> \tif (!sndev)\n" "> \t\treturn;\n" - ">=20\n" - "> +\tstdev->link_notifier =3D NULL;\n" - "> \tstdev->sndev =3D NULL;\n" + "> \n" + "> +\tstdev->link_notifier = NULL;\n" + "> \tstdev->sndev = NULL;\n" "> \tntb_unregister_device(&sndev->ntb);\n" "> \tswitchtec_ntb_deinit_db_msg_irq(sndev);\n" "> --\n" > 2.11.0 -64339929093798d435ea8e0e8a213f07d83ea0308b3d849bb7740d1ca552fab7 +43ba9ac2a3d5b3766bd8c3748364053f2d14b2a4535c7e162142d9dad31b40d2
diff --git a/a/1.txt b/N2/1.txt index 5236134..cd3bc8b 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -2,32 +2,29 @@ From: Logan Gunthorpe > switchtec_ntb checks for a link by looking at the shared memory > window. If the magic number is correct and the otherside indicates > their link is enabled then we take the link to be up. ->=20 +> > Whenever we change our local link status we send a msg to the > otherside to check whether it's up and change their status. ->=20 +> > The current status is maintained in a flag so ntb_is_link_up > can return quickly. ->=20 +> > We utilize switchtec's link status notifier to also check link changes > when the switch notices a port changes state. ->=20 +> > Signed-off-by: Logan Gunthorpe <logang@deltatee.com> > Reviewed-by: Stephen Bates <sbates@raithlin.com> > Reviewed-by: Kurt Schwemmer <kurt.schwemmer@microsemi.com> > --- -> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 = -+++++++++++++++++++++++++++++++++++- +> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 +++++++++++++++++++++++++++++++++++- > 1 file changed, 129 insertions(+), 1 deletion(-) ->=20 -> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c = -b/drivers/ntb/hw/mscc/switchtec_ntb.c +> +> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c b/drivers/ntb/hw/mscc/switchtec_ntb.c > index 0587b2380bcc..8ef84d45bda6 100644 > --- a/drivers/ntb/hw/mscc/switchtec_ntb.c > +++ b/drivers/ntb/hw/mscc/switchtec_ntb.c -> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem = -*mmio) ->=20 +> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem *mmio) +> > struct shared_mw { > u32 magic; > + u32 link_sta; @@ -43,7 +40,7 @@ b/drivers/ntb/hw/mscc/switchtec_ntb.c > + enum ntb_speed link_speed; > + enum ntb_width link_width; > }; ->=20 +> > +static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb) > +{ > + return container_of(ntb, struct switchtec_ntb, ntb); @@ -52,16 +49,14 @@ b/drivers/ntb/hw/mscc/switchtec_ntb.c > static int switchtec_ntb_part_op(struct switchtec_ntb *sndev, > struct ntb_ctrl_regs __iomem *ctl, > u32 op, int wait_status) -> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct = -switchtec_ntb *sndev, +> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct switchtec_ntb *sndev, > return -EIO; > } ->=20 -> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int = -idx, +> +> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int idx, > + u32 val) > +{ -> + if (idx < 0 || idx >=3D ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg)) +> + if (idx < 0 || idx >= ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg)) > + return -EINVAL; > + > + iowrite32(val, &sndev->mmio_self_dbmsg->omsg[idx].msg); @@ -72,29 +67,25 @@ idx, > static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx) > { > return 0; -> @@ -192,22 +213,124 @@ static int = -switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx, +> @@ -192,22 +213,124 @@ static int switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx, > return 0; > } ->=20 -> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb = -*sndev, +> +> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev, > + int partition, > + enum ntb_speed *speed, > + enum ntb_width *width) > +{ -> + struct switchtec_dev *stdev =3D sndev->stdev; +> + struct switchtec_dev *stdev = sndev->stdev; > + -> + u32 pff =3D = -ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); -> + u32 linksta =3D = -ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); +> + u32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); +> + u32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + > + if (speed) -> + *speed =3D (linksta >> 16) & 0xF; +> + *speed = (linksta >> 16) & 0xF; > + > + if (width) -> + *width =3D (linksta >> 20) & 0x3F; +> + *width = (linksta >> 20) & 0x3F; > +} > + > +static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev) @@ -103,8 +94,8 @@ ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + enum ntb_width self_width, peer_width; > + > + if (!sndev->link_is_up) { -> + sndev->link_speed =3D NTB_SPEED_NONE; -> + sndev->link_width =3D NTB_WIDTH_NONE; +> + sndev->link_speed = NTB_SPEED_NONE; +> + sndev->link_width = NTB_WIDTH_NONE; > + return; > + } > + @@ -113,42 +104,39 @@ ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); > + switchtec_ntb_part_link_speed(sndev, sndev->peer_partition, > + &peer_speed, &peer_width); -Should we only set self_partition? I think each peer should be able to = -set preferred speed, and negotiate down. As written here, the last peer = -to set the speed overrides the setting on the peer, and even that is not = -atomic if they race. +Should we only set self_partition? I think each peer should be able to set preferred speed, and negotiate down. As written here, the last peer to set the speed overrides the setting on the peer, and even that is not atomic if they race. > + -> + sndev->link_speed =3D min(self_speed, peer_speed); -> + sndev->link_width =3D min(self_width, peer_width); +> + sndev->link_speed = min(self_speed, peer_speed); +> + sndev->link_width = min(self_width, peer_width); > +} > + > +enum { -> + LINK_MESSAGE =3D 0, -> + MSG_LINK_UP =3D 1, -> + MSG_LINK_DOWN =3D 2, -> + MSG_CHECK_LINK =3D 3, +> + LINK_MESSAGE = 0, +> + MSG_LINK_UP = 1, +> + MSG_LINK_DOWN = 2, +> + MSG_CHECK_LINK = 3, > +}; > + > +static void switchtec_ntb_check_link(struct switchtec_ntb *sndev) > +{ > + int link_sta; -> + int old =3D sndev->link_is_up; +> + int old = sndev->link_is_up; > + -> + link_sta =3D sndev->self_shared->link_sta; +> + link_sta = sndev->self_shared->link_sta; > + if (link_sta) { -> + u64 peer =3D ioread64(&sndev->peer_shared->magic); +> + u64 peer = ioread64(&sndev->peer_shared->magic); > + -> + if ((peer & 0xFFFFFFFF) =3D=3D SWITCHTEC_NTB_MAGIC) -> + link_sta =3D peer >> 32; +> + if ((peer & 0xFFFFFFFF) == SWITCHTEC_NTB_MAGIC) +> + link_sta = peer >> 32; > + else -> + link_sta =3D 0; +> + link_sta = 0; > + } > + -> + sndev->link_is_up =3D link_sta; +> + sndev->link_is_up = link_sta; > + switchtec_ntb_set_link_speed(sndev); > + -> + if (link_sta !=3D old) { +> + if (link_sta != old) { > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_CHECK_LINK); > + ntb_link_event(&sndev->ntb); > + dev_info(&sndev->stdev->dev, "ntb link %s", @@ -156,10 +144,9 @@ atomic if they race. > + } > +} > + -> +static void switchtec_ntb_link_notification(struct switchtec_dev = -*stdev) +> +static void switchtec_ntb_link_notification(struct switchtec_dev *stdev) > +{ -> + struct switchtec_ntb *sndev =3D stdev->sndev; +> + struct switchtec_ntb *sndev = stdev->sndev; > + > + switchtec_ntb_check_link(sndev); > +} @@ -169,71 +156,70 @@ atomic if they race. > enum ntb_width *width) > { > - return 0; -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + if (speed) -> + *speed =3D sndev->link_speed; +> + *speed = sndev->link_speed; > + if (width) -> + *width =3D sndev->link_width; +> + *width = sndev->link_width; > + > + return sndev->link_is_up; > } ->=20 +> > static int switchtec_ntb_link_enable(struct ntb_dev *ntb, > enum ntb_speed max_speed, > enum ntb_width max_width) > { -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + dev_dbg(&sndev->stdev->dev, "enabling link"); > + -> + sndev->self_shared->link_sta =3D 1; +> + sndev->self_shared->link_sta = 1; > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP); > + > + switchtec_ntb_check_link(sndev); > + > return 0; > } ->=20 +> > static int switchtec_ntb_link_disable(struct ntb_dev *ntb) > { -> + struct switchtec_ntb *sndev =3D ntb_sndev(ntb); +> + struct switchtec_ntb *sndev = ntb_sndev(ntb); > + > + dev_dbg(&sndev->stdev->dev, "disabling link"); > + -> + sndev->self_shared->link_sta =3D 0; +> + sndev->self_shared->link_sta = 0; > + switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP); > + > + switchtec_ntb_check_link(sndev); > + > return 0; > } ->=20 -> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int = -irq, void *dev) +> +> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev) > dev_dbg(&sndev->stdev->dev, "message: %d %08x\n", i, > (u32)msg); > iowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status); > + -> + if (i =3D=3D LINK_MESSAGE) +> + if (i == LINK_MESSAGE) > + switchtec_ntb_check_link(sndev); > } > } ->=20 +> > @@ -659,6 +785,7 @@ static int switchtec_ntb_add(struct device *dev, > goto deinit_and_exit; ->=20 -> stdev->sndev =3D sndev; -> + stdev->link_notifier =3D switchtec_ntb_link_notification; +> +> stdev->sndev = sndev; +> + stdev->link_notifier = switchtec_ntb_link_notification; > dev_info(dev, "NTB device registered"); ->=20 +> > return 0; > @@ -682,6 +809,7 @@ void switchtec_ntb_remove(struct device *dev, > if (!sndev) > return; ->=20 -> + stdev->link_notifier =3D NULL; -> stdev->sndev =3D NULL; +> +> + stdev->link_notifier = NULL; +> stdev->sndev = NULL; > ntb_unregister_device(&sndev->ntb); > switchtec_ntb_deinit_db_msg_irq(sndev); > -- diff --git a/a/content_digest b/N2/content_digest index 15c96cc..d358517 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -20,32 +20,29 @@ "> switchtec_ntb checks for a link by looking at the shared memory\n" "> window. If the magic number is correct and the otherside indicates\n" "> their link is enabled then we take the link to be up.\n" - ">=20\n" + "> \n" "> Whenever we change our local link status we send a msg to the\n" "> otherside to check whether it's up and change their status.\n" - ">=20\n" + "> \n" "> The current status is maintained in a flag so ntb_is_link_up\n" "> can return quickly.\n" - ">=20\n" + "> \n" "> We utilize switchtec's link status notifier to also check link changes\n" "> when the switch notices a port changes state.\n" - ">=20\n" + "> \n" "> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>\n" "> Reviewed-by: Stephen Bates <sbates@raithlin.com>\n" "> Reviewed-by: Kurt Schwemmer <kurt.schwemmer@microsemi.com>\n" "> ---\n" - "> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 =\n" - "+++++++++++++++++++++++++++++++++++-\n" + "> drivers/ntb/hw/mscc/switchtec_ntb.c | 130 +++++++++++++++++++++++++++++++++++-\n" "> 1 file changed, 129 insertions(+), 1 deletion(-)\n" - ">=20\n" - "> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c =\n" - "b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" + "> \n" + "> diff --git a/drivers/ntb/hw/mscc/switchtec_ntb.c b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" "> index 0587b2380bcc..8ef84d45bda6 100644\n" "> --- a/drivers/ntb/hw/mscc/switchtec_ntb.c\n" "> +++ b/drivers/ntb/hw/mscc/switchtec_ntb.c\n" - "> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem =\n" - "*mmio)\n" - ">=20\n" + "> @@ -64,6 +64,7 @@ static inline void _iowrite64(u64 val, void __iomem *mmio)\n" + "> \n" "> struct shared_mw {\n" "> \tu32 magic;\n" "> +\tu32 link_sta;\n" @@ -61,7 +58,7 @@ "> +\tenum ntb_speed link_speed;\n" "> +\tenum ntb_width link_width;\n" "> };\n" - ">=20\n" + "> \n" "> +static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb)\n" "> +{\n" "> +\treturn container_of(ntb, struct switchtec_ntb, ntb);\n" @@ -70,16 +67,14 @@ "> static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,\n" "> \t\t\t\t struct ntb_ctrl_regs __iomem *ctl,\n" "> \t\t\t\t u32 op, int wait_status)\n" - "> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct =\n" - "switchtec_ntb *sndev,\n" + "> @@ -161,6 +171,17 @@ static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,\n" "> \treturn -EIO;\n" "> }\n" - ">=20\n" - "> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int =\n" - "idx,\n" + "> \n" + "> +static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int idx,\n" "> +\t\t\t\t u32 val)\n" "> +{\n" - "> +\tif (idx < 0 || idx >=3D ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg))\n" + "> +\tif (idx < 0 || idx >= ARRAY_SIZE(sndev->mmio_self_dbmsg->omsg))\n" "> +\t\treturn -EINVAL;\n" "> +\n" "> +\tiowrite32(val, &sndev->mmio_self_dbmsg->omsg[idx].msg);\n" @@ -90,29 +85,25 @@ "> static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx)\n" "> {\n" "> \treturn 0;\n" - "> @@ -192,22 +213,124 @@ static int =\n" - "switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,\n" + "> @@ -192,22 +213,124 @@ static int switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,\n" "> \treturn 0;\n" "> }\n" - ">=20\n" - "> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb =\n" - "*sndev,\n" + "> \n" + "> +static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev,\n" "> +\t\t\t\t\t int partition,\n" "> +\t\t\t\t\t enum ntb_speed *speed,\n" "> +\t\t\t\t\t enum ntb_width *width)\n" "> +{\n" - "> +\tstruct switchtec_dev *stdev =3D sndev->stdev;\n" + "> +\tstruct switchtec_dev *stdev = sndev->stdev;\n" "> +\n" - "> +\tu32 pff =3D =\n" - "ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id);\n" - "> +\tu32 linksta =3D =\n" - "ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]);\n" + "> +\tu32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id);\n" + "> +\tu32 linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]);\n" "> +\n" "> +\tif (speed)\n" - "> +\t\t*speed =3D (linksta >> 16) & 0xF;\n" + "> +\t\t*speed = (linksta >> 16) & 0xF;\n" "> +\n" "> +\tif (width)\n" - "> +\t\t*width =3D (linksta >> 20) & 0x3F;\n" + "> +\t\t*width = (linksta >> 20) & 0x3F;\n" "> +}\n" "> +\n" "> +static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev)\n" @@ -121,8 +112,8 @@ "> +\tenum ntb_width self_width, peer_width;\n" "> +\n" "> +\tif (!sndev->link_is_up) {\n" - "> +\t\tsndev->link_speed =3D NTB_SPEED_NONE;\n" - "> +\t\tsndev->link_width =3D NTB_WIDTH_NONE;\n" + "> +\t\tsndev->link_speed = NTB_SPEED_NONE;\n" + "> +\t\tsndev->link_width = NTB_WIDTH_NONE;\n" "> +\t\treturn;\n" "> +\t}\n" "> +\n" @@ -131,42 +122,39 @@ "> +\tswitchtec_ntb_part_link_speed(sndev, sndev->peer_partition,\n" "> +\t\t\t\t &peer_speed, &peer_width);\n" "\n" - "Should we only set self_partition? I think each peer should be able to =\n" - "set preferred speed, and negotiate down. As written here, the last peer =\n" - "to set the speed overrides the setting on the peer, and even that is not =\n" - "atomic if they race.\n" + "Should we only set self_partition? I think each peer should be able to set preferred speed, and negotiate down. As written here, the last peer to set the speed overrides the setting on the peer, and even that is not atomic if they race.\n" "\n" "> +\n" - "> +\tsndev->link_speed =3D min(self_speed, peer_speed);\n" - "> +\tsndev->link_width =3D min(self_width, peer_width);\n" + "> +\tsndev->link_speed = min(self_speed, peer_speed);\n" + "> +\tsndev->link_width = min(self_width, peer_width);\n" "> +}\n" "> +\n" "> +enum {\n" - "> +\tLINK_MESSAGE =3D 0,\n" - "> +\tMSG_LINK_UP =3D 1,\n" - "> +\tMSG_LINK_DOWN =3D 2,\n" - "> +\tMSG_CHECK_LINK =3D 3,\n" + "> +\tLINK_MESSAGE = 0,\n" + "> +\tMSG_LINK_UP = 1,\n" + "> +\tMSG_LINK_DOWN = 2,\n" + "> +\tMSG_CHECK_LINK = 3,\n" "> +};\n" "> +\n" "> +static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)\n" "> +{\n" "> +\tint link_sta;\n" - "> +\tint old =3D sndev->link_is_up;\n" + "> +\tint old = sndev->link_is_up;\n" "> +\n" - "> +\tlink_sta =3D sndev->self_shared->link_sta;\n" + "> +\tlink_sta = sndev->self_shared->link_sta;\n" "> +\tif (link_sta) {\n" - "> +\t\tu64 peer =3D ioread64(&sndev->peer_shared->magic);\n" + "> +\t\tu64 peer = ioread64(&sndev->peer_shared->magic);\n" "> +\n" - "> +\t\tif ((peer & 0xFFFFFFFF) =3D=3D SWITCHTEC_NTB_MAGIC)\n" - "> +\t\t\tlink_sta =3D peer >> 32;\n" + "> +\t\tif ((peer & 0xFFFFFFFF) == SWITCHTEC_NTB_MAGIC)\n" + "> +\t\t\tlink_sta = peer >> 32;\n" "> +\t\telse\n" - "> +\t\t\tlink_sta =3D 0;\n" + "> +\t\t\tlink_sta = 0;\n" "> +\t}\n" "> +\n" - "> +\tsndev->link_is_up =3D link_sta;\n" + "> +\tsndev->link_is_up = link_sta;\n" "> +\tswitchtec_ntb_set_link_speed(sndev);\n" "> +\n" - "> +\tif (link_sta !=3D old) {\n" + "> +\tif (link_sta != old) {\n" "> +\t\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_CHECK_LINK);\n" "> +\t\tntb_link_event(&sndev->ntb);\n" "> +\t\tdev_info(&sndev->stdev->dev, \"ntb link %s\",\n" @@ -174,10 +162,9 @@ "> +\t}\n" "> +}\n" "> +\n" - "> +static void switchtec_ntb_link_notification(struct switchtec_dev =\n" - "*stdev)\n" + "> +static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)\n" "> +{\n" - "> +\tstruct switchtec_ntb *sndev =3D stdev->sndev;\n" + "> +\tstruct switchtec_ntb *sndev = stdev->sndev;\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +}\n" @@ -187,74 +174,73 @@ "> \t\t\t\t enum ntb_width *width)\n" "> {\n" "> -\treturn 0;\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tif (speed)\n" - "> +\t\t*speed =3D sndev->link_speed;\n" + "> +\t\t*speed = sndev->link_speed;\n" "> +\tif (width)\n" - "> +\t\t*width =3D sndev->link_width;\n" + "> +\t\t*width = sndev->link_width;\n" "> +\n" "> +\treturn sndev->link_is_up;\n" "> }\n" - ">=20\n" + "> \n" "> static int switchtec_ntb_link_enable(struct ntb_dev *ntb,\n" "> \t\t\t\t enum ntb_speed max_speed,\n" "> \t\t\t\t enum ntb_width max_width)\n" "> {\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tdev_dbg(&sndev->stdev->dev, \"enabling link\");\n" "> +\n" - "> +\tsndev->self_shared->link_sta =3D 1;\n" + "> +\tsndev->self_shared->link_sta = 1;\n" "> +\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +\n" "> \treturn 0;\n" "> }\n" - ">=20\n" + "> \n" "> static int switchtec_ntb_link_disable(struct ntb_dev *ntb)\n" "> {\n" - "> +\tstruct switchtec_ntb *sndev =3D ntb_sndev(ntb);\n" + "> +\tstruct switchtec_ntb *sndev = ntb_sndev(ntb);\n" "> +\n" "> +\tdev_dbg(&sndev->stdev->dev, \"disabling link\");\n" "> +\n" - "> +\tsndev->self_shared->link_sta =3D 0;\n" + "> +\tsndev->self_shared->link_sta = 0;\n" "> +\tswitchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);\n" "> +\n" "> +\tswitchtec_ntb_check_link(sndev);\n" "> +\n" "> \treturn 0;\n" "> }\n" - ">=20\n" - "> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int =\n" - "irq, void *dev)\n" + "> \n" + "> @@ -555,6 +678,9 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev)\n" "> \t\t\tdev_dbg(&sndev->stdev->dev, \"message: %d %08x\\n\", i,\n" "> \t\t\t\t(u32)msg);\n" "> \t\t\tiowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status);\n" "> +\n" - "> +\t\t\tif (i =3D=3D LINK_MESSAGE)\n" + "> +\t\t\tif (i == LINK_MESSAGE)\n" "> +\t\t\t\tswitchtec_ntb_check_link(sndev);\n" "> \t\t}\n" "> \t}\n" - ">=20\n" + "> \n" "> @@ -659,6 +785,7 @@ static int switchtec_ntb_add(struct device *dev,\n" "> \t\tgoto deinit_and_exit;\n" - ">=20\n" - "> \tstdev->sndev =3D sndev;\n" - "> +\tstdev->link_notifier =3D switchtec_ntb_link_notification;\n" + "> \n" + "> \tstdev->sndev = sndev;\n" + "> +\tstdev->link_notifier = switchtec_ntb_link_notification;\n" "> \tdev_info(dev, \"NTB device registered\");\n" - ">=20\n" + "> \n" "> \treturn 0;\n" "> @@ -682,6 +809,7 @@ void switchtec_ntb_remove(struct device *dev,\n" "> \tif (!sndev)\n" "> \t\treturn;\n" - ">=20\n" - "> +\tstdev->link_notifier =3D NULL;\n" - "> \tstdev->sndev =3D NULL;\n" + "> \n" + "> +\tstdev->link_notifier = NULL;\n" + "> \tstdev->sndev = NULL;\n" "> \tntb_unregister_device(&sndev->ntb);\n" "> \tswitchtec_ntb_deinit_db_msg_irq(sndev);\n" "> --\n" > 2.11.0 -64339929093798d435ea8e0e8a213f07d83ea0308b3d849bb7740d1ca552fab7 +8f87b528fa09673fa4413332954817d6ec8ecd34f7116b1634643c9d11716f3d
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.