From owner-svn-src-head@freebsd.org Tue Apr 3 21:46:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0E79F83603; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FC3976FA1; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5ABDE249B; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LkSqc070575; Tue, 3 Apr 2018 21:46:28 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LkSUA070574; Tue, 3 Apr 2018 21:46:28 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032146.w33LkSUA070574@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:46:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331956 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331956 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:46:28 -0000 Author: mw Date: Tue Apr 3 21:46:28 2018 New Revision: 331956 URL: https://svnweb.freebsd.org/changeset/base/331956 Log: Make validation in Marvell mv_common.c generic Validate only drivers used by given platform. Pointers to validation function are added to soc_node_spec structure. Submitted by: Rafal Kozik Reviewed by: andrew Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14737 Modified: head/sys/arm/mv/mv_common.c Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Tue Apr 3 21:44:43 2018 (r331955) +++ head/sys/arm/mv/mv_common.c Tue Apr 3 21:46:28 2018 (r331956) @@ -138,6 +138,7 @@ const struct decode_win *cpu_wins = cpu_win_tbl; typedef void (*decode_win_setup_t)(u_long); typedef void (*dump_win_t)(u_long); +typedef int (*valid_t)(void); /* * The power status of device feature is only supported on @@ -153,22 +154,27 @@ struct soc_node_spec { const char *compat; decode_win_setup_t decode_handler; dump_win_t dump_handler; + valid_t valid_handler; }; static struct soc_node_spec soc_nodes[] = { - { "mrvl,ge", &decode_win_eth_setup, &decode_win_eth_dump }, - { "marvell,armada-370-neta", &decode_win_neta_setup, &decode_win_neta_dump }, - { "mrvl,usb-ehci", &decode_win_usb_setup, &decode_win_usb_dump }, - { "marvell,orion-ehci", &decode_win_usb_setup, &decode_win_usb_dump }, - { "marvell,armada-380-xhci", &decode_win_usb3_setup, &decode_win_usb3_dump }, - { "marvell,armada-380-ahci", &decode_win_ahci_setup, &decode_win_ahci_dump }, - { "marvell,armada-380-sdhci", &decode_win_sdhci_setup, &decode_win_sdhci_dump }, - { "mrvl,sata", &decode_win_sata_setup, NULL }, - { "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump }, - { "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump }, - { "mrvl,cesa", &decode_win_cesa_setup, &decode_win_cesa_dump }, - { "mrvl,pcie", &decode_win_pcie_setup, &decode_win_pcie_dump }, - { NULL, NULL, NULL }, + { "mrvl,ge", &decode_win_eth_setup, &decode_win_eth_dump, &decode_win_eth_valid}, + { "marvell,armada-370-neta", &decode_win_neta_setup, + &decode_win_neta_dump, NULL }, + { "mrvl,usb-ehci", &decode_win_usb_setup, &decode_win_usb_dump, &decode_win_usb_valid}, + { "marvell,orion-ehci", &decode_win_usb_setup, &decode_win_usb_dump, &decode_win_usb_valid }, + { "marvell,armada-380-xhci", &decode_win_usb3_setup, + &decode_win_usb3_dump, &decode_win_usb3_valid }, + { "marvell,armada-380-ahci", &decode_win_ahci_setup, + &decode_win_ahci_dump, NULL }, + { "marvell,armada-380-sdhci", &decode_win_sdhci_setup, + &decode_win_sdhci_dump, &decode_win_sdhci_valid}, + { "mrvl,sata", &decode_win_sata_setup, NULL, &decode_win_sata_valid}, + { "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump, &decode_win_xor_valid}, + { "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump, &decode_win_idma_valid}, + { "mrvl,cesa", &decode_win_cesa_setup, &decode_win_cesa_dump, &decode_win_cesa_valid}, + { "mrvl,pcie", &decode_win_pcie_setup, &decode_win_pcie_dump, &decode_win_pcie_valid}, + { NULL, NULL, NULL, NULL }, }; struct fdt_pm_mask_entry { @@ -595,12 +601,6 @@ soc_decode_win(void) return(err); #endif - if (!decode_win_cpu_valid() || !decode_win_usb_valid() || - !decode_win_eth_valid() || !decode_win_idma_valid() || - !decode_win_pcie_valid() || !decode_win_sata_valid() || - !decode_win_xor_valid() || !decode_win_usb3_valid() || - !decode_win_sdhci_valid() || !decode_win_cesa_valid()) - return (EINVAL); decode_win_cpu_setup(); if (MV_DUMP_WIN) @@ -2461,6 +2461,10 @@ fdt_win_process(phandle_t child) else base = fdt_data_get(®[addr_cells - 2], 2); size = fdt_data_get(®[addr_cells], size_cells); + + if (soc_node->valid_handler != NULL) + if (!soc_node->valid_handler()) + return (EINVAL); base = (base & 0x000fffff) | fdt_immr_va; if (soc_node->decode_handler != NULL)