Skip to contentSkip to conversation

esp_scsi, was Re: Modified Linux 4.1.20 (mac+scsi) on Quadra 660av

DISCUSSION Michael Schmitz 2 participants 6 messages Nov 1, 2016 – Nov 9, 2016 10 messages not in the archive

lore
Share & tools
lore
#10 lore raw
In reply to a message not in the archive

Hi Finn,

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

The SEL-with-ATN process is discussed in the "Configuration Register 3" section, Bit 3, in
http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR53C9X.txt

What chip revision is this doc for?

It can only be FAS100A. That's the document which David cited when he posted his ESP_CONFIG2_SCSI2ENAB patch in 2014, which is why I was using it. I think the documents Kars cited may be more relevant in this case:
http://www.spinics.net/lists/linux-scsi/msg73856.html
(those documents are all available from bitsavers).

Thanks, I'll look at those again.

Quoted 5 lines
Quoted 3 lines

As far as I can make out, it should be fas100a? The esp_scsi.h comments suggest the tagged queuing bit is for revisions fas236. The chips used on Macs were probably esp236 or fas236? Depending on the

The Quadras I've used have ESP236 chips, according to esp_scsi detection.

Right - we've already established that bit 6 (ESP_CONFIG3_TBMS) is what we need (plus possibly bit 5).

Quoted 9 lines
Quoted 8 lines

The ESP driver explicitly clears this bit and only sets it for the FAS236 variant (using it as fast clock bit there). The logic for setting a target's config3 value refer to the stored config for target 0, and the only place I can see that get initialized is again in esp_get_rev(). First to 5, then to 0 once it's clear the register even exists. We could set bit 3 here, but it may not matter for the chip revisions that we are interested in... Better set bit 6 (ESP_CONFIG3_TBMS) in our esp_slave_configure() hook?

Quoted 4 lines

That hook lets particular board-specific drivers disable particular features for particular targets. It would be better, I think, to fix this in the core driver, so that any target is free to use three byte messages regardless of the board-specific driver (except ESP100 I guess).

That would be the best solution, but from what I understand, no one has reported this bug for revisions > FAS236. I'd rather not touch these cases - can't test them.

Quoted 4 lines

Besides, ESP_CONFIG3_EWIDE == ESP_CONFIG3_TBMS, so this bit will get wiped in esp_reset_cleanup() anyway. Probably this should be conditional on FASHME. I think there's a similar bug in esp_data_bytes_sent().

Oops - these bits should be cleared only for FAS100A and HME. I don't think we redo domain validation after a bus reset so clearing the bits here means they are lost for good.
Can't spot a bug in esp_data_bytes_sent() though.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Anyway, is safe to do this?

        esp->ops->send_dma_cmd(esp, esp->command_block_dma,
                               2, 2, 1, ESP_CMD_DMA | ESP_CMD_TI);

        /* ACK the message.  */
        scsi_esp_cmd(esp, ESP_CMD_MOK);
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

For PIO and PDMA, the transfer will be finished before the MOK ("Message Accepted") command, but for DMA this seems to be racey...

It sure is racey. Is there a DMA complete interrupt that you can wait for before proceeding with the ACK?

That code comes from esp_reconnect_with_tag(). The interrupt you asked about never shows up, hence, "Reconnect IRQ2 timeout".

OK, I see the later loop to check for the FDONE status bit. If the ESP chip never reads in the missing tag bytes, we ACK a message that we haven't really fully received. But we're treating this as an error anyway so the cleanup will take care of that. In the normal case, I suppose the ESP chip has read all message bytes into the FIFO so the ACK there is probably OK.

