From patchwork Mon Dec 10 21:34:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153363 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4039748ljp; Mon, 10 Dec 2018 13:35:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/VI4l4s0aTeWMaWbt0rYoAVLb8TwWblaUItjmvW3g/3N4ZF/lurNOrgp5c+nwRZJHOEqQDg X-Received: by 2002:a62:a510:: with SMTP id v16mr13800482pfm.18.1544477725995; Mon, 10 Dec 2018 13:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544477725; cv=none; d=google.com; s=arc-20160816; b=NGvRW9VtQ/BbQ/Cr9M2SW+eEsNth0xnJCusL0tiLutIh5DxnK8JHs9/jinBDClHs+t eFtZRGIpqT+BbavK7r8YixUNwVId9mzIhugBlF2mDsEtlgjfXAOU1rqb9m0PSKB6Cxz4 PSckXPf8wE1jpF4cDJHv/jHY+aR997w1wrQDPQM5TW8YwwSh6px73fR/OfRleb7ia29I RrYKrG8j4axc0CLPyewSUYe/guukzKFz+usbigZCsvCNuZeDq8g4DESaUcYOuxRTTKWi fuPxZM2gnkyVR44S7gspuV+/uPUssyd3Ai85oCiOM7cYwx/aQwjyHQa8zhx+qIQqWXDs zg7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MQxxqG+9LmdGAy9IHlE0I2+tuHDpZ85XIa7kKYWnmWE=; b=D9tnwTs6YR9Zmh+ZhqDrpdotmvyQhS9BQ4t19In4VnrlPtojf7IBTlaGdeP3EigMlO yWNmtcTNDJozut2ssyC9rshnxeu17qHRC5lbRu0tvYzF12eXOEwL9hWH1vDdoWk2Aym1 xvhND8n0P5oICD7NZD3fH1L5KM7G3+uJggrEjmkhWviH8pY2rtdm/ZC7TjE+7bE8Q6Lh izGwUBfi4F8dYpTTBIf4n9eDdGvTglpe62aJkLpDgpHVNMPPkxMyTmp0gb8Lqom4Lpi+ OvupGMLtUb1otURhGllX1FknzRrRRg0M4Q7YubQZj6eOpgy0ePCgh+Y0ZVuJN10bR/9n TurQ== 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 y73si9964116pgd.478.2018.12.10.13.35.25; Mon, 10 Dec 2018 13:35:25 -0800 (PST) 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 S1729985AbeLJVfY (ORCPT + 31 others); Mon, 10 Dec 2018 16:35:24 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:57165 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727529AbeLJVfY (ORCPT ); Mon, 10 Dec 2018 16:35:24 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPA (Nemesis) id 1M5xDJ-1gYN9a39XH-007Skp; Mon, 10 Dec 2018 22:35:01 +0100 From: Arnd Bergmann To: Jens Axboe Cc: Arnd Bergmann , Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , Matthew Wilcox , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mtip32xx: avoid using semaphores Date: Mon, 10 Dec 2018 22:34:39 +0100 Message-Id: <20181210213459.1147671-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:bAKGUqjSdfxw9cELQaqHA8DxRoZriOdQDSeLBEhTssFMoerCf3M O1FyQRHjoR+2gzIarvKFEikMF1jbKGKKknlQYmiaIxnUyhdYwiQQ8fIGeDBIN2ktGu+vM/W B0AV1PxsTWK3P41iPsG7vhMPwnUEOtcOJ/wuWNuMRSaybrAKj140+YQ7lYwo/Wo0+79jO6V 7f4MxYWUHsS75CC1JAs+w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:tseO4L7P49I=:QblY4sSgrUoSAFVm+Djb/H THmKDHvccHngbjXF/5W3cpkCftKWWhg4CZeVIS4GmfwGd4fGMLq6pnWxN3dH6nz0KTRZ8O+QB tuNUdVCNbPfTaRjmOuvh2B8SM7zkajmudRq3Edt/jlMeSUx1ow4dG4KNGBojhFfhqe6d4W/NU U9VFtsQNFw7giezr15hgxcefP0E67yOMf1xGfFC/JB2WGwpWnvn5wujvSbASdArzUeYxqbmlm FVAYgVjc2o7oEG+LqVCVbwuGlKacN/Csvp/QwE/K5SMElPZPtm/gz7tFO/708nAf/GrrVxMeQ OyKDNdX9aAC2o7x1KyfVMoxWr2WyUL62LlI5Brjf3EWB94NKrWuiuPQ/DeyENeqokFRfcevjq bkCpwYNSgXuTs2aUnPgtfxBRvXC4v/xQ5FMXU/x/Dg90mtp+cwy2UuwolIBIMNH17dU0lsACn WshZeONdseUmfo7ynfiDAkLZrRUfVQOHVd72dI6vS+zQ/sd6tqNoPXTUZSL01TW650xcGWHbr xZ8bVJg0LU90iobRHYUpPKMpVUEAhpWEWIvTCMHTgjG+EORKiNIreFfbtvsofWOAcrtRY8Fad Co93/KDqx/X3j8IP0vmoOBRf011fC2HM2f1gFowIhEEe7Jch0rTv+6lQ7SeBsjmAu6a7PEIra tYW+td5AMt8Db7Cfa4omZP9yKuNZ28H3rnru0I5+x0vlW1Mhvhwf/iIcJGFIaKcJ6fy6x6vlo j+s4AjbWkjNrkTFc9YYWcjZMkHX3KK6Y0UVulA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The "cmd_slot_unal" semaphore is never used in a blocking way but only as an atomic counter. Change the code to using atomic_dec_if_positive() as a better API. Signed-off-by: Arnd Bergmann --- drivers/block/mtip32xx/mtip32xx.c | 6 +++--- drivers/block/mtip32xx/mtip32xx.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.20.0 diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 2b0ac9d01e51..d7dc307d0cc8 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2680,7 +2680,7 @@ static void mtip_softirq_done_fn(struct request *rq) cmd->direction); if (unlikely(cmd->unaligned)) - up(&dd->port->cmd_slot_unal); + atomic_inc(&dd->port->cmd_slot_unal); blk_mq_end_request(rq, cmd->status); } @@ -2990,7 +2990,7 @@ static int mtip_hw_init(struct driver_data *dd) else dd->unal_qdepth = 0; - sema_init(&dd->port->cmd_slot_unal, dd->unal_qdepth); + atomic_set(&dd->port->cmd_slot_unal, dd->unal_qdepth); /* Spinlock to prevent concurrent issue */ for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++) @@ -3533,7 +3533,7 @@ static bool mtip_check_unal_depth(struct blk_mq_hw_ctx *hctx, cmd->unaligned = 1; } - if (cmd->unaligned && down_trylock(&dd->port->cmd_slot_unal)) + if (cmd->unaligned && atomic_dec_if_positive(&dd->port->cmd_slot_unal) >= 0) return true; return false; diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h index c33f8c3d9fb4..abce25f27f57 100644 --- a/drivers/block/mtip32xx/mtip32xx.h +++ b/drivers/block/mtip32xx/mtip32xx.h @@ -433,8 +433,8 @@ struct mtip_port { */ unsigned long ic_pause_timer; - /* Semaphore to control queue depth of unaligned IOs */ - struct semaphore cmd_slot_unal; + /* Counter to control queue depth of unaligned IOs */ + atomic_t cmd_slot_unal; /* Spinlock for working around command-issue bug. */ spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS];