Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3757813pxt; Tue, 10 Aug 2021 10:37:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNzJvhg9nkhaxLJ5SpqnlDiIlDT6yupWsHhYqWBdlw4cpvqVg+2h8cnrXduqfMCadbRYS5 X-Received: by 2002:a17:906:4e08:: with SMTP id z8mr9255481eju.360.1628617024064; Tue, 10 Aug 2021 10:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617024; cv=none; d=google.com; s=arc-20160816; b=PxFX5Xn1aMiqrSOlVF0W7XnRCIBN2XbWAtxTw0KKNrRKL43JdiP87zaOxIIEt/6MQe +xhOvuvN3KcR9rDny2WRXeyKf7HaDy3x2iwYMEUJ5ikRrP7qqCXfl43xYDtfk4Jnstz3 Z4t8WEzBeYgTfRCvmwp8uM6Xhaet9qZ2Kqvl2Xe3N1qSmmguHp45daYkVQ6+x/ns3RRb 2PUwtqkqbp9b4fUyU7L+HMPybs2KoT/jzzp+27obDILsS5UGFG7DWw9FFFJXKrmmQXp2 pm6UVHXoNu4tHl8LWFFB97xTyFfHqopY/bwgdbKWDygL5WQEO1cqbQogYpjKaKikJ9PZ 5h1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GeFpH/Ti0RxkYkPFh+wRz0UKRcVBbwrhQHqaAmsxo2U=; b=K/WcU0J7i+KvHaCWCZQV5DWxpXr3e6Zet8CGOV4H0zeR13XwL+2oYY1pZ2DHDljkIG t2l+/AroPyTDsAcmrMZSVJFwpvTdC4GVKURgaGXYkAr65HV3f12v8qBJeFt1ZeKn9m2S P1q6DpALFKtgHuFEDImb3LyEexIrVTI6gnGvrP0FrG2k9D9xzDZKe8wHgj9I7vHqPt8Y 6w5XWIkLJH7xhPtDwGu5VPKuXx+UlzPyHflyRPT6GFzuiw8hge/5SVUv8cAG0HwdMknv W/EjwIKLH35VTphXM1yDJX/HnB8mjj0L63WjTozzOIWqGYaqeKVXKwQCcSKQAh9iVnd+ u1eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P5JWlNWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si273369ede.445.2021.08.10.10.36.38; Tue, 10 Aug 2021 10:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P5JWlNWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233095AbhHJReq (ORCPT + 99 others); Tue, 10 Aug 2021 13:34:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbhHJReB (ORCPT ); Tue, 10 Aug 2021 13:34:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 562B1610CF; Tue, 10 Aug 2021 17:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616818; bh=//W2AOkZKarKR/m0ISvGsAjaLCFLauuC4u1WBYKVT2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5JWlNWM5q/kyw/0Hwsm+WvMuFp1Z7cSssZER604cD1vOInLQ0dkfgHeKVb0cQR6e X7QfGD49P2M9VVVsyZk1kHB41SNnV+2lWCBjmqUuQrqug0mCvrl2eqYqS9R2ZQbPqe PJtzLR1UjfWMfKxRooocotGjkKKR91gBFTI7N7sw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 49/54] libata: fix ata_pio_sector for CONFIG_HIGHMEM Date: Tue, 10 Aug 2021 19:30:43 +0200 Message-Id: <20210810172945.820938473@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172944.179901509@linuxfoundation.org> References: <20210810172944.179901509@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit ecef6a9effe49e8e2635c839020b9833b71e934c ] Data transfers are not required to be block aligned in memory, so they span two pages. Fix this by splitting the call to >sff_data_xfer into two for that case. This has been broken since the initial libata import before the damn of git, but was uncovered by the legacy ide driver removal. Reported-by: kernel test robot Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20210709130237.3730959-1-hch@lst.de Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/ata/libata-sff.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 7484ffdabd54..ec62d26c32a9 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -657,6 +657,20 @@ unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc, unsigned char *buf, } EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); +static void ata_pio_xfer(struct ata_queued_cmd *qc, struct page *page, + unsigned int offset, size_t xfer_size) +{ + bool do_write = (qc->tf.flags & ATA_TFLAG_WRITE); + unsigned char *buf; + + buf = kmap_atomic(page); + qc->ap->ops->sff_data_xfer(qc, buf + offset, xfer_size, do_write); + kunmap_atomic(buf); + + if (!do_write && !PageSlab(page)) + flush_dcache_page(page); +} + /** * ata_pio_sector - Transfer a sector of data. * @qc: Command on going @@ -668,11 +682,9 @@ EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); */ static void ata_pio_sector(struct ata_queued_cmd *qc) { - int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); struct ata_port *ap = qc->ap; struct page *page; unsigned int offset; - unsigned char *buf; if (!qc->cursg) { qc->curbytes = qc->nbytes; @@ -690,13 +702,20 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); - /* do the actual data transfer */ - buf = kmap_atomic(page); - ap->ops->sff_data_xfer(qc, buf + offset, qc->sect_size, do_write); - kunmap_atomic(buf); + /* + * Split the transfer when it splits a page boundary. Note that the + * split still has to be dword aligned like all ATA data transfers. + */ + WARN_ON_ONCE(offset % 4); + if (offset + qc->sect_size > PAGE_SIZE) { + unsigned int split_len = PAGE_SIZE - offset; - if (!do_write && !PageSlab(page)) - flush_dcache_page(page); + ata_pio_xfer(qc, page, offset, split_len); + ata_pio_xfer(qc, nth_page(page, 1), 0, + qc->sect_size - split_len); + } else { + ata_pio_xfer(qc, page, offset, qc->sect_size); + } qc->curbytes += qc->sect_size; qc->cursg_ofs += qc->sect_size; -- 2.30.2