Received: by 10.192.165.148 with SMTP id m20csp831882imm; Wed, 25 Apr 2018 08:20:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SgPPCCdSwepxSMIpJ91PWJwDyj5XbkjrZBTgyZYBULb/pxNlfE9Rms7gHnmpMsE1Pw9pg X-Received: by 2002:a17:902:5329:: with SMTP id b38-v6mr25267429pli.326.1524669609738; Wed, 25 Apr 2018 08:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524669609; cv=none; d=google.com; s=arc-20160816; b=fi2aT4mBTZrVDxs59xvypDk85c6lwihqDlq3gnTnQXaTXPDr7M2uaQFKVKdb1gEABu BaAjonj+/G7Iy7yeSifLGoA9Y+psh0PuWn7KvKA4Wg73hZcPGfz03hm7xC4mxCBohXTU PxIrmtsw+g8v+PuQsrMHdP6L3rTTGgXSL97enHVaj36jMBeYhj/ROfSRW7AellUf9ZUs YdTyvOW6e0cHGylc5RvuE075H0x2bze1Z3CEdsmk7RGUPk92HtM7Xn7NW9mwqZ4PyTlA e58sNg9Mor54Q4AHHK59eYeamWp0NyGx+z1S6EzT287IRcsZPmm+t2heFkDtMM7V7EjU ElWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=c9Lut6ToLB7ZXwCq8aW69UFJLQ/cgzi/Bdm5z9H4dPU=; b=YW8dURZal7eVU9SwlJj/HsIKeNpuFzNhO5kVKwD7CHzGc/vCF+mraHduWgZP0bPwu9 nC7/a4Qjg5IWp1FoSxwGXeOVOF4NleMNFlPAchUWUrzZJsPCWKBY4BW3ueVZq5pFUOHT kLpN0bfV+p8W2ab/f2lNYdKPbWWGYd43UKBfYX51p//ULTvFTWUZ+XQ2Lpruncwj3CMM BysdJRjjHx6LWNXoQjBglo6PM+UGyo2D0kDf8Dcf7VHkPGdvY66h1bCFigJQ8oAZFXDm lCGiLiWCg3LrJd6X4YxlpgXvC7pB4fpVCDHNHtMP8nWTPfAqJc1+X6619JwfBrZr0m02 q2gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SekWymAo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si2592831pgu.450.2018.04.25.08.19.55; Wed, 25 Apr 2018 08:20:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b=SekWymAo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbeDYPSr (ORCPT + 99 others); Wed, 25 Apr 2018 11:18:47 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:44583 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbeDYPSp (ORCPT ); Wed, 25 Apr 2018 11:18:45 -0400 Received: by mail-io0-f196.google.com with SMTP id d11-v6so19367483iof.11 for ; Wed, 25 Apr 2018 08:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=c9Lut6ToLB7ZXwCq8aW69UFJLQ/cgzi/Bdm5z9H4dPU=; b=SekWymAo6YpWtz4lSMLXvjsi3hb2L7gIAsU/gkAOwPfn8s1TtYqK230xW8xJru8B3v kwmgGIsN0FFzmCAwVzf5TKCWffZk2iiXKIpn4OufbkGRzmNcj/CqyTUQjujPhS7Zrw6m dzUQBmH1UmTtbCs2dJuACd6jem0JxPUW24Kjc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c9Lut6ToLB7ZXwCq8aW69UFJLQ/cgzi/Bdm5z9H4dPU=; b=ZBbTMhBd9gRNeKBwFiHkCX+vMe6BU2W7OY4u31FtcMPiMdNvkTJA9jJCPm3Epo+ZmP OKpb7uz5qibRK5Gf4Vt38VrT+fIxiXO58xehdLbYRB6+c8VobV+pjyn2fbwNk1+Ndexv GBIVyYlvhnRC+8qcK8AlyxF1eAfUsv/uvc/A7ayXWIbIl+UiWrgyssa6cyM4Y22jfhPx onmawocsfjxrwfUfWqwZGcz2+PIxLjCYOQA6y5zWyH4Tlu+a8i0/57NEw9y94c8kAKcW CoGAX0iH2Px+DTkXzF6o4Q0IdmV+KYidExe41vHloK5Ubfi8BBwGxB1nTxMIwmZdNWy6 DFaQ== X-Gm-Message-State: ALQs6tDi5DTdvhsrdS1r4Ubulm7pECxwiYLoCm7aSHFUVYa8JxqcPEvB Ns6sLcKhhvwsn9fPzR8aFoh7gA== X-Received: by 2002:a6b:b58d:: with SMTP id e135-v6mr29019896iof.189.1524669525058; Wed, 25 Apr 2018 08:18:45 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id w77-v6sm7468904iow.70.2018.04.25.08.18.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 08:18:44 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: qcom: smem: introduce qcom_smem_virt_to_phys() Date: Wed, 25 Apr 2018 10:18:20 -0500 Message-Id: <20180425151820.25595-1-elder@linaro.org> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create function qcom_smem_virt_to_phys(), which returns the physical address corresponding to a given SMEM item's virtual address. This feature is required for a driver that will soon be out for review. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 27 +++++++++++++++++++++++++++ include/linux/soc/qcom/smem.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7d9a43da5084..70b2ee80d6bd 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -655,6 +655,33 @@ int qcom_smem_get_free_space(unsigned host) } EXPORT_SYMBOL(qcom_smem_get_free_space); +/** + * qcom_smem_virt_to_phys() - return the physical address associated + * with an smem item pointer (previously returned by qcom_smem_get() + * @p: the virtual address to convert + * + * Returns 0 if the pointer provided is not within any smem region. + */ +phys_addr_t qcom_smem_virt_to_phys(void *p) +{ + unsigned i; + + for (i = 0; i < __smem->num_regions; i++) { + struct smem_region *region = &__smem->regions[i]; + + if (p < region->virt_base) + continue; + if (p < region->virt_base + region->size) { + u64 offset = p - region->virt_base; + + return (phys_addr_t)region->aux_base + offset; + } + } + + return 0; +} +EXPORT_SYMBOL(qcom_smem_virt_to_phys); + static int qcom_smem_get_sbl_version(struct qcom_smem *smem) { struct smem_header *header; diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index c1657ed27b30..86e1b358688a 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -9,4 +9,6 @@ void *qcom_smem_get(unsigned host, unsigned item, size_t *size); int qcom_smem_get_free_space(unsigned host); +phys_addr_t qcom_smem_virt_to_phys(void *p); + #endif -- 2.14.1