From patchwork Mon Jun 24 14:35:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 167599 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4311874ilk; Mon, 24 Jun 2019 07:36:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoMRZ7UU2j576qVJTm0LKUx7o0f9ZxhrwCpxRXjQ7Hc1QYy3oB4aspB7EJkGxRcK8ZSqS2 X-Received: by 2002:a17:902:102c:: with SMTP id b41mr97498629pla.204.1561387016957; Mon, 24 Jun 2019 07:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561387016; cv=none; d=google.com; s=arc-20160816; b=DpvwWu/cDhfrJDYBkOKN1IRrpRbI1R+F7NHmIlBhxaU4KMH0GyN+NGtbOXE9gZ9aV8 xdG7w3DV3gkYiQvKId146uJ3Y5SCf/pNNyanJsqv9PqdjVfdb8a9S27bFL+RO6UjF65C 3fd0Vi+EKanupoT3iKBnphWVGrypqnlMClIkvQmpwOonz8y7na+QJyOFlDJz/8ydYOv3 d/pgTJist+o52uZUr8+ytSLKk0ZVOJbOHl4/VNeeXuliUjb9k0r4yPmLTjhgg9qTyF7A NAQ1Dobk9aOcflKsAdIpnsUISSfz6jSNzhPmmfmQCgbdDG+jdLweyPdZX3HkSNrBwSaM YvtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ZrEG8o34TAZKcyMewnNA9kGmfUhEFU6mWpLliqmz2lI=; b=NpPSVuw3rcmEriNBaoTGEy7NsieR/TryuiAPhXdidUw3785XEL2OMBDnR8heda6OTe mq4HjJGwcK6SQKeW2d5BQ1NCt/IIQyrJSyJcih7FfIgvmD5RbWBbjAQXXgAdzB+0s0w5 pAEPqjrjMCy0/SPd9XM+KUDAyvIQiv7cDzsxSw6leUR3lkkfXOZbcMr5wL8+Ru37il2B 9VqI6gyRICIdSyTOseygtYtJRimABeiLzKm7j0tEEATTwSvN9cX1QiKMhM2Ya1wso29N rQ9UxUbqXUaWRC1i0onvA7SpYe/bTsQvN1aAjKftMc27fdsCYB2WNSIq2/xyC70s2LeV wI2Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si10531360plg.122.2019.06.24.07.36.56; Mon, 24 Jun 2019 07:36:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728360AbfFXOgk (ORCPT + 30 others); Mon, 24 Jun 2019 10:36:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:19067 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727627AbfFXOgj (ORCPT ); Mon, 24 Jun 2019 10:36:39 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 116C6F2CF14767A30AAD; Mon, 24 Jun 2019 22:36:37 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Mon, 24 Jun 2019 22:36:28 +0800 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH v2 3/6] lib: logic_pio: Add logic_pio_unregister_range() Date: Mon, 24 Jun 2019 22:35:05 +0800 Message-ID: <1561386908-31884-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1561386908-31884-1-git-send-email-john.garry@huawei.com> References: <1561386908-31884-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a function to unregister a logical PIO range. Logical PIO space can still be leaked when unregistering certain LOGIC_PIO_CPU_MMIO regions, but this acceptable for now since there are no callers to unregister LOGIC_PIO_CPU_MMIO regions, and the logical PIO region allocation scheme would need significant work to improve this. Signed-off-by: John Garry --- include/linux/logic_pio.h | 1 + lib/logic_pio.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) -- 2.17.1 diff --git a/include/linux/logic_pio.h b/include/linux/logic_pio.h index cbd9d8495690..88e1e6304a71 100644 --- a/include/linux/logic_pio.h +++ b/include/linux/logic_pio.h @@ -117,6 +117,7 @@ struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode); unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode, resource_size_t hw_addr, resource_size_t size); int logic_pio_register_range(struct logic_pio_hwaddr *newrange); +void logic_pio_unregister_range(struct logic_pio_hwaddr *range); resource_size_t logic_pio_to_hwaddr(unsigned long pio); unsigned long logic_pio_trans_cpuaddr(resource_size_t hw_addr); diff --git a/lib/logic_pio.c b/lib/logic_pio.c index d0165c88f705..905027574e5d 100644 --- a/lib/logic_pio.c +++ b/lib/logic_pio.c @@ -98,6 +98,20 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) return ret; } +/** + * logic_pio_unregister_range - unregister a logical PIO range for a host + * @range: pointer to the IO range which has been already registered. + * + * Unregister a previously-registered IO range node. + */ +void logic_pio_unregister_range(struct logic_pio_hwaddr *range) +{ + mutex_lock(&io_range_mutex); + list_del_rcu(&range->list); + mutex_unlock(&io_range_mutex); + synchronize_rcu(); +} + /** * find_io_range_by_fwnode - find logical PIO range for given FW node * @fwnode: FW node handle associated with logical PIO range