Skip to content

Commit 92abf4c

Browse files
amd-anathjonmason
authored andcommitted
NTB: move ntb_ctrl handling to init and deinit
It does not really make sense to enable or disable the bits of NTB_CTRL register only during enable and disable link callbacks. They should be done independent of these callbacks. The correct placement for that is during the amd_init_side_info() and amd_deinit_side_info() functions, which are invoked during probe and remove respectively. Signed-off-by: Arindam Nath <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent 673dd0c commit 92abf4c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb,
290290
{
291291
struct amd_ntb_dev *ndev = ntb_ndev(ntb);
292292
void __iomem *mmio = ndev->self_mmio;
293-
u32 ntb_ctl;
294293

295294
/* Enable event interrupt */
296295
ndev->int_mask &= ~AMD_EVENT_INTMASK;
@@ -300,18 +299,13 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb,
300299
return -EINVAL;
301300
dev_dbg(&ntb->pdev->dev, "Enabling Link.\n");
302301

303-
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
304-
ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
305-
writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
306-
307302
return 0;
308303
}
309304

310305
static int amd_ntb_link_disable(struct ntb_dev *ntb)
311306
{
312307
struct amd_ntb_dev *ndev = ntb_ndev(ntb);
313308
void __iomem *mmio = ndev->self_mmio;
314-
u32 ntb_ctl;
315309

316310
/* Disable event interrupt */
317311
ndev->int_mask |= AMD_EVENT_INTMASK;
@@ -321,10 +315,6 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb)
321315
return -EINVAL;
322316
dev_dbg(&ntb->pdev->dev, "Enabling Link.\n");
323317

324-
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
325-
ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);
326-
writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
327-
328318
return 0;
329319
}
330320

@@ -927,25 +917,35 @@ static void amd_init_side_info(struct amd_ntb_dev *ndev)
927917
{
928918
void __iomem *mmio = ndev->self_mmio;
929919
unsigned int reg;
920+
u32 ntb_ctl;
930921

931922
reg = readl(mmio + AMD_SIDEINFO_OFFSET);
932923
if (!(reg & AMD_SIDE_READY)) {
933924
reg |= AMD_SIDE_READY;
934925
writel(reg, mmio + AMD_SIDEINFO_OFFSET);
935926
}
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);
936931
}
937932

938933
static void amd_deinit_side_info(struct amd_ntb_dev *ndev)
939934
{
940935
void __iomem *mmio = ndev->self_mmio;
941936
unsigned int reg;
937+
u32 ntb_ctl;
942938

943939
reg = readl(mmio + AMD_SIDEINFO_OFFSET);
944940
if (reg & AMD_SIDE_READY) {
945941
reg &= ~AMD_SIDE_READY;
946942
writel(reg, mmio + AMD_SIDEINFO_OFFSET);
947943
readl(mmio + AMD_SIDEINFO_OFFSET);
948944
}
945+
946+
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
947+
ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);
948+
writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
949949
}
950950

951951
static int amd_init_ntb(struct amd_ntb_dev *ndev)

0 commit comments

Comments
 (0)