Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2044619rwl; Fri, 6 Jan 2023 00:49:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXsie+vaIQz4dhWhoqlwefMEyztsEoRHrE2lgL7FKhXvmrxlRM3pso0ul1K/KC8GnO+oWDQ+ X-Received: by 2002:a05:6402:241d:b0:482:9afc:c542 with SMTP id t29-20020a056402241d00b004829afcc542mr38668700eda.14.1672994954303; Fri, 06 Jan 2023 00:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672994954; cv=none; d=google.com; s=arc-20160816; b=CZtNf4BK+jms5RuThS4NJCOqvjaBvvVoEGMUAh1hMRhNVyBHy2HGbA0OK1l+u108Ib 9pAjWTCTDpddVWf5ut0xpYiNtu40HQma1zlBhCLFXArMzombyudzfZgPA2E6dsAoPzPg k5FwsHlICM3buKC+NMwieKVk+ASntdRekLJ8bvEs8MZqInuDwAIZ+okR1ueEHchKOmRA 4rmPYubsvsc8z0WJJFRawzdkZVznnTdD3+OWDzxnwRnkx6fyZgYWVic6cR87aP49gsSM jD9KB6g4s6OHgdA770E7aCS4BkPDZ9ji2pxYNPkEZHxW8ZQgNZp+fofzT4jEoeC8jH9n KGBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=EIjw4uNlK9SylmVBL8+cWonmcPGRxEV2L9l0u7AV8Gk=; b=r+O4CahLPZaNe4rKLgtPm/VEBUsausaH+0De7/WkAq7ntWHQDXW51HU5MrcsVYXhlL GdCgKNAi4+wsCTpKTLdlkK/wXMZeb5xuJRJhQYsk3LQDyl4RjEbmdxWdkZcM0fOrn9Qp vamuM9936rD3gFrjS3yEdHITCtJPUN3WIuMWmWa+CItCzwUN10RgGy8nBjgU7QM+A6Rr xekM2/CKPSmBlKjpUze1tTJv+Z2CIUPe6fAkHfGhPdp3dvzetOGR7G7/RIRn4r/oVvBi w6fNN4dveU1TQbyY3oIsYdaOrXYQBM9rEE9G3Rpd+sOKhcgQ6Cq2ktJDV/JayIX78XxC Hgnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020aa7d356000000b00485dea76f09si894483edr.634.2023.01.06.00.49.01; Fri, 06 Jan 2023 00:49:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjAFIiv (ORCPT + 54 others); Fri, 6 Jan 2023 03:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjAFIis (ORCPT ); Fri, 6 Jan 2023 03:38:48 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F26AF30; Fri, 6 Jan 2023 00:38:46 -0800 (PST) Received: from dggpemm500017.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NpGq64HNhzJq3M; Fri, 6 Jan 2023 16:34:42 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) by dggpemm500017.china.huawei.com (7.185.36.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 6 Jan 2023 16:38:44 +0800 Message-ID: <3108ffb4-c158-a5b1-b2a3-8bcdd1bba0ab@huawei.com> Date: Fri, 6 Jan 2023 16:38:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v3] ata: libata-eh: Cleanup ata_scsi_cmd_error_handler() Content-Language: en-US To: Damien Le Moal , , CC: , References: <20221215153749.1947570-1-haowenchao@huawei.com> <02d139a3-1886-dd6e-8812-dac4d292f064@opensource.wdc.com> From: Wenchao Hao In-Reply-To: <02d139a3-1886-dd6e-8812-dac4d292f064@opensource.wdc.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggpeml100006.china.huawei.com (7.185.36.169) To dggpemm500017.china.huawei.com (7.185.36.178) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/1/4 12:29, Damien Le Moal wrote: > On 12/16/22 00:37, Wenchao Hao wrote: >> If ap->ops->error_handler is NULL just return. This patch also >> fixes some comment style issue. >> >> --- >> v3: >> - Start with a "/*" empty line for multi-line comments. >> - Correct the commit subject >> >> v2: >> - Check ap->ops->error_handler without taking the spin lock >> >> Signed-off-by: Wenchao Hao > > Ah, so your SoB is here. Wrong patch format. The changelog needs to go > right below the "---" below here and your SoB above it. You added a "---" > above, which tells git that this is the end of the commit message and so > your SoB below it is ignored. I fixed that up when applying to for-6.3, > together with Niklas suggested edits. In the future, please format your > patches correctly. OK, I would use correct format in future patches. > >> --- >> drivers/ata/libata-eh.c | 101 +++++++++++++++++++++------------------- >> 1 file changed, 52 insertions(+), 49 deletions(-) >> >> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c >> index 34303ce67c14..56820b8e953a 100644 >> --- a/drivers/ata/libata-eh.c >> +++ b/drivers/ata/libata-eh.c >> @@ -565,13 +565,19 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, >> { >> int i; >> unsigned long flags; >> + struct scsi_cmnd *scmd, *tmp; >> + int nr_timedout = 0; >> >> /* make sure sff pio task is not running */ >> ata_sff_flush_pio_task(ap); >> >> + if (!ap->ops->error_handler) >> + return; >> + >> /* synchronize with host lock and sort out timeouts */ >> >> - /* For new EH, all qcs are finished in one of three ways - >> + /* >> + * For new EH, all qcs are finished in one of three ways - >> * normal completion, error completion, and SCSI timeout. >> * Both completions can race against SCSI timeout. When normal >> * completion wins, the qc never reaches EH. When error >> @@ -584,62 +590,59 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, >> * timed out iff its associated qc is active and not failed. >> */ >> spin_lock_irqsave(ap->lock, flags); >> - if (ap->ops->error_handler) { >> - struct scsi_cmnd *scmd, *tmp; >> - int nr_timedout = 0; >> - >> - /* This must occur under the ap->lock as we don't want >> - a polled recovery to race the real interrupt handler >> - >> - The lost_interrupt handler checks for any completed but >> - non-notified command and completes much like an IRQ handler. >> >> - We then fall into the error recovery code which will treat >> - this as if normal completion won the race */ >> - >> - if (ap->ops->lost_interrupt) >> - ap->ops->lost_interrupt(ap); >> + /* >> + * This must occur under the ap->lock as we don't want >> + * a polled recovery to race the real interrupt handler >> + * >> + * The lost_interrupt handler checks for any completed but >> + * non-notified command and completes much like an IRQ handler. >> + * >> + * We then fall into the error recovery code which will treat >> + * this as if normal completion won the race >> + */ >> + if (ap->ops->lost_interrupt) >> + ap->ops->lost_interrupt(ap); >> >> - list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { >> - struct ata_queued_cmd *qc; >> + list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { >> + struct ata_queued_cmd *qc; >> >> - ata_qc_for_each_raw(ap, qc, i) { >> - if (qc->flags & ATA_QCFLAG_ACTIVE && >> - qc->scsicmd == scmd) >> - break; >> - } >> + ata_qc_for_each_raw(ap, qc, i) { >> + if (qc->flags & ATA_QCFLAG_ACTIVE && >> + qc->scsicmd == scmd) >> + break; >> + } >> >> - if (i < ATA_MAX_QUEUE) { >> - /* the scmd has an associated qc */ >> - if (!(qc->flags & ATA_QCFLAG_FAILED)) { >> - /* which hasn't failed yet, timeout */ >> - qc->err_mask |= AC_ERR_TIMEOUT; >> - qc->flags |= ATA_QCFLAG_FAILED; >> - nr_timedout++; >> - } >> - } else { >> - /* Normal completion occurred after >> - * SCSI timeout but before this point. >> - * Successfully complete it. >> - */ >> - scmd->retries = scmd->allowed; >> - scsi_eh_finish_cmd(scmd, &ap->eh_done_q); >> + if (i < ATA_MAX_QUEUE) { >> + /* the scmd has an associated qc */ >> + if (!(qc->flags & ATA_QCFLAG_FAILED)) { >> + /* which hasn't failed yet, timeout */ >> + qc->err_mask |= AC_ERR_TIMEOUT; >> + qc->flags |= ATA_QCFLAG_FAILED; >> + nr_timedout++; >> } >> + } else { >> + /* Normal completion occurred after >> + * SCSI timeout but before this point. >> + * Successfully complete it. >> + */ >> + scmd->retries = scmd->allowed; >> + scsi_eh_finish_cmd(scmd, &ap->eh_done_q); >> } >> + } >> >> - /* If we have timed out qcs. They belong to EH from >> - * this point but the state of the controller is >> - * unknown. Freeze the port to make sure the IRQ >> - * handler doesn't diddle with those qcs. This must >> - * be done atomically w.r.t. setting QCFLAG_FAILED. >> - */ >> - if (nr_timedout) >> - __ata_port_freeze(ap); >> - >> + /* >> + * If we have timed out qcs. They belong to EH from >> + * this point but the state of the controller is >> + * unknown. Freeze the port to make sure the IRQ >> + * handler doesn't diddle with those qcs. This must >> + * be done atomically w.r.t. setting QCFLAG_FAILED. >> + */ >> + if (nr_timedout) >> + __ata_port_freeze(ap); >> >> - /* initialize eh_tries */ >> - ap->eh_tries = ATA_EH_MAX_TRIES; >> - } >> + /* initialize eh_tries */ >> + ap->eh_tries = ATA_EH_MAX_TRIES; >> spin_unlock_irqrestore(ap->lock, flags); >> >> } >