Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1462007yba; Sat, 6 Apr 2019 13:01:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9Ghsy2Ss34px0z8SH+ICuV0C/wIQp0i0ZRVitaDulLcGG9Hk0xjVfV8iZ+T1lIFi38wwd X-Received: by 2002:a17:902:9a89:: with SMTP id w9mr21010136plp.126.1554580885893; Sat, 06 Apr 2019 13:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554580885; cv=none; d=google.com; s=arc-20160816; b=mp5g+Nl9PKV3UG4PftPNCLuT+f0DD5s/o9maEdmQ39oaKxy8zSOOAjk+v4wueLLPI6 EyMr1T8+xyaLMPj76z8sdBY27Mpv2VKUXmQWSzuEwJhUE3HW2+qZ/PDieIij7iGT3WHw Xl4M1BrKXY9R9z0KjPfuxfXrLek5i9Zo5vrIf9nzeg34pYstVm5VDsySY+zRkkqxbxw8 XYtb2i+KuitEdi5elvZRXyVwQN2PBaVD8wPdBV9b1R8Izx/Zr27V4t7d0DrkrnWTcqUb L4AjVR7x7hgFh7X+qyF4NDYy2bvD4Xz6XWe1exQ2E1SyOuyX0MUk65CNnKRFmvH2bFef RR9g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=8EoY4E+zgTj6Q4a5jQreky8OFMQSbhywxdKKa+6Bhw8=; b=iZPva9HUeD6pJyY1geLFpqh4tcztxNV81/Lsz+F0Z8znrxXISuPmifR1iU2G4I171U mqll5diHgu920kKLZ+BGWGZ5/4zoqOV9VgCKMF3wYYgIjMJK1zmsqD5kD0Hv0AE3M4DB P24pjvSEC3qQZDdvzyykncVSh51pKC+2KyvuMGgLmYU5latgCFLOegVOOJ6Rvrq0Ax4x sPYa7jk3aPFH9zGtbFPlA5hhJB47HQbPy7Cq950FHL04Wb2z210lVa6JIwgzjT6W3W89 K4K0BPqCwbGVp+2R2qAZwrxbkFKN1W3yE0sF4DsnH6Bvfx4weW7Y6ZZNfD+9rdw16KM8 Ad0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=DyUpNqKw; 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 p17si22750901pgl.181.2019.04.06.13.00.55; Sat, 06 Apr 2019 13:01:25 -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; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=DyUpNqKw; 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 S1726676AbfDFT7k (ORCPT + 99 others); Sat, 6 Apr 2019 15:59:40 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34811 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbfDFT7k (ORCPT ); Sat, 6 Apr 2019 15:59:40 -0400 Received: by mail-lj1-f193.google.com with SMTP id j89so7996211ljb.1 for ; Sat, 06 Apr 2019 12:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8EoY4E+zgTj6Q4a5jQreky8OFMQSbhywxdKKa+6Bhw8=; b=DyUpNqKwyIkdP+97YYVMV2S/nTpHkJJiqqxKyyq0Ja+wQo9QpumaNfsr3/E7cPw8KV c702+kT9JCBHnnXb46wYzXvN48u5RodcbABTfAiRQ7pjjnIsulnE9irG7TvHA/Tua31k teUotVBpzxyQFwqloNOV8l6ruWSAGIqvDansJJq2NovA6tbsXvu+7vUWi/hJQcEvOyC9 I8MeM1MNUfnZPR7ZTMC7+M2NLyTHE0PajI+KlzHexyhQxvE4LJ3Gi8O5qzEtCddsqud1 0EKHcI2l6yVTCKgzQF4L0d2mu+0cEF4nL4CrFBjhLcGKl44WpfjmUVHdHjNOmXgXb9V/ uoYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=8EoY4E+zgTj6Q4a5jQreky8OFMQSbhywxdKKa+6Bhw8=; b=QEeNrhvwsgiBRmIOev6e3wO81idVB/0n3cKLvgKYD1tJXC0paBVYHvzawK+Icqv5XC gOVBPva5W0l/xFn6bu1Qevs5IYkmhexJif+hS0W2rT6krG5GsueYhoCfKVbRiEN3g5mw iKdayzoXsPB7Nh3/s3mJvKZmy/j63jqoNk+HLLyhSI5pjU5Hc/PIOzjFfqzOKmNXHh2s fobBVSbA+hYAZO4izz2xXvW2eaJXOF4BQ57AmBCvdDlt3YkCKSGTJF9uQZktpxJu8JbA BMbMhFPq4CCpsrlysTSrtPsZ4KMqRy8Cnn//tUtIXSoq+o78NBj7VQnf/lvHRVldqx3K zIRA== X-Gm-Message-State: APjAAAW0rFAFv/azelWv+6uldIBRm7FB19ZB+KyYJ3w7PPuTAFn7BguP 9SksvNubOKsmTrAMPD7skrglYg== X-Received: by 2002:a2e:9682:: with SMTP id q2mr10783137lji.168.1554580777355; Sat, 06 Apr 2019 12:59:37 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.86.164]) by smtp.gmail.com with ESMTPSA id c15sm5219115lfi.14.2019.04.06.12.59.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Apr 2019 12:59:36 -0700 (PDT) Subject: Re: [PATCH v9 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver To: Boris Brezillon Cc: masonccyang@mxic.com.tw, bbrezillon@kernel.org, broonie@kernel.org, devicetree@vger.kernel.org, Geert Uytterhoeven , Simon Horman , juliensu@mxic.com.tw, lee.jones@linaro.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-spi@vger.kernel.org, marek.vasut@gmail.com, mark.rutland@arm.com, robh+dt@kernel.org, zhengxunli@mxic.com.tw References: <1553847606-18122-1-git-send-email-masonccyang@mxic.com.tw> <1553847606-18122-3-git-send-email-masonccyang@mxic.com.tw> <231f7423-bf13-99f8-427b-530f5446348b@cogentembedded.com> <6d60bbef-a8ef-849e-33f3-3db35cefc09f@cogentembedded.com> <7467d695-8922-16b2-03d4-fb4bbdda125a@cogentembedded.com> <20190404211234.5468e7a4@collabora.com> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <724feb3b-2ef9-3ff4-8cad-586162fbc471@cogentembedded.com> Date: Sat, 6 Apr 2019 22:59:33 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20190404211234.5468e7a4@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-MW Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2019 10:12 PM, Boris Brezillon wrote: [...] >>>>>>> +static ssize_t rpc_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc, >>>>>>> + u64 offs, size_t len, void *buf) >>>>>>> +{ >>>>>>> + struct rpc_spi *rpc = >>>>>>> + spi_controller_get_devdata(desc->mem->spi->controller); >>>>>>> + int ret; >>>>>>> + >>>>>>> + if (offs + desc->info.offset + len > U32_MAX) >>>>>>> + return -EINVAL; >>>>>>> + >>>>>>> + if (len > 0x4000000) >>>>>>> + len = 0x4000000; >>>>>> >>>>>> Ugh... >>>>> >>>>> by mtd->size ? >>>> >>>> That'd be better, yes. >>>> >>> >>> Oops, it seems hard to get mtd->size info. from spi_mem_dirmap, >> >> It's in desc->info.length, no? > > It's the lengths of the mapping which not necessarily mtd->size, but in > the SPI NOR case it is :-). Anyway, you should not assume > dirmapdesc->info.length == memory_device->size. > >> >>> I would like to keep 0x4000000. >> >> I'm seeing Boris in the CC's... Boris, is it legitimate to limit >> a single dirmap read by the memory "window" size? Or should we try to >> serve any valid transfer length? > > If by memory window you're talking about the memory region reserved in Yes, we have 64 MiB window thru which we can "look into" the large MTD chips. > the CPU address space, then no. It should not be limited to this size > if possible. Mhm, so we're expected to loop incrementing the window address register in order to serve the full xfer request? > Most HW have a way to configure an offset to apply to the spi-mem operation, > and in that case, the driver should change this > offset on the fly when one tries to access a region that's outside of > the currently configured window. Well, my question wasn't about that actually -- that seemed quite obvious. >>>>>>> + >>>>>>> + ret = rpc_spi_set_freq(rpc, desc->mem->spi->max_speed_hz); >>>>>>> + if (ret) >>>>>>> + return ret; >>>>>>> + >>>>>>> + rpc_spi_mem_set_prep_op_cfg(desc->mem->spi, >>>>>>> + &desc->info.op_tmpl, &offs, &len); >>>>>>> + >>>>>>> + regmap_update_bits(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD, 0); >>>>>>> + regmap_write(rpc->regmap, RPC_DRCR, RPC_DRCR_RBURST(32) | >>>>>>> + RPC_DRCR_RBE); >>>>>>> + >>>>>>> + regmap_write(rpc->regmap, RPC_DRCMR, rpc->cmd); >>>>>>> + regmap_write(rpc->regmap, RPC_DREAR, RPC_DREAR_EAC(1)); >>>>>> >>>>>> So you're not even trying to support flashes larger than the >>>> read dirmap? >>>>>> Now I don't think it's acceptable (and I have rewritten this code >>>> internally). >>>>> >>>>> what about the size comes form mtd->size ? >>>> >>>> I'm not talking about size here; we should use the full address. >>>> I'm attaching >>>> my patch... >>> >>> okay,got it! >>> what about just >>> - regmap_write(rpc->mfd->regmap, RPC_DREAR, RPC_DREAR_EAC(1)); >>> + regmap_write(rpc->mfd->regmap, RPC_DREAR, >>> + RPC_DREAR_EAV(offs >> 25) | RPC_DREAR_EAC(1)); >>> >>> because only > 64MByte size make RPC_DREAR_EAV() work. >> >> Boris, what's your opinion on this? >> Note that for the write dirmap we have just 256-byte buffer (reusing >> the read cache). Is it legitimate to limit the served length to 256 bytes? > I don't know what the HW is capable of, As I said, there's 64 MiB read window, and for the writes we can re-use the read cache to write (exactly) 256 bytes at a time... > but drivers should use any try > they have to dynamically move the memory map window (make it point at a > different spi-mem offset on demand). Note that dirmap_read/write() are > allowed to return less than the amount of data requested, in that case > the caller should continue reading at the offset where things stopped. > This avoids having to implement a loop that splits things in several > accesses when the access cannot be done in one step. Ah, this somewhat contradicts what you said earlier but seems clear now. I'll go remove the loops. :-) MBR, Sergei