From patchwork Thu Jul 21 18:41:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9242315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C029B60871 for ; Thu, 21 Jul 2016 18:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B33FE268AE for ; Thu, 21 Jul 2016 18:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7CEB1FF10; Thu, 21 Jul 2016 18:43:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59B29268AE for ; Thu, 21 Jul 2016 18:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752283AbcGUSmy (ORCPT ); Thu, 21 Jul 2016 14:42:54 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36699 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753202AbcGUSmu (ORCPT ); Thu, 21 Jul 2016 14:42:50 -0400 Received: by mail-pf0-f195.google.com with SMTP id y134so5870356pfg.3; Thu, 21 Jul 2016 11:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7BSfy06fx+3TFgxjC5fICHdD0G03+CAf/MO1dwGXePw=; b=Pb+YlQ+YVyAHueh4FQVANjR2noLjTBDRGhu6zsKw5VovzTHRF2ZBr9wERhdlNq1f9R 0sPjKyjbfhzlUjTVwuA5KdUWVyjM7nYAtaFDuwa4m735bxudl0XsjkLR1ZhI0D+6g1x/ RNJtSd5l1yP3gz3CmenRMxCRnaCIVTlw50vl3O+5cLXjT72Myo343jn2IjLzbgR5WSVO C+NE6BohSIIJYYhndb0UJRqxSl8qZXCYTGAAO8nMHjLCEPyDx8dx6VgRrIM0TratC24L 260UOr3+wwduvUKByVGH4MN/KPGsDGH/rvfXDKm1VkVC8Q16OEnzccEheb3QMoVr+9xd OZeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7BSfy06fx+3TFgxjC5fICHdD0G03+CAf/MO1dwGXePw=; b=HOEbZCaT53afRwztRetV1oy7BH/AjTjjKY10QwXSEdrThhO+697fdHNrdEMg7JvGpK KmRrp+T8gIOZoZsX4Wpa8LtafoIUpzCKA3ovScQ3Cj5sIRmmprQeEw2wL5ZOKBQHRncH S3KZR+YMEWvkzmmmFHx5Ru2w27Yob1IsG14+GwEa4yznmvYohIOhSOdmh1n9eIGbHIl1 AzXaLfhbLSRZ84WjJ0AAVD55Mtm5NbCRvyA4JeaTh/0yZxJdrnOXUX0MdYoVk04gcHbR CCebeLZygn0ynFj5ygmLgOOyflu37c8iI5FWhHnNh4vFbRhsxWX06dW0iUUUaJ9PAyj0 6s/g== X-Gm-Message-State: ALyK8tICzQeCrapIQsKomyizczFTpN5HgKCi5LqxR6BhloQDNHmKQHqOEISual8iM5E/lg== X-Received: by 10.98.13.84 with SMTP id v81mr75559786pfi.108.1469126564480; Thu, 21 Jul 2016 11:42:44 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id j7sm14002691paa.30.2016.07.21.11.42.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 11:42:44 -0700 (PDT) From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, hare@suse.de, sergei.shtylyov@cogentembedded.com, arnd@arndb.de Cc: sfr@canb.auug.org.au, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, Tom Yan Subject: [PATCH resend 5/5] libata-scsi: fix MODE SELECT translation for Control mode page Date: Fri, 22 Jul 2016 02:41:54 +0800 Message-Id: <2ed3f3aba21a4b815e9497e6aeba497280f9f333.1469126217.git.tom.ty89@gmail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <14bd98eb08ddf86be28f558817bed3cd27c397cd.1469126217.git.tom.ty89@gmail.com> References: <14bd98eb08ddf86be28f558817bed3cd27c397cd.1469126217.git.tom.ty89@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Yan scsi_done() was called repeatedly and apparently because of that, the kernel would call trace when we touch the Control mode page: Call Trace: [] dump_stack+0x63/0x81 [] __warn+0xcb/0xf0 [] warn_slowpath_null+0x1d/0x20 [] ata_eh_finish+0xe0/0xf0 [libata] [] sata_pmp_error_handler+0x640/0xa50 [libata] [] ahci_error_handler+0x1d/0x70 [libahci] [] ata_scsi_port_error_handler+0x430/0x770 [libata] [] ? ata_scsi_cmd_error_handler+0xdd/0x160 [libata] [] ata_scsi_error+0xa7/0xf0 [libata] [] scsi_error_handler+0xaa/0x560 [scsi_mod] [] ? scsi_eh_get_sense+0x180/0x180 [scsi_mod] [] kthread+0xd8/0xf0 [] ret_from_fork+0x1f/0x40 [] ? kthread_worker_fn+0x170/0x170 ---[ end trace 8b7501047e928a17 ]--- Removed the unnecessary code and let ata_scsi_translate() do the job. Also, since ata_mselect_control() has no ATA command to send to the device, ata_scsi_mode_select_xlat() should return 1 for it, so that ata_scsi_translate() will finish early to avoid ata_qc_issue(). Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 6c424c5..f5c4200 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3720,8 +3720,6 @@ static int ata_mselect_control(struct ata_queued_cmd *qc, dev->flags |= ATA_DFLAG_D_SENSE; else dev->flags &= ~ATA_DFLAG_D_SENSE; - qc->scsicmd->result = SAM_STAT_GOOD; - qc->scsicmd->scsi_done(qc->scsicmd); return 0; } @@ -3854,6 +3852,8 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { fp += hdr_len + bd_len; goto invalid_param; + } else { + goto skip; /* No ATA command to send */ } break; default: /* invalid page code */