Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B91AC4338F for ; Mon, 2 Aug 2021 20:16:21 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92FCB6100A for ; Mon, 2 Aug 2021 20:16:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 92FCB6100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDDCA82D84; Mon, 2 Aug 2021 22:16:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="NndLBac2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A12D833FB; Mon, 2 Aug 2021 22:16:17 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8B09480F47 for ; Mon, 2 Aug 2021 22:16:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 131F960F9E; Mon, 2 Aug 2021 20:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627935371; bh=fMDl0iz9xHP5ie7+Aewta1V7KgeN8Pg7ZKA4HbL90o8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NndLBac2hsiKmfHyeTokiH9IaemmzrJYUtLAt9F860GMCoN5VN5FB6E1ZlnLARZ+u 22QOojxFs0NhACBTtD7cPell1dmpm1hxQxrVp5QjC0pv1GsuvCLWxUsLaFrDIgvm3c YA/AxutkW05dg2y8vwE+4B4tulCPZ3m1sHOm5T2cZyd1CX905twZQw2Rvpo8lObh0Z +7NTjRIBEhoK3+Hq+aZt688zK0MDqDYKYQ2UkpOT/2hnu8/detHOaW+A6lJQxpv8jB aAoK/bibZKio6SzrSJjvuqibZ5EMUN5+/MOVwRyvO2FaQahKt2BdtIgutcj4NsMXm3 ukpE90TkcgUOQ== Received: by pali.im (Postfix) id B274FB98; Mon, 2 Aug 2021 22:16:08 +0200 (CEST) Date: Mon, 2 Aug 2021 22:16:08 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Simon Glass Cc: Stefan Roese , Masami Hiramatsu , Frank Wunderlich , Marek =?utf-8?B?QmVow7pu?= , U-Boot Mailing List Subject: Re: Broken CONFIG_SPL_SATA_SUPPORT=y Message-ID: <20210802201608.byonlpr5mzqznaz4@pali> References: <20210801122516.dl6vykk22aumzjfd@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Monday 02 August 2021 13:21:51 Simon Glass wrote: > Hi Pali, > > On Sun, 1 Aug 2021 at 06:25, Pali Rohár wrote: > > > > Hello! > > > > Option CONFIG_SPL_SATA_SUPPORT=y is currently broken in u-boot master > > branch. If I try to enable it for A38x platform I'm getting following > > compiler error: > > > > LD spl/u-boot-spl > > arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci.o: in function `ahci_probe_scsi_pci': > > drivers/ata/ahci.c:1205: undefined reference to `dm_pci_map_bar' > > arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci.c:1215: undefined reference to `dm_pci_read_config16' > > arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci.c:1216: undefined reference to `dm_pci_read_config16' > > arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci.c:1220: undefined reference to `dm_pci_map_bar' > > make[1]: *** [scripts/Makefile.spl:512: spl/u-boot-spl] Error 1 > > make: *** [Makefile:1977: spl/u-boot-spl] Error 2 > > > > You can reproduce it by running following commands: > > > > $ make turris_omnia_defconfig > > $ echo CONFIG_SPL_SATA_SUPPORT=y >> .config > > $ make CROSS_COMPILE=arm-linux-gnueabihf- > > > > I workaround it by following patch: > > > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > > index d4047c04f5d0..6bad72e4cfa4 100644 > > --- a/drivers/ata/ahci.c > > +++ b/drivers/ata/ahci.c > > @@ -1196,7 +1196,7 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) > > return 0; > > } > > > > -#ifdef CONFIG_DM_PCI > > +#if CONFIG_IS_ENABLED(DM_PCI) > > int ahci_probe_scsi_pci(struct udevice *ahci_dev) > > { > > ulong base; > > > > It fixed this particular problem. So it looks like that CONFIG_DM_PCI is > > defined also when building SPL even when it is not enabled for SPL. > > Whole PCI is disabled in SPL. > > > > But then I got another compile error: > > > > LD spl/u-boot-spl > > arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci-pci.o: in function `ahci_pci_probe': > > drivers/ata/ahci-pci.c:21: undefined reference to `ahci_probe_scsi_pci' > > make[1]: *** [scripts/Makefile.spl:512: spl/u-boot-spl] Error 1 > > make: *** [Makefile:1977: spl/u-boot-spl] Error 2 > > > > Seems that u-boot is trying to compile and link ahci-pci.o into SPL > > binary even when it is not enabled nor used. PCI is completed disabled > > in SPL for this case. > > > > I workaround it by putting whole ahci-pci.c file into one big #idef: > > > > diff --git a/drivers/ata/ahci-pci.c b/drivers/ata/ahci-pci.c > > index b1d231e0f9e1..34afebd2f87f 100644 > > --- a/drivers/ata/ahci-pci.c > > +++ b/drivers/ata/ahci-pci.c > > @@ -9,6 +9,8 @@ > > #include > > #include > > > > +#if CONFIG_IS_ENABLED(DM_PCI) > > + > > static int ahci_pci_bind(struct udevice *dev) > > { > > struct udevice *scsi_dev; > > @@ -42,3 +44,5 @@ static struct pci_device_id ahci_pci_supported[] = { > > }; > > > > U_BOOT_PCI_DEVICE(ahci_pci, ahci_pci_supported); > > + > > +#endif > > > > And then finally U-Boot produced final target image u-boot-spl.kwb: > > > > LD spl/u-boot-spl > > OBJCOPY spl/u-boot-spl-nodtb.bin > > SYM spl/u-boot-spl.sym > > CAT spl/u-boot-spl-dtb.bin > > COPY spl/u-boot-spl.bin > > MKIMAGE u-boot-spl.kwb > > > > So this looks like a bug in Kconfig or Makefile dependences that build > > system is trying to compile and link also files which should not be > > linked at all. > > I sent a series to drop DM_PCI: > > http://patchwork.ozlabs.org/project/uboot/list/?series=256181 > > Can you give that a try and see if it helps? $ make turris_omnia_defconfig $ echo CONFIG_SPL_SATA_SUPPORT=y >> .config $ make CROSS_COMPILE=arm-linux-gnueabihf- ... LD spl/u-boot-spl arm-linux-gnueabihf-ld.bfd: drivers/ata/ahci.o: in function `ahci_probe_scsi_pci': /home/pali/omnia/u-boot/drivers/ata/ahci.c:1151: undefined reference to `dm_pci_map_bar' arm-linux-gnueabihf-ld.bfd: /home/pali/omnia/u-boot/drivers/ata/ahci.c:1161: undefined reference to `dm_pci_read_config16' arm-linux-gnueabihf-ld.bfd: /home/pali/omnia/u-boot/drivers/ata/ahci.c:1162: undefined reference to `dm_pci_read_config16' arm-linux-gnueabihf-ld.bfd: /home/pali/omnia/u-boot/drivers/ata/ahci.c:1166: undefined reference to `dm_pci_map_bar' make[1]: *** [scripts/Makefile.spl:512: spl/u-boot-spl] Error 1 make: *** [Makefile:1998: spl/u-boot-spl] Error 2