Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3756958imu; Mon, 14 Jan 2019 08:30:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN7eAp3KrzVuQid1/Dz5VV7pL3F/o6i0wDHck1g7iDkKC7DGCsNazGnFI7D7xOV/xSYTAV90 X-Received: by 2002:a62:442:: with SMTP id 63mr25716481pfe.156.1547483449406; Mon, 14 Jan 2019 08:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547483449; cv=none; d=google.com; s=arc-20160816; b=NjfV6hPjSAMS3h/xu6SstQ9yj/sFLUhey6QM/iwp2clphVHth3E2kC6vbdTHj52Exh KZlUO0Too+uymVD8nBysE1IXDMUF3ZfeUQu0rAr1/Tyuz+qW1rCQ7opjilGKzaq4/sKH cNn3VdQWVHyTTgVnkOduspy4GFpleEzDndN0Ln5MvGOpB6FE3pYgMbYMyL2sUgcaDLqD KDRm7ENiJCGegPDQxUIM6dREaZogzOB4xH0b5nnixISrLPN8Jr7yd8gNqv1OobAFHo30 59LS0EWjuk+gxMjW8fRRvqBXBklE5FZQnKceVeNtf13zLe20d6ceERZ032e7SV9QqEuY h2/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=A5cQcWgbQjYFw544uutW3MxtIejCvx84mGC5rsDJ3Uo=; b=bagLsz3fKkw9HrBLuXWxm4TIFJ0U2i+uii4BlwnOliDj6YraRWnMyqpx/INgqSI0H+ U7BCPat/J+gOqHpPB99TwITkH570ZoKF76tSBGRAvviqWiA9IFOv9Q3gc1lA7nVs+2Xx ymhNTl8JvKA5aO+/P7FiE3zRNYqG/IfoH+taaR6YS2xby43mR9KiAKTY2/jp57ItIBYz sTxfayKeWMhGec9LSWhv9oBltLdrjfu1X7UY+AAfUzoU0BqmSjTQYcpPY4npjQXdo3QH 5EDobye4oqdp4tjOfYFSDBCqhiXUomTERi9CkSmrEwH9VmLmD5WjMHxVWJM5oU6u5Mp3 TanA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jdn17jXh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si626428plc.364.2019.01.14.08.30.25; Mon, 14 Jan 2019 08:30:49 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=Jdn17jXh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbfANQ3M (ORCPT + 99 others); Mon, 14 Jan 2019 11:29:12 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:39836 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726708AbfANQ3M (ORCPT ); Mon, 14 Jan 2019 11:29:12 -0500 Received: by mail-qt1-f196.google.com with SMTP id u47so27167833qtj.6 for ; Mon, 14 Jan 2019 08:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=A5cQcWgbQjYFw544uutW3MxtIejCvx84mGC5rsDJ3Uo=; b=Jdn17jXhi5/Cb6MK2/K85r7Tc0CfKsJZgI/IyqenXtjyT7I1liyDG5P0lYQLaXshSX 8fM6j+jIg4LXs4aP6HvhyexqvoeLF1IwFwAmRBnrsgVLY+NoY70whcaTx18GJrHth3bi X2CdXlaX9eEmpLzviWdyuGf+3hyqiO9MQUMfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=A5cQcWgbQjYFw544uutW3MxtIejCvx84mGC5rsDJ3Uo=; b=QEu1ygQsdnsPC4aNb9SxI8T+Vlk0rkPOFXQF/G9/amZylOuhwHUwgT5X5gLBftTx4V J1bE9VbnUOcUrBrBuJ4jtp9Stwxz6bqCM3MBRWulXaNrmnlpMhVdoX1PEiHeysWBCB1R 7aaG7YNKtkYTKd0X1tfLm5Waqv+OGlk93IAc59yyFqmjmObrgj+1QaNANRnvSVR7SzKH SW9LZDM/Nuvc6w3OU3qEJG98mvIC0MW1PMDjNcjx5mIFVVVyGDe7d+ZoGYtV8NH+g26G Oi4yubw8dU9Kqmp/dY3vQ9a9hpdgsiXj22CgZW4kYTm4UBYgp9Lk31lK6xL/rcHSPbHy DKqA== X-Gm-Message-State: AJcUukfY2nZMCKzvuxjPYPUid+OGRG2EOc2UG6LB87rDjoh23luW1uPX DZ04QRhczu5C/nqZ6GfomPfhNg== X-Received: by 2002:ac8:60cb:: with SMTP id i11mr24962694qtm.360.1547483350790; Mon, 14 Jan 2019 08:29:10 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id l95sm7311992qkh.37.2019.01.14.08.29.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 08:29:09 -0800 (PST) Date: Mon, 14 Jan 2019 11:29:07 -0500 (EST) From: Nicolas Pitre To: Christoph Hellwig cc: Ulf Hansson , Russell King , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/11] mmc: mvsdio: handle highmem pages In-Reply-To: <20190114095804.27978-8-hch@lst.de> Message-ID: References: <20190114095804.27978-1-hch@lst.de> <20190114095804.27978-8-hch@lst.de> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Jan 2019, Christoph Hellwig wrote: > Instead of setting up a kernel pointer to track the current PIO address, > track the offset in the current page, and do an atomic kmap for the page > while doing the actual PIO operations. > > Signed-off-by: Christoph Hellwig Just a small suggestion below > --- > drivers/mmc/host/mvsdio.c | 48 +++++++++++++++++++++++---------------- > 1 file changed, 29 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c > index e22bbff89c8d..545e370d6dae 100644 > --- a/drivers/mmc/host/mvsdio.c > +++ b/drivers/mmc/host/mvsdio.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -42,7 +43,8 @@ struct mvsd_host { > unsigned int intr_en; > unsigned int ctrl; > unsigned int pio_size; > - void *pio_ptr; > + struct scatterlist *pio_sg; > + unsigned int pio_offset; /* offset in words into the segment */ > unsigned int sg_frags; > unsigned int ns_per_clk; > unsigned int clock; > @@ -96,9 +98,9 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) > if (tmout_index > MVSD_HOST_CTRL_TMOUT_MAX) > tmout_index = MVSD_HOST_CTRL_TMOUT_MAX; > > - dev_dbg(host->dev, "data %s at 0x%08x: blocks=%d blksz=%d tmout=%u (%d)\n", > + dev_dbg(host->dev, "data %s at 0x%08llx: blocks=%d blksz=%d tmout=%u (%d)\n", > (data->flags & MMC_DATA_READ) ? "read" : "write", > - (u32)sg_virt(data->sg), data->blocks, data->blksz, > + (u64)sg_phys(data->sg), data->blocks, data->blksz, > tmout, tmout_index); > > host->ctrl &= ~MVSD_HOST_CTRL_TMOUT_MASK; > @@ -118,10 +120,11 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) > * boundary. > */ > host->pio_size = data->blocks * data->blksz; > - host->pio_ptr = sg_virt(data->sg); > + host->pio_sg = data->sg; > + host->pio_offset = data->sg->offset / 2; > if (!nodma) > - dev_dbg(host->dev, "fallback to PIO for data at 0x%p size %d\n", > - host->pio_ptr, host->pio_size); > + dev_dbg(host->dev, "fallback to PIO for data at 0x%x size %d\n", > + host->pio_offset, host->pio_size); > return 1; > } else { > dma_addr_t phys_addr; > @@ -291,8 +294,9 @@ static u32 mvsd_finish_data(struct mvsd_host *host, struct mmc_data *data, > { > void __iomem *iobase = host->base; > > - if (host->pio_ptr) { > - host->pio_ptr = NULL; > + if (host->pio_sg) { > + host->pio_sg = NULL; > + host->pio_offset = 0; > host->pio_size = 0; > } else { > dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_frags, > @@ -376,11 +380,12 @@ static irqreturn_t mvsd_irq(int irq, void *dev) > if (host->pio_size && > (intr_status & host->intr_en & > (MVSD_NOR_RX_READY | MVSD_NOR_RX_FIFO_8W))) { > - u16 *p = host->pio_ptr; > + u16 *p = kmap_atomic(sg_page(host->pio_sg)); > + unsigned int o = host->pio_offset; To minimize code change, you could do: u16 *p0 = kmap_atomic(sg_page(host->pio_sg)); u16 *p = p0 + host->pio_offset; and at the end: host->pio_offset = p - p0; leaving the middle code unchanged. This might also produce slightly better assembly with the post increment instructions on ARM if the compiler doesn't figure it out on its own otherwise. Nicolas