From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A9129C433F5 for ; Thu, 21 Apr 2022 16:14:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A97F883EE0; Thu, 21 Apr 2022 18:12:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com 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=google.com header.i=@google.com header.b="dfi1R6la"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 751E383EAB; Thu, 21 Apr 2022 18:11:53 +0200 (CEST) Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9574683E92 for ; Thu, 21 Apr 2022 18:11:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3RoJhYgYKBukLdNfWWRZZRWP.NZXf-MZZeWTded.OPYi.OP@flex--ascull.bounces.google.com Received: by mail-wr1-x449.google.com with SMTP id e13-20020adf9bcd000000b0020aa78ef365so1297147wrc.13 for ; Thu, 21 Apr 2022 09:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=vlS+HkqYgXNEgdn87lzL07dxqrSO7BVDPEHCr7AvTIU=; b=dfi1R6laI6FdYjVMgC/5CUHDLzr6Y8kAVBZdJXbiFqWph2Y8fvj+bRg63jCf0gw6Q0 roznMHpV+GHZAf6E6mleCc9CcDJ4EQatzPYgqyvFVP31ITIIooQNsrD37JBi9eMJ5wNE Ngmsvn9sBvTJ5GO4dxPJMQGhMS89RU5b9JykjzCuTNfp7LejMFBUP+/MNbDu8pHxvtEh RwDDed8dTgjvbYELIbqZaIiGHjkgZushhuVtB9tz7FFcw/Wsw71KZvgwYReLoXc5P4Is /pZSa7bD7Abp1/zYNRHT6sFFZ3u7SfTESnVTiXzab9NCFlMWKz0GeKrjtiFQlEf3UI16 kuXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vlS+HkqYgXNEgdn87lzL07dxqrSO7BVDPEHCr7AvTIU=; b=wmoZWu5wXYehIQyPwyrUe6sTYcfo/mG0xR7T8QYYaOZVIYd9K+o3Yf1beG6wVFVwUA ie7JLnn7WKrF66EUsA25pL3rjY1VBa17VAgUd+HFA3YSgMdBNzZB4uTGhc7qSm9psfg+ nfOBlO03Nfso14/E44Ysc3Yv99gHyY6AaqsLnOPOnG2BclymkjpoXXbx9z2p8kREMTIg 3FPIHxiFkNkb1rddvkh60RTAotJIWXU5CPm6plJH3B4UVQLEB3nX4g4A+lOZ7N9DC+DH D+d9lXgsDW4U15A1rJ7uWuyueMxB43pkUA8XYP8Ecx+SFtpdHyGxAPTxErbp/npjAwh+ R2fw== X-Gm-Message-State: AOAM533Q7P2fVPHyOJVy7ykbVfQmw1VUSvVgAMREh+oHHiWlzRWnn3cI kLcWhd4GET6aQCWYNQh+G9zec5PbobZPPCskziZowmh1ZAMGjPw8xt5PrcWbYp2f8OduMAWayVQ kKV+M3E4E/F23QRx0lXZSpGTFc8xJbhpEHSiJjLJKh0inRvUSn+8FvVFiZB4= X-Google-Smtp-Source: ABdhPJyCws4jEJguBbSngUS0U4PnT7LBe18GWIed4s1iASFp1y2bEYJPE7sP3gGYJHC6xvJr+LEJTOIz1I4= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a1c:2942:0:b0:392:3aff:4fcd with SMTP id p63-20020a1c2942000000b003923aff4fcdmr131600wmp.0.1650557510190; Thu, 21 Apr 2022 09:11:50 -0700 (PDT) Date: Thu, 21 Apr 2022 16:11:12 +0000 In-Reply-To: <20220421161116.1202023-1-ascull@google.com> Message-Id: <20220421161116.1202023-15-ascull@google.com> Mime-Version: 1.0 References: <20220421161116.1202023-1-ascull@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 14/18] pci: Update dm_pci_bus_to_virt() parameters From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, bmeng.cn@gmail.com, trini@konsulko.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean Add mask parameter and reorder length parameter to match the other PCI address conversion functions. Using PCI_REGION_TYPE as the mask gives the old behaviour. It's converted from a macro to an inline function as the length parameter is now used twice, but should only be calculated once. Signed-off-by: Andrew Scull --- drivers/bios_emulator/atibios.c | 4 ++-- drivers/pci/pci-uclass.c | 4 ++-- include/pci.h | 16 +++++++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/bios_emulator/atibios.c b/drivers/bios_emulator/atibios.c index 9547470a2f..cdc5ba6ad9 100644 --- a/drivers/bios_emulator/atibios.c +++ b/drivers/bios_emulator/atibios.c @@ -368,8 +368,8 @@ void *PCI_mapBIOSImage(struct udevice *pcidev) return NULL; } - BIOSImage = dm_pci_bus_to_virt(pcidev, BIOSImageBus, - PCI_REGION_MEM, 0, MAP_NOCACHE); + BIOSImage = dm_pci_bus_to_virt(pcidev, BIOSImageBus, 0, PCI_REGION_TYPE, + PCI_REGION_MEM, MAP_NOCACHE); /*Change the PCI BAR registers to map it onto the bus.*/ dm_pci_write_config32(pcidev, BIOSImageBAR, 0); diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index edcb1a245f..a193e2511f 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1596,8 +1596,8 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, size_t offset, size_t len, * a PCI range, but a better check would be to probe for the size of * the bar and prevent overflow more locally. */ - return dm_pci_bus_to_virt(udev, pci_bus_addr + offset, flags, len, - MAP_NOCACHE); + return dm_pci_bus_to_virt(udev, pci_bus_addr + offset, len, + PCI_REGION_TYPE, flags, MAP_NOCACHE); } static int _dm_pci_find_next_capability(struct udevice *dev, u8 pos, int cap) diff --git a/include/pci.h b/include/pci.h index 0a6b7a6f4b..c0eefe9209 100644 --- a/include/pci.h +++ b/include/pci.h @@ -1461,9 +1461,13 @@ int dm_pci_flr(struct udevice *dev); #define dm_pci_virt_to_bus(dev, addr, flags) \ dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), 0, PCI_REGION_TYPE, (flags)) -#define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \ - map_physmem(dm_pci_bus_to_phys(dev, (addr), (len), PCI_REGION_TYPE, (flags)), \ - (len), (map_flags)) +#define dm_pci_bus_to_virt(dev, addr, len, mask, flags, map_flags) \ +({ \ + size_t _len = (len); \ + phys_addr_t phys_addr = dm_pci_bus_to_phys((dev), (addr), _len, \ + (mask), (flags)); \ + map_physmem(phys_addr, _len, (map_flags)); \ +}) #define dm_pci_phys_to_mem(dev, addr) \ dm_pci_phys_to_bus((dev), (addr), 0, PCI_REGION_TYPE, PCI_REGION_MEM) @@ -1477,11 +1481,13 @@ int dm_pci_flr(struct udevice *dev); #define dm_pci_virt_to_mem(dev, addr) \ dm_pci_virt_to_bus((dev), (addr), PCI_REGION_MEM) #define dm_pci_mem_to_virt(dev, addr, len, map_flags) \ - dm_pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags)) + dm_pci_bus_to_virt((dev), (addr), (len), PCI_REGION_TYPE, \ + PCI_REGION_MEM, (map_flags)) #define dm_pci_virt_to_io(dev, addr) \ dm_pci_virt_to_bus((dev), (addr), PCI_REGION_IO) #define dm_pci_io_to_virt(dev, addr, len, map_flags) \ - dm_pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags)) + dm_pci_bus_to_virt((dev), (addr), (len), PCI_REGION_TYPE, \ + PCI_REGION_IO, (map_flags)) /** * dm_pci_find_device() - find a device by vendor/device ID -- 2.36.0.rc2.479.g8af0fa9b8e-goog