Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4480446ybl; Mon, 26 Aug 2019 11:03:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4XcHuPdBn1ZBMa6C7EWv5oRZOE1Q8yRahUwXxjQeOE56ORC2ODvmyrDCoNwcIfJAq7MKB X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr20191784plm.306.1566842584724; Mon, 26 Aug 2019 11:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566842584; cv=none; d=google.com; s=arc-20160816; b=xdplThLe1MFfQ1QNaR45HTn6d7F9IiD0aAebasjGjxFqhoaNek2xONLenzYBjZ/08E HPAb0hlq7L3sRTuQKpQdMbsdvzbmDpzZEaGWZyN3dAribJMvanWJUthNAxD0801iHhrR fMPr1rDjFco+WAEgv5lnVEOgPs3+Ui/Il2Zpt1WmVtmvmM11QAqc1YblvOnrriGxKWSd zrjs86PywsjNvTLBa2Sh+5u29+WrlsvvyYH/dMiBfyZ9PQGBSgKm+bBtWMOMFPT025rx umxvPG4JOM1Ad1Qsinq2xExQmLozC7ItnVFnkUxKrA0t4SzXwPKZSLDp/9WLHGWIwULp Agsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date; bh=atErFOr5c5ZJwv51CvHMWH4sClWR+qhcj6kv8wW6Lrk=; b=Zn9Y4b8hS/tnKZAVJTj+Ih7vs5p7/d3uArdraL7AHO8rQS8eoJJps8RGTLRkzisLDR u4NbZOfUuP1BTeSoEdViFlgLxsljBv8Xo2XRC6/vE/DldcJe9mbrTSkJy7ATM0BBsWls RUuGDGQRM8hY7FGSfB4pM98TuO2k50pp1GaU+VEWrAm/kx1SQRGvdeie84x4uVZ6PBaC poV1UeuaQSwUvf/uszJQgdhnLl03TB0/QLkJ/++CFjM6xo7czvrC2Ot3zql1P22/pTzQ B4O1EBD5r9bNffvIEtwX1neeLCaatIHkxbwayDXaDeL0rHhWO2ne6VehZBgC5EhuZmVR lGKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20si186978pjq.109.2019.08.26.11.02.47; Mon, 26 Aug 2019 11:03:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731864AbfHZP5F (ORCPT + 99 others); Mon, 26 Aug 2019 11:57:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:57206 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731490AbfHZP5F (ORCPT ); Mon, 26 Aug 2019 11:57:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7E319AF65; Mon, 26 Aug 2019 15:57:02 +0000 (UTC) Date: Mon, 26 Aug 2019 17:57:02 +0200 Message-ID: From: Takashi Iwai To: Scott Branden Cc: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/7] firmware: add offset to request_firmware_into_buf In-Reply-To: <93b8285a-e5eb-d4a4-545d-426bbbeb8008@broadcom.com> References: <20190822192451.5983-1-scott.branden@broadcom.com> <20190822192451.5983-3-scott.branden@broadcom.com> <10461fcf-9eca-32b6-0f9d-23c63b3f3442@broadcom.com> <93b8285a-e5eb-d4a4-545d-426bbbeb8008@broadcom.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Aug 2019 17:41:40 +0200, Scott Branden wrote: > > HI Takashi, > > On 2019-08-26 8:20 a.m., Takashi Iwai wrote: > > On Fri, 23 Aug 2019 21:44:42 +0200, > > Scott Branden wrote: > >> Hi Takashi, > >> > >> Thanks for review.  comments below. > >> > >> On 2019-08-23 3:05 a.m., Takashi Iwai wrote: > >>> On Thu, 22 Aug 2019 21:24:46 +0200, > >>> Scott Branden wrote: > >>>> Add offset to request_firmware_into_buf to allow for portions > >>>> of firmware file to be read into a buffer. Necessary where firmware > >>>> needs to be loaded in portions from file in memory constrained systems. > >>> AFAIU, this won't work with the fallback user helper, right? > >> Seems to work fine in the fw_run_tests.sh with fallbacks. > > But how? You patch doesn't change anything about the fallback loading > > mechanism. > Correct - I didn't change any of the underlying mechanisms, > so however request_firmware_into_buf worked before it still does. But how? That's the question. If I understand correctly, essentially your patch changes the call of kernel_read_file_from_path() with additional offset and partial size parameters. i.e. the partial read behavior itself purely relies on the kernel_read_file_from_path(). And, if the file isn't read via this function, the f/w loader falls back to the UMH. Since fallback.c has no idea about the partial read, it shall return the full content of the file. Then this must contradict against the expected result, no? > > Or, if the expected behavior is to load the whole content > > and then copy a part, what's the merit of this API? > The merit of the API is that the entire file is not copied into a buffer. > In my use case, the buffer is a memory region in PCIe space that isn't > even large enough for the whole file.  So the only way to get the file > is to read it > in portions. But you read not in portions but the whole content, in the case of fallback mode... > >>> Also it won't work for the compressed firmware files as-is. > >> Although unnecessary, seems to work fine in the fw_run_tests.sh with > >> "both" and "xzonly" options. > > This looks also suspicious. Loading a part of the file from the > > middle and decompression won't work together, from obvious reasons. > I don't know what the underlying mechanisms are doing right now. > If they decompress the whole file then that is why it's working. No, it shouldn't be a complete read. As already mentioned, the patch changes only the call pattern of kernel_read_file_from_path(). The decompression is done after that, so it must be applied to the partially read content which cannot be decompressed properly. > An obvious improvement that could be made later is to only read > a portion of the file before writing it into the buffer in the non-xz case. > > > If the test passes, it means that the test itself is more likely > > incorrect, I'm afraid. > Then all of the tests for "both" and "xzonly" could be broken. I suspect that the fallback test is also broken. thanks, Takashi