Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1638846rdb; Sat, 2 Dec 2023 04:06:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUXztjk7nGsd8tzQVVUdrdtRPBJ7HVFSc+WMsN36H9uCg04as4wyb7RTCHebbF8aEChO2H X-Received: by 2002:a05:6a20:1aaa:b0:187:20e1:eefc with SMTP id ci42-20020a056a201aaa00b0018720e1eefcmr208184pzb.17.1701518817349; Sat, 02 Dec 2023 04:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701518817; cv=none; d=google.com; s=arc-20160816; b=yJSAcghhVM8nBIcCBBcB38elWYxvlkQPlHXrWKoGiigCVGM+60e2EoOPF24rQVIK7/ ZtUPhN8vPO27heZp495Xof1jdx1R4bpT7VEwQIQ9FACz3C235mdcUr9ffxqYmBrqskpu DYDmlxUZEBJAfy8pecGsSSut7zAq5kw2QmrydzpDK+q3N92ZRdzSQi61YoHzs2x2oY42 N8qjN6UbYJCJf38J6u8Ymni0HNgNrYWQO/Tmp2uNuTpiVqbAA42oBGSf+21TECZgIqKz sOtGz0/NU4sxUpshpfIraU0GDN84NW+l4monscsfNTl1k+8Jtvs7zZFRbaANgJuePE2T 3zpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:content-language:references:cc:to:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=wBtqWrKnwnUVIlGOmEk1Gn03UZaztjLzJnpIKC6mSHQ=; fh=R5z3XicpYsEV6rtrr2PKz9ORQrFYOkIFQizMZtcEWqw=; b=i3IX2ac+XK3bcidgvJyIivQ51OuhqKJlDaRAlZrYkrsWGzxlTS6y7X+HfRylLu7g2V lIoORS8uMqAo2mw6ACsw7esLNcGPZdOJaK/XqKIN12x/lBSvLhuRO12YT7oJAe1YtTBd MEjbHCs9SZjDvuyeDPPDtrKPlctMFzNKbnChwYDDf7C/so1LGcPBouQK8Ye7YvtejRVs 11/+ecgz54XTX3hGV1xVSPh6f7RHAPPwMSFo07j2yLKZ/9i5LGmbWkcbooIZ5D/jqdA6 aq3pY797LZ4KYqKKg4SJ/q+9ybB/cKurF747vyb/ORzA/T4K12Zj12I5JJC3gPW2aua/ o4Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ra4lMt8x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a2-20020a170902ecc200b001d006d3b969si4875888plh.555.2023.12.02.04.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 04:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ra4lMt8x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D5C5F80BEF39; Sat, 2 Dec 2023 04:06:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbjLBMBo (ORCPT + 99 others); Sat, 2 Dec 2023 07:01:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjLBMBn (ORCPT ); Sat, 2 Dec 2023 07:01:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87CFA123 for ; Sat, 2 Dec 2023 04:01:49 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFB60C433C9; Sat, 2 Dec 2023 12:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701518509; bh=qGF18cj5rouLI1EH0KmHGn52Fmi+W0AJNsfWPtuN2qw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ra4lMt8xEm7aZSkJnkPN72ti44Ti5DIfsTJQqmyjLy907PoxtAFpV9zCl1c9jaJOA 8tUJo3wxPJj15A2X0GDshgVaaOIH2bOS4ZQ938qq5/EqOZ1nd4zX9p70DkG2MRJo/L uYJGbssiqgMv8xXFGm+UAMobvSl6HtCmZRKxa5gksqp0uskezGm/ubvcWmnv+mV328 PPCOrSYgAvfu8unQhiSh3Bb/GmjHgvSh3LY1zAQwQe4vWeRfHKtkXbNl4VhCrsACK3 fd3/T0hF85mOdPj2TichFRJy98nrxntBDoh1wHzlB1ralt5jN8KhLj+1s/gPKWNsVd 8NhpTj7c+iKsw== Message-ID: <5ccc0a13-01e1-464c-980b-bdf34970cc33@kernel.org> Date: Sat, 2 Dec 2023 13:01:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/5] w1: ds2490: support block sizes larger than 128 bytes in ds_read_block To: marc.ferland@gmail.com, krzysztof.kozlowski@linaro.org Cc: gregkh@linuxfoundation.org, marc.ferland@sonatest.com, jeff.dagenais@gmail.com, rdunlap@infradead.org, linux-kernel@vger.kernel.org References: <20231130135232.191320-1-marc.ferland@sonatest.com> <20231130135232.191320-2-marc.ferland@sonatest.com> Content-Language: en-US From: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BLHFTg2hYnLFJI4Xjg+AX1hHFVKmvl3VBHIsBv0oDcsQWXqY+NaFahT0lRPjYtrTa1v3tem/ JoFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20231130135232.191320-2-marc.ferland@sonatest.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 02 Dec 2023 04:06:55 -0800 (PST) On 30/11/2023 14:52, marc.ferland@gmail.com wrote: > From: Marc Ferland > > The current ds_read_block function only supports block sizes up to > 128 bytes, which is the depth of the 'data out' fifo on the ds2490. > > Reading larger blocks will fail with a: -110 (ETIMEDOUT) from > usb_control_msg(). Example: > > $ dd if=/sys/bus/w1/devices/43-000000478756/eeprom bs=256 count=1 > > yields to the following message from the kernel: > > usb 5-1: Failed to write 1-wire data to ep0x2: err=-110. > > I discovered this issue while implementing support for the ds28ec20 > eeprom in the w1-2433 driver. This driver accepts reading blocks of > sizes up to the size of the entire memory (2560 bytes in the case of > the ds28ec20). Note that this issue _does not_ arises when the kernel > is configured with CONFIG_W1_SLAVE_DS2433_CRC enabled since in this > mode the driver reads one 32 byte block at a time (a single memory > page). > > Also, from the ds2490 datasheet (2995.pdf, page 22, BLOCK I/O > command): > > For a block write sequence the EP2 FIFO must be pre-filled with > data before command execution. Additionally, for block sizes > greater then the FIFO size, the FIFO content status must be > monitored by host SW so that additional data can be sent to the > FIFO when necessary. A similar EP3 FIFO content monitoring > requirement exists for block read sequences. During a block read > the number of bytes loaded into the EP3 FIFO must be monitored so > that the data can be read before the FIFO overflows. > > Breaking the buffer in 128 bytes blocks and simply calling the > original code sequence has solved the issue for me. > > Tested with a DS1490F usb<->one-wire adapter and both the DS28EC20 and > DS2433 eeprom memories. > > Note: The v1 of this patch changed both the ds_read_block and > ds_write_block functions, but since I don't have any way to test the > 'write' part with writes bigger than a page size (maximum accepted by > my eeprom), I preferred not to make any assumptions and I just > removed that part. Drop that paragraph, not really helping to understand the commit once accepted. > > Signed-off-by: Marc Ferland > --- > drivers/w1/masters/ds2490.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c > index 5f5b97e24700..b6e244992c15 100644 > --- a/drivers/w1/masters/ds2490.c > +++ b/drivers/w1/masters/ds2490.c > @@ -98,6 +98,8 @@ > #define ST_EPOF 0x80 > /* Status transfer size, 16 bytes status, 16 byte result flags */ > #define ST_SIZE 0x20 > +/* 1-wire data i/o fifo size, 128 bytes */ > +#define FIFO_SIZE 0x80 > > /* Result Register flags */ > #define RR_DETECT 0xA5 /* New device detected */ > @@ -614,14 +616,11 @@ static int ds_read_byte(struct ds_device *dev, u8 *byte) > return 0; > } > > -static int ds_read_block(struct ds_device *dev, u8 *buf, int len) > +static int __read_block(struct ds_device *dev, u8 *buf, int len) Drop __ and name the function descriptive. It's confusing to have two times read_block(). Just name them according to what they really do. Best regards, Krzysztof