Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1512223 > unrolled thread
| Started by | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| First post | 2016-10-30 23:50 +0100 |
| Last post | 2016-10-31 04:40 +0100 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() Ondrej Zary <linux@rainbow-software.org> - 2016-10-30 23:50 +0100
Re: [PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() Finn Thain <fthain@telegraphics.com.au> - 2016-10-31 04:20 +0100
Re: [PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() Ondrej Zary <linux@rainbow-software.org> - 2016-10-31 09:10 +0100
Re: [PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() Finn Thain <fthain@telegraphics.com.au> - 2016-10-31 10:40 +0100
Re: [PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() Finn Thain <fthain@telegraphics.com.au> - 2016-10-31 04:40 +0100
| From | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| Date | 2016-10-30 23:50 +0100 |
| Subject | [PATCH 3/3] NCR5380: Check for chip presence in NCR5380_init() |
| Message-ID | <sy75o-2jv-9@gated-at.bofh.it> |
Read back MODE_REG after writing it in NCR5380_init() to check if the
chip is really there.
This prevents hang when incorrect I/O address was specified by user.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
drivers/scsi/NCR5380.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 01c0027..ce3156d 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -495,6 +495,11 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
NCR5380_write(MODE_REG, MR_BASE);
+ /* check if the chip is really there */
+ if (NCR5380_read(MODE_REG) != MR_BASE) {
+ NCR5380_exit(instance);
+ return -ENODEV;
+ }
NCR5380_write(TARGET_COMMAND_REG, 0);
NCR5380_write(SELECT_ENABLE_REG, 0);
--
Ondrej Zary
[toc] | [next] | [standalone]
| From | Finn Thain <fthain@telegraphics.com.au> |
|---|---|
| Date | 2016-10-31 04:20 +0100 |
| Message-ID | <sybiF-5ce-3@gated-at.bofh.it> |
| In reply to | #1512223 |
On Sun, 30 Oct 2016, Ondrej Zary wrote:
> Read back MODE_REG after writing it in NCR5380_init() to check if the
> chip is really there.
>
> This prevents hang when incorrect I/O address was specified by user.
>
> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> ---
> drivers/scsi/NCR5380.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index 01c0027..ce3156d 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -495,6 +495,11 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
>
> NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
> NCR5380_write(MODE_REG, MR_BASE);
> + /* check if the chip is really there */
> + if (NCR5380_read(MODE_REG) != MR_BASE) {
> + NCR5380_exit(instance);
> + return -ENODEV;
> + }
This doesn't belong in the core driver. Only the 5380 ISA drivers have
configurable base addresses.
Also, MR_BASE == 0, so that test is likely to be ineffectual anyway. This
patch doesn't really add any value AFAICT.
--
> NCR5380_write(TARGET_COMMAND_REG, 0);
> NCR5380_write(SELECT_ENABLE_REG, 0);
>
>
[toc] | [prev] | [next] | [standalone]
| From | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| Date | 2016-10-31 09:10 +0100 |
| Message-ID | <syfPj-89m-9@gated-at.bofh.it> |
| In reply to | #1512300 |
On Monday 31 October 2016, Finn Thain wrote:
> On Sun, 30 Oct 2016, Ondrej Zary wrote:
> > Read back MODE_REG after writing it in NCR5380_init() to check if the
> > chip is really there.
> >
> > This prevents hang when incorrect I/O address was specified by user.
> >
> > Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> > ---
> > drivers/scsi/NCR5380.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> > index 01c0027..ce3156d 100644
> > --- a/drivers/scsi/NCR5380.c
> > +++ b/drivers/scsi/NCR5380.c
> > @@ -495,6 +495,11 @@ static int NCR5380_init(struct Scsi_Host *instance,
> > int flags)
> >
> > NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
> > NCR5380_write(MODE_REG, MR_BASE);
> > + /* check if the chip is really there */
> > + if (NCR5380_read(MODE_REG) != MR_BASE) {
> > + NCR5380_exit(instance);
> > + return -ENODEV;
> > + }
>
> This doesn't belong in the core driver. Only the 5380 ISA drivers have
> configurable base addresses.
>
> Also, MR_BASE == 0, so that test is likely to be ineffectual anyway. This
> patch doesn't really add any value AFAICT.
This fixes the most common problem: no device present at the specified I/O
address, all reads result in 0xff.
--
Ondrej Zary
[toc] | [prev] | [next] | [standalone]
| From | Finn Thain <fthain@telegraphics.com.au> |
|---|---|
| Date | 2016-10-31 10:40 +0100 |
| Message-ID | <syhep-us-3@gated-at.bofh.it> |
| In reply to | #1512386 |
On Mon, 31 Oct 2016, Ondrej Zary wrote:
> On Monday 31 October 2016, Finn Thain wrote:
> > On Sun, 30 Oct 2016, Ondrej Zary wrote:
> > > Read back MODE_REG after writing it in NCR5380_init() to check if the
> > > chip is really there.
> > >
> > > This prevents hang when incorrect I/O address was specified by user.
> > >
> > > Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> > > ---
> > > drivers/scsi/NCR5380.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> > > index 01c0027..ce3156d 100644
> > > --- a/drivers/scsi/NCR5380.c
> > > +++ b/drivers/scsi/NCR5380.c
> > > @@ -495,6 +495,11 @@ static int NCR5380_init(struct Scsi_Host *instance,
> > > int flags)
> > >
> > > NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
> > > NCR5380_write(MODE_REG, MR_BASE);
> > > + /* check if the chip is really there */
> > > + if (NCR5380_read(MODE_REG) != MR_BASE) {
> > > + NCR5380_exit(instance);
> > > + return -ENODEV;
> > > + }
> >
> > This doesn't belong in the core driver. Only the 5380 ISA drivers have
> > configurable base addresses.
> >
> > Also, MR_BASE == 0, so that test is likely to be ineffectual anyway.
> > This patch doesn't really add any value AFAICT.
>
> This fixes the most common problem: no device present at the specified
> I/O address, all reads result in 0xff.
>
ISTR that's true for ISA in general, so I guess it would be okay in
g_NCR5380.c.
Better do this before NCR5380_init() so you can probe before allocating a
scsi host. Just write 0 to MODE_REG or SELECT_ENABLE_REG.
--
[toc] | [prev] | [next] | [standalone]
| From | Finn Thain <fthain@telegraphics.com.au> |
|---|---|
| Date | 2016-10-31 04:40 +0100 |
| Message-ID | <sybC6-5ja-11@gated-at.bofh.it> |
| In reply to | #1512223 |
On Sun, 30 Oct 2016, Ondrej Zary wrote:
> Read back MODE_REG after writing it in NCR5380_init() to check if the
> chip is really there.
>
> This prevents hang when incorrect I/O address was specified by user.
Do you know whereabouts in the driver the hang happens? Maybe there is a
robustness issue there.
Card type detection (and vacant slot detection) is a good idea but I'm not
sure how we can detect this chip reliably.
--
>
> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> ---
> drivers/scsi/NCR5380.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index 01c0027..ce3156d 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -495,6 +495,11 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
>
> NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
> NCR5380_write(MODE_REG, MR_BASE);
> + /* check if the chip is really there */
> + if (NCR5380_read(MODE_REG) != MR_BASE) {
> + NCR5380_exit(instance);
> + return -ENODEV;
> + }
> NCR5380_write(TARGET_COMMAND_REG, 0);
> NCR5380_write(SELECT_ENABLE_REG, 0);
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web