Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4040546ybg; Fri, 25 Oct 2019 12:27:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0UzbdkTKVUcSsnDtnkA7UFBjcxcU5wbJ0dh8WW90mwBBbkVGfVb/8aA2b4QEzQYbvjIQ7 X-Received: by 2002:a50:fc18:: with SMTP id i24mr5780879edr.42.1572031660735; Fri, 25 Oct 2019 12:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572031660; cv=none; d=google.com; s=arc-20160816; b=svkm2IYunb/SKRV3P6++ibsmRQYwisvgHqXCzXacV675L3DbEP42QjQtjSiJqA13GI kehzFcexjBOtUJdmrIaR9ysxZCIvlRpUX3HIEhLoAYHQl8f+ANJRa/8BnFMP9G1KXGe0 MYALNKchvwnqkl1EJsRAPdTka9fyAQXV2xiEsCgIy5DPAy1jAOixnWSCjefkqTOPDhNY PDurL6WRW7ouKjnXB2t3pO+PpFJ5a9YUM7bn4atgovqUrHYluNJxptTqK+z8vv7TrUSS ZQ11qlhCUhGOPgh9vnlU8c54qYGJgZIH06+Z8DyUInJ91sHSW9gNzZKrRzO+yvI4Scep zh5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6A6igi+iIahcN2i7nqFwvDHaOIrrC7kc9SulvaWb1t0=; b=b7R/LWKYbQDkAAqrTOVPJe+EqrgDV5mSPAmmIs8Nn6I1A+xG+7nHgPZjkSP9X/p+Sv YDRRuhg4YtBDxsUoSDtB9T/Pjy9QGUUJg5vqKx+Kx6XCzwoRgEEVTIIfj98etLLnAY5d lr4IIYLvhkW0XOuWW3hCToM88EyhBOexkVZIxsmss8diwgg4VWylYaQFuhXtFjJFwfFv p2VYOYGO9pyfYf/mJxbkP0i5HfWWxRBUioVa5s6PpfYN0S2p3J9vvpEoe9d9kDuR/oNo GfUDvQMesxJO1C9XfM/5yJyumPvSAq5PJ6I/iTQjK3z0AqsgY4PMt9ey6pCIEYRhrR1W kNqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eMiPHVZU; 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 e15si1715433ejq.269.2019.10.25.12.27.17; Fri, 25 Oct 2019 12:27:40 -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=eMiPHVZU; 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 S2407060AbfJYHfn (ORCPT + 99 others); Fri, 25 Oct 2019 03:35:43 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38382 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406923AbfJYHfn (ORCPT ); Fri, 25 Oct 2019 03:35:43 -0400 Received: by mail-wr1-f68.google.com with SMTP id v9so1094898wrq.5 for ; Fri, 25 Oct 2019 00:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=6A6igi+iIahcN2i7nqFwvDHaOIrrC7kc9SulvaWb1t0=; b=eMiPHVZUMZHiiC3b4wO8fkj4sOT4J8cQT/B7pTI+nYvnYmtef30uo9xxiPHTDLQ5OH p1K+uv8OkW0Z4+Kk0Tns6Ry1uk+qekivivWeZV5mil3cYc2J06xyu99Q13F36NeSDlFJ rCwL2/2JJ/GHtnlog9n0EAP+hWde6vBnc1/wchD+xtgxxg/12KbLv8zkavTCEwK2iFsA euMXFexUNw+UqcOh1hGHC/S+9XxBlELQihI0O1c3+IXjt7+5Y8y1iS2pCgejUvYGtOiv tec/DUnVsEEciNCVkbSGwBxfjhhW+CVVJyU6ZIQEf0ECvNkxNj+Dx6J4dObCthj1q831 QgUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=6A6igi+iIahcN2i7nqFwvDHaOIrrC7kc9SulvaWb1t0=; b=WOQazdEy+gAjxRFn0506mXOr42CC+EBQ1gyKZGbngseEVWN+/QE5ONE0loFbrzYhgf gGjyLXALcI7IrDR/LlXTe7yIvTp7YAXoEIpoIRgk9hMgWHGqv6Mrvfl8TRNVvj7jOu2a GzGCWbvgkRk89u9s0gRx9RwAWiDL3RLwQVp6FUQOyn+5pznvP7P/vdVt0foHE1vsPdWX 54KDeUhyu19bGmJvCvyrX+t5RQ6YJyDbLMOcsOJJLC+xVSWpXcGKHJYaV1YdlwugS7J5 5A2yTJPWvZawPKQUkswxfl8fu+9SXfYbFI5Xs019Gm4oO80CLqYp6lX55F9hbydjPn/0 ftRA== X-Gm-Message-State: APjAAAX9pfOdhUAaMu7mPO52gvkwaELCpaAPjYa1jzvimscavn1wVz5b 3fXzcszxtEQoNonyI4eJYrVbBw== X-Received: by 2002:adf:a50b:: with SMTP id i11mr1590050wrb.308.1571988941205; Fri, 25 Oct 2019 00:35:41 -0700 (PDT) Received: from lophozonia ([85.195.192.192]) by smtp.gmail.com with ESMTPSA id l26sm592473wmg.3.2019.10.25.00.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 00:35:40 -0700 (PDT) Date: Fri, 25 Oct 2019 09:35:38 +0200 From: Jean-Philippe Brucker To: "zhangfei.gao@foxmail.com" Cc: Zhangfei Gao , Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , jonathan.cameron@huawei.com, grant.likely@arm.com, ilias.apalodimas@linaro.org, francois.ozog@linaro.org, kenneth-lee-2012@foxmail.com, Wangzhou , "haojian . zhuang" , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Kenneth Lee , Zaibo Xu Subject: Re: [PATCH v6 2/3] uacce: add uacce driver Message-ID: <20191025073538.GC503659@lophozonia> References: <1571214873-27359-1-git-send-email-zhangfei.gao@linaro.org> <1571214873-27359-3-git-send-email-zhangfei.gao@linaro.org> <20191016172802.GA1533448@lophozonia> <5da9a9cd.1c69fb81.9f8e8.60faSMTPIN_ADDED_BROKEN@mx.google.com> <20191023074227.GA264888@lophozonia> <5db25e56.1c69fb81.4fe57.380cSMTPIN_ADDED_BROKEN@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5db25e56.1c69fb81.4fe57.380cSMTPIN_ADDED_BROKEN@mx.google.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 25, 2019 at 10:28:30AM +0800, zhangfei.gao@foxmail.com wrote: > > Something else I noticed is uacce_idr isn't currently protected. The IDR > > API expected the caller to use its own locking scheme. You could replace > > it with an xarray, which I think is preferred to IDR now and provides a > > xa_lock. > Currently  idr_alloc and idr_remove are simply protected by uacce_mutex, Ah right, but idr_find() also needs to be protected? > Will check xarray, looks it is more complicated then idr. Having tried both, it can easily replace idr. For uacce I think it could be something like (locking included): static DEFINE_XARRAY_ALLOC(uacce_xa); uacce = xa_load(&uacce_xa, iminor(inode)); ret = xa_alloc(&uacce_xa, &uacce->dev_id, uacce, xa_limit_32b, GFP_KERNEL); xa_erase(&uacce_xa, uacce->dev_id); Thanks, Jean