Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1773495imm; Thu, 27 Sep 2018 02:13:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62T3Wq6ZeKR2I494rXkMqXf6EX1/sZgtiwdskWDRHrSScOBJ0vRr543SrdIfLjo632bc3Sy X-Received: by 2002:a17:902:b287:: with SMTP id u7-v6mr9746083plr.123.1538039595113; Thu, 27 Sep 2018 02:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039595; cv=none; d=google.com; s=arc-20160816; b=YVn3/SZqDWxO3wcbHPXUaGn86prxrrhNREN6ur0Ii9rbysLhVA3toiwgIee8vAVtOe jsYJhY7fyXv8jSsHMT9X+/2937oMmYW5XdS6txkIOXBeKggK/amg2aE8Pgwlf5xTd1Oo UHReX5lHVSPRW6f50YEn9TiKSWtqeKEGlRDX3myLAU4q44rVXcgWed7z7lfwZzp0m/ic zta2bO6h0GhUeJ/GZAlf/kMeRXrzMTHA0//x+cknwfElHBf91vU1Yl/GFe+VDk1DSMps FEB9ORP0jyl59UM1OtEVNttJalgTzW9cLjNSzsW8QITW7vXkzCoxiRprEd9JP1FLj2RT qZjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=eQtmotjhJCiTVCn67iQBnhBxkakjinnbcSBQOtgpHRw=; b=pjBRWx9XTH5k5wAUAHfUuOWmwfEncB4v7LTwtDDZfvTc2VaV7px10mb70TG0KUYnmZ 4GJeCHiH/K9EWSYOHNeI+JTN5CFj5VOWkguHs0y8FwqwDa6+fc/CbID22IJBaQ927lvp JkbAMpb7JgdkX7WE3J4djNN8rnX5YqMrcVJXfSIFDfOUWBX9lHcb5VyoR+McE2BUoI68 fuYScMaxtkRodAnjT3cU3phEJgV57rO8ryjRqATB+8RtVrC4NSmsbBmEvP1OUSYAF2aY qSFPIV1LeZgir6hLx9C654MX22yjSCFz9/wBu3u4cDPJrxjJB2HsAE73hfJNshW46BQQ uPjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63-v6si1653444pfb.299.2018.09.27.02.13.00; Thu, 27 Sep 2018 02:13:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728343AbeI0P3S (ORCPT + 99 others); Thu, 27 Sep 2018 11:29:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55316 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbeI0P3S (ORCPT ); Thu, 27 Sep 2018 11:29:18 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B725610A4; Thu, 27 Sep 2018 09:12:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Sbarra , Jens Axboe Subject: [PATCH 4.18 59/88] libata: mask swap internal and hardware tag Date: Thu, 27 Sep 2018 11:03:40 +0200 Message-Id: <20180927090307.961382188@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe commit 7ce5c8cd753f9afa8e79e9ec40351998e354f239 upstream. hen we're comparing the hardware completion mask passed in from the driver with the internal tag pending mask, we need to account for the fact that the internal tag is different from the hardware tag. If not, then we can end up either prematurely completing the internal tag (since it's not set in the hw mask), or simply flag an error: ata2: illegal qc_active transition (100000000->00000001) If the internal tag is set, then swap that with the hardware tag in this case before comparing with what the hardware reports. Fixes: 28361c403683 ("libata: add extra internal command") Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=201151 Cc: stable@vger.kernel.org Reported-by: Paul Sbarra Tested-by: Paul Sbarra Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libata-core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5358,10 +5358,20 @@ void ata_qc_complete(struct ata_queued_c */ int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active) { + u64 done_mask, ap_qc_active = ap->qc_active; int nr_done = 0; - u64 done_mask; - done_mask = ap->qc_active ^ qc_active; + /* + * If the internal tag is set on ap->qc_active, then we care about + * bit0 on the passed in qc_active mask. Move that bit up to match + * the internal tag. + */ + if (ap_qc_active & (1ULL << ATA_TAG_INTERNAL)) { + qc_active |= (qc_active & 0x01) << ATA_TAG_INTERNAL; + qc_active ^= qc_active & 0x01; + } + + done_mask = ap_qc_active ^ qc_active; if (unlikely(done_mask & qc_active)) { ata_port_err(ap, "illegal qc_active transition (%08llx->%08llx)\n",