Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp952963lqb; Fri, 15 Mar 2024 10:47:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWskZ4uzggTvBByEFUs3UnFTzY976SFQU3gCAKeATJhn/qQ5e8AEZEA0wsaVlCMG+nR5MGymMRgS1GXl7LgemQCiU3UYADoKvCRkfPLWg== X-Google-Smtp-Source: AGHT+IFTaY1KrhMo4I+qjDm4HGSi1gi5tKBqzi+zjlxV1Vgf0Dg8vC4UCIrmdE+6InXF5GI/8W1F X-Received: by 2002:a67:c40f:0:b0:473:2dd5:89e5 with SMTP id c15-20020a67c40f000000b004732dd589e5mr6991090vsk.16.1710524879154; Fri, 15 Mar 2024 10:47:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710524879; cv=pass; d=google.com; s=arc-20160816; b=WEZW3wg4HsWSnZg1EfEaF91212j8QKyOy6rKykr6Ik1Fukrs0OJ8waVUcQSby047QI dmnYpZpzxLpnoLtCdoxkT1G6EFKapoQXM3dzfjh/t9FRw/dkSXhkxOLv5DlLT3UlWGI3 eMaSLaYXvJqEKn0wioUrV5UqPUP9jxui4WLuHyV9NcTM01EmrrePdpTzyimXdSW4hyZa 4LowFiKYeAOiabO1cse3UyMrFLCvWQZZCYMOR92m4pZ2E8m0oi5zhmPpPn54PNvABjyu YCVhgz2sVtF4TDupNmJJY1RaVeVOff7sa4KNyFzc2F0AAmV2MeMe0E5HX9RGIh4Xs5aE +oZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=NCJFY9oBMIc4jIR5EozdVizV1EDLctfDAJOmTBaMPQI=; fh=pYoNXzaPML3jJca1oFPPtABBVyqED8G/oFpcN1+F7vg=; b=Ih7fRIxb29hivyR04t0uiUX1xS71wdpPJ+J7kRRDUFnReLHrP3Y/shokLazt5C2TVp LPtWrU5TUz7/YPxsycCEIRyIHAqM5OdRbeIPZtC31HDbvvrYJdG3rmu+/fgHfeCv7Zjw q4JHnytv66r3usMdfL126VL1Zw9IY5RMgdRIDGE9SUDZTF9X/tswalJg5lf2umRdhXld pphD4oIFr6r3PBL9elFJsNTG6CdNFIz9rwVZBU+MLEm2iKja18XgFtngKylPXbPscnA3 q9vXf6nOBdn85/qkBDWwjNSbzjcdHfJ0JnZ4Gc1TBF5nGdaMSpg4X3D4T6NFZKYIVf69 IHfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=svq0qhBs; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-104744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pt9-20020a056214048900b0068d01989970si3323215qvb.509.2024.03.15.10.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 10:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=svq0qhBs; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-104744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1C2661C22299 for ; Fri, 15 Mar 2024 17:47:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA0CC4C637; Fri, 15 Mar 2024 17:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="svq0qhBs" Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FBA74CB23 for ; Fri, 15 Mar 2024 17:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710524868; cv=none; b=thrFgtSebvwcEksVczPvlpNpxdpMDjTEJ4CpQYppj+b6QkcCyBibOjmn0+RuZWb8UXSPVRQf5tSFPATPryJ2neITzToZfWWxfGKifCz12EbCqu8QGyKaYII4uSk9JoZ4xq4KfYxgIfzcHIay7W6oUiA4x1aRbo5Ag0KR6HYouMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710524868; c=relaxed/simple; bh=fkPK1LmQHyIfCMGWch1qUnlA3RLep24AWMuGdq+oBJg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Bofs9cQOSdKmmzFn56DKnbeRmn6nh8nog+mMOGNISZRvmGLOMpLq0KeyQtkUla968cRKC7CZGeNcGd4/mroipmlMrYM6rk9pSpFrr19AvJyaw0GnHZhDP3IJVoE/jfHB6lvSXzK9NL+1cyIsPWyTeIgCGvQ2caoxqU0bb5DNk1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=svq0qhBs; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <3b481539-0c9c-4110-ad03-bd252e80efb0@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710524864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NCJFY9oBMIc4jIR5EozdVizV1EDLctfDAJOmTBaMPQI=; b=svq0qhBsz5hF1uH+RwKFS22DuTVjdHzsmisCBiKz0P0nggI+CYt0XPtClNfHaWB4P2oLRw IMrh+Hhp2qttSDqSfcqmiedJUtely/HUU7gSM+gdWwy9WwyVFUC2DBIcWO5q5UfQ9hHo8V FowdcNrSr1m1hut/GiuEjf3Y2LBnCU8= Date: Fri, 15 Mar 2024 13:47:40 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask Content-Language: en-US To: "O'Griofa, Conall" , Jonathan Cameron Cc: "linux-iio@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Lars-Peter Clausen References: <20240311162800.11074-1-sean.anderson@linux.dev> <20240314154824.37150a54@jic23-huawei> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Hi Conall, On 3/15/24 09:18, O'Griofa, Conall wrote: > [AMD Official Use Only - General] > > Hi, > > I think there was a fix for this issue applied to the version that was running on 5.15 that didn't seem to make it into the upstream driver. > Please see link for reference https://github.com/Xilinx/linux-xlnx/commit/608426961f16ab149b1b699f1c35f7ad244c0720 > > I think a similar fix to the above patch is may be beneficial? These patches look functionally identical to me. --Sean >> -----Original Message----- >> From: Sean Anderson >> Sent: Thursday, March 14, 2024 5:30 PM >> To: Jonathan Cameron >> Cc: linux-iio@vger.kernel.org; O'Griofa, Conall ; >> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Lars-Peter >> Clausen >> Subject: Re: [PATCH] iio: xilinx-ams: Don't include ams_ctrl_channels in >> scan_mask >> >> Caution: This message originated from an External Source. Use proper caution >> when opening attachments, clicking links, or responding. >> >> >> On 3/14/24 11:48, Jonathan Cameron wrote: >> > On Mon, 11 Mar 2024 12:28:00 -0400 >> > Sean Anderson wrote: >> > >> >> ams_enable_channel_sequence constructs a "scan_mask" for all the PS >> >> and PL channels. This works out fine, since scan_index for these >> >> channels is less than 64. However, it also includes the >> >> ams_ctrl_channels, where scan_index is greater than 64, triggering >> >> undefined behavior. Since we don't need these channels anyway, just >> exclude them. >> >> >> >> Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver") >> >> Signed-off-by: Sean Anderson >> > >> > Hi Sean, >> > >> > I'd ideally like to understand why we have channels with such large >> > scan indexes. Those values should only be used for buffered capture. >> > It feels like they are being abused here. Can we set them to -1 >> > instead and check based on that? >> > For a channel, a scan index of -1 means it can't be captured via the >> > buffered interfaces but only accessed via sysfs reads. >> > I think that's what we have here? >> >> From what I can tell, none of the channels support buffered reads. And we can't >> naïvely convert the scan_index to -1, since that causes sysfs naming conflicts >> (not to mention the compatibility break). >> >> > >> > I just feel like if we leave these as things stand, we will get bitten >> > by similar bugs in the future. At least with -1 it should be obvious why! >> >> There are just as likely to be bugs confusing the PL/PS subdevices... >> >> FWIW I had no trouble identifying the channels involved with this bug. >> >> --Sean >> >> > Jonathan >> > >> > >> >> --- >> >> >> >> drivers/iio/adc/xilinx-ams.c | 8 ++++++-- >> >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/drivers/iio/adc/xilinx-ams.c >> >> b/drivers/iio/adc/xilinx-ams.c index a55396c1f8b2..4de7ce598e4d >> >> 100644 >> >> --- a/drivers/iio/adc/xilinx-ams.c >> >> +++ b/drivers/iio/adc/xilinx-ams.c >> >> @@ -414,8 +414,12 @@ static void ams_enable_channel_sequence(struct >> >> iio_dev *indio_dev) >> >> >> >> /* Run calibration of PS & PL as part of the sequence */ >> >> scan_mask = BIT(0) | BIT(AMS_PS_SEQ_MAX); >> >> - for (i = 0; i < indio_dev->num_channels; i++) >> >> - scan_mask |= BIT_ULL(indio_dev->channels[i].scan_index); >> >> + for (i = 0; i < indio_dev->num_channels; i++) { >> >> + const struct iio_chan_spec *chan = >> >> + &indio_dev->channels[i]; >> >> + >> >> + if (chan->scan_index < AMS_CTRL_SEQ_BASE) >> >> + scan_mask |= BIT_ULL(chan->scan_index); >> >> + } >> >> >> >> if (ams->ps_base) { >> >> /* put sysmon in a soft reset to change the sequence */ >> >