Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1037880rdb; Wed, 1 Nov 2023 09:33:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU/lOprenNEjPlVMbQsoDxsxa8dK2A6wGg6KXAq44vRk8kcXc3V3/vN2MWGvUNTMfUVWEF X-Received: by 2002:a05:6a00:98f:b0:6be:3c44:c18b with SMTP id u15-20020a056a00098f00b006be3c44c18bmr15702683pfg.25.1698856412905; Wed, 01 Nov 2023 09:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698856412; cv=none; d=google.com; s=arc-20160816; b=Gxvb+Am/J9+QrX0BaWeoLTrmTFBRGdHEABwJ2lIGQtnwOk2XDkiiJkMVc6KTmP3S4w 8Hqwx2juNgOV6BZpCNerGN45BJyhyw0aoQMLanNlVgoQ6PmlojqML83Ag7Td4CcNeYpm Bp/jtF6QYrYnt8PVH2Nbzv9GXyubMGfWeSzuMBO/GiDvSaAD3nJSXzgvuM9GT6FbqnTk 4rPdhdeOZ/5PqgnUkPO0Aa1rr2OnUhcfUmO9D49zUY3EuYJ70nPaJx/BMJ58ZPvCt822 Zm6l/wZhHz64DSCZAsVacRJQrlKZvdtEflQW8YnBVb0WF4oDL5MiT9PkM/u/yligZB6Y Vy7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b7ErS4udndynF6UaXLpgiQ7+PIYLOlNsuoCTupPOWmI=; fh=FNpU43Pj/YFmN573F4VGBShrc6T3FEci7P+n+4NWHQk=; b=PxgUP355AUJ6pBfIhOQxDwwL8g04JjooBHGXuqVdqS9WwChawP9yJDn/V0TdSTj+Tx 9lUOPcRDENd4UKr26/UUS8j5nLoHGo2jIJgsTiLpZ0o69YfZYdPDtpKqG3Q2Fx/MHLMC MV7snYMG/VpAJGi4lJVKLO8QUc/fC//9qko62SZBKgngHeSUud7H3ZUHpo5AiDp8x+12 qLvvEVzT1kKdGf3Y7jpClM0Z3Ce3YIFC9Dka0Ul9X1eAPQMHpbLtBeEq+1q4k5yYeRF6 N/2pgRQ++Zx+zS/JGK3GrL3rhLP+mvlbTgtTUErF6QZ5KKrEzbP1yn4NE0fwx3lXuVck QNHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="R/gO4xfA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id g16-20020a635650000000b005b8ebd4eec7si231993pgm.61.2023.11.01.09.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 09:33:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="R/gO4xfA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D746B804C53E; Wed, 1 Nov 2023 09:33:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231955AbjKAQcu (ORCPT + 99 others); Wed, 1 Nov 2023 12:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjKAQct (ORCPT ); Wed, 1 Nov 2023 12:32:49 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65141183; Wed, 1 Nov 2023 09:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=b7ErS4udndynF6UaXLpgiQ7+PIYLOlNsuoCTupPOWmI=; b=R/gO4xfAVLAFORdwaOjVel2gQ1 ldQeo1PiZoeo2VlEDgy7DjdnE8D5BLQW0SdGY+2IuHSyHkqMN3kAsK0IJ0JT23KY6+FPj7q5cC6zZ IbouZ6W1KsqlfLHw3Nn3gomjThRsjZNXpJUMjNLd6/bxCB1BA/t8v4R5g1Jsgrhwcgek=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qyE8r-000hBV-OS; Wed, 01 Nov 2023 17:32:29 +0100 Date: Wed, 1 Nov 2023 17:32:29 +0100 From: Andrew Lunn To: Christian Marangi Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiner Kallweit , Russell King , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Marko Subject: Re: [net-next PATCH v2 1/2] net: phy: aquantia: add firmware load support Message-ID: <34a0b76e-aa0e-4148-ba01-c3b4608f17f7@lunn.ch> References: <20231101123608.11157-1-ansuelsmth@gmail.com> <4b536ad3-2112-4f28-90e4-586b5745be20@lunn.ch> <65427400.5d0a0220.41c58.0ded@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <65427400.5d0a0220.41c58.0ded@mx.google.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 09:33:07 -0700 (PDT) > > > + for (pos = 0; pos < len; pos += min(sizeof(u32), len - pos)) { > > > + u32 word = 0; > > > + > > > + memcpy(&word, data + pos, min(sizeof(u32), len - pos)); > > > > Rather than do a memcpy, use the get_unaligned_ macros. They might map > > to a memcpy(), but some architectures can do unaligned accesses > > without problems. > > > > I don't think this is doable for this loop, think we would end up in > some funny situation where for the last run we have to copy less than > u32. (get_unaligned would always take u32 of data and that would end up > reading more than requested) Am I wrong? Does it happen in practice that the last chunk is not 4 bytes? Since this is firmware, its probably produced by some sort of linker, and they often round segments to words. Could you take a look at the firmware images you have access to and see if this is true? It could be we do need to keep with the memcpy, but it would be nice if we could limit it to words, at least until somebody has a firmware which is not word aligned. Andrew