Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp411843pxb; Tue, 3 Nov 2020 02:58:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSlipkf5DgK07xdDjNN0x6jsVd6Om6J9CfOrsKhRXdyDBRtoFLdXiZ3Str0mHCQDnb7ghN X-Received: by 2002:a17:906:3689:: with SMTP id a9mr19455802ejc.403.1604401137707; Tue, 03 Nov 2020 02:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604401137; cv=none; d=google.com; s=arc-20160816; b=TYWm/cTN1t0V1gH25Gx5l8Kg8qfQcKEDJkvjrJGro+c3sUnRiYpEZNFBOOQwH/8FdH u0rr+gWiypEZkSOtb3z17Euld/FD3XoxRveGeADC3nwaBDAd3wVa7tMf/P6sr38EFJPv G/M4XvjpbeZZafcfDsKAr5MCS7v7OtoVo3awJS+q7iff4nAufVEb/1OnrtoKQCVHCLUc lvl06xvH5IFhIQQZWZonpA0vyemFbRy74u0L0ToobbOUPSPDrUpHVRKdgdmcGVUEwgjE mKXsBAEoo+W4GPtnu5cL1TkhXdcXGlShRiJcKw7zpzjAI0ZWxkKvEdV1yXSe+ZSdMgeN 1vVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=dMgNn0lSWQMza/5Zo8wbqUqbHws/42HxlnbVxnk07gI=; b=yXNE6stwIv4B9RpDiiIEd4cYj2CoU2ekQ+HfGei9eSVXtjqiLEElcFj5lsjmmVlpgF ++79JZNcbljbaMlXz/843kNkqjMFh825yXU2Q27Hu3fyxvYdEJ0RyYsY7hfeKawZUopN xvLaUuP5axmrc/dA7c/z1gfoGGML2stniOwFz+SuA2r3ujv9kO+ikg2aFXZUSUykdo/k jtejYClqtKIzfdl0J4lsAIxV0uStkCekNTf3arUyxrYddLP8LnbChZQaLiDagibwVMRM o0GiV38vYEC5j9uLRP4OzRBnqyqn/5s11xxDAO264lWqpFPwy8C8kMI9l4rroTpSHKvo UE9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2sEeylef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u14si5175377edq.494.2020.11.03.02.58.35; Tue, 03 Nov 2020 02:58:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2sEeylef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728252AbgKCKz1 (ORCPT + 99 others); Tue, 3 Nov 2020 05:55:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgKCKz0 (ORCPT ); Tue, 3 Nov 2020 05:55:26 -0500 Received: from pobox.suse.cz (nat1.prg.suse.com [195.250.132.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3FFC223BD; Tue, 3 Nov 2020 10:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604400925; bh=Gx/xjl1lJ2zVpy4vXYoDX8bz9kjv23h23jTvE3/Hxbg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=2sEeylef5AtEFxa+uyhscnSV6SoxvnPd4MSyfVxYTzKxNFoH0FbBX+085E6KdkwwP 4vV8ZWaOIEwHSTPKOmq8PFRXoe+pcvjYqj/HdrYTsDDnFQke3cisQ+0KvJUx2qYnLz mWIhbwbEF6BRJDWLFqQWq+e9aeJsKvHlXBqVdyrM= Date: Tue, 3 Nov 2020 11:55:22 +0100 (CET) From: Jiri Kosina To: Pascal Giard cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Sanjay Govind Subject: Re: [PATCH] HID: ghlive: support for ghlive ps3/wii u dongles In-Reply-To: Message-ID: References: <20201009022722.123943-1-pascal.giard@etsmtl.ca> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Oct 2020, Pascal Giard wrote: > > > drivers/hid/Kconfig | 6 ++ > > > drivers/hid/Makefile | 1 + > > > drivers/hid/hid-ghlive.c | 220 +++++++++++++++++++++++++++++++++++++++ > > > > Would it make more sense (with respect to how we are structuring/naming > > the hid drivers) to incorporate this into hid-sony (irrespective of > > currently ongoing discussions about actually splitting that driver :) )? > > > > I think it would be most appropriate, yes. > > Note that there are 3 other dongles out there: > - the xbox360 dongle does not need any special treatment, it just > works with hid-generic; > - the ps4 dongle obviously makes sense to go into hid-sony (although > no one has reversed engineered that one (yet)); > - the xboxone dongle: that's an unknown one to me. I don't have any > information about that one unfortunately and do not own one. > > I wrote this as a separate hid driver as I saw that email [1] from > Roderick Colenbrander in which he expressed a preference for a > seperate driver in cases where the device is not from Sony proper. Yeah, but before that happens, I think we should just continue with status quo, meaning putting the support into hid-sony, if noone has any objections. > > So if one of the allocations above succeeds and a subsequent one fails, > > you're going to try re-allocate all of them next time again, leaking the > > ones that previously succeeded, right? > > > > I attempted to avoid such a case. IIUC there are 4 possible scenarios > tied to those 3 allocs (cr, databuf, and urb): > 1) alloc of cr fails. nothing to be freed, we reschedule; > 2) alloc of cr succeeds, alloc of databuf fails. we free cr and we reschedule; > 3) allocs of cr and databuf succeed, alloc of urb fails. we free cr > and databuf, and we reschedule; > 4) all allocs succeed, we submit the urb, and free urb. once the > control packet is sent, the callback is called and we free cr and > databuf. > > Am I missing something? No, I probably didn't have my first coffee of the day when looking at your patch, sorry. Still, the way it tries to allocate the buffers is sub-optimal, as if either (not necessarily the first one) fails, it retries the next iteration with attempting to allocate from scratch. If the system really is in tight memory condition, it'd make more sense to keep the ones for which the allocation succeeded already allocated, and retry only the failed one(s). Thanks, -- Jiri Kosina SUSE Labs