Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5356378pxv; Wed, 7 Jul 2021 01:36:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJkAl3/JPyJhRnlMXnlVZTMCQmw95lwUZgQeF6ZqEZNh+kwf1WWO1DN6vpE2+hRoagh37W X-Received: by 2002:a17:907:2d0a:: with SMTP id gs10mr22631026ejc.207.1625647019250; Wed, 07 Jul 2021 01:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625647019; cv=none; d=google.com; s=arc-20160816; b=Yv8ndeaXwy0nrvdPVDTfZD/aoJLVbsM6cbnQpEM8enyiq47pGLKd/GUb7Z9zOr3Kuy uxkM4U21R6K327M5YIfn5JXPc/a+i8jdF3Mvr/wjmlwhHvv2Ce9W9gHzDOvsJ/BRJwUJ MDwTbH8Ja/786w9H+TcCrpyaGsak+RlBh7k99CqwojSo5QBokYK561/JRwcY4t5dJ8on U8wqYi+flgyidopkXtx3blabVaIxxK1G7Cv1jRQV8hmqCqR5aIGC4LaWTksjT/oJm10q C9IXQrg6XGcox9aOOCVOv1xZ5AC4mxTNalnhT4hlRjWDjg0jgXiTPazVv64lgYkSR+9d SN+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=awAhviWYOP8aZZucDzBMz+b8dD7+V6zw7/hTVugvR5s=; b=Xj/8RmVV+xVOMXfyi3vr555OLd2KxXG8cxiaghA7tnKEo78sTQ33lRiQwf+/26okZb YSvr8L6B44IptsU4677OoLfy2AEoa3DeKhOeiPZxERjWQhdcUfoKwtzWOP3aEE83gkRK 8WzWpi017q6/12iAyqWx9AeBNHmTvLdgckdcAEjmKirCepaplvO3E2iQedvgfVNao0bc SqWFgaETQssO1WQ1Rm7jbr3SsqIdT8XWAZiQpr9TgEUoJOz0q5spZUH5G5ljHr8/0k1l flg6aUM4dDgrEy+Rnr3gSO2kr3ZR4HzqDN8rPV+tYDYs5TJi8EcTq2oO01s+xN1V0cZO 84Vw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd21si11033363ejc.261.2021.07.07.01.36.35; Wed, 07 Jul 2021 01:36:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbhGGIiN (ORCPT + 99 others); Wed, 7 Jul 2021 04:38:13 -0400 Received: from verein.lst.de ([213.95.11.211]:36073 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhGGIiK (ORCPT ); Wed, 7 Jul 2021 04:38:10 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A40D268BEB; Wed, 7 Jul 2021 10:35:28 +0200 (CEST) Date: Wed, 7 Jul 2021 10:35:28 +0200 From: Christoph Hellwig To: Linus Torvalds Cc: Christoph Hellwig , kernel test robot , Jens Axboe , LKML , lkp@lists.01.org, kernel test robot , "H. Peter Anvin" , Borislav Petkov Subject: Re: [ide] b7fb14d3ac: EIP:ioread32_rep Message-ID: <20210707083528.GA353@lst.de> References: <20210704150025.GC21572@xsang-OptiPlex-9020> <20210705125756.GA25141@lst.de> <20210706143647.GA28289@lst.de> <20210707081220.GA31179@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210707081220.GA31179@lst.de> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 07, 2021 at 10:12:20AM +0200, Christoph Hellwig wrote: > On Tue, Jul 06, 2021 at 12:08:42PM -0700, Linus Torvalds wrote: > > On Tue, Jul 6, 2021 at 7:36 AM Christoph Hellwig wrote: > > > > > > Yeah, there's usually a huge offset into the page. The otherwise > > > similar ATAPI code actually has checks to chunk it up and not cross > > > page boundaries, and copying that over fixes the problem. > > > > Ok. > > > > Your patch made me go "I think it should loop until it has transferred > > the full 512 bytes", but maybe the caller loops properly? > > Yes, the callers (ata_read_pio_sectors) does). Actually, not it doesn't. Sorry. So for a non-aligned large request this won't work. So we'll need to actually loop here. This is probably better and fixes the issue as well (and ATAPI probably needs the same treatment): diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index ae7189d1a568..40d2dc3b2989 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -637,6 +637,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 @@ -648,11 +662,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; @@ -670,13 +682,15 @@ 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); + 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;