Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4720305iob; Sun, 8 May 2022 23:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxialNzNyfOjheLj21htXfAkyS/XQtveZ1eU9WWFdxussT0rnris7CZcMPSRJaj/Ht/y+Kw X-Received: by 2002:a17:902:a382:b0:158:f7a9:62a0 with SMTP id x2-20020a170902a38200b00158f7a962a0mr14783544pla.74.1652076689454; Sun, 08 May 2022 23:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652076689; cv=none; d=google.com; s=arc-20160816; b=0HTIsAaPT6l/fmWpEVmudfDSl1zoMCY7HqA5TcKY3wWM4tV3095QCZvZj0OvAmLK3d BFM/X9wvp3CC8NGFc1js/uNCjOHwiLbTOKyTCrst8rz2qARjCsL3NhciQJirbXwPBb0O VslqVqTmHlxrjWQhNlHBXWq91VRXI/pbOPOQqvdvGygVE9s7e35BYcxf8lH32bemFTex yqjSTOWjQVz3U4wU2ct8BOUi9yQ5/2MNYNJ6kEgBres9XNsqaiXV1JZ75USozGZ8JCRO WioSntxBkr3lSQ4DjFh43fX+wrsbEl2ELMsHHaKKGs48e5XGPiI7ZLJ0dOvZBlCzhnWd YexQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/0uTfLMAGHfvYrD5Q0nkpz3r5eKsJGBJfRi4HcVFeg4=; b=VPJYJoC9fYXvIpDUHkYJ8CFdny5pkunRIzZbME+Cgoml+LZgLAUJ4ynQpqNnvkbmsU AAZtJ0X6/A7c/+8Gtf/A51uF6vVpJIsOGULyMiwJdpTJ6Mk2TYW+5czn+PUS1zZq6cRK Fl7tBE1ubdTHnTO0arU/JtLDUDPWaL7ubqViO3a7KcdKQdAoHNIh3eztGbJ7nDkmv/LI HIETySZ/tj0TnsNEtmF//9wxz+KJuNbIGyIxM08XiLsPqaQTzRNH59PUCXHd8MyidGDE vnpMhkQ1rE5pOzlEH54ArNc1DDAH/txPMVopxdzQyIVs+pya3HK5sMi3JFAP8/wbSdyn VOUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e16-20020a63d950000000b00399149a5d14si14508442pgj.205.2022.05.08.23.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1101494193; Sun, 8 May 2022 23:10:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376853AbiEEMeu (ORCPT + 99 others); Thu, 5 May 2022 08:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376779AbiEEMek (ORCPT ); Thu, 5 May 2022 08:34:40 -0400 X-Greylist: delayed 906 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 05 May 2022 05:31:01 PDT Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B46F4B1F0 for ; Thu, 5 May 2022 05:31:01 -0700 (PDT) From: Indan Zupancic To: Greg Kroah-Hartman Cc: Indan Zupancic , linux-kernel@vger.kernel.org Subject: [PATCH v2] UIO: Let uio_pdrv_genirq support cached memory Date: Thu, 5 May 2022 14:15:19 +0200 Message-Id: <20220505121518.46054-1-Indan.Zupancic@mep-info.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <436ea1f019d26d28ab4fce4ee28f609b@mep-info.com> References: <436ea1f019d26d28ab4fce4ee28f609b@mep-info.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-As-Hash: ffa5b08e093a8a3dd7ef4f7d7b64ba463f993468 X-Virus-Scanned: by clamav at smarthost1.greenhost.nl X-Spam-Score: -0.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Scan-Signature: 353bb18b0f14186cd389c275975c39f5 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If 'cacheable' DT property exists, the memory mapping will be done with UIO_MEM_IOVA instead of the default UIO_MEM_PHYS. Signed-off-by: Indan Zupancic --- Documentation/driver-api/uio-howto.rst | 3 ++- drivers/uio/uio_pdrv_genirq.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/driver-api/uio-howto.rst b/Documentation/driver-api/uio-howto.rst index 907ffa3b38f5..3cb48fc757d9 100644 --- a/Documentation/driver-api/uio-howto.rst +++ b/Documentation/driver-api/uio-howto.rst @@ -413,7 +413,8 @@ probed with the ``"of_id"`` module parameter set to the ``"compatible"`` string of the node the driver is supposed to handle. By default, the node's name (without the unit address) is exposed as name for the UIO device in userspace. To set a custom name, a property named -``"linux,uio-name"`` may be specified in the DT node. +``"linux,uio-name"`` may be specified in the DT node. If a property +named ``cacheable`` exists, the memory will be mapped cacheable. Using uio_dmem_genirq for platform devices ------------------------------------------ diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c index 63258b6accc4..269784ce0ba3 100644 --- a/drivers/uio/uio_pdrv_genirq.c +++ b/drivers/uio/uio_pdrv_genirq.c @@ -115,6 +115,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev) struct uio_mem *uiomem; int ret = -EINVAL; int i; + int memtype = UIO_MEM_PHYS; if (node) { const char *name; @@ -132,7 +133,10 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev) else uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn", node); - + if (of_get_property(node, "cacheable", NULL)) { + dev_info(&pdev->dev, "%s cacheable\n", uioinfo->name); + memtype = UIO_MEM_IOVA; + } uioinfo->version = "devicetree"; /* Multiple IRQs are not supported */ } @@ -204,7 +208,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev) break; } - uiomem->memtype = UIO_MEM_PHYS; + uiomem->memtype = memtype; uiomem->addr = r->start & PAGE_MASK; uiomem->offs = r->start & ~PAGE_MASK; uiomem->size = (uiomem->offs + resource_size(r) -- 2.30.2