Could be moved until after the IRQ2 checking loop to make sure (not certain what this'll do to the target - is there a max. time to ACK the message before the target stuffs up?).

Quoted 3 lines

Anyway, there must about 3 potential patches from this discussion. I say we do as Geert suggests and move the discussion to the kernel.org lists (with code, of course).

Agreed - the three patches I see so far would be

- set config2 SCSI2 enable bit as originally proposed by Dave,

- correct the esp_reset_cleanup() bug so a reset won't wipe out our config3 ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM bits

- set ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM for all targets in either esp_slave_configure() or esp_reset_esp()

Is that what you had in mind?

Cheers,

Michael

#11 lore raw
Quoted 7 lines · Michael Schmitz
Quoted 3 lines

It would be better, I think, to fix this in the core driver, so that any target is free to use three byte messages regardless of the board-specific driver (except ESP100 I guess).

That would be the best solution, but from what I understand, no one has reported this bug for revisions > FAS236. I'd rather not touch these cases - can't test them.

Even untested patches can carry low risk, given enough review, in which case we should avoid hacks.

Anyway, based on activity on the list, it seems likely that there are testers for the affected silicon. Besides ESP236 and FAS236, it is probably only FASHME and PCSCSI.

Quoted 11 lines
Quoted 6 lines

Besides, ESP_CONFIG3_EWIDE == ESP_CONFIG3_TBMS, so this bit will get wiped in esp_reset_cleanup() anyway. Probably this should be conditional on FASHME. I think there's a similar bug in esp_data_bytes_sent().

Oops - these bits should be cleared only for FAS100A and HME. I don't think we redo domain validation after a bus reset so clearing the bits here means they are lost for good. Can't spot a bug in esp_data_bytes_sent() though.

It's not a bug, it's just that ESP_CONFIG3_EWIDE == ESP_CONFIG3_TBMS:

	if (esp->prev_cfg3 & ESP_CONFIG3_EWIDE)
		fifo_cnt <<= 1;
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines

Anyway, is safe to do this?

        esp->ops->send_dma_cmd(esp, esp->command_block_dma,
                               2, 2, 1, ESP_CMD_DMA | ESP_CMD_TI);

        /* ACK the message.  */
        scsi_esp_cmd(esp, ESP_CMD_MOK);

For PIO and PDMA, the transfer will be finished before the MOK ("Message Accepted") command, but for DMA this seems to be racey...

It sure is racey. Is there a DMA complete interrupt that you can wait for before proceeding with the ACK?

Quoted 8 lines
Quoted 2 lines

That code comes from esp_reconnect_with_tag(). The interrupt you asked about never shows up, hence, "Reconnect IRQ2 timeout".

OK, I see the later loop to check for the FDONE status bit. If the ESP chip never reads in the missing tag bytes, we ACK a message that we haven't really fully received. But we're treating this as an error anyway so the cleanup will take care of that.

The question is, did we cause the error by releasing ACK during DMA.

But perhaps the chip is smart enough to handle the two commands
back-to-back: Transfer Information followed by Accept Message.

Quoted 6 lines

In the normal case, I suppose the ESP chip has read all message bytes into the FIFO so the ACK there is probably OK.

Could be moved until after the IRQ2 checking loop to make sure (not certain what this'll do to the target - is there a max. time to ACK the message before the target stuffs up?).

The complication is that the spec demands that certain messages be acknowleged with /ATN negated before the final negation of /ACK. I think that negating /ACK with /ATN asserted signals message rejection.

Perhaps that's the problem here: scsi_esp_cmd(esp, ESP_CMD_SATN) occurs after the transfer, but instead probably should be scsi_esp_cmd(esp, ESP_CMD_RATN) before scsi_esp_cmd(esp, ESP_CMD_MOK). It would be easy to believe that some targets don't tolerate this.

Anyway, I suspect our problem lies in this reselection message transfer, not in the configuration registers.

Quoted 9 lines
Quoted 4 lines

Anyway, there must about 3 potential patches from this discussion. I say we do as Geert suggests and move the discussion to the kernel.org lists (with code, of course).

Agreed - the three patches I see so far would be

- set config2 SCSI2 enable bit as originally proposed by Dave,

Quoted 7 lines

- correct the esp_reset_cleanup() bug so a reset won't wipe out our config3 ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM bits

- set ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM for all targets in either esp_slave_configure() or esp_reset_esp()

Is that what you had in mind?

Something like that. All of which is based on the notion that the config2 SCSI2 Enable bit could be useful for an initiator. But that notion looks more and more dubious to me --

What use could an initiator have for the Group Two Command Block bit (ESP_CONFIG3_GTM)?

What use could an initiator have for the QTAG Control bit (ESP_CONFIG3_TBMS) when the target never controls /ATN? (I only remembered this yesterday, so please ignore my earlier comments about reselection and SEL-with-ATN.)

Quoted 4 lines

Cheers,

Michael

#12 lore raw

Hi Finn,

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

Besides, ESP_CONFIG3_EWIDE == ESP_CONFIG3_TBMS, so this bit will get wiped in esp_reset_cleanup() anyway. Probably this should be conditional on FASHME. I think there's a similar bug in esp_data_bytes_sent().

Oops - these bits should be cleared only for FAS100A and HME. I don't think we redo domain validation after a bus reset so clearing the bits here means they are lost for good. Can't spot a bug in esp_data_bytes_sent() though.

Quoted 4 lines

It's not a bug, it's just that ESP_CONFIG3_EWIDE == ESP_CONFIG3_TBMS:

	if (esp->prev_cfg3 & ESP_CONFIG3_EWIDE)
		fifo_cnt <<= 1;

I see - having this bit set would have side effects here.

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

That code comes from esp_reconnect_with_tag(). The interrupt you asked about never shows up, hence, "Reconnect IRQ2 timeout".

OK, I see the later loop to check for the FDONE status bit. If the ESP chip never reads in the missing tag bytes, we ACK a message that we haven't really fully received. But we're treating this as an error anyway so the cleanup will take care of that.

Quoted 4 lines

The question is, did we cause the error by releasing ACK during DMA.

But perhaps the chip is smart enough to handle the two commands
back-to-back: Transfer Information followed by Accept Message.

You can queue two commands in the command fifo - the Accept Message would only be run once the Transfer Information is complete.

We can read back the command register to see which command was last excecuting (or still is). I suspect it's the Transfer Information here.

Quoted 3 lines

The complication is that the spec demands that certain messages be acknowleged with /ATN negated before the final negation of /ACK. I think that negating /ACK with /ATN asserted signals message rejection.

Yep, that's my reading as well.

Quoted 3 lines

Perhaps that's the problem here: scsi_esp_cmd(esp, ESP_CMD_SATN) occurs after the transfer, but instead probably should be scsi_esp_cmd(esp,

Where? In esp_reconnect, we don't get to that point when returning from esp_reconnect_with_tag() after timeout. And without timeout, there's still the check for ESP_CMD_FLAG_ABORT which I don't see set anywhere.

Quoted 5 lines

ESP_CMD_RATN) before scsi_esp_cmd(esp, ESP_CMD_MOK). It would be easy to believe that some targets don't tolerate this.

Anyway, I suspect our problem lies in this reselection message transfer, not in the configuration registers.

How does the target signal end of message in phase? Stop handshaking, or change phase? ATN going false?

With the DMA programmed for two tag bytes, and the reselection originating from a tagged command, I would expect the target to send the two tag bytes. Would it help to do the message transfer without DMA?

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines

Anyway, there must about 3 potential patches from this discussion. I say we do as Geert suggests and move the discussion to the kernel.org lists (with code, of course).

Agreed - the three patches I see so far would be

- set config2 SCSI2 enable bit as originally proposed by Dave,

- correct the esp_reset_cleanup() bug so a reset won't wipe out our config3 ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM bits

- set ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM for all targets in either esp_slave_configure() or esp_reset_esp()

Quoted 8 lines
Quoted 1 line

Is that what you had in mind?

Something like that. All of which is based on the notion that the config2 SCSI2 Enable bit could be useful for an initiator. But that notion looks more and more dubious to me --

What use could an initiator have for the Group Two Command Block bit (ESP_CONFIG3_GTM)?

Upon closer reading of the docs, none.

Quoted 4 lines

What use could an initiator have for the QTAG Control bit (ESP_CONFIG3_TBMS) when the target never controls /ATN? (I only remembered this yesterday, so please ignore my earlier comments about reselection and SEL-with-ATN.)

I had thought the reselection process similar to selection. But if the target does not signal further message bytes by keepin ATN asserted, that bit might not matter here.

Are we dealing with SCSI disks that fool the domain validation into assuming tagged queuing capability, and then ignore the tag message bytes, sending only the identify message byte on reselection?

Trying to make reconnect_with_tag work for these disks would be foolish indeed ...

Cheers,

Michael

#13 lore raw

Wed, 2 Nov 2016 20:53:50 +1100 (AEDT)

Quoted 5 lines · Michael Schmitz
Quoted 4 lines

The complication is that the spec demands that certain messages be acknowleged with /ATN negated before the final negation of /ACK. I think that negating /ACK with /ATN asserted signals message rejection.

Quoted 8 lines

Yep, that's my reading as well.

Quoted 3 lines

Perhaps that's the problem here: scsi_esp_cmd(esp, ESP_CMD_SATN) occurs after the transfer,

Where? In esp_reconnect, we don't get to that point when returning from esp_reconnect_with_tag() after timeout.

Well, the point is, we potentially release ACK (either after the Information Transfer command or after the Accept Message command) with ATN still asserted.

Quoted 2 lines

And without timeout, there's still the check for ESP_CMD_FLAG_ABORT which I don't see set anywhere.

I don't know what that's about. The git history may explain where it comes from.

Quoted 10 lines
Quoted 7 lines

but instead probably should be scsi_esp_cmd(esp, ESP_CMD_RATN) before scsi_esp_cmd(esp, ESP_CMD_MOK). It would be easy to believe that some targets don't tolerate this.

Anyway, I suspect our problem lies in this reselection message transfer, not in the configuration registers.

How does the target signal end of message in phase? Stop handshaking, or change phase?

Either would do. To stop handshaking would imply entering bus free phase.

Quoted 1 line

ATN going false?

AIUI, only the initiator can drive ATN.

Quoted 4 lines

With the DMA programmed for two tag bytes, and the reselection originating from a tagged command, I would expect the target to send the two tag bytes.

Sure, but I think the initator is messing it up along the way.

Quoted 1 line

Would it help to do the message transfer without DMA?

I would, just to see more clearly what was going on (command queue, control lines, bus phase).

Recall that Tuomas said he tried PIO for this with zorro_esp without any improvement. And I first saw this bug on a Quadra 660av, on which mac_esp uses PIO for all transfers.

Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines

Anyway, there must about 3 potential patches from this discussion. I say we do as Geert suggests and move the discussion to the kernel.org lists (with code, of course).

Agreed - the three patches I see so far would be

- set config2 SCSI2 enable bit as originally proposed by Dave,

- correct the esp_reset_cleanup() bug so a reset won't wipe out our config3 ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM bits

- set ESP_CONFIG3_TBMS and ESP_CONFIG3_GTM for all targets in either esp_slave_configure() or esp_reset_esp()

Quoted 8 lines
Quoted 1 line

Is that what you had in mind?

Something like that. All of which is based on the notion that the config2 SCSI2 Enable bit could be useful for an initiator. But that notion looks more and more dubious to me --

What use could an initiator have for the Group Two Command Block bit (ESP_CONFIG3_GTM)?

Upon closer reading of the docs, none.

Quoted 8 lines
Quoted 4 lines

What use could an initiator have for the QTAG Control bit (ESP_CONFIG3_TBMS) when the target never controls /ATN? (I only remembered this yesterday, so please ignore my earlier comments about reselection and SEL-with-ATN.)

I had thought the reselection process similar to selection. But if the target does not signal further message bytes by keepin ATN asserted, that bit might not matter here.

If only the initator drives ATN, the documentation can only be referring to an ESP device in target mode.

Quoted 4 lines

Are we dealing with SCSI disks that fool the domain validation into assuming tagged queuing capability, and then ignore the tag message bytes, sending only the identify message byte on reselection?

I don't think so.

Quoted 3 lines

Trying to make reconnect_with_tag work for these disks would be foolish indeed ...

My recollection from 2009 is that this particular disk did work with mac_esp on one of my Quadras, but not on my 660av. And three people have reported the problem now (to my knowledge) so I don't blame the disks.

Quoted 9 lines

Cheers,

Michael
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

Hi Finn,

got sidetracked once again ...

Quoted 6 lines
Quoted 2 lines

Where? In esp_reconnect, we don't get to that point when returning from esp_reconnect_with_tag() after timeout.

Well, the point is, we potentially release ACK (either after the Information Transfer command or after the Accept Message command) with ATN still asserted.

Who asserts ATN in case of reselection? I always thought that the target, by initiating reselection, assumes the role of initiator and is in charge of driving bus phase changes (including control of ATN).

Quoted 8 lines
Quoted 2 lines

How does the target signal end of message in phase? Stop handshaking, or change phase?

Either would do. To stop handshaking would imply entering bus free phase.

Quoted 1 line

ATN going false?

AIUI, only the initiator can drive ATN.

So the initiator would have to read two tag message bytes if a target reselects that had a tagged command disconnected? From the initiator side, that should work (if an untagged commmand has been issued, no tagged commands are sent so we expect either tagged or untagged reselections).

Quoted 5 lines
Quoted 3 lines

With the DMA programmed for two tag bytes, and the reselection originating from a tagged command, I would expect the target to send the two tag bytes.

Sure, but I think the initator is messing it up along the way.

Can't see how - reconnect_with_tag() is only used if no untagged command is on record for the target.

Quoted 5 lines
Quoted 2 lines

Would it help to do the message transfer without DMA?

I would, just to see more clearly what was going on (command queue, control lines, bus phase).

Not sure we can get control lines read - bus phases are available IIRC.

Quoted 3 lines

Recall that Tuomas said he tried PIO for this with zorro_esp without any improvement. And I first saw this bug on a Quadra 660av, on which mac_esp uses PIO for all transfers.

PIO does get set up for the expected number of message bytes though. Is there a check for phase mismatch during PIO?

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

What use could an initiator have for the QTAG Control bit (ESP_CONFIG3_TBMS) when the target never controls /ATN? (I only remembered this yesterday, so please ignore my earlier comments about reselection and SEL-with-ATN.)

I had thought the reselection process similar to selection. But if the target does not signal further message bytes by keepin ATN asserted, that bit might not matter here.

If only the initator drives ATN, the documentation can only be referring to an ESP device in target mode.

The documentation mentions a command descriptor block to be transferred
- would only apply to ESP in target mode again.

Quoted 3 lines

My recollection from 2009 is that this particular disk did work with mac_esp on one of my Quadras, but not on my 660av. And three people have reported the problem now (to my knowledge) so I don't blame the disks.

What ESP versions are used in the Quadras vs 660av?

Cheers,

Michael

#15 lore raw
Quoted 9 lines · Michael Schmitz
Quoted 4 lines

Well, the point is, we potentially release ACK (either after the Information Transfer command or after the Accept Message command) with ATN still asserted.

Who asserts ATN in case of reselection? I always thought that the target, by initiating reselection, assumes the role of initiator and is in charge of driving bus phase changes (including control of ATN).

The difference between selection and reselection is the SEL signal. For selection, the host controls SEL. For reselection, the device controls it.

If the device disconnects and reconnects a command, it doesn't alter the initiator/target roles for that command. The host always controls ATN.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

How does the target signal end of message in phase? Stop handshaking, or change phase?

Either would do. To stop handshaking would imply entering bus free phase.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

ATN going false?

AIUI, only the initiator can drive ATN.

So the initiator would have to read two tag message bytes if a target reselects that had a tagged command disconnected?

Right, the target contols the bus phase, so it will send as many bytes as it wants. The initiator gets to alter that behaviour by signalling with ATN. Hence esp_scsi needs to be more careful with ATN during reselection.

Quoted 4 lines

From the initiator side, that should work (if an untagged commmand has been issued, no tagged commands are sent so we expect either tagged or untagged reselections).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

With the DMA programmed for two tag bytes, and the reselection originating from a tagged command, I would expect the target to send the two tag bytes.

Sure, but I think the initator is messing it up along the way.

Can't see how - reconnect_with_tag() is only used if no untagged command is on record for the target.

Please see prior discussion of "Queue Tag Enable" bit, which relates to target response to ACK with and without ATN. Please also refer to the first para quoted at the top of this message.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Would it help to do the message transfer without DMA?

I would, just to see more clearly what was going on (command queue, control lines, bus phase).

Quoted 9 lines

Not sure we can get control lines read - bus phases are available IIRC.

Quoted 3 lines

Recall that Tuomas said he tried PIO for this with zorro_esp without any improvement. And I first saw this bug on a Quadra 660av, on which mac_esp uses PIO for all transfers.

PIO does get set up for the expected number of message bytes though. Is there a check for phase mismatch during PIO?

There is in mac_esp. But you really need to try it.

Quoted 4 lines
Quoted 3 lines

If only the initator drives ATN, the documentation can only be referring to an ESP device in target mode.

Quoted 8 lines

The documentation mentions a command descriptor block to be transferred
- would only apply to ESP in target mode again.

Quoted 3 lines

My recollection from 2009 is that this particular disk did work with mac_esp on one of my Quadras, but not on my 660av. And three people have reported the problem now (to my knowledge) so I don't blame the disks.

What ESP versions are used in the Quadras vs 660av?

All are ESP236 according to esp_scsi detection.

Quoted 7 lines

Cheers,

Michael