diff mbox series

[6/7] pm80xx: Reset PI and CI memory during re-initialize

Message ID 20210224155802.13292-7-Viswas.G@microchip.com
State Superseded
Headers show
Series pm80xx updates | expand

Commit Message

Viswas G Feb. 24, 2021, 3:58 p.m. UTC
Producer index(PI) outbound queue and consumer index(CI)
for Outbound queue are in DMA memory. These values should
be reset to 0 during driver reinitialization.

Signed-off-by: Viswas G <Viswas.G@microchip.com>
Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com>
Signed-off-by: Ashokkumar N <Ashokkumar.N@microchip.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c | 2 ++
 drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++
 2 files changed, 4 insertions(+)

Comments

Jinpu Wang March 4, 2021, 9:37 a.m. UTC | #1
On Wed, Feb 24, 2021 at 4:48 PM Viswas G <Viswas.G@microchip.com> wrote:
>

> Producer index(PI) outbound queue and consumer index(CI)

> for Outbound queue are in DMA memory. These values should

> be reset to 0 during driver reinitialization.


Why "reinitialization", the function  init_default_table_values is
called from chip init?
>

> Signed-off-by: Viswas G <Viswas.G@microchip.com>

> Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com>

> Signed-off-by: Ashokkumar N <Ashokkumar.N@microchip.com>

> ---

>  drivers/scsi/pm8001/pm8001_hwi.c | 2 ++

>  drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++

>  2 files changed, 4 insertions(+)

>

> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c

> index 4e0ce044ac69..783149b8b127 100644

> --- a/drivers/scsi/pm8001/pm8001_hwi.c

> +++ b/drivers/scsi/pm8001/pm8001_hwi.c

> @@ -240,6 +240,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)

>                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

>                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

>                         pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;

> +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0);

>                 offsetib = i * 0x20;

>                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

>                         get_pci_bar_index(pm8001_mr32(addressib,

> @@ -268,6 +269,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)

>                         0 | (10 << 16) | (i << 24);

>                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

>                         pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;

> +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0);

>                 offsetob = i * 0x24;

>                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

>                         get_pci_bar_index(pm8001_mr32(addressob,

> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c

> index 1aa3a499c85a..0f2c57e054ac 100644

> --- a/drivers/scsi/pm8001/pm80xx_hwi.c

> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c

> @@ -787,6 +787,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)

>                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

>                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

>                         pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;

> +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0);

>                 offsetib = i * 0x20;

>                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

>                         get_pci_bar_index(pm8001_mr32(addressib,

> @@ -820,6 +821,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)

>                 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24);

>                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

>                         pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;

> +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0);

>                 offsetob = i * 0x24;

>                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

