Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp907688iob; Wed, 4 May 2022 10:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykXZwhrsetYW/niSfS/l0/FtKKvfx88iD/fwAfbW66nbc58Oo1tn0axt2sJvSrSJfPo6pq X-Received: by 2002:a05:6870:c213:b0:ed:efbb:258e with SMTP id z19-20020a056870c21300b000edefbb258emr287719oae.30.1651684974534; Wed, 04 May 2022 10:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651684974; cv=none; d=google.com; s=arc-20160816; b=HSxwDeUYIvV/gLcNzTjvurwE6DJcxPVHQthIF/jp4TiYSv5JFlfVFDw2luXUGV97lI UUG73QoeA6v6DjS+XZ1yaaC4ZIAH3VMgsQicsvMFHJnPGBkc4jCNcqucUOH7ZCrP0WhP hnCPsJ62gg7DaOagCGr3s1XIp7L7rA2iTMpwL5EtfdKBhPhYxxDmXwP5ZSQwht4of6Px W2szkCxZPvcm2MWykLefexLle2jF03X64OZ/rwrpItjis43s81Tx1EEwovCNDW9zr/ZQ FsafTi6XI9JH5dseFcA8YL20W0RjKQ9kwe7R6I6+I3sAKqVgVqvRra3FmxNdOsJagjmg FVGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:user-agent:message-id :subject:cc:to:from:date:mime-version; bh=60bQKYXgT+TD5kqo1WQlaPOIWU/zpRY9fC+pbivYseE=; b=t4XWe6P8tV1OcKNy75Yb7ZaxMK0joIbCHI1d9OnE/3O+G4AytRUeBcIKehsbmTPaHN bexMsfXveqDQMISnKwgq5s6skFGKNx0TC6cNN07TjxsOrbAheXABzOVOSsD6OJ8antBh IwuQfsVT8/yGTOUfbZpZ9eu0rYD9zCMVdG7KekoBFbLcOIhltvk1rb0NY8uuSepdj2K0 sDm8lsa+Cop+L2RSTRYmXbrQzKRTV+EGVpEB95ts+hbXkX7aLHQGdRz0l+ODiQ74L2Ze 5H76nxYWYvWP1zuiWRaUpTZoYi6FJuwbWytfPbtIJQqkQ35irZCJi5I0HyDaZNMRcGlZ yQ9Q== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w189-20020aca62c6000000b00325d0d2ebe4si6931283oib.282.2022.05.04.10.22.39; Wed, 04 May 2022 10:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352191AbiEDPVt (ORCPT + 99 others); Wed, 4 May 2022 11:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346612AbiEDPVb (ORCPT ); Wed, 4 May 2022 11:21:31 -0400 X-Greylist: delayed 1467 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 04 May 2022 08:17:50 PDT Received: from vps19.webwerkers.nl (vps19.webwerkers.nl [136.144.231.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0AC36E26 for ; Wed, 4 May 2022 08:17:50 -0700 (PDT) Received: from [89.255.59.226] (helo=server.mep) by vps19.webwerkers.nl with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nmGNV-000625-O2; Wed, 04 May 2022 16:53:21 +0200 Received: from _ (localhost [127.0.0.1]) by server.mep (Postfix) with ESMTPA id EC363D0FEBA; Wed, 4 May 2022 16:52:53 +0200 (CEST) MIME-Version: 1.0 Date: Wed, 04 May 2022 16:52:53 +0200 From: Indan Zupancic To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] UIO: Let uio_pdrv_genirq support cached memory Message-ID: <436ea1f019d26d28ab4fce4ee28f609b@mep-info.com> X-Sender: indan.zupancic@mep-info.com User-Agent: Roundcube Webmail/1.3.16 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Id: meptelco X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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. --- 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) --