From patchwork Tue Dec 18 09:26:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10735261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 157BF6C2 for ; Tue, 18 Dec 2018 09:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04A7929AAE for ; Tue, 18 Dec 2018 09:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECE8E29B70; Tue, 18 Dec 2018 09:29:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E50C29AAE for ; Tue, 18 Dec 2018 09:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbeLRJ3e (ORCPT ); Tue, 18 Dec 2018 04:29:34 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55928 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726666AbeLRJ3c (ORCPT ); Tue, 18 Dec 2018 04:29:32 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBI9SWG2101524 for ; Tue, 18 Dec 2018 04:29:31 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pewf52snd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 18 Dec 2018 04:29:30 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Dec 2018 09:29:28 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 18 Dec 2018 09:29:25 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBI9TO4k59637828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Dec 2018 09:29:24 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF4A542042; Tue, 18 Dec 2018 09:29:24 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E8B54203F; Tue, 18 Dec 2018 09:29:24 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.152.224.44]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 18 Dec 2018 09:29:24 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests RFC v3 11/13] s390x: Add sclp busy indication locking Date: Tue, 18 Dec 2018 10:26:55 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181218092657.46466-1-frankja@linux.ibm.com> References: <20181218092657.46466-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18121809-0016-0000-0000-00000238169B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121809-0017-0000-0000-0000329064DF Message-Id: <20181218092657.46466-12-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-18_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=919 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812180085 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With smp CPUs have to compete for sclp. Let's add some locking, so they execute sclp calls in an orderly fashion. Signed-off-by: Janosch Frank --- lib/s390x/sclp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index eed51ef..6b147d1 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "sclp.h" #include @@ -26,6 +27,7 @@ static uint64_t ram_size; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); volatile bool sclp_busy; +static struct spinlock sclp_lock; static void mem_init(phys_addr_t mem_end) { @@ -48,7 +50,9 @@ static void sclp_setup_int(void) void sclp_handle_ext(void) { ctl_clear_bit(0, 9); + spin_lock(&sclp_lock); sclp_busy = false; + spin_unlock(&sclp_lock); } void sclp_wait_busy(void) @@ -60,7 +64,19 @@ void sclp_wait_busy(void) void sclp_mark_busy(void) { + /* + * With multiple CPUs we might need to wait for another CPU's + * request before grabbing the busy indication. + */ +retry_wait: + sclp_wait_busy(); + spin_lock(&sclp_lock); + if (sclp_busy) { + spin_unlock(&sclp_lock); + goto retry_wait; + } sclp_busy = true; + spin_unlock(&sclp_lock); } static void sclp_read_scp_info(ReadInfo *ri, int length)