Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5255898iob; Mon, 9 May 2022 12:05:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1v/XrzxhNsZn7FOh8v9u4oR/Qx8FrxVRiSCAoRM+5KOBZBMTOEi4o+2cLLZvbSiv/+GCo X-Received: by 2002:a17:902:ba91:b0:15a:42f3:73ef with SMTP id k17-20020a170902ba9100b0015a42f373efmr17194492pls.162.1652123104031; Mon, 09 May 2022 12:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652123104; cv=none; d=google.com; s=arc-20160816; b=nOCsZWL7gjH242hwb+O03Ye2YaGgHKOZd+mdBIif9FGkM9vff0q/mT+6tvExhNcyi+ hzdJ3jSN0ZGbyZaE4SD0p8fUHEt5JTUluoQ+xeLTj2ZeSxCM96YM05Ybg7ybNT1keOww LJOLFWoQU+NnlW271eHGNPBLsz6s+WpNgQDUBaZ26mMj2dmTPl5sX2AZEf33O94kx09F WaUI9IWorUvR5BOa8vCtXKTRHY6w4ClZCGLPWPZ/m/vvCAoWpiGY4ZyvMZtlh8/NmlKa jFpNZuQ+cP42KJ25t66MimgWvsR6vhgpLOzBUqb4/zoiTYuUoI4JCLeUv70acTeq1OIb 75uw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fqTBattGAJtnrmVWrbgz/UotSXeK8Snx1e8ZFCucKYs=; b=LG29YAu0ZxPnq89I5Ou7BpZmdyclLysOlkDGzO3CCd+5hJnKytiGBAwxwV0/xAgLTq 7WomubX0OQ8SqDMIOsxZL1DonaRB6s66Dxu0Fdeqpwaw5NjnRCrWXJr8mhQ6D3ZQhwkC bJZEajHB+j0k3RPF0yT1LLExTZICfJdp5pTxq2+V6CujpX95d1zV2KQnP3wq+cJN9VjR 8g0L/GAUEVTFMZLXfgx3PCwZssgOy3LXV9wyNL2FHC8FhDBejFLYoqOM3tXXNtEQqOYb 4PnCP5xpvccWoXNJyjLXD8FlWZOAkEtO0lLwbiVg8BygqDYvSX3OKQ5gky0mOtrumigT O5CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@conchuod.ie header.s=google header.b="gDkG04/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=conchuod.ie Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x11-20020a170902ec8b00b0015eb782c600si695944plg.179.2022.05.09.12.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 12:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@conchuod.ie header.s=google header.b="gDkG04/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=conchuod.ie Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E848516D494; Mon, 9 May 2022 11:56:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240373AbiEITAZ (ORCPT + 99 others); Mon, 9 May 2022 15:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240346AbiEITAP (ORCPT ); Mon, 9 May 2022 15:00:15 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5441E14B65A for ; Mon, 9 May 2022 11:56:18 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id x18so20758176wrc.0 for ; Mon, 09 May 2022 11:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conchuod.ie; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=fqTBattGAJtnrmVWrbgz/UotSXeK8Snx1e8ZFCucKYs=; b=gDkG04/SNxmFNVgZf2d+irbN58bze6dLPrPLblpNEnpzyfg3yubPF3B0U6E/9ctDrq wDypkXp7VhgTOVfAjOJNBQyi9lUlwsMt4aaFQaHCtV3uO1VAvnq275wobPNDbf7yfbwe Z0cAPR50UUkVcwZ2RsCUw42jScMWc1ZPRVj9vg/Gqdws20DlniqLNg8FnWnDi5eYCfrL IDHf2CsiWeJj6vX0/5obzvHMoTII/wyc+8ZmGzQ+LUAuPPQ7ETeigSMuEPaltJpJAfpT LqE8Ai9WH0otikn32hI1NdPZdtEMqNVIVY8+UObjuuKmkzSg6ZsppWXPVmWcrSrik5uj 060A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fqTBattGAJtnrmVWrbgz/UotSXeK8Snx1e8ZFCucKYs=; b=1xz3FN4hC61bfD2rudMRY0d67XHzfEJ4kEttVIkH6+x/3+2xTRg+A1rq/OSm7JvNC8 g9TZF7MdHeQDB6wnRkwwGgfe65QkXpMIJzPxr/gnVFsLSdHExDVUeUkrwGdQNQU456b/ HK3VrwMBrcX2K76WWQDC2MSIVhNYFyVU9/HwIkf6CCe/K2bXTwjzWJxSO/tYWl9ucmrP ADBnT/gOrK7UQm2QveLrL9AG3GBc/L6H/Tc2/Oc3lX+nI6M3Ah9x5UWfbZHCHxtg8Ys3 8zm+PUk6yHI9+I3CPic7UE7qfbhfzpVqoAUKIuSVcsnek0QIcPHuZPEX+NOYDojlNXK7 BNvA== X-Gm-Message-State: AOAM532UG1ntx4k6wcBS9Yj+ZBGjLa6Tvct/7tUQAMUSEhcHXsFb9QtD ZHTMKgkPLkyBNwmdGfGvgfwfAg== X-Received: by 2002:adf:e941:0:b0:20a:d483:1bbc with SMTP id m1-20020adfe941000000b0020ad4831bbcmr15595525wrn.218.1652122576800; Mon, 09 May 2022 11:56:16 -0700 (PDT) Received: from [192.168.2.222] ([109.76.240.96]) by smtp.gmail.com with ESMTPSA id x22-20020a1c7c16000000b003942a244ecfsm71616wmc.20.2022.05.09.11.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 May 2022 11:56:16 -0700 (PDT) Message-ID: Date: Mon, 9 May 2022 19:56:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v11 2/3] fpga: microchip-spi: add Microchip MPF FPGA manager Content-Language: en-US To: Ivan Bornyakov , Conor.Dooley@microchip.com Cc: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-fpga@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, system@metrotek.ru References: <20220507074304.11144-1-i.bornyakov@metrotek.ru> <20220507074304.11144-3-i.bornyakov@metrotek.ru> <20220509171621.zk4owxwlngxjodgz@x260> From: Conor Dooley In-Reply-To: <20220509171621.zk4owxwlngxjodgz@x260> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/2022 18:16, Ivan Bornyakov wrote: > On Mon, May 09, 2022 at 11:41:18AM +0000, Conor.Dooley@microchip.com wrote: >> Hey Ivan, one comment below. >> Thanks, >> Conor. >> >> On 07/05/2022 08:43, Ivan Bornyakov wrote: >>> ... snip ... >>> +static int mpf_read_status(struct spi_device *spi) >>> +{ >>> + u8 status, status_command = MPF_SPI_READ_STATUS; >>> + struct spi_transfer xfer = { >>> + .tx_buf = &status_command, >>> + .rx_buf = &status, >>> + .len = 1, >>> + }; >>> + int ret = spi_sync_transfer(spi, &xfer, 1); >>> + >>> + if ((status & MPF_STATUS_SPI_VIOLATION) || >>> + (status & MPF_STATUS_SPI_ERROR)) >>> + ret = -EIO; >>> + >>> + return ret ? : status; >>> +} >>> + >>> ... snip ... >>> + >>> +static int poll_status_not_busy(struct spi_device *spi, u8 mask) >>> +{ >>> + int status, timeout = MPF_STATUS_POLL_TIMEOUT; >>> + >>> + while (timeout--) { >>> + status = mpf_read_status(spi); >>> + if (status < 0 || >>> + (!(status & MPF_STATUS_BUSY) && (!mask || (status & mask)))) >>> + return status; >>> + >>> + usleep_range(1000, 2000); >>> + } >>> + >>> + return -EBUSY; >>> +} >> >> Is there a reason you changed this from the snippet you sent me >> in the responses to version 8: >> static int poll_status_not_busy(struct spi_device *spi, u8 mask) >> { >> u8 status, status_command = MPF_SPI_READ_STATUS; >> int ret, timeout = MPF_STATUS_POLL_TIMEOUT; >> struct spi_transfer xfer = { >> .tx_buf = &status_command, >> .rx_buf = &status, >> .len = 1, >> }; >> >> while (timeout--) { >> ret = spi_sync_transfer(spi, &xfer, 1); >> if (ret < 0) >> return ret; >> >> if (!(status & MPF_STATUS_BUSY) && (!mask || (status & mask))) >> return status; >> >> usleep_range(1000, 2000); >> } >> >> return -EBUSY; >> } >> >> With the current version, I hit the "Failed to write bitstream >> frame" check in mpf_ops_write at random points in the transfer. >> Replacing poll_status_not_busy with the above allows it to run >> to completion. > > In my eyes they are equivalent, aren't they? > I was in a bit of a rush today & didn't have time to do proper debugging, I'll put some debug code in tomorrow and try to find exactly what is different between the two. Off the top of my head, since I don't have a board on me to test, the only difference I can see is that with the snippet you only checked if spi_sync_transfer was negative whereas now you check if it has a value at all w/ that ternary operator. But even that seems like it *shouldn't* be the problem, since ret should contain -errno or zero, right? Either way, I will do some digging tomorrow. Thanks, Conor.