From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F664199E9D for ; Mon, 30 Jun 2025 10:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751280405; cv=none; b=IwJhru8dHavTqOINQ8QvsqHoADC0EuHx6mTNtng0bEFNrpOg9sCZf+vC/ScFic23Q9hYMiVy4buuds1zFHLcikUR5QdcvA3Bor4wpVgVuo0Z/ItcW0cPrx8MOT2MfuYpDbXzSPMiamNhzfR01/rCQ1Ib+8s7TWAI+J2WjSlH/Rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751280405; c=relaxed/simple; bh=gvyprsey8lBq/cwWETIidXRcGflIGW0KiZP0ucqQnYU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aOzXPTWQRCN26fPsVcXhJ6rDkW2VglfzsDjOTbovIrLYiGHTuLIB9fiYW9+0fQs7eOgdC+R9UaNhfd3wskTGt+ye39hvmMZhhq8pUDIgRXV83kw4Tt++4G7ytm9KaxNP7/NmIL1KLdxKrrRVX7CH1v8YYXo7MZ2fSDPWkodQqic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QS2cHGEF; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QS2cHGEF" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-453634d8609so29497685e9.3 for ; Mon, 30 Jun 2025 03:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1751280401; x=1751885201; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HFNukEVeOuH7fRtCazTP0zdNBYQLRBbJSaq5WQ9/jSE=; b=QS2cHGEF0LCLKtTg56W65PZeV1MqSaN02Tm+mgecpDqNuc5cIe35Kih5HZjpMTYC5N GkfIam99sy2VzrR8JlhMvB2VqlTLJoNmd8b+8U4Ec1kYnRYcBek/TGw1jEHxUPmww03M dhICwFjJU3J5sLY4MpSCWuTpdJqjhtlctrQ0OoLmWZ3dwN8o2jXWnuJRwN6JP5p1f4zE bBQFhSgO1WbHWqCTajzN1jiS4llT7SIrVOYVv3Lv1K5k7nJo3LhBRtuaumeZGfBzz9tk 2j8bIOY7iLGblJDSgk9IziJXg4soNEhkCb673xARi3emBk0USPAbHjuOcB3KbafIFiLh +1Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751280401; x=1751885201; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HFNukEVeOuH7fRtCazTP0zdNBYQLRBbJSaq5WQ9/jSE=; b=GRgmeuNmwM3c1H1gKnX8BFyH0DwUvi/4sJrUX0E662Ck1rSz0qHgUtepJ0SxecUsN2 qiBnnl7lgdjUCzYvuD5MXxgo+lwYQdiyBaHWIIjrUuXRS+a+AxXZ2nBydbwE5pUePZxG iSULxMeWtEtz3hVcZgfQuKQ9ZBzCq+VrHkGlz1eBPn9mByEivIIIJ7IADur+Q84/PVZe hENwDsher/gfooMBP8vkcOCM2OiUF/bLLhJkWcexI3O0/b1e/J5PrNx+umvHbz1BdaWM SjBlKoONlGTjjFhCv+3w5Y730K67kHROnrjNMA7fvMAVfHFhGhCTAow+P2hYfhvsKYXc vo9A== X-Forwarded-Encrypted: i=1; AJvYcCX2d0pBrM+u5ZJGKy1/cbTBspmE8j9zuHSS0QRmGIJC6vxiGel/S3mpTBa2oW9Uh9YAz+OqcBeQwEA1URk=@vger.kernel.org X-Gm-Message-State: AOJu0YxFYhHMUYfJlYAcCDvocnXb8unG6/4Rgw9k6wYeNUozKNsdVwXg NgxghdZSvRihINYwu2IlJsxXPdNKV9VNNeE9p/YAlhMA1qOlHavJb7PNglsOoUTevLo= X-Gm-Gg: ASbGncuHSLnKLg+q597venzDZ0lkdm0BKC4BwlhPVs4g488q77Yp0PoypUByQrA23e7 IIw/ETf95NOfZfgE5CcmvB6SEfEDPthprCbFNU0Tm8AgUm2bsbQkasbyQyuRhCpJBgTBDnbCsH5 IGy5an/R052IeVMMLEh8/Ye4SfRNQfkxr0XAxjFL2WlzFQc0L1Vj4+lrL4AIirFIuc8f6RJqIyB hke1PIx0SIDU9YJW8Vbwa/6m2ntOgJVMk3NG6KsMngs6bZ3vghj1VIiTMKuU7XUSJRVsapaxBRH 4on9SkHRODiHeM76R5yfdviegcTCEuqDDgaLdz1w4oF7/7cvS5dNz/yH7RHUwqDOrEc= X-Google-Smtp-Source: AGHT+IELSI+nHvc6/8x9c+zD3eFzVE2pjiOsqeuYSJZ1xJs78DtrT3WanbqFwCoHNk3vMxHy8BC9hg== X-Received: by 2002:a05:6000:2013:b0:3a4:f7dc:8a62 with SMTP id ffacd0b85a97d-3a8f2f34f7cmr10696844f8f.0.1751280401373; Mon, 30 Jun 2025 03:46:41 -0700 (PDT) Received: from [192.168.1.3] ([37.18.136.128]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-453814ae64fsm106803355e9.1.2025.06.30.03.46.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 03:46:41 -0700 (PDT) Message-ID: Date: Mon, 30 Jun 2025 11:46:40 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/6] spi: spi-fsl-dspi: Report FIFO overflows as errors To: Mark Brown , Frank Li Cc: Vladimir Oltean , Vladimir Oltean , Arnd Bergmann , Larisa Grigore , Christoph Hellwig , linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org References: <20250627-james-nxp-spi-dma-v4-0-178dba20c120@linaro.org> <20250627-james-nxp-spi-dma-v4-6-178dba20c120@linaro.org> <22d69113-fec0-4405-872d-af76bd038c09@sirena.org.uk> Content-Language: en-US From: James Clark In-Reply-To: <22d69113-fec0-4405-872d-af76bd038c09@sirena.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 27/06/2025 10:41 pm, Mark Brown wrote: > On Fri, Jun 27, 2025 at 03:56:43PM -0400, Frank Li wrote: >> On Fri, Jun 27, 2025 at 11:21:42AM +0100, James Clark wrote: > >>> In target mode, the host sending more data than can be consumed would be >>> a common problem for any message exceeding the FIFO or DMA buffer size. >>> Cancel the whole message as soon as this condition is hit as the message >>> will be corrupted. > >>> Only do this for target mode in a DMA transfer, it's not likely these >>> flags will be set in host mode > >> "not likely", I think SPI controller should stop CLK if FIFO empty and full. >> It should be "never" happen. > >> Only check FIFO error flags at target mode because it never happen at host mode. > >> You can remove below whole paragram. > > I agree it *should* never happen in host mode but it can be good > practice to look in case something gets messed up. That said extra > device accesses in the hot path are probably going to be noticable so > likely not worth it, but in the dspi_poll() case: > Yeah the point was to be defensive. Even though it shouldn't happen I don't see an issue with checking error flags. We could add a condition to only do it in target mode, but it doesn't make the code more readable, and it wouldn't be any faster than just checking the flags. So I'm not sure what problem we're trying to solve by removing it. >> @@ -1067,6 +1080,9 @@ static void dspi_poll(struct fsl_dspi *dspi) >> regmap_read(dspi->regmap, SPI_SR, &spi_sr); >> regmap_write(dspi->regmap, SPI_SR, spi_sr); >> >> + dspi->cur_msg->status = dspi_fifo_error(dspi, spi_sr); >> + if (dspi->cur_msg->status) >> + return; > > we're reading the register anyway so the overhead is much lower. In both poll and interrupt mode we're already reading it. Only DMA mode didn't have a read and I didn't add a check for error flags there anyway.