From patchwork Wed Apr 25 15:18:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134342 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp996945lji; Wed, 25 Apr 2018 08:18:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ywLMoBnJYZ8/hMrH1JLan5fPF5rjfw7Wm8G7KWRKEQ5vkP0l2ik37PPq6zZB30BpogL2m X-Received: by 2002:a17:902:be06:: with SMTP id r6-v6mr23845513pls.158.1524669528280; Wed, 25 Apr 2018 08:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524669528; cv=none; d=google.com; s=arc-20160816; b=HajQ+MJdyiceM0WVQj3maIhUcWIolvGuZCxuP++pf1BJUvocVvr7/1n7zyzJlx6Tdl 6tER0KBlLwnhvI8s8O6eLPjOtqaP4OFb8mzjlMYI8WdrWYIOpg5aYyaMtenyRfVtQYLf YaxkAhIrZXj8qKws1BAoOMg+sWDGyqIGsoBT5QaaVtubzaFLo808LLVMH956Oqn2YZTn +M09xze3SuS+va0Eu5Vbiaz3gUU2csLioVR30fWUmEyllRcvu9ag9ptkNZzrnJZnAAeK nlVqsVNsG3eW8uwgu04Z2vfLzynt5dAWn+WUG1kmPtPpyaJJVCLKDso31zTVyEbtG9pW DROw== 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=6hV7qoHdf/o56NVohOICeaRLGDgdafhoL7O4Rxs8oVQ=; b=VHmFBAFEH6S2/n9ZnwJ1IrRJNe5K5o0Jw2Bo5Ry485GcvARNV7we8Y7eGFentFA1kY aqelSE8XkVpYNmUIJhhnEtrvCWpXaWDTRoEAMs4Ov4ooqeY1Z4NXiS9Cq80rQAnq4BMD kgTR0toqZD5/v7yOI1OF5GZ1yCIh4OfWYehkpkU2HMYmptN4ynwYQwo4L6iI7t/a1UbY E7Y/Z414CHl+4WuV+6qb4wKC/mWRfzaZelQJIOUWsS/jScaXz6rIYD13A1TUZ2vPCiPG cp6iInUmMaN5JjCIBta+HfplYwC8+u8KWSvBiIYupZpcjh10ImjRKvEZwHPe2lmtgqUr y/qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SekWymAo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 v2si13810729pgf.75.2018.04.25.08.18.48; Wed, 25 Apr 2018 08:18:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SekWymAo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754585AbeDYPSr (ORCPT + 12 others); Wed, 25 Apr 2018 11:18:47 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:41960 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754586AbeDYPSp (ORCPT ); Wed, 25 Apr 2018 11:18:45 -0400 Received: by mail-io0-f194.google.com with SMTP id e12-v6so4235110iob.8 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=a0cKNlXMiN1uM+ePPNZ0Rf2fxS5oIxYTNQ6cQU6Gi7Atv7MdSESlh0Wwx6Tt19Ebie dAYeZ9WhQV0hXAnZHxZQiQXG541WUr9c+QVbbtPpR+1APdKr+5KvdXI0SxQVqrPr9Aj5 dvkW4qpPwgAafYyf/F+oH2S88twIsqn3PS//j16L1+XBZSy6qNWsHBBIPpL39SRrv9Ql KdGgNnHphcTsau2KToQ8Rs+AYW8hGkI/srROcD1NDyJhUT5recgswYh9vdg4knLj+/Nz WR+AYtm1VPLzF6L6WowpsRu9teXuMZetHqg6ruyYEWL1TNkSmQ40i0n9jk00rGO4Fc6U 1Exw== X-Gm-Message-State: ALQs6tA/vzv3JqXBNZ8QwpWAU+Zj07IueGZJNRMaoWJ5u6yjhQiJwQCn YUfSeiUMd4YmZlufTOJshy7gaw== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(+) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bjorn Andersson 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