Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932782AbbHZHPC (ORCPT ); Wed, 26 Aug 2015 03:15:02 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:36275 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932653AbbHZHO7 (ORCPT ); Wed, 26 Aug 2015 03:14:59 -0400 Message-ID: <55DD676F.3060109@gmail.com> Date: Wed, 26 Aug 2015 09:14:55 +0200 From: Sergio Callegari User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Christoph Hellwig CC: Borislav Petkov , linux-kernel@vger.kernel.org Subject: Re: "scsi: convert host_busy to atomic_t" series causes regressions for some hardware configurations References: <20150625213140.GA16951@pd.tnic> <55D2E25C.7090201@gmail.com> <20150820080846.GA11599@infradead.org> <55DB4F5D.4070604@gmail.com> <20150825110057.GA30711@infradead.org> In-Reply-To: <20150825110057.GA30711@infradead.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2238 Lines: 84 Sure, thanks! I'll test this weekend. Best, Sergio On 25/08/2015 13:00, Christoph Hellwig wrote: > Hi Sergio, > > can you give the patch below a try? > > libata currently completes the SCSI command before freeing the internal > command structure, which could lead to various races that mess with > the ATA command state, which might cause issues like the one you see. > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > index 641a61a..92cc156 100644 > --- a/drivers/ata/libata-scsi.c > +++ b/drivers/ata/libata-scsi.c > @@ -1772,6 +1772,15 @@ nothing_to_do: > return 1; > } > > +static void ata_qc_done(struct ata_queued_cmd *qc) > +{ > + struct scsi_cmnd *cmd = qc->scsicmd; > + void (*done)(struct scsi_cmnd *) = qc->scsidone; > + > + ata_qc_free(qc); > + done(cmd); > +} > + > static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) > { > struct ata_port *ap = qc->ap; > @@ -1810,9 +1819,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) > if (need_sense && !ap->ops->error_handler) > ata_dump_status(ap->print_id, &qc->result_tf); > > - qc->scsidone(cmd); > - > - ata_qc_free(qc); > + ata_qc_done(qc); > } > > /** > @@ -2611,8 +2618,7 @@ static void atapi_sense_complete(struct ata_queued_cmd *qc) > ata_gen_passthru_sense(qc); > } > > - qc->scsidone(qc->scsicmd); > - ata_qc_free(qc); > + ata_qc_done(qc); > } > > /* is it pointless to prefer PIO for "safety reasons"? */ > @@ -2707,8 +2713,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) > qc->dev->sdev->locked = 0; > > qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; > - qc->scsidone(cmd); > - ata_qc_free(qc); > + ata_qc_done(qc); > return; > } > > @@ -2752,8 +2757,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) > cmd->result = SAM_STAT_GOOD; > } > > - qc->scsidone(cmd); > - ata_qc_free(qc); > + ata_qc_done(qc); > } > /** > * atapi_xlat - Initialize PACKET taskfile -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/