>                         get_pci_bar_index(pm8001_mr32(addressob,

> --

> 2.16.3

>
Viswas G March 4, 2021, 4:40 p.m. UTC | #2
> -----Original Message-----

> From: Jinpu Wang <jinpu.wang@cloud.ionos.com>

> Sent: Thursday, March 4, 2021 3:07 PM

> To: Viswas G - I30667 <Viswas.G@microchip.com>

> Cc: Linux SCSI Mailinglist <linux-scsi@vger.kernel.org>; Vasanthalakshmi

> Tharmarajan - I30664 <Vasanthalakshmi.Tharmarajan@microchip.com>;

> Ruksar Devadi - I52327 <Ruksar.devadi@microchip.com>; Vishakha

> Channapattan <vishakhavc@google.com>; Radha Ramachandran

> <radha@google.com>

> Subject: Re: [PATCH 6/7] pm80xx: Reset PI and CI memory during re-initialize

> 

> EXTERNAL EMAIL: Do not click links or open attachments unless you know the

> content is safe

> 

> On Wed, Feb 24, 2021 at 4:48 PM Viswas G <Viswas.G@microchip.com>

> wrote:

> >

> > Producer index(PI) outbound queue and consumer index(CI) for Outbound

> > queue are in DMA memory. These values should be reset to 0 during

> > driver reinitialization.

> 

> Why "reinitialization", the function  init_default_table_values is called from

> chip init?


Yes. This called from both probe() and resume(). During resume(), the stale PI and CI 
Values will leads to unexpected behavior.

> >

> > Signed-off-by: Viswas G <Viswas.G@microchip.com>

> > Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com>

> > Signed-off-by: Ashokkumar N <Ashokkumar.N@microchip.com>

> > ---

> >  drivers/scsi/pm8001/pm8001_hwi.c | 2 ++

> > drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++

> >  2 files changed, 4 insertions(+)

> >

> > diff --git a/drivers/scsi/pm8001/pm8001_hwi.c

> > b/drivers/scsi/pm8001/pm8001_hwi.c

> > index 4e0ce044ac69..783149b8b127 100644

> > --- a/drivers/scsi/pm8001/pm8001_hwi.c

> > +++ b/drivers/scsi/pm8001/pm8001_hwi.c

> > @@ -240,6 +240,7 @@ static void init_default_table_values(struct

> pm8001_hba_info *pm8001_ha)

> >                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

> >                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

> >                         pm8001_ha->memoryMap.region[ci_offset +

> > i].virt_ptr;

> > +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0,

> > + 0);

> >                 offsetib = i * 0x20;

> >                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

> >                         get_pci_bar_index(pm8001_mr32(addressib,

> > @@ -268,6 +269,7 @@ static void init_default_table_values(struct

> pm8001_hba_info *pm8001_ha)

> >                         0 | (10 << 16) | (i << 24);

> >                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

> >                         pm8001_ha->memoryMap.region[pi_offset +

> > i].virt_ptr;

> > +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0,

> > + 0);

> >                 offsetob = i * 0x24;

> >                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

> >                         get_pci_bar_index(pm8001_mr32(addressob,

> > diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c

> > b/drivers/scsi/pm8001/pm80xx_hwi.c

> > index 1aa3a499c85a..0f2c57e054ac 100644

> > --- a/drivers/scsi/pm8001/pm80xx_hwi.c

> > +++ b/drivers/scsi/pm8001/pm80xx_hwi.c

> > @@ -787,6 +787,7 @@ static void init_default_table_values(struct

> pm8001_hba_info *pm8001_ha)

> >                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

> >                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

> >                         pm8001_ha->memoryMap.region[ci_offset +

> > i].virt_ptr;

> > +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0,

> > + 0);

> >                 offsetib = i * 0x20;

> >                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

> >                         get_pci_bar_index(pm8001_mr32(addressib,

> > @@ -820,6 +821,7 @@ static void init_default_table_values(struct

> pm8001_hba_info *pm8001_ha)

> >                 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24);

> >                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

> >                         pm8001_ha->memoryMap.region[pi_offset +

> > i].virt_ptr;

> > +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0,

> > + 0);

> >                 offsetob = i * 0x24;

> >                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

> >                         get_pci_bar_index(pm8001_mr32(addressob,

> > --

> > 2.16.3

> >
Jinpu Wang March 5, 2021, 6:45 a.m. UTC | #3
On Thu, Mar 4, 2021 at 5:47 PM <Viswas.G@microchip.com> wrote:
>

>

> > -----Original Message-----

> > From: Jinpu Wang <jinpu.wang@cloud.ionos.com>

> > Sent: Thursday, March 4, 2021 3:07 PM

> > To: Viswas G - I30667 <Viswas.G@microchip.com>

> > Cc: Linux SCSI Mailinglist <linux-scsi@vger.kernel.org>; Vasanthalakshmi

> > Tharmarajan - I30664 <Vasanthalakshmi.Tharmarajan@microchip.com>;

> > Ruksar Devadi - I52327 <Ruksar.devadi@microchip.com>; Vishakha

> > Channapattan <vishakhavc@google.com>; Radha Ramachandran

> > <radha@google.com>

> > Subject: Re: [PATCH 6/7] pm80xx: Reset PI and CI memory during re-initialize

> >

> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the

> > content is safe

> >

> > On Wed, Feb 24, 2021 at 4:48 PM Viswas G <Viswas.G@microchip.com>

> > wrote:

> > >

> > > Producer index(PI) outbound queue and consumer index(CI) for Outbound

> > > queue are in DMA memory. These values should be reset to 0 during

> > > driver reinitialization.

> >

> > Why "reinitialization", the function  init_default_table_values is called from

> > chip init?

>

> Yes. This called from both probe() and resume(). During resume(), the stale PI and CI

> Values will leads to unexpected behavior.

Can you add this part to the commit message?
>

> > >

> > > Signed-off-by: Viswas G <Viswas.G@microchip.com>

> > > Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com>

> > > Signed-off-by: Ashokkumar N <Ashokkumar.N@microchip.com>

With that,
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>

> > > ---

> > >  drivers/scsi/pm8001/pm8001_hwi.c | 2 ++

> > > drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++

> > >  2 files changed, 4 insertions(+)

> > >

> > > diff --git a/drivers/scsi/pm8001/pm8001_hwi.c

> > > b/drivers/scsi/pm8001/pm8001_hwi.c

> > > index 4e0ce044ac69..783149b8b127 100644

> > > --- a/drivers/scsi/pm8001/pm8001_hwi.c

> > > +++ b/drivers/scsi/pm8001/pm8001_hwi.c

> > > @@ -240,6 +240,7 @@ static void init_default_table_values(struct

> > pm8001_hba_info *pm8001_ha)

> > >                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

> > >                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

> > >                         pm8001_ha->memoryMap.region[ci_offset +

> > > i].virt_ptr;

> > > +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0,

> > > + 0);

> > >                 offsetib = i * 0x20;

> > >                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

> > >                         get_pci_bar_index(pm8001_mr32(addressib,

> > > @@ -268,6 +269,7 @@ static void init_default_table_values(struct

> > pm8001_hba_info *pm8001_ha)

> > >                         0 | (10 << 16) | (i << 24);

> > >                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

> > >                         pm8001_ha->memoryMap.region[pi_offset +

> > > i].virt_ptr;

> > > +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0,

> > > + 0);

> > >                 offsetob = i * 0x24;

> > >                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

> > >                         get_pci_bar_index(pm8001_mr32(addressob,

> > > diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c

> > > b/drivers/scsi/pm8001/pm80xx_hwi.c

> > > index 1aa3a499c85a..0f2c57e054ac 100644

> > > --- a/drivers/scsi/pm8001/pm80xx_hwi.c

> > > +++ b/drivers/scsi/pm8001/pm80xx_hwi.c

> > > @@ -787,6 +787,7 @@ static void init_default_table_values(struct

> > pm8001_hba_info *pm8001_ha)

> > >                         pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;

> > >                 pm8001_ha->inbnd_q_tbl[i].ci_virt               =

> > >                         pm8001_ha->memoryMap.region[ci_offset +

> > > i].virt_ptr;

> > > +               pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0,

> > > + 0);

> > >                 offsetib = i * 0x20;

> > >                 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar            =

> > >                         get_pci_bar_index(pm8001_mr32(addressib,

> > > @@ -820,6 +821,7 @@ static void init_default_table_values(struct

> > pm8001_hba_info *pm8001_ha)

> > >                 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24);

> > >                 pm8001_ha->outbnd_q_tbl[i].pi_virt              =

> > >                         pm8001_ha->memoryMap.region[pi_offset +

> > > i].virt_ptr;

> > > +               pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0,

> > > + 0);

> > >                 offsetob = i * 0x24;

> > >                 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar           =

> > >                         get_pci_bar_index(pm8001_mr32(addressob,

> > > --

> > > 2.16.3

> > >
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 4e0ce044ac69..783149b8b127 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -240,6 +240,7 @@  static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 			pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;
 		pm8001_ha->inbnd_q_tbl[i].ci_virt		=
 			pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;
+		pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0);
 		offsetib = i * 0x20;
 		pm8001_ha->inbnd_q_tbl[i].pi_pci_bar		=
 			get_pci_bar_index(pm8001_mr32(addressib,
@@ -268,6 +269,7 @@  static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 			0 | (10 << 16) | (i << 24);
 		pm8001_ha->outbnd_q_tbl[i].pi_virt		=
 			pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;
+		pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0);
 		offsetob = i * 0x24;
 		pm8001_ha->outbnd_q_tbl[i].ci_pci_bar		=
 			get_pci_bar_index(pm8001_mr32(addressob,
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 1aa3a499c85a..0f2c57e054ac 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -787,6 +787,7 @@  static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 			pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;
 		pm8001_ha->inbnd_q_tbl[i].ci_virt		=
 			pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;
+		pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0);
 		offsetib = i * 0x20;
 		pm8001_ha->inbnd_q_tbl[i].pi_pci_bar		=
 			get_pci_bar_index(pm8001_mr32(addressib,
@@ -820,6 +821,7 @@  static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 		pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24);
 		pm8001_ha->outbnd_q_tbl[i].pi_virt		=
 			pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;
+		pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0);
 		offsetob = i * 0x24;
 		pm8001_ha->outbnd_q_tbl[i].ci_pci_bar		=
 			get_pci_bar_index(pm8001_mr32(addressob,