Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2686942rdh; Wed, 27 Sep 2023 09:38:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFChxAyBWwmPrM3804Y9aU0hL3yDSZgUGAAk6KlOFlRXbGuIsmHhz3D7VzsAne4W4k57bsd X-Received: by 2002:a05:6358:52d4:b0:135:85ec:a080 with SMTP id z20-20020a05635852d400b0013585eca080mr3264045rwz.32.1695832686480; Wed, 27 Sep 2023 09:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695832686; cv=none; d=google.com; s=arc-20160816; b=EWiSX+kOCvnyiWuYAPxNmyZpiY3rr7CLxV3OVcqAFLYEPoPwGCqULvJx+KPNDLqHzc OyZSh4Xlmt7w3GPjSrV+ktT/8TK1WTJX74/8Czm1R3rarTXIuuOJ3aDYtwhWgii3YkKV Jvkn63xiZjsuNMuvw2iw5qXJyZflsfx5H7K5jvg+ajJzURSZYuA8I9BQnP2tYIGg0ivn wI0Gr+JQGAfMCiuxDlQjCpzeZEP/k5qN+0kgx5UPiq9UxlhQQCYGTqoJUwslSKURHk3m 7RZxo3GyYNRLYDPt3LA7phLWgJL96NkCACjRgyCajFDrQ05v0jm9t9BMQci8NRKzir3S BS0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6FnvdfcXt2Jt9O82odmrecYimjieWGznUYEOA558FPc=; fh=civ/+RxzSn4TABsRMUbtxH1X3FN4334eGpu7PisCyhk=; b=iI2uC5kJlyHuUvPKtKTzi6lyo0HY15CDC8DMHmpOUEeFGxk0ggksFjfSAa2MZbVzhz 8BIGX98vpmLW05vujkREirSoBJRpt0mCc9mkvM9xS668E9UvUt19ibv5Kri8GLvAXdwZ iZIcno3XM5wQ0jTCpDx7M1AsGNnbLAZd3T82LVloR5DVRV2nVpOmP4hMKbdUVoss2rrN y6iGOYOtczMErFMWTErh0WEbEs+ufXkjl7hFgesnZXUhpfWQ/C8sMC5ZU2BtMek/i9HD AyoUgFUmZ4Of5XpiWueTa5fsG5LWDr/MM5f8O8RIFjoXmxZqPYnFPkk6Zu+21/62RSD+ zWgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a03mMW0E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00564bdf6958fsi15843806pgb.649.2023.09.27.09.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a03mMW0E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D778082DE873; Wed, 27 Sep 2023 05:28:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjI0M2N (ORCPT + 99 others); Wed, 27 Sep 2023 08:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbjI0M2F (ORCPT ); Wed, 27 Sep 2023 08:28:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF5A0CCA; Wed, 27 Sep 2023 05:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695817680; x=1727353680; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=W3h2wW/brscHyngLBq3Ts+PQWQBvYW/Hdi4JL7jg9iI=; b=a03mMW0EXnizVPctyTDsh442ehhFvsyPh/gZmgn1t6v75X/6NqSqBjJf ZOlRc4veNJ6OsXqspBi47mdDqZ0z8iLSDPTR6VhV1xfcCYJ+j2gC68i4h x8OVd/MHJ+WNyHSWP3Yb1iIkITlU5t7L/pJyuIXlmoLdDOrRGjWiz8b8D XUsjZn6SVpJ+sK7PNnZmOqpSxlqqhGkLVt8q0lXUW4znFV//FeOWbD3Lq yI1/EWaWBrjwRgivn7v3dgx2om+CarVvR/cVYxPrEPlRzCyfR4uVg7Sgb 0n/JIGoqed+z0d4o5U5XWTMKuL5pWwfCZlZNHC81OJ9oKEznQliLO4vZI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="379089223" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="379089223" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 05:28:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="742693950" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="742693950" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 05:27:56 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qlTdw-00000000sl9-3Dmm; Wed, 27 Sep 2023 15:27:52 +0300 Date: Wed, 27 Sep 2023 15:27:52 +0300 From: Andy Shevchenko To: Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Angel Iglesias , Andreas Klinger , Benjamin Bara , Christophe JAILLET , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/5] tools: iio: iio_generic_buffer ensure alignment Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 05:28:22 -0700 (PDT) On Wed, Sep 27, 2023 at 11:26:07AM +0300, Matti Vaittinen wrote: > The iio_generic_buffer can return garbage values when the total size of > scan data is not a multiple of the largest element in the scan. This can be > demonstrated by reading a scan, consisting, for example of one 4-byte and > one 2-byte element, where the 4-byte element is first in the buffer. > > The IIO generic buffer code does not take into account the last two > padding bytes that are needed to ensure that the 4-byte data for next > scan is correctly aligned. > > Add the padding bytes required to align the next sample with the scan size. ... > + /* > + * We wan't the data in next sample to also be properly aligned so Pardon me, won't or want, I didn't get?.. > + * we'll add padding at the end if needed. > + * > + * Please note, this code does ensure alignment to maximum channel > + * size. It works only as long as the channel sizes are 1, 2, 4 or 8 > + * bytes. Also, on 32 bit platforms it might be enough to align also 32-bit > + * the 8 byte elements to 4 byte boundary - which this code is not 8-byte 4-byte > + * doing. > + */ -- With Best Regards, Andy Shevchenko