Skip to content

Commit ae5f4bd

Browse files
amd-anathjonmason
authored andcommitted
NTB: add helper functions to set and clear sideinfo
We define two new helper functions to set and clear sideinfo registers respectively. These functions take an additional boolean parameter which signifies whether we want to set/clear the sideinfo register of the peer(true) or local host(false). Signed-off-by: Arindam Nath <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent 92abf4c commit ae5f4bd

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -913,35 +913,59 @@ static int amd_init_isr(struct amd_ntb_dev *ndev)
913913
return ndev_init_isr(ndev, AMD_DB_CNT, AMD_MSIX_VECTOR_CNT);
914914
}
915915

916-
static void amd_init_side_info(struct amd_ntb_dev *ndev)
916+
static void amd_set_side_info_reg(struct amd_ntb_dev *ndev, bool peer)
917917
{
918-
void __iomem *mmio = ndev->self_mmio;
918+
void __iomem *mmio = NULL;
919919
unsigned int reg;
920-
u32 ntb_ctl;
920+
921+
if (peer)
922+
mmio = ndev->peer_mmio;
923+
else
924+
mmio = ndev->self_mmio;
921925

922926
reg = readl(mmio + AMD_SIDEINFO_OFFSET);
923927
if (!(reg & AMD_SIDE_READY)) {
924928
reg |= AMD_SIDE_READY;
925929
writel(reg, mmio + AMD_SIDEINFO_OFFSET);
926930
}
927-
928-
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
929-
ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
930-
writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
931931
}
932932

933-
static void amd_deinit_side_info(struct amd_ntb_dev *ndev)
933+
static void amd_clear_side_info_reg(struct amd_ntb_dev *ndev, bool peer)
934934
{
935-
void __iomem *mmio = ndev->self_mmio;
935+
void __iomem *mmio = NULL;
936936
unsigned int reg;
937-
u32 ntb_ctl;
937+
938+
if (peer)
939+
mmio = ndev->peer_mmio;
940+
else
941+
mmio = ndev->self_mmio;
938942

939943
reg = readl(mmio + AMD_SIDEINFO_OFFSET);
940944
if (reg & AMD_SIDE_READY) {
941945
reg &= ~AMD_SIDE_READY;
942946
writel(reg, mmio + AMD_SIDEINFO_OFFSET);
943947
readl(mmio + AMD_SIDEINFO_OFFSET);
944948
}
949+
}
950+
951+
static void amd_init_side_info(struct amd_ntb_dev *ndev)
952+
{
953+
void __iomem *mmio = ndev->self_mmio;
954+
u32 ntb_ctl;
955+
956+
amd_set_side_info_reg(ndev, false);
957+
958+
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
959+
ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
960+
writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
961+
}
962+
963+
static void amd_deinit_side_info(struct amd_ntb_dev *ndev)
964+
{
965+
void __iomem *mmio = ndev->self_mmio;
966+
u32 ntb_ctl;
967+
968+
amd_clear_side_info_reg(ndev, false);
945969

946970
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
947971
ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);

drivers/ntb/hw/amd/ntb_hw_amd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,7 @@ struct amd_ntb_dev {
215215
#define ntb_ndev(__ntb) container_of(__ntb, struct amd_ntb_dev, ntb)
216216
#define hb_ndev(__work) container_of(__work, struct amd_ntb_dev, hb_timer.work)
217217

218+
static void amd_set_side_info_reg(struct amd_ntb_dev *ndev, bool peer);
219+
static void amd_clear_side_info_reg(struct amd_ntb_dev *ndev, bool peer);
220+
218221
#endif

0 commit comments

Comments
 (